Skip to content

Commit

Permalink
feat(sdk): added support for issuer metadata in JS SDK (#583)
Browse files Browse the repository at this point in the history
  • Loading branch information
birtony authored Sep 1, 2023
1 parent dbd1a6d commit e878d55
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions cmd/wallet-sdk-js/jsinterop/types/openid4ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ SPDX-License-Identifier: Apache-2.0
package types

import (
"encoding/json"
"fmt"
"syscall/js"

Expand All @@ -24,6 +25,7 @@ const (
openid4ciRequestCredentialWithPreAuth = "requestCredentialWithPreAuth"
openid4ciPreAuthorizedCodeGrantParams = "preAuthorizedCodeGrantParams"
openid4ciIssuerURI = "issuerURI"
openid4ciIssuerMetadata = "issuerMetadata"
)

func SerializeOpenID4CIIssuerInitiatedInteraction(agentMethodsRunner *jssupport.AsyncRunner,
Expand All @@ -33,6 +35,25 @@ func SerializeOpenID4CIIssuerInitiatedInteraction(agentMethodsRunner *jssupport.
openid4ciIssuerURI: js.FuncOf(func(this js.Value, args []js.Value) any {
return interaction.Interaction.IssuerURI()
}),
openid4ciIssuerMetadata: agentMethodsRunner.CreateAsyncFunc(func(this js.Value, args []js.Value) (any, error) {
issuerMetadata, err := interaction.Interaction.IssuerMetadata()
if err != nil {
return nil, err
}
supportedCredentialsBytes, err := json.Marshal(issuerMetadata.CredentialsSupported)
if err != nil {
return nil, err
}
localizedIssuerDisplaysBytes, err := json.Marshal(issuerMetadata.LocalizedIssuerDisplays)
if err != nil {
return nil, err
}
return map[string]interface{}{
"credentialIssuer": issuerMetadata.CredentialIssuer,
"supportedCredentials": string(supportedCredentialsBytes),
"localizedIssuerDisplays": string(localizedIssuerDisplaysBytes),
}, nil
}),
openid4ciPreAuthorizedCodeGrantParams: agentMethodsRunner.CreateAsyncFunc(func(this js.Value, args []js.Value) (any, error) {
params, err := interaction.Interaction.PreAuthorizedCodeGrantParams()
if err != nil {
Expand Down

0 comments on commit e878d55

Please sign in to comment.