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 - 2024 The Matrix.org Foundation C.I.C.
@@ -20,7 +19,7 @@ import { CryptoEvent } from "../crypto-api/index.js";
20
19
  import { ClientPrefix, MatrixError, Method } from "../http-api/index.js";
21
20
  import { encodeUri, sleep } from "../utils.js";
22
21
  // The minimum time to wait between two retries in case of errors. To avoid hammering the server.
23
- var KEY_BACKUP_BACKOFF = 5000; // ms
22
+ const KEY_BACKUP_BACKOFF = 5000; // ms
24
23
 
25
24
  /**
26
25
  * Enumerates the different kind of errors that can occurs when downloading and importing a key from backup.
@@ -36,14 +35,14 @@ var KeyDownloadErrorCode = /*#__PURE__*/function (KeyDownloadErrorCode) {
36
35
  }(KeyDownloadErrorCode || {});
37
36
  class KeyDownloadError extends Error {
38
37
  constructor(code) {
39
- super("Failed to get key from backup: ".concat(code));
38
+ super(`Failed to get key from backup: ${code}`);
40
39
  this.code = code;
41
40
  this.name = "KeyDownloadError";
42
41
  }
43
42
  }
44
43
  class KeyDownloadRateLimitError extends Error {
45
44
  constructor(retryMillis) {
46
- super("Failed to get key from backup: rate limited");
45
+ super(`Failed to get key from backup: rate limited`);
47
46
  this.retryMillis = retryMillis;
48
47
  this.name = "KeyDownloadRateLimitError";
49
48
  }
@@ -77,9 +76,6 @@ export class PerSessionKeyBackupDownloader {
77
76
  * @param logger - The logger to use.
78
77
  */
79
78
  constructor(logger, olmMachine, http, backupManager) {
80
- this.olmMachine = olmMachine;
81
- this.http = http;
82
- this.backupManager = backupManager;
83
79
  _defineProperty(this, "stopped", false);
84
80
  /**
85
81
  * The version and decryption key to use with current backup if all set up correctly.
@@ -115,6 +111,9 @@ export class PerSessionKeyBackupDownloader {
115
111
  }
116
112
  });
117
113
  });
114
+ this.olmMachine = olmMachine;
115
+ this.http = http;
116
+ this.backupManager = backupManager;
118
117
  this.logger = logger.getChild("[PerSessionKeyBackupDownloader]");
119
118
  backupManager.on(CryptoEvent.KeyBackupStatus, this.onBackupStatusChanged);
120
119
  backupManager.on(CryptoEvent.KeyBackupFailed, this.onBackupStatusChanged);
@@ -124,7 +123,7 @@ export class PerSessionKeyBackupDownloader {
124
123
  /**
125
124
  * Check if key download is successfully configured and active.
126
125
  *
127
- * @return `true` if key download is correctly configured and active; otherwise `false`.
126
+ * @returns `true` if key download is correctly configured and active; otherwise `false`.
128
127
  */
129
128
  isKeyBackupDownloadConfigured() {
130
129
  return this.configuration !== null;
@@ -135,11 +134,8 @@ export class PerSessionKeyBackupDownloader {
135
134
  *
136
135
  * This is just a convenience method to expose {@link RustBackupManager.getServerBackupInfo}.
137
136
  */
138
- getServerBackupInfo() {
139
- var _this = this;
140
- return _asyncToGenerator(function* () {
141
- return yield _this.backupManager.getServerBackupInfo();
142
- })();
137
+ async getServerBackupInfo() {
138
+ return await this.backupManager.getServerBackupInfo();
143
139
  }
144
140
 
145
141
  /**
@@ -157,12 +153,12 @@ export class PerSessionKeyBackupDownloader {
157
153
  // so we need to be resistant and not query several time the same session.
158
154
  if (this.isAlreadyInQueue(roomId, megolmSessionId)) {
159
155
  // There is already a request queued for this session, no need to queue another one.
160
- this.logger.trace("Not checking key backup for session ".concat(megolmSessionId, " as it is already queued"));
156
+ this.logger.trace(`Not checking key backup for session ${megolmSessionId} as it is already queued`);
161
157
  return;
162
158
  }
163
159
  if (this.wasRequestedRecently(megolmSessionId)) {
164
160
  // We already tried to download this session recently and it was not in backup, no need to try again.
165
- this.logger.trace("Not checking key backup for session ".concat(megolmSessionId, " as it was already requested recently"));
161
+ this.logger.trace(`Not checking key backup for session ${megolmSessionId} as it was already requested recently`);
166
162
  return;
167
163
  }
168
164
 
@@ -198,7 +194,7 @@ export class PerSessionKeyBackupDownloader {
198
194
  * @param megolmSessionId - The megolm session ID that is missing.
199
195
  */
200
196
  markAsNotFoundInBackup(megolmSessionId) {
201
- var now = Date.now();
197
+ const now = Date.now();
202
198
  this.sessionLastCheckAttemptedTime.set(megolmSessionId, now);
203
199
  // if too big make some cleaning to keep under control
204
200
  if (this.sessionLastCheckAttemptedTime.size > 100) {
@@ -210,19 +206,16 @@ export class PerSessionKeyBackupDownloader {
210
206
 
211
207
  /** Returns true if the session was requested recently. */
212
208
  wasRequestedRecently(megolmSessionId) {
213
- var lastCheck = this.sessionLastCheckAttemptedTime.get(megolmSessionId);
209
+ const lastCheck = this.sessionLastCheckAttemptedTime.get(megolmSessionId);
214
210
  if (!lastCheck) return false;
215
211
  return Math.max(Date.now() - lastCheck, 0) < KEY_BACKUP_BACKOFF;
216
212
  }
217
- getBackupDecryptionKey() {
218
- var _this2 = this;
219
- return _asyncToGenerator(function* () {
220
- try {
221
- return yield _this2.olmMachine.getBackupKeys();
222
- } catch (_unused) {
223
- return null;
224
- }
225
- })();
213
+ async getBackupDecryptionKey() {
214
+ try {
215
+ return await this.olmMachine.getBackupKeys();
216
+ } catch {
217
+ return null;
218
+ }
226
219
  }
227
220
 
228
221
  /**
@@ -232,82 +225,76 @@ export class PerSessionKeyBackupDownloader {
232
225
  * @param roomId - The room ID of the room where the error occurred.
233
226
  * @param sessionId - The megolm session ID that is missing.
234
227
  */
235
- requestRoomKeyFromBackup(version, roomId, sessionId) {
236
- var _this3 = this;
237
- return _asyncToGenerator(function* () {
238
- var path = encodeUri("/room_keys/keys/$roomId/$sessionId", {
239
- $roomId: roomId,
240
- $sessionId: sessionId
241
- });
242
- return yield _this3.http.authedRequest(Method.Get, path, {
243
- version
244
- }, undefined, {
245
- prefix: ClientPrefix.V3
246
- });
247
- })();
228
+ async requestRoomKeyFromBackup(version, roomId, sessionId) {
229
+ const path = encodeUri("/room_keys/keys/$roomId/$sessionId", {
230
+ $roomId: roomId,
231
+ $sessionId: sessionId
232
+ });
233
+ return await this.http.authedRequest(Method.Get, path, {
234
+ version
235
+ }, undefined, {
236
+ prefix: ClientPrefix.V3
237
+ });
248
238
  }
249
- downloadKeysLoop() {
250
- var _this4 = this;
251
- return _asyncToGenerator(function* () {
252
- if (_this4.downloadLoopRunning) return;
239
+ async downloadKeysLoop() {
240
+ if (this.downloadLoopRunning) return;
253
241
 
254
- // If we have a configuration problem, we don't want to try to download.
255
- // If any configuration change is detected, we will retry and restart the loop.
256
- if (_this4.hasConfigurationProblem) return;
257
- _this4.downloadLoopRunning = true;
258
- try {
259
- while (_this4.queuedRequests.length > 0) {
260
- // we just peek the first one without removing it, so if a new request for same key comes in while we're
261
- // processing this one, it won't queue another request.
262
- var request = _this4.queuedRequests[0];
242
+ // If we have a configuration problem, we don't want to try to download.
243
+ // If any configuration change is detected, we will retry and restart the loop.
244
+ if (this.hasConfigurationProblem) return;
245
+ this.downloadLoopRunning = true;
246
+ try {
247
+ while (this.queuedRequests.length > 0) {
248
+ // we just peek the first one without removing it, so if a new request for same key comes in while we're
249
+ // processing this one, it won't queue another request.
250
+ const request = this.queuedRequests[0];
251
+ try {
252
+ // The backup could have changed between the time we queued the request and now, so we need to check
253
+ const configuration = await this.getOrCreateBackupConfiguration();
254
+ if (!configuration) {
255
+ // Backup is not configured correctly, so stop the loop.
256
+ this.downloadLoopRunning = false;
257
+ return;
258
+ }
259
+ const result = await this.queryKeyBackup(request.roomId, request.megolmSessionId, configuration);
260
+ if (this.stopped) {
261
+ return;
262
+ }
263
+ // We got the encrypted key from backup, let's try to decrypt and import it.
263
264
  try {
264
- // The backup could have changed between the time we queued the request and now, so we need to check
265
- var configuration = yield _this4.getOrCreateBackupConfiguration();
266
- if (!configuration) {
267
- // Backup is not configured correctly, so stop the loop.
268
- _this4.downloadLoopRunning = false;
269
- return;
270
- }
271
- var result = yield _this4.queryKeyBackup(request.roomId, request.megolmSessionId, configuration);
272
- if (_this4.stopped) {
273
- return;
274
- }
275
- // We got the encrypted key from backup, let's try to decrypt and import it.
276
- try {
277
- yield _this4.decryptAndImport(request, result, configuration);
278
- } catch (e) {
279
- _this4.logger.error("Error while decrypting and importing key backup for session ".concat(request.megolmSessionId), e);
280
- }
281
- // now remove the request from the queue as we've processed it.
282
- _this4.queuedRequests.shift();
283
- } catch (err) {
284
- if (err instanceof KeyDownloadError) {
285
- switch (err.code) {
286
- case KeyDownloadErrorCode.MISSING_DECRYPTION_KEY:
287
- _this4.markAsNotFoundInBackup(request.megolmSessionId);
288
- // continue for next one
289
- _this4.queuedRequests.shift();
290
- break;
291
- case KeyDownloadErrorCode.NETWORK_ERROR:
292
- // We don't want to hammer if there is a problem, so wait a bit.
293
- yield sleep(KEY_BACKUP_BACKOFF);
294
- break;
295
- case KeyDownloadErrorCode.STOPPED:
296
- // If the downloader was stopped, we don't want to retry.
297
- _this4.downloadLoopRunning = false;
298
- return;
299
- }
300
- } else if (err instanceof KeyDownloadRateLimitError) {
301
- // we want to retry after the backoff time
302
- yield sleep(err.retryMillis);
265
+ await this.decryptAndImport(request, result, configuration);
266
+ } catch (e) {
267
+ this.logger.error(`Error while decrypting and importing key backup for session ${request.megolmSessionId}`, e);
268
+ }
269
+ // now remove the request from the queue as we've processed it.
270
+ this.queuedRequests.shift();
271
+ } catch (err) {
272
+ if (err instanceof KeyDownloadError) {
273
+ switch (err.code) {
274
+ case KeyDownloadErrorCode.MISSING_DECRYPTION_KEY:
275
+ this.markAsNotFoundInBackup(request.megolmSessionId);
276
+ // continue for next one
277
+ this.queuedRequests.shift();
278
+ break;
279
+ case KeyDownloadErrorCode.NETWORK_ERROR:
280
+ // We don't want to hammer if there is a problem, so wait a bit.
281
+ await sleep(KEY_BACKUP_BACKOFF);
282
+ break;
283
+ case KeyDownloadErrorCode.STOPPED:
284
+ // If the downloader was stopped, we don't want to retry.
285
+ this.downloadLoopRunning = false;
286
+ return;
303
287
  }
288
+ } else if (err instanceof KeyDownloadRateLimitError) {
289
+ // we want to retry after the backoff time
290
+ await sleep(err.retryMillis);
304
291
  }
305
292
  }
306
- } finally {
307
- // all pending request have been processed, we can stop the loop.
308
- _this4.downloadLoopRunning = false;
309
293
  }
310
- })();
294
+ } finally {
295
+ // all pending request have been processed, we can stop the loop.
296
+ this.downloadLoopRunning = false;
297
+ }
311
298
  }
312
299
 
313
300
  /**
@@ -317,60 +304,53 @@ export class PerSessionKeyBackupDownloader {
317
304
  * @param targetSessionId - ID of the session for which to check backup.
318
305
  * @param configuration - The backup configuration to use.
319
306
  */
320
- queryKeyBackup(targetRoomId, targetSessionId, configuration) {
321
- var _this5 = this;
322
- return _asyncToGenerator(function* () {
323
- _this5.logger.debug("Checking key backup for session ".concat(targetSessionId));
324
- if (_this5.stopped) throw new KeyDownloadError(KeyDownloadErrorCode.STOPPED);
325
- try {
326
- var res = yield _this5.requestRoomKeyFromBackup(configuration.backupVersion, targetRoomId, targetSessionId);
327
- _this5.logger.debug("Got key from backup for sessionId:".concat(targetSessionId));
328
- return res;
329
- } catch (e) {
330
- if (_this5.stopped) throw new KeyDownloadError(KeyDownloadErrorCode.STOPPED);
331
- _this5.logger.info("No luck requesting key backup for session ".concat(targetSessionId, ": ").concat(e));
332
- if (e instanceof MatrixError) {
333
- var errCode = e.data.errcode;
334
- if (errCode == "M_NOT_FOUND") {
335
- // Unfortunately the spec doesn't give us a way to differentiate between a missing key and a wrong version.
336
- // Synapse will return:
337
- // - "error": "Unknown backup version" if the version is wrong.
338
- // - "error": "No room_keys found" if the key is missing.
339
- // It's useful to know if the key is missing or if the version is wrong.
340
- // As it's not spec'ed, we fall back on considering the key is not in backup.
341
- // Notice that this request will be lost if instead the backup got out of sync (updated from other session).
342
- throw new KeyDownloadError(KeyDownloadErrorCode.MISSING_DECRYPTION_KEY);
307
+ async queryKeyBackup(targetRoomId, targetSessionId, configuration) {
308
+ this.logger.debug(`Checking key backup for session ${targetSessionId}`);
309
+ if (this.stopped) throw new KeyDownloadError(KeyDownloadErrorCode.STOPPED);
310
+ try {
311
+ const res = await this.requestRoomKeyFromBackup(configuration.backupVersion, targetRoomId, targetSessionId);
312
+ this.logger.debug(`Got key from backup for sessionId:${targetSessionId}`);
313
+ return res;
314
+ } catch (e) {
315
+ if (this.stopped) throw new KeyDownloadError(KeyDownloadErrorCode.STOPPED);
316
+ this.logger.info(`No luck requesting key backup for session ${targetSessionId}: ${e}`);
317
+ if (e instanceof MatrixError) {
318
+ const errCode = e.data.errcode;
319
+ if (errCode == "M_NOT_FOUND") {
320
+ // Unfortunately the spec doesn't give us a way to differentiate between a missing key and a wrong version.
321
+ // Synapse will return:
322
+ // - "error": "Unknown backup version" if the version is wrong.
323
+ // - "error": "No room_keys found" if the key is missing.
324
+ // It's useful to know if the key is missing or if the version is wrong.
325
+ // As it's not spec'ed, we fall back on considering the key is not in backup.
326
+ // Notice that this request will be lost if instead the backup got out of sync (updated from other session).
327
+ throw new KeyDownloadError(KeyDownloadErrorCode.MISSING_DECRYPTION_KEY);
328
+ }
329
+ if (e.isRateLimitError()) {
330
+ let waitTime;
331
+ try {
332
+ waitTime = e.getRetryAfterMs() ?? undefined;
333
+ } catch (error) {
334
+ this.logger.warn("Error while retrieving a rate-limit retry delay", error);
343
335
  }
344
- if (e.isRateLimitError()) {
345
- var waitTime;
346
- try {
347
- var _e$getRetryAfterMs;
348
- waitTime = (_e$getRetryAfterMs = e.getRetryAfterMs()) !== null && _e$getRetryAfterMs !== void 0 ? _e$getRetryAfterMs : undefined;
349
- } catch (error) {
350
- _this5.logger.warn("Error while retrieving a rate-limit retry delay", error);
351
- }
352
- if (waitTime && waitTime > 0) {
353
- _this5.logger.info("Rate limited by server, waiting ".concat(waitTime, "ms"));
354
- }
355
- throw new KeyDownloadRateLimitError(waitTime !== null && waitTime !== void 0 ? waitTime : KEY_BACKUP_BACKOFF);
336
+ if (waitTime && waitTime > 0) {
337
+ this.logger.info(`Rate limited by server, waiting ${waitTime}ms`);
356
338
  }
339
+ throw new KeyDownloadRateLimitError(waitTime ?? KEY_BACKUP_BACKOFF);
357
340
  }
358
- throw new KeyDownloadError(KeyDownloadErrorCode.NETWORK_ERROR);
359
341
  }
360
- })();
342
+ throw new KeyDownloadError(KeyDownloadErrorCode.NETWORK_ERROR);
343
+ }
361
344
  }
362
- decryptAndImport(sessionInfo, data, configuration) {
363
- var _this6 = this;
364
- return _asyncToGenerator(function* () {
365
- var sessionsToImport = {
366
- [sessionInfo.megolmSessionId]: data
367
- };
368
- var keys = yield configuration.decryptor.decryptSessions(sessionsToImport);
369
- for (var k of keys) {
370
- k.room_id = sessionInfo.roomId;
371
- }
372
- yield _this6.backupManager.importBackedUpRoomKeys(keys, configuration.backupVersion);
373
- })();
345
+ async decryptAndImport(sessionInfo, data, configuration) {
346
+ const sessionsToImport = {
347
+ [sessionInfo.megolmSessionId]: data
348
+ };
349
+ const keys = await configuration.decryptor.decryptSessions(sessionsToImport);
350
+ for (const k of keys) {
351
+ k.room_id = sessionInfo.roomId;
352
+ }
353
+ await this.backupManager.importBackedUpRoomKeys(keys, configuration.backupVersion);
374
354
  }
375
355
 
376
356
  /**
@@ -381,89 +361,81 @@ export class PerSessionKeyBackupDownloader {
381
361
  *
382
362
  * @returns The backup configuration to use or null if there is a configuration problem.
383
363
  */
384
- getOrCreateBackupConfiguration() {
385
- var _this7 = this;
386
- return _asyncToGenerator(function* () {
387
- if (_this7.configuration) {
388
- return _this7.configuration;
389
- }
364
+ async getOrCreateBackupConfiguration() {
365
+ if (this.configuration) {
366
+ return this.configuration;
367
+ }
390
368
 
391
- // We already tried to check the configuration and it failed.
392
- // We don't want to try again immediately, we will retry if a configuration change is detected.
393
- if (_this7.hasConfigurationProblem) {
394
- return null;
395
- }
369
+ // We already tried to check the configuration and it failed.
370
+ // We don't want to try again immediately, we will retry if a configuration change is detected.
371
+ if (this.hasConfigurationProblem) {
372
+ return null;
373
+ }
396
374
 
397
- // This method can be called rapidly by several emitted CryptoEvent, so we need to make sure that we don't
398
- // query the server several times.
399
- if (_this7.currentBackupVersionCheck != null) {
400
- _this7.logger.debug("Already checking server version, use current promise");
401
- return yield _this7.currentBackupVersionCheck;
402
- }
403
- _this7.currentBackupVersionCheck = _this7.internalCheckFromServer();
404
- try {
405
- return yield _this7.currentBackupVersionCheck;
406
- } finally {
407
- _this7.currentBackupVersionCheck = null;
408
- }
409
- })();
375
+ // This method can be called rapidly by several emitted CryptoEvent, so we need to make sure that we don't
376
+ // query the server several times.
377
+ if (this.currentBackupVersionCheck != null) {
378
+ this.logger.debug(`Already checking server version, use current promise`);
379
+ return await this.currentBackupVersionCheck;
380
+ }
381
+ this.currentBackupVersionCheck = this.internalCheckFromServer();
382
+ try {
383
+ return await this.currentBackupVersionCheck;
384
+ } finally {
385
+ this.currentBackupVersionCheck = null;
386
+ }
410
387
  }
411
- internalCheckFromServer() {
412
- var _this8 = this;
413
- return _asyncToGenerator(function* () {
414
- var _currentServerVersion, _currentServerVersion2, _currentServerVersion4;
415
- var currentServerVersion = null;
416
- try {
417
- currentServerVersion = yield _this8.backupManager.getServerBackupInfo();
418
- } catch (e) {
419
- _this8.logger.debug("Backup: error while checking server version: ".concat(e));
420
- _this8.hasConfigurationProblem = true;
421
- return null;
422
- }
423
- _this8.logger.debug("Got current backup version from server: ".concat((_currentServerVersion = currentServerVersion) === null || _currentServerVersion === void 0 ? void 0 : _currentServerVersion.version));
424
- if (((_currentServerVersion2 = currentServerVersion) === null || _currentServerVersion2 === void 0 ? void 0 : _currentServerVersion2.algorithm) != "m.megolm_backup.v1.curve25519-aes-sha2") {
425
- var _currentServerVersion3;
426
- _this8.logger.info("Unsupported algorithm ".concat((_currentServerVersion3 = currentServerVersion) === null || _currentServerVersion3 === void 0 ? void 0 : _currentServerVersion3.algorithm));
427
- _this8.hasConfigurationProblem = true;
428
- return null;
429
- }
430
- if (!((_currentServerVersion4 = currentServerVersion) !== null && _currentServerVersion4 !== void 0 && _currentServerVersion4.version)) {
431
- _this8.logger.info("No current key backup");
432
- _this8.hasConfigurationProblem = true;
433
- return null;
434
- }
435
- var activeVersion = yield _this8.backupManager.getActiveBackupVersion();
436
- if (activeVersion == null || currentServerVersion.version != activeVersion) {
437
- // Either the current backup version on server side is not trusted, or it is out of sync with the active version on the client side.
438
- _this8.logger.info("The current backup version on the server (".concat(currentServerVersion.version, ") is not trusted. Version we are currently backing up to: ").concat(activeVersion));
439
- _this8.hasConfigurationProblem = true;
440
- return null;
441
- }
442
- var backupKeys = yield _this8.getBackupDecryptionKey();
443
- if (!(backupKeys !== null && backupKeys !== void 0 && backupKeys.decryptionKey)) {
444
- _this8.logger.debug("Not checking key backup for session (no decryption key)");
445
- _this8.hasConfigurationProblem = true;
446
- return null;
447
- }
448
- if (activeVersion != backupKeys.backupVersion) {
449
- _this8.logger.debug("Version for which we have a decryption key (".concat(backupKeys.backupVersion, ") doesn't match the version we are backing up to (").concat(activeVersion, ")"));
450
- _this8.hasConfigurationProblem = true;
451
- return null;
452
- }
453
- var authData = currentServerVersion.auth_data;
454
- if (authData.public_key != backupKeys.decryptionKey.megolmV1PublicKey.publicKeyBase64) {
455
- _this8.logger.debug("Key backup on server does not match our decryption key");
456
- _this8.hasConfigurationProblem = true;
457
- return null;
458
- }
459
- var backupDecryptor = _this8.backupManager.createBackupDecryptor(backupKeys.decryptionKey);
460
- _this8.hasConfigurationProblem = false;
461
- _this8.configuration = {
462
- decryptor: backupDecryptor,
463
- backupVersion: activeVersion
464
- };
465
- return _this8.configuration;
466
- })();
388
+ async internalCheckFromServer() {
389
+ let currentServerVersion = null;
390
+ try {
391
+ currentServerVersion = await this.backupManager.getServerBackupInfo();
392
+ } catch (e) {
393
+ this.logger.debug(`Backup: error while checking server version: ${e}`);
394
+ this.hasConfigurationProblem = true;
395
+ return null;
396
+ }
397
+ this.logger.debug(`Got current backup version from server: ${currentServerVersion?.version}`);
398
+ if (currentServerVersion?.algorithm != "m.megolm_backup.v1.curve25519-aes-sha2") {
399
+ this.logger.info(`Unsupported algorithm ${currentServerVersion?.algorithm}`);
400
+ this.hasConfigurationProblem = true;
401
+ return null;
402
+ }
403
+ if (!currentServerVersion?.version) {
404
+ this.logger.info(`No current key backup`);
405
+ this.hasConfigurationProblem = true;
406
+ return null;
407
+ }
408
+ const activeVersion = await this.backupManager.getActiveBackupVersion();
409
+ if (activeVersion == null || currentServerVersion.version != activeVersion) {
410
+ // Either the current backup version on server side is not trusted, or it is out of sync with the active version on the client side.
411
+ this.logger.info(`The current backup version on the server (${currentServerVersion.version}) is not trusted. Version we are currently backing up to: ${activeVersion}`);
412
+ this.hasConfigurationProblem = true;
413
+ return null;
414
+ }
415
+ const backupKeys = await this.getBackupDecryptionKey();
416
+ if (!backupKeys?.decryptionKey) {
417
+ this.logger.debug(`Not checking key backup for session (no decryption key)`);
418
+ this.hasConfigurationProblem = true;
419
+ return null;
420
+ }
421
+ if (activeVersion != backupKeys.backupVersion) {
422
+ this.logger.debug(`Version for which we have a decryption key (${backupKeys.backupVersion}) doesn't match the version we are backing up to (${activeVersion})`);
423
+ this.hasConfigurationProblem = true;
424
+ return null;
425
+ }
426
+ const authData = currentServerVersion.auth_data;
427
+ if (authData.public_key != backupKeys.decryptionKey.megolmV1PublicKey.publicKeyBase64) {
428
+ this.logger.debug(`Key backup on server does not match our decryption key`);
429
+ this.hasConfigurationProblem = true;
430
+ return null;
431
+ }
432
+ const backupDecryptor = this.backupManager.createBackupDecryptor(backupKeys.decryptionKey);
433
+ this.hasConfigurationProblem = false;
434
+ this.configuration = {
435
+ decryptor: backupDecryptor,
436
+ backupVersion: activeVersion
437
+ };
438
+ return this.configuration;
467
439
  }
468
440
  }
469
441
  //# sourceMappingURL=PerSessionKeyBackupDownloader.js.map