kuzzle 2.60.0-beta.1 → 2.60.0-beta.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 (179) hide show
  1. package/dist/bin/copy-binaries.js +17 -7
  2. package/dist/bin/start-kuzzle-server +19 -8
  3. package/dist/index.d.ts +2 -1
  4. package/dist/index.js +6 -2
  5. package/dist/lib/api/controllers/adminController.d.ts +9 -3
  6. package/dist/lib/api/controllers/adminController.js +42 -26
  7. package/dist/lib/api/controllers/authController.d.ts +15 -5
  8. package/dist/lib/api/controllers/authController.js +35 -20
  9. package/dist/lib/api/controllers/baseController.js +17 -7
  10. package/dist/lib/api/controllers/bulkController.js +17 -7
  11. package/dist/lib/api/controllers/collectionController.js +17 -7
  12. package/dist/lib/api/controllers/debugController.js +17 -7
  13. package/dist/lib/api/controllers/documentController.js +17 -7
  14. package/dist/lib/api/controllers/indexController.d.ts +1 -1
  15. package/dist/lib/api/controllers/memoryStorageController.js +17 -7
  16. package/dist/lib/api/controllers/securityController.d.ts +30 -28
  17. package/dist/lib/api/controllers/securityController.js +18 -8
  18. package/dist/lib/api/controllers/serverController.d.ts +0 -1
  19. package/dist/lib/api/controllers/serverController.js +17 -7
  20. package/dist/lib/api/documentExtractor.js +17 -7
  21. package/dist/lib/api/funnel.js +19 -9
  22. package/dist/lib/api/httpRoutes.d.ts +2 -1
  23. package/dist/lib/api/openapi/OpenApiManager.d.ts +2 -1
  24. package/dist/lib/api/openapi/openApiGenerator.js +1 -2
  25. package/dist/lib/api/request/kuzzleRequest.d.ts +9 -2
  26. package/dist/lib/api/request/kuzzleRequest.js +21 -7
  27. package/dist/lib/api/request/requestContext.d.ts +7 -2
  28. package/dist/lib/api/request/requestContext.js +17 -7
  29. package/dist/lib/api/request/requestInput.d.ts +1 -1
  30. package/dist/lib/api/request/requestInput.js +17 -7
  31. package/dist/lib/api/request/requestResponse.d.ts +2 -2
  32. package/dist/lib/api/request/requestResponse.js +21 -10
  33. package/dist/lib/cluster/command.d.ts +0 -2
  34. package/dist/lib/cluster/command.js +17 -7
  35. package/dist/lib/cluster/idCardHandler.d.ts +7 -2
  36. package/dist/lib/cluster/idCardHandler.js +24 -3
  37. package/dist/lib/cluster/node.d.ts +15 -3
  38. package/dist/lib/cluster/node.js +112 -40
  39. package/dist/lib/cluster/protobuf/command.proto +23 -22
  40. package/dist/lib/cluster/protobuf/sync.proto +91 -85
  41. package/dist/lib/cluster/publisher.js +17 -7
  42. package/dist/lib/cluster/state.js +17 -7
  43. package/dist/lib/cluster/subscriber.d.ts +0 -2
  44. package/dist/lib/cluster/subscriber.js +17 -7
  45. package/dist/lib/cluster/workers/IDCardRenewer.d.ts +6 -1
  46. package/dist/lib/cluster/workers/IDCardRenewer.js +14 -8
  47. package/dist/lib/config/index.js +20 -14
  48. package/dist/lib/core/auth/formatProcessing.d.ts +1 -1
  49. package/dist/lib/core/auth/formatProcessing.js +3 -3
  50. package/dist/lib/core/auth/passportResponse.d.ts +0 -1
  51. package/dist/lib/core/auth/passportWrapper.js +24 -8
  52. package/dist/lib/core/backend/backend.js +17 -7
  53. package/dist/lib/core/backend/backendConfig.d.ts +1 -1
  54. package/dist/lib/core/backend/backendConfig.js +17 -7
  55. package/dist/lib/core/backend/backendController.js +17 -7
  56. package/dist/lib/core/backend/backendErrors.js +17 -7
  57. package/dist/lib/core/backend/backendHook.js +17 -7
  58. package/dist/lib/core/backend/backendImport.js +17 -7
  59. package/dist/lib/core/backend/backendPipe.d.ts +4 -1
  60. package/dist/lib/core/backend/backendPipe.js +17 -7
  61. package/dist/lib/core/backend/backendPlugin.js +17 -7
  62. package/dist/lib/core/backend/backendStorage.js +8 -8
  63. package/dist/lib/core/backend/backendSubscription.js +17 -7
  64. package/dist/lib/core/backend/backendVault.js +17 -7
  65. package/dist/lib/core/backend/internalLogger.d.ts +7 -7
  66. package/dist/lib/core/debug/kuzzleDebugger.js +17 -7
  67. package/dist/lib/core/network/accessLogger.d.ts +0 -1
  68. package/dist/lib/core/network/accessLogger.js +17 -7
  69. package/dist/lib/core/network/clientConnection.js +17 -7
  70. package/dist/lib/core/network/context.d.ts +0 -1
  71. package/dist/lib/core/network/entryPoint.js +17 -7
  72. package/dist/lib/core/network/httpRouter/routePart.js +17 -7
  73. package/dist/lib/core/network/protocols/httpMessage.d.ts +0 -2
  74. package/dist/lib/core/network/protocols/httpwsProtocol.d.ts +0 -3
  75. package/dist/lib/core/network/protocols/httpwsProtocol.js +17 -7
  76. package/dist/lib/core/network/protocols/mqttProtocol.d.ts +1 -2
  77. package/dist/lib/core/network/protocols/mqttProtocol.js +31 -10
  78. package/dist/lib/core/network/router.js +17 -7
  79. package/dist/lib/core/plugin/plugin.js +17 -7
  80. package/dist/lib/core/plugin/pluginContext.d.ts +20 -9
  81. package/dist/lib/core/plugin/pluginContext.js +39 -24
  82. package/dist/lib/core/plugin/pluginsManager.js +17 -7
  83. package/dist/lib/core/realtime/channel.js +17 -7
  84. package/dist/lib/core/realtime/hotelClerk.d.ts +3 -2
  85. package/dist/lib/core/realtime/hotelClerk.js +17 -7
  86. package/dist/lib/core/realtime/notifier.js +17 -7
  87. package/dist/lib/core/security/profileRepository.js +17 -7
  88. package/dist/lib/core/security/roleRepository.js +17 -7
  89. package/dist/lib/core/security/securityLoader.js +17 -7
  90. package/dist/lib/core/security/tokenRepository.js +18 -8
  91. package/dist/lib/core/security/userRepository.js +17 -7
  92. package/dist/lib/core/shared/ObjectRepository.js +20 -7
  93. package/dist/lib/core/shared/abstractManifest.js +17 -7
  94. package/dist/lib/core/shared/sdk/embeddedSdk.js +20 -8
  95. package/dist/lib/core/shared/sdk/funnelProtocol.js +17 -7
  96. package/dist/lib/core/shared/store.d.ts +11 -1
  97. package/dist/lib/core/shared/store.js +26 -30
  98. package/dist/lib/core/statistics/statistics.d.ts +0 -1
  99. package/dist/lib/core/statistics/statistics.js +17 -7
  100. package/dist/lib/core/storage/clientAdapter.d.ts +4 -6
  101. package/dist/lib/core/storage/clientAdapter.js +24 -18
  102. package/dist/lib/core/storage/indexCache.js +17 -7
  103. package/dist/lib/core/validation/specification.js +1 -2
  104. package/dist/lib/core/validation/types/date.js +17 -7
  105. package/dist/lib/core/validation/types/enum.js +17 -7
  106. package/dist/lib/core/validation/types/geoShape.js +17 -7
  107. package/dist/lib/core/validation/types/geoShapeUtils.js +6 -7
  108. package/dist/lib/core/validation/validation.js +17 -7
  109. package/dist/lib/core/validation/validationUtils.js +24 -15
  110. package/dist/lib/kerror/codes/8-cluster.json +23 -0
  111. package/dist/lib/kerror/codes/index.js +20 -10
  112. package/dist/lib/kerror/errors/kuzzleError.js +18 -8
  113. package/dist/lib/kerror/index.js +31 -18
  114. package/dist/lib/kuzzle/Logger.js +4 -3
  115. package/dist/lib/kuzzle/dumpGenerator.js +17 -7
  116. package/dist/lib/kuzzle/event/KuzzleEventEmitter.d.ts +3 -3
  117. package/dist/lib/kuzzle/event/KuzzleEventEmitter.js +17 -7
  118. package/dist/lib/kuzzle/event/pipeRunner.js +17 -7
  119. package/dist/lib/kuzzle/exitOnFailure.d.ts +13 -0
  120. package/dist/lib/kuzzle/exitOnFailure.js +60 -0
  121. package/dist/lib/kuzzle/internalIndexHandler.js +37 -32
  122. package/dist/lib/kuzzle/kuzzle.d.ts +20 -8
  123. package/dist/lib/kuzzle/kuzzle.js +148 -130
  124. package/dist/lib/model/security/profile.js +17 -7
  125. package/dist/lib/model/security/role.js +17 -7
  126. package/dist/lib/model/security/user.js +17 -7
  127. package/dist/lib/model/storage/apiKey.d.ts +1 -1
  128. package/dist/lib/model/storage/apiKey.js +17 -7
  129. package/dist/lib/service/cache/redis.js +40 -9
  130. package/dist/lib/service/service.js +17 -7
  131. package/dist/lib/service/storage/7/elasticsearch.d.ts +36 -25
  132. package/dist/lib/service/storage/7/elasticsearch.js +73 -55
  133. package/dist/lib/service/storage/8/elasticsearch.d.ts +47 -36
  134. package/dist/lib/service/storage/8/elasticsearch.js +73 -55
  135. package/dist/lib/service/storage/Elasticsearch.d.ts +10 -4
  136. package/dist/lib/types/HttpStream.d.ts +0 -1
  137. package/dist/lib/types/Plugin.js +17 -7
  138. package/dist/lib/types/config/SecurityConfiguration.d.ts +0 -2
  139. package/dist/lib/types/config/storageEngine/StorageEngineElasticsearchConfiguration.d.ts +5 -0
  140. package/dist/lib/types/controllers/GetCurrentUserResponse.d.ts +5 -0
  141. package/dist/lib/types/controllers/GetCurrentUserResponse.js +3 -0
  142. package/dist/lib/types/controllers/ResetSecurityResult.d.ts +5 -0
  143. package/dist/lib/types/controllers/ResetSecurityResult.js +3 -0
  144. package/dist/lib/types/controllers/adminController.type.d.ts +7 -5
  145. package/dist/lib/types/controllers/authController.type.d.ts +7 -5
  146. package/dist/lib/types/core/auth/Serialized.d.ts +14 -0
  147. package/dist/lib/types/core/auth/Serialized.js +3 -0
  148. package/dist/lib/types/core/auth/formatProcessing.type.d.ts +5 -11
  149. package/dist/lib/types/events/EventProtocol.d.ts +0 -2
  150. package/dist/lib/types/index.d.ts +1 -0
  151. package/dist/lib/types/index.js +1 -0
  152. package/dist/lib/types/storage/8/Elasticsearch.d.ts +4 -3
  153. package/dist/lib/util/array.d.ts +1 -1
  154. package/dist/lib/util/array.js +7 -6
  155. package/dist/lib/util/assertType.js +5 -6
  156. package/dist/lib/util/async.js +1 -2
  157. package/dist/lib/util/asyncStore.d.ts +0 -1
  158. package/dist/lib/util/bufferedPassThrough.d.ts +0 -3
  159. package/dist/lib/util/crypto.js +1 -2
  160. package/dist/lib/util/debug.d.ts +0 -1
  161. package/dist/lib/util/debug.js +17 -7
  162. package/dist/lib/util/distributedLock.d.ts +27 -4
  163. package/dist/lib/util/distributedLock.js +69 -16
  164. package/dist/lib/util/dump-collection.d.ts +2 -2
  165. package/dist/lib/util/dump-collection.js +22 -13
  166. package/dist/lib/util/esRequest.js +1 -2
  167. package/dist/lib/util/extractFields.d.ts +16 -7
  168. package/dist/lib/util/extractFields.js +1 -10
  169. package/dist/lib/util/koncordeCompat.js +22 -13
  170. package/dist/lib/util/mutex.d.ts +4 -4
  171. package/dist/lib/util/mutex.js +21 -11
  172. package/dist/lib/util/name-generator.js +2 -2
  173. package/dist/lib/util/requestAssertions.js +27 -18
  174. package/dist/lib/util/safeObject.js +3 -4
  175. package/dist/lib/util/stackTrace.js +2 -3
  176. package/dist/lib/util/thrown.js +1 -2
  177. package/dist/lib/util/time.js +1 -2
  178. package/dist/package.json +22 -15
  179. package/package.json +22 -15
