Merge pull request #17 from IMZihad21/main
Destructure payload from decode function properly
This commit is contained in:
2
index.js
2
index.js
@@ -94,7 +94,7 @@ class JWT {
|
|||||||
const importAlgorithm = this.algorithms[options.algorithm]
|
const importAlgorithm = this.algorithms[options.algorithm]
|
||||||
if (!importAlgorithm)
|
if (!importAlgorithm)
|
||||||
throw new Error('algorithm not found')
|
throw new Error('algorithm not found')
|
||||||
const payload = this.decode(token)
|
const { payload } = this.decode(token)
|
||||||
if (payload.nbf && payload.nbf > Math.floor(Date.now() / 1000)) {
|
if (payload.nbf && payload.nbf > Math.floor(Date.now() / 1000)) {
|
||||||
if (options.throwError)
|
if (options.throwError)
|
||||||
throw 'NOT_YET_VALID'
|
throw 'NOT_YET_VALID'
|
||||||
|
|||||||
Reference in New Issue
Block a user