{"name":"@eggjs/session","version":"4.0.0","keywords":["egg","egg-plugin","eggPlugin","session","cookie"],"author":{"name":"dead_horse"},"_id":"@eggjs/session@4.0.0","maintainers":[{"name":"gxkl","email":"gxkl203@gmail.com"},{"name":"eggjs-admin","email":"fengmk2+eggjs@gmail.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"},{"name":"atian25","email":"atian25@qq.com"},{"name":"dead_horse","email":"dead_horse@qq.com"},{"name":"wanghx","email":"whxaxes@gmail.com"},{"name":"hyj1991","email":"yeekwanvong@gmail.com"},{"name":"killagu","email":"killa07071201@gmail.com"},{"name":"coolme200","email":"2001-wms@163.com"},{"name":"mansonchor.zzw","email":"mansonchor1987@gmail.com"},{"name":"hubcarl","email":"hubcarl@126.com"},{"name":"gemwuu","email":"gemwuu@gmail.com"},{"name":"akitasummer","email":"644171127@qq.com"}],"homepage":"https://github.com/eggjs/session#readme","bugs":{"url":"https://github.com/eggjs/session/issues"},"dist":{"shasum":"916aeb1fcd92f1e4bdcdd118f911c5f0d398bd25","tarball":"http://registry-npm.ywwl.com/@eggjs/session/download/@eggjs/session-4.0.0.tgz","fileCount":37,"integrity":"sha512-yBOw5XL7tDg2CVFVu3qfA2WY1Rzmdfp8rYqpveok9zzY7/wdtv2t09va4iULw2oV3zRZhqo264DXsGqzucftdw==","signatures":[{"sig":"MEUCIAf6xGOQ60saLkPrCXrLMevbKAsmn8rHyYePmFf4eXSKAiEA1vBtWE67ktEPwEde5bfB5fTqOH7lfSOjbJAzaUYL0AU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@eggjs%2fsession@4.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":48360,"size":9838,"noattachment":false,"key":"/@eggjs/session/-/@eggjs/session-4.0.0.tgz"},"main":"./dist/commonjs/index.js","tshy":{"exports":{".":"./src/index.ts","./package.json":"./package.json"}},"type":"module","types":"./dist/commonjs/index.d.ts","module":"./dist/esm/index.js","engines":{"node":">= 18.19.0"},"exports":{".":{"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.js"},"require":{"types":"./dist/commonjs/index.d.ts","default":"./dist/commonjs/index.js"}},"./package.json":"./package.json"},"gitHead":"1909d44d6ba9b8521b24ceda74a8b23ece85750d","scripts":{"ci":"egg-bin cov","lint":"eslint --cache src test --ext .ts","test":"egg-bin test","clean":"rimraf dist","preci":"npm run clean &&  npm run lint","postci":"npm run prepublishOnly && npm run clean","pretest":"npm run clean && npm run lint -- --fix","prepublishOnly":"tshy && tshy-after && attw --pack","test:snapshot:update":"SNAPSHOT_UPDATE=1 egg-bin test"},"_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"eggPlugin":{"name":"session","exports":{"import":"./dist/esm","require":"./dist/commonjs","typescript":"./src"}},"repository":{"url":"git+ssh://git@github.com/eggjs/session.git","type":"git"},"_npmVersion":"10.8.2","description":"session plugin for egg","directories":{},"_nodeVersion":"20.18.1","dependencies":{"zod":"^3.24.1","@eggjs/core":"^6.2.13","koa-session":"^7.0.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"egg":"^4.0.1","tshy":"3","eslint":"8","rimraf":"6","egg-redis":"^2.6.0","@eggjs/bin":"7","tshy-after":"1","typescript":"5","@eggjs/mock":"^6.0.5","@types/node":"22","@types/mocha":"10","snap-shot-it":"^7.9.10","@eggjs/tsconfig":"1","@eggjs/supertest":"^8.2.0","eslint-config-egg":"14","@arethetypeswrong/cli":"^0.17.1"},"_npmOperationalInternal":{"tmp":"tmp/session_4.0.0_1737280471113_0.03632932393815613","host":"s3://npm-registry-packages-npm-production"},"readme":"# @eggjs/session\n\n[![NPM version][npm-image]][npm-url]\n[![Known Vulnerabilities][snyk-image]][snyk-url]\n[![npm download][download-image]][download-url]\n[![Node.js Version](https://img.shields.io/node/v/@eggjs/session.svg?style=flat)](https://nodejs.org/en/download/)\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://makeapullrequest.com)\n![CodeRabbit Pull Request Reviews](https://img.shields.io/coderabbit/prs/github/eggjs/session)\n\n[npm-image]: https://img.shields.io/npm/v/@eggjs/session.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/@eggjs/session\n[snyk-image]: https://snyk.io/test/npm/@eggjs/session/badge.svg?style=flat-square\n[snyk-url]: https://snyk.io/test/npm/@eggjs/session\n[download-image]: https://img.shields.io/npm/dm/@eggjs/session.svg?style=flat-square\n[download-url]: https://npmjs.org/package/@eggjs/session\n\nSession plugin for egg, based on [koa-session](https://github.com/koajs/session).\n\n## Usage\n\n`session` is a built-in plugin in egg and enabled by default.\n\n```js\n// {app_root}/config/plugin.js\nexports.session = true; // enable by default\n```\n\n### External Store\n\negg-session support external store, you can store your sessions in redis, memcached or other databases.\n\nFor example, if you want to store session in redis, you must:\n\n1. Dependent [@eggjs/redis](https://github.com/eggjs/egg/tree/next/plugins/redis)\n\n```bash\nnpm i --save @eggjs/redis\n```\n\n2. Import `@eggjs/redis` as a plugin and set the configuration\n\n```js\n// config/plugin.js\nexports.redis = {\n  enable: true,\n  package: '@eggjs/redis',\n};\n```\n\n```js\n// config/config.default.js\nexports.redis = {\n  // your redis configurations\n};\n```\n\n3. Implement a session store with redis\n\n```js\n// app.js\n\nmodule.exports = (app) => {\n  // set redis session store\n  // session store must have 3 methods\n  // define sessionStore in `app.js` so you can access `app.redis`\n  app.sessionStore = {\n    async get(key) {\n      const res = await app.redis.get(key);\n      if (!res) return null;\n      return JSON.parse(res);\n    },\n\n    async set(key, value, maxAge) {\n      // maxAge not present means session cookies\n      // we can't exactly know the maxAge and just set an appropriate value like one day\n      if (!maxAge) maxAge = 24 * 60 * 60 * 1000;\n      value = JSON.stringify(value);\n      await app.redis.set(key, value, 'PX', maxAge);\n    },\n\n    async destroy(key) {\n      await app.redis.del(key);\n    },\n  };\n\n  // session store can be a session store class\n  // app.sessionStore = class Store {\n  //   constructor(app) {\n  //     this.app = app;\n  //   }\n  //   async get() {}\n  //   async set() {}\n  //   async destroy() {}\n  // };\n};\n```\n\nOnce you use external session store, session is strong dependent on your external store, you can't access session if your external store is down. **Use external session stores only if necessary, avoid use session as a cache, keep session lean and stored by cookie!**\n\n## Configuration\n\nSupport all configurations in [koa-session](https://github.com/koajs/session).\n\n- logValue\n\n```bash\nSupport not to print the session value when session event trigger log. Default to be true.\n```\n\n[View the default configurations](https://github.com/eggjs/egg/tree/next/plugins/session/src/config/config.default.ts)\n\n## Questions & Suggestions\n\nPlease open an issue [here](https://github.com/eggjs/egg/issues).\n\n## License\n\n[MIT](LICENSE)\n\n## Contributors\n\n[![Contributors](https://contrib.rocks/image?repo=eggjs/egg)](https://github.com/eggjs/egg/graphs/contributors)\n\nMade with [contributors-img](https://contrib.rocks).\n","publish_time":1737280471361,"_cnpm_publish_time":1737280471361,"dist-tags":{"beta":"5.0.2-beta.27","latest":"5.1.0","rc":"5.0.2-rc.1"}}