@arkstack/driver-h3 0.12.19 → 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 +81 -8
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -65,8 +65,9 @@ const defaultErrorHandler = async (err, event) => {
|
|
|
65
65
|
});
|
|
66
66
|
};
|
|
67
67
|
//#endregion
|
|
68
|
-
//#region ../http/dist/redirect-
|
|
68
|
+
//#region ../http/dist/redirect-CFGcSkzk.js
|
|
69
69
|
const unwrapRequestSource = (source) => {
|
|
70
|
+
if (source.original) return unwrapRequestSource(source.original);
|
|
70
71
|
if (source.headers) return source;
|
|
71
72
|
if (source.req) return source.req;
|
|
72
73
|
if (source.request) return source.request;
|
|
@@ -118,18 +119,48 @@ var Request$1 = class Request$1 extends Request {
|
|
|
118
119
|
headers;
|
|
119
120
|
ip;
|
|
120
121
|
source;
|
|
121
|
-
|
|
122
|
-
|
|
122
|
+
currentUser;
|
|
123
|
+
currentAuth;
|
|
124
|
+
currentAuthUser;
|
|
125
|
+
currentAuthToken;
|
|
126
|
+
get user() {
|
|
127
|
+
return this.getSourceRequest()?.user ?? this.currentUser;
|
|
128
|
+
}
|
|
129
|
+
set user(user) {
|
|
130
|
+
this.currentUser = user;
|
|
131
|
+
}
|
|
132
|
+
get auth() {
|
|
133
|
+
return this.getSourceRequest()?.auth ?? this.currentAuth;
|
|
134
|
+
}
|
|
135
|
+
set auth(auth) {
|
|
136
|
+
this.currentAuth = auth;
|
|
137
|
+
}
|
|
138
|
+
get authUser() {
|
|
139
|
+
return this.getSourceRequest()?.authUser ?? this.currentAuthUser;
|
|
140
|
+
}
|
|
141
|
+
set authUser(user) {
|
|
142
|
+
this.currentAuthUser = user;
|
|
143
|
+
}
|
|
144
|
+
get authToken() {
|
|
145
|
+
return this.getSourceRequest()?.authToken ?? this.currentAuthToken;
|
|
146
|
+
}
|
|
147
|
+
set authToken(token) {
|
|
148
|
+
this.currentAuthToken = token;
|
|
149
|
+
}
|
|
123
150
|
constructor(options = {}) {
|
|
124
151
|
super(options);
|
|
152
|
+
const source = options.source ?? options.original;
|
|
153
|
+
const sourceRequest = isRecord(source) ? source : void 0;
|
|
125
154
|
this.headers = normalizeHeaders(options.headers);
|
|
126
155
|
if (this.method) this.method = options.method;
|
|
127
156
|
if (this.url) this.url = options.url;
|
|
128
157
|
if (this.path) this.path = options.path;
|
|
129
|
-
this.ip = options.ip ?? null;
|
|
130
|
-
this.user = options.user;
|
|
131
|
-
this.
|
|
132
|
-
this.
|
|
158
|
+
this.ip = options.ip ?? sourceRequest?.ip ?? null;
|
|
159
|
+
this.user = options.user ?? sourceRequest?.user;
|
|
160
|
+
this.auth = options.auth ?? sourceRequest?.auth;
|
|
161
|
+
this.authUser = options.authUser ?? sourceRequest?.authUser;
|
|
162
|
+
this.authToken = options.authToken ?? sourceRequest?.authToken;
|
|
163
|
+
this.source = source;
|
|
133
164
|
globalThis.request = (key) => key ? this.input(key) : this;
|
|
134
165
|
}
|
|
135
166
|
static from(source) {
|
|
@@ -143,8 +174,10 @@ var Request$1 = class Request$1 extends Request {
|
|
|
143
174
|
path: request.path,
|
|
144
175
|
ip: request.ip ?? null,
|
|
145
176
|
user: request.user,
|
|
177
|
+
auth: request.auth,
|
|
178
|
+
authUser: request.authUser,
|
|
146
179
|
authToken: request.authToken,
|
|
147
|
-
source
|
|
180
|
+
source: request
|
|
148
181
|
});
|
|
149
182
|
}
|
|
150
183
|
header(name) {
|
|
@@ -160,6 +193,43 @@ var Request$1 = class Request$1 extends Request {
|
|
|
160
193
|
if (isRecord(this.source)) this.source.user = user;
|
|
161
194
|
return this;
|
|
162
195
|
}
|
|
196
|
+
setAuthentication(auth, user, token) {
|
|
197
|
+
this.auth = auth;
|
|
198
|
+
this.authUser = user;
|
|
199
|
+
this.authToken = token;
|
|
200
|
+
this.setUser(user);
|
|
201
|
+
if (isRecord(this.source)) {
|
|
202
|
+
this.source.auth = auth;
|
|
203
|
+
this.source.authUser = user;
|
|
204
|
+
this.source.authToken = token;
|
|
205
|
+
}
|
|
206
|
+
return this;
|
|
207
|
+
}
|
|
208
|
+
syncFromSource() {
|
|
209
|
+
if (!isRecord(this.source)) return this;
|
|
210
|
+
const source = this.source;
|
|
211
|
+
this.user = source.user ?? this.user;
|
|
212
|
+
this.auth = source.auth ?? this.auth;
|
|
213
|
+
this.authUser = source.authUser ?? this.authUser;
|
|
214
|
+
this.authToken = source.authToken ?? this.authToken;
|
|
215
|
+
return this;
|
|
216
|
+
}
|
|
217
|
+
getSourceRequest() {
|
|
218
|
+
return isRecord(this.source) ? this.source : void 0;
|
|
219
|
+
}
|
|
220
|
+
clearAuthentication() {
|
|
221
|
+
this.auth = void 0;
|
|
222
|
+
this.authUser = void 0;
|
|
223
|
+
this.authToken = void 0;
|
|
224
|
+
this.user = void 0;
|
|
225
|
+
if (isRecord(this.source)) {
|
|
226
|
+
this.source.auth = void 0;
|
|
227
|
+
this.source.authUser = void 0;
|
|
228
|
+
this.source.authToken = void 0;
|
|
229
|
+
this.source.user = void 0;
|
|
230
|
+
}
|
|
231
|
+
return this;
|
|
232
|
+
}
|
|
163
233
|
};
|
|
164
234
|
var FlashBag = class {
|
|
165
235
|
bag = {};
|
|
@@ -1179,6 +1249,9 @@ definePlugin({
|
|
|
1179
1249
|
registerResponseFlashSweep(ctx, session);
|
|
1180
1250
|
return session;
|
|
1181
1251
|
});
|
|
1252
|
+
bind(Request$1, ({ request, ctx }) => {
|
|
1253
|
+
return (request instanceof Request$1 ? request : Request$1.from(request ?? ctx)).syncFromSource();
|
|
1254
|
+
});
|
|
1182
1255
|
useHttpContext((context) => {
|
|
1183
1256
|
const session = getSession(context.ctx);
|
|
1184
1257
|
if (session) {
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arkstack/driver-h3",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.21",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "H3 driver for Arkstack, providing H3-based runtime integration for the framework.",
|
|
6
6
|
"homepage": "https://arkstack.toneflix.net",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/arkstack-
|
|
9
|
+
"url": "git+https://github.com/arkstack-hq/arkstack.git",
|
|
10
10
|
"directory": "packages/driver-h3"
|
|
11
11
|
},
|
|
12
12
|
"keywords": [
|
|
@@ -38,15 +38,15 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"clear-router": "^2.8.6",
|
|
41
|
-
"@resora/plugin-clear-router": "^1.0.
|
|
42
|
-
"resora": "^1.3.
|
|
43
|
-
"@arkstack/contract": "^0.12.
|
|
41
|
+
"@resora/plugin-clear-router": "^1.0.48",
|
|
42
|
+
"resora": "^1.3.16",
|
|
43
|
+
"@arkstack/contract": "^0.12.21"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"h3": "2.0.1-rc.22",
|
|
47
|
-
"@arkstack/
|
|
48
|
-
"@arkstack/
|
|
49
|
-
"@arkstack/auth": "^0.12.
|
|
47
|
+
"@arkstack/foundry": "^0.12.21",
|
|
48
|
+
"@arkstack/common": "^0.12.21",
|
|
49
|
+
"@arkstack/auth": "^0.12.21"
|
|
50
50
|
},
|
|
51
51
|
"peerDependenciesMeta": {
|
|
52
52
|
"@arkstack/auth": {
|