@webex/plugin-meetings 3.12.0-task-refactor.1 → 3.12.0-webex-services-ready.2

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 (302) hide show
  1. package/AGENTS.md +9 -0
  2. package/dist/aiEnableRequest/index.js +197 -0
  3. package/dist/aiEnableRequest/index.js.map +1 -0
  4. package/dist/aiEnableRequest/utils.js +36 -0
  5. package/dist/aiEnableRequest/utils.js.map +1 -0
  6. package/dist/annotation/index.js +14 -5
  7. package/dist/annotation/index.js.map +1 -1
  8. package/dist/breakouts/breakout.js +8 -3
  9. package/dist/breakouts/breakout.js.map +1 -1
  10. package/dist/breakouts/index.js +26 -2
  11. package/dist/breakouts/index.js.map +1 -1
  12. package/dist/common/errors/webex-errors.js +49 -5
  13. package/dist/common/errors/webex-errors.js.map +1 -1
  14. package/dist/config.js +9 -3
  15. package/dist/config.js.map +1 -1
  16. package/dist/constants.js +59 -10
  17. package/dist/constants.js.map +1 -1
  18. package/dist/controls-options-manager/constants.js +11 -1
  19. package/dist/controls-options-manager/constants.js.map +1 -1
  20. package/dist/controls-options-manager/index.js +67 -29
  21. package/dist/controls-options-manager/index.js.map +1 -1
  22. package/dist/controls-options-manager/util.js +91 -0
  23. package/dist/controls-options-manager/util.js.map +1 -1
  24. package/dist/hashTree/constants.js +34 -0
  25. package/dist/hashTree/constants.js.map +1 -0
  26. package/dist/hashTree/hashTree.js +533 -0
  27. package/dist/hashTree/hashTree.js.map +1 -0
  28. package/dist/hashTree/hashTreeParser.js +2068 -36
  29. package/dist/hashTree/hashTreeParser.js.map +1 -1
  30. package/dist/hashTree/types.js +13 -3
  31. package/dist/hashTree/types.js.map +1 -1
  32. package/dist/hashTree/utils.js +111 -0
  33. package/dist/hashTree/utils.js.map +1 -0
  34. package/dist/index.js +18 -2
  35. package/dist/index.js.map +1 -1
  36. package/dist/interceptors/constant.js +12 -0
  37. package/dist/interceptors/constant.js.map +1 -0
  38. package/dist/interceptors/dataChannelAuthToken.js +350 -0
  39. package/dist/interceptors/dataChannelAuthToken.js.map +1 -0
  40. package/dist/interceptors/index.js +7 -0
  41. package/dist/interceptors/index.js.map +1 -1
  42. package/dist/interceptors/locusRetry.js +23 -8
  43. package/dist/interceptors/locusRetry.js.map +1 -1
  44. package/dist/interceptors/locusRouteToken.js +27 -5
  45. package/dist/interceptors/locusRouteToken.js.map +1 -1
  46. package/dist/interceptors/utils.js +27 -0
  47. package/dist/interceptors/utils.js.map +1 -0
  48. package/dist/interpretation/index.js +11 -2
  49. package/dist/interpretation/index.js.map +1 -1
  50. package/dist/interpretation/interpretation.types.js +7 -0
  51. package/dist/interpretation/interpretation.types.js.map +1 -0
  52. package/dist/interpretation/siLanguage.js +1 -1
  53. package/dist/locus-info/controlsUtils.js +11 -4
  54. package/dist/locus-info/controlsUtils.js.map +1 -1
  55. package/dist/locus-info/index.js +896 -277
  56. package/dist/locus-info/index.js.map +1 -1
  57. package/dist/locus-info/infoUtils.js +36 -5
  58. package/dist/locus-info/infoUtils.js.map +1 -1
  59. package/dist/locus-info/selfUtils.js +1 -0
  60. package/dist/locus-info/selfUtils.js.map +1 -1
  61. package/dist/locus-info/types.js +19 -0
  62. package/dist/locus-info/types.js.map +1 -1
  63. package/dist/media/MediaConnectionAwaiter.js +72 -3
  64. package/dist/media/MediaConnectionAwaiter.js.map +1 -1
  65. package/dist/media/index.js +8 -2
  66. package/dist/media/index.js.map +1 -1
  67. package/dist/media/properties.js +5 -2
  68. package/dist/media/properties.js.map +1 -1
  69. package/dist/meeting/in-meeting-actions.js +11 -1
  70. package/dist/meeting/in-meeting-actions.js.map +1 -1
  71. package/dist/meeting/index.js +2075 -1096
  72. package/dist/meeting/index.js.map +1 -1
  73. package/dist/meeting/locusMediaRequest.js +229 -82
  74. package/dist/meeting/locusMediaRequest.js.map +1 -1
  75. package/dist/meeting/muteState.js +10 -1
  76. package/dist/meeting/muteState.js.map +1 -1
  77. package/dist/meeting/request.js +55 -2
  78. package/dist/meeting/request.js.map +1 -1
  79. package/dist/meeting/request.type.js.map +1 -1
  80. package/dist/meeting/util.js +168 -5
  81. package/dist/meeting/util.js.map +1 -1
  82. package/dist/meeting-info/meeting-info-v2.js +2 -2
  83. package/dist/meeting-info/meeting-info-v2.js.map +1 -1
  84. package/dist/meetings/index.js +369 -173
  85. package/dist/meetings/index.js.map +1 -1
  86. package/dist/meetings/meetings.types.js +6 -1
  87. package/dist/meetings/meetings.types.js.map +1 -1
  88. package/dist/meetings/request.js +39 -0
  89. package/dist/meetings/request.js.map +1 -1
  90. package/dist/meetings/util.js +127 -25
  91. package/dist/meetings/util.js.map +1 -1
  92. package/dist/member/index.js +20 -0
  93. package/dist/member/index.js.map +1 -1
  94. package/dist/member/types.js.map +1 -1
  95. package/dist/member/util.js +40 -0
  96. package/dist/member/util.js.map +1 -1
  97. package/dist/members/index.js +101 -43
  98. package/dist/members/index.js.map +1 -1
  99. package/dist/members/util.js +8 -1
  100. package/dist/members/util.js.map +1 -1
  101. package/dist/metrics/constants.js +11 -1
  102. package/dist/metrics/constants.js.map +1 -1
  103. package/dist/multistream/codec/constants.js +63 -0
  104. package/dist/multistream/codec/constants.js.map +1 -0
  105. package/dist/multistream/mediaRequestManager.js +64 -68
  106. package/dist/multistream/mediaRequestManager.js.map +1 -1
  107. package/dist/multistream/receiveSlot.js +9 -0
  108. package/dist/multistream/receiveSlot.js.map +1 -1
  109. package/dist/multistream/remoteMediaManager.js +11 -0
  110. package/dist/multistream/remoteMediaManager.js.map +1 -1
  111. package/dist/multistream/sendSlotManager.js +116 -2
  112. package/dist/multistream/sendSlotManager.js.map +1 -1
  113. package/dist/reachability/clusterReachability.js +171 -18
  114. package/dist/reachability/clusterReachability.js.map +1 -1
  115. package/dist/reachability/index.js +142 -94
  116. package/dist/reachability/index.js.map +1 -1
  117. package/dist/reachability/reachability.types.js +2 -0
  118. package/dist/reachability/reachability.types.js.map +1 -1
  119. package/dist/reachability/reachabilityPeerConnection.js +1 -1
  120. package/dist/reachability/reachabilityPeerConnection.js.map +1 -1
  121. package/dist/reachability/util.js +45 -0
  122. package/dist/reachability/util.js.map +1 -1
  123. package/dist/reactions/reactions.type.js.map +1 -1
  124. package/dist/reconnection-manager/index.js +0 -1
  125. package/dist/reconnection-manager/index.js.map +1 -1
  126. package/dist/recording-controller/index.js +1 -3
  127. package/dist/recording-controller/index.js.map +1 -1
  128. package/dist/types/aiEnableRequest/index.d.ts +5 -0
  129. package/dist/types/aiEnableRequest/utils.d.ts +2 -0
  130. package/dist/types/common/browser-detection.d.ts +1 -0
  131. package/dist/types/common/errors/webex-errors.d.ts +32 -2
  132. package/dist/types/common/events/events-scope.d.ts +1 -0
  133. package/dist/types/common/events/events.d.ts +1 -0
  134. package/dist/types/config.d.ts +7 -2
  135. package/dist/types/constants.d.ts +35 -1
  136. package/dist/types/controls-options-manager/constants.d.ts +6 -1
  137. package/dist/types/controls-options-manager/index.d.ts +16 -0
  138. package/dist/types/hashTree/constants.d.ts +11 -0
  139. package/dist/types/hashTree/hashTree.d.ts +136 -0
  140. package/dist/types/hashTree/hashTreeParser.d.ts +392 -14
  141. package/dist/types/hashTree/types.d.ts +20 -0
  142. package/dist/types/hashTree/utils.d.ts +40 -0
  143. package/dist/types/index.d.ts +4 -0
  144. package/dist/types/interceptors/constant.d.ts +5 -0
  145. package/dist/types/interceptors/dataChannelAuthToken.d.ts +43 -0
  146. package/dist/types/interceptors/index.d.ts +2 -1
  147. package/dist/types/interceptors/locusRetry.d.ts +4 -4
  148. package/dist/types/interceptors/locusRouteToken.d.ts +2 -0
  149. package/dist/types/interceptors/utils.d.ts +1 -0
  150. package/dist/types/interpretation/interpretation.types.d.ts +10 -0
  151. package/dist/types/locus-info/index.d.ts +116 -51
  152. package/dist/types/locus-info/infoUtils.d.ts +8 -0
  153. package/dist/types/locus-info/types.d.ts +48 -12
  154. package/dist/types/media/MediaConnectionAwaiter.d.ts +20 -2
  155. package/dist/types/media/properties.d.ts +3 -1
  156. package/dist/types/meeting/in-meeting-actions.d.ts +10 -0
  157. package/dist/types/meeting/index.d.ts +196 -15
  158. package/dist/types/meeting/locusMediaRequest.d.ts +12 -0
  159. package/dist/types/meeting/request.d.ts +17 -1
  160. package/dist/types/meeting/request.type.d.ts +5 -0
  161. package/dist/types/meeting/util.d.ts +40 -0
  162. package/dist/types/meeting-info/util.d.ts +1 -0
  163. package/dist/types/meeting-info/utilv2.d.ts +1 -0
  164. package/dist/types/meetings/index.d.ts +34 -20
  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 +2 -0
  168. package/dist/types/member/types.d.ts +5 -4
  169. package/dist/types/member/util.d.ts +14 -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 +10 -0
  173. package/dist/types/multistream/codec/constants.d.ts +7 -0
  174. package/dist/types/multistream/mediaRequestManager.d.ts +20 -26
  175. package/dist/types/multistream/sendSlotManager.d.ts +23 -1
  176. package/dist/types/reachability/clusterReachability.d.ts +33 -6
  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 +4 -0
  181. package/dist/types/recording-controller/util.d.ts +5 -5
  182. package/dist/types/roap/index.d.ts +1 -1
  183. package/dist/types/webinar/utils.d.ts +6 -0
  184. package/dist/webinar/index.js +585 -164
  185. package/dist/webinar/index.js.map +1 -1
  186. package/dist/webinar/utils.js +25 -0
  187. package/dist/webinar/utils.js.map +1 -0
  188. package/package.json +26 -24
  189. package/src/aiEnableRequest/README.md +84 -0
  190. package/src/aiEnableRequest/index.ts +186 -0
  191. package/src/aiEnableRequest/utils.ts +25 -0
  192. package/src/annotation/index.ts +27 -7
  193. package/src/breakouts/breakout.ts +3 -1
  194. package/src/breakouts/index.ts +31 -0
  195. package/src/common/errors/webex-errors.ts +50 -3
  196. package/src/config.ts +7 -2
  197. package/src/constants.ts +49 -3
  198. package/src/controls-options-manager/constants.ts +14 -1
  199. package/src/controls-options-manager/index.ts +87 -28
  200. package/src/controls-options-manager/util.ts +81 -1
  201. package/src/hashTree/constants.ts +26 -0
  202. package/src/hashTree/hashTree.ts +480 -0
  203. package/src/hashTree/hashTreeParser.ts +1911 -29
  204. package/src/hashTree/types.ts +24 -1
  205. package/src/hashTree/utils.ts +98 -0
  206. package/src/index.ts +14 -1
  207. package/src/interceptors/constant.ts +6 -0
  208. package/src/interceptors/dataChannelAuthToken.ts +246 -0
  209. package/src/interceptors/index.ts +2 -1
  210. package/src/interceptors/locusRetry.ts +25 -4
  211. package/src/interceptors/locusRouteToken.ts +22 -5
  212. package/src/interceptors/utils.ts +16 -0
  213. package/src/interpretation/index.ts +29 -11
  214. package/src/interpretation/interpretation.types.ts +11 -0
  215. package/src/locus-info/controlsUtils.ts +20 -1
  216. package/src/locus-info/index.ts +958 -250
  217. package/src/locus-info/infoUtils.ts +41 -6
  218. package/src/locus-info/selfUtils.ts +1 -0
  219. package/src/locus-info/types.ts +51 -12
  220. package/src/media/MediaConnectionAwaiter.ts +62 -5
  221. package/src/media/index.ts +10 -1
  222. package/src/media/properties.ts +4 -1
  223. package/src/meeting/in-meeting-actions.ts +20 -0
  224. package/src/meeting/index.ts +1025 -146
  225. package/src/meeting/locusMediaRequest.ts +106 -6
  226. package/src/meeting/muteState.ts +10 -1
  227. package/src/meeting/request.ts +53 -0
  228. package/src/meeting/request.type.ts +6 -0
  229. package/src/meeting/util.ts +207 -7
  230. package/src/meeting-info/meeting-info-v2.ts +4 -2
  231. package/src/meetings/index.ts +307 -132
  232. package/src/meetings/meetings.types.ts +19 -0
  233. package/src/meetings/request.ts +43 -0
  234. package/src/meetings/util.ts +127 -13
  235. package/src/member/index.ts +20 -0
  236. package/src/member/types.ts +1 -0
  237. package/src/member/util.ts +41 -0
  238. package/src/members/index.ts +70 -7
  239. package/src/members/util.ts +12 -4
  240. package/src/metrics/constants.ts +11 -0
  241. package/src/multistream/codec/constants.ts +58 -0
  242. package/src/multistream/mediaRequestManager.ts +117 -76
  243. package/src/multistream/receiveSlot.ts +18 -0
  244. package/src/multistream/remoteMediaManager.ts +13 -0
  245. package/src/multistream/sendSlotManager.ts +97 -3
  246. package/src/reachability/clusterReachability.ts +156 -29
  247. package/src/reachability/index.ts +62 -17
  248. package/src/reachability/reachability.types.ts +11 -0
  249. package/src/reachability/reachabilityPeerConnection.ts +3 -1
  250. package/src/reachability/util.ts +36 -0
  251. package/src/reactions/reactions.type.ts +4 -0
  252. package/src/reconnection-manager/index.ts +0 -1
  253. package/src/recording-controller/index.ts +1 -2
  254. package/src/webinar/index.ts +448 -11
  255. package/src/webinar/utils.ts +16 -0
  256. package/test/unit/spec/aiEnableRequest/index.ts +1067 -0
  257. package/test/unit/spec/aiEnableRequest/utils.ts +130 -0
  258. package/test/unit/spec/annotation/index.ts +69 -7
  259. package/test/unit/spec/breakouts/breakout.ts +9 -3
  260. package/test/unit/spec/breakouts/index.ts +49 -0
  261. package/test/unit/spec/common/errors/webex-errors.ts +78 -0
  262. package/test/unit/spec/controls-options-manager/index.js +244 -29
  263. package/test/unit/spec/controls-options-manager/util.js +165 -0
  264. package/test/unit/spec/hashTree/hashTree.ts +721 -0
  265. package/test/unit/spec/hashTree/hashTreeParser.ts +5328 -0
  266. package/test/unit/spec/hashTree/utils.ts +264 -0
  267. package/test/unit/spec/interceptors/dataChannelAuthToken.ts +406 -0
  268. package/test/unit/spec/interceptors/locusRetry.ts +205 -4
  269. package/test/unit/spec/interceptors/locusRouteToken.ts +44 -0
  270. package/test/unit/spec/interceptors/utils.ts +75 -0
  271. package/test/unit/spec/interpretation/index.ts +26 -4
  272. package/test/unit/spec/locus-info/controlsUtils.js +222 -52
  273. package/test/unit/spec/locus-info/index.js +2000 -171
  274. package/test/unit/spec/locus-info/infoUtils.js +184 -1
  275. package/test/unit/spec/media/MediaConnectionAwaiter.ts +96 -1
  276. package/test/unit/spec/media/index.ts +92 -0
  277. package/test/unit/spec/media/properties.ts +12 -3
  278. package/test/unit/spec/meeting/in-meeting-actions.ts +12 -2
  279. package/test/unit/spec/meeting/index.js +2925 -209
  280. package/test/unit/spec/meeting/locusMediaRequest.ts +406 -4
  281. package/test/unit/spec/meeting/muteState.js +81 -0
  282. package/test/unit/spec/meeting/request.js +82 -0
  283. package/test/unit/spec/meeting/utils.js +595 -27
  284. package/test/unit/spec/meeting-info/meetinginfov2.js +19 -10
  285. package/test/unit/spec/meetings/index.js +1214 -75
  286. package/test/unit/spec/meetings/request.js +141 -0
  287. package/test/unit/spec/meetings/utils.js +453 -52
  288. package/test/unit/spec/member/index.js +35 -4
  289. package/test/unit/spec/member/util.js +154 -27
  290. package/test/unit/spec/members/index.js +216 -0
  291. package/test/unit/spec/members/request.js +37 -1
  292. package/test/unit/spec/members/utils.js +63 -0
  293. package/test/unit/spec/multistream/mediaRequestManager.ts +503 -122
  294. package/test/unit/spec/multistream/remoteMediaManager.ts +30 -0
  295. package/test/unit/spec/multistream/sendSlotManager.ts +135 -36
  296. package/test/unit/spec/reachability/clusterReachability.ts +125 -1
  297. package/test/unit/spec/reachability/index.ts +154 -49
  298. package/test/unit/spec/reachability/util.ts +31 -0
  299. package/test/unit/spec/reconnection-manager/index.js +4 -8
  300. package/test/unit/spec/recording-controller/index.js +9 -8
  301. package/test/unit/spec/webinar/index.ts +837 -39
  302. package/test/unit/spec/webinar/utils.ts +39 -0
