Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@forge/bridge

Package Overview
Dependencies
Maintainers
2
Versions
140
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@forge/bridge - npm Package Compare versions

Comparing version 2.5.6 to 2.6.0-next.0

6

CHANGELOG.md
# @forge/bridge
## 2.6.0-next.0
### Minor Changes
- 139a2cc: Fix support for uploading attachments via product fetch APIs
## 2.5.6

@@ -4,0 +10,0 @@

36

out/fetch/fetch.js

@@ -5,9 +5,34 @@ "use strict";

const tslib_1 = require("tslib");
const toBase64 = (file) => new Promise((resolve, reject) => {
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = () => resolve(reader.result);
reader.onerror = (error) => reject(error);
});
const parseFormData = (form) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
const parsed = {};
for (const [key, value] of form.entries()) {
if (key === 'file') {
const fileName = value.name;
const fileType = value.type;
parsed['file'] = yield toBase64(value);
parsed['__fileName'] = fileName;
parsed['__fileType'] = fileType;
}
else {
parsed[key] = value;
}
}
return JSON.stringify(parsed);
});
const parseBodyAndHeaders = (init) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
const req = new Request('', { body: init === null || init === void 0 ? void 0 : init.body, method: init === null || init === void 0 ? void 0 : init.method, headers: init === null || init === void 0 ? void 0 : init.headers });
const isFormData = (init === null || init === void 0 ? void 0 : init.body) instanceof FormData ? true : false;
const requestBody = isFormData ? yield parseFormData(init === null || init === void 0 ? void 0 : init.body) : init === null || init === void 0 ? void 0 : init.body;
const req = new Request('', { body: requestBody, method: init === null || init === void 0 ? void 0 : init.method, headers: init === null || init === void 0 ? void 0 : init.headers });
const headers = Object.fromEntries(req.headers.entries());
const body = req.method !== 'GET' ? yield req.text() : null;
const headers = Object.fromEntries(req.headers.entries());
return {
body,
headers: new Headers(headers)
headers: new Headers(headers),
isMultipartFormData: isFormData
};

@@ -17,3 +42,3 @@ });

const fetch = (product, restPath, init) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
const { body: requestBody, headers: requestHeaders } = yield parseBodyAndHeaders(init);
const { body: requestBody, headers: requestHeaders, isMultipartFormData } = yield parseBodyAndHeaders(init);
if (!requestHeaders.has('X-Atlassian-Token')) {

@@ -25,3 +50,4 @@ requestHeaders.set('X-Atlassian-Token', 'no-check');

restPath,
fetchRequestInit: Object.assign(Object.assign({}, init), { body: requestBody, headers: [...requestHeaders.entries()] })
fetchRequestInit: Object.assign(Object.assign({}, init), { body: requestBody, headers: [...requestHeaders.entries()] }),
isMultipartFormData
};

@@ -28,0 +54,0 @@ const { body, headers, statusText, status } = yield callBridge('fetchProduct', fetchPayload);

2

package.json
{
"name": "@forge/bridge",
"version": "2.5.6",
"version": "2.6.0-next.0",
"description": "Forge bridge API for custom UI apps",

@@ -5,0 +5,0 @@ "author": "Atlassian",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc