mm_session 1.5.8 → 1.5.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/session.js +8 -4
- package/package.json +4 -4
package/lib/session.js
CHANGED
|
@@ -3,7 +3,11 @@ const { Helper } = require('./helper.js');
|
|
|
3
3
|
|
|
4
4
|
if (!$.dict) {
|
|
5
5
|
// 增加字典
|
|
6
|
-
$.dict = {
|
|
6
|
+
$.dict = {
|
|
7
|
+
session_id: 'mm:uuid',
|
|
8
|
+
cookie_token: 'mm:uuid',
|
|
9
|
+
header_token: 'x-auth-token',
|
|
10
|
+
};
|
|
7
11
|
}
|
|
8
12
|
|
|
9
13
|
/**
|
|
@@ -23,9 +27,9 @@ class Session {
|
|
|
23
27
|
// HTTP请求头中用于传递session ID的字段名,默认'x-auth-token'
|
|
24
28
|
header_token: $.dict.header_token || 'x-auth-token',
|
|
25
29
|
// session ID过期时间,单位秒,默认7天
|
|
26
|
-
uuid_expire:
|
|
30
|
+
uuid_expire: 60 * 60 * 24 * 7,
|
|
27
31
|
// session过期时间,单位秒,默认2小时
|
|
28
|
-
max_age:
|
|
32
|
+
max_age: 60 * 60 * 2,
|
|
29
33
|
// 过期token处理选项:'reject'(拒绝访问)或'allow'(允许访问缓存)
|
|
30
34
|
expired_handling: 'reject',
|
|
31
35
|
};
|
|
@@ -156,7 +160,7 @@ Session.prototype._getClientIP = function (ctx) {
|
|
|
156
160
|
*/
|
|
157
161
|
Session.prototype._getHeaderInfo = function (ctx) {
|
|
158
162
|
let ip = this._getClientIP(ctx);
|
|
159
|
-
let user_agent = ctx.headers['user-agent'] || '
|
|
163
|
+
let user_agent = ctx.headers['user-agent'] || 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36';
|
|
160
164
|
return {
|
|
161
165
|
ip,
|
|
162
166
|
user_agent
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mm_session",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.9",
|
|
4
4
|
"description": "这是超级美眉session函数模块,用于web服务端session缓存",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
},
|
|
31
31
|
"homepage": "https://gitee.com/qiuwenwu91/mm_session#readme",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"mm_cache": "^1.4.
|
|
33
|
+
"mm_cache": "^1.4.9"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"eslint-plugin-jsdoc": "^
|
|
37
|
-
"mm_eslint": "^1.7.
|
|
36
|
+
"eslint-plugin-jsdoc": "^63.0.8",
|
|
37
|
+
"mm_eslint": "^1.7.5"
|
|
38
38
|
}
|
|
39
39
|
}
|