bdy 1.22.65-dev → 1.22.66-master

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.65-dev",
4
+ "version": "1.22.66-master",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "scripts": {
@@ -95,28 +95,16 @@ 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 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) {
98
+ const publicKey = ssh2_1.default.utils.parseKey(keys[i]);
99
+ if (publicKey instanceof Error)
102
100
  continue;
103
- }
104
- if (ctx.key.algo !== publicKey.type) {
101
+ if (ctx.key.algo !== publicKey.type)
105
102
  continue;
106
- }
107
- if (!this.checkValueSafe(ctx.key.data, publicKey.getPublicSSH())) {
103
+ if (!this.checkValueSafe(ctx.key.data, publicKey.getPublicSSH()))
108
104
  continue;
109
- }
110
105
  if (ctx.signature &&
111
- !publicKey.verify(ctx.blob || '', ctx.signature, ctx.hashAlgo)) {
106
+ !publicKey.verify(ctx.blob || '', ctx.signature, ctx.hashAlgo))
112
107
  continue;
113
- }
114
- if (key.name && key.email) {
115
- return {
116
- name: key.name,
117
- email: key.email
118
- };
119
- }
120
108
  return true;
121
109
  }
122
110
  }
@@ -170,7 +158,7 @@ class ServerSsh extends events_1.default {
170
158
  try {
171
159
  const resp = await buddy_1.default.fetchAgentKeys(this.agent.id, this.agent.host, this.agent.token);
172
160
  logger_1.default.debug(resp);
173
- keys = resp.userKeys || resp.keys;
161
+ keys = resp.keys;
174
162
  privateKey = resp.privateKey;
175
163
  user = resp.user || 'root';
176
164
  }
@@ -189,17 +177,7 @@ class ServerSsh extends events_1.default {
189
177
  const proxyClient = await this.createProxyConnection(privateKey, user);
190
178
  logger_1.default.debug('proxy connected');
191
179
  ctx.accept();
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
- };
180
+ return proxyClient;
203
181
  }
204
182
  catch (err) {
205
183
  logger_1.default.debug('proxy not connected');
@@ -266,8 +244,8 @@ class ServerSsh extends events_1.default {
266
244
  stream.end();
267
245
  }
268
246
  }
269
- clientSession(session, client, proxyClient, globalEnv) {
270
- let env = globalEnv ? { ...globalEnv } : {};
247
+ clientSession(session, client, proxyClient) {
248
+ let env = {};
271
249
  let sftp;
272
250
  let channel;
273
251
  let pty;
@@ -470,14 +448,11 @@ class ServerSsh extends events_1.default {
470
448
  processClient(client) {
471
449
  logger_1.default.debug('new ssh client');
472
450
  let proxyClient;
473
- let globalEnv = {};
474
451
  client.setNoDelay();
475
452
  client.on('authentication', async (ctx) => {
476
453
  logger_1.default.debug('ssh authentication');
477
- const ac = await this.authenticateClient(ctx);
478
- if (ac) {
479
- proxyClient = ac.proxyClient;
480
- globalEnv = ac.env;
454
+ proxyClient = await this.authenticateClient(ctx);
455
+ if (proxyClient) {
481
456
  proxyClient.on('tcp connection', (details, accept, reject) => {
482
457
  logger_1.default.debug('new ssh client forward connection');
483
458
  logger_1.default.debug(details);
@@ -581,7 +556,7 @@ class ServerSsh extends events_1.default {
581
556
  });
582
557
  client.on('session', (accept) => {
583
558
  logger_1.default.debug('ssh session');
584
- this.clientSession(accept(), client, proxyClient, globalEnv);
559
+ this.clientSession(accept(), client, proxyClient);
585
560
  });
586
561
  }
587
562
  }
@@ -15,6 +15,7 @@ class SshClient extends events_1.default {
15
15
  password;
16
16
  keepalive;
17
17
  client;
18
+ lastError;
18
19
  constructor(ip, port, username, password) {
19
20
  super();
20
21
  this.ip = ip;
@@ -30,9 +31,13 @@ class SshClient extends events_1.default {
30
31
  this.client = new ssh2_1.Client();
31
32
  this.client.setNoDelay();
32
33
  this.client.on('ready', () => {
34
+ this.lastError = null;
33
35
  if (this.client) {
34
36
  this.client.removeAllListeners();
35
- this.client.on('error', () => { });
37
+ this.client.on('error', (err) => {
38
+ this.lastError = err;
39
+ logger_1.default.debug(`SSH client transport error: ${err?.message}`);
40
+ });
36
41
  }
37
42
  resolve();
38
43
  });
@@ -51,6 +56,7 @@ class SshClient extends events_1.default {
51
56
  kex: ['ecdh-sha2-nistp256'],
52
57
  },
53
58
  keepaliveInterval: 10000,
59
+ keepaliveCountMax: 6,
54
60
  host: this.ip,
55
61
  port: this.port,
56
62
  username: this.username,
@@ -179,7 +185,7 @@ class SshClient extends events_1.default {
179
185
  this.emit(tunnel_1.TUNNEL_SSH_EVENT.CONNECTED);
180
186
  if (this.client) {
181
187
  this.client.on('close', () => {
182
- logger_1.default.debug(`SSH client closed`);
188
+ logger_1.default.debug(`SSH client closed (reason: ${this.lastError?.message || 'clean close / no transport error'})`);
183
189
  if (this.keepalive)
184
190
  this.openKeepAlive();
185
191
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bdy",
3
3
  "preferGlobal": false,
4
- "version": "1.22.65-dev",
4
+ "version": "1.22.66-master",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "scripts": {