kuzzle 2.17.0 → 2.17.3

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.
Files changed (58) hide show
  1. package/lib/api/controllers/authController.js +1 -1
  2. package/lib/api/controllers/securityController.js +1 -1
  3. package/lib/api/controllers/serverController.js +0 -1
  4. package/lib/api/funnel.js +4 -0
  5. package/lib/api/request/kuzzleRequest.js +5 -7
  6. package/lib/api/request/requestResponse.js +6 -1
  7. package/lib/cluster/state.js +20 -4
  8. package/lib/core/backend/backend.d.ts +7 -3
  9. package/lib/core/backend/backend.js +10 -9
  10. package/lib/core/backend/backendConfig.js +21 -2
  11. package/lib/core/backend/backendController.js +21 -5
  12. package/lib/core/backend/backendErrors.d.ts +58 -0
  13. package/lib/core/backend/backendErrors.js +121 -0
  14. package/lib/core/backend/backendHook.js +21 -5
  15. package/lib/core/backend/backendImport.js +21 -5
  16. package/lib/core/backend/backendOpenApi.js +1 -1
  17. package/lib/core/backend/backendPipe.js +21 -5
  18. package/lib/core/backend/backendPlugin.js +22 -3
  19. package/lib/core/backend/backendVault.js +21 -2
  20. package/lib/core/backend/index.d.ts +1 -0
  21. package/lib/core/backend/index.js +1 -0
  22. package/lib/core/network/protocols/httpMessage.js +2 -1
  23. package/lib/core/network/protocols/httpwsProtocol.js +31 -8
  24. package/lib/core/plugin/pluginContext.js +22 -3
  25. package/lib/core/realtime/channel.js +20 -4
  26. package/lib/core/realtime/hotelClerk.js +24 -5
  27. package/lib/core/security/profileRepository.js +26 -7
  28. package/lib/core/shared/sdk/embeddedSdk.js +21 -2
  29. package/lib/core/storage/indexCache.js +20 -4
  30. package/lib/kerror/codes/0-core.json +1 -1
  31. package/lib/kerror/codes/1-services.json +1 -1
  32. package/lib/kerror/codes/2-api.json +1 -1
  33. package/lib/kerror/codes/3-network.json +1 -1
  34. package/lib/kerror/codes/4-plugin.json +1 -1
  35. package/lib/kerror/codes/5-validation.json +1 -1
  36. package/lib/kerror/codes/6-protocol.json +1 -1
  37. package/lib/kerror/codes/7-security.json +1 -1
  38. package/lib/kerror/codes/8-cluster.json +1 -1
  39. package/lib/kerror/codes/index.js +7 -7
  40. package/lib/kerror/errors/multipleErrorsError.d.ts +1 -1
  41. package/lib/kerror/errors/multipleErrorsError.js +3 -3
  42. package/lib/kerror/index.d.ts +82 -0
  43. package/lib/kerror/index.js +180 -143
  44. package/lib/kuzzle/kuzzle.js +23 -4
  45. package/lib/model/security/profile.js +24 -5
  46. package/lib/model/security/role.js +21 -5
  47. package/lib/model/security/user.js +21 -2
  48. package/lib/types/Plugin.js +20 -4
  49. package/lib/types/errors/ErrorDefinition.d.ts +33 -0
  50. package/lib/types/errors/ErrorDefinition.js +3 -0
  51. package/lib/types/errors/ErrorDomains.d.ts +17 -0
  52. package/lib/types/errors/ErrorDomains.js +3 -0
  53. package/lib/types/index.d.ts +2 -0
  54. package/lib/types/index.js +2 -0
  55. package/lib/util/dump-collection.js +21 -2
  56. package/lib/util/mutex.js +21 -2
  57. package/package-lock.json +4 -4
  58. package/package.json +1 -1
@@ -19,15 +19,34 @@
19
19
  * See the License for the specific language governing permissions and
20
20
  * limitations under the License.
21
21
  */
22
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
23
+ if (k2 === undefined) k2 = k;
24
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
25
+ }) : (function(o, m, k, k2) {
26
+ if (k2 === undefined) k2 = k;
27
+ o[k2] = m[k];
28
+ }));
29
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
30
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
31
+ }) : function(o, v) {
32
+ o["default"] = v;
33
+ });
34
+ var __importStar = (this && this.__importStar) || function (mod) {
35
+ if (mod && mod.__esModule) return mod;
36
+ var result = {};
37
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
38
+ __setModuleDefault(result, mod);
39
+ return result;
40
+ };
22
41
  var __importDefault = (this && this.__importDefault) || function (mod) {
23
42
  return (mod && mod.__esModule) ? mod : { "default": mod };
24
43
  };