@@ -1,107 +1,113 @@
1
1
  // sync messages definitions
2
2
  // /!\ ALL messages must have a "messageId" property
3
+ // /!\ Every singular scalar field is "optional": protobufjs 8 otherwise drops a
4
+ // field holding its default value ("", 0, false) on encode and in
5
+ // toObject(), where protobufjs 7 kept it. "optional" keeps the bytes and
6
+ // the decoded objects identical between both versions, which a cluster
7
+ // mixing them during a rolling upgrade relies on. Declare new fields the
8
+ // same way (tests/cluster/protobufWireCompat.test.ts checks the result).
3
9
  package sync;
4
10
 
5
11
  syntax="proto3";
6
12
 
7
13
  message Heartbeat {
8
- uint64 messageId = 1;
9
- string address = 2;
14
+ optional uint64 messageId = 1;
15
+ optional string address = 2;
10
16
  }
11
17
 
12
18
  message NodeEvicted {
13
- uint64 messageId = 1;
14
- string nodeId = 2;
15
- string reason = 3;
16
- string evictor = 4;
19
+ optional uint64 messageId = 1;
20
+ optional string nodeId = 2;
21
+ optional string reason = 3;
22
+ optional string evictor = 4;
17
23
  }
18
24
 
19
25
  message NodeShutdown {
20
- uint64 messageId = 1;
21
- string nodeId = 2;
26
+ optional uint64 messageId = 1;
27
+ optional string nodeId = 2;
22
28
  }
