@webda/core 1.2.1 → 1.6.0-beta.0
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.d.ts +3 -0
- package/lib/application.js +26 -22
- package/lib/application.js.map +1 -1
- package/lib/application.spec.js +185 -2
- package/lib/application.spec.js.map +1 -1
- package/lib/core.d.ts +62 -6
- package/lib/core.js +127 -86
- package/lib/core.js.map +1 -1
- package/lib/core.spec.js +151 -6
- package/lib/core.spec.js.map +1 -1
- package/lib/index.d.ts +4 -0
- package/lib/index.js +4 -0
- package/lib/index.js.map +1 -1
- package/lib/models/aclmodel.d.ts +42 -3
- package/lib/models/aclmodel.js +58 -3
- package/lib/models/aclmodel.js.map +1 -1
- package/lib/models/aclmodel.spec.js +46 -0
- package/lib/models/aclmodel.spec.js.map +1 -1
- package/lib/models/coremodel.d.ts +58 -10
- package/lib/models/coremodel.js +39 -32
- package/lib/models/coremodel.js.map +1 -1
- package/lib/models/coremodel.spec.js +68 -6
- package/lib/models/coremodel.spec.js.map +1 -1
- package/lib/models/ident.d.ts +8 -2
- package/lib/models/ident.js.map +1 -1
- package/lib/models/ident.spec.js +16 -0
- package/lib/models/ident.spec.js.map +1 -1
- package/lib/models/ownermodel.d.ts +1 -1
- package/lib/models/ownermodel.js.map +1 -1
- package/lib/models/ownermodel.spec.js +22 -19
- package/lib/models/ownermodel.spec.js.map +1 -1
- package/lib/models/user.d.ts +2 -0
- package/lib/models/user.js +4 -2
- package/lib/models/user.js.map +1 -1
- package/lib/models/user.spec.js +9 -2
- package/lib/models/user.spec.js.map +1 -1
- package/lib/queues/filequeue.d.ts +63 -0
- package/lib/queues/filequeue.js +161 -0
- package/lib/queues/filequeue.js.map +1 -0
- package/lib/queues/filequeue.spec.d.ts +1 -0
- package/lib/queues/filequeue.spec.js +90 -0
- package/lib/queues/filequeue.spec.js.map +1 -0
- package/lib/queues/memoryqueue.d.ts +18 -4
- package/lib/queues/memoryqueue.js +20 -13
- package/lib/queues/memoryqueue.js.map +1 -1
- package/lib/queues/memoryqueue.spec.js +142 -39
- package/lib/queues/memoryqueue.spec.js.map +1 -1
- package/lib/queues/pubsubservice.d.ts +27 -0
- package/lib/queues/pubsubservice.js +21 -0
- package/lib/queues/pubsubservice.js.map +1 -0
- package/lib/queues/queue.spec.js +16 -7
- package/lib/queues/queue.spec.js.map +1 -1
- package/lib/queues/queueservice.d.ts +108 -13
- package/lib/queues/queueservice.js +100 -36
- package/lib/queues/queueservice.js.map +1 -1
- package/lib/router.js +4 -6
- package/lib/router.js.map +1 -1
- package/lib/router.spec.js +27 -2
- package/lib/router.spec.js.map +1 -1
- package/lib/services/asyncevents.d.ts +110 -5
- package/lib/services/asyncevents.js +134 -39
- package/lib/services/asyncevents.js.map +1 -1
- package/lib/services/asyncevents.spec.js +58 -4
- package/lib/services/asyncevents.spec.js.map +1 -1
- package/lib/services/authentication.d.ts +57 -5
- package/lib/services/authentication.js +93 -84
- package/lib/services/authentication.js.map +1 -1
- package/lib/services/authentication.spec.js +118 -82
- package/lib/services/authentication.spec.js.map +1 -1
- package/lib/services/binary.d.ts +175 -48
- package/lib/services/binary.js +205 -170
- package/lib/services/binary.js.map +1 -1
- package/lib/services/binary.spec.d.ts +22 -3
- package/lib/services/binary.spec.js +327 -22
- package/lib/services/binary.spec.js.map +1 -1
- package/lib/services/configuration.d.ts +94 -13
- package/lib/services/configuration.js +98 -28
- package/lib/services/configuration.js.map +1 -1
- package/lib/services/configuration.spec.js +40 -1
- package/lib/services/configuration.spec.js.map +1 -1
- package/lib/services/cron.d.ts +4 -4
- package/lib/services/cron.js +37 -53
- package/lib/services/cron.js.map +1 -1
- package/lib/services/cron.spec.d.ts +1 -0
- package/lib/services/cron.spec.js +76 -0
- package/lib/services/cron.spec.js.map +1 -0
- package/lib/services/debugmailer.spec.js +18 -4
- package/lib/services/debugmailer.spec.js.map +1 -1
- package/lib/services/echo.js +22 -13
- package/lib/services/echo.js.map +1 -1
- package/lib/services/echo.spec.d.ts +1 -0
- package/lib/services/echo.spec.js +52 -0
- package/lib/services/echo.spec.js.map +1 -0
- package/lib/services/filebinary.d.ts +16 -9
- package/lib/services/filebinary.js +58 -73
- package/lib/services/filebinary.js.map +1 -1
- package/lib/services/filebinary.spec.d.ts +8 -1
- package/lib/services/filebinary.spec.js +133 -7
- package/lib/services/filebinary.spec.js.map +1 -1
- package/lib/services/fileconfiguration.d.ts +9 -3
- package/lib/services/fileconfiguration.js +13 -6
- package/lib/services/fileconfiguration.js.map +1 -1
- package/lib/services/fileconfiguration.spec.js +100 -5
- package/lib/services/fileconfiguration.spec.js.map +1 -1
- package/lib/services/kubernetesconfiguration.d.ts +8 -2
- package/lib/services/kubernetesconfiguration.js +16 -5
- package/lib/services/kubernetesconfiguration.js.map +1 -1
- package/lib/services/kubernetesconfiguration.spec.js +53 -16
- package/lib/services/kubernetesconfiguration.spec.js.map +1 -1
- package/lib/services/mailer.d.ts +11 -2
- package/lib/services/mailer.js +28 -34
- package/lib/services/mailer.js.map +1 -1
- package/lib/services/mailer.spec.js +69 -23
- package/lib/services/mailer.spec.js.map +1 -1
- package/lib/services/oauth.d.ts +5 -2
- package/lib/services/oauth.js +22 -8
- package/lib/services/oauth.js.map +1 -1
- package/lib/services/oauth.spec.js +33 -3
- package/lib/services/oauth.spec.js.map +1 -1
- package/lib/services/resource.spec.js +39 -2
- package/lib/services/resource.spec.js.map +1 -1
- package/lib/services/service.d.ts +16 -0
- package/lib/services/service.js +47 -6
- package/lib/services/service.js.map +1 -1
- package/lib/services/service.spec.d.ts +1 -0
- package/lib/services/service.spec.js +119 -0
- package/lib/services/service.spec.js.map +1 -0
- package/lib/stores/aggregator.d.ts +43 -0
- package/lib/stores/aggregator.js +106 -0
- package/lib/stores/aggregator.js.map +1 -0
- package/lib/stores/file.d.ts +49 -11
- package/lib/stores/file.js +84 -81
- package/lib/stores/file.js.map +1 -1
- package/lib/stores/file.spec.d.ts +6 -1
- package/lib/stores/file.spec.js +134 -9
- package/lib/stores/file.spec.js.map +1 -1
- package/lib/stores/mapper.d.ts +151 -0
- package/lib/stores/mapper.js +294 -0
- package/lib/stores/mapper.js.map +1 -0
- package/lib/stores/mapper.spec.d.ts +1 -0
- package/lib/stores/mapper.spec.js +55 -0
- package/lib/stores/mapper.spec.js.map +1 -0
- package/lib/stores/memory.d.ts +52 -7
- package/lib/stores/memory.js +71 -33
- package/lib/stores/memory.js.map +1 -1
- package/lib/stores/memory.spec.d.ts +6 -1
- package/lib/stores/memory.spec.js +65 -4
- package/lib/stores/memory.spec.js.map +1 -1
- package/lib/stores/store.d.ts +263 -126
- package/lib/stores/store.js +285 -493
- package/lib/stores/store.js.map +1 -1
- package/lib/stores/store.spec.d.ts +20 -0
- package/lib/stores/store.spec.js +242 -18
- package/lib/stores/store.spec.js.map +1 -1
- package/lib/test.d.ts +1 -7
- package/lib/test.js +3 -12
- package/lib/test.js.map +1 -1
- package/lib/utils/abstractdeployer.spec.d.ts +1 -0
- package/lib/utils/abstractdeployer.spec.js +23 -0
- package/lib/utils/abstractdeployer.spec.js.map +1 -0
- package/lib/utils/context.d.ts +25 -2
- package/lib/utils/context.js +33 -12
- package/lib/utils/context.js.map +1 -1
- package/lib/utils/context.spec.js +81 -11
- package/lib/utils/context.spec.js.map +1 -1
- package/lib/utils/cookie.d.ts +12 -0
- package/lib/utils/cookie.js +13 -1
- package/lib/utils/cookie.js.map +1 -1
- package/lib/utils/cookie.spec.js +42 -11
- package/lib/utils/cookie.spec.js.map +1 -1
- package/lib/utils/logger.d.ts +23 -4
- package/lib/utils/logger.js +29 -6
- package/lib/utils/logger.js.map +1 -1
- package/lib/utils/logger.spec.js +8 -0
- package/lib/utils/logger.spec.js.map +1 -1
- package/lib/utils/serializers.d.ts +5 -5
- package/lib/utils/serializers.js +10 -10
- package/lib/utils/serializers.js.map +1 -1
- package/lib/utils/serializers.spec.js +41 -16
- package/lib/utils/serializers.spec.js.map +1 -1
- package/lib/utils/waiter.d.ts +59 -1
- package/lib/utils/waiter.js +86 -3
- package/lib/utils/waiter.js.map +1 -1
- package/lib/utils/waiter.spec.js +48 -4
- package/lib/utils/waiter.spec.js.map +1 -1
- package/package.json +16 -11
- package/test/badapp/package.json +4 -0
- package/test/badapp/webda.config.json +1 -0
- package/test/cachedapp/webda.config.json +7 -0
- package/test/config-file-no-reload.json +70 -0
- package/test/config-file-reload.json +7 -1
- package/test/config-kube-reload.json +7 -1
- package/test/config.json +45 -21
- package/test/config.old-default.json +0 -16
- package/test/config.old.json +0 -16
- package/test/deployments/invalid.json +1 -0
- package/test/moddas/fakeservice.js +5 -0
- package/test/models/ident.js +10 -14
- package/test/models/task.js +2 -4
|
@@ -9,8 +9,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.EventService = exports.EventServiceParameters = void 0;
|
|
12
|
+
exports.EventService = exports.EventServiceParameters = exports.AsyncEvent = void 0;
|
|
13
13
|
const service_1 = require("./service");
|
|
14
|
+
/**
|
|
15
|
+
* AsyncEvent representation
|
|
16
|
+
*/
|
|
14
17
|
class AsyncEvent {
|
|
15
18
|
constructor(service, type, payload = {}) {
|
|
16
19
|
this.service = service;
|
|
@@ -18,22 +21,63 @@ class AsyncEvent {
|
|
|
18
21
|
this.payload = payload;
|
|
19
22
|
this.time = new Date();
|
|
20
23
|
}
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Allow payload to contain Service but do not serialize them
|
|
26
|
+
* replacing them by a #Webda:Service:${service.getName()} so it
|
|
27
|
+
* can be revived
|
|
28
|
+
*
|
|
29
|
+
* @returns
|
|
30
|
+
*/
|
|
31
|
+
toJSON() {
|
|
32
|
+
return Object.assign(Object.assign({}, this), { payload: JSON.stringify(this.payload, (key, value) => {
|
|
33
|
+
if (value instanceof service_1.Service) {
|
|
34
|
+
return `${AsyncEvent.ServiceTag}${value.getName()}`;
|
|
35
|
+
}
|
|
36
|
+
return value;
|
|
37
|
+
}) });
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Deserialize from the queue, reviving any detected service
|
|
41
|
+
*
|
|
42
|
+
* @param data
|
|
43
|
+
* @param service
|
|
44
|
+
* @returns
|
|
45
|
+
*/
|
|
46
|
+
static fromQueue(data, service) {
|
|
47
|
+
let evt = new AsyncEvent(data.service, data.type, JSON.parse(data.payload, (key, value) => {
|
|
48
|
+
if (typeof value === "string" && value.startsWith(AsyncEvent.ServiceTag)) {
|
|
49
|
+
return service.getService(value.substr(AsyncEvent.ServiceTag.length));
|
|
50
|
+
}
|
|
51
|
+
return value;
|
|
52
|
+
}));
|
|
23
53
|
evt.time = data.time;
|
|
24
54
|
return evt;
|
|
25
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Mapper name
|
|
58
|
+
* @returns
|
|
59
|
+
*/
|
|
26
60
|
getMapper() {
|
|
27
61
|
return this.service + "_" + this.type;
|
|
28
62
|
}
|
|
29
63
|
}
|
|
64
|
+
exports.AsyncEvent = AsyncEvent;
|
|
65
|
+
/**
|
|
66
|
+
* Used when serializing a service
|
|
67
|
+
*/
|
|
68
|
+
AsyncEvent.ServiceTag = "#Webda:Service:";
|
|
69
|
+
/**
|
|
70
|
+
* @inheritdoc
|
|
71
|
+
*/
|
|
30
72
|
class EventServiceParameters extends service_1.ServiceParameters {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
73
|
+
/**
|
|
74
|
+
* @inheritdoc
|
|
75
|
+
*/
|
|
76
|
+
constructor(params) {
|
|
77
|
+
var _a, _b;
|
|
78
|
+
super(params);
|
|
79
|
+
(_a = this.queues) !== null && _a !== void 0 ? _a : (this.queues = {});
|
|
80
|
+
(_b = this.sync) !== null && _b !== void 0 ? _b : (this.sync = false);
|
|
37
81
|
}
|
|
38
82
|
}
|
|
39
83
|
exports.EventServiceParameters = EventServiceParameters;
|
|
@@ -62,15 +106,13 @@ class EventService extends service_1.Service {
|
|
|
62
106
|
*/
|
|
63
107
|
computeParameters() {
|
|
64
108
|
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
});
|
|
73
|
-
}
|
|
109
|
+
Object.keys(this.parameters.queues).forEach(key => {
|
|
110
|
+
// Define default as first queue
|
|
111
|
+
if (!this._defaultQueue) {
|
|
112
|
+
this._defaultQueue = key;
|
|
113
|
+
}
|
|
114
|
+
this._queues[key] = this.getService(this.parameters.queues[key]);
|
|
115
|
+
});
|
|
74
116
|
this._async = !this.parameters.sync;
|
|
75
117
|
// Check we have at least one queue to handle asynchronous
|
|
76
118
|
if (this._async && Object.keys(this._queues).length < 1) {
|
|
@@ -79,6 +121,30 @@ class EventService extends service_1.Service {
|
|
|
79
121
|
}
|
|
80
122
|
});
|
|
81
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* Bind a asynchronous event
|
|
126
|
+
*
|
|
127
|
+
* ```mermaid
|
|
128
|
+
* sequenceDiagram
|
|
129
|
+
* participant S as Service
|
|
130
|
+
* participant As as AsyncEventService
|
|
131
|
+
* participant Q as Queue
|
|
132
|
+
* participant Aw as AsyncEventService Worker
|
|
133
|
+
*
|
|
134
|
+
* As->>S: Bind event to a sendQueue listener
|
|
135
|
+
* activate As
|
|
136
|
+
* S->>As: Emit event
|
|
137
|
+
* As->>Q: Push the event to the queue
|
|
138
|
+
* deactivate As
|
|
139
|
+
* Aw->>Q: Consume queue
|
|
140
|
+
* Aw->>Aw: Call the original listener
|
|
141
|
+
* ```
|
|
142
|
+
*
|
|
143
|
+
* @param service
|
|
144
|
+
* @param event
|
|
145
|
+
* @param callback
|
|
146
|
+
* @param queue
|
|
147
|
+
*/
|
|
82
148
|
bindAsyncListener(service, event, callback, queue) {
|
|
83
149
|
if (!this._async) {
|
|
84
150
|
throw Error("EventService is not configured for asynchronous");
|
|
@@ -93,35 +159,64 @@ class EventService extends service_1.Service {
|
|
|
93
159
|
}
|
|
94
160
|
this._callbacks[mapper].push(callback);
|
|
95
161
|
}
|
|
162
|
+
/**
|
|
163
|
+
* Synchronous Listener to proxy to async
|
|
164
|
+
*
|
|
165
|
+
* @param service
|
|
166
|
+
* @param type
|
|
167
|
+
* @param queue
|
|
168
|
+
* @param payload
|
|
169
|
+
* @returns
|
|
170
|
+
*/
|
|
96
171
|
pushEvent(service, type, queue, payload) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
172
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
173
|
+
let event = new AsyncEvent(service.getName(), type, payload);
|
|
174
|
+
if (this._async) {
|
|
175
|
+
return this._queues[queue].sendMessage(event);
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
return this.handleEvent(event);
|
|
179
|
+
}
|
|
180
|
+
});
|
|
104
181
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
182
|
+
/**
|
|
183
|
+
* Process one event
|
|
184
|
+
*
|
|
185
|
+
* @param event
|
|
186
|
+
* @returns
|
|
187
|
+
*/
|
|
188
|
+
handleEvent(event) {
|
|
189
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
190
|
+
if (!this._callbacks[event.getMapper()]) {
|
|
191
|
+
return Promise.reject("Callbacks should not be empty, possible application version mismatch between emitter and worker");
|
|
192
|
+
}
|
|
193
|
+
let promises = [];
|
|
194
|
+
this._callbacks[event.getMapper()].map(executor => {
|
|
195
|
+
promises.push(executor(event.payload, event));
|
|
196
|
+
});
|
|
197
|
+
// Need to handle the failure
|
|
198
|
+
yield Promise.all(promises);
|
|
112
199
|
});
|
|
113
|
-
// Need to handle the failure
|
|
114
|
-
return Promise.all(promises);
|
|
115
200
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
201
|
+
/**
|
|
202
|
+
*
|
|
203
|
+
* @param eventBody serialized event
|
|
204
|
+
* @returns
|
|
205
|
+
*/
|
|
206
|
+
handleRawEvent(event) {
|
|
207
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
208
|
+
return this.handleEvent(AsyncEvent.fromQueue(event, this));
|
|
119
209
|
});
|
|
120
210
|
}
|
|
121
|
-
|
|
211
|
+
/**
|
|
212
|
+
* Process asynchronous event on queue
|
|
213
|
+
* @param queue
|
|
214
|
+
* @returns
|
|
215
|
+
*/
|
|
216
|
+
worker(queue = this._defaultQueue) {
|
|
122
217
|
// Avoid loops
|
|
123
218
|
this._async = false;
|
|
124
|
-
return this._queues[queue].
|
|
219
|
+
return this._queues[queue].consume(this.handleRawEvent.bind(this));
|
|
125
220
|
}
|
|
126
221
|
}
|
|
127
222
|
exports.EventService = EventService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asyncevents.js","sourceRoot":"","sources":["../../src/services/asyncevents.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,uCAAuD;AAEvD,
|
|
1
|
+
{"version":3,"file":"asyncevents.js","sourceRoot":"","sources":["../../src/services/asyncevents.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,uCAAuD;AAEvD;;GAEG;AACH,MAAa,UAAU;IAuBrB,YAAY,OAAe,EAAE,IAAI,EAAE,OAAO,GAAG,EAAE;QAC7C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;IACzB,CAAC;IAED;;;;;;OAMG;IACH,MAAM;QACJ,uCACK,IAAI,KACP,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,GA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AC,SAAS,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;gBAChD,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;YAChD,CAAC,CAAC,CAAC;YACH,6BAA6B;YAC7B,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC9B,CAAC;KAAA;IAED;;;;OAIG;IACa,cAAc,CAAC,KAAiB;;YAC9C,OAAO,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;QAC7D,CAAC;KAAA;IAED;;;;OAIG;IACH,MAAM,CAAC,QAAgB,IAAI,CAAC,aAAa;QACvC,cAAc;QACd,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACrE,CAAC;CACF;AAEQ,oCAAY"}
|
|
@@ -18,6 +18,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
18
18
|
const assert = require("assert");
|
|
19
19
|
const mocha_1 = require("@testdeck/mocha");
|
|
20
20
|
const test_1 = require("../test");
|
|
21
|
+
const asyncevents_1 = require("./asyncevents");
|
|
22
|
+
const sinon = require("sinon");
|
|
21
23
|
let AsyncEventsTest = class AsyncEventsTest extends test_1.WebdaTest {
|
|
22
24
|
simple() {
|
|
23
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -50,12 +52,14 @@ let AsyncEventsTest = class AsyncEventsTest extends test_1.WebdaTest {
|
|
|
50
52
|
// We need to emulate the worker as it wont stop pulling from the queue
|
|
51
53
|
assert.strictEqual(eventsCount, 0);
|
|
52
54
|
assert.strictEqual(priorityEventsCount, 0);
|
|
53
|
-
let
|
|
54
|
-
|
|
55
|
+
let evts = yield defaultQueue.receiveMessage();
|
|
56
|
+
// @ts-ignore
|
|
57
|
+
yield eventService.handleRawEvent(evts[0].Message);
|
|
55
58
|
assert.strictEqual(eventsCount, 1);
|
|
56
59
|
assert.strictEqual(priorityEventsCount, 0);
|
|
57
|
-
|
|
58
|
-
|
|
60
|
+
evts = yield priorityQueue.receiveMessage();
|
|
61
|
+
// @ts-ignore
|
|
62
|
+
yield eventService.handleRawEvent(evts[0].Message);
|
|
59
63
|
assert.strictEqual(eventsCount, 1);
|
|
60
64
|
assert.strictEqual(priorityEventsCount, 1);
|
|
61
65
|
// Disable async and verify that it directly update now
|
|
@@ -71,10 +75,60 @@ let AsyncEventsTest = class AsyncEventsTest extends test_1.WebdaTest {
|
|
|
71
75
|
assert.strictEqual(priorityEventsCount, 2);
|
|
72
76
|
});
|
|
73
77
|
}
|
|
78
|
+
worker() {
|
|
79
|
+
let eventService = this.webda.getService("AsyncEvents");
|
|
80
|
+
eventService._queues = {
|
|
81
|
+
plop: {
|
|
82
|
+
// @ts-ignore
|
|
83
|
+
consume: () => "ploper"
|
|
84
|
+
},
|
|
85
|
+
default: {
|
|
86
|
+
// @ts-ignore
|
|
87
|
+
consume: () => "default"
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
assert.strictEqual(eventService.worker("plop"), "ploper");
|
|
91
|
+
assert.strictEqual(eventService.worker(), "default");
|
|
92
|
+
}
|
|
93
|
+
computeParameters() {
|
|
94
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
+
let evt = new asyncevents_1.EventService(this.webda, "none", { sync: false });
|
|
96
|
+
yield assert.rejects(() => evt.computeParameters(), /Need at least one queue for async to be ready/);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
cov() {
|
|
100
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
101
|
+
let evt = new asyncevents_1.EventService(this.webda, "none", { sync: true });
|
|
102
|
+
assert.throws(() => evt.bindAsyncListener(evt, "plop", undefined, "plop"), /EventService is not configured for asynchronous/);
|
|
103
|
+
yield assert.rejects(
|
|
104
|
+
// @ts-ignore
|
|
105
|
+
() => evt.handleEvent({ getMapper: () => "plop" }), /Callbacks should not be empty, possible application version mismatch between emitter and worker/);
|
|
106
|
+
evt._async = true;
|
|
107
|
+
let stub = sinon.spy(this.webda.getService("users"), "on");
|
|
108
|
+
try {
|
|
109
|
+
evt.bindAsyncListener(this.webda.getService("users"), "plop", () => { }, "priority");
|
|
110
|
+
evt.bindAsyncListener(this.webda.getService("users"), "plop", () => { }, "priority");
|
|
111
|
+
// Should call 'on' only once
|
|
112
|
+
assert.strictEqual(stub.callCount, 1);
|
|
113
|
+
}
|
|
114
|
+
finally {
|
|
115
|
+
stub.restore();
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
74
119
|
};
|
|
75
120
|
__decorate([
|
|
76
121
|
mocha_1.test
|
|
77
122
|
], AsyncEventsTest.prototype, "simple", null);
|
|
123
|
+
__decorate([
|
|
124
|
+
mocha_1.test
|
|
125
|
+
], AsyncEventsTest.prototype, "worker", null);
|
|
126
|
+
__decorate([
|
|
127
|
+
mocha_1.test
|
|
128
|
+
], AsyncEventsTest.prototype, "computeParameters", null);
|
|
129
|
+
__decorate([
|
|
130
|
+
mocha_1.test
|
|
131
|
+
], AsyncEventsTest.prototype, "cov", null);
|
|
78
132
|
AsyncEventsTest = __decorate([
|
|
79
133
|
mocha_1.suite
|
|
80
134
|
], AsyncEventsTest);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asyncevents.spec.js","sourceRoot":"","sources":["../../src/services/asyncevents.spec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,iCAAiC;AACjC,2CAA8C;AAI9C,kCAAoC;
|
|
1
|
+
{"version":3,"file":"asyncevents.spec.js","sourceRoot":"","sources":["../../src/services/asyncevents.spec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,iCAAiC;AACjC,2CAA8C;AAI9C,kCAA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CAClG,CAAC;YACF,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC;YAClB,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,CAAC;YAC3D,IAAI;gBACF,GAAG,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,UAAU,CAAC,CAAC;gBACpF,GAAG,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,UAAU,CAAC,CAAC;gBACpF,6BAA6B;gBAC7B,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;aACvC;oBAAS;gBACR,IAAI,CAAC,OAAO,EAAE,CAAC;aAChB;QACH,CAAC;KAAA;CACF,CAAA;AApGC;IADC,YAAI;6CAwDJ;AAEK;IAAL,YAAI;6CAcJ;AAEK;IAAL,YAAI;wDAGJ;AAEK;IAAL,YAAI;0CAqBJ;AArGG,eAAe;IADpB,aAAK;GACA,eAAe,CAsGpB"}
|
|
@@ -22,6 +22,12 @@ export interface EventAuthenticationRegister extends EventAuthenticationGetMe {
|
|
|
22
22
|
*/
|
|
23
23
|
export interface EventAuthenticationLogout extends EventWithContext {
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Sent when a user update his password
|
|
27
|
+
*/
|
|
28
|
+
export interface EventAuthenticationPasswordUpdate extends EventAuthenticationGetMe {
|
|
29
|
+
password: string;
|
|
30
|
+
}
|
|
25
31
|
/**
|
|
26
32
|
* Emitted when user login
|
|
27
33
|
*/
|
|
@@ -29,7 +35,7 @@ export interface EventAuthenticationLogin extends EventWithContext {
|
|
|
29
35
|
userId: string;
|
|
30
36
|
user?: User;
|
|
31
37
|
identId: string;
|
|
32
|
-
ident
|
|
38
|
+
ident: Ident;
|
|
33
39
|
}
|
|
34
40
|
/**
|
|
35
41
|
* Export when a user failed to authenticate with his password
|
|
@@ -46,8 +52,9 @@ export interface PasswordVerifier extends Service {
|
|
|
46
52
|
* return false
|
|
47
53
|
*
|
|
48
54
|
* @param password to verify
|
|
55
|
+
* @param user to verify from
|
|
49
56
|
*/
|
|
50
|
-
validate(password: string): Promise<boolean>;
|
|
57
|
+
validate(password: string, user?: User): Promise<boolean>;
|
|
51
58
|
}
|
|
52
59
|
/**
|
|
53
60
|
* Information required to reset a password
|
|
@@ -105,6 +112,12 @@ export declare class AuthenticationParameters extends ServiceParameters {
|
|
|
105
112
|
* @default 3600000 * 4
|
|
106
113
|
*/
|
|
107
114
|
delay: number;
|
|
115
|
+
/**
|
|
116
|
+
* When a delay is added between two attempt to authenticate
|
|
117
|
+
*
|
|
118
|
+
* @default 3
|
|
119
|
+
*/
|
|
120
|
+
failedLoginBeforeDelay: number;
|
|
108
121
|
};
|
|
109
122
|
password: {
|
|
110
123
|
/**
|
|
@@ -129,6 +142,10 @@ export declare class AuthenticationParameters extends ServiceParameters {
|
|
|
129
142
|
* Redirect to this page when email validation succeed
|
|
130
143
|
*/
|
|
131
144
|
successRedirect: string;
|
|
145
|
+
/**
|
|
146
|
+
* Redirect to this page once email is validate to finish the registration process
|
|
147
|
+
*/
|
|
148
|
+
registerRedirect: string;
|
|
132
149
|
constructor(params: any);
|
|
133
150
|
}
|
|
134
151
|
/**
|
|
@@ -172,18 +189,41 @@ declare class Authentication<T extends AuthenticationParameters = Authentication
|
|
|
172
189
|
*/
|
|
173
190
|
computeParameters(): void;
|
|
174
191
|
addProvider(name: string): void;
|
|
192
|
+
/**
|
|
193
|
+
* Send or resend an email to validate the email address
|
|
194
|
+
*
|
|
195
|
+
* @param ctx
|
|
196
|
+
* @throws 409 if ident is linked to someone else
|
|
197
|
+
* @throws 412 if the email is already validated
|
|
198
|
+
* @throws 429 if a validation email has been sent recently
|
|
199
|
+
*/
|
|
175
200
|
_sendEmailValidation(ctx: any): Promise<void>;
|
|
176
201
|
_getMe(ctx: Context): Promise<void>;
|
|
177
202
|
_listAuthentications(ctx: Context): Promise<void>;
|
|
178
|
-
_registerNewEmail(ctx: any): Promise<void>;
|
|
179
203
|
onIdentLogin(ctx: Context, provider: string, identId: string, profile: any, tokens?: any): Promise<void>;
|
|
180
204
|
registerUser(ctx: Context, datas: any, user?: any): Promise<any>;
|
|
181
205
|
getPasswordRecoveryInfos(uuid: string | User, interval?: number): Promise<PasswordRecoveryInfos>;
|
|
182
206
|
_passwordRecoveryEmail(ctx: Context): Promise<void>;
|
|
183
|
-
_verifyPassword(password: string): Promise<void>;
|
|
207
|
+
_verifyPassword(password: string, user?: User): Promise<void>;
|
|
184
208
|
_passwordRecovery(ctx: Context): Promise<void>;
|
|
185
209
|
_handleEmailCallback(ctx: Context): Promise<void>;
|
|
210
|
+
/**
|
|
211
|
+
* Send an email to recover the user password
|
|
212
|
+
*
|
|
213
|
+
* @param ctx
|
|
214
|
+
* @param user
|
|
215
|
+
* @param email
|
|
216
|
+
* @returns
|
|
217
|
+
*/
|
|
186
218
|
sendRecoveryEmail(ctx: Context, user: any, email: string): Promise<any>;
|
|
219
|
+
/**
|
|
220
|
+
* Send an email to validate the user email by sending a unique link to
|
|
221
|
+
* his email
|
|
222
|
+
*
|
|
223
|
+
* @param ctx
|
|
224
|
+
* @param email
|
|
225
|
+
* @returns
|
|
226
|
+
*/
|
|
187
227
|
sendValidationEmail(ctx: Context, email: string): Promise<any>;
|
|
188
228
|
/**
|
|
189
229
|
* Create a SHA256 of the info
|
|
@@ -215,9 +255,21 @@ declare class Authentication<T extends AuthenticationParameters = Authentication
|
|
|
215
255
|
* @param ident
|
|
216
256
|
* @returns
|
|
217
257
|
*/
|
|
218
|
-
login(ctx: Context, user: User | string, ident: Ident
|
|
258
|
+
login(ctx: Context, user: User | string, ident: Ident): Promise<any[]>;
|
|
219
259
|
getMailMan(): Mailer;
|
|
260
|
+
/**
|
|
261
|
+
* Handle a user login request
|
|
262
|
+
*
|
|
263
|
+
* @param ctx
|
|
264
|
+
* @param ident
|
|
265
|
+
*/
|
|
220
266
|
protected handleLogin(ctx: Context, ident: Ident): Promise<void>;
|
|
267
|
+
/**
|
|
268
|
+
* Handle the POST /auth/email
|
|
269
|
+
*
|
|
270
|
+
* @param ctx
|
|
271
|
+
* @returns
|
|
272
|
+
*/
|
|
221
273
|
_handleEmail(ctx: Context): Promise<any>;
|
|
222
274
|
generateEmailValidationToken(user: string, email: string): string;
|
|
223
275
|
/** @inheritdoc */
|