25
44
  Object.defineProperty(exports, "__esModule", { value: true });
26
45
  exports.BackendVault = void 0;
27
46
  const vault_1 = __importDefault(require("../../kuzzle/vault"));
28
- const kerror_1 = __importDefault(require("../../kerror"));
47
+ const kerror = __importStar(require("../../kerror"));
29
48
  const index_1 = require("./index");
30
- const runtimeError = kerror_1.default.wrap('plugin', 'runtime');
49
+ const runtimeError = kerror.wrap('plugin', 'runtime');
31
50
  class BackendVault extends index_1.ApplicationManager {
32
51
  constructor() {
33
52
  super(...arguments);
@@ -11,3 +11,4 @@ export * from './backendStorage';
11
11
  export * from './backendVault';
12
12
  export * from './backendOpenApi';
13
13
  export * from './internalLogger';
14
+ export * from './backendErrors';
@@ -23,4 +23,5 @@ __exportStar(require("./backendStorage"), exports);
23
23
  __exportStar(require("./backendVault"), exports);
24
24
  __exportStar(require("./backendOpenApi"), exports);
25
25
  __exportStar(require("./internalLogger"), exports);
26
+ __exportStar(require("./backendErrors"), exports);
26
27
  //# sourceMappingURL=index.js.map
@@ -33,7 +33,6 @@ class HttpMessage {
33
33
  this.connection = connection;
34
34
  this._content = null;
35
35
  this.ips = connection.ips;
36
- this.requestId = connection.id;
37
36
  this.query = request.getQuery();
38
37
  this.path = request.getUrl();
39
38
 
@@ -51,6 +50,8 @@ class HttpMessage {
51
50
  this.headers = {};
52
51
 
53
52
  request.forEach((name, value) => (this.headers[name] = value));
53
+
54
+ this.requestId = this.headers['x-kuzzle-request-id'] || connection.id;
54
55
  }
55
56
 
56
57
  set content (value) {
@@ -77,6 +77,9 @@ const HTTP_ALLOWED_CONTENT_TYPES = [
77
77
  'application/x-www-form-urlencoded',
78
78
  'multipart/form-data',
79
79
  ];
80
+ const HTTP_SKIPPED_HEADERS = [
81
+ 'content-length',
82
+ ];
80
83
  const HTTP_HEADER_CONNECTION = Buffer.from('Connection');
81
84
  const HTTP_HEADER_CONTENT_LENGTH = Buffer.from('Content-Length');
82
85
  const HTTP_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN = Buffer.from('Access-Control-Allow-Origin');
@@ -85,6 +88,7 @@ const HTTP_HEADER_TRANSFER_ENCODING = Buffer.from('Transfer-Encoding');
85
88
  const CHUNKED = Buffer.from('chunked');
86
89
  const WILDCARD = Buffer.from('*');
87
90
  const ORIGIN = Buffer.from('Origin');
91
+ const X_KUZZLE_REQUEST_ID = Buffer.from('X-Kuzzle-Request-Id');
88
92
  const CLOSE = Buffer.from('close');
89
93
  const CHARSET_REGEX = /charset=([\w-]+)/i;
90
94
 
@@ -255,6 +259,7 @@ class HttpWsProtocol extends Protocol {
255
259
  res.upgrade(
256
260
  {
257
261
  cookie: req.getHeader('cookie'),
262
+ origin: req.getHeader('origin'),
258
263
  },
259
264
  req.getHeader('sec-websocket-key'),
260
265
  req.getHeader('sec-websocket-protocol'),
@@ -265,7 +270,14 @@ class HttpWsProtocol extends Protocol {
265
270
 
266
271
  wsOnOpenHandler (socket) {
267
272
  const ip = Buffer.from(socket.getRemoteAddressAsText()).toString();
268
- const connection = new ClientConnection(this.name, [ip], { cookie: socket.cookie });
273
+ const connection = new ClientConnection(
274
+ this.name,
275
+ [ip],
276
+ {
277
+ cookie: socket.cookie,
278
+ origin: socket.origin
279
+ }
280
+ );
269
281
 
270
282
  this.entryPoint.newConnection(connection);
271
283
  this.connectionBySocket.set(socket, connection);
@@ -351,7 +363,7 @@ class HttpWsProtocol extends Protocol {
351
363
  request = new Request(parsed, { connection });
352
364
  }
353
365
  catch (e) {
354
- this.wsSendError(socket, connection, e);
366
+ this.wsSendError(socket, connection, e, parsed.requestId);
355
367
  return;
356
368
  }
357
369
 
@@ -392,9 +404,14 @@ class HttpWsProtocol extends Protocol {
392
404
  * @param {uWS.WebSocket} socket
393
405
  * @param {ClientConnection} connection
394
406
  * @param {Error} error
407
+ * @param {String} requestId @optional
395
408
  */
396
- wsSendError (socket, connection, error) {
409
+ wsSendError (socket, connection, error, requestId) {
397
410
  const request = new Request({}, { connection, error });
411
+
412
+ // If a requestId is provided we use it instead of the generated one
413
+ request.id = requestId || request.id;
414
+
398
415
  const sanitized = removeErrorStack(request.response.toJSON()).content;
399
416
 
400
417
  this.wsSend(socket, Buffer.from(JSON.stringify(sanitized)));
@@ -626,15 +643,16 @@ class HttpWsProtocol extends Protocol {
626
643
  }
627
644
 
628
645
  /**
629
- *
630
- * @param {uWS.HttpRequest} request
631
- * @param {uWS.HttpResponse} response
632
- * @param {HttpMessage} message
646
+ *
647
+ * @param {uWS.HttpRequest} request
648
+ * @param {uWS.HttpResponse} response
649
+ * @param {HttpMessage} message
633
650
  */
634
651
  httpWriteRequestHeaders (request, response, message) {
635
652
  response.writeStatus(Buffer.from(request.response.status.toString()));
636
-
653
+
637
654
  response.writeHeader(HTTP_HEADER_CONNECTION, CLOSE);
655
+ response.writeHeader(X_KUZZLE_REQUEST_ID, message.requestId);
638
656
 
639
657
  for (const header of this.httpConfig.headers) {
640
658
  // If header is missing, add the default one
@@ -656,6 +674,11 @@ class HttpWsProtocol extends Protocol {
656
674
  }
657
675
 
658
676
  for (const [key, value] of Object.entries(request.response.headers)) {
677
+ // Skip some headers that are not allowed to be sent or modified
678
+ if (HTTP_SKIPPED_HEADERS.includes(key.toLowerCase())) {
679
+ continue;
680
+ }
681
+
659
682
  response.writeHeader(Buffer.from(key), Buffer.from(value.toString()));
660
683
  }
661
684
  }
@@ -19,6 +19,25 @@
19
19
  * See the License for the specific language governing permissions and
20
20
  * limitations under the License.
21
21
  */
22
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
23
+ if (k2 === undefined) k2 = k;
24
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
25
+ }) : (function(o, m, k, k2) {
26
+ if (k2 === undefined) k2 = k;
27
+ o[k2] = m[k];
28
+ }));
29
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
30
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
31
+ }) : function(o, v) {
32
+ o["default"] = v;
33
+ });
34
+ var __importStar = (this && this.__importStar) || function (mod) {
35
+ if (mod && mod.__esModule) return mod;
36
+ var result = {};
37
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
38
+ __setModuleDefault(result, mod);
39
+ return result;
40
+ };
22
41
  var __importDefault = (this && this.__importDefault) || function (mod) {
23
42
  return (mod && mod.__esModule) ? mod : { "default": mod };
24
43
  };
@@ -33,12 +52,12 @@ const elasticsearch_1 = __importDefault(require("../../service/storage/elasticse
33
52
  const safeObject_1 = require("../../util/safeObject");
34
53
  const promback_1 = __importDefault(require("../../util/promback"));
35
54
  const mutex_1 = require("../../util/mutex");
36
- const kerror_1 = __importDefault(require("../../kerror"));
55
+ const kerror = __importStar(require("../../kerror"));
37
56
  const storeScopeEnum_1 = __importDefault(require("../storage/storeScopeEnum"));
38
57
  const errors_1 = require("../../kerror/errors");
39
58
  const index_1 = require("../../../index");
40
59
  const backend_1 = require("../backend");
41
- const contextError = kerror_1.default.wrap('plugin', 'context');
60
+ const contextError = kerror.wrap('plugin', 'context');
42
61
  class PluginContext {
43
62
  constructor(pluginName) {
44
63
  this.config = JSON.parse(JSON.stringify(global.kuzzle.config));
@@ -60,7 +79,7 @@ class PluginContext {
60
79
  TooManyRequestsError: errors_1.TooManyRequestsError,
61
80
  UnauthorizedError: errors_1.UnauthorizedError,
62
81
  };
63
- this.kerror = kerror_1.default.wrap('plugin', pluginName);
82
+ this.kerror = kerror.wrap('plugin', pluginName);
64
83
  // @deprecated - backward compatibility only
65
84
  this.errorsManager = this.kerror;
66
85
  /* context.secrets ====================================================== */
@@ -19,13 +19,29 @@
19
19
  * See the License for the specific language governing permissions and
20
20
  * limitations under the License.
21
21
  */
22
- var __importDefault = (this && this.__importDefault) || function (mod) {
23
- return (mod && mod.__esModule) ? mod : { "default": mod };
22
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
23
+ if (k2 === undefined) k2 = k;
24
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
25
+ }) : (function(o, m, k, k2) {
26
+ if (k2 === undefined) k2 = k;
27
+ o[k2] = m[k];
28
+ }));
29
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
30
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
31
+ }) : function(o, v) {
32
+ o["default"] = v;
33
+ });
34
+ var __importStar = (this && this.__importStar) || function (mod) {
35
+ if (mod && mod.__esModule) return mod;
36
+ var result = {};
37
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
38
+ __setModuleDefault(result, mod);
39
+ return result;
24
40
  };
25
41
  Object.defineProperty(exports, "__esModule", { value: true });
26
42
  exports.Channel = void 0;
27
- const kerror_1 = __importDefault(require("../../kerror"));
28
- const realtimeError = kerror_1.default.wrap('core', 'realtime');
43
+ const kerror = __importStar(require("../../kerror"));
44
+ const realtimeError = kerror.wrap('core', 'realtime');
29
45
  /**
30
46
  * A channel define how notifications should be send for a particular realtime
31
47
  * room.
@@ -19,6 +19,25 @@
19
19
  * See the License for the specific language governing permissions and
20
20
  * limitations under the License.
21
21
  */
22
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
23
+ if (k2 === undefined) k2 = k;
24
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
25
+ }) : (function(o, m, k, k2) {
26
+ if (k2 === undefined) k2 = k;
27
+ o[k2] = m[k];
28
+ }));
29
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
30
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
31
+ }) : function(o, v) {
32
+ o["default"] = v;
33
+ });
34
+ var __importStar = (this && this.__importStar) || function (mod) {
35
+ if (mod && mod.__esModule) return mod;
36
+ var result = {};
37
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
38
+ __setModuleDefault(result, mod);
39
+ return result;
40
+ };
22
41
  var __importDefault = (this && this.__importDefault) || function (mod) {
23
42
  return (mod && mod.__esModule) ? mod : { "default": mod };
24
43
  };
