kuzzle 2.16.4 → 2.16.8

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 (44) hide show
  1. package/lib/api/controllers/authController.js +2 -2
  2. package/lib/api/controllers/collectionController.js +2 -8
  3. package/lib/api/controllers/serverController.js +27 -14
  4. package/lib/config/default.config.d.ts +13 -0
  5. package/lib/config/default.config.js +363 -362
  6. package/lib/config/index.js +7 -5
  7. package/lib/core/backend/backendConfig.d.ts +3 -3
  8. package/lib/core/backend/backendConfig.js +2 -2
  9. package/lib/model/security/profile.js +10 -10
  10. package/lib/model/security/role.js +3 -3
  11. package/lib/service/cache/redis.js +33 -0
  12. package/lib/service/storage/elasticsearch.js +6 -0
  13. package/lib/types/PasswordPolicy.d.ts +77 -0
  14. package/lib/types/PasswordPolicy.js +3 -0
  15. package/lib/types/ProfileDefinition.d.ts +48 -0
  16. package/lib/types/ProfileDefinition.js +3 -0
  17. package/lib/types/RoleDefinition.d.ts +27 -0
  18. package/lib/types/RoleDefinition.js +3 -0
  19. package/lib/types/config/DumpConfiguration.d.ts +42 -0
  20. package/lib/types/config/DumpConfiguration.js +3 -0
  21. package/lib/types/config/HttpConfiguration.d.ts +43 -0
  22. package/lib/types/config/HttpConfiguration.js +9 -0
  23. package/lib/types/config/KuzzleConfiguration.d.ts +123 -0
  24. package/lib/types/config/KuzzleConfiguration.js +3 -0
  25. package/lib/types/config/LimitsConfiguration.d.ts +111 -0
  26. package/lib/types/config/LimitsConfiguration.js +3 -0
  27. package/lib/types/config/PluginsConfiguration.d.ts +177 -0
  28. package/lib/types/config/PluginsConfiguration.js +3 -0
  29. package/lib/types/config/SecurityConfiguration.d.ts +182 -0
  30. package/lib/types/config/SecurityConfiguration.js +3 -0
  31. package/lib/types/config/ServerConfiguration.d.ts +195 -0
  32. package/lib/types/config/ServerConfiguration.js +3 -0
  33. package/lib/types/config/ServicesConfiguration.d.ts +41 -0
  34. package/lib/types/config/ServicesConfiguration.js +3 -0
  35. package/lib/types/config/StorageService/StorageServiceElasticsearchConfiguration.d.ts +217 -0
  36. package/lib/types/config/StorageService/StorageServiceElasticsearchConfiguration.js +3 -0
  37. package/lib/types/config/internalCache/InternalCacheRedisConfiguration.d.ts +111 -0
  38. package/lib/types/config/internalCache/InternalCacheRedisConfiguration.js +3 -0
  39. package/lib/types/config/publicCache/PublicCacheRedisConfiguration.d.ts +31 -0
  40. package/lib/types/config/publicCache/PublicCacheRedisConfiguration.js +3 -0
  41. package/lib/types/index.d.ts +17 -0
  42. package/lib/types/index.js +17 -0
  43. package/package-lock.json +1 -1
  44. package/package.json +1 -1
