@rotty3000/config-node 0.5.0 → 0.6.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.
Files changed (46) hide show
  1. package/README.md +28 -12
  2. package/dist/config-lxc/index.js +33 -35
  3. package/dist/config-lxc/index.js.map +1 -1
  4. package/dist/config-node/index.js +74 -30
  5. package/dist/config-node/index.js.map +1 -1
  6. package/dist/config-node/providers/1000-application-packaged.d.ts +1 -2
  7. package/dist/config-node/providers/1000-application-packaged.js +14 -21
  8. package/dist/config-node/providers/1000-application-packaged.js.map +1 -1
  9. package/dist/config-node/providers/10000-cli.js +1 -1
  10. package/dist/config-node/providers/10000-cli.js.map +1 -1
  11. package/dist/config-node/providers/11000-config-node-devtools.d.ts +7 -2
  12. package/dist/config-node/providers/11000-config-node-devtools.js +13 -12
  13. package/dist/config-node/providers/11000-config-node-devtools.js.map +1 -1
  14. package/dist/config-node/providers/2000-application.d.ts +1 -2
  15. package/dist/config-node/providers/2000-application.js +5 -11
  16. package/dist/config-node/providers/2000-application.js.map +1 -1
  17. package/dist/config-node/providers/3000-application-config.d.ts +1 -2
  18. package/dist/config-node/providers/3000-application-config.js +5 -11
  19. package/dist/config-node/providers/3000-application-config.js.map +1 -1
  20. package/dist/config-node/providers/4000-application-profile.d.ts +1 -2
  21. package/dist/config-node/providers/4000-application-profile.js +9 -15
  22. package/dist/config-node/providers/4000-application-profile.js.map +1 -1
  23. package/dist/config-node/providers/5000-application-profile-config.d.ts +1 -2
  24. package/dist/config-node/providers/5000-application-profile-config.js +9 -15
  25. package/dist/config-node/providers/5000-application-profile-config.js.map +1 -1
  26. package/dist/config-node/providers/6000-config-trees.js +5 -4
  27. package/dist/config-node/providers/6000-config-trees.js.map +1 -1
  28. package/dist/config-node/providers/7000-individual-env-vars.js +1 -1
  29. package/dist/config-node/providers/7000-individual-env-vars.js.map +1 -1
  30. package/dist/config-node/providers/8000-env-application-json.js +1 -1
  31. package/dist/config-node/providers/8000-env-application-json.js.map +1 -1
  32. package/dist/config-node/providers/9000-cli-application-json.js +1 -1
  33. package/dist/config-node/providers/9000-cli-application-json.js.map +1 -1
  34. package/dist/config-node/providers/active-profile.d.ts +5 -0
  35. package/dist/config-node/providers/active-profile.js +19 -0
  36. package/dist/config-node/providers/active-profile.js.map +1 -0
  37. package/dist/config-node/providers/json-file.d.ts +19 -0
  38. package/dist/config-node/providers/json-file.js +30 -0
  39. package/dist/config-node/providers/json-file.js.map +1 -0
  40. package/dist/config-node/util/index.d.ts +35 -3
  41. package/dist/config-node/util/index.js +95 -10
  42. package/dist/config-node/util/index.js.map +1 -1
  43. package/package.json +6 -7
  44. package/.github/workflows/node.js.yml +0 -30
  45. package/.nvmrc +0 -1
  46. package/RELEASE_PROCESS.md +0 -4
