@forge/runtime 5.8.0-next.0 → 5.8.1-next.0
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 +12 -0
- package/out/app-manifest.js +12 -13
- package/out/context.js +6 -3
- package/out/feature-flag.d.ts +0 -1
- package/out/feature-flag.d.ts.map +1 -1
- package/out/feature-flag.js +5 -5
- package/out/limits/tracker.js +2 -2
- package/out/metrics/metrics.js +1 -0
- package/out/sandbox/inspector.js +41 -35
- package/out/sandbox/invocation-request.d.ts.map +1 -1
- package/out/sandbox/invocation-request.js +20 -18
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @forge/runtime
|
|
2
2
|
|
|
3
|
+
## 5.8.1-next.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 4e2b1a9: Remove references to unused FF
|
|
8
|
+
|
|
9
|
+
## 5.8.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- ee4e0a1: allow app developer choose location to save the bundled app code
|
|
14
|
+
|
|
3
15
|
## 5.8.0-next.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/out/app-manifest.js
CHANGED
|
@@ -45,6 +45,14 @@ const AppManifestRequiredFields = t.type({
|
|
|
45
45
|
});
|
|
46
46
|
const AppManifestType = t.intersection([AppManifestRequiredFields, AppManifestOptionalFields]);
|
|
47
47
|
class AppManifest {
|
|
48
|
+
static FILE_NAME = 'manifest.yml';
|
|
49
|
+
static async fromFile(filePath) {
|
|
50
|
+
const fullPath = path_1.default.join(filePath, AppManifest.FILE_NAME);
|
|
51
|
+
const manifestContents = (0, fs_1.readFileSync)(fullPath, 'utf-8');
|
|
52
|
+
const manifest = yaml_1.default.parse(manifestContents);
|
|
53
|
+
return new AppManifest(manifest);
|
|
54
|
+
}
|
|
55
|
+
manifest;
|
|
48
56
|
constructor(manifest) {
|
|
49
57
|
if (!AppManifestType.is(manifest)) {
|
|
50
58
|
throw new Error('invalid manifest');
|
|
@@ -53,32 +61,23 @@ class AppManifest {
|
|
|
53
61
|
this.manifest = manifest;
|
|
54
62
|
}
|
|
55
63
|
}
|
|
56
|
-
static async fromFile(filePath) {
|
|
57
|
-
const fullPath = path_1.default.join(filePath, AppManifest.FILE_NAME);
|
|
58
|
-
const manifestContents = (0, fs_1.readFileSync)(fullPath, 'utf-8');
|
|
59
|
-
const manifest = yaml_1.default.parse(manifestContents);
|
|
60
|
-
return new AppManifest(manifest);
|
|
61
|
-
}
|
|
62
64
|
getHostForRemote(remote) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
return found === null || found === void 0 ? void 0 : found.baseUrl;
|
|
65
|
+
const found = this.manifest.remotes?.find(({ key }) => key === remote);
|
|
66
|
+
return found?.baseUrl;
|
|
66
67
|
}
|
|
67
68
|
getDefaultRemoteForProvider(provider) {
|
|
68
69
|
const providerConfig = this.getExternalAuthProviderConfig(provider);
|
|
69
|
-
const remotes = providerConfig
|
|
70
|
+
const remotes = providerConfig?.remotes;
|
|
70
71
|
if (remotes && remotes.length > 0) {
|
|
71
72
|
return remotes[0];
|
|
72
73
|
}
|
|
73
74
|
return undefined;
|
|
74
75
|
}
|
|
75
76
|
getExternalAuthProviderConfig(provider) {
|
|
76
|
-
|
|
77
|
-
return (_a = this.manifest.providers) === null || _a === void 0 ? void 0 : _a.auth.find((v) => v.key === provider);
|
|
77
|
+
return this.manifest.providers?.auth.find((v) => v.key === provider);
|
|
78
78
|
}
|
|
79
79
|
getEgressAllowlist() {
|
|
80
80
|
return this.manifest.egress || [];
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
exports.AppManifest = AppManifest;
|
|
84
|
-
AppManifest.FILE_NAME = 'manifest.yml';
|
package/out/context.js
CHANGED
|
@@ -31,18 +31,21 @@ function createPrincipal(cfg) {
|
|
|
31
31
|
}
|
|
32
32
|
exports.createPrincipal = createPrincipal;
|
|
33
33
|
function createLicenseContext(cfg) {
|
|
34
|
-
var _a;
|
|
35
34
|
const { license } = cfg.meta;
|
|
36
35
|
if (license) {
|
|
37
36
|
return {
|
|
38
37
|
license: {
|
|
39
|
-
isActive:
|
|
38
|
+
isActive: license.isActive ?? false
|
|
40
39
|
}
|
|
41
40
|
};
|
|
42
41
|
}
|
|
43
42
|
}
|
|
44
43
|
exports.createLicenseContext = createLicenseContext;
|
|
45
44
|
function setupRequestContext(cfg) {
|
|
46
|
-
return
|
|
45
|
+
return {
|
|
46
|
+
principal: createPrincipal(cfg),
|
|
47
|
+
...createLicenseContext(cfg),
|
|
48
|
+
...createInstallationContext(cfg)
|
|
49
|
+
};
|
|
47
50
|
}
|
|
48
51
|
exports.setupRequestContext = setupRequestContext;
|
package/out/feature-flag.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { Metadata } from './request';
|
|
|
2
2
|
export declare const SHOULD_ATTACH_TOKEN_FOR_ATLASSIAN_ACCOUNT = "should-attach-token-for-atlassian-account";
|
|
3
3
|
export declare const SHOULD_ATTACH_TOKEN_FOR_APP = "should-attach-token-for-app";
|
|
4
4
|
export declare const XEN_RUNTIME_ENABLE_EGRESS_FILTER = "xen-runtime-enable-egress-filter";
|
|
5
|
-
export declare const XEN_RUNTIME_ENABLE_EGRESS_PROXY = "xen-runtime-enable-egress-proxy";
|
|
6
5
|
export declare const XEN_RUNTIME_EGRESS_DISCLOSURE_ENABLED = "xen-runtime-egress-disclosure-enabled";
|
|
7
6
|
export declare const XEN_RUNTIME_ENABLE_NETWORK_LIMITS = "xen-runtime-enable-network-limits";
|
|
8
7
|
export declare const XEN_RUNTIME_SHOULD_BLOCK_EXTERNAL_FETCH = "xen-runtime-should-block-external-fetch";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature-flag.d.ts","sourceRoot":"","sources":["../src/feature-flag.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAGrC,eAAO,MAAM,yCAAyC,8CAA8C,CAAC;AACrG,eAAO,MAAM,2BAA2B,gCAAgC,CAAC;AACzE,eAAO,MAAM,gCAAgC,qCAAqC,CAAC;AACnF,eAAO,MAAM
|
|
1
|
+
{"version":3,"file":"feature-flag.d.ts","sourceRoot":"","sources":["../src/feature-flag.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAGrC,eAAO,MAAM,yCAAyC,8CAA8C,CAAC;AACrG,eAAO,MAAM,2BAA2B,gCAAgC,CAAC;AACzE,eAAO,MAAM,gCAAgC,qCAAqC,CAAC;AACnF,eAAO,MAAM,qCAAqC,0CAA0C,CAAC;AAC7F,eAAO,MAAM,iCAAiC,sCAAsC,CAAC;AACrF,eAAO,MAAM,uCAAuC,4CAA4C,CAAC;AACjG,eAAO,MAAM,iCAAiC,sCAAsC,CAAC;AAErF,qBAAa,YAAY;IAIX,OAAO,CAAC,KAAK;WAHX,mBAAmB,CAAC,QAAQ,EAAE,QAAQ;gBAGhC,KAAK,EAAE,MAAM,EAAE;IAC5B,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;CAGnD"}
|
package/out/feature-flag.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FeatureFlags = exports.XEN_RUNTIME_SHOULD_REPORT_METRICS = exports.XEN_RUNTIME_SHOULD_BLOCK_EXTERNAL_FETCH = exports.XEN_RUNTIME_ENABLE_NETWORK_LIMITS = exports.XEN_RUNTIME_EGRESS_DISCLOSURE_ENABLED = exports.
|
|
3
|
+
exports.FeatureFlags = exports.XEN_RUNTIME_SHOULD_REPORT_METRICS = exports.XEN_RUNTIME_SHOULD_BLOCK_EXTERNAL_FETCH = exports.XEN_RUNTIME_ENABLE_NETWORK_LIMITS = exports.XEN_RUNTIME_EGRESS_DISCLOSURE_ENABLED = exports.XEN_RUNTIME_ENABLE_EGRESS_FILTER = exports.SHOULD_ATTACH_TOKEN_FOR_APP = exports.SHOULD_ATTACH_TOKEN_FOR_ATLASSIAN_ACCOUNT = void 0;
|
|
4
4
|
exports.SHOULD_ATTACH_TOKEN_FOR_ATLASSIAN_ACCOUNT = 'should-attach-token-for-atlassian-account';
|
|
5
5
|
exports.SHOULD_ATTACH_TOKEN_FOR_APP = 'should-attach-token-for-app';
|
|
6
6
|
exports.XEN_RUNTIME_ENABLE_EGRESS_FILTER = 'xen-runtime-enable-egress-filter';
|
|
7
|
-
exports.XEN_RUNTIME_ENABLE_EGRESS_PROXY = 'xen-runtime-enable-egress-proxy';
|
|
8
7
|
exports.XEN_RUNTIME_EGRESS_DISCLOSURE_ENABLED = 'xen-runtime-egress-disclosure-enabled';
|
|
9
8
|
exports.XEN_RUNTIME_ENABLE_NETWORK_LIMITS = 'xen-runtime-enable-network-limits';
|
|
10
9
|
exports.XEN_RUNTIME_SHOULD_BLOCK_EXTERNAL_FETCH = 'xen-runtime-should-block-external-fetch';
|
|
11
10
|
exports.XEN_RUNTIME_SHOULD_REPORT_METRICS = 'xen-runtime-should-report-metrics';
|
|
12
11
|
class FeatureFlags {
|
|
13
|
-
|
|
14
|
-
this.flags = flags;
|
|
15
|
-
}
|
|
12
|
+
flags;
|
|
16
13
|
static fromRequestMetaData(metaData) {
|
|
17
14
|
return new FeatureFlags(metaData.featureFlags || []);
|
|
18
15
|
}
|
|
16
|
+
constructor(flags) {
|
|
17
|
+
this.flags = flags;
|
|
18
|
+
}
|
|
19
19
|
isFeatureFlagEnabled(flag) {
|
|
20
20
|
return this.flags.includes(flag);
|
|
21
21
|
}
|
package/out/limits/tracker.js
CHANGED
|
@@ -6,9 +6,9 @@ exports.Limit = {
|
|
|
6
6
|
FetchRequestLimit: 'forge-fetch-request-count'
|
|
7
7
|
};
|
|
8
8
|
class PerInvocationLimitsTracker {
|
|
9
|
+
limits = {};
|
|
10
|
+
limitCount = {};
|
|
9
11
|
constructor(limits) {
|
|
10
|
-
this.limits = {};
|
|
11
|
-
this.limitCount = {};
|
|
12
12
|
this.limits = limits || {};
|
|
13
13
|
}
|
|
14
14
|
incrementCount(limitKey, by = 1) {
|
package/out/metrics/metrics.js
CHANGED
package/out/sandbox/inspector.js
CHANGED
|
@@ -62,37 +62,24 @@ function processArgForLogConsole(arg) {
|
|
|
62
62
|
}
|
|
63
63
|
const className = type === 'object' ? arg.constructor.name : undefined;
|
|
64
64
|
const subtype = inspectorSubtypeEntries.find((a) => a[1](arg));
|
|
65
|
-
return
|
|
65
|
+
return {
|
|
66
|
+
type,
|
|
67
|
+
...(className ? { className } : undefined),
|
|
68
|
+
...(subtype ? { subtype: subtype[0] } : undefined),
|
|
69
|
+
value: arg,
|
|
70
|
+
description: (0, util_1.inspect)(arg)
|
|
71
|
+
};
|
|
66
72
|
}
|
|
67
73
|
class ChromeInspector {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
wss.clients.forEach((ws) => ws.send(message));
|
|
79
|
-
};
|
|
80
|
-
this.stopSession = () => {
|
|
81
|
-
const wss = this.wss;
|
|
82
|
-
if (!wss) {
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
if (CLOSE_CONNECTION_ON_SESSION_STOP) {
|
|
86
|
-
wss.clients.forEach((ws) => ws.close());
|
|
87
|
-
}
|
|
88
|
-
const callbacks = this.callbacks;
|
|
89
|
-
if (!callbacks) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
this.callbacks = undefined;
|
|
93
|
-
callbacks.onSessionStop();
|
|
94
|
-
};
|
|
95
|
-
}
|
|
74
|
+
static DENY_CODE = 1011;
|
|
75
|
+
static DENY_REASON = 'Only one frontend is allowed';
|
|
76
|
+
static FORCE_RESET_FRONTEND_STATE_EVENTS = [
|
|
77
|
+
'{"method":"Runtime.executionContextsCleared"}',
|
|
78
|
+
'{"method":"Inspector.targetReloadedAfterCrash"}'
|
|
79
|
+
];
|
|
80
|
+
wss;
|
|
81
|
+
callbacks;
|
|
82
|
+
frontendMsgsForNewSandbox = [];
|
|
96
83
|
startServer(port = 0) {
|
|
97
84
|
const wss = new ws_1.default.Server({ port });
|
|
98
85
|
wss.on('connection', (ws) => {
|
|
@@ -203,6 +190,31 @@ class ChromeInspector {
|
|
|
203
190
|
throw Error('Unable to find port for inspector server');
|
|
204
191
|
}
|
|
205
192
|
}
|
|
193
|
+
sendMessageToFrontend = (message) => {
|
|
194
|
+
const wss = this.wss;
|
|
195
|
+
if (!wss) {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
if (VERBOSE_LOG) {
|
|
199
|
+
log('Message to frontend:\n' + message);
|
|
200
|
+
}
|
|
201
|
+
wss.clients.forEach((ws) => ws.send(message));
|
|
202
|
+
};
|
|
203
|
+
stopSession = () => {
|
|
204
|
+
const wss = this.wss;
|
|
205
|
+
if (!wss) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
if (CLOSE_CONNECTION_ON_SESSION_STOP) {
|
|
209
|
+
wss.clients.forEach((ws) => ws.close());
|
|
210
|
+
}
|
|
211
|
+
const callbacks = this.callbacks;
|
|
212
|
+
if (!callbacks) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
this.callbacks = undefined;
|
|
216
|
+
callbacks.onSessionStop();
|
|
217
|
+
};
|
|
206
218
|
forceResetFrontendState() {
|
|
207
219
|
for (const evt of ChromeInspector.FORCE_RESET_FRONTEND_STATE_EVENTS) {
|
|
208
220
|
this.sendMessageToFrontend(evt);
|
|
@@ -231,12 +243,6 @@ class ChromeInspector {
|
|
|
231
243
|
}
|
|
232
244
|
}
|
|
233
245
|
exports.ChromeInspector = ChromeInspector;
|
|
234
|
-
ChromeInspector.DENY_CODE = 1011;
|
|
235
|
-
ChromeInspector.DENY_REASON = 'Only one frontend is allowed';
|
|
236
|
-
ChromeInspector.FORCE_RESET_FRONTEND_STATE_EVENTS = [
|
|
237
|
-
'{"method":"Runtime.executionContextsCleared"}',
|
|
238
|
-
'{"method":"Inspector.targetReloadedAfterCrash"}'
|
|
239
|
-
];
|
|
240
246
|
exports.notImplementedInspector = {
|
|
241
247
|
startServer: () => {
|
|
242
248
|
throw new Error('Not implemented');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invocation-request.d.ts","sourceRoot":"","sources":["../../src/sandbox/invocation-request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,GAAG,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAGhE,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,UAAU,EAAE,QAAQ,EAAmB,MAAM,YAAY,CAAC;AAGjH,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,iBAAiB,EAAE,MAAM,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd;AAED,aAAK,KAAK,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAChC,aAAK,cAA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B,aAAa,IAAI,MAAM;IAIvB,SAAS,IAAI,KAAK;IAIlB,UAAU,IAAI,eAAe,GAAG,SAAS;IAIzC,UAAU;;;;CAGlB"}
|
|
@@ -6,10 +6,13 @@ const feature_flag_1 = require("../feature-flag");
|
|
|
6
6
|
const ari_1 = require("@forge/util/packages/ari");
|
|
7
7
|
const __1 = require("..");
|
|
8
8
|
class XenInvocationRequestImpl {
|
|
9
|
+
request;
|
|
10
|
+
invocationId;
|
|
11
|
+
featureFlags;
|
|
12
|
+
serviceTokens = [];
|
|
9
13
|
constructor(request, invocationId) {
|
|
10
14
|
this.request = request;
|
|
11
15
|
this.invocationId = invocationId;
|
|
12
|
-
this.serviceTokens = [];
|
|
13
16
|
this.serviceTokens = this.buildServiceTokens(request._meta.tokens);
|
|
14
17
|
}
|
|
15
18
|
buildServiceTokens(tokens) {
|
|
@@ -77,11 +80,7 @@ class XenInvocationRequestImpl {
|
|
|
77
80
|
return this.request._meta.appToken;
|
|
78
81
|
}
|
|
79
82
|
getProxy() {
|
|
80
|
-
|
|
81
|
-
if (!this.isFeatureFlagEnabled(feature_flag_1.XEN_RUNTIME_ENABLE_EGRESS_PROXY)) {
|
|
82
|
-
return undefined;
|
|
83
|
-
}
|
|
84
|
-
return (_a = this.request._meta) === null || _a === void 0 ? void 0 : _a.proxy;
|
|
83
|
+
return this.request._meta?.proxy;
|
|
85
84
|
}
|
|
86
85
|
getAllTokens() {
|
|
87
86
|
return this.serviceTokens;
|
|
@@ -115,12 +114,9 @@ function xenInvocationRequestFactory(invocation) {
|
|
|
115
114
|
}
|
|
116
115
|
exports.xenInvocationRequestFactory = xenInvocationRequestFactory;
|
|
117
116
|
class InvocationRequest {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
this.manifest = manifest;
|
|
122
|
-
this.thirdPartyAuthTokenReferences = this.getThirdPartyTokenReferences();
|
|
123
|
-
}
|
|
117
|
+
sandboxConfig;
|
|
118
|
+
xenInvocationRequest;
|
|
119
|
+
manifest;
|
|
124
120
|
static async setup(sandboxConfig, xenInvocationRequest) {
|
|
125
121
|
const manifest = await app_manifest_1.AppManifest.fromFile(sandboxConfig.appPath);
|
|
126
122
|
return this.setupSync(sandboxConfig, xenInvocationRequest, manifest);
|
|
@@ -128,6 +124,13 @@ class InvocationRequest {
|
|
|
128
124
|
static setupSync(sandboxConfig, xenInvocationRequest, manifest) {
|
|
129
125
|
return new InvocationRequest(sandboxConfig, xenInvocationRequest, manifest);
|
|
130
126
|
}
|
|
127
|
+
thirdPartyAuthTokenReferences;
|
|
128
|
+
constructor(sandboxConfig, xenInvocationRequest, manifest) {
|
|
129
|
+
this.sandboxConfig = sandboxConfig;
|
|
130
|
+
this.xenInvocationRequest = xenInvocationRequest;
|
|
131
|
+
this.manifest = manifest;
|
|
132
|
+
this.thirdPartyAuthTokenReferences = this.getThirdPartyTokenReferences();
|
|
133
|
+
}
|
|
131
134
|
getAppAri() {
|
|
132
135
|
return this.manifest.manifest.app.id;
|
|
133
136
|
}
|
|
@@ -225,16 +228,16 @@ class InvocationRequest {
|
|
|
225
228
|
return serviceTokens ? serviceTokens[0] : undefined;
|
|
226
229
|
}
|
|
227
230
|
getAtlassianServiceToken() {
|
|
228
|
-
var _a;
|
|
229
231
|
const atlassianTokens = this.getAllTokens(this.getAtlassianTokenServiceKey());
|
|
230
|
-
return
|
|
232
|
+
return this.pickTokenToUse(atlassianTokens)?.token;
|
|
231
233
|
}
|
|
232
234
|
getAppTokenKey() {
|
|
233
235
|
return '__atlassian-app-token';
|
|
234
236
|
}
|
|
235
237
|
getThirdPartyTokenReferenceList(serviceKey) {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
+
return (this.thirdPartyAuthTokenReferences
|
|
239
|
+
?.filter((ref) => ref.serviceKey === serviceKey)
|
|
240
|
+
.map((service) => service.reference) || []);
|
|
238
241
|
}
|
|
239
242
|
getThirdPartyTokenReferences() {
|
|
240
243
|
return this.getThirdPartyTokens().map(({ service, token }, index) => {
|
|
@@ -250,8 +253,7 @@ class InvocationRequest {
|
|
|
250
253
|
return this.getAllTokens().filter(({ service }) => service !== this.getAtlassianTokenServiceKey());
|
|
251
254
|
}
|
|
252
255
|
getThirdPartyToken(serviceKey) {
|
|
253
|
-
|
|
254
|
-
return (_b = (_a = this.thirdPartyAuthTokenReferences) === null || _a === void 0 ? void 0 : _a.find((ref) => ref.reference === serviceKey || ref.serviceKey === serviceKey)) === null || _b === void 0 ? void 0 : _b.token;
|
|
256
|
+
return this.thirdPartyAuthTokenReferences?.find((ref) => ref.reference === serviceKey || ref.serviceKey === serviceKey)?.token;
|
|
255
257
|
}
|
|
256
258
|
getAppVersion() {
|
|
257
259
|
return this.xenInvocationRequest.getAppVersion();
|