@webex/plugin-meetings 3.12.0-next.16 → 3.12.0-next.161

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 (301) 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 +207 -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/dist/aiEnableRequest/index.js +15 -2
  40. package/dist/aiEnableRequest/index.js.map +1 -1
  41. package/dist/annotation/index.js +2 -2
  42. package/dist/annotation/index.js.map +1 -1
  43. package/dist/breakouts/breakout.js +8 -3
  44. package/dist/breakouts/breakout.js.map +1 -1
  45. package/dist/breakouts/events.js +29 -14
  46. package/dist/breakouts/events.js.map +1 -1
  47. package/dist/breakouts/index.js +99 -4
  48. package/dist/breakouts/index.js.map +1 -1
  49. package/dist/common/errors/webex-errors.js +49 -5
  50. package/dist/common/errors/webex-errors.js.map +1 -1
  51. package/dist/config.js +2 -2
  52. package/dist/config.js.map +1 -1
  53. package/dist/constants.js +37 -10
  54. package/dist/constants.js.map +1 -1
  55. package/dist/controls-options-manager/index.js +46 -10
  56. package/dist/controls-options-manager/index.js.map +1 -1
  57. package/dist/hashTree/constants.js +4 -1
  58. package/dist/hashTree/constants.js.map +1 -1
  59. package/dist/hashTree/hashTreeParser.js +1096 -391
  60. package/dist/hashTree/hashTreeParser.js.map +1 -1
  61. package/dist/hashTree/utils.js +20 -0
  62. package/dist/hashTree/utils.js.map +1 -1
  63. package/dist/index.js +7 -0
  64. package/dist/index.js.map +1 -1
  65. package/dist/interceptors/dataChannelAuthToken.js +75 -15
  66. package/dist/interceptors/dataChannelAuthToken.js.map +1 -1
  67. package/dist/interceptors/locusRetry.js +24 -9
  68. package/dist/interceptors/locusRetry.js.map +1 -1
  69. package/dist/interpretation/index.js +55 -12
  70. package/dist/interpretation/index.js.map +1 -1
  71. package/dist/interpretation/interpretation.types.js +7 -0
  72. package/dist/interpretation/interpretation.types.js.map +1 -0
  73. package/dist/interpretation/siLanguage.js +1 -1
  74. package/dist/locus-info/controlsUtils.js +4 -1
  75. package/dist/locus-info/controlsUtils.js.map +1 -1
  76. package/dist/locus-info/index.js +615 -176
  77. package/dist/locus-info/index.js.map +1 -1
  78. package/dist/locus-info/infoUtils.js +36 -5
  79. package/dist/locus-info/infoUtils.js.map +1 -1
  80. package/dist/locus-info/types.js +20 -0
  81. package/dist/locus-info/types.js.map +1 -1
  82. package/dist/media/MediaConnectionAwaiter.js +15 -2
  83. package/dist/media/MediaConnectionAwaiter.js.map +1 -1
  84. package/dist/media/index.js +8 -2
  85. package/dist/media/index.js.map +1 -1
  86. package/dist/media/properties.js +4 -5
  87. package/dist/media/properties.js.map +1 -1
  88. package/dist/meeting/in-meeting-actions.js +7 -1
  89. package/dist/meeting/in-meeting-actions.js.map +1 -1
  90. package/dist/meeting/index.js +1688 -835
  91. package/dist/meeting/index.js.map +1 -1
  92. package/dist/meeting/locusMediaRequest.js +229 -82
  93. package/dist/meeting/locusMediaRequest.js.map +1 -1
  94. package/dist/meeting/muteState.js +10 -1
  95. package/dist/meeting/muteState.js.map +1 -1
  96. package/dist/meeting/request.js +5 -2
  97. package/dist/meeting/request.js.map +1 -1
  98. package/dist/meeting/util.js +37 -3
  99. package/dist/meeting/util.js.map +1 -1
  100. package/dist/meeting/voicea-meeting.js +2 -1
  101. package/dist/meeting/voicea-meeting.js.map +1 -1
  102. package/dist/meeting-info/meeting-info-v2.js +9 -3
  103. package/dist/meeting-info/meeting-info-v2.js.map +1 -1
  104. package/dist/meetings/index.js +300 -128
  105. package/dist/meetings/index.js.map +1 -1
  106. package/dist/meetings/meetings.types.js +6 -1
  107. package/dist/meetings/meetings.types.js.map +1 -1
  108. package/dist/meetings/request.js +39 -0
  109. package/dist/meetings/request.js.map +1 -1
  110. package/dist/meetings/util.js +116 -18
  111. package/dist/meetings/util.js.map +1 -1
  112. package/dist/member/index.js +10 -0
  113. package/dist/member/index.js.map +1 -1
  114. package/dist/member/types.js.map +1 -1
  115. package/dist/member/util.js +30 -0
  116. package/dist/member/util.js.map +1 -1
  117. package/dist/members/index.js +101 -43
  118. package/dist/members/index.js.map +1 -1
  119. package/dist/members/util.js +8 -1
  120. package/dist/members/util.js.map +1 -1
  121. package/dist/metrics/constants.js +7 -1
  122. package/dist/metrics/constants.js.map +1 -1
  123. package/dist/multistream/codec/constants.js +63 -0
  124. package/dist/multistream/codec/constants.js.map +1 -0
  125. package/dist/multistream/mediaRequestManager.js +62 -15
  126. package/dist/multistream/mediaRequestManager.js.map +1 -1
  127. package/dist/multistream/receiveSlot.js +9 -0
  128. package/dist/multistream/receiveSlot.js.map +1 -1
  129. package/dist/multistream/remoteMediaManager.js +32 -4
  130. package/dist/multistream/remoteMediaManager.js.map +1 -1
  131. package/dist/reachability/clusterReachability.js.map +1 -1
  132. package/dist/reachability/index.js +121 -83
  133. package/dist/reachability/index.js.map +1 -1
  134. package/dist/reachability/reachability.types.js +2 -0
  135. package/dist/reachability/reachability.types.js.map +1 -1
  136. package/dist/reachability/util.js +45 -0
  137. package/dist/reachability/util.js.map +1 -1
  138. package/dist/reactions/reactions.type.js.map +1 -1
  139. package/dist/recording-controller/index.js +1 -3
  140. package/dist/recording-controller/index.js.map +1 -1
  141. package/dist/roap/turnDiscovery.js +8 -1
  142. package/dist/roap/turnDiscovery.js.map +1 -1
  143. package/dist/types/common/errors/webex-errors.d.ts +32 -2
  144. package/dist/types/config.d.ts +2 -2
  145. package/dist/types/constants.d.ts +13 -1
  146. package/dist/types/controls-options-manager/index.d.ts +16 -0
  147. package/dist/types/hashTree/constants.d.ts +1 -0
  148. package/dist/types/hashTree/hashTreeParser.d.ts +201 -22
  149. package/dist/types/hashTree/utils.d.ts +7 -0
  150. package/dist/types/index.d.ts +3 -0
  151. package/dist/types/interceptors/locusRetry.d.ts +4 -4
  152. package/dist/types/interpretation/interpretation.types.d.ts +10 -0
  153. package/dist/types/locus-info/index.d.ts +106 -8
  154. package/dist/types/locus-info/infoUtils.d.ts +8 -0
  155. package/dist/types/locus-info/types.d.ts +22 -1
  156. package/dist/types/media/MediaConnectionAwaiter.d.ts +10 -1
  157. package/dist/types/media/properties.d.ts +6 -2
  158. package/dist/types/meeting/in-meeting-actions.d.ts +6 -0
  159. package/dist/types/meeting/index.d.ts +176 -11
  160. package/dist/types/meeting/locusMediaRequest.d.ts +12 -0
  161. package/dist/types/meeting/request.d.ts +1 -0
  162. package/dist/types/meeting/util.d.ts +9 -0
  163. package/dist/types/meeting-info/meeting-info-v2.d.ts +1 -0
  164. package/dist/types/meetings/index.d.ts +40 -19
  165. package/dist/types/meetings/meetings.types.d.ts +15 -0
  166. package/dist/types/meetings/request.d.ts +14 -0
  167. package/dist/types/member/index.d.ts +1 -0
  168. package/dist/types/member/types.d.ts +1 -0
  169. package/dist/types/member/util.d.ts +9 -0
  170. package/dist/types/members/index.d.ts +15 -2
  171. package/dist/types/members/util.d.ts +1 -5
  172. package/dist/types/metrics/constants.d.ts +6 -0
  173. package/dist/types/multistream/codec/constants.d.ts +7 -0
  174. package/dist/types/multistream/mediaRequestManager.d.ts +22 -5
  175. package/dist/types/multistream/remoteMediaManager.d.ts +18 -0
  176. package/dist/types/reachability/clusterReachability.d.ts +3 -3
  177. package/dist/types/reachability/index.d.ts +10 -3
  178. package/dist/types/reachability/reachability.types.d.ts +7 -0
  179. package/dist/types/reachability/util.d.ts +17 -0
  180. package/dist/types/reactions/reactions.type.d.ts +3 -0
  181. package/dist/webinar/index.js +307 -161
  182. package/dist/webinar/index.js.map +1 -1
  183. package/package.json +23 -23
  184. package/src/aiEnableRequest/ai-docs/ai-enable-request-spec.md +223 -0
  185. package/src/aiEnableRequest/index.ts +16 -0
  186. package/src/annotation/ai-docs/annotation-spec.md +236 -0
  187. package/src/annotation/index.ts +6 -4
  188. package/src/breakouts/ai-docs/breakouts-spec.md +324 -0
  189. package/src/breakouts/breakout.ts +3 -1
  190. package/src/breakouts/events.ts +33 -11
  191. package/src/breakouts/index.ts +122 -2
  192. package/src/common/errors/webex-errors.ts +50 -3
  193. package/src/config.ts +2 -2
  194. package/src/constants.ts +21 -3
  195. package/src/controls-options-manager/ai-docs/controls-options-manager-spec.md +243 -0
  196. package/src/controls-options-manager/index.ts +62 -10
  197. package/src/hashTree/ai-docs/hash-tree-spec.md +267 -0
  198. package/src/hashTree/constants.ts +7 -0
  199. package/src/hashTree/hashTreeParser.ts +861 -193
  200. package/src/hashTree/utils.ts +19 -0
  201. package/src/index.ts +6 -0
  202. package/src/interceptors/ai-docs/interceptors-spec.md +247 -0
  203. package/src/interceptors/dataChannelAuthToken.ts +88 -12
  204. package/src/interceptors/locusRetry.ts +26 -5
  205. package/src/interpretation/ai-docs/interpretation-spec.md +256 -0
  206. package/src/interpretation/index.ts +65 -10
  207. package/src/interpretation/interpretation.types.ts +11 -0
  208. package/src/locus-info/ai-docs/locus-info-spec.md +293 -0
  209. package/src/locus-info/controlsUtils.ts +3 -1
  210. package/src/locus-info/index.ts +566 -164
  211. package/src/locus-info/infoUtils.ts +41 -6
  212. package/src/locus-info/types.ts +26 -1
  213. package/src/media/MediaConnectionAwaiter.ts +21 -4
  214. package/src/media/ai-docs/media-spec.md +267 -0
  215. package/src/media/index.ts +10 -1
  216. package/src/media/properties.ts +8 -3
  217. package/src/meeting/ai-docs/meeting-spec.md +401 -0
  218. package/src/meeting/in-meeting-actions.ts +12 -0
  219. package/src/meeting/index.ts +946 -120
  220. package/src/meeting/locusMediaRequest.ts +106 -6
  221. package/src/meeting/muteState.ts +10 -1
  222. package/src/meeting/request.ts +11 -0
  223. package/src/meeting/util.ts +51 -7
  224. package/src/meeting/voicea-meeting.ts +1 -1
  225. package/src/meeting-info/ai-docs/meeting-info-spec.md +261 -0
  226. package/src/meeting-info/meeting-info-v2.ts +10 -4
  227. package/src/meetings/ai-docs/meetings-spec.md +296 -0
  228. package/src/meetings/index.ts +200 -80
  229. package/src/meetings/meetings.types.ts +19 -0
  230. package/src/meetings/request.ts +43 -0
  231. package/src/meetings/util.ts +117 -4
  232. package/src/member/ai-docs/member-spec.md +196 -0
  233. package/src/member/index.ts +10 -0
  234. package/src/member/types.ts +1 -0
  235. package/src/member/util.ts +29 -0
  236. package/src/members/ai-docs/members-spec.md +256 -0
  237. package/src/members/index.ts +70 -7
  238. package/src/members/util.ts +12 -4
  239. package/src/metrics/ai-docs/metrics-spec.md +185 -0
  240. package/src/metrics/constants.ts +6 -0
  241. package/src/multistream/ai-docs/multistream-spec.md +292 -0
  242. package/src/multistream/codec/constants.ts +58 -0
  243. package/src/multistream/mediaRequestManager.ts +119 -28
  244. package/src/multistream/receiveSlot.ts +18 -0
  245. package/src/multistream/remoteMediaManager.ts +23 -1
  246. package/src/personal-meeting-room/ai-docs/personal-meeting-room-spec.md +234 -0
  247. package/src/reachability/ai-docs/reachability-spec.md +261 -0
  248. package/src/reachability/clusterReachability.ts +3 -2
  249. package/src/reachability/index.ts +47 -16
  250. package/src/reachability/reachability.types.ts +11 -0
  251. package/src/reachability/util.ts +36 -0
  252. package/src/reactions/ai-docs/reactions-spec.md +198 -0
  253. package/src/reactions/reactions.type.ts +3 -0
  254. package/src/reconnection-manager/ai-docs/reconnection-manager-spec.md +272 -0
  255. package/src/recording-controller/ai-docs/recording-controller-spec.md +223 -0
  256. package/src/recording-controller/index.ts +1 -2
  257. package/src/roap/ai-docs/roap-spec.md +241 -0
  258. package/src/roap/turnDiscovery.ts +9 -1
  259. package/src/webinar/ai-docs/webinar-spec.md +243 -0
  260. package/src/webinar/index.ts +216 -38
  261. package/test/unit/spec/aiEnableRequest/index.ts +86 -0
  262. package/test/unit/spec/annotation/index.ts +3 -3
  263. package/test/unit/spec/breakouts/breakout.ts +9 -3
  264. package/test/unit/spec/breakouts/events.ts +120 -2
  265. package/test/unit/spec/breakouts/index.ts +223 -3
  266. package/test/unit/spec/common/errors/webex-errors.ts +78 -0
  267. package/test/unit/spec/controls-options-manager/index.js +139 -32
  268. package/test/unit/spec/hashTree/hashTreeParser.ts +2451 -184
  269. package/test/unit/spec/hashTree/utils.ts +37 -0
  270. package/test/unit/spec/interceptors/dataChannelAuthToken.ts +196 -0
  271. package/test/unit/spec/interceptors/locusRetry.ts +234 -5
  272. package/test/unit/spec/interpretation/index.ts +119 -4
  273. package/test/unit/spec/locus-info/controlsUtils.js +172 -57
  274. package/test/unit/spec/locus-info/index.js +1014 -58
  275. package/test/unit/spec/locus-info/infoUtils.js +184 -1
  276. package/test/unit/spec/media/MediaConnectionAwaiter.ts +55 -0
  277. package/test/unit/spec/media/index.ts +92 -0
  278. package/test/unit/spec/media/properties.ts +23 -23
  279. package/test/unit/spec/meeting/in-meeting-actions.ts +6 -0
  280. package/test/unit/spec/meeting/index.js +2838 -109
  281. package/test/unit/spec/meeting/locusMediaRequest.ts +406 -4
  282. package/test/unit/spec/meeting/muteState.js +81 -0
  283. package/test/unit/spec/meeting/request.js +12 -0
  284. package/test/unit/spec/meeting/utils.js +189 -17
  285. package/test/unit/spec/meeting/voicea-meeting.ts +85 -1
  286. package/test/unit/spec/meeting-info/meetinginfov2.js +76 -10
  287. package/test/unit/spec/meetings/index.js +544 -49
  288. package/test/unit/spec/meetings/request.js +141 -0
  289. package/test/unit/spec/meetings/utils.js +402 -51
  290. package/test/unit/spec/member/index.js +7 -0
  291. package/test/unit/spec/member/util.js +89 -0
  292. package/test/unit/spec/members/index.js +216 -0
  293. package/test/unit/spec/members/request.js +37 -1
  294. package/test/unit/spec/members/utils.js +63 -0
  295. package/test/unit/spec/multistream/mediaRequestManager.ts +501 -37
  296. package/test/unit/spec/multistream/remoteMediaManager.ts +46 -0
  297. package/test/unit/spec/reachability/index.ts +128 -46
  298. package/test/unit/spec/reachability/util.ts +31 -0
  299. package/test/unit/spec/recording-controller/index.js +9 -8
  300. package/test/unit/spec/roap/turnDiscovery.ts +20 -0
  301. package/test/unit/spec/webinar/index.ts +332 -31
