vvauth 0.2.0 → 0.2.1

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 (2) hide show
  1. package/index.js +25 -10
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -110,22 +110,37 @@ class vvauth {
110
110
  let {entity_id} = await this._lookup_token(this.VAULT_TOKEN);
111
111
  let identity = await this._lookup_identity(this.VAULT_TOKEN, entity_id);
112
112
  let profile = {};
113
- for(let alias of identity.aliases)
114
- {for(let [k, v] of Object.entries(alias.custom_metadata || {}))
115
- {if(k.startsWith('env_'))
116
- profile[k.substr(4)] = v;}}
117
- for(let [k, v] of Object.entries(identity.metadata || {}))
118
- {if(k.startsWith('env_'))
119
- profile[k.substr(4)] = v;}
113
+ for(let alias of identity.aliases) {
114
+ for(let [k, v] of Object.entries(alias.custom_metadata || {})) {
115
+ if(k.startsWith('env_'))
116
+ profile[k.substr(4)] = v;
117
+ }
118
+ }
119
+ for(let [k, v] of Object.entries(identity.metadata || {})) {
120
+ if(k.startsWith('env_'))
121
+ profile[k.substr(4)] = v;
122
+ }
120
123
  return {entity_id, identity, profile};
121
124
  }
122
125
 
123
126
  async env(source = false) {
124
127
  let {profile} = await this._get_profile();
125
128
 
126
- let env = {VAULT_TOKEN : this.VAULT_TOKEN};
127
- for(let [k, v] of Object.entries(this.rc.env || {}))
128
- env[k] = profile[v];
129
+ let env = {VAULT_TOKEN : this.VAULT_TOKEN}, {env : {git, map}} = this.rc;
130
+ if(git) {
131
+ map = {...map,
132
+ "GIT_COMMITTER_NAME" : "VAUTH_USER_NAME",
133
+ "GIT_COMMITTER_EMAIL" : "VAUTH_USER_MAIL",
134
+ "GIT_AUTHOR_EMAIL" : "VAUTH_USER_MAIL",
135
+ "GIT_AUTHOR_NAME" : "VAUTH_USER_NAME",
136
+ "GIT_USER_LOGIN" : "VAUTH_USER_LOGIN",
137
+ };
138
+ }
139
+
140
+ for(let [k, v] of Object.entries(map || {})) {
141
+ if(profile[v])
142
+ env[k] = profile[v];
143
+ }
129
144
 
130
145
  if(source) {
131
146
  this._publish_env(env);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vvauth",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Vault Auth helper",
5
5
  "main": "index.js",
6
6
  "bin": {