-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1888 from blockchain-certificates/feat/vc-v2-name…
…-description feat(VCv2): add support for name and description
- Loading branch information
Showing
5 changed files
with
123 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |