Skip to content

Commit

Permalink
Extend test app and demo issuer front-ends with "is adult" credential (
Browse files Browse the repository at this point in the history
…#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
  • Loading branch information
Frederik Rothenberger authored Dec 12, 2023
1 parent 0f2e4cf commit 9b3d183
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
7 changes: 7 additions & 0 deletions demos/test-app/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -507,6 +511,9 @@ const App = () => {
<button data-action="verify-grad" onClick={() => startVcFlow("grad")}>
Verify Graduate Credential
</button>
<button data-action="verify-adult" onClick={() => startVcFlow("adult")}>
Verify Adult Person Credential
</button>

<pre data-role="presentation">{latestPresentation}</pre>
</>
Expand Down
20 changes: 20 additions & 0 deletions demos/vc_issuer/app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<main data-page="add-employee">
Expand Down Expand Up @@ -131,6 +138,19 @@ const App = () => {
Add employee
</button>
)}
{principal ? (
<button
data-action="add-adult"
disabled={dsbld}
onClick={() => addAdult(principal)}
>
Add Adult
</button>
) : (
<button data-action="add-adult" disabled={dsbld || !principal}>
Add Adult
</button>
)}
</section>
</main>
);
Expand Down
5 changes: 5 additions & 0 deletions demos/vc_issuer/app/issuer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> => {
const actor = await this.createActor();
return await actor.add_adult(Principal.fromText(principal));
};
}
4 changes: 2 additions & 2 deletions demos/vc_issuer/src/consent_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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."###;

Expand Down

0 comments on commit 9b3d183

Please sign in to comment.