kuzzle 2.56.0 → 2.57.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/copy-binaries.js +71 -4
- package/dist/bin/start-kuzzle-server +191 -97
- package/dist/index.d.ts +31 -1
- package/dist/index.js +45 -2
- package/dist/lib/api/controllers/adminController.d.ts +4 -3
- package/dist/lib/api/controllers/adminController.js +1 -2
- package/dist/lib/api/controllers/authController.d.ts +37 -16
- package/dist/lib/api/controllers/authController.js +88 -39
- package/dist/lib/api/controllers/baseController.d.ts +10 -5
- package/dist/lib/api/controllers/baseController.js +36 -15
- package/dist/lib/api/controllers/bulkController.d.ts +11 -7
- package/dist/lib/api/controllers/bulkController.js +28 -5
- package/dist/lib/api/controllers/clusterController.d.ts +2 -2
- package/dist/lib/api/controllers/clusterController.js +3 -3
- package/dist/lib/api/controllers/collectionController.d.ts +57 -21
- package/dist/lib/api/controllers/collectionController.js +40 -11
- package/dist/lib/api/controllers/debugController.d.ts +1 -1
- package/dist/lib/api/controllers/documentController.d.ts +137 -28
- package/dist/lib/api/controllers/documentController.js +156 -125
- package/dist/lib/api/controllers/index.d.ts +27 -12
- package/dist/lib/api/controllers/index.js +28 -13
- package/dist/lib/api/controllers/indexController.d.ts +17 -10
- package/dist/lib/api/controllers/indexController.js +13 -11
- package/dist/lib/api/controllers/memoryStorageController.d.ts +2 -5
- package/dist/lib/api/controllers/memoryStorageController.js +199 -127
- package/dist/lib/api/controllers/realtimeController.d.ts +19 -9
- package/dist/lib/api/controllers/realtimeController.js +8 -4
- package/dist/lib/api/controllers/securityController.d.ts +42 -29
- package/dist/lib/api/controllers/securityController.js +35 -19
- package/dist/lib/api/controllers/serverController.d.ts +114 -19
- package/dist/lib/api/controllers/serverController.js +69 -29
- package/dist/lib/api/documentExtractor.d.ts +9 -7
- package/dist/lib/api/documentExtractor.js +105 -41
- package/dist/lib/api/funnel.d.ts +131 -29
- package/dist/lib/api/funnel.js +436 -225
- package/dist/lib/api/httpRoutes.d.ts +16 -11
- package/dist/lib/api/httpRoutes.js +272 -2
- package/dist/lib/api/openapi/OpenApiManager.d.ts +1 -1
- package/dist/lib/api/openapi/openApiGenerator.d.ts +1 -1
- package/dist/lib/api/rateLimiter.d.ts +15 -5
- package/dist/lib/api/rateLimiter.js +42 -14
- package/dist/lib/api/request/kuzzleRequest.d.ts +83 -12
- package/dist/lib/api/request/kuzzleRequest.js +88 -23
- package/dist/lib/api/request/requestContext.d.ts +20 -5
- package/dist/lib/api/request/requestContext.js +14 -4
- package/dist/lib/api/request/requestInput.d.ts +37 -6
- package/dist/lib/api/request/requestInput.js +22 -9
- package/dist/lib/api/request/requestResponse.d.ts +45 -9
- package/dist/lib/api/request/requestResponse.js +34 -3
- package/dist/lib/cluster/command.d.ts +131 -37
- package/dist/lib/cluster/command.js +243 -71
- package/dist/lib/cluster/idCardHandler.d.ts +18 -5
- package/dist/lib/cluster/idCardHandler.js +52 -19
- package/dist/lib/cluster/index.d.ts +8 -2
- package/dist/lib/cluster/index.js +6 -2
- package/dist/lib/cluster/node.d.ts +127 -49
- package/dist/lib/cluster/node.js +412 -179
- package/dist/lib/cluster/protobuf/command.proto +18 -0
- package/dist/lib/cluster/protobuf/commandMessages.d.ts +104 -0
- package/dist/lib/cluster/protobuf/commandMessages.js +30 -0
- package/dist/lib/cluster/protobuf/syncMessages.d.ts +184 -0
- package/dist/lib/cluster/protobuf/syncMessages.js +23 -0
- package/dist/lib/cluster/publisher.d.ts +118 -78
- package/dist/lib/cluster/publisher.js +174 -72
- package/dist/lib/cluster/state.d.ts +15 -9
- package/dist/lib/cluster/state.js +12 -8
- package/dist/lib/cluster/subscriber.d.ts +185 -131
- package/dist/lib/cluster/subscriber.js +357 -95
- package/dist/lib/cluster/workers/IDCardRenewer.d.ts +39 -8
- package/dist/lib/cluster/workers/IDCardRenewer.js +88 -23
- package/dist/lib/config/default.config.d.ts +2 -2
- package/dist/lib/config/default.config.js +10 -3
- package/dist/lib/config/documentEventAliases.d.ts +1 -1
- package/dist/lib/config/index.d.ts +2 -5
- package/dist/lib/config/index.js +30 -17
- package/dist/lib/core/auth/formatProcessing.d.ts +3 -3
- package/dist/lib/core/auth/passportResponse.d.ts +1 -1
- package/dist/lib/core/auth/passportWrapper.d.ts +1 -1
- package/dist/lib/core/auth/passportWrapper.js +14 -13
- package/dist/lib/core/auth/tokenManager.d.ts +24 -3
- package/dist/lib/core/auth/tokenManager.js +47 -19
- package/dist/lib/core/backend/applicationManager.d.ts +2 -2
- package/dist/lib/core/backend/backend.d.ts +16 -5
- package/dist/lib/core/backend/backend.js +14 -6
- package/dist/lib/core/backend/backendCluster.d.ts +1 -1
- package/dist/lib/core/backend/backendConfig.d.ts +17 -5
- package/dist/lib/core/backend/backendConfig.js +1 -0
- package/dist/lib/core/backend/backendController.d.ts +1 -1
- package/dist/lib/core/backend/backendController.js +8 -1
- package/dist/lib/core/backend/backendErrors.d.ts +15 -8
- package/dist/lib/core/backend/backendErrors.js +5 -0
- package/dist/lib/core/backend/backendHook.d.ts +1 -1
- package/dist/lib/core/backend/backendImport.d.ts +1 -1
- package/dist/lib/core/backend/backendOpenApi.d.ts +3 -2
- package/dist/lib/core/backend/backendPipe.d.ts +1 -1
- package/dist/lib/core/backend/backendPipe.js +9 -1
- package/dist/lib/core/backend/backendPlugin.d.ts +2 -2
- package/dist/lib/core/backend/backendSubscription.d.ts +2 -2
- package/dist/lib/core/backend/backendVault.d.ts +1 -1
- package/dist/lib/core/backend/backendVault.js +8 -1
- package/dist/lib/core/cache/cacheEngine.d.ts +7 -4
- package/dist/lib/core/cache/cacheEngine.js +25 -8
- package/dist/lib/core/debug/kuzzleDebugger.d.ts +2 -1
- package/dist/lib/core/debug/kuzzleDebugger.js +31 -17
- package/dist/lib/core/network/accessLogger.d.ts +33 -18
- package/dist/lib/core/network/accessLogger.js +135 -73
- package/dist/lib/core/network/clientConnection.d.ts +13 -11
- package/dist/lib/core/network/clientConnection.js +33 -9
- package/dist/lib/core/network/context.d.ts +17 -22
- package/dist/lib/core/network/context.js +43 -26
- package/dist/lib/core/network/entryPoint.d.ts +38 -16
- package/dist/lib/core/network/entryPoint.js +119 -48
- package/dist/lib/core/network/httpRouter/index.d.ts +20 -50
- package/dist/lib/core/network/httpRouter/index.js +61 -75
- package/dist/lib/core/network/httpRouter/routeHandler.d.ts +17 -32
- package/dist/lib/core/network/httpRouter/routeHandler.js +26 -36
- package/dist/lib/core/network/httpRouter/routePart.d.ts +9 -18
- package/dist/lib/core/network/httpRouter/routePart.js +61 -43
- package/dist/lib/core/network/httpRouter/routeTypes.d.ts +3 -0
- package/dist/lib/core/network/httpRouter/routeTypes.js +23 -0
- package/dist/lib/core/network/networkEntryPoint.d.ts +20 -0
- package/dist/lib/core/network/networkEntryPoint.js +23 -0
- package/dist/lib/core/network/protocolManifest.d.ts +5 -4
- package/dist/lib/core/network/protocolManifest.js +6 -3
- package/dist/lib/core/network/protocols/httpMessage.d.ts +25 -18
- package/dist/lib/core/network/protocols/httpMessage.js +14 -11
- package/dist/lib/core/network/protocols/httpwsProtocol.d.ts +84 -93
- package/dist/lib/core/network/protocols/httpwsProtocol.js +284 -129
- package/dist/lib/core/network/protocols/internalProtocol.d.ts +26 -15
- package/dist/lib/core/network/protocols/internalProtocol.js +17 -16
- package/dist/lib/core/network/protocols/mqttProtocol.d.ts +56 -32
- package/dist/lib/core/network/protocols/mqttProtocol.js +91 -44
- package/dist/lib/core/network/protocols/protocol.d.ts +85 -21
- package/dist/lib/core/network/protocols/protocol.js +83 -27
- package/dist/lib/core/network/router.d.ts +13 -22
- package/dist/lib/core/network/router.js +59 -46
- package/dist/lib/core/plugin/plugin.d.ts +57 -51
- package/dist/lib/core/plugin/plugin.js +218 -103
- package/dist/lib/core/plugin/pluginContext.d.ts +54 -11
- package/dist/lib/core/plugin/pluginContext.js +99 -58
- package/dist/lib/core/plugin/pluginManifest.d.ts +6 -2
- package/dist/lib/core/plugin/pluginManifest.js +18 -11
- package/dist/lib/core/plugin/pluginRepository.d.ts +35 -44
- package/dist/lib/core/plugin/pluginRepository.js +35 -50
- package/dist/lib/core/plugin/pluginsManager.d.ts +128 -46
- package/dist/lib/core/plugin/pluginsManager.js +468 -231
- package/dist/lib/core/plugin/privilegedContext.d.ts +4 -9
- package/dist/lib/core/plugin/privilegedContext.js +5 -10
- package/dist/lib/core/realtime/actionEnum.d.ts +12 -21
- package/dist/lib/core/realtime/actionEnum.js +6 -7
- package/dist/lib/core/realtime/channel.d.ts +11 -5
- package/dist/lib/core/realtime/channel.js +17 -2
- package/dist/lib/core/realtime/connectionRooms.d.ts +2 -2
- package/dist/lib/core/realtime/hotelClerk.d.ts +12 -6
- package/dist/lib/core/realtime/hotelClerk.js +29 -11
- package/dist/lib/core/realtime/index.d.ts +8 -3
- package/dist/lib/core/realtime/index.js +12 -5
- package/dist/lib/core/realtime/notification/document.d.ts +54 -25
- package/dist/lib/core/realtime/notification/document.js +10 -13
- package/dist/lib/core/realtime/notification/index.d.ts +9 -3
- package/dist/lib/core/realtime/notification/index.js +10 -4
- package/dist/lib/core/realtime/notification/server.d.ts +7 -10
- package/dist/lib/core/realtime/notification/server.js +4 -7
- package/dist/lib/core/realtime/notification/user.d.ts +45 -21
- package/dist/lib/core/realtime/notification/user.js +8 -9
- package/dist/lib/core/realtime/notifier.d.ts +52 -40
- package/dist/lib/core/realtime/notifier.js +60 -25
- package/dist/lib/core/realtime/room.d.ts +1 -1
- package/dist/lib/core/realtime/subscription.d.ts +11 -6
- package/dist/lib/core/realtime/subscription.js +5 -1
- package/dist/lib/core/security/index.d.ts +14 -6
- package/dist/lib/core/security/index.js +27 -13
- package/dist/lib/core/security/profileRepository.d.ts +24 -19
- package/dist/lib/core/security/profileRepository.js +23 -10
- package/dist/lib/core/security/roleRepository.d.ts +60 -23
- package/dist/lib/core/security/roleRepository.js +122 -53
- package/dist/lib/core/security/securityLoader.d.ts +33 -18
- package/dist/lib/core/security/securityLoader.js +43 -16
- package/dist/lib/core/security/tokenRepository.d.ts +21 -7
- package/dist/lib/core/security/tokenRepository.js +50 -23
- package/dist/lib/core/security/userRepository.d.ts +44 -21
- package/dist/lib/core/security/userRepository.js +59 -19
- package/dist/lib/core/shared/KoncordeWrapper.d.ts +1 -1
- package/dist/lib/core/shared/ObjectRepository.d.ts +80 -18
- package/dist/lib/core/shared/ObjectRepository.js +57 -29
- package/dist/lib/core/shared/abstractManifest.d.ts +21 -8
- package/dist/lib/core/shared/abstractManifest.js +57 -17
- package/dist/lib/core/shared/sdk/embeddedSdk.d.ts +3 -1
- package/dist/lib/core/shared/sdk/embeddedSdk.js +8 -7
- package/dist/lib/core/shared/sdk/funnelProtocol.d.ts +2 -1
- package/dist/lib/core/shared/sdk/funnelProtocol.js +12 -3
- package/dist/lib/core/shared/sdk/impersonatedSdk.d.ts +11 -5
- package/dist/lib/core/shared/sdk/impersonatedSdk.js +22 -9
- package/dist/lib/core/shared/store.d.ts +45 -29
- package/dist/lib/core/shared/store.js +48 -27
- package/dist/lib/core/statistics/statistics.d.ts +1 -1
- package/dist/lib/core/storage/clientAdapter.d.ts +39 -21
- package/dist/lib/core/storage/clientAdapter.js +88 -48
- package/dist/lib/core/storage/indexCache.d.ts +8 -0
- package/dist/lib/core/storage/indexCache.js +16 -7
- package/dist/lib/core/storage/storageEngine.d.ts +7 -6
- package/dist/lib/core/storage/storageEngine.js +11 -8
- package/dist/lib/core/validation/baseType.d.ts +22 -22
- package/dist/lib/core/validation/baseType.js +11 -26
- package/dist/lib/core/validation/specification.d.ts +148 -0
- package/dist/lib/core/validation/specification.js +34 -0
- package/dist/lib/core/validation/typeOptions.d.ts +62 -0
- package/dist/lib/core/validation/typeOptions.js +23 -0
- package/dist/lib/core/validation/types/anything.d.ts +3 -6
- package/dist/lib/core/validation/types/anything.js +7 -7
- package/dist/lib/core/validation/types/boolean.d.ts +5 -12
- package/dist/lib/core/validation/types/boolean.js +7 -12
- package/dist/lib/core/validation/types/date.d.ts +19 -11
- package/dist/lib/core/validation/types/date.js +212 -161
- package/dist/lib/core/validation/types/email.d.ts +7 -11
- package/dist/lib/core/validation/types/email.js +13 -17
- package/dist/lib/core/validation/types/enum.d.ts +7 -11
- package/dist/lib/core/validation/types/enum.js +39 -20
- package/dist/lib/core/validation/types/geoPoint.d.ts +5 -13
- package/dist/lib/core/validation/types/geoPoint.js +10 -15
- package/dist/lib/core/validation/types/geoShape.d.ts +22 -21
- package/dist/lib/core/validation/types/geoShape.js +113 -129
- package/dist/lib/core/validation/types/geoShapeUtils.d.ts +15 -0
- package/dist/lib/core/validation/types/geoShapeUtils.js +75 -0
- package/dist/lib/core/validation/types/integer.d.ts +7 -5
- package/dist/lib/core/validation/types/integer.js +7 -13
- package/dist/lib/core/validation/types/ipAddress.d.ts +7 -11
- package/dist/lib/core/validation/types/ipAddress.js +13 -17
- package/dist/lib/core/validation/types/numeric.d.ts +7 -11
- package/dist/lib/core/validation/types/numeric.js +22 -29
- package/dist/lib/core/validation/types/object.d.ts +8 -15
- package/dist/lib/core/validation/types/object.js +12 -21
- package/dist/lib/core/validation/types/string.d.ts +7 -11
- package/dist/lib/core/validation/types/string.js +22 -29
- package/dist/lib/core/validation/types/url.d.ts +7 -11
- package/dist/lib/core/validation/types/url.js +14 -18
- package/dist/lib/core/validation/validation.d.ts +119 -80
- package/dist/lib/core/validation/validation.js +470 -412
- package/dist/lib/core/validation/validationUtils.d.ts +31 -0
- package/dist/lib/core/validation/validationUtils.js +190 -0
- package/dist/lib/kerror/codes/4-plugin.json +0 -12
- package/dist/lib/kerror/codes/index.d.ts +12 -2
- package/dist/lib/kerror/codes/index.js +5 -4
- package/dist/lib/kerror/errors/badRequestError.d.ts +1 -1
- package/dist/lib/kerror/errors/badRequestError.js +1 -1
- package/dist/lib/kerror/errors/externalServiceError.d.ts +1 -1
- package/dist/lib/kerror/errors/externalServiceError.js +1 -1
- package/dist/lib/kerror/errors/forbiddenError.d.ts +1 -1
- package/dist/lib/kerror/errors/forbiddenError.js +1 -1
- package/dist/lib/kerror/errors/gatewayTimeoutError.d.ts +1 -1
- package/dist/lib/kerror/errors/gatewayTimeoutError.js +1 -1
- package/dist/lib/kerror/errors/internalError.d.ts +1 -1
- package/dist/lib/kerror/errors/internalError.js +1 -1
- package/dist/lib/kerror/errors/kuzzleError.d.ts +32 -3
- package/dist/lib/kerror/errors/kuzzleError.js +21 -7
- package/dist/lib/kerror/errors/multipleErrorsError.d.ts +2 -2
- package/dist/lib/kerror/errors/multipleErrorsError.js +2 -2
- package/dist/lib/kerror/errors/notFoundError.d.ts +1 -1
- package/dist/lib/kerror/errors/notFoundError.js +1 -1
- package/dist/lib/kerror/errors/partialError.d.ts +8 -2
- package/dist/lib/kerror/errors/partialError.js +22 -9
- package/dist/lib/kerror/errors/pluginImplementationError.d.ts +9 -1
- package/dist/lib/kerror/errors/pluginImplementationError.js +9 -3
- package/dist/lib/kerror/errors/preconditionError.d.ts +1 -1
- package/dist/lib/kerror/errors/preconditionError.js +1 -1
- package/dist/lib/kerror/errors/serviceUnavailableError.d.ts +1 -1
- package/dist/lib/kerror/errors/serviceUnavailableError.js +1 -1
- package/dist/lib/kerror/errors/sizeLimitError.d.ts +1 -1
- package/dist/lib/kerror/errors/sizeLimitError.js +1 -1
- package/dist/lib/kerror/errors/tooManyRequestsError.d.ts +1 -1
- package/dist/lib/kerror/errors/tooManyRequestsError.js +1 -1
- package/dist/lib/kerror/errors/unauthorizedError.d.ts +1 -1
- package/dist/lib/kerror/errors/unauthorizedError.js +1 -1
- package/dist/lib/kerror/index.d.ts +19 -13
- package/dist/lib/kerror/index.js +60 -19
- package/dist/lib/kuzzle/Logger.d.ts +2 -2
- package/dist/lib/kuzzle/dumpGenerator.d.ts +12 -8
- package/dist/lib/kuzzle/dumpGenerator.js +130 -62
- package/dist/lib/kuzzle/event/KuzzleEventEmitter.d.ts +18 -9
- package/dist/lib/kuzzle/event/KuzzleEventEmitter.js +45 -18
- package/dist/lib/kuzzle/event/pipeRunner.d.ts +37 -16
- package/dist/lib/kuzzle/event/pipeRunner.js +73 -26
- package/dist/lib/kuzzle/event/waterfall.d.ts +11 -1
- package/dist/lib/kuzzle/event/waterfall.js +38 -13
- package/dist/lib/kuzzle/internalIndexHandler.d.ts +11 -174
- package/dist/lib/kuzzle/internalIndexHandler.js +58 -29
- package/dist/lib/kuzzle/kuzzle.d.ts +25 -10
- package/dist/lib/kuzzle/kuzzle.js +74 -17
- package/dist/lib/kuzzle/kuzzleStateEnum.d.ts +16 -12
- package/dist/lib/kuzzle/kuzzleStateEnum.js +5 -7
- package/dist/lib/kuzzle/vault.d.ts +5 -1
- package/dist/lib/kuzzle/vault.js +29 -17
- package/dist/lib/model/security/profile.d.ts +34 -5
- package/dist/lib/model/security/profile.js +6 -5
- package/dist/lib/model/security/rights.d.ts +12 -4
- package/dist/lib/model/security/rights.js +7 -6
- package/dist/lib/model/security/role.d.ts +8 -4
- package/dist/lib/model/security/role.js +12 -6
- package/dist/lib/model/security/token.d.ts +8 -0
- package/dist/lib/model/security/user.d.ts +8 -2
- package/dist/lib/model/security/user.js +7 -4
- package/dist/lib/model/storage/apiKey.d.ts +55 -26
- package/dist/lib/model/storage/apiKey.js +97 -24
- package/dist/lib/model/storage/baseModel.d.ts +77 -66
- package/dist/lib/model/storage/baseModel.js +21 -34
- package/dist/lib/service/cache/redis.d.ts +53 -36
- package/dist/lib/service/cache/redis.js +148 -71
- package/dist/lib/service/service.d.ts +14 -19
- package/dist/lib/service/service.js +41 -22
- package/dist/lib/service/storage/7/elasticsearch.d.ts +136 -93
- package/dist/lib/service/storage/7/elasticsearch.js +218 -165
- package/dist/lib/service/storage/7/esWrapper.d.ts +30 -13
- package/dist/lib/service/storage/7/esWrapper.js +58 -37
- package/dist/lib/service/storage/8/elasticsearch.d.ts +153 -119
- package/dist/lib/service/storage/8/elasticsearch.js +286 -213
- package/dist/lib/service/storage/8/esWrapper.d.ts +30 -13
- package/dist/lib/service/storage/8/esWrapper.js +59 -38
- package/dist/lib/service/storage/commons/queryTranslator.d.ts +3 -3
- package/dist/lib/service/storage/commons/queryTranslator.js +71 -35
- package/dist/lib/types/ApiRoute.d.ts +12 -0
- package/dist/lib/types/ApiRoute.js +23 -0
- package/dist/lib/types/ClientConnection.d.ts +1 -1
- package/dist/lib/types/EventHandler.d.ts +10 -0
- package/dist/lib/types/Global.d.ts +8 -3
- package/dist/lib/types/HttpMessage.d.ts +2 -2
- package/dist/lib/types/HttpStream.d.ts +1 -1
- package/dist/lib/types/HttpStream.js +3 -1
- package/dist/lib/types/JSONObject.d.ts +9 -0
- package/dist/lib/types/JSONObject.js +23 -0
- package/dist/lib/types/Kuzzle.d.ts +5 -3
- package/dist/lib/types/KuzzleDocument.d.ts +1 -1
- package/dist/lib/types/KuzzleWebSocket.d.ts +24 -0
- package/dist/lib/types/KuzzleWebSocket.js +23 -0
- package/dist/lib/types/OpenApiDefinition.d.ts +1 -1
- package/dist/lib/types/Plugin.d.ts +33 -8
- package/dist/lib/types/PluginInstance.d.ts +67 -0
- package/dist/lib/types/PluginInstance.js +23 -0
- package/dist/lib/types/Policy.d.ts +1 -1
- package/dist/lib/types/Target.d.ts +8 -0
- package/dist/lib/types/Token.d.ts +14 -2
- package/dist/lib/types/config/HttpConfiguration.d.ts +5 -0
- package/dist/lib/types/config/KuzzleConfiguration.d.ts +102 -1
- package/dist/lib/types/config/PluginsConfiguration.d.ts +3 -2
- package/dist/lib/types/config/SecurityConfiguration.d.ts +6 -2
- package/dist/lib/types/config/ServerConfiguration.d.ts +2 -2
- package/dist/lib/types/config/ServicesConfiguration.d.ts +1 -1
- package/dist/lib/types/config/cache/BaseCacheRedisConfiguration.d.ts +131 -0
- package/dist/lib/types/config/cache/BaseCacheRedisConfiguration.js +3 -0
- package/dist/lib/types/config/internalCache/InternalCacheRedisConfiguration.d.ts +2 -106
- package/dist/lib/types/config/publicCache/PublicCacheRedisConfiguration.d.ts +2 -26
- package/dist/lib/types/config/storageEngine/StorageEngineElasticsearchConfiguration.d.ts +3 -0
- package/dist/lib/types/controllers/Controller.d.ts +12 -3
- package/dist/lib/types/controllers/ControllerDefinition.d.ts +2 -2
- package/dist/lib/types/controllers/{adminControlller.type.js → adminController.type.js} +1 -1
- package/dist/lib/types/controllers/authController.type.d.ts +2 -2
- package/dist/lib/types/core/auth/formatProcessing.type.d.ts +7 -1
- package/dist/lib/types/errors/ErrorDomains.d.ts +1 -1
- package/dist/lib/types/events/EventGenericDocument.d.ts +10 -9
- package/dist/lib/types/events/EventProtocol.d.ts +4 -4
- package/dist/lib/types/index.d.ts +7 -0
- package/dist/lib/types/index.js +7 -0
- package/dist/lib/types/shared/StoreCollectionsDefinition.d.ts +1 -1
- package/dist/lib/types/storage/7/Elasticsearch.d.ts +62 -13
- package/dist/lib/types/storage/8/Elasticsearch.d.ts +62 -13
- package/dist/lib/util/Inflector.d.ts +4 -1
- package/dist/lib/util/Inflector.js +0 -3
- package/dist/lib/util/assertType.d.ts +24 -27
- package/dist/lib/util/assertType.js +28 -39
- package/dist/lib/util/async.js +19 -6
- package/dist/lib/util/asyncStore.js +1 -1
- package/dist/lib/util/bufferedPassThrough.d.ts +9 -0
- package/dist/lib/util/bufferedPassThrough.js +27 -13
- package/dist/lib/util/bytes.d.ts +1 -1
- package/dist/lib/util/bytes.js +6 -2
- package/dist/lib/util/debug.d.ts +3 -1
- package/dist/lib/util/debug.js +42 -10
- package/dist/lib/util/deprecate.d.ts +9 -1
- package/dist/lib/util/deprecate.js +10 -6
- package/dist/lib/util/didYouMean.d.ts +2 -1
- package/dist/lib/util/didYouMean.js +8 -4
- package/dist/lib/util/distributedLock.d.ts +56 -0
- package/dist/lib/util/distributedLock.js +166 -0
- package/dist/lib/util/dump-collection.d.ts +1 -1
- package/dist/lib/util/dump-collection.js +4 -5
- package/dist/lib/util/extractFields.d.ts +15 -11
- package/dist/lib/util/extractFields.js +8 -9
- package/dist/lib/util/koncordeCompat.d.ts +2 -2
- package/dist/lib/util/koncordeCompat.js +33 -0
- package/dist/lib/util/memoize.d.ts +7 -6
- package/dist/lib/util/memoize.js +3 -3
- package/dist/lib/util/mutex.d.ts +22 -2
- package/dist/lib/util/mutex.js +39 -1
- package/dist/lib/util/name-generator.js +14 -2
- package/dist/lib/util/promback.d.ts +20 -11
- package/dist/lib/util/promback.js +14 -7
- package/dist/lib/util/requestAssertions.d.ts +30 -10
- package/dist/lib/util/requestAssertions.js +125 -121
- package/dist/lib/util/safeObject.d.ts +3 -3
- package/dist/lib/util/safeObject.js +7 -3
- package/dist/lib/util/stackTrace.d.ts +13 -5
- package/dist/lib/util/stackTrace.js +17 -12
- package/dist/lib/util/thrown.d.ts +13 -0
- package/dist/lib/util/thrown.js +46 -0
- package/dist/package.json +26 -19
- package/package.json +26 -19
- package/dist/lib/util/wildcard.d.ts +0 -1
- package/dist/lib/util/wildcard.js +0 -46
- /package/dist/lib/types/controllers/{adminControlller.type.d.ts → adminController.type.d.ts} +0 -0
|
@@ -1,13 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import Redis from "../../service/cache/redis";
|
|
3
|
+
/**
|
|
4
|
+
* `redis.ts` uses `export =`, so it cannot also export this type. Deriving it
|
|
5
|
+
* from the constructor keeps it tied to the real signature instead of to a copy
|
|
6
|
+
* that can drift.
|
|
7
|
+
*/
|
|
8
|
+
type RedisServiceConfig = ConstructorParameters<typeof Redis>[0];
|
|
9
|
+
export type IDCardRenewerConfig = {
|
|
10
|
+
nodeIdKey: string;
|
|
11
|
+
refreshDelay?: number;
|
|
12
|
+
refreshMultiplier: number;
|
|
13
|
+
redis?: {
|
|
14
|
+
config: RedisServiceConfig;
|
|
15
|
+
name: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* The two commands this worker issues, and nothing else. A real `Redis` service
|
|
20
|
+
* satisfies it structurally; declaring the whole service here would make every
|
|
21
|
+
* test double carry twenty-odd members it never uses, and would hide a widening
|
|
22
|
+
* of what the worker touches.
|
|
23
|
+
*/
|
|
24
|
+
type IdCardStore = {
|
|
25
|
+
commands: {
|
|
26
|
+
pexpire(key: string, ttl: number): Promise<number>;
|
|
27
|
+
del(key: string): Promise<unknown>;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
declare class IDCardRenewer {
|
|
31
|
+
redis: IdCardStore | null;
|
|
32
|
+
refreshTimer: NodeJS.Timeout | null;
|
|
33
|
+
nodeIdKey: string | null;
|
|
5
34
|
refreshDelay: number;
|
|
35
|
+
/** Same default as `ClusterIdCardHandler`, which is what sends the real one. */
|
|
36
|
+
refreshMultiplier: number;
|
|
37
|
+
/** Disposed until `init()` says otherwise. */
|
|
6
38
|
disposed: boolean;
|
|
7
|
-
init(config:
|
|
8
|
-
|
|
9
|
-
initRedis(config: any, name: any): Promise<void>;
|
|
39
|
+
init(config: IDCardRenewerConfig): Promise<void>;
|
|
40
|
+
initRedis(config?: RedisServiceConfig, name?: string): Promise<void>;
|
|
10
41
|
renewIDCard(): Promise<void>;
|
|
11
42
|
dispose(): Promise<void>;
|
|
12
43
|
}
|
|
13
|
-
|
|
44
|
+
export { IDCardRenewer };
|
|
@@ -1,12 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.IDCardRenewer = void 0;
|
|
7
|
+
const node_util_1 = require("node:util");
|
|
8
|
+
// A default import, not `import Redis = require(...)`: the latter emits a real
|
|
9
|
+
// `require()` that vite cannot resolve for a `.ts` path, so any vitest spec
|
|
10
|
+
// reaching this module dies on "Cannot find module". It type-checks against
|
|
11
|
+
// `export =` under `esModuleInterop`. See ADR-0001, TD-49 (#2739).
|
|
12
|
+
const redis_1 = __importDefault(require("../../service/cache/redis"));
|
|
13
|
+
/**
|
|
14
|
+
* What `idCardHandler.createIdCard()` sends this worker with `action: "start"`.
|
|
15
|
+
* It is a `child_process.fork()` child, so everything here crossed an IPC
|
|
16
|
+
* boundary and is plain JSON.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* The message of whatever was thrown. `catch` answers `unknown`, and this
|
|
20
|
+
* worker reports every failure it meets to its parent as text.
|
|
21
|
+
*/
|
|
22
|
+
function messageOf(thrown) {
|
|
23
|
+
return thrown instanceof Error ? thrown.message : (0, node_util_1.inspect)(thrown);
|
|
24
|
+
}
|
|
3
25
|
class IDCardRenewer {
|
|
4
26
|
constructor() {
|
|
5
27
|
this.redis = null;
|
|
6
28
|
this.refreshTimer = null;
|
|
7
29
|
this.nodeIdKey = null;
|
|
8
30
|
this.refreshDelay = 2000;
|
|
9
|
-
|
|
31
|
+
/** Same default as `ClusterIdCardHandler`, which is what sends the real one. */
|
|
32
|
+
this.refreshMultiplier = 2;
|
|
33
|
+
/** Disposed until `init()` says otherwise. */
|
|
34
|
+
this.disposed = true;
|
|
10
35
|
}
|
|
11
36
|
async init(config) {
|
|
12
37
|
if (!this.disposed) {
|
|
@@ -21,14 +46,24 @@ class IDCardRenewer {
|
|
|
21
46
|
* so we need to have an instance of Redis similar to the one used in the Cache Engine
|
|
22
47
|
*/
|
|
23
48
|
try {
|
|
24
|
-
|
|
25
|
-
|
|
49
|
+
// `redis` is absent when the worker is started without one (the specs do
|
|
50
|
+
// it, and `initRedis` is then expected to reject) — the JS spelled this
|
|
51
|
+
// `config.redis || {}` and read two undefined fields off it.
|
|
52
|
+
const redisConf = config.redis;
|
|
53
|
+
await this.initRedis(redisConf?.config, redisConf?.name);
|
|
26
54
|
}
|
|
27
55
|
catch (error) {
|
|
28
56
|
// eslint-disable-next-line no-console
|
|
29
|
-
console.error(`Failed to connect to redis, could not refresh ID card: ${error
|
|
30
|
-
this.parentPort.postMessage
|
|
31
|
-
|
|
57
|
+
console.error(`Failed to connect to redis, could not refresh ID card: ${messageOf(error)}`);
|
|
58
|
+
// `process.send`, not `this.parentPort.postMessage`: this worker is a
|
|
59
|
+
// `child_process.fork()` child and has no `parentPort` — that is the
|
|
60
|
+
// `worker_threads` API, left behind by an earlier implementation, and the
|
|
61
|
+
// property was never assigned anywhere. The one path that exists to say
|
|
62
|
+
// *why* the ID card cannot be renewed used to raise a TypeError instead
|
|
63
|
+
// of sending `{ error }`, so the node was evicted by the `close` handler
|
|
64
|
+
// with a generic reason rather than this one. See TD-63 (#2770).
|
|
65
|
+
process.send?.({
|
|
66
|
+
error: `Failed to connect to redis, could not refresh ID card: ${messageOf(error)}`,
|
|
32
67
|
});
|
|
33
68
|
return;
|
|
34
69
|
}
|
|
@@ -41,10 +76,17 @@ class IDCardRenewer {
|
|
|
41
76
|
this.refreshTimer = setInterval(this.renewIDCard.bind(this), this.refreshDelay);
|
|
42
77
|
}
|
|
43
78
|
// Notify that the worker is running and updating the ID Card
|
|
44
|
-
process.send({ initialized: true });
|
|
79
|
+
process.send?.({ initialized: true });
|
|
45
80
|
}
|
|
46
81
|
async initRedis(config, name) {
|
|
47
|
-
|
|
82
|
+
// Rejecting here is what `init()` above reports: the worker is started
|
|
83
|
+
// without a redis configuration in the specs, and the JS read two fields
|
|
84
|
+
// off a `config.redis || {}` and handed `new Redis(undefined, undefined)`
|
|
85
|
+
// the result.
|
|
86
|
+
if (config === undefined || name === undefined) {
|
|
87
|
+
throw new Error("no redis configuration was sent to the ID card worker");
|
|
88
|
+
}
|
|
89
|
+
const redis = new redis_1.default(config, name);
|
|
48
90
|
await redis.init();
|
|
49
91
|
this.redis = redis;
|
|
50
92
|
}
|
|
@@ -52,21 +94,26 @@ class IDCardRenewer {
|
|
|
52
94
|
if (this.disposed) {
|
|
53
95
|
return; // Do not refresh ID Card when worker has been disposed
|
|
54
96
|
}
|
|
97
|
+
// Both are set by `init()`, which is the only thing that clears
|
|
98
|
+
// `disposed` above — but the timer it starts outlives a failed one.
|
|
99
|
+
if (this.redis === null || this.nodeIdKey === null) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
55
102
|
try {
|
|
56
103
|
const refreshed = await this.redis.commands.pexpire(this.nodeIdKey, this.refreshDelay * this.refreshMultiplier);
|
|
57
104
|
// Unable to refresh the key in time before it expires
|
|
58
105
|
// => this node is too slow, we need to remove it from the cluster
|
|
59
106
|
if (refreshed === 0) {
|
|
60
107
|
await this.dispose();
|
|
61
|
-
process.send({
|
|
108
|
+
process.send?.({
|
|
62
109
|
error: "Node too slow: ID card expired",
|
|
63
110
|
});
|
|
64
111
|
}
|
|
65
112
|
}
|
|
66
113
|
catch (error) {
|
|
67
114
|
await this.dispose();
|
|
68
|
-
process.send({
|
|
69
|
-
error: `Failed to refresh ID Card: ${error
|
|
115
|
+
process.send?.({
|
|
116
|
+
error: `Failed to refresh ID Card: ${messageOf(error)}`,
|
|
70
117
|
});
|
|
71
118
|
}
|
|
72
119
|
}
|
|
@@ -75,11 +122,11 @@ class IDCardRenewer {
|
|
|
75
122
|
return; // Already disposed
|
|
76
123
|
}
|
|
77
124
|
this.disposed = true;
|
|
78
|
-
clearInterval(this.refreshTimer);
|
|
125
|
+
clearInterval(this.refreshTimer ?? undefined);
|
|
79
126
|
this.refreshTimer = null;
|
|
80
127
|
// If the worker is disposed before it had time to starts, redis service
|
|
81
128
|
// may not have been initialized
|
|
82
|
-
if (!this.redis) {
|
|
129
|
+
if (!this.redis || this.nodeIdKey === null) {
|
|
83
130
|
return;
|
|
84
131
|
}
|
|
85
132
|
try {
|
|
@@ -87,23 +134,42 @@ class IDCardRenewer {
|
|
|
87
134
|
}
|
|
88
135
|
catch (error) {
|
|
89
136
|
// eslint-disable-next-line no-console
|
|
90
|
-
console.error(`Could not delete key '${this.nodeIdKey}' from redis: ${error
|
|
137
|
+
console.error(`Could not delete key '${this.nodeIdKey}' from redis: ${messageOf(error)}`);
|
|
91
138
|
}
|
|
92
139
|
}
|
|
93
140
|
}
|
|
141
|
+
exports.IDCardRenewer = IDCardRenewer;
|
|
94
142
|
const idCardRenewer = new IDCardRenewer();
|
|
95
143
|
process.on("message", async (message) => {
|
|
96
144
|
if (message.action === "start") {
|
|
97
145
|
// Simulate basic global Kuzzle Context
|
|
98
146
|
global.kuzzle = { ...message.kuzzle };
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
147
|
+
// A deliberately partial logger: this process is a `fork()` child with no
|
|
148
|
+
// Kuzzle instance, and the four console methods are all it needs. The
|
|
149
|
+
// codebase already knows — `redis.ts` branches on `global.kuzzle.log.child`
|
|
150
|
+
// being absent for exactly this case — but the type does not: `log` is
|
|
151
|
+
// declared `Logger`. Assigned through `Object.assign` rather than asserted
|
|
152
|
+
// with a cast, and reported rather than silenced: making the declaration
|
|
153
|
+
// admit a partial logger is a change to a widely-shared type, not part of
|
|
154
|
+
// a conversion.
|
|
155
|
+
Object.assign(global.kuzzle, {
|
|
156
|
+
log: {
|
|
157
|
+
debug: console.debug, // eslint-disable-line no-console
|
|
158
|
+
error: console.error, // eslint-disable-line no-console
|
|
159
|
+
info: console.info, // eslint-disable-line no-console
|
|
160
|
+
warn: console.warn, // eslint-disable-line no-console
|
|
161
|
+
},
|
|
162
|
+
});
|
|
105
163
|
// Should never throw
|
|
106
|
-
|
|
164
|
+
// Named field by field rather than passed whole: this crossed an IPC
|
|
165
|
+
// boundary as plain JSON, and listing what is read is what keeps the
|
|
166
|
+
// worker's contract with `idCardHandler.createIdCard()` visible.
|
|
167
|
+
await idCardRenewer.init({
|
|
168
|
+
nodeIdKey: message.nodeIdKey,
|
|
169
|
+
redis: message.redis,
|
|
170
|
+
refreshDelay: message.refreshDelay,
|
|
171
|
+
refreshMultiplier: message.refreshMultiplier,
|
|
172
|
+
});
|
|
107
173
|
}
|
|
108
174
|
else if (message.action === "dispose") {
|
|
109
175
|
// Should never throw
|
|
@@ -116,5 +182,4 @@ process.on("disconnect", async () => {
|
|
|
116
182
|
await idCardRenewer.dispose();
|
|
117
183
|
process.exit();
|
|
118
184
|
});
|
|
119
|
-
module.exports = { IDCardRenewer };
|
|
120
185
|
//# sourceMappingURL=IDCardRenewer.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { PackagedKuzzleConfiguration } from "../types/config/KuzzleConfiguration";
|
|
2
2
|
/**
|
|
3
3
|
* /!\ DO NOT MODIFY THIS FILE
|
|
4
4
|
*
|
|
@@ -9,5 +9,5 @@ import { KuzzleConfiguration } from "../types/config/KuzzleConfiguration";
|
|
|
9
9
|
*
|
|
10
10
|
* @class KuzzleConfiguration
|
|
11
11
|
*/
|
|
12
|
-
declare const defaultConfig:
|
|
12
|
+
declare const defaultConfig: PackagedKuzzleConfiguration;
|
|
13
13
|
export default defaultConfig;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
6
|
+
const httpRoutes_1 = __importDefault(require("../api/httpRoutes"));
|
|
7
7
|
/* eslint-disable sort-keys */
|
|
8
8
|
/**
|
|
9
9
|
* /!\ DO NOT MODIFY THIS FILE
|
|
@@ -42,7 +42,7 @@ const defaultConfig = {
|
|
|
42
42
|
(see https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS)
|
|
43
43
|
*/
|
|
44
44
|
http: {
|
|
45
|
-
routes:
|
|
45
|
+
routes: httpRoutes_1.default,
|
|
46
46
|
accessControlAllowOrigin: "*",
|
|
47
47
|
accessControlAllowOriginUseRegExp: false,
|
|
48
48
|
accessControlAllowMethods: "GET,POST,PUT,PATCH,DELETE,OPTIONS,HEAD",
|
|
@@ -390,6 +390,7 @@ const defaultConfig = {
|
|
|
390
390
|
properties: {
|
|
391
391
|
userId: { type: "keyword" },
|
|
392
392
|
hash: { type: "keyword" },
|
|
393
|
+
fingerprint: { type: "keyword" },
|
|
393
394
|
description: { type: "text" },
|
|
394
395
|
expiresAt: { type: "long" },
|
|
395
396
|
ttl: { type: "keyword" },
|
|
@@ -451,15 +452,21 @@ const defaultConfig = {
|
|
|
451
452
|
command: 7510,
|
|
452
453
|
sync: 7511,
|
|
453
454
|
},
|
|
455
|
+
retransmitBuffer: {
|
|
456
|
+
bytes: 16777216,
|
|
457
|
+
messages: 1000,
|
|
458
|
+
},
|
|
454
459
|
syncTimeout: 5000,
|
|
455
460
|
},
|
|
456
|
-
/** @type {DocumentSpecification} */
|
|
457
461
|
validation: {},
|
|
458
462
|
controllers: {
|
|
459
463
|
definition: {
|
|
460
464
|
allowAdditionalActionProperties: false,
|
|
461
465
|
},
|
|
462
466
|
},
|
|
467
|
+
vault: {
|
|
468
|
+
newAlgorithm: false,
|
|
469
|
+
},
|
|
463
470
|
};
|
|
464
471
|
exports.default = defaultConfig;
|
|
465
472
|
//# sourceMappingURL=default.config.js.map
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* @returns {object}
|
|
4
|
-
*/
|
|
5
|
-
export declare function loadConfig(): any;
|
|
1
|
+
import type { IKuzzleConfiguration } from "../types/config/KuzzleConfiguration";
|
|
2
|
+
export declare function loadConfig(): IKuzzleConfiguration;
|
package/dist/lib/config/index.js
CHANGED
|
@@ -25,6 +25,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.loadConfig = void 0;
|
|
27
27
|
const assert_1 = __importDefault(require("assert"));
|
|
28
|
+
const node_util_1 = require("node:util");
|
|
28
29
|
const rc_1 = __importDefault(require("rc"));
|
|
29
30
|
const default_config_1 = __importDefault(require("./default.config"));
|
|
30
31
|
const package_json_1 = __importDefault(require("../../package.json"));
|
|
@@ -32,17 +33,13 @@ const kerror_1 = require("../kerror");
|
|
|
32
33
|
const safeObject_1 = require("../util/safeObject");
|
|
33
34
|
const bytes_1 = __importDefault(require("../util/bytes"));
|
|
34
35
|
const wrapped = (0, kerror_1.wrap)("core", "configuration");
|
|
35
|
-
/**
|
|
36
|
-
* Loads, interprets and checks configuration files
|
|
37
|
-
* @returns {object}
|
|
38
|
-
*/
|
|
39
36
|
function loadConfig() {
|
|
40
37
|
let config;
|
|
41
38
|
try {
|
|
42
39
|
config = (0, rc_1.default)("kuzzle", default_config_1.default);
|
|
43
40
|
}
|
|
44
41
|
catch (e) {
|
|
45
|
-
throw wrapped.get("cannot_parse", e.message);
|
|
42
|
+
throw wrapped.get("cannot_parse", e instanceof Error ? e.message : (0, node_util_1.inspect)(e));
|
|
46
43
|
}
|
|
47
44
|
config = unstringify(config);
|
|
48
45
|
checkLimitsConfig(config);
|
|
@@ -89,7 +86,7 @@ function unstringify(cfg) {
|
|
|
89
86
|
try {
|
|
90
87
|
cfg[k] = JSON.parse(cfg[k].replace(/^\*json:/, ""));
|
|
91
88
|
}
|
|
92
|
-
catch
|
|
89
|
+
catch {
|
|
93
90
|
throw wrapped.get("cannot_parse", `the key "${k}" does not contain a valid stringified JSON (${cfg[k]})`);
|
|
94
91
|
}
|
|
95
92
|
}
|
|
@@ -131,24 +128,32 @@ function checkLimitsConfig(cfg) {
|
|
|
131
128
|
"subscriptionRooms",
|
|
132
129
|
"subscriptionDocumentTTL",
|
|
133
130
|
];
|
|
134
|
-
|
|
131
|
+
const configured = cfg.limits;
|
|
132
|
+
if (!(0, safeObject_1.isPlainObject)(configured)) {
|
|
135
133
|
throw wrapped.get("invalid_type", "limits", "object");
|
|
136
134
|
}
|
|
137
|
-
|
|
138
|
-
|
|
135
|
+
// One read per limit, validated where it is read: `isPlainObject` narrows
|
|
136
|
+
// to a record of `unknown`, which is the honest type for a configuration
|
|
137
|
+
// file, and the three comparisons below each re-read two of these.
|
|
138
|
+
const limit = (opt) => {
|
|
139
|
+
const value = configured[opt];
|
|
140
|
+
if (typeof value !== "number") {
|
|
139
141
|
throw wrapped.get("invalid_type", `limits.${opt}`, "number");
|
|
140
142
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
+
return value;
|
|
144
|
+
};
|
|
145
|
+
for (const opt of limits) {
|
|
146
|
+
const value = limit(opt);
|
|
147
|
+
if (value < 0 || (value === 0 && !canBeZero.includes(opt))) {
|
|
143
148
|
const allowed = `>= ${canBeZero.includes(opt) ? "0" : "1"}`;
|
|
144
149
|
throw wrapped.get("out_of_range", `limits.${opt}`, allowed);
|
|
145
150
|
}
|
|
146
151
|
}
|
|
147
|
-
if (
|
|
152
|
+
if (limit("concurrentRequests") >= limit("requestsBufferSize")) {
|
|
148
153
|
throw wrapped.get("out_of_range", "limits.concurrentRequests", 'lower than "limits.requestsBufferSize"');
|
|
149
154
|
}
|
|
150
|
-
if (
|
|
151
|
-
|
|
155
|
+
if (limit("requestsBufferWarningThreshold") < limit("concurrentRequests") ||
|
|
156
|
+
limit("requestsBufferWarningThreshold") > limit("requestsBufferSize")) {
|
|
152
157
|
throw wrapped.get("out_of_range", "limits.requestsBufferWarningThreshold", "[limits.concurrentRequests, limits.requestsBufferSize]");
|
|
153
158
|
}
|
|
154
159
|
}
|
|
@@ -158,7 +163,9 @@ function checkWebSocketOptions(config) {
|
|
|
158
163
|
return;
|
|
159
164
|
}
|
|
160
165
|
(0, assert_1.default)(typeof cfg.enabled === "boolean", `[websocket] "enabled" parameter: invalid value "${cfg.enabled}" (boolean expected)`);
|
|
161
|
-
|
|
166
|
+
// The 1000 ms floor is the protocol's, not this check's: `httpwsProtocol`
|
|
167
|
+
// replaces a lower value (0 included) with its default, and warns.
|
|
168
|
+
(0, assert_1.default)(Number.isInteger(cfg.idleTimeout) && cfg.idleTimeout >= 0, `[websocket] "idleTimeout" parameter: invalid value "${cfg.idleTimeout}" (integer >= 0 expected)`);
|
|
162
169
|
(0, assert_1.default)(Number.isInteger(cfg.rateLimit) && cfg.rateLimit >= 0, `[websocket] "rateLimit" parameter: invalid value "${cfg.rateLimit}" (integer >= 0 expected)`);
|
|
163
170
|
(0, assert_1.default)(typeof cfg.compression === "boolean", `[websocket] "compression" parameter: invalid value "${cfg.compression}" (boolean expected)`);
|
|
164
171
|
(0, assert_1.default)(typeof cfg.sendPingsAutomatically === "boolean", `[websocket] "sendPingsAutomatically" parameter: invalid value "${cfg.sendPingsAutomatically}" (boolean expected)`);
|
|
@@ -171,12 +178,14 @@ function checkHttpOptions(config) {
|
|
|
171
178
|
}
|
|
172
179
|
(0, assert_1.default)(typeof config.http.accessControlAllowOrigin === "string" ||
|
|
173
180
|
Array.isArray(config.http.accessControlAllowOrigin), `[http] "accessControlAllowOrigin" parameter: invalid value "${config.http.accessControlAllowOrigin}" (array or string expected)`);
|
|
174
|
-
(0, assert_1.default)(typeof config.http.accessControlAllowOriginUseRegExp === "boolean", `[http] "accessControlAllowOriginUseRegExp" parameter: invalid value "${
|
|
181
|
+
(0, assert_1.default)(typeof config.http.accessControlAllowOriginUseRegExp === "boolean", `[http] "accessControlAllowOriginUseRegExp" parameter: invalid value "${config.http.accessControlAllowOriginUseRegExp}" (boolean expected)`);
|
|
175
182
|
(0, assert_1.default)(typeof cfg.enabled === "boolean", `[http] "enabled" parameter: invalid value "${cfg.enabled}" (boolean expected)`);
|
|
176
183
|
(0, assert_1.default)(typeof cfg.allowCompression === "boolean", `[http] "allowCompression" parameter: invalid value "${cfg.allowCompression}" (boolean expected)`);
|
|
177
184
|
(0, assert_1.default)(Number.isInteger(cfg.maxEncodingLayers) && cfg.maxEncodingLayers >= 1, `[http] "maxEncodingLayers" parameter: invalid value "${cfg.maxEncodingLayers}" (integer >= 1 expected)`);
|
|
178
185
|
const maxFormFileSize = (0, bytes_1.default)(cfg.maxFormFileSize);
|
|
179
|
-
(0, assert_1.default)(
|
|
186
|
+
(0, assert_1.default)(maxFormFileSize !== null &&
|
|
187
|
+
Number.isInteger(maxFormFileSize) &&
|
|
188
|
+
maxFormFileSize >= 0, `[http] "maxFormFileSize" parameter: cannot parse "${cfg.maxFormFileSize}"`);
|
|
180
189
|
cfg.maxFormFileSize = maxFormFileSize;
|
|
181
190
|
(0, assert_1.default)(typeof config.http.cookieAuthentication === "boolean", `[http] "cookieAuthentication" parameter: invalid value "${config.http.cookieAuthentication}" (boolean expected)`);
|
|
182
191
|
(0, assert_1.default)(Array.isArray(cfg.additionalContentTypes) &&
|
|
@@ -197,6 +206,10 @@ function checkClusterOptions(config) {
|
|
|
197
206
|
for (const prop of ["command", "sync"]) {
|
|
198
207
|
(0, assert_1.default)(typeof cfg.ports[prop] === "number" && cfg.ports[prop] > 0, `[CONFIG] kuzzlerc.cluster.ports.${prop}: value must be a number greater than 0`);
|
|
199
208
|
}
|
|
209
|
+
for (const prop of ["messages", "bytes"]) {
|
|
210
|
+
(0, assert_1.default)(Number.isInteger(cfg.retransmitBuffer?.[prop]) &&
|
|
211
|
+
cfg.retransmitBuffer[prop] >= 0, `[CONFIG] kuzzlerc.cluster.retransmitBuffer.${prop}: integer >= 0 expected`);
|
|
212
|
+
}
|
|
200
213
|
(0, assert_1.default)(typeof cfg.ipv6 === "boolean", "[CONFIG] kuzzlerc.cluster.ipv6: boolean expected");
|
|
201
214
|
// If config is passed with env variable, ip cannot be the value null
|
|
202
215
|
// but only blank string or the string "null"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Profile } from "../../model/security/profile";
|
|
2
|
-
import { Role } from "../../model/security/role";
|
|
3
|
-
import { User } from "../../model/security/user";
|
|
1
|
+
import type { Profile } from "../../model/security/profile";
|
|
2
|
+
import type { Role } from "../../model/security/role";
|
|
3
|
+
import type { User } from "../../model/security/user";
|
|
4
4
|
import type { Serialized } from "../../types/core/auth/formatProcessing.type";
|
|
5
5
|
declare const _default: {
|
|
6
6
|
/**
|
|
@@ -72,14 +72,20 @@ class PassportWrapper {
|
|
|
72
72
|
// Thus, despite the apparences, the promise can only be resolved once.
|
|
73
73
|
// (Proof: HTTP redirection unit test)
|
|
74
74
|
response.addEndListener(() => resolve(response));
|
|
75
|
+
// A strategy is plugin code and can fail with anything; so can passport,
|
|
76
|
+
// which reports what it decides itself (an unknown strategy name, first
|
|
77
|
+
// of all) through the middleware's `next`. All three paths end here.
|
|
78
|
+
const fail = (e) => {
|
|
79
|
+
if (e instanceof errors_1.KuzzleError) {
|
|
80
|
+
reject(e);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const error = e instanceof Error ? e : new Error(String(e));
|
|
84
|
+
reject(kerror.getFrom(error, "plugin", "runtime", "unexpected_error", error.message));
|
|
85
|
+
};
|
|
75
86
|
const authCB = (err, user, info) => {
|
|
76
87
|
if (err !== null) {
|
|
77
|
-
|
|
78
|
-
reject(err);
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
reject(kerror.getFrom(err, "plugin", "runtime", "unexpected_error", err.message));
|
|
82
|
-
}
|
|
88
|
+
fail(err);
|
|
83
89
|
}
|
|
84
90
|
else if (!user) {
|
|
85
91
|
reject(kerror.get("plugin", "strategy", "missing_user", info.message));
|
|
@@ -89,15 +95,10 @@ class PassportWrapper {
|
|
|
89
95
|
}
|
|
90
96
|
};
|
|
91
97
|
try {
|
|
92
|
-
passport_1.default.authenticate(strategyName, this.options[strategyName] || {}, authCB)(request, response);
|
|
98
|
+
passport_1.default.authenticate(strategyName, this.options[strategyName] || {}, authCB)(request, response, fail);
|
|
93
99
|
}
|
|
94
100
|
catch (e) {
|
|
95
|
-
|
|
96
|
-
reject(e);
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
reject(kerror.getFrom(e, "plugin", "runtime", "unexpected_error", e.message));
|
|
100
|
-
}
|
|
101
|
+
fail(e);
|
|
101
102
|
}
|
|
102
103
|
});
|
|
103
104
|
}
|
|
@@ -8,6 +8,7 @@ import { Token } from "../../model/security/token";
|
|
|
8
8
|
*/
|
|
9
9
|
export declare class TokenManager {
|
|
10
10
|
private tokens;
|
|
11
|
+
/** Read from the anonymous user by `init()`, and not before. */
|
|
11
12
|
private anonymousUserId;
|
|
12
13
|
/**
|
|
13
14
|
* Map<connectionId, ManagedToken>
|
|
@@ -17,6 +18,14 @@ export declare class TokenManager {
|
|
|
17
18
|
private readonly logger;
|
|
18
19
|
constructor();
|
|
19
20
|
init(): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* The managed token filed under `idx`, or undefined when none is.
|
|
23
|
+
*
|
|
24
|
+
* `search` answers a position or `-1`, and indexing `array` with it is
|
|
25
|
+
* `| undefined` for every position under `noUncheckedIndexedAccess` — so the
|
|
26
|
+
* callers test one value rather than a position and then an element.
|
|
27
|
+
*/
|
|
28
|
+
private find;
|
|
20
29
|
runTimer(): void;
|
|
21
30
|
/**
|
|
22
31
|
* Link a connection and a token.
|
|
@@ -31,7 +40,13 @@ export declare class TokenManager {
|
|
|
31
40
|
* @param token
|
|
32
41
|
* @param connectionId
|
|
33
42
|
*/
|
|
34
|
-
|
|
43
|
+
/**
|
|
44
|
+
* `Token | null`: a request whose connection never authenticated carries no
|
|
45
|
+
* token, and the trace below is the deliberate answer to that. The
|
|
46
|
+
* non-nullable parameter made `authController.logout` — the one caller —
|
|
47
|
+
* look like it had checked.
|
|
48
|
+
*/
|
|
49
|
+
unlink(token: Token | null, connectionId: string): void;
|
|
35
50
|
/**
|
|
36
51
|
* Remove token associated with a connection.
|
|
37
52
|
*/
|
|
@@ -54,9 +69,15 @@ export declare class TokenManager {
|
|
|
54
69
|
refresh(oldToken: Token, newToken: Token): void;
|
|
55
70
|
checkTokensValidity(): Promise<void>;
|
|
56
71
|
/**
|
|
57
|
-
* Gets the token matching user & connection if any
|
|
72
|
+
* Gets the token matching user & connection if any.
|
|
73
|
+
*
|
|
74
|
+
* `string | null` on both: this is a query, and a request that carries
|
|
75
|
+
* neither a connection nor a stored user is answered — `null` misses the
|
|
76
|
+
* map, and a null kuid matches no token's `userId` — rather than being a
|
|
77
|
+
* caller error. `authController.login` asks it of every login, including
|
|
78
|
+
* the ones where the strategy has not yet produced either.
|
|
58
79
|
*/
|
|
59
|
-
getConnectedUserToken(userId: string, connectionId: string): Token | null;
|
|
80
|
+
getConnectedUserToken(userId: string | null, connectionId: string | null): Token | null;
|
|
60
81
|
/**
|
|
61
82
|
* Returns the kuid associated to a connection
|
|
62
83
|
*/
|