From 56f9733ae858205461b8a46d91ae9d38d2101497 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Mon, 10 Jul 2023 21:10:36 +0000 Subject: [PATCH 1/6] Add test for VC 2.0 issuing. --- test/mocha/20-credentials.js | 33 ++++++++++++++++++++++++++++++ test/mocha/mock-credential-v2.json | 29 ++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 test/mocha/mock-credential-v2.json diff --git a/test/mocha/20-credentials.js b/test/mocha/20-credentials.js index b10b572f..d5f4ef87 100644 --- a/test/mocha/20-credentials.js +++ b/test/mocha/20-credentials.js @@ -21,6 +21,7 @@ const serviceType = 'vc-issuer'; // NOTE: using embedded context in mockCredential: // https://www.w3.org/2018/credentials/examples/v1 const mockCredential = require('./mock-credential.json'); +const mockCredentialV2 = require('./mock-credential-v2.json'); describe('issue APIs', () => { const suiteNames = { @@ -220,6 +221,38 @@ describe('issue APIs', () => { should.exist(verifiableCredential.proof); verifiableCredential.proof.should.be.an('object'); }); + it('issues a VC 2.0 credential w/no "credentialStatus"', async () => { + const credential = klona(mockCredentialV2); + let error; + let result; + try { + const zcapClient = helpers.createZcapClient({capabilityAgent}); + result = await zcapClient.write({ + url: `${noStatusListIssuerId}/credentials/issue`, + capability: noStatusListIssuerRootZcap, + json: { + credential + } + }); + } catch(e) { + error = e; + } + assertNoError(error); + should.exist(result.data); + should.exist(result.data.verifiableCredential); + const {verifiableCredential} = result.data; + verifiableCredential.should.be.an('object'); + should.exist(verifiableCredential['@context']); + should.exist(verifiableCredential.id); + should.exist(verifiableCredential.type); + should.exist(verifiableCredential.issuer); + should.exist(verifiableCredential.credentialSubject); + verifiableCredential.credentialSubject.should.be.an('object'); + should.not.exist(verifiableCredential.credentialStatus); + should.exist(verifiableCredential.proof); + verifiableCredential.proof.should.be.an('object'); + }); + it('fails to issue a valid credential', async () => { let error; try { diff --git a/test/mocha/mock-credential-v2.json b/test/mocha/mock-credential-v2.json new file mode 100644 index 00000000..0b1b0c78 --- /dev/null +++ b/test/mocha/mock-credential-v2.json @@ -0,0 +1,29 @@ +{ + "@context": [ + "https://www.w3.org/ns/credentials/v2", + { + "ex": "https://example.org/examples#", + "schema": "http://schema.org/", + "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#", + + "BachelorDegree": "ex:BachelorDegree", + "UniversityDegreeCredential": "ex:UniversityDegreeCredential", + + "degree": "ex:degree", + "name": {"@id": "schema:name", "@type": "rdf:HTML"} + } + ], + "id": "http://example.gov/credentials/3732", + "type": [ + "VerifiableCredential", + "UniversityDegreeCredential" + ], + "issuer": "https://example.edu", + "credentialSubject": { + "id": "did:example:ebfeb1f712ebc6f1c276e12ec21", + "degree": { + "type": "BachelorDegree", + "name": "Bachelor of Science and Arts" + } + } +} From 4d9341bace0d445ec5cdf5c4184e0e661f08ff26 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Fri, 21 Jul 2023 18:43:44 +0000 Subject: [PATCH 2/6] Use vc 2.0 branches for vc-revocation & vc-status list. --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3c737e8e..78e17582 100644 --- a/package.json +++ b/package.json @@ -41,8 +41,8 @@ "@digitalbazaar/eddsa-rdfc-2022-cryptosuite": "^1.0.1", "@digitalbazaar/lru-memoize": "^3.0.0", "@digitalbazaar/vc": "^6.0.2", - "@digitalbazaar/vc-revocation-list": "^6.0.0", - "@digitalbazaar/vc-status-list": "^7.0.0", + "@digitalbazaar/vc-revocation-list": "github:digitalbazaar/vc-revocation-list#update-vc-2.0", + "@digitalbazaar/vc-status-list": "github:digitalbazaar/vc-status-list#update-vc-2.0", "@digitalbazaar/webkms-client": "^13.0.0", "assert-plus": "^1.0.0", "bnid": "^3.0.0", From e95833f5d1d92b3b2821f4c540aa6ba1a7dcf829 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Fri, 21 Jul 2023 18:48:45 +0000 Subject: [PATCH 3/6] Use update @db/vc for vc 2.0. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 78e17582..0570bd00 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@digitalbazaar/eddsa-2022-cryptosuite": "^1.0.0", "@digitalbazaar/eddsa-rdfc-2022-cryptosuite": "^1.0.1", "@digitalbazaar/lru-memoize": "^3.0.0", - "@digitalbazaar/vc": "^6.0.2", + "@digitalbazaar/vc": "github:digitalbazaar/vc#update-vc-2.0", "@digitalbazaar/vc-revocation-list": "github:digitalbazaar/vc-revocation-list#update-vc-2.0", "@digitalbazaar/vc-status-list": "github:digitalbazaar/vc-status-list#update-vc-2.0", "@digitalbazaar/webkms-client": "^13.0.0", From 5a597ac5206a8366db91a1d9a40c011c9b6a02a6 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Tue, 30 Jan 2024 20:47:32 +0000 Subject: [PATCH 4/6] Use time props branch of VC 2.0 driver for validUntil & validBefore. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0570bd00..b6903798 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@digitalbazaar/eddsa-2022-cryptosuite": "^1.0.0", "@digitalbazaar/eddsa-rdfc-2022-cryptosuite": "^1.0.1", "@digitalbazaar/lru-memoize": "^3.0.0", - "@digitalbazaar/vc": "github:digitalbazaar/vc#update-vc-2.0", + "@digitalbazaar/vc": "github:digitalbazaar/vc#vc-2.0-time-props", "@digitalbazaar/vc-revocation-list": "github:digitalbazaar/vc-revocation-list#update-vc-2.0", "@digitalbazaar/vc-status-list": "github:digitalbazaar/vc-status-list#update-vc-2.0", "@digitalbazaar/webkms-client": "^13.0.0", From bdec6eaf8423c89e740cc7d18aa72096a00b7a24 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Tue, 30 Jan 2024 21:07:25 +0000 Subject: [PATCH 5/6] Use bedrock-credentials-context with 2.0 context in it. --- test/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/package.json b/test/package.json index 8140cef3..d8889e2d 100644 --- a/test/package.json +++ b/test/package.json @@ -13,7 +13,7 @@ "dependencies": { "@bedrock/app-identity": "^4.0.0", "@bedrock/core": "^6.0.1", - "@bedrock/credentials-context": "^4.0.0", + "@bedrock/credentials-context": "digitalbazaar/bedrock-credentials-context#update-vc-2.0", "@bedrock/data-integrity-context": "^3.0.0", "@bedrock/did-context": "^5.0.0", "@bedrock/did-io": "^10.1.0", From 03011cc911e54bdf18c29271c864ac9db51ce8d9 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Wed, 31 Jan 2024 16:06:02 +0000 Subject: [PATCH 6/6] Add manadatoryPointers option. --- test/mocha/20-credentials.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/mocha/20-credentials.js b/test/mocha/20-credentials.js index d5f4ef87..87d18ef2 100644 --- a/test/mocha/20-credentials.js +++ b/test/mocha/20-credentials.js @@ -231,7 +231,10 @@ describe('issue APIs', () => { url: `${noStatusListIssuerId}/credentials/issue`, capability: noStatusListIssuerRootZcap, json: { - credential + credential, + options: { + mandatoryPointers: ['issuer'] + } } }); } catch(e) {