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

@forge/bridge

Package Overview
Dependencies
Maintainers
8
Versions
139
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.1.1 to 2.1.2-next.0

6

CHANGELOG.md
# @forge/bridge
## 2.1.2-next.0
### Patch Changes
- 06edfce: Fix headers for some REST endpoints
## 2.1.1

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

2

out/bridge.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCallBridge = void 0;
exports.getCallBridge = function () {
exports.getCallBridge = () => {
return window.__bridge.callBridge;
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BridgeAPIError = void 0;
var tslib_1 = require("tslib");
var BridgeAPIError = (function (_super) {
tslib_1.__extends(BridgeAPIError, _super);
function BridgeAPIError() {
return _super !== null && _super.apply(this, arguments) || this;
}
return BridgeAPIError;
}(Error));
class BridgeAPIError extends Error {
}
exports.BridgeAPIError = BridgeAPIError;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.productFetchApi = void 0;
var tslib_1 = require("tslib");
var parseBodyAndHeaders = function (init) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
var req, body, _a, headers;
return tslib_1.__generator(this, function (_b) {
switch (_b.label) {
case 0:
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 });
if (!(req.method !== 'GET')) return [3, 2];
return [4, req.text()];
case 1:
_a = _b.sent();
return [3, 3];
case 2:
_a = null;
_b.label = 3;
case 3:
body = _a;
headers = Object.fromEntries(req.headers.entries());
return [2, {
body: body,
headers: headers
}];
const tslib_1 = require("tslib");
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 body = req.method !== 'GET' ? yield req.text() : null;
const headers = Object.fromEntries(req.headers.entries());
return {
body,
headers: new Headers(headers)
};
});
exports.productFetchApi = (callBridge) => {
const fetch = (product, restPath, init) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
const { body: requestBody, headers: requestHeaders } = yield parseBodyAndHeaders(init);
if (!requestHeaders.has('X-Atlassian-Token')) {
requestHeaders.set('X-Atlassian-Token', 'no-check');
}
const fetchPayload = {
product,
restPath,
fetchRequestInit: Object.assign(Object.assign({}, init), { body: requestBody, headers: [...requestHeaders.entries()] })
};
const { body, headers, statusText, status } = yield callBridge('fetchProduct', fetchPayload);
return new Response(body || null, { headers, status, statusText });
});
}); };
exports.productFetchApi = function (callBridge) {
var fetch = function (product, restPath, init) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
var fetchPayload, _a, _b, _c, body, headers, statusText, status;
return tslib_1.__generator(this, function (_d) {
switch (_d.label) {
case 0:
_a = {
product: product,
restPath: restPath
};
_b = [tslib_1.__assign({}, init)];
return [4, parseBodyAndHeaders(init)];
case 1:
fetchPayload = (_a.fetchRequestInit = tslib_1.__assign.apply(void 0, _b.concat([(_d.sent())])),
_a);
return [4, callBridge('fetchProduct', fetchPayload)];
case 2:
_c = _d.sent(), body = _c.body, headers = _c.headers, statusText = _c.statusText, status = _c.status;
return [2, new Response(body || null, { headers: headers, status: status, statusText: statusText })];
}
});
}); };
return {
requestConfluence: function (restPath, fetchOptions) {
return fetch('confluence', restPath, fetchOptions);
},
requestJira: function (restPath, fetchOptions) {
return fetch('jira', restPath, fetchOptions);
}
requestConfluence: (restPath, fetchOptions) => fetch('confluence', restPath, fetchOptions),
requestJira: (restPath, fetchOptions) => fetch('jira', restPath, fetchOptions)
};
};

@@ -5,4 +5,4 @@ "use strict";

exports.requestJira = exports.requestConfluence = void 0;
var bridge_1 = require("../bridge");
var fetch_1 = require("./fetch");
exports.requestConfluence = (_a = fetch_1.productFetchApi(bridge_1.getCallBridge()), _a.requestConfluence), exports.requestJira = _a.requestJira;
const bridge_1 = require("../bridge");
const fetch_1 = require("./fetch");
_a = fetch_1.productFetchApi(bridge_1.getCallBridge()), exports.requestConfluence = _a.requestConfluence, exports.requestJira = _a.requestJira;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./invoke"), exports);