23
29
 
24
30
  message NodePreventEviction {
25
- uint64 messageId = 1;
26
- bool evictionPrevented = 2;
31
+ optional uint64 messageId = 1;
32
+ optional bool evictionPrevented = 2;
27
33
  }
28
34
 
29
35
  message NewRealtimeRoom {
30
- uint64 messageId = 1;
31
- string index = 2;
32
- string id = 3;
36
+ optional uint64 messageId = 1;
37
+ optional string index = 2;
38
+ optional string id = 3;
33
39
 
34
40
  // serialized JSON
35
- string filter = 4;
41
+ optional string filter = 4;
36
42
  }
37
43
 
38
44
  message RemoveRealtimeRoom {
39
- uint64 messageId = 1;
40
- string roomId = 2;
45
+ optional uint64 messageId = 1;
46
+ optional string roomId = 2;
41
47
  }
42
48
 
43
49
  message Subscription {
44
- uint64 messageId = 1;
45
- string roomId = 2;
50
+ optional uint64 messageId = 1;
51
+ optional string roomId = 2;
46
52
  }
47
53
 
48
54
  message Unsubscription {
49
- uint64 messageId = 1;
50
- string roomId = 2;
55
+ optional uint64 messageId = 1;
56
+ optional string roomId = 2;
51
57
  }