@@ -26,14 +45,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
45
  exports.HotelClerk = void 0;
27
46
  const bluebird_1 = __importDefault(require("bluebird"));
28
47
  const request_1 = require("../../api/request");
29
- const kerror_1 = __importDefault(require("../../kerror"));
48
+ const kerror = __importStar(require("../../kerror"));
30
49
  const debug_1 = __importDefault(require("../../util/debug"));
31
50
  const koncordeCompat_1 = require("../../util/koncordeCompat");
32
51
  const channel_1 = require("./channel");
33
52
  const connectionRooms_1 = require("./connectionRooms");
34
53
  const room_1 = require("./room");
35
54
  const subscription_1 = require("./subscription");
36
- const realtimeError = kerror_1.default.wrap('core', 'realtime');
55
+ const realtimeError = kerror.wrap('core', 'realtime');
37
56
  const debug = (0, debug_1.default)('kuzzle:realtime:hotelClerk');
38
57
  /**
39
58
  * The HotelClerk is responsible of keeping the list of rooms and subscriptions
@@ -168,10 +187,10 @@ class HotelClerk {
168
187
  async subscribe(request) {
169
188
  const { index, collection } = request.input.resource;
170
189
  if (!index) {
171
- return kerror_1.default.reject('api', 'assert', 'missing_argument', 'index');
190
+ return kerror.reject('api', 'assert', 'missing_argument', 'index');
172
191
  }
173
192
  if (!collection) {
174
- return kerror_1.default.reject('api', 'assert', 'missing_argument', 'collection');
193
+ return kerror.reject('api', 'assert', 'missing_argument', 'collection');
175
194
  }
176
195
  /*
177
196
  * /!\ This check is a duplicate to the one already made by the
@@ -192,7 +211,7 @@ class HotelClerk {
192
211
  normalized = this.koncorde.normalize(request.input.body, (0, koncordeCompat_1.toKoncordeIndex)(index, collection));
193
212
  }
194
213
  catch (e) {
195
- throw kerror_1.default.get('api', 'assert', 'koncorde_dsl_error', e.message);
214
+ throw kerror.get('api', 'assert', 'koncorde_dsl_error', e.message);
196
215
  }
197
216
  this.createRoom(normalized);
198
217
  const { channel, subscribed } = await this.subscribeToRoom(normalized.id, request);
@@ -19,6 +19,25 @@
19
19
  * See the License for the specific language governing permissions and
20
20
  * limitations under the License.
21
21
  */
