bdy 1.16.15-dev → 1.16.17-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 +2 -1
- package/distTs/src/api/client.js +107 -14
- package/distTs/src/command/login.js +111 -46
- package/distTs/src/command/package/download.js +259 -0
- package/distTs/src/command/package/list.js +35 -0
- package/distTs/src/command/package/publish.js +231 -0
- package/distTs/src/command/package.js +16 -0
- package/distTs/src/command/pipeline/run.js +3 -3
- package/distTs/src/command/project/set.js +1 -1
- package/distTs/src/index.js +2 -0
- package/distTs/src/input.js +24 -2
- package/distTs/src/texts.js +69 -22
- package/distTs/src/tunnel/cfg.js +17 -0
- package/distTs/src/tunnel/server/http1.js +11 -6
- package/distTs/src/tunnel/server/http2.js +14 -6
- package/package.json +2 -1
package/distTs/src/tunnel/cfg.js
CHANGED
|
@@ -172,6 +172,17 @@ class Cfg {
|
|
|
172
172
|
this.json.apiToken = token;
|
|
173
173
|
this.save();
|
|
174
174
|
}
|
|
175
|
+
setApiClient(clientId, clientSecret) {
|
|
176
|
+
if (!clientId || !clientSecret) {
|
|
177
|
+
delete this.json.apiClientId;
|
|
178
|
+
delete this.json.apiClientSecret;
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
this.json.apiClientId = clientId;
|
|
182
|
+
this.json.apiClientSecret = clientSecret;
|
|
183
|
+
}
|
|
184
|
+
this.save();
|
|
185
|
+
}
|
|
175
186
|
setWhitelist(whitelist) {
|
|
176
187
|
if (!whitelist || !whitelist.length)
|
|
177
188
|
delete this.json.whitelist;
|
|
@@ -192,6 +203,12 @@ class Cfg {
|
|
|
192
203
|
getApiToken() {
|
|
193
204
|
return this.json.apiToken || '';
|
|
194
205
|
}
|
|
206
|
+
getApiClientId() {
|
|
207
|
+
return this.json.apiClientId || '';
|
|
208
|
+
}
|
|
209
|
+
getApiClientSecret() {
|
|
210
|
+
return this.json.apiClientSecret || '';
|
|
211
|
+
}
|
|
195
212
|
getTokenHost() {
|
|
196
213
|
const token = this.getToken();
|
|
197
214
|
if (!token) {
|
|
@@ -11,9 +11,11 @@ const texts_1 = require("../../texts");
|
|
|
11
11
|
const tunnel_1 = require("../../types/tunnel");
|
|
12
12
|
class ServerHttp1 extends events_1.default {
|
|
13
13
|
server;
|
|
14
|
+
host;
|
|
14
15
|
constructor(host) {
|
|
15
16
|
super();
|
|
16
|
-
this.
|
|
17
|
+
this.host = host;
|
|
18
|
+
this.server = http_1.default.createServer((req, res) => this.processRequest(req, res));
|
|
17
19
|
this.server.on('connection', (socket) => {
|
|
18
20
|
socket.id = (0, uuid_1.v4)();
|
|
19
21
|
this.emit(tunnel_1.TUNNEL_HTTP_SOCKET.OPEN, socket);
|
|
@@ -46,7 +48,10 @@ class ServerHttp1 extends events_1.default {
|
|
|
46
48
|
method: logRequest.method,
|
|
47
49
|
setHost: false,
|
|
48
50
|
path: logRequest.url,
|
|
49
|
-
headers:
|
|
51
|
+
headers: {
|
|
52
|
+
...logRequest.headers,
|
|
53
|
+
host: this.host
|
|
54
|
+
},
|
|
50
55
|
});
|
|
51
56
|
if (logRequest.requestBody.data.length > 0)
|
|
52
57
|
req.write(logRequest.requestBody.data);
|
|
@@ -60,9 +65,9 @@ class ServerHttp1 extends events_1.default {
|
|
|
60
65
|
});
|
|
61
66
|
req.end();
|
|
62
67
|
}
|
|
63
|
-
checkHostHeader(req, res
|
|
68
|
+
checkHostHeader(req, res) {
|
|
64
69
|
const headerHost = (req.headers.host || '').split(':')[0];
|
|
65
|
-
if (headerHost === host)
|
|
70
|
+
if (headerHost === this.host)
|
|
66
71
|
return true;
|
|
67
72
|
else {
|
|
68
73
|
res.statusCode = 421;
|
|
@@ -70,8 +75,8 @@ class ServerHttp1 extends events_1.default {
|
|
|
70
75
|
return false;
|
|
71
76
|
}
|
|
72
77
|
}
|
|
73
|
-
async processRequest(req, res
|
|
74
|
-
if (!this.checkHostHeader(req, res
|
|
78
|
+
async processRequest(req, res) {
|
|
79
|
+
if (!this.checkHostHeader(req, res))
|
|
75
80
|
return;
|
|
76
81
|
logger_1.default.debug((0, texts_1.LOG_HTTP1_REQUEST)(req.method, req.url));
|
|
77
82
|
this.emit(tunnel_1.TUNNEL_EVENT.HTTP_REQUEST, req, res);
|
|
@@ -11,9 +11,11 @@ const texts_1 = require("../../texts");
|
|
|
11
11
|
const tunnel_1 = require("../../types/tunnel");
|
|
12
12
|
class ServerHttp2 extends events_1.default {
|
|
13
13
|
server;
|
|
14
|
+
host;
|
|
14
15
|
constructor(host) {
|
|
15
16
|
super();
|
|
16
|
-
this.
|
|
17
|
+
this.host = host;
|
|
18
|
+
this.server = http2_1.default.createServer((req, res) => this.processRequest(req, res));
|
|
17
19
|
this.server.on('session', (session) => {
|
|
18
20
|
session.id = (0, uuid_1.v4)();
|
|
19
21
|
this.emit(tunnel_1.TUNNEL_EVENT.HTTP_SESSION_OPEN, session);
|
|
@@ -43,7 +45,10 @@ class ServerHttp2 extends events_1.default {
|
|
|
43
45
|
let client = http2_1.default.connect(`http://localhost:${address.port}`, {
|
|
44
46
|
maxSessionMemory: 100,
|
|
45
47
|
});
|
|
46
|
-
let req = client.request(
|
|
48
|
+
let req = client.request({
|
|
49
|
+
...logRequest.headers,
|
|
50
|
+
':authority': this.host
|
|
51
|
+
});
|
|
47
52
|
if (logRequest.requestBody.data.length > 0)
|
|
48
53
|
req.write(logRequest.requestBody.data);
|
|
49
54
|
req.on('response', () => {
|
|
@@ -64,9 +69,12 @@ class ServerHttp2 extends events_1.default {
|
|
|
64
69
|
});
|
|
65
70
|
req.end();
|
|
66
71
|
}
|
|
67
|
-
checkHostHeader(req, res
|
|
72
|
+
checkHostHeader(req, res) {
|
|
73
|
+
logger_js_1.default.info('checkHostHeader');
|
|
74
|
+
logger_js_1.default.info(this.host);
|
|
75
|
+
logger_js_1.default.info(req.headers[':authority']);
|
|
68
76
|
const headerHost = (req.headers[':authority'] || '').split(':')[0];
|
|
69
|
-
if (headerHost === host)
|
|
77
|
+
if (headerHost === this.host)
|
|
70
78
|
return true;
|
|
71
79
|
else {
|
|
72
80
|
res.statusCode = 421;
|
|
@@ -74,8 +82,8 @@ class ServerHttp2 extends events_1.default {
|
|
|
74
82
|
return false;
|
|
75
83
|
}
|
|
76
84
|
}
|
|
77
|
-
async processRequest(req, res
|
|
78
|
-
if (!this.checkHostHeader(req, res
|
|
85
|
+
async processRequest(req, res) {
|
|
86
|
+
if (!this.checkHostHeader(req, res))
|
|
79
87
|
return;
|
|
80
88
|
logger_js_1.default.debug((0, texts_1.LOG_HTTP2_REQUEST)(req.method, req.url));
|
|
81
89
|
this.emit(tunnel_1.TUNNEL_EVENT.HTTP_REQUEST, req, res);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bdy",
|
|
3
3
|
"preferGlobal": false,
|
|
4
|
-
"version": "1.16.
|
|
4
|
+
"version": "1.16.17-dev",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"scripts": {
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"eventsource": "4.0.0",
|
|
32
32
|
"fastify": "4.28.1",
|
|
33
33
|
"fdir": "6.5.0",
|
|
34
|
+
"open": "11.0.0",
|
|
34
35
|
"fflate": "0.8.2",
|
|
35
36
|
"human-id": "^4.1.3",
|
|
36
37
|
"isbinaryfile": "5.0.2",
|