@unwanted/matrix-sdk-mini 34.12.0-2 → 34.12.0-3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (467) hide show
  1. package/git-revision.txt +1 -1
  2. package/lib/@types/global.d.js +0 -2
  3. package/lib/@types/global.d.js.map +1 -1
  4. package/lib/browser-index.d.ts.map +1 -1
  5. package/lib/browser-index.js +0 -11
  6. package/lib/browser-index.js.map +1 -1
  7. package/lib/client.d.ts +2 -1176
  8. package/lib/client.d.ts.map +1 -1
  9. package/lib/client.js +346 -2717
  10. package/lib/client.js.map +1 -1
  11. package/lib/embedded.d.ts +0 -22
  12. package/lib/embedded.d.ts.map +1 -1
  13. package/lib/embedded.js +24 -166
  14. package/lib/embedded.js.map +1 -1
  15. package/lib/event-mapper.d.ts.map +1 -1
  16. package/lib/event-mapper.js +0 -4
  17. package/lib/event-mapper.js.map +1 -1
  18. package/lib/matrix.d.ts +0 -19
  19. package/lib/matrix.d.ts.map +1 -1
  20. package/lib/matrix.js +1 -26
  21. package/lib/matrix.js.map +1 -1
  22. package/lib/models/MSC3089Branch.d.ts.map +1 -1
  23. package/lib/models/MSC3089Branch.js +0 -3
  24. package/lib/models/MSC3089Branch.js.map +1 -1
  25. package/lib/models/event.d.ts +0 -94
  26. package/lib/models/event.d.ts.map +1 -1
  27. package/lib/models/event.js +0 -274
  28. package/lib/models/event.js.map +1 -1
  29. package/lib/models/poll.d.ts.map +1 -1
  30. package/lib/models/poll.js +1 -5
  31. package/lib/models/poll.js.map +1 -1
  32. package/lib/models/relations-container.d.ts.map +1 -1
  33. package/lib/models/relations-container.js +1 -7
  34. package/lib/models/relations-container.js.map +1 -1
  35. package/lib/models/relations.d.ts +0 -1
  36. package/lib/models/relations.d.ts.map +1 -1
  37. package/lib/models/relations.js +0 -8
  38. package/lib/models/relations.js.map +1 -1
  39. package/lib/models/room-state.d.ts.map +1 -1
  40. package/lib/models/room-state.js +10 -26
  41. package/lib/models/room-state.js.map +1 -1
  42. package/lib/models/room.d.ts +0 -18
  43. package/lib/models/room.d.ts.map +1 -1
  44. package/lib/models/room.js +94 -148
  45. package/lib/models/room.js.map +1 -1
  46. package/lib/models/thread.d.ts.map +1 -1
  47. package/lib/models/thread.js +0 -1
  48. package/lib/models/thread.js.map +1 -1
  49. package/lib/sliding-sync-sdk.d.ts +2 -3
  50. package/lib/sliding-sync-sdk.d.ts.map +1 -1
  51. package/lib/sliding-sync-sdk.js +41 -90
  52. package/lib/sliding-sync-sdk.js.map +1 -1
  53. package/lib/sync.d.ts +0 -12
  54. package/lib/sync.d.ts.map +1 -1
  55. package/lib/sync.js +1 -73
  56. package/lib/sync.js.map +1 -1
  57. package/lib/testing.d.ts +0 -48
  58. package/lib/testing.d.ts.map +1 -1
  59. package/lib/testing.js +0 -105
  60. package/lib/testing.js.map +1 -1
  61. package/package.json +1 -3
  62. package/src/@types/global.d.ts +0 -3
  63. package/src/browser-index.ts +0 -11
  64. package/src/client.ts +57 -2732
  65. package/src/embedded.ts +3 -130
  66. package/src/event-mapper.ts +0 -4
  67. package/src/matrix.ts +0 -28
  68. package/src/models/MSC3089Branch.ts +0 -3
  69. package/src/models/event.ts +0 -289
  70. package/src/models/poll.ts +0 -6
  71. package/src/models/relations-container.ts +1 -8
  72. package/src/models/relations.ts +0 -8
  73. package/src/models/room-state.ts +2 -8
  74. package/src/models/room.ts +0 -62
  75. package/src/models/thread.ts +0 -1
  76. package/src/sliding-sync-sdk.ts +2 -72
  77. package/src/sync.ts +1 -98
  78. package/src/testing.ts +0 -108
  79. package/lib/@types/crypto.d.ts +0 -47
  80. package/lib/@types/crypto.d.ts.map +0 -1
  81. package/lib/@types/crypto.js +0 -1
  82. package/lib/@types/crypto.js.map +0 -1
  83. package/lib/@types/matrix-sdk-crypto-wasm.d.js +0 -1
  84. package/lib/@types/matrix-sdk-crypto-wasm.d.js.map +0 -1
  85. package/lib/common-crypto/CryptoBackend.d.ts +0 -240
  86. package/lib/common-crypto/CryptoBackend.d.ts.map +0 -1
  87. package/lib/common-crypto/CryptoBackend.js +0 -73
  88. package/lib/common-crypto/CryptoBackend.js.map +0 -1
  89. package/lib/common-crypto/key-passphrase.d.ts +0 -14
  90. package/lib/common-crypto/key-passphrase.d.ts.map +0 -1
  91. package/lib/common-crypto/key-passphrase.js +0 -33
  92. package/lib/common-crypto/key-passphrase.js.map +0 -1
  93. package/lib/crypto/CrossSigning.d.ts +0 -184
  94. package/lib/crypto/CrossSigning.d.ts.map +0 -1
  95. package/lib/crypto/CrossSigning.js +0 -718
  96. package/lib/crypto/CrossSigning.js.map +0 -1
  97. package/lib/crypto/DeviceList.d.ts +0 -216
  98. package/lib/crypto/DeviceList.d.ts.map +0 -1
  99. package/lib/crypto/DeviceList.js +0 -892
  100. package/lib/crypto/DeviceList.js.map +0 -1
  101. package/lib/crypto/EncryptionSetup.d.ts +0 -152
  102. package/lib/crypto/EncryptionSetup.d.ts.map +0 -1
  103. package/lib/crypto/EncryptionSetup.js +0 -356
  104. package/lib/crypto/EncryptionSetup.js.map +0 -1
  105. package/lib/crypto/OlmDevice.d.ts +0 -457
  106. package/lib/crypto/OlmDevice.d.ts.map +0 -1
  107. package/lib/crypto/OlmDevice.js +0 -1241
  108. package/lib/crypto/OlmDevice.js.map +0 -1
  109. package/lib/crypto/OutgoingRoomKeyRequestManager.d.ts +0 -109
  110. package/lib/crypto/OutgoingRoomKeyRequestManager.d.ts.map +0 -1
  111. package/lib/crypto/OutgoingRoomKeyRequestManager.js +0 -415
  112. package/lib/crypto/OutgoingRoomKeyRequestManager.js.map +0 -1
  113. package/lib/crypto/RoomList.d.ts +0 -26
  114. package/lib/crypto/RoomList.d.ts.map +0 -1
  115. package/lib/crypto/RoomList.js +0 -71
  116. package/lib/crypto/RoomList.js.map +0 -1
  117. package/lib/crypto/SecretSharing.d.ts +0 -24
  118. package/lib/crypto/SecretSharing.d.ts.map +0 -1
  119. package/lib/crypto/SecretSharing.js +0 -194
  120. package/lib/crypto/SecretSharing.js.map +0 -1
  121. package/lib/crypto/SecretStorage.d.ts +0 -55
  122. package/lib/crypto/SecretStorage.d.ts.map +0 -1
  123. package/lib/crypto/SecretStorage.js +0 -118
  124. package/lib/crypto/SecretStorage.js.map +0 -1
  125. package/lib/crypto/aes.d.ts +0 -6
  126. package/lib/crypto/aes.d.ts.map +0 -1
  127. package/lib/crypto/aes.js +0 -24
  128. package/lib/crypto/aes.js.map +0 -1
  129. package/lib/crypto/algorithms/base.d.ts +0 -156
  130. package/lib/crypto/algorithms/base.d.ts.map +0 -1
  131. package/lib/crypto/algorithms/base.js +0 -187
  132. package/lib/crypto/algorithms/base.js.map +0 -1
  133. package/lib/crypto/algorithms/index.d.ts +0 -4
  134. package/lib/crypto/algorithms/index.d.ts.map +0 -1
  135. package/lib/crypto/algorithms/index.js +0 -20
  136. package/lib/crypto/algorithms/index.js.map +0 -1
  137. package/lib/crypto/algorithms/megolm.d.ts +0 -385
  138. package/lib/crypto/algorithms/megolm.d.ts.map +0 -1
  139. package/lib/crypto/algorithms/megolm.js +0 -1822
  140. package/lib/crypto/algorithms/megolm.js.map +0 -1
  141. package/lib/crypto/algorithms/olm.d.ts +0 -5
  142. package/lib/crypto/algorithms/olm.d.ts.map +0 -1
  143. package/lib/crypto/algorithms/olm.js +0 -299
  144. package/lib/crypto/algorithms/olm.js.map +0 -1
  145. package/lib/crypto/api.d.ts +0 -32
  146. package/lib/crypto/api.d.ts.map +0 -1
  147. package/lib/crypto/api.js +0 -22
  148. package/lib/crypto/api.js.map +0 -1
  149. package/lib/crypto/backup.d.ts +0 -227
  150. package/lib/crypto/backup.d.ts.map +0 -1
  151. package/lib/crypto/backup.js +0 -824
  152. package/lib/crypto/backup.js.map +0 -1
  153. package/lib/crypto/crypto.d.ts +0 -3
  154. package/lib/crypto/crypto.d.ts.map +0 -1
  155. package/lib/crypto/crypto.js +0 -19
  156. package/lib/crypto/crypto.js.map +0 -1
  157. package/lib/crypto/dehydration.d.ts +0 -34
  158. package/lib/crypto/dehydration.d.ts.map +0 -1
  159. package/lib/crypto/dehydration.js +0 -252
  160. package/lib/crypto/dehydration.js.map +0 -1
  161. package/lib/crypto/device-converter.d.ts +0 -9
  162. package/lib/crypto/device-converter.d.ts.map +0 -1
  163. package/lib/crypto/device-converter.js +0 -42
  164. package/lib/crypto/device-converter.js.map +0 -1
  165. package/lib/crypto/deviceinfo.d.ts +0 -99
  166. package/lib/crypto/deviceinfo.d.ts.map +0 -1
  167. package/lib/crypto/deviceinfo.js +0 -148
  168. package/lib/crypto/deviceinfo.js.map +0 -1
  169. package/lib/crypto/index.d.ts +0 -1209
  170. package/lib/crypto/index.d.ts.map +0 -1
  171. package/lib/crypto/index.js +0 -4097
  172. package/lib/crypto/index.js.map +0 -1
  173. package/lib/crypto/key_passphrase.d.ts +0 -14
  174. package/lib/crypto/key_passphrase.d.ts.map +0 -1
  175. package/lib/crypto/key_passphrase.js +0 -44
  176. package/lib/crypto/key_passphrase.js.map +0 -1
  177. package/lib/crypto/keybackup.d.ts +0 -18
  178. package/lib/crypto/keybackup.d.ts.map +0 -1
  179. package/lib/crypto/keybackup.js +0 -1
  180. package/lib/crypto/keybackup.js.map +0 -1
  181. package/lib/crypto/olmlib.d.ts +0 -129
  182. package/lib/crypto/olmlib.d.ts.map +0 -1
  183. package/lib/crypto/olmlib.js +0 -492
  184. package/lib/crypto/olmlib.js.map +0 -1
  185. package/lib/crypto/recoverykey.d.ts +0 -2
  186. package/lib/crypto/recoverykey.d.ts.map +0 -1
  187. package/lib/crypto/recoverykey.js +0 -19
  188. package/lib/crypto/recoverykey.js.map +0 -1
  189. package/lib/crypto/store/base.d.ts +0 -252
  190. package/lib/crypto/store/base.d.ts.map +0 -1
  191. package/lib/crypto/store/base.js +0 -64
  192. package/lib/crypto/store/base.js.map +0 -1
  193. package/lib/crypto/store/indexeddb-crypto-store-backend.d.ts +0 -187
  194. package/lib/crypto/store/indexeddb-crypto-store-backend.d.ts.map +0 -1
  195. package/lib/crypto/store/indexeddb-crypto-store-backend.js +0 -1145
  196. package/lib/crypto/store/indexeddb-crypto-store-backend.js.map +0 -1
  197. package/lib/crypto/store/indexeddb-crypto-store.d.ts +0 -432
  198. package/lib/crypto/store/indexeddb-crypto-store.d.ts.map +0 -1
  199. package/lib/crypto/store/indexeddb-crypto-store.js +0 -728
  200. package/lib/crypto/store/indexeddb-crypto-store.js.map +0 -1
  201. package/lib/crypto/store/localStorage-crypto-store.d.ts +0 -119
  202. package/lib/crypto/store/localStorage-crypto-store.d.ts.map +0 -1
  203. package/lib/crypto/store/localStorage-crypto-store.js +0 -531
  204. package/lib/crypto/store/localStorage-crypto-store.js.map +0 -1
  205. package/lib/crypto/store/memory-crypto-store.d.ts +0 -215
  206. package/lib/crypto/store/memory-crypto-store.d.ts.map +0 -1
  207. package/lib/crypto/store/memory-crypto-store.js +0 -622
  208. package/lib/crypto/store/memory-crypto-store.js.map +0 -1
  209. package/lib/crypto/verification/Base.d.ts +0 -105
  210. package/lib/crypto/verification/Base.d.ts.map +0 -1
  211. package/lib/crypto/verification/Base.js +0 -372
  212. package/lib/crypto/verification/Base.js.map +0 -1
  213. package/lib/crypto/verification/Error.d.ts +0 -35
  214. package/lib/crypto/verification/Error.d.ts.map +0 -1
  215. package/lib/crypto/verification/Error.js +0 -86
  216. package/lib/crypto/verification/Error.js.map +0 -1
  217. package/lib/crypto/verification/IllegalMethod.d.ts +0 -15
  218. package/lib/crypto/verification/IllegalMethod.d.ts.map +0 -1
  219. package/lib/crypto/verification/IllegalMethod.js +0 -43
  220. package/lib/crypto/verification/IllegalMethod.js.map +0 -1
  221. package/lib/crypto/verification/QRCode.d.ts +0 -51
  222. package/lib/crypto/verification/QRCode.d.ts.map +0 -1
  223. package/lib/crypto/verification/QRCode.js +0 -277
  224. package/lib/crypto/verification/QRCode.js.map +0 -1
  225. package/lib/crypto/verification/SAS.d.ts +0 -27
  226. package/lib/crypto/verification/SAS.d.ts.map +0 -1
  227. package/lib/crypto/verification/SAS.js +0 -485
  228. package/lib/crypto/verification/SAS.js.map +0 -1
  229. package/lib/crypto/verification/SASDecimal.d.ts +0 -8
  230. package/lib/crypto/verification/SASDecimal.d.ts.map +0 -1
  231. package/lib/crypto/verification/SASDecimal.js +0 -34
  232. package/lib/crypto/verification/SASDecimal.js.map +0 -1
  233. package/lib/crypto/verification/request/Channel.d.ts +0 -18
  234. package/lib/crypto/verification/request/Channel.d.ts.map +0 -1
  235. package/lib/crypto/verification/request/Channel.js +0 -1
  236. package/lib/crypto/verification/request/Channel.js.map +0 -1
  237. package/lib/crypto/verification/request/InRoomChannel.d.ts +0 -113
  238. package/lib/crypto/verification/request/InRoomChannel.d.ts.map +0 -1
  239. package/lib/crypto/verification/request/InRoomChannel.js +0 -351
  240. package/lib/crypto/verification/request/InRoomChannel.js.map +0 -1
  241. package/lib/crypto/verification/request/ToDeviceChannel.d.ts +0 -105
  242. package/lib/crypto/verification/request/ToDeviceChannel.d.ts.map +0 -1
  243. package/lib/crypto/verification/request/ToDeviceChannel.js +0 -328
  244. package/lib/crypto/verification/request/ToDeviceChannel.js.map +0 -1
  245. package/lib/crypto/verification/request/VerificationRequest.d.ts +0 -227
  246. package/lib/crypto/verification/request/VerificationRequest.d.ts.map +0 -1
  247. package/lib/crypto/verification/request/VerificationRequest.js +0 -937
  248. package/lib/crypto/verification/request/VerificationRequest.js.map +0 -1
  249. package/lib/crypto-api/CryptoEvent.d.ts +0 -69
  250. package/lib/crypto-api/CryptoEvent.d.ts.map +0 -1
  251. package/lib/crypto-api/CryptoEvent.js +0 -33
  252. package/lib/crypto-api/CryptoEvent.js.map +0 -1
  253. package/lib/crypto-api/CryptoEventHandlerMap.d.ts +0 -16
  254. package/lib/crypto-api/CryptoEventHandlerMap.d.ts.map +0 -1
  255. package/lib/crypto-api/CryptoEventHandlerMap.js +0 -22
  256. package/lib/crypto-api/CryptoEventHandlerMap.js.map +0 -1
  257. package/lib/crypto-api/index.d.ts +0 -978
  258. package/lib/crypto-api/index.d.ts.map +0 -1
  259. package/lib/crypto-api/index.js +0 -304
  260. package/lib/crypto-api/index.js.map +0 -1
  261. package/lib/crypto-api/key-passphrase.d.ts +0 -11
  262. package/lib/crypto-api/key-passphrase.d.ts.map +0 -1
  263. package/lib/crypto-api/key-passphrase.js +0 -51
  264. package/lib/crypto-api/key-passphrase.js.map +0 -1
  265. package/lib/crypto-api/keybackup.d.ts +0 -88
  266. package/lib/crypto-api/keybackup.d.ts.map +0 -1
  267. package/lib/crypto-api/keybackup.js +0 -1
  268. package/lib/crypto-api/keybackup.js.map +0 -1
  269. package/lib/crypto-api/recovery-key.d.ts +0 -11
  270. package/lib/crypto-api/recovery-key.d.ts.map +0 -1
  271. package/lib/crypto-api/recovery-key.js +0 -65
  272. package/lib/crypto-api/recovery-key.js.map +0 -1
  273. package/lib/crypto-api/verification.d.ts +0 -344
  274. package/lib/crypto-api/verification.d.ts.map +0 -1
  275. package/lib/crypto-api/verification.js +0 -91
  276. package/lib/crypto-api/verification.js.map +0 -1
  277. package/lib/rendezvous/MSC4108SignInWithQR.d.ts +0 -112
  278. package/lib/rendezvous/MSC4108SignInWithQR.d.ts.map +0 -1
  279. package/lib/rendezvous/MSC4108SignInWithQR.js +0 -392
  280. package/lib/rendezvous/MSC4108SignInWithQR.js.map +0 -1
  281. package/lib/rendezvous/RendezvousChannel.d.ts +0 -27
  282. package/lib/rendezvous/RendezvousChannel.d.ts.map +0 -1
  283. package/lib/rendezvous/RendezvousChannel.js +0 -1
  284. package/lib/rendezvous/RendezvousChannel.js.map +0 -1
  285. package/lib/rendezvous/RendezvousCode.d.ts +0 -9
  286. package/lib/rendezvous/RendezvousCode.d.ts.map +0 -1
  287. package/lib/rendezvous/RendezvousCode.js +0 -1
  288. package/lib/rendezvous/RendezvousCode.js.map +0 -1
  289. package/lib/rendezvous/RendezvousError.d.ts +0 -6
  290. package/lib/rendezvous/RendezvousError.d.ts.map +0 -1
  291. package/lib/rendezvous/RendezvousError.js +0 -23
  292. package/lib/rendezvous/RendezvousError.js.map +0 -1
  293. package/lib/rendezvous/RendezvousFailureReason.d.ts +0 -31
  294. package/lib/rendezvous/RendezvousFailureReason.d.ts.map +0 -1
  295. package/lib/rendezvous/RendezvousFailureReason.js +0 -38
  296. package/lib/rendezvous/RendezvousFailureReason.js.map +0 -1
  297. package/lib/rendezvous/RendezvousIntent.d.ts +0 -5
  298. package/lib/rendezvous/RendezvousIntent.d.ts.map +0 -1
  299. package/lib/rendezvous/RendezvousIntent.js +0 -22
  300. package/lib/rendezvous/RendezvousIntent.js.map +0 -1
  301. package/lib/rendezvous/RendezvousTransport.d.ts +0 -36
  302. package/lib/rendezvous/RendezvousTransport.d.ts.map +0 -1
  303. package/lib/rendezvous/RendezvousTransport.js +0 -1
  304. package/lib/rendezvous/RendezvousTransport.js.map +0 -1
  305. package/lib/rendezvous/channels/MSC4108SecureChannel.d.ts +0 -58
  306. package/lib/rendezvous/channels/MSC4108SecureChannel.d.ts.map +0 -1
  307. package/lib/rendezvous/channels/MSC4108SecureChannel.js +0 -246
  308. package/lib/rendezvous/channels/MSC4108SecureChannel.js.map +0 -1
  309. package/lib/rendezvous/channels/index.d.ts +0 -2
  310. package/lib/rendezvous/channels/index.d.ts.map +0 -1
  311. package/lib/rendezvous/channels/index.js +0 -18
  312. package/lib/rendezvous/channels/index.js.map +0 -1
  313. package/lib/rendezvous/index.d.ts +0 -10
  314. package/lib/rendezvous/index.d.ts.map +0 -1
  315. package/lib/rendezvous/index.js +0 -23
  316. package/lib/rendezvous/index.js.map +0 -1
  317. package/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts +0 -61
  318. package/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts.map +0 -1
  319. package/lib/rendezvous/transports/MSC4108RendezvousSession.js +0 -253
  320. package/lib/rendezvous/transports/MSC4108RendezvousSession.js.map +0 -1
  321. package/lib/rendezvous/transports/index.d.ts +0 -2
  322. package/lib/rendezvous/transports/index.d.ts.map +0 -1
  323. package/lib/rendezvous/transports/index.js +0 -18
  324. package/lib/rendezvous/transports/index.js.map +0 -1
  325. package/lib/rust-crypto/CrossSigningIdentity.d.ts +0 -33
  326. package/lib/rust-crypto/CrossSigningIdentity.d.ts.map +0 -1
  327. package/lib/rust-crypto/CrossSigningIdentity.js +0 -157
  328. package/lib/rust-crypto/CrossSigningIdentity.js.map +0 -1
  329. package/lib/rust-crypto/DehydratedDeviceManager.d.ts +0 -98
  330. package/lib/rust-crypto/DehydratedDeviceManager.d.ts.map +0 -1
  331. package/lib/rust-crypto/DehydratedDeviceManager.js +0 -285
  332. package/lib/rust-crypto/DehydratedDeviceManager.js.map +0 -1
  333. package/lib/rust-crypto/KeyClaimManager.d.ts +0 -33
  334. package/lib/rust-crypto/KeyClaimManager.d.ts.map +0 -1
  335. package/lib/rust-crypto/KeyClaimManager.js +0 -82
  336. package/lib/rust-crypto/KeyClaimManager.js.map +0 -1
  337. package/lib/rust-crypto/OutgoingRequestProcessor.d.ts +0 -43
  338. package/lib/rust-crypto/OutgoingRequestProcessor.d.ts.map +0 -1
  339. package/lib/rust-crypto/OutgoingRequestProcessor.js +0 -195
  340. package/lib/rust-crypto/OutgoingRequestProcessor.js.map +0 -1
  341. package/lib/rust-crypto/OutgoingRequestsManager.d.ts +0 -47
  342. package/lib/rust-crypto/OutgoingRequestsManager.d.ts.map +0 -1
  343. package/lib/rust-crypto/OutgoingRequestsManager.js +0 -148
  344. package/lib/rust-crypto/OutgoingRequestsManager.js.map +0 -1
  345. package/lib/rust-crypto/PerSessionKeyBackupDownloader.d.ts +0 -120
  346. package/lib/rust-crypto/PerSessionKeyBackupDownloader.d.ts.map +0 -1
  347. package/lib/rust-crypto/PerSessionKeyBackupDownloader.js +0 -467
  348. package/lib/rust-crypto/PerSessionKeyBackupDownloader.js.map +0 -1
  349. package/lib/rust-crypto/RoomEncryptor.d.ts +0 -98
  350. package/lib/rust-crypto/RoomEncryptor.d.ts.map +0 -1
  351. package/lib/rust-crypto/RoomEncryptor.js +0 -299
  352. package/lib/rust-crypto/RoomEncryptor.js.map +0 -1
  353. package/lib/rust-crypto/backup.d.ts +0 -254
  354. package/lib/rust-crypto/backup.d.ts.map +0 -1
  355. package/lib/rust-crypto/backup.js +0 -837
  356. package/lib/rust-crypto/backup.js.map +0 -1
  357. package/lib/rust-crypto/constants.d.ts +0 -3
  358. package/lib/rust-crypto/constants.d.ts.map +0 -1
  359. package/lib/rust-crypto/constants.js +0 -19
  360. package/lib/rust-crypto/constants.js.map +0 -1
  361. package/lib/rust-crypto/device-converter.d.ts +0 -28
  362. package/lib/rust-crypto/device-converter.d.ts.map +0 -1
  363. package/lib/rust-crypto/device-converter.js +0 -123
  364. package/lib/rust-crypto/device-converter.js.map +0 -1
  365. package/lib/rust-crypto/index.d.ts +0 -61
  366. package/lib/rust-crypto/index.d.ts.map +0 -1
  367. package/lib/rust-crypto/index.js +0 -152
  368. package/lib/rust-crypto/index.js.map +0 -1
  369. package/lib/rust-crypto/libolm_migration.d.ts +0 -81
  370. package/lib/rust-crypto/libolm_migration.d.ts.map +0 -1
  371. package/lib/rust-crypto/libolm_migration.js +0 -459
  372. package/lib/rust-crypto/libolm_migration.js.map +0 -1
  373. package/lib/rust-crypto/rust-crypto.d.ts +0 -556
  374. package/lib/rust-crypto/rust-crypto.d.ts.map +0 -1
  375. package/lib/rust-crypto/rust-crypto.js +0 -2016
  376. package/lib/rust-crypto/rust-crypto.js.map +0 -1
  377. package/lib/rust-crypto/secret-storage.d.ts +0 -22
  378. package/lib/rust-crypto/secret-storage.d.ts.map +0 -1
  379. package/lib/rust-crypto/secret-storage.js +0 -63
  380. package/lib/rust-crypto/secret-storage.js.map +0 -1
  381. package/lib/rust-crypto/verification.d.ts +0 -319
  382. package/lib/rust-crypto/verification.d.ts.map +0 -1
  383. package/lib/rust-crypto/verification.js +0 -816
  384. package/lib/rust-crypto/verification.js.map +0 -1
  385. package/lib/secret-storage.d.ts +0 -370
  386. package/lib/secret-storage.d.ts.map +0 -1
  387. package/lib/secret-storage.js +0 -466
  388. package/lib/secret-storage.js.map +0 -1
  389. package/src/@types/crypto.ts +0 -73
  390. package/src/@types/matrix-sdk-crypto-wasm.d.ts +0 -44
  391. package/src/common-crypto/CryptoBackend.ts +0 -302
  392. package/src/common-crypto/README.md +0 -4
  393. package/src/common-crypto/key-passphrase.ts +0 -43
  394. package/src/crypto/CrossSigning.ts +0 -773
  395. package/src/crypto/DeviceList.ts +0 -989
  396. package/src/crypto/EncryptionSetup.ts +0 -351
  397. package/src/crypto/OlmDevice.ts +0 -1500
  398. package/src/crypto/OutgoingRoomKeyRequestManager.ts +0 -485
  399. package/src/crypto/RoomList.ts +0 -70
  400. package/src/crypto/SecretSharing.ts +0 -240
  401. package/src/crypto/SecretStorage.ts +0 -136
  402. package/src/crypto/aes.ts +0 -23
  403. package/src/crypto/algorithms/base.ts +0 -236
  404. package/src/crypto/algorithms/index.ts +0 -20
  405. package/src/crypto/algorithms/megolm.ts +0 -2216
  406. package/src/crypto/algorithms/olm.ts +0 -381
  407. package/src/crypto/api.ts +0 -70
  408. package/src/crypto/backup.ts +0 -922
  409. package/src/crypto/crypto.ts +0 -18
  410. package/src/crypto/dehydration.ts +0 -272
  411. package/src/crypto/device-converter.ts +0 -45
  412. package/src/crypto/deviceinfo.ts +0 -158
  413. package/src/crypto/index.ts +0 -4414
  414. package/src/crypto/key_passphrase.ts +0 -42
  415. package/src/crypto/keybackup.ts +0 -47
  416. package/src/crypto/olmlib.ts +0 -539
  417. package/src/crypto/recoverykey.ts +0 -18
  418. package/src/crypto/store/base.ts +0 -348
  419. package/src/crypto/store/indexeddb-crypto-store-backend.ts +0 -1250
  420. package/src/crypto/store/indexeddb-crypto-store.ts +0 -845
  421. package/src/crypto/store/localStorage-crypto-store.ts +0 -579
  422. package/src/crypto/store/memory-crypto-store.ts +0 -680
  423. package/src/crypto/verification/Base.ts +0 -409
  424. package/src/crypto/verification/Error.ts +0 -76
  425. package/src/crypto/verification/IllegalMethod.ts +0 -50
  426. package/src/crypto/verification/QRCode.ts +0 -310
  427. package/src/crypto/verification/SAS.ts +0 -494
  428. package/src/crypto/verification/SASDecimal.ts +0 -37
  429. package/src/crypto/verification/request/Channel.ts +0 -34
  430. package/src/crypto/verification/request/InRoomChannel.ts +0 -371
  431. package/src/crypto/verification/request/ToDeviceChannel.ts +0 -354
  432. package/src/crypto/verification/request/VerificationRequest.ts +0 -976
  433. package/src/crypto-api/CryptoEvent.ts +0 -93
  434. package/src/crypto-api/CryptoEventHandlerMap.ts +0 -32
  435. package/src/crypto-api/index.ts +0 -1175
  436. package/src/crypto-api/key-passphrase.ts +0 -58
  437. package/src/crypto-api/keybackup.ts +0 -115
  438. package/src/crypto-api/recovery-key.ts +0 -69
  439. package/src/crypto-api/verification.ts +0 -408
  440. package/src/rendezvous/MSC4108SignInWithQR.ts +0 -444
  441. package/src/rendezvous/RendezvousChannel.ts +0 -48
  442. package/src/rendezvous/RendezvousCode.ts +0 -25
  443. package/src/rendezvous/RendezvousError.ts +0 -26
  444. package/src/rendezvous/RendezvousFailureReason.ts +0 -49
  445. package/src/rendezvous/RendezvousIntent.ts +0 -20
  446. package/src/rendezvous/RendezvousTransport.ts +0 -58
  447. package/src/rendezvous/channels/MSC4108SecureChannel.ts +0 -270
  448. package/src/rendezvous/channels/index.ts +0 -17
  449. package/src/rendezvous/index.ts +0 -25
  450. package/src/rendezvous/transports/MSC4108RendezvousSession.ts +0 -270
  451. package/src/rendezvous/transports/index.ts +0 -17
  452. package/src/rust-crypto/CrossSigningIdentity.ts +0 -183
  453. package/src/rust-crypto/DehydratedDeviceManager.ts +0 -306
  454. package/src/rust-crypto/KeyClaimManager.ts +0 -86
  455. package/src/rust-crypto/OutgoingRequestProcessor.ts +0 -236
  456. package/src/rust-crypto/OutgoingRequestsManager.ts +0 -143
  457. package/src/rust-crypto/PerSessionKeyBackupDownloader.ts +0 -501
  458. package/src/rust-crypto/RoomEncryptor.ts +0 -352
  459. package/src/rust-crypto/backup.ts +0 -881
  460. package/src/rust-crypto/constants.ts +0 -18
  461. package/src/rust-crypto/device-converter.ts +0 -128
  462. package/src/rust-crypto/index.ts +0 -237
  463. package/src/rust-crypto/libolm_migration.ts +0 -530
  464. package/src/rust-crypto/rust-crypto.ts +0 -2205
  465. package/src/rust-crypto/secret-storage.ts +0 -60
  466. package/src/rust-crypto/verification.ts +0 -830
  467. package/src/secret-storage.ts +0 -693
