nestjs-infisical 1.0.4 → 1.0.8
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/infisical.loader.js
CHANGED
|
@@ -6,8 +6,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.loadInfisicalSecrets = loadInfisicalSecrets;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
8
|
const LOG_PREFIX = '[nestjs-infisical]';
|
|
9
|
+
function debugLog(enabled, message) {
|
|
10
|
+
if (enabled) {
|
|
11
|
+
console.log(`${LOG_PREFIX} ${message}`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
9
14
|
async function loadInfisicalSecrets(options) {
|
|
10
15
|
try {
|
|
16
|
+
debugLog(options.debug, `Fetching secrets from Infisical`);
|
|
17
|
+
debugLog(options.debug, `baseUrl=${options.baseUrl}, projectId=${options.projectId}, environment=${options.environment}`);
|
|
11
18
|
const response = await axios_1.default.get(`${options.baseUrl}/api/v3/secrets/raw`, {
|
|
12
19
|
headers: {
|
|
13
20
|
Authorization: `Bearer ${options.token}`,
|
|
@@ -18,9 +25,18 @@ async function loadInfisicalSecrets(options) {
|
|
|
18
25
|
},
|
|
19
26
|
});
|
|
20
27
|
const secrets = response.data?.secrets ?? {};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
28
|
+
debugLog(options.debug, `Fetched ${Object.keys(secrets).length} secrets from Infisical`);
|
|
29
|
+
debugLog(options.debug, `Secret keys fetched: ${Object.keys(secrets).join(', ')}`);
|
|
30
|
+
for (const [key] of Object.entries(secrets)) {
|
|
31
|
+
const exists = process.env[key] !== undefined;
|
|
32
|
+
if (options.override || !exists) {
|
|
33
|
+
debugLog(options.debug, exists
|
|
34
|
+
? `Overwriting env var: ${key}`
|
|
35
|
+
: `Setting env var: ${key}`);
|
|
36
|
+
process.env[key] = secrets[key];
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
debugLog(options.debug, `Skipping existing env var: ${key}`);
|
|
24
40
|
}
|
|
25
41
|
}
|
|
26
42
|
}
|
|
@@ -7,17 +7,28 @@ exports.initializeInfisical = initializeInfisical;
|
|
|
7
7
|
const infisical_loader_1 = require("./infisical.loader");
|
|
8
8
|
const dotenv_1 = __importDefault(require("dotenv"));
|
|
9
9
|
const LOG_PREFIX = '[nestjs-infisical]';
|
|
10
|
+
function debugLog(enabled, message) {
|
|
11
|
+
if (enabled) {
|
|
12
|
+
console.log(`${LOG_PREFIX} ${message}`);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
10
15
|
async function initializeInfisical(options) {
|
|
11
|
-
const { dotenv: dotenvOptions, baseUrl, token, projectId, environment, override = true, failFast = true, } = options;
|
|
16
|
+
const { dotenv: dotenvOptions, baseUrl, token, projectId, environment, override = true, failFast = true, debug = false } = options;
|
|
12
17
|
if (dotenvOptions !== false) {
|
|
18
|
+
debugLog(debug, 'Loading dotenv configuration');
|
|
13
19
|
dotenv_1.default.config(dotenvOptions);
|
|
14
20
|
}
|
|
21
|
+
else {
|
|
22
|
+
debugLog(debug, 'Dotenv disabled');
|
|
23
|
+
}
|
|
15
24
|
const provided = [baseUrl, token, projectId, environment].filter(Boolean).length;
|
|
25
|
+
debugLog(debug, `Infisical config resolved: ${provided === 0 ? 'none' : provided === 4 ? 'complete' : 'partial'}`);
|
|
16
26
|
if (provided === 0) {
|
|
17
27
|
return;
|
|
18
28
|
}
|
|
19
29
|
if (provided !== 4) {
|
|
20
30
|
console.warn(`${LOG_PREFIX} Partial Infisical configuration detected. Secrets will not be loaded.`);
|
|
31
|
+
debugLog(debug, `baseUrl=${!!baseUrl}, token=${!!token}, projectId=${!!projectId}, environment=${!!environment}`);
|
|
21
32
|
return;
|
|
22
33
|
}
|
|
23
34
|
await (0, infisical_loader_1.loadInfisicalSecrets)({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nestjs-infisical",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "CLI-free Infisical HTTP integration for NestJS",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -20,6 +20,11 @@
|
|
|
20
20
|
"peerDependencies": {
|
|
21
21
|
"@nestjs/common": ">=9.0.0"
|
|
22
22
|
},
|
|
23
|
+
"peerDependenciesMeta": {
|
|
24
|
+
"@nestjs/common": {
|
|
25
|
+
"optional": false
|
|
26
|
+
}
|
|
27
|
+
},
|
|
23
28
|
"engines": {
|
|
24
29
|
"node": ">=18"
|
|
25
30
|
},
|