From a03e64cfa933a469838374f2923f4cbc17767af0 Mon Sep 17 00:00:00 2001 From: PatStLouis Date: Mon, 27 Jan 2025 05:31:56 +0000 Subject: [PATCH 1/3] debug context Signed-off-by: PatStLouis --- package.json | 3 ++- tests/fixtures/license/1.1/credential.json | 2 +- tests/fixtures/license/2.0/credential.json | 2 +- tests/vc-generator/contexts.js | 6 ++++- tests/vc-generator/debug.js | 28 ++++++++++++++++++++++ tests/vc-generator/index.js | 1 + 6 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 tests/vc-generator/debug.js diff --git a/package.json b/package.json index 490842a..d6159ed 100644 --- a/package.json +++ b/package.json @@ -48,12 +48,13 @@ "@digitalbazaar/mocha-w3c-interop-reporter": "^1.6.0", "@digitalbazaar/multikey-context": "^2.0.1", "@digitalbazaar/vc": "^7.1.0", + "@digitalbazaar/vdl-context": "^1.0.0", "@digitalcredentials/did-context": "^1.0.0", "base58-universal": "^2.0.0", "base64url-universal": "^2.0.0", "chai": "^4.3.7", "data-integrity-test-suite-assertion": "github:w3c-ccg/data-integrity-test-suite-assertion", - "jsonld": "^8.3.2", + "jsonld": "^8.3.3", "jsonld-document-loader": "^2.2.0", "mocha": "^10.2.0", "uuid": "^9.0.0", diff --git a/tests/fixtures/license/1.1/credential.json b/tests/fixtures/license/1.1/credential.json index efcab4f..27fa51d 100644 --- a/tests/fixtures/license/1.1/credential.json +++ b/tests/fixtures/license/1.1/credential.json @@ -1,7 +1,7 @@ { "@context": [ "https://www.w3.org/2018/credentials/v1", - "https://w3id.org/vdl/v2" + "https://w3id.org/vdl/v1" ], "id": "urn:uuid:36245ee9-9074-4b05-a777-febff2e69757", "type": ["VerifiableCredential", "Iso18013DriversLicenseCredential"], diff --git a/tests/fixtures/license/2.0/credential.json b/tests/fixtures/license/2.0/credential.json index 19e5f0a..c7ff86d 100644 --- a/tests/fixtures/license/2.0/credential.json +++ b/tests/fixtures/license/2.0/credential.json @@ -1,7 +1,7 @@ { "@context": [ "https://www.w3.org/ns/credentials/v2", - "https://w3id.org/vdl/v2" + "https://w3id.org/vdl/v1" ], "id": "urn:uuid:36245ee9-9074-4b05-a777-febff2e69757", "type": ["VerifiableCredential", "Iso18013DriversLicenseCredential"], diff --git a/tests/vc-generator/contexts.js b/tests/vc-generator/contexts.js index ddb74d7..cd524b6 100644 --- a/tests/vc-generator/contexts.js +++ b/tests/vc-generator/contexts.js @@ -6,6 +6,10 @@ import { contexts as credentialsContexts, named as namedCredentialsContexts } from '@digitalbazaar/credentials-context'; +import { + CONTEXT as vdlCtx, + CONTEXT_URL as vdlCtxUrl +} from '@digitalbazaar/vdl-context'; import dataIntegrityCtx from '@digitalbazaar/data-integrity-context'; import didCtx from '@digitalcredentials/did-context'; import multikeyCtx from '@digitalbazaar/multikey-context'; @@ -29,7 +33,7 @@ contextMap.set( ); // add contexts for the documentLoader contextMap.set(multikeyCtx.constants.CONTEXT_URL, multikeyCtx.CONTEXT); - +contextMap.set(vdlCtxUrl, vdlCtx); // add the dids contexts setContexts(didCtx.contexts); diff --git a/tests/vc-generator/debug.js b/tests/vc-generator/debug.js new file mode 100644 index 0000000..b30d9a7 --- /dev/null +++ b/tests/vc-generator/debug.js @@ -0,0 +1,28 @@ +import {documentLoader as customLoader} from './documentLoader.js'; +import jsonld from 'jsonld'; + +jsonld.documentLoader = customLoader; +const doc = { + '@context': [ + 'https://www.w3.org/ns/credentials/v2', + 'https://w3id.org/vdl/v1' + ], + id: 'urn:uuid:36245ee9-9074-4b05-a777-febff2e69757', + type: ['VerifiableCredential', 'Iso18013DriversLicenseCredential'], + credentialSubject: { + id: 'urn:uuid:1a0e4ef5-091f-4060-842e-18e519ab9440', + type: 'LicensedDriver', + driversLicense: { + type: 'Iso18013DriversLicense', + document_number: 'T21387yc328c7y32h23f23', + birth_date: '01-01-1990', + expiry_date: '01-01-2030', + issuing_authority: 'VA' + } + } +}; + +// alternatively, pass the custom loader for just a specific call: +const expanded = await jsonld.expand( + doc, {documentLoader: customLoader}); +console.log(expanded); diff --git a/tests/vc-generator/index.js b/tests/vc-generator/index.js index df9ed18..4e05168 100644 --- a/tests/vc-generator/index.js +++ b/tests/vc-generator/index.js @@ -119,6 +119,7 @@ export async function deriveCredentials({ // and vectors const testData = generators.reduce((accumulator, current) => current(accumulator), initParams); + testData.loader = defaultLoader; const vc = await issueCloned(testData); map.get(keyType).set(vcVersion, vc); } From 4d98e8a2b00bfbf0d6547bc06d41c7c0fd29f415 Mon Sep 17 00:00:00 2001 From: PatStLouis Date: Tue, 4 Feb 2025 19:05:18 +0000 Subject: [PATCH 2/3] work Signed-off-by: PatStLouis --- tests/vc-generator/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/vc-generator/index.js b/tests/vc-generator/index.js index 4e05168..7f4a6b1 100644 --- a/tests/vc-generator/index.js +++ b/tests/vc-generator/index.js @@ -119,7 +119,7 @@ export async function deriveCredentials({ // and vectors const testData = generators.reduce((accumulator, current) => current(accumulator), initParams); - testData.loader = defaultLoader; + testData.loader = documentLoader; const vc = await issueCloned(testData); map.get(keyType).set(vcVersion, vc); } From 2440d23bd36fda6161e1eddedbc5ab47f057e1ed Mon Sep 17 00:00:00 2001 From: PatStLouis Date: Tue, 4 Feb 2025 19:15:43 +0000 Subject: [PATCH 3/3] remove the debug file Signed-off-by: PatStLouis --- tests/vc-generator/debug.js | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100644 tests/vc-generator/debug.js diff --git a/tests/vc-generator/debug.js b/tests/vc-generator/debug.js deleted file mode 100644 index b30d9a7..0000000 --- a/tests/vc-generator/debug.js +++ /dev/null @@ -1,28 +0,0 @@ -import {documentLoader as customLoader} from './documentLoader.js'; -import jsonld from 'jsonld'; - -jsonld.documentLoader = customLoader; -const doc = { - '@context': [ - 'https://www.w3.org/ns/credentials/v2', - 'https://w3id.org/vdl/v1' - ], - id: 'urn:uuid:36245ee9-9074-4b05-a777-febff2e69757', - type: ['VerifiableCredential', 'Iso18013DriversLicenseCredential'], - credentialSubject: { - id: 'urn:uuid:1a0e4ef5-091f-4060-842e-18e519ab9440', - type: 'LicensedDriver', - driversLicense: { - type: 'Iso18013DriversLicense', - document_number: 'T21387yc328c7y32h23f23', - birth_date: '01-01-1990', - expiry_date: '01-01-2030', - issuing_authority: 'VA' - } - } -}; - -// alternatively, pass the custom loader for just a specific call: -const expanded = await jsonld.expand( - doc, {documentLoader: customLoader}); -console.log(expanded);