@webex/plugin-meetings 3.13.0-next.13 → 3.13.0-next.14

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.
Files changed (100) hide show
  1. package/.repo-context.json +577 -0
  2. package/.sdd/manifest.json +1320 -428
  3. package/AGENTS.md +528 -72
  4. package/dist/aiEnableRequest/index.js +1 -1
  5. package/dist/breakouts/breakout.js +1 -1
  6. package/dist/breakouts/index.js +1 -1
  7. package/dist/config.js +1 -1
  8. package/dist/interpretation/index.js +1 -1
  9. package/dist/interpretation/siLanguage.js +1 -1
  10. package/dist/webinar/index.js +1 -1
  11. package/docs/adr/0001-migrate-existing-docs-into-sdd.md +141 -0
  12. package/docs/adr/index.md +26 -0
  13. package/docs/architecture.md +816 -0
  14. package/docs/getting-started.md +177 -0
  15. package/docs/index.md +53 -0
  16. package/docs/specs/README.md +126 -0
  17. package/package.json +21 -21
  18. package/schemas/repo-context.schema.json +796 -0
  19. package/src/aiEnableRequest/docs/README.md +376 -0
  20. package/src/annotation/docs/README.md +402 -0
  21. package/src/breakouts/docs/README.md +643 -0
  22. package/src/controls-options-manager/docs/README.md +365 -0
  23. package/src/hashTree/docs/README.md +566 -0
  24. package/src/interceptors/docs/README.md +434 -0
  25. package/src/interpretation/docs/README.md +420 -0
  26. package/src/locus-info/docs/README.md +609 -0
  27. package/src/media/docs/README.md +488 -0
  28. package/src/meeting/docs/README.md +834 -0
  29. package/src/meeting-info/docs/README.md +352 -0
  30. package/src/meetings/docs/README.md +549 -0
  31. package/src/member/docs/README.md +347 -0
  32. package/src/members/docs/README.md +514 -0
  33. package/src/metrics/docs/README.md +287 -0
  34. package/src/multistream/docs/README.md +523 -0
  35. package/src/personal-meeting-room/docs/README.md +322 -0
  36. package/src/reachability/docs/README.md +548 -0
  37. package/src/reactions/docs/README.md +296 -0
  38. package/src/reconnection-manager/docs/README.md +485 -0
  39. package/src/recording-controller/docs/README.md +335 -0
  40. package/src/roap/docs/README.md +444 -0
  41. package/src/webinar/docs/README.md +425 -0
  42. package/.sdd/templates/.source.json +0 -30
  43. package/.sdd/templates/component-repo/module-docs/module-spec-quality.md +0 -111
  44. package/.sdd/templates/component-repo/module-docs/module-spec.template.md +0 -321
  45. package/.sdd/templates/component-repo/reference-docs/adr/_adr-example.md +0 -59
  46. package/.sdd/templates/component-repo/reference-docs/patterns/_pattern-example.md +0 -49
  47. package/.sdd/templates/component-repo/reference-docs/rules/_rule-example.md +0 -42
  48. package/.sdd/templates/component-repo/standing-docs/AGENTS.template.md +0 -120
  49. package/.sdd/templates/component-repo/standing-docs/ARCHITECTURE.template.md +0 -206
  50. package/.sdd/templates/component-repo/standing-docs/CONTRACTS.template.md +0 -90
  51. package/.sdd/templates/component-repo/standing-docs/DATA_MODEL.template.md +0 -68
  52. package/.sdd/templates/component-repo/standing-docs/GETTING_STARTED.template.md +0 -111
  53. package/.sdd/templates/component-repo/standing-docs/GLOSSARY.template.md +0 -57
  54. package/.sdd/templates/component-repo/standing-docs/REVIEW_CHECKLIST.template.md +0 -69
  55. package/.sdd/templates/component-repo/standing-docs/RULES.template.md +0 -96
  56. package/.sdd/templates/component-repo/standing-docs/SECURITY.template.md +0 -84
  57. package/.sdd/templates/component-repo/standing-docs/SERVICE_STATE.template.md +0 -82
  58. package/.sdd/templates/component-repo/standing-docs/SPEC_INDEX.template.md +0 -94
  59. package/.sdd/templates/component-repo/standing-docs/TEST_INDEX.template.md +0 -64
  60. package/.sdd/templates/component-repo/template-map.json +0 -112
  61. package/ai-docs/ARCHITECTURE.md +0 -208
  62. package/ai-docs/CONTRACTS.md +0 -267
  63. package/ai-docs/DATA_MODEL.md +0 -64
  64. package/ai-docs/GETTING_STARTED.md +0 -73
  65. package/ai-docs/GLOSSARY.md +0 -56
  66. package/ai-docs/REVIEW_CHECKLIST.md +0 -45
  67. package/ai-docs/RULES.md +0 -79
  68. package/ai-docs/SECURITY.md +0 -74
  69. package/ai-docs/SERVICE_STATE.md +0 -59
  70. package/ai-docs/SPEC_INDEX.md +0 -85
  71. package/ai-docs/TEST_INDEX.md +0 -45
  72. package/ai-docs/adr/0001-migrate-existing-docs-into-sdd.md +0 -61
  73. package/ai-docs/patterns/defensive-error-propagation.md +0 -55
  74. package/ai-docs/patterns/event-scope-emission.md +0 -46
  75. package/ai-docs/patterns/source-to-test-path-mirroring.md +0 -45
  76. package/ai-docs/patterns/stateless-plugin-request-classes.md +0 -53
  77. package/ai-docs/patterns/typed-constants-and-enum-values.md +0 -47
  78. package/src/aiEnableRequest/ai-docs/ai-enable-request-spec.md +0 -223
  79. package/src/annotation/ai-docs/annotation-spec.md +0 -236
  80. package/src/breakouts/ai-docs/breakouts-spec.md +0 -324
  81. package/src/controls-options-manager/ai-docs/controls-options-manager-spec.md +0 -243
  82. package/src/hashTree/ai-docs/hash-tree-spec.md +0 -267
  83. package/src/interceptors/ai-docs/interceptors-spec.md +0 -247
  84. package/src/interpretation/ai-docs/interpretation-spec.md +0 -256
  85. package/src/locus-info/ai-docs/locus-info-spec.md +0 -293
  86. package/src/media/ai-docs/media-spec.md +0 -267
  87. package/src/meeting/ai-docs/meeting-spec.md +0 -404
  88. package/src/meeting-info/ai-docs/meeting-info-spec.md +0 -261
  89. package/src/meetings/ai-docs/meetings-spec.md +0 -298
  90. package/src/member/ai-docs/member-spec.md +0 -196
  91. package/src/members/ai-docs/members-spec.md +0 -256
  92. package/src/metrics/ai-docs/metrics-spec.md +0 -185
  93. package/src/multistream/ai-docs/multistream-spec.md +0 -295
  94. package/src/personal-meeting-room/ai-docs/personal-meeting-room-spec.md +0 -234
  95. package/src/reachability/ai-docs/reachability-spec.md +0 -261
  96. package/src/reactions/ai-docs/reactions-spec.md +0 -198
  97. package/src/reconnection-manager/ai-docs/reconnection-manager-spec.md +0 -272
  98. package/src/recording-controller/ai-docs/recording-controller-spec.md +0 -223
  99. package/src/roap/ai-docs/roap-spec.md +0 -241
  100. package/src/webinar/ai-docs/webinar-spec.md +0 -243
