kuzzle 2.27.1 → 2.27.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.
- package/README.md +12 -6
- package/lib/api/controllers/adminController.js +9 -9
- package/lib/api/controllers/bulkController.js +9 -9
- package/lib/api/controllers/collectionController.js +17 -17
- package/lib/api/controllers/documentController.js +51 -51
- package/lib/api/controllers/indexController.js +4 -4
- package/lib/api/controllers/memoryStorageController.js +11 -11
- package/lib/api/controllers/realtimeController.js +1 -1
- package/lib/api/controllers/securityController.js +67 -70
- package/lib/api/controllers/serverController.js +5 -5
- package/lib/api/documentExtractor.js +3 -3
- package/lib/api/funnel.js +43 -43
- package/lib/api/rateLimiter.js +1 -1
- package/lib/cluster/command.js +4 -4
- package/lib/cluster/idCardHandler.js +1 -1
- package/lib/cluster/node.js +55 -55
- package/lib/cluster/subscriber.js +33 -33
- package/lib/cluster/workers/IDCardRenewer.js +4 -4
- package/lib/config/index.js +24 -24
- package/lib/core/auth/passportWrapper.js +6 -6
- package/lib/core/cache/cacheEngine.js +20 -20
- package/lib/core/network/accessLogger.js +15 -15
- package/lib/core/network/entryPoint.js +12 -12
- package/lib/core/network/httpRouter/index.js +4 -4
- package/lib/core/network/httpRouter/routePart.js +2 -2
- package/lib/core/network/protocols/httpwsProtocol.js +41 -41
- package/lib/core/network/protocols/internalProtocol.js +2 -2
- package/lib/core/network/protocols/mqttProtocol.js +9 -9
- package/lib/core/network/protocols/protocol.js +3 -3
- package/lib/core/network/router.js +7 -7
- package/lib/core/plugin/plugin.js +23 -23
- package/lib/core/plugin/pluginManifest.js +1 -1
- package/lib/core/plugin/pluginsManager.js +62 -62
- package/lib/core/realtime/notifier.js +14 -14
- package/lib/core/security/README.md +223 -0
- package/lib/core/security/roleRepository.js +18 -18
- package/lib/core/security/securityLoader.js +7 -7
- package/lib/core/security/userRepository.js +16 -16
- package/lib/core/shared/README.md +3 -0
- package/lib/core/shared/abstractManifest.js +1 -1
- package/lib/core/shared/sdk/impersonatedSdk.js +1 -1
- package/lib/core/shared/store.js +11 -11
- package/lib/core/statistics/statistics.js +15 -15
- package/lib/core/storage/clientAdapter.js +61 -61
- package/lib/core/validation/baseType.js +1 -1
- package/lib/core/validation/types/date.js +1 -1
- package/lib/core/validation/types/enum.js +5 -5
- package/lib/core/validation/types/geoShape.js +13 -13
- package/lib/core/validation/types/numeric.js +2 -2
- package/lib/core/validation/types/string.js +2 -2
- package/lib/core/validation/validation.js +71 -71
- package/lib/kerror/codes/index.js +23 -23
- package/lib/kuzzle/dumpGenerator.js +17 -17
- package/lib/kuzzle/event/kuzzleEventEmitter.js +9 -9
- package/lib/kuzzle/event/pipeRunner.js +2 -2
- package/lib/kuzzle/internalIndexHandler.js +8 -8
- package/lib/kuzzle/log.js +2 -2
- package/lib/kuzzle/vault.js +4 -4
- package/lib/model/security/role.js +3 -1
- package/lib/model/security/user.js +3 -1
- package/lib/model/storage/apiKey.js +3 -3
- package/lib/model/storage/baseModel.js +7 -7
- package/lib/service/cache/redis.js +3 -3
- package/lib/service/storage/elasticsearch.js +52 -52
- package/lib/service/storage/esWrapper.js +3 -3
- package/lib/service/storage/queryTranslator.js +2 -2
- package/lib/util/assertType.js +1 -1
- package/lib/util/deprecate.js +3 -3
- package/lib/util/extractFields.js +2 -2
- package/lib/util/wildcard.js +1 -1
- package/package.json +69 -81
|
@@ -49,57 +49,57 @@ function checkErrors(subdomain, domain, options) {
|
|
|
49
49
|
for (const [name, error] of Object.entries(subdomain.errors)) {
|
|
50
50
|
assert(
|
|
51
51
|
has(error, "code"),
|
|
52
|
-
`Error configuration file : Missing required 'code' field (domain: ${domain.code}, subdomain: ${subdomain.code}, error: ${name})
|
|
52
|
+
`Error configuration file : Missing required 'code' field (domain: ${domain.code}, subdomain: ${subdomain.code}, error: ${name}).`,
|
|
53
53
|
);
|
|
54
54
|
assert(
|
|
55
55
|
Number.isInteger(error.code),
|
|
56
|
-
`Error configuration file : Field 'code' must be an integer (domain: ${domain.code}, subdomain: ${subdomain.code}, error: ${name})
|
|
56
|
+
`Error configuration file : Field 'code' must be an integer (domain: ${domain.code}, subdomain: ${subdomain.code}, error: ${name}).`,
|
|
57
57
|
);
|
|
58
58
|
assert(
|
|
59
59
|
error.code > 0x0000 && error.code <= 0xffff,
|
|
60
|
-
`Error configuration file : Field 'code' must be between 1 and 65535 (domain: ${domain.code}, subdomain: ${subdomain.code}, error: ${name})
|
|
60
|
+
`Error configuration file : Field 'code' must be between 1 and 65535 (domain: ${domain.code}, subdomain: ${subdomain.code}, error: ${name}).`,
|
|
61
61
|
);
|
|
62
62
|
assert(
|
|
63
63
|
!codes.has(error.code),
|
|
64
|
-
`Error configuration file : code ${error.code} for error '${name}' is not unique (domain: ${domain.code}, subdomain: ${subdomain.code})
|
|
64
|
+
`Error configuration file : code ${error.code} for error '${name}' is not unique (domain: ${domain.code}, subdomain: ${subdomain.code}).`,
|
|
65
65
|
);
|
|
66
66
|
|
|
67
67
|
codes.add(error.code);
|
|
68
68
|
|
|
69
69
|
assert(
|
|
70
70
|
has(error, "message"),
|
|
71
|
-
`Error configuration file : Missing required 'message' field (domain: ${domain.code}, subdomain: ${subdomain.code}, error: ${name})
|
|
71
|
+
`Error configuration file : Missing required 'message' field (domain: ${domain.code}, subdomain: ${subdomain.code}, error: ${name}).`,
|
|
72
72
|
);
|
|
73
73
|
assert(
|
|
74
74
|
typeof error.message === "string" && error.message.length > 0,
|
|
75
|
-
`Error configuration file : Field 'message' must be a non-empty string (domain: ${domain.code}, subdomain: ${subdomain.code}, error: ${name})
|
|
75
|
+
`Error configuration file : Field 'message' must be a non-empty string (domain: ${domain.code}, subdomain: ${subdomain.code}, error: ${name}).`,
|
|
76
76
|
);
|
|
77
77
|
|
|
78
78
|
assert(
|
|
79
79
|
has(error, "class"),
|
|
80
|
-
`Error configuration file : Missing required 'class' field (domain: ${domain.code}, subdomain: ${subdomain.code}, error: ${name})
|
|
80
|
+
`Error configuration file : Missing required 'class' field (domain: ${domain.code}, subdomain: ${subdomain.code}, error: ${name}).`,
|
|
81
81
|
);
|
|
82
82
|
assert(
|
|
83
83
|
typeof error.class === "string",
|
|
84
|
-
`Error configuration file : Field 'class' must be a string (domain: ${domain.code}, subdomain: ${subdomain.code}, error: ${name})
|
|
84
|
+
`Error configuration file : Field 'class' must be a string (domain: ${domain.code}, subdomain: ${subdomain.code}, error: ${name}).`,
|
|
85
85
|
);
|
|
86
86
|
assert(
|
|
87
87
|
has(errors, error.class),
|
|
88
|
-
`Error configuration file : Field 'class' must target a known KuzzleError object (domain: ${domain.code}, subdomain: ${subdomain.code}, error: ${name}), '${name.class}' does not exist
|
|
88
|
+
`Error configuration file : Field 'class' must target a known KuzzleError object (domain: ${domain.code}, subdomain: ${subdomain.code}, error: ${name}), '${name.class}' does not exist.`,
|
|
89
89
|
);
|
|
90
90
|
|
|
91
91
|
// plugin errors aren't required to have descriptions
|
|
92
92
|
if (!options.plugin) {
|
|
93
93
|
assert(
|
|
94
94
|
typeof error.description === "string" && error.description.length > 0,
|
|
95
|
-
`Error configuration file : Field 'description' must be a non-empty string (domain: ${domain.code}, subdomain: ${subdomain.code}, error: ${name})
|
|
95
|
+
`Error configuration file : Field 'description' must be a non-empty string (domain: ${domain.code}, subdomain: ${subdomain.code}, error: ${name}).`,
|
|
96
96
|
);
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
if (error.deprecated !== undefined && error.deprecated !== null) {
|
|
100
100
|
assert(
|
|
101
101
|
typeof error.deprecated === "string" && error.deprecated.length > 0,
|
|
102
|
-
`Error configuration file : Field 'deprecated' must be a non-empty string (domain: ${domain.code}, subdomain: ${subdomain.code}, error: ${name})
|
|
102
|
+
`Error configuration file : Field 'deprecated' must be a non-empty string (domain: ${domain.code}, subdomain: ${subdomain.code}, error: ${name}).`,
|
|
103
103
|
);
|
|
104
104
|
}
|
|
105
105
|
}
|
|
@@ -115,7 +115,7 @@ function checkSubdomains(domain, options) {
|
|
|
115
115
|
if (!options.plugin) {
|
|
116
116
|
assert(
|
|
117
117
|
has(subdomain, "code"),
|
|
118
|
-
`Error configuration file : Missing required 'code' field (domain: ${domain.code}, subdomain: ${subdomainName})
|
|
118
|
+
`Error configuration file : Missing required 'code' field (domain: ${domain.code}, subdomain: ${subdomainName}).`,
|
|
119
119
|
);
|
|
120
120
|
} else if (!has(subdomain, "code")) {
|
|
121
121
|
subdomain.code = 0;
|
|
@@ -123,15 +123,15 @@ function checkSubdomains(domain, options) {
|
|
|
123
123
|
|
|
124
124
|
assert(
|
|
125
125
|
Number.isInteger(subdomain.code),
|
|
126
|
-
`Error configuration file : Field 'code' must be an integer (domain: ${domain.code}, subdomain: ${subdomainName})
|
|
126
|
+
`Error configuration file : Field 'code' must be an integer (domain: ${domain.code}, subdomain: ${subdomainName}).`,
|
|
127
127
|
);
|
|
128
128
|
assert(
|
|
129
129
|
subdomain.code >= 0x00 && subdomain.code <= 0xff,
|
|
130
|
-
`Error configuration file : Field 'code' must be between 0 and 255 (domain: ${domain.code}, subdomain: ${subdomainName})
|
|
130
|
+
`Error configuration file : Field 'code' must be between 0 and 255 (domain: ${domain.code}, subdomain: ${subdomainName}).`,
|
|
131
131
|
);
|
|
132
132
|
assert(
|
|
133
133
|
!subdomainCodes.has(subdomain.code),
|
|
134
|
-
`Error configuration file : code ${subdomain.code} for subdomain '${subdomainName}' is not unique (domain: ${domain.code})
|
|
134
|
+
`Error configuration file : code ${subdomain.code} for subdomain '${subdomainName}' is not unique (domain: ${domain.code}).`,
|
|
135
135
|
);
|
|
136
136
|
|
|
137
137
|
// We don't allow duplicates, except for defaulted plugin subdomain codes
|
|
@@ -141,11 +141,11 @@ function checkSubdomains(domain, options) {
|
|
|
141
141
|
|
|
142
142
|
assert(
|
|
143
143
|
has(subdomain, "errors"),
|
|
144
|
-
`Error configuration file : Missing required 'errors' field (domain: ${domain.code}, subdomain: ${subdomainName})
|
|
144
|
+
`Error configuration file : Missing required 'errors' field (domain: ${domain.code}, subdomain: ${subdomainName}).`,
|
|
145
145
|
);
|
|
146
146
|
assert(
|
|
147
147
|
isPlainObject(subdomain.errors),
|
|
148
|
-
`Error configuration file : Field 'errors' must be an object (domain: ${domain.code}, subdomain: ${subdomainName})
|
|
148
|
+
`Error configuration file : Field 'errors' must be an object (domain: ${domain.code}, subdomain: ${subdomainName}).`,
|
|
149
149
|
);
|
|
150
150
|
|
|
151
151
|
checkErrors(subdomain, domain, options);
|
|
@@ -160,30 +160,30 @@ function checkDomains(errorCodesFiles, options = { plugin: false }) {
|
|
|
160
160
|
|
|
161
161
|
assert(
|
|
162
162
|
has(domain, "code"),
|
|
163
|
-
`Error configuration file : Missing required 'code' field. (domain: '${domainName}')
|
|
163
|
+
`Error configuration file : Missing required 'code' field. (domain: '${domainName}').`,
|
|
164
164
|
);
|
|
165
165
|
assert(
|
|
166
166
|
Number.isInteger(domain.code),
|
|
167
|
-
`Error configuration file : Field 'code' must be an integer. (domain: '${domainName}')
|
|
167
|
+
`Error configuration file : Field 'code' must be an integer. (domain: '${domainName}').`,
|
|
168
168
|
);
|
|
169
169
|
assert(
|
|
170
170
|
domain.code >= 0x00 && domain.code <= 0xff,
|
|
171
|
-
`Error configuration file : Field 'code' must be between 0 and 255. (domain: '${domainName}')
|
|
171
|
+
`Error configuration file : Field 'code' must be between 0 and 255. (domain: '${domainName}').`,
|
|
172
172
|
);
|
|
173
173
|
assert(
|
|
174
174
|
!domainCodes.has(domain.code),
|
|
175
|
-
`Error configuration file : code ${domain.code} for domain ${domainName} is not unique
|
|
175
|
+
`Error configuration file : code ${domain.code} for domain ${domainName} is not unique.`,
|
|
176
176
|
);
|
|
177
177
|
|
|
178
178
|
domainCodes.add(domain.code);
|
|
179
179
|
|
|
180
180
|
assert(
|
|
181
181
|
has(domain, "subDomains"),
|
|
182
|
-
`Error configuration file : Missing required 'subDomains' field. (domain: '${domainName}')
|
|
182
|
+
`Error configuration file : Missing required 'subDomains' field. (domain: '${domainName}').`,
|
|
183
183
|
);
|
|
184
184
|
assert(
|
|
185
185
|
isPlainObject(domain.subDomains),
|
|
186
|
-
`Error configuration file : Field 'subDomains' must be an object. (domain: '${domainName}')
|
|
186
|
+
`Error configuration file : Field 'subDomains' must be an object. (domain: '${domainName}').`,
|
|
187
187
|
);
|
|
188
188
|
|
|
189
189
|
checkSubdomains(domain, options);
|
|
@@ -56,7 +56,7 @@ class DumpGenerator {
|
|
|
56
56
|
moment()
|
|
57
57
|
.format(global.kuzzle.config.dump.dateFormat)
|
|
58
58
|
.concat(`-${suffix}`)
|
|
59
|
-
.substring(0, 200)
|
|
59
|
+
.substring(0, 200),
|
|
60
60
|
);
|
|
61
61
|
|
|
62
62
|
global.kuzzle.log.info("=".repeat(79));
|
|
@@ -83,8 +83,8 @@ class DumpGenerator {
|
|
|
83
83
|
version: require("../../package.json").version,
|
|
84
84
|
},
|
|
85
85
|
null,
|
|
86
|
-
" "
|
|
87
|
-
).concat("\n")
|
|
86
|
+
" ",
|
|
87
|
+
).concat("\n"),
|
|
88
88
|
);
|
|
89
89
|
|
|
90
90
|
// dump plugins configuration
|
|
@@ -94,8 +94,8 @@ class DumpGenerator {
|
|
|
94
94
|
JSON.stringify(
|
|
95
95
|
global.kuzzle.pluginsManager.getPluginsDescription(),
|
|
96
96
|
null,
|
|
97
|
-
" "
|
|
98
|
-
).concat("\n")
|
|
97
|
+
" ",
|
|
98
|
+
).concat("\n"),
|
|
99
99
|
);
|
|
100
100
|
|
|
101
101
|
// dump Node.js configuration
|
|
@@ -112,8 +112,8 @@ class DumpGenerator {
|
|
|
112
112
|
versions: process.versions,
|
|
113
113
|
},
|
|
114
114
|
null,
|
|
115
|
-
" "
|
|
116
|
-
).concat("\n")
|
|
115
|
+
" ",
|
|
116
|
+
).concat("\n"),
|
|
117
117
|
);
|
|
118
118
|
|
|
119
119
|
// dump os configuration
|
|
@@ -133,8 +133,8 @@ class DumpGenerator {
|
|
|
133
133
|
uptime: os.uptime(),
|
|
134
134
|
},
|
|
135
135
|
null,
|
|
136
|
-
" "
|
|
137
|
-
).concat("\n")
|
|
136
|
+
" ",
|
|
137
|
+
).concat("\n"),
|
|
138
138
|
);
|
|
139
139
|
|
|
140
140
|
// core-dump
|
|
@@ -159,11 +159,11 @@ class DumpGenerator {
|
|
|
159
159
|
fs.unlinkSync(corefiles[0]);
|
|
160
160
|
} catch (e) {
|
|
161
161
|
global.kuzzle.log.warn(
|
|
162
|
-
`> unable to clean up core file ${corefiles[0]}
|
|
162
|
+
`> unable to clean up core file ${corefiles[0]}`,
|
|
163
163
|
);
|
|
164
164
|
}
|
|
165
165
|
resolve();
|
|
166
|
-
})
|
|
166
|
+
}),
|
|
167
167
|
);
|
|
168
168
|
} else {
|
|
169
169
|
global.kuzzle.log.warn("> could not generate dump");
|
|
@@ -179,17 +179,17 @@ class DumpGenerator {
|
|
|
179
179
|
// dumping Kuzzle's stats
|
|
180
180
|
global.kuzzle.log.info("> dumping kuzzle's stats");
|
|
181
181
|
const statistics = await global.kuzzle.statistics.getAllStats(
|
|
182
|
-
new Request({ action: "getAllStats", controller: "statistics" })
|
|
182
|
+
new Request({ action: "getAllStats", controller: "statistics" }),
|
|
183
183
|
);
|
|
184
184
|
|
|
185
185
|
fs.writeFileSync(
|
|
186
186
|
path.join(dumpPath, "statistics.json"),
|
|
187
|
-
JSON.stringify(statistics.hits, null, " ").concat("\n")
|
|
187
|
+
JSON.stringify(statistics.hits, null, " ").concat("\n"),
|
|
188
188
|
);
|
|
189
189
|
|
|
190
190
|
global.kuzzle.log.info("Done.");
|
|
191
191
|
global.kuzzle.log.info(
|
|
192
|
-
"[ℹ] You can send the folder to the kuzzle core team at support@kuzzle.io"
|
|
192
|
+
"[ℹ] You can send the folder to the kuzzle core team at support@kuzzle.io",
|
|
193
193
|
);
|
|
194
194
|
global.kuzzle.log.info("=".repeat(79));
|
|
195
195
|
|
|
@@ -204,7 +204,7 @@ class DumpGenerator {
|
|
|
204
204
|
try {
|
|
205
205
|
fs.accessSync(
|
|
206
206
|
dumpPath,
|
|
207
|
-
fs.constants.R_OK | fs.constants.W_OK | fs.constants.X_OK
|
|
207
|
+
fs.constants.R_OK | fs.constants.W_OK | fs.constants.X_OK,
|
|
208
208
|
);
|
|
209
209
|
} catch (e) {
|
|
210
210
|
return;
|
|
@@ -234,7 +234,7 @@ class DumpGenerator {
|
|
|
234
234
|
for (let i = 0; i < dumps.length - config.history.coredump; i++) {
|
|
235
235
|
const corefiles = this._listFilesMatching(
|
|
236
236
|
path.normalize(dumps[i].path),
|
|
237
|
-
"core"
|
|
237
|
+
"core",
|
|
238
238
|
);
|
|
239
239
|
|
|
240
240
|
if (corefiles[0]) {
|
|
@@ -249,7 +249,7 @@ class DumpGenerator {
|
|
|
249
249
|
.filter(
|
|
250
250
|
(entry) =>
|
|
251
251
|
fs.lstatSync(`${directory}/${entry}`).isFile() &&
|
|
252
|
-
entry.startsWith(start)
|
|
252
|
+
entry.startsWith(start),
|
|
253
253
|
)
|
|
254
254
|
.map((file) => path.join(directory, file));
|
|
255
255
|
}
|
|
@@ -81,7 +81,7 @@ class KuzzleEventEmitter extends EventEmitter {
|
|
|
81
81
|
onPipe(event, fn) {
|
|
82
82
|
assert(
|
|
83
83
|
typeof fn === "function",
|
|
84
|
-
`Cannot listen to pipe event ${event}: "${fn}" is not a function
|
|
84
|
+
`Cannot listen to pipe event ${event}: "${fn}" is not a function`,
|
|
85
85
|
);
|
|
86
86
|
|
|
87
87
|
if (!this.corePipes.has(event)) {
|
|
@@ -101,11 +101,11 @@ class KuzzleEventEmitter extends EventEmitter {
|
|
|
101
101
|
onAsk(event, fn) {
|
|
102
102
|
assert(
|
|
103
103
|
typeof fn === "function",
|
|
104
|
-
`Cannot listen to ask event "${event}": "${fn}" is not a function
|
|
104
|
+
`Cannot listen to ask event "${event}": "${fn}" is not a function`,
|
|
105
105
|
);
|
|
106
106
|
assert(
|
|
107
107
|
!this.coreAnswerers.has(event),
|
|
108
|
-
`Cannot add a listener to the ask event "${event}": event has already an answerer
|
|
108
|
+
`Cannot add a listener to the ask event "${event}": event has already an answerer`,
|
|
109
109
|
);
|
|
110
110
|
|
|
111
111
|
this.coreAnswerers.set(event, fn);
|
|
@@ -121,11 +121,11 @@ class KuzzleEventEmitter extends EventEmitter {
|
|
|
121
121
|
onCall(event, fn) {
|
|
122
122
|
assert(
|
|
123
123
|
typeof fn === "function",
|
|
124
|
-
`Cannot register callback for event "${event}": "${fn}" is not a function
|
|
124
|
+
`Cannot register callback for event "${event}": "${fn}" is not a function`,
|
|
125
125
|
);
|
|
126
126
|
assert(
|
|
127
127
|
!this.coreSyncedAnswerers.has(event),
|
|
128
|
-
`Cannot register callback for event "${event}": a callback has already been registered
|
|
128
|
+
`Cannot register callback for event "${event}": a callback has already been registered`,
|
|
129
129
|
);
|
|
130
130
|
|
|
131
131
|
this.coreSyncedAnswerers.set(event, fn);
|
|
@@ -222,7 +222,7 @@ class KuzzleEventEmitter extends EventEmitter {
|
|
|
222
222
|
"core",
|
|
223
223
|
"fatal",
|
|
224
224
|
"assertion_failed",
|
|
225
|
-
`the requested ask event '${event}' doesn't have an answerer
|
|
225
|
+
`the requested ask event '${event}' doesn't have an answerer`,
|
|
226
226
|
);
|
|
227
227
|
}
|
|
228
228
|
|
|
@@ -232,7 +232,7 @@ class KuzzleEventEmitter extends EventEmitter {
|
|
|
232
232
|
super.emit(ev, {
|
|
233
233
|
args: payload,
|
|
234
234
|
response,
|
|
235
|
-
})
|
|
235
|
+
}),
|
|
236
236
|
);
|
|
237
237
|
|
|
238
238
|
return response;
|
|
@@ -251,7 +251,7 @@ class KuzzleEventEmitter extends EventEmitter {
|
|
|
251
251
|
"core",
|
|
252
252
|
"fatal",
|
|
253
253
|
"assertion_failed",
|
|
254
|
-
`the requested callback event '${event}' doesn't have an answerer
|
|
254
|
+
`the requested callback event '${event}' doesn't have an answerer`,
|
|
255
255
|
);
|
|
256
256
|
}
|
|
257
257
|
|
|
@@ -261,7 +261,7 @@ class KuzzleEventEmitter extends EventEmitter {
|
|
|
261
261
|
super.emit(ev, {
|
|
262
262
|
args: payload,
|
|
263
263
|
response,
|
|
264
|
-
})
|
|
264
|
+
}),
|
|
265
265
|
);
|
|
266
266
|
|
|
267
267
|
return response;
|
|
@@ -83,11 +83,11 @@ class PipeRunner {
|
|
|
83
83
|
constructor(concurrent, bufferSize) {
|
|
84
84
|
assert(
|
|
85
85
|
typeof concurrent === "number" && concurrent > 0,
|
|
86
|
-
"Cannot instantiate pipes executor: invalid maxConcurrentPipes parameter value"
|
|
86
|
+
"Cannot instantiate pipes executor: invalid maxConcurrentPipes parameter value",
|
|
87
87
|
);
|
|
88
88
|
assert(
|
|
89
89
|
typeof bufferSize === "number" && bufferSize > 0,
|
|
90
|
-
"Cannot instantiate pipes executor: invalid pipesBufferSize parameter value"
|
|
90
|
+
"Cannot instantiate pipes executor: invalid pipesBufferSize parameter value",
|
|
91
91
|
);
|
|
92
92
|
|
|
93
93
|
this.maxConcurrent = concurrent;
|
|
@@ -81,7 +81,7 @@ class InternalIndexHandler extends Store {
|
|
|
81
81
|
constructor() {
|
|
82
82
|
super(
|
|
83
83
|
global.kuzzle.config.services.storageEngine.internalIndex.name,
|
|
84
|
-
scopeEnum.PRIVATE
|
|
84
|
+
scopeEnum.PRIVATE,
|
|
85
85
|
);
|
|
86
86
|
|
|
87
87
|
this.timeout =
|
|
@@ -121,7 +121,7 @@ class InternalIndexHandler extends Store {
|
|
|
121
121
|
{ timestamp: Date.now() },
|
|
122
122
|
{
|
|
123
123
|
id: this._BOOTSTRAP_DONE_ID,
|
|
124
|
-
}
|
|
124
|
+
},
|
|
125
125
|
);
|
|
126
126
|
} catch (error) {
|
|
127
127
|
if (error instanceof Bluebird.TimeoutError) {
|
|
@@ -129,7 +129,7 @@ class InternalIndexHandler extends Store {
|
|
|
129
129
|
"services",
|
|
130
130
|
"storage",
|
|
131
131
|
"bootstrap_timeout",
|
|
132
|
-
"internalIndex"
|
|
132
|
+
"internalIndex",
|
|
133
133
|
);
|
|
134
134
|
}
|
|
135
135
|
|
|
@@ -158,7 +158,7 @@ class InternalIndexHandler extends Store {
|
|
|
158
158
|
{ version: dataModelVersion },
|
|
159
159
|
{
|
|
160
160
|
id: this._DATAMODEL_VERSION_ID,
|
|
161
|
-
}
|
|
161
|
+
},
|
|
162
162
|
);
|
|
163
163
|
}
|
|
164
164
|
|
|
@@ -172,7 +172,7 @@ class InternalIndexHandler extends Store {
|
|
|
172
172
|
return this.createOrReplace("roles", roleId, content, {
|
|
173
173
|
refresh: "wait_for",
|
|
174
174
|
});
|
|
175
|
-
}
|
|
175
|
+
},
|
|
176
176
|
);
|
|
177
177
|
|
|
178
178
|
await Bluebird.map(
|
|
@@ -181,7 +181,7 @@ class InternalIndexHandler extends Store {
|
|
|
181
181
|
return this.createOrReplace("profiles", profileId, content, {
|
|
182
182
|
refresh: "wait_for",
|
|
183
183
|
});
|
|
184
|
-
}
|
|
184
|
+
},
|
|
185
185
|
);
|
|
186
186
|
}
|
|
187
187
|
|
|
@@ -194,7 +194,7 @@ class InternalIndexHandler extends Store {
|
|
|
194
194
|
const validationId = `${index}#${collectionName}`;
|
|
195
195
|
|
|
196
196
|
promises.push(
|
|
197
|
-
this.createOrReplace("validations", validationId, validation)
|
|
197
|
+
this.createOrReplace("validations", validationId, validation),
|
|
198
198
|
);
|
|
199
199
|
}
|
|
200
200
|
}
|
|
@@ -218,7 +218,7 @@ class InternalIndexHandler extends Store {
|
|
|
218
218
|
{ seed },
|
|
219
219
|
{
|
|
220
220
|
id: this._JWT_SECRET_ID,
|
|
221
|
-
}
|
|
221
|
+
},
|
|
222
222
|
);
|
|
223
223
|
}
|
|
224
224
|
}
|
package/lib/kuzzle/log.js
CHANGED
|
@@ -58,12 +58,12 @@ class Logger {
|
|
|
58
58
|
|
|
59
59
|
global.kuzzle.emit(
|
|
60
60
|
`log:${method}`,
|
|
61
|
-
`[${global.kuzzle.id}] ${this.failsafeModeString}[${request.id}] ${message}
|
|
61
|
+
`[${global.kuzzle.id}] ${this.failsafeModeString}[${request.id}] ${message}`,
|
|
62
62
|
);
|
|
63
63
|
} else {
|
|
64
64
|
global.kuzzle.emit(
|
|
65
65
|
`log:${method}`,
|
|
66
|
-
`[${global.kuzzle.id}] ${this.failsafeModeString}${message}
|
|
66
|
+
`[${global.kuzzle.id}] ${this.failsafeModeString}${message}`,
|
|
67
67
|
);
|
|
68
68
|
}
|
|
69
69
|
};
|
package/lib/kuzzle/vault.js
CHANGED
|
@@ -35,7 +35,7 @@ function load(vaultKey, secretsFile) {
|
|
|
35
35
|
// Using KaaF kuzzle is an npm package and is located under node_modules folder
|
|
36
36
|
// We need to get back to root folder of the project to get the secret file
|
|
37
37
|
const defaultEncryptedSecretsFile = __dirname.endsWith(
|
|
38
|
-
"/node_modules/kuzzle/lib/kuzzle"
|
|
38
|
+
"/node_modules/kuzzle/lib/kuzzle",
|
|
39
39
|
)
|
|
40
40
|
? path.resolve(`${__dirname}/../../../../config/secrets.enc.json`)
|
|
41
41
|
: path.resolve(`${__dirname}/../../config/secrets.enc.json`);
|
|
@@ -59,7 +59,7 @@ function load(vaultKey, secretsFile) {
|
|
|
59
59
|
if (!_.isEmpty(process.env.KUZZLE_SECRETS_FILE) || !_.isEmpty(secretsFile)) {
|
|
60
60
|
assert(
|
|
61
61
|
fileExists,
|
|
62
|
-
`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
63
|
);
|
|
64
64
|
}
|
|
65
65
|
|
|
@@ -67,14 +67,14 @@ function load(vaultKey, secretsFile) {
|
|
|
67
67
|
// but no vault key has been provided
|
|
68
68
|
assert(
|
|
69
69
|
!(fileExists && _.isEmpty(key)),
|
|
70
|
-
"A secret file has been provided but Kuzzle cannot find the Vault key. Aborting."
|
|
70
|
+
"A secret file has been provided but Kuzzle cannot find the Vault key. Aborting.",
|
|
71
71
|
);
|
|
72
72
|
|
|
73
73
|
// Abort if a vault key has been provided
|
|
74
74
|
// but no secrets file can be loaded (default or custom)
|
|
75
75
|
assert(
|
|
76
76
|
!(!_.isEmpty(key) && !fileExists),
|
|
77
|
-
`A Vault key is present but Kuzzle cannot find the secret file at "${encryptedSecretsFile}". Aborting
|
|
77
|
+
`A Vault key is present but Kuzzle cannot find the secret file at "${encryptedSecretsFile}". Aborting.`,
|
|
78
78
|
);
|
|
79
79
|
|
|
80
80
|
const vault = new Vault(key);
|
|
@@ -115,7 +115,9 @@ class Role {
|
|
|
115
115
|
if (Object.keys(this.controllers).length === 0) {
|
|
116
116
|
throw assertionError.get("empty_argument", `${this._id}.controllers`);
|
|
117
117
|
}
|
|
118
|
-
Object.entries(this.controllers)
|
|
118
|
+
for (const entry of Object.entries(this.controllers)) {
|
|
119
|
+
this.validateControllerRights(...entry);
|
|
120
|
+
}
|
|
119
121
|
}
|
|
120
122
|
/**
|
|
121
123
|
* @param {String} index
|
|
@@ -74,7 +74,9 @@ class User {
|
|
|
74
74
|
const profiles = await this.getProfiles();
|
|
75
75
|
const results = await Promise.all(profiles.map((p) => p.getRights()));
|
|
76
76
|
const rights = {};
|
|
77
|
-
|
|
77
|
+
for (const right of results) {
|
|
78
|
+
lodash_1.default.assignWith(rights, right, rights_1.default.merge);
|
|
79
|
+
}
|
|
78
80
|
return rights;
|
|
79
81
|
}
|
|
80
82
|
/**
|
|
@@ -38,7 +38,7 @@ class ApiKey extends BaseModel {
|
|
|
38
38
|
const token = await global.kuzzle.ask(
|
|
39
39
|
"core:security:token:get",
|
|
40
40
|
this.userId,
|
|
41
|
-
this.token
|
|
41
|
+
this.token,
|
|
42
42
|
);
|
|
43
43
|
|
|
44
44
|
if (token) {
|
|
@@ -93,7 +93,7 @@ class ApiKey extends BaseModel {
|
|
|
93
93
|
user,
|
|
94
94
|
expiresIn,
|
|
95
95
|
description,
|
|
96
|
-
{ creatorId = null, apiKeyId = null, refresh, bypassMaxTTL = false } = {}
|
|
96
|
+
{ creatorId = null, apiKeyId = null, refresh, bypassMaxTTL = false } = {},
|
|
97
97
|
) {
|
|
98
98
|
const token = await global.kuzzle.ask("core:security:token:create", user, {
|
|
99
99
|
bypassMaxTTL,
|
|
@@ -111,7 +111,7 @@ class ApiKey extends BaseModel {
|
|
|
111
111
|
ttl: token.ttl,
|
|
112
112
|
userId: user._id,
|
|
113
113
|
},
|
|
114
|
-
apiKeyId || fingerprint
|
|
114
|
+
apiKeyId || fingerprint,
|
|
115
115
|
);
|
|
116
116
|
|
|
117
117
|
await apiKey.save({ refresh, userId: creatorId });
|
|
@@ -78,7 +78,7 @@ class BaseModel {
|
|
|
78
78
|
const { _id, _source } = await global.kuzzle.internalIndex.create(
|
|
79
79
|
this.constructor.collection,
|
|
80
80
|
this._source,
|
|
81
|
-
{ id: this._id, refresh, userId }
|
|
81
|
+
{ id: this._id, refresh, userId },
|
|
82
82
|
);
|
|
83
83
|
|
|
84
84
|
this._id = _id;
|
|
@@ -89,7 +89,7 @@ class BaseModel {
|
|
|
89
89
|
this.constructor.collection,
|
|
90
90
|
this._id,
|
|
91
91
|
this._source,
|
|
92
|
-
{ refresh, userId }
|
|
92
|
+
{ refresh, userId },
|
|
93
93
|
);
|
|
94
94
|
}
|
|
95
95
|
}
|
|
@@ -110,7 +110,7 @@ class BaseModel {
|
|
|
110
110
|
await global.kuzzle.internalIndex.delete(
|
|
111
111
|
this.constructor.collection,
|
|
112
112
|
this._id,
|
|
113
|
-
{ refresh }
|
|
113
|
+
{ refresh },
|
|
114
114
|
);
|
|
115
115
|
|
|
116
116
|
await this._afterDelete();
|
|
@@ -190,13 +190,13 @@ class BaseModel {
|
|
|
190
190
|
static async deleteByQuery(query, { refresh } = {}) {
|
|
191
191
|
const { documents } = await global.kuzzle.internalIndex.deleteByQuery(
|
|
192
192
|
this.collection,
|
|
193
|
-
query
|
|
193
|
+
query,
|
|
194
194
|
);
|
|
195
195
|
|
|
196
196
|
await Bluebird.map(
|
|
197
197
|
documents,
|
|
198
198
|
(document) => this._instantiateFromDb(document)._afterDelete(),
|
|
199
|
-
{ concurrency: 10 }
|
|
199
|
+
{ concurrency: 10 },
|
|
200
200
|
); // limits the load on storage services
|
|
201
201
|
|
|
202
202
|
if (refresh) {
|
|
@@ -216,7 +216,7 @@ class BaseModel {
|
|
|
216
216
|
const resp = await global.kuzzle.internalIndex.search(
|
|
217
217
|
this.collection,
|
|
218
218
|
searchBody,
|
|
219
|
-
options
|
|
219
|
+
options,
|
|
220
220
|
);
|
|
221
221
|
|
|
222
222
|
return resp.hits.map((hit) => this._instantiateFromDb(hit));
|
|
@@ -237,7 +237,7 @@ class BaseModel {
|
|
|
237
237
|
return global.kuzzle.internalIndex.mExecute(
|
|
238
238
|
this.collection,
|
|
239
239
|
query,
|
|
240
|
-
callback
|
|
240
|
+
callback,
|
|
241
241
|
);
|
|
242
242
|
}
|
|
243
243
|
|
|
@@ -77,7 +77,7 @@ class Redis extends Service {
|
|
|
77
77
|
this.client.on("error", (error) => {
|
|
78
78
|
if (this.connected) {
|
|
79
79
|
global.kuzzle.log.error(
|
|
80
|
-
`Redis service seem to be down, see original error for more info:\n${error.message}
|
|
80
|
+
`Redis service seem to be down, see original error for more info:\n${error.message}`,
|
|
81
81
|
);
|
|
82
82
|
}
|
|
83
83
|
this.connected = false;
|
|
@@ -93,7 +93,7 @@ class Redis extends Service {
|
|
|
93
93
|
this.client.once("ready", async () => {
|
|
94
94
|
await this.client.client(
|
|
95
95
|
"SETNAME",
|
|
96
|
-
`${this.adapterName}/${global.kuzzle.id}
|
|
96
|
+
`${this.adapterName}/${global.kuzzle.id}`,
|
|
97
97
|
);
|
|
98
98
|
resolve();
|
|
99
99
|
});
|
|
@@ -128,7 +128,7 @@ class Redis extends Service {
|
|
|
128
128
|
await this.client.ping();
|
|
129
129
|
} catch (error) {
|
|
130
130
|
global.kuzzle.log.error(
|
|
131
|
-
`Failed to PING Redis to keep connection alive:\n${error.message}
|
|
131
|
+
`Failed to PING Redis to keep connection alive:\n${error.message}`,
|
|
132
132
|
);
|
|
133
133
|
}
|
|
134
134
|
}
|