Skip to content

Commit 1260291

Browse files
committed
fix: Fix iat expiration check
1 parent a453002 commit 1260291

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

packages/issuer/lib/VcIssuer.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,8 @@ export class VcIssuer<DIDDoc extends object> {
230230
credentialDataSupplier?: CredentialDataSupplier
231231
credentialDataSupplierInput?: CredentialDataSupplierInput
232232
newCNonce?: string
233-
cNonceExpiresIn?: number
234-
tokenExpiresIn?: number
233+
cNonceExpiresIn?: number // expiration duration in seconds
234+
tokenExpiresIn?: number // expiration duration in seconds
235235
jwtVerifyCallback?: JWTVerifyCallback<DIDDoc>
236236
credentialSignerCallback?: CredentialSignerCallback<DIDDoc>
237237
responseCNonce?: string
@@ -417,7 +417,7 @@ export class VcIssuer<DIDDoc extends object> {
417417
tokenExpiresIn,
418418
}: {
419419
credentialRequest: UniformCredentialRequest
420-
tokenExpiresIn: number
420+
tokenExpiresIn: number // expiration duration in seconds
421421
// grants?: Grant,
422422
clientId?: string
423423
jwtVerifyCallback?: JWTVerifyCallback<DIDDoc>
@@ -519,7 +519,8 @@ export class VcIssuer<DIDDoc extends object> {
519519
}
520520
if (!iat) {
521521
throw new Error(IAT_ERROR)
522-
} else if (iat > createdAt + tokenExpiresIn * 1000) {
522+
} else if (iat > (createdAt/1000 + tokenExpiresIn)) {
523+
// createdAt is in milliseconds whilst iat and tokenExpiresIn are in seconds
523524
throw new Error(IAT_ERROR)
524525
}
525526
// todo: Add a check of iat against current TS on server with a skew

0 commit comments

Comments
 (0)