@arkstack/driver-express 0.12.20 → 0.12.21
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 +52 -13
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -62,8 +62,9 @@ const defaultErrorHandler = async (err, req, res, next) => {
|
|
|
62
62
|
}));
|
|
63
63
|
};
|
|
64
64
|
//#endregion
|
|
65
|
-
//#region ../http/dist/redirect-
|
|
65
|
+
//#region ../http/dist/redirect-CFGcSkzk.js
|
|
66
66
|
const unwrapRequestSource = (source) => {
|
|
67
|
+
if (source.original) return unwrapRequestSource(source.original);
|
|
67
68
|
if (source.headers) return source;
|
|
68
69
|
if (source.req) return source.req;
|
|
69
70
|
if (source.request) return source.request;
|
|
@@ -115,22 +116,48 @@ var Request$1$1 = class Request$1$2 extends Request$1 {
|
|
|
115
116
|
headers;
|
|
116
117
|
ip;
|
|
117
118
|
source;
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
119
|
+
currentUser;
|
|
120
|
+
currentAuth;
|
|
121
|
+
currentAuthUser;
|
|
122
|
+
currentAuthToken;
|
|
123
|
+
get user() {
|
|
124
|
+
return this.getSourceRequest()?.user ?? this.currentUser;
|
|
125
|
+
}
|
|
126
|
+
set user(user) {
|
|
127
|
+
this.currentUser = user;
|
|
128
|
+
}
|
|
129
|
+
get auth() {
|
|
130
|
+
return this.getSourceRequest()?.auth ?? this.currentAuth;
|
|
131
|
+
}
|
|
132
|
+
set auth(auth) {
|
|
133
|
+
this.currentAuth = auth;
|
|
134
|
+
}
|
|
135
|
+
get authUser() {
|
|
136
|
+
return this.getSourceRequest()?.authUser ?? this.currentAuthUser;
|
|
137
|
+
}
|
|
138
|
+
set authUser(user) {
|
|
139
|
+
this.currentAuthUser = user;
|
|
140
|
+
}
|
|
141
|
+
get authToken() {
|
|
142
|
+
return this.getSourceRequest()?.authToken ?? this.currentAuthToken;
|
|
143
|
+
}
|
|
144
|
+
set authToken(token) {
|
|
145
|
+
this.currentAuthToken = token;
|
|
146
|
+
}
|
|
122
147
|
constructor(options = {}) {
|
|
123
148
|
super(options);
|
|
149
|
+
const source = options.source ?? options.original;
|
|
150
|
+
const sourceRequest = isRecord(source) ? source : void 0;
|
|
124
151
|
this.headers = normalizeHeaders(options.headers);
|
|
125
152
|
if (this.method) this.method = options.method;
|
|
126
153
|
if (this.url) this.url = options.url;
|
|
127
154
|
if (this.path) this.path = options.path;
|
|
128
|
-
this.ip = options.ip ?? null;
|
|
129
|
-
this.user = options.user;
|
|
130
|
-
this.auth = options.auth;
|
|
131
|
-
this.authUser = options.authUser;
|
|
132
|
-
this.authToken = options.authToken;
|
|
133
|
-
this.source =
|
|
155
|
+
this.ip = options.ip ?? sourceRequest?.ip ?? null;
|
|
156
|
+
this.user = options.user ?? sourceRequest?.user;
|
|
157
|
+
this.auth = options.auth ?? sourceRequest?.auth;
|
|
158
|
+
this.authUser = options.authUser ?? sourceRequest?.authUser;
|
|
159
|
+
this.authToken = options.authToken ?? sourceRequest?.authToken;
|
|
160
|
+
this.source = source;
|
|
134
161
|
globalThis.request = (key) => key ? this.input(key) : this;
|
|
135
162
|
}
|
|
136
163
|
static from(source) {
|
|
@@ -147,7 +174,7 @@ var Request$1$1 = class Request$1$2 extends Request$1 {
|
|
|
147
174
|
auth: request.auth,
|
|
148
175
|
authUser: request.authUser,
|
|
149
176
|
authToken: request.authToken,
|
|
150
|
-
source
|
|
177
|
+
source: request
|
|
151
178
|
});
|
|
152
179
|
}
|
|
153
180
|
header(name) {
|
|
@@ -175,6 +202,18 @@ var Request$1$1 = class Request$1$2 extends Request$1 {
|
|
|
175
202
|
}
|
|
176
203
|
return this;
|
|
177
204
|
}
|
|
205
|
+
syncFromSource() {
|
|
206
|
+
if (!isRecord(this.source)) return this;
|
|
207
|
+
const source = this.source;
|
|
208
|
+
this.user = source.user ?? this.user;
|
|
209
|
+
this.auth = source.auth ?? this.auth;
|
|
210
|
+
this.authUser = source.authUser ?? this.authUser;
|
|
211
|
+
this.authToken = source.authToken ?? this.authToken;
|
|
212
|
+
return this;
|
|
213
|
+
}
|
|
214
|
+
getSourceRequest() {
|
|
215
|
+
return isRecord(this.source) ? this.source : void 0;
|
|
216
|
+
}
|
|
178
217
|
clearAuthentication() {
|
|
179
218
|
this.auth = void 0;
|
|
180
219
|
this.authUser = void 0;
|
|
@@ -1208,7 +1247,7 @@ definePlugin({
|
|
|
1208
1247
|
return session;
|
|
1209
1248
|
});
|
|
1210
1249
|
bind(Request$1$1, ({ request, ctx }) => {
|
|
1211
|
-
return request instanceof Request$1$1 ? request : Request$1$1.from(request ?? ctx);
|
|
1250
|
+
return (request instanceof Request$1$1 ? request : Request$1$1.from(request ?? ctx)).syncFromSource();
|
|
1212
1251
|
});
|
|
1213
1252
|
useHttpContext((context) => {
|
|
1214
1253
|
const session = getSession(context.ctx);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arkstack/driver-express",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.21",
|
|
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.48",
|
|
44
44
|
"resora": "^1.3.16",
|
|
45
|
-
"@arkstack/contract": "^0.12.
|
|
45
|
+
"@arkstack/contract": "^0.12.21"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"express": "^5.2.1",
|
|
49
|
-
"@arkstack/
|
|
50
|
-
"@arkstack/
|
|
51
|
-
"@arkstack/
|
|
49
|
+
"@arkstack/auth": "^0.12.21",
|
|
50
|
+
"@arkstack/common": "^0.12.21",
|
|
51
|
+
"@arkstack/foundry": "^0.12.21"
|
|
52
52
|
},
|
|
53
53
|
"peerDependenciesMeta": {
|
|
54
54
|
"@arkstack/auth": {
|