matrix-js-sdk 41.8.0 → 41.9.0

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 (458) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +1 -1
  3. package/lib/@types/AESEncryptedSecretStoragePayload.js +3 -1
  4. package/lib/@types/IIdentityServerProvider.js +3 -1
  5. package/lib/@types/PushRules.js +7 -7
  6. package/lib/@types/PushRules.js.map +1 -1
  7. package/lib/@types/auth.js +4 -4
  8. package/lib/@types/auth.js.map +1 -1
  9. package/lib/@types/beacon.js +2 -2
  10. package/lib/@types/beacon.js.map +1 -1
  11. package/lib/@types/common.js +3 -1
  12. package/lib/@types/crypto.js +3 -1
  13. package/lib/@types/event.js +20 -20
  14. package/lib/@types/event.js.map +1 -1
  15. package/lib/@types/events.js +3 -1
  16. package/lib/@types/extensible_events.js +6 -6
  17. package/lib/@types/extensible_events.js.map +1 -1
  18. package/lib/@types/global.d.js.map +1 -1
  19. package/lib/@types/json.js +3 -1
  20. package/lib/@types/local_notifications.js +3 -1
  21. package/lib/@types/location.js +4 -4
  22. package/lib/@types/location.js.map +1 -1
  23. package/lib/@types/matrix-sdk-crypto-wasm.d.js +3 -1
  24. package/lib/@types/media.js +3 -1
  25. package/lib/@types/membership.js +1 -1
  26. package/lib/@types/membership.js.map +1 -1
  27. package/lib/@types/partials.js +6 -6
  28. package/lib/@types/partials.js.map +1 -1
  29. package/lib/@types/polls.js +5 -5
  30. package/lib/@types/polls.js.map +1 -1
  31. package/lib/@types/read_receipts.js +2 -2
  32. package/lib/@types/read_receipts.js.map +1 -1
  33. package/lib/@types/registration.js +3 -1
  34. package/lib/@types/requests.js +1 -1
  35. package/lib/@types/requests.js.map +1 -1
  36. package/lib/@types/retention.js +1 -1
  37. package/lib/@types/retention.js.map +1 -1
  38. package/lib/@types/search.js +1 -1
  39. package/lib/@types/search.js.map +1 -1
  40. package/lib/@types/signed.js +3 -1
  41. package/lib/@types/spaces.js +3 -1
  42. package/lib/@types/state_events.js +3 -1
  43. package/lib/@types/synapse.js +3 -1
  44. package/lib/@types/sync.js +1 -1
  45. package/lib/@types/sync.js.map +1 -1
  46. package/lib/@types/threepids.js +1 -1
  47. package/lib/@types/threepids.js.map +1 -1
  48. package/lib/@types/topic.js +1 -1
  49. package/lib/@types/topic.js.map +1 -1
  50. package/lib/@types/uia.js +3 -1
  51. package/lib/NamespacedValue.js +8 -8
  52. package/lib/NamespacedValue.js.map +1 -1
  53. package/lib/ReEmitter.js +9 -16
  54. package/lib/ReEmitter.js.map +1 -1
  55. package/lib/ToDeviceMessageQueue.js +49 -57
  56. package/lib/ToDeviceMessageQueue.js.map +1 -1
  57. package/lib/autodiscovery.js +232 -247
  58. package/lib/autodiscovery.js.map +1 -1
  59. package/lib/base64.js +1 -1
  60. package/lib/base64.js.map +1 -1
  61. package/lib/browser-index.d.ts +2 -2
  62. package/lib/browser-index.d.ts.map +1 -1
  63. package/lib/browser-index.js +5 -5
  64. package/lib/browser-index.js.map +1 -1
  65. package/lib/capabilityPoller.js +19 -22
  66. package/lib/capabilityPoller.js.map +1 -1
  67. package/lib/client.d.ts +2 -8
  68. package/lib/client.d.ts.map +1 -1
  69. package/lib/client.js +2043 -2487
  70. package/lib/client.js.map +1 -1
  71. package/lib/common-crypto/CryptoBackend.js +2 -2
  72. package/lib/common-crypto/CryptoBackend.js.map +1 -1
  73. package/lib/common-crypto/key-passphrase.js.map +1 -1
  74. package/lib/content-helpers.js +43 -48
  75. package/lib/content-helpers.js.map +1 -1
  76. package/lib/content-repo.js +14 -24
  77. package/lib/content-repo.js.map +1 -1
  78. package/lib/crypto/store/base.js +6 -6
  79. package/lib/crypto/store/base.js.map +1 -1
  80. package/lib/crypto/store/indexeddb-crypto-store-backend.js +190 -238
  81. package/lib/crypto/store/indexeddb-crypto-store-backend.js.map +1 -1
  82. package/lib/crypto/store/indexeddb-crypto-store.js +25 -30
  83. package/lib/crypto/store/indexeddb-crypto-store.js.map +1 -1
  84. package/lib/crypto/store/localStorage-crypto-store.js +113 -145
  85. package/lib/crypto/store/localStorage-crypto-store.js.map +1 -1
  86. package/lib/crypto/store/memory-crypto-store.js +74 -105
  87. package/lib/crypto/store/memory-crypto-store.js.map +1 -1
  88. package/lib/crypto-api/CryptoEvent.js +1 -1
  89. package/lib/crypto-api/CryptoEvent.js.map +1 -1
  90. package/lib/crypto-api/CryptoEventHandlerMap.js +3 -1
  91. package/lib/crypto-api/index.d.ts +15 -6
  92. package/lib/crypto-api/index.d.ts.map +1 -1
  93. package/lib/crypto-api/index.js +22 -22
  94. package/lib/crypto-api/index.js.map +1 -1
  95. package/lib/crypto-api/key-passphrase.js +15 -23
  96. package/lib/crypto-api/key-passphrase.js.map +1 -1
  97. package/lib/crypto-api/keybackup.js +3 -1
  98. package/lib/crypto-api/recovery-key.js +11 -12
  99. package/lib/crypto-api/recovery-key.js.map +1 -1
  100. package/lib/crypto-api/verification.js +3 -3
  101. package/lib/crypto-api/verification.js.map +1 -1
  102. package/lib/digest.js +7 -14
  103. package/lib/digest.js.map +1 -1
  104. package/lib/embedded.d.ts.map +1 -1
  105. package/lib/embedded.js +380 -505
  106. package/lib/embedded.js.map +1 -1
  107. package/lib/errors.js +2 -2
  108. package/lib/errors.js.map +1 -1
  109. package/lib/event-mapper.js +10 -12
  110. package/lib/event-mapper.js.map +1 -1
  111. package/lib/extensible_events_v1/ExtensibleEvent.js.map +1 -1
  112. package/lib/extensible_events_v1/InvalidEventError.js.map +1 -1
  113. package/lib/extensible_events_v1/MessageEvent.js +11 -13
  114. package/lib/extensible_events_v1/MessageEvent.js.map +1 -1
  115. package/lib/extensible_events_v1/PollEndEvent.js +3 -4
  116. package/lib/extensible_events_v1/PollEndEvent.js.map +1 -1
  117. package/lib/extensible_events_v1/PollResponseEvent.js +5 -6
  118. package/lib/extensible_events_v1/PollResponseEvent.js.map +1 -1
  119. package/lib/extensible_events_v1/PollStartEvent.js +8 -10
  120. package/lib/extensible_events_v1/PollStartEvent.js.map +1 -1
  121. package/lib/extensible_events_v1/utilities.js.map +1 -1
  122. package/lib/feature.js +18 -31
  123. package/lib/feature.js.map +1 -1
  124. package/lib/filter-component.d.ts.map +1 -1
  125. package/lib/filter-component.js +20 -26
  126. package/lib/filter-component.js.map +1 -1
  127. package/lib/filter.js +14 -17
  128. package/lib/filter.js.map +1 -1
  129. package/lib/http-api/errors.js +28 -43
  130. package/lib/http-api/errors.js.map +1 -1
  131. package/lib/http-api/fetch.js +141 -159
  132. package/lib/http-api/fetch.js.map +1 -1
  133. package/lib/http-api/index.js +17 -20
  134. package/lib/http-api/index.js.map +1 -1
  135. package/lib/http-api/interface.js +1 -1
  136. package/lib/http-api/interface.js.map +1 -1
  137. package/lib/http-api/method.js +1 -1
  138. package/lib/http-api/method.js.map +1 -1
  139. package/lib/http-api/prefix.js +3 -3
  140. package/lib/http-api/prefix.js.map +1 -1
  141. package/lib/http-api/refresh.js +74 -94
  142. package/lib/http-api/refresh.js.map +1 -1
  143. package/lib/http-api/utils.d.ts +1 -1
  144. package/lib/http-api/utils.d.ts.map +1 -1
  145. package/lib/http-api/utils.js +34 -42
  146. package/lib/http-api/utils.js.map +1 -1
  147. package/lib/index.js.map +1 -1
  148. package/lib/indexeddb-helpers.js +3 -3
  149. package/lib/indexeddb-helpers.js.map +1 -1
  150. package/lib/indexeddb-worker.js.map +1 -1
  151. package/lib/interactive-auth.d.ts +5 -5
  152. package/lib/interactive-auth.d.ts.map +1 -1
  153. package/lib/interactive-auth.js +172 -204
  154. package/lib/interactive-auth.js.map +1 -1
  155. package/lib/logger.js +21 -57
  156. package/lib/logger.js.map +1 -1
  157. package/lib/matrix.js +7 -11
  158. package/lib/matrix.js.map +1 -1
  159. package/lib/matrixrtc/CallMembership.js +80 -74
  160. package/lib/matrixrtc/CallMembership.js.map +1 -1
  161. package/lib/matrixrtc/EncryptionManager.js +1 -1
  162. package/lib/matrixrtc/EncryptionManager.js.map +1 -1
  163. package/lib/matrixrtc/IKeyTransport.js +1 -1
  164. package/lib/matrixrtc/IKeyTransport.js.map +1 -1
  165. package/lib/matrixrtc/IMembershipManager.js +1 -1
  166. package/lib/matrixrtc/IMembershipManager.js.map +1 -1
  167. package/lib/matrixrtc/LivekitTransport.d.ts +1 -1
  168. package/lib/matrixrtc/LivekitTransport.js +4 -4
  169. package/lib/matrixrtc/LivekitTransport.js.map +1 -1
  170. package/lib/matrixrtc/MatrixRTCSession.js +137 -187
  171. package/lib/matrixrtc/MatrixRTCSession.js.map +1 -1
  172. package/lib/matrixrtc/MatrixRTCSessionManager.js +36 -41
  173. package/lib/matrixrtc/MatrixRTCSessionManager.js.map +1 -1
  174. package/lib/matrixrtc/MembershipManager.js +332 -378
  175. package/lib/matrixrtc/MembershipManager.js.map +1 -1
  176. package/lib/matrixrtc/MembershipManagerActionScheduler.js +54 -63
  177. package/lib/matrixrtc/MembershipManagerActionScheduler.js.map +1 -1
  178. package/lib/matrixrtc/RTCEncryptionManager.js +119 -143
  179. package/lib/matrixrtc/RTCEncryptionManager.js.map +1 -1
  180. package/lib/matrixrtc/ToDeviceKeyTransport.js +53 -58
  181. package/lib/matrixrtc/ToDeviceKeyTransport.js.map +1 -1
  182. package/lib/matrixrtc/index.js.map +1 -1
  183. package/lib/matrixrtc/membershipData/common.js +1 -1
  184. package/lib/matrixrtc/membershipData/common.js.map +1 -1
  185. package/lib/matrixrtc/membershipData/index.js.map +1 -1
  186. package/lib/matrixrtc/membershipData/rtc.js +15 -23
  187. package/lib/matrixrtc/membershipData/rtc.js.map +1 -1
  188. package/lib/matrixrtc/membershipData/session.js +4 -5
  189. package/lib/matrixrtc/membershipData/session.js.map +1 -1
  190. package/lib/matrixrtc/types.js +4 -6
  191. package/lib/matrixrtc/types.js.map +1 -1
  192. package/lib/matrixrtc/utils.js +4 -11
  193. package/lib/matrixrtc/utils.js.map +1 -1
  194. package/lib/models/MSC3089Branch.js +91 -116
  195. package/lib/models/MSC3089Branch.js.map +1 -1
  196. package/lib/models/MSC3089TreeSpace.js +209 -245
  197. package/lib/models/MSC3089TreeSpace.js.map +1 -1
  198. package/lib/models/ToDeviceMessage.js +3 -1
  199. package/lib/models/beacon.js +14 -13
  200. package/lib/models/beacon.js.map +1 -1
  201. package/lib/models/compare-event-ordering.js +13 -13
  202. package/lib/models/compare-event-ordering.js.map +1 -1
  203. package/lib/models/device.js +3 -3
  204. package/lib/models/device.js.map +1 -1
  205. package/lib/models/event-context.js +5 -8
  206. package/lib/models/event-context.js.map +1 -1
  207. package/lib/models/event-status.js +1 -1
  208. package/lib/models/event-status.js.map +1 -1
  209. package/lib/models/event-timeline-set.js +88 -94
  210. package/lib/models/event-timeline-set.js.map +1 -1
  211. package/lib/models/event-timeline.js +28 -30
  212. package/lib/models/event-timeline.js.map +1 -1
  213. package/lib/models/event.js +182 -226
  214. package/lib/models/event.js.map +1 -1
  215. package/lib/models/invites-ignorer-types.js +4 -4
  216. package/lib/models/invites-ignorer-types.js.map +1 -1
  217. package/lib/models/invites-ignorer.js +159 -179
  218. package/lib/models/invites-ignorer.js.map +1 -1
  219. package/lib/models/poll.js +71 -81
  220. package/lib/models/poll.js.map +1 -1
  221. package/lib/models/profile-keys.js +2 -2
  222. package/lib/models/profile-keys.js.map +1 -1
  223. package/lib/models/read-receipt.js +40 -56
  224. package/lib/models/read-receipt.js.map +1 -1
  225. package/lib/models/related-relations.js.map +1 -1
  226. package/lib/models/relations-container.js +22 -23
  227. package/lib/models/relations-container.js.map +1 -1
  228. package/lib/models/relations.js +133 -159
  229. package/lib/models/relations.js.map +1 -1
  230. package/lib/models/room-member.js +24 -29
  231. package/lib/models/room-member.js.map +1 -1
  232. package/lib/models/room-receipts.js +29 -43
  233. package/lib/models/room-receipts.js.map +1 -1
  234. package/lib/models/room-retention.js +74 -83
  235. package/lib/models/room-retention.js.map +1 -1
  236. package/lib/models/room-state.js +143 -172
  237. package/lib/models/room-state.js.map +1 -1
  238. package/lib/models/room-sticky-events.d.ts +1 -0
  239. package/lib/models/room-sticky-events.d.ts.map +1 -1
  240. package/lib/models/room-sticky-events.js +45 -65
  241. package/lib/models/room-sticky-events.js.map +1 -1
  242. package/lib/models/room-summary.js.map +1 -1
  243. package/lib/models/room.d.ts.map +1 -1
  244. package/lib/models/room.js +765 -909
  245. package/lib/models/room.js.map +1 -1
  246. package/lib/models/search-result.js +5 -5
  247. package/lib/models/search-result.js.map +1 -1
  248. package/lib/models/thread.js +225 -285
  249. package/lib/models/thread.js.map +1 -1
  250. package/lib/models/typed-event-emitter.js +7 -18
  251. package/lib/models/typed-event-emitter.js.map +1 -1
  252. package/lib/models/user.js +8 -8
  253. package/lib/models/user.js.map +1 -1
  254. package/lib/oidc/authorize.js +208 -241
  255. package/lib/oidc/authorize.js.map +1 -1
  256. package/lib/oidc/discovery.js +23 -36
  257. package/lib/oidc/discovery.js.map +1 -1
  258. package/lib/oidc/error.js +1 -1
  259. package/lib/oidc/error.js.map +1 -1
  260. package/lib/oidc/index.js +1 -0
  261. package/lib/oidc/index.js.map +1 -1
  262. package/lib/oidc/register.js +60 -66
  263. package/lib/oidc/register.js.map +1 -1
  264. package/lib/oidc/tokenRefresher.js +77 -91
  265. package/lib/oidc/tokenRefresher.js.map +1 -1
  266. package/lib/oidc/validate.js +18 -18
  267. package/lib/oidc/validate.js.map +1 -1
  268. package/lib/pushprocessor.js +71 -82
  269. package/lib/pushprocessor.js.map +1 -1
  270. package/lib/randomstring.js +9 -9
  271. package/lib/randomstring.js.map +1 -1
  272. package/lib/realtime-callbacks.js +25 -28
  273. package/lib/realtime-callbacks.js.map +1 -1
  274. package/lib/receipt-accumulator.d.ts +2 -0
  275. package/lib/receipt-accumulator.d.ts.map +1 -1
  276. package/lib/receipt-accumulator.js +14 -22
  277. package/lib/receipt-accumulator.js.map +1 -1
  278. package/lib/rendezvous/MSC4108SignInWithQR.js +271 -302
  279. package/lib/rendezvous/MSC4108SignInWithQR.js.map +1 -1
  280. package/lib/rendezvous/RendezvousChannel.js +3 -1
  281. package/lib/rendezvous/RendezvousCode.js +3 -1
  282. package/lib/rendezvous/RendezvousError.js.map +1 -1
  283. package/lib/rendezvous/RendezvousFailureReason.js +2 -2
  284. package/lib/rendezvous/RendezvousFailureReason.js.map +1 -1
  285. package/lib/rendezvous/RendezvousIntent.js +1 -1
  286. package/lib/rendezvous/RendezvousIntent.js.map +1 -1
  287. package/lib/rendezvous/RendezvousTransport.js +3 -1
  288. package/lib/rendezvous/channels/MSC4108SecureChannel.js +123 -147
  289. package/lib/rendezvous/channels/MSC4108SecureChannel.js.map +1 -1
  290. package/lib/rendezvous/index.js +44 -69
  291. package/lib/rendezvous/index.js.map +1 -1
  292. package/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts +1 -1
  293. package/lib/rendezvous/transports/MSC4108RendezvousSession.js +134 -152
  294. package/lib/rendezvous/transports/MSC4108RendezvousSession.js.map +1 -1
  295. package/lib/retentionPolicy.js +6 -9
  296. package/lib/retentionPolicy.js.map +1 -1
  297. package/lib/room-hierarchy.js +52 -60
  298. package/lib/room-hierarchy.js.map +1 -1
  299. package/lib/rust-crypto/CrossSigningIdentity.js +94 -104
  300. package/lib/rust-crypto/CrossSigningIdentity.js.map +1 -1
  301. package/lib/rust-crypto/DehydratedDeviceManager.js +157 -190
  302. package/lib/rust-crypto/DehydratedDeviceManager.js.map +1 -1
  303. package/lib/rust-crypto/KeyClaimManager.js +18 -22
  304. package/lib/rust-crypto/KeyClaimManager.js.map +1 -1
  305. package/lib/rust-crypto/OutgoingRequestProcessor.js +109 -139
  306. package/lib/rust-crypto/OutgoingRequestProcessor.js.map +1 -1
  307. package/lib/rust-crypto/OutgoingRequestsManager.js +66 -80
  308. package/lib/rust-crypto/OutgoingRequestsManager.js.map +1 -1
  309. package/lib/rust-crypto/PerSessionKeyBackupDownloader.d.ts +1 -1
  310. package/lib/rust-crypto/PerSessionKeyBackupDownloader.js +196 -224
  311. package/lib/rust-crypto/PerSessionKeyBackupDownloader.js.map +1 -1
  312. package/lib/rust-crypto/RoomEncryptor.js +127 -143
  313. package/lib/rust-crypto/RoomEncryptor.js.map +1 -1
  314. package/lib/rust-crypto/backup.js +453 -549
  315. package/lib/rust-crypto/backup.js.map +1 -1
  316. package/lib/rust-crypto/constants.js +1 -1
  317. package/lib/rust-crypto/constants.js.map +1 -1
  318. package/lib/rust-crypto/device-converter.js +15 -28
  319. package/lib/rust-crypto/device-converter.js.map +1 -1
  320. package/lib/rust-crypto/index.js +103 -116
  321. package/lib/rust-crypto/index.js.map +1 -1
  322. package/lib/rust-crypto/libolm_migration.js +303 -365
  323. package/lib/rust-crypto/libolm_migration.js.map +1 -1
  324. package/lib/rust-crypto/rust-crypto.d.ts +5 -1
  325. package/lib/rust-crypto/rust-crypto.d.ts.map +1 -1
  326. package/lib/rust-crypto/rust-crypto.js +1067 -1332
  327. package/lib/rust-crypto/rust-crypto.js.map +1 -1
  328. package/lib/rust-crypto/secret-storage.js +12 -25
  329. package/lib/rust-crypto/secret-storage.js.map +1 -1
  330. package/lib/rust-crypto/verification.js +137 -189
  331. package/lib/rust-crypto/verification.js.map +1 -1
  332. package/lib/scheduler.js +44 -19
  333. package/lib/scheduler.js.map +1 -1
  334. package/lib/secret-storage.js +179 -213
  335. package/lib/secret-storage.js.map +1 -1
  336. package/lib/serverCapabilities.js +6 -9
  337. package/lib/serverCapabilities.js.map +1 -1
  338. package/lib/service-types.js +1 -1
  339. package/lib/service-types.js.map +1 -1
  340. package/lib/sliding-sync-sdk.d.ts.map +1 -1
  341. package/lib/sliding-sync-sdk.js +368 -424
  342. package/lib/sliding-sync-sdk.js.map +1 -1
  343. package/lib/sliding-sync.js +135 -171
  344. package/lib/sliding-sync.js.map +1 -1
  345. package/lib/store/index.js +3 -1
  346. package/lib/store/indexeddb-backend.js +3 -1
  347. package/lib/store/indexeddb-local-backend.js +194 -253
  348. package/lib/store/indexeddb-local-backend.js.map +1 -1
  349. package/lib/store/indexeddb-remote-backend.js +33 -63
  350. package/lib/store/indexeddb-remote-backend.js.map +1 -1
  351. package/lib/store/indexeddb-store-worker.js +22 -23
  352. package/lib/store/indexeddb-store-worker.js.map +1 -1
  353. package/lib/store/indexeddb.js +44 -71
  354. package/lib/store/indexeddb.js.map +1 -1
  355. package/lib/store/local-storage-events-emitter.js +2 -2
  356. package/lib/store/local-storage-events-emitter.js.map +1 -1
  357. package/lib/store/memory.js +34 -57
  358. package/lib/store/memory.js.map +1 -1
  359. package/lib/store/stub.js +22 -35
  360. package/lib/store/stub.js.map +1 -1
  361. package/lib/sync-accumulator.js +54 -66
  362. package/lib/sync-accumulator.js.map +1 -1
  363. package/lib/sync.d.ts.map +1 -1
  364. package/lib/sync.js +905 -998
  365. package/lib/sync.js.map +1 -1
  366. package/lib/testing.js +63 -105
  367. package/lib/testing.js.map +1 -1
  368. package/lib/thread-utils.js +1 -4
  369. package/lib/thread-utils.js.map +1 -1
  370. package/lib/timeline-window.js +89 -102
  371. package/lib/timeline-window.js.map +1 -1
  372. package/lib/types.js +1 -1
  373. package/lib/types.js.map +1 -1
  374. package/lib/utils/decryptAESSecretStorageItem.js +14 -25
  375. package/lib/utils/decryptAESSecretStorageItem.js.map +1 -1
  376. package/lib/utils/encryptAESSecretStorageItem.js +27 -38
  377. package/lib/utils/encryptAESSecretStorageItem.js.map +1 -1
  378. package/lib/utils/internal/deriveKeys.js +25 -32
  379. package/lib/utils/internal/deriveKeys.js.map +1 -1
  380. package/lib/utils/roomVersion.js +1 -1
  381. package/lib/utils/roomVersion.js.map +1 -1
  382. package/lib/utils.js +83 -135
  383. package/lib/utils.js.map +1 -1
  384. package/lib/version-support.js +3 -3
  385. package/lib/version-support.js.map +1 -1
  386. package/lib/webrtc/audioContext.js +5 -6
  387. package/lib/webrtc/audioContext.js.map +1 -1
  388. package/lib/webrtc/call.js +1081 -1250
  389. package/lib/webrtc/call.js.map +1 -1
  390. package/lib/webrtc/callEventHandler.js +202 -214
  391. package/lib/webrtc/callEventHandler.js.map +1 -1
  392. package/lib/webrtc/callEventTypes.js +2 -2
  393. package/lib/webrtc/callEventTypes.js.map +1 -1
  394. package/lib/webrtc/callFeed.js +18 -20
  395. package/lib/webrtc/callFeed.js.map +1 -1
  396. package/lib/webrtc/groupCall.js +513 -602
  397. package/lib/webrtc/groupCall.js.map +1 -1
  398. package/lib/webrtc/groupCallEventHandler.js +59 -62
  399. package/lib/webrtc/groupCallEventHandler.js.map +1 -1
  400. package/lib/webrtc/mediaHandler.js +198 -232
  401. package/lib/webrtc/mediaHandler.js.map +1 -1
  402. package/lib/webrtc/stats/callFeedStatsReporter.js +16 -20
  403. package/lib/webrtc/stats/callFeedStatsReporter.js.map +1 -1
  404. package/lib/webrtc/stats/callStatsReportGatherer.js +67 -75
  405. package/lib/webrtc/stats/callStatsReportGatherer.js.map +1 -1
  406. package/lib/webrtc/stats/callStatsReportSummary.js +3 -1
  407. package/lib/webrtc/stats/connectionStats.js.map +1 -1
  408. package/lib/webrtc/stats/connectionStatsBuilder.js +2 -2
  409. package/lib/webrtc/stats/connectionStatsBuilder.js.map +1 -1
  410. package/lib/webrtc/stats/connectionStatsReportBuilder.js +20 -24
  411. package/lib/webrtc/stats/connectionStatsReportBuilder.js.map +1 -1
  412. package/lib/webrtc/stats/groupCallStats.js +6 -8
  413. package/lib/webrtc/stats/groupCallStats.js.map +1 -1
  414. package/lib/webrtc/stats/media/mediaSsrcHandler.js +7 -8
  415. package/lib/webrtc/stats/media/mediaSsrcHandler.js.map +1 -1
  416. package/lib/webrtc/stats/media/mediaTrackHandler.js +7 -9
  417. package/lib/webrtc/stats/media/mediaTrackHandler.js.map +1 -1
  418. package/lib/webrtc/stats/media/mediaTrackStats.js +3 -3
  419. package/lib/webrtc/stats/media/mediaTrackStats.js.map +1 -1
  420. package/lib/webrtc/stats/media/mediaTrackStatsHandler.js +7 -7
  421. package/lib/webrtc/stats/media/mediaTrackStatsHandler.js.map +1 -1
  422. package/lib/webrtc/stats/statsReport.js +1 -1
  423. package/lib/webrtc/stats/statsReport.js.map +1 -1
  424. package/lib/webrtc/stats/statsReportEmitter.js.map +1 -1
  425. package/lib/webrtc/stats/summaryStatsReportGatherer.js +14 -14
  426. package/lib/webrtc/stats/summaryStatsReportGatherer.js.map +1 -1
  427. package/lib/webrtc/stats/trackStatsBuilder.js +32 -34
  428. package/lib/webrtc/stats/trackStatsBuilder.js.map +1 -1
  429. package/lib/webrtc/stats/transportStats.js +3 -1
  430. package/lib/webrtc/stats/transportStatsBuilder.js +9 -9
  431. package/lib/webrtc/stats/transportStatsBuilder.js.map +1 -1
  432. package/lib/webrtc/stats/valueFormatter.js +1 -1
  433. package/lib/webrtc/stats/valueFormatter.js.map +1 -1
  434. package/package.json +18 -33
  435. package/src/@types/global.d.ts +2 -2
  436. package/src/ToDeviceMessageQueue.ts +2 -2
  437. package/src/browser-index.ts +4 -4
  438. package/src/client.ts +15 -20
  439. package/src/crypto-api/index.ts +17 -6
  440. package/src/embedded.ts +4 -6
  441. package/src/filter-component.ts +1 -0
  442. package/src/http-api/utils.ts +1 -1
  443. package/src/interactive-auth.ts +11 -5
  444. package/src/matrixrtc/LivekitTransport.ts +1 -1
  445. package/src/matrixrtc/MatrixRTCSession.ts +1 -1
  446. package/src/models/MSC3089Branch.ts +1 -1
  447. package/src/models/room-sticky-events.ts +1 -0
  448. package/src/models/room.ts +9 -11
  449. package/src/receipt-accumulator.ts +2 -0
  450. package/src/rendezvous/index.ts +1 -1
  451. package/src/rendezvous/transports/MSC4108RendezvousSession.ts +2 -2
  452. package/src/rust-crypto/PerSessionKeyBackupDownloader.ts +1 -1
  453. package/src/rust-crypto/index.ts +6 -6
  454. package/src/rust-crypto/rust-crypto.ts +31 -7
  455. package/src/rust-crypto/verification.ts +1 -1
  456. package/src/sliding-sync-sdk.ts +5 -7
  457. package/src/store/indexeddb-local-backend.ts +3 -3
  458. package/src/sync.ts +6 -8