@@ -2,9 +2,11 @@ import {HashTreeObject, ObjectType} from '../../../../src/hashTree/types';
2
2
  import {
3
3
  deleteNestedObjectsWithHtMeta,
4
4
  isSelf,
5
+ sleep,
5
6
  sortByInitPriority,
6
7
  } from '../../../../src/hashTree/utils';
7
8
  import {DataSetNames, DATA_SET_INIT_PRIORITY} from '../../../../src/hashTree/constants';
9
+ import sinon from 'sinon';
8
10
 
9
11
  import {assert} from '@webex/test-helper-chai';
10
12
 
@@ -224,4 +226,39 @@ describe('Hash Tree Utils', () => {
224
226
  ]);
225
227
  });
226
228
  });
229
+
230
+ describe('#sleep', () => {
231
+ let clock;
232
+
233
+ beforeEach(() => {
234
+ clock = sinon.useFakeTimers();
235
+ });
236
+
237
+ afterEach(() => {
238
+ clock.restore();
239
+ });
240
+
241
+ [0, -1, -100].forEach((ms) => {
242
+ it(`resolves immediately when ms is ${ms}`, async () => {
243
+ const result = sleep(ms);
244
+
245
+ assert.instanceOf(result, Promise);
246
+ await result;
247
+ });
248
+ });
249
+
250
+ it('resolves after the specified delay', async () => {
251
+ let resolved = false;
252
+
253
+ sleep(500).then(() => { resolved = true; });
254
+
255
+ assert.isFalse(resolved);
256
+
257
+ await clock.tickAsync(499);
258
+ assert.isFalse(resolved);
259
+
260
+ await clock.tickAsync(1);
261
+ assert.isTrue(resolved);
262
+ });
263
+ });
227
264
  });