52
58
 
53
59
  message DocumentNotification {
54
- uint64 messageId = 1;
60
+ optional uint64 messageId = 1;
55
61
  repeated string rooms = 2;
56
- uint32 status = 3;
57
- string requestId = 4;
58
- uint64 timestamp = 5;
59
- string index = 6;
60
- string collection = 7;
61
- string controller = 8;
62
- string action = 9;
63
- string protocol = 10;
64
- string scope = 11;
62
+ optional uint32 status = 3;
63
+ optional string requestId = 4;
64
+ optional uint64 timestamp = 5;
65
+ optional string index = 6;
66
+ optional string collection = 7;
67
+ optional string controller = 8;
68
+ optional string action = 9;
69
+ optional string protocol = 10;
70
+ optional string scope = 11;
65
71
 
66
72
  // serialized JSON
67
- string volatile = 12;
68
- string result = 13;
73
+ optional string volatile = 12;
74
+ optional string result = 13;
69
75
  }
70
76
 
71
77
  message UserNotification {
72
- uint64 messageId = 1;
73
- string room = 2;
74
- uint32 status = 3;
75
- uint64 timestamp = 4;
76
- string index = 5;
77
- string collection = 6;
78
- string controller = 7;
79
- string action = 8;
80
- string protocol = 9;
81
- string user = 10;
78
+ optional uint64 messageId = 1;
79
+ optional string room = 2;
80
+ optional uint32 status = 3;
81
+ optional uint64 timestamp = 4;
82
+ optional string index = 5;
83
+ optional string collection = 6;
84
+ optional string controller = 7;
85
+ optional string action = 8;
86
+ optional string protocol = 9;
87
+ optional string user = 10;
82
88
 
83
89
  // serialized JSON
84
- string volatile = 11;
85
- string result = 12;
90
+ optional string volatile = 11;
91
+ optional string result = 12;
86
92
  }
87
93
 
