@forge/api 3.3.0 → 3.3.1-next.0

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,11 @@
1
1
  # @forge/api
2
2
 
3
+ ## 3.3.1-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - da345ba: Fix custom authentication header for first party api request
8
+
3
9
  ## 3.3.0
4
10
 
5
11
  ### Minor Changes
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/api/fetch.ts"],"names":[],"mappings":"AAEA,OAAc,EAAE,WAAW,EAAY,MAAM,YAAY,CAAC;AAS1D,OAAO,EAIL,QAAQ,EACR,WAAW,EAEZ,MAAM,IAAI,CAAC;AAKZ,aAAK,YAAY,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;AAC5C,aAAK,SAAS,GAAG,MAAM,GAAG,YAAY,GAAG,UAAU,GAAG,WAAW,CAAC;AAElE,aAAK,oBAAoB,GAAG,MAAM,CAAC;AACnC,aAAK,kBAAkB,GAAG,MAAM,CAAC;AAEjC,aAAK,SAAS,GAAG;IAAE,QAAQ,EAAE,YAAY,CAAC;IAAC,MAAM,EAAE,SAAS,CAAA;CAAE,CAAC;AAC/D,aAAK,qBAAqB,GAAG;IAAE,QAAQ,EAAE,oBAAoB,CAAC;IAAC,MAAM,EAAE,kBAAkB,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAS7G,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,GAAG,WAAW,CAkBzD;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,qBAAqB,GAAG,WAAW,CAcpE;AA+FD,eAAO,MAAM,aAAa,EAAE,CAAC,IAAI,CAAC,EAAE,WAAW,EAAE,aAAa,CAAC,EAAE,MAAM,KAAK,WAG1E,CAAC;AA2CH,wBAAgB,iBAAiB,IAAI,QAAQ,CAsB5C;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,GAAG,GAAG,QAAQ,CAEvD"}
1
+ {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/api/fetch.ts"],"names":[],"mappings":"AAEA,OAAc,EAAE,WAAW,EAAkC,MAAM,YAAY,CAAC;AAShF,OAAO,EAIL,QAAQ,EACR,WAAW,EAEZ,MAAM,IAAI,CAAC;AAKZ,aAAK,YAAY,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;AAC5C,aAAK,SAAS,GAAG,MAAM,GAAG,YAAY,GAAG,UAAU,GAAG,WAAW,CAAC;AAElE,aAAK,oBAAoB,GAAG,MAAM,CAAC;AACnC,aAAK,kBAAkB,GAAG,MAAM,CAAC;AAEjC,aAAK,SAAS,GAAG;IAAE,QAAQ,EAAE,YAAY,CAAC;IAAC,MAAM,EAAE,SAAS,CAAA;CAAE,CAAC;AAC/D,aAAK,qBAAqB,GAAG;IAAE,QAAQ,EAAE,oBAAoB,CAAC;IAAC,MAAM,EAAE,kBAAkB,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAS7G,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,GAAG,WAAW,CAqBzD;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,qBAAqB,GAAG,WAAW,CAcpE;AAyGD,eAAO,MAAM,aAAa,EAAE,CAAC,IAAI,CAAC,EAAE,WAAW,EAAE,aAAa,CAAC,EAAE,MAAM,KAAK,WAG1E,CAAC;AA2CH,wBAAgB,iBAAiB,IAAI,QAAQ,CAsB5C;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,GAAG,GAAG,QAAQ,CAEvD"}
package/out/api/fetch.js CHANGED
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getSandboxRuntimeAPI = exports.getNodeRuntimeAPI = exports.addMagicAgent = exports.fetchRemote = exports.fetchProduct = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
5
+ const node_fetch_1 = tslib_1.__importStar(require("node-fetch"));
6
6
  const _1 = require(".");
7
7
  const runtime_1 = require("./runtime");
8
8
  const polyfill_response_1 = require("./polyfill-response");
@@ -11,7 +11,9 @@ function fetchProduct(args) {
11
11
  return async (path, init) => {
12
12
  const url = productURL(args.remote, path);
13
13
  init = (0, exports.addMagicAgent)(init);
14
- init.headers = Object.assign(Object.assign({}, init.headers), { authorization: `Forge ${args.provider}` });
14
+ if (!hasAuthorizationHeader(init.headers)) {
15
+ init.headers = Object.assign(Object.assign({}, init.headers), { authorization: `Forge ${args.provider}` });
16
+ }
15
17
  const response = await (0, node_fetch_1.default)(url, init);
16
18
  handleProxyResponseErrors(response);
17
19
  return response;
@@ -56,6 +58,11 @@ const handleProxyResponseErrors = (response) => {
56
58
  throw new errors_1.ProxyRequestError(response.status, response.headers.get('forge-proxy-error'));
57
59
  }
58
60
  };
61
+ const hasAuthorizationHeader = (headersInit) => {
62
+ if (!headersInit)
63
+ return false;
64
+ return new node_fetch_1.Headers(headersInit).has('authorization');
65
+ };
59
66
  function productURL(remote, path) {
60
67
  if (!path.startsWith('/')) {
61
68
  path = '/' + path;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forge/api",
3
- "version": "3.3.0",
3
+ "version": "3.3.1-next.0",
4
4
  "description": "Forge API methods",
5
5
  "author": "Atlassian",
6
6
  "license": "UNLICENSED",