@forge/bundler 4.10.4-next.9 → 4.10.4

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,148 @@
1
1
  # @forge/bundler
2
2
 
3
+ ## 4.10.4
4
+
5
+ ### Patch Changes
6
+
7
+ - 88be9538: Use HTTP polyfill to call proxy
8
+ - 7ade714: Bumping dependencies via Renovate:
9
+
10
+ - @typescript-eslint/eslint-plugin
11
+ - @typescript-eslint/parser
12
+ - @typescript-eslint/typescript-estree
13
+
14
+ - 48a4ea4: Renovate
15
+ - 79b19f2: Bumping dependencies via Renovate:
16
+
17
+ - prettier
18
+
19
+ - 8105c45: Bumping dependencies via Renovate:
20
+
21
+ - @types/jest
22
+ - jest
23
+ - jest-environment-jsdom
24
+
25
+ - 4999c4b: Renovate
26
+ - 02ff3939d: Bumping dependencies via Renovate:
27
+
28
+ - @babel/core
29
+
30
+ - 508de66a4: Support static initialisation blocks
31
+ - Updated dependencies [88be9538]
32
+ - Updated dependencies [7ade714]
33
+ - Updated dependencies [801ea11]
34
+ - Updated dependencies [48a4ea4]
35
+ - Updated dependencies [07eb84d]
36
+ - Updated dependencies [8105c45]
37
+ - Updated dependencies [4999c4b]
38
+ - Updated dependencies [665f1b2]
39
+ - Updated dependencies [467d04a]
40
+ - Updated dependencies [94b724a]
41
+ - Updated dependencies [d672827]
42
+ - Updated dependencies [593cb3e]
43
+ - @forge/runtime@4.4.5
44
+ - @forge/api@2.18.3
45
+ - @forge/lint@3.6.3
46
+ - @forge/util@1.3.1
47
+ - @forge/cli-shared@3.17.0
48
+ - @forge/babel-plugin-transform-ui@1.1.5
49
+
50
+ ## 4.10.4-next.20
51
+
52
+ ### Patch Changes
53
+
54
+ - @forge/cli-shared@3.17.0-next.15
55
+ - @forge/lint@3.6.3-next.16
56
+
57
+ ## 4.10.4-next.19
58
+
59
+ ### Patch Changes
60
+
61
+ - @forge/cli-shared@3.17.0-next.14
62
+ - @forge/lint@3.6.3-next.15
63
+
64
+ ## 4.10.4-next.18
65
+
66
+ ### Patch Changes
67
+
68
+ - @forge/cli-shared@3.17.0-next.13
69
+ - @forge/lint@3.6.3-next.14
70
+
71
+ ## 4.10.4-next.17
72
+
73
+ ### Patch Changes
74
+
75
+ - @forge/cli-shared@3.17.0-next.12
76
+ - @forge/lint@3.6.3-next.13
77
+
78
+ ## 4.10.4-next.16
79
+
80
+ ### Patch Changes
81
+
82
+ - Updated dependencies [593cb3ea]
83
+ - @forge/cli-shared@3.17.0-next.11
84
+ - @forge/lint@3.6.3-next.12
85
+
86
+ ## 4.10.4-next.15
87
+
88
+ ### Patch Changes
89
+
90
+ - @forge/cli-shared@3.17.0-next.10
91
+ - @forge/lint@3.6.3-next.11
92
+
93
+ ## 4.10.4-next.14
94
+
95
+ ### Patch Changes
96
+
97
+ - 4999c4b: Renovate
98
+ - Updated dependencies [4999c4b]
99
+ - @forge/babel-plugin-transform-ui@1.1.5-next.0
100
+ - @forge/util@1.3.1-next.2
101
+ - @forge/api@2.18.3-next.4
102
+ - @forge/cli-shared@3.17.0-next.9
103
+ - @forge/runtime@4.4.5-next.4
104
+ - @forge/lint@3.6.3-next.10
105
+
106
+ ## 4.10.4-next.13
107
+
108
+ ### Patch Changes
109
+
110
+ - Updated dependencies [801ea11]
111
+ - @forge/util@1.3.1-next.1
112
+ - @forge/api@2.18.3-next.3
113
+ - @forge/cli-shared@3.17.0-next.8
114
+ - @forge/runtime@4.4.5-next.3
115
+ - @forge/lint@3.6.3-next.9
116
+
117
+ ## 4.10.4-next.12
118
+
119
+ ### Patch Changes
120
+
121
+ - Updated dependencies [94b724a]
122
+ - @forge/util@1.3.1-next.0
123
+ - @forge/api@2.18.3-next.2
124
+ - @forge/cli-shared@3.17.0-next.7
125
+ - @forge/runtime@4.4.5-next.2
126
+ - @forge/lint@3.6.3-next.8
127
+
128
+ ## 4.10.4-next.11
129
+
130
+ ### Patch Changes
131
+
132
+ - 48a4ea41: Renovate
133
+ - Updated dependencies [48a4ea41]
134
+ - @forge/cli-shared@3.17.0-next.6
135
+ - @forge/lint@3.6.3-next.7
136
+
137
+ ## 4.10.4-next.10
138
+
139
+ ### Patch Changes
140
+
141
+ - 88be9538: Use HTTP polyfill to call proxy
142
+ - Updated dependencies [88be9538]
143
+ - @forge/runtime@4.4.5-next.1
144
+ - @forge/api@2.18.3-next.1
145
+
3
146
  ## 4.10.4-next.9
