{"_id":"@aravsanj/verify-token","_rev":"1-250bc364bd1fa6e8ab3dbce04741ecc9","name":"@aravsanj/verify-token","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@aravsanj/verify-token","version":"1.0.0","description":"A package used to verify the JWT token for HackerConnect project","main":"index.js","type":"module","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/aravsanj/verify-token.git"},"author":{"name":"Aravind Sanjeev"},"license":"GPL-3.0","bugs":{"url":"https://github.com/aravsanj/verify-token/issues"},"homepage":"https://github.com/aravsanj/verify-token#readme","dependencies":{"dotenv":"^16.3.1","jsonwebtoken":"^9.0.2"},"gitHead":"4ae49b09c620e8e937622e8822825f7b84385e0a","_id":"@aravsanj/verify-token@1.0.0","_nodeVersion":"18.13.0","_npmVersion":"8.19.3","dist":{"integrity":"sha512-DPUcSsxtZCOPdHJ14Mjw6/QhKvB8Gj64YByEx4RGBfCiX58222iAUGyQsigJXqEk/+b4R7WpqriCgKaEwiXAEA==","shasum":"fc8899c242fec003dc0f03741660da1a50b5671d","tarball":"https://registry.npmjs.org/@aravsanj/verify-token/-/verify-token-1.0.0.tgz","fileCount":2,"unpackedSize":1107,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFKm4UJ3bdEer6pXMM9AobhtkdE/hhnipAk1AbWsdWECAiEA6Hpdn9CxJyMeZ2tpRBMW0vJz3syARyncw61nhFwdGxk="}]},"_npmUser":{"name":"aravsanj","email":"saravind436@gmail.com"},"directories":{},"maintainers":[{"name":"aravsanj","email":"saravind436@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/verify-token_1.0.0_1700717864009_0.3980258860291317"},"_hasShrinkwrap":false},"1.0.1":{"name":"@aravsanj/verify-token","version":"1.0.1","description":"A package used to verify the JWT token for HackerConnect project","main":"index.js","type":"module","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/aravsanj/verify-token.git"},"author":{"name":"Aravind Sanjeev"},"license":"GPL-3.0","bugs":{"url":"https://github.com/aravsanj/verify-token/issues"},"homepage":"https://github.com/aravsanj/verify-token#readme","dependencies":{"dotenv":"^16.3.1","jsonwebtoken":"^9.0.2"},"gitHead":"973e71ef1620afeb3123ad6428bf3feb351384b1","_id":"@aravsanj/verify-token@1.0.1","_nodeVersion":"18.13.0","_npmVersion":"8.19.3","dist":{"integrity":"sha512-EsqGQGWkOZ5SXSirpdBuCgD/0iNGPVwWSOG7sOjKG5Ult15E4IVyalgjVS26P/lCfdO6MVWdR5tg5hEjeIvnOg==","shasum":"605a63091e324caa8abc97e2415e2f56114ed143","tarball":"https://registry.npmjs.org/@aravsanj/verify-token/-/verify-token-1.0.1.tgz","fileCount":3,"unpackedSize":2197,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD6OzdizwAaLjxtHO3o54c3efG9n2kqLyWMV65E6VeV5gIhAIipHG5T0LTer+1Vy6b04gbQnFfzu/bHv5YyE7Q7iHcI"}]},"_npmUser":{"name":"aravsanj","email":"saravind436@gmail.com"},"directories":{},"maintainers":[{"name":"aravsanj","email":"saravind436@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/verify-token_1.0.1_1700966977181_0.4288455832337499"},"_hasShrinkwrap":false}},"time":{"created":"2023-11-23T05:37:43.918Z","1.0.0":"2023-11-23T05:37:44.201Z","modified":"2023-11-26T02:49:37.509Z","1.0.1":"2023-11-26T02:49:37.335Z"},"maintainers":[{"name":"aravsanj","email":"saravind436@gmail.com"}],"description":"A package used to verify the JWT token for HackerConnect project","homepage":"https://github.com/aravsanj/verify-token#readme","repository":{"type":"git","url":"git+https://github.com/aravsanj/verify-token.git"},"author":{"name":"Aravind Sanjeev"},"bugs":{"url":"https://github.com/aravsanj/verify-token/issues"},"license":"GPL-3.0","readme":"# verify-token\n\nIt's a simple package that exports a express middleware function called verifyJWT. Internally it uses `jsonwebtoken` and `dotenv`.\n\nYou can provide your secret in the `.env` file with variable name `SECRET`. The package will automatically pick it up and use it as your JWT secret.\n\nThe token should be stored in the cookie with key value `access-token`.\n\nThe result will be attached in `req.user`.\n\nOr you can just recreate the below code inside your node project and avoid additional dependencies.\n\n```js\nimport jwt from \"jsonwebtoken\";\nimport dotenv from \"dotenv\";\n\ndotenv.config();\n\nfunction verifyJWT(req, res, next) {\n  const accessToken = req.cookies[\"access-token\"];\n\n  if (!accessToken) {\n    return res.status(401).send({ isLoggedIn: false });\n  }\n\n  jwt.verify(accessToken, process.env.SECRET, (err, user) => {\n    if (err) {\n      return res.status(401).send({ isLoggedIn: false });\n    }\n    req.user = user;\n  });\n  next();\n}\n\nexport default verifyJWT;\n```\n\nPlease, this was not intended for public use as it was developed as a side gig for my personal project.","readmeFilename":"README.md"}