Skip to content

Commit

Permalink
Merge branch 'main' of github.com:european-epc-competence-center/vc-v…
Browse files Browse the repository at this point in the history
…erifier
  • Loading branch information
Echsecutor committed Sep 10, 2024
2 parents ef1b72d + 1568628 commit edbb828
Show file tree
Hide file tree
Showing 22 changed files with 9,294 additions and 444 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
name: Tests

on: [ push ]
on: [push]

jobs:
test:

runs-on: ubuntu-latest

steps:
Expand All @@ -13,7 +12,9 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 18


- run: npm i @gs1us/vc-verifier-rules
working-directory: ./api
- run: npm ci
working-directory: ./api
- run: npm test
Expand Down
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,28 @@ VC Verifier Changelog
WIP
---

2.0.3 (2024-07-23)

- fix container startup

2.0.2 (2024-07-23)

- fix api url

2.0.1 (2024-07-23)

- fix show version

2.0.0 (2024-07-23)

- add gs1 verification endpoint
- use gs1 endpoint on gs1 credential

1.7.8 (2024-06-13)
---

- fix status verification for SD


1.7.7 (2023-11-21)
---
Expand Down
1 change: 1 addition & 0 deletions api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ WORKDIR /usr/src/app

COPY . .

RUN npm install @gs1us/vc-verifier-rules
RUN npm i
RUN npm run build-tsc

Expand Down
280 changes: 280 additions & 0 deletions api/__tests__/gs1.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,280 @@
import request from "supertest";

import server from "../src/index";

afterAll((done) => {
server.close();
done();
});

const licenceKeyCredential: any = {
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://ref.gs1.org/gs1/vc/license-context",
"https://w3id.org/security/suites/ed25519-2020/v1",
{
name: "https://schema.org/name",
description: "https://schema.org/description",
image: "https://schema.org/image",
},
"https://w3id.org/vc-revocation-list-2020/v1",
],
id: "https://id.gs1.org/vc/license/gs1_prefix/08",
type: ["VerifiableCredential", "GS1PrefixLicenseCredential"],
issuer: "did:web:id.gs1.org",
name: "GS1 Prefix License",
description:
"FOR DEMONSTRATION PURPOSES ONLY: NOT TO BE USED FOR PRODUCTION GRADE SYSTEMS! A company prefix that complies with GS1 Standards (a “GS1 Company Prefix”) is a unique identification number that is assigned to just your company by GS1 US. It’s the foundation of GS1 Standards and can be found in all of the GS1 Identification Numbers.",
issuanceDate: "2023-05-19T13:39:41.368Z",
credentialSubject: {
id: "did:web:cbpvsvip-vc.gs1us.org",
organization: {
"gs1:partyGLN": "0614141000005",
"gs1:organizationName": "GS1 US",
},
licenseValue: "08",
alternativeLicenseValue: "8",
},
proof: {
type: "Ed25519Signature2020",
created: "2023-05-19T13:39:41Z",
verificationMethod:
"did:web:id.gs1.org#z6MkkzYByKSsaWusRbYNZGAMvdd5utsPqsGKvrc7T9jyvUrN",
proofPurpose: "assertionMethod",
proofValue:
"z56N5j6WZRwAng8f12RNNPStBBmGLaozHkdPtDmMLwZmqo1EXW3juFZYpeyU7QRh6NRGxJtxMJvAXPq4PveR2bR7m",
},
};

