@arkstack/driver-express 0.12.11 → 0.12.12
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/index.js +21 -11
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -62,7 +62,7 @@ const defaultErrorHandler = async (err, req, res, next) => {
|
|
|
62
62
|
}));
|
|
63
63
|
};
|
|
64
64
|
//#endregion
|
|
65
|
-
//#region ../http/dist/redirect-
|
|
65
|
+
//#region ../http/dist/redirect-C1kZMywY.js
|
|
66
66
|
const unwrapRequestSource = (source) => {
|
|
67
67
|
if (source.headers) return source;
|
|
68
68
|
if (source.req) return source.req;
|
|
@@ -730,7 +730,7 @@ const ensureSession = (ctx, initial, persistent) => {
|
|
|
730
730
|
*/
|
|
731
731
|
const getSession = (ctx) => {
|
|
732
732
|
if (!isRecord(ctx)) return;
|
|
733
|
-
const session = ctx[sessionKey] ?? ctx.session;
|
|
733
|
+
const session = ctx[sessionKey] ?? (ctx.httpSession instanceof Session ? ctx.httpSession : void 0) ?? (ctx.session instanceof Session ? ctx.session : void 0) ?? (isRecord(ctx.req) && ctx.req.httpSession instanceof Session ? ctx.req.httpSession : void 0) ?? (isRecord(ctx.context) && ctx.context.httpSession instanceof Session ? ctx.context.httpSession : void 0);
|
|
734
734
|
return session instanceof Session ? session : void 0;
|
|
735
735
|
};
|
|
736
736
|
const generateSessionId = () => randomBytes(32).toString("base64url");
|
|
@@ -1167,16 +1167,26 @@ const getSessionDriver = () => {
|
|
|
1167
1167
|
definePlugin({
|
|
1168
1168
|
name: "arkstack-http",
|
|
1169
1169
|
setup: ({ bind, useHttpContext }) => {
|
|
1170
|
-
bind(Session, ({ ctx }) =>
|
|
1171
|
-
|
|
1170
|
+
bind(Session, async ({ ctx }) => {
|
|
1171
|
+
const existing = getSession(ctx);
|
|
1172
|
+
if (existing) return existing;
|
|
1173
|
+
const persistent = await getSessionDriver().start(ctx);
|
|
1174
|
+
const session = ensureSession(ctx, persistent.state, persistent);
|
|
1175
|
+
attachViewState(ctx, session);
|
|
1176
|
+
registerResponseFlashSweep(ctx, session);
|
|
1177
|
+
return session;
|
|
1178
|
+
});
|
|
1179
|
+
useHttpContext((context) => {
|
|
1180
|
+
const session = getSession(context.ctx);
|
|
1181
|
+
if (session) {
|
|
1182
|
+
context.httpSession = session;
|
|
1183
|
+
if (!("session" in context) || context.session instanceof Session) context.session = session;
|
|
1184
|
+
context.errors = session.errors;
|
|
1185
|
+
attachViewState(context.ctx, session);
|
|
1186
|
+
attachViewState(context, session);
|
|
1187
|
+
registerResponseFlashSweep(context, session);
|
|
1188
|
+
} else delete globalThis.session;
|
|
1172
1189
|
globalThis.request = (key) => key ? context.request.input(key) : context.request;
|
|
1173
|
-
const persistent = await getSessionDriver().start(context);
|
|
1174
|
-
const session = ensureSession(context.ctx, persistent.state, persistent);
|
|
1175
|
-
context.httpSession = session;
|
|
1176
|
-
if (!("session" in context) || context.session instanceof Session) context.session = session;
|
|
1177
|
-
context.errors = session.errors;
|
|
1178
|
-
attachViewState(context, session);
|
|
1179
|
-
registerResponseFlashSweep(context, session);
|
|
1180
1190
|
});
|
|
1181
1191
|
}
|
|
1182
1192
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arkstack/driver-express",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.12",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Express driver for Arkstack, providing Express-based runtime integration for the framework.",
|
|
6
6
|
"homepage": "https://arkstack.toneflix.net",
|
|
@@ -42,13 +42,13 @@
|
|
|
42
42
|
"express-rate-limit": "^8.4.1",
|
|
43
43
|
"@resora/plugin-clear-router": "^1.0.37",
|
|
44
44
|
"resora": "^1.3.6",
|
|
45
|
-
"@arkstack/contract": "^0.12.
|
|
45
|
+
"@arkstack/contract": "^0.12.12"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"express": "^5.2.1",
|
|
49
|
-
"@arkstack/auth": "^0.12.
|
|
50
|
-
"@arkstack/common": "^0.12.
|
|
51
|
-
"@arkstack/foundry": "^0.12.
|
|
49
|
+
"@arkstack/auth": "^0.12.12",
|
|
50
|
+
"@arkstack/common": "^0.12.12",
|
|
51
|
+
"@arkstack/foundry": "^0.12.12"
|
|
52
52
|
},
|
|
53
53
|
"peerDependenciesMeta": {
|
|
54
54
|
"@arkstack/auth": {
|