@vettvangur/design-system 2.0.32 → 2.0.33

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.
Files changed (3) hide show
  1. package/LICENSE +11 -11
  2. package/dist/index.js +502 -427
  3. package/package.json +1 -1
package/LICENSE CHANGED
@@ -1,11 +1,11 @@
1
- Portions of this package rely on third-party open source libraries, which are licensed under their respective open source licenses (such as MIT). Use of those libraries is governed solely by their respective license terms.
2
-
3
- All original code in this repository is licensed under the terms below:
4
-
5
- ---
6
-
7
- Copyright (c) 2025 Vettvangur
8
-
9
- This software is provided for personal or internal non-commercial use only. You may not modify, distribute, sublicense, or use this software in commercial products or services without explicit written permission from Vettvangur.
10
-
11
- All rights reserved.
1
+ Portions of this package rely on third-party open source libraries, which are licensed under their respective open source licenses (such as MIT). Use of those libraries is governed solely by their respective license terms.
2
+
3
+ All original code in this repository is licensed under the terms below:
4
+
5
+ ---
6
+
7
+ Copyright (c) 2025 Vettvangur
8
+
9
+ This software is provided for personal or internal non-commercial use only. You may not modify, distribute, sublicense, or use this software in commercial products or services without explicit written permission from Vettvangur.
10
+
11
+ All rights reserved.
package/dist/index.js CHANGED
@@ -20,450 +20,525 @@ var require$$4 = {
20
20
  version: version};
21
21
 
22
22
  var hasRequiredMain;
