@webex/webex-core 3.12.0-next.64 → 3.12.0-next.66
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 +7 -0
- package/dist/config.js.map +1 -1
- package/dist/lib/batcher.js +1 -1
- package/dist/lib/credentials/credentials.js +1 -1
- package/dist/lib/credentials/token.js +1 -1
- package/dist/lib/services/services.js +11 -5
- package/dist/lib/services/services.js.map +1 -1
- package/dist/lib/services-v2/services-v2.js +15 -6
- package/dist/lib/services-v2/services-v2.js.map +1 -1
- package/dist/plugins/logger.js +1 -1
- package/dist/webex-core.js +2 -2
- package/package.json +3 -3
- package/src/config.js +7 -0
- package/src/lib/services/services.js +12 -2
- package/src/lib/services-v2/docs/README.md +4 -3
- package/src/lib/services-v2/services-v2.ts +16 -3
- package/test/unit/spec/services/services.js +26 -0
- package/test/unit/spec/services-v2/services-v2.ts +121 -0
|
@@ -78,7 +78,7 @@ Related context: [repository architecture](../../../../docs/architecture.md) ·
|
|
|
78
78
|
| `src/lib/services-v2/service-catalog.ts` | The in-memory catalog: five groups, status flags, ordering, URL matching delegation, allowed domains, failover entry point |
|
|
79
79
|
| `src/lib/services-v2/service-detail.ts` | One cluster-scoped service with its ordered base URLs; priority selection and host failure marking |
|
|
80
80
|
| `src/lib/services-v2/types.ts` | Hostmap, service, service-URL, catalog and service-detail type declarations |
|
|
81
|
-
| `src/lib/services-v2/service-fed-ramp.ts` | The FedRAMP discovery
|
|
81
|
+
| `src/lib/services-v2/service-fed-ramp.ts` | The FedRAMP discovery defaults; an existing U2C discovery URL is preserved |
|
|
82
82
|
| `src/lib/services-v2/metrics.ts` | A metric-name constant file that nothing in the module imports |
|
|
83
83
|
| `src/lib/services-v2/README.md` | Existing work-in-progress note (DNSSec-oriented, "continue to use /services"), read as evidence only |
|
|
84
84
|
| `src/lib/metrics.js` | The metric names the v2 plugin actually imports |
|
|
@@ -185,7 +185,7 @@ Related context: [repository architecture](../../../../docs/architecture.md) ·
|
|
|
185
185
|
| `SV2-014` | `getServiceUrlFromClusterId({cluster})` resolves the conversation-style service for a cluster: `us` becomes the default cluster identifier (overridable via `WEBEX_CONVERSATION_DEFAULT_CLUSTER` and `WEBEX_CONVERSATION_CLUSTER_SERVICE`), an identifier with fewer than four colon-separated parts gets the service name appended, and an unresolved cluster throws `Could not find service for cluster [...]` | Hydra returns bare cluster names for non-US regions | `src/lib/services-v2/services-v2.ts` | none found | Environment variables are read once at module load; no test | Weak |
|
|
186
186
|
| `SV2-015` | `waitForService({name, url, timeout = 5})` resolves immediately with `get(servicesNotNeedValidation name)` for names in `services.servicesNotNeedValidation`; otherwise with the name's priority URL or the URL's priority URL if either is known; when `catalog.isReady` and unknown it resolves with the given `url` if any, else submits `JS_SDK_SERVICE_NOT_FOUND` and rejects; when not ready it waits on the preauth, signin and postauth groups concurrently and rejects (with the metric) only after all three waits settle without a match | Callers (notably `ServiceInterceptor`) need a URL or a definite failure without hanging forever | `src/lib/services-v2/services-v2.ts`, `src/lib/interceptors/service.js` | `test/integration/spec/services-v2/services-v2.js` | No unit test; the whole timeout is paid per call when not ready and the service is unknown | Present |
|
|
187
187
|
| `SV2-016` | `waitForCatalog(group, timeout)` on the plugin starts collection itself when the group is `postauth`, a supertoken exists and no collection is running or complete (calling `initServiceCatalogs` if preauth is not ready, else `updateServices`); otherwise it delegates to the catalog, which resolves when the group is ready or on its next event and rejects `services: timeout occured while waiting for '<group>' catalog to populate` after `timeout` seconds (60 when absent, negative or non-numeric) | Lets early callers trigger and then await the first authorized catalog | `src/lib/services-v2/services-v2.ts`, `src/lib/services-v2/service-catalog.ts` | `test/integration/spec/services-v2/service-catalog.js` | Plugin-level kick-off is untested | Present |
|
|
188
|
-
| `SV2-017` | `initConfig` (once, on first `change:config`) injects `services.discovery` and `services.override` entries as single-URL priority-1 details into their groups,
|
|
188
|
+
| `SV2-017` | `initConfig` (once, on first `change:config`) injects `services.discovery` and `services.override` entries as single-URL priority-1 details into their groups; when `fedramp` is on, applies a fresh copy of the FedRAMP defaults while preserving an existing truthy `discovery.u2c`; otherwise unions `services.allowedDomains` with the commercial allowed domains, stores allowed domains in the catalog and copies `validateDomains` | The SDK must resolve `u2c`, `hydra` and `sqdiscovery` before any hostmap exists, preserve the selected U2C seed, and trust only configured domains | `src/lib/services-v2/services-v2.ts`, `src/lib/services-v2/service-fed-ramp.ts`, `src/lib/constants.js` | `test/unit/spec/services-v2/services-v2.ts`, `test/integration/spec/services-v2/services-v2.js` | The commercial allowed-domain union is not asserted; the method mutates the config object | Present |
|
|
189
189
|
| `SV2-018` | Ungated init (default, `waitForCatalogInit` not `true`): sets `ready` to `true` immediately; on the webex `ready` event it tries a cache warm (success sets `catalog.isReady` and stops); else with a supertoken calls `initServiceCatalogs`, without one calls `collectPreauthCatalog` (with the configured email if any) unless `skipPreauthCatalogOnUnauthenticated`; failures set `initFailed` and are logged | Existing integrators keep non-blocking startup | `src/lib/services-v2/services-v2.ts` | `test/unit/spec/services-v2/services-v2.ts` | none | Present |
|
|
190
190
|
| `SV2-019` | Gated init (`waitForCatalogInit === true`): leaves `ready` false, waits for the webex `loaded` event (not `ready`, which would deadlock), then warms from cache or collects catalogs raced against `catalogInitTimeout`, and in every outcome finalizes `ready`; with no supertoken it also listens once for `change:canAuthorize` and then collects the postauth catalog if not already ready; with `skipPreauthCatalogOnUnauthenticated` it finalizes immediately without creating a timeout | `webex.ready` can then imply a populated catalog, without a hung request stalling the app indefinitely | `src/lib/services-v2/services-v2.ts`, `src/config.js`, `src/webex-core.js` | `test/unit/spec/services-v2/services-v2.ts`, `test/integration/spec/services-v2/services-v2.js` | `waitForCatalogInit` has no default in config (absent means off) | Present |
|
|
191
191
|
| `SV2-020` | `_finalizeReady` awaits one `change:isRefreshing` event when `credentials.isRefreshing` is true, then sets `ready`; `_makeInitTimeout` rejects with `services: init timed out after <ms>ms` | A credential refresh in flight must settle before the app is told it is ready | `src/lib/services-v2/services-v2.ts` | `test/unit/spec/services-v2/services-v2.ts` | The init-timeout timer is never cleared after the race settles | Present |
|
|
@@ -686,6 +686,7 @@ stateDiagram-v2
|
|
|
686
686
|
- **`invalidateCache` swallows nothing:** it does not await or catch `initServiceCatalogs(true)`, so its rejection is unhandled while the method returns a resolved promise.
|
|
687
687
|
- **`internal.metrics` is dereferenced unguarded** in `waitForService` when a service is not found; a webex instance without the metrics plugin throws a `TypeError` instead of the intended rejection.
|
|
688
688
|
- **Config is read once** (`initConfig` on the first `change:config`) and mutates the config object (discovery replacement under FedRAMP and the allowed-domain union). `fedramp` defaults to the raw value of `ENABLE_FEDRAMP` (a string when set).
|
|
689
|
+
- **FedRAMP preserves an existing U2C seed, not its provenance.** Both standard FedRAMP and DNSSEC U2C URLs are accepted without hostname-specific selection. `undefined`, `null`, and the empty string fall back to the FedRAMP default; any existing truthy value, including an SDK-merged commercial default, is retained. Callers are responsible for supplying the correct environment's U2C URL. Other discovery entries still use the FedRAMP defaults, and higher-priority catalogs can replace the discovery seed during normal service resolution. This rule applies to v2 only; v1 is unchanged.
|
|
689
690
|
- **Only one slash is stripped** by the trailing-slash expression (no global flag), as in v1.
|
|
690
691
|
|
|
691
692
|
## Module-specific rules
|
|
@@ -730,7 +731,7 @@ No design record states why two parallel implementations are maintained; the cod
|
|
|
730
731
|
| `SV2-011`, `SV2-012`, `INV-V2-001` | Unit, integration | `test/unit/spec/services-v2/service-catalog.ts`, `test/unit/spec/services-v2/services-v2.ts`, `test/unit/spec/interceptors/auth.js` | `test/unit/spec/services-v2/service-catalog.ts` (look-alike hosts, prefix without boundary, unparsable) | none |
|
|
731
732
|
| `SV2-014` | none | none found | none found | `getServiceUrlFromClusterId` untested |
|
|
732
733
|
| `SV2-015`, `SV2-016` | Integration | `test/integration/spec/services-v2/services-v2.js`, `test/integration/spec/services-v2/service-catalog.js` | The same files (missing service, timeout) | No unit test of `waitForService`; `servicesNotNeedValidation` shortcut and plugin kick-off untested; leaked timer unasserted |
|
|
733
|
-
| `SV2-017` |
|
|
734
|
+
| `SV2-017` | Unit, integration | `test/unit/spec/services-v2/services-v2.ts`, `test/integration/spec/services-v2/services-v2.js` | Unit tests cover old/new/custom/commercial U2C preservation, missing or empty U2C fallback, commercial discovery, and instance isolation | Commercial allowed-domain union unasserted |
|
|
734
735
|
| `SV2-018`, `SV2-019`, `SV2-020`, `SV2-021`, `INV-V2-007` | Unit | `test/unit/spec/services-v2/services-v2.ts` | `test/unit/spec/services-v2/services-v2.ts` (errors, timeout, refresh wait, skip preauth, no stray timer) | Real timers not exercised |
|
|
735
736
|
| `SV2-022`, `SV2-023`, `INV-V2-008` | Unit | `test/unit/spec/services-v2/services-v2.ts` | `test/unit/spec/services-v2/services-v2.ts` (proximity mode, selection mismatch, environment mismatch) | TTL expiry, org mismatch, flag off, storage exceptions, `clearCatalogCache`, and the missing rehydration of plugin maps are untested |
|
|
736
737
|
| `SV2-024` | Unit, integration | `test/unit/spec/services-v2/services-v2.ts`, `test/integration/spec/services-v2/services-v2.js` | `test/unit/spec/services-v2/services-v2.ts` (older, equal, non-numeric and null timestamps) | Unhandled rejection of the unawaited refetch untested |
|
|
@@ -218,13 +218,23 @@ const Services = WebexPlugin.extend({
|
|
|
218
218
|
},
|
|
219
219
|
|
|
220
220
|
/**
|
|
221
|
-
* Checks if the current environment is an integration (INT) environment
|
|
222
|
-
*
|
|
221
|
+
* Checks if the current environment is an integration (INT) environment.
|
|
222
|
+
* Uses the explicit environment config when set, otherwise examines the u2c discovery URL.
|
|
223
223
|
* INT environments use discovery URLs containing 'intb' (e.g., u2c-intb.ciscospark.com).
|
|
224
224
|
* @returns {boolean} True if INT environment, false otherwise
|
|
225
225
|
*/
|
|
226
226
|
isIntegrationEnvironment(): boolean {
|
|
227
227
|
try {
|
|
228
|
+
const configuredEnvironment = this.webex?.config?.environment;
|
|
229
|
+
|
|
230
|
+
if (configuredEnvironment !== undefined) {
|
|
231
|
+
const isIntFromConfig = configuredEnvironment === 'integration';
|
|
232
|
+
|
|
233
|
+
this.logger.info(`services: isIntegrationEnvironment: ${isIntFromConfig} (config)`);
|
|
234
|
+
|
|
235
|
+
return isIntFromConfig;
|
|
236
|
+
}
|
|
237
|
+
|
|
228
238
|
const u2cUrl = this.webex?.config?.services?.discovery?.u2c || '';
|
|
229
239
|
const isInt = u2cUrl.includes('intb');
|
|
230
240
|
|
|
@@ -1286,7 +1296,10 @@ const Services = WebexPlugin.extend({
|
|
|
1286
1296
|
// Validate that the services configuration exists.
|
|
1287
1297
|
if (services) {
|
|
1288
1298
|
if (fedramp) {
|
|
1289
|
-
services.discovery =
|
|
1299
|
+
services.discovery = {
|
|
1300
|
+
...fedRampServices,
|
|
1301
|
+
u2c: services.discovery?.u2c || fedRampServices.u2c,
|
|
1302
|
+
};
|
|
1290
1303
|
}
|
|
1291
1304
|
// Check for discovery services.
|
|
1292
1305
|
if (services.discovery) {
|
|
@@ -1361,6 +1361,32 @@ describe('webex-core', () => {
|
|
|
1361
1361
|
});
|
|
1362
1362
|
|
|
1363
1363
|
describe('#isIntegrationEnvironment', () => {
|
|
1364
|
+
it('uses the integration environment config when set, regardless of the u2c URL', () => {
|
|
1365
|
+
services.webex.config = {
|
|
1366
|
+
environment: 'integration',
|
|
1367
|
+
services: {
|
|
1368
|
+
discovery: {
|
|
1369
|
+
u2c: 'https://u2c.wbx2.com/u2c/api/v1',
|
|
1370
|
+
},
|
|
1371
|
+
},
|
|
1372
|
+
};
|
|
1373
|
+
|
|
1374
|
+
assert.isTrue(services.isIntegrationEnvironment());
|
|
1375
|
+
});
|
|
1376
|
+
|
|
1377
|
+
it('uses the production environment config when set, regardless of the u2c URL', () => {
|
|
1378
|
+
services.webex.config = {
|
|
1379
|
+
environment: 'production',
|
|
1380
|
+
services: {
|
|
1381
|
+
discovery: {
|
|
1382
|
+
u2c: 'https://u2c-intb.ciscospark.com/u2c/api/v1',
|
|
1383
|
+
},
|
|
1384
|
+
},
|
|
1385
|
+
};
|
|
1386
|
+
|
|
1387
|
+
assert.isFalse(services.isIntegrationEnvironment());
|
|
1388
|
+
});
|
|
1389
|
+
|
|
1364
1390
|
it('returns true when u2c URL contains "intb"', () => {
|
|
1365
1391
|
services.webex.config = {
|
|
1366
1392
|
services: {
|
|
@@ -8,6 +8,7 @@ import sinon from 'sinon';
|
|
|
8
8
|
import {ServicesV2} from '@webex/webex-core';
|
|
9
9
|
import {NewMetrics} from '@webex/internal-plugin-metrics';
|
|
10
10
|
import {formattedServiceHostmapV2, serviceHostmapV2} from '../../../fixtures/host-catalog-v2';
|
|
11
|
+
import fedRampServices from '../../../../src/lib/services-v2/service-fed-ramp';
|
|
11
12
|
|
|
12
13
|
const waitForAsync = () =>
|
|
13
14
|
new Promise<void>((resolve) =>
|
|
@@ -33,6 +34,100 @@ describe('webex-core', () => {
|
|
|
33
34
|
catalog = services._getCatalog();
|
|
34
35
|
});
|
|
35
36
|
|
|
37
|
+
describe('#initConfig', () => {
|
|
38
|
+
it.each([
|
|
39
|
+
'https://u2c.gov.ciscospark.com/u2c/api/v1',
|
|
40
|
+
'https://u2c.svc.webexgov.us/u2c/api/v1',
|
|
41
|
+
'https://u2c.example.com/u2c/api/v1',
|
|
42
|
+
'https://u2c.wbx2.com/u2c/api/v1',
|
|
43
|
+
])('preserves the existing FedRAMP U2C discovery URL %s', (u2c) => {
|
|
44
|
+
const discovery = {
|
|
45
|
+
hydra: 'https://hydra.example.com/v1',
|
|
46
|
+
u2c,
|
|
47
|
+
sqdiscovery: 'https://region.example.com/v1/region',
|
|
48
|
+
};
|
|
49
|
+
const defaults = {...fedRampServices};
|
|
50
|
+
webex.config = {
|
|
51
|
+
fedramp: true,
|
|
52
|
+
services: {discovery, allowedDomains: ['webexgov.us'], validateDomains: true},
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
services.initConfig();
|
|
56
|
+
|
|
57
|
+
assert.deepEqual(webex.config.services.discovery, {...defaults, u2c});
|
|
58
|
+
assert.strictEqual(services.get('u2c', 'discovery'), u2c);
|
|
59
|
+
assert.strictEqual(services.get('hydra', 'discovery'), defaults.hydra);
|
|
60
|
+
assert.strictEqual(services.get('sqdiscovery', 'discovery'), defaults.sqdiscovery);
|
|
61
|
+
assert.notStrictEqual(webex.config.services.discovery, fedRampServices);
|
|
62
|
+
assert.deepEqual(fedRampServices, defaults);
|
|
63
|
+
assert.deepEqual(catalog.getAllowedDomains(), ['webexgov.us']);
|
|
64
|
+
assert.isTrue(services.validateDomains);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it.each([undefined, null, {}, {u2c: undefined}, {u2c: null}, {u2c: ''}])(
|
|
68
|
+
'uses the FedRAMP defaults when discovery has no U2C URL: %p',
|
|
69
|
+
(discovery) => {
|
|
70
|
+
webex.config = {
|
|
71
|
+
fedramp: true,
|
|
72
|
+
services: {discovery, allowedDomains: [], validateDomains: true},
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
services.initConfig();
|
|
76
|
+
|
|
77
|
+
assert.deepEqual(webex.config.services.discovery, fedRampServices);
|
|
78
|
+
assert.strictEqual(services.get('u2c', 'discovery'), fedRampServices.u2c);
|
|
79
|
+
assert.notStrictEqual(webex.config.services.discovery, fedRampServices);
|
|
80
|
+
}
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
it('leaves commercial discovery configuration unchanged', () => {
|
|
84
|
+
const discovery = {
|
|
85
|
+
hydra: 'https://api.ciscospark.com/v1',
|
|
86
|
+
u2c: 'https://u2c.wbx2.com/u2c/api/v1',
|
|
87
|
+
sqdiscovery: 'https://ds.ciscospark.com/v1/region',
|
|
88
|
+
};
|
|
89
|
+
webex.config = {
|
|
90
|
+
fedramp: false,
|
|
91
|
+
services: {discovery, allowedDomains: [], validateDomains: true},
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
services.initConfig();
|
|
95
|
+
|
|
96
|
+
assert.strictEqual(webex.config.services.discovery, discovery);
|
|
97
|
+
assert.strictEqual(services.get('u2c', 'discovery'), discovery.u2c);
|
|
98
|
+
assert.strictEqual(services.get('hydra', 'discovery'), discovery.hydra);
|
|
99
|
+
assert.strictEqual(services.get('sqdiscovery', 'discovery'), discovery.sqdiscovery);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('keeps FedRAMP discovery URLs isolated between instances', () => {
|
|
103
|
+
const oldU2c = 'https://u2c.gov.ciscospark.com/u2c/api/v1';
|
|
104
|
+
const newU2c = 'https://u2c.svc.webexgov.us/u2c/api/v1';
|
|
105
|
+
const defaults = {...fedRampServices};
|
|
106
|
+
const otherWebex = MockWebex({children: {services: ServicesV2}});
|
|
107
|
+
webex.config = {
|
|
108
|
+
fedramp: true,
|
|
109
|
+
services: {discovery: {u2c: oldU2c}, allowedDomains: []},
|
|
110
|
+
};
|
|
111
|
+
otherWebex.config = {
|
|
112
|
+
fedramp: true,
|
|
113
|
+
services: {discovery: {u2c: newU2c}, allowedDomains: []},
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
services.initConfig();
|
|
117
|
+
otherWebex.internal.services.initConfig();
|
|
118
|
+
|
|
119
|
+
assert.deepEqual(webex.config.services.discovery, {...defaults, u2c: oldU2c});
|
|
120
|
+
assert.deepEqual(otherWebex.config.services.discovery, {...defaults, u2c: newU2c});
|
|
121
|
+
assert.strictEqual(services.get('u2c', 'discovery'), oldU2c);
|
|
122
|
+
assert.strictEqual(otherWebex.internal.services.get('u2c', 'discovery'), newU2c);
|
|
123
|
+
assert.notStrictEqual(
|
|
124
|
+
webex.config.services.discovery,
|
|
125
|
+
otherWebex.config.services.discovery
|
|
126
|
+
);
|
|
127
|
+
assert.deepEqual(fedRampServices, defaults);
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
|
|
36
131
|
describe('#initialize', () => {
|
|
37
132
|
it('initFailed is false when initialization succeeds and credentials are available', async () => {
|
|
38
133
|
services.listenToOnce = sinon.stub();
|
|
@@ -1283,6 +1378,32 @@ describe('webex-core', () => {
|
|
|
1283
1378
|
});
|
|
1284
1379
|
|
|
1285
1380
|
describe('#isIntegrationEnvironment', () => {
|
|
1381
|
+
it('uses the integration environment config when set, regardless of the u2c URL', () => {
|
|
1382
|
+
services.webex.config = {
|
|
1383
|
+
environment: 'integration',
|
|
1384
|
+
services: {
|
|
1385
|
+
discovery: {
|
|
1386
|
+
u2c: 'https://u2c.wbx2.com/u2c/api/v1',
|
|
1387
|
+
},
|
|
1388
|
+
},
|
|
1389
|
+
};
|
|
1390
|
+
|
|
1391
|
+
assert.isTrue(services.isIntegrationEnvironment());
|
|
1392
|
+
});
|
|
1393
|
+
|
|
1394
|
+
it('uses the production environment config when set, regardless of the u2c URL', () => {
|
|
1395
|
+
services.webex.config = {
|
|
1396
|
+
environment: 'production',
|
|
1397
|
+
services: {
|
|
1398
|
+
discovery: {
|
|
1399
|
+
u2c: 'https://u2c-intb.ciscospark.com/u2c/api/v1',
|
|
1400
|
+
},
|
|
1401
|
+
},
|
|
1402
|
+
};
|
|
1403
|
+
|
|
1404
|
+
assert.isFalse(services.isIntegrationEnvironment());
|
|
1405
|
+
});
|
|
1406
|
+
|
|
1286
1407
|
it('returns true when u2c URL contains "intb"', () => {
|
|
1287
1408
|
services.webex.config = {
|
|
1288
1409
|
services: {
|