@webex/webex-core 3.12.0-webex-services-ready.4 → 3.13.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/.repo-context.json +653 -0
- package/.sdd/manifest.json +605 -0
- package/AGENTS.md +209 -0
- package/dist/config.js +30 -0
- package/dist/config.js.map +1 -1
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -1
- package/dist/interceptors/catalog-url.js +87 -0
- package/dist/interceptors/catalog-url.js.map +1 -0
- package/dist/interceptors/payload-transformer.js +25 -4
- package/dist/interceptors/payload-transformer.js.map +1 -1
- package/dist/lib/batcher.js +1 -1
- package/dist/lib/credentials/credentials.js +56 -1
- package/dist/lib/credentials/credentials.js.map +1 -1
- package/dist/lib/credentials/token.js +1 -1
- package/dist/lib/services/service-catalog.js +102 -8
- package/dist/lib/services/service-catalog.js.map +1 -1
- package/dist/lib/services/services.js +84 -48
- package/dist/lib/services/services.js.map +1 -1
- package/dist/lib/services-v2/service-catalog.js +8 -1
- package/dist/lib/services-v2/service-catalog.js.map +1 -1
- package/dist/lib/services-v2/services-v2.js +90 -50
- package/dist/lib/services-v2/services-v2.js.map +1 -1
- package/dist/lib/static-asset-loader.js +153 -0
- package/dist/lib/static-asset-loader.js.map +1 -0
- package/dist/plugins/logger.js +1 -1
- package/dist/webex-core.js +11 -3
- package/dist/webex-core.js.map +1 -1
- package/docs/adr/index.md +32 -0
- package/docs/architecture.md +298 -0
- package/docs/getting-started.md +96 -0
- package/docs/index.md +55 -0
- package/docs/specs/README.md +76 -0
- package/package.json +13 -13
- package/schemas/repo-context.schema.json +796 -0
- package/src/config.js +32 -0
- package/src/docs/README.md +732 -0
- package/src/index.js +2 -0
- package/src/interceptors/catalog-url.js +66 -0
- package/src/interceptors/docs/README.md +658 -0
- package/src/interceptors/payload-transformer.js +23 -1
- package/src/lib/credentials/credentials.js +43 -0
- package/src/lib/credentials/docs/README.md +846 -0
- package/src/lib/services/docs/README.md +737 -0
- package/src/lib/services/service-catalog.js +106 -6
- package/src/lib/services/services.js +77 -32
- package/src/lib/services-v2/docs/README.md +751 -0
- package/src/lib/services-v2/service-catalog.ts +10 -1
- package/src/lib/services-v2/services-v2.ts +86 -33
- package/src/lib/static-asset-loader.ts +128 -0
- package/src/lib/storage/docs/README.md +646 -0
- package/src/webex-core.js +8 -0
- package/test/integration/spec/services/services.js +148 -113
- package/test/integration/spec/services-v2/services-v2.js +134 -99
- package/test/unit/spec/credentials/credentials.js +114 -1
- package/test/unit/spec/interceptors/catalog-url.js +224 -0
- package/test/unit/spec/interceptors/payload-transformer.js +119 -1
- package/test/unit/spec/services/service-catalog.js +275 -0
- package/test/unit/spec/services/services.js +161 -2
- package/test/unit/spec/services-v2/service-catalog.ts +41 -0
- package/test/unit/spec/services-v2/services-v2.ts +279 -2
- package/test/unit/spec/static-asset-loader.ts +224 -0
- package/test/unit/spec/webex-core.js +77 -1
|
@@ -0,0 +1,732 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: Module Spec
|
|
3
|
+
title: 'webex-core runtime specification'
|
|
4
|
+
description: Responsibilities, boundaries, design, invariants, and verification for the @webex/webex-core package runtime (plugin host, request pipeline wiring, config, shared plugin base classes).
|
|
5
|
+
tags: [module, specification]
|
|
6
|
+
---
|
|
7
|
+
<!-- sdd-generated-metadata
|
|
8
|
+
doc_kind: module-spec
|
|
9
|
+
generated_from: module-spec@0.3.0
|
|
10
|
+
generated_by: claude-code
|
|
11
|
+
approved_by: rsarika@cisco.com
|
|
12
|
+
updated_at: 2026-10-07T13:20:21Z
|
|
13
|
+
validation_status: pass-with-warnings
|
|
14
|
+
-->
|
|
15
|
+
|
|
16
|
+
# webex-core runtime
|
|
17
|
+
|
|
18
|
+
This source-local document at `src/docs/README.md` owns the stable specification for the **package
|
|
19
|
+
root of `@webex/webex-core`**: the `WebexCore` plugin host, its internal-plugin twin, plugin
|
|
20
|
+
registration, the assembly of the HTTP interceptor pipeline, configuration defaults and merging, the
|
|
21
|
+
`request`/`upload`/`logout` orchestration, the two plugin base classes, and the shared helpers
|
|
22
|
+
`Batcher`, `Page`, `WebexHttpError`, and the allowed-domain matcher.
|
|
23
|
+
|
|
24
|
+
Five children own their own specifications and are referenced here by contract, never restated:
|
|
25
|
+
[interceptors](../interceptors/docs/README.md), [credentials](../lib/credentials/docs/README.md),
|
|
26
|
+
[services](../lib/services/docs/README.md), [services-v2](../lib/services-v2/docs/README.md), and
|
|
27
|
+
[storage](../lib/storage/docs/README.md).
|
|
28
|
+
|
|
29
|
+
Related context: [repository architecture](../../docs/architecture.md) ·
|
|
30
|
+
[documentation index](../../docs/index.md) · [agent instructions](../../AGENTS.md) ·
|
|
31
|
+
[specification registry](../../docs/specs/README.md)
|
|
32
|
+
|
|
33
|
+
## Metadata
|
|
34
|
+
|
|
35
|
+
| Field | Value |
|
|
36
|
+
| ----------------- | --------------------------------------------------------------------- |
|
|
37
|
+
| Owner | Cisco Webex for Developers |
|
|
38
|
+
| Source path | `src` |
|
|
39
|
+
| Resource kind | Package root module (plugin host and shared plugin base classes) |
|
|
40
|
+
| Status | Active |
|
|
41
|
+
| Last verified | 2026-10-07 |
|
|
42
|
+
| Module id | `src` |
|
|
43
|
+
| Parent spec | — |
|
|
44
|
+
| Doc kind | Module spec |
|
|
45
|
+
| Coverage score | 93.8% assessed 2026-10-07; 15 of 16 mandatory fields present; critical 8 of 8; independent validation pass-with-warnings 2026-10-07 |
|
|
46
|
+
| Validation status | Pass with warnings — 2026-10-07; runtime `01a1166d-02d9-7772-bc25-1a801fb5f1d1`; 0 Blocking, 8 Important, 3 Medium |
|
|
47
|
+
|
|
48
|
+
## Applicability
|
|
49
|
+
|
|
50
|
+
| Condition ID | Status | Evidence or reason | Owned section |
|
|
51
|
+
| ------------------------------------ | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------- |
|
|
52
|
+
| `module.has_tiers` | N/A | The repository assigns no operational or review tiers | Tier |
|
|
53
|
+
| `module.has_ui` | N/A | No components or rendering; the package is an SDK runtime | UI use-case flow |
|
|
54
|
+
| `module.crosses_service_boundaries` | Applicable | `src/webex-core.js` sends every plugin request over HTTP and runs the three-phase upload; `src/lib/page.js` fetches follow-up pages | Cross-boundary use-case flow |
|
|
55
|
+
| `module.holds_client_state` | Applicable | `src/webex-core.js` is an ampersand-state model holding config, loaded, request, sessionId; `src/lib/webex-plugin.js` holds per-plugin state | Client state model |
|
|
56
|
+
| `module.enforces_domain_rules` | Applicable | Registration first-wins, request set-once, internal plugins refuse proxies, and the dual-parser host match in `src/lib/domains.ts` | Business rules and invariants |
|
|
57
|
+
| `module.is_concurrent_async` | Applicable | Promise chains in `src/webex-core.js`, in-flight de-duplication and debounced flush in `src/lib/batcher.js`, nextTick listener wiring in `src/webex-core.js` | Concurrency and reactive flow |
|
|
58
|
+
| `module.owns_persistence` | N/A | Persistence is owned by the storage child; this module only selects the adapters in `src/config.js` and wires the stores in `src/webex-core.js` | Data, schema, and migration |
|
|
59
|
+
| `module.stateful_transitions` | Applicable | loaded and ready flip through a one-way event lifecycle driven from `src/webex-core.js`; logout is a staged sequence | State machine |
|
|
60
|
+
| `module.exposes_wire_protocol` | N/A | Speaks standard HTTP through the transport library; the only parsed wire format is the Link header in `src/lib/page.js`, which is not defined here | Protocol and wire format |
|
|
61
|
+
| `module.ui_multi_screen` | N/A | Gated by module.has_ui, which is N/A | UI flow |
|
|
62
|
+
| `module.large_data_model` | N/A | Gated by module.owns_persistence, which is N/A; the module's own state is a handful of session props | Data model |
|
|
63
|
+
| `module.returns_caller_errors` | Applicable | `src/lib/webex-http-error.js` is the request failure type; `src/webex-core.js` rejects uploads; `src/lib/stateless-webex-plugin.js` throws | Caller-visible failure modes |
|
|
64
|
+
| `module.module_specific_conventions` | Applicable | Ampersand-state plugin conventions, prototype-level registration, and import-order coupling across `src/index.js` and `src/plugins/logger.js` | Module-specific rules |
|
|
65
|
+
| `module.published_package` | Applicable | `package.json` declares main and devMain and the deploy script | Export stability |
|
|
66
|
+
| `module.embedded_in_host` | N/A | Consumed as a dependency, not mounted into a host application | Host integration and theming |
|
|
67
|
+
| `module.has_design_tradeoff` | Applicable | Services and credentials live in core (header comment in `src/index.js`); registration is global on the prototype | Key design trade-off |
|
|
68
|
+
| `module.has_submodules` | Applicable | Five child modules own their own specifications, listed under Sub-modules | Sub-modules |
|
|
69
|
+
|
|
70
|
+
## Evidence register
|
|
71
|
+
|
|
72
|
+
| Evidence | What it establishes |
|
|
73
|
+
| -------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
|
|
74
|
+
| `src/index.js` | The complete public export surface, the side-effect imports that register logger, credentials, services, and the services-in-core rationale comment |
|
|
75
|
+
| `src/webex-core.js` | `WebexCore` construction, token-argument normalization, interceptor map and assembly, lifecycle events, upload, logout, `setConfig`, `registerPlugin`/`registerInternalPlugin` |
|
|
76
|
+
| `src/webex-internal-core.js` | The `internal` child that namespaces private plugins and aggregates their ready |
|
|
77
|
+
| `src/lib/webex-core-plugin-mixin.js` | Public-plugin registration: first-wins rule, proxies, interceptors, config, payload transformer, `onBeforeLogout`, ready dependency |
|
|
78
|
+
| `src/lib/webex-internal-core-plugin-mixin.js` | Internal-plugin registration: same as above but proxies are rejected |
|
|
79
|
+
| `src/config.js` | Default configuration values and the environment variables that influence them |
|
|
80
|
+
| `src/credentials-config.js` | The `credentials` default instance embedded in the config (detailed in the credentials child) |
|
|
81
|
+
| `src/plugins/logger.js` | The default `logger` plugin and its console-method fallback |
|
|
82
|
+
| `src/lib/webex-plugin.js` | Stateful plugin base: `webex`, `config`, `logger`, ready, `clear`, `when`, change propagation |
|
|
83
|
+
| `src/lib/stateless-webex-plugin.js` | Stateless plugin base: WeakMap-held `webex`, namespace config, readonly ready |
|
|
84
|
+
| `src/lib/batcher.js` | Request coalescing, de-duplication, capped-debounce flush, and error fan-out |
|
|
85
|
+
| `src/lib/page.js` | Paginated response wrapper and Link header parsing |
|
|
86
|
+
| `src/lib/webex-http-error.js` | Webex-specific `HttpError` with enriched messages and a `TooManyRequests` override |
|
|
87
|
+
| `src/lib/constants.js` | Service-catalog names, allowed commercial domains, and credential metric names |
|
|
88
|
+
| `src/lib/metrics.js` | The single service-catalog metric constant |
|
|
89
|
+
| `src/lib/domains.ts` | Hostname normalization and the fail-closed dual-parser allowed-domain match |
|
|
90
|
+
| `package.json` | Entry points, dependencies, and every build and test command |
|
|
91
|
+
| `jest.config.js` | Unit-test runner configuration (delegates to the shared legacy jest config) |
|
|
92
|
+
| `test/unit/spec/webex-core.js` | Construction, token forms, interceptor assembly cases, `setConfig`, upload rejection and progress, loaded/ready events |
|
|
93
|
+
| `test/unit/spec/webex-internal-core.js` | Internal plugin config access and ready aggregation |
|
|
94
|
+
| `test/unit/spec/_setup.js` | Per-test re-registration of a neutral `test` plugin to prevent cross-talk |
|
|
95
|
+
| `test/unit/spec/lib/batcher.js` | Coalescing, de-duplication, thresholds, failure fan-out, unhandled-rejection safety |
|
|
96
|
+
| `test/unit/spec/lib/page.js` | Page construction, link navigation, link-header parsing |
|
|
97
|
+
| `test/unit/spec/lib/webex-plugin.js` | Namespaced config, logger proxy, root `webex` resolution |
|
|
98
|
+
| `test/integration/spec/webex-core.js` | Tracking id and user-agent headers on a real request, WebexHttpError on failure, logout ordering and store clearing |
|
|
99
|
+
| `test/integration/spec/unit-browser/auth.js` | `AuthInterceptor` 401 handling in a browser runner |
|
|
100
|
+
| `test/integration/spec/unit-browser/token.js` | `Token` `canRefresh` and `refresh()` in a browser runner |
|
|
101
|
+
| `test/fixtures/host-catalog-v2.ts` | Shared catalog fixture consumed by the services-v2 specs |
|
|
102
|
+
| `test/fixtures/activation-email.ts` | Fixture used by the services specs |
|
|
103
|
+
|
|
104
|
+
## Purpose and boundary
|
|
105
|
+
|
|
106
|
+
- **Responsibility:** host the plugin system of the Webex JS SDK. This module builds the one object
|
|
107
|
+
every SDK plugin hangs off (`WebexCore`), decides which interceptors run in which order around every
|
|
108
|
+
HTTP request, owns the default configuration all plugins read from, and provides the base classes and
|
|
109
|
+
helpers plugins are written against.
|
|
110
|
+
- **In scope:** `WebexCore` and `WebexInternalCore`; public and internal plugin registration; the
|
|
111
|
+
interceptor map and its assembly into `request`/`prepareFetchOptions`; config defaults and merge
|
|
112
|
+
rules; `refresh`, `logout`, `measure`, `upload`, `transform`; `WebexPlugin`, `StatelessWebexPlugin`;
|
|
113
|
+
`Batcher`, `Page`, `WebexHttpError`; the allowed-domain matcher; service-catalog constants; the
|
|
114
|
+
default `logger` plugin; the package export surface.
|
|
115
|
+
- **Out of scope:** the sixteen interceptor classes themselves (interceptors child); token and
|
|
116
|
+
credentials behavior (credentials child); service catalogs and discovery, including the three
|
|
117
|
+
services interceptors (services child, services-v2 child); persistence mechanics and the `persist`
|
|
118
|
+
and `waitForValue` decorators (storage child); transport, `HttpError` base and the interceptor fold
|
|
119
|
+
(http-core dependency).
|
|
120
|
+
- **Why services live here:** the header comment of `src/index.js` states that Services is part of
|
|
121
|
+
webex-core because its contents must be reachable when webex-core initializes. As a plugin outside
|
|
122
|
+
core it would initialize after credentials, so every request before then would skip federation
|
|
123
|
+
handling and go to the environmentally assigned URLs. `src/index.js` therefore imports the
|
|
124
|
+
credentials and services modules for their registration side effects.
|
|
125
|
+
- **Consumers:** 49 workspace packages declare `@webex/webex-core` as a dependency (for example
|
|
126
|
+
`@webex/plugin-meetings`, `@webex/internal-plugin-mercury`, `@webex/internal-plugin-metrics`,
|
|
127
|
+
`@webex/plugin-authorization-browser`, `@webex/storage-adapter-local-storage`, `@webex/webex-server`).
|
|
128
|
+
About fifty source files outside this package call `registerPlugin` or `registerInternalPlugin`.
|
|
129
|
+
|
|
130
|
+
## Structure and key files
|
|
131
|
+
|
|
132
|
+
| Path | Responsibility |
|
|
133
|
+
| ------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
|
|
134
|
+
| `src/index.js` | Package entry. Side-effect imports register logger, credentials, services; re-exports the whole public surface |
|
|
135
|
+
| `src/webex-core.js` | Defines `WebexCore`, the interceptor map, the pre/post groups, the lifecycle, upload, logout; calls both plugin mixins |
|
|
136
|
+
| `src/webex-internal-core.js` | `WebexInternalCore`: the `internal` child with its own plugin registry and aggregated ready |
|
|
137
|
+
| `src/lib/webex-core-plugin-mixin.js` | Adds `registerPlugin` to `WebexCore` (supports proxies) |
|
|
138
|
+
| `src/lib/webex-internal-core-plugin-mixin.js` | Adds `registerPlugin` to `WebexInternalCore` (rejects proxies) |
|
|
139
|
+
| `src/config.js` | Default configuration object, mutated at import time by plugin registrations |
|
|
140
|
+
| `src/credentials-config.js` | `CredentialsConfig` default instance; owned by the credentials child, embedded by `src/config.js` |
|
|
141
|
+
| `src/plugins/logger.js` | Registers the default `logger` plugin on the console |
|
|
142
|
+
| `src/lib/webex-plugin.js` | Ampersand-state plugin base class |
|
|
143
|
+
| `src/lib/stateless-webex-plugin.js` | Plain-class plugin base class without ampersand state |
|
|
144
|
+
| `src/lib/batcher.js` | Abstract request-coalescing plugin base |
|
|
145
|
+
| `src/lib/page.js` | Paginated list wrapper |
|
|
146
|
+
| `src/lib/webex-http-error.js` | WebexHttpError |
|
|
147
|
+
| `src/lib/domains.ts` | Allowed-domain matching used by both service catalogs |
|
|
148
|
+
| `src/lib/constants.js` | `NAMESPACE`, `SERVICE_CATALOGS`, `SERVICE_CATALOGS_ENUM_TYPES`, `COMMERCIAL_ALLOWED_DOMAINS`, `METRICS` |
|
|
149
|
+
| `src/lib/metrics.js` | `JS_SDK_SERVICE_NOT_FOUND` metric name |
|
|
150
|
+
| `package.json` | Entry points, dependencies, scripts |
|
|
151
|
+
|
|
152
|
+
## Sub-modules
|
|
153
|
+
|
|
154
|
+
| Sub-module | Responsibility | Specification |
|
|
155
|
+
| ---------------------- | --------------------------------------------------------------------------------------------------------------- | --------------------------------------- |
|
|
156
|
+
| `src/interceptors` | Sixteen request/response interceptor classes; provides `webex-core-interceptors` | `src/interceptors/docs/README.md` |
|
|
157
|
+
| `src/lib/credentials` | `Credentials` and `Token` plugins, scopes, grant errors; provides `webex-core-credentials` | `src/lib/credentials/docs/README.md` |
|
|
158
|
+
| `src/lib/services` | Service catalog, registry, hosts, discovery, plus the service, host-map and server-error interceptors in `src/lib/interceptors`; provides `webex-core-services` | `src/lib/services/docs/README.md` |
|
|
159
|
+
| `src/lib/services-v2` | Second-generation catalog and services plugin classes; provides `webex-core-services-v2` | `src/lib/services-v2/docs/README.md` |
|
|
160
|
+
| `src/lib/storage` | Store construction, adapters, `persist`/`waitForValue`; provides `webex-core-storage` | `src/lib/storage/docs/README.md` |
|
|
161
|
+
|
|
162
|
+
This module assigns the children's position in the pipeline and in `index.js` but never their
|
|
163
|
+
behavior: interceptor semantics are in the interceptors specification, token refresh and expiry in the
|
|
164
|
+
credentials specification, catalog resolution and URL mapping in the services specifications, and
|
|
165
|
+
hydration timing in the storage specification. The services-v2 classes are exported from
|
|
166
|
+
`src/index.js` but are not registered by it; see Public surface for the services-v2 row.
|
|
167
|
+
|
|
168
|
+
## Public surface
|
|
169
|
+
|
|
170
|
+
The package's published surface is the export list of `src/index.js`, reached through `main` and
|
|
171
|
+
`devMain` in `package.json`. This section is a contract index: it names each export and its behavior
|
|
172
|
+
and links the native file. Signatures are read from the source, not copied here. Every row below is
|
|
173
|
+
provided under `webex-core-sdk` unless it names a child contract. The package ships no TypeScript
|
|
174
|
+
declarations for these exports.
|
|
175
|
+
|
|
176
|
+
| Surface | Contract | Consumer | Compatibility commitment | Source |
|
|
177
|
+
| ------- | -------- | -------- | ------------------------ | ------ |
|
|
178
|
+
| `default` (`WebexCore`) | `webex-core-sdk` | Umbrella packages, every host application | Constructed with an attrs object or a bare token string; exposes request, `prepareFetchOptions`, `setTimingsAndFetch`, `refresh`, `logout`, `measure`, `upload`, `transform`, `setConfig`, sessionId, loaded, ready, `internal`, and one property per registered plugin | `src/webex-core.js` |
|
|
179
|
+
| `registerPlugin` | `webex-core-sdk` | Every public plugin package | First registration of a name wins unless `replace` is set; options `proxies`, `interceptors`, `config`, `payloadTransformer`, `onBeforeLogout`, `replace` | `src/webex-core.js`, `src/lib/webex-core-plugin-mixin.js` |
|
|
180
|
+
| `registerInternalPlugin` | `webex-core-sdk` | Every internal plugin package | Same options minus `proxies`, which throws; plugins surface on `webex.internal` | `src/webex-core.js`, `src/lib/webex-internal-core-plugin-mixin.js` |
|
|
181
|
+
| `WebexPlugin` | `webex-core-sdk` | Plugin authors | Ampersand-state base: `webex`, namespaced `config`, `logger`, ready (default `true`), request, `upload`, `when`, `clear` | `src/lib/webex-plugin.js` |
|
|
182
|
+
| `StatelessWebexPlugin` | `webex-core-sdk` | Plugin authors who avoid ampersand state | Class requiring `attrs.webex` or `options.parent`; `config`, `logger`, `webex`, readonly ready, request, `upload` | `src/lib/stateless-webex-plugin.js` |
|
|
183
|
+
| WebexHttpError | `webex-core-sdk` | Every caller handling request failures | `HttpError` subclass whose message adds error code, method and URL, tracking id, trans id, retry-after | `src/lib/webex-http-error.js` |
|
|
184
|
+
| `Batcher` | `webex-core-sdk` | Presence, user, metrics batchers | Abstract plugin; subclasses must supply `fingerprintRequest`, `fingerprintResponse`, `submitHttpRequest` | `src/lib/batcher.js` |
|
|
185
|
+
| `Page` | `webex-core-sdk` | Plugins returning paginated lists | Iterable wrapper with `items`, `length`, `next`, `previous`, `hasNext`, `hasPrevious`, static `parseLinkHeaders` | `src/lib/page.js` |
|
|
186
|
+
| `config` | `webex-core-sdk` | Hosts, tests, plugins | The default configuration object; plugin registration mutates it | `src/config.js` |
|
|
187
|
+
| `serviceConstants` | `webex-core-sdk` | Service consumers | Namespace export of the constants module | `src/lib/constants.js` |
|
|
188
|
+
| `Credentials`, `Token`, `filterScope`, `sortScope`, `grantErrors` | `webex-core-credentials` | Authorization plugins | Re-exports; behavior in the credentials specification | `src/lib/credentials/index.js` |
|
|
189
|
+
| `Services`, `ServiceCatalog`, `ServiceRegistry`, `ServiceState`, `ServiceHost`, `ServiceUrl` | `webex-core-services` | Device, mercury, locus, and others | Re-exports; behavior in the services specification | `src/lib/services/index.js` |
|
|
190
|
+
| `ServiceCatalogV2`, `ServicesV2`, `ServiceDetail` | `webex-core-services-v2` | Hosts opting into the second generation | Re-exports; not registered by this package | `src/lib/services-v2/index.ts` |
|
|
191
|
+
| `makeWebexStore`, `makeWebexPluginStore`, `MemoryStoreAdapter`, `NotFoundError`, `StorageError`, `persist`, `waitForValue` | `webex-core-storage` | Plugin and adapter authors | Re-exports; behavior in the storage specification | `src/lib/storage/index.js` |
|
|
192
|
+
| `AuthInterceptor`, `CatalogUrlInterceptor`, `DefaultOptionsInterceptor`, `EmbargoInterceptor`, `NetworkTimingInterceptor`, `PayloadTransformerInterceptor`, `ProxyInterceptor`, `RateLimitInterceptor`, `RedirectInterceptor`, `RequestEventInterceptor`, `RequestLoggerInterceptor`, `RequestTimingInterceptor`, `ResponseLoggerInterceptor`, `UserAgentInterceptor`, `WebexTrackingIdInterceptor`, `webexTrackingIdSequenceNumbers`, `WebexUserAgentInterceptor` | `webex-core-interceptors` | Hosts composing custom chains | Re-exports of the classes in `src/interceptors` | `src/interceptors/auth.js`, `src/interceptors/webex-tracking-id.js` |
|
|
193
|
+
| `HostMapInterceptor`, `ServiceInterceptor`, `ServerErrorInterceptor` | `webex-core-services` | Hosts composing custom chains | Re-exports of the classes in `src/lib/interceptors` | `src/lib/interceptors/hostmap.js`, `src/lib/interceptors/service.js`, `src/lib/interceptors/server-error.js` |
|
|
194
|
+
|
|
195
|
+
`HttpStatusInterceptor` is not exported by this package; it is imported from the transport library in
|
|
196
|
+
`src/webex-core.js` and bound to `WebexHttpError`. The allowed-domain matcher in `src/lib/domains.ts`
|
|
197
|
+
and the `Logger` class in `src/plugins/logger.js` are not exported from `src/index.js`.
|
|
198
|
+
|
|
199
|
+
## Dependencies
|
|
200
|
+
|
|
201
|
+
| Dependency | Why it is required | Failure behavior |
|
|
202
|
+
| ---------- | ------------------ | ---------------- |
|
|
203
|
+
| `@webex/http-core` (`http-core-sdk`) | Provides `defaults`, `protoprepareFetchOptions`, `setTimingsAndFetch`, `HttpStatusInterceptor`, `HttpError`. Per its specification, `defaults(options)` returns a client function and request interceptors run in array order, response interceptors in reverse | Load-time import; request failures arrive as rejections already converted by `HttpStatusInterceptor` into the error class supplied here |
|
|
204
|
+
| `@webex/common` (`webex-common-js-api`) | `proxyEvents`, `transferEvents`, `retry` (upload), `cappedDebounce` and `Defer` (Batcher). Per its specification these are externally supported helpers | Load-time import; `retry` exhaustion surfaces as an upload rejection |
|
|
205
|
+
| `@webex/common-timers` (`common-timers-sdk`) | Declared in `package.json`; used by the credentials child, not by this module's own files | Child concern |
|
|
206
|
+
| `@webex/storage-adapter-spec` (`storage-adapter-spec-suite`) | Declared dependency; defines the adapter contract the default `MemoryStoreAdapter` in `src/config.js` follows | Adapters that violate it fail in the storage child |
|
|
207
|
+
| `ampersand-state`, `ampersand-events`, `ampersand-collection` (`ampersand-state-library`) | State, derived properties, children, and event model for `WebexCore` and `WebexPlugin`. Described from code, no specification | Load-time import; derived-property and children semantics are inherited |
|
|
208
|
+
| `core-decorators` | `@readonly` on `StatelessWebexPlugin.ready` | Load-time import |
|
|
209
|
+
| `lodash` | `merge`, `defaultsDeep`, `get`/`set`/`unset`, `union`, and others across the module | Load-time import |
|
|
210
|
+
| `uuid` | Session id and upload `x-trans-id` generation | Load-time import |
|
|
211
|
+
| `url` (Node core or bundler polyfill) | `Url.parse` in `src/lib/domains.ts` | The matcher returns no match when parsing throws |
|
|
212
|
+
| `@webex/internal-plugin-device`, `@webex/plugin-logger`, test helpers | Dev dependencies only; not imported by `src` | Absence affects tests only |
|
|
213
|
+
| `crypto-js`, `jsonwebtoken` | Declared dependencies used by the services and credentials children | Child concern |
|
|
214
|
+
|
|
215
|
+
## Requirements
|
|
216
|
+
|
|
217
|
+
| ID | WHAT | WHY | Source evidence | Test or example evidence | Assumptions or gaps | Confidence |
|
|
218
|
+
| -- | ---- | --- | --------------- | ------------------------ | ------------------- | ---------- |
|
|
219
|
+
| `MOD-001` | `new WebexCore(string)` treats the string as an access token and stores it as `credentials.supertoken.access_token` without validation or trimming | Lets hosts initialize with a bare token | `src/webex-core.js` | `test/unit/spec/webex-core.js` | The test feeds token strings through attrs paths, not the bare-string form: bare form untested | Present |
|
|
220
|
+
| `MOD-002` | For object attrs, the first truthy value among `credentials.authorization`, `authorization`, `credentials.supertoken.supertoken`, `supertoken`, `access_token`, `credentials.authorization.supertoken` is removed from its path and set as `credentials.supertoken`, in that fixed order | Hosts historically passed tokens in many shapes; normalizing keeps one shape for the credentials plugin | `src/webex-core.js` | `test/unit/spec/webex-core.js` | Order is documented only by the in-source "order is important" comment; the caller's attrs object is mutated | Present |
|
|
221
|
+
| `MOD-003` | A string at `credentials` or `credentials.authorization` becomes `credentials.supertoken` | Accepts a token string where an object is expected | `src/webex-core.js` | `test/unit/spec/webex-core.js` | none | Present |
|
|
222
|
+
| `MOD-004` | A string `credentials.access_token` is trimmed, passed through `bearerValidator`, and then the whole `credentials` object becomes `credentials.supertoken` | Keeps legacy `{credentials: {access_token}}` working while repairing malformed Bearer strings | `src/webex-core.js` | `test/unit/spec/webex-core.js` | none | Present |
|
|
223
|
+
| `MOD-005` | `bearerValidator` collapses whitespace runs to one space, inserts the missing space in `Bearer1234`, and logs a `console.warn` plus tip for glued or extra-spaced input | Silent repair would hide a host misconfiguration | `src/webex-core.js` | `test/unit/spec/webex-core.js` | Warning text is not asserted | Present |
|
|
224
|
+
| `MOD-006` | `initialize` sets `config` to `merge({}, defaultConfig, attrs.config)` and then triggers `change:config` before any other work | Children need a hook to read config during their own initialization | `src/webex-core.js`, `src/config.js` | `test/unit/spec/webex-core.js` | The `change:config` trigger itself is not asserted | Present |
|
|
225
|
+
| `MOD-007` | `setConfig(newConfig)` replaces `config` with `merge({}, config, newConfig)`; it does not rebuild the interceptor chain or sessionId | Allows late tuning of plugin config reads that are uncached | `src/webex-core.js`, `src/lib/webex-plugin.js` | `test/unit/spec/webex-core.js` | Only a credentials key is asserted; chain and session id staleness untested | Present |
|
|
226
|
+
| `MOD-008` | Plugin registration options `config`, `payloadTransformer.predicates`, and `payloadTransformer.transforms` are merged or concatenated into the module-level default config, so they apply to every instance created afterwards | Plugins ship their own defaults without touching host code | `src/lib/webex-core-plugin-mixin.js`, `src/lib/webex-internal-core-plugin-mixin.js` | none found | Gap: no unit test registers a plugin with `config` or transformer options | Present |
|
|
227
|
+
| `MOD-009` | Default config carries `maxAppLevelRedirects: 10`, `maxLocusRedirects: 5`, `maxAuthenticationReplays: 1`, `maxReconnectAttempts: 1`, `trackingIdPrefix: 'webex-js-sdk'`, empty `trackingIdSuffix`, empty `onBeforeLogout`, memory adapters for both storage slots, `payloadTransformer` with empty predicates and transforms, and `skipRepeatedInboundTransforms: false` | Safe defaults let a bare `new WebexCore()` work offline | `src/config.js` | `test/unit/spec/webex-core.js` | Only `fedramp` presence is asserted | Present |
|
|
228
|
+
| `MOD-010` | `config.fedramp` is `process.env.ENABLE_FEDRAMP || false`, evaluated once at import | Selects FedRAMP behavior by environment | `src/config.js` | `test/unit/spec/webex-core.js` | Any non-empty string, including `false`, is truthy; only key presence is tested | Present |
|
|
229
|
+
| `MOD-011` | `services.discovery` URLs default to the hydra, region-discovery, and U2C endpoints and are overridden by `HYDRA_SERVICE_URL`, `SQDISCOVERY_SERVICE_URL`, `U2C_SERVICE_URL` at import; `device.preDiscoveryServices` also reads `HYDRA_SERVICE_URL` | Lets test and non-production environments redirect discovery | `src/config.js` | none found | Gap: no test covers the overrides | Present |
|
|
230
|
+
| `MOD-012` | `services.validateCatalogUrls` defaults to `false`; `services.validateDomains` defaults to `true`; `services.allowedDomains` defaults to an empty list; `services.catalogInitTimeout` defaults to 15000 ms; `services.useCatalogOverride`, `skipPreauthCatalogOnUnauthenticated`, and `useUserOnboardingServiceForActivations` default to `false`; `calling.cacheU2C` defaults to `false` | Opt-in flags keep default behavior unchanged for existing hosts | `src/config.js` | `test/unit/spec/webex-core.js` | Consumption of these keys is specified in the services child; only `validateCatalogUrls` is asserted here | Present |
|
|
231
|
+
| `MOD-013` | `registerPlugin(name, ctor, options)` returns immediately without changing anything if `name` is already a child, unless `options.replace` is truthy; none of the options are applied on the early return | Prevents a second import of a plugin from duplicating interceptors, config, and logout handlers | `src/lib/webex-core-plugin-mixin.js`, `src/lib/webex-internal-core-plugin-mixin.js` | `test/unit/spec/_setup.js` | Gap: the no-replace early return is not directly asserted | Present |
|
|
232
|
+
| `MOD-014` | Registration writes the constructor into the prototype `_children` map, so every later `WebexCore` instance gets `webex.<name>` and instances created earlier do not | Plugins are discovered by import, not by per-instance configuration | `src/lib/webex-core-plugin-mixin.js` | `test/unit/spec/webex-core.js` | Registration after construction is not tested | Present |
|
|
233
|
+
| `MOD-015` | `options.proxies` creates one derived property per key on `WebexCore` that reads the same key from the plugin (for example `canAuthorize`, `canRefresh` from credentials) | Gives hosts a flat shortcut without copying state | `src/lib/webex-core-plugin-mixin.js`, `src/lib/credentials/index.js` | `test/unit/spec/webex-core.js` | Verified only through `canAuthorize` | Present |
|
|
234
|
+
| `MOD-016` | `registerInternalPlugin` with `options.proxies` throws `Proxies are not currently supported for private plugins` | Private plugins must stay behind `webex.internal` | `src/lib/webex-internal-core-plugin-mixin.js` | none found | Gap: the throw is untested | Present |
|
|
235
|
+
| `MOD-017` | Plugin-registered `interceptors` entries are written into the shared interceptor map by key, replacing an existing key | The services plugin supplies `ServiceInterceptor` and `ServerErrorInterceptor` this way | `src/lib/webex-core-plugin-mixin.js`, `src/lib/services/index.js` | `test/unit/spec/webex-core.js` | Collision behavior untested | Present |
|
|
236
|
+
| `MOD-018` | `onBeforeLogout` options (single function or array) are appended to `config.onBeforeLogout` as `{plugin, fn}` pairs in registration order | Plugins can release resources before credentials are invalidated | `src/lib/webex-core-plugin-mixin.js` | `test/integration/spec/webex-core.js` | Registration path not directly tested; the integration test injects pairs through config | Present |
|
|
237
|
+
| `MOD-019` | A registered plugin whose prototype defines ready adds `<name>.ready` to `WebexCore`'s derived ready dependency list (and likewise for `WebexInternalCore`) | The host ready must reflect every plugin that can be not-ready | `src/lib/webex-core-plugin-mixin.js`, `src/lib/webex-internal-core-plugin-mixin.js` | `test/unit/spec/webex-core.js`, `test/unit/spec/webex-internal-core.js` | none | Present |
|
|
238
|
+
| `MOD-020` | `WebexCore.ready` is loaded AND every child plugin's ready not strictly `false`; `WebexInternalCore.ready` applies the same fold to its children, and `WebexCore` depends on `internal.ready` | One boolean tells a host that storage hydration and all plugin start-up finished | `src/webex-core.js`, `src/webex-internal-core.js` | `test/unit/spec/webex-core.js`, `test/unit/spec/webex-internal-core.js` | none | Present |
|
|
239
|
+
| `MOD-021` | `src/index.js` imports `./plugins/logger`, `./lib/credentials`, and `./lib/services` before anything else is exported, registering `logger` (public), `credentials` (public, proxies `canAuthorize` and `canRefresh`), and `services` (internal, with `ServiceInterceptor` and `ServerErrorInterceptor`) | Core must have services and credentials available at first initialization (see Purpose and boundary) | `src/index.js`, `src/plugins/logger.js` | `test/unit/spec/webex-core.js` | Registration order between the three is not asserted | Present |
|
|
240
|
+
| `MOD-022` | With no `config.interceptors`, the chain is the pre group, then every other map entry in map order, then the post group; a key listed in both groups (`RateLimitInterceptor`) is instantiated once per occurrence | Fixes the nesting of cross-cutting behavior (timing outermost, status conversion innermost on the response path) | `src/webex-core.js` | `test/unit/spec/webex-core.js` | Exact middle order depends on import-time registration order | Present |
|
|
241
|
+
| `MOD-023` | The pre group is `ResponseLoggerInterceptor`, `RequestTimingInterceptor`, `RequestEventInterceptor`, `WebexTrackingIdInterceptor`, `RateLimitInterceptor`, `CatalogUrlInterceptor`; the post group is `HttpStatusInterceptor`, `NetworkTimingInterceptor`, `EmbargoInterceptor`, `RequestLoggerInterceptor`, `RateLimitInterceptor` | Request hooks run in array order and response hooks in reverse, so order encodes who sees raw versus converted responses | `src/webex-core.js` | `test/unit/spec/webex-core.js` | Test asserts the default 18-entry and 19-entry lists, not each group in isolation | Present |
|
|
242
|
+
| `MOD-024` | An entry is added only if its map value is a function: the two logger interceptors are `undefined` unless `ENABLE_NETWORK_LOGGING` or `ENABLE_VERBOSE_NETWORK_LOGGING` is set when `src/webex-core.js` is first imported, and `ServiceInterceptor`, `KmsDryErrorInterceptor`, `ConversationInterceptor` stay `undefined` until a plugin supplies them | Optional behavior is expressed by absence from the map, not by flags checked per request | `src/webex-core.js` | `test/unit/spec/webex-core.js` | Env-driven logger inclusion is untested | Present |
|
|
243
|
+
| `MOD-025` | `CatalogUrlInterceptor` is added only when `config.services.validateCatalogUrls === true` (strict boolean), in both the default and the `config.interceptors` assembly | Opt-in SSRF protection without changing default traffic | `src/webex-core.js`, `src/config.js` | `test/unit/spec/webex-core.js` | none | Present |
|
|
244
|
+
| `MOD-026` | When `config.interceptors` is set, only its own keys, in its own key order, are instantiated; no pre/post grouping and no plugin-registered interceptors are added; an empty object or array yields zero interceptors | Lets a host replace the pipeline wholesale | `src/webex-core.js` | `test/unit/spec/webex-core.js` | none | Present |
|
|
245
|
+
| `MOD-027` | Each interceptor factory is invoked with `this` bound to the `WebexCore` instance; `HttpStatusInterceptor` is built with WebexHttpError as its error constructor | Interceptors reach the instance without constructor arguments, and status failures become WebexHttpError | `src/webex-core.js` | `test/integration/spec/webex-core.js` | Binding is verified only through behavior | Present |
|
|
246
|
+
| `MOD-028` | `initialize` sets request (set-once) and `prepareFetchOptions` to the transport defaults with `json: true` and the assembled chain, and `setTimingsAndFetch` to the transport helper unchanged | One function is the single entry for all plugin HTTP traffic | `src/webex-core.js` | `test/unit/spec/webex-core.js`, `test/integration/spec/webex-core.js` | `setTimingsAndFetch` is not asserted | Present |
|
|
247
|
+
| `MOD-029` | sessionId is `<trackingIdPrefix>_<trackingIdBase or new uuid>` with `_<trackingIdSuffix>` appended when the suffix is non-empty | Correlates all requests of one SDK instance | `src/webex-core.js` | `test/integration/spec/webex-core.js` | Suffix and base branches untested | Present |
|
|
248
|
+
| `MOD-030` | `WebexCore` fires loaded once, when loaded becomes true, and ready once, when derived ready becomes true; listeners are attached on the next tick and run immediately if the state is already reached | Hosts can await readiness without racing construction | `src/webex-core.js` | `test/unit/spec/webex-core.js` | ready event fires once even if a plugin later flips it false | Present |
|
|
249
|
+
| `MOD-031` | Changes on any child (`change` event) re-emit on the parent as `change:<childName>`; a `WebexPlugin` change re-emits on its parent as `change:<lowercased namespace>` | Hosts observe plugin state through one object | `src/webex-core.js`, `src/lib/webex-plugin.js` | `test/unit/spec/webex-core.js` | Only exercised indirectly through the ready tests | Present |
|
|
250
|
+
| `MOD-032` | `refresh(...args)` delegates to `credentials.refresh(...args)` | Stable host-facing refresh entry | `src/webex-core.js` | none found | Gap: no test of delegation | Present |
|
|
251
|
+
| `MOD-033` | `logout(options, ...rest)` runs `onBeforeLogout` handlers last-registered first, each in the owning plugin's scope (`this[plugin]` else `this.internal[plugin]`) with `{token}` merged into options, where token is the refresh token else the access token; a handler failure is logged as a warning and does not stop the sequence | Teardown must unwind in reverse dependency order and must not be blockable by one plugin | `src/webex-core.js` | `test/integration/spec/webex-core.js` | Handler rejection path covered only by a rejecting stub in the integration test | Present |
|
|
252
|
+
| `MOD-034` | After handlers, `logout` clears both stores, calls `credentials.invalidate(...rest)`, calls `authorization.logout` when it exists, and finally triggers `client:logout` | Local data is erased before tokens are revoked, and observers learn of completion last | `src/webex-core.js` | `test/integration/spec/webex-core.js` | Requires the integration environment; no unit test | Present |
|
|
253
|
+
| `MOD-035` | `logout` with no credentials token still resolves (token is `undefined`) | Logging out an unauthenticated instance must not throw | `src/webex-core.js` | `test/integration/spec/webex-core.js` | none | Present |
|
|
254
|
+
| `MOD-036` | `measure(...)` forwards to `metrics.sendUnstructured` when a metrics plugin is present and otherwise resolves | Metrics are optional | `src/webex-core.js` | none found | Gap: untested | Present |
|
|
255
|
+
| `MOD-037` | `transform(direction, object)` runs every configured predicate whose direction matches, extracts targets, and applies named transforms serially, resolving to the same object; `applyNamedTransform` follows `alias` redirection | Payload shaping is configured by plugins, not hard-coded | `src/webex-core.js` | none found | Gap: no spec in this package exercises it (the payload-transformer interceptor spec lives with the child) | Present |
|
|
256
|
+
| `MOD-038` | `upload` rejects with `` `options.file` is required `` when `options` or `options.file` is absent | Fail fast before any request | `src/webex-core.js` | `test/unit/spec/webex-core.js` | none | Present |
|
|
257
|
+
| `MOD-039` | `upload` fills three phase option blocks: initialize defaults to `POST` with `uploadProtocol: 'content-length'`; upload defaults to `PUT`, `json: false`, no credentials, body from `file`, a fresh `x-trans-id`, and an explicitly undefined `authorization`; finalize defaults to `POST` | The upload target is a pre-signed endpoint that must not receive the SDK bearer token | `src/webex-core.js` | none found | Gap: default blocks are not asserted | Present |
|
|
258
|
+
| `MOD-040` | After initialize, if `body.fileUploadSizeLimit` (default 2048 MB) is below `options.file.byteLength`, the session is deleted with a `DELETE` and the upload rejects with a JSON message containing `file-upload-size-limit-enabled` | Oversize files are refused before bytes are sent | `src/webex-core.js` | none found | Gap: abort path untested | Present |
|
|
259
|
+
| `MOD-041` | Phase option keys starting with `$` (upload, finalize) are replaced by the result of calling them with the initialize response body, under the key without the `$` | Lets callers derive URLs and headers from the session | `src/webex-core.js` | none found | Gap: untested | Present |
|
|
260
|
+
| `MOD-042` | The upload phase is wrapped with `retry`, its progress events are re-emitted through an internal emitter onto the returned promise, and the promise resolves to the finalize response body merged with its headers | Large uploads survive transient failures and report progress | `src/webex-core.js` | `test/unit/spec/webex-core.js` | The test stubs all three phases, so retry and the real phase wiring are untested | Present |
|
|
261
|
+
| `MOD-043` | `WebexPlugin.webex` resolves to the root of the parent or collection chain and throws if neither exists | Plugins nested at any depth reach the one `WebexCore` | `src/lib/webex-plugin.js` | `test/unit/spec/lib/webex-plugin.js` | Throw path untested | Present |
|
|
262
|
+
| `MOD-044` | `WebexPlugin.config` is the plugin's namespace key of `webex.config` (lowercased), the whole config without a namespace, or `{}` before a `webex` exists; it is not cached | A plugin always sees current config including `setConfig` changes | `src/lib/webex-plugin.js` | `test/unit/spec/lib/webex-plugin.js`, `test/unit/spec/webex-internal-core.js` | `{}` fallback untested | Present |
|
|
263
|
+
| `MOD-045` | `WebexPlugin.logger` is `webex.logger` or `console`; ready defaults to `true`; `clear()` unsets every attribute except `parent` and recurses into children and collections; `when(event)` returns a promise of the event arguments and throws if given a callback | Shared plugin ergonomics | `src/lib/webex-plugin.js` | `test/unit/spec/lib/webex-plugin.js` | `clear`, `when`, ready default untested | Present |
|
|
264
|
+
| `MOD-046` | `StatelessWebexPlugin` requires `attrs.webex` or `options.parent` (throws otherwise), walks to the root, holds it in a module-level `WeakMap`, exposes namespaced `config`, `logger`, request, `upload`, and a readonly ready of `true` | Gives plugins without ampersand state the same access with no retain cycle | `src/lib/stateless-webex-plugin.js` | none found | Gap: no spec covers this class | Present |
|
|
265
|
+
| `MOD-047` | The `logger` plugin exposes `error`, `warn`, `log`, `info`, `debug`, `trace` bound to console methods, falling back down a fixed precedence when a level is missing | Logging works on minimal consoles | `src/plugins/logger.js` | `test/unit/spec/webex-core.js` | Fallback precedence untested | Present |
|
|
266
|
+
| `MOD-048` | `WebexHttpError.parse` extends the base message with `errorCode`, `METHOD url-or-uri-or-SERVICE/resource`, `WEBEX_TRACKING_ID`, `X-Trans-Id`, and `RETRY-AFTER` (also exposed as an enumerable `retryAfter`), and defines `options` and `body` non-enumerably | Support and logs need the request identity in the message | `src/lib/webex-http-error.js` | `test/integration/spec/webex-core.js`, `test/unit/spec/lib/batcher.js` | No unit test of message construction | Present |
|
|
267
|
+
| `MOD-049` | Importing `src/lib/webex-http-error.js` builds the subtype tree on WebexHttpError and reassigns `HttpError[429]` and `HttpError.TooManyRequests` on the transport library's base class | Provides a rate-limit error class available to consumers of either base | `src/lib/webex-http-error.js` | `test/unit/spec/interceptors/rate-limit.js` | Side effect on a class owned by another package | Present |
|
|
268
|
+
| `MOD-050` | `Batcher.request(item)` fingerprints the item; a second request with the same fingerprint before the first settles returns the first's promise; the fingerprint entry is removed when the promise settles | Collapses duplicate lookups into one slot | `src/lib/batcher.js` | `test/unit/spec/lib/batcher.js` | none | Present |
|
|
269
|
+
| `MOD-051` | Queued items flush through a capped debounce bounded by `config.batcherWait`, `config.batcherMaxWait`, and `config.batcherMaxCalls`; each flush takes at most `batcherMaxCalls` items | Bounds both latency and payload size of batched calls | `src/lib/batcher.js` | `test/unit/spec/lib/batcher.js` | Defaults for the three keys are not in `src/config.js`; each subclass's namespace must provide them | Present |
|
|
270
|
+
| `MOD-052` | On a failed flush, a WebexHttpError is routed to `handleHttpError` (rejecting each deferred named by `reason.options.body`), falling back to rejecting every queued deferred if that handler itself rejects; any other error rejects every queued deferred; the flush never rethrows | Every caller's promise settles and no global unhandled rejection is produced | `src/lib/batcher.js` | `test/unit/spec/lib/batcher.js` | none | Present |
|
|
271
|
+
| `MOD-053` | `Batcher` subclasses must implement `fingerprintRequest`, `fingerprintResponse`, and `submitHttpRequest`; `prepareItem`, `enqueue`, `prepareRequest`, `didItemFail`, `handleItemSuccess`, `handleItemFailure`, `handleHttpSuccess`, and `handleHttpError` have working defaults | Template-method base: only the API-specific parts vary | `src/lib/batcher.js` | `test/unit/spec/lib/batcher.js` | Not-implemented throws untested | Present |
|
|
272
|
+
| `MOD-054` | `Page` stores the body `items` and parsed Link headers; `next`/`previous` request the linked URL through `webex.request` and resolve to a new `Page`; `hasNext`/`hasPrevious` report link presence; iteration yields `items` in order | Uniform pagination across plugins | `src/lib/page.js` | `test/unit/spec/lib/page.js` | none | Present |
|
|
273
|
+
| `MOD-055` | `Page.parseLinkHeaders` returns `{}` for no header, accepts a string or an array, and maps each `rel` to its URL | Hosts may receive one or several Link headers | `src/lib/page.js` | `test/unit/spec/lib/page.js` | A single string holding comma-joined links is not split | Present |
|
|
274
|
+
| `MOD-056` | `matchAllowedDomain(url, allowedDomains)` returns the matching allowed domain only if the WHATWG parser and the legacy Node parser agree on the hostname, and the hostname equals the domain or ends with `.<domain>`; otherwise `undefined`; `normalizeAllowedDomains` lowercases, strips IPv6 brackets and surrounding dots, drops non-strings and empties, and de-duplicates | The match gates where an `Authorization` header may be sent, so ambiguity must fail closed and substring look-alikes must not match | `src/lib/domains.ts` | `test/unit/spec/services/service-catalog.js` | No dedicated spec; covered only through catalog consumers | Present |
|
|
275
|
+
| `MOD-057` | `src/lib/constants.js` exports the catalog names (`discovery`, `limited`, `signin`, `postauth`, `custom`), the `services` namespace, the commercial allowed-domain list, and credential metric names; `src/index.js` exposes the module as `serviceConstants` | One source of constants for both service generations and credentials | `src/lib/constants.js`, `src/index.js` | none found | Gap: no test asserts the constant values | Present |
|
|
276
|
+
| `MOD-058` | `inspect` on `WebexCore`, `WebexInternalCore`, and `WebexPlugin` serializes props, session, and derived values while omitting stores, request, `config`, `logger`, `webex`, `parent` as applicable | Prevents console output of whole object graphs and secrets-bearing config | `src/webex-core.js`, `src/webex-internal-core.js`, `src/lib/webex-plugin.js` | none found | Gap: untested | Present |
|
|
277
|
+
| `MOD-059` | `WebexCore.version` and `webex.version` equal the build-time `PACKAGE_VERSION` constant | Reporting the SDK version | `src/webex-core.js` | `test/unit/spec/webex-core.js` | The version tests are skipped (`it.skip`) | Weak |
|
|
278
|
+
| `MOD-060` | `build:src` compiles `src` to `dist`; `test:unit` runs jest; `test:integration` runs mocha; `test:browser` runs karma; `test:style` runs eslint over `src` | Defines how the package is built and verified | `package.json`, `jest.config.js` | none found | Integration and browser tiers need provisioned services | Present |
|
|
279
|
+
|
|
280
|
+
## Design overview
|
|
281
|
+
|
|
282
|
+
**The object model is ampersand-state, and the registry is the prototype.** `WebexCore` extends an
|
|
283
|
+
ampersand state class whose `children` map starts with only `internal`. `registerPlugin` writes
|
|
284
|
+
constructors into that prototype-level `_children` map, so registration is a global, import-time act:
|
|
285
|
+
whichever plugin packages a host imports before constructing `WebexCore` are the plugins that instance
|
|
286
|
+
gets. The twin `WebexInternalCore` repeats the pattern one level down so private plugins live under
|
|
287
|
+
`webex.internal` and can be told apart from public ones. Both mixins share one implementation shape and
|
|
288
|
+
differ only in refusing `proxies` for internal plugins.
|
|
289
|
+
|
|
290
|
+
**One module-level config and one module-level interceptor map, mutated by registration.** The default
|
|
291
|
+
`config` object and the `interceptors` map in `src/webex-core.js` are passed into both mixins. A plugin
|
|
292
|
+
that registers with `config`, `interceptors`, transformer predicates, or `onBeforeLogout` is therefore
|
|
293
|
+
changing defaults for every later instance. `initialize` then takes a deep copy of the defaults merged
|
|
294
|
+
with the host's `attrs.config`, which is why per-instance changes never leak back to the defaults.
|
|
295
|
+
|
|
296
|
+
**The interceptor chain is an ordered list built once per instance.** Pre-group names run first, then
|
|
297
|
+
everything else in map insertion order, then the post group; the chain is frozen into `request` and
|
|
298
|
+
`prepareFetchOptions` at the end of `initialize`. Optional interceptors are not flags; they are
|
|
299
|
+
`undefined` map values that disappear at assembly, and `CatalogUrlInterceptor` is the one conditional
|
|
300
|
+
the assembler applies itself. Nesting semantics (what sees a raw versus converted response) are those of
|
|
301
|
+
the transport library's fold and are explained in the interceptors specification.
|
|
302
|
+
|
|
303
|
+
**Lifecycle is derived, not orchestrated.** There is no start-up routine. `loaded` is set by the storage
|
|
304
|
+
child when every persisted plugin finished hydrating; `ready` is a derived property over `loaded` and
|
|
305
|
+
each child's `ready`. The `loaded` and `ready` events are thin edge detectors over those two properties.
|
|
306
|
+
Plugins that need async start-up declare `ready: false` and flip it when done.
|
|
307
|
+
|
|
308
|
+
**Two plugin base classes for two eras.** `WebexPlugin` carries ampersand state, persistence hooks, and
|
|
309
|
+
change propagation. `StatelessWebexPlugin` is a plain class that holds its `webex` in a `WeakMap` and
|
|
310
|
+
mixes in event methods, for plugins that need neither. Both resolve the root `webex` by walking
|
|
311
|
+
`parent`/`collection` links.
|
|
312
|
+
|
|
313
|
+
**Helpers are deliberately small.** `Batcher` is a template-method plugin: `request` de-duplicates by
|
|
314
|
+
fingerprint, enqueues, and arms a capped debounce; `executeQueue` splices a bounded slice, prepares,
|
|
315
|
+
submits, and fans results or errors out to per-item deferreds. `Page` wraps one list response and fetches
|
|
316
|
+
neighbors lazily. `WebexHttpError` enriches the transport error message. `domains.ts` exists because the
|
|
317
|
+
two transports parse URLs differently and the match gates credential disclosure.
|
|
318
|
+
|
|
319
|
+
## Data flow and sequence coverage
|
|
320
|
+
|
|
321
|
+
Transport is HTTP via the transport library's promise-returning client for requests, uploads, pages, and
|
|
322
|
+
batched submissions; everything else is in-process method calls and ampersand events. The major
|
|
323
|
+
operation groups are: construction and plugin registration, interceptor-chain assembly, request
|
|
324
|
+
execution, logout, upload, batching, and pagination. Request execution beyond the hand-off to the
|
|
325
|
+
interceptors is specified in the interceptors and services specifications.
|
|
326
|
+
|
|
327
|
+
| Operation group | Entry and outcome | Diagram or evidence | Failure and recovery coverage |
|
|
328
|
+
| --------------- | ----------------- | ------------------- | ----------------------------- |
|
|
329
|
+
| Registration and construction | `registerPlugin` at import; `new WebexCore(attrs)` builds children, merges config, normalizes tokens | Diagram 1 | Duplicate name ignored; internal proxies throw |
|
|
330
|
+
| Chain assembly and request | `initialize` builds request; a plugin calls `webex.request` | Diagram 2 | Chain-level failure surfaces as WebexHttpError; replay and redirect detail is in the interceptors specification |
|
|
331
|
+
| Lifecycle events | storage sets loaded; plugins set ready | State machine section | ready regressing after the event |
|
|
332
|
+
| Logout | `webex.logout(options)` | Diagram 3 | Handler failure swallowed; later stages still run; stage failure rejects |
|
|
333
|
+
| Upload | `webex.upload({file, phases})` | Diagram 4 | Size-limit abort with `DELETE`; retry on the upload phase |
|
|
334
|
+
| Batching | `Batcher.request(item)` | Diagram 5 | Fan-out rejection, de-duplication, flush errors |
|
|
335
|
+
| Pagination | `Page.next()` | Diagram 6 | Request rejection propagates |
|
|
336
|
+
|
|
337
|
+
**Diagram 1: registration and construction**
|
|
338
|
+
|
|
339
|
+
```mermaid
|
|
340
|
+
sequenceDiagram
|
|
341
|
+
participant P as Plugin package
|
|
342
|
+
participant R as registerPlugin (mixin)
|
|
343
|
+
participant S as module config and interceptors map
|
|
344
|
+
participant H as Host
|
|
345
|
+
participant W as WebexCore
|
|
346
|
+
P->>R: registerPlugin(name, ctor, options)
|
|
347
|
+
alt name already a child and no replace
|
|
348
|
+
R-->>P: return (no option applied)
|
|
349
|
+
else
|
|
350
|
+
R->>R: prototype _children[name] = ctor
|
|
351
|
+
R->>R: proxies become derived props (public only)
|
|
352
|
+
R->>S: merge interceptors, config, transformers, onBeforeLogout
|
|
353
|
+
R->>R: add name.ready to ready dependencies
|
|
354
|
+
end
|
|
355
|
+
H->>W: new WebexCore(attrs)
|
|
356
|
+
W->>W: normalize token argument forms
|
|
357
|
+
W->>W: ampersand construct children
|
|
358
|
+
W->>W: initialize: merge config, trigger change:config
|
|
359
|
+
W->>W: assemble chain, set request and sessionId
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
**Diagram 2: chain assembly and one request**
|
|
363
|
+
|
|
364
|
+
```mermaid
|
|
365
|
+
sequenceDiagram
|
|
366
|
+
participant W as WebexCore.initialize
|
|
367
|
+
participant M as interceptor map
|
|
368
|
+
participant T as transport client
|
|
369
|
+
participant Pl as Plugin
|
|
370
|
+
W->>W: config.interceptors set?
|
|
371
|
+
alt set
|
|
372
|
+
W->>M: instantiate listed keys in key order
|
|
373
|
+
else default
|
|
374
|
+
W->>M: pre group, then remaining keys, then post group
|
|
375
|
+
end
|
|
376
|
+
W->>W: skip non-functions, CatalogUrl only if validateCatalogUrls === true
|
|
377
|
+
W->>T: defaults({json: true, interceptors})
|
|
378
|
+
Pl->>W: request(options)
|
|
379
|
+
W->>T: client(options)
|
|
380
|
+
alt response status below 400
|
|
381
|
+
T-->>Pl: response
|
|
382
|
+
else failure
|
|
383
|
+
T-->>Pl: reject WebexHttpError
|
|
384
|
+
end
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
**Diagram 3: logout**
|
|
388
|
+
|
|
389
|
+
```mermaid
|
|
390
|
+
sequenceDiagram
|
|
391
|
+
participant H as Host
|
|
392
|
+
participant W as WebexCore
|
|
393
|
+
participant Pg as Plugins (reverse registration order)
|
|
394
|
+
participant St as bounded and unbounded stores
|
|
395
|
+
participant C as credentials and authorization
|
|
396
|
+
H->>W: logout(options)
|
|
397
|
+
W->>W: token = refresh token else access token
|
|
398
|
+
loop each onBeforeLogout handler
|
|
399
|
+
W->>Pg: fn(options with token)
|
|
400
|
+
alt handler rejects
|
|
401
|
+
W->>W: logger.warn and continue
|
|
402
|
+
end
|
|
403
|
+
end
|
|
404
|
+
W->>St: clear both stores
|
|
405
|
+
W->>C: credentials.invalidate
|
|
406
|
+
opt authorization plugin has logout
|
|
407
|
+
W->>C: authorization.logout
|
|
408
|
+
end
|
|
409
|
+
W-->>H: trigger client:logout, resolve
|
|
410
|
+
Note over W,C: A rejection in clear, invalidate, or authorization.logout rejects the returned promise
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
**Diagram 4: upload**
|
|
414
|
+
|
|
415
|
+
```mermaid
|
|
416
|
+
sequenceDiagram
|
|
417
|
+
participant H as Host
|
|
418
|
+
participant W as WebexCore.upload
|
|
419
|
+
participant Svc as upload service
|
|
420
|
+
H->>W: upload({file, phases})
|
|
421
|
+
alt no options or no file
|
|
422
|
+
W-->>H: reject file is required
|
|
423
|
+
end
|
|
424
|
+
W->>Svc: initialize (POST, content-length)
|
|
425
|
+
Svc-->>W: session body
|
|
426
|
+
alt size limit exceeded
|
|
427
|
+
W->>Svc: DELETE session
|
|
428
|
+
W-->>H: reject file-upload-size-limit-enabled
|
|
429
|
+
else
|
|
430
|
+
W->>W: apply $-keys with session
|
|
431
|
+
W->>Svc: upload (PUT, retry, progress events)
|
|
432
|
+
Svc-->>W: response
|
|
433
|
+
W->>Svc: finalize (POST)
|
|
434
|
+
Svc-->>W: response
|
|
435
|
+
W-->>H: body merged with headers
|
|
436
|
+
end
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
**Diagram 5: batching**
|
|
440
|
+
|
|
441
|
+
```mermaid
|
|
442
|
+
sequenceDiagram
|
|
443
|
+
participant C as Caller
|
|
444
|
+
participant B as Batcher
|
|
445
|
+
participant D as cappedDebounce
|
|
446
|
+
participant A as batched API
|
|
447
|
+
C->>B: request(item)
|
|
448
|
+
B->>B: fingerprintRequest
|
|
449
|
+
alt fingerprint already pending
|
|
450
|
+
B-->>C: existing promise
|
|
451
|
+
else
|
|
452
|
+
B->>B: prepareItem, enqueue
|
|
453
|
+
B->>D: bounce()
|
|
454
|
+
D->>B: executeQueue (wait, maxWait, or maxCalls)
|
|
455
|
+
B->>A: submitHttpRequest(prepared queue)
|
|
456
|
+
alt success
|
|
457
|
+
A-->>B: items
|
|
458
|
+
B->>B: acceptItem: fail or succeed each deferred
|
|
459
|
+
else WebexHttpError
|
|
460
|
+
B->>B: handleHttpError rejects deferreds in options.body
|
|
461
|
+
B->>B: if that rejects, reject every queued deferred
|
|
462
|
+
else other error
|
|
463
|
+
B->>B: reject every queued deferred
|
|
464
|
+
end
|
|
465
|
+
B-->>C: settle promise, delete fingerprint
|
|
466
|
+
end
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
**Diagram 6: pagination**
|
|
470
|
+
|
|
471
|
+
```mermaid
|
|
472
|
+
sequenceDiagram
|
|
473
|
+
participant C as Caller
|
|
474
|
+
participant P as Page
|
|
475
|
+
participant W as webex.request
|
|
476
|
+
C->>P: hasNext()
|
|
477
|
+
P-->>C: link present?
|
|
478
|
+
C->>P: next()
|
|
479
|
+
P->>W: request({uri: next link})
|
|
480
|
+
alt success
|
|
481
|
+
W-->>P: response
|
|
482
|
+
P-->>C: new Page
|
|
483
|
+
else failure
|
|
484
|
+
W-->>C: rejection
|
|
485
|
+
end
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
## Class and component relationships
|
|
489
|
+
|
|
490
|
+
```mermaid
|
|
491
|
+
classDiagram
|
|
492
|
+
class AmpState
|
|
493
|
+
class WebexCore {
|
|
494
|
+
+request
|
|
495
|
+
+prepareFetchOptions
|
|
496
|
+
+sessionId
|
|
497
|
+
+loaded
|
|
498
|
+
+ready
|
|
499
|
+
+logout()
|
|
500
|
+
+upload()
|
|
501
|
+
+setConfig()
|
|
502
|
+
}
|
|
503
|
+
class WebexInternalCore {
|
|
504
|
+
+ready
|
|
505
|
+
}
|
|
506
|
+
class WebexPlugin
|
|
507
|
+
class StatelessWebexPlugin
|
|
508
|
+
class Batcher
|
|
509
|
+
class Logger
|
|
510
|
+
class Page
|
|
511
|
+
class HttpError
|
|
512
|
+
class WebexHttpError
|
|
513
|
+
AmpState <|-- WebexCore
|
|
514
|
+
AmpState <|-- WebexInternalCore
|
|
515
|
+
AmpState <|-- WebexPlugin
|
|
516
|
+
WebexPlugin <|-- Batcher
|
|
517
|
+
WebexPlugin <|-- Logger
|
|
518
|
+
HttpError <|-- WebexHttpError
|
|
519
|
+
WebexCore *-- WebexInternalCore : internal
|
|
520
|
+
WebexCore o-- WebexPlugin : registered children
|
|
521
|
+
WebexInternalCore o-- WebexPlugin : internal children
|
|
522
|
+
WebexCore ..> WebexHttpError : HttpStatusInterceptor error type
|
|
523
|
+
Batcher ..> WebexHttpError : failure routing
|
|
524
|
+
Page ..> WebexCore : request
|
|
525
|
+
StatelessWebexPlugin ..> WebexCore : WeakMap reference
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
The five children attach as follows: `Credentials` is a public child plugin; `Services` is a child of
|
|
529
|
+
`WebexInternalCore`; the storage module builds the `boundedStorage` and `unboundedStorage` objects that
|
|
530
|
+
`WebexCore` and every `WebexPlugin` derive; the interceptors and the services-registered interceptors
|
|
531
|
+
are produced by the factories in the map.
|
|
532
|
+
|
|
533
|
+
## Use cases and flows
|
|
534
|
+
|
|
535
|
+
| Use case | Actor or caller | Primary steps and outcome | Failure or boundary behavior | Evidence |
|
|
536
|
+
| -------- | --------------- | ------------------------- | ---------------------------- | -------- |
|
|
537
|
+
| `UC-001` | Host application | Import plugin packages, call `new WebexCore({credentials, config})`, await ready, call plugins | Token in a legacy shape is normalized; malformed Bearer strings are repaired with a warning | `src/webex-core.js`, `test/unit/spec/webex-core.js` |
|
|
538
|
+
| `UC-002` | Plugin author | Subclass `WebexPlugin`, register with `registerPlugin`, read `this.config` for its namespace | Registering the same name twice is ignored unless `replace` is passed | `src/lib/webex-plugin.js`, `src/lib/webex-core-plugin-mixin.js`, `test/unit/spec/lib/webex-plugin.js` |
|
|
539
|
+
| `UC-003` | Plugin author | Register an internal plugin so it is reachable at `webex.internal.<name>` | Proxies are refused | `src/lib/webex-internal-core-plugin-mixin.js`, `test/unit/spec/webex-internal-core.js` |
|
|
540
|
+
| `UC-004` | Plugin | Call `this.request({service, resource})`; the chain adds tracking id, user agent, auth, and maps the failure | Failure rejects with WebexHttpError carrying options and body | `src/lib/webex-plugin.js`, `src/webex-core.js`, `test/integration/spec/webex-core.js` |
|
|
541
|
+
| `UC-005` | Host with custom pipeline | Pass `config.interceptors` to supply its own interceptor map | Plugin-registered interceptors are omitted; `CatalogUrlInterceptor` still needs the opt-in flag | `src/webex-core.js`, `test/unit/spec/webex-core.js` |
|
|
542
|
+
| `UC-006` | Host | Call `logout()`; plugin handlers run, stores clear, tokens are invalidated | A failing handler is logged and skipped | `src/webex-core.js`, `test/integration/spec/webex-core.js` |
|
|
543
|
+
| `UC-007` | Plugin with a bulk API | Extend `Batcher`, implement fingerprints and submit; callers call `request(item)` | Duplicate in-flight items share one promise; a failed batch rejects every caller | `src/lib/batcher.js`, `test/unit/spec/lib/batcher.js` |
|
|
544
|
+
| `UC-008` | Plugin with a list endpoint | Wrap the response in `new Page(res, webex)`; callers loop with `hasNext`/`next` | A failed neighbor fetch rejects | `src/lib/page.js`, `test/unit/spec/lib/page.js` |
|
|
545
|
+
| `UC-009` | Host | Call `upload` with a `file` and optional per-phase options for a three-phase upload and listen for `progress` | Oversize and missing-file rejections | `src/webex-core.js`, `test/unit/spec/webex-core.js` |
|
|
546
|
+
|
|
547
|
+
### Cross-boundary use-case flow
|
|
548
|
+
|
|
549
|
+
| Boundary | Transport | Ordering | Compatibility | Timeout and retry | Recovery |
|
|
550
|
+
| -------- | --------- | -------- | ------------- | ----------------- | -------- |
|
|
551
|
+
| Plugin to Webex service | HTTP through the assembled chain | Request hooks in array order, response hooks reversed | Option vocabulary comes from the transport library | No timeout or retry here; replay and redirect limits come from config keys read by the interceptors child | Failure arrives as WebexHttpError |
|
|
552
|
+
| Host to upload target | HTTP, three requests | initialize, optional abort or upload then finalize | Session body keys `url` and `fileUploadSizeLimit` are assumed | `retry` on the upload phase only | Abort sends `DELETE` to the session URL |
|
|
553
|
+
| Batcher to batched API | HTTP via subclass `submitHttpRequest` | One request per flush, at most `batcherMaxCalls` items | Response must be an array or hold `items` | Flush timing from three config keys; no retry in the base | Every deferred is settled, flush never throws |
|
|
554
|
+
| Page to next link | HTTP through `webex.request` | Sequential, caller-driven | Link header with `rel` names | None | Rejection reaches the caller |
|
|
555
|
+
|
|
556
|
+
## Client state model
|
|
557
|
+
|
|
558
|
+
| State or slice | Owner | Initial state | Transition triggers | Reset or persistence boundary |
|
|
559
|
+
| -------------- | ----- | ------------- | ------------------- | ----------------------------- |
|
|
560
|
+
| `config` | `WebexCore` session prop | `merge({}, defaults, attrs.config)` | `setConfig`; plugin `config` option mutates defaults for later instances only | In memory; never persisted |
|
|
561
|
+
| loaded | `WebexCore` session prop | `false` | Set `true` by the storage child once every persisted plugin hydrated | Per instance; not reset on logout |
|
|
562
|
+
| ready | Derived on `WebexCore` | `false` | Any change of loaded, `internal.ready`, or a plugin's ready | Recomputed; cached by ampersand |
|
|
563
|
+
| request | `WebexCore` session prop, set once | Unset until `initialize` | Assigned once | Immutable afterwards |
|
|
564
|
+
| sessionId | `WebexCore` session prop | Built in `initialize` | None | Per instance |
|
|
565
|
+
| `boundedStorage`, `unboundedStorage` | Derived on `WebexCore` and each plugin | Built lazily from adapters in config | First access | Cleared by `logout` |
|
|
566
|
+
| Plugin ready | Each `WebexPlugin` | `true` unless overridden | Plugin code | Per plugin |
|
|
567
|
+
| `deferreds`, `queue`, `bounce` | Each `Batcher` | Empty map, empty array, lazy debounce | request, flush | Entries removed on settle; queue spliced per flush |
|
|
568
|
+
|
|
569
|
+
## Business rules and invariants
|
|
570
|
+
|
|
571
|
+
| ID | Invariant | WHY | Enforcement source | Test evidence |
|
|
572
|
+
| -- | --------- | --- | ------------------ | ------------- |
|
|
573
|
+
| `INV-001` | A plugin name is registered at most once unless `replace` is passed | Duplicate registration would duplicate logout handlers, interceptors, and config merges | `src/lib/webex-core-plugin-mixin.js` | `test/unit/spec/_setup.js` |
|
|
574
|
+
| `INV-002` | request can be assigned only once per instance | The chain must not change after initialization | `src/webex-core.js` | none found |
|
|
575
|
+
| `INV-003` | Internal plugins never expose proxies | Private plugins must not leak onto the public object | `src/lib/webex-internal-core-plugin-mixin.js` | none found |
|
|
576
|
+
| `INV-004` | ready is true only when loaded is true and no child reports `ready === false` | Hosts treat ready as safe-to-use | `src/webex-core.js` | `test/unit/spec/webex-core.js` |
|
|
577
|
+
| `INV-005` | An allowed-domain match requires both URL parsers to yield the same normalized hostname | A disagreeing parse could authorize a host the transport does not contact | `src/lib/domains.ts` | `test/unit/spec/services/service-catalog.js` |
|
|
578
|
+
| `INV-006` | `CatalogUrlInterceptor` is included only when `validateCatalogUrls` is exactly `true` | A truthy string must not silently enable request blocking | `src/webex-core.js` | `test/unit/spec/webex-core.js` |
|
|
579
|
+
| `INV-007` | A `Batcher` flush never throws to its debounce caller, and every queued deferred is settled | Debounced callbacks cannot propagate rejections | `src/lib/batcher.js` | `test/unit/spec/lib/batcher.js` |
|
|
580
|
+
|
|
581
|
+
## Concurrency and reactive flow
|
|
582
|
+
|
|
583
|
+
- **Execution model:** single-threaded promise code on the host event loop plus ampersand events.
|
|
584
|
+
Listener wiring for `loaded` and `ready` is deferred with `process.nextTick` so hosts can attach
|
|
585
|
+
handlers after construction.
|
|
586
|
+
- **Ordering guarantees:** `onBeforeLogout` handlers run strictly serially, last registered first.
|
|
587
|
+
Upload phases run in sequence. Within a `Batcher`, items flush in enqueue order in slices of at most
|
|
588
|
+
`batcherMaxCalls`. No ordering exists across concurrent `request` calls.
|
|
589
|
+
- **Idempotency and retry:** `Batcher` de-duplicates concurrent identical items by fingerprint; the upload
|
|
590
|
+
phase is retried by the common `retry` decorator; nothing else in this module retries.
|
|
591
|
+
- **Shared-state protection:** the module-level default `config` and interceptor map are mutated by
|
|
592
|
+
registration and read by `initialize`; there is no locking, so registration must complete before
|
|
593
|
+
instances are constructed. `Batcher` state lives per instance.
|
|
594
|
+
- **Blocking restrictions:** `Page` iteration and getters are synchronous over stored items; network work
|
|
595
|
+
is only in `next`/`previous`. Handlers in `onBeforeLogout` are awaited, so a slow handler delays logout.
|
|
596
|
+
|
|
597
|
+
## State machine
|
|
598
|
+
|
|
599
|
+
```mermaid
|
|
600
|
+
stateDiagram-v2
|
|
601
|
+
[*] --> Constructed
|
|
602
|
+
Constructed --> Loaded: storage hydration drains, loaded event
|
|
603
|
+
Loaded --> Ready: all plugin ready flags not false, ready event
|
|
604
|
+
Constructed --> Ready: only if loaded was already true at next tick
|
|
605
|
+
Ready --> NotReady: a plugin sets ready false (no event)
|
|
606
|
+
NotReady --> Ready: plugin sets ready true (change:ready, no new ready event)
|
|
607
|
+
```
|
|
608
|
+
|
|
609
|
+
`loaded` and `ready` events each fire at most once, because their listeners remove themselves after the
|
|
610
|
+
first success. `NotReady` is a condition of derived state, not a named state in code; logout is not a lifecycle
|
|
611
|
+
state here and is owned by Diagram 3 and `MOD-018`; the `ready` property itself is recomputed on every dependency change.
|
|
612
|
+
|
|
613
|
+
## Caller-visible failure modes
|
|
614
|
+
|
|
615
|
+
| Condition | Signal or result | Caller behavior | Retry or recovery | Evidence |
|
|
616
|
+
| --------- | ---------------- | --------------- | ----------------- | -------- |
|
|
617
|
+
| HTTP status of 400 or higher on `webex.request` | Rejection with a WebexHttpError subtype whose message includes request identity | Branch on class, read `options`, `body` | Caller-owned | `src/lib/webex-http-error.js`, `test/integration/spec/webex-core.js` |
|
|
618
|
+
| Failing response lacking `options.headers` | Message construction throws a `TypeError` before the headers guard | Treat as an internal error | None | `src/lib/webex-http-error.js` |
|
|
619
|
+
| `upload` with no file | Rejection ``options.file is required`` | Fix the call | None | `src/webex-core.js`, `test/unit/spec/webex-core.js` |
|
|
620
|
+
| Upload exceeds size limit | Rejection whose message is JSON with `currentFileSizeInBytes`, `fileUploadSizeLimitInMB`, `file-upload-size-limit-enabled` | Parse the message string | Session is deleted first | `src/webex-core.js` |
|
|
621
|
+
| Plugin created without a parent | `WebexPlugin.webex` throws; `StatelessWebexPlugin` constructor throws | Supply `parent` or `webex` | None | `src/lib/webex-plugin.js`, `src/lib/stateless-webex-plugin.js` |
|
|
622
|
+
| `registerInternalPlugin` with proxies | Throws at registration | Remove the option | None | `src/lib/webex-internal-core-plugin-mixin.js` |
|
|
623
|
+
| `Batcher` subclass lacks required methods | Synchronous throw from request; rejection from a flush | Implement the methods | None | `src/lib/batcher.js` |
|
|
624
|
+
| `Batcher` batch fails | Every pending request rejects with the same reason | Retry at the call site | Caller-owned | `src/lib/batcher.js`, `test/unit/spec/lib/batcher.js` |
|
|
625
|
+
| `Page.next()` without a next link | Request issued with an undefined URI; transport decides the outcome | Check `hasNext()` first | None | `src/lib/page.js` |
|
|
626
|
+
| `when(event, callback)` | Throws: `#when() does not accept a callback` | Use the returned promise | None | `src/lib/webex-plugin.js` |
|
|
627
|
+
|
|
628
|
+
## Pitfalls and constraints
|
|
629
|
+
|
|
630
|
+
- **Registration is silent and global.** A second registration of the same name returns without applying
|
|
631
|
+
its options; a plugin that needs different options must pass `replace: true`. Instances constructed
|
|
632
|
+
before a registration never see that plugin.
|
|
633
|
+
- **`logout` reverses `config.onBeforeLogout` in place.** The array is the instance's merged copy, so a
|
|
634
|
+
second `logout` on the same instance runs handlers in registration order instead of reverse.
|
|
635
|
+
- **`config.interceptors` replaces, it does not extend.** Plugin-registered interceptors, including the
|
|
636
|
+
services interceptors, vanish from the chain when a host supplies its own map.
|
|
637
|
+
- **Environment variables are read at import.** `ENABLE_NETWORK_LOGGING`, `ENABLE_VERBOSE_NETWORK_LOGGING`,
|
|
638
|
+
`ENABLE_FEDRAMP`, and the three service URL variables take effect only if set before the module loads;
|
|
639
|
+
`ENABLE_FEDRAMP=false` still evaluates truthy.
|
|
640
|
+
- **`setConfig` does not re-run initialization.** The chain, `sessionId`, and anything a plugin cached at
|
|
641
|
+
construction keep old values. Only uncached reads such as `WebexPlugin.config` see the change.
|
|
642
|
+
- **The token normalizer mutates the caller's attrs object** (`unset` and `set` on it) and only validates
|
|
643
|
+
Bearer formatting for `credentials.access_token`, not for the bare-string constructor form.
|
|
644
|
+
- **`WebexHttpError` message construction assumes `options.headers` exists** for the tracking id line,
|
|
645
|
+
and assumes either `url`, `uri`, or `service` is present.
|
|
646
|
+
- **`WebexHttpError` import mutates the transport library's `HttpError`** by assigning `429` and
|
|
647
|
+
`TooManyRequests`.
|
|
648
|
+
- **`Batcher` defaults to throwing synchronously.** `fingerprintRequest` and `fingerprintResponse` throw
|
|
649
|
+
rather than returning rejected promises; and `batcherWait`, `batcherMaxWait`, `batcherMaxCalls` come
|
|
650
|
+
from the subclass's config namespace, not from `src/config.js`.
|
|
651
|
+
- **`Page.parseLinkHeaders` treats one `Link` header string as one link.** A header with several
|
|
652
|
+
comma-joined links in one string is mis-parsed; pass them as an array.
|
|
653
|
+
- **The storage `loaded` flag depends on a module-level set** in the storage child that is shared across
|
|
654
|
+
instances, so `loaded` is tied to a pending set shared by every instance in the process.
|
|
655
|
+
- **`src/index.js` import order matters.** The logger import must precede credentials and services,
|
|
656
|
+
because those register through `src/webex-core.js` and need the registry in place.
|
|
657
|
+
- **Services-v2 is exported but not registered.** See the services-v2 row of Public surface; importing the package does not activate it.
|
|
658
|
+
|
|
659
|
+
## Module-specific rules
|
|
660
|
+
|
|
661
|
+
- **Do:** register plugins at import time, before any `WebexCore` is constructed; use `replace: true` in
|
|
662
|
+
test setup as `test/unit/spec/_setup.js` does.
|
|
663
|
+
- **Do:** put a plugin's defaults in `options.config` and its extra pipeline stages in
|
|
664
|
+
`options.interceptors` rather than editing `src/config.js` or the map in `src/webex-core.js`.
|
|
665
|
+
- **Do:** use `Reflect.apply` and ampersand `session`/`derived` declarations as the surrounding code does.
|
|
666
|
+
- **Do:** add a new default interceptor to the map in `src/webex-core.js` and decide explicitly whether it
|
|
667
|
+
belongs in the pre or post group, because the middle position depends on registration order.
|
|
668
|
+
- **Do not:** make a plugin depend on a feature that needs `setConfig` after construction to rebuild the chain.
|
|
669
|
+
- **Do not:** call `fingerprintRequest` unimplemented on a `Batcher`, or rely on `request` being
|
|
670
|
+
reassignable.
|
|
671
|
+
|
|
672
|
+
## Export stability
|
|
673
|
+
|
|
674
|
+
| Export or entry point | Consumer | Stability | Versioning and deprecation rule | Declaration or API report |
|
|
675
|
+
| --------------------- | -------- | --------- | ------------------------------- | ------------------------- |
|
|
676
|
+
| `default`, `registerPlugin`, `registerInternalPlugin` | Every plugin and host | Stable | Registration options and the `WebexCore` instance members are relied on by about fifty packages; removal is breaking | `package.json`, `src/index.js` |
|
|
677
|
+
| `WebexPlugin`, `StatelessWebexPlugin` | Plugin authors | Stable | Derived and session member names are contract | `package.json`, `src/index.js` |
|
|
678
|
+
| WebexHttpError, `Batcher`, `Page` | Plugins | Stable | Override points of `Batcher` are contract | `package.json`, `src/index.js` |
|
|
679
|
+
| `config` | Hosts and tests | Stable, with keys that can be added | Existing key names and defaults are relied on | `package.json`, `src/index.js` |
|
|
680
|
+
| Re-exports for credentials, services, services-v2, storage, interceptors | Hosts and plugins | Per child contract | Governed by the child specifications | `package.json`, `src/index.js` |
|
|
681
|
+
| `dist/index.js` (main), `src/index.js` (devMain) | npm and workspace consumers | Stable | Build output of the legacy tools build | `package.json` |
|
|
682
|
+
|
|
683
|
+
There is no TypeScript declaration file or API report for the package; export changes are visible only by
|
|
684
|
+
reading `src/index.js`.
|
|
685
|
+
|
|
686
|
+
## Key design trade-off
|
|
687
|
+
|
|
688
|
+
| Chosen trade-off | Preserved invariant or benefit | Cost or limitation | Decision evidence |
|
|
689
|
+
| ---------------- | ------------------------------ | ------------------ | ----------------- |
|
|
690
|
+
| Services and credentials live in core, not in an external plugin | They exist at the first `initialize`, so every request is federation-aware from the start | Core carries large modules and their dependencies (jwt, crypto, ampersand collections) | `src/index.js` |
|
|
691
|
+
| Plugin registry is global on the prototype | Plugins self-register on import, no host wiring | Registration order and import side effects matter; late registration is invisible to existing instances; tests need reset hooks | `src/lib/webex-core-plugin-mixin.js`, `test/unit/spec/_setup.js` |
|
|
692
|
+
| Optional interceptors are absent map entries | Chain assembly is uniform and free of per-request checks | Env-driven inclusion is fixed at import; `config.interceptors` fully replaces the pipeline | `src/webex-core.js` |
|
|
693
|
+
| Dual URL parsing in the domain matcher | Credentials cannot be sent to a host the two parsers disagree on | A legitimately unusual URL fails closed | `src/lib/domains.ts` |
|
|
694
|
+
| Errors, upload, and batching built on one request function | One place to add cross-cutting behavior | Helpers cannot opt out of the chain | `src/webex-core.js` |
|
|
695
|
+
|
|
696
|
+
## Verification
|
|
697
|
+
|
|
698
|
+
| Requirement or invariant | Test level | Positive evidence | Negative or boundary evidence | Gap |
|
|
699
|
+
| ------------------------ | ---------- | ----------------- | ----------------------------- | --- |
|
|
700
|
+
| `MOD-001`, `MOD-002`, `MOD-003`, `MOD-004`, `MOD-005` | Unit | `test/unit/spec/webex-core.js` (thirty token path and form cases, six Bearer formatting cases) | `test/unit/spec/webex-core.js` (padded and glued Bearer strings) | Bare-string constructor form and the warning output |
|
|
701
|
+
| `MOD-006`, `MOD-007`, `MOD-009`, `MOD-010`, `MOD-012` | Unit | `test/unit/spec/webex-core.js` | none found | Defaults are asserted only for `fedramp`, `validateCatalogUrls`, and one `setConfig` key |
|
|
702
|
+
| `MOD-008`, `MOD-011` | — | none found | none found | No test for plugin-supplied config or env overrides |
|
|
703
|
+
| `MOD-013`, `INV-001` | Unit | `test/unit/spec/_setup.js` (replace path) | none found | The ignored-duplicate path is not asserted |
|
|
704
|
+
| `MOD-014`, `MOD-015`, `MOD-017` | Unit | `test/unit/spec/webex-core.js` | none found | Late registration and interceptor key collision |
|
|
705
|
+
| `MOD-016`, `INV-003` | — | none found | none found | The proxies throw |
|
|
706
|
+
| `MOD-018`, `MOD-033`, `MOD-034`, `MOD-035` | Integration | `test/integration/spec/webex-core.js` | `test/integration/spec/webex-core.js` (failing handler, missing token) | No unit-level logout test; second-call order reversal untested |
|
|
707
|
+
| `MOD-019`, `MOD-020`, `MOD-030`, `INV-004` | Unit | `test/unit/spec/webex-core.js`, `test/unit/spec/webex-internal-core.js` | `test/unit/spec/webex-core.js` (plugin held not-ready) | A ready regression after the event |
|
|
708
|
+
| `MOD-021` | Unit | `test/unit/spec/webex-core.js` | none found | Registration order between logger, credentials, services |
|
|
709
|
+
| `MOD-022`, `MOD-023`, `MOD-025`, `MOD-026`, `INV-006` | Unit | `test/unit/spec/webex-core.js` (default, opt-in, single, multiple, none) | `test/unit/spec/webex-core.js` (truthy non-boolean) | Env-driven logger inclusion; group-level ordering beyond the two default lists |
|
|
710
|
+
| `MOD-024`, `MOD-027`, `MOD-028`, `MOD-029` | Integration | `test/integration/spec/webex-core.js` (tracking id, user agent, WebexHttpError) | `test/integration/spec/webex-core.js` (unknown route) | Session-id suffix and base branches |
|
|
711
|
+
| `MOD-031` | Unit | `test/unit/spec/webex-core.js` | none found | Direct assertion of `change:<child>` |
|
|
712
|
+
| `MOD-032`, `MOD-036`, `MOD-037`, `MOD-058` | — | none found | none found | No tests |
|
|
713
|
+
| `MOD-038`, `MOD-042` | Unit | `test/unit/spec/webex-core.js` (rejections, progress pass-through with stubbed phases) | `test/unit/spec/webex-core.js` | Real phase wiring, retry |
|
|
714
|
+
| `MOD-039`, `MOD-040`, `MOD-041` | — | none found | none found | No test of defaults, abort, or `$` templating |
|
|
715
|
+
| `MOD-043`, `MOD-044` | Unit | `test/unit/spec/lib/webex-plugin.js`, `test/unit/spec/webex-internal-core.js` | none found | Throw path and `{}` fallback |
|
|
716
|
+
| `MOD-045`, `MOD-046`, `MOD-047` | Unit | `test/unit/spec/webex-core.js` (logger exists and logs) | none found | `clear`, `when`, stateless plugin, fallback precedence |
|
|
717
|
+
| `MOD-048`, `MOD-049` | Integration | `test/integration/spec/webex-core.js` | `test/unit/spec/lib/batcher.js` (error object use) | No unit test of message text or the 429 override |
|
|
718
|
+
| `MOD-050`, `MOD-051`, `MOD-052`, `MOD-053`, `INV-007` | Unit | `test/unit/spec/lib/batcher.js` | `test/unit/spec/lib/batcher.js` (failures, no unhandled rejection, no body) | Subclass not-implemented throws |
|
|
719
|
+
| `MOD-054`, `MOD-055` | Unit | `test/unit/spec/lib/page.js` | `test/unit/spec/lib/page.js` (no link header) | Comma-joined single header; `next()` without a link |
|
|
720
|
+
| `MOD-056`, `INV-005` | Unit (indirect) | `test/unit/spec/services/service-catalog.js` | none found | No dedicated spec for parser disagreement or normalization |
|
|
721
|
+
| `MOD-057`, `MOD-060` | — | none found | none found | Constants and scripts not asserted |
|
|
722
|
+
| `MOD-059` | Unit | `test/unit/spec/webex-core.js` (skipped) | none found | Tests are `it.skip` |
|
|
723
|
+
|
|
724
|
+
Auxiliary browser-runner specs `test/integration/spec/unit-browser/auth.js` and
|
|
725
|
+
`test/integration/spec/unit-browser/token.js` live under this module's test tree but exercise
|
|
726
|
+
`AuthInterceptor` and `Token`; their requirements are tracked in the interceptors and credentials
|
|
727
|
+
specifications. The fixtures `test/fixtures/host-catalog-v2.ts` and `test/fixtures/activation-email.ts`
|
|
728
|
+
are consumed by the services-v2 and services specs.
|
|
729
|
+
|
|
730
|
+
Gaps worth acting on: there is no unit test for logout, registration rules, upload phases, or the
|
|
731
|
+
stateless plugin; the version tests are skipped; and the integration tiers need provisioned test users.
|
|
732
|
+
Generator-side field measurement for this module is complete (see the coverage score above); independent validation is recorded in Metadata and drift remains unmeasured until it passes.
|