@forge/api 6.1.0-next.2 → 6.1.1-experimental-3f68b81
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 +32 -0
- package/out/api/endpoint.d.ts +8 -0
- package/out/api/endpoint.d.ts.map +1 -0
- package/out/api/endpoint.js +54 -0
- package/out/api/errors.d.ts +4 -0
- package/out/api/errors.d.ts.map +1 -1
- package/out/api/errors.js +16 -2
- package/out/api/permissions.d.ts +23 -0
- package/out/api/permissions.d.ts.map +1 -0
- package/out/api/permissions.js +142 -0
- package/out/api/runtime.d.ts +29 -0
- package/out/api/runtime.d.ts.map +1 -1
- package/out/api/runtime.js +95 -3
- package/out/index.d.ts +2 -2
- package/out/index.d.ts.map +1 -1
- package/out/index.js +8 -7
- package/package.json +6 -4
- package/out/api/remote.d.ts +0 -7
- package/out/api/remote.d.ts.map +0 -1
- package/out/api/remote.js +0 -28
- package/out/api/service.d.ts +0 -7
- package/out/api/service.d.ts.map +0 -1
- package/out/api/service.js +0 -28
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# @forge/api
|
|
2
2
|
|
|
3
|
+
## 6.1.1-experimental-3f68b81
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fe2852a: Added backend SDK for permission handling
|
|
8
|
+
- Updated dependencies [fe2852a]
|
|
9
|
+
- @forge/manifest@10.4.0-experimental-3f68b81
|
|
10
|
+
|
|
11
|
+
## 6.1.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- ad46892: Refactor invokeService and invokeRemote API functions into one
|
|
16
|
+
|
|
17
|
+
## 6.1.1-next.0
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- ad46892: Refactor invokeService and invokeRemote API functions into one
|
|
22
|
+
|
|
23
|
+
## 6.1.0
|
|
24
|
+
|
|
25
|
+
### Minor Changes
|
|
26
|
+
|
|
27
|
+
- 518c490: Add invokeService to @forge/api
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- 6392355: Add realtime to ForgeRuntime type
|
|
32
|
+
- Updated dependencies [8a3d993]
|
|
33
|
+
- @forge/egress@2.0.3
|
|
34
|
+
|
|
3
35
|
## 6.1.0-next.2
|
|
4
36
|
|
|
5
37
|
### Patch Changes
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { APIResponse, RequestInit } from '../index';
|
|
2
|
+
declare type InvokeEndpointOptions = {
|
|
3
|
+
path: string;
|
|
4
|
+
};
|
|
5
|
+
export declare function invokeRemote(remoteKey: string, options: RequestInit & InvokeEndpointOptions): Promise<APIResponse>;
|
|
6
|
+
export declare function invokeService(serviceKey: string, options: RequestInit & InvokeEndpointOptions): Promise<APIResponse>;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=endpoint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endpoint.d.ts","sourceRoot":"","sources":["../../src/api/endpoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AASpD,aAAK,qBAAqB,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,wBAAsB,YAAY,CAChC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,WAAW,GAAG,qBAAqB,GAC3C,OAAO,CAAC,WAAW,CAAC,CAEtB;AAED,wBAAsB,aAAa,CACjC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,WAAW,GAAG,qBAAqB,GAC3C,OAAO,CAAC,WAAW,CAAC,CAEtB"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.invokeService = exports.invokeRemote = void 0;
|
|
4
|
+
const errors_1 = require("./errors");
|
|
5
|
+
const fetch_1 = require("./fetch");
|
|
6
|
+
var InvokeType;
|
|
7
|
+
(function (InvokeType) {
|
|
8
|
+
InvokeType["REMOTE"] = "Remote";
|
|
9
|
+
InvokeType["CONTAINER"] = "Service";
|
|
10
|
+
})(InvokeType || (InvokeType = {}));
|
|
11
|
+
async function invokeRemote(remoteKey, options) {
|
|
12
|
+
return invokeEndpoint(remoteKey, options, InvokeType.REMOTE);
|
|
13
|
+
}
|
|
14
|
+
exports.invokeRemote = invokeRemote;
|
|
15
|
+
async function invokeService(serviceKey, options) {
|
|
16
|
+
return invokeEndpoint(serviceKey, options, InvokeType.CONTAINER);
|
|
17
|
+
}
|
|
18
|
+
exports.invokeService = invokeService;
|
|
19
|
+
async function invokeEndpoint(key, options, type) {
|
|
20
|
+
const { path, ...fetchOptions } = options;
|
|
21
|
+
if (!key) {
|
|
22
|
+
throw new Error(`Missing ${type.toLowerCase()} key provided to invoke${type}`);
|
|
23
|
+
}
|
|
24
|
+
if (!path) {
|
|
25
|
+
throw new Error(`Missing or empty path provided to invoke${type}`);
|
|
26
|
+
}
|
|
27
|
+
const response = await global.__forge_fetch__(constructInvokePayload(key, type), path, fetchOptions);
|
|
28
|
+
handleResponseErrors(response, key);
|
|
29
|
+
return response;
|
|
30
|
+
}
|
|
31
|
+
function constructInvokePayload(key, type) {
|
|
32
|
+
switch (type) {
|
|
33
|
+
case InvokeType.REMOTE:
|
|
34
|
+
return {
|
|
35
|
+
type: 'frc',
|
|
36
|
+
remote: key
|
|
37
|
+
};
|
|
38
|
+
case InvokeType.CONTAINER:
|
|
39
|
+
return {
|
|
40
|
+
type: 'fcc',
|
|
41
|
+
service: key
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function handleResponseErrors(response, key) {
|
|
46
|
+
const forgeProxyError = (0, fetch_1.getForgeProxyError)(response);
|
|
47
|
+
if (forgeProxyError === 'INVALID_SERVICE_KEY') {
|
|
48
|
+
throw new errors_1.InvalidContainerServiceError(`Invalid service key provided: "${key}"`, key);
|
|
49
|
+
}
|
|
50
|
+
else if (forgeProxyError === 'INVALID_REMOTE') {
|
|
51
|
+
throw new errors_1.InvalidRemoteError(`Invalid remote key provided: "${key}"`, key);
|
|
52
|
+
}
|
|
53
|
+
(0, fetch_1.handleProxyResponseErrors)(response);
|
|
54
|
+
}
|
package/out/api/errors.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export declare const NEEDS_AUTHENTICATION_ERR = "NEEDS_AUTHENTICATION_ERR";
|
|
|
5
5
|
export declare const INVALID_REMOTE_ERR = "INVALID_REMOTE_ERR";
|
|
6
6
|
export declare const INVALID_CONTAINER_SERVICE_ERR = "INVALID_CONTAINER_SERVICE_ERR";
|
|
7
7
|
export declare const PROXY_ERR = "PROXY_ERR";
|
|
8
|
+
export declare const API_NOT_READY_ERR = "API_NOT_READY_ERR";
|
|
8
9
|
export declare function isForgePlatformError(err: Error): boolean;
|
|
9
10
|
export declare function isHostedCodeError(err: Error | string): boolean;
|
|
10
11
|
export declare function isExpectedError(err: Error): boolean;
|
|
@@ -52,4 +53,7 @@ export declare class ProxyRequestError extends HttpError {
|
|
|
52
53
|
errorCode: string;
|
|
53
54
|
constructor(status: number, errorCode: string);
|
|
54
55
|
}
|
|
56
|
+
export declare class ApiNotReadyError extends Error {
|
|
57
|
+
constructor(message?: string);
|
|
58
|
+
}
|
|
55
59
|
//# sourceMappingURL=errors.d.ts.map
|
package/out/api/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/api/errors.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAC3C,eAAO,MAAM,4BAA4B,iCAAiC,CAAC;AAC3E,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AACvD,eAAO,MAAM,wBAAwB,6BAA6B,CAAC;AACnE,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AAC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C,EAAE,MAAM,EAAE,CAAC;IAKlB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,qBAAa,wBAAyB,SAAQ,SAAS;aAGnC,UAAU,EAAE,MAAM;aAClB,OAAO,CAAC;gBAFxB,KAAK,EAAE,MAAM,EACG,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,6CAAiC;CAO5D;AAED,qBAAa,kBAAmB,SAAQ,SAAS;aAG7B,SAAS,EAAE,MAAM;gBADjC,KAAK,EAAE,MAAM,EACG,SAAS,EAAE,MAAM;CAMpC;AAED,qBAAa,4BAA6B,SAAQ,SAAS;aAGvC,UAAU,EAAE,MAAM;gBADlC,KAAK,EAAE,MAAM,EACG,UAAU,EAAE,MAAM;CAMrC;AAED,qBAAa,iBAAkB,SAAQ,SAAS;IAErC,MAAM,EAAE,MAAM;IACd,SAAS,EAAE,MAAM;gBADjB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM;CAK3B;AAED,qBAAa,gBAAiB,SAAQ,KAAK;gBAC7B,OAAO,SAAsC;CAI1D"}
|
package/out/api/errors.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ProxyRequestError = exports.InvalidContainerServiceError = exports.InvalidRemoteError = exports.NeedsAuthenticationError = exports.InvalidWorkspaceRequestedError = exports.RequestProductNotAllowedError = exports.ProductEndpointNotAllowedError = exports.ExternalEndpointNotAllowedError = exports.NotAllowedError = exports.FetchError = exports.HttpError = exports.isExpectedError = exports.isHostedCodeError = exports.isForgePlatformError = exports.PROXY_ERR = exports.INVALID_CONTAINER_SERVICE_ERR = exports.INVALID_REMOTE_ERR = exports.NEEDS_AUTHENTICATION_ERR = exports.FUNCTION_FETCH_ERR = exports.REQUEST_EGRESS_ALLOWLIST_ERR = exports.FUNCTION_ERR = void 0;
|
|
3
|
+
exports.ApiNotReadyError = exports.ProxyRequestError = exports.InvalidContainerServiceError = exports.InvalidRemoteError = exports.NeedsAuthenticationError = exports.InvalidWorkspaceRequestedError = exports.RequestProductNotAllowedError = exports.ProductEndpointNotAllowedError = exports.ExternalEndpointNotAllowedError = exports.NotAllowedError = exports.FetchError = exports.HttpError = exports.isExpectedError = exports.isHostedCodeError = exports.isForgePlatformError = exports.API_NOT_READY_ERR = exports.PROXY_ERR = exports.INVALID_CONTAINER_SERVICE_ERR = exports.INVALID_REMOTE_ERR = exports.NEEDS_AUTHENTICATION_ERR = exports.FUNCTION_FETCH_ERR = exports.REQUEST_EGRESS_ALLOWLIST_ERR = exports.FUNCTION_ERR = void 0;
|
|
4
4
|
exports.FUNCTION_ERR = 'FUNCTION_ERR';
|
|
5
5
|
exports.REQUEST_EGRESS_ALLOWLIST_ERR = 'REQUEST_EGRESS_ALLOWLIST_ERR';
|
|
6
6
|
exports.FUNCTION_FETCH_ERR = 'FUNCTION_FETCH_ERR';
|
|
@@ -8,8 +8,15 @@ exports.NEEDS_AUTHENTICATION_ERR = 'NEEDS_AUTHENTICATION_ERR';
|
|
|
8
8
|
exports.INVALID_REMOTE_ERR = 'INVALID_REMOTE_ERR';
|
|
9
9
|
exports.INVALID_CONTAINER_SERVICE_ERR = 'INVALID_CONTAINER_SERVICE_ERR';
|
|
10
10
|
exports.PROXY_ERR = 'PROXY_ERR';
|
|
11
|
+
exports.API_NOT_READY_ERR = 'API_NOT_READY_ERR';
|
|
11
12
|
function isForgePlatformError(err) {
|
|
12
|
-
return [
|
|
13
|
+
return [
|
|
14
|
+
exports.REQUEST_EGRESS_ALLOWLIST_ERR,
|
|
15
|
+
exports.FUNCTION_FETCH_ERR,
|
|
16
|
+
exports.NEEDS_AUTHENTICATION_ERR,
|
|
17
|
+
exports.PROXY_ERR,
|
|
18
|
+
exports.API_NOT_READY_ERR
|
|
19
|
+
].includes(err.name);
|
|
13
20
|
}
|
|
14
21
|
exports.isForgePlatformError = isForgePlatformError;
|
|
15
22
|
function isHostedCodeError(err) {
|
|
@@ -112,3 +119,10 @@ class ProxyRequestError extends HttpError {
|
|
|
112
119
|
}
|
|
113
120
|
}
|
|
114
121
|
exports.ProxyRequestError = ProxyRequestError;
|
|
122
|
+
class ApiNotReadyError extends Error {
|
|
123
|
+
constructor(message = 'Forge API currently not available') {
|
|
124
|
+
super(message);
|
|
125
|
+
this.name = exports.API_NOT_READY_ERR;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
exports.ApiNotReadyError = ApiNotReadyError;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { PermissionRequirements, MissingPermissions } from './runtime';
|
|
2
|
+
export declare function extractUrlString(url: string | {
|
|
3
|
+
address: string;
|
|
4
|
+
} | {
|
|
5
|
+
remote: string;
|
|
6
|
+
}): string;
|
|
7
|
+
export type { PermissionRequirements };
|
|
8
|
+
export type { MissingPermissions };
|
|
9
|
+
export interface PermissionResult {
|
|
10
|
+
granted: boolean;
|
|
11
|
+
missing: MissingPermissions;
|
|
12
|
+
}
|
|
13
|
+
export declare const hasPermission: (requirements: Partial<PermissionRequirements>) => PermissionResult;
|
|
14
|
+
export declare const hasScope: (scope: string) => boolean;
|
|
15
|
+
export declare const canFetchFrom: (type: 'backend' | 'client', url: string) => boolean;
|
|
16
|
+
export declare const canLoadResource: (type: 'fonts' | 'styles' | 'frames' | 'images' | 'media' | 'scripts', url: string) => boolean;
|
|
17
|
+
export declare const permissions: {
|
|
18
|
+
hasPermission: (requirements: Partial<PermissionRequirements>) => PermissionResult;
|
|
19
|
+
hasScope: (scope: string) => boolean;
|
|
20
|
+
canFetchFrom: (type: 'backend' | 'client', url: string) => boolean;
|
|
21
|
+
canLoadResource: (type: 'fonts' | 'styles' | 'frames' | 'images' | 'media' | 'scripts', url: string) => boolean;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=permissions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../src/api/permissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,sBAAsB,EAAE,kBAAkB,EAA8B,MAAM,WAAW,CAAC;AAOlH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAQ/F;AAKD,YAAY,EAAE,sBAAsB,EAAE,CAAC;AAKvC,YAAY,EAAE,kBAAkB,EAAE,CAAC;AAKnC,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,kBAAkB,CAAC;CAC7B;AAoCD,eAAO,MAAM,aAAa,iBAAkB,QAAQ,sBAAsB,CAAC,KAAG,gBAqG7E,CAAC;AAmBF,eAAO,MAAM,QAAQ,UAAW,MAAM,KAAG,OAWxC,CAAC;AAyBF,eAAO,MAAM,YAAY,SAAU,SAAS,GAAG,QAAQ,OAAO,MAAM,KAAG,OAetE,CAAC;AAyBF,eAAO,MAAM,eAAe,SACpB,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,OAC/D,MAAM,KACV,OAeF,CAAC;AAKF,eAAO,MAAM,WAAW;kCA3NoB,QAAQ,sBAAsB,CAAC,KAAG,gBAAgB;sBAwH9D,MAAM,KAAG,OAAO;yBAoCb,SAAS,GAAG,QAAQ,OAAO,MAAM,KAAG,OAAO;4BAyCtE,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,OAC/D,MAAM,KACV,OAAO;CAyBT,CAAC"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.permissions = exports.canLoadResource = exports.canFetchFrom = exports.hasScope = exports.hasPermission = exports.extractUrlString = void 0;
|
|
4
|
+
const runtime_1 = require("./runtime");
|
|
5
|
+
const errors_1 = require("./errors");
|
|
6
|
+
const minimatch_1 = require("minimatch");
|
|
7
|
+
function extractUrlString(url) {
|
|
8
|
+
if (typeof url === 'string') {
|
|
9
|
+
return url;
|
|
10
|
+
}
|
|
11
|
+
if ('address' in url) {
|
|
12
|
+
return url.address;
|
|
13
|
+
}
|
|
14
|
+
return url.remote;
|
|
15
|
+
}
|
|
16
|
+
exports.extractUrlString = extractUrlString;
|
|
17
|
+
const hasPermission = (requirements) => {
|
|
18
|
+
if (!(0, runtime_1.arePermsAvailableInRuntime)()) {
|
|
19
|
+
throw new errors_1.ApiNotReadyError('API not ready: permissions are not available in the runtime object');
|
|
20
|
+
}
|
|
21
|
+
const appContext = (0, runtime_1.getAppContext)();
|
|
22
|
+
const currentGrantedPermissions = appContext.permissions;
|
|
23
|
+
const missingPermissions = {};
|
|
24
|
+
let hasMissingPermissions = false;
|
|
25
|
+
if (requirements.scopes && Array.isArray(requirements.scopes) && requirements.scopes.length > 0) {
|
|
26
|
+
const currentGrantedScopes = Array.isArray(currentGrantedPermissions.scopes)
|
|
27
|
+
? currentGrantedPermissions.scopes
|
|
28
|
+
: [];
|
|
29
|
+
const missingScopes = requirements.scopes.filter((scope) => !currentGrantedScopes.includes(scope));
|
|
30
|
+
if (missingScopes.length > 0) {
|
|
31
|
+
missingPermissions.scopes = missingScopes;
|
|
32
|
+
hasMissingPermissions = true;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (requirements.external) {
|
|
36
|
+
const { external } = requirements;
|
|
37
|
+
const currentGrantedExternal = currentGrantedPermissions.external || {};
|
|
38
|
+
if (external.fetch) {
|
|
39
|
+
const missingFetch = {};
|
|
40
|
+
if (external.fetch.backend && external.fetch.backend.length > 0) {
|
|
41
|
+
const missingBackend = external.fetch.backend.filter((requiredUrl) => {
|
|
42
|
+
const currentGrantedBackendUrls = currentGrantedExternal.fetch?.backend || [];
|
|
43
|
+
const isUrlAlreadyGranted = currentGrantedBackendUrls.some((currentGrantedUrl) => {
|
|
44
|
+
return (0, minimatch_1.minimatch)(extractUrlString(requiredUrl), extractUrlString(currentGrantedUrl));
|
|
45
|
+
});
|
|
46
|
+
return !isUrlAlreadyGranted;
|
|
47
|
+
});
|
|
48
|
+
if (missingBackend.length > 0) {
|
|
49
|
+
missingFetch.backend = missingBackend.map(extractUrlString);
|
|
50
|
+
hasMissingPermissions = true;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (external.fetch.client && external.fetch.client.length > 0) {
|
|
54
|
+
const missingClient = external.fetch.client.filter((requiredUrl) => {
|
|
55
|
+
const currentGrantedClientUrls = currentGrantedExternal.fetch?.client || [];
|
|
56
|
+
const isUrlAlreadyGranted = currentGrantedClientUrls.some((currentGrantedUrl) => {
|
|
57
|
+
return (0, minimatch_1.minimatch)(extractUrlString(requiredUrl), extractUrlString(currentGrantedUrl));
|
|
58
|
+
});
|
|
59
|
+
return !isUrlAlreadyGranted;
|
|
60
|
+
});
|
|
61
|
+
if (missingClient.length > 0) {
|
|
62
|
+
missingFetch.client = missingClient.map(extractUrlString);
|
|
63
|
+
hasMissingPermissions = true;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (Object.keys(missingFetch).length > 0) {
|
|
67
|
+
missingPermissions.external = { ...missingPermissions.external, fetch: missingFetch };
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const externalTypes = ['fonts', 'styles', 'frames', 'images', 'media', 'scripts'];
|
|
71
|
+
for (const type of externalTypes) {
|
|
72
|
+
const externalUrls = external[type];
|
|
73
|
+
if (externalUrls && externalUrls.length > 0) {
|
|
74
|
+
const missingUrls = externalUrls.filter((requiredUrl) => {
|
|
75
|
+
const currentGrantedUrls = currentGrantedExternal[type] || [];
|
|
76
|
+
const isUrlAlreadyGranted = currentGrantedUrls.some((currentGrantedUrl) => {
|
|
77
|
+
return (0, minimatch_1.minimatch)(extractUrlString(requiredUrl), extractUrlString(currentGrantedUrl));
|
|
78
|
+
});
|
|
79
|
+
return !isUrlAlreadyGranted;
|
|
80
|
+
});
|
|
81
|
+
if (missingUrls.length > 0) {
|
|
82
|
+
if (!missingPermissions.external) {
|
|
83
|
+
missingPermissions.external = {};
|
|
84
|
+
}
|
|
85
|
+
missingPermissions.external[type] = missingUrls.map(extractUrlString);
|
|
86
|
+
hasMissingPermissions = true;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
granted: !hasMissingPermissions,
|
|
93
|
+
missing: new runtime_1.MissingPermissions(missingPermissions.scopes, missingPermissions.external, missingPermissions.content)
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
exports.hasPermission = hasPermission;
|
|
97
|
+
const hasScope = (scope) => {
|
|
98
|
+
if (!(0, runtime_1.arePermsAvailableInRuntime)()) {
|
|
99
|
+
throw new errors_1.ApiNotReadyError('API not ready: permissions are not available in the runtime object');
|
|
100
|
+
}
|
|
101
|
+
const appContext = (0, runtime_1.getAppContext)();
|
|
102
|
+
const currentScopes = appContext.permissions.scopes;
|
|
103
|
+
if (Array.isArray(currentScopes)) {
|
|
104
|
+
return currentScopes.includes(scope);
|
|
105
|
+
}
|
|
106
|
+
return false;
|
|
107
|
+
};
|
|
108
|
+
exports.hasScope = hasScope;
|
|
109
|
+
const canFetchFrom = (type, url) => {
|
|
110
|
+
if (!(0, runtime_1.arePermsAvailableInRuntime)()) {
|
|
111
|
+
throw new errors_1.ApiNotReadyError('API not ready: permissions are not available in the runtime object');
|
|
112
|
+
}
|
|
113
|
+
const appContext = (0, runtime_1.getAppContext)();
|
|
114
|
+
const grantedUrls = appContext.permissions.external?.fetch?.[type];
|
|
115
|
+
if (!grantedUrls || grantedUrls.length === 0) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
return grantedUrls.some((grantedUrl) => {
|
|
119
|
+
return (0, minimatch_1.minimatch)(url, extractUrlString(grantedUrl));
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
exports.canFetchFrom = canFetchFrom;
|
|
123
|
+
const canLoadResource = (type, url) => {
|
|
124
|
+
if (!(0, runtime_1.arePermsAvailableInRuntime)()) {
|
|
125
|
+
throw new errors_1.ApiNotReadyError('API not ready: permissions are not available in the runtime object');
|
|
126
|
+
}
|
|
127
|
+
const appContext = (0, runtime_1.getAppContext)();
|
|
128
|
+
const grantedUrls = appContext.permissions.external?.[type];
|
|
129
|
+
if (!grantedUrls || grantedUrls.length === 0) {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
return grantedUrls.some((grantedUrl) => {
|
|
133
|
+
return (0, minimatch_1.minimatch)(url, extractUrlString(grantedUrl));
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
exports.canLoadResource = canLoadResource;
|
|
137
|
+
exports.permissions = {
|
|
138
|
+
hasPermission: exports.hasPermission,
|
|
139
|
+
hasScope: exports.hasScope,
|
|
140
|
+
canFetchFrom: exports.canFetchFrom,
|
|
141
|
+
canLoadResource: exports.canLoadResource
|
|
142
|
+
};
|
package/out/api/runtime.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AppAri, EnvironmentAri, InstallationAri } from './ari';
|
|
2
|
+
import { Permissions as ManifestPermissions, External as ManifestExternal, Scopes as ManifestScopes, Content1 as ManifestContent } from '@forge/manifest';
|
|
2
3
|
interface Timer {
|
|
3
4
|
stop(tags?: Record<string, string>): void;
|
|
4
5
|
}
|
|
@@ -64,6 +65,31 @@ export interface Installation {
|
|
|
64
65
|
export interface Realtime {
|
|
65
66
|
contextToken?: string;
|
|
66
67
|
}
|
|
68
|
+
export declare type External = ManifestExternal;
|
|
69
|
+
export declare abstract class Permissions implements ManifestPermissions {
|
|
70
|
+
abstract scopes?: ManifestScopes;
|
|
71
|
+
abstract content?: ManifestContent;
|
|
72
|
+
abstract external?: ManifestExternal;
|
|
73
|
+
format(): string;
|
|
74
|
+
}
|
|
75
|
+
export declare class RuntimePermissions extends Permissions {
|
|
76
|
+
scopes: ManifestScopes;
|
|
77
|
+
external: ManifestExternal;
|
|
78
|
+
content?: ManifestContent | undefined;
|
|
79
|
+
constructor(scopes: ManifestScopes, external: ManifestExternal, content?: ManifestContent | undefined);
|
|
80
|
+
}
|
|
81
|
+
export declare class PermissionRequirements extends Permissions {
|
|
82
|
+
scopes?: ManifestScopes | undefined;
|
|
83
|
+
external?: ManifestExternal | undefined;
|
|
84
|
+
content?: ManifestContent | undefined;
|
|
85
|
+
constructor(scopes?: ManifestScopes | undefined, external?: ManifestExternal | undefined, content?: ManifestContent | undefined);
|
|
86
|
+
}
|
|
87
|
+
export declare class MissingPermissions extends Permissions {
|
|
88
|
+
scopes?: ManifestScopes | undefined;
|
|
89
|
+
external?: ManifestExternal | undefined;
|
|
90
|
+
content?: ManifestContent | undefined;
|
|
91
|
+
constructor(scopes?: ManifestScopes | undefined, external?: ManifestExternal | undefined, content?: ManifestContent | undefined);
|
|
92
|
+
}
|
|
67
93
|
export declare type ForgeRuntime = {
|
|
68
94
|
proxy: ProxyInfo;
|
|
69
95
|
contextAri: string;
|
|
@@ -85,6 +111,7 @@ export declare type ForgeRuntime = {
|
|
|
85
111
|
moduleKey: string;
|
|
86
112
|
license?: License;
|
|
87
113
|
installation?: Installation;
|
|
114
|
+
permissions: Permissions;
|
|
88
115
|
};
|
|
89
116
|
aaid?: string;
|
|
90
117
|
lambdaContext: {
|
|
@@ -119,10 +146,12 @@ export declare type AppContext = {
|
|
|
119
146
|
moduleKey: string;
|
|
120
147
|
license?: License;
|
|
121
148
|
installation?: Installation;
|
|
149
|
+
permissions: Permissions;
|
|
122
150
|
};
|
|
123
151
|
export declare function __getRuntime(): ForgeRuntime;
|
|
124
152
|
export declare function getAppContext(): AppContext;
|
|
125
153
|
export declare function wrapInMetrics<Args extends unknown[], Ret>(name: string, fn: (...args: Args) => Promise<Ret>): (...args: Args) => Promise<Ret>;
|
|
126
154
|
export declare function bindInvocationContext<Func extends (...args: never[]) => unknown>(fn: Func): Func;
|
|
155
|
+
export declare function arePermsAvailableInRuntime(): boolean;
|
|
127
156
|
export {};
|
|
128
157
|
//# sourceMappingURL=runtime.d.ts.map
|
package/out/api/runtime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/api/runtime.ts"],"names":[],"mappings":"AACA,OAAO,EAAoD,MAAM,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/api/runtime.ts"],"names":[],"mappings":"AACA,OAAO,EAAoD,MAAM,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAClH,OAAO,EACL,WAAW,IAAI,mBAAmB,EAClC,QAAQ,IAAI,gBAAgB,EAC5B,MAAM,IAAI,cAAc,EACxB,QAAQ,IAAI,eAAe,EAC5B,MAAM,iBAAiB,CAAC;AAezB,UAAU,KAAK;IACb,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;CAC3C;AAED,UAAU,OAAO;IACf,IAAI,IAAI,IAAI,CAAC;IACb,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,IAAI,IAAI,IAAI,CAAC;IACb,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED,UAAU,MAAM;IACd,OAAO,IAAI,KAAK,CAAC;CAClB;AAED,UAAU,KAAK;IACb,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,MAAM,WAAW,OAAO;IACtB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC;IAC5D,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAA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E,eAAe,CAAC;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,WAAW,EAAE,WAAW,CAAC;CAC1B,CAAC;AAEF,wBAAgB,YAAY,IAAI,YAAY,CAO3C;AAED,wBAAgB,aAAa,IAAI,UAAU,CAkC1C;AAED,wBAAgB,aAAa,CAAC,IAAI,SAAS,OAAO,EAAE,EAAE,GAAG,EACvD,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,GAAG,CAAC,GAClC,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,GAAG,CAAC,CAqBjC;AAED,wBAAgB,qBAAqB,CAAC,IAAI,SAAS,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,EAAE,EAAE,EAAE,IAAI,GAAG,IAAI,CAShG;AAmBD,wBAAgB,0BAA0B,IAAI,OAAO,CAQpD"}
|
package/out/api/runtime.js
CHANGED
|
@@ -1,8 +1,88 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.bindInvocationContext = exports.wrapInMetrics = exports.getAppContext = exports.__getRuntime = void 0;
|
|
3
|
+
exports.arePermsAvailableInRuntime = exports.bindInvocationContext = exports.wrapInMetrics = exports.getAppContext = exports.__getRuntime = exports.MissingPermissions = exports.PermissionRequirements = exports.RuntimePermissions = exports.Permissions = void 0;
|
|
4
4
|
const errors_1 = require("./errors");
|
|
5
5
|
const ari_1 = require("./ari");
|
|
6
|
+
function extractUrlString(item) {
|
|
7
|
+
if (typeof item === 'string') {
|
|
8
|
+
return item;
|
|
9
|
+
}
|
|
10
|
+
else if ('address' in item) {
|
|
11
|
+
return item.address;
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
return item.remote;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
class Permissions {
|
|
18
|
+
format() {
|
|
19
|
+
const parts = [];
|
|
20
|
+
if (this.scopes && Array.isArray(this.scopes) && this.scopes.length > 0) {
|
|
21
|
+
parts.push(`Scopes: ${this.scopes.join(', ')}`);
|
|
22
|
+
}
|
|
23
|
+
if (this.external) {
|
|
24
|
+
const externalParts = [];
|
|
25
|
+
if (this.external.fetch) {
|
|
26
|
+
if (this.external.fetch.backend && this.external.fetch.backend.length > 0) {
|
|
27
|
+
const backendUrls = this.external.fetch.backend.map(extractUrlString).join(', ');
|
|
28
|
+
externalParts.push(`Fetch Backend: ${backendUrls}`);
|
|
29
|
+
}
|
|
30
|
+
if (this.external.fetch.client && this.external.fetch.client.length > 0) {
|
|
31
|
+
const clientUrls = this.external.fetch.client.map(extractUrlString).join(', ');
|
|
32
|
+
externalParts.push(`Fetch Client: ${clientUrls}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const resourceTypes = ['fonts', 'frames', 'navigation', 'images', 'media', 'scripts', 'styles'];
|
|
36
|
+
for (const type of resourceTypes) {
|
|
37
|
+
const externalUrls = this.external[type];
|
|
38
|
+
if (externalUrls && externalUrls.length > 0) {
|
|
39
|
+
externalParts.push(`${type.charAt(0).toUpperCase() + type.slice(1)}: ${externalUrls.join(', ')}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (externalParts.length > 0) {
|
|
43
|
+
parts.push(`External: ${externalParts.join('; ')}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return parts.length > 0 ? parts.join('; ') : 'No permissions specified';
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.Permissions = Permissions;
|
|
50
|
+
class RuntimePermissions extends Permissions {
|
|
51
|
+
scopes;
|
|
52
|
+
external;
|
|
53
|
+
content;
|
|
54
|
+
constructor(scopes, external, content) {
|
|
55
|
+
super();
|
|
56
|
+
this.scopes = scopes;
|
|
57
|
+
this.external = external;
|
|
58
|
+
this.content = content;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.RuntimePermissions = RuntimePermissions;
|
|
62
|
+
class PermissionRequirements extends Permissions {
|
|
63
|
+
scopes;
|
|
64
|
+
external;
|
|
65
|
+
content;
|
|
66
|
+
constructor(scopes, external, content) {
|
|
67
|
+
super();
|
|
68
|
+
this.scopes = scopes;
|
|
69
|
+
this.external = external;
|
|
70
|
+
this.content = content;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.PermissionRequirements = PermissionRequirements;
|
|
74
|
+
class MissingPermissions extends Permissions {
|
|
75
|
+
scopes;
|
|
76
|
+
external;
|
|
77
|
+
content;
|
|
78
|
+
constructor(scopes, external, content) {
|
|
79
|
+
super();
|
|
80
|
+
this.scopes = scopes;
|
|
81
|
+
this.external = external;
|
|
82
|
+
this.content = content;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.MissingPermissions = MissingPermissions;
|
|
6
86
|
function __getRuntime() {
|
|
7
87
|
const runtime = global.__forge_runtime__;
|
|
8
88
|
if (!runtime) {
|
|
@@ -13,7 +93,7 @@ function __getRuntime() {
|
|
|
13
93
|
exports.__getRuntime = __getRuntime;
|
|
14
94
|
function getAppContext() {
|
|
15
95
|
const runtime = __getRuntime();
|
|
16
|
-
const { appId, appVersion, environmentId, environmentType, invocationId, installationId, moduleKey, license, installation } = runtime.appContext;
|
|
96
|
+
const { appId, appVersion, environmentId, environmentType, invocationId, installationId, moduleKey, license, installation, permissions } = runtime.appContext;
|
|
17
97
|
const invocationRemainingTimeInMillis = runtime.lambdaContext.getRemainingTimeInMillis ??
|
|
18
98
|
(() => {
|
|
19
99
|
throw new Error('Lambda remaining time is not available. If tunnelling, update Forge CLI to the latest version.');
|
|
@@ -28,7 +108,8 @@ function getAppContext() {
|
|
|
28
108
|
invocationRemainingTimeInMillis,
|
|
29
109
|
moduleKey,
|
|
30
110
|
license,
|
|
31
|
-
installation
|
|
111
|
+
installation,
|
|
112
|
+
permissions: new RuntimePermissions(permissions?.scopes || [], permissions?.external || {})
|
|
32
113
|
};
|
|
33
114
|
}
|
|
34
115
|
exports.getAppContext = getAppContext;
|
|
@@ -60,3 +141,14 @@ function bindInvocationContext(fn) {
|
|
|
60
141
|
return AsyncLocalStorage.bind(fn);
|
|
61
142
|
}
|
|
62
143
|
exports.bindInvocationContext = bindInvocationContext;
|
|
144
|
+
function arePermsAvailableInRuntime() {
|
|
145
|
+
try {
|
|
146
|
+
const runtime = __getRuntime();
|
|
147
|
+
const permissions = runtime.appContext.permissions;
|
|
148
|
+
return !!(permissions && typeof permissions === 'object');
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
exports.arePermsAvailableInRuntime = arePermsAvailableInRuntime;
|
package/out/index.d.ts
CHANGED
|
@@ -2,8 +2,7 @@ import { QueryApi, EntityStorageApi } from '@forge/storage';
|
|
|
2
2
|
import { authorize } from './authorization';
|
|
3
3
|
import { Route } from './safeUrl';
|
|
4
4
|
import { webTrigger, WebTriggerResponse, WebTriggerRequest, WebTriggerMethod, WebTriggerContext } from './webTrigger';
|
|
5
|
-
import { invokeRemote } from './api/
|
|
6
|
-
import { invokeService } from './api/service';
|
|
5
|
+
import { invokeRemote, invokeService } from './api/endpoint';
|
|
7
6
|
import { __fetchProduct, __requestAtlassianAsApp, __requestAtlassianAsUser } from './api/fetch';
|
|
8
7
|
export interface RequestInit {
|
|
9
8
|
body?: ArrayBuffer | string | URLSearchParams;
|
|
@@ -107,4 +106,5 @@ export { route, assumeTrustedRoute, routeFromAbsolute, Route } from './safeUrl';
|
|
|
107
106
|
export { ForgeRuntime, AppContext, getAppContext, __getRuntime, bindInvocationContext } from './api/runtime';
|
|
108
107
|
export { NeedsAuthenticationError, NeedsAuthenticationErrorOptions, ProxyRequestError, FetchError, ExternalEndpointNotAllowedError, ProductEndpointNotAllowedError, RequestProductNotAllowedError, NotAllowedError, InvalidWorkspaceRequestedError, HttpError, FUNCTION_ERR, isForgePlatformError, isHostedCodeError, isExpectedError } from './api/errors';
|
|
109
108
|
export { i18n, type TranslationFunction } from './api/i18n';
|
|
109
|
+
export { permissions } from './api/permissions';
|
|
110
110
|
//# sourceMappingURL=index.d.ts.map
|
package/out/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8C,QAAQ,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAExG,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACtH,OAAO,EAAE,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8C,QAAQ,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAExG,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACtH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAe,cAAc,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAK7G,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,eAAe,CAAC;IAC9C,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC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,EAAE,MAAM,eAAe,CAAC;AAC7G,OAAO,EACL,wBAAwB,EACxB,+BAA+B,EAC/B,iBAAiB,EACjB,UAAU,EACV,+BAA+B,EAC/B,8BAA8B,EAC9B,6BAA6B,EAC7B,eAAe,EACf,8BAA8B,EAC9B,SAAS,EACT,YAAY,EACZ,oBAAoB,EACpB,iBAAiB,EACjB,eAAe,EAChB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,IAAI,EAAE,KAAK,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAE5D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC"}
|
package/out/index.js
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.i18n = exports.isExpectedError = exports.isHostedCodeError = exports.isForgePlatformError = exports.FUNCTION_ERR = exports.HttpError = exports.InvalidWorkspaceRequestedError = exports.NotAllowedError = exports.RequestProductNotAllowedError = exports.ProductEndpointNotAllowedError = exports.ExternalEndpointNotAllowedError = exports.FetchError = exports.ProxyRequestError = exports.NeedsAuthenticationError = exports.bindInvocationContext = exports.__getRuntime = exports.getAppContext = exports.routeFromAbsolute = exports.assumeTrustedRoute = exports.route = exports.SortOrder = exports.FilterConditions = exports.WhereConditions = exports.startsWith = exports.createRequestStargateAsApp = exports.__fetchProduct = exports.__requestAtlassianAsUser = exports.__requestAtlassianAsApp = exports.webTrigger = exports.storage = exports.invokeService = exports.invokeRemote = exports.requestBitbucket = exports.requestConfluence = exports.requestJira = exports.fetch = exports.authorize = exports.asApp = exports.asUser = exports.privacy = void 0;
|
|
3
|
+
exports.permissions = exports.i18n = exports.isExpectedError = exports.isHostedCodeError = exports.isForgePlatformError = exports.FUNCTION_ERR = exports.HttpError = exports.InvalidWorkspaceRequestedError = exports.NotAllowedError = exports.RequestProductNotAllowedError = exports.ProductEndpointNotAllowedError = exports.ExternalEndpointNotAllowedError = exports.FetchError = exports.ProxyRequestError = exports.NeedsAuthenticationError = exports.bindInvocationContext = exports.__getRuntime = exports.getAppContext = exports.routeFromAbsolute = exports.assumeTrustedRoute = exports.route = exports.SortOrder = exports.FilterConditions = exports.WhereConditions = exports.startsWith = exports.createRequestStargateAsApp = exports.__fetchProduct = exports.__requestAtlassianAsUser = exports.__requestAtlassianAsApp = exports.webTrigger = exports.storage = exports.invokeService = exports.invokeRemote = exports.requestBitbucket = exports.requestConfluence = exports.requestJira = exports.fetch = exports.authorize = exports.asApp = exports.asUser = exports.privacy = void 0;
|
|
4
4
|
const storage_1 = require("@forge/storage");
|
|
5
5
|
const authorization_1 = require("./authorization");
|
|
6
6
|
Object.defineProperty(exports, "authorize", { enumerable: true, get: function () { return authorization_1.authorize; } });
|
|
7
7
|
const privacy_1 = require("./privacy");
|
|
8
8
|
const webTrigger_1 = require("./webTrigger");
|
|
9
9
|
Object.defineProperty(exports, "webTrigger", { enumerable: true, get: function () { return webTrigger_1.webTrigger; } });
|
|
10
|
-
const
|
|
11
|
-
Object.defineProperty(exports, "invokeRemote", { enumerable: true, get: function () { return
|
|
12
|
-
|
|
13
|
-
Object.defineProperty(exports, "invokeService", { enumerable: true, get: function () { return service_1.invokeService; } });
|
|
10
|
+
const endpoint_1 = require("./api/endpoint");
|
|
11
|
+
Object.defineProperty(exports, "invokeRemote", { enumerable: true, get: function () { return endpoint_1.invokeRemote; } });
|
|
12
|
+
Object.defineProperty(exports, "invokeService", { enumerable: true, get: function () { return endpoint_1.invokeService; } });
|
|
14
13
|
const fetch_1 = require("./api/fetch");
|
|
15
14
|
Object.defineProperty(exports, "__fetchProduct", { enumerable: true, get: function () { return fetch_1.__fetchProduct; } });
|
|
16
15
|
Object.defineProperty(exports, "__requestAtlassianAsApp", { enumerable: true, get: function () { return fetch_1.__requestAtlassianAsApp; } });
|
|
@@ -33,8 +32,8 @@ const storage = (0, storage_1.getStorageInstanceWithQuery)(new storage_1.GlobalS
|
|
|
33
32
|
exports.storage = storage;
|
|
34
33
|
const API = {
|
|
35
34
|
...fetchAPI,
|
|
36
|
-
invokeRemote:
|
|
37
|
-
invokeService:
|
|
35
|
+
invokeRemote: endpoint_1.invokeRemote,
|
|
36
|
+
invokeService: endpoint_1.invokeService
|
|
38
37
|
};
|
|
39
38
|
exports.privacy = {
|
|
40
39
|
reportPersonalData: (0, privacy_1.createReportPersonalData)(fetch_1.__requestAtlassianAsApp)
|
|
@@ -71,3 +70,5 @@ Object.defineProperty(exports, "isHostedCodeError", { enumerable: true, get: fun
|
|
|
71
70
|
Object.defineProperty(exports, "isExpectedError", { enumerable: true, get: function () { return errors_1.isExpectedError; } });
|
|
72
71
|
var i18n_1 = require("./api/i18n");
|
|
73
72
|
Object.defineProperty(exports, "i18n", { enumerable: true, get: function () { return i18n_1.i18n; } });
|
|
73
|
+
var permissions_1 = require("./api/permissions");
|
|
74
|
+
Object.defineProperty(exports, "permissions", { enumerable: true, get: function () { return permissions_1.permissions; } });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forge/api",
|
|
3
|
-
"version": "6.1.
|
|
3
|
+
"version": "6.1.1-experimental-3f68b81",
|
|
4
4
|
"description": "Forge API methods",
|
|
5
5
|
"author": "Atlassian",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"@atlassian/ari": "^2.199.0",
|
|
17
17
|
"@atlassian/in-memory-metrics": "0.1.0",
|
|
18
18
|
"@atlassian/metrics-interface": "4.0.0",
|
|
19
|
-
"@forge/runtime": "6.0.3
|
|
19
|
+
"@forge/runtime": "6.0.3",
|
|
20
20
|
"@types/node": "20.19.1",
|
|
21
21
|
"@types/node-fetch": "^2.6.12",
|
|
22
22
|
"expect-type": "^0.17.3",
|
|
@@ -26,10 +26,12 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@forge/auth": "0.0.8",
|
|
29
|
-
"@forge/egress": "2.0.3
|
|
29
|
+
"@forge/egress": "2.0.3",
|
|
30
30
|
"@forge/i18n": "0.0.7",
|
|
31
|
+
"@forge/manifest": "^10.4.0-experimental-3f68b81",
|
|
31
32
|
"@forge/storage": "2.0.2",
|
|
32
|
-
"headers-utils": "^3.0.2"
|
|
33
|
+
"headers-utils": "^3.0.2",
|
|
34
|
+
"minimatch": "^9.0.5"
|
|
33
35
|
},
|
|
34
36
|
"publishConfig": {
|
|
35
37
|
"registry": "https://packages.atlassian.com/api/npm/npm-public/"
|
package/out/api/remote.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { APIResponse, RequestInit } from '../index';
|
|
2
|
-
declare type InvokeRemoteOptions = {
|
|
3
|
-
path: string;
|
|
4
|
-
};
|
|
5
|
-
export declare function invokeRemote(remoteKey: string, options: RequestInit & InvokeRemoteOptions): Promise<APIResponse>;
|
|
6
|
-
export {};
|
|
7
|
-
//# sourceMappingURL=remote.d.ts.map
|
package/out/api/remote.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"remote.d.ts","sourceRoot":"","sources":["../../src/api/remote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAIpD,aAAK,mBAAmB,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,wBAAsB,YAAY,CAChC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,WAAW,GAAG,mBAAmB,GACzC,OAAO,CAAC,WAAW,CAAC,CAqBtB"}
|
package/out/api/remote.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.invokeRemote = void 0;
|
|
4
|
-
const errors_1 = require("./errors");
|
|
5
|
-
const fetch_1 = require("./fetch");
|
|
6
|
-
async function invokeRemote(remoteKey, options) {
|
|
7
|
-
const { path, ...fetchOptions } = options;
|
|
8
|
-
if (!remoteKey) {
|
|
9
|
-
throw new Error('Missing remote key provided to invokeRemote');
|
|
10
|
-
}
|
|
11
|
-
if (!path) {
|
|
12
|
-
throw new Error('Missing or empty path provided to invokeRemote');
|
|
13
|
-
}
|
|
14
|
-
const response = await global.__forge_fetch__({
|
|
15
|
-
type: 'frc',
|
|
16
|
-
remote: remoteKey
|
|
17
|
-
}, path, fetchOptions);
|
|
18
|
-
handleResponseErrors(response, remoteKey);
|
|
19
|
-
return response;
|
|
20
|
-
}
|
|
21
|
-
exports.invokeRemote = invokeRemote;
|
|
22
|
-
function handleResponseErrors(response, remoteKey) {
|
|
23
|
-
const forgeProxyError = (0, fetch_1.getForgeProxyError)(response);
|
|
24
|
-
if (forgeProxyError === 'INVALID_REMOTE') {
|
|
25
|
-
throw new errors_1.InvalidRemoteError(`Invalid remote key provided: "${remoteKey}"`, remoteKey);
|
|
26
|
-
}
|
|
27
|
-
(0, fetch_1.handleProxyResponseErrors)(response);
|
|
28
|
-
}
|
package/out/api/service.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { APIResponse, RequestInit } from '../index';
|
|
2
|
-
declare type InvokeServiceOptions = {
|
|
3
|
-
path: string;
|
|
4
|
-
};
|
|
5
|
-
export declare function invokeService(serviceKey: string, options: RequestInit & InvokeServiceOptions): Promise<APIResponse>;
|
|
6
|
-
export {};
|
|
7
|
-
//# sourceMappingURL=service.d.ts.map
|
package/out/api/service.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/api/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAIpD,aAAK,oBAAoB,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,wBAAsB,aAAa,CACjC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,WAAW,GAAG,oBAAoB,GAC1C,OAAO,CAAC,WAAW,CAAC,CAqBtB"}
|
package/out/api/service.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.invokeService = void 0;
|
|
4
|
-
const errors_1 = require("./errors");
|
|
5
|
-
const fetch_1 = require("./fetch");
|
|
6
|
-
async function invokeService(serviceKey, options) {
|
|
7
|
-
const { path, ...fetchOptions } = options;
|
|
8
|
-
if (!serviceKey) {
|
|
9
|
-
throw new Error('Missing service key provided to invokeService');
|
|
10
|
-
}
|
|
11
|
-
if (!path) {
|
|
12
|
-
throw new Error('Missing or empty path provided to invokeService');
|
|
13
|
-
}
|
|
14
|
-
const response = await global.__forge_fetch__({
|
|
15
|
-
type: 'fcc',
|
|
16
|
-
service: serviceKey
|
|
17
|
-
}, path, fetchOptions);
|
|
18
|
-
handleResponseErrors(response, serviceKey);
|
|
19
|
-
return response;
|
|
20
|
-
}
|
|
21
|
-
exports.invokeService = invokeService;
|
|
22
|
-
function handleResponseErrors(response, serviceKey) {
|
|
23
|
-
const forgeProxyError = (0, fetch_1.getForgeProxyError)(response);
|
|
24
|
-
if (forgeProxyError === 'INVALID_SERVICE_KEY') {
|
|
25
|
-
throw new errors_1.InvalidContainerServiceError(`Invalid service key provided: "${serviceKey}"`, serviceKey);
|
|
26
|
-
}
|
|
27
|
-
(0, fetch_1.handleProxyResponseErrors)(response);
|
|
28
|
-
}
|