mvc-common-toolkit 1.43.10 → 1.43.11
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/src/constants.d.ts +42 -0
- package/dist/src/constants.js +50 -0
- package/dist/src/constants.js.map +1 -0
- package/dist/src/gateways/alibaba-cloud-gateway.d.ts +30 -0
- package/dist/src/gateways/alibaba-cloud-gateway.js +120 -0
- package/dist/src/gateways/alibaba-cloud-gateway.js.map +1 -0
- package/dist/src/gateways/http-audit-gateway.d.ts +20 -0
- package/dist/src/gateways/http-audit-gateway.js +76 -0
- package/dist/src/gateways/http-audit-gateway.js.map +1 -0
- package/dist/src/gateways/index.d.ts +5 -0
- package/dist/src/gateways/index.js +22 -0
- package/dist/src/gateways/index.js.map +1 -0
- package/dist/src/gateways/internal-auth-gateway.d.ts +8 -0
- package/dist/src/gateways/internal-auth-gateway.js +40 -0
- package/dist/src/gateways/internal-auth-gateway.js.map +1 -0
- package/dist/src/gateways/stdout-audit-gateway.d.ts +7 -0
- package/dist/src/gateways/stdout-audit-gateway.js +25 -0
- package/dist/src/gateways/stdout-audit-gateway.js.map +1 -0
- package/dist/src/gateways/webhook-audit-gateway.d.ts +14 -0
- package/dist/src/gateways/webhook-audit-gateway.js +27 -0
- package/dist/src/gateways/webhook-audit-gateway.js.map +1 -0
- package/dist/src/interfaces.d.ts +218 -0
- package/dist/src/interfaces.js +3 -0
- package/dist/src/interfaces.js.map +1 -0
- package/dist/src/models/audit-log.d.ts +77 -0
- package/dist/src/models/audit-log.js +92 -0
- package/dist/src/models/audit-log.js.map +1 -0
- package/dist/src/models/index.d.ts +1 -0
- package/dist/src/models/index.js +18 -0
- package/dist/src/models/index.js.map +1 -0
- package/dist/src/pkg/array-helper.d.ts +1 -0
- package/dist/src/pkg/array-helper.js +12 -0
- package/dist/src/pkg/array-helper.js.map +1 -0
- package/dist/src/pkg/bcrypt-helper.d.ts +2 -0
- package/dist/src/pkg/bcrypt-helper.js +36 -0
- package/dist/src/pkg/bcrypt-helper.js.map +1 -0
- package/dist/src/pkg/crypto-helper.d.ts +2 -0
- package/dist/src/pkg/crypto-helper.js +16 -0
- package/dist/src/pkg/crypto-helper.js.map +1 -0
- package/dist/src/pkg/encryption-helper.d.ts +18 -0
- package/dist/src/pkg/encryption-helper.js +89 -0
- package/dist/src/pkg/encryption-helper.js.map +1 -0
- package/dist/src/pkg/encryption-helper.spec.d.ts +1 -0
- package/dist/src/pkg/encryption-helper.spec.js +238 -0
- package/dist/src/pkg/encryption-helper.spec.js.map +1 -0
- package/dist/src/pkg/filter-helper.d.ts +2 -0
- package/dist/src/pkg/filter-helper.js +102 -0
- package/dist/src/pkg/filter-helper.js.map +1 -0
- package/dist/src/pkg/filter-helper.spec.d.ts +1 -0
- package/dist/src/pkg/filter-helper.spec.js +94 -0
- package/dist/src/pkg/filter-helper.spec.js.map +1 -0
- package/dist/src/pkg/geoip-helper.d.ts +2 -0
- package/dist/src/pkg/geoip-helper.js +32 -0
- package/dist/src/pkg/geoip-helper.js.map +1 -0
- package/dist/src/pkg/hash-helper.d.ts +1 -0
- package/dist/src/pkg/hash-helper.js +37 -0
- package/dist/src/pkg/hash-helper.js.map +1 -0
- package/dist/src/pkg/http-request-utils.d.ts +4 -0
- package/dist/src/pkg/http-request-utils.js +55 -0
- package/dist/src/pkg/http-request-utils.js.map +1 -0
- package/dist/src/pkg/index.d.ts +18 -0
- package/dist/src/pkg/index.js +45 -0
- package/dist/src/pkg/index.js.map +1 -0
- package/dist/src/pkg/key-helper.d.ts +2 -0
- package/dist/src/pkg/key-helper.js +20 -0
- package/dist/src/pkg/key-helper.js.map +1 -0
- package/dist/src/pkg/logger.d.ts +9 -0
- package/dist/src/pkg/logger.js +23 -0
- package/dist/src/pkg/logger.js.map +1 -0
- package/dist/src/pkg/object-helper.d.ts +2 -0
- package/dist/src/pkg/object-helper.js +37 -0
- package/dist/src/pkg/object-helper.js.map +1 -0
- package/dist/src/pkg/paginated-cache-registry.d.ts +8 -0
- package/dist/src/pkg/paginated-cache-registry.js +23 -0
- package/dist/src/pkg/paginated-cache-registry.js.map +1 -0
- package/dist/src/pkg/query-helper.d.ts +3 -0
- package/dist/src/pkg/query-helper.js +60 -0
- package/dist/src/pkg/query-helper.js.map +1 -0
- package/dist/src/pkg/referral-tree-utils.d.ts +33 -0
- package/dist/src/pkg/referral-tree-utils.js +71 -0
- package/dist/src/pkg/referral-tree-utils.js.map +1 -0
- package/dist/src/pkg/scripts/index.d.ts +1 -0
- package/dist/src/pkg/scripts/index.js +28 -0
- package/dist/src/pkg/scripts/index.js.map +1 -0
- package/dist/src/pkg/scripts/lua.d.ts +10 -0
- package/dist/src/pkg/scripts/lua.js +109 -0
- package/dist/src/pkg/scripts/lua.js.map +1 -0
- package/dist/src/pkg/sort-helper.d.ts +3 -0
- package/dist/src/pkg/sort-helper.js +18 -0
- package/dist/src/pkg/sort-helper.js.map +1 -0
- package/dist/src/pkg/string-utils.d.ts +10 -0
- package/dist/src/pkg/string-utils.js +79 -0
- package/dist/src/pkg/string-utils.js.map +1 -0
- package/dist/src/pkg/task-helper.d.ts +2 -0
- package/dist/src/pkg/task-helper.js +30 -0
- package/dist/src/pkg/task-helper.js.map +1 -0
- package/dist/src/pkg/workflow/delayed-task-registry.d.ts +10 -0
- package/dist/src/pkg/workflow/delayed-task-registry.js +67 -0
- package/dist/src/pkg/workflow/delayed-task-registry.js.map +1 -0
- package/dist/src/pkg/workflow/delayed-task.d.ts +18 -0
- package/dist/src/pkg/workflow/delayed-task.js +95 -0
- package/dist/src/pkg/workflow/delayed-task.js.map +1 -0
- package/dist/src/pkg/workflow/index.d.ts +5 -0
- package/dist/src/pkg/workflow/index.js +22 -0
- package/dist/src/pkg/workflow/index.js.map +1 -0
- package/dist/src/pkg/workflow/processing-milestone.d.ts +18 -0
- package/dist/src/pkg/workflow/processing-milestone.js +39 -0
- package/dist/src/pkg/workflow/processing-milestone.js.map +1 -0
- package/dist/src/pkg/workflow/retry-task.d.ts +24 -0
- package/dist/src/pkg/workflow/retry-task.js +89 -0
- package/dist/src/pkg/workflow/retry-task.js.map +1 -0
- package/dist/src/pkg/workflow/retry-task.spec.d.ts +1 -0
- package/dist/src/pkg/workflow/retry-task.spec.js +145 -0
- package/dist/src/pkg/workflow/retry-task.spec.js.map +1 -0
- package/dist/src/pkg/workflow/sync-taskqueue.d.ts +32 -0
- package/dist/src/pkg/workflow/sync-taskqueue.js +108 -0
- package/dist/src/pkg/workflow/sync-taskqueue.js.map +1 -0
- package/dist/src/pkg/worksheet.utils.d.ts +27 -0
- package/dist/src/pkg/worksheet.utils.js +116 -0
- package/dist/src/pkg/worksheet.utils.js.map +1 -0
- package/dist/src/services/audit-service.d.ts +7 -0
- package/dist/src/services/audit-service.js +32 -0
- package/dist/src/services/audit-service.js.map +1 -0
- package/dist/src/services/excel.service.d.ts +25 -0
- package/dist/src/services/excel.service.js +95 -0
- package/dist/src/services/excel.service.js.map +1 -0
- package/dist/src/services/http-service.d.ts +7 -0
- package/dist/src/services/http-service.js +67 -0
- package/dist/src/services/http-service.js.map +1 -0
- package/dist/src/services/index.d.ts +8 -0
- package/dist/src/services/index.js +25 -0
- package/dist/src/services/index.js.map +1 -0
- package/dist/src/services/kafka-service.d.ts +15 -0
- package/dist/src/services/kafka-service.js +68 -0
- package/dist/src/services/kafka-service.js.map +1 -0
- package/dist/src/services/mailer-service.d.ts +15 -0
- package/dist/src/services/mailer-service.js +44 -0
- package/dist/src/services/mailer-service.js.map +1 -0
- package/dist/src/services/paginated-cache.d.ts +16 -0
- package/dist/src/services/paginated-cache.js +115 -0
- package/dist/src/services/paginated-cache.js.map +1 -0
- package/dist/src/services/paginated-cache.spec.d.ts +1 -0
- package/dist/src/services/paginated-cache.spec.js +284 -0
- package/dist/src/services/paginated-cache.spec.js.map +1 -0
- package/dist/src/services/redis-service.d.ts +33 -0
- package/dist/src/services/redis-service.js +230 -0
- package/dist/src/services/redis-service.js.map +1 -0
- package/dist/src/services/security-service.d.ts +11 -0
- package/dist/src/services/security-service.js +68 -0
- package/dist/src/services/security-service.js.map +1 -0
- package/package.json +1 -1
- package/src/constants.ts +47 -0
- package/src/gateways/alibaba-cloud-gateway.ts +127 -0
- package/src/gateways/http-audit-gateway.ts +104 -0
- package/src/gateways/index.ts +5 -0
- package/src/gateways/internal-auth-gateway.ts +42 -0
- package/src/gateways/stdout-audit-gateway.ts +23 -0
- package/src/gateways/webhook-audit-gateway.ts +33 -0
- package/src/interfaces.ts +304 -0
- package/src/models/audit-log.ts +126 -0
- package/src/models/index.ts +1 -0
- package/src/pkg/array-helper.ts +7 -0
- package/src/pkg/bcrypt-helper.ts +9 -0
- package/src/pkg/crypto-helper.ts +18 -0
- package/src/pkg/encryption-helper.spec.ts +423 -0
- package/src/pkg/encryption-helper.ts +155 -0
- package/src/pkg/filter-helper.spec.ts +105 -0
- package/src/pkg/filter-helper.ts +139 -0
- package/src/pkg/geoip-helper.ts +5 -0
- package/src/pkg/hash-helper.ts +12 -0
- package/src/pkg/http-request-utils.ts +75 -0
- package/src/pkg/index.ts +18 -0
- package/src/pkg/key-helper.ts +20 -0
- package/src/pkg/logger.ts +23 -0
- package/src/pkg/object-helper.ts +42 -0
- package/src/pkg/paginated-cache-registry.ts +25 -0
- package/src/pkg/query-helper.ts +79 -0
- package/src/pkg/referral-tree-utils.ts +165 -0
- package/src/pkg/scripts/index.ts +1 -0
- package/src/pkg/scripts/lua.ts +112 -0
- package/src/pkg/sort-helper.ts +19 -0
- package/src/pkg/string-utils.ts +104 -0
- package/src/pkg/task-helper.ts +25 -0
- package/src/pkg/workflow/delayed-task-registry.ts +54 -0
- package/src/pkg/workflow/delayed-task.ts +106 -0
- package/src/pkg/workflow/index.ts +5 -0
- package/src/pkg/workflow/processing-milestone.ts +54 -0
- package/src/pkg/workflow/retry-task.spec.ts +194 -0
- package/src/pkg/workflow/retry-task.ts +119 -0
- package/src/pkg/workflow/sync-taskqueue.ts +118 -0
- package/src/pkg/worksheet.utils.ts +178 -0
- package/src/services/audit-service.ts +22 -0
- package/src/services/excel.service.ts +103 -0
- package/src/services/http-service.ts +71 -0
- package/src/services/index.ts +8 -0
- package/src/services/kafka-service.ts +81 -0
- package/src/services/mailer-service.ts +43 -0
- package/src/services/paginated-cache.spec.ts +519 -0
- package/src/services/paginated-cache.ts +122 -0
- package/src/services/redis-service.ts +238 -0
- package/src/services/security-service.ts +80 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export declare enum LOG_LEVEL {
|
|
2
|
+
INFO = "info",
|
|
3
|
+
ERROR = "error",
|
|
4
|
+
DEBUG = "debug",
|
|
5
|
+
FATAL = "fatal"
|
|
6
|
+
}
|
|
7
|
+
export type HttpMethod = "get" | "post" | "put" | "patch" | "delete";
|
|
8
|
+
export declare enum APP_ERROR {
|
|
9
|
+
HTTP_REQ_TIMEOUT = "ECONNABORTED"
|
|
10
|
+
}
|
|
11
|
+
export declare enum SET_CACHE_POLICY {
|
|
12
|
+
KEEP_TTL = 0,
|
|
13
|
+
WITH_TTL = 1,
|
|
14
|
+
IF_EXISTS = 2,
|
|
15
|
+
IF_NOT_EXISTS = 3
|
|
16
|
+
}
|
|
17
|
+
export declare enum APP_ENV {
|
|
18
|
+
DEVELOPMENT = "development",
|
|
19
|
+
STAGING = "staging",
|
|
20
|
+
PRODUCTION = "production"
|
|
21
|
+
}
|
|
22
|
+
export declare enum FILTER_OPERATOR {
|
|
23
|
+
NOT = "not",
|
|
24
|
+
EQUAL = "eq",
|
|
25
|
+
LIKE = "like",
|
|
26
|
+
INS_LIKE = "ins_like",
|
|
27
|
+
STARTS_WITH = "starts_with",
|
|
28
|
+
ENDS_WITH = "ends_with",
|
|
29
|
+
INS_STARTS_WITH = "ins_starts_with",
|
|
30
|
+
INS_ENDS_WITH = "ins_ends_with",
|
|
31
|
+
LESS_THAN = "lt",
|
|
32
|
+
LESS_THAN_OR_EQUAL = "lte",
|
|
33
|
+
GREATER_THAN = "gt",
|
|
34
|
+
GREATER_THAN_OR_EQUAL = "gte",
|
|
35
|
+
IN = "in",
|
|
36
|
+
NOT_IN = "nin",
|
|
37
|
+
OR = "or",
|
|
38
|
+
NOR = "nor",
|
|
39
|
+
AND = "and",
|
|
40
|
+
IS = "is",
|
|
41
|
+
NOT_EQUAL = "ne"
|
|
42
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FILTER_OPERATOR = exports.APP_ENV = exports.SET_CACHE_POLICY = exports.APP_ERROR = exports.LOG_LEVEL = void 0;
|
|
4
|
+
var LOG_LEVEL;
|
|
5
|
+
(function (LOG_LEVEL) {
|
|
6
|
+
LOG_LEVEL["INFO"] = "info";
|
|
7
|
+
LOG_LEVEL["ERROR"] = "error";
|
|
8
|
+
LOG_LEVEL["DEBUG"] = "debug";
|
|
9
|
+
LOG_LEVEL["FATAL"] = "fatal";
|
|
10
|
+
})(LOG_LEVEL = exports.LOG_LEVEL || (exports.LOG_LEVEL = {}));
|
|
11
|
+
var APP_ERROR;
|
|
12
|
+
(function (APP_ERROR) {
|
|
13
|
+
APP_ERROR["HTTP_REQ_TIMEOUT"] = "ECONNABORTED";
|
|
14
|
+
})(APP_ERROR = exports.APP_ERROR || (exports.APP_ERROR = {}));
|
|
15
|
+
var SET_CACHE_POLICY;
|
|
16
|
+
(function (SET_CACHE_POLICY) {
|
|
17
|
+
SET_CACHE_POLICY[SET_CACHE_POLICY["KEEP_TTL"] = 0] = "KEEP_TTL";
|
|
18
|
+
SET_CACHE_POLICY[SET_CACHE_POLICY["WITH_TTL"] = 1] = "WITH_TTL";
|
|
19
|
+
SET_CACHE_POLICY[SET_CACHE_POLICY["IF_EXISTS"] = 2] = "IF_EXISTS";
|
|
20
|
+
SET_CACHE_POLICY[SET_CACHE_POLICY["IF_NOT_EXISTS"] = 3] = "IF_NOT_EXISTS";
|
|
21
|
+
})(SET_CACHE_POLICY = exports.SET_CACHE_POLICY || (exports.SET_CACHE_POLICY = {}));
|
|
22
|
+
var APP_ENV;
|
|
23
|
+
(function (APP_ENV) {
|
|
24
|
+
APP_ENV["DEVELOPMENT"] = "development";
|
|
25
|
+
APP_ENV["STAGING"] = "staging";
|
|
26
|
+
APP_ENV["PRODUCTION"] = "production";
|
|
27
|
+
})(APP_ENV = exports.APP_ENV || (exports.APP_ENV = {}));
|
|
28
|
+
var FILTER_OPERATOR;
|
|
29
|
+
(function (FILTER_OPERATOR) {
|
|
30
|
+
FILTER_OPERATOR["NOT"] = "not";
|
|
31
|
+
FILTER_OPERATOR["EQUAL"] = "eq";
|
|
32
|
+
FILTER_OPERATOR["LIKE"] = "like";
|
|
33
|
+
FILTER_OPERATOR["INS_LIKE"] = "ins_like";
|
|
34
|
+
FILTER_OPERATOR["STARTS_WITH"] = "starts_with";
|
|
35
|
+
FILTER_OPERATOR["ENDS_WITH"] = "ends_with";
|
|
36
|
+
FILTER_OPERATOR["INS_STARTS_WITH"] = "ins_starts_with";
|
|
37
|
+
FILTER_OPERATOR["INS_ENDS_WITH"] = "ins_ends_with";
|
|
38
|
+
FILTER_OPERATOR["LESS_THAN"] = "lt";
|
|
39
|
+
FILTER_OPERATOR["LESS_THAN_OR_EQUAL"] = "lte";
|
|
40
|
+
FILTER_OPERATOR["GREATER_THAN"] = "gt";
|
|
41
|
+
FILTER_OPERATOR["GREATER_THAN_OR_EQUAL"] = "gte";
|
|
42
|
+
FILTER_OPERATOR["IN"] = "in";
|
|
43
|
+
FILTER_OPERATOR["NOT_IN"] = "nin";
|
|
44
|
+
FILTER_OPERATOR["OR"] = "or";
|
|
45
|
+
FILTER_OPERATOR["NOR"] = "nor";
|
|
46
|
+
FILTER_OPERATOR["AND"] = "and";
|
|
47
|
+
FILTER_OPERATOR["IS"] = "is";
|
|
48
|
+
FILTER_OPERATOR["NOT_EQUAL"] = "ne";
|
|
49
|
+
})(FILTER_OPERATOR = exports.FILTER_OPERATOR || (exports.FILTER_OPERATOR = {}));
|
|
50
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAA,IAAY,SAKX;AALD,WAAY,SAAS;IACnB,0BAAa,CAAA;IACb,4BAAe,CAAA;IACf,4BAAe,CAAA;IACf,4BAAe,CAAA;AACjB,CAAC,EALW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAKpB;AAID,IAAY,SAEX;AAFD,WAAY,SAAS;IACnB,8CAAiC,CAAA;AACnC,CAAC,EAFW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAEpB;AAED,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC1B,+DAAQ,CAAA;IACR,+DAAQ,CAAA;IACR,iEAAS,CAAA;IACT,yEAAa,CAAA;AACf,CAAC,EALW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAK3B;AAED,IAAY,OAIX;AAJD,WAAY,OAAO;IACjB,sCAA2B,CAAA;IAC3B,8BAAmB,CAAA;IACnB,oCAAyB,CAAA;AAC3B,CAAC,EAJW,OAAO,GAAP,eAAO,KAAP,eAAO,QAIlB;AAED,IAAY,eAoBX;AApBD,WAAY,eAAe;IACzB,8BAAW,CAAA;IACX,+BAAY,CAAA;IACZ,gCAAa,CAAA;IACb,wCAAqB,CAAA;IACrB,8CAA2B,CAAA;IAC3B,0CAAuB,CAAA;IACvB,sDAAmC,CAAA;IACnC,kDAA+B,CAAA;IAC/B,mCAAgB,CAAA;IAChB,6CAA0B,CAAA;IAC1B,sCAAmB,CAAA;IACnB,gDAA6B,CAAA;IAC7B,4BAAS,CAAA;IACT,iCAAc,CAAA;IACd,4BAAS,CAAA;IACT,8BAAW,CAAA;IACX,8BAAW,CAAA;IACX,4BAAS,CAAA;IACT,mCAAgB,CAAA;AAClB,CAAC,EApBW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAoB1B"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import OSS from "ali-oss";
|
|
3
|
+
import Core from "@alicloud/pop-core";
|
|
4
|
+
import { CloudStorageClient, PutObjectOption, STSResponse } from "../interfaces";
|
|
5
|
+
export interface AlibabaCloudGatewayConfig {
|
|
6
|
+
accessKey: string;
|
|
7
|
+
secret: string;
|
|
8
|
+
apiVersion?: string;
|
|
9
|
+
endpoint: string;
|
|
10
|
+
timeout?: number;
|
|
11
|
+
oss: {
|
|
12
|
+
bucketName: string;
|
|
13
|
+
region: string;
|
|
14
|
+
};
|
|
15
|
+
sts: {
|
|
16
|
+
roleArn: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export declare class AlibabaCloudGateway implements CloudStorageClient {
|
|
20
|
+
protected config: AlibabaCloudGatewayConfig;
|
|
21
|
+
protected coreClient: Core;
|
|
22
|
+
protected ossClient: OSS;
|
|
23
|
+
constructor(config: AlibabaCloudGatewayConfig);
|
|
24
|
+
generateTmpCredentials(sessionID: string): Promise<STSResponse["Credentials"]>;
|
|
25
|
+
uploadLocalToBucket(fileName: string, fileData: Buffer, options?: PutObjectOption): Promise<string>;
|
|
26
|
+
deleteObject(filePath: string): Promise<void>;
|
|
27
|
+
uploadRemoteObjectToBucket(fileName: string, remoteUrl: string, options?: PutObjectOption): Promise<string>;
|
|
28
|
+
getObjectReadStream(fileName: string): Promise<OSS.GetStreamResult>;
|
|
29
|
+
writeFileToDestination(fileName: string, destination: string | WritableStream): Promise<OSS.GetObjectResult>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.AlibabaCloudGateway = void 0;
|
|
39
|
+
const ali_oss_1 = __importDefault(require("ali-oss"));
|
|
40
|
+
const axios_1 = __importStar(require("axios"));
|
|
41
|
+
const pop_core_1 = __importDefault(require("@alicloud/pop-core"));
|
|
42
|
+
class AlibabaCloudGateway {
|
|
43
|
+
constructor(config) {
|
|
44
|
+
this.config = config;
|
|
45
|
+
this.coreClient = new pop_core_1.default({
|
|
46
|
+
accessKeyId: config.accessKey,
|
|
47
|
+
accessKeySecret: config.secret,
|
|
48
|
+
apiVersion: config.apiVersion || "2015-04-01",
|
|
49
|
+
endpoint: config.endpoint,
|
|
50
|
+
});
|
|
51
|
+
this.ossClient = new ali_oss_1.default({
|
|
52
|
+
accessKeyId: config.accessKey,
|
|
53
|
+
accessKeySecret: config.secret,
|
|
54
|
+
region: config.oss.region,
|
|
55
|
+
bucket: config.oss.bucketName,
|
|
56
|
+
timeout: config.timeout || 3000,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
generateTmpCredentials(sessionID) {
|
|
60
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
const requestResponse = yield this.coreClient.request("AssumeRole", {
|
|
62
|
+
RoleArn: this.config.sts.roleArn,
|
|
63
|
+
RoleSessionName: sessionID,
|
|
64
|
+
DurationSeconds: this.config.timeout || 900,
|
|
65
|
+
}, {
|
|
66
|
+
method: "POST",
|
|
67
|
+
contentType: "application/json",
|
|
68
|
+
});
|
|
69
|
+
return requestResponse.Credentials;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
uploadLocalToBucket(fileName, fileData, options) {
|
|
73
|
+
var _a;
|
|
74
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
const putResult = yield this.ossClient.put(fileName, fileData, {
|
|
76
|
+
timeout: (options === null || options === void 0 ? void 0 : options.timeout) || 15000,
|
|
77
|
+
});
|
|
78
|
+
if (options === null || options === void 0 ? void 0 : options.domain) {
|
|
79
|
+
return `${options.domain}/${fileName}`;
|
|
80
|
+
}
|
|
81
|
+
if ((_a = putResult === null || putResult === void 0 ? void 0 : putResult.url) === null || _a === void 0 ? void 0 : _a.includes("http://")) {
|
|
82
|
+
return putResult.url.replace("http://", "https://");
|
|
83
|
+
}
|
|
84
|
+
return putResult.url;
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
deleteObject(filePath) {
|
|
88
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
yield this.ossClient.delete(filePath);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
uploadRemoteObjectToBucket(fileName, remoteUrl, options) {
|
|
93
|
+
var _a;
|
|
94
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
+
const response = yield axios_1.default.get(remoteUrl, { responseType: "stream" });
|
|
96
|
+
if (response.status !== axios_1.HttpStatusCode.Ok) {
|
|
97
|
+
throw new Error("failed to fetch from remote url");
|
|
98
|
+
}
|
|
99
|
+
const { data } = response;
|
|
100
|
+
const putResult = yield this.ossClient.put(fileName, data, {
|
|
101
|
+
timeout: options.timeout || 15000,
|
|
102
|
+
});
|
|
103
|
+
if (options === null || options === void 0 ? void 0 : options.domain) {
|
|
104
|
+
return `${options.domain}/${fileName}`;
|
|
105
|
+
}
|
|
106
|
+
if ((_a = putResult === null || putResult === void 0 ? void 0 : putResult.url) === null || _a === void 0 ? void 0 : _a.includes("http://")) {
|
|
107
|
+
return putResult.url.replace("http://", "https://");
|
|
108
|
+
}
|
|
109
|
+
return putResult.url;
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
getObjectReadStream(fileName) {
|
|
113
|
+
return this.ossClient.getStream(fileName);
|
|
114
|
+
}
|
|
115
|
+
writeFileToDestination(fileName, destination) {
|
|
116
|
+
return this.ossClient.get(fileName, destination);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
exports.AlibabaCloudGateway = AlibabaCloudGateway;
|
|
120
|
+
//# sourceMappingURL=alibaba-cloud-gateway.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alibaba-cloud-gateway.js","sourceRoot":"","sources":["../../../src/gateways/alibaba-cloud-gateway.ts"],"names":[],"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AAT,SAAS,uBAAT,SAAS,CAAE,GAAG,0CAAE,QAAQ,CAAC,SAAS,CAAC,EAAE;gBACvC,OAAO,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;aACrD;YAED,OAAO,SAAS,CAAC,GAAG,CAAC;;KACtB;IAEM,mBAAmB,CAAC,QAAgB;QACzC,OAAO,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IAC5C,CAAC;IAEM,sBAAsB,CAC3B,QAAgB,EAChB,WAAoC;QAEpC,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;IACnD,CAAC;CACF;AArGD,kDAqGC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AxiosRequestConfig, AxiosResponse } from "axios";
|
|
2
|
+
import { LOG_LEVEL } from "../constants";
|
|
3
|
+
import { AuditGateway } from "../interfaces";
|
|
4
|
+
export interface HttpAuditGatewayConfig {
|
|
5
|
+
baseUrl: string;
|
|
6
|
+
appName?: string;
|
|
7
|
+
auth: {
|
|
8
|
+
username: string;
|
|
9
|
+
password: string;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export declare class HttpAuditGateway implements AuditGateway {
|
|
13
|
+
protected config: HttpAuditGatewayConfig;
|
|
14
|
+
protected baseURL: string;
|
|
15
|
+
protected access_token: string;
|
|
16
|
+
constructor(config: HttpAuditGatewayConfig);
|
|
17
|
+
publish(logId: string, level: LOG_LEVEL, content: Record<string, any>): Promise<unknown>;
|
|
18
|
+
private auth;
|
|
19
|
+
protected send<T>(logId: string, options: AxiosRequestConfig, is_retry?: boolean, use_access_token?: boolean): Promise<AxiosResponse<T>>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.HttpAuditGateway = void 0;
|
|
16
|
+
const axios_1 = __importDefault(require("axios"));
|
|
17
|
+
const string_utils_1 = require("../pkg/string-utils");
|
|
18
|
+
class HttpAuditGateway {
|
|
19
|
+
constructor(config) {
|
|
20
|
+
this.config = config;
|
|
21
|
+
if (!config.baseUrl) {
|
|
22
|
+
throw new Error("Missing base url config");
|
|
23
|
+
}
|
|
24
|
+
this.baseURL = config.baseUrl;
|
|
25
|
+
}
|
|
26
|
+
publish(logId, level, content) {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
if (!this.access_token) {
|
|
29
|
+
yield this.auth();
|
|
30
|
+
}
|
|
31
|
+
const response = yield this.send(logId, {
|
|
32
|
+
method: "POST",
|
|
33
|
+
url: "/event/create",
|
|
34
|
+
data: Object.assign(Object.assign({}, content), { level }),
|
|
35
|
+
});
|
|
36
|
+
return response === null || response === void 0 ? void 0 : response.data;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
auth(logId = "system", forceReAuth = false) {
|
|
40
|
+
var _a;
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
if (this.access_token || forceReAuth) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const authResponse = yield this.send(logId, {
|
|
46
|
+
method: "POST",
|
|
47
|
+
url: "/auth/login",
|
|
48
|
+
data: this.config.auth,
|
|
49
|
+
}, false, false);
|
|
50
|
+
this.access_token = (_a = authResponse === null || authResponse === void 0 ? void 0 : authResponse.data) === null || _a === void 0 ? void 0 : _a.access_token;
|
|
51
|
+
return !!this.access_token;
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
send(logId, options, is_retry = false, use_access_token = true) {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
console.log(`[${logId}] ${is_retry ? "Resend" : "Send"} to Audit Service: ${JSON.stringify(options, string_utils_1.maskFn)}`);
|
|
57
|
+
options.baseURL = this.baseURL;
|
|
58
|
+
if (use_access_token) {
|
|
59
|
+
options.headers = {
|
|
60
|
+
Authorization: `Bearer ${this.access_token}`,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
const response = yield axios_1.default.request(options);
|
|
64
|
+
if ((response === null || response === void 0 ? void 0 : response.status) == 401 && use_access_token && !is_retry) {
|
|
65
|
+
console.log(`[${logId}] Retrying...`);
|
|
66
|
+
const isAuthSuccess = yield this.auth(logId, true);
|
|
67
|
+
if (isAuthSuccess) {
|
|
68
|
+
return this.send(logId, options, true);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return response;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.HttpAuditGateway = HttpAuditGateway;
|
|
76
|
+
//# sourceMappingURL=http-audit-gateway.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-audit-gateway.js","sourceRoot":"","sources":["../../../src/gateways/http-audit-gateway.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAAiE;AAIjE,sDAA6C;AAW7C,MAAa,gBAAgB;IAI3B,YAAsB,MAA8B;QAA9B,WAAM,GAAN,MAAM,CAAwB;QAClD,IAAI,CA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BAAsB,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,qBAAM,CAAC,EAAE,CACxD,CAAC;YAEF,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;YAC/B,IAAI,gBAAgB,EAAE;gBACpB,OAAO,CAAC,OAAO,GAAG;oBAChB,aAAa,EAAE,UAAU,IAAI,CAAC,YAAY,EAAE;iBAC7C,CAAC;aACH;YAED,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YAG9C,IAAI,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,MAAM,KAAI,GAAG,IAAI,gBAAgB,IAAI,CAAC,QAAQ,EAAE;gBAC5D,OAAO,CAAC,GAAG,CAAC,IAAI,KAAK,eAAe,CAAC,CAAC;gBAEtC,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;gBAEnD,IAAI,aAAa,EAAE;oBACjB,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;iBACxC;aACF;YAED,OAAO,QAAQ,CAAC;QAClB,CAAC;KAAA;CACF;AAxFD,4CAwFC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./alibaba-cloud-gateway"), exports);
|
|
18
|
+
__exportStar(require("./http-audit-gateway"), exports);
|
|
19
|
+
__exportStar(require("./stdout-audit-gateway"), exports);
|
|
20
|
+
__exportStar(require("./internal-auth-gateway"), exports);
|
|
21
|
+
__exportStar(require("./webhook-audit-gateway"), exports);
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/gateways/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAwC;AACxC,uDAAqC;AACrC,yDAAuC;AACvC,0DAAwC;AACxC,0DAAwC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { HttpService, InternalAuthGatewayOptions, InternalAuthLoginResult, InternalServiceAuthResult, OperationResult } from "../interfaces";
|
|
2
|
+
export declare class InternalAuthGateway {
|
|
3
|
+
protected httpService: HttpService;
|
|
4
|
+
protected options: InternalAuthGatewayOptions;
|
|
5
|
+
constructor(httpService: HttpService, options: InternalAuthGatewayOptions);
|
|
6
|
+
login(): Promise<OperationResult<InternalAuthLoginResult>>;
|
|
7
|
+
verify(accessToken: string): Promise<OperationResult<InternalServiceAuthResult>>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.InternalAuthGateway = void 0;
|
|
13
|
+
class InternalAuthGateway {
|
|
14
|
+
constructor(httpService, options) {
|
|
15
|
+
this.httpService = httpService;
|
|
16
|
+
this.options = options;
|
|
17
|
+
}
|
|
18
|
+
login() {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
return this.httpService.send("post", `${this.options.endpointURL}/actors/login`, {
|
|
21
|
+
body: {
|
|
22
|
+
secret: this.options.secret,
|
|
23
|
+
},
|
|
24
|
+
serviceName: this.options.serviceName,
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
verify(accessToken) {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
return this.httpService.send("post", `${this.options.endpointURL}/actors/verify`, {
|
|
31
|
+
body: {
|
|
32
|
+
accessToken,
|
|
33
|
+
},
|
|
34
|
+
serviceName: this.options.serviceName,
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.InternalAuthGateway = InternalAuthGateway;
|
|
40
|
+
//# sourceMappingURL=internal-auth-gateway.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal-auth-gateway.js","sourceRoot":"","sources":["../../../src/gateways/internal-auth-gateway.ts"],"names":[],"mappings":";;;;;;;;;;;;AAQA,MAAa,mBAAmB;IAC9B,YACY,WAAwB,EACxB,OAAmC;QADnC,gBAAW,GAAX,WAAW,CAAa;QACxB,YAAO,GAAP,OAAO,CAA4B;IAC5C,CAAC;IAES,KAAK;;YAChB,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAC1B,MAAM,EACN,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,eAAe,EAC1C;gBACE,IAAI,EAAE;oBACJ,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM;iBAC5B;gBACD,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW;aACtC,CACF,CAAC;QACJ,CAAC;KAAA;IAEY,MAAM,CACjB,WAAmB;;YAEnB,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAC1B,MAAM,EACN,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,gBAAgB,EAC3C;gBACE,IAAI,EAAE;oBACJ,WAAW;iBACZ;gBACD,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW;aACtC,CACF,CAAC;QACJ,CAAC;KAAA;CACF;AAjCD,kDAiCC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { LOG_LEVEL } from "../constants";
|
|
2
|
+
import { AuditGateway, Logger } from "../interfaces";
|
|
3
|
+
export declare class StdOutAuditGateway implements AuditGateway {
|
|
4
|
+
protected logger: Logger;
|
|
5
|
+
constructor();
|
|
6
|
+
publish(logId: string, level: LOG_LEVEL, content: any): Promise<any>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.StdOutAuditGateway = void 0;
|
|
13
|
+
const pkg_1 = require("../pkg");
|
|
14
|
+
class StdOutAuditGateway {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.logger = new pkg_1.loggers.PinoLogger();
|
|
17
|
+
}
|
|
18
|
+
publish(logId, level, content) {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
return this.logger.info(`[LogId ${logId}]`, `[${level.toUpperCase}]`, content);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.StdOutAuditGateway = StdOutAuditGateway;
|
|
25
|
+
//# sourceMappingURL=stdout-audit-gateway.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stdout-audit-gateway.js","sourceRoot":"","sources":["../../../src/gateways/stdout-audit-gateway.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,gCAAiC;AAGjC,MAAa,kBAAkB;IAG7B;QACE,IAAI,CAAC,MAAM,GAAG,IAAI,aAAO,CAAC,UAAU,EAAE,CAAC;IACzC,CAAC;IAEY,OAAO,CAClB,KAAa,EACb,KAAgB,EAChB,OAAY;;YAEZ,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CACrB,UAAU,KAAK,GAAG,EAClB,IAAI,KAAK,CAAC,WAAW,GAAG,EACxB,OAAO,CACR,CAAC;QACJ,CAAC;KAAA;CACF;AAlBD,gDAkBC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { LOG_LEVEL } from "../constants";
|
|
2
|
+
import { AuditGateway, HttpService } from "../interfaces";
|
|
3
|
+
interface WebhookAuditGatewayConfig {
|
|
4
|
+
projectName: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class WebhookAuditGateway implements AuditGateway {
|
|
7
|
+
protected webhookURL: string;
|
|
8
|
+
protected httpService: HttpService;
|
|
9
|
+
protected config: WebhookAuditGatewayConfig;
|
|
10
|
+
static contentField: string;
|
|
11
|
+
constructor(webhookURL: string, httpService: HttpService, config: WebhookAuditGatewayConfig);
|
|
12
|
+
publish(logId: string, level: LOG_LEVEL, content: any): Promise<any>;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebhookAuditGateway = void 0;
|
|
4
|
+
class WebhookAuditGateway {
|
|
5
|
+
constructor(webhookURL, httpService, config) {
|
|
6
|
+
this.webhookURL = webhookURL;
|
|
7
|
+
this.httpService = httpService;
|
|
8
|
+
this.config = config;
|
|
9
|
+
}
|
|
10
|
+
publish(logId, level, content) {
|
|
11
|
+
const logContent = content && typeof content === "object"
|
|
12
|
+
? JSON.stringify(content)
|
|
13
|
+
: content;
|
|
14
|
+
const msg = `[${this.config.projectName}] | [${level}] | [${logId}]: ${logContent}`;
|
|
15
|
+
return this.httpService.send("post", this.webhookURL, {
|
|
16
|
+
headers: {
|
|
17
|
+
"Content-Type": "application/json",
|
|
18
|
+
},
|
|
19
|
+
body: {
|
|
20
|
+
[WebhookAuditGateway.contentField]: msg,
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
WebhookAuditGateway.contentField = "content";
|
|
26
|
+
exports.WebhookAuditGateway = WebhookAuditGateway;
|
|
27
|
+
//# sourceMappingURL=webhook-audit-gateway.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook-audit-gateway.js","sourceRoot":"","sources":["../../../src/gateways/webhook-audit-gateway.ts"],"names":[],"mappings":";;;AAOA,MAAa,mBAAmB;IAG9B,YACY,UAAkB,EAClB,WAAwB,EACxB,MAAiC;QAFjC,eAAU,GAAV,UAAU,CAAQ;QAClB,gBAAW,GAAX,WAAW,CAAa;QACxB,WAAM,GAAN,MAAM,CAA2B;IAC1C,CAAC;IAEG,OAAO,CAAC,KAAa,EAAE,KAAgB,EAAE,OAAY;QAC1D,MAAM,UAAU,GACd,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ;YACpC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;YACzB,CAAC,CAAC,OAAO,CAAC;QACd,MAAM,GAAG,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,WAAW,QAAQ,KAAK,QAAQ,KAAK,MAAM,UAAU,EAAE,CAAC;QAEpF,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE;YACpD,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE;gBACJ,CAAC,mBAAmB,CAAC,YAAY,CAAC,EAAE,GAAG;aACxC;SACF,CAAC,CAAC;IACL,CAAC;;AAvBa,gCAAY,GAAG,SAAS,CAAC;AAD5B,kDAAmB"}
|