matrix-js-sdk 41.8.0 → 41.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (458) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +1 -1
  3. package/lib/@types/AESEncryptedSecretStoragePayload.js +3 -1
  4. package/lib/@types/IIdentityServerProvider.js +3 -1
  5. package/lib/@types/PushRules.js +7 -7
  6. package/lib/@types/PushRules.js.map +1 -1
  7. package/lib/@types/auth.js +4 -4
  8. package/lib/@types/auth.js.map +1 -1
  9. package/lib/@types/beacon.js +2 -2
  10. package/lib/@types/beacon.js.map +1 -1
  11. package/lib/@types/common.js +3 -1
  12. package/lib/@types/crypto.js +3 -1
  13. package/lib/@types/event.js +20 -20
  14. package/lib/@types/event.js.map +1 -1
  15. package/lib/@types/events.js +3 -1
  16. package/lib/@types/extensible_events.js +6 -6
  17. package/lib/@types/extensible_events.js.map +1 -1
  18. package/lib/@types/global.d.js.map +1 -1
  19. package/lib/@types/json.js +3 -1
  20. package/lib/@types/local_notifications.js +3 -1
  21. package/lib/@types/location.js +4 -4
  22. package/lib/@types/location.js.map +1 -1
  23. package/lib/@types/matrix-sdk-crypto-wasm.d.js +3 -1
  24. package/lib/@types/media.js +3 -1
  25. package/lib/@types/membership.js +1 -1
  26. package/lib/@types/membership.js.map +1 -1
  27. package/lib/@types/partials.js +6 -6
  28. package/lib/@types/partials.js.map +1 -1
  29. package/lib/@types/polls.js +5 -5
  30. package/lib/@types/polls.js.map +1 -1
  31. package/lib/@types/read_receipts.js +2 -2
  32. package/lib/@types/read_receipts.js.map +1 -1
  33. package/lib/@types/registration.js +3 -1
  34. package/lib/@types/requests.js +1 -1
  35. package/lib/@types/requests.js.map +1 -1
  36. package/lib/@types/retention.js +1 -1
  37. package/lib/@types/retention.js.map +1 -1
  38. package/lib/@types/search.js +1 -1
  39. package/lib/@types/search.js.map +1 -1
  40. package/lib/@types/signed.js +3 -1
  41. package/lib/@types/spaces.js +3 -1
  42. package/lib/@types/state_events.js +3 -1
  43. package/lib/@types/synapse.js +3 -1
  44. package/lib/@types/sync.js +1 -1
  45. package/lib/@types/sync.js.map +1 -1
  46. package/lib/@types/threepids.js +1 -1
  47. package/lib/@types/threepids.js.map +1 -1
  48. package/lib/@types/topic.js +1 -1
  49. package/lib/@types/topic.js.map +1 -1
  50. package/lib/@types/uia.js +3 -1
  51. package/lib/NamespacedValue.js +8 -8
  52. package/lib/NamespacedValue.js.map +1 -1
  53. package/lib/ReEmitter.js +9 -16
  54. package/lib/ReEmitter.js.map +1 -1
  55. package/lib/ToDeviceMessageQueue.js +49 -57
  56. package/lib/ToDeviceMessageQueue.js.map +1 -1
  57. package/lib/autodiscovery.js +232 -247
  58. package/lib/autodiscovery.js.map +1 -1
  59. package/lib/base64.js +1 -1
  60. package/lib/base64.js.map +1 -1
  61. package/lib/browser-index.d.ts +2 -2
  62. package/lib/browser-index.d.ts.map +1 -1
  63. package/lib/browser-index.js +5 -5
  64. package/lib/browser-index.js.map +1 -1
  65. package/lib/capabilityPoller.js +19 -22
  66. package/lib/capabilityPoller.js.map +1 -1
  67. package/lib/client.d.ts +2 -8
  68. package/lib/client.d.ts.map +1 -1
  69. package/lib/client.js +2043 -2487
  70. package/lib/client.js.map +1 -1
  71. package/lib/common-crypto/CryptoBackend.js +2 -2
  72. package/lib/common-crypto/CryptoBackend.js.map +1 -1
  73. package/lib/common-crypto/key-passphrase.js.map +1 -1
  74. package/lib/content-helpers.js +43 -48
  75. package/lib/content-helpers.js.map +1 -1
  76. package/lib/content-repo.js +14 -24
  77. package/lib/content-repo.js.map +1 -1
  78. package/lib/crypto/store/base.js +6 -6
  79. package/lib/crypto/store/base.js.map +1 -1
  80. package/lib/crypto/store/indexeddb-crypto-store-backend.js +190 -238
  81. package/lib/crypto/store/indexeddb-crypto-store-backend.js.map +1 -1
  82. package/lib/crypto/store/indexeddb-crypto-store.js +25 -30
  83. package/lib/crypto/store/indexeddb-crypto-store.js.map +1 -1
  84. package/lib/crypto/store/localStorage-crypto-store.js +113 -145
  85. package/lib/crypto/store/localStorage-crypto-store.js.map +1 -1
  86. package/lib/crypto/store/memory-crypto-store.js +74 -105
  87. package/lib/crypto/store/memory-crypto-store.js.map +1 -1
  88. package/lib/crypto-api/CryptoEvent.js +1 -1
  89. package/lib/crypto-api/CryptoEvent.js.map +1 -1
  90. package/lib/crypto-api/CryptoEventHandlerMap.js +3 -1
  91. package/lib/crypto-api/index.d.ts +15 -6
  92. package/lib/crypto-api/index.d.ts.map +1 -1
  93. package/lib/crypto-api/index.js +22 -22
  94. package/lib/crypto-api/index.js.map +1 -1
  95. package/lib/crypto-api/key-passphrase.js +15 -23
  96. package/lib/crypto-api/key-passphrase.js.map +1 -1
  97. package/lib/crypto-api/keybackup.js +3 -1
  98. package/lib/crypto-api/recovery-key.js +11 -12
  99. package/lib/crypto-api/recovery-key.js.map +1 -1
  100. package/lib/crypto-api/verification.js +3 -3
  101. package/lib/crypto-api/verification.js.map +1 -1
  102. package/lib/digest.js +7 -14
  103. package/lib/digest.js.map +1 -1
  104. package/lib/embedded.d.ts.map +1 -1
  105. package/lib/embedded.js +380 -505
  106. package/lib/embedded.js.map +1 -1
  107. package/lib/errors.js +2 -2
  108. package/lib/errors.js.map +1 -1
  109. package/lib/event-mapper.js +10 -12
  110. package/lib/event-mapper.js.map +1 -1
  111. package/lib/extensible_events_v1/ExtensibleEvent.js.map +1 -1
  112. package/lib/extensible_events_v1/InvalidEventError.js.map +1 -1
  113. package/lib/extensible_events_v1/MessageEvent.js +11 -13
  114. package/lib/extensible_events_v1/MessageEvent.js.map +1 -1
  115. package/lib/extensible_events_v1/PollEndEvent.js +3 -4
  116. package/lib/extensible_events_v1/PollEndEvent.js.map +1 -1
  117. package/lib/extensible_events_v1/PollResponseEvent.js +5 -6
  118. package/lib/extensible_events_v1/PollResponseEvent.js.map +1 -1
  119. package/lib/extensible_events_v1/PollStartEvent.js +8 -10
  120. package/lib/extensible_events_v1/PollStartEvent.js.map +1 -1
  121. package/lib/extensible_events_v1/utilities.js.map +1 -1
  122. package/lib/feature.js +18 -31
  123. package/lib/feature.js.map +1 -1
  124. package/lib/filter-component.d.ts.map +1 -1
  125. package/lib/filter-component.js +20 -26
  126. package/lib/filter-component.js.map +1 -1
  127. package/lib/filter.js +14 -17
  128. package/lib/filter.js.map +1 -1
  129. package/lib/http-api/errors.js +28 -43
  130. package/lib/http-api/errors.js.map +1 -1
  131. package/lib/http-api/fetch.js +141 -159
  132. package/lib/http-api/fetch.js.map +1 -1
  133. package/lib/http-api/index.js +17 -20
  134. package/lib/http-api/index.js.map +1 -1
  135. package/lib/http-api/interface.js +1 -1
  136. package/lib/http-api/interface.js.map +1 -1
  137. package/lib/http-api/method.js +1 -1
  138. package/lib/http-api/method.js.map +1 -1
  139. package/lib/http-api/prefix.js +3 -3
  140. package/lib/http-api/prefix.js.map +1 -1
  141. package/lib/http-api/refresh.js +74 -94
  142. package/lib/http-api/refresh.js.map +1 -1
  143. package/lib/http-api/utils.d.ts +1 -1
  144. package/lib/http-api/utils.d.ts.map +1 -1
  145. package/lib/http-api/utils.js +34 -42
  146. package/lib/http-api/utils.js.map +1 -1
  147. package/lib/index.js.map +1 -1
  148. package/lib/indexeddb-helpers.js +3 -3
  149. package/lib/indexeddb-helpers.js.map +1 -1
  150. package/lib/indexeddb-worker.js.map +1 -1
  151. package/lib/interactive-auth.d.ts +5 -5
  152. package/lib/interactive-auth.d.ts.map +1 -1
  153. package/lib/interactive-auth.js +172 -204
  154. package/lib/interactive-auth.js.map +1 -1
  155. package/lib/logger.js +21 -57
  156. package/lib/logger.js.map +1 -1
  157. package/lib/matrix.js +7 -11
  158. package/lib/matrix.js.map +1 -1
  159. package/lib/matrixrtc/CallMembership.js +80 -74
  160. package/lib/matrixrtc/CallMembership.js.map +1 -1
  161. package/lib/matrixrtc/EncryptionManager.js +1 -1
  162. package/lib/matrixrtc/EncryptionManager.js.map +1 -1
  163. package/lib/matrixrtc/IKeyTransport.js +1 -1
  164. package/lib/matrixrtc/IKeyTransport.js.map +1 -1
  165. package/lib/matrixrtc/IMembershipManager.js +1 -1
  166. package/lib/matrixrtc/IMembershipManager.js.map +1 -1
  167. package/lib/matrixrtc/LivekitTransport.d.ts +1 -1
  168. package/lib/matrixrtc/LivekitTransport.js +4 -4
  169. package/lib/matrixrtc/LivekitTransport.js.map +1 -1
  170. package/lib/matrixrtc/MatrixRTCSession.js +137 -187
  171. package/lib/matrixrtc/MatrixRTCSession.js.map +1 -1
  172. package/lib/matrixrtc/MatrixRTCSessionManager.js +36 -41
  173. package/lib/matrixrtc/MatrixRTCSessionManager.js.map +1 -1
  174. package/lib/matrixrtc/MembershipManager.js +332 -378
  175. package/lib/matrixrtc/MembershipManager.js.map +1 -1
  176. package/lib/matrixrtc/MembershipManagerActionScheduler.js +54 -63
  177. package/lib/matrixrtc/MembershipManagerActionScheduler.js.map +1 -1
  178. package/lib/matrixrtc/RTCEncryptionManager.js +119 -143
  179. package/lib/matrixrtc/RTCEncryptionManager.js.map +1 -1
  180. package/lib/matrixrtc/ToDeviceKeyTransport.js +53 -58
  181. package/lib/matrixrtc/ToDeviceKeyTransport.js.map +1 -1
  182. package/lib/matrixrtc/index.js.map +1 -1
  183. package/lib/matrixrtc/membershipData/common.js +1 -1
  184. package/lib/matrixrtc/membershipData/common.js.map +1 -1
  185. package/lib/matrixrtc/membershipData/index.js.map +1 -1
  186. package/lib/matrixrtc/membershipData/rtc.js +15 -23
  187. package/lib/matrixrtc/membershipData/rtc.js.map +1 -1
  188. package/lib/matrixrtc/membershipData/session.js +4 -5
  189. package/lib/matrixrtc/membershipData/session.js.map +1 -1
  190. package/lib/matrixrtc/types.js +4 -6
  191. package/lib/matrixrtc/types.js.map +1 -1
  192. package/lib/matrixrtc/utils.js +4 -11
  193. package/lib/matrixrtc/utils.js.map +1 -1
  194. package/lib/models/MSC3089Branch.js +91 -116
  195. package/lib/models/MSC3089Branch.js.map +1 -1
  196. package/lib/models/MSC3089TreeSpace.js +209 -245
  197. package/lib/models/MSC3089TreeSpace.js.map +1 -1
  198. package/lib/models/ToDeviceMessage.js +3 -1
  199. package/lib/models/beacon.js +14 -13
  200. package/lib/models/beacon.js.map +1 -1
  201. package/lib/models/compare-event-ordering.js +13 -13
  202. package/lib/models/compare-event-ordering.js.map +1 -1
  203. package/lib/models/device.js +3 -3
  204. package/lib/models/device.js.map +1 -1
  205. package/lib/models/event-context.js +5 -8
  206. package/lib/models/event-context.js.map +1 -1
  207. package/lib/models/event-status.js +1 -1
  208. package/lib/models/event-status.js.map +1 -1
  209. package/lib/models/event-timeline-set.js +88 -94
  210. package/lib/models/event-timeline-set.js.map +1 -1
  211. package/lib/models/event-timeline.js +28 -30
  212. package/lib/models/event-timeline.js.map +1 -1
  213. package/lib/models/event.js +182 -226
  214. package/lib/models/event.js.map +1 -1
  215. package/lib/models/invites-ignorer-types.js +4 -4
  216. package/lib/models/invites-ignorer-types.js.map +1 -1
  217. package/lib/models/invites-ignorer.js +159 -179
  218. package/lib/models/invites-ignorer.js.map +1 -1
  219. package/lib/models/poll.js +71 -81
  220. package/lib/models/poll.js.map +1 -1
  221. package/lib/models/profile-keys.js +2 -2
  222. package/lib/models/profile-keys.js.map +1 -1
  223. package/lib/models/read-receipt.js +40 -56
  224. package/lib/models/read-receipt.js.map +1 -1
  225. package/lib/models/related-relations.js.map +1 -1
  226. package/lib/models/relations-container.js +22 -23
  227. package/lib/models/relations-container.js.map +1 -1
  228. package/lib/models/relations.js +133 -159
  229. package/lib/models/relations.js.map +1 -1
  230. package/lib/models/room-member.js +24 -29
  231. package/lib/models/room-member.js.map +1 -1
  232. package/lib/models/room-receipts.js +29 -43
  233. package/lib/models/room-receipts.js.map +1 -1
  234. package/lib/models/room-retention.js +74 -83
  235. package/lib/models/room-retention.js.map +1 -1
  236. package/lib/models/room-state.js +143 -172
  237. package/lib/models/room-state.js.map +1 -1
  238. package/lib/models/room-sticky-events.d.ts +1 -0
  239. package/lib/models/room-sticky-events.d.ts.map +1 -1
  240. package/lib/models/room-sticky-events.js +45 -65
  241. package/lib/models/room-sticky-events.js.map +1 -1
  242. package/lib/models/room-summary.js.map +1 -1
  243. package/lib/models/room.d.ts.map +1 -1
  244. package/lib/models/room.js +765 -909
  245. package/lib/models/room.js.map +1 -1
  246. package/lib/models/search-result.js +5 -5
  247. package/lib/models/search-result.js.map +1 -1
  248. package/lib/models/thread.js +225 -285
  249. package/lib/models/thread.js.map +1 -1
  250. package/lib/models/typed-event-emitter.js +7 -18
  251. package/lib/models/typed-event-emitter.js.map +1 -1
  252. package/lib/models/user.js +8 -8
  253. package/lib/models/user.js.map +1 -1
  254. package/lib/oidc/authorize.js +208 -241
  255. package/lib/oidc/authorize.js.map +1 -1
  256. package/lib/oidc/discovery.js +23 -36
  257. package/lib/oidc/discovery.js.map +1 -1
  258. package/lib/oidc/error.js +1 -1
  259. package/lib/oidc/error.js.map +1 -1
  260. package/lib/oidc/index.js +1 -0
  261. package/lib/oidc/index.js.map +1 -1
  262. package/lib/oidc/register.js +60 -66
  263. package/lib/oidc/register.js.map +1 -1
  264. package/lib/oidc/tokenRefresher.js +77 -91
  265. package/lib/oidc/tokenRefresher.js.map +1 -1
  266. package/lib/oidc/validate.js +18 -18
  267. package/lib/oidc/validate.js.map +1 -1
  268. package/lib/pushprocessor.js +71 -82
  269. package/lib/pushprocessor.js.map +1 -1
  270. package/lib/randomstring.js +9 -9
  271. package/lib/randomstring.js.map +1 -1
  272. package/lib/realtime-callbacks.js +25 -28
  273. package/lib/realtime-callbacks.js.map +1 -1
  274. package/lib/receipt-accumulator.d.ts +2 -0
  275. package/lib/receipt-accumulator.d.ts.map +1 -1
  276. package/lib/receipt-accumulator.js +14 -22
  277. package/lib/receipt-accumulator.js.map +1 -1
  278. package/lib/rendezvous/MSC4108SignInWithQR.js +271 -302
  279. package/lib/rendezvous/MSC4108SignInWithQR.js.map +1 -1
  280. package/lib/rendezvous/RendezvousChannel.js +3 -1
  281. package/lib/rendezvous/RendezvousCode.js +3 -1
  282. package/lib/rendezvous/RendezvousError.js.map +1 -1
  283. package/lib/rendezvous/RendezvousFailureReason.js +2 -2
  284. package/lib/rendezvous/RendezvousFailureReason.js.map +1 -1
  285. package/lib/rendezvous/RendezvousIntent.js +1 -1
  286. package/lib/rendezvous/RendezvousIntent.js.map +1 -1
  287. package/lib/rendezvous/RendezvousTransport.js +3 -1
  288. package/lib/rendezvous/channels/MSC4108SecureChannel.js +123 -147
  289. package/lib/rendezvous/channels/MSC4108SecureChannel.js.map +1 -1
  290. package/lib/rendezvous/index.js +44 -69
  291. package/lib/rendezvous/index.js.map +1 -1
  292. package/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts +1 -1
  293. package/lib/rendezvous/transports/MSC4108RendezvousSession.js +134 -152
  294. package/lib/rendezvous/transports/MSC4108RendezvousSession.js.map +1 -1
  295. package/lib/retentionPolicy.js +6 -9
  296. package/lib/retentionPolicy.js.map +1 -1
  297. package/lib/room-hierarchy.js +52 -60
  298. package/lib/room-hierarchy.js.map +1 -1
  299. package/lib/rust-crypto/CrossSigningIdentity.js +94 -104
  300. package/lib/rust-crypto/CrossSigningIdentity.js.map +1 -1
  301. package/lib/rust-crypto/DehydratedDeviceManager.js +157 -190
  302. package/lib/rust-crypto/DehydratedDeviceManager.js.map +1 -1
  303. package/lib/rust-crypto/KeyClaimManager.js +18 -22
  304. package/lib/rust-crypto/KeyClaimManager.js.map +1 -1
  305. package/lib/rust-crypto/OutgoingRequestProcessor.js +109 -139
  306. package/lib/rust-crypto/OutgoingRequestProcessor.js.map +1 -1
  307. package/lib/rust-crypto/OutgoingRequestsManager.js +66 -80
  308. package/lib/rust-crypto/OutgoingRequestsManager.js.map +1 -1
  309. package/lib/rust-crypto/PerSessionKeyBackupDownloader.d.ts +1 -1
  310. package/lib/rust-crypto/PerSessionKeyBackupDownloader.js +196 -224
  311. package/lib/rust-crypto/PerSessionKeyBackupDownloader.js.map +1 -1
  312. package/lib/rust-crypto/RoomEncryptor.js +127 -143
  313. package/lib/rust-crypto/RoomEncryptor.js.map +1 -1
  314. package/lib/rust-crypto/backup.js +453 -549
  315. package/lib/rust-crypto/backup.js.map +1 -1
  316. package/lib/rust-crypto/constants.js +1 -1
  317. package/lib/rust-crypto/constants.js.map +1 -1
  318. package/lib/rust-crypto/device-converter.js +15 -28
  319. package/lib/rust-crypto/device-converter.js.map +1 -1
  320. package/lib/rust-crypto/index.js +103 -116
  321. package/lib/rust-crypto/index.js.map +1 -1
  322. package/lib/rust-crypto/libolm_migration.js +303 -365
  323. package/lib/rust-crypto/libolm_migration.js.map +1 -1
  324. package/lib/rust-crypto/rust-crypto.d.ts +5 -1
  325. package/lib/rust-crypto/rust-crypto.d.ts.map +1 -1
  326. package/lib/rust-crypto/rust-crypto.js +1067 -1332
  327. package/lib/rust-crypto/rust-crypto.js.map +1 -1
  328. package/lib/rust-crypto/secret-storage.js +12 -25
  329. package/lib/rust-crypto/secret-storage.js.map +1 -1
  330. package/lib/rust-crypto/verification.js +137 -189
  331. package/lib/rust-crypto/verification.js.map +1 -1
  332. package/lib/scheduler.js +44 -19
  333. package/lib/scheduler.js.map +1 -1
  334. package/lib/secret-storage.js +179 -213
  335. package/lib/secret-storage.js.map +1 -1
  336. package/lib/serverCapabilities.js +6 -9
  337. package/lib/serverCapabilities.js.map +1 -1
  338. package/lib/service-types.js +1 -1
  339. package/lib/service-types.js.map +1 -1
  340. package/lib/sliding-sync-sdk.d.ts.map +1 -1
  341. package/lib/sliding-sync-sdk.js +368 -424
  342. package/lib/sliding-sync-sdk.js.map +1 -1
  343. package/lib/sliding-sync.js +135 -171
  344. package/lib/sliding-sync.js.map +1 -1
  345. package/lib/store/index.js +3 -1
  346. package/lib/store/indexeddb-backend.js +3 -1
  347. package/lib/store/indexeddb-local-backend.js +194 -253
  348. package/lib/store/indexeddb-local-backend.js.map +1 -1
  349. package/lib/store/indexeddb-remote-backend.js +33 -63
  350. package/lib/store/indexeddb-remote-backend.js.map +1 -1
  351. package/lib/store/indexeddb-store-worker.js +22 -23
  352. package/lib/store/indexeddb-store-worker.js.map +1 -1
  353. package/lib/store/indexeddb.js +44 -71
  354. package/lib/store/indexeddb.js.map +1 -1
  355. package/lib/store/local-storage-events-emitter.js +2 -2
  356. package/lib/store/local-storage-events-emitter.js.map +1 -1
  357. package/lib/store/memory.js +34 -57
  358. package/lib/store/memory.js.map +1 -1
  359. package/lib/store/stub.js +22 -35
  360. package/lib/store/stub.js.map +1 -1
  361. package/lib/sync-accumulator.js +54 -66
  362. package/lib/sync-accumulator.js.map +1 -1
  363. package/lib/sync.d.ts.map +1 -1
  364. package/lib/sync.js +905 -998
  365. package/lib/sync.js.map +1 -1
  366. package/lib/testing.js +63 -105
  367. package/lib/testing.js.map +1 -1
  368. package/lib/thread-utils.js +1 -4
  369. package/lib/thread-utils.js.map +1 -1
  370. package/lib/timeline-window.js +89 -102
  371. package/lib/timeline-window.js.map +1 -1
  372. package/lib/types.js +1 -1
  373. package/lib/types.js.map +1 -1
  374. package/lib/utils/decryptAESSecretStorageItem.js +14 -25
  375. package/lib/utils/decryptAESSecretStorageItem.js.map +1 -1
  376. package/lib/utils/encryptAESSecretStorageItem.js +27 -38
  377. package/lib/utils/encryptAESSecretStorageItem.js.map +1 -1
  378. package/lib/utils/internal/deriveKeys.js +25 -32
  379. package/lib/utils/internal/deriveKeys.js.map +1 -1
  380. package/lib/utils/roomVersion.js +1 -1
  381. package/lib/utils/roomVersion.js.map +1 -1
  382. package/lib/utils.js +83 -135
  383. package/lib/utils.js.map +1 -1
  384. package/lib/version-support.js +3 -3
  385. package/lib/version-support.js.map +1 -1
  386. package/lib/webrtc/audioContext.js +5 -6
  387. package/lib/webrtc/audioContext.js.map +1 -1
  388. package/lib/webrtc/call.js +1081 -1250
  389. package/lib/webrtc/call.js.map +1 -1
  390. package/lib/webrtc/callEventHandler.js +202 -214
  391. package/lib/webrtc/callEventHandler.js.map +1 -1
  392. package/lib/webrtc/callEventTypes.js +2 -2
  393. package/lib/webrtc/callEventTypes.js.map +1 -1
  394. package/lib/webrtc/callFeed.js +18 -20
  395. package/lib/webrtc/callFeed.js.map +1 -1
  396. package/lib/webrtc/groupCall.js +513 -602
  397. package/lib/webrtc/groupCall.js.map +1 -1
  398. package/lib/webrtc/groupCallEventHandler.js +59 -62
  399. package/lib/webrtc/groupCallEventHandler.js.map +1 -1
  400. package/lib/webrtc/mediaHandler.js +198 -232
  401. package/lib/webrtc/mediaHandler.js.map +1 -1
  402. package/lib/webrtc/stats/callFeedStatsReporter.js +16 -20
  403. package/lib/webrtc/stats/callFeedStatsReporter.js.map +1 -1
  404. package/lib/webrtc/stats/callStatsReportGatherer.js +67 -75
  405. package/lib/webrtc/stats/callStatsReportGatherer.js.map +1 -1
  406. package/lib/webrtc/stats/callStatsReportSummary.js +3 -1
  407. package/lib/webrtc/stats/connectionStats.js.map +1 -1
  408. package/lib/webrtc/stats/connectionStatsBuilder.js +2 -2
  409. package/lib/webrtc/stats/connectionStatsBuilder.js.map +1 -1
  410. package/lib/webrtc/stats/connectionStatsReportBuilder.js +20 -24
  411. package/lib/webrtc/stats/connectionStatsReportBuilder.js.map +1 -1
  412. package/lib/webrtc/stats/groupCallStats.js +6 -8
  413. package/lib/webrtc/stats/groupCallStats.js.map +1 -1
  414. package/lib/webrtc/stats/media/mediaSsrcHandler.js +7 -8
  415. package/lib/webrtc/stats/media/mediaSsrcHandler.js.map +1 -1
  416. package/lib/webrtc/stats/media/mediaTrackHandler.js +7 -9
  417. package/lib/webrtc/stats/media/mediaTrackHandler.js.map +1 -1
  418. package/lib/webrtc/stats/media/mediaTrackStats.js +3 -3
  419. package/lib/webrtc/stats/media/mediaTrackStats.js.map +1 -1
  420. package/lib/webrtc/stats/media/mediaTrackStatsHandler.js +7 -7
  421. package/lib/webrtc/stats/media/mediaTrackStatsHandler.js.map +1 -1
  422. package/lib/webrtc/stats/statsReport.js +1 -1
  423. package/lib/webrtc/stats/statsReport.js.map +1 -1
  424. package/lib/webrtc/stats/statsReportEmitter.js.map +1 -1
  425. package/lib/webrtc/stats/summaryStatsReportGatherer.js +14 -14
  426. package/lib/webrtc/stats/summaryStatsReportGatherer.js.map +1 -1
  427. package/lib/webrtc/stats/trackStatsBuilder.js +32 -34
  428. package/lib/webrtc/stats/trackStatsBuilder.js.map +1 -1
  429. package/lib/webrtc/stats/transportStats.js +3 -1
  430. package/lib/webrtc/stats/transportStatsBuilder.js +9 -9
  431. package/lib/webrtc/stats/transportStatsBuilder.js.map +1 -1
  432. package/lib/webrtc/stats/valueFormatter.js +1 -1
  433. package/lib/webrtc/stats/valueFormatter.js.map +1 -1
  434. package/package.json +18 -33
  435. package/src/@types/global.d.ts +2 -2
  436. package/src/ToDeviceMessageQueue.ts +2 -2
  437. package/src/browser-index.ts +4 -4
  438. package/src/client.ts +15 -20
  439. package/src/crypto-api/index.ts +17 -6
  440. package/src/embedded.ts +4 -6
  441. package/src/filter-component.ts +1 -0
  442. package/src/http-api/utils.ts +1 -1
  443. package/src/interactive-auth.ts +11 -5
  444. package/src/matrixrtc/LivekitTransport.ts +1 -1
  445. package/src/matrixrtc/MatrixRTCSession.ts +1 -1
  446. package/src/models/MSC3089Branch.ts +1 -1
  447. package/src/models/room-sticky-events.ts +1 -0
  448. package/src/models/room.ts +9 -11
  449. package/src/receipt-accumulator.ts +2 -0
  450. package/src/rendezvous/index.ts +1 -1
  451. package/src/rendezvous/transports/MSC4108RendezvousSession.ts +2 -2
  452. package/src/rust-crypto/PerSessionKeyBackupDownloader.ts +1 -1
  453. package/src/rust-crypto/index.ts +6 -6
  454. package/src/rust-crypto/rust-crypto.ts +31 -7
  455. package/src/rust-crypto/verification.ts +1 -1
  456. package/src/sliding-sync-sdk.ts +5 -7
  457. package/src/store/indexeddb-local-backend.ts +3 -3
  458. package/src/sync.ts +6 -8
