UNPKG
@metacall/protocol
Version:
latest (0.1.35)
0.1.35
0.1.34
0.1.33
0.1.32
0.1.31
0.1.30
0.1.29
0.1.28
0.1.27
0.1.26
0.1.25
0.1.24
0.1.23
0.1.21
0.1.20
0.1.19
0.1.18
0.1.17
0.1.16
0.1.15
0.1.14
0.1.13
0.1.12
0.1.11
0.1.9
0.1.8
0.1.5
Tool for deploying into MetaCall FaaS platform.
github.com/metacall/protocol
metacall/protocol
@metacall/protocol
/
src
/
token.ts
11 lines
(9 loc)
•
284 B
text/typescript
View Raw
1
2
3
4
5
6
7
8
9
10
11
import
jwt
from
'jsonwebtoken'
;
export
const
expiresIn = (
token
:
string
):
number
=>
{
const
decoded = jwt.
decode
(token);
if
(
typeof
decoded ===
'string'
) {
return
0
; }
const
now =
Date
.
now
() /
1000
;
return
new
Date
((decoded?.[
'exp'
] || now) *
1000
).
getTime
() - now *
1000
; };