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
  /*
3
2
  Copyright 2023 The Matrix.org Foundation C.I.C.
4
3
 
@@ -23,8 +22,8 @@ limitations under the License.
23
22
  *
24
23
  * @internal
25
24
  */
26
- export function secretStorageContainsCrossSigningKeys(_x) {
27
- return _secretStorageContainsCrossSigningKeys.apply(this, arguments);
25
+ export async function secretStorageContainsCrossSigningKeys(secretStorage) {
26
+ return secretStorageCanAccessSecrets(secretStorage, ["m.cross_signing.master", "m.cross_signing.user_signing", "m.cross_signing.self_signing"]);
28
27
  }
29
28
 
30
29
  /**
@@ -37,27 +36,15 @@ export function secretStorageContainsCrossSigningKeys(_x) {
37
36
  *
38
37
  * @internal
39
38
  */
40
- function _secretStorageContainsCrossSigningKeys() {
41
- _secretStorageContainsCrossSigningKeys = _asyncToGenerator(function* (secretStorage) {
42
- return secretStorageCanAccessSecrets(secretStorage, ["m.cross_signing.master", "m.cross_signing.user_signing", "m.cross_signing.self_signing"]);
43
- });
44
- return _secretStorageContainsCrossSigningKeys.apply(this, arguments);
45
- }
46
- export function secretStorageCanAccessSecrets(_x2, _x3) {
47
- return _secretStorageCanAccessSecrets.apply(this, arguments);
48
- }
49
- function _secretStorageCanAccessSecrets() {
50
- _secretStorageCanAccessSecrets = _asyncToGenerator(function* (secretStorage, secretNames) {
51
- var defaultKeyId = yield secretStorage.getDefaultKeyId();
52
- if (!defaultKeyId) return false;
53
- for (var secretName of secretNames) {
54
- // check which keys this particular secret is encrypted with
55
- var record = (yield secretStorage.isStored(secretName)) || {};
56
- // if it's not encrypted with the right key, there is no point continuing
57
- if (!(defaultKeyId in record)) return false;
58
- }
59
- return true;
60
- });
61
- return _secretStorageCanAccessSecrets.apply(this, arguments);
39
+ export async function secretStorageCanAccessSecrets(secretStorage, secretNames) {
40
+ const defaultKeyId = await secretStorage.getDefaultKeyId();
41
+ if (!defaultKeyId) return false;
42
+ for (const secretName of secretNames) {
43
+ // check which keys this particular secret is encrypted with
44
+ const record = (await secretStorage.isStored(secretName)) || {};
45
+ // if it's not encrypted with the right key, there is no point continuing
46
+ if (!(defaultKeyId in record)) return false;
47
+ }
48
+ return true;
62
49
  }
63
50
  //# sourceMappingURL=secret-storage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"secret-storage.js","names":["secretStorageContainsCrossSigningKeys","_x","_secretStorageContainsCrossSigningKeys","apply","arguments","_asyncToGenerator","secretStorage","secretStorageCanAccessSecrets","_x2","_x3","_secretStorageCanAccessSecrets","secretNames","defaultKeyId","getDefaultKeyId","secretName","record","isStored"],"sources":["../../src/rust-crypto/secret-storage.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 SecretStorageKey, type ServerSideSecretStorage } from \"../secret-storage.ts\";\n\n/**\n * Check that the private cross signing keys (master, self signing, user signing) are stored in the secret storage and encrypted with the default secret storage key.\n *\n * @param secretStorage - The secret store using account data\n * @returns True if the cross-signing keys are all stored and encrypted with the same secret storage key.\n *\n * @internal\n */\nexport async function secretStorageContainsCrossSigningKeys(secretStorage: ServerSideSecretStorage): Promise<boolean> {\n return secretStorageCanAccessSecrets(secretStorage, [\n \"m.cross_signing.master\",\n \"m.cross_signing.user_signing\",\n \"m.cross_signing.self_signing\",\n ]);\n}\n\n/**\n *\n * Check that the secret storage can access the given secrets using the default key.\n *\n * @param secretStorage - The secret store using account data\n * @param secretNames - The secret names to check\n * @returns True if all the given secrets are accessible and encrypted with the given key.\n *\n * @internal\n */\nexport async function secretStorageCanAccessSecrets(\n secretStorage: ServerSideSecretStorage,\n secretNames: SecretStorageKey[],\n): Promise<boolean> {\n const defaultKeyId = await secretStorage.getDefaultKeyId();\n if (!defaultKeyId) return false;\n\n for (const secretName of secretNames) {\n // check which keys this particular secret is encrypted with\n const record = (await secretStorage.isStored(secretName)) || {};\n // if it's not encrypted with the right key, there is no point continuing\n if (!(defaultKeyId in record)) return false;\n }\n\n return true;\n}\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAsBA,qCAAqCA,CAAAC,EAAA;EAAA,OAAAC,sCAAA,CAAAC,KAAA,OAAAC,SAAA;AAAA;;AAQ3D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AATA,SAAAF,uCAAA;EAAAA,sCAAA,GAAAG,iBAAA,CARO,WAAqDC,aAAsC,EAAoB;IAClH,OAAOC,6BAA6B,CAACD,aAAa,EAAE,CAChD,wBAAwB,EACxB,8BAA8B,EAC9B,8BAA8B,CACjC,CAAC;EACN,CAAC;EAAA,OAAAJ,sCAAA,CAAAC,KAAA,OAAAC,SAAA;AAAA;AAYD,gBAAsBG,6BAA6BA,CAAAC,GAAA,EAAAC,GAAA;EAAA,OAAAC,8BAAA,CAAAP,KAAA,OAAAC,SAAA;AAAA;AAelD,SAAAM,+BAAA;EAAAA,8BAAA,GAAAL,iBAAA,CAfM,WACHC,aAAsC,EACtCK,WAA+B,EACf;IAChB,IAAMC,YAAY,SAASN,aAAa,CAACO,eAAe,CAAC,CAAC;IAC1D,IAAI,CAACD,YAAY,EAAE,OAAO,KAAK;IAE/B,KAAK,IAAME,UAAU,IAAIH,WAAW,EAAE;MAClC;MACA,IAAMI,MAAM,GAAG,OAAOT,aAAa,CAACU,QAAQ,CAACF,UAAU,CAAC,KAAK,CAAC,CAAC;MAC/D;MACA,IAAI,EAAEF,YAAY,IAAIG,MAAM,CAAC,EAAE,OAAO,KAAK;IAC/C;IAEA,OAAO,IAAI;EACf,CAAC;EAAA,OAAAL,8BAAA,CAAAP,KAAA,OAAAC,SAAA;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"secret-storage.js","names":[],"sources":["../../src/rust-crypto/secret-storage.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 SecretStorageKey, type ServerSideSecretStorage } from \"../secret-storage.ts\";\n\n/**\n * Check that the private cross signing keys (master, self signing, user signing) are stored in the secret storage and encrypted with the default secret storage key.\n *\n * @param secretStorage - The secret store using account data\n * @returns True if the cross-signing keys are all stored and encrypted with the same secret storage key.\n *\n * @internal\n */\nexport async function secretStorageContainsCrossSigningKeys(secretStorage: ServerSideSecretStorage): Promise<boolean> {\n return secretStorageCanAccessSecrets(secretStorage, [\n \"m.cross_signing.master\",\n \"m.cross_signing.user_signing\",\n \"m.cross_signing.self_signing\",\n ]);\n}\n\n/**\n *\n * Check that the secret storage can access the given secrets using the default key.\n *\n * @param secretStorage - The secret store using account data\n * @param secretNames - The secret names to check\n * @returns True if all the given secrets are accessible and encrypted with the given key.\n *\n * @internal\n */\nexport async function secretStorageCanAccessSecrets(\n secretStorage: ServerSideSecretStorage,\n secretNames: SecretStorageKey[],\n): Promise<boolean> {\n const defaultKeyId = await secretStorage.getDefaultKeyId();\n if (!defaultKeyId) return false;\n\n for (const secretName of secretNames) {\n // check which keys this particular secret is encrypted with\n const record = (await secretStorage.isStored(secretName)) || {};\n // if it's not encrypted with the right key, there is no point continuing\n if (!(defaultKeyId in record)) return false;\n }\n\n return true;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAe,qCAAqC,CAAC,aAAsC,EAAoB;EAClH,OAAO,6BAA6B,CAAC,aAAa,EAAE,CAChD,wBAAwB,EACxB,8BAA8B,EAC9B,8BAA8B,CACjC,CAAC;AACN;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAe,6BAA6B,CAC/C,aAAsC,EACtC,WAA+B,EACf;EAChB,MAAM,YAAY,GAAG,MAAM,aAAa,CAAC,eAAe,CAAC,CAAC;EAC1D,IAAI,CAAC,YAAY,EAAE,OAAO,KAAK;EAE/B,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE;IAClC;IACA,MAAM,MAAM,GAAG,CAAC,MAAM,aAAa,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IAC/D;IACA,IAAI,EAAE,YAAY,IAAI,MAAM,CAAC,EAAE,OAAO,KAAK;EAC/C;EAEA,OAAO,IAAI;AACf","ignoreList":[]}
@@ -1,5 +1,3 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
2
  /*
5
3
  Copyright 2023 The Matrix.org Foundation C.I.C.
@@ -41,11 +39,6 @@ export class RustVerificationRequest extends TypedEventEmitter {
41
39
  */
42
40
  constructor(logger, olmMachine, inner, outgoingRequestProcessor, supportedVerificationMethods) {
43
41
  super();
44
- this.logger = logger;
45
- this.olmMachine = olmMachine;
46
- this.inner = inner;
47
- this.outgoingRequestProcessor = outgoingRequestProcessor;
48
- this.supportedVerificationMethods = supportedVerificationMethods;
49
42
  /** a reëmitter which relays VerificationRequestEvent.Changed events emitted by the verifier */
50
43
  _defineProperty(this, "reEmitter", void 0);
51
44
  /** Are we in the process of sending an `m.key.verification.ready` event? */
@@ -53,6 +46,11 @@ export class RustVerificationRequest extends TypedEventEmitter {
53
46
  /** Are we in the process of sending an `m.key.verification.cancellation` event? */
54
47
  _defineProperty(this, "_cancelling", false);
55
48
  _defineProperty(this, "_verifier", void 0);
49
+ this.logger = logger;
50
+ this.olmMachine = olmMachine;
51
+ this.inner = inner;
52
+ this.outgoingRequestProcessor = outgoingRequestProcessor;
53
+ this.supportedVerificationMethods = supportedVerificationMethods;
56
54
  this.reEmitter = new TypedReEmitter(this);
57
55
 
58
56
  // Obviously, the Rust object maintains a reference to the callback function. If the callback function maintains
@@ -61,18 +59,15 @@ export class RustVerificationRequest extends TypedEventEmitter {
61
59
  //
62
60
  // To avoid this reference cycle, use a weak reference in the callback function. If the `RustVerificationRequest`
63
61
  // gets garbage-collected, then there is nothing to update!
64
- var weakThis = new WeakRef(this);
65
- inner.registerChangesCallback(/*#__PURE__*/_asyncToGenerator(function* () {
66
- var _weakThis$deref;
67
- return (_weakThis$deref = weakThis.deref()) === null || _weakThis$deref === void 0 ? void 0 : _weakThis$deref.onChange();
68
- }));
62
+ const weakThis = new WeakRef(this);
63
+ inner.registerChangesCallback(async () => weakThis.deref()?.onChange());
69
64
  }
70
65
 
71
66
  /**
72
67
  * Hook which is called when the underlying rust class notifies us that there has been a change.
73
68
  */
74
69
  onChange() {
75
- var verification = this.inner.getVerification();
70
+ const verification = this.inner.getVerification();
76
71
 
77
72
  // Set the _verifier object (wrapping the rust `Verification` as a js-sdk Verifier) if:
78
73
  // - we now have a `Verification` where we lacked one before
@@ -114,8 +109,7 @@ export class RustVerificationRequest extends TypedEventEmitter {
114
109
  * For to-device verifications, `undefined`.
115
110
  */
116
111
  get roomId() {
117
- var _this$inner$roomId;
118
- return (_this$inner$roomId = this.inner.roomId) === null || _this$inner$roomId === void 0 ? void 0 : _this$inner$roomId.toString();
112
+ return this.inner.roomId?.toString();
119
113
  }
120
114
 
121
115
  /**
@@ -135,20 +129,16 @@ export class RustVerificationRequest extends TypedEventEmitter {
135
129
 
136
130
  /** For verifications via to-device messages: the ID of the other device. Otherwise, undefined. */
137
131
  get otherDeviceId() {
138
- var _this$inner$otherDevi;
139
- return (_this$inner$otherDevi = this.inner.otherDeviceId) === null || _this$inner$otherDevi === void 0 ? void 0 : _this$inner$otherDevi.toString();
132
+ return this.inner.otherDeviceId?.toString();
140
133
  }
141
134
 
142
135
  /** Get the other device involved in the verification, if it is known */
143
- getOtherDevice() {
144
- var _this = this;
145
- return _asyncToGenerator(function* () {
146
- var otherDeviceId = _this.inner.otherDeviceId;
147
- if (!otherDeviceId) {
148
- return undefined;
149
- }
150
- return yield _this.olmMachine.getDevice(_this.inner.otherUserId, otherDeviceId, 5);
151
- })();
136
+ async getOtherDevice() {
137
+ const otherDeviceId = this.inner.otherDeviceId;
138
+ if (!otherDeviceId) {
139
+ return undefined;
140
+ }
141
+ return await this.olmMachine.getDevice(this.inner.otherUserId, otherDeviceId, 5);
152
142
  }
153
143
 
154
144
  /** True if the other party in this request is one of this user's own devices. */
@@ -158,7 +148,7 @@ export class RustVerificationRequest extends TypedEventEmitter {
158
148
 
159
149
  /** current phase of the request. */
160
150
  get phase() {
161
- var phase = this.inner.phase();
151
+ const phase = this.inner.phase();
162
152
  switch (phase) {
163
153
  case RustSdkCryptoJs.VerificationRequestPhase.Created:
164
154
  case RustSdkCryptoJs.VerificationRequestPhase.Requested:
@@ -178,7 +168,7 @@ export class RustVerificationRequest extends TypedEventEmitter {
178
168
  case RustSdkCryptoJs.VerificationRequestPhase.Cancelled:
179
169
  return VerificationPhase.Cancelled;
180
170
  }
181
- throw new Error("Unknown verification phase ".concat(phase));
171
+ throw new Error(`Unknown verification phase ${phase}`);
182
172
  }
183
173
 
184
174
  /** True if the request has sent its initial event and needs more events to complete
@@ -186,7 +176,7 @@ export class RustVerificationRequest extends TypedEventEmitter {
186
176
  */
187
177
  get pending() {
188
178
  if (this.inner.isPassive()) return false;
189
- var phase = this.phase;
179
+ const phase = this.phase;
190
180
  return phase !== VerificationPhase.Done && phase !== VerificationPhase.Cancelled;
191
181
  }
192
182
 
@@ -223,7 +213,7 @@ export class RustVerificationRequest extends TypedEventEmitter {
223
213
  /** the method picked in the .start event */
224
214
  get chosenMethod() {
225
215
  if (this.phase !== VerificationPhase.Started) return null;
226
- var verification = this.inner.getVerification();
216
+ const verification = this.inner.getVerification();
227
217
  if (verification instanceof RustSdkCryptoJs.Sas) {
228
218
  return VerificationMethod.Sas;
229
219
  } else if (verification instanceof RustSdkCryptoJs.Qr) {
@@ -243,12 +233,12 @@ export class RustVerificationRequest extends TypedEventEmitter {
243
233
  * @returns true if the other party said they supported the method
244
234
  */
245
235
  otherPartySupportsMethod(method) {
246
- var theirMethods = this.inner.theirSupportedMethods;
236
+ const theirMethods = this.inner.theirSupportedMethods;
247
237
  if (theirMethods === undefined) {
248
238
  // no message from the other side yet
249
239
  return false;
250
240
  }
251
- var requiredMethod = verificationMethodsByIdentifier[method];
241
+ const requiredMethod = verificationMethodsByIdentifier[method];
252
242
  return theirMethods.some(m => m === requiredMethod);
253
243
  }
254
244
 
@@ -257,25 +247,22 @@ export class RustVerificationRequest extends TypedEventEmitter {
257
247
  *
258
248
  * @returns Promise which resolves when the event has been sent.
259
249
  */
260
- accept() {
261
- var _this2 = this;
262
- return _asyncToGenerator(function* () {
263
- if (_this2.inner.phase() !== RustSdkCryptoJs.VerificationRequestPhase.Requested || _this2._accepting) {
264
- throw new Error("Cannot accept a verification request in phase ".concat(_this2.phase));
265
- }
266
- _this2._accepting = true;
267
- try {
268
- var req = _this2.inner.acceptWithMethods(_this2.supportedVerificationMethods.map(verificationMethodIdentifierToMethod));
269
- if (req) {
270
- yield _this2.outgoingRequestProcessor.makeOutgoingRequest(req);
271
- }
272
- } finally {
273
- _this2._accepting = false;
250
+ async accept() {
251
+ if (this.inner.phase() !== RustSdkCryptoJs.VerificationRequestPhase.Requested || this._accepting) {
252
+ throw new Error(`Cannot accept a verification request in phase ${this.phase}`);
253
+ }
254
+ this._accepting = true;
255
+ try {
256
+ const req = this.inner.acceptWithMethods(this.supportedVerificationMethods.map(verificationMethodIdentifierToMethod));
257
+ if (req) {
258
+ await this.outgoingRequestProcessor.makeOutgoingRequest(req);
274
259
  }
260
+ } finally {
261
+ this._accepting = false;
262
+ }
275
263
 
276
- // phase may have changed, so emit a 'change' event
277
- _this2.emit(VerificationRequestEvent.Change);
278
- })();
264
+ // phase may have changed, so emit a 'change' event
265
+ this.emit(VerificationRequestEvent.Change);
279
266
  }
280
267
 
281
268
  /**
@@ -286,24 +273,21 @@ export class RustVerificationRequest extends TypedEventEmitter {
286
273
  *
287
274
  * @returns Promise which resolves when the event has been sent.
288
275
  */
289
- cancel(params) {
290
- var _this3 = this;
291
- return _asyncToGenerator(function* () {
292
- if (_this3._cancelling) {
293
- // already cancelling; do nothing
294
- return;
295
- }
296
- _this3.logger.info("Cancelling verification request with params:", params);
297
- _this3._cancelling = true;
298
- try {
299
- var req = _this3.inner.cancel();
300
- if (req) {
301
- yield _this3.outgoingRequestProcessor.makeOutgoingRequest(req);
302
- }
303
- } finally {
304
- _this3._cancelling = false;
276
+ async cancel(params) {
277
+ if (this._cancelling) {
278
+ // already cancelling; do nothing
279
+ return;
280
+ }
281
+ this.logger.info("Cancelling verification request with params:", params);
282
+ this._cancelling = true;
283
+ try {
284
+ const req = this.inner.cancel();
285
+ if (req) {
286
+ await this.outgoingRequestProcessor.makeOutgoingRequest(req);
305
287
  }
306
- })();
288
+ } finally {
289
+ this._cancelling = false;
290
+ }
307
291
  }
308
292
 
309
293
  /**
@@ -332,30 +316,26 @@ export class RustVerificationRequest extends TypedEventEmitter {
332
316
  *
333
317
  * @param method - the name of the verification method to use.
334
318
  */
335
- startVerification(method) {
336
- var _this4 = this;
337
- return _asyncToGenerator(function* () {
338
- if (method !== VerificationMethod.Sas) {
339
- throw new Error("Unsupported verification method ".concat(method));
340
- }
319
+ async startVerification(method) {
320
+ if (method !== VerificationMethod.Sas) {
321
+ throw new Error(`Unsupported verification method ${method}`);
322
+ }
341
323
 
342
- // make sure that we have a list of the other user's devices (workaround https://github.com/matrix-org/matrix-rust-sdk/issues/2896)
343
- if (!(yield _this4.getOtherDevice())) {
344
- throw new Error("startVerification(): other device is unknown");
345
- }
346
- var res = yield _this4.inner.startSas();
347
- if (res) {
348
- var _res = _slicedToArray(res, 2),
349
- req = _res[1];
350
- yield _this4.outgoingRequestProcessor.makeOutgoingRequest(req);
351
- }
324
+ // make sure that we have a list of the other user's devices (workaround https://github.com/matrix-org/matrix-rust-sdk/issues/2896)
325
+ if (!(await this.getOtherDevice())) {
326
+ throw new Error("startVerification(): other device is unknown");
327
+ }
328
+ const res = await this.inner.startSas();
329
+ if (res) {
330
+ const [, req] = res;
331
+ await this.outgoingRequestProcessor.makeOutgoingRequest(req);
332
+ }
352
333
 
353
- // this should have triggered the onChange callback, and we should now have a verifier
354
- if (!_this4._verifier) {
355
- throw new Error("Still no verifier after startSas() call");
356
- }
357
- return _this4._verifier;
358
- })();
334
+ // this should have triggered the onChange callback, and we should now have a verifier
335
+ if (!this._verifier) {
336
+ throw new Error("Still no verifier after startSas() call");
337
+ }
338
+ return this._verifier;
359
339
  }
360
340
 
361
341
  /**
@@ -366,24 +346,21 @@ export class RustVerificationRequest extends TypedEventEmitter {
366
346
  * @param qrCodeData - the decoded QR code.
367
347
  * @returns A verifier; call `.verify()` on it to wait for the other side to complete the verification flow.
368
348
  */
369
- scanQRCode(uint8Array) {
370
- var _this5 = this;
371
- return _asyncToGenerator(function* () {
372
- var scan = RustSdkCryptoJs.QrCodeScan.fromBytes(uint8Array);
373
- var verifier = yield _this5.inner.scanQrCode(scan);
349
+ async scanQRCode(uint8Array) {
350
+ const scan = RustSdkCryptoJs.QrCodeScan.fromBytes(uint8Array);
351
+ const verifier = await this.inner.scanQrCode(scan);
374
352
 
375
- // this should have triggered the onChange callback, and we should now have a verifier
376
- if (!_this5._verifier) {
377
- throw new Error("Still no verifier after scanQrCode() call");
378
- }
353
+ // this should have triggered the onChange callback, and we should now have a verifier
354
+ if (!this._verifier) {
355
+ throw new Error("Still no verifier after scanQrCode() call");
356
+ }
379
357
 
380
- // we can immediately trigger the reciprocate request
381
- var req = verifier.reciprocate();
382
- if (req) {
383
- yield _this5.outgoingRequestProcessor.makeOutgoingRequest(req);
384
- }
385
- return _this5._verifier;
386
- })();
358
+ // we can immediately trigger the reciprocate request
359
+ const req = verifier.reciprocate();
360
+ if (req) {
361
+ await this.outgoingRequestProcessor.makeOutgoingRequest(req);
362
+ }
363
+ return this._verifier;
387
364
  }
388
365
 
389
366
  /**
@@ -412,18 +389,15 @@ export class RustVerificationRequest extends TypedEventEmitter {
412
389
  *
413
390
  * Implementation of {@link Crypto.VerificationRequest#generateQRCode}.
414
391
  */
415
- generateQRCode() {
416
- var _this6 = this;
417
- return _asyncToGenerator(function* () {
418
- // make sure that we have a list of the other user's devices (workaround https://github.com/matrix-org/matrix-rust-sdk/issues/2896)
419
- if (!(yield _this6.getOtherDevice())) {
420
- throw new Error("generateQRCode(): other device is unknown");
421
- }
422
- var innerVerifier = yield _this6.inner.generateQrCode();
423
- // If we are unable to generate a QRCode, we return undefined
424
- if (!innerVerifier) return;
425
- return innerVerifier.toBytes();
426
- })();
392
+ async generateQRCode() {
393
+ // make sure that we have a list of the other user's devices (workaround https://github.com/matrix-org/matrix-rust-sdk/issues/2896)
394
+ if (!(await this.getOtherDevice())) {
395
+ throw new Error("generateQRCode(): other device is unknown");
396
+ }
397
+ const innerVerifier = await this.inner.generateQrCode();
398
+ // If we are unable to generate a QRCode, we return undefined
399
+ if (!innerVerifier) return;
400
+ return innerVerifier.toBytes();
427
401
  }
428
402
 
429
403
  /**
@@ -431,8 +405,7 @@ export class RustVerificationRequest extends TypedEventEmitter {
431
405
  * this verification.
432
406
  */
433
407
  get cancellationCode() {
434
- var _this$inner$cancelInf, _this$inner$cancelInf2;
435
- return (_this$inner$cancelInf = (_this$inner$cancelInf2 = this.inner.cancelInfo) === null || _this$inner$cancelInf2 === void 0 ? void 0 : _this$inner$cancelInf2.cancelCode()) !== null && _this$inner$cancelInf !== void 0 ? _this$inner$cancelInf : null;
408
+ return this.inner.cancelInfo?.cancelCode() ?? null;
436
409
  }
437
410
 
438
411
  /**
@@ -441,7 +414,7 @@ export class RustVerificationRequest extends TypedEventEmitter {
441
414
  * Only defined when phase is Cancelled
442
415
  */
443
416
  get cancellingUserId() {
444
- var cancelInfo = this.inner.cancelInfo;
417
+ const cancelInfo = this.inner.cancelInfo;
445
418
  if (!cancelInfo) {
446
419
  return undefined;
447
420
  } else if (cancelInfo.cancelledbyUs()) {
@@ -461,19 +434,16 @@ export class RustVerificationRequest extends TypedEventEmitter {
461
434
  class BaseRustVerifer extends TypedEventEmitter {
462
435
  constructor(inner, outgoingRequestProcessor) {
463
436
  super();
464
- this.inner = inner;
465
- this.outgoingRequestProcessor = outgoingRequestProcessor;
466
437
  /** A deferred which completes when the verification completes (or rejects when it is cancelled/fails) */
467
438
  _defineProperty(this, "completionDeferred", void 0);
439
+ this.inner = inner;
440
+ this.outgoingRequestProcessor = outgoingRequestProcessor;
468
441
  this.completionDeferred = Promise.withResolvers();
469
442
 
470
443
  // As with RustVerificationRequest, we need to avoid a reference cycle.
471
444
  // See the comments in RustVerificationRequest.
472
- var weakThis = new WeakRef(this);
473
- inner.registerChangesCallback(/*#__PURE__*/_asyncToGenerator(function* () {
474
- var _weakThis$deref2;
475
- return (_weakThis$deref2 = weakThis.deref()) === null || _weakThis$deref2 === void 0 ? void 0 : _weakThis$deref2.onChange();
476
- }));
445
+ const weakThis = new WeakRef(this);
446
+ inner.registerChangesCallback(async () => weakThis.deref()?.onChange());
477
447
 
478
448
  // stop the runtime complaining if nobody catches a failure
479
449
  this.completionDeferred.promise.catch(() => null);
@@ -489,8 +459,8 @@ class BaseRustVerifer extends TypedEventEmitter {
489
459
  if (this.inner.isDone()) {
490
460
  this.completionDeferred.resolve(undefined);
491
461
  } else if (this.inner.isCancelled()) {
492
- var cancelInfo = this.inner.cancelInfo();
493
- this.completionDeferred.reject(new Error("Verification cancelled by ".concat(cancelInfo.cancelledbyUs() ? "us" : "them", " with code ").concat(cancelInfo.cancelCode(), ": ").concat(cancelInfo.reason())));
462
+ const cancelInfo = this.inner.cancelInfo();
463
+ this.completionDeferred.reject(new Error(`Verification cancelled by ${cancelInfo.cancelledbyUs() ? "us" : "them"} with code ${cancelInfo.cancelCode()}: ${cancelInfo.reason()}`));
494
464
  }
495
465
  this.emit(VerificationRequestEvent.Change);
496
466
  }
@@ -519,7 +489,7 @@ class BaseRustVerifer extends TypedEventEmitter {
519
489
  */
520
490
  cancel(e) {
521
491
  // TODO: something with `e`
522
- var req = this.inner.cancel();
492
+ const req = this.inner.cancel();
523
493
  if (req) {
524
494
  this.outgoingRequestProcessor.makeOutgoingRequest(req);
525
495
  }
@@ -572,17 +542,14 @@ export class RustQrCodeVerifier extends BaseRustVerifer {
572
542
  * @returns Promise which resolves when the verification has completed, or rejects if the verification is cancelled
573
543
  * or times out.
574
544
  */
575
- verify() {
576
- var _this7 = this;
577
- return _asyncToGenerator(function* () {
578
- // Some applications (hello, matrix-react-sdk) may not check if there is a `ShowQrCodeCallbacks` and instead
579
- // register a `ShowReciprocateQr` listener which they expect to be called once `.verify` is called.
580
- if (_this7.callbacks !== null) {
581
- _this7.emit(VerifierEvent.ShowReciprocateQr, _this7.callbacks);
582
- }
583
- // Nothing to do here but wait.
584
- yield _this7.completionDeferred.promise;
585
- })();
545
+ async verify() {
546
+ // Some applications (hello, matrix-react-sdk) may not check if there is a `ShowQrCodeCallbacks` and instead
547
+ // register a `ShowReciprocateQr` listener which they expect to be called once `.verify` is called.
548
+ if (this.callbacks !== null) {
549
+ this.emit(VerifierEvent.ShowReciprocateQr, this.callbacks);
550
+ }
551
+ // Nothing to do here but wait.
552
+ await this.completionDeferred.promise;
586
553
  }
587
554
 
588
555
  /**
@@ -615,7 +582,7 @@ export class RustQrCodeVerifier extends BaseRustVerifer {
615
582
  case QrState.Cancelled:
616
583
  return VerificationPhase.Cancelled;
617
584
  default:
618
- throw new Error("Unknown qr code state ".concat(this.inner.state()));
585
+ throw new Error(`Unknown qr code state ${this.inner.state()}`);
619
586
  }
620
587
  }
621
588
 
@@ -628,14 +595,11 @@ export class RustQrCodeVerifier extends BaseRustVerifer {
628
595
  getReciprocateQrCodeCallbacks() {
629
596
  return this.callbacks;
630
597
  }
631
- confirmScanning() {
632
- var _this8 = this;
633
- return _asyncToGenerator(function* () {
634
- var req = _this8.inner.confirmScanning();
635
- if (req) {
636
- yield _this8.outgoingRequestProcessor.makeOutgoingRequest(req);
637
- }
638
- })();
598
+ async confirmScanning() {
599
+ const req = this.inner.confirmScanning();
600
+ if (req) {
601
+ await this.outgoingRequestProcessor.makeOutgoingRequest(req);
602
+ }
639
603
  }
640
604
  }
641
605
 
@@ -655,38 +619,31 @@ export class RustSASVerifier extends BaseRustVerifer {
655
619
  * @returns Promise which resolves when the verification has completed, or rejects if the verification is cancelled
656
620
  * or times out.
657
621
  */
658
- verify() {
659
- var _this9 = this;
660
- return _asyncToGenerator(function* () {
661
- yield _this9.sendAccept();
662
- yield _this9.completionDeferred.promise;
663
- })();
622
+ async verify() {
623
+ await this.sendAccept();
624
+ await this.completionDeferred.promise;
664
625
  }
665
626
 
666
627
  /**
667
628
  * Send the accept or start event, if it hasn't already been sent
668
629
  */
669
- sendAccept() {
670
- var _this0 = this;
671
- return _asyncToGenerator(function* () {
672
- var req = _this0.inner.accept();
673
- if (req) {
674
- yield _this0.outgoingRequestProcessor.makeOutgoingRequest(req);
675
- }
676
- })();
630
+ async sendAccept() {
631
+ const req = this.inner.accept();
632
+ if (req) {
633
+ await this.outgoingRequestProcessor.makeOutgoingRequest(req);
634
+ }
677
635
  }
678
636
 
679
637
  /** if we can now show the callbacks, do so */
680
638
  onChange() {
681
- var _this1 = this;
682
639
  super.onChange();
683
640
  if (this.callbacks === null) {
684
- var emoji = this.inner.emoji();
685
- var decimal = this.inner.decimals();
641
+ const emoji = this.inner.emoji();
642
+ const decimal = this.inner.decimals();
686
643
  if (emoji === undefined && decimal === undefined) {
687
644
  return;
688
645
  }
689
- var sas = {};
646
+ const sas = {};
690
647
  if (emoji) {
691
648
  sas.emoji = emoji.map(e => [e.symbol, e.description]);
692
649
  }
@@ -695,26 +652,20 @@ export class RustSASVerifier extends BaseRustVerifer {
695
652
  }
696
653
  this.callbacks = {
697
654
  sas,
698
- confirm: function () {
699
- var _confirm = _asyncToGenerator(function* () {
700
- var requests = yield _this1.inner.confirm();
701
- for (var m of requests) {
702
- yield _this1.outgoingRequestProcessor.makeOutgoingRequest(m);
703
- }
704
- });
705
- function confirm() {
706
- return _confirm.apply(this, arguments);
655
+ confirm: async () => {
656
+ const requests = await this.inner.confirm();
657
+ for (const m of requests) {
658
+ await this.outgoingRequestProcessor.makeOutgoingRequest(m);
707
659
  }
708
- return confirm;
709
- }(),
660
+ },
710
661
  mismatch: () => {
711
- var request = this.inner.cancelWithCode("m.mismatched_sas");
662
+ const request = this.inner.cancelWithCode("m.mismatched_sas");
712
663
  if (request) {
713
- this.outgoingRequestProcessor.makeOutgoingRequest(request);
664
+ void this.outgoingRequestProcessor.makeOutgoingRequest(request);
714
665
  }
715
666
  },
716
667
  cancel: () => {
717
- var request = this.inner.cancelWithCode("m.user");
668
+ const request = this.inner.cancelWithCode("m.user");
718
669
  if (request) {
719
670
  this.outgoingRequestProcessor.makeOutgoingRequest(request);
720
671
  }
@@ -753,11 +704,8 @@ export class RustSASVerifier extends BaseRustVerifer {
753
704
 
754
705
  // As with RustVerificationRequest, we need to avoid a reference cycle.
755
706
  // See the comments in RustVerificationRequest.
756
- var weakThis = new WeakRef(this);
757
- inner.registerChangesCallback(/*#__PURE__*/_asyncToGenerator(function* () {
758
- var _weakThis$deref3;
759
- return (_weakThis$deref3 = weakThis.deref()) === null || _weakThis$deref3 === void 0 ? void 0 : _weakThis$deref3.onChange();
760
- }));
707
+ const weakThis = new WeakRef(this);
708
+ inner.registerChangesCallback(async () => weakThis.deref()?.onChange());
761
709
 
762
710
  // replaceInner will only get called if we started the verification at the same time as the other side, and we lost
763
711
  // the tie breaker. So we need to re-accept their verification.
@@ -768,7 +716,7 @@ export class RustSASVerifier extends BaseRustVerifer {
768
716
  }
769
717
 
770
718
  /** For each specced verification method, the rust-side `VerificationMethod` corresponding to it */
771
- var verificationMethodsByIdentifier = {
719
+ const verificationMethodsByIdentifier = {
772
720
  [VerificationMethod.Sas]: RustSdkCryptoJs.VerificationMethod.SasV1,
773
721
  [VerificationMethod.ScanQrCode]: RustSdkCryptoJs.VerificationMethod.QrCodeScanV1,
774
722
  [VerificationMethod.ShowQrCode]: RustSdkCryptoJs.VerificationMethod.QrCodeShowV1,
@@ -785,9 +733,9 @@ var verificationMethodsByIdentifier = {
785
733
  * @internal
786
734
  */
787
735
  export function verificationMethodIdentifierToMethod(method) {
788
- var meth = verificationMethodsByIdentifier[method];
736
+ const meth = verificationMethodsByIdentifier[method];
789
737
  if (meth === undefined) {
790
- throw new Error("Unknown verification method ".concat(method));
738
+ throw new Error(`Unknown verification method ${method}`);
791
739
  }
792
740
  return meth;
793
741
  }