@@ -7,6 +7,7 @@ import DataChannelAuthTokenInterceptor from '@webex/plugin-meetings/src/intercep
7
7
  import LoggerProxy from '@webex/plugin-meetings/src/common/logs/logger-proxy';
8
8
  import * as utils from '@webex/plugin-meetings/src/interceptors/utils';
9
9
  import {DATA_CHANNEL_AUTH_HEADER, MAX_RETRY} from '@webex/plugin-meetings/src/interceptors/constant';
10
+ import {LOCUS_URL} from '@webex/plugin-meetings/src/constants';
10
11
 
11
12
  describe('plugin-meetings', () => {
12
13
  describe('Interceptors', () => {
@@ -178,6 +179,28 @@ describe('plugin-meetings', () => {
178
179
  expect(result).to.equal('mock-response');
179
180
  });
180
181
 
182
+ it('passes request URL to _refreshDataChannelToken', async () => {
183
+ const psOptions = {
184
+ headers: {[DATA_CHANNEL_AUTH_HEADER]: 'old-token'},
185
+ method: 'POST',
186
+ uri: 'https://locus.example.com/practiceSession/datachannel',
187
+ };
188
+
189
+ interceptor._refreshDataChannelToken.resolves('new-token');
190
+ webex.request.resolves('mock-response');
191
+
192
+ const promise = interceptor.refreshTokenAndRetryWithDelay(psOptions);
193
+
194
+ clock.tick(2000);
195
+
196
+ await promise;
197
+
198
+ sinon.assert.calledOnceWithExactly(
199
+ interceptor._refreshDataChannelToken,
200
+ psOptions.uri
201
+ );
202
+ });
203
+
181
204
  it('rejects when refreshDataChannelToken fails', async () => {
182
205
  interceptor._refreshDataChannelToken.rejects(new Error('refresh failed'));
183
206
 
@@ -205,6 +228,179 @@ describe('plugin-meetings', () => {
205
228
  );
206
229
  });
207
230
  });
231
+
232
+ describe('refreshDataChannelToken routing (factory dispatcher)', () => {
233
+ let llmMock;
234
+ let meetingA;
235
+ let meetingsMock;
236
+ let dispatcherInterceptor;
237
+
238
+ const PS_DATACHANNEL_URL = 'https://board-a.wbx2.com/datachannel/api/v1/locus/cHJhY3RpY2Vfc2Vzc2lvbl9sb2N1cw==/registrations';
239
+ const DEFAULT_DATACHANNEL_URL = 'https://board-a.wbx2.com/datachannel/api/v1/locus/aHR0cHM6Ly9sb2N1cy1hLndieDIuY29t/registrations';
240
+
241
+ beforeEach(() => {
242
+ meetingA = {
243
+ id: 'meeting-a',
244
+ refreshDataChannelToken: sinon.stub().resolves({
245
+ body: {
246
+ datachannelToken: 'token-from-meeting-a',
247
+ dataChannelTokenType: 'llm-practice-session',
248
+ },
249
+ }),
250
+ };
251
+
252
+ llmMock = {
253
+ isDataChannelTokenEnabled: sinon.stub().resolves(true),
254
+ getSessionIdByDatachannelUrl: sinon.stub(),
255
+ getLocusUrlByDatachannelUrl: sinon.stub(),
256
+ getOwnerMeetingId: sinon.stub().returns(undefined),
257
+ refreshDataChannelToken: sinon.stub().resolves({
258
+ body: {
259
+ datachannelToken: 'token-from-llm-fallback',
260
+ dataChannelTokenType: 'llm-default-session',
261
+ },
262
+ }),
263
+ setDatachannelToken: sinon.stub(),
264
+ };
265
+
266
+ meetingsMock = {
267
+ getMeetingByType: sinon.stub(),
268
+ };
269
+
270
+ const context = {
271
+ internal: {llm: llmMock},
272
+ meetings: meetingsMock,
273
+ };
274
+
275
+ dispatcherInterceptor = Reflect.apply(DataChannelAuthTokenInterceptor.create, context, []);
276
+ });
277
+
278
+ it('routes PS request URL to PS session handler', async () => {
279
+ llmMock.getSessionIdByDatachannelUrl.withArgs(PS_DATACHANNEL_URL).returns('llm-practice-session');
280
+ llmMock.refreshDataChannelToken
281
+ .withArgs('llm-practice-session')
282
+ .resolves({
283
+ body: {
284
+ datachannelToken: 'token-from-ps-session',
285
+ dataChannelTokenType: 'llm-practice-session',
286
+ },
287
+ });
288
+
289
+ const token = await dispatcherInterceptor._refreshDataChannelToken(PS_DATACHANNEL_URL);
290
+
291
+ expect(token).to.equal('token-from-ps-session');
292
+ sinon.assert.calledOnceWithExactly(llmMock.refreshDataChannelToken, 'llm-practice-session');
293
+ sinon.assert.calledOnceWithExactly(
294
+ llmMock.setDatachannelToken,
295
+ 'token-from-ps-session',
296
+ 'llm-practice-session',
297
+ undefined
298
+ );
299
+ });
300
+
301
+ it('routes non-PS URL to default session handler', async () => {
302
+ llmMock.getSessionIdByDatachannelUrl.withArgs(DEFAULT_DATACHANNEL_URL).returns('llm-default-session');
303
+ llmMock.refreshDataChannelToken
304
+ .withArgs('llm-default-session')
305
+ .resolves({
306
+ body: {
307
+ datachannelToken: 'token-from-default-session',
308
+ dataChannelTokenType: 'llm-default-session',
309
+ },
310
+ });
311
+
312
+ const token = await dispatcherInterceptor._refreshDataChannelToken(DEFAULT_DATACHANNEL_URL);
313
+
314
+ expect(token).to.equal('token-from-default-session');
315
+ sinon.assert.calledOnceWithExactly(llmMock.refreshDataChannelToken, 'llm-default-session');
316
+ sinon.assert.calledOnceWithExactly(
317
+ llmMock.setDatachannelToken,
318
+ 'token-from-default-session',
319
+ 'llm-default-session',
320
+ undefined
321
+ );
322
+ });
323
+
324
+ it('falls back to default refresh when URL does not match any session or meeting route', async () => {
325
+ llmMock.getSessionIdByDatachannelUrl.withArgs(PS_DATACHANNEL_URL).returns(undefined);
326
+ llmMock.getLocusUrlByDatachannelUrl.withArgs(PS_DATACHANNEL_URL).returns(undefined);
327
+ llmMock.refreshDataChannelToken.withArgs(undefined).resolves({
328
+ body: {
329
+ datachannelToken: 'token-from-default-fallback',
330
+ dataChannelTokenType: 'llm-default-session',
331
+ },
332
+ });
333
+
334
+ const token = await dispatcherInterceptor._refreshDataChannelToken(PS_DATACHANNEL_URL);
335
+
336
+ expect(token).to.equal('token-from-default-fallback');
337
+ sinon.assert.calledOnceWithExactly(llmMock.refreshDataChannelToken, undefined);
338
+ sinon.assert.calledOnceWithExactly(
339
+ llmMock.setDatachannelToken,
340
+ 'token-from-default-fallback',
341
+ 'llm-default-session',
342
+ undefined
343
+ );
344
+ });
345
+
346
+ it('falls back to meeting lookup by locusUrl when session cannot be resolved', async () => {
347
+ llmMock.getSessionIdByDatachannelUrl.withArgs(PS_DATACHANNEL_URL).returns(undefined);
348
+ llmMock.getLocusUrlByDatachannelUrl.withArgs(PS_DATACHANNEL_URL).returns('https://locus-a.example.com');
349
+ meetingsMock.getMeetingByType.withArgs(LOCUS_URL, 'https://locus-a.example.com').returns(meetingA);
350
+
351
+ const token = await dispatcherInterceptor._refreshDataChannelToken(PS_DATACHANNEL_URL);
352
+
353
+ expect(token).to.equal('token-from-meeting-a');
354
+ sinon.assert.calledOnceWithExactly(meetingA.refreshDataChannelToken);
355
+ sinon.assert.notCalled(llmMock.refreshDataChannelToken);
356
+ sinon.assert.calledOnceWithExactly(
357
+ llmMock.setDatachannelToken,
358
+ 'token-from-meeting-a',
359
+ 'llm-practice-session',
360
+ 'meeting-a'
361
+ );
362
+ });
363
+
364
+ it('falls back to active meeting datachannel URL lookup when session/locus routing is unavailable', async () => {
365
+ llmMock.getSessionIdByDatachannelUrl.withArgs(PS_DATACHANNEL_URL).returns(undefined);
366
+ llmMock.getLocusUrlByDatachannelUrl.withArgs(PS_DATACHANNEL_URL).returns(undefined);
367
+ meetingsMock.getAllMeetings = sinon.stub().returns({
368
+ 'meeting-a': {
369
+ ...meetingA,
370
+ locusInfo: {
371
+ info: {
372
+ practiceSessionDatachannelUrl: PS_DATACHANNEL_URL,
373
+ datachannelUrl: DEFAULT_DATACHANNEL_URL,
374
+ },
375
+ },
376
+ },
377
+ });
378
+
379
+ const token = await dispatcherInterceptor._refreshDataChannelToken(PS_DATACHANNEL_URL);
380
+
381
+ expect(token).to.equal('token-from-meeting-a');
382
+ sinon.assert.calledOnceWithExactly(meetingA.refreshDataChannelToken);
383
+ sinon.assert.notCalled(llmMock.refreshDataChannelToken);
384
+ sinon.assert.calledOnceWithExactly(
385
+ llmMock.setDatachannelToken,
386
+ 'token-from-meeting-a',
387
+ 'llm-practice-session',
388
+ 'meeting-a'
389
+ );
390
+ });
391
+
392
+ it('throws when refresh returns no payload', async () => {
393
+ llmMock.getSessionIdByDatachannelUrl.returns('llm-default-session');
394
+ llmMock.refreshDataChannelToken.withArgs('llm-default-session').resolves(null);
395
+
396
+ await assert.isRejected(
397
+ dispatcherInterceptor._refreshDataChannelToken(
398
+ 'https://unknown-datachannel.example.com/registrations'
399
+ ),
400
+ /DataChannel token refresh returned no payload/
401
+ );
402
+ });
403
+ });
208
404
  });
209
405
  });