@@ -5,0 +5,0 @@ tslib_1.__exportStar(require("./view"), exports);

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./invoke"), exports);
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.invoke = void 0;
var bridge_1 = require("../bridge");
var errors_1 = require("../errors");
var utils_1 = require("../utils");
var callBridge = bridge_1.getCallBridge();
var validatePayload = function (payload) {
const bridge_1 = require("../bridge");
const errors_1 = require("../errors");
const utils_1 = require("../utils");
const callBridge = bridge_1.getCallBridge();
const validatePayload = (payload) => {
if (!payload)
return;
if (Object.values(payload).some(function (val) { return typeof val === 'function'; })) {
if (Object.values(payload).some((val) => typeof val === 'function')) {
throw new errors_1.BridgeAPIError('Passing functions as part of the payload is not supported!');
}
};
var _invoke = function (functionKey, payload) {
const _invoke = (functionKey, payload) => {
if (typeof functionKey !== 'string') {

@@ -20,4 +20,4 @@ throw new errors_1.BridgeAPIError('functionKey must be a string!');

validatePayload(payload);
return callBridge('invoke', { functionKey: functionKey, payload: payload });
return callBridge('invoke', { functionKey, payload });
};
exports.invoke = utils_1.withRateLimiter(_invoke, 20, 2000, 'Resolver calls are rate limited at 20req/2s');
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./modal"), exports);
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Modal = void 0;
var tslib_1 = require("tslib");
var bridge_1 = require("../bridge");
var errors_1 = require("../errors");
var callBridge = bridge_1.getCallBridge();
var noop = function () { };
var Modal = (function () {
function Modal(opts) {
const tslib_1 = require("tslib");
const bridge_1 = require("../bridge");
const errors_1 = require("../errors");
const callBridge = bridge_1.getCallBridge();
const noop = () => { };
class Modal {
constructor(opts) {
this.resource = (opts === null || opts === void 0 ? void 0 : opts.resource) || null;

@@ -16,31 +16,21 @@ this.onClose = (opts === null || opts === void 0 ? void 0 : opts.onClose) || noop;

}
Modal.prototype.open = function () {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var success, err_1;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4, callBridge('openModal', {
resource: this.resource,
onClose: this.onClose,
size: this.size,
context: this.context
})];
case 1:
success = _a.sent();
if (success === false) {
throw new errors_1.BridgeAPIError('Unable to open modal.');
}
return [3, 3];
case 2:
err_1 = _a.sent();
throw new errors_1.BridgeAPIError('Unable to open modal.');
case 3: return [2];
open() {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
try {
const success = yield callBridge('openModal', {
resource: this.resource,
onClose: this.onClose,
size: this.size,
context: this.context
});
if (success === false) {
throw new errors_1.BridgeAPIError('Unable to open modal.');
}
});
}
catch (err) {
throw new errors_1.BridgeAPIError('Unable to open modal.');
}
});
};
return Modal;
}());
}
}
exports.Modal = Modal;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./router"), exports);
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.router = void 0;
var tslib_1 = require("tslib");
var bridge_1 = require("../bridge");
var callBridge = bridge_1.getCallBridge();
var navigate = function (url) { return tslib_1.__awaiter(void 0, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) {
return [2, callBridge('navigate', { url: url, type: 'same-tab' })];
}); }); };
var open = function (url) { return tslib_1.__awaiter(void 0, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) {
return [2, callBridge('navigate', { url: url, type: 'new-tab' })];
}); }); };
const tslib_1 = require("tslib");
const bridge_1 = require("../bridge");
const callBridge = bridge_1.getCallBridge();
const navigate = (url) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { return callBridge('navigate', { url, type: 'same-tab' }); });
const open = (url) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { return callBridge('navigate', { url, type: 'new-tab' }); });
exports.router = {
navigate: navigate,
open: open
navigate,
open
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.withRateLimiter = void 0;
var tslib_1 = require("tslib");
var errors_1 = require("../errors");
exports.withRateLimiter = function (wrappedFn, maxOps, intervalInMs, exceededErrorMessage) {
var start = Date.now();
var numOps = 0;
return function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
const tslib_1 = require("tslib");
const errors_1 = require("../errors");
exports.withRateLimiter = (wrappedFn, maxOps, intervalInMs, exceededErrorMessage) => {
let start = Date.now();
let numOps = 0;
return (...args) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
const now = Date.now();
const elapsed = now - start;
if (elapsed > intervalInMs) {
start = now;
numOps = 0;
}
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
var now, elapsed;
return tslib_1.__generator(this, function (_a) {
now = Date.now();
elapsed = now - start;
if (elapsed > intervalInMs) {
start = now;
numOps = 0;
}
if (numOps >= maxOps) {
throw new errors_1.BridgeAPIError(exceededErrorMessage || 'Too many invocations.');
}
numOps = numOps + 1;
return [2, wrappedFn.apply(void 0, args)];
});
});
};
if (numOps >= maxOps) {
throw new errors_1.BridgeAPIError(exceededErrorMessage || 'Too many invocations.');
}
numOps = numOps + 1;
return wrappedFn(...args);
});
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.close = void 0;
var tslib_1 = require("tslib");
var bridge_1 = require("../bridge");
var errors_1 = require("../errors");
var callBridge = bridge_1.getCallBridge();
exports.close = function (payload) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
var success, e_1;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4, callBridge('close', payload)];
case 1:
success = _a.sent();
if (success === false) {
throw new errors_1.BridgeAPIError("this resource's view is not closable.");
}
return [3, 3];
case 2:
e_1 = _a.sent();
throw new errors_1.BridgeAPIError("this resource's view is not closable.");
case 3: return [2];
const tslib_1 = require("tslib");
const bridge_1 = require("../bridge");
const errors_1 = require("../errors");
const callBridge = bridge_1.getCallBridge();
exports.close = (payload) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
try {
const success = yield callBridge('close', payload);
if (success === false) {
throw new errors_1.BridgeAPIError("this resource's view is not closable.");
}
});
}); };
}
catch (e) {
throw new errors_1.BridgeAPIError("this resource's view is not closable.");
}
});
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createHistory = void 0;
var bridge_1 = require("../bridge");
var callBridge = bridge_1.getCallBridge();
exports.createHistory = function () {
const bridge_1 = require("../bridge");
const callBridge = bridge_1.getCallBridge();
exports.createHistory = () => {
return callBridge('createHistory');
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getContext = void 0;
var bridge_1 = require("../bridge");
var callBridge = bridge_1.getCallBridge();
exports.getContext = function () {
const bridge_1 = require("../bridge");
const callBridge = bridge_1.getCallBridge();
exports.getContext = () => {
return callBridge('getContext');
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./view"), exports);
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.submit = void 0;
var tslib_1 = require("tslib");
var bridge_1 = require("../bridge");
var errors_1 = require("../errors");
var callBridge = bridge_1.getCallBridge();
exports.submit = function (payload) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
var success;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4, callBridge('submit', payload)];
case 1:
success = _a.sent();
if (success === false) {
throw new errors_1.BridgeAPIError("this resource's view is not submittable.");
}
return [2];
}
});
}); };
const tslib_1 = require("tslib");
const bridge_1 = require("../bridge");
const errors_1 = require("../errors");
const callBridge = bridge_1.getCallBridge();
exports.submit = (payload) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
const success = yield callBridge('submit', payload);
if (success === false) {
throw new errors_1.BridgeAPIError("this resource's view is not submittable.");
}
});
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.view = void 0;
var submit_1 = require("./submit");
var close_1 = require("./close");
var createHistory_1 = require("./createHistory");
var getContext_1 = require("./getContext");
const submit_1 = require("./submit");
const close_1 = require("./close");
const createHistory_1 = require("./createHistory");
const getContext_1 = require("./getContext");
exports.view = {

@@ -9,0 +9,0 @@ submit: submit_1.submit,

{
"name": "@forge/bridge",
"version": "2.1.1",
"version": "2.1.2-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