bdy 1.22.40-dev → 1.22.41-beta
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/command/login.js +11 -1
- package/distTs/src/input.js +51 -43
- package/distTs/src/texts.js +2 -0
- package/distTs/src/tunnel/http.js +9 -0
- package/distTs/src/tunnel/server/ssh.js +30 -1
- package/package.json +1 -1
package/distTs/package.json
CHANGED
|
@@ -10,6 +10,7 @@ const texts_1 = require("../texts");
|
|
|
10
10
|
const utils_1 = require("../utils");
|
|
11
11
|
const input_1 = __importDefault(require("../input"));
|
|
12
12
|
const uuid_1 = require("uuid");
|
|
13
|
+
const OAUTH_TIMEOUT = 5 * 60 * 1000;
|
|
13
14
|
const OAUTH_CLIENT_APP_PORT = 7596;
|
|
14
15
|
const OAUTH_CLIENT_APP_HOST = 'localhost';
|
|
15
16
|
const OAUTH_CLIENT_APP_SCOPES = [
|
|
@@ -52,6 +53,9 @@ async function oauthServer(api, clientId, clientSecret) {
|
|
|
52
53
|
const ApiClient = require('../api/client').default;
|
|
53
54
|
const open = require('open').default;
|
|
54
55
|
const redirectUrl = getRedirectUrl(api);
|
|
56
|
+
const ts = setTimeout(() => {
|
|
57
|
+
output_1.default.exitError(texts_1.ERR_LOGIN_HTTP_CANCEL);
|
|
58
|
+
}, OAUTH_TIMEOUT);
|
|
55
59
|
return new Promise((resolve) => {
|
|
56
60
|
const state = (0, uuid_1.v4)();
|
|
57
61
|
const abortCode = new AbortController();
|
|
@@ -63,6 +67,7 @@ async function oauthServer(api, clientId, clientSecret) {
|
|
|
63
67
|
res.end(urlState);
|
|
64
68
|
s.close();
|
|
65
69
|
abortCode.abort();
|
|
70
|
+
clearTimeout(ts);
|
|
66
71
|
resolve({
|
|
67
72
|
token: response.access_token,
|
|
68
73
|
refreshToken: response.refresh_token,
|
|
@@ -94,6 +99,7 @@ async function oauthServer(api, clientId, clientSecret) {
|
|
|
94
99
|
});
|
|
95
100
|
s.on('error', () => {
|
|
96
101
|
s.close();
|
|
102
|
+
clearTimeout(ts);
|
|
97
103
|
output_1.default.exitError(texts_1.ERR_LOGIN_HTTP_SERVER_PORT_TAKEN);
|
|
98
104
|
});
|
|
99
105
|
s.listen(OAUTH_CLIENT_APP_PORT, OAUTH_CLIENT_APP_HOST, async () => {
|
|
@@ -115,15 +121,19 @@ async function oauthServer(api, clientId, clientSecret) {
|
|
|
115
121
|
try {
|
|
116
122
|
const code = await output_1.default.inputString(texts_1.TXT_LOGIN_PROVIDE_CODE, undefined, false, abortCode.signal);
|
|
117
123
|
const success = await exchange(code, state);
|
|
118
|
-
if (success)
|
|
124
|
+
if (success) {
|
|
125
|
+
clearTimeout(ts);
|
|
119
126
|
break;
|
|
127
|
+
}
|
|
120
128
|
}
|
|
121
129
|
catch (err) {
|
|
122
130
|
if (err.name === 'AbortPromptError') {
|
|
131
|
+
clearTimeout(ts);
|
|
123
132
|
output_1.default.clearPreviousLine();
|
|
124
133
|
break;
|
|
125
134
|
}
|
|
126
135
|
else if (err.name === 'ExitPromptError') {
|
|
136
|
+
clearTimeout(ts);
|
|
127
137
|
output_1.default.exitError(texts_1.ERR_LOGIN_HTTP_CANCEL);
|
|
128
138
|
}
|
|
129
139
|
}
|
package/distTs/src/input.js
CHANGED
|
@@ -492,6 +492,9 @@ class Input {
|
|
|
492
492
|
static sandboxFetch(fetchList) {
|
|
493
493
|
const fetch = [];
|
|
494
494
|
const SEP = '\x00';
|
|
495
|
+
const hasParts = (str) => {
|
|
496
|
+
return /(^|,)\s?(ref|path|url|build|artifact)=/.test(str);
|
|
497
|
+
};
|
|
495
498
|
if (Array.isArray(fetchList)) {
|
|
496
499
|
fetchList.forEach((str) => {
|
|
497
500
|
let type = sandbox_1.SANDBOX_FETCH.PROJECT_REPO;
|
|
@@ -500,57 +503,62 @@ class Input {
|
|
|
500
503
|
let path = '';
|
|
501
504
|
let build = '';
|
|
502
505
|
let artifact = '';
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
const key = p.substring(0, idx).trim();
|
|
514
|
-
const val = p.substring(idx + 1).trim();
|
|
515
|
-
if (key === 'url' && val) {
|
|
516
|
-
if (repository || type !== sandbox_1.SANDBOX_FETCH.PROJECT_REPO) {
|
|
517
|
-
output_1.default.exitError((0, texts_1.ERR_WRONG_FETCH)(str, 'Param url defined twice'));
|
|
506
|
+
if (hasParts(str)) {
|
|
507
|
+
const parts = str
|
|
508
|
+
.replace(/\\,/g, SEP)
|
|
509
|
+
.split(',')
|
|
510
|
+
.map((p) => p.split(SEP).join(',').trim());
|
|
511
|
+
for (let i = 0; i < parts.length; i += 1) {
|
|
512
|
+
const p = parts[i];
|
|
513
|
+
const idx = p.indexOf('=');
|
|
514
|
+
if (idx < 0) {
|
|
515
|
+
output_1.default.exitError((0, texts_1.ERR_WRONG_FETCH)(str, 'No key=val delimiter'));
|
|
518
516
|
}
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
517
|
+
const key = p.substring(0, idx).trim();
|
|
518
|
+
const val = p.substring(idx + 1).trim();
|
|
519
|
+
if (key === 'url' && val) {
|
|
520
|
+
if (repository || type !== sandbox_1.SANDBOX_FETCH.PROJECT_REPO) {
|
|
521
|
+
output_1.default.exitError((0, texts_1.ERR_WRONG_FETCH)(str, 'Param url defined twice'));
|
|
522
|
+
}
|
|
523
|
+
type = sandbox_1.SANDBOX_FETCH.PUBLIC_REPO;
|
|
524
|
+
repository = val;
|
|
525
525
|
}
|
|
526
|
-
path
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
526
|
+
else if (key === 'path' && val) {
|
|
527
|
+
if (path) {
|
|
528
|
+
output_1.default.exitError((0, texts_1.ERR_WRONG_FETCH)(str, 'Param path defined twice'));
|
|
529
|
+
}
|
|
530
|
+
path = val;
|
|
531
531
|
}
|
|
532
|
-
ref
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
532
|
+
else if (key === 'ref' && val) {
|
|
533
|
+
if (ref) {
|
|
534
|
+
output_1.default.exitError((0, texts_1.ERR_WRONG_FETCH)(str, 'Param ref defined twice'));
|
|
535
|
+
}
|
|
536
|
+
ref = val;
|
|
537
537
|
}
|
|
538
|
-
build
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
538
|
+
else if (key === 'build' && val) {
|
|
539
|
+
if (build) {
|
|
540
|
+
output_1.default.exitError((0, texts_1.ERR_WRONG_FETCH)(str, 'Param build defined twice'));
|
|
541
|
+
}
|
|
542
|
+
build = val;
|
|
543
543
|
}
|
|
544
|
-
if (
|
|
545
|
-
|
|
544
|
+
else if (key === 'artifact' && val) {
|
|
545
|
+
if (artifact) {
|
|
546
|
+
output_1.default.exitError((0, texts_1.ERR_WRONG_FETCH)(str, 'Param artifact defined twice'));
|
|
547
|
+
}
|
|
548
|
+
if (type !== sandbox_1.SANDBOX_FETCH.PROJECT_REPO) {
|
|
549
|
+
output_1.default.exitError((0, texts_1.ERR_WRONG_FETCH)(str, 'Cant mix artifact with repository'));
|
|
550
|
+
}
|
|
551
|
+
type = sandbox_1.SANDBOX_FETCH.ARTIFACT;
|
|
552
|
+
artifact = val;
|
|
553
|
+
}
|
|
554
|
+
else {
|
|
555
|
+
output_1.default.exitError((0, texts_1.ERR_WRONG_FETCH)(str, 'Unknown param'));
|
|
546
556
|
}
|
|
547
|
-
type = sandbox_1.SANDBOX_FETCH.ARTIFACT;
|
|
548
|
-
artifact = val;
|
|
549
|
-
}
|
|
550
|
-
else {
|
|
551
|
-
output_1.default.exitError((0, texts_1.ERR_WRONG_FETCH)(str, 'Unknown param'));
|
|
552
557
|
}
|
|
553
558
|
}
|
|
559
|
+
else {
|
|
560
|
+
ref = str.trim();
|
|
561
|
+
}
|
|
554
562
|
const f = {
|
|
555
563
|
type,
|
|
556
564
|
};
|
package/distTs/src/texts.js
CHANGED
|
@@ -1009,6 +1009,8 @@ EXAMPLES:
|
|
|
1009
1009
|
bdy sb create --resources 4x8 --tag "tag1" --tag "tag2"
|
|
1010
1010
|
### create sandbox and fetch project repository from default branch to working directory
|
|
1011
1011
|
bdy sb create --fetch
|
|
1012
|
+
### create sandbox and fetch project repository branch
|
|
1013
|
+
bdy sb create --fetch feature-branch
|
|
1012
1014
|
### create sandbox and fetch public repository
|
|
1013
1015
|
bdy sb create --fetch "path=/home/buddy/repo,url=https://public-repo.com,ref=feature-branch"
|
|
1014
1016
|
### create sandbox and fetch artifact
|
|
@@ -106,6 +106,15 @@ class TunnelHttp extends events_1.default {
|
|
|
106
106
|
Object.keys(this.responseHeaders).forEach((name) => {
|
|
107
107
|
this.res.setHeader(name.toLowerCase(), this.responseHeaders[name]);
|
|
108
108
|
});
|
|
109
|
+
setImmediate(() => {
|
|
110
|
+
try {
|
|
111
|
+
if (this.res && !this.res.headersSent)
|
|
112
|
+
this.res.flushHeaders();
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
// do nothing
|
|
116
|
+
}
|
|
117
|
+
});
|
|
109
118
|
}
|
|
110
119
|
catch {
|
|
111
120
|
// headers already sent
|
|
@@ -41,7 +41,36 @@ class ServerSsh extends events_1.default {
|
|
|
41
41
|
this.server = new ssh2_1.default.Server({
|
|
42
42
|
hostKeys: [hostKey],
|
|
43
43
|
highWaterMark: 65536,
|
|
44
|
-
ident: '
|
|
44
|
+
ident: 'SSH-2.0-Buddy',
|
|
45
|
+
algorithms: {
|
|
46
|
+
kex: [
|
|
47
|
+
'curve25519-sha256',
|
|
48
|
+
'curve25519-sha256@libssh.org',
|
|
49
|
+
'ecdh-sha2-nistp256',
|
|
50
|
+
'ecdh-sha2-nistp384',
|
|
51
|
+
'ecdh-sha2-nistp521',
|
|
52
|
+
'diffie-hellman-group-exchange-sha256',
|
|
53
|
+
'diffie-hellman-group14-sha256',
|
|
54
|
+
'diffie-hellman-group16-sha512',
|
|
55
|
+
'diffie-hellman-group18-sha512',
|
|
56
|
+
],
|
|
57
|
+
cipher: [
|
|
58
|
+
'chacha20-poly1305@openssh.com',
|
|
59
|
+
'aes256-gcm@openssh.com',
|
|
60
|
+
'aes128-gcm@openssh.com',
|
|
61
|
+
'aes256-ctr',
|
|
62
|
+
'aes192-ctr',
|
|
63
|
+
'aes128-ctr',
|
|
64
|
+
],
|
|
65
|
+
hmac: [
|
|
66
|
+
'hmac-sha2-256-etm@openssh.com',
|
|
67
|
+
'hmac-sha2-512-etm@openssh.com',
|
|
68
|
+
'hmac-sha2-256',
|
|
69
|
+
'hmac-sha2-512',
|
|
70
|
+
],
|
|
71
|
+
serverHostKey: ['ssh-ed25519', 'rsa-sha2-512', 'rsa-sha2-256'],
|
|
72
|
+
compress: ['none', 'zlib@openssh.com'],
|
|
73
|
+
},
|
|
45
74
|
}, (client) => this.processClient(client));
|
|
46
75
|
this.server.listen();
|
|
47
76
|
}
|