bdy 1.22.56-stage → 1.22.57-dev

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.56-stage",
4
+ "version": "1.22.57-dev",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "scripts": {
@@ -38,8 +38,7 @@ commandSandboxEndpointGet.action(async (identifier, endpointName, options) => {
38
38
  ['Endpoint', endpoint.endpoint || '-'],
39
39
  ['Type', endpoint.type || '-'],
40
40
  ['Region', endpoint.region || '-'],
41
- ['Active', endpoint.active ? output_1.default.getOkSign() : output_1.default.getCancelSign()],
42
- ['Target Latency', typeof endpoint.target_latency === 'number' && endpoint.target_latency >= 0 ? `${endpoint.target_latency}ms` : '-'],
41
+ ['Status', (0, utils_1.isSandboxEndpointActive)(endpoint) ? 'Online' : 'Offline'],
43
42
  ['URL', endpoint.endpoint_url || '-'],
44
43
  ['Timeout', endpoint.timeout?.toString() || '-'],
45
44
  ];
@@ -47,18 +46,18 @@ commandSandboxEndpointGet.action(async (identifier, endpointName, options) => {
47
46
  data.push(['Whitelist', endpoint.whitelist?.join(', ')]);
48
47
  }
49
48
  if (endpoint.http) {
50
- data.push(['HTTP2', endpoint.http.http2 ? 'TRUE' : 'FALSE']);
49
+ data.push(['HTTP2', endpoint.http.http2 ? output_1.default.getOkSign() : output_1.default.getCancelSign()]);
51
50
  data.push([
52
51
  'Verify certificate',
53
- endpoint.http.verify_certificate ? 'TRUE' : 'FALSE',
52
+ endpoint.http.verify_certificate ? output_1.default.getOkSign() : output_1.default.getCancelSign(),
54
53
  ]);
55
54
  data.push([
56
55
  'Compression',
57
- endpoint.http.compression ? 'TRUE' : 'FALSE',
56
+ endpoint.http.compression ? output_1.default.getOkSign() : output_1.default.getCancelSign(),
58
57
  ]);
59
58
  data.push([
60
59
  'Log requests',
61
- endpoint.http.log_requests ? 'TRUE' : 'FALSE',
60
+ endpoint.http.log_requests ? output_1.default.getOkSign() : output_1.default.getCancelSign(),
62
61
  ]);
63
62
  data.push(['Auth type', endpoint.http.auth_type]);
64
63
  if (endpoint.http.serve_path) {
@@ -76,21 +75,23 @@ commandSandboxEndpointGet.action(async (identifier, endpointName, options) => {
76
75
  if (endpoint.http.rewrite_host_header) {
77
76
  data.push(['Rewrite host header', endpoint.http.rewrite_host_header]);
78
77
  }
79
- let headers = Object.keys(endpoint.http.request_headers || {});
80
- if (headers.length) {
78
+ const requestHeaders = endpoint.http.request_headers || {};
79
+ const requestHeadersKeys = Object.keys(requestHeaders);
80
+ if (requestHeadersKeys.length) {
81
81
  data.push([
82
82
  'Request headers',
83
- headers
84
- .map((key) => `${key}: ${endpoint.http.request_headers[key]}`)
83
+ requestHeadersKeys
84
+ .map((key) => `${key}: ${requestHeaders[key]}`)
85
85
  .join('\n '),
86
86
  ]);
87
87
  }
88
- headers = Object.keys(endpoint.http.response_headers || {});
89
- if (headers.length) {
88
+ const responseHeaders = endpoint.http.response_headers || {};
89
+ const responseHeadersKeys = Object.keys(responseHeaders);
90
+ if (responseHeadersKeys.length) {
90
91
  data.push([
91
92
  'Request headers',
92
- headers
93
- .map((key) => `${key}: ${endpoint.http.response_headers[key]}`)
93
+ responseHeadersKeys
94
+ .map((key) => `${key}: ${responseHeaders[key]}`)
94
95
  .join('\n '),
95
96
  ]);
96
97
  }
@@ -31,15 +31,16 @@ commandSandboxEndpointList.action(async (identifier, options) => {
31
31
  if (endpoints.length === 0) {
32
32
  output_1.default.exitError(texts_1.ERR_SANDBOX_ENDPOINTS_NOT_FOUND);
33
33
  }
34
- const data = [['Name', 'Endpoint', 'Type', 'Region', 'Active', 'Target Latency', 'URL']];
34
+ const data = [
35
+ ['Name', 'Endpoint', 'Type', 'Region', 'Status', 'URL'],
36
+ ];
35
37
  for (const ep of endpoints) {
36
38
  data.push([
37
39
  ep.name || '-',
38
40
  ep.endpoint || '-',
39
41
  ep.type || '-',
40
42
  ep.region || '-',
41
- ep.active ? output_1.default.getOkSign() : output_1.default.getCancelSign(),
42
- typeof ep.target_latency === 'number' && ep.target_latency >= 0 ? `${ep.target_latency}ms` : '-',
43
+ (0, utils_1.isSandboxEndpointActive)(ep) ? 'Online' : 'Offline',
43
44
  ep.endpoint_url || '-',
44
45
  ]);
45
46
  }
@@ -854,7 +854,7 @@ exports.TXT_LOGIN_PROVIDE_CODE = 'Paste code here if prompted >';
854
854
  exports.TXT_LOGIN_ENTER_BASE_URL = 'Enter your Buddy instance URL (e.g., buddy.company.com):';
855
855
  exports.TXT_LOGIN_SELECT_WORKSPACE = 'Select workspace:';
856
856
  exports.TXT_LOGIN_SUCCESS = 'Logged in successfully!';
857
- exports.TXT_REGISTER_SUCCESS = 'Signed up successfully!';
857
+ exports.TXT_REGISTER_SUCCESS = 'Account created. Logged in successfully!';
858
858
  exports.ERR_LOGIN_HTTP_SERVER_PORT_TAKEN = 'Cant start local http server to authorize';
859
859
  exports.ERR_LOGIN_HTTP_FAILED = 'Buddy CLI failed to authorize. Try again...';
860
860
  exports.ERR_LOGIN_HTTP_CANCEL = 'Login canceled';
@@ -1145,13 +1145,19 @@ exports.EXAMPLE_SANDBOX_CREATE = `
1145
1145
  bdy sb create -vf path/to/env/file
1146
1146
  ### create sandbox from yaml file:
1147
1147
  bdy sb create --yaml @./test.yml"`;
1148
- const EXAMPLE_TUNNEL_HTTP = (agent) => `
1148
+ const EXAMPLE_TUNNEL_HTTP = (agent) => {
1149
+ let r = `
1149
1150
  ### start http tunnel on port 80:
1150
1151
  bdy ${agent ? 'agent ' : ''}tunnel http 80
1151
- ### start named http tunnel and serve local directory:
1152
- bdy ${agent ? 'agent ' : ''}tunnel http -n name -s /path/to/dir
1153
1152
  ### start http tunnel, whitelist ip and turn on on basic auth:
1154
1153
  bdy ${agent ? 'agent ' : ''}tunnel http https://myhost.com -w 1.1.1.1 -a user:pass`;
1154
+ if (!agent) {
1155
+ r += `
1156
+ ### start named http tunnel and serve local directory:
1157
+ bdy tunnel http -n name -s /path/to/dir`;
1158
+ }
1159
+ return r;
1160
+ };
1155
1161
  exports.EXAMPLE_TUNNEL_HTTP = EXAMPLE_TUNNEL_HTTP;
1156
1162
  exports.EXAMPLE_AGENT_TUNNEL_LIST = `
1157
1163
  ### list agent tunnels:
@@ -600,12 +600,19 @@ class OutputInteractiveTunnel {
600
600
  updateSpriteStatus(y) {
601
601
  let text;
602
602
  let color;
603
- if (this.tunnel.status === tunnel_1.TUNNEL_STATUS.OPEN) {
604
- text = 'OPEN ';
603
+ let isActive = true;
604
+ if (this.tunnel.status !== tunnel_1.TUNNEL_STATUS.OPEN) {
605
+ isActive = false;
606
+ }
607
+ else if (this.tunnel.type !== tunnel_1.TUNNEL_TYPE.SSH && !(this.tunnel.type === tunnel_1.TUNNEL_TYPE.HTTP && this.tunnel.serve) && this.tunnel.targetLatency?.latency < 0) {
608
+ isActive = false;
609
+ }
610
+ if (isActive) {
611
+ text = 'ONLINE ';
605
612
  color = COLOR_GREEN;
606
613
  }
607
614
  else {
608
- text = 'CLOSED';
615
+ text = 'OFFLINE';
609
616
  color = COLOR_RED;
610
617
  }
611
618
  this.sprites.status.put({
@@ -26,15 +26,22 @@ class OutputNoninteractiveAgentTunnels {
26
26
  let status;
27
27
  if (tunnel.serve)
28
28
  target = format_1.default.serve(tunnel.serve) + ' / 0ms';
29
+ else {
30
+ target = format_1.default.target(tunnel.type, tunnel.target);
31
+ target += ` / ${format_1.default.latency(tunnel.targetLatency)}`;
32
+ }
33
+ let entry = format_1.default.entry(tunnel);
34
+ entry += ` / ${format_1.default.latency(tunnel.regionLatency)}`;
35
+ if (tunnel.status !== tunnel_1.TUNNEL_STATUS.OPEN)
36
+ status = 'Offline';
37
+ else if (tunnel.type === tunnel_1.TUNNEL_TYPE.SSH)
38
+ status = 'Online';
39
+ else if (tunnel.type === tunnel_1.TUNNEL_TYPE.HTTP && tunnel.serve)
40
+ status = 'Online';
41
+ else if (tunnel.targetLatency < 0)
42
+ status = 'Offline';
29
43
  else
30
- target =
31
- format_1.default.target(tunnel.type, tunnel.target) +
32
- ` / ${format_1.default.latency(tunnel.targetLatency)}`;
33
- const entry = format_1.default.entry(tunnel) + ` / ${format_1.default.latency(tunnel.regionLatency)}`;
34
- if (tunnel.status === tunnel_1.TUNNEL_STATUS.OPEN)
35
- status = 'Open';
36
- else
37
- status = 'Closed';
44
+ status = 'Online';
38
45
  tunnels.push([tunnel.id, tunnel.type, target, entry, status]);
39
46
  });
40
47
  output.table(tunnels);
@@ -51,6 +51,7 @@ exports.isInSandbox = isInSandbox;
51
51
  exports.isValidSubdomain = isValidSubdomain;
52
52
  exports.isValidEmail = isValidEmail;
53
53
  exports.isValidName = isValidName;
54
+ exports.isSandboxEndpointActive = isSandboxEndpointActive;
54
55
  exports.getSubdomain = getSubdomain;
55
56
  exports.getDomainTld = getDomainTld;
56
57
  exports.getPopularTlds = getPopularTlds;
@@ -62,6 +63,7 @@ const node_sea_1 = require("node:sea");
62
63
  const commander_1 = require("commander");
63
64
  const node_os_1 = __importStar(require("node:os"));
64
65
  const node_child_process_1 = require("node:child_process");
66
+ const tunnel_1 = require("./types/tunnel");
65
67
  exports.TUNNEL_HTTP_RATE_LIMIT = 2000;
66
68
  exports.TUNNEL_HTTP_RATE_WINDOW = 60000;
67
69
  exports.TUNNEL_HTTP_LOG_MAX_BODY = 5242880; // 5MB
@@ -728,6 +730,15 @@ function isValidEmail(email) {
728
730
  function isValidName(name) {
729
731
  return name.length > 0 && name.length <= 100;
730
732
  }
733
+ function isSandboxEndpointActive(ep) {
734
+ if (!ep.active)
735
+ return false;
736
+ if (ep.type === tunnel_1.TUNNEL_TYPE.HTTP && ep.http?.serve_path)
737
+ return true;
738
+ if (ep.type === tunnel_1.TUNNEL_TYPE.SSH)
739
+ return true;
740
+ return ep.target_latency >= 0;
741
+ }
731
742
  const getGitEmail = async () => {
732
743
  try {
733
744
  const out = await (0, exports.execLocally)('git config user.email', {}, true);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bdy",
3
3
  "preferGlobal": false,
4
- "version": "1.22.56-stage",
4
+ "version": "1.22.57-dev",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "scripts": {