-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from transmute-industries/fix-presentation-to-…
…cliams fix credential formatting in presentationToClaims
- Loading branch information
Showing
2 changed files
with
101 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,21 @@ | ||
import * as jose from 'jose' | ||
import * as jose from "jose"; | ||
|
||
it('JWT sign and verify', async () => { | ||
const { publicKey, privateKey } = await jose.generateKeyPair('ES256') | ||
it("JWT sign and verify", async () => { | ||
const { publicKey, privateKey } = await jose.generateKeyPair("ES256"); | ||
const jws = await new jose.CompactSign( | ||
new TextEncoder().encode(JSON.stringify({ | ||
iss: 'urn:uuid:123' | ||
})), | ||
new TextEncoder().encode( | ||
JSON.stringify({ | ||
iss: "urn:uuid:123", | ||
}) | ||
) | ||
) | ||
.setProtectedHeader({ alg: 'ES256' }) | ||
.sign(privateKey) | ||
.setProtectedHeader({ alg: "ES256" }) | ||
.sign(privateKey); | ||
|
||
const { payload, protectedHeader } = await jose.jwtVerify(jws, publicKey, { | ||
issuer: 'urn:uuid:123', | ||
issuer: "urn:uuid:123", | ||
audience: undefined, | ||
}) | ||
expect(protectedHeader.alg).toBe('ES256') | ||
expect(payload.iss).toBe('urn:uuid:123') | ||
}) | ||
}); | ||
expect(protectedHeader.alg).toBe("ES256"); | ||
expect(payload.iss).toBe("urn:uuid:123"); | ||
}); |