@@ -1 +1 @@
1
- {"version":3,"file":"3000-application-config.js","sourceRoot":"","sources":["../../../src/config-node/providers/3000-application-config.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAyB;AACzB,0DAA6B;AAE7B,kCAA+D;AAElD,QAAA,iBAAiB,GAAmB;IAC/C,GAAG,EAAE,gCAAgC;IACrC,WAAW,EAAE,uDAAuD;IACpE,QAAQ,EAAE,IAAI;IACd,GAAG,EAAE,CAAC,GAAG,EAAE,aAAa,EAAE,WAAW,EAAE,EAAE;QACvC,MAAM,GAAG,GAAG,IAAA,sBAAe,EAAC,WAAW,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QACrE,MAAM,UAAU,GAAG,mBAAI,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,EAAE,kBAAkB,CAAC,CAAC;QAChE,IAAI,iBAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,GAAG,IAAA,sBAAe,EAAC,aAAa,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,IAAA,mBAAY,EAAC,UAAU,CAAC,CAAC,CAAC;YACxF,IAAI,IAAI,EAAE,CAAC;gBACT,OAAO,IAAA,cAAO,EAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;YAC5B,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAC"}
1
+ {"version":3,"file":"3000-application-config.js","sourceRoot":"","sources":["../../../src/config-node/providers/3000-application-config.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA6B;AAC7B,kCAAwC;AACxC,2CAA6C;AAEhC,QAAA,iBAAiB,GAAG,IAAA,4BAAgB,EAAC;IAChD,GAAG,EAAE,gCAAgC;IACrC,WAAW,EAAE,uDAAuD;IACpE,QAAQ,EAAE,IAAI;IACd,WAAW,EAAE,CAAC,WAAW,EAAE,EAAE;QAC3B,MAAM,GAAG,GAAG,IAAA,sBAAe,EAAC,WAAW,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QAErE,OAAO,mBAAI,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,EAAE,kBAAkB,CAAC,CAAC;IACtD,CAAC;CACF,CAAC,CAAC"}
@@ -1,2 +1 @@
1
- import { ConfigProvider } from '../types';
2
- export declare const applicationProfile: ConfigProvider;
1
+ export declare const applicationProfile: import("..").ConfigProvider;
@@ -5,27 +5,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.applicationProfile = void 0;
7
7
  const node_path_1 = __importDefault(require("node:path"));
8
- const config_node_1 = require("../../config-node");
9
8
  const util_1 = require("../util");
10
- exports.applicationProfile = {
9
+ const active_profile_1 = require("./active-profile");
10
+ const json_file_1 = require("./json-file");
11
+ exports.applicationProfile = (0, json_file_1.jsonFileProvider)({
11
12
  key: '${CWD}/application-<profile>.json',
12
13
  description: 'From application profile property json files in ${CWD}',
13
14
  priority: 4000,
14
- get: (key, providerCache, commonCache) => {
15
- if (util_1.protectedKeys.includes(key)) {
16
- return;
17
- }
18
- let profile = (0, config_node_1.lookupConfig)('config.node.profiles.active');
15
+ isEnabled: (key) => !util_1.protectedKeys.includes(key),
16
+ resolvePath: (commonCache) => {
17
+ const profile = (0, active_profile_1.activeProfile)();
19
18
  if (!profile) {
20
- return;
19
+ return undefined;
21
20
  }
22
- profile = Array.isArray(profile) ? profile[profile.length - 1] : profile;
23
21
  const cwd = (0, util_1.computeIfAbsent)(commonCache, 'cwd', () => process.cwd());
24
- const configPath = node_path_1.default.join(cwd, `application-${profile}.json`);
25
- const json = (0, util_1.computeIfAbsent)(providerCache, configPath, () => (0, util_1.readJSONFile)(configPath));
26
- if (json) {
27
- return (0, util_1.unquote)(json[key]);
28
- }
22
+ return node_path_1.default.join(cwd, `application-${profile}.json`);
29
23
  },
30
- };
24
+ });
31
25
  //# sourceMappingURL=4000-application-profile.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"4000-application-profile.js","sourceRoot":"","sources":["../../../src/config-node/providers/4000-application-profile.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA6B;AAC7B,mDAA+C;AAE/C,kCAA8E;AAEjE,QAAA,kBAAkB,GAAmB;IAChD,GAAG,EAAE,mCAAmC;IACxC,WAAW,EAAE,wDAAwD;IACrE,QAAQ,EAAE,IAAI;IACd,GAAG,EAAE,CAAC,GAAG,EAAE,aAAa,EAAE,WAAW,EAAE,EAAE;QACvC,IAAI,oBAAa,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YAChC,OAAO;QACT,CAAC;QACD,IAAI,OAAO,GAAG,IAAA,0BAAY,EAAC,6BAA6B,CAAC,CAAC;QAC1D,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO;QACT,CAAC;QACD,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;QACzE,MAAM,GAAG,GAAG,IAAA,sBAAe,EAAC,WAAW,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QACrE,MAAM,UAAU,GAAG,mBAAI,CAAC,IAAI,CAAC,GAAG,EAAE,eAAe,OAAO,OAAO,CAAC,CAAC;QACjE,MAAM,IAAI,GAAG,IAAA,sBAAe,EAAC,aAAa,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,IAAA,mBAAY,EAAC,UAAU,CAAC,CAAC,CAAC;QACxF,IAAI,IAAI,EAAE,CAAC;YACT,OAAO,IAAA,cAAO,EAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;CACF,CAAC"}
1
+ {"version":3,"file":"4000-application-profile.js","sourceRoot":"","sources":["../../../src/config-node/providers/4000-application-profile.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA6B;AAC7B,kCAAuD;AACvD,qDAA+C;AAC/C,2CAA6C;AAEhC,QAAA,kBAAkB,GAAG,IAAA,4BAAgB,EAAC;IACjD,GAAG,EAAE,mCAAmC;IACxC,WAAW,EAAE,wDAAwD;IACrE,QAAQ,EAAE,IAAI;IACd,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,oBAAa,CAAC,QAAQ,CAAC,GAAG,CAAC;IAChD,WAAW,EAAE,CAAC,WAAW,EAAE,EAAE;QAC3B,MAAM,OAAO,GAAG,IAAA,8BAAa,GAAE,CAAC;QAEhC,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,MAAM,GAAG,GAAG,IAAA,sBAAe,EAAC,WAAW,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QAErE,OAAO,mBAAI,CAAC,IAAI,CAAC,GAAG,EAAE,eAAe,OAAO,OAAO,CAAC,CAAC;IACvD,CAAC;CACF,CAAC,CAAC"}
@@ -1,2 +1 @@
1
- import { ConfigProvider } from '../types';
2
- export declare const applicationProfileConfig: ConfigProvider;
1
+ export declare const applicationProfileConfig: import("..").ConfigProvider;
@@ -5,27 +5,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.applicationProfileConfig = void 0;
7
7
  const node_path_1 = __importDefault(require("node:path"));
8
- const config_node_1 = require("../../config-node");
9
8
  const util_1 = require("../util");
10
- exports.applicationProfileConfig = {
9
+ const active_profile_1 = require("./active-profile");
10
+ const json_file_1 = require("./json-file");
11
+ exports.applicationProfileConfig = (0, json_file_1.jsonFileProvider)({
11
12
  key: '${CWD}/config/application-<profile>.json',
12
13
  description: 'From application profile property json files in ${CWD}/config',
13
14
  priority: 5000,
14
- get: (key, providerCache, commonCache) => {
15
- if (util_1.protectedKeys.includes(key)) {
16
- return;
17
- }
18
- let profile = (0, config_node_1.lookupConfig)('config.node.profiles.active');
15
+ isEnabled: (key) => !util_1.protectedKeys.includes(key),
16
+ resolvePath: (commonCache) => {
17
+ const profile = (0, active_profile_1.activeProfile)();
19
18
  if (!profile) {
20
- return;
19
+ return undefined;
21
20
  }
22
- profile = Array.isArray(profile) ? profile[profile.length - 1] : profile;
23
21
  const cwd = (0, util_1.computeIfAbsent)(commonCache, 'cwd', () => process.cwd());
24
- const configPath = node_path_1.default.join(cwd, 'config', `application-${profile}.json`);
25
- const json = (0, util_1.computeIfAbsent)(providerCache, configPath, () => (0, util_1.readJSONFile)(configPath));
26
- if (json) {
27
- return (0, util_1.unquote)(json[key]);
28
- }
22
+ return node_path_1.default.join(cwd, 'config', `application-${profile}.json`);
29
23
  },
30
- };
24
+ });
31
25
  //# sourceMappingURL=5000-application-profile-config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"5000-application-profile-config.js","sourceRoot":"","sources":["../../../src/config-node/providers/5000-application-profile-config.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA6B;AAC7B,mDAA+C;AAE/C,kCAA8E;AAEjE,QAAA,wBAAwB,GAAmB;IACtD,GAAG,EAAE,0CAA0C;IAC/C,WAAW,EAAE,+DAA+D;IAC5E,QAAQ,EAAE,IAAI;IACd,GAAG,EAAE,CAAC,GAAG,EAAE,aAAa,EAAE,WAAW,EAAE,EAAE;QACvC,IAAI,oBAAa,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YAChC,OAAO;QACT,CAAC;QACD,IAAI,OAAO,GAAG,IAAA,0BAAY,EAAC,6BAA6B,CAAC,CAAC;QAC1D,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO;QACT,CAAC;QACD,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;QACzE,MAAM,GAAG,GAAG,IAAA,sBAAe,EAAC,WAAW,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QACrE,MAAM,UAAU,GAAG,mBAAI,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,EAAE,eAAe,OAAO,OAAO,CAAC,CAAC;QAC3E,MAAM,IAAI,GAAG,IAAA,sBAAe,EAAC,aAAa,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,IAAA,mBAAY,EAAC,UAAU,CAAC,CAAC,CAAC;QACxF,IAAI,IAAI,EAAE,CAAC;YACT,OAAO,IAAA,cAAO,EAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;CACF,CAAC"}
1
+ {"version":3,"file":"5000-application-profile-config.js","sourceRoot":"","sources":["../../../src/config-node/providers/5000-application-profile-config.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA6B;AAC7B,kCAAuD;AACvD,qDAA+C;AAC/C,2CAA6C;AAEhC,QAAA,wBAAwB,GAAG,IAAA,4BAAgB,EAAC;IACvD,GAAG,EAAE,0CAA0C;IAC/C,WAAW,EAAE,+DAA+D;IAC5E,QAAQ,EAAE,IAAI;IACd,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,oBAAa,CAAC,QAAQ,CAAC,GAAG,CAAC;IAChD,WAAW,EAAE,CAAC,WAAW,EAAE,EAAE;QAC3B,MAAM,OAAO,GAAG,IAAA,8BAAa,GAAE,CAAC;QAEhC,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,MAAM,GAAG,GAAG,IAAA,sBAAe,EAAC,WAAW,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QAErE,OAAO,mBAAI,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,EAAE,eAAe,OAAO,OAAO,CAAC,CAAC;IACjE,CAAC;CACF,CAAC,CAAC"}
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.configTrees = void 0;
7
7
  const node_fs_1 = __importDefault(require("node:fs"));
8
- const path_1 = __importDefault(require("path"));
9
8
  const config_node_1 = require("../../config-node");
10
9
  const util_1 = require("../util");
11
10
  exports.configTrees = {
@@ -23,9 +22,11 @@ exports.configTrees = {
23
22
  configtrees = Array.isArray(configtrees) ? configtrees : [configtrees];
24
23
  return (0, util_1.computeIfAbsent)(providerCache, `configtree:${key}`, () => {
25
24
  for (var configtree of configtrees) {
26
- const configtreeEntry = path_1.default.join(configtree, key);
27
- if (node_fs_1.default.existsSync(configtreeEntry)) {
28
- return (0, util_1.unquote)(node_fs_1.default.readFileSync(configtreeEntry, 'utf8'));
25
+ // the key becomes a file name below the tree, so it is resolved and containment is checked on the
26
+ // real (symlink free) path: neither a `..` key nor a link can read outside the configured tree
27
+ const configtreeEntry = (0, util_1.resolveContainedFile)(configtree, key);
28
+ if (configtreeEntry) {
29
+ return (0, util_1.commaSeparated)((0, util_1.unquote)((0, util_1.trimFileValue)(node_fs_1.default.readFileSync(configtreeEntry, 'utf8'))));
29
30
  }
30
31
  }
31
32
  });
@@ -1 +1 @@
1
- {"version":3,"file":"6000-config-trees.js","sourceRoot":"","sources":["../../../src/config-node/providers/6000-config-trees.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAyB;AACzB,gDAAwB;AACxB,mDAA+C;AAE/C,kCAAgE;AAEnD,QAAA,WAAW,GAAmB;IACzC,GAAG,EAAE,cAAc;IACnB,WAAW,EAAE,yEAAyE;IACtF,QAAQ,EAAE,IAAI;IACd,GAAG,EAAE,CAAC,GAAG,EAAE,aAAa,EAAE,EAAE;QAC1B,IAAI,oBAAa,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YAChC,OAAO;QACT,CAAC;QACD,IAAI,WAAW,GAAG,IAAA,0BAAY,EAAC,0BAA0B,CAAC,CAAC;QAC3D,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,OAAO;QACT,CAAC;QACD,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;QACvE,OAAO,IAAA,sBAAe,EAAC,aAAa,EAAE,cAAc,GAAG,EAAE,EAAE,GAAG,EAAE;YAC9D,KAAK,IAAI,UAAU,IAAI,WAAW,EAAE,CAAC;gBACnC,MAAM,eAAe,GAAG,cAAI,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;gBACnD,IAAI,iBAAE,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE,CAAC;oBACnC,OAAO,IAAA,cAAO,EAAC,iBAAE,CAAC,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC,CAAC;gBAC3D,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
1
+ {"version":3,"file":"6000-config-trees.js","sourceRoot":"","sources":["../../../src/config-node/providers/6000-config-trees.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAyB;AACzB,mDAA+C;AAE/C,kCAEiB;AAEJ,QAAA,WAAW,GAAmB;IACzC,GAAG,EAAE,cAAc;IACnB,WAAW,EAAE,yEAAyE;IACtF,QAAQ,EAAE,IAAI;IACd,GAAG,EAAE,CAAC,GAAG,EAAE,aAAa,EAAE,EAAE;QAC1B,IAAI,oBAAa,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YAChC,OAAO;QACT,CAAC;QACD,IAAI,WAAW,GAAG,IAAA,0BAAY,EAAC,0BAA0B,CAAC,CAAC;QAC3D,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,OAAO;QACT,CAAC;QACD,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;QACvE,OAAO,IAAA,sBAAe,EAAC,aAAa,EAAE,cAAc,GAAG,EAAE,EAAE,GAAG,EAAE;YAC9D,KAAK,IAAI,UAAU,IAAI,WAAuB,EAAE,CAAC;gBAC/C,kGAAkG;gBAClG,+FAA+F;gBAC/F,MAAM,eAAe,GAAG,IAAA,2BAAoB,EAAC,UAAU,EAAE,GAAG,CAAC,CAAC;gBAE9D,IAAI,eAAe,EAAE,CAAC;oBACpB,OAAO,IAAA,qBAAc,EAAC,IAAA,cAAO,EAAC,IAAA,oBAAa,EAAC,iBAAE,CAAC,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC1F,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
@@ -10,7 +10,7 @@ exports.individualEnvVars = {
10
10
  let modifiedKey = key.replace(/\./gi, '_');
11
11
  modifiedKey = modifiedKey.replace(/-/gi, '');
12
12
  modifiedKey = modifiedKey.toUpperCase();
13
- return (0, util_1.unquote)(process.env[modifiedKey]);
13
+ return (0, util_1.commaSeparated)((0, util_1.unquote)(process.env[modifiedKey]));
14
14
  }),
15
15
  };
16
16
  //# sourceMappingURL=7000-individual-env-vars.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"7000-individual-env-vars.js","sourceRoot":"","sources":["../../../src/config-node/providers/7000-individual-env-vars.ts"],"names":[],"mappings":";;;AACA,kCAAiD;AAEpC,QAAA,iBAAiB,GAAmB;IAC/C,GAAG,EAAE,uBAAuB;IAC5B,WAAW,EAAE,uEAAuE;IACpF,QAAQ,EAAE,IAAI;IACd,GAAG,EAAE,CAAC,GAAG,EAAE,aAAa,EAAE,EAAE,CAAC,IAAA,sBAAe,EAAC,aAAa,EAAE,eAAe,GAAG,EAAE,EAAE,GAAG,EAAE;QACrF,IAAI,WAAW,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC3C,WAAW,GAAG,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAC7C,WAAW,GAAG,WAAW,CAAC,WAAW,EAAE,CAAC;QACxC,OAAO,IAAA,cAAO,EAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC;IAC3C,CAAC,CAAC;CACH,CAAC"}
1
+ {"version":3,"file":"7000-individual-env-vars.js","sourceRoot":"","sources":["../../../src/config-node/providers/7000-individual-env-vars.ts"],"names":[],"mappings":";;;AACA,kCAAiE;AAEpD,QAAA,iBAAiB,GAAmB;IAC/C,GAAG,EAAE,uBAAuB;IAC5B,WAAW,EAAE,uEAAuE;IACpF,QAAQ,EAAE,IAAI;IACd,GAAG,EAAE,CAAC,GAAG,EAAE,aAAa,EAAE,EAAE,CAAC,IAAA,sBAAe,EAAC,aAAa,EAAE,eAAe,GAAG,EAAE,EAAE,GAAG,EAAE;QACrF,IAAI,WAAW,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC3C,WAAW,GAAG,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAC7C,WAAW,GAAG,WAAW,CAAC,WAAW,EAAE,CAAC;QACxC,OAAO,IAAA,qBAAc,EAAC,IAAA,cAAO,EAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAC3D,CAAC,CAAC;CACH,CAAC"}
@@ -11,7 +11,7 @@ exports.envApplicationJson = {
11
11
  if (value && value.length > 1) {
12
12
  const json = (0, util_1.computeIfAbsent)(providerCache, `process.env.APPLICATION_JSON`, () => JSON.parse(value));
13
13
  if (json) {
14
- return (0, util_1.unquote)(json[key]);
14
+ return (0, util_1.unquote)((0, util_1.readKey)(json, key));
15
15
  }
16
16
  }
17
17
  }),
@@ -1 +1 @@
1
- {"version":3,"file":"8000-env-application-json.js","sourceRoot":"","sources":["../../../src/config-node/providers/8000-env-application-json.ts"],"names":[],"mappings":";;;AACA,kCAAiD;AAEpC,QAAA,kBAAkB,GAAmB;IAChD,GAAG,EAAE,8BAA8B;IACnC,WAAW,EAAE,oFAAoF;IACjG,QAAQ,EAAE,IAAI;IACd,GAAG,EAAE,CAAC,GAAG,EAAE,aAAa,EAAE,EAAE,CAAC,IAAA,sBAAe,EAAC,aAAa,EAAE,GAAG,EAAE,GAAG,EAAE;QACpE,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC;QAC3C,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,GAAG,IAAA,sBAAe,EAAC,aAAa,EAAE,8BAA8B,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;YACrG,IAAI,IAAI,EAAE,CAAC;gBACT,OAAO,IAAA,cAAO,EAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;YAC5B,CAAC;QACH,CAAC;IACH,CAAC,CAAC;CACH,CAAC"}
1
+ {"version":3,"file":"8000-env-application-json.js","sourceRoot":"","sources":["../../../src/config-node/providers/8000-env-application-json.ts"],"names":[],"mappings":";;;AACA,kCAA0D;AAE7C,QAAA,kBAAkB,GAAmB;IAChD,GAAG,EAAE,8BAA8B;IACnC,WAAW,EAAE,oFAAoF;IACjG,QAAQ,EAAE,IAAI;IACd,GAAG,EAAE,CAAC,GAAG,EAAE,aAAa,EAAE,EAAE,CAAC,IAAA,sBAAe,EAAC,aAAa,EAAE,GAAG,EAAE,GAAG,EAAE;QACpE,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC;QAC3C,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,GAAG,IAAA,sBAAe,EAAC,aAAa,EAAE,8BAA8B,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;YACrG,IAAI,IAAI,EAAE,CAAC;gBACT,OAAO,IAAA,cAAO,EAAC,IAAA,cAAO,EAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;YACrC,CAAC;QACH,CAAC;IACH,CAAC,CAAC;CACH,CAAC"}
@@ -11,7 +11,7 @@ exports.cliApplicationJson = {
11
11
  for (var arg of process.argv) {
12
12
  if (arg.startsWith(prefix)) {
13
13
  const value = JSON.parse(arg.substring(prefix.length));
14
- return (0, util_1.unquote)(value[key]);
14
+ return (0, util_1.unquote)((0, util_1.readKey)(value, key));
15
15
  }
16
16
  }
17
17
  return undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"9000-cli-application-json.js","sourceRoot":"","sources":["../../../src/config-node/providers/9000-cli-application-json.ts"],"names":[],"mappings":";;;AACA,kCAAiD;AAEpC,QAAA,kBAAkB,GAAmB;IAChD,GAAG,EAAE,+BAA+B;IACpC,WAAW,EAAE,wDAAwD;IACrE,QAAQ,EAAE,IAAI;IACd,GAAG,EAAE,CAAC,GAAG,EAAE,aAAa,EAAE,EAAE,CAAC,IAAA,sBAAe,EAAC,aAAa,EAAE,gBAAgB,GAAG,EAAE,EAAE,GAAG,EAAE;QACtF,MAAM,MAAM,GAAG,qBAAqB,CAAA;QACpC,KAAK,IAAI,GAAG,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;YAC7B,IAAI,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC3B,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;gBACvD,OAAO,IAAA,cAAO,EAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;YAC7B,CAAC;QACH,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;CACH,CAAC"}
1
+ {"version":3,"file":"9000-cli-application-json.js","sourceRoot":"","sources":["../../../src/config-node/providers/9000-cli-application-json.ts"],"names":[],"mappings":";;;AACA,kCAA0D;AAE7C,QAAA,kBAAkB,GAAmB;IAChD,GAAG,EAAE,+BAA+B;IACpC,WAAW,EAAE,wDAAwD;IACrE,QAAQ,EAAE,IAAI;IACd,GAAG,EAAE,CAAC,GAAG,EAAE,aAAa,EAAE,EAAE,CAAC,IAAA,sBAAe,EAAC,aAAa,EAAE,gBAAgB,GAAG,EAAE,EAAE,GAAG,EAAE;QACtF,MAAM,MAAM,GAAG,qBAAqB,CAAA;QACpC,KAAK,IAAI,GAAG,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;YAC7B,IAAI,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC3B,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;gBACvD,OAAO,IAAA,cAAO,EAAC,IAAA,cAAO,EAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;YACtC,CAAC;QACH,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;CACH,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * The profile the application is running under, or undefined when there is none. A comma delimited list is
3
+ * reduced to its last entry, and a name that could walk out of the directory it is pasted into is refused.
4
+ */
5
+ export declare function activeProfile(): string | undefined;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.activeProfile = void 0;
4
+ const config_node_1 = require("../../config-node");
5
+ const util_1 = require("../util");
6
+ /**
7
+ * The profile the application is running under, or undefined when there is none. A comma delimited list is
8
+ * reduced to its last entry, and a name that could walk out of the directory it is pasted into is refused.
9
+ */
10
+ function activeProfile() {
11
+ const profile = (0, config_node_1.lookupConfig)('config.node.profiles.active');
12
+ if (!profile) {
13
+ return undefined;
14
+ }
15
+ const name = Array.isArray(profile) ? profile[profile.length - 1] : profile;
16
+ return (0, util_1.isSafePathSegment)(name) ? name : undefined;
17
+ }
18
+ exports.activeProfile = activeProfile;
19
+ //# sourceMappingURL=active-profile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"active-profile.js","sourceRoot":"","sources":["../../../src/config-node/providers/active-profile.ts"],"names":[],"mappings":";;;AAAA,mDAA+C;AAC/C,kCAA0C;AAE1C;;;GAGG;AACH,SAAgB,aAAa;IAC3B,MAAM,OAAO,GAAG,IAAA,0BAAY,EAAC,6BAA6B,CAAC,CAAC;IAE5D,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IAE5E,OAAO,IAAA,wBAAiB,EAAC,IAAc,CAAC,CAAC,CAAC,CAAC,IAAc,CAAC,CAAC,CAAC,SAAS,CAAC;AACxE,CAAC;AAVD,sCAUC"}
@@ -0,0 +1,19 @@
1
+ import { ConfigProvider } from '../types';
2
+ export interface JsonFileProviderOptions {
3
+ /** The name this provider is reported under in verbose output. */
4
+ readonly key: string;
5
+ readonly description: string;
6
+ readonly priority: number;
7
+ /** Where the JSON file lives, or undefined when there is nothing to read for this lookup. */
8
+ readonly resolvePath: (commonCache: Map<string, any>) => string | undefined;
9
+ /**
10
+ * Lets a provider decline a lookup outright, before anything is resolved or read (used for the keys a
11
+ * provider must never satisfy for itself, and for the developer only devtools file).
12
+ */
13
+ readonly isEnabled?: (key: string) => boolean;
14
+ }
15
+ /**
16
+ * The shape shared by every provider that reads one JSON file: resolve the path, parse the file once into the
17
+ * provider cache, and hand back one key from it.
18
+ */
19
+ export declare function jsonFileProvider(options: JsonFileProviderOptions): ConfigProvider;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.jsonFileProvider = void 0;
4
+ const util_1 = require("../util");
5
+ /**
6
+ * The shape shared by every provider that reads one JSON file: resolve the path, parse the file once into the
7
+ * provider cache, and hand back one key from it.
8
+ */
9
+ function jsonFileProvider(options) {
10
+ return {
11
+ key: options.key,
12
+ description: options.description,
13
+ priority: options.priority,
14
+ get: (key, providerCache, commonCache) => {
15
+ if (options.isEnabled && !options.isEnabled(key)) {
16
+ return undefined;
17
+ }
18
+ const configPath = options.resolvePath(commonCache);
19
+ if (!configPath) {
20
+ return undefined;
21
+ }
22
+ // readJSONFile already tolerates a missing file, so the parsed document (or its absence) is cached per
23
+ // path: the file is read at most once per process
24
+ const json = (0, util_1.computeIfAbsent)(providerCache, configPath, () => (0, util_1.readJSONFile)(configPath));
25
+ return json ? (0, util_1.unquote)((0, util_1.readKey)(json, key)) : undefined;
26
+ },
27
+ };
28
+ }
29
+ exports.jsonFileProvider = jsonFileProvider;
30
+ //# sourceMappingURL=json-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-file.js","sourceRoot":"","sources":["../../../src/config-node/providers/json-file.ts"],"names":[],"mappings":";;;AACA,kCAAwE;AAgBxE;;;GAGG;AACH,SAAgB,gBAAgB,CAAC,OAAgC;IAC/D,OAAO;QACL,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,GAAG,EAAE,CAAC,GAAG,EAAE,aAAa,EAAE,WAAW,EAAE,EAAE;YACvC,IAAI,OAAO,CAAC,SAAS,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;gBACjD,OAAO,SAAS,CAAC;YACnB,CAAC;YAED,MAAM,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;YAEpD,IAAI,CAAC,UAAU,EAAE,CAAC;gBAChB,OAAO,SAAS,CAAC;YACnB,CAAC;YAED,uGAAuG;YACvG,kDAAkD;YAClD,MAAM,IAAI,GAAG,IAAA,sBAAe,EAAC,aAAa,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,IAAA,mBAAY,EAAC,UAAU,CAAC,CAAC,CAAC;YAExF,OAAO,IAAI,CAAC,CAAC,CAAC,IAAA,cAAO,EAAC,IAAA,cAAO,EAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACxD,CAAC;KACF,CAAC;AACJ,CAAC;AAvBD,4CAuBC"}
@@ -1,10 +1,11 @@
1
1
  declare let verbose: boolean;
2
2
  declare const protectedKeys: string[];
3
+ declare function findProjectRoot(currentPath?: string): string | null;
3
4
  /**
4
5
  * A utility function to get the root folder of the parent project, use this function to get the application.json file
5
6
  * when it's packaged in the client extension files.
6
7
  * */
7
- declare function getProjectRoot(): string;
8
+ declare function getProjectRoot(): string | null;
8
9
  /**
9
10
  * A utility function for providers that implements lazy computation of values when the cache does not contain the specified key.
10
11
  *
@@ -14,7 +15,33 @@ declare function getProjectRoot(): string;
14
15
  * @returns the cached value (having been computed and added to the cache if absent when requested)
15
16
  */
16
17
  declare function computeIfAbsent(cache: Map<string, any>, key: string, fn: () => any): any;
17
- declare function readJSONFile(path: string): string;
18
+ /**
19
+ * A lookup key is turned into a file system path by the config-tree and profile providers, so it has to be
20
+ * treated as a path segment rather than as free text: anything that could escape the directory it is joined
21
+ * to (`..`, separators, a leading dot) is rejected.
22
+ */
23
+ declare function isSafePathSegment(value: string): boolean;
24
+ /**
25
+ * Resolve `name` against `root`, refusing anything that is unsafe as a path segment or that resolves (after
26
+ * following symlinks) to a location outside of `root`. Volume mounted ConfigMaps/Secrets are built out of
27
+ * symlinks into a `..data` directory inside the tree, so containment is checked on the resolved path rather
28
+ * than by refusing links outright.
29
+ */
30
+ declare function resolveContainedFile(root: string, name: string): string | undefined;
31
+ /**
32
+ * Strip the trailing newline that volume mounted ConfigMap/Secret files always carry.
33
+ */
34
+ declare function trimFileValue(value: any): any;
35
+ /**
36
+ * The value of a sensitive key must never reach a log line, not even in verbose mode.
37
+ */
38
+ declare function redactValue(key: string, value: any): any;
39
+ /**
40
+ * Read a key from a parsed JSON object without falling through to the prototype chain, so that keys like
41
+ * `__proto__` or `constructor` resolve to nothing instead of returning an object that no file ever declared.
42
+ */
43
+ declare function readKey(json: Record<string, any>, key: string): any;
44
+ declare function readJSONFile(filePath: string): Record<string, any> | undefined;
18
45
  /**
19
46
  * A utility function to enable verbose output from this library, convenient for debugging.
20
47
  *
@@ -22,4 +49,9 @@ declare function readJSONFile(path: string): string;
22
49
  */
23
50
  declare function setVerbose(b: boolean): void;
24
51
  declare function unquote(it: any): any;
25
- export { computeIfAbsent, getProjectRoot, protectedKeys, readJSONFile, setVerbose, verbose, unquote };
52
+ /**
53
+ * A comma delimited list is how the flat text sources express a list (an environment variable, or a file in a
54
+ * volume mounted ConfigMap); JSON sources can express an array for real, so they are not split this way.
55
+ */
56
+ declare function commaSeparated(it: any): any;
57
+ export { commaSeparated, computeIfAbsent, findProjectRoot, getProjectRoot, isSafePathSegment, protectedKeys, readJSONFile, readKey, redactValue, resolveContainedFile, setVerbose, trimFileValue, unquote, verbose };
@@ -3,26 +3,30 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.unquote = exports.verbose = exports.setVerbose = exports.readJSONFile = exports.protectedKeys = exports.getProjectRoot = exports.computeIfAbsent = void 0;
6
+ exports.verbose = exports.unquote = exports.trimFileValue = exports.setVerbose = exports.resolveContainedFile = exports.redactValue = exports.readKey = exports.readJSONFile = exports.protectedKeys = exports.isSafePathSegment = exports.getProjectRoot = exports.findProjectRoot = exports.computeIfAbsent = exports.commaSeparated = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const fs_1 = __importDefault(require("fs"));
9
9
  let verbose = false;
10
10
  exports.verbose = verbose;
11
11
  const protectedKeys = [
12
12
  'config.node.config.trees',
13
- 'config.node.profiles.active'
13
+ 'config.node.profiles.active',
14
+ 'config.node.config.verbose'
14
15
  ];
15
16
  exports.protectedKeys = protectedKeys;
17
+ const sensitiveKeyPattern = /(secret|password|passwd|token|credential|api[-_.]?key|private[-_.]?key)/i;
16
18
  function findProjectRoot(currentPath = process.cwd()) {
17
19
  const hasPackageJson = fs_1.default.existsSync(path_1.default.join(currentPath, 'package.json'));
18
20
  if (hasPackageJson) {
19
21
  return currentPath;
20
22
  }
21
- if (currentPath === path_1.default.resolve('/')) {
23
+ // a path is its own parent only at the filesystem root, which keeps this terminating on Windows too
24
+ if (path_1.default.dirname(currentPath) === currentPath) {
22
25
  return null;
23
26
  }
24
27
  return findProjectRoot(path_1.default.dirname(currentPath));
25
28
  }
29
+ exports.findProjectRoot = findProjectRoot;
26
30
  /**
27
31
  * A utility function to get the root folder of the parent project, use this function to get the application.json file
28
32
  * when it's packaged in the client extension files.
@@ -57,14 +61,82 @@ function computeIfAbsent(cache, key, fn) {
57
61
  return value;
58
62
  }
59
63
  exports.computeIfAbsent = computeIfAbsent;
60
- function readJSONFile(path) {
61
- if (fs_1.default.existsSync(path)) {
62
- const contents = fs_1.default.readFileSync(path, 'utf8');
64
+ /**
65
+ * A lookup key is turned into a file system path by the config-tree and profile providers, so it has to be
66
+ * treated as a path segment rather than as free text: anything that could escape the directory it is joined
67
+ * to (`..`, separators, a leading dot) is rejected.
68
+ */
69
+ function isSafePathSegment(value) {
70
+ return typeof value === 'string' &&
71
+ value.length > 0 &&
72
+ !value.includes('/') &&
73
+ !value.includes('\\') &&
74
+ !value.includes('\0') &&
75
+ !value.includes('..') &&
76
+ !value.startsWith('.');
77
+ }
78
+ exports.isSafePathSegment = isSafePathSegment;
79
+ /**
80
+ * Resolve `name` against `root`, refusing anything that is unsafe as a path segment or that resolves (after
81
+ * following symlinks) to a location outside of `root`. Volume mounted ConfigMaps/Secrets are built out of
82
+ * symlinks into a `..data` directory inside the tree, so containment is checked on the resolved path rather
83
+ * than by refusing links outright.
84
+ */
85
+ function resolveContainedFile(root, name) {
86
+ if (!root || !isSafePathSegment(name)) {
87
+ return undefined;
88
+ }
89
+ const candidate = path_1.default.join(root, name);
90
+ if (!fs_1.default.existsSync(candidate)) {
91
+ return undefined;
92
+ }
93
+ try {
94
+ const realRoot = fs_1.default.realpathSync(root);
95
+ const realCandidate = fs_1.default.realpathSync(candidate);
96
+ if (realCandidate !== realRoot && !realCandidate.startsWith(realRoot + path_1.default.sep)) {
97
+ return undefined;
98
+ }
99
+ return realCandidate;
100
+ }
101
+ catch (e) {
102
+ // the candidate exists but could not be resolved (a mocked fs, or a race with a deleted entry): the key
103
+ // itself has already been validated as a single path segment, and the read that follows will fail on its
104
+ // own if the path is really gone
105
+ return candidate;
106
+ }
107
+ }
108
+ exports.resolveContainedFile = resolveContainedFile;
109
+ /**
110
+ * Strip the trailing newline that volume mounted ConfigMap/Secret files always carry.
111
+ */
112
+ function trimFileValue(value) {
113
+ return typeof value === 'string' ? value.replace(/[\r\n]+$/, '') : value;
114
+ }
115
+ exports.trimFileValue = trimFileValue;
116
+ /**
117
+ * The value of a sensitive key must never reach a log line, not even in verbose mode.
118
+ */
119
+ function redactValue(key, value) {
120
+ return sensitiveKeyPattern.test(key) ? '[redacted]' : value;
121
+ }
122
+ exports.redactValue = redactValue;
123
+ /**
124
+ * Read a key from a parsed JSON object without falling through to the prototype chain, so that keys like
125
+ * `__proto__` or `constructor` resolve to nothing instead of returning an object that no file ever declared.
126
+ */
127
+ function readKey(json, key) {
128
+ return json && Object.prototype.hasOwnProperty.call(json, key) ? json[key] : undefined;
129
+ }
130
+ exports.readKey = readKey;
131
+ function readJSONFile(filePath) {
132
+ if (fs_1.default.existsSync(filePath)) {
133
+ const contents = fs_1.default.readFileSync(filePath, 'utf8');
63
134
  try {
64
135
  return JSON.parse(contents);
65
136
  }
66
137
  catch (error) {
67
- console.error('[config-node]', 'contents', contents, error);
138
+ // never log the contents: a truncated or hand-edited config file is exactly where secrets live
139
+ console.error('[config-node]', 'could not parse', filePath, ':', error.message);
68
140
  }
69
141
  }
70
142
  return undefined;
@@ -80,6 +152,11 @@ function setVerbose(b) {
80
152
  }
81
153
  exports.setVerbose = setVerbose;
82
154
  function unquote(it) {
155
+ if (typeof it === "boolean" || typeof it === "number") {
156
+ // a JSON file is allowed to express false/0; providers use a falsy return for "no value", so a legitimate
157
+ // scalar has to travel as a string
158
+ return String(it);
159
+ }
83
160
  if (typeof it === "string") {
84
161
  if (it.startsWith('"') && it.endsWith('"')) {
85
162
  return it.slice(1, -1);
@@ -87,11 +164,19 @@ function unquote(it) {
87
164
  else if (it.startsWith('\'') && it.endsWith('\'')) {
88
165
  return it.slice(1, -1);
89
166
  }
90
- if (it.includes(',')) {
91
- return it.split(',');
92
- }
93
167
  }
94
168
  return it;
95
169
  }
96
170
  exports.unquote = unquote;
171
+ /**
172
+ * A comma delimited list is how the flat text sources express a list (an environment variable, or a file in a
173
+ * volume mounted ConfigMap); JSON sources can express an array for real, so they are not split this way.
174
+ */
175
+ function commaSeparated(it) {
176
+ if (typeof it === 'string' && it.includes(',')) {
177
+ return it.split(',');
178
+ }
179
+ return it;
180
+ }
181
+ exports.commaSeparated = commaSeparated;
97
182
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/config-node/util/index.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,4CAAoB;AAEpB,IAAI,OAAO,GAAY,KAAK,CAAC;AA+FqD,0BAAO;AA7FzF,MAAM,aAAa,GAAG;IACpB,0BAA0B;IAC1B,6BAA6B;CAC9B,CAAC;AA0FuC,sCAAa;AAxFtD,SAAS,eAAe,CAAC,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE;IAClD,MAAM,cAAc,GAAG,YAAE,CAAC,UAAU,CAAC,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC,CAAC;IAE7E,IAAI,cAAc,EAAE,CAAC;QACnB,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,IAAI,WAAW,KAAK,cAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACtC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,eAAe,CAAC,cAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;AACpD,CAAC;AACD;;;KAGK;AACL,SAAS,cAAc;IACrB,MAAM,uBAAuB,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC9C,MAAM,WAAW,GAAG,eAAe,CAAC,uBAAuB,CAAC,CAAC;IAE7D,OAAO,WAAW,CAAC;AACrB,CAAC;AAkEwB,wCAAc;AAhEvC;;;;;;;GAOG;AACH,SAAS,eAAe,CAAC,KAAuB,EAAE,GAAW,EAAE,EAAa;IAC1E,IAAI,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAE3B,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,IAAI,CAAC;YACH,KAAK,GAAG,EAAE,EAAE,CAAC;QACf,CAAC;QAAC,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IAC7B,IAAI,OAAO,EAAE,KAAK,QAAQ,IAAI,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/C,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAGC,wCAAc"}
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@rotty3000/config-node",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "A library for obtaining external configuration for your application.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "scripts": {
8
+ "build": "tsc -p tsconfig.build.json",
9
+ "check": "tsc -p tsconfig.json",
8
10
  "clean": "rm -rf dist",
9
- "prepublish": "npm run clean && tsc",
10
- "build": "tsc",
11
- "run": "npm run clean && npm run build && node dist/src/index.js",
12
- "test": "npm run clean && npm run build && ts-mocha test/*.ts"
11
+ "prepublishOnly": "npm run clean && npm run build",
12
+ "test": "npm run check && ts-mocha test/*.ts"
13
13
  },
14
14
  "author": "Raymond Augé",
15
15
  "license": "Apache-2.0",
@@ -19,7 +19,6 @@
19
19
  "@types/node": "^20.10.4",
20
20
  "@types/sinon": "^17.0.2",
21
21
  "chai": "^4.3.10",
22
- "copyfiles": "^2.4.1",
23
22
  "mocha": "^10.2.0",
24
23
  "sinon": "^17.0.1",
25
24
  "ts-mocha": "^10.0.0",
@@ -45,4 +44,4 @@
45
44
  "url": "https://github.com/rotty3000/config-node/issues"
46
45
  },
47
46
  "homepage": "https://github.com/rotty3000/config-node#readme"
48
- }
47
+ }
@@ -1,30 +0,0 @@
1
- # This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2
- # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
3
-
4
- name: Node.js CI
5
-
6
- on:
7
- push:
8
- branches: [ "main" ]
9
- pull_request:
10
- branches: [ "main" ]
11
-
12
- jobs:
13
- build:
14
-
15
- runs-on: ubuntu-latest
16
-
17
- strategy:
18
- matrix:
19
- node-version: [16.x, 18.x]
20
- # See supported Node.js release schedule at https://nodejs.org/en/about/releases/
21
-
22
- steps:
23
- - uses: actions/checkout@v3
24
- - name: Use Node.js ${{ matrix.node-version }}
25
- uses: actions/setup-node@v3
26
- with:
27
- node-version: ${{ matrix.node-version }}
28
- cache: 'npm'
29
- - run: npm ci
30
- - run: npm test
package/.nvmrc DELETED
@@ -1 +0,0 @@
1
- v16.20.2
@@ -1,4 +0,0 @@
1
- ## Release process
2
-
3
- 1. Tag a commit (format `v#.#.#`)
4
- 1. Run `npm publish --access public`