Skip to content

Commit

Permalink
Merge pull request #1888 from blockchain-certificates/feat/vc-v2-name…
Browse files Browse the repository at this point in the history
…-description

feat(VCv2): add support for name and description
  • Loading branch information
lemoustachiste authored Oct 23, 2024
2 parents 03a1846 + 4e0178a commit 3e384a7
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 6 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/verifier/mocknet-vc-v2-credential-schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
40 changes: 40 additions & 0 deletions test/e2e/verifier/mocknet-vc-v2-name-description.test.ts
Original file line number Diff line number Diff line change
@@ -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);
});
});
});
77 changes: 77 additions & 0 deletions test/fixtures/v3/mocknet-vc-v2-name-description.json
Original file line number Diff line number Diff line change
@@ -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": "<div style=\"background-color:transparent;padding:6px;display:inline-flex;align-items:center;flex-direction:column\">Yo</div>"
},
"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"
}
}

0 comments on commit 3e384a7

Please sign in to comment.