@arkstack/driver-h3 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
|
@@ -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,22 +119,48 @@ var Request$1 = class Request$1 extends Request {
|
|
|
118
119
|
headers;
|
|
119
120
|
ip;
|
|
120
121
|
source;
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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
|
+
}
|
|
125
150
|
constructor(options = {}) {
|
|
126
151
|
super(options);
|
|
152
|
+
const source = options.source ?? options.original;
|
|
153
|
+
const sourceRequest = isRecord(source) ? source : void 0;
|
|
127
154
|
this.headers = normalizeHeaders(options.headers);
|
|
128
155
|
if (this.method) this.method = options.method;
|
|
129
156
|
if (this.url) this.url = options.url;
|
|
130
157
|
if (this.path) this.path = options.path;
|
|
131
|
-
this.ip = options.ip ?? null;
|
|
132
|
-
this.user = options.user;
|
|
133
|
-
this.auth = options.auth;
|
|
134
|
-
this.authUser = options.authUser;
|
|
135
|
-
this.authToken = options.authToken;
|
|
136
|
-
this.source =
|
|
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;
|
|
137
164
|
globalThis.request = (key) => key ? this.input(key) : this;
|
|
138
165
|
}
|
|
139
166
|
static from(source) {
|
|
@@ -150,7 +177,7 @@ var Request$1 = class Request$1 extends Request {
|
|
|
150
177
|
auth: request.auth,
|
|
151
178
|
authUser: request.authUser,
|
|
152
179
|
authToken: request.authToken,
|
|
153
|
-
source
|
|
180
|
+
source: request
|
|
154
181
|
});
|
|
155
182
|
}
|
|
156
183
|
header(name) {
|
|
@@ -178,6 +205,18 @@ var Request$1 = class Request$1 extends Request {
|
|
|
178
205
|
}
|
|
179
206
|
return this;
|
|
180
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
|
+
}
|
|
181
220
|
clearAuthentication() {
|
|
182
221
|
this.auth = void 0;
|
|
183
222
|
this.authUser = void 0;
|
|
@@ -1211,7 +1250,7 @@ definePlugin({
|
|
|
1211
1250
|
return session;
|
|
1212
1251
|
});
|
|
1213
1252
|
bind(Request$1, ({ request, ctx }) => {
|
|
1214
|
-
return request instanceof Request$1 ? request : Request$1.from(request ?? ctx);
|
|
1253
|
+
return (request instanceof Request$1 ? request : Request$1.from(request ?? ctx)).syncFromSource();
|
|
1215
1254
|
});
|
|
1216
1255
|
useHttpContext((context) => {
|
|
1217
1256
|
const session = getSession(context.ctx);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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",
|
|
@@ -40,13 +40,13 @@
|
|
|
40
40
|
"clear-router": "^2.8.6",
|
|
41
41
|
"@resora/plugin-clear-router": "^1.0.48",
|
|
42
42
|
"resora": "^1.3.16",
|
|
43
|
-
"@arkstack/contract": "^0.12.
|
|
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/
|
|
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": {
|