Skip to content

Commit

Permalink
fix: update example code
Browse files Browse the repository at this point in the history
Signed-off-by: Mirko Mollik <mirko.mollik@fit.fraunhofer.de>
  • Loading branch information
cre8 committed Mar 8, 2024
1 parent f91e3e3 commit 84a8d36
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 8 deletions.
10 changes: 9 additions & 1 deletion examples/core-example/all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion examples/core-example/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion examples/core-example/custom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 12 additions & 3 deletions examples/core-example/custom_header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion examples/core-example/decoy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion examples/core-example/kb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 84a8d36

Please sign in to comment.