const companyPrefixCredential: any = {
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://ref.gs1.org/gs1/vc/license-context",
"https://w3id.org/security/suites/ed25519-2020/v1",
{
name: "https://schema.org/name",
description: "https://schema.org/description",
image: "https://schema.org/image",
},
"https://w3id.org/vc-revocation-list-2020/v1",
],
issuer: "did:web:cbpvsvip-vc.gs1us.org",
name: "GS1 Company Prefix License",
description:
"THIS GS1 DIGITAL LICENSE CREDENTIAL IS FOR TESTING PURPOSES ONLY. A GS1 Company Prefix License is issued by a GS1 Member Organization or GS1 Global Office and allocated to a user company or to itself for the purpose of generating tier 1 GS1 identification keys.",
issuanceDate: "2021-05-11T10:50:36.701Z",
id: "http://did-vc.gs1us.org/vc/license/08600057694",
type: ["VerifiableCredential", "GS1CompanyPrefixLicenseCredential"],
credentialSubject: {
id: "did:key:z6Mkfb3kW3kBP4UGqaBEQoCLBUJjdzuuuPsmdJ2LcPMvUreS/1",
organization: {
"gs1:partyGLN": "0860005769407",
"gs1:organizationName": "Healthy Tots",
},
extendsCredential: "https://id.gs1.org/vc/license/gs1_prefix/08",
licenseValue: "08600057694",
alternativeLicenseValue: "8600057694",
},
credentialStatus: {
id: "https://cbpvsvip-vc.dev.gs1us.org/status/2c0a1f02-d545-481b-902a-1e919cd706e2/1193",
type: "RevocationList2020Status",
revocationListIndex: 1193,
revocationListCredential:
"https://cbpvsvip-vc.dev.gs1us.org/status/2c0a1f02-d545-481b-902a-1e919cd706e2/",
},
proof: {
type: "Ed25519Signature2020",
created: "2023-05-22T16:55:59Z",
verificationMethod:
"did:web:cbpvsvip-vc.gs1us.org#z6Mkig1nTEAxna86Pjb71SZdbX3jEdKRqG1krDdKDatiHVxt",
proofPurpose: "assertionMethod",
proofValue:
"zfWTiZ9CRLJBUUHRFa82adMZFwiAvYCsTwRjX7JaTpUnVuCTj44f9ErSGbTBWezv89MyKQ3jTLFgWUbUvB6nuJCN",
},
};