@@ -1,4 +1,3 @@
1
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
2
  /*
4
3
  Copyright 2025 The Matrix.org Foundation C.I.C.
@@ -35,14 +34,10 @@ export class NotSupportedError extends Error {
35
34
  */
36
35
  export class ToDeviceKeyTransport extends TypedEventEmitter {
37
36
  setParentLogger(parentLogger) {
38
- this.logger = parentLogger.getChild("[ToDeviceKeyTransport]");
37
+ this.logger = parentLogger.getChild(`[ToDeviceKeyTransport]`);
39
38
  }
40
39
  constructor(membership, roomId, client, statistics, parentLogger) {
41
40
  super();
42
- this.membership = membership;
43
- this.roomId = roomId;
44
- this.client = client;
45
- this.statistics = statistics;
46
41
  _defineProperty(this, "logger", rootLogger);
47
42
  _defineProperty(this, "onToDeviceEvent", event => {
48
43
  if (event.getType() !== EventType.CallEncryptionKeysPrefix) {
@@ -58,12 +53,16 @@ export class ToDeviceKeyTransport extends TypedEventEmitter {
58
53
  // return;
59
54
  // }
60
55
 
61
- var content = this.getValidEventContent(event);
56
+ const content = this.getValidEventContent(event);
62
57
  if (!content) return;
63
58
  if (!event.getSender()) return;
64
59
  this.receiveCallKeyEvent(event.getSender(), content);
65
60
  });
66
- this.setParentLogger(parentLogger !== null && parentLogger !== void 0 ? parentLogger : rootLogger);
61
+ this.membership = membership;
62
+ this.roomId = roomId;
63
+ this.client = client;
64
+ this.statistics = statistics;
65
+ this.setParentLogger(parentLogger ?? rootLogger);
67
66
  }
68
67
  start() {
69
68
  this.client.on(ClientEvent.ToDeviceEvent, this.onToDeviceEvent);
@@ -71,74 +70,70 @@ export class ToDeviceKeyTransport extends TypedEventEmitter {
71
70
  stop() {
72
71
  this.client.off(ClientEvent.ToDeviceEvent, this.onToDeviceEvent);
73
72
  }
74
- sendKey(keyBase64Encoded, index, members) {
75
- var _this = this;
76
- return _asyncToGenerator(function* () {
77
- var content = {
78
- keys: {
79
- index: index,
80
- key: keyBase64Encoded
81
- },
82
- room_id: _this.roomId,
83
- member: {
84
- claimed_device_id: _this.membership.deviceId,
85
- id: _this.membership.memberId
86
- },
87
- session: {
88
- call_id: "",
89
- application: "m.call",
90
- scope: "m.room"
91
- },
92
- sent_ts: Date.now()
73
+ async sendKey(keyBase64Encoded, index, members) {
74
+ const content = {
75
+ keys: {
76
+ index: index,
77
+ key: keyBase64Encoded
78
+ },
79
+ room_id: this.roomId,
80
+ member: {
81
+ claimed_device_id: this.membership.deviceId,
82
+ id: this.membership.memberId
83
+ },
84
+ session: {
85
+ call_id: "",
86
+ application: "m.call",
87
+ scope: "m.room"
88
+ },
89
+ sent_ts: Date.now()
90
+ };
91
+ const targets = members.map(member => {
92
+ return {
93
+ userId: member.userId,
94
+ deviceId: member.deviceId
93
95
  };
94
- var targets = members.map(member => {
95
- return {
96
- userId: member.userId,
97
- deviceId: member.deviceId
98
- };
99
- })
100
- // filter out me
101
- .filter(member => !(member.userId == _this.membership.userId && member.deviceId == _this.membership.deviceId));
102
- if (targets.length > 0) {
103
- yield _this.client.encryptAndSendToDevice(EventType.CallEncryptionKeysPrefix, targets, content).catch(error => {
104
- var msg = error.message;
105
- // This is not ideal. We would want to have a custom error type for unsupported actions.
106
- // This is not part of the widget API spec. Since as of now there are only two implementations:
107
- // Rust SDK + JS-SDK, and the JS-SDK does support to-device sending, we can assume that
108
- // this is a widget driver issue error message.
109
- if (msg.includes("unknown variant") && msg.includes("send_to_device") || msg.includes("not supported")) {
110
- throw new NotSupportedError("The widget driver does not support to-device encryption");
111
- }
112
- });
113
- _this.statistics.counters.roomEventEncryptionKeysSent += 1;
114
- } else {
115
- _this.logger.warn("No targets found for sending key");
116
- }
117
- })();
96
+ })
97
+ // filter out me
98
+ .filter(member => !(member.userId == this.membership.userId && member.deviceId == this.membership.deviceId));
99
+ if (targets.length > 0) {
100
+ await this.client.encryptAndSendToDevice(EventType.CallEncryptionKeysPrefix, targets, content).catch(error => {
101
+ const msg = error.message;
102
+ // This is not ideal. We would want to have a custom error type for unsupported actions.
103
+ // This is not part of the widget API spec. Since as of now there are only two implementations:
104
+ // Rust SDK + JS-SDK, and the JS-SDK does support to-device sending, we can assume that
105
+ // this is a widget driver issue error message.
106
+ if (msg.includes("unknown variant") && msg.includes("send_to_device") || msg.includes("not supported")) {
107
+ throw new NotSupportedError("The widget driver does not support to-device encryption");
108
+ }
109
+ });
110
+ this.statistics.counters.roomEventEncryptionKeysSent += 1;
111
+ } else {
112
+ this.logger.warn("No targets found for sending key");
113
+ }
118
114
  }
119
115
  receiveCallKeyEvent(fromUser, content) {
120
- var _content$member$id;
121
116
  // The event has already been validated at this point.
122
117
 
123
118
  this.statistics.counters.roomEventEncryptionKeysReceived += 1;
124
119
 
125
120
  // What is this, and why is it needed?
126
121
  // Also to device events do not have an origin server ts
127
- var now = Date.now();
128
- var age = now - (typeof content.sent_ts === "number" ? content.sent_ts : now);
122
+ const now = Date.now();
123
+ const age = now - (typeof content.sent_ts === "number" ? content.sent_ts : now);
129
124
  this.statistics.totals.roomEventEncryptionKeysReceivedTotalAge += age;
130
- var hardcodedMemberIdAlternative = "".concat(fromUser, ":").concat(content.member.claimed_device_id);
125
+ const hardcodedMemberIdAlternative = `${fromUser}:${content.member.claimed_device_id}`;
131
126
  this.emit(KeyTransportEvents.ReceivedKeys,
132
127
  // TODO userId this is claimed information, deviceId is claimed information
133
128
  {
134
129
  userId: fromUser,
135
130
  deviceId: content.member.claimed_device_id,
136
- memberId: (_content$member$id = content.member.id) !== null && _content$member$id !== void 0 ? _content$member$id : hardcodedMemberIdAlternative
131
+ memberId: content.member.id ?? hardcodedMemberIdAlternative
137
132
  }, content.keys.key, content.keys.index, now);
138
133
  }
139
134
  getValidEventContent(event) {
140
- var content = event.getContent();
141
- var roomId = content.room_id;
135
+ const content = event.getContent();
136
+ const roomId = content.room_id;
142
137
  if (!roomId) {
143
138
  // Invalid event
144
139
  this.logger.warn("Malformed Event: invalid call encryption keys event, no roomId");
@@ -1 +1 @@
1
- {"version":3,"file":"ToDeviceKeyTransport.js","names":["TypedEventEmitter","KeyTransportEvents","logger","rootLogger","ClientEvent","EventType","NotSupportedError","Error","constructor","message","name","ToDeviceKeyTransport","setParentLogger","parentLogger","getChild","membership","roomId","client","statistics","_defineProperty","event","getType","CallEncryptionKeysPrefix","content","getValidEventContent","getSender","receiveCallKeyEvent","start","on","ToDeviceEvent","onToDeviceEvent","stop","off","sendKey","keyBase64Encoded","index","members","_this","_asyncToGenerator","keys","key","room_id","member","claimed_device_id","deviceId","id","memberId","session","call_id","application","scope","sent_ts","Date","now","targets","map","userId","filter","length","encryptAndSendToDevice","catch","error","msg","includes","counters","roomEventEncryptionKeysSent","warn","fromUser","_content$member$id","roomEventEncryptionKeysReceived","age","totals","roomEventEncryptionKeysReceivedTotalAge","hardcodedMemberIdAlternative","concat","emit","ReceivedKeys","getContent"],"sources":["../../src/matrixrtc/ToDeviceKeyTransport.ts"],"sourcesContent":["/*\nCopyright 2025 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { type WidgetApiResponseError } from \"matrix-widget-api\";\n\nimport { TypedEventEmitter } from \"../models/typed-event-emitter.ts\";\nimport { type IKeyTransport, KeyTransportEvents, type KeyTransportEventsHandlerMap } from \"./IKeyTransport.ts\";\nimport { type Logger, logger as rootLogger } from \"../logger.ts\";\nimport { type EncryptionKeysToDeviceEventContent, type ParticipantDeviceInfo, type Statistics } from \"./types.ts\";\nimport { ClientEvent, type MatrixClient } from \"../client.ts\";\nimport type { MatrixEvent } from \"../models/event.ts\";\nimport { EventType } from \"../@types/event.ts\";\nimport { type CallMembershipIdentityParts } from \"./EncryptionManager.ts\";\n\nexport class NotSupportedError extends Error {\n public constructor(message?: string) {\n super(message);\n }\n public get name(): string {\n return \"NotSupportedError\";\n }\n}\n/**\n * ToDeviceKeyTransport is used to send MatrixRTC keys to other devices using the\n * to-device CS-API.\n */\nexport class ToDeviceKeyTransport\n extends TypedEventEmitter<KeyTransportEvents, KeyTransportEventsHandlerMap>\n implements IKeyTransport\n{\n private logger: Logger = rootLogger;\n\n public setParentLogger(parentLogger: Logger): void {\n this.logger = parentLogger.getChild(`[ToDeviceKeyTransport]`);\n }\n\n public constructor(\n private membership: CallMembershipIdentityParts,\n private roomId: string,\n private client: Pick<MatrixClient, \"encryptAndSendToDevice\" | \"on\" | \"off\">,\n private statistics: Statistics,\n parentLogger?: Logger,\n ) {\n super();\n this.setParentLogger(parentLogger ?? rootLogger);\n }\n\n public start(): void {\n this.client.on(ClientEvent.ToDeviceEvent, this.onToDeviceEvent);\n }\n\n public stop(): void {\n this.client.off(ClientEvent.ToDeviceEvent, this.onToDeviceEvent);\n }\n\n public async sendKey(keyBase64Encoded: string, index: number, members: ParticipantDeviceInfo[]): Promise<void> {\n const content: EncryptionKeysToDeviceEventContent = {\n keys: {\n index: index,\n key: keyBase64Encoded,\n },\n room_id: this.roomId,\n member: {\n claimed_device_id: this.membership.deviceId,\n id: this.membership.memberId,\n },\n session: {\n call_id: \"\",\n application: \"m.call\",\n scope: \"m.room\",\n },\n sent_ts: Date.now(),\n };\n\n const targets = members\n .map((member) => {\n return {\n userId: member.userId!,\n deviceId: member.deviceId!,\n };\n })\n // filter out me\n .filter(\n (member) => !(member.userId == this.membership.userId && member.deviceId == this.membership.deviceId),\n );\n\n if (targets.length > 0) {\n await this.client\n .encryptAndSendToDevice(EventType.CallEncryptionKeysPrefix, targets, content)\n .catch((error: WidgetApiResponseError) => {\n const msg: string = error.message;\n // This is not ideal. We would want to have a custom error type for unsupported actions.\n // This is not part of the widget API spec. Since as of now there are only two implementations:\n // Rust SDK + JS-SDK, and the JS-SDK does support to-device sending, we can assume that\n // this is a widget driver issue error message.\n if (\n (msg.includes(\"unknown variant\") && msg.includes(\"send_to_device\")) ||\n msg.includes(\"not supported\")\n ) {\n throw new NotSupportedError(\"The widget driver does not support to-device encryption\");\n }\n });\n this.statistics.counters.roomEventEncryptionKeysSent += 1;\n } else {\n this.logger.warn(\"No targets found for sending key\");\n }\n }\n\n private receiveCallKeyEvent(fromUser: string, content: EncryptionKeysToDeviceEventContent): void {\n // The event has already been validated at this point.\n\n this.statistics.counters.roomEventEncryptionKeysReceived += 1;\n\n // What is this, and why is it needed?\n // Also to device events do not have an origin server ts\n const now = Date.now();\n const age = now - (typeof content.sent_ts === \"number\" ? content.sent_ts : now);\n this.statistics.totals.roomEventEncryptionKeysReceivedTotalAge += age;\n\n const hardcodedMemberIdAlternative = `${fromUser}:${content.member.claimed_device_id}`;\n\n this.emit(\n KeyTransportEvents.ReceivedKeys,\n // TODO userId this is claimed information, deviceId is claimed information\n {\n userId: fromUser,\n deviceId: content.member.claimed_device_id!,\n memberId: content.member.id ?? hardcodedMemberIdAlternative,\n },\n content.keys.key,\n content.keys.index,\n now,\n );\n }\n\n private onToDeviceEvent = (event: MatrixEvent): void => {\n if (event.getType() !== EventType.CallEncryptionKeysPrefix) {\n // Ignore this is not a call encryption event\n return;\n }\n\n // TODO: Not possible to check if the event is encrypted or not\n // see https://github.com/matrix-org/matrix-rust-sdk/issues/4883\n // if (evnt.getWireType() != EventType.RoomMessageEncrypted) {\n // // WARN: The call keys were sent in clear. Ignore them\n // logger.warn(`Call encryption keys sent in clear from: ${event.getSender()}`);\n // return;\n // }\n\n const content = this.getValidEventContent(event);\n if (!content) return;\n\n if (!event.getSender()) return;\n\n this.receiveCallKeyEvent(event.getSender()!, content);\n };\n\n private getValidEventContent(event: MatrixEvent): EncryptionKeysToDeviceEventContent | undefined {\n const content = event.getContent();\n const roomId = content.room_id;\n if (!roomId) {\n // Invalid event\n this.logger.warn(\"Malformed Event: invalid call encryption keys event, no roomId\");\n return;\n }\n if (roomId !== this.roomId) {\n this.logger.warn(\"Malformed Event: Mismatch roomId\");\n return;\n }\n\n if (!content.keys || !content.keys.key || typeof content.keys.index !== \"number\") {\n this.logger.warn(\"Malformed Event: Missing keys field\");\n return;\n }\n\n if (!content.member || !content.member.claimed_device_id) {\n this.logger.warn(\"Malformed Event: Missing claimed_device_id\");\n return;\n }\n\n // TODO check for session related fields once the to-device encryption uses the new format.\n return content as EncryptionKeysToDeviceEventContent;\n }\n}\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAASA,iBAAiB,QAAQ,kCAAkC;AACpE,SAA6BC,kBAAkB,QAA2C,oBAAoB;AAC9G,SAAsBC,MAAM,IAAIC,UAAU,QAAQ,cAAc;AAEhE,SAASC,WAAW,QAA2B,cAAc;AAE7D,SAASC,SAAS,QAAQ,oBAAoB;AAG9C,OAAO,MAAMC,iBAAiB,SAASC,KAAK,CAAC;EAClCC,WAAWA,CAACC,OAAgB,EAAE;IACjC,KAAK,CAACA,OAAO,CAAC;EAClB;EACA,IAAWC,IAAIA,CAAA,EAAW;IACtB,OAAO,mBAAmB;EAC9B;AACJ;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,oBAAoB,SACrBX,iBAAiB,CAE7B;EAGWY,eAAeA,CAACC,YAAoB,EAAQ;IAC/C,IAAI,CAACX,MAAM,GAAGW,YAAY,CAACC,QAAQ,yBAAyB,CAAC;EACjE;EAEON,WAAWA,CACNO,UAAuC,EACvCC,MAAc,EACdC,MAAmE,EACnEC,UAAsB,EAC9BL,YAAqB,EACvB;IACE,KAAK,CAAC,CAAC;IAAC,KANAE,UAAuC,GAAvCA,UAAuC;IAAA,KACvCC,MAAc,GAAdA,MAAc;IAAA,KACdC,MAAmE,GAAnEA,MAAmE;IAAA,KACnEC,UAAsB,GAAtBA,UAAsB;IAAAC,eAAA,iBAVThB,UAAU;IAAAgB,eAAA,0BAyGRC,KAAkB,IAAW;MACpD,IAAIA,KAAK,CAACC,OAAO,CAAC,CAAC,KAAKhB,SAAS,CAACiB,wBAAwB,EAAE;QACxD;QACA;MACJ;;MAEA;MACA;MACA;MACA;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,CAACnB,OAAO,CAACmB,MAAM,CAACC,iBAAiB,EAAE;MACtD,IAAI,CAACzC,MAAM,CAACgE,IAAI,CAAC,4CAA4C,CAAC;MAC9D;IACJ;;IAEA;IACA,OAAO3C,OAAO;EAClB;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"ToDeviceKeyTransport.js","names":[],"sources":["../../src/matrixrtc/ToDeviceKeyTransport.ts"],"sourcesContent":["/*\nCopyright 2025 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { type WidgetApiResponseError } from \"matrix-widget-api\";\n\nimport { TypedEventEmitter } from \"../models/typed-event-emitter.ts\";\nimport { type IKeyTransport, KeyTransportEvents, type KeyTransportEventsHandlerMap } from \"./IKeyTransport.ts\";\nimport { type Logger, logger as rootLogger } from \"../logger.ts\";\nimport { type EncryptionKeysToDeviceEventContent, type ParticipantDeviceInfo, type Statistics } from \"./types.ts\";\nimport { ClientEvent, type MatrixClient } from \"../client.ts\";\nimport type { MatrixEvent } from \"../models/event.ts\";\nimport { EventType } from \"../@types/event.ts\";\nimport { type CallMembershipIdentityParts } from \"./EncryptionManager.ts\";\n\nexport class NotSupportedError extends Error {\n public constructor(message?: string) {\n super(message);\n }\n public get name(): string {\n return \"NotSupportedError\";\n }\n}\n/**\n * ToDeviceKeyTransport is used to send MatrixRTC keys to other devices using the\n * to-device CS-API.\n */\nexport class ToDeviceKeyTransport\n extends TypedEventEmitter<KeyTransportEvents, KeyTransportEventsHandlerMap>\n implements IKeyTransport\n{\n private logger: Logger = rootLogger;\n\n public setParentLogger(parentLogger: Logger): void {\n this.logger = parentLogger.getChild(`[ToDeviceKeyTransport]`);\n }\n\n public constructor(\n private membership: CallMembershipIdentityParts,\n private roomId: string,\n private client: Pick<MatrixClient, \"encryptAndSendToDevice\" | \"on\" | \"off\">,\n private statistics: Statistics,\n parentLogger?: Logger,\n ) {\n super();\n this.setParentLogger(parentLogger ?? rootLogger);\n }\n\n public start(): void {\n this.client.on(ClientEvent.ToDeviceEvent, this.onToDeviceEvent);\n }\n\n public stop(): void {\n this.client.off(ClientEvent.ToDeviceEvent, this.onToDeviceEvent);\n }\n\n public async sendKey(keyBase64Encoded: string, index: number, members: ParticipantDeviceInfo[]): Promise<void> {\n const content: EncryptionKeysToDeviceEventContent = {\n keys: {\n index: index,\n key: keyBase64Encoded,\n },\n room_id: this.roomId,\n member: {\n claimed_device_id: this.membership.deviceId,\n id: this.membership.memberId,\n },\n session: {\n call_id: \"\",\n application: \"m.call\",\n scope: \"m.room\",\n },\n sent_ts: Date.now(),\n };\n\n const targets = members\n .map((member) => {\n return {\n userId: member.userId!,\n deviceId: member.deviceId!,\n };\n })\n // filter out me\n .filter(\n (member) => !(member.userId == this.membership.userId && member.deviceId == this.membership.deviceId),\n );\n\n if (targets.length > 0) {\n await this.client\n .encryptAndSendToDevice(EventType.CallEncryptionKeysPrefix, targets, content)\n .catch((error: WidgetApiResponseError) => {\n const msg: string = error.message;\n // This is not ideal. We would want to have a custom error type for unsupported actions.\n // This is not part of the widget API spec. Since as of now there are only two implementations:\n // Rust SDK + JS-SDK, and the JS-SDK does support to-device sending, we can assume that\n // this is a widget driver issue error message.\n if (\n (msg.includes(\"unknown variant\") && msg.includes(\"send_to_device\")) ||\n msg.includes(\"not supported\")\n ) {\n throw new NotSupportedError(\"The widget driver does not support to-device encryption\");\n }\n });\n this.statistics.counters.roomEventEncryptionKeysSent += 1;\n } else {\n this.logger.warn(\"No targets found for sending key\");\n }\n }\n\n private receiveCallKeyEvent(fromUser: string, content: EncryptionKeysToDeviceEventContent): void {\n // The event has already been validated at this point.\n\n this.statistics.counters.roomEventEncryptionKeysReceived += 1;\n\n // What is this, and why is it needed?\n // Also to device events do not have an origin server ts\n const now = Date.now();\n const age = now - (typeof content.sent_ts === \"number\" ? content.sent_ts : now);\n this.statistics.totals.roomEventEncryptionKeysReceivedTotalAge += age;\n\n const hardcodedMemberIdAlternative = `${fromUser}:${content.member.claimed_device_id}`;\n\n this.emit(\n KeyTransportEvents.ReceivedKeys,\n // TODO userId this is claimed information, deviceId is claimed information\n {\n userId: fromUser,\n deviceId: content.member.claimed_device_id!,\n memberId: content.member.id ?? hardcodedMemberIdAlternative,\n },\n content.keys.key,\n content.keys.index,\n now,\n );\n }\n\n private onToDeviceEvent = (event: MatrixEvent): void => {\n if (event.getType() !== EventType.CallEncryptionKeysPrefix) {\n // Ignore this is not a call encryption event\n return;\n }\n\n // TODO: Not possible to check if the event is encrypted or not\n // see https://github.com/matrix-org/matrix-rust-sdk/issues/4883\n // if (evnt.getWireType() != EventType.RoomMessageEncrypted) {\n // // WARN: The call keys were sent in clear. Ignore them\n // logger.warn(`Call encryption keys sent in clear from: ${event.getSender()}`);\n // return;\n // }\n\n const content = this.getValidEventContent(event);\n if (!content) return;\n\n if (!event.getSender()) return;\n\n this.receiveCallKeyEvent(event.getSender()!, content);\n };\n\n private getValidEventContent(event: MatrixEvent): EncryptionKeysToDeviceEventContent | undefined {\n const content = event.getContent();\n const roomId = content.room_id;\n if (!roomId) {\n // Invalid event\n this.logger.warn(\"Malformed Event: invalid call encryption keys event, no roomId\");\n return;\n }\n if (roomId !== this.roomId) {\n this.logger.warn(\"Malformed Event: Mismatch roomId\");\n return;\n }\n\n if (!content.keys || !content.keys.key || typeof content.keys.index !== \"number\") {\n this.logger.warn(\"Malformed Event: Missing keys field\");\n return;\n }\n\n if (!content.member || !content.member.claimed_device_id) {\n this.logger.warn(\"Malformed Event: Missing claimed_device_id\");\n return;\n }\n\n // TODO check for session related fields once the to-device encryption uses the new format.\n return content as EncryptionKeysToDeviceEventContent;\n }\n}\n"],"mappings":";AA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AC;EACL;EAwBQ,oBAAoB,CAAC,KAAkB,EAAkD;IAC7F,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;IAClC,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO;IAC9B,IAAI,CAAC,MAAM,EAAE;MACT;MACA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gEAAgE,CAAC;MAClF;IACJ;IACA,IAAI,MAAM,KAAK,IAAI,CAAC,MAAM,EAAE;MACxB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,kCAAkC,CAAC;MACpD;IACJ;IAEA,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,OAAO,OAAO,CAAC,IAAI,CAAC,KAAK,KAAK,QAAQ,EAAE;MAC9E,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,qCAAqC,CAAC;MACvD;IACJ;IAEA,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,iBAAiB,EAAE;MACtD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,4CAA4C,CAAC;MAC9D;IACJ;;IAEA;IACA,OAAO,OAAO;EAClB;AACJ","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["Status","parseCallNotificationContent","isMyMembership","MembershipManagerEvent"],"sources":["../../src/matrixrtc/index.ts"],"sourcesContent":["/*\nCopyright 2024 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nexport * from \"./CallMembership.ts\";\nexport * from \"./LivekitTransport.ts\";\nexport * from \"./MatrixRTCSession.ts\";\nexport * from \"./MatrixRTCSessionManager.ts\";\nexport type * from \"./types.ts\";\nexport { type SessionMembershipData, type RtcMembershipData } from \"./membershipData/index.ts\";\nexport { Status, parseCallNotificationContent, isMyMembership } from \"./types.ts\";\nexport { MembershipManagerEvent } from \"./IMembershipManager.ts\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,cAAc,qBAAqB;AACnC,cAAc,uBAAuB;AACrC,cAAc,uBAAuB;AACrC,cAAc,8BAA8B;AAG5C,SAASA,MAAM,EAAEC,4BAA4B,EAAEC,cAAc,QAAQ,YAAY;AACjF,SAASC,sBAAsB,QAAQ,yBAAyB","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/matrixrtc/index.ts"],"sourcesContent":["/*\nCopyright 2024 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nexport * from \"./CallMembership.ts\";\nexport * from \"./LivekitTransport.ts\";\nexport * from \"./MatrixRTCSession.ts\";\nexport * from \"./MatrixRTCSessionManager.ts\";\nexport type * from \"./types.ts\";\nexport { type SessionMembershipData, type RtcMembershipData } from \"./membershipData/index.ts\";\nexport { Status, parseCallNotificationContent, isMyMembership } from \"./types.ts\";\nexport { MembershipManagerEvent } from \"./IMembershipManager.ts\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,cAAc,qBAAqB;AACnC,cAAc,uBAAuB;AACrC,cAAc,uBAAuB;AACrC,cAAc,8BAA8B;AAG5C,SAAS,MAAM,EAAE,4BAA4B,EAAE,cAAc,QAAQ,YAAY;AACjF,SAAS,sBAAsB,QAAQ,yBAAyB","ignoreList":[]}
@@ -19,7 +19,7 @@ limitations under the License.
19
19
  */
20
20
  export class MatrixRTCMembershipParseError extends AggregateError {
21
21
  constructor(type, errors) {
22
- super(errors, "Does not match ".concat(type, ":\n").concat(errors.join("\n")));
22
+ super(errors, `Does not match ${type}:\n${errors.join("\n")}`);
23
23
  this.type = type;
24
24
  }
25
25
  }
@@ -1 +1 @@
1
- {"version":3,"file":"common.js","names":["MatrixRTCMembershipParseError","AggregateError","constructor","type","errors","concat","join"],"sources":["../../../src/matrixrtc/membershipData/common.ts"],"sourcesContent":["/*\nCopyright 2026 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\n/**\n * Thrown when an event is not valid for use with MatrixRTC.\n */\nexport class MatrixRTCMembershipParseError extends AggregateError {\n public constructor(\n public readonly type: string,\n errors: string[],\n ) {\n super(errors, `Does not match ${type}:\\n${errors.join(\"\\n\")}`);\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,OAAO,MAAMA,6BAA6B,SAASC,cAAc,CAAC;EACvDC,WAAWA,CACEC,IAAY,EAC5BC,MAAgB,EAClB;IACE,KAAK,CAACA,MAAM,oBAAAC,MAAA,CAAoBF,IAAI,SAAAE,MAAA,CAAMD,MAAM,CAACE,IAAI,CAAC,IAAI,CAAC,CAAE,CAAC;IAAC,KAH/CH,IAAY,GAAZA,IAAY;EAIhC;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"common.js","names":[],"sources":["../../../src/matrixrtc/membershipData/common.ts"],"sourcesContent":["/*\nCopyright 2026 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\n/**\n * Thrown when an event is not valid for use with MatrixRTC.\n */\nexport class MatrixRTCMembershipParseError extends AggregateError {\n public constructor(\n public readonly type: string,\n errors: string[],\n ) {\n super(errors, `Does not match ${type}:\\n${errors.join(\"\\n\")}`);\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,OAAO,MAAM,6BAA6B,SAAS,cAAc,CAAC;EACvD,WAAW,CACE,IAAY,EAC5B,MAAgB,EAClB;IACE,KAAK,CAAC,MAAM,EAAE,kBAAkB,IAAI,MAAM,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;IAAC,KAH/C,IAAY,GAAZ,IAAY;EAIhC;AACJ","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["checkSessionsMembershipData","computeRtcIdentityRaw","checkRtcMembershipData","MatrixRTCMembershipParseError"],"sources":["../../../src/matrixrtc/membershipData/index.ts"],"sourcesContent":["/*\nCopyright 2026 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nexport { type SessionMembershipData, checkSessionsMembershipData } from \"./session.ts\";\nexport { type RtcMembershipData, computeRtcIdentityRaw, checkRtcMembershipData } from \"./rtc.ts\";\nexport { MatrixRTCMembershipParseError } from \"./common.ts\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAAqCA,2BAA2B,QAAQ,cAAc;AACtF,SAAiCC,qBAAqB,EAAEC,sBAAsB,QAAQ,UAAU;AAChG,SAASC,6BAA6B,QAAQ,aAAa","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/matrixrtc/membershipData/index.ts"],"sourcesContent":["/*\nCopyright 2026 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nexport { type SessionMembershipData, checkSessionsMembershipData } from \"./session.ts\";\nexport { type RtcMembershipData, computeRtcIdentityRaw, checkRtcMembershipData } from \"./rtc.ts\";\nexport { MatrixRTCMembershipParseError } from \"./common.ts\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAAqC,2BAA2B,QAAQ,cAAc;AACtF,SAAiC,qBAAqB,EAAE,sBAAsB,QAAQ,UAAU;AAChG,SAAS,6BAA6B,QAAQ,aAAa","ignoreList":[]}
@@ -1,4 +1,3 @@
1
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
1
  /*
3
2
  Copyright 2026 The Matrix.org Foundation C.I.C.
4
3
 
@@ -32,22 +31,21 @@ import { slotIdToDescription } from "../utils.js";
32
31
  * @returns true if `data` is valid RtcMembershipData
33
32
  * @throws {MatrixRTCMembershipParseError} if the content is not valid
34
33
  */
35
- export var checkRtcMembershipData = (data, sender) => {
36
- var _data$application, _data$sticky_key;
37
- var errors = [];
38
- var prefix = " - ";
39
- var expectedSlotPrefix = "".concat(data === null || data === void 0 || (_data$application = data.application) === null || _data$application === void 0 ? void 0 : _data$application.type, "#");
34
+ export const checkRtcMembershipData = (data, sender) => {
35
+ const errors = [];
36
+ const prefix = " - ";
37
+ const expectedSlotPrefix = `${data?.application?.type}#`;
40
38
 
41
39
  // required fields
42
40
  if (typeof data.slot_id !== "string") {
43
41
  errors.push(prefix + "slot_id must be string");
44
42
  } else if (!data.slot_id.startsWith(expectedSlotPrefix)) {
45
- errors.push(prefix + "slot_id must start with ".concat(expectedSlotPrefix));
43
+ errors.push(prefix + `slot_id must start with ${expectedSlotPrefix}`);
46
44
  } else {
47
45
  try {
48
46
  slotIdToDescription(data.slot_id);
49
47
  } catch (ex) {
50
- errors.push(prefix + "slot_id was badly formed".concat(ex instanceof Error ? ": ".concat(ex.message) : ""));
48
+ errors.push(prefix + `slot_id was badly formed${ex instanceof Error ? `: ${ex.message}` : ""}`);
51
49
  }
52
50
  }
53
51
  if (typeof data.member !== "object" || data.member === null) {
@@ -82,7 +80,7 @@ export var checkRtcMembershipData = (data, sender) => {
82
80
  errors.push(prefix + "rtc_transports must be an array");
83
81
  } else {
84
82
  // validate that each transport has at least a string 'type'
85
- for (var t of data.rtc_transports) {
83
+ for (const t of data.rtc_transports) {
86
84
  if (typeof t !== "object" || t === null || typeof t.type !== "string") {
87
85
  errors.push(prefix + "rtc_transports entries must be objects with a string type");
88
86
  break;
@@ -96,7 +94,7 @@ export var checkRtcMembershipData = (data, sender) => {
96
94
  }
97
95
 
98
96
  // optional fields
99
- if (((_data$sticky_key = data.sticky_key) !== null && _data$sticky_key !== void 0 ? _data$sticky_key : data.msc4354_sticky_key) === undefined) {
97
+ if ((data.sticky_key ?? data.msc4354_sticky_key) === undefined) {
100
98
  errors.push(prefix + "sticky_key or msc4354_sticky_key must be a defined");
101
99
  }
102
100
  if (data.sticky_key !== undefined && typeof data.sticky_key !== "string") {
@@ -109,7 +107,7 @@ export var checkRtcMembershipData = (data, sender) => {
109
107
  errors.push(prefix + "sticky_key and msc4354_sticky_key must be equal if both are defined");
110
108
  }
111
109
  if (data["m.relates_to"] !== undefined) {
112
- var rel = data["m.relates_to"];
110
+ const rel = data["m.relates_to"];
113
111
  if (typeof rel !== "object" || rel === null) {
114
112
  errors.push(prefix + "m.relates_to must be an object if provided");
115
113
  } else {
@@ -122,17 +120,11 @@ export var checkRtcMembershipData = (data, sender) => {
122
120
  }
123
121
  return true;
124
122
  };
125
- export function computeRtcIdentityRaw(_x, _x2, _x3) {
126
- return _computeRtcIdentityRaw.apply(this, arguments);
127
- }
128
- function _computeRtcIdentityRaw() {
129
- _computeRtcIdentityRaw = _asyncToGenerator(function* (userId, deviceId, memberId) {
130
- // canonical JSON serialization (Matrix canonical JSON for arrays)
131
- var jsonStr = JSON.stringify([userId, deviceId, memberId]);
132
- var hashBuffer = yield sha256(jsonStr);
133
- var hashedString = encodeUnpaddedBase64(hashBuffer);
134
- return hashedString;
135
- });
136
- return _computeRtcIdentityRaw.apply(this, arguments);
123
+ export async function computeRtcIdentityRaw(userId, deviceId, memberId) {
124
+ // canonical JSON serialization (Matrix canonical JSON for arrays)
125
+ const jsonStr = JSON.stringify([userId, deviceId, memberId]);
126
+ const hashBuffer = await sha256(jsonStr);
127
+ const hashedString = encodeUnpaddedBase64(hashBuffer);
128
+ return hashedString;
137
129
  }
138
130
  //# sourceMappingURL=rtc.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rtc.js","names":["MXID_PATTERN","MatrixRTCMembershipParseError","sha256","encodeUnpaddedBase64","slotIdToDescription","checkRtcMembershipData","data","sender","_data$application","_data$sticky_key","errors","prefix","expectedSlotPrefix","concat","application","type","slot_id","push","startsWith","ex","Error","message","member","user_id","test","device_id","id","includes","rtc_transports","undefined","Array","isArray","t","versions","every","v","sticky_key","msc4354_sticky_key","rel","event_id","rel_type","length","computeRtcIdentityRaw","_x","_x2","_x3","_computeRtcIdentityRaw","apply","arguments","_asyncToGenerator","userId","deviceId","memberId","jsonStr","JSON","stringify","hashBuffer","hashedString"],"sources":["../../../src/matrixrtc/membershipData/rtc.ts"],"sourcesContent":["/*\nCopyright 2026 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { MXID_PATTERN } from \"../../models/room-member.ts\";\nimport type { IContent } from \"../../models/event.ts\";\nimport type { RelationType } from \"../../types.ts\";\nimport { type RtcSlotEventContent, type Transport } from \"../types.ts\";\nimport { MatrixRTCMembershipParseError } from \"./common.ts\";\nimport { sha256 } from \"../../digest.ts\";\nimport { encodeUnpaddedBase64 } from \"../../base64.ts\";\nimport { slotIdToDescription } from \"../utils.ts\";\n\n/**\n * Represents the current form of MSC4143, which uses sticky events to store membership.\n */\nexport interface RtcMembershipData {\n \"slot_id\": string;\n \"member\": {\n user_id: string;\n device_id: string;\n id: string;\n };\n \"m.relates_to\"?: {\n event_id: string;\n rel_type: RelationType.Reference;\n };\n \"application\": RtcSlotEventContent[\"application\"];\n \"rtc_transports\": Transport[];\n \"versions\": string[];\n \"msc4354_sticky_key\"?: string;\n \"sticky_key\"?: string;\n}\n\n/**\n * Validates that `data` matches the format expected by MSC4143.\n * @param data The event content.\n * @param sender The sender of the event.\n * @returns true if `data` is valid RtcMembershipData\n * @throws {MatrixRTCMembershipParseError} if the content is not valid\n */\nexport const checkRtcMembershipData = (data: IContent, sender: string): data is RtcMembershipData => {\n const errors: string[] = [];\n const prefix = \" - \";\n const expectedSlotPrefix = `${data?.application?.type}#`;\n\n // required fields\n if (typeof data.slot_id !== \"string\") {\n errors.push(prefix + \"slot_id must be string\");\n } else if (!data.slot_id.startsWith(expectedSlotPrefix)) {\n errors.push(prefix + `slot_id must start with ${expectedSlotPrefix}`);\n } else {\n try {\n slotIdToDescription(data.slot_id);\n } catch (ex) {\n errors.push(prefix + `slot_id was badly formed${ex instanceof Error ? `: ${ex.message}` : \"\"}`);\n }\n }\n\n if (typeof data.member !== \"object\" || data.member === null) {\n errors.push(prefix + \"member must be an object\");\n } else {\n if (typeof data.member.user_id !== \"string\") {\n errors.push(prefix + \"member.user_id must be string\");\n } else if (!MXID_PATTERN.test(data.member.user_id)) {\n errors.push(prefix + \"member.user_id must be a valid mxid\");\n }\n // This is not what the spec enforces but there currently are no rules what power levels are required to\n // send a m.rtc.member event for a other user. So we add this check for simplicity and to avoid possible attacks until there\n // is a proper definition when this is allowed.\n else if (data.member.user_id !== sender) {\n errors.push(prefix + \"member.user_id must match the sender\");\n }\n if (typeof data.member.device_id !== \"string\") {\n errors.push(prefix + \"member.device_id must be string\");\n }\n if (typeof data.member.id !== \"string\") errors.push(prefix + \"member.id must be string\");\n }\n if (typeof data.application !== \"object\" || data.application === null) {\n errors.push(prefix + \"application must be an object\");\n } else {\n if (typeof data.application.type !== \"string\") {\n errors.push(prefix + \"application.type must be a string\");\n } else {\n if (data.application.type.includes(\"#\")) errors.push(prefix + 'application.type must not include \"#\"');\n }\n }\n if (data.rtc_transports === undefined || !Array.isArray(data.rtc_transports)) {\n errors.push(prefix + \"rtc_transports must be an array\");\n } else {\n // validate that each transport has at least a string 'type'\n for (const t of data.rtc_transports) {\n if (typeof t !== \"object\" || t === null || typeof (t as any).type !== \"string\") {\n errors.push(prefix + \"rtc_transports entries must be objects with a string type\");\n break;\n }\n }\n }\n if (data.versions === undefined || !Array.isArray(data.versions)) {\n errors.push(prefix + \"versions must be an array\");\n } else if (!data.versions.every((v) => typeof v === \"string\")) {\n errors.push(prefix + \"versions must be an array of strings\");\n }\n\n // optional fields\n if ((data.sticky_key ?? data.msc4354_sticky_key) === undefined) {\n errors.push(prefix + \"sticky_key or msc4354_sticky_key must be a defined\");\n }\n if (data.sticky_key !== undefined && typeof data.sticky_key !== \"string\") {\n errors.push(prefix + \"sticky_key must be a string\");\n }\n if (data.msc4354_sticky_key !== undefined && typeof data.msc4354_sticky_key !== \"string\") {\n errors.push(prefix + \"msc4354_sticky_key must be a string\");\n }\n if (\n data.sticky_key !== undefined &&\n data.msc4354_sticky_key !== undefined &&\n data.sticky_key !== data.msc4354_sticky_key\n ) {\n errors.push(prefix + \"sticky_key and msc4354_sticky_key must be equal if both are defined\");\n }\n if (data[\"m.relates_to\"] !== undefined) {\n const rel = data[\"m.relates_to\"] as RtcMembershipData[\"m.relates_to\"];\n if (typeof rel !== \"object\" || rel === null) {\n errors.push(prefix + \"m.relates_to must be an object if provided\");\n } else {\n if (typeof rel.event_id !== \"string\") errors.push(prefix + \"m.relates_to.event_id must be a string\");\n if (rel.rel_type !== \"m.reference\") errors.push(prefix + \"m.relates_to.rel_type must be m.reference\");\n }\n }\n\n if (errors.length) {\n throw new MatrixRTCMembershipParseError(\"RtcMembership\", errors);\n }\n\n return true;\n};\n\nexport async function computeRtcIdentityRaw(userId: string, deviceId: string, memberId: string): Promise<string> {\n // canonical JSON serialization (Matrix canonical JSON for arrays)\n const jsonStr = JSON.stringify([userId, deviceId, memberId]);\n const hashBuffer = await sha256(jsonStr);\n const hashedString = encodeUnpaddedBase64(hashBuffer);\n return hashedString;\n}\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,YAAY,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,QAAQ,EAAEC,QAAQ,CAAC,CAAC;IAC5D,IAAMI,UAAU,SAAStD,MAAM,CAACmD,OAAO,CAAC;IACxC,IAAMI,YAAY,GAAGtD,oBAAoB,CAACqD,UAAU,CAAC;IACrD,OAAOC,YAAY;EACvB,CAAC;EAAA,OAAAX,sBAAA,CAAAC,KAAA,OAAAC,SAAA;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"rtc.js","names":[],"sources":["../../../src/matrixrtc/membershipData/rtc.ts"],"sourcesContent":["/*\nCopyright 2026 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { MXID_PATTERN } from \"../../models/room-member.ts\";\nimport type { IContent } from \"../../models/event.ts\";\nimport type { RelationType } from \"../../types.ts\";\nimport { type RtcSlotEventContent, type Transport } from \"../types.ts\";\nimport { MatrixRTCMembershipParseError } from \"./common.ts\";\nimport { sha256 } from \"../../digest.ts\";\nimport { encodeUnpaddedBase64 } from \"../../base64.ts\";\nimport { slotIdToDescription } from \"../utils.ts\";\n\n/**\n * Represents the current form of MSC4143, which uses sticky events to store membership.\n */\nexport interface RtcMembershipData {\n \"slot_id\": string;\n \"member\": {\n user_id: string;\n device_id: string;\n id: string;\n };\n \"m.relates_to\"?: {\n event_id: string;\n rel_type: RelationType.Reference;\n };\n \"application\": RtcSlotEventContent[\"application\"];\n \"rtc_transports\": Transport[];\n \"versions\": string[];\n \"msc4354_sticky_key\"?: string;\n \"sticky_key\"?: string;\n}\n\n/**\n * Validates that `data` matches the format expected by MSC4143.\n * @param data The event content.\n * @param sender The sender of the event.\n * @returns true if `data` is valid RtcMembershipData\n * @throws {MatrixRTCMembershipParseError} if the content is not valid\n */\nexport const checkRtcMembershipData = (data: IContent, sender: string): data is RtcMembershipData => {\n const errors: string[] = [];\n const prefix = \" - \";\n const expectedSlotPrefix = `${data?.application?.type}#`;\n\n // required fields\n if (typeof data.slot_id !== \"string\") {\n errors.push(prefix + \"slot_id must be string\");\n } else if (!data.slot_id.startsWith(expectedSlotPrefix)) {\n errors.push(prefix + `slot_id must start with ${expectedSlotPrefix}`);\n } else {\n try {\n slotIdToDescription(data.slot_id);\n } catch (ex) {\n errors.push(prefix + `slot_id was badly formed${ex instanceof Error ? `: ${ex.message}` : \"\"}`);\n }\n }\n\n if (typeof data.member !== \"object\" || data.member === null) {\n errors.push(prefix + \"member must be an object\");\n } else {\n if (typeof data.member.user_id !== \"string\") {\n errors.push(prefix + \"member.user_id must be string\");\n } else if (!MXID_PATTERN.test(data.member.user_id)) {\n errors.push(prefix + \"member.user_id must be a valid mxid\");\n }\n // This is not what the spec enforces but there currently are no rules what power levels are required to\n // send a m.rtc.member event for a other user. So we add this check for simplicity and to avoid possible attacks until there\n // is a proper definition when this is allowed.\n else if (data.member.user_id !== sender) {\n errors.push(prefix + \"member.user_id must match the sender\");\n }\n if (typeof data.member.device_id !== \"string\") {\n errors.push(prefix + \"member.device_id must be string\");\n }\n if (typeof data.member.id !== \"string\") errors.push(prefix + \"member.id must be string\");\n }\n if (typeof data.application !== \"object\" || data.application === null) {\n errors.push(prefix + \"application must be an object\");\n } else {\n if (typeof data.application.type !== \"string\") {\n errors.push(prefix + \"application.type must be a string\");\n } else {\n if (data.application.type.includes(\"#\")) errors.push(prefix + 'application.type must not include \"#\"');\n }\n }\n if (data.rtc_transports === undefined || !Array.isArray(data.rtc_transports)) {\n errors.push(prefix + \"rtc_transports must be an array\");\n } else {\n // validate that each transport has at least a string 'type'\n for (const t of data.rtc_transports) {\n if (typeof t !== \"object\" || t === null || typeof (t as any).type !== \"string\") {\n errors.push(prefix + \"rtc_transports entries must be objects with a string type\");\n break;\n }\n }\n }\n if (data.versions === undefined || !Array.isArray(data.versions)) {\n errors.push(prefix + \"versions must be an array\");\n } else if (!data.versions.every((v) => typeof v === \"string\")) {\n errors.push(prefix + \"versions must be an array of strings\");\n }\n\n // optional fields\n if ((data.sticky_key ?? data.msc4354_sticky_key) === undefined) {\n errors.push(prefix + \"sticky_key or msc4354_sticky_key must be a defined\");\n }\n if (data.sticky_key !== undefined && typeof data.sticky_key !== \"string\") {\n errors.push(prefix + \"sticky_key must be a string\");\n }\n if (data.msc4354_sticky_key !== undefined && typeof data.msc4354_sticky_key !== \"string\") {\n errors.push(prefix + \"msc4354_sticky_key must be a string\");\n }\n if (\n data.sticky_key !== undefined &&\n data.msc4354_sticky_key !== undefined &&\n data.sticky_key !== data.msc4354_sticky_key\n ) {\n errors.push(prefix + \"sticky_key and msc4354_sticky_key must be equal if both are defined\");\n }\n if (data[\"m.relates_to\"] !== undefined) {\n const rel = data[\"m.relates_to\"] as RtcMembershipData[\"m.relates_to\"];\n if (typeof rel !== \"object\" || rel === null) {\n errors.push(prefix + \"m.relates_to must be an object if provided\");\n } else {\n if (typeof rel.event_id !== \"string\") errors.push(prefix + \"m.relates_to.event_id must be a string\");\n if (rel.rel_type !== \"m.reference\") errors.push(prefix + \"m.relates_to.rel_type must be m.reference\");\n }\n }\n\n if (errors.length) {\n throw new MatrixRTCMembershipParseError(\"RtcMembership\", errors);\n }\n\n return true;\n};\n\nexport async function computeRtcIdentityRaw(userId: string, deviceId: string, memberId: string): Promise<string> {\n // canonical JSON serialization (Matrix canonical JSON for arrays)\n const jsonStr = JSON.stringify([userId, deviceId, memberId]);\n const hashBuffer = await sha256(jsonStr);\n const hashedString = encodeUnpaddedBase64(hashBuffer);\n return hashedString;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAAS,YAAY,QAAQ,6BAA6B;AAI1D,SAAS,6BAA6B,QAAQ,aAAa;AA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AI,CAAC,cAAc,CAAsC;IACrE,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,EAAE;MACzC,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,4CAA4C,CAAC;IACtE,CAAC,MAAM;MACH,IAAI,OAAO,GAAG,CAAC,QAAQ,KAAK,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,wCAAwC,CAAC;MACpG,IAAI,GAAG,CAAC,QAAQ,KAAK,aAAa,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,2CAA2C,CAAC;IACzG;EACJ;EAEA,IAAI,MAAM,CAAC,MAAM,EAAE;IACf,MAAM,IAAI,6BAA6B,CAAC,eAAe,EAAE,MAAM,CAAC;EACpE;EAEA,OAAO,IAAI;AACf,CAAC;AAED,OAAO,eAAe,qBAAqB,CAAC,MAAc,EAAE,QAAgB,EAAE,QAAgB,EAAmB;EAC7G;EACA,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;EAC5D,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;EACxC,MAAM,YAAY,GAAG,oBAAoB,CAAC,UAAU,CAAC;EACrD,OAAO,YAAY;AACvB","ignoreList":[]}
@@ -28,17 +28,16 @@ import { MatrixRTCMembershipParseError } from "./common.js";
28
28
  * @returns true if `data` is valid SessionMembershipData
29
29
  * @throws {MatrixRTCMembershipParseError} if the content is not valid
30
30
  */
31
- export var checkSessionsMembershipData = data => {
32
- var _data$focus_active;
33
- var prefix = " - ";
34
- var errors = [];
31
+ export const checkSessionsMembershipData = data => {
32
+ const prefix = " - ";
33
+ const errors = [];
35
34
  if (typeof data.device_id !== "string") errors.push(prefix + "device_id must be string");
36
35
  if (typeof data.call_id !== "string") errors.push(prefix + "call_id must be string");
37
36
  if (typeof data.application !== "string") errors.push(prefix + "application must be a string");
38
37
  if (data.focus_active === undefined) {
39
38
  errors.push(prefix + "focus_active has an invalid type");
40
39
  }
41
- if (typeof ((_data$focus_active = data.focus_active) === null || _data$focus_active === void 0 ? void 0 : _data$focus_active.type) !== "string") {
40
+ if (typeof data.focus_active?.type !== "string") {
42
41
  errors.push(prefix + "focus_active.type must be a string");
43
42
  }
44
43
  if (data.foci_preferred !== undefined && !(Array.isArray(data.foci_preferred) && data.foci_preferred.every(f => typeof f === "object" && f !== null && typeof f.type === "string"))) {
@@ -1 +1 @@
1
- {"version":3,"file":"session.js","names":["MatrixRTCMembershipParseError","checkSessionsMembershipData","data","_data$focus_active","prefix","errors","device_id","push","call_id","application","focus_active","undefined","type","foci_preferred","Array","isArray","every","f","created_ts","scope","length"],"sources":["../../../src/matrixrtc/membershipData/session.ts"],"sourcesContent":["/*\nCopyright 2026 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { type IContent } from \"../../matrix.ts\";\nimport { type RTCCallIntent, type Transport } from \"../types.ts\";\nimport { MatrixRTCMembershipParseError } from \"./common.ts\";\n\n/**\n * (MatrixRTC) session membership data.\n * This represents the *OLD* form of MSC4143, which uses state events to store membership.\n * Represents the `session` in the memberships section of an m.call.member event as it is on the wire.\n **/\nexport type SessionMembershipData = {\n /**\n * The RTC application defines the type of the RTC session.\n */\n \"application\": string;\n\n /**\n * The id of this session.\n * A session can never span over multiple rooms so this id is to distinguish between\n * multiple session in one room. A room wide session that is not associated with a user,\n * and therefore immune to creation race conflicts, uses the `call_id: \"\"`.\n */\n \"call_id\": string;\n\n /**\n * The Matrix device ID of this session. A single user can have multiple sessions on different devices.\n */\n \"device_id\": string;\n\n /**\n * The focus selection system this user/membership is using.\n * NOTE: This is still included for legacy reasons, but not consumed by the SDK.\n */\n \"focus_active\": {\n type: \"livekit\" | string;\n focus_selection: \"oldest_membership\" | \"multi_sfu\" | string;\n };\n\n /**\n * A list of possible foci this user knows about. One of them might be used based on the focus_active\n * selection system.\n */\n \"foci_preferred\": Transport[];\n\n /**\n * Optional field that contains the creation of the session. If it is undefined the creation\n * is the `origin_server_ts` of the event itself. For updates to the event this property tracks\n * the `origin_server_ts` of the initial join event.\n * - If it is undefined it can be interpreted as a \"Join\".\n * - If it is defined it can be interpreted as an \"Update\"\n */\n \"created_ts\"?: number;\n\n // Application specific data\n\n /**\n * If the `application` = `\"m.call\"` this defines if it is a room or user owned call.\n * There can always be one room scoped call but multiple user owned calls (breakout sessions)\n */\n \"scope\"?: \"m.room\" | \"m.user\";\n\n /**\n * Optionally we allow to define a delta to the `created_ts` that defines when the event is expired/invalid.\n * This should be set to multiple hours. The only reason it exist is to deal with failed delayed events.\n * (for example caused by a homeserver crashes)\n **/\n \"expires\"?: number;\n\n /**\n * The intent of the call from the perspective of this user. This may be an audio call, video call or\n * something else.\n */\n \"m.call.intent\"?: RTCCallIntent;\n\n /**\n * The id used on the media backend.\n * (With livekit this is the participant identity on the LK SFU)\n * This can be a UUID but right now it is `${this.matrixEventData.sender}:${data.device_id}`.\n *\n * It is compleatly valid to not set this field. Other clients will treat `undefined` as `${this.matrixEventData.sender}:${data.device_id}`\n */\n \"membershipID\"?: string;\n};\n\n/**\n * Validates that `data` matches the format expected by the legacy form of MSC4143.\n * @param data The event content.\n * @returns true if `data` is valid SessionMembershipData\n * @throws {MatrixRTCMembershipParseError} if the content is not valid\n */\nexport const checkSessionsMembershipData = (data: IContent): data is SessionMembershipData => {\n const prefix = \" - \";\n const errors: string[] = [];\n if (typeof data.device_id !== \"string\") errors.push(prefix + \"device_id must be string\");\n if (typeof data.call_id !== \"string\") errors.push(prefix + \"call_id must be string\");\n if (typeof data.application !== \"string\") errors.push(prefix + \"application must be a string\");\n if (data.focus_active === undefined) {\n errors.push(prefix + \"focus_active has an invalid type\");\n }\n if (typeof data.focus_active?.type !== \"string\") {\n errors.push(prefix + \"focus_active.type must be a string\");\n }\n if (\n data.foci_preferred !== undefined &&\n !(\n Array.isArray(data.foci_preferred) &&\n data.foci_preferred.every(\n (f: Transport) => typeof f === \"object\" && f !== null && typeof f.type === \"string\",\n )\n )\n ) {\n errors.push(prefix + \"foci_preferred must be an array of transport objects\");\n }\n // optional parameters\n if (data.created_ts !== undefined && typeof data.created_ts !== \"number\") {\n errors.push(prefix + \"created_ts must be number\");\n }\n\n // application specific data (we first need to check if they exist)\n if (data.scope !== undefined && typeof data.scope !== \"string\") errors.push(prefix + \"scope must be string\");\n\n if (data[\"m.call.intent\"] !== undefined && typeof data[\"m.call.intent\"] !== \"string\") {\n errors.push(prefix + \"m.call.intent must be a string\");\n }\n\n if (errors.length) {\n throw new MatrixRTCMembershipParseError(\"SessionMembership\", errors);\n }\n\n return true;\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAASA,6BAA6B,QAAQ,aAAa;;AAE3D;AACA;AACA;AACA;AACA;;AA2EA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,IAAMC,2BAA2B,GAAIC,IAAc,IAAoC;EAAA,IAAAC,kBAAA;EAC1F,IAAMC,MAAM,GAAG,KAAK;EACpB,IAAMC,MAAgB,GAAG,EAAE;EAC3B,IAAI,OAAOH,IAAI,CAACI,SAAS,KAAK,QAAQ,EAAED,MAAM,CAACE,IAAI,CAACH,MAAM,GAAG,0BAA0B,CAAC;EACxF,IAAI,OAAOF,IAAI,CAACM,OAAO,KAAK,QAAQ,EAAEH,MAAM,CAACE,IAAI,CAACH,MAAM,GAAG,wBAAwB,CAAC;EACpF,IAAI,OAAOF,IAAI,CAACO,WAAW,KAAK,QAAQ,EAAEJ,MAAM,CAACE,I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AAC,mBAAmB,EAAEK,MAAM,CAAC;EACxE;EAEA,OAAO,IAAI;AACf,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"session.js","names":[],"sources":["../../../src/matrixrtc/membershipData/session.ts"],"sourcesContent":["/*\nCopyright 2026 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { type IContent } from \"../../matrix.ts\";\nimport { type RTCCallIntent, type Transport } from \"../types.ts\";\nimport { MatrixRTCMembershipParseError } from \"./common.ts\";\n\n/**\n * (MatrixRTC) session membership data.\n * This represents the *OLD* form of MSC4143, which uses state events to store membership.\n * Represents the `session` in the memberships section of an m.call.member event as it is on the wire.\n **/\nexport type SessionMembershipData = {\n /**\n * The RTC application defines the type of the RTC session.\n */\n \"application\": string;\n\n /**\n * The id of this session.\n * A session can never span over multiple rooms so this id is to distinguish between\n * multiple session in one room. A room wide session that is not associated with a user,\n * and therefore immune to creation race conflicts, uses the `call_id: \"\"`.\n */\n \"call_id\": string;\n\n /**\n * The Matrix device ID of this session. A single user can have multiple sessions on different devices.\n */\n \"device_id\": string;\n\n /**\n * The focus selection system this user/membership is using.\n * NOTE: This is still included for legacy reasons, but not consumed by the SDK.\n */\n \"focus_active\": {\n type: \"livekit\" | string;\n focus_selection: \"oldest_membership\" | \"multi_sfu\" | string;\n };\n\n /**\n * A list of possible foci this user knows about. One of them might be used based on the focus_active\n * selection system.\n */\n \"foci_preferred\": Transport[];\n\n /**\n * Optional field that contains the creation of the session. If it is undefined the creation\n * is the `origin_server_ts` of the event itself. For updates to the event this property tracks\n * the `origin_server_ts` of the initial join event.\n * - If it is undefined it can be interpreted as a \"Join\".\n * - If it is defined it can be interpreted as an \"Update\"\n */\n \"created_ts\"?: number;\n\n // Application specific data\n\n /**\n * If the `application` = `\"m.call\"` this defines if it is a room or user owned call.\n * There can always be one room scoped call but multiple user owned calls (breakout sessions)\n */\n \"scope\"?: \"m.room\" | \"m.user\";\n\n /**\n * Optionally we allow to define a delta to the `created_ts` that defines when the event is expired/invalid.\n * This should be set to multiple hours. The only reason it exist is to deal with failed delayed events.\n * (for example caused by a homeserver crashes)\n **/\n \"expires\"?: number;\n\n /**\n * The intent of the call from the perspective of this user. This may be an audio call, video call or\n * something else.\n */\n \"m.call.intent\"?: RTCCallIntent;\n\n /**\n * The id used on the media backend.\n * (With livekit this is the participant identity on the LK SFU)\n * This can be a UUID but right now it is `${this.matrixEventData.sender}:${data.device_id}`.\n *\n * It is compleatly valid to not set this field. Other clients will treat `undefined` as `${this.matrixEventData.sender}:${data.device_id}`\n */\n \"membershipID\"?: string;\n};\n\n/**\n * Validates that `data` matches the format expected by the legacy form of MSC4143.\n * @param data The event content.\n * @returns true if `data` is valid SessionMembershipData\n * @throws {MatrixRTCMembershipParseError} if the content is not valid\n */\nexport const checkSessionsMembershipData = (data: IContent): data is SessionMembershipData => {\n const prefix = \" - \";\n const errors: string[] = [];\n if (typeof data.device_id !== \"string\") errors.push(prefix + \"device_id must be string\");\n if (typeof data.call_id !== \"string\") errors.push(prefix + \"call_id must be string\");\n if (typeof data.application !== \"string\") errors.push(prefix + \"application must be a string\");\n if (data.focus_active === undefined) {\n errors.push(prefix + \"focus_active has an invalid type\");\n }\n if (typeof data.focus_active?.type !== \"string\") {\n errors.push(prefix + \"focus_active.type must be a string\");\n }\n if (\n data.foci_preferred !== undefined &&\n !(\n Array.isArray(data.foci_preferred) &&\n data.foci_preferred.every(\n (f: Transport) => typeof f === \"object\" && f !== null && typeof f.type === \"string\",\n )\n )\n ) {\n errors.push(prefix + \"foci_preferred must be an array of transport objects\");\n }\n // optional parameters\n if (data.created_ts !== undefined && typeof data.created_ts !== \"number\") {\n errors.push(prefix + \"created_ts must be number\");\n }\n\n // application specific data (we first need to check if they exist)\n if (data.scope !== undefined && typeof data.scope !== \"string\") errors.push(prefix + \"scope must be string\");\n\n if (data[\"m.call.intent\"] !== undefined && typeof data[\"m.call.intent\"] !== \"string\") {\n errors.push(prefix + \"m.call.intent must be a string\");\n }\n\n if (errors.length) {\n throw new MatrixRTCMembershipParseError(\"SessionMembership\", errors);\n }\n\n return true;\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAAS,6BAA6B,QAAQ,aAAa;;AAE3D;AACA;AACA;AACA;AACA;;AA2EA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAM,2BAA2B,GAAI,IAAc,IAAoC;EAC1F,MAAM,MAAM,GAAG,KAAK;EACpB,MAAM,MAAgB,GAAG,EAAE;EAC3B,IAAI,OAAO,IAAI,CAAC,SAAS,KAAK,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,0BAA0B,CAAC;EACxF,IAAI,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,wBAAwB,CAAC;EACpF,IAAI,OAAO,IAAI,CAAC,WAAW,KAAK,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,8BAA8B,CAAC;EAC9F,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE;IACjC,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,kCAAkC,CAAC;EAC5D;EACA,IAAI,OAAO,IAAI,CAAC,YAAY,EAAE,IAAI,KAAK,QAAQ,EAAE;IAC7C,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,oCAAoC,CAAC;EAC9D;EACA,IACI,IAAI,CAAC,cAAc,KAAK,SAAS,IACjC,EACI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,IAClC,IAAI,CAAC,cAAc,CAAC,KAAK,CACpB,CAAY,IAAK,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,OAAO,CAAC,CAAC,IAAI,KAAK,QAC/E,CAAC,CACJ,EACH;IACE,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,sDAAsD,CAAC;EAChF;EACA;EACA,IAAI,IAAI,CAAC,UAAU,KAAK,SAAS,IAAI,OAAO,IAAI,CAAC,UAAU,KAAK,QAAQ,EAAE;IACtE,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,2BAA2B,CAAC;EACrD;;EAEA;EACA,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,sBAAsB,CAAC;EAE5G,IAAI,IAAI,CAAC,eAAe,CAAC,KAAK,SAAS,IAAI,OAAO,IAAI,CAAC,eAAe,CAAC,KAAK,QAAQ,EAAE;IAClF,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,gCAAgC,CAAC;EAC1D;EAEA,IAAI,MAAM,CAAC,MAAM,EAAE;IACf,MAAM,IAAI,6BAA6B,CAAC,mBAAmB,EAAE,MAAM,CAAC;EACxE;EAEA,OAAO,IAAI;AACf,CAAC","ignoreList":[]}
@@ -1,6 +1,4 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1
+ import _objectSpread from "@babel/runtime/helpers/objectSpread2";
4
2
  /*
5
3
  Copyright 2023-2026 The Matrix.org Foundation C.I.C.
6
4
 
@@ -72,7 +70,7 @@ export function parseCallNotificationContent(content) {
72
70
  if (content["m.call.intent"] && typeof content["m.call.intent"] !== "string") {
73
71
  throw new Error("Invalid m.call.intent");
74
72
  }
75
- var cappedLifetime = content["lifetime"] >= 90000 ? 90000 : content["lifetime"];
73
+ const cappedLifetime = content["lifetime"] >= 90000 ? 90000 : content["lifetime"];
76
74
  return _objectSpread(_objectSpread({}, content), {}, {
77
75
  lifetime: cappedLifetime
78
76
  });
@@ -88,7 +86,7 @@ export function parseCallNotificationContent(content) {
88
86
  * Sent as a standard m.reference relation to an `org.matrix.msc4075.rtc.notification` event.
89
87
  */
90
88
 
91
- export var Status = /*#__PURE__*/function (Status) {
89
+ export let Status = /*#__PURE__*/function (Status) {
92
90
  Status["Disconnected"] = "Disconnected";
93
91
  Status["Connecting"] = "Connecting";
94
92
  Status["Connected"] = "Connected";
@@ -101,7 +99,7 @@ export var Status = /*#__PURE__*/function (Status) {
101
99
  * A type collecting call encryption statistics for a session.
102
100
  */
103
101
 
104
- export var isMyMembership = (m, userId, deviceId) => m.sender === userId && m.deviceId === deviceId;
102
+ export const isMyMembership = (m, userId, deviceId) => m.sender === userId && m.deviceId === deviceId;
105
103
 
106
104
  /**
107
105
  * A RTC transport is a JSON object that describes how to connect to a RTC member.
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":["parseCallNotificationContent","content","Error","cappedLifetime","_objectSpread","lifetime","Status","isMyMembership","m","userId","deviceId","sender"],"sources":["../../src/matrixrtc/types.ts"],"sourcesContent":["/*\nCopyright 2023-2026 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\nimport type { IContent, IMentions } from \"../matrix.ts\";\nimport type { RelationEvent } from \"../types.ts\";\nimport type { CallMembership } from \"./CallMembership.ts\";\nimport { type CallMembershipIdentityParts } from \"./EncryptionManager.ts\";\n\nexport type EncryptionKeyMapKey = string;\n\nexport interface EncryptionKeyEntry {\n index: number;\n key: string;\n}\n\n/**\n * The mxID, deviceId and membership timestamp of a RTC session participant.\n */\nexport type ParticipantDeviceInfo = {\n userId: string;\n deviceId: string;\n membershipTs: number;\n};\n\n/**\n * A type representing the information needed to decrypt video streams.\n */\nexport type InboundEncryptionSession = {\n key: Uint8Array<ArrayBuffer>;\n membership: CallMembershipIdentityParts;\n keyIndex: number;\n creationTS: number;\n};\n\n/**\n * The information about the key used to encrypt video streams.\n */\nexport type OutboundEncryptionSession = {\n key: Uint8Array<ArrayBuffer>;\n creationTS: number;\n // The devices that this key is shared with.\n sharedWith: Array<ParticipantDeviceInfo>;\n // This is an index acting as the id of the key\n keyId: number;\n};\n\nexport interface EncryptionKeysEventContent {\n keys: EncryptionKeyEntry[];\n device_id: string;\n call_id: string;\n sent_ts?: number;\n}\n\n/**\n * THe content of a to-device event that contains encryption keys.\n */\nexport interface EncryptionKeysToDeviceEventContent {\n keys: { index: number; key: string };\n member: {\n id: string;\n // TODO Remove that it is claimed, need to get the sealed sender from decryption info\n // Or add some validation on it based on the encryption info\n claimed_device_id: string;\n };\n room_id: string;\n session: {\n application: string;\n call_id: string;\n scope: string;\n };\n // Why is this needed?\n sent_ts?: number;\n}\n/**\n * @deprecated Use `RTCNotificationType` instead.\n */\nexport type CallNotifyType = \"ring\" | \"notify\";\n/**\n * @deprecated Use `IRTCNotificationContent` instead.\n */\nexport interface ICallNotifyContent {\n \"application\": string;\n \"m.mentions\": IMentions;\n \"notify_type\": CallNotifyType;\n \"call_id\": string;\n}\n\nexport type RTCNotificationType = \"ring\" | \"notification\";\n\n/**\n * Represents the intention of the call from the perspective of the sending user.\n * May be any string, although `\"audio\"` and `\"video\"` are commonly accepted values.\n */\nexport type RTCCallIntent = \"audio\" | \"video\" | string;\n\n/**\n * This will check if the content has all the expected fields to be a valid IRTCNotificationContent.\n * It will also cap the lifetime to 90000ms (1.5 min) if a higher value is provided.\n * @param content\n * @throws if the content is invalid\n * @returns a parsed IRTCNotificationContent\n */\nexport function parseCallNotificationContent(content: IContent): IRTCNotificationContent {\n if (content[\"m.mentions\"] && typeof content[\"m.mentions\"] !== \"object\") {\n throw new Error(\"malformed m.mentions\");\n }\n if (typeof content[\"notification_type\"] !== \"string\") {\n throw new Error(\"Missing or invalid notification_type\");\n }\n if (typeof content[\"sender_ts\"] !== \"number\") {\n throw new Error(\"Missing or invalid sender_ts\");\n }\n if (typeof content[\"lifetime\"] !== \"number\") {\n throw new Error(\"Missing or invalid lifetime\");\n }\n\n if (content[\"relation\"] && content[\"relation\"][\"rel_type\"] !== \"m.reference\") {\n throw new Error(\"Invalid relation\");\n }\n if (content[\"m.call.intent\"] && typeof content[\"m.call.intent\"] !== \"string\") {\n throw new Error(\"Invalid m.call.intent\");\n }\n\n const cappedLifetime = content[\"lifetime\"] >= 90000 ? 90000 : content[\"lifetime\"];\n return { ...content, lifetime: cappedLifetime } as IRTCNotificationContent;\n}\n\n/**\n * Interface for `org.matrix.msc4075.rtc.notification` events.\n * Don't cast event content to this directly. Use `parseCallNotificationContent` instead to validate the content first.\n */\nexport interface IRTCNotificationContent extends RelationEvent {\n \"m.mentions\"?: IMentions;\n \"notification_type\": RTCNotificationType;\n /**\n * The initial intent of the calling user.\n */\n \"m.call.intent\"?: RTCCallIntent;\n \"sender_ts\": number;\n \"lifetime\": number;\n}\n\n/**\n * MSC4310 decline event content for `org.matrix.msc4310.rtc.decline`.\n * Sent as a standard m.reference relation to an `org.matrix.msc4075.rtc.notification` event.\n */\nexport interface IRTCDeclineContent extends RelationEvent {}\n\nexport enum Status {\n Disconnected = \"Disconnected\",\n Connecting = \"Connecting\",\n Connected = \"Connected\",\n Disconnecting = \"Disconnecting\",\n Unknown = \"Unknown\",\n}\n\n/**\n * A type collecting call encryption statistics for a session.\n */\nexport type Statistics = {\n counters: {\n /**\n * The number of times we have sent a room event containing encryption keys.\n */\n roomEventEncryptionKeysSent: number;\n /**\n * The number of times we have received a room event containing encryption keys.\n */\n roomEventEncryptionKeysReceived: number;\n };\n totals: {\n /**\n * The total age (in milliseconds) of all room events containing encryption keys that we have received.\n * We track the total age so that we can later calculate the average age of all keys received.\n */\n roomEventEncryptionKeysReceivedTotalAge: number;\n };\n};\n\nexport const isMyMembership = (m: CallMembership, userId: string, deviceId: string): boolean =>\n m.sender === userId && m.deviceId === deviceId;\n\n/**\n * A RTC transport is a JSON object that describes how to connect to a RTC member.\n */\nexport interface Transport {\n type: string;\n [key: string]: unknown;\n}\n\n/**\n * Event content for a `m.rtc.slot` state event.\n */\nexport interface RtcSlotEventContent<T extends string = string> {\n application: {\n type: T;\n // other application specific keys\n [key: string]: unknown;\n };\n slot_id: string;\n}\n\n/**\n * The session description is used to identify a session. Used in the state event.\n */\nexport interface SlotDescription {\n /**\n * The application type. e.g. \"m.call\".\n */\n application: string;\n /**\n * The application-specific slot ID. e.g. \"ROOM\".\n */\n id: string;\n}\n"],"mappings":";;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAaA;AACA;AACA;;AAOA;AACA;AACA;;AAQA;AACA;AACA;;AAiBA;AACA;AACA;;AAkBA;AACA;AACA;;AAEA;AACA;AACA;;AAUA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,4BAA4BA,CAACC,OAAiB,EAA2B;EACrF,IAAIA,OAAO,CAAC,YAAY,CAAC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AAM,IAAID,CAAC,CAACE,QAAQ,KAAKA,QAAQ;;AAElD;AACA;AACA;;AAMA;AACA;AACA;;AAUA;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../src/matrixrtc/types.ts"],"sourcesContent":["/*\nCopyright 2023-2026 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\nimport type { IContent, IMentions } from \"../matrix.ts\";\nimport type { RelationEvent } from \"../types.ts\";\nimport type { CallMembership } from \"./CallMembership.ts\";\nimport { type CallMembershipIdentityParts } from \"./EncryptionManager.ts\";\n\nexport type EncryptionKeyMapKey = string;\n\nexport interface EncryptionKeyEntry {\n index: number;\n key: string;\n}\n\n/**\n * The mxID, deviceId and membership timestamp of a RTC session participant.\n */\nexport type ParticipantDeviceInfo = {\n userId: string;\n deviceId: string;\n membershipTs: number;\n};\n\n/**\n * A type representing the information needed to decrypt video streams.\n */\nexport type InboundEncryptionSession = {\n key: Uint8Array<ArrayBuffer>;\n membership: CallMembershipIdentityParts;\n keyIndex: number;\n creationTS: number;\n};\n\n/**\n * The information about the key used to encrypt video streams.\n */\nexport type OutboundEncryptionSession = {\n key: Uint8Array<ArrayBuffer>;\n creationTS: number;\n // The devices that this key is shared with.\n sharedWith: Array<ParticipantDeviceInfo>;\n // This is an index acting as the id of the key\n keyId: number;\n};\n\nexport interface EncryptionKeysEventContent {\n keys: EncryptionKeyEntry[];\n device_id: string;\n call_id: string;\n sent_ts?: number;\n}\n\n/**\n * THe content of a to-device event that contains encryption keys.\n */\nexport interface EncryptionKeysToDeviceEventContent {\n keys: { index: number; key: string };\n member: {\n id: string;\n // TODO Remove that it is claimed, need to get the sealed sender from decryption info\n // Or add some validation on it based on the encryption info\n claimed_device_id: string;\n };\n room_id: string;\n session: {\n application: string;\n call_id: string;\n scope: string;\n };\n // Why is this needed?\n sent_ts?: number;\n}\n/**\n * @deprecated Use `RTCNotificationType` instead.\n */\nexport type CallNotifyType = \"ring\" | \"notify\";\n/**\n * @deprecated Use `IRTCNotificationContent` instead.\n */\nexport interface ICallNotifyContent {\n \"application\": string;\n \"m.mentions\": IMentions;\n \"notify_type\": CallNotifyType;\n \"call_id\": string;\n}\n\nexport type RTCNotificationType = \"ring\" | \"notification\";\n\n/**\n * Represents the intention of the call from the perspective of the sending user.\n * May be any string, although `\"audio\"` and `\"video\"` are commonly accepted values.\n */\nexport type RTCCallIntent = \"audio\" | \"video\" | string;\n\n/**\n * This will check if the content has all the expected fields to be a valid IRTCNotificationContent.\n * It will also cap the lifetime to 90000ms (1.5 min) if a higher value is provided.\n * @param content\n * @throws if the content is invalid\n * @returns a parsed IRTCNotificationContent\n */\nexport function parseCallNotificationContent(content: IContent): IRTCNotificationContent {\n if (content[\"m.mentions\"] && typeof content[\"m.mentions\"] !== \"object\") {\n throw new Error(\"malformed m.mentions\");\n }\n if (typeof content[\"notification_type\"] !== \"string\") {\n throw new Error(\"Missing or invalid notification_type\");\n }\n if (typeof content[\"sender_ts\"] !== \"number\") {\n throw new Error(\"Missing or invalid sender_ts\");\n }\n if (typeof content[\"lifetime\"] !== \"number\") {\n throw new Error(\"Missing or invalid lifetime\");\n }\n\n if (content[\"relation\"] && content[\"relation\"][\"rel_type\"] !== \"m.reference\") {\n throw new Error(\"Invalid relation\");\n }\n if (content[\"m.call.intent\"] && typeof content[\"m.call.intent\"] !== \"string\") {\n throw new Error(\"Invalid m.call.intent\");\n }\n\n const cappedLifetime = content[\"lifetime\"] >= 90000 ? 90000 : content[\"lifetime\"];\n return { ...content, lifetime: cappedLifetime } as IRTCNotificationContent;\n}\n\n/**\n * Interface for `org.matrix.msc4075.rtc.notification` events.\n * Don't cast event content to this directly. Use `parseCallNotificationContent` instead to validate the content first.\n */\nexport interface IRTCNotificationContent extends RelationEvent {\n \"m.mentions\"?: IMentions;\n \"notification_type\": RTCNotificationType;\n /**\n * The initial intent of the calling user.\n */\n \"m.call.intent\"?: RTCCallIntent;\n \"sender_ts\": number;\n \"lifetime\": number;\n}\n\n/**\n * MSC4310 decline event content for `org.matrix.msc4310.rtc.decline`.\n * Sent as a standard m.reference relation to an `org.matrix.msc4075.rtc.notification` event.\n */\nexport interface IRTCDeclineContent extends RelationEvent {}\n\nexport enum Status {\n Disconnected = \"Disconnected\",\n Connecting = \"Connecting\",\n Connected = \"Connected\",\n Disconnecting = \"Disconnecting\",\n Unknown = \"Unknown\",\n}\n\n/**\n * A type collecting call encryption statistics for a session.\n */\nexport type Statistics = {\n counters: {\n /**\n * The number of times we have sent a room event containing encryption keys.\n */\n roomEventEncryptionKeysSent: number;\n /**\n * The number of times we have received a room event containing encryption keys.\n */\n roomEventEncryptionKeysReceived: number;\n };\n totals: {\n /**\n * The total age (in milliseconds) of all room events containing encryption keys that we have received.\n * We track the total age so that we can later calculate the average age of all keys received.\n */\n roomEventEncryptionKeysReceivedTotalAge: number;\n };\n};\n\nexport const isMyMembership = (m: CallMembership, userId: string, deviceId: string): boolean =>\n m.sender === userId && m.deviceId === deviceId;\n\n/**\n * A RTC transport is a JSON object that describes how to connect to a RTC member.\n */\nexport interface Transport {\n type: string;\n [key: string]: unknown;\n}\n\n/**\n * Event content for a `m.rtc.slot` state event.\n */\nexport interface RtcSlotEventContent<T extends string = string> {\n application: {\n type: T;\n // other application specific keys\n [key: string]: unknown;\n };\n slot_id: string;\n}\n\n/**\n * The session description is used to identify a session. Used in the state event.\n */\nexport interface SlotDescription {\n /**\n * The application type. e.g. \"m.call\".\n */\n application: string;\n /**\n * The application-specific slot ID. e.g. \"ROOM\".\n */\n id: string;\n}\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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