diff --git a/package-lock.json b/package-lock.json index f4a5d566..84c5d5af 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "@blockcerts/ecdsa-secp256k1-verification-key-2019": "^0.1.7", "@blockcerts/explorer-lookup": "^1.5.1", "@blockcerts/hashlink-verifier": "^1.6.0", - "@blockcerts/schemas": "^3.6.3", + "@blockcerts/schemas": "^3.7.2", "@did-core/did-ld-json": "npm:@blockcerts/did-ld-json@^0.1.2", "@digitalbazaar/data-integrity": "^2.1.0", "@digitalbazaar/ecdsa-sd-2023-cryptosuite": "github:blockchain-certificates/ecdsa-sd-2023-cryptosuite#chore/secp256k1-with-multikey-fork", @@ -742,9 +742,9 @@ } }, "node_modules/@blockcerts/schemas": { - "version": "3.6.4", - "resolved": "https://registry.npmjs.org/@blockcerts/schemas/-/schemas-3.6.4.tgz", - "integrity": "sha512-Oq3Du3FMWGL9Jaw5ElPVkULvt/0g0iiIoLluzBn266CiipUn84n/kPUcmyUapjU2gDiBwrzUn1barxUUD8QvDQ==", + "version": "3.7.2", + "resolved": "https://registry.npmjs.org/@blockcerts/schemas/-/schemas-3.7.2.tgz", + "integrity": "sha512-mfK5lE7lD6QY72TapxcNJUXU/9N37o0ZzmBGhnKmDsjN6GnpACyD5RwNqnfpbdfo81l55M1/c6yTion2MyLMnw==", "license": "MIT" }, "node_modules/@colors/colors": { diff --git a/package.json b/package.json index 6bd30ff4..ac24a907 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "@blockcerts/ecdsa-secp256k1-verification-key-2019": "^0.1.7", "@blockcerts/explorer-lookup": "^1.5.1", "@blockcerts/hashlink-verifier": "^1.6.0", - "@blockcerts/schemas": "^3.6.3", + "@blockcerts/schemas": "^3.7.2", "@did-core/did-ld-json": "npm:@blockcerts/did-ld-json@^0.1.2", "@digitalbazaar/data-integrity": "^2.1.0", "@digitalbazaar/ecdsa-sd-2023-cryptosuite": "github:blockchain-certificates/ecdsa-sd-2023-cryptosuite#chore/secp256k1-with-multikey-fork", diff --git a/test/e2e/verifier/mocknet-vc-v2-credential-schema.test.ts b/test/e2e/verifier/mocknet-vc-v2-credential-schema.test.ts index c8b698d6..2090b155 100644 --- a/test/e2e/verifier/mocknet-vc-v2-credential-schema.test.ts +++ b/test/e2e/verifier/mocknet-vc-v2-credential-schema.test.ts @@ -5,7 +5,7 @@ import MocknetVCV2CredentialSchemaInvalid from '../../fixtures/v3/mocknet-vc-v2- import fixtureBlockcertsIssuerProfile from '../../fixtures/issuer-blockcerts.json'; import fixtureCredentialSchema from '../../fixtures/credential-schema-example-id-card.json'; -describe('given the certificate is a valid mocknet (v3.0)', function () { +describe('given the certificate is a valid mocknet (v3.2)', function () { beforeAll(function () { vi.mock('@blockcerts/explorer-lookup', async (importOriginal) => { const explorerLookup = await importOriginal(); diff --git a/test/e2e/verifier/mocknet-vc-v2-name-description.test.ts b/test/e2e/verifier/mocknet-vc-v2-name-description.test.ts new file mode 100644 index 00000000..b126ff44 --- /dev/null +++ b/test/e2e/verifier/mocknet-vc-v2-name-description.test.ts @@ -0,0 +1,40 @@ +import { describe, it, expect, beforeAll, vi, afterAll } from 'vitest'; +import { Certificate, VERIFICATION_STATUSES } from '../../../src'; +import MocknetVCV2CredentialSchema from '../../fixtures/v3/mocknet-vc-v2-name-description.json'; +import fixtureBlockcertsIssuerProfile from '../../fixtures/issuer-blockcerts.json'; +import fixtureCredentialSchema from '../../fixtures/credential-schema-example-id-card.json'; + +describe('given the certificate is a valid mocknet (v3.2)', function () { + beforeAll(function () { + vi.mock('@blockcerts/explorer-lookup', async (importOriginal) => { + const explorerLookup = await importOriginal(); + return { + ...explorerLookup, + // replace some exports + request: async function ({ url }) { + if (url === 'https://www.blockcerts.org/samples/3.0/issuer-blockcerts.json') { + return JSON.stringify(fixtureBlockcertsIssuerProfile); + } + + if (url === 'https://www.blockcerts.org/samples/3.0/example-id-card-schema.json') { + return JSON.stringify(fixtureCredentialSchema); + } + } + }; + }); + }); + + afterAll(function () { + vi.restoreAllMocks(); + }); + + describe('where name and description are root level properties', function () { + // this test will expire in 2039 + it('should verify successfully', async function () { + const certificate = new Certificate(MocknetVCV2CredentialSchema); + await certificate.init(); + const result = await certificate.verify(); + expect(result.status).toBe(VERIFICATION_STATUSES.SUCCESS); + }); + }); +}); diff --git a/test/fixtures/v3/mocknet-vc-v2-name-description.json b/test/fixtures/v3/mocknet-vc-v2-name-description.json new file mode 100644 index 00000000..1ff20158 --- /dev/null +++ b/test/fixtures/v3/mocknet-vc-v2-name-description.json @@ -0,0 +1,77 @@ +{ + "@context": [ + "https://www.w3.org/ns/credentials/v2", + { + "DOB": { + "@id": "https://schemas.learningmachine.com/2017/blockcerts/DOB", + "@type": "https://schema.org/Text" + }, + "nationality": { + "@id": "https://schemas.learningmachine.com/2017/blockcerts/nationality", + "@type": "https://schema.org/Text" + }, + "height": { + "@id": "https://schemas.learningmachine.com/2017/blockcerts/height", + "@type": "https://schema.org/Text" + }, + "residentialAddressStreet": { + "@id": "https://schemas.learningmachine.com/2017/blockcerts/residentialAddressStreet", + "@type": "https://schema.org/Text" + }, + "residentialAddressTown": { + "@id": "https://schemas.learningmachine.com/2017/blockcerts/residentialAddressTown", + "@type": "https://schema.org/Text" + }, + "residentialAddressPostCode": { + "@id": "https://schemas.learningmachine.com/2017/blockcerts/residentialAddressPostCode", + "@type": "https://schema.org/Text" + }, + "IdCardCredential": { + "@id": "https://schemas.learningmachine.com/2017/blockcerts/IdCardCredential", + "@type": "https://schema.org/DataType" + } + }, + "https://w3id.org/security/data-integrity/v2", + "https://w3id.org/blockcerts/v3.2" + ], + "type": [ + "VerifiableCredential", + "BlockcertsCredential", + "IdCardCredential" + ], + "name": "Canadian Id Card", + "description": "A Blockcerts example (not an official document) highlighting various VC v2 spec items", + "issuer": "https://www.blockcerts.org/samples/3.0/issuer-blockcerts.json", + "validFrom": "2024-03-01T00:00:00Z", + "validUntil": "2039-02-28T23:59:59Z", + "id": "urn:uuid:4f5f0100-ccbf-4ca9-9cfc-4f5fc3052d28", + "credentialSchema": [ + { + "id": "https://www.blockcerts.org/samples/3.0/example-id-card-schema.json", + "type": "JsonSchema" + } + ], + "credentialSubject": { + "id": "did:example:ebfeb1f712ebc6f1c276e12ec21", + "name": "John Smith", + "nationality": "Canada", + "DOB": "05/10/1983", + "height": "1.80m", + "residentialAddressStreet": "6 Maple Tree street", + "residentialAddressTown": "Toronto", + "residentialAddressPostCode": "YYZYUL" + }, + "display": { + "contentMediaType": "text/html", + "content": "
Yo
" + }, + "proof": { + "id": "urn:uuid:24234d1c-d4d8-4ab0-b39c-dbfa34453c57", + "type": "DataIntegrityProof", + "cryptosuite": "merkle-proof-2019", + "proofPurpose": "assertionMethod", + "created": "2024-10-22T17:46:57Z", + "proofValue": "zEuZQLZTYrdsDv2b4UaTDmwfUkysUhJGNFY5dhtvEby9iaip6ivoEUCXsYVv6ZzFgxoxwE1AxRpBgxf498vvUobDFTNd1qJ84afnmucg7cHAJCXiXWY8EmYpKgeXckNtiyzZmgDSCeegHkrwUSaM7G2fz2byGYBhweuysT76mhUbFwPGBzQpgQX6tgsvQS8dtSW8zXHKoK7PyvoQwkJvfoHoHCTZd4QnVPPPisYnjN6ZUAw38Zow7evEkK3VdHmcCi2gRfWrjvvutAtfXoT1sSLx5v2V4T1sRbH7kFoEY2VS5VA", + "verificationMethod": "https://www.blockcerts.org/samples/3.0/issuer-blockcerts.json#key-1" + } +}