22
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
23
+ if (k2 === undefined) k2 = k;
24
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
25
+ }) : (function(o, m, k, k2) {
26
+ if (k2 === undefined) k2 = k;
27
+ o[k2] = m[k];
28
+ }));
29
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
30
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
31
+ }) : function(o, v) {
32
+ o["default"] = v;
33
+ });
34
+ var __importStar = (this && this.__importStar) || function (mod) {
35
+ if (mod && mod.__esModule) return mod;
36
+ var result = {};
37
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
38
+ __setModuleDefault(result, mod);
39
+ return result;
40
+ };
22
41
  var __importDefault = (this && this.__importDefault) || function (mod) {
23
42
  return (mod && mod.__esModule) ? mod : { "default": mod };
24
43
  };
@@ -28,7 +47,7 @@ const lodash_1 = require("lodash");
28
47
  const bluebird_1 = __importDefault(require("bluebird"));
29
48
  const profile_1 = require("../../model/security/profile");
30
49
  const repository_1 = __importDefault(require("../shared/repository"));
31
- const kerror_1 = __importDefault(require("../../kerror"));
50
+ const kerror = __importStar(require("../../kerror"));
32
51
  const cacheDbEnum_1 = __importDefault(require("../cache/cacheDbEnum"));
33
52
  /**
34
53
  * @class ProfileRepository
@@ -159,7 +178,7 @@ class ProfileRepository extends repository_1.default {
159
178
  async loadProfiles(profileIds = []) {
160
179
  const profiles = [];
161
180
  if (profileIds.some(p => typeof p !== 'string')) {
162
- throw kerror_1.default.get('api', 'assert', 'invalid_type', 'profileIds', 'string[]');
181
+ throw kerror.get('api', 'assert', 'invalid_type', 'profileIds', 'string[]');
163
182
  }
164
183
  for (const id of profileIds) {
165
184
  let profile = this.profiles.get(id);
@@ -184,7 +203,7 @@ class ProfileRepository extends repository_1.default {
184
203
  }
185
204
  catch (err) {
186
205
  if (err.status === 404) {
187
- throw kerror_1.default.get('security', 'profile', 'not_found', id);
206
+ throw kerror.get('security', 'profile', 'not_found', id);
188
207
  }
189
208
  throw err;
190
209
  }
@@ -283,7 +302,7 @@ class ProfileRepository extends repository_1.default {
283
302
  */
