Skip to content

Commit a9f993f

Browse files
committed
Fixed arg for clockSkew and default to 5.
1 parent 255d813 commit a9f993f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/token-verifier.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ export class FirebaseTokenVerifier {
229229
* @param clockSkewSeconds - The number of seconds to tolerate when checking the token's iat. Must be between 0-60, and an integer. Defualts to 0.
230230
* @returns A promise fulfilled with the decoded claims of the Firebase Auth ID token.
231231
*/
232-
public verifyJWT(jwtToken: string, isEmulator = false, clockSkewSeconds: number = 0): Promise<FirebaseIdToken> {
232+
public verifyJWT(jwtToken: string, isEmulator = false, clockSkewSeconds: number = 5): Promise<FirebaseIdToken> {
233233
if (!isString(jwtToken)) {
234234
throw new FirebaseAuthError(
235235
AuthClientErrorCode.INVALID_ARGUMENT,
@@ -243,13 +243,13 @@ export class FirebaseTokenVerifier {
243243
'clockSkewSeconds must be an integer between 0 and 60.'
244244
)
245245
}
246-
return this.decodeAndVerify(jwtToken, isEmulator, 0).then(payload => {
246+
return this.decodeAndVerify(jwtToken, isEmulator, clockSkewSeconds).then(payload => {
247247
payload.uid = payload.sub;
248248
return payload;
249249
});
250250
}
251251

252-
private async decodeAndVerify(token: string, isEmulator: boolean, clockSkewSeconds: number = 0): Promise<FirebaseIdToken> {
252+
private async decodeAndVerify(token: string, isEmulator: boolean, clockSkewSeconds: number = 5): Promise<FirebaseIdToken> {
253253
const currentTimestamp = Math.floor(Date.now() / 1000) + clockSkewSeconds;
254254
try {
255255
const rs256Token = this.safeDecode(token, isEmulator, currentTimestamp);

0 commit comments

Comments
 (0)