vvauth 1.0.5 → 1.1.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/index.js +29 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -147,6 +147,34 @@ class vvauth {
|
|
|
147
147
|
return {entity_id, identity, profile};
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
+
|
|
151
|
+
async dotenv() {
|
|
152
|
+
let {profile} = await this._get_profile();
|
|
153
|
+
|
|
154
|
+
let env = {VAULT_TOKEN : this.VAULT_TOKEN, VAULT_ADDR : this.VAULT_ADDR}, secrets = {},
|
|
155
|
+
{map = {}, paths, path : mount = "secrets"} = this.rc.env || {};
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
if(paths) {
|
|
159
|
+
for(let secret_path of paths) {
|
|
160
|
+
console.error("reaching paths", secret_path);
|
|
161
|
+
let data = await this._read(mount, secret_path);
|
|
162
|
+
secrets = {...secrets, ...data};
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
}
|
|
166
|
+
for(let [k, v] of Object.entries(map))
|
|
167
|
+
env[k] = replaceEnv(v, {env : process.env, profile, secrets});
|
|
168
|
+
|
|
169
|
+
for(let [k, v] of Object.entries(env)) {
|
|
170
|
+
process.stdout.write(`${k}=${shellEscape(v)}\n`);
|
|
171
|
+
process.stderr.write(`export ${k}=[redacted]\n`);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
process.exit();
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
|
|
150
178
|
async env(source = false) {
|
|
151
179
|
let {profile} = await this._get_profile();
|
|
152
180
|
|
|
@@ -282,7 +310,7 @@ class vvauth {
|
|
|
282
310
|
|
|
283
311
|
const shellEscape = (arg) => {
|
|
284
312
|
// see man bash
|
|
285
|
-
return "'"+ String(arg).replace(/'/g, '\'"\'"\'') + "'"
|
|
313
|
+
return "'" + String(arg).replace(/'/g, '\'"\'"\'') + "'";
|
|
286
314
|
};
|
|
287
315
|
|
|
288
316
|
//ensure module is called directly, i.e. not required
|