badmfck-api-server 4.0.75 → 4.0.78
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/apiServer/APIService.d.ts +2 -0
- package/dist/apiServer/APIService.js +7 -1
- package/dist/apiServer/DBService.d.ts +1 -1
- package/dist/apiServer/db/MysqlAdapter.js +4 -0
- package/dist/apiServer/external/MicroserviceClient.js +2 -2
- package/dist/apiServer/external/MicroserviceHost.js +2 -2
- package/package.json +1 -1
|
@@ -31,6 +31,8 @@ export interface APIServiceOptions<TInterceptor = unknown> {
|
|
|
31
31
|
corsHostWhiteList: string[];
|
|
32
32
|
projectName: string;
|
|
33
33
|
endpoints: IBaseEndpoint[];
|
|
34
|
+
keepAliveTimeout?: number;
|
|
35
|
+
headersTimeout?: number;
|
|
34
36
|
jsonLimit: string;
|
|
35
37
|
isProductionEnvironment: boolean;
|
|
36
38
|
interceptor?: IInterceptor<TInterceptor>;
|
|
@@ -66,6 +66,8 @@ function defaultOptions() {
|
|
|
66
66
|
appVersion: undefined,
|
|
67
67
|
fileTempDir: "/tmp",
|
|
68
68
|
fileLimit: 10_000_000,
|
|
69
|
+
keepAliveTimeout: 25 * 1000,
|
|
70
|
+
headersTimeout: 26 * 1000,
|
|
69
71
|
};
|
|
70
72
|
}
|
|
71
73
|
const getDefaultOptions = (overrides) => {
|
|
@@ -95,7 +97,7 @@ async function Initializer(services) {
|
|
|
95
97
|
}
|
|
96
98
|
exports.Initializer = Initializer;
|
|
97
99
|
class APIService extends BaseService_1.BaseService {
|
|
98
|
-
version = "4.0.
|
|
100
|
+
version = "4.0.78";
|
|
99
101
|
options;
|
|
100
102
|
monitor = null;
|
|
101
103
|
started = new Date();
|
|
@@ -159,6 +161,10 @@ class APIService extends BaseService_1.BaseService {
|
|
|
159
161
|
};
|
|
160
162
|
const app = (0, express_1.default)();
|
|
161
163
|
const server = http_1.default.createServer(app);
|
|
164
|
+
if (this.options.keepAliveTimeout !== undefined)
|
|
165
|
+
server.keepAliveTimeout = this.options.keepAliveTimeout;
|
|
166
|
+
if (this.options.headersTimeout !== undefined)
|
|
167
|
+
server.headersTimeout = this.options.headersTimeout;
|
|
162
168
|
exports.REQ_HTTP_SERVER.listener = async (_) => { return { express: app, http: server }; };
|
|
163
169
|
if (this.options.isProductionEnvironment)
|
|
164
170
|
app.set("env", 'production');
|
|
@@ -12,7 +12,7 @@ export interface IDBQueryField {
|
|
|
12
12
|
fields?: Record<string, number | boolean | string | null>;
|
|
13
13
|
}
|
|
14
14
|
export interface IDBQueryFields {
|
|
15
|
-
[key: string]: string | number | boolean | IDBQueryField | null | undefined;
|
|
15
|
+
[key: string]: string | number | boolean | Date | IDBQueryField | null | undefined;
|
|
16
16
|
}
|
|
17
17
|
export interface IDBQuery {
|
|
18
18
|
dbid?: string;
|
|
@@ -628,6 +628,10 @@ class MysqlAdapter {
|
|
|
628
628
|
}
|
|
629
629
|
if (typeof value === "boolean")
|
|
630
630
|
value = value ? 1 : 0;
|
|
631
|
+
if (typeof value === "object" && value instanceof Date) {
|
|
632
|
+
const utcString = value.toISOString().slice(0, 19).replace('T', ' ');
|
|
633
|
+
value = promise_1.default.escape(utcString);
|
|
634
|
+
}
|
|
631
635
|
if (field.fields && typeof field.fields === "object" && value && typeof value === "string" && value.indexOf("@") !== -1) {
|
|
632
636
|
for (let key in field.fields) {
|
|
633
637
|
if (!field.fields[key])
|
|
@@ -43,9 +43,9 @@ class MicroserviceClient extends BaseService_1.BaseService {
|
|
|
43
43
|
"x-microservice-ts": ts,
|
|
44
44
|
"x-microservice-nonce": nonce
|
|
45
45
|
};
|
|
46
|
-
const
|
|
46
|
+
const rawSecret = Buffer.from(this.options.securityKey, "base64");
|
|
47
|
+
const key = crypto_1.default.createHash("sha256").update(rawSecret).digest();
|
|
47
48
|
const hash = crypto_1.default.createHash("sha256").update(nonce + ts + this.options.securityKey).digest();
|
|
48
|
-
const key = secret;
|
|
49
49
|
const iv = hash.subarray(0, 12);
|
|
50
50
|
const aad = Buffer.from(`${ts}.${nonce}.${this.options.id}`, "utf8");
|
|
51
51
|
const data = Buffer.from(JSON.stringify(req), "utf8");
|
|
@@ -46,9 +46,9 @@ class MicroserviceHost extends BaseService_1.BaseService {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
try {
|
|
49
|
-
const
|
|
49
|
+
const rawSecret = Buffer.from(this.options.securityKey, "base64");
|
|
50
|
+
const key = crypto_1.default.createHash("sha256").update(rawSecret).digest();
|
|
50
51
|
const hash = crypto_1.default.createHash("sha256").update(nonce + ts + this.options.securityKey).digest();
|
|
51
|
-
const key = secret;
|
|
52
52
|
const iv = hash.subarray(0, 12);
|
|
53
53
|
const aad = Buffer.from(`${ts}.${nonce}.${this.options.id}`, "utf8");
|
|
54
54
|
const tag = Buffer.from(req.data.tag, "base64");
|