@@ -1,15 +1,33 @@
1
1
  import {Enum} from '../constants';
2
2
 
3
- // todo: Locus docs have now more types like CONTROL_ENTRY, EMBEDDED_APP, FULL_STATE, INFO, MEDIA_SHARE - need to add support for them once Locus implements them
3
+ // todo: Locus docs have now more types like EMBEDDED_APP - need to add support for them once Locus implements them
4
4
  export const ObjectType = {
5
5
  participant: 'participant',
6
6
  self: 'self',
7
7
  locus: 'locus',
8
8
  mediaShare: 'mediashare',
9
+ info: 'info',
10
+ fullState: 'fullstate',
11
+ links: 'links',
12
+ control: 'controlentry',
13
+ metadata: 'metadata',
14
+ embeddedApp: 'embeddedapp',
9
15
  } as const;
10
16
 
11
17
  export type ObjectType = Enum<typeof ObjectType>;
12
18
 
19
+ // mapping from ObjectType to top level LocusDTO keys
20
+ export const ObjectTypeToLocusKeyMap = {
21
+ [ObjectType.links]: 'links',
22
+ [ObjectType.info]: 'info',
23
+ [ObjectType.fullState]: 'fullState',
24
+ [ObjectType.self]: 'self',
25
+ [ObjectType.participant]: 'participants', // note: each object is a single participant in participants array
26
+ [ObjectType.mediaShare]: 'mediaShares', // note: each object is a single mediaShare in mediaShares array
27
+ [ObjectType.control]: 'controls', // note: each object is a single control entry in controls object
28
+ [ObjectType.embeddedApp]: 'embeddedApps', // note: each object is a single embedded app in embeddedApps array
29
+ };
30
+
13
31
  export interface HtMeta {
14
32
  elementId: {
15
33
  type: ObjectType;
@@ -18,3 +36,8 @@ export interface HtMeta {
18
36
  };
19
37
  dataSetNames: string[];
20
38
  }
39
+
40
+ export interface HashTreeObject {
41
+ htMeta: HtMeta;
42
+ data: Record<string, any>;
43
+ }
@@ -0,0 +1,98 @@
1
+ /* eslint-disable import/prefer-default-export */
2
+
3
+ import {ObjectType, HashTreeObject} from './types';
4
+
5
+ /**
6
+ * Checks if the given hash tree object is of type "self"
7
+ * @param {HashTreeObject} object object to check
8
+ * @returns {boolean} True if the object is of type "self", false otherwise
9
+ */
10
+ export function isSelf(object: HashTreeObject) {
11
+ return object.htMeta.elementId.type.toLowerCase() === ObjectType.self;
12
+ }
13
+
14
+ /**
15
+ * Checks if the given hash tree object is of type "Metadata"
16
+ * @param {HashTreeObject} object object to check
17
+ * @returns {boolean} True if the object is of type "Metadata", false otherwise
18
+ */
19
+ export function isMetadata(object: HashTreeObject) {
20
+ return object.htMeta.elementId.type.toLowerCase() === ObjectType.metadata;
21
+ }
22
+
23
+ /**
24
+ * Analyzes given part of Locus DTO recursively and delete any nested objects that have their own htMeta
25
+ *
26
+ * @param {Object} currentLocusPart part of locus DTO to analyze
27
+ * @param {Object} parent parent object
28
+ * @param {string|number} currentKey key of the parent object that currentLocusPart is
29
+ * @returns {void}
30
+ */
31
+ export const deleteNestedObjectsWithHtMeta = (
32
+ currentLocusPart: any,
33
+ parent?: any,
34
+ currentKey?: string | number
35
+ ) => {
36
+ if (typeof currentLocusPart !== 'object' || currentLocusPart === null) {
37
+ return;
38
+ }
39
+
40
+ if (parent && currentKey !== undefined && currentLocusPart.htMeta) {
41
+ if (Array.isArray(parent)) {
42
+ parent.splice(Number(currentKey), 1);
43
+ } else {
44
+ delete parent[currentKey];
45
+ }
46
+
47
+ return;
48
+ }
49
+
50
+ if (Array.isArray(currentLocusPart)) {
51
+ // iterate array in reverse, so that indexes remain valid when deleting elements
52
+ for (let i = currentLocusPart.length - 1; i >= 0; i -= 1) {
53
+ deleteNestedObjectsWithHtMeta(currentLocusPart[i], currentLocusPart, i);
54
+ }
55
+ } else {
56
+ for (const key of Object.keys(currentLocusPart)) {
57
+ if (Object.prototype.hasOwnProperty.call(currentLocusPart, key)) {
58
+ deleteNestedObjectsWithHtMeta(currentLocusPart[key], currentLocusPart, key);
59
+ }
60
+ }
61
+ }
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
@@ -3,7 +3,11 @@ import {registerPlugin} from '@webex/webex-core';
3
3
 
4
4
  import Meetings from './meetings';
5
5
  import config from './config';
6
- import {LocusRetryStatusInterceptor, LocusRouteTokenInterceptor} from './interceptors';
6
+ import {
7
+ LocusRetryStatusInterceptor,
8
+ LocusRouteTokenInterceptor,
9
+ DataChannelAuthTokenInterceptor,
10
+ } from './interceptors';
7
11
  import CaptchaError from './common/errors/captcha-error';
8
12
  import IntentToJoinError from './common/errors/intent-to-join';
9
13
  import PasswordError from './common/errors/password-error';
@@ -25,6 +29,7 @@ registerPlugin('meetings', Meetings, {
25
29
  interceptors: {
26
30
  LocusRetryStatusInterceptor: LocusRetryStatusInterceptor.create,
27
31
  LocusRouteTokenInterceptor: LocusRouteTokenInterceptor.create,
32
+ DataChannelAuthTokenInterceptor: DataChannelAuthTokenInterceptor.create,
28
33
  },
29
34
  });
30
35
 
@@ -60,6 +65,12 @@ export * as REACTIONS from './reactions/reactions';
60
65
  export * as sdkAnnotationTypes from './annotation/annotation.types';
61
66
  export * as MeetingInfoV2 from './meeting-info/meeting-info-v2';
62
67
  export {type Reaction} from './reactions/reactions.type';
68
+ export {SitePreferenceSelectOption} from './meetings/meetings.types';
69
+ export type {
70
+ FetchSitePreferencesMeViaSiteOptions,
71
+ SitePreferencesResponse,
72
+ } from './meetings/meetings.types';
73
+ export type {Interpreter, InterpreterUsingResource} from './interpretation/interpretation.types';
63
74
 
64
75
  export {
65
76
  CaptchaError,
@@ -80,3 +91,5 @@ export {
80
91
  export {RemoteMedia} from './multistream/remoteMedia';
81
92
 
82
93
  export {default as TriggerProxy} from './common/events/trigger-proxy';
94
+
95
+ export {getAIEnablementApprover} from './aiEnableRequest/utils';
@@ -0,0 +1,6 @@
1
+ const DATA_CHANNEL_AUTH_HEADER = 'Data-Channel-Auth-Token';
2
+ const MAX_RETRY = 1;
3
+ const RETRY_INTERVAL = 2000;
4
+ const RETRY_KEY = '_dcRetryKey';
5
+
6
+ export {DATA_CHANNEL_AUTH_HEADER, MAX_RETRY, RETRY_INTERVAL, RETRY_KEY};
@@ -0,0 +1,246 @@
1
+ /*!
2
+ * Copyright (c) 2015-2026 Cisco Systems, Inc. See LICENSE file.
3
+ */
4
+
5
+ import {Interceptor} from '@webex/http-core';
6
+ import LLMChannel from '@webex/internal-plugin-llm';
7
+ import LoggerProxy from '../common/logs/logger-proxy';
8
+ import {DATA_CHANNEL_AUTH_HEADER, MAX_RETRY, RETRY_INTERVAL, RETRY_KEY} from './constant';
9
+ import {isJwtTokenExpired} from './utils';
10
+ import {LLM_DEFAULT_SESSION, LLM_PRACTICE_SESSION, LOCUS_URL} from '../constants';
11
+
12
+ const retryCountMap = new Map();
13
+ interface HttpLikeError extends Error {
14
+ statusCode?: number;
15
+ original?: any;
16
+ }
17
+ /**
18
+ * @class
19
+ */
20
+ export default class DataChannelAuthTokenInterceptor extends Interceptor {
21
+ private _refreshDataChannelToken: (requestUrl?: string) => Promise<string>;
22
+ private _isDataChannelTokenEnabled: () => Promise<boolean>;
23
+ constructor(options) {
24
+ super(options);
25
+
26
+ this._refreshDataChannelToken = options.refreshDataChannelToken;
27
+ this._isDataChannelTokenEnabled = options.isDataChannelTokenEnabled;
28
+ }
29
+
30
+ /**
31
+ * @returns {DataChannelAuthTokenInterceptor}
32
+ */
33
+ static create() {
34
+ // @ts-ignore
35
+ return new DataChannelAuthTokenInterceptor({
36
+ webex: this,
37
+
38
+ isDataChannelTokenEnabled: async () => {
39
+ // @ts-ignore
40
+ return this.internal.llm.isDataChannelTokenEnabled();
41
+ },
42
+
43
+ // Route refresh by request URL in two steps:
44
+ // 1) Match active LLM sessions (supports non-default/multiple sessions)
45
+ // 2) If no session matches, resolve locusUrl and refresh via owning meeting
46
+ // If neither route matches, fall back to the default-session refresh.
47
+ refreshDataChannelToken: async (requestUrl?: string) => {
48
+ let sessionId;
49
+ let meeting;
50
+
51
+ if (typeof requestUrl === 'string') {
52
+ // @ts-ignore
53
+ sessionId = this.internal.llm.getSessionIdByDatachannelUrl?.(requestUrl);
54
+
55
+ if (!sessionId) {
56
+ // @ts-ignore
57
+ const locusUrl = this.internal.llm.getLocusUrlByDatachannelUrl?.(requestUrl);
58
+
59
+ if (locusUrl) {
60
+ // @ts-ignore
61
+ meeting = this.meetings?.getMeetingByType?.(LOCUS_URL, locusUrl);
62
+ }
63
+ }
64
+
65
+ if (!meeting) {
66
+ // Fallback: registerAndConnect() pre-populates datachannelUrl in
67
+ // connections before calling register(), so getSessionIdByDatachannelUrl
68
+ // above should normally resolve. This scan covers any residual gap
69
+ // where connections are not yet populated (e.g. if setRefreshHandler
70
+ // is called on a session that has no connection entry at all).
71
+ // @ts-ignore
72
+ const allMeetings = this.meetings?.getAllMeetings?.() || {};
73
+
74
+ meeting = Object.values(allMeetings).find((activeMeeting: any) => {
75
+ const info = activeMeeting?.locusInfo?.info || {};
76
+
77
+ return (
78
+ (info.practiceSessionDatachannelUrl &&
79
+ LLMChannel.matchesDatachannelRequestUrl(
80
+ requestUrl,
81
+ info.practiceSessionDatachannelUrl
82
+ )) ||
83
+ (info.datachannelUrl &&
84
+ LLMChannel.matchesDatachannelRequestUrl(requestUrl, info.datachannelUrl))
85
+ );
86
+ });
87
+
88
+ if (!sessionId) {
89
+ // @ts-ignore
90
+ const info = meeting?.locusInfo?.info || {};
91
+
92
+ if (
93
+ info.practiceSessionDatachannelUrl &&
94
+ LLMChannel.matchesDatachannelRequestUrl(
95
+ requestUrl,
96
+ info.practiceSessionDatachannelUrl
97
+ )
98
+ ) {
99
+ sessionId = LLM_PRACTICE_SESSION;
100
+ } else if (
101
+ info.datachannelUrl &&
102
+ LLMChannel.matchesDatachannelRequestUrl(requestUrl, info.datachannelUrl)
103
+ ) {
104
+ sessionId = LLM_DEFAULT_SESSION;
105
+ }
106
+ }
107
+ }
108
+ }
109
+
110
+ let result;
111
+ if (meeting) {
112
+ result = await meeting.refreshDataChannelToken();
113
+ } else {
114
+ // @ts-ignore
115
+ result = await this.internal.llm.refreshDataChannelToken(sessionId);
116
+ }
117
+
118
+ if (!result?.body) {
119
+ throw new Error('DataChannel token refresh returned no payload');
120
+ }
121
+ const {datachannelToken, dataChannelTokenType} = result.body;
122
+ const tokenStoreKey = dataChannelTokenType || sessionId;
123
+ const ownerMeetingId =
124
+ // @ts-ignore
125
+ meeting?.id || this.internal.llm.getOwnerMeetingId?.(tokenStoreKey);
126
+ // @ts-ignore
127
+ this.internal.llm.setDatachannelToken(datachannelToken, tokenStoreKey, ownerMeetingId);
128
+
129
+ return datachannelToken;
130
+ },
131
+ });
132
+ }
133
+
134
+ private getRetryKey(options) {
135
+ if (!options[RETRY_KEY]) {
136
+ options[RETRY_KEY] = `${Date.now()}-${Math.random()}`;
137
+ }
138
+
139
+ return options[RETRY_KEY];
140
+ }
141
+
142
+ // Helper function to get header value case insensitively
143
+ private getHeader(headers: Record<string, string>, name: string) {
144
+ const key = Object.keys(headers).find((k) => k.toLowerCase() === name.toLowerCase());
145
+
146
+ return key ? headers[key] : undefined;
147
+ }
148
+
149
+ /**
150
+ * Intercepts outgoing requests and refreshes the Data-Channel-Auth-Token
151
+ * if the current JWT token is expired before the request is sent.
152
+ *
153
+ * @param {Object} options - The original request options.
154
+ * @returns {Promise<Object>} Updated request options with refreshed token if needed.
155
+ */
156
+ async onRequest(options) {
157
+ const token = this.getHeader(options.headers, DATA_CHANNEL_AUTH_HEADER);
158
+ const enabled = await this._isDataChannelTokenEnabled();
159
+
160
+ if (!token || !enabled) {
161
+ return options;
162
+ }
163
+
164
+ if (isJwtTokenExpired(token)) {
165
+ try {
166
+ const newToken = await this._refreshDataChannelToken(options.uri || options.url);
167
+ options.headers[DATA_CHANNEL_AUTH_HEADER] = newToken;
168
+ } catch (e) {
169
+ LoggerProxy.logger.warn(`DataChannelAuthTokenInterceptor: refresh failed: ${e.message}`);
170
+ }
171
+ }
172
+
173
+ return options;
174
+ }
175
+
176
+ /**
177
+ * Intercept responses and, on 401/403 with `Data-Channel-Auth-Token` header,
178
+ * attempt to refresh the data channel token and retry the original request once.
179
+ *
180
+ * @param {Object} options
181
+ * @param {Object} reason
182
+ * @returns {Promise<HttpResponse>}
183
+ */
184
+ async onResponseError(options, reason) {
185
+ const token = this.getHeader(options.headers, DATA_CHANNEL_AUTH_HEADER);
186
+ const enabled = await this._isDataChannelTokenEnabled();
187
+
188
+ if (!token || !enabled) {
189
+ return Promise.reject(reason);
190
+ }
191
+
192
+ if (reason.statusCode !== 401 && reason.statusCode !== 403) {
193
+ return Promise.reject(reason);
194
+ }
195
+
196
+ const key = this.getRetryKey(options);
197
+ const retryCount = retryCountMap.get(key) || 0;
198
+
199
+ if (retryCount >= MAX_RETRY) {
200
+ LoggerProxy.logger.error(`data channel token refresh exceeded max retry (${MAX_RETRY})`);
201
+ retryCountMap.delete(key);
202
+
203
+ return Promise.reject(reason);
204
+ }
205
+
206
+ retryCountMap.set(key, retryCount + 1);
207
+
208
+ return this.refreshTokenAndRetryWithDelay(options);
209
+ }
210
+
211
+ /**
212
+ * Retry the failed data channel request after a delay.
213
+ * Refreshes the Data-Channel-Auth-Token and re-sends the original request.
214
+ *
215
+ * @param {Object} options - Original request options.
216
+ * @returns {Promise<HttpResponse>} - Resolves on successful retry.
217
+ */
218
+ refreshTokenAndRetryWithDelay(options) {
219
+ return new Promise((resolve, reject) => {
220
+ setTimeout(async () => {
221
+ const key = this.getRetryKey(options);
222
+ try {
223
+ const newToken = await this._refreshDataChannelToken(options.uri || options.url);
224
+
225
+ options.headers[DATA_CHANNEL_AUTH_HEADER] = newToken;
226
+
227
+ // @ts-ignore
228
+ const res = await this.webex.request(options);
229
+ retryCountMap.delete(key);
230
+
231
+ resolve(res);
232
+ } catch (e) {
233
+ retryCountMap.delete(key);
234
+
235
+ const msg = e?.message || String(e);
236
+
237
+ const err: HttpLikeError = new Error(`DataChannel token refresh failed: ${msg}`);
238
+ err.statusCode = e?.statusCode;
239
+ err.original = e;
240
+
241
+ reject(err);
242
+ }
243
+ }, RETRY_INTERVAL);
244
+ });
245
+ }
246
+ }
@@ -1,4 +1,5 @@
1
1
  import LocusRetryStatusInterceptor from './locusRetry';
2
2
  import LocusRouteTokenInterceptor from './locusRouteToken';
3
+ import DataChannelAuthTokenInterceptor from './dataChannelAuthToken';
3
4
 
4
- export {LocusRetryStatusInterceptor, LocusRouteTokenInterceptor};
5
+ export {LocusRetryStatusInterceptor, LocusRouteTokenInterceptor, DataChannelAuthTokenInterceptor};
@@ -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;
@@ -3,7 +3,6 @@
3
3
  */
4
4
 
5
5
  import {Interceptor} from '@webex/http-core';
6
- import {has} from 'lodash';
7
6
 
8
7
  const LOCUS_ID_REGEX = /\/locus\/api\/v1\/loci\/([a-f0-9-]{36})/i;
9
8
  const X_CISCO_PART_ROUTE_TOKEN = 'X-Cisco-Part-Route-Token';
@@ -25,16 +24,30 @@ export default class LocusRouteTokenInterceptor extends Interceptor {
25
24
  return url?.match(LOCUS_ID_REGEX)?.[1];
26
25
  }
27
26
 
27
+ getLocusIdByResponseBody(body: any) {
28
+ return body?.locus?.url?.match(LOCUS_ID_REGEX)?.[1];
29
+ }
30
+
31
+ // Helper function to get header value case insensitively
32
+ getHeader(headers: Record<string, string>, name: string) {
33
+ const key = Object.keys(headers).find((k) => k.toLowerCase() === name.toLowerCase());
34
+
35
+ return key ? headers[key] : undefined;
36
+ }
37
+
28
38
  /**
29
39
  * @param {Object} options
30
40
  * @param {HttpResponse} response
31
41
  * @returns {Promise<HttpResponse>}
32
42
  */
33
43
  onResponse(options, response) {
34
- const locusId = this.getLocusIdByRequestUrl(options.uri);
44
+ const locusId =
45
+ this.getLocusIdByResponseBody(response.body) || this.getLocusIdByRequestUrl(options.uri);
35
46
  if (locusId) {
36
- const hasRouteToken = has(response.headers, X_CISCO_PART_ROUTE_TOKEN);
37
- const token = response.headers[X_CISCO_PART_ROUTE_TOKEN];
47
+ const hasRouteToken = Object.keys(response.headers).some(
48
+ (key) => key.toLowerCase() === X_CISCO_PART_ROUTE_TOKEN.toLowerCase()
49
+ );
50
+ const token = this.getHeader(response.headers, X_CISCO_PART_ROUTE_TOKEN);
38
51
  if (hasRouteToken) {
39
52
  this.updateToken(locusId, token);
40
53
  }
@@ -66,7 +79,11 @@ export default class LocusRouteTokenInterceptor extends Interceptor {
66
79
  * @returns {void}
67
80
  */
68
81
  updateToken(locusId, token) {
69
- ROUTE_TOKEN[locusId] = token;
82
+ if (token === 'null' || token === null) {
83
+ delete ROUTE_TOKEN[locusId];
84
+ } else {
85
+ ROUTE_TOKEN[locusId] = token;
86
+ }
70
87
  }
71
88
 
72
89
  /**
@@ -0,0 +1,16 @@
1
+ import * as jose from 'jose';
2
+
3
+ const EXPIRY_BUFFER = 30 * 1000;
4
+
5
+ // eslint-disable-next-line import/prefer-default-export
6
+ export const isJwtTokenExpired = (token: string): boolean => {
7
+ try {
8
+ const payload = jose.decodeJwt(token);
9
+
10
+ if (!payload?.exp) return false;
11
+
12
+ return payload.exp * 1000 < Date.now() + EXPIRY_BUFFER;
13
+ } catch {
14
+ return true;
15
+ }
16
+ };
@@ -3,9 +3,11 @@
3
3
  */
4
4
  import {WebexPlugin} from '@webex/webex-core';
5
5
  import LoggerProxy from '../common/logs/logger-proxy';
6
- import {HTTP_VERBS, INTERPRETATION, MEETINGS} from '../constants';
6
+ import {HTTP_VERBS, INTERPRETATION, LOCUSEVENT, MEETINGS} from '../constants';
7
+ import MeetingUtil from '../meeting/util';
7
8
 
8
9
  import SILanguageCollection from './collection';
10
+ import {Interpreter} from './interpretation.types';
9
11
 
10
12
  /**
11
13
  * @class SimultaneousInterpretation
@@ -182,7 +184,9 @@ const SimultaneousInterpretation = WebexPlugin.extend({
182
184
  * @param {Array} interpreters
183
185
  * @returns {Promise}
184
186
  */
185
- updateInterpreters(interpreters) {
187
+ updateInterpreters(interpreters: Interpreter[]) {
188
+ const meeting = this.webex.meetings.meetingCollection.getByKey('locusUrl', this.locusUrl);
189
+
186
190
  return this.request({
187
191
  method: HTTP_VERBS.PATCH,
188
192
  uri: `${this.locusUrl}/controls`,
@@ -191,10 +195,16 @@ const SimultaneousInterpretation = WebexPlugin.extend({
191
195
  interpreters,
192
196
  },
193
197
  },
194
- }).catch((error) => {
195
- LoggerProxy.logger.error('Meeting:interpretation#updateInterpreters failed', error);
196
- throw error;
197
- });
198
+ })
199
+ .then((response) => {
200
+ MeetingUtil.updateLocusFromApiResponse(meeting, response);
201
+
202
+ return response;
203
+ })
204
+ .catch((error) => {
205
+ LoggerProxy.logger.error('Meeting:interpretation#updateInterpreters failed', error);
206
+ throw error;
207
+ });
198
208
  },
199
209
  /**
200
210
  * Change direction of interpretation for an interpreter participant
@@ -209,6 +219,8 @@ const SimultaneousInterpretation = WebexPlugin.extend({
209
219
  return Promise.reject(new Error('Missing self participant id'));
210
220
  }
211
221
 
222
+ const meeting = this.webex.meetings.meetingCollection.getByKey('locusUrl', this.locusUrl);
223
+
212
224
  return this.request({
213
225
  method: HTTP_VERBS.PATCH,
214
226
  uri: `${this.locusUrl}/participant/${this.selfParticipantId}/controls`,
@@ -220,17 +232,23 @@ const SimultaneousInterpretation = WebexPlugin.extend({
220
232
  order: this.order,
221
233
  },
222
234
  },
223
- }).catch((error) => {
224
- LoggerProxy.logger.error('Meeting:interpretation#changeDirection failed', error);
225
- throw error;
226
- });
235
+ })
236
+ .then((response) => {
237
+ MeetingUtil.updateLocusFromApiResponse(meeting, response);
238
+
239
+ return response;
240
+ })
241
+ .catch((error) => {
242
+ LoggerProxy.logger.error('Meeting:interpretation#changeDirection failed', error);
243
+ throw error;
244
+ });
227
245
  },
228
246
  /**
229
247
  * Sets up a listener for handoff requests from mercury
230
248
  * @returns {void}
231
249
  */
232
250
  listenToHandoffRequests() {
233
- this.listenTo(this.webex.internal.mercury, 'event:locus.approval_request', (event) => {
251
+ this.listenTo(this.webex.internal.mercury, `event:${LOCUSEVENT.APPROVAL_REQUEST}`, (event) => {
234
252
  if (event?.data?.approval?.resourceType === INTERPRETATION.RESOURCE_TYPE) {
235
253
  const {receivers, initiator, actionType, url} = event.data.approval;
236
254
  const receiverId = receivers?.[0]?.participantId;
@@ -0,0 +1,11 @@
1
+ export type InterpreterUsingResource = {
2
+ id: string;
3
+ email?: string;
4
+ };
5
+
6
+ export type Interpreter = {
7
+ order: number;
8
+ sourceLanguage: string;
9
+ targetLanguage: string;
10
+ usingResource: InterpreterUsingResource;
11
+ };