@forge/tunnel 1.5.0-next.23 → 1.5.0-next.27

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,5 +1,40 @@
1
1
  # @forge/tunnel
2
2
 
3
+ ## 1.5.0-next.27
4
+
5
+ ### Patch Changes
6
+
7
+ - @forge/cli-shared@2.2.0-next.22
8
+ - @forge/bundler@1.1.0-next.25
9
+
10
+ ## 1.5.0-next.26
11
+
12
+ ### Patch Changes
13
+
14
+ - @forge/cli-shared@2.2.0-next.21
15
+ - @forge/bundler@1.1.0-next.24
16
+
17
+ ## 1.5.0-next.25
18
+
19
+ ### Patch Changes
20
+
21
+ - @forge/cli-shared@2.2.0-next.20
22
+ - @forge/bundler@1.1.0-next.23
23
+
24
+ ## 1.5.0-next.24
25
+
26
+ ### Minor Changes
27
+
28
+ - 1c196ff: Add support for external fetch client to reference remote
29
+
30
+ ### Patch Changes
31
+
32
+ - Updated dependencies [1c196ff]
33
+ - @forge/csp@1.9.0-next.1
34
+ - @forge/runtime@1.12.0-next.7
35
+ - @forge/cli-shared@2.2.0-next.19
36
+ - @forge/bundler@1.1.0-next.22
37
+
3
38
  ## 1.5.0-next.23
4
39
 
