bdy 1.22.20-dev → 1.22.23-beta

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.20-dev",
4
+ "version": "1.22.23-beta",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "scripts": {
@@ -20,7 +20,7 @@ const utils_1 = require("./utils");
20
20
  exports.ERR_REST_API_GENERAL_ERROR = 'Something went wrong';
21
21
  exports.ERR_REST_API_NOT_RESPONDING = 'Api endpoint not responding. Try again later...';
22
22
  exports.ERR_REST_API_CONNECT_ERROR = 'Connection refused. Check selected endpoint';
23
- exports.ERR_REST_API_WRONG_TOKEN = 'Valid token with proper scopes is required or run bdy login';
23
+ exports.ERR_REST_API_WRONG_TOKEN = "Unauthorized (401): Invalid or missing token. Run 'buddy login' to authenticate";
24
24
  exports.ERR_REST_API_RESOURCE_NOT_FOUND = 'Resource not found';
25
25
  const ERR_REST_API_RATE_LIMIT = (rateLimitReset) => {
26
26
  if (rateLimitReset) {
@@ -812,6 +812,9 @@ const ERR_API_MESSAGE_REPLACER = (message, path, baseUrl, rateLimitTs) => {
812
812
  workspaceUrl = (0, utils_1.getAppWorkspaceSettingsUrl)(baseUrl, m[1]);
813
813
  }
814
814
  }
815
+ if (message === 'Rate limit exceeded') {
816
+ return (0, exports.ERR_REST_API_RATE_LIMIT)(rateLimitTs);
817
+ }
815
818
  if (message === 'API is disabled in this workspace') {
816
819
  message =
817
820
  'API is disabled in this workspace. To enable it, ask a workspace admin to update the settings';
@@ -819,8 +822,8 @@ const ERR_API_MESSAGE_REPLACER = (message, path, baseUrl, rateLimitTs) => {
819
822
  message += `: ${workspaceUrl}`;
820
823
  }
821
824
  }
822
- if (message === 'Rate limit exceeded') {
823
- return (0, exports.ERR_REST_API_RATE_LIMIT)(rateLimitTs);
825
+ else if (message === 'Access denied') {
826
+ message = "You don't have permission to perform this action";
824
827
  }
825
828
  return message;
826
829
  };
@@ -46,6 +46,22 @@ class ServerSftp {
46
46
  this.count = 0;
47
47
  this.sftp = sftp;
48
48
  this.home = (0, node_os_1.homedir)();
49
+ // fix for sftp/scp exit status -1: send exit-status and EOF before channel close
50
+ // https://github.com/mscdex/ssh2/pull/1492
51
+ const s = sftp;
52
+ const origDestroy = s.destroy.bind(s);
53
+ s.destroy = () => {
54
+ try {
55
+ if (s.outgoing?.state === 'open') {
56
+ s._protocol.exitStatus(s.outgoing.id, 0);
57
+ s._protocol.channelEOF(s.outgoing.id);
58
+ }
59
+ }
60
+ catch {
61
+ // do nothing
62
+ }
63
+ return origDestroy();
64
+ };
49
65
  this.sftp.on('OPEN', (reqId, fileName, flags, attrs) => this.open(reqId, fileName, flags, attrs));
50
66
  this.sftp.on('READ', (reqId, handle, offset, length) => this.read(reqId, handle, offset, length));
51
67
  this.sftp.on('WRITE', (reqId, handle, offset, data) => this.write(reqId, handle, offset, data));
@@ -40,7 +40,7 @@ class ServerSsh extends events_1.default {
40
40
  this.password = password;
41
41
  this.server = new ssh2_1.default.Server({
42
42
  hostKeys: [hostKey],
43
- highWaterMark: 16 * 1024 * 1024,
43
+ highWaterMark: 65536,
44
44
  ident: 'ssh2 server',
45
45
  }, (client) => this.processClient(client));
46
46
  this.server.listen();
@@ -251,20 +251,15 @@ class ServerSsh extends events_1.default {
251
251
  session.on('close', () => closeSession());
252
252
  session.on('end', () => closeSession());
253
253
  session.on('eof', () => {
254
- try {
255
- // @ts-ignore fix for sftp channel not ending properly https://github.com/mscdex/ssh2/pull/1111
256
- if (session._channel) {
257
- // fix for sftp/scp exit status -1: send exit-status before EOF https://github.com/mscdex/ssh2/pull/1492
258
- if (sftp) {
259
- // @ts-ignore
260
- session._channel.exit(0);
261
- }
254
+ // @ts-ignore fix for sftp channel not ending properly https://github.com/mscdex/ssh2/pull/1111
255
+ if (session._channel) {
256
+ try {
262
257
  // @ts-ignore
263
258
  session._channel.end();
264
259
  }
265
- }
266
- catch {
267
- // do nothing
260
+ catch {
261
+ // do nothing
262
+ }
268
263
  }
269
264
  });
270
265
  session.on('pty', (accept, reject, info) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bdy",
3
3
  "preferGlobal": false,
4
- "version": "1.22.20-dev",
4
+ "version": "1.22.23-beta",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "scripts": {