package/lib/client.js CHANGED
@@ -29,30 +29,24 @@ import { EventStatus, MatrixEvent, MatrixEventEvent } from "./models/event.js";
29
29
  import { StubStore } from "./store/stub.js";
30
30
  import { Filter } from "./filter.js";
31
31
  import * as utils from "./utils.js";
32
- import { noUnsafeEventProps, replaceParam, safeSet, sleep } from "./utils.js";
32
+ import { noUnsafeEventProps, replaceParam, sleep } from "./utils.js";
33
33
  import { Direction, EventTimeline } from "./models/event-timeline.js";
34
34
  import { PushProcessor } from "./pushprocessor.js";
35
35
  import { AutoDiscovery } from "./autodiscovery.js";
36
- import * as olmlib from "./crypto/olmlib.js";
37
- import { decodeBase64, encodeBase64, encodeUnpaddedBase64Url } from "./base64.js";
36
+ import { encodeUnpaddedBase64Url } from "./base64.js";
38
37
  import { TypedReEmitter } from "./ReEmitter.js";
39
38
  import { logger } from "./logger.js";
40
39
  import { SERVICE_TYPES } from "./service-types.js";
41
40
  import { ClientPrefix, IdentityPrefix, MatrixError, MatrixHttpApi, MediaPrefix, Method, retryNetworkOperation } from "./http-api/index.js";
42
- import { Crypto, CryptoEvent as LegacyCryptoEvent, fixBackupKey } from "./crypto/index.js";
43
41
  import { User, UserEvent } from "./models/user.js";
44
42
  import { getHttpUriForMxc } from "./content-repo.js";
45
43
  import { SearchResult } from "./models/search-result.js";
46
- import { DEHYDRATION_ALGORITHM } from "./crypto/dehydration.js";
47
- import { CrossSigningKey } from "./crypto/api.js";
48
44
  import * as ContentHelpers from "./content-helpers.js";
49
45
  import { NotificationCountType } from "./models/room.js";
50
- import { RoomMemberEvent } from "./models/room-member.js";
51
46
  import { EventType, LOCAL_NOTIFICATION_SETTINGS_PREFIX, MSC3912_RELATION_BASED_REDACTIONS_PROP, MsgType, PUSHER_ENABLED, RelationType, RoomCreateTypeField, RoomType, UNSTABLE_MSC3088_ENABLED, UNSTABLE_MSC3088_PURPOSE, UNSTABLE_MSC3089_TREE_SUBTYPE } from "./@types/event.js";
52
47
  import { GuestAccess, HistoryVisibility, Preset } from "./@types/partials.js";
53
48
  import { eventMapperFor } from "./event-mapper.js";
54
49
  import { randomString } from "./randomstring.js";
55
- import { BackupManager } from "./crypto/backup.js";
56
50
  import { DEFAULT_TREE_POWER_LEVELS_TEMPLATE, MSC3089TreeSpace } from "./models/MSC3089TreeSpace.js";
57
51
  import { SearchOrderBy } from "./@types/search.js";
58
52
  import { PushRuleActionName, PushRuleKind } from "./@types/PushRules.js";
@@ -65,17 +59,11 @@ import { NamespacedValue, UnstableValue } from "./NamespacedValue.js";
65
59
  import { ToDeviceMessageQueue } from "./ToDeviceMessageQueue.js";
66
60
  import { IgnoredInvites } from "./models/invites-ignorer.js";
67
61
  import { buildFeatureSupportMap, Feature, ServerSupport } from "./feature.js";
68
- import { RUST_SDK_STORE_PREFIX } from "./rust-crypto/constants.js";
69
- import { decodeRecoveryKey, CryptoEvent } from "./crypto-api/index.js";
70
- import { ServerSideSecretStorageImpl } from "./secret-storage.js";
71
62
  import { getRelationsThreadFilter } from "./thread-utils.js";
72
63
  import { KnownMembership } from "./@types/membership.js";
73
64
  import { ServerCapabilities } from "./serverCapabilities.js";
74
65
  import { sha256 } from "./digest.js";
75
- import { keyFromAuthData } from "./common-crypto/key-passphrase.js";
76
66
  var SCROLLBACK_DELAY_MS = 3000;
77
- var TURN_CHECK_INTERVAL = 10 * 60 * 1000; // poll for turn credentials every 10 minutes
78
-
79
67
  export var UNSTABLE_MSC3852_LAST_SEEN_UA = new UnstableValue("last_seen_user_agent", "org.matrix.msc3852.last_seen_user_agent");
