@forge/tunnel 5.8.2-next.0-experimental-147ff14 → 5.9.0-next.2
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/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
# @forge/tunnel
|
|
2
2
|
|
|
3
|
-
## 5.
|
|
3
|
+
## 5.9.0-next.2
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
- @forge/bundler@4.20.6-next.
|
|
8
|
-
- @forge/cli-shared@6.5.
|
|
9
|
-
|
|
7
|
+
- @forge/bundler@4.20.6-next.2
|
|
8
|
+
- @forge/cli-shared@6.5.3-next.1
|
|
9
|
+
|
|
10
|
+
## 5.9.0-next.1
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- c86b880: Make the cloudflared dependency optional to unblock users with network restrictions
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [cda6bc5]
|
|
19
|
+
- @forge/cli-shared@6.5.3-next.0
|
|
20
|
+
- @forge/bundler@4.20.6-next.1
|
|
10
21
|
|
|
11
22
|
## 5.8.2-next.0
|
|
12
23
|
|
|
@@ -19,7 +19,8 @@ export declare class CloudflareCreateTunnelService implements CreateTunnelServic
|
|
|
19
19
|
private readonly logger;
|
|
20
20
|
private stopFunction;
|
|
21
21
|
constructor(logger: Logger);
|
|
22
|
-
private
|
|
22
|
+
private handleTunnelEstablishError;
|
|
23
|
+
private handleChildProcessData;
|
|
23
24
|
establishTunnel({ port, id, token, tunnelUrl }: TunnelConfig): Promise<URL>;
|
|
24
25
|
closeTunnel(): Promise<void>;
|
|
25
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-tunnel-service.d.ts","sourceRoot":"","sources":["../../src/services/create-tunnel-service.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"create-tunnel-service.d.ts","sourceRoot":"","sources":["../../src/services/create-tunnel-service.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAI1B,OAAO,EAAE,SAAS,EAAE,MAAM,EAAmB,MAAM,mBAAmB,CAAC;AAEvE,oBAAY,sBAAsB,GAAG;IACnC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACjC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC9B,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CACtC,CAAC;AAEF,oBAAY,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;CACd,GAAG,sBAAsB,CAAC;AAE3B,MAAM,WAAW,mBAAmB;IAClC,eAAe,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAC5E,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED,qBAAa,eAAgB,SAAQ,SAAS;CAAG;AAEjD,qBAAa,6BAA8B,YAAW,mBAAmB;IAG3D,OAAO,CAAC,QAAQ,CAAC,MAAM;IAFnC,OAAO,CAAC,YAAY,CAA0E;gBAEjE,MAAM,EAAE,MAAM;IAE3C,OAAO,CAAC,0BAA0B;IAgBlC,OAAO,CAAC,sBAAsB;IAgBjB,eAAe,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC;IA2D3E,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;CAQ1C"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CloudflareCreateTunnelService = exports.CloudflareError = void 0;
|
|
4
|
-
const
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
5
|
const url_1 = require("url");
|
|
6
|
+
const child_process_1 = require("child_process");
|
|
7
|
+
const which_1 = tslib_1.__importDefault(require("which"));
|
|
8
|
+
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
6
9
|
const cli_shared_1 = require("@forge/cli-shared");
|
|
7
10
|
class CloudflareError extends cli_shared_1.BaseError {
|
|
8
11
|
}
|
|
@@ -13,50 +16,76 @@ class CloudflareCreateTunnelService {
|
|
|
13
16
|
constructor(logger) {
|
|
14
17
|
this.logger = logger;
|
|
15
18
|
}
|
|
16
|
-
|
|
19
|
+
handleTunnelEstablishError(e, usingLocalCloudflareBinary) {
|
|
17
20
|
const UNKNOWN_SYS_ERROR = 'Unknown system error -86';
|
|
18
21
|
const userSysErrors = [UNKNOWN_SYS_ERROR, 'EPERM'];
|
|
19
|
-
if (userSysErrors.some((error) => e.message.includes(error))) {
|
|
22
|
+
if (userSysErrors.some((error) => e.message.includes(error)) || usingLocalCloudflareBinary) {
|
|
20
23
|
let errorMessage = e.message;
|
|
21
24
|
if (e.message.includes(UNKNOWN_SYS_ERROR)) {
|
|
22
25
|
errorMessage += ': Running `softwareupdate --install-rosetta` may help fix the problem';
|
|
23
26
|
}
|
|
24
|
-
|
|
27
|
+
return new cli_shared_1.UserError(errorMessage);
|
|
25
28
|
}
|
|
26
|
-
|
|
29
|
+
return e;
|
|
30
|
+
}
|
|
31
|
+
handleChildProcessData(child) {
|
|
32
|
+
child.stdout?.on('data', (chunk) => this.logger.debug(cli_shared_1.Text.tunnel.cloudflaredLog(chunk)));
|
|
33
|
+
child.stderr?.on('data', (chunk) => this.logger.debug(cli_shared_1.Text.tunnel.cloudflaredLog(chunk)));
|
|
34
|
+
child.on('error', (err) => {
|
|
35
|
+
this.logger.error(err);
|
|
36
|
+
throw new cli_shared_1.BaseError(undefined, cli_shared_1.Text.tunnel.error.cloudflaredError);
|
|
37
|
+
});
|
|
38
|
+
child.on('exit', (code) => {
|
|
39
|
+
if (code !== 0 && code !== null) {
|
|
40
|
+
throw new cli_shared_1.BaseError(undefined, cli_shared_1.Text.tunnel.error.cloudflaredExit(code));
|
|
41
|
+
}
|
|
42
|
+
});
|
|
27
43
|
}
|
|
28
44
|
async establishTunnel({ port, id, token, tunnelUrl }) {
|
|
29
45
|
if (!id || !token || !tunnelUrl) {
|
|
30
46
|
throw new CloudflareError(undefined, 'Missing configuration to create tunnel');
|
|
31
47
|
}
|
|
32
|
-
const options =
|
|
33
|
-
|
|
34
|
-
'
|
|
35
|
-
'--
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
48
|
+
const options = [
|
|
49
|
+
'tunnel',
|
|
50
|
+
'run',
|
|
51
|
+
'--token',
|
|
52
|
+
token,
|
|
53
|
+
'--url',
|
|
54
|
+
`localhost:${port}`,
|
|
55
|
+
'--protocol',
|
|
56
|
+
'http2'
|
|
57
|
+
];
|
|
39
58
|
process.env['TUNNEL_LOGLEVEL'] = 'debug';
|
|
59
|
+
let cloudflaredBinary = null;
|
|
60
|
+
let usingLocalCloudflareBinary = false;
|
|
40
61
|
try {
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
62
|
+
const cloudflaredBin = require('cloudflared').bin;
|
|
63
|
+
if (fs_1.default.existsSync(cloudflaredBin)) {
|
|
64
|
+
cloudflaredBinary = cloudflaredBin;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
catch (error) { }
|
|
68
|
+
try {
|
|
69
|
+
if (!cloudflaredBinary) {
|
|
70
|
+
cloudflaredBinary = await (0, which_1.default)('cloudflared', { nothrow: true });
|
|
71
|
+
if (cloudflaredBinary) {
|
|
72
|
+
usingLocalCloudflareBinary = true;
|
|
73
|
+
this.logger.warn(cli_shared_1.Text.tunnel.tunnelWithLocalCloudflared);
|
|
51
74
|
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
75
|
+
}
|
|
76
|
+
if (!cloudflaredBinary) {
|
|
77
|
+
throw new cli_shared_1.UserError(cli_shared_1.Text.tunnel.error.cloudflaredUnavailableError);
|
|
78
|
+
}
|
|
79
|
+
const cloudflareTunnelProcess = (0, child_process_1.spawn)(cloudflaredBinary, options, { stdio: ['ignore', 'pipe', 'pipe'] });
|
|
80
|
+
this.handleChildProcessData(cloudflareTunnelProcess);
|
|
81
|
+
this.stopFunction = (signal) => {
|
|
82
|
+
return cloudflareTunnelProcess.kill(signal);
|
|
83
|
+
};
|
|
55
84
|
this.logger.debug(cli_shared_1.Text.tunnel.startedTunnel(tunnelUrl));
|
|
56
85
|
return new url_1.URL(tunnelUrl);
|
|
57
86
|
}
|
|
58
87
|
catch (e) {
|
|
59
|
-
throw this.
|
|
88
|
+
throw this.handleTunnelEstablishError(e, usingLocalCloudflareBinary);
|
|
60
89
|
}
|
|
61
90
|
}
|
|
62
91
|
async closeTunnel() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forge/tunnel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.9.0-next.2",
|
|
4
4
|
"description": "Tunnel functionality for Forge CLI",
|
|
5
5
|
"author": "Atlassian",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -11,12 +11,11 @@
|
|
|
11
11
|
"compile": "tsc -b -v"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@forge/bundler": "4.20.6-next.
|
|
15
|
-
"@forge/cli-shared": "6.5.
|
|
16
|
-
"@forge/csp": "3.6.0
|
|
14
|
+
"@forge/bundler": "4.20.6-next.2",
|
|
15
|
+
"@forge/cli-shared": "6.5.3-next.1",
|
|
16
|
+
"@forge/csp": "3.6.0",
|
|
17
17
|
"@forge/runtime": "5.10.4",
|
|
18
18
|
"chokidar": "^3.6.0",
|
|
19
|
-
"cloudflared": "^0.5.2",
|
|
20
19
|
"express": "^4.18.3",
|
|
21
20
|
"express-intercept": "^1.1.0",
|
|
22
21
|
"http-proxy-middleware": "^2.0.6",
|
|
@@ -25,17 +24,22 @@
|
|
|
25
24
|
"tmp": "^0.2.3",
|
|
26
25
|
"tslib": "^2.6.2",
|
|
27
26
|
"uuid": "^9.0.1",
|
|
28
|
-
"webpack-dev-server": "^4.15.1"
|
|
27
|
+
"webpack-dev-server": "^4.15.1",
|
|
28
|
+
"which": "^5.0.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@atlassian/xen-test-util": "^4.2.0",
|
|
32
|
-
"@forge/manifest": "8.
|
|
32
|
+
"@forge/manifest": "8.5.0-next.1",
|
|
33
33
|
"@types/express": "^4.17.21",
|
|
34
34
|
"@types/jest": "^29.5.12",
|
|
35
35
|
"@types/node": "14.18.63",
|
|
36
36
|
"@types/supertest": "^2.0.16",
|
|
37
37
|
"@types/tmp": "^0.2.6",
|
|
38
38
|
"@types/uuid": "^9.0.8",
|
|
39
|
+
"@types/which": "^3.0.4",
|
|
39
40
|
"supertest": "^6.3.3"
|
|
41
|
+
},
|
|
42
|
+
"optionalDependencies": {
|
|
43
|
+
"cloudflared": "^0.5.2"
|
|
40
44
|
}
|
|
41
45
|
}
|