23
- function requireMain() {
24
- if (hasRequiredMain) return main.exports;
25
- hasRequiredMain = 1;
26
- const fs = require$$0;
27
- const path = require$$1;
28
- const os = require$$2;
29
- const crypto = require$$3;
30
- const packageJson = require$$4;
31
- const version = packageJson.version;
32
-
33
- // Array of tips to display randomly
34
- const TIPS = ['🔐 encrypt with Dotenvx: https://dotenvx.com', '🔐 prevent committing .env to code: https://dotenvx.com/precommit', '🔐 prevent building .env in docker: https://dotenvx.com/prebuild', '📡 add observability to secrets: https://dotenvx.com/ops', '👥 sync secrets across teammates & machines: https://dotenvx.com/ops', '🗂️ backup and recover secrets: https://dotenvx.com/ops', '✅ audit secrets and track compliance: https://dotenvx.com/ops', '🔄 add secrets lifecycle management: https://dotenvx.com/ops', '🔑 add access controls to secrets: https://dotenvx.com/ops', '🛠️ run anywhere with `dotenvx run -- yourcommand`', '⚙️ specify custom .env file path with { path: \'/custom/path/.env\' }', '⚙️ enable debug logging with { debug: true }', '⚙️ override existing env vars with { override: true }', '⚙️ suppress all logs with { quiet: true }', '⚙️ write to custom object with { processEnv: myObject }', '⚙️ load multiple .env files with { path: [\'.env.local\', \'.env\'] }'];
35
-
36
- // Get a random tip from the tips array
37
- function _getRandomTip() {
38
- return TIPS[Math.floor(Math.random() * TIPS.length)];
39
- }
40
- function parseBoolean(value) {
41
- if (typeof value === 'string') {
42
- return !['false', '0', 'no', 'off', ''].includes(value.toLowerCase());
43
- }
44
- return Boolean(value);
45
- }
46
- function supportsAnsi() {
47
- return process.stdout.isTTY; // && process.env.TERM !== 'dumb'
48
- }
49
- function dim(text) {
50
- return supportsAnsi() ? `\x1b[2m${text}\x1b[0m` : text;
51
- }
52
- const LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
53
-
54
- // Parse src into an Object
55
- function parse(src) {
56
- const obj = {};
57
-
58
- // Convert buffer to string
59
- let lines = src.toString();
60
-
61
- // Convert line breaks to same format
62
- lines = lines.replace(/\r\n?/mg, '\n');
63
- let match;
64
- while ((match = LINE.exec(lines)) != null) {
65
- const key = match[1];
66
23
 
67
- // Default undefined or null to empty string
68
- let value = match[2] || '';
69
-
70
- // Remove whitespace
71
- value = value.trim();
72
-
73
- // Check if double quoted
74
- const maybeQuote = value[0];
75
-
76
- // Remove surrounding quotes
77
- value = value.replace(/^(['"`])([\s\S]*)\1$/mg, '$2');
24
+ function requireMain () {
25
+ if (hasRequiredMain) return main.exports;
26
+ hasRequiredMain = 1;
27
+ const fs = require$$0;
28
+ const path = require$$1;
29
+ const os = require$$2;
30
+ const crypto = require$$3;
31
+ const packageJson = require$$4;
32
+
33
+ const version = packageJson.version;
34
+
35
+ // Array of tips to display randomly
36
+ const TIPS = [
37
+ '🔐 encrypt with Dotenvx: https://dotenvx.com',
38
+ '🔐 prevent committing .env to code: https://dotenvx.com/precommit',
39
+ '🔐 prevent building .env in docker: https://dotenvx.com/prebuild',
40
+ '📡 add observability to secrets: https://dotenvx.com/ops',
41
+ '👥 sync secrets across teammates & machines: https://dotenvx.com/ops',
42
+ '🗂️ backup and recover secrets: https://dotenvx.com/ops',
43
+ '✅ audit secrets and track compliance: https://dotenvx.com/ops',
44
+ '🔄 add secrets lifecycle management: https://dotenvx.com/ops',
45
+ '🔑 add access controls to secrets: https://dotenvx.com/ops',
46
+ '🛠️ run anywhere with `dotenvx run -- yourcommand`',
47
+ '⚙️ specify custom .env file path with { path: \'/custom/path/.env\' }',
48
+ '⚙️ enable debug logging with { debug: true }',
49
+ '⚙️ override existing env vars with { override: true }',
50
+ '⚙️ suppress all logs with { quiet: true }',
51
+ '⚙️ write to custom object with { processEnv: myObject }',
52
+ '⚙️ load multiple .env files with { path: [\'.env.local\', \'.env\'] }'
53
+ ];
54
+
55
+ // Get a random tip from the tips array
56
+ function _getRandomTip () {
57
+ return TIPS[Math.floor(Math.random() * TIPS.length)]
58
+ }
59
+
60
+ function parseBoolean (value) {
61
+ if (typeof value === 'string') {
62
+ return !['false', '0', 'no', 'off', ''].includes(value.toLowerCase())
63
+ }
64
+ return Boolean(value)
65
+ }
66
+
67
+ function supportsAnsi () {
68
+ return process.stdout.isTTY // && process.env.TERM !== 'dumb'
69
+ }
70
+
71
+ function dim (text) {
72
+ return supportsAnsi() ? `\x1b[2m${text}\x1b[0m` : text
73
+ }
74
+
75
+ const LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
76
+
77
+ // Parse src into an Object
78
+ function parse (src) {
79
+ const obj = {};
80
+
81
+ // Convert buffer to string
82
+ let lines = src.toString();
83
+
84
+ // Convert line breaks to same format
85
+ lines = lines.replace(/\r\n?/mg, '\n');
86
+
87
+ let match;
88
+ while ((match = LINE.exec(lines)) != null) {
89
+ const key = match[1];
90
+
91
+ // Default undefined or null to empty string
92
+ let value = (match[2] || '');
93
+
94
+ // Remove whitespace
95
+ value = value.trim();
96
+
97
+ // Check if double quoted
98
+ const maybeQuote = value[0];
99
+
100
+ // Remove surrounding quotes
101
+ value = value.replace(/^(['"`])([\s\S]*)\1$/mg, '$2');
102
+
103
+ // Expand newlines if double quoted
104
+ if (maybeQuote === '"') {
105
+ value = value.replace(/\\n/g, '\n');
106
+ value = value.replace(/\\r/g, '\r');
107
+ }
108
+
109
+ // Add to object
110
+ obj[key] = value;
111
+ }
112
+
113
+ return obj
114
+ }
115
+
116
+ function _parseVault (options) {
117
+ options = options || {};
118
+
119
+ const vaultPath = _vaultPath(options);
120
+ options.path = vaultPath; // parse .env.vault
121
+ const result = DotenvModule.configDotenv(options);
122
+ if (!result.parsed) {
123
+ const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
124
+ err.code = 'MISSING_DATA';
125
+ throw err
126
+ }
127
+
128
+ // handle scenario for comma separated keys - for use with key rotation
129
+ // example: DOTENV_KEY="dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=prod,dotenv://:key_7890@dotenvx.com/vault/.env.vault?environment=prod"
130
+ const keys = _dotenvKey(options).split(',');
131
+ const length = keys.length;
132
+
133
+ let decrypted;
134
+ for (let i = 0; i < length; i++) {
135
+ try {
136
+ // Get full key
137
+ const key = keys[i].trim();
138
+
139
+ // Get instructions for decrypt
140
+ const attrs = _instructions(result, key);
141
+
142
+ // Decrypt
143
+ decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
144
+
145
+ break
146
+ } catch (error) {
147
+ // last key
148
+ if (i + 1 >= length) {
149
+ throw error
150
+ }
151
+ // try next key
152
+ }
153
+ }
154
+
155
+ // Parse decrypted .env string
156
+ return DotenvModule.parse(decrypted)
157
+ }
158
+
159
+ function _warn (message) {
160
+ console.error(`[dotenv@${version}][WARN] ${message}`);
161
+ }
162
+
163
+ function _debug (message) {
164
+ console.log(`[dotenv@${version}][DEBUG] ${message}`);
165
+ }
166
+
167
+ function _log (message) {
168
+ console.log(`[dotenv@${version}] ${message}`);
169
+ }
170
+
171
+ function _dotenvKey (options) {
172
+ // prioritize developer directly setting options.DOTENV_KEY
173
+ if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
174
+ return options.DOTENV_KEY
175
+ }
176
+
177
+ // secondary infra already contains a DOTENV_KEY environment variable
178
+ if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
179
+ return process.env.DOTENV_KEY
180
+ }
181
+
182
+ // fallback to empty string
183
+ return ''
184
+ }
185
+
186
+ function _instructions (result, dotenvKey) {
187
+ // Parse DOTENV_KEY. Format is a URI
188
+ let uri;
189
+ try {
190
+ uri = new URL(dotenvKey);
191
+ } catch (error) {
192
+ if (error.code === 'ERR_INVALID_URL') {
193
+ 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');
194
+ err.code = 'INVALID_DOTENV_KEY';
195
+ throw err
196
+ }
197
+
198
+ throw error
199
+ }
200
+
201
+ // Get decrypt key
202
+ const key = uri.password;
203
+ if (!key) {
204
+ const err = new Error('INVALID_DOTENV_KEY: Missing key part');
205
+ err.code = 'INVALID_DOTENV_KEY';
206
+ throw err
207
+ }
208
+
209
+ // Get environment
210
+ const environment = uri.searchParams.get('environment');
211
+ if (!environment) {
212
+ const err = new Error('INVALID_DOTENV_KEY: Missing environment part');
213
+ err.code = 'INVALID_DOTENV_KEY';
214
+ throw err
215
+ }
216
+
217
+ // Get ciphertext payload
218
+ const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
219
+ const ciphertext = result.parsed[environmentKey]; // DOTENV_VAULT_PRODUCTION
220
+ if (!ciphertext) {
221
+ const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
222
+ err.code = 'NOT_FOUND_DOTENV_ENVIRONMENT';
223
+ throw err
224
+ }
225
+
226
+ return { ciphertext, key }
227
+ }
228
+
229
+ function _vaultPath (options) {
230
+ let possibleVaultPath = null;
231
+
232
+ if (options && options.path && options.path.length > 0) {
233
+ if (Array.isArray(options.path)) {
234
+ for (const filepath of options.path) {
235
+ if (fs.existsSync(filepath)) {
236
+ possibleVaultPath = filepath.endsWith('.vault') ? filepath : `${filepath}.vault`;
237
+ }
238
+ }
239
+ } else {
240
+ possibleVaultPath = options.path.endsWith('.vault') ? options.path : `${options.path}.vault`;
241
+ }
242
+ } else {
243
+ possibleVaultPath = path.resolve(process.cwd(), '.env.vault');
244
+ }
245
+
246
+ if (fs.existsSync(possibleVaultPath)) {
247
+ return possibleVaultPath
248
+ }
249
+
250
+ return null
251
+ }
252
+
253
+ function _resolveHome (envPath) {
254
+ return envPath[0] === '~' ? path.join(os.homedir(), envPath.slice(1)) : envPath
255
+ }
256
+
257
+ function _configVault (options) {
258
+ const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || (options && options.debug));
259
+ const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || (options && options.quiet));
260
+
261
+ if (debug || !quiet) {
262
+ _log('Loading env from encrypted .env.vault');
263
+ }
264
+
265
+ const parsed = DotenvModule._parseVault(options);
266
+
267
+ let processEnv = process.env;
268
+ if (options && options.processEnv != null) {
269
+ processEnv = options.processEnv;
270
+ }
271
+
272
+ DotenvModule.populate(processEnv, parsed, options);
273
+
274
+ return { parsed }
275
+ }
276
+
277
+ function configDotenv (options) {
278
+ const dotenvPath = path.resolve(process.cwd(), '.env');
279
+ let encoding = 'utf8';
280
+ let processEnv = process.env;
281
+ if (options && options.processEnv != null) {
282
+ processEnv = options.processEnv;
283
+ }
284
+ let debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || (options && options.debug));
285
+ let quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || (options && options.quiet));
286
+
287
+ if (options && options.encoding) {
288
+ encoding = options.encoding;
289
+ } else {
290
+ if (debug) {
291
+ _debug('No encoding is specified. UTF-8 is used by default');
292
+ }
293
+ }
294
+
295
+ let optionPaths = [dotenvPath]; // default, look for .env
296
+ if (options && options.path) {
297
+ if (!Array.isArray(options.path)) {
298
+ optionPaths = [_resolveHome(options.path)];
299
+ } else {
300
+ optionPaths = []; // reset default
301
+ for (const filepath of options.path) {
302
+ optionPaths.push(_resolveHome(filepath));
303
+ }
304
+ }
305
+ }
306
+
307
+ // Build the parsed data in a temporary object (because we need to return it). Once we have the final
308
+ // parsed data, we will combine it with process.env (or options.processEnv if provided).
309
+ let lastError;
310
+ const parsedAll = {};
311
+ for (const path of optionPaths) {
312
+ try {
313
+ // Specifying an encoding returns a string instead of a buffer
314
+ const parsed = DotenvModule.parse(fs.readFileSync(path, { encoding }));
315
+
316
+ DotenvModule.populate(parsedAll, parsed, options);
317
+ } catch (e) {
318
+ if (debug) {
319
+ _debug(`Failed to load ${path} ${e.message}`);
320
+ }
321
+ lastError = e;
322
+ }
323
+ }
324
+
325
+ const populated = DotenvModule.populate(processEnv, parsedAll, options);
326
+
327
+ // handle user settings DOTENV_CONFIG_ options inside .env file(s)
328
+ debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || debug);
329
+ quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || quiet);
330
+
331
+ if (debug || !quiet) {
332
+ const keysCount = Object.keys(populated).length;
333
+ const shortPaths = [];
334
+ for (const filePath of optionPaths) {
335
+ try {
336
+ const relative = path.relative(process.cwd(), filePath);
337
+ shortPaths.push(relative);
338
+ } catch (e) {
339
+ if (debug) {
340
+ _debug(`Failed to load ${filePath} ${e.message}`);
341
+ }
342
+ lastError = e;
343
+ }
344
+ }
345
+
346
+ _log(`injecting env (${keysCount}) from ${shortPaths.join(',')} ${dim(`-- tip: ${_getRandomTip()}`)}`);
347
+ }
348
+
349
+ if (lastError) {
350
+ return { parsed: parsedAll, error: lastError }
351
+ } else {
352
+ return { parsed: parsedAll }
353
+ }
354
+ }
355
+
356
+ // Populates process.env from .env file
357
+ function config (options) {
358
+ // fallback to original dotenv if DOTENV_KEY is not set
359
+ if (_dotenvKey(options).length === 0) {
360
+ return DotenvModule.configDotenv(options)
361
+ }
362
+
363
+ const vaultPath = _vaultPath(options);
364
+
365
+ // dotenvKey exists but .env.vault file does not exist
366
+ if (!vaultPath) {
367
+ _warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
368
+
369
+ return DotenvModule.configDotenv(options)
370
+ }
371
+
372
+ return DotenvModule._configVault(options)
373
+ }
374
+
375
+ function decrypt (encrypted, keyStr) {
376
+ const key = Buffer.from(keyStr.slice(-64), 'hex');
377
+ let ciphertext = Buffer.from(encrypted, 'base64');
378
+
379
+ const nonce = ciphertext.subarray(0, 12);
380
+ const authTag = ciphertext.subarray(-16);
381
+ ciphertext = ciphertext.subarray(12, -16);
382
+
383
+ try {
384
+ const aesgcm = crypto.createDecipheriv('aes-256-gcm', key, nonce);
385
+ aesgcm.setAuthTag(authTag);
386
+ return `${aesgcm.update(ciphertext)}${aesgcm.final()}`
387
+ } catch (error) {
388
+ const isRange = error instanceof RangeError;
389
+ const invalidKeyLength = error.message === 'Invalid key length';
390
+ const decryptionFailed = error.message === 'Unsupported state or unable to authenticate data';
391
+
392
+ if (isRange || invalidKeyLength) {
393
+ const err = new Error('INVALID_DOTENV_KEY: It must be 64 characters long (or more)');
394
+ err.code = 'INVALID_DOTENV_KEY';
395
+ throw err
396
+ } else if (decryptionFailed) {
397
+ const err = new Error('DECRYPTION_FAILED: Please check your DOTENV_KEY');
398
+ err.code = 'DECRYPTION_FAILED';
399
+ throw err
400
+ } else {
401
+ throw error
402
+ }
403
+ }
404
+ }
405
+
406
+ // Populate process.env with parsed values
407
+ function populate (processEnv, parsed, options = {}) {
408
+ const debug = Boolean(options && options.debug);
409
+ const override = Boolean(options && options.override);
410
+ const populated = {};
411
+
412
+ if (typeof parsed !== 'object') {
413
+ const err = new Error('OBJECT_REQUIRED: Please check the processEnv argument being passed to populate');
414
+ err.code = 'OBJECT_REQUIRED';
415
+ throw err
416
+ }
417
+
418
+ // Set process.env
419
+ for (const key of Object.keys(parsed)) {
420
+ if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
421
+ if (override === true) {
422
+ processEnv[key] = parsed[key];
423
+ populated[key] = parsed[key];
424
+ }
425
+
426
+ if (debug) {
427
+ if (override === true) {
428
+ _debug(`"${key}" is already defined and WAS overwritten`);
429
+ } else {
430
+ _debug(`"${key}" is already defined and was NOT overwritten`);
431
+ }
432
+ }
433
+ } else {
434
+ processEnv[key] = parsed[key];
435
+ populated[key] = parsed[key];
436
+ }
437
+ }
438
+
439
+ return populated
440
+ }
441
+
442
+ const DotenvModule = {
443
+ configDotenv,
444
+ _configVault,
445
+ _parseVault,
446
+ config,
447
+ decrypt,
448
+ parse,
449
+ populate
450
+ };
451
+
452
+ main.exports.configDotenv = DotenvModule.configDotenv;
453
+ main.exports._configVault = DotenvModule._configVault;
454
+ main.exports._parseVault = DotenvModule._parseVault;
455
+ main.exports.config = DotenvModule.config;
456
+ main.exports.decrypt = DotenvModule.decrypt;
457
+ main.exports.parse = DotenvModule.parse;
458
+ main.exports.populate = DotenvModule.populate;
459
+
460
+ main.exports = DotenvModule;
461
+ return main.exports;
462
+ }
78
463
 
