From f29e494a8cb6a9de30682a59feb6adee7e15b1e7 Mon Sep 17 00:00:00 2001 From: Martin Domajnko <35891136+martines3000@users.noreply.github.com> Date: Fri, 12 Apr 2024 16:01:02 +0200 Subject: [PATCH] fix: adjust iat and nbf for id token signing (#625) --- .changeset/young-forks-jog.md | 5 +++++ packages/snap/snap.manifest.json | 2 +- packages/snap/src/utils/sign.ts | 6 +++--- 3 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 .changeset/young-forks-jog.md diff --git a/.changeset/young-forks-jog.md b/.changeset/young-forks-jog.md new file mode 100644 index 000000000..f1204ee82 --- /dev/null +++ b/.changeset/young-forks-jog.md @@ -0,0 +1,5 @@ +--- +"@blockchain-lab-um/masca": patch +--- + +Adjust nbf and iat for idtoken signing diff --git a/packages/snap/snap.manifest.json b/packages/snap/snap.manifest.json index 9059a8554..eac6a89a6 100644 --- a/packages/snap/snap.manifest.json +++ b/packages/snap/snap.manifest.json @@ -26,7 +26,7 @@ "./files/circuits/credentialAtomicQuerySigV2/circuit_final.zkey", "./files/circuits/credentialAtomicQuerySigV2/verification_key.json" ], - "shasum": "BOsLk3unGah8h8EbmeUV37papTKym1Tlb+sYI/sK1wg=" + "shasum": "BxBaqzALa1v9aL1XW5mcXd/ppZOisCN+LmrEjpifQ4E=" }, "initialPermissions": { "endowment:ethereum-provider": {}, diff --git a/packages/snap/src/utils/sign.ts b/packages/snap/src/utils/sign.ts index ca060aec1..5f4f6b37e 100644 --- a/packages/snap/src/utils/sign.ts +++ b/packages/snap/src/utils/sign.ts @@ -26,9 +26,9 @@ export const sign = async (signArgs: SignArgs, signOptions: SignOptions) => { const jwtPayload = { ...signArgs.payload, - exp: Math.floor(Date.now() / 1000) + 60 * 60, - iat: Math.floor(Date.now() / 1000), - nbf: Math.floor(Date.now() / 1000), + exp: Math.floor(new Date().getTime() / 1000) + 60 * 60, // 1 hour in the future + iat: Math.floor(new Date().getTime() / 1000) - 60, // 1 minute in the past + nbf: Math.floor(new Date().getTime() / 1000) - 60, // 1 minute in the past iss: did, sub: did, };