kuzzle 2.19.2 → 2.19.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 (289) hide show
  1. package/lib/api/controllers/adminController.js +94 -80
  2. package/lib/api/controllers/authController.js +239 -212
  3. package/lib/api/controllers/baseController.js +89 -51
  4. package/lib/api/controllers/bulkController.js +62 -49
  5. package/lib/api/controllers/clusterController.js +6 -8
  6. package/lib/api/controllers/collectionController.js +140 -129
  7. package/lib/api/controllers/debugController.d.ts +2 -2
  8. package/lib/api/controllers/debugController.js +33 -31
  9. package/lib/api/controllers/documentController.js +365 -274
  10. package/lib/api/controllers/index.js +13 -13
  11. package/lib/api/controllers/indexController.js +46 -50
  12. package/lib/api/controllers/memoryStorageController.js +410 -360
  13. package/lib/api/controllers/realtimeController.js +37 -36
  14. package/lib/api/controllers/securityController.js +553 -412
  15. package/lib/api/controllers/serverController.js +111 -104
  16. package/lib/api/documentExtractor.js +75 -68
  17. package/lib/api/funnel.js +411 -312
  18. package/lib/api/httpRoutes.js +1493 -324
  19. package/lib/api/openapi/OpenApiManager.d.ts +1 -1
  20. package/lib/api/openapi/OpenApiManager.js +22 -22
  21. package/lib/api/openapi/components/document/count.yaml +1 -1
  22. package/lib/api/openapi/components/document/create.yaml +2 -2
  23. package/lib/api/openapi/components/document/delete.yaml +1 -1
  24. package/lib/api/openapi/components/document/deleteByQuery.yaml +1 -1
  25. package/lib/api/openapi/components/document/exists.yaml +1 -1
  26. package/lib/api/openapi/components/document/get.yaml +2 -2
  27. package/lib/api/openapi/components/document/index.js +12 -12
  28. package/lib/api/openapi/components/document/replace.yaml +1 -1
  29. package/lib/api/openapi/components/document/scroll.yaml +1 -1
  30. package/lib/api/openapi/components/document/validate.yaml +1 -1
  31. package/lib/api/openapi/components/index.d.ts +2 -2
  32. package/lib/api/openapi/components/index.js +1 -1
  33. package/lib/api/openapi/components/security/index.js +1 -1
  34. package/lib/api/openapi/components/security/upsertUser.yaml +2 -3
  35. package/lib/api/openapi/index.d.ts +1 -1
  36. package/lib/api/openapi/openApiGenerator.d.ts +1 -1
  37. package/lib/api/openapi/openApiGenerator.js +7 -7
  38. package/lib/api/rateLimiter.js +12 -13
  39. package/lib/api/request/index.d.ts +4 -4
  40. package/lib/api/request/kuzzleRequest.d.ts +9 -9
  41. package/lib/api/request/kuzzleRequest.js +89 -87
  42. package/lib/api/request/requestContext.d.ts +2 -2
  43. package/lib/api/request/requestContext.js +17 -17
  44. package/lib/api/request/requestInput.d.ts +1 -1
  45. package/lib/api/request/requestInput.js +19 -19
  46. package/lib/api/request/requestResponse.d.ts +4 -4
  47. package/lib/api/request/requestResponse.js +31 -33
  48. package/lib/cluster/command.js +48 -44
  49. package/lib/cluster/idCardHandler.d.ts +1 -1
  50. package/lib/cluster/idCardHandler.js +15 -15
  51. package/lib/cluster/index.js +2 -2
  52. package/lib/cluster/node.js +301 -269
  53. package/lib/cluster/publisher.js +45 -46
  54. package/lib/cluster/state.d.ts +5 -5
  55. package/lib/cluster/state.js +8 -8
  56. package/lib/cluster/subscriber.js +163 -113
  57. package/lib/cluster/workers/IDCardRenewer.js +33 -32
  58. package/lib/config/default.config.d.ts +1 -1
  59. package/lib/config/default.config.js +212 -171
  60. package/lib/config/documentEventAliases.js +6 -6
  61. package/lib/config/index.js +161 -98
  62. package/lib/config/sdkCompatibility.json +8 -8
  63. package/lib/core/auth/formatProcessing.js +7 -7
  64. package/lib/core/auth/passportResponse.js +7 -7
  65. package/lib/core/auth/passportWrapper.js +34 -30
  66. package/lib/core/auth/tokenManager.d.ts +2 -2
  67. package/lib/core/auth/tokenManager.js +11 -10
  68. package/lib/core/backend/applicationManager.d.ts +1 -1
  69. package/lib/core/backend/applicationManager.js +2 -2
  70. package/lib/core/backend/backend.d.ts +3 -3
  71. package/lib/core/backend/backend.js +34 -31
  72. package/lib/core/backend/backendCluster.d.ts +2 -2
  73. package/lib/core/backend/backendCluster.js +5 -5
  74. package/lib/core/backend/backendConfig.d.ts +2 -2
  75. package/lib/core/backend/backendConfig.js +3 -3
  76. package/lib/core/backend/backendController.d.ts +2 -2
  77. package/lib/core/backend/backendController.js +9 -10
  78. package/lib/core/backend/backendErrors.d.ts +3 -3
  79. package/lib/core/backend/backendErrors.js +2 -1
  80. package/lib/core/backend/backendHook.d.ts +2 -2
  81. package/lib/core/backend/backendHook.js +5 -5
  82. package/lib/core/backend/backendImport.d.ts +3 -3
  83. package/lib/core/backend/backendImport.js +23 -23
  84. package/lib/core/backend/backendOpenApi.d.ts +2 -2
  85. package/lib/core/backend/backendOpenApi.js +16 -16
  86. package/lib/core/backend/backendPipe.d.ts +2 -2
  87. package/lib/core/backend/backendPipe.js +6 -6
  88. package/lib/core/backend/backendPlugin.d.ts +4 -4
  89. package/lib/core/backend/backendPlugin.js +14 -14
  90. package/lib/core/backend/backendStorage.d.ts +2 -2
  91. package/lib/core/backend/backendStorage.js +1 -2
  92. package/lib/core/backend/backendVault.d.ts +2 -2
  93. package/lib/core/backend/backendVault.js +3 -3
  94. package/lib/core/backend/index.d.ts +14 -14
  95. package/lib/core/backend/internalLogger.d.ts +1 -1
  96. package/lib/core/backend/internalLogger.js +5 -5
  97. package/lib/core/cache/cacheDbEnum.js +4 -4
  98. package/lib/core/cache/cacheEngine.js +79 -85
  99. package/lib/core/network/accessLogger.js +126 -120
  100. package/lib/core/network/clientConnection.js +5 -5
  101. package/lib/core/network/context.js +8 -8
  102. package/lib/core/network/entryPoint.js +100 -85
  103. package/lib/core/network/httpRouter/index.js +63 -60
  104. package/lib/core/network/httpRouter/routeHandler.js +18 -19
  105. package/lib/core/network/httpRouter/routePart.js +23 -19
  106. package/lib/core/network/protocolManifest.js +3 -3
  107. package/lib/core/network/protocols/httpMessage.js +8 -10
  108. package/lib/core/network/protocols/httpwsProtocol.js +305 -250
  109. package/lib/core/network/protocols/internalProtocol.js +27 -24
  110. package/lib/core/network/protocols/mqttProtocol.js +106 -96
  111. package/lib/core/network/protocols/protocol.js +20 -17
  112. package/lib/core/network/router.js +56 -46
  113. package/lib/core/plugin/plugin.js +151 -120
  114. package/lib/core/plugin/pluginContext.d.ts +7 -7
  115. package/lib/core/plugin/pluginContext.js +48 -44
  116. package/lib/core/plugin/pluginManifest.js +13 -12
  117. package/lib/core/plugin/pluginRepository.js +26 -27
  118. package/lib/core/plugin/pluginsManager.js +425 -304
  119. package/lib/core/plugin/privilegedContext.js +3 -3
  120. package/lib/core/realtime/actionEnum.js +1 -1
  121. package/lib/core/realtime/channel.d.ts +1 -1
  122. package/lib/core/realtime/channel.js +22 -22
  123. package/lib/core/realtime/connectionRooms.d.ts +1 -1
  124. package/lib/core/realtime/hotelClerk.d.ts +2 -2
  125. package/lib/core/realtime/hotelClerk.js +53 -50
  126. package/lib/core/realtime/index.js +5 -5
  127. package/lib/core/realtime/notification/document.js +25 -25
  128. package/lib/core/realtime/notification/index.js +4 -4
  129. package/lib/core/realtime/notification/server.js +3 -3
  130. package/lib/core/realtime/notification/user.js +4 -4
  131. package/lib/core/realtime/notifier.js +113 -75
  132. package/lib/core/realtime/room.d.ts +1 -1
  133. package/lib/core/realtime/subscription.d.ts +1 -1
  134. package/lib/core/realtime/subscription.js +1 -1
  135. package/lib/core/security/index.js +8 -8
  136. package/lib/core/security/profileRepository.d.ts +6 -6
  137. package/lib/core/security/profileRepository.js +48 -45
  138. package/lib/core/security/roleRepository.js +127 -115
  139. package/lib/core/security/securityLoader.js +70 -63
  140. package/lib/core/security/tokenRepository.js +132 -118
  141. package/lib/core/security/userRepository.js +104 -88
  142. package/lib/core/shared/KoncordeWrapper.d.ts +1 -1
  143. package/lib/core/shared/KoncordeWrapper.js +3 -1
  144. package/lib/core/shared/abstractManifest.js +22 -23
  145. package/lib/core/shared/repository.js +69 -67
  146. package/lib/core/shared/sdk/embeddedSdk.d.ts +2 -2
  147. package/lib/core/shared/sdk/embeddedSdk.js +36 -32
  148. package/lib/core/shared/sdk/funnelProtocol.d.ts +1 -1
  149. package/lib/core/shared/sdk/funnelProtocol.js +11 -11
  150. package/lib/core/shared/sdk/impersonatedSdk.js +19 -18
  151. package/lib/core/shared/store.js +127 -32
  152. package/lib/core/statistics/index.js +2 -2
  153. package/lib/core/statistics/statistics.js +99 -85
  154. package/lib/core/storage/clientAdapter.js +219 -136
  155. package/lib/core/storage/indexCache.js +3 -3
  156. package/lib/core/storage/storageEngine.js +10 -13
  157. package/lib/core/storage/storeScopeEnum.js +3 -3
  158. package/lib/core/validation/baseType.js +12 -10
  159. package/lib/core/validation/index.js +2 -2
  160. package/lib/core/validation/types/anything.js +4 -4
  161. package/lib/core/validation/types/boolean.js +7 -7
  162. package/lib/core/validation/types/date.js +165 -131
  163. package/lib/core/validation/types/email.js +18 -21
  164. package/lib/core/validation/types/enum.js +34 -21
  165. package/lib/core/validation/types/geoPoint.js +7 -7
  166. package/lib/core/validation/types/geoShape.js +148 -125
  167. package/lib/core/validation/types/integer.js +9 -9
  168. package/lib/core/validation/types/ipAddress.js +17 -19
  169. package/lib/core/validation/types/numeric.js +36 -29
  170. package/lib/core/validation/types/object.js +19 -19
  171. package/lib/core/validation/types/string.js +36 -29
  172. package/lib/core/validation/types/url.js +17 -19
  173. package/lib/core/validation/validation.js +422 -378
  174. package/lib/kerror/codes/1-services.json +7 -1
  175. package/lib/kerror/codes/4-plugin.json +2 -2
  176. package/lib/kerror/codes/index.js +85 -63
  177. package/lib/kerror/errors/badRequestError.d.ts +1 -1
  178. package/lib/kerror/errors/externalServiceError.d.ts +1 -1
  179. package/lib/kerror/errors/forbiddenError.d.ts +1 -1
  180. package/lib/kerror/errors/gatewayTimeoutError.d.ts +1 -1
  181. package/lib/kerror/errors/index.d.ts +15 -15
  182. package/lib/kerror/errors/internalError.d.ts +1 -1
  183. package/lib/kerror/errors/kuzzleError.d.ts +1 -1
  184. package/lib/kerror/errors/multipleErrorsError.d.ts +1 -1
  185. package/lib/kerror/errors/multipleErrorsError.js +1 -1
  186. package/lib/kerror/errors/notFoundError.d.ts +1 -1
  187. package/lib/kerror/errors/partialError.d.ts +1 -1
  188. package/lib/kerror/errors/partialError.js +1 -1
  189. package/lib/kerror/errors/pluginImplementationError.d.ts +1 -1
  190. package/lib/kerror/errors/pluginImplementationError.js +2 -1
  191. package/lib/kerror/errors/preconditionError.d.ts +1 -1
  192. package/lib/kerror/errors/serviceUnavailableError.d.ts +1 -1
  193. package/lib/kerror/errors/sizeLimitError.d.ts +1 -1
  194. package/lib/kerror/errors/tooManyRequestsError.d.ts +1 -1
  195. package/lib/kerror/errors/unauthorizedError.d.ts +1 -1
  196. package/lib/kerror/index.d.ts +3 -3
  197. package/lib/kerror/index.js +17 -16
  198. package/lib/kuzzle/dumpGenerator.js +130 -114
  199. package/lib/kuzzle/event/kuzzleEventEmitter.js +96 -70
  200. package/lib/kuzzle/event/pipeRunner.js +25 -24
  201. package/lib/kuzzle/event/waterfall.js +13 -15
  202. package/lib/kuzzle/index.js +2 -2
  203. package/lib/kuzzle/internalIndexHandler.js +80 -59
  204. package/lib/kuzzle/kuzzle.js +99 -99
  205. package/lib/kuzzle/kuzzleStateEnum.js +1 -1
  206. package/lib/kuzzle/log.js +23 -18
  207. package/lib/kuzzle/vault.js +34 -19
  208. package/lib/model/security/profile.d.ts +3 -3
  209. package/lib/model/security/profile.js +38 -37
  210. package/lib/model/security/rights.js +5 -5
  211. package/lib/model/security/role.d.ts +3 -3
  212. package/lib/model/security/role.js +25 -26
  213. package/lib/model/security/token.d.ts +1 -1
  214. package/lib/model/security/token.js +4 -4
  215. package/lib/model/security/user.d.ts +2 -2
  216. package/lib/model/security/user.js +9 -9
  217. package/lib/model/storage/apiKey.js +43 -33
  218. package/lib/model/storage/baseModel.js +49 -45
  219. package/lib/service/cache/redis.js +60 -55
  220. package/lib/service/service.js +17 -17
  221. package/lib/service/storage/elasticsearch.js +839 -755
  222. package/lib/service/storage/esWrapper.js +103 -86
  223. package/lib/service/storage/queryTranslator.js +52 -59
  224. package/lib/types/Controller.d.ts +3 -3
  225. package/lib/types/ControllerDefinition.d.ts +3 -3
  226. package/lib/types/DebugModule.d.ts +2 -2
  227. package/lib/types/DebugModule.js +1 -1
  228. package/lib/types/Global.d.ts +1 -1
  229. package/lib/types/HttpStream.d.ts +2 -1
  230. package/lib/types/HttpStream.js +7 -5
  231. package/lib/types/Kuzzle.d.ts +1 -1
  232. package/lib/types/KuzzleDocument.d.ts +1 -1
  233. package/lib/types/OpenApiDefinition.d.ts +1 -1
  234. package/lib/types/PasswordPolicy.d.ts +1 -1
  235. package/lib/types/Plugin.d.ts +6 -6
  236. package/lib/types/Plugin.js +2 -2
  237. package/lib/types/Policy.d.ts +1 -1
  238. package/lib/types/RequestPayload.d.ts +1 -1
  239. package/lib/types/ResponsePayload.d.ts +1 -1
  240. package/lib/types/Token.d.ts +1 -1
  241. package/lib/types/User.d.ts +1 -1
  242. package/lib/types/config/DumpConfiguration.d.ts +8 -8
  243. package/lib/types/config/HttpConfiguration.d.ts +1 -1
  244. package/lib/types/config/KuzzleConfiguration.d.ts +1 -1
  245. package/lib/types/config/LimitsConfiguration.d.ts +8 -8
  246. package/lib/types/config/PluginsConfiguration.d.ts +4 -4
  247. package/lib/types/config/SecurityConfiguration.d.ts +62 -62
  248. package/lib/types/config/ServerConfiguration.d.ts +55 -55
  249. package/lib/types/config/ServicesConfiguration.d.ts +2 -2
  250. package/lib/types/config/internalCache/InternalCacheRedisConfiguration.d.ts +10 -10
  251. package/lib/types/config/publicCache/PublicCacheRedisConfiguration.d.ts +3 -3
  252. package/lib/types/config/storageEngine/StorageEngineElasticsearchConfiguration.d.ts +194 -110
  253. package/lib/types/errors/ErrorDefinition.d.ts +1 -1
  254. package/lib/types/errors/ErrorDomains.d.ts +1 -1
  255. package/lib/types/index.d.ts +38 -38
  256. package/lib/types/realtime/RealtimeScope.d.ts +1 -1
  257. package/lib/types/realtime/RealtimeUsers.d.ts +1 -1
  258. package/lib/util/assertType.js +13 -11
  259. package/lib/util/async.d.ts +1 -0
  260. package/lib/util/async.js +61 -0
  261. package/lib/util/asyncStore.js +19 -21
  262. package/lib/util/bufferedPassThrough.d.ts +2 -2
  263. package/lib/util/bufferedPassThrough.js +4 -4
  264. package/lib/util/bytes.js +9 -13
  265. package/lib/util/crypto.js +1 -1
  266. package/lib/util/debug.js +5 -5
  267. package/lib/util/deprecate.js +24 -21
  268. package/lib/util/didYouMean.js +7 -7
  269. package/lib/util/dump-collection.d.ts +2 -2
  270. package/lib/util/dump-collection.js +26 -26
  271. package/lib/util/esRequest.d.ts +1 -0
  272. package/lib/util/esRequest.js +62 -0
  273. package/lib/util/extractFields.js +24 -25
  274. package/lib/util/inflector.js +5 -5
  275. package/lib/util/koncordeCompat.d.ts +2 -2
  276. package/lib/util/koncordeCompat.js +5 -5
  277. package/lib/util/memoize.js +3 -5
  278. package/lib/util/mutex.d.ts +19 -1
  279. package/lib/util/mutex.js +39 -12
  280. package/lib/util/name-generator.js +1331 -1331
  281. package/lib/util/promback.js +8 -10
  282. package/lib/util/readYamlFile.d.ts +1 -1
  283. package/lib/util/readYamlFile.js +1 -1
  284. package/lib/util/requestAssertions.js +34 -34
  285. package/lib/util/safeObject.js +5 -5
  286. package/lib/util/stackTrace.js +20 -22
  287. package/lib/util/wildcard.js +15 -15
  288. package/package.json +6 -6
  289. package/npm-shrinkwrap.json +0 -19422
