-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sdk): id token custom claims (#655)
feat(sdk): id_token custom claims. Signed-off-by: Volodymyr Kubiv <[email protected]>
- Loading branch information
Showing
17 changed files
with
336 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1465,6 +1465,18 @@ val preferredVC = savedCredentials.atIndex(0) | |
interaction.presentCredentialUnsafe(preferredVC) | ||
``` | ||
|
||
###### Read scope and add custom scope claims | ||
|
||
```kotlin | ||
|
||
val scope = interaction.scope() | ||
|
||
interaction.presentCredentialWithOpts(selectedCredentials, PresentCredentialOpts() | ||
.addScopeClaim("registration", """{"email", "[email protected]"}""")) | ||
|
||
``` | ||
|
||
|
||
#### Swift (iOS) | ||
|
||
```swift | ||
|
@@ -1514,6 +1526,18 @@ let preferredVC = savedCredentials.atIndex(0) | |
interaction.presentCredentialUnsafe(preferredVC) | ||
``` | ||
|
||
###### Read scope and add custom scope claims | ||
|
||
```swift | ||
|
||
val scope = interaction.scope() | ||
|
||
let opts = Openid4vpNewPresentCredentialOpts()?.addScopeClaim("registration", #"{"email", "[email protected]"}"#) | ||
|
||
try interaction.presentCredentialWithOpts(selectedCredentials, opts) | ||
|
||
``` | ||
|
||
### Error Codes & Troubleshooting Tips | ||
|
||
| Error | Possible Reasons | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
Copyright Gen Digital Inc. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package openid4vp | ||
|
||
// Scope represents an array of scope strings. | ||
// Since arrays and slices are not compatible with gomobile, this type acts as a wrapper around a Go array of strings. | ||
type Scope struct { | ||
scope []string | ||
} | ||
|
||
// NewScope creates Scope object from array of scopes. | ||
func NewScope(scope []string) *Scope { | ||
return &Scope{scope: scope} | ||
} | ||
|
||
// Length returns the number scopes. | ||
func (s *Scope) Length() int { | ||
return len(s.scope) | ||
} | ||
|
||
// AtIndex returns scope by index. | ||
func (s *Scope) AtIndex(index int) string { | ||
return s.scope[index] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
Copyright Gen Digital Inc. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package openid4vp_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/trustbloc/wallet-sdk/cmd/wallet-sdk-gomobile/openid4vp" | ||
) | ||
|
||
func TestNewScope(t *testing.T) { | ||
scope := openid4vp.NewScope([]string{"scope1", "scope2"}) | ||
|
||
require.Equal(t, 2, scope.Length()) | ||
require.Equal(t, "scope1", scope.AtIndex(0)) | ||
require.Equal(t, "scope2", scope.AtIndex(1)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.