drapcode-utility 2.7.3 → 2.7.4-sandbox.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/build/aws/aws-util.d.ts +6 -0
- package/build/aws/aws-util.d.ts.map +1 -0
- package/build/aws/aws-util.js +34 -0
- package/build/aws/aws-util.js.map +1 -0
- package/build/aws/encryption/KMS.d.ts +9 -0
- package/build/aws/encryption/KMS.d.ts.map +1 -0
- package/build/aws/encryption/KMS.js +65 -0
- package/build/aws/encryption/KMS.js.map +1 -0
- package/build/{encryption → aws/encryption}/crypt.d.ts +1 -0
- package/build/aws/encryption/crypt.d.ts.map +1 -0
- package/build/{encryption → aws/encryption}/crypt.js +25 -36
- package/build/aws/encryption/crypt.js.map +1 -0
- package/build/{encryption → aws/encryption}/file.d.ts +2 -1
- package/build/aws/encryption/file.d.ts.map +1 -0
- package/build/{encryption → aws/encryption}/file.js +2 -3
- package/build/aws/encryption/file.js.map +1 -0
- package/build/{encryption → aws/encryption}/index.d.ts +4 -3
- package/build/aws/encryption/index.d.ts.map +1 -0
- package/build/{encryption → aws/encryption}/index.js +41 -41
- package/build/aws/encryption/index.js.map +1 -0
- package/build/{encryption → aws/encryption}/utility.d.ts +1 -0
- package/build/aws/encryption/utility.d.ts.map +1 -0
- package/build/{encryption → aws/encryption}/utility.js +3 -2
- package/build/aws/encryption/utility.js.map +1 -0
- package/build/aws/model.d.ts +30 -0
- package/build/aws/model.d.ts.map +1 -0
- package/build/{encryption → aws}/model.js +1 -0
- package/build/aws/model.js.map +1 -0
- package/build/aws/s3-util.d.ts +36 -0
- package/build/aws/s3-util.d.ts.map +1 -0
- package/build/aws/s3-util.js +198 -0
- package/build/aws/s3-util.js.map +1 -0
- package/build/errors/app-error.d.ts +17 -4
- package/build/errors/app-error.d.ts.map +1 -0
- package/build/errors/app-error.js +184 -6
- package/build/errors/app-error.js.map +1 -0
- package/build/errors/async-handler.d.ts +3 -0
- package/build/errors/async-handler.d.ts.map +1 -0
- package/build/errors/async-handler.js +9 -0
- package/build/errors/async-handler.js.map +1 -0
- package/build/errors/axios-error.d.ts +2 -1
- package/build/errors/axios-error.d.ts.map +1 -0
- package/build/errors/axios-error.js +12 -8
- package/build/errors/axios-error.js.map +1 -0
- package/build/errors/bad-request-error.d.ts +2 -1
- package/build/errors/bad-request-error.d.ts.map +1 -0
- package/build/errors/bad-request-error.js +1 -0
- package/build/errors/bad-request-error.js.map +1 -0
- package/build/errors/custom-error.d.ts +1 -0
- package/build/errors/custom-error.d.ts.map +1 -0
- package/build/errors/custom-error.js +1 -0
- package/build/errors/custom-error.js.map +1 -0
- package/build/errors/error-classes.d.ts +23 -0
- package/build/errors/error-classes.d.ts.map +1 -0
- package/build/errors/error-classes.js +87 -0
- package/build/errors/error-classes.js.map +1 -0
- package/build/errors/error-codes.d.ts +47 -0
- package/build/errors/error-codes.d.ts.map +1 -0
- package/build/errors/error-codes.js +78 -0
- package/build/errors/error-codes.js.map +1 -0
- package/build/errors/error-obj.d.ts +10 -0
- package/build/errors/error-obj.d.ts.map +1 -0
- package/build/errors/error-obj.js +55 -0
- package/build/errors/error-obj.js.map +1 -0
- package/build/errors/get-error-details.d.ts +11 -0
- package/build/errors/get-error-details.d.ts.map +1 -0
- package/build/errors/get-error-details.js +28 -0
- package/build/errors/get-error-details.js.map +1 -0
- package/build/errors/not-found.d.ts +2 -1
- package/build/errors/not-found.d.ts.map +1 -0
- package/build/errors/not-found.js +3 -2
- package/build/errors/not-found.js.map +1 -0
- package/build/errors/wrap-error.d.ts +9 -0
- package/build/errors/wrap-error.d.ts.map +1 -0
- package/build/errors/wrap-error.js +17 -0
- package/build/errors/wrap-error.js.map +1 -0
- package/build/format-fields/index.d.ts +1 -0
- package/build/format-fields/index.d.ts.map +1 -0
- package/build/format-fields/index.js +13 -13
- package/build/format-fields/index.js.map +1 -0
- package/build/index.d.ts +25 -21
- package/build/index.d.ts.map +1 -0
- package/build/index.js +13 -7
- package/build/index.js.map +1 -0
- package/build/middlewares/redis/request-log.d.ts +1 -0
- package/build/middlewares/redis/request-log.d.ts.map +1 -0
- package/build/middlewares/redis/request-log.js +3 -2
- package/build/middlewares/redis/request-log.js.map +1 -0
- package/build/query/queryBuilder.d.ts +1 -0
- package/build/query/queryBuilder.d.ts.map +1 -0
- package/build/query/queryBuilder.js +66 -129
- package/build/query/queryBuilder.js.map +1 -0
- package/build/utils/check-error.d.ts +1 -0
- package/build/utils/check-error.d.ts.map +1 -0
- package/build/utils/check-error.js +14 -15
- package/build/utils/check-error.js.map +1 -0
- package/build/utils/common-util.d.ts +2 -1
- package/build/utils/common-util.d.ts.map +1 -0
- package/build/utils/common-util.js +46 -47
- package/build/utils/common-util.js.map +1 -0
- package/build/utils/date-util.d.ts +1 -0
- package/build/utils/date-util.d.ts.map +1 -0
- package/build/utils/date-util.js +59 -60
- package/build/utils/date-util.js.map +1 -0
- package/build/utils/file-util.d.ts +9 -0
- package/build/utils/file-util.d.ts.map +1 -0
- package/build/utils/file-util.js +120 -9
- package/build/utils/file-util.js.map +1 -0
- package/build/utils/prepare-query.d.ts +1 -0
- package/build/utils/prepare-query.d.ts.map +1 -0
- package/build/utils/prepare-query.js +15 -17
- package/build/utils/prepare-query.js.map +1 -0
- package/build/utils/project-util.d.ts +2 -1
- package/build/utils/project-util.d.ts.map +1 -0
- package/build/utils/project-util.js +45 -50
- package/build/utils/project-util.js.map +1 -0
- package/build/utils/query-parser.d.ts +1 -1
- package/build/utils/query-parser.d.ts.map +1 -0
- package/build/utils/query-parser.js +6 -568
- package/build/utils/query-parser.js.map +1 -0
- package/build/utils/query-utils.d.ts +1 -0
- package/build/utils/query-utils.d.ts.map +1 -0
- package/build/utils/query-utils.js +46 -50
- package/build/utils/query-utils.js.map +1 -0
- package/build/utils/rest-client.d.ts +1 -0
- package/build/utils/rest-client.d.ts.map +1 -0
- package/build/utils/rest-client.js +88 -122
- package/build/utils/rest-client.js.map +1 -0
- package/build/utils/token.d.ts +1 -0
- package/build/utils/token.d.ts.map +1 -0
- package/build/utils/token.js +4 -3
- package/build/utils/token.js.map +1 -0
- package/build/utils/util.d.ts +2 -1
- package/build/utils/util.d.ts.map +1 -0
- package/build/utils/util.js +340 -392
- package/build/utils/util.js.map +1 -0
- package/build/utils/uuid-generator.d.ts +1 -0
- package/build/utils/uuid-generator.d.ts.map +1 -0
- package/build/utils/uuid-generator.js +9 -8
- package/build/utils/uuid-generator.js.map +1 -0
- package/package.json +7 -6
- package/build/encryption/KMS.d.ts +0 -8
- package/build/encryption/KMS.js +0 -67
- package/build/encryption/model.d.ts +0 -17
- package/build/middlewares/error-logger.d.ts +0 -3
- package/build/middlewares/error-logger.js +0 -74
- package/build/utils/s3-util.d.ts +0 -36
- package/build/utils/s3-util.js +0 -275
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { S3Client } from '@aws-sdk/client-s3';
|
|
2
|
+
import { KMSClient } from '@aws-sdk/client-kms';
|
|
3
|
+
import { AWSConfig } from './model';
|
|
4
|
+
export declare const createS3Client: (awsConfig: AWSConfig) => S3Client | null;
|
|
5
|
+
export declare const createKMSClient: (awsConfig: AWSConfig, maxAttempts?: number) => KMSClient | null;
|
|
6
|
+
//# sourceMappingURL=aws-util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aws-util.d.ts","sourceRoot":"","sources":["../../src/aws/aws-util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC,eAAO,MAAM,cAAc,GAAI,WAAW,SAAS,oBAalD,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,WAAW,SAAS,EAAE,oBAAe,qBAWpE,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createKMSClient = exports.createS3Client = void 0;
|
|
4
|
+
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
5
|
+
const client_kms_1 = require("@aws-sdk/client-kms");
|
|
6
|
+
const createS3Client = (awsConfig) => {
|
|
7
|
+
if (!awsConfig) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
const { region, accessKeyId, secretAccessKey } = awsConfig;
|
|
11
|
+
const s3client = new client_s3_1.S3Client({
|
|
12
|
+
region,
|
|
13
|
+
credentials: {
|
|
14
|
+
accessKeyId: accessKeyId,
|
|
15
|
+
secretAccessKey: secretAccessKey,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
return s3client;
|
|
19
|
+
};
|
|
20
|
+
exports.createS3Client = createS3Client;
|
|
21
|
+
const createKMSClient = (awsConfig, maxAttempts = 1) => {
|
|
22
|
+
if (!awsConfig) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
const { accessKeyId, secretAccessKey, region } = awsConfig;
|
|
26
|
+
const client = new client_kms_1.KMSClient({
|
|
27
|
+
region,
|
|
28
|
+
credentials: { accessKeyId, secretAccessKey },
|
|
29
|
+
maxAttempts,
|
|
30
|
+
});
|
|
31
|
+
return client;
|
|
32
|
+
};
|
|
33
|
+
exports.createKMSClient = createKMSClient;
|
|
34
|
+
//# sourceMappingURL=aws-util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aws-util.js","sourceRoot":"","sources":["../../src/aws/aws-util.ts"],"names":[],"mappings":";;;AAAA,kDAA8C;AAC9C,oDAAgD;AAGzC,MAAM,cAAc,GAAG,CAAC,SAAoB,EAAE,EAAE;IACrD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,eAAe,EAAE,GAAG,SAAS,CAAC;IAC3D,MAAM,QAAQ,GAAG,IAAI,oBAAQ,CAAC;QAC5B,MAAM;QACN,WAAW,EAAE;YACX,WAAW,EAAE,WAAW;YACxB,eAAe,EAAE,eAAe;SACjC;KACF,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAbW,QAAA,cAAc,kBAazB;AAEK,MAAM,eAAe,GAAG,CAAC,SAAoB,EAAE,WAAW,GAAG,CAAC,EAAE,EAAE;IACvE,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAC3D,MAAM,MAAM,GAAG,IAAI,sBAAS,CAAC;QAC3B,MAAM;QACN,WAAW,EAAE,EAAE,WAAW,EAAE,eAAe,EAAE;QAC7C,WAAW;KACZ,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAXW,QAAA,eAAe,mBAW1B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DecryptResponse, Encryption, AWSConfig } from '../model';
|
|
2
|
+
export declare const processKey: (encryption: Encryption, encryptionType: string) => Promise<string>;
|
|
3
|
+
export declare const processKMSDecryption: (config: AWSConfig, cipherText: string) => Promise<DecryptResponse>;
|
|
4
|
+
export declare const processKMSGenerateDataKey: (config: AWSConfig, arn: string) => Promise<{
|
|
5
|
+
status: string;
|
|
6
|
+
dataKey: string;
|
|
7
|
+
message: string;
|
|
8
|
+
}>;
|
|
9
|
+
//# sourceMappingURL=KMS.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KMS.d.ts","sourceRoot":"","sources":["../../../src/aws/encryption/KMS.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAGlE,eAAO,MAAM,UAAU,GACrB,YAAY,UAAU,EACtB,gBAAgB,MAAM,KACrB,OAAO,CAAC,MAAM,CAYhB,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,SAAS,EACjB,YAAY,MAAM,KACjB,OAAO,CAAC,eAAe,CAqBzB,CAAC;AAEF,eAAO,MAAM,yBAAyB,GAAU,QAAQ,SAAS,EAAE,KAAK,MAAM;;;;EAsB7E,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.processKMSGenerateDataKey = exports.processKMSDecryption = exports.processKey = void 0;
|
|
4
|
+
const client_kms_1 = require("@aws-sdk/client-kms");
|
|
5
|
+
const aws_util_1 = require("../aws-util");
|
|
6
|
+
const processKey = async (encryption, encryptionType) => {
|
|
7
|
+
if (encryptionType !== 'KMS') {
|
|
8
|
+
return '';
|
|
9
|
+
}
|
|
10
|
+
const plainTextData = await (0, exports.processKMSDecryption)(encryption.awsConfig, encryption.dataKey);
|
|
11
|
+
if (plainTextData.status === 'SUCCESS') {
|
|
12
|
+
return plainTextData.data;
|
|
13
|
+
// return { ...encryption, dataKey: plainTextData.data };
|
|
14
|
+
}
|
|
15
|
+
return '';
|
|
16
|
+
};
|
|
17
|
+
exports.processKey = processKey;
|
|
18
|
+
const processKMSDecryption = async (config, cipherText) => {
|
|
19
|
+
try {
|
|
20
|
+
const client = (0, aws_util_1.createKMSClient)(config, 3);
|
|
21
|
+
if (!client)
|
|
22
|
+
throw new Error('Invalid or missing info');
|
|
23
|
+
const dCipherText = Buffer.from(cipherText, 'base64');
|
|
24
|
+
const input = {
|
|
25
|
+
CiphertextBlob: dCipherText,
|
|
26
|
+
EncryptionContext: {},
|
|
27
|
+
};
|
|
28
|
+
const command = new client_kms_1.DecryptCommand(input);
|
|
29
|
+
const response = await client.send(command);
|
|
30
|
+
if (!response.Plaintext) {
|
|
31
|
+
throw new Error('Missing plaintext in KMS response.');
|
|
32
|
+
}
|
|
33
|
+
const plainText = Buffer.from(response.Plaintext).toString('base64');
|
|
34
|
+
return { status: 'SUCCESS', data: plainText, message: '' };
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
return { status: 'FAILED', data: '', message: error.message };
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
exports.processKMSDecryption = processKMSDecryption;
|
|
41
|
+
const processKMSGenerateDataKey = async (config, arn) => {
|
|
42
|
+
try {
|
|
43
|
+
const input = {
|
|
44
|
+
KeyId: arn,
|
|
45
|
+
KeySpec: 'AES_256',
|
|
46
|
+
};
|
|
47
|
+
const client = (0, aws_util_1.createKMSClient)(config);
|
|
48
|
+
if (!client)
|
|
49
|
+
throw new Error('Invalid or missing info');
|
|
50
|
+
const command = new client_kms_1.GenerateDataKeyCommand(input);
|
|
51
|
+
const response = await client.send(command);
|
|
52
|
+
//@ts-expect-error it is important else it will throw error
|
|
53
|
+
const cipherText = Buffer.from(response.CiphertextBlob).toString('base64');
|
|
54
|
+
return { status: 'SUCCESS', dataKey: cipherText, message: '' };
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
return {
|
|
58
|
+
status: 'FAILED',
|
|
59
|
+
message: error.message,
|
|
60
|
+
dataKey: '',
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
exports.processKMSGenerateDataKey = processKMSGenerateDataKey;
|
|
65
|
+
//# sourceMappingURL=KMS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KMS.js","sourceRoot":"","sources":["../../../src/aws/encryption/KMS.ts"],"names":[],"mappings":";;;AAAA,oDAI6B;AAE7B,0CAA8C;AAEvC,MAAM,UAAU,GAAG,KAAK,EAC7B,UAAsB,EACtB,cAAsB,EACL,EAAE;IACnB,IAAI,cAAc,KAAK,KAAK,EAAE,CAAC;QAC7B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,aAAa,GAAG,MAAM,IAAA,4BAAoB,EAAC,UAAU,CAAC,SAAS,EAAE,UAAU,CAAC,OAA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AAC,CAAC;AAxBW,QAAA,oBAAoB,wBAwB/B;AAEK,MAAM,yBAAyB,GAAG,KAAK,EAAE,MAAiB,EAAE,GAAW,EAAE,EAAE;IAChF,IAAI,CAAC;QACH,MAAM,KAAK,GAAgC;YACzC,KAAK,EAAE,GAAG;YACV,OAAO,EAAE,SAAS;SACnB,CAAC;QACF,MAAM,MAAM,GAAG,IAAA,0BAAe,EAAC,MAAM,CAAC,CAAC;QACvC,IAAI,CAAC,MAAM;YAAE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAExD,MAAM,OAAO,GAAG,IAAI,mCAAsB,CAAC,KAAK,CAAC,CAAC;QAClD,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAE5C,2DAA2D;QAC3D,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAC3E,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACjE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,MAAM,EAAE,QAAQ;YAChB,OAAO,EAAG,KAAe,CAAC,OAAO;YACjC,OAAO,EAAE,EAAE;SACZ,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAtBW,QAAA,yBAAyB,6BAsBpC"}
|
|
@@ -2,3 +2,4 @@ export declare const encryptData: (data: string, key: string, iv?: string) => st
|
|
|
2
2
|
export declare const decryptData: (data: string, key: string, iv?: string) => string;
|
|
3
3
|
export declare const encryptFile: (filePath: string, key: string, iv: string) => Promise<string>;
|
|
4
4
|
export declare const decryptFile: (encryptedFilePath: string, key: string, iv: string) => Promise<string>;
|
|
5
|
+
//# sourceMappingURL=crypt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypt.d.ts","sourceRoot":"","sources":["../../../src/aws/encryption/crypt.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,WAAW,GAAI,MAAM,MAAM,EAAE,KAAK,MAAM,EAAE,KAAK,MAAM,KAAG,MAUpE,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,MAAM,MAAM,EAAE,KAAK,MAAM,EAAE,KAAK,MAAM,KAAG,MAYpE,CAAC;AAEF,eAAO,MAAM,WAAW,GAAU,UAAU,MAAM,EAAE,KAAK,MAAM,EAAE,IAAI,MAAM,KAAG,OAAO,CAAC,MAAM,CA0B3F,CAAC;AAEF,eAAO,MAAM,WAAW,GACtB,mBAAmB,MAAM,EACzB,KAAK,MAAM,EACX,IAAI,MAAM,KACT,OAAO,CAAC,MAAM,CA+BhB,CAAC"}
|
|
@@ -6,44 +6,38 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.decryptFile = exports.encryptFile = exports.decryptData = exports.encryptData = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const crypto_1 = __importDefault(require("crypto"));
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
9
|
+
const drapcode_logger_1 = require("drapcode-logger");
|
|
10
|
+
const defaultAlgorithm = 'aes-256-cbc';
|
|
11
|
+
const fixedIv = 'i4mboZDwaNEC38YCzi77lw==';
|
|
12
|
+
const toBuffer = (base64) => Buffer.from(base64, 'base64');
|
|
12
13
|
const createCipher = (key, iv) => crypto_1.default.createCipheriv(defaultAlgorithm, toBuffer(key), toBuffer(iv));
|
|
13
14
|
const createDecipher = (key, iv) => crypto_1.default.createDecipheriv(defaultAlgorithm, toBuffer(key), toBuffer(iv));
|
|
14
15
|
const encryptData = (data, key, iv) => {
|
|
15
16
|
try {
|
|
16
|
-
console.log("encryptData: key :>> ", key);
|
|
17
|
-
console.log("encryptData: iv :>> ", iv);
|
|
18
17
|
if (!iv)
|
|
19
18
|
iv = fixedIv;
|
|
20
19
|
const cipher = createCipher(key, iv);
|
|
21
20
|
const encrypted = Buffer.concat([cipher.update(`${data}`), cipher.final()]);
|
|
22
|
-
return handleExtraString(encrypted.toString(
|
|
21
|
+
return handleExtraString(encrypted.toString('base64'), true);
|
|
23
22
|
}
|
|
24
23
|
catch (error) {
|
|
25
|
-
|
|
24
|
+
drapcode_logger_1.logger.error(error);
|
|
26
25
|
return data;
|
|
27
26
|
}
|
|
28
27
|
};
|
|
29
28
|
exports.encryptData = encryptData;
|
|
30
29
|
const decryptData = (data, key, iv) => {
|
|
31
30
|
try {
|
|
32
|
-
console.log("decryptData: key :>> ", key);
|
|
33
|
-
console.log("decryptData: iv :>> ", iv);
|
|
34
31
|
const cleaned = handleExtraString(data, false);
|
|
35
32
|
const encryptedData = toBuffer(cleaned);
|
|
36
33
|
if (!iv)
|
|
37
34
|
iv = fixedIv;
|
|
38
35
|
const decipher = createDecipher(key, iv);
|
|
39
|
-
const decrypted = Buffer.concat([
|
|
40
|
-
decipher.update(encryptedData),
|
|
41
|
-
decipher.final(),
|
|
42
|
-
]);
|
|
36
|
+
const decrypted = Buffer.concat([decipher.update(encryptedData), decipher.final()]);
|
|
43
37
|
return decrypted.toString();
|
|
44
38
|
}
|
|
45
39
|
catch (error) {
|
|
46
|
-
|
|
40
|
+
drapcode_logger_1.logger.error(error);
|
|
47
41
|
return data;
|
|
48
42
|
}
|
|
49
43
|
};
|
|
@@ -51,30 +45,26 @@ exports.decryptData = decryptData;
|
|
|
51
45
|
const encryptFile = async (filePath, key, iv) => {
|
|
52
46
|
return new Promise((resolve, reject) => {
|
|
53
47
|
try {
|
|
54
|
-
console.log("encryptFile: key :>> ", key);
|
|
55
|
-
console.log("encryptFile: iv :>> ", iv);
|
|
56
48
|
if (!iv)
|
|
57
49
|
iv = fixedIv;
|
|
58
50
|
const cipher = createCipher(key, iv);
|
|
59
|
-
const encryptedFilePath = filePath.endsWith(
|
|
60
|
-
? filePath
|
|
61
|
-
: `${filePath}.enc`;
|
|
51
|
+
const encryptedFilePath = filePath.endsWith('.enc') ? filePath : `${filePath}.enc`;
|
|
62
52
|
const readStream = fs_1.default.createReadStream(filePath);
|
|
63
53
|
const writeStream = fs_1.default.createWriteStream(encryptedFilePath);
|
|
64
54
|
readStream
|
|
65
55
|
.pipe(cipher)
|
|
66
56
|
.pipe(writeStream)
|
|
67
|
-
.on(
|
|
68
|
-
|
|
57
|
+
.on('finish', () => {
|
|
58
|
+
drapcode_logger_1.logger.info('File encrypted successfully (stream).');
|
|
69
59
|
resolve(encryptedFilePath);
|
|
70
60
|
})
|
|
71
|
-
.on(
|
|
72
|
-
|
|
61
|
+
.on('error', (err) => {
|
|
62
|
+
drapcode_logger_1.logger.error(`encryptFileStream error: ${err}`);
|
|
73
63
|
reject(err);
|
|
74
64
|
});
|
|
75
65
|
}
|
|
76
66
|
catch (error) {
|
|
77
|
-
|
|
67
|
+
drapcode_logger_1.logger.error(`encryptFile error: ${error}`);
|
|
78
68
|
reject(error);
|
|
79
69
|
}
|
|
80
70
|
});
|
|
@@ -83,44 +73,43 @@ exports.encryptFile = encryptFile;
|
|
|
83
73
|
const decryptFile = async (encryptedFilePath, key, iv) => {
|
|
84
74
|
return new Promise((resolve, reject) => {
|
|
85
75
|
try {
|
|
86
|
-
console.log("decryptFile: key :>> ", key);
|
|
87
|
-
console.log("decryptFile: iv :>> ", iv);
|
|
88
76
|
if (!iv)
|
|
89
77
|
iv = fixedIv;
|
|
90
78
|
const decipher = createDecipher(key, iv);
|
|
91
79
|
const readStream = fs_1.default.createReadStream(encryptedFilePath);
|
|
92
|
-
const decryptedFilePath = encryptedFilePath.endsWith(
|
|
80
|
+
const decryptedFilePath = encryptedFilePath.endsWith('.enc')
|
|
93
81
|
? `${encryptedFilePath.slice(0, -4)}.dec`
|
|
94
82
|
: `${encryptedFilePath}.dec`;
|
|
95
83
|
const writeStream = fs_1.default.createWriteStream(decryptedFilePath);
|
|
96
84
|
readStream
|
|
97
85
|
.pipe(decipher)
|
|
98
86
|
.pipe(writeStream)
|
|
99
|
-
.on(
|
|
100
|
-
|
|
87
|
+
.on('finish', () => {
|
|
88
|
+
drapcode_logger_1.logger.info('File decrypted successfully (stream).');
|
|
101
89
|
resolve(decryptedFilePath);
|
|
102
90
|
})
|
|
103
|
-
.on(
|
|
104
|
-
|
|
91
|
+
.on('error', (err) => {
|
|
92
|
+
drapcode_logger_1.logger.error(`decryptFileStream error: ${err}`);
|
|
105
93
|
reject(err);
|
|
106
94
|
});
|
|
107
|
-
|
|
95
|
+
drapcode_logger_1.logger.info('File decrypted successfully.');
|
|
108
96
|
return decryptedFilePath;
|
|
109
97
|
}
|
|
110
98
|
catch (error) {
|
|
111
|
-
|
|
99
|
+
drapcode_logger_1.logger.error(`decryptFile error: ${error}`);
|
|
112
100
|
reject(error);
|
|
113
101
|
}
|
|
114
102
|
});
|
|
115
103
|
};
|
|
116
104
|
exports.decryptFile = decryptFile;
|
|
117
105
|
const handleExtraString = (key, append = true) => {
|
|
118
|
-
if (!key || key ===
|
|
106
|
+
if (!key || key === 'undefined' || typeof key === 'undefined')
|
|
119
107
|
return key;
|
|
120
108
|
if (append) {
|
|
121
|
-
const prefix = crypto_1.default.randomBytes(2).toString(
|
|
122
|
-
const suffix = crypto_1.default.randomBytes(2).toString(
|
|
109
|
+
const prefix = crypto_1.default.randomBytes(2).toString('hex');
|
|
110
|
+
const suffix = crypto_1.default.randomBytes(2).toString('hex');
|
|
123
111
|
return `${prefix}${key}${suffix}`;
|
|
124
112
|
}
|
|
125
113
|
return key.substring(4, key.length - 4);
|
|
126
114
|
};
|
|
115
|
+
//# sourceMappingURL=crypt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypt.js","sourceRoot":"","sources":["../../../src/aws/encryption/crypt.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,oDAA4B;AAC5B,qDAAyC;AACzC,MAAM,gBAAgB,GAAG,aAAa,CAAC;AAEvC,MAAM,OAAO,GAAG,0BAA0B,C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|
|
1
|
+
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../../src/aws/encryption/file.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,eAAO,MAAM,+BAA+B,GAC1C,MAAM,MAAM,EACZ,YAAY,UAAU,EACtB,SAAS,OAAO,oBAMjB,CAAC"}
|
|
@@ -6,8 +6,7 @@ const processFileEncryptionDecryption = async (data, encryption, decrypt) => {
|
|
|
6
6
|
const { dataKey, iv } = encryption;
|
|
7
7
|
if (!data)
|
|
8
8
|
return data;
|
|
9
|
-
return decrypt
|
|
10
|
-
? await (0, crypt_1.decryptFile)(data, dataKey, iv)
|
|
11
|
-
: await (0, crypt_1.encryptFile)(data, dataKey, iv);
|
|
9
|
+
return decrypt ? await (0, crypt_1.decryptFile)(data, dataKey, iv) : await (0, crypt_1.encryptFile)(data, dataKey, iv);
|
|
12
10
|
};
|
|
13
11
|
exports.processFileEncryptionDecryption = processFileEncryptionDecryption;
|
|
12
|
+
//# sourceMappingURL=file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.js","sourceRoot":"","sources":["../../../src/aws/encryption/file.ts"],"names":[],"mappings":";;;AAAA,mCAAmD;AAG5C,MAAM,+BAA+B,GAAG,KAAK,EAClD,IAAY,EACZ,UAAsB,EACtB,OAAgB,EAChB,EAAE;IACF,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,UAAU,CAAC;IACnC,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IAEvB,OAAO,OAAO,CAAC,CAAC,CAAC,MAAM,IAAA,mBAAW,EAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,IAAA,mBAAW,EAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;AAC/F,CAAC,CAAC;AATW,QAAA,+BAA+B,mCAS1C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AWSConfig, Encryption } from '../model';
|
|
2
2
|
export declare const crypt: (data: any, fields: Array<object>, encryption: Encryption, decrypt: boolean, encryptedRefCollections?: Array<object>) => Promise<any>;
|
|
3
3
|
export declare const processItemEncryptDecrypt: (item: any, fields: Array<object>, encryption: Encryption, decrypt: boolean, encryptedRefCollections?: Array<object>) => Promise<any>;
|
|
4
4
|
export declare const processDataEncryptionDecryption: (data: string, encryption: Encryption, decrypt: boolean) => Promise<string>;
|
|
@@ -9,10 +9,11 @@ export declare const processDataEncryptionDecryption: (data: string, encryption:
|
|
|
9
9
|
* @param arn KMS Key
|
|
10
10
|
* @returns {status: string, dataKey: string, message: ""}
|
|
11
11
|
*/
|
|
12
|
-
export declare const createKMSDataKey: (config:
|
|
12
|
+
export declare const createKMSDataKey: (config: AWSConfig, arn: string) => Promise<{
|
|
13
13
|
status: string;
|
|
14
14
|
dataKey: string;
|
|
15
15
|
message: string;
|
|
16
16
|
}>;
|
|
17
|
-
export declare const drapcodeEncryptDecrypt: (data: string, encrypt: boolean) => Promise<import("
|
|
17
|
+
export declare const drapcodeEncryptDecrypt: (data: string, encrypt: boolean) => Promise<import("../model").DecryptResponse>;
|
|
18
18
|
export declare const cryptFile: (filePath: any, encryption: Encryption, decrypt: boolean) => Promise<string>;
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/aws/encryption/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAkCjD,eAAO,MAAM,KAAK,GAChB,MAAM,GAAG,EACT,QAAQ,KAAK,CAAC,MAAM,CAAC,EACrB,YAAY,UAAU,EACtB,SAAS,OAAO,EAChB,0BAAyB,KAAK,CAAC,MAAM,CAAM,iBAiB5C,CAAC;AAEF,eAAO,MAAM,yBAAyB,GACpC,MAAM,GAAG,EACT,QAAQ,KAAK,CAAC,MAAM,CAAC,EACrB,YAAY,UAAU,EACtB,SAAS,OAAO,EAChB,0BAAyB,KAAK,CAAC,MAAM,CAAM,iBA0C5C,CAAC;AAEF,eAAO,MAAM,+BAA+B,GAC1C,MAAM,MAAM,EACZ,YAAY,UAAU,EACtB,SAAS,OAAO,oBAMjB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAAU,QAAQ,SAAS,EAAE,KAAK,MAAM;;;;EAGpE,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAU,MAAM,MAAM,EAAE,SAAS,OAAO,gDAwC1E,CAAC;AAEF,eAAO,MAAM,SAAS,GAAU,UAAU,GAAG,EAAE,YAAY,UAAU,EAAE,SAAS,OAAO,oBAGtF,CAAC"}
|
|
@@ -2,9 +2,30 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.cryptFile = exports.drapcodeEncryptDecrypt = exports.createKMSDataKey = exports.processDataEncryptionDecryption = exports.processItemEncryptDecrypt = exports.crypt = void 0;
|
|
4
4
|
const drapcode_constant_1 = require("drapcode-constant");
|
|
5
|
+
const drapcode_logger_1 = require("drapcode-logger");
|
|
5
6
|
const crypt_1 = require("./crypt");
|
|
6
7
|
const file_1 = require("./file");
|
|
7
8
|
const KMS_1 = require("./KMS");
|
|
9
|
+
const processReferenceItemDecrypt = async (data, encryption, decrypt, refField, encryptedRefCollections) => {
|
|
10
|
+
const { refCollection } = getEncryptedReferenceCollection(encryptedRefCollections, refField);
|
|
11
|
+
if (refCollection && Array.isArray(data)) {
|
|
12
|
+
const promises = data.map((item) => (0, exports.processItemEncryptDecrypt)(item, refCollection.fields, encryption, decrypt));
|
|
13
|
+
data = await Promise.all(promises);
|
|
14
|
+
}
|
|
15
|
+
return data;
|
|
16
|
+
};
|
|
17
|
+
const getEncryptedReferenceCollection = (encryptedRefCollections, refField) => {
|
|
18
|
+
const { collectionName: refCollectionName, collectionField: refCollectionFieldName } =
|
|
19
|
+
// eslint-disable-next-line no-unsafe-optional-chaining
|
|
20
|
+
refField?.refCollection;
|
|
21
|
+
let refCollection;
|
|
22
|
+
if (encryptedRefCollections.length) {
|
|
23
|
+
if (refCollectionName) {
|
|
24
|
+
refCollection = encryptedRefCollections.find((encColl) => encColl.collectionName === refCollectionName);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return { refCollectionName, refCollectionFieldName, refCollection };
|
|
28
|
+
};
|
|
8
29
|
const crypt = async (data, fields, encryption, decrypt, encryptedRefCollections = []) => {
|
|
9
30
|
if (Array.isArray(data)) {
|
|
10
31
|
const promises = data.map((item) => (0, exports.processItemEncryptDecrypt)(item, fields, encryption, decrypt, encryptedRefCollections));
|
|
@@ -17,7 +38,7 @@ const crypt = async (data, fields, encryption, decrypt, encryptedRefCollections
|
|
|
17
38
|
};
|
|
18
39
|
exports.crypt = crypt;
|
|
19
40
|
const processItemEncryptDecrypt = async (item, fields, encryption, decrypt, encryptedRefCollections = []) => {
|
|
20
|
-
if (!item && typeof item !==
|
|
41
|
+
if (!item && typeof item !== 'object') {
|
|
21
42
|
return item;
|
|
22
43
|
}
|
|
23
44
|
//TODO: Need to refactor
|
|
@@ -25,8 +46,7 @@ const processItemEncryptDecrypt = async (item, fields, encryption, decrypt, encr
|
|
|
25
46
|
for (const fieldName of Object.keys(item)) {
|
|
26
47
|
const field = fields.find((field) => field.fieldName === fieldName);
|
|
27
48
|
if (field && field.encrypted) {
|
|
28
|
-
if (Array.isArray(item[fieldName]) &&
|
|
29
|
-
drapcode_constant_1.OptionTypeFields.includes(field.type)) {
|
|
49
|
+
if (Array.isArray(item[fieldName]) && drapcode_constant_1.OptionTypeFields.includes(field.type)) {
|
|
30
50
|
const promises = item[fieldName].map((value) => (item[fieldName] = (0, exports.processDataEncryptionDecryption)(value, encryption, decrypt)));
|
|
31
51
|
item[fieldName] = await Promise.all(promises);
|
|
32
52
|
}
|
|
@@ -35,11 +55,11 @@ const processItemEncryptDecrypt = async (item, fields, encryption, decrypt, encr
|
|
|
35
55
|
}
|
|
36
56
|
}
|
|
37
57
|
if (decrypt && drapcode_constant_1.BelongsCreatedByRefField.includes(field?.type)) {
|
|
38
|
-
|
|
58
|
+
const refField = field;
|
|
39
59
|
if (!refField.refCollection && drapcode_constant_1.byFields.has(field.type)) {
|
|
40
60
|
refField.refCollection = {
|
|
41
|
-
collectionField:
|
|
42
|
-
collectionName:
|
|
61
|
+
collectionField: 'userName',
|
|
62
|
+
collectionName: 'user',
|
|
43
63
|
};
|
|
44
64
|
}
|
|
45
65
|
item[fieldName] = await processReferenceItemDecrypt(item[fieldName], encryption, decrypt, refField, encryptedRefCollections);
|
|
@@ -52,29 +72,9 @@ const processDataEncryptionDecryption = async (data, encryption, decrypt) => {
|
|
|
52
72
|
if (!data)
|
|
53
73
|
return data;
|
|
54
74
|
const { dataKey, iv } = encryption;
|
|
55
|
-
return decrypt
|
|
56
|
-
? (0, crypt_1.decryptData)(data, dataKey, iv)
|
|
57
|
-
: (0, crypt_1.encryptData)(data, dataKey, iv);
|
|
75
|
+
return decrypt ? (0, crypt_1.decryptData)(data, dataKey, iv) : (0, crypt_1.encryptData)(data, dataKey, iv);
|
|
58
76
|
};
|
|
59
77
|
exports.processDataEncryptionDecryption = processDataEncryptionDecryption;
|
|
60
|
-
const processReferenceItemDecrypt = async (data, encryption, decrypt, refField, encryptedRefCollections) => {
|
|
61
|
-
const { refCollection } = getEncryptedReferenceCollection(encryptedRefCollections, refField);
|
|
62
|
-
if (refCollection && Array.isArray(data)) {
|
|
63
|
-
const promises = data.map((item) => (0, exports.processItemEncryptDecrypt)(item, refCollection.fields, encryption, decrypt));
|
|
64
|
-
data = await Promise.all(promises);
|
|
65
|
-
}
|
|
66
|
-
return data;
|
|
67
|
-
};
|
|
68
|
-
const getEncryptedReferenceCollection = (encryptedRefCollections, refField) => {
|
|
69
|
-
const { collectionName: refCollectionName, collectionField: refCollectionFieldName, } = refField?.refCollection;
|
|
70
|
-
let refCollection;
|
|
71
|
-
if (encryptedRefCollections.length) {
|
|
72
|
-
if (refCollectionName) {
|
|
73
|
-
refCollection = encryptedRefCollections.find((encColl) => encColl.collectionName === refCollectionName);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return { refCollectionName, refCollectionFieldName, refCollection };
|
|
77
|
-
};
|
|
78
78
|
/**
|
|
79
79
|
* This method is used to generate private KEY for KMS ARN
|
|
80
80
|
* It requires KMS config and ARN
|
|
@@ -93,20 +93,20 @@ const drapcodeEncryptDecrypt = async (data, encrypt) => {
|
|
|
93
93
|
const secretKey = process.env.AWS_KMS_SECRET_KEY;
|
|
94
94
|
const privateDataKey = process.env.AWS_KMS_PRIVATE_DATA_KEY;
|
|
95
95
|
if (!region)
|
|
96
|
-
return { status:
|
|
96
|
+
return { status: 'FAILED', message: 'AWS Region is missing', data: '' };
|
|
97
97
|
if (!accessKey)
|
|
98
|
-
return { status:
|
|
98
|
+
return { status: 'FAILED', message: 'AWS Access Key is missing', data: '' };
|
|
99
99
|
if (!secretKey)
|
|
100
100
|
return {
|
|
101
|
-
status:
|
|
102
|
-
message:
|
|
103
|
-
data:
|
|
101
|
+
status: 'FAILED',
|
|
102
|
+
message: 'AWS Access Secret Key is missing',
|
|
103
|
+
data: '',
|
|
104
104
|
};
|
|
105
105
|
if (!privateDataKey)
|
|
106
106
|
return {
|
|
107
|
-
status:
|
|
108
|
-
message:
|
|
109
|
-
data:
|
|
107
|
+
status: 'FAILED',
|
|
108
|
+
message: 'KMS Private Key is missing',
|
|
109
|
+
data: '',
|
|
110
110
|
};
|
|
111
111
|
const config = {
|
|
112
112
|
region,
|
|
@@ -114,26 +114,26 @@ const drapcodeEncryptDecrypt = async (data, encrypt) => {
|
|
|
114
114
|
secretAccessKey: secretKey,
|
|
115
115
|
};
|
|
116
116
|
//Generate Public Key from
|
|
117
|
-
const plainTextData = await (0, KMS_1.processKMSDecryption)(config, privateDataKey
|
|
118
|
-
if (plainTextData.status ===
|
|
117
|
+
const plainTextData = await (0, KMS_1.processKMSDecryption)(config, privateDataKey);
|
|
118
|
+
if (plainTextData.status === 'FAILED') {
|
|
119
119
|
return plainTextData;
|
|
120
120
|
}
|
|
121
121
|
const publicKey = plainTextData.data;
|
|
122
122
|
let response = null;
|
|
123
123
|
if (encrypt) {
|
|
124
|
-
|
|
124
|
+
drapcode_logger_1.logger.warn('Encrypting');
|
|
125
125
|
response = (0, crypt_1.encryptData)(data, publicKey);
|
|
126
126
|
}
|
|
127
127
|
else {
|
|
128
|
-
|
|
128
|
+
drapcode_logger_1.logger.warn('Decrypting');
|
|
129
129
|
response = (0, crypt_1.decryptData)(data, publicKey);
|
|
130
130
|
}
|
|
131
|
-
return { status:
|
|
131
|
+
return { status: 'SUCCESS', message: '', data: response };
|
|
132
132
|
};
|
|
133
133
|
exports.drapcodeEncryptDecrypt = drapcodeEncryptDecrypt;
|
|
134
134
|
const cryptFile = async (filePath, encryption, decrypt) => {
|
|
135
|
-
console.log("encryption cryptFile:>> ", encryption);
|
|
136
135
|
const data = await (0, file_1.processFileEncryptionDecryption)(filePath, encryption, decrypt);
|
|
137
136
|
return data;
|
|
138
137
|
};
|
|
139
138
|
exports.cryptFile = cryptFile;
|
|
139
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/aws/encryption/index.ts"],"names":[],"mappings":";;;AAAA,yDAAyF;AACzF,qDAAyC;AACzC,mCAAmD;AACnD,iCAAyD;AACzD,+BAAwE;AAGxE,MAAM,2BAA2B,GAAG,KAAK,EACvC,IAAS,EACT,UAAe,EACf,OAAY,EACZ,QAAa,EACb,uBAA4B,EAC5B,EAAE;IACF,MAAM,EAAE,aAAa,EAAE,GAAG,+BAA+B,CAAC,uBAAuB,EAAE,QAAQ,CAAC,CAAC;IAC7F,IAAI,aAAa,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACzC,MA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pB,IAAI,OAAO,EAAE,CAAC;QACZ,wBAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC1B,QAAQ,GAAG,IAAA,mBAAW,EAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAC1C,CAAC;SAAM,CAAC;QACN,wBAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC1B,QAAQ,GAAG,IAAA,mBAAW,EAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AAC5D,CAAC,CAAC;AAxCW,QAAA,sBAAsB,0BAwCjC;AAEK,MAAM,SAAS,GAAG,KAAK,EAAE,QAAa,EAAE,UAAsB,EAAE,OAAgB,EAAE,EAAE;IACzF,MAAM,IAAI,GAAG,MAAM,IAAA,sCAA+B,EAAC,QAAQ,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;IAClF,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAHW,QAAA,SAAS,aAGpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utility.d.ts","sourceRoot":"","sources":["../../../src/aws/encryption/utility.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,2BAA2B,GAAI,kBAAkB,GAAG,QAchE,CAAC"}
|
|
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getEncryptedReferenceFields = void 0;
|
|
4
4
|
const drapcode_constant_1 = require("drapcode-constant");
|
|
5
5
|
const getEncryptedReferenceFields = (collectionFields) => {
|
|
6
|
-
|
|
6
|
+
const collectionsNamesArr = [];
|
|
7
7
|
collectionFields = collectionFields.filter((field) => drapcode_constant_1.BelongsCreatedByRefField.includes(field.type));
|
|
8
8
|
collectionFields.forEach((field) => {
|
|
9
9
|
if (!field.refCollection && drapcode_constant_1.byFields.has(field.type)) {
|
|
10
|
-
collectionsNamesArr.push(
|
|
10
|
+
collectionsNamesArr.push('user');
|
|
11
11
|
}
|
|
12
12
|
else {
|
|
13
13
|
const { collectionName } = field.refCollection;
|
|
@@ -17,3 +17,4 @@ const getEncryptedReferenceFields = (collectionFields) => {
|
|
|
17
17
|
return collectionsNamesArr;
|
|
18
18
|
};
|
|
19
19
|
exports.getEncryptedReferenceFields = getEncryptedReferenceFields;
|
|
20
|
+
//# sourceMappingURL=utility.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utility.js","sourceRoot":"","sources":["../../../src/aws/encryption/utility.ts"],"names":[],"mappings":";;;AAAA,yDAAuE;AAEhE,MAAM,2BAA2B,GAAG,CAAC,gBAAqB,EAAE,EAAE;IACnE,MAAM,mBAAmB,GAAQ,EAAE,CAAC;IACpC,gBAAgB,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC,KAAU,EAAE,EAAE,CACxD,4CAAwB,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAC9C,CAAC;IACF,gBAAgB,CAAC,OAAO,CAAC,CAAC,KAAU,EAAE,EAAE;QACtC,IAAI,CAAC,KAAK,CAAC,aAAa,IAAI,4BAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;YACrD,mBAAmB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACnC,CAAC;aAAM,CAAC;YACN,MAAM,EAAE,cAAc,EAAE,GAAG,KAAK,CAAC,aAAa,CAAC;YAC/C,mBAAmB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC3C,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,mBAAmB,CAAC;AAC7B,CAAC,CAAC;AAdW,QAAA,2BAA2B,+BActC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ObjectCannedACL } from '@aws-sdk/client-s3';
|
|
2
|
+
export type AWSConfig = {
|
|
3
|
+
region: string;
|
|
4
|
+
accessKeyId: string;
|
|
5
|
+
secretAccessKey: string;
|
|
6
|
+
};
|
|
7
|
+
export type S3Config = {
|
|
8
|
+
acl: ObjectCannedACL;
|
|
9
|
+
key: string;
|
|
10
|
+
bucket: string;
|
|
11
|
+
append: boolean;
|
|
12
|
+
};
|
|
13
|
+
export type IconKeys = {
|
|
14
|
+
smallIcon: string | null;
|
|
15
|
+
mediumIcon: string | null;
|
|
16
|
+
largeIcon: string | null;
|
|
17
|
+
};
|
|
18
|
+
export type Encryption = {
|
|
19
|
+
encryptionType: string;
|
|
20
|
+
algorithm: string;
|
|
21
|
+
dataKey: string;
|
|
22
|
+
awsConfig: AWSConfig;
|
|
23
|
+
iv: string;
|
|
24
|
+
};
|
|
25
|
+
export type DecryptResponse = {
|
|
26
|
+
status: string;
|
|
27
|
+
data: string;
|
|
28
|
+
message: string;
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/aws/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,MAAM,MAAM,SAAS,GAAG;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,GAAG,EAAE,eAAe,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,SAAS,CAAC;IACrB,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/aws/model.ts"],"names":[],"mappings":""}
|