5
40
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"start-tunnel-command.d.ts","sourceRoot":"","sources":["../../../src/tunnelling/command/start-tunnel-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,EAAQ,MAAM,mBAAmB,CAAC;AAChF,OAAO,EAAE,SAAS,EAAqB,MAAM,gBAAgB,CAAC;AAI9D,OAAO,EAAE,iBAAiB,EAA2C,MAAM,YAAY,CAAC;AACxF,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAsC,iBAAiB,EAAE,MAAM,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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,CAS3B;IAEF,OAAO,CAAC,0BAA0B,CAiChC;IAEW,OAAO,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAwC9E"}
@@ -44,7 +44,7 @@ class StartTunnelCommand {
44
44
  var _a, _b;
45
45
  const resourcePortMap = JSON.parse((_a = process.env.RESOURCE_PORT_MAP) !== null && _a !== void 0 ? _a : '{}');
46
46
  const resourceDetails = await this.configFile.getResources();
47
- const { permissions = {} } = await this.configFile.readConfig();
47
+ const { permissions = {}, remotes = [] } = await this.configFile.readConfig();
48
48
  const cspReporterPort = parseInt((_b = process.env.CSP_REPORTER_PORT) !== null && _b !== void 0 ? _b : '4000', 10);
49
49
  if (resourceDetails.length === 0)
50
50
  return [];
@@ -53,7 +53,8 @@ class StartTunnelCommand {
53
53
  return await Promise.all(resourceDetails.map(async (rd) => {
54
54
  const { key } = rd;
55
55
  const port = resourcePortMap[key];
56
- this.tunnelServers[key] = new servers_1.ResourceTunnelServer(Object.assign(Object.assign({}, rd), { port, logger: this.logger, cspReporterServerPort: cspReporterPort, permissions }));
56
+ this.tunnelServers[key] = new servers_1.ResourceTunnelServer(Object.assign(Object.assign({}, rd), { port, logger: this.logger, cspReporterServerPort: cspReporterPort, permissions,
57
+ remotes }));
57
58
  await this.tunnelServers[key].start();
58
59
  return {
59
60
  resourceKey: key,
@@ -1,11 +1,12 @@
1
1
  import { Resource, Logger } from '@forge/cli-shared';
2
2
  import { Express } from 'express';
3
- import type { Permissions } from '@forge/manifest';
3
+ import type { Permissions, Remotes } from '@forge/manifest';
4
4
  export interface ResourceTunnelServerArgs extends Resource {
5
5
  port: number;
6
6
  logger: Logger;
7
7
  permissions: Permissions;
8
8
  cspReporterServerPort: number;
9
+ remotes: Remotes;
9
10
  }
10
11
  export declare class ResourceTunnelServer {
11
12
  private readonly port;
@@ -17,8 +18,25 @@ export declare class ResourceTunnelServer {
17
18
  private readonly proxy;
18
19
  private socket;
19
20
  private cspReporterServerPort;
20
- constructor({ port, key, path, tunnel, permissions, logger, cspReporterServerPort }: ResourceTunnelServerArgs);
21
+ constructor({ port, key, path, tunnel, permissions, remotes, logger, cspReporterServerPort }: ResourceTunnelServerArgs);
21
22
  getApp(): Express;
23
+ static transformPermissionsWithRemotes(permissions: Permissions, remotes: Remotes): {
24
+ external: {
25
+ fetch: {
26
+ client: string[] | undefined;
27
+ backend?: import("@forge/manifest/out/schema/manifest").Backend | undefined;
28
+ };
29
+ fonts?: import("@forge/manifest/out/schema/manifest").Fonts | undefined;
30
+ frames?: import("@forge/manifest/out/schema/manifest").Frames | undefined;
31
+ navigation?: import("@forge/manifest/out/schema/manifest").Navigation | undefined;
32
+ images?: import("@forge/manifest/out/schema/manifest").Images | undefined;
33
+ media?: import("@forge/manifest/out/schema/manifest").Media | undefined;
34
+ scripts?: import("@forge/manifest/out/schema/manifest").Scripts1 | undefined;
35
+ styles?: import("@forge/manifest/out/schema/manifest").Styles1 | undefined;
36
+ };
37
+ scopes?: import("@forge/manifest/out/schema/manifest").Scopes | undefined;
38
+ content?: import("@forge/manifest/out/schema/manifest").Content1 | undefined;
39
+ };
22
40
  start(): Promise<void>;
23
41
  stop(): Promise<void>;
24
42
  private logFileServed;
@@ -1 +1 @@
1
- {"version":3,"file":"resource-tunnel-server.d.ts","sourceRoot":"","sources":["../../../src/tunnelling/servers/resource-tunnel-server.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAMR,MAAM,EAGP,MAAM,mBAAmB,CAAC;AAC3B,OAAgB,EAAE,OAAO,EAAqB,MAAM,SAA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7 +13,7 @@ var ConnectionErrorCode;
13
13
  })(ConnectionErrorCode || (ConnectionErrorCode = {}));
14
14
  const HOST = process.env.FORGE_DEV_TUNNEL ? 'localhost' : 'host.docker.internal';
15
15
  class ResourceTunnelServer {
16
- constructor({ port, key, path, tunnel, permissions, logger, cspReporterServerPort }) {
16
+ constructor({ port, key, path, tunnel, permissions, remotes, logger, cspReporterServerPort }) {
17
17
  this.getCspHeader = (existingCsp) => new csp_1.CSPInjectionService()
18
18
  .getInjectableCSP(existingCsp, cli_shared_1.getEnvironment(cli_shared_1.CDNEnvironments), `http://localhost:${this.cspReporterServerPort}`)
19
19
  .join('; ');
@@ -23,14 +23,14 @@ class ResourceTunnelServer {
23
23
  this.injectIframeResizerScript = (htmlContent) => new cli_shared_1.IframeResizerScriptService().injectIframeResizer(htmlContent, () => {
24
24
  throw new Error('Malformed HTML document');
25
25
  });
26
- this.getCustomUIResourceMiddleware = (permissions) => express_mung_1.write((body, _, __, res) => {
26
+ this.getCustomUIResourceMiddleware = (permissions, remotes) => express_mung_1.write((body, _, __, res) => {
27
27
  const contentType = res.getHeaders()['content-type'];
28
28
  if (!contentType.startsWith('text/html'))
29
29
  return body;
30
30
  res.removeHeader('content-length');
31
31
  const htmlContentWithIframeResizerScript = this.injectIframeResizerScript(body);
32
32
  const htmlContentWithBridgeScript = this.injectGlobalBridgeScript(htmlContentWithIframeResizerScript);
33
- const cspDetails = new csp_1.CSPProcessingService({ info: () => { } }).getCspDetails(htmlContentWithBridgeScript, permissions);
33
+ const cspDetails = new csp_1.CSPProcessingService({ info: () => { } }).getCspDetails(htmlContentWithBridgeScript, ResourceTunnelServer.transformPermissionsWithRemotes(permissions, remotes));
34
34
  res.setHeader('Content-Security-Policy', this.getCspHeader(cspDetails));
35
35
  return htmlContentWithBridgeScript;
36
36
  });
@@ -40,7 +40,7 @@ class ResourceTunnelServer {
40
40
  this.logger = logger;
41
41
  this.cspReporterServerPort = cspReporterServerPort;
42
42
  this.app = express_1.default();
43
- this.app.use(this.getCustomUIResourceMiddleware(permissions));
43
+ this.app.use(this.getCustomUIResourceMiddleware(permissions, remotes));
44
44
  if (tunnel) {
45
45
  const { port: tunnelPort } = tunnel;
46
46
  this.proxy = http_proxy_middleware_1.createProxyMiddleware({
@@ -76,6 +76,16 @@ class ResourceTunnelServer {
76
76
  getApp() {
77
77
  return this.app;
78
78
  }
79
+ static transformPermissionsWithRemotes(permissions, remotes) {
80
+ var _a, _b, _c, _d, _e;
81
+ const client = (_d = (_c = (_b = (_a = permissions.external) === null || _a === void 0 ? void 0 : _a.fetch) === null || _b === void 0 ? void 0 : _b.client) === null || _c === void 0 ? void 0 : _c.map((item) => {
82
+ var _a;
83
+ if (typeof item === 'string')
84
+ return item;
85
+ return (_a = remotes === null || remotes === void 0 ? void 0 : remotes.find((remote) => remote.key === item.remote)) === null || _a === void 0 ? void 0 : _a.baseUrl;
86
+ }).filter((item) => typeof item === 'string')) !== null && _d !== void 0 ? _d : undefined;
87
+ return Object.assign(Object.assign({}, permissions), { external: Object.assign(Object.assign({}, permissions.external), { fetch: Object.assign(Object.assign({}, (_e = permissions.external) === null || _e === void 0 ? void 0 : _e.fetch), { client }) }) });
88
+ }
79
89
  async start() {
80
90
  return new Promise((resolve) => {
81
91
  this.server = this.app.listen(this.port, resolve);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forge/tunnel",
3
- "version": "1.5.0-next.23",
3
+ "version": "1.5.0-next.27",
4
4
  "description": "Tunnel functionality for Forge CLI",
5
5
  "author": "Atlassian",
6
6
  "license": "UNLICENSED",
@@ -16,11 +16,11 @@
16
16
  "postbuild": "chmod +x out/*.js"
17
17
  },
18
18
  "dependencies": {
19
- "@forge/bundler": "1.1.0-next.21",
20
- "@forge/cli-shared": "2.2.0-next.18",
21
- "@forge/csp": "^1.8.1-next.0",
19
+ "@forge/bundler": "1.1.0-next.25",
20
+ "@forge/cli-shared": "2.2.0-next.22",
21
+ "@forge/csp": "^1.9.0-next.1",
22
22
  "@forge/isolated-vm": "3.3.10",
23
- "@forge/runtime": "1.12.0-next.6",
23
+ "@forge/runtime": "1.12.0-next.7",
24
24
  "express": "^4.17.1",
25
25
  "express-mung": "^0.5.1",
26
26
  "http-proxy-middleware": "^1.0.6",
@@ -31,7 +31,7 @@
31
31
  "uuid": "^3.4.0"
32
32
  },
33
33
  "devDependencies": {
34
- "@forge/manifest": "^2.6.0-next.17",
34
+ "@forge/manifest": "^3.0.0-next.21",
35
35
  "@types/express": "^4.17.2",
36
36
  "@types/express-mung": "^0.5.2",
37
37
  "@types/jest": "^26.0.0",