@lucaapp/service-utils 1.45.0 → 1.46.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.
- package/dist/lib/api/endpoint.js +1 -3
- package/dist/lib/wsEvent/index.d.ts +3 -1
- package/dist/lib/wsEvent/index.js +13 -1
- package/package.json +33 -26
package/dist/lib/api/endpoint.js
CHANGED
|
@@ -115,9 +115,7 @@ const validateAndSendResponse = async (expressResponse, response, validResponses
|
|
|
115
115
|
// get schema respective to status code
|
|
116
116
|
const responseSchema = validResponses.find(responseSchema => responseSchema.status === response.status);
|
|
117
117
|
const schema = responseSchema?.schema;
|
|
118
|
-
|
|
119
|
-
const isZodVoid = schema instanceof zod_1.z.ZodVoid;
|
|
120
|
-
(0, assert_1.default)(isZodSchema || isZodVoid);
|
|
118
|
+
(0, assert_1.default)(schema);
|
|
121
119
|
// validate response schema
|
|
122
120
|
const validatedResponseBody = await schema.parseAsync(response.body);
|
|
123
121
|
if (validatedResponseBody === undefined) {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { KafkaClient } from '../kafka';
|
|
2
2
|
declare const generateSubscriptionId: () => string;
|
|
3
3
|
declare const emitWebsocketEvent: (kafkaClient: KafkaClient, subId: string, type: string, data: any) => Promise<void>;
|
|
4
|
-
|
|
4
|
+
declare const derivePublicSubId: (method: string, path: string) => string;
|
|
5
|
+
declare const deriveSubId: (method: string, path: string, secret: string) => string;
|
|
6
|
+
export { generateSubscriptionId, emitWebsocketEvent, deriveSubId, derivePublicSubId, };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.emitWebsocketEvent = exports.generateSubscriptionId = void 0;
|
|
3
|
+
exports.derivePublicSubId = exports.deriveSubId = exports.emitWebsocketEvent = exports.generateSubscriptionId = void 0;
|
|
4
4
|
const uuid_1 = require("uuid");
|
|
5
5
|
const crypto_1 = require("crypto");
|
|
6
6
|
const generateSubscriptionId = () => {
|
|
@@ -25,3 +25,15 @@ data) => {
|
|
|
25
25
|
await kafkaClient.produce(topic, subId, message);
|
|
26
26
|
};
|
|
27
27
|
exports.emitWebsocketEvent = emitWebsocketEvent;
|
|
28
|
+
const derivePublicSubId = (method, path) => {
|
|
29
|
+
return deriveSubId(method, path, 'public');
|
|
30
|
+
};
|
|
31
|
+
exports.derivePublicSubId = derivePublicSubId;
|
|
32
|
+
const deriveSubId = (method, path, secret) => {
|
|
33
|
+
const data = `${method.toLowerCase()}:${path.toLowerCase()}`;
|
|
34
|
+
const hmac = (0, crypto_1.createHmac)('sha256', secret);
|
|
35
|
+
hmac.update(data);
|
|
36
|
+
const subscriptionId = hmac.digest('base64');
|
|
37
|
+
return subscriptionId;
|
|
38
|
+
};
|
|
39
|
+
exports.deriveSubId = deriveSubId;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lucaapp/service-utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.46.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -12,39 +12,19 @@
|
|
|
12
12
|
"build": "tsc -p tsconfig.build.json",
|
|
13
13
|
"ts:check": "tsc -p . --noEmit",
|
|
14
14
|
"lint": "eslint .",
|
|
15
|
-
"test": "
|
|
16
|
-
"test:coverage": "
|
|
17
|
-
"test:ci": "
|
|
15
|
+
"test": "vitest run",
|
|
16
|
+
"test:coverage": "vitest run --coverage",
|
|
17
|
+
"test:ci": "VITEST_JUNIT_SUITE_NAME=service-utils CI=true vitest run --coverage",
|
|
18
18
|
"audit": "improved-yarn-audit --ignore-dev-deps"
|
|
19
19
|
},
|
|
20
|
-
"devDependencies": {
|
|
21
|
-
"@types/express": "4.17.13",
|
|
22
|
-
"@types/jest": "^28.1.5",
|
|
23
|
-
"@types/lodash": "^4.14.187",
|
|
24
|
-
"@types/negotiator": "^0.6.1",
|
|
25
|
-
"@types/uuid": "^8.3.4",
|
|
26
|
-
"@typescript-eslint/eslint-plugin": "^5.30.6",
|
|
27
|
-
"@typescript-eslint/parser": "^5.30.6",
|
|
28
|
-
"conventional-changelog-conventionalcommits": "^5.0.0",
|
|
29
|
-
"eslint": "^8.19.0",
|
|
30
|
-
"eslint-plugin-prettier": "4.2.1",
|
|
31
|
-
"improved-yarn-audit": "^3.0.0",
|
|
32
|
-
"jest": "^28.1.2",
|
|
33
|
-
"jest-junit": "^14.0.0",
|
|
34
|
-
"prettier": "2.7.1",
|
|
35
|
-
"semantic-release": "^19.0.3",
|
|
36
|
-
"semantic-release-monorepo": "^7.0.5",
|
|
37
|
-
"supertest": "^6.3.3",
|
|
38
|
-
"ts-jest": "^28.0.5",
|
|
39
|
-
"typescript": "^4.7.4"
|
|
40
|
-
},
|
|
41
20
|
"dependencies": {
|
|
42
|
-
"@asteasolutions/zod-to-openapi": "4.
|
|
21
|
+
"@asteasolutions/zod-to-openapi": "4.6.0",
|
|
43
22
|
"@hapi/boom": "^10.0.0",
|
|
44
23
|
"@types/express": "4.17.13",
|
|
45
24
|
"@types/response-time": "^2.3.5",
|
|
46
25
|
"@types/supertest": "^2.0.12",
|
|
47
26
|
"@types/swagger-ui-express": "4.1.3",
|
|
27
|
+
"@types/node": "18.11.9",
|
|
48
28
|
"axios": "^0.27.2",
|
|
49
29
|
"cls-rtracer": "^2.6.2",
|
|
50
30
|
"express": "4.18.1",
|
|
@@ -52,6 +32,7 @@
|
|
|
52
32
|
"jose": "4.9.2",
|
|
53
33
|
"kafkajs": "2.1.0",
|
|
54
34
|
"lodash": "^4.17.21",
|
|
35
|
+
"@tsconfig/node18": "1.0.1",
|
|
55
36
|
"moment": "^2.29.4",
|
|
56
37
|
"negotiator": "^0.6.3",
|
|
57
38
|
"pino-http": "8.2.1",
|
|
@@ -61,6 +42,32 @@
|
|
|
61
42
|
"swagger-ui-express": "4.5.0",
|
|
62
43
|
"url-value-parser": "^2.2.0",
|
|
63
44
|
"uuid": "^9.0.0",
|
|
45
|
+
"vitest": "0.30.1",
|
|
64
46
|
"zod": "^3.21.4"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@types/express": "4.17.13",
|
|
50
|
+
"@types/lodash": "^4.14.187",
|
|
51
|
+
"@types/negotiator": "^0.6.1",
|
|
52
|
+
"@types/uuid": "^8.3.4",
|
|
53
|
+
"@types/supertest": "2.0.11",
|
|
54
|
+
"@typescript-eslint/eslint-plugin": "^5.30.6",
|
|
55
|
+
"@typescript-eslint/parser": "^5.30.6",
|
|
56
|
+
"conventional-changelog-conventionalcommits": "^5.0.0",
|
|
57
|
+
"eslint": "^8.19.0",
|
|
58
|
+
"eslint-plugin-prettier": "4.2.1",
|
|
59
|
+
"improved-yarn-audit": "^3.0.0",
|
|
60
|
+
"@vitest/coverage-c8": "0.29.2",
|
|
61
|
+
"@vitest/ui": "0.29.2",
|
|
62
|
+
"prettier": "2.7.1",
|
|
63
|
+
"semantic-release": "^19.0.3",
|
|
64
|
+
"semantic-release-monorepo": "^7.0.5",
|
|
65
|
+
"supertest": "^6.3.3",
|
|
66
|
+
"vite-tsconfig-paths": "4.0.5",
|
|
67
|
+
"eslint-plugin-vitest": "0.0.54",
|
|
68
|
+
"typescript": "^4.7.4"
|
|
69
|
+
},
|
|
70
|
+
"resolutions": {
|
|
71
|
+
"yaml": "2.2.2"
|
|
65
72
|
}
|
|
66
73
|
}
|