@forge/api 6.1.1-experimental-73629cc → 6.1.1-experimental-78c5fee
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 +5 -4
- package/out/api/permissions.d.ts +3 -3
- package/out/api/permissions.d.ts.map +1 -1
- package/out/api/permissions.js +77 -66
- package/out/api/runtime.d.ts +2 -0
- package/out/api/runtime.d.ts.map +1 -1
- package/out/api/runtime.js +46 -25
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
# @forge/api
|
|
2
2
|
|
|
3
|
-
## 6.1.1-experimental-
|
|
3
|
+
## 6.1.1-experimental-78c5fee
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
- Updated dependencies [
|
|
9
|
-
|
|
7
|
+
- c561a03: Added backend SDK for permission handling
|
|
8
|
+
- Updated dependencies [c561a03]
|
|
9
|
+
- Updated dependencies [2d37370]
|
|
10
|
+
- @forge/manifest@10.5.0-next.0-experimental-78c5fee
|
|
10
11
|
|
|
11
12
|
## 6.1.1
|
|
12
13
|
|
package/out/api/permissions.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PermissionRequirements, MissingPermissions } from './runtime';
|
|
1
|
+
import { PermissionRequirements, MissingPermissions, ExternalResourceType } from './runtime';
|
|
2
2
|
export declare function extractUrlString(url: string | {
|
|
3
3
|
address: string;
|
|
4
4
|
} | {
|
|
@@ -13,11 +13,11 @@ export interface PermissionResult {
|
|
|
13
13
|
export declare const hasPermission: (requirements: Partial<PermissionRequirements>) => PermissionResult;
|
|
14
14
|
export declare const hasScope: (scope: string) => boolean;
|
|
15
15
|
export declare const canFetchFrom: (type: 'backend' | 'client', url: string) => boolean;
|
|
16
|
-
export declare const canLoadResource: (type:
|
|
16
|
+
export declare const canLoadResource: (type: ExternalResourceType, url: string) => boolean;
|
|
17
17
|
export declare const permissions: {
|
|
18
18
|
hasPermission: (requirements: Partial<PermissionRequirements>) => PermissionResult;
|
|
19
19
|
hasScope: (scope: string) => boolean;
|
|
20
20
|
canFetchFrom: (type: 'backend' | 'client', url: string) => boolean;
|
|
21
|
-
canLoadResource: (type:
|
|
21
|
+
canLoadResource: (type: ExternalResourceType, url: string) => boolean;
|
|
22
22
|
};
|
|
23
23
|
//# sourceMappingURL=permissions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../src/api/permissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,sBAAsB,EACtB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../src/api/permissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,sBAAsB,EACtB,kBAAkB,EAGlB,oBAAoB,EAErB,MAAM,WAAW,CAAC;AAQnB,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAQ/F;AAeD,YAAY,EAAE,sBAAsB,EAAE,CAAC;AAKvC,YAAY,EAAE,kBAAkB,EAAE,CAAC;AAKnC,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,kBAAkB,CAAC;CAC9B;AA6HD,eAAO,MAAM,aAAa,iBAAkB,QAAQ,sBAAsB,CAAC,KAAG,gBA2C7E,CAAC;AAmBF,eAAO,MAAM,QAAQ,UAAW,MAAM,KAAG,OAaxC,CAAC;AAyBF,eAAO,MAAM,YAAY,SAAU,SAAS,GAAG,QAAQ,OAAO,MAAM,KAAG,OAiBtE,CAAC;AAyBF,eAAO,MAAM,eAAe,SAAU,oBAAoB,OAAO,MAAM,KAAG,OAiBzE,CAAC;AAKF,eAAO,MAAM,WAAW;kCApKoB,QAAQ,sBAAsB,CAAC,KAAG,gBAAgB;sBA8D9D,MAAM,KAAG,OAAO;yBAsCb,SAAS,GAAG,QAAQ,OAAO,MAAM,KAAG,OAAO;4BA0CxC,oBAAoB,OAAO,MAAM,KAAG,OAAO;CA2BhF,CAAC"}
|
package/out/api/permissions.js
CHANGED
|
@@ -19,79 +19,90 @@ function wrapInSyncMetrics(options, cb) {
|
|
|
19
19
|
metrics.counter(options.name, options.tags).incr();
|
|
20
20
|
return cb();
|
|
21
21
|
}
|
|
22
|
+
function hasMissingScopes(requiredScopes, currentlyGrantedScopes, missingPermissions) {
|
|
23
|
+
if (requiredScopes && Array.isArray(requiredScopes) && requiredScopes.length > 0) {
|
|
24
|
+
const currentGrantedScopes = Array.isArray(currentlyGrantedScopes) ? currentlyGrantedScopes : [];
|
|
25
|
+
const missingScopes = requiredScopes.filter((scope) => !currentGrantedScopes.includes(scope));
|
|
26
|
+
if (missingScopes.length > 0) {
|
|
27
|
+
missingPermissions.scopes = missingScopes;
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
function hasMissingFetchPermissions(requiredFetch, currentlyGrantedFetch, missingPermissions) {
|
|
34
|
+
if (!requiredFetch) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
let hasMissing = false;
|
|
38
|
+
const fetchTypes = ['backend', 'client'];
|
|
39
|
+
for (const fetchType of fetchTypes) {
|
|
40
|
+
const requiredUrls = requiredFetch[fetchType];
|
|
41
|
+
if (requiredUrls && requiredUrls.length > 0) {
|
|
42
|
+
const missingUrls = requiredUrls.filter((requiredUrl) => {
|
|
43
|
+
const currentlyGrantedUrls = currentlyGrantedFetch?.[fetchType] ?? [];
|
|
44
|
+
const isUrlAlreadyGranted = currentlyGrantedUrls.some((currentGrantedUrl) => {
|
|
45
|
+
return (0, minimatch_1.minimatch)(extractUrlString(requiredUrl), extractUrlString(currentGrantedUrl));
|
|
46
|
+
});
|
|
47
|
+
return !isUrlAlreadyGranted;
|
|
48
|
+
});
|
|
49
|
+
if (missingUrls.length > 0) {
|
|
50
|
+
if (!missingPermissions.external) {
|
|
51
|
+
missingPermissions.external = {};
|
|
52
|
+
}
|
|
53
|
+
if (!missingPermissions.external.fetch) {
|
|
54
|
+
missingPermissions.external.fetch = {};
|
|
55
|
+
}
|
|
56
|
+
missingPermissions.external.fetch[fetchType] = missingUrls.map(extractUrlString);
|
|
57
|
+
hasMissing = true;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return hasMissing;
|
|
62
|
+
}
|
|
63
|
+
function hasMissingExternalResourceTypes(requiredExternal, currentGrantedExternal, missingPermissions) {
|
|
64
|
+
let hasMissing = false;
|
|
65
|
+
for (const type of runtime_1.EXTERNAL_RESOURCE_TYPES) {
|
|
66
|
+
const externalUrls = requiredExternal[type];
|
|
67
|
+
if (externalUrls && externalUrls.length > 0) {
|
|
68
|
+
const missingUrls = externalUrls.filter((requiredUrl) => {
|
|
69
|
+
const currentGrantedUrls = currentGrantedExternal[type] || [];
|
|
70
|
+
const isUrlAlreadyGranted = currentGrantedUrls.some((currentGrantedUrl) => {
|
|
71
|
+
return (0, minimatch_1.minimatch)(extractUrlString(requiredUrl), extractUrlString(currentGrantedUrl));
|
|
72
|
+
});
|
|
73
|
+
return !isUrlAlreadyGranted;
|
|
74
|
+
});
|
|
75
|
+
if (missingUrls.length > 0) {
|
|
76
|
+
if (!missingPermissions.external) {
|
|
77
|
+
missingPermissions.external = {};
|
|
78
|
+
}
|
|
79
|
+
missingPermissions.external[type] = missingUrls.map(extractUrlString);
|
|
80
|
+
hasMissing = true;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return hasMissing;
|
|
85
|
+
}
|
|
22
86
|
const hasPermission = (requirements) => {
|
|
23
87
|
return wrapInSyncMetrics({ name: 'api.permissions.hasPermission' }, () => {
|
|
24
88
|
if (!(0, runtime_1.arePermsAvailableInRuntime)()) {
|
|
25
|
-
throw new errors_1.ApiNotReadyError('API not ready:
|
|
89
|
+
throw new errors_1.ApiNotReadyError('API not ready: this feature is not available yet');
|
|
26
90
|
}
|
|
27
91
|
const appContext = (0, runtime_1.getAppContext)();
|
|
28
|
-
const
|
|
92
|
+
const currentlyGrantedPermissions = appContext.permissions;
|
|
29
93
|
const missingPermissions = {};
|
|
30
94
|
let hasMissingPermissions = false;
|
|
31
|
-
if (
|
|
32
|
-
|
|
33
|
-
? currentGrantedPermissions.scopes
|
|
34
|
-
: [];
|
|
35
|
-
const missingScopes = requirements.scopes.filter((scope) => !currentGrantedScopes.includes(scope));
|
|
36
|
-
if (missingScopes.length > 0) {
|
|
37
|
-
missingPermissions.scopes = missingScopes;
|
|
38
|
-
hasMissingPermissions = true;
|
|
39
|
-
}
|
|
95
|
+
if (hasMissingScopes(requirements.scopes, currentlyGrantedPermissions.scopes, missingPermissions)) {
|
|
96
|
+
hasMissingPermissions = true;
|
|
40
97
|
}
|
|
41
98
|
if (requirements.external) {
|
|
42
|
-
const { external } = requirements;
|
|
43
|
-
const
|
|
44
|
-
if (
|
|
45
|
-
|
|
46
|
-
if (external.fetch.backend && external.fetch.backend.length > 0) {
|
|
47
|
-
const missingBackend = external.fetch.backend.filter((requiredUrl) => {
|
|
48
|
-
const currentGrantedBackendUrls = currentGrantedExternal.fetch?.backend || [];
|
|
49
|
-
const isUrlAlreadyGranted = currentGrantedBackendUrls.some((currentGrantedUrl) => {
|
|
50
|
-
return (0, minimatch_1.minimatch)(extractUrlString(requiredUrl), extractUrlString(currentGrantedUrl));
|
|
51
|
-
});
|
|
52
|
-
return !isUrlAlreadyGranted;
|
|
53
|
-
});
|
|
54
|
-
if (missingBackend.length > 0) {
|
|
55
|
-
missingFetch.backend = missingBackend.map(extractUrlString);
|
|
56
|
-
hasMissingPermissions = true;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
if (external.fetch.client && external.fetch.client.length > 0) {
|
|
60
|
-
const missingClient = external.fetch.client.filter((requiredUrl) => {
|
|
61
|
-
const currentGrantedClientUrls = currentGrantedExternal.fetch?.client || [];
|
|
62
|
-
const isUrlAlreadyGranted = currentGrantedClientUrls.some((currentGrantedUrl) => {
|
|
63
|
-
return (0, minimatch_1.minimatch)(extractUrlString(requiredUrl), extractUrlString(currentGrantedUrl));
|
|
64
|
-
});
|
|
65
|
-
return !isUrlAlreadyGranted;
|
|
66
|
-
});
|
|
67
|
-
if (missingClient.length > 0) {
|
|
68
|
-
missingFetch.client = missingClient.map(extractUrlString);
|
|
69
|
-
hasMissingPermissions = true;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
if (Object.keys(missingFetch).length > 0) {
|
|
73
|
-
missingPermissions.external = { ...missingPermissions.external, fetch: missingFetch };
|
|
74
|
-
}
|
|
99
|
+
const { external: requiredExternal } = requirements;
|
|
100
|
+
const currentlyGrantedExternal = currentlyGrantedPermissions.external || {};
|
|
101
|
+
if (hasMissingFetchPermissions(requiredExternal.fetch, currentlyGrantedExternal.fetch, missingPermissions)) {
|
|
102
|
+
hasMissingPermissions = true;
|
|
75
103
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const externalUrls = external[type];
|
|
79
|
-
if (externalUrls && externalUrls.length > 0) {
|
|
80
|
-
const missingUrls = externalUrls.filter((requiredUrl) => {
|
|
81
|
-
const currentGrantedUrls = currentGrantedExternal[type] || [];
|
|
82
|
-
const isUrlAlreadyGranted = currentGrantedUrls.some((currentGrantedUrl) => {
|
|
83
|
-
return (0, minimatch_1.minimatch)(extractUrlString(requiredUrl), extractUrlString(currentGrantedUrl));
|
|
84
|
-
});
|
|
85
|
-
return !isUrlAlreadyGranted;
|
|
86
|
-
});
|
|
87
|
-
if (missingUrls.length > 0) {
|
|
88
|
-
if (!missingPermissions.external) {
|
|
89
|
-
missingPermissions.external = {};
|
|
90
|
-
}
|
|
91
|
-
missingPermissions.external[type] = missingUrls.map(extractUrlString);
|
|
92
|
-
hasMissingPermissions = true;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
104
|
+
if (hasMissingExternalResourceTypes(requiredExternal, currentlyGrantedExternal, missingPermissions)) {
|
|
105
|
+
hasMissingPermissions = true;
|
|
95
106
|
}
|
|
96
107
|
}
|
|
97
108
|
return {
|
|
@@ -106,7 +117,7 @@ exports.hasPermission = hasPermission;
|
|
|
106
117
|
const hasScope = (scope) => {
|
|
107
118
|
return wrapInSyncMetrics({ name: 'api.permissions.hasScope' }, () => {
|
|
108
119
|
if (!(0, runtime_1.arePermsAvailableInRuntime)()) {
|
|
109
|
-
throw new errors_1.ApiNotReadyError('API not ready:
|
|
120
|
+
throw new errors_1.ApiNotReadyError('API not ready: this feature is not available yet');
|
|
110
121
|
}
|
|
111
122
|
const appContext = (0, runtime_1.getAppContext)();
|
|
112
123
|
const currentScopes = appContext.permissions.scopes;
|
|
@@ -120,7 +131,7 @@ exports.hasScope = hasScope;
|
|
|
120
131
|
const canFetchFrom = (type, url) => {
|
|
121
132
|
return wrapInSyncMetrics({ name: 'api.permissions.canFetchFrom' }, () => {
|
|
122
133
|
if (!(0, runtime_1.arePermsAvailableInRuntime)()) {
|
|
123
|
-
throw new errors_1.ApiNotReadyError('API not ready:
|
|
134
|
+
throw new errors_1.ApiNotReadyError('API not ready: this feature is not available yet');
|
|
124
135
|
}
|
|
125
136
|
const appContext = (0, runtime_1.getAppContext)();
|
|
126
137
|
const grantedUrls = appContext.permissions.external?.fetch?.[type];
|
|
@@ -136,7 +147,7 @@ exports.canFetchFrom = canFetchFrom;
|
|
|
136
147
|
const canLoadResource = (type, url) => {
|
|
137
148
|
return wrapInSyncMetrics({ name: 'api.permissions.canLoadResource' }, () => {
|
|
138
149
|
if (!(0, runtime_1.arePermsAvailableInRuntime)()) {
|
|
139
|
-
throw new errors_1.ApiNotReadyError('API not ready:
|
|
150
|
+
throw new errors_1.ApiNotReadyError('API not ready: this feature is not available yet');
|
|
140
151
|
}
|
|
141
152
|
const appContext = (0, runtime_1.getAppContext)();
|
|
142
153
|
const grantedUrls = appContext.permissions.external?.[type];
|
package/out/api/runtime.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { AppAri, EnvironmentAri, InstallationAri } from './ari';
|
|
2
2
|
import { Permissions as ManifestPermissions, External as ManifestExternal, Scopes as ManifestScopes, Content1 as ManifestContent } from '@forge/manifest';
|
|
3
|
+
export declare const EXTERNAL_RESOURCE_TYPES: readonly ["fonts", "styles", "frames", "images", "media", "scripts"];
|
|
4
|
+
export declare type ExternalResourceType = (typeof EXTERNAL_RESOURCE_TYPES)[number];
|
|
3
5
|
interface Timer {
|
|
4
6
|
stop(tags?: Record<string, string>): void;
|
|
5
7
|
}
|
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;AAClH,OAAO,EACL,WAAW,IAAI,mBAAmB,EAClC,QAAQ,IAAI,gBAAgB,EAC5B,MAAM,IAAI,cAAc,EACxB,QAAQ,IAAI,eAAe,EAC5B,MAAM,iBAAiB,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;AAKzB,eAAO,MAAM,uBAAuB,sEAAuE,CAAC;AAE5G,oBAAY,oBAAoB,GAAG,CAAC,OAAO,uBAAuB,CAAC,CAAC,MAAM,CAAC,CAAC;AA4F5E,UAA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G;AAmBD,wBAAgB,0BAA0B,IAAI,OAAO,CAIpD"}
|
package/out/api/runtime.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.arePermsAvailableInRuntime = exports.bindInvocationContext = exports.wrapInMetrics = exports.getAppContext = exports.__getRuntime = exports.MissingPermissions = exports.PermissionRequirements = exports.RuntimePermissions = exports.Permissions = void 0;
|
|
3
|
+
exports.arePermsAvailableInRuntime = exports.bindInvocationContext = exports.wrapInMetrics = exports.getAppContext = exports.__getRuntime = exports.MissingPermissions = exports.PermissionRequirements = exports.RuntimePermissions = exports.Permissions = exports.EXTERNAL_RESOURCE_TYPES = void 0;
|
|
4
4
|
const errors_1 = require("./errors");
|
|
5
5
|
const ari_1 = require("./ari");
|
|
6
|
+
exports.EXTERNAL_RESOURCE_TYPES = ['fonts', 'styles', 'frames', 'images', 'media', 'scripts'];
|
|
6
7
|
function extractUrlString(item) {
|
|
7
8
|
if (typeof item === 'string') {
|
|
8
9
|
return item;
|
|
@@ -14,34 +15,54 @@ function extractUrlString(item) {
|
|
|
14
15
|
return item.remote;
|
|
15
16
|
}
|
|
16
17
|
}
|
|
18
|
+
function formatScopesSection(scopes) {
|
|
19
|
+
if (scopes && Array.isArray(scopes) && scopes.length > 0) {
|
|
20
|
+
return `Scopes: ${scopes.join(', ')}`;
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
function formatExternalSection(external) {
|
|
25
|
+
if (!external) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
const externalParts = [];
|
|
29
|
+
addFetchPermissions(external, externalParts);
|
|
30
|
+
addResourcePermissions(external, externalParts);
|
|
31
|
+
return externalParts.length > 0 ? `External: ${externalParts.join('; ')}` : null;
|
|
32
|
+
}
|
|
33
|
+
function addFetchPermissions(external, externalParts) {
|
|
34
|
+
if (!external.fetch) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (external.fetch.backend && external.fetch.backend.length > 0) {
|
|
38
|
+
const backendUrls = external.fetch.backend.map(extractUrlString).join(', ');
|
|
39
|
+
externalParts.push(`Fetch Backend: ${backendUrls}`);
|
|
40
|
+
}
|
|
41
|
+
if (external.fetch.client && external.fetch.client.length > 0) {
|
|
42
|
+
const clientUrls = external.fetch.client.map(extractUrlString).join(', ');
|
|
43
|
+
externalParts.push(`Fetch Client: ${clientUrls}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function addResourcePermissions(external, externalParts) {
|
|
47
|
+
for (const type of exports.EXTERNAL_RESOURCE_TYPES) {
|
|
48
|
+
const externalUrls = external[type];
|
|
49
|
+
if (externalUrls && externalUrls.length > 0) {
|
|
50
|
+
const capitalizedType = type.charAt(0).toUpperCase() + type.slice(1);
|
|
51
|
+
const urlList = externalUrls.map(extractUrlString).join(', ');
|
|
52
|
+
externalParts.push(`${capitalizedType}: ${urlList}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
17
56
|
class Permissions {
|
|
18
57
|
format() {
|
|
19
58
|
const parts = [];
|
|
20
|
-
|
|
21
|
-
|
|
59
|
+
const scopesSection = formatScopesSection(this.scopes);
|
|
60
|
+
if (scopesSection) {
|
|
61
|
+
parts.push(scopesSection);
|
|
22
62
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
}
|
|
63
|
+
const externalSection = formatExternalSection(this.external);
|
|
64
|
+
if (externalSection) {
|
|
65
|
+
parts.push(externalSection);
|
|
45
66
|
}
|
|
46
67
|
return parts.length > 0 ? parts.join('; ') : 'No permissions specified';
|
|
47
68
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forge/api",
|
|
3
|
-
"version": "6.1.1-experimental-
|
|
3
|
+
"version": "6.1.1-experimental-78c5fee",
|
|
4
4
|
"description": "Forge API methods",
|
|
5
5
|
"author": "Atlassian",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@forge/auth": "0.0.8",
|
|
29
29
|
"@forge/egress": "2.0.3",
|
|
30
30
|
"@forge/i18n": "0.0.7",
|
|
31
|
-
"@forge/manifest": "^10.
|
|
31
|
+
"@forge/manifest": "^10.5.0-next.0-experimental-78c5fee",
|
|
32
32
|
"@forge/storage": "2.0.2",
|
|
33
33
|
"headers-utils": "^3.0.2",
|
|
34
34
|
"minimatch": "^9.0.5"
|