88
94
  message NewAuthStrategy {
89
95
  message AuthStrategyConfig {
90
- string authenticator = 1;
96
+ optional string authenticator = 1;
91
97
  repeated string fields = 2;
92
98
 
93
99
  // serialized JSON
94
- string authenticateOptions = 3;
95
- string strategyOptions = 4;
100
+ optional string authenticateOptions = 3;
101
+ optional string strategyOptions = 4;
96
102
  }
97
103
 
98
104
  message AuthStrategyMethods {
99
- string create = 1;
100
- string delete = 2;
101
- string exists = 3;
102
- string update = 4;
103
- string validate = 5;
104
- string verify = 6;
105
+ optional string create = 1;
106
+ optional string delete = 2;
107
+ optional string exists = 3;
108
+ optional string update = 4;
109
+ optional string validate = 5;
110
+ optional string verify = 6;
105
111
  optional string getById = 7;
106
112
  optional string getInfo = 8;
107
113
  optional string afterRegister = 9;
@@ -112,77 +118,77 @@ message NewAuthStrategy {
112
118
  AuthStrategyConfig config = 2;
113
119
  }
114
120
 
115
- uint64 messageId = 1;
116
- string strategyName = 2;
117
- string pluginName = 3;
121
+ optional uint64 messageId = 1;
122
+ optional string strategyName = 2;
123
+ optional string pluginName = 3;
118
124
  AuthStrategy strategy = 4;
119
125
  }
120
126
 
121
127
  message RemoveAuthStrategy {
122
- uint64 messageId = 1;
123
- string strategyName = 2;
124
- string pluginName = 3;
128
+ optional uint64 messageId = 1;
129
+ optional string strategyName = 2;
130
+ optional string pluginName = 3;
125
131
  }
126
132
 
127
133
  message DumpRequest {
128
- uint64 messageId = 1;
129
- string suffix = 2;
134
+ optional uint64 messageId = 1;
135
+ optional string suffix = 2;
130
136
  }
131
137
 
132
138
  message ResetSecurity {
133
- uint64 messageId = 1;
139
+ optional uint64 messageId = 1;
134
140
  }
135
141
 
136
142
  message Shutdown {
137
- uint64 messageId = 1;
143
+ optional uint64 messageId = 1;
138
144
  }
139
145
 
140
146
  message RefreshValidators {
141
- uint64 messageId = 1;
147
+ optional uint64 messageId = 1;
142
148
  }
143
149
 
144
150
  message InvalidateProfile {
145
- uint64 messageId = 1;
146
- string profileId = 2;
151
+ optional uint64 messageId = 1;
152
+ optional string profileId = 2;
147
153
  }
148
154
 
149
155
  message InvalidateRole {
150
- uint64 messageId = 1;
151
- string roleId = 2;
156
+ optional uint64 messageId = 1;
157
+ optional string roleId = 2;
152
158
  }
153
159
 
154
160
  message AddIndex {
155
- uint64 messageId = 1;
156
- string scope = 2;
157
- string index = 3;
161
+ optional uint64 messageId = 1;
162
+ optional string scope = 2;
163
+ optional string index = 3;
158
164
  }
159
165
 
160
166
  message AddCollection {
161
- uint64 messageId = 1;
162
- string scope = 2;
163
- string index = 3;
164
- string collection = 4;
167
+ optional uint64 messageId = 1;
168
+ optional string scope = 2;
169
+ optional string index = 3;
170
+ optional string collection = 4;
165
171
  }
166
172
 
167
173
  message RemoveIndexes {
168
- uint64 messageId = 1;
169
- string scope = 2;
174
+ optional uint64 messageId = 1;
175
+ optional string scope = 2;
170
176
  repeated string indexes = 3;
171
177
  }
172
178
 
173
179
  message RemoveCollection {
174
- uint64 messageId = 1;
175
- string scope = 2;
176
- string index = 3;
177
- string collection = 4;
180
+ optional uint64 messageId = 1;
181
+ optional string scope = 2;
182
+ optional string index = 3;
183
+ optional string collection = 4;
178
184
  }
179
185
 
180
186
  message ClusterWideEvent {
181
- uint64 messageId = 1;
182
- string event = 2;
183
- string payload = 3;
187
+ optional uint64 messageId = 1;
188
+ optional string event = 2;
189
+ optional string payload = 3;
184
190
  }
185
191
 
186
192
  message RefreshIndexCache {
187
- uint64 messageId = 1;
193
+ optional uint64 messageId = 1;
188
194
  }
@@ -35,13 +35,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
35
35
  }) : function(o, v) {
36
36
  o["default"] = v;
37
37
  });