284
303
  async delete(profile, { refresh = 'false', onAssignedUsers = 'fail', userId = '-1', } = {}) {
285
304
  if (['admin', 'default', 'anonymous'].includes(profile._id)) {
286
- throw kerror_1.default.get('security', 'profile', 'cannot_delete');
305
+ throw kerror.get('security', 'profile', 'cannot_delete');
287
306
  }
288
307
  const query = {
289
308
  terms: {
@@ -316,7 +335,7 @@ class ProfileRepository extends repository_1.default {
316
335
  else {
317
336
  const hits = await this.module.user.search({ query }, { from: 0, size: 1 });
318
337
  if (hits.total > 0) {
319
- throw kerror_1.default.get('security', 'profile', 'in_use');
338
+ throw kerror.get('security', 'profile', 'in_use');
320
339
  }
321
340
  }
322
341
  await this.deleteFromDatabase(profile._id, { refresh });
@@ -353,7 +372,7 @@ class ProfileRepository extends repository_1.default {
353
372
  await profile.validateDefinition({ strict });
354
373
  if (profile._id === 'anonymous'
355
374
  && policiesRoles.indexOf('anonymous') === -1) {
356
- throw kerror_1.default.get('security', 'profile', 'missing_anonymous_role');
375
+ throw kerror.get('security', 'profile', 'missing_anonymous_role');
357
376
  }
358
377
  profile.optimizedPolicies = undefined; // Remove optimized policies
359
378
  await super.persistToDatabase(profile, { method, refresh, retryOnConflict });
@@ -380,7 +399,7 @@ class ProfileRepository extends repository_1.default {
380
399
  const roles = await this.module.role.loadRoles(policiesRoles);
381
400
  // Fail if not all roles are found
382
401
  if (roles.some(r => r === null)) {
383
- throw kerror_1.default.get('security', 'profile', 'cannot_hydrate');
402
+ throw kerror.get('security', 'profile', 'cannot_hydrate');
384
403
  }
385
404
  return profile;
386
405
  }
@@ -19,6 +19,25 @@
19
19
  * See the License for the specific language governing permissions and
20
20
  * limitations under the License.
21
21
  */
22
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
23
+ if (k2 === undefined) k2 = k;
24
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
25
+ }) : (function(o, m, k, k2) {
26
+ if (k2 === undefined) k2 = k;
27
+ o[k2] = m[k];
28
+ }));
29
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
30
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
31
+ }) : function(o, v) {
32
+ o["default"] = v;
33
+ });
34
+ var __importStar = (this && this.__importStar) || function (mod) {
35
+ if (mod && mod.__esModule) return mod;
36
+ var result = {};
37
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
38
+ __setModuleDefault(result, mod);
39
+ return result;
40
+ };
22
41
  var __importDefault = (this && this.__importDefault) || function (mod) {
23
42
  return (mod && mod.__esModule) ? mod : { "default": mod };
24
43
  };
