1
0

Compare commits

...

1 Commits

Author SHA1 Message Date
8952a12e4f Updated example code 2021-09-23 22:51:14 +02:00
3 changed files with 12 additions and 4 deletions

View File

@@ -31,6 +31,10 @@ async () => {
// Verifing token // Verifing token
const isValid = await jwt.verify(token, 'secret') const isValid = await jwt.verify(token, 'secret')
// Check for validity
if (!isValid)
return
// Decoding token // Decoding token
const payload = jwt.decode(token) const payload = jwt.decode(token)
} }
@@ -53,6 +57,10 @@ async () => {
// Verifing token // Verifing token
const isValid = await jwt.verify(token, 'secret') // false const isValid = await jwt.verify(token, 'secret') // false
// Check for validity
if (!isValid)
return
// Decoding token // Decoding token
const payload = jwt.decode(token) // { name: 'John Doe', email: 'john.doe@gmail.com', ... } const payload = jwt.decode(token) // { name: 'John Doe', email: 'john.doe@gmail.com', ... }
} }

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "@tsndr/cloudflare-worker-jwt", "name": "@tsndr/cloudflare-worker-jwt",
"version": "1.1.2", "version": "1.1.3",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@tsndr/cloudflare-worker-jwt", "name": "@tsndr/cloudflare-worker-jwt",
"version": "1.1.2", "version": "1.1.3",
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"tslint": "^6.1.3" "tslint": "^6.1.3"

View File

@@ -1,6 +1,6 @@
{ {
"name": "@tsndr/cloudflare-worker-jwt", "name": "@tsndr/cloudflare-worker-jwt",
"version": "1.1.2", "version": "1.1.3",
"description": "A lightweight JWT implementation with ZERO dependencies for Cloudflare Worker", "description": "A lightweight JWT implementation with ZERO dependencies for Cloudflare Worker",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {