Skip to content

Commit

Permalink
update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
pilcrowonpaper committed Sep 18, 2024
1 parent 089932e commit 0eeae65
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@
"dependencies": {
"@oslojs/crypto": "0.6.0",
"@oslojs/encoding": "0.4.1",
"@oslojs/jwt": "0.1.0"
"@oslojs/jwt": "0.2.0"
}
}
5 changes: 2 additions & 3 deletions src/oidc.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { parseJWT } from "@oslojs/jwt";
import { decodeJWT } from "@oslojs/jwt";

export function decodeIdToken(idToken: string): object {
try {
const [_header, payload, _signature] = parseJWT(idToken);
return payload;
return decodeJWT(idToken);
} catch (e) {
throw new Error("Invalid ID token", {
cause: e
Expand Down
12 changes: 6 additions & 6 deletions src/providers/apple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,29 +62,29 @@ export class Apple {
["sign"]
);
const now = Math.floor(Date.now() / 1000);
const header = {
const headerJSON = JSON.stringify({
typ: "JWT",
alg: "ES256",
kid: this.keyId
};
const payload = {
});
const payloadJSON = JSON.stringify({
iss: this.teamId,
exp: now + 5 * 60,
aud: ["https://appleid.apple.com"],
sub: this.clientId,
iat: now
};
});
const signature = new Uint8Array(
await crypto.subtle.sign(
{
name: "ECDSA",
hash: "SHA-256"
},
privateKey,
createJWTSignatureMessage(header, payload)
createJWTSignatureMessage(headerJSON, payloadJSON)
)
);
const jwt = encodeJWT(header, payload, signature);
const jwt = encodeJWT(headerJSON, payloadJSON, signature);
return jwt;
}
}

0 comments on commit 0eeae65

Please sign in to comment.