drapcode-utility 1.1.9 → 1.2.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.
- package/build/encryption/KMS.d.ts +0 -5
- package/build/encryption/KMS.js +5 -35
- package/build/encryption/crypt.js +2 -2
- package/build/encryption/file.js +4 -4
- package/build/encryption/index.d.ts +2 -1
- package/build/encryption/index.js +47 -33
- package/build/encryption/model.d.ts +2 -2
- package/build/index.js +5 -1
- package/build/middlewares/error-logger.js +6 -6
- package/build/middlewares/interceptor-logger-new.js +6 -6
- package/build/middlewares/interceptor-logger.js +3 -3
- package/build/middlewares/redis/request-log.js +4 -4
- package/build/utils/check-error.js +12 -8
- package/build/utils/date-util.js +3 -3
- package/build/utils/query-parser.js +57 -53
- package/build/utils/query-paser-new.js +52 -48
- package/build/utils/s3-util.d.ts +4 -0
- package/build/utils/s3-util.js +45 -24
- package/build/utils/util.d.ts +1 -1
- package/build/utils/util.js +11 -11
- package/build/utils/uuid-generator.js +2 -2
- package/package.json +1 -1
|
@@ -4,11 +4,6 @@ export declare const processKMSEncryption: (config: AwsConfig, arn: string, plai
|
|
|
4
4
|
data: string;
|
|
5
5
|
message: string;
|
|
6
6
|
}>;
|
|
7
|
-
export declare const processKMSDecryption: (config: AwsConfig, cipherText: string, context: any) => Promise<{
|
|
8
|
-
status: string;
|
|
9
|
-
data: string;
|
|
10
|
-
message: string;
|
|
11
|
-
}>;
|
|
12
7
|
export declare const processKMSGenerateDataKey: (config: AwsConfig, arn: string) => Promise<{
|
|
13
8
|
status: string;
|
|
14
9
|
dataKey: string;
|
package/build/encryption/KMS.js
CHANGED
|
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
18
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
19
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
20
|
switch (op[0]) {
|
|
@@ -36,7 +36,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.processKMSGenerateDataKey = exports.
|
|
39
|
+
exports.processKMSGenerateDataKey = exports.processKMSEncryption = void 0;
|
|
40
40
|
var client_kms_1 = require("@aws-sdk/client-kms");
|
|
41
41
|
var processKMSEncryption = function (config, arn, plainText, context) { return __awaiter(void 0, void 0, void 0, function () {
|
|
42
42
|
var accessKeyId, secretAccessKey, region, client, input, command, response, cipherText, error_1;
|
|
@@ -72,38 +72,8 @@ var processKMSEncryption = function (config, arn, plainText, context) { return _
|
|
|
72
72
|
});
|
|
73
73
|
}); };
|
|
74
74
|
exports.processKMSEncryption = processKMSEncryption;
|
|
75
|
-
var processKMSDecryption = function (config, cipherText, context) { return __awaiter(void 0, void 0, void 0, function () {
|
|
76
|
-
var accessKeyId, secretAccessKey, region, client, dcipherText, input, command, response, plainText, error_2;
|
|
77
|
-
return __generator(this, function (_a) {
|
|
78
|
-
switch (_a.label) {
|
|
79
|
-
case 0:
|
|
80
|
-
_a.trys.push([0, 2, , 3]);
|
|
81
|
-
accessKeyId = config.accessKeyId, secretAccessKey = config.secretAccessKey, region = config.region;
|
|
82
|
-
client = new client_kms_1.KMSClient({
|
|
83
|
-
region: region,
|
|
84
|
-
credentials: { accessKeyId: accessKeyId, secretAccessKey: secretAccessKey },
|
|
85
|
-
});
|
|
86
|
-
dcipherText = Buffer.from(cipherText, "base64");
|
|
87
|
-
input = {
|
|
88
|
-
CiphertextBlob: dcipherText,
|
|
89
|
-
EncryptionContext: context,
|
|
90
|
-
};
|
|
91
|
-
command = new client_kms_1.DecryptCommand(input);
|
|
92
|
-
return [4 /*yield*/, client.send(command)];
|
|
93
|
-
case 1:
|
|
94
|
-
response = _a.sent();
|
|
95
|
-
plainText = Buffer.from(response.Plaintext).toString("base64");
|
|
96
|
-
return [2 /*return*/, { status: "SUCCESS", data: plainText, message: "" }];
|
|
97
|
-
case 2:
|
|
98
|
-
error_2 = _a.sent();
|
|
99
|
-
return [2 /*return*/, { status: "FAILED", data: "", message: error_2.message }];
|
|
100
|
-
case 3: return [2 /*return*/];
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
}); };
|
|
104
|
-
exports.processKMSDecryption = processKMSDecryption;
|
|
105
75
|
var processKMSGenerateDataKey = function (config, arn) { return __awaiter(void 0, void 0, void 0, function () {
|
|
106
|
-
var accessKeyId, secretAccessKey, region, input, client, command, response, cipherText,
|
|
76
|
+
var accessKeyId, secretAccessKey, region, input, client, command, response, cipherText, error_2;
|
|
107
77
|
return __generator(this, function (_a) {
|
|
108
78
|
switch (_a.label) {
|
|
109
79
|
case 0:
|
|
@@ -124,10 +94,10 @@ var processKMSGenerateDataKey = function (config, arn) { return __awaiter(void 0
|
|
|
124
94
|
cipherText = Buffer.from(response.CiphertextBlob).toString("base64");
|
|
125
95
|
return [2 /*return*/, { status: "SUCCESS", dataKey: cipherText, message: "" }];
|
|
126
96
|
case 2:
|
|
127
|
-
|
|
97
|
+
error_2 = _a.sent();
|
|
128
98
|
return [2 /*return*/, {
|
|
129
99
|
status: "FAILED",
|
|
130
|
-
message:
|
|
100
|
+
message: error_2.message,
|
|
131
101
|
dataKey: "",
|
|
132
102
|
}];
|
|
133
103
|
case 3: return [2 /*return*/];
|
|
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
18
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
19
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
20
|
switch (op[0]) {
|
|
@@ -88,7 +88,7 @@ var handleExtraString = function (key, append) {
|
|
|
88
88
|
if (append) {
|
|
89
89
|
var start = crypto_1.default.randomBytes(2).toString("hex");
|
|
90
90
|
var end = crypto_1.default.randomBytes(2).toString("hex");
|
|
91
|
-
key = ""
|
|
91
|
+
key = "".concat(start).concat(key).concat(end);
|
|
92
92
|
return key;
|
|
93
93
|
}
|
|
94
94
|
else {
|
package/build/encryption/file.js
CHANGED
|
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
18
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
19
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
20
|
switch (op[0]) {
|
|
@@ -58,11 +58,11 @@ var processFileEncryptionDecryption = function (data, encryption, decrypt) { ret
|
|
|
58
58
|
return [3 /*break*/, 6];
|
|
59
59
|
case 1:
|
|
60
60
|
if (!decrypt) return [3 /*break*/, 3];
|
|
61
|
-
return [4 /*yield*/, exports.decryptFile(data, dataKey)];
|
|
61
|
+
return [4 /*yield*/, (0, exports.decryptFile)(data, dataKey)];
|
|
62
62
|
case 2:
|
|
63
63
|
_b = _c.sent();
|
|
64
64
|
return [3 /*break*/, 5];
|
|
65
|
-
case 3: return [4 /*yield*/, exports.encryptFile(data, dataKey)];
|
|
65
|
+
case 3: return [4 /*yield*/, (0, exports.encryptFile)(data, dataKey)];
|
|
66
66
|
case 4:
|
|
67
67
|
_b = _c.sent();
|
|
68
68
|
_c.label = 5;
|
|
@@ -117,7 +117,7 @@ var decryptFile = function (encryptedFilePath, key) { return __awaiter(void 0, v
|
|
|
117
117
|
decipher = crypto_1.default.createDecipheriv(defaultAlgorithm, keyBuffer, iv);
|
|
118
118
|
decryptedBuffer = decipher.update(encryptedData);
|
|
119
119
|
decryptedBuffer = Buffer.concat([decryptedBuffer, decipher.final()]);
|
|
120
|
-
decryptedFilePath = encryptedFilePath.slice(0, -4)
|
|
120
|
+
decryptedFilePath = "".concat(encryptedFilePath.slice(0, -4), ".dec");
|
|
121
121
|
return [4 /*yield*/, fs_1.default.promises.writeFile(decryptedFilePath, decryptedBuffer)];
|
|
122
122
|
case 2:
|
|
123
123
|
_a.sent();
|
|
@@ -46,7 +46,8 @@ export declare const drapcodeEncryptDecrypt: (data: string, encrypt: boolean) =>
|
|
|
46
46
|
data: string;
|
|
47
47
|
message: string;
|
|
48
48
|
}>;
|
|
49
|
-
export declare const cryptFile: (filePath: any, encryption: Encryption, decrypt: boolean) => Promise<string
|
|
49
|
+
export declare const cryptFile: (filePath: any, encryption: Encryption, decrypt: boolean) => Promise<string>;
|
|
50
|
+
export declare const processKMSDecryption: (config: AwsConfig, cipherText: string, context: any) => Promise<{
|
|
50
51
|
status: string;
|
|
51
52
|
data: string;
|
|
52
53
|
message: string;
|
|
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
18
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
19
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
20
|
switch (op[0]) {
|
|
@@ -36,7 +36,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.cryptFile = exports.drapcodeEncryptDecrypt = exports.decryptDataWithKMS = exports.encryptDataWithKMS = exports.createKMSDataKey = exports.processDataEncryptionDecryption = exports.processItemEncryptDecrypt = exports.crypt = void 0;
|
|
39
|
+
exports.processKMSDecryption = exports.cryptFile = exports.drapcodeEncryptDecrypt = exports.decryptDataWithKMS = exports.encryptDataWithKMS = exports.createKMSDataKey = exports.processDataEncryptionDecryption = exports.processItemEncryptDecrypt = exports.crypt = void 0;
|
|
40
|
+
var client_kms_1 = require("@aws-sdk/client-kms");
|
|
40
41
|
var crypt_1 = require("./crypt");
|
|
41
42
|
var file_1 = require("./file");
|
|
42
43
|
var KMS_1 = require("./KMS");
|
|
@@ -52,7 +53,7 @@ var crypt = function (data, fields, encryption, decrypt) { return __awaiter(void
|
|
|
52
53
|
accessKeyId: accessKeyId,
|
|
53
54
|
secretAccessKey: secretAccessKey,
|
|
54
55
|
};
|
|
55
|
-
return [4 /*yield*/,
|
|
56
|
+
return [4 /*yield*/, (0, exports.processKMSDecryption)(config, encryption.dataKey, {})];
|
|
56
57
|
case 1:
|
|
57
58
|
plainTextData = _b.sent();
|
|
58
59
|
if (plainTextData.status === "FAILED") {
|
|
@@ -63,13 +64,13 @@ var crypt = function (data, fields, encryption, decrypt) { return __awaiter(void
|
|
|
63
64
|
case 2:
|
|
64
65
|
if (!Array.isArray(data)) return [3 /*break*/, 4];
|
|
65
66
|
promises = data.map(function (item) {
|
|
66
|
-
return exports.processItemEncryptDecrypt(item, fields, encryption, decrypt);
|
|
67
|
+
return (0, exports.processItemEncryptDecrypt)(item, fields, encryption, decrypt);
|
|
67
68
|
});
|
|
68
69
|
return [4 /*yield*/, Promise.all(promises)];
|
|
69
70
|
case 3:
|
|
70
71
|
data = _b.sent();
|
|
71
72
|
return [3 /*break*/, 6];
|
|
72
|
-
case 4: return [4 /*yield*/, exports.processItemEncryptDecrypt(data, fields, encryption, decrypt)];
|
|
73
|
+
case 4: return [4 /*yield*/, (0, exports.processItemEncryptDecrypt)(data, fields, encryption, decrypt)];
|
|
73
74
|
case 5:
|
|
74
75
|
data = _b.sent();
|
|
75
76
|
_b.label = 6;
|
|
@@ -93,7 +94,7 @@ var processItemEncryptDecrypt = function (item, fields, encryption, decrypt) { r
|
|
|
93
94
|
if (!(field && field.encrypted)) return [3 /*break*/, 2];
|
|
94
95
|
_c = item;
|
|
95
96
|
_d = fieldName;
|
|
96
|
-
return [4 /*yield*/, exports.processDataEncryptionDecryption(item[fieldName], encryption, decrypt)];
|
|
97
|
+
return [4 /*yield*/, (0, exports.processDataEncryptionDecryption)(item[fieldName], encryption, decrypt)];
|
|
97
98
|
case 1:
|
|
98
99
|
_c[_d] = _e.sent();
|
|
99
100
|
_e.label = 2;
|
|
@@ -133,11 +134,11 @@ var processDataEncryptionDecryption = function (data, encryption, decrypt) { ret
|
|
|
133
134
|
return [3 /*break*/, 6];
|
|
134
135
|
case 1:
|
|
135
136
|
if (!decrypt) return [3 /*break*/, 3];
|
|
136
|
-
return [4 /*yield*/, crypt_1.decryptData(data, dataKey)];
|
|
137
|
+
return [4 /*yield*/, (0, crypt_1.decryptData)(data, dataKey)];
|
|
137
138
|
case 2:
|
|
138
139
|
_b = _c.sent();
|
|
139
140
|
return [3 /*break*/, 5];
|
|
140
|
-
case 3: return [4 /*yield*/, crypt_1.encryptData(data, dataKey)];
|
|
141
|
+
case 3: return [4 /*yield*/, (0, crypt_1.encryptData)(data, dataKey)];
|
|
141
142
|
case 4:
|
|
142
143
|
_b = _c.sent();
|
|
143
144
|
_c.label = 5;
|
|
@@ -160,7 +161,7 @@ var createKMSDataKey = function (config, arn) { return __awaiter(void 0, void 0,
|
|
|
160
161
|
var dataKeyRes;
|
|
161
162
|
return __generator(this, function (_a) {
|
|
162
163
|
switch (_a.label) {
|
|
163
|
-
case 0: return [4 /*yield*/, KMS_1.processKMSGenerateDataKey(config, arn)];
|
|
164
|
+
case 0: return [4 /*yield*/, (0, KMS_1.processKMSGenerateDataKey)(config, arn)];
|
|
164
165
|
case 1:
|
|
165
166
|
dataKeyRes = _a.sent();
|
|
166
167
|
return [2 /*return*/, dataKeyRes];
|
|
@@ -181,7 +182,7 @@ var encryptDataWithKMS = function (config, arn, plainText, context) { return __a
|
|
|
181
182
|
var cryptData;
|
|
182
183
|
return __generator(this, function (_a) {
|
|
183
184
|
switch (_a.label) {
|
|
184
|
-
case 0: return [4 /*yield*/, KMS_1.processKMSEncryption(config, arn, plainText, context)];
|
|
185
|
+
case 0: return [4 /*yield*/, (0, KMS_1.processKMSEncryption)(config, arn, plainText, context)];
|
|
185
186
|
case 1:
|
|
186
187
|
cryptData = _a.sent();
|
|
187
188
|
return [2 /*return*/, cryptData];
|
|
@@ -201,7 +202,7 @@ var decryptDataWithKMS = function (config, cipherText, context) { return __await
|
|
|
201
202
|
var plainTextData;
|
|
202
203
|
return __generator(this, function (_a) {
|
|
203
204
|
switch (_a.label) {
|
|
204
|
-
case 0: return [4 /*yield*/,
|
|
205
|
+
case 0: return [4 /*yield*/, (0, exports.processKMSDecryption)(config, cipherText, context)];
|
|
205
206
|
case 1:
|
|
206
207
|
plainTextData = _a.sent();
|
|
207
208
|
return [2 /*return*/, plainTextData];
|
|
@@ -240,7 +241,7 @@ var drapcodeEncryptDecrypt = function (data, encrypt) { return __awaiter(void 0,
|
|
|
240
241
|
accessKeyId: accessKey,
|
|
241
242
|
secretAccessKey: secretKey,
|
|
242
243
|
};
|
|
243
|
-
return [4 /*yield*/,
|
|
244
|
+
return [4 /*yield*/, (0, exports.processKMSDecryption)(config, privateDataKey, {})];
|
|
244
245
|
case 1:
|
|
245
246
|
plainTextData = _a.sent();
|
|
246
247
|
if (plainTextData.status === "FAILED") {
|
|
@@ -250,13 +251,13 @@ var drapcodeEncryptDecrypt = function (data, encrypt) { return __awaiter(void 0,
|
|
|
250
251
|
response = null;
|
|
251
252
|
if (!encrypt) return [3 /*break*/, 3];
|
|
252
253
|
console.log("Encrypting");
|
|
253
|
-
return [4 /*yield*/, crypt_1.encryptData(data, publicKey)];
|
|
254
|
+
return [4 /*yield*/, (0, crypt_1.encryptData)(data, publicKey)];
|
|
254
255
|
case 2:
|
|
255
256
|
response = _a.sent();
|
|
256
257
|
return [3 /*break*/, 5];
|
|
257
258
|
case 3:
|
|
258
259
|
console.log("Decrypting");
|
|
259
|
-
return [4 /*yield*/, crypt_1.decryptData(data, publicKey)];
|
|
260
|
+
return [4 /*yield*/, (0, crypt_1.decryptData)(data, publicKey)];
|
|
260
261
|
case 4:
|
|
261
262
|
response = _a.sent();
|
|
262
263
|
_a.label = 5;
|
|
@@ -266,31 +267,44 @@ var drapcodeEncryptDecrypt = function (data, encrypt) { return __awaiter(void 0,
|
|
|
266
267
|
}); };
|
|
267
268
|
exports.drapcodeEncryptDecrypt = drapcodeEncryptDecrypt;
|
|
268
269
|
var cryptFile = function (filePath, encryption, decrypt) { return __awaiter(void 0, void 0, void 0, function () {
|
|
269
|
-
var
|
|
270
|
+
var data;
|
|
270
271
|
return __generator(this, function (_a) {
|
|
271
272
|
switch (_a.label) {
|
|
272
|
-
case 0:
|
|
273
|
-
awsConfig = encryption.awsConfig, encryptionType = encryption.encryptionType, dataKey = encryption.dataKey;
|
|
274
|
-
if (!(encryptionType === "KMS")) return [3 /*break*/, 2];
|
|
275
|
-
accessKeyId = awsConfig.accessKeyId, secretAccessKey = awsConfig.secretAccessKey, region = awsConfig.region;
|
|
276
|
-
config = {
|
|
277
|
-
region: region,
|
|
278
|
-
accessKeyId: accessKeyId,
|
|
279
|
-
secretAccessKey: secretAccessKey,
|
|
280
|
-
};
|
|
281
|
-
return [4 /*yield*/, KMS_1.processKMSDecryption(config, dataKey, {})];
|
|
273
|
+
case 0: return [4 /*yield*/, (0, file_1.processFileEncryptionDecryption)(filePath, encryption, decrypt)];
|
|
282
274
|
case 1:
|
|
283
|
-
plainTextData = _a.sent();
|
|
284
|
-
if (plainTextData.status === "FAILED") {
|
|
285
|
-
return [2 /*return*/, plainTextData];
|
|
286
|
-
}
|
|
287
|
-
encryption.dataKey = plainTextData.data;
|
|
288
|
-
_a.label = 2;
|
|
289
|
-
case 2: return [4 /*yield*/, file_1.processFileEncryptionDecryption(filePath, encryption, decrypt)];
|
|
290
|
-
case 3:
|
|
291
275
|
data = _a.sent();
|
|
292
276
|
return [2 /*return*/, data];
|
|
293
277
|
}
|
|
294
278
|
});
|
|
295
279
|
}); };
|
|
296
280
|
exports.cryptFile = cryptFile;
|
|
281
|
+
var processKMSDecryption = function (config, cipherText, context) { return __awaiter(void 0, void 0, void 0, function () {
|
|
282
|
+
var accessKeyId, secretAccessKey, region, client, dcipherText, input, command, response, plainText, error_1;
|
|
283
|
+
return __generator(this, function (_a) {
|
|
284
|
+
switch (_a.label) {
|
|
285
|
+
case 0:
|
|
286
|
+
_a.trys.push([0, 2, , 3]);
|
|
287
|
+
accessKeyId = config.accessKeyId, secretAccessKey = config.secretAccessKey, region = config.region;
|
|
288
|
+
client = new client_kms_1.KMSClient({
|
|
289
|
+
region: region,
|
|
290
|
+
credentials: { accessKeyId: accessKeyId, secretAccessKey: secretAccessKey },
|
|
291
|
+
});
|
|
292
|
+
dcipherText = Buffer.from(cipherText, "base64");
|
|
293
|
+
input = {
|
|
294
|
+
CiphertextBlob: dcipherText,
|
|
295
|
+
EncryptionContext: context,
|
|
296
|
+
};
|
|
297
|
+
command = new client_kms_1.DecryptCommand(input);
|
|
298
|
+
return [4 /*yield*/, client.send(command)];
|
|
299
|
+
case 1:
|
|
300
|
+
response = _a.sent();
|
|
301
|
+
plainText = Buffer.from(response.Plaintext).toString("base64");
|
|
302
|
+
return [2 /*return*/, { status: "SUCCESS", data: plainText, message: "" }];
|
|
303
|
+
case 2:
|
|
304
|
+
error_1 = _a.sent();
|
|
305
|
+
return [2 /*return*/, { status: "FAILED", data: "", message: error_1.message }];
|
|
306
|
+
case 3: return [2 /*return*/];
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
}); };
|
|
310
|
+
exports.processKMSDecryption = processKMSDecryption;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type AwsConfig = {
|
|
2
2
|
accessKeyId: string;
|
|
3
3
|
secretAccessKey: string;
|
|
4
4
|
region: string;
|
|
5
5
|
};
|
|
6
|
-
export
|
|
6
|
+
export type Encryption = {
|
|
7
7
|
encryptionType: string;
|
|
8
8
|
algorithm: string;
|
|
9
9
|
dataKey: string;
|
package/build/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
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);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -32,16 +32,16 @@ var errorLogger = function (err, req, res, next) {
|
|
|
32
32
|
var originalUrl = req.originalUrl, method = req.method, body = req.body, params = req.params, query = req.query, db = req.db, projectName = req.projectName, projectId = req.projectId, ip = req.ip;
|
|
33
33
|
var PreviouseFilePath;
|
|
34
34
|
if (projectName) {
|
|
35
|
-
loggerPath = loggerPath
|
|
36
|
-
PreviouseFilePath = loggerPath
|
|
35
|
+
loggerPath = "".concat(loggerPath, "/").concat(projectName, "/").concat((0, date_util_1.createLoggerDateFormat)(), "/output");
|
|
36
|
+
PreviouseFilePath = "".concat(loggerPath, "/").concat(projectName, "/").concat((0, date_util_1.createLoggerPreviouseDateFormat)(), "/");
|
|
37
37
|
}
|
|
38
38
|
else if (projectId) {
|
|
39
|
-
loggerPath = loggerPath
|
|
40
|
-
PreviouseFilePath = loggerPath
|
|
39
|
+
loggerPath = "".concat(loggerPath, "/").concat(projectId, "/").concat((0, date_util_1.createLoggerDateFormat)(), "/output");
|
|
40
|
+
PreviouseFilePath = "".concat(loggerPath, "/").concat(projectId, "/").concat((0, date_util_1.createLoggerPreviouseDateFormat)(), "/");
|
|
41
41
|
}
|
|
42
42
|
else {
|
|
43
|
-
loggerPath = loggerPath
|
|
44
|
-
PreviouseFilePath = loggerPath
|
|
43
|
+
loggerPath = "".concat(loggerPath, "/").concat((0, date_util_1.createLoggerDateFormat)(), "/output");
|
|
44
|
+
PreviouseFilePath = "".concat(loggerPath, "/").concat((0, date_util_1.createLoggerPreviouseDateFormat)(), "/");
|
|
45
45
|
}
|
|
46
46
|
if (fs_1.default.existsSync(PreviouseFilePath)) {
|
|
47
47
|
fs_1.default.rmSync(PreviouseFilePath, { recursive: true, force: true });
|
|
@@ -27,16 +27,16 @@ var interceptLoggerNew = function (req, res, next) {
|
|
|
27
27
|
}
|
|
28
28
|
var PreviouseFilePath;
|
|
29
29
|
if (projectName) {
|
|
30
|
-
loggerPath = loggerPath
|
|
31
|
-
PreviouseFilePath = loggerPath
|
|
30
|
+
loggerPath = "".concat(loggerPath, "/").concat(projectName, "/").concat((0, date_util_1.createLoggerDateFormat)(), "/output");
|
|
31
|
+
PreviouseFilePath = "".concat(loggerPath, "/").concat(projectName, "/").concat((0, date_util_1.createLoggerPreviouseDateFormat)(), "/");
|
|
32
32
|
}
|
|
33
33
|
else if (projectId) {
|
|
34
|
-
loggerPath = loggerPath
|
|
35
|
-
PreviouseFilePath = loggerPath
|
|
34
|
+
loggerPath = "".concat(loggerPath, "/").concat(projectId, "/").concat((0, date_util_1.createLoggerDateFormat)(), "/output");
|
|
35
|
+
PreviouseFilePath = "".concat(loggerPath, "/").concat(projectId, "/").concat((0, date_util_1.createLoggerPreviouseDateFormat)(), "/");
|
|
36
36
|
}
|
|
37
37
|
else {
|
|
38
|
-
loggerPath = loggerPath
|
|
39
|
-
PreviouseFilePath = loggerPath
|
|
38
|
+
loggerPath = "".concat(loggerPath, "/").concat((0, date_util_1.createLoggerDateFormat)(), "/output");
|
|
39
|
+
PreviouseFilePath = "".concat(loggerPath, "/").concat((0, date_util_1.createLoggerPreviouseDateFormat)(), "/");
|
|
40
40
|
}
|
|
41
41
|
if (fs_1.default.existsSync(PreviouseFilePath)) {
|
|
42
42
|
fs_1.default.rmSync(PreviouseFilePath, { recursive: true, force: true });
|
|
@@ -21,13 +21,13 @@ var interceptLogger = function (req, res, next) {
|
|
|
21
21
|
reqObject["dbName"] = db.name;
|
|
22
22
|
}
|
|
23
23
|
if (projectName) {
|
|
24
|
-
loggerPath = loggerPath
|
|
24
|
+
loggerPath = "".concat(loggerPath, "/").concat(projectName, "/").concat((0, date_util_1.createLoggerDateFormat)());
|
|
25
25
|
}
|
|
26
26
|
else if (projectId) {
|
|
27
|
-
loggerPath = loggerPath
|
|
27
|
+
loggerPath = "".concat(loggerPath, "/").concat(projectId, "/").concat((0, date_util_1.createLoggerDateFormat)());
|
|
28
28
|
}
|
|
29
29
|
else {
|
|
30
|
-
loggerPath = loggerPath
|
|
30
|
+
loggerPath = "".concat(loggerPath, "/").concat((0, date_util_1.createLoggerDateFormat)());
|
|
31
31
|
}
|
|
32
32
|
var logger = new drapcode_logger_1.FileLogger(loggerPath).createLogger();
|
|
33
33
|
var oldSend = res.send;
|
|
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
18
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
19
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
20
|
switch (op[0]) {
|
|
@@ -47,7 +47,7 @@ var saveRequest = function (req, res) {
|
|
|
47
47
|
return __generator(this, function (_a) {
|
|
48
48
|
switch (_a.label) {
|
|
49
49
|
case 0:
|
|
50
|
-
req.body = util_1.isEmpty(req.body) ? req.query : req.body;
|
|
50
|
+
req.body = (0, util_1.isEmpty)(req.body) ? req.query : req.body;
|
|
51
51
|
ip = req.headers["x-forwarded-for"] ||
|
|
52
52
|
req.connection.remoteAddress ||
|
|
53
53
|
req.socket.remoteAddress ||
|
|
@@ -62,13 +62,13 @@ var saveRequest = function (req, res) {
|
|
|
62
62
|
response: JSON.stringify(res),
|
|
63
63
|
ipAddress: ip,
|
|
64
64
|
};
|
|
65
|
-
return [4 /*yield*/, drapcode_redis_1.redis_get_method("requestLog")];
|
|
65
|
+
return [4 /*yield*/, (0, drapcode_redis_1.redis_get_method)("requestLog")];
|
|
66
66
|
case 1:
|
|
67
67
|
redisData = _a.sent();
|
|
68
68
|
if (!redisData)
|
|
69
69
|
redisData = [];
|
|
70
70
|
redisData.push(respObj);
|
|
71
|
-
return [4 /*yield*/, drapcode_redis_1.redis_set_method("requestLog", redisData)];
|
|
71
|
+
return [4 /*yield*/, (0, drapcode_redis_1.redis_set_method)("requestLog", redisData)];
|
|
72
72
|
case 2:
|
|
73
73
|
_a.sent();
|
|
74
74
|
return [2 /*return*/];
|
|
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
18
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
19
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
20
|
switch (op[0]) {
|
|
@@ -35,10 +35,14 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
39
|
-
for (var i = 0,
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
39
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
40
|
+
if (ar || !(i in from)) {
|
|
41
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
42
|
+
ar[i] = from[i];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
42
46
|
};
|
|
43
47
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
44
48
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
@@ -114,7 +118,7 @@ var handleMultErrorConfig = function (error, result, status) {
|
|
|
114
118
|
var apiErrorMessage;
|
|
115
119
|
var apiErrorValue;
|
|
116
120
|
if (result && result !== "undefined" && result !== "null") {
|
|
117
|
-
console.log("handleMultErrorConfig result :>> "
|
|
121
|
+
console.log("handleMultErrorConfig result :>> ".concat(Object.keys(result)));
|
|
118
122
|
apiErrorMessage = lodash_1.default.get(result, message);
|
|
119
123
|
if (apiErrorMessage) {
|
|
120
124
|
console.log("*** utility 3 ***");
|
|
@@ -144,7 +148,7 @@ var handleMultErrorConfig = function (error, result, status) {
|
|
|
144
148
|
apiErrorValue = status;
|
|
145
149
|
}
|
|
146
150
|
console.log("apiErrorValue", apiErrorValue);
|
|
147
|
-
apiErrorValue = ""
|
|
151
|
+
apiErrorValue = "".concat(apiErrorValue);
|
|
148
152
|
console.log("apiErrorMessage", apiErrorMessage);
|
|
149
153
|
console.log("apiErrorValue", apiErrorValue);
|
|
150
154
|
if (value && apiErrorValue == value) {
|
|
@@ -181,7 +185,7 @@ var nestedValue = function (data, messages) {
|
|
|
181
185
|
messages.push(value);
|
|
182
186
|
}
|
|
183
187
|
else if (Array.isArray(value)) {
|
|
184
|
-
messages = __spreadArray(__spreadArray([], messages), value);
|
|
188
|
+
messages = __spreadArray(__spreadArray([], messages, true), value, true);
|
|
185
189
|
}
|
|
186
190
|
else {
|
|
187
191
|
if (Object.keys(value).length) {
|
package/build/utils/date-util.js
CHANGED
|
@@ -29,11 +29,11 @@ exports.createLogsDateFormat = createLogsDateFormat;
|
|
|
29
29
|
var getDateValue = function (value, timezone) {
|
|
30
30
|
if (timezone === void 0) { timezone = ""; }
|
|
31
31
|
if (!value)
|
|
32
|
-
return exports.createLogsDateFormat(timezone);
|
|
32
|
+
return (0, exports.createLogsDateFormat)(timezone);
|
|
33
33
|
var dateFormat = "YYYY-MM-DDTHH:mm:ss.SSS";
|
|
34
34
|
var _a = value.split(":"), type = _a[0], number = _a[1], unit = _a[2];
|
|
35
35
|
if (!["ADD", "SUB"].includes(type))
|
|
36
|
-
return exports.createLogsDateFormat(timezone);
|
|
36
|
+
return (0, exports.createLogsDateFormat)(timezone);
|
|
37
37
|
var dateUnit = getDateUnit(unit);
|
|
38
38
|
var result;
|
|
39
39
|
if (type === "ADD") {
|
|
@@ -80,7 +80,7 @@ var timezoneDateParse = function (value, nextDay, prevDay) {
|
|
|
80
80
|
if (prevDay && value.length <= 10) {
|
|
81
81
|
timeZoneDate = timeZoneDate.subtract(1, "days");
|
|
82
82
|
}
|
|
83
|
-
console.log("If it was for end date "
|
|
83
|
+
console.log("If it was for end date ".concat(nextDay, " then"), timeZoneDate);
|
|
84
84
|
timeZoneDate = timeZoneDate.format("YYYY-MM-DDTHH:mm:ss");
|
|
85
85
|
console.log("Format Date into date string", timeZoneDate);
|
|
86
86
|
return new Date(timeZoneDate);
|