79
- // Expand newlines if double quoted
80
- if (maybeQuote === '"') {
81
- value = value.replace(/\\n/g, '\n');
82
- value = value.replace(/\\r/g, '\r');
83
- }
464
+ var envOptions;
465
+ var hasRequiredEnvOptions;
84
466
 
85
- // Add to object
86
- obj[key] = value;
87
- }
88
- return obj;
89
- }
90
- function _parseVault(options) {
91
- options = options || {};
92
- const vaultPath = _vaultPath(options);
93
- options.path = vaultPath; // parse .env.vault
94
- const result = DotenvModule.configDotenv(options);
95
- if (!result.parsed) {
96
- const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
97
- err.code = 'MISSING_DATA';
98
- throw err;
99
- }
467
+ function requireEnvOptions () {
468
+ if (hasRequiredEnvOptions) return envOptions;
469
+ hasRequiredEnvOptions = 1;
470
+ // ../config.js accepts options via environment variables
471
+ const options = {};
100
472
 
101
- // handle scenario for comma separated keys - for use with key rotation
102
- // example: DOTENV_KEY="dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=prod,dotenv://:key_7890@dotenvx.com/vault/.env.vault?environment=prod"
103
- const keys = _dotenvKey(options).split(',');
104
- const length = keys.length;
105
- let decrypted;
106
- for (let i = 0; i < length; i++) {
107
- try {
108
- // Get full key
109
- const key = keys[i].trim();
110
-
111
- // Get instructions for decrypt
112
- const attrs = _instructions(result, key);
113
-
114
- // Decrypt
115
- decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
116
- break;
117
- } catch (error) {
118
- // last key
119
- if (i + 1 >= length) {
120
- throw error;
121
- }
122
- // try next key
123
- }
124
- }
473
+ if (process.env.DOTENV_CONFIG_ENCODING != null) {
474
+ options.encoding = process.env.DOTENV_CONFIG_ENCODING;
475
+ }
125
476
 
126
- // Parse decrypted .env string
127
- return DotenvModule.parse(decrypted);
128
- }
129
- function _warn(message) {
130
- console.error(`[dotenv@${version}][WARN] ${message}`);
131
- }
132
- function _debug(message) {
133
- console.log(`[dotenv@${version}][DEBUG] ${message}`);
134
- }
135
- function _log(message) {
136
- console.log(`[dotenv@${version}] ${message}`);
137
- }
138
- function _dotenvKey(options) {
139
- // prioritize developer directly setting options.DOTENV_KEY
140
- if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
141
- return options.DOTENV_KEY;
142
- }
477
+ if (process.env.DOTENV_CONFIG_PATH != null) {
478
+ options.path = process.env.DOTENV_CONFIG_PATH;
479
+ }
143
480
 
144
- // secondary infra already contains a DOTENV_KEY environment variable
145
- if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
146
- return process.env.DOTENV_KEY;
147
- }
481
+ if (process.env.DOTENV_CONFIG_QUIET != null) {
482
+ options.quiet = process.env.DOTENV_CONFIG_QUIET;
483
+ }
148
484
 
