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
package/lib/embedded.js CHANGED
@@ -1,9 +1,5 @@
1
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
1
+ import _objectSpread from "@babel/runtime/helpers/objectSpread2";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
- 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; }
4
- 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; }
5
- function _asyncIterator(r) { var n, t, o, e = 2; for ("undefined" != typeof Symbol && (t = Symbol.asyncIterator, o = Symbol.iterator); e--;) { if (t && null != (n = r[t])) return n.call(r); if (o && null != (n = r[o])) return new AsyncFromSyncIterator(n.call(r)); t = "@@asyncIterator", o = "@@iterator"; } throw new TypeError("Object is not async iterable"); }
6
- function AsyncFromSyncIterator(r) { function AsyncFromSyncIteratorContinuation(r) { if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object.")); var n = r.done; return Promise.resolve(r.value).then(function (r) { return { value: r, done: n }; }); } return AsyncFromSyncIterator = function AsyncFromSyncIterator(r) { this.s = r, this.n = r.next; }, AsyncFromSyncIterator.prototype = { s: null, n: null, next: function next() { return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments)); }, return: function _return(r) { var n = this.s.return; return void 0 === n ? Promise.resolve({ value: r, done: !0 }) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments)); }, throw: function _throw(r) { var n = this.s.return; return void 0 === n ? Promise.reject(r) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments)); } }, new AsyncFromSyncIterator(r); }
7
3
  /*
8
4
  Copyright 2022 The Matrix.org Foundation C.I.C.
9
5
 
@@ -32,7 +28,7 @@ import { ConnectionError, MatrixError } from "./http-api/errors.js";
32
28
  import { User } from "./models/user.js";
33
29
  import { MapWithDefault, recursiveMapToObject } from "./utils.js";
34
30
  import { TypedEventEmitter, UnsupportedDelayedEventsEndpointError } from "./matrix.js";
35
- export var RoomWidgetClientEvent = /*#__PURE__*/function (RoomWidgetClientEvent) {
31
+ export let RoomWidgetClientEvent = /*#__PURE__*/function (RoomWidgetClientEvent) {
36
32
  RoomWidgetClientEvent["PendingEventsChanged"] = "PendingEvent.pendingEventsChanged";
37
33
  return RoomWidgetClientEvent;
38
34
  }({});
@@ -52,13 +48,8 @@ export class RoomWidgetClient extends MatrixClient {
52
48
  * Set to `false` if the widget uses `waitForIFrameLoad=true` (in this case the client does not expect a content loaded action at all),
53
49
  * or if the the widget wants to send the `ContentLoaded` action at a later point in time after the initial setup.
54
50
  */
55
- constructor(widgetApi, capabilities, roomId, opts, sendContentLoaded) {
56
- var _this, _capabilities$receive;
51
+ constructor(widgetApi, capabilities, _roomId, opts, sendContentLoaded) {
57
52
  super(opts);
58
- _this = this;
59
- this.widgetApi = widgetApi;
60
- this.capabilities = capabilities;
61
- this.roomId = roomId;
62
53
  _defineProperty(this, "room", void 0);
63
54
  _defineProperty(this, "widgetApiReady", void 0);
64
55
  _defineProperty(this, "roomStateSynced", void 0);
@@ -67,180 +58,153 @@ export class RoomWidgetClient extends MatrixClient {
67
58
  _defineProperty(this, "pendingSendingEventsTxId", []);
68
59
  _defineProperty(this, "eventEmitter", new TypedEventEmitter());
69
60
  _defineProperty(this, "syncApiResolver", Promise.withResolvers());
70
- _defineProperty(this, "updateTxId", /*#__PURE__*/function () {
71
- var _ref = _asyncToGenerator(function* (event) {
72
- // We update the txId for remote echos that originate from this client.
73
- // This happens with the help of `pendingSendingEventsTxId` where we store all events that are currently sending
74
- // with their widget txId and once ready the final evId.
75
- if (
76
- // This could theoretically be an event send by this device
77
- // In that case we need to update the txId of the event because the embedded client/widget
78
- // knows this event with a different transaction Id than what was used by the host client.
79
- event.getSender() === _this.getUserId() &&
80
- // We optimize by not blocking events from types that we have not send
81
- // with this client.
82
- _this.pendingSendingEventsTxId.some(p => event.getType() === p.type)) {
83
- var _this$pendingSendingE;
84
- // Compare by event Id if we have a matching pending event where we know the txId.
85
- var matchingTxId = (_this$pendingSendingE = _this.pendingSendingEventsTxId.find(p => p.id === event.getId())) === null || _this$pendingSendingE === void 0 ? void 0 : _this$pendingSendingE.txId;
86
- // Block any further processing of this event until we have received the sending response.
87
- // -> until we know the event id.
88
- // -> until we have not pending events anymore.
89
- while (!matchingTxId && _this.pendingSendingEventsTxId.length > 0) {
90
- var _this$pendingSendingE2;
91
- // Recheck whenever the PendingEventsChanged
92
- yield new Promise(resolve => _this.eventEmitter.once(RoomWidgetClientEvent.PendingEventsChanged, () => resolve()));
93
- matchingTxId = (_this$pendingSendingE2 = _this.pendingSendingEventsTxId.find(p => p.id === event.getId())) === null || _this$pendingSendingE2 === void 0 ? void 0 : _this$pendingSendingE2.txId;
94
- }
61
+ _defineProperty(this, "updateTxId", async event => {
62
+ // We update the txId for remote echos that originate from this client.
63
+ // This happens with the help of `pendingSendingEventsTxId` where we store all events that are currently sending
64
+ // with their widget txId and once ready the final evId.
65
+ if (
66
+ // This could theoretically be an event send by this device
67
+ // In that case we need to update the txId of the event because the embedded client/widget
68
+ // knows this event with a different transaction Id than what was used by the host client.
69
+ event.getSender() === this.getUserId() &&
70
+ // We optimize by not blocking events from types that we have not send
71
+ // with this client.
72
+ this.pendingSendingEventsTxId.some(p => event.getType() === p.type)) {
73
+ // Compare by event Id if we have a matching pending event where we know the txId.
74
+ let matchingTxId = this.pendingSendingEventsTxId.find(p => p.id === event.getId())?.txId;
75
+ // Block any further processing of this event until we have received the sending response.
76
+ // -> until we know the event id.
77
+ // -> until we have not pending events anymore.
78
+ while (!matchingTxId && this.pendingSendingEventsTxId.length > 0) {
79
+ // Recheck whenever the PendingEventsChanged
80
+ await new Promise(resolve => this.eventEmitter.once(RoomWidgetClientEvent.PendingEventsChanged, () => resolve()));
81
+ matchingTxId = this.pendingSendingEventsTxId.find(p => p.id === event.getId())?.txId;
82
+ }
95
83
 
96
- // We found the correct txId: we update the event and delete the entry of the pending events.
97
- if (matchingTxId) {
98
- event.setTxnId(matchingTxId);
99
- event.setUnsigned(_objectSpread(_objectSpread({}, event.getUnsigned()), {}, {
100
- transaction_id: matchingTxId
101
- }));
102
- }
103
- _this.pendingSendingEventsTxId = _this.pendingSendingEventsTxId.filter(p => p.id !== event.getId());
84
+ // We found the correct txId: we update the event and delete the entry of the pending events.
85
+ if (matchingTxId) {
86
+ event.setTxnId(matchingTxId);
87
+ event.setUnsigned(_objectSpread(_objectSpread({}, event.getUnsigned()), {}, {
88
+ transaction_id: matchingTxId
89
+ }));
90
+ }
91
+ this.pendingSendingEventsTxId = this.pendingSendingEventsTxId.filter(p => p.id !== event.getId());
104
92
 
105
- // Emit once there are no pending events anymore to release all other events that got
106
- // awaited in the `while (!matchingTxId && this.pendingSendingEventsTxId.length > 0)` loop
107
- // but are not send by this client.
108
- if (_this.pendingSendingEventsTxId.length === 0) {
109
- _this.eventEmitter.emit(RoomWidgetClientEvent.PendingEventsChanged);
110
- }
93
+ // Emit once there are no pending events anymore to release all other events that got
94
+ // awaited in the `while (!matchingTxId && this.pendingSendingEventsTxId.length > 0)` loop
95
+ // but are not send by this client.
96
+ if (this.pendingSendingEventsTxId.length === 0) {
97
+ this.eventEmitter.emit(RoomWidgetClientEvent.PendingEventsChanged);
111
98
  }
112
- });
113
- return function (_x) {
114
- return _ref.apply(this, arguments);
115
- };
116
- }());
117
- _defineProperty(this, "onEvent", /*#__PURE__*/function () {
118
- var _ref2 = _asyncToGenerator(function* (ev) {
119
- ev.preventDefault();
99
+ }
100
+ });
101
+ _defineProperty(this, "onEvent", async ev => {
102
+ ev.preventDefault();
120
103
 
121
- // Verify the room ID matches, since it's possible for the client to
122
- // send us events from other rooms if this widget is always on screen
123
- if (ev.detail.data.room_id === _this.roomId) {
124
- var _event = new MatrixEvent(ev.detail.data);
104
+ // Verify the room ID matches, since it's possible for the client to
105
+ // send us events from other rooms if this widget is always on screen
106
+ if (ev.detail.data.room_id === this.roomId) {
107
+ const event = new MatrixEvent(ev.detail.data);
125
108
 
126
- // Only inject once we have update the txId
127
- yield _this.updateTxId(_event);
128
- yield _this.syncApiResolver.promise;
129
- if (_this.syncApi instanceof SyncApi) {
130
- if (yield _this.supportUpdateState()) {
131
- yield _this.syncApi.injectRoomEvents(_this.room, undefined, [], [_event]);
132
- } else {
133
- // Passing undefined for `stateAfterEventList` will make `injectRoomEvents` run in legacy mode
134
- // -> state events in `timelineEventList` will update the state.
135
- yield _this.syncApi.injectRoomEvents(_this.room, [], undefined, [_event]);
136
- }
109
+ // Only inject once we have update the txId
110
+ await this.updateTxId(event);
111
+ await this.syncApiResolver.promise;
112
+ if (this.syncApi instanceof SyncApi) {
113
+ if (await this.supportUpdateState()) {
114
+ await this.syncApi.injectRoomEvents(this.room, undefined, [], [event]);
137
115
  } else {
138
- // Sliding Sync
139
- if (yield _this.supportUpdateState()) {
140
- yield _this.syncApi.injectRoomEvents(_this.room, [], [_event]);
141
- } else {
142
- logger.error("slididng sync cannot be used in widget mode if the client widget driver does not support the version: 'org.matrix.msc2762_update_state'");
143
- }
116
+ // Passing undefined for `stateAfterEventList` will make `injectRoomEvents` run in legacy mode
117
+ // -> state events in `timelineEventList` will update the state.
118
+ await this.syncApi.injectRoomEvents(this.room, [], undefined, [event]);
144
119
  }
145
- _this.emit(ClientEvent.Event, _event);
146
- if (_event.unstableStickyInfo !== undefined) _this.room._unstable_addStickyEvents([_event]);
147
- _this.setSyncState(SyncState.Syncing);
148
- logger.info("Received event ".concat(_event.getId(), " ").concat(_event.getType()));
149
120
  } else {
150
- var _ev$detail$data = ev.detail.data,
151
- eventId = _ev$detail$data.event_id,
152
- _roomId = _ev$detail$data.room_id;
153
- logger.info("Received event ".concat(eventId, " for a different room ").concat(_roomId, "; discarding"));
154
- }
155
- yield _this.ack(ev);
156
- });
157
- return function (_x2) {
158
- return _ref2.apply(this, arguments);
159
- };
160
- }());
161
- _defineProperty(this, "onToDevice", /*#__PURE__*/function () {
162
- var _ref3 = _asyncToGenerator(function* (ev) {
163
- ev.preventDefault();
164
- var event = new MatrixEvent({
165
- type: ev.detail.data.type,
166
- sender: ev.detail.data.sender,
167
- content: ev.detail.data.content
168
- });
169
- // Mark the event as encrypted if it was, using fake contents and keys since those are unknown to us
170
- if (ev.detail.data.encrypted) event.makeEncrypted(EventType.RoomMessageEncrypted, {}, "", "");
171
- _this.emit(ClientEvent.ToDeviceEvent, event);
172
- _this.setSyncState(SyncState.Syncing);
173
- yield _this.ack(ev);
174
- });
175
- return function (_x3) {
176
- return _ref3.apply(this, arguments);
177
- };
178
- }());
179
- _defineProperty(this, "onStateUpdate", /*#__PURE__*/function () {
180
- var _ref4 = _asyncToGenerator(function* (ev) {
181
- ev.preventDefault();
182
- if (!(yield _this.supportUpdateState())) {
183
- logger.warn("received update_state widget action but the widget driver did not claim to support 'org.matrix.msc2762_update_state'");
184
- }
185
- yield _this.syncApiResolver.promise;
186
- for (var rawEvent of ev.detail.data.state) {
187
- // Verify the room ID matches, since it's possible for the client to
188
- // send us state updates from other rooms if this widget is always
189
- // on screen
190
- if (rawEvent.room_id === _this.roomId) {
191
- var _event2 = new MatrixEvent(rawEvent);
192
- if (_this.syncApi instanceof SyncApi) {
193
- yield _this.syncApi.injectRoomEvents(_this.room, undefined, [_event2]);
194
- } else {
195
- // Sliding Sync
196
- yield _this.syncApi.injectRoomEvents(_this.room, [_event2]);
197
- }
198
- logger.debug("Updated state entry ".concat(_event2.getType(), " ").concat(_event2.getStateKey(), " to ").concat(_event2.getId()));
121
+ // Sliding Sync
122
+ if (await this.supportUpdateState()) {
123
+ await this.syncApi.injectRoomEvents(this.room, [], [event]);
199
124
  } else {
200
- var _ev$detail$data2 = ev.detail.data,
201
- eventId = _ev$detail$data2.event_id,
202
- _roomId2 = _ev$detail$data2.room_id;
203
- logger.info("Received state entry ".concat(eventId, " for a different room ").concat(_roomId2, "; discarding"));
125
+ logger.error("slididng sync cannot be used in widget mode if the client widget driver does not support the version: 'org.matrix.msc2762_update_state'");
204
126
  }
205
127
  }
206
- yield _this.ack(ev);
207
- });
208
- return function (_x4) {
209
- return _ref4.apply(this, arguments);
210
- };
211
- }());
212
- var transportSend = this.widgetApi.transport.send.bind(this.widgetApi.transport);
213
- this.widgetApi.transport.send = /*#__PURE__*/function () {
214
- var _ref5 = _asyncToGenerator(function* (action, data) {
215
- try {
216
- return yield transportSend(action, data);
217
- } catch (error) {
218
- processAndThrow(error);
219
- }
128
+ this.emit(ClientEvent.Event, event);
129
+ if (event.unstableStickyInfo !== undefined) this.room._unstable_addStickyEvents([event]);
130
+ this.setSyncState(SyncState.Syncing);
131
+ logger.info(`Received event ${event.getId()} ${event.getType()}`);
132
+ } else {
133
+ const {
134
+ event_id: eventId,
135
+ room_id: roomId
136
+ } = ev.detail.data;
137
+ logger.info(`Received event ${eventId} for a different room ${roomId}; discarding`);
138
+ }
139
+ await this.ack(ev);
140
+ });
141
+ _defineProperty(this, "onToDevice", async ev => {
142
+ ev.preventDefault();
143
+ const event = new MatrixEvent({
144
+ type: ev.detail.data.type,
145
+ sender: ev.detail.data.sender,
146
+ content: ev.detail.data.content
220
147
  });
221
- return function (_x5, _x6) {
222
- return _ref5.apply(this, arguments);
223
- };
224
- }();
225
- var transportSendComplete = this.widgetApi.transport.sendComplete.bind(this.widgetApi.transport);
226
- this.widgetApi.transport.sendComplete = /*#__PURE__*/function () {
227
- var _ref6 = _asyncToGenerator(function* (action, data) {
228
- try {
229
- return yield transportSendComplete(action, data);
230
- } catch (error) {
231
- processAndThrow(error);
148
+ // Mark the event as encrypted if it was, using fake contents and keys since those are unknown to us
149
+ if (ev.detail.data.encrypted) event.makeEncrypted(EventType.RoomMessageEncrypted, {}, "", "");
150
+ this.emit(ClientEvent.ToDeviceEvent, event);
151
+ this.setSyncState(SyncState.Syncing);
152
+ await this.ack(ev);
153
+ });
154
+ _defineProperty(this, "onStateUpdate", async ev => {
155
+ ev.preventDefault();
156
+ if (!(await this.supportUpdateState())) {
157
+ logger.warn("received update_state widget action but the widget driver did not claim to support 'org.matrix.msc2762_update_state'");
158
+ }
159
+ await this.syncApiResolver.promise;
160
+ for (const rawEvent of ev.detail.data.state) {
161
+ // Verify the room ID matches, since it's possible for the client to
162
+ // send us state updates from other rooms if this widget is always
163
+ // on screen
164
+ if (rawEvent.room_id === this.roomId) {
165
+ const event = new MatrixEvent(rawEvent);
166
+ if (this.syncApi instanceof SyncApi) {
167
+ await this.syncApi.injectRoomEvents(this.room, undefined, [event]);
168
+ } else {
169
+ // Sliding Sync
170
+ await this.syncApi.injectRoomEvents(this.room, [event]);
171
+ }
172
+ logger.debug(`Updated state entry ${event.getType()} ${event.getStateKey()} to ${event.getId()}`);
173
+ } else {
174
+ const {
175
+ event_id: eventId,
176
+ room_id: roomId
177
+ } = ev.detail.data;
178
+ logger.info(`Received state entry ${eventId} for a different room ${roomId}; discarding`);
232
179
  }
233
- });
234
- return function (_x7, _x8) {
235
- return _ref6.apply(this, arguments);
236
- };
237
- }();
180
+ }
181
+ await this.ack(ev);
182
+ });
183
+ this.widgetApi = widgetApi;
184
+ this.capabilities = capabilities;
185
+ this.roomId = _roomId;
186
+ const transportSend = this.widgetApi.transport.send.bind(this.widgetApi.transport);
187
+ this.widgetApi.transport.send = async (action, data) => {
188
+ try {
189
+ return await transportSend(action, data);
190
+ } catch (error) {
191
+ processAndThrow(error);
192
+ }
193
+ };
194
+ const transportSendComplete = this.widgetApi.transport.sendComplete.bind(this.widgetApi.transport);
195
+ this.widgetApi.transport.sendComplete = async (action, data) => {
196
+ try {
197
+ return await transportSendComplete(action, data);
198
+ } catch (error) {
199
+ processAndThrow(error);
200
+ }
201
+ };
238
202
  this.widgetApiReady = new Promise(resolve => this.widgetApi.once("ready", resolve));
239
- this.roomStateSynced = (_capabilities$receive = capabilities.receiveState) !== null && _capabilities$receive !== void 0 && _capabilities$receive.length ? new Promise(resolve => this.widgetApi.once("action:".concat(WidgetApiToWidgetAction.UpdateState), resolve)) : Promise.resolve();
240
- this.requestInitialCapabilities(capabilities, roomId);
241
- widgetApi.on("action:".concat(WidgetApiToWidgetAction.SendEvent), this.onEvent);
242
- widgetApi.on("action:".concat(WidgetApiToWidgetAction.SendToDevice), this.onToDevice);
243
- widgetApi.on("action:".concat(WidgetApiToWidgetAction.UpdateState), this.onStateUpdate);
203
+ this.roomStateSynced = capabilities.receiveState?.length ? new Promise(resolve => this.widgetApi.once(`action:${WidgetApiToWidgetAction.UpdateState}`, resolve)) : Promise.resolve();
204
+ this.requestInitialCapabilities(capabilities, _roomId);
205
+ widgetApi.on(`action:${WidgetApiToWidgetAction.SendEvent}`, this.onEvent);
206
+ widgetApi.on(`action:${WidgetApiToWidgetAction.SendToDevice}`, this.onToDevice);
207
+ widgetApi.on(`action:${WidgetApiToWidgetAction.UpdateState}`, this.onStateUpdate);
244
208
 
245
209
  // Open communication with the host
246
210
  widgetApi.start();
@@ -252,13 +216,12 @@ export class RoomWidgetClient extends MatrixClient {
252
216
  if (sendContentLoaded) widgetApi.sendContentLoaded();
253
217
  }
254
218
  requestInitialCapabilities(capabilities, roomId) {
255
- var _capabilities$sendEve, _capabilities$receive2, _capabilities$sendSta, _capabilities$receive3, _capabilities$sendEve2, _capabilities$receive4, _capabilities$sendSta2, _capabilities$receive5, _capabilities$sendToD, _capabilities$receive6, _capabilities$sendEve3, _capabilities$sendSta3;
256
219
  // Request capabilities for the functionality this client needs to support
257
- if ((_capabilities$sendEve = capabilities.sendEvent) !== null && _capabilities$sendEve !== void 0 && _capabilities$sendEve.length || (_capabilities$receive2 = capabilities.receiveEvent) !== null && _capabilities$receive2 !== void 0 && _capabilities$receive2.length || capabilities.sendMessage === true || Array.isArray(capabilities.sendMessage) && capabilities.sendMessage.length || capabilities.receiveMessage === true || Array.isArray(capabilities.receiveMessage) && capabilities.receiveMessage.length || (_capabilities$sendSta = capabilities.sendState) !== null && _capabilities$sendSta !== void 0 && _capabilities$sendSta.length || (_capabilities$receive3 = capabilities.receiveState) !== null && _capabilities$receive3 !== void 0 && _capabilities$receive3.length) {
220
+ if (capabilities.sendEvent?.length || capabilities.receiveEvent?.length || capabilities.sendMessage === true || Array.isArray(capabilities.sendMessage) && capabilities.sendMessage.length || capabilities.receiveMessage === true || Array.isArray(capabilities.receiveMessage) && capabilities.receiveMessage.length || capabilities.sendState?.length || capabilities.receiveState?.length) {
258
221
  this.widgetApi.requestCapabilityForRoomTimeline(roomId);
259
222
  }
260
- (_capabilities$sendEve2 = capabilities.sendEvent) === null || _capabilities$sendEve2 === void 0 || _capabilities$sendEve2.forEach(eventType => this.widgetApi.requestCapabilityToSendEvent(eventType));
261
- (_capabilities$receive4 = capabilities.receiveEvent) === null || _capabilities$receive4 === void 0 || _capabilities$receive4.forEach(eventType => this.widgetApi.requestCapabilityToReceiveEvent(eventType));
223
+ capabilities.sendEvent?.forEach(eventType => this.widgetApi.requestCapabilityToSendEvent(eventType));
224
+ capabilities.receiveEvent?.forEach(eventType => this.widgetApi.requestCapabilityToReceiveEvent(eventType));
262
225
  if (capabilities.sendMessage === true) {
263
226
  this.widgetApi.requestCapabilityToSendMessage();
264
227
  } else if (Array.isArray(capabilities.sendMessage)) {
@@ -269,19 +232,17 @@ export class RoomWidgetClient extends MatrixClient {
269
232
  } else if (Array.isArray(capabilities.receiveMessage)) {
270
233
  capabilities.receiveMessage.forEach(msgType => this.widgetApi.requestCapabilityToReceiveMessage(msgType));
271
234
  }
272
- (_capabilities$sendSta2 = capabilities.sendState) === null || _capabilities$sendSta2 === void 0 || _capabilities$sendSta2.forEach(_ref7 => {
273
- var eventType = _ref7.eventType,
274
- stateKey = _ref7.stateKey;
275
- return this.widgetApi.requestCapabilityToSendState(eventType, stateKey);
276
- });
277
- (_capabilities$receive5 = capabilities.receiveState) === null || _capabilities$receive5 === void 0 || _capabilities$receive5.forEach(_ref8 => {
278
- var eventType = _ref8.eventType,
279
- stateKey = _ref8.stateKey;
280
- return this.widgetApi.requestCapabilityToReceiveState(eventType, stateKey);
281
- });
282
- (_capabilities$sendToD = capabilities.sendToDevice) === null || _capabilities$sendToD === void 0 || _capabilities$sendToD.forEach(eventType => this.widgetApi.requestCapabilityToSendToDevice(eventType));
283
- (_capabilities$receive6 = capabilities.receiveToDevice) === null || _capabilities$receive6 === void 0 || _capabilities$receive6.forEach(eventType => this.widgetApi.requestCapabilityToReceiveToDevice(eventType));
284
- if (capabilities.sendDelayedEvents && ((_capabilities$sendEve3 = capabilities.sendEvent) !== null && _capabilities$sendEve3 !== void 0 && _capabilities$sendEve3.length || capabilities.sendMessage === true || Array.isArray(capabilities.sendMessage) && capabilities.sendMessage.length || (_capabilities$sendSta3 = capabilities.sendState) !== null && _capabilities$sendSta3 !== void 0 && _capabilities$sendSta3.length)) {
235
+ capabilities.sendState?.forEach(({
236
+ eventType,
237
+ stateKey
238
+ }) => this.widgetApi.requestCapabilityToSendState(eventType, stateKey));
239
+ capabilities.receiveState?.forEach(({
240
+ eventType,
241
+ stateKey
242
+ }) => this.widgetApi.requestCapabilityToReceiveState(eventType, stateKey));
243
+ capabilities.sendToDevice?.forEach(eventType => this.widgetApi.requestCapabilityToSendToDevice(eventType));
244
+ capabilities.receiveToDevice?.forEach(eventType => this.widgetApi.requestCapabilityToReceiveToDevice(eventType));
245
+ if (capabilities.sendDelayedEvents && (capabilities.sendEvent?.length || capabilities.sendMessage === true || Array.isArray(capabilities.sendMessage) && capabilities.sendMessage.length || capabilities.sendState?.length)) {
285
246
  this.widgetApi.requestCapability(MatrixCapabilities.MSC4157SendDelayedEvent);
286
247
  }
287
248
  if (capabilities.updateDelayedEvents) {
@@ -297,189 +258,159 @@ export class RoomWidgetClient extends MatrixClient {
297
258
  this.widgetApi.requestCapability(MatrixCapabilities.MSC3846TurnServers);
298
259
  }
299
260
  }
300
- supportUpdateState() {
301
- var _this2 = this;
302
- return _asyncToGenerator(function* () {
303
- return (yield _this2.widgetApi.getClientVersions()).includes(UnstableApiVersion.MSC2762_UPDATE_STATE);
304
- })();
261
+ async supportUpdateState() {
262
+ return (await this.widgetApi.getClientVersions()).includes(UnstableApiVersion.MSC2762_UPDATE_STATE);
305
263
  }
306
- startClient() {
307
- var _arguments = arguments,
308
- _this3 = this;
309
- return _asyncToGenerator(function* () {
310
- var opts = _arguments.length > 0 && _arguments[0] !== undefined ? _arguments[0] : {};
311
- _this3.lifecycle = new AbortController();
264
+ async startClient(opts = {}) {
265
+ this.lifecycle = new AbortController();
312
266
 
313
- // Create our own user object artificially (instead of waiting for sync)
314
- // so it's always available, even if the user is not in any rooms etc.
315
- var userId = _this3.getUserId();
316
- if (userId) {
317
- _this3.store.storeUser(new User(userId));
318
- }
267
+ // Create our own user object artificially (instead of waiting for sync)
268
+ // so it's always available, even if the user is not in any rooms etc.
269
+ const userId = this.getUserId();
270
+ if (userId) {
271
+ this.store.storeUser(new User(userId));
272
+ }
319
273
 
320
- // Even though we have no access token and cannot sync, the sync class
321
- // still has some valuable helper methods that we make use of, so we
322
- // instantiate it anyways
323
- if (opts.slidingSync) {
324
- _this3.syncApi = new SlidingSyncSdk(opts.slidingSync, _this3, opts, _this3.buildSyncApiOptions());
325
- } else {
326
- _this3.syncApi = new SyncApi(_this3, opts, _this3.buildSyncApiOptions());
327
- }
328
- _this3.syncApiResolver.resolve();
329
- _this3.room = _this3.syncApi.createRoom(_this3.roomId);
330
- _this3.store.storeRoom(_this3.room);
331
- yield _this3.widgetApiReady;
274
+ // Even though we have no access token and cannot sync, the sync class
275
+ // still has some valuable helper methods that we make use of, so we
276
+ // instantiate it anyways
277
+ if (opts.slidingSync) {
278
+ this.syncApi = new SlidingSyncSdk(opts.slidingSync, this, opts, this.buildSyncApiOptions());
279
+ } else {
280
+ this.syncApi = new SyncApi(this, opts, this.buildSyncApiOptions());
281
+ }
282
+ this.syncApiResolver.resolve();
283
+ this.room = this.syncApi.createRoom(this.roomId);
284
+ this.store.storeRoom(this.room);
285
+ await this.widgetApiReady;
332
286
 
333
- // sync room state:
334
- if (yield _this3.supportUpdateState()) {
335
- // This will resolve once the client driver has sent us all the allowed room state.
336
- yield _this3.roomStateSynced;
337
- } else {
338
- var _this3$capabilities$r, _this3$capabilities$r2;
339
- // Backfill the requested events
340
- // We only get the most recent event for every type + state key combo,
341
- // so it doesn't really matter what order we inject them in
342
- yield Promise.all((_this3$capabilities$r = (_this3$capabilities$r2 = _this3.capabilities.receiveState) === null || _this3$capabilities$r2 === void 0 ? void 0 : _this3$capabilities$r2.map(/*#__PURE__*/function () {
343
- var _ref0 = _asyncToGenerator(function* (_ref9) {
344
- var eventType = _ref9.eventType,
345
- stateKey = _ref9.stateKey;
346
- var rawEvents = yield _this3.widgetApi.readStateEvents(eventType, undefined, stateKey, [_this3.roomId]);
347
- var events = rawEvents.map(rawEvent => new MatrixEvent(rawEvent));
348
- if (_this3.syncApi instanceof SyncApi) {
349
- // Passing events as `stateAfterEventList` will update the state.
350
- yield _this3.syncApi.injectRoomEvents(_this3.room, undefined, events);
351
- } else {
352
- yield _this3.syncApi.injectRoomEvents(_this3.room, events); // Sliding Sync
353
- }
354
- events.forEach(event => {
355
- _this3.emit(ClientEvent.Event, event);
356
- logger.info("Backfilled event ".concat(event.getId(), " ").concat(event.getType(), " ").concat(event.getStateKey()));
357
- });
358
- });
359
- return function (_x9) {
360
- return _ref0.apply(this, arguments);
361
- };
362
- }())) !== null && _this3$capabilities$r !== void 0 ? _this3$capabilities$r : []);
363
- }
364
- if (opts.clientWellKnownPollPeriod !== undefined) {
365
- _this3.clientWellKnownIntervalID = setInterval(() => {
366
- _this3.fetchClientWellKnown();
367
- }, 1000 * opts.clientWellKnownPollPeriod);
368
- _this3.fetchClientWellKnown();
369
- }
370
- _this3.setSyncState(SyncState.Syncing);
371
- logger.info("Finished initial sync");
372
- _this3.matrixRTC.start();
287
+ // sync room state:
288
+ if (await this.supportUpdateState()) {
289
+ // This will resolve once the client driver has sent us all the allowed room state.
290
+ await this.roomStateSynced;
291
+ } else {
292
+ // Backfill the requested events
293
+ // We only get the most recent event for every type + state key combo,
294
+ // so it doesn't really matter what order we inject them in
295
+ await Promise.all(this.capabilities.receiveState?.map(async ({
296
+ eventType,
297
+ stateKey
298
+ }) => {
299
+ const rawEvents = await this.widgetApi.readStateEvents(eventType, undefined, stateKey, [this.roomId]);
300
+ const events = rawEvents.map(rawEvent => new MatrixEvent(rawEvent));
301
+ if (this.syncApi instanceof SyncApi) {
302
+ // Passing events as `stateAfterEventList` will update the state.
303
+ await this.syncApi.injectRoomEvents(this.room, undefined, events);
304
+ } else {
305
+ await this.syncApi.injectRoomEvents(this.room, events); // Sliding Sync
306
+ }
307
+ events.forEach(event => {
308
+ this.emit(ClientEvent.Event, event);
309
+ logger.info(`Backfilled event ${event.getId()} ${event.getType()} ${event.getStateKey()}`);
310
+ });
311
+ }) ?? []);
312
+ }
313
+ if (opts.clientWellKnownPollPeriod !== undefined) {
314
+ this.clientWellKnownIntervalID = setInterval(() => {
315
+ this.fetchClientWellKnown();
316
+ }, 1000 * opts.clientWellKnownPollPeriod);
317
+ this.fetchClientWellKnown();
318
+ }
319
+ this.setSyncState(SyncState.Syncing);
320
+ logger.info("Finished initial sync");
321
+ this.matrixRTC.start();
373
322
 
374
- // Watch for TURN servers, if requested
375
- if (_this3.capabilities.turnServers) _this3.watchTurnServers();
376
- })();
323
+ // Watch for TURN servers, if requested
324
+ if (this.capabilities.turnServers) this.watchTurnServers();
377
325
  }
378
326
  stopClient() {
379
- this.widgetApi.off("action:".concat(WidgetApiToWidgetAction.SendEvent), this.onEvent);
380
- this.widgetApi.off("action:".concat(WidgetApiToWidgetAction.SendToDevice), this.onToDevice);
381
- this.widgetApi.off("action:".concat(WidgetApiToWidgetAction.UpdateState), this.onStateUpdate);
327
+ this.widgetApi.off(`action:${WidgetApiToWidgetAction.SendEvent}`, this.onEvent);
328
+ this.widgetApi.off(`action:${WidgetApiToWidgetAction.SendToDevice}`, this.onToDevice);
329
+ this.widgetApi.off(`action:${WidgetApiToWidgetAction.UpdateState}`, this.onStateUpdate);
382
330
  super.stopClient();
383
331
  this.lifecycle.abort(); // Signal to other async tasks that the client has stopped
384
332
  }
385
- joinRoom(roomIdOrAlias) {
386
- var _this4 = this;
387
- return _asyncToGenerator(function* () {
388
- if (roomIdOrAlias === _this4.roomId) return _this4.room;
389
- throw new Error("Unknown room: ".concat(roomIdOrAlias));
390
- })();
333
+ async joinRoom(roomIdOrAlias) {
334
+ if (roomIdOrAlias === this.roomId) return this.room;
335
+ throw new Error(`Unknown room: ${roomIdOrAlias}`);
391
336
  }
392
- encryptAndSendEvent(room, event, delayOptsOrQuery, queryDict) {
393
- var _this5 = this;
394
- return _asyncToGenerator(function* () {
395
- var _queryOpts;
396
- var queryOpts = queryDict;
397
- var delayOpts;
398
- if (delayOptsOrQuery && isSendDelayedEventRequestOpts(delayOptsOrQuery)) {
399
- delayOpts = delayOptsOrQuery;
400
- } else if (!queryOpts) {
401
- queryOpts = delayOptsOrQuery;
402
- }
403
- var stickyDurationMs = (_queryOpts = queryOpts) === null || _queryOpts === void 0 ? void 0 : _queryOpts["org.matrix.msc4354.sticky_duration_ms"];
404
- if (stickyDurationMs !== undefined && typeof stickyDurationMs !== "number") {
405
- throw new Error("Sticky duration must be a number when defined");
406
- }
407
- // This is save since we just checked that above
408
- // We need the additional as assertion for the EW linter to be happy.
409
- // It is not capable of implying the type based on the throw if `stickyDurationMs !== undefined && typeof stickyDurationMs !== "number"`
410
- // above
411
- var stickyDurationMsAsNumber = stickyDurationMs;
337
+ async encryptAndSendEvent(room, event, delayOptsOrQuery, queryDict) {
338
+ let queryOpts = queryDict;
339
+ let delayOpts;
340
+ if (delayOptsOrQuery && isSendDelayedEventRequestOpts(delayOptsOrQuery)) {
341
+ delayOpts = delayOptsOrQuery;
342
+ } else if (!queryOpts) {
343
+ queryOpts = delayOptsOrQuery;
344
+ }
345
+ const stickyDurationMs = queryOpts?.["org.matrix.msc4354.sticky_duration_ms"];
346
+ if (stickyDurationMs !== undefined && typeof stickyDurationMs !== "number") {
347
+ throw new Error("Sticky duration must be a number when defined");
348
+ }
349
+ // This is save since we just checked that above
350
+ // We need the additional as assertion for the EW linter to be happy.
351
+ // It is not capable of implying the type based on the throw if `stickyDurationMs !== undefined && typeof stickyDurationMs !== "number"`
352
+ // above
353
+ const stickyDurationMsAsNumber = stickyDurationMs;
412
354
 
413
- // We need to extend the content with the redacts parameter
414
- // The js sdk uses event.redacts but the widget api uses event.content.redacts
415
- // This will be converted back to event.redacts in the widget driver.
416
- var content = event.event.redacts ? _objectSpread(_objectSpread({}, event.getContent()), {}, {
417
- redacts: event.event.redacts
418
- }) : event.getContent();
355
+ // We need to extend the content with the redacts parameter
356
+ // The js sdk uses event.redacts but the widget api uses event.content.redacts
357
+ // This will be converted back to event.redacts in the widget driver.
358
+ const content = event.event.redacts ? _objectSpread(_objectSpread({}, event.getContent()), {}, {
359
+ redacts: event.event.redacts
360
+ }) : event.getContent();
419
361
 
420
- // Delayed event special case.
421
- if (delayOpts) {
422
- // TODO: updatePendingEvent for delayed events?
423
- var _response = yield _this5.widgetApi.sendRoomEvent(event.getType(), content, room.roomId, "delay" in delayOpts ? delayOpts.delay : undefined, "parent_delay_id" in delayOpts ? delayOpts.parent_delay_id : undefined, stickyDurationMsAsNumber).catch(timeoutToConnectionError);
424
- return _this5.validateSendDelayedEventResponse(_response);
425
- }
426
- var txId = event.getTxnId();
427
- // Add the txnId to the pending list (still with unknown evID)
428
- if (txId) _this5.pendingSendingEventsTxId.push({
429
- type: event.getType(),
430
- id: undefined,
431
- txId
432
- });
433
- var response;
434
- try {
435
- response = yield _this5.widgetApi.sendRoomEvent(event.getType(), content, room.roomId, undefined, undefined, stickyDurationMsAsNumber).catch(timeoutToConnectionError);
436
- } catch (e) {
437
- _this5.updatePendingEventStatus(room, event, EventStatus.NOT_SENT);
438
- throw e;
439
- }
440
- // This also checks for an event id on the response
441
- room.updatePendingEvent(event, EventStatus.SENT, response.event_id);
362
+ // Delayed event special case.
363
+ if (delayOpts) {
364
+ // TODO: updatePendingEvent for delayed events?
365
+ const response = await this.widgetApi.sendRoomEvent(event.getType(), content, room.roomId, "delay" in delayOpts ? delayOpts.delay : undefined, "parent_delay_id" in delayOpts ? delayOpts.parent_delay_id : undefined, stickyDurationMsAsNumber).catch(timeoutToConnectionError);
366
+ return this.validateSendDelayedEventResponse(response);
367
+ }
368
+ const txId = event.getTxnId();
369
+ // Add the txnId to the pending list (still with unknown evID)
370
+ if (txId) this.pendingSendingEventsTxId.push({
371
+ type: event.getType(),
372
+ id: undefined,
373
+ txId
374
+ });
375
+ let response;
376
+ try {
377
+ response = await this.widgetApi.sendRoomEvent(event.getType(), content, room.roomId, undefined, undefined, stickyDurationMsAsNumber).catch(timeoutToConnectionError);
378
+ } catch (e) {
379
+ this.updatePendingEventStatus(room, event, EventStatus.NOT_SENT);
380
+ throw e;
381
+ }
382
+ // This also checks for an event id on the response
383
+ room.updatePendingEvent(event, EventStatus.SENT, response.event_id);
442
384
 
443
- // Update the pending events list with the eventId
444
- _this5.pendingSendingEventsTxId.forEach(p => {
445
- if (p.txId === txId) p.id = response.event_id;
446
- });
447
- _this5.eventEmitter.emit(RoomWidgetClientEvent.PendingEventsChanged);
448
- return {
449
- event_id: response.event_id
450
- };
451
- })();
385
+ // Update the pending events list with the eventId
386
+ this.pendingSendingEventsTxId.forEach(p => {
387
+ if (p.txId === txId) p.id = response.event_id;
388
+ });
389
+ this.eventEmitter.emit(RoomWidgetClientEvent.PendingEventsChanged);
390
+ return {
391
+ event_id: response.event_id
392
+ };
452
393
  }
453
- sendStateEvent(roomId, eventType, content) {
454
- var _arguments2 = arguments,
455
- _this6 = this;
456
- return _asyncToGenerator(function* () {
457
- var stateKey = _arguments2.length > 3 && _arguments2[3] !== undefined ? _arguments2[3] : "";
458
- var response = yield _this6.widgetApi.sendStateEvent(eventType, stateKey, content, roomId).catch(timeoutToConnectionError);
459
- if (response.event_id === undefined) {
460
- throw new Error("'event_id' absent from response to an event request");
461
- }
462
- return {
463
- event_id: response.event_id
464
- };
465
- })();
394
+ async sendStateEvent(roomId, eventType, content, stateKey = "") {
395
+ const response = await this.widgetApi.sendStateEvent(eventType, stateKey, content, roomId).catch(timeoutToConnectionError);
396
+ if (response.event_id === undefined) {
397
+ throw new Error("'event_id' absent from response to an event request");
398
+ }
399
+ return {
400
+ event_id: response.event_id
401
+ };
466
402
  }
467
403
 
468
404
  /**
469
405
  * @experimental This currently relies on an unstable MSC (MSC4140).
470
406
  */
471
407
  // eslint-disable-next-line
472
- _unstable_sendDelayedStateEvent(roomId, delayOpts, eventType, content) {
473
- var _arguments3 = arguments,
474
- _this7 = this;
475
- return _asyncToGenerator(function* () {
476
- var stateKey = _arguments3.length > 4 && _arguments3[4] !== undefined ? _arguments3[4] : "";
477
- if (!(yield _this7.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {
478
- throw new UnsupportedDelayedEventsEndpointError("Server does not support the delayed events API", "sendDelayedStateEvent");
479
- }
480
- var response = yield _this7.widgetApi.sendStateEvent(eventType, stateKey, content, roomId, "delay" in delayOpts ? delayOpts.delay : undefined, "parent_delay_id" in delayOpts ? delayOpts.parent_delay_id : undefined).catch(timeoutToConnectionError);
481
- return _this7.validateSendDelayedEventResponse(response);
482
- })();
408
+ async _unstable_sendDelayedStateEvent(roomId, delayOpts, eventType, content, stateKey = "") {
409
+ if (!(await this.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {
410
+ throw new UnsupportedDelayedEventsEndpointError("Server does not support the delayed events API", "sendDelayedStateEvent");
411
+ }
412
+ const response = await this.widgetApi.sendStateEvent(eventType, stateKey, content, roomId, "delay" in delayOpts ? delayOpts.delay : undefined, "parent_delay_id" in delayOpts ? delayOpts.parent_delay_id : undefined).catch(timeoutToConnectionError);
413
+ return this.validateSendDelayedEventResponse(response);
483
414
  }
484
415
  validateSendDelayedEventResponse(response) {
485
416
  if (response.delay_id === undefined) {
@@ -498,126 +429,103 @@ export class RoomWidgetClient extends MatrixClient {
498
429
  * - {@link _unstable_sendScheduledDelayedEvent}
499
430
  */
500
431
  // eslint-disable-next-line @typescript-eslint/naming-convention
501
- _unstable_updateDelayedEvent(delayId, action) {
502
- var _this8 = this;
503
- return _asyncToGenerator(function* () {
504
- if (!(yield _this8.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {
505
- throw new UnsupportedDelayedEventsEndpointError("Server does not support the delayed events API", "updateDelayedEvent");
506
- }
507
- var updateDelayedEvent;
508
- switch (action) {
509
- case UpdateDelayedEventAction.Cancel:
510
- updateDelayedEvent = _this8.widgetApi.cancelScheduledDelayedEvent;
511
- break;
512
- case UpdateDelayedEventAction.Restart:
513
- updateDelayedEvent = _this8.widgetApi.cancelScheduledDelayedEvent;
514
- break;
515
- case UpdateDelayedEventAction.Send:
516
- updateDelayedEvent = _this8.widgetApi.sendScheduledDelayedEvent;
517
- break;
518
- }
519
- yield updateDelayedEvent.call(_this8.widgetApi, delayId).catch(timeoutToConnectionError);
520
- return {};
521
- })();
432
+ async _unstable_updateDelayedEvent(delayId, action) {
433
+ if (!(await this.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {
434
+ throw new UnsupportedDelayedEventsEndpointError("Server does not support the delayed events API", "updateDelayedEvent");
435
+ }
436
+ switch (action) {
437
+ case UpdateDelayedEventAction.Cancel:
438
+ await this.widgetApi.cancelScheduledDelayedEvent(delayId).catch(timeoutToConnectionError);
439
+ break;
440
+ case UpdateDelayedEventAction.Restart:
441
+ await this.widgetApi.restartScheduledDelayedEvent(delayId).catch(timeoutToConnectionError);
442
+ break;
443
+ case UpdateDelayedEventAction.Send:
444
+ await this.widgetApi.sendScheduledDelayedEvent(delayId).catch(timeoutToConnectionError);
445
+ break;
446
+ }
447
+ return {};
522
448
  }
523
449
 
524
450
  /**
525
451
  * @experimental This currently relies on an unstable MSC (MSC4140).
526
452
  */
527
453
  // eslint-disable-next-line @typescript-eslint/naming-convention
528
- _unstable_cancelScheduledDelayedEvent(delayId) {
529
- var _this9 = this;
530
- return _asyncToGenerator(function* () {
531
- if (!(yield _this9.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {
532
- throw new UnsupportedDelayedEventsEndpointError("Server does not support the delayed events API", "cancelScheduledDelayedEvent");
533
- }
534
- yield _this9.widgetApi.cancelScheduledDelayedEvent(delayId).catch(timeoutToConnectionError);
535
- return {};
536
- })();
454
+ async _unstable_cancelScheduledDelayedEvent(delayId) {
455
+ if (!(await this.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {
456
+ throw new UnsupportedDelayedEventsEndpointError("Server does not support the delayed events API", "cancelScheduledDelayedEvent");
457
+ }
458
+ await this.widgetApi.cancelScheduledDelayedEvent(delayId).catch(timeoutToConnectionError);
459
+ return {};
537
460
  }
538
461
 
539
462
  /**
540
463
  * @experimental This currently relies on an unstable MSC (MSC4140).
541
464
  */
542
465
  // eslint-disable-next-line @typescript-eslint/naming-convention
543
- _unstable_restartScheduledDelayedEvent(delayId) {
544
- var _this0 = this;
545
- return _asyncToGenerator(function* () {
546
- if (!(yield _this0.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {
547
- throw new UnsupportedDelayedEventsEndpointError("Server does not support the delayed events API", "restartScheduledDelayedEvent");
548
- }
549
- yield _this0.widgetApi.restartScheduledDelayedEvent(delayId).catch(timeoutToConnectionError);
550
- return {};
551
- })();
466
+ async _unstable_restartScheduledDelayedEvent(delayId) {
467
+ if (!(await this.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {
468
+ throw new UnsupportedDelayedEventsEndpointError("Server does not support the delayed events API", "restartScheduledDelayedEvent");
469
+ }
470
+ await this.widgetApi.restartScheduledDelayedEvent(delayId).catch(timeoutToConnectionError);
471
+ return {};
552
472
  }
553
473
 
554
474
  /**
555
475
  * @experimental This currently relies on an unstable MSC (MSC4140).
556
476
  */
557
477
  // eslint-disable-next-line @typescript-eslint/naming-convention
558
- _unstable_sendScheduledDelayedEvent(delayId) {
559
- var _this1 = this;
560
- return _asyncToGenerator(function* () {
561
- if (!(yield _this1.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {
562
- throw new UnsupportedDelayedEventsEndpointError("Server does not support the delayed events API", "sendScheduledDelayedEvent");
563
- }
564
- yield _this1.widgetApi.sendScheduledDelayedEvent(delayId).catch(timeoutToConnectionError);
565
- return {};
566
- })();
478
+ async _unstable_sendScheduledDelayedEvent(delayId) {
479
+ if (!(await this.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {
480
+ throw new UnsupportedDelayedEventsEndpointError("Server does not support the delayed events API", "sendScheduledDelayedEvent");
481
+ }
482
+ await this.widgetApi.sendScheduledDelayedEvent(delayId).catch(timeoutToConnectionError);
483
+ return {};
567
484
  }
568
485
 
569
486
  /**
570
487
  * by {@link MatrixClient.encryptAndSendToDevice}.
571
488
  */
572
- encryptAndSendToDevice(eventType, devices, payload) {
573
- var _this10 = this;
574
- return _asyncToGenerator(function* () {
575
- // map: user Id → device Id → payload
576
- var contentMap = new MapWithDefault(() => new Map());
577
- for (var _ref10 of devices) {
578
- var userId = _ref10.userId;
579
- var deviceId = _ref10.deviceId;
580
- contentMap.getOrCreate(userId).set(deviceId, payload);
581
- }
582
- yield _this10.widgetApi.sendToDevice(eventType, true, recursiveMapToObject(contentMap)).catch(timeoutToConnectionError);
583
- })();
489
+ async encryptAndSendToDevice(eventType, devices, payload) {
490
+ // map: user Id → device Id → payload
491
+ const contentMap = new MapWithDefault(() => new Map());
492
+ for (const {
493
+ userId,
494
+ deviceId
495
+ } of devices) {
496
+ contentMap.getOrCreate(userId).set(deviceId, payload);
497
+ }
498
+ await this.widgetApi.sendToDevice(eventType, true, recursiveMapToObject(contentMap)).catch(timeoutToConnectionError);
584
499
  }
585
- sendToDevice(eventType, contentMap) {
586
- var _this11 = this;
587
- return _asyncToGenerator(function* () {
588
- yield _this11.widgetApi.sendToDevice(eventType, false, recursiveMapToObject(contentMap)).catch(timeoutToConnectionError);
589
- return {};
590
- })();
500
+ async sendToDevice(eventType, contentMap) {
501
+ await this.widgetApi.sendToDevice(eventType, false, recursiveMapToObject(contentMap)).catch(timeoutToConnectionError);
502
+ return {};
591
503
  }
592
- getOpenIdToken() {
593
- var _this12 = this;
594
- return _asyncToGenerator(function* () {
595
- var token = yield _this12.widgetApi.requestOpenIDConnectToken().catch(timeoutToConnectionError);
596
- // the IOpenIDCredentials from the widget-api and IOpenIDToken form the matrix-js-sdk are compatible.
597
- // we still recreate the token to make this transparent and catch'able by the linter in case the types change in the future.
598
- return {
599
- access_token: token.access_token,
600
- expires_in: token.expires_in,
601
- matrix_server_name: token.matrix_server_name,
602
- token_type: token.token_type
603
- };
604
- })();
504
+ async getOpenIdToken() {
505
+ const token = await this.widgetApi.requestOpenIDConnectToken().catch(timeoutToConnectionError);
506
+ // the IOpenIDCredentials from the widget-api and IOpenIDToken form the matrix-js-sdk are compatible.
507
+ // we still recreate the token to make this transparent and catch'able by the linter in case the types change in the future.
508
+ return {
509
+ access_token: token.access_token,
510
+ expires_in: token.expires_in,
511
+ matrix_server_name: token.matrix_server_name,
512
+ token_type: token.token_type
513
+ };
605
514
  }
606
- queueToDevice(_ref11) {
607
- var _this13 = this;
608
- return _asyncToGenerator(function* () {
609
- var eventType = _ref11.eventType,
610
- batch = _ref11.batch;
611
- // map: user Id device Id → payload
612
- var contentMap = new MapWithDefault(() => new Map());
613
- for (var _ref13 of batch) {
614
- var userId = _ref13.userId;
615
- var deviceId = _ref13.deviceId;
616
- var payload = _ref13.payload;
617
- contentMap.getOrCreate(userId).set(deviceId, payload);
618
- }
619
- yield _this13.widgetApi.sendToDevice(eventType, false, recursiveMapToObject(contentMap)).catch(timeoutToConnectionError);
620
- })();
515
+ async queueToDevice({
516
+ eventType,
517
+ batch
518
+ }) {
519
+ // map: user Id → device Id → payload
520
+ const contentMap = new MapWithDefault(() => new Map());
521
+ for (const {
522
+ userId,
523
+ deviceId,
524
+ payload
525
+ } of batch) {
526
+ contentMap.getOrCreate(userId).set(deviceId, payload);
527
+ }
528
+ await this.widgetApi.sendToDevice(eventType, false, recursiveMapToObject(contentMap)).catch(timeoutToConnectionError);
621
529
  }
622
530
 
623
531
  /**
@@ -633,20 +541,14 @@ export class RoomWidgetClient extends MatrixClient {
633
541
  * @param encrypted - Whether the event should be encrypted.
634
542
  * @param contentMap - The content to send. Map from user_id to device_id to content object.
635
543
  */
636
- sendToDeviceViaWidgetApi(eventType, encrypted, contentMap) {
637
- var _this14 = this;
638
- return _asyncToGenerator(function* () {
639
- yield _this14.widgetApi.sendToDevice(eventType, encrypted, recursiveMapToObject(contentMap)).catch(timeoutToConnectionError);
640
- })();
544
+ async sendToDeviceViaWidgetApi(eventType, encrypted, contentMap) {
545
+ await this.widgetApi.sendToDevice(eventType, encrypted, recursiveMapToObject(contentMap)).catch(timeoutToConnectionError);
641
546
  }
642
547
 
643
548
  // Overridden since we get TURN servers automatically over the widget API,
644
549
  // and this method would otherwise complain about missing an access token
645
- checkTurnServers() {
646
- var _this15 = this;
647
- return _asyncToGenerator(function* () {
648
- return _this15.turnServers.length > 0;
649
- })();
550
+ async checkTurnServers() {
551
+ return this.turnServers.length > 0;
650
552
  }
651
553
 
652
554
  // Overridden since we 'sync' manually without the sync API
@@ -654,61 +556,34 @@ export class RoomWidgetClient extends MatrixClient {
654
556
  return this.syncState;
655
557
  }
656
558
  setSyncState(state) {
657
- var oldState = this.syncState;
559
+ const oldState = this.syncState;
658
560
  this.syncState = state;
659
561
  this.emit(ClientEvent.Sync, state, oldState);
660
562
  }
661
- ack(ev) {
662
- var _this16 = this;
663
- return _asyncToGenerator(function* () {
664
- yield _this16.widgetApi.transport.reply(ev.detail, {});
665
- })();
563
+ async ack(ev) {
564
+ this.widgetApi.transport.reply(ev.detail, {});
666
565
  }
667
- watchTurnServers() {
668
- var _this17 = this;
669
- return _asyncToGenerator(function* () {
670
- var servers = _this17.widgetApi.getTurnServers();
671
- var onClientStopped = () => {
672
- servers.return(undefined);
673
- };
674
- _this17.lifecycle.signal.addEventListener("abort", onClientStopped);
675
- try {
676
- var _iteratorAbruptCompletion = false;
677
- var _didIteratorError = false;
678
- var _iteratorError;
679
- try {
680
- for (var _iterator = _asyncIterator(servers), _step; _iteratorAbruptCompletion = !(_step = yield _iterator.next()).done; _iteratorAbruptCompletion = false) {
681
- var server = _step.value;
682
- {
683
- _this17.turnServers = [{
684
- urls: server.uris,
685
- username: server.username,
686
- credential: server.password
687
- }];
688
- _this17.emit(ClientEvent.TurnServers, _this17.turnServers);
689
- logger.log("Received TURN server: ".concat(server.uris));
690
- }
691
- }
692
- } catch (err) {
693
- _didIteratorError = true;
694
- _iteratorError = err;
695
- } finally {
696
- try {
697
- if (_iteratorAbruptCompletion && _iterator.return != null) {
698
- yield _iterator.return();
699
- }
700
- } finally {
701
- if (_didIteratorError) {
702
- throw _iteratorError;
703
- }
704
- }
705
- }
706
- } catch (e) {
707
- logger.warn("Error watching TURN servers", e);
708
- } finally {
709
- _this17.lifecycle.signal.removeEventListener("abort", onClientStopped);
566
+ async watchTurnServers() {
567
+ const servers = this.widgetApi.getTurnServers();
568
+ const onClientStopped = () => {
569
+ servers.return(undefined);
570
+ };
571
+ this.lifecycle.signal.addEventListener("abort", onClientStopped);
572
+ try {
573
+ for await (const server of servers) {
574
+ this.turnServers = [{
575
+ urls: server.uris,
576
+ username: server.username,
577
+ credential: server.password
578
+ }];
579
+ this.emit(ClientEvent.TurnServers, this.turnServers);
580
+ logger.log(`Received TURN server: ${server.uris}`);
710
581
  }
711
- })();
582
+ } catch (e) {
583
+ logger.warn("Error watching TURN servers", e);
584
+ } finally {
585
+ this.lifecycle.signal.removeEventListener("abort", onClientStopped);
586
+ }
712
587
  }
713
588
  }
714
589
  function processAndThrow(error) {