kuzzle 2.36.0 → 2.37.0

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.
@@ -21,46 +21,49 @@
21
21
  * limitations under the License.
22
22
  */
23
23
 
24
- 'use strict';
24
+ "use strict";
25
25
 
26
26
  /* eslint-disable no-console */
27
27
 
28
- const fs = require('fs');
28
+ const fs = require("fs");
29
29
 
30
- const yargs = require('yargs');
30
+ const yargs = require("yargs");
31
31
 
32
- const { Backend } = require('../index');
32
+ const { Backend } = require("../index");
33
33
 
34
- function loadJson (path) {
35
- if (! path) {
34
+ function loadJson(path) {
35
+ if (!path) {
36
36
  return {};
37
37
  }
38
38
 
39
- return JSON.parse(fs.readFileSync(path, 'utf8'));
39
+ return JSON.parse(fs.readFileSync(path, "utf8"));
40
40
  }
41
41
 
42
- async function startKuzzle (options = {}) {
43
- const app = new Backend('kuzzle');
42
+ async function startKuzzle(options = {}) {
43
+ const app = new Backend("kuzzle");
44
44
 
45
45
  if (options.enablePlugins) {
46
46
  const additionalPlugins = options.enablePlugins
47
47
  .trim()
48
- .split(',')
49
- .map(x => x.trim().replace(/(^")|("$)/g, ''));
48
+ .split(",")
49
+ .map((x) => x.trim().replace(/(^")|("$)/g, ""));
50
50
 
51
51
  for (const additionalPlugin of additionalPlugins) {
52
52
  const PluginClass = require(`../plugins/available/${additionalPlugin}`);
53
- const manifest = require(`../plugins/available/${additionalPlugin}/manifest.json`);
53
+ const manifest = require(
54
+ `../plugins/available/${additionalPlugin}/manifest.json`,
55
+ );
54
56
  const plugin = new PluginClass();
55
57
 
56
58
  try {
57
- plugin.version = require(`../plugins/available/${additionalPlugin}/package.json`).version;
58
- }
59
- catch (e) {
59
+ plugin.version = require(
60
+ `../plugins/available/${additionalPlugin}/package.json`,
61
+ ).version;
62
+ } catch (e) {
60
63
  // ignore
61
64
  }
62
65
 
63
- app.plugin.use(plugin, { name: manifest.name, manifest });
66
+ app.plugin.use(plugin, { manifest, name: manifest.name });
64
67
  }
65
68
  }
66
69
 
@@ -74,36 +77,43 @@ async function startKuzzle (options = {}) {
74
77
 
75
78
  app.vault.file = options.secretsFile;
76
79
 
77
- app.version = '1.0.0';
80
+ app.version = "1.0.0";
78
81
 
79
82
  await app.start();
80
83
 
81
84
  const { total: admins } = await app.sdk.security.searchUsers({
82
- query: { term: { profileIds: 'admin' } }
85
+ query: { term: { profileIds: "admin" } },
83
86
  });
84
87
 
85
88
  if (admins.length === 0) {
86
- console.log('[!] [WARNING] There is no administrator user yet: everyone has administrator rights.');
87
- console.log('[] You can use the CLI or the admin console to create the first administrator user.');
88
- console.log(' For more information: https://docs.kuzzle.io/core/2/guides/essentials/security/');
89
+ console.log(
90
+ "[!] [WARNING] There is no administrator user yet: everyone has administrator rights.",
91
+ );
92
+ console.log(
93
+ "[ℹ] You can use the CLI or the admin console to create the first administrator user.",
94
+ );
95
+ console.log(
96
+ " For more information: https://docs.kuzzle.io/core/2/guides/essentials/security/",
97
+ );
89
98
  }
90
99
  }
91
100
 
92
101
  const options = yargs
93
- .usage('start-kuzzle-server [options]')
94
- .describe('fixtures', 'Import data from file')
95
- .describe('mappings', 'Apply mappings from file')
96
- .describe('securities', 'Import roles, profiles and users from file')
97
- .describe('vault-key', 'Vault key used to decrypt secrets')
98
- .describe('secrets-file', 'Output file to write decrypted secrets')
99
- .describe('enable-plugins', 'Enable plugins from "plugins/available" directory')
100
- .argv;
102
+ .usage("start-kuzzle-server [options]")
103
+ .describe("fixtures", "Import data from file")
104
+ .describe("mappings", "Apply mappings from file")
105
+ .describe("securities", "Import roles, profiles and users from file")
106
+ .describe("vault-key", "Vault key used to decrypt secrets")
107
+ .describe("secrets-file", "Output file to write decrypted secrets")
108
+ .describe(
109
+ "enable-plugins",
110
+ 'Enable plugins from "plugins/available" directory',
111
+ ).argv;
101
112
 
102
113
  const run = async () => {
103
114
  try {
104
115
  await startKuzzle(options);
105
- }
106
- catch (error) {
116
+ } catch (error) {
107
117
  console.error(`[x] [ERROR] ${error.stack}`);
108
118
  process.exit(1);
109
119
  }
@@ -0,0 +1,17 @@
1
+ /* eslint-disable no-console */
2
+
3
+ "use strict";
4
+
5
+ const semver = require("semver");
6
+ const { engines } = require("./package.json");
7
+
8
+ const version = engines.node;
9
+ const nodeVersion = process.version;
10
+
11
+ if (!semver.satisfies(nodeVersion, version)) {
12
+ console.error(
13
+ "\x1b[31m%s\x1b[0m",
14
+ `Required node version ${version} not satisfied with current version ${nodeVersion}`,
15
+ );
16
+ process.exit(1);
17
+ }
@@ -48,7 +48,7 @@ exports.AuthController = void 0;
48
48
  * limitations under the License.
49
49
  */
50
50
  const http_1 = require("http");
51
- const cookie_1 = __importDefault(require("cookie"));
51
+ const Cookie = __importStar(require("cookie"));
52
52
  const bluebird_1 = __importDefault(require("bluebird"));
53
53
  const lodash_1 = require("lodash");
54
54
  const errors_1 = require("../../kerror/errors");
@@ -212,7 +212,7 @@ class AuthController extends baseController_1.NativeController {
212
212
  request.getBoolean("cookieAuth")) {
213
213
  request.response.configure({
214
214
  headers: {
215
- "Set-Cookie": cookie_1.default.serialize("authToken", null, {
215
+ "Set-Cookie": Cookie.serialize("authToken", null, {
216
216
  httpOnly: true,
217
217
  path: "/",
218
218
  sameSite: "strict",
@@ -235,7 +235,7 @@ class AuthController extends baseController_1.NativeController {
235
235
  // or that the version of kuzzle doesn't support the feature Browser Cookie as Authentication Token
236
236
  request.response.configure({
237
237
  headers: {
238
- "Set-Cookie": cookie_1.default.serialize("authToken", token.jwt, {
238
+ "Set-Cookie": Cookie.serialize("authToken", token.jwt, {
239
239
  expires: new Date(token.expiresAt),
240
240
  httpOnly: true,
241
241
  path: "/",
@@ -40,7 +40,7 @@ class MqttProtocol extends Protocol {
40
40
  super("mqtt");
41
41
 
42
42
  // eslint-disable-next-line new-cap
43
- this.aedes = new Aedes.Server();
43
+ this.aedes = new Aedes();
44
44
  this.server = net.createServer(this.aedes.handle);
45
45
 
46
46
  this.connections = new Map();
@@ -1,4 +1,3 @@
1
- /// <reference types="lodash" />
2
1
  import { JSONObject } from "kuzzle-sdk";
3
2
  import { Profile } from "../../model/security/profile";
4
3
  import { ObjectRepository } from "../shared/ObjectRepository";
@@ -54,12 +54,9 @@ const kerror = __importStar(require("../../kerror"));
54
54
  const errors_1 = require("../../kerror/errors");
55
55
  const token_1 = require("../../model/security/token");
56
56
  const apiKey_1 = __importDefault(require("../../model/storage/apiKey"));
57
- const debug_1 = __importDefault(require("../../util/debug"));
58
57
  const ObjectRepository_1 = require("../shared/ObjectRepository");
59
58
  const crypto_1 = require("../../util/crypto");
60
59
  const securityError = kerror.wrap("security", "token");
61
- const debug = (0, debug_1.default)("kuzzle:bootstrap:tokens");
62
- const BOOTSTRAP_DONE_KEY = "token/bootstrap";
63
60
  class TokenRepository extends ObjectRepository_1.ObjectRepository {
64
61
  constructor(opts = {}) {
65
62
  super();
@@ -186,8 +183,8 @@ class TokenRepository extends ObjectRepository_1.ObjectRepository {
186
183
  const parsedExpiresIn = parseTimespan(expiresIn);
187
184
  const maxTTL = type === "apiKey"
188
185
  ? global.kuzzle.config.security.apiKey.maxTTL
189
- : global.kuzzle.config.security.authToken.maxTTL ??
190
- global.kuzzle.config.security.jwt.maxTTL;
186
+ : (global.kuzzle.config.security.authToken.maxTTL ??
187
+ global.kuzzle.config.security.jwt.maxTTL);
191
188
  if (!bypassMaxTTL &&
192
189
  maxTTL > -1 &&
193
190
  (parsedExpiresIn > maxTTL || parsedExpiresIn === -1)) {
@@ -53,7 +53,6 @@ const json_stable_stringify_1 = __importDefault(require("json-stable-stringify")
53
53
  const koncorde_1 = require("koncorde");
54
54
  const lodash_1 = __importDefault(require("lodash"));
55
55
  const murmurhash_1 = __importDefault(require("murmurhash"));
56
- const node_segfault_handler_1 = __importDefault(require("node-segfault-handler"));
57
56
  const package_json_1 = require("../../package.json");
58
57
  const funnel_1 = __importDefault(require("../api/funnel"));
59
58
  const openapi_1 = require("../api/openapi");
@@ -566,7 +565,6 @@ class Kuzzle extends KuzzleEventEmitter_1.default {
566
565
  this.shutdown();
567
566
  });
568
567
  }
569
- node_segfault_handler_1.default.registerHandler();
570
568
  }
571
569
  async dumpAndExit(suffix) {
572
570
  if (this.config.dump.enabled) {
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import { JSONObject } from "../../../index";
3
4
  import { RoleDefinition, ProfileDefinition } from "../index";
4
5
  export type SecurityConfiguration = {
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import { JSONObject, PipeEventHandler } from "../../../";
3
4
  import { ClientConnection } from "../ClientConnection";
4
5
  import { HttpMessage } from "../HttpMessage";
@@ -1,5 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
+ /// <reference types="node" />
3
4
  import stream from "stream";
4
5
  type Encoding = BufferEncoding | "buffer";
5
6
  type ChunkData = Buffer | string;
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "kuzzle",
3
3
  "author": "The Kuzzle Team <support@kuzzle.io>",
4
- "version": "2.36.0",
4
+ "version": "2.37.0",
5
5
  "description": "Kuzzle is an open-source solution that handles all the data management through a secured API, with a large choice of protocols.",
6
6
  "bin": "bin/start-kuzzle-server",
7
7
  "scripts": {
8
+ "preinstall": "node ./check-node-version.js",
8
9
  "build": "tsc",
9
10
  "clean": "touch index.ts && npm run build | grep TSFILE | cut -d' ' -f 2 | xargs rm",
10
11
  "cucumber": "cucumber.js --fail-fast",
@@ -21,113 +22,115 @@
21
22
  "test:functional:websocket": "KUZZLE_PROTOCOL=websocket cucumber-js --profile websocket",
22
23
  "test:functional": "npm run test:functional:http && npm run test:functional:websocket && npm run test:functional:jest",
23
24
  "test:lint": "eslint ./lib ./test ./bin ./features ./plugins/available/functional-test-plugin",
24
- "test:unit": "DEBUG= npx --node-arg=--trace-warnings mocha --exit",
25
+ "test:unit": "npx mocha --exit",
25
26
  "test": "npm run clean && npm run --silent test:lint && npm run build && npm run test:unit:coverage && npm run test:functional"
26
27
  },
27
28
  "directories": {
28
29
  "lib": "lib"
29
30
  },
30
31
  "dependencies": {
31
- "aedes": "0.46.3",
32
+ "aedes": "0.51.3",
32
33
  "bluebird": "3.7.2",
33
- "cli-color": "2.0.3",
34
- "cookie": "0.6.0",
35
- "debug": "4.3.4",
34
+ "cli-color": "2.0.4",
35
+ "cookie": "1.0.2",
36
+ "debug": "4.4.0",
36
37
  "denque": "2.1.0",
37
38
  "didyoumean": "1.2.2",
38
39
  "dumpme": "1.0.3",
39
40
  "eventemitter3": "5.0.1",
40
- "inquirer": "9.2.12",
41
- "ioredis": "5.3.2",
41
+ "inquirer": "12.3.0",
42
+ "ioredis": "5.4.2",
42
43
  "js-yaml": "4.1.0",
43
- "json-stable-stringify": "1.1.0",
44
+ "json-stable-stringify": "1.2.1",
44
45
  "json2yaml": "1.1.0",
45
46
  "jsonwebtoken": "9.0.2",
46
- "koncorde": "4.3.0",
47
+ "koncorde": "4.4.0",
47
48
  "kuzzle-plugin-auth-passport-local": "6.4.1",
48
49
  "kuzzle-plugin-logger": "3.0.3",
49
- "kuzzle-sdk": "^7.13.0",
50
- "kuzzle-vault": "2.0.4",
50
+ "kuzzle-sdk": "^7.14.0",
51
+ "kuzzle-vault": "2.1.0",
51
52
  "lodash": "4.17.21",
52
53
  "long": "5.2.3",
53
- "moment": "2.29.4",
54
+ "moment": "2.30.1",
54
55
  "ms": "2.1.3",
55
- "murmurhash": "^2.0.1",
56
+ "murmurhash": "2.0.1",
56
57
  "ndjson": "2.0.0",
57
- "node-segfault-handler": "1.4.2",
58
58
  "passport": "0.7.0",
59
- "protobufjs": "7.2.5",
59
+ "protobufjs": "7.4.0",
60
60
  "rc": "1.2.8",
61
61
  "sdk-es7": "npm:@elastic/elasticsearch@7.13.0",
62
- "sdk-es8": "npm:@elastic/elasticsearch@8.12.1",
63
- "semver": "7.6.0",
62
+ "sdk-es8": "npm:@elastic/elasticsearch@8.17.0",
63
+ "semver": "7.6.3",
64
64
  "sorted-array": "2.0.4",
65
- "uuid": "9.0.1",
66
- "uWebSockets.js": "https://github.com/uNetworking/uWebSockets.js/archive/refs/tags/v20.34.0.tar.gz",
67
- "validator": "13.11.0",
68
- "winston": "3.11.0",
69
- "winston-elasticsearch": "0.17.4",
70
- "winston-syslog": "2.7.0",
71
- "winston-transport": "4.6.0",
65
+ "uuid": "11.0.4",
66
+ "uWebSockets.js": "https://github.com/uNetworking/uWebSockets.js/archive/refs/tags/v20.51.0.tar.gz",
67
+ "validator": "13.12.0",
68
+ "winston": "3.17.0",
69
+ "winston-elasticsearch": "0.19.0",
70
+ "winston-syslog": "2.7.1",
71
+ "winston-transport": "4.9.0",
72
72
  "yargs": "17.7.2",
73
- "zeromq": "6.0.0-beta.6"
73
+ "zeromq": "6.3.0"
74
74
  },
75
75
  "repository": {
76
76
  "type": "git",
77
77
  "url": "git://github.com/kuzzleio/kuzzle.git"
78
78
  },
79
79
  "devDependencies": {
80
- "@commitlint/cli": "^17.6.7",
81
- "@commitlint/config-conventional": "^17.6.7",
80
+ "@commitlint/cli": "19.6.1",
81
+ "@commitlint/config-conventional": "19.6.0",
82
82
  "@jest/globals": "29.7.0",
83
- "@semantic-release/changelog": "^6.0.3",
84
- "@semantic-release/commit-analyzer": "^10.0.1",
85
- "@semantic-release/git": "^10.0.1",
86
- "@semantic-release/release-notes-generator": "^11.0.4",
87
- "@types/bluebird": "^3.5.42",
88
- "@types/cookie": "^0.6.0",
89
- "@types/jest": "29.5.10",
83
+ "@semantic-release/changelog": "6.0.3",
84
+ "@semantic-release/commit-analyzer": "13.0.1",
85
+ "@semantic-release/git": "10.0.1",
86
+ "@semantic-release/release-notes-generator": "14.0.3",
87
+ "@types/bluebird": "3.5.42",
88
+ "@types/cookie": "1.0.0",
89
+ "@types/jest": "29.5.14",
90
90
  "@types/js-yaml": "4.0.9",
91
- "@types/lodash": "4.14.202",
92
- "async": "3.2.5",
93
- "chokidar": "3.5.3",
94
- "cucumber": "6.0.5",
95
- "cz-conventional-changelog": "^3.3.0",
91
+ "@types/lodash": "4.17.14",
92
+ "@types/mocha": "^10.0.10",
93
+ "async": "3.2.6",
94
+ "chokidar": "4.0.3",
95
+ "cucumber": "6.0.7",
96
+ "cz-conventional-changelog": "3.3.0",
96
97
  "ergol": "1.0.2",
97
- "eslint-plugin-kuzzle": "0.0.12",
98
+ "eslint-plugin-kuzzle": "0.0.13",
98
99
  "jest": "29.7.0",
99
- "mocha": "10.2.0",
100
+ "mocha": "11.0.1",
100
101
  "mock-require": "3.0.3",
101
- "mqtt": "5.3.0",
102
- "nyc": "15.1.0",
102
+ "mqtt": "5.10.3",
103
+ "nyc": "17.1.0",
103
104
  "request": "2.88.2",
104
105
  "request-promise": "4.2.6",
105
106
  "rewire": "5.0.0",
106
- "semantic-release-config-kuzzle": "^1.0.0",
107
- "semantic-release-slack-bot": "^4.0.2",
107
+ "semantic-release-config-kuzzle": "1.0.0",
108
+ "semantic-release-slack-bot": "4.0.2",
108
109
  "should": "13.2.3",
109
110
  "should-sinon": "0.0.6",
110
- "sinon": "14.0.2",
111
+ "sinon": "19.0.2",
111
112
  "strip-json-comments": "https://github.com/sindresorhus/strip-json-comments/archive/refs/tags/v3.1.1.tar.gz",
112
- "ts-jest": "29.1.1",
113
- "ts-node": "10.9.1",
113
+ "ts-jest": "29.2.5",
114
+ "ts-node": "10.9.2",
114
115
  "typescript": "5.3.2",
115
- "yaml": "2.3.4"
116
+ "yaml": "2.7.0"
116
117
  },
117
118
  "engines": {
118
- "node": ">= 12.13.0"
119
+ "node": ">=18.0.0 <23.0.0"
119
120
  },
121
+ "engineStrict": true,
120
122
  "license": "Apache-2.0",
121
123
  "files": [
122
- "lib/**/*.js",
124
+ "check-node-version.js",
125
+ "index.d.ts",
126
+ "index.js",
123
127
  "lib/**/*.d.ts",
128
+ "lib/**/*.js",
124
129
  "lib/**/*.json",
125
130
  "lib/**/*.proto",
126
131
  "lib/**/*.yaml",
127
- "package.json",
128
- "index.js",
129
- "index.d.ts",
130
132
  "LICENSE.md",
133
+ "package.json",
131
134
  "README.md"
132
135
  ]
133
136
  }