bdy 1.22.13-dev → 1.22.15-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.
- package/distTs/package.json +1 -1
- package/distTs/src/api/client.js +0 -1
- package/distTs/src/output.js +20 -0
- package/distTs/src/tunnel/api/agent.js +3 -2
- package/distTs/src/tunnel/api/buddy.js +2 -7
- package/distTs/src/tunnel/server/ssh.js +2 -0
- package/distTs/src/utils.js +2 -2
- package/distTs/src/visualTest/requests.js +1 -7
- package/package.json +1 -1
package/distTs/package.json
CHANGED
package/distTs/src/api/client.js
CHANGED
package/distTs/src/output.js
CHANGED
|
@@ -12,9 +12,11 @@ const texts_1 = require("./texts");
|
|
|
12
12
|
const tunnels_2 = __importDefault(require("./tunnel/output/noninteractive/agent/tunnels"));
|
|
13
13
|
const utils_1 = require("./utils");
|
|
14
14
|
const chalk_1 = __importDefault(require("chalk"));
|
|
15
|
+
const undici_1 = __importDefault(require("undici"));
|
|
15
16
|
const terminal = termkit_no_lazy_require_1.default.terminal;
|
|
16
17
|
class Output {
|
|
17
18
|
static s;
|
|
19
|
+
static _a;
|
|
18
20
|
static getCyanColor(text) {
|
|
19
21
|
return chalk_1.default.hex('#00C9FF')(text);
|
|
20
22
|
}
|
|
@@ -76,12 +78,14 @@ class Output {
|
|
|
76
78
|
this.exitNormal(this.getGreenColor(msg));
|
|
77
79
|
}
|
|
78
80
|
static exitNormal(msg) {
|
|
81
|
+
this.clearUndici();
|
|
79
82
|
this.clearTerminal();
|
|
80
83
|
if (msg)
|
|
81
84
|
terminal(`${msg}\n`);
|
|
82
85
|
process.exit(0);
|
|
83
86
|
}
|
|
84
87
|
static exitCode(code) {
|
|
88
|
+
this.clearUndici();
|
|
85
89
|
this.clearTerminal();
|
|
86
90
|
process.exit(code);
|
|
87
91
|
}
|
|
@@ -398,6 +402,21 @@ class Output {
|
|
|
398
402
|
return utils_1.REST_API_REGION.AS;
|
|
399
403
|
return utils_1.REST_API_REGION.ONPREM;
|
|
400
404
|
}
|
|
405
|
+
static getUndiciUnauthorizedAgent() {
|
|
406
|
+
if (!this._a) {
|
|
407
|
+
this._a = new undici_1.default.Agent({
|
|
408
|
+
connect: {
|
|
409
|
+
rejectUnauthorized: false,
|
|
410
|
+
},
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
return this._a;
|
|
414
|
+
}
|
|
415
|
+
static clearUndici() {
|
|
416
|
+
undici_1.default.getGlobalDispatcher().destroy(() => { });
|
|
417
|
+
if (this._a)
|
|
418
|
+
this._a.destroy(() => { });
|
|
419
|
+
}
|
|
401
420
|
static clearTerminal() {
|
|
402
421
|
this.killSpinner();
|
|
403
422
|
terminal.styleReset();
|
|
@@ -406,6 +425,7 @@ class Output {
|
|
|
406
425
|
terminal.grabInput(false);
|
|
407
426
|
}
|
|
408
427
|
static exitError(err) {
|
|
428
|
+
this.clearUndici();
|
|
409
429
|
this.clearTerminal();
|
|
410
430
|
const isDebug = process.env.DEBUG === '1';
|
|
411
431
|
let msg;
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const logger_1 = __importDefault(require("../../logger"));
|
|
7
7
|
const texts_1 = require("../../texts");
|
|
8
8
|
const ws_1 = require("ws");
|
|
9
|
+
const undici_1 = __importDefault(require("undici"));
|
|
9
10
|
const TIMEOUT = 120000;
|
|
10
11
|
const openSocket = (port, path) => {
|
|
11
12
|
return new Promise((resolve, reject) => {
|
|
@@ -25,9 +26,9 @@ const makeRequest = async (port, path, body) => {
|
|
|
25
26
|
}, TIMEOUT);
|
|
26
27
|
logger_1.default.debug(`TUNNEL API AGENT REQUEST: :${port}${path}`);
|
|
27
28
|
logger_1.default.debug(body);
|
|
28
|
-
const response = await fetch(`http://localhost:${port}${path}`, {
|
|
29
|
+
const response = await undici_1.default.fetch(`http://localhost:${port}${path}`, {
|
|
29
30
|
body: body ? JSON.stringify(body) : null,
|
|
30
|
-
headers: { 'Content-Type': 'application/json'
|
|
31
|
+
headers: { 'Content-Type': 'application/json' },
|
|
31
32
|
method: 'POST',
|
|
32
33
|
signal: c.signal,
|
|
33
34
|
});
|
|
@@ -10,13 +10,8 @@ const logger_1 = __importDefault(require("../../logger"));
|
|
|
10
10
|
const agent_1 = __importDefault(require("../../agent/agent"));
|
|
11
11
|
const utils_1 = require("../../utils");
|
|
12
12
|
const texts_1 = require("../../texts");
|
|
13
|
+
const output_1 = __importDefault(require("../../output"));
|
|
13
14
|
const TIMEOUT = 120000;
|
|
14
|
-
const dispatcher = new undici_1.Agent({
|
|
15
|
-
keepAliveTimeout: 10,
|
|
16
|
-
connect: {
|
|
17
|
-
rejectUnauthorized: false,
|
|
18
|
-
},
|
|
19
|
-
});
|
|
20
15
|
const makeRequest = async (host, path, body, method = 'POST', respAsJson = true, timeout = TIMEOUT) => {
|
|
21
16
|
let data;
|
|
22
17
|
try {
|
|
@@ -31,7 +26,7 @@ const makeRequest = async (host, path, body, method = 'POST', respAsJson = true,
|
|
|
31
26
|
headers: body ? { 'Content-Type': 'application/json' } : undefined,
|
|
32
27
|
method,
|
|
33
28
|
signal: c.signal,
|
|
34
|
-
dispatcher,
|
|
29
|
+
dispatcher: output_1.default.getUndiciUnauthorizedAgent(),
|
|
35
30
|
});
|
|
36
31
|
if (respAsJson)
|
|
37
32
|
data = await response.json();
|
|
@@ -222,6 +222,8 @@ class ServerSsh extends events_1.default {
|
|
|
222
222
|
return;
|
|
223
223
|
sessionClosed = true;
|
|
224
224
|
logger_1.default.debug('ssh close session');
|
|
225
|
+
if (exitCode === undefined && sftp)
|
|
226
|
+
exitCode = 0;
|
|
225
227
|
if (exitCode !== undefined) {
|
|
226
228
|
session.exit(exitCode);
|
|
227
229
|
session.end();
|
package/distTs/src/utils.js
CHANGED
|
@@ -54,6 +54,7 @@ exports.getPopularTlds = getPopularTlds;
|
|
|
54
54
|
exports.getAppHostByApiBaseUrl = getAppHostByApiBaseUrl;
|
|
55
55
|
const node_path_1 = __importDefault(require("node:path"));
|
|
56
56
|
const node_fs_1 = require("node:fs");
|
|
57
|
+
const undici_1 = __importDefault(require("undici"));
|
|
57
58
|
const texts_1 = require("./texts");
|
|
58
59
|
const node_sea_1 = require("node:sea");
|
|
59
60
|
const commander_1 = require("commander");
|
|
@@ -460,9 +461,8 @@ const getLatestVersion = async () => {
|
|
|
460
461
|
setTimeout(() => {
|
|
461
462
|
c.abort();
|
|
462
463
|
}, 10000);
|
|
463
|
-
const response = await fetch(`https://es.buddy.works/bdy/${env}/latest`, {
|
|
464
|
+
const response = await undici_1.default.fetch(`https://es.buddy.works/bdy/${env}/latest`, {
|
|
464
465
|
method: 'GET',
|
|
465
|
-
headers: { 'Connection': 'close' },
|
|
466
466
|
signal: c.signal,
|
|
467
467
|
});
|
|
468
468
|
if (response.status === 200) {
|
|
@@ -242,13 +242,7 @@ async function sendRequest({ path, token, payload, multipart, }) {
|
|
|
242
242
|
'X-CLI-VERSION': context_1.cliVersion,
|
|
243
243
|
'X-TOKEN': token,
|
|
244
244
|
},
|
|
245
|
-
dispatcher: isDevToken
|
|
246
|
-
? new undici_1.Agent({
|
|
247
|
-
connect: {
|
|
248
|
-
rejectUnauthorized: false,
|
|
249
|
-
},
|
|
250
|
-
})
|
|
251
|
-
: undefined,
|
|
245
|
+
dispatcher: isDevToken ? output_1.default.getUndiciUnauthorizedAgent() : undefined,
|
|
252
246
|
};
|
|
253
247
|
if (payload && !multipart) {
|
|
254
248
|
init.method = 'POST';
|