210
406
  });
@@ -36,6 +36,27 @@ describe('plugin-meetings', () => {
36
36
  uri: `https://locus-test.webex.com/locus/api/v1/loci/call`,
37
37
  body: 'foo'
38
38
  };
39
+
40
+ const hashTreeOptions = {
41
+ method: 'GET',
42
+ headers: {
43
+ trackingid: 'test',
44
+ 'retry-after': 1000,
45
+ },
46
+ uri: `https://locus-test.webex.com/locus/api/v1/loci/12345/session/abc/datasets/main/hashtree`,
47
+ body: undefined,
48
+ };
49
+
50
+ const syncOptions = {
51
+ method: 'POST',
52
+ headers: {
53
+ trackingid: 'test',
54
+ 'retry-after': 1000,
55
+ },
56
+ uri: `https://locus-test.webex.com/locus/api/v1/loci/12345/session/abc/datasets/main/sync`,
57
+ body: 'foo',
58
+ };
59
+
39
60
  const reason1 = new WebexHttpError.MethodNotAllowed({
40
61
  statusCode: 403,
41
62
  options: {
@@ -68,14 +89,223 @@ describe('plugin-meetings', () => {
68
89
  });
69
90
 
70
91
  it('calls handleRetryRequestLocusServiceError with correct retry time when locus service unavailable error', () => {
71
- interceptor.webex.request = sinon.stub().returns(Promise.resolve());
72
- const handleRetryStub = sinon.stub(interceptor, 'handleRetryRequestLocusServiceError');
92
+ interceptor.webex.request = sinon.stub().returns(Promise.resolve());
93
+ const handleRetryStub = sinon.stub(
94
+ interceptor,
95
+ 'handleRetryRequestLocusServiceError'
96
+ );
97
+ handleRetryStub.returns(Promise.resolve());
98
+
99
+ return interceptor.onResponseError(options, reason2).then(() => {
100
+ expect(handleRetryStub.calledWith(options, 1000)).to.be.true;
101
+ });
102
+ });
103
+
104
+ [429, 500, 502, 503, 504].forEach((statusCode) => {
105
+ it(`does not retry /hashtree requests on ${statusCode}`, () => {
106
+ const reason = new WebexHttpError.MethodNotAllowed({
107
+ statusCode,
108
+ options: {
109
+ headers: {trackingid: 'test', 'retry-after': 1000},
110
+ uri: hashTreeOptions.uri,
111
+ },
112
+ body: {error: `Fake ${statusCode}`},
113
+ });
114
+
115
+ const handleRetryStub = sinon.stub(
116
+ interceptor,
117
+ 'handleRetryRequestLocusServiceError'
118
+ );
119
+ handleRetryStub.returns(Promise.resolve());
120
+
121
+ return interceptor.onResponseError(hashTreeOptions, reason).then(
122
+ () => assert.fail('Expected promise to be rejected'),
123
+ (err) => {
124
+ expect(err).to.equal(reason);
125
+ expect(handleRetryStub.called).to.be.false;
126
+ handleRetryStub.restore();
127
+ }
128
+ );
129
+ });
130
+
131
+ it(`does not retry /sync requests on ${statusCode}`, () => {
132
+ const reason = new WebexHttpError.MethodNotAllowed({
133
+ statusCode,
134
+ options: {
135
+ headers: {trackingid: 'test', 'retry-after': 1000},
136
+ uri: syncOptions.uri,
137
+ },
138
+ body: {error: `Fake ${statusCode}`},
139
+ });
140
+
141
+ const handleRetryStub = sinon.stub(
142
+ interceptor,
143
+ 'handleRetryRequestLocusServiceError'
144
+ );
73
145
  handleRetryStub.returns(Promise.resolve());
74
146
 
75
- return interceptor.onResponseError(options, reason2).then(() => {
76
- expect(handleRetryStub.calledWith(options, 1000)).to.be.true;
147
+ return interceptor.onResponseError(syncOptions, reason).then(
148
+ () => assert.fail('Expected promise to be rejected'),
149
+ (err) => {
150
+ expect(err).to.equal(reason);
151
+ expect(handleRetryStub.called).to.be.false;
152
+ handleRetryStub.restore();
153
+ }
154
+ );
155
+ });
156
+ });
157
+
158
+ it('still retries other locus requests on 429', () => {
159
+ const reason429 = new WebexHttpError.MethodNotAllowed({
160
+ statusCode: 429,
161
+ options: {
162
+ headers: {trackingid: 'test', 'retry-after': 1000},
163
+ uri: options.uri,
164
+ },
165
+ body: {error: 'Too Many Requests'},
166
+ });
167
+
168
+ interceptor.webex.request = sinon.stub().returns(Promise.resolve());
169
+ const handleRetryStub = sinon.stub(
170
+ interceptor,
171
+ 'handleRetryRequestLocusServiceError'
172
+ );
173
+ handleRetryStub.returns(Promise.resolve());
174
+
175
+ return interceptor.onResponseError(options, reason429).then(() => {
176
+ expect(handleRetryStub.calledOnce).to.be.true;
177
+ handleRetryStub.restore();
178
+ });
179
+ });
180
+
181
+ it('still retries other locus requests on 503', () => {
182
+ interceptor.webex.request = sinon.stub().returns(Promise.resolve());
183
+ const handleRetryStub = sinon.stub(
184
+ interceptor,
185
+ 'handleRetryRequestLocusServiceError'
186
+ );
187
+ handleRetryStub.returns(Promise.resolve());
77
188
 
189
+ return interceptor.onResponseError(options, reason2).then(() => {
190
+ expect(handleRetryStub.calledOnce).to.be.true;
191
+ handleRetryStub.restore();
192
+ });
193
+ });
194
+
195
+ [
196
+ [429, WebexHttpError.TooManyRequests],
197
+ [503, WebexHttpError.ServiceUnavailable],
198
+ ].forEach(([statusCode, ErrorType]) => {
199
+ it(`rejects the HTTP ${statusCode} error after a locus retry is exhausted`, async () => {
200
+ const reason = new ErrorType({
201
+ statusCode,
202
+ options: {
203
+ headers: {trackingid: 'test', 'retry-after': 1000},
204
+ uri: options.uri,
205
+ },
206
+ body: {message: 'Locus request failed'},
207
+ });
208
+ const handleRetryStub = sinon
209
+ .stub(interceptor, 'handleRetryRequestLocusServiceError')
210
+ .resolves();
211
+
212
+ await interceptor.onResponseError(options, reason);
213
+
214
+ return interceptor.onResponseError(options, reason).then(
215
+ () => assert.fail('Expected promise to be rejected'),
216
+ (error) => {
217
+ expect(error).to.equal(reason);
218
+ handleRetryStub.restore();
219
+ }
220
+ );
221
+ });
222
+ });
223
+
224
+ describe('URI parsing edge cases', () => {
225
+ const make503Reason = (uri) =>
226
+ new WebexHttpError.MethodNotAllowed({
227
+ statusCode: 503,
228
+ options: {headers: {trackingid: 'test', 'retry-after': 1000}, uri},
229
+ body: {error: 'Service Unavailable'},
230
+ });
231
+
232
+ const makeOptions = (uri) => ({
233
+ method: 'GET',
234
+ headers: {trackingid: 'test', 'retry-after': 1000},
235
+ uri,
236
+ body: undefined,
237
+ });
238
+
239
+ [
240
+ 'https://locus.webex.com/locus/api/v1/loci/123/session/abc/datasets/main/hashtree?rootHash=xyz',
241
+ 'https://locus.webex.com/locus/api/v1/loci/123/session/abc/datasets/main/sync?seq=5',
242
+ ].forEach((uri) => {
243
+ it(`skips retry even with query params: ${uri.split('/').pop()}`, () => {
244
+ const opts = makeOptions(uri);
245
+ const reason = make503Reason(uri);
246
+ const stub = sinon
247
+ .stub(interceptor, 'handleRetryRequestLocusServiceError')
248
+ .returns(Promise.resolve());
249
+
250
+ return interceptor.onResponseError(opts, reason).then(
251
+ () => assert.fail('Expected promise to be rejected'),
252
+ (err) => {
253
+ expect(err).to.equal(reason);
254
+ expect(stub.called).to.be.false;
255
+ stub.restore();
256
+ }
257
+ );
78
258
  });
259
+ });
260
+
261
+ [
262
+ 'https://locus.webex.com/locus/api/v1/loci/123/hashtree-v2',
263
+ 'https://locus.webex.com/locus/api/v1/loci/123/syncData',
264
+ 'https://locus.webex.com/locus/api/v1/loci/123/async',
265
+ 'https://locus.webex.com/locus/api/v1/loci/123/hashtree/metadata',
266
+ ].forEach((uri) => {
267
+ it(`still retries when path only partially matches: ${uri
268
+ .split('/')
269
+ .pop()}`, () => {
270
+ const opts = makeOptions(uri);
271
+ const reason = make503Reason(uri);
272
+ interceptor.webex.request = sinon.stub().returns(Promise.resolve());
273
+ const stub = sinon
274
+ .stub(interceptor, 'handleRetryRequestLocusServiceError')
275
+ .returns(Promise.resolve());
276
+
277
+ return interceptor.onResponseError(opts, reason).then(() => {
278
+ expect(stub.calledOnce).to.be.true;
279
+ stub.restore();
280
+ });
281
+ });
282
+ });
283
+
284
+ it('still retries when /hashtree is on a non-locus host', () => {
285
+ const uri = 'https://other-service.webex.com/api/v1/hashtree';
286
+ const opts = makeOptions(uri);
287
+ const reason = make503Reason(uri);
288
+
289
+ return interceptor.onResponseError(opts, reason).then(
290
+ () => assert.fail('Expected promise to be rejected'),
291
+ (err) => {
292
+ expect(err).to.equal(reason);
293
+ }
294
+ );
295
+ });
296
+
297
+ it('still retries when URI is malformed', () => {
298
+ const uri = 'not-a-valid-url';
299
+ const opts = makeOptions(uri);
300
+ const reason = make503Reason(uri);
301
+
302
+ return interceptor.onResponseError(opts, reason).then(
303
+ () => assert.fail('Expected promise to be rejected'),
304
+ (err) => {
305
+ expect(err).to.equal(reason);
306
+ }
307
+ );
308
+ });
79
309
  });
80
310
  });
81
311
 
@@ -129,4 +359,3 @@ describe('plugin-meetings', () => {
129
359
  });
130
360
  });
131
361
  });
132
-