Skip to content

Commit

Permalink
feat: Support for Verifiable Credentials Data Model v2.0
Browse files Browse the repository at this point in the history
Both models v1.1 and v2.0 are supported.

Signed-off-by: Bob Stasyszyn <bob.stasyszyn@gendigital.com>
  • Loading branch information
bstasyszyn committed Sep 12, 2024
1 parent caec9f8 commit 825cc43
Show file tree
Hide file tree
Showing 26 changed files with 1,477 additions and 425 deletions.
18 changes: 10 additions & 8 deletions didconfig/verifier/didconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func TestIsValidDomainCredentialJWT(t *testing.T) {
dlcJWT, err := verifiable.CreateCredential(verifiable.CredentialContents{
Issued: afgotime.NewTime(time.Now()),
Expired: afgotime.NewTime(time.Now().Add(time.Hour)),
Context: []string{verifiable.ContextURI, ContextV1},
Context: []string{verifiable.V1ContextURI, ContextV1},
Types: []string{verifiable.VCType, domainLinkageCredentialType},
Subject: []verifiable.Subject{{ID: testDID, CustomFields: map[string]interface{}{"origin": testJWTDomain}}},
Issuer: &verifiable.Issuer{ID: testDID},
Expand Down Expand Up @@ -241,7 +241,7 @@ func TestIsValidDomainCredentialJWT(t *testing.T) {
dlcJWT, err := verifiable.CreateCredential(verifiable.CredentialContents{
Issued: afgotime.NewTime(time.Now()),
Expired: afgotime.NewTime(time.Now().Add(time.Hour)),
Context: []string{verifiable.ContextURI, ContextV1},
Context: []string{verifiable.V1ContextURI, ContextV1},
Types: []string{verifiable.VCType, domainLinkageCredentialType},
Subject: []verifiable.Subject{{ID: testDID, CustomFields: map[string]interface{}{"origin": testJWTDomain}}},
Issuer: &verifiable.Issuer{ID: testDID},
Expand Down Expand Up @@ -286,7 +286,7 @@ func TestIsValidDomainCredentialJWT(t *testing.T) {
dlcJWT, err := verifiable.CreateCredential(verifiable.CredentialContents{
Issued: afgotime.NewTime(time.Now()),
Expired: afgotime.NewTime(time.Now().Add(time.Hour)),
Context: []string{verifiable.ContextURI, ContextV1},
Context: []string{verifiable.V1ContextURI, ContextV1},
Types: []string{verifiable.VCType, domainLinkageCredentialType},
Subject: []verifiable.Subject{{ID: testDID, CustomFields: map[string]interface{}{"origin": testJWTDomain}}},
Issuer: &verifiable.Issuer{ID: testDID},
Expand Down Expand Up @@ -330,7 +330,7 @@ func TestIsValidDomainCredentialJWT(t *testing.T) {
dlcJWT, err := verifiable.CreateCredential(verifiable.CredentialContents{
Issued: afgotime.NewTime(time.Now()),
Expired: afgotime.NewTime(time.Now().Add(time.Hour)),
Context: []string{verifiable.ContextURI, ContextV1},
Context: []string{verifiable.V1ContextURI, ContextV1},
Types: []string{verifiable.VCType, domainLinkageCredentialType},
Subject: []verifiable.Subject{{ID: testDID, CustomFields: map[string]interface{}{"origin": testJWTDomain}}},
Issuer: &verifiable.Issuer{ID: testDID},
Expand Down Expand Up @@ -365,7 +365,7 @@ func TestIsValidDomainCredentialJWT(t *testing.T) {
dlcJWT, err := verifiable.CreateCredential(verifiable.CredentialContents{
Issued: afgotime.NewTime(time.Now()),
Expired: afgotime.NewTime(time.Now().Add(time.Hour)),
Context: []string{verifiable.ContextURI, ContextV1},
Context: []string{verifiable.V1ContextURI, ContextV1},
Types: []string{verifiable.VCType, domainLinkageCredentialType},
Subject: []verifiable.Subject{{ID: testDID, CustomFields: map[string]interface{}{"origin": testJWTDomain}}},
Issuer: &verifiable.Issuer{ID: testDID},
Expand Down Expand Up @@ -440,7 +440,7 @@ func TestIsValidDomainCredentialJWT(t *testing.T) {
dlcJWT, err := verifiable.CreateCredential(verifiable.CredentialContents{
Issued: afgotime.NewTime(time.Now()),
Expired: afgotime.NewTime(time.Now().Add(time.Hour)),
Context: []string{verifiable.ContextURI, ContextV1},
Context: []string{verifiable.V1ContextURI, ContextV1},
Types: []string{verifiable.VCType, domainLinkageCredentialType},
Subject: []verifiable.Subject{{ID: "did:key:different", CustomFields: map[string]interface{}{"origin": testJWTDomain}}}, // nolint:lll
Issuer: &verifiable.Issuer{ID: testDID},
Expand All @@ -461,7 +461,7 @@ func TestIsValidDomainCredentialJWT(t *testing.T) {
dlcJWT, err := verifiable.CreateCredential(verifiable.CredentialContents{
Issued: afgotime.NewTime(time.Now()),
Expired: afgotime.NewTime(time.Now().Add(time.Hour)),
Context: []string{verifiable.ContextURI, ContextV1},
Context: []string{verifiable.V1ContextURI, ContextV1},
Types: []string{verifiable.VCType, domainLinkageCredentialType},
Subject: []verifiable.Subject{{ID: testDID, CustomFields: map[string]interface{}{"origin": testJWTDomain}}},
Issuer: &verifiable.Issuer{ID: testDID},
Expand All @@ -472,7 +472,9 @@ func TestIsValidDomainCredentialJWT(t *testing.T) {

dlcJWT = createEdDSAJWS(t, dlcJWT, ed25519ProofCreator, testKID, false)

borkenJWT, err := verifiable.CreateCredential(verifiable.CredentialContents{}, nil)
borkenJWT, err := verifiable.CreateCredential(verifiable.CredentialContents{
Context: []string{verifiable.V1ContextURI},
}, nil)
require.NoError(t, err)

borkenJWT.JWTEnvelope = dlcJWT.JWTEnvelope
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ require (
github.com/tidwall/gjson v1.14.3
github.com/tidwall/sjson v1.1.4
github.com/trustbloc/bbs-signature-go v1.0.2
github.com/trustbloc/did-go v1.3.0
github.com/trustbloc/did-go v1.3.1-0.20240910130808-bf0188fdfe70
github.com/trustbloc/kms-go v1.1.2
github.com/veraison/go-cose v1.1.1-0.20240126165338-2300d5c96dbd
github.com/xeipuuv/gojsonschema v1.2.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ github.com/tidwall/sjson v1.1.4 h1:bTSsPLdAYF5QNLSwYsKfBKKTnlGbIuhqL3CpRsjzGhg=
github.com/tidwall/sjson v1.1.4/go.mod h1:wXpKXu8CtDjKAZ+3DrKY5ROCorDFahq8l0tey/Lx1fg=
github.com/trustbloc/bbs-signature-go v1.0.2 h1:gepEsbLiZHv/vva9FKG5gF38mGtOIyGez7desZxiI1o=
github.com/trustbloc/bbs-signature-go v1.0.2/go.mod h1:xYotcXHAbcE0TO+SteW0J6XI3geQaXq4wdnXR2k+XCU=
github.com/trustbloc/did-go v1.3.0 h1:vfiY/dewd9cORo3U5c+eoWgNIQnKsuQYn5PV0CRu1o0=
github.com/trustbloc/did-go v1.3.0/go.mod h1:packTRoBoo8DrwOE7QKsI98xXS3Vf6ovUXYD4FUAcB4=
github.com/trustbloc/did-go v1.3.1-0.20240910130808-bf0188fdfe70 h1:5GOoXZcKYDTsobaTCeFUEBjbognYbjBh38fCjkvClU4=
github.com/trustbloc/did-go v1.3.1-0.20240910130808-bf0188fdfe70/go.mod h1:packTRoBoo8DrwOE7QKsI98xXS3Vf6ovUXYD4FUAcB4=
github.com/trustbloc/kms-go v1.1.2 h1:nAlhDoHkSyX1eQFRz/sJsdgmJuNadyX7FJEy/9ROwys=
github.com/trustbloc/kms-go v1.1.2/go.mod h1:OKOtsLbE6W5s4mpjWkvk8XEqcmt9vTgVmDNkHELpWO0=
github.com/veraison/go-cose v1.1.1-0.20240126165338-2300d5c96dbd h1:QhdCHSW1/oosJbzBTEYLU6xcKxXbQzzqFnhCtW2UWbA=
Expand Down
Loading

0 comments on commit 825cc43

Please sign in to comment.