diff --git a/packages/credentials/src/index.ts b/packages/credentials/src/index.ts index 55ad631b3..9374e7fd7 100644 --- a/packages/credentials/src/index.ts +++ b/packages/credentials/src/index.ts @@ -1,4 +1,5 @@ export * from './jwt.js'; export * from './presentation-exchange.js'; export * from './verifiable-credential.js'; +export * from './verifiable-presentation.js'; export * as utils from './utils.js'; \ No newline at end of file diff --git a/packages/credentials/src/validators.ts b/packages/credentials/src/validators.ts index 2fd2b85bc..637487ee7 100644 --- a/packages/credentials/src/validators.ts +++ b/packages/credentials/src/validators.ts @@ -4,7 +4,7 @@ import type { } from '@sphereon/ssi-types'; import { - DEFAULT_CONTEXT, + DEFAULT_VC_CONTEXT, DEFAULT_VC_TYPE, VerifiableCredential } from './verifiable-credential.js'; @@ -23,8 +23,8 @@ export class SsiValidator { static validateContext(value: ICredentialContextType | ICredentialContextType[]): void { const input = this.asArray(value); - if (input.length < 1 || input.indexOf(DEFAULT_CONTEXT) === -1) { - throw new Error(`@context is missing default context "${DEFAULT_CONTEXT}"`); + if (input.length < 1 || input.indexOf(DEFAULT_VC_CONTEXT) === -1) { + throw new Error(`@context is missing default context "${DEFAULT_VC_CONTEXT}"`); } } diff --git a/packages/credentials/src/verifiable-credential.ts b/packages/credentials/src/verifiable-credential.ts index ea338c1bf..e4ff03924 100644 --- a/packages/credentials/src/verifiable-credential.ts +++ b/packages/credentials/src/verifiable-credential.ts @@ -7,7 +7,7 @@ import { Jwt } from './jwt.js'; import { SsiValidator } from './validators.js'; import { getCurrentXmlSchema112Timestamp } from './utils.js'; -export const DEFAULT_CONTEXT = 'https://www.w3.org/2018/credentials/v1'; +export const DEFAULT_VC_CONTEXT = 'https://www.w3.org/2018/credentials/v1'; export const DEFAULT_VC_TYPE = 'VerifiableCredential'; /** @@ -147,7 +147,7 @@ export class VerifiableCredential { }; const vcDataModel: VcDataModel = { - '@context' : [DEFAULT_CONTEXT], + '@context' : [DEFAULT_VC_CONTEXT], type : Array.isArray(type) ? [DEFAULT_VC_TYPE, ...type] : (type ? [DEFAULT_VC_TYPE, type] : [DEFAULT_VC_TYPE]), diff --git a/packages/credentials/src/verifiable-presentation.ts b/packages/credentials/src/verifiable-presentation.ts index a74e48df5..7d1ec96ad 100644 --- a/packages/credentials/src/verifiable-presentation.ts +++ b/packages/credentials/src/verifiable-presentation.ts @@ -5,8 +5,8 @@ import { utils as cryptoUtils } from '@web5/crypto'; import { Jwt } from './jwt.js'; import { SsiValidator } from './validators.js'; +import { DEFAULT_VC_CONTEXT } from './verifiable-credential.js'; -export const DEFAULT_CONTEXT = 'https://www.w3.org/2018/credentials/v1'; export const DEFAULT_VP_TYPE = 'VerifiablePresentation'; /** @@ -133,7 +133,7 @@ export class VerifiablePresentation { } const vpDataModel: VpDataModel = { - '@context' : [DEFAULT_CONTEXT], + '@context' : [DEFAULT_VC_CONTEXT], type : Array.isArray(type) ? [DEFAULT_VP_TYPE, ...type] : (type ? [DEFAULT_VP_TYPE, type] : [DEFAULT_VP_TYPE]), diff --git a/packages/credentials/tests/ssi-validator.spec.ts b/packages/credentials/tests/ssi-validator.spec.ts index fa5d579e3..91ac067f5 100644 --- a/packages/credentials/tests/ssi-validator.spec.ts +++ b/packages/credentials/tests/ssi-validator.spec.ts @@ -1,17 +1,17 @@ import { expect } from 'chai'; import { SsiValidator } from '../src/validators.js'; -import { DEFAULT_CONTEXT, DEFAULT_VC_TYPE } from '../src/verifiable-credential.js'; +import { DEFAULT_VC_CONTEXT, DEFAULT_VC_TYPE } from '../src/verifiable-credential.js'; describe('SsiValidator', () => { describe('validateContext', () => { it('should throw an error if the default context is missing', () => { - expect(() => SsiValidator.validateContext(['http://example.com'])).throw(`@context is missing default context "${DEFAULT_CONTEXT}"`); + expect(() => SsiValidator.validateContext(['http://example.com'])).throw(`@context is missing default context "${DEFAULT_VC_CONTEXT}"`); }); it('should not throw an error if the default context is present', () => { - expect(() => SsiValidator.validateContext([DEFAULT_CONTEXT, 'http://example.com'])).not.throw(); + expect(() => SsiValidator.validateContext([DEFAULT_VC_CONTEXT, 'http://example.com'])).not.throw(); }); }); diff --git a/web5-spec b/web5-spec index deb64f42c..1e498f37f 160000 --- a/web5-spec +++ b/web5-spec @@ -1 +1 @@ -Subproject commit deb64f42cc892985c45d33ff40f19ee1947079d9 +Subproject commit 1e498f37f07a1f29c89c10b8a59c7ed9b7d54050