{"_id":"@around25/jwt-utils","_rev":"7-c09542bb3a8263a614ae21e5310b683a","name":"@around25/jwt-utils","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@around25/jwt-utils","version":"1.0.0","description":"Perform jwt token operations like store, get, decode, get expiration date, check if expired, validate, remove from storage","main":"index.js","scripts":{"test":"jest"},"keywords":["jwt","token"],"author":{"name":"Calin Tamas","email":"calin.tamas@around25.com"},"license":"MIT","dependencies":{"jwt-decode":"^2.2.0"},"gitHead":"b9cadfdffe62edda2ea335584055b5e2d1b678d1","_id":"@around25/jwt-utils@1.0.0","_npmVersion":"5.3.0","_nodeVersion":"8.5.0","_npmUser":{"name":"calintamas","email":"calinntamas@gmail.com"},"dist":{"integrity":"sha512-FId+qDKnsg9qIHznSFB0kQtiiJPesG5aKR9mCzNVahsRacHP6566Nelq9rYzxPoeoq77w6KiThkH0BL+z9PQHQ==","shasum":"b387803fbfbb638fa59350650c4a4afa1b253eae","tarball":"https://registry.npmjs.org/@around25/jwt-utils/-/jwt-utils-1.0.0.tgz","fileCount":8,"unpackedSize":7775,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJa8ZHJCRA9TVsSAnZWagAAaI8QAIkLlIIUoz/R2HArPU7a\nEz82AjimsI+DDflduNiGvF0E7DzIgLPGSbt5Rf5C8P10fA1OZrOikf7TNJnF\nLOmDTAgSvb89L7d4w5KsW6xwYfmALmEDjAAZOgNyhjyddE8SV6JC04uEjSmr\nI+SdloyqpPH3KYxaCnHfrSSBmaHp1vv6VO23R386DsVtQhsjuEcbBj+n0Adz\n/GwFTFG7L3cYoMWxZ9yur6weRf1kC86BRyzZrIu+qwR5Uz5fZ72q3ZFB9yrx\nIRu86cgzr45S0OqlTWlsET3SqvaA4Yxs8HW8NPZY8bI2uEQo8RNbMAI8to8y\neTyWkuoUCGNiFttNOZ3k+kZbpYpGGsodTiCrenn3u/sjVp4ru3F63Xq2XLq8\neohIV5XVaGUJksvIQerxEMmQVbKH9mIuKHK/nt5ByqTp5X4SN7kNtwnlArbA\ncLWQ6WZnGImyATKwq/a5GBu3hlh8MWT3JXrzcOdb6FU8bVm7H0r6qr1rVKKp\n15HgpvSoABa8zDAVBU2fMvS8ngLNySgnlUAVKZ6A5PXlG5+QA34WPpCwJZ6t\n+0jU2vbzPB6GaAWq3L6459zuEGm2xsEuoAMKX5cIceFwi53FVF0FAKtEfBh/\nOY7jsWcXVm0Zas5DYsI/QmCB1SKfMZ8EazwPb4jax/HWmoU7p9FycS58LwuM\nd/It\r\n=L3yz\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFZ/izhb7MXA1+keL5pDJgWileFhpI05WmuV0/eaYwl0AiEAn2N8CkFTi6JYnb6puadd5WoM+9ydf8rINhfVIRlRkc0="}]},"maintainers":[{"name":"alinporumb","email":"alin.porumb@gmail.com"},{"name":"andreirat","email":"andrei.rat@around25.com"},{"name":"calintamas","email":"calinntamas@gmail.com"},{"name":"cosminharangus","email":"cosmin@around25.com"},{"name":"cupsadarius","email":"cupsadarius@gmail.com"},{"name":"daniel.suciu.developer","email":"suciudaniel2@gmail.com"},{"name":"deniel","email":"denielheinrich@gmail.com"},{"name":"gabicg","email":"dogabicg@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/jwt-utils_1.0.0_1525780936533_0.7080751820253359"},"_hasShrinkwrap":false},"1.0.1":{"name":"@around25/jwt-utils","version":"1.0.1","description":"Perform jwt token operations like store, get, decode, get expiration date, check if expired, validate, remove from storage","main":"index.js","scripts":{"test":"jest"},"keywords":["jwt","token"],"author":{"name":"Calin Tamas","email":"calin.tamas@around25.com"},"license":"MIT","dependencies":{"jwt-decode":"^2.2.0"},"directories":{"lib":"lib","test":"tests"},"devDependencies":{},"repository":{"type":"git","url":"git+https://github.com/Around25/jwt-utils.git"},"bugs":{"url":"https://github.com/Around25/jwt-utils/issues"},"homepage":"https://github.com/Around25/jwt-utils#readme","gitHead":"b9cadfdffe62edda2ea335584055b5e2d1b678d1","_id":"@around25/jwt-utils@1.0.1","_npmVersion":"5.3.0","_nodeVersion":"8.5.0","_npmUser":{"name":"calintamas","email":"calinntamas@gmail.com"},"dist":{"integrity":"sha512-beolqnz7PTTNveaLsfxvMAZCXFT+rNlwd2fNguXt5zSt6nRZ1SvbwWmrAnxiL196IaNyS/Jjd46G/mFBOtDkrw==","shasum":"db20390b5e4f1a46119383a7095663669565b714","tarball":"https://registry.npmjs.org/@around25/jwt-utils/-/jwt-utils-1.0.1.tgz","fileCount":8,"unpackedSize":8100,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJa8ZKICRA9TVsSAnZWagAA2agP/0rN+Tm4fBm44hwST/kB\nYFtOTplhlGrNTkUFEhvpvRX2GoWmvYnYrmyqIhSQAXY6mtH/rGUH6SLhM3D6\nZDG/XnJw70qQmv/3ro/VbX456OnT9UevfW+PWQRTlIXosqhjNEr9gWtez4dG\nOeBvRAO1GXcucViSOdDXltDU0vwHRFSJAEHQE2Amv9X3CX3ZDMYjHQoqjSZZ\nzDFQD7vtde0cUMmNOFkONm2cqHtCBrskfOw31x0+1EoSS8/iNqDdbDAfOjBb\nas9yCgz8gpZO1hLhCyQLAscuAn3fPWh0/VTap4HPSOLYI4RhSWCIcdvU86QR\nIL+QJ+7QG/wIhHr2uuXCbYkUlLtFanadlZG2Z6zfU4Yrxc+KLolUa4JkfoNB\nCv8OPRUgHWA4mhnquncmqWZ4FCUx5qHfqOC3B2p+ehoAsOsZC2Yr6+IltG/C\nL3MSLfwo1UtgNewXiCA8E9gxt/zmcdADlgYmezFJDhA0wCVt+k/r9fJfm0Kc\n1kj3t6a0G/C9j/cSQEAEYUpGkg+SPJ0kU/UsVwsxoivHc05sUJ1WL4vWwndQ\nqUiErokmH0Rl9/mAMkJ2i6o3vXEnoNYqczk95gvpRSYdQjWflHyEt6LY1gM5\neHTGlxQZgDKkeM6H00D4nuqwyqRtdBoc6hhDXu0Svf37FaVjV0jGHtS9P6Ki\nIw84\r\n=lThG\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEwWtExT4/x4sOfOxw/AyUmnjdxX0hYG3XfgG/WPExoFAiAA5UO51P0CoWDtcXspAn958SIAREWt9zi51bh3C5+3Tw=="}]},"maintainers":[{"name":"alinporumb","email":"alin.porumb@gmail.com"},{"name":"andreirat","email":"andrei.rat@around25.com"},{"name":"calintamas","email":"calinntamas@gmail.com"},{"name":"cosminharangus","email":"cosmin@around25.com"},{"name":"cupsadarius","email":"cupsadarius@gmail.com"},{"name":"daniel.suciu.developer","email":"suciudaniel2@gmail.com"},{"name":"deniel","email":"denielheinrich@gmail.com"},{"name":"gabicg","email":"dogabicg@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/jwt-utils_1.0.1_1525781127985_0.6344720650654283"},"_hasShrinkwrap":false}},"time":{"created":"2018-05-08T12:02:16.480Z","1.0.0":"2018-05-08T12:02:16.946Z","modified":"2022-04-04T15:34:03.670Z","1.0.1":"2018-05-08T12:05:28.058Z"},"maintainers":[{"email":"farcas.bianca25@gmail.com","name":"biancap"},{"email":"adrian@around25.com","name":"adrian.boros"},{"email":"dogabicg@gmail.com","name":"gabicg"},{"email":"suciudaniel2@gmail.com","name":"daniel.suciu.developer"},{"email":"cupsadarius@gmail.com","name":"cupsadarius"},{"email":"calinntamas@gmail.com","name":"calintamas"},{"email":"cosmin@around25.com","name":"cosminharangus"}],"description":"Perform jwt token operations like store, get, decode, get expiration date, check if expired, validate, remove from storage","keywords":["jwt","token"],"author":{"name":"Calin Tamas","email":"calin.tamas@around25.com"},"license":"MIT","readme":"A small package to perform [JWT](https://jwt.io/) token operations (store, get, decode, get expiration date, check if expired, validate, remove from storage).\n\nWorks in `React` and `React Native`.\n\n## Installation\n```\nnpm install --save jwt-utils\n```\n\n## Usage\n\nInitialize the package and then import in wherever you need it. The constructor takes a single config object as parameter. The `storageSystem` property is required.\n\n```js\nimport TokenService from 'jwt-utils'\n\nconst TokenUtils = new TokenService({\n  storageSystem: window.localStorage\n});\n\nexport default TokenUtils\n```\n\nIn the `React` environment, it can be either [window.localStorage](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage) or [window.sessionStorage](https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage). And it's totally synchronous.\n\n#### Store\nStores token using the specified storage system. Token must be a `string`.\n```js\n// Take a properly formatted JWT token\nconst token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjEiLCJuYW1lIjoiSm9obiBEb2UiLCJleHAiOjE1MjU3MDAxNjE1NjJ9.qGB98H-4th9E0yTVHH235A4kCgFyKt5jIVgekk4fcp4'\n\nTokenUtils.store(token);\n```\n\n#### Get\nRetrieves the stored token if set, `undefined` otherwise.\n```js\nconst token = TokenUtils.get();\n\n// eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjEiLCJuY...\n```\n\n#### Decode\nDecodes a token. A falsy token will return `{}`.\n```js\nconst decodedToken = TokenUtils.decode(token);\n\n// {\n//   id: 1,\n//   name: \"John Doe\",\n//   exp: 1525700161562\n// }\n```\n\n#### Get expiration date\nReturns expiration date as unix timestamp (ms) or null if the `exp` property is not defined in the decoded token.\n```js\nconst expirationDate = TokenUtils.getExpirationDate(token);\n\n// 1525700161562\n```\n\n#### Check if expired\nReturns a `boolean` value specifying if token is expired or not.\n```js\nconst isExpired = TokenUtils.isExpired(token);\n```\n\n#### Check if valid\nChecks if token is valid, simply by checking its existence. You can optionally use a validation function as a secondary param. In that case, the validation function should return a `boolean` value.\n```js\nconst isValid = TokenUtils.isValid(token, validationFunc);\n```\n\n#### Remove from storage\nRemoves token from storage\n```js\nTokenUtils.remove(token);\n```\n\n## Usage with React Native\nIn the `React Native` environment, `store`, `get` and `remove` methods return promises (due to the `async` nature of the storage system).\n```js\nimport { AsyncStorage } from 'react-native'\nimport TokenService from 'jwt-utils'\n\nexport default new TokenService({\n  storageSystem: AsyncStorage\n});\n```\n\n```js\nconst result = await TokenUtils.store(token);\n// true\n\nconst token = await TokenUtils.get();\n// eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjEiLCJuY...\n```\n\n## External dependencies\n\nThis package depends on [jwt-decode](https://github.com/auth0/jwt-decode) for token decoding.\n","readmeFilename":"readme.md","homepage":"https://github.com/Around25/jwt-utils#readme","repository":{"type":"git","url":"git+https://github.com/Around25/jwt-utils.git"},"bugs":{"url":"https://github.com/Around25/jwt-utils/issues"}}