@@ -27,9 +46,9 @@ exports.EmbeddedSDK = void 0;
27
46
  const kuzzle_sdk_1 = require("kuzzle-sdk");
28
47
  const funnelProtocol_1 = __importDefault(require("./funnelProtocol"));
29
48
  const safeObject_1 = require("../../../util/safeObject");
30
- const kerror_1 = __importDefault(require("../../../kerror"));
49
+ const kerror = __importStar(require("../../../kerror"));
31
50
  const impersonatedSdk_1 = __importDefault(require("./impersonatedSdk"));
32
- const contextError = kerror_1.default.wrap('plugin', 'context');
51
+ const contextError = kerror.wrap('plugin', 'context');
33
52
  /**
34
53
  * Kuzzle embedded SDK to make API calls inside applications or plugins.
35
54
  */
@@ -19,13 +19,29 @@
19
19
  * See the License for the specific language governing permissions and
20
20
  * limitations under the License.
21
21
  */
22
- var __importDefault = (this && this.__importDefault) || function (mod) {
23
- return (mod && mod.__esModule) ? mod : { "default": mod };
22
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
23
+ if (k2 === undefined) k2 = k;
24
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
25
+ }) : (function(o, m, k, k2) {
26
+ if (k2 === undefined) k2 = k;
27
+ o[k2] = m[k];
28
+ }));
29
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
30
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
31
+ }) : function(o, v) {
32
+ o["default"] = v;
33
+ });
34
+ var __importStar = (this && this.__importStar) || function (mod) {
35
+ if (mod && mod.__esModule) return mod;
36
+ var result = {};
37
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
38
+ __setModuleDefault(result, mod);
39
+ return result;
24
40
  };
25
41
  Object.defineProperty(exports, "__esModule", { value: true });
26
42
  exports.IndexCache = void 0;
