@webda/core 2.0.1 → 2.1.2
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/lib/application.spec.js.map +1 -1
- package/lib/core.d.ts +28 -3
- package/lib/core.js +36 -7
- package/lib/core.js.map +1 -1
- package/lib/core.spec.js +2 -0
- package/lib/core.spec.js.map +1 -1
- package/lib/models/aclmodel.d.ts +7 -7
- package/lib/models/aclmodel.js +1 -1
- package/lib/models/aclmodel.js.map +1 -1
- package/lib/models/aclmodel.spec.js.map +1 -1
- package/lib/models/coremodel.d.ts +3 -3
- package/lib/models/coremodel.js +8 -3
- package/lib/models/coremodel.js.map +1 -1
- package/lib/models/coremodel.spec.js.map +1 -1
- package/lib/models/ident.d.ts +3 -0
- package/lib/models/ident.js.map +1 -1
- package/lib/models/ownermodel.spec.js.map +1 -1
- package/lib/models/rolemodel.spec.js.map +1 -1
- package/lib/models/user.d.ts +1 -0
- package/lib/models/user.js +1 -0
- package/lib/models/user.js.map +1 -1
- package/lib/queues/filequeue.spec.js.map +1 -1
- package/lib/queues/memoryqueue.spec.js.map +1 -1
- package/lib/router.spec.js.map +1 -1
- package/lib/services/asyncevents.spec.js.map +1 -1
- package/lib/services/authentication.js.map +1 -1
- package/lib/services/authentication.spec.js.map +1 -1
- package/lib/services/binary.spec.js.map +1 -1
- package/lib/services/cloudbinary.spec.js.map +1 -1
- package/lib/services/configuration.spec.js.map +1 -1
- package/lib/services/cryptoservice.js.map +1 -1
- package/lib/services/cryptoservice.spec.js.map +1 -1
- package/lib/services/debugmailer.spec.js.map +1 -1
- package/lib/services/echo.spec.js.map +1 -1
- package/lib/services/filebinary.spec.js.map +1 -1
- package/lib/services/fileconfiguration.spec.js.map +1 -1
- package/lib/services/invitationservice.spec.js.map +1 -1
- package/lib/services/kubernetesconfiguration.spec.js.map +1 -1
- package/lib/services/mailer.spec.js.map +1 -1
- package/lib/services/notificationservice.spec.js.map +1 -1
- package/lib/services/oauth.spec.js.map +1 -1
- package/lib/services/proxy.js.map +1 -1
- package/lib/services/proxy.spec.js.map +1 -1
- package/lib/services/resource.spec.js.map +1 -1
- package/lib/services/service.d.ts +16 -1
- package/lib/services/service.js +47 -0
- package/lib/services/service.js.map +1 -1
- package/lib/services/service.spec.js +28 -1
- package/lib/services/service.spec.js.map +1 -1
- package/lib/services/version.spec.js.map +1 -1
- package/lib/stores/file.spec.js +8 -4
- package/lib/stores/file.spec.js.map +1 -1
- package/lib/stores/mapper.spec.js.map +1 -1
- package/lib/stores/memory.js +1 -2
- package/lib/stores/memory.js.map +1 -1
- package/lib/stores/memory.spec.js.map +1 -1
- package/lib/stores/store.d.ts +1 -0
- package/lib/stores/store.js +14 -3
- package/lib/stores/store.js.map +1 -1
- package/lib/stores/store.spec.js +5 -0
- package/lib/stores/store.spec.js.map +1 -1
- package/lib/test.js.map +1 -1
- package/lib/unpackedapplication.js +5 -1
- package/lib/unpackedapplication.js.map +1 -1
- package/lib/utils/context.d.ts +177 -79
- package/lib/utils/context.js +263 -133
- package/lib/utils/context.js.map +1 -1
- package/lib/utils/context.spec.js +20 -2
- package/lib/utils/context.spec.js.map +1 -1
- package/lib/utils/cookie.spec.js.map +1 -1
- package/lib/utils/httpcontext.spec.js.map +1 -1
- package/lib/utils/serializers.spec.js +1 -1
- package/lib/utils/serializers.spec.js.map +1 -1
- package/lib/utils/session.spec.js.map +1 -1
- package/lib/utils/waiter.spec.js.map +1 -1
- package/package.json +6 -6
- package/webda.module.json +145 -0
package/lib/utils/context.js
CHANGED
|
@@ -10,46 +10,204 @@ import { JSONUtils } from "./serializers.js";
|
|
|
10
10
|
class Cookie {
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
14
|
-
* @WebdaModel
|
|
13
|
+
* OperationContext is used when call to an operation
|
|
15
14
|
*/
|
|
16
|
-
export class
|
|
15
|
+
export class OperationContext extends EventEmitter {
|
|
17
16
|
/**
|
|
18
17
|
* @ignore
|
|
19
18
|
* Used by Webda framework to set the body, session and output stream if known
|
|
20
19
|
*/
|
|
21
|
-
constructor(webda,
|
|
20
|
+
constructor(webda, stream = undefined) {
|
|
22
21
|
super();
|
|
23
|
-
this._ended = undefined;
|
|
24
|
-
this.parameters = undefined;
|
|
25
|
-
this._pathParams = {};
|
|
26
|
-
this._serviceParams = {};
|
|
27
22
|
this.global = false;
|
|
28
|
-
this.extensions = {
|
|
29
|
-
http: httpContext
|
|
30
|
-
};
|
|
23
|
+
this.extensions = {};
|
|
31
24
|
this._webda = webda;
|
|
32
25
|
this._promises = [];
|
|
33
|
-
this._outputHeaders = new Map();
|
|
34
|
-
this.headersFlushed = false;
|
|
35
26
|
this._body = undefined;
|
|
36
|
-
this.statusCode = 204;
|
|
37
27
|
this._stream = stream;
|
|
38
|
-
this.parameters = {};
|
|
39
|
-
this.headers = new Map();
|
|
40
28
|
if (stream === undefined) {
|
|
41
29
|
this.createStream();
|
|
42
30
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Get an extension of the context
|
|
34
|
+
* @param name of the extension
|
|
35
|
+
* @returns extension object
|
|
36
|
+
*/
|
|
37
|
+
getExtension(name) {
|
|
38
|
+
return this.extensions[name];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
*
|
|
42
|
+
* @param name to add
|
|
43
|
+
* @param extension object to store
|
|
44
|
+
*/
|
|
45
|
+
setExtension(name, extension) {
|
|
46
|
+
this.extensions[name] = extension;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Return the webda
|
|
50
|
+
*/
|
|
51
|
+
getWebda() {
|
|
52
|
+
return this._webda;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Register a promise with the context
|
|
56
|
+
* @param promise
|
|
57
|
+
*/
|
|
58
|
+
addAsyncRequest(promise) {
|
|
59
|
+
this._promises.push(promise);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get output as string, if a OutputStream is provided it will returned null
|
|
63
|
+
* @returns
|
|
64
|
+
*/
|
|
65
|
+
getOutput() {
|
|
66
|
+
if (this._stream instanceof WritableStreamBuffer && this._stream.size()) {
|
|
67
|
+
return this._stream.getContents().toString();
|
|
68
|
+
}
|
|
69
|
+
return this._body;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Ensure the whole execution is finished
|
|
73
|
+
*/
|
|
74
|
+
async end() {
|
|
75
|
+
this.emit("end");
|
|
76
|
+
await Promise.all(this._promises);
|
|
77
|
+
this.emit("close");
|
|
78
|
+
}
|
|
79
|
+
async getInput(sanitizedOptions = {
|
|
80
|
+
allowedTags: [],
|
|
81
|
+
allowedAttributes: {}
|
|
82
|
+
}) {
|
|
83
|
+
if (this._sanitized) {
|
|
84
|
+
return this._sanitized;
|
|
85
|
+
}
|
|
86
|
+
let recursiveSanitize = (obj, options = undefined) => {
|
|
87
|
+
if (typeof obj === "string") {
|
|
88
|
+
return sanitizeHtml(obj, options);
|
|
89
|
+
}
|
|
90
|
+
if (typeof obj === "object") {
|
|
91
|
+
Object.keys(obj).forEach(key => {
|
|
92
|
+
obj[key] = recursiveSanitize(obj[key], options);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
return obj;
|
|
96
|
+
};
|
|
97
|
+
try {
|
|
98
|
+
this._sanitized = recursiveSanitize(JSON.parse(await this.getRawInputAsString(this.getWebda().getGlobalParams().requestLimit, this.getWebda().getGlobalParams().requestTimeout)), sanitizedOptions);
|
|
99
|
+
}
|
|
100
|
+
catch (err) {
|
|
101
|
+
this.log("ERROR", err, `Body: '${await this.getRawInputAsString()}'`);
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
return this._sanitized;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* By default empty
|
|
108
|
+
* @returns
|
|
109
|
+
*/
|
|
110
|
+
async getRawInputAsString(_limit = 1024 * 1024 * 10, _timeout = 60000, _encoding) {
|
|
111
|
+
return "";
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* @override
|
|
115
|
+
*/
|
|
116
|
+
async getRawInput(limit = 1024 * 1024 * 10, timeout = 60000) {
|
|
117
|
+
return Buffer.from("");
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* @override
|
|
121
|
+
*/
|
|
122
|
+
getRawStream() {
|
|
123
|
+
return undefined;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Get the HTTP stream to output raw data
|
|
127
|
+
* @returns {*}
|
|
128
|
+
*/
|
|
129
|
+
getOutputStream() {
|
|
130
|
+
return this._stream;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Get linked session
|
|
134
|
+
* @returns
|
|
135
|
+
*/
|
|
136
|
+
getSession() {
|
|
137
|
+
return this.session;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Remove samitized body
|
|
141
|
+
*/
|
|
142
|
+
reinit() {
|
|
143
|
+
this._sanitized = undefined;
|
|
144
|
+
if (!this._stream || this._stream instanceof WritableStreamBuffer) {
|
|
145
|
+
this.createStream();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Create a buffer stream
|
|
150
|
+
*/
|
|
151
|
+
createStream() {
|
|
152
|
+
this._stream = new WritableStreamBuffer({
|
|
153
|
+
initialSize: 100 * 1024,
|
|
154
|
+
incrementAmount: 100 * 1024
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Proxy for simplification
|
|
159
|
+
* @param level
|
|
160
|
+
* @param args
|
|
161
|
+
*/
|
|
162
|
+
log(level, ...args) {
|
|
163
|
+
this._webda.log(level, ...args);
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Create a new session
|
|
167
|
+
* @returns
|
|
168
|
+
*/
|
|
169
|
+
newSession() {
|
|
170
|
+
this.session = new (this._webda.getModel(this._webda.parameter("sessionModel") || "Webda/Session"))(this);
|
|
171
|
+
return this.session;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Remove everything that was about to be sent
|
|
175
|
+
*/
|
|
176
|
+
resetResponse() {
|
|
177
|
+
this._body = undefined;
|
|
178
|
+
if (this._stream instanceof WritableStreamBuffer) {
|
|
179
|
+
this.createStream();
|
|
46
180
|
}
|
|
47
181
|
}
|
|
182
|
+
/**
|
|
183
|
+
* Write data to the client
|
|
184
|
+
*
|
|
185
|
+
* @param output If it is an object it will be serializeb with toPublicJSON, if it is a String it will be appended to the result, if it is a buffer it will replace the result
|
|
186
|
+
* @param ...args any arguments to pass to the toPublicJSON method
|
|
187
|
+
*/
|
|
188
|
+
write(output, _encoding, _cb) {
|
|
189
|
+
if (!output) {
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
if (typeof output === "object" && !(output instanceof Buffer)) {
|
|
193
|
+
this._body = JSONUtils.stringify(output, undefined, 0, true);
|
|
194
|
+
}
|
|
195
|
+
else if (typeof output == "string") {
|
|
196
|
+
if (this._body == undefined) {
|
|
197
|
+
this._body = "";
|
|
198
|
+
}
|
|
199
|
+
this._body += output;
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
this._body = output.toString();
|
|
203
|
+
}
|
|
204
|
+
return true;
|
|
205
|
+
}
|
|
48
206
|
/**
|
|
49
207
|
* Get Global Context
|
|
50
208
|
*/
|
|
51
209
|
static getGlobalContext() {
|
|
52
|
-
return
|
|
210
|
+
return OperationContext.__globalContext;
|
|
53
211
|
}
|
|
54
212
|
/**
|
|
55
213
|
* Set the Global Context
|
|
@@ -58,7 +216,7 @@ export class Context extends EventEmitter {
|
|
|
58
216
|
*/
|
|
59
217
|
static setGlobalContext(ctx) {
|
|
60
218
|
ctx.global = true;
|
|
61
|
-
|
|
219
|
+
OperationContext.__globalContext = ctx;
|
|
62
220
|
}
|
|
63
221
|
/**
|
|
64
222
|
* Return if context is global
|
|
@@ -66,6 +224,59 @@ export class Context extends EventEmitter {
|
|
|
66
224
|
isGlobal() {
|
|
67
225
|
return this.global;
|
|
68
226
|
}
|
|
227
|
+
async init() {
|
|
228
|
+
return this;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Get the current user from session
|
|
232
|
+
*/
|
|
233
|
+
async getCurrentUser(refresh = false) {
|
|
234
|
+
if (!this.getCurrentUserId()) {
|
|
235
|
+
return undefined;
|
|
236
|
+
}
|
|
237
|
+
// Caching the answer
|
|
238
|
+
if (!this.user || refresh) {
|
|
239
|
+
this.user = await this._webda.getService("Users").get(this.getCurrentUserId());
|
|
240
|
+
}
|
|
241
|
+
return this.user;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Get the current user id from session
|
|
245
|
+
*/
|
|
246
|
+
getCurrentUserId() {
|
|
247
|
+
return undefined;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* This represent in fact a WebContext
|
|
252
|
+
* In 3.0 an abstract version of Context will replace this (closer to OperationContext)
|
|
253
|
+
* @category CoreFeatures
|
|
254
|
+
* @WebdaModel
|
|
255
|
+
*
|
|
256
|
+
* @deprecated use WebContext instead - will be removed in 3.0
|
|
257
|
+
*/
|
|
258
|
+
export class Context extends OperationContext {
|
|
259
|
+
/**
|
|
260
|
+
* @ignore
|
|
261
|
+
* Used by Webda framework to set the body, session and output stream if known
|
|
262
|
+
*/
|
|
263
|
+
constructor(webda, httpContext, stream = undefined) {
|
|
264
|
+
super(webda, stream);
|
|
265
|
+
this._ended = undefined;
|
|
266
|
+
this.parameters = undefined;
|
|
267
|
+
this._pathParams = {};
|
|
268
|
+
this._serviceParams = {};
|
|
269
|
+
this.setHttpContext(httpContext);
|
|
270
|
+
this._outputHeaders = new Map();
|
|
271
|
+
this.headersFlushed = false;
|
|
272
|
+
this.statusCode = 204;
|
|
273
|
+
this.parameters = {};
|
|
274
|
+
this.headers = new Map();
|
|
275
|
+
this.processParameters();
|
|
276
|
+
if (httpContext) {
|
|
277
|
+
this.session = this.newSession();
|
|
278
|
+
}
|
|
279
|
+
}
|
|
69
280
|
/**
|
|
70
281
|
* Set current http context
|
|
71
282
|
* @param httpContext current http context
|
|
@@ -74,13 +285,6 @@ export class Context extends EventEmitter {
|
|
|
74
285
|
this.extensions["http"] = httpContext;
|
|
75
286
|
this.reinit();
|
|
76
287
|
}
|
|
77
|
-
/**
|
|
78
|
-
* Remove samitized body
|
|
79
|
-
*/
|
|
80
|
-
reinit() {
|
|
81
|
-
this._sanitized = undefined;
|
|
82
|
-
this.createStream();
|
|
83
|
-
}
|
|
84
288
|
/**
|
|
85
289
|
* Get current http context
|
|
86
290
|
*/
|
|
@@ -88,20 +292,22 @@ export class Context extends EventEmitter {
|
|
|
88
292
|
return this.getExtension("http");
|
|
89
293
|
}
|
|
90
294
|
/**
|
|
91
|
-
*
|
|
92
|
-
* @param name of the extension
|
|
93
|
-
* @returns extension object
|
|
295
|
+
* @override
|
|
94
296
|
*/
|
|
95
|
-
|
|
96
|
-
return this.
|
|
297
|
+
async getRawInputAsString(limit = 1024 * 1024 * 10, timeout = 60000, encoding) {
|
|
298
|
+
return this.getHttpContext().getRawBodyAsString(limit, timeout, encoding);
|
|
97
299
|
}
|
|
98
300
|
/**
|
|
99
|
-
*
|
|
100
|
-
* @param name to add
|
|
101
|
-
* @param extension object to store
|
|
301
|
+
* @override
|
|
102
302
|
*/
|
|
103
|
-
|
|
104
|
-
this.
|
|
303
|
+
async getRawInput(limit = 1024 * 1024 * 10, timeout = 60000) {
|
|
304
|
+
return this.getHttpContext().getRawBody(limit, timeout);
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* @override
|
|
308
|
+
*/
|
|
309
|
+
getRawStream() {
|
|
310
|
+
return this.getHttpContext().getRawStream();
|
|
105
311
|
}
|
|
106
312
|
/**
|
|
107
313
|
* Get output headers
|
|
@@ -122,13 +328,6 @@ export class Context extends EventEmitter {
|
|
|
122
328
|
this.parameters = Object.assign({}, this._serviceParams);
|
|
123
329
|
this.parameters = Object.assign(this.parameters, this._pathParams);
|
|
124
330
|
}
|
|
125
|
-
/**
|
|
126
|
-
* Get linked session
|
|
127
|
-
* @returns
|
|
128
|
-
*/
|
|
129
|
-
getSession() {
|
|
130
|
-
return this.session;
|
|
131
|
-
}
|
|
132
331
|
getServiceParameters() {
|
|
133
332
|
return this._serviceParams;
|
|
134
333
|
}
|
|
@@ -147,11 +346,8 @@ export class Context extends EventEmitter {
|
|
|
147
346
|
* Remove everything that was about to be sent
|
|
148
347
|
*/
|
|
149
348
|
resetResponse() {
|
|
150
|
-
this._body = undefined;
|
|
151
349
|
this._outputHeaders.clear();
|
|
152
|
-
|
|
153
|
-
this.createStream();
|
|
154
|
-
}
|
|
350
|
+
super.resetResponse();
|
|
155
351
|
}
|
|
156
352
|
/**
|
|
157
353
|
* Write data to the client
|
|
@@ -160,25 +356,14 @@ export class Context extends EventEmitter {
|
|
|
160
356
|
* @param ...args any arguments to pass to the toPublicJSON method
|
|
161
357
|
*/
|
|
162
358
|
// @ts-ignore
|
|
163
|
-
write(output,
|
|
359
|
+
write(output, encoding, cb) {
|
|
164
360
|
if (this.statusCode === 204) {
|
|
165
361
|
this.statusCode = 200;
|
|
166
362
|
}
|
|
167
363
|
if (typeof output === "object" && !(output instanceof Buffer)) {
|
|
168
364
|
this.setHeader("Content-type", "application/json");
|
|
169
|
-
this._body = JSONUtils.stringify(output, undefined, 0, true);
|
|
170
|
-
return true;
|
|
171
|
-
}
|
|
172
|
-
else if (typeof output == "string") {
|
|
173
|
-
if (this._body == undefined) {
|
|
174
|
-
this._body = "";
|
|
175
|
-
}
|
|
176
|
-
this._body += output;
|
|
177
|
-
return true;
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
180
|
-
this._body = output;
|
|
181
365
|
}
|
|
366
|
+
return super.write(output, encoding, cb);
|
|
182
367
|
}
|
|
183
368
|
/**
|
|
184
369
|
* Set a header value
|
|
@@ -226,9 +411,6 @@ export class Context extends EventEmitter {
|
|
|
226
411
|
getResponseCookies() {
|
|
227
412
|
return this._cookie;
|
|
228
413
|
}
|
|
229
|
-
addAsyncRequest(promise) {
|
|
230
|
-
this._promises.push(promise);
|
|
231
|
-
}
|
|
232
414
|
isEnded() {
|
|
233
415
|
return this._ended;
|
|
234
416
|
}
|
|
@@ -238,7 +420,7 @@ export class Context extends EventEmitter {
|
|
|
238
420
|
*
|
|
239
421
|
******************************/
|
|
240
422
|
/**
|
|
241
|
-
* Express response allow statusCode to be defined this
|
|
423
|
+
* Express response allow statusCode to be defined this way
|
|
242
424
|
* @param code to return
|
|
243
425
|
*/
|
|
244
426
|
status(code) {
|
|
@@ -246,7 +428,7 @@ export class Context extends EventEmitter {
|
|
|
246
428
|
return this;
|
|
247
429
|
}
|
|
248
430
|
/**
|
|
249
|
-
* Express response allow answer to be sent this
|
|
431
|
+
* Express response allow answer to be sent this way
|
|
250
432
|
* @param code to return
|
|
251
433
|
*/
|
|
252
434
|
json(obj) {
|
|
@@ -271,7 +453,7 @@ export class Context extends EventEmitter {
|
|
|
271
453
|
}
|
|
272
454
|
await Promise.all(this._promises);
|
|
273
455
|
if (this._stream instanceof WritableStreamBuffer && this._stream.size()) {
|
|
274
|
-
this._body = this._stream.getContents();
|
|
456
|
+
this._body = this._stream.getContents().toString();
|
|
275
457
|
this.statusCode = 200;
|
|
276
458
|
}
|
|
277
459
|
if (!this.headersFlushed) {
|
|
@@ -283,32 +465,16 @@ export class Context extends EventEmitter {
|
|
|
283
465
|
});
|
|
284
466
|
return this._ended;
|
|
285
467
|
}
|
|
468
|
+
/**
|
|
469
|
+
* Alias to keep compatibility with WebContext
|
|
470
|
+
* @param sanitizedOptions
|
|
471
|
+
* @returns
|
|
472
|
+
*/
|
|
286
473
|
async getRequestBody(sanitizedOptions = {
|
|
287
474
|
allowedTags: [],
|
|
288
475
|
allowedAttributes: {}
|
|
289
476
|
}) {
|
|
290
|
-
|
|
291
|
-
return this._sanitized;
|
|
292
|
-
}
|
|
293
|
-
let recursiveSanitize = (obj, options = undefined) => {
|
|
294
|
-
if (typeof obj === "string") {
|
|
295
|
-
return sanitizeHtml(obj, options);
|
|
296
|
-
}
|
|
297
|
-
if (typeof obj === "object") {
|
|
298
|
-
Object.keys(obj).forEach(key => {
|
|
299
|
-
obj[key] = recursiveSanitize(obj[key], options);
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
return obj;
|
|
303
|
-
};
|
|
304
|
-
try {
|
|
305
|
-
this._sanitized = recursiveSanitize(JSON.parse(await this.getHttpContext().getRawBodyAsString(this.getWebda().getGlobalParams().requestLimit, this.getWebda().getGlobalParams().requestTimeout)), sanitizedOptions);
|
|
306
|
-
}
|
|
307
|
-
catch (err) {
|
|
308
|
-
this.log("ERROR", err, `Body: '${await this.getHttpContext().getRawBodyAsString()}'`);
|
|
309
|
-
return undefined;
|
|
310
|
-
}
|
|
311
|
-
return this._sanitized;
|
|
477
|
+
return this.getInput(sanitizedOptions);
|
|
312
478
|
}
|
|
313
479
|
/**
|
|
314
480
|
* Get request body
|
|
@@ -361,20 +527,7 @@ export class Context extends EventEmitter {
|
|
|
361
527
|
* @returns {*}
|
|
362
528
|
*/
|
|
363
529
|
getStream() {
|
|
364
|
-
return this.
|
|
365
|
-
}
|
|
366
|
-
/**
|
|
367
|
-
* Get the current user from session
|
|
368
|
-
*/
|
|
369
|
-
async getCurrentUser(refresh = false) {
|
|
370
|
-
if (!this.getCurrentUserId()) {
|
|
371
|
-
return undefined;
|
|
372
|
-
}
|
|
373
|
-
// Caching the answer
|
|
374
|
-
if (!this.user || refresh) {
|
|
375
|
-
this.user = await this._webda.getService("Users").get(this.getCurrentUserId());
|
|
376
|
-
}
|
|
377
|
-
return this.user;
|
|
530
|
+
return this.getOutputStream();
|
|
378
531
|
}
|
|
379
532
|
/**
|
|
380
533
|
* Get the current user id from session
|
|
@@ -400,12 +553,6 @@ export class Context extends EventEmitter {
|
|
|
400
553
|
}
|
|
401
554
|
return Promise.reject(Error("Not implemented"));
|
|
402
555
|
}
|
|
403
|
-
/**
|
|
404
|
-
* Return the webda
|
|
405
|
-
*/
|
|
406
|
-
getWebda() {
|
|
407
|
-
return this._webda;
|
|
408
|
-
}
|
|
409
556
|
/**
|
|
410
557
|
* Get the request locale if found
|
|
411
558
|
*/
|
|
@@ -442,14 +589,6 @@ export class Context extends EventEmitter {
|
|
|
442
589
|
logIn() {
|
|
443
590
|
// Empty for compatibility
|
|
444
591
|
}
|
|
445
|
-
/**
|
|
446
|
-
* Proxy for simplification
|
|
447
|
-
* @param level
|
|
448
|
-
* @param args
|
|
449
|
-
*/
|
|
450
|
-
log(level, ...args) {
|
|
451
|
-
this._webda.log(level, ...args);
|
|
452
|
-
}
|
|
453
592
|
/**
|
|
454
593
|
* Return true if Headers got flushed already
|
|
455
594
|
* @returns
|
|
@@ -464,20 +603,6 @@ export class Context extends EventEmitter {
|
|
|
464
603
|
setFlushedHeaders(status = true) {
|
|
465
604
|
this.headersFlushed = status;
|
|
466
605
|
}
|
|
467
|
-
createStream() {
|
|
468
|
-
this._stream = new WritableStreamBuffer({
|
|
469
|
-
initialSize: 100 * 1024,
|
|
470
|
-
incrementAmount: 100 * 1024
|
|
471
|
-
});
|
|
472
|
-
}
|
|
473
|
-
/**
|
|
474
|
-
* Create a new session
|
|
475
|
-
* @returns
|
|
476
|
-
*/
|
|
477
|
-
newSession() {
|
|
478
|
-
this.session = new (this._webda.getModel(this._webda.parameter("sessionModel") || "Webda/Session"))(this);
|
|
479
|
-
return this.session;
|
|
480
|
-
}
|
|
481
606
|
async init() {
|
|
482
607
|
this._stream.on("pipe", () => {
|
|
483
608
|
this._webda.flushHeaders(this);
|
|
@@ -486,10 +611,15 @@ export class Context extends EventEmitter {
|
|
|
486
611
|
if (this.getExtension("http")) {
|
|
487
612
|
this.session = (await this._webda.getService("SessionManager").load(this)).getProxy();
|
|
488
613
|
}
|
|
489
|
-
return
|
|
614
|
+
return super.init();
|
|
490
615
|
}
|
|
491
616
|
emitError(err) {
|
|
492
617
|
this.emit("error", err);
|
|
493
618
|
}
|
|
494
619
|
}
|
|
620
|
+
/**
|
|
621
|
+
* Replacement for Context
|
|
622
|
+
*/
|
|
623
|
+
export class WebContext extends Context {
|
|
624
|
+
}
|
|
495
625
|
//# sourceMappingURL=context.js.map
|
package/lib/utils/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/utils/context.ts"],"names":[],"mappings":"AACA,OAAO,cAAc,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,YAAY,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAY,MAAM,QAAQ,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAOtD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C;;GAEG;AACH,MAAM,MAAM;CAIX;AAED;;;GAGG;AACH,MAAM,OAAO,OAA0B,SAAQ,YAAY;IA8gBzD;;;OAGG;IACH,YAAY,KAAW,EAAE,WAAwB,EAAE,SAAmB,SAAS;QAC7E,KAAK,EAAE,CAAC;QA3fV,WAAM,GAAiB,SAAS,CAAC;QAevB,eAAU,GAAQ,SAAS,CAAC;QAC5B,gBAAW,GAAQ,EAAE,CAAC;QACtB,mBAAc,GAAQ,EAAE,CAAC;QAE3B,WAAM,GAAY,KAAK,CAAC;QAye9B,IAAI,CAAC,UAAU,GAAG;YAChB,IAAI,EAAE,WAAW;SAClB,CAAC;QACF,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACpB,IAAI,CAAC,cAAc,GAAG,IAAI,GAAG,EAAE,CAAC;QAChC,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC;QAC5B,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;QACvB,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC;Q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,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED;;;OAGG;IACH,iBAAiB,CAAC,SAAkB,IAAI;QACtC,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC;IAC/B,CAAC;IAoBD,KAAK,CAAC,IAAI;QACR,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE;YAC3B,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;YAC/B,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC7B,CAAC,CAAC,CAAC;QACH,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE;YAC7B,IAAI,CAAC,OAAO,GAAG,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,CAAiB,gBAAgB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;SACvG;QACD,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC;IACtB,CAAC;IAED,SAAS,CAAC,GAAG;QACX,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAC1B,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,UAA6B,SAAQ,OAAa;CAAG"}
|
|
@@ -8,7 +8,7 @@ import { suite, test } from "@testdeck/mocha";
|
|
|
8
8
|
import * as assert from "assert";
|
|
9
9
|
import { Readable } from "stream";
|
|
10
10
|
import { WebdaTest } from "../test.js";
|
|
11
|
-
import { Context } from "./context.js";
|
|
11
|
+
import { Context, OperationContext, WebContext } from "./context.js";
|
|
12
12
|
import { HttpContext } from "./httpcontext.js";
|
|
13
13
|
let ContextTest = class ContextTest extends WebdaTest {
|
|
14
14
|
async before() {
|
|
@@ -191,7 +191,7 @@ let ContextTest = class ContextTest extends WebdaTest {
|
|
|
191
191
|
this.ctx.setHeader("X-Webda", "HEAD");
|
|
192
192
|
assert.strictEqual(this.ctx.getResponseHeaders()["X-Webda"], "HEAD");
|
|
193
193
|
this.ctx.write(400);
|
|
194
|
-
assert.strictEqual(this.ctx.getResponseBody(), 400);
|
|
194
|
+
assert.strictEqual(this.ctx.getResponseBody(), "400");
|
|
195
195
|
// @ts-ignore
|
|
196
196
|
Object.observe = (obj, callback) => {
|
|
197
197
|
callback([
|
|
@@ -231,6 +231,21 @@ let ContextTest = class ContextTest extends WebdaTest {
|
|
|
231
231
|
this.ctx.getHttpContext().getHeaders()["accept-language"] = "zn-CH,zn;q=0.8,en-US;q=0.6,en;q=0.4,es;q=0.2";
|
|
232
232
|
assert.strictEqual(this.ctx.getLocale(), "en");
|
|
233
233
|
}
|
|
234
|
+
async operationContext() {
|
|
235
|
+
let ctx = new OperationContext(this.webda);
|
|
236
|
+
assert.strictEqual(ctx.getCurrentUserId(), undefined);
|
|
237
|
+
assert.strictEqual(await ctx.getRawInputAsString(), "");
|
|
238
|
+
assert.strictEqual((await ctx.getRawInput()).toString(), "");
|
|
239
|
+
assert.strictEqual(ctx.getRawStream(), undefined);
|
|
240
|
+
ctx.createStream();
|
|
241
|
+
ctx.getOutputStream().write("plop");
|
|
242
|
+
assert.strictEqual(ctx.getOutput(), "plop");
|
|
243
|
+
// cov
|
|
244
|
+
let http = new HttpContext("test.webda.io", "GET", "/");
|
|
245
|
+
ctx = new WebContext(this.webda, http);
|
|
246
|
+
await ctx.getRawInput();
|
|
247
|
+
ctx.getRawStream();
|
|
248
|
+
}
|
|
234
249
|
};
|
|
235
250
|
__decorate([
|
|
236
251
|
test
|
|
@@ -268,6 +283,9 @@ __decorate([
|
|
|
268
283
|
__decorate([
|
|
269
284
|
test
|
|
270
285
|
], ContextTest.prototype, "fallbackLocale", null);
|
|
286
|
+
__decorate([
|
|
287
|
+
test
|
|
288
|
+
], ContextTest.prototype, "operationContext", null);
|
|
271
289
|
ContextTest = __decorate([
|
|
272
290
|
suite
|
|
273
291
|
], ContextTest);
|