38
- var __importStar = (this && this.__importStar) || function (mod) {
39
- if (mod && mod.__esModule) return mod;
40
- var result = {};
41
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
42
- __setModuleDefault(result, mod);
43
- return result;
44
- };
38
+ var __importStar = (this && this.__importStar) || (function () {
39
+ var ownKeys = function(o) {
40
+ ownKeys = Object.getOwnPropertyNames || function (o) {
41
+ var ar = [];
42
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
43
+ return ar;
44
+ };
45
+ return ownKeys(o);
46
+ };
47
+ return function (mod) {
48
+ if (mod && mod.__esModule) return mod;
49
+ var result = {};
50
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
51
+ __setModuleDefault(result, mod);
52
+ return result;
53
+ };
54
+ })();
45
55
  var __importDefault = (this && this.__importDefault) || function (mod) {
46
56
  return (mod && mod.__esModule) ? mod : { "default": mod };
47
57
  };
@@ -35,13 +35,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
35
35
  }) : function(o, v) {
36
36
  o["default"] = v;
37
37
  });
38
- var __importStar = (this && this.__importStar) || function (mod) {
39
- if (mod && mod.__esModule) return mod;
40
- var result = {};
41
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
42
- __setModuleDefault(result, mod);
43
- return result;
44
- };
38
+ var __importStar = (this && this.__importStar) || (function () {
39
+ var ownKeys = function(o) {
40
+ ownKeys = Object.getOwnPropertyNames || function (o) {
41
+ var ar = [];
42
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
43
+ return ar;
44
+ };
45
+ return ownKeys(o);
46
+ };
47
+ return function (mod) {
48
+ if (mod && mod.__esModule) return mod;
49
+ var result = {};
50
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
51
+ __setModuleDefault(result, mod);
52
+ return result;
53
+ };
54
+ })();
45
55
  Object.defineProperty(exports, "__esModule", { value: true });
46
56
  const koncorde_1 = require("koncorde");
47
57
  const kerror = __importStar(require("../kerror"));
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import Long from "long";
4
2
  import type { IKuzzleConfiguration } from "../types/config/KuzzleConfiguration";
5
3
  import type State from "./state";
@@ -35,13 +35,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
35
35
  }) : function(o, v) {
36
36
  o["default"] = v;
37
37
  });
38
- var __importStar = (this && this.__importStar) || function (mod) {
39
- if (mod && mod.__esModule) return mod;
40
- var result = {};
41
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
42
- __setModuleDefault(result, mod);
43
- return result;
44
- };
38
+ var __importStar = (this && this.__importStar) || (function () {
39
+ var ownKeys = function(o) {
40
+ ownKeys = Object.getOwnPropertyNames || function (o) {
41
+ var ar = [];
42
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
43
+ return ar;
44
+ };
45
+ return ownKeys(o);
46
+ };
47
+ return function (mod) {
48
+ if (mod && mod.__esModule) return mod;
49
+ var result = {};
50
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
51
+ __setModuleDefault(result, mod);
52
+ return result;
53
+ };
54
+ })();
45
55
  var __importDefault = (this && this.__importDefault) || function (mod) {
46
56
  return (mod && mod.__esModule) ? mod : { "default": mod };
47
57
  };
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import Redis from "../../service/cache/redis";
3
2
  /**
4
3
  * `redis.ts` uses `export =`, so it cannot also export this type. Deriving it
@@ -39,6 +38,12 @@ declare class IDCardRenewer {
39
38
  init(config: IDCardRenewerConfig): Promise<void>;
40
39
  initRedis(config?: RedisServiceConfig, name?: string): Promise<void>;
41
40
  renewIDCard(): Promise<void>;
41
+ /**
42
+ * Disposes the worker and tells the parent why, once: the renewals queued
43
+ * behind a stalled redis all fail together, and each report evicts the node
44
+ * again (#3017)
45
+ */
46
+ private reportFailure;
42
47
  dispose(): Promise<void>;
43
48
  }
44
49
  export { IDCardRenewer };
@@ -104,18 +104,24 @@ class IDCardRenewer {
104
104
  // Unable to refresh the key in time before it expires
105
105
  // => this node is too slow, we need to remove it from the cluster
106
106
  if (refreshed === 0) {
107
- await this.dispose();
108
- process.send?.({
109
- error: "Node too slow: ID card expired",
110
- });
107
+ await this.reportFailure("Node too slow: ID card expired");
111
108
  }
112
109
  }
113
110
  catch (error) {
114
- await this.dispose();
115
- process.send?.({
116
- error: `Failed to refresh ID Card: ${messageOf(error)}`,
117
- });
111
+ await this.reportFailure(`Failed to refresh ID Card: ${messageOf(error)}`);
112
+ }
113
+ }
114
+ /**
115
+ * Disposes the worker and tells the parent why, once: the renewals queued
116
+ * behind a stalled redis all fail together, and each report evicts the node
117
+ * again (#3017)
118
+ */
119
+ async reportFailure(error) {
120
+ if (this.disposed) {
121
+ return;
118
122
  }
123
+ await this.dispose();
124
+ process.send?.({ error });
119
125
  }
