kuzzle 2.19.12 → 2.20.1

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 (33) hide show
  1. package/index.d.ts +1 -1
  2. package/index.js +1 -1
  3. package/lib/api/controllers/authController.d.ts +164 -0
  4. package/lib/api/controllers/authController.js +469 -654
  5. package/lib/api/controllers/baseController.d.ts +74 -0
  6. package/lib/api/controllers/baseController.js +169 -221
  7. package/lib/api/controllers/documentController.js +6 -8
  8. package/lib/api/funnel.js +4 -1
  9. package/lib/api/httpRoutes.js +6 -0
  10. package/lib/api/openapi/openApiGenerator.js +2 -2
  11. package/lib/api/request/kuzzleRequest.d.ts +3 -1
  12. package/lib/api/request/kuzzleRequest.js +32 -0
  13. package/lib/core/backend/backendController.js +2 -2
  14. package/lib/core/backend/backendPlugin.js +2 -2
  15. package/lib/core/network/protocols/httpwsProtocol.js +0 -12
  16. package/lib/core/plugin/pluginRepository.js +1 -1
  17. package/lib/core/plugin/pluginsManager.js +1 -1
  18. package/lib/core/security/index.js +1 -1
  19. package/lib/core/security/profileRepository.d.ts +14 -4
  20. package/lib/core/security/profileRepository.js +2 -2
  21. package/lib/core/security/roleRepository.js +1 -1
  22. package/lib/core/security/tokenRepository.d.ts +73 -0
  23. package/lib/core/security/tokenRepository.js +359 -460
  24. package/lib/core/security/userRepository.js +1 -1
  25. package/lib/core/shared/repository.d.ts +178 -0
  26. package/lib/core/shared/repository.js +365 -450
  27. package/lib/kerror/codes/7-security.json +6 -0
  28. package/lib/model/security/token.d.ts +2 -0
  29. package/lib/model/security/token.js +1 -0
  30. package/lib/service/storage/elasticsearch.js +4 -0
  31. package/lib/util/{inflector.d.ts → Inflector.d.ts} +5 -0
  32. package/lib/util/{inflector.js → Inflector.js} +12 -1
  33. package/package.json +11 -4
@@ -51,6 +51,12 @@
51
51
  "code": 8,
52
52
  "message": "%s cannot be refreshed.",
53
53
  "class": "UnauthorizedError"
54
+ },
55
+ "invalid_expiration": {
56
+ "description": "The specified expiration time is invalid",
57
+ "code": 9,
58
+ "message": "Token can not be created with this expiration time: %s",
59
+ "class": "BadRequestError"
54
60
  }
55
61
  }
56
62
  },
@@ -11,6 +11,7 @@ export interface TokenContent {
11
11
  connectionIds?: string[];
12
12
  jwt?: string;
13
13
  refreshed?: boolean;
14
+ singleUse?: boolean;
14
15
  }
15
16
  /**
16
17
  * Represents a token that identify an user.
@@ -22,6 +23,7 @@ export declare class Token implements TokenContent {
22
23
  userId: string;
23
24
  jwt: string;
24
25
  refreshed: boolean;
26
+ singleUse: boolean;
25
27
  constructor(data?: TokenContent);
26
28
  get type(): "apiKey" | "authToken";
27
29
  static get AUTH_PREFIX(): string;
@@ -32,6 +32,7 @@ class Token {
32
32
  this.userId = data.userId || null;
33
33
  this.jwt = data.jwt || null;
34
34
  this.refreshed = Boolean(data.refreshed);
35
+ this.singleUse = Boolean(data.singleUse);
35
36
  }
36
37
  get type() {
37
38
  if (this.jwt && this.jwt.startsWith(Token.APIKEY_PREFIX)) {
@@ -2010,6 +2010,10 @@ class ElasticSearch extends Service {
2010
2010
  { index: [] }
2011
2011
  );
2012
2012
 
2013
+ if (esRequest.index.length === 0) {
2014
+ return [];
2015
+ }
2016
+
2013
2017
  debug("Delete indexes: %o", esRequest);
2014
2018
 
2015
2019
  await this._client.indices.delete(esRequest);
@@ -22,4 +22,9 @@ export declare class Inflector {
22
22
  * Converts a string to camelCase
23
23
  */
24
24
  static camelCase(string: any): string;
25
+ /**
26
+ * Converts a string to snake_case
27
+ * https://stackoverflow.com/a/52964182
28
+ */
29
+ static snakeCase(str: string): string;
25
30
  }
@@ -62,6 +62,17 @@ class Inflector {
62
62
  static camelCase(string) {
63
63
  return lodash_1.default.camelCase(string);
64
64
  }
65
+ /**
66
+ * Converts a string to snake_case
67
+ * https://stackoverflow.com/a/52964182
68
+ */
69
+ static snakeCase(str) {
70
+ return str
71
+ .replace(/\W+/g, " ")
72
+ .split(/ |\B(?=[A-Z])/)
73
+ .map((word) => word.toLowerCase())
74
+ .join("_");
75
+ }
65
76
  }
