@uniformdev/redirect 19.17.0 → 19.20.0

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.d.ts CHANGED
@@ -110,6 +110,7 @@ declare class RedirectClient extends ApiClient<RedirectClientOptions> {
110
110
  * @param options - Different options available to the redirect engine
111
111
  */
112
112
  private static processDefinitionToResults;
113
+ static validateRedirect(url: string, redirectDefinition: RedirectDefinition['redirect']): boolean;
113
114
  static getTargetVariableExpandedUrl(url: string, redirectDefinition: RedirectDefinition['redirect'], isVariable?: (pathSegment: string) => boolean): string;
114
115
  private static mergeQueryStrings;
115
116
  private static getSourceVariables;
package/dist/index.esm.js CHANGED
@@ -240,8 +240,8 @@ var _RedirectClient = class extends ApiClient {
240
240
  if (result)
241
241
  return result;
242
242
  }
243
- const ret = this.assembleTrie(options);
244
- (_b = this.options.dataCache) == null ? void 0 : _b.set(key, ret, () => this.assembleTrie(options));
243
+ const ret = this.assembleTrie(projectId);
244
+ (_b = this.options.dataCache) == null ? void 0 : _b.set(key, ret, () => this.assembleTrie(projectId));
245
245
  return ret;
246
246
  };
247
247
  this.resetRedirectTrieDataCache = async () => {
@@ -342,7 +342,7 @@ var _RedirectClient = class extends ApiClient {
342
342
  }
343
343
  }
344
344
  }
