@arkstack/driver-express 0.12.19 → 0.12.20
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 +35 -1
- package/dist/middlewares/index.js +1 -1
- package/package.json +8 -8
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-C1DNCiO9.js
|
|
66
66
|
const unwrapRequestSource = (source) => {
|
|
67
67
|
if (source.headers) return source;
|
|
68
68
|
if (source.req) return source.req;
|
|
@@ -116,6 +116,8 @@ var Request$1$1 = class Request$1$2 extends Request$1 {
|
|
|
116
116
|
ip;
|
|
117
117
|
source;
|
|
118
118
|
user;
|
|
119
|
+
auth;
|
|
120
|
+
authUser;
|
|
119
121
|
authToken;
|
|
120
122
|
constructor(options = {}) {
|
|
121
123
|
super(options);
|
|
@@ -125,6 +127,8 @@ var Request$1$1 = class Request$1$2 extends Request$1 {
|
|
|
125
127
|
if (this.path) this.path = options.path;
|
|
126
128
|
this.ip = options.ip ?? null;
|
|
127
129
|
this.user = options.user;
|
|
130
|
+
this.auth = options.auth;
|
|
131
|
+
this.authUser = options.authUser;
|
|
128
132
|
this.authToken = options.authToken;
|
|
129
133
|
this.source = options.source;
|
|
130
134
|
globalThis.request = (key) => key ? this.input(key) : this;
|
|
@@ -140,6 +144,8 @@ var Request$1$1 = class Request$1$2 extends Request$1 {
|
|
|
140
144
|
path: request.path,
|
|
141
145
|
ip: request.ip ?? null,
|
|
142
146
|
user: request.user,
|
|
147
|
+
auth: request.auth,
|
|
148
|
+
authUser: request.authUser,
|
|
143
149
|
authToken: request.authToken,
|
|
144
150
|
source
|
|
145
151
|
});
|
|
@@ -157,6 +163,31 @@ var Request$1$1 = class Request$1$2 extends Request$1 {
|
|
|
157
163
|
if (isRecord(this.source)) this.source.user = user;
|
|
158
164
|
return this;
|
|
159
165
|
}
|
|
166
|
+
setAuthentication(auth, user, token) {
|
|
167
|
+
this.auth = auth;
|
|
168
|
+
this.authUser = user;
|
|
169
|
+
this.authToken = token;
|
|
170
|
+
this.setUser(user);
|
|
171
|
+
if (isRecord(this.source)) {
|
|
172
|
+
this.source.auth = auth;
|
|
173
|
+
this.source.authUser = user;
|
|
174
|
+
this.source.authToken = token;
|
|
175
|
+
}
|
|
176
|
+
return this;
|
|
177
|
+
}
|
|
178
|
+
clearAuthentication() {
|
|
179
|
+
this.auth = void 0;
|
|
180
|
+
this.authUser = void 0;
|
|
181
|
+
this.authToken = void 0;
|
|
182
|
+
this.user = void 0;
|
|
183
|
+
if (isRecord(this.source)) {
|
|
184
|
+
this.source.auth = void 0;
|
|
185
|
+
this.source.authUser = void 0;
|
|
186
|
+
this.source.authToken = void 0;
|
|
187
|
+
this.source.user = void 0;
|
|
188
|
+
}
|
|
189
|
+
return this;
|
|
190
|
+
}
|
|
160
191
|
};
|
|
161
192
|
var FlashBag = class {
|
|
162
193
|
bag = {};
|
|
@@ -1176,6 +1207,9 @@ definePlugin({
|
|
|
1176
1207
|
registerResponseFlashSweep(ctx, session);
|
|
1177
1208
|
return session;
|
|
1178
1209
|
});
|
|
1210
|
+
bind(Request$1$1, ({ request, ctx }) => {
|
|
1211
|
+
return request instanceof Request$1$1 ? request : Request$1$1.from(request ?? ctx);
|
|
1212
|
+
});
|
|
1179
1213
|
useHttpContext((context) => {
|
|
1180
1214
|
const session = getSession(context.ctx);
|
|
1181
1215
|
if (session) {
|
|
@@ -15,7 +15,7 @@ const auth = async (req, res, next) => {
|
|
|
15
15
|
status: 401
|
|
16
16
|
});
|
|
17
17
|
const auth = Auth.make().setRequest(req);
|
|
18
|
-
const user = await
|
|
18
|
+
const user = await auth.authorizeToken(token);
|
|
19
19
|
req.user = user;
|
|
20
20
|
req.auth = auth;
|
|
21
21
|
req.authUser = user;
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arkstack/driver-express",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.20",
|
|
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",
|
|
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-express"
|
|
11
11
|
},
|
|
12
12
|
"keywords": [
|
|
@@ -40,15 +40,15 @@
|
|
|
40
40
|
"multer": "^2.1.1",
|
|
41
41
|
"clear-router": "^2.8.6",
|
|
42
42
|
"express-rate-limit": "^8.4.1",
|
|
43
|
-
"@resora/plugin-clear-router": "^1.0.
|
|
44
|
-
"resora": "^1.3.
|
|
45
|
-
"@arkstack/contract": "^0.12.
|
|
43
|
+
"@resora/plugin-clear-router": "^1.0.48",
|
|
44
|
+
"resora": "^1.3.16",
|
|
45
|
+
"@arkstack/contract": "^0.12.20"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"express": "^5.2.1",
|
|
49
|
-
"@arkstack/
|
|
50
|
-
"@arkstack/
|
|
51
|
-
"@arkstack/common": "^0.12.
|
|
49
|
+
"@arkstack/foundry": "^0.12.20",
|
|
50
|
+
"@arkstack/auth": "^0.12.20",
|
|
51
|
+
"@arkstack/common": "^0.12.20"
|
|
52
52
|
},
|
|
53
53
|
"peerDependenciesMeta": {
|
|
54
54
|
"@arkstack/auth": {
|