149
- // fallback to empty string
150
- return '';
151
- }
152
- function _instructions(result, dotenvKey) {
153
- // Parse DOTENV_KEY. Format is a URI
154
- let uri;
155
- try {
156
- uri = new URL(dotenvKey);
157
- } catch (error) {
158
- if (error.code === 'ERR_INVALID_URL') {
159
- 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');
160
- err.code = 'INVALID_DOTENV_KEY';
161
- throw err;
162
- }
163
- throw error;
164
- }
485
+ if (process.env.DOTENV_CONFIG_DEBUG != null) {
486
+ options.debug = process.env.DOTENV_CONFIG_DEBUG;
487
+ }
165
488
 
166
- // Get decrypt key
167
- const key = uri.password;
168
- if (!key) {
169
- const err = new Error('INVALID_DOTENV_KEY: Missing key part');
170
- err.code = 'INVALID_DOTENV_KEY';
171
- throw err;
172
- }
489
+ if (process.env.DOTENV_CONFIG_OVERRIDE != null) {
490
+ options.override = process.env.DOTENV_CONFIG_OVERRIDE;
491
+ }
173
492
 
174
- // Get environment
175
- const environment = uri.searchParams.get('environment');
176
- if (!environment) {
177
- const err = new Error('INVALID_DOTENV_KEY: Missing environment part');
178
- err.code = 'INVALID_DOTENV_KEY';
179
- throw err;
180
- }
493
+ if (process.env.DOTENV_CONFIG_DOTENV_KEY != null) {
494
+ options.DOTENV_KEY = process.env.DOTENV_CONFIG_DOTENV_KEY;
495
+ }
181
496
 
182
- // Get ciphertext payload
183
- const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
184
- const ciphertext = result.parsed[environmentKey]; // DOTENV_VAULT_PRODUCTION
185
- if (!ciphertext) {
186
- const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
187
- err.code = 'NOT_FOUND_DOTENV_ENVIRONMENT';
188
- throw err;
189
- }
190
- return {
191
- ciphertext,
192
- key
193
- };
194
- }
195
- function _vaultPath(options) {
196
- let possibleVaultPath = null;
197
- if (options && options.path && options.path.length > 0) {
198
- if (Array.isArray(options.path)) {
199
- for (const filepath of options.path) {
200
- if (fs.existsSync(filepath)) {
201
- possibleVaultPath = filepath.endsWith('.vault') ? filepath : `${filepath}.vault`;
202
- }
203
- }
204
- } else {
205
- possibleVaultPath = options.path.endsWith('.vault') ? options.path : `${options.path}.vault`;
206
- }
207
- } else {
208
- possibleVaultPath = path.resolve(process.cwd(), '.env.vault');
209
- }
210
- if (fs.existsSync(possibleVaultPath)) {
211
- return possibleVaultPath;
212
- }
213
- return null;
214
- }
215
- function _resolveHome(envPath) {
216
- return envPath[0] === '~' ? path.join(os.homedir(), envPath.slice(1)) : envPath;
217
- }
218
- function _configVault(options) {
219
- const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || options && options.debug);
220
- const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || options && options.quiet);
221
- if (debug || !quiet) {
222
- _log('Loading env from encrypted .env.vault');
223
- }
224
- const parsed = DotenvModule._parseVault(options);
225
- let processEnv = process.env;
226
- if (options && options.processEnv != null) {
227
- processEnv = options.processEnv;
228
- }
229
- DotenvModule.populate(processEnv, parsed, options);
230
- return {
231
- parsed
232
- };
233
- }
234
- function configDotenv(options) {
235
- const dotenvPath = path.resolve(process.cwd(), '.env');
236
- let encoding = 'utf8';
237
- let processEnv = process.env;
238
- if (options && options.processEnv != null) {
239
- processEnv = options.processEnv;
240
- }
241
- let debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || options && options.debug);
242
- let quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || options && options.quiet);
243
- if (options && options.encoding) {
244
- encoding = options.encoding;
245
- } else {
246
- if (debug) {
247
- _debug('No encoding is specified. UTF-8 is used by default');
248
- }
249
- }
250
- let optionPaths = [dotenvPath]; // default, look for .env
251
- if (options && options.path) {
252
- if (!Array.isArray(options.path)) {
253
- optionPaths = [_resolveHome(options.path)];
254
- } else {
255
- optionPaths = []; // reset default
256
- for (const filepath of options.path) {
257
- optionPaths.push(_resolveHome(filepath));
258
- }
259
- }
260
- }
261
-
262
- // Build the parsed data in a temporary object (because we need to return it). Once we have the final
263
- // parsed data, we will combine it with process.env (or options.processEnv if provided).
264
- let lastError;
265
- const parsedAll = {};
266
- for (const path of optionPaths) {
267
- try {
268
- // Specifying an encoding returns a string instead of a buffer
269
- const parsed = DotenvModule.parse(fs.readFileSync(path, {
270
- encoding
271
- }));
272
- DotenvModule.populate(parsedAll, parsed, options);
273
- } catch (e) {
274
- if (debug) {
275
- _debug(`Failed to load ${path} ${e.message}`);
276
- }
277
- lastError = e;
278
- }
279
- }
280
- const populated = DotenvModule.populate(processEnv, parsedAll, options);
281
-
282
- // handle user settings DOTENV_CONFIG_ options inside .env file(s)
283
- debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || debug);
284
- quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || quiet);
285
- if (debug || !quiet) {
286
- const keysCount = Object.keys(populated).length;
287
- const shortPaths = [];
288
- for (const filePath of optionPaths) {
289
- try {
290
- const relative = path.relative(process.cwd(), filePath);
291
- shortPaths.push(relative);
292
- } catch (e) {
293
- if (debug) {
294
- _debug(`Failed to load ${filePath} ${e.message}`);
295
- }
296
- lastError = e;
297
- }
298
- }
299
- _log(`injecting env (${keysCount}) from ${shortPaths.join(',')} ${dim(`-- tip: ${_getRandomTip()}`)}`);
300
- }
301
- if (lastError) {
302
- return {
303
- parsed: parsedAll,
304
- error: lastError
305
- };
306
- } else {
307
- return {
308
- parsed: parsedAll
309
- };
310
- }
311
- }
312
-
313
- // Populates process.env from .env file
314
- function config(options) {
315
- // fallback to original dotenv if DOTENV_KEY is not set
316
- if (_dotenvKey(options).length === 0) {
317
- return DotenvModule.configDotenv(options);
318
- }
319
- const vaultPath = _vaultPath(options);
497
+ envOptions = options;
498
+ return envOptions;
499
+ }
320
500
 
