node-consul-service 1.0.15 → 1.0.16
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/index.cjs.js +416 -37
- package/dist/index.esm.js +416 -37
- package/package.json +5 -3
package/dist/index.cjs.js
CHANGED
|
@@ -1,18 +1,401 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var require$$0$1 = require('fs');
|
|
4
|
+
var require$$1 = require('path');
|
|
5
|
+
var require$$2 = require('os');
|
|
6
|
+
var require$$3 = require('crypto');
|
|
3
7
|
var Consul = require('consul');
|
|
4
|
-
var require$$1 = require('util');
|
|
8
|
+
var require$$1$1 = require('util');
|
|
5
9
|
var stream = require('stream');
|
|
6
|
-
var require$$
|
|
7
|
-
var require$$
|
|
8
|
-
var require$$
|
|
9
|
-
var require$$
|
|
10
|
-
var require$$6 = require('fs');
|
|
11
|
-
var crypto = require('crypto');
|
|
12
|
-
var require$$4$1 = require('assert');
|
|
10
|
+
var require$$3$1 = require('http');
|
|
11
|
+
var require$$4$1 = require('https');
|
|
12
|
+
var require$$0$2 = require('url');
|
|
13
|
+
var require$$4$2 = require('assert');
|
|
13
14
|
var zlib = require('zlib');
|
|
14
15
|
var events = require('events');
|
|
15
16
|
|
|
17
|
+
function getDefaultExportFromCjs (x) {
|
|
18
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
var main = {exports: {}};
|
|
22
|
+
|
|
23
|
+
var version = "16.5.0";
|
|
24
|
+
var require$$4 = {
|
|
25
|
+
version: version};
|
|
26
|
+
|
|
27
|
+
var hasRequiredMain;
|
|
28
|
+
|
|
29
|
+
function requireMain () {
|
|
30
|
+
if (hasRequiredMain) return main.exports;
|
|
31
|
+
hasRequiredMain = 1;
|
|
32
|
+
const fs = require$$0$1;
|
|
33
|
+
const path = require$$1;
|
|
34
|
+
const os = require$$2;
|
|
35
|
+
const crypto = require$$3;
|
|
36
|
+
const packageJson = require$$4;
|
|
37
|
+
|
|
38
|
+
const version = packageJson.version;
|
|
39
|
+
|
|
40
|
+
const LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
|
|
41
|
+
|
|
42
|
+
// Parse src into an Object
|
|
43
|
+
function parse (src) {
|
|
44
|
+
const obj = {};
|
|
45
|
+
|
|
46
|
+
// Convert buffer to string
|
|
47
|
+
let lines = src.toString();
|
|
48
|
+
|
|
49
|
+
// Convert line breaks to same format
|
|
50
|
+
lines = lines.replace(/\r\n?/mg, '\n');
|
|
51
|
+
|
|
52
|
+
let match;
|
|
53
|
+
while ((match = LINE.exec(lines)) != null) {
|
|
54
|
+
const key = match[1];
|
|
55
|
+
|
|
56
|
+
// Default undefined or null to empty string
|
|
57
|
+
let value = (match[2] || '');
|
|
58
|
+
|
|
59
|
+
// Remove whitespace
|
|
60
|
+
value = value.trim();
|
|
61
|
+
|
|
62
|
+
// Check if double quoted
|
|
63
|
+
const maybeQuote = value[0];
|
|
64
|
+
|
|
65
|
+
// Remove surrounding quotes
|
|
66
|
+
value = value.replace(/^(['"`])([\s\S]*)\1$/mg, '$2');
|
|
67
|
+
|
|
68
|
+
// Expand newlines if double quoted
|
|
69
|
+
if (maybeQuote === '"') {
|
|
70
|
+
value = value.replace(/\\n/g, '\n');
|
|
71
|
+
value = value.replace(/\\r/g, '\r');
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Add to object
|
|
75
|
+
obj[key] = value;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return obj
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function _parseVault (options) {
|
|
82
|
+
const vaultPath = _vaultPath(options);
|
|
83
|
+
|
|
84
|
+
// Parse .env.vault
|
|
85
|
+
const result = DotenvModule.configDotenv({ path: vaultPath });
|
|
86
|
+
if (!result.parsed) {
|
|
87
|
+
const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
|
|
88
|
+
err.code = 'MISSING_DATA';
|
|
89
|
+
throw err
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// handle scenario for comma separated keys - for use with key rotation
|
|
93
|
+
// example: DOTENV_KEY="dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=prod,dotenv://:key_7890@dotenvx.com/vault/.env.vault?environment=prod"
|
|
94
|
+
const keys = _dotenvKey(options).split(',');
|
|
95
|
+
const length = keys.length;
|
|
96
|
+
|
|
97
|
+
let decrypted;
|
|
98
|
+
for (let i = 0; i < length; i++) {
|
|
99
|
+
try {
|
|
100
|
+
// Get full key
|
|
101
|
+
const key = keys[i].trim();
|
|
102
|
+
|
|
103
|
+
// Get instructions for decrypt
|
|
104
|
+
const attrs = _instructions(result, key);
|
|
105
|
+
|
|
106
|
+
// Decrypt
|
|
107
|
+
decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
|
|
108
|
+
|
|
109
|
+
break
|
|
110
|
+
} catch (error) {
|
|
111
|
+
// last key
|
|
112
|
+
if (i + 1 >= length) {
|
|
113
|
+
throw error
|
|
114
|
+
}
|
|
115
|
+
// try next key
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Parse decrypted .env string
|
|
120
|
+
return DotenvModule.parse(decrypted)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function _warn (message) {
|
|
124
|
+
console.log(`[dotenv@${version}][WARN] ${message}`);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function _debug (message) {
|
|
128
|
+
console.log(`[dotenv@${version}][DEBUG] ${message}`);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function _dotenvKey (options) {
|
|
132
|
+
// prioritize developer directly setting options.DOTENV_KEY
|
|
133
|
+
if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
|
|
134
|
+
return options.DOTENV_KEY
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// secondary infra already contains a DOTENV_KEY environment variable
|
|
138
|
+
if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
|
|
139
|
+
return process.env.DOTENV_KEY
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// fallback to empty string
|
|
143
|
+
return ''
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function _instructions (result, dotenvKey) {
|
|
147
|
+
// Parse DOTENV_KEY. Format is a URI
|
|
148
|
+
let uri;
|
|
149
|
+
try {
|
|
150
|
+
uri = new URL(dotenvKey);
|
|
151
|
+
} catch (error) {
|
|
152
|
+
if (error.code === 'ERR_INVALID_URL') {
|
|
153
|
+
const err = new Error('INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development');
|
|
154
|
+
err.code = 'INVALID_DOTENV_KEY';
|
|
155
|
+
throw err
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
throw error
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Get decrypt key
|
|
162
|
+
const key = uri.password;
|
|
163
|
+
if (!key) {
|
|
164
|
+
const err = new Error('INVALID_DOTENV_KEY: Missing key part');
|
|
165
|
+
err.code = 'INVALID_DOTENV_KEY';
|
|
166
|
+
throw err
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Get environment
|
|
170
|
+
const environment = uri.searchParams.get('environment');
|
|
171
|
+
if (!environment) {
|
|
172
|
+
const err = new Error('INVALID_DOTENV_KEY: Missing environment part');
|
|
173
|
+
err.code = 'INVALID_DOTENV_KEY';
|
|
174
|
+
throw err
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// Get ciphertext payload
|
|
178
|
+
const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
|
|
179
|
+
const ciphertext = result.parsed[environmentKey]; // DOTENV_VAULT_PRODUCTION
|
|
180
|
+
if (!ciphertext) {
|
|
181
|
+
const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
|
|
182
|
+
err.code = 'NOT_FOUND_DOTENV_ENVIRONMENT';
|
|
183
|
+
throw err
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return { ciphertext, key }
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function _vaultPath (options) {
|
|
190
|
+
let possibleVaultPath = null;
|
|
191
|
+
|
|
192
|
+
if (options && options.path && options.path.length > 0) {
|
|
193
|
+
if (Array.isArray(options.path)) {
|
|
194
|
+
for (const filepath of options.path) {
|
|
195
|
+
if (fs.existsSync(filepath)) {
|
|
196
|
+
possibleVaultPath = filepath.endsWith('.vault') ? filepath : `${filepath}.vault`;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
} else {
|
|
200
|
+
possibleVaultPath = options.path.endsWith('.vault') ? options.path : `${options.path}.vault`;
|
|
201
|
+
}
|
|
202
|
+
} else {
|
|
203
|
+
possibleVaultPath = path.resolve(process.cwd(), '.env.vault');
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if (fs.existsSync(possibleVaultPath)) {
|
|
207
|
+
return possibleVaultPath
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
return null
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function _resolveHome (envPath) {
|
|
214
|
+
return envPath[0] === '~' ? path.join(os.homedir(), envPath.slice(1)) : envPath
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function _configVault (options) {
|
|
218
|
+
const debug = Boolean(options && options.debug);
|
|
219
|
+
if (debug) {
|
|
220
|
+
_debug('Loading env from encrypted .env.vault');
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const parsed = DotenvModule._parseVault(options);
|
|
224
|
+
|
|
225
|
+
let processEnv = process.env;
|
|
226
|
+
if (options && options.processEnv != null) {
|
|
227
|
+
processEnv = options.processEnv;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
DotenvModule.populate(processEnv, parsed, options);
|
|
231
|
+
|
|
232
|
+
return { parsed }
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function configDotenv (options) {
|
|
236
|
+
const dotenvPath = path.resolve(process.cwd(), '.env');
|
|
237
|
+
let encoding = 'utf8';
|
|
238
|
+
const debug = Boolean(options && options.debug);
|
|
239
|
+
|
|
240
|
+
if (options && options.encoding) {
|
|
241
|
+
encoding = options.encoding;
|
|
242
|
+
} else {
|
|
243
|
+
if (debug) {
|
|
244
|
+
_debug('No encoding is specified. UTF-8 is used by default');
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
let optionPaths = [dotenvPath]; // default, look for .env
|
|
249
|
+
if (options && options.path) {
|
|
250
|
+
if (!Array.isArray(options.path)) {
|
|
251
|
+
optionPaths = [_resolveHome(options.path)];
|
|
252
|
+
} else {
|
|
253
|
+
optionPaths = []; // reset default
|
|
254
|
+
for (const filepath of options.path) {
|
|
255
|
+
optionPaths.push(_resolveHome(filepath));
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// Build the parsed data in a temporary object (because we need to return it). Once we have the final
|
|
261
|
+
// parsed data, we will combine it with process.env (or options.processEnv if provided).
|
|
262
|
+
let lastError;
|
|
263
|
+
const parsedAll = {};
|
|
264
|
+
for (const path of optionPaths) {
|
|
265
|
+
try {
|
|
266
|
+
// Specifying an encoding returns a string instead of a buffer
|
|
267
|
+
const parsed = DotenvModule.parse(fs.readFileSync(path, { encoding }));
|
|
268
|
+
|
|
269
|
+
DotenvModule.populate(parsedAll, parsed, options);
|
|
270
|
+
} catch (e) {
|
|
271
|
+
if (debug) {
|
|
272
|
+
_debug(`Failed to load ${path} ${e.message}`);
|
|
273
|
+
}
|
|
274
|
+
lastError = e;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
let processEnv = process.env;
|
|
279
|
+
if (options && options.processEnv != null) {
|
|
280
|
+
processEnv = options.processEnv;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
DotenvModule.populate(processEnv, parsedAll, options);
|
|
284
|
+
|
|
285
|
+
if (lastError) {
|
|
286
|
+
return { parsed: parsedAll, error: lastError }
|
|
287
|
+
} else {
|
|
288
|
+
return { parsed: parsedAll }
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// Populates process.env from .env file
|
|
293
|
+
function config (options) {
|
|
294
|
+
// fallback to original dotenv if DOTENV_KEY is not set
|
|
295
|
+
if (_dotenvKey(options).length === 0) {
|
|
296
|
+
return DotenvModule.configDotenv(options)
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
const vaultPath = _vaultPath(options);
|
|
300
|
+
|
|
301
|
+
// dotenvKey exists but .env.vault file does not exist
|
|
302
|
+
if (!vaultPath) {
|
|
303
|
+
_warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
|
|
304
|
+
|
|
305
|
+
return DotenvModule.configDotenv(options)
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
return DotenvModule._configVault(options)
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
function decrypt (encrypted, keyStr) {
|
|
312
|
+
const key = Buffer.from(keyStr.slice(-64), 'hex');
|
|
313
|
+
let ciphertext = Buffer.from(encrypted, 'base64');
|
|
314
|
+
|
|
315
|
+
const nonce = ciphertext.subarray(0, 12);
|
|
316
|
+
const authTag = ciphertext.subarray(-16);
|
|
317
|
+
ciphertext = ciphertext.subarray(12, -16);
|
|
318
|
+
|
|
319
|
+
try {
|
|
320
|
+
const aesgcm = crypto.createDecipheriv('aes-256-gcm', key, nonce);
|
|
321
|
+
aesgcm.setAuthTag(authTag);
|
|
322
|
+
return `${aesgcm.update(ciphertext)}${aesgcm.final()}`
|
|
323
|
+
} catch (error) {
|
|
324
|
+
const isRange = error instanceof RangeError;
|
|
325
|
+
const invalidKeyLength = error.message === 'Invalid key length';
|
|
326
|
+
const decryptionFailed = error.message === 'Unsupported state or unable to authenticate data';
|
|
327
|
+
|
|
328
|
+
if (isRange || invalidKeyLength) {
|
|
329
|
+
const err = new Error('INVALID_DOTENV_KEY: It must be 64 characters long (or more)');
|
|
330
|
+
err.code = 'INVALID_DOTENV_KEY';
|
|
331
|
+
throw err
|
|
332
|
+
} else if (decryptionFailed) {
|
|
333
|
+
const err = new Error('DECRYPTION_FAILED: Please check your DOTENV_KEY');
|
|
334
|
+
err.code = 'DECRYPTION_FAILED';
|
|
335
|
+
throw err
|
|
336
|
+
} else {
|
|
337
|
+
throw error
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
// Populate process.env with parsed values
|
|
343
|
+
function populate (processEnv, parsed, options = {}) {
|
|
344
|
+
const debug = Boolean(options && options.debug);
|
|
345
|
+
const override = Boolean(options && options.override);
|
|
346
|
+
|
|
347
|
+
if (typeof parsed !== 'object') {
|
|
348
|
+
const err = new Error('OBJECT_REQUIRED: Please check the processEnv argument being passed to populate');
|
|
349
|
+
err.code = 'OBJECT_REQUIRED';
|
|
350
|
+
throw err
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
// Set process.env
|
|
354
|
+
for (const key of Object.keys(parsed)) {
|
|
355
|
+
if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
|
|
356
|
+
if (override === true) {
|
|
357
|
+
processEnv[key] = parsed[key];
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
if (debug) {
|
|
361
|
+
if (override === true) {
|
|
362
|
+
_debug(`"${key}" is already defined and WAS overwritten`);
|
|
363
|
+
} else {
|
|
364
|
+
_debug(`"${key}" is already defined and was NOT overwritten`);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
} else {
|
|
368
|
+
processEnv[key] = parsed[key];
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
const DotenvModule = {
|
|
374
|
+
configDotenv,
|
|
375
|
+
_configVault,
|
|
376
|
+
_parseVault,
|
|
377
|
+
config,
|
|
378
|
+
decrypt,
|
|
379
|
+
parse,
|
|
380
|
+
populate
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
main.exports.configDotenv = DotenvModule.configDotenv;
|
|
384
|
+
main.exports._configVault = DotenvModule._configVault;
|
|
385
|
+
main.exports._parseVault = DotenvModule._parseVault;
|
|
386
|
+
main.exports.config = DotenvModule.config;
|
|
387
|
+
main.exports.decrypt = DotenvModule.decrypt;
|
|
388
|
+
main.exports.parse = DotenvModule.parse;
|
|
389
|
+
main.exports.populate = DotenvModule.populate;
|
|
390
|
+
|
|
391
|
+
main.exports = DotenvModule;
|
|
392
|
+
return main.exports;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
var mainExports = requireMain();
|
|
396
|
+
var dotenv = /*@__PURE__*/getDefaultExportFromCjs(mainExports);
|
|
397
|
+
|
|
398
|
+
dotenv.config();
|
|
16
399
|
const { CONSUL_HOST, CONSUL_PORT, CONSUL_SECURE } = process.env;
|
|
17
400
|
if (!CONSUL_HOST) {
|
|
18
401
|
throw new Error("Missing environment variable: CONSUL_HOST");
|
|
@@ -940,10 +1323,6 @@ AxiosError$1.from = (error, code, config, request, response, customProps) => {
|
|
|
940
1323
|
return axiosError;
|
|
941
1324
|
};
|
|
942
1325
|
|
|
943
|
-
function getDefaultExportFromCjs (x) {
|
|
944
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
945
|
-
}
|
|
946
|
-
|
|
947
1326
|
var delayed_stream;
|
|
948
1327
|
var hasRequiredDelayed_stream;
|
|
949
1328
|
|
|
@@ -951,7 +1330,7 @@ function requireDelayed_stream () {
|
|
|
951
1330
|
if (hasRequiredDelayed_stream) return delayed_stream;
|
|
952
1331
|
hasRequiredDelayed_stream = 1;
|
|
953
1332
|
var Stream = stream.Stream;
|
|
954
|
-
var util = require$$1;
|
|
1333
|
+
var util = require$$1$1;
|
|
955
1334
|
|
|
956
1335
|
delayed_stream = DelayedStream;
|
|
957
1336
|
function DelayedStream() {
|
|
@@ -1066,7 +1445,7 @@ var hasRequiredCombined_stream;
|
|
|
1066
1445
|
function requireCombined_stream () {
|
|
1067
1446
|
if (hasRequiredCombined_stream) return combined_stream;
|
|
1068
1447
|
hasRequiredCombined_stream = 1;
|
|
1069
|
-
var util = require$$1;
|
|
1448
|
+
var util = require$$1$1;
|
|
1070
1449
|
var Stream = stream.Stream;
|
|
1071
1450
|
var DelayedStream = requireDelayed_stream();
|
|
1072
1451
|
|
|
@@ -12023,7 +12402,7 @@ function requireMimeTypes () {
|
|
|
12023
12402
|
*/
|
|
12024
12403
|
|
|
12025
12404
|
var db = requireMimeDb();
|
|
12026
|
-
var extname = require$$1
|
|
12405
|
+
var extname = require$$1.extname;
|
|
12027
12406
|
|
|
12028
12407
|
/**
|
|
12029
12408
|
* Module variables.
|
|
@@ -13763,12 +14142,12 @@ function requireForm_data () {
|
|
|
13763
14142
|
if (hasRequiredForm_data) return form_data;
|
|
13764
14143
|
hasRequiredForm_data = 1;
|
|
13765
14144
|
var CombinedStream = requireCombined_stream();
|
|
13766
|
-
var util = require$$1;
|
|
13767
|
-
var path = require$$1
|
|
13768
|
-
var http = require$$3;
|
|
13769
|
-
var https = require$$4;
|
|
13770
|
-
var parseUrl = require$$0$
|
|
13771
|
-
var fs = require$$
|
|
14145
|
+
var util = require$$1$1;
|
|
14146
|
+
var path = require$$1;
|
|
14147
|
+
var http = require$$3$1;
|
|
14148
|
+
var https = require$$4$1;
|
|
14149
|
+
var parseUrl = require$$0$2.parse;
|
|
14150
|
+
var fs = require$$0$1;
|
|
13772
14151
|
var Stream = stream.Stream;
|
|
13773
14152
|
var mime = requireMimeTypes();
|
|
13774
14153
|
var asynckit = requireAsynckit();
|
|
@@ -14672,7 +15051,7 @@ var transitionalDefaults = {
|
|
|
14672
15051
|
clarifyTimeoutError: false
|
|
14673
15052
|
};
|
|
14674
15053
|
|
|
14675
|
-
var URLSearchParams = require$$0$
|
|
15054
|
+
var URLSearchParams = require$$0$2.URLSearchParams;
|
|
14676
15055
|
|
|
14677
15056
|
const ALPHA = 'abcdefghijklmnopqrstuvwxyz';
|
|
14678
15057
|
|
|
@@ -14688,7 +15067,7 @@ const generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {
|
|
|
14688
15067
|
let str = '';
|
|
14689
15068
|
const {length} = alphabet;
|
|
14690
15069
|
const randomValues = new Uint32Array(size);
|
|
14691
|
-
|
|
15070
|
+
require$$3.randomFillSync(randomValues);
|
|
14692
15071
|
for (let i = 0; i < size; i++) {
|
|
14693
15072
|
str += alphabet[randomValues[i] % length];
|
|
14694
15073
|
}
|
|
@@ -14754,12 +15133,12 @@ const hasStandardBrowserWebWorkerEnv = (() => {
|
|
|
14754
15133
|
const origin = hasBrowserEnv && window.location.href || 'http://localhost';
|
|
14755
15134
|
|
|
14756
15135
|
var utils = /*#__PURE__*/Object.freeze({
|
|
14757
|
-
|
|
14758
|
-
|
|
14759
|
-
|
|
14760
|
-
|
|
14761
|
-
|
|
14762
|
-
|
|
15136
|
+
__proto__: null,
|
|
15137
|
+
hasBrowserEnv: hasBrowserEnv,
|
|
15138
|
+
hasStandardBrowserEnv: hasStandardBrowserEnv,
|
|
15139
|
+
hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
|
|
15140
|
+
navigator: _navigator,
|
|
15141
|
+
origin: origin
|
|
14763
15142
|
});
|
|
14764
15143
|
|
|
14765
15144
|
var platform = {
|
|
@@ -15504,7 +15883,7 @@ function requireProxyFromEnv () {
|
|
|
15504
15883
|
if (hasRequiredProxyFromEnv) return proxyFromEnv$1;
|
|
15505
15884
|
hasRequiredProxyFromEnv = 1;
|
|
15506
15885
|
|
|
15507
|
-
var parseUrl = require$$0$
|
|
15886
|
+
var parseUrl = require$$0$2.parse;
|
|
15508
15887
|
|
|
15509
15888
|
var DEFAULT_PORTS = {
|
|
15510
15889
|
ftp: 21,
|
|
@@ -15647,12 +16026,12 @@ var hasRequiredFollowRedirects;
|
|
|
15647
16026
|
function requireFollowRedirects () {
|
|
15648
16027
|
if (hasRequiredFollowRedirects) return followRedirects$1.exports;
|
|
15649
16028
|
hasRequiredFollowRedirects = 1;
|
|
15650
|
-
var url = require$$0$
|
|
16029
|
+
var url = require$$0$2;
|
|
15651
16030
|
var URL = url.URL;
|
|
15652
|
-
var http = require$$3;
|
|
15653
|
-
var https = require$$4;
|
|
16031
|
+
var http = require$$3$1;
|
|
16032
|
+
var https = require$$4$1;
|
|
15654
16033
|
var Writable = stream.Writable;
|
|
15655
|
-
var assert = require$$4$
|
|
16034
|
+
var assert = require$$4$2;
|
|
15656
16035
|
var debug = requireDebug();
|
|
15657
16036
|
|
|
15658
16037
|
// Preventive platform detection
|
|
@@ -16547,7 +16926,7 @@ const readBlob = async function* (blob) {
|
|
|
16547
16926
|
|
|
16548
16927
|
const BOUNDARY_ALPHABET = platform.ALPHABET.ALPHA_DIGIT + '-_';
|
|
16549
16928
|
|
|
16550
|
-
const textEncoder = typeof TextEncoder === 'function' ? new TextEncoder() : new require$$1.TextEncoder();
|
|
16929
|
+
const textEncoder = typeof TextEncoder === 'function' ? new TextEncoder() : new require$$1$1.TextEncoder();
|
|
16551
16930
|
|
|
16552
16931
|
const CRLF = '\r\n';
|
|
16553
16932
|
const CRLF_BYTES = textEncoder.encode(CRLF);
|
|
@@ -17104,7 +17483,7 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
17104
17483
|
|
|
17105
17484
|
if (!headers.hasContentLength()) {
|
|
17106
17485
|
try {
|
|
17107
|
-
const knownLength = await require$$1.promisify(data.getLength).call(data);
|
|
17486
|
+
const knownLength = await require$$1$1.promisify(data.getLength).call(data);
|
|
17108
17487
|
Number.isFinite(knownLength) && knownLength >= 0 && headers.setContentLength(knownLength);
|
|
17109
17488
|
/*eslint no-empty:0*/
|
|
17110
17489
|
} catch (e) {
|
|
@@ -17232,7 +17611,7 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
17232
17611
|
if (config.transport) {
|
|
17233
17612
|
transport = config.transport;
|
|
17234
17613
|
} else if (config.maxRedirects === 0) {
|
|
17235
|
-
transport = isHttpsRequest ? require$$4 : require$$3;
|
|
17614
|
+
transport = isHttpsRequest ? require$$4$1 : require$$3$1;
|
|
17236
17615
|
} else {
|
|
17237
17616
|
if (config.maxRedirects) {
|
|
17238
17617
|
options.maxRedirects = config.maxRedirects;
|
package/dist/index.esm.js
CHANGED
|
@@ -1,16 +1,399 @@
|
|
|
1
|
+
import require$$0$1 from 'fs';
|
|
2
|
+
import require$$1 from 'path';
|
|
3
|
+
import require$$2 from 'os';
|
|
4
|
+
import require$$3 from 'crypto';
|
|
1
5
|
import Consul from 'consul';
|
|
2
|
-
import require$$1 from 'util';
|
|
6
|
+
import require$$1$1 from 'util';
|
|
3
7
|
import stream, { Readable } from 'stream';
|
|
4
|
-
import require$$
|
|
5
|
-
import require$$
|
|
6
|
-
import require$$
|
|
7
|
-
import require$$
|
|
8
|
-
import require$$6 from 'fs';
|
|
9
|
-
import crypto from 'crypto';
|
|
10
|
-
import require$$4$1 from 'assert';
|
|
8
|
+
import require$$3$1 from 'http';
|
|
9
|
+
import require$$4$1 from 'https';
|
|
10
|
+
import require$$0$2 from 'url';
|
|
11
|
+
import require$$4$2 from 'assert';
|
|
11
12
|
import zlib from 'zlib';
|
|
12
13
|
import { EventEmitter } from 'events';
|
|
13
14
|
|
|
15
|
+
function getDefaultExportFromCjs (x) {
|
|
16
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
var main = {exports: {}};
|
|
20
|
+
|
|
21
|
+
var version = "16.5.0";
|
|
22
|
+
var require$$4 = {
|
|
23
|
+
version: version};
|
|
24
|
+
|
|
25
|
+
var hasRequiredMain;
|
|
26
|
+
|
|
27
|
+
function requireMain () {
|
|
28
|
+
if (hasRequiredMain) return main.exports;
|
|
29
|
+
hasRequiredMain = 1;
|
|
30
|
+
const fs = require$$0$1;
|
|
31
|
+
const path = require$$1;
|
|
32
|
+
const os = require$$2;
|
|
33
|
+
const crypto = require$$3;
|
|
34
|
+
const packageJson = require$$4;
|
|
35
|
+
|
|
36
|
+
const version = packageJson.version;
|
|
37
|
+
|
|
38
|
+
const LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
|
|
39
|
+
|
|
40
|
+
// Parse src into an Object
|
|
41
|
+
function parse (src) {
|
|
42
|
+
const obj = {};
|
|
43
|
+
|
|
44
|
+
// Convert buffer to string
|
|
45
|
+
let lines = src.toString();
|
|
46
|
+
|
|
47
|
+
// Convert line breaks to same format
|
|
48
|
+
lines = lines.replace(/\r\n?/mg, '\n');
|
|
49
|
+
|
|
50
|
+
let match;
|
|
51
|
+
while ((match = LINE.exec(lines)) != null) {
|
|
52
|
+
const key = match[1];
|
|
53
|
+
|
|
54
|
+
// Default undefined or null to empty string
|
|
55
|
+
let value = (match[2] || '');
|
|
56
|
+
|
|
57
|
+
// Remove whitespace
|
|
58
|
+
value = value.trim();
|
|
59
|
+
|
|
60
|
+
// Check if double quoted
|
|
61
|
+
const maybeQuote = value[0];
|
|
62
|
+
|
|
63
|
+
// Remove surrounding quotes
|
|
64
|
+
value = value.replace(/^(['"`])([\s\S]*)\1$/mg, '$2');
|
|
65
|
+
|
|
66
|
+
// Expand newlines if double quoted
|
|
67
|
+
if (maybeQuote === '"') {
|
|
68
|
+
value = value.replace(/\\n/g, '\n');
|
|
69
|
+
value = value.replace(/\\r/g, '\r');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Add to object
|
|
73
|
+
obj[key] = value;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return obj
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function _parseVault (options) {
|
|
80
|
+
const vaultPath = _vaultPath(options);
|
|
81
|
+
|
|
82
|
+
// Parse .env.vault
|
|
83
|
+
const result = DotenvModule.configDotenv({ path: vaultPath });
|
|
84
|
+
if (!result.parsed) {
|
|
85
|
+
const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
|
|
86
|
+
err.code = 'MISSING_DATA';
|
|
87
|
+
throw err
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// handle scenario for comma separated keys - for use with key rotation
|
|
91
|
+
// example: DOTENV_KEY="dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=prod,dotenv://:key_7890@dotenvx.com/vault/.env.vault?environment=prod"
|
|
92
|
+
const keys = _dotenvKey(options).split(',');
|
|
93
|
+
const length = keys.length;
|
|
94
|
+
|
|
95
|
+
let decrypted;
|
|
96
|
+
for (let i = 0; i < length; i++) {
|
|
97
|
+
try {
|
|
98
|
+
// Get full key
|
|
99
|
+
const key = keys[i].trim();
|
|
100
|
+
|
|
101
|
+
// Get instructions for decrypt
|
|
102
|
+
const attrs = _instructions(result, key);
|
|
103
|
+
|
|
104
|
+
// Decrypt
|
|
105
|
+
decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
|
|
106
|
+
|
|
107
|
+
break
|
|
108
|
+
} catch (error) {
|
|
109
|
+
// last key
|
|
110
|
+
if (i + 1 >= length) {
|
|
111
|
+
throw error
|
|
112
|
+
}
|
|
113
|
+
// try next key
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Parse decrypted .env string
|
|
118
|
+
return DotenvModule.parse(decrypted)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function _warn (message) {
|
|
122
|
+
console.log(`[dotenv@${version}][WARN] ${message}`);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function _debug (message) {
|
|
126
|
+
console.log(`[dotenv@${version}][DEBUG] ${message}`);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function _dotenvKey (options) {
|
|
130
|
+
// prioritize developer directly setting options.DOTENV_KEY
|
|
131
|
+
if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
|
|
132
|
+
return options.DOTENV_KEY
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// secondary infra already contains a DOTENV_KEY environment variable
|
|
136
|
+
if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
|
|
137
|
+
return process.env.DOTENV_KEY
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// fallback to empty string
|
|
141
|
+
return ''
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function _instructions (result, dotenvKey) {
|
|
145
|
+
// Parse DOTENV_KEY. Format is a URI
|
|
146
|
+
let uri;
|
|
147
|
+
try {
|
|
148
|
+
uri = new URL(dotenvKey);
|
|
149
|
+
} catch (error) {
|
|
150
|
+
if (error.code === 'ERR_INVALID_URL') {
|
|
151
|
+
const err = new Error('INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development');
|
|
152
|
+
err.code = 'INVALID_DOTENV_KEY';
|
|
153
|
+
throw err
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
throw error
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Get decrypt key
|
|
160
|
+
const key = uri.password;
|
|
161
|
+
if (!key) {
|
|
162
|
+
const err = new Error('INVALID_DOTENV_KEY: Missing key part');
|
|
163
|
+
err.code = 'INVALID_DOTENV_KEY';
|
|
164
|
+
throw err
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Get environment
|
|
168
|
+
const environment = uri.searchParams.get('environment');
|
|
169
|
+
if (!environment) {
|
|
170
|
+
const err = new Error('INVALID_DOTENV_KEY: Missing environment part');
|
|
171
|
+
err.code = 'INVALID_DOTENV_KEY';
|
|
172
|
+
throw err
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Get ciphertext payload
|
|
176
|
+
const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
|
|
177
|
+
const ciphertext = result.parsed[environmentKey]; // DOTENV_VAULT_PRODUCTION
|
|
178
|
+
if (!ciphertext) {
|
|
179
|
+
const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
|
|
180
|
+
err.code = 'NOT_FOUND_DOTENV_ENVIRONMENT';
|
|
181
|
+
throw err
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return { ciphertext, key }
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function _vaultPath (options) {
|
|
188
|
+
let possibleVaultPath = null;
|
|
189
|
+
|
|
190
|
+
if (options && options.path && options.path.length > 0) {
|
|
191
|
+
if (Array.isArray(options.path)) {
|
|
192
|
+
for (const filepath of options.path) {
|
|
193
|
+
if (fs.existsSync(filepath)) {
|
|
194
|
+
possibleVaultPath = filepath.endsWith('.vault') ? filepath : `${filepath}.vault`;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
} else {
|
|
198
|
+
possibleVaultPath = options.path.endsWith('.vault') ? options.path : `${options.path}.vault`;
|
|
199
|
+
}
|
|
200
|
+
} else {
|
|
201
|
+
possibleVaultPath = path.resolve(process.cwd(), '.env.vault');
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (fs.existsSync(possibleVaultPath)) {
|
|
205
|
+
return possibleVaultPath
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return null
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function _resolveHome (envPath) {
|
|
212
|
+
return envPath[0] === '~' ? path.join(os.homedir(), envPath.slice(1)) : envPath
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function _configVault (options) {
|
|
216
|
+
const debug = Boolean(options && options.debug);
|
|
217
|
+
if (debug) {
|
|
218
|
+
_debug('Loading env from encrypted .env.vault');
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
const parsed = DotenvModule._parseVault(options);
|
|
222
|
+
|
|
223
|
+
let processEnv = process.env;
|
|
224
|
+
if (options && options.processEnv != null) {
|
|
225
|
+
processEnv = options.processEnv;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
DotenvModule.populate(processEnv, parsed, options);
|
|
229
|
+
|
|
230
|
+
return { parsed }
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function configDotenv (options) {
|
|
234
|
+
const dotenvPath = path.resolve(process.cwd(), '.env');
|
|
235
|
+
let encoding = 'utf8';
|
|
236
|
+
const debug = Boolean(options && options.debug);
|
|
237
|
+
|
|
238
|
+
if (options && options.encoding) {
|
|
239
|
+
encoding = options.encoding;
|
|
240
|
+
} else {
|
|
241
|
+
if (debug) {
|
|
242
|
+
_debug('No encoding is specified. UTF-8 is used by default');
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
let optionPaths = [dotenvPath]; // default, look for .env
|
|
247
|
+
if (options && options.path) {
|
|
248
|
+
if (!Array.isArray(options.path)) {
|
|
249
|
+
optionPaths = [_resolveHome(options.path)];
|
|
250
|
+
} else {
|
|
251
|
+
optionPaths = []; // reset default
|
|
252
|
+
for (const filepath of options.path) {
|
|
253
|
+
optionPaths.push(_resolveHome(filepath));
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// Build the parsed data in a temporary object (because we need to return it). Once we have the final
|
|
259
|
+
// parsed data, we will combine it with process.env (or options.processEnv if provided).
|
|
260
|
+
let lastError;
|
|
261
|
+
const parsedAll = {};
|
|
262
|
+
for (const path of optionPaths) {
|
|
263
|
+
try {
|
|
264
|
+
// Specifying an encoding returns a string instead of a buffer
|
|
265
|
+
const parsed = DotenvModule.parse(fs.readFileSync(path, { encoding }));
|
|
266
|
+
|
|
267
|
+
DotenvModule.populate(parsedAll, parsed, options);
|
|
268
|
+
} catch (e) {
|
|
269
|
+
if (debug) {
|
|
270
|
+
_debug(`Failed to load ${path} ${e.message}`);
|
|
271
|
+
}
|
|
272
|
+
lastError = e;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
let processEnv = process.env;
|
|
277
|
+
if (options && options.processEnv != null) {
|
|
278
|
+
processEnv = options.processEnv;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
DotenvModule.populate(processEnv, parsedAll, options);
|
|
282
|
+
|
|
283
|
+
if (lastError) {
|
|
284
|
+
return { parsed: parsedAll, error: lastError }
|
|
285
|
+
} else {
|
|
286
|
+
return { parsed: parsedAll }
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// Populates process.env from .env file
|
|
291
|
+
function config (options) {
|
|
292
|
+
// fallback to original dotenv if DOTENV_KEY is not set
|
|
293
|
+
if (_dotenvKey(options).length === 0) {
|
|
294
|
+
return DotenvModule.configDotenv(options)
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
const vaultPath = _vaultPath(options);
|
|
298
|
+
|
|
299
|
+
// dotenvKey exists but .env.vault file does not exist
|
|
300
|
+
if (!vaultPath) {
|
|
301
|
+
_warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
|
|
302
|
+
|
|
303
|
+
return DotenvModule.configDotenv(options)
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
return DotenvModule._configVault(options)
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
function decrypt (encrypted, keyStr) {
|
|
310
|
+
const key = Buffer.from(keyStr.slice(-64), 'hex');
|
|
311
|
+
let ciphertext = Buffer.from(encrypted, 'base64');
|
|
312
|
+
|
|
313
|
+
const nonce = ciphertext.subarray(0, 12);
|
|
314
|
+
const authTag = ciphertext.subarray(-16);
|
|
315
|
+
ciphertext = ciphertext.subarray(12, -16);
|
|
316
|
+
|
|
317
|
+
try {
|
|
318
|
+
const aesgcm = crypto.createDecipheriv('aes-256-gcm', key, nonce);
|
|
319
|
+
aesgcm.setAuthTag(authTag);
|
|
320
|
+
return `${aesgcm.update(ciphertext)}${aesgcm.final()}`
|
|
321
|
+
} catch (error) {
|
|
322
|
+
const isRange = error instanceof RangeError;
|
|
323
|
+
const invalidKeyLength = error.message === 'Invalid key length';
|
|
324
|
+
const decryptionFailed = error.message === 'Unsupported state or unable to authenticate data';
|
|
325
|
+
|
|
326
|
+
if (isRange || invalidKeyLength) {
|
|
327
|
+
const err = new Error('INVALID_DOTENV_KEY: It must be 64 characters long (or more)');
|
|
328
|
+
err.code = 'INVALID_DOTENV_KEY';
|
|
329
|
+
throw err
|
|
330
|
+
} else if (decryptionFailed) {
|
|
331
|
+
const err = new Error('DECRYPTION_FAILED: Please check your DOTENV_KEY');
|
|
332
|
+
err.code = 'DECRYPTION_FAILED';
|
|
333
|
+
throw err
|
|
334
|
+
} else {
|
|
335
|
+
throw error
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// Populate process.env with parsed values
|
|
341
|
+
function populate (processEnv, parsed, options = {}) {
|
|
342
|
+
const debug = Boolean(options && options.debug);
|
|
343
|
+
const override = Boolean(options && options.override);
|
|
344
|
+
|
|
345
|
+
if (typeof parsed !== 'object') {
|
|
346
|
+
const err = new Error('OBJECT_REQUIRED: Please check the processEnv argument being passed to populate');
|
|
347
|
+
err.code = 'OBJECT_REQUIRED';
|
|
348
|
+
throw err
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
// Set process.env
|
|
352
|
+
for (const key of Object.keys(parsed)) {
|
|
353
|
+
if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
|
|
354
|
+
if (override === true) {
|
|
355
|
+
processEnv[key] = parsed[key];
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
if (debug) {
|
|
359
|
+
if (override === true) {
|
|
360
|
+
_debug(`"${key}" is already defined and WAS overwritten`);
|
|
361
|
+
} else {
|
|
362
|
+
_debug(`"${key}" is already defined and was NOT overwritten`);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
} else {
|
|
366
|
+
processEnv[key] = parsed[key];
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
const DotenvModule = {
|
|
372
|
+
configDotenv,
|
|
373
|
+
_configVault,
|
|
374
|
+
_parseVault,
|
|
375
|
+
config,
|
|
376
|
+
decrypt,
|
|
377
|
+
parse,
|
|
378
|
+
populate
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
main.exports.configDotenv = DotenvModule.configDotenv;
|
|
382
|
+
main.exports._configVault = DotenvModule._configVault;
|
|
383
|
+
main.exports._parseVault = DotenvModule._parseVault;
|
|
384
|
+
main.exports.config = DotenvModule.config;
|
|
385
|
+
main.exports.decrypt = DotenvModule.decrypt;
|
|
386
|
+
main.exports.parse = DotenvModule.parse;
|
|
387
|
+
main.exports.populate = DotenvModule.populate;
|
|
388
|
+
|
|
389
|
+
main.exports = DotenvModule;
|
|
390
|
+
return main.exports;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
var mainExports = requireMain();
|
|
394
|
+
var dotenv = /*@__PURE__*/getDefaultExportFromCjs(mainExports);
|
|
395
|
+
|
|
396
|
+
dotenv.config();
|
|
14
397
|
const { CONSUL_HOST, CONSUL_PORT, CONSUL_SECURE } = process.env;
|
|
15
398
|
if (!CONSUL_HOST) {
|
|
16
399
|
throw new Error("Missing environment variable: CONSUL_HOST");
|
|
@@ -938,10 +1321,6 @@ AxiosError$1.from = (error, code, config, request, response, customProps) => {
|
|
|
938
1321
|
return axiosError;
|
|
939
1322
|
};
|
|
940
1323
|
|
|
941
|
-
function getDefaultExportFromCjs (x) {
|
|
942
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
943
|
-
}
|
|
944
|
-
|
|
945
1324
|
var delayed_stream;
|
|
946
1325
|
var hasRequiredDelayed_stream;
|
|
947
1326
|
|
|
@@ -949,7 +1328,7 @@ function requireDelayed_stream () {
|
|
|
949
1328
|
if (hasRequiredDelayed_stream) return delayed_stream;
|
|
950
1329
|
hasRequiredDelayed_stream = 1;
|
|
951
1330
|
var Stream = stream.Stream;
|
|
952
|
-
var util = require$$1;
|
|
1331
|
+
var util = require$$1$1;
|
|
953
1332
|
|
|
954
1333
|
delayed_stream = DelayedStream;
|
|
955
1334
|
function DelayedStream() {
|
|
@@ -1064,7 +1443,7 @@ var hasRequiredCombined_stream;
|
|
|
1064
1443
|
function requireCombined_stream () {
|
|
1065
1444
|
if (hasRequiredCombined_stream) return combined_stream;
|
|
1066
1445
|
hasRequiredCombined_stream = 1;
|
|
1067
|
-
var util = require$$1;
|
|
1446
|
+
var util = require$$1$1;
|
|
1068
1447
|
var Stream = stream.Stream;
|
|
1069
1448
|
var DelayedStream = requireDelayed_stream();
|
|
1070
1449
|
|
|
@@ -12021,7 +12400,7 @@ function requireMimeTypes () {
|
|
|
12021
12400
|
*/
|
|
12022
12401
|
|
|
12023
12402
|
var db = requireMimeDb();
|
|
12024
|
-
var extname = require$$1
|
|
12403
|
+
var extname = require$$1.extname;
|
|
12025
12404
|
|
|
12026
12405
|
/**
|
|
12027
12406
|
* Module variables.
|
|
@@ -13761,12 +14140,12 @@ function requireForm_data () {
|
|
|
13761
14140
|
if (hasRequiredForm_data) return form_data;
|
|
13762
14141
|
hasRequiredForm_data = 1;
|
|
13763
14142
|
var CombinedStream = requireCombined_stream();
|
|
13764
|
-
var util = require$$1;
|
|
13765
|
-
var path = require$$1
|
|
13766
|
-
var http = require$$3;
|
|
13767
|
-
var https = require$$4;
|
|
13768
|
-
var parseUrl = require$$0$
|
|
13769
|
-
var fs = require$$
|
|
14143
|
+
var util = require$$1$1;
|
|
14144
|
+
var path = require$$1;
|
|
14145
|
+
var http = require$$3$1;
|
|
14146
|
+
var https = require$$4$1;
|
|
14147
|
+
var parseUrl = require$$0$2.parse;
|
|
14148
|
+
var fs = require$$0$1;
|
|
13770
14149
|
var Stream = stream.Stream;
|
|
13771
14150
|
var mime = requireMimeTypes();
|
|
13772
14151
|
var asynckit = requireAsynckit();
|
|
@@ -14670,7 +15049,7 @@ var transitionalDefaults = {
|
|
|
14670
15049
|
clarifyTimeoutError: false
|
|
14671
15050
|
};
|
|
14672
15051
|
|
|
14673
|
-
var URLSearchParams = require$$0$
|
|
15052
|
+
var URLSearchParams = require$$0$2.URLSearchParams;
|
|
14674
15053
|
|
|
14675
15054
|
const ALPHA = 'abcdefghijklmnopqrstuvwxyz';
|
|
14676
15055
|
|
|
@@ -14686,7 +15065,7 @@ const generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {
|
|
|
14686
15065
|
let str = '';
|
|
14687
15066
|
const {length} = alphabet;
|
|
14688
15067
|
const randomValues = new Uint32Array(size);
|
|
14689
|
-
|
|
15068
|
+
require$$3.randomFillSync(randomValues);
|
|
14690
15069
|
for (let i = 0; i < size; i++) {
|
|
14691
15070
|
str += alphabet[randomValues[i] % length];
|
|
14692
15071
|
}
|
|
@@ -14752,12 +15131,12 @@ const hasStandardBrowserWebWorkerEnv = (() => {
|
|
|
14752
15131
|
const origin = hasBrowserEnv && window.location.href || 'http://localhost';
|
|
14753
15132
|
|
|
14754
15133
|
var utils = /*#__PURE__*/Object.freeze({
|
|
14755
|
-
|
|
14756
|
-
|
|
14757
|
-
|
|
14758
|
-
|
|
14759
|
-
|
|
14760
|
-
|
|
15134
|
+
__proto__: null,
|
|
15135
|
+
hasBrowserEnv: hasBrowserEnv,
|
|
15136
|
+
hasStandardBrowserEnv: hasStandardBrowserEnv,
|
|
15137
|
+
hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
|
|
15138
|
+
navigator: _navigator,
|
|
15139
|
+
origin: origin
|
|
14761
15140
|
});
|
|
14762
15141
|
|
|
14763
15142
|
var platform = {
|
|
@@ -15502,7 +15881,7 @@ function requireProxyFromEnv () {
|
|
|
15502
15881
|
if (hasRequiredProxyFromEnv) return proxyFromEnv$1;
|
|
15503
15882
|
hasRequiredProxyFromEnv = 1;
|
|
15504
15883
|
|
|
15505
|
-
var parseUrl = require$$0$
|
|
15884
|
+
var parseUrl = require$$0$2.parse;
|
|
15506
15885
|
|
|
15507
15886
|
var DEFAULT_PORTS = {
|
|
15508
15887
|
ftp: 21,
|
|
@@ -15645,12 +16024,12 @@ var hasRequiredFollowRedirects;
|
|
|
15645
16024
|
function requireFollowRedirects () {
|
|
15646
16025
|
if (hasRequiredFollowRedirects) return followRedirects$1.exports;
|
|
15647
16026
|
hasRequiredFollowRedirects = 1;
|
|
15648
|
-
var url = require$$0$
|
|
16027
|
+
var url = require$$0$2;
|
|
15649
16028
|
var URL = url.URL;
|
|
15650
|
-
var http = require$$3;
|
|
15651
|
-
var https = require$$4;
|
|
16029
|
+
var http = require$$3$1;
|
|
16030
|
+
var https = require$$4$1;
|
|
15652
16031
|
var Writable = stream.Writable;
|
|
15653
|
-
var assert = require$$4$
|
|
16032
|
+
var assert = require$$4$2;
|
|
15654
16033
|
var debug = requireDebug();
|
|
15655
16034
|
|
|
15656
16035
|
// Preventive platform detection
|
|
@@ -16545,7 +16924,7 @@ const readBlob = async function* (blob) {
|
|
|
16545
16924
|
|
|
16546
16925
|
const BOUNDARY_ALPHABET = platform.ALPHABET.ALPHA_DIGIT + '-_';
|
|
16547
16926
|
|
|
16548
|
-
const textEncoder = typeof TextEncoder === 'function' ? new TextEncoder() : new require$$1.TextEncoder();
|
|
16927
|
+
const textEncoder = typeof TextEncoder === 'function' ? new TextEncoder() : new require$$1$1.TextEncoder();
|
|
16549
16928
|
|
|
16550
16929
|
const CRLF = '\r\n';
|
|
16551
16930
|
const CRLF_BYTES = textEncoder.encode(CRLF);
|
|
@@ -17102,7 +17481,7 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
17102
17481
|
|
|
17103
17482
|
if (!headers.hasContentLength()) {
|
|
17104
17483
|
try {
|
|
17105
|
-
const knownLength = await require$$1.promisify(data.getLength).call(data);
|
|
17484
|
+
const knownLength = await require$$1$1.promisify(data.getLength).call(data);
|
|
17106
17485
|
Number.isFinite(knownLength) && knownLength >= 0 && headers.setContentLength(knownLength);
|
|
17107
17486
|
/*eslint no-empty:0*/
|
|
17108
17487
|
} catch (e) {
|
|
@@ -17230,7 +17609,7 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
17230
17609
|
if (config.transport) {
|
|
17231
17610
|
transport = config.transport;
|
|
17232
17611
|
} else if (config.maxRedirects === 0) {
|
|
17233
|
-
transport = isHttpsRequest ? require$$4 : require$$3;
|
|
17612
|
+
transport = isHttpsRequest ? require$$4$1 : require$$3$1;
|
|
17234
17613
|
} else {
|
|
17235
17614
|
if (config.maxRedirects) {
|
|
17236
17615
|
options.maxRedirects = config.maxRedirects;
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-consul-service",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.16",
|
|
4
4
|
"main": "dist/index.cjs.js",
|
|
5
5
|
"module": "dist/index.esm.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "rollup -c",
|
|
9
|
-
"dev": "ts-node src/index.ts"
|
|
9
|
+
"dev": "ts-node src/index.ts",
|
|
10
|
+
"pub": "npm run build && npm version patch && npm publish"
|
|
10
11
|
},
|
|
11
12
|
"keywords": [
|
|
12
13
|
"consul",
|
|
@@ -24,7 +25,8 @@
|
|
|
24
25
|
"dependencies": {
|
|
25
26
|
"axios": "^1.9.0",
|
|
26
27
|
"cache-center": "^1.0.8",
|
|
27
|
-
"consul": "^2.0.1"
|
|
28
|
+
"consul": "^2.0.1",
|
|
29
|
+
"dotenv": "^16.5.0"
|
|
28
30
|
},
|
|
29
31
|
"devDependencies": {
|
|
30
32
|
"@rollup/plugin-commonjs": "^28.0.3",
|