66
77
  exports.Inflector = Inflector;
67
- //# sourceMappingURL=inflector.js.map
78
+ //# sourceMappingURL=Inflector.js.map
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.19.12",
4
+ "version": "2.20.1",
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
+ "docker": "docker-compose run kuzzle_node_1 ",
8
9
  "file": "npx ergol docker/scripts/start-kuzzle-dev.ts -c ./config/ergol.config.json",
9
10
  "start:dev": "npx ergol docker/scripts/start-kuzzle-dev.ts -c ./config/ergol.config.json --script-args=--enable-plugins functional-test-plugin",
10
11
  "prepublishOnly": "npm run build",
@@ -15,15 +16,17 @@
15
16
  "dev": "npx ergol docker/scripts/start-kuzzle-dev.ts -c ./config/ergol.config.json",
16
17
  "dev:test": "npm run dev -- docker/scripts/start-kuzzle-dev.ts --enable-plugins functional-test-plugin",
17
18
  "test": "npm run clean && npm run --silent test:lint && npm run build && npm run test:unit:coverage && npm run test:functional",
19
+ "test:jest": "jest",
18
20
  "test:unit": "DEBUG= npx --node-arg=--trace-warnings mocha --exit",
19
21
  "test:unit:coverage": "DEBUG= nyc --reporter=text-summary --reporter=lcov mocha --exit",
20
- "test:functional": "npm run test:functional:http && npm run test:functional:websocket",
22
+ "test:functional": "npm run test:functional:http && npm run test:functional:websocket && npm run test:jest",
21
23
  "test:functional:http": "KUZZLE_PROTOCOL=http npx cucumber-js --profile http",
22
24
  "test:functional:websocket": "KUZZLE_PROTOCOL=websocket npx cucumber-js --profile websocket",
23
25
  "test:functional:legacy": "npm run test:functional:legacy:http && npm run test:functional:legacy:websocket && npm run test:functional:legacy:mqtt",
24
26
  "test:functional:legacy:http": "npx cucumber-js --format progress-bar --profile http ./features-legacy",
25
27
  "test:functional:legacy:websocket": "npx cucumber-js --format progress-bar --profile websocket ./features-legacy",
26
28
  "test:functional:legacy:mqtt": "npx cucumber-js --format progress-bar --profile mqtt ./features-legacy",
29
+ "test:functional:jest": "npm run test:jest",
27
30
  "cucumber": "cucumber.js --fail-fast",
28
31
  "codecov": "codecov",
29
32
  "prettier": "npx prettier ./lib ./test ./bin ./features ./plugins/available/functional-test-plugin --write",
@@ -61,7 +64,7 @@
61
64
  "koncorde": "^4.0.3",
62
65
  "kuzzle-plugin-auth-passport-local": "^6.3.6",
63
66
  "kuzzle-plugin-logger": "^3.0.3",
64
- "kuzzle-sdk": "^7.10.3",
67
+ "kuzzle-sdk": "^7.10.5",
65
68
  "kuzzle-vault": "^2.0.4",
66
69
  "lodash": "4.17.21",
67
70
  "long": "^5.2.1",
@@ -69,7 +72,7 @@
69
72
  "ms": "^2.1.3",
70
73
  "murmurhash-native": "^3.5.0",
71
74
  "ndjson": "^2.0.0",
72
- "node-segfault-handler": "^1.1.0",
75
+ "node-segfault-handler": "^1.4.2",
73
76
  "passport": "^0.6.0",
74
77
  "protobufjs": "~7.1.2",
75
78
  "rc": "1.2.8",
@@ -90,6 +93,8 @@
90
93
  "url": "git://github.com/kuzzleio/kuzzle.git"
91
94
  },
92
95
  "devDependencies": {
96
+ "@jest/globals": "^29.3.1",
97
+ "@types/jest": "^29.2.5",
93
98
  "@types/js-yaml": "^4.0.5",
94
99
  "@types/lodash": "^4.14.190",
95
100
  "async": "^3.2.4",
@@ -97,6 +102,7 @@
97
102
  "codecov": "^3.8.3",
98
103
  "cucumber": "^6.0.5",
99
104
  "ergol": "^1.0.2",
105
+ "jest": "^29.3.1",
100
106
  "mocha": "^10.1.0",
101
107
  "mock-require": "^3.0.3",
102
108
  "mqtt": "^4.3.7",
@@ -108,6 +114,7 @@
108
114
  "should-sinon": "0.0.6",
109
115
  "sinon": "^14.0.2",
110
116
  "strip-json-comments": "https://github.com/sindresorhus/strip-json-comments/archive/refs/tags/v3.1.1.tar.gz",
117
+ "ts-jest": "^29.0.5",
111
118
  "ts-node": "^10.9.1",
112
119
  "typescript": "^4.9.3",
113
120
  "yaml": "^2.1.3"