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 0.0.0-experimental-ed3737f to 0.0.0-experimental-edeb51b

out/fetch/fetch.d.ts

162

CHANGELOG.md
# @forge/bridge
## 0.0.0-experimental-ed3737f
## 0.0.0-experimental-edeb51b
### Patch Changes
- f5350a5: Change
- 97ce1f3: update history.location in bridge when route changes
- 456c10c: Add
## 2.2.1-next.0
### Patch Changes
- 97ce1f3: update history.location in bridge when route changes
## 2.2.0
### Minor Changes
- 6fe6082: Ability to disable close on escape and overlay click for modals
## 2.2.0-next.0
### Minor Changes
- 6fe60823: Ability to disable close on escape and overlay click for modals
## 2.1.3
### Patch Changes
- 7c11b22: Improve error message for when the Custom UI bridge is not available
## 2.1.3-next.0
### Patch Changes
- 7c11b22: Improve error message for when the Custom UI bridge is not available
## 2.1.2
### Patch Changes
- 06edfce: Fix headers for some REST endpoints
## 2.1.2-next.0
### Patch Changes
- 06edfce: Fix headers for some REST endpoints
## 2.1.1
### Patch Changes
- abf359f: Enable requestJira and requestConfluence in Forge bridge to generate correct content type for form data
## 2.1.1-next.0
### Patch Changes
- abf359f: Enable requestJira and requestConfluence in Forge bridge to generate correct content type for form data
## 2.1.0
### Minor Changes
- 63e5561: Add submit method
## 2.1.0-next.0
### Minor Changes
- 63e5561: Add submit method
## 2.0.0
### Major Changes
- 2f07efb: Add new client-side 3LO requestJira and requestConfluence methods
## 2.0.0-next.0
### Major Changes
- 2f07efb: Add new client-side 3LO requestJira and requestConfluence methods
## 1.5.0
### Minor Changes
- c5aedc4: Move createHistory method into view namespace
- 05977d4: Add modal api
- eafead6: Add createHistory method to router API
## 1.5.0-next.2
### Minor Changes
- c5aedc4: Move createHistory method into view namespace
## 1.5.0-next.1
### Minor Changes
- eafead6: Add createHistory method to router API
## 1.5.0-next.0
### Minor Changes
- 05977d4: Add modal api
## 1.4.0
### Minor Changes
- 6bb4c77: router.open and router.navigate are now supported in Confluence
## 1.4.0-next.0
### Minor Changes
- 6bb4c77: router.open and router.navigate are now supported in Confluence
## 1.3.0
### Minor Changes
- 69e2a9e: Expose router.open for opening external links in new tabs
- fbc16b0: Add router.navigate to bridge
### Patch Changes
- 180e45a: Throw error if router is used from confluence
- ff35ac9: Check for Jira instead of Confluence
## 1.3.0-next.3
### Patch Changes
- ff35ac9: Check for Jira instead of Confluence
## 1.3.0-next.2
### Minor Changes
- 69e2a9e: Expose router.open for opening external links in new tabs
## 1.3.0-next.1
### Patch Changes
- 180e45a: Throw error if router is used from confluence
## 1.3.0-next.0
### Minor Changes
- fbc16b0: Add router.navigate to bridge
## 1.2.0
### Minor Changes
- 74a0279: Add getContext method

@@ -8,0 +168,0 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCallBridge = void 0;
exports.getCallBridge = function () {
return window.__bridge.callBridge;
const errors_1 = require("./errors");
function isBridgeAvailable(bridge) {
return !!(bridge === null || bridge === void 0 ? void 0 : bridge.callBridge);
}
exports.getCallBridge = () => {
if (!isBridgeAvailable(self.__bridge)) {
throw new errors_1.BridgeAPIError(`
Unable to establish a connection with the Custom UI bridge.
If you are trying to run your app locally, Forge apps only work in the context of Atlassian products. Refer to https://go.atlassian.com/forge-tunneling-with-custom-ui for how to tunnel when using a local development server.
`);
}
return self.__bridge.callBridge;
};

10

out/errors.js
"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;
export * from './invoke';
export * from './view';
export * from './router';
export * from './modal';
export * from './fetch';
//# sourceMappingURL=index.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./invoke"), exports);
tslib_1.__exportStar(require("./view"), exports);
tslib_1.__exportStar(require("./router"), exports);
tslib_1.__exportStar(require("./modal"), exports);
tslib_1.__exportStar(require("./fetch"), exports);
export * from './invoke';
export * from './requestJira';
export * from './requestConfluence';
//# sourceMappingURL=index.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./invoke"), exports);
tslib_1.__exportStar(require("./requestJira"), exports);
tslib_1.__exportStar(require("./requestConfluence"), 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');

@@ -5,6 +5,6 @@ export declare type InvokePayload = {

export declare type InvokeResponse = Record<string, any> | void;
export declare type ProductResponse = {
body: any;
} & Pick<Response, 'ok' | 'status' | 'statusText'>;
export declare type ProductFetchResponse = {
body?: string;
} & Pick<ResponseInit, 'headers' | 'status' | 'statusText'>;
export declare type FullContext = {};
//# sourceMappingURL=types.d.ts.map
"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);
});
};

@@ -1,2 +0,2 @@

export declare const close: () => Promise<void>;
export declare const close: (payload?: any) => Promise<void>;
//# sourceMappingURL=close.d.ts.map
"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 () { 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')];
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.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);
export declare const view: {
close: () => Promise<void>;
submit: (payload?: any) => Promise<void>;
close: (payload?: any) => Promise<void>;
createHistory: () => Promise<import("history").History<unknown>>;
getContext: () => Promise<import("../types").FullContext>;
};
//# sourceMappingURL=view.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.view = void 0;
var getContext_1 = require("./getContext");
var close_1 = require("./close");
const submit_1 = require("./submit");
const close_1 = require("./close");
const createHistory_1 = require("./createHistory");
const getContext_1 = require("./getContext");
exports.view = {
submit: submit_1.submit,
close: close_1.close,
createHistory: createHistory_1.createHistory,
getContext: getContext_1.getContext
};
{
"name": "@forge/bridge",
"version": "0.0.0-experimental-ed3737f",
"version": "0.0.0-experimental-edeb51b",
"description": "Forge bridge API for custom UI apps",

@@ -14,5 +14,10 @@ "author": "Atlassian",

},
"dependencies": {
"@types/history": "^4.7.8"
},
"devDependencies": {
"history": "4.10.1",
"isomorphic-fetch": "^3.0.0",
"jest-date-mock": "^1.0.8"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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