@shware/security 2.5.3 → 3.0.0
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/auth/index.cjs +519 -561
- package/dist/auth/index.cjs.map +1 -1
- package/dist/auth/index.d.cts +104 -106
- package/dist/auth/index.d.cts.map +1 -0
- package/dist/auth/index.d.mts +109 -0
- package/dist/auth/index.d.mts.map +1 -0
- package/dist/auth/index.mjs +512 -536
- package/dist/auth/index.mjs.map +1 -1
- package/dist/auth/types.cjs +0 -19
- package/dist/auth/types.d.cts +44 -44
- package/dist/auth/types.d.cts.map +1 -0
- package/dist/auth/types.d.mts +50 -0
- package/dist/auth/types.d.mts.map +1 -0
- package/dist/auth/types.mjs +1 -1
- package/dist/core/index.cjs +18 -59
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +13 -24
- package/dist/core/index.d.cts.map +1 -0
- package/dist/core/index.d.mts +21 -0
- package/dist/core/index.d.mts.map +1 -0
- package/dist/core/index.mjs +17 -33
- package/dist/core/index.mjs.map +1 -1
- package/dist/email/schema.cjs +13 -38
- package/dist/email/schema.cjs.map +1 -1
- package/dist/email/schema.d.cts +11 -12
- package/dist/email/schema.d.cts.map +1 -0
- package/dist/email/schema.d.mts +12 -0
- package/dist/email/schema.d.mts.map +1 -0
- package/dist/email/schema.mjs +10 -11
- package/dist/email/schema.mjs.map +1 -1
- package/dist/index.cjs +18 -54
- package/dist/index.d.cts +10 -15
- package/dist/index.d.mts +10 -0
- package/dist/index.mjs +5 -17
- package/dist/oauth2/client.cjs +109 -145
- package/dist/oauth2/client.cjs.map +1 -1
- package/dist/oauth2/client.d.cts +55 -56
- package/dist/oauth2/client.d.cts.map +1 -0
- package/dist/oauth2/client.d.mts +58 -0
- package/dist/oauth2/client.d.mts.map +1 -0
- package/dist/oauth2/client.mjs +104 -116
- package/dist/oauth2/client.mjs.map +1 -1
- package/dist/oauth2/error.cjs +19 -44
- package/dist/oauth2/error.cjs.map +1 -1
- package/dist/oauth2/error.d.cts +8 -6
- package/dist/oauth2/error.d.cts.map +1 -0
- package/dist/oauth2/{error.d.ts → error.d.mts} +8 -6
- package/dist/oauth2/error.d.mts.map +1 -0
- package/dist/oauth2/error.mjs +18 -19
- package/dist/oauth2/error.mjs.map +1 -1
- package/dist/oauth2/provider/apple.cjs +75 -88
- package/dist/oauth2/provider/apple.cjs.map +1 -1
- package/dist/oauth2/provider/apple.d.cts +31 -30
- package/dist/oauth2/provider/apple.d.cts.map +1 -0
- package/dist/oauth2/provider/apple.d.mts +42 -0
- package/dist/oauth2/provider/apple.d.mts.map +1 -0
- package/dist/oauth2/provider/apple.mjs +71 -60
- package/dist/oauth2/provider/apple.mjs.map +1 -1
- package/dist/oauth2/provider/common.cjs +86 -109
- package/dist/oauth2/provider/common.cjs.map +1 -1
- package/dist/oauth2/provider/common.d.cts +19 -18
- package/dist/oauth2/provider/common.d.cts.map +1 -0
- package/dist/oauth2/provider/common.d.mts +30 -0
- package/dist/oauth2/provider/common.d.mts.map +1 -0
- package/dist/oauth2/provider/common.mjs +80 -79
- package/dist/oauth2/provider/common.mjs.map +1 -1
- package/dist/oauth2/provider/facebook.cjs +93 -109
- package/dist/oauth2/provider/facebook.cjs.map +1 -1
- package/dist/oauth2/provider/facebook.d.cts +29 -28
- package/dist/oauth2/provider/facebook.d.cts.map +1 -0
- package/dist/oauth2/provider/facebook.d.mts +45 -0
- package/dist/oauth2/provider/facebook.d.mts.map +1 -0
- package/dist/oauth2/provider/facebook.mjs +89 -81
- package/dist/oauth2/provider/facebook.mjs.map +1 -1
- package/dist/oauth2/provider/github.cjs +64 -91
- package/dist/oauth2/provider/github.cjs.map +1 -1
- package/dist/oauth2/provider/github.d.cts +52 -51
- package/dist/oauth2/provider/github.d.cts.map +1 -0
- package/dist/oauth2/provider/github.d.mts +60 -0
- package/dist/oauth2/provider/github.d.mts.map +1 -0
- package/dist/oauth2/provider/github.mjs +60 -63
- package/dist/oauth2/provider/github.mjs.map +1 -1
- package/dist/oauth2/provider/google.cjs +105 -122
- package/dist/oauth2/provider/google.cjs.map +1 -1
- package/dist/oauth2/provider/google.d.cts +34 -33
- package/dist/oauth2/provider/google.d.cts.map +1 -0
- package/dist/oauth2/provider/google.d.mts +44 -0
- package/dist/oauth2/provider/google.d.mts.map +1 -0
- package/dist/oauth2/provider/google.mjs +101 -94
- package/dist/oauth2/provider/google.mjs.map +1 -1
- package/dist/oauth2/provider/index.cjs +13 -46
- package/dist/oauth2/provider/index.d.cts +7 -7
- package/dist/oauth2/provider/index.d.mts +7 -0
- package/dist/oauth2/provider/index.mjs +1 -10
- package/dist/oauth2/provider/wechat.cjs +77 -99
- package/dist/oauth2/provider/wechat.cjs.map +1 -1
- package/dist/oauth2/provider/wechat.d.cts +28 -27
- package/dist/oauth2/provider/wechat.d.cts.map +1 -0
- package/dist/oauth2/provider/wechat.d.mts +39 -0
- package/dist/oauth2/provider/wechat.d.mts.map +1 -0
- package/dist/oauth2/provider/wechat.mjs +74 -72
- package/dist/oauth2/provider/wechat.mjs.map +1 -1
- package/dist/oauth2/provider/x.cjs +102 -125
- package/dist/oauth2/provider/x.cjs.map +1 -1
- package/dist/oauth2/provider/x.d.cts +51 -50
- package/dist/oauth2/provider/x.d.cts.map +1 -0
- package/dist/oauth2/provider/x.d.mts +69 -0
- package/dist/oauth2/provider/x.d.mts.map +1 -0
- package/dist/oauth2/provider/x.mjs +99 -103
- package/dist/oauth2/provider/x.mjs.map +1 -1
- package/dist/oauth2/types.cjs +12 -37
- package/dist/oauth2/types.cjs.map +1 -1
- package/dist/oauth2/types.d.cts +176 -180
- package/dist/oauth2/types.d.cts.map +1 -0
- package/dist/oauth2/types.d.mts +207 -0
- package/dist/oauth2/types.d.mts.map +1 -0
- package/dist/oauth2/types.mjs +12 -13
- package/dist/oauth2/types.mjs.map +1 -1
- package/dist/session/common.cjs +17 -43
- package/dist/session/common.cjs.map +1 -1
- package/dist/session/common.d.cts +4 -4
- package/dist/session/common.d.cts.map +1 -0
- package/dist/session/{common.d.ts → common.d.mts} +4 -4
- package/dist/session/common.d.mts.map +1 -0
- package/dist/session/common.mjs +14 -16
- package/dist/session/common.mjs.map +1 -1
- package/dist/session/db.cjs +88 -123
- package/dist/session/db.cjs.map +1 -1
- package/dist/session/db.d.cts +36 -36
- package/dist/session/db.d.cts.map +1 -0
- package/dist/session/db.d.mts +44 -0
- package/dist/session/db.d.mts.map +1 -0
- package/dist/session/db.mjs +84 -95
- package/dist/session/db.mjs.map +1 -1
- package/dist/session/map-session.cjs +71 -103
- package/dist/session/map-session.cjs.map +1 -1
- package/dist/session/map-session.d.cts +24 -24
- package/dist/session/map-session.d.cts.map +1 -0
- package/dist/session/map-session.d.mts +27 -0
- package/dist/session/map-session.d.mts.map +1 -0
- package/dist/session/map-session.mjs +70 -78
- package/dist/session/map-session.mjs.map +1 -1
- package/dist/session/redis.cjs +270 -319
- package/dist/session/redis.cjs.map +1 -1
- package/dist/session/redis.d.cts +51 -51
- package/dist/session/redis.d.cts.map +1 -0
- package/dist/session/redis.d.mts +58 -0
- package/dist/session/redis.d.mts.map +1 -0
- package/dist/session/redis.mjs +266 -291
- package/dist/session/redis.mjs.map +1 -1
- package/dist/session/types.cjs +0 -19
- package/dist/session/types.d.cts +34 -33
- package/dist/session/types.d.cts.map +1 -0
- package/dist/session/types.d.mts +45 -0
- package/dist/session/types.d.mts.map +1 -0
- package/dist/session/types.mjs +1 -1
- package/dist/utils/http.cjs +31 -55
- package/dist/utils/http.cjs.map +1 -1
- package/dist/utils/http.d.cts +7 -10
- package/dist/utils/http.d.cts.map +1 -0
- package/dist/utils/{http.d.ts → http.d.mts} +7 -10
- package/dist/utils/http.d.mts.map +1 -0
- package/dist/utils/http.mjs +24 -24
- package/dist/utils/http.mjs.map +1 -1
- package/dist/utils/oauth2.cjs +6 -30
- package/dist/utils/oauth2.cjs.map +1 -1
- package/dist/utils/oauth2.d.cts +3 -1
- package/dist/utils/oauth2.d.cts.map +1 -0
- package/dist/utils/oauth2.d.mts +5 -0
- package/dist/utils/oauth2.d.mts.map +1 -0
- package/dist/utils/oauth2.mjs +5 -5
- package/dist/utils/oauth2.mjs.map +1 -1
- package/dist/utils/timing.cjs +49 -70
- package/dist/utils/timing.cjs.map +1 -1
- package/dist/utils/timing.d.cts +10 -8
- package/dist/utils/timing.d.cts.map +1 -0
- package/dist/utils/timing.d.mts +15 -0
- package/dist/utils/timing.d.mts.map +1 -0
- package/dist/utils/timing.mjs +48 -45
- package/dist/utils/timing.mjs.map +1 -1
- package/dist/utils/valid.cjs +50 -71
- package/dist/utils/valid.cjs.map +1 -1
- package/dist/utils/valid.d.cts +17 -16
- package/dist/utils/valid.d.cts.map +1 -0
- package/dist/utils/valid.d.mts +28 -0
- package/dist/utils/valid.d.mts.map +1 -0
- package/dist/utils/valid.mjs +47 -44
- package/dist/utils/valid.mjs.map +1 -1
- package/package.json +22 -12
- package/dist/auth/index.d.ts +0 -111
- package/dist/auth/types.cjs.map +0 -1
- package/dist/auth/types.d.ts +0 -50
- package/dist/auth/types.mjs.map +0 -1
- package/dist/core/index.d.ts +0 -32
- package/dist/email/schema.d.ts +0 -13
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts +0 -15
- package/dist/index.mjs.map +0 -1
- package/dist/oauth2/client.d.ts +0 -59
- package/dist/oauth2/provider/apple.d.ts +0 -41
- package/dist/oauth2/provider/common.d.ts +0 -29
- package/dist/oauth2/provider/facebook.d.ts +0 -44
- package/dist/oauth2/provider/github.d.ts +0 -59
- package/dist/oauth2/provider/google.d.ts +0 -43
- package/dist/oauth2/provider/index.cjs.map +0 -1
- package/dist/oauth2/provider/index.d.ts +0 -7
- package/dist/oauth2/provider/index.mjs.map +0 -1
- package/dist/oauth2/provider/wechat.d.ts +0 -38
- package/dist/oauth2/provider/x.d.ts +0 -68
- package/dist/oauth2/types.d.ts +0 -211
- package/dist/session/__tests__/redis.test.cjs +0 -247
- package/dist/session/__tests__/redis.test.cjs.map +0 -1
- package/dist/session/__tests__/redis.test.d.cts +0 -2
- package/dist/session/__tests__/redis.test.d.ts +0 -2
- package/dist/session/__tests__/redis.test.mjs +0 -252
- package/dist/session/__tests__/redis.test.mjs.map +0 -1
- package/dist/session/db.d.ts +0 -44
- package/dist/session/map-session.d.ts +0 -27
- package/dist/session/redis.d.ts +0 -58
- package/dist/session/types.cjs.map +0 -1
- package/dist/session/types.d.ts +0 -44
- package/dist/session/types.mjs.map +0 -1
- package/dist/utils/oauth2.d.ts +0 -3
- package/dist/utils/timing.d.ts +0 -13
- package/dist/utils/valid.d.ts +0 -27
package/dist/session/db.mjs
CHANGED
|
@@ -1,102 +1,91 @@
|
|
|
1
|
-
// src/session/db.ts
|
|
2
|
-
import { randomUUID } from "crypto";
|
|
3
1
|
import { PRINCIPAL_NAME_INDEX_NAME, resolveIndexesFor } from "./common.mjs";
|
|
4
2
|
import { MapSession } from "./map-session.mjs";
|
|
3
|
+
import { randomUUID } from "node:crypto";
|
|
4
|
+
//#region src/session/db.ts
|
|
5
5
|
var DBSession = class extends MapSession {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
isNew;
|
|
7
|
+
primaryId;
|
|
8
|
+
constructor(cached, isNew) {
|
|
9
|
+
super(cached);
|
|
10
|
+
this.isNew = isNew;
|
|
11
|
+
this.primaryId = randomUUID();
|
|
12
|
+
}
|
|
13
13
|
};
|
|
14
14
|
var DBIndexedSessionRepository = class {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
sessions.set(session.getId(), session);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return sessions;
|
|
91
|
-
}
|
|
92
|
-
async findByPrincipalName(principalName) {
|
|
93
|
-
return this.findByIndexNameAndIndexValue(PRINCIPAL_NAME_INDEX_NAME, principalName);
|
|
94
|
-
}
|
|
95
|
-
async cleanupExpiredSessions(cleanupCount) {
|
|
96
|
-
return this.db.cleanupExpiredSessions(cleanupCount);
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
export {
|
|
100
|
-
DBIndexedSessionRepository
|
|
15
|
+
defaultMaxInactiveInterval = 1800;
|
|
16
|
+
db;
|
|
17
|
+
constructor(db) {
|
|
18
|
+
this.db = db;
|
|
19
|
+
}
|
|
20
|
+
setDefaultMaxInactiveInterval(interval) {
|
|
21
|
+
this.defaultMaxInactiveInterval = interval;
|
|
22
|
+
}
|
|
23
|
+
mapSessionToEntity(session) {
|
|
24
|
+
const attributes = {};
|
|
25
|
+
for (const name of session.getAttributeNames()) attributes[name] = session.getAttribute(name);
|
|
26
|
+
const principalName = resolveIndexesFor(session);
|
|
27
|
+
return {
|
|
28
|
+
primaryId: session.primaryId,
|
|
29
|
+
sessionId: session.getId(),
|
|
30
|
+
creationTime: session.getCreationTime(),
|
|
31
|
+
lastAccessTime: session.getLastAccessedTime(),
|
|
32
|
+
maxInactiveInterval: session.getMaxInactiveInterval(),
|
|
33
|
+
expiryTime: session.getLastAccessedTime() + session.getMaxInactiveInterval() * 1e3,
|
|
34
|
+
attributes,
|
|
35
|
+
principalName
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
mapEntityToSession(entity, allowExpired) {
|
|
39
|
+
const loaded = new MapSession(entity.sessionId);
|
|
40
|
+
loaded.setCreationTime(entity.creationTime);
|
|
41
|
+
loaded.setLastAccessedTime(entity.lastAccessTime);
|
|
42
|
+
loaded.setMaxInactiveInterval(entity.maxInactiveInterval);
|
|
43
|
+
for (const [key, value] of Object.entries(entity.attributes)) loaded.setAttribute(key, value);
|
|
44
|
+
if (!allowExpired && loaded.isExpired()) return null;
|
|
45
|
+
const session = new DBSession(loaded, false);
|
|
46
|
+
session.primaryId = entity.primaryId;
|
|
47
|
+
return session;
|
|
48
|
+
}
|
|
49
|
+
async getSession(id, allowExpired) {
|
|
50
|
+
const entity = await this.db.findById(id);
|
|
51
|
+
if (!entity) return null;
|
|
52
|
+
return this.mapEntityToSession(entity, allowExpired);
|
|
53
|
+
}
|
|
54
|
+
createSession() {
|
|
55
|
+
const cached = new MapSession();
|
|
56
|
+
cached.setMaxInactiveInterval(this.defaultMaxInactiveInterval);
|
|
57
|
+
return new DBSession(cached, true);
|
|
58
|
+
}
|
|
59
|
+
async save(session) {
|
|
60
|
+
const entity = this.mapSessionToEntity(session);
|
|
61
|
+
await this.db.save(entity);
|
|
62
|
+
session.isNew = false;
|
|
63
|
+
}
|
|
64
|
+
async findById(sessionId) {
|
|
65
|
+
return this.getSession(sessionId, false);
|
|
66
|
+
}
|
|
67
|
+
async deleteById(sessionId) {
|
|
68
|
+
await this.db.deleteById(sessionId);
|
|
69
|
+
}
|
|
70
|
+
async findByIndexNameAndIndexValue(indexName, indexValue) {
|
|
71
|
+
if (indexName !== PRINCIPAL_NAME_INDEX_NAME) return /* @__PURE__ */ new Map();
|
|
72
|
+
const entities = await this.db.findByPrincipalName(indexValue);
|
|
73
|
+
if (entities.length === 0) return /* @__PURE__ */ new Map();
|
|
74
|
+
const sessions = /* @__PURE__ */ new Map();
|
|
75
|
+
for (const entity of entities) {
|
|
76
|
+
const session = this.mapEntityToSession(entity, false);
|
|
77
|
+
if (session) sessions.set(session.getId(), session);
|
|
78
|
+
}
|
|
79
|
+
return sessions;
|
|
80
|
+
}
|
|
81
|
+
async findByPrincipalName(principalName) {
|
|
82
|
+
return this.findByIndexNameAndIndexValue(PRINCIPAL_NAME_INDEX_NAME, principalName);
|
|
83
|
+
}
|
|
84
|
+
async cleanupExpiredSessions(cleanupCount) {
|
|
85
|
+
return this.db.cleanupExpiredSessions(cleanupCount);
|
|
86
|
+
}
|
|
101
87
|
};
|
|
88
|
+
//#endregion
|
|
89
|
+
export { DBIndexedSessionRepository };
|
|
90
|
+
|
|
102
91
|
//# sourceMappingURL=db.mjs.map
|
package/dist/session/db.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/session/db.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto';\nimport { PRINCIPAL_NAME_INDEX_NAME, resolveIndexesFor } from './common';\nimport { MapSession } from './map-session';\nimport type { SessionRepository } from './types';\n\ninterface SessionEntity {\n primaryId: string;\n sessionId: string;\n creationTime: number;\n lastAccessTime: number;\n maxInactiveInterval: number;\n expiryTime: number;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n attributes: Record<string, any>;\n principalName?: string | null;\n}\n\nclass DBSession extends MapSession {\n public isNew: boolean;\n public primaryId: string;\n\n constructor(cached: MapSession, isNew: boolean) {\n super(cached);\n this.isNew = isNew;\n this.primaryId = randomUUID();\n }\n}\n\nexport interface DBAdapter {\n save(session: SessionEntity): Promise<void>;\n deleteById(sessionId: string): Promise<void>;\n findById(sessionId: string): Promise<SessionEntity | null>;\n findByPrincipalName(principalName: string): Promise<SessionEntity[]>;\n cleanupExpiredSessions(cleanupCount?: number): Promise<void>;\n}\n\nexport class DBIndexedSessionRepository implements SessionRepository<DBSession> {\n private defaultMaxInactiveInterval = 1800;\n private db: DBAdapter;\n\n constructor(db: DBAdapter) {\n this.db = db;\n }\n\n setDefaultMaxInactiveInterval(interval: number) {\n this.defaultMaxInactiveInterval = interval;\n }\n\n private mapSessionToEntity(session: DBSession): SessionEntity {\n const attributes: Record<string, string | number | null> = {};\n for (const name of session.getAttributeNames()) {\n attributes[name] = session.getAttribute(name);\n }\n const principalName = resolveIndexesFor(session);\n\n return {\n primaryId: session.primaryId,\n sessionId: session.getId(),\n creationTime: session.getCreationTime(),\n lastAccessTime: session.getLastAccessedTime(),\n maxInactiveInterval: session.getMaxInactiveInterval(),\n expiryTime: session.getLastAccessedTime() + session.getMaxInactiveInterval() * 1000,\n attributes,\n principalName,\n };\n }\n\n private mapEntityToSession(entity: SessionEntity, allowExpired: boolean): DBSession | null {\n const loaded = new MapSession(entity.sessionId);\n loaded.setCreationTime(entity.creationTime);\n loaded.setLastAccessedTime(entity.lastAccessTime);\n loaded.setMaxInactiveInterval(entity.maxInactiveInterval);\n for (const [key, value] of Object.entries(entity.attributes)) {\n loaded.setAttribute(key, value);\n }\n\n if (!allowExpired && loaded.isExpired()) return null;\n const session = new DBSession(loaded, false);\n session.primaryId = entity.primaryId;\n return session;\n }\n\n private async getSession(id: string, allowExpired: boolean): Promise<DBSession | null> {\n const entity = await this.db.findById(id);\n if (!entity) return null;\n return this.mapEntityToSession(entity, allowExpired);\n }\n\n // override\n createSession() {\n const cached = new MapSession();\n cached.setMaxInactiveInterval(this.defaultMaxInactiveInterval);\n return new DBSession(cached, true);\n }\n\n async save(session: DBSession) {\n const entity = this.mapSessionToEntity(session);\n await this.db.save(entity);\n session.isNew = false;\n }\n\n async findById(sessionId: string): Promise<DBSession | null> {\n return this.getSession(sessionId, false);\n }\n\n async deleteById(sessionId: string) {\n await this.db.deleteById(sessionId);\n }\n\n async findByIndexNameAndIndexValue(\n indexName: string,\n indexValue: string\n ): Promise<Map<string, DBSession>> {\n if (indexName !== PRINCIPAL_NAME_INDEX_NAME) {\n return new Map<string, DBSession>();\n }\n const entities = await this.db.findByPrincipalName(indexValue);\n if (entities.length === 0) {\n return new Map<string, DBSession>();\n }\n const sessions = new Map<string, DBSession>();\n for (const entity of entities) {\n const session = this.mapEntityToSession(entity, false);\n if (session) {\n sessions.set(session.getId(), session);\n }\n }\n return sessions;\n }\n\n async findByPrincipalName(principalName: string): Promise<Map<string, DBSession>> {\n return this.findByIndexNameAndIndexValue(PRINCIPAL_NAME_INDEX_NAME, principalName);\n }\n\n async cleanupExpiredSessions(cleanupCount?: number): Promise<void> {\n return this.db.cleanupExpiredSessions(cleanupCount);\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"db.mjs","names":[],"sources":["../../src/session/db.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto';\nimport { PRINCIPAL_NAME_INDEX_NAME, resolveIndexesFor } from './common';\nimport { MapSession } from './map-session';\nimport type { SessionRepository } from './types';\n\ninterface SessionEntity {\n primaryId: string;\n sessionId: string;\n creationTime: number;\n lastAccessTime: number;\n maxInactiveInterval: number;\n expiryTime: number;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n attributes: Record<string, any>;\n principalName?: string | null;\n}\n\nclass DBSession extends MapSession {\n public isNew: boolean;\n public primaryId: string;\n\n constructor(cached: MapSession, isNew: boolean) {\n super(cached);\n this.isNew = isNew;\n this.primaryId = randomUUID();\n }\n}\n\nexport interface DBAdapter {\n save(session: SessionEntity): Promise<void>;\n deleteById(sessionId: string): Promise<void>;\n findById(sessionId: string): Promise<SessionEntity | null>;\n findByPrincipalName(principalName: string): Promise<SessionEntity[]>;\n cleanupExpiredSessions(cleanupCount?: number): Promise<void>;\n}\n\nexport class DBIndexedSessionRepository implements SessionRepository<DBSession> {\n private defaultMaxInactiveInterval = 1800;\n private db: DBAdapter;\n\n constructor(db: DBAdapter) {\n this.db = db;\n }\n\n setDefaultMaxInactiveInterval(interval: number) {\n this.defaultMaxInactiveInterval = interval;\n }\n\n private mapSessionToEntity(session: DBSession): SessionEntity {\n const attributes: Record<string, string | number | null> = {};\n for (const name of session.getAttributeNames()) {\n attributes[name] = session.getAttribute(name);\n }\n const principalName = resolveIndexesFor(session);\n\n return {\n primaryId: session.primaryId,\n sessionId: session.getId(),\n creationTime: session.getCreationTime(),\n lastAccessTime: session.getLastAccessedTime(),\n maxInactiveInterval: session.getMaxInactiveInterval(),\n expiryTime: session.getLastAccessedTime() + session.getMaxInactiveInterval() * 1000,\n attributes,\n principalName,\n };\n }\n\n private mapEntityToSession(entity: SessionEntity, allowExpired: boolean): DBSession | null {\n const loaded = new MapSession(entity.sessionId);\n loaded.setCreationTime(entity.creationTime);\n loaded.setLastAccessedTime(entity.lastAccessTime);\n loaded.setMaxInactiveInterval(entity.maxInactiveInterval);\n for (const [key, value] of Object.entries(entity.attributes)) {\n loaded.setAttribute(key, value);\n }\n\n if (!allowExpired && loaded.isExpired()) return null;\n const session = new DBSession(loaded, false);\n session.primaryId = entity.primaryId;\n return session;\n }\n\n private async getSession(id: string, allowExpired: boolean): Promise<DBSession | null> {\n const entity = await this.db.findById(id);\n if (!entity) return null;\n return this.mapEntityToSession(entity, allowExpired);\n }\n\n // override\n createSession() {\n const cached = new MapSession();\n cached.setMaxInactiveInterval(this.defaultMaxInactiveInterval);\n return new DBSession(cached, true);\n }\n\n async save(session: DBSession) {\n const entity = this.mapSessionToEntity(session);\n await this.db.save(entity);\n session.isNew = false;\n }\n\n async findById(sessionId: string): Promise<DBSession | null> {\n return this.getSession(sessionId, false);\n }\n\n async deleteById(sessionId: string) {\n await this.db.deleteById(sessionId);\n }\n\n async findByIndexNameAndIndexValue(\n indexName: string,\n indexValue: string\n ): Promise<Map<string, DBSession>> {\n if (indexName !== PRINCIPAL_NAME_INDEX_NAME) {\n return new Map<string, DBSession>();\n }\n const entities = await this.db.findByPrincipalName(indexValue);\n if (entities.length === 0) {\n return new Map<string, DBSession>();\n }\n const sessions = new Map<string, DBSession>();\n for (const entity of entities) {\n const session = this.mapEntityToSession(entity, false);\n if (session) {\n sessions.set(session.getId(), session);\n }\n }\n return sessions;\n }\n\n async findByPrincipalName(principalName: string): Promise<Map<string, DBSession>> {\n return this.findByIndexNameAndIndexValue(PRINCIPAL_NAME_INDEX_NAME, principalName);\n }\n\n async cleanupExpiredSessions(cleanupCount?: number): Promise<void> {\n return this.db.cleanupExpiredSessions(cleanupCount);\n }\n}\n"],"mappings":";;;;AAiBA,IAAM,YAAN,cAAwB,WAAW;CACjC;CACA;CAEA,YAAY,QAAoB,OAAgB;EAC9C,MAAM,MAAM;EACZ,KAAK,QAAQ;EACb,KAAK,YAAY,WAAW;CAC9B;AACF;AAUA,IAAa,6BAAb,MAAgF;CAC9E,6BAAqC;CACrC;CAEA,YAAY,IAAe;EACzB,KAAK,KAAK;CACZ;CAEA,8BAA8B,UAAkB;EAC9C,KAAK,6BAA6B;CACpC;CAEA,mBAA2B,SAAmC;EAC5D,MAAM,aAAqD,CAAC;EAC5D,KAAK,MAAM,QAAQ,QAAQ,kBAAkB,GAC3C,WAAW,QAAQ,QAAQ,aAAa,IAAI;EAE9C,MAAM,gBAAgB,kBAAkB,OAAO;EAE/C,OAAO;GACL,WAAW,QAAQ;GACnB,WAAW,QAAQ,MAAM;GACzB,cAAc,QAAQ,gBAAgB;GACtC,gBAAgB,QAAQ,oBAAoB;GAC5C,qBAAqB,QAAQ,uBAAuB;GACpD,YAAY,QAAQ,oBAAoB,IAAI,QAAQ,uBAAuB,IAAI;GAC/E;GACA;EACF;CACF;CAEA,mBAA2B,QAAuB,cAAyC;EACzF,MAAM,SAAS,IAAI,WAAW,OAAO,SAAS;EAC9C,OAAO,gBAAgB,OAAO,YAAY;EAC1C,OAAO,oBAAoB,OAAO,cAAc;EAChD,OAAO,uBAAuB,OAAO,mBAAmB;EACxD,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,UAAU,GACzD,OAAO,aAAa,KAAK,KAAK;EAGhC,IAAI,CAAC,gBAAgB,OAAO,UAAU,GAAG,OAAO;EAChD,MAAM,UAAU,IAAI,UAAU,QAAQ,KAAK;EAC3C,QAAQ,YAAY,OAAO;EAC3B,OAAO;CACT;CAEA,MAAc,WAAW,IAAY,cAAkD;EACrF,MAAM,SAAS,MAAM,KAAK,GAAG,SAAS,EAAE;EACxC,IAAI,CAAC,QAAQ,OAAO;EACpB,OAAO,KAAK,mBAAmB,QAAQ,YAAY;CACrD;CAGA,gBAAgB;EACd,MAAM,SAAS,IAAI,WAAW;EAC9B,OAAO,uBAAuB,KAAK,0BAA0B;EAC7D,OAAO,IAAI,UAAU,QAAQ,IAAI;CACnC;CAEA,MAAM,KAAK,SAAoB;EAC7B,MAAM,SAAS,KAAK,mBAAmB,OAAO;EAC9C,MAAM,KAAK,GAAG,KAAK,MAAM;EACzB,QAAQ,QAAQ;CAClB;CAEA,MAAM,SAAS,WAA8C;EAC3D,OAAO,KAAK,WAAW,WAAW,KAAK;CACzC;CAEA,MAAM,WAAW,WAAmB;EAClC,MAAM,KAAK,GAAG,WAAW,SAAS;CACpC;CAEA,MAAM,6BACJ,WACA,YACiC;EACjC,IAAI,cAAc,2BAChB,uBAAO,IAAI,IAAuB;EAEpC,MAAM,WAAW,MAAM,KAAK,GAAG,oBAAoB,UAAU;EAC7D,IAAI,SAAS,WAAW,GACtB,uBAAO,IAAI,IAAuB;EAEpC,MAAM,2BAAW,IAAI,IAAuB;EAC5C,KAAK,MAAM,UAAU,UAAU;GAC7B,MAAM,UAAU,KAAK,mBAAmB,QAAQ,KAAK;GACrD,IAAI,SACF,SAAS,IAAI,QAAQ,MAAM,GAAG,OAAO;EAEzC;EACA,OAAO;CACT;CAEA,MAAM,oBAAoB,eAAwD;EAChF,OAAO,KAAK,6BAA6B,2BAA2B,aAAa;CACnF;CAEA,MAAM,uBAAuB,cAAsC;EACjE,OAAO,KAAK,GAAG,uBAAuB,YAAY;CACpD;AACF"}
|
|
@@ -1,108 +1,76 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/session/map-session.ts
|
|
21
|
-
var map_session_exports = {};
|
|
22
|
-
__export(map_session_exports, {
|
|
23
|
-
MapSession: () => MapSession
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(map_session_exports);
|
|
26
|
-
var import_node_crypto = require("crypto");
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let node_crypto = require("node:crypto");
|
|
3
|
+
//#region src/session/map-session.ts
|
|
27
4
|
function generateId() {
|
|
28
|
-
|
|
5
|
+
return (0, node_crypto.randomUUID)();
|
|
29
6
|
}
|
|
30
|
-
|
|
7
|
+
const DEFAULT_MAX_INACTIVE_INTERVAL = 1800;
|
|
31
8
|
var MapSession = class {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
setMaxInactiveInterval(interval) {
|
|
97
|
-
this.maxInactiveInterval = interval;
|
|
98
|
-
}
|
|
99
|
-
isExpired() {
|
|
100
|
-
if (this.maxInactiveInterval < 0) return false;
|
|
101
|
-
return Date.now() - this.maxInactiveInterval * 1e3 - this.lastAccessedTime >= 0;
|
|
102
|
-
}
|
|
9
|
+
id;
|
|
10
|
+
sessionAttrs = /* @__PURE__ */ new Map();
|
|
11
|
+
creationTime = Date.now();
|
|
12
|
+
lastAccessedTime = this.creationTime;
|
|
13
|
+
maxInactiveInterval = DEFAULT_MAX_INACTIVE_INTERVAL;
|
|
14
|
+
constructor(input) {
|
|
15
|
+
if (typeof input === "undefined") this.id = generateId();
|
|
16
|
+
else if (typeof input === "string") this.id = input;
|
|
17
|
+
else {
|
|
18
|
+
const session = input;
|
|
19
|
+
this.id = session.getId();
|
|
20
|
+
for (const attrName of session.getAttributeNames()) {
|
|
21
|
+
const attrValue = session.getAttribute(attrName);
|
|
22
|
+
if (attrValue !== null) this.setAttribute(attrName, attrValue);
|
|
23
|
+
}
|
|
24
|
+
this.lastAccessedTime = session.getLastAccessedTime();
|
|
25
|
+
this.creationTime = session.getCreationTime();
|
|
26
|
+
this.maxInactiveInterval = session.getMaxInactiveInterval();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
setCreationTime(creationTime) {
|
|
30
|
+
this.creationTime = creationTime;
|
|
31
|
+
}
|
|
32
|
+
getId() {
|
|
33
|
+
return this.id;
|
|
34
|
+
}
|
|
35
|
+
changeSessionId() {
|
|
36
|
+
const changedId = generateId();
|
|
37
|
+
this.id = changedId;
|
|
38
|
+
return changedId;
|
|
39
|
+
}
|
|
40
|
+
getAttribute(name) {
|
|
41
|
+
return this.sessionAttrs.get(name) ?? null;
|
|
42
|
+
}
|
|
43
|
+
getAttributeNames() {
|
|
44
|
+
return Array.from(this.sessionAttrs.keys());
|
|
45
|
+
}
|
|
46
|
+
setAttribute(name, value) {
|
|
47
|
+
if (value === null) this.removeAttribute(name);
|
|
48
|
+
else this.sessionAttrs.set(name, value);
|
|
49
|
+
}
|
|
50
|
+
removeAttribute(name) {
|
|
51
|
+
this.sessionAttrs.delete(name);
|
|
52
|
+
}
|
|
53
|
+
getCreationTime() {
|
|
54
|
+
return this.creationTime;
|
|
55
|
+
}
|
|
56
|
+
getLastAccessedTime() {
|
|
57
|
+
return this.lastAccessedTime;
|
|
58
|
+
}
|
|
59
|
+
setLastAccessedTime(lastAccessedTime) {
|
|
60
|
+
this.lastAccessedTime = lastAccessedTime;
|
|
61
|
+
}
|
|
62
|
+
getMaxInactiveInterval() {
|
|
63
|
+
return this.maxInactiveInterval;
|
|
64
|
+
}
|
|
65
|
+
setMaxInactiveInterval(interval) {
|
|
66
|
+
this.maxInactiveInterval = interval;
|
|
67
|
+
}
|
|
68
|
+
isExpired() {
|
|
69
|
+
if (this.maxInactiveInterval < 0) return false;
|
|
70
|
+
return Date.now() - this.maxInactiveInterval * 1e3 - this.lastAccessedTime >= 0;
|
|
71
|
+
}
|
|
103
72
|
};
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
});
|
|
73
|
+
//#endregion
|
|
74
|
+
exports.MapSession = MapSession;
|
|
75
|
+
|
|
108
76
|
//# sourceMappingURL=map-session.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/session/map-session.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto';\nimport type { Session } from './types';\n\nfunction generateId() {\n return randomUUID();\n}\n\nconst DEFAULT_MAX_INACTIVE_INTERVAL = 1800;\n\nexport class MapSession implements Session {\n private id: string;\n private sessionAttrs = new Map<string, string | number>();\n private creationTime = Date.now();\n private lastAccessedTime = this.creationTime;\n private maxInactiveInterval = DEFAULT_MAX_INACTIVE_INTERVAL;\n\n constructor(id?: string);\n constructor(session: Session);\n constructor(input?: string | Session) {\n if (typeof input === 'undefined') {\n this.id = generateId();\n } else if (typeof input === 'string') {\n this.id = input;\n } else {\n const session = input;\n this.id = session.getId();\n\n for (const attrName of session.getAttributeNames()) {\n const attrValue = session.getAttribute(attrName);\n if (attrValue !== null) {\n this.setAttribute(attrName, attrValue);\n }\n }\n\n this.lastAccessedTime = session.getLastAccessedTime();\n this.creationTime = session.getCreationTime();\n this.maxInactiveInterval = session.getMaxInactiveInterval();\n }\n }\n\n setCreationTime(creationTime: number) {\n this.creationTime = creationTime;\n }\n\n // override\n getId() {\n return this.id;\n }\n\n changeSessionId() {\n const changedId = generateId();\n this.id = changedId;\n return changedId;\n }\n\n getAttribute(name: string) {\n return this.sessionAttrs.get(name) ?? null;\n }\n\n getAttributeNames(): string[] {\n return Array.from(this.sessionAttrs.keys());\n }\n\n setAttribute(name: string, value: string | number) {\n if (value === null) {\n this.removeAttribute(name);\n } else {\n this.sessionAttrs.set(name, value);\n }\n }\n\n removeAttribute(name: string) {\n this.sessionAttrs.delete(name);\n }\n\n getCreationTime() {\n return this.creationTime;\n }\n\n getLastAccessedTime() {\n return this.lastAccessedTime;\n }\n\n setLastAccessedTime(lastAccessedTime: number) {\n this.lastAccessedTime = lastAccessedTime;\n }\n\n getMaxInactiveInterval() {\n return this.maxInactiveInterval;\n }\n\n setMaxInactiveInterval(interval: number) {\n this.maxInactiveInterval = interval;\n }\n\n isExpired() {\n if (this.maxInactiveInterval < 0) return false;\n return Date.now() - this.maxInactiveInterval * 1000 - this.lastAccessedTime >= 0;\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"map-session.cjs","names":[],"sources":["../../src/session/map-session.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto';\nimport type { Session } from './types';\n\nfunction generateId() {\n return randomUUID();\n}\n\nconst DEFAULT_MAX_INACTIVE_INTERVAL = 1800;\n\nexport class MapSession implements Session {\n private id: string;\n private sessionAttrs = new Map<string, string | number>();\n private creationTime = Date.now();\n private lastAccessedTime = this.creationTime;\n private maxInactiveInterval = DEFAULT_MAX_INACTIVE_INTERVAL;\n\n constructor(id?: string);\n constructor(session: Session);\n constructor(input?: string | Session) {\n if (typeof input === 'undefined') {\n this.id = generateId();\n } else if (typeof input === 'string') {\n this.id = input;\n } else {\n const session = input;\n this.id = session.getId();\n\n for (const attrName of session.getAttributeNames()) {\n const attrValue = session.getAttribute(attrName);\n if (attrValue !== null) {\n this.setAttribute(attrName, attrValue);\n }\n }\n\n this.lastAccessedTime = session.getLastAccessedTime();\n this.creationTime = session.getCreationTime();\n this.maxInactiveInterval = session.getMaxInactiveInterval();\n }\n }\n\n setCreationTime(creationTime: number) {\n this.creationTime = creationTime;\n }\n\n // override\n getId() {\n return this.id;\n }\n\n changeSessionId() {\n const changedId = generateId();\n this.id = changedId;\n return changedId;\n }\n\n getAttribute(name: string) {\n return this.sessionAttrs.get(name) ?? null;\n }\n\n getAttributeNames(): string[] {\n return Array.from(this.sessionAttrs.keys());\n }\n\n setAttribute(name: string, value: string | number) {\n if (value === null) {\n this.removeAttribute(name);\n } else {\n this.sessionAttrs.set(name, value);\n }\n }\n\n removeAttribute(name: string) {\n this.sessionAttrs.delete(name);\n }\n\n getCreationTime() {\n return this.creationTime;\n }\n\n getLastAccessedTime() {\n return this.lastAccessedTime;\n }\n\n setLastAccessedTime(lastAccessedTime: number) {\n this.lastAccessedTime = lastAccessedTime;\n }\n\n getMaxInactiveInterval() {\n return this.maxInactiveInterval;\n }\n\n setMaxInactiveInterval(interval: number) {\n this.maxInactiveInterval = interval;\n }\n\n isExpired() {\n if (this.maxInactiveInterval < 0) return false;\n return Date.now() - this.maxInactiveInterval * 1000 - this.lastAccessedTime >= 0;\n }\n}\n"],"mappings":";;;AAGA,SAAS,aAAa;CACpB,QAAA,GAAA,YAAA,WAAA,CAAkB;AACpB;AAEA,MAAM,gCAAgC;AAEtC,IAAa,aAAb,MAA2C;CACzC;CACA,+BAAuB,IAAI,IAA6B;CACxD,eAAuB,KAAK,IAAI;CAChC,mBAA2B,KAAK;CAChC,sBAA8B;CAI9B,YAAY,OAA0B;EACpC,IAAI,OAAO,UAAU,aACnB,KAAK,KAAK,WAAW;OAChB,IAAI,OAAO,UAAU,UAC1B,KAAK,KAAK;OACL;GACL,MAAM,UAAU;GAChB,KAAK,KAAK,QAAQ,MAAM;GAExB,KAAK,MAAM,YAAY,QAAQ,kBAAkB,GAAG;IAClD,MAAM,YAAY,QAAQ,aAAa,QAAQ;IAC/C,IAAI,cAAc,MAChB,KAAK,aAAa,UAAU,SAAS;GAEzC;GAEA,KAAK,mBAAmB,QAAQ,oBAAoB;GACpD,KAAK,eAAe,QAAQ,gBAAgB;GAC5C,KAAK,sBAAsB,QAAQ,uBAAuB;EAC5D;CACF;CAEA,gBAAgB,cAAsB;EACpC,KAAK,eAAe;CACtB;CAGA,QAAQ;EACN,OAAO,KAAK;CACd;CAEA,kBAAkB;EAChB,MAAM,YAAY,WAAW;EAC7B,KAAK,KAAK;EACV,OAAO;CACT;CAEA,aAAa,MAAc;EACzB,OAAO,KAAK,aAAa,IAAI,IAAI,KAAK;CACxC;CAEA,oBAA8B;EAC5B,OAAO,MAAM,KAAK,KAAK,aAAa,KAAK,CAAC;CAC5C;CAEA,aAAa,MAAc,OAAwB;EACjD,IAAI,UAAU,MACZ,KAAK,gBAAgB,IAAI;OAEzB,KAAK,aAAa,IAAI,MAAM,KAAK;CAErC;CAEA,gBAAgB,MAAc;EAC5B,KAAK,aAAa,OAAO,IAAI;CAC/B;CAEA,kBAAkB;EAChB,OAAO,KAAK;CACd;CAEA,sBAAsB;EACpB,OAAO,KAAK;CACd;CAEA,oBAAoB,kBAA0B;EAC5C,KAAK,mBAAmB;CAC1B;CAEA,yBAAyB;EACvB,OAAO,KAAK;CACd;CAEA,uBAAuB,UAAkB;EACvC,KAAK,sBAAsB;CAC7B;CAEA,YAAY;EACV,IAAI,KAAK,sBAAsB,GAAG,OAAO;EACzC,OAAO,KAAK,IAAI,IAAI,KAAK,sBAAsB,MAAO,KAAK,oBAAoB;CACjF;AACF"}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { Session } from
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { Session } from "./types.cjs";
|
|
2
|
+
//#region src/session/map-session.d.ts
|
|
4
3
|
declare class MapSession implements Session {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
4
|
+
private id;
|
|
5
|
+
private sessionAttrs;
|
|
6
|
+
private creationTime;
|
|
7
|
+
private lastAccessedTime;
|
|
8
|
+
private maxInactiveInterval;
|
|
9
|
+
constructor(id?: string);
|
|
10
|
+
constructor(session: Session);
|
|
11
|
+
setCreationTime(creationTime: number): void;
|
|
12
|
+
getId(): string;
|
|
13
|
+
changeSessionId(): `${string}-${string}-${string}-${string}-${string}`;
|
|
14
|
+
getAttribute(name: string): string | number | null;
|
|
15
|
+
getAttributeNames(): string[];
|
|
16
|
+
setAttribute(name: string, value: string | number): void;
|
|
17
|
+
removeAttribute(name: string): void;
|
|
18
|
+
getCreationTime(): number;
|
|
19
|
+
getLastAccessedTime(): number;
|
|
20
|
+
setLastAccessedTime(lastAccessedTime: number): void;
|
|
21
|
+
getMaxInactiveInterval(): number;
|
|
22
|
+
setMaxInactiveInterval(interval: number): void;
|
|
23
|
+
isExpired(): boolean;
|
|
25
24
|
}
|
|
26
|
-
|
|
25
|
+
//#endregion
|
|
27
26
|
export { MapSession };
|
|
27
|
+
//# sourceMappingURL=map-session.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map-session.d.cts","names":[],"sources":["../../src/session/map-session.ts"],"mappings":";;cASa,sBAAsB;UACzB;UACA;UACA;UACA;UACA;EAER,YAAY;EACZ,YAAY,SAAS;EAuBrB,gBAAgB;EAKhB;EAIA;EAMA,aAAa;EAIb;EAIA,aAAa,cAAc;EAQ3B,gBAAgB;EAIhB;EAIA;EAIA,oBAAoB;EAIpB;EAIA,uBAAuB;EAIvB"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Session } from "./types.mjs";
|
|
2
|
+
//#region src/session/map-session.d.ts
|
|
3
|
+
declare class MapSession implements Session {
|
|
4
|
+
private id;
|
|
5
|
+
private sessionAttrs;
|
|
6
|
+
private creationTime;
|
|
7
|
+
private lastAccessedTime;
|
|
8
|
+
private maxInactiveInterval;
|
|
9
|
+
constructor(id?: string);
|
|
10
|
+
constructor(session: Session);
|
|
11
|
+
setCreationTime(creationTime: number): void;
|
|
12
|
+
getId(): string;
|
|
13
|
+
changeSessionId(): `${string}-${string}-${string}-${string}-${string}`;
|
|
14
|
+
getAttribute(name: string): string | number | null;
|
|
15
|
+
getAttributeNames(): string[];
|
|
16
|
+
setAttribute(name: string, value: string | number): void;
|
|
17
|
+
removeAttribute(name: string): void;
|
|
18
|
+
getCreationTime(): number;
|
|
19
|
+
getLastAccessedTime(): number;
|
|
20
|
+
setLastAccessedTime(lastAccessedTime: number): void;
|
|
21
|
+
getMaxInactiveInterval(): number;
|
|
22
|
+
setMaxInactiveInterval(interval: number): void;
|
|
23
|
+
isExpired(): boolean;
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { MapSession };
|
|
27
|
+
//# sourceMappingURL=map-session.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map-session.d.mts","names":[],"sources":["../../src/session/map-session.ts"],"mappings":";;cASa,sBAAsB;UACzB;UACA;UACA;UACA;UACA;EAER,YAAY;EACZ,YAAY,SAAS;EAuBrB,gBAAgB;EAKhB;EAIA;EAMA,aAAa;EAIb;EAIA,aAAa,cAAc;EAQ3B,gBAAgB;EAIhB;EAIA;EAIA,oBAAoB;EAIpB;EAIA,uBAAuB;EAIvB"}
|