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,7 +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
3
  /*
6
4
  Copyright 2021 - 2023 The Matrix.org Foundation C.I.C.
7
5
 
@@ -30,7 +28,7 @@ import { logger } from "../logger.js";
30
28
  import { ReadReceipt } from "./read-receipt.js";
31
29
  import { ReceiptType } from "../@types/read_receipts.js";
32
30
  import { Feature, ServerSupport } from "../feature.js";
33
- export var ThreadEvent = /*#__PURE__*/function (ThreadEvent) {
31
+ export let ThreadEvent = /*#__PURE__*/function (ThreadEvent) {
34
32
  ThreadEvent["New"] = "Thread.new";
35
33
  ThreadEvent["Update"] = "Thread.update";
36
34
  ThreadEvent["NewReply"] = "Thread.newReply";
@@ -38,7 +36,7 @@ export var ThreadEvent = /*#__PURE__*/function (ThreadEvent) {
38
36
  ThreadEvent["Delete"] = "Thread.delete";
39
37
  return ThreadEvent;
40
38
  }({});
41
- export var FeatureSupport = /*#__PURE__*/function (FeatureSupport) {
39
+ export let FeatureSupport = /*#__PURE__*/function (FeatureSupport) {
42
40
  FeatureSupport[FeatureSupport["None"] = 0] = "None";
43
41
  FeatureSupport[FeatureSupport["Experimental"] = 1] = "Experimental";
44
42
  FeatureSupport[FeatureSupport["Stable"] = 2] = "Stable";
@@ -55,12 +53,9 @@ export function determineFeatureSupport(stable, unstable) {
55
53
  }
56
54
  export class Thread extends ReadReceipt {
57
55
  constructor(id, rootEvent, opts) {
58
- var _this, _opts$pendingEventOrd;
59
- // each Event in the thread adds a reemitter, so we could hit the listener limit.
60
56
  super();
61
- _this = this;
62
- this.id = id;
63
- this.rootEvent = rootEvent;
57
+
58
+ // each Event in the thread adds a reemitter, so we could hit the listener limit.
64
59
  /**
65
60
  * A reference to all the events ID at the bottom of the threads
66
61
  */
@@ -119,13 +114,13 @@ export class Thread extends ReadReceipt {
119
114
  * with server suppport.
120
115
  */
121
116
  _defineProperty(this, "replayEvents", []);
122
- _defineProperty(this, "onTimelineReset", /*#__PURE__*/_asyncToGenerator(function* () {
117
+ _defineProperty(this, "onTimelineReset", async () => {
123
118
  // We hit a gappy sync, ask the server for an update
124
- yield _this.processRootEventPromise;
125
- _this.processRootEventPromise = undefined;
126
- }));
119
+ await this.processRootEventPromise;
120
+ this.processRootEventPromise = undefined;
121
+ });
127
122
  _defineProperty(this, "onBeforeRedaction", (event, redaction) => {
128
- if (event !== null && event !== void 0 && event.isRelation(THREAD_RELATION_TYPE.name) && this.room.eventShouldLiveIn(event).threadId === this.id && event.getId() !== this.id &&
123
+ if (event?.isRelation(THREAD_RELATION_TYPE.name) && this.room.eventShouldLiveIn(event).threadId === this.id && event.getId() !== this.id &&
129
124
  // the root event isn't counted in the length so ignore this redaction
130
125
  !redaction.status // only respect it when it succeeds
131
126
  ) {
@@ -134,34 +129,28 @@ export class Thread extends ReadReceipt {
134
129
  this.emit(ThreadEvent.Update, this);
135
130
  }
136
131
  });
137
- _defineProperty(this, "onRedaction", /*#__PURE__*/function () {
138
- var _ref2 = _asyncToGenerator(function* (event, room, threadRootId) {
139
- if (threadRootId !== _this.id) return; // ignore redactions for other timelines
140
- if (_this.replyCount <= 0) {
141
- for (var threadEvent of _this.timeline) {
142
- _this.clearEventMetadata(threadEvent);
143
- }
144
- _this.lastEvent = _this.rootEvent;
145
- _this._currentUserParticipated = false;
146
- _this.emit(ThreadEvent.Delete, _this);
147
- } else {
148
- var _this$lastEvent;
149
- if (((_this$lastEvent = _this.lastEvent) === null || _this$lastEvent === void 0 ? void 0 : _this$lastEvent.getId()) === event.getAssociatedId()) {
150
- // XXX: If our last event got redacted we query the server for the last event once again
151
- yield _this.processRootEventPromise;
152
- _this.processRootEventPromise = undefined;
153
- }
154
- yield _this.updateThreadMetadata();
132
+ _defineProperty(this, "onRedaction", async (event, room, threadRootId) => {
133
+ if (threadRootId !== this.id) return; // ignore redactions for other timelines
134
+ if (this.replyCount <= 0) {
135
+ for (const threadEvent of this.timeline) {
136
+ this.clearEventMetadata(threadEvent);
155
137
  }
156
- });
157
- return function (_x, _x2, _x3) {
158
- return _ref2.apply(this, arguments);
159
- };
160
- }());
138
+ this.lastEvent = this.rootEvent;
139
+ this._currentUserParticipated = false;
140
+ this.emit(ThreadEvent.Delete, this);
141
+ } else {
142
+ if (this.lastEvent?.getId() === event.getAssociatedId()) {
143
+ // XXX: If our last event got redacted we query the server for the last event once again
144
+ await this.processRootEventPromise;
145
+ this.processRootEventPromise = undefined;
146
+ }
147
+ await this.updateThreadMetadata();
148
+ }
149
+ });
161
150
  _defineProperty(this, "onTimelineEvent", (event, room, toStartOfTimeline) => {
162
151
  // Add a synthesized receipt when paginating forward in the timeline
163
152
  if (!toStartOfTimeline) {
164
- var sender = event.getSender();
153
+ const sender = event.getSender();
165
154
  if (sender && room && this.shouldSendLocalEchoReceipt(sender, event)) {
166
155
  room.addLocalEchoReceipt(sender, event, ReceiptType.Read);
167
156
  }
@@ -169,35 +158,32 @@ export class Thread extends ReadReceipt {
169
158
  this.replyCount++;
170
159
  }
171
160
  }
172
- this.onEcho(event, toStartOfTimeline !== null && toStartOfTimeline !== void 0 ? toStartOfTimeline : false);
161
+ this.onEcho(event, toStartOfTimeline ?? false);
173
162
  });
174
163
  _defineProperty(this, "onLocalEcho", event => {
175
164
  this.onEcho(event, false);
176
165
  });
177
- _defineProperty(this, "onEcho", /*#__PURE__*/function () {
178
- var _ref3 = _asyncToGenerator(function* (event, toStartOfTimeline) {
179
- if (event.threadRootId !== _this.id) return; // ignore echoes for other timelines
180
- if (_this.lastEvent === event) return; // ignore duplicate events
181
- yield _this.updateThreadMetadata();
182
- if (!event.isRelation(THREAD_RELATION_TYPE.name)) return; // don't send a new reply event for reactions or edits
183
- if (toStartOfTimeline) return; // ignore messages added to the start of the timeline
184
- // Clear the lastEvent and instead start tracking locally using lastReply
185
- _this.lastEvent = undefined;
186
- _this.emit(ThreadEvent.NewReply, _this, event);
187
- });
188
- return function (_x4, _x5) {
189
- return _ref3.apply(this, arguments);
190
- };
191
- }());
166
+ _defineProperty(this, "onEcho", async (event, toStartOfTimeline) => {
167
+ if (event.threadRootId !== this.id) return; // ignore echoes for other timelines
168
+ if (this.lastEvent === event) return; // ignore duplicate events
169
+ await this.updateThreadMetadata();
170
+ if (!event.isRelation(THREAD_RELATION_TYPE.name)) return; // don't send a new reply event for reactions or edits
171
+ if (toStartOfTimeline) return; // ignore messages added to the start of the timeline
172
+ // Clear the lastEvent and instead start tracking locally using lastReply
173
+ this.lastEvent = undefined;
174
+ this.emit(ThreadEvent.NewReply, this, event);
175
+ });
176
+ this.id = id;
177
+ this.rootEvent = rootEvent;
192
178
  this.setMaxListeners(1000);
193
- if (!(opts !== null && opts !== void 0 && opts.room)) {
179
+ if (!opts?.room) {
194
180
  // Logging/debugging for https://github.com/vector-im/element-web/issues/22141
195
181
  // Hope is that we end up with a more obvious stack trace.
196
182
  throw new Error("element-web#22141: A thread requires a room in order to function");
197
183
  }
198
184
  this.room = opts.room;
199
185
  this.client = opts.client;
200
- this.pendingEventOrdering = (_opts$pendingEventOrd = opts.pendingEventOrdering) !== null && _opts$pendingEventOrd !== void 0 ? _opts$pendingEventOrd : PendingEventOrdering.Chronological;
186
+ this.pendingEventOrdering = opts.pendingEventOrdering ?? PendingEventOrdering.Chronological;
201
187
  this.timelineSet = new EventTimelineSet(this.room, {
202
188
  timelineSupport: true,
203
189
  pendingEvents: true
@@ -216,20 +202,17 @@ export class Thread extends ReadReceipt {
216
202
  this.updateThreadMetadata();
217
203
  this.setEventMetadata(this.rootEvent);
218
204
  }
219
- fetchRootEvent() {
220
- var _this2 = this;
221
- return _asyncToGenerator(function* () {
222
- // Always fetch the root event, even if we already have it, so we can get the latest
223
- // state (via unsigned).
224
- try {
225
- var eventData = yield _this2.client.fetchRoomEvent(_this2.roomId, _this2.id);
226
- var mapper = _this2.client.getEventMapper();
227
- _this2.rootEvent = mapper(eventData); // will merge with existing event object if such is known
228
- } catch (e) {
229
- logger.error("Failed to fetch thread root to construct thread with", e);
230
- }
231
- yield _this2.processEvent(_this2.rootEvent);
232
- })();
205
+ async fetchRootEvent() {
206
+ // Always fetch the root event, even if we already have it, so we can get the latest
207
+ // state (via unsigned).
208
+ try {
209
+ const eventData = await this.client.fetchRoomEvent(this.roomId, this.id);
210
+ const mapper = this.client.getEventMapper();
211
+ this.rootEvent = mapper(eventData); // will merge with existing event object if such is known
212
+ } catch (e) {
213
+ logger.error("Failed to fetch thread root to construct thread with", e);
214
+ }
215
+ await this.processEvent(this.rootEvent);
233
216
  }
234
217
  static setServerSideSupport(status) {
235
218
  Thread.hasServerSideSupport = status;
@@ -247,16 +230,14 @@ export class Thread extends ReadReceipt {
247
230
  Thread.hasServerSideFwdPaginationSupport = status;
248
231
  }
249
232
  shouldSendLocalEchoReceipt(sender, event) {
250
- var _this$client$canSuppo;
251
- var recursionSupport = (_this$client$canSuppo = this.client.canSupport.get(Feature.RelationsRecursion)) !== null && _this$client$canSuppo !== void 0 ? _this$client$canSuppo : ServerSupport.Unsupported;
233
+ const recursionSupport = this.client.canSupport.get(Feature.RelationsRecursion) ?? ServerSupport.Unsupported;
252
234
  if (recursionSupport === ServerSupport.Unsupported) {
253
- var _this$getReadReceiptF;
254
235
  // Normally we add a local receipt, but if we don't have
255
236
  // recursion support, then events may arrive out of order, so we
256
237
  // only create a receipt if it's after our existing receipt.
257
- var oldReceiptEventId = (_this$getReadReceiptF = this.getReadReceiptForUserId(sender)) === null || _this$getReadReceiptF === void 0 ? void 0 : _this$getReadReceiptF.eventId;
238
+ const oldReceiptEventId = this.getReadReceiptForUserId(sender)?.eventId;
258
239
  if (oldReceiptEventId) {
259
- var receiptEvent = this.findEventById(oldReceiptEventId);
240
+ const receiptEvent = this.findEventById(oldReceiptEventId);
260
241
  if (receiptEvent && receiptEvent.getTs() > event.getTs()) {
261
242
  return false;
262
243
  }
@@ -292,7 +273,7 @@ export class Thread extends ReadReceipt {
292
273
  * @internal
293
274
  */
294
275
  insertEventIntoTimeline(event) {
295
- var eventId = event.getId();
276
+ const eventId = event.getId();
296
277
  if (!eventId) {
297
278
  return;
298
279
  }
@@ -316,15 +297,14 @@ export class Thread extends ReadReceipt {
316
297
  * to the start (and not the end) of the timeline.
317
298
  * @param emit - whether to emit the Update event if the thread was updated or not.
318
299
  */
319
- addEvent(event, toStartOfTimeline) {
320
- var emit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
300
+ addEvent(event, toStartOfTimeline, emit = true) {
321
301
  // Modify this event to point at our room's state, and mark its thread
322
302
  // as this.
323
303
  this.setEventMetadata(event);
324
304
 
325
305
  // Decide whether this event is going to be added at the end of the timeline.
326
- var lastReply = this.lastReply();
327
- var isNewestReply = !lastReply || event.localTimestamp >= lastReply.localTimestamp;
306
+ const lastReply = this.lastReply();
307
+ const isNewestReply = !lastReply || event.localTimestamp >= lastReply.localTimestamp;
328
308
  if (!Thread.hasServerSideSupport) {
329
309
  // When there's no server-side support, just add it to the end of the timeline.
330
310
  this.addEventToTimeline(event, toStartOfTimeline);
@@ -369,7 +349,6 @@ export class Thread extends ReadReceipt {
369
349
  // reference to something that is, then we have two cases:
370
350
 
371
351
  if (!this.initialEventsFetched) {
372
- var _this$replayEvents;
373
352
  // Case 1: we haven't yet fetched events from the server. In
374
353
  // this case, when we do, the events we get back might only be
375
354
  // the first-order ones, so this event (which is second-order -
@@ -385,17 +364,15 @@ export class Thread extends ReadReceipt {
385
364
  * This fix keeps a reference to those events and replay them once the thread
386
365
  * has been initialised properly.
387
366
  */
388
- (_this$replayEvents = this.replayEvents) === null || _this$replayEvents === void 0 || _this$replayEvents.push(event);
367
+ this.replayEvents?.push(event);
389
368
 
390
369
  // For annotations (reactions), aggregate immediately (pre-init) to keep
391
370
  // reaction counts/summary visible while the thread is still initialising.
392
371
  // Only aggregate as child: parent aggregation is unnecessary here.
393
372
  if (event.isRelation(RelationType.Annotation)) {
394
- var _this$timelineSet$rel;
395
- (_this$timelineSet$rel = this.timelineSet.relations) === null || _this$timelineSet$rel === void 0 || _this$timelineSet$rel.aggregateChildEvent(event, this.timelineSet);
373
+ this.timelineSet.relations?.aggregateChildEvent(event, this.timelineSet);
396
374
  }
397
375
  } else {
398
- var _this$client$canSuppo2;
399
376
  // Case 2: this is happening later, and we have a timeline. In
400
377
  // this case, these events might be out-of order.
401
378
  //
@@ -413,7 +390,7 @@ export class Thread extends ReadReceipt {
413
390
  // (Note that both insertEventIntoTimeline and addEventToTimeline
414
391
  // do nothing if we have seen this event before.)
415
392
 
416
- var recursionSupport = (_this$client$canSuppo2 = this.client.canSupport.get(Feature.RelationsRecursion)) !== null && _this$client$canSuppo2 !== void 0 ? _this$client$canSuppo2 : ServerSupport.Unsupported;
393
+ const recursionSupport = this.client.canSupport.get(Feature.RelationsRecursion) ?? ServerSupport.Unsupported;
417
394
  if (recursionSupport === ServerSupport.Unsupported) {
418
395
  this.insertEventIntoTimeline(event);
419
396
  } else {
@@ -422,14 +399,11 @@ export class Thread extends ReadReceipt {
422
399
  // Aggregation is handled by EventTimelineSet when inserting/adding.
423
400
  }
424
401
  }
425
- processEvent(event) {
426
- var _this3 = this;
427
- return _asyncToGenerator(function* () {
428
- if (event) {
429
- _this3.setEventMetadata(event);
430
- yield _this3.fetchEditsWhereNeeded(event);
431
- }
432
- })();
402
+ async processEvent(event) {
403
+ if (event) {
404
+ this.setEventMetadata(event);
405
+ await this.fetchEditsWhereNeeded(event);
406
+ }
433
407
  }
434
408
 
435
409
  /**
@@ -438,44 +412,37 @@ export class Thread extends ReadReceipt {
438
412
  * and apply them to the current thread
439
413
  * @param receipts - A collection of the receipts cached from initial sync
440
414
  */
441
- processReceipts() {
442
- var receipts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
443
- for (var _ref5 of receipts) {
444
- var eventId = _ref5.eventId;
445
- var receiptType = _ref5.receiptType;
446
- var userId = _ref5.userId;
447
- var receipt = _ref5.receipt;
448
- var synthetic = _ref5.synthetic;
415
+ processReceipts(receipts = []) {
416
+ for (const {
417
+ eventId,
418
+ receiptType,
419
+ userId,
420
+ receipt,
421
+ synthetic
422
+ } of receipts) {
449
423
  this.addReceiptToStructure(eventId, receiptType, userId, receipt, synthetic);
450
424
  }
451
425
  }
452
- getRootEventBundledRelationship() {
453
- var rootEvent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.rootEvent;
454
- return rootEvent === null || rootEvent === void 0 ? void 0 : rootEvent.getServerAggregatedRelation(THREAD_RELATION_TYPE.name);
455
- }
456
- processRootEvent() {
457
- var _this4 = this;
458
- return _asyncToGenerator(function* () {
459
- var bundledRelationship = _this4.getRootEventBundledRelationship();
460
- if (Thread.hasServerSideSupport && bundledRelationship) {
461
- _this4.replyCount = bundledRelationship.count;
462
- _this4._currentUserParticipated = !!bundledRelationship.current_user_participated;
463
- var mapper = _this4.client.getEventMapper();
464
- // re-insert roomId
465
- _this4.lastEvent = mapper(_objectSpread(_objectSpread({}, bundledRelationship.latest_event), {}, {
466
- room_id: _this4.roomId
467
- }));
468
- _this4.updatePendingReplyCount();
469
- yield _this4.processEvent(_this4.lastEvent);
470
- }
471
- })();
426
+ getRootEventBundledRelationship(rootEvent = this.rootEvent) {
427
+ return rootEvent?.getServerAggregatedRelation(THREAD_RELATION_TYPE.name);
428
+ }
429
+ async processRootEvent() {
430
+ const bundledRelationship = this.getRootEventBundledRelationship();
431
+ if (Thread.hasServerSideSupport && bundledRelationship) {
432
+ this.replyCount = bundledRelationship.count;
433
+ this._currentUserParticipated = !!bundledRelationship.current_user_participated;
434
+ const mapper = this.client.getEventMapper();
435
+ // re-insert roomId
436
+ this.lastEvent = mapper(_objectSpread(_objectSpread({}, bundledRelationship.latest_event), {}, {
437
+ room_id: this.roomId
438
+ }));
439
+ this.updatePendingReplyCount();
440
+ await this.processEvent(this.lastEvent);
441
+ }
472
442
  }
473
443
  updatePendingReplyCount() {
474
- var unfilteredPendingEvents = this.pendingEventOrdering === PendingEventOrdering.Detached ? this.room.getPendingEvents() : this.events;
475
- var pendingEvents = unfilteredPendingEvents.filter(ev => {
476
- var _this$lastEvent2;
477
- return ev.threadRootId === this.id && ev.isRelation(THREAD_RELATION_TYPE.name) && ev.status !== null && ev.getId() !== ((_this$lastEvent2 = this.lastEvent) === null || _this$lastEvent2 === void 0 ? void 0 : _this$lastEvent2.getId());
478
- });
444
+ const unfilteredPendingEvents = this.pendingEventOrdering === PendingEventOrdering.Detached ? this.room.getPendingEvents() : this.events;
445
+ const pendingEvents = unfilteredPendingEvents.filter(ev => ev.threadRootId === this.id && ev.isRelation(THREAD_RELATION_TYPE.name) && ev.status !== null && ev.getId() !== this.lastEvent?.getId());
479
446
  this.lastPendingEvent = pendingEvents.length ? pendingEvents[pendingEvents.length - 1] : undefined;
480
447
  this.pendingReplyCount = pendingEvents.length;
481
448
  }
@@ -494,147 +461,125 @@ export class Thread extends ReadReceipt {
494
461
  * timeline which would otherwise be unable to paginate forwards without this token).
495
462
  * Removing just the old live timeline whilst preserving previous ones is not supported.
496
463
  */
497
- resetLiveTimeline(backPaginationToken, forwardPaginationToken) {
498
- var _this5 = this;
499
- return _asyncToGenerator(function* () {
500
- var oldLive = _this5.liveTimeline;
501
- _this5.timelineSet.resetLiveTimeline(backPaginationToken !== null && backPaginationToken !== void 0 ? backPaginationToken : undefined, forwardPaginationToken !== null && forwardPaginationToken !== void 0 ? forwardPaginationToken : undefined);
502
- var newLive = _this5.liveTimeline;
464
+ async resetLiveTimeline(backPaginationToken, forwardPaginationToken) {
465
+ const oldLive = this.liveTimeline;
466
+ this.timelineSet.resetLiveTimeline(backPaginationToken ?? undefined, forwardPaginationToken ?? undefined);
467
+ const newLive = this.liveTimeline;
503
468
 
504
- // FIXME: Remove the following as soon as https://github.com/matrix-org/synapse/issues/14830 is resolved.
505
- //
506
- // The pagination API for thread timelines currently can't handle the type of pagination tokens returned by sync
507
- //
508
- // To make this work anyway, we'll have to transform them into one of the types that the API can handle.
509
- // One option is passing the tokens to /messages, which can handle sync tokens, and returns the right format.
510
- // /messages does not return new tokens on requests with a limit of 0.
511
- // This means our timelines might overlap a slight bit, but that's not an issue, as we deduplicate messages
512
- // anyway.
469
+ // FIXME: Remove the following as soon as https://github.com/matrix-org/synapse/issues/14830 is resolved.
470
+ //
471
+ // The pagination API for thread timelines currently can't handle the type of pagination tokens returned by sync
472
+ //
473
+ // To make this work anyway, we'll have to transform them into one of the types that the API can handle.
474
+ // One option is passing the tokens to /messages, which can handle sync tokens, and returns the right format.
475
+ // /messages does not return new tokens on requests with a limit of 0.
476
+ // This means our timelines might overlap a slight bit, but that's not an issue, as we deduplicate messages
477
+ // anyway.
513
478
 
514
- var newBackward;
515
- var oldForward;
516
- if (backPaginationToken) {
517
- var res = yield _this5.client.createMessagesRequest(_this5.roomId, backPaginationToken, 1, Direction.Forward);
518
- newBackward = res.end;
519
- }
520
- if (forwardPaginationToken) {
521
- var _res = yield _this5.client.createMessagesRequest(_this5.roomId, forwardPaginationToken, 1, Direction.Backward);
522
- oldForward = _res.start;
523
- }
524
- // Only replace the token if we don't have paginated away from this position already. This situation doesn't
525
- // occur today, but if the above issue is resolved, we'd have to go down this path.
526
- if (forwardPaginationToken && oldLive.getPaginationToken(Direction.Forward) === forwardPaginationToken) {
527
- oldLive.setPaginationToken(oldForward !== null && oldForward !== void 0 ? oldForward : null, Direction.Forward);
528
- }
529
- if (backPaginationToken && newLive.getPaginationToken(Direction.Backward) === backPaginationToken) {
530
- newLive.setPaginationToken(newBackward !== null && newBackward !== void 0 ? newBackward : null, Direction.Backward);
531
- }
532
- })();
533
- }
534
- updateThreadFromRootEvent() {
535
- var _this6 = this;
536
- return _asyncToGenerator(function* () {
537
- if (Thread.hasServerSideSupport) {
538
- // Ensure we show *something* as soon as possible, we'll update it as soon as we get better data, but we
539
- // don't want the thread preview to be empty if we can avoid it
540
- if (!_this6.initialEventsFetched && !_this6.lastEvent) {
541
- yield _this6.processRootEvent();
542
- }
543
- yield _this6.fetchRootEvent();
544
- }
545
- yield _this6.processRootEvent();
546
- })();
547
- }
548
- updateThreadMetadata() {
549
- var _this7 = this;
550
- return _asyncToGenerator(function* () {
551
- _this7.updatePendingReplyCount();
552
- if (!_this7.processRootEventPromise) {
553
- // We only want to do this once otherwise we end up rolling back to the last unsigned summary we have for the thread
554
- _this7.processRootEventPromise = _this7.updateThreadFromRootEvent();
479
+ let newBackward;
480
+ let oldForward;
481
+ if (backPaginationToken) {
482
+ const res = await this.client.createMessagesRequest(this.roomId, backPaginationToken, 1, Direction.Forward);
483
+ newBackward = res.end;
484
+ }
485
+ if (forwardPaginationToken) {
486
+ const res = await this.client.createMessagesRequest(this.roomId, forwardPaginationToken, 1, Direction.Backward);
487
+ oldForward = res.start;
488
+ }
489
+ // Only replace the token if we don't have paginated away from this position already. This situation doesn't
490
+ // occur today, but if the above issue is resolved, we'd have to go down this path.
491
+ if (forwardPaginationToken && oldLive.getPaginationToken(Direction.Forward) === forwardPaginationToken) {
492
+ oldLive.setPaginationToken(oldForward ?? null, Direction.Forward);
493
+ }
494
+ if (backPaginationToken && newLive.getPaginationToken(Direction.Backward) === backPaginationToken) {
495
+ newLive.setPaginationToken(newBackward ?? null, Direction.Backward);
496
+ }
497
+ }
498
+ async updateThreadFromRootEvent() {
499
+ if (Thread.hasServerSideSupport) {
500
+ // Ensure we show *something* as soon as possible, we'll update it as soon as we get better data, but we
501
+ // don't want the thread preview to be empty if we can avoid it
502
+ if (!this.initialEventsFetched && !this.lastEvent) {
503
+ await this.processRootEvent();
555
504
  }
556
- yield _this7.processRootEventPromise;
557
- if (!_this7.initialEventsFetched) {
558
- if (_this7.initalEventFetchProm) {
559
- yield _this7.initalEventFetchProm;
560
- } else {
561
- // fetch initial events to allow proper pagination
562
- try {
563
- // clear out any events that were added before the pagination request
564
- // completed (eg. from sync). They'll be replaced by those from the pagination.
565
- // Really, we should do this after the pagination request completes, but
566
- // paginateEventTimeline does the request and adds the events in one go, so
567
- // this would need a refactor in order to do. It's therefore possible there's
568
- // a remaining race where an event comes in while the pagination request is
569
- // happening.
570
- _this7.timelineSet.resetLiveTimeline();
571
- // if the thread has regular events, this will just load the last reply.
572
- // if the thread is newly created, this will load the root event.
573
- if (_this7.replyCount === 0 && _this7.rootEvent) {
574
- _this7.timelineSet.addEventsToTimeline([_this7.rootEvent], true, false, _this7.liveTimeline, null);
575
- _this7.liveTimeline.setPaginationToken(null, Direction.Backward);
576
- } else {
577
- _this7.initalEventFetchProm = _this7.client.paginateEventTimeline(_this7.liveTimeline, {
578
- backwards: true
579
- });
580
- yield _this7.initalEventFetchProm;
581
- }
582
- // We have now fetched the initial events, so set the flag. We need to do this before
583
- // we actually add the events, so `this.addEvents` knows that it can now safely add
584
- // them rather than buffer them in the pending event list. The main thing is that this
585
- // must remain false while the async fetch happens, so we don't try to add events before
586
- // the pagination has finished. The important thing is that we're not await-ing anything
587
- // else between setting this and adding events, so no races.
588
- _this7.initialEventsFetched = true;
589
- for (var event of _this7.replayEvents) {
590
- _this7.addEvent(event, false);
591
- }
592
- _this7.replayEvents = null;
593
- // just to make sure that, if we've created a timeline window for this thread before the thread itself
594
- // existed (e.g. when creating a new thread), we'll make sure the panel is force refreshed correctly.
595
- _this7.emit(RoomEvent.TimelineReset, _this7.room, _this7.timelineSet, true);
596
- } catch (e) {
597
- logger.error("Failed to load start of newly created thread: ", e);
598
- _this7.initialEventsFetched = false;
505
+ await this.fetchRootEvent();
506
+ }
507
+ await this.processRootEvent();
508
+ }
509
+ async updateThreadMetadata() {
510
+ this.updatePendingReplyCount();
511
+ if (!this.processRootEventPromise) {
512
+ // We only want to do this once otherwise we end up rolling back to the last unsigned summary we have for the thread
513
+ this.processRootEventPromise = this.updateThreadFromRootEvent();
514
+ }
515
+ await this.processRootEventPromise;
516
+ if (!this.initialEventsFetched) {
517
+ if (this.initalEventFetchProm) {
518
+ await this.initalEventFetchProm;
519
+ } else {
520
+ // fetch initial events to allow proper pagination
521
+ try {
522
+ // clear out any events that were added before the pagination request
523
+ // completed (eg. from sync). They'll be replaced by those from the pagination.
524
+ // Really, we should do this after the pagination request completes, but
525
+ // paginateEventTimeline does the request and adds the events in one go, so
526
+ // this would need a refactor in order to do. It's therefore possible there's
527
+ // a remaining race where an event comes in while the pagination request is
528
+ // happening.
529
+ this.timelineSet.resetLiveTimeline();
530
+ // if the thread has regular events, this will just load the last reply.
531
+ // if the thread is newly created, this will load the root event.
532
+ if (this.replyCount === 0 && this.rootEvent) {
533
+ this.timelineSet.addEventsToTimeline([this.rootEvent], true, false, this.liveTimeline, null);
534
+ this.liveTimeline.setPaginationToken(null, Direction.Backward);
535
+ } else {
536
+ this.initalEventFetchProm = this.client.paginateEventTimeline(this.liveTimeline, {
537
+ backwards: true
538
+ });
539
+ await this.initalEventFetchProm;
540
+ }
541
+ // We have now fetched the initial events, so set the flag. We need to do this before
542
+ // we actually add the events, so `this.addEvents` knows that it can now safely add
543
+ // them rather than buffer them in the pending event list. The main thing is that this
544
+ // must remain false while the async fetch happens, so we don't try to add events before
545
+ // the pagination has finished. The important thing is that we're not await-ing anything
546
+ // else between setting this and adding events, so no races.
547
+ this.initialEventsFetched = true;
548
+ for (const event of this.replayEvents) {
549
+ this.addEvent(event, false);
599
550
  }
551
+ this.replayEvents = null;
552
+ // just to make sure that, if we've created a timeline window for this thread before the thread itself
553
+ // existed (e.g. when creating a new thread), we'll make sure the panel is force refreshed correctly.
554
+ this.emit(RoomEvent.TimelineReset, this.room, this.timelineSet, true);
555
+ } catch (e) {
556
+ logger.error("Failed to load start of newly created thread: ", e);
557
+ this.initialEventsFetched = false;
600
558
  }
601
559
  }
602
- _this7.emit(ThreadEvent.Update, _this7);
603
- })();
560
+ }
561
+ this.emit(ThreadEvent.Update, this);
604
562
  }
605
563
 
606
564
  // XXX: Workaround for https://github.com/matrix-org/matrix-spec-proposals/pull/2676/files#r827240084
607
- fetchEditsWhereNeeded() {
608
- var _arguments = arguments,
609
- _this8 = this;
610
- return _asyncToGenerator(function* () {
611
- var _this8$client$canSupp;
612
- var recursionSupport = (_this8$client$canSupp = _this8.client.canSupport.get(Feature.RelationsRecursion)) !== null && _this8$client$canSupp !== void 0 ? _this8$client$canSupp : ServerSupport.Unsupported;
613
- if (recursionSupport === ServerSupport.Unsupported) {
614
- for (var _len = _arguments.length, events = new Array(_len), _key = 0; _key < _len; _key++) {
615
- events[_key] = _arguments[_key];
616
- }
617
- return Promise.all(events.filter(isAnEncryptedThreadMessage).map(/*#__PURE__*/function () {
618
- var _ref6 = _asyncToGenerator(function* (event) {
619
- try {
620
- var relations = yield _this8.client.relations(_this8.roomId, event.getId(), RelationType.Replace, event.getType(), {
621
- limit: 1
622
- });
623
- if (relations.events.length) {
624
- var editEvent = relations.events[0];
625
- event.makeReplaced(editEvent);
626
- _this8.insertEventIntoTimeline(editEvent);
627
- }
628
- } catch (e) {
629
- logger.error("Failed to load edits for encrypted thread event", e);
630
- }
565
+ async fetchEditsWhereNeeded(...events) {
566
+ const recursionSupport = this.client.canSupport.get(Feature.RelationsRecursion) ?? ServerSupport.Unsupported;
567
+ if (recursionSupport === ServerSupport.Unsupported) {
568
+ return Promise.all(events.filter(isAnEncryptedThreadMessage).map(async event => {
569
+ try {
570
+ const relations = await this.client.relations(this.roomId, event.getId(), RelationType.Replace, event.getType(), {
571
+ limit: 1
631
572
  });
632
- return function (_x6) {
633
- return _ref6.apply(this, arguments);
634
- };
635
- }()));
636
- }
637
- })();
573
+ if (relations.events.length) {
574
+ const editEvent = relations.events[0];
575
+ event.makeReplaced(editEvent);
576
+ this.insertEventIntoTimeline(editEvent);
577
+ }
578
+ } catch (e) {
579
+ logger.error("Failed to load edits for encrypted thread event", e);
580
+ }
581
+ }));
582
+ }
638
583
  }
639
584
  setEventMetadata(event) {
640
585
  if (event) {
@@ -644,9 +589,8 @@ export class Thread extends ReadReceipt {
644
589
  }
645
590
  clearEventMetadata(event) {
646
591
  if (event) {
647
- var _event$event;
648
592
  event.setThread(undefined);
649
- (_event$event = event.event) === null || _event$event === void 0 || (_event$event = _event$event.unsigned) === null || _event$event === void 0 || (_event$event = _event$event["m.relations"]) === null || _event$event === void 0 || delete _event$event[THREAD_RELATION_TYPE.name];
593
+ delete event.event?.unsigned?.["m.relations"]?.[THREAD_RELATION_TYPE.name];
650
594
  }
651
595
  }
652
596
 
@@ -660,10 +604,9 @@ export class Thread extends ReadReceipt {
660
604
  /**
661
605
  * Return last reply to the thread, if known.
662
606
  */
663
- lastReply() {
664
- var matches = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ev => ev.isRelation(THREAD_RELATION_TYPE.name);
665
- for (var i = this.timeline.length - 1; i >= 0; i--) {
666
- var event = this.timeline[i];
607
+ lastReply(matches = ev => ev.isRelation(THREAD_RELATION_TYPE.name)) {
608
+ for (let i = this.timeline.length - 1; i >= 0; i--) {
609
+ const event = this.timeline[i];
667
610
  if (matches(event)) {
668
611
  return event;
669
612
  }
@@ -688,8 +631,7 @@ export class Thread extends ReadReceipt {
688
631
  * This might be a synthesized event, if so, it will not emit any events to listeners.
689
632
  */
690
633
  get replyToEvent() {
691
- var _ref7, _this$lastPendingEven;
692
- return (_ref7 = (_this$lastPendingEven = this.lastPendingEvent) !== null && _this$lastPendingEven !== void 0 ? _this$lastPendingEven : this.lastEvent) !== null && _ref7 !== void 0 ? _ref7 : this.lastReply();
634
+ return this.lastPendingEvent ?? this.lastEvent ?? this.lastReply();
693
635
  }
694
636
 
695
637
  /**
@@ -751,32 +693,31 @@ export class Thread extends ReadReceipt {
751
693
  //
752
694
  // --- andyb
753
695
 
754
- var isCurrentUser = userId === this.client.getUserId();
755
- var lastReply = this.timeline[this.timeline.length - 1];
696
+ const isCurrentUser = userId === this.client.getUserId();
697
+ const lastReply = this.timeline[this.timeline.length - 1];
756
698
  if (isCurrentUser && lastReply) {
757
699
  // If the last activity in a thread is prior to the first threaded read receipt
758
700
  // sent in the room (suggesting that it was sent before the user started
759
701
  // using a client that supported threaded read receipts), we want to
760
702
  // consider this thread as read.
761
- var beforeFirstThreadedReceipt = lastReply.getTs() < this.room.getOldestThreadedReceiptTs();
762
- var lastReplyId = lastReply.getId();
703
+ const beforeFirstThreadedReceipt = lastReply.getTs() < this.room.getOldestThreadedReceiptTs();
704
+ const lastReplyId = lastReply.getId();
763
705
  // Some unsent events do not have an ID, we do not want to consider them read
764
706
  if (beforeFirstThreadedReceipt && lastReplyId) {
765
707
  return lastReplyId;
766
708
  }
767
709
  }
768
- var readUpToId = super.getEventReadUpTo(userId, ignoreSynthesized);
710
+ const readUpToId = super.getEventReadUpTo(userId, ignoreSynthesized);
769
711
 
770
712
  // Check whether the unthreaded read receipt for that user is more recent
771
713
  // than the read receipt inside that thread.
772
714
  if (lastReply) {
773
- var unthreadedReceipt = this.room.getLastUnthreadedReceiptFor(userId);
715
+ const unthreadedReceipt = this.room.getLastUnthreadedReceiptFor(userId);
774
716
  if (!unthreadedReceipt) {
775
717
  return readUpToId;
776
718
  }
777
- for (var i = ((_this$timeline = this.timeline) === null || _this$timeline === void 0 ? void 0 : _this$timeline.length) - 1; i >= 0; --i) {
778
- var _this$timeline, _ev$getId;
779
- var ev = this.timeline[i];
719
+ for (let i = this.timeline?.length - 1; i >= 0; --i) {
720
+ const ev = this.timeline[i];
780
721
  // If we encounter the `readUpToId` we do not need to look further
781
722
  // there is no "more recent" unthreaded read receipt
782
723
  if (ev.getId() === readUpToId) return readUpToId;
@@ -785,7 +726,7 @@ export class Thread extends ReadReceipt {
785
726
  // whether an unthreaded read receipt is more recent that the current event.
786
727
  // We usually prefer relying on the order of the DAG but in this scenario
787
728
  // it is not possible and we have to rely on timestamp
788
- if (ev.getTs() < unthreadedReceipt.ts) return (_ev$getId = ev.getId()) !== null && _ev$getId !== void 0 ? _ev$getId : readUpToId;
729
+ if (ev.getTs() < unthreadedReceipt.ts) return ev.getId() ?? readUpToId;
789
730
  }
790
731
  }
791
732
  return readUpToId;
@@ -804,14 +745,13 @@ export class Thread extends ReadReceipt {
804
745
  */
805
746
  hasUserReadEvent(userId, eventId) {
806
747
  if (userId === this.client.getUserId()) {
807
- var _this$lastReply$getTs, _this$lastReply, _this$room$getLastUnt, _this$room$getLastUnt2, _this$lastReply$getTs2, _this$lastReply2;
808
748
  // Consider an event read if it's part of a thread that is before the
809
749
  // first threaded receipt sent in that room. It is likely that it is
810
750
  // part of a thread that was created before MSC3771 was implemented.
811
751
  // Or before the last unthreaded receipt for the logged in user
812
- var beforeFirstThreadedReceipt = ((_this$lastReply$getTs = (_this$lastReply = this.lastReply()) === null || _this$lastReply === void 0 ? void 0 : _this$lastReply.getTs()) !== null && _this$lastReply$getTs !== void 0 ? _this$lastReply$getTs : 0) < this.room.getOldestThreadedReceiptTs();
813
- var unthreadedReceiptTs = (_this$room$getLastUnt = (_this$room$getLastUnt2 = this.room.getLastUnthreadedReceiptFor(userId)) === null || _this$room$getLastUnt2 === void 0 ? void 0 : _this$room$getLastUnt2.ts) !== null && _this$room$getLastUnt !== void 0 ? _this$room$getLastUnt : 0;
814
- var beforeLastUnthreadedReceipt = ((_this$lastReply$getTs2 = this === null || this === void 0 || (_this$lastReply2 = this.lastReply()) === null || _this$lastReply2 === void 0 ? void 0 : _this$lastReply2.getTs()) !== null && _this$lastReply$getTs2 !== void 0 ? _this$lastReply$getTs2 : 0) < unthreadedReceiptTs;
752
+ const beforeFirstThreadedReceipt = (this.lastReply()?.getTs() ?? 0) < this.room.getOldestThreadedReceiptTs();
753
+ const unthreadedReceiptTs = this.room.getLastUnthreadedReceiptFor(userId)?.ts ?? 0;
754
+ const beforeLastUnthreadedReceipt = (this?.lastReply()?.getTs() ?? 0) < unthreadedReceiptTs;
815
755
  if (beforeFirstThreadedReceipt || beforeLastUnthreadedReceipt) {
816
756
  return true;
817
757
  }
@@ -846,10 +786,10 @@ _defineProperty(Thread, "hasServerSideFwdPaginationSupport", FeatureSupport.None
846
786
  function isAnEncryptedThreadMessage(event) {
847
787
  return event.isEncrypted() && (event.isRelation(THREAD_RELATION_TYPE.name) || event.isThreadRoot);
848
788
  }
849
- export var FILTER_RELATED_BY_SENDERS = new ServerControlledNamespacedValue("related_by_senders", "io.element.relation_senders");
850
- export var FILTER_RELATED_BY_REL_TYPES = new ServerControlledNamespacedValue("related_by_rel_types", "io.element.relation_types");
851
- export var THREAD_RELATION_TYPE = new ServerControlledNamespacedValue("m.thread", "io.element.thread");
852
- export var ThreadFilterType = /*#__PURE__*/function (ThreadFilterType) {
789
+ export const FILTER_RELATED_BY_SENDERS = new ServerControlledNamespacedValue("related_by_senders", "io.element.relation_senders");
790
+ export const FILTER_RELATED_BY_REL_TYPES = new ServerControlledNamespacedValue("related_by_rel_types", "io.element.relation_types");
791
+ export const THREAD_RELATION_TYPE = new ServerControlledNamespacedValue("m.thread", "io.element.thread");
792
+ export let ThreadFilterType = /*#__PURE__*/function (ThreadFilterType) {
853
793
  ThreadFilterType[ThreadFilterType["My"] = 0] = "My";
854
794
  ThreadFilterType[ThreadFilterType["All"] = 1] = "All";
855
795
  return ThreadFilterType;