const orgDataCredentialPresentation: any = {
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://w3id.org/security/suites/ed25519-2020/v1",
],
type: ["VerifiablePresentation"],
verifiableCredential: [
{
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://ref.gs1.org/gs1/vc/license-context",
"https://w3id.org/security/suites/ed25519-2020/v1",
{
name: "https://schema.org/name",
description: "https://schema.org/description",
image: "https://schema.org/image",
},
"https://w3id.org/vc-revocation-list-2020/v1",
],
issuer: "did:web:cbpvsvip-vc.gs1us.org",
name: "GS1 Company Prefix License",
description:
"THIS GS1 DIGITAL LICENSE CREDENTIAL IS FOR TESTING PURPOSES ONLY. A GS1 Company Prefix License is issued by a GS1 Member Organization or GS1 Global Office and allocated to a user company or to itself for the purpose of generating tier 1 GS1 identification keys.",
issuanceDate: "2021-05-11T10:50:36.701Z",
id: "http://did-vc.gs1us.org/vc/license/08600057694",
type: ["VerifiableCredential", "GS1CompanyPrefixLicenseCredential"],
credentialSubject: {
id: "did:key:z6Mkfb3kW3kBP4UGqaBEQoCLBUJjdzuuuPsmdJ2LcPMvUreS/1",
organization: {
"gs1:partyGLN": "0860005769407",
"gs1:organizationName": "Healthy Tots",
},
extendsCredential: "https://id.gs1.org/vc/license/gs1_prefix/08",
licenseValue: "08600057694",
alternativeLicenseValue: "8600057694",
},
credentialStatus: {
id: "https://cbpvsvip-vc.dev.gs1us.org/status/2c0a1f02-d545-481b-902a-1e919cd706e2/1193",
type: "RevocationList2020Status",
revocationListIndex: 1193,
revocationListCredential:
"https://cbpvsvip-vc.dev.gs1us.org/status/2c0a1f02-d545-481b-902a-1e919cd706e2/",
},
proof: {
type: "Ed25519Signature2020",
created: "2023-05-22T16:55:59Z",
verificationMethod:
"did:web:cbpvsvip-vc.gs1us.org#z6Mkig1nTEAxna86Pjb71SZdbX3jEdKRqG1krDdKDatiHVxt",
proofPurpose: "assertionMethod",
proofValue:
"zfWTiZ9CRLJBUUHRFa82adMZFwiAvYCsTwRjX7JaTpUnVuCTj44f9ErSGbTBWezv89MyKQ3jTLFgWUbUvB6nuJCN",
},
},
{
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://ref.gs1.org/gs1/vc/license-context",
"https://ref.gs1.org/gs1/vc/declaration-context",
"https://w3id.org/security/suites/ed25519-2020/v1",
{
name: "https://schema.org/name",
description: "https://schema.org/description",
image: "https://schema.org/image",
},
"https://w3id.org/vc-revocation-list-2020/v1",
],
issuer: "did:web:cbpvsvip-vc.gs1us.org",
name: "GS1 Key Credential",
description:
"THIS GS1 DIGITAL LICENSE CREDENTIAL IS FOR TESTING PURPOSES ONLY. This is the Verifiable Credential that indicates that something has been identified. It contains no data about what has been identified as that is done via the association process. This credential is used only to indicate that the key that it contains exists and is valid.",
id: "did:key:z6MkkzTNsyFfx4VQFkSs3R7q8nKN5twGrM8538Xu7YXym6mW",
type: ["VerifiableCredential", "KeyCredential"],
credentialSubject: {
id: "https://id.gs1.org/417/0860005769407",
extendsCredential: "http://did-vc.gs1us.org/vc/license/08600057694",
},
credentialStatus: {
id: "https://cbpvsvip-vc.dev.gs1us.org/status/2c0a1f02-d545-481b-902a-1e919cd706e2/1195",
type: "RevocationList2020Status",
revocationListIndex: 1195,
revocationListCredential:
"https://cbpvsvip-vc.dev.gs1us.org/status/2c0a1f02-d545-481b-902a-1e919cd706e2/",
},
issuanceDate: "2023-05-22T17:02:41Z",
proof: {
type: "Ed25519Signature2020",
created: "2023-05-22T17:02:41Z",
verificationMethod:
"did:web:cbpvsvip-vc.gs1us.org#z6Mkig1nTEAxna86Pjb71SZdbX3jEdKRqG1krDdKDatiHVxt",
proofPurpose: "assertionMethod",
proofValue:
"zsZsQaGwTpbDNAwPDDK4aPoiVWYDTQcgmgRzb7CP74eEyGE4atrudRjFx7EMndFsNnWx1qh1WUSgEWa6ZTTeBPdb",
},
},
{
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://ref.gs1.org/gs1/vc/license-context",
"https://ref.gs1.org/gs1/vc/declaration-context",
"https://ref.gs1.org/gs1/vc/organization-context",
"https://w3id.org/security/suites/ed25519-2020/v1",
{
name: "https://schema.org/name",
description: "https://schema.org/description",
image: "https://schema.org/image",
},
"https://w3id.org/vc-revocation-list-2020/v1",
],
issuer: "did:web:cbpvsvip-vc.gs1us.org",
name: "GS1 Party Identification Credential",
description:
"THIS GS1 DIGITAL LICENSE CREDENTIAL IS FOR TESTING PURPOSES ONLY. The party data credential is the Verifiable Credential that is shared with parties interested in the basic information associated with a party identified by a GLN.",
issuanceDate: "2021-05-11T10:50:36.701Z",
id: "did:key:z6MkfEHKfq5vmXXDs6AuE1xt58WySEoLPKLGLoWHHuF1pmVm",
type: ["VerifiableCredential", "OrganizationDataCredential"],
credentialSubject: {
id: "did:key:z6MktUvJtDf1tx6TFuxEb3NxAV3KmWx6j8BVp3jM9TheiFsX/1",
sameAs: "https://id.gs1.org/417/0860005769407",
keyAuthorization:
"did:key:z6MkkzTNsyFfx4VQFkSs3R7q8nKN5twGrM8538Xu7YXym6mW",
organization: {
"gs1:partyGLN": "0860005769407",
"gs1:organizationName": "Healthy Tots",
},
},
credentialStatus: {
id: "https://cbpvsvip-vc.dev.gs1us.org/status/2c0a1f02-d545-481b-902a-1e919cd706e2/1194",
type: "RevocationList2020Status",
revocationListIndex: 1194,
revocationListCredential:
"https://cbpvsvip-vc.dev.gs1us.org/status/2c0a1f02-d545-481b-902a-1e919cd706e2/",
},
proof: {
type: "Ed25519Signature2020",
created: "2023-05-22T17:01:12Z",
verificationMethod:
"did:web:cbpvsvip-vc.gs1us.org#z6Mkig1nTEAxna86Pjb71SZdbX3jEdKRqG1krDdKDatiHVxt",
proofPurpose: "assertionMethod",
proofValue:
"z43LLp9h8SKASz3bGKYfy68SaWutdzH9Jz542LHjKwTHWEJafcPorDazU2NPydzHknmxj9rEbrr9Lkzkh5ikpxQcp",
},
},
],
id: "urn:uuid:c1lb4rsf9cfamox0e1qfr5",
holder: "urn:uuid:c1lb4rsf9cfamox0e1qfr5:holder",
proof: {
type: "Ed25519Signature2020",
created: "2023-05-22T17:04:10Z",
verificationMethod:
"did:web:cbpvsvip-vc.gs1us.org#z6Mkig1nTEAxna86Pjb71SZdbX3jEdKRqG1krDdKDatiHVxt",
proofPurpose: "authentication",
challenge: "tst123",
proofValue:
"z2Mv46TpVBzJn5LM9WBg5CkBGScKkVhUyf34xmzvURXVWoqg4r3Xywwbg9AbD54Aus9KAoWFkmGhFeGUZi3fwck7G",
},
};