27
- const kerror_1 = __importDefault(require("../../kerror"));
28
- const storageError = kerror_1.default.wrap('services', 'storage');
43
+ const kerror = __importStar(require("../../kerror"));
44
+ const storageError = kerror.wrap('services', 'storage');
29
45
  class IndexCache {
30
46
  constructor() {
31
47
  /**
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "code": 0,
3
- "subdomains": {
3
+ "subDomains": {
4
4
  "fatal": {
5
5
  "code": 0,
6
6
  "errors": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "code": 1,
3
- "subdomains": {
3
+ "subDomains": {
4
4
  "storage": {
5
5
  "code": 1,
6
6
  "errors": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "code": 2,
3
- "subdomains": {
3
+ "subDomains": {
4
4
  "assert": {
5
5
  "code": 1,
6
6
  "errors": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "code": 3,
3
- "subdomains": {
3
+ "subDomains": {
4
4
  "http": {
5
5
  "code": 1,
6
6
  "errors": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "code": 4,
3
- "subdomains": {
3
+ "subDomains": {
4
4
  "assert": {
5
5
  "code": 1,
6
6
  "errors" : {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "code": 5,
3
- "subdomains": {
3
+ "subDomains": {
4
4
  "assert": {
5
5
  "code": 1,
6
6
  "errors": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "code": 6,
3
- "subdomains": {
3
+ "subDomains": {
4
4
  "runtime": {
5
5
  "code": 1,
6
6
  "errors": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "code": 7,
3
- "subdomains": {
3
+ "subDomains": {
4
4
  "token": {
5
5
  "code": 1,
6
6
  "errors": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "code": 8,
3
- "subdomains": {
3
+ "subDomains": {
4
4
  "fatal": {
5
5
  "code": 0,
6
6
  "errors": {
@@ -97,8 +97,8 @@ function checkErrors (subdomain, domain, options) {
97
97
  function checkSubdomains (domain, options) {
98
98
  const subdomainCodes = new Set();
99
99
 
100
- for (const subdomainName of Object.keys(domain.subdomains)) {
101
- const subdomain = domain.subdomains[subdomainName];
100
+ for (const subdomainName of Object.keys(domain.subDomains)) {
101
+ const subdomain = domain.subDomains[subdomainName];
102
102
 
103
103
  // Subdomain code for plugins is not required and is automatically set to 0
104
104
  if (! options.plugin) {
@@ -158,11 +158,11 @@ function checkDomains (errorCodesFiles, options = { plugin: false }) {
158
158
  domainCodes.add(domain.code);
159
159
 
160
160
  assert(
161
- has(domain, 'subdomains'),
162
- `Error configuration file : Missing required 'subdomains' field. (domain: '${domainName}').`);
161
+ has(domain, 'subDomains'),
162
+ `Error configuration file : Missing required 'subDomains' field. (domain: '${domainName}').`);
163
163
  assert(
164
- isPlainObject(domain.subdomains),
165
- `Error configuration file : Field 'subdomains' must be an object. (domain: '${domainName}').`);
164
+ isPlainObject(domain.subDomains),
165
+ `Error configuration file : Field 'subDomains' must be an object. (domain: '${domainName}').`);
166
166
 
167
167
  checkSubdomains(domain, options);
168
168
  }
@@ -170,7 +170,7 @@ function checkDomains (errorCodesFiles, options = { plugin: false }) {
170
170
 
171
171
  function loadPluginsErrors (pluginManifest, pluginCode) {
172
172
  // @todo this should be in its own, independant domain
173
- domains.plugin.subdomains[pluginManifest.name] = {
173
+ domains.plugin.subDomains[pluginManifest.name] = {
174
174
  code: pluginCode,
175
175
  errors: pluginManifest.errors
176
176
  };
@@ -2,6 +2,6 @@ import { KuzzleError } from './kuzzleError';
2
2
  export declare class MultipleErrorsError extends KuzzleError {
3
3
  errors: Array<KuzzleError>;
4
4
  count: number;
5
- constructor(message: string, body?: Array<KuzzleError>, id?: string, code?: number);
5
+ constructor(message: string, errors?: KuzzleError[], id?: string, code?: number);
6
6
  toJSON(): import("kuzzle-sdk").JSONObject;
7
7
  }
@@ -23,10 +23,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.MultipleErrorsError = void 0;
24
24
  const kuzzleError_1 = require("./kuzzleError");
25
25
  class MultipleErrorsError extends kuzzleError_1.KuzzleError {
26
- constructor(message, body = [], id, code) {
26
+ constructor(message, errors = [], id, code) {
27
27
  super(message, 400, id, code);
28
- this.errors = body;
29
- this.count = body.length;
28
+ this.errors = errors;
29
+ this.count = errors.length;
30
30
  }
31
31
  toJSON() {
32
32
  const serialized = super.toJSON();