Skip to content

Commit

Permalink
fix: Fix iat expiration check
Browse files Browse the repository at this point in the history
  • Loading branch information
nklomp committed Apr 24, 2024
1 parent a453002 commit 1260291
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/issuer/lib/VcIssuer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ export class VcIssuer<DIDDoc extends object> {
credentialDataSupplier?: CredentialDataSupplier
credentialDataSupplierInput?: CredentialDataSupplierInput
newCNonce?: string
cNonceExpiresIn?: number
tokenExpiresIn?: number
cNonceExpiresIn?: number // expiration duration in seconds
tokenExpiresIn?: number // expiration duration in seconds
jwtVerifyCallback?: JWTVerifyCallback<DIDDoc>
credentialSignerCallback?: CredentialSignerCallback<DIDDoc>
responseCNonce?: string
Expand Down Expand Up @@ -417,7 +417,7 @@ export class VcIssuer<DIDDoc extends object> {
tokenExpiresIn,
}: {
credentialRequest: UniformCredentialRequest
tokenExpiresIn: number
tokenExpiresIn: number // expiration duration in seconds
// grants?: Grant,
clientId?: string
jwtVerifyCallback?: JWTVerifyCallback<DIDDoc>
Expand Down Expand Up @@ -519,7 +519,8 @@ export class VcIssuer<DIDDoc extends object> {
}
if (!iat) {
throw new Error(IAT_ERROR)
} else if (iat > createdAt + tokenExpiresIn * 1000) {
} else if (iat > (createdAt/1000 + tokenExpiresIn)) {
// createdAt is in milliseconds whilst iat and tokenExpiresIn are in seconds
throw new Error(IAT_ERROR)
}
// todo: Add a check of iat against current TS on server with a skew
Expand Down

0 comments on commit 1260291

Please sign in to comment.