321
- // dotenvKey exists but .env.vault file does not exist
322
- if (!vaultPath) {
323
- _warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
324
- return DotenvModule.configDotenv(options);
325
- }
326
- return DotenvModule._configVault(options);
327
- }
328
- function decrypt(encrypted, keyStr) {
329
- const key = Buffer.from(keyStr.slice(-64), 'hex');
330
- let ciphertext = Buffer.from(encrypted, 'base64');
331
- const nonce = ciphertext.subarray(0, 12);
332
- const authTag = ciphertext.subarray(-16);
333
- ciphertext = ciphertext.subarray(12, -16);
334
- try {
335
- const aesgcm = crypto.createDecipheriv('aes-256-gcm', key, nonce);
336
- aesgcm.setAuthTag(authTag);
337
- return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
338
- } catch (error) {
339
- const isRange = error instanceof RangeError;
340
- const invalidKeyLength = error.message === 'Invalid key length';
341
- const decryptionFailed = error.message === 'Unsupported state or unable to authenticate data';
342
- if (isRange || invalidKeyLength) {
343
- const err = new Error('INVALID_DOTENV_KEY: It must be 64 characters long (or more)');
344
- err.code = 'INVALID_DOTENV_KEY';
345
- throw err;
346
- } else if (decryptionFailed) {
347
- const err = new Error('DECRYPTION_FAILED: Please check your DOTENV_KEY');
348
- err.code = 'DECRYPTION_FAILED';
349
- throw err;
350
- } else {
351
- throw error;
352
- }
353
- }
354
- }
501
+ var cliOptions;
502
+ var hasRequiredCliOptions;
355
503
 