120
126
  async dispose() {
121
127
  if (this.disposed) {
@@ -23,7 +23,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
23
23
  return (mod && mod.__esModule) ? mod : { "default": mod };
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.loadConfig = void 0;
26
+ exports.loadConfig = loadConfig;
27
27
  const assert_1 = __importDefault(require("assert"));
28
28
  const node_util_1 = require("node:util");
29
29
  const rc_1 = __importDefault(require("rc"));
@@ -34,32 +34,38 @@ const safeObject_1 = require("../util/safeObject");
34
34
  const bytes_1 = __importDefault(require("../util/bytes"));
35
35
  const wrapped = (0, kerror_1.wrap)("core", "configuration");
36
36
  function loadConfig() {
37
- let config;
37
+ let loaded;
38
38
  try {
39
- config = (0, rc_1.default)("kuzzle", default_config_1.default);
39
+ loaded = (0, rc_1.default)("kuzzle", default_config_1.default);
40
40
  }
41
41
  catch (e) {
42
42
  throw wrapped.get("cannot_parse", e instanceof Error ? e.message : (0, node_util_1.inspect)(e));
43
43
  }
44
- config = unstringify(config);
45
- checkLimitsConfig(config);
46
- checkHttpOptions(config);
47
- checkWebSocketOptions(config);
48
- checkClusterOptions(config);
49
- config.internal = {
50
- hash: {
51
- seed: Buffer.from("^m&mOISKBvb1xpl1mRsrylaQXpjb&IJX"),
44
+ // In place: what `unstringify` answers is the object it was given.
45
+ unstringify(loaded);
46
+ checkLimitsConfig(loaded);
47
+ checkHttpOptions(loaded);
48
+ checkWebSocketOptions(loaded);
49
+ checkClusterOptions(loaded);
50
+ // The two sections the defaults do not carry. `notifiableProtocols` is
51
+ // filled in by `preprocessProtocolsOptions` below; `version` injects the
52
+ // current Kuzzle version.
53
+ const config = {
54
+ ...loaded,
55
+ internal: {
56
+ hash: {
57
+ seed: Buffer.from("^m&mOISKBvb1xpl1mRsrylaQXpjb&IJX"),
58
+ },
59
+ notifiableProtocols: [],
52
60
  },
61
+ version: package_json_1.default.version,
53
62
  };
54
63
  preprocessHttpOptions(config);
55
64
  preprocessProtocolsOptions(config);
56
65
  preprocessRedisOptions(config.services.internalCache);
57
66
  preprocessRedisOptions(config.services.memoryStorage);
58
- // Injects the current Kuzzle version
59
- config.version = package_json_1.default.version;
60
67
  return config;
61
68
  }
62
- exports.loadConfig = loadConfig;
63
69
  /**
64
70
  * RC params can be overriden using environment variables,
65
71
  * in which case all values are passed as strings.
@@ -1,7 +1,7 @@
1
1
  import type { Profile } from "../../model/security/profile";
2
2
  import type { Role } from "../../model/security/role";
3
3
  import type { User } from "../../model/security/user";
4
- import type { Serialized } from "../../types/core/auth/formatProcessing.type";
4
+ import type { Serialized } from "../../types/core/auth/Serialized";
5
5
  declare const _default: {
6
6
  /**
7
7
  * Serializes profile and transforms it into a POJO
@@ -29,7 +29,7 @@ exports.default = {
29
29
  */
30
30
  serializeProfile(profile) {
31
31
  const { _id, ..._source } = profile;
32
- return { _id, _source: _source };
32
+ return { _id, _source };
33
33
  },
34
34
  /**
35
35
  * Serializes role and transforms it into a POJO
@@ -39,7 +39,7 @@ exports.default = {
39
39
  */
40
40
  serializeRole(role) {
41
41
  const { _id, ..._source } = role;
42
- return { _id, _source: _source };
42
+ return { _id, _source };
43
43
  },
44
44
  /**
45
45
  * Serializes user and transforms it into a POJO
@@ -49,7 +49,7 @@ exports.default = {
49
49
  */
50
50
  serializeUser(user) {
51
51
  const { _id, ..._source } = user;
52
- return { _id, _source: _source };
52
+ return { _id, _source };
53
53
  },
54
54
  };
55
55
  //# sourceMappingURL=formatProcessing.js.map
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import type { OutgoingHttpHeaders } from "http";
3
2
  /**
4
3
  * @class PassportResponse
@@ -35,13 +35,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
35
35
  }) : function(o, v) {
36
36
  o["default"] = v;
37
37
  });
38
- var __importStar = (this && this.__importStar) || function (mod) {
39
- if (mod && mod.__esModule) return mod;
40
- var result = {};
41
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
42
- __setModuleDefault(result, mod);
43
- return result;
44
- };
38
+ var __importStar = (this && this.__importStar) || (function () {
39
+ var ownKeys = function(o) {
40
+ ownKeys = Object.getOwnPropertyNames || function (o) {
41
+ var ar = [];
42
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
43
+ return ar;
44
+ };
45
+ return ownKeys(o);
46
+ };
47
+ return function (mod) {
48
+ if (mod && mod.__esModule) return mod;
49
+ var result = {};
50
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
51
+ __setModuleDefault(result, mod);
52
+ return result;
53
+ };
54
+ })();
45
55
  var __importDefault = (this && this.__importDefault) || function (mod) {
46
56
  return (mod && mod.__esModule) ? mod : { "default": mod };
47
57
  };
@@ -63,6 +73,7 @@ class PassportWrapper {
63
73
  * @param strategyName
64
74
  * @returns {Promise.<*>}
65
75
  */
76
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- kept for v2 compatibility, see docs/v3-breaking-changes.md
66
77
  authenticate(request, strategyName) {
67
78
  const response = new passportResponse_1.default();
68
79
  return new bluebird_1.default((resolve, reject) => {
@@ -88,7 +99,12 @@ class PassportWrapper {
88
99
  fail(err);
89
100
  }
90
101
  else if (!user) {
91
- reject(kerror.get("plugin", "strategy", "missing_user", info.message));
102
+ const message =
103
+ // `typeof null` is "object" too: a strategy may fail with no info
104
+ typeof info === "object" && info !== null && "message" in info
105
+ ? info.message
106
+ : undefined;
107
+ reject(kerror.get("plugin", "strategy", "missing_user", message));
92
108
  }
93
109
  else {
94
110
  resolve(user);
@@ -35,13 +35,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
35
35
  }) : function(o, v) {
36
36
  o["default"] = v;
37
37
  });
38
- var __importStar = (this && this.__importStar) || function (mod) {
39
- if (mod && mod.__esModule) return mod;
40
- var result = {};
41
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
42
- __setModuleDefault(result, mod);
43
- return result;
44
- };
38
+ var __importStar = (this && this.__importStar) || (function () {
39
+ var ownKeys = function(o) {
40
+ ownKeys = Object.getOwnPropertyNames || function (o) {
41
+ var ar = [];
42
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
43
+ return ar;
44
+ };
45
+ return ownKeys(o);
46
+ };
47
+ return function (mod) {
48
+ if (mod && mod.__esModule) return mod;
49
+ var result = {};
50
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
51
+ __setModuleDefault(result, mod);
52
+ return result;
53
+ };
54
+ })();
45
55
  var __importDefault = (this && this.__importDefault) || function (mod) {
46
56
  return (mod && mod.__esModule) ? mod : { "default": mod };
47
57
  };
@@ -26,7 +26,7 @@ export declare class BackendConfig extends ApplicationManager {
26
26
  * @param path - Path to the configuration key (lodash style)
27
27
  * @param value - Value for the configuration key
28
28
  */
29
- set(path: string, value: any): void;
29
+ set(path: string, value: unknown): void;
30
30
  /**
31
31
  * Merges a configuration object into the current configuration
32
32
  *
@@ -35,13 +35,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
35
35
  }) : function(o, v) {
36
36
  o["default"] = v;
37
37
  });
38
- var __importStar = (this && this.__importStar) || function (mod) {
39
- if (mod && mod.__esModule) return mod;
40
- var result = {};
41
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
42
- __setModuleDefault(result, mod);
43
- return result;
44
- };
38
+ var __importStar = (this && this.__importStar) || (function () {
39
+ var ownKeys = function(o) {
40
+ ownKeys = Object.getOwnPropertyNames || function (o) {
41
+ var ar = [];
42
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
43
+ return ar;
44
+ };
45
+ return ownKeys(o);
46
+ };
47
+ return function (mod) {
48
+ if (mod && mod.__esModule) return mod;
49
+ var result = {};
50
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
51
+ __setModuleDefault(result, mod);
52
+ return result;
53
+ };
54
+ })();
45
55
  var __importDefault = (this && this.__importDefault) || function (mod) {
46
56
  return (mod && mod.__esModule) ? mod : { "default": mod };
47
57
  };