80
68
  export var PendingEventOrdering = /*#__PURE__*/function (PendingEventOrdering) {
81
69
  PendingEventOrdering["Chronological"] = "chronological";
@@ -88,16 +76,14 @@ export var UNSTABLE_MSC2666_MUTUAL_ROOMS = "uk.half-shot.msc2666.mutual_rooms";
88
76
  export var UNSTABLE_MSC2666_QUERY_MUTUAL_ROOMS = "uk.half-shot.msc2666.query_mutual_rooms";
89
77
  export var UNSTABLE_MSC4140_DELAYED_EVENTS = "org.matrix.msc4140";
90
78
  export var UNSTABLE_MSC4133_EXTENDED_PROFILES = "uk.tcpip.msc4133";
91
- var CrossSigningKeyType = /*#__PURE__*/function (CrossSigningKeyType) {
92
- CrossSigningKeyType["MasterKey"] = "master_key";
93
- CrossSigningKeyType["SelfSigningKey"] = "self_signing_key";
94
- CrossSigningKeyType["UserSigningKey"] = "user_signing_key";
95
- return CrossSigningKeyType;
96
- }(CrossSigningKeyType || {}); // Re-export for backwards compatibility
79
+
80
+ // Re-export for backwards compatibility
81
+
97
82
  /**
98
83
  * The summary of a room as defined by an initial version of MSC3266 and implemented in Synapse
99
84
  * Proposed at https://github.com/matrix-org/matrix-doc/pull/3266
100
85
  */
86
+
101
87
  /* eslint-enable camelcase */
102
88
 
103
89
  // We're using this constant for methods overloading and inspect whether a variable
@@ -129,7 +115,7 @@ var SSO_ACTION_PARAM = new UnstableValue("action", "org.matrix.msc3824.action");
129
115
  */
130
116
  export class MatrixClient extends TypedEventEmitter {
131
117
  constructor(opts) {
132
- var _opts$logger, _opts$usingExternalCr, _this, _opts$cryptoCallbacks;
118
+ var _opts$logger, _opts$usingExternalCr, _this;
133
119
  // If a custom logger is provided, use it. Otherwise, default to the global
134
120
  // one in logger.ts.
135
121
  super();
@@ -159,18 +145,6 @@ export class MatrixClient extends TypedEventEmitter {
159
145
  _defineProperty(this, "identityServer", void 0);
160
146
  _defineProperty(this, "http", void 0);
161
147
  // XXX: Intended private, used in code.
162
- /**
163
- * The libolm crypto implementation, if it is in use.
164
- *
165
- * @deprecated This should not be used. Instead, use the methods exposed directly on this class or
166
- * (where they are available) via {@link getCrypto}.
167
- */
168
- _defineProperty(this, "crypto", void 0);
169
- // XXX: Intended private, used in code. Being replaced by cryptoBackend
170
- _defineProperty(this, "cryptoBackend", void 0);
171
- // one of crypto or rustCrypto
172
- _defineProperty(this, "cryptoCallbacks", void 0);
173
- // XXX: Intended private, used in code.
174
148
  _defineProperty(this, "supportsCallTransfer", false);
175
149
  // XXX: Intended private, used in code.
176
150
  _defineProperty(this, "forceTURN", false);
@@ -183,13 +157,11 @@ export class MatrixClient extends TypedEventEmitter {
183
157
  _defineProperty(this, "useLivekitForGroupCalls", void 0);
184
158
  // Note: these are all `protected` to let downstream consumers make mistakes if they want to.
185
159
  // We don't technically support this usage, but have reasons to do this.
186
- _defineProperty(this, "canSupportVoip", false);
187
160
  _defineProperty(this, "peekSync", null);
188
161
  _defineProperty(this, "isGuestAccount", false);
189
162
  _defineProperty(this, "ongoingScrollbacks", {});
190
163
  _defineProperty(this, "notifTimelineSet", null);
191
164
  /* @deprecated */
192
- _defineProperty(this, "cryptoStore", void 0);
193
165
  _defineProperty(this, "verificationMethods", void 0);
194
166
  _defineProperty(this, "fallbackICEServerAllowed", false);
195
167
  _defineProperty(this, "syncApi", void 0);
@@ -208,10 +180,6 @@ export class MatrixClient extends TypedEventEmitter {
208
180
  _defineProperty(this, "serverVersionsPromise", void 0);
209
181
  _defineProperty(this, "clientWellKnown", void 0);
210
182
  _defineProperty(this, "clientWellKnownPromise", void 0);
211
- _defineProperty(this, "turnServers", []);
212
- _defineProperty(this, "turnServersExpiry", 0);
213
- _defineProperty(this, "checkTurnServersIntervalID", void 0);
214
- _defineProperty(this, "exportedOlmDeviceToImport", void 0);
215
183
  _defineProperty(this, "txnCtr", 0);
216
184
  _defineProperty(this, "sessionId", void 0);
217
185
  /** IDs of events which are currently being encrypted.
@@ -223,7 +191,6 @@ export class MatrixClient extends TypedEventEmitter {
223
191
  _defineProperty(this, "useE2eForGroupCall", true);
224
192
  _defineProperty(this, "toDeviceMessageQueue", void 0);
225
193
  _defineProperty(this, "livekitServiceURL", void 0);
226
- _defineProperty(this, "_secretStorage", void 0);
227
194
  // A manager for determining which invites should be ignored.
228
195
  _defineProperty(this, "ignoredInvites", void 0);
229
196
  _defineProperty(this, "serverCapabilitiesService", void 0);
@@ -288,8 +255,6 @@ export class MatrixClient extends TypedEventEmitter {
288
255
  } else {
289
256
  this.deviceId = opts.deviceToImport.deviceId;
290
257
  this.credentials.userId = opts.deviceToImport.userId;
291
- // will be used during async initialization of the crypto
292
- this.exportedOlmDeviceToImport = opts.deviceToImport.olmDevice;
293
258
  }
294
259
  } else if (opts.pickleKey) {
295
260
  this.pickleKey = opts.pickleKey;
@@ -319,9 +284,7 @@ export class MatrixClient extends TypedEventEmitter {
319
284
  this.serverCapabilitiesService = new ServerCapabilities(this.http);
320
285
  this.on(ClientEvent.Sync, this.fixupRoomNotifications);
321
286
  this.timelineSupport = Boolean(opts.timelineSupport);
322
- this.cryptoStore = opts.cryptoStore;
323
287
  this.verificationMethods = opts.verificationMethods;
324
- this.cryptoCallbacks = opts.cryptoCallbacks || {};
325
288
  this.forceTURN = opts.forceTURN || false;
326
289
  this.iceCandidatePoolSize = opts.iceCandidatePoolSize === undefined ? 0 : opts.iceCandidatePoolSize;
327
290
  this.supportsCallTransfer = opts.supportsCallTransfer || false;
@@ -340,7 +303,6 @@ export class MatrixClient extends TypedEventEmitter {
340
303
  fixNotificationCountOnDecryption(this, event);
341
304
  });
342
305
  this.ignoredInvites = new IgnoredInvites(this);
343
- this._secretStorage = new ServerSideSecretStorageImpl(this, (_opts$cryptoCallbacks = opts.cryptoCallbacks) !== null && _opts$cryptoCallbacks !== void 0 ? _opts$cryptoCallbacks : {});
344
306
 
345
307
  // having lots of event listeners is not unusual. 0 means "unlimited".
346
308
  this.setMaxListeners(0);
@@ -375,15 +337,6 @@ export class MatrixClient extends TypedEventEmitter {
375
337
  if (userId) {
376
338
  _this2.store.storeUser(new User(userId));
377
339
  }
378
-
379
- // periodically poll for turn servers if we support voip
380
- if (_this2.canSupportVoip) {
381
- _this2.checkTurnServersIntervalID = setInterval(() => {
382
- _this2.checkTurnServers();
383
- }, TURN_CHECK_INTERVAL);
384
- // noinspection ES6MissingAwait
385
- _this2.checkTurnServers();
386
- }
387
340
  if (_this2.syncApi) {
388
341
  // This shouldn't happen since we thought the client was not running
389
342
  _this2.logger.error("Still have sync object whilst not running: stopping old one");
@@ -407,7 +360,7 @@ export class MatrixClient extends TypedEventEmitter {
407
360
  }
408
361
  _this2.clientOpts = opts !== null && opts !== void 0 ? opts : {};
409
362
  if (_this2.clientOpts.slidingSync) {
410
- _this2.syncApi = new SlidingSyncSdk(_this2.clientOpts.slidingSync, _this2, _this2.clientOpts, _this2.buildSyncApiOptions());
363
+ _this2.syncApi = new SlidingSyncSdk(_this2.clientOpts.slidingSync, _this2, _this2.clientOpts);
411
364
  } else {
412
365
  _this2.syncApi = new SyncApi(_this2, _this2.clientOpts, _this2.buildSyncApiOptions());
413
366
  }
@@ -428,8 +381,6 @@ export class MatrixClient extends TypedEventEmitter {
428
381
  */
429
382
  buildSyncApiOptions() {
430
383
  return {
431
- crypto: this.crypto,
432
- cryptoCallbacks: this.cryptoBackend,
433
384
  canResetEntireTimeline: roomId => {
434
385
  if (!this.canResetTimelineCallback) {
435
386
  return false;
@@ -444,9 +395,7 @@ export class MatrixClient extends TypedEventEmitter {
444
395
  * clean shutdown.
445
396
  */
446
397
  stopClient() {
447
- var _this$cryptoBackend, _this$syncApi, _this$peekSync;
448
- (_this$cryptoBackend = this.cryptoBackend) === null || _this$cryptoBackend === void 0 || _this$cryptoBackend.stop(); // crypto might have been initialised even if the client wasn't fully started
449
-
398
+ var _this$syncApi, _this$peekSync;
450
399
  if (!this.clientRunning) return; // already stopped
451
400
 
452
401
  this.logger.debug("stopping MatrixClient");
@@ -454,8 +403,6 @@ export class MatrixClient extends TypedEventEmitter {
454
403
  (_this$syncApi = this.syncApi) === null || _this$syncApi === void 0 || _this$syncApi.stop();
455
404
  this.syncApi = undefined;
456
405
  (_this$peekSync = this.peekSync) === null || _this$peekSync === void 0 || _this$peekSync.stopPeeking();
457
- globalThis.clearInterval(this.checkTurnServersIntervalID);
458
- this.checkTurnServersIntervalID = undefined;
459
406
  if (this.clientWellKnownIntervalID !== undefined) {
460
407
  globalThis.clearInterval(this.clientWellKnownIntervalID);
461
408
  }
@@ -463,219 +410,17 @@ export class MatrixClient extends TypedEventEmitter {
463
410
  this.serverCapabilitiesService.stop();
464
411
  }
465
412
 
466
- /**
467
- * Try to rehydrate a device if available. The client must have been
468
- * initialized with a `cryptoCallback.getDehydrationKey` option, and this
469
- * function must be called before initCrypto and startClient are called.
470
- *
471
- * @returns Promise which resolves to undefined if a device could not be dehydrated, or
472
- * to the new device ID if the dehydration was successful.
473
- * @returns Rejects: with an error response.
474
- *
475
- * @deprecated MSC2697 device dehydration is not supported for rust cryptography.
476
- */
477
- rehydrateDevice() {
478
- var _this3 = this;
479
- return _asyncToGenerator(function* () {
480
- if (_this3.crypto) {
481
- throw new Error("Cannot rehydrate device after crypto is initialized");
482
- }
483
- if (!_this3.cryptoCallbacks.getDehydrationKey) {
484
- return;
485
- }
486
- var getDeviceResult = yield _this3.getDehydratedDevice();
487
- if (!getDeviceResult) {
488
- return;
489
- }
490
- if (!getDeviceResult.device_data || !getDeviceResult.device_id) {
491
- _this3.logger.info("no dehydrated device found");
492
- return;
493
- }
494
- var account = new globalThis.Olm.Account();
495
- try {
496
- var deviceData = getDeviceResult.device_data;
497
- if (deviceData.algorithm !== DEHYDRATION_ALGORITHM) {
498
- _this3.logger.warn("Wrong algorithm for dehydrated device");
499
- return;
500
- }
501
- _this3.logger.debug("unpickling dehydrated device");
502
- var _key = yield _this3.cryptoCallbacks.getDehydrationKey(deviceData, k => {
503
- // copy the key so that it doesn't get clobbered
504
- account.unpickle(new Uint8Array(k), deviceData.account);
505
- });
506
- account.unpickle(_key, deviceData.account);
507
- _this3.logger.debug("unpickled device");
508
- var rehydrateResult = yield _this3.http.authedRequest(Method.Post, "/dehydrated_device/claim", undefined, {
509
- device_id: getDeviceResult.device_id
510
- }, {
511
- prefix: "/_matrix/client/unstable/org.matrix.msc2697.v2"
512
- });
513
- if (rehydrateResult.success) {
514
- _this3.deviceId = getDeviceResult.device_id;
515
- _this3.logger.info("using dehydrated device");
516
- var pickleKey = _this3.pickleKey || "DEFAULT_KEY";
517
- _this3.exportedOlmDeviceToImport = {
518
- pickledAccount: account.pickle(pickleKey),
519
- sessions: [],
520
- pickleKey: pickleKey
521
- };
522
- account.free();
523
- return _this3.deviceId;
524
- } else {
525
- account.free();
526
- _this3.logger.info("not using dehydrated device");
527
- return;
528
- }
529
- } catch (e) {
530
- account.free();
531
- _this3.logger.warn("could not unpickle", e);
532
- }
533
- })();
534
- }
535
-
536
- /**
537
- * Get the current dehydrated device, if any
538
- * @returns A promise of an object containing the dehydrated device
539
- *
540
- * @deprecated MSC2697 device dehydration is not supported for rust cryptography.
541
- */
542
- getDehydratedDevice() {
543
- var _this4 = this;
544
- return _asyncToGenerator(function* () {
545
- try {
546
- return yield _this4.http.authedRequest(Method.Get, "/dehydrated_device", undefined, undefined, {
547
- prefix: "/_matrix/client/unstable/org.matrix.msc2697.v2"
548
- });
549
- } catch (e) {
550
- _this4.logger.info("could not get dehydrated device", e);
551
- return;
552
- }
553
- })();
554
- }
555
-
556
- /**
557
- * Set the dehydration key. This will also periodically dehydrate devices to
558
- * the server.
559
- *
560
- * @param key - the dehydration key
561
- * @param keyInfo - Information about the key. Primarily for
562
- * information about how to generate the key from a passphrase.
563
- * @param deviceDisplayName - The device display name for the
564
- * dehydrated device.
565
- * @returns A promise that resolves when the dehydrated device is stored.
566
- *
567
- * @deprecated Not supported for Rust Cryptography.
568
- */
569
- setDehydrationKey(key, keyInfo, deviceDisplayName) {
570
- var _this5 = this;
571
- return _asyncToGenerator(function* () {
572
- if (!_this5.crypto) {
573
- _this5.logger.warn("not dehydrating device if crypto is not enabled");
574
- return;
575
- }
576
- return _this5.crypto.dehydrationManager.setKeyAndQueueDehydration(key, keyInfo, deviceDisplayName);
577
- })();
578
- }
579
-
580
- /**
581
- * Creates a new MSC2967 dehydrated device (without queuing periodic dehydration)
582
- * @param key - the dehydration key
583
- * @param keyInfo - Information about the key. Primarily for
584
- * information about how to generate the key from a passphrase.
585
- * @param deviceDisplayName - The device display name for the
586
- * dehydrated device.
587
- * @returns the device id of the newly created dehydrated device
588
- *
589
- * @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi.startDehydration}.
590
- */
591
- createDehydratedDevice(key, keyInfo, deviceDisplayName) {
592
- var _this6 = this;
593
- return _asyncToGenerator(function* () {
594
- if (!_this6.crypto) {
595
- _this6.logger.warn("not dehydrating device if crypto is not enabled");
596
- return;
597
- }
598
- yield _this6.crypto.dehydrationManager.setKey(key, keyInfo, deviceDisplayName);
599
- return _this6.crypto.dehydrationManager.dehydrateDevice();
600
- })();
601
- }
602
-
603
- /** @deprecated Not supported for Rust Cryptography. */
604
- exportDevice() {
605
- var _this7 = this;
606
- return _asyncToGenerator(function* () {
607
- if (!_this7.crypto) {
608
- _this7.logger.warn("not exporting device if crypto is not enabled");
609
- return;
610
- }
611
- return {
612
- userId: _this7.credentials.userId,
613
- deviceId: _this7.deviceId,
614
- // XXX: Private member access.
615
- olmDevice: yield _this7.crypto.olmDevice.export()
616
- };
617
- })();
618
- }
619
-
620
413
  /**
621
414
  * Clear any data out of the persistent stores used by the client.
622
415
  *
623
416
  * @returns Promise which resolves when the stores have been cleared.
624
417
  */
625
418
  clearStores() {
626
- var _this8 = this;
627
419
  if (this.clientRunning) {
628
420
  throw new Error("Cannot clear stores while client is running");
629
421
  }
630
422
  var promises = [];
631
423
  promises.push(this.store.deleteAllData());
632
- if (this.cryptoStore) {
633
- promises.push(this.cryptoStore.deleteAllData());
634
- }
635
-
636
- // delete the stores used by the rust matrix-sdk-crypto, in case they were used
637
- var deleteRustSdkStore = /*#__PURE__*/function () {
638
- var _ref2 = _asyncToGenerator(function* () {
639
- var indexedDB;
640
- try {
641
- indexedDB = globalThis.indexedDB;
642
- if (!indexedDB) return; // No indexedDB support
643
- } catch (_unused) {
644
- // No indexedDB support
645
- return;
646
- }
647
- var _loop = function* _loop(dbname) {
648
- var prom = new Promise((resolve, reject) => {
649
- _this8.logger.info("Removing IndexedDB instance ".concat(dbname));
650
- var req = indexedDB.deleteDatabase(dbname);
651
- req.onsuccess = _ => {
652
- _this8.logger.info("Removed IndexedDB instance ".concat(dbname));
653
- resolve(0);
654
- };
655
- req.onerror = e => {
656
- // In private browsing, Firefox has a globalThis.indexedDB, but attempts to delete an indexeddb
657
- // (even a non-existent one) fail with "DOMException: A mutation operation was attempted on a
658
- // database that did not allow mutations."
659
- //
660
- // it seems like the only thing we can really do is ignore the error.
661
- _this8.logger.warn("Failed to remove IndexedDB instance ".concat(dbname, ":"), e);
662
- resolve(0);
663
- };
664
- req.onblocked = e => {
665
- _this8.logger.info("cannot yet remove IndexedDB instance ".concat(dbname));
666
- };
667
- });
668
- yield prom;
669
- };
670
- for (var dbname of ["".concat(RUST_SDK_STORE_PREFIX, "::matrix-sdk-crypto"), "".concat(RUST_SDK_STORE_PREFIX, "::matrix-sdk-crypto-meta")]) {
671
- yield* _loop(dbname);
672
- }
673
- });
674
- return function deleteRustSdkStore() {
675
- return _ref2.apply(this, arguments);
676
- };
677
- }();
678
- promises.push(deleteRustSdkStore());
679
424
  return Promise.all(promises).then(); // .then to fix types
680
425
  }
681
426
 
@@ -743,14 +488,6 @@ export class MatrixClient extends TypedEventEmitter {
743
488
  return this.sessionId;
744
489
  }
745
490
 
746
- /**
747
- * Check if the runtime environment supports VoIP calling.
748
- * @returns True if VoIP is supported.
749
- */
750
- supportsVoip() {
751
- return this.canSupportVoip;
752
- }
753
-
754
491
  /**
755
492
  * Set whether VoIP calls are forced to use only TURN
756
493
  * candidates. This is the same as the forceTURN option
@@ -866,1895 +603,64 @@ export class MatrixClient extends TypedEventEmitter {
866
603
  }
867
604
 
868
605
  /**
869
- * Return the global notification EventTimelineSet, if any
870
- *
871
- * @returns the globl notification EventTimelineSet
872
- */
873
- getNotifTimelineSet() {
874
- return this.notifTimelineSet;
875
- }
876
-
877
- /**
878
- * Set the global notification EventTimelineSet
879
- *
880
- */
881
- setNotifTimelineSet(set) {
882
- this.notifTimelineSet = set;
883
- }
884
-
885
- /**
886
- * Gets the cached capabilities of the homeserver, returning cached ones if available.
887
- * If there are no cached capabilities and none can be fetched, throw an exception.
888
- *
889
- * @returns Promise resolving with The capabilities of the homeserver
890
- */
891
- getCapabilities() {
892
- var _this9 = this;
893
- return _asyncToGenerator(function* () {
894
- var caps = _this9.serverCapabilitiesService.getCachedCapabilities();
895
- if (caps) return caps;
896
- return _this9.serverCapabilitiesService.fetchCapabilities();
897
- })();
898
- }
899
-
900
- /**
901
- * Gets the cached capabilities of the homeserver. If none have been fetched yet,
902
- * return undefined.
903
- *
904
- * @returns The capabilities of the homeserver
905
- */
906
- getCachedCapabilities() {
907
- return this.serverCapabilitiesService.getCachedCapabilities();
908
- }
909
-
910
- /**
911
- * Fetches the latest capabilities from the homeserver, ignoring any cached
912
- * versions. The newly returned version is cached.
913
- *
914
- * @returns A promise which resolves to the capabilities of the homeserver
915
- */
916
- fetchCapabilities() {
917
- return this.serverCapabilitiesService.fetchCapabilities();
918
- }
919
-
920
- /**
921
- * Initialise support for end-to-end encryption in this client, using libolm.
922
- *
923
- * You should call this method after creating the matrixclient, but *before*
924
- * calling `startClient`, if you want to support end-to-end encryption.
925
- *
926
- * It will return a Promise which will resolve when the crypto layer has been
927
- * successfully initialised.
928
- *
929
- * @deprecated libolm is deprecated. Prefer {@link initRustCrypto}.
930
- */
931
- initCrypto() {
932
- var _this10 = this;
933
- return _asyncToGenerator(function* () {
934
- if (_this10.cryptoBackend) {
935
- _this10.logger.warn("Attempt to re-initialise e2e encryption on MatrixClient");
936
- return;
937
- }
938
- if (!_this10.cryptoStore) {
939
- // the cryptostore is provided by sdk.createClient, so this shouldn't happen
940
- throw new Error("Cannot enable encryption: no cryptoStore provided");
941
- }
942
- _this10.logger.debug("Crypto: Starting up crypto store...");
943
- yield _this10.cryptoStore.startup();
944
- var userId = _this10.getUserId();
945
- if (userId === null) {
946
- throw new Error("Cannot enable encryption on MatrixClient with unknown userId: " + "ensure userId is passed in createClient().");
947
- }
948
- if (_this10.deviceId === null) {
949
- throw new Error("Cannot enable encryption on MatrixClient with unknown deviceId: " + "ensure deviceId is passed in createClient().");
950
- }
951
- var crypto = new Crypto(_this10, userId, _this10.deviceId, _this10.store, _this10.cryptoStore, _this10.verificationMethods);
952
- _this10.reEmitter.reEmit(crypto, [LegacyCryptoEvent.KeyBackupFailed, LegacyCryptoEvent.KeyBackupSessionsRemaining, LegacyCryptoEvent.RoomKeyRequest, LegacyCryptoEvent.RoomKeyRequestCancellation, LegacyCryptoEvent.Warning, LegacyCryptoEvent.DevicesUpdated, LegacyCryptoEvent.WillUpdateDevices, LegacyCryptoEvent.DeviceVerificationChanged, LegacyCryptoEvent.UserTrustStatusChanged, LegacyCryptoEvent.KeysChanged]);
953
- _this10.logger.debug("Crypto: initialising crypto object...");
954
- yield crypto.init({
955
- exportedOlmDevice: _this10.exportedOlmDeviceToImport,
956
- pickleKey: _this10.pickleKey
957
- });
958
- delete _this10.exportedOlmDeviceToImport;
959
- _this10.olmVersion = Crypto.getOlmVersion();
960
-
961
- // if crypto initialisation was successful, tell it to attach its event handlers.
962
- crypto.registerEventHandlers(_this10);
963
- _this10.cryptoBackend = _this10.crypto = crypto;
964
-
965
- // upload our keys in the background
966
- _this10.crypto.uploadDeviceKeys().catch(e => {
967
- // TODO: throwing away this error is a really bad idea.
968
- _this10.logger.error("Error uploading device keys", e);
969
- });
970
- })();
971
- }
972
-
973
- /**
974
- * Initialise support for end-to-end encryption in this client, using the rust matrix-sdk-crypto.
975
- *
976
- * An alternative to {@link initCrypto}.
977
- *
978
- * @param args.useIndexedDB - True to use an indexeddb store, false to use an in-memory store. Defaults to 'true'.
979
- * @param args.storageKey - A key with which to encrypt the indexeddb store. If provided, it must be exactly
980
- * 32 bytes of data, and must be the same each time the client is initialised for a given device.
981
- * If both this and `storagePassword` are unspecified, the store will be unencrypted.
982
- * @param args.storagePassword - An alternative to `storageKey`. A password which will be used to derive a key to
983
- * encrypt the store with. Deriving a key from a password is (deliberately) a slow operation, so prefer
984
- * to pass a `storageKey` directly where possible.
985
- *
986
- * @returns a Promise which will resolve when the crypto layer has been
987
- * successfully initialised.
988
- */
989
- initRustCrypto() {
990
- var _arguments = arguments,
991
- _this11 = this;
992
- return _asyncToGenerator(function* () {
993
- var _this11$pickleKey;
994
- var args = _arguments.length > 0 && _arguments[0] !== undefined ? _arguments[0] : {};
995
- if (_this11.cryptoBackend) {
996
- _this11.logger.warn("Attempt to re-initialise e2e encryption on MatrixClient");
997
- return;
998
- }
999
- var userId = _this11.getUserId();
1000
- if (userId === null) {
1001
- throw new Error("Cannot enable encryption on MatrixClient with unknown userId: " + "ensure userId is passed in createClient().");
1002
- }
1003
- var deviceId = _this11.getDeviceId();
1004
- if (deviceId === null) {
1005
- throw new Error("Cannot enable encryption on MatrixClient with unknown deviceId: " + "ensure deviceId is passed in createClient().");
1006
- }
1007
-
1008
- // importing rust-crypto will download the webassembly, so we delay it until we know it will be
1009
- // needed.
1010
- _this11.logger.debug("Downloading Rust crypto library");
1011
- var RustCrypto = yield import("./rust-crypto/index.js");
1012
- var rustCrypto = yield RustCrypto.initRustCrypto({
1013
- logger: _this11.logger,
1014
- http: _this11.http,
1015
- userId: userId,
1016
- deviceId: deviceId,
1017
- secretStorage: _this11.secretStorage,
1018
- cryptoCallbacks: _this11.cryptoCallbacks,
1019
- storePrefix: args.useIndexedDB === false ? null : RUST_SDK_STORE_PREFIX,
1020
- storeKey: args.storageKey,
1021
- storePassphrase: args.storagePassword,
1022
- legacyCryptoStore: _this11.cryptoStore,
1023
- legacyPickleKey: (_this11$pickleKey = _this11.pickleKey) !== null && _this11$pickleKey !== void 0 ? _this11$pickleKey : "DEFAULT_KEY",
1024
- legacyMigrationProgressListener: (progress, total) => {
1025
- _this11.emit(CryptoEvent.LegacyCryptoStoreMigrationProgress, progress, total);
1026
- }
1027
- });
1028
- rustCrypto.setSupportedVerificationMethods(_this11.verificationMethods);
1029
- _this11.cryptoBackend = rustCrypto;
1030
-
1031
- // attach the event listeners needed by RustCrypto
1032
- _this11.on(RoomMemberEvent.Membership, rustCrypto.onRoomMembership.bind(rustCrypto));
1033
- _this11.on(ClientEvent.Event, event => {
1034
- rustCrypto.onLiveEventFromSync(event);
1035
- });
1036
-
1037
- // re-emit the events emitted by the crypto impl
1038
- _this11.reEmitter.reEmit(rustCrypto, [CryptoEvent.VerificationRequestReceived, CryptoEvent.UserTrustStatusChanged, CryptoEvent.KeyBackupStatus, CryptoEvent.KeyBackupSessionsRemaining, CryptoEvent.KeyBackupFailed, CryptoEvent.KeyBackupDecryptionKeyCached, CryptoEvent.KeysChanged, CryptoEvent.DevicesUpdated, CryptoEvent.WillUpdateDevices]);
1039
- })();
1040
- }
1041
-
1042
- /**
1043
- * Access the server-side secret storage API for this client.
1044
- */
1045
- get secretStorage() {
1046
- return this._secretStorage;
1047
- }
1048
-
1049
- /**
1050
- * Access the crypto API for this client.
1051
- *
1052
- * If end-to-end encryption has been enabled for this client (via {@link initCrypto} or {@link initRustCrypto}),
1053
- * returns an object giving access to the crypto API. Otherwise, returns `undefined`.
1054
- */
1055
- getCrypto() {
1056
- return this.cryptoBackend;
1057
- }
1058
-
1059
- /**
1060
- * Is end-to-end crypto enabled for this client.
1061
- * @returns True if end-to-end is enabled.
1062
- * @deprecated prefer {@link getCrypto}
1063
- */
1064
- isCryptoEnabled() {
1065
- return !!this.cryptoBackend;
1066
- }
1067
-
1068
- /**
1069
- * Get the Ed25519 key for this device
1070
- *
1071
- * @returns base64-encoded ed25519 key. Null if crypto is
1072
- * disabled.
1073
- *
1074
- * @deprecated Not supported for Rust Cryptography.Prefer {@link CryptoApi.getOwnDeviceKeys}
1075
- */
1076
- getDeviceEd25519Key() {
1077
- var _this$crypto$getDevic, _this$crypto;
1078
- return (_this$crypto$getDevic = (_this$crypto = this.crypto) === null || _this$crypto === void 0 ? void 0 : _this$crypto.getDeviceEd25519Key()) !== null && _this$crypto$getDevic !== void 0 ? _this$crypto$getDevic : null;
1079
- }
1080
-
1081
- /**
1082
- * Get the Curve25519 key for this device
1083
- *
1084
- * @returns base64-encoded curve25519 key. Null if crypto is
1085
- * disabled.
1086
- *
1087
- * @deprecated Not supported for Rust Cryptography. Use {@link CryptoApi.getOwnDeviceKeys}
1088
- */
1089
- getDeviceCurve25519Key() {
1090
- var _this$crypto$getDevic2, _this$crypto2;
1091
- return (_this$crypto$getDevic2 = (_this$crypto2 = this.crypto) === null || _this$crypto2 === void 0 ? void 0 : _this$crypto2.getDeviceCurve25519Key()) !== null && _this$crypto$getDevic2 !== void 0 ? _this$crypto$getDevic2 : null;
1092
- }
1093
-
1094
- /**
1095
- * @deprecated Does nothing.
1096
- */
1097
- uploadKeys() {
1098
- var _this12 = this;
1099
- return _asyncToGenerator(function* () {
1100
- _this12.logger.warn("MatrixClient.uploadKeys is deprecated");
1101
- })();
1102
- }
1103
-
1104
- /**
1105
- * Download the keys for a list of users and stores the keys in the session
1106
- * store.
1107
- * @param userIds - The users to fetch.
1108
- * @param forceDownload - Always download the keys even if cached.
1109
- *
1110
- * @returns A promise which resolves to a map userId-\>deviceId-\>`DeviceInfo`
1111
- *
1112
- * @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi.getUserDeviceInfo}
1113
- */
1114
- downloadKeys(userIds, forceDownload) {
1115
- if (!this.crypto) {
1116
- return Promise.reject(new Error("End-to-end encryption disabled"));
1117
- }
1118
- return this.crypto.downloadKeys(userIds, forceDownload);
1119
- }
1120
-
1121
- /**
1122
- * Get the stored device keys for a user id
1123
- *
1124
- * @param userId - the user to list keys for.
1125
- *
1126
- * @returns list of devices
1127
- * @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi.getUserDeviceInfo}
1128
- */
1129
- getStoredDevicesForUser(userId) {
1130
- if (!this.crypto) {
1131
- throw new Error("End-to-end encryption disabled");
1132
- }
1133
- return this.crypto.getStoredDevicesForUser(userId) || [];
1134
- }
1135
-
1136
- /**
1137
- * Get the stored device key for a user id and device id
1138
- *
1139
- * @param userId - the user to list keys for.
1140
- * @param deviceId - unique identifier for the device
1141
- *
1142
- * @returns device or null
1143
- * @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi.getUserDeviceInfo}
1144
- */
1145
- getStoredDevice(userId, deviceId) {
1146
- if (!this.crypto) {
1147
- throw new Error("End-to-end encryption disabled");
1148
- }
1149
- return this.crypto.getStoredDevice(userId, deviceId) || null;
1150
- }
1151
-
1152
- /**
1153
- * Mark the given device as verified
1154
- *
1155
- * @param userId - owner of the device
1156
- * @param deviceId - unique identifier for the device or user's
1157
- * cross-signing public key ID.
1158
- *
1159
- * @param verified - whether to mark the device as verified. defaults
1160
- * to 'true'.
1161
- *
1162
- * @returns
1163
- *
1164
- * @remarks
1165
- * Fires {@link CryptoEvent#DeviceVerificationChanged}
1166
- */
1167
- setDeviceVerified(userId, deviceId) {
1168
- var verified = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
1169
- var prom = this.setDeviceVerification(userId, deviceId, verified, null, null);
1170
-
1171
- // if one of the user's own devices is being marked as verified / unverified,
1172
- // check the key backup status, since whether or not we use this depends on
1173
- // whether it has a signature from a verified device
1174
- if (userId == this.credentials.userId) {
1175
- this.checkKeyBackup();
1176
- }
1177
- return prom;
1178
- }
1179
-
1180
- /**
1181
- * Mark the given device as blocked/unblocked
1182
- *
1183
- * @param userId - owner of the device
1184
- * @param deviceId - unique identifier for the device or user's
1185
- * cross-signing public key ID.
1186
- *
1187
- * @param blocked - whether to mark the device as blocked. defaults
1188
- * to 'true'.
1189
- *
1190
- * @returns
1191
- *
1192
- * @remarks
1193
- * Fires {@link LegacyCryptoEvent.DeviceVerificationChanged}
1194
- *
1195
- * @deprecated Not supported for Rust Cryptography.
1196
- */
1197
- setDeviceBlocked(userId, deviceId) {
1198
- var blocked = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
1199
- return this.setDeviceVerification(userId, deviceId, null, blocked, null);
1200
- }
1201
-
1202
- /**
1203
- * Mark the given device as known/unknown
1204
- *
1205
- * @param userId - owner of the device
1206
- * @param deviceId - unique identifier for the device or user's
1207
- * cross-signing public key ID.
1208
- *
1209
- * @param known - whether to mark the device as known. defaults
1210
- * to 'true'.
1211
- *
1212
- * @returns
1213
- *
1214
- * @remarks
1215
- * Fires {@link CryptoEvent#DeviceVerificationChanged}
1216
- *
1217
- * @deprecated Not supported for Rust Cryptography.
1218
- */
1219
- setDeviceKnown(userId, deviceId) {
1220
- var known = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
1221
- return this.setDeviceVerification(userId, deviceId, null, null, known);
1222
- }
1223
- setDeviceVerification(userId, deviceId, verified, blocked, known) {
1224
- var _this13 = this;
1225
- return _asyncToGenerator(function* () {
1226
- if (!_this13.crypto) {
1227
- throw new Error("End-to-end encryption disabled");
1228
- }
1229
- yield _this13.crypto.setDeviceVerification(userId, deviceId, verified, blocked, known);
1230
- })();
1231
- }
1232
-
1233
- /**
1234
- * Request a key verification from another user, using a DM.
1235
- *
1236
- * @param userId - the user to request verification with
1237
- * @param roomId - the room to use for verification
1238
- *
1239
- * @returns resolves to a VerificationRequest
1240
- * when the request has been sent to the other party.
1241
- *
1242
- * @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi.requestVerificationDM}.
1243
- */
1244
- requestVerificationDM(userId, roomId) {
1245
- if (!this.crypto) {
1246
- throw new Error("End-to-end encryption disabled");
1247
- }
1248
- return this.crypto.requestVerificationDM(userId, roomId);
1249
- }
1250
-
1251
- /**
1252
- * Finds a DM verification request that is already in progress for the given room id
1253
- *
1254
- * @param roomId - the room to use for verification
1255
- *
1256
- * @returns the VerificationRequest that is in progress, if any
1257
- * @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi.findVerificationRequestDMInProgress}.
1258
- */
1259
- findVerificationRequestDMInProgress(roomId) {
1260
- if (!this.cryptoBackend) {
1261
- throw new Error("End-to-end encryption disabled");
1262
- } else if (!this.crypto) {
1263
- // Hack for element-R to avoid breaking the cypress tests. We can get rid of this once the react-sdk is
1264
- // updated to use CryptoApi.findVerificationRequestDMInProgress.
1265
- return undefined;
1266
- }
1267
- return this.crypto.findVerificationRequestDMInProgress(roomId);
1268
- }
1269
-
1270
- /**
1271
- * Returns all to-device verification requests that are already in progress for the given user id
1272
- *
1273
- * @param userId - the ID of the user to query
1274
- *
1275
- * @returns the VerificationRequests that are in progress
1276
- * @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi.getVerificationRequestsToDeviceInProgress}.
1277
- */
1278
- getVerificationRequestsToDeviceInProgress(userId) {
1279
- if (!this.crypto) {
1280
- throw new Error("End-to-end encryption disabled");
1281
- }
1282
- return this.crypto.getVerificationRequestsToDeviceInProgress(userId);
1283
- }
1284
-
1285
- /**
1286
- * Request a key verification from another user.
1287
- *
1288
- * @param userId - the user to request verification with
1289
- * @param devices - array of device IDs to send requests to. Defaults to
1290
- * all devices owned by the user
1291
- *
1292
- * @returns resolves to a VerificationRequest
1293
- * when the request has been sent to the other party.
1294
- *
1295
- * @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi#requestOwnUserVerification} or {@link CryptoApi#requestDeviceVerification}.
1296
- */
1297
- requestVerification(userId, devices) {
1298
- if (!this.crypto) {
1299
- throw new Error("End-to-end encryption disabled");
1300
- }
1301
- return this.crypto.requestVerification(userId, devices);
1302
- }
1303
-
1304
- /**
1305
- * Begin a key verification.
1306
- *
1307
- * @param method - the verification method to use
1308
- * @param userId - the user to verify keys with
1309
- * @param deviceId - the device to verify
1310
- *
1311
- * @returns a verification object
1312
- * @deprecated Prefer {@link CryptoApi#requestOwnUserVerification} or {@link CryptoApi#requestDeviceVerification}.
1313
- */
1314
- beginKeyVerification(method, userId, deviceId) {
1315
- if (!this.crypto) {
1316
- throw new Error("End-to-end encryption disabled");
1317
- }
1318
- return this.crypto.beginKeyVerification(method, userId, deviceId);
1319
- }
1320
-
1321
- /**
1322
- * @deprecated Use {@link MatrixClient#secretStorage} and {@link SecretStorage.ServerSideSecretStorage#checkKey}.
1323
- */
1324
- checkSecretStorageKey(key, info) {
1325
- return this.secretStorage.checkKey(key, info);
1326
- }
1327
-
1328
- /**
1329
- * Set the global override for whether the client should ever send encrypted
1330
- * messages to unverified devices. This provides the default for rooms which
1331
- * do not specify a value.
1332
- *
1333
- * @param value - whether to blacklist all unverified devices by default
1334
- *
1335
- * @deprecated Prefer direct access to {@link CryptoApi.globalBlacklistUnverifiedDevices}:
1336
- *
1337
- * ```javascript
1338
- * client.getCrypto().globalBlacklistUnverifiedDevices = value;
1339
- * ```
1340
- */
1341
- setGlobalBlacklistUnverifiedDevices(value) {
1342
- if (!this.cryptoBackend) {
1343
- throw new Error("End-to-end encryption disabled");
1344
- }
1345
- this.cryptoBackend.globalBlacklistUnverifiedDevices = value;
1346
- return value;
1347
- }
1348
-
1349
- /**
1350
- * @returns whether to blacklist all unverified devices by default
1351
- *
1352
- * @deprecated Prefer direct access to {@link CryptoApi.globalBlacklistUnverifiedDevices}:
1353
- *
1354
- * ```javascript
1355
- * value = client.getCrypto().globalBlacklistUnverifiedDevices;
1356
- * ```
1357
- */
1358
- getGlobalBlacklistUnverifiedDevices() {
1359
- if (!this.cryptoBackend) {
1360
- throw new Error("End-to-end encryption disabled");
1361
- }
1362
- return this.cryptoBackend.globalBlacklistUnverifiedDevices;
1363
- }
1364
-
1365
- /**
1366
- * Set whether sendMessage in a room with unknown and unverified devices
1367
- * should throw an error and not send them message. This has 'Global' for
1368
- * symmetry with setGlobalBlacklistUnverifiedDevices but there is currently
1369
- * no room-level equivalent for this setting.
1370
- *
1371
- * This API is currently UNSTABLE and may change or be removed without notice.
1372
- *
1373
- * It has no effect with the Rust crypto implementation.
1374
- *
1375
- * @param value - whether error on unknown devices
1376
- *
1377
- * ```ts
1378
- * client.getCrypto().globalErrorOnUnknownDevices = value;
1379
- * ```
1380
- */
1381
- setGlobalErrorOnUnknownDevices(value) {
1382
- if (!this.cryptoBackend) {
1383
- throw new Error("End-to-end encryption disabled");
1384
- }
1385
- this.cryptoBackend.globalErrorOnUnknownDevices = value;
1386
- }
1387
-
1388
- /**
1389
- * @returns whether to error on unknown devices
1390
- *
1391
- * This API is currently UNSTABLE and may change or be removed without notice.
1392
- */
1393
- getGlobalErrorOnUnknownDevices() {
1394
- if (!this.cryptoBackend) {
1395
- throw new Error("End-to-end encryption disabled");
1396
- }
1397
- return this.cryptoBackend.globalErrorOnUnknownDevices;
1398
- }
1399
-
1400
- /**
1401
- * Get the ID of one of the user's cross-signing keys
1402
- *
1403
- * @param type - The type of key to get the ID of. One of
1404
- * "master", "self_signing", or "user_signing". Defaults to "master".
1405
- *
1406
- * @returns the key ID
1407
- * @deprecated Not supported for Rust Cryptography. prefer {@link Crypto.CryptoApi#getCrossSigningKeyId}
1408
- */
1409
- getCrossSigningId() {
1410
- var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : CrossSigningKey.Master;
1411
- if (!this.crypto) {
1412
- throw new Error("End-to-end encryption disabled");
1413
- }
1414
- return this.crypto.getCrossSigningId(type);
1415
- }
1416
-
1417
- /**
1418
- * Get the cross signing information for a given user.
1419
- *
1420
- * The cross-signing API is currently UNSTABLE and may change without notice.
1421
- *
1422
- * @param userId - the user ID to get the cross-signing info for.
1423
- *
1424
- * @returns the cross signing information for the user.
1425
- * @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi#userHasCrossSigningKeys}
1426
- */
1427
- getStoredCrossSigningForUser(userId) {
1428
- if (!this.cryptoBackend) {
1429
- throw new Error("End-to-end encryption disabled");
1430
- }
1431
- return this.cryptoBackend.getStoredCrossSigningForUser(userId);
1432
- }
1433
-
1434
- /**
1435
- * Check whether a given user is trusted.
1436
- *
1437
- * The cross-signing API is currently UNSTABLE and may change without notice.
1438
- *
1439
- * @param userId - The ID of the user to check.
1440
- *
1441
- * @deprecated Use {@link Crypto.CryptoApi.getUserVerificationStatus | `CryptoApi.getUserVerificationStatus`}
1442
- */
1443
- checkUserTrust(userId) {
1444
- if (!this.cryptoBackend) {
1445
- throw new Error("End-to-end encryption disabled");
1446
- }
1447
- return this.cryptoBackend.checkUserTrust(userId);
1448
- }
1449
-
1450
- /**
1451
- * Check whether a given device is trusted.
1452
- *
1453
- * The cross-signing API is currently UNSTABLE and may change without notice.
1454
- *
1455
- * @param userId - The ID of the user whose devices is to be checked.
1456
- * @param deviceId - The ID of the device to check
1457
- *
1458
- * @deprecated Use {@link Crypto.CryptoApi.getDeviceVerificationStatus | `CryptoApi.getDeviceVerificationStatus`}
1459
- */
1460
- checkDeviceTrust(userId, deviceId) {
1461
- if (!this.crypto) {
1462
- throw new Error("End-to-end encryption disabled");
1463
- }
1464
- return this.crypto.checkDeviceTrust(userId, deviceId);
1465
- }
1466
-
1467
- /**
1468
- * Check whether one of our own devices is cross-signed by our
1469
- * user's stored keys, regardless of whether we trust those keys yet.
1470
- *
1471
- * @param deviceId - The ID of the device to check
1472
- *
1473
- * @returns true if the device is cross-signed
1474
- *
1475
- * @deprecated Not supported for Rust Cryptography.
1476
- */
1477
- checkIfOwnDeviceCrossSigned(deviceId) {
1478
- if (!this.crypto) {
1479
- throw new Error("End-to-end encryption disabled");
1480
- }
1481
- return this.crypto.checkIfOwnDeviceCrossSigned(deviceId);
1482
- }
1483
-
1484
- /**
1485
- * Check the copy of our cross-signing key that we have in the device list and
1486
- * see if we can get the private key. If so, mark it as trusted.
1487
- * @param opts - ICheckOwnCrossSigningTrustOpts object
1488
- *
1489
- * @deprecated Unneeded for the new crypto
1490
- */
1491
- checkOwnCrossSigningTrust(opts) {
1492
- if (!this.cryptoBackend) {
1493
- throw new Error("End-to-end encryption disabled");
1494
- }
1495
- return this.cryptoBackend.checkOwnCrossSigningTrust(opts);
1496
- }
1497
-
1498
- /**
1499
- * Checks that a given cross-signing private key matches a given public key.
1500
- * This can be used by the getCrossSigningKey callback to verify that the
1501
- * private key it is about to supply is the one that was requested.
1502
- * @param privateKey - The private key
1503
- * @param expectedPublicKey - The public key
1504
- * @returns true if the key matches, otherwise false
1505
- *
1506
- * @deprecated Not supported for Rust Cryptography.
1507
- */
1508
- checkCrossSigningPrivateKey(privateKey, expectedPublicKey) {
1509
- if (!this.crypto) {
1510
- throw new Error("End-to-end encryption disabled");
1511
- }
1512
- return this.crypto.checkCrossSigningPrivateKey(privateKey, expectedPublicKey);
1513
- }
1514
-
1515
- /**
1516
- * @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi#requestDeviceVerification}.
1517
- */
1518
- legacyDeviceVerification(userId, deviceId, method) {
1519
- if (!this.crypto) {
1520
- throw new Error("End-to-end encryption disabled");
1521
- }
1522
- return this.crypto.legacyDeviceVerification(userId, deviceId, method);
1523
- }
1524
-
1525
- /**
1526
- * Perform any background tasks that can be done before a message is ready to
1527
- * send, in order to speed up sending of the message.
1528
- * @param room - the room the event is in
1529
- *
1530
- * @deprecated Prefer {@link CryptoApi.prepareToEncrypt | `CryptoApi.prepareToEncrypt`}:
1531
- *
1532
- * ```javascript
1533
- * client.getCrypto().prepareToEncrypt(room);
1534
- * ```
1535
- */
1536
- prepareToEncrypt(room) {
1537
- if (!this.cryptoBackend) {
1538
- throw new Error("End-to-end encryption disabled");
1539
- }
1540
- this.cryptoBackend.prepareToEncrypt(room);
1541
- }
1542
-
1543
- /**
1544
- * Checks if the user has previously published cross-signing keys
1545
- *
1546
- * This means downloading the devicelist for the user and checking if the list includes
1547
- * the cross-signing pseudo-device.
1548
- *
1549
- * @deprecated Prefer {@link CryptoApi.userHasCrossSigningKeys | `CryptoApi.userHasCrossSigningKeys`}:
1550
- *
1551
- * ```javascript
1552
- * result = client.getCrypto().userHasCrossSigningKeys();
1553
- * ```
1554
- */
1555
- userHasCrossSigningKeys() {
1556
- if (!this.cryptoBackend) {
1557
- throw new Error("End-to-end encryption disabled");
1558
- }
1559
- return this.cryptoBackend.userHasCrossSigningKeys();
1560
- }
1561
-
1562
- /**
1563
- * Checks whether cross signing:
1564
- * - is enabled on this account and trusted by this device
1565
- * - has private keys either cached locally or stored in secret storage
1566
- *
1567
- * If this function returns false, bootstrapCrossSigning() can be used
1568
- * to fix things such that it returns true. That is to say, after
1569
- * bootstrapCrossSigning() completes successfully, this function should
1570
- * return true.
1571
- * @returns True if cross-signing is ready to be used on this device
1572
- * @deprecated Prefer {@link CryptoApi.isCrossSigningReady | `CryptoApi.isCrossSigningReady`}:
1573
- */
1574
- isCrossSigningReady() {
1575
- if (!this.cryptoBackend) {
1576
- throw new Error("End-to-end encryption disabled");
1577
- }
1578
- return this.cryptoBackend.isCrossSigningReady();
1579
- }
1580
-
1581
- /**
1582
- * Bootstrap cross-signing by creating keys if needed. If everything is already
1583
- * set up, then no changes are made, so this is safe to run to ensure
1584
- * cross-signing is ready for use.
1585
- *
1586
- * This function:
1587
- * - creates new cross-signing keys if they are not found locally cached nor in
1588
- * secret storage (if it has been set up)
1589
- *
1590
- * @deprecated Prefer {@link CryptoApi.bootstrapCrossSigning | `CryptoApi.bootstrapCrossSigning`}.
1591
- */
1592
- bootstrapCrossSigning(opts) {
1593
- if (!this.cryptoBackend) {
1594
- throw new Error("End-to-end encryption disabled");
1595
- }
1596
- return this.cryptoBackend.bootstrapCrossSigning(opts);
1597
- }
1598
-
1599
- /**
1600
- * Whether to trust a others users signatures of their devices.
1601
- * If false, devices will only be considered 'verified' if we have
1602
- * verified that device individually (effectively disabling cross-signing).
1603
- *
1604
- * Default: true
1605
- *
1606
- * @returns True if trusting cross-signed devices
1607
- *
1608
- * @deprecated Prefer {@link CryptoApi.getTrustCrossSignedDevices | `CryptoApi.getTrustCrossSignedDevices`}.
1609
- */
1610
- getCryptoTrustCrossSignedDevices() {
1611
- if (!this.cryptoBackend) {
1612
- throw new Error("End-to-end encryption disabled");
1613
- }
1614
- return this.cryptoBackend.getTrustCrossSignedDevices();
1615
- }
1616
-
1617
- /**
1618
- * See getCryptoTrustCrossSignedDevices
1619
- *
1620
- * @param val - True to trust cross-signed devices
1621
- *
1622
- * @deprecated Prefer {@link CryptoApi.setTrustCrossSignedDevices | `CryptoApi.setTrustCrossSignedDevices`}.
1623
- */
1624
- setCryptoTrustCrossSignedDevices(val) {
1625
- if (!this.cryptoBackend) {
1626
- throw new Error("End-to-end encryption disabled");
1627
- }
1628
- this.cryptoBackend.setTrustCrossSignedDevices(val);
1629
- }
1630
-
1631
- /**
1632
- * Counts the number of end to end session keys that are waiting to be backed up
1633
- * @returns Promise which resolves to the number of sessions requiring backup
1634
- *
1635
- * @deprecated Not supported for Rust Cryptography.
1636
- */
1637
- countSessionsNeedingBackup() {
1638
- if (!this.crypto) {
1639
- throw new Error("End-to-end encryption disabled");
1640
- }
1641
- return this.crypto.countSessionsNeedingBackup();
1642
- }
1643
-
1644
- /**
1645
- * Get information about the encryption of an event
1646
- *
1647
- * @param event - event to be checked
1648
- * @returns The event information.
1649
- * @deprecated Prefer {@link Crypto.CryptoApi.getEncryptionInfoForEvent | `CryptoApi.getEncryptionInfoForEvent`}.
1650
- */
1651
- getEventEncryptionInfo(event) {
1652
- if (!this.cryptoBackend) {
1653
- throw new Error("End-to-end encryption disabled");
1654
- }
1655
- return this.cryptoBackend.getEventEncryptionInfo(event);
1656
- }
1657
-
1658
- /**
1659
- * Create a recovery key from a user-supplied passphrase.
1660
- *
1661
- * The Secure Secret Storage API is currently UNSTABLE and may change without notice.
1662
- *
1663
- * @param password - Passphrase string that can be entered by the user
1664
- * when restoring the backup as an alternative to entering the recovery key.
1665
- * Optional.
1666
- * @returns Object with public key metadata, encoded private
1667
- * recovery key which should be disposed of after displaying to the user,
1668
- * and raw private key to avoid round tripping if needed.
1669
- *
1670
- * @deprecated Prefer {@link CryptoApi.createRecoveryKeyFromPassphrase | `CryptoApi.createRecoveryKeyFromPassphrase`}.
1671
- */
1672
- createRecoveryKeyFromPassphrase(password) {
1673
- if (!this.cryptoBackend) {
1674
- throw new Error("End-to-end encryption disabled");
1675
- }
1676
- return this.cryptoBackend.createRecoveryKeyFromPassphrase(password);
1677
- }
1678
-
1679
- /**
1680
- * Checks whether secret storage:
1681
- * - is enabled on this account
1682
- * - is storing cross-signing private keys
1683
- * - is storing session backup key (if enabled)
1684
- *
1685
- * If this function returns false, bootstrapSecretStorage() can be used
1686
- * to fix things such that it returns true. That is to say, after
1687
- * bootstrapSecretStorage() completes successfully, this function should
1688
- * return true.
1689
- *
1690
- * @returns True if secret storage is ready to be used on this device
1691
- * @deprecated Prefer {@link CryptoApi.isSecretStorageReady | `CryptoApi.isSecretStorageReady`}.
1692
- */
1693
- isSecretStorageReady() {
1694
- if (!this.cryptoBackend) {
1695
- throw new Error("End-to-end encryption disabled");
1696
- }
1697
- return this.cryptoBackend.isSecretStorageReady();
1698
- }
1699
-
1700
- /**
1701
- * Bootstrap Secure Secret Storage if needed by creating a default key. If everything is
1702
- * already set up, then no changes are made, so this is safe to run to ensure secret
1703
- * storage is ready for use.
1704
- *
1705
- * This function
1706
- * - creates a new Secure Secret Storage key if no default key exists
1707
- * - if a key backup exists, it is migrated to store the key in the Secret
1708
- * Storage
1709
- * - creates a backup if none exists, and one is requested
1710
- * - migrates Secure Secret Storage to use the latest algorithm, if an outdated
1711
- * algorithm is found
1712
- *
1713
- * @deprecated Use {@link CryptoApi.bootstrapSecretStorage | `CryptoApi.bootstrapSecretStorage`}.
1714
- */
1715
- bootstrapSecretStorage(opts) {
1716
- if (!this.cryptoBackend) {
1717
- throw new Error("End-to-end encryption disabled");
1718
- }
1719
- return this.cryptoBackend.bootstrapSecretStorage(opts);
1720
- }
1721
-
1722
- /**
1723
- * Add a key for encrypting secrets.
1724
- *
1725
- * The Secure Secret Storage API is currently UNSTABLE and may change without notice.
1726
- *
1727
- * @param algorithm - the algorithm used by the key
1728
- * @param opts - the options for the algorithm. The properties used
1729
- * depend on the algorithm given.
1730
- * @param keyName - the name of the key. If not given, a random name will be generated.
1731
- *
1732
- * @returns An object with:
1733
- * keyId: the ID of the key
1734
- * keyInfo: details about the key (iv, mac, passphrase)
1735
- *
1736
- * @deprecated Use {@link MatrixClient#secretStorage} and {@link SecretStorage.ServerSideSecretStorage#addKey}.
1737
- */
1738
- addSecretStorageKey(algorithm, opts, keyName) {
1739
- return this.secretStorage.addKey(algorithm, opts, keyName);
1740
- }
1741
-
1742
- /**
1743
- * Check whether we have a key with a given ID.
1744
- *
1745
- * The Secure Secret Storage API is currently UNSTABLE and may change without notice.
1746
- *
1747
- * @param keyId - The ID of the key to check
1748
- * for. Defaults to the default key ID if not provided.
1749
- * @returns Whether we have the key.
1750
- *
1751
- * @deprecated Use {@link MatrixClient#secretStorage} and {@link SecretStorage.ServerSideSecretStorage#hasKey}.
1752
- */
1753
- hasSecretStorageKey(keyId) {
1754
- return this.secretStorage.hasKey(keyId);
1755
- }
1756
-
1757
- /**
1758
- * Store an encrypted secret on the server.
1759
- *
1760
- * The Secure Secret Storage API is currently UNSTABLE and may change without notice.
1761
- *
1762
- * @param name - The name of the secret
1763
- * @param secret - The secret contents.
1764
- * @param keys - The IDs of the keys to use to encrypt the secret or null/undefined
1765
- * to use the default (will throw if no default key is set).
1766
- *
1767
- * @deprecated Use {@link MatrixClient#secretStorage} and {@link SecretStorage.ServerSideSecretStorage#store}.
1768
- */
1769
- storeSecret(name, secret, keys) {
1770
- return this.secretStorage.store(name, secret, keys);
1771
- }
1772
-
1773
- /**
1774
- * Get a secret from storage.
1775
- *
1776
- * The Secure Secret Storage API is currently UNSTABLE and may change without notice.
1777
- *
1778
- * @param name - the name of the secret
1779
- *
1780
- * @returns the contents of the secret
1781
- *
1782
- * @deprecated Use {@link MatrixClient#secretStorage} and {@link SecretStorage.ServerSideSecretStorage#get}.
1783
- */
1784
- getSecret(name) {
1785
- return this.secretStorage.get(name);
1786
- }
1787
-
1788
- /**
1789
- * Check if a secret is stored on the server.
1790
- *
1791
- * The Secure Secret Storage API is currently UNSTABLE and may change without notice.
1792
- *
1793
- * @param name - the name of the secret
1794
- * @returns map of key name to key info the secret is encrypted
1795
- * with, or null if it is not present or not encrypted with a trusted
1796
- * key
1797
- *
1798
- * @deprecated Use {@link MatrixClient#secretStorage} and {@link SecretStorage.ServerSideSecretStorage#isStored}.
1799
- */
1800
- isSecretStored(name) {
1801
- return this.secretStorage.isStored(name);
1802
- }
1803
-
1804
- /**
1805
- * Request a secret from another device.
1806
- *
1807
- * The Secure Secret Storage API is currently UNSTABLE and may change without notice.
1808
- *
1809
- * @param name - the name of the secret to request
1810
- * @param devices - the devices to request the secret from
1811
- *
1812
- * @returns the secret request object
1813
- * @deprecated Not supported for Rust Cryptography.
1814
- */
1815
- requestSecret(name, devices) {
1816
- if (!this.crypto) {
1817
- throw new Error("End-to-end encryption disabled");
1818
- }
1819
- return this.crypto.requestSecret(name, devices);
1820
- }
1821
-
1822
- /**
1823
- * Get the current default key ID for encrypting secrets.
1824
- *
1825
- * The Secure Secret Storage API is currently UNSTABLE and may change without notice.
1826
- *
1827
- * @returns The default key ID or null if no default key ID is set
1828
- *
1829
- * @deprecated Use {@link MatrixClient#secretStorage} and {@link SecretStorage.ServerSideSecretStorage#getDefaultKeyId}.
1830
- */
1831
- getDefaultSecretStorageKeyId() {
1832
- return this.secretStorage.getDefaultKeyId();
1833
- }
1834
-
1835
- /**
1836
- * Set the current default key ID for encrypting secrets.
1837
- *
1838
- * The Secure Secret Storage API is currently UNSTABLE and may change without notice.
1839
- *
1840
- * @param keyId - The new default key ID
1841
- *
1842
- * @deprecated Use {@link MatrixClient#secretStorage} and {@link SecretStorage.ServerSideSecretStorage#setDefaultKeyId}.
1843
- */
1844
- setDefaultSecretStorageKeyId(keyId) {
1845
- return this.secretStorage.setDefaultKeyId(keyId);
1846
- }
1847
-
1848
- /**
1849
- * Checks that a given secret storage private key matches a given public key.
1850
- * This can be used by the getSecretStorageKey callback to verify that the
1851
- * private key it is about to supply is the one that was requested.
1852
- *
1853
- * The Secure Secret Storage API is currently UNSTABLE and may change without notice.
1854
- *
1855
- * @param privateKey - The private key
1856
- * @param expectedPublicKey - The public key
1857
- * @returns true if the key matches, otherwise false
1858
- *
1859
- * @deprecated The use of asymmetric keys for SSSS is deprecated.
1860
- * Use {@link SecretStorage.ServerSideSecretStorage#checkKey} for symmetric keys.
1861
- */
1862
- checkSecretStoragePrivateKey(privateKey, expectedPublicKey) {
1863
- if (!this.crypto) {
1864
- throw new Error("End-to-end encryption disabled");
1865
- }
1866
- return this.crypto.checkSecretStoragePrivateKey(privateKey, expectedPublicKey);
1867
- }
1868
-
1869
- /**
1870
- * Get e2e information on the device that sent an event
1871
- *
1872
- * @param event - event to be checked
1873
- * @deprecated Not supported for Rust Cryptography.
1874
- */
1875
- getEventSenderDeviceInfo(event) {
1876
- var _this14 = this;
1877
- return _asyncToGenerator(function* () {
1878
- if (!_this14.crypto) {
1879
- return null;
1880
- }
1881
- return _this14.crypto.getEventSenderDeviceInfo(event);
1882
- })();
1883
- }
1884
-
1885
- /**
1886
- * Check if the sender of an event is verified
1887
- *
1888
- * @param event - event to be checked
1889
- *
1890
- * @returns true if the sender of this event has been verified using
1891
- * {@link MatrixClient#setDeviceVerified}.
1892
- *
1893
- * @deprecated Not supported for Rust Cryptography.
1894
- */
1895
- isEventSenderVerified(event) {
1896
- var _this15 = this;
1897
- return _asyncToGenerator(function* () {
1898
- var device = yield _this15.getEventSenderDeviceInfo(event);
1899
- if (!device) {
1900
- return false;
1901
- }
1902
- return device.isVerified();
1903
- })();
1904
- }
1905
-
1906
- /**
1907
- * Get outgoing room key request for this event if there is one.
1908
- * @param event - The event to check for
1909
- *
1910
- * @returns A room key request, or null if there is none
1911
- *
1912
- * @deprecated Not supported for Rust Cryptography.
1913
- */
1914
- getOutgoingRoomKeyRequest(event) {
1915
- if (!this.crypto) {
1916
- throw new Error("End-to-End encryption disabled");
1917
- }
1918
- var wireContent = event.getWireContent();
1919
- var requestBody = {
1920
- session_id: wireContent.session_id,
1921
- sender_key: wireContent.sender_key,
1922
- algorithm: wireContent.algorithm,
1923
- room_id: event.getRoomId()
1924
- };
1925
- if (!requestBody.session_id || !requestBody.sender_key || !requestBody.algorithm || !requestBody.room_id) {
1926
- return Promise.resolve(null);
1927
- }
1928
- return this.crypto.cryptoStore.getOutgoingRoomKeyRequest(requestBody);
1929
- }
1930
-
1931
- /**
1932
- * Cancel a room key request for this event if one is ongoing and resend the
1933
- * request.
1934
- * @param event - event of which to cancel and resend the room
1935
- * key request.
1936
- * @returns A promise that will resolve when the key request is queued
1937
- *
1938
- * @deprecated Not supported for Rust Cryptography.
1939
- */
1940
- cancelAndResendEventRoomKeyRequest(event) {
1941
- if (!this.crypto) {
1942
- throw new Error("End-to-End encryption disabled");
1943
- }
1944
- return event.cancelAndResendKeyRequest(this.crypto, this.getUserId());
1945
- }
1946
-
1947
- /**
1948
- * Enable end-to-end encryption for a room. This does not modify room state.
1949
- * Any messages sent before the returned promise resolves will be sent unencrypted.
1950
- * @param roomId - The room ID to enable encryption in.
1951
- * @param config - The encryption config for the room.
1952
- * @returns A promise that will resolve when encryption is set up.
1953
- *
1954
- * @deprecated Not supported for Rust Cryptography. To enable encryption in a room, send an `m.room.encryption`
1955
- * state event.
1956
- */
1957
- setRoomEncryption(roomId, config) {
1958
- if (!this.crypto) {
1959
- throw new Error("End-to-End encryption disabled");
1960
- }
1961
- return this.crypto.setRoomEncryption(roomId, config);
1962
- }
1963
-
1964
- /**
1965
- * Whether encryption is enabled for a room.
1966
- * @param roomId - the room id to query.
1967
- * @returns whether encryption is enabled.
1968
- *
1969
- * @deprecated Not correctly supported for Rust Cryptography. Use {@link CryptoApi.isEncryptionEnabledInRoom} and/or
1970
- * {@link Room.hasEncryptionStateEvent}.
1971
- */
1972
- isRoomEncrypted(roomId) {
1973
- var _this$crypto$isRoomEn, _this$crypto3;
1974
- var room = this.getRoom(roomId);
1975
- if (!room) {
1976
- // we don't know about this room, so can't determine if it should be
1977
- // encrypted. Let's assume not.
1978
- return false;
1979
- }
1980
-
1981
- // if there is an 'm.room.encryption' event in this room, it should be
1982
- // encrypted (independently of whether we actually support encryption)
1983
- if (room.hasEncryptionStateEvent()) {
1984
- return true;
1985
- }
1986
-
1987
- // we don't have an m.room.encrypted event, but that might be because
1988
- // the server is hiding it from us. Check the store to see if it was
1989
- // previously encrypted.
1990
- return (_this$crypto$isRoomEn = (_this$crypto3 = this.crypto) === null || _this$crypto3 === void 0 ? void 0 : _this$crypto3.isRoomEncrypted(roomId)) !== null && _this$crypto$isRoomEn !== void 0 ? _this$crypto$isRoomEn : false;
1991
- }
1992
-
1993
- /**
1994
- * Encrypts and sends a given object via Olm to-device messages to a given
1995
- * set of devices.
1996
- *
1997
- * @param userDeviceInfoArr - list of deviceInfo objects representing the devices to send to
1998
- *
1999
- * @param payload - fields to include in the encrypted payload
2000
- *
2001
- * @returns Promise which
2002
- * resolves once the message has been encrypted and sent to the given
2003
- * userDeviceMap, and returns the `{ contentMap, deviceInfoByDeviceId }`
2004
- * of the successfully sent messages.
2005
- *
2006
- * @deprecated Instead use {@link CryptoApi.encryptToDeviceMessages} followed by {@link queueToDevice}.
2007
- */
2008
- encryptAndSendToDevices(userDeviceInfoArr, payload) {
2009
- if (!this.crypto) {
2010
- throw new Error("End-to-End encryption disabled");
2011
- }
2012
- return this.crypto.encryptAndSendToDevices(userDeviceInfoArr, payload);
2013
- }
2014
-
2015
- /**
2016
- * Forces the current outbound group session to be discarded such
2017
- * that another one will be created next time an event is sent.
2018
- *
2019
- * @param roomId - The ID of the room to discard the session for
2020
- *
2021
- * @deprecated Prefer {@link CryptoApi.forceDiscardSession | `CryptoApi.forceDiscardSession`}:
2022
- */
2023
- forceDiscardSession(roomId) {
2024
- if (!this.cryptoBackend) {
2025
- throw new Error("End-to-End encryption disabled");
2026
- }
2027
- this.cryptoBackend.forceDiscardSession(roomId);
2028
- }
2029
-
2030
- /**
2031
- * Get a list containing all of the room keys
2032
- *
2033
- * This should be encrypted before returning it to the user.
2034
- *
2035
- * @returns a promise which resolves to a list of session export objects
2036
- *
2037
- * @deprecated Prefer {@link CryptoApi.exportRoomKeys | `CryptoApi.exportRoomKeys`}:
2038
- *
2039
- * ```javascript
2040
- * sessionData = await client.getCrypto().exportRoomKeys();
2041
- * ```
2042
- */
2043
- exportRoomKeys() {
2044
- if (!this.cryptoBackend) {
2045
- return Promise.reject(new Error("End-to-end encryption disabled"));
2046
- }
2047
- return this.cryptoBackend.exportRoomKeys();
2048
- }
2049
-
2050
- /**
2051
- * Import a list of room keys previously exported by exportRoomKeys
2052
- *
2053
- * @param keys - a list of session export objects
2054
- * @param opts - options object
2055
- *
2056
- * @returns a promise which resolves when the keys have been imported
2057
- *
2058
- * @deprecated Prefer {@link CryptoApi.importRoomKeys | `CryptoApi.importRoomKeys`}:
2059
- * ```javascript
2060
- * await client.getCrypto()?.importRoomKeys([..]);
2061
- * ```
2062
- */
2063
- importRoomKeys(keys, opts) {
2064
- if (!this.cryptoBackend) {
2065
- throw new Error("End-to-end encryption disabled");
2066
- }
2067
- return this.cryptoBackend.importRoomKeys(keys, opts);
2068
- }
2069
-
2070
- /**
2071
- * Force a re-check of the local key backup status against
2072
- * what's on the server.
2073
- *
2074
- * @returns Object with backup info (as returned by
2075
- * getKeyBackupVersion) in backupInfo and
2076
- * trust information (as returned by isKeyBackupTrusted)
2077
- * in trustInfo.
2078
- *
2079
- * @deprecated Prefer {@link Crypto.CryptoApi.checkKeyBackupAndEnable}.
2080
- */
2081
- checkKeyBackup() {
2082
- if (!this.crypto) {
2083
- throw new Error("End-to-end encryption disabled");
2084
- }
2085
- return this.crypto.backupManager.checkKeyBackup();
2086
- }
2087
-
2088
- /**
2089
- * Get information about the current key backup from the server.
2090
- *
2091
- * Performs some basic validity checks on the shape of the result, and raises an error if it is not as expected.
2092
- *
2093
- * **Note**: there is no (supported) way to distinguish between "failure to talk to the server" and "another client
2094
- * uploaded a key backup version using an algorithm I don't understand.
2095
- *
2096
- * @returns Information object from API, or null if no backup is present on the server.
2097
- *
2098
- * @deprecated Prefer {@link CryptoApi.getKeyBackupInfo}.
2099
- */
2100
- getKeyBackupVersion() {
2101
- var _this16 = this;
2102
- return _asyncToGenerator(function* () {
2103
- var res;
2104
- try {
2105
- res = yield _this16.http.authedRequest(Method.Get, "/room_keys/version", undefined, undefined, {
2106
- prefix: ClientPrefix.V3
2107
- });
2108
- } catch (e) {
2109
- if (e.errcode === "M_NOT_FOUND") {
2110
- return null;
2111
- } else {
2112
- throw e;
2113
- }
2114
- }
2115
- BackupManager.checkBackupVersion(res);
2116
- return res;
2117
- })();
2118
- }
2119
-
2120
- /**
2121
- * @param info - key backup info dict from getKeyBackupVersion()
2122
- *
2123
- * @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi.isKeyBackupTrusted | `CryptoApi.isKeyBackupTrusted`}.
2124
- */
2125
- isKeyBackupTrusted(info) {
2126
- if (!this.crypto) {
2127
- throw new Error("End-to-end encryption disabled");
2128
- }
2129
- return this.crypto.backupManager.isKeyBackupTrusted(info);
2130
- }
2131
-
2132
- /**
2133
- * @returns true if the client is configured to back up keys to
2134
- * the server, otherwise false. If we haven't completed a successful check
2135
- * of key backup status yet, returns null.
2136
- *
2137
- * @deprecated Not supported for Rust Cryptography. Prefer direct access to {@link Crypto.CryptoApi.getActiveSessionBackupVersion}:
2138
- *
2139
- * ```javascript
2140
- * let enabled = (await client.getCrypto().getActiveSessionBackupVersion()) !== null;
2141
- * ```
2142
- */
2143
- getKeyBackupEnabled() {
2144
- if (!this.crypto) {
2145
- throw new Error("End-to-end encryption disabled");
2146
- }
2147
- return this.crypto.backupManager.getKeyBackupEnabled();
2148
- }
2149
-
2150
- /**
2151
- * Enable backing up of keys, using data previously returned from
2152
- * getKeyBackupVersion.
2153
- *
2154
- * @param info - Backup information object as returned by getKeyBackupVersion
2155
- * @returns Promise which resolves when complete.
2156
- *
2157
- * @deprecated Do not call this directly. Instead call {@link Crypto.CryptoApi.checkKeyBackupAndEnable}.
2158
- */
2159
- enableKeyBackup(info) {
2160
- if (!this.crypto) {
2161
- throw new Error("End-to-end encryption disabled");
2162
- }
2163
- return this.crypto.backupManager.enableKeyBackup(info);
2164
- }
2165
-
2166
- /**
2167
- * Disable backing up of keys.
2168
- *
2169
- * @deprecated Not supported for Rust Cryptography. It should be unnecessary to disable key backup.
2170
- */
2171
- disableKeyBackup() {
2172
- if (!this.crypto) {
2173
- throw new Error("End-to-end encryption disabled");
2174
- }
2175
- this.crypto.backupManager.disableKeyBackup();
2176
- }
2177
-
2178
- /**
2179
- * Set up the data required to create a new backup version. The backup version
2180
- * will not be created and enabled until createKeyBackupVersion is called.
2181
- *
2182
- * @param password - Passphrase string that can be entered by the user
2183
- * when restoring the backup as an alternative to entering the recovery key.
2184
- * Optional.
2185
- *
2186
- * @returns Object that can be passed to createKeyBackupVersion and
2187
- * additionally has a 'recovery_key' member with the user-facing recovery key string.
2188
- *
2189
- * @deprecated Not supported for Rust cryptography. Use {@link Crypto.CryptoApi.resetKeyBackup | `CryptoApi.resetKeyBackup`}.
2190
- */
2191
- prepareKeyBackupVersion(password) {
2192
- var _arguments2 = arguments,
2193
- _this17 = this;
2194
- return _asyncToGenerator(function* () {
2195
- var opts = _arguments2.length > 1 && _arguments2[1] !== undefined ? _arguments2[1] : {
2196
- secureSecretStorage: false
2197
- };
2198
- if (!_this17.crypto) {
2199
- throw new Error("End-to-end encryption disabled");
2200
- }
2201
-
2202
- // eslint-disable-next-line camelcase
2203
- var {
2204
- algorithm,
2205
- auth_data,
2206
- recovery_key,
2207
- privateKey
2208
- } = yield _this17.crypto.backupManager.prepareKeyBackupVersion(password);
2209
- if (opts.secureSecretStorage) {
2210
- yield _this17.secretStorage.store("m.megolm_backup.v1", encodeBase64(privateKey));
2211
- _this17.logger.info("Key backup private key stored in secret storage");
2212
- }
2213
- return {
2214
- algorithm,
2215
- /* eslint-disable camelcase */
2216
- auth_data,
2217
- recovery_key
2218
- /* eslint-enable camelcase */
2219
- };
2220
- })();
2221
- }
2222
-
2223
- /**
2224
- * Check whether the key backup private key is stored in secret storage.
2225
- * @returns map of key name to key info the secret is
2226
- * encrypted with, or null if it is not present or not encrypted with a
2227
- * trusted key
2228
- */
2229
- isKeyBackupKeyStored() {
2230
- return Promise.resolve(this.secretStorage.isStored("m.megolm_backup.v1"));
2231
- }
2232
-
2233
- /**
2234
- * Create a new key backup version and enable it, using the information return
2235
- * from prepareKeyBackupVersion.
2236
- *
2237
- * @param info - Info object from prepareKeyBackupVersion
2238
- * @returns Object with 'version' param indicating the version created
2239
- *
2240
- * @deprecated Use {@link Crypto.CryptoApi.resetKeyBackup | `CryptoApi.resetKeyBackup`}.
2241
- */
2242
- createKeyBackupVersion(info) {
2243
- var _this18 = this;
2244
- return _asyncToGenerator(function* () {
2245
- if (!_this18.crypto) {
2246
- throw new Error("End-to-end encryption disabled");
2247
- }
2248
- yield _this18.crypto.backupManager.createKeyBackupVersion(info);
2249
- var data = {
2250
- algorithm: info.algorithm,
2251
- auth_data: info.auth_data
2252
- };
2253
-
2254
- // Sign the backup auth data with the device key for backwards compat with
2255
- // older devices with cross-signing. This can probably go away very soon in
2256
- // favour of just signing with the cross-singing master key.
2257
- // XXX: Private member access
2258
- yield _this18.crypto.signObject(data.auth_data);
2259
- if (_this18.cryptoCallbacks.getCrossSigningKey &&
2260
- // XXX: Private member access
2261
- _this18.crypto.crossSigningInfo.getId()) {
2262
- // now also sign the auth data with the cross-signing master key
2263
- // we check for the callback explicitly here because we still want to be able
2264
- // to create an un-cross-signed key backup if there is a cross-signing key but
2265
- // no callback supplied.
2266
- // XXX: Private member access
2267
- yield _this18.crypto.crossSigningInfo.signObject(data.auth_data, "master");
2268
- }
2269
- var res = yield _this18.http.authedRequest(Method.Post, "/room_keys/version", undefined, data);
2270
-
2271
- // We could assume everything's okay and enable directly, but this ensures
2272
- // we run the same signature verification that will be used for future
2273
- // sessions.
2274
- yield _this18.checkKeyBackup();
2275
- if (!_this18.getKeyBackupEnabled()) {
2276
- _this18.logger.error("Key backup not usable even though we just created it");
2277
- }
2278
- return res;
2279
- })();
2280
- }
2281
-
2282
- /**
2283
- * @deprecated Use {@link Crypto.CryptoApi.deleteKeyBackupVersion | `CryptoApi.deleteKeyBackupVersion`}.
2284
- */
2285
- deleteKeyBackupVersion(version) {
2286
- var _this19 = this;
2287
- return _asyncToGenerator(function* () {
2288
- if (!_this19.cryptoBackend) {
2289
- throw new Error("End-to-end encryption disabled");
2290
- }
2291
- yield _this19.cryptoBackend.deleteKeyBackupVersion(version);
2292
- })();
2293
- }
2294
- makeKeyBackupPath(roomId, sessionId, version) {
2295
- var path;
2296
- if (sessionId !== undefined) {
2297
- path = utils.encodeUri("/room_keys/keys/$roomId/$sessionId", {
2298
- $roomId: roomId,
2299
- $sessionId: sessionId
2300
- });
2301
- } else if (roomId !== undefined) {
2302
- path = utils.encodeUri("/room_keys/keys/$roomId", {
2303
- $roomId: roomId
2304
- });
2305
- } else {
2306
- path = "/room_keys/keys";
2307
- }
2308
- var queryData = version === undefined ? undefined : {
2309
- version
2310
- };
2311
- return {
2312
- path,
2313
- queryData
2314
- };
2315
- }
2316
-
2317
- /**
2318
- * Back up session keys to the homeserver.
2319
- * @param roomId - ID of the room that the keys are for Optional.
2320
- * @param sessionId - ID of the session that the keys are for Optional.
2321
- * @param version - backup version Optional.
2322
- * @param data - Object keys to send
2323
- * @returns a promise that will resolve when the keys
2324
- * are uploaded
2325
- *
2326
- * @deprecated Not supported for Rust Cryptography.
2327
- */
2328
-
2329
- sendKeyBackup(roomId, sessionId, version, data) {
2330
- var _this20 = this;
2331
- return _asyncToGenerator(function* () {
2332
- if (!_this20.crypto) {
2333
- throw new Error("End-to-end encryption disabled");
2334
- }
2335
- var path = _this20.makeKeyBackupPath(roomId, sessionId, version);
2336
- yield _this20.http.authedRequest(Method.Put, path.path, path.queryData, data, {
2337
- prefix: ClientPrefix.V3
2338
- });
2339
- })();
2340
- }
2341
-
2342
- /**
2343
- * Marks all group sessions as needing to be backed up and schedules them to
2344
- * upload in the background as soon as possible.
2345
- *
2346
- * @deprecated Not supported for Rust Cryptography. This is done automatically as part of
2347
- * {@link CryptoApi.resetKeyBackup}, so there is probably no need to call this manually.
2348
- */
2349
- scheduleAllGroupSessionsForBackup() {
2350
- var _this21 = this;
2351
- return _asyncToGenerator(function* () {
2352
- if (!_this21.crypto) {
2353
- throw new Error("End-to-end encryption disabled");
2354
- }
2355
- yield _this21.crypto.backupManager.scheduleAllGroupSessionsForBackup();
2356
- })();
2357
- }
2358
-
2359
- /**
2360
- * Marks all group sessions as needing to be backed up without scheduling
2361
- * them to upload in the background.
2362
- *
2363
- * (This is done automatically as part of {@link CryptoApi.resetKeyBackup},
2364
- * so there is probably no need to call this manually.)
2365
- *
2366
- * @returns Promise which resolves to the number of sessions requiring a backup.
2367
- * @deprecated Not supported for Rust Cryptography.
2368
- */
2369
- flagAllGroupSessionsForBackup() {
2370
- if (!this.crypto) {
2371
- throw new Error("End-to-end encryption disabled");
2372
- }
2373
- return this.crypto.backupManager.flagAllGroupSessionsForBackup();
2374
- }
2375
-
2376
- /**
2377
- * Return true if recovery key is valid.
2378
- * Try to decode the recovery key and check if it's successful.
2379
- * @param recoveryKey
2380
- * @deprecated Use {@link decodeRecoveryKey} directly
2381
- */
2382
- isValidRecoveryKey(recoveryKey) {
2383
- try {
2384
- decodeRecoveryKey(recoveryKey);
2385
- return true;
2386
- } catch (_unused2) {
2387
- return false;
2388
- }
2389
- }
2390
-
2391
- /**
2392
- * Get the raw key for a key backup from the password
2393
- * Used when migrating key backups into SSSS
2394
- *
2395
- * The cross-signing API is currently UNSTABLE and may change without notice.
2396
- *
2397
- * @param password - Passphrase
2398
- * @param backupInfo - Backup metadata from `checkKeyBackup`
2399
- * @returns key backup key
2400
- * @deprecated Deriving a backup key from a passphrase is not part of the matrix spec. Instead, a random key is generated and stored/shared via 4S.
2401
- */
2402
- keyBackupKeyFromPassword(password, backupInfo) {
2403
- return keyFromAuthData(backupInfo.auth_data, password);
2404
- }
2405
-
2406
- /**
2407
- * Get the raw key for a key backup from the recovery key
2408
- * Used when migrating key backups into SSSS
2409
- *
2410
- * The cross-signing API is currently UNSTABLE and may change without notice.
2411
- *
2412
- * @param recoveryKey - The recovery key
2413
- * @returns key backup key
2414
- * @deprecated Use {@link decodeRecoveryKey} directly
2415
- */
2416
- keyBackupKeyFromRecoveryKey(recoveryKey) {
2417
- return decodeRecoveryKey(recoveryKey);
2418
- }
2419
-
2420
- /**
2421
- * Restore from an existing key backup via a passphrase.
2422
- *
2423
- * @param password - Passphrase
2424
- * @param targetRoomId - Room ID to target a specific room.
2425
- * Restores all rooms if omitted.
2426
- * @param targetSessionId - Session ID to target a specific session.
2427
- * Restores all sessions if omitted.
2428
- * @param backupInfo - Backup metadata from `getKeyBackupVersion` or `checkKeyBackup`.`backupInfo`
2429
- * @param opts - Optional params such as callbacks
2430
- * @returns Status of restoration with `total` and `imported`
2431
- * key counts.
2432
- *
2433
- * @deprecated Prefer {@link CryptoApi.restoreKeyBackupWithPassphrase | `CryptoApi.restoreKeyBackupWithPassphrase`}.
2434
- */
2435
-
2436
- /**
2437
- * @deprecated Prefer {@link CryptoApi.restoreKeyBackupWithPassphrase | `CryptoApi.restoreKeyBackupWithPassphrase`}.
2438
- */
2439
-
2440
- /**
2441
- * @deprecated Prefer {@link CryptoApi.restoreKeyBackupWithPassphrase | `CryptoApi.restoreKeyBackupWithPassphrase`}.
2442
- */
2443
-
2444
- /**
2445
- * @deprecated Prefer {@link CryptoApi.restoreKeyBackupWithPassphrase | `CryptoApi.restoreKeyBackupWithPassphrase`}.
2446
- */
2447
- restoreKeyBackupWithPassword(password, targetRoomId, targetSessionId, backupInfo, opts) {
2448
- var _this22 = this;
2449
- return _asyncToGenerator(function* () {
2450
- var privKey = yield keyFromAuthData(backupInfo.auth_data, password);
2451
- return _this22.restoreKeyBackup(privKey, targetRoomId, targetSessionId, backupInfo, opts);
2452
- })();
2453
- }
2454
-
2455
- /**
2456
- * Restore from an existing key backup via a private key stored in secret
2457
- * storage.
2458
- *
2459
- * @param backupInfo - Backup metadata from `checkKeyBackup`
2460
- * @param targetRoomId - Room ID to target a specific room.
2461
- * Restores all rooms if omitted.
2462
- * @param targetSessionId - Session ID to target a specific session.
2463
- * Restores all sessions if omitted.
2464
- * @param opts - Optional params such as callbacks
2465
- * @returns Status of restoration with `total` and `imported`
2466
- * key counts.
2467
- *
2468
- * @deprecated Prefer {@link CryptoApi.restoreKeyBackup | `CryptoApi.restoreKeyBackup`}.
2469
- */
2470
- restoreKeyBackupWithSecretStorage(backupInfo, targetRoomId, targetSessionId, opts) {
2471
- var _this23 = this;
2472
- return _asyncToGenerator(function* () {
2473
- if (!_this23.cryptoBackend) {
2474
- throw new Error("End-to-end encryption disabled");
2475
- }
2476
- var storedKey = yield _this23.secretStorage.get("m.megolm_backup.v1");
2477
-
2478
- // ensure that the key is in the right format. If not, fix the key and
2479
- // store the fixed version
2480
- var fixedKey = fixBackupKey(storedKey);
2481
- if (fixedKey) {
2482
- var keys = yield _this23.secretStorage.getKey();
2483
- yield _this23.secretStorage.store("m.megolm_backup.v1", fixedKey, [keys[0]]);
2484
- }
2485
- var privKey = decodeBase64(fixedKey || storedKey);
2486
- return _this23.restoreKeyBackup(privKey, targetRoomId, targetSessionId, backupInfo, opts);
2487
- })();
2488
- }
2489
-
2490
- /**
2491
- * Restore from an existing key backup via an encoded recovery key.
2492
- *
2493
- * @param recoveryKey - Encoded recovery key
2494
- * @param targetRoomId - Room ID to target a specific room.
2495
- * Restores all rooms if omitted.
2496
- * @param targetSessionId - Session ID to target a specific session.
2497
- * Restores all sessions if omitted.
2498
- * @param backupInfo - Backup metadata from `checkKeyBackup`
2499
- * @param opts - Optional params such as callbacks
2500
- * @returns Status of restoration with `total` and `imported`
2501
- * key counts.
2502
- *
2503
- * @deprecated Prefer {@link CryptoApi.restoreKeyBackup | `CryptoApi.restoreKeyBackup`}.
2504
- */
2505
-
2506
- /**
2507
- * @deprecated Prefer {@link CryptoApi.restoreKeyBackup | `CryptoApi.restoreKeyBackup`}.
2508
- */
2509
-
2510
- /**
2511
- * @deprecated Prefer {@link CryptoApi.restoreKeyBackup | `CryptoApi.restoreKeyBackup`}.
2512
- */
2513
-
2514
- /**
2515
- * @deprecated Prefer {@link CryptoApi.restoreKeyBackup | `CryptoApi.restoreKeyBackup`}.
2516
- */
2517
- restoreKeyBackupWithRecoveryKey(recoveryKey, targetRoomId, targetSessionId, backupInfo, opts) {
2518
- var privKey = decodeRecoveryKey(recoveryKey);
2519
- return this.restoreKeyBackup(privKey, targetRoomId, targetSessionId, backupInfo, opts);
2520
- }
2521
-
2522
- /**
2523
- * Restore from an existing key backup via a private key stored locally
2524
- * @param targetRoomId
2525
- * @param targetSessionId
2526
- * @param backupInfo
2527
- * @param opts
2528
- *
2529
- * @deprecated Prefer {@link CryptoApi.restoreKeyBackup | `CryptoApi.restoreKeyBackup`}.
2530
- */
2531
-
2532
- /**
2533
- * @deprecated Prefer {@link CryptoApi.restoreKeyBackup | `CryptoApi.restoreKeyBackup`}.
2534
- */
2535
-
2536
- /**
2537
- * @deprecated Prefer {@link CryptoApi.restoreKeyBackup | `CryptoApi.restoreKeyBackup`}.
2538
- */
2539
-
2540
- /**
2541
- * @deprecated Prefer {@link CryptoApi.restoreKeyBackup | `CryptoApi.restoreKeyBackup`}.
2542
- */
2543
- restoreKeyBackupWithCache(targetRoomId, targetSessionId, backupInfo, opts) {
2544
- var _this24 = this;
2545
- return _asyncToGenerator(function* () {
2546
- if (!_this24.cryptoBackend) {
2547
- throw new Error("End-to-end encryption disabled");
2548
- }
2549
- var privKey = yield _this24.cryptoBackend.getSessionBackupPrivateKey();
2550
- if (!privKey) {
2551
- throw new Error("Couldn't get key");
2552
- }
2553
- return _this24.restoreKeyBackup(privKey, targetRoomId, targetSessionId, backupInfo, opts);
2554
- })();
2555
- }
2556
- restoreKeyBackup(privKey, targetRoomId, targetSessionId, backupInfo, opts) {
2557
- var _this25 = this;
2558
- return _asyncToGenerator(function* () {
2559
- var cacheCompleteCallback = opts === null || opts === void 0 ? void 0 : opts.cacheCompleteCallback;
2560
- var progressCallback = opts === null || opts === void 0 ? void 0 : opts.progressCallback;
2561
- if (!_this25.cryptoBackend) {
2562
- throw new Error("End-to-end encryption disabled");
2563
- }
2564
- if (!backupInfo.version) {
2565
- throw new Error("Backup version must be defined");
2566
- }
2567
- var backupVersion = backupInfo.version;
2568
- var totalKeyCount = 0;
2569
- var totalFailures = 0;
2570
- var totalImported = 0;
2571
- var path = _this25.makeKeyBackupPath(targetRoomId, targetSessionId, backupVersion);
2572
- var backupDecryptor = yield _this25.cryptoBackend.getBackupDecryptor(backupInfo, privKey);
2573
- var untrusted = !backupDecryptor.sourceTrusted;
2574
- try {
2575
- if (!(privKey instanceof Uint8Array)) {
2576
- // eslint-disable-next-line @typescript-eslint/no-base-to-string
2577
- throw new Error("restoreKeyBackup expects Uint8Array, got ".concat(privKey));
2578
- }
2579
- // Cache the key, if possible.
2580
- // This is async.
2581
- _this25.cryptoBackend.storeSessionBackupPrivateKey(privKey, backupVersion).catch(e => {
2582
- _this25.logger.warn("Error caching session backup key:", e);
2583
- }).then(cacheCompleteCallback);
2584
- if (progressCallback) {
2585
- progressCallback({
2586
- stage: "fetch"
2587
- });
2588
- }
2589
- var res = yield _this25.http.authedRequest(Method.Get, path.path, path.queryData, undefined, {
2590
- prefix: ClientPrefix.V3
2591
- });
2592
-
2593
- // We have finished fetching the backup, go to next step
2594
- if (progressCallback) {
2595
- progressCallback({
2596
- stage: "load_keys"
2597
- });
2598
- }
2599
- if (res.rooms) {
2600
- // We have a full backup here, it can get quite big, so we need to decrypt and import it in chunks.
2601
-
2602
- // Get the total count as a first pass
2603
- totalKeyCount = _this25.getTotalKeyCount(res);
2604
- // Now decrypt and import the keys in chunks
2605
- yield _this25.handleDecryptionOfAFullBackup(res, backupDecryptor, 200, /*#__PURE__*/function () {
2606
- var _ref3 = _asyncToGenerator(function* (chunk) {
2607
- // We have a chunk of decrypted keys: import them
2608
- try {
2609
- var _backupVersion = backupInfo.version;
2610
- yield _this25.cryptoBackend.importBackedUpRoomKeys(chunk, _backupVersion, {
2611
- untrusted
2612
- });
2613
- totalImported += chunk.length;
2614
- } catch (e) {
2615
- totalFailures += chunk.length;
2616
- // We failed to import some keys, but we should still try to import the rest?
2617
- // Log the error and continue
2618
- logger.error("Error importing keys from backup", e);
2619
- }
2620
- if (progressCallback) {
2621
- progressCallback({
2622
- total: totalKeyCount,
2623
- successes: totalImported,
2624
- stage: "load_keys",
2625
- failures: totalFailures
2626
- });
2627
- }
2628
- });
2629
- return function (_x2) {
2630
- return _ref3.apply(this, arguments);
2631
- };
2632
- }());
2633
- } else if (res.sessions) {
2634
- // For now we don't chunk for a single room backup, but we could in the future.
2635
- // Currently it is not used by the application.
2636
- var sessions = res.sessions;
2637
- totalKeyCount = Object.keys(sessions).length;
2638
- var keys = yield backupDecryptor.decryptSessions(sessions);
2639
- for (var _k of keys) {
2640
- _k.room_id = targetRoomId;
2641
- }
2642
- yield _this25.cryptoBackend.importBackedUpRoomKeys(keys, backupVersion, {
2643
- progressCallback,
2644
- untrusted
2645
- });
2646
- totalImported = keys.length;
2647
- } else {
2648
- totalKeyCount = 1;
2649
- try {
2650
- var [_key2] = yield backupDecryptor.decryptSessions({
2651
- [targetSessionId]: res
2652
- });
2653
- _key2.room_id = targetRoomId;
2654
- _key2.session_id = targetSessionId;
2655
- yield _this25.cryptoBackend.importBackedUpRoomKeys([_key2], backupVersion, {
2656
- progressCallback,
2657
- untrusted
2658
- });
2659
- totalImported = 1;
2660
- } catch (e) {
2661
- _this25.logger.debug("Failed to decrypt megolm session from backup", e);
2662
- }
2663
- }
2664
- } finally {
2665
- backupDecryptor.free();
2666
- }
2667
-
2668
- /// in case entering the passphrase would add a new signature?
2669
- yield _this25.cryptoBackend.checkKeyBackupAndEnable();
2670
- return {
2671
- total: totalKeyCount,
2672
- imported: totalImported
2673
- };
2674
- })();
606
+ * Return the global notification EventTimelineSet, if any
607
+ *
608
+ * @returns the globl notification EventTimelineSet
609
+ */
610
+ getNotifTimelineSet() {
611
+ return this.notifTimelineSet;
2675
612
  }
2676
613
 
2677
614
  /**
2678
- * This method calculates the total number of keys present in the response of a `/room_keys/keys` call.
2679
- *
2680
- * @param res - The response from the server containing the keys to be counted.
615
+ * Set the global notification EventTimelineSet
2681
616
  *
2682
- * @returns The total number of keys in the backup.
2683
- */
2684
- getTotalKeyCount(res) {
2685
- var rooms = res.rooms;
2686
- var totalKeyCount = 0;
2687
- for (var roomData of Object.values(rooms)) {
2688
- if (!roomData.sessions) continue;
2689
- totalKeyCount += Object.keys(roomData.sessions).length;
2690
- }
2691
- return totalKeyCount;
617
+ */
618
+ setNotifTimelineSet(set) {
619
+ this.notifTimelineSet = set;
2692
620
  }
2693
621
 
2694
622
  /**
2695
- * This method handles the decryption of a full backup, i.e a call to `/room_keys/keys`.
2696
- * It will decrypt the keys in chunks and call the `block` callback for each chunk.
2697
- *
2698
- * @param res - The response from the server containing the keys to be decrypted.
2699
- * @param backupDecryptor - An instance of the BackupDecryptor class used to decrypt the keys.
2700
- * @param chunkSize - The size of the chunks to be processed at a time.
2701
- * @param block - A callback function that is called for each chunk of keys.
623
+ * Gets the cached capabilities of the homeserver, returning cached ones if available.
624
+ * If there are no cached capabilities and none can be fetched, throw an exception.
2702
625
  *
2703
- * @returns A promise that resolves when the decryption is complete.
626
+ * @returns Promise resolving with The capabilities of the homeserver
2704
627
  */
2705
- handleDecryptionOfAFullBackup(res, backupDecryptor, chunkSize, block) {
628
+ getCapabilities() {
629
+ var _this3 = this;
2706
630
  return _asyncToGenerator(function* () {
2707
- var rooms = res.rooms;
2708
- var groupChunkCount = 0;
2709
- var chunkGroupByRoom = new Map();
2710
- var handleChunkCallback = /*#__PURE__*/function () {
2711
- var _ref4 = _asyncToGenerator(function* (roomChunks) {
2712
- var currentChunk = [];
2713
- for (var _roomId of roomChunks.keys()) {
2714
- var decryptedSessions = yield backupDecryptor.decryptSessions(roomChunks.get(_roomId));
2715
- for (var _sessionId in decryptedSessions) {
2716
- var _k2 = decryptedSessions[_sessionId];
2717
- _k2.room_id = _roomId;
2718
- currentChunk.push(_k2);
2719
- }
2720
- }
2721
- yield block(currentChunk);
2722
- });
2723
- return function handleChunkCallback(_x3) {
2724
- return _ref4.apply(this, arguments);
2725
- };
2726
- }();
2727
- for (var [_roomId2, roomData] of Object.entries(rooms)) {
2728
- if (!roomData.sessions) continue;
2729
- chunkGroupByRoom.set(_roomId2, {});
2730
- for (var [_sessionId2, session] of Object.entries(roomData.sessions)) {
2731
- var sessionsForRoom = chunkGroupByRoom.get(_roomId2);
2732
- sessionsForRoom[_sessionId2] = session;
2733
- groupChunkCount += 1;
2734
- if (groupChunkCount >= chunkSize) {
2735
- // We have enough chunks to decrypt
2736
- yield handleChunkCallback(chunkGroupByRoom);
2737
- chunkGroupByRoom = new Map();
2738
- // There might be remaining keys for that room, so add back an entry for the current room.
2739
- chunkGroupByRoom.set(_roomId2, {});
2740
- groupChunkCount = 0;
2741
- }
2742
- }
2743
- }
2744
-
2745
- // Handle remaining chunk if needed
2746
- if (groupChunkCount > 0) {
2747
- yield handleChunkCallback(chunkGroupByRoom);
2748
- }
631
+ var caps = _this3.serverCapabilitiesService.getCachedCapabilities();
632
+ if (caps) return caps;
633
+ return _this3.serverCapabilitiesService.fetchCapabilities();
2749
634
  })();
2750
635
  }
2751
- deleteKeysFromBackup(roomId, sessionId, version) {
2752
- var _this26 = this;
636
+
637
+ /**
638
+ * Gets the cached capabilities of the homeserver. If none have been fetched yet,
639
+ * return undefined.
640
+ *
641
+ * @returns The capabilities of the homeserver
642
+ */
643
+ getCachedCapabilities() {
644
+ return this.serverCapabilitiesService.getCachedCapabilities();
645
+ }
646
+
647
+ /**
648
+ * Fetches the latest capabilities from the homeserver, ignoring any cached
649
+ * versions. The newly returned version is cached.
650
+ *
651
+ * @returns A promise which resolves to the capabilities of the homeserver
652
+ */
653
+ fetchCapabilities() {
654
+ return this.serverCapabilitiesService.fetchCapabilities();
655
+ }
656
+
657
+ /**
658
+ * @deprecated Does nothing.
659
+ */
660
+ uploadKeys() {
661
+ var _this4 = this;
2753
662
  return _asyncToGenerator(function* () {
2754
- var path = _this26.makeKeyBackupPath(roomId, sessionId, version);
2755
- yield _this26.http.authedRequest(Method.Delete, path.path, path.queryData, undefined, {
2756
- prefix: ClientPrefix.V3
2757
- });
663
+ _this4.logger.warn("MatrixClient.uploadKeys is deprecated");
2758
664
  })();
2759
665
  }
2760
666
 
@@ -2876,10 +782,10 @@ export class MatrixClient extends TypedEventEmitter {
2876
782
  * @returns Rejects: with an error response.
2877
783
  */
2878
784
  getAccountDataFromServer(eventType) {
2879
- var _this27 = this;
785
+ var _this5 = this;
2880
786
  return _asyncToGenerator(function* () {
2881
- if (_this27.isInitialSyncComplete()) {
2882
- var _event = _this27.store.getAccountData(eventType);
787
+ if (_this5.isInitialSyncComplete()) {
788
+ var _event = _this5.store.getAccountData(eventType);
2883
789
  if (!_event) {
2884
790
  return null;
2885
791
  }
@@ -2888,11 +794,11 @@ export class MatrixClient extends TypedEventEmitter {
2888
794
  return _event.getContent();
2889
795
  }
2890
796
  var path = utils.encodeUri("/user/$userId/account_data/$type", {
2891
- $userId: _this27.credentials.userId,
797
+ $userId: _this5.credentials.userId,
2892
798
  $type: eventType
2893
799
  });
2894
800
  try {
2895
- return yield _this27.http.authedRequest(Method.Get, path);
801
+ return yield _this5.http.authedRequest(Method.Get, path);
2896
802
  } catch (e) {
2897
803
  var _data;
2898
804
  if (((_data = e.data) === null || _data === void 0 ? void 0 : _data.errcode) === "M_NOT_FOUND") {
@@ -2903,22 +809,22 @@ export class MatrixClient extends TypedEventEmitter {
2903
809
  })();
2904
810
  }
2905
811
  deleteAccountData(eventType) {
2906
- var _this28 = this;
812
+ var _this6 = this;
2907
813
  return _asyncToGenerator(function* () {
2908
- var msc3391DeleteAccountDataServerSupport = _this28.canSupport.get(Feature.AccountDataDeletion);
814
+ var msc3391DeleteAccountDataServerSupport = _this6.canSupport.get(Feature.AccountDataDeletion);
2909
815
  // if deletion is not supported overwrite with empty content
2910
816
  if (msc3391DeleteAccountDataServerSupport === ServerSupport.Unsupported) {
2911
- yield _this28.setAccountData(eventType, {});
817
+ yield _this6.setAccountData(eventType, {});
2912
818
  return;
2913
819
  }
2914
820
  var path = utils.encodeUri("/user/$userId/account_data/$type", {
2915
- $userId: _this28.getSafeUserId(),
821
+ $userId: _this6.getSafeUserId(),
2916
822
  $type: eventType
2917
823
  });
2918
824
  var options = msc3391DeleteAccountDataServerSupport === ServerSupport.Unstable ? {
2919
825
  prefix: "/_matrix/client/unstable/org.matrix.msc3391"
2920
826
  } : undefined;
2921
- return yield _this28.http.authedRequest(Method.Delete, path, undefined, undefined, options);
827
+ return yield _this6.http.authedRequest(Method.Delete, path, undefined, undefined, options);
2922
828
  })();
2923
829
  }
2924
830
 
@@ -2965,20 +871,20 @@ export class MatrixClient extends TypedEventEmitter {
2965
871
  * @returns Rejects: with an error response.
2966
872
  */
2967
873
  joinRoom(roomIdOrAlias) {
2968
- var _arguments3 = arguments,
2969
- _this29 = this;
874
+ var _arguments = arguments,
875
+ _this7 = this;
2970
876
  return _asyncToGenerator(function* () {
2971
- var opts = _arguments3.length > 1 && _arguments3[1] !== undefined ? _arguments3[1] : {};
877
+ var opts = _arguments.length > 1 && _arguments[1] !== undefined ? _arguments[1] : {};
2972
878
  if (opts.syncRoom === undefined) {
2973
879
  opts.syncRoom = true;
2974
880
  }
2975
- var room = _this29.getRoom(roomIdOrAlias);
2976
- if (room !== null && room !== void 0 && room.hasMembershipState(_this29.credentials.userId, KnownMembership.Join)) return room;
881
+ var room = _this7.getRoom(roomIdOrAlias);
882
+ if (room !== null && room !== void 0 && room.hasMembershipState(_this7.credentials.userId, KnownMembership.Join)) return room;
2977
883
  var signPromise = Promise.resolve();
2978
884
  if (opts.inviteSignUrl) {
2979
885
  var _url = new URL(opts.inviteSignUrl);
2980
- _url.searchParams.set("mxid", _this29.credentials.userId);
2981
- signPromise = _this29.http.requestOtherUrl(Method.Post, _url);
886
+ _url.searchParams.set("mxid", _this7.credentials.userId);
887
+ signPromise = _this7.http.requestOtherUrl(Method.Post, _url);
2982
888
  }
2983
889
  var queryParams = {};
2984
890
  if (opts.viaServers) {
@@ -2994,14 +900,14 @@ export class MatrixClient extends TypedEventEmitter {
2994
900
  var path = utils.encodeUri("/join/$roomid", {
2995
901
  $roomid: roomIdOrAlias
2996
902
  });
2997
- var res = yield _this29.http.authedRequest(Method.Post, path, queryParams, data);
903
+ var res = yield _this7.http.authedRequest(Method.Post, path, queryParams, data);
2998
904
  var roomId = res.room_id;
2999
905
  // In case we were originally given an alias, check the room cache again
3000
906
  // with the resolved ID - this method is supposed to no-op if we already
3001
907
  // were in the room, after all.
3002
- var resolvedRoom = _this29.getRoom(roomId);
3003
- if (resolvedRoom !== null && resolvedRoom !== void 0 && resolvedRoom.hasMembershipState(_this29.credentials.userId, KnownMembership.Join)) return resolvedRoom;
3004
- var syncApi = new SyncApi(_this29, _this29.clientOpts, _this29.buildSyncApiOptions());
908
+ var resolvedRoom = _this7.getRoom(roomId);
909
+ if (resolvedRoom !== null && resolvedRoom !== void 0 && resolvedRoom.hasMembershipState(_this7.credentials.userId, KnownMembership.Join)) return resolvedRoom;
910
+ var syncApi = new SyncApi(_this7, _this7.clientOpts, _this7.buildSyncApiOptions());
3005
911
  var syncRoom = syncApi.createRoom(roomId);
3006
912
  if (opts.syncRoom) {
3007
913
  // v2 will do this for us
@@ -3171,17 +1077,17 @@ export class MatrixClient extends TypedEventEmitter {
3171
1077
  * @returns Rejects: with an error response.
3172
1078
  */
3173
1079
  setPowerLevel(roomId, userId, powerLevel) {
3174
- var _this30 = this;
1080
+ var _this8 = this;
3175
1081
  return _asyncToGenerator(function* () {
3176
1082
  var _content;
3177
1083
  var content;
3178
- if (_this30.clientRunning && _this30.isInitialSyncComplete()) {
3179
- var _this30$getRoom;
3180
- content = (_this30$getRoom = _this30.getRoom(roomId)) === null || _this30$getRoom === void 0 || (_this30$getRoom = _this30$getRoom.currentState) === null || _this30$getRoom === void 0 || (_this30$getRoom = _this30$getRoom.getStateEvents(EventType.RoomPowerLevels, "")) === null || _this30$getRoom === void 0 ? void 0 : _this30$getRoom.getContent();
1084
+ if (_this8.clientRunning && _this8.isInitialSyncComplete()) {
1085
+ var _this8$getRoom;
1086
+ content = (_this8$getRoom = _this8.getRoom(roomId)) === null || _this8$getRoom === void 0 || (_this8$getRoom = _this8$getRoom.currentState) === null || _this8$getRoom === void 0 || (_this8$getRoom = _this8$getRoom.getStateEvents(EventType.RoomPowerLevels, "")) === null || _this8$getRoom === void 0 ? void 0 : _this8$getRoom.getContent();
3181
1087
  }
3182
1088
  if (!content) {
3183
1089
  try {
3184
- content = yield _this30.getStateEvent(roomId, EventType.RoomPowerLevels, "");
1090
+ content = yield _this8.getStateEvent(roomId, EventType.RoomPowerLevels, "");
3185
1091
  } catch (e) {
3186
1092
  // It is possible for a Matrix room to not have a power levels event
3187
1093
  if (e instanceof MatrixError && e.errcode === "M_NOT_FOUND") {
@@ -3206,7 +1112,7 @@ export class MatrixClient extends TypedEventEmitter {
3206
1112
  content.users[user] = powerLevel;
3207
1113
  }
3208
1114
  }
3209
- return _this30.sendStateEvent(roomId, EventType.RoomPowerLevels, content, "");
1115
+ return _this8.sendStateEvent(roomId, EventType.RoomPowerLevels, content, "");
3210
1116
  })();
3211
1117
  }
3212
1118
 
@@ -3216,9 +1122,9 @@ export class MatrixClient extends TypedEventEmitter {
3216
1122
  */
3217
1123
  // eslint-disable-next-line @typescript-eslint/naming-convention
3218
1124
  unstable_createLiveBeacon(roomId, beaconInfoContent) {
3219
- var _this31 = this;
1125
+ var _this9 = this;
3220
1126
  return _asyncToGenerator(function* () {
3221
- return _this31.unstable_setLiveBeacon(roomId, beaconInfoContent);
1127
+ return _this9.unstable_setLiveBeacon(roomId, beaconInfoContent);
3222
1128
  })();
3223
1129
  }
3224
1130
 
@@ -3230,9 +1136,9 @@ export class MatrixClient extends TypedEventEmitter {
3230
1136
  */
3231
1137
  // eslint-disable-next-line @typescript-eslint/naming-convention
3232
1138
  unstable_setLiveBeacon(roomId, beaconInfoContent) {
3233
- var _this32 = this;
1139
+ var _this10 = this;
3234
1140
  return _asyncToGenerator(function* () {
3235
- return _this32.sendStateEvent(roomId, M_BEACON_INFO.name, beaconInfoContent, _this32.getUserId());
1141
+ return _this10.sendStateEvent(roomId, M_BEACON_INFO.name, beaconInfoContent, _this10.getUserId());
3236
1142
  })();
3237
1143
  }
3238
1144
  sendEvent(roomId, threadIdOrEventType, eventTypeOrContent, contentOrTxnId, txnIdOrVoid) {
@@ -3380,44 +1286,34 @@ export class MatrixClient extends TypedEventEmitter {
3380
1286
  */
3381
1287
 
3382
1288
  encryptAndSendEvent(room, event, delayOpts) {
3383
- var _this33 = this;
1289
+ var _this11 = this;
3384
1290
  return _asyncToGenerator(function* () {
3385
1291
  if (delayOpts) {
3386
- return _this33.sendEventHttpRequest(event, delayOpts);
1292
+ return _this11.sendEventHttpRequest(event, delayOpts);
3387
1293
  }
3388
1294
  try {
3389
- var cancelled;
3390
- _this33.eventsBeingEncrypted.add(event.getId());
3391
- try {
3392
- yield _this33.encryptEventIfNeeded(event, room !== null && room !== void 0 ? room : undefined);
3393
- } finally {
3394
- cancelled = !_this33.eventsBeingEncrypted.delete(event.getId());
3395
- }
3396
- if (cancelled) {
3397
- // cancelled via MatrixClient::cancelPendingEvent
3398
- return {};
3399
- }
1295
+ _this11.eventsBeingEncrypted.add(event.getId());
3400
1296
 
3401
1297
  // encryptEventIfNeeded may have updated the status from SENDING to ENCRYPTING. If so, we need
3402
1298
  // to put it back.
3403
1299
  if (event.status === EventStatus.ENCRYPTING) {
3404
- _this33.updatePendingEventStatus(room, event, EventStatus.SENDING);
1300
+ _this11.updatePendingEventStatus(room, event, EventStatus.SENDING);
3405
1301
  }
3406
1302
  var promise = null;
3407
- if (_this33.scheduler) {
1303
+ if (_this11.scheduler) {
3408
1304
  // if this returns a promise then the scheduler has control now and will
3409
1305
  // resolve/reject when it is done. Internally, the scheduler will invoke
3410
1306
  // processFn which is set to this._sendEventHttpRequest so the same code
3411
1307
  // path is executed regardless.
3412
- promise = _this33.scheduler.queueEvent(event);
3413
- if (promise && _this33.scheduler.getQueueForEvent(event).length > 1) {
1308
+ promise = _this11.scheduler.queueEvent(event);
1309
+ if (promise && _this11.scheduler.getQueueForEvent(event).length > 1) {
3414
1310
  // event is processed FIFO so if the length is 2 or more we know
3415
1311
  // this event is stuck behind an earlier event.
3416
- _this33.updatePendingEventStatus(room, event, EventStatus.QUEUED);
1312
+ _this11.updatePendingEventStatus(room, event, EventStatus.QUEUED);
3417
1313
  }
3418
1314
  }
3419
1315
  if (!promise) {
3420
- promise = _this33.sendEventHttpRequest(event);
1316
+ promise = _this11.sendEventHttpRequest(event);
3421
1317
  if (room) {
3422
1318
  promise = promise.then(res => {
3423
1319
  room.updatePendingEvent(event, EventStatus.SENT, res["event_id"]);
@@ -3427,15 +1323,15 @@ export class MatrixClient extends TypedEventEmitter {
3427
1323
  }
3428
1324
  return yield promise;
3429
1325
  } catch (err) {
3430
- _this33.logger.error("Error sending event", err);
1326
+ _this11.logger.error("Error sending event", err);
3431
1327
  try {
3432
1328
  // set the error on the event before we update the status:
3433
1329
  // updating the status emits the event, so the state should be
3434
1330
  // consistent at that point.
3435
1331
  event.error = err;
3436
- _this33.updatePendingEventStatus(room, event, EventStatus.NOT_SENT);
1332
+ _this11.updatePendingEventStatus(room, event, EventStatus.NOT_SENT);
3437
1333
  } catch (e) {
3438
- _this33.logger.error("Exception in error handler!", e);
1334
+ _this11.logger.error("Exception in error handler!", e);
3439
1335
  }
3440
1336
  if (err instanceof MatrixError) {
3441
1337
  err.event = event;
@@ -3444,70 +1340,6 @@ export class MatrixClient extends TypedEventEmitter {
3444
1340
  }
3445
1341
  })();
3446
1342
  }
3447
- encryptEventIfNeeded(event, room) {
3448
- var _this34 = this;
3449
- return _asyncToGenerator(function* () {
3450
- // If the room is unknown, we cannot encrypt for it
3451
- if (!room) return;
3452
- if (!(yield _this34.shouldEncryptEventForRoom(event, room))) return;
3453
- if (!_this34.cryptoBackend && _this34.usingExternalCrypto) {
3454
- // The client has opted to allow sending messages to encrypted
3455
- // rooms even if the room is encrypted, and we haven't set up
3456
- // crypto. This is useful for users of matrix-org/pantalaimon
3457
- return;
3458
- }
3459
- if (!_this34.cryptoBackend) {
3460
- throw new Error("This room is configured to use encryption, but your client does not support encryption.");
3461
- }
3462
- _this34.updatePendingEventStatus(room, event, EventStatus.ENCRYPTING);
3463
- yield _this34.cryptoBackend.encryptEvent(event, room);
3464
- })();
3465
- }
3466
-
3467
- /**
3468
- * Determine whether a given event should be encrypted when we send it to the given room.
3469
- *
3470
- * This takes into account event type and room configuration.
3471
- */
3472
- shouldEncryptEventForRoom(event, room) {
3473
- var _this35 = this;
3474
- return _asyncToGenerator(function* () {
3475
- var _this35$cryptoBackend;
3476
- if (event.isEncrypted()) {
3477
- // this event has already been encrypted; this happens if the
3478
- // encryption step succeeded, but the send step failed on the first
3479
- // attempt.
3480
- return false;
3481
- }
3482
- if (event.getType() === EventType.Reaction) {
3483
- // For reactions, there is a very little gained by encrypting the entire
3484
- // event, as relation data is already kept in the clear. Event
3485
- // encryption for a reaction effectively only obscures the event type,
3486
- // but the purpose is still obvious from the relation data, so nothing
3487
- // is really gained. It also causes quite a few problems, such as:
3488
- // * triggers notifications via default push rules
3489
- // * prevents server-side bundling for reactions
3490
- // The reaction key / content / emoji value does warrant encrypting, but
3491
- // this will be handled separately by encrypting just this value.
3492
- // See https://github.com/matrix-org/matrix-doc/pull/1849#pullrequestreview-248763642
3493
- return false;
3494
- }
3495
- if (event.isRedaction()) {
3496
- // Redactions do not support encryption in the spec at this time.
3497
- // Whilst it mostly worked in some clients, it wasn't compliant.
3498
- return false;
3499
- }
3500
-
3501
- // If the room has an m.room.encryption event, we should encrypt.
3502
- if (room.hasEncryptionStateEvent()) return true;
3503
-
3504
- // If we have a crypto impl, and *it* thinks we should encrypt, then we should.
3505
- if (yield (_this35$cryptoBackend = _this35.cryptoBackend) === null || _this35$cryptoBackend === void 0 ? void 0 : _this35$cryptoBackend.isEncryptionEnabledInRoom(room.roomId)) return true;
3506
-
3507
- // Otherwise, no need to encrypt.
3508
- return false;
3509
- })();
3510
- }
3511
1343
 
3512
1344
  /**
3513
1345
  * Returns the eventType that should be used taking encryption into account
@@ -3770,13 +1602,13 @@ export class MatrixClient extends TypedEventEmitter {
3770
1602
  */
3771
1603
  // eslint-disable-next-line
3772
1604
  _unstable_sendDelayedEvent(roomId, delayOpts, threadId, eventType, content, txnId) {
3773
- var _this36 = this;
1605
+ var _this12 = this;
3774
1606
  return _asyncToGenerator(function* () {
3775
- if (!(yield _this36.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {
1607
+ if (!(yield _this12.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {
3776
1608
  throw Error("Server does not support the delayed events API");
3777
1609
  }
3778
- _this36.addThreadRelationIfNeeded(content, threadId, roomId);
3779
- return _this36.sendCompleteEvent(roomId, threadId, {
1610
+ _this12.addThreadRelationIfNeeded(content, threadId, roomId);
1611
+ return _this12.sendCompleteEvent(roomId, threadId, {
3780
1612
  type: eventType,
3781
1613
  content
3782
1614
  }, delayOpts, txnId);
@@ -3791,12 +1623,12 @@ export class MatrixClient extends TypedEventEmitter {
3791
1623
  */
3792
1624
  // eslint-disable-next-line
3793
1625
  _unstable_sendDelayedStateEvent(roomId, delayOpts, eventType, content) {
3794
- var _arguments4 = arguments,
3795
- _this37 = this;
1626
+ var _arguments2 = arguments,
1627
+ _this13 = this;
3796
1628
  return _asyncToGenerator(function* () {
3797
- var stateKey = _arguments4.length > 4 && _arguments4[4] !== undefined ? _arguments4[4] : "";
3798
- var opts = _arguments4.length > 5 && _arguments4[5] !== undefined ? _arguments4[5] : {};
3799
- if (!(yield _this37.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {
1629
+ var stateKey = _arguments2.length > 4 && _arguments2[4] !== undefined ? _arguments2[4] : "";
1630
+ var opts = _arguments2.length > 5 && _arguments2[5] !== undefined ? _arguments2[5] : {};
1631
+ if (!(yield _this13.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {
3800
1632
  throw Error("Server does not support the delayed events API");
3801
1633
  }
3802
1634
  var pathParams = {
@@ -3808,7 +1640,7 @@ export class MatrixClient extends TypedEventEmitter {
3808
1640
  if (stateKey !== undefined) {
3809
1641
  path = utils.encodeUri(path + "/$stateKey", pathParams);
3810
1642
  }
3811
- return _this37.http.authedRequest(Method.Put, path, getUnstableDelayQueryOpts(delayOpts), content, opts);
1643
+ return _this13.http.authedRequest(Method.Put, path, getUnstableDelayQueryOpts(delayOpts), content, opts);
3812
1644
  })();
3813
1645
  }
3814
1646
 
@@ -3820,15 +1652,15 @@ export class MatrixClient extends TypedEventEmitter {
3820
1652
  */
3821
1653
  // eslint-disable-next-line
3822
1654
  _unstable_getDelayedEvents(fromToken) {
3823
- var _this38 = this;
1655
+ var _this14 = this;
3824
1656
  return _asyncToGenerator(function* () {
3825
- if (!(yield _this38.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {
1657
+ if (!(yield _this14.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {
3826
1658
  throw Error("Server does not support the delayed events API");
3827
1659
  }
3828
1660
  var queryDict = fromToken ? {
3829
1661
  from: fromToken
3830
1662
  } : undefined;
3831
- return yield _this38.http.authedRequest(Method.Get, "/delayed_events", queryDict, undefined, {
1663
+ return yield _this14.http.authedRequest(Method.Get, "/delayed_events", queryDict, undefined, {
3832
1664
  prefix: "".concat(ClientPrefix.Unstable, "/").concat(UNSTABLE_MSC4140_DELAYED_EVENTS)
3833
1665
  });
3834
1666
  })();
@@ -3842,9 +1674,9 @@ export class MatrixClient extends TypedEventEmitter {
3842
1674
  */
3843
1675
  // eslint-disable-next-line
3844
1676
  _unstable_updateDelayedEvent(delayId, action) {
3845
- var _this39 = this;
1677
+ var _this15 = this;
3846
1678
  return _asyncToGenerator(function* () {
3847
- if (!(yield _this39.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {
1679
+ if (!(yield _this15.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {
3848
1680
  throw Error("Server does not support the delayed events API");
3849
1681
  }
3850
1682
  var path = utils.encodeUri("/delayed_events/$delayId", {
@@ -3853,7 +1685,7 @@ export class MatrixClient extends TypedEventEmitter {
3853
1685
  var data = {
3854
1686
  action
3855
1687
  };
3856
- return yield _this39.http.authedRequest(Method.Post, path, undefined, data, {
1688
+ return yield _this15.http.authedRequest(Method.Post, path, undefined, data, {
3857
1689
  prefix: "".concat(ClientPrefix.Unstable, "/").concat(UNSTABLE_MSC4140_DELAYED_EVENTS)
3858
1690
  });
3859
1691
  })();
@@ -3870,11 +1702,11 @@ export class MatrixClient extends TypedEventEmitter {
3870
1702
  * @returns Rejects: with an error response.
3871
1703
  */
3872
1704
  sendReceipt(event, receiptType, body) {
3873
- var _arguments5 = arguments,
3874
- _this40 = this;
1705
+ var _arguments3 = arguments,
1706
+ _this16 = this;
3875
1707
  return _asyncToGenerator(function* () {
3876
- var unthreaded = _arguments5.length > 3 && _arguments5[3] !== undefined ? _arguments5[3] : false;
3877
- if (_this40.isGuest()) {
1708
+ var unthreaded = _arguments3.length > 3 && _arguments3[3] !== undefined ? _arguments3[3] : false;
1709
+ if (_this16.isGuest()) {
3878
1710
  return Promise.resolve({}); // guests cannot send receipts so don't bother.
3879
1711
  }
3880
1712
  var path = utils.encodeUri("/rooms/$roomId/receipt/$receiptType/$eventId", {
@@ -3885,14 +1717,14 @@ export class MatrixClient extends TypedEventEmitter {
3885
1717
 
3886
1718
  // Unless we're explicitly making an unthreaded receipt or we don't
3887
1719
  // support threads, include the `thread_id` property in the body.
3888
- var shouldAddThreadId = !unthreaded && _this40.supportsThreads();
1720
+ var shouldAddThreadId = !unthreaded && _this16.supportsThreads();
3889
1721
  var fullBody = shouldAddThreadId ? _objectSpread(_objectSpread({}, body), {}, {
3890
1722
  thread_id: threadIdForReceipt(event)
3891
1723
  }) : body;
3892
- var promise = _this40.http.authedRequest(Method.Post, path, undefined, fullBody || {});
3893
- var room = _this40.getRoom(event.getRoomId());
3894
- if (room && _this40.credentials.userId) {
3895
- room.addLocalEchoReceipt(_this40.credentials.userId, event, receiptType, unthreaded);
1724
+ var promise = _this16.http.authedRequest(Method.Post, path, undefined, fullBody || {});
1725
+ var room = _this16.getRoom(event.getRoomId());
1726
+ if (room && _this16.credentials.userId) {
1727
+ room.addLocalEchoReceipt(_this16.credentials.userId, event, receiptType, unthreaded);
3896
1728
  }
3897
1729
  return promise;
3898
1730
  })();
@@ -3906,18 +1738,18 @@ export class MatrixClient extends TypedEventEmitter {
3906
1738
  * @returns Rejects: with an error response.
3907
1739
  */
3908
1740
  sendReadReceipt(event) {
3909
- var _arguments6 = arguments,
3910
- _this41 = this;
1741
+ var _arguments4 = arguments,
1742
+ _this17 = this;
3911
1743
  return _asyncToGenerator(function* () {
3912
- var receiptType = _arguments6.length > 1 && _arguments6[1] !== undefined ? _arguments6[1] : ReceiptType.Read;
3913
- var unthreaded = _arguments6.length > 2 && _arguments6[2] !== undefined ? _arguments6[2] : false;
1744
+ var receiptType = _arguments4.length > 1 && _arguments4[1] !== undefined ? _arguments4[1] : ReceiptType.Read;
1745
+ var unthreaded = _arguments4.length > 2 && _arguments4[2] !== undefined ? _arguments4[2] : false;
3914
1746
  if (!event) return;
3915
1747
  var eventId = event.getId();
3916
- var room = _this41.getRoom(event.getRoomId());
1748
+ var room = _this17.getRoom(event.getRoomId());
3917
1749
  if (room !== null && room !== void 0 && room.hasPendingEvent(eventId)) {
3918
1750
  throw new Error("Cannot set read receipt to a pending event (".concat(eventId, ")"));
3919
1751
  }
3920
- return _this41.sendReceipt(event, receiptType, {}, unthreaded);
1752
+ return _this17.sendReceipt(event, receiptType, {}, unthreaded);
3921
1753
  })();
3922
1754
  }
3923
1755
 
@@ -3936,9 +1768,9 @@ export class MatrixClient extends TypedEventEmitter {
3936
1768
  * @returns Promise which resolves: the empty object, `{}`.
3937
1769
  */
3938
1770
  setRoomReadMarkers(roomId, rmEventId, rrEvent, rpEvent) {
3939
- var _this42 = this;
1771
+ var _this18 = this;
3940
1772
  return _asyncToGenerator(function* () {
3941
- var room = _this42.getRoom(roomId);
1773
+ var room = _this18.getRoom(roomId);
3942
1774
  if (room !== null && room !== void 0 && room.hasPendingEvent(rmEventId)) {
3943
1775
  throw new Error("Cannot set read marker to a pending event (".concat(rmEventId, ")"));
3944
1776
  }
@@ -3950,7 +1782,7 @@ export class MatrixClient extends TypedEventEmitter {
3950
1782
  if (room !== null && room !== void 0 && room.hasPendingEvent(rrEventId)) {
3951
1783
  throw new Error("Cannot set read receipt to a pending event (".concat(rrEventId, ")"));
3952
1784
  }
3953
- room === null || room === void 0 || room.addLocalEchoReceipt(_this42.credentials.userId, rrEvent, ReceiptType.Read);
1785
+ room === null || room === void 0 || room.addLocalEchoReceipt(_this18.credentials.userId, rrEvent, ReceiptType.Read);
3954
1786
  }
3955
1787
 
3956
1788
  // Add the optional private RR update, do local echo like `sendReceipt`
@@ -3960,9 +1792,9 @@ export class MatrixClient extends TypedEventEmitter {
3960
1792
  if (room !== null && room !== void 0 && room.hasPendingEvent(rpEventId)) {
3961
1793
  throw new Error("Cannot set read receipt to a pending event (".concat(rpEventId, ")"));
3962
1794
  }
3963
- room === null || room === void 0 || room.addLocalEchoReceipt(_this42.credentials.userId, rpEvent, ReceiptType.ReadPrivate);
1795
+ room === null || room === void 0 || room.addLocalEchoReceipt(_this18.credentials.userId, rpEvent, ReceiptType.ReadPrivate);
3964
1796
  }
3965
- return yield _this42.setRoomReadMarkersHttpRequest(roomId, rmEventId, rrEventId, rpEventId);
1797
+ return yield _this18.setRoomReadMarkersHttpRequest(roomId, rmEventId, rrEventId, rpEventId);
3966
1798
  })();
3967
1799
  }
3968
1800
 
@@ -4146,13 +1978,13 @@ export class MatrixClient extends TypedEventEmitter {
4146
1978
  * @returns Rejects: with an error response.
4147
1979
  */
4148
1980
  inviteByThreePid(roomId, medium, address) {
4149
- var _this43 = this;
1981
+ var _this19 = this;
4150
1982
  return _asyncToGenerator(function* () {
4151
- var _this43$identityServe;
1983
+ var _this19$identityServe;
4152
1984
  var path = utils.encodeUri("/rooms/$roomId/invite", {
4153
1985
  $roomId: roomId
4154
1986
  });
4155
- var identityServerUrl = _this43.getIdentityServerUrl(true);
1987
+ var identityServerUrl = _this19.getIdentityServerUrl(true);
4156
1988
  if (!identityServerUrl) {
4157
1989
  return Promise.reject(new MatrixError({
4158
1990
  error: "No supplied identity server URL",
@@ -4164,13 +1996,13 @@ export class MatrixClient extends TypedEventEmitter {
4164
1996
  medium: medium,
4165
1997
  address: address
4166
1998
  };
4167
- if ((_this43$identityServe = _this43.identityServer) !== null && _this43$identityServe !== void 0 && _this43$identityServe.getAccessToken) {
4168
- var identityAccessToken = yield _this43.identityServer.getAccessToken();
1999
+ if ((_this19$identityServe = _this19.identityServer) !== null && _this19$identityServe !== void 0 && _this19$identityServe.getAccessToken) {
2000
+ var identityAccessToken = yield _this19.identityServer.getAccessToken();
4169
2001
  if (identityAccessToken) {
4170
2002
  params["id_access_token"] = identityAccessToken;
4171
2003
  }
4172
2004
  }
4173
- return _this43.http.authedRequest(Method.Post, path, undefined, params);
2005
+ return _this19.http.authedRequest(Method.Post, path, undefined, params);
4174
2006
  })();
4175
2007
  }
4176
2008
 
@@ -4238,18 +2070,18 @@ export class MatrixClient extends TypedEventEmitter {
4238
2070
  * @returns Rejects: with an error response.
4239
2071
  */
4240
2072
  forget(roomId) {
4241
- var _arguments7 = arguments,
4242
- _this44 = this;
2073
+ var _arguments5 = arguments,
2074
+ _this20 = this;
4243
2075
  return _asyncToGenerator(function* () {
4244
- var deleteRoom = _arguments7.length > 1 && _arguments7[1] !== undefined ? _arguments7[1] : true;
2076
+ var deleteRoom = _arguments5.length > 1 && _arguments5[1] !== undefined ? _arguments5[1] : true;
4245
2077
  // API returns an empty object
4246
2078
  var path = utils.encodeUri("/rooms/$room_id/forget", {
4247
2079
  $room_id: roomId
4248
2080
  });
4249
- var response = yield _this44.http.authedRequest(Method.Post, path);
2081
+ var response = yield _this20.http.authedRequest(Method.Post, path);
4250
2082
  if (deleteRoom) {
4251
- _this44.store.removeRoom(roomId);
4252
- _this44.emit(ClientEvent.DeleteRoom, roomId);
2083
+ _this20.store.removeRoom(roomId);
2084
+ _this20.emit(ClientEvent.DeleteRoom, roomId);
4253
2085
  }
4254
2086
  return response;
4255
2087
  })();
@@ -4363,13 +2195,13 @@ export class MatrixClient extends TypedEventEmitter {
4363
2195
  * @returns Rejects: with an error response.
4364
2196
  */
4365
2197
  setDisplayName(name) {
4366
- var _this45 = this;
2198
+ var _this21 = this;
4367
2199
  return _asyncToGenerator(function* () {
4368
- var prom = yield _this45.setProfileInfo("displayname", {
2200
+ var prom = yield _this21.setProfileInfo("displayname", {
4369
2201
  displayname: name
4370
2202
  });
4371
2203
  // XXX: synthesise a profile update for ourselves because Synapse is broken and won't
4372
- var user = _this45.getUser(_this45.getUserId());
2204
+ var user = _this21.getUser(_this21.getUserId());
4373
2205
  if (user) {
4374
2206
  user.displayName = name;
4375
2207
  user.emit(UserEvent.DisplayName, user.events.presence, user);
@@ -4383,13 +2215,13 @@ export class MatrixClient extends TypedEventEmitter {
4383
2215
  * @returns Rejects: with an error response.
4384
2216
  */
4385
2217
  setAvatarUrl(url) {
4386
- var _this46 = this;
2218
+ var _this22 = this;
4387
2219
  return _asyncToGenerator(function* () {
4388
- var prom = yield _this46.setProfileInfo("avatar_url", {
2220
+ var prom = yield _this22.setProfileInfo("avatar_url", {
4389
2221
  avatar_url: url
4390
2222
  });
4391
2223
  // XXX: synthesise a profile update for ourselves because Synapse is broken and won't
4392
- var user = _this46.getUser(_this46.getUserId());
2224
+ var user = _this22.getUser(_this22.getUserId());
4393
2225
  if (user) {
4394
2226
  user.avatarUrl = url;
4395
2227
  user.emit(UserEvent.AvatarUrl, user.events.presence, user);
@@ -4430,10 +2262,10 @@ export class MatrixClient extends TypedEventEmitter {
4430
2262
  * @param presence - the presence to specify to set_presence of sync calls
4431
2263
  */
4432
2264
  setSyncPresence(presence) {
4433
- var _this47 = this;
2265
+ var _this23 = this;
4434
2266
  return _asyncToGenerator(function* () {
4435
- var _this47$syncApi;
4436
- (_this47$syncApi = _this47.syncApi) === null || _this47$syncApi === void 0 || _this47$syncApi.setPresence(presence);
2267
+ var _this23$syncApi;
2268
+ (_this23$syncApi = _this23.syncApi) === null || _this23$syncApi === void 0 || _this23$syncApi.setPresence(presence);
4437
2269
  })();
4438
2270
  }
4439
2271
 
@@ -4444,16 +2276,16 @@ export class MatrixClient extends TypedEventEmitter {
4444
2276
  * @throws If 'presence' isn't a valid presence enum value.
4445
2277
  */
4446
2278
  setPresence(opts) {
4447
- var _this48 = this;
2279
+ var _this24 = this;
4448
2280
  return _asyncToGenerator(function* () {
4449
2281
  var path = utils.encodeUri("/presence/$userId/status", {
4450
- $userId: _this48.credentials.userId
2282
+ $userId: _this24.credentials.userId
4451
2283
  });
4452
2284
  var validStates = ["offline", "online", "unavailable"];
4453
2285
  if (validStates.indexOf(opts.presence) === -1) {
4454
2286
  throw new Error("Bad presence value: " + opts.presence);
4455
2287
  }
4456
- yield _this48.http.authedRequest(Method.Put, path, undefined, opts);
2288
+ yield _this24.http.authedRequest(Method.Put, path, undefined, opts);
4457
2289
  })();
4458
2290
  }
4459
2291
 
@@ -4562,11 +2394,11 @@ export class MatrixClient extends TypedEventEmitter {
4562
2394
  * {@link EventTimeline} including the given event
4563
2395
  */
4564
2396
  getEventTimeline(timelineSet, eventId) {
4565
- var _this49 = this;
2397
+ var _this25 = this;
4566
2398
  return _asyncToGenerator(function* () {
4567
- var _this49$clientOpts, _ref5, _timelineSet$getTimel, _timelineSet$room$fin;
2399
+ var _this25$clientOpts, _ref2, _timelineSet$getTimel, _timelineSet$room$fin;
4568
2400
  // don't allow any timeline support unless it's been enabled.
4569
- if (!_this49.timelineSupport) {
2401
+ if (!_this25.timelineSupport) {
4570
2402
  throw new Error("timeline support is disabled. Set the 'timelineSupport'" + " parameter to true when creating MatrixClient to enable it.");
4571
2403
  }
4572
2404
  if (!(timelineSet !== null && timelineSet !== void 0 && timelineSet.room)) {
@@ -4575,22 +2407,22 @@ export class MatrixClient extends TypedEventEmitter {
4575
2407
  if (timelineSet.getTimelineForEvent(eventId)) {
4576
2408
  return timelineSet.getTimelineForEvent(eventId);
4577
2409
  }
4578
- if (timelineSet.thread && _this49.supportsThreads()) {
4579
- return _this49.getThreadTimeline(timelineSet, eventId);
2410
+ if (timelineSet.thread && _this25.supportsThreads()) {
2411
+ return _this25.getThreadTimeline(timelineSet, eventId);
4580
2412
  }
4581
2413
  var path = utils.encodeUri("/rooms/$roomId/context/$eventId", {
4582
2414
  $roomId: timelineSet.room.roomId,
4583
2415
  $eventId: eventId
4584
2416
  });
4585
2417
  var params = undefined;
4586
- if ((_this49$clientOpts = _this49.clientOpts) !== null && _this49$clientOpts !== void 0 && _this49$clientOpts.lazyLoadMembers) {
2418
+ if ((_this25$clientOpts = _this25.clientOpts) !== null && _this25$clientOpts !== void 0 && _this25$clientOpts.lazyLoadMembers) {
4587
2419
  params = {
4588
2420
  filter: JSON.stringify(Filter.LAZY_LOADING_MESSAGES_FILTER)
4589
2421
  };
4590
2422
  }
4591
2423
 
4592
2424
  // TODO: we should implement a backoff (as per scrollback()) to deal more nicely with HTTP errors.
4593
- var res = yield _this49.http.authedRequest(Method.Get, path, params);
2425
+ var res = yield _this25.http.authedRequest(Method.Get, path, params);
4594
2426
  if (!res.event) {
4595
2427
  throw new Error("'event' not in '/context' result - homeserver too old?");
4596
2428
  }
@@ -4599,10 +2431,10 @@ export class MatrixClient extends TypedEventEmitter {
4599
2431
  if (timelineSet.getTimelineForEvent(eventId)) {
4600
2432
  return timelineSet.getTimelineForEvent(eventId);
4601
2433
  }
4602
- var mapper = _this49.getEventMapper();
2434
+ var mapper = _this25.getEventMapper();
4603
2435
  var event = mapper(res.event);
4604
2436
  if (event.isRelation(THREAD_RELATION_TYPE.name)) {
4605
- _this49.logger.warn("Tried loading a regular timeline at the position of a thread event");
2437
+ _this25.logger.warn("Tried loading a regular timeline at the position of a thread event");
4606
2438
  return undefined;
4607
2439
  }
4608
2440
  var events = [
@@ -4623,23 +2455,23 @@ export class MatrixClient extends TypedEventEmitter {
4623
2455
  var [timelineEvents, threadedEvents, unknownRelations] = timelineSet.room.partitionThreadedEvents(events);
4624
2456
  timelineSet.addEventsToTimeline(timelineEvents, true, timeline, res.start);
4625
2457
  // The target event is not in a thread but process the contextual events, so we can show any threads around it.
4626
- _this49.processThreadEvents(timelineSet.room, threadedEvents, true);
4627
- _this49.processAggregatedTimelineEvents(timelineSet.room, timelineEvents);
2458
+ _this25.processThreadEvents(timelineSet.room, threadedEvents, true);
2459
+ _this25.processAggregatedTimelineEvents(timelineSet.room, timelineEvents);
4628
2460
  unknownRelations.forEach(event => timelineSet.relations.aggregateChildEvent(event));
4629
2461
 
4630
2462
  // There is no guarantee that the event ended up in "timeline" (we might have switched to a neighbouring
4631
2463
  // timeline) - so check the room's index again. On the other hand, there's no guarantee the event ended up
4632
2464
  // anywhere, if it was later redacted, so we just return the timeline we first thought of.
4633
- return (_ref5 = (_timelineSet$getTimel = timelineSet.getTimelineForEvent(eventId)) !== null && _timelineSet$getTimel !== void 0 ? _timelineSet$getTimel : (_timelineSet$room$fin = timelineSet.room.findThreadForEvent(event)) === null || _timelineSet$room$fin === void 0 ? void 0 : _timelineSet$room$fin.liveTimeline) !== null && _ref5 !== void 0 ? _ref5 :
2465
+ return (_ref2 = (_timelineSet$getTimel = timelineSet.getTimelineForEvent(eventId)) !== null && _timelineSet$getTimel !== void 0 ? _timelineSet$getTimel : (_timelineSet$room$fin = timelineSet.room.findThreadForEvent(event)) === null || _timelineSet$room$fin === void 0 ? void 0 : _timelineSet$room$fin.liveTimeline) !== null && _ref2 !== void 0 ? _ref2 :
4634
2466
  // for Threads degraded support
4635
2467
  timeline;
4636
2468
  })();
4637
2469
  }
4638
2470
  getThreadTimeline(timelineSet, eventId) {
4639
- var _this50 = this;
2471
+ var _this26 = this;
4640
2472
  return _asyncToGenerator(function* () {
4641
- var _this50$clientOpts;
4642
- if (!_this50.supportsThreads()) {
2473
+ var _this26$clientOpts;
2474
+ if (!_this26.supportsThreads()) {
4643
2475
  throw new Error("could not get thread timeline: no client support");
4644
2476
  }
4645
2477
  if (!timelineSet.room) {
@@ -4655,18 +2487,18 @@ export class MatrixClient extends TypedEventEmitter {
4655
2487
  var params = {
4656
2488
  limit: "0"
4657
2489
  };
4658
- if ((_this50$clientOpts = _this50.clientOpts) !== null && _this50$clientOpts !== void 0 && _this50$clientOpts.lazyLoadMembers) {
2490
+ if ((_this26$clientOpts = _this26.clientOpts) !== null && _this26$clientOpts !== void 0 && _this26$clientOpts.lazyLoadMembers) {
4659
2491
  params.filter = JSON.stringify(Filter.LAZY_LOADING_MESSAGES_FILTER);
4660
2492
  }
4661
2493
 
4662
2494
  // TODO: we should implement a backoff (as per scrollback()) to deal more nicely with HTTP errors.
4663
- var res = yield _this50.http.authedRequest(Method.Get, path, params);
4664
- var mapper = _this50.getEventMapper();
2495
+ var res = yield _this26.http.authedRequest(Method.Get, path, params);
2496
+ var mapper = _this26.getEventMapper();
4665
2497
  var event = mapper(res.event);
4666
2498
  if (!timelineSet.canContain(event)) {
4667
2499
  return undefined;
4668
2500
  }
4669
- var recurse = _this50.canSupport.get(Feature.RelationsRecursion) !== ServerSupport.Unsupported;
2501
+ var recurse = _this26.canSupport.get(Feature.RelationsRecursion) !== ServerSupport.Unsupported;
4670
2502
  if (Thread.hasServerSideSupport) {
4671
2503
  if (Thread.hasServerSideFwdPaginationSupport) {
4672
2504
  var _resOlder$next_batch, _resNewer$next_batch, _timelineSet$getTimel2;
@@ -4674,12 +2506,12 @@ export class MatrixClient extends TypedEventEmitter {
4674
2506
  throw new Error("could not get thread timeline: not a thread timeline");
4675
2507
  }
4676
2508
  var thread = timelineSet.thread;
4677
- var resOlder = yield _this50.fetchRelations(timelineSet.room.roomId, thread.id, null, null, {
2509
+ var resOlder = yield _this26.fetchRelations(timelineSet.room.roomId, thread.id, null, null, {
4678
2510
  dir: Direction.Backward,
4679
2511
  from: res.start,
4680
2512
  recurse: recurse || undefined
4681
2513
  });
4682
- var resNewer = yield _this50.fetchRelations(timelineSet.room.roomId, thread.id, null, null, {
2514
+ var resNewer = yield _this26.fetchRelations(timelineSet.room.roomId, thread.id, null, null, {
4683
2515
  dir: Direction.Forward,
4684
2516
  from: res.end,
4685
2517
  recurse: recurse || undefined
@@ -4704,12 +2536,12 @@ export class MatrixClient extends TypedEventEmitter {
4704
2536
  }
4705
2537
  timelineSet.addEventsToTimeline(events, true, timeline, resNewer.next_batch);
4706
2538
  if (!resOlder.next_batch) {
4707
- var originalEvent = yield _this50.fetchRoomEvent(timelineSet.room.roomId, thread.id);
2539
+ var originalEvent = yield _this26.fetchRoomEvent(timelineSet.room.roomId, thread.id);
4708
2540
  timelineSet.addEventsToTimeline([mapper(originalEvent)], true, timeline, null);
4709
2541
  }
4710
2542
  timeline.setPaginationToken((_resOlder$next_batch = resOlder.next_batch) !== null && _resOlder$next_batch !== void 0 ? _resOlder$next_batch : null, Direction.Backward);
4711
2543
  timeline.setPaginationToken((_resNewer$next_batch = resNewer.next_batch) !== null && _resNewer$next_batch !== void 0 ? _resNewer$next_batch : null, Direction.Forward);
4712
- _this50.processAggregatedTimelineEvents(timelineSet.room, events);
2544
+ _this26.processAggregatedTimelineEvents(timelineSet.room, events);
4713
2545
 
4714
2546
  // There is no guarantee that the event ended up in "timeline" (we might have switched to a neighbouring
4715
2547
  // timeline) - so check the room's index again. On the other hand, there's no guarantee the event ended up
@@ -4722,7 +2554,7 @@ export class MatrixClient extends TypedEventEmitter {
4722
2554
  // XXX: workaround for https://github.com/vector-im/element-meta/issues/150
4723
2555
 
4724
2556
  var _thread = timelineSet.thread;
4725
- var _resOlder = yield _this50.fetchRelations(timelineSet.room.roomId, _thread.id, THREAD_RELATION_TYPE.name, null, {
2557
+ var _resOlder = yield _this26.fetchRelations(timelineSet.room.roomId, _thread.id, THREAD_RELATION_TYPE.name, null, {
4726
2558
  dir: Direction.Backward,
4727
2559
  from: res.start,
4728
2560
  recurse: recurse || undefined
@@ -4731,7 +2563,7 @@ export class MatrixClient extends TypedEventEmitter {
4731
2563
  var nextBatch = res.end;
4732
2564
  while (nextBatch) {
4733
2565
  var _resNewer$next_batch2;
4734
- var _resNewer = yield _this50.fetchRelations(timelineSet.room.roomId, _thread.id, THREAD_RELATION_TYPE.name, null, {
2566
+ var _resNewer = yield _this26.fetchRelations(timelineSet.room.roomId, _thread.id, THREAD_RELATION_TYPE.name, null, {
4735
2567
  dir: Direction.Forward,
4736
2568
  from: nextBatch,
4737
2569
  recurse: recurse || undefined
@@ -4755,12 +2587,12 @@ export class MatrixClient extends TypedEventEmitter {
4755
2587
  _timeline.getState(EventTimeline.BACKWARDS).setUnknownStateEvents(res.state.map(mapper));
4756
2588
  timelineSet.addEventsToTimeline(_events, true, _timeline, null);
4757
2589
  if (!_resOlder.next_batch) {
4758
- var _originalEvent = yield _this50.fetchRoomEvent(timelineSet.room.roomId, _thread.id);
2590
+ var _originalEvent = yield _this26.fetchRoomEvent(timelineSet.room.roomId, _thread.id);
4759
2591
  timelineSet.addEventsToTimeline([mapper(_originalEvent)], true, _timeline, null);
4760
2592
  }
4761
2593
  _timeline.setPaginationToken((_resOlder$next_batch2 = _resOlder.next_batch) !== null && _resOlder$next_batch2 !== void 0 ? _resOlder$next_batch2 : null, Direction.Backward);
4762
2594
  _timeline.setPaginationToken(null, Direction.Forward);
4763
- _this50.processAggregatedTimelineEvents(timelineSet.room, _events);
2595
+ _this26.processAggregatedTimelineEvents(timelineSet.room, _events);
4764
2596
  return _timeline;
4765
2597
  }
4766
2598
  }
@@ -4778,10 +2610,10 @@ export class MatrixClient extends TypedEventEmitter {
4778
2610
  * {@link EventTimeline} timeline with the latest events in the room
4779
2611
  */
4780
2612
  getLatestTimeline(timelineSet) {
4781
- var _this51 = this;
2613
+ var _this27 = this;
4782
2614
  return _asyncToGenerator(function* () {
4783
2615
  // don't allow any timeline support unless it's been enabled.
4784
- if (!_this51.timelineSupport) {
2616
+ if (!_this27.timelineSupport) {
4785
2617
  throw new Error("timeline support is disabled. Set the 'timelineSupport'" + " parameter to true when creating MatrixClient to enable it.");
4786
2618
  }
4787
2619
  if (!timelineSet.room) {
@@ -4790,35 +2622,35 @@ export class MatrixClient extends TypedEventEmitter {
4790
2622
  var event;
4791
2623
  if (timelineSet.threadListType !== null) {
4792
2624
  var _res$chunk;
4793
- var res = yield _this51.createThreadListMessagesRequest(timelineSet.room.roomId, null, 1, Direction.Backward, timelineSet.threadListType, timelineSet.getFilter());
2625
+ var res = yield _this27.createThreadListMessagesRequest(timelineSet.room.roomId, null, 1, Direction.Backward, timelineSet.threadListType, timelineSet.getFilter());
4794
2626
  event = (_res$chunk = res.chunk) === null || _res$chunk === void 0 ? void 0 : _res$chunk[0];
4795
2627
  } else if (timelineSet.thread && Thread.hasServerSideSupport) {
4796
2628
  var _res$chunk2;
4797
- var recurse = _this51.canSupport.get(Feature.RelationsRecursion) !== ServerSupport.Unsupported;
4798
- var _res = yield _this51.fetchRelations(timelineSet.room.roomId, timelineSet.thread.id, THREAD_RELATION_TYPE.name, null, {
2629
+ var recurse = _this27.canSupport.get(Feature.RelationsRecursion) !== ServerSupport.Unsupported;
2630
+ var _res = yield _this27.fetchRelations(timelineSet.room.roomId, timelineSet.thread.id, THREAD_RELATION_TYPE.name, null, {
4799
2631
  dir: Direction.Backward,
4800
2632
  limit: 1,
4801
2633
  recurse: recurse || undefined
4802
2634
  });
4803
2635
  event = (_res$chunk2 = _res.chunk) === null || _res$chunk2 === void 0 ? void 0 : _res$chunk2[0];
4804
2636
  } else {
4805
- var _this51$clientOpts, _res2$chunk;
2637
+ var _this27$clientOpts, _res2$chunk;
4806
2638
  var messagesPath = utils.encodeUri("/rooms/$roomId/messages", {
4807
2639
  $roomId: timelineSet.room.roomId
4808
2640
  });
4809
2641
  var params = {
4810
2642
  dir: "b"
4811
2643
  };
4812
- if ((_this51$clientOpts = _this51.clientOpts) !== null && _this51$clientOpts !== void 0 && _this51$clientOpts.lazyLoadMembers) {
2644
+ if ((_this27$clientOpts = _this27.clientOpts) !== null && _this27$clientOpts !== void 0 && _this27$clientOpts.lazyLoadMembers) {
4813
2645
  params.filter = JSON.stringify(Filter.LAZY_LOADING_MESSAGES_FILTER);
4814
2646
  }
4815
- var _res2 = yield _this51.http.authedRequest(Method.Get, messagesPath, params);
2647
+ var _res2 = yield _this27.http.authedRequest(Method.Get, messagesPath, params);
4816
2648
  event = (_res2$chunk = _res2.chunk) === null || _res2$chunk === void 0 ? void 0 : _res2$chunk[0];
4817
2649
  }
4818
2650
  if (!event) {
4819
2651
  throw new Error("No message returned when trying to construct getLatestTimeline");
4820
2652
  }
4821
- return _this51.getEventTimeline(timelineSet, event.event_id);
2653
+ return _this27.getEventTimeline(timelineSet, event.event_id);
4822
2654
  })();
4823
2655
  }
4824
2656
 
@@ -4930,7 +2762,7 @@ export class MatrixClient extends TypedEventEmitter {
4930
2762
  * events and we reached either end of the timeline; else true.
4931
2763
  */
4932
2764
  paginateEventTimeline(eventTimeline, opts) {
4933
- var _this52 = this;
2765
+ var _this28 = this;
4934
2766
  var isNotifTimeline = eventTimeline.getTimelineSet() === this.notifTimelineSet;
4935
2767
  var room = this.getRoom(eventTimeline.getRoomId());
4936
2768
  var threadListType = eventTimeline.getTimelineSet().threadListType;
@@ -4966,17 +2798,17 @@ export class MatrixClient extends TypedEventEmitter {
4966
2798
  params.from = token;
4967
2799
  }
4968
2800
  promise = this.http.authedRequest(Method.Get, path, params).then(/*#__PURE__*/function () {
4969
- var _ref6 = _asyncToGenerator(function* (res) {
2801
+ var _ref3 = _asyncToGenerator(function* (res) {
4970
2802
  var token = res.next_token;
4971
2803
  var matrixEvents = [];
4972
2804
  res.notifications = res.notifications.filter(noUnsafeEventProps);
4973
2805
  for (var i = 0; i < res.notifications.length; i++) {
4974
2806
  var notification = res.notifications[i];
4975
- var _event4 = _this52.getEventMapper()(notification.event);
2807
+ var _event4 = _this28.getEventMapper()(notification.event);
4976
2808
 
4977
2809
  // @TODO(kerrya) reprocessing every notification is ugly
4978
2810
  // remove if we get server MSC3994 support
4979
- _this52.getPushDetailsForEvent(_event4, true);
2811
+ _this28.getPushDetailsForEvent(_event4, true);
4980
2812
  _event4.event.room_id = notification.room_id; // XXX: gutwrenching
4981
2813
  matrixEvents[i] = _event4;
4982
2814
  }
@@ -4985,7 +2817,7 @@ export class MatrixClient extends TypedEventEmitter {
4985
2817
  // in the notification timeline set
4986
2818
  var timelineSet = eventTimeline.getTimelineSet();
4987
2819
  timelineSet.addEventsToTimeline(matrixEvents, backwards, eventTimeline, token);
4988
- _this52.processAggregatedTimelineEvents(timelineSet.room, matrixEvents);
2820
+ _this28.processAggregatedTimelineEvents(timelineSet.room, matrixEvents);
4989
2821
 
4990
2822
  // if we've hit the end of the timeline, we need to stop trying to
4991
2823
  // paginate. We need to keep the 'forwards' token though, to make sure
@@ -4995,8 +2827,8 @@ export class MatrixClient extends TypedEventEmitter {
4995
2827
  }
4996
2828
  return Boolean(res.next_token);
4997
2829
  });
4998
- return function (_x4) {
4999
- return _ref6.apply(this, arguments);
2830
+ return function (_x2) {
2831
+ return _ref3.apply(this, arguments);
5000
2832
  };
5001
2833
  }()).finally(() => {
5002
2834
  eventTimeline.paginationRequests[dir] = null;
@@ -5046,8 +2878,8 @@ export class MatrixClient extends TypedEventEmitter {
5046
2878
  from: token !== null && token !== void 0 ? token : undefined,
5047
2879
  recurse: recurse || undefined
5048
2880
  }).then(/*#__PURE__*/function () {
5049
- var _ref7 = _asyncToGenerator(function* (res) {
5050
- var mapper = _this52.getEventMapper();
2881
+ var _ref4 = _asyncToGenerator(function* (res) {
2882
+ var mapper = _this28.getEventMapper();
5051
2883
  var matrixEvents = res.chunk.filter(noUnsafeEventProps).filter(getRelationsThreadFilter(thread.id)).map(mapper);
5052
2884
 
5053
2885
  // Process latest events first
@@ -5063,10 +2895,10 @@ export class MatrixClient extends TypedEventEmitter {
5063
2895
  timelineSet.addEventsToTimeline(matrixEvents, backwards, eventTimeline, newToken !== null && newToken !== void 0 ? newToken : null);
5064
2896
  if (!newToken && backwards) {
5065
2897
  var _thread$rootEvent, _eventTimeline$getRoo3;
5066
- var originalEvent = (_thread$rootEvent = thread.rootEvent) !== null && _thread$rootEvent !== void 0 ? _thread$rootEvent : mapper(yield _this52.fetchRoomEvent((_eventTimeline$getRoo3 = eventTimeline.getRoomId()) !== null && _eventTimeline$getRoo3 !== void 0 ? _eventTimeline$getRoo3 : "", thread.id));
2898
+ var originalEvent = (_thread$rootEvent = thread.rootEvent) !== null && _thread$rootEvent !== void 0 ? _thread$rootEvent : mapper(yield _this28.fetchRoomEvent((_eventTimeline$getRoo3 = eventTimeline.getRoomId()) !== null && _eventTimeline$getRoo3 !== void 0 ? _eventTimeline$getRoo3 : "", thread.id));
5067
2899
  timelineSet.addEventsToTimeline([originalEvent], true, eventTimeline, null);
5068
2900
  }
5069
- _this52.processAggregatedTimelineEvents(timelineSet.room, matrixEvents);
2901
+ _this28.processAggregatedTimelineEvents(timelineSet.room, matrixEvents);
5070
2902
 
5071
2903
  // if we've hit the end of the timeline, we need to stop trying to
5072
2904
  // paginate. We need to keep the 'forwards' token though, to make sure
@@ -5076,8 +2908,8 @@ export class MatrixClient extends TypedEventEmitter {
5076
2908
  }
5077
2909
  return Boolean(newToken);
5078
2910
  });
5079
- return function (_x5) {
5080
- return _ref7.apply(this, arguments);
2911
+ return function (_x3) {
2912
+ return _ref4.apply(this, arguments);
5081
2913
  };
5082
2914
  }()).finally(() => {
5083
2915
  eventTimeline.paginationRequests[dir] = null;
@@ -5352,10 +3184,10 @@ export class MatrixClient extends TypedEventEmitter {
5352
3184
  * @returns Promise which resolves: As requestEmailToken
5353
3185
  */
5354
3186
  requestTokenFromEndpoint(endpoint, params) {
5355
- var _this53 = this;
3187
+ var _this29 = this;
5356
3188
  return _asyncToGenerator(function* () {
5357
3189
  var postParams = Object.assign({}, params);
5358
- return _this53.http.request(Method.Post, endpoint, undefined, postParams);
3190
+ return _this29.http.request(Method.Post, endpoint, undefined, postParams);
5359
3191
  })();
5360
3192
  }
5361
3193
 
@@ -5650,14 +3482,14 @@ export class MatrixClient extends TypedEventEmitter {
5650
3482
  * @returns Filter ID
5651
3483
  */
5652
3484
  getOrCreateFilter(filterName, filter) {
5653
- var _this54 = this;
3485
+ var _this30 = this;
5654
3486
  return _asyncToGenerator(function* () {
5655
- var filterId = _this54.store.getFilterIdByName(filterName);
3487
+ var filterId = _this30.store.getFilterIdByName(filterName);
5656
3488
  var existingId;
5657
3489
  if (filterId) {
5658
3490
  // check that the existing filter matches our expectations
5659
3491
  try {
5660
- var existingFilter = yield _this54.getFilter(_this54.credentials.userId, filterId, true);
3492
+ var existingFilter = yield _this30.getFilter(_this30.credentials.userId, filterId, true);
5661
3493
  if (existingFilter) {
5662
3494
  var oldDef = existingFilter.getDefinition();
5663
3495
  var newDef = filter.getDefinition();
@@ -5681,7 +3513,7 @@ export class MatrixClient extends TypedEventEmitter {
5681
3513
  }
5682
3514
  // if the filter doesn't exist anymore on the server, remove from store
5683
3515
  if (!existingId) {
5684
- _this54.store.setFilterIdByName(filterName, undefined);
3516
+ _this30.store.setFilterIdByName(filterName, undefined);
5685
3517
  }
5686
3518
  }
5687
3519
  if (existingId) {
@@ -5689,8 +3521,8 @@ export class MatrixClient extends TypedEventEmitter {
5689
3521
  }
5690
3522
 
5691
3523
  // create a new filter
5692
- var createdFilter = yield _this54.createFilter(filter.getDefinition());
5693
- _this54.store.setFilterIdByName(filterName, createdFilter.filterId);
3524
+ var createdFilter = yield _this30.createFilter(filter.getDefinition());
3525
+ _this30.store.setFilterIdByName(filterName, createdFilter.filterId);
5694
3526
  return createdFilter.filterId;
5695
3527
  })();
5696
3528
  }
@@ -5708,84 +3540,6 @@ export class MatrixClient extends TypedEventEmitter {
5708
3540
  });
5709
3541
  return this.http.authedRequest(Method.Post, path, undefined, {});
5710
3542
  }
5711
- /**
5712
- * @returns Promise which resolves: ITurnServerResponse object
5713
- * @returns Rejects: with an error response.
5714
- */
5715
- turnServer() {
5716
- return this.http.authedRequest(Method.Get, "/voip/turnServer");
5717
- }
5718
-
5719
- /**
5720
- * Get the TURN servers for this homeserver.
5721
- * @returns The servers or an empty list.
5722
- */
5723
- getTurnServers() {
5724
- return this.turnServers || [];
5725
- }
5726
-
5727
- /**
5728
- * Get the unix timestamp (in milliseconds) at which the current
5729
- * TURN credentials (from getTurnServers) expire
5730
- * @returns The expiry timestamp in milliseconds
5731
- */
5732
- getTurnServersExpiry() {
5733
- return this.turnServersExpiry;
5734
- }
5735
- get pollingTurnServers() {
5736
- return this.checkTurnServersIntervalID !== undefined;
5737
- }
5738
-
5739
- // XXX: Intended private, used in code.
5740
- checkTurnServers() {
5741
- var _this55 = this;
5742
- return _asyncToGenerator(function* () {
5743
- if (!_this55.canSupportVoip) {
5744
- return;
5745
- }
5746
- var credentialsGood = false;
5747
- var remainingTime = _this55.turnServersExpiry - Date.now();
5748
- if (remainingTime > TURN_CHECK_INTERVAL) {
5749
- _this55.logger.debug("TURN creds are valid for another " + remainingTime + " ms: not fetching new ones.");
5750
- credentialsGood = true;
5751
- } else {
5752
- _this55.logger.debug("Fetching new TURN credentials");
5753
- try {
5754
- var res = yield _this55.turnServer();
5755
- if (res.uris) {
5756
- _this55.logger.debug("Got TURN URIs: " + res.uris + " refresh in " + res.ttl + " secs");
5757
- // map the response to a format that can be fed to RTCPeerConnection
5758
- var servers = {
5759
- urls: res.uris,
5760
- username: res.username,
5761
- credential: res.password
5762
- };
5763
- _this55.turnServers = [servers];
5764
- // The TTL is in seconds but we work in ms
5765
- _this55.turnServersExpiry = Date.now() + res.ttl * 1000;
5766
- credentialsGood = true;
5767
- _this55.emit(ClientEvent.TurnServers, _this55.turnServers);
5768
- }
5769
- } catch (err) {
5770
- _this55.logger.error("Failed to get TURN URIs", err);
5771
- if (err.httpStatus === 403) {
5772
- // We got a 403, so there's no point in looping forever.
5773
- _this55.logger.info("TURN access unavailable for this account: stopping credentials checks");
5774
- if (_this55.checkTurnServersIntervalID !== null) {
5775
- globalThis.clearInterval(_this55.checkTurnServersIntervalID);
5776
- }
5777
- _this55.checkTurnServersIntervalID = undefined;
5778
- _this55.emit(ClientEvent.TurnServersError, err, true); // fatal
5779
- } else {
5780
- // otherwise, if we failed for whatever reason, try again the next time we're called.
5781
- _this55.emit(ClientEvent.TurnServersError, err, false); // non-fatal
5782
- }
5783
- }
5784
- }
5785
- return credentialsGood;
5786
- })();
5787
- }
5788
-
5789
3543
  /**
5790
3544
  * Set whether to allow a fallback ICE server should be used for negotiating a
5791
3545
  * WebRTC connection if the homeserver doesn't provide any servers. Defaults to
@@ -5854,14 +3608,14 @@ export class MatrixClient extends TypedEventEmitter {
5854
3608
  });
5855
3609
  }
5856
3610
  fetchClientWellKnown() {
5857
- var _this56 = this;
3611
+ var _this31 = this;
5858
3612
  return _asyncToGenerator(function* () {
5859
- var _this56$getDomain;
3613
+ var _this31$getDomain;
5860
3614
  // `getRawClientConfig` does not throw or reject on network errors, instead
5861
3615
  // it absorbs errors and returns `{}`.
5862
- _this56.clientWellKnownPromise = AutoDiscovery.getRawClientConfig((_this56$getDomain = _this56.getDomain()) !== null && _this56$getDomain !== void 0 ? _this56$getDomain : undefined);
5863
- _this56.clientWellKnown = yield _this56.clientWellKnownPromise;
5864
- _this56.emit(ClientEvent.ClientWellKnown, _this56.clientWellKnown);
3616
+ _this31.clientWellKnownPromise = AutoDiscovery.getRawClientConfig((_this31$getDomain = _this31.getDomain()) !== null && _this31$getDomain !== void 0 ? _this31$getDomain : undefined);
3617
+ _this31.clientWellKnown = yield _this31.clientWellKnownPromise;
3618
+ _this31.emit(ClientEvent.ClientWellKnown, _this31.clientWellKnown);
5865
3619
  })();
5866
3620
  }
5867
3621
  getClientWellKnown() {
@@ -5883,11 +3637,11 @@ export class MatrixClient extends TypedEventEmitter {
5883
3637
  storeClientOptions() {
5884
3638
  // XXX: Intended private, used in code
5885
3639
  var primTypes = ["boolean", "string", "number"];
5886
- var serializableOpts = Object.entries(this.clientOpts).filter(_ref8 => {
5887
- var [key, value] = _ref8;
3640
+ var serializableOpts = Object.entries(this.clientOpts).filter(_ref5 => {
3641
+ var [key, value] = _ref5;
5888
3642
  return primTypes.includes(typeof value);
5889
- }).reduce((obj, _ref9) => {
5890
- var [key, value] = _ref9;
3643
+ }).reduce((obj, _ref6) => {
3644
+ var [key, value] = _ref6;
5891
3645
  obj[key] = value;
5892
3646
  return obj;
5893
3647
  }, {});
@@ -5907,16 +3661,16 @@ export class MatrixClient extends TypedEventEmitter {
5907
3661
  // TODO: on spec release, rename this to getMutualRooms
5908
3662
  // eslint-disable-next-line
5909
3663
  _unstable_getSharedRooms(userId) {
5910
- var _this57 = this;
3664
+ var _this32 = this;
5911
3665
  return _asyncToGenerator(function* () {
5912
3666
  // Initial variant of the MSC
5913
- var sharedRoomsSupport = yield _this57.doesServerSupportUnstableFeature(UNSTABLE_MSC2666_SHARED_ROOMS);
3667
+ var sharedRoomsSupport = yield _this32.doesServerSupportUnstableFeature(UNSTABLE_MSC2666_SHARED_ROOMS);
5914
3668
 
5915
3669
  // Newer variant that renamed shared rooms to mutual rooms
5916
- var mutualRoomsSupport = yield _this57.doesServerSupportUnstableFeature(UNSTABLE_MSC2666_MUTUAL_ROOMS);
3670
+ var mutualRoomsSupport = yield _this32.doesServerSupportUnstableFeature(UNSTABLE_MSC2666_MUTUAL_ROOMS);
5917
3671
 
5918
3672
  // Latest variant that changed from path elements to query elements
5919
- var queryMutualRoomsSupport = yield _this57.doesServerSupportUnstableFeature(UNSTABLE_MSC2666_QUERY_MUTUAL_ROOMS);
3673
+ var queryMutualRoomsSupport = yield _this32.doesServerSupportUnstableFeature(UNSTABLE_MSC2666_QUERY_MUTUAL_ROOMS);
5920
3674
  if (!sharedRoomsSupport && !mutualRoomsSupport && !queryMutualRoomsSupport) {
5921
3675
  throw Error("Server does not support the Mutual Rooms API");
5922
3676
  }
@@ -5944,7 +3698,7 @@ export class MatrixClient extends TypedEventEmitter {
5944
3698
  if (token != null && queryMutualRoomsSupport) {
5945
3699
  tokenQuery["batch_token"] = token;
5946
3700
  }
5947
- var res = yield _this57.http.authedRequest(Method.Get, path, _objectSpread(_objectSpread({}, query), tokenQuery), undefined, {
3701
+ var res = yield _this32.http.authedRequest(Method.Get, path, _objectSpread(_objectSpread({}, query), tokenQuery), undefined, {
5948
3702
  prefix: ClientPrefix.Unstable
5949
3703
  });
5950
3704
  rooms.push(...res.joined);
@@ -5964,24 +3718,24 @@ export class MatrixClient extends TypedEventEmitter {
5964
3718
  * @returns The server /versions response
5965
3719
  */
5966
3720
  getVersions() {
5967
- var _this58 = this;
3721
+ var _this33 = this;
5968
3722
  return _asyncToGenerator(function* () {
5969
- if (_this58.serverVersionsPromise) {
5970
- return _this58.serverVersionsPromise;
3723
+ if (_this33.serverVersionsPromise) {
3724
+ return _this33.serverVersionsPromise;
5971
3725
  }
5972
3726
 
5973
3727
  // We send an authenticated request as of MSC4026
5974
- _this58.serverVersionsPromise = _this58.http.authedRequest(Method.Get, "/_matrix/client/versions", undefined, undefined, {
3728
+ _this33.serverVersionsPromise = _this33.http.authedRequest(Method.Get, "/_matrix/client/versions", undefined, undefined, {
5975
3729
  prefix: ""
5976
3730
  }).catch(e => {
5977
3731
  // Need to unset this if it fails, otherwise we'll never retry
5978
- _this58.serverVersionsPromise = undefined;
3732
+ _this33.serverVersionsPromise = undefined;
5979
3733
  // but rethrow the exception to anything that was waiting
5980
3734
  throw e;
5981
3735
  });
5982
- var serverVersions = yield _this58.serverVersionsPromise;
5983
- _this58.canSupport = yield buildFeatureSupportMap(serverVersions);
5984
- return _this58.serverVersionsPromise;
3736
+ var serverVersions = yield _this33.serverVersionsPromise;
3737
+ _this33.canSupport = yield buildFeatureSupportMap(serverVersions);
3738
+ return _this33.serverVersionsPromise;
5985
3739
  })();
5986
3740
  }
5987
3741
 
@@ -5991,11 +3745,11 @@ export class MatrixClient extends TypedEventEmitter {
5991
3745
  * @returns Whether it is supported
5992
3746
  */
5993
3747
  isVersionSupported(version) {
5994
- var _this59 = this;
3748
+ var _this34 = this;
5995
3749
  return _asyncToGenerator(function* () {
5996
3750
  var {
5997
3751
  versions
5998
- } = yield _this59.getVersions();
3752
+ } = yield _this34.getVersions();
5999
3753
  return versions && versions.includes(version);
6000
3754
  })();
6001
3755
  }
@@ -6007,9 +3761,9 @@ export class MatrixClient extends TypedEventEmitter {
6007
3761
  * @returns true if the feature is supported
6008
3762
  */
6009
3763
  doesServerSupportUnstableFeature(feature) {
6010
- var _this60 = this;
3764
+ var _this35 = this;
6011
3765
  return _asyncToGenerator(function* () {
6012
- var response = yield _this60.getVersions();
3766
+ var response = yield _this35.getVersions();
6013
3767
  if (!response) return false;
6014
3768
  var unstableFeatures = response["unstable_features"];
6015
3769
  return unstableFeatures && !!unstableFeatures[feature];
@@ -6024,9 +3778,9 @@ export class MatrixClient extends TypedEventEmitter {
6024
3778
  * for the preset.
6025
3779
  */
6026
3780
  doesServerForceEncryptionForPreset(presetName) {
6027
- var _this61 = this;
3781
+ var _this36 = this;
6028
3782
  return _asyncToGenerator(function* () {
6029
- var response = yield _this61.getVersions();
3783
+ var response = yield _this36.getVersions();
6030
3784
  if (!response) return false;
6031
3785
  var unstableFeatures = response["unstable_features"];
6032
3786
 
@@ -6036,9 +3790,9 @@ export class MatrixClient extends TypedEventEmitter {
6036
3790
  })();
6037
3791
  }
6038
3792
  doesServerSupportThread() {
6039
- var _this62 = this;
3793
+ var _this37 = this;
6040
3794
  return _asyncToGenerator(function* () {
6041
- if (yield _this62.isVersionSupported("v1.4")) {
3795
+ if (yield _this37.isVersionSupported("v1.4")) {
6042
3796
  return {
6043
3797
  threads: FeatureSupport.Stable,
6044
3798
  list: FeatureSupport.Stable,
@@ -6046,13 +3800,13 @@ export class MatrixClient extends TypedEventEmitter {
6046
3800
  };
6047
3801
  }
6048
3802
  try {
6049
- var [threadUnstable, threadStable, listUnstable, listStable, fwdPaginationUnstable, fwdPaginationStable] = yield Promise.all([_this62.doesServerSupportUnstableFeature("org.matrix.msc3440"), _this62.doesServerSupportUnstableFeature("org.matrix.msc3440.stable"), _this62.doesServerSupportUnstableFeature("org.matrix.msc3856"), _this62.doesServerSupportUnstableFeature("org.matrix.msc3856.stable"), _this62.doesServerSupportUnstableFeature("org.matrix.msc3715"), _this62.doesServerSupportUnstableFeature("org.matrix.msc3715.stable")]);
3803
+ var [threadUnstable, threadStable, listUnstable, listStable, fwdPaginationUnstable, fwdPaginationStable] = yield Promise.all([_this37.doesServerSupportUnstableFeature("org.matrix.msc3440"), _this37.doesServerSupportUnstableFeature("org.matrix.msc3440.stable"), _this37.doesServerSupportUnstableFeature("org.matrix.msc3856"), _this37.doesServerSupportUnstableFeature("org.matrix.msc3856.stable"), _this37.doesServerSupportUnstableFeature("org.matrix.msc3715"), _this37.doesServerSupportUnstableFeature("org.matrix.msc3715.stable")]);
6050
3804
  return {
6051
3805
  threads: determineFeatureSupport(threadStable, threadUnstable),
6052
3806
  list: determineFeatureSupport(listStable, listUnstable),
6053
3807
  fwdPagination: determineFeatureSupport(fwdPaginationStable, fwdPaginationUnstable)
6054
3808
  };
6055
- } catch (_unused3) {
3809
+ } catch (_unused) {
6056
3810
  return {
6057
3811
  threads: FeatureSupport.None,
6058
3812
  list: FeatureSupport.None,
@@ -6104,21 +3858,19 @@ export class MatrixClient extends TypedEventEmitter {
6104
3858
  * @returns an object with `events` as `MatrixEvent[]` and optionally `nextBatch` if more relations are available.
6105
3859
  */
6106
3860
  relations(roomId, eventId, relationType, eventType) {
6107
- var _arguments8 = arguments,
6108
- _this63 = this;
3861
+ var _arguments6 = arguments,
3862
+ _this38 = this;
6109
3863
  return _asyncToGenerator(function* () {
6110
3864
  var _result$next_batch, _result$prev_batch;
6111
- var opts = _arguments8.length > 4 && _arguments8[4] !== undefined ? _arguments8[4] : {
3865
+ var opts = _arguments6.length > 4 && _arguments6[4] !== undefined ? _arguments6[4] : {
6112
3866
  dir: Direction.Backward
6113
3867
  };
6114
- var fetchedEventType = eventType ? _this63.getEncryptedIfNeededEventType(roomId, eventType) : null;
6115
- var [eventResult, result] = yield Promise.all([_this63.fetchRoomEvent(roomId, eventId), _this63.fetchRelations(roomId, eventId, relationType, fetchedEventType, opts)]);
6116
- var mapper = _this63.getEventMapper();
3868
+ var fetchedEventType = eventType ? _this38.getEncryptedIfNeededEventType(roomId, eventType) : null;
3869
+ var [eventResult, result] = yield Promise.all([_this38.fetchRoomEvent(roomId, eventId), _this38.fetchRelations(roomId, eventId, relationType, fetchedEventType, opts)]);
3870
+ var mapper = _this38.getEventMapper();
6117
3871
  var originalEvent = eventResult ? mapper(eventResult) : undefined;
6118
3872
  var events = result.chunk.map(mapper);
6119
3873
  if (fetchedEventType === EventType.RoomMessageEncrypted) {
6120
- var allEvents = originalEvent ? events.concat(originalEvent) : events;
6121
- yield Promise.all(allEvents.map(e => _this63.decryptEventIfNeeded(e)));
6122
3874
  if (eventType !== null) {
6123
3875
  events = events.filter(e => e.getType() === eventType);
6124
3876
  }
@@ -6135,18 +3887,6 @@ export class MatrixClient extends TypedEventEmitter {
6135
3887
  })();
6136
3888
  }
6137
3889
 
6138
- /**
6139
- * The app may wish to see if we have a key cached without
6140
- * triggering a user interaction.
6141
- *
6142
- * @deprecated Not supported for Rust Cryptography.
6143
- */
6144
- getCrossSigningCacheCallbacks() {
6145
- var _this$crypto4;
6146
- // XXX: Private member access
6147
- return (_this$crypto4 = this.crypto) === null || _this$crypto4 === void 0 ? void 0 : _this$crypto4.crossSigningInfo.getCacheCallbacks();
6148
- }
6149
-
6150
3890
  /**
6151
3891
  * Generates a random string suitable for use as a client secret. <strong>This
6152
3892
  * method is experimental and may change.</strong>
@@ -6162,14 +3902,7 @@ export class MatrixClient extends TypedEventEmitter {
6162
3902
  * @returns A decryption promise
6163
3903
  */
6164
3904
  decryptEventIfNeeded(event, options) {
6165
- if (event.shouldAttemptDecryption() && this.isCryptoEnabled()) {
6166
- event.attemptDecryption(this.cryptoBackend, options);
6167
- }
6168
- if (event.isBeingDecrypted()) {
6169
- return event.getDecryptionPromise();
6170
- } else {
6171
- return Promise.resolve();
6172
- }
3905
+ return Promise.resolve();
6173
3906
  }
6174
3907
  termsUrlForService(serviceType, baseUrl) {
6175
3908
  switch (serviceType) {
@@ -6468,23 +4201,15 @@ export class MatrixClient extends TypedEventEmitter {
6468
4201
  * @returns Promise which resolves: On success, the empty object `{}`
6469
4202
  */
6470
4203
  logout() {
6471
- var _arguments9 = arguments,
6472
- _this64 = this;
4204
+ var _arguments7 = arguments,
4205
+ _this39 = this;
6473
4206
  return _asyncToGenerator(function* () {
6474
- var _this64$crypto;
6475
- var stopClient = _arguments9.length > 0 && _arguments9[0] !== undefined ? _arguments9[0] : false;
6476
- if ((_this64$crypto = _this64.crypto) !== null && _this64$crypto !== void 0 && (_this64$crypto = _this64$crypto.backupManager) !== null && _this64$crypto !== void 0 && _this64$crypto.getKeyBackupEnabled()) {
6477
- try {
6478
- while ((yield _this64.crypto.backupManager.backupPendingKeys(200)) > 0);
6479
- } catch (err) {
6480
- _this64.logger.error("Key backup request failed when logging out. Some keys may be missing from backup", err);
6481
- }
6482
- }
4207
+ var stopClient = _arguments7.length > 0 && _arguments7[0] !== undefined ? _arguments7[0] : false;
6483
4208
  if (stopClient) {
6484
- _this64.stopClient();
6485
- _this64.http.abort();
4209
+ _this39.stopClient();
4210
+ _this39.http.abort();
6486
4211
  }
6487
- return _this64.http.authedRequest(Method.Post, "/logout");
4212
+ return _this39.http.authedRequest(Method.Post, "/logout");
6488
4213
  })();
6489
4214
  }
6490
4215
 
@@ -6522,12 +4247,12 @@ export class MatrixClient extends TypedEventEmitter {
6522
4247
  * or UIA auth data.
6523
4248
  */
6524
4249
  requestLoginToken(auth) {
6525
- var _this65 = this;
4250
+ var _this40 = this;
6526
4251
  return _asyncToGenerator(function* () {
6527
4252
  var body = {
6528
4253
  auth
6529
4254
  };
6530
- return _this65.http.authedRequest(Method.Post, "/login/get_token", undefined,
4255
+ return _this40.http.authedRequest(Method.Post, "/login/get_token", undefined,
6531
4256
  // no query params
6532
4257
  body, {
6533
4258
  prefix: ClientPrefix.V1
@@ -6559,23 +4284,23 @@ export class MatrixClient extends TypedEventEmitter {
6559
4284
  * @returns Rejects: with an error response.
6560
4285
  */
6561
4286
  createRoom(options) {
6562
- var _this66 = this;
4287
+ var _this41 = this;
6563
4288
  return _asyncToGenerator(function* () {
6564
- var _this66$identityServe;
4289
+ var _this41$identityServe;
6565
4290
  // eslint-disable-line camelcase
6566
4291
  // some valid options include: room_alias_name, visibility, invite
6567
4292
 
6568
4293
  // inject the id_access_token if inviting 3rd party addresses
6569
4294
  var invitesNeedingToken = (options.invite_3pid || []).filter(i => !i.id_access_token);
6570
- if (invitesNeedingToken.length > 0 && (_this66$identityServe = _this66.identityServer) !== null && _this66$identityServe !== void 0 && _this66$identityServe.getAccessToken) {
6571
- var identityAccessToken = yield _this66.identityServer.getAccessToken();
4295
+ if (invitesNeedingToken.length > 0 && (_this41$identityServe = _this41.identityServer) !== null && _this41$identityServe !== void 0 && _this41$identityServe.getAccessToken) {
4296
+ var identityAccessToken = yield _this41.identityServer.getAccessToken();
6572
4297
  if (identityAccessToken) {
6573
4298
  for (var invite of invitesNeedingToken) {
6574
4299
  invite.id_access_token = identityAccessToken;
6575
4300
  }
6576
4301
  }
6577
4302
  }
6578
- return _this66.http.authedRequest(Method.Post, "/createRoom", undefined, options);
4303
+ return _this41.http.authedRequest(Method.Post, "/createRoom", undefined, options);
6579
4304
  })();
6580
4305
  }
6581
4306
 
@@ -6759,7 +4484,7 @@ export class MatrixClient extends TypedEventEmitter {
6759
4484
  * @returns Promise which resolves: the empty object, `{}`.
6760
4485
  */
6761
4486
  setRoomReadMarkersHttpRequest(roomId, rmEventId, rrEventId, rpEventId) {
6762
- var _this67 = this;
4487
+ var _this42 = this;
6763
4488
  return _asyncToGenerator(function* () {
6764
4489
  var path = utils.encodeUri("/rooms/$roomId/read_markers", {
6765
4490
  $roomId: roomId
@@ -6768,10 +4493,10 @@ export class MatrixClient extends TypedEventEmitter {
6768
4493
  [ReceiptType.FullyRead]: rmEventId,
6769
4494
  [ReceiptType.Read]: rrEventId
6770
4495
  };
6771
- if ((yield _this67.doesServerSupportUnstableFeature("org.matrix.msc2285.stable")) || (yield _this67.isVersionSupported("v1.4"))) {
4496
+ if ((yield _this42.doesServerSupportUnstableFeature("org.matrix.msc2285.stable")) || (yield _this42.isVersionSupported("v1.4"))) {
6772
4497
  content[ReceiptType.ReadPrivate] = rpEventId;
6773
4498
  }
6774
- return _this67.http.authedRequest(Method.Post, path, undefined, content);
4499
+ return _this42.http.authedRequest(Method.Post, path, undefined, content);
6775
4500
  })();
6776
4501
  }
6777
4502
 
@@ -6804,13 +4529,13 @@ export class MatrixClient extends TypedEventEmitter {
6804
4529
  * @returns Rejects: with an error response.
6805
4530
  */
6806
4531
  publicRooms() {
6807
- var _ref10 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4532
+ var _ref7 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
6808
4533
  var {
6809
4534
  server,
6810
4535
  limit,
6811
4536
  since
6812
- } = _ref10,
6813
- options = _objectWithoutProperties(_ref10, _excluded);
4537
+ } = _ref7,
4538
+ options = _objectWithoutProperties(_ref7, _excluded);
6814
4539
  if (Object.keys(options).length === 0) {
6815
4540
  var queryParams = {
6816
4541
  server,
@@ -6928,11 +4653,11 @@ export class MatrixClient extends TypedEventEmitter {
6928
4653
  * @param options.limit - the maximum number of results to return. The server will apply a limit if unspecified.
6929
4654
  * @returns Promise which resolves: an array of results.
6930
4655
  */
6931
- searchUserDirectory(_ref11) {
4656
+ searchUserDirectory(_ref8) {
6932
4657
  var {
6933
4658
  term,
6934
4659
  limit
6935
- } = _ref11;
4660
+ } = _ref8;
6936
4661
  var body = {
6937
4662
  search_term: term
6938
4663
  };
@@ -7004,9 +4729,9 @@ export class MatrixClient extends TypedEventEmitter {
7004
4729
  * @returns `true` if supported, otherwise `false`
7005
4730
  */
7006
4731
  doesServerSupportExtendedProfiles() {
7007
- var _this68 = this;
4732
+ var _this43 = this;
7008
4733
  return _asyncToGenerator(function* () {
7009
- return _this68.doesServerSupportUnstableFeature(UNSTABLE_MSC4133_EXTENDED_PROFILES);
4734
+ return _this43.doesServerSupportUnstableFeature(UNSTABLE_MSC4133_EXTENDED_PROFILES);
7010
4735
  })();
7011
4736
  }
7012
4737
 
@@ -7016,9 +4741,9 @@ export class MatrixClient extends TypedEventEmitter {
7016
4741
  * @returns The prefix for use with `authedRequest`
7017
4742
  */
7018
4743
  getExtendedProfileRequestPrefix() {
7019
- var _this69 = this;
4744
+ var _this44 = this;
7020
4745
  return _asyncToGenerator(function* () {
7021
- if (yield _this69.doesServerSupportUnstableFeature("uk.tcpip.msc4133.stable")) {
4746
+ if (yield _this44.doesServerSupportUnstableFeature("uk.tcpip.msc4133.stable")) {
7022
4747
  return ClientPrefix.V3;
7023
4748
  }
7024
4749
  return "/_matrix/client/unstable/uk.tcpip.msc4133";
@@ -7036,15 +4761,15 @@ export class MatrixClient extends TypedEventEmitter {
7036
4761
  * @throws A M_NOT_FOUND error if the profile could not be found.
7037
4762
  */
7038
4763
  getExtendedProfile(userId) {
7039
- var _this70 = this;
4764
+ var _this45 = this;
7040
4765
  return _asyncToGenerator(function* () {
7041
- if (!(yield _this70.doesServerSupportExtendedProfiles())) {
4766
+ if (!(yield _this45.doesServerSupportExtendedProfiles())) {
7042
4767
  throw new Error("Server does not support extended profiles");
7043
4768
  }
7044
- return _this70.http.authedRequest(Method.Get, utils.encodeUri("/profile/$userId", {
4769
+ return _this45.http.authedRequest(Method.Get, utils.encodeUri("/profile/$userId", {
7045
4770
  $userId: userId
7046
4771
  }), undefined, undefined, {
7047
- prefix: yield _this70.getExtendedProfileRequestPrefix()
4772
+ prefix: yield _this45.getExtendedProfileRequestPrefix()
7048
4773
  });
7049
4774
  })();
7050
4775
  }
@@ -7061,16 +4786,16 @@ export class MatrixClient extends TypedEventEmitter {
7061
4786
  * @throws A M_NOT_FOUND error if the key was not set OR the profile could not be found.
7062
4787
  */
7063
4788
  getExtendedProfileProperty(userId, key) {
7064
- var _this71 = this;
4789
+ var _this46 = this;
7065
4790
  return _asyncToGenerator(function* () {
7066
- if (!(yield _this71.doesServerSupportExtendedProfiles())) {
4791
+ if (!(yield _this46.doesServerSupportExtendedProfiles())) {
7067
4792
  throw new Error("Server does not support extended profiles");
7068
4793
  }
7069
- var profile = yield _this71.http.authedRequest(Method.Get, utils.encodeUri("/profile/$userId/$key", {
4794
+ var profile = yield _this46.http.authedRequest(Method.Get, utils.encodeUri("/profile/$userId/$key", {
7070
4795
  $userId: userId,
7071
4796
  $key: key
7072
4797
  }), undefined, undefined, {
7073
- prefix: yield _this71.getExtendedProfileRequestPrefix()
4798
+ prefix: yield _this46.getExtendedProfileRequestPrefix()
7074
4799
  });
7075
4800
  return profile[key];
7076
4801
  })();
@@ -7086,19 +4811,19 @@ export class MatrixClient extends TypedEventEmitter {
7086
4811
  * @throws An error if the server does not support MSC4133 OR the server disallows editing the user profile.
7087
4812
  */
7088
4813
  setExtendedProfileProperty(key, value) {
7089
- var _this72 = this;
4814
+ var _this47 = this;
7090
4815
  return _asyncToGenerator(function* () {
7091
- if (!(yield _this72.doesServerSupportExtendedProfiles())) {
4816
+ if (!(yield _this47.doesServerSupportExtendedProfiles())) {
7092
4817
  throw new Error("Server does not support extended profiles");
7093
4818
  }
7094
- var userId = _this72.getUserId();
7095
- yield _this72.http.authedRequest(Method.Put, utils.encodeUri("/profile/$userId/$key", {
4819
+ var userId = _this47.getUserId();
4820
+ yield _this47.http.authedRequest(Method.Put, utils.encodeUri("/profile/$userId/$key", {
7096
4821
  $userId: userId,
7097
4822
  $key: key
7098
4823
  }), undefined, {
7099
4824
  [key]: value
7100
4825
  }, {
7101
- prefix: yield _this72.getExtendedProfileRequestPrefix()
4826
+ prefix: yield _this47.getExtendedProfileRequestPrefix()
7102
4827
  });
7103
4828
  })();
7104
4829
  }
@@ -7112,17 +4837,17 @@ export class MatrixClient extends TypedEventEmitter {
7112
4837
  * @throws An error if the server does not support MSC4133 OR the server disallows editing the user profile.
7113
4838
  */
7114
4839
  deleteExtendedProfileProperty(key) {
7115
- var _this73 = this;
4840
+ var _this48 = this;
7116
4841
  return _asyncToGenerator(function* () {
7117
- if (!(yield _this73.doesServerSupportExtendedProfiles())) {
4842
+ if (!(yield _this48.doesServerSupportExtendedProfiles())) {
7118
4843
  throw new Error("Server does not support extended profiles");
7119
4844
  }
7120
- var userId = _this73.getUserId();
7121
- yield _this73.http.authedRequest(Method.Delete, utils.encodeUri("/profile/$userId/$key", {
4845
+ var userId = _this48.getUserId();
4846
+ yield _this48.http.authedRequest(Method.Delete, utils.encodeUri("/profile/$userId/$key", {
7122
4847
  $userId: userId,
7123
4848
  $key: key
7124
4849
  }), undefined, undefined, {
7125
- prefix: yield _this73.getExtendedProfileRequestPrefix()
4850
+ prefix: yield _this48.getExtendedProfileRequestPrefix()
7126
4851
  });
7127
4852
  })();
7128
4853
  }
@@ -7138,16 +4863,16 @@ export class MatrixClient extends TypedEventEmitter {
7138
4863
  * @throws An error if the server does not support MSC4133 OR the server disallows editing the user profile.
7139
4864
  */
7140
4865
  patchExtendedProfile(profile) {
7141
- var _this74 = this;
4866
+ var _this49 = this;
7142
4867
  return _asyncToGenerator(function* () {
7143
- if (!(yield _this74.doesServerSupportExtendedProfiles())) {
4868
+ if (!(yield _this49.doesServerSupportExtendedProfiles())) {
7144
4869
  throw new Error("Server does not support extended profiles");
7145
4870
  }
7146
- var userId = _this74.getUserId();
7147
- return _this74.http.authedRequest(Method.Patch, utils.encodeUri("/profile/$userId", {
4871
+ var userId = _this49.getUserId();
4872
+ return _this49.http.authedRequest(Method.Patch, utils.encodeUri("/profile/$userId", {
7148
4873
  $userId: userId
7149
4874
  }), {}, profile, {
7150
- prefix: yield _this74.getExtendedProfileRequestPrefix()
4875
+ prefix: yield _this49.getExtendedProfileRequestPrefix()
7151
4876
  });
7152
4877
  })();
7153
4878
  }
@@ -7162,16 +4887,16 @@ export class MatrixClient extends TypedEventEmitter {
7162
4887
  * @throws An error if the server does not support MSC4133 OR the server disallows editing the user profile.
7163
4888
  */
7164
4889
  setExtendedProfile(profile) {
7165
- var _this75 = this;
4890
+ var _this50 = this;
7166
4891
  return _asyncToGenerator(function* () {
7167
- if (!(yield _this75.doesServerSupportExtendedProfiles())) {
4892
+ if (!(yield _this50.doesServerSupportExtendedProfiles())) {
7168
4893
  throw new Error("Server does not support extended profiles");
7169
4894
  }
7170
- var userId = _this75.getUserId();
7171
- yield _this75.http.authedRequest(Method.Put, utils.encodeUri("/profile/$userId", {
4895
+ var userId = _this50.getUserId();
4896
+ yield _this50.http.authedRequest(Method.Put, utils.encodeUri("/profile/$userId", {
7172
4897
  $userId: userId
7173
4898
  }), {}, profile, {
7174
- prefix: yield _this75.getExtendedProfileRequestPrefix()
4899
+ prefix: yield _this50.getExtendedProfileRequestPrefix()
7175
4900
  });
7176
4901
  })();
7177
4902
  }
@@ -7194,10 +4919,10 @@ export class MatrixClient extends TypedEventEmitter {
7194
4919
  * @returns Rejects: with an error response.
7195
4920
  */
7196
4921
  addThreePidOnly(data) {
7197
- var _this76 = this;
4922
+ var _this51 = this;
7198
4923
  return _asyncToGenerator(function* () {
7199
4924
  var path = "/account/3pid/add";
7200
- return _this76.http.authedRequest(Method.Post, path, undefined, data);
4925
+ return _this51.http.authedRequest(Method.Post, path, undefined, data);
7201
4926
  })();
7202
4927
  }
7203
4928
 
@@ -7213,10 +4938,10 @@ export class MatrixClient extends TypedEventEmitter {
7213
4938
  * @returns Rejects: with an error response.
7214
4939
  */
7215
4940
  bindThreePid(data) {
7216
- var _this77 = this;
4941
+ var _this52 = this;
7217
4942
  return _asyncToGenerator(function* () {
7218
4943
  var path = "/account/3pid/bind";
7219
- return _this77.http.authedRequest(Method.Post, path, undefined, data);
4944
+ return _this52.http.authedRequest(Method.Post, path, undefined, data);
7220
4945
  })();
7221
4946
  }
7222
4947
 
@@ -7234,15 +4959,15 @@ export class MatrixClient extends TypedEventEmitter {
7234
4959
  unbindThreePid(medium, address
7235
4960
  // eslint-disable-next-line camelcase
7236
4961
  ) {
7237
- var _this78 = this;
4962
+ var _this53 = this;
7238
4963
  return _asyncToGenerator(function* () {
7239
4964
  var path = "/account/3pid/unbind";
7240
4965
  var data = {
7241
4966
  medium,
7242
4967
  address,
7243
- id_server: _this78.getIdentityServerUrl(true)
4968
+ id_server: _this53.getIdentityServerUrl(true)
7244
4969
  };
7245
- return _this78.http.authedRequest(Method.Post, path, undefined, data);
4970
+ return _this53.http.authedRequest(Method.Post, path, undefined, data);
7246
4971
  })();
7247
4972
  }
7248
4973
 
@@ -7364,13 +5089,13 @@ export class MatrixClient extends TypedEventEmitter {
7364
5089
  * @returns Rejects: with an error response.
7365
5090
  */
7366
5091
  getPushers() {
7367
- var _this79 = this;
5092
+ var _this54 = this;
7368
5093
  return _asyncToGenerator(function* () {
7369
- var response = yield _this79.http.authedRequest(Method.Get, "/pushers");
5094
+ var response = yield _this54.http.authedRequest(Method.Get, "/pushers");
7370
5095
 
7371
5096
  // Migration path for clients that connect to a homeserver that does not support
7372
5097
  // MSC3881 yet, see https://github.com/matrix-org/matrix-spec-proposals/blob/kerry/remote-push-toggle/proposals/3881-remote-push-notification-toggling.md#migration
7373
- if (!(yield _this79.doesServerSupportUnstableFeature("org.matrix.msc3881"))) {
5098
+ if (!(yield _this54.doesServerSupportUnstableFeature("org.matrix.msc3881"))) {
7374
5099
  response.pushers = response.pushers.map(pusher => {
7375
5100
  if (!pusher.hasOwnProperty(PUSHER_ENABLED.name)) {
7376
5101
  pusher[PUSHER_ENABLED.name] = true;
@@ -7509,11 +5234,11 @@ export class MatrixClient extends TypedEventEmitter {
7509
5234
  * @returns Promise which resolves to the search response object.
7510
5235
  * @returns Rejects: with an error response.
7511
5236
  */
7512
- search(_ref12, abortSignal) {
5237
+ search(_ref9, abortSignal) {
7513
5238
  var {
7514
5239
  body,
7515
5240
  next_batch: nextBatch
7516
- } = _ref12;
5241
+ } = _ref9;
7517
5242
  var queryParams = {};
7518
5243
  if (nextBatch) {
7519
5244
  queryParams.next_batch = nextBatch;
@@ -7523,86 +5248,6 @@ export class MatrixClient extends TypedEventEmitter {
7523
5248
  });
7524
5249
  }
7525
5250
 
7526
- /**
7527
- * Upload keys
7528
- *
7529
- * @param content - body of upload request
7530
- *
7531
- * @param opts - this method no longer takes any opts,
7532
- * used to take opts.device_id but this was not removed from the spec as a redundant parameter
7533
- *
7534
- * @returns Promise which resolves: result object. Rejects: with
7535
- * an error response ({@link MatrixError}).
7536
- */
7537
- uploadKeysRequest(content, opts) {
7538
- return this.http.authedRequest(Method.Post, "/keys/upload", undefined, content);
7539
- }
7540
- uploadKeySignatures(content) {
7541
- return this.http.authedRequest(Method.Post, "/keys/signatures/upload", undefined, content);
7542
- }
7543
-
7544
- /**
7545
- * Download device keys
7546
- *
7547
- * @param userIds - list of users to get keys for
7548
- *
7549
- * @param token - sync token to pass in the query request, to help
7550
- * the HS give the most recent results
7551
- *
7552
- * @returns Promise which resolves: result object. Rejects: with
7553
- * an error response ({@link MatrixError}).
7554
- */
7555
- downloadKeysForUsers(userIds) {
7556
- var {
7557
- token
7558
- } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
7559
- var content = {
7560
- device_keys: {}
7561
- };
7562
- if (token !== undefined) {
7563
- content.token = token;
7564
- }
7565
- userIds.forEach(u => {
7566
- content.device_keys[u] = [];
7567
- });
7568
- return this.http.authedRequest(Method.Post, "/keys/query", undefined, content);
7569
- }
7570
-
7571
- /**
7572
- * Claim one-time keys
7573
- *
7574
- * @param devices - a list of [userId, deviceId] pairs
7575
- *
7576
- * @param keyAlgorithm - desired key type
7577
- *
7578
- * @param timeout - the time (in milliseconds) to wait for keys from remote
7579
- * servers
7580
- *
7581
- * @returns Promise which resolves: result object. Rejects: with
7582
- * an error response ({@link MatrixError}).
7583
- */
7584
- claimOneTimeKeys(devices) {
7585
- var keyAlgorithm = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "signed_curve25519";
7586
- var timeout = arguments.length > 2 ? arguments[2] : undefined;
7587
- var queries = {};
7588
- if (keyAlgorithm === undefined) {
7589
- keyAlgorithm = "signed_curve25519";
7590
- }
7591
- for (var [userId, _deviceId] of devices) {
7592
- var query = queries[userId] || {};
7593
- safeSet(queries, userId, query);
7594
- safeSet(query, _deviceId, keyAlgorithm);
7595
- }
7596
- var content = {
7597
- one_time_keys: queries
7598
- };
7599
- if (timeout) {
7600
- content.timeout = timeout;
7601
- }
7602
- var path = "/keys/claim";
7603
- return this.http.authedRequest(Method.Post, path, undefined, content);
7604
- }
7605
-
7606
5251
  /**
7607
5252
  * Ask the server for a list of users who have changed their device lists
7608
5253
  * between a pair of sync tokens
@@ -7618,16 +5263,6 @@ export class MatrixClient extends TypedEventEmitter {
7618
5263
  };
7619
5264
  return this.http.authedRequest(Method.Get, "/keys/changes", qps);
7620
5265
  }
7621
- uploadDeviceSigningKeys(auth, keys) {
7622
- // API returns empty object
7623
- var data = Object.assign({}, keys);
7624
- if (auth) Object.assign(data, {
7625
- auth
7626
- });
7627
- return this.http.authedRequest(Method.Post, "/keys/device_signing/upload", undefined, data, {
7628
- prefix: ClientPrefix.Unstable
7629
- });
7630
- }
7631
5266
 
7632
5267
  /**
7633
5268
  * Register with an identity server using the OpenID token from the user's
@@ -7800,7 +5435,7 @@ export class MatrixClient extends TypedEventEmitter {
7800
5435
  * found MXIDs. Results where no user could be found will not be listed.
7801
5436
  */
7802
5437
  identityHashedLookup(addressPairs, identityAccessToken) {
7803
- var _this80 = this;
5438
+ var _this55 = this;
7804
5439
  return _asyncToGenerator(function* () {
7805
5440
  var params = {
7806
5441
  // addresses: ["email@example.org", "10005550000"],
@@ -7809,7 +5444,7 @@ export class MatrixClient extends TypedEventEmitter {
7809
5444
  };
7810
5445
 
7811
5446
  // Get hash information first before trying to do a lookup
7812
- var hashes = yield _this80.getIdentityHashDetails(identityAccessToken);
5447
+ var hashes = yield _this55.getIdentityHashDetails(identityAccessToken);
7813
5448
  if (!hashes || !hashes["lookup_pepper"] || !hashes["algorithms"]) {
7814
5449
  throw new Error("Unsupported identity server: bad response");
7815
5450
  }
@@ -7822,7 +5457,7 @@ export class MatrixClient extends TypedEventEmitter {
7822
5457
  // When picking an algorithm, we pick the hashed over no hashes
7823
5458
  if (hashes["algorithms"].includes("sha256")) {
7824
5459
  params["addresses"] = yield Promise.all(addressPairs.map(/*#__PURE__*/function () {
7825
- var _ref13 = _asyncToGenerator(function* (p) {
5460
+ var _ref10 = _asyncToGenerator(function* (p) {
7826
5461
  var addr = p[0].toLowerCase(); // lowercase to get consistent hashes
7827
5462
  var med = p[1].toLowerCase();
7828
5463
  var hashBuffer = yield sha256("".concat(addr, " ").concat(med, " ").concat(params["pepper"]));
@@ -7833,8 +5468,8 @@ export class MatrixClient extends TypedEventEmitter {
7833
5468
  localMapping[hashed] = p[0];
7834
5469
  return hashed;
7835
5470
  });
7836
- return function (_x6) {
7837
- return _ref13.apply(this, arguments);
5471
+ return function (_x4) {
5472
+ return _ref10.apply(this, arguments);
7838
5473
  };
7839
5474
  }()));
7840
5475
  params["algorithm"] = "sha256";
@@ -7852,7 +5487,7 @@ export class MatrixClient extends TypedEventEmitter {
7852
5487
  } else {
7853
5488
  throw new Error("Unsupported identity server: unknown hash algorithm");
7854
5489
  }
7855
- var response = yield _this80.http.idServerRequest(Method.Post, "/lookup", params, IdentityPrefix.V2, identityAccessToken);
5490
+ var response = yield _this55.http.idServerRequest(Method.Post, "/lookup", params, IdentityPrefix.V2, identityAccessToken);
7856
5491
  if (!(response !== null && response !== void 0 && response["mappings"])) return []; // no results
7857
5492
 
7858
5493
  var foundAddresses = [];
@@ -7886,12 +5521,12 @@ export class MatrixClient extends TypedEventEmitter {
7886
5521
  * @returns Rejects: with an error response.
7887
5522
  */
7888
5523
  lookupThreePid(medium, address, identityAccessToken) {
7889
- var _this81 = this;
5524
+ var _this56 = this;
7890
5525
  return _asyncToGenerator(function* () {
7891
5526
  // Note: we're using the V2 API by calling this function, but our
7892
5527
  // function contract requires a V1 response. We therefore have to
7893
5528
  // convert it manually.
7894
- var response = yield _this81.identityHashedLookup([[address, medium]], identityAccessToken);
5529
+ var response = yield _this56.identityHashedLookup([[address, medium]], identityAccessToken);
7895
5530
  var result = response.find(p => p.address === address);
7896
5531
  if (!result) {
7897
5532
  return {};
@@ -7923,16 +5558,16 @@ export class MatrixClient extends TypedEventEmitter {
7923
5558
  * @returns Rejects: with an error response.
7924
5559
  */
7925
5560
  bulkLookupThreePids(query, identityAccessToken) {
7926
- var _this82 = this;
5561
+ var _this57 = this;
7927
5562
  return _asyncToGenerator(function* () {
7928
5563
  // Note: we're using the V2 API by calling this function, but our
7929
5564
  // function contract requires a V1 response. We therefore have to
7930
5565
  // convert it manually.
7931
- var response = yield _this82.identityHashedLookup(
5566
+ var response = yield _this57.identityHashedLookup(
7932
5567
  // We have to reverse the query order to get [address, medium] pairs
7933
5568
  query.map(p => [p[1], p[0]]), identityAccessToken);
7934
5569
  var v1results = [];
7935
- var _loop2 = function* _loop2(mapping) {
5570
+ var _loop = function* _loop(mapping) {
7936
5571
  var originalQuery = query.find(p => p[1] === mapping.address);
7937
5572
  if (!originalQuery) {
7938
5573
  throw new Error("Identity sever returned unexpected results");
@@ -7942,7 +5577,7 @@ export class MatrixClient extends TypedEventEmitter {
7942
5577
  mapping.address, mapping.mxid]);
7943
5578
  };
7944
5579
  for (var mapping of response) {
7945
- yield* _loop2(mapping);
5580
+ yield* _loop(mapping);
7946
5581
  }
7947
5582
  return {
7948
5583
  threepids: v1results
@@ -8129,16 +5764,16 @@ export class MatrixClient extends TypedEventEmitter {
8129
5764
  * @returns Promise which resolves to the created space.
8130
5765
  */
8131
5766
  unstableCreateFileTree(name) {
8132
- var _this83 = this;
5767
+ var _this58 = this;
8133
5768
  return _asyncToGenerator(function* () {
8134
5769
  var {
8135
5770
  room_id: roomId
8136
- } = yield _this83.createRoom({
5771
+ } = yield _this58.createRoom({
8137
5772
  name: name,
8138
5773
  preset: Preset.PrivateChat,
8139
5774
  power_level_content_override: _objectSpread(_objectSpread({}, DEFAULT_TREE_POWER_LEVELS_TEMPLATE), {}, {
8140
5775
  users: {
8141
- [_this83.getUserId()]: 100
5776
+ [_this58.getUserId()]: 100
8142
5777
  }
8143
5778
  }),
8144
5779
  creation_content: {
@@ -8150,15 +5785,9 @@ export class MatrixClient extends TypedEventEmitter {
8150
5785
  content: {
8151
5786
  [UNSTABLE_MSC3088_ENABLED.name]: true
8152
5787
  }
8153
- }, {
8154
- type: EventType.RoomEncryption,
8155
- state_key: "",
8156
- content: {
8157
- algorithm: olmlib.MEGOLM_ALGORITHM
8158
- }
8159
5788
  }]
8160
5789
  });
8161
- return new MSC3089TreeSpace(_this83, roomId);
5790
+ return new MSC3089TreeSpace(_this58, roomId);
8162
5791
  })();
8163
5792
  }
8164
5793
 
@@ -8235,7 +5864,7 @@ export class MatrixClient extends TypedEventEmitter {
8235
5864
  * @param via - The list of servers which know about the room if only an ID was provided.
8236
5865
  */
8237
5866
  getRoomSummary(roomIdOrAlias, via) {
8238
- var _this84 = this;
5867
+ var _this59 = this;
8239
5868
  return _asyncToGenerator(function* () {
8240
5869
  var paramOpts = {
8241
5870
  prefix: "/_matrix/client/unstable/im.nheko.summary"
@@ -8244,7 +5873,7 @@ export class MatrixClient extends TypedEventEmitter {
8244
5873
  var path = utils.encodeUri("/summary/$roomid", {
8245
5874
  $roomid: roomIdOrAlias
8246
5875
  });
8247
- return yield _this84.http.authedRequest(Method.Get, path, {
5876
+ return yield _this59.http.authedRequest(Method.Get, path, {
8248
5877
  via
8249
5878
  }, undefined, paramOpts);
8250
5879
  } catch (e) {
@@ -8252,7 +5881,7 @@ export class MatrixClient extends TypedEventEmitter {
8252
5881
  var _path = utils.encodeUri("/rooms/$roomid/summary", {
8253
5882
  $roomid: roomIdOrAlias
8254
5883
  });
8255
- return yield _this84.http.authedRequest(Method.Get, _path, {
5884
+ return yield _this59.http.authedRequest(Method.Get, _path, {
8256
5885
  via
8257
5886
  }, undefined, paramOpts);
8258
5887
  } else {
@@ -8304,9 +5933,9 @@ export class MatrixClient extends TypedEventEmitter {
8304
5933
  * Fetches information about the user for the configured access token.
8305
5934
  */
8306
5935
  whoami() {
8307
- var _this85 = this;
5936
+ var _this60 = this;
8308
5937
  return _asyncToGenerator(function* () {
8309
- return _this85.http.authedRequest(Method.Get, "/account/whoami");
5938
+ return _this60.http.authedRequest(Method.Get, "/account/whoami");
8310
5939
  })();
8311
5940
  }
8312
5941
 
@@ -8317,7 +5946,7 @@ export class MatrixClient extends TypedEventEmitter {
8317
5946
  * @returns Rejects: when the request fails (module:http-api.MatrixError)
8318
5947
  */
8319
5948
  timestampToEvent(roomId, timestamp, dir) {
8320
- var _this86 = this;
5949
+ var _this61 = this;
8321
5950
  return _asyncToGenerator(function* () {
8322
5951
  var path = utils.encodeUri("/rooms/$roomId/timestamp_to_event", {
8323
5952
  $roomId: roomId
@@ -8327,7 +5956,7 @@ export class MatrixClient extends TypedEventEmitter {
8327
5956
  dir: dir
8328
5957
  };
8329
5958
  try {
8330
- return yield _this86.http.authedRequest(Method.Get, path, queryParams, undefined, {
5959
+ return yield _this61.http.authedRequest(Method.Get, path, queryParams, undefined, {
8331
5960
  prefix: ClientPrefix.V1
8332
5961
  });
8333
5962
  } catch (err) {
@@ -8343,7 +5972,7 @@ export class MatrixClient extends TypedEventEmitter {
8343
5972
  // both indicate that this endpoint+verb combination is
8344
5973
  // not supported.
8345
5974
  err.httpStatus === 404 || err.httpStatus === 405)) {
8346
- return yield _this86.http.authedRequest(Method.Get, path, queryParams, undefined, {
5975
+ return yield _this61.http.authedRequest(Method.Get, path, queryParams, undefined, {
8347
5976
  prefix: "/_matrix/client/unstable/org.matrix.msc3030"
8348
5977
  });
8349
5978
  }
@@ -8359,9 +5988,9 @@ export class MatrixClient extends TypedEventEmitter {
8359
5988
  * @experimental - part of MSC2965
8360
5989
  */
8361
5990
  getAuthIssuer() {
8362
- var _this87 = this;
5991
+ var _this62 = this;
8363
5992
  return _asyncToGenerator(function* () {
8364
- return _this87.http.request(Method.Get, "/auth_issuer", undefined, undefined, {
5993
+ return _this62.http.request(Method.Get, "/auth_issuer", undefined, undefined, {
8365
5994
  prefix: ClientPrefix.Unstable + "/org.matrix.msc2965"
8366
5995
  });
8367
5996
  })();
@@ -8369,8 +5998,8 @@ export class MatrixClient extends TypedEventEmitter {
8369
5998
  }
8370
5999
  _defineProperty(MatrixClient, "RESTORE_BACKUP_ERROR_BAD_KEY", "RESTORE_BACKUP_ERROR_BAD_KEY");
8371
6000
  function getUnstableDelayQueryOpts(delayOpts) {
8372
- return Object.fromEntries(Object.entries(delayOpts).map(_ref14 => {
8373
- var [k, v] = _ref14;
6001
+ return Object.fromEntries(Object.entries(delayOpts).map(_ref11 => {
6002
+ var [k, v] = _ref11;
8374
6003
  return ["".concat(UNSTABLE_MSC4140_DELAYED_EVENTS, ".").concat(k), v];
8375
6004
  }));
8376
6005
  }