bdy 1.16.33-dev → 1.16.35-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 +1 -1
- package/distTs/src/command/agent/tunnel/http.js +1 -0
- package/distTs/src/command/agent/tunnel/list.js +2 -0
- package/distTs/src/command/agent/tunnel/remove.js +1 -0
- package/distTs/src/command/agent/tunnel/start.js +1 -0
- package/distTs/src/command/agent/tunnel/status.js +1 -0
- package/distTs/src/command/agent/tunnel/tcp.js +1 -0
- package/distTs/src/command/agent/tunnel/tls.js +1 -0
- package/distTs/src/command/agent/tunnel.js +7 -0
- package/distTs/src/command/api/delete.js +9 -0
- package/distTs/src/command/api/get.js +9 -0
- package/distTs/src/command/api/patch.js +9 -0
- package/distTs/src/command/api/post.js +9 -0
- package/distTs/src/command/api/put.js +9 -0
- package/distTs/src/command/api/request.js +170 -0
- package/distTs/src/command/api.js +10 -0
- package/distTs/src/command/login.js +20 -2
- package/distTs/src/command/tunnel/http.js +1 -0
- package/distTs/src/command/tunnel/start.js +1 -0
- package/distTs/src/command/tunnel/tcp.js +1 -0
- package/distTs/src/command/tunnel/tls.js +1 -0
- package/distTs/src/command/tunnel.js +4 -0
- package/distTs/src/input.js +3 -1
- package/distTs/src/texts.js +70 -2
- package/package.json +1 -1
package/distTs/package.json
CHANGED
package/distTs/src/api/client.js
CHANGED
|
@@ -643,7 +643,7 @@ class ApiClient {
|
|
|
643
643
|
form.append('file', file);
|
|
644
644
|
return await this.request({
|
|
645
645
|
method: 'POST',
|
|
646
|
-
path: `/workspaces/${encodeURIComponent(workspace)}/packages/${encodeURIComponent(pkgId)}/versions/${versionId}/upload`,
|
|
646
|
+
path: `/workspaces/${encodeURIComponent(workspace)}/packages/${encodeURIComponent(pkgId)}/versions/${encodeURIComponent(versionId)}/upload`,
|
|
647
647
|
body: form,
|
|
648
648
|
parseResponseBody: true,
|
|
649
649
|
});
|
|
@@ -14,6 +14,7 @@ const commandAgentTunnelHttp = (0, utils_1.getBasicCommandHttp)();
|
|
|
14
14
|
commandAgentTunnelHttp.description(texts_1.DESC_COMMAND_HTTP);
|
|
15
15
|
commandAgentTunnelHttp.option('-f, --follow', texts_1.OPTION_FOLLOW);
|
|
16
16
|
commandAgentTunnelHttp.argument('[protocol://host:port]', texts_1.OPTION_TARGET);
|
|
17
|
+
commandAgentTunnelHttp.addHelpText('after', `\nEXAMPLES:${(0, texts_1.EXAMPLE_TUNNEL_HTTP)(true)}`);
|
|
17
18
|
commandAgentTunnelHttp.action(async (target, options) => {
|
|
18
19
|
if (!commandAgentTunnelHttp.agentInstalled) {
|
|
19
20
|
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
@@ -8,6 +8,8 @@ const texts_1 = require("../../../texts");
|
|
|
8
8
|
const agent_1 = __importDefault(require("../../../tunnel/api/agent"));
|
|
9
9
|
const utils_1 = require("../../../utils");
|
|
10
10
|
const commandAgentTunnelList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_AGENT_TUNNEL_LIST);
|
|
11
|
+
commandAgentTunnelList.alias('ls');
|
|
12
|
+
commandAgentTunnelList.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_AGENT_TUNNEL_LIST}`);
|
|
11
13
|
commandAgentTunnelList.action(async () => {
|
|
12
14
|
if (!commandAgentTunnelList.agentInstalled) {
|
|
13
15
|
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
@@ -8,6 +8,7 @@ const texts_1 = require("../../../texts");
|
|
|
8
8
|
const agent_1 = __importDefault(require("../../../tunnel/api/agent"));
|
|
9
9
|
const utils_1 = require("../../../utils");
|
|
10
10
|
const commandAgentTunnelRemove = (0, utils_1.newCommand)('rm', texts_1.DESC_COMMAND_AGENT_TUNNEL_REMOVE);
|
|
11
|
+
commandAgentTunnelRemove.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_AGENT_TUNNEL_REMOVE}`);
|
|
11
12
|
commandAgentTunnelRemove.argument('<id>', texts_1.OPTION_ID);
|
|
12
13
|
commandAgentTunnelRemove.action(async (id) => {
|
|
13
14
|
if (!commandAgentTunnelRemove.agentInstalled) {
|
|
@@ -9,6 +9,7 @@ const texts_1 = require("../../../texts");
|
|
|
9
9
|
const agent_1 = __importDefault(require("../../../tunnel/api/agent"));
|
|
10
10
|
const utils_1 = require("../../../utils");
|
|
11
11
|
const commandAgentTunnelStart = (0, utils_1.newCommand)('start', texts_1.DESC_COMMAND_START);
|
|
12
|
+
commandAgentTunnelStart.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_AGENT_TUNNEL_START}`);
|
|
12
13
|
commandAgentTunnelStart.argument('<name>', texts_1.OPTION_NAME);
|
|
13
14
|
commandAgentTunnelStart.action(async (name) => {
|
|
14
15
|
if (!commandAgentTunnelStart.agentInstalled) {
|
|
@@ -9,6 +9,7 @@ const agent_1 = __importDefault(require("../../../tunnel/api/agent"));
|
|
|
9
9
|
const tunnel_1 = __importDefault(require("../../../agent/socket/tunnel"));
|
|
10
10
|
const utils_1 = require("../../../utils");
|
|
11
11
|
const commandAgentTunnelStatus = (0, utils_1.newCommand)('status', texts_1.DESC_COMMAND_AGENT_TUNNEL_STATUS);
|
|
12
|
+
commandAgentTunnelStatus.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_AGENT_TUNNEL_STATUS}`);
|
|
12
13
|
commandAgentTunnelStatus.argument('<id>', texts_1.OPTION_ID);
|
|
13
14
|
commandAgentTunnelStatus.action(async (id) => {
|
|
14
15
|
if (!commandAgentTunnelStatus.agentInstalled) {
|
|
@@ -14,6 +14,7 @@ const commandAgentTunnelTcp = (0, utils_1.getBasicCommandTcp)();
|
|
|
14
14
|
commandAgentTunnelTcp.description(texts_1.DESC_COMMAND_TCP);
|
|
15
15
|
commandAgentTunnelTcp.option('-f, --follow', texts_1.OPTION_FOLLOW);
|
|
16
16
|
commandAgentTunnelTcp.argument('[host:port]', texts_1.OPTION_TARGET);
|
|
17
|
+
commandAgentTunnelTcp.addHelpText('after', `\nEXAMPLES:${(0, texts_1.EXAMPLE_TUNNEL_TCP)(true)}`);
|
|
17
18
|
commandAgentTunnelTcp.action(async (target, options) => {
|
|
18
19
|
if (!commandAgentTunnelTcp.agentInstalled) {
|
|
19
20
|
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
@@ -14,6 +14,7 @@ const commandAgentTunnelTls = (0, utils_1.getBasicCommandTls)();
|
|
|
14
14
|
commandAgentTunnelTls.description(texts_1.DESC_COMMAND_TLS);
|
|
15
15
|
commandAgentTunnelTls.option('-f, --follow', texts_1.OPTION_FOLLOW);
|
|
16
16
|
commandAgentTunnelTls.argument('[host:port]', texts_1.OPTION_TARGET);
|
|
17
|
+
commandAgentTunnelTls.addHelpText('after', `\nEXAMPLES:${(0, texts_1.EXAMPLE_TUNNEL_TLS)(true)}`);
|
|
17
18
|
commandAgentTunnelTls.action(async (target, options) => {
|
|
18
19
|
if (!commandAgentTunnelTls.agentInstalled) {
|
|
19
20
|
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
@@ -20,4 +20,11 @@ commandAgentTunnel.addCommand(start_1.default);
|
|
|
20
20
|
commandAgentTunnel.addCommand(remove_1.default);
|
|
21
21
|
commandAgentTunnel.addCommand(list_1.default);
|
|
22
22
|
commandAgentTunnel.addCommand(status_1.default);
|
|
23
|
+
commandAgentTunnel.addHelpText('after', `\nEXAMPLES:${(0, texts_1.EXAMPLE_TUNNEL_HTTP)(true)}
|
|
24
|
+
${(0, texts_1.EXAMPLE_TUNNEL_TLS)(true)}
|
|
25
|
+
${(0, texts_1.EXAMPLE_TUNNEL_TCP)(true)}
|
|
26
|
+
${texts_1.EXAMPLE_AGENT_TUNNEL_START}
|
|
27
|
+
${texts_1.EXAMPLE_AGENT_TUNNEL_LIST}
|
|
28
|
+
${texts_1.EXAMPLE_AGENT_TUNNEL_STATUS}
|
|
29
|
+
${texts_1.EXAMPLE_AGENT_TUNNEL_REMOVE}`);
|
|
23
30
|
exports.default = commandAgentTunnel;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const request_1 = __importDefault(require("./request"));
|
|
7
|
+
const texts_1 = require("../../texts");
|
|
8
|
+
const commandApiDelete = (0, request_1.default)('delete', texts_1.DESC_COMMAND_API_DELETE, true);
|
|
9
|
+
exports.default = commandApiDelete;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const request_1 = __importDefault(require("./request"));
|
|
7
|
+
const texts_1 = require("../../texts");
|
|
8
|
+
const commandApiGet = (0, request_1.default)('get', texts_1.DESC_COMMAND_API_GET, false);
|
|
9
|
+
exports.default = commandApiGet;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const request_1 = __importDefault(require("./request"));
|
|
7
|
+
const texts_1 = require("../../texts");
|
|
8
|
+
const commandApiPatch = (0, request_1.default)('patch', texts_1.DESC_COMMAND_API_PATCH, true);
|
|
9
|
+
exports.default = commandApiPatch;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const texts_1 = require("../../texts");
|
|
7
|
+
const request_1 = __importDefault(require("./request"));
|
|
8
|
+
const commandApiPost = (0, request_1.default)('post', texts_1.DESC_COMMAND_API_POST, true);
|
|
9
|
+
exports.default = commandApiPost;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const request_1 = __importDefault(require("./request"));
|
|
7
|
+
const texts_1 = require("../../texts");
|
|
8
|
+
const commandApiPut = (0, request_1.default)('put', texts_1.DESC_COMMAND_API_PUT, true);
|
|
9
|
+
exports.default = commandApiPut;
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../utils");
|
|
7
|
+
const texts_1 = require("../../texts");
|
|
8
|
+
const output_1 = __importDefault(require("../../output"));
|
|
9
|
+
const input_1 = __importDefault(require("../../input"));
|
|
10
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
11
|
+
const promises_1 = require("node:stream/promises");
|
|
12
|
+
const path_1 = require("path");
|
|
13
|
+
const undici_1 = require("undici");
|
|
14
|
+
const tryReadFile = async (filePath) => {
|
|
15
|
+
try {
|
|
16
|
+
return await node_fs_1.default.promises.readFile(filePath, 'utf8');
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
output_1.default.exitError(texts_1.ERR_API_REQUEST_FILE_ERROR);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const tryOpenAsBlob = async (filePath) => {
|
|
23
|
+
try {
|
|
24
|
+
return await node_fs_1.default.openAsBlob(filePath);
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
output_1.default.exitError(texts_1.ERR_API_REQUEST_FILE_ERROR);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const prepareJsonBody = async (json) => {
|
|
31
|
+
let data;
|
|
32
|
+
if (json.startsWith('@')) {
|
|
33
|
+
data = await tryReadFile(json.replace(/^@/, ''));
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
data = json;
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
return JSON.parse(data);
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
output_1.default.exitError(texts_1.ERR_API_REQUEST_INVALID_JSON);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const prepareEncodedBody = async (params) => {
|
|
46
|
+
const obj = {};
|
|
47
|
+
for (let i = 0; i < params.length; i += 1) {
|
|
48
|
+
const s = params[i].split(':');
|
|
49
|
+
if (s.length !== 2) {
|
|
50
|
+
output_1.default.exitError(texts_1.ERR_API_REQUEST_BODY_VALUE);
|
|
51
|
+
}
|
|
52
|
+
const [key, value] = s;
|
|
53
|
+
if (value.startsWith('@')) {
|
|
54
|
+
obj[key] = await tryReadFile(value.replace(/^@/, ''));
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
obj[key] = value;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return obj;
|
|
61
|
+
};
|
|
62
|
+
const prepareMultipartBody = async (params) => {
|
|
63
|
+
const form = new undici_1.FormData();
|
|
64
|
+
for (let i = 0; i < params.length; i += 1) {
|
|
65
|
+
const s = params[i].split(':');
|
|
66
|
+
if (s.length !== 2) {
|
|
67
|
+
output_1.default.exitError(texts_1.ERR_API_REQUEST_BODY_VALUE);
|
|
68
|
+
}
|
|
69
|
+
const [key, value] = s;
|
|
70
|
+
if (value.startsWith('@')) {
|
|
71
|
+
const blob = await tryOpenAsBlob(value.replace(/^@/, ''));
|
|
72
|
+
form.set(key, blob);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
form.set(key, value);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return form;
|
|
79
|
+
};
|
|
80
|
+
const request = async (method, url, options) => {
|
|
81
|
+
output_1.default.handleSignals();
|
|
82
|
+
const workspace = input_1.default.restApiWorkspace(options.workspace, true);
|
|
83
|
+
const project = input_1.default.restApiProject(options.project, true);
|
|
84
|
+
const client = input_1.default.restApiTokenClient(options.api, options.region, options.token);
|
|
85
|
+
const query = {};
|
|
86
|
+
if (options.query) {
|
|
87
|
+
options.query.forEach((q) => {
|
|
88
|
+
const s = q.split(':');
|
|
89
|
+
if (s.length !== 2) {
|
|
90
|
+
output_1.default.exitError((0, texts_1.ERR_API_REQUEST_QUERY_VALUE)(q));
|
|
91
|
+
}
|
|
92
|
+
query[s[0]] = s[1];
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
let preparedUrl = url;
|
|
96
|
+
if (workspace) {
|
|
97
|
+
preparedUrl = preparedUrl.replaceAll('{workspace_domain}', encodeURIComponent(workspace));
|
|
98
|
+
}
|
|
99
|
+
if (project) {
|
|
100
|
+
preparedUrl = preparedUrl.replaceAll('{project_name}', encodeURIComponent(project));
|
|
101
|
+
}
|
|
102
|
+
const m = preparedUrl.match(/{[^}]*}/g);
|
|
103
|
+
if (m) {
|
|
104
|
+
output_1.default.exitError((0, texts_1.ERR_API_PARAMETER_NOT_REPLACED)(m[0]));
|
|
105
|
+
}
|
|
106
|
+
let filePath;
|
|
107
|
+
if (options.output) {
|
|
108
|
+
const fp = (0, path_1.resolve)(options.output);
|
|
109
|
+
try {
|
|
110
|
+
await node_fs_1.default.promises.stat(fp);
|
|
111
|
+
output_1.default.exitError(texts_1.ERR_API_REQUEST_OUTPUT_EXISTS);
|
|
112
|
+
}
|
|
113
|
+
catch {
|
|
114
|
+
filePath = fp;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const opts = {
|
|
118
|
+
method: method.toUpperCase(),
|
|
119
|
+
path: preparedUrl,
|
|
120
|
+
query,
|
|
121
|
+
rawResponseBody: true,
|
|
122
|
+
};
|
|
123
|
+
if (options.data && options.data.length > 0) {
|
|
124
|
+
opts.httpUrlEncoded = true;
|
|
125
|
+
opts.body = await prepareEncodedBody(options.data);
|
|
126
|
+
}
|
|
127
|
+
else if (options.form && options.form.length > 0) {
|
|
128
|
+
opts.body = await prepareMultipartBody(options.form);
|
|
129
|
+
}
|
|
130
|
+
else if (options.json) {
|
|
131
|
+
opts.body = await prepareJsonBody(options.json);
|
|
132
|
+
}
|
|
133
|
+
const body = await client.request(opts);
|
|
134
|
+
if (filePath) {
|
|
135
|
+
const ws = node_fs_1.default.createWriteStream(filePath);
|
|
136
|
+
await (0, promises_1.pipeline)(body, ws);
|
|
137
|
+
output_1.default.exitNormal('');
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
body.on('data', (data) => {
|
|
141
|
+
output_1.default.normal(data.toString('utf8'));
|
|
142
|
+
});
|
|
143
|
+
body.on('close', () => {
|
|
144
|
+
output_1.default.exitNormal('');
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
const newApiRequestCommand = (method, description, allowBody) => {
|
|
149
|
+
const command = (0, utils_1.newCommand)(method, description);
|
|
150
|
+
command.hideVersionUpdate = true;
|
|
151
|
+
command.alias(method.toUpperCase());
|
|
152
|
+
command.option('--token <token>', texts_1.OPTION_REST_API_TOKEN);
|
|
153
|
+
command.option('--api <url>', texts_1.OPTION_REST_API_ENDPOINT);
|
|
154
|
+
command.option('--region <region>', texts_1.OPTION_REST_API_REGION);
|
|
155
|
+
command.option('-w, --workspace <domain>', texts_1.DESC_COMMAND_API_WORKSPACE);
|
|
156
|
+
command.option('-p, --project <name>', texts_1.DESC_COMMAND_API_PROJECT);
|
|
157
|
+
command.option('-q, --query <key:val...>', texts_1.DESC_COMMAND_API_REQUEST_QUERY);
|
|
158
|
+
command.option('-o, --output <filepath>', texts_1.DESC_COMMAND_API_OUTPUT);
|
|
159
|
+
if (allowBody) {
|
|
160
|
+
command.option('-d, --data <key:val...>', texts_1.DESC_COMMAND_API_DATA);
|
|
161
|
+
command.option('-j, --json <json>', texts_1.DESC_COMMAND_API_JSON);
|
|
162
|
+
command.option('-f, --form <key:val...>', texts_1.DESC_COMMAND_API_FORM);
|
|
163
|
+
}
|
|
164
|
+
command.argument('<url>', texts_1.DESC_COMMAND_API_REQUEST_URL);
|
|
165
|
+
command.action(async (url, options) => {
|
|
166
|
+
await request(method, url, options);
|
|
167
|
+
});
|
|
168
|
+
return command;
|
|
169
|
+
};
|
|
170
|
+
exports.default = newApiRequestCommand;
|
|
@@ -7,7 +7,17 @@ const utils_1 = require("../utils");
|
|
|
7
7
|
const texts_1 = require("../texts");
|
|
8
8
|
const list_1 = __importDefault(require("./api/list"));
|
|
9
9
|
const info_1 = __importDefault(require("./api/info"));
|
|
10
|
+
const post_1 = __importDefault(require("./api/post"));
|
|
11
|
+
const put_1 = __importDefault(require("./api/put"));
|
|
12
|
+
const patch_1 = __importDefault(require("./api/patch"));
|
|
13
|
+
const get_1 = __importDefault(require("./api/get"));
|
|
14
|
+
const delete_1 = __importDefault(require("./api/delete"));
|
|
10
15
|
const commandApi = (0, utils_1.newCommand)('api', texts_1.DESC_COMMAND_API);
|
|
11
16
|
commandApi.addCommand(list_1.default);
|
|
12
17
|
commandApi.addCommand(info_1.default);
|
|
18
|
+
commandApi.addCommand(post_1.default);
|
|
19
|
+
commandApi.addCommand(put_1.default);
|
|
20
|
+
commandApi.addCommand(patch_1.default);
|
|
21
|
+
commandApi.addCommand(get_1.default);
|
|
22
|
+
commandApi.addCommand(delete_1.default);
|
|
13
23
|
exports.default = commandApi;
|
|
@@ -14,7 +14,25 @@ const input_1 = __importDefault(require("../input"));
|
|
|
14
14
|
const OAUTH_CLIENT_APP_PORT = 7596;
|
|
15
15
|
const OAUTH_CLIENT_APP_HOST = 'localhost';
|
|
16
16
|
const OAUTH_CLIENT_APP_REDIRECT_URL = `http://localhost:${OAUTH_CLIENT_APP_PORT}`;
|
|
17
|
-
const OAUTH_CLIENT_APP_SCOPES =
|
|
17
|
+
const OAUTH_CLIENT_APP_SCOPES = [
|
|
18
|
+
'WORKSPACE',
|
|
19
|
+
'MEMBER_EMAIL',
|
|
20
|
+
'REPOSITORY_WRITE',
|
|
21
|
+
'EXECUTION_MANAGE',
|
|
22
|
+
'ENVIRONMENT_MANAGE',
|
|
23
|
+
'TARGET_MANAGE',
|
|
24
|
+
'ZONE_MANAGE',
|
|
25
|
+
'WEBHOOK_MANAGE',
|
|
26
|
+
'VARIABLE_MANAGE',
|
|
27
|
+
'USER_EMAIL',
|
|
28
|
+
'USER_KEY',
|
|
29
|
+
'USER_INFO',
|
|
30
|
+
'INTEGRATION_MANAGE',
|
|
31
|
+
'SANDBOX_MANAGE',
|
|
32
|
+
'PACKAGE_MANAGE',
|
|
33
|
+
'TUNNEL_MANAGE',
|
|
34
|
+
'UNIT_TEST_MANAGE'
|
|
35
|
+
];
|
|
18
36
|
function normalizeBaseUrl(url) {
|
|
19
37
|
let normalized = url.trim();
|
|
20
38
|
normalized = normalized.replace(/^https?:\/\//i, '');
|
|
@@ -79,7 +97,7 @@ async function oauthServer(api, clientId, clientSecret) {
|
|
|
79
97
|
reject(texts_1.ERR_LOGIN_HTTP_SERVER_PORT_TAKEN);
|
|
80
98
|
});
|
|
81
99
|
s.listen(OAUTH_CLIENT_APP_PORT, OAUTH_CLIENT_APP_HOST);
|
|
82
|
-
const url = `https://${api}/oauth2/authorize?type=web_server&client_id=${encodeURIComponent(clientId)}&redirect_uri=${encodeURIComponent(OAUTH_CLIENT_APP_REDIRECT_URL)}&response_type=code&scope=${encodeURIComponent(OAUTH_CLIENT_APP_SCOPES)}`;
|
|
100
|
+
const url = `https://${api}/oauth2/authorize?type=web_server&client_id=${encodeURIComponent(clientId)}&redirect_uri=${encodeURIComponent(OAUTH_CLIENT_APP_REDIRECT_URL)}&response_type=code&scope=${encodeURIComponent(OAUTH_CLIENT_APP_SCOPES.join(' '))}`;
|
|
83
101
|
(0, open_1.default)(url);
|
|
84
102
|
});
|
|
85
103
|
}
|
|
@@ -15,6 +15,7 @@ commandHttp.description(texts_1.DESC_COMMAND_HTTP);
|
|
|
15
15
|
commandHttp.option('-s, --serve <directory>', texts_1.OPTION_SERVE);
|
|
16
16
|
commandHttp.option('--token <token>', texts_1.OPTION_TOKEN);
|
|
17
17
|
commandHttp.argument('[protocol://host:port]', texts_1.OPTION_TARGET);
|
|
18
|
+
commandHttp.addHelpText('after', `\nEXAMPLES:${(0, texts_1.EXAMPLE_TUNNEL_HTTP)(false)}`);
|
|
18
19
|
commandHttp.action(async (target, options) => {
|
|
19
20
|
await input_1.default.tunnelToken(options.token);
|
|
20
21
|
const prepared = await cfg_1.default.prepareTunnel(tunnel_1.TUNNEL_TYPE.HTTP, target, options, true);
|
|
@@ -10,6 +10,7 @@ const buddy_1 = __importDefault(require("../../tunnel/api/buddy"));
|
|
|
10
10
|
const utils_1 = require("../../utils");
|
|
11
11
|
const commandStart = (0, utils_1.newCommand)('start', texts_1.DESC_COMMAND_START);
|
|
12
12
|
commandStart.argument('<name>', texts_1.OPTION_NAME);
|
|
13
|
+
commandStart.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_TUNNEL_START}`);
|
|
13
14
|
commandStart.action(async (name) => {
|
|
14
15
|
if (!cfg_1.default.hasTunnel(name)) {
|
|
15
16
|
output_1.default.exitError((0, texts_1.ERR_TUNNEL_NOT_FOUND)(name));
|
|
@@ -14,6 +14,7 @@ const commandTcp = (0, utils_1.getBasicCommandTcp)();
|
|
|
14
14
|
commandTcp.description(texts_1.DESC_COMMAND_TCP);
|
|
15
15
|
commandTcp.option('--token <token>', texts_1.OPTION_TOKEN);
|
|
16
16
|
commandTcp.argument('[host:port]', texts_1.OPTION_TARGET);
|
|
17
|
+
commandTcp.addHelpText('after', `\nEXAMPLES:${(0, texts_1.EXAMPLE_TUNNEL_TCP)(false)}`);
|
|
17
18
|
commandTcp.action(async (target, options) => {
|
|
18
19
|
await input_1.default.tunnelToken(options.token);
|
|
19
20
|
const prepared = await cfg_1.default.prepareTunnel(tunnel_1.TUNNEL_TYPE.TCP, target, options, true);
|
|
@@ -14,6 +14,7 @@ const commandTls = (0, utils_1.getBasicCommandTls)();
|
|
|
14
14
|
commandTls.description(texts_1.DESC_COMMAND_TLS);
|
|
15
15
|
commandTls.option('--token <token>', texts_1.OPTION_TOKEN);
|
|
16
16
|
commandTls.argument('[host:port]', texts_1.OPTION_TARGET);
|
|
17
|
+
commandTls.addHelpText('after', `\nEXAMPLES:${(0, texts_1.EXAMPLE_TUNNEL_TLS)(false)}`);
|
|
17
18
|
commandTls.action(async (target, options) => {
|
|
18
19
|
await input_1.default.tunnelToken(options.token);
|
|
19
20
|
const prepared = await cfg_1.default.prepareTunnel(tunnel_1.TUNNEL_TYPE.TLS, target, options, true);
|
|
@@ -16,4 +16,8 @@ commandTunnel.addCommand(tcp_1.default);
|
|
|
16
16
|
commandTunnel.addCommand(tls_1.default);
|
|
17
17
|
commandTunnel.addCommand(http_1.default);
|
|
18
18
|
commandTunnel.addCommand(start_1.default);
|
|
19
|
+
commandTunnel.addHelpText('after', `\nEXAMPLES:${(0, texts_1.EXAMPLE_TUNNEL_HTTP)(false)}
|
|
20
|
+
${(0, texts_1.EXAMPLE_TUNNEL_TLS)(false)}
|
|
21
|
+
${(0, texts_1.EXAMPLE_TUNNEL_TCP)(false)}
|
|
22
|
+
${texts_1.EXAMPLE_TUNNEL_START}`);
|
|
19
23
|
exports.default = commandTunnel;
|
package/distTs/src/input.js
CHANGED
|
@@ -470,13 +470,15 @@ class Input {
|
|
|
470
470
|
}
|
|
471
471
|
return p;
|
|
472
472
|
}
|
|
473
|
-
static restApiWorkspace(workspace) {
|
|
473
|
+
static restApiWorkspace(workspace, allowNull) {
|
|
474
474
|
let w = process.env.BUDDY_WORKSPACE;
|
|
475
475
|
if (workspace)
|
|
476
476
|
w = workspace;
|
|
477
477
|
if (!w)
|
|
478
478
|
w = cfg_1.default.getWorkspace();
|
|
479
479
|
if (!w) {
|
|
480
|
+
if (allowNull)
|
|
481
|
+
return null;
|
|
480
482
|
output_1.default.exitError(texts_1.ERR_REST_API_WORKSPACE);
|
|
481
483
|
}
|
|
482
484
|
return w;
|
package/distTs/src/texts.js
CHANGED
|
@@ -10,8 +10,9 @@ exports.LOG_TUNNEL_REGISTERED = exports.LOG_ERROR_WHILE_REFRESHING_AGENT = expor
|
|
|
10
10
|
exports.DESC_COMMAND_SANDBOX_LIST = exports.DESC_COMMAND_SANDBOX_CREATE = exports.DESC_COMMAND_SANDBOX = exports.DEBUG_WAIT_FOR_IDLE_TIMEOUT = exports.DEBUG_WAIT_FOR_IDLE = exports.DEBUG_RESOURCE_DISCOVERY_TIMEOUT = exports.DEBUG_AUTO_WIDTH = exports.DEBUG_AUTO_SCROLL = exports.DEBUG_RESOURCE_SCRAPPING_URL = exports.DEBUG_SNAPSHOT_PROCESSING = exports.DEBUG_SNAPSHOTS_PROCESSING = exports.DEBUG_EXEC_COMMAND = exports.DEBUG_EXEC_TEST_COMMAND = exports.LOG_INSTALLED_BROWSER = exports.LOG_SESSION_LINK = exports.LOG_SENDING_DATA = exports.LOG_SENDING_REQUEST = exports.LOG_PROCESSING_SNAPSHOTS = exports.LOG_RUNNING_EXEC_COMMAND = exports.LOG_TUNNEL_SSH_STREAM = exports.LOG_TUNNEL_TLS_AGENT_STREAM = exports.LOG_TUNNEL_TLS_REGION_STREAM = exports.LOG_TUNNEL_TLS_TARGET_STREAM = exports.LOG_TUNNEL_HTTP2_STREAM = exports.LOG_TUNNEL_HTTP1_STREAM = exports.LOG_TUNNEL_TCP_STREAM = exports.LOG_TUNNEL_HTTP_WRONG_USER_AGENTS = exports.LOG_TUNNEL_HTTP_CIRCUIT_BREAKER_OPEN = exports.LOG_TUNNEL_HTTP_RATE_LIMIT = exports.LOG_TUNNEL_HTTP_WRON_AUTH = exports.LOG_TUNNEL_IDENTIFIED = exports.LOG_TUNNEL_DISCONNECTED = exports.LOG_TUNNEL_FAILED = exports.LOG_TUNNEL_CONNECTED = exports.LOG_AGENT_STARTED = exports.LOG_AGENT_SERVER_STARTED = exports.LOG_ERROR_STARTING_AGENT_SERVER = exports.LOG_SSH_CONNECTION = exports.LOG_WRONG_STREAM = exports.LOG_DETECTED_STREAM = exports.LOG_HTTP2_REQUEST = exports.LOG_HTTP2_CONNECTION = exports.LOG_HTTP1_REQUEST = exports.LOG_HTTP1_CONNECTION = exports.LOG_ERROR = exports.LOG_STOPPING_TUNNEL = exports.LOG_STARTING_TUNNEL = exports.LOG_ENABLING_AGENT_TARGET = exports.LOG_DISABLING_AGENT_TARGET = exports.LOG_REMOVING_TUNNEL = void 0;
|
|
11
11
|
exports.DESC_COMMAND_SANDBOX_SNAPSHOT_CREATE = exports.DESC_COMMAND_SANDBOX_SNAPSHOT_LIST = exports.DESC_COMMAND_SANDBOX_SNAPSHOT = exports.TXT_SANDBOX_COMMAND_KILLED = exports.OPTION_SANDBOX_COMMAND_KILL_CONFIRM = exports.OPTION_SANDBOX_COMMAND_ID = exports.DESC_COMMAND_SANDBOX_EXEC_KILL = exports.DESC_COMMAND_SANDBOX_EXEC_LOGS = exports.DESC_COMMAND_SANDBOX_EXEC_STATUS = exports.DESC_COMMAND_SANDBOX_EXEC_LIST = exports.TXT_SANDBOX_WAITING_START = exports.TXT_SANDBOX_WAITING_STOP = exports.TXT_SANDBOX_WAITING_SETUP = exports.TXT_SANDBOX_WAITING_RUNNING = exports.TXT_SANDBOX_STOPPED = exports.TXT_SANDBOX_STARTED = exports.TXT_SANDBOX_DESTROYED = exports.TXT_SANDBOX_DESTROY_CONFIRM = exports.TXT_SANDBOX_CREATED = exports.TXT_SANDBOX_CREATING = exports.OPTION_SANDBOX_WAIT = exports.OPTION_SANDBOX_WAIT_CONFIGURED = exports.OPTION_SANDBOX_WAIT_RUNNING = exports.ERR_SANDBOX_STOP_FAILED = exports.ERR_SANDBOX_NO_COMMANDS = exports.ERR_SANDBOX_RUNNING_FAILED = exports.ERR_SANDBOX_STOP_TIMEOUT = exports.ERR_SANDBOX_SNAPSHOT_TIMEOUT = exports.ERR_SANDBOX_RUNNING_TIMEOUT = exports.ERR_SANDBOX_SETUP_TIMEOUT = exports.ERR_SANDBOX_SETUP_FAILED = exports.ERR_SANDBOX_INVALID_RESOURCES = exports.ERR_SANDBOX_NOT_FOUND = exports.OPTION_SANDBOX_RUNTIME = exports.OPTION_SANDBOX_APP_TYPE = exports.OPTION_SANDBOX_APP_DIR = exports.OPTION_SANDBOX_RUN_COMMAND = exports.OPTION_SANDBOX_TAGS = exports.OPTION_SANDBOX_INSTALL_COMMANDS = exports.OPTION_SANDBOX_RESOURCES = exports.OPTION_SANDBOX_OS = exports.OPTION_SANDBOX_NAME = exports.OPTION_SANDBOX_IDENTIFIER = exports.DESC_COMMAND_SANDBOX_EXEC = exports.DESC_COMMAND_SANDBOX_STATUS = exports.DESC_COMMAND_SANDBOX_RESTART = exports.DESC_COMMAND_SANDBOX_STOP = exports.DESC_COMMAND_SANDBOX_START = exports.DESC_COMMAND_SANDBOX_DESTROY = exports.DESC_COMMAND_SANDBOX_GET = void 0;
|
|
12
12
|
exports.TXT_SANDBOX_EXEC_BACKGROUND = exports.TXT_SANDBOX_EXEC_ID = exports.ERR_SANDBOX_CP_INVALID_SOURCE = exports.ERR_SANDBOX_CP_INVALID_DEST = exports.ERR_SANDBOX_CP_REPLACE = exports.ERR_SANDBOX_CP_MKDIR = exports.ERR_SANDBOX_CP_PATH_EXISTS = exports.ERR_SANDBOX_CP_NOT_EMPTY_DIR = exports.ERR_SANDBOX_CP_READDIR = exports.ERR_SANDBOX_CP_DEST_NOT_FOLDER = exports.ERR_SANDBOX_CP_SOURCE_NOT_FOUND = exports.TXT_SANDBOX_CP_DONE = exports.TXT_SANDBOX_CP_PROGRESS = exports.TXT_SANDBOX_UNZIPPING_COUNT = exports.TXT_SANDBOX_UNZIP_DONE = exports.TXT_SANDBOX_UNZIP = exports.TXT_SANDBOX_CP_DOWNLOAD_DONE = exports.TXT_SANDBOX_CP_DOWNLOAD = exports.OPTION_SANDBOX_CP_DOWNLOAD_REPLACE = exports.OPTION_SANDBOX_CP_DOWNLOAD_MERGE = exports.OPTION_SANDBOX_CP_DEST = exports.OPTION_SANDBOX_CP_SOURCE = exports.DESC_COMMAND_SANDBOX_CP = exports.ERR_SANDBOX_ENDPOINTS_NOT_FOUND = exports.ERR_SANDBOX_ENDPOINT_NOT_FOUND = exports.ERR_SANDBOX_ENDPOINT_EXISTS = exports.TXT_SANDBOX_ENDPOINT_DELETED = exports.TXT_SANDBOX_ENDPOINT_DELETE_CONFIRM = exports.TXT_SANDBOX_ENDPOINT_ADDED = exports.OPTION_SANDBOX_ENDPOINT_TYPE = exports.OPTION_SANDBOX_ENDPOINT_PORT = exports.OPTION_SANDBOX_ENDPOINT_NAME_ARG = exports.OPTION_SANDBOX_ENDPOINT_NAME = exports.DESC_COMMAND_SANDBOX_ENDPOINT_DELETE = exports.DESC_COMMAND_SANDBOX_ENDPOINT_ADD = exports.DESC_COMMAND_SANDBOX_ENDPOINT_GET = exports.DESC_COMMAND_SANDBOX_ENDPOINT_LIST = exports.DESC_COMMAND_SANDBOX_ENDPOINT = exports.ERR_SANDBOX_SNAPSHOTS_NOT_FOUND = exports.ERR_SANDBOX_SNAPSHOT_NOT_FOUND = exports.ERR_SANDBOX_SNAPSHOT_FAILED = exports.TXT_SANDBOX_SNAPSHOT_WAITING = exports.TXT_SANDBOX_SNAPSHOT_DELETE_CONFIRM = exports.TXT_SANDBOX_SNAPSHOT_DELETED = exports.TXT_SANDBOX_SNAPSHOT_CREATED = exports.OPTION_SANDBOX_FROM_SNAPSHOT = exports.OPTION_SANDBOX_SNAPSHOT_NAME_ARG = exports.OPTION_SANDBOX_SNAPSHOT_NAME = exports.DESC_COMMAND_SANDBOX_SNAPSHOT_DELETE = exports.DESC_COMMAND_SANDBOX_SNAPSHOT_GET = void 0;
|
|
13
|
-
exports.
|
|
14
|
-
exports.
|
|
13
|
+
exports.TXT_LOGIN_ENTER_BASE_URL = exports.TXT_LOGIN_SELECT_REGION = exports.TXT_WORKSPACE_NONE = exports.TXT_WORKSPACE_SET_SUCCESS = exports.ARG_COMMAND_WORKSPACE = exports.DESC_COMMAND_WORKSPACE_GET = exports.DESC_COMMAND_WORKSPACE_SET = exports.DESC_COMMAND_WORKSPACE_LIST = exports.DESC_COMMAND_WORKSPACE = exports.TXT_LOGOUT_SUCCESS = exports.DESC_COMMAND_LOGOUT = exports.DESC_COMMAND_LOGIN = exports.ERR_API_MEDIA_TYPE_NOT_IMPLEMENTED = exports.ERR_API_PARAMETER_NOT_REPLACED = exports.TXT_API_ENDPOINT_REQUIRED_SCOPES = exports.ERR_API_ENDPOINT_NOT_FOUND = exports.ERR_API_WRONG_METHOD = exports.ERR_SCHEMA_FETCH_FAILED = exports.OPT_COMMAND_API_INFO_URL = exports.OPT_COMMAND_API_INFO_METHOD = exports.OPT_COMMAND_API_LIST_SEARCH = exports.OPT_COMMAND_API_LIST_METHOD = exports.ERR_API_REQUEST_BODY_VALUE = exports.ERR_API_REQUEST_QUERY_VALUE = exports.ERR_API_REQUEST_INVALID_JSON = exports.ERR_API_REQUEST_FILE_ERROR = exports.ERR_API_REQUEST_OUTPUT_EXISTS = exports.DESC_COMMAND_API_INFO = exports.DESC_COMMAND_API_FORM = exports.DESC_COMMAND_API_JSON = exports.DESC_COMMAND_API_DATA = exports.DESC_COMMAND_API_OUTPUT = exports.DESC_COMMAND_API_REQUEST_QUERY = exports.DESC_COMMAND_API_PROJECT = exports.DESC_COMMAND_API_WORKSPACE = exports.DESC_COMMAND_API_REQUEST_URL = exports.DESC_COMMAND_API_GET = exports.DESC_COMMAND_API_PATCH = exports.DESC_COMMAND_API_DELETE = exports.DESC_COMMAND_API_PUT = exports.DESC_COMMAND_API_POST = exports.DESC_COMMAND_API_LIST = exports.DESC_COMMAND_API = exports.ERR_WHOAMI_LOGOUT = exports.TXT_WHOAMI_NO_PROJECT = exports.TXT_WHOAMI_NO_WORKSPACE = exports.DESC_COMMAND_WHOAMI = exports.TXT_SANDBOX_EXEC_FAILED = exports.TXT_SANDBOX_EXEC_INPROGRESS = exports.TXT_SANDBOX_EXEC_SUCCESS = void 0;
|
|
14
|
+
exports.EXAMPLE_AGENT_TUNNEL_LIST = exports.EXAMPLE_TUNNEL_HTTP = exports.EXAMPLE_SANDBOX_CREATE = exports.EXAMPLE_SANDBOX_CP = exports.TXT_PROJECT_NONE = exports.ERR_PROJECT_NO_PROJECTS = exports.TXT_LOGIN_SELECT_PROJECT = exports.TXT_PROJECT_SET_CLEARED = exports.TXT_PROJECT_SET_SUCCESS = exports.DESC_COMMAND_PROJECT_GET = exports.ARG_COMMAND_PROJECT_NAME = exports.DESC_COMMAND_PROJECT_SET = exports.DESC_COMMAND_PROJECT_LIST = exports.DESC_COMMAND_PROJECT = exports.TXT_PACKAGE_VERSION_DOWNLOAD = exports.TXT_PACKAGE_PUBLISH = exports.TXT_PACKAGE_CREATED = exports.TXT_PACKAGE_VERSION_DELETED = exports.TXT_PACKAGE_DELETED = exports.ERR_COMMAND_PACKAGE_TYPE = exports.OPT_COMMAND_PACKAGE_VERSION = exports.OPT_COMMAND_PACKAGE_IDENTIFIER = exports.OPT_COMMAND_PACKAGE_CREATE_IDENTIFIER = exports.OPT_COMMAND_PACKAGE_NAME = exports.OPT_COMMAND_PACKAGE_TYPE = exports.DESC_COMMAND_PACKAGE_CREATE = exports.DESC_COMMAND_PACKAGE_GET = exports.TXT_PACKAGE_DOCKER_LOGIN_FAILED = exports.TXT_PACKAGE_DOCKER_LOGIN_SUCCESS = exports.TXT_PACKAGE_VERSION_DELETE_CONFIRM = exports.TXT_PACKAGE_DELETE_CONFIRM = exports.DESC_COMMAND_PACKAGE_DELETE = exports.ERR_COMMAND_PACKAGE_NO_PROJECTS = exports.DESC_COMMAND_PACKAGE_VERSION_GET = exports.DESC_COMMAND_PACKAGE_VERSION_LIST = exports.DESC_COMMAND_PACKAGE_VERSION_DELETE = exports.DESC_COMMAND_PACKAGE_DOCKER_LOGIN = exports.DESC_COMMAND_PACKAGE_LIST = exports.DESC_COMMAND_PACKAGE_VERSION = exports.ERR_API_MESSAGE_REPLACER = exports.ERR_LOGIN_INVALID_BASE_URL = exports.ERR_LOGIN_NO_PROJECT_FOUND = exports.ERR_LOGIN_NO_WORKSPACE_FOUND = exports.ERR_LOGIN_NO_WORKSPACES = exports.ERR_LOGIN_HTTP_SUCCESS = exports.ERR_LOGIN_HTTP_FAILED = exports.TXT_LOGIN_OAUTH = exports.ERR_LOGIN_HTTP_SERVER_PORT_TAKEN = exports.TXT_LOGIN_SUCCESS = exports.TXT_LOGIN_SELECT_WORKSPACE = void 0;
|
|
15
|
+
exports.EXAMPLE_PACKAGE_VERSION_DELETE = exports.EXAMPLE_PACKAGE_VERSION_GET = exports.EXAMPLE_PACKAGE_VERSION_LIST = exports.EXAMPLE_PACKAGE_CREATE = exports.EXAMPLE_PACKAGE_DELETE = exports.EXAMPLE_PACKAGE_DOWNLOAD = exports.EXAMPLE_PACKAGE_PUBLISH = exports.EXAMPLE_PIPELINE_RUN = exports.EXAMPLE_SANDBOX_ENDPOINT_LIST = exports.EXAMPLE_SANDBOX_ENDPOINT_GET = exports.EXAMPLE_SANDBOX_ENDPOINT_DELETE = exports.EXAMPLE_SANDBOX_ENDPOINT_CREATE = exports.EXAMPLE_SANDBOX_SNAPSHOT_LIST = exports.EXAMPLE_SANDBOX_SNAPSHOT_GET = exports.EXAMPLE_SANDBOX_SNAPSHOT_DELETE = exports.EXAMPLE_SANDBOX_SNAPSHOT_CREATE = exports.EXAMPLE_SANDBOX_EXEC_STATUS = exports.EXAMPLE_SANDBOX_EXEC_LOGS = exports.EXAMPLE_SANDBOX_EXEC_LIST = exports.EXAMPLE_SANDBOX_EXEC_KILL = exports.EXAMPLE_SANDBOX_EXEC_COMMAND = exports.EXAMPLE_TUNNEL_START = exports.EXAMPLE_TUNNEL_TCP = exports.EXAMPLE_TUNNEL_TLS = exports.EXAMPLE_AGENT_TUNNEL_START = exports.EXAMPLE_AGENT_TUNNEL_STATUS = exports.EXAMPLE_AGENT_TUNNEL_REMOVE = void 0;
|
|
15
16
|
const utils_1 = require("./utils");
|
|
16
17
|
exports.ERR_REST_API_GENERAL_ERROR = 'Something went wrong';
|
|
17
18
|
exports.ERR_REST_API_NOT_RESPONDING = 'Api endpoint not responding. Try again later...';
|
|
@@ -653,7 +654,27 @@ exports.ERR_WHOAMI_LOGOUT = 'Not logged in. Run `bdy login` to authenticate.';
|
|
|
653
654
|
// api command
|
|
654
655
|
exports.DESC_COMMAND_API = 'Contact Buddy API directly';
|
|
655
656
|
exports.DESC_COMMAND_API_LIST = 'List Buddy API endpoints';
|
|
657
|
+
exports.DESC_COMMAND_API_POST = 'Make HTTP POST to Buddy API endpoint';
|
|
658
|
+
exports.DESC_COMMAND_API_PUT = 'Make HTTP PUT to Buddy API endpoint';
|
|
659
|
+
exports.DESC_COMMAND_API_DELETE = 'Make HTTP DELETE to Buddy API endpoint';
|
|
660
|
+
exports.DESC_COMMAND_API_PATCH = 'Make HTTP PATCH to Buddy API endpoint';
|
|
661
|
+
exports.DESC_COMMAND_API_GET = 'Make HTTP GET to Buddy API endpoint';
|
|
662
|
+
exports.DESC_COMMAND_API_REQUEST_URL = 'Request url';
|
|
663
|
+
exports.DESC_COMMAND_API_WORKSPACE = 'Workspace domain. If url contains {workspace_domain} it will be automatically replaced with provided value.';
|
|
664
|
+
exports.DESC_COMMAND_API_PROJECT = 'Project name. If url contains {project_name} it will be automatically replaced with provided value.';
|
|
665
|
+
exports.DESC_COMMAND_API_REQUEST_QUERY = 'Provide query param as key:value. Can be used multiple times';
|
|
666
|
+
exports.DESC_COMMAND_API_OUTPUT = 'Write to file instead of stdout';
|
|
667
|
+
exports.DESC_COMMAND_API_DATA = 'HTTP request urlencoded data. To specify file use @path/to/file format in value';
|
|
668
|
+
exports.DESC_COMMAND_API_JSON = 'HTTP request json data. To specify file containing json use @path/to/file format in value';
|
|
669
|
+
exports.DESC_COMMAND_API_FORM = 'HTTP request multipart data. Can be used multiple times. To specify file use @path/to/file format in value';
|
|
656
670
|
exports.DESC_COMMAND_API_INFO = 'Show info about API endpoint';
|
|
671
|
+
exports.ERR_API_REQUEST_OUTPUT_EXISTS = 'Output path already exists';
|
|
672
|
+
exports.ERR_API_REQUEST_FILE_ERROR = 'Cannot read provided file';
|
|
673
|
+
exports.ERR_API_REQUEST_INVALID_JSON = 'JSON data is invalid';
|
|
674
|
+
const ERR_API_REQUEST_QUERY_VALUE = (q) => `Wrong value of query param: ${q}`;
|
|
675
|
+
exports.ERR_API_REQUEST_QUERY_VALUE = ERR_API_REQUEST_QUERY_VALUE;
|
|
676
|
+
const ERR_API_REQUEST_BODY_VALUE = (p) => `Wrong value of body param ${p}`;
|
|
677
|
+
exports.ERR_API_REQUEST_BODY_VALUE = ERR_API_REQUEST_BODY_VALUE;
|
|
657
678
|
exports.OPT_COMMAND_API_LIST_METHOD = 'Filter endpoints by method (all, get, post, put, patch, delete). Default: all';
|
|
658
679
|
exports.OPT_COMMAND_API_LIST_SEARCH = 'Filter endpoints by phrase';
|
|
659
680
|
exports.OPT_COMMAND_API_INFO_METHOD = 'Endpoint method (get, post, put, patch, delete)';
|
|
@@ -662,6 +683,8 @@ exports.ERR_SCHEMA_FETCH_FAILED = 'Failed to fetch api schema';
|
|
|
662
683
|
exports.ERR_API_WRONG_METHOD = 'Wrong method value';
|
|
663
684
|
exports.ERR_API_ENDPOINT_NOT_FOUND = 'Endpoint not found';
|
|
664
685
|
exports.TXT_API_ENDPOINT_REQUIRED_SCOPES = 'Required scopes';
|
|
686
|
+
const ERR_API_PARAMETER_NOT_REPLACED = (param) => `Replace URL parameter ${param}`;
|
|
687
|
+
exports.ERR_API_PARAMETER_NOT_REPLACED = ERR_API_PARAMETER_NOT_REPLACED;
|
|
665
688
|
const ERR_API_MEDIA_TYPE_NOT_IMPLEMENTED = (type) => `Media type not implemented (${type})`;
|
|
666
689
|
exports.ERR_API_MEDIA_TYPE_NOT_IMPLEMENTED = ERR_API_MEDIA_TYPE_NOT_IMPLEMENTED;
|
|
667
690
|
// Login command
|
|
@@ -832,6 +855,51 @@ EXAMPLES:
|
|
|
832
855
|
|
|
833
856
|
# create sandbox with custom resources and tag it:
|
|
834
857
|
bdy sb create --resources 4x8 --tag "tag1" --tag "tag2"`;
|
|
858
|
+
const EXAMPLE_TUNNEL_HTTP = (agent) => `
|
|
859
|
+
# start http tunnel on port 80:
|
|
860
|
+
bdy ${agent ? 'agent ' : ''}tunnel http 80
|
|
861
|
+
|
|
862
|
+
# start named http tunnel and serve local directory:
|
|
863
|
+
bdy ${agent ? 'agent ' : ''}tunnel http -n name -s /path/to/dir
|
|
864
|
+
|
|
865
|
+
# start http tunnel, whitelist ip and turn on on basic auth:
|
|
866
|
+
bdy ${agent ? 'agent ' : ''}tunnel http https://myhost.com -w 1.1.1.1 -a user:pass`;
|
|
867
|
+
exports.EXAMPLE_TUNNEL_HTTP = EXAMPLE_TUNNEL_HTTP;
|
|
868
|
+
exports.EXAMPLE_AGENT_TUNNEL_LIST = `
|
|
869
|
+
# list agent tunnels:
|
|
870
|
+
bdy agent tunnel list`;
|
|
871
|
+
exports.EXAMPLE_AGENT_TUNNEL_REMOVE = `
|
|
872
|
+
# remove agent tunnel:
|
|
873
|
+
bdy agent tunnel rm tunnel-id`;
|
|
874
|
+
exports.EXAMPLE_AGENT_TUNNEL_STATUS = `
|
|
875
|
+
# get agent tunnel status:
|
|
876
|
+
bdy agent tunnel status tunnel-id`;
|
|
877
|
+
exports.EXAMPLE_AGENT_TUNNEL_START = `
|
|
878
|
+
# add tunnel to config:
|
|
879
|
+
bdy tunnel config add http name 80
|
|
880
|
+
|
|
881
|
+
# start agent tunnel from config:
|
|
882
|
+
bdy agent tunnel start name`;
|
|
883
|
+
const EXAMPLE_TUNNEL_TLS = (agent) => `
|
|
884
|
+
# start tls tunnel on port 80:
|
|
885
|
+
bdy ${agent ? 'agent ' : ''}tunnel tls 80
|
|
886
|
+
|
|
887
|
+
# start tls tunnel and terminate tls at target:
|
|
888
|
+
bdy ${agent ? 'agent ' : ''}tunnel tls 443 -i target`;
|
|
889
|
+
exports.EXAMPLE_TUNNEL_TLS = EXAMPLE_TUNNEL_TLS;
|
|
890
|
+
const EXAMPLE_TUNNEL_TCP = (agent) => `
|
|
891
|
+
# start tcp tunnel on port 22:
|
|
892
|
+
bdy ${agent ? 'agent ' : ''}tunnel tcp 22
|
|
893
|
+
|
|
894
|
+
# start named tcp tunnel with whitelist:
|
|
895
|
+
bdy ${agent ? 'agent ' : ''}tunnel tcp 80 -n name -w 1.1.1.1/27`;
|
|
896
|
+
exports.EXAMPLE_TUNNEL_TCP = EXAMPLE_TUNNEL_TCP;
|
|
897
|
+
exports.EXAMPLE_TUNNEL_START = `
|
|
898
|
+
# add tunnel to config:
|
|
899
|
+
bdy tunnel config add http name 80
|
|
900
|
+
|
|
901
|
+
# start tunnel from config:
|
|
902
|
+
bdy tunnel start name`;
|
|
835
903
|
exports.EXAMPLE_SANDBOX_EXEC_COMMAND = `
|
|
836
904
|
# ran command in sandbox:
|
|
837
905
|
bdy sb exec command sandbox-identifier "ls -la"
|