bdy 1.22.12-dev → 1.22.14-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
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,21 +402,30 @@ 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();
|
|
404
423
|
terminal.fullscreen(false);
|
|
405
424
|
terminal.hideCursor(false);
|
|
406
425
|
terminal.grabInput(false);
|
|
407
|
-
try {
|
|
408
|
-
const { getGlobalDispatcher } = require('undici');
|
|
409
|
-
getGlobalDispatcher().close();
|
|
410
|
-
}
|
|
411
|
-
catch {
|
|
412
|
-
// undici not available
|
|
413
|
-
}
|
|
414
426
|
}
|
|
415
427
|
static exitError(err) {
|
|
428
|
+
this.clearUndici();
|
|
416
429
|
this.clearTerminal();
|
|
417
430
|
const isDebug = process.env.DEBUG === '1';
|
|
418
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,7 +26,7 @@ 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
31
|
headers: { 'Content-Type': 'application/json' },
|
|
31
32
|
method: 'POST',
|
|
@@ -10,12 +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
|
-
connect: {
|
|
16
|
-
rejectUnauthorized: false,
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
15
|
const makeRequest = async (host, path, body, method = 'POST', respAsJson = true, timeout = TIMEOUT) => {
|
|
20
16
|
let data;
|
|
21
17
|
try {
|
|
@@ -30,7 +26,7 @@ const makeRequest = async (host, path, body, method = 'POST', respAsJson = true,
|
|
|
30
26
|
headers: body ? { 'Content-Type': 'application/json' } : undefined,
|
|
31
27
|
method,
|
|
32
28
|
signal: c.signal,
|
|
33
|
-
dispatcher,
|
|
29
|
+
dispatcher: output_1.default.getUndiciUnauthorizedAgent(),
|
|
34
30
|
});
|
|
35
31
|
if (respAsJson)
|
|
36
32
|
data = await response.json();
|
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,7 +461,7 @@ 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
466
|
signal: c.signal,
|
|
466
467
|
});
|
|
@@ -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';
|