4
147
 
5
148
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"http-node.d.ts","sourceRoot":"","sources":["../../src/stubs/http-node.ts"],"names":[],"mappings":"AAkEA,wBAAgB,YAAY,SAK3B;AAED,wBAAgB,YAAY,SAG3B"}
1
+ {"version":3,"file":"http-node.d.ts","sourceRoot":"","sources":["../../src/stubs/http-node.ts"],"names":[],"mappings":"AAqQA,wBAAgB,YAAY,SAG3B;AAED,wBAAgB,YAAY,SAG3B"}
@@ -1,37 +1,137 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.restoreHttps = exports.replaceHttps = void 0;
4
+ const http_1 = require("http");
5
+ const perf_hooks_1 = require("perf_hooks");
4
6
  const url_1 = require("url");
5
- const http_impl_1 = require("./http-impl");
7
+ const http_shared_1 = require("./http-shared");
8
+ const api_1 = require("@forge/api");
6
9
  const https = require('https');
10
+ const FORGE_PROXY_UPSTREAM_LATENCY_HEADER = 'forge-proxy-upstream-latency';
11
+ const FORGE_PROXY_RELATIVE_LOCATION_HEADER = 'forge-proxy-relative-location';
12
+ const REDIRECT_STATUS = new Set([300, 301, 302, 303, 307, 308]);
7
13
  const originalHttpsRequest = https.request;
8
14
  const originalHttpsGet = https.get;