345
- async assembleTrie(options) {
345
+ async assembleTrie(projectId, options) {
346
346
  const trie = new PathTrie();
347
347
  for await (const redirect of this.getAllRedirects()) {
348
348
  const path = processUrl(
@@ -406,7 +406,7 @@ var _RedirectClient = class extends ApiClient {
406
406
  definition = trie.find(processedUrl.path, bestMatch);
407
407
  }
408
408
  if (definition == null ? void 0 : definition.length) {
409
- return definition.map(
409
+ return definition.filter((def) => _RedirectClient.validateRedirect(url, def.data.redirect)).map(
410
410
  (def) => this.processDefinitionToResults(processedUrl, def.data, def.variables, options)
411
411
  ).filter((r) => Boolean(r));
412
412
  }
@@ -440,6 +440,23 @@ var _RedirectClient = class extends ApiClient {
440
440
  }, finalUrl) : void 0
441
441
  };
442
442
  }
443
+ static validateRedirect(url, redirectDefinition) {
444
+ const processedSource = processUrl(redirectDefinition.sourceUrl);
445
+ const processedUrl = processUrl(url);
446
+ if (redirectDefinition.sourceMustMatchDomain && processedSource.domain !== processedUrl.domain)
447
+ return false;
448
+ if (processedSource.query && !processedUrl.query)
449
+ return false;
450
+ if (processedSource.query && processedUrl.query) {
451
+ const sourceqs = new URLSearchParams(processedSource.query);
452
+ const urlqs = new URLSearchParams(processedUrl.query);
453
+ for (const [key] of sourceqs) {
454
+ if (!urlqs.has(key) || urlqs.get(key) !== sourceqs.get(key))
455
+ return false;
456
+ }
457
+ }
458
+ return true;
459
+ }
443
460
  static getTargetVariableExpandedUrl(url, redirectDefinition, isVariable) {
444
461
  const processedTarget = processUrl(redirectDefinition.targetUrl);
445
462
  const processedSource = processUrl(redirectDefinition.sourceUrl);
@@ -501,7 +518,7 @@ var UncachedRedirectClient = class extends RedirectClient {
501
518
 
502
519
  // src/util/RedirectFileConverter.ts
503
520
  var getDefaultClient = async () => {
504
- const dotenv = await import("./main-NHOL4NFR.mjs");
521
+ const dotenv = await import("./main-DHQ5ANFI.mjs");
505
522
  dotenv.config();
506
523
  return new RedirectClient({
507
524
  apiKey: process.env.UNIFORM_API_KEY,
package/dist/index.js CHANGED
@@ -30,19 +30,19 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
30
30
  ));
31
31
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
32
 
33
- // ../../node_modules/.pnpm/dotenv@16.0.3/node_modules/dotenv/package.json
33
+ // ../../node_modules/.pnpm/dotenv@16.1.3/node_modules/dotenv/package.json
34
34
  var require_package = __commonJS({
35
- "../../node_modules/.pnpm/dotenv@16.0.3/node_modules/dotenv/package.json"(exports, module2) {
35
+ "../../node_modules/.pnpm/dotenv@16.1.3/node_modules/dotenv/package.json"(exports, module2) {
36
36
  module2.exports = {
37
37
  name: "dotenv",
38
- version: "16.0.3",
38
+ version: "16.1.3",
39
39
  description: "Loads environment variables from .env file",
40
40
  main: "lib/main.js",
41
41
  types: "lib/main.d.ts",
42
42
  exports: {
43
43
  ".": {
44
- require: "./lib/main.js",
45
44
  types: "./lib/main.d.ts",
45
+ require: "./lib/main.js",
46
46
  default: "./lib/main.js"
47
47
  },
48
48
  "./config": "./config.js",
@@ -66,6 +66,7 @@ var require_package = __commonJS({
66
66
  type: "git",
67
67
  url: "git://github.com/motdotla/dotenv.git"
68
68
  },
69
+ funding: "https://github.com/motdotla/dotenv?sponsor=1",
69
70
  keywords: [
70
71
  "dotenv",
71
72
  "env",
@@ -78,30 +79,34 @@ var require_package = __commonJS({
78
79
  readmeFilename: "README.md",
79
80
  license: "BSD-2-Clause",
80
81
  devDependencies: {
81
- "@types/node": "^17.0.9",
82
+ "@definitelytyped/dtslint": "^0.0.133",
83
+ "@types/node": "^18.11.3",
82
84
  decache: "^4.6.1",
83
- dtslint: "^3.7.0",
84
- sinon: "^12.0.1",
85
- standard: "^16.0.4",
85
+ sinon: "^14.0.1",
86
+ standard: "^17.0.0",
86
87
  "standard-markdown": "^7.1.0",
87
- "standard-version": "^9.3.2",
88
- tap: "^15.1.6",
88
+ "standard-version": "^9.5.0",
89
+ tap: "^16.3.0",
89
90
  tar: "^6.1.11",
90
- typescript: "^4.5.4"
91
+ typescript: "^4.8.4"
91
92
  },
92
93
  engines: {
93
94
  node: ">=12"
95
+ },
96
+ browser: {
97
+ fs: false
94
98
  }
95
99
  };
96
100
  }
97
101
  });
98
102
 
99
- // ../../node_modules/.pnpm/dotenv@16.0.3/node_modules/dotenv/lib/main.js
103
+ // ../../node_modules/.pnpm/dotenv@16.1.3/node_modules/dotenv/lib/main.js
100
104
  var require_main = __commonJS({
101
- "../../node_modules/.pnpm/dotenv@16.0.3/node_modules/dotenv/lib/main.js"(exports, module2) {
105
+ "../../node_modules/.pnpm/dotenv@16.1.3/node_modules/dotenv/lib/main.js"(exports, module2) {
102
106
  var fs = require("fs");
103
107
  var path = require("path");
104
108
  var os = require("os");
109
+ var crypto = require("crypto");
105
110
  var packageJson = require_package();
106
111
  var version = packageJson.version;
107
112
  var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
@@ -124,17 +129,89 @@ var require_main = __commonJS({
124
129
  }
125
130
  return obj;
126
131
  }
132
+ function _parseVault(options) {
133
+ const vaultPath = _vaultPath(options);
134
+ const result = DotenvModule.configDotenv({ path: vaultPath });
135
+ if (!result.parsed) {
136
+ throw new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
137
+ }
138
+ const keys = _dotenvKey().split(",");
139
+ const length = keys.length;
140
+ let decrypted;
141
+ for (let i = 0; i < length; i++) {
142
+ try {
143
+ const key = keys[i].trim();
144
+ const attrs = _instructions(result, key);
145
+ decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
146
+ break;
147
+ } catch (error) {
148
+ if (i + 1 >= length) {
149
+ throw error;
150
+ }
151
+ }
152
+ }
153
+ return DotenvModule.parse(decrypted);
154
+ }
127
155
  function _log(message) {
156
+ console.log(`[dotenv@${version}][INFO] ${message}`);
157
+ }
158
+ function _warn(message) {
159
+ console.log(`[dotenv@${version}][WARN] ${message}`);
160
+ }
161
+ function _debug(message) {
128
162
  console.log(`[dotenv@${version}][DEBUG] ${message}`);
129
163
  }
164
+ function _dotenvKey() {
165
+ if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
166
+ return process.env.DOTENV_KEY;
167
+ }
168
+ return "";
169
+ }
170
+ function _instructions(result, dotenvKey) {
171
+ let uri;
172
+ try {
173
+ uri = new URL(dotenvKey);
174
+ } catch (error) {
175
+ if (error.code === "ERR_INVALID_URL") {
176
+ throw new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenv.org/vault/.env.vault?environment=development");
177
+ }
178
+ throw error;
179
+ }
180
+ const key = uri.password;
181
+ if (!key) {
182
+ throw new Error("INVALID_DOTENV_KEY: Missing key part");
183
+ }
184
+ const environment = uri.searchParams.get("environment");
185
+ if (!environment) {
186
+ throw new Error("INVALID_DOTENV_KEY: Missing environment part");
187
+ }
188
+ const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
189
+ const ciphertext = result.parsed[environmentKey];
190
+ if (!ciphertext) {
191
+ throw new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
192
+ }
193
+ return { ciphertext, key };
194
+ }
195
+ function _vaultPath(options) {
196
+ let dotenvPath = path.resolve(process.cwd(), ".env");
197
+ if (options && options.path && options.path.length > 0) {
198
+ dotenvPath = options.path;
199
+ }
200
+ return dotenvPath.endsWith(".vault") ? dotenvPath : `${dotenvPath}.vault`;
201
+ }
130
202
  function _resolveHome(envPath) {
131
203
  return envPath[0] === "~" ? path.join(os.homedir(), envPath.slice(1)) : envPath;
132
204
  }
133
- function config(options) {
205
+ function _configVault(options) {
206
+ _log("Loading env from encrypted .env.vault");
207
+ const parsed = DotenvModule._parseVault(options);
208
+ DotenvModule.populate(process.env, parsed, options);
209
+ return { parsed };
210
+ }
211
+ function configDotenv(options) {
134
212
  let dotenvPath = path.resolve(process.cwd(), ".env");
135
213
  let encoding = "utf8";
136
214
  const debug = Boolean(options && options.debug);
137
- const override = Boolean(options && options.override);
138
215
  if (options) {
139
216
  if (options.path != null) {
140
217
  dotenvPath = _resolveHome(options.path);
@@ -145,36 +222,92 @@ var require_main = __commonJS({
145
222
  }
146
223
  try {
147
224
  const parsed = DotenvModule.parse(fs.readFileSync(dotenvPath, { encoding }));
148
- Object.keys(parsed).forEach(function(key) {
149
- if (!Object.prototype.hasOwnProperty.call(process.env, key)) {
150
- process.env[key] = parsed[key];
151
- } else {
152
- if (override === true) {
153
- process.env[key] = parsed[key];
154
- }
155
- if (debug) {
156
- if (override === true) {
157
- _log(`"${key}" is already defined in \`process.env\` and WAS overwritten`);
158
- } else {
159
- _log(`"${key}" is already defined in \`process.env\` and was NOT overwritten`);
160
- }
161
- }
162
- }
163
- });
225
+ DotenvModule.populate(process.env, parsed, options);
164
226
  return { parsed };
165
227
  } catch (e) {
166
228
  if (debug) {
167
- _log(`Failed to load ${dotenvPath} ${e.message}`);
229
+ _debug(`Failed to load ${dotenvPath} ${e.message}`);
168
230
  }
169
231
  return { error: e };
170
232
  }
171
233
  }
234
+ function config(options) {
235
+ const vaultPath = _vaultPath(options);
236
+ if (_dotenvKey().length === 0) {
237
+ return DotenvModule.configDotenv(options);
238
+ }
239
+ if (!fs.existsSync(vaultPath)) {
240
+ _warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
241
+ return DotenvModule.configDotenv(options);
242
+ }
243
+ return DotenvModule._configVault(options);
244
+ }
245
+ function decrypt(encrypted, keyStr) {
246
+ const key = Buffer.from(keyStr.slice(-64), "hex");
247
+ let ciphertext = Buffer.from(encrypted, "base64");
248
+ const nonce = ciphertext.slice(0, 12);
249
+ const authTag = ciphertext.slice(-16);
250
+ ciphertext = ciphertext.slice(12, -16);
251
+ try {
252
+ const aesgcm = crypto.createDecipheriv("aes-256-gcm", key, nonce);
253
+ aesgcm.setAuthTag(authTag);
254
+ return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
255
+ } catch (error) {
256
+ const isRange = error instanceof RangeError;
257
+ const invalidKeyLength = error.message === "Invalid key length";
258
+ const decryptionFailed = error.message === "Unsupported state or unable to authenticate data";
259
+ if (isRange || invalidKeyLength) {
260
+ const msg = "INVALID_DOTENV_KEY: It must be 64 characters long (or more)";
261
+ throw new Error(msg);
262
+ } else if (decryptionFailed) {
263
+ const msg = "DECRYPTION_FAILED: Please check your DOTENV_KEY";
264
+ throw new Error(msg);
265
+ } else {
266
+ console.error("Error: ", error.code);
267
+ console.error("Error: ", error.message);
268
+ throw error;
269
+ }
270
+ }
271
+ }
272
+ function populate(processEnv, parsed, options = {}) {
273
+ const debug = Boolean(options && options.debug);
274
+ const override = Boolean(options && options.override);
275
+ if (typeof parsed !== "object") {
276
+ throw new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
277
+ }
278
+ for (const key of Object.keys(parsed)) {
279
+ if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
280
+ if (override === true) {
281
+ processEnv[key] = parsed[key];
282
+ }
283
+ if (debug) {
284
+ if (override === true) {
285
+ _debug(`"${key}" is already defined and WAS overwritten`);
286
+ } else {
287
+ _debug(`"${key}" is already defined and was NOT overwritten`);
288
+ }
289
+ }
290
+ } else {
291
+ processEnv[key] = parsed[key];
292
+ }
293
+ }
294
+ }
172
295
  var DotenvModule = {
296
+ configDotenv,
297
+ _configVault,
298
+ _parseVault,
173
299
  config,
174
- parse
300
+ decrypt,
301
+ parse,
302
+ populate
175
303
  };
304
+ module2.exports.configDotenv = DotenvModule.configDotenv;
305
+ module2.exports._configVault = DotenvModule._configVault;
306
+ module2.exports._parseVault = DotenvModule._parseVault;
176
307
  module2.exports.config = DotenvModule.config;
308
+ module2.exports.decrypt = DotenvModule.decrypt;
177
309
  module2.exports.parse = DotenvModule.parse;
310
+ module2.exports.populate = DotenvModule.populate;
178
311
  module2.exports = DotenvModule;
179
312
  }
180
313
  });
@@ -433,8 +566,8 @@ var _RedirectClient = class extends import_api.ApiClient {
433
566
  if (result)
434
567
  return result;
435
568
  }
436
- const ret = this.assembleTrie(options);
437
- (_b = this.options.dataCache) == null ? void 0 : _b.set(key, ret, () => this.assembleTrie(options));
569
+ const ret = this.assembleTrie(projectId);
570
+ (_b = this.options.dataCache) == null ? void 0 : _b.set(key, ret, () => this.assembleTrie(projectId));
438
571
  return ret;
439
572
  };
440
573
  this.resetRedirectTrieDataCache = async () => {
@@ -535,7 +668,7 @@ var _RedirectClient = class extends import_api.ApiClient {
535
668
  }
536
669
  }
537
670
  }
538
- async assembleTrie(options) {
671
+ async assembleTrie(projectId, options) {
539
672
  const trie = new PathTrie();
540
673
  for await (const redirect of this.getAllRedirects()) {
541
674
  const path = processUrl(
@@ -599,7 +732,7 @@ var _RedirectClient = class extends import_api.ApiClient {
599
732
  definition = trie.find(processedUrl.path, bestMatch);
600
733
  }
601
734
  if (definition == null ? void 0 : definition.length) {
602
- return definition.map(
735
+ return definition.filter((def) => _RedirectClient.validateRedirect(url, def.data.redirect)).map(
603
736
  (def) => this.processDefinitionToResults(processedUrl, def.data, def.variables, options)
604
737
  ).filter((r) => Boolean(r));
605
738
  }
@@ -633,6 +766,23 @@ var _RedirectClient = class extends import_api.ApiClient {
633
766
  }, finalUrl) : void 0
634
767
  };
635
768
  }
769
+ static validateRedirect(url, redirectDefinition) {
770
+ const processedSource = processUrl(redirectDefinition.sourceUrl);
771
+ const processedUrl = processUrl(url);
772
+ if (redirectDefinition.sourceMustMatchDomain && processedSource.domain !== processedUrl.domain)
773
+ return false;
774
+ if (processedSource.query && !processedUrl.query)
775
+ return false;
776
+ if (processedSource.query && processedUrl.query) {
777
+ const sourceqs = new URLSearchParams(processedSource.query);
778
+ const urlqs = new URLSearchParams(processedUrl.query);
779
+ for (const [key] of sourceqs) {
780
+ if (!urlqs.has(key) || urlqs.get(key) !== sourceqs.get(key))
781
+ return false;
782
+ }
783
+ }
784
+ return true;
785
+ }
636
786
  static getTargetVariableExpandedUrl(url, redirectDefinition, isVariable) {
637
787
  const processedTarget = processUrl(redirectDefinition.targetUrl);
638
788
  const processedSource = processUrl(redirectDefinition.sourceUrl);
package/dist/index.mjs CHANGED
@@ -240,8 +240,8 @@ var _RedirectClient = class extends ApiClient {
240
240
  if (result)
241
241
  return result;
242
242
  }
243
- const ret = this.assembleTrie(options);
244
- (_b = this.options.dataCache) == null ? void 0 : _b.set(key, ret, () => this.assembleTrie(options));
243
+ const ret = this.assembleTrie(projectId);
244
+ (_b = this.options.dataCache) == null ? void 0 : _b.set(key, ret, () => this.assembleTrie(projectId));
245
245
  return ret;
246
246
  };
247
247
  this.resetRedirectTrieDataCache = async () => {
@@ -342,7 +342,7 @@ var _RedirectClient = class extends ApiClient {
342
342
  }
343
343
  }
344
344
  }
345
- async assembleTrie(options) {
345
+ async assembleTrie(projectId, options) {
346
346
  const trie = new PathTrie();
347
347
  for await (const redirect of this.getAllRedirects()) {
348
348
  const path = processUrl(
@@ -406,7 +406,7 @@ var _RedirectClient = class extends ApiClient {
406
406
  definition = trie.find(processedUrl.path, bestMatch);
407
407
  }
408
408
  if (definition == null ? void 0 : definition.length) {
409
- return definition.map(
409
+ return definition.filter((def) => _RedirectClient.validateRedirect(url, def.data.redirect)).map(
410
410
  (def) => this.processDefinitionToResults(processedUrl, def.data, def.variables, options)
411
411
  ).filter((r) => Boolean(r));
412
412
  }
@@ -440,6 +440,23 @@ var _RedirectClient = class extends ApiClient {
440
440
  }, finalUrl) : void 0
441
441
  };
442
442
  }
443
+ static validateRedirect(url, redirectDefinition) {
444
+ const processedSource = processUrl(redirectDefinition.sourceUrl);
445
+ const processedUrl = processUrl(url);
446
+ if (redirectDefinition.sourceMustMatchDomain && processedSource.domain !== processedUrl.domain)
447
+ return false;
448
+ if (processedSource.query && !processedUrl.query)
449
+ return false;
450
+ if (processedSource.query && processedUrl.query) {
451
+ const sourceqs = new URLSearchParams(processedSource.query);
452
+ const urlqs = new URLSearchParams(processedUrl.query);
453
+ for (const [key] of sourceqs) {
454
+ if (!urlqs.has(key) || urlqs.get(key) !== sourceqs.get(key))
455
+ return false;
456
+ }
457
+ }
458
+ return true;
459
+ }
443
460
  static getTargetVariableExpandedUrl(url, redirectDefinition, isVariable) {
444
461
  const processedTarget = processUrl(redirectDefinition.targetUrl);
445
462
  const processedSource = processUrl(redirectDefinition.sourceUrl);
@@ -501,7 +518,7 @@ var UncachedRedirectClient = class extends RedirectClient {
501
518
 
502
519
  // src/util/RedirectFileConverter.ts
503
520
  var getDefaultClient = async () => {
504
- const dotenv = await import("./main-NHOL4NFR.mjs");
521
+ const dotenv = await import("./main-DHQ5ANFI.mjs");
505
522
  dotenv.config();
506
523
  return new RedirectClient({
507
524
  apiKey: process.env.UNIFORM_API_KEY,
@@ -0,0 +1,287 @@
1
+ import {
2
+ __commonJS,
3
+ __require
4
+ } from "./chunk-FFYIGW52.mjs";
5
+
6
+ // ../../node_modules/.pnpm/dotenv@16.1.3/node_modules/dotenv/package.json
7
+ var require_package = __commonJS({
8
+ "../../node_modules/.pnpm/dotenv@16.1.3/node_modules/dotenv/package.json"(exports, module) {
9
+ module.exports = {
10
+ name: "dotenv",
11
+ version: "16.1.3",
12
+ description: "Loads environment variables from .env file",
13
+ main: "lib/main.js",
14
+ types: "lib/main.d.ts",
15
+ exports: {
16
+ ".": {
17
+ types: "./lib/main.d.ts",
18
+ require: "./lib/main.js",
19
+ default: "./lib/main.js"
20
+ },
21
+ "./config": "./config.js",
22
+ "./config.js": "./config.js",
23
+ "./lib/env-options": "./lib/env-options.js",
24
+ "./lib/env-options.js": "./lib/env-options.js",
25
+ "./lib/cli-options": "./lib/cli-options.js",
26
+ "./lib/cli-options.js": "./lib/cli-options.js",
27
+ "./package.json": "./package.json"
28
+ },
29
+ scripts: {
30
+ "dts-check": "tsc --project tests/types/tsconfig.json",
31
+ lint: "standard",
32
+ "lint-readme": "standard-markdown",
33
+ pretest: "npm run lint && npm run dts-check",
34
+ test: "tap tests/*.js --100 -Rspec",
35
+ prerelease: "npm test",
36
+ release: "standard-version"
37
+ },
38
+ repository: {
39
+ type: "git",
40
+ url: "git://github.com/motdotla/dotenv.git"
41
+ },
42
+ funding: "https://github.com/motdotla/dotenv?sponsor=1",
43
+ keywords: [
44
+ "dotenv",
45
+ "env",
46
+ ".env",
47
+ "environment",
48
+ "variables",
49
+ "config",
50
+ "settings"
51
+ ],
52
+ readmeFilename: "README.md",
53
+ license: "BSD-2-Clause",
54
+ devDependencies: {
55
+ "@definitelytyped/dtslint": "^0.0.133",
56
+ "@types/node": "^18.11.3",
57
+ decache: "^4.6.1",
58
+ sinon: "^14.0.1",
59
+ standard: "^17.0.0",
60
+ "standard-markdown": "^7.1.0",
61
+ "standard-version": "^9.5.0",
62
+ tap: "^16.3.0",
63
+ tar: "^6.1.11",
64
+ typescript: "^4.8.4"
65
+ },
66
+ engines: {
67
+ node: ">=12"
68
+ },
69
+ browser: {
70
+ fs: false
71
+ }
72
+ };
73
+ }
74
+ });
75
+
76
+ // ../../node_modules/.pnpm/dotenv@16.1.3/node_modules/dotenv/lib/main.js
77
+ var require_main = __commonJS({
78
+ "../../node_modules/.pnpm/dotenv@16.1.3/node_modules/dotenv/lib/main.js"(exports, module) {
79
+ var fs = __require("fs");
80
+ var path = __require("path");
81
+ var os = __require("os");
82
+ var crypto = __require("crypto");
83
+ var packageJson = require_package();
84
+ var version = packageJson.version;
85
+ var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
86
+ function parse(src) {
87
+ const obj = {};
88
+ let lines = src.toString();
89
+ lines = lines.replace(/\r\n?/mg, "\n");
90
+ let match;
91
+ while ((match = LINE.exec(lines)) != null) {
92
+ const key = match[1];
93
+ let value = match[2] || "";
94
+ value = value.trim();
95
+ const maybeQuote = value[0];
96
+ value = value.replace(/^(['"`])([\s\S]*)\1$/mg, "$2");
97
+ if (maybeQuote === '"') {
98
+ value = value.replace(/\\n/g, "\n");
99
+ value = value.replace(/\\r/g, "\r");
100
+ }
101
+ obj[key] = value;
102
+ }
103
+ return obj;
104
+ }
105
+ function _parseVault(options) {
106
+ const vaultPath = _vaultPath(options);
107
+ const result = DotenvModule.configDotenv({ path: vaultPath });
108
+ if (!result.parsed) {
109
+ throw new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
110
+ }
111
+ const keys = _dotenvKey().split(",");
112
+ const length = keys.length;
113
+ let decrypted;
114
+ for (let i = 0; i < length; i++) {
115
+ try {
116
+ const key = keys[i].trim();
117
+ const attrs = _instructions(result, key);
118
+ decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
119
+ break;
120
+ } catch (error) {
121
+ if (i + 1 >= length) {
122
+ throw error;
123
+ }
124
+ }
125
+ }
126
+ return DotenvModule.parse(decrypted);
127
+ }
128
+ function _log(message) {
129
+ console.log(`[dotenv@${version}][INFO] ${message}`);
130
+ }
131
+ function _warn(message) {
132
+ console.log(`[dotenv@${version}][WARN] ${message}`);
133
+ }
134
+ function _debug(message) {
135
+ console.log(`[dotenv@${version}][DEBUG] ${message}`);
136
+ }
137
+ function _dotenvKey() {
138
+ if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
139
+ return process.env.DOTENV_KEY;
140
+ }
141
+ return "";
142
+ }
143
+ function _instructions(result, dotenvKey) {
144
+ let uri;
145
+ try {
146
+ uri = new URL(dotenvKey);
147
+ } catch (error) {
148
+ if (error.code === "ERR_INVALID_URL") {
149
+ throw new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenv.org/vault/.env.vault?environment=development");
150
+ }
151
+ throw error;
152
+ }
153
+ const key = uri.password;
154
+ if (!key) {
155
+ throw new Error("INVALID_DOTENV_KEY: Missing key part");
156
+ }
157
+ const environment = uri.searchParams.get("environment");
158
+ if (!environment) {
159
+ throw new Error("INVALID_DOTENV_KEY: Missing environment part");
160
+ }
161
+ const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
162
+ const ciphertext = result.parsed[environmentKey];
163
+ if (!ciphertext) {
164
+ throw new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
165
+ }
166
+ return { ciphertext, key };
167
+ }
168
+ function _vaultPath(options) {
169
+ let dotenvPath = path.resolve(process.cwd(), ".env");
170
+ if (options && options.path && options.path.length > 0) {
171
+ dotenvPath = options.path;
172
+ }
173
+ return dotenvPath.endsWith(".vault") ? dotenvPath : `${dotenvPath}.vault`;
174
+ }
175
+ function _resolveHome(envPath) {
176
+ return envPath[0] === "~" ? path.join(os.homedir(), envPath.slice(1)) : envPath;
177
+ }
178
+ function _configVault(options) {
179
+ _log("Loading env from encrypted .env.vault");
180
+ const parsed = DotenvModule._parseVault(options);
181
+ DotenvModule.populate(process.env, parsed, options);
182
+ return { parsed };
183
+ }
184
+ function configDotenv(options) {
185
+ let dotenvPath = path.resolve(process.cwd(), ".env");
186
+ let encoding = "utf8";
187
+ const debug = Boolean(options && options.debug);
188
+ if (options) {
189
+ if (options.path != null) {
190
+ dotenvPath = _resolveHome(options.path);
191
+ }
192
+ if (options.encoding != null) {
193
+ encoding = options.encoding;
194
+ }
195
+ }
196
+ try {
197
+ const parsed = DotenvModule.parse(fs.readFileSync(dotenvPath, { encoding }));
198
+ DotenvModule.populate(process.env, parsed, options);
199
+ return { parsed };
200
+ } catch (e) {
201
+ if (debug) {
202
+ _debug(`Failed to load ${dotenvPath} ${e.message}`);
203
+ }
204
+ return { error: e };
205
+ }
206
+ }
207
+ function config(options) {
208
+ const vaultPath = _vaultPath(options);
209
+ if (_dotenvKey().length === 0) {
210
+ return DotenvModule.configDotenv(options);
211
+ }
212
+ if (!fs.existsSync(vaultPath)) {
213
+ _warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
214
+ return DotenvModule.configDotenv(options);
215
+ }
216
+ return DotenvModule._configVault(options);
217
+ }
218
+ function decrypt(encrypted, keyStr) {
219
+ const key = Buffer.from(keyStr.slice(-64), "hex");
220
+ let ciphertext = Buffer.from(encrypted, "base64");
221
+ const nonce = ciphertext.slice(0, 12);
222
+ const authTag = ciphertext.slice(-16);
223
+ ciphertext = ciphertext.slice(12, -16);
224
+ try {
225
+ const aesgcm = crypto.createDecipheriv("aes-256-gcm", key, nonce);
226
+ aesgcm.setAuthTag(authTag);
227
+ return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
228
+ } catch (error) {
229
+ const isRange = error instanceof RangeError;
230
+ const invalidKeyLength = error.message === "Invalid key length";
231
+ const decryptionFailed = error.message === "Unsupported state or unable to authenticate data";
232
+ if (isRange || invalidKeyLength) {
233
+ const msg = "INVALID_DOTENV_KEY: It must be 64 characters long (or more)";
234
+ throw new Error(msg);
235
+ } else if (decryptionFailed) {
236
+ const msg = "DECRYPTION_FAILED: Please check your DOTENV_KEY";
237
+ throw new Error(msg);
238
+ } else {
239
+ console.error("Error: ", error.code);
240
+ console.error("Error: ", error.message);
241
+ throw error;
242
+ }
243
+ }
244
+ }
245
+ function populate(processEnv, parsed, options = {}) {
246
+ const debug = Boolean(options && options.debug);
247
+ const override = Boolean(options && options.override);
248
+ if (typeof parsed !== "object") {
249
+ throw new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
250
+ }
251
+ for (const key of Object.keys(parsed)) {
252
+ if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
253
+ if (override === true) {
254
+ processEnv[key] = parsed[key];
255
+ }
256
+ if (debug) {
257
+ if (override === true) {
258
+ _debug(`"${key}" is already defined and WAS overwritten`);
259
+ } else {
260
+ _debug(`"${key}" is already defined and was NOT overwritten`);
261
+ }
262
+ }
263
+ } else {
264
+ processEnv[key] = parsed[key];
265
+ }
266
+ }
267
+ }
268
+ var DotenvModule = {
269
+ configDotenv,
270
+ _configVault,
271
+ _parseVault,
272
+ config,
273
+ decrypt,
274
+ parse,
275
+ populate
276
+ };
277
+ module.exports.configDotenv = DotenvModule.configDotenv;
278
+ module.exports._configVault = DotenvModule._configVault;
279
+ module.exports._parseVault = DotenvModule._parseVault;
280
+ module.exports.config = DotenvModule.config;
281
+ module.exports.decrypt = DotenvModule.decrypt;
282
+ module.exports.parse = DotenvModule.parse;
283
+ module.exports.populate = DotenvModule.populate;
284
+ module.exports = DotenvModule;
285
+ }
286
+ });
287
+ export default require_main();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/redirect",
3
- "version": "19.17.0",
3
+ "version": "19.20.0",
4
4
  "description": "Uniform redirect client",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -32,12 +32,12 @@
32
32
  "/dist"
33
33
  ],
34
34
  "dependencies": {
35
- "@uniformdev/context": "19.17.0",
35
+ "@uniformdev/context": "19.20.0",
36
36
  "p-limit": "^3.1.0",
37
37
  "rfdc": "^1.3.0"
38
38
  },
39
39
  "publishConfig": {
40
40
  "access": "public"
41
41
  },
42
- "gitHead": "ed86997d97cefd0d6849abdeb3bdf3737812ea01"
42
+ "gitHead": "eb731fec3a9f35b9cc6d218e2a77861ccf00441a"
43
43
  }
@@ -1,154 +0,0 @@
1
- import {
2
- __commonJS,
3
- __require
4
- } from "./chunk-FFYIGW52.mjs";
5
-
6
- // ../../node_modules/.pnpm/dotenv@16.0.3/node_modules/dotenv/package.json
7
- var require_package = __commonJS({
8
- "../../node_modules/.pnpm/dotenv@16.0.3/node_modules/dotenv/package.json"(exports, module) {
9
- module.exports = {
10
- name: "dotenv",
11
- version: "16.0.3",
12
- description: "Loads environment variables from .env file",
13
- main: "lib/main.js",
14
- types: "lib/main.d.ts",
15
- exports: {
16
- ".": {
17
- require: "./lib/main.js",
18
- types: "./lib/main.d.ts",
19
- default: "./lib/main.js"
20
- },
21
- "./config": "./config.js",
22
- "./config.js": "./config.js",
23
- "./lib/env-options": "./lib/env-options.js",
24
- "./lib/env-options.js": "./lib/env-options.js",
25
- "./lib/cli-options": "./lib/cli-options.js",
26
- "./lib/cli-options.js": "./lib/cli-options.js",
27
- "./package.json": "./package.json"
28
- },
29
- scripts: {
30
- "dts-check": "tsc --project tests/types/tsconfig.json",
31
- lint: "standard",
32
- "lint-readme": "standard-markdown",
33
- pretest: "npm run lint && npm run dts-check",
34
- test: "tap tests/*.js --100 -Rspec",
35
- prerelease: "npm test",
36
- release: "standard-version"
37
- },
38
- repository: {
39
- type: "git",
40
- url: "git://github.com/motdotla/dotenv.git"
41
- },
42
- keywords: [
43
- "dotenv",
44
- "env",
45
- ".env",
46
- "environment",
47
- "variables",
48
- "config",
49
- "settings"
50
- ],
51
- readmeFilename: "README.md",
52
- license: "BSD-2-Clause",
53
- devDependencies: {
54
- "@types/node": "^17.0.9",
55
- decache: "^4.6.1",
56
- dtslint: "^3.7.0",
57
- sinon: "^12.0.1",
58
- standard: "^16.0.4",
59
- "standard-markdown": "^7.1.0",
60
- "standard-version": "^9.3.2",
61
- tap: "^15.1.6",
62
- tar: "^6.1.11",
63
- typescript: "^4.5.4"
64
- },
65
- engines: {
66
- node: ">=12"
67
- }
68
- };
69
- }
70
- });
71
-
72
- // ../../node_modules/.pnpm/dotenv@16.0.3/node_modules/dotenv/lib/main.js
73
- var require_main = __commonJS({
74
- "../../node_modules/.pnpm/dotenv@16.0.3/node_modules/dotenv/lib/main.js"(exports, module) {
75
- var fs = __require("fs");
76
- var path = __require("path");
77
- var os = __require("os");
78
- var packageJson = require_package();
79
- var version = packageJson.version;
80
- var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
81
- function parse(src) {
82
- const obj = {};
83
- let lines = src.toString();
84
- lines = lines.replace(/\r\n?/mg, "\n");
85
- let match;
86
- while ((match = LINE.exec(lines)) != null) {
87
- const key = match[1];
88
- let value = match[2] || "";
89
- value = value.trim();
90
- const maybeQuote = value[0];
91
- value = value.replace(/^(['"`])([\s\S]*)\1$/mg, "$2");
92
- if (maybeQuote === '"') {
93
- value = value.replace(/\\n/g, "\n");
94
- value = value.replace(/\\r/g, "\r");
95
- }
96
- obj[key] = value;
97
- }
98
- return obj;
99
- }
100
- function _log(message) {
101
- console.log(`[dotenv@${version}][DEBUG] ${message}`);
102
- }
103
- function _resolveHome(envPath) {
104
- return envPath[0] === "~" ? path.join(os.homedir(), envPath.slice(1)) : envPath;
105
- }
106
- function config(options) {
107
- let dotenvPath = path.resolve(process.cwd(), ".env");
108
- let encoding = "utf8";
109
- const debug = Boolean(options && options.debug);
110
- const override = Boolean(options && options.override);
111
- if (options) {
112
- if (options.path != null) {
113
- dotenvPath = _resolveHome(options.path);
114
- }
115
- if (options.encoding != null) {
116
- encoding = options.encoding;
117
- }
118
- }
119
- try {
120
- const parsed = DotenvModule.parse(fs.readFileSync(dotenvPath, { encoding }));
121
- Object.keys(parsed).forEach(function(key) {
122
- if (!Object.prototype.hasOwnProperty.call(process.env, key)) {
123
- process.env[key] = parsed[key];
124
- } else {
125
- if (override === true) {
126
- process.env[key] = parsed[key];
127
- }
128
- if (debug) {
129
- if (override === true) {
130
- _log(`"${key}" is already defined in \`process.env\` and WAS overwritten`);
131
- } else {
132
- _log(`"${key}" is already defined in \`process.env\` and was NOT overwritten`);
133
- }
134
- }
135
- }
136
- });
137
- return { parsed };
138
- } catch (e) {
139
- if (debug) {
140
- _log(`Failed to load ${dotenvPath} ${e.message}`);
141
- }
142
- return { error: e };
143
- }
144
- }
145
- var DotenvModule = {
146
- config,
147
- parse
148
- };
149
- module.exports.config = DotenvModule.config;
150
- module.exports.parse = DotenvModule.parse;
151
- module.exports = DotenvModule;
152
- }
153
- });
154
- export default require_main();