{"_id":"@yuzheng14/vue-session","_rev":"1-8bd0e8ba5a077fa85b0ea43f1954bac5","name":"@yuzheng14/vue-session","dist-tags":{"latest":"2.0.1"},"versions":{"2.0.0":{"name":"@yuzheng14/vue-session","version":"2.0.0","description":"A simplistic session plugin for VueJS backed by SessionStorage","main":"./dist/lib/index.cjs","module":"./dist/es/index.js","exports":{".":{"import":"./dist/es/index.js","require":"./dist/lib/index.cjs"}},"typings":"./dist/typings/index.d.ts","repository":{"type":"git","url":"git+https://github.com/yuzheng14/vue-session.git"},"keywords":["vue","vuejs","session","plugin","vue-plugin"],"author":{"name":"yuzheng14","email":"me@yuzheng14.com"},"license":"ISC","dependencies":{"vue":"^2.7.14"},"devDependencies":{"@rollup/plugin-node-resolve":"^15.0.1","@rollup/plugin-typescript":"^11.0.0","@types/jest":"^29.5.0","@types/node":"^18.15.3","jest":"^29.5.0","jest-environment-jsdom":"^29.5.0","prettier":"^2.8.4","rollup":"^3.20.0","ts-jest":"^29.0.5","tslib":"^2.5.0","typescript":"^5.0.2"},"type":"module","scripts":{"test":"jest","build":"pnpm jest && rm -rf dist && rollup -c && tsc -p tsconfig.type.json"},"bugs":{"url":"https://github.com/yuzheng14/vue-session/issues"},"homepage":"https://github.com/yuzheng14/vue-session#readme","_id":"@yuzheng14/vue-session@2.0.0","_integrity":"sha512-jJLgSDPl3dQnhMF2JAIsbhw8yyn5Yc73L8aG0pB+5HOVo4YjtFeiX0GXz+74Nkna6yfQ3c9p8iq1XbfVd/heCQ==","_resolved":"/private/var/folders/vf/txq1tzfx63ncxpw_stfqtvn40000gn/T/e61439ccfab26151d75724696cdbc4b2/yuzheng14-vue-session-2.0.0.tgz","_from":"file:yuzheng14-vue-session-2.0.0.tgz","_nodeVersion":"18.13.0","_npmVersion":"8.19.3","dist":{"integrity":"sha512-jJLgSDPl3dQnhMF2JAIsbhw8yyn5Yc73L8aG0pB+5HOVo4YjtFeiX0GXz+74Nkna6yfQ3c9p8iq1XbfVd/heCQ==","shasum":"27da1ae919a7cae05709680a89f63469f8e05ab0","tarball":"https://registry.npmjs.org/@yuzheng14/vue-session/-/vue-session-2.0.0.tgz","fileCount":7,"unpackedSize":33824,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDeNve5BOzpExyPdBBgHmj49AjtZ3cAfTnFarFTNs+glgIgdnlhksxaJfijdJLEg3/O279wkebtIDa/4ZktLFw9jfQ="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkGD6yACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmownA/+KngEBEqkxsRXkaXDpgcLWNM3ob4apRhiwOhb487LDqQn5QPZ\r\nPIAzWD3n/oPa7QZsYMOxvKc8/jcotW3ERfLVjqImWr+sPg3IiWKut1An05vn\r\n+hMT5S6mXznWS2ttgidQngIdxma9WHBYdqgXgnrupGITlzroTrRwMNstbd80\r\nGiYp6tKvYCxoZelmyRu71Ie8FXfKRlbG9cW1FbLpBVGvU1BBHbJV2gMWZ/RC\r\n5oqL2HN7XcxCzJ3k+oyedV7HdgwhpjPArcKIA0fB0dn8zBSgEwgxjxMKPnEf\r\njCcrEF40RlIGpKB8A4Veo1XI4RN57ZRM9l3JXT7Wkff9vlBV6QYfce5C3UXD\r\n6Vd12+zEp8abty+2boIi8YmNmIFnBr2dP3I7WYR/HzRzo+9nHwwDBl7cvOsn\r\n/tS7vgCB7HeHx8CNKG1MnUs3WM9ceHMuOMHdDom8mkgW1arLZZeys+cY8jZp\r\nWfA9U3sGTUo7hGTFpwMlIfqwSwfP87K0F3rivofN61fvxpaAh/N+RJUngx8Z\r\n6cycTxmTr9hrNvhAIZkbVvltmDtIHG6H3Rt016H9ABGsL1NeiEn5jJeQ/bBw\r\nshOBlRGH0PU1/7XVpd0CvgalNWD+G6Mo9KzeioqELExc+g7qKN1rYCM1xfN4\r\nY6cEBVppZnkGm8UHTXDf29hV4Xdbu4mCPqE=\r\n=Lgk0\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"yuzheng14","email":"422450117@qq.com"},"directories":{},"maintainers":[{"name":"yuzheng14","email":"422450117@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/vue-session_2.0.0_1679310513932_0.30246714938791097"},"_hasShrinkwrap":false},"2.0.1":{"name":"@yuzheng14/vue-session","version":"2.0.1","description":"A simplistic session plugin for VueJS backed by SessionStorage","main":"./dist/lib/index.cjs","module":"./dist/es/index.js","exports":{".":{"import":"./dist/es/index.js","require":"./dist/lib/index.cjs","types":"./dist/typings/index.d.ts"}},"typings":"./dist/typings/index.d.ts","repository":{"type":"git","url":"git+https://github.com/yuzheng14/vue-session.git"},"keywords":["vue","vuejs","session","plugin","vue-plugin"],"author":{"name":"yuzheng14","email":"me@yuzheng14.com"},"license":"ISC","dependencies":{"vue":"^2.7.14"},"devDependencies":{"@rollup/plugin-node-resolve":"^15.0.1","@rollup/plugin-typescript":"^11.0.0","@types/jest":"^29.5.0","@types/node":"^18.15.3","jest":"^29.5.0","jest-environment-jsdom":"^29.5.0","prettier":"^2.8.4","rollup":"^3.20.0","ts-jest":"^29.0.5","tslib":"^2.5.0","typescript":"^5.0.2"},"type":"module","scripts":{"test":"jest","build":"pnpm jest && rm -rf dist && rollup -c && tsc -p tsconfig.type.json"},"bugs":{"url":"https://github.com/yuzheng14/vue-session/issues"},"homepage":"https://github.com/yuzheng14/vue-session#readme","_id":"@yuzheng14/vue-session@2.0.1","_integrity":"sha512-TNsG6gj5L5g1DxLEr8uq+iZLdnPoZE217GLye7Q88/RvIK9T406hozTqg27colfX1SP52qEb/ki9Z7hKAiO0Vg==","_resolved":"/private/var/folders/vf/txq1tzfx63ncxpw_stfqtvn40000gn/T/69b4b60451069ff2ee677f827e6c38f7/yuzheng14-vue-session-2.0.1.tgz","_from":"file:yuzheng14-vue-session-2.0.1.tgz","_nodeVersion":"20.9.0","_npmVersion":"10.5.2","dist":{"integrity":"sha512-TNsG6gj5L5g1DxLEr8uq+iZLdnPoZE217GLye7Q88/RvIK9T406hozTqg27colfX1SP52qEb/ki9Z7hKAiO0Vg==","shasum":"2ff0955d2742b67d4fe1b7753578a8363853b549","tarball":"https://registry.npmjs.org/@yuzheng14/vue-session/-/vue-session-2.0.1.tgz","fileCount":7,"unpackedSize":33868,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCg5nsKkUr3eOUtc6KmLSTxcEf3Y2ijNzM0mZi9+unUgQIhAJdhsgjmJvbVhgqaVk5ypPsX/RDDPgtcNLW7JhX1mRE9"}]},"_npmUser":{"name":"yuzheng14","email":"422450117@qq.com"},"directories":{},"maintainers":[{"name":"yuzheng14","email":"422450117@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/vue-session_2.0.1_1715408387867_0.024289234835058737"},"_hasShrinkwrap":false}},"time":{"created":"2023-03-20T11:08:33.863Z","2.0.0":"2023-03-20T11:08:34.144Z","modified":"2024-05-11T06:19:48.206Z","2.0.1":"2024-05-11T06:19:48.038Z"},"maintainers":[{"name":"yuzheng14","email":"422450117@qq.com"}],"description":"A simplistic session plugin for VueJS backed by SessionStorage","homepage":"https://github.com/yuzheng14/vue-session#readme","keywords":["vue","vuejs","session","plugin","vue-plugin"],"repository":{"type":"git","url":"git+https://github.com/yuzheng14/vue-session.git"},"author":{"name":"yuzheng14","email":"me@yuzheng14.com"},"bugs":{"url":"https://github.com/yuzheng14/vue-session/issues"},"license":"ISC","readme":"To install the plugin, do the following:\n\n```javascript\nimport VueSession from 'vue-session'\nVue.use(VueSession)\n```\n\nNow you can use it in your components with the `$session` property.\n\n## Options\n\nVueSession can be started with some options that will change its behavior.\n\n- `persist` A Boolean value to determine whether the data stored in the session may persist between tabs and browser instances. Defaults to `false`.\n\nPass the options in the `use` method:\n\n```javascript\nvar options = {\n    persist: true\n}\n\nVue.use(VueSession, options)\n```\n\n## Reference\n\n- `this.$session.getAll()`, returns all data stored in the Session.\n- `this.$session.set(key,value)`, sets a single value to the Session.\n- `this.$session.get(key)`, returns the value attributed to the given key.\n- `this.$session.start()`, initializes a session with a 'session-id'. If you attempt to save a value without having started a new session, the plugin will automatically start a new session.\n- `this.$session.exists()`, checks whether a session has been initialized or not.\n- `this.$session.has(key)`, checks whether the key exists in the Session\n- `this.$session.remove(key)`, removes the given key from the Session\n- `this.$session.clear()`, clear all keys in the Session, except for 'session-id', keeping the Session alive\n- `this.$session.destroy()`, destroys the Session\n- `this.$session.id()`, returns the 'session-id'\n- `this.$session.renew(session_id)`, allows a user to renew a previous session by manually inputting the session_id\n\n### Flash\n\nFlash allows you to save data until you read them without having to start a regular Session.\n\n- `this.$session.flash.set(key, value)`, sets a flash value\n- `this.$session.flash.get(key)`, reads and removes a flash value\n- `this.$session.flash.remove(key)`, removes a flash value\n\n\n## Example\n\nYour login method could look like this:\n\n```javascript\nexport default {\n    name: 'login',\n    methods: {\n        login: function () {\n          this.$http.post('http://somehost/user/login', {\n            password: this.password,\n            email: this.email\n          }).then(function (response) {\n            if (response.status === 200 && 'token' in response.body) {\n              this.$session.start()\n              this.$session.set('jwt', response.body.token)\n              Vue.http.headers.common['Authorization'] = 'Bearer ' + response.body.token\n              this.$router.push('/panel/search')\n            }\n          }, function (err) {\n            console.log('err', err)\n          })\n        }\n    }\n}\n```\n\nIn your logged-in area, you can check whether or not a session is started and destroy it when the user wants to logout:\n\n```javascript\nexport default {\n  name: 'panel',\n  data () {\n    return { }\n  },\n  beforeCreate: function () {\n    if (!this.$session.exists()) {\n      this.$router.push('/')\n    }\n  },\n  methods: {\n    logout: function () {\n      this.$session.destroy()\n      this.$router.push('/')\n    }\n  }\n}\n```\n","readmeFilename":"README.md"}