diff --git a/packages/credentials/tests/VCs/valid/vc-example-1.json b/packages/credentials/tests/VCs/valid/vc-example-1.json new file mode 100644 index 000000000..b170bbfe8 --- /dev/null +++ b/packages/credentials/tests/VCs/valid/vc-example-1.json @@ -0,0 +1,36 @@ +{ + "@context": [ + "https://www.w3.org/2018/credentials/v1", + "https://www.w3.org/2018/credentials/examples/v1" + ], + "id": "http://example.edu/credentials/1872", + "type": [ + "VerifiableCredential", + "AlumniCredential" + ], + "issuer": "https://example.edu/issuers/565049", + "issuanceDate": "2010-01-01T19:23:24Z", + "credentialSubject": { + "id": "did:example:ebfeb1f712ebc6f1c276e12ec21", + "alumniOf": { + "id": "did:example:c276e12ec21ebfeb1f712ebc6f1", + "name": [ + { + "value": "Example University", + "lang": "en" + }, + { + "value": "Exemple d'Université", + "lang": "fr" + } + ] + } + }, + "proof": { + "type": "RsaSignature2018", + "created": "2017-06-18T21:19:10Z", + "proofPurpose": "assertionMethod", + "verificationMethod": "https://example.edu/issuers/565049/keys/1", + "jws": "eyJhbGciOiJSUzI1NiIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..TCYt5XsITJX1CxPCT8yAV-TVkIEq_PbChOMqsLfRoPsnsgw5WEuts01mq-pQy7UJiN5mgRxD-WUcX16dUEMGlv50aqzpqh4Qktb3rk-BuQy72IFLOqV0G_zS245-kronKb78cPN25DGlcTwLtjPAYuNzVBAh4vGHSrQyHUdBBPM" + } +} diff --git a/packages/credentials/tests/VCs/valid/vc-example-11.json b/packages/credentials/tests/VCs/valid/vc-example-11.json new file mode 100644 index 000000000..014e975c2 --- /dev/null +++ b/packages/credentials/tests/VCs/valid/vc-example-11.json @@ -0,0 +1,27 @@ +{ + "@context": [ + "https://www.w3.org/2018/credentials/v1", + "https://www.w3.org/2018/credentials/examples/v1" + ], + "id": "http://example.gov/credentials/3732", + "type": [ + "VerifiableCredential", + "UniversityDegreeCredential" + ], + "issuer": "https://example.edu", + "issuanceDate": "2010-01-01T19:23:24Z", + "credentialSubject": { + "id": "did:example:ebfeb1f712ebc6f1c276e12ec21", + "degree": { + "type": "BachelorDegree", + "name": "Bachelor of Science and Arts" + } + }, + "proof": { + "type": "RsaSignature2018", + "created": "2018-06-18T21:19:10Z", + "proofPurpose": "assertionMethod", + "verificationMethod": "https://example.com/jdoe/keys/1", + "jws": "eyJhbGciOiJQUzI1NiIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19DJBMvvFAIC00nSGB6Tn0XKbbF9XrsaJZREWvR2aONYTQQxnyXirtXnlewJMBBn2h9hfcGZrvnC1b6PgWmukzFJ1IiH1dWgnDIS81BH-IxXnPkbuYDeySorc4QU9MJxdVkY5EL4HYbcIfwKj6X4LBQ2_ZHZIu1jdqLcRZqHcsDF5KKylKc1THn5VRWy5WhYg_gBnyWny8E6Qkrze53MR7OuAmmNJ1m1nN8SxDrG6a08L78J0-Fbas5OjAQz3c17GY8mVuDPOBIOVjMEghBlgl3nOi1ysxbRGhHLEK4s0KKbeRogZdgt1DkQxDFxxn41QWDw_mmMCjs9qxg0zcZzqEJw" + } +} diff --git a/packages/credentials/tests/VCs/valid/vc-example-20.json b/packages/credentials/tests/VCs/valid/vc-example-20.json new file mode 100644 index 000000000..99257a3d3 --- /dev/null +++ b/packages/credentials/tests/VCs/valid/vc-example-20.json @@ -0,0 +1,24 @@ +{ + "@context": [ + "https://www.w3.org/2018/credentials/v1", + "https://www.w3.org/2018/credentials/examples/v1" + ], + "id": "http://example.edu/credentials/3732", + "type": [ + "VerifiableCredential", + "UniversityDegreeCredential" + ], + "issuer": "https://example.edu/issuers/14", + "issuanceDate": "2010-01-01T19:23:24Z", + "credentialSubject": { + "id": "did:example:ebfeb1f712ebc6f1c276e12ec21", + "degree": { + "type": "BachelorDegree", + "name": "Bachelor of Science and Arts" + } + }, + "refreshService": { + "id": "https://example.edu/refresh/3732", + "type": "ManualRefreshService2018" + } +} diff --git a/packages/credentials/tests/VCs/valid/vc-example-21.json b/packages/credentials/tests/VCs/valid/vc-example-21.json new file mode 100644 index 000000000..c46abbfbf --- /dev/null +++ b/packages/credentials/tests/VCs/valid/vc-example-21.json @@ -0,0 +1,37 @@ +{ + "@context": [ + "https://www.w3.org/2018/credentials/v1", + "https://www.w3.org/2018/credentials/examples/v1" + ], + "id": "http://example.edu/credentials/3732", + "type": [ + "VerifiableCredential", + "UniversityDegreeCredential" + ], + "issuer": "https://example.edu/issuers/14", + "issuanceDate": "2010-01-01T19:23:24Z", + "credentialSubject": { + "id": "did:example:ebfeb1f712ebc6f1c276e12ec21", + "degree": { + "type": "BachelorDegree", + "name": "Bachelor of Science and Arts" + } + }, + "termsOfUse": [ + { + "type": "IssuerPolicy", + "id": "http://example.com/policies/credential/4", + "profile": "http://example.com/profiles/credential", + "prohibition": [ + { + "assigner": "https://example.edu/issuers/14", + "assignee": "AllVerifiers", + "target": "http://example.edu/credentials/3732", + "action": [ + "Archival" + ] + } + ] + } + ] +} diff --git a/packages/credentials/tests/VCs/valid/vc_universityDegree.jwt b/packages/credentials/tests/VCs/valid/vc_universityDegree.jwt deleted file mode 100644 index c3c050897..000000000 --- a/packages/credentials/tests/VCs/valid/vc_universityDegree.jwt +++ /dev/null @@ -1 +0,0 @@ -eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImRpZDpleGFtcGxlOmFiZmUxM2Y3MTIxMjA0MzFjMjc2ZTEyZWNhYiNrZXlzLTEifQ.eyJzdWIiOiJkaWQ6ZXhhbXBsZTplYmZlYjFmNzEyZWJjNmYxYzI3NmUxMmVjMjEiLCJqdGkiOiJodHRwOi8vZXhhbXBsZS5lZHUvY3JlZGVudGlhbHMvMzczMiIsImlzcyI6Imh0dHBzOi8vZXhhbXBsZS5jb20va2V5cy9mb28uandrIiwibmJmIjoxNTQxNDkzNzI0LCJpYXQiOjE1NDE0OTM3MjQsImV4cCI6MTU3MzAyOTcyMywibm9uY2UiOiI2NjAhNjM0NUZTZXIiLCJ2YyI6eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSIsImh0dHBzOi8vd3d3LnczLm9yZy8yMDE4L2NyZWRlbnRpYWxzL2V4YW1wbGVzL3YxIl0sInR5cGUiOlsiVmVyaWZpYWJsZUNyZWRlbnRpYWwiLCJVbml2ZXJzaXR5RGVncmVlQ3JlZGVudGlhbCJdLCJjcmVkZW50aWFsU3ViamVjdCI6eyJkZWdyZWUiOnsidHlwZSI6IkJhY2hlbG9yRGVncmVlIiwibmFtZSI6IjxzcGFuIGxhbmc9J2ZyLUNBJz5CYWNjYWxhdXLDqWF0IGVuIG11c2lxdWVzIG51bcOpcmlxdWVzPC9zcGFuPiJ9fX19.KLJo5GAyBND3LDTn9H7FQokEsUEi8jKwXhGvoN3JtRa51xrNDgXDb0cq1UTYB-rK4Ft9YVmR1NI_ZOF8oGc_7wAp8PHbF2HaWodQIoOBxxT-4WNqAxft7ET6lkH-4S6Ux3rSGAmczMohEEf8eCeN-jC8WekdPl6zKZQj0YPB1rx6X0-xlFBs7cl6Wt8rfBP_tZ9YgVWrQmUWypSioc0MUyiphmyEbLZagTyPlUyflGlEdqrZAv6eSe6RtxJy6M1-lD7a5HTzanYTWBPAUHDZGyGKXdJw-W_x0IWChBzI8t3kpG253fg6V3tPgHeKXE94fz_QpYfg--7kLsyBAfQGbg \ No newline at end of file diff --git a/packages/credentials/tests/VCs/valid/vp-example-2.json b/packages/credentials/tests/VCs/valid/vp-example-2.json new file mode 100644 index 000000000..d51e73e96 --- /dev/null +++ b/packages/credentials/tests/VCs/valid/vp-example-2.json @@ -0,0 +1,54 @@ +{ + "@context": [ + "https://www.w3.org/2018/credentials/v1", + "https://www.w3.org/2018/credentials/examples/v1" + ], + "type": "VerifiablePresentation", + "verifiableCredential": [ + { + "@context": [ + "https://www.w3.org/2018/credentials/v1", + "https://www.w3.org/2018/credentials/examples/v1" + ], + "id": "http://example.edu/credentials/1872", + "type": [ + "VerifiableCredential", + "AlumniCredential" + ], + "issuer": "https://example.edu/issuers/565049", + "issuanceDate": "2010-01-01T19:23:24Z", + "credentialSubject": { + "id": "did:example:ebfeb1f712ebc6f1c276e12ec21", + "alumniOf": { + "id": "did:example:c276e12ec21ebfeb1f712ebc6f1", + "name": [ + { + "value": "Example University", + "lang": "en" + }, + { + "value": "Exemple d'Université", + "lang": "fr" + } + ] + } + }, + "proof": { + "type": "RsaSignature2018", + "created": "2017-06-18T21:19:10Z", + "proofPurpose": "assertionMethod", + "verificationMethod": "https://example.edu/issuers/565049/keys/1", + "jws": "eyJhbGciOiJSUzI1NiIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..TCYt5XsITJX1CxPCT8yAV-TVkIEq_PbChOMqsLfRoPsnsgw5WEuts01mq-pQy7UJiN5mgRxD-WUcX16dUEMGlv50aqzpqh4Qktb3rk-BuQy72IFLOqV0G_zS245-kronKb78cPN25DGlcTwLtjPAYuNzVBAh4vGHSrQyHUdBBPM" + } + } + ], + "proof": { + "type": "RsaSignature2018", + "created": "2018-09-14T21:19:10Z", + "proofPurpose": "authentication", + "verificationMethod": "did:example:ebfeb1f712ebc6f1c276e12ec21#keys-1", + "challenge": "1f44d55f-f161-4938-a659-f8026467f126", + "domain": "4jt78h47fh47", + "jws": "eyJhbGciOiJSUzI1NiIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..kTCYt5XsITJX1CxPCT8yAV-TVIw5WEuts01mq-pQy7UJiN5mgREEMGlv50aqzpqh4Qq_PbChOMqsLfRoPsnsgxD-WUcX16dUOqV0G_zS245-kronKb78cPktb3rk-BuQy72IFLN25DYuNzVBAh4vGHSrQyHUGlcTwLtjPAnKb78" + } +} diff --git a/packages/credentials/tests/VCs/valid/vp-example-22.json b/packages/credentials/tests/VCs/valid/vp-example-22.json new file mode 100644 index 000000000..62e0723de --- /dev/null +++ b/packages/credentials/tests/VCs/valid/vp-example-22.json @@ -0,0 +1,46 @@ +{ + "@context": [ + "https://www.w3.org/2018/credentials/v1", + "https://www.w3.org/2018/credentials/examples/v1", + { + "@protected": true, + "VerifiablePresentationTermsOfUseExtension": { + "@id": "https://www.w3.org/2018/credentials/examples#VerifiablePresentationExtension", + "@context": { + "@protected": true, + "termsOfUse": { + "@id": "https://www.w3.org/2018/credentials#termsOfUse", + "@type": "@id" + } + } + } + } + ], + "id": "did:example:ebfeb1f712ebc6f1c276e12ec21", + "type": [ + "VerifiablePresentation", + "VerifiablePresentationTermsOfUseExtension" + ], + "verifiableCredential": [ + { + "@context": [ + "https://www.w3.org/2018/credentials/v1", + "https://www.w3.org/2018/credentials/examples/v1" + ], + "id": "http://example.edu/credentials/3732", + "type": [ + "VerifiableCredential", + "UniversityDegreeCredential" + ], + "issuer": "https://example.edu/issuers/14", + "issuanceDate": "2010-01-01T19:23:24Z", + "credentialSubject": { + "id": "did:example:ebfeb1f712ebc6f1c276e12ec21", + "degree": { + "type": "BachelorDegree", + "name": "Bachelor of Science and Arts" + } + } + } + ] +} diff --git a/packages/credentials/tests/verifiable-credentials.spec.ts b/packages/credentials/tests/verifiable-credentials.spec.ts index a4a975d33..b4d49c7c5 100644 --- a/packages/credentials/tests/verifiable-credentials.spec.ts +++ b/packages/credentials/tests/verifiable-credentials.spec.ts @@ -63,11 +63,19 @@ describe('VerifiableCredentials', () => { expect(credential).to.have.property('credentialSubject'); }); - const validVCFilenames = globSync('./tests/VCs/valid/*.jwt'); - for(const filename of validVCFilenames) { + const validVCjwts = globSync('./tests/VCs/valid/*.jwt'); + for(const filename of validVCjwts) { it('loads and validates valid VC ' + filename, async () => { const jwt = fs.readFileSync(filename); await VerifiableCredential.verify(jwt.toString()); }); } + + const validVCjsons = globSync('./tests/VCs/valid/*.json'); + for(const filename of validVCjsons) { + it('loads and validates valid VC ' + filename, async () => { + const vc = JSON.parse(fs.readFileSync(filename).toString()); + VerifiableCredential.validatePayload(vc); + }); + } }); \ No newline at end of file