Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
OR13 committed Aug 10, 2024
1 parent 18bc6db commit ac13592
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/v2/holder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const holder = (options: RequestHolder = {}) => {
throw new Error('alg must be passed as an option or restricted via privateKeyJwk')
}
return {
issue: async ({ token, disclosure, audience, nonce }: { token: string, disclosure: string, audience ?: string, nonce ?: string }): Promise<PresentedCompactSdJwt> => {
issue: async ({ token, disclosure, audience, nonce }: { token: string, disclosure: string, audience ?: string | string[], nonce ?: string }): Promise<PresentedCompactSdJwt> => {
if (options.privateKeyJwk){
options.signer = await JWS.signer(options.privateKeyJwk)
}
Expand Down
32 changes: 32 additions & 0 deletions test/audience.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,35 @@ it('nonce can be undefined', async () => {
expect(verification.protectedHeader).toBeDefined()
expect(verification.claimset).toBeDefined()
});



it('audience can be an array', async () => {
const audience = ['verifier-1', 'verifier-2'];
const nonce = 'nonce-456';
const { publicKeyJwk, privateKeyJwk } = await sd.key.generate(alg);
const vc = await sd.issuer({ privateKeyJwk })
.issue({
jwk: publicKeyJwk,
claimset
})
const vp = await sd.holder({ privateKeyJwk })
.issue({
token: vc,
disclosure,
audience,
nonce
})
const verification = await sd.verifier({
publicKeyJwk,
debug: false // set to true for debug logs
})
.verify({
token: vp,
audience: 'verifier-1',
nonce
})
// TODO: add type to object
expect(verification.protectedHeader).toBeDefined()
expect(verification.claimset).toBeDefined()
});
1 change: 0 additions & 1 deletion test/vc-jose-cose-test/vc-jose-cose.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ it('W3C VC JOSE COSE Test', async () => {
salter
})


const claimsYaml = fs.readFileSync(`test/vc-jose-cose-test/payload.yaml`).toString()
const vc = await issuer.issue({
jwk: holderKeyPair.publicKeyJwk,
Expand Down

0 comments on commit ac13592

Please sign in to comment.