@scayle/h3-session 0.6.0 → 0.6.2

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @scayle/h3-session
2
2
 
3
+ ## 0.6.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Cleaned up README.md and added CONTRIBUTING.md. No functional changes.
8
+
9
+ ## 0.6.1
10
+
11
+ ### Patch Changes
12
+
13
+ - 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.
14
+
3
15
  ## 0.6.0
4
16
 
5
17
  ### Minor Changes
@@ -10,7 +22,7 @@
10
22
 
11
23
  ### Patch Changes
12
24
 
13
- - When a sessionID exists, but there is no session data, re-use the sessionID instead of generating both new data and a new ID. This enables proper functioning of the `saveUnitialized` configuration.
25
+ - When a sessionID exists, but there is no session data, re-use the sessionID instead of generating both new data and a new ID. This enables proper functioning of the `saveUninitialized` configuration.
14
26
  - Fix the `clear()` method on `UnstorageSessionStore` not clearing sessions
15
27
 
16
28
  ## 0.5.0
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 SCAYLE GmbH
3
+ Copyright (c) 2025 SCAYLE GmbH
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -143,12 +143,3 @@ declare module '@scayle/h3-session' {
143
143
  ## License
144
144
 
145
145
  Licensed under the [MIT License](https://opensource.org/license/mit/)
146
-
147
- <!-- Badges -->
148
-
149
- [npm-version-src]: https://img.shields.io/npm/v/@scayle/h3-session/latest.svg?style=flat&colorA=18181B&colorB=28CF8D
150
- [npm-version-href]: https://npmjs.com/package/@scayle/h3-session
151
- [npm-downloads-src]: https://img.shields.io/npm/dm/@scayle/h3-session.svg?style=flat&colorA=18181B&colorB=28CF8D
152
- [npm-downloads-href]: https://npmjs.com/package/@scayle/h3-session
153
- [license-src]: https://img.shields.io/npm/l/@scayle/h3-session.svg?style=flat&colorA=18181B&colorB=28CF8D
154
- [license-href]: https://npmjs.com/package/@scayle/h3-session
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 { type H3SessionOptions, type RawSession, Session, type SessionCookie, type SessionCookieOptions, type SessionDataT, type SessionMethods, type SessionStore, UnstorageSessionStore, signCookie, unsignCookie, useSession, validateConfig };
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 { type H3SessionOptions, type RawSession, Session, type SessionCookie, type SessionCookieOptions, type SessionDataT, type SessionMethods, type SessionStore, UnstorageSessionStore, signCookie, unsignCookie, useSession, validateConfig };
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 ?? undefined;
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 undefined;
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 undefined;
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.0",
3
+ "version": "0.6.2",
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
  },
@@ -16,18 +23,6 @@
16
23
  "CHANGELOG.md",
17
24
  "dist/**"
18
25
  ],
19
- "scripts": {
20
- "build": "unbuild",
21
- "verify-packaging": "attw --pack . --profile esm-only",
22
- "format": "dprint check",
23
- "format:fix": "dprint fmt",
24
- "lint": "eslint . --format gitlab",
25
- "lint:fix": "eslint . --fix",
26
- "test": "vitest run",
27
- "test:ci": "vitest --run --coverage --reporter=default --reporter=junit --outputFile=./coverage/junit.xml",
28
- "test:watch": "vitest watch",
29
- "typecheck": "tsc --noEmit -p tsconfig.json"
30
- },
31
26
  "peerDependencies": {
32
27
  "h3": "^1.10.0"
33
28
  },
@@ -37,18 +32,33 @@
37
32
  "unstorage": "^1.10.2"
38
33
  },
39
34
  "devDependencies": {
40
- "@arethetypeswrong/cli": "0.17.3",
41
- "@scayle/eslint-config-storefront": "4.4.1",
42
- "cookie-es": "1.2.2",
43
- "dprint": "0.48.0",
44
- "eslint": "9.18.0",
45
- "eslint-formatter-gitlab": "5.1.0",
46
- "h3": "1.13.1",
47
- "typescript": "5.7.3",
48
- "unbuild": "3.3.1",
49
- "vitest": "2.1.8"
35
+ "@arethetypeswrong/cli": "0.18.2",
36
+ "@vitest/coverage-v8": "3.2.4",
37
+ "cookie-es": "2.0.0",
38
+ "dprint": "0.50.2",
39
+ "eslint-formatter-gitlab": "6.0.1",
40
+ "eslint": "9.38.0",
41
+ "h3": "1.15.4",
42
+ "typescript": "5.9.3",
43
+ "unbuild": "3.6.1",
44
+ "vitest": "3.2.4",
45
+ "@scayle/eslint-config-storefront": "4.7.11",
46
+ "@scayle/vitest-config-storefront": "1.0.0"
50
47
  },
51
48
  "volta": {
52
- "node": "22.13.0"
49
+ "node": "22.21.0"
50
+ },
51
+ "scripts": {
52
+ "build": "unbuild",
53
+ "verify-packaging": "attw --pack . --profile esm-only",
54
+ "format": "dprint check",
55
+ "format:fix": "dprint fmt",
56
+ "lint": "eslint .",
57
+ "lint:ci": "eslint . --format gitlab",
58
+ "lint:fix": "eslint . --fix",
59
+ "test": "vitest run",
60
+ "test:ci": "vitest --run --coverage --reporter=default --reporter=junit --outputFile=./coverage/junit.xml",
61
+ "test:watch": "vitest watch",
62
+ "typecheck": "tsc --noEmit -p tsconfig.json"
53
63
  }
54
- }
64
+ }