Skip to content

Commit 4d6d46b

Browse files
committed
Update exp types to follow up updates in jsonwebtoken
1 parent b3904f4 commit 4d6d46b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/utils/jwt.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import fs from 'fs';
22
import jsonwebtoken, { SignOptions, VerifyOptions } from 'jsonwebtoken';
3+
import { StringValue } from 'ms';
34
import path from 'path';
45

56
const { JWT_PRI_FILENAME = '', JWT_PUB_FILENAME = '', JWT_ISS = '' } = process.env;
@@ -14,7 +15,7 @@ const tolerance = 10; // 10s tolerance for difference between servers
1415
export type JwtPayload = jsonwebtoken.JwtPayload;
1516
export type VerifyErrors = jsonwebtoken.VerifyErrors;
1617

17-
export const createSignOpt = (sub: string, aud: string, exp: string = '1d'): SignOptions => {
18+
export const createSignOpt = (sub: string, aud: string, exp: StringValue = '1d'): SignOptions => {
1819
return {
1920
algorithm: alg,
2021
expiresIn: exp,
@@ -34,7 +35,7 @@ export const createVerifyOpt = (aud: string | RegExp): VerifyOptions => {
3435
};
3536
};
3637

37-
export const sign = (payload: object, sub: string, aud: string, exp: string = '1d') =>
38+
export const sign = (payload: object, sub: string, aud: string, exp: StringValue = '1d') =>
3839
jsonwebtoken.sign(payload, priFile, createSignOpt(sub, aud, exp));
3940

4041
export const verify = (token: string, aud: string | RegExp) =>

0 commit comments

Comments
 (0)