@webex/webex-core 2.59.8-next.1 → 2.60.0-next.1
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/dist/config.js +1 -2
- package/dist/config.js.map +1 -1
- package/dist/credentials-config.js +1 -2
- package/dist/credentials-config.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/interceptors/auth.js +4 -3
- package/dist/interceptors/auth.js.map +1 -1
- package/dist/interceptors/default-options.js +4 -3
- package/dist/interceptors/default-options.js.map +1 -1
- package/dist/interceptors/embargo.js +4 -3
- package/dist/interceptors/embargo.js.map +1 -1
- package/dist/interceptors/network-timing.js +4 -3
- package/dist/interceptors/network-timing.js.map +1 -1
- package/dist/interceptors/payload-transformer.js +4 -3
- package/dist/interceptors/payload-transformer.js.map +1 -1
- package/dist/interceptors/rate-limit.js +4 -3
- package/dist/interceptors/rate-limit.js.map +1 -1
- package/dist/interceptors/redirect.js +4 -3
- package/dist/interceptors/redirect.js.map +1 -1
- package/dist/interceptors/request-event.js +4 -3
- package/dist/interceptors/request-event.js.map +1 -1
- package/dist/interceptors/request-logger.js +4 -3
- package/dist/interceptors/request-logger.js.map +1 -1
- package/dist/interceptors/request-timing.js +4 -3
- package/dist/interceptors/request-timing.js.map +1 -1
- package/dist/interceptors/response-logger.js +4 -3
- package/dist/interceptors/response-logger.js.map +1 -1
- package/dist/interceptors/user-agent.js +4 -3
- package/dist/interceptors/user-agent.js.map +1 -1
- package/dist/interceptors/webex-tracking-id.js +4 -3
- package/dist/interceptors/webex-tracking-id.js.map +1 -1
- package/dist/interceptors/webex-user-agent.js +4 -3
- package/dist/interceptors/webex-user-agent.js.map +1 -1
- package/dist/lib/batcher.js +2 -3
- package/dist/lib/batcher.js.map +1 -1
- package/dist/lib/constants.js +13 -0
- package/dist/lib/constants.js.map +1 -0
- package/dist/lib/credentials/credentials.js +67 -26
- package/dist/lib/credentials/credentials.js.map +1 -1
- package/dist/lib/credentials/grant-errors.js +5 -5
- package/dist/lib/credentials/grant-errors.js.map +1 -1
- package/dist/lib/credentials/scope.js +21 -2
- package/dist/lib/credentials/scope.js.map +1 -1
- package/dist/lib/credentials/token-collection.js +1 -2
- package/dist/lib/credentials/token-collection.js.map +1 -1
- package/dist/lib/credentials/token.js +9 -8
- package/dist/lib/credentials/token.js.map +1 -1
- package/dist/lib/page.js +1 -2
- package/dist/lib/page.js.map +1 -1
- package/dist/lib/services/constants.js +3 -6
- package/dist/lib/services/constants.js.map +1 -1
- package/dist/lib/services/index.js +2 -2
- package/dist/lib/services/index.js.map +1 -1
- package/dist/lib/services/interceptors/server-error.js +4 -3
- package/dist/lib/services/interceptors/server-error.js.map +1 -1
- package/dist/lib/services/interceptors/service.js +8 -5
- package/dist/lib/services/interceptors/service.js.map +1 -1
- package/dist/lib/services/metrics.js +1 -2
- package/dist/lib/services/metrics.js.map +1 -1
- package/dist/lib/services/service-catalog.js +5 -5
- package/dist/lib/services/service-catalog.js.map +1 -1
- package/dist/lib/services/service-fed-ramp.js +1 -2
- package/dist/lib/services/service-fed-ramp.js.map +1 -1
- package/dist/lib/services/service-host.js +1 -2
- package/dist/lib/services/service-host.js.map +1 -1
- package/dist/lib/services/service-registry.js +3 -4
- package/dist/lib/services/service-registry.js.map +1 -1
- package/dist/lib/services/service-state.js +1 -2
- package/dist/lib/services/service-state.js.map +1 -1
- package/dist/lib/services/service-url.js +1 -2
- package/dist/lib/services/service-url.js.map +1 -1
- package/dist/lib/services/services.js +6 -9
- package/dist/lib/services/services.js.map +1 -1
- package/dist/lib/stateless-webex-plugin.js +1 -2
- package/dist/lib/stateless-webex-plugin.js.map +1 -1
- package/dist/lib/storage/decorators.js.map +1 -1
- package/dist/lib/storage/errors.js +5 -5
- package/dist/lib/storage/errors.js.map +1 -1
- package/dist/lib/storage/make-webex-plugin-store.js.map +1 -1
- package/dist/lib/storage/make-webex-store.js.map +1 -1
- package/dist/lib/storage/memory-store-adapter.js +1 -2
- package/dist/lib/storage/memory-store-adapter.js.map +1 -1
- package/dist/lib/webex-core-plugin-mixin.js.map +1 -1
- package/dist/lib/webex-http-error.js +4 -3
- package/dist/lib/webex-http-error.js.map +1 -1
- package/dist/lib/webex-internal-core-plugin-mixin.js.map +1 -1
- package/dist/lib/webex-plugin.js +1 -2
- package/dist/lib/webex-plugin.js.map +1 -1
- package/dist/plugins/logger.js +2 -3
- package/dist/plugins/logger.js.map +1 -1
- package/dist/webex-core.js +13 -6
- package/dist/webex-core.js.map +1 -1
- package/dist/webex-internal-core.js +1 -2
- package/dist/webex-internal-core.js.map +1 -1
- package/package.json +14 -14
- package/src/lib/constants.js +6 -0
- package/src/lib/credentials/credentials.js +82 -40
- package/src/lib/credentials/scope.js +19 -2
- package/src/lib/services/interceptors/service.js +2 -2
- package/src/lib/services/service-catalog.js +3 -1
- package/src/webex-core.js +13 -1
- package/test/unit/spec/credentials/credentials.js +169 -13
- package/test/unit/spec/credentials/scope.js +55 -0
- package/test/unit/spec/interceptors/auth.js +3 -0
- package/test/unit/spec/services/interceptors/service.js +9 -3
- package/test/unit/spec/webex-core.js +12 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_util","_interopRequireDefault","require","_ampersandState","WebexInternalCore","AmpState","extend","derived","ready","deps","fn","_this","_keys","default","_children","reduce","name","inspect","depth","util","serialize","props","session","_default","exports"],"sources":["webex-internal-core.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport util from 'util';\n\nimport AmpState from 'ampersand-state';\n\n/**\n * WebexInternalCore is an extra layer of nesting to make it blatantly clear that\n * private plugins are, in fact, private.\n * @class\n */\nconst WebexInternalCore = AmpState.extend({\n derived: {\n ready: {\n deps: [],\n fn() {\n return Object.keys(this._children).reduce(\n (ready, name) => ready && this[name] && this[name].ready !== false,\n true\n );\n },\n },\n },\n\n /**\n * @instance\n * @memberof WebexPlugin\n * @param {number} depth\n * @private\n * @returns {Object}\n */\n inspect(depth) {\n return util.inspect(\n this.serialize({\n props: true,\n session: true,\n derived: true,\n }),\n {depth}\n );\n },\n});\n\nexport default WebexInternalCore;\n"],"mappings":";;;;;;;;;AAIA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,eAAA,GAAAF,sBAAA,CAAAC,OAAA;AANA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA,IAAME,iBAAiB,GAAGC,uBAAQ,CAACC,MAAM,CAAC;EACxCC,OAAO,EAAE;IACPC,KAAK,EAAE;MACLC,IAAI,EAAE,EAAE;MACRC,EAAE,WAAAA,GAAA,EAAG;QAAA,IAAAC,KAAA;QACH,OAAO,IAAAC,KAAA,CAAAC,OAAA,EAAY,IAAI,CAACC,SAAS,CAAC,CAACC,MAAM,CACvC,UAACP,KAAK,EAAEQ,IAAI;UAAA,OAAKR,KAAK,IAAIG,KAAI,CAACK,IAAI,CAAC,IAAIL,KAAI,CAACK,IAAI,CAAC,CAACR,KAAK,KAAK,KAAK;QAAA,GAClE,
|
|
1
|
+
{"version":3,"names":["_util","_interopRequireDefault","require","_ampersandState","WebexInternalCore","AmpState","extend","derived","ready","deps","fn","_this","_keys","default","_children","reduce","name","inspect","depth","util","serialize","props","session","_default","exports"],"sources":["webex-internal-core.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport util from 'util';\n\nimport AmpState from 'ampersand-state';\n\n/**\n * WebexInternalCore is an extra layer of nesting to make it blatantly clear that\n * private plugins are, in fact, private.\n * @class\n */\nconst WebexInternalCore = AmpState.extend({\n derived: {\n ready: {\n deps: [],\n fn() {\n return Object.keys(this._children).reduce(\n (ready, name) => ready && this[name] && this[name].ready !== false,\n true\n );\n },\n },\n },\n\n /**\n * @instance\n * @memberof WebexPlugin\n * @param {number} depth\n * @private\n * @returns {Object}\n */\n inspect(depth) {\n return util.inspect(\n this.serialize({\n props: true,\n session: true,\n derived: true,\n }),\n {depth}\n );\n },\n});\n\nexport default WebexInternalCore;\n"],"mappings":";;;;;;;;;AAIA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,eAAA,GAAAF,sBAAA,CAAAC,OAAA;AANA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA,IAAME,iBAAiB,GAAGC,uBAAQ,CAACC,MAAM,CAAC;EACxCC,OAAO,EAAE;IACPC,KAAK,EAAE;MACLC,IAAI,EAAE,EAAE;MACRC,EAAE,WAAAA,GAAA,EAAG;QAAA,IAAAC,KAAA;QACH,OAAO,IAAAC,KAAA,CAAAC,OAAA,EAAY,IAAI,CAACC,SAAS,CAAC,CAACC,MAAM,CACvC,UAACP,KAAK,EAAEQ,IAAI;UAAA,OAAKR,KAAK,IAAIG,KAAI,CAACK,IAAI,CAAC,IAAIL,KAAI,CAACK,IAAI,CAAC,CAACR,KAAK,KAAK,KAAK;QAAA,GAClE,IACF,CAAC;MACH;IACF;EACF,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;AACA;EACES,OAAO,WAAAA,QAACC,KAAK,EAAE;IACb,OAAOC,aAAI,CAACF,OAAO,CACjB,IAAI,CAACG,SAAS,CAAC;MACbC,KAAK,EAAE,IAAI;MACXC,OAAO,EAAE,IAAI;MACbf,OAAO,EAAE;IACX,CAAC,CAAC,EACF;MAACW,KAAK,EAALA;IAAK,CACR,CAAC;EACH;AACF,CAAC,CAAC;AAAC,IAAAK,QAAA,GAAAC,OAAA,CAAAX,OAAA,GAEYT,iBAAiB"}
|
package/package.json
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"directory": "packages/@webex/webex-core"
|
|
21
21
|
},
|
|
22
22
|
"engines": {
|
|
23
|
-
"node": ">=
|
|
23
|
+
"node": ">=16"
|
|
24
24
|
},
|
|
25
25
|
"browserify": {
|
|
26
26
|
"transform": [
|
|
@@ -35,12 +35,12 @@
|
|
|
35
35
|
"@webex/eslint-config-legacy": "^0.0.0",
|
|
36
36
|
"@webex/jest-config-legacy": "^0.0.0",
|
|
37
37
|
"@webex/legacy-tools": "^0.0.0",
|
|
38
|
-
"@webex/test-helper-chai": "^2.
|
|
39
|
-
"@webex/test-helper-make-local-url": "^2.
|
|
40
|
-
"@webex/test-helper-mocha": "^2.
|
|
41
|
-
"@webex/test-helper-mock-webex": "^2.
|
|
42
|
-
"@webex/test-helper-refresh-callback": "^2.
|
|
43
|
-
"@webex/test-helper-test-users": "^2.
|
|
38
|
+
"@webex/test-helper-chai": "^2.60.0-next.1",
|
|
39
|
+
"@webex/test-helper-make-local-url": "^2.60.0-next.1",
|
|
40
|
+
"@webex/test-helper-mocha": "^2.60.0-next.1",
|
|
41
|
+
"@webex/test-helper-mock-webex": "^2.60.0-next.1",
|
|
42
|
+
"@webex/test-helper-refresh-callback": "^2.60.0-next.1",
|
|
43
|
+
"@webex/test-helper-test-users": "^2.60.0-next.1",
|
|
44
44
|
"chai": "^4.3.4",
|
|
45
45
|
"chai-as-promised": "^7.1.1",
|
|
46
46
|
"eslint": "^8.24.0",
|
|
@@ -48,12 +48,12 @@
|
|
|
48
48
|
"sinon": "^9.2.4"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@webex/common": "^2.
|
|
52
|
-
"@webex/common-timers": "^2.
|
|
53
|
-
"@webex/http-core": "^2.
|
|
54
|
-
"@webex/internal-plugin-device": "^2.
|
|
55
|
-
"@webex/plugin-logger": "^2.
|
|
56
|
-
"@webex/storage-adapter-spec": "^2.
|
|
51
|
+
"@webex/common": "^2.60.0-next.1",
|
|
52
|
+
"@webex/common-timers": "^2.60.0-next.1",
|
|
53
|
+
"@webex/http-core": "^2.60.0-next.1",
|
|
54
|
+
"@webex/internal-plugin-device": "^2.60.0-next.1",
|
|
55
|
+
"@webex/plugin-logger": "^2.60.0-next.1",
|
|
56
|
+
"@webex/storage-adapter-spec": "^2.60.0-next.1",
|
|
57
57
|
"ampersand-collection": "^2.0.2",
|
|
58
58
|
"ampersand-events": "^2.0.2",
|
|
59
59
|
"ampersand-state": "^5.0.3",
|
|
@@ -73,5 +73,5 @@
|
|
|
73
73
|
"test:style": "eslint ./src/**/*.*",
|
|
74
74
|
"test:unit": "webex-legacy-tools test --unit --runner jest"
|
|
75
75
|
},
|
|
76
|
-
"version": "2.
|
|
76
|
+
"version": "2.60.0-next.1"
|
|
77
77
|
}
|
|
@@ -13,10 +13,11 @@ import {clone, cloneDeep, isObject, isEmpty} from 'lodash';
|
|
|
13
13
|
import WebexPlugin from '../webex-plugin';
|
|
14
14
|
import {persist, waitForValue} from '../storage/decorators';
|
|
15
15
|
|
|
16
|
-
import grantErrors from './grant-errors';
|
|
17
|
-
import {filterScope, sortScope} from './scope';
|
|
16
|
+
import grantErrors, {OAuthError} from './grant-errors';
|
|
17
|
+
import {filterScope, diffScopes, sortScope} from './scope';
|
|
18
18
|
import Token from './token';
|
|
19
19
|
import TokenCollection from './token-collection';
|
|
20
|
+
import {METRICS} from '../constants';
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* @class
|
|
@@ -48,6 +49,25 @@ const Credentials = WebexPlugin.extend({
|
|
|
48
49
|
return Boolean(this.supertoken && this.supertoken.canRefresh);
|
|
49
50
|
},
|
|
50
51
|
},
|
|
52
|
+
isUnverifiedGuest: {
|
|
53
|
+
deps: ['supertoken'],
|
|
54
|
+
/**
|
|
55
|
+
* Returns true if the user is an unverified guest
|
|
56
|
+
* @returns {boolean}
|
|
57
|
+
*/
|
|
58
|
+
fn() {
|
|
59
|
+
let isGuest = false;
|
|
60
|
+
try {
|
|
61
|
+
isGuest =
|
|
62
|
+
JSON.parse(base64.decode(this.supertoken.access_token.split('.')[1])).user_type ===
|
|
63
|
+
'guest';
|
|
64
|
+
} catch {
|
|
65
|
+
/* the non-guest token is formatted differently so catch is expected */
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return isGuest;
|
|
69
|
+
},
|
|
70
|
+
},
|
|
51
71
|
},
|
|
52
72
|
|
|
53
73
|
props: {
|
|
@@ -240,8 +260,15 @@ const Credentials = WebexPlugin.extend({
|
|
|
240
260
|
*/
|
|
241
261
|
downscope(scope) {
|
|
242
262
|
return this.supertoken.downscope(scope).catch((reason) => {
|
|
243
|
-
|
|
263
|
+
const failReason = reason?.body ?? reason;
|
|
264
|
+
this.logger.warn(`credentials: failed to downscope supertoken to "${scope}"`, failReason);
|
|
244
265
|
this.logger.trace(`credentials: falling back to supertoken for ${scope}`);
|
|
266
|
+
this.webex.internal.metrics.submitClientMetrics(METRICS.JS_SDK_CREDENTIALS_DOWNSCOPE_FAILED, {
|
|
267
|
+
fields: {
|
|
268
|
+
requestedScope: scope,
|
|
269
|
+
failReason,
|
|
270
|
+
},
|
|
271
|
+
});
|
|
245
272
|
|
|
246
273
|
return Promise.resolve(new Token({scope, ...this.supertoken.serialize()}), {
|
|
247
274
|
parent: this,
|
|
@@ -322,12 +349,12 @@ const Credentials = WebexPlugin.extend({
|
|
|
322
349
|
}
|
|
323
350
|
|
|
324
351
|
if (!scope) {
|
|
325
|
-
scope = filterScope('spark:kms', this.
|
|
352
|
+
scope = filterScope('spark:kms', this.supertoken.scope);
|
|
326
353
|
}
|
|
327
354
|
|
|
328
355
|
scope = sortScope(scope);
|
|
329
356
|
|
|
330
|
-
if (scope === sortScope(this.
|
|
357
|
+
if (scope === sortScope(this.supertoken.scope)) {
|
|
331
358
|
return Promise.resolve(this.supertoken);
|
|
332
359
|
}
|
|
333
360
|
|
|
@@ -477,42 +504,10 @@ const Credentials = WebexPlugin.extend({
|
|
|
477
504
|
|
|
478
505
|
return supertoken
|
|
479
506
|
.refresh()
|
|
480
|
-
.then((st) => {
|
|
481
|
-
// clear refresh timer
|
|
482
|
-
if (this.refreshTimer) {
|
|
483
|
-
clearTimeout(this.refreshTimer);
|
|
484
|
-
this.unset('refreshTimer');
|
|
485
|
-
}
|
|
486
|
-
this.supertoken = st;
|
|
487
|
-
|
|
488
|
-
return Promise.all(
|
|
489
|
-
tokens.map((token) =>
|
|
490
|
-
this.downscope(token.scope)
|
|
491
|
-
// eslint-disable-next-line max-nested-callbacks
|
|
492
|
-
.then((t) => {
|
|
493
|
-
this.logger.info(`credentials: revoking token for ${token.scope}`);
|
|
494
|
-
|
|
495
|
-
return token
|
|
496
|
-
.revoke()
|
|
497
|
-
.catch((err) => {
|
|
498
|
-
this.logger.warn('credentials: failed to revoke user token', err);
|
|
499
|
-
})
|
|
500
|
-
.then(() => {
|
|
501
|
-
this.userTokens.remove(token.scope);
|
|
502
|
-
this.userTokens.add(t);
|
|
503
|
-
});
|
|
504
|
-
})
|
|
505
|
-
)
|
|
506
|
-
);
|
|
507
|
-
})
|
|
508
|
-
.then(() => {
|
|
509
|
-
this.scheduleRefresh(this.supertoken.expires);
|
|
510
|
-
})
|
|
511
507
|
.catch((error) => {
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
// Error: The refresh token provided is expired, revoked, malformed, or invalid. Hence emit an event to the client, an opportunity to logout.
|
|
508
|
+
if (error instanceof OAuthError) {
|
|
509
|
+
// Error: super token refresh failed with 400 status code.
|
|
510
|
+
// Hence emit an event to the client, an opportunity to logout.
|
|
516
511
|
this.unset('supertoken');
|
|
517
512
|
while (this.userTokens.models.length) {
|
|
518
513
|
try {
|
|
@@ -525,6 +520,53 @@ const Credentials = WebexPlugin.extend({
|
|
|
525
520
|
}
|
|
526
521
|
|
|
527
522
|
return Promise.reject(error);
|
|
523
|
+
})
|
|
524
|
+
.then((st) => {
|
|
525
|
+
// clear refresh timer
|
|
526
|
+
if (this.refreshTimer) {
|
|
527
|
+
clearTimeout(this.refreshTimer);
|
|
528
|
+
this.unset('refreshTimer');
|
|
529
|
+
}
|
|
530
|
+
this.supertoken = st;
|
|
531
|
+
|
|
532
|
+
const invalidScopes = diffScopes(this.config.scope, st.scope);
|
|
533
|
+
|
|
534
|
+
if (invalidScopes !== '') {
|
|
535
|
+
this.logger.warn(
|
|
536
|
+
`credentials: "${invalidScopes}" scope(s) are invalid because not listed in the supertoken, they will be excluded from user token requests.`
|
|
537
|
+
);
|
|
538
|
+
this.webex.internal.metrics.submitClientMetrics(
|
|
539
|
+
METRICS.JS_SDK_CREDENTIALS_TOKEN_REFRESH_SCOPE_MISMATCH,
|
|
540
|
+
{fields: {invalidScopes}}
|
|
541
|
+
);
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
return Promise.all(
|
|
545
|
+
tokens.map((token) => {
|
|
546
|
+
const tokenScope = filterScope(diffScopes(token.scope, st.scope), token.scope);
|
|
547
|
+
|
|
548
|
+
return (
|
|
549
|
+
this.downscope(tokenScope)
|
|
550
|
+
// eslint-disable-next-line max-nested-callbacks
|
|
551
|
+
.then((t) => {
|
|
552
|
+
this.logger.info(`credentials: revoking token for ${token.scope}`);
|
|
553
|
+
|
|
554
|
+
return token
|
|
555
|
+
.revoke()
|
|
556
|
+
.catch((err) => {
|
|
557
|
+
this.logger.warn('credentials: failed to revoke user token', err);
|
|
558
|
+
})
|
|
559
|
+
.then(() => {
|
|
560
|
+
this.userTokens.remove(token.scope);
|
|
561
|
+
this.userTokens.add(t);
|
|
562
|
+
});
|
|
563
|
+
})
|
|
564
|
+
);
|
|
565
|
+
})
|
|
566
|
+
);
|
|
567
|
+
})
|
|
568
|
+
.then(() => {
|
|
569
|
+
this.scheduleRefresh(this.supertoken.expires);
|
|
528
570
|
});
|
|
529
571
|
},
|
|
530
572
|
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
+
import {difference} from 'lodash';
|
|
6
|
+
|
|
5
7
|
/**
|
|
6
8
|
* sorts a list of scopes
|
|
7
9
|
* @param {string} scope
|
|
@@ -17,7 +19,7 @@ export function sortScope(scope) {
|
|
|
17
19
|
|
|
18
20
|
/**
|
|
19
21
|
* sorts a list of scopes and filters the specified scope
|
|
20
|
-
* @param {string} toFilter
|
|
22
|
+
* @param {string|string[]} toFilter
|
|
21
23
|
* @param {string} scope
|
|
22
24
|
* @returns {string}
|
|
23
25
|
*/
|
|
@@ -25,10 +27,25 @@ export function filterScope(toFilter, scope) {
|
|
|
25
27
|
if (!scope) {
|
|
26
28
|
return '';
|
|
27
29
|
}
|
|
30
|
+
const toFilterArr = Array.isArray(toFilter) ? toFilter : [toFilter];
|
|
28
31
|
|
|
29
32
|
return scope
|
|
30
33
|
.split(' ')
|
|
31
|
-
.filter((item) => item
|
|
34
|
+
.filter((item) => !toFilterArr.includes(item))
|
|
32
35
|
.sort()
|
|
33
36
|
.join(' ');
|
|
34
37
|
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Returns a string containing all items in scopeA that are not in scopeB, or an empty string if there are none.
|
|
41
|
+
*
|
|
42
|
+
* @param {string} scopeA
|
|
43
|
+
* @param {string} scopeB
|
|
44
|
+
* @returns {string}
|
|
45
|
+
*/
|
|
46
|
+
export function diffScopes(scopeA, scopeB) {
|
|
47
|
+
const a = scopeA?.split(' ') ?? [];
|
|
48
|
+
const b = scopeB?.split(' ') ?? [];
|
|
49
|
+
|
|
50
|
+
return difference(a, b).sort().join(' ');
|
|
51
|
+
}
|
|
@@ -36,11 +36,11 @@ export default class ServiceInterceptor extends Interceptor {
|
|
|
36
36
|
|
|
37
37
|
// Destructure commonly referenced namespaces.
|
|
38
38
|
const {services} = this.webex.internal;
|
|
39
|
-
const {service, resource} = options;
|
|
39
|
+
const {service, resource, waitForServiceTimeout} = options;
|
|
40
40
|
|
|
41
41
|
// Attempt to collect the service url.
|
|
42
42
|
return services
|
|
43
|
-
.waitForService({name: service})
|
|
43
|
+
.waitForService({name: service, timeout: waitForServiceTimeout})
|
|
44
44
|
.then((serviceUrl) => {
|
|
45
45
|
// Generate the combined service url and resource.
|
|
46
46
|
options.uri = this.generateUri(serviceUrl, resource);
|
|
@@ -413,6 +413,8 @@ const ServiceCatalog = AmpState.extend({
|
|
|
413
413
|
resolve();
|
|
414
414
|
}
|
|
415
415
|
|
|
416
|
+
const validatedTimeout = typeof timeout === 'number' && timeout >= 0 ? timeout : 60;
|
|
417
|
+
|
|
416
418
|
const timeoutTimer = setTimeout(
|
|
417
419
|
() =>
|
|
418
420
|
reject(
|
|
@@ -420,7 +422,7 @@ const ServiceCatalog = AmpState.extend({
|
|
|
420
422
|
`services: timeout occured while waiting for '${serviceGroup}' catalog to populate`
|
|
421
423
|
)
|
|
422
424
|
),
|
|
423
|
-
|
|
425
|
+
validatedTimeout * 1000
|
|
424
426
|
);
|
|
425
427
|
|
|
426
428
|
this.once(serviceGroup, () => {
|
package/src/webex-core.js
CHANGED
|
@@ -6,7 +6,12 @@ import {EventEmitter} from 'events';
|
|
|
6
6
|
import util from 'util';
|
|
7
7
|
|
|
8
8
|
import {proxyEvents, retry, transferEvents} from '@webex/common';
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
HttpStatusInterceptor,
|
|
11
|
+
defaults as requestDefaults,
|
|
12
|
+
protoprepareFetchOptions as prepareFetchOptions,
|
|
13
|
+
setTimingsAndFetch as _setTimingsAndFetch,
|
|
14
|
+
} from '@webex/http-core';
|
|
10
15
|
import {defaultsDeep, get, isFunction, isString, last, merge, omit, set, unset} from 'lodash';
|
|
11
16
|
import AmpState from 'ampersand-state';
|
|
12
17
|
import uuid from 'uuid';
|
|
@@ -402,6 +407,13 @@ const WebexCore = AmpState.extend({
|
|
|
402
407
|
interceptors: ints,
|
|
403
408
|
});
|
|
404
409
|
|
|
410
|
+
this.prepareFetchOptions = prepareFetchOptions({
|
|
411
|
+
json: true,
|
|
412
|
+
interceptors: ints,
|
|
413
|
+
});
|
|
414
|
+
|
|
415
|
+
this.setTimingsAndFetch = _setTimingsAndFetch;
|
|
416
|
+
|
|
405
417
|
let sessionId = `${get(this, 'config.trackingIdPrefix', 'webex-js-sdk')}_${get(
|
|
406
418
|
this,
|
|
407
419
|
'config.trackingIdBase',
|