matrix-js-sdk 41.8.0 → 41.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (458) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +1 -1
  3. package/lib/@types/AESEncryptedSecretStoragePayload.js +3 -1
  4. package/lib/@types/IIdentityServerProvider.js +3 -1
  5. package/lib/@types/PushRules.js +7 -7
  6. package/lib/@types/PushRules.js.map +1 -1
  7. package/lib/@types/auth.js +4 -4
  8. package/lib/@types/auth.js.map +1 -1
  9. package/lib/@types/beacon.js +2 -2
  10. package/lib/@types/beacon.js.map +1 -1
  11. package/lib/@types/common.js +3 -1
  12. package/lib/@types/crypto.js +3 -1
  13. package/lib/@types/event.js +20 -20
  14. package/lib/@types/event.js.map +1 -1
  15. package/lib/@types/events.js +3 -1
  16. package/lib/@types/extensible_events.js +6 -6
  17. package/lib/@types/extensible_events.js.map +1 -1
  18. package/lib/@types/global.d.js.map +1 -1
  19. package/lib/@types/json.js +3 -1
  20. package/lib/@types/local_notifications.js +3 -1
  21. package/lib/@types/location.js +4 -4
  22. package/lib/@types/location.js.map +1 -1
  23. package/lib/@types/matrix-sdk-crypto-wasm.d.js +3 -1
  24. package/lib/@types/media.js +3 -1
  25. package/lib/@types/membership.js +1 -1
  26. package/lib/@types/membership.js.map +1 -1
  27. package/lib/@types/partials.js +6 -6
  28. package/lib/@types/partials.js.map +1 -1
  29. package/lib/@types/polls.js +5 -5
  30. package/lib/@types/polls.js.map +1 -1
  31. package/lib/@types/read_receipts.js +2 -2
  32. package/lib/@types/read_receipts.js.map +1 -1
  33. package/lib/@types/registration.js +3 -1
  34. package/lib/@types/requests.js +1 -1
  35. package/lib/@types/requests.js.map +1 -1
  36. package/lib/@types/retention.js +1 -1
  37. package/lib/@types/retention.js.map +1 -1
  38. package/lib/@types/search.js +1 -1
  39. package/lib/@types/search.js.map +1 -1
  40. package/lib/@types/signed.js +3 -1
  41. package/lib/@types/spaces.js +3 -1
  42. package/lib/@types/state_events.js +3 -1
  43. package/lib/@types/synapse.js +3 -1
  44. package/lib/@types/sync.js +1 -1
  45. package/lib/@types/sync.js.map +1 -1
  46. package/lib/@types/threepids.js +1 -1
  47. package/lib/@types/threepids.js.map +1 -1
  48. package/lib/@types/topic.js +1 -1
  49. package/lib/@types/topic.js.map +1 -1
  50. package/lib/@types/uia.js +3 -1
  51. package/lib/NamespacedValue.js +8 -8
  52. package/lib/NamespacedValue.js.map +1 -1
  53. package/lib/ReEmitter.js +9 -16
  54. package/lib/ReEmitter.js.map +1 -1
  55. package/lib/ToDeviceMessageQueue.js +49 -57
  56. package/lib/ToDeviceMessageQueue.js.map +1 -1
  57. package/lib/autodiscovery.js +232 -247
  58. package/lib/autodiscovery.js.map +1 -1
  59. package/lib/base64.js +1 -1
  60. package/lib/base64.js.map +1 -1
  61. package/lib/browser-index.d.ts +2 -2
  62. package/lib/browser-index.d.ts.map +1 -1
  63. package/lib/browser-index.js +5 -5
  64. package/lib/browser-index.js.map +1 -1
  65. package/lib/capabilityPoller.js +19 -22
  66. package/lib/capabilityPoller.js.map +1 -1
  67. package/lib/client.d.ts +2 -8
  68. package/lib/client.d.ts.map +1 -1
  69. package/lib/client.js +2043 -2487
  70. package/lib/client.js.map +1 -1
  71. package/lib/common-crypto/CryptoBackend.js +2 -2
  72. package/lib/common-crypto/CryptoBackend.js.map +1 -1
  73. package/lib/common-crypto/key-passphrase.js.map +1 -1
  74. package/lib/content-helpers.js +43 -48
  75. package/lib/content-helpers.js.map +1 -1
  76. package/lib/content-repo.js +14 -24
  77. package/lib/content-repo.js.map +1 -1
  78. package/lib/crypto/store/base.js +6 -6
  79. package/lib/crypto/store/base.js.map +1 -1
  80. package/lib/crypto/store/indexeddb-crypto-store-backend.js +190 -238
  81. package/lib/crypto/store/indexeddb-crypto-store-backend.js.map +1 -1
  82. package/lib/crypto/store/indexeddb-crypto-store.js +25 -30
  83. package/lib/crypto/store/indexeddb-crypto-store.js.map +1 -1
  84. package/lib/crypto/store/localStorage-crypto-store.js +113 -145
  85. package/lib/crypto/store/localStorage-crypto-store.js.map +1 -1
  86. package/lib/crypto/store/memory-crypto-store.js +74 -105
  87. package/lib/crypto/store/memory-crypto-store.js.map +1 -1
  88. package/lib/crypto-api/CryptoEvent.js +1 -1
  89. package/lib/crypto-api/CryptoEvent.js.map +1 -1
  90. package/lib/crypto-api/CryptoEventHandlerMap.js +3 -1
  91. package/lib/crypto-api/index.d.ts +15 -6
  92. package/lib/crypto-api/index.d.ts.map +1 -1
  93. package/lib/crypto-api/index.js +22 -22
  94. package/lib/crypto-api/index.js.map +1 -1
  95. package/lib/crypto-api/key-passphrase.js +15 -23
  96. package/lib/crypto-api/key-passphrase.js.map +1 -1
  97. package/lib/crypto-api/keybackup.js +3 -1
  98. package/lib/crypto-api/recovery-key.js +11 -12
  99. package/lib/crypto-api/recovery-key.js.map +1 -1
  100. package/lib/crypto-api/verification.js +3 -3
  101. package/lib/crypto-api/verification.js.map +1 -1
  102. package/lib/digest.js +7 -14
  103. package/lib/digest.js.map +1 -1
  104. package/lib/embedded.d.ts.map +1 -1
  105. package/lib/embedded.js +380 -505
  106. package/lib/embedded.js.map +1 -1
  107. package/lib/errors.js +2 -2
  108. package/lib/errors.js.map +1 -1
  109. package/lib/event-mapper.js +10 -12
  110. package/lib/event-mapper.js.map +1 -1
  111. package/lib/extensible_events_v1/ExtensibleEvent.js.map +1 -1
  112. package/lib/extensible_events_v1/InvalidEventError.js.map +1 -1
  113. package/lib/extensible_events_v1/MessageEvent.js +11 -13
  114. package/lib/extensible_events_v1/MessageEvent.js.map +1 -1
  115. package/lib/extensible_events_v1/PollEndEvent.js +3 -4
  116. package/lib/extensible_events_v1/PollEndEvent.js.map +1 -1
  117. package/lib/extensible_events_v1/PollResponseEvent.js +5 -6
  118. package/lib/extensible_events_v1/PollResponseEvent.js.map +1 -1
  119. package/lib/extensible_events_v1/PollStartEvent.js +8 -10
  120. package/lib/extensible_events_v1/PollStartEvent.js.map +1 -1
  121. package/lib/extensible_events_v1/utilities.js.map +1 -1
  122. package/lib/feature.js +18 -31
  123. package/lib/feature.js.map +1 -1
  124. package/lib/filter-component.d.ts.map +1 -1
  125. package/lib/filter-component.js +20 -26
  126. package/lib/filter-component.js.map +1 -1
  127. package/lib/filter.js +14 -17
  128. package/lib/filter.js.map +1 -1
  129. package/lib/http-api/errors.js +28 -43
  130. package/lib/http-api/errors.js.map +1 -1
  131. package/lib/http-api/fetch.js +141 -159
  132. package/lib/http-api/fetch.js.map +1 -1
  133. package/lib/http-api/index.js +17 -20
  134. package/lib/http-api/index.js.map +1 -1
  135. package/lib/http-api/interface.js +1 -1
  136. package/lib/http-api/interface.js.map +1 -1
  137. package/lib/http-api/method.js +1 -1
  138. package/lib/http-api/method.js.map +1 -1
  139. package/lib/http-api/prefix.js +3 -3
  140. package/lib/http-api/prefix.js.map +1 -1
  141. package/lib/http-api/refresh.js +74 -94
  142. package/lib/http-api/refresh.js.map +1 -1
  143. package/lib/http-api/utils.d.ts +1 -1
  144. package/lib/http-api/utils.d.ts.map +1 -1
  145. package/lib/http-api/utils.js +34 -42
  146. package/lib/http-api/utils.js.map +1 -1
  147. package/lib/index.js.map +1 -1
  148. package/lib/indexeddb-helpers.js +3 -3
  149. package/lib/indexeddb-helpers.js.map +1 -1
  150. package/lib/indexeddb-worker.js.map +1 -1
  151. package/lib/interactive-auth.d.ts +5 -5
  152. package/lib/interactive-auth.d.ts.map +1 -1
  153. package/lib/interactive-auth.js +172 -204
  154. package/lib/interactive-auth.js.map +1 -1
  155. package/lib/logger.js +21 -57
  156. package/lib/logger.js.map +1 -1
  157. package/lib/matrix.js +7 -11
  158. package/lib/matrix.js.map +1 -1
  159. package/lib/matrixrtc/CallMembership.js +80 -74
  160. package/lib/matrixrtc/CallMembership.js.map +1 -1
  161. package/lib/matrixrtc/EncryptionManager.js +1 -1
  162. package/lib/matrixrtc/EncryptionManager.js.map +1 -1
  163. package/lib/matrixrtc/IKeyTransport.js +1 -1
  164. package/lib/matrixrtc/IKeyTransport.js.map +1 -1
  165. package/lib/matrixrtc/IMembershipManager.js +1 -1
  166. package/lib/matrixrtc/IMembershipManager.js.map +1 -1
  167. package/lib/matrixrtc/LivekitTransport.d.ts +1 -1
  168. package/lib/matrixrtc/LivekitTransport.js +4 -4
  169. package/lib/matrixrtc/LivekitTransport.js.map +1 -1
  170. package/lib/matrixrtc/MatrixRTCSession.js +137 -187
  171. package/lib/matrixrtc/MatrixRTCSession.js.map +1 -1
  172. package/lib/matrixrtc/MatrixRTCSessionManager.js +36 -41
  173. package/lib/matrixrtc/MatrixRTCSessionManager.js.map +1 -1
  174. package/lib/matrixrtc/MembershipManager.js +332 -378
  175. package/lib/matrixrtc/MembershipManager.js.map +1 -1
  176. package/lib/matrixrtc/MembershipManagerActionScheduler.js +54 -63
  177. package/lib/matrixrtc/MembershipManagerActionScheduler.js.map +1 -1
  178. package/lib/matrixrtc/RTCEncryptionManager.js +119 -143
  179. package/lib/matrixrtc/RTCEncryptionManager.js.map +1 -1
  180. package/lib/matrixrtc/ToDeviceKeyTransport.js +53 -58
  181. package/lib/matrixrtc/ToDeviceKeyTransport.js.map +1 -1
  182. package/lib/matrixrtc/index.js.map +1 -1
  183. package/lib/matrixrtc/membershipData/common.js +1 -1
  184. package/lib/matrixrtc/membershipData/common.js.map +1 -1
  185. package/lib/matrixrtc/membershipData/index.js.map +1 -1
  186. package/lib/matrixrtc/membershipData/rtc.js +15 -23
  187. package/lib/matrixrtc/membershipData/rtc.js.map +1 -1
  188. package/lib/matrixrtc/membershipData/session.js +4 -5
  189. package/lib/matrixrtc/membershipData/session.js.map +1 -1
  190. package/lib/matrixrtc/types.js +4 -6
  191. package/lib/matrixrtc/types.js.map +1 -1
  192. package/lib/matrixrtc/utils.js +4 -11
  193. package/lib/matrixrtc/utils.js.map +1 -1
  194. package/lib/models/MSC3089Branch.js +91 -116
  195. package/lib/models/MSC3089Branch.js.map +1 -1
  196. package/lib/models/MSC3089TreeSpace.js +209 -245
  197. package/lib/models/MSC3089TreeSpace.js.map +1 -1
  198. package/lib/models/ToDeviceMessage.js +3 -1
  199. package/lib/models/beacon.js +14 -13
  200. package/lib/models/beacon.js.map +1 -1
  201. package/lib/models/compare-event-ordering.js +13 -13
  202. package/lib/models/compare-event-ordering.js.map +1 -1
  203. package/lib/models/device.js +3 -3
  204. package/lib/models/device.js.map +1 -1
  205. package/lib/models/event-context.js +5 -8
  206. package/lib/models/event-context.js.map +1 -1
  207. package/lib/models/event-status.js +1 -1
  208. package/lib/models/event-status.js.map +1 -1
  209. package/lib/models/event-timeline-set.js +88 -94
  210. package/lib/models/event-timeline-set.js.map +1 -1
  211. package/lib/models/event-timeline.js +28 -30
  212. package/lib/models/event-timeline.js.map +1 -1
  213. package/lib/models/event.js +182 -226
  214. package/lib/models/event.js.map +1 -1
  215. package/lib/models/invites-ignorer-types.js +4 -4
  216. package/lib/models/invites-ignorer-types.js.map +1 -1
  217. package/lib/models/invites-ignorer.js +159 -179
  218. package/lib/models/invites-ignorer.js.map +1 -1
  219. package/lib/models/poll.js +71 -81
  220. package/lib/models/poll.js.map +1 -1
  221. package/lib/models/profile-keys.js +2 -2
  222. package/lib/models/profile-keys.js.map +1 -1
  223. package/lib/models/read-receipt.js +40 -56
  224. package/lib/models/read-receipt.js.map +1 -1
  225. package/lib/models/related-relations.js.map +1 -1
  226. package/lib/models/relations-container.js +22 -23
  227. package/lib/models/relations-container.js.map +1 -1
  228. package/lib/models/relations.js +133 -159
  229. package/lib/models/relations.js.map +1 -1
  230. package/lib/models/room-member.js +24 -29
  231. package/lib/models/room-member.js.map +1 -1
  232. package/lib/models/room-receipts.js +29 -43
  233. package/lib/models/room-receipts.js.map +1 -1
  234. package/lib/models/room-retention.js +74 -83
  235. package/lib/models/room-retention.js.map +1 -1
  236. package/lib/models/room-state.js +143 -172
  237. package/lib/models/room-state.js.map +1 -1
  238. package/lib/models/room-sticky-events.d.ts +1 -0
  239. package/lib/models/room-sticky-events.d.ts.map +1 -1
  240. package/lib/models/room-sticky-events.js +45 -65
  241. package/lib/models/room-sticky-events.js.map +1 -1
  242. package/lib/models/room-summary.js.map +1 -1
  243. package/lib/models/room.d.ts.map +1 -1
  244. package/lib/models/room.js +765 -909
  245. package/lib/models/room.js.map +1 -1
  246. package/lib/models/search-result.js +5 -5
  247. package/lib/models/search-result.js.map +1 -1
  248. package/lib/models/thread.js +225 -285
  249. package/lib/models/thread.js.map +1 -1
  250. package/lib/models/typed-event-emitter.js +7 -18
  251. package/lib/models/typed-event-emitter.js.map +1 -1
  252. package/lib/models/user.js +8 -8
  253. package/lib/models/user.js.map +1 -1
  254. package/lib/oidc/authorize.js +208 -241
  255. package/lib/oidc/authorize.js.map +1 -1
  256. package/lib/oidc/discovery.js +23 -36
  257. package/lib/oidc/discovery.js.map +1 -1
  258. package/lib/oidc/error.js +1 -1
  259. package/lib/oidc/error.js.map +1 -1
  260. package/lib/oidc/index.js +1 -0
  261. package/lib/oidc/index.js.map +1 -1
  262. package/lib/oidc/register.js +60 -66
  263. package/lib/oidc/register.js.map +1 -1
  264. package/lib/oidc/tokenRefresher.js +77 -91
  265. package/lib/oidc/tokenRefresher.js.map +1 -1
  266. package/lib/oidc/validate.js +18 -18
  267. package/lib/oidc/validate.js.map +1 -1
  268. package/lib/pushprocessor.js +71 -82
  269. package/lib/pushprocessor.js.map +1 -1
  270. package/lib/randomstring.js +9 -9
  271. package/lib/randomstring.js.map +1 -1
  272. package/lib/realtime-callbacks.js +25 -28
  273. package/lib/realtime-callbacks.js.map +1 -1
  274. package/lib/receipt-accumulator.d.ts +2 -0
  275. package/lib/receipt-accumulator.d.ts.map +1 -1
  276. package/lib/receipt-accumulator.js +14 -22
  277. package/lib/receipt-accumulator.js.map +1 -1
  278. package/lib/rendezvous/MSC4108SignInWithQR.js +271 -302
  279. package/lib/rendezvous/MSC4108SignInWithQR.js.map +1 -1
  280. package/lib/rendezvous/RendezvousChannel.js +3 -1
  281. package/lib/rendezvous/RendezvousCode.js +3 -1
  282. package/lib/rendezvous/RendezvousError.js.map +1 -1
  283. package/lib/rendezvous/RendezvousFailureReason.js +2 -2
  284. package/lib/rendezvous/RendezvousFailureReason.js.map +1 -1
  285. package/lib/rendezvous/RendezvousIntent.js +1 -1
  286. package/lib/rendezvous/RendezvousIntent.js.map +1 -1
  287. package/lib/rendezvous/RendezvousTransport.js +3 -1
  288. package/lib/rendezvous/channels/MSC4108SecureChannel.js +123 -147
  289. package/lib/rendezvous/channels/MSC4108SecureChannel.js.map +1 -1
  290. package/lib/rendezvous/index.js +44 -69
  291. package/lib/rendezvous/index.js.map +1 -1
  292. package/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts +1 -1
  293. package/lib/rendezvous/transports/MSC4108RendezvousSession.js +134 -152
  294. package/lib/rendezvous/transports/MSC4108RendezvousSession.js.map +1 -1
  295. package/lib/retentionPolicy.js +6 -9
  296. package/lib/retentionPolicy.js.map +1 -1
  297. package/lib/room-hierarchy.js +52 -60
  298. package/lib/room-hierarchy.js.map +1 -1
  299. package/lib/rust-crypto/CrossSigningIdentity.js +94 -104
  300. package/lib/rust-crypto/CrossSigningIdentity.js.map +1 -1
  301. package/lib/rust-crypto/DehydratedDeviceManager.js +157 -190
  302. package/lib/rust-crypto/DehydratedDeviceManager.js.map +1 -1
  303. package/lib/rust-crypto/KeyClaimManager.js +18 -22
  304. package/lib/rust-crypto/KeyClaimManager.js.map +1 -1
  305. package/lib/rust-crypto/OutgoingRequestProcessor.js +109 -139
  306. package/lib/rust-crypto/OutgoingRequestProcessor.js.map +1 -1
  307. package/lib/rust-crypto/OutgoingRequestsManager.js +66 -80
  308. package/lib/rust-crypto/OutgoingRequestsManager.js.map +1 -1
  309. package/lib/rust-crypto/PerSessionKeyBackupDownloader.d.ts +1 -1
  310. package/lib/rust-crypto/PerSessionKeyBackupDownloader.js +196 -224
  311. package/lib/rust-crypto/PerSessionKeyBackupDownloader.js.map +1 -1
  312. package/lib/rust-crypto/RoomEncryptor.js +127 -143
  313. package/lib/rust-crypto/RoomEncryptor.js.map +1 -1
  314. package/lib/rust-crypto/backup.js +453 -549
  315. package/lib/rust-crypto/backup.js.map +1 -1
  316. package/lib/rust-crypto/constants.js +1 -1
  317. package/lib/rust-crypto/constants.js.map +1 -1
  318. package/lib/rust-crypto/device-converter.js +15 -28
  319. package/lib/rust-crypto/device-converter.js.map +1 -1
  320. package/lib/rust-crypto/index.js +103 -116
  321. package/lib/rust-crypto/index.js.map +1 -1
  322. package/lib/rust-crypto/libolm_migration.js +303 -365
  323. package/lib/rust-crypto/libolm_migration.js.map +1 -1
  324. package/lib/rust-crypto/rust-crypto.d.ts +5 -1
  325. package/lib/rust-crypto/rust-crypto.d.ts.map +1 -1
  326. package/lib/rust-crypto/rust-crypto.js +1067 -1332
  327. package/lib/rust-crypto/rust-crypto.js.map +1 -1
  328. package/lib/rust-crypto/secret-storage.js +12 -25
  329. package/lib/rust-crypto/secret-storage.js.map +1 -1
  330. package/lib/rust-crypto/verification.js +137 -189
  331. package/lib/rust-crypto/verification.js.map +1 -1
  332. package/lib/scheduler.js +44 -19
  333. package/lib/scheduler.js.map +1 -1
  334. package/lib/secret-storage.js +179 -213
  335. package/lib/secret-storage.js.map +1 -1
  336. package/lib/serverCapabilities.js +6 -9
  337. package/lib/serverCapabilities.js.map +1 -1
  338. package/lib/service-types.js +1 -1
  339. package/lib/service-types.js.map +1 -1
  340. package/lib/sliding-sync-sdk.d.ts.map +1 -1
  341. package/lib/sliding-sync-sdk.js +368 -424
  342. package/lib/sliding-sync-sdk.js.map +1 -1
  343. package/lib/sliding-sync.js +135 -171
  344. package/lib/sliding-sync.js.map +1 -1
  345. package/lib/store/index.js +3 -1
  346. package/lib/store/indexeddb-backend.js +3 -1
  347. package/lib/store/indexeddb-local-backend.js +194 -253
  348. package/lib/store/indexeddb-local-backend.js.map +1 -1
  349. package/lib/store/indexeddb-remote-backend.js +33 -63
  350. package/lib/store/indexeddb-remote-backend.js.map +1 -1
  351. package/lib/store/indexeddb-store-worker.js +22 -23
  352. package/lib/store/indexeddb-store-worker.js.map +1 -1
  353. package/lib/store/indexeddb.js +44 -71
  354. package/lib/store/indexeddb.js.map +1 -1
  355. package/lib/store/local-storage-events-emitter.js +2 -2
  356. package/lib/store/local-storage-events-emitter.js.map +1 -1
  357. package/lib/store/memory.js +34 -57
  358. package/lib/store/memory.js.map +1 -1
  359. package/lib/store/stub.js +22 -35
  360. package/lib/store/stub.js.map +1 -1
  361. package/lib/sync-accumulator.js +54 -66
  362. package/lib/sync-accumulator.js.map +1 -1
  363. package/lib/sync.d.ts.map +1 -1
  364. package/lib/sync.js +905 -998
  365. package/lib/sync.js.map +1 -1
  366. package/lib/testing.js +63 -105
  367. package/lib/testing.js.map +1 -1
  368. package/lib/thread-utils.js +1 -4
  369. package/lib/thread-utils.js.map +1 -1
  370. package/lib/timeline-window.js +89 -102
  371. package/lib/timeline-window.js.map +1 -1
  372. package/lib/types.js +1 -1
  373. package/lib/types.js.map +1 -1
  374. package/lib/utils/decryptAESSecretStorageItem.js +14 -25
  375. package/lib/utils/decryptAESSecretStorageItem.js.map +1 -1
  376. package/lib/utils/encryptAESSecretStorageItem.js +27 -38
  377. package/lib/utils/encryptAESSecretStorageItem.js.map +1 -1
  378. package/lib/utils/internal/deriveKeys.js +25 -32
  379. package/lib/utils/internal/deriveKeys.js.map +1 -1
  380. package/lib/utils/roomVersion.js +1 -1
  381. package/lib/utils/roomVersion.js.map +1 -1
  382. package/lib/utils.js +83 -135
  383. package/lib/utils.js.map +1 -1
  384. package/lib/version-support.js +3 -3
  385. package/lib/version-support.js.map +1 -1
  386. package/lib/webrtc/audioContext.js +5 -6
  387. package/lib/webrtc/audioContext.js.map +1 -1
  388. package/lib/webrtc/call.js +1081 -1250
  389. package/lib/webrtc/call.js.map +1 -1
  390. package/lib/webrtc/callEventHandler.js +202 -214
  391. package/lib/webrtc/callEventHandler.js.map +1 -1
  392. package/lib/webrtc/callEventTypes.js +2 -2
  393. package/lib/webrtc/callEventTypes.js.map +1 -1
  394. package/lib/webrtc/callFeed.js +18 -20
  395. package/lib/webrtc/callFeed.js.map +1 -1
  396. package/lib/webrtc/groupCall.js +513 -602
  397. package/lib/webrtc/groupCall.js.map +1 -1
  398. package/lib/webrtc/groupCallEventHandler.js +59 -62
  399. package/lib/webrtc/groupCallEventHandler.js.map +1 -1
  400. package/lib/webrtc/mediaHandler.js +198 -232
  401. package/lib/webrtc/mediaHandler.js.map +1 -1
  402. package/lib/webrtc/stats/callFeedStatsReporter.js +16 -20
  403. package/lib/webrtc/stats/callFeedStatsReporter.js.map +1 -1
  404. package/lib/webrtc/stats/callStatsReportGatherer.js +67 -75
  405. package/lib/webrtc/stats/callStatsReportGatherer.js.map +1 -1
  406. package/lib/webrtc/stats/callStatsReportSummary.js +3 -1
  407. package/lib/webrtc/stats/connectionStats.js.map +1 -1
  408. package/lib/webrtc/stats/connectionStatsBuilder.js +2 -2
  409. package/lib/webrtc/stats/connectionStatsBuilder.js.map +1 -1
  410. package/lib/webrtc/stats/connectionStatsReportBuilder.js +20 -24
  411. package/lib/webrtc/stats/connectionStatsReportBuilder.js.map +1 -1
  412. package/lib/webrtc/stats/groupCallStats.js +6 -8
  413. package/lib/webrtc/stats/groupCallStats.js.map +1 -1
  414. package/lib/webrtc/stats/media/mediaSsrcHandler.js +7 -8
  415. package/lib/webrtc/stats/media/mediaSsrcHandler.js.map +1 -1
  416. package/lib/webrtc/stats/media/mediaTrackHandler.js +7 -9
  417. package/lib/webrtc/stats/media/mediaTrackHandler.js.map +1 -1
  418. package/lib/webrtc/stats/media/mediaTrackStats.js +3 -3
  419. package/lib/webrtc/stats/media/mediaTrackStats.js.map +1 -1
  420. package/lib/webrtc/stats/media/mediaTrackStatsHandler.js +7 -7
  421. package/lib/webrtc/stats/media/mediaTrackStatsHandler.js.map +1 -1
  422. package/lib/webrtc/stats/statsReport.js +1 -1
  423. package/lib/webrtc/stats/statsReport.js.map +1 -1
  424. package/lib/webrtc/stats/statsReportEmitter.js.map +1 -1
  425. package/lib/webrtc/stats/summaryStatsReportGatherer.js +14 -14
  426. package/lib/webrtc/stats/summaryStatsReportGatherer.js.map +1 -1
  427. package/lib/webrtc/stats/trackStatsBuilder.js +32 -34
  428. package/lib/webrtc/stats/trackStatsBuilder.js.map +1 -1
  429. package/lib/webrtc/stats/transportStats.js +3 -1
  430. package/lib/webrtc/stats/transportStatsBuilder.js +9 -9
  431. package/lib/webrtc/stats/transportStatsBuilder.js.map +1 -1
  432. package/lib/webrtc/stats/valueFormatter.js +1 -1
  433. package/lib/webrtc/stats/valueFormatter.js.map +1 -1
  434. package/package.json +18 -33
  435. package/src/@types/global.d.ts +2 -2
  436. package/src/ToDeviceMessageQueue.ts +2 -2
  437. package/src/browser-index.ts +4 -4
  438. package/src/client.ts +15 -20
  439. package/src/crypto-api/index.ts +17 -6
  440. package/src/embedded.ts +4 -6
  441. package/src/filter-component.ts +1 -0
  442. package/src/http-api/utils.ts +1 -1
  443. package/src/interactive-auth.ts +11 -5
  444. package/src/matrixrtc/LivekitTransport.ts +1 -1
  445. package/src/matrixrtc/MatrixRTCSession.ts +1 -1
  446. package/src/models/MSC3089Branch.ts +1 -1
  447. package/src/models/room-sticky-events.ts +1 -0
  448. package/src/models/room.ts +9 -11
  449. package/src/receipt-accumulator.ts +2 -0
  450. package/src/rendezvous/index.ts +1 -1
  451. package/src/rendezvous/transports/MSC4108RendezvousSession.ts +2 -2
  452. package/src/rust-crypto/PerSessionKeyBackupDownloader.ts +1 -1
  453. package/src/rust-crypto/index.ts +6 -6
  454. package/src/rust-crypto/rust-crypto.ts +31 -7
  455. package/src/rust-crypto/verification.ts +1 -1
  456. package/src/sliding-sync-sdk.ts +5 -7
  457. package/src/store/indexeddb-local-backend.ts +3 -3
  458. package/src/sync.ts +6 -8