@@ -1,7 +1,5 @@
1
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
1
+ import _objectSpread from "@babel/runtime/helpers/objectSpread2";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
3
  /*
6
4
  Copyright 2024 The Matrix.org Foundation C.I.C.
7
5
 
@@ -29,7 +27,7 @@ import { generateScope, OAuthGrantType, startDeviceAuthorization, waitForDeviceA
29
27
  * secure channels.
30
28
  * @experimental Note that this is UNSTABLE and may have breaking changes without notice.
31
29
  */
32
- export var PayloadType = /*#__PURE__*/function (PayloadType) {
30
+ export let PayloadType = /*#__PURE__*/function (PayloadType) {
33
31
  PayloadType["Protocols"] = "m.login.protocols";
34
32
  PayloadType["Protocol"] = "m.login.protocol";
35
33
  PayloadType["Failure"] = "m.login.failure";
@@ -59,8 +57,7 @@ export class MSC4108SignInWithQR {
59
57
  * Returns the check code for the secure channel or undefined if not generated yet.
60
58
  */
61
59
  get checkCode() {
62
- var _this$channel;
63
- return (_this$channel = this.channel) === null || _this$channel === void 0 ? void 0 : _this$channel.getCheckCode();
60
+ return this.channel?.getCheckCode();
64
61
  }
65
62
 
66
63
  /**
@@ -70,15 +67,15 @@ export class MSC4108SignInWithQR {
70
67
  * @param onFailure - Callback for when the rendezvous fails
71
68
  */
72
69
  constructor(channel, didScanCode, client, onFailure) {
73
- this.channel = channel;
74
- this.didScanCode = didScanCode;
75
- this.client = client;
76
- this.onFailure = onFailure;
77
70
  _defineProperty(this, "ourIntent", void 0);
78
71
  _defineProperty(this, "_code", void 0);
79
72
  _defineProperty(this, "expectingNewDeviceId", void 0);
80
73
  _defineProperty(this, "metadata", void 0);
81
74
  _defineProperty(this, "grantInProgress", void 0);
75
+ this.channel = channel;
76
+ this.didScanCode = didScanCode;
77
+ this.client = client;
78
+ this.onFailure = onFailure;
82
79
  this.ourIntent = client ? QrCodeIntent.Reciprocate : QrCodeIntent.Login;
83
80
  }
84
81
 
@@ -92,18 +89,15 @@ export class MSC4108SignInWithQR {
92
89
  /**
93
90
  * Generate the code including doing partial set up of the channel where required.
94
91
  */
95
- generateCode() {
96
- var _this = this;
97
- return _asyncToGenerator(function* () {
98
- if (_this._code) {
99
- return;
100
- }
101
- if (_this.ourIntent === QrCodeIntent.Reciprocate && _this.client) {
102
- _this._code = yield _this.channel.generateCode(_this.ourIntent, _this.client.getDomain());
103
- } else if (_this.ourIntent === QrCodeIntent.Login) {
104
- _this._code = yield _this.channel.generateCode(_this.ourIntent);
105
- }
106
- })();
92
+ async generateCode() {
93
+ if (this._code) {
94
+ return;
95
+ }
96
+ if (this.ourIntent === QrCodeIntent.Reciprocate && this.client) {
97
+ this._code = await this.channel.generateCode(this.ourIntent, this.client.getDomain());
98
+ } else if (this.ourIntent === QrCodeIntent.Login) {
99
+ this._code = await this.channel.generateCode(this.ourIntent);
100
+ }
107
101
  }
108
102
 
109
103
  /**
@@ -126,61 +120,57 @@ export class MSC4108SignInWithQR {
126
120
  * The scanning device has to discover the homeserver details, if they scanned the code then they already have it.
127
121
  * If the new device is the one rendering the QR code then it has to wait be sent the homeserver details via the rendezvous channel.
128
122
  */
129
- negotiateProtocols() {
130
- var _this2 = this;
131
- return _asyncToGenerator(function* () {
132
- logger.info("negotiateProtocols(isNewDevice=".concat(_this2.isNewDevice, " didScanCode=").concat(_this2.didScanCode, ")"));
133
- yield _this2.channel.connect();
134
- if (_this2.didScanCode) {
135
- // Secure Channel step 6 completed, we trust the channel
123
+ async negotiateProtocols() {
124
+ logger.info(`negotiateProtocols(isNewDevice=${this.isNewDevice} didScanCode=${this.didScanCode})`);
125
+ await this.channel.connect();
126
+ if (this.didScanCode) {
127
+ // Secure Channel step 6 completed, we trust the channel
136
128
 
137
- if (_this2.isNewDevice) {
138
- // MSC4108-Flow: ExistingScanned - take homeserver from QR code which should already be set
139
- } else {
140
- var _oidcClientConfig;
141
- // MSC4108-Flow: NewScanned -send protocols message
142
- var oidcClientConfig;
143
- try {
144
- oidcClientConfig = yield _this2.client.getAuthMetadata();
145
- } catch (e) {
146
- logger.error("Failed to discover OIDC metadata", e);
147
- }
148
- if ((_oidcClientConfig = oidcClientConfig) !== null && _oidcClientConfig !== void 0 && _oidcClientConfig.grant_types_supported.includes(OAuthGrantType.DeviceAuthorization)) {
149
- yield _this2.send({
150
- type: PayloadType.Protocols,
151
- protocols: ["device_authorization_grant"],
152
- homeserver: _this2.client.getDomain()
153
- });
154
- } else {
155
- yield _this2.send({
156
- type: PayloadType.Failure,
157
- reason: MSC4108FailureReason.UnsupportedProtocol
158
- });
159
- throw new RendezvousError("Device code grant unsupported", MSC4108FailureReason.UnsupportedProtocol);
160
- }
161
- }
162
- } else if (_this2.isNewDevice) {
163
- // MSC4108-Flow: ExistingScanned - wait for protocols message
164
- logger.info("Waiting for protocols message");
165
- var payload = yield _this2.receive();
166
- if ((payload === null || payload === void 0 ? void 0 : payload.type) === PayloadType.Failure) {
167
- throw new RendezvousError("Failed", payload.reason);
129
+ if (this.isNewDevice) {
130
+ // MSC4108-Flow: ExistingScanned - take homeserver from QR code which should already be set
131
+ } else {
132
+ // MSC4108-Flow: NewScanned -send protocols message
133
+ let oidcClientConfig;
134
+ try {
135
+ oidcClientConfig = await this.client.getAuthMetadata();
136
+ } catch (e) {
137
+ logger.error("Failed to discover OIDC metadata", e);
168
138
  }
169
- if ((payload === null || payload === void 0 ? void 0 : payload.type) !== PayloadType.Protocols) {
170
- yield _this2.send({
139
+ if (oidcClientConfig?.grant_types_supported.includes(OAuthGrantType.DeviceAuthorization)) {
140
+ await this.send({
141
+ type: PayloadType.Protocols,
142
+ protocols: ["device_authorization_grant"],
143
+ homeserver: this.client.getDomain()
144
+ });
145
+ } else {
146
+ await this.send({
171
147
  type: PayloadType.Failure,
172
- reason: MSC4108FailureReason.UnexpectedMessageReceived
148
+ reason: MSC4108FailureReason.UnsupportedProtocol
173
149
  });
174
- throw new RendezvousError("Unexpected message received", MSC4108FailureReason.UnexpectedMessageReceived);
150
+ throw new RendezvousError("Device code grant unsupported", MSC4108FailureReason.UnsupportedProtocol);
175
151
  }
176
- return {
177
- serverName: payload.homeserver
178
- };
179
- } else {
180
- // MSC4108-Flow: NewScanned - nothing to do
181
152
  }
182
- return {};
183
- })();
153
+ } else if (this.isNewDevice) {
154
+ // MSC4108-Flow: ExistingScanned - wait for protocols message
155
+ logger.info("Waiting for protocols message");
156
+ const payload = await this.receive();
157
+ if (payload?.type === PayloadType.Failure) {
158
+ throw new RendezvousError("Failed", payload.reason);
159
+ }
160
+ if (payload?.type !== PayloadType.Protocols) {
161
+ await this.send({
162
+ type: PayloadType.Failure,
163
+ reason: MSC4108FailureReason.UnexpectedMessageReceived
164
+ });
165
+ throw new RendezvousError("Unexpected message received", MSC4108FailureReason.UnexpectedMessageReceived);
166
+ }
167
+ return {
168
+ serverName: payload.homeserver
169
+ };
170
+ } else {
171
+ // MSC4108-Flow: NewScanned - nothing to do
172
+ }
173
+ return {};
184
174
  }
185
175
 
186
176
  /**
@@ -190,90 +180,91 @@ export class MSC4108SignInWithQR {
190
180
  *
191
181
  * @param input - Required for the new device to start the device authorization grant, not required for the existing device reciprocating the login
192
182
  */
193
- deviceAuthorizationGrant(input) {
194
- var _this3 = this;
195
- return _asyncToGenerator(function* () {
196
- if (_this3.isNewDevice) {
197
- var _dagResponse$verifica;
198
- if (!input) {
199
- throw new Error("Input must be provided for new device");
200
- }
201
- var metadata = input.metadata,
202
- clientId = input.clientId,
203
- deviceId = input.deviceId;
204
- var scope = generateScope(deviceId);
183
+ async deviceAuthorizationGrant(input) {
184
+ if (this.isNewDevice) {
185
+ if (!input) {
186
+ throw new Error("Input must be provided for new device");
187
+ }
188
+ const {
189
+ metadata,
190
+ clientId,
191
+ deviceId
192
+ } = input;
193
+ const scope = generateScope(deviceId);
205
194
 
206
- // MSC4108-Flow: NewDevice - start device authorization grant
207
- var dagResponse = yield startDeviceAuthorization({
208
- clientId,
209
- scope,
210
- metadata
195
+ // MSC4108-Flow: NewDevice - start device authorization grant
196
+ const dagResponse = await startDeviceAuthorization({
197
+ clientId,
198
+ scope,
199
+ metadata
200
+ });
201
+ this.metadata = metadata;
202
+ this.grantInProgress = dagResponse;
203
+ const protocol = {
204
+ type: PayloadType.Protocol,
205
+ protocol: "device_authorization_grant",
206
+ device_id: deviceId,
207
+ device_authorization_grant: {
208
+ verification_uri: dagResponse.verification_uri,
209
+ verification_uri_complete: dagResponse.verification_uri_complete
210
+ }
211
+ };
212
+ await this.send(protocol);
213
+ return {
214
+ verificationUri: dagResponse.verification_uri_complete ?? dagResponse.verification_uri,
215
+ userCode: dagResponse.user_code
216
+ };
217
+ } else {
218
+ // The user needs to do step 7 for the out-of-band confirmation
219
+ // but, first we receive the protocol chosen by the other device so that
220
+ // the confirmation_uri is ready to go
221
+ logger.info("Waiting for protocol message");
222
+ const payload = await this.receive();
223
+ if (payload?.type === PayloadType.Failure) {
224
+ throw new RendezvousError("Failed", payload.reason);
225
+ }
226
+ if (payload?.type !== PayloadType.Protocol) {
227
+ await this.send({
228
+ type: PayloadType.Failure,
229
+ reason: MSC4108FailureReason.UnexpectedMessageReceived
211
230
  });
212
- _this3.metadata = metadata;
213
- _this3.grantInProgress = dagResponse;
214
- var protocol = {
215
- type: PayloadType.Protocol,
216
- protocol: "device_authorization_grant",
217
- device_id: deviceId,
218
- device_authorization_grant: {
219
- verification_uri: dagResponse.verification_uri,
220
- verification_uri_complete: dagResponse.verification_uri_complete
231
+ throw new RendezvousError("Unexpected message received", MSC4108FailureReason.UnexpectedMessageReceived);
232
+ }
233
+ if (isDeviceAuthorizationGrantProtocolPayload(payload)) {
234
+ const {
235
+ device_authorization_grant: dag,
236
+ device_id: expectingNewDeviceId
237
+ } = payload;
238
+ const {
239
+ verification_uri: verificationUri,
240
+ verification_uri_complete: verificationUriComplete
241
+ } = dag;
242
+ let deviceAlreadyExists = true;
243
+ try {
244
+ await this.client?.getDevice(expectingNewDeviceId);
245
+ } catch (err) {
246
+ if (err instanceof MatrixError && err.httpStatus === 404) {
247
+ deviceAlreadyExists = false;
221
248
  }
222
- };
223
- yield _this3.send(protocol);
224
- return {
225
- verificationUri: (_dagResponse$verifica = dagResponse.verification_uri_complete) !== null && _dagResponse$verifica !== void 0 ? _dagResponse$verifica : dagResponse.verification_uri,
226
- userCode: dagResponse.user_code
227
- };
228
- } else {
229
- // The user needs to do step 7 for the out-of-band confirmation
230
- // but, first we receive the protocol chosen by the other device so that
231
- // the confirmation_uri is ready to go
232
- logger.info("Waiting for protocol message");
233
- var payload = yield _this3.receive();
234
- if ((payload === null || payload === void 0 ? void 0 : payload.type) === PayloadType.Failure) {
235
- throw new RendezvousError("Failed", payload.reason);
236
249
  }
237
- if ((payload === null || payload === void 0 ? void 0 : payload.type) !== PayloadType.Protocol) {
238
- yield _this3.send({
250
+ if (deviceAlreadyExists) {
251
+ await this.send({
239
252
  type: PayloadType.Failure,
240
- reason: MSC4108FailureReason.UnexpectedMessageReceived
253
+ reason: MSC4108FailureReason.DeviceAlreadyExists
241
254
  });
242
- throw new RendezvousError("Unexpected message received", MSC4108FailureReason.UnexpectedMessageReceived);
243
- }
244
- if (isDeviceAuthorizationGrantProtocolPayload(payload)) {
245
- var dag = payload.device_authorization_grant,
246
- expectingNewDeviceId = payload.device_id;
247
- var verificationUri = dag.verification_uri,
248
- verificationUriComplete = dag.verification_uri_complete;
249
- var deviceAlreadyExists = true;
250
- try {
251
- var _this3$client;
252
- yield (_this3$client = _this3.client) === null || _this3$client === void 0 ? void 0 : _this3$client.getDevice(expectingNewDeviceId);
253
- } catch (err) {
254
- if (err instanceof MatrixError && err.httpStatus === 404) {
255
- deviceAlreadyExists = false;
256
- }
257
- }
258
- if (deviceAlreadyExists) {
259
- yield _this3.send({
260
- type: PayloadType.Failure,
261
- reason: MSC4108FailureReason.DeviceAlreadyExists
262
- });
263
- throw new RendezvousError("Specified device ID already exists", MSC4108FailureReason.DeviceAlreadyExists);
264
- }
265
- _this3.expectingNewDeviceId = expectingNewDeviceId;
266
- return {
267
- verificationUri: verificationUriComplete !== null && verificationUriComplete !== void 0 ? verificationUriComplete : verificationUri
268
- };
255
+ throw new RendezvousError("Specified device ID already exists", MSC4108FailureReason.DeviceAlreadyExists);
269
256
  }
270
- yield _this3.send({
271
- type: PayloadType.Failure,
272
- reason: MSC4108FailureReason.UnsupportedProtocol
273
- });
274
- throw new RendezvousError("Received a request for an unsupported protocol", MSC4108FailureReason.UnsupportedProtocol);
257
+ this.expectingNewDeviceId = expectingNewDeviceId;
258
+ return {
259
+ verificationUri: verificationUriComplete ?? verificationUri
260
+ };
275
261
  }
276
- })();
262
+ await this.send({
263
+ type: PayloadType.Failure,
264
+ reason: MSC4108FailureReason.UnsupportedProtocol
265
+ });
266
+ throw new RendezvousError("Received a request for an unsupported protocol", MSC4108FailureReason.UnsupportedProtocol);
267
+ }
277
268
  }
278
269
 
279
270
  /**
@@ -281,191 +272,169 @@ export class MSC4108SignInWithQR {
281
272
  * The reciprocating device must perform step 5 for this method to resolve.
282
273
  * To be called after {@link deviceAuthorizationGrant} only on the new device.
283
274
  */
284
- completeLoginOnNewDevice(_ref) {
285
- var _this4 = this;
286
- return _asyncToGenerator(function* () {
287
- var clientId = _ref.clientId;
288
- if (!_this4.isNewDevice || !_this4.grantInProgress || !_this4.metadata) {
289
- throw new Error("Can only complete login on new device");
290
- }
291
- logger.info("Waiting for protocol accepted message");
292
- // wait for accepted message
293
- var payload = yield _this4.receive();
294
- if (!payload) {
295
- throw new RendezvousError("No response from existing device", MSC4108FailureReason.UnexpectedMessageReceived);
296
- }
297
- if (payload.type === PayloadType.Failure) {
298
- throw new RendezvousError("Failed", payload.reason);
299
- }
300
- if (payload.type !== PayloadType.ProtocolAccepted) {
301
- throw new RendezvousError("Unexpected message received", MSC4108FailureReason.UnexpectedMessageReceived);
302
- }
275
+ async completeLoginOnNewDevice({
276
+ clientId
277
+ }) {
278
+ if (!this.isNewDevice || !this.grantInProgress || !this.metadata) {
279
+ throw new Error("Can only complete login on new device");
280
+ }
281
+ logger.info("Waiting for protocol accepted message");
282
+ // wait for accepted message
283
+ const payload = await this.receive();
284
+ if (!payload) {
285
+ throw new RendezvousError("No response from existing device", MSC4108FailureReason.UnexpectedMessageReceived);
286
+ }
287
+ if (payload.type === PayloadType.Failure) {
288
+ throw new RendezvousError("Failed", payload.reason);
289
+ }
290
+ if (payload.type !== PayloadType.ProtocolAccepted) {
291
+ throw new RendezvousError("Unexpected message received", MSC4108FailureReason.UnexpectedMessageReceived);
292
+ }
303
293
 
304
- // poll for DAG
305
- var res = yield waitForDeviceAuthorization({
306
- session: _this4.grantInProgress,
307
- metadata: _this4.metadata,
308
- clientId
309
- });
310
- if (!res) {
311
- throw new RendezvousError("No response from device authorization endpoint", ClientRendezvousFailureReason.Unknown);
294
+ // poll for DAG
295
+ const res = await waitForDeviceAuthorization({
296
+ session: this.grantInProgress,
297
+ metadata: this.metadata,
298
+ clientId
299
+ });
300
+ if (!res) {
301
+ throw new RendezvousError("No response from device authorization endpoint", ClientRendezvousFailureReason.Unknown);
302
+ }
303
+ if ("error" in res) {
304
+ let reason = MSC4108FailureReason.UnexpectedMessageReceived;
305
+ if (res.error === "expired_token") {
306
+ reason = MSC4108FailureReason.AuthorizationExpired;
307
+ } else if (res.error === "access_denied") {
308
+ reason = MSC4108FailureReason.UserCancelled;
312
309
  }
313
- if ("error" in res) {
314
- var reason = MSC4108FailureReason.UnexpectedMessageReceived;
315
- if (res.error === "expired_token") {
316
- reason = MSC4108FailureReason.AuthorizationExpired;
317
- } else if (res.error === "access_denied") {
318
- reason = MSC4108FailureReason.UserCancelled;
319
- }
320
- var _payload = {
321
- type: PayloadType.Failure,
322
- reason
323
- };
324
- yield _this4.send(_payload);
325
- throw new RendezvousError("Rejection from device authorization endpoint", reason);
326
- }
327
- return res;
328
- })();
310
+ const payload = {
311
+ type: PayloadType.Failure,
312
+ reason
313
+ };
314
+ await this.send(payload);
315
+ throw new RendezvousError("Rejection from device authorization endpoint", reason);
316
+ }
317
+ return res;
329
318
  }
330
319
 
331
320
  /**
332
321
  * The fifth (and final) step in the OIDC QR login process.
333
322
  * To be called after the new device has completed authentication.
334
323
  */
335
- shareSecrets() {
336
- var _this5 = this;
337
- return _asyncToGenerator(function* () {
338
- if (_this5.isNewDevice) {
339
- yield _this5.send({
340
- type: PayloadType.Success
341
- });
342
- // then wait for secrets
343
- logger.info("Waiting for secrets message");
344
- var payload = yield _this5.receive();
345
- if ((payload === null || payload === void 0 ? void 0 : payload.type) === PayloadType.Failure) {
346
- throw new RendezvousError("Failed", payload.reason);
347
- }
348
- if ((payload === null || payload === void 0 ? void 0 : payload.type) !== PayloadType.Secrets) {
349
- yield _this5.send({
350
- type: PayloadType.Failure,
351
- reason: MSC4108FailureReason.UnexpectedMessageReceived
352
- });
353
- throw new RendezvousError("Unexpected message received", MSC4108FailureReason.UnexpectedMessageReceived);
354
- }
355
- return {
356
- secrets: payload
357
- };
358
- // then done?
359
- } else {
360
- if (!_this5.expectingNewDeviceId) {
361
- throw new Error("No new device ID expected");
362
- }
363
- yield _this5.send({
364
- type: PayloadType.ProtocolAccepted
324
+ async shareSecrets() {
325
+ if (this.isNewDevice) {
326
+ await this.send({
327
+ type: PayloadType.Success
328
+ });
329
+ // then wait for secrets
330
+ logger.info("Waiting for secrets message");
331
+ const payload = await this.receive();
332
+ if (payload?.type === PayloadType.Failure) {
333
+ throw new RendezvousError("Failed", payload.reason);
334
+ }
335
+ if (payload?.type !== PayloadType.Secrets) {
336
+ await this.send({
337
+ type: PayloadType.Failure,
338
+ reason: MSC4108FailureReason.UnexpectedMessageReceived
365
339
  });
366
- logger.info("Waiting for outcome message");
367
- var _payload2 = yield _this5.receive();
368
- if ((_payload2 === null || _payload2 === void 0 ? void 0 : _payload2.type) === PayloadType.Failure) {
369
- throw new RendezvousError("Failed", _payload2.reason);
370
- }
371
- if ((_payload2 === null || _payload2 === void 0 ? void 0 : _payload2.type) === PayloadType.Declined) {
372
- throw new RendezvousError("User declined", ClientRendezvousFailureReason.UserDeclined);
373
- }
374
- if ((_payload2 === null || _payload2 === void 0 ? void 0 : _payload2.type) !== PayloadType.Success) {
375
- yield _this5.send({
376
- type: PayloadType.Failure,
377
- reason: MSC4108FailureReason.UnexpectedMessageReceived
378
- });
379
- throw new RendezvousError("Unexpected message", MSC4108FailureReason.UnexpectedMessageReceived);
380
- }
381
- var timeout = Date.now() + 10000; // wait up to 10 seconds
382
- do {
383
- // is the device visible via the Homeserver?
384
- try {
385
- var _this5$client;
386
- var device = yield (_this5$client = _this5.client) === null || _this5$client === void 0 ? void 0 : _this5$client.getDevice(_this5.expectingNewDeviceId);
387
- if (device) {
388
- // if so, return the secrets
389
- var secretsBundle = yield _this5.client.getCrypto().exportSecretsBundle();
390
- if (_this5.channel.cancelled) {
391
- throw new RendezvousError("User cancelled", MSC4108FailureReason.UserCancelled);
392
- }
393
- // send secrets
394
- yield _this5.send(_objectSpread({
395
- type: PayloadType.Secrets
396
- }, secretsBundle));
397
- return {
398
- secrets: secretsBundle
399
- };
400
- // let the other side close the rendezvous session
401
- }
402
- } catch (err) {
403
- if (err instanceof MatrixError && err.httpStatus === 404) {
404
- // not found, so keep waiting until timeout
405
- } else {
406
- throw err;
407
- }
408
- }
409
- yield sleep(1000);
410
- } while (Date.now() < timeout);
411
- yield _this5.send({
340
+ throw new RendezvousError("Unexpected message received", MSC4108FailureReason.UnexpectedMessageReceived);
341
+ }
342
+ return {
343
+ secrets: payload
344
+ };
345
+ // then done?
346
+ } else {
347
+ if (!this.expectingNewDeviceId) {
348
+ throw new Error("No new device ID expected");
349
+ }
350
+ await this.send({
351
+ type: PayloadType.ProtocolAccepted
352
+ });
353
+ logger.info("Waiting for outcome message");
354
+ const payload = await this.receive();
355
+ if (payload?.type === PayloadType.Failure) {
356
+ throw new RendezvousError("Failed", payload.reason);
357
+ }
358
+ if (payload?.type === PayloadType.Declined) {
359
+ throw new RendezvousError("User declined", ClientRendezvousFailureReason.UserDeclined);
360
+ }
361
+ if (payload?.type !== PayloadType.Success) {
362
+ await this.send({
412
363
  type: PayloadType.Failure,
413
- reason: MSC4108FailureReason.DeviceNotFound
364
+ reason: MSC4108FailureReason.UnexpectedMessageReceived
414
365
  });
415
- throw new RendezvousError("New device not found", MSC4108FailureReason.DeviceNotFound);
366
+ throw new RendezvousError("Unexpected message", MSC4108FailureReason.UnexpectedMessageReceived);
416
367
  }
417
- })();
368
+ const timeout = Date.now() + 10000; // wait up to 10 seconds
369
+ do {
370
+ // is the device visible via the Homeserver?
371
+ try {
372
+ const device = await this.client?.getDevice(this.expectingNewDeviceId);
373
+ if (device) {
374
+ // if so, return the secrets
375
+ const secretsBundle = await this.client.getCrypto().exportSecretsBundle();
376
+ if (this.channel.cancelled) {
377
+ throw new RendezvousError("User cancelled", MSC4108FailureReason.UserCancelled);
378
+ }
379
+ // send secrets
380
+ await this.send(_objectSpread({
381
+ type: PayloadType.Secrets
382
+ }, secretsBundle));
383
+ return {
384
+ secrets: secretsBundle
385
+ };
386
+ // let the other side close the rendezvous session
387
+ }
388
+ } catch (err) {
389
+ if (err instanceof MatrixError && err.httpStatus === 404) {
390
+ // not found, so keep waiting until timeout
391
+ } else {
392
+ throw err;
393
+ }
394
+ }
395
+ await sleep(1000);
396
+ } while (Date.now() < timeout);
397
+ await this.send({
398
+ type: PayloadType.Failure,
399
+ reason: MSC4108FailureReason.DeviceNotFound
400
+ });
401
+ throw new RendezvousError("New device not found", MSC4108FailureReason.DeviceNotFound);
402
+ }
418
403
  }
419
- receive() {
420
- var _this6 = this;
421
- return _asyncToGenerator(function* () {
422
- return yield _this6.channel.secureReceive();
423
- })();
404
+ async receive() {
405
+ return await this.channel.secureReceive();
424
406
  }
425
- send(payload) {
426
- var _this7 = this;
427
- return _asyncToGenerator(function* () {
428
- yield _this7.channel.secureSend(payload);
429
- })();
407
+ async send(payload) {
408
+ await this.channel.secureSend(payload);
430
409
  }
431
410
 
432
411
  /**
433
412
  * Decline the login on the existing device.
434
413
  */
435
- declineLoginOnExistingDevice() {
436
- var _this8 = this;
437
- return _asyncToGenerator(function* () {
438
- if (!_this8.isExistingDevice) {
439
- throw new Error("Can only decline login on existing device");
440
- }
441
- yield _this8.send({
442
- type: PayloadType.Failure,
443
- reason: MSC4108FailureReason.UserCancelled
444
- });
445
- })();
414
+ async declineLoginOnExistingDevice() {
415
+ if (!this.isExistingDevice) {
416
+ throw new Error("Can only decline login on existing device");
417
+ }
418
+ await this.send({
419
+ type: PayloadType.Failure,
420
+ reason: MSC4108FailureReason.UserCancelled
421
+ });
446
422
  }
447
423
 
448
424
  /**
449
425
  * Cancels the rendezvous session.
450
426
  * @param reason the reason for the cancellation
451
427
  */
452
- cancel(reason) {
453
- var _this9 = this;
454
- return _asyncToGenerator(function* () {
455
- var _this9$onFailure;
456
- (_this9$onFailure = _this9.onFailure) === null || _this9$onFailure === void 0 || _this9$onFailure.call(_this9, reason);
457
- yield _this9.channel.cancel(reason);
458
- })();
428
+ async cancel(reason) {
429
+ this.onFailure?.(reason);
430
+ await this.channel.cancel(reason);
459
431
  }
460
432
 
461
433
  /**
462
434
  * Closes the rendezvous session.
463
435
  */
464
- close() {
465
- var _this0 = this;
466
- return _asyncToGenerator(function* () {
467
- yield _this0.channel.close();
468
- })();
436
+ async close() {
437
+ await this.channel.close();
469
438
  }
470
439
  }
471
440
  //# sourceMappingURL=MSC4108SignInWithQR.js.map