356
- // Populate process.env with parsed values
357
- function populate(processEnv, parsed, options = {}) {
358
- const debug = Boolean(options && options.debug);
359
- const override = Boolean(options && options.override);
360
- const populated = {};
361
- if (typeof parsed !== 'object') {
362
- const err = new Error('OBJECT_REQUIRED: Please check the processEnv argument being passed to populate');
363
- err.code = 'OBJECT_REQUIRED';
364
- throw err;
365
- }
504
+ function requireCliOptions () {
505
+ if (hasRequiredCliOptions) return cliOptions;
506
+ hasRequiredCliOptions = 1;
507
+ const re = /^dotenv_config_(encoding|path|quiet|debug|override|DOTENV_KEY)=(.+)$/;
366
508
 
367
- // Set process.env
368
- for (const key of Object.keys(parsed)) {
369
- if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
370
- if (override === true) {
371
- processEnv[key] = parsed[key];
372
- populated[key] = parsed[key];
373
- }
374
- if (debug) {
375
- if (override === true) {
376
- _debug(`"${key}" is already defined and WAS overwritten`);
377
- } else {
378
- _debug(`"${key}" is already defined and was NOT overwritten`);
379
- }
380
- }
381
- } else {
382
- processEnv[key] = parsed[key];
383
- populated[key] = parsed[key];
384
- }
385
- }
386
- return populated;
387
- }
388
- const DotenvModule = {
389
- configDotenv,
390
- _configVault,
391
- _parseVault,
392
- config,
393
- decrypt,
394
- parse,
395
- populate
396
- };
397
- main.exports.configDotenv = DotenvModule.configDotenv;
398
- main.exports._configVault = DotenvModule._configVault;
399
- main.exports._parseVault = DotenvModule._parseVault;
400
- main.exports.config = DotenvModule.config;
401
- main.exports.decrypt = DotenvModule.decrypt;
402
- main.exports.parse = DotenvModule.parse;
403
- main.exports.populate = DotenvModule.populate;
404
- main.exports = DotenvModule;
405
- return main.exports;
406
- }
509
+ cliOptions = function optionMatcher (args) {
510
+ const options = args.reduce(function (acc, cur) {
511
+ const matches = cur.match(re);
512
+ if (matches) {
513
+ acc[matches[1]] = matches[2];
514
+ }
515
+ return acc
516
+ }, {});
407
517
 
408
- var envOptions;
409
- var hasRequiredEnvOptions;
410
- function requireEnvOptions() {
411
- if (hasRequiredEnvOptions) return envOptions;
412
- hasRequiredEnvOptions = 1;
413
- // ../config.js accepts options via environment variables
414
- const options = {};
415
- if (process.env.DOTENV_CONFIG_ENCODING != null) {
416
- options.encoding = process.env.DOTENV_CONFIG_ENCODING;
417
- }
418
- if (process.env.DOTENV_CONFIG_PATH != null) {
419
- options.path = process.env.DOTENV_CONFIG_PATH;
420
- }
421
- if (process.env.DOTENV_CONFIG_QUIET != null) {
422
- options.quiet = process.env.DOTENV_CONFIG_QUIET;
423
- }
424
- if (process.env.DOTENV_CONFIG_DEBUG != null) {
425
- options.debug = process.env.DOTENV_CONFIG_DEBUG;
426
- }
427
- if (process.env.DOTENV_CONFIG_OVERRIDE != null) {
428
- options.override = process.env.DOTENV_CONFIG_OVERRIDE;
429
- }
430
- if (process.env.DOTENV_CONFIG_DOTENV_KEY != null) {
431
- options.DOTENV_KEY = process.env.DOTENV_CONFIG_DOTENV_KEY;
432
- }
433
- envOptions = options;
434
- return envOptions;
435
- }
518
+ if (!('quiet' in options)) {
519
+ options.quiet = 'true';
520
+ }
436
521
 
437
- var cliOptions;
438
- var hasRequiredCliOptions;
439
- function requireCliOptions() {
440
- if (hasRequiredCliOptions) return cliOptions;
441
- hasRequiredCliOptions = 1;
442
- const re = /^dotenv_config_(encoding|path|quiet|debug|override|DOTENV_KEY)=(.+)$/;
443
- cliOptions = function optionMatcher(args) {
444
- const options = args.reduce(function (acc, cur) {
445
- const matches = cur.match(re);
446
- if (matches) {
447
- acc[matches[1]] = matches[2];
448
- }
449
- return acc;
450
- }, {});
451
- if (!('quiet' in options)) {
452
- options.quiet = 'true';
453
- }
454
- return options;
455
- };
456
- return cliOptions;
522
+ return options
523
+ };
524
+ return cliOptions;
457
525
  }