@@ -1,4 +1,3 @@
1
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
2
  /*
4
3
  Copyright 2023 The Matrix.org Foundation C.I.C.
@@ -25,10 +24,10 @@ limitations under the License.
25
24
  */
26
25
  export class KeyClaimManager {
27
26
  constructor(olmMachine, outgoingRequestProcessor) {
28
- this.olmMachine = olmMachine;
29
- this.outgoingRequestProcessor = outgoingRequestProcessor;
30
27
  _defineProperty(this, "currentClaimPromise", void 0);
31
28
  _defineProperty(this, "stopped", false);
29
+ this.olmMachine = olmMachine;
30
+ this.outgoingRequestProcessor = outgoingRequestProcessor;
32
31
  this.currentClaimPromise = Promise.resolve();
33
32
  }
34
33
 
@@ -52,31 +51,28 @@ export class KeyClaimManager {
52
51
  // The Rust-SDK requires that we only have one getMissingSessions process in flight at once. This little dance
53
52
  // ensures that, by only having one call to ensureSessionsForUsersInner active at once (and making them
54
53
  // queue up in order).
55
- var prom = this.currentClaimPromise.catch(() => {
54
+ const prom = this.currentClaimPromise.catch(() => {
56
55
  // any errors in the previous claim will have been reported already, so there is nothing to do here.
57
56
  // we just throw away the error and start anew.
58
57
  }).then(() => this.ensureSessionsForUsersInner(logger, userList));
59
58
  this.currentClaimPromise = prom;
60
59
  return prom;
61
60
  }
62
- ensureSessionsForUsersInner(logger, userList) {
63
- var _this = this;
64
- return _asyncToGenerator(function* () {
65
- // bail out quickly if we've been stopped.
66
- if (_this.stopped) {
67
- throw new Error("Cannot ensure Olm sessions: shutting down");
68
- }
69
- logger.info("Checking for missing Olm sessions");
70
- // By passing the userId array to rust we transfer ownership of the items to rust, causing
71
- // them to be invalidated on the JS side as soon as the method is called.
72
- // As we haven't created the `userList` let's clone the users, to not break the caller from re-using it.
73
- var claimRequest = yield _this.olmMachine.getMissingSessions(userList.map(u => u.clone()));
74
- if (claimRequest) {
75
- logger.info("Making /keys/claim request");
76
- yield _this.outgoingRequestProcessor.makeOutgoingRequest(claimRequest);
77
- }
78
- logger.info("Olm sessions prepared");
79
- })();
61
+ async ensureSessionsForUsersInner(logger, userList) {
62
+ // bail out quickly if we've been stopped.
63
+ if (this.stopped) {
64
+ throw new Error(`Cannot ensure Olm sessions: shutting down`);
65
+ }
66
+ logger.info("Checking for missing Olm sessions");
67
+ // By passing the userId array to rust we transfer ownership of the items to rust, causing
68
+ // them to be invalidated on the JS side as soon as the method is called.
69
+ // As we haven't created the `userList` let's clone the users, to not break the caller from re-using it.
70
+ const claimRequest = await this.olmMachine.getMissingSessions(userList.map(u => u.clone()));
71
+ if (claimRequest) {
72
+ logger.info("Making /keys/claim request");
73
+ await this.outgoingRequestProcessor.makeOutgoingRequest(claimRequest);
74
+ }
75
+ logger.info("Olm sessions prepared");
80
76
  }
81
77
  }
82
78
  //# sourceMappingURL=KeyClaimManager.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"KeyClaimManager.js","names":["KeyClaimManager","constructor","olmMachine","outgoingRequestProcessor","_defineProperty","currentClaimPromise","Promise","resolve","stop","stopped","ensureSessionsForUsers","logger","userList","prom","catch","then","ensureSessionsForUsersInner","_this","_asyncToGenerator","Error","info","claimRequest","getMissingSessions","map","u","clone","makeOutgoingRequest"],"sources":["../../src/rust-crypto/KeyClaimManager.ts"],"sourcesContent":["/*\nCopyright 2023 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { type OlmMachine, type UserId } from \"@matrix-org/matrix-sdk-crypto-wasm\";\n\nimport { type OutgoingRequestProcessor } from \"./OutgoingRequestProcessor.ts\";\nimport { type LogSpan } from \"../logger.ts\";\n\n/**\n * KeyClaimManager: linearises calls to OlmMachine.getMissingSessions to avoid races\n *\n * We have one of these per `RustCrypto` (and hence per `MatrixClient`).\n *\n * @internal\n */\nexport class KeyClaimManager {\n private currentClaimPromise: Promise<void>;\n private stopped = false;\n\n public constructor(\n private readonly olmMachine: OlmMachine,\n private readonly outgoingRequestProcessor: OutgoingRequestProcessor,\n ) {\n this.currentClaimPromise = Promise.resolve();\n }\n\n /**\n * Tell the KeyClaimManager to immediately stop processing requests.\n *\n * Any further calls, and any still in the queue, will fail with an error.\n */\n public stop(): void {\n this.stopped = true;\n }\n\n /**\n * Given a list of users, attempt to ensure that we have Olm Sessions active with each of their devices\n *\n * If we don't have an active olm session, we will claim a one-time key and start one.\n * @param logger - logger to use\n * @param userList - list of userIDs to claim\n */\n public ensureSessionsForUsers(logger: LogSpan, userList: Array<UserId>): Promise<void> {\n // The Rust-SDK requires that we only have one getMissingSessions process in flight at once. This little dance\n // ensures that, by only having one call to ensureSessionsForUsersInner active at once (and making them\n // queue up in order).\n const prom = this.currentClaimPromise\n .catch(() => {\n // any errors in the previous claim will have been reported already, so there is nothing to do here.\n // we just throw away the error and start anew.\n })\n .then(() => this.ensureSessionsForUsersInner(logger, userList));\n this.currentClaimPromise = prom;\n return prom;\n }\n\n private async ensureSessionsForUsersInner(logger: LogSpan, userList: Array<UserId>): Promise<void> {\n // bail out quickly if we've been stopped.\n if (this.stopped) {\n throw new Error(`Cannot ensure Olm sessions: shutting down`);\n }\n logger.info(\"Checking for missing Olm sessions\");\n // By passing the userId array to rust we transfer ownership of the items to rust, causing\n // them to be invalidated on the JS side as soon as the method is called.\n // As we haven't created the `userList` let's clone the users, to not break the caller from re-using it.\n const claimRequest = await this.olmMachine.getMissingSessions(userList.map((u) => u.clone()));\n if (claimRequest) {\n logger.info(\"Making /keys/claim request\");\n await this.outgoingRequestProcessor.makeOutgoingRequest(claimRequest);\n }\n logger.info(\"Olm sessions prepared\");\n }\n}\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,eAAe,CAAC;EAIlBC,WAAWA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B,CAAC;IAAC;EACzC;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"KeyClaimManager.js","names":[],"sources":["../../src/rust-crypto/KeyClaimManager.ts"],"sourcesContent":["/*\nCopyright 2023 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { type OlmMachine, type UserId } from \"@matrix-org/matrix-sdk-crypto-wasm\";\n\nimport { type OutgoingRequestProcessor } from \"./OutgoingRequestProcessor.ts\";\nimport { type LogSpan } from \"../logger.ts\";\n\n/**\n * KeyClaimManager: linearises calls to OlmMachine.getMissingSessions to avoid races\n *\n * We have one of these per `RustCrypto` (and hence per `MatrixClient`).\n *\n * @internal\n */\nexport class KeyClaimManager {\n private currentClaimPromise: Promise<void>;\n private stopped = false;\n\n public constructor(\n private readonly olmMachine: OlmMachine,\n private readonly outgoingRequestProcessor: OutgoingRequestProcessor,\n ) {\n this.currentClaimPromise = Promise.resolve();\n }\n\n /**\n * Tell the KeyClaimManager to immediately stop processing requests.\n *\n * Any further calls, and any still in the queue, will fail with an error.\n */\n public stop(): void {\n this.stopped = true;\n }\n\n /**\n * Given a list of users, attempt to ensure that we have Olm Sessions active with each of their devices\n *\n * If we don't have an active olm session, we will claim a one-time key and start one.\n * @param logger - logger to use\n * @param userList - list of userIDs to claim\n */\n public ensureSessionsForUsers(logger: LogSpan, userList: Array<UserId>): Promise<void> {\n // The Rust-SDK requires that we only have one getMissingSessions process in flight at once. This little dance\n // ensures that, by only having one call to ensureSessionsForUsersInner active at once (and making them\n // queue up in order).\n const prom = this.currentClaimPromise\n .catch(() => {\n // any errors in the previous claim will have been reported already, so there is nothing to do here.\n // we just throw away the error and start anew.\n })\n .then(() => this.ensureSessionsForUsersInner(logger, userList));\n this.currentClaimPromise = prom;\n return prom;\n }\n\n private async ensureSessionsForUsersInner(logger: LogSpan, userList: Array<UserId>): Promise<void> {\n // bail out quickly if we've been stopped.\n if (this.stopped) {\n throw new Error(`Cannot ensure Olm sessions: shutting down`);\n }\n logger.info(\"Checking for missing Olm sessions\");\n // By passing the userId array to rust we transfer ownership of the items to rust, causing\n // them to be invalidated on the JS side as soon as the method is called.\n // As we haven't created the `userList` let's clone the users, to not break the caller from re-using it.\n const claimRequest = await this.olmMachine.getMissingSessions(userList.map((u) => u.clone()));\n if (claimRequest) {\n logger.info(\"Making /keys/claim request\");\n await this.outgoingRequestProcessor.makeOutgoingRequest(claimRequest);\n }\n logger.info(\"Olm sessions prepared\");\n }\n}\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAM,eAAe,CAAC;EAIlB,WAAW,CACG,UAAsB,EACtB,wBAAkD,EACrE;IAAA;IAAA,iCALgB,KAAK;IAAA,KAGF,UAAsB,GAAtB,UAAsB;IAAA,KACtB,wBAAkD,GAAlD,wBAAkD;IAEnE,IAAI,CAAC,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;EAChD;;EAEA;AACJ;AACA;AACA;AACA;EACW,IAAI,GAAS;IAChB,IAAI,CAAC,OAAO,GAAG,IAAI;EACvB;;EAEA;AACJ;AACA;AACA;AACA;AACA;AACA;EACW,sBAAsB,CAAC,MAAe,EAAE,QAAuB,EAAiB;IACnF;IACA;IACA;IACA,MAAM,IAAI,GAAG,IAAI,CAAC,mBAAmB,CAChC,KAAK,CAAC,MAAM;MACT;MACA;IAAA,CACH,CAAC,CACD,IAAI,CAAC,MAAM,IAAI,CAAC,2BAA2B,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACnE,IAAI,CAAC,mBAAmB,GAAG,IAAI;IAC/B,OAAO,IAAI;EACf;EAEA,MAAc,2BAA2B,CAAC,MAAe,EAAE,QAAuB,EAAiB;IAC/F;IACA,IAAI,IAAI,CAAC,OAAO,EAAE;MACd,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC;IAChE;IACA,MAAM,CAAC,IAAI,CAAC,mCAAmC,CAAC;IAChD;IACA;IACA;IACA,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,QAAQ,CAAC,GAAG,CAAE,CAAC,IAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC7F,IAAI,YAAY,EAAE;MACd,MAAM,CAAC,IAAI,CAAC,4BAA4B,CAAC;MACzC,MAAM,IAAI,CAAC,wBAAwB,CAAC,mBAAmB,CAAC,YAAY,CAAC;IACzE;IACA,MAAM,CAAC,IAAI,CAAC,uBAAuB,CAAC;EACxC;AACJ","ignoreList":[]}
@@ -1,8 +1,4 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
4
- 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; }
5
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1
+ import _objectSpread from "@babel/runtime/helpers/objectSpread2";
6
2
  /*
7
3
  Copyright 2023 The Matrix.org Foundation C.I.C.
8
4
 
@@ -43,62 +39,59 @@ export class OutgoingRequestProcessor {
43
39
  this.olmMachine = olmMachine;
44
40
  this.http = http;
45
41
  }
46
- makeOutgoingRequest(msg, uiaCallback) {
47
- var _this = this;
48
- return _asyncToGenerator(function* () {
49
- var resp;
42
+ async makeOutgoingRequest(msg, uiaCallback) {
43
+ let resp;
50
44
 
51
- /* refer https://docs.rs/matrix-sdk-crypto/0.6.0/matrix_sdk_crypto/requests/enum.OutgoingRequests.html
52
- * for the complete list of request types
53
- */
54
- if (msg instanceof KeysUploadRequest) {
55
- resp = yield _this.requestWithRetry(Method.Post, "/_matrix/client/v3/keys/upload", {}, msg.body);
56
- } else if (msg instanceof KeysQueryRequest) {
57
- resp = yield _this.requestWithRetry(Method.Post, "/_matrix/client/v3/keys/query", {}, msg.body);
58
- } else if (msg instanceof KeysClaimRequest) {
59
- resp = yield _this.requestWithRetry(Method.Post, "/_matrix/client/v3/keys/claim", {}, msg.body);
60
- } else if (msg instanceof SignatureUploadRequest) {
61
- resp = yield _this.requestWithRetry(Method.Post, "/_matrix/client/v3/keys/signatures/upload", {}, msg.body);
62
- } else if (msg instanceof KeysBackupRequest) {
63
- resp = yield _this.requestWithRetry(Method.Put, "/_matrix/client/v3/room_keys/keys", {
64
- version: msg.version
65
- }, msg.body);
66
- } else if (msg instanceof ToDeviceRequest) {
67
- resp = yield _this.sendToDeviceRequest(msg);
68
- } else if (msg instanceof RoomMessageRequest) {
69
- var path = "/_matrix/client/v3/rooms/".concat(encodeURIComponent(msg.room_id), "/send/") + "".concat(encodeURIComponent(msg.event_type), "/").concat(encodeURIComponent(msg.txn_id));
70
- resp = yield _this.requestWithRetry(Method.Put, path, {}, msg.body);
71
- } else if (msg instanceof UploadSigningKeysRequest) {
72
- yield _this.makeRequestWithUIA(Method.Post, "/_matrix/client/v3/keys/device_signing/upload", {}, msg.body, uiaCallback);
73
- // SigningKeysUploadRequest does not implement OutgoingRequest and does not need to be marked as sent.
74
- return;
75
- } else if (msg instanceof PutDehydratedDeviceRequest) {
76
- var _path = DehydrationUnstablePrefix + "/dehydrated_device";
77
- yield _this.rawJsonRequest(Method.Put, _path, {}, msg.body);
78
- // PutDehydratedDeviceRequest does not implement OutgoingRequest and does not need to be marked as sent.
79
- return;
80
- } else {
81
- _this.logger.warn("Unsupported outgoing message", Object.getPrototypeOf(msg));
82
- resp = "";
83
- }
84
- if (msg.id) {
85
- try {
86
- yield logDuration(_this.logger, "Mark Request as sent ".concat(msg.type), /*#__PURE__*/_asyncToGenerator(function* () {
87
- yield _this.olmMachine.markRequestAsSent(msg.id, msg.type, resp);
88
- }));
89
- } catch (e) {
90
- // Ignore errors which are caused by the olmMachine having been freed. The exact error message depends
91
- // on whether we are using a release or develop build of rust-sdk-crypto-wasm.
92
- if (e instanceof Error && (e.message === "Attempt to use a moved value" || e.message === "null pointer passed to rust")) {
93
- _this.logger.debug("Ignoring error '".concat(e.message, "': client is likely shutting down"));
94
- } else {
95
- throw e;
96
- }
45
+ /* refer https://docs.rs/matrix-sdk-crypto/0.6.0/matrix_sdk_crypto/requests/enum.OutgoingRequests.html
46
+ * for the complete list of request types
47
+ */
48
+ if (msg instanceof KeysUploadRequest) {
49
+ resp = await this.requestWithRetry(Method.Post, "/_matrix/client/v3/keys/upload", {}, msg.body);
50
+ } else if (msg instanceof KeysQueryRequest) {
51
+ resp = await this.requestWithRetry(Method.Post, "/_matrix/client/v3/keys/query", {}, msg.body);
52
+ } else if (msg instanceof KeysClaimRequest) {
53
+ resp = await this.requestWithRetry(Method.Post, "/_matrix/client/v3/keys/claim", {}, msg.body);
54
+ } else if (msg instanceof SignatureUploadRequest) {
55
+ resp = await this.requestWithRetry(Method.Post, "/_matrix/client/v3/keys/signatures/upload", {}, msg.body);
56
+ } else if (msg instanceof KeysBackupRequest) {
57
+ resp = await this.requestWithRetry(Method.Put, "/_matrix/client/v3/room_keys/keys", {
58
+ version: msg.version
59
+ }, msg.body);
60
+ } else if (msg instanceof ToDeviceRequest) {
61
+ resp = await this.sendToDeviceRequest(msg);
62
+ } else if (msg instanceof RoomMessageRequest) {
63
+ const path = `/_matrix/client/v3/rooms/${encodeURIComponent(msg.room_id)}/send/` + `${encodeURIComponent(msg.event_type)}/${encodeURIComponent(msg.txn_id)}`;
64
+ resp = await this.requestWithRetry(Method.Put, path, {}, msg.body);
65
+ } else if (msg instanceof UploadSigningKeysRequest) {
66
+ await this.makeRequestWithUIA(Method.Post, "/_matrix/client/v3/keys/device_signing/upload", {}, msg.body, uiaCallback);
67
+ // SigningKeysUploadRequest does not implement OutgoingRequest and does not need to be marked as sent.
68
+ return;
69
+ } else if (msg instanceof PutDehydratedDeviceRequest) {
70
+ const path = DehydrationUnstablePrefix + "/dehydrated_device";
71
+ await this.rawJsonRequest(Method.Put, path, {}, msg.body);
72
+ // PutDehydratedDeviceRequest does not implement OutgoingRequest and does not need to be marked as sent.
73
+ return;
74
+ } else {
75
+ this.logger.warn("Unsupported outgoing message", Object.getPrototypeOf(msg));
76
+ resp = "";
77
+ }
78
+ if (msg.id) {
79
+ try {
80
+ await logDuration(this.logger, `Mark Request as sent ${msg.type}`, async () => {
81
+ await this.olmMachine.markRequestAsSent(msg.id, msg.type, resp);
82
+ });
83
+ } catch (e) {
84
+ // Ignore errors which are caused by the olmMachine having been freed. The exact error message depends
85
+ // on whether we are using a release or develop build of rust-sdk-crypto-wasm.
86
+ if (e instanceof Error && (e.message === "Attempt to use a moved value" || e.message === "null pointer passed to rust")) {
87
+ this.logger.debug(`Ignoring error '${e.message}': client is likely shutting down`);
88
+ } else {
89
+ throw e;
97
90
  }
98
- } else {
99
- _this.logger.trace("Outgoing request type:".concat(msg.type, " does not have an ID"));
100
91
  }
101
- })();
92
+ } else {
93
+ this.logger.trace(`Outgoing request type:${msg.type} does not have an ID`);
94
+ }
102
95
  }
103
96
 
104
97
  /**
@@ -107,95 +100,72 @@ export class OutgoingRequestProcessor {
107
100
  * @param request - request to send
108
101
  * @returns JSON-serialized body of the response, if successful
109
102
  */
110
- sendToDeviceRequest(request) {
111
- var _this2 = this;
112
- return _asyncToGenerator(function* () {
113
- // a bit of extra logging, to help trace to-device messages through the system
114
- var parsedBody = JSON.parse(request.body);
115
- var messageList = [];
116
- for (var _ref4 of Object.entries(parsedBody.messages)) {
117
- var _ref3 = _slicedToArray(_ref4, 2);
118
- var userId = _ref3[0];
119
- var perUserMessages = _ref3[1];
120
- for (var _ref7 of Object.entries(perUserMessages)) {
121
- var _ref6 = _slicedToArray(_ref7, 2);
122
- var deviceId = _ref6[0];
123
- var message = _ref6[1];
124
- messageList.push("".concat(userId, "/").concat(deviceId, " (msgid ").concat(message[ToDeviceMessageId], ")"));
125
- }
103
+ async sendToDeviceRequest(request) {
104
+ // a bit of extra logging, to help trace to-device messages through the system
105
+ const parsedBody = JSON.parse(request.body);
106
+ const messageList = [];
107
+ for (const [userId, perUserMessages] of Object.entries(parsedBody.messages)) {
108
+ for (const [deviceId, message] of Object.entries(perUserMessages)) {
109
+ messageList.push(`${userId}/${deviceId} (msgid ${message[ToDeviceMessageId]})`);
126
110
  }
127
- _this2.logger.info("Sending batch of to-device messages. type=".concat(request.event_type, " txnid=").concat(request.txn_id), messageList);
128
- var path = "/_matrix/client/v3/sendToDevice/".concat(encodeURIComponent(request.event_type), "/") + encodeURIComponent(request.txn_id);
129
- return yield _this2.requestWithRetry(Method.Put, path, {}, request.body);
130
- })();
111
+ }
112
+ this.logger.info(`Sending batch of to-device messages. type=${request.event_type} txnid=${request.txn_id}`, messageList);
113
+ const path = `/_matrix/client/v3/sendToDevice/${encodeURIComponent(request.event_type)}/` + encodeURIComponent(request.txn_id);
114
+ return await this.requestWithRetry(Method.Put, path, {}, request.body);
131
115
  }
132
- makeRequestWithUIA(method, path, queryParams, body, uiaCallback) {
133
- var _this3 = this;
134
- return _asyncToGenerator(function* () {
135
- if (!uiaCallback) {
136
- return yield _this3.requestWithRetry(method, path, queryParams, body);
116
+ async makeRequestWithUIA(method, path, queryParams, body, uiaCallback) {
117
+ if (!uiaCallback) {
118
+ return await this.requestWithRetry(method, path, queryParams, body);
119
+ }
120
+ const parsedBody = JSON.parse(body);
121
+ const makeRequest = async auth => {
122
+ const newBody = _objectSpread({}, parsedBody);
123
+ if (auth !== null) {
124
+ newBody.auth = auth;
137
125
  }
138
- var parsedBody = JSON.parse(body);
139
- var makeRequest = /*#__PURE__*/function () {
140
- var _ref8 = _asyncToGenerator(function* (auth) {
141
- var newBody = _objectSpread({}, parsedBody);
142
- if (auth !== null) {
143
- newBody.auth = auth;
144
- }
145
- var resp = yield _this3.requestWithRetry(method, path, queryParams, JSON.stringify(newBody));
146
- return JSON.parse(resp);
147
- });
148
- return function makeRequest(_x) {
149
- return _ref8.apply(this, arguments);
150
- };
151
- }();
152
- var resp = yield uiaCallback(makeRequest);
153
- return JSON.stringify(resp);
154
- })();
126
+ const resp = await this.requestWithRetry(method, path, queryParams, JSON.stringify(newBody));
127
+ return JSON.parse(resp);
128
+ };
129
+ const resp = await uiaCallback(makeRequest);
130
+ return JSON.stringify(resp);
155
131
  }
156
- requestWithRetry(method, path, queryParams, body) {
157
- var _this4 = this;
158
- return _asyncToGenerator(function* () {
159
- var currentRetryCount = 0;
132
+ async requestWithRetry(method, path, queryParams, body) {
133
+ let currentRetryCount = 0;
160
134
 
161
- // eslint-disable-next-line no-constant-condition
162
- while (true) {
163
- try {
164
- return yield _this4.rawJsonRequest(method, path, queryParams, body);
165
- } catch (e) {
166
- currentRetryCount++;
167
- var backoff = calculateRetryBackoff(e, currentRetryCount, true);
168
- if (backoff < 0) {
169
- // Max number of retries reached, or error is not retryable. rethrow the error
170
- throw e;
171
- }
172
- // wait for the specified time and then retry the request
173
- yield sleep(backoff);
135
+ // eslint-disable-next-line no-constant-condition
136
+ while (true) {
137
+ try {
138
+ return await this.rawJsonRequest(method, path, queryParams, body);
139
+ } catch (e) {
140
+ currentRetryCount++;
141
+ const backoff = calculateRetryBackoff(e, currentRetryCount, true);
142
+ if (backoff < 0) {
143
+ // Max number of retries reached, or error is not retryable. rethrow the error
144
+ throw e;
174
145
  }
146
+ // wait for the specified time and then retry the request
147
+ await sleep(backoff);
175
148
  }
176
- })();
149
+ }
177
150
  }
178
- rawJsonRequest(method, path, queryParams, body) {
179
- var _this5 = this;
180
- return _asyncToGenerator(function* () {
181
- var opts = {
182
- // inhibit the JSON stringification and parsing within HttpApi.
183
- json: false,
184
- // nevertheless, we are sending, and accept, JSON.
185
- headers: {
186
- "Content-Type": "application/json",
187
- "Accept": "application/json"
188
- },
189
- // we use the full prefix
190
- prefix: "",
191
- // We set a timeout of 60 seconds to guard against requests getting stuck forever and wedging the
192
- // request loop (cf https://github.com/element-hq/element-web/issues/29534).
193
- //
194
- // (XXX: should we do this in the whole of the js-sdk?)
195
- localTimeoutMs: 60000
196
- };
197
- return yield _this5.http.authedRequest(method, path, queryParams, body, opts);
198
- })();
151
+ async rawJsonRequest(method, path, queryParams, body) {
152
+ const opts = {
153
+ // inhibit the JSON stringification and parsing within HttpApi.
154
+ json: false,
155
+ // nevertheless, we are sending, and accept, JSON.
156
+ headers: {
157
+ "Content-Type": "application/json",
158
+ "Accept": "application/json"
159
+ },
160
+ // we use the full prefix
161
+ prefix: "",
162
+ // We set a timeout of 60 seconds to guard against requests getting stuck forever and wedging the
163
+ // request loop (cf https://github.com/element-hq/element-web/issues/29534).
164
+ //
165
+ // (XXX: should we do this in the whole of the js-sdk?)
166
+ localTimeoutMs: 60000
167
+ };
168
+ return await this.http.authedRequest(method, path, queryParams, body, opts);
199
169
  }
200
170
  }
201
171
  //# sourceMappingURL=OutgoingRequestProcessor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"OutgoingRequestProcessor.js","names":["KeysBackupRequest","KeysClaimRequest","KeysQueryRequest","KeysUploadRequest","PutDehydratedDeviceRequest","RoomMessageRequest","SignatureUploadRequest","ToDeviceRequest","UploadSigningKeysRequest","calculateRetryBackoff","Method","logDuration","sleep","ToDeviceMessageId","UnstablePrefix","DehydrationUnstablePrefix","OutgoingRequestProcessor","constructor","logger","olmMachine","http","makeOutgoingRequest","msg","uiaCallback","_this","_asyncToGenerator","resp","requestWithRetry","Post","body","Put","version","sendToDeviceRequest","path","concat","encodeURIComponent","room_id","event_type","txn_id","makeRequestWithUIA","rawJsonRequest","warn","Object","getPrototypeOf","id","type","markRequestAsSent","e","Error","message","debug","trace","request","_this2","parsedBody","JSON","parse","messageList","_ref4","entries","messages","_ref3","_slicedToArray","userId","perUserMessages","_ref7","_ref6","deviceId","push","info","method","queryParams","_this3","makeRequest","_ref8","auth","newBody","_objectSpread","stringify","_x","apply","arguments","_this4","currentRetryCount","backoff","_this5","opts","json","headers","prefix","localTimeoutMs","authedRequest"],"sources":["../../src/rust-crypto/OutgoingRequestProcessor.ts"],"sourcesContent":["/*\nCopyright 2023 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport {\n KeysBackupRequest,\n KeysClaimRequest,\n KeysQueryRequest,\n KeysUploadRequest,\n type OlmMachine,\n type OutgoingRequest,\n PutDehydratedDeviceRequest,\n RoomMessageRequest,\n SignatureUploadRequest,\n ToDeviceRequest,\n UploadSigningKeysRequest,\n} from \"@matrix-org/matrix-sdk-crypto-wasm\";\n\nimport { type Logger } from \"../logger.ts\";\nimport { calculateRetryBackoff, type IHttpOpts, type MatrixHttpApi, Method } from \"../http-api/index.ts\";\nimport { logDuration, type QueryDict, sleep } from \"../utils.ts\";\nimport { type AuthDict, type UIAuthCallback } from \"../interactive-auth.ts\";\nimport { ToDeviceMessageId } from \"../@types/event.ts\";\nimport { UnstablePrefix as DehydrationUnstablePrefix } from \"./DehydratedDeviceManager.ts\";\n\n/**\n * OutgoingRequestManager: turns `OutgoingRequest`s from the rust sdk into HTTP requests\n *\n * We have one of these per `RustCrypto` (and hence per `MatrixClient`), not that it does anything terribly complicated.\n * It's responsible for:\n *\n * * holding the reference to the `MatrixHttpApi`\n * * turning `OutgoingRequest`s from the rust backend into HTTP requests, and sending them\n * * sending the results of such requests back to the rust backend.\n *\n * @internal\n */\nexport class OutgoingRequestProcessor {\n public constructor(\n private readonly logger: Logger,\n private readonly olmMachine: OlmMachine,\n private readonly http: MatrixHttpApi<IHttpOpts & { onlyData: true }>,\n ) {}\n\n public async makeOutgoingRequest<T>(\n msg: OutgoingRequest | UploadSigningKeysRequest | PutDehydratedDeviceRequest,\n uiaCallback?: UIAuthCallback<T>,\n ): Promise<void> {\n let resp: string;\n\n /* refer https://docs.rs/matrix-sdk-crypto/0.6.0/matrix_sdk_crypto/requests/enum.OutgoingRequests.html\n * for the complete list of request types\n */\n if (msg instanceof KeysUploadRequest) {\n resp = await this.requestWithRetry(Method.Post, \"/_matrix/client/v3/keys/upload\", {}, msg.body);\n } else if (msg instanceof KeysQueryRequest) {\n resp = await this.requestWithRetry(Method.Post, \"/_matrix/client/v3/keys/query\", {}, msg.body);\n } else if (msg instanceof KeysClaimRequest) {\n resp = await this.requestWithRetry(Method.Post, \"/_matrix/client/v3/keys/claim\", {}, msg.body);\n } else if (msg instanceof SignatureUploadRequest) {\n resp = await this.requestWithRetry(Method.Post, \"/_matrix/client/v3/keys/signatures/upload\", {}, msg.body);\n } else if (msg instanceof KeysBackupRequest) {\n resp = await this.requestWithRetry(\n Method.Put,\n \"/_matrix/client/v3/room_keys/keys\",\n { version: msg.version },\n msg.body,\n );\n } else if (msg instanceof ToDeviceRequest) {\n resp = await this.sendToDeviceRequest(msg);\n } else if (msg instanceof RoomMessageRequest) {\n const path =\n `/_matrix/client/v3/rooms/${encodeURIComponent(msg.room_id)}/send/` +\n `${encodeURIComponent(msg.event_type)}/${encodeURIComponent(msg.txn_id)}`;\n resp = await this.requestWithRetry(Method.Put, path, {}, msg.body);\n } else if (msg instanceof UploadSigningKeysRequest) {\n await this.makeRequestWithUIA(\n Method.Post,\n \"/_matrix/client/v3/keys/device_signing/upload\",\n {},\n msg.body,\n uiaCallback,\n );\n // SigningKeysUploadRequest does not implement OutgoingRequest and does not need to be marked as sent.\n return;\n } else if (msg instanceof PutDehydratedDeviceRequest) {\n const path = DehydrationUnstablePrefix + \"/dehydrated_device\";\n await this.rawJsonRequest(Method.Put, path, {}, msg.body);\n // PutDehydratedDeviceRequest does not implement OutgoingRequest and does not need to be marked as sent.\n return;\n } else {\n this.logger.warn(\"Unsupported outgoing message\", Object.getPrototypeOf(msg));\n resp = \"\";\n }\n\n if (msg.id) {\n try {\n await logDuration(this.logger, `Mark Request as sent ${msg.type}`, async () => {\n await this.olmMachine.markRequestAsSent(msg.id!, msg.type, resp);\n });\n } catch (e) {\n // Ignore errors which are caused by the olmMachine having been freed. The exact error message depends\n // on whether we are using a release or develop build of rust-sdk-crypto-wasm.\n if (\n e instanceof Error &&\n (e.message === \"Attempt to use a moved value\" || e.message === \"null pointer passed to rust\")\n ) {\n this.logger.debug(`Ignoring error '${e.message}': client is likely shutting down`);\n } else {\n throw e;\n }\n }\n } else {\n this.logger.trace(`Outgoing request type:${msg.type} does not have an ID`);\n }\n }\n\n /**\n * Send the HTTP request for a `ToDeviceRequest`\n *\n * @param request - request to send\n * @returns JSON-serialized body of the response, if successful\n */\n private async sendToDeviceRequest(request: ToDeviceRequest): Promise<string> {\n // a bit of extra logging, to help trace to-device messages through the system\n const parsedBody: { messages: Record<string, Record<string, Record<string, any>>> } = JSON.parse(request.body);\n\n const messageList = [];\n for (const [userId, perUserMessages] of Object.entries(parsedBody.messages)) {\n for (const [deviceId, message] of Object.entries(perUserMessages)) {\n messageList.push(`${userId}/${deviceId} (msgid ${message[ToDeviceMessageId]})`);\n }\n }\n\n this.logger.info(\n `Sending batch of to-device messages. type=${request.event_type} txnid=${request.txn_id}`,\n messageList,\n );\n\n const path =\n `/_matrix/client/v3/sendToDevice/${encodeURIComponent(request.event_type)}/` +\n encodeURIComponent(request.txn_id);\n return await this.requestWithRetry(Method.Put, path, {}, request.body);\n }\n\n private async makeRequestWithUIA<T>(\n method: Method,\n path: string,\n queryParams: QueryDict,\n body: string,\n uiaCallback: UIAuthCallback<T> | undefined,\n ): Promise<string> {\n if (!uiaCallback) {\n return await this.requestWithRetry(method, path, queryParams, body);\n }\n\n const parsedBody = JSON.parse(body);\n const makeRequest = async (auth: AuthDict | null): Promise<T> => {\n const newBody: Record<string, any> = {\n ...parsedBody,\n };\n if (auth !== null) {\n newBody.auth = auth;\n }\n const resp = await this.requestWithRetry(method, path, queryParams, JSON.stringify(newBody));\n return JSON.parse(resp) as T;\n };\n\n const resp = await uiaCallback(makeRequest);\n return JSON.stringify(resp);\n }\n\n private async requestWithRetry(\n method: Method,\n path: string,\n queryParams: QueryDict,\n body: string,\n ): Promise<string> {\n let currentRetryCount = 0;\n\n // eslint-disable-next-line no-constant-condition\n while (true) {\n try {\n return await this.rawJsonRequest(method, path, queryParams, body);\n } catch (e) {\n currentRetryCount++;\n const backoff = calculateRetryBackoff(e, currentRetryCount, true);\n if (backoff < 0) {\n // Max number of retries reached, or error is not retryable. rethrow the error\n throw e;\n }\n // wait for the specified time and then retry the request\n await sleep(backoff);\n }\n }\n }\n\n private async rawJsonRequest(method: Method, path: string, queryParams: QueryDict, body: string): Promise<string> {\n const opts = {\n // inhibit the JSON stringification and parsing within HttpApi.\n json: false,\n\n // nevertheless, we are sending, and accept, JSON.\n headers: {\n \"Content-Type\": \"application/json\",\n \"Accept\": \"application/json\",\n },\n\n // we use the full prefix\n prefix: \"\",\n\n // We set a timeout of 60 seconds to guard against requests getting stuck forever and wedging the\n // request loop (cf https://github.com/element-hq/element-web/issues/29534).\n //\n // (XXX: should we do this in the whole of the js-sdk?)\n localTimeoutMs: 60000,\n };\n\n return await this.http.authedRequest<string>(method, path, queryParams, body, opts);\n }\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EAAE;UACnB,IAAMC,OAAO,GAAG3E,qBAAqB,CAACsC,CAAC,EAAEoC,iBAAiB,EAAE,IAAI,CAAC;UACjE,IAAIC,OAAO,GAAG,CAAC,EAAE;YACb;YACA,MAAMrC,CAAC;UACX;UACA;UACA,MAAMnC,KAAK,CAACwE,OAAO,CAAC;QACxB;MACJ;IAAC;EACL;EAEc5C,cAAcA,CAAC8B,MAAc,EAAErC,IAAY,EAAEsC,WAAsB,EAAE1C,IAAY,EAAmB;IAAA,IAAAwD,MAAA;IAAA,OAAA5D,iBAAA;MAC9G,IAAM6D,IAAI,GAAG;QACT;QACAC,IAAI,EAAE,KAAK;QAEX;QACAC,OAAO,EAAE;UACL,cAAc,EAAE,kBAAkB;UAClC,QAAQ,EAAE;QACd,CAAC;QAED;QACAC,MAAM,EAAE,EAAE;QAEV;QACA;QACA;QACA;QACAC,cAAc,EAAE;MACpB,CAAC;MAED,aAAaL,MAAI,CAACjE,IAAI,CAACuE,aAAa,CAASrB,MAAM,EAAErC,IAAI,EAAEsC,WAAW,EAAE1C,IAAI,EAAEyD,IAAI,CAAC;IAAC;EACxF;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"OutgoingRequestProcessor.js","names":[],"sources":["../../src/rust-crypto/OutgoingRequestProcessor.ts"],"sourcesContent":["/*\nCopyright 2023 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport {\n KeysBackupRequest,\n KeysClaimRequest,\n KeysQueryRequest,\n KeysUploadRequest,\n type OlmMachine,\n type OutgoingRequest,\n PutDehydratedDeviceRequest,\n RoomMessageRequest,\n SignatureUploadRequest,\n ToDeviceRequest,\n UploadSigningKeysRequest,\n} from \"@matrix-org/matrix-sdk-crypto-wasm\";\n\nimport { type Logger } from \"../logger.ts\";\nimport { calculateRetryBackoff, type IHttpOpts, type MatrixHttpApi, Method } from \"../http-api/index.ts\";\nimport { logDuration, type QueryDict, sleep } from \"../utils.ts\";\nimport { type AuthDict, type UIAuthCallback } from \"../interactive-auth.ts\";\nimport { ToDeviceMessageId } from \"../@types/event.ts\";\nimport { UnstablePrefix as DehydrationUnstablePrefix } from \"./DehydratedDeviceManager.ts\";\n\n/**\n * OutgoingRequestManager: turns `OutgoingRequest`s from the rust sdk into HTTP requests\n *\n * We have one of these per `RustCrypto` (and hence per `MatrixClient`), not that it does anything terribly complicated.\n * It's responsible for:\n *\n * * holding the reference to the `MatrixHttpApi`\n * * turning `OutgoingRequest`s from the rust backend into HTTP requests, and sending them\n * * sending the results of such requests back to the rust backend.\n *\n * @internal\n */\nexport class OutgoingRequestProcessor {\n public constructor(\n private readonly logger: Logger,\n private readonly olmMachine: OlmMachine,\n private readonly http: MatrixHttpApi<IHttpOpts & { onlyData: true }>,\n ) {}\n\n public async makeOutgoingRequest<T>(\n msg: OutgoingRequest | UploadSigningKeysRequest | PutDehydratedDeviceRequest,\n uiaCallback?: UIAuthCallback<T>,\n ): Promise<void> {\n let resp: string;\n\n /* refer https://docs.rs/matrix-sdk-crypto/0.6.0/matrix_sdk_crypto/requests/enum.OutgoingRequests.html\n * for the complete list of request types\n */\n if (msg instanceof KeysUploadRequest) {\n resp = await this.requestWithRetry(Method.Post, \"/_matrix/client/v3/keys/upload\", {}, msg.body);\n } else if (msg instanceof KeysQueryRequest) {\n resp = await this.requestWithRetry(Method.Post, \"/_matrix/client/v3/keys/query\", {}, msg.body);\n } else if (msg instanceof KeysClaimRequest) {\n resp = await this.requestWithRetry(Method.Post, \"/_matrix/client/v3/keys/claim\", {}, msg.body);\n } else if (msg instanceof SignatureUploadRequest) {\n resp = await this.requestWithRetry(Method.Post, \"/_matrix/client/v3/keys/signatures/upload\", {}, msg.body);\n } else if (msg instanceof KeysBackupRequest) {\n resp = await this.requestWithRetry(\n Method.Put,\n \"/_matrix/client/v3/room_keys/keys\",\n { version: msg.version },\n msg.body,\n );\n } else if (msg instanceof ToDeviceRequest) {\n resp = await this.sendToDeviceRequest(msg);\n } else if (msg instanceof RoomMessageRequest) {\n const path =\n `/_matrix/client/v3/rooms/${encodeURIComponent(msg.room_id)}/send/` +\n `${encodeURIComponent(msg.event_type)}/${encodeURIComponent(msg.txn_id)}`;\n resp = await this.requestWithRetry(Method.Put, path, {}, msg.body);\n } else if (msg instanceof UploadSigningKeysRequest) {\n await this.makeRequestWithUIA(\n Method.Post,\n \"/_matrix/client/v3/keys/device_signing/upload\",\n {},\n msg.body,\n uiaCallback,\n );\n // SigningKeysUploadRequest does not implement OutgoingRequest and does not need to be marked as sent.\n return;\n } else if (msg instanceof PutDehydratedDeviceRequest) {\n const path = DehydrationUnstablePrefix + \"/dehydrated_device\";\n await this.rawJsonRequest(Method.Put, path, {}, msg.body);\n // PutDehydratedDeviceRequest does not implement OutgoingRequest and does not need to be marked as sent.\n return;\n } else {\n this.logger.warn(\"Unsupported outgoing message\", Object.getPrototypeOf(msg));\n resp = \"\";\n }\n\n if (msg.id) {\n try {\n await logDuration(this.logger, `Mark Request as sent ${msg.type}`, async () => {\n await this.olmMachine.markRequestAsSent(msg.id!, msg.type, resp);\n });\n } catch (e) {\n // Ignore errors which are caused by the olmMachine having been freed. The exact error message depends\n // on whether we are using a release or develop build of rust-sdk-crypto-wasm.\n if (\n e instanceof Error &&\n (e.message === \"Attempt to use a moved value\" || e.message === \"null pointer passed to rust\")\n ) {\n this.logger.debug(`Ignoring error '${e.message}': client is likely shutting down`);\n } else {\n throw e;\n }\n }\n } else {\n this.logger.trace(`Outgoing request type:${msg.type} does not have an ID`);\n }\n }\n\n /**\n * Send the HTTP request for a `ToDeviceRequest`\n *\n * @param request - request to send\n * @returns JSON-serialized body of the response, if successful\n */\n private async sendToDeviceRequest(request: ToDeviceRequest): Promise<string> {\n // a bit of extra logging, to help trace to-device messages through the system\n const parsedBody: { messages: Record<string, Record<string, Record<string, any>>> } = JSON.parse(request.body);\n\n const messageList = [];\n for (const [userId, perUserMessages] of Object.entries(parsedBody.messages)) {\n for (const [deviceId, message] of Object.entries(perUserMessages)) {\n messageList.push(`${userId}/${deviceId} (msgid ${message[ToDeviceMessageId]})`);\n }\n }\n\n this.logger.info(\n `Sending batch of to-device messages. type=${request.event_type} txnid=${request.txn_id}`,\n messageList,\n );\n\n const path =\n `/_matrix/client/v3/sendToDevice/${encodeURIComponent(request.event_type)}/` +\n encodeURIComponent(request.txn_id);\n return await this.requestWithRetry(Method.Put, path, {}, request.body);\n }\n\n private async makeRequestWithUIA<T>(\n method: Method,\n path: string,\n queryParams: QueryDict,\n body: string,\n uiaCallback: UIAuthCallback<T> | undefined,\n ): Promise<string> {\n if (!uiaCallback) {\n return await this.requestWithRetry(method, path, queryParams, body);\n }\n\n const parsedBody = JSON.parse(body);\n const makeRequest = async (auth: AuthDict | null): Promise<T> => {\n const newBody: Record<string, any> = {\n ...parsedBody,\n };\n if (auth !== null) {\n newBody.auth = auth;\n }\n const resp = await this.requestWithRetry(method, path, queryParams, JSON.stringify(newBody));\n return JSON.parse(resp) as T;\n };\n\n const resp = await uiaCallback(makeRequest);\n return JSON.stringify(resp);\n }\n\n private async requestWithRetry(\n method: Method,\n path: string,\n queryParams: QueryDict,\n body: string,\n ): Promise<string> {\n let currentRetryCount = 0;\n\n // eslint-disable-next-line no-constant-condition\n while (true) {\n try {\n return await this.rawJsonRequest(method, path, queryParams, body);\n } catch (e) {\n currentRetryCount++;\n const backoff = calculateRetryBackoff(e, currentRetryCount, true);\n if (backoff < 0) {\n // Max number of retries reached, or error is not retryable. rethrow the error\n throw e;\n }\n // wait for the specified time and then retry the request\n await sleep(backoff);\n }\n }\n }\n\n private async rawJsonRequest(method: Method, path: string, queryParams: QueryDict, body: string): Promise<string> {\n const opts = {\n // inhibit the JSON stringification and parsing within HttpApi.\n json: false,\n\n // nevertheless, we are sending, and accept, JSON.\n headers: {\n \"Content-Type\": \"application/json\",\n \"Accept\": \"application/json\",\n },\n\n // we use the full prefix\n prefix: \"\",\n\n // We set a timeout of 60 seconds to guard against requests getting stuck forever and wedging the\n // request loop (cf https://github.com/element-hq/element-web/issues/29534).\n //\n // (XXX: should we do this in the whole of the js-sdk?)\n localTimeoutMs: 60000,\n };\n\n return await this.http.authedRequest<string>(method, path, queryParams, body, opts);\n }\n}\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SACI,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EAGjB,0BAA0B,EAC1B,kBAAkB,EAClB,sBAAsB,EACtB,eAAe,EACf,wBAAwB,QACrB,oCAAoC;AAG3C,SAAS,qBAAqB,EAAsC,MAAM,QAAQ,sBAAsB;AACxG,SAAS,WAAW,EAAkB,KAAK,QAAQ,aAAa;AAEhE,SAAS,iBAAiB,QAAQ,oBAAoB;AACtD,SAAS,cAAc,IAAI,yBAAyB,QAAQ,8BAA8B;;AAE1F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAM,wBAAwB,CAAC;EAC3B,WAAW,CACG,MAAc,EACd,UAAsB,EACtB,IAAmD,EACtE;IAAA,KAHmB,MAAc,GAAd,MAAc;IAAA,KACd,UAAsB,GAAtB,UAAsB;IAAA,KACtB,IAAmD,GAAnD,IAAmD;EACrE;EAEH,MAAa,mBAAmB,CAC5B,GAA4E,EAC5E,WAA+B,EAClB;IACb,IAAI,IAAY;;IAEhB;AACR;AACA;IACQ,IAAI,GAAG,YAAY,iBAAiB,EAAE;MAClC,IAAI,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,IAAI,EAAE,gCAAgC,EAAE,CAAC,CAAC,EAAE,GAAG,CAA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