From 9b3d18381d9d3907371bc21018efc543794baef6 Mon Sep 17 00:00:00 2001 From: Frederik Rothenberger Date: Tue, 12 Dec 2023 14:48:49 +0100 Subject: [PATCH] Extend test app and demo issuer front-ends with "is adult" credential (#2133) * Extend test app and demo issuer front-ends with "is adult" credential This PR adds front-end support for the demo applications to go through the attribute sharing flow with an "Is adult person" credential. * Remove trailing comma from consent message title --- demos/test-app/src/index.tsx | 7 +++++++ demos/vc_issuer/app/index.tsx | 20 ++++++++++++++++++++ demos/vc_issuer/app/issuer.ts | 5 +++++ demos/vc_issuer/src/consent_message.rs | 4 ++-- 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/demos/test-app/src/index.tsx b/demos/test-app/src/index.tsx index d5a1f4bb51..b930e413ae 100644 --- a/demos/test-app/src/index.tsx +++ b/demos/test-app/src/index.tsx @@ -345,6 +345,10 @@ const credentialSpecs = { credentialType: "UniversityDegreeCredential", arguments: { institutionName: "DFINITY College of Engineering" }, }, + adult: { + credentialType: "VerifiedAdult", + arguments: { age_at_least: 18 }, + }, } as const; type CredType = keyof typeof credentialSpecs; @@ -507,6 +511,9 @@ const App = () => { +
{latestPresentation}
diff --git a/demos/vc_issuer/app/index.tsx b/demos/vc_issuer/app/index.tsx index 7964f04fbb..1df778fe4f 100644 --- a/demos/vc_issuer/app/index.tsx +++ b/demos/vc_issuer/app/index.tsx @@ -73,6 +73,13 @@ const App = () => { const res: string = await vcIssuer.addEmployee({ principal }); setCanisterLogs([...canisterLogs, res]); }); + const addAdult = (principal: string) => + withDisabled(async () => { + const canisterId = readCanisterId(); + const vcIssuer = new VcIssuer(canisterId); + const res: string = await vcIssuer.addAdult({ principal }); + setCanisterLogs([...canisterLogs, res]); + }); return (
@@ -131,6 +138,19 @@ const App = () => { Add employee )} + {principal ? ( + + ) : ( + + )}
); diff --git a/demos/vc_issuer/app/issuer.ts b/demos/vc_issuer/app/issuer.ts index ae1ea738b2..31ed00a26e 100644 --- a/demos/vc_issuer/app/issuer.ts +++ b/demos/vc_issuer/app/issuer.ts @@ -31,4 +31,9 @@ export class VcIssuer { const actor = await this.createActor(); return await actor.add_employee(Principal.fromText(principal)); }; + + addAdult = async ({ principal }: { principal: string }): Promise => { + const actor = await this.createActor(); + return await actor.add_adult(Principal.fromText(principal)); + }; } diff --git a/demos/vc_issuer/src/consent_message.rs b/demos/vc_issuer/src/consent_message.rs index fbba611fe5..6709b38e31 100644 --- a/demos/vc_issuer/src/consent_message.rs +++ b/demos/vc_issuer/src/consent_message.rs @@ -24,10 +24,10 @@ const DEGREE_VC_DESCRIPTION_DE: &str = r###"# Bachelor of Engineering, {institut Ausweis, der bestätigt, dass der Besitzer oder die Besitzerin einen Bachelorabschluss in einer Ingenieurwissenschaft des {institute} besitzt."###; -const ADULT_VC_DESCRIPTION_EN: &str = r###"# Verified Adult, +const ADULT_VC_DESCRIPTION_EN: &str = r###"# Verified Adult Credential that states that the holder's age is at least {age_at_least} years."###; -const ADULT_VC_DESCRIPTION_DE: &str = r###"# Erwachsene Person, +const ADULT_VC_DESCRIPTION_DE: &str = r###"# Erwachsene Person Ausweis, der bestätigt, dass der Besitzer oder die Besitzerin mindestens {age_at_least} Jahre alt ist."###;