@yumerijs/core 1.0.7 → 1.0.8
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/dist/session.d.ts +2 -3
- package/dist/session.js +2 -28
- package/dist/session.js.map +1 -1
- package/package.json +2 -2
package/dist/session.d.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
export declare class Session {
|
|
2
2
|
ip: string;
|
|
3
|
-
cookie:
|
|
3
|
+
cookie: Record<string, string>;
|
|
4
4
|
query: Record<string, string> | undefined;
|
|
5
5
|
sessionid: string;
|
|
6
6
|
data: Record<string, any>;
|
|
7
|
-
constructor(ip: string, cookie:
|
|
7
|
+
constructor(ip: string, cookie: Record<string, string>, query?: Record<string, string>);
|
|
8
8
|
private generateId;
|
|
9
9
|
private md5;
|
|
10
10
|
setData(key: string, value: any): void;
|
|
11
11
|
deleteData(key: string): void;
|
|
12
12
|
clearData(): void;
|
|
13
13
|
destroy(): void;
|
|
14
|
-
private getCommand;
|
|
15
14
|
}
|
package/dist/session.js
CHANGED
|
@@ -16,16 +16,8 @@ class Session {
|
|
|
16
16
|
this.ip = ip;
|
|
17
17
|
this.cookie = cookie;
|
|
18
18
|
this.query = query;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
jsoncookie = JSON.parse(this.cookie);
|
|
22
|
-
}
|
|
23
|
-
catch (error) {
|
|
24
|
-
console.error("Error parsing cookie:", error);
|
|
25
|
-
jsoncookie = {};
|
|
26
|
-
}
|
|
27
|
-
if (jsoncookie.sessionid) {
|
|
28
|
-
this.sessionid = jsoncookie.sessionid;
|
|
19
|
+
if (cookie.sessionid) {
|
|
20
|
+
this.sessionid = cookie.sessionid;
|
|
29
21
|
}
|
|
30
22
|
else {
|
|
31
23
|
this.sessionid = this.generateId(this.ip);
|
|
@@ -60,24 +52,6 @@ class Session {
|
|
|
60
52
|
destroy() {
|
|
61
53
|
this.clearData(); // 清理会话数据
|
|
62
54
|
}
|
|
63
|
-
// 从请求路径提取指令和剩余的查询字符串
|
|
64
|
-
getCommand() {
|
|
65
|
-
try {
|
|
66
|
-
const jsoncookie = JSON.parse(this.cookie);
|
|
67
|
-
if (jsoncookie.requestPath) {
|
|
68
|
-
const path = jsoncookie.requestPath;
|
|
69
|
-
const pathParts = path.split('?'); // 分割路径和查询字符串
|
|
70
|
-
const command = pathParts[0].substring(1); // 移除开头的 '/' (如果存在)
|
|
71
|
-
const queryString = pathParts.length > 1 ? pathParts[1] : null; // 获取查询字符串,若没有则为 null
|
|
72
|
-
return { command: command || null, queryString };
|
|
73
|
-
}
|
|
74
|
-
return { command: null, queryString: null };
|
|
75
|
-
}
|
|
76
|
-
catch (e) {
|
|
77
|
-
console.error('Could not extract path from cookie', e);
|
|
78
|
-
return { command: null, queryString: null };
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
55
|
}
|
|
82
56
|
exports.Session = Session;
|
|
83
57
|
//# sourceMappingURL=session.js.map
|
package/dist/session.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAE5B,MAAa,OAAO;IAQhB;;;;OAIG;IACH,YAAY,EAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAE5B,MAAa,OAAO;IAQhB;;;;OAIG;IACH,YAAY,EAAU,EAAE,MAA8B,EAAE,KAA8B;QAR/E,SAAI,GAAwB,EAAE,CAAC;QASlC,IAAI,CAAC,EAAE,GAAI,EAAE,CAAC;QACd,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QAEnB,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;YACnB,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;QACtC,CAAC;aACI,CAAC;YACF,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAC1C,wCAAwC;YACxC,8CAA8C;QAClD,CAAC;IACL,CAAC;IAED,eAAe;IACP,UAAU,CAAC,EAAU,EAAE,MAAe;QAC1C,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,QAAQ;QAC3F,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,SAAS;IACD,GAAG,CAAC,GAAW;QACnB,MAAM,IAAI,GAAG,gBAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QACtC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACjB,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;IAED,SAAS;IACF,OAAO,CAAC,GAAW,EAAE,KAAU;QAClC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAC3B,CAAC;IAED,SAAS;IACF,UAAU,CAAC,GAAW;QACzB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;IAED,SAAS;IACF,SAAS;QACb,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;IAClB,CAAC;IAED,WAAW;IACJ,OAAO;QACV,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,SAAS;IAC/B,CAAC;CACJ;AA5DD,0BA4DC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yumerijs/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "Core module for yumeri",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
],
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "tsc",
|
|
12
|
-
"prepublishOnly": "
|
|
12
|
+
"prepublishOnly": "yarn build"
|
|
13
13
|
},
|
|
14
14
|
"repository": {
|
|
15
15
|
"type": "git",
|