diff --git a/discovery/client.go b/discovery/client.go index 09e2c6556..059181c44 100644 --- a/discovery/client.go +++ b/discovery/client.go @@ -227,8 +227,7 @@ func (r *defaultClientRegistrationManager) deactivate(ctx context.Context, servi func (r *defaultClientRegistrationManager) deregisterPresentation(ctx context.Context, subjectDID did.DID, service ServiceDefinition, vp vc.VerifiablePresentation) error { presentation, err := r.buildPresentation(ctx, subjectDID, service, nil, map[string]interface{}{ "retract_jti": vp.ID.String(), - "type": []ssi.URI{vc.VerifiablePresentationTypeV1URI(), retractionPresentationType}, // this overrides the default 'type' so must include all types - }) + }, &retractionPresentationType) if err != nil { return err } @@ -264,15 +263,18 @@ func (r *defaultClientRegistrationManager) findCredentialsAndBuildPresentation(c return nil, fmt.Errorf(errStr, service.ID, subjectDID, err) } - return r.buildPresentation(ctx, subjectDID, service, matchingCredentials, nil) + return r.buildPresentation(ctx, subjectDID, service, matchingCredentials, nil, nil) } -func (r *defaultClientRegistrationManager) buildPresentation(ctx context.Context, subjectDID did.DID, service ServiceDefinition, - credentials []vc.VerifiableCredential, additionalProperties map[string]interface{}) (*vc.VerifiablePresentation, error) { +func (r *defaultClientRegistrationManager) buildPresentation(ctx context.Context, subjectDID did.DID, service ServiceDefinition, credentials []vc.VerifiableCredential, additionalProperties map[string]interface{}, additionalVPType *ssi.URI) (*vc.VerifiablePresentation, error) { nonce := nutsCrypto.GenerateNonce() // Make sure the presentation is not valid for longer than the max validity as defined by the Service Definitio. expires := time.Now().Add(time.Duration(service.PresentationMaxValidity-1) * time.Second).Truncate(time.Second) holderURI := subjectDID.URI() + var additionalVPTypes []ssi.URI + if additionalVPType != nil { + additionalVPTypes = append(additionalVPTypes, *additionalVPType) + } return r.vcr.Wallet().BuildPresentation(ctx, credentials, holder.PresentationOptions{ ProofOptions: proof.ProofOptions{ Created: time.Now(), @@ -281,8 +283,9 @@ func (r *defaultClientRegistrationManager) buildPresentation(ctx context.Context Nonce: &nonce, AdditionalProperties: additionalProperties, }, - Format: vc.JWTPresentationProofFormat, - Holder: &holderURI, + AdditionalTypes: additionalVPTypes, + Format: vc.JWTPresentationProofFormat, + Holder: &holderURI, }, &subjectDID, false) } diff --git a/discovery/client_test.go b/discovery/client_test.go index 5cabb6967..928722e41 100644 --- a/discovery/client_test.go +++ b/discovery/client_test.go @@ -20,7 +20,6 @@ package discovery import ( "context" - "encoding/json" "errors" "github.com/lestrrat-go/jwx/v2/jwt" "github.com/nuts-foundation/go-did/did" @@ -223,9 +222,7 @@ func Test_defaultClientRegistrationManager_deactivate(t *testing.T) { ctx.invoker.EXPECT().Register(gomock.Any(), gomock.Any(), gomock.Any()) ctx.wallet.EXPECT().BuildPresentation(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), false).DoAndReturn( func(ctx context.Context, credentials []vc.VerifiableCredential, options holder.PresentationOptions, signerDID *did.DID, validateVC bool) (*vc.VerifiablePresentation, error) { - bs, err := json.Marshal(options.ProofOptions.AdditionalProperties["type"]) - require.NoError(t, err) - assert.Contains(t, string(bs), retractionPresentationType.String()) + assert.Equal(t, options.AdditionalTypes[0], retractionPresentationType) return &vpAlice, nil // not a revocation VP }) ctx.subjectManager.EXPECT().ListDIDs(gomock.Any(), aliceSubject).Return([]did.DID{aliceDID}, nil)