bdy 1.22.72 → 1.22.73-stage

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bdy",
3
3
  "preferGlobal": false,
4
- "version": "1.22.72",
4
+ "version": "1.22.73-stage",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "scripts": {
@@ -95,16 +95,28 @@ class ServerSsh extends events_1.default {
95
95
  async verifyKey(ctx, keys) {
96
96
  try {
97
97
  for (let i = 0; i < keys.length; i += 1) {
98
- const publicKey = ssh2_1.default.utils.parseKey(keys[i]);
99
- if (publicKey instanceof Error)
98
+ const key = keys[i];
99
+ const content = key.content ? key.content : key;
100
+ const publicKey = ssh2_1.default.utils.parseKey(content);
101
+ if (publicKey instanceof Error) {
100
102
  continue;
101
- if (ctx.key.algo !== publicKey.type)
103
+ }
104
+ if (ctx.key.algo !== publicKey.type) {
102
105
  continue;
103
- if (!this.checkValueSafe(ctx.key.data, publicKey.getPublicSSH()))
106
+ }
107
+ if (!this.checkValueSafe(ctx.key.data, publicKey.getPublicSSH())) {
104
108
  continue;
109
+ }
105
110
  if (ctx.signature &&
106
- !publicKey.verify(ctx.blob || '', ctx.signature, ctx.hashAlgo))
111
+ !publicKey.verify(ctx.blob || '', ctx.signature, ctx.hashAlgo)) {
107
112
  continue;
113
+ }
114
+ if (key.name && key.email) {
115
+ return {
116
+ name: key.name,
117
+ email: key.email
118
+ };
119
+ }
108
120
  return true;
109
121
  }
110
122
  }
@@ -158,7 +170,7 @@ class ServerSsh extends events_1.default {
158
170
  try {
159
171
  const resp = await buddy_1.default.fetchAgentKeys(this.agent.id, this.agent.host, this.agent.token);
160
172
  logger_1.default.debug(resp);
161
- keys = resp.keys;
173
+ keys = resp.userKeys || resp.keys;
162
174
  privateKey = resp.privateKey;
163
175
  user = resp.user || 'root';
164
176
  }
@@ -177,7 +189,17 @@ class ServerSsh extends events_1.default {
177
189
  const proxyClient = await this.createProxyConnection(privateKey, user);
178
190
  logger_1.default.debug('proxy connected');
179
191
  ctx.accept();
180
- return proxyClient;
192
+ const env = {};
193
+ if (typeof verified === 'object' && verified.name && verified.email) {
194
+ env.GIT_AUTHOR_NAME = verified.name;
195
+ env.GIT_AUTHOR_EMAIL = verified.email;
196
+ env.GIT_COMMITTER_NAME = verified.name;
197
+ env.GIT_COMMITTER_EMAIL = verified.email;
198
+ }
199
+ return {
200
+ proxyClient,
201
+ env
202
+ };
181
203
  }
182
204
  catch (err) {
183
205
  logger_1.default.debug('proxy not connected');
@@ -244,8 +266,8 @@ class ServerSsh extends events_1.default {
244
266
  stream.end();
245
267
  }
246
268
  }
247
- clientSession(session, client, proxyClient) {
248
- let env = {};
269
+ clientSession(session, client, proxyClient, globalEnv) {
270
+ let env = globalEnv ? { ...globalEnv } : {};
249
271
  let sftp;
250
272
  let channel;
251
273
  let pty;
@@ -448,11 +470,14 @@ class ServerSsh extends events_1.default {
448
470
  processClient(client) {
449
471
  logger_1.default.debug('new ssh client');
450
472
  let proxyClient;
473
+ let globalEnv = {};
451
474
  client.setNoDelay();
452
475
  client.on('authentication', async (ctx) => {
453
476
  logger_1.default.debug('ssh authentication');
454
- proxyClient = await this.authenticateClient(ctx);
455
- if (proxyClient) {
477
+ const ac = await this.authenticateClient(ctx);
478
+ if (ac) {
479
+ proxyClient = ac.proxyClient;
480
+ globalEnv = ac.env;
456
481
  proxyClient.on('tcp connection', (details, accept, reject) => {
457
482
  logger_1.default.debug('new ssh client forward connection');
458
483
  logger_1.default.debug(details);
@@ -556,7 +581,7 @@ class ServerSsh extends events_1.default {
556
581
  });
557
582
  client.on('session', (accept) => {
558
583
  logger_1.default.debug('ssh session');
559
- this.clientSession(accept(), client, proxyClient);
584
+ this.clientSession(accept(), client, proxyClient, globalEnv);
560
585
  });
561
586
  }
562
587
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bdy",
3
3
  "preferGlobal": false,
4
- "version": "1.22.72",
4
+ "version": "1.22.73-stage",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "scripts": {