itrm-tools 1.3.46-beta-1 → 1.3.46-beta-2
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.
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare function decodeEnvFile(secretKey: string): Record<string, string>;
|
|
2
|
-
export declare function requestSecretKey(secretKeyServiceUrl: string): Promise<string>;
|
|
2
|
+
export declare function requestSecretKey(secretKeyServiceUrl: string, serviceReferer?: string, serviceSecretKey?: string): Promise<string>;
|
|
@@ -42,14 +42,16 @@ const path = __importStar(require("node:path"));
|
|
|
42
42
|
const fs = __importStar(require("node:fs"));
|
|
43
43
|
const dotenv = __importStar(require("dotenv"));
|
|
44
44
|
const axios_1 = __importDefault(require("axios"));
|
|
45
|
+
const AesCipheringAlgorithm_1 = require("../cryptography/algorithm/AesCipheringAlgorithm");
|
|
45
46
|
const GcmCipheringAlgorithm_1 = require("../cryptography/algorithm/GcmCipheringAlgorithm");
|
|
46
|
-
const
|
|
47
|
+
const REFERER_CIPHER = new AesCipheringAlgorithm_1.AesCipheringAlgorithm();
|
|
48
|
+
const GCM_CIPHER = new GcmCipheringAlgorithm_1.GcmCipheringAlgorithm();
|
|
47
49
|
function decodeEnvFile(secretKey) {
|
|
48
50
|
const encPath = path.resolve(process.cwd(), ".env.enc");
|
|
49
51
|
if (fs.existsSync(encPath)) {
|
|
50
52
|
const buf = fs.readFileSync(encPath);
|
|
51
53
|
try {
|
|
52
|
-
const plaintext =
|
|
54
|
+
const plaintext = GCM_CIPHER.decrypt(buf, secretKey);
|
|
53
55
|
if (plaintext) {
|
|
54
56
|
return dotenv.parse(plaintext);
|
|
55
57
|
}
|
|
@@ -60,8 +62,12 @@ function decodeEnvFile(secretKey) {
|
|
|
60
62
|
}
|
|
61
63
|
return {};
|
|
62
64
|
}
|
|
63
|
-
async function requestSecretKey(secretKeyServiceUrl) {
|
|
64
|
-
const
|
|
65
|
+
async function requestSecretKey(secretKeyServiceUrl, serviceReferer, serviceSecretKey) {
|
|
66
|
+
const headers = {};
|
|
67
|
+
if (serviceReferer && serviceSecretKey) {
|
|
68
|
+
headers.Referer = REFERER_CIPHER.encrypt(serviceReferer, serviceSecretKey);
|
|
69
|
+
}
|
|
70
|
+
const response = await axios_1.default.get(`${secretKeyServiceUrl}/service/secret-key`, { headers });
|
|
65
71
|
if (response.data && response.data.payload) {
|
|
66
72
|
return response.data.payload;
|
|
67
73
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnvDecryption.js","sourceRoot":"","sources":["../../src/env/EnvDecryption.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"EnvDecryption.js","sourceRoot":"","sources":["../../src/env/EnvDecryption.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,sCAcC;AAED,4CAiBC;AA5CD,gDAAkC;AAClC,4CAA8B;AAC9B,+CAAiC;AACjC,kDAA0B;AAC1B,2FAAwF;AACxF,2FAAwF;AAExF,MAAM,cAAc,GAAG,IAAI,6CAAqB,EAAE,CAAC;AACnD,MAAM,UAAU,GAAG,IAAI,6CAAqB,EAAE,CAAC;AAG/C,SAAgB,aAAa,CAAC,SAAiB;IAC3C,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,UAAU,CAAC,CAAC;IACxD,IAAI,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QACzB,MAAM,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QACrC,IAAI,CAAC;YACD,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;YACrD,IAAI,SAAS,EAAE,CAAC;gBACZ,OAAO,MAAM,CAAC,KAAK,CAAC,SAAS,CAA2B,CAAC;YAC7D,CAAC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