{"_id":"@21jumpclick/cookie-parser","_rev":"1-4d4a6bc31db9c4bfa0efe60092d9bb8d","name":"@21jumpclick/cookie-parser","dist-tags":{"latest":"2.4.1"},"versions":{"2.4.0":{"name":"@21jumpclick/cookie-parser","version":"2.4.0","keywords":["laravel","crypto","nodejs","cookie","cookie-parser"],"author":{"name":"Adolfo Segura Hall"},"license":"MIT","_id":"@21jumpclick/cookie-parser@2.4.0","maintainers":[{"name":"agent-smits","email":"victor-smi@hotmail.fr"}],"dist":{"shasum":"a7e792cfb7a7a0f1405dca44d8d4f1cc28c911eb","tarball":"https://registry.npmjs.org/@21jumpclick/cookie-parser/-/cookie-parser-2.4.0.tgz","fileCount":28,"integrity":"sha512-VBw7iTDPrKnAm6+HQOwFLqj8d4JrtJ8tiShDXxoFf6fUvTuKIN9bUJTYHeYKIUwSVxT1wlsrPTNEIJZb2T3Kaw==","signatures":[{"sig":"MEYCIQCFHvSg+IRim/Vh/LU+CWcFgFf6ybybRpxTuos9UHALCgIhAPupTSv5KFmKxwp+UdlVFdmPVFi+7VhixQEUszH7D7Bt","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":109007},"main":"dist/index.js","types":"./dist/index.d.ts","engines":{"npm":">=6.4.1","node":">=8.16.1","express":">=4.1.1"},"gitHead":"f996c727043529e6888a189979781dd83eede15a","scripts":{"dev":"tsc -w","build":"tsup src/index.ts --format cjs,esm --dts","clean":"rimraf lib","prepack":"npm run clean && npm run build","prebuild":"tsc"},"_npmUser":{"name":"agent-smits","email":"victor-smi@hotmail.fr"},"_npmVersion":"10.8.2","description":"Express Response Cookie override to add crypto cookie and cookie-parser module replacement","directories":{},"_nodeVersion":"20.18.0","dependencies":{"socket.io":"^4.7.5","php-serialize":"^4.1.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^5.1.0","tsup":"^8.0.2","uuid":"^9.0.1","debug":"^4.3.4","mocha":"^10.4.0","cookie":"^0.6.0","rimraf":"^5.0.5","express":"^4.19.2","chai-http":"^4.4.0","typescript":"^5.4.4","@types/node":"^20.12.5","@types/uuid":"^9.0.8","body-parser":"^1.20.2","@types/mocha":"^10.0.6","concurrently":"^8.2.2"},"_npmOperationalInternal":{"tmp":"tmp/cookie-parser_2.4.0_1735981737722_0.6847266612051797","host":"s3://npm-registry-packages-npm-production"}},"2.4.1":{"name":"@21jumpclick/cookie-parser","publishConfig":{"access":"public"},"version":"2.4.1","engines":{"node":">=8.16.1","npm":">=6.4.1","express":">=4.1.1"},"description":"Express Response Cookie override to add crypto cookie and cookie-parser module replacement","main":"dist/index.js","scripts":{"clean":"rimraf lib","build":"tsup src/index.ts --format cjs,esm --dts","prebuild":"tsc","prepack":"npm run clean && npm run build","dev":"tsc -w"},"author":{"name":"Adolfo Segura Hall"},"license":"MIT","devDependencies":{"@types/mocha":"^10.0.6","@types/node":"^20.12.5","@types/uuid":"^9.0.8","body-parser":"^1.20.2","chai":"^5.1.0","chai-http":"^4.4.0","concurrently":"^8.2.2","cookie":"^0.6.0","debug":"^4.3.4","express":"^4.19.2","mocha":"^10.4.0","rimraf":"^5.0.5","tsup":"^8.0.2","typescript":"^5.4.4","uuid":"^9.0.1"},"dependencies":{"php-serialize":"^4.1.1","socket.io":"^4.7.5"},"keywords":["laravel","crypto","nodejs","cookie","cookie-parser"],"_id":"@21jumpclick/cookie-parser@2.4.1","gitHead":"bd048e066c70517f344ba7c8a68b7807f2db0591","types":"./dist/index.d.ts","_nodeVersion":"20.18.0","_npmVersion":"10.8.2","dist":{"integrity":"sha512-SM5EG7b6vYD2Lc7SWNv/cguS8vC54TV1pNcCIapr/h/37gscivec57geoMrbY1nO6O+vRkwL5mYdEYwmzs7B6A==","shasum":"058f278c1abb1457b610bd2a90e8232cc5a92f86","tarball":"https://registry.npmjs.org/@21jumpclick/cookie-parser/-/cookie-parser-2.4.1.tgz","fileCount":28,"unpackedSize":109010,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIEq2kdppNrfLzXHapntC0DSc2rO+414VuqjbxMd/5B5JAiBkZyLAyc8XjiJhEMG4OWzg9iAWo117tTmo9EIYtZhKBg=="}]},"_npmUser":{"name":"agent-smits","email":"victor-smi@hotmail.fr"},"directories":{},"maintainers":[{"name":"agent-smits","email":"victor-smi@hotmail.fr"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/cookie-parser_2.4.1_1738493848914_0.5844030358754084"},"_hasShrinkwrap":false}},"time":{"created":"2025-01-04T09:08:57.615Z","modified":"2025-02-02T10:57:29.368Z","2.4.0":"2025-01-04T09:08:57.928Z","2.4.1":"2025-02-02T10:57:29.162Z"},"author":{"name":"Adolfo Segura Hall"},"license":"MIT","keywords":["laravel","crypto","nodejs","cookie","cookie-parser"],"description":"Express Response Cookie override to add crypto cookie and cookie-parser module replacement","maintainers":[{"name":"agent-smits","email":"victor-smi@hotmail.fr"}],"readme":"[![Build Status](https://api.travis-ci.org/adsegura/crypto-parser-express.svg?branch=master)](https://travis-ci.org/adsegura/crypto-parser-express)\r\n[![npm version](https://badge.fury.io/js/crypto-parser-express.svg)](https://badge.fury.io/js/crypto-parser-express)\r\n[![node version](https://badgen.net/badge/node/%3E=8.10.0/green)](https://badgen.net/badge/node/%3E=8.10.0/green)\r\n\r\n# crypto-parser-express\r\n\r\nExpress `>=v4.10.0` Response Cookie override to add crypto cookie support\r\nand cookie-parser middleware module replacement.\r\n\r\ncrypto-parser-express use `node-laravel-encryptor` to cipher/decipher cookies\r\nwith signature verification support.\r\n\r\nThis module borrows parts of cookieParse and parse methods from [cookie-parser module](https://github.com/expressjs/cookie-parser#readme) \r\nkudos to that dev.\r\n\r\n# Features\r\n* cipher/decipher cookies with\r\n    * res.cookies\r\n    * res.cookies_async\r\n* Laravel Cookie Compatible `>=5.4` if serialize_mode `php` (default mode `node-laravel-encryptor`)\r\n* only parse allowed cookies.\r\n* only decipher encrypted cookie payload instead of every cookie params [path, domain, expires, secure, etc].\r\n* option to allow all cookies, only allowed cookies will be deciphered. \r\n  \r\n\r\n## Install\r\n```sh\r\n$> npm i crypto-parser-express\r\n```\r\n\r\n## Prerequisites\r\n* NodeJs `>=v8.10.0 (npm v5.6.0)`\r\n* expressJS `>=v4.10.0`\r\n\r\n# Usage\r\n```js\r\nconst express = require('express');\r\nconst CryptoCookieParser = require('crypto-parser-express');\r\nconst cryptoCookieParser = new CryptoCookieParser(options);\r\n\r\n//instead of const app = express();\r\nconst app = cryptoCookieParser.overrideCookie(express());\r\n\r\n//use custom cookieParser middleware\r\napp.use(cryptoCookieParser.cookieParser())\r\n```\r\n\r\n### Options\r\n```js\r\nconst options = {\r\n  encryptor: {key: 'app_key', serialize_mode: 'php|json'},\r\n  cookie: {\r\n      allow_all: false,\r\n      allowed: ['session', 'superCookie'],\r\n      options: {\r\n          domain: 'localhost',\r\n          expires: 0,\r\n          maxAge: 60*60*1000,\r\n          path: '/',\r\n          sameSite: true,\r\n          secure: false,\r\n          httpOnly: false\r\n      }\r\n  }\r\n}\r\n```\r\n\r\n## Options \r\n### Encryptor options\r\n[node-laravel-encryptor](https://github.com/adsegura/node-laravel-encryptor/blob/master/README.md)\r\n### Cookie options\r\n* allow_all: `<boolean>` [default] `false`\r\n* allowed:   `<array>` list allowed cookie name\r\n* options: `npm cookie package` options \r\n\r\n# Tests\r\n```bash\r\n> npm run test\r\n\r\n  Class CryptoCookie\r\n    ✓ should return express instance with res.cookie method overridden\r\n    ✓ should return express instance with res.cookie_async new method\r\n\r\n  Test Errors...\r\n    ✓ should throw Error 'overrideCookie express argument not an express instance' when trying to override Cookie method on non express instance\r\n    ✓ should Throw Error MAC signature failed (53ms)\r\n\r\n  Express cookie override\r\n    ✓ should client send cipher cookie and cookieParser should decipher it\r\n    ✓ should server res.cookie not populate response Headers Set-Cookie when cookie name is not allowed \r\n    ✓ should server res.cookie populate response Headers Set-Cookie when cookie name is not allowed and allow_all = true\r\n    ✓ should client send not allowed cookie and cookieParser should discard\r\n    ✓ should client send not allowed cookie when allow_all option true and should not decipher but should be parsed in req.cookies\r\n\r\n  Express response res.cookie method and res.cookie_async method\r\n    ✓ should client get cipher cookie using res.cookie_async\r\n    ✓ should client get cipher cookie using res.cookie method overridden\r\n\r\n  11 passing (112ms)\r\n```\r\n\r\n\r\n### Dependencies\r\n* [node-laravel-encryptor](https://github.com/adsegura/node-laravel-encryptor/blob/master/README.md)\r\n    * [php-serialize](https://github.com/steelbrain/php-serialize#readme)\r\n\r\n### Contributing\r\nPull requests are welcome.\r\n\r\n### License\r\n[MIT](https://choosealicense.com/licenses/mit/)\r\n","readmeFilename":"README.md"}