File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ export const verifyJwt = async (publicKey, jwt) => {
47
47
throw new Error ( 'Invalid JWT' )
48
48
}
49
49
const payload = _parse ( payloadBase64 )
50
- if ( payload . exp != null && time . getUnixTime ( ) > payload . exp ) {
50
+ if ( payload . exp != null && time . getUnixTimeInSeconds ( ) > payload . exp ) {
51
51
throw new Error ( 'Expired JWT' )
52
52
}
53
53
return {
Original file line number Diff line number Diff line change @@ -21,6 +21,13 @@ export const getDate = () => new Date()
21
21
*/
22
22
export const getUnixTime = Date . now
23
23
24
+ /**
25
+ * Return current Unix time in seconds (since epoch).
26
+ *
27
+ * @return {number } current Unix time in seconds
28
+ */
29
+ export const getUnixTimeInSeconds = ( ) => Math . floor ( Date . now ( ) / 1000 )
30
+
24
31
/**
25
32
* Transform time (in ms) to a human readable format. E.g. 1100 => 1.1s. 60s => 1min. .001 => 10μs.
26
33
*
You can’t perform that action at this time.
0 commit comments