From 84a8d365508fffcd34d72149f9462767a116c4f5 Mon Sep 17 00:00:00 2001 From: Mirko Mollik Date: Mon, 26 Feb 2024 13:36:42 +0100 Subject: [PATCH] fix: update example code Signed-off-by: Mirko Mollik --- examples/core-example/all.ts | 10 +++++++++- examples/core-example/basic.ts | 10 +++++++++- examples/core-example/custom.ts | 10 +++++++++- examples/core-example/custom_header.ts | 15 ++++++++++++--- examples/core-example/decoy.ts | 10 +++++++++- examples/core-example/kb.ts | 10 +++++++++- 6 files changed, 57 insertions(+), 8 deletions(-) diff --git a/examples/core-example/all.ts b/examples/core-example/all.ts index 34c0c70..aaccfd0 100644 --- a/examples/core-example/all.ts +++ b/examples/core-example/all.ts @@ -53,7 +53,15 @@ import { createSignerVerifier, digest, generateSalt } from './utils'; // Issue a signed JWT credential with the specified claims and disclosures // Return a Encoded SD JWT. Issuer send the credential to the holder - const credential = await sdjwt.issue(claims, disclosureFrame); + const credential = await sdjwt.issue( + { + iss: 'Issuer', + iat: new Date().getTime(), + vct: 'https://example.com', + ...claims, + }, + disclosureFrame, + ); console.log('encodedJwt:', credential); // Holder Receive the credential from the issuer and validate it diff --git a/examples/core-example/basic.ts b/examples/core-example/basic.ts index 8bbbc94..a9cedaa 100644 --- a/examples/core-example/basic.ts +++ b/examples/core-example/basic.ts @@ -30,7 +30,15 @@ import { createSignerVerifier, digest, generateSalt } from './utils'; // Issue a signed JWT credential with the specified claims and disclosures // Return a Encoded SD JWT. Issuer send the credential to the holder - const credential = await sdjwt.issue(claims, disclosureFrame); + const credential = await sdjwt.issue( + { + iss: 'Issuer', + iat: new Date().getTime(), + vct: 'https://example.com', + ...claims, + }, + disclosureFrame, + ); // Holder Receive the credential from the issuer and validate it // Return a boolean result diff --git a/examples/core-example/custom.ts b/examples/core-example/custom.ts index 0d9aa23..263dd27 100644 --- a/examples/core-example/custom.ts +++ b/examples/core-example/custom.ts @@ -30,7 +30,15 @@ import { createSignerVerifier, digest, generateSalt } from './utils'; // Issue a signed JWT credential with the specified claims and disclosures // Return a Encoded SD JWT. Issuer send the credential to the holder - const credential = await sdjwt.issue(claims, disclosureFrame); + const credential = await sdjwt.issue( + { + iss: 'Issuer', + iat: new Date().getTime(), + vct: 'https://example.com', + ...claims, + }, + disclosureFrame, + ); console.log('encodedJwt:', credential); // Holder Receive the credential from the issuer and validate it diff --git a/examples/core-example/custom_header.ts b/examples/core-example/custom_header.ts index d4581df..b993f8b 100644 --- a/examples/core-example/custom_header.ts +++ b/examples/core-example/custom_header.ts @@ -30,9 +30,18 @@ import { createSignerVerifier, digest, generateSalt } from './utils'; // Issue a signed JWT credential with the specified claims and disclosures // Return a Encoded SD JWT. Issuer send the credential to the holder - const credential = await sdjwt.issue(claims, disclosureFrame, { - header: { typ: 'vc+sd-jwt', custom: 'data' }, // You can add custom header data to the SD JWT - }); + const credential = await sdjwt.issue( + { + iss: 'Issuer', + iat: new Date().getTime(), + vct: 'https://example.com', + ...claims, + }, + disclosureFrame, + { + header: { typ: 'vc+sd-jwt', custom: 'data' }, // You can add custom header data to the SD JWT + }, + ); console.log('encodedSdjwt:', credential); // You can check the custom header data by decoding the SD JWT diff --git a/examples/core-example/decoy.ts b/examples/core-example/decoy.ts index 58e9e91..4359d11 100644 --- a/examples/core-example/decoy.ts +++ b/examples/core-example/decoy.ts @@ -26,7 +26,15 @@ import { createSignerVerifier, digest, generateSalt } from './utils'; _sd: ['id'], _sd_decoy: 1, // 1 decoy digest will be added in SD JWT }; - const credential = await sdjwt.issue(claims, disclosureFrame); + const credential = await sdjwt.issue( + { + iss: 'Issuer', + iat: new Date().getTime(), + vct: 'https://example.com', + ...claims, + }, + disclosureFrame, + ); console.log('encodedSdjwt:', credential); // You can check the decoy digest in the SD JWT by decoding it diff --git a/examples/core-example/kb.ts b/examples/core-example/kb.ts index fe0d62c..7c5b59d 100644 --- a/examples/core-example/kb.ts +++ b/examples/core-example/kb.ts @@ -34,7 +34,15 @@ import { createSignerVerifier, digest, generateSalt } from './utils'; sd_hash: '1234', }; - const encodedSdjwt = await sdjwt.issue(claims, disclosureFrame); + const encodedSdjwt = await sdjwt.issue( + { + iss: 'Issuer', + iat: new Date().getTime(), + vct: 'https://example.com', + ...claims, + }, + disclosureFrame, + ); console.log('encodedSdjwt:', encodedSdjwt); const sdjwttoken = await sdjwt.decode(encodedSdjwt); console.log(sdjwttoken);