9
15
  function parseArgs(args) {
10
16
  const result = {
11
17
  options: {}
12
18
  };
13
- if (args.length > 0 && (0, http_impl_1.isStringOrURL)(args[0])) {
14
- const url = (0, http_impl_1.isString)(args[0]) ? new url_1.URL(args[0]) : args[0];
19
+ if (args.length > 0 && (0, http_shared_1.isStringOrURL)(args[0])) {
20
+ const url = (0, http_shared_1.isString)(args[0]) ? new url_1.URL(args[0]) : args[0];
15
21
  result.options = (0, url_1.urlToHttpOptions)(url);
16
22
  args.shift();
17
23
  }
18
- if (args.length > 0 && (0, http_impl_1.isRequestOptions)(args[0])) {
24
+ if (args.length > 0 && (0, http_shared_1.isRequestOptions)(args[0])) {
19
25
  result.options = Object.assign(result.options, args[0]);
20
26
  args.shift();
21
27
  }
22
- if (args.length > 0 && (0, http_impl_1.isCallback)(args[0])) {
28
+ if (args.length > 0 && (0, http_shared_1.isCallback)(args[0])) {
23
29
  result.callback = args[0];
24
30
  args.shift();
25
31
  }
26
32
  return result;
27
33
  }
34
+ const AUTH_PROVIDERS = ['app', 'user', 'none'];
35
+ function isAuthProvider(provider) {
36
+ return AUTH_PROVIDERS.includes(provider);
37
+ }
38
+ const REMOTE_APIS = ['jira', 'confluence', 'stargate', 'bitbucket'];
39
+ function isRemoteAPI(remote) {
40
+ return REMOTE_APIS.includes(remote);
41
+ }
42
+ function getProxyPath(args) {
43
+ switch (args.type) {
44
+ case 'egress':
45
+ return '/egress';
46
+ case 'fpp':
47
+ return `/fpp/provider/${args.provider}/remote/${args.remote}`;
48
+ }
49
+ }
50
+ const providerToMetric = {
51
+ app: 'asApp',
52
+ user: 'asUser'
53
+ };
54
+ const remoteToMetric = {
55
+ jira: 'requestJira',
56
+ confluence: 'requestConfluence',
57
+ bitbucket: 'requestBitbucket',
58
+ stargate: 'requestAtlassian'
59
+ };
60
+ const METRICS_TAGS = { proxy: 'true' };
61
+ function getMetricsName(args) {
62
+ switch (args.type) {
63
+ case 'egress':
64
+ return 'api.fetch';
65
+ case 'fpp':
66
+ const { provider, remote } = args;
67
+ if (provider === 'none') {
68
+ return `api.${remoteToMetric[remote]}`;
69
+ }
70
+ return `api.${providerToMetric[provider]}.${remoteToMetric[remote]}`;
71
+ }
72
+ }
73
+ function getSingleString(values) {
74
+ if (typeof values === 'string') {
75
+ return values;
76
+ }
77
+ if (Array.isArray(values)) {
78
+ return values[0];
79
+ }
80
+ }
81
+ function getSingleHeader(response, header) {
82
+ return getSingleString(response.headers[header]);
83
+ }
28
84
  function request(...args) {
29
- var _a;
85
+ var _a, _b;
30
86
  const { options, callback } = parseArgs(args);
31
- if ((_a = options === null || options === void 0 ? void 0 : options.headers) === null || _a === void 0 ? void 0 : _a['Forge-Proxy-Authorization']) {
32
- return originalHttpsRequest(options, callback);
87
+ let proxyArgs = { type: 'egress' };
88
+ const host = (_a = options.host) !== null && _a !== void 0 ? _a : options.hostname;
89
+ if ((options === null || options === void 0 ? void 0 : options.agent) === 'FORGE_PRODUCT_REQUEST') {
90
+ delete options.agent;
91
+ if (host && isRemoteAPI(host)) {
92
+ const authorization = getSingleString((_b = options.headers) === null || _b === void 0 ? void 0 : _b.authorization);
93
+ if (authorization === null || authorization === void 0 ? void 0 : authorization.startsWith('Forge ')) {
94
+ const [, provider] = authorization.split(' ');
95
+ if (isAuthProvider(provider)) {
96
+ proxyArgs = { type: 'fpp', provider, remote: host };
97
+ }
98
+ }
99
+ }
100
+ }
101
+ const { metrics, proxy } = (0, api_1.getRuntime)();
102
+ const metricsName = getMetricsName(proxyArgs);
103
+ const headers = Object.assign(Object.assign({}, options.headers), { 'forge-proxy-authorization': `Bearer ${proxy.token}` });
104
+ if (proxy.host) {
105
+ headers['Host'] = proxy.host;
106
+ }
107
+ switch (proxyArgs.type) {
108
+ case 'egress':
109
+ headers['forge-proxy-target'] = (0, http_shared_1.formatUrl)(options);
110
+ break;
111
+ case 'fpp':
112
+ headers['forge-proxy-target'] = options.path;
113
+ break;
33
114
  }
34
- return new http_impl_1.Request(options, callback);
115
+ const proxyOptions = Object.assign(Object.assign(Object.assign({}, options), (0, url_1.urlToHttpOptions)(new url_1.URL(`${proxy.url}${getProxyPath(proxyArgs)}`))), { headers });
116
+ metrics.counter(metricsName, METRICS_TAGS).incr();
117
+ const originalRequest = proxyOptions.protocol === 'http:' ? http_1.request : originalHttpsRequest;
118
+ const requestStart = perf_hooks_1.performance.now();
119
+ return originalRequest(proxyOptions, (response) => {
120
+ const requestEnd = perf_hooks_1.performance.now();
121
+ metrics.timing(metricsName, METRICS_TAGS).set(requestEnd - requestStart);
122
+ const upstreamLatencyHeader = getSingleHeader(response, FORGE_PROXY_UPSTREAM_LATENCY_HEADER);
123
+ if (upstreamLatencyHeader !== undefined) {
124
+ const proxyUpstreamLatency = parseInt(upstreamLatencyHeader);
125
+ metrics.timing('proxy-success-overhead', METRICS_TAGS).set(requestEnd - requestStart - proxyUpstreamLatency);
126
+ }
127
+ if (response.statusCode && REDIRECT_STATUS.has(response.statusCode)) {
128
+ const relativeLocation = getSingleHeader(response, FORGE_PROXY_RELATIVE_LOCATION_HEADER);
129
+ if (relativeLocation) {
130
+ response.headers['location'] = `https://${host}${relativeLocation}`;
131
+ }
132
+ }
133
+ callback === null || callback === void 0 ? void 0 : callback(response);
134
+ });
35
135
  }
36
136
  function get(...args) {
37
137
  const { options, callback } = parseArgs(args);
@@ -45,7 +145,7 @@ function replaceHttps() {
45
145
  }
46
146
  exports.replaceHttps = replaceHttps;
47
147
  function restoreHttps() {
48
- https.request = originalHttpsGet;
148
+ https.request = originalHttpsRequest;
49
149
  https.get = originalHttpsGet;
50
150
  }
51
151
  exports.restoreHttps = restoreHttps;
@@ -1,24 +1,16 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
- /// <reference types="node" />
4
- import { IncomingMessage } from 'http';
5
- import { RequestOptions, AgentOptions } from 'https';
3
+ import { RequestOptions } from 'https';
6
4
  import { Writable } from 'readable-stream';
7
5
  import { URL } from 'url';
8
6
  import { FetchOptions } from '@forge/api';
9
- export interface ChainableOptions {
7
+ import { Callback } from './http-shared';
8
+ interface ChainableOptions {
10
9
  timeout?: number;
11
10
  headers: {
12
11
  [key: string]: string;
13
12
  };
14
13
  }
15
- export type Callback = (res: IncomingMessage) => void;
16
- export type Arg = RequestOptions | string | URL | Callback;
17
- export declare const isCallback: (options: Arg) => options is Callback;
18
- export declare const isString: (options: Arg) => options is string;
19
- export declare const isURL: (options: Arg) => options is URL;
20
- export declare const isStringOrURL: (options: Arg) => options is string | URL;
21
- export declare const isRequestOptions: (options: Arg) => options is RequestOptions;
22
14
  export declare class Request extends Writable {
23
15
  private reqBody;
24
16
  private chainableOptions;
@@ -27,7 +19,6 @@ export declare class Request extends Writable {
27
19
  setTimeout(value: number, callback?: () => void): Request;
28
20
  private fetch;
29
21
  _write(chunk: any, encoding: string, callback: (error?: Error | null) => void): void;
30
- static formatUrl(options: RequestOptions): string;
31
22
  static urlFromFetchArgs(options: RequestOptions | string | URL): string;
32
23
  static convertToForgeFetchArgs(options: RequestOptions | string | URL, chainableOptions: ChainableOptions): {
33
24
  url: string;
@@ -35,7 +26,5 @@ export declare class Request extends Writable {
35
26
  };
36
27
  abort(): void;
37
28
  }
38
- export declare class Agent {
39
- constructor(options: AgentOptions);
40
- }
41
- //# sourceMappingURL=http-impl.d.ts.map
29
+ export {};
30
+ //# sourceMappingURL=http-sandbox-impl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-sandbox-impl.d.ts","sourceRoot":"","sources":["../../src/stubs/http-sandbox-impl.ts"],"names":[],"mappings":";;AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAY,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,OAAO,EAAe,YAAY,EAAS,MAAM,YAAY,CAAC;AAE9D,OAAO,EAAE,QAAQ,EAA6C,MAAM,eAAe,CAAC;AAEpF,UAAU,gBAAgB;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE;QACP,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;KACvB,CAAC;CACH;AAED,qBAAa,OAAQ,SAAQ,QAAQ;IACnC,OAAO,CAAC,OAAO,CAAW;IAC1B,OAAO,CAAC,gBAAgB,CAAmB;gBAE/B,OAAO,EAAE,cAAc,GAAG,MAAM,GAAG,GAAG,EAAE,QAAQ,CAAC,EAAE,QAAQ;IAahE,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO;IAM/C,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO;IAQhE,OAAO,CAAC,KAAK;IAsBN,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,KAAK,IAAI,GAAG,IAAI;IAe3F,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,GAAG,GAAG,GAAG,MAAM;IAiBvE,MAAM,CAAC,uBAAuB,CAC5B,OAAO,EAAE,cAAc,GAAG,MAAM,GAAG,GAAG,EACtC,gBAAgB,EAAE,gBAAgB,GACjC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,YAAY,CAAA;KAAE;IAuBtC,KAAK;CAGN"}
@@ -1,71 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Agent = exports.Request = exports.isRequestOptions = exports.isStringOrURL = exports.isURL = exports.isString = exports.isCallback = void 0;
3
+ exports.Request = void 0;
4
4
  const readable_stream_1 = require("readable-stream");
5
5
  const api_1 = require("@forge/api");
6
- const HEADERS_DISCARD_DUPLICATES = new Set([
7
- 'age',
8
- 'authorization',
9
- 'content-length',
10
- 'content-type',
11
- 'etag',
12
- 'expires',
13
- 'from',
14
- 'host',
15
- 'if-modified-since',
16
- 'if-unmodified-since',
17
- 'last-modified',
18
- 'location',
19
- 'max-forwards',
20
- 'proxy-authorization',
21
- 'referer',
22
- 'retry-after',
23
- 'server',
24
- 'user-agent'
25
- ]);
26
- class Response extends readable_stream_1.Readable {
27
- constructor(content, response) {
28
- super();
29
- this.statusCode = response.status;
30
- this.statusMessage = response.statusText;
31
- this.headers = {};
32
- this.headersDistinct = {};
33
- const rawHeaders = response.headers.raw();
34
- for (const [name, values] of Object.entries(rawHeaders)) {
35
- if (name === 'content-encoding') {
36
- continue;
37
- }
38
- let value;
39
- if (HEADERS_DISCARD_DUPLICATES.has(name)) {
40
- value = values[0];
41
- }
42
- else if (name === 'set-cookie') {
43
- value = values;
44
- }
45
- else if (name === 'cookie') {
46
- value = values.join('; ');
47
- }
48
- else {
49
- value = values.join(', ');
50
- }
51
- this.headers[name] = value;
52
- this.headersDistinct[name] = values;
53
- }
54
- this._read = () => { };
55
- this.push(Buffer.from(content));
56
- this.push(null);
57
- }
58
- }
59
- const isCallback = (options) => typeof options === 'function';
60
- exports.isCallback = isCallback;
61
- const isString = (options) => typeof options === 'string';
62
- exports.isString = isString;
63
- const isURL = (options) => typeof options === 'object' && options.constructor.name === 'URL';
64
- exports.isURL = isURL;
65
- const isStringOrURL = (options) => (0, exports.isString)(options) || (0, exports.isURL)(options);
66
- exports.isStringOrURL = isStringOrURL;
67
- const isRequestOptions = (options) => !(0, exports.isStringOrURL)(options) && !(0, exports.isCallback)(options);
68
- exports.isRequestOptions = isRequestOptions;
6
+ const http_shared_1 = require("./http-shared");
69
7
  class Request extends readable_stream_1.Writable {
70
8
  constructor(options, callback) {
71
9
  super();
@@ -126,25 +64,16 @@ class Request extends readable_stream_1.Writable {
126
64
  callback(err);
127
65
  }
128
66
  }
129
- static formatUrl(options) {
130
- var _a, _b;
131
- const protocol = 'https:';
132
- const auth = options.auth ? `${options.auth}@` : '';
133
- const host = (_a = options.hostname) !== null && _a !== void 0 ? _a : options.host;
134
- const port = options.port ? `:${options.port}` : '';
135
- const path = (_b = options.path) !== null && _b !== void 0 ? _b : '/';
136
- return `${protocol}//${auth}${host}${port}${path}`;
137
- }
138
67
  static urlFromFetchArgs(options) {
139
- if ((0, exports.isString)(options)) {
68
+ if ((0, http_shared_1.isString)(options)) {
140
69
  return options;
141
70
  }
142
- else if ((0, exports.isURL)(options)) {
71
+ else if ((0, http_shared_1.isURL)(options)) {
143
72
  return options.toString();
144
73
  }
145
74
  else {
146
75
  try {
147
- return Request.formatUrl(options);
76
+ return (0, http_shared_1.formatUrl)(options);
148
77
  }
149
78
  catch (err) {
150
79
  console.error('Unable to make request with unrecognised URL options:', options);
@@ -154,7 +83,7 @@ class Request extends readable_stream_1.Writable {
154
83
  }
155
84
  static convertToForgeFetchArgs(options, chainableOptions) {
156
85
  const url = Request.urlFromFetchArgs(options);
157
- if ((0, exports.isStringOrURL)(options)) {
86
+ if ((0, http_shared_1.isStringOrURL)(options)) {
158
87
  return { url, init: chainableOptions };
159
88
  }
160
89
  else {
@@ -178,13 +107,56 @@ class Request extends readable_stream_1.Writable {
178
107
  }
179
108
  }
180
109
  exports.Request = Request;
181
- const NUM_SUPPORTED_AGENT_OPTIONS = 1;
182
- class Agent {
183
- constructor(options) {
184
- if (Object.keys(options).length > NUM_SUPPORTED_AGENT_OPTIONS) {
185
- console.warn("Forge only supports 'keepAlive' as an option to http.Agent");
110
+ const HEADERS_DISCARD_DUPLICATES = new Set([
111
+ 'age',
112
+ 'authorization',
113
+ 'content-length',
114
+ 'content-type',
115
+ 'etag',
116
+ 'expires',
117
+ 'from',
118
+ 'host',
119
+ 'if-modified-since',
120
+ 'if-unmodified-since',
121
+ 'last-modified',
122
+ 'location',
123
+ 'max-forwards',
124
+ 'proxy-authorization',
125
+ 'referer',
126
+ 'retry-after',
127
+ 'server',
128
+ 'user-agent'
129
+ ]);
130
+ class Response extends readable_stream_1.Readable {
131
+ constructor(content, response) {
132
+ super();
133
+ this.statusCode = response.status;
134
+ this.statusMessage = response.statusText;
135
+ this.headers = {};
136
+ this.headersDistinct = {};
137
+ const rawHeaders = response.headers.raw();
138
+ for (const [name, values] of Object.entries(rawHeaders)) {
139
+ if (name === 'content-encoding') {
140
+ continue;
141
+ }
142
+ let value;
143
+ if (HEADERS_DISCARD_DUPLICATES.has(name)) {
144
+ value = values[0];
145
+ }
146
+ else if (name === 'set-cookie') {
147
+ value = values;
148
+ }
149
+ else if (name === 'cookie') {
150
+ value = values.join('; ');
151
+ }
152
+ else {
153
+ value = values.join(', ');
154
+ }
155
+ this.headers[name] = value;
156
+ this.headersDistinct[name] = values;
186
157
  }
187
- return { keepAlive: options.keepAlive };
158
+ this._read = () => { };
159
+ this.push(Buffer.from(content));
160
+ this.push(null);
188
161
  }
189
162
  }
190
- exports.Agent = Agent;
@@ -1,2 +1,13 @@
1
- export {};
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ /// <reference types="node" />
4
+ import { AgentOptions, IncomingMessage } from 'http';
5
+ import { RequestOptions } from 'https';
6
+ import { URL } from 'url';
7
+ import { Request } from './http-sandbox-impl';
8
+ export declare function request(options: RequestOptions | string | URL, callback?: (res: IncomingMessage) => void): Request;
9
+ export declare function get(options: RequestOptions | string | URL, callback?: (res: IncomingMessage) => void): Request;
10
+ export declare class Agent {
11
+ constructor(options: AgentOptions);
12
+ }
2
13
  //# sourceMappingURL=http-sandbox.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"http-sandbox.d.ts","sourceRoot":"","sources":["../../src/stubs/http-sandbox.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"http-sandbox.d.ts","sourceRoot":"","sources":["../../src/stubs/http-sandbox.ts"],"names":[],"mappings":";;;AAAA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAG1B,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,wBAAgB,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,GAAG,GAAG,EAAE,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK,IAAI,GAAG,OAAO,CAElH;AAED,wBAAgB,GAAG,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,GAAG,GAAG,EAAE,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK,IAAI,GAAG,OAAO,CAO9G;AAID,qBAAa,KAAK;gBACJ,OAAO,EAAE,YAAY;CAOlC"}
@@ -1,17 +1,28 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const http_impl_1 = require("./http-impl");
4
- module.exports = {
5
- request: (options, callback) => {
6
- return new http_impl_1.Request(options, callback);
7
- },
8
- get: (options, callback) => {
9
- if ((0, http_impl_1.isRequestOptions)(options)) {
10
- options = Object.assign(Object.assign({}, options), { method: 'GET' });
3
+ exports.Agent = exports.get = exports.request = void 0;
4
+ const http_shared_1 = require("./http-shared");
5
+ const http_sandbox_impl_1 = require("./http-sandbox-impl");
6
+ function request(options, callback) {
7
+ return new http_sandbox_impl_1.Request(options, callback);
8
+ }
9
+ exports.request = request;
10
+ function get(options, callback) {
11
+ if ((0, http_shared_1.isRequestOptions)(options)) {
12
+ options = Object.assign(Object.assign({}, options), { method: 'GET' });
13
+ }
14
+ const result = new http_sandbox_impl_1.Request(options, callback);
15
+ result.end();
16
+ return result;
17
+ }
18
+ exports.get = get;
19
+ const NUM_SUPPORTED_AGENT_OPTIONS = 1;
20
+ class Agent {
21
+ constructor(options) {
22
+ if (Object.keys(options).length > NUM_SUPPORTED_AGENT_OPTIONS) {
23
+ console.warn("Forge only supports 'keepAlive' as an option to http.Agent");
11
24
  }
12
- const result = new http_impl_1.Request(options, callback);
13
- result.end();
14
- return result;
15
- },
16
- Agent: http_impl_1.Agent
17
- };
25
+ return { keepAlive: options.keepAlive };
26
+ }
27
+ }
28
+ exports.Agent = Agent;
@@ -0,0 +1,15 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ /// <reference types="node" />
4
+ import { IncomingMessage } from 'http';
5
+ import { RequestOptions } from 'https';
6
+ import { URL } from 'url';
7
+ export type Callback = (res: IncomingMessage) => void;
8
+ export type Arg = RequestOptions | string | URL | Callback;
9
+ export declare const isCallback: (options: Arg) => options is Callback;
10
+ export declare const isString: (options: Arg) => options is string;
11
+ export declare const isURL: (options: Arg) => options is URL;
12
+ export declare const isStringOrURL: (options: Arg) => options is string | URL;
13
+ export declare const isRequestOptions: (options: Arg) => options is RequestOptions;
14
+ export declare function formatUrl(options: RequestOptions): string;
15
+ //# sourceMappingURL=http-shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-shared.d.ts","sourceRoot":"","sources":["../../src/stubs/http-shared.ts"],"names":[],"mappings":";;;AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,MAAM,QAAQ,GAAG,CAAC,GAAG,EAAE,eAAe,KAAK,IAAI,CAAC;AAEtD,MAAM,MAAM,GAAG,GAAG,cAAc,GAAG,MAAM,GAAG,GAAG,GAAG,QAAQ,CAAC;AAE3D,eAAO,MAAM,UAAU,YAAa,GAAG,wBAAuD,CAAC;AAC/F,eAAO,MAAM,QAAQ,YAAa,GAAG,sBAAmD,CAAC;AACzF,eAAO,MAAM,KAAK,YAAa,GAAG,mBACiC,CAAC;AAEpE,eAAO,MAAM,aAAa,YAAa,GAAG,4BAAiE,CAAC;AAE5G,eAAO,MAAM,gBAAgB,YAAa,GAAG,8BACI,CAAC;AAElD,wBAAgB,SAAS,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,CAQzD"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatUrl = exports.isRequestOptions = exports.isStringOrURL = exports.isURL = exports.isString = exports.isCallback = void 0;
4
+ const isCallback = (options) => typeof options === 'function';
5
+ exports.isCallback = isCallback;
6
+ const isString = (options) => typeof options === 'string';
7
+ exports.isString = isString;
8
+ const isURL = (options) => typeof options === 'object' && options.constructor.name === 'URL';
9
+ exports.isURL = isURL;
10
+ const isStringOrURL = (options) => (0, exports.isString)(options) || (0, exports.isURL)(options);
11
+ exports.isStringOrURL = isStringOrURL;
12
+ const isRequestOptions = (options) => !(0, exports.isStringOrURL)(options) && !(0, exports.isCallback)(options);
13
+ exports.isRequestOptions = isRequestOptions;
14
+ function formatUrl(options) {
15
+ var _a, _b;
16
+ const protocol = 'https:';
17
+ const auth = options.auth ? `${options.auth}@` : '';
18
+ const host = (_a = options.hostname) !== null && _a !== void 0 ? _a : options.host;
19
+ const port = options.port ? `:${options.port}` : '';
20
+ const path = (_b = options.path) !== null && _b !== void 0 ? _b : '/';
21
+ return `${protocol}//${auth}${host}${port}${path}`;
22
+ }
23
+ exports.formatUrl = formatUrl;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forge/bundler",
3
- "version": "4.10.4-next.9",
3
+ "version": "4.10.4",
4
4
  "description": "Default bundler for Forge apps",
5
5
  "license": "UNLICENSED",
6
6
  "author": "Atlassian",
@@ -19,12 +19,12 @@
19
19
  "@babel/plugin-transform-optional-chaining": "^7.22.6",
20
20
  "@babel/plugin-transform-react-jsx": "^7.22.5",
21
21
  "@babel/preset-typescript": "^7.22.5",
22
- "@forge/api": "2.18.3-next.0",
23
- "@forge/babel-plugin-transform-ui": "1.1.4",
24
- "@forge/cli-shared": "3.17.0-next.5",
25
- "@forge/lint": "3.6.3-next.6",
26
- "@forge/runtime": "4.4.5-next.0",
27
- "@forge/util": "1.3.0",
22
+ "@forge/api": "2.18.3",
23
+ "@forge/babel-plugin-transform-ui": "1.1.5",
24
+ "@forge/cli-shared": "3.17.0",
25
+ "@forge/lint": "3.6.3",
26
+ "@forge/runtime": "4.4.5",
27
+ "@forge/util": "1.3.1",
28
28
  "assert": "^1.5.0",
29
29
  "babel-loader": "^8.3.0",
30
30
  "browserify-zlib": "^0.2.0",
@@ -50,12 +50,12 @@
50
50
  "typescript": "^4.9.5",
51
51
  "url": "^0.11.1",
52
52
  "util": "^0.12.5",
53
- "webpack": "5.88.1",
53
+ "webpack": "5.88.2",
54
54
  "webpack-bundle-analyzer": "^4.9.0",
55
55
  "whatwg-url": "^7.1.0"
56
56
  },
57
57
  "devDependencies": {
58
- "@atlassian/xen-test-util": "^1.16.0",
58
+ "@atlassian/xen-test-util": "^2.1.3",
59
59
  "@types/jest": "^29.5.3",
60
60
  "@types/node": "14.18.53",
61
61
  "@types/react": "^17.0.53",
@@ -1 +0,0 @@
1
- {"version":3,"file":"http-impl.d.ts","sourceRoot":"","sources":["../../src/stubs/http-impl.ts"],"names":[],"mappings":";;;AAMA,OAAO,EAAuB,eAAe,EAAE,MAAM,MAAM,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAErD,OAAO,EAAY,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC1B,OAAO,EAAe,YAAY,EAAS,MAAM,YAAY,CAAC;AAwE9D,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE;QACP,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;KACvB,CAAC;CACH;AAED,MAAM,MAAM,QAAQ,GAAG,CAAC,GAAG,EAAE,eAAe,KAAK,IAAI,CAAC;AAEtD,MAAM,MAAM,GAAG,GAAG,cAAc,GAAG,MAAM,GAAG,GAAG,GAAG,QAAQ,CAAC;AAE3D,eAAO,MAAM,UAAU,YAAa,GAAG,wBAAuD,CAAC;AAC/F,eAAO,MAAM,QAAQ,YAAa,GAAG,sBAAmD,CAAC;AACzF,eAAO,MAAM,KAAK,YAAa,GAAG,mBACiC,CAAC;AAEpE,eAAO,MAAM,aAAa,YAAa,GAAG,4BAAiE,CAAC;AAE5G,eAAO,MAAM,gBAAgB,YAAa,GAAG,8BACI,CAAC;AAElD,qBAAa,OAAQ,SAAQ,QAAQ;IACnC,OAAO,CAAC,OAAO,CAAW;IAC1B,OAAO,CAAC,gBAAgB,CAAmB;gBAE/B,OAAO,EAAE,cAAc,GAAG,MAAM,GAAG,GAAG,EAAE,QAAQ,CAAC,EAAE,QAAQ;IAahE,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO;IAM/C,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO;IAQhE,OAAO,CAAC,KAAK;IAsBN,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,KAAK,IAAI,GAAG,IAAI;IAe3F,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM;IAUjD,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,GAAG,GAAG,GAAG,MAAM;IAiBvE,MAAM,CAAC,uBAAuB,CAC5B,OAAO,EAAE,cAAc,GAAG,MAAM,GAAG,GAAG,EACtC,gBAAgB,EAAE,gBAAgB,GACjC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,YAAY,CAAA;KAAE;IAuBtC,KAAK;CAGN;AAID,qBAAa,KAAK;gBACJ,OAAO,EAAE,YAAY;CAOlC"}