@scayle/h3-session 0.6.0 → 0.6.1
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/CHANGELOG.md +6 -0
- package/LICENSE +1 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.mjs +9 -3
- package/package.json +21 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @scayle/h3-session
|
|
2
2
|
|
|
3
|
+
## 0.6.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Disallow setting `name`, `path` or `domain` on the session cookie. Setting these properties would result in a new cookie rather than updating the existing cookie. It is now blocked to prevent unexpected behavior.
|
|
8
|
+
|
|
3
9
|
## 0.6.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/LICENSE
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -140,4 +140,5 @@ declare function validateConfig(config: H3SessionOptions): void;
|
|
|
140
140
|
*/
|
|
141
141
|
declare function useSession(event: H3Event, config: H3SessionOptions): Promise<void>;
|
|
142
142
|
|
|
143
|
-
export {
|
|
143
|
+
export { Session, UnstorageSessionStore, signCookie, unsignCookie, useSession, validateConfig };
|
|
144
|
+
export type { H3SessionOptions, RawSession, SessionCookie, SessionCookieOptions, SessionDataT, SessionMethods, SessionStore };
|
package/dist/index.d.ts
CHANGED
|
@@ -140,4 +140,5 @@ declare function validateConfig(config: H3SessionOptions): void;
|
|
|
140
140
|
*/
|
|
141
141
|
declare function useSession(event: H3Event, config: H3SessionOptions): Promise<void>;
|
|
142
142
|
|
|
143
|
-
export {
|
|
143
|
+
export { Session, UnstorageSessionStore, signCookie, unsignCookie, useSession, validateConfig };
|
|
144
|
+
export type { H3SessionOptions, RawSession, SessionCookie, SessionCookieOptions, SessionDataT, SessionMethods, SessionStore };
|
package/dist/index.mjs
CHANGED
|
@@ -95,7 +95,7 @@ class UnstorageSessionStore {
|
|
|
95
95
|
*/
|
|
96
96
|
async get(sid) {
|
|
97
97
|
const item = await this.storage.getItem(this.getKey(sid));
|
|
98
|
-
return item ??
|
|
98
|
+
return item ?? void 0;
|
|
99
99
|
}
|
|
100
100
|
/**
|
|
101
101
|
* Save the session with the specified session ID
|
|
@@ -166,11 +166,11 @@ class UnstorageSessionStore {
|
|
|
166
166
|
const signatureLength = 43;
|
|
167
167
|
function parseCookieValue(value) {
|
|
168
168
|
if (value.length < signatureLength + 3) {
|
|
169
|
-
return
|
|
169
|
+
return void 0;
|
|
170
170
|
}
|
|
171
171
|
const separatorIndex = value.length - signatureLength - 1;
|
|
172
172
|
if (value.charAt(0) !== "s" || value.charAt(1) !== ":" || value.charAt(separatorIndex) !== ".") {
|
|
173
|
-
return
|
|
173
|
+
return void 0;
|
|
174
174
|
}
|
|
175
175
|
return [
|
|
176
176
|
value.substring(2, separatorIndex),
|
|
@@ -222,6 +222,7 @@ function validateConfig(config) {
|
|
|
222
222
|
throw new Error("[h3-session] Session secret is required!");
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
|
+
const uniqueCookieAttributes = /* @__PURE__ */ new Set(["name", "path", "domain"]);
|
|
225
226
|
async function useSession(event, config) {
|
|
226
227
|
if (event.context.session) {
|
|
227
228
|
return;
|
|
@@ -261,6 +262,11 @@ async function useSession(event, config) {
|
|
|
261
262
|
await cookie.setSessionId(sid);
|
|
262
263
|
return new Proxy(cookie, {
|
|
263
264
|
set(target, property, value) {
|
|
265
|
+
if (uniqueCookieAttributes.has(property)) {
|
|
266
|
+
throw new Error(
|
|
267
|
+
`[h3-session] Cannot change ${property} on a session cookie!`
|
|
268
|
+
);
|
|
269
|
+
}
|
|
264
270
|
target[property] = value;
|
|
265
271
|
setCookie(event, sessionConfig.name, signedCookie, cookie);
|
|
266
272
|
return true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scayle/h3-session",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Persistent sessions for h3",
|
|
5
5
|
"author": "SCAYLE Commerce Engine",
|
|
6
6
|
"license": "MIT",
|
|
@@ -8,6 +8,13 @@
|
|
|
8
8
|
"access": "public",
|
|
9
9
|
"registry": "https://registry.npmjs.org/"
|
|
10
10
|
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"url": "git+https://github.com/scayle/h3-session.git"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"h3",
|
|
16
|
+
"session"
|
|
17
|
+
],
|
|
11
18
|
"exports": {
|
|
12
19
|
".": "./dist/index.mjs"
|
|
13
20
|
},
|
|
@@ -21,7 +28,8 @@
|
|
|
21
28
|
"verify-packaging": "attw --pack . --profile esm-only",
|
|
22
29
|
"format": "dprint check",
|
|
23
30
|
"format:fix": "dprint fmt",
|
|
24
|
-
"lint": "eslint .
|
|
31
|
+
"lint": "eslint .",
|
|
32
|
+
"lint:ci": "eslint . --format gitlab",
|
|
25
33
|
"lint:fix": "eslint . --fix",
|
|
26
34
|
"test": "vitest run",
|
|
27
35
|
"test:ci": "vitest --run --coverage --reporter=default --reporter=junit --outputFile=./coverage/junit.xml",
|
|
@@ -37,18 +45,18 @@
|
|
|
37
45
|
"unstorage": "^1.10.2"
|
|
38
46
|
},
|
|
39
47
|
"devDependencies": {
|
|
40
|
-
"@arethetypeswrong/cli": "0.17.
|
|
41
|
-
"@scayle/eslint-config-storefront": "4.
|
|
42
|
-
"cookie-es": "
|
|
43
|
-
"dprint": "0.
|
|
44
|
-
"eslint": "9.
|
|
45
|
-
"eslint-formatter-gitlab": "
|
|
46
|
-
"h3": "1.
|
|
47
|
-
"typescript": "5.
|
|
48
|
-
"unbuild": "3.
|
|
49
|
-
"vitest": "
|
|
48
|
+
"@arethetypeswrong/cli": "0.17.4",
|
|
49
|
+
"@scayle/eslint-config-storefront": "4.5.0",
|
|
50
|
+
"cookie-es": "2.0.0",
|
|
51
|
+
"dprint": "0.49.1",
|
|
52
|
+
"eslint": "9.25.1",
|
|
53
|
+
"eslint-formatter-gitlab": "6.0.0",
|
|
54
|
+
"h3": "1.15.1",
|
|
55
|
+
"typescript": "5.8.3",
|
|
56
|
+
"unbuild": "3.5.0",
|
|
57
|
+
"vitest": "3.1.2"
|
|
50
58
|
},
|
|
51
59
|
"volta": {
|
|
52
|
-
"node": "22.
|
|
60
|
+
"node": "22.14.0"
|
|
53
61
|
}
|
|
54
62
|
}
|