@forge/tunnel 5.3.4-next.3 → 5.4.0-experimental-9fa730f
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 +132 -0
- package/out/command/start-tunnel-command.d.ts +0 -1
- package/out/command/start-tunnel-command.d.ts.map +1 -1
- package/out/command/start-tunnel-command.js +4 -4
- package/out/servers/csp-reporter-server.d.ts.map +1 -1
- package/out/servers/csp-reporter-server.js +9 -1
- package/out/services/create-tunnel-service.d.ts +3 -27
- package/out/services/create-tunnel-service.d.ts.map +1 -1
- package/out/services/create-tunnel-service.js +1 -104
- package/out/services/register-tunnel-service.d.ts +1 -3
- package/out/services/register-tunnel-service.d.ts.map +1 -1
- package/out/services/register-tunnel-service.js +2 -11
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,137 @@
|
|
|
1
1
|
# @forge/tunnel
|
|
2
2
|
|
|
3
|
+
## 5.4.0-experimental-9fa730f
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @forge/bundler@4.18.0-experimental-9fa730f
|
|
8
|
+
|
|
9
|
+
## 5.4.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 41ba7c6: Removing Cloudflare enable FF and ngrok tunnel implementation
|
|
14
|
+
- fd7827d: User Error handling for ports already in use
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [84550d3]
|
|
19
|
+
- Updated dependencies [41ba7c6]
|
|
20
|
+
- Updated dependencies [90f621b]
|
|
21
|
+
- Updated dependencies [6c9b381]
|
|
22
|
+
- Updated dependencies [eaa03f9]
|
|
23
|
+
- Updated dependencies [694a970]
|
|
24
|
+
- @forge/cli-shared@5.4.0
|
|
25
|
+
- @forge/bundler@4.18.0
|
|
26
|
+
- @forge/csp@3.3.0
|
|
27
|
+
|
|
28
|
+
## 5.4.0-next.11
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- Updated dependencies [90f621b]
|
|
33
|
+
- @forge/cli-shared@5.4.0-next.9
|
|
34
|
+
- @forge/bundler@4.18.0-next.10
|
|
35
|
+
- @forge/csp@3.3.0-next.1
|
|
36
|
+
|
|
37
|
+
## 5.4.0-next.10
|
|
38
|
+
|
|
39
|
+
### Patch Changes
|
|
40
|
+
|
|
41
|
+
- @forge/cli-shared@5.4.0-next.8
|
|
42
|
+
- @forge/bundler@4.18.0-next.9
|
|
43
|
+
|
|
44
|
+
## 5.4.0-next.9
|
|
45
|
+
|
|
46
|
+
### Patch Changes
|
|
47
|
+
|
|
48
|
+
- @forge/cli-shared@5.4.0-next.7
|
|
49
|
+
- @forge/bundler@4.18.0-next.8
|
|
50
|
+
|
|
51
|
+
## 5.4.0-next.8
|
|
52
|
+
|
|
53
|
+
### Patch Changes
|
|
54
|
+
|
|
55
|
+
- Updated dependencies [694a970]
|
|
56
|
+
- @forge/cli-shared@5.4.0-next.6
|
|
57
|
+
- @forge/bundler@4.18.0-next.7
|
|
58
|
+
|
|
59
|
+
## 5.4.0-next.7
|
|
60
|
+
|
|
61
|
+
### Patch Changes
|
|
62
|
+
|
|
63
|
+
- Updated dependencies [4117f97]
|
|
64
|
+
- @forge/cli-shared@5.4.0-next.5
|
|
65
|
+
- @forge/bundler@4.18.0-next.6
|
|
66
|
+
- @forge/csp@3.3.0-next.0
|
|
67
|
+
|
|
68
|
+
## 5.4.0-next.6
|
|
69
|
+
|
|
70
|
+
### Patch Changes
|
|
71
|
+
|
|
72
|
+
- Updated dependencies [6c9b381]
|
|
73
|
+
- Updated dependencies [eaa03f9]
|
|
74
|
+
- @forge/bundler@4.17.6-next.5
|
|
75
|
+
|
|
76
|
+
## 5.4.0-next.5
|
|
77
|
+
|
|
78
|
+
### Patch Changes
|
|
79
|
+
|
|
80
|
+
- @forge/cli-shared@5.4.0-next.4
|
|
81
|
+
- @forge/bundler@4.17.6-next.4
|
|
82
|
+
|
|
83
|
+
## 5.4.0-next.4
|
|
84
|
+
|
|
85
|
+
### Minor Changes
|
|
86
|
+
|
|
87
|
+
- fd7827d: User Error handling for ports already in use
|
|
88
|
+
|
|
89
|
+
## 5.4.0-next.3
|
|
90
|
+
|
|
91
|
+
### Patch Changes
|
|
92
|
+
|
|
93
|
+
- Updated dependencies [84550d3]
|
|
94
|
+
- @forge/cli-shared@5.4.0-next.3
|
|
95
|
+
- @forge/bundler@4.17.6-next.3
|
|
96
|
+
|
|
97
|
+
## 5.4.0-next.2
|
|
98
|
+
|
|
99
|
+
### Patch Changes
|
|
100
|
+
|
|
101
|
+
- @forge/cli-shared@5.4.0-next.2
|
|
102
|
+
- @forge/bundler@4.17.6-next.2
|
|
103
|
+
|
|
104
|
+
## 5.4.0-next.1
|
|
105
|
+
|
|
106
|
+
### Patch Changes
|
|
107
|
+
|
|
108
|
+
- @forge/cli-shared@5.4.0-next.1
|
|
109
|
+
- @forge/bundler@4.17.6-next.1
|
|
110
|
+
|
|
111
|
+
## 5.4.0-next.0
|
|
112
|
+
|
|
113
|
+
### Minor Changes
|
|
114
|
+
|
|
115
|
+
- 41ba7c6: Removing Cloudflare enable FF and ngrok tunnel implementation
|
|
116
|
+
|
|
117
|
+
### Patch Changes
|
|
118
|
+
|
|
119
|
+
- Updated dependencies [41ba7c6]
|
|
120
|
+
- @forge/cli-shared@5.4.0-next.0
|
|
121
|
+
- @forge/bundler@4.17.6-next.0
|
|
122
|
+
|
|
123
|
+
## 5.3.4
|
|
124
|
+
|
|
125
|
+
### Patch Changes
|
|
126
|
+
|
|
127
|
+
- c9077a2: Rename function getEnvironment to getEnvironmentConfig
|
|
128
|
+
- Updated dependencies [69aafa2]
|
|
129
|
+
- Updated dependencies [c9077a2]
|
|
130
|
+
- Updated dependencies [07355ac]
|
|
131
|
+
- @forge/runtime@5.10.1
|
|
132
|
+
- @forge/cli-shared@5.3.2
|
|
133
|
+
- @forge/bundler@4.17.5
|
|
134
|
+
|
|
3
135
|
## 5.3.4-next.3
|
|
4
136
|
|
|
5
137
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start-tunnel-command.d.ts","sourceRoot":"","sources":["../../src/command/start-tunnel-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,EAAyB,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAChH,OAAO,EAAE,SAAS,EAAqB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"start-tunnel-command.d.ts","sourceRoot":"","sources":["../../src/command/start-tunnel-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,EAAyB,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAChH,OAAO,EAAE,SAAS,EAAqB,MAAM,gBAAgB,CAAC;AAI9D,OAAO,EACL,iBAAiB,EAKlB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAsC,iBAAiB,EAAE,MAAM,UAAU,CAAC;AACjF,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACzE,MAAM,WAAW,kBAAkB;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1C;AAED,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,iBAAiB,EAAE,CAAC;IAChC,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,eAAe,CAAC,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1F;AAED,qBAAa,kBAAkB;IAK3B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAX7B,OAAO,CAAC,aAAa,CAAmE;IACxF,OAAO,CAAC,iBAAiB,CAAgC;gBAGtC,YAAY,EAAE,iBAAiB,EAC/B,SAAS,EAAE,iBAAiB,EAC5B,aAAa,EAAE,mBAAmB,EAClC,YAAY,EAAE,qBAAqB,EACnC,YAAY,EAAE,qBAAqB,EACnC,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU;IAGzC,OAAO,CAAC,YAAY,CAUlB;IAEF,OAAO,CAAC,qBAAqB,CAuB3B;IAEF,OAAO,CAAC,gCAAgC,CAmCtC;IAEW,OAAO,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAwD9E"}
|
|
@@ -5,6 +5,7 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const cli_shared_1 = require("@forge/cli-shared");
|
|
6
6
|
const runtime_1 = require("@forge/runtime");
|
|
7
7
|
const node_cache_1 = tslib_1.__importDefault(require("node-cache"));
|
|
8
|
+
const portfinder_1 = require("portfinder");
|
|
8
9
|
const servers_1 = require("../servers");
|
|
9
10
|
const index_1 = require("../index");
|
|
10
11
|
class StartTunnelCommand {
|
|
@@ -39,13 +40,12 @@ class StartTunnelCommand {
|
|
|
39
40
|
this.cspReporterServer?.stop()
|
|
40
41
|
]);
|
|
41
42
|
};
|
|
42
|
-
startFaaSTunnelServer = async ({ port,
|
|
43
|
+
startFaaSTunnelServer = async ({ port, appId, environmentKey }) => {
|
|
43
44
|
const { permissions = {}, remotes = [] } = await this.configFile.readConfig();
|
|
44
45
|
const serverInfo = await this.devServer.start(port, permissions, remotes);
|
|
45
46
|
const { id, token, url } = await this.tunnelClient.setupTunnel(appId, environmentKey);
|
|
46
47
|
const faasTunnelUrl = await this.tunnelFactory.establishTunnel({
|
|
47
48
|
port: serverInfo.port,
|
|
48
|
-
tunnelConfigPath,
|
|
49
49
|
id,
|
|
50
50
|
token,
|
|
51
51
|
tunnelUrl: url
|
|
@@ -58,7 +58,8 @@ class StartTunnelCommand {
|
|
|
58
58
|
startResourceBasedTunnelsServers = async (resourceDetails, options) => {
|
|
59
59
|
const portMap = options.resourcePortMap ?? JSON.parse(process.env.RESOURCE_PORT_MAP ?? '{}');
|
|
60
60
|
const { permissions = {}, remotes = [] } = await this.configFile.readConfig();
|
|
61
|
-
const
|
|
61
|
+
const availablePort = await (0, portfinder_1.getPortPromise)({ port: 4000 });
|
|
62
|
+
const cspReporterPort = process.env.CSP_REPORTER_PORT ? parseInt(process.env.CSP_REPORTER_PORT, 10) : availablePort;
|
|
62
63
|
if (resourceDetails.length === 0)
|
|
63
64
|
return [];
|
|
64
65
|
this.cspReporterServer = new servers_1.CspReporterServer(cspReporterPort, this.logger, new node_cache_1.default());
|
|
@@ -86,7 +87,6 @@ class StartTunnelCommand {
|
|
|
86
87
|
try {
|
|
87
88
|
const faasTunnelServer = await this.startFaaSTunnelServer({
|
|
88
89
|
port,
|
|
89
|
-
tunnelConfigPath: options.ngrokConfig,
|
|
90
90
|
appId,
|
|
91
91
|
environmentKey
|
|
92
92
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csp-reporter-server.d.ts","sourceRoot":"","sources":["../../src/servers/csp-reporter-server.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,OAAO,EAAqB,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"csp-reporter-server.d.ts","sourceRoot":"","sources":["../../src/servers/csp-reporter-server.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,OAAO,EAAqB,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAmB,MAAM,mBAAmB,CAAC;AAE5D,OAAO,SAAS,MAAM,YAAY,CAAC;AAYnC,qBAAa,iBAAiB;IAM1B,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,KAAK;IAPxB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAU;IAC9B,OAAO,CAAC,MAAM,CAAqB;IACnC,OAAO,CAAC,MAAM,CAAC,cAAc,CAAM;gBAGhB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,SAAS;IAwBnC,MAAM,IAAI,OAAO;IAIX,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAkBtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAK5B"}
|
|
@@ -36,7 +36,15 @@ class CspReporterServer {
|
|
|
36
36
|
async start() {
|
|
37
37
|
return new Promise((resolve, reject) => {
|
|
38
38
|
this.server = this.app.listen(this.port, resolve);
|
|
39
|
-
this.server.on('error',
|
|
39
|
+
this.server.on('error', (err) => {
|
|
40
|
+
const error = err;
|
|
41
|
+
if (error.code === 'EADDRINUSE') {
|
|
42
|
+
reject(new cli_shared_1.UserError(`Port ${this.port} is already in use. Please select a different port by setting the CSP_REPORTER_PORT environment variable`));
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
reject(err);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
40
48
|
});
|
|
41
49
|
}
|
|
42
50
|
async stop() {
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
import { URL } from 'url';
|
|
3
|
-
import { BaseError,
|
|
4
|
-
export declare type NgrokTunnelConfig = {
|
|
5
|
-
tunnelConfigPath: string | undefined;
|
|
6
|
-
};
|
|
3
|
+
import { BaseError, Logger } from '@forge/cli-shared';
|
|
7
4
|
export declare type CloudflareTunnelConfig = {
|
|
8
5
|
token: string | null | undefined;
|
|
9
6
|
id: string | null | undefined;
|
|
@@ -11,27 +8,13 @@ export declare type CloudflareTunnelConfig = {
|
|
|
11
8
|
};
|
|
12
9
|
export declare type TunnelConfig = {
|
|
13
10
|
port: number;
|
|
14
|
-
} &
|
|
11
|
+
} & CloudflareTunnelConfig;
|
|
15
12
|
export interface CreateTunnelService {
|
|
16
|
-
establishTunnel({ port,
|
|
13
|
+
establishTunnel({ port, token, id, tunnelUrl }: TunnelConfig): Promise<URL>;
|
|
17
14
|
closeTunnel(): Promise<void>;
|
|
18
15
|
}
|
|
19
|
-
export declare const USER_NGROK_ERRORS: string[];
|
|
20
|
-
export declare class NgrokError extends BaseError {
|
|
21
|
-
constructor(message?: string);
|
|
22
|
-
isUserError(): boolean;
|
|
23
|
-
}
|
|
24
16
|
export declare class CloudflareError extends BaseError {
|
|
25
17
|
}
|
|
26
|
-
export declare class TunnelServiceFacade implements CreateTunnelService {
|
|
27
|
-
private readonly featureFlagService;
|
|
28
|
-
private readonly logger;
|
|
29
|
-
private instance;
|
|
30
|
-
constructor(featureFlagService: FeatureFlagService, logger: Logger);
|
|
31
|
-
private getInstance;
|
|
32
|
-
establishTunnel({ port, tunnelConfigPath, id, token, tunnelUrl }: TunnelConfig): Promise<URL>;
|
|
33
|
-
closeTunnel(): Promise<void>;
|
|
34
|
-
}
|
|
35
18
|
export declare class CloudflareCreateTunnelService implements CreateTunnelService {
|
|
36
19
|
private readonly logger;
|
|
37
20
|
private stopFunction;
|
|
@@ -39,11 +22,4 @@ export declare class CloudflareCreateTunnelService implements CreateTunnelServic
|
|
|
39
22
|
establishTunnel({ port, id, token, tunnelUrl }: TunnelConfig): Promise<URL>;
|
|
40
23
|
closeTunnel(): Promise<void>;
|
|
41
24
|
}
|
|
42
|
-
export declare class NgrokCreateTunnelService implements CreateTunnelService {
|
|
43
|
-
private readonly logger;
|
|
44
|
-
private endpoint;
|
|
45
|
-
constructor(logger: Logger);
|
|
46
|
-
establishTunnel({ port, tunnelConfigPath }: TunnelConfig): Promise<URL>;
|
|
47
|
-
closeTunnel(): Promise<void>;
|
|
48
|
-
}
|
|
49
25
|
//# sourceMappingURL=create-tunnel-service.d.ts.map
|
|
@@ -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":";AACA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,OAAO,EAAE,SAAS,EAAE,MAAM,EAAQ,MAAM,mBAAmB,CAAC;AAE5D,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;IAE9B,eAAe,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC;IAwB3E,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;CAQ1C"}
|
|
@@ -1,67 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const ngrok = tslib_1.__importStar(require("ngrok"));
|
|
3
|
+
exports.CloudflareCreateTunnelService = exports.CloudflareError = void 0;
|
|
6
4
|
const cloudflared_1 = require("cloudflared");
|
|
7
5
|
const url_1 = require("url");
|
|
8
6
|
const cli_shared_1 = require("@forge/cli-shared");
|
|
9
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
10
|
-
exports.USER_NGROK_ERRORS = [
|
|
11
|
-
'ERR_NGROK_105',
|
|
12
|
-
'ERR_NGROK_108',
|
|
13
|
-
'ERR_NGROK_120',
|
|
14
|
-
'ERR_NGROK_714',
|
|
15
|
-
'ERR_NGROK_715',
|
|
16
|
-
'ERR_NGROK_718',
|
|
17
|
-
'ERR_NGROK_720',
|
|
18
|
-
'ERR_NGROK_725',
|
|
19
|
-
'ERR_NGROK_726',
|
|
20
|
-
'ERR_NGROK_727',
|
|
21
|
-
'ERR_NGROK_728',
|
|
22
|
-
'ERR_NGROK_734',
|
|
23
|
-
'ERR_NGROK_1226',
|
|
24
|
-
'ERR_NGROK_3208',
|
|
25
|
-
'no such file or directory',
|
|
26
|
-
'The system cannot find the file specified',
|
|
27
|
-
'context canceled'
|
|
28
|
-
];
|
|
29
|
-
class NgrokError extends cli_shared_1.BaseError {
|
|
30
|
-
constructor(message) {
|
|
31
|
-
super(undefined, cli_shared_1.Text.tunnel.error.ngrok(message));
|
|
32
|
-
}
|
|
33
|
-
isUserError() {
|
|
34
|
-
return exports.USER_NGROK_ERRORS.some((err) => this.message.includes(err));
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
exports.NgrokError = NgrokError;
|
|
38
7
|
class CloudflareError extends cli_shared_1.BaseError {
|
|
39
8
|
}
|
|
40
9
|
exports.CloudflareError = CloudflareError;
|
|
41
|
-
class TunnelServiceFacade {
|
|
42
|
-
featureFlagService;
|
|
43
|
-
logger;
|
|
44
|
-
instance;
|
|
45
|
-
constructor(featureFlagService, logger) {
|
|
46
|
-
this.featureFlagService = featureFlagService;
|
|
47
|
-
this.logger = logger;
|
|
48
|
-
}
|
|
49
|
-
async getInstance() {
|
|
50
|
-
if (!this.instance) {
|
|
51
|
-
this.instance = (await this.featureFlagService.isCloudflareTunnelEnabled())
|
|
52
|
-
? new CloudflareCreateTunnelService(this.logger)
|
|
53
|
-
: new NgrokCreateTunnelService(this.logger);
|
|
54
|
-
}
|
|
55
|
-
return this.instance;
|
|
56
|
-
}
|
|
57
|
-
async establishTunnel({ port, tunnelConfigPath, id, token, tunnelUrl }) {
|
|
58
|
-
return (await this.getInstance()).establishTunnel({ port, tunnelConfigPath, id, token, tunnelUrl });
|
|
59
|
-
}
|
|
60
|
-
async closeTunnel() {
|
|
61
|
-
return (await this.getInstance()).closeTunnel();
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
exports.TunnelServiceFacade = TunnelServiceFacade;
|
|
65
10
|
class CloudflareCreateTunnelService {
|
|
66
11
|
logger;
|
|
67
12
|
stopFunction;
|
|
@@ -96,51 +41,3 @@ class CloudflareCreateTunnelService {
|
|
|
96
41
|
}
|
|
97
42
|
}
|
|
98
43
|
exports.CloudflareCreateTunnelService = CloudflareCreateTunnelService;
|
|
99
|
-
class NgrokCreateTunnelService {
|
|
100
|
-
logger;
|
|
101
|
-
endpoint;
|
|
102
|
-
constructor(logger) {
|
|
103
|
-
this.logger = logger;
|
|
104
|
-
}
|
|
105
|
-
async establishTunnel({ port, tunnelConfigPath }) {
|
|
106
|
-
const defaultConfigPath = path_1.default.join(__dirname, '..', '..', 'config', 'ngrok.yml');
|
|
107
|
-
let ngrokErrorMessage = undefined;
|
|
108
|
-
try {
|
|
109
|
-
const options = {
|
|
110
|
-
addr: port,
|
|
111
|
-
configPath: tunnelConfigPath ?? defaultConfigPath,
|
|
112
|
-
onStatusChange: (status) => {
|
|
113
|
-
this.logger.debug(cli_shared_1.Text.tunnel.tunnelStatusChange(status));
|
|
114
|
-
},
|
|
115
|
-
onLogEvent: (data) => {
|
|
116
|
-
const errorMatch = /err=(".+")$/m.exec(data);
|
|
117
|
-
if (errorMatch && !data.includes('obj=updater')) {
|
|
118
|
-
ngrokErrorMessage = errorMatch[1];
|
|
119
|
-
try {
|
|
120
|
-
ngrokErrorMessage = JSON.parse(ngrokErrorMessage);
|
|
121
|
-
}
|
|
122
|
-
catch { }
|
|
123
|
-
}
|
|
124
|
-
this.logger.debug(data);
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
this.endpoint = await ngrok.connect(options);
|
|
128
|
-
this.logger.debug(cli_shared_1.Text.tunnel.startedTunnel(this.endpoint));
|
|
129
|
-
return new url_1.URL(this.endpoint);
|
|
130
|
-
}
|
|
131
|
-
catch (e) {
|
|
132
|
-
throw new NgrokError(ngrokErrorMessage);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
async closeTunnel() {
|
|
136
|
-
if (this.endpoint) {
|
|
137
|
-
try {
|
|
138
|
-
await ngrok.disconnect();
|
|
139
|
-
await ngrok.kill();
|
|
140
|
-
}
|
|
141
|
-
catch { }
|
|
142
|
-
this.endpoint = undefined;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
exports.NgrokCreateTunnelService = NgrokCreateTunnelService;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { TunnelClient, TunnelDefinitions, TunnelSetup } from '../graphql';
|
|
2
|
-
import { FeatureFlagService } from '@forge/cli-shared';
|
|
3
2
|
export interface RegisterTunnelService {
|
|
4
3
|
setupTunnel(appId: string, environmentKey: string): Promise<TunnelSetup>;
|
|
5
4
|
registerTunnels(appId: string, environmentKey: string, tunnelDefinitions: TunnelDefinitions): Promise<void>;
|
|
@@ -7,8 +6,7 @@ export interface RegisterTunnelService {
|
|
|
7
6
|
}
|
|
8
7
|
export declare class RegisterTunnelServiceImpl implements RegisterTunnelService {
|
|
9
8
|
private readonly tunnelClient;
|
|
10
|
-
|
|
11
|
-
constructor(tunnelClient: TunnelClient, featureFlagService: FeatureFlagService);
|
|
9
|
+
constructor(tunnelClient: TunnelClient);
|
|
12
10
|
private keepAliveHandler;
|
|
13
11
|
private keepAliveActive;
|
|
14
12
|
registerTunnels(appId: string, environmentKey: string, tunnelDefinitions: TunnelDefinitions): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register-tunnel-service.d.ts","sourceRoot":"","sources":["../../src/services/register-tunnel-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"register-tunnel-service.d.ts","sourceRoot":"","sources":["../../src/services/register-tunnel-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAI1E,MAAM,WAAW,qBAAqB;IACpC,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IACzE,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,iBAAiB,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5G,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACzE;AAED,qBAAa,yBAA0B,YAAW,qBAAqB;IACzD,OAAO,CAAC,QAAQ,CAAC,YAAY;gBAAZ,YAAY,EAAE,YAAY;IAIvD,OAAO,CAAC,gBAAgB,CAA6B;IACrD,OAAO,CAAC,eAAe,CAAU;IAEpB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,iBAAiB,EAAE,iBAAiB;IAQ3F,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;IAIjD,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;YAQtD,gBAAgB;IAoB9B,OAAO,CAAC,MAAM;CAaf"}
|
|
@@ -4,10 +4,8 @@ exports.RegisterTunnelServiceImpl = void 0;
|
|
|
4
4
|
const ONE_DAY = 1000 * 60 * 60 * 24;
|
|
5
5
|
class RegisterTunnelServiceImpl {
|
|
6
6
|
tunnelClient;
|
|
7
|
-
|
|
8
|
-
constructor(tunnelClient, featureFlagService) {
|
|
7
|
+
constructor(tunnelClient) {
|
|
9
8
|
this.tunnelClient = tunnelClient;
|
|
10
|
-
this.featureFlagService = featureFlagService;
|
|
11
9
|
this.keepAliveActive = true;
|
|
12
10
|
}
|
|
13
11
|
keepAliveHandler;
|
|
@@ -20,14 +18,7 @@ class RegisterTunnelServiceImpl {
|
|
|
20
18
|
await this.keepTunnelsAlive(appId, environmentKey, tunnelDefinitions, expiry);
|
|
21
19
|
}
|
|
22
20
|
async setupTunnel(appId, environmentKey) {
|
|
23
|
-
|
|
24
|
-
return await this.tunnelClient.setupTunnel(appId, environmentKey);
|
|
25
|
-
}
|
|
26
|
-
return {
|
|
27
|
-
token: undefined,
|
|
28
|
-
id: undefined,
|
|
29
|
-
url: undefined
|
|
30
|
-
};
|
|
21
|
+
return await this.tunnelClient.setupTunnel(appId, environmentKey);
|
|
31
22
|
}
|
|
32
23
|
async unregisterTunnels(appId, environmentKey) {
|
|
33
24
|
if (this.keepAliveHandler) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forge/tunnel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.4.0-experimental-9fa730f",
|
|
4
4
|
"description": "Tunnel functionality for Forge CLI",
|
|
5
5
|
"author": "Atlassian",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -11,17 +11,17 @@
|
|
|
11
11
|
"compile": "tsc -b -v"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@forge/bundler": "4.
|
|
15
|
-
"@forge/cli-shared": "5.
|
|
16
|
-
"@forge/csp": "3.
|
|
17
|
-
"@forge/runtime": "5.10.1
|
|
14
|
+
"@forge/bundler": "4.18.0-experimental-9fa730f",
|
|
15
|
+
"@forge/cli-shared": "5.4.0",
|
|
16
|
+
"@forge/csp": "3.3.0",
|
|
17
|
+
"@forge/runtime": "5.10.1",
|
|
18
18
|
"chokidar": "^3.6.0",
|
|
19
19
|
"cloudflared": "^0.5.2",
|
|
20
20
|
"express": "^4.18.3",
|
|
21
21
|
"express-intercept": "^1.1.0",
|
|
22
22
|
"http-proxy-middleware": "^2.0.6",
|
|
23
|
-
"ngrok": "^5.0.0-beta.2",
|
|
24
23
|
"node-cache": "^5.1.2",
|
|
24
|
+
"portfinder": "^1.0.32",
|
|
25
25
|
"tmp": "^0.2.3",
|
|
26
26
|
"tslib": "^2.6.2",
|
|
27
27
|
"uuid": "^9.0.1",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@atlassian/xen-test-util": "^4.2.0",
|
|
32
|
-
"@forge/manifest": "7.
|
|
32
|
+
"@forge/manifest": "7.6.0",
|
|
33
33
|
"@types/express": "^4.17.21",
|
|
34
34
|
"@types/jest": "^29.5.12",
|
|
35
35
|
"@types/node": "14.18.63",
|