@travetto/config 3.0.0-rc.22 → 3.0.0-rc.24

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/config",
3
- "version": "3.0.0-rc.22",
3
+ "version": "3.0.0-rc.24",
4
4
  "description": "Configuration support",
5
5
  "keywords": [
6
6
  "yaml",
@@ -26,9 +26,9 @@
26
26
  "directory": "module/config"
27
27
  },
28
28
  "dependencies": {
29
- "@travetto/di": "^3.0.0-rc.21",
30
- "@travetto/schema": "^3.0.0-rc.22",
31
- "@travetto/yaml": "^3.0.0-rc.18"
29
+ "@travetto/di": "^3.0.0-rc.23",
30
+ "@travetto/schema": "^3.0.0-rc.24",
31
+ "@travetto/yaml": "^3.0.0-rc.20"
32
32
  },
33
33
  "travetto": {
34
34
  "displayName": "Configuration"
@@ -26,6 +26,7 @@ export class Configuration {
26
26
  #storage: Record<string, unknown> = {}; // Lowered, and flattened
27
27
  #profiles: string[] = ['application', ...GlobalEnv.profiles, 'override'];
28
28
  #sources: string[] = [];
29
+ #secrets: (RegExp | string)[] = [/password|private|secret/i];
29
30
 
30
31
  /**
31
32
  * Get a sub tree of the config, or everything if namespace is not passed
@@ -67,6 +68,18 @@ export class Configuration {
67
68
  for (const { config: element } of sorted) {
68
69
  DataUtil.deepAssign(this.#storage, BindUtil.expandPaths(element), 'coerce');
69
70
  }
71
+
72
+ // Initialize Secrets
73
+ const userSpecified = (this.#get('config')?.secrets ?? []);
74
+ for (const el of Array.isArray(userSpecified) ? userSpecified : [userSpecified]) {
75
+ if (el !== undefined && el !== null && typeof el === 'string') {
76
+ if (el.startsWith('/')) {
77
+ this.#secrets.push(DataUtil.coerceType(el, RegExp, true));
78
+ } else {
79
+ this.#secrets.push(DataUtil.coerceType(el, String, true));
80
+ }
81
+ }
82
+ }
70
83
  }
71
84
 
72
85
  /**
@@ -89,7 +102,7 @@ export class Configuration {
89
102
  const data = BindUtil.bindSchemaToObject<ConfigData>(
90
103
  inst.constructor, {}, inst, { filterField: f => !f.secret, filterValue: v => v !== undefined }
91
104
  );
92
- out[el.class.name] = data;
105
+ out[el.class.name] = DataUtil.filterByKeys(data, this.#secrets);
93
106
  }
94
107
  return { sources: this.#sources, active: out };
95
108
  }