Skip to content

Use local document loader with vdlCtx #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tests/15-di-bbs-verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as bbs2023Cryptosuite from '@digitalbazaar/bbs-2023-cryptosuite';
import {
checkDataIntegrityProofVerifyErrors
} from 'data-integrity-test-suite-assertion';
import {documentLoader} from './vc-generator/documentLoader.js';
import {endpoints} from 'vc-test-suite-implementations';
import {filterVerifiers} from './helpers.js';
import {getMultiKey} from './vc-generator/key-gen.js';
Expand All @@ -30,6 +31,7 @@ for(const vcVersion of vectors.vcTypes) {
authentication: true
},
testDataOptions: {
documentLoader,
suiteName: 'bbs-2023',
key,
cryptosuite: bbs2023Cryptosuite,
Expand Down
35 changes: 25 additions & 10 deletions tests/vc-generator/contexts.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,42 @@ import dataIntegrityCtx from '@digitalbazaar/data-integrity-context';
import didCtx from '@digitalcredentials/did-context';
import multikeyCtx from '@digitalbazaar/multikey-context';

const contextMap = new Map(credentialsContexts);
const contextMap = new Map();
const setContexts = contexts => {
for(const [key, value] of contexts) {
contextMap.set(key, structuredClone(value));
}
};
const invalidPurpose = {
'@id': 'https://w3id.org/security#invalidPurpose',
'@type': '@id',
'@container': '@set'
};

const {context: vc2Context} = namedCredentialsContexts.get('v2');
const v2Ctx = vc2Context['@context'];
// adding terms manually
const {
id: v2ContextUrl,
context: v2Context
} = structuredClone(namedCredentialsContexts.get('v2'));
const v2Ctx = v2Context['@context'];
v2Ctx.UnknownProofType = structuredClone(v2Ctx.DataIntegrityProof);
v2Ctx.DataIntegrityProof['@context'].proofPurpose['@context'].invalidPurpose =
invalidPurpose;
v2Ctx.undefinedTerm = 'urn:example:undefinedTerm';

const _dataIntegrityCtx = structuredClone(dataIntegrityCtx.CONTEXT);
const diCtx = _dataIntegrityCtx['@context'];
diCtx.UnknownProofType = structuredClone(diCtx.DataIntegrityProof);
contextMap.set(
dataIntegrityCtx.constants.CONTEXT_URL,
_dataIntegrityCtx
);
// add contexts for the documentLoader
diCtx.DataIntegrityProof['@context'].proofPurpose['@context'].invalidPurpose =
invalidPurpose;
diCtx.undefinedTerm = 'urn:example:undefinedTerm';

// adding to contextMap
setContexts(didCtx.contexts);
setContexts(credentialsContexts);
contextMap.set(multikeyCtx.constants.CONTEXT_URL, multikeyCtx.CONTEXT);
contextMap.set(vdlCtxUrl, vdlCtx);
// add the dids contexts
setContexts(didCtx.contexts);
contextMap.set(dataIntegrityCtx.constants.CONTEXT_URL, _dataIntegrityCtx);
contextMap.set(v2ContextUrl, v2Context);

export {contextMap};