Skip to content

Commit

Permalink
refactor(sdk): support for ldp_vp proof types (#857)
Browse files Browse the repository at this point in the history
Signed-off-by: Andrii Holovko <[email protected]>
  • Loading branch information
aholovko authored Jan 3, 2025
1 parent ad7f959 commit b6f80ed
Show file tree
Hide file tree
Showing 11 changed files with 472 additions and 447 deletions.
10 changes: 0 additions & 10 deletions cmd/wallet-sdk-gomobile/openid4vp/interaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,16 +286,6 @@ func toGoAPIOpts(opts *Opts) ([]openid4vp.Opt, error) {
goAPIOpts = append(goAPIOpts, openid4vp.WithMetricsLogger(mobileMetricsLoggerWrapper))
}

if opts.kms != nil {
signer, err := opts.kms.GoAPILocalKMS.AriesSuite.KMSCryptoSigner()
if err != nil {
return nil, fmt.Errorf("aries local crypto suite missing support for signing: %w", err)
}

goAPIOpts = append(goAPIOpts,
openid4vp.WithDIProofs(signer))
}

return goAPIOpts, nil
}

Expand Down
37 changes: 7 additions & 30 deletions cmd/wallet-sdk-gomobile/openid4vp/interaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,19 @@ import (
"strings"
"testing"

"github.com/trustbloc/kms-go/doc/jose/jwk"
wrapperapi "github.com/trustbloc/kms-go/wrapper/api"

gomobdid "github.com/trustbloc/wallet-sdk/cmd/wallet-sdk-gomobile/did"
"github.com/trustbloc/wallet-sdk/cmd/wallet-sdk-gomobile/metricslogger/stderr"
goapilocalkms "github.com/trustbloc/wallet-sdk/pkg/localkms"

"github.com/trustbloc/wallet-sdk/cmd/wallet-sdk-gomobile/activitylogger/mem"

"github.com/trustbloc/wallet-sdk/cmd/wallet-sdk-gomobile/localkms"

"github.com/piprate/json-gold/ld"
"github.com/stretchr/testify/require"
"github.com/trustbloc/did-go/doc/did"
"github.com/trustbloc/kms-go/doc/jose/jwk"
wrapperapi "github.com/trustbloc/kms-go/wrapper/api"
"github.com/trustbloc/vc-go/presexch"
afgoverifiable "github.com/trustbloc/vc-go/verifiable"

"github.com/trustbloc/wallet-sdk/cmd/wallet-sdk-gomobile/activitylogger/mem"
"github.com/trustbloc/wallet-sdk/cmd/wallet-sdk-gomobile/api"
gomobdid "github.com/trustbloc/wallet-sdk/cmd/wallet-sdk-gomobile/did"
"github.com/trustbloc/wallet-sdk/cmd/wallet-sdk-gomobile/localkms"
"github.com/trustbloc/wallet-sdk/cmd/wallet-sdk-gomobile/metricslogger/stderr"
"github.com/trustbloc/wallet-sdk/cmd/wallet-sdk-gomobile/verifiable"
"github.com/trustbloc/wallet-sdk/internal/testutil"
"github.com/trustbloc/wallet-sdk/pkg/models"
Expand Down Expand Up @@ -107,24 +102,6 @@ func TestNewInteraction(t *testing.T) {
})
})

t.Run("Failure - kms crypto suite does not support signing for DI proofs", func(t *testing.T) {
requiredArgs := NewArgs(
requestObjectJWT,
&mockCrypto{},
&mockDIDResolver{},
)

opts := NewOpts()

localKMS := &localkms.KMS{GoAPILocalKMS: &goapilocalkms.LocalKMS{AriesSuite: &mockSuite{}}}

opts.EnableAddingDIProofs(localKMS)

instance, err := NewInteraction(requiredArgs, opts)
testutil.RequireErrorContains(t, err, "aries local crypto suite missing support for signing")
require.Nil(t, instance)
})

t.Run("Failure - invalid authorization request", func(t *testing.T) {
requiredArgs := NewArgs(
requestObjectJWT,
Expand Down Expand Up @@ -467,7 +444,7 @@ func (o *mockGoAPIInteraction) CustomScope() []string {
func (o *mockGoAPIInteraction) PresentCredential(
[]*afgoverifiable.Credential,
openid4vp.CustomClaims,
...openid4vp.PresentOpt,
...openid4vp.PresentOpt,
) error {
return o.PresentCredentialErr
}
Expand Down
1 change: 1 addition & 0 deletions cmd/wallet-sdk-gomobile/openid4vp/opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ func (o *Opts) DisableOpenTelemetry() *Opts {

// EnableAddingDIProofs enables the adding of data integrity proofs to presentations sent to the verifier. It requires
// a KMS to be passed in.
// Deprecated: DI proofs are now enabled by default. Their usage depends on the proof types supported by the verifier.
func (o *Opts) EnableAddingDIProofs(kms *localkms.KMS) *Opts {
o.kms = kms

Expand Down
Loading

0 comments on commit b6f80ed

Please sign in to comment.