Skip to content

Commit

Permalink
fix: adjust iat and nbf for id token signing (#625)
Browse files Browse the repository at this point in the history
  • Loading branch information
martines3000 authored Apr 12, 2024
1 parent 45a1293 commit f29e494
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/young-forks-jog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@blockchain-lab-um/masca": patch
---

Adjust nbf and iat for idtoken signing
2 changes: 1 addition & 1 deletion packages/snap/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {},
Expand Down
6 changes: 3 additions & 3 deletions packages/snap/src/utils/sign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down

0 comments on commit f29e494

Please sign in to comment.