@@ -0,0 +1,111 @@
1
+ export declare type LimitsConfiguration = {
2
+ /**
3
+ * Number of requests Kuzzle processes simultaneously.
4
+ *
5
+ * Requests received above this limit are buffered until a slot is freed
6
+ *
7
+ * This value should be kept low to avoid overloading Kuzzle's event loop.
8
+ *
9
+ * @default 100
10
+ */
11
+ concurrentRequests: number;
12
+ /**
13
+ * Maximum number of documents that can be fetched by a single API
14
+ * request. The minimum value to this limit is 1.
15
+ *
16
+ * This limits is applied to any route returning multiple documents,
17
+ * such as document:mGet or document:search
18
+ *
19
+ * You may have to configure ElasticSearch as well if you need
20
+ * to set this value higher than 10000
21
+ *
22
+ * @default 10000
23
+ */
24
+ documentsFetchCount: number;
25
+ /**
26
+ * Maximum number of documents that can be written by a single API
27
+ * request. The minimum value to this limit is 1.
28
+ *
29
+ * There is no higher limit to this value, but you may
30
+ * also have to change the value of the `maxRequestSize` parameter
31
+ * (in the `server` section) to make Kuzzle accept larger requests.
32
+ *
33
+ * @default 200
34
+ */
35
+ documentsWriteCount: number;
36
+ /**
37
+ * Maximum number of logins per second and per network connection.
38
+ *
39
+ * @default 1
40
+ */
41
+ loginsPerSecond: number;
42
+ /**
43
+ * Maximum number of requests that can be buffered.
44
+ *
45
+ * Requests received above this limit are discarded with a 503 error
46
+ *
47
+ * @default 50000
48
+ */
49
+ requestsBufferSize: number;
50
+ /**
51
+ * Number of buffered requests after which Kuzzle
52
+ * will throw `core:overload` events.
53
+ *
54
+ * @see https://docs.kuzzle.io/core/2/framework/events/core/#core-overload
55
+ *
56
+ * @default 5000
57
+ *
58
+ */
59
+ requestsBufferWarningThreshold: number;
60
+ /**
61
+ * Maximum number of conditions a subscription filter can contain.
62
+ *
63
+ * NB: A condition is either a "simple" operator (anything but "and",
64
+ * "or" and "bool"), or a boolean condition that contains only
65
+ * simple operators.
66
+ *
67
+ * @default 100
68
+ */
69
+ subscriptionConditionsCount: number;
70
+ /**
71
+ * Maximum number of minterms (AND) clauses after the filters are
72
+ * transformed in their Canonical Disjunctive Normal Form (CDNF).
73
+ *
74
+ * Set to 0 for no limit.
75
+ *
76
+ * @default 0
77
+ */
78
+ subscriptionMinterms: number;
79
+ /**
80
+ * Maximum number of different subscription rooms.
81
+ * (i.e. different index+collection+filters subscription configurations)
82
+ *
83
+ * Depends primarily on available memory.
84
+ *
85
+ * If set to 0, an unlimited number of rooms can be created.
86
+ *
87
+ * @default 1000000
88
+ */
89
+ subscriptionRooms: number;
90
+ /**
91
+ * Maximum time (in seconds) a document will be kept in cache for
92
+ * real-time subscriptions.
93
+ *
94
+ * This cache is used to notify subscriber when a document enters or
95
+ * leaves a scope after an update.
96
+ *
97
+ * By default, subscriptions will be kept 72 hours.
98
+ *
99
+ * Please note that keeping subscriptions over a long period of
100
+ * time may result in memory overuse.
101
+ *
102
+ * If set to 0, the subscription will be kept in cache forever.
103
+ *
104
+ * Setting the property to 0 will lead to a memory leak if
105
+ * documents enter a real-time subscription scope and never exit
106
+ * that scope.
107
+ *
108
+ * @default 259200000 (72 * 60 * 60)
109
+ */
110
+ subscriptionDocumentTTL: number;
111
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=LimitsConfiguration.js.map
@@ -0,0 +1,177 @@
1
+ import { JSONObject } from '../../../index';
2
+ import { PasswordPolicy } from '../index';
3
+ export declare type PluginsConfiguration = {
4
+ /**
5
+ * Common configuration for all plugins.
6
+ */
7
+ common: {
8
+ /**
9
+ * If true, Kuzzle will not load custom plugin and features (including
10
+ * the ones defined in the application).
11
+ * The API will only be available to administrators ("admin" profile)
12
+ * during failsafe mode.
13
+ *
14
+ * @default false
15
+ */
16
+ failsafeMode: boolean;
17
+ /**
18
+ * Maximum amount of time (in milliseconds) to wait
19
+ * for a concurrent plugin bootstrap.
20
+ *
21
+ * @default 30000
22
+ */
23
+ bootstrapLockTimeout: number;
24
+ /**
25
+ * List of Kuzzle's embedded plugins to be activated.
26
+ *
27
+ * Edit this list to deactivate one or more of those plugins.
28
+ * NOTE: this list does not control plugins installed manually.
29
+ *
30
+ * @default ["kuzzle-plugin-logger","kuzzle-plugin-auth-passport-local"]
31
+ */
32
+ include: string[];
33
+ /**
34
+ * Warning time threshold on a pipe plugin action (in milliseconds).
35
+ *
36
+ * @default 500
37
+ */
38
+ pipeWarnTime: number;
39
+ /**
40
+ * Maximum execution time of a plugin init method (in milliseconds).
41
+ *
42
+ * @default 10000
43
+ */
44
+ initTimeout: number;
45
+ /**
46
+ * Maximum number of pipes that can be executed in parallel.
47
+ *
48
+ * New pipes submitted while the maximum number of pipes is met are
49
+ * delayed for later execution.
50
+ *
51
+ * This parameter controls is used to limit the stress put on the
52
+ * event loop, allowing for Kuzzle to process pipes faster, and to
53
+ * protect it from performances degradation if an abnormal number of
54
+ * pipes are submitted.
55
+ *
56
+ * (timers do not start while a pipe is hold back)
57
+ *
58
+ * @default 50
59
+ */
60
+ maxConcurrentPipes: number;
61
+ /**
62
+ * Maximum number of pipes that can be delayed. If full, new pipes
63
+ * are rejected.
64
+ *
65
+ * @default 50000
66
+ */
67
+ pipesBufferSize: number;
68
+ };
69
+ /**
70
+ * Default logger plugin configuration.
71
+ *
72
+ * This plugin use Winston to transport the logs.
73
+ *
74
+ * @see https://github.com/kuzzleio/kuzzle-plugin-logger
75
+ */
76
+ 'kuzzle-plugin-logger': {
77
+ /**
78
+ * Winston transport services declaration
79
+ */
80
+ services: {
81
+ /**
82
+ * Print logs to STDOUT
83
+ *
84
+ * @default
85
+ *
86
+ * @see https://github.com/winstonjs/winston/blob/master/docs/transports.md#console-transport
87
+ */
88
+ stdout: {
89
+ /**
90
+ * Level of messages that transport should log
91
+ *
92
+ * @default "info"
93
+ */
94
+ level: string;
95
+ /**
96
+ * Add the date to log lines
97
+ *
98
+ * @default true
99
+ */
100
+ addDate: boolean;
101
+ /**
102
+ * Date format
103
+ *
104
+ * @default "YYYY-MM-DD HH-mm-ss"
105
+ */
106
+ dateFormat: string;
107
+ };
108
+ [transport: string]: JSONObject;
109
+ };
110
+ };
111
+ /**
112
+ * Default local auth strategy plugin.
113
+ *
114
+ * @see https://github.com/kuzzleio/kuzzle-plugin-auth-passport-local/
115
+ */
116
+ 'kuzzle-plugin-auth-passport-local': {
117
+ /**
118
+ * One of the supported encryption algorithms
119
+ * (run crypto.getHashes() to get the complete list).
120
+ *
121
+ * Examples: sha256, sha512, blake2b512, whirlpool, ...
122
+ *
123
+ * @default "sha512"
124
+ */
125
+ algorithm: string;
126
+ /**
127
+ * Boolean and controlling if the password is stretched or not.
128
+ *
129
+ * @default true
130
+ */
131
+ stretching: boolean;
132
+ /**
133
+ * Describes how the hashed password is stored in the database
134
+ *
135
+ * @see https://nodejs.org/api/buffer.html#buffer_buf_tostring_encoding_start_end
136
+ *
137
+ * @default "hex"
138
+ */
139
+ digest: string;
140
+ /**
141
+ * Determines whether the hashing algorithm uses crypto.createHash (hash)
142
+ * or crypto.createHmac (hmac).
143
+ *
144
+ * @see https://nodejs.org/api/crypto.html
145
+ *
146
+ * @default "hmac"
147
+ */
148
+ encryption: string;
149
+ /**
150
+ * If true, Kuzzle will refuse any credentials update or deletion,
151
+ * unless the currently valid password is provided
152
+ * or if the change is performed via the security controller.
153
+ *
154
+ * @default false
155
+ */
156
+ requirePassword: boolean;
157
+ /**
158
+ * A positive time representation of the delay after which a
159
+ * reset password token expires.
160
+ *
161
+ * @see https://www.npmjs.com/package/ms
162
+ *
163
+ * Users with expired passwords are given a resetPasswordToken when
164
+ * logging in and must change their password to be allowed to log in again.
165
+ *
166
+ * @default -1
167
+ */
168
+ resetPasswordExpiresIn: number;
169
+ /**
170
+ * Set of additional rules to apply to users, or to groups of users.
171
+ *
172
+ * @see https://docs.kuzzle.io/core/2/guides/main-concepts/authentication#password-policies
173
+ */
174
+ passwordPolicies: PasswordPolicy[];
175
+ };
176
+ [pluginName: string]: JSONObject;
177
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=PluginsConfiguration.js.map
@@ -0,0 +1,182 @@
1
+ /// <reference types="node" />
2
+ import { JSONObject } from '../../../index';
3
+ import { RoleDefinition, ProfileDefinition } from '../index';
4
+ export declare type SecurityConfiguration = {
5
+ /**
6
+ * The profileIds applied to a user created with the API action
7
+ * `security:createRestrictedUser`.
8
+ *
9
+ * @default ["default"]
10
+ */
11
+ restrictedProfileIds: string[];
12
+ /**
13
+ * @deprecated Use `security.authToken` instead.
14
+ */
15
+ jwt?: JSONObject;
16
+ /**
17
+ * Configuration for the npm package jsonwebtoken
18
+ * who handle Kuzzle Authentication Token.
19
+ *
20
+ * @see https://github.com/auth0/node-jsonwebtoken
21
+ */
22
+ authToken: {
23
+ /**
24
+ * Hash/encryption method used to sign the token.
25
+ *
26
+ * @default "HS256"
27
+ */
28
+ algorithm: string;
29
+ /**
30
+ * Token default expiration time.
31
+ *
32
+ * @see https://www.npmjs.com/package/ms
33
+ *
34
+ * @default "1h"
35
+ */
36
+ expiresIn: string;
37
+ /**
38
+ * Duration in ms during which a renewed token is still considered valid.
39
+ *
40
+ * @default 1000
41
+ */
42
+ gracePeriod: number;
43
+ /**
44
+ * Maximum duration in milliseconds a token can be requested to be valid.
45
+ *
46
+ * If set to -1, no maximum duration is set.
47
+ *
48
+ * @default -1
49
+ */
50
+ maxTTL: number;
51
+ /**
52
+ * String or buffer data containing either the secret for HMAC
53
+ * algorithms, or the PEM encoded private key for RSA and ECDSA.
54
+ *
55
+ * If left to null, Kuzzle will autogenerate a random
56
+ * seed (can only be used with HMAC algorithms).
57
+ *
58
+ * @default null
59
+ */
60
+ secret: string | Buffer;
61
+ };
62
+ apiKey: {
63
+ /**
64
+ * Maximum duration in milliseconds a token can be requested to be valid.
65
+ *
66
+ * If set to -1, no maximum duration is set.
67
+ *
68
+ * @default -1
69
+ */
70
+ maxTTL: number;
71
+ };
72
+ /**
73
+ * The default role defines permissions for all users,
74
+ * until an administrator configures the backend rights.
75
+ *
76
+ * By default, all users are granted all permissions.
77
+ *
78
+ * @default
79
+ *
80
+ * {
81
+ * "role": {
82
+ * "controllers": {
83
+ * "*": {
84
+ * "actions": {
85
+ * "*": true
86
+ * }
87
+ * }
88
+ * }
89
+ * }
90
+ * }
91
+ */
92
+ default: {
93
+ role: RoleDefinition;
94
+ };
95
+ /**
96
+ * Permissions used when creating an administrator user.
97
+ *
98
+ * By default, the admin user is granted all permissions.
99
+ *
100
+ * Anonymous and non-administrator users have their rights restricted.
101
+ *
102
+ * @default
103
+ *
104
+ * {
105
+ "roles": {
106
+ "admin": {
107
+ "controllers": {
108
+ "*": {
109
+ "actions": {
110
+ "*": true
111
+ }
112
+ }
113
+ }
114
+ },
115
+ "default": {
116
+ "controllers": {
117
+ "auth": {
118
+ "actions": {
119
+ "checkToken": true,
120
+ "getCurrentUser": true,
121
+ "getMyRights": true,
122
+ "logout": true,
123
+ "updateSelf": true
124
+ }
125
+ },
126
+ "server": {
127
+ "actions": {
128
+ "publicApi": true
129
+ }
130
+ }
131
+ }
132
+ },
133
+ "anonymous": {
134
+ "controllers": {
135
+ "auth": {
136
+ "actions": {
137
+ "checkToken": true,
138
+ "getCurrentUser": true,
139
+ "getMyRights": true,
140
+ "login": true
141
+ }
142
+ },
143
+ "server": {
144
+ "actions": {
145
+ "publicApi": true,
146
+ "openapi": true
147
+ }
148
+ }
149
+ }
150
+ }
151
+ },
152
+ "profiles": {
153
+ "admin": {
154
+ "rateLimit": 0,
155
+ "policies": [ {"roleId": "admin"} ]
156
+ },
157
+ "default": {
158
+ "rateLimit": 10,
159
+ "policies": [ {"roleId": "default"} ]
160
+ },
161
+ "anonymous": {
162
+ "rateLimit": 200,
163
+ "policies": [ {"roleId": "anonymous"} ]
164
+ }
165
+ }
166
+ }
167
+ */
168
+ standard: {
169
+ roles: {
170
+ admin: RoleDefinition;
171
+ default: RoleDefinition;
172
+ anonymous: RoleDefinition;
173
+ [roleName: string]: RoleDefinition;
174
+ };
175
+ profiles: {
176
+ admin: ProfileDefinition;
177
+ default: ProfileDefinition;
178
+ anonymous: ProfileDefinition;
179
+ [profileName: string]: ProfileDefinition;
180
+ };
181
+ };
182
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=SecurityConfiguration.js.map
@@ -0,0 +1,195 @@
1
+ import { JSONObject } from '../../../index';
2
+ export declare type ServerConfiguration = {
3
+ /**
4
+ * The maximum size of an incoming request.
5
+ *
6
+ * Units can be expressed in bytes ("b" or none), kilobytes ("kb"),
7
+ * megabytes ("mb"), gigabytes ("gb") or terabytes ("tb").
8
+ *
9
+ * @default "1mb"
10
+ */
11
+ maxRequestSize: string;
12
+ /**
13
+ * The listening port for HTTP and WebSocket protocols.
14
+ *
15
+ * @default 7512
16
+ */
17
+ port: number;
18
+ /**
19
+ * Configuration section for Kuzzle access logs.
20
+ */
21
+ logs: {
22
+ /**
23
+ * An array of Winston transports configurations to output access
24
+ * logs.
25
+ *
26
+ * Possible transport types are: console, file, elasticsearch and syslog.
27
+ *
28
+ * Please refer to https://github.com/winstonjs/winston/blob/master/docs/transports.md
29
+ * for more information on transports configuration.
30
+ *
31
+ * @default
32
+ *
33
+ * [
34
+ {
35
+ transport: 'console',
36
+ level: 'info',
37
+ stderrLevels: [],
38
+ silent: true
39
+ }
40
+ ]
41
+ *
42
+ */
43
+ transports: JSONObject[];
44
+ /**
45
+ * Access log format.
46
+ *
47
+ * Currently supported are "combined" (=Apache combined logs format)
48
+ * and "logstash".
49
+ *
50
+ * "logstash" will output the whole request input to JSON, ready to
51
+ * be consumed by logstash agent.
52
+ *
53
+ * @default "combined"
54
+ */
55
+ accessLogFormat: 'combined' | 'logstash';
56
+ /**
57
+ * The offset to use as the client ip, from the FORWARDED-FOR chain,
58
+ * beginning from the right (0 = the ip address of the last
59
+ * client|proxy which connected to Kuzzle.
60
+ *
61
+ * @default 0
62
+ */
63
+ accessLogIpOffset: number;
64
+ };
65
+ /**
66
+ * protocols accepted by Kuzzle.
67
+ * protocols can be extended and configured in this section.
68
+ */
69
+ protocols: {
70
+ http: {
71
+ /**
72
+ * Enable support for compressed requests, using the Content-Encoding header
73
+ * Currently supported compression algorithms: gzip, deflate, identity
74
+ * Note: "identity" is always an accepted value, even if compression support is disabled
75
+ *
76
+ * @default true
77
+ */
78
+ allowCompression: boolean;
79
+ /**
80
+ * Set to "false" to disable HTTP support
81
+ *
82
+ * @default true
83
+ */
84
+ enabled: boolean;
85
+ /**
86
+ * Maximum number of encoding layers that can be applied to an http message, using the Content-Encoding header.
87
+ * This parameter is meant to prevent abuses by setting an abnormally large number
88
+ * of encodings, forcing Kuzzle to allocate as many decoders to handle the incoming request.
89
+ *
90
+ * @default 3
91
+ */
92
+ maxEncodingLayers: number;
93
+ /**
94
+ * Maximum size of requests sent via http forms
95
+ *
96
+ * @default "1MB"
97
+ */
98
+ maxFormFileSize: string;
99
+ };
100
+ mqtt: {
101
+ /**
102
+ * Set to true to enable MQTT support
103
+ *
104
+ * @default false
105
+ */
106
+ enabled: boolean;
107
+ /**
108
+ * Allow MQTT pub/sub capabilities or restrict to Kuzzle requests only
109
+ *
110
+ * @default false
111
+ */
112
+ allowPubSub: boolean;
113
+ /**
114
+ * Switches responseTopic back to a regular public topic
115
+ *
116
+ * @default false
117
+ */
118
+ developmentMode: boolean;
119
+ /**
120
+ * Delay in ms to apply between a disconnection notification is
121
+ * received and the connection is actually removed
122
+ *
123
+ * @default 250
124
+ */
125
+ disconnectDelay: number;
126
+ /**
127
+ * Name of the topic listened by the plugin for requests
128
+ *
129
+ * @default 'Kuzzle/request'
130
+ */
131
+ requestTopic: string;
132
+ /**
133
+ * Name of the topic clients should listen to get requests result
134
+ *
135
+ * @default 'Kuzzle/response'
136
+ */
137
+ responseTopic: string;
138
+ /**
139
+ * Constructor options passed to underlying MQTT server.
140
+ * See aedes documentation for further reference: https://github.com/moscajs/aedes
141
+ */
142
+ server: {
143
+ /**
144
+ * @default 1883
145
+ */
146
+ port: number;
147
+ };
148
+ /**
149
+ * Set to "true" to enable realtime notifications like "TokenExpired" notifications
150
+ *
151
+ * @default true
152
+ */
153
+ realtimeNotifications: boolean;
154
+ };
155
+ websocket: {
156
+ /**
157
+ * Set to true to enable WebSocket support
158
+ *
159
+ * @default true
160
+ */
161
+ enabled: boolean;
162
+ /**
163
+ * The maximum time (in milliseconds) without sending or receiving a message from a client.
164
+ * Once reached, the client's socket is forcibly closed.
165
+ * If a client socket is inactive for too long, the server will send a PING request before closing the socket.
166
+ * Minimum value: 1000 (but it's strongly advised to not set a value this low to forcibly close idle client sockets)
167
+ *
168
+ * @default 60000
169
+ */
170
+ idleTimeout: number;
171
+ /**
172
+ * Enable/Disable per message compression
173
+ *
174
+ * @default false
175
+ */
176
+ compression: boolean;
177
+ /**
178
+ * The maximum number of messages per second a single socket can
179
+ * submit to the server.
180
+ * @default 0
181
+ */
182
+ rateLimit: number;
183
+ /**
184
+ * Set to "true" to enable realtime notifications like "TokenExpired" notifications
185
+ *
186
+ * @default true
187
+ */
188
+ realtimeNotifications: boolean;
189
+ };
190
+ };
191
+ /**
192
+ * @default true
193
+ */
194
+ strictSdkVersion: boolean;
195
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ServerConfiguration.js.map