@webex/plugin-meetings 3.12.0 → 3.13.0-next.10

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 (354) hide show
  1. package/.sdd/manifest.json +1312 -0
  2. package/.sdd/templates/.source.json +30 -0
  3. package/.sdd/templates/component-repo/module-docs/module-spec-quality.md +111 -0
  4. package/.sdd/templates/component-repo/module-docs/module-spec.template.md +321 -0
  5. package/.sdd/templates/component-repo/reference-docs/adr/_adr-example.md +59 -0
  6. package/.sdd/templates/component-repo/reference-docs/patterns/_pattern-example.md +49 -0
  7. package/.sdd/templates/component-repo/reference-docs/rules/_rule-example.md +42 -0
  8. package/.sdd/templates/component-repo/standing-docs/AGENTS.template.md +120 -0
  9. package/.sdd/templates/component-repo/standing-docs/ARCHITECTURE.template.md +206 -0
  10. package/.sdd/templates/component-repo/standing-docs/CONTRACTS.template.md +90 -0
  11. package/.sdd/templates/component-repo/standing-docs/DATA_MODEL.template.md +68 -0
  12. package/.sdd/templates/component-repo/standing-docs/GETTING_STARTED.template.md +111 -0
  13. package/.sdd/templates/component-repo/standing-docs/GLOSSARY.template.md +57 -0
  14. package/.sdd/templates/component-repo/standing-docs/REVIEW_CHECKLIST.template.md +69 -0
  15. package/.sdd/templates/component-repo/standing-docs/RULES.template.md +96 -0
  16. package/.sdd/templates/component-repo/standing-docs/SECURITY.template.md +84 -0
  17. package/.sdd/templates/component-repo/standing-docs/SERVICE_STATE.template.md +82 -0
  18. package/.sdd/templates/component-repo/standing-docs/SPEC_INDEX.template.md +94 -0
  19. package/.sdd/templates/component-repo/standing-docs/TEST_INDEX.template.md +64 -0
  20. package/.sdd/templates/component-repo/template-map.json +112 -0
  21. package/AGENTS.md +135 -0
  22. package/ai-docs/ARCHITECTURE.md +208 -0
  23. package/ai-docs/CONTRACTS.md +267 -0
  24. package/ai-docs/DATA_MODEL.md +64 -0
  25. package/ai-docs/GETTING_STARTED.md +73 -0
  26. package/ai-docs/GLOSSARY.md +56 -0
  27. package/ai-docs/REVIEW_CHECKLIST.md +45 -0
  28. package/ai-docs/RULES.md +79 -0
  29. package/ai-docs/SECURITY.md +74 -0
  30. package/ai-docs/SERVICE_STATE.md +59 -0
  31. package/ai-docs/SPEC_INDEX.md +85 -0
  32. package/ai-docs/TEST_INDEX.md +45 -0
  33. package/ai-docs/adr/0001-migrate-existing-docs-into-sdd.md +61 -0
  34. package/ai-docs/patterns/defensive-error-propagation.md +55 -0
  35. package/ai-docs/patterns/event-scope-emission.md +46 -0
  36. package/ai-docs/patterns/source-to-test-path-mirroring.md +45 -0
  37. package/ai-docs/patterns/stateless-plugin-request-classes.md +53 -0
  38. package/ai-docs/patterns/typed-constants-and-enum-values.md +47 -0
  39. package/assets/README.md +28 -0
  40. package/assets/e2ee-0.0.1.js +2 -0
  41. package/assets/e2ee-0.0.1.wasm +0 -0
  42. package/babel.config.js +17 -1
  43. package/dist/aiEnableRequest/index.js +15 -2
  44. package/dist/aiEnableRequest/index.js.map +1 -1
  45. package/dist/annotation/index.js +55 -19
  46. package/dist/annotation/index.js.map +1 -1
  47. package/dist/assets/e2ee-0.0.1.js +2 -0
  48. package/dist/assets/e2ee-0.0.1.wasm +0 -0
  49. package/dist/breakouts/breakout.js +8 -3
  50. package/dist/breakouts/breakout.js.map +1 -1
  51. package/dist/breakouts/events.js +29 -14
  52. package/dist/breakouts/events.js.map +1 -1
  53. package/dist/breakouts/index.js +128 -7
  54. package/dist/breakouts/index.js.map +1 -1
  55. package/dist/common/errors/webex-errors.js +54 -5
  56. package/dist/common/errors/webex-errors.js.map +1 -1
  57. package/dist/common/wasm-loader.js +174 -0
  58. package/dist/common/wasm-loader.js.map +1 -0
  59. package/dist/config.js +5 -2
  60. package/dist/config.js.map +1 -1
  61. package/dist/constants.js +39 -11
  62. package/dist/constants.js.map +1 -1
  63. package/dist/controls-options-manager/constants.js +11 -1
  64. package/dist/controls-options-manager/constants.js.map +1 -1
  65. package/dist/controls-options-manager/index.js +67 -29
  66. package/dist/controls-options-manager/index.js.map +1 -1
  67. package/dist/controls-options-manager/util.js +91 -0
  68. package/dist/controls-options-manager/util.js.map +1 -1
  69. package/dist/e2ee/E2eeManager.js +91 -0
  70. package/dist/e2ee/E2eeManager.js.map +1 -0
  71. package/dist/e2ee/E2eeSignaling.js +200 -0
  72. package/dist/e2ee/E2eeSignaling.js.map +1 -0
  73. package/dist/e2ee/MediaEncryptionService.js +75 -0
  74. package/dist/e2ee/MediaEncryptionService.js.map +1 -0
  75. package/dist/e2ee/mls.js +558 -0
  76. package/dist/e2ee/mls.js.map +1 -0
  77. package/dist/e2ee/types.js +59 -0
  78. package/dist/e2ee/types.js.map +1 -0
  79. package/dist/e2ee/wasm.d.js +7 -0
  80. package/dist/e2ee/wasm.d.js.map +1 -0
  81. package/dist/hashTree/constants.js +13 -1
  82. package/dist/hashTree/constants.js.map +1 -1
  83. package/dist/hashTree/hashTreeParser.js +1245 -404
  84. package/dist/hashTree/hashTreeParser.js.map +1 -1
  85. package/dist/hashTree/utils.js +42 -0
  86. package/dist/hashTree/utils.js.map +1 -1
  87. package/dist/index.js +8 -0
  88. package/dist/index.js.map +1 -1
  89. package/dist/interceptors/dataChannelAuthToken.js +58 -16
  90. package/dist/interceptors/dataChannelAuthToken.js.map +1 -1
  91. package/dist/interceptors/locusRetry.js +24 -9
  92. package/dist/interceptors/locusRetry.js.map +1 -1
  93. package/dist/interpretation/index.js +55 -12
  94. package/dist/interpretation/index.js.map +1 -1
  95. package/dist/interpretation/interpretation.types.js +7 -0
  96. package/dist/interpretation/interpretation.types.js.map +1 -0
  97. package/dist/interpretation/siLanguage.js +1 -1
  98. package/dist/locus-info/controlsUtils.js +4 -1
  99. package/dist/locus-info/controlsUtils.js.map +1 -1
  100. package/dist/locus-info/index.js +914 -196
  101. package/dist/locus-info/index.js.map +1 -1
  102. package/dist/locus-info/infoUtils.js +36 -5
  103. package/dist/locus-info/infoUtils.js.map +1 -1
  104. package/dist/locus-info/types.js +20 -0
  105. package/dist/locus-info/types.js.map +1 -1
  106. package/dist/media/MediaConnectionAwaiter.js +229 -166
  107. package/dist/media/MediaConnectionAwaiter.js.map +1 -1
  108. package/dist/media/index.js +8 -2
  109. package/dist/media/index.js.map +1 -1
  110. package/dist/media/properties.js +4 -5
  111. package/dist/media/properties.js.map +1 -1
  112. package/dist/meeting/in-meeting-actions.js +5 -1
  113. package/dist/meeting/in-meeting-actions.js.map +1 -1
  114. package/dist/meeting/index.js +1931 -887
  115. package/dist/meeting/index.js.map +1 -1
  116. package/dist/meeting/locusMediaRequest.js +229 -82
  117. package/dist/meeting/locusMediaRequest.js.map +1 -1
  118. package/dist/meeting/muteState.js +10 -1
  119. package/dist/meeting/muteState.js.map +1 -1
  120. package/dist/meeting/request.js +5 -2
  121. package/dist/meeting/request.js.map +1 -1
  122. package/dist/meeting/util.js +42 -3
  123. package/dist/meeting/util.js.map +1 -1
  124. package/dist/meeting/voicea-meeting.js +2 -1
  125. package/dist/meeting/voicea-meeting.js.map +1 -1
  126. package/dist/meeting-info/meeting-info-v2.js +12 -5
  127. package/dist/meeting-info/meeting-info-v2.js.map +1 -1
  128. package/dist/meetings/index.js +342 -129
  129. package/dist/meetings/index.js.map +1 -1
  130. package/dist/meetings/meetings.types.js +6 -1
  131. package/dist/meetings/meetings.types.js.map +1 -1
  132. package/dist/meetings/request.js +39 -0
  133. package/dist/meetings/request.js.map +1 -1
  134. package/dist/meetings/util.js +116 -18
  135. package/dist/meetings/util.js.map +1 -1
  136. package/dist/member/index.js +10 -0
  137. package/dist/member/index.js.map +1 -1
  138. package/dist/member/types.js.map +1 -1
  139. package/dist/member/util.js +30 -0
  140. package/dist/member/util.js.map +1 -1
  141. package/dist/members/index.js +101 -43
  142. package/dist/members/index.js.map +1 -1
  143. package/dist/members/util.js +8 -1
  144. package/dist/members/util.js.map +1 -1
  145. package/dist/metrics/constants.js +11 -1
  146. package/dist/metrics/constants.js.map +1 -1
  147. package/dist/multistream/codec/constants.js +63 -0
  148. package/dist/multistream/codec/constants.js.map +1 -0
  149. package/dist/multistream/mediaRequestManager.js +62 -15
  150. package/dist/multistream/mediaRequestManager.js.map +1 -1
  151. package/dist/multistream/receiveSlot.js +9 -0
  152. package/dist/multistream/receiveSlot.js.map +1 -1
  153. package/dist/multistream/remoteMediaManager.js +32 -4
  154. package/dist/multistream/remoteMediaManager.js.map +1 -1
  155. package/dist/multistream/sendSlotManager.js +127 -3
  156. package/dist/multistream/sendSlotManager.js.map +1 -1
  157. package/dist/reachability/clusterReachability.js.map +1 -1
  158. package/dist/reachability/index.js +121 -83
  159. package/dist/reachability/index.js.map +1 -1
  160. package/dist/reachability/reachability.types.js +2 -0
  161. package/dist/reachability/reachability.types.js.map +1 -1
  162. package/dist/reachability/util.js +45 -0
  163. package/dist/reachability/util.js.map +1 -1
  164. package/dist/reactions/reactions.type.js.map +1 -1
  165. package/dist/recording-controller/index.js +1 -3
  166. package/dist/recording-controller/index.js.map +1 -1
  167. package/dist/roap/turnDiscovery.js +8 -1
  168. package/dist/roap/turnDiscovery.js.map +1 -1
  169. package/dist/types/annotation/index.d.ts +19 -0
  170. package/dist/types/common/errors/webex-errors.d.ts +36 -2
  171. package/dist/types/common/wasm-loader.d.ts +55 -0
  172. package/dist/types/config.d.ts +5 -2
  173. package/dist/types/constants.d.ts +15 -2
  174. package/dist/types/controls-options-manager/constants.d.ts +6 -1
  175. package/dist/types/controls-options-manager/index.d.ts +16 -0
  176. package/dist/types/e2ee/E2eeManager.d.ts +23 -0
  177. package/dist/types/e2ee/E2eeSignaling.d.ts +94 -0
  178. package/dist/types/e2ee/MediaEncryptionService.d.ts +27 -0
  179. package/dist/types/e2ee/mls.d.ts +191 -0
  180. package/dist/types/e2ee/types.d.ts +104 -0
  181. package/dist/types/hashTree/constants.d.ts +2 -0
  182. package/dist/types/hashTree/hashTreeParser.d.ts +230 -18
  183. package/dist/types/hashTree/utils.d.ts +18 -0
  184. package/dist/types/index.d.ts +4 -0
  185. package/dist/types/interceptors/locusRetry.d.ts +4 -4
  186. package/dist/types/interpretation/interpretation.types.d.ts +10 -0
  187. package/dist/types/locus-info/index.d.ts +151 -15
  188. package/dist/types/locus-info/infoUtils.d.ts +8 -0
  189. package/dist/types/locus-info/types.d.ts +28 -1
  190. package/dist/types/media/MediaConnectionAwaiter.d.ts +66 -49
  191. package/dist/types/media/properties.d.ts +6 -2
  192. package/dist/types/meeting/in-meeting-actions.d.ts +4 -0
  193. package/dist/types/meeting/index.d.ts +247 -13
  194. package/dist/types/meeting/locusMediaRequest.d.ts +12 -0
  195. package/dist/types/meeting/request.d.ts +1 -0
  196. package/dist/types/meeting/util.d.ts +12 -1
  197. package/dist/types/meeting-info/meeting-info-v2.d.ts +1 -0
  198. package/dist/types/meetings/index.d.ts +44 -19
  199. package/dist/types/meetings/meetings.types.d.ts +15 -0
  200. package/dist/types/meetings/request.d.ts +14 -0
  201. package/dist/types/member/index.d.ts +1 -0
  202. package/dist/types/member/types.d.ts +1 -0
  203. package/dist/types/member/util.d.ts +9 -0
  204. package/dist/types/members/index.d.ts +15 -2
  205. package/dist/types/members/util.d.ts +1 -5
  206. package/dist/types/metrics/constants.d.ts +10 -0
  207. package/dist/types/multistream/codec/constants.d.ts +7 -0
  208. package/dist/types/multistream/mediaRequestManager.d.ts +22 -5
  209. package/dist/types/multistream/remoteMediaManager.d.ts +18 -0
  210. package/dist/types/multistream/sendSlotManager.d.ts +28 -2
  211. package/dist/types/reachability/clusterReachability.d.ts +3 -3
  212. package/dist/types/reachability/index.d.ts +10 -3
  213. package/dist/types/reachability/reachability.types.d.ts +7 -0
  214. package/dist/types/reachability/util.d.ts +17 -0
  215. package/dist/types/reactions/reactions.type.d.ts +3 -0
  216. package/dist/webinar/index.js +539 -245
  217. package/dist/webinar/index.js.map +1 -1
  218. package/package.json +26 -24
  219. package/src/aiEnableRequest/ai-docs/ai-enable-request-spec.md +223 -0
  220. package/src/aiEnableRequest/index.ts +16 -0
  221. package/src/annotation/ai-docs/annotation-spec.md +236 -0
  222. package/src/annotation/index.ts +61 -29
  223. package/src/breakouts/ai-docs/breakouts-spec.md +324 -0
  224. package/src/breakouts/breakout.ts +3 -1
  225. package/src/breakouts/events.ts +33 -11
  226. package/src/breakouts/index.ts +145 -3
  227. package/src/common/errors/webex-errors.ts +56 -3
  228. package/src/common/wasm-loader.ts +124 -0
  229. package/src/config.ts +9 -3
  230. package/src/constants.ts +23 -4
  231. package/src/controls-options-manager/ai-docs/controls-options-manager-spec.md +243 -0
  232. package/src/controls-options-manager/constants.ts +14 -1
  233. package/src/controls-options-manager/index.ts +87 -28
  234. package/src/controls-options-manager/util.ts +81 -1
  235. package/src/e2ee/E2eeManager.ts +58 -0
  236. package/src/e2ee/E2eeSignaling.ts +215 -0
  237. package/src/e2ee/MediaEncryptionService.ts +41 -0
  238. package/src/e2ee/mls.ts +548 -0
  239. package/src/e2ee/types.ts +114 -0
  240. package/src/e2ee/wasm.d.ts +153 -0
  241. package/src/hashTree/ai-docs/hash-tree-spec.md +267 -0
  242. package/src/hashTree/constants.ts +16 -0
  243. package/src/hashTree/hashTreeParser.ts +1021 -214
  244. package/src/hashTree/utils.ts +36 -0
  245. package/src/index.ts +7 -0
  246. package/src/interceptors/ai-docs/interceptors-spec.md +247 -0
  247. package/src/interceptors/dataChannelAuthToken.ts +59 -12
  248. package/src/interceptors/locusRetry.ts +26 -5
  249. package/src/interpretation/ai-docs/interpretation-spec.md +256 -0
  250. package/src/interpretation/index.ts +65 -10
  251. package/src/interpretation/interpretation.types.ts +11 -0
  252. package/src/locus-info/ai-docs/locus-info-spec.md +293 -0
  253. package/src/locus-info/controlsUtils.ts +3 -1
  254. package/src/locus-info/index.ts +907 -184
  255. package/src/locus-info/infoUtils.ts +41 -6
  256. package/src/locus-info/types.ts +33 -1
  257. package/src/media/MediaConnectionAwaiter.ts +229 -196
  258. package/src/media/ai-docs/media-spec.md +267 -0
  259. package/src/media/index.ts +10 -1
  260. package/src/media/properties.ts +8 -3
  261. package/src/meeting/ai-docs/meeting-spec.md +404 -0
  262. package/src/meeting/in-meeting-actions.ts +8 -0
  263. package/src/meeting/index.ts +1237 -254
  264. package/src/meeting/locusMediaRequest.ts +106 -6
  265. package/src/meeting/muteState.ts +10 -1
  266. package/src/meeting/request.ts +11 -0
  267. package/src/meeting/util.ts +53 -8
  268. package/src/meeting/voicea-meeting.ts +1 -1
  269. package/src/meeting-info/ai-docs/meeting-info-spec.md +261 -0
  270. package/src/meeting-info/meeting-info-v2.ts +11 -4
  271. package/src/meetings/ai-docs/meetings-spec.md +298 -0
  272. package/src/meetings/index.ts +242 -80
  273. package/src/meetings/meetings.types.ts +19 -0
  274. package/src/meetings/request.ts +43 -0
  275. package/src/meetings/util.ts +117 -4
  276. package/src/member/ai-docs/member-spec.md +196 -0
  277. package/src/member/index.ts +10 -0
  278. package/src/member/types.ts +1 -0
  279. package/src/member/util.ts +29 -0
  280. package/src/members/ai-docs/members-spec.md +256 -0
  281. package/src/members/index.ts +70 -7
  282. package/src/members/util.ts +12 -4
  283. package/src/metrics/ai-docs/metrics-spec.md +185 -0
  284. package/src/metrics/constants.ts +11 -0
  285. package/src/multistream/ai-docs/multistream-spec.md +295 -0
  286. package/src/multistream/codec/constants.ts +58 -0
  287. package/src/multistream/mediaRequestManager.ts +119 -28
  288. package/src/multistream/receiveSlot.ts +18 -0
  289. package/src/multistream/remoteMediaManager.ts +23 -1
  290. package/src/multistream/sendSlotManager.ts +112 -4
  291. package/src/personal-meeting-room/ai-docs/personal-meeting-room-spec.md +234 -0
  292. package/src/reachability/ai-docs/reachability-spec.md +261 -0
  293. package/src/reachability/clusterReachability.ts +3 -2
  294. package/src/reachability/index.ts +47 -16
  295. package/src/reachability/reachability.types.ts +11 -0
  296. package/src/reachability/util.ts +36 -0
  297. package/src/reactions/ai-docs/reactions-spec.md +198 -0
  298. package/src/reactions/reactions.type.ts +3 -0
  299. package/src/reconnection-manager/ai-docs/reconnection-manager-spec.md +272 -0
  300. package/src/recording-controller/ai-docs/recording-controller-spec.md +223 -0
  301. package/src/recording-controller/index.ts +1 -2
  302. package/src/roap/ai-docs/roap-spec.md +241 -0
  303. package/src/roap/turnDiscovery.ts +9 -1
  304. package/src/webinar/ai-docs/webinar-spec.md +243 -0
  305. package/src/webinar/index.ts +333 -73
  306. package/test/unit/spec/aiEnableRequest/index.ts +86 -0
  307. package/test/unit/spec/annotation/index.ts +214 -182
  308. package/test/unit/spec/breakouts/breakout.ts +9 -3
  309. package/test/unit/spec/breakouts/events.ts +120 -2
  310. package/test/unit/spec/breakouts/index.ts +336 -15
  311. package/test/unit/spec/common/errors/webex-errors.ts +78 -0
  312. package/test/unit/spec/common/wasm-loader.ts +171 -0
  313. package/test/unit/spec/controls-options-manager/index.js +244 -29
  314. package/test/unit/spec/controls-options-manager/util.js +165 -0
  315. package/test/unit/spec/e2ee/E2eeManager.ts +82 -0
  316. package/test/unit/spec/e2ee/E2eeSignaling.ts +172 -0
  317. package/test/unit/spec/e2ee/MediaEncryptionService.ts +43 -0
  318. package/test/unit/spec/e2ee/mls.ts +765 -0
  319. package/test/unit/spec/hashTree/hashTreeParser.ts +3126 -238
  320. package/test/unit/spec/hashTree/utils.ts +125 -1
  321. package/test/unit/spec/interceptors/dataChannelAuthToken.ts +179 -1
  322. package/test/unit/spec/interceptors/locusRetry.ts +234 -5
  323. package/test/unit/spec/interpretation/index.ts +119 -4
  324. package/test/unit/spec/locus-info/controlsUtils.js +172 -57
  325. package/test/unit/spec/locus-info/index.js +1880 -136
  326. package/test/unit/spec/locus-info/infoUtils.js +184 -1
  327. package/test/unit/spec/media/MediaConnectionAwaiter.ts +479 -17
  328. package/test/unit/spec/media/index.ts +92 -0
  329. package/test/unit/spec/media/properties.ts +26 -26
  330. package/test/unit/spec/meeting/in-meeting-actions.ts +4 -0
  331. package/test/unit/spec/meeting/index.js +3697 -501
  332. package/test/unit/spec/meeting/locusMediaRequest.ts +406 -4
  333. package/test/unit/spec/meeting/muteState.js +81 -0
  334. package/test/unit/spec/meeting/request.js +12 -0
  335. package/test/unit/spec/meeting/utils.js +206 -16
  336. package/test/unit/spec/meeting/voicea-meeting.ts +85 -1
  337. package/test/unit/spec/meeting-info/index.js +2 -3
  338. package/test/unit/spec/meeting-info/meetinginfov2.js +88 -11
  339. package/test/unit/spec/meetings/index.js +606 -53
  340. package/test/unit/spec/meetings/request.js +141 -0
  341. package/test/unit/spec/meetings/utils.js +402 -51
  342. package/test/unit/spec/member/index.js +7 -0
  343. package/test/unit/spec/member/util.js +89 -0
  344. package/test/unit/spec/members/index.js +216 -0
  345. package/test/unit/spec/members/request.js +37 -1
  346. package/test/unit/spec/members/utils.js +63 -0
  347. package/test/unit/spec/multistream/mediaRequestManager.ts +501 -37
  348. package/test/unit/spec/multistream/remoteMediaManager.ts +46 -0
  349. package/test/unit/spec/multistream/sendSlotManager.ts +165 -38
  350. package/test/unit/spec/reachability/index.ts +128 -46
  351. package/test/unit/spec/reachability/util.ts +31 -0
  352. package/test/unit/spec/recording-controller/index.js +9 -8
  353. package/test/unit/spec/roap/turnDiscovery.ts +20 -0
  354. package/test/unit/spec/webinar/index.ts +982 -328
