@scayle/h3-session 0.5.0 → 0.5.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 +7 -0
- package/dist/index.mjs +13 -4
- package/package.json +6 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @scayle/h3-session
|
|
2
2
|
|
|
3
|
+
## 0.5.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 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.
|
|
8
|
+
- Fix the `clear()` method on `UnstorageSessionStore` not clearing sessions
|
|
9
|
+
|
|
3
10
|
## 0.5.0
|
|
4
11
|
|
|
5
12
|
### Minor Changes
|
package/dist/index.mjs
CHANGED
|
@@ -88,7 +88,8 @@ class UnstorageSessionStore {
|
|
|
88
88
|
* Remove all saved sessions
|
|
89
89
|
*/
|
|
90
90
|
async clear() {
|
|
91
|
-
|
|
91
|
+
const keys = await this.getAllKeys();
|
|
92
|
+
await Promise.all(keys.map((k) => this.storage.removeItem(k)));
|
|
92
93
|
}
|
|
93
94
|
/**
|
|
94
95
|
* Fetch all saved sessions.
|
|
@@ -262,14 +263,22 @@ async function useSession(event, config) {
|
|
|
262
263
|
}
|
|
263
264
|
async function createExistingSession(id, data) {
|
|
264
265
|
const cookie = await createSessionCookie(id);
|
|
265
|
-
if (store.touch) {
|
|
266
|
+
if (store.touch && data) {
|
|
266
267
|
await store.touch(id, data);
|
|
267
268
|
}
|
|
268
|
-
event.context.session = new Session(
|
|
269
|
+
event.context.session = new Session(
|
|
270
|
+
id,
|
|
271
|
+
data ?? sessionConfig.generate(),
|
|
272
|
+
store,
|
|
273
|
+
generate,
|
|
274
|
+
cookie
|
|
275
|
+
);
|
|
269
276
|
event.context.sessionId = id;
|
|
270
277
|
}
|
|
271
|
-
if (!sessionId
|
|
278
|
+
if (!sessionId) {
|
|
272
279
|
await createNewSession();
|
|
280
|
+
} else if (!sessionData) {
|
|
281
|
+
await createExistingSession(sessionId);
|
|
273
282
|
} else {
|
|
274
283
|
await createExistingSession(sessionId, sessionData);
|
|
275
284
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scayle/h3-session",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Persistent sessions for h3",
|
|
5
5
|
"author": "SCAYLE Commerce Engine",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,14 +37,15 @@
|
|
|
37
37
|
"unstorage": "^1.10.2"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@arethetypeswrong/cli": "0.17.
|
|
40
|
+
"@arethetypeswrong/cli": "0.17.2",
|
|
41
41
|
"@scayle/eslint-config-storefront": "4.4.0",
|
|
42
|
-
"
|
|
42
|
+
"cookie-es": "1.2.2",
|
|
43
|
+
"dprint": "0.48.0",
|
|
43
44
|
"eslint": "9.17.0",
|
|
44
45
|
"eslint-formatter-gitlab": "5.1.0",
|
|
45
46
|
"h3": "1.13.0",
|
|
46
|
-
"typescript": "5.
|
|
47
|
-
"unbuild": "3.0
|
|
47
|
+
"typescript": "5.7.2",
|
|
48
|
+
"unbuild": "3.2.0",
|
|
48
49
|
"vitest": "2.1.8"
|
|
49
50
|
},
|
|
50
51
|
"volta": {
|