{"_id":"@aftabmk/cookie","_rev":"2-885e481f3fe99a37a921ed60e09c9fff","name":"@aftabmk/cookie","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"@aftabmk/cookie","version":"1.0.0","description":"This package is used to create dynamic cookie value and authenticate the created cookie to prevent external tampering.This is simple and plain way to create advanced binaary based cookie with no effort.It primarly targeted for beginner coders","main":"index.js","scripts":{"test":"node run index.js"},"keywords":["cookie","cookie-parser","set-cookie","cookies","set-cookies","easy-cookie","cookie-beginner"],"author":{"name":"Aftab Mohamed Kizhissery"},"license":"MIT","gitHead":"f9245be40920f5f00c24a84f796056ebb6edd052","_id":"@aftabmk/cookie@1.0.0","_nodeVersion":"18.6.0","_npmVersion":"8.13.2","dist":{"integrity":"sha512-YnYFqpthKG6mXlq5bB+29vRMsDQZzJnwEu3EKEVD4iOA982xSq4FVwPCIDR2lnRFUW1ZhXJkA+Fsj1jUPHR8Hg==","shasum":"9548185abb72c2ddd72033e80dba67891d945b5b","tarball":"https://registry.npmjs.org/@aftabmk/cookie/-/cookie-1.0.0.tgz","fileCount":5,"unpackedSize":1630,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDwOPvB8p2xaE5lNYH14X63s0gQWi+ibzxWO1Kx1D9tGwIhALf6n8xcFy8dqAM44yW8vZv5zvlKkh54afAO5BrzcIyJ"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjTsfLACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpBzg/8DKC0g88Z+7f1BzH2DH84EVt1tEYiDFnMRHYe+9gkgzLEHRls\r\nSvLXX1rtOKseT9A9zNHqmRAAEA4z9QnZG+HiiBYfHZUY7jPDgy6P5308Rhnl\r\n10/f8wB6k09MnQfRN04DJcIM9HB/RV0Ta8P9jTK1/6yHLgaq6Ic0XKAVdIBN\r\nivnpzDXlUIlE4ibzoBzQB8dDVWic4zLxpn/oHf5P+gGt6fdJ4ahZDF6l7KlR\r\nz3vDxISYwmgBYMpK8BmPqgL1ax8xQmvhj4bkndSPBg0t3avLJGYiWbLJU49i\r\nZMCc47q8lsqaYdehhniqQEUNatQB/mIhix2fCbdBSP0eCJbNfFIKT5fnA5Ry\r\nNUyna0TH/wCNJluwD7V5VCuYacfFa26ydl+XsAW5FAjzr5L05rPP8RcYcodK\r\nIEaYD9eX5M3ojp4Xt9pPVojAMj7HukREcHqrS6GMaZdN3anWLH4OLgMLXfVV\r\niN2JiXPKzL60s9xmoMfV/UP3kcjP2a43IPFabYJ3R695RwnwoMko3tt5JdlO\r\nAxbQutYSvnYjYf+/7dytlK7lcI0IhT9OvESwnjGeWGG7Z2T/Fq1LwNOZa+bm\r\nmaZxswhwiYKk2TNIPeztawFlEth4JymJ8FRY7yP6V9t9tODIKVPDo08FoSgS\r\nGZ6lFRpmgGI7HMxrC7OTZoFI707s2FDHkbo=\r\n=/7iN\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"aftabmk","email":"aftabmk.work@gmail.com"},"directories":{},"maintainers":[{"name":"aftabmk","email":"aftabmk.work@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cookie_1.0.0_1666107339796_0.007092431726618331"},"_hasShrinkwrap":false},"1.0.1":{"name":"@aftabmk/cookie","version":"1.0.1","description":"This package is used to create dynamic cookie value and authenticate the created cookie to prevent external tampering.This is simple and plain way to create advanced binaary based cookie with no effort.It primarly targeted for beginner coders","main":"index.js","scripts":{"test":"node run index.js"},"keywords":["cookie","cookie-parser","set-cookie","cookies","set-cookies","easy-cookie","cookie-beginner"],"author":{"name":"Aftab Mohamed Kizhissery"},"license":"MIT","gitHead":"5aecf067bcb4e043a02aca8c481aa19b9e405374","_id":"@aftabmk/cookie@1.0.1","_nodeVersion":"18.6.0","_npmVersion":"8.13.2","dist":{"integrity":"sha512-tjgRHRlGQOWwTc0BhCA+dHnr/IgBlBLnmMyWUSrQjJyNyMvf/FW5FE1ACq/jJvGjOetWyJeodD6p5jH18ihGFg==","shasum":"5fb599db029dd49bde45901e7024c51f475e766f","tarball":"https://registry.npmjs.org/@aftabmk/cookie/-/cookie-1.0.1.tgz","fileCount":7,"unpackedSize":194578,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD/DYaElGQ3NvuTR24gAPlx/q398d3e+7xDUC7IhO//NQIgb5D2PGCrgk1A0ImprDKRZda7AHNhv/Qcn7OGpe1f1/8="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjTt0sACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqvjA/8DPDkCfbQPf4bTqSCNupfoiVsIUwEYuR3y8Dzufjg/NRJK4y2\r\n+F3QRQ4KJPuLwaWiLcpbzTR3/fIp1u+32IDRLolv9Q6Pfbz6bh7KteV0soRl\r\n8uCP65vS05tURaOFO/qc9ndO/zMxrjakgVh57YTtYomEEb6ZDYRIgTHLaop1\r\nVqyYEkjiHySY4lrS3qoANUOm65Mwc+Zr5gVzmP3yZMsEC76sB4DfD9RBiR3H\r\nyBsz122AhHyfzo/DXpG1JLMIDl73m2EGBmvbMBDDMlT02vX3/J8rWCavQm0o\r\n6ZEl6bqzxxNWdVUUgDr6LZScpDC2d9xsscIg3QJYKX5g2BA7UMt6mvUFK5we\r\nff52KYUvkqmNJpu0l81DAynnQKVG5/vJVCpCE1SdJ2EzcZhGcPSR1GDKF8Y3\r\n0dtql68lyi/kDB7SJebmjRBVDTFtA932pQtO5pOThMc9le+wNebisaSmaKsK\r\n2hJsTxcoeCwUTBIIVyRwELRMmNMn/q9whvBZC5wpqxgVofRKoq8pCkZg9Idh\r\nkCHqkGBs88J/dRNpyVskF23b4xkMqVexf/C9UHdPIhuQC2lU07uiVWAViDCI\r\nFjDqFc/0YO/KE5Uchebd2HQjDI473ZsDPnZ02dMQuF0Ydm6wFYRaQMniLgP2\r\nCTiWl0rZALqpE38rpXg9oaqKDwRa/cIT4aY=\r\n=dIjj\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"aftabmk","email":"aftabmk.work@gmail.com"},"directories":{},"maintainers":[{"name":"aftabmk","email":"aftabmk.work@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cookie_1.0.1_1666112812404_0.9100537378681888"},"_hasShrinkwrap":false},"1.0.2":{"name":"@aftabmk/cookie","version":"1.0.2","description":"This package is used to create dynamic cookie value and authenticate the created cookie to prevent external tampering.This is simple and plain way to create advanced binaary based cookie with no effort.It primarly targeted for beginner coders","main":"index.js","scripts":{"test":"node run index.js"},"keywords":["cookie","cookie-parser","set-cookie","cookies","set-cookies","easy-cookie","cookie-beginner"],"author":{"name":"Aftab Mohamed Kizhissery"},"license":"MIT","gitHead":"4d30ca28478d274f20f29ce914b8d1fd004b457f","_id":"@aftabmk/cookie@1.0.2","_nodeVersion":"18.6.0","_npmVersion":"8.13.2","dist":{"integrity":"sha512-EwrJfK8+F9LvDRpJDFI1ctIGlb9b/n5AKzHezssZg2tkeUfS5coHK7P7C9ljC/lPlPvbXlljN18Lr6sB+ZxA2w==","shasum":"09469722e8d6ba770145ba46d01c516155501e00","tarball":"https://registry.npmjs.org/@aftabmk/cookie/-/cookie-1.0.2.tgz","fileCount":7,"unpackedSize":194792,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDXP1p17s/O4UGwliS48crSkAE5kBA8O/pEmnEeGTwZ6QIhAIuJVVqqy4b9HyXud//210IQGYc7tVy5g2bFrmGv5EVJ"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjTt83ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrfDw/+PQjLqkoe6PyR1OxPofo6JAMcmzoaS0+cQNZ7M/HDOxECMAiK\r\nYLKI4I9zepKw81sG60tXc3ktj5NDlRAbXJCaskNHUfIBIEoGtWGys2WtHqvV\r\neL0MLO0UViBZrKBmUt/yyfqof9t0yh2Aso9bAX+276AfkEy3cwmdWYNmPg5w\r\nl47MYGenX0DGf1QMN1nmz+He6/0yHFCwg4P7gyu5qUvegnvB/5x8KqcxoEEM\r\nq/XpSal35hgF/01FieDX0aP6219zNr85ZRJCSp/veIEWXoG2ObEorHU5HXnS\r\ntzyk+YYkQ+NqY2piZliYuyvBUarfbAA8ZYa3S4k5bUKETUyfk4Yu7dwJ1Hb9\r\nkPqjpS8ICc4sqkKQkCvUxkQgcl8ju1vvPeiOuREZSeKzr1kgdcjn09bvqHZu\r\naH8RBP1+Nm5TNJ/iJLkMIswO/EQxDs0q1pdmEBM1UqgQX8C6aQcnDlvRVZVZ\r\nHJjQpcZaK47zXcBAlans74JkI2c0IIfhEF55jXMmxc5z2PnWFoLwQv1Y6Q87\r\nHlbV4WO8peW6NTY6AkaPXh2RhpSOKJgIH5XCM+COYkvEGUFkIbPLRSSHVsYk\r\ngCeJIxbI5lJH6if8lEEYs7X+hYldK4zaSGjjHutfQG752TuVImWl4VngE/zr\r\n/32AafPAeVDG6l3fzePL6Uhy+PPA74vOFi0=\r\n=G30z\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"aftabmk","email":"aftabmk.work@gmail.com"},"directories":{},"maintainers":[{"name":"aftabmk","email":"aftabmk.work@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cookie_1.0.2_1666113335742_0.7795931046691056"},"_hasShrinkwrap":false}},"time":{"created":"2022-10-18T15:35:39.745Z","1.0.0":"2022-10-18T15:35:39.975Z","modified":"2022-10-18T17:15:36.022Z","1.0.1":"2022-10-18T17:06:52.674Z","1.0.2":"2022-10-18T17:15:35.946Z"},"maintainers":[{"name":"aftabmk","email":"aftabmk.work@gmail.com"}],"description":"This package is used to create dynamic cookie value and authenticate the created cookie to prevent external tampering.This is simple and plain way to create advanced binaary based cookie with no effort.It primarly targeted for beginner coders","keywords":["cookie","cookie-parser","set-cookie","cookies","set-cookies","easy-cookie","cookie-beginner"],"author":{"name":"Aftab Mohamed Kizhissery"},"license":"MIT","readme":"<h1 align=\"center\">\r\n    Cookie generator\r\n   <b>\r\n        <a href=\"https://aftab.netlify.app\"><img src=\"https://raw.githubusercontent.com/aftabmk/Cookie/master/image/cookie.jpg\" /></a><br>\r\n    </b>\r\n</h1>\r\n<p align=\"center\">This package is used to create dynamic cookie value and authenticate the created cookie to prevent external tampering.This is simple and plain way to create advanced binaary based cookie with no effort.It primarly targeted for beginner coders.</p>\r\n\r\n## Installing\r\n\r\nUsing npm:\r\n\r\n```bash\r\n$ npm i @aftabmk/cookie\r\n```\r\n\r\nUsing bower:\r\n\r\n```bash\r\n$ bower install @aftabmk/cookie\r\n```\r\n\r\nUsing yarn:\r\n\r\n```bash\r\n$ yarn add @aftabmk/cookie\r\n```\r\n\r\nUsing pnpm:\r\n\r\n```bash\r\n$ pnpm add @aftabmk/cookie\r\n```\r\n\r\n## Documentation\r\n\r\n## Functions\r\n*setCookie*\r\n```ts\r\nconst cookie : setCookie(String,String,Number,Number)\r\n```\r\n*filterCookie*\r\n```ts\r\nconst bool : filterCookie(String,Number,String)\r\n```\r\n\r\n# Example\r\n# setCookie inputs\r\n*Name*\r\n```js\r\nconst cookie = setCookie('kizhissery','-',7,5)\r\n/*{\r\n    cookie:'kizhissery-101010000.........\r\n    here input is Kizhissery\r\n}*/\r\n```\r\n*Symbol*\r\n```js\r\nconst cookie = setCookie('kizhissery','=',7,20)\r\n/*{\r\n    cookie:'kizhissery-101010000.........\r\n    here input is Kizhissery\r\n}*/\r\n```\r\n*Key*\r\n```js\r\nconst cookie = setCookie('aftab','-',7,20)\r\n/*{\r\n    cookie:'kizhissery-101010000.........\r\n    here secret key is 7, it can be any +ve integer Only, decimal and -ve integer will not function\r\n}*/\r\n```\r\n*Repeat*\r\n```js\r\nconst cookie = setCookie('aftab','-',7,5)\r\n/*{\r\n    cookie:'kizhissery-101010000.........\r\n    here length of cookie detemined length here it is 5\r\n    cookie:'kizhissery-101010000.........*4\r\n    here length of cookie detemined length here it is 20, if you need bigger cookie value , should be more than 5 and less than 20 for optimal result\r\n}*/\r\n```\r\n*result*\r\n```js\r\nconst cookie = setCookie(name,symbol,key,length)\r\n/*{\r\n    cookie:'kizhissery-101010000.........\r\n    here length of cookie detemined length here it is 5\r\n    cookie:'kizhissery-101010000.........*4\r\n    here length of cookie detemined length here it is 20, if you need bigger cookie value , should be more than 5 and less than 20 for optimal result\r\n}*/\r\n```\r\n# filterCookie inputs\r\n\r\n*result*\r\n```js\r\nconst filter = filterCookie(name,key,cookie)\r\n/*{\r\n    cookie is the the derived value of the above function \"setCookie\" which is passed to filter function.\r\n    Note the name and key of setCookie must match the inputs of filterCookie.\r\n}*/\r\n```\r\n\r\n# Starter Code\r\n*example 1*\r\n```js\r\nconst { setCookie , filterCookie } = require('@aftabmk/cookie')\r\n\r\nconst cookie = setCookie('aftab','=',30,5)\r\nconst filter = filterCookie('aftab',30,cookie)\r\n\r\nconsole.log({cookie},{filter})\r\n```\r\n*example 2*\r\n```js\r\n// imports\r\nconst express = require(\"express\");\r\nconst cookieParser = require('cookie-parser')\r\nconst { setCookie , filterCookie } = require('@aftabmk/cookie');\r\n//setting up express\r\napp.use(ex.json())\r\napp.use(ex.urlencoded({ extended: true }))\r\n//auth\r\nfunction Auth(req, res, next)\r\n{\r\n    if(!req.headers.cookie) return res.status(403).send('403 access forbidden')\r\n    if(filterCookie('user',77,req.headers.cookie))\r\n    // name was set to user and key to 77 at setCookie function\r\n    // filterCookie return true\r\n    // so it will lead to next() , if authentication fails it will send 403 to unauthorised api/json scrapper\r\n    // for true return /api route and access the data from those route\r\n        {\r\n            next();return\r\n        }\r\n        else\r\n        {\r\n            res.status(401).send([{'status':401,'description':'Invalid certificate'}]);\r\n        }\r\n}\r\n// the user in front end redirect to setCookie end point to initialise setCookie function to set cookie inside cookie-parser option\r\napp.get(`/setCookie`, async (req, res) => \r\n{ try \r\n    { \r\n        return res.status(202)\r\n        .cookieParser( setCookie('user','=',77,20) , cookieOptions)\r\n        // here name is user , symbol is '=' , secret key = 77 and length = 20\r\n        // cookieOption { sameSite: 'strict', path: '/', expires: new Date(Date.now() + 900000), httpOnly: true }\r\n        // IMPORTANT htmlonly to true\r\n        .send('User cookie is  set') \r\n    } \r\n    catch (err) \r\n    { \r\n        return res.status(500).json({ err: err.toString() }) \r\n    } })\r\n\r\n// Express router import whereapi are stored hence we introduce Auth middleware , to prevent unwanted scrapers\r\napp.use('/api',Auth,api)\r\n\r\n\r\napp.listen(port, () => { console.log(`running on port http://localhost:5000`) })\r\n```","readmeFilename":"README.md"}