@@ -60,3 +60,39 @@ export const deleteNestedObjectsWithHtMeta = (
60
60
  }
61
61
  }
62
62
  };
63
+
64
+ /**
65
+ * Reorders items so that those matching the given priority list come first (in priority order),
66
+ * followed by everything else in their original order.
67
+ *
68
+ * @param {Array<T>} items - The items to reorder
69
+ * @param {string[]} priority - Ordered list of names that should come first
70
+ * @returns {Array<T>} A new array with prioritized items first
71
+ */
72
+ export function sortByInitPriority<T extends {name: string}>(items: T[], priority: string[]): T[] {
73
+ const prioritized = priority
74
+ .map((name) => items.find((item) => item.name === name))
75
+ .filter(Boolean) as T[];
76
+ const rest = items.filter((item) => !priority.includes(item.name));
77
+
78
+ return [...prioritized, ...rest];
79
+ }
80
+
81
+ /**
82
+ * Sleeps for the specified amount of milliseconds
83
+ *
84
+ * @param {number} ms amount of milliseconds to sleep
85
+ * @returns {Promise<void>} A promise that resolves after the specified delay
86
+ */
87
+ export function sleep(ms: number): Promise<void> {
88
+ if (ms <= 0) {
89
+ return Promise.resolve();
90
+ }
91
+
92
+ return new Promise((resolve) => {
93
+ // start a timer that will resolve the promise after the specified delay
94
+ setTimeout(() => {
95
+ resolve();
96
+ }, ms);
97
+ });
98
+ }
package/src/index.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  /* eslint-env browser */
2
+ import '@webex/internal-plugin-identity';
2
3
  import {registerPlugin} from '@webex/webex-core';
