{"_id":"@chantouchsek/jwt-redis","_rev":"1-2c80bf7395f241366a9dddd5edcdf164","name":"@chantouchsek/jwt-redis","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.1":{"name":"@chantouchsek/jwt-redis","version":"0.0.1","description":"This library completely repeats the entire functionality of the library [jsonwebtoken](https://www.npmjs.com/package/jsonwebtoken), with one important addition. Jwt-redis allows you to store the token label in redis to verify validity. The absence of a to","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"clean":"rimraf dist","build":"yarn clean && tsc","start":"ts-node-dev -r tsconfig-paths/register src/JwtRedis.ts","prepare":"npm run build","test":"jest --coverage","release":"yarn prepare && semantic-release","prepublish":"yarn test && yarn prepare"},"author":{"name":"Chantouch Sek","email":"chantouchsek.cs83@gmail.com"},"license":"ISC","keywords":["jwt","redis","node","nodejs","jwt-blacklist","jsonwebtoken"],"repository":{"type":"git","url":"git+https://github.com/Chantouch/jwt-redis.git"},"bugs":{"url":"https://github.com/Chantouch/jwt-redis.git/issues","email":"chantouchsek.cs83@gmail.com"},"homepage":"https://github.com/Chantouch/jwt-redis.git#readme","devDependencies":{"@babel/core":"^7.10.5","@babel/preset-env":"^7.10.4","@babel/preset-typescript":"^7.10.4","@types/jest":"^26.0.7","@types/jsonwebtoken":"^8.5.0","@types/redis":"^2.8.25","babel-jest":"^26.1.0","jest":"^26.1.0","redis-mock":"^0.50.0","rimraf":"^3.0.2","semantic-release":"^17.1.1","ts-jest":"^26.1.4","ts-node-dev":"^1.0.0-pre.56","tsconfig-paths":"^3.9.0","typescript":"^3.9.7","@semantic-release/changelog":"^5.0.1","@semantic-release/commit-analyzer":"^8.0.1","@semantic-release/git":"^9.0.0","@semantic-release/github":"^7.0.7","@semantic-release/npm":"^7.0.5","@semantic-release/release-notes-generator":"^9.0.1"},"dependencies":{"jsonwebtoken":"^8.5.1"},"peerDependencies":{"@types/redis":"^2.8.25","redis":"^3.0.2"},"gitHead":"5489df1c757869b406e388dccd066de92d67b80e","_id":"@chantouchsek/jwt-redis@0.0.1","_nodeVersion":"13.11.0","_npmVersion":"6.14.7","dist":{"integrity":"sha512-ngDVhUPaAOo1QHFSTi5ags0r89JUPXWod+5qEu0ogHu5Gk8/RtmLN8IFBoedPRL+PgVtNmG0+nuc0OT+jNOMiA==","shasum":"e5bd0676f003a6ba7fa628fde46dbf6dee7e631f","tarball":"https://registry.npmjs.org/@chantouchsek/jwt-redis/-/jwt-redis-0.0.1.tgz","fileCount":14,"unpackedSize":20973,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfISXlCRA9TVsSAnZWagAAMKkP/R9DlD0EGzpkyM++fjQ+\nktGhdD+KCJs4uyKyBE2pI/armiHdyizMR+OUza6ige5+mDTqU2/DUudM3HZp\nSyGxIjwo/pqEpn2BAsIH20c3jIAb504ou/MPw748Wl3nkKVg6yQ+s3igyC1X\n8M8OazM6hm6j8cE1TJHi+bf2kiv2Xz7EQHJz/E5AHMjxSWGOZsYaAg78n867\no/fXLAwW6iH069lr0sk9ODfUu9l6XQnDqDySwBU8bWzfb2QOQIdpJRwTdJZC\nQHVfXtK1MljnRH+BJz2Zw+dFdJL+ZtufEfQpk+SIcFiUeN3wQ/15F5EMOSKh\nnHKwAb10dKhWgTId6F5D12d6ynXJNM7CynkcGkuxEgKz7E2M3+7uIyiiVkL6\nwmb0XbGjaJ1B6NDuyzN3EWq39eKColizci0R1cJyvl1/TyJo301mLCpwdIXn\n3sG2dOv2a4+FXX7kQzVnXEfixcAQV0hCB3hDVxdaWeXCVT6+AWvaFkeup3Pf\nwNQxVpnHUOtv/KQbvqzg9BKBlhzUsgO9JTrMlhJ/YFGFDtWzTxXmpatzZdmb\nqqqEg+w6phF+712ZAoPF1NhuASSdfvDkumDDgSvjMQSC6g4id1klRxC2/EFU\nRu3glpYh2PUwjTGL5TuJTXnNleFt8hXpuvTL//FNpMGOGbRgeDgi6x7kG8FH\nZQ/D\r\n=GWEF\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHtYRQeTiJxR39krrK3mVgSqsF4WOTnP/tvuGlVNyHAQAiBDi3UovXjlqHAUjn2YRa2VqqLmiUVI38bJ/OAxCFVKXw=="}]},"maintainers":[{"name":"chantouchsek","email":"chantouchsek.cs83@gmail.com"}],"_npmUser":{"name":"chantouchsek","email":"chantouchsek.cs83@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/jwt-redis_0.0.1_1596007908582_0.9383610503684701"},"_hasShrinkwrap":false}},"time":{"created":"2020-07-29T07:31:48.546Z","0.0.1":"2020-07-29T07:31:48.783Z","modified":"2022-04-04T22:30:58.421Z"},"maintainers":[{"name":"chantouchsek","email":"chantouchsek.cs83@gmail.com"}],"description":"This library completely repeats the entire functionality of the library [jsonwebtoken](https://www.npmjs.com/package/jsonwebtoken), with one important addition. Jwt-redis allows you to store the token label in redis to verify validity. The absence of a to","homepage":"https://github.com/Chantouch/jwt-redis.git#readme","keywords":["jwt","redis","node","nodejs","jwt-blacklist","jsonwebtoken"],"repository":{"type":"git","url":"git+https://github.com/Chantouch/jwt-redis.git"},"author":{"name":"Chantouch Sek","email":"chantouchsek.cs83@gmail.com"},"bugs":{"url":"https://github.com/Chantouch/jwt-redis.git/issues","email":"chantouchsek.cs83@gmail.com"},"license":"ISC","readme":"# jwt-redis\n\nThis library completely repeats the entire functionality of the library [jsonwebtoken](https://www.npmjs.com/package/jsonwebtoken), with one important addition.\nJwt-redis allows you to store the token label in redis to verify validity.\nThe absence of a token label in redis makes the token not valid. To destroy the token in **jwt-redis**, there is a destroy method.\nThis makes it possible to make a token not valid until it expires.\nJwt-redis support [node_redis](https://www.npmjs.com/package/redis) client.\n\n[![Build Status](https://travis-ci.org/Chantouch/jwt-redis.svg?branch=master)](https://travis-ci.org/Chantouch/jwt-redis.svg?branch=master)\n[![Latest Version on NPM](https://img.shields.io/npm/v/@chantouchsek/jwt-redis.svg?style=flat-square)](https://npmjs.com/package/@chantouchsek/jwt-redis)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)\n[![npm](https://img.shields.io/npm/dt/@chantouchsek/jwt-redis.svg?style=flat-square)](https://npmjs.com/package/@chantouchsek/jwt-redis)\n[![npm](https://img.shields.io/npm/dm/@chantouchsek/jwt-redis.svg?style=flat-square)](https://npmjs.com/package/@chantouchsek/jwt-redis)\n\n# Installation\n\nNpm\n```npm\nnpm install @chantouchsek/jwt-redis\n```\n\nYarn\n```yarn\nyarn add @chantouchsek/jwt-redis\n```\n\n# Support\n\nThis library is quite fresh, and maybe has bugs. Write me an **email** to *chantouchsek.cs83@gmail.com* and I will\n fix the bug in a few working days.\n\n# Quick start\n\n```js\nconst redis = require('redis')\nconst JWTR =  require('@chantouchsek/jwt-redis').default \n//ES6 import JWTR from '@chantouchsek/jwt-redis';\nconst redisClient = redis.createClient()\nconst jwtr = new JWTR(redisClient)\n\nconst secret = 'secret'\nconst jti = 'test'\nconst payload = { jti }\n\n// Create a token\njwtr.sign(payload, secret)\n    .then(()=>{\n            // Token verification\n            return jwtr.verify(token, secret);\n    })\n    .then(()=>{\n            // Destroying the token\n            return jwtr.destroy(jti, secret);\n    });\n```\n\n# Expiration time\nYou can set the lifetime of the token the same way as in the [jsonwebtoken](https://www.npmjs.com/package/jsonwebtoken) library.\nThe label in redis is deleted when the token expires.\n```js\n    // expiresIn - number of seconds through which the token will not be valid\n    await jwtr.sign({}, 'secret', {expiresIn: expiresIn})\n    // exp - time at which the token will not be valid\n    await  jwtr.sign({exp: exp}, secret)\n```\n\n# Create jti\n\nFor each token, the claims are added **jti**. **Jti** is the identifier of the token.\nYou can decide for yourself what it will be equal by adding its values to payload.\n\n```js\n    const payload = {jti: 'test'}\n    await jwtr.sign(payload, secret)\n```\n\nIf **jti** is not present, then **jti** is generated randomly by the library.\n\n# Destroy token\n\nYou can destroy the token through jti.\n\n```js\n    await jwtr.destroy(jti)\n```\n\n\n# Native Promise\n\nAll methods except the decode method (since it is synchronous) can return a native Promise.\n\n```js\ntry {\n  const token = await jwtr.sign({}, secret)\n  console.log(token);\n} catch (e) {\n  console.log(e)\n}\n```\n\n# Bluebird\n\nIf you want to use **Bluebird**, then after the promiscilation all the methods of the library will be available that return Promise,\nOnly at the end of each method should you add **Async**.\n\n```js\n    const Promise = require('bluebird')\n    const Redis = require('ioredis')\n    const redis = new Redis()\n    const JWTR =  require('@chantouchsek/jwt-redis')\n    //ES6 import JWTR from 'jwt-redis';\n    const jwtr = new JWTR(redis)\n    const jwtrAsync = Promise.promisifyAll(jwtr)\n\n    jwtrAsync\n    .signAsync({}, secret)\n    .then(function (token) {\n\n    })\n    .catch(function (err) {\n\n    })\n```\n\n# API\n\nMethod for creating a token.\n### jwtr.sign(payload, secretOrPrivateKey, [options]): Promise<string> ###\n\nMethod for verifying a token\n### jwtr.verify<T>(token, secretOrPublicKey, [options]): Promise<T> ###\n\nMethod for breaking the token\n### jwtr.destroy(jti, [options]): Promise<void> ###\n\nMethod for decoding token\n### jwt.decode<T>(token, [options]): T ###\n\njwt-redis fully supports all method options that support the library [jsonwebtoken](https://www.npmjs.com/package/jsonwebtoken).\nTherefore, it is better to read their documentation in addition. But there are several options that are available only in jwt-redis.\n\nAlso in the options you can specify a prefix for the redis keys. By default it is *jwt_label:*.\n\n```js\nconst options = {\n    prefix: 'example'\n}\nconst jwtr = new JWTR(redis, options)\n```\n\n# TypesScript\n\nThis library have typing in module.\n","readmeFilename":"README.md"}