@@ -0,0 +1,434 @@
1
+ ---
2
+ type: Module Spec
3
+ title: 'Locus and data-channel interceptors specification'
4
+ description: Responsibilities, boundaries, retry and token rules, failure modes, and verification for the request interceptors of plugin-meetings.
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: rarajes2@cisco.com
12
+ updated_at: 2026-11-17T03:14:21Z
13
+ validation_status: pass-with-warnings
14
+ -->
15
+
16
+ # Locus and data-channel interceptors
17
+
18
+ This source-local document at `src/interceptors/docs/README.md` owns the stable specification for
19
+ **the interceptors module** of `@webex/plugin-meetings`: three `@webex/http-core` request
20
+ interceptors that the package installs into the Webex request pipeline — a bounded retry for Locus
21
+ 429/503 responses, Locus route-token capture and attachment, and data-channel auth-token refresh.
22
+ Ground every claim in package evidence and link to the
23
+ [package architecture](../../../docs/architecture.md) instead of repeating broader facts. No service
24
+ specification exists because this package is a library.
25
+
26
+ Related context — start here: root [package agent instructions](../../../AGENTS.md) · router
27
+ [documentation index](../../../docs/index.md) · system [package architecture](../../../docs/architecture.md).
28
+ This is the canonical source-local spec for `src/interceptors/`.
29
+
30
+ Repo architecture: [package architecture](../../../docs/architecture.md) · Registry:
31
+ [documentation index](../../../docs/index.md) · Coverage state and contracts baseline: `.sdd/manifest.json`.
32
+
33
+ ## Metadata
34
+
35
+ | Field | Value |
36
+ |---|---|
37
+ | Owner | @webex/web-client, @webex/web-sdk |
38
+ | Source path | `src/interceptors` |
39
+ | Resource kind | module |
40
+ | Status | Draft |
41
+ | Last verified | 2026-11-16 at `0b8c34db7f` |
42
+ | Module id | `plugin-meetings/interceptors` |
43
+ | Parent spec | — |
44
+ | Doc kind | Module spec |
45
+ | Coverage score | Pending coverage assessment |
46
+ | Validation status | not-run |
47
+
48
+ ## Applicability
49
+
50
+ | Condition ID | Status | Evidence or reason | Owned section |
51
+ | ------------ | ------ | ------------------ | ------------- |
52
+ | `module.has_tiers` | N/A | No tier policy exists in `package.json` or `.sdd/manifest.json` | Tier |
53
+ | `module.has_ui` | N/A | `src/interceptors/index.ts` exports request middleware only | UI use-case flow |
54
+ | `module.crosses_service_boundaries` | Applicable | `src/interceptors/locusRetry.ts` re-issues Locus requests and `src/interceptors/dataChannelAuthToken.ts` refreshes tokens and re-issues data-channel requests | Cross-boundary use-case flow |
55
+ | `module.holds_client_state` | N/A | Process-level maps in `src/interceptors/locusRouteToken.ts` and `src/interceptors/dataChannelAuthToken.ts` are routing bookkeeping, not client-visible state | Client state model |
56
+ | `module.enforces_domain_rules` | Applicable | Status, path, header, and retry-count rules in `src/interceptors/locusRetry.ts`, `src/interceptors/locusRouteToken.ts`, and `src/interceptors/dataChannelAuthToken.ts` | Business rules and invariants |
57
+ | `module.is_concurrent_async` | Applicable | Every hook returns a promise; both retry paths wait on timers (`src/interceptors/locusRetry.ts`, `src/interceptors/dataChannelAuthToken.ts`) | Concurrency and reactive flow |
58
+ | `module.owns_persistence` | N/A | Nothing is stored beyond process memory in `src/interceptors/locusRouteToken.ts` | Data, schema, and migration discipline |
59
+ | `module.stateful_transitions` | N/A | The retry flag and counters in `src/interceptors/locusRetry.ts` are covered under Concurrency and reactive flow | State machine |
60
+ | `module.exposes_wire_protocol` | Applicable | The route-token and data-channel auth headers and the Locus URL pattern in `src/interceptors/locusRouteToken.ts` and `src/interceptors/constant.ts` | Protocol and wire format |
61
+ | `module.ui_multi_screen` | N/A | No UI | UI flow |
62
+ | `module.large_data_model` | N/A | No data model in `src/interceptors/index.ts` | Data model |
63
+ | `module.returns_caller_errors` | Applicable | Requests that end in these hooks reject with the HTTP error or a wrapped refresh error (`src/interceptors/locusRetry.ts`, `src/interceptors/dataChannelAuthToken.ts`) | Caller-visible failure modes |
64
+ | `module.module_specific_conventions` | N/A | Repository-wide rules in `AGENTS.md` apply unchanged | Module-specific rules |
65
+ | `module.published_package` | N/A | `src/index.ts` registers the interceptors but does not export them | Export stability |
66
+ | `module.embedded_in_host` | Applicable | `src/index.ts` hands the three factories to the plugin registration, and the host's request pipeline instantiates them | Host integration and theming |
67
+ | `module.has_design_tradeoff` | N/A | No recorded trade-off in `src/interceptors/index.ts` | Key design trade-off |
68
+ | `module.has_submodules` | N/A | The module directory has no child module | Sub-modules |
69
+
70
+ ## Evidence register
71
+
72
+ Requirements cite current source and mirrored tests. Current code wins over retained prose when they
73
+ conflict; commit and PR history are excluded. Missing evidence stays a gap.
74
+
75
+ | Evidence | What it establishes |
76
+ | -------- | ------------------- |
77
+ | `src/index.ts` | `registerPlugin('meetings', Meetings, {config, interceptors: {LocusRetryStatusInterceptor, LocusRouteTokenInterceptor, DataChannelAuthTokenInterceptor}})`, each value being the class's static `create` |
78
+ | `src/interceptors/index.ts` | Named exports of the three interceptor classes, nothing else |
79
+ | `src/interceptors/locusRetry.ts` | `LocusRetryStatusInterceptor.onResponseError` and `handleRetryRequestLocusServiceError`; the module-level `WeakMap` retry flag keyed by interceptor instance; the code comment that retrying `/hashtree` or `/sync` during a sync storm makes things worse and the sync timers recover them |
80
+ | `src/interceptors/locusRouteToken.ts` | `LocusRouteTokenInterceptor` with `LOCUS_ID_REGEX`, the `X-Cisco-Part-Route-Token` header, and the module-level `ROUTE_TOKEN` map |
81
+ | `src/interceptors/dataChannelAuthToken.ts` | `DataChannelAuthTokenInterceptor` with the URL-routed `refreshDataChannelToken`, `onRequest`, `onResponseError`, `refreshTokenAndRetryWithDelay`, and the module-level `retryCountMap` |
82
+ | `src/interceptors/constant.ts`, `src/interceptors/utils.ts` | `DATA_CHANNEL_AUTH_HEADER`, `MAX_RETRY = 1`, `RETRY_INTERVAL = 2000`, `RETRY_KEY = '_dcRetryKey'`; `isJwtTokenExpired` with a 30-second `EXPIRY_BUFFER` using `jose.decodeJwt` |
83
+ | `test/unit/spec/interceptors/locusRetry.ts`, `test/unit/spec/interceptors/locusRouteToken.ts`, `test/unit/spec/interceptors/dataChannelAuthToken.ts`, `test/unit/spec/interceptors/utils.ts` | Mirrored suites for each interceptor and the JWT helper |
84
+ | Sibling package webex-core, file src/webex-core.js | Each configured interceptor factory is called with the Webex instance as `this` (`Reflect.apply(interceptor, this, [])`), so each Webex instance gets one instance of each interceptor in its request pipeline |
85
+ | Sibling package http-core, file src/lib/interceptor.js | `Interceptor` copies constructor attributes onto the instance and supplies pass-through defaults for every hook |
86
+ | Observation, no stated WHY | `isJwtTokenExpired` returns `false` for a token without `exp` and `true` for a token `jose.decodeJwt` cannot decode (`src/interceptors/utils.ts`, `test/unit/spec/interceptors/utils.ts`) |
87
+ | Observation, no stated WHY | `LocusRetryStatusInterceptor` reads `retry-after` from the request options headers, not from the error response, and uses the value as milliseconds (`src/interceptors/locusRetry.ts`, `test/unit/spec/interceptors/locusRetry.ts`) |
88
+ | Observation, no stated WHY | The Locus retry re-sends only `method`, `uri`, and `body`; other request options such as headers and `qs` are dropped (`src/interceptors/locusRetry.ts`) |
89
+
90
+ ## Purpose and boundary
91
+
92
+ - Responsibility: Provides Webex-core request middleware for bounded Locus retries, Locus route-token
93
+ propagation, and data-channel auth-token refresh.
94
+ - In scope: the three interceptor classes, their constants, and the JWT expiry helper.
95
+ - Out of scope: the request pipeline and its other interceptors (`@webex/webex-core`,
96
+ `@webex/http-core`); issuing the data-channel token refresh request (the LLM channel in
97
+ `@webex/internal-plugin-llm`, or `Meeting.refreshDataChannelToken`); Locus sync recovery (the
98
+ locus-info and hashTree modules (`src/locus-info/docs/README.md`,
99
+ `src/hashTree/docs/README.md`)); what Locus and the data channel decide.
100
+ - Consumers: `src/index.ts` registers them; afterwards every request sent through `webex.request` on
101
+ that Webex instance passes through them, whichever plugin sends it.
102
+
103
+ ## Structure and key files
104
+
105
+ `src/interceptors` contains 6 direct source/reference file(s) and has 4 mirrored unit-test file(s). Stack:
106
+ TypeScript/JavaScript in the Node 22.14 Yarn workspace; Webex core/plugin abstractions and
107
+ Mocha/Sinon/`@webex/test-helper-chai` tests.
108
+
109
+ ```text
110
+ src/interceptors/
111
+ ├── constant.ts — interceptor constants (data-channel header and retry settings)
112
+ ├── dataChannelAuthToken.ts — dataChannelAuthToken implementation responsibility (DataChannelAuthTokenInterceptor)
113
+ ├── index.ts — module facade/controller or primary exports (the three classes)
114
+ ├── locusRetry.ts — locusRetry implementation responsibility (LocusRetryStatusInterceptor)
115
+ ├── locusRouteToken.ts — locusRouteToken implementation responsibility (LocusRouteTokenInterceptor)
116
+ ├── utils.ts — normalization/helper functions (isJwtTokenExpired)
117
+ └── docs/README.md — canonical module specification
118
+ ```
119
+
120
+ | File | Holds |
121
+ |---|---|
122
+ | `src/interceptors/constant.ts` | interceptor constants: `DATA_CHANNEL_AUTH_HEADER`, `MAX_RETRY`, `RETRY_INTERVAL`, `RETRY_KEY` |
123
+ | `src/interceptors/dataChannelAuthToken.ts` | dataChannelAuthToken implementation responsibility: `DataChannelAuthTokenInterceptor` and its URL-routed refresh |
124
+ | `src/interceptors/index.ts` | module facade/controller or primary exports: the three interceptor classes |
125
+ | `src/interceptors/locusRetry.ts` | locusRetry implementation responsibility: `LocusRetryStatusInterceptor` |
126
+ | `src/interceptors/locusRouteToken.ts` | locusRouteToken implementation responsibility: `LocusRouteTokenInterceptor` and the route-token map |
127
+ | `src/interceptors/utils.ts` | normalization/helper functions: `isJwtTokenExpired` |
128
+ | `test/unit/spec/interceptors/dataChannelAuthToken.ts` and 3 sibling test file(s) | mirrored characterization/unit coverage: `locusRetry.ts`, `locusRouteToken.ts`, and `utils.ts` |
129
+
130
+ ## Public surface
131
+
132
+ | Contract ID | Type | Surface | Purpose | Compatibility / deprecation | Schema / detail link | Root index |
133
+ |---|---|---|---|---|---|---|
134
+ | `locus-interceptors` | request interceptor | `LocusRetryStatusInterceptor.create()`, `onResponseError()`, and `handleRetryRequestLocusServiceError()` | Retry one eligible Locus 429/503 response while excluding hash-tree/sync recovery routes. | Preserve the instance-local one-retry `WeakMap` guard and the delay selection (request `retry-after` or 2000 ms). | `src/interceptors/locusRetry.ts` | [package architecture](../../../docs/architecture.md) |
135
+ | `locus-interceptors` | request/response interceptor | `LocusRouteTokenInterceptor.create()`, `getLocusIdByRequestUrl()`, `getLocusIdByResponseBody()`, `getHeader()`, `onResponse()`, `onRequest()`, `updateToken()`, and `getToken()` | Capture route tokens by Locus id and attach only the token matching the outgoing request. | Never leak a token across Locus ids; preserve response/header parsing. | `src/interceptors/locusRouteToken.ts` | [package architecture](../../../docs/architecture.md) |
136
+ | `locus-interceptors` | auth interceptor | `DataChannelAuthTokenInterceptor.create()`, `onRequest()`, `onResponseError()`, and `refreshTokenAndRetryWithDelay()` | Attach a usable data-channel token and perform the bounded refresh/retry path after auth failure. | Preserve `MAX_RETRY = 1`, `RETRY_INTERVAL = 2000`, and per-options retry bookkeeping. | `src/interceptors/dataChannelAuthToken.ts` | [package architecture](../../../docs/architecture.md) |
137
+ | `locus-interceptors` | exported utility | `isJwtTokenExpired()` | Treat a token as expired when its JWT expiry is within the 30-second safety buffer. | Preserve malformed-token handling and the exact buffer used before request dispatch. | `src/interceptors/utils.ts` | [package architecture](../../../docs/architecture.md) |
138
+ | `locus-interceptors` | exported constants | `DATA_CHANNEL_AUTH_HEADER`, `MAX_RETRY`, `RETRY_INTERVAL`, and `RETRY_KEY` | Share the exact header and bounded-retry settings used by the auth interceptor. | Header/key values and retry limits are observable request behavior. | `src/interceptors/constant.ts` | [package architecture](../../../docs/architecture.md) |
139
+
140
+ Contract ID `locus-interceptors` is internal to the package: `src/index.ts` registers the factories
141
+ but does not export the classes. It is indexed in the
142
+ [package architecture](../../../docs/architecture.md) and registered in `.sdd/manifest.json`; the
143
+ module requires `webex-core-plugin-host` and `internal-plugin-llm-channel`.
144
+
145
+ Compatibility notes:
146
+
147
+ - Prefer additive fields/options and preserve current return and rejection semantics. Internal helpers are not public merely because they are exported within the source directory.
148
+
149
+ ## Dependencies
150
+
151
+ Webex core Interceptor/request pipeline, JWT decoding helpers, LLM data channels and the meetings
152
+ collection, request URLs/headers, timers, and retry constants.
153
+
154
+ | Dependency | Why it is required | Failure behavior |
155
+ | ---------- | ------------------ | ---------------- |
156
+ | `@webex/http-core` `Interceptor` base class (imported, not declared in `package.json`) | Hook defaults and attribute copying for all three classes | — |
157
+ | `@webex/webex-core` request pipeline (contract `webex-core-plugin-host`) | Calls each `create` with the Webex instance as `this`; runs the hooks on every request; `webex.request` re-sends retried requests | A re-sent request passes through every interceptor again |
158
+ | `webex.internal.llm` (`@webex/internal-plugin-llm`, contract `internal-plugin-llm-channel`) | `isDataChannelTokenEnabled()` gates the data-channel hooks; `getChannelByDatachannelUrl()` finds the channel that refreshes the token; `LLMChannel.matchesDatachannelRequestUrl` matches meeting URLs | A rejection of the enabled check rejects the hook |
159
+ | `webex.meetings.getAllMeetings()` and `Meeting.refreshDataChannelToken()` / `setLLMChannelDataToken()` | Fallback refresh when no LLM channel matches the request URL | No match throws `No LLM channel or meeting found for request URL` |
160
+ | `jose` `decodeJwt` | Reads `exp` without verifying the signature | A decode error counts as expired |
161
+ | `LoggerProxy` (`src/common/logs/logger-proxy.ts`) | Warns on a failed pre-request refresh; errors when the retry count is exhausted | — |
162
+
163
+ ## Requirements
164
+
165
+ | ID | WHAT | WHY | Source Evidence | Test / Example Evidence | Assumptions / Gaps | Confidence |
166
+ |---|---|---|---|---|---|---|
167
+ | `INTERCEPTORS-R-001` | retry eligible Locus failures using status-based rules: a response error with status 429 or 503 on a URI containing `locus` is retried once by `LocusRetryStatusInterceptor`. | The retry JSDoc handles Locus service-unavailable errors, which are temporary, so one delayed retry can succeed without caller involvement. | `src/interceptors/locusRetry.ts`, `src/interceptors/index.ts` | `test/unit/spec/interceptors/locusRetry.ts` | none | PRESENT |
168
+ | `INTERCEPTORS-R-002` | capture and attach route tokens keyed by Locus id. | A route or auth token attached to the wrong request can leak authority across meetings or retry indefinitely. | `src/interceptors/locusRouteToken.ts`, `src/interceptors/index.ts` | `test/unit/spec/interceptors/locusRouteToken.ts` | no case attaches a stored token to a request for another Locus id | PRESENT |
169
+ | `INTERCEPTORS-R-003` | Failures outside the eligible retry branches reject with the original reason. For an eligible Locus 429/503 after this interceptor instance has already retried once, `LocusRetryStatusInterceptor.onResponseError()` clears its retry flag and rejects with the original HTTP reason. Locus retries are bounded per interceptor; token-refresh retries are tracked through request options. | Rejecting the original reason preserves the terminal HTTP status and response details for callers. | `src/interceptors/locusRetry.ts`, `src/interceptors/dataChannelAuthToken.ts` | `test/unit/spec/interceptors/locusRetry.ts`, `test/unit/spec/interceptors/dataChannelAuthToken.ts` | none | PRESENT |
170
+ | `INTERCEPTORS-R-004` | Locus retry handles one eligible 429/503 retry per interceptor instance using the `WeakMap` flag and the existing delay selection (default 2000 ms); Locus `/hashtree` and `/sync` 429/5xx responses are excluded. | Global request middleware must not amplify synchronization storms, retry terminal failures, or loop indefinitely. | `src/interceptors/locusRetry.ts` | `test/unit/spec/interceptors/locusRetry.ts` | none | PRESENT |
171
+ | `INTERCEPTORS-R-005` | Route tokens are extracted from supported Locus responses, keyed by Locus id, and attached only to matching requests. | Loose routing could omit a required token or leak it to an unrelated request. | `src/interceptors/locusRouteToken.ts` | `test/unit/spec/interceptors/locusRouteToken.ts` | none | PRESENT |
172
+ | `INTERCEPTORS-R-006` | Data-channel JWTs are treated as expired when `exp` is within the 30-second (`30 * 1000`) buffer, refreshed when needed, and retried once after 2000 ms on eligible 401/403 responses. | Refreshing before expiry avoids a request racing token expiration without creating an authentication retry storm. | `src/interceptors/dataChannelAuthToken.ts`, `src/interceptors/utils.ts`, `src/interceptors/constant.ts` | `test/unit/spec/interceptors/dataChannelAuthToken.ts`, `test/unit/spec/interceptors/utils.ts` | none | PRESENT |
173
+ | `INTERCEPTORS-R-007` | Both data-channel hooks act only when the request carries a `Data-Channel-Auth-Token` header (any case) and `webex.internal.llm.isDataChannelTokenEnabled()` resolves true; otherwise `onRequest` returns the options unchanged and `onResponseError` rejects with the original reason. | The interceptor sees every request of the Webex instance and must leave requests without a data-channel token, or with the feature off, untouched. | `src/interceptors/dataChannelAuthToken.ts` | `test/unit/spec/interceptors/dataChannelAuthToken.ts` | none | PRESENT |
174
+ | `INTERCEPTORS-R-008` | A token refresh is routed by request URL: the LLM channel returned by `getChannelByDatachannelUrl` refreshes and stores the token; with no channel, the meeting whose `datachannelUrl` or `practiceSessionDatachannelUrl` matches refreshes it and stores it on its LLM channel; a refresh result without `body` throws `DataChannel token refresh returned no payload`, and no match throws `No LLM channel or meeting found for request URL`. | The code comment: route refresh by request URL, because each meeting (and its practice session) owns its own channel and token. | `src/interceptors/dataChannelAuthToken.ts` | `test/unit/spec/interceptors/dataChannelAuthToken.ts` | none | PRESENT |
175
+ | `INTERCEPTORS-R-009` | Importing the package registers the three factories on the `meetings` plugin, so each Webex instance builds one instance of each interceptor in its request pipeline. | Locus and data-channel requests are sent through `webex.request` by many modules; the pipeline is the one place every such request passes. | `src/index.ts`, `src/interceptors/index.ts` | None found | registration is not asserted by a unit case | PRESENT |
176
+
177
+ ## Design overview
178
+
179
+ `index.ts` only exports three independent Webex-core interceptors. `locusRetry.ts` bounds eligible
180
+ retries, `locusRouteToken.ts` stores/attaches tokens by Locus id, and `dataChannelAuthToken.ts`
181
+ refreshes expiring channel credentials; none is a controller for the others.
182
+
183
+ Each class extends the `@webex/http-core` `Interceptor` and overrides only the hooks it needs:
184
+ `LocusRetryStatusInterceptor` overrides `onResponseError`; `LocusRouteTokenInterceptor` overrides
185
+ `onRequest` and `onResponse`; `DataChannelAuthTokenInterceptor` overrides `onRequest` and
186
+ `onResponseError`. State lives in module-level maps shared by every instance in the process: the
187
+ Locus retry flag (`WeakMap` keyed by interceptor instance), the route tokens (`ROUTE_TOKEN` keyed by
188
+ Locus id), and the data-channel retry counts (`retryCountMap` keyed by the `_dcRetryKey` stamped on
189
+ the request options). `DataChannelAuthTokenInterceptor.create` injects the two functions that reach
190
+ the LLM plugin and the meetings collection, so the class itself depends only on its constructor
191
+ options.
192
+
193
+ ## Data flow and sequence coverage
194
+
195
+ Call style: in-process hooks invoked by the `@webex/webex-core` request pipeline around HTTPS
196
+ requests; retries re-enter the pipeline through `webex.request`. There are three operation groups,
197
+ one per interceptor; the data-channel group has a pre-request refresh and a post-error retry.
198
+
199
+ ```mermaid
200
+ flowchart LR
201
+ Request[Webex-core request] --> Retry[locusRetry.ts]
202
+ Request --> Route[locusRouteToken.ts]
203
+ Request --> Auth[dataChannelAuthToken.ts]
204
+ Retry --> Continue[retry or propagate response]
205
+ Route --> Continue
206
+ Auth --> Refresh[data-channel token refresh]
207
+ Refresh --> Continue
208
+ Constants[constant.ts] --> Auth
209
+ Utils[utils.ts] --> Auth
210
+ ```
211
+
212
+ Sequence coverage:
213
+
214
+ | Operation group | Diagram | Failure coverage |
215
+ |---|---|---|
216
+ | UC-1…UC-4 — request interceptor operation groups | Request interceptor sequence | ineligible Locus status, token mismatch/expiry, refresh failure, and retry exhaustion; non-retryable status, exhausted retry count, missing Locus-token match, or failed data-channel token refresh |
217
+ | UC-2 — route-token capture and attachment | Route-token sequence | no Locus id, no header, `null` token deletion |
218
+ | UC-3 — pre-request data-channel refresh | Pre-request refresh sequence | feature disabled, no header, refresh failure continues with the old token |
219
+
220
+ Request interceptor sequence:
221
+
222
+ ```mermaid
223
+ sequenceDiagram
224
+ participant W as Webex request pipeline
225
+ participant I as Locus / data-channel interceptor
226
+ participant T as Token refresh
227
+ participant N as next()
228
+ W->>I: request or response context (response failure or authenticated request)
229
+ I->>I: evaluate only its retry/token rule
230
+ alt eligible Locus 429/503 outside /hashtree and /sync with no prior retry
231
+ I->>I: wait selected delay or 2000 ms, retry once
232
+ I-->>W: retry result or rejection
233
+ else eligible Locus request was already retried
234
+ I--xW: reject with the original HTTP reason
235
+ else data-channel 401/403 with enabled token
236
+ I->>T: refresh token after 2000 ms
237
+ T-->>I: token or failure
238
+ I-->>W: one retry result or wrapped refresh failure
239
+ else rule does not apply
240
+ I->>N: unchanged context / propagated error
241
+ N-->>W: response or rejection
242
+ end
243
+ ```
244
+
245
+ Route-token sequence:
246
+
247
+ ```mermaid
248
+ sequenceDiagram
249
+ participant W as Webex request pipeline
250
+ participant R as LocusRouteTokenInterceptor
251
+ participant M as ROUTE_TOKEN map
252
+ W->>R: onResponse(options, response)
253
+ R->>R: locus id from body.locus.url, else from options.uri
254
+ opt id found and X-Cisco-Part-Route-Token header present
255
+ alt header value null or "null"
256
+ R->>M: delete token for id
257
+ else
258
+ R->>M: store token for id
259
+ end
260
+ end
261
+ R-->>W: response unchanged
262
+ W->>R: onRequest(options)
263
+ R->>M: token for id in options.uri
264
+ opt token stored
265
+ R->>R: set X-Cisco-Part-Route-Token header
266
+ end
267
+ R-->>W: options
268
+ ```
269
+
270
+ Pre-request refresh sequence:
271
+
272
+ ```mermaid
273
+ sequenceDiagram
274
+ participant W as Webex request pipeline
275
+ participant D as DataChannelAuthTokenInterceptor
276
+ participant L as LLM channel or Meeting
277
+ W->>D: onRequest(options)
278
+ D->>D: Data-Channel-Auth-Token header and isDataChannelTokenEnabled()
279
+ opt header set, enabled, and token expires within 30 s
280
+ D->>L: refreshDataChannelToken(options.uri or options.url)
281
+ alt refreshed
282
+ L-->>D: datachannelToken
283
+ D->>D: replace the header value
284
+ else refresh fails
285
+ D->>D: log a warning, keep the old token
286
+ end
287
+ end
288
+ D-->>W: options
289
+ ```
290
+
291
+ ## Class and component relationships
292
+
293
+ ```mermaid
294
+ classDiagram
295
+ class Interceptor
296
+ class Request
297
+ class Retry
298
+ class Route
299
+ class Auth
300
+ class Refresh
301
+ class Constants
302
+ class Utils
303
+ Interceptor <|-- Retry
304
+ Interceptor <|-- Route
305
+ Interceptor <|-- Auth
306
+ Request --> Retry
307
+ Request --> Route
308
+ Request --> Auth
309
+ Auth --> Refresh
310
+ Constants --> Auth
311
+ Utils --> Auth
312
+ ```
313
+
314
+ The arrows identify ownership and delegation inside `src/interceptors/`; files that only declare types
315
+ or constants are not presented as transports. `Interceptor` is the `@webex/http-core` base class,
316
+ `Request` is the webex-core pipeline, `Retry` is `LocusRetryStatusInterceptor`, `Route` is
317
+ `LocusRouteTokenInterceptor`, `Auth` is `DataChannelAuthTokenInterceptor`, `Refresh` is the injected
318
+ URL-routed refresh function, `Constants` is `constant.ts`, and `Utils` is `utils.ts`.
319
+
320
+ ## Use cases and flows
321
+
322
+ | Use case | Actor or caller | Primary steps and outcome | Failure or boundary behavior | Evidence |
323
+ | -------- | --------------- | ------------------------- | ---------------------------- | -------- |
324
+ | `UC-1` | Any module sending a Locus request | Retry one eligible Locus 429/503 response after the selected delay (request `retry-after`, else 2000 ms) while leaving hash-tree/sync failures to their owning recovery paths. | The next eligible failure on the same Webex instance rejects without retry and clears the flag | `src/interceptors/locusRetry.ts`, `test/unit/spec/interceptors/locusRetry.ts` |
325
+ | `UC-2` | Any module sending Locus requests | Capture a route token from a Locus response and attach it only to a later request whose URL resolves to the same Locus id. | A response without the header keeps the stored token; a `null` value deletes it | `src/interceptors/locusRouteToken.ts`, `test/unit/spec/interceptors/locusRouteToken.ts` |
326
+ | `UC-3` | LLM channel or Meeting sending a data-channel request | Attach an unexpired data-channel token to an outgoing request, using the 30-second JWT expiry buffer. | A failed refresh is logged and the request is sent with the old token | `src/interceptors/dataChannelAuthToken.ts`, `test/unit/spec/interceptors/dataChannelAuthToken.ts` |
327
+ | `UC-4` | Same, after a 401 or 403 | On the handled auth failure, wait 2000 ms, refresh, retry once, and clear the retry key after success or refresh failure. | A second 401/403 on the retry rejects; the caller sees `DataChannel token refresh failed: …` | `src/interceptors/dataChannelAuthToken.ts`, `test/unit/spec/interceptors/dataChannelAuthToken.ts` |
328
+
329
+ ### Cross-boundary use-case flow
330
+
331
+ | Boundary | Transport and ordering | Compatibility | Timeout, retry, and recovery |
332
+ | -------- | ---------------------- | ------------- | ---------------------------- |
333
+ | Locus (`UC-1`, `UC-2`) | HTTPS through the webex-core pipeline; the retry is a new `webex.request` after the delay | Route tokens use `X-Cisco-Part-Route-Token`; Locus ids follow `/locus/api/v1/loci/<uuid>` | One retry per eligible failure, alternating per interceptor instance; `/hashtree` and `/sync` recover through their own sync timers |
334
+ | Data channel (`UC-3`, `UC-4`) | HTTPS through the pipeline; the refresh runs before the request or 2000 ms after a 401/403 | `Data-Channel-Auth-Token` header carries the JWT | One refresh-and-retry per request options object (`MAX_RETRY = 1`) |
335
+ | LLM plugin and meetings collection (refresh) | In-process calls that issue their own refresh request | Refresh result must carry `body.datachannelToken` | Errors propagate into the hook as described under Caller-visible failure modes |
336
+
337
+ ## Business rules and invariants
338
+
339
+ - Tokens attach only to intended request routes; JWT expiry includes the 30-second buffer;
340
+ data-channel retry stops at `MAX_RETRY = 1`; terminal auth/service errors propagate. Enforced under
341
+ `src/interceptors/`.
342
+
343
+ | ID | Invariant | WHY | Enforcement source | Test evidence |
344
+ | -- | --------- | --- | ------------------ | ------------- |
345
+ | `INV-001` | A Locus URI whose path contains `/locus/` and ends with `/hashtree` or `/sync` is never retried on 429 or any status of 500 or above; a URI that cannot be parsed is not treated as such. | The code comment: retries during a sync storm make things worse, and the normal sync timers recover these endpoints (`INTERCEPTORS-R-004`). | `src/interceptors/locusRetry.ts` | `test/unit/spec/interceptors/locusRetry.ts` |
346
+ | `INV-002` | A route token is attached only when the request URI yields a Locus id with a stored token, and only under that id. | Loose routing could leak a token to an unrelated request (`INTERCEPTORS-R-005`). | `src/interceptors/locusRouteToken.ts` | `test/unit/spec/interceptors/locusRouteToken.ts` |
347
+ | `INV-003` | A data-channel request is refreshed and retried at most once after a 401/403; its retry key is removed after success, refresh failure, or exhaustion. | Avoid an authentication retry storm (`INTERCEPTORS-R-006`). | `src/interceptors/dataChannelAuthToken.ts`, `src/interceptors/constant.ts` | `test/unit/spec/interceptors/dataChannelAuthToken.ts` |
348
+
349
+ ## Concurrency and reactive flow
350
+
351
+ - `LocusRetryStatusInterceptor` permits one retry per interceptor instance using its `WeakMap` flag and never retries Locus `/hashtree` or `/sync` 429/5xx failures. Data-channel retries are keyed on the request options, wait 2000 ms, and stop after `MAX_RETRY = 1`; the key is removed after success or refresh failure.
352
+ - Execution model: one JavaScript event loop; every hook returns a promise, and both retry paths wait
353
+ on a `setTimeout`.
354
+ - Ordering guarantees: none across requests. The Locus flag is shared by all requests of the
355
+ interceptor instance, not tracked per request: after a retry the flag stays set until the next
356
+ eligible failure, which rejects without retry and clears it, so concurrent eligible failures do not
357
+ each get a retry.
358
+ - Idempotency and retry: the Locus retry re-sends `method`, `uri`, and `body` regardless of HTTP
359
+ method; the data-channel retry re-sends the full options with the new token.
360
+ - Shared-state protection: none. `ROUTE_TOKEN` and `retryCountMap` are module-level, so every Webex
361
+ instance in the process shares them.
362
+
363
+ ## Protocol and wire format
364
+
365
+ - Existing request/event/channel types and constants under `src/interceptors/` own serialization and
366
+ parsing. Preserve field names, enum/raw values, identity/routing fields, and compatibility;
367
+ normalized client properties are not a replacement wire schema.
368
+
369
+ | Message or frame | Version | Producer or serializer | Consumer or parser | Compatibility and ordering rule |
370
+ | ---------------- | ------- | ---------------------- | ------------------ | ------------------------------- |
371
+ | `X-Cisco-Part-Route-Token` response header | Unversioned | Locus | `LocusRouteTokenInterceptor.onResponse` | Read case-insensitively; the value `null` or the string `null` deletes the stored token |
372
+ | `X-Cisco-Part-Route-Token` request header | Unversioned | `LocusRouteTokenInterceptor.onRequest` | Locus | Set only on requests whose URI carries a Locus id with a stored token |
373
+ | Locus id in `/locus/api/v1/loci/<36-character hex-and-dash id>` | — | Locus URLs | `LOCUS_ID_REGEX` | Taken from `body.locus.url` before the request URI |
374
+ | `Data-Channel-Auth-Token` request header | Unversioned | LLM channel or Meeting | `DataChannelAuthTokenInterceptor` | Read case-insensitively; replaced under the exact name `Data-Channel-Auth-Token` |
375
+ | Request option `_dcRetryKey` | — | `DataChannelAuthTokenInterceptor` | The same interceptor | Stamped on the options object as `<timestamp>-<random>`; never sent as a header |
376
+ | `retry-after` request header | — | The caller's request options | `LocusRetryStatusInterceptor` | Used as milliseconds; absent means 2000 |
377
+
378
+ ## Caller-visible failure modes
379
+
380
+ | Condition | Signal | Caller recovery |
381
+ |---|---|---|
382
+ | Locus failure is not 429/503, is a `/hashtree` or `/sync` 429/5xx, or has already been retried | The interceptor rejects without another retry. | Let the normal sync/recovery path or caller policy handle the failure. |
383
+ | A route token does not match the request's Locus id | No unrelated route token is attached. | Continue without a token or obtain the token for the matching Locus. |
384
+ | Data-channel token refresh or its single retry fails | The interceptor clears its retry key and rejects with a `DataChannel token refresh failed: <message>` error carrying `statusCode` and `original`; when the retry count is already exhausted it rejects with the original terminal response. | Re-establish valid data-channel credentials before a new request. |
385
+ | Data-channel 401/403 while the token feature is disabled or the request has no `Data-Channel-Auth-Token` header | The original HTTP error, unchanged. | Handle the error. |
386
+ | Pre-request refresh fails | No error: a warning is logged and the request is sent with the expired token. | A resulting 401/403 enters the retry path. |
387
+
388
+ ## Pitfalls and constraints
389
+
390
+ - An interceptor runs across host requests. Loose URL matching or header reuse can leak meeting tokens to an unrelated service.
391
+ - Verify both typed constants/enums and raw wire values before changing a logical condition in this legacy package.
392
+ - The Locus retry matches any URI containing `locus`, host names included, and its delay comes from the
393
+ request options, not from a server `Retry-After` response header.
394
+ - The Locus retry drops request headers and query options; the route-token interceptor re-adds its
395
+ header on the new request, but other headers are not re-sent.
396
+ - `@webex/http-core` is imported by all three interceptors but is not listed in `package.json`; it
397
+ resolves through the workspace.
398
+ - `updateToken(id, undefined)` stores `undefined` rather than deleting the entry.
399
+
400
+ ## Host integration and theming
401
+
402
+ The Webex SDK host provides request, identity, event, and media capabilities and exposes this module
403
+ through `webex.meetings` or Meeting-composed controllers. The module renders no UI and has no theme
404
+ contract.
405
+
406
+ - Mount or entry contract: `registerPlugin('meetings', …, {interceptors})` in `src/index.ts`;
407
+ webex-core calls each `create` with the Webex instance as `this`.
408
+ - Required providers, peers, or host versions: `@webex/webex-core` and `@webex/http-core` from the
409
+ workspace; `webex.internal.llm` and `webex.meetings` for the data-channel interceptor.
410
+ - Theme and design-token contract: none.
411
+ - Accessibility and lifecycle obligations: none; the instances live as long as the Webex instance.
412
+
413
+ ## Verification
414
+
415
+ Use the current mirrored suites: `test/unit/spec/interceptors/dataChannelAuthToken.ts`,
416
+ `test/unit/spec/interceptors/locusRetry.ts`, `test/unit/spec/interceptors/locusRouteToken.ts`,
417
+ `test/unit/spec/interceptors/utils.ts`. Characterize the interceptors-specific use cases above and
418
+ each listed failure condition; add cleanup or transition cases only for resources and state this
419
+ module actually owns.
420
+
421
+ | Behavior / Requirement | Existing test evidence | Gap |
422
+ |---|---|---|
423
+ | `INTERCEPTORS-R-001` | `test/unit/spec/interceptors/locusRetry.ts` | retry, route-token, and data-channel interceptor families are now covered independently, one suite each; no case covers a URI containing `locus` only in its host name |
424
+ | `INTERCEPTORS-R-002` | `test/unit/spec/interceptors/locusRouteToken.ts` | add cross-Locus request/response cases proving tokens cannot be attached to the wrong id |
425
+ | `INTERCEPTORS-R-003` | `test/unit/spec/interceptors/dataChannelAuthToken.ts`, `test/unit/spec/interceptors/locusRetry.ts` | assert one delayed retry and retry-key removal on both terminal paths; the exhausted Locus retry rejecting with the original reason is covered |
426
+ | `INTERCEPTORS-R-004` | `test/unit/spec/interceptors/locusRetry.ts` | terminal status and retry exhaustion are now verified; the alternating flag after a successful retry is not |
427
+ | `INTERCEPTORS-R-005` | `test/unit/spec/interceptors/locusRouteToken.ts` | verify unrelated URL never receives token |
428
+ | `INTERCEPTORS-R-006` | `test/unit/spec/interceptors/dataChannelAuthToken.ts`, `test/unit/spec/interceptors/utils.ts` | malformed/near-expiry tokens and retry exhaustion are now verified, and the 2000 ms delay is driven with fake timers; no case asserts the retry key is removed after exhaustion |
429
+ | `INTERCEPTORS-R-007` | `test/unit/spec/interceptors/dataChannelAuthToken.ts` | none |
430
+ | `INTERCEPTORS-R-008` | `test/unit/spec/interceptors/dataChannelAuthToken.ts` | the practice-session URL branch is not exercised |
431
+ | `INTERCEPTORS-R-009` | None found | no case asserts the registration in `src/index.ts` |
432
+
433
+ A module specification is complete only when its public surface, invariants, failure modes, and test
434
+ evidence agree with the implementation.