3
4
 
4
5
  import Meetings from './meetings';
@@ -65,6 +66,12 @@ export * as REACTIONS from './reactions/reactions';
65
66
  export * as sdkAnnotationTypes from './annotation/annotation.types';
66
67
  export * as MeetingInfoV2 from './meeting-info/meeting-info-v2';
67
68
  export {type Reaction} from './reactions/reactions.type';
69
+ export {SitePreferenceSelectOption} from './meetings/meetings.types';
70
+ export type {
71
+ FetchSitePreferencesMeViaSiteOptions,
72
+ SitePreferencesResponse,
73
+ } from './meetings/meetings.types';
74
+ export type {Interpreter, InterpreterUsingResource} from './interpretation/interpretation.types';
68
75
 
69
76
  export {
70
77
  CaptchaError,
@@ -0,0 +1,247 @@
1
+ <!-- sdd-generated-metadata
2
+ doc_kind: module-spec
3
+ generated_from: module-spec@0.2.2
4
+ generator_plugin: repo-annotation@1.0.5+codex.20260818094939
5
+ generated_by: codex
6
+ approved_by: repository user
7
+ updated_at: 2026-08-22T15:21:29Z
8
+ validation_status: pass-with-warnings
9
+ -->
10
+ # INTERCEPTORS — SPEC
11
+
12
+ > Start here → root [`AGENTS.md`](../../../AGENTS.md) · router [`SPEC_INDEX.md`](../../../ai-docs/SPEC_INDEX.md) · system [`ARCHITECTURE.md`](../../../ai-docs/ARCHITECTURE.md). This is the canonical source-local spec for `src/interceptors/`.
13
+
14
+ ## Metadata
15
+
16
+ | Field | Value |
17
+ |---|---|
18
+ | Module id | `interceptors` |
19
+ | Source path(s) | `src/interceptors/` |
20
+ | Parent spec | — |
21
+ | Doc kind | Module spec |
22
+ | Coverage score | 93% assessed 2026-08-22; 13/14 mandatory fields present; all critical and Important fields present; one noncritical polish gap remains; pending independent validation of the participant-role repair |
23
+ | Generated from | `module-spec` @ SDLC template library `0.2.2` |
24
+ | generated_by / approved_by / updated_at | codex / repository user / 2026-08-22T15:21:29Z |
25
+ | Validation status | pass-with-warnings |
26
+
27
+ ## Evidence Rules
28
+
29
+ Requirements cite current source and mirrored tests. Current code wins over retained prose when they conflict; commit and PR history are excluded. Missing evidence stays a gap.
30
+
31
+ ## Source Material Register
32
+
33
+ | Source material | Scope | Decision | Detail location or disposition |
34
+ |---|---|---|---|
35
+ | No routed legacy module spec | overview / API / behavior / tests | none; generated from current interceptors/constants/utilities and tests |
36
+ | Current source and mirrored tests | implementation / tests | verified | requirements, flows, failures, and test strategy below |
37
+
38
+ ## Overview
39
+
40
+ `src/interceptors/` contains 6 direct source/reference file(s) and has 4 mirrored unit-test file(s). This spec separates its public operations, runtime data movement, component ownership, state applicability, and verification boundary.
41
+
42
+ ## Purpose / Responsibility
43
+
44
+ Provides Webex-core request middleware for bounded Locus retries, Locus route-token propagation, and data-channel auth-token refresh.
45
+
46
+ ## Stack
47
+
48
+ TypeScript/JavaScript in the Node 22.14 Yarn workspace; Webex core/plugin abstractions and Mocha/Sinon/`@webex/test-helper-chai` tests.
49
+
50
+ ## Folder / Package Structure
51
+
52
+ ```text
53
+ src/interceptors/
54
+ ├── constant.ts — interceptor constants
55
+ ├── dataChannelAuthToken.ts — dataChannelAuthToken implementation responsibility
56
+ ├── index.ts — module facade/controller or primary exports
57
+ ├── locusRetry.ts — locusRetry implementation responsibility
58
+ ├── locusRouteToken.ts — locusRouteToken implementation responsibility
59
+ ├── utils.ts — normalization/helper functions
60
+ └── ai-docs/interceptors-spec.md — canonical module specification
61
+ ```
62
+
63
+ ## Key Files (source of truth)
64
+
65
+ | File | Holds |
66
+ |---|---|
67
+ | `src/interceptors/constant.ts` | interceptor constants |
68
+ | `src/interceptors/dataChannelAuthToken.ts` | dataChannelAuthToken implementation responsibility |
69
+ | `src/interceptors/index.ts` | module facade/controller or primary exports |
70
+ | `src/interceptors/locusRetry.ts` | locusRetry implementation responsibility |
71
+ | `src/interceptors/locusRouteToken.ts` | locusRouteToken implementation responsibility |
72
+ | `src/interceptors/utils.ts` | normalization/helper functions |
73
+ | `test/unit/spec/interceptors/dataChannelAuthToken.ts` and 3 sibling test file(s) | mirrored characterization/unit coverage |
74
+
75
+ ## Public Surface
76
+
77
+ | Contract ID | Type | Surface | Purpose | Compatibility / deprecation | Schema / detail link | Root index |
78
+ |---|---|---|---|---|---|---|
79
+ | `interceptors.1` | 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 server delay handling. | `src/interceptors/locusRetry.ts` | [CONTRACTS](../../../ai-docs/CONTRACTS.md) |
80
+ | `interceptors.2` | 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` | [CONTRACTS](../../../ai-docs/CONTRACTS.md) |
81
+ | `interceptors.3` | 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` | [CONTRACTS](../../../ai-docs/CONTRACTS.md) |
82
+ | `interceptors.4` | 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` | [CONTRACTS](../../../ai-docs/CONTRACTS.md) |
83
+ | `interceptors.5` | 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` | [CONTRACTS](../../../ai-docs/CONTRACTS.md) |
84
+
85
+ Compatibility notes:
86
+ - 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.
87
+
88
+ ## Requires (dependencies)
89
+
90
+ Webex core Interceptor/request pipeline, JWT decoding/verification helpers, Meetings token state/services, request URLs/headers, timers, and retry constants.
91
+
92
+ ## Requirements
93
+
94
+ | ID | WHAT | WHY | Source Evidence | Test / Example Evidence | Assumptions / Gaps | Confidence |
95
+ |---|---|---|---|---|---|---|
96
+ | `INTERCEPTORS-R-001` | retry eligible Locus failures using status-based rules. | Provides Webex-core request middleware for bounded Locus retries, Locus route-token propagation, and data-channel auth-token refresh. | `src/interceptors/index.ts` | `test/unit/spec/interceptors/dataChannelAuthToken.ts` | none | PRESENT |
97
+ | `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/index.ts`, `src/interceptors/dataChannelAuthToken.ts` | `test/unit/spec/interceptors/dataChannelAuthToken.ts` | 30-second JWT boundary and refresh-key removal need explicit boundary coverage | PRESENT |
98
+ | `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 |
99
+ | `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 |
100
+ | `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 |
101
+ | `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 |
102
+
103
+ ## Design Overview
104
+
105
+ `index.ts` only exports three independent Webex-core interceptors. `locusRetry.ts` bounds eligible retries, `locusRouteToken.ts` stores/attaches tokens by Locus id, and `dataChannelAuthToken.ts` refreshes expiring channel credentials; none is a controller for the others.
106
+
107
+ ## Data Flow
108
+
109
+ ```mermaid
110
+ flowchart LR
111
+ Request[Webex-core request] --> Retry[locusRetry.ts]
112
+ Request --> Route[locusRouteToken.ts]
113
+ Request --> Auth[dataChannelAuthToken.ts]
114
+ Retry --> Continue[retry or propagate response]
115
+ Route --> Continue
116
+ Auth --> Refresh[data-channel token refresh]
117
+ Refresh --> Continue
118
+ Constants[constant.ts] --> Auth
119
+ Utils[utils.ts] --> Auth
120
+ ```
121
+
122
+ ## Sequence Diagram(s)
123
+
124
+ Sequence coverage:
125
+
126
+ | Operation group | Diagram | Failure coverage |
127
+ |---|---|---|
128
+ | UC-1…UC-4 — request interceptor operation groups | Request interceptor primary sequence | ineligible Locus status, token mismatch/expiry, refresh failure, and retry exhaustion |
129
+ | UC-1…UC-4 — request interceptor alternate/failure paths | Request interceptor alternate/failure sequence | non-retryable status, exhausted retry count, missing Locus-token match, or failed data-channel token refresh |
130
+
131
+ ### Request interceptor primary sequence
132
+
133
+ ```mermaid
134
+ sequenceDiagram
135
+ participant W as Webex core
136
+ participant I as Selected interceptor
137
+ participant N as next()
138
+ W->>I: request or response context
139
+ I->>I: evaluate only its retry/token rule
140
+ alt rule applies
141
+ I->>N: amended request or bounded retry
142
+ else rule does not apply
143
+ I->>N: unchanged context / propagated error
144
+ end
145
+ N-->>W: response or rejection
146
+ ```
147
+
148
+ ### Request interceptor alternate/failure sequence
149
+
150
+ ```mermaid
151
+ sequenceDiagram
152
+ participant W as Webex request pipeline
153
+ participant I as Locus / data-channel interceptor
154
+ participant T as Token refresh
155
+ W->>I: response failure or authenticated request
156
+ alt eligible Locus 429/503 outside /hashtree and /sync with no prior retry
157
+ I->>I: wait selected delay or 2000 ms; retry once
158
+ I-->>W: retry result or rejection
159
+ else eligible Locus request was already retried
160
+ I--xW: reject with the original HTTP reason
161
+ else data-channel 401/403 with enabled token
162
+ I->>T: refresh token after 2000 ms
163
+ T-->>I: token or failure
164
+ I-->>W: one retry result or wrapped refresh failure
165
+ else other non-eligible failure
166
+ I--xW: propagate the original rejection
167
+ end
168
+ ```
169
+
170
+ ## Class / Component Relationships
171
+
172
+ ```mermaid
173
+ classDiagram
174
+ class Request
175
+ class Retry
176
+ class Route
177
+ class Auth
178
+ class Continue
179
+ class Refresh
180
+ class Constants
181
+ class Utils
182
+ Request --> Retry
183
+ Request --> Route
184
+ Request --> Auth
185
+ Retry --> Continue
186
+ Route --> Continue
187
+ Auth --> Refresh
188
+ Refresh --> Continue
189
+ Constants --> Auth
190
+ Utils --> Auth
191
+ ```
192
+
193
+ The arrows identify ownership and delegation inside `src/interceptors/`; files that only declare types or constants are not presented as transports.
194
+
195
+ ## Use Cases
196
+
197
+ - **UC-1:** Retry one eligible Locus 429/503 response after its server-directed delay while leaving hash-tree/sync failures to their owning recovery paths. Evidence: `src/interceptors/locusRetry.ts`.
198
+ - **UC-2:** Capture a route token from a Locus response and attach it only to a later request whose URL resolves to the same Locus id. Evidence: `src/interceptors/locusRouteToken.ts`.
199
+ - **UC-3:** Attach an unexpired data-channel token to an outgoing request, using the 30-second JWT expiry buffer. Evidence: `src/interceptors/dataChannelAuthToken.ts`.
200
+ - **UC-4:** On the handled auth failure, wait 2000 ms, refresh, retry once, and clear the retry key after success or refresh failure. Evidence: `src/interceptors/dataChannelAuthToken.ts`.
201
+
202
+ ## Business Rules & Invariants
203
+
204
+ - Tokens attach only to intended request routes; JWT expiry includes the 30-second buffer; data-channel retry stops at `MAX_RETRY = 1`; terminal auth/service errors propagate. Enforced under `src/interceptors/`.
205
+
206
+ ## Concurrency & Reactive Flow
207
+
208
+ - `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.
209
+
210
+ ## Protocol / Wire Format
211
+
212
+ - Existing request/event/channel types and constants under `src/interceptors/` own serialization and parsing. Preserve field names, enum/raw values, identity/routing fields, and compatibility; normalized client properties are not a replacement wire schema.
213
+
214
+ ## Error Handling & Failure Modes
215
+
216
+ | Condition | Signal | Caller recovery |
217
+ |---|---|---|
218
+ | 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. |
219
+ | 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. |
220
+ | Data-channel token refresh or its single retry fails | The interceptor clears its retry key and rejects with the original terminal response or a `DataChannel token refresh failed` error. | Re-establish valid data-channel credentials before a new request. |
221
+
222
+ ## Pitfalls
223
+
224
+ - An interceptor runs across host requests. Loose URL matching or header reuse can leak meeting tokens to an unrelated service.
225
+ - Verify both typed constants/enums and raw wire values before changing a logical condition in this legacy package.
226
+
227
+ ## Host Integration & Theming
228
+
229
+ The Webex SDK host provides request, identity, event, and media capabilities and exposes this module through `webex.meetings` or Meeting-composed controllers. The module renders no UI and has no theme contract.
230
+
231
+ ## Test-Case Strategy (module)
232
+
233
+ Use the current mirrored suites: `test/unit/spec/interceptors/dataChannelAuthToken.ts`, `test/unit/spec/interceptors/locusRetry.ts`, `test/unit/spec/interceptors/locusRouteToken.ts`, `test/unit/spec/interceptors/utils.ts`. Characterize the interceptors-specific use cases above and each listed failure condition; add cleanup or transition cases only for resources and state this module actually owns.
234
+
235
+ | Behavior / Requirement | Existing test evidence | Gap |
236
+ |---|---|---|
237
+ | `INTERCEPTORS-R-001` | `test/unit/spec/interceptors/dataChannelAuthToken.ts` | cover retry, route-token, and data-channel interceptor families independently |
238
+ | `INTERCEPTORS-R-002` | `test/unit/spec/interceptors/locusRouteToken.ts` | add cross-Locus request/response cases proving tokens cannot be attached to the wrong id |
239
+ | `INTERCEPTORS-R-003` | `test/unit/spec/interceptors/dataChannelAuthToken.ts` | assert one delayed retry, the 30-second expiry boundary, and retry-key removal on both terminal paths |
240
+ | `INTERCEPTORS-R-004` | `test/unit/spec/interceptors/locusRetry.ts` | verify terminal status and retry exhaustion |
241
+ | `INTERCEPTORS-R-005` | `test/unit/spec/interceptors/locusRouteToken.ts` | verify unrelated URL never receives token |
242
+ | `INTERCEPTORS-R-006` | `test/unit/spec/interceptors/dataChannelAuthToken.ts`, `test/unit/spec/interceptors/utils.ts` | verify malformed/near-expiry tokens and retry exhaustion |
243
+
244
+ ## Traceability
245
+
246
+ - Repo architecture: [`ARCHITECTURE.md`](../../../ai-docs/ARCHITECTURE.md) · Registry: [`SPEC_INDEX.md`](../../../ai-docs/SPEC_INDEX.md)
247
+ - Coverage state and contracts baseline: `../../../.sdd/manifest.json`
@@ -3,14 +3,14 @@
3
3
  */
4
4
 
5
5
  import {Interceptor} from '@webex/http-core';
6
+
7
+ // @ts-ignore - internal-plugin-llm types
8
+ import LLMChannel from '@webex/internal-plugin-llm';
6
9
  import LoggerProxy from '../common/logs/logger-proxy';
10
+ import Meeting from '../meeting';
7
11
  import {DATA_CHANNEL_AUTH_HEADER, MAX_RETRY, RETRY_INTERVAL, RETRY_KEY} from './constant';
8
12
  import {isJwtTokenExpired} from './utils';
9
13
 
10
- /*!
11
- * Copyright (c) 2015-2026 Cisco Systems, Inc. See LICENSE file.
12
- */
13
-
14
14
  const retryCountMap = new Map();
15
15
  interface HttpLikeError extends Error {
16
16
  statusCode?: number;
@@ -20,7 +20,7 @@ interface HttpLikeError extends Error {
20
20
  * @class
21
21
  */
22
22
  export default class DataChannelAuthTokenInterceptor extends Interceptor {
23
- private _refreshDataChannelToken: () => Promise<string>;
23
+ private _refreshDataChannelToken: (requestUrl?: string) => Promise<string>;
24
24
  private _isDataChannelTokenEnabled: () => Promise<boolean>;
25
25
  constructor(options) {
26
26
  super(options);
@@ -42,15 +42,62 @@ export default class DataChannelAuthTokenInterceptor extends Interceptor {
42
42
  return this.internal.llm.isDataChannelTokenEnabled();
43
43
  },
44
44
 
45
- refreshDataChannelToken: async () => {
45
+ // Route refresh by request URL:
46
+ // 1) Find the LLM channel that matches the request URL
47
+ // 2) If found, use its refresh handler
48
+ // 3) If no channel matches, fall back to finding the meeting by locusUrl
49
+ refreshDataChannelToken: async (requestUrl?: string) => {
46
50
  // @ts-ignore
47
- const {body} = await this.internal.llm.refreshDataChannelToken();
48
- const {datachannelToken, dataChannelTokenType} = body ?? {};
51
+ const channel = this.internal.llm.getChannelByDatachannelUrl(requestUrl);
52
+
53
+ if (channel) {
54
+ // Channel found - use its refresh handler
55
+ const result = await channel.refreshDataChannelToken();
56
+
57
+ if (!result?.body) {
58
+ throw new Error('DataChannel token refresh returned no payload');
59
+ }
60
+
61
+ const {datachannelToken} = result.body;
62
+ channel.setDatachannelToken(datachannelToken);
63
+
64
+ return datachannelToken;
65
+ }
49
66
 
67
+ // No channel found - fallback to finding meeting by matching datachannel URLs
50
68
  // @ts-ignore
51
- this.internal.llm.setDatachannelToken(datachannelToken, dataChannelTokenType);
69
+ const allMeetings: Record<string, Meeting> = this.meetings?.getAllMeetings() || {};
70
+
71
+ const meeting = Object.values(allMeetings).find((activeMeeting) => {
72
+ const info = activeMeeting?.locusInfo?.info || {};
73
+
74
+ return (
75
+ (info.practiceSessionDatachannelUrl &&
76
+ LLMChannel.matchesDatachannelRequestUrl(
77
+ requestUrl,
78
+ info.practiceSessionDatachannelUrl
79
+ )) ||
80
+ (info.datachannelUrl &&
81
+ LLMChannel.matchesDatachannelRequestUrl(requestUrl, info.datachannelUrl))
82
+ );
83
+ });
84
+
85
+ if (meeting) {
86
+ const result = await meeting.refreshDataChannelToken();
87
+
88
+ if (!result?.body) {
89
+ throw new Error('DataChannel token refresh returned no payload');
90
+ }
91
+
92
+ const {datachannelToken} = result.body;
93
+
94
+ // Store token on the meeting's LLM channel if available
95
+ meeting.setLLMChannelDataToken(datachannelToken);
96
+
97
+ return datachannelToken;
98
+ }
52
99
 
53
- return datachannelToken;
100
+ throw new Error('No LLM channel or meeting found for request URL');
54
101
  },
55
102
  });
56
103
  }
@@ -87,7 +134,7 @@ export default class DataChannelAuthTokenInterceptor extends Interceptor {
87
134
 
88
135
  if (isJwtTokenExpired(token)) {
89
136
  try {
90
- const newToken = await this._refreshDataChannelToken();
137
+ const newToken = await this._refreshDataChannelToken(options.uri || options.url);
91
138
  options.headers[DATA_CHANNEL_AUTH_HEADER] = newToken;
92
139
  } catch (e) {
93
140
  LoggerProxy.logger.warn(`DataChannelAuthTokenInterceptor: refresh failed: ${e.message}`);
@@ -144,7 +191,7 @@ export default class DataChannelAuthTokenInterceptor extends Interceptor {
144
191
  setTimeout(async () => {
145
192
  const key = this.getRetryKey(options);
146
193
  try {
147
- const newToken = await this._refreshDataChannelToken();
194
+ const newToken = await this._refreshDataChannelToken(options.uri || options.url);
148
195
 
149
196
  options.headers[DATA_CHANNEL_AUTH_HEADER] = newToken;
150
197
 
@@ -18,12 +18,33 @@ export default class LocusRetryStatusInterceptor extends Interceptor {
18
18
  }
19
19
 
20
20
  /**
21
- * Handle response errors
22
- * @param {Object} options
23
- * @param {WebexHttpError} reason
24
- * @returns {Promise<WebexHttpError>}
21
+ * Check whether a URI is a Locus /hashtree or /sync endpoint.
22
+ * @param {string} uri
23
+ * @returns {boolean}
25
24
  */
25
+ private static isLocusHashtreeOrSync(uri: string): boolean {
26
+ try {
27
+ const {pathname} = new URL(uri);
28
+
29
+ return (
30
+ pathname.includes('/locus/') &&
31
+ (pathname.endsWith('/hashtree') || pathname.endsWith('/sync'))
32
+ );
33
+ } catch {
34
+ return false;
35
+ }
36
+ }
37
+
26
38
  onResponseError(options, reason) {
39
+ // Don't retry /hashtree or /sync calls for 429 or any 5xx — during a sync storm retries
40
+ // make things worse. The normal sync timers will handle recovery for these endpoints.
41
+ if (
42
+ (reason.statusCode === 429 || reason.statusCode >= 500) &&
43
+ LocusRetryStatusInterceptor.isLocusHashtreeOrSync(options.uri)
44
+ ) {
45
+ return Promise.reject(reason);
46
+ }
47
+
27
48
  if ((reason.statusCode === 503 || reason.statusCode === 429) && options.uri.includes('locus')) {
28
49
  const hasRetriedLocusRequest = rateLimitExpiryTime.get(this);
29
50
  const retryAfterTime = options.headers['retry-after'] || 2000;
@@ -31,7 +52,7 @@ export default class LocusRetryStatusInterceptor extends Interceptor {
31
52
  if (hasRetriedLocusRequest) {
32
53
  rateLimitExpiryTime.set(this, false);
33
54
 
34
- return Promise.reject(options);
55
+ return Promise.reject(reason);
35
56
  }
36
57
  rateLimitExpiryTime.set(this, true);
37
58