@@ -80,20 +80,20 @@ const package_json_1 = require("../../package.json");
80
80
  const name_generator_1 = require("../util/name-generator");
81
81
  const openapi_1 = require("../api/openapi");
82
82
  const crypto_1 = require("../util/crypto");
83
- exports.BACKEND_IMPORT_KEY = 'backend:init:import';
83
+ exports.BACKEND_IMPORT_KEY = "backend:init:import";
84
84
  let _kuzzle = null;
85
- Reflect.defineProperty(global, 'kuzzle', {
85
+ Reflect.defineProperty(global, "kuzzle", {
86
86
  configurable: true,
87
87
  enumerable: false,
88
88
  get() {
89
89
  if (_kuzzle === null) {
90
- throw new Error('Kuzzle instance not found. Did you try to use a live-only feature before starting your application?');
90
+ throw new Error("Kuzzle instance not found. Did you try to use a live-only feature before starting your application?");
91
91
  }
92
92
  return _kuzzle;
93
93
  },
94
94
  set(value) {
95
95
  if (_kuzzle !== null) {
96
- throw new Error('Cannot build a Kuzzle instance: another one already exists');
96
+ throw new Error("Cannot build a Kuzzle instance: another one already exists");
97
97
  }
98
98
  _kuzzle = value;
99
99
  },
@@ -106,7 +106,7 @@ class Kuzzle extends kuzzleEventEmitter_1.default {
106
106
  this._state = kuzzleStateEnum_1.default.STARTING;
107
107
  this.config = config;
108
108
  this.log = new log_1.default();
109
- this.rootPath = path_1.default.resolve(path_1.default.join(__dirname, '../..'));
109
+ this.rootPath = path_1.default.resolve(path_1.default.join(__dirname, "../.."));
110
110
  this.internalIndex = new internalIndexHandler_1.default();
111
111
  this.pluginsManager = new pluginsManager_1.default();
112
112
  this.tokenManager = new tokenManager_1.TokenManager();
@@ -139,18 +139,18 @@ class Kuzzle extends kuzzleEventEmitter_1.default {
139
139
  this.registerSignalHandlers();
140
140
  try {
141
141
  this.log.info(`[ℹ] Starting Kuzzle ${this.version} ...`);
142
- await this.pipe('kuzzle:state:start');
142
+ await this.pipe("kuzzle:state:start");
143
143
  // Koncorde realtime engine
144
144
  this.koncorde = new koncorde_1.Koncorde({
145
145
  maxConditions: this.config.limits.subscriptionConditionsCount,
146
- regExpEngine: this.config.realtime.pcreSupport ? 'js' : 're2',
147
- seed: this.config.internal.hash.seed
146
+ regExpEngine: this.config.realtime.pcreSupport ? "js" : "re2",
147
+ seed: this.config.internal.hash.seed,
148
148
  });
149
- await (new cacheEngine_1.default()).init();
150
- await (new storageEngine_1.default()).init();
151
- await (new realtime_1.default()).init();
149
+ await new cacheEngine_1.default().init();
150
+ await new storageEngine_1.default().init();
151
+ await new realtime_1.default().init();
152
152
  await this.internalIndex.init();
153
- await (new security_1.default()).init();
153
+ await new security_1.default().init();
154
154
  // This will init the cluster module if enabled
155
155
  this.id = await this.initKuzzleNode();
156
156
  // Secret used to generate JWTs
@@ -166,24 +166,24 @@ class Kuzzle extends kuzzleEventEmitter_1.default {
166
166
  await this.entryPoint.init();
167
167
  this.pluginsManager.application = application;
168
168
  await this.pluginsManager.init(options.plugins);
169
- this.log.info(`[✔] Successfully loaded ${this.pluginsManager.loadedPlugins.length} plugins: ${this.pluginsManager.loadedPlugins.join(', ')}`);
169
+ this.log.info(`[✔] Successfully loaded ${this.pluginsManager.loadedPlugins.length} plugins: ${this.pluginsManager.loadedPlugins.join(", ")}`);
170
170
  // Authentification plugins must be loaded before users import to avoid
171
171
  // credentials related error which would prevent Kuzzle from starting
172
172
  await this.loadInitialState(options.import, options.support);
173
- await this.ask('core:security:verify');
173
+ await this.ask("core:security:verify");
174
174
  this.router.init();
175
- this.log.info('[✔] Core components loaded');
175
+ this.log.info("[✔] Core components loaded");
176
176
  await this.install(options.installations);
177
177
  this.log.info(`[✔] Start "${this.pluginsManager.application.name}" application`);
178
178
  this.openApiManager = new openapi_1.OpenApiManager(application.openApi, this.config.http.routes, this.pluginsManager.routes);
179
179
  // @deprecated
180
- await this.pipe('kuzzle:start');
181
- await this.pipe('kuzzle:state:live');
180
+ await this.pipe("kuzzle:start");
181
+ await this.pipe("kuzzle:state:live");
182
182
  await this.entryPoint.startListening();
183
- await this.pipe('kuzzle:state:ready');
183
+ await this.pipe("kuzzle:state:ready");
184
184
  this.log.info(`[✔] Kuzzle ${this.version} is ready (node name: ${this.id})`);
185
185
  // @deprecated
186
- this.emit('core:kuzzleStart', 'Kuzzle is ready to accept requests');
186
+ this.emit("core:kuzzleStart", "Kuzzle is ready to accept requests");
187
187
  this._state = kuzzleStateEnum_1.default.RUNNING;
188
188
  }
189
189
  catch (error) {
@@ -199,12 +199,12 @@ class Kuzzle extends kuzzleEventEmitter_1.default {
199
199
  async initKuzzleNode() {
200
200
  let id;
201
201
  if (this.config.cluster.enabled) {
202
- id = await (new cluster_1.default()).init();
203
- this.log.info('[✔] Cluster initialized');
202
+ id = await new cluster_1.default().init();
203
+ this.log.info("[✔] Cluster initialized");
204
204
  }
205
205
  else {
206
- id = name_generator_1.NameGenerator.generateRandomName({ prefix: 'knode' });
207
- this.log.info('[X] Cluster disabled: single node mode.');
206
+ id = name_generator_1.NameGenerator.generateRandomName({ prefix: "knode" });
207
+ this.log.info("[X] Cluster disabled: single node mode.");
208
208
  }
209
209
  return id;
210
210
  }
@@ -215,17 +215,17 @@ class Kuzzle extends kuzzleEventEmitter_1.default {
215
215
  */
216
216
  async shutdown() {
217
217
  this._state = kuzzleStateEnum_1.default.SHUTTING_DOWN;
218
- this.log.info('Initiating shutdown...');
218
+ this.log.info("Initiating shutdown...");
219
219
  // Ask the network layer to stop accepting new request
220
- this.entryPoint.dispatch('shutdown');
221
- await this.pipe('kuzzle:shutdown');
220
+ this.entryPoint.dispatch("shutdown");
221
+ await this.pipe("kuzzle:shutdown");
222
222
  // @deprecated
223
- this.emit('core:shutdown');
223
+ this.emit("core:shutdown");
224
224
  while (this.funnel.remainingRequests !== 0) {
225
225
  this.log.info(`[shutdown] Waiting: ${this.funnel.remainingRequests} remaining requests`);
226
226
  await bluebird_1.default.delay(1000);
227
227
  }
228
- this.log.info('Halted.');
228
+ this.log.info("Halted.");
229
229
  process.exit(0);
230
230
  }
231
231
  /**
@@ -239,22 +239,22 @@ class Kuzzle extends kuzzleEventEmitter_1.default {
239
239
  if (!installations || !installations.length) {
240
240
  return;
241
241
  }
242
- const mutex = new mutex_1.Mutex('backend:installations');
242
+ const mutex = new mutex_1.Mutex("backend:installations");
243
243
  await mutex.lock();
244
244
  try {
245
245
  for (const installation of installations) {
246
- const isAlreadyInstalled = await this.ask('core:storage:private:document:exist', 'kuzzle', 'installations', installation.id);
246
+ const isAlreadyInstalled = await this.ask("core:storage:private:document:exist", "kuzzle", "installations", installation.id);
247
247
  if (!isAlreadyInstalled) {
248
248
  try {
249
249
  await installation.handler();
250
250
  }
251
251
  catch (error) {
252
- throw kerror.get('plugin', 'runtime', 'unexpected_installation_error', installation.id, error);
252
+ throw kerror.get("plugin", "runtime", "unexpected_installation_error", installation.id, error);
253
253
  }
254
- await this.ask('core:storage:private:document:create', 'kuzzle', 'installations', {
254
+ await this.ask("core:storage:private:document:create", "kuzzle", "installations", {
255
255
  description: installation.description,
256
256
  handler: installation.handler.toString(),
257
- installedAt: Date.now()
257
+ installedAt: Date.now(),
258
258
  }, { id: installation.id });
259
259
  this.log.info(`[✔] Install code "${installation.id}" successfully executed`);
260
260
  }
@@ -282,19 +282,19 @@ class Kuzzle extends kuzzleEventEmitter_1.default {
282
282
  }
283
283
  const toImport = config.toImport;
284
284
  if (!lodash_1.default.isEmpty(toImport.userMappings)) {
285
- await this.internalIndex.updateMapping('users', toImport.userMappings);
286
- await this.internalIndex.refreshCollection('users');
287
- this.log.info('[✔] User mappings import successful');
285
+ await this.internalIndex.updateMapping("users", toImport.userMappings);
286
+ await this.internalIndex.refreshCollection("users");
287
+ this.log.info("[✔] User mappings import successful");
288
288
  }
289
289
  }
290
290
  async importMappings(config, status) {
291
291
  const toImport = config.toImport;
292
292
  const toSupport = config.toSupport;
293
293
  if (!lodash_1.default.isEmpty(toSupport.mappings) && !lodash_1.default.isEmpty(toImport.mappings)) {
294
- throw kerror.get('plugin', 'runtime', 'incompatible', '_support.mappings', 'import.mappings');
294
+ throw kerror.get("plugin", "runtime", "incompatible", "_support.mappings", "import.mappings");
295
295
  }
296
296
  else if (!lodash_1.default.isEmpty(toSupport.mappings)) {
297
- await this.ask('core:storage:public:mappings:import', toSupport.mappings, {
297
+ await this.ask("core:storage:public:mappings:import", toSupport.mappings, {
298
298
  /**
299
299
  * If it's the first time the mapping are loaded and another node is already importing the mapping into the database
300
300
  * we just want to load the mapping in our own index cache and not in the database.
@@ -304,10 +304,10 @@ class Kuzzle extends kuzzleEventEmitter_1.default {
304
304
  rawMappings: true,
305
305
  refresh: true,
306
306
  });
307
- this.log.info('[✔] Mappings import successful');
307
+ this.log.info("[✔] Mappings import successful");
308
308
  }
309
309
  else if (!lodash_1.default.isEmpty(toImport.mappings)) {
310
- await this.ask('core:storage:public:mappings:import', toImport.mappings, {
310
+ await this.ask("core:storage:public:mappings:import", toImport.mappings, {
311
311
  /**
312
312
  * If it's the first time the mapping are loaded and another node is already importing the mapping into the database
313
313
  * we just want to load the mapping in our own index cache and not in the database.
@@ -316,7 +316,7 @@ class Kuzzle extends kuzzleEventEmitter_1.default {
316
316
  propagate: false,
317
317
  refresh: true,
318
318
  });
319
- this.log.info('[✔] Mappings import successful');
319
+ this.log.info("[✔] Mappings import successful");
320
320
  }
321
321
  }
322
322
  async importFixtures(config, status) {
@@ -325,8 +325,8 @@ class Kuzzle extends kuzzleEventEmitter_1.default {
325
325
  }
326
326
  const toSupport = config.toSupport;
327
327
  if (!lodash_1.default.isEmpty(toSupport.fixtures)) {
328
- await this.ask('core:storage:public:document:import', toSupport.fixtures);
329
- this.log.info('[✔] Fixtures import successful');
328
+ await this.ask("core:storage:public:document:import", toSupport.fixtures);
329
+ this.log.info("[✔] Fixtures import successful");
330
330
  }
331
331
  }
332
332
  async importPermissions(config, status) {
@@ -335,34 +335,34 @@ class Kuzzle extends kuzzleEventEmitter_1.default {
335
335
  }
336
336
  const toImport = config.toImport;
337
337
  const toSupport = config.toSupport;
338
- const isPermissionsToImport = !(lodash_1.default.isEmpty(toImport.profiles)
339
- && lodash_1.default.isEmpty(toImport.roles)
340
- && lodash_1.default.isEmpty(toImport.users));
341
- const isPermissionsToSupport = toSupport.securities
342
- && !(lodash_1.default.isEmpty(toSupport.securities.profiles)
343
- && lodash_1.default.isEmpty(toSupport.securities.roles)
344
- && lodash_1.default.isEmpty(toSupport.securities.users));
338
+ const isPermissionsToImport = !(lodash_1.default.isEmpty(toImport.profiles) &&
339
+ lodash_1.default.isEmpty(toImport.roles) &&
340
+ lodash_1.default.isEmpty(toImport.users));
341
+ const isPermissionsToSupport = toSupport.securities &&
342
+ !(lodash_1.default.isEmpty(toSupport.securities.profiles) &&
343
+ lodash_1.default.isEmpty(toSupport.securities.roles) &&
344
+ lodash_1.default.isEmpty(toSupport.securities.users));
345
345
  if (isPermissionsToSupport && isPermissionsToImport) {
346
- throw kerror.get('plugin', 'runtime', 'incompatible', '_support.securities', 'import profiles roles or users');
346
+ throw kerror.get("plugin", "runtime", "incompatible", "_support.securities", "import profiles roles or users");
347
347
  }
348
348
  else if (isPermissionsToSupport) {
349
- await this.ask('core:security:load', toSupport.securities, {
349
+ await this.ask("core:security:load", toSupport.securities, {
350
350
  force: true,
351
- refresh: 'wait_for'
351
+ refresh: "wait_for",
352
352
  });
353
- this.log.info('[✔] Securities import successful');
353
+ this.log.info("[✔] Securities import successful");
354
354
  }
355
355
  else if (isPermissionsToImport) {
356
- await this.ask('core:security:load', {
356
+ await this.ask("core:security:load", {
357
357
  profiles: toImport.profiles,
358
358
  roles: toImport.roles,
359
359
  users: toImport.users,
360
360
  }, {
361
361
  onExistingUsers: toImport.onExistingUsers,
362
362
  onExistingUsersWarning: true,
363
- refresh: 'wait_for',
363
+ refresh: "wait_for",
364
364
  });
365
- this.log.info('[✔] Permissions import successful');
365
+ this.log.info("[✔] Permissions import successful");
366
366
  }
367
367
  }
368
368
  /**
@@ -372,7 +372,7 @@ class Kuzzle extends kuzzleEventEmitter_1.default {
372
372
  const importTypes = Object.keys(this.importTypes);
373
373
  for (const importType of importTypes) {
374
374
  // If the import is done, we pop it from the queue to check the next one
375
- if (await this.ask('core:cache:internal:get', `${exports.BACKEND_IMPORT_KEY}:${importType}`)) {
375
+ if (await this.ask("core:cache:internal:get", `${exports.BACKEND_IMPORT_KEY}:${importType}`)) {
376
376
  return;
377
377
  }
378
378
  await bluebird_1.default.delay(1000);
@@ -387,14 +387,14 @@ class Kuzzle extends kuzzleEventEmitter_1.default {
387
387
  * @returns {Promise<void>}
388
388
  */
389
389
  async loadInitialState(toImport = {}, toSupport = {}) {
390
- if (lodash_1.default.isEmpty(toImport.mappings)
391
- && lodash_1.default.isEmpty(toImport.profiles)
392
- && lodash_1.default.isEmpty(toImport.roles)
393
- && lodash_1.default.isEmpty(toImport.userMappings)
394
- && lodash_1.default.isEmpty(toImport.users)
395
- && lodash_1.default.isEmpty(toSupport.fixtures)
396
- && lodash_1.default.isEmpty(toSupport.mappings)
397
- && lodash_1.default.isEmpty(toSupport.securities)) {
390
+ if (lodash_1.default.isEmpty(toImport.mappings) &&
391
+ lodash_1.default.isEmpty(toImport.profiles) &&
392
+ lodash_1.default.isEmpty(toImport.roles) &&
393
+ lodash_1.default.isEmpty(toImport.userMappings) &&
394
+ lodash_1.default.isEmpty(toImport.users) &&
395
+ lodash_1.default.isEmpty(toSupport.fixtures) &&
396
+ lodash_1.default.isEmpty(toSupport.mappings) &&
397
+ lodash_1.default.isEmpty(toSupport.securities)) {
398
398
  return;
399
399
  }
400
400
  const lockedMutex = [];
@@ -402,23 +402,23 @@ class Kuzzle extends kuzzleEventEmitter_1.default {
402
402
  for (const [type, importMethod] of Object.entries(this.importTypes)) {
403
403
  const importPayload = {};
404
404
  switch (type) {
405
- case 'fixtures':
406
- lodash_1.default.set(importPayload, 'toSupport.fixtures', toSupport.fixtures);
405
+ case "fixtures":
406
+ lodash_1.default.set(importPayload, "toSupport.fixtures", toSupport.fixtures);
407
407
  break;
408
- case 'mappings':
409
- lodash_1.default.set(importPayload, 'toSupport.mappings', toSupport.mappings);
410
- lodash_1.default.set(importPayload, 'toImport.mappings', toImport.mappings);
408
+ case "mappings":
409
+ lodash_1.default.set(importPayload, "toSupport.mappings", toSupport.mappings);
410
+ lodash_1.default.set(importPayload, "toImport.mappings", toImport.mappings);
411
411
  break;
412
- case 'permissions':
413
- lodash_1.default.set(importPayload, 'toSupport.securities', toSupport.securities);
414
- lodash_1.default.set(importPayload, 'toImport.profiles', toImport.profiles);
415
- lodash_1.default.set(importPayload, 'toImport.roles', toImport.roles);
416
- lodash_1.default.set(importPayload, 'toImport.users', toImport.users);
412
+ case "permissions":
413
+ lodash_1.default.set(importPayload, "toSupport.securities", toSupport.securities);
414
+ lodash_1.default.set(importPayload, "toImport.profiles", toImport.profiles);
415
+ lodash_1.default.set(importPayload, "toImport.roles", toImport.roles);
416
+ lodash_1.default.set(importPayload, "toImport.users", toImport.users);
417
417
  break;
418
418
  }
419
419
  const importPayloadHash = (0, crypto_1.sha256)((0, json_stable_stringify_1.default)(importPayload));
420
420
  const mutex = new mutex_1.Mutex(`backend:import:${type}`, { timeout: 0 });
421
- const existingHash = await this.ask('core:cache:internal:get', `${exports.BACKEND_IMPORT_KEY}:${type}`);
421
+ const existingHash = await this.ask("core:cache:internal:get", `${exports.BACKEND_IMPORT_KEY}:${type}`);
422
422
  const initialized = existingHash === importPayloadHash;
423
423
  const locked = await mutex.lock();
424
424
  await importMethod({ toImport, toSupport }, {
@@ -428,14 +428,14 @@ class Kuzzle extends kuzzleEventEmitter_1.default {
428
428
  });
429
429
  if (!initialized && locked) {
430
430
  lockedMutex.push(mutex);
431
- await this.ask('core:cache:internal:store', `${exports.BACKEND_IMPORT_KEY}:${type}`, importPayloadHash);
431
+ await this.ask("core:cache:internal:store", `${exports.BACKEND_IMPORT_KEY}:${type}`, importPayloadHash);
432
432
  }
433
433
  }
434
434
  await this._waitForImportToFinish();
435
- this.log.info('[✔] Import successful');
435
+ this.log.info("[✔] Import successful");
436
436
  }
437
437
  finally {
438
- await Promise.all(lockedMutex.map(mutex => mutex.unlock()));
438
+ await Promise.all(lockedMutex.map((mutex) => mutex.unlock()));
439
439
  }
440
440
  }
441
441
  dump(suffix) {
@@ -444,22 +444,22 @@ class Kuzzle extends kuzzleEventEmitter_1.default {
444
444
  hash(input) {
445
445
  let inString;
446
446
  switch (typeof input) {
447
- case 'string':
448
- case 'number':
449
- case 'boolean':
447
+ case "string":
448
+ case "number":
449
+ case "boolean":
450
450
  inString = input;
451
451
  break;
452
452
  default:
453
453
  inString = (0, json_stable_stringify_1.default)(input);
454
454
  }
455
- return (0, murmurhash_native_1.murmurHash128)(Buffer.from(inString), 'hex', this.config.internal.hash.seed);
455
+ return (0, murmurhash_native_1.murmurHash128)(Buffer.from(inString), "hex", this.config.internal.hash.seed);
456
456
  }
457
457
  get state() {
458
458
  return this._state;
459
459
  }
460
460
  set state(value) {
461
461
  this._state = value;
462
- this.emit('kuzzle:state:change', value);
462
+ this.emit("kuzzle:state:change", value);
463
463
  }
464
464
  /**
465
465
  * Register handlers and do a kuzzle dump for:
@@ -468,8 +468,8 @@ class Kuzzle extends kuzzleEventEmitter_1.default {
468
468
  * - uncaught-exception
469
469
  */
470
470
  registerSignalHandlers() {
471
- process.removeAllListeners('unhandledRejection');
472
- process.on('unhandledRejection', (reason, promise) => {
471
+ process.removeAllListeners("unhandledRejection");
472
+ process.on("unhandledRejection", (reason, promise) => {
473
473
  if (reason !== undefined) {
474
474
  if (reason instanceof Error) {
475
475
  this.log.error(`ERROR: unhandledRejection: ${reason.message}. Reason: ${reason.stack}`);
@@ -484,33 +484,33 @@ class Kuzzle extends kuzzleEventEmitter_1.default {
484
484
  // Crashing on an unhandled rejection is a good idea during development
485
485
  // as it helps spotting code errors. And according to the warning messages,
486
486
  // this is what Node.js will do automatically in future versions anyway.
487
- if (global.NODE_ENV === 'development') {
488
- this.log.error('Kuzzle caught an unhandled rejected promise and will shutdown.');
487
+ if (global.NODE_ENV === "development") {
488
+ this.log.error("Kuzzle caught an unhandled rejected promise and will shutdown.");
489
489
  this.log.error('This behavior is only triggered if global.NODE_ENV is set to "development"');
490
490
  throw reason;
491
491
  }
492
492
  });
493
- process.removeAllListeners('uncaughtException');
494
- process.on('uncaughtException', err => {
493
+ process.removeAllListeners("uncaughtException");
494
+ process.on("uncaughtException", (err) => {
495
495
  this.log.error(`ERROR: uncaughtException: ${err.message}\n${err.stack}`);
496
- this.dumpAndExit('uncaught-exception');
496
+ this.dumpAndExit("uncaught-exception");
497
497
  });
498
498
  // abnormal termination signals => generate a core dump
499
- for (const signal of ['SIGQUIT', 'SIGABRT']) {
499
+ for (const signal of ["SIGQUIT", "SIGABRT"]) {
500
500
  process.removeAllListeners(signal);
501
501
  process.on(signal, () => {
502
502
  this.log.error(`ERROR: Caught signal: ${signal}`);
503
- this.dumpAndExit('signal-'.concat(signal.toLowerCase()));
503
+ this.dumpAndExit("signal-".concat(signal.toLowerCase()));
504
504
  });
505
505
  }
506
506
  // signal SIGTRAP is used to generate a kuzzle dump without stopping it
507
- process.removeAllListeners('SIGTRAP');
508
- process.on('SIGTRAP', () => {
509
- this.log.error('Caught signal SIGTRAP => generating a core dump');
510
- this.dump('signal-sigtrap');
507
+ process.removeAllListeners("SIGTRAP");
508
+ process.on("SIGTRAP", () => {
509
+ this.log.error("Caught signal SIGTRAP => generating a core dump");
510
+ this.dump("signal-sigtrap");
511
511
  });
512
512
  // gracefully exits on normal termination
513
- for (const signal of ['SIGINT', 'SIGTERM']) {
513
+ for (const signal of ["SIGINT", "SIGTERM"]) {
514
514
  process.removeAllListeners(signal);
515
515
  process.on(signal, () => {
516
516
  this.log.info(`Caught signal ${signal} => gracefully exit`);
@@ -19,7 +19,7 @@
19
19
  * limitations under the License.
20
20
  */
21
21
 
22
- 'use strict';
22
+ "use strict";
23
23
 
24
24
  /**
25
25
  * @typedef {number} kuzzleStateEnum
package/lib/kuzzle/log.js CHANGED
@@ -19,25 +19,25 @@
19
19
  * limitations under the License.
20
20
  */
21
21
 
22
- 'use strict';
22
+ "use strict";
23
23
 
24
24
  class Logger {
25
- constructor () {
26
- this.logMethods = ['info', 'warn', 'error', 'silly', 'debug', 'verbose'];
25
+ constructor() {
26
+ this.logMethods = ["info", "warn", "error", "silly", "debug", "verbose"];
27
27
 
28
28
  this.failsafeModeString = global.kuzzle.config.plugins.common.failsafeMode
29
- ? '[FAILSAFE MODE] '
30
- : '';
29
+ ? "[FAILSAFE MODE] "
30
+ : "";
31
31
 
32
32
  this._useConsole();
33
33
 
34
- global.kuzzle.once('core:kuzzleStart', this._useLogger.bind(this));
34
+ global.kuzzle.once("core:kuzzleStart", this._useLogger.bind(this));
35
35
  }
36
36
 
37
- _useConsole () {
37
+ _useConsole() {
38
38
  // until kuzzle has started, use the console to print logs
39
39
  for (const method of this.logMethods) {
40
- this[method] = message => {
40
+ this[method] = (message) => {
41
41
  /* eslint-disable-next-line no-console */
42
42
  const writer = console[method] || console.log;
43
43
 
@@ -46,20 +46,25 @@ class Logger {
46
46
  }
47
47
  }
48
48
 
49
- _useLogger () {
50
-
49
+ _useLogger() {
51
50
  // when kuzzle has started, use the event to dispatch logs
52
51
  for (const method of this.logMethods) {
53
- this[method] = message => {
54
- if ( global.kuzzle.asyncStore.exists()
55
- && global.kuzzle.asyncStore.has('REQUEST')
52
+ this[method] = (message) => {
53
+ if (
54
+ global.kuzzle.asyncStore.exists() &&
55
+ global.kuzzle.asyncStore.has("REQUEST")
56
56
  ) {
57
- const request = global.kuzzle.asyncStore.get('REQUEST');
57
+ const request = global.kuzzle.asyncStore.get("REQUEST");
58
58
 
59
- global.kuzzle.emit(`log:${method}`, `[${global.kuzzle.id}] ${this.failsafeModeString}[${request.id}] ${message}`);
60
- }
61
- else {
62
- global.kuzzle.emit(`log:${method}`, `[${global.kuzzle.id}] ${this.failsafeModeString}${message}`);
59
+ global.kuzzle.emit(
60
+ `log:${method}`,
61
+ `[${global.kuzzle.id}] ${this.failsafeModeString}[${request.id}] ${message}`
62
+ );
63
+ } else {
64
+ global.kuzzle.emit(
65
+ `log:${method}`,
66
+ `[${global.kuzzle.id}] ${this.failsafeModeString}${message}`
67
+ );
63
68
  }
64
69
  };
65
70
  }
@@ -19,48 +19,63 @@
19
19
  * limitations under the License.
20
20
  */
21
21
 
22
- 'use strict';
22
+ "use strict";
23
23
 
24
- const assert = require('assert');
25
- const fs = require('fs');
26
- const path = require('path');
27
- const _ = require('lodash');
28
- const { Vault } = require('kuzzle-vault');
24
+ const assert = require("assert");
25
+ const fs = require("fs");
26
+ const path = require("path");
27
+ const _ = require("lodash");
28
+ const { Vault } = require("kuzzle-vault");
29
29
 
30
- function load (vaultKey, secretsFile) {
30
+ // The Vault package remove the variable from env after reading it and we have
31
+ // to instantiate the Vault two times with Kaaf (one before init and one after)
32
+ let ENV_VAULT_KEY;
33
+
34
+ function load(vaultKey, secretsFile) {
31
35
  // Using KaaF kuzzle is an npm package and is located under node_modules folder
32
36
  // We need to get back to root folder of the project to get the secret file
33
- const defaultEncryptedSecretsFile = __dirname.endsWith('/node_modules/kuzzle/lib/kuzzle') ?
34
- path.resolve(`${__dirname}/../../../../config/secrets.enc.json`) :
35
- path.resolve(`${__dirname}/../../config/secrets.enc.json`);
37
+ const defaultEncryptedSecretsFile = __dirname.endsWith(
38
+ "/node_modules/kuzzle/lib/kuzzle"
39
+ )
40
+ ? path.resolve(`${__dirname}/../../../../config/secrets.enc.json`)
41
+ : path.resolve(`${__dirname}/../../config/secrets.enc.json`);
36
42
 
37
43
  const encryptedSecretsFile =
38
- secretsFile || process.env.KUZZLE_SECRETS_FILE || defaultEncryptedSecretsFile;
44
+ secretsFile ||
45
+ process.env.KUZZLE_SECRETS_FILE ||
46
+ defaultEncryptedSecretsFile;
39
47
 
40
48
  let key = vaultKey;
41
- if (_.isEmpty(vaultKey) && ! _.isEmpty(process.env.KUZZLE_VAULT_KEY)) {
42
- key = process.env.KUZZLE_VAULT_KEY;
49
+ if (
50
+ _.isEmpty(vaultKey) &&
51
+ (!_.isEmpty(process.env.KUZZLE_VAULT_KEY) || !_.isEmpty(ENV_VAULT_KEY))
52
+ ) {
53
+ // Keep the vault key value when reading it from the env
54
+ key = ENV_VAULT_KEY = process.env.KUZZLE_VAULT_KEY || ENV_VAULT_KEY;
43
55
  }
44
56
 
45
57
  const fileExists = fs.existsSync(encryptedSecretsFile);
46
58
  // Abort if a custom secrets file has been provided but Kuzzle can't load it
47
- if (! _.isEmpty(process.env.KUZZLE_SECRETS_FILE) || ! _.isEmpty(secretsFile)) {
59
+ if (!_.isEmpty(process.env.KUZZLE_SECRETS_FILE) || !_.isEmpty(secretsFile)) {
48
60
  assert(
49
61
  fileExists,
50
- `A secret file has been provided but Kuzzle cannot find it at "${encryptedSecretsFile}".`);
62
+ `A secret file has been provided but Kuzzle cannot find it at "${encryptedSecretsFile}".`
63
+ );
51
64
  }
52
65
 
53
66
  // Abort if a secret file is found (default or custom)
54
67
  // but no vault key has been provided
55
68
  assert(
56
- ! (fileExists && _.isEmpty(key)),
57
- 'A secret file has been provided but Kuzzle cannot find the Vault key. Aborting.');
69
+ !(fileExists && _.isEmpty(key)),
70
+ "A secret file has been provided but Kuzzle cannot find the Vault key. Aborting."
71
+ );
58
72
 
59
73
  // Abort if a vault key has been provided
60
74
  // but no secrets file can be loaded (default or custom)
61
75
  assert(
62
- ! (! _.isEmpty(key) && ! fileExists),
63
- `A Vault key is present but Kuzzle cannot find the secret file at "${encryptedSecretsFile}". Aborting.`);
76
+ !(!_.isEmpty(key) && !fileExists),
77
+ `A Vault key is present but Kuzzle cannot find the secret file at "${encryptedSecretsFile}". Aborting.`
78
+ );
64
79
 
65
80
  const vault = new Vault(key);
66
81
 
@@ -1,6 +1,6 @@
1
- import { Policy, OptimizedPolicy, OptimizedPolicyRestrictions } from '../../types/index';
2
- import { Role } from './role';
3
- import { KuzzleRequest } from '../../../index';
1
+ import { Policy, OptimizedPolicy, OptimizedPolicyRestrictions } from "../../types/index";
2
+ import { Role } from "./role";
3
+ import { KuzzleRequest } from "../../../index";
4
4
  /** @internal */
5
5
  declare type InternalProfilePolicy = {
6
6
  role: Role;