458
526
 
459
527
  var hasRequiredConfig;
460
- function requireConfig() {
461
- if (hasRequiredConfig) return config;
462
- hasRequiredConfig = 1;
463
- (function () {
464
- requireMain().config(Object.assign({}, requireEnvOptions(), requireCliOptions()(process.argv)));
465
- })();
466
- return config;
528
+
529
+ function requireConfig () {
530
+ if (hasRequiredConfig) return config;
531
+ hasRequiredConfig = 1;
532
+ (function () {
533
+ requireMain().config(
534
+ Object.assign(
535
+ {},
536
+ requireEnvOptions(),
537
+ requireCliOptions()(process.argv)
538
+ )
539
+ );
540
+ })();
541
+ return config;
467
542
  }
468
543
 
469
544
  requireConfig();
@@ -2960,7 +3035,7 @@ async function generateNavigation(config, outpath) {
2960
3035
  function renderDesignSystemViewCshtml(projectName) {
2961
3036
  return `@* AUTO-GENERATED - DO NOT EDIT BY HAND *@
2962
3037
  @{
2963
- Layout = "${ProjectName}Master.cshtml";
3038
+ Layout = "${projectName}Master.cshtml";
2964
3039
  // This template will used later, right now users are redirected to /design-system/colors
2965
3040
  }
2966
3041
  <section class="ds">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vettvangur/design-system",
3
- "version": "2.0.32",
3
+ "version": "2.0.33",
4
4
  "description": "",
5
5
  "access": "public",
6
6
  "type": "module",