describe("Verifier API Test for GS1 Credentials", () => {
test("Verify GS1 licence prefix credentials", async () => {
const res = await request(server)
.post("/api/verifier/gs1")
.send(licenceKeyCredential);
expect(res.statusCode).toEqual(200);
expect(res.body).toHaveProperty("verified");
expect(res.body.verified).toBe(true);
});

test("Verify GS1 company licence prefix credentials", async () => {
const res = await request(server)
.post("/api/verifier/gs1")
.send(companyPrefixCredential);
expect(res.statusCode).toEqual(200);
expect(res.body).toHaveProperty("verified");
expect(res.body.verified).toBe(true);
});

test("Verify GS1 data presentation", async () => {
const res = await request(server)
.post("/api/verifier/gs1")
.send(orgDataCredentialPresentation);
expect(res.statusCode).toEqual(200);
expect(res.body).toHaveProperty("verified");
expect(res.body.verified).toBe(true);
});
});
3 changes: 3 additions & 0 deletions api/__tests__/presentation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ describe("Verifier API Test for Presentations", () => {
});
});

/* todo: re enable + fix test
test("Verify single presentation with challenge & domain", async () => {
const res = await request(server).post("/api/verifier").query({ challenge: '12345', domain: 'ssi.eecc.de/verifier' }).send([domainPresentation]);
expect(res.statusCode).toEqual(200);
Expand All @@ -237,6 +238,7 @@ describe("Verifier API Test for Presentations", () => {
expect(el.verified).toBe(true);
});
});
test("Falsify single presentation with wrong challenge", async () => {
const res = await request(server).post("/api/verifier").query({ challenge: 'falseChallenge', domain: 'ssi.eecc.de/verifier' }).send([domainPresentation]);
Expand All @@ -247,4 +249,5 @@ describe("Verifier API Test for Presentations", () => {
expect(res.body[0].error.name).toBe('VerificationError');
});
*/
});
Loading

0 comments on commit edbb828

Please sign in to comment.