diff --git a/openid4vc/types.go b/openid4vc/types.go deleted file mode 100644 index b75973668e..0000000000 --- a/openid4vc/types.go +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Nuts node - * Copyright (C) 2021 Nuts community - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -// openid4vc contains common constants and logic for OpenID4VCI, SiopV2 and OpenID4VP -package openid4vc - -// VerifiableCredentialJSONLDFormat defines the JSON-LD format identifier for Verifiable Credentials. -const VerifiableCredentialJSONLDFormat = "ldp_vc" - -// VerifiablePresentationJSONLDFormat defines the JSON-LD format identifier for Verifiable Presentations. -const VerifiablePresentationJSONLDFormat = "ldp_vp" - -// VerifiablePresentationJWTFormat defines the JWT format identifier for Verifiable Presentations. -const VerifiablePresentationJWTFormat = "jwt_vp" diff --git a/vcr/api/openid4vci/v0/holder_test.go b/vcr/api/openid4vci/v0/holder_test.go index 80b74fd29f..5809b034be 100644 --- a/vcr/api/openid4vci/v0/holder_test.go +++ b/vcr/api/openid4vci/v0/holder_test.go @@ -23,7 +23,7 @@ import ( "encoding/json" ssi "github.com/nuts-foundation/go-did" "github.com/nuts-foundation/go-did/did" - "github.com/nuts-foundation/nuts-node/openid4vc" + "github.com/nuts-foundation/go-did/vc" "github.com/nuts-foundation/nuts-node/vcr" "github.com/nuts-foundation/nuts-node/vcr/holder" "github.com/nuts-foundation/nuts-node/vcr/openid4vci" @@ -85,7 +85,7 @@ func TestWrapper_HandleCredentialOffer(t *testing.T) { CredentialIssuer: issuerDID.String(), Credentials: []openid4vci.OfferedCredential{ { - Format: openid4vc.VerifiableCredentialJSONLDFormat, + Format: vc.JSONLDCredentialProofFormat, CredentialDefinition: &openid4vci.CredentialDefinition{ Context: []ssi.URI{ssi.MustParseURI("a"), ssi.MustParseURI("b")}, Type: []ssi.URI{ssi.MustParseURI("VerifiableCredential"), ssi.MustParseURI("HumanCredential")}, diff --git a/vcr/api/openid4vci/v0/issuer.go b/vcr/api/openid4vci/v0/issuer.go index 77e3c24731..193f5c0455 100644 --- a/vcr/api/openid4vci/v0/issuer.go +++ b/vcr/api/openid4vci/v0/issuer.go @@ -23,7 +23,7 @@ import ( "encoding/json" "errors" "fmt" - "github.com/nuts-foundation/nuts-node/openid4vc" + "github.com/nuts-foundation/go-did/vc" "github.com/nuts-foundation/nuts-node/vcr/issuer" "github.com/nuts-foundation/nuts-node/vcr/openid4vci" "net/http" @@ -108,7 +108,7 @@ func (w Wrapper) RequestCredential(ctx context.Context, request RequestCredentia } return RequestCredential200JSONResponse(CredentialResponse{ Credential: &credentialMap, - Format: openid4vc.VerifiableCredentialJSONLDFormat, + Format: vc.JSONLDCredentialProofFormat, }), nil } diff --git a/vcr/holder/openid.go b/vcr/holder/openid.go index ffabe98811..151a8171ba 100644 --- a/vcr/holder/openid.go +++ b/vcr/holder/openid.go @@ -23,7 +23,6 @@ import ( "errors" "fmt" "github.com/nuts-foundation/nuts-node/auth/oauth" - "github.com/nuts-foundation/nuts-node/openid4vc" "net/http" "time" @@ -96,7 +95,7 @@ func (h *openidHandler) HandleCredentialOffer(ctx context.Context, offer openid4 } } offeredCredential := offer.Credentials[0] - if offeredCredential.Format != openid4vc.VerifiableCredentialJSONLDFormat { + if offeredCredential.Format != vc.JSONLDCredentialProofFormat { return openid4vci.Error{ Err: fmt.Errorf("credential offer: unsupported format '%s'", offeredCredential.Format), Code: openid4vci.UnsupportedCredentialType, @@ -213,7 +212,7 @@ func (h *openidHandler) retrieveCredential(ctx context.Context, issuerClient ope credentialRequest := openid4vci.CredentialRequest{ CredentialDefinition: offer, - Format: openid4vc.VerifiableCredentialJSONLDFormat, + Format: vc.JSONLDCredentialProofFormat, Proof: &openid4vci.CredentialRequestProof{ Jwt: proof, ProofType: "jwt", diff --git a/vcr/holder/openid_test.go b/vcr/holder/openid_test.go index 2856ed2982..11d013a292 100644 --- a/vcr/holder/openid_test.go +++ b/vcr/holder/openid_test.go @@ -28,7 +28,6 @@ import ( "github.com/nuts-foundation/nuts-node/auth/oauth" "github.com/nuts-foundation/nuts-node/core" "github.com/nuts-foundation/nuts-node/crypto" - "github.com/nuts-foundation/nuts-node/openid4vc" "github.com/nuts-foundation/nuts-node/vcr/openid4vci" "github.com/nuts-foundation/nuts-node/vcr/types" "github.com/nuts-foundation/nuts-node/vdr/resolver" @@ -275,7 +274,7 @@ func Test_wallet_HandleCredentialOffer(t *testing.T) { // offeredCredential returns a structure that can be used as CredentialOffer.Credentials, func offeredCredential() []openid4vci.OfferedCredential { return []openid4vci.OfferedCredential{{ - Format: openid4vc.VerifiableCredentialJSONLDFormat, + Format: vc.JSONLDCredentialProofFormat, CredentialDefinition: &openid4vci.CredentialDefinition{ Context: []ssi.URI{ ssi.MustParseURI("https://www.w3.org/2018/credentials/v1"), diff --git a/vcr/issuer/openid.go b/vcr/issuer/openid.go index 889460d628..423cb0cf03 100644 --- a/vcr/issuer/openid.go +++ b/vcr/issuer/openid.go @@ -32,7 +32,6 @@ import ( "github.com/nuts-foundation/nuts-node/audit" "github.com/nuts-foundation/nuts-node/core" "github.com/nuts-foundation/nuts-node/crypto" - "github.com/nuts-foundation/nuts-node/openid4vc" "github.com/nuts-foundation/nuts-node/storage" "github.com/nuts-foundation/nuts-node/vcr/issuer/assets" "github.com/nuts-foundation/nuts-node/vcr/log" @@ -208,7 +207,7 @@ func (i *openidHandler) OfferCredential(ctx context.Context, credential vc.Verif } func (i *openidHandler) HandleCredentialRequest(ctx context.Context, request openid4vci.CredentialRequest, accessToken string) (*vc.VerifiableCredential, error) { - if request.Format != openid4vc.VerifiableCredentialJSONLDFormat { + if request.Format != vc.JSONLDCredentialProofFormat { return nil, openid4vci.Error{ Err: fmt.Errorf("credential request: unsupported format '%s'", request.Format), Code: openid4vci.UnsupportedCredentialType, @@ -409,7 +408,7 @@ func (i *openidHandler) createOffer(ctx context.Context, credential vc.Verifiabl offer := openid4vci.CredentialOffer{ CredentialIssuer: i.issuerIdentifierURL, Credentials: []openid4vci.OfferedCredential{{ - Format: openid4vc.VerifiableCredentialJSONLDFormat, + Format: vc.JSONLDCredentialProofFormat, CredentialDefinition: &openid4vci.CredentialDefinition{ Context: credential.Context, Type: credential.Type, diff --git a/vcr/issuer/openid_test.go b/vcr/issuer/openid_test.go index 449de9eda6..25875df74a 100644 --- a/vcr/issuer/openid_test.go +++ b/vcr/issuer/openid_test.go @@ -28,7 +28,6 @@ import ( "github.com/nuts-foundation/nuts-node/audit" "github.com/nuts-foundation/nuts-node/core" "github.com/nuts-foundation/nuts-node/crypto" - "github.com/nuts-foundation/nuts-node/openid4vc" "github.com/nuts-foundation/nuts-node/storage" "github.com/nuts-foundation/nuts-node/vcr/openid4vci" "github.com/nuts-foundation/nuts-node/vdr/resolver" @@ -144,7 +143,7 @@ func Test_memoryIssuer_HandleCredentialRequest(t *testing.T) { proof, err := keyStore.SignJWT(ctx, claims, headers, headers["kid"]) require.NoError(t, err) return openid4vci.CredentialRequest{ - Format: openid4vc.VerifiableCredentialJSONLDFormat, + Format: vc.JSONLDCredentialProofFormat, CredentialDefinition: &openid4vci.CredentialDefinition{ Context: []ssi.URI{ ssi.MustParseURI("https://www.w3.org/2018/credentials/v1"), diff --git a/vcr/openid4vci/issuer_client_test.go b/vcr/openid4vci/issuer_client_test.go index 2c0fbcad20..72355f6d05 100644 --- a/vcr/openid4vci/issuer_client_test.go +++ b/vcr/openid4vci/issuer_client_test.go @@ -20,7 +20,7 @@ package openid4vci import ( "context" - "github.com/nuts-foundation/nuts-node/openid4vc" + "github.com/nuts-foundation/go-did/vc" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "net/http" @@ -90,7 +90,7 @@ func Test_httpIssuerClient_RequestCredential(t *testing.T) { httpClient := &http.Client{} credentialRequest := CredentialRequest{ CredentialDefinition: &CredentialDefinition{}, - Format: openid4vc.VerifiableCredentialJSONLDFormat, + Format: vc.JSONLDCredentialProofFormat, } t.Run("ok", func(t *testing.T) { setup := setupClientTest(t) diff --git a/vcr/openid4vci/test.go b/vcr/openid4vci/test.go index 8435c1ce7e..f105ff4674 100644 --- a/vcr/openid4vci/test.go +++ b/vcr/openid4vci/test.go @@ -22,8 +22,8 @@ import ( "context" "encoding/json" "fmt" + "github.com/nuts-foundation/go-did/vc" "github.com/nuts-foundation/nuts-node/auth/oauth" - "github.com/nuts-foundation/nuts-node/openid4vc" "github.com/nuts-foundation/nuts-node/test" "net/http" "testing" @@ -36,7 +36,7 @@ func setupClientTest(t *testing.T) *oidcClientTestContext { providerMetadata := new(ProviderMetadata) walletMetadata := new(OAuth2ClientMetadata) credentialResponse := CredentialResponse{ - Format: openid4vc.VerifiableCredentialJSONLDFormat, + Format: vc.JSONLDCredentialProofFormat, Credential: &map[string]interface{}{ "@context": []string{"https://www.w3.org/2018/credentials/v1"}, "type": []string{"VerifiableCredential"}, diff --git a/vcr/test/openid4vci_integration_test.go b/vcr/test/openid4vci_integration_test.go index b6ee8020a4..6e246f7a9c 100644 --- a/vcr/test/openid4vci_integration_test.go +++ b/vcr/test/openid4vci_integration_test.go @@ -24,7 +24,6 @@ import ( "github.com/nuts-foundation/nuts-node/core" httpModule "github.com/nuts-foundation/nuts-node/http" "github.com/nuts-foundation/nuts-node/network/log" - "github.com/nuts-foundation/nuts-node/openid4vc" "github.com/nuts-foundation/nuts-node/vcr/issuer" "github.com/nuts-foundation/nuts-node/vcr/openid4vci" "github.com/nuts-foundation/nuts-node/vdr" @@ -230,7 +229,7 @@ func TestOpenID4VCIErrorResponses(t *testing.T) { require.NoError(t, err) requestBody, _ := json.Marshal(openid4vci.CredentialRequest{ - Format: openid4vc.VerifiableCredentialJSONLDFormat, + Format: vc.JSONLDCredentialProofFormat, }) t.Run("error from API layer (missing access token)", func(t *testing.T) {