@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/src/client.ts CHANGED
@@ -20,7 +20,6 @@ limitations under the License.
20
20
 
21
21
  import { Optional } from "matrix-events-sdk";
22
22
 
23
- import type { IDeviceKeys, IMegolmSessionData, IOneTimeKey } from "./@types/crypto.ts";
24
23
  import { ISyncStateData, SetPresence, SyncApi, SyncApiOptions, SyncState } from "./sync.ts";
25
24
  import {
26
25
  EventStatus,
@@ -34,18 +33,13 @@ import {
34
33
  } from "./models/event.ts";
35
34
  import { StubStore } from "./store/stub.ts";
36
35
  import { Filter, IFilterDefinition, IRoomEventFilter } from "./filter.ts";
37
-
38
36
  import * as utils from "./utils.ts";
39
- import { noUnsafeEventProps, QueryDict, replaceParam, safeSet, sleep } from "./utils.ts";
37
+ import { noUnsafeEventProps, QueryDict, replaceParam, sleep } from "./utils.ts";
40
38
  import { Direction, EventTimeline } from "./models/event-timeline.ts";
41
39
  import { IActionsObject, PushProcessor } from "./pushprocessor.ts";
42
40
  import { AutoDiscovery, AutoDiscoveryAction } from "./autodiscovery.ts";
43
- import * as olmlib from "./crypto/olmlib.ts";
44
- import { decodeBase64, encodeBase64, encodeUnpaddedBase64Url } from "./base64.ts";
45
- import { IExportedDevice as IExportedOlmDevice } from "./crypto/OlmDevice.ts";
46
- import { IOlmDevice } from "./crypto/algorithms/megolm.ts";
41
+ import { encodeUnpaddedBase64Url } from "./base64.ts";
47
42
  import { TypedReEmitter } from "./ReEmitter.ts";
48
- import { IRoomEncryption } from "./crypto/RoomList.ts";
49
43
  import { logger, Logger } from "./logger.ts";
50
44
  import { SERVICE_TYPES } from "./service-types.ts";
51
45
  import {
@@ -54,7 +48,6 @@ import {
54
48
  FileType,
55
49
  HttpApiEvent,
56
50
  HttpApiEventHandlerMap,
57
- HTTPError,
58
51
  IdentityPrefix,
59
52
  IHttpOpts,
60
53
  IRequestOpts,
@@ -68,38 +61,16 @@ import {
68
61
  UploadOpts,
69
62
  UploadResponse,
70
63
  } from "./http-api/index.ts";
71
- import {
72
- Crypto,
73
- CryptoEvent as LegacyCryptoEvent,
74
- CryptoEventHandlerMap as LegacyCryptoEventHandlerMap,
75
- fixBackupKey,
76
- ICheckOwnCrossSigningTrustOpts,
77
- IRoomKeyRequestBody,
78
- } from "./crypto/index.ts";
79
- import { DeviceInfo } from "./crypto/deviceinfo.ts";
80
64
  import { User, UserEvent, UserEventHandlerMap } from "./models/user.ts";
81
65
  import { getHttpUriForMxc } from "./content-repo.ts";
82
66
  import { SearchResult } from "./models/search-result.ts";
83
- import { DEHYDRATION_ALGORITHM, IDehydratedDevice, IDehydratedDeviceKeyInfo } from "./crypto/dehydration.ts";
84
- import {
85
- IKeyBackupInfo,
86
- IKeyBackupPrepareOpts,
87
- IKeyBackupRestoreOpts,
88
- IKeyBackupRestoreResult,
89
- IKeyBackupRoomSessions,
90
- IKeyBackupSession,
91
- } from "./crypto/keybackup.ts";
92
67
  import { IIdentityServerProvider } from "./@types/IIdentityServerProvider.ts";
93
68
  import { MatrixScheduler } from "./scheduler.ts";
94
69
  import { BeaconEvent, BeaconEventHandlerMap } from "./models/beacon.ts";
95
70
  import { AuthDict } from "./interactive-auth.ts";
96
71
  import { IMinimalEvent, IRoomEvent, IStateEvent } from "./sync-accumulator.ts";
97
- import { CrossSigningKey, ICreateSecretStorageOpts, IEncryptedEventInfo, IRecoveryKey } from "./crypto/api.ts";
98
72
  import { EventTimelineSet } from "./models/event-timeline-set.ts";
99
- import { VerificationRequest } from "./crypto/verification/request/VerificationRequest.ts";
100
- import { VerificationBase as Verification } from "./crypto/verification/Base.ts";
101
73
  import * as ContentHelpers from "./content-helpers.ts";
102
- import { CrossSigningInfo, DeviceTrustLevel, ICacheCallbacks, UserTrustLevel } from "./crypto/CrossSigning.ts";
103
74
  import { NotificationCountType, Room, RoomEvent, RoomEventHandlerMap, RoomNameState } from "./models/room.ts";
104
75
  import { RoomMemberEvent, RoomMemberEventHandlerMap } from "./models/room-member.ts";
105
76
  import { IPowerLevelsContent, RoomStateEvent, RoomStateEventHandlerMap } from "./models/room-state.ts";
@@ -154,11 +125,9 @@ import {
154
125
  } from "./@types/partials.ts";
155
126
  import { EventMapper, eventMapperFor, MapperOpts } from "./event-mapper.ts";
156
127
  import { randomString } from "./randomstring.ts";
157
- import { BackupManager, IKeyBackup, IKeyBackupCheck, IPreparedKeyBackupVersion, TrustInfo } from "./crypto/backup.ts";
158
128
  import { DEFAULT_TREE_POWER_LEVELS_TEMPLATE, MSC3089TreeSpace } from "./models/MSC3089TreeSpace.ts";
159
129
  import { ISignatures } from "./@types/signed.ts";
160
130
  import { IStore } from "./store/index.ts";
161
- import { ISecretRequest } from "./crypto/SecretStorage.ts";
162
131
  import {
163
132
  IEventWithRoomId,
164
133
  ISearchRequestBody,
@@ -180,7 +149,6 @@ import {
180
149
  RuleId,
181
150
  } from "./@types/PushRules.ts";
182
151
  import { IThreepid } from "./@types/threepids.ts";
183
- import { CryptoStore, OutgoingRoomKeyRequest } from "./crypto/store/base.ts";
184
152
  import {
185
153
  ILoginFlowsResponse,
186
154
  IRefreshTokenResponse,
@@ -209,25 +177,6 @@ import { IgnoredInvites } from "./models/invites-ignorer.ts";
209
177
  import { UIARequest, UIAResponse } from "./@types/uia.ts";
210
178
  import { LocalNotificationSettings } from "./@types/local_notifications.ts";
211
179
  import { buildFeatureSupportMap, Feature, ServerSupport } from "./feature.ts";
212
- import { BackupDecryptor, CryptoBackend } from "./common-crypto/CryptoBackend.ts";
213
- import { RUST_SDK_STORE_PREFIX } from "./rust-crypto/constants.ts";
214
- import {
215
- BootstrapCrossSigningOpts,
216
- CrossSigningKeyInfo,
217
- CryptoApi,
218
- decodeRecoveryKey,
219
- ImportRoomKeysOpts,
220
- CryptoEvent,
221
- CryptoEventHandlerMap,
222
- CryptoCallbacks,
223
- } from "./crypto-api/index.ts";
224
- import { DeviceInfoMap } from "./crypto/DeviceList.ts";
225
- import {
226
- AddSecretStorageKeyOpts,
227
- SecretStorageKeyDescription,
228
- ServerSideSecretStorage,
229
- ServerSideSecretStorageImpl,
230
- } from "./secret-storage.ts";
231
180
  import { RegisterRequest, RegisterResponse } from "./@types/registration.ts";
232
181
  import { getRelationsThreadFilter } from "./thread-utils.ts";
233
182
  import { KnownMembership, Membership } from "./@types/membership.ts";
@@ -235,14 +184,12 @@ import { RoomMessageEventContent, StickerEventContent } from "./@types/events.ts
235
184
  import { ImageInfo } from "./@types/media.ts";
236
185
  import { Capabilities, ServerCapabilities } from "./serverCapabilities.ts";
237
186
  import { sha256 } from "./digest.ts";
238
- import { keyFromAuthData } from "./common-crypto/key-passphrase.ts";
239
187
 
240
188
  export type Store = IStore;
241
189
 
242
190
  export type ResetTimelineCallback = (roomId: string) => boolean;
243
191
 
244
192
  const SCROLLBACK_DELAY_MS = 3000;
245
- const TURN_CHECK_INTERVAL = 10 * 60 * 1000; // poll for turn credentials every 10 minutes
246
193
 
247
194
  export const UNSTABLE_MSC3852_LAST_SEEN_UA = new UnstableValue(
248
195
  "last_seen_user_agent",
@@ -250,7 +197,6 @@ export const UNSTABLE_MSC3852_LAST_SEEN_UA = new UnstableValue(
250
197
  );
251
198
 
252
199
  interface IExportedDevice {
253
- olmDevice: IExportedOlmDevice;
254
200
  userId: string;
255
201
  deviceId: string;
256
202
  }
@@ -274,20 +220,6 @@ export interface ICreateClientOpts {
274
220
  */
275
221
  store?: Store;
276
222
 
277
- /**
278
- * A store to be used for end-to-end crypto session data.
279
- * The `createClient` helper will create a default store if needed. Calls the factory supplied to
280
- * {@link setCryptoStoreFactory} if unspecified; or if no factory has been
281
- * specified, uses a default implementation (indexeddb in the browser,
282
- * in-memory otherwise).
283
- *
284
- * This is only used for the legacy crypto implementation (as used by {@link MatrixClient#initCrypto}),
285
- * but if you use the rust crypto implementation ({@link MatrixClient#initRustCrypto}) and the device
286
- * previously used legacy crypto (so must be migrated), then this must still be provided, so that the
287
- * data can be migrated from the legacy store.
288
- */
289
- cryptoStore?: CryptoStore;
290
-
291
223
  /**
292
224
  * The scheduler to use. If not
293
225
  * specified, this client will not retry requests on failure. This client
@@ -423,11 +355,6 @@ export interface ICreateClientOpts {
423
355
 
424
356
  livekitServiceURL?: string;
425
357
 
426
- /**
427
- * Crypto callbacks provided by the application
428
- */
429
- cryptoCallbacks?: CryptoCallbacks;
430
-
431
358
  /**
432
359
  * Method to generate room names for empty rooms and rooms names based on membership.
433
360
  * Defaults to a built-in English handler with basic pluralisation.
@@ -546,14 +473,6 @@ export const UNSTABLE_MSC4140_DELAYED_EVENTS = "org.matrix.msc4140";
546
473
 
547
474
  export const UNSTABLE_MSC4133_EXTENDED_PROFILES = "uk.tcpip.msc4133";
548
475
 
549
- enum CrossSigningKeyType {
550
- MasterKey = "master_key",
551
- SelfSigningKey = "self_signing_key",
552
- UserSigningKey = "user_signing_key",
553
- }
554
-
555
- export type CrossSigningKeys = Record<CrossSigningKeyType, CrossSigningKeyInfo>;
556
-
557
476
  export type SendToDeviceContentMap = Map<string, Map<string, Record<string, any>>>;
558
477
 
559
478
  export interface ISignedKey {
@@ -564,7 +483,6 @@ export interface ISignedKey {
564
483
  device_id: string;
565
484
  }
566
485
 
567
- export type KeySignatures = Record<string, Record<string, CrossSigningKeyInfo | ISignedKey>>;
568
486
  export interface IUploadKeySignaturesResponse {
569
487
  failures: Record<
570
488
  string,
@@ -626,13 +544,6 @@ export interface IWellKnownConfig<T = IClientWellKnown> {
626
544
  server_name?: string;
627
545
  }
628
546
 
629
- interface IKeyBackupPath {
630
- path: string;
631
- queryData?: {
632
- version: string;
633
- };
634
- }
635
-
636
547
  interface IMediaConfig {
637
548
  [key: string]: any; // extensible
638
549
  "m.upload.size"?: number;
@@ -679,12 +590,6 @@ export interface IRequestMsisdnTokenResponse extends IRequestTokenResponse {
679
590
  intl_fmt: string;
680
591
  }
681
592
 
682
- export interface IUploadKeysRequest {
683
- "device_keys"?: Required<IDeviceKeys>;
684
- "one_time_keys"?: Record<string, IOneTimeKey>;
685
- "org.matrix.msc2732.fallback_keys"?: Record<string, IOneTimeKey>;
686
- }
687
-
688
593
  export interface IQueryKeysRequest {
689
594
  device_keys: { [userId: string]: string[] };
690
595
  timeout?: number;
@@ -779,27 +684,6 @@ export interface Keys {
779
684
  user_id: string;
780
685
  }
781
686
 
782
- export interface SigningKeys extends Keys {
783
- signatures: ISignatures;
784
- }
785
-
786
- export interface DeviceKeys {
787
- [deviceId: string]: IDeviceKeys & {
788
- unsigned?: {
789
- device_display_name: string;
790
- };
791
- };
792
- }
793
-
794
- export interface IDownloadKeyResult {
795
- failures: { [serverName: string]: object };
796
- device_keys: { [userId: string]: DeviceKeys };
797
- // the following three fields were added in 1.1
798
- master_keys?: { [userId: string]: Keys };
799
- self_signing_keys?: { [userId: string]: SigningKeys };
800
- user_signing_keys?: { [userId: string]: SigningKeys };
801
- }
802
-
803
687
  export interface IClaimOTKsResult {
804
688
  failures: { [serverName: string]: object };
805
689
  one_time_keys: {
@@ -868,14 +752,6 @@ export interface RoomSummary extends Omit<IPublicRoomsChunkRoom, "canonical_alia
868
752
  "im.nheko.summary.encryption"?: string;
869
753
  }
870
754
 
871
- interface IRoomKeysResponse {
872
- sessions: IKeyBackupRoomSessions;
873
- }
874
-
875
- interface IRoomsKeysResponse {
876
- rooms: Record<string, IRoomKeysResponse>;
877
- }
878
-
879
755
  interface IRoomHierarchy {
880
756
  rooms: IHierarchyRoom[];
881
757
  next_batch?: string;
@@ -934,26 +810,6 @@ type RoomStateEvents =
934
810
  | RoomStateEvent.Update
935
811
  | RoomStateEvent.Marker;
936
812
 
937
- type LegacyCryptoEvents =
938
- | LegacyCryptoEvent.KeySignatureUploadFailure
939
- | LegacyCryptoEvent.KeyBackupStatus
940
- | LegacyCryptoEvent.KeyBackupFailed
941
- | LegacyCryptoEvent.KeyBackupSessionsRemaining
942
- | LegacyCryptoEvent.KeyBackupDecryptionKeyCached
943
- | LegacyCryptoEvent.RoomKeyRequest
944
- | LegacyCryptoEvent.RoomKeyRequestCancellation
945
- | LegacyCryptoEvent.VerificationRequest
946
- | LegacyCryptoEvent.VerificationRequestReceived
947
- | LegacyCryptoEvent.DeviceVerificationChanged
948
- | LegacyCryptoEvent.UserTrustStatusChanged
949
- | LegacyCryptoEvent.KeysChanged
950
- | LegacyCryptoEvent.Warning
951
- | LegacyCryptoEvent.DevicesUpdated
952
- | LegacyCryptoEvent.WillUpdateDevices
953
- | LegacyCryptoEvent.LegacyCryptoStoreMigrationProgress;
954
-
955
- type CryptoEvents = (typeof CryptoEvent)[keyof typeof CryptoEvent];
956
-
957
813
  type MatrixEventEvents = MatrixEventEvent.Decrypted | MatrixEventEvent.Replaced | MatrixEventEvent.VisibilityChange;
958
814
 
959
815
  type RoomMemberEvents =
@@ -973,8 +829,6 @@ export type EmittedEvents =
973
829
  | ClientEvent
974
830
  | RoomEvents
975
831
  | RoomStateEvents
976
- | LegacyCryptoEvents
977
- | CryptoEvents
978
832
  | MatrixEventEvents
979
833
  | RoomMemberEvents
980
834
  | UserEvents
@@ -1179,8 +1033,6 @@ export type ClientEventHandlerMap = {
1179
1033
  [ClientEvent.TurnServersError]: (error: Error, fatal: boolean) => void;
1180
1034
  } & RoomEventHandlerMap &
1181
1035
  RoomStateEventHandlerMap &
1182
- LegacyCryptoEventHandlerMap &
1183
- CryptoEventHandlerMap &
1184
1036
  MatrixEventHandlerMap &
1185
1037
  RoomMemberEventHandlerMap &
1186
1038
  UserEventHandlerMap &
@@ -1224,16 +1076,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
1224
1076
  public identityServer?: IIdentityServerProvider;
1225
1077
  public http: MatrixHttpApi<IHttpOpts & { onlyData: true }>; // XXX: Intended private, used in code.
1226
1078
 
1227
- /**
1228
- * The libolm crypto implementation, if it is in use.
1229
- *
1230
- * @deprecated This should not be used. Instead, use the methods exposed directly on this class or
1231
- * (where they are available) via {@link getCrypto}.
1232
- */
1233
- public crypto?: Crypto; // XXX: Intended private, used in code. Being replaced by cryptoBackend
1234
-
1235
- private cryptoBackend?: CryptoBackend; // one of crypto or rustCrypto
1236
- public cryptoCallbacks: CryptoCallbacks; // XXX: Intended private, used in code.
1237
1079
  public supportsCallTransfer = false; // XXX: Intended private, used in code.
1238
1080
  public forceTURN = false; // XXX: Intended private, used in code.
1239
1081
  public iceCandidatePoolSize = 0; // XXX: Intended private, used in code.
@@ -1246,13 +1088,11 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
1246
1088
  // Note: these are all `protected` to let downstream consumers make mistakes if they want to.
1247
1089
  // We don't technically support this usage, but have reasons to do this.
1248
1090
 
1249
- protected canSupportVoip = false;
1250
1091
  protected peekSync: SyncApi | null = null;
1251
1092
  protected isGuestAccount = false;
1252
1093
  protected ongoingScrollbacks: { [roomId: string]: { promise?: Promise<Room>; errorTs?: number } } = {};
1253
1094
  protected notifTimelineSet: EventTimelineSet | null = null;
1254
1095
  /* @deprecated */
1255
- protected cryptoStore?: CryptoStore;
1256
1096
  protected verificationMethods?: string[];
1257
1097
  protected fallbackICEServerAllowed = false;
1258
1098
  protected syncApi?: SlidingSyncSdk | SyncApi;
@@ -1275,10 +1115,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
1275
1115
 
1276
1116
  protected clientWellKnown?: IClientWellKnown;
1277
1117
  protected clientWellKnownPromise?: Promise<IClientWellKnown>;
1278
- protected turnServers: ITurnServer[] = [];
1279
- protected turnServersExpiry = 0;
1280
- protected checkTurnServersIntervalID?: ReturnType<typeof setInterval>;
1281
- protected exportedOlmDeviceToImport?: IExportedOlmDevice;
1282
1118
  protected txnCtr = 0;
1283
1119
  protected sessionId: string;
1284
1120
 
@@ -1293,8 +1129,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
1293
1129
  private toDeviceMessageQueue: ToDeviceMessageQueue;
1294
1130
  public livekitServiceURL?: string;
1295
1131
 
1296
- private _secretStorage: ServerSideSecretStorageImpl;
1297
-
1298
1132
  // A manager for determining which invites should be ignored.
1299
1133
  public readonly ignoredInvites: IgnoredInvites;
1300
1134
 
@@ -1353,8 +1187,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
1353
1187
  } else {
1354
1188
  this.deviceId = opts.deviceToImport.deviceId;
1355
1189
  this.credentials.userId = opts.deviceToImport.userId;
1356
- // will be used during async initialization of the crypto
1357
- this.exportedOlmDeviceToImport = opts.deviceToImport.olmDevice;
1358
1190
  }
1359
1191
  } else if (opts.pickleKey) {
1360
1192
  this.pickleKey = opts.pickleKey;
@@ -1385,9 +1217,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
1385
1217
 
1386
1218
  this.timelineSupport = Boolean(opts.timelineSupport);
1387
1219
 
1388
- this.cryptoStore = opts.cryptoStore;
1389
1220
  this.verificationMethods = opts.verificationMethods;
1390
- this.cryptoCallbacks = opts.cryptoCallbacks || {};
1391
1221
 
1392
1222
  this.forceTURN = opts.forceTURN || false;
1393
1223
  this.iceCandidatePoolSize = opts.iceCandidatePoolSize === undefined ? 0 : opts.iceCandidatePoolSize;
@@ -1412,7 +1242,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
1412
1242
  });
1413
1243
 
1414
1244
  this.ignoredInvites = new IgnoredInvites(this);
1415
- this._secretStorage = new ServerSideSecretStorageImpl(this, opts.cryptoCallbacks ?? {});
1416
1245
 
1417
1246
  // having lots of event listeners is not unusual. 0 means "unlimited".
1418
1247
  this.setMaxListeners(0);
@@ -1448,15 +1277,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
1448
1277
  this.store.storeUser(new User(userId));
1449
1278
  }
1450
1279
 
1451
- // periodically poll for turn servers if we support voip
1452
- if (this.canSupportVoip) {
1453
- this.checkTurnServersIntervalID = setInterval(() => {
1454
- this.checkTurnServers();
1455
- }, TURN_CHECK_INTERVAL);
1456
- // noinspection ES6MissingAwait
1457
- this.checkTurnServers();
1458
- }
1459
-
1460
1280
  if (this.syncApi) {
1461
1281
  // This shouldn't happen since we thought the client was not running
1462
1282
  this.logger.error("Still have sync object whilst not running: stopping old one");
@@ -1485,7 +1305,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
1485
1305
  this.clientOpts.slidingSync,
1486
1306
  this,
1487
1307
  this.clientOpts,
1488
- this.buildSyncApiOptions(),
1489
1308
  );
1490
1309
  } else {
1491
1310
  this.syncApi = new SyncApi(this, this.clientOpts, this.buildSyncApiOptions());
@@ -1509,8 +1328,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
1509
1328
  */
1510
1329
  protected buildSyncApiOptions(): SyncApiOptions {
1511
1330
  return {
1512
- crypto: this.crypto,
1513
- cryptoCallbacks: this.cryptoBackend,
1514
1331
  canResetEntireTimeline: (roomId: string): boolean => {
1515
1332
  if (!this.canResetTimelineCallback) {
1516
1333
  return false;
@@ -1525,8 +1342,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
1525
1342
  * clean shutdown.
1526
1343
  */
1527
1344
  public stopClient(): void {
1528
- this.cryptoBackend?.stop(); // crypto might have been initialised even if the client wasn't fully started
1529
-
1530
1345
  if (!this.clientRunning) return; // already stopped
1531
1346
 
1532
1347
  this.logger.debug("stopping MatrixClient");
@@ -1538,9 +1353,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
1538
1353
 
1539
1354
  this.peekSync?.stopPeeking();
1540
1355
 
1541
- globalThis.clearInterval(this.checkTurnServersIntervalID);
1542
- this.checkTurnServersIntervalID = undefined;
1543
-
1544
1356
  if (this.clientWellKnownIntervalID !== undefined) {
1545
1357
  globalThis.clearInterval(this.clientWellKnownIntervalID);
1546
1358
  }
@@ -1550,171 +1362,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
1550
1362
  this.serverCapabilitiesService.stop();
1551
1363
  }
1552
1364
 
1553
- /**
1554
- * Try to rehydrate a device if available. The client must have been
1555
- * initialized with a `cryptoCallback.getDehydrationKey` option, and this
1556
- * function must be called before initCrypto and startClient are called.
1557
- *
1558
- * @returns Promise which resolves to undefined if a device could not be dehydrated, or
1559
- * to the new device ID if the dehydration was successful.
1560
- * @returns Rejects: with an error response.
1561
- *
1562
- * @deprecated MSC2697 device dehydration is not supported for rust cryptography.
1563
- */
1564
- public async rehydrateDevice(): Promise<string | undefined> {
1565
- if (this.crypto) {
1566
- throw new Error("Cannot rehydrate device after crypto is initialized");
1567
- }
1568
-
1569
- if (!this.cryptoCallbacks.getDehydrationKey) {
1570
- return;
1571
- }
1572
-
1573
- const getDeviceResult = await this.getDehydratedDevice();
1574
- if (!getDeviceResult) {
1575
- return;
1576
- }
1577
-
1578
- if (!getDeviceResult.device_data || !getDeviceResult.device_id) {
1579
- this.logger.info("no dehydrated device found");
1580
- return;
1581
- }
1582
-
1583
- const account = new globalThis.Olm.Account();
1584
- try {
1585
- const deviceData = getDeviceResult.device_data;
1586
- if (deviceData.algorithm !== DEHYDRATION_ALGORITHM) {
1587
- this.logger.warn("Wrong algorithm for dehydrated device");
1588
- return;
1589
- }
1590
- this.logger.debug("unpickling dehydrated device");
1591
- const key = await this.cryptoCallbacks.getDehydrationKey(deviceData, (k) => {
1592
- // copy the key so that it doesn't get clobbered
1593
- account.unpickle(new Uint8Array(k), deviceData.account);
1594
- });
1595
- account.unpickle(key, deviceData.account);
1596
- this.logger.debug("unpickled device");
1597
-
1598
- const rehydrateResult = await this.http.authedRequest<{ success: boolean }>(
1599
- Method.Post,
1600
- "/dehydrated_device/claim",
1601
- undefined,
1602
- {
1603
- device_id: getDeviceResult.device_id,
1604
- },
1605
- {
1606
- prefix: "/_matrix/client/unstable/org.matrix.msc2697.v2",
1607
- },
1608
- );
1609
-
1610
- if (rehydrateResult.success) {
1611
- this.deviceId = getDeviceResult.device_id;
1612
- this.logger.info("using dehydrated device");
1613
- const pickleKey = this.pickleKey || "DEFAULT_KEY";
1614
- this.exportedOlmDeviceToImport = {
1615
- pickledAccount: account.pickle(pickleKey),
1616
- sessions: [],
1617
- pickleKey: pickleKey,
1618
- };
1619
- account.free();
1620
- return this.deviceId;
1621
- } else {
1622
- account.free();
1623
- this.logger.info("not using dehydrated device");
1624
- return;
1625
- }
1626
- } catch (e) {
1627
- account.free();
1628
- this.logger.warn("could not unpickle", e);
1629
- }
1630
- }
1631
-
1632
- /**
1633
- * Get the current dehydrated device, if any
1634
- * @returns A promise of an object containing the dehydrated device
1635
- *
1636
- * @deprecated MSC2697 device dehydration is not supported for rust cryptography.
1637
- */
1638
- public async getDehydratedDevice(): Promise<IDehydratedDevice | undefined> {
1639
- try {
1640
- return await this.http.authedRequest<IDehydratedDevice>(
1641
- Method.Get,
1642
- "/dehydrated_device",
1643
- undefined,
1644
- undefined,
1645
- {
1646
- prefix: "/_matrix/client/unstable/org.matrix.msc2697.v2",
1647
- },
1648
- );
1649
- } catch (e) {
1650
- this.logger.info("could not get dehydrated device", e);
1651
- return;
1652
- }
1653
- }
1654
-
1655
- /**
1656
- * Set the dehydration key. This will also periodically dehydrate devices to
1657
- * the server.
1658
- *
1659
- * @param key - the dehydration key
1660
- * @param keyInfo - Information about the key. Primarily for
1661
- * information about how to generate the key from a passphrase.
1662
- * @param deviceDisplayName - The device display name for the
1663
- * dehydrated device.
1664
- * @returns A promise that resolves when the dehydrated device is stored.
1665
- *
1666
- * @deprecated Not supported for Rust Cryptography.
1667
- */
1668
- public async setDehydrationKey(
1669
- key: Uint8Array,
1670
- keyInfo: IDehydratedDeviceKeyInfo,
1671
- deviceDisplayName?: string,
1672
- ): Promise<void> {
1673
- if (!this.crypto) {
1674
- this.logger.warn("not dehydrating device if crypto is not enabled");
1675
- return;
1676
- }
1677
- return this.crypto.dehydrationManager.setKeyAndQueueDehydration(key, keyInfo, deviceDisplayName);
1678
- }
1679
-
1680
- /**
1681
- * Creates a new MSC2967 dehydrated device (without queuing periodic dehydration)
1682
- * @param key - the dehydration key
1683
- * @param keyInfo - Information about the key. Primarily for
1684
- * information about how to generate the key from a passphrase.
1685
- * @param deviceDisplayName - The device display name for the
1686
- * dehydrated device.
1687
- * @returns the device id of the newly created dehydrated device
1688
- *
1689
- * @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi.startDehydration}.
1690
- */
1691
- public async createDehydratedDevice(
1692
- key: Uint8Array,
1693
- keyInfo: IDehydratedDeviceKeyInfo,
1694
- deviceDisplayName?: string,
1695
- ): Promise<string | undefined> {
1696
- if (!this.crypto) {
1697
- this.logger.warn("not dehydrating device if crypto is not enabled");
1698
- return;
1699
- }
1700
- await this.crypto.dehydrationManager.setKey(key, keyInfo, deviceDisplayName);
1701
- return this.crypto.dehydrationManager.dehydrateDevice();
1702
- }
1703
-
1704
- /** @deprecated Not supported for Rust Cryptography. */
1705
- public async exportDevice(): Promise<IExportedDevice | undefined> {
1706
- if (!this.crypto) {
1707
- this.logger.warn("not exporting device if crypto is not enabled");
1708
- return;
1709
- }
1710
- return {
1711
- userId: this.credentials.userId!,
1712
- deviceId: this.deviceId!,
1713
- // XXX: Private member access.
1714
- olmDevice: await this.crypto.olmDevice.export(),
1715
- };
1716
- }
1717
-
1718
1365
  /**
1719
1366
  * Clear any data out of the persistent stores used by the client.
1720
1367
  *
@@ -1728,48 +1375,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
1728
1375
  const promises: Promise<void>[] = [];
1729
1376
 
1730
1377
  promises.push(this.store.deleteAllData());
1731
- if (this.cryptoStore) {
1732
- promises.push(this.cryptoStore.deleteAllData());
1733
- }
1734
-
1735
- // delete the stores used by the rust matrix-sdk-crypto, in case they were used
1736
- const deleteRustSdkStore = async (): Promise<void> => {
1737
- let indexedDB: IDBFactory;
1738
- try {
1739
- indexedDB = globalThis.indexedDB;
1740
- if (!indexedDB) return; // No indexedDB support
1741
- } catch {
1742
- // No indexedDB support
1743
- return;
1744
- }
1745
- for (const dbname of [
1746
- `${RUST_SDK_STORE_PREFIX}::matrix-sdk-crypto`,
1747
- `${RUST_SDK_STORE_PREFIX}::matrix-sdk-crypto-meta`,
1748
- ]) {
1749
- const prom = new Promise((resolve, reject) => {
1750
- this.logger.info(`Removing IndexedDB instance ${dbname}`);
1751
- const req = indexedDB.deleteDatabase(dbname);
1752
- req.onsuccess = (_): void => {
1753
- this.logger.info(`Removed IndexedDB instance ${dbname}`);
1754
- resolve(0);
1755
- };
1756
- req.onerror = (e): void => {
1757
- // In private browsing, Firefox has a globalThis.indexedDB, but attempts to delete an indexeddb
1758
- // (even a non-existent one) fail with "DOMException: A mutation operation was attempted on a
1759
- // database that did not allow mutations."
1760
- //
1761
- // it seems like the only thing we can really do is ignore the error.
1762
- this.logger.warn(`Failed to remove IndexedDB instance ${dbname}:`, e);
1763
- resolve(0);
1764
- };
1765
- req.onblocked = (e): void => {
1766
- this.logger.info(`cannot yet remove IndexedDB instance ${dbname}`);
1767
- };
1768
- });
1769
- await prom;
1770
- }
1771
- };
1772
- promises.push(deleteRustSdkStore());
1773
1378
 
1774
1379
  return Promise.all(promises).then(); // .then to fix types
1775
1380
  }
@@ -1838,14 +1443,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
1838
1443
  return this.sessionId;
1839
1444
  }
1840
1445
 
1841
- /**
1842
- * Check if the runtime environment supports VoIP calling.
1843
- * @returns True if VoIP is supported.
1844
- */
1845
- public supportsVoip(): boolean {
1846
- return this.canSupportVoip;
1847
- }
1848
-
1849
1446
  /**
1850
1447
  * Set whether VoIP calls are forced to use only TURN
1851
1448
  * candidates. This is the same as the forceTURN option
@@ -1919,2090 +1516,100 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
1919
1516
  }
1920
1517
 
1921
1518
  /**
1922
- * Return whether the client is configured for a guest account.
1923
- * @returns True if this is a guest access_token (or no token is supplied).
1924
- */
1925
- public isGuest(): boolean {
1926
- return this.isGuestAccount;
1927
- }
1928
-
1929
- /**
1930
- * Set whether this client is a guest account. <b>This method is experimental
1931
- * and may change without warning.</b>
1932
- * @param guest - True if this is a guest account.
1933
- * @experimental if the token is a macaroon, it should be encoded in it that it is a 'guest'
1934
- * access token, which means that the SDK can determine this entirely without
1935
- * the dev manually flipping this flag.
1936
- */
1937
- public setGuest(guest: boolean): void {
1938
- this.isGuestAccount = guest;
1939
- }
1940
-
1941
- /**
1942
- * Return the provided scheduler, if any.
1943
- * @returns The scheduler or undefined
1944
- */
1945
- public getScheduler(): MatrixScheduler | undefined {
1946
- return this.scheduler;
1947
- }
1948
-
1949
- /**
1950
- * Retry a backed off syncing request immediately. This should only be used when
1951
- * the user <b>explicitly</b> attempts to retry their lost connection.
1952
- * Will also retry any outbound to-device messages currently in the queue to be sent
1953
- * (retries of regular outgoing events are handled separately, per-event).
1954
- * @returns True if this resulted in a request being retried.
1955
- */
1956
- public retryImmediately(): boolean {
1957
- // don't await for this promise: we just want to kick it off
1958
- this.toDeviceMessageQueue.sendQueue();
1959
- return this.syncApi?.retryImmediately() ?? false;
1960
- }
1961
-
1962
- /**
1963
- * Return the global notification EventTimelineSet, if any
1964
- *
1965
- * @returns the globl notification EventTimelineSet
1966
- */
1967
- public getNotifTimelineSet(): EventTimelineSet | null {
1968
- return this.notifTimelineSet;
1969
- }
1970
-
1971
- /**
1972
- * Set the global notification EventTimelineSet
1973
- *
1974
- */
1975
- public setNotifTimelineSet(set: EventTimelineSet): void {
1976
- this.notifTimelineSet = set;
1977
- }
1978
-
1979
- /**
1980
- * Gets the cached capabilities of the homeserver, returning cached ones if available.
1981
- * If there are no cached capabilities and none can be fetched, throw an exception.
1982
- *
1983
- * @returns Promise resolving with The capabilities of the homeserver
1984
- */
1985
- public async getCapabilities(): Promise<Capabilities> {
1986
- const caps = this.serverCapabilitiesService.getCachedCapabilities();
1987
- if (caps) return caps;
1988
- return this.serverCapabilitiesService.fetchCapabilities();
1989
- }
1990
-
1991
- /**
1992
- * Gets the cached capabilities of the homeserver. If none have been fetched yet,
1993
- * return undefined.
1994
- *
1995
- * @returns The capabilities of the homeserver
1996
- */
1997
- public getCachedCapabilities(): Capabilities | undefined {
1998
- return this.serverCapabilitiesService.getCachedCapabilities();
1999
- }
2000
-
2001
- /**
2002
- * Fetches the latest capabilities from the homeserver, ignoring any cached
2003
- * versions. The newly returned version is cached.
2004
- *
2005
- * @returns A promise which resolves to the capabilities of the homeserver
2006
- */
2007
- public fetchCapabilities(): Promise<Capabilities> {
2008
- return this.serverCapabilitiesService.fetchCapabilities();
2009
- }
2010
-
2011
- /**
2012
- * Initialise support for end-to-end encryption in this client, using libolm.
2013
- *
2014
- * You should call this method after creating the matrixclient, but *before*
2015
- * calling `startClient`, if you want to support end-to-end encryption.
2016
- *
2017
- * It will return a Promise which will resolve when the crypto layer has been
2018
- * successfully initialised.
2019
- *
2020
- * @deprecated libolm is deprecated. Prefer {@link initRustCrypto}.
2021
- */
2022
- public async initCrypto(): Promise<void> {
2023
- if (this.cryptoBackend) {
2024
- this.logger.warn("Attempt to re-initialise e2e encryption on MatrixClient");
2025
- return;
2026
- }
2027
-
2028
- if (!this.cryptoStore) {
2029
- // the cryptostore is provided by sdk.createClient, so this shouldn't happen
2030
- throw new Error(`Cannot enable encryption: no cryptoStore provided`);
2031
- }
2032
-
2033
- this.logger.debug("Crypto: Starting up crypto store...");
2034
- await this.cryptoStore.startup();
2035
-
2036
- const userId = this.getUserId();
2037
- if (userId === null) {
2038
- throw new Error(
2039
- `Cannot enable encryption on MatrixClient with unknown userId: ` +
2040
- `ensure userId is passed in createClient().`,
2041
- );
2042
- }
2043
- if (this.deviceId === null) {
2044
- throw new Error(
2045
- `Cannot enable encryption on MatrixClient with unknown deviceId: ` +
2046
- `ensure deviceId is passed in createClient().`,
2047
- );
2048
- }
2049
-
2050
- const crypto = new Crypto(this, userId, this.deviceId, this.store, this.cryptoStore, this.verificationMethods!);
2051
-
2052
- this.reEmitter.reEmit(crypto, [
2053
- LegacyCryptoEvent.KeyBackupFailed,
2054
- LegacyCryptoEvent.KeyBackupSessionsRemaining,
2055
- LegacyCryptoEvent.RoomKeyRequest,
2056
- LegacyCryptoEvent.RoomKeyRequestCancellation,
2057
- LegacyCryptoEvent.Warning,
2058
- LegacyCryptoEvent.DevicesUpdated,
2059
- LegacyCryptoEvent.WillUpdateDevices,
2060
- LegacyCryptoEvent.DeviceVerificationChanged,
2061
- LegacyCryptoEvent.UserTrustStatusChanged,
2062
- LegacyCryptoEvent.KeysChanged,
2063
- ]);
2064
-
2065
- this.logger.debug("Crypto: initialising crypto object...");
2066
- await crypto.init({
2067
- exportedOlmDevice: this.exportedOlmDeviceToImport,
2068
- pickleKey: this.pickleKey,
2069
- });
2070
- delete this.exportedOlmDeviceToImport;
2071
-
2072
- this.olmVersion = Crypto.getOlmVersion();
2073
-
2074
- // if crypto initialisation was successful, tell it to attach its event handlers.
2075
- crypto.registerEventHandlers(this as Parameters<Crypto["registerEventHandlers"]>[0]);
2076
- this.cryptoBackend = this.crypto = crypto;
2077
-
2078
- // upload our keys in the background
2079
- this.crypto.uploadDeviceKeys().catch((e) => {
2080
- // TODO: throwing away this error is a really bad idea.
2081
- this.logger.error("Error uploading device keys", e);
2082
- });
2083
- }
2084
-
2085
- /**
2086
- * Initialise support for end-to-end encryption in this client, using the rust matrix-sdk-crypto.
2087
- *
2088
- * An alternative to {@link initCrypto}.
2089
- *
2090
- * @param args.useIndexedDB - True to use an indexeddb store, false to use an in-memory store. Defaults to 'true'.
2091
- * @param args.storageKey - A key with which to encrypt the indexeddb store. If provided, it must be exactly
2092
- * 32 bytes of data, and must be the same each time the client is initialised for a given device.
2093
- * If both this and `storagePassword` are unspecified, the store will be unencrypted.
2094
- * @param args.storagePassword - An alternative to `storageKey`. A password which will be used to derive a key to
2095
- * encrypt the store with. Deriving a key from a password is (deliberately) a slow operation, so prefer
2096
- * to pass a `storageKey` directly where possible.
2097
- *
2098
- * @returns a Promise which will resolve when the crypto layer has been
2099
- * successfully initialised.
2100
- */
2101
- public async initRustCrypto(
2102
- args: {
2103
- useIndexedDB?: boolean;
2104
- storageKey?: Uint8Array;
2105
- storagePassword?: string;
2106
- } = {},
2107
- ): Promise<void> {
2108
- if (this.cryptoBackend) {
2109
- this.logger.warn("Attempt to re-initialise e2e encryption on MatrixClient");
2110
- return;
2111
- }
2112
-
2113
- const userId = this.getUserId();
2114
- if (userId === null) {
2115
- throw new Error(
2116
- `Cannot enable encryption on MatrixClient with unknown userId: ` +
2117
- `ensure userId is passed in createClient().`,
2118
- );
2119
- }
2120
- const deviceId = this.getDeviceId();
2121
- if (deviceId === null) {
2122
- throw new Error(
2123
- `Cannot enable encryption on MatrixClient with unknown deviceId: ` +
2124
- `ensure deviceId is passed in createClient().`,
2125
- );
2126
- }
2127
-
2128
- // importing rust-crypto will download the webassembly, so we delay it until we know it will be
2129
- // needed.
2130
- this.logger.debug("Downloading Rust crypto library");
2131
- const RustCrypto = await import("./rust-crypto/index.ts");
2132
-
2133
- const rustCrypto = await RustCrypto.initRustCrypto({
2134
- logger: this.logger,
2135
- http: this.http,
2136
- userId: userId,
2137
- deviceId: deviceId,
2138
- secretStorage: this.secretStorage,
2139
- cryptoCallbacks: this.cryptoCallbacks,
2140
- storePrefix: args.useIndexedDB === false ? null : RUST_SDK_STORE_PREFIX,
2141
- storeKey: args.storageKey,
2142
- storePassphrase: args.storagePassword,
2143
-
2144
- legacyCryptoStore: this.cryptoStore,
2145
- legacyPickleKey: this.pickleKey ?? "DEFAULT_KEY",
2146
- legacyMigrationProgressListener: (progress: number, total: number): void => {
2147
- this.emit(CryptoEvent.LegacyCryptoStoreMigrationProgress, progress, total);
2148
- },
2149
- });
2150
-
2151
- rustCrypto.setSupportedVerificationMethods(this.verificationMethods);
2152
-
2153
- this.cryptoBackend = rustCrypto;
2154
-
2155
- // attach the event listeners needed by RustCrypto
2156
- this.on(RoomMemberEvent.Membership, rustCrypto.onRoomMembership.bind(rustCrypto));
2157
- this.on(ClientEvent.Event, (event) => {
2158
- rustCrypto.onLiveEventFromSync(event);
2159
- });
2160
-
2161
- // re-emit the events emitted by the crypto impl
2162
- this.reEmitter.reEmit(rustCrypto, [
2163
- CryptoEvent.VerificationRequestReceived,
2164
- CryptoEvent.UserTrustStatusChanged,
2165
- CryptoEvent.KeyBackupStatus,
2166
- CryptoEvent.KeyBackupSessionsRemaining,
2167
- CryptoEvent.KeyBackupFailed,
2168
- CryptoEvent.KeyBackupDecryptionKeyCached,
2169
- CryptoEvent.KeysChanged,
2170
- CryptoEvent.DevicesUpdated,
2171
- CryptoEvent.WillUpdateDevices,
2172
- ]);
2173
- }
2174
-
2175
- /**
2176
- * Access the server-side secret storage API for this client.
2177
- */
2178
- public get secretStorage(): ServerSideSecretStorage {
2179
- return this._secretStorage;
2180
- }
2181
-
2182
- /**
2183
- * Access the crypto API for this client.
2184
- *
2185
- * If end-to-end encryption has been enabled for this client (via {@link initCrypto} or {@link initRustCrypto}),
2186
- * returns an object giving access to the crypto API. Otherwise, returns `undefined`.
2187
- */
2188
- public getCrypto(): CryptoApi | undefined {
2189
- return this.cryptoBackend;
2190
- }
2191
-
2192
- /**
2193
- * Is end-to-end crypto enabled for this client.
2194
- * @returns True if end-to-end is enabled.
2195
- * @deprecated prefer {@link getCrypto}
2196
- */
2197
- public isCryptoEnabled(): boolean {
2198
- return !!this.cryptoBackend;
2199
- }
2200
-
2201
- /**
2202
- * Get the Ed25519 key for this device
2203
- *
2204
- * @returns base64-encoded ed25519 key. Null if crypto is
2205
- * disabled.
2206
- *
2207
- * @deprecated Not supported for Rust Cryptography.Prefer {@link CryptoApi.getOwnDeviceKeys}
2208
- */
2209
- public getDeviceEd25519Key(): string | null {
2210
- return this.crypto?.getDeviceEd25519Key() ?? null;
2211
- }
2212
-
2213
- /**
2214
- * Get the Curve25519 key for this device
2215
- *
2216
- * @returns base64-encoded curve25519 key. Null if crypto is
2217
- * disabled.
2218
- *
2219
- * @deprecated Not supported for Rust Cryptography. Use {@link CryptoApi.getOwnDeviceKeys}
2220
- */
2221
- public getDeviceCurve25519Key(): string | null {
2222
- return this.crypto?.getDeviceCurve25519Key() ?? null;
2223
- }
2224
-
2225
- /**
2226
- * @deprecated Does nothing.
2227
- */
2228
- public async uploadKeys(): Promise<void> {
2229
- this.logger.warn("MatrixClient.uploadKeys is deprecated");
2230
- }
2231
-
2232
- /**
2233
- * Download the keys for a list of users and stores the keys in the session
2234
- * store.
2235
- * @param userIds - The users to fetch.
2236
- * @param forceDownload - Always download the keys even if cached.
2237
- *
2238
- * @returns A promise which resolves to a map userId-\>deviceId-\>`DeviceInfo`
2239
- *
2240
- * @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi.getUserDeviceInfo}
2241
- */
2242
- public downloadKeys(userIds: string[], forceDownload?: boolean): Promise<DeviceInfoMap> {
2243
- if (!this.crypto) {
2244
- return Promise.reject(new Error("End-to-end encryption disabled"));
2245
- }
2246
- return this.crypto.downloadKeys(userIds, forceDownload);
2247
- }
2248
-
2249
- /**
2250
- * Get the stored device keys for a user id
2251
- *
2252
- * @param userId - the user to list keys for.
2253
- *
2254
- * @returns list of devices
2255
- * @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi.getUserDeviceInfo}
2256
- */
2257
- public getStoredDevicesForUser(userId: string): DeviceInfo[] {
2258
- if (!this.crypto) {
2259
- throw new Error("End-to-end encryption disabled");
2260
- }
2261
- return this.crypto.getStoredDevicesForUser(userId) || [];
2262
- }
2263
-
2264
- /**
2265
- * Get the stored device key for a user id and device id
2266
- *
2267
- * @param userId - the user to list keys for.
2268
- * @param deviceId - unique identifier for the device
2269
- *
2270
- * @returns device or null
2271
- * @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi.getUserDeviceInfo}
2272
- */
2273
- public getStoredDevice(userId: string, deviceId: string): DeviceInfo | null {
2274
- if (!this.crypto) {
2275
- throw new Error("End-to-end encryption disabled");
2276
- }
2277
- return this.crypto.getStoredDevice(userId, deviceId) || null;
2278
- }
2279
-
2280
- /**
2281
- * Mark the given device as verified
2282
- *
2283
- * @param userId - owner of the device
2284
- * @param deviceId - unique identifier for the device or user's
2285
- * cross-signing public key ID.
2286
- *
2287
- * @param verified - whether to mark the device as verified. defaults
2288
- * to 'true'.
2289
- *
2290
- * @returns
2291
- *
2292
- * @remarks
2293
- * Fires {@link CryptoEvent#DeviceVerificationChanged}
2294
- */
2295
- public setDeviceVerified(userId: string, deviceId: string, verified = true): Promise<void> {
2296
- const prom = this.setDeviceVerification(userId, deviceId, verified, null, null);
2297
-
2298
- // if one of the user's own devices is being marked as verified / unverified,
2299
- // check the key backup status, since whether or not we use this depends on
2300
- // whether it has a signature from a verified device
2301
- if (userId == this.credentials.userId) {
2302
- this.checkKeyBackup();
2303
- }
2304
- return prom;
2305
- }
2306
-
2307
- /**
2308
- * Mark the given device as blocked/unblocked
2309
- *
2310
- * @param userId - owner of the device
2311
- * @param deviceId - unique identifier for the device or user's
2312
- * cross-signing public key ID.
2313
- *
2314
- * @param blocked - whether to mark the device as blocked. defaults
2315
- * to 'true'.
2316
- *
2317
- * @returns
2318
- *
2319
- * @remarks
2320
- * Fires {@link LegacyCryptoEvent.DeviceVerificationChanged}
2321
- *
2322
- * @deprecated Not supported for Rust Cryptography.
2323
- */
2324
- public setDeviceBlocked(userId: string, deviceId: string, blocked = true): Promise<void> {
2325
- return this.setDeviceVerification(userId, deviceId, null, blocked, null);
2326
- }
2327
-
2328
- /**
2329
- * Mark the given device as known/unknown
2330
- *
2331
- * @param userId - owner of the device
2332
- * @param deviceId - unique identifier for the device or user's
2333
- * cross-signing public key ID.
2334
- *
2335
- * @param known - whether to mark the device as known. defaults
2336
- * to 'true'.
2337
- *
2338
- * @returns
2339
- *
2340
- * @remarks
2341
- * Fires {@link CryptoEvent#DeviceVerificationChanged}
2342
- *
2343
- * @deprecated Not supported for Rust Cryptography.
2344
- */
2345
- public setDeviceKnown(userId: string, deviceId: string, known = true): Promise<void> {
2346
- return this.setDeviceVerification(userId, deviceId, null, null, known);
2347
- }
2348
-
2349
- private async setDeviceVerification(
2350
- userId: string,
2351
- deviceId: string,
2352
- verified?: boolean | null,
2353
- blocked?: boolean | null,
2354
- known?: boolean | null,
2355
- ): Promise<void> {
2356
- if (!this.crypto) {
2357
- throw new Error("End-to-end encryption disabled");
2358
- }
2359
- await this.crypto.setDeviceVerification(userId, deviceId, verified, blocked, known);
2360
- }
2361
-
2362
- /**
2363
- * Request a key verification from another user, using a DM.
2364
- *
2365
- * @param userId - the user to request verification with
2366
- * @param roomId - the room to use for verification
2367
- *
2368
- * @returns resolves to a VerificationRequest
2369
- * when the request has been sent to the other party.
2370
- *
2371
- * @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi.requestVerificationDM}.
2372
- */
2373
- public requestVerificationDM(userId: string, roomId: string): Promise<VerificationRequest> {
2374
- if (!this.crypto) {
2375
- throw new Error("End-to-end encryption disabled");
2376
- }
2377
- return this.crypto.requestVerificationDM(userId, roomId);
2378
- }
2379
-
2380
- /**
2381
- * Finds a DM verification request that is already in progress for the given room id
2382
- *
2383
- * @param roomId - the room to use for verification
2384
- *
2385
- * @returns the VerificationRequest that is in progress, if any
2386
- * @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi.findVerificationRequestDMInProgress}.
2387
- */
2388
- public findVerificationRequestDMInProgress(roomId: string): VerificationRequest | undefined {
2389
- if (!this.cryptoBackend) {
2390
- throw new Error("End-to-end encryption disabled");
2391
- } else if (!this.crypto) {
2392
- // Hack for element-R to avoid breaking the cypress tests. We can get rid of this once the react-sdk is
2393
- // updated to use CryptoApi.findVerificationRequestDMInProgress.
2394
- return undefined;
2395
- }
2396
- return this.crypto.findVerificationRequestDMInProgress(roomId);
2397
- }
2398
-
2399
- /**
2400
- * Returns all to-device verification requests that are already in progress for the given user id
2401
- *
2402
- * @param userId - the ID of the user to query
2403
- *
2404
- * @returns the VerificationRequests that are in progress
2405
- * @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi.getVerificationRequestsToDeviceInProgress}.
2406
- */
2407
- public getVerificationRequestsToDeviceInProgress(userId: string): VerificationRequest[] {
2408
- if (!this.crypto) {
2409
- throw new Error("End-to-end encryption disabled");
2410
- }
2411
- return this.crypto.getVerificationRequestsToDeviceInProgress(userId);
2412
- }
2413
-
2414
- /**
2415
- * Request a key verification from another user.
2416
- *
2417
- * @param userId - the user to request verification with
2418
- * @param devices - array of device IDs to send requests to. Defaults to
2419
- * all devices owned by the user
2420
- *
2421
- * @returns resolves to a VerificationRequest
2422
- * when the request has been sent to the other party.
2423
- *
2424
- * @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi#requestOwnUserVerification} or {@link CryptoApi#requestDeviceVerification}.
2425
- */
2426
- public requestVerification(userId: string, devices?: string[]): Promise<VerificationRequest> {
2427
- if (!this.crypto) {
2428
- throw new Error("End-to-end encryption disabled");
2429
- }
2430
- return this.crypto.requestVerification(userId, devices);
2431
- }
2432
-
2433
- /**
2434
- * Begin a key verification.
2435
- *
2436
- * @param method - the verification method to use
2437
- * @param userId - the user to verify keys with
2438
- * @param deviceId - the device to verify
2439
- *
2440
- * @returns a verification object
2441
- * @deprecated Prefer {@link CryptoApi#requestOwnUserVerification} or {@link CryptoApi#requestDeviceVerification}.
2442
- */
2443
- public beginKeyVerification(method: string, userId: string, deviceId: string): Verification<any, any> {
2444
- if (!this.crypto) {
2445
- throw new Error("End-to-end encryption disabled");
2446
- }
2447
- return this.crypto.beginKeyVerification(method, userId, deviceId);
2448
- }
2449
-
2450
- /**
2451
- * @deprecated Use {@link MatrixClient#secretStorage} and {@link SecretStorage.ServerSideSecretStorage#checkKey}.
2452
- */
2453
- public checkSecretStorageKey(key: Uint8Array, info: SecretStorageKeyDescription): Promise<boolean> {
2454
- return this.secretStorage.checkKey(key, info);
2455
- }
2456
-
2457
- /**
2458
- * Set the global override for whether the client should ever send encrypted
2459
- * messages to unverified devices. This provides the default for rooms which
2460
- * do not specify a value.
2461
- *
2462
- * @param value - whether to blacklist all unverified devices by default
2463
- *
2464
- * @deprecated Prefer direct access to {@link CryptoApi.globalBlacklistUnverifiedDevices}:
2465
- *
2466
- * ```javascript
2467
- * client.getCrypto().globalBlacklistUnverifiedDevices = value;
2468
- * ```
2469
- */
2470
- public setGlobalBlacklistUnverifiedDevices(value: boolean): boolean {
2471
- if (!this.cryptoBackend) {
2472
- throw new Error("End-to-end encryption disabled");
2473
- }
2474
- this.cryptoBackend.globalBlacklistUnverifiedDevices = value;
2475
- return value;
2476
- }
2477
-
2478
- /**
2479
- * @returns whether to blacklist all unverified devices by default
2480
- *
2481
- * @deprecated Prefer direct access to {@link CryptoApi.globalBlacklistUnverifiedDevices}:
2482
- *
2483
- * ```javascript
2484
- * value = client.getCrypto().globalBlacklistUnverifiedDevices;
2485
- * ```
2486
- */
2487
- public getGlobalBlacklistUnverifiedDevices(): boolean {
2488
- if (!this.cryptoBackend) {
2489
- throw new Error("End-to-end encryption disabled");
2490
- }
2491
- return this.cryptoBackend.globalBlacklistUnverifiedDevices;
2492
- }
2493
-
2494
- /**
2495
- * Set whether sendMessage in a room with unknown and unverified devices
2496
- * should throw an error and not send them message. This has 'Global' for
2497
- * symmetry with setGlobalBlacklistUnverifiedDevices but there is currently
2498
- * no room-level equivalent for this setting.
2499
- *
2500
- * This API is currently UNSTABLE and may change or be removed without notice.
2501
- *
2502
- * It has no effect with the Rust crypto implementation.
2503
- *
2504
- * @param value - whether error on unknown devices
2505
- *
2506
- * ```ts
2507
- * client.getCrypto().globalErrorOnUnknownDevices = value;
2508
- * ```
2509
- */
2510
- public setGlobalErrorOnUnknownDevices(value: boolean): void {
2511
- if (!this.cryptoBackend) {
2512
- throw new Error("End-to-end encryption disabled");
2513
- }
2514
- this.cryptoBackend.globalErrorOnUnknownDevices = value;
2515
- }
2516
-
2517
- /**
2518
- * @returns whether to error on unknown devices
2519
- *
2520
- * This API is currently UNSTABLE and may change or be removed without notice.
2521
- */
2522
- public getGlobalErrorOnUnknownDevices(): boolean {
2523
- if (!this.cryptoBackend) {
2524
- throw new Error("End-to-end encryption disabled");
2525
- }
2526
- return this.cryptoBackend.globalErrorOnUnknownDevices;
2527
- }
2528
-
2529
- /**
2530
- * Get the ID of one of the user's cross-signing keys
2531
- *
2532
- * @param type - The type of key to get the ID of. One of
2533
- * "master", "self_signing", or "user_signing". Defaults to "master".
2534
- *
2535
- * @returns the key ID
2536
- * @deprecated Not supported for Rust Cryptography. prefer {@link Crypto.CryptoApi#getCrossSigningKeyId}
2537
- */
2538
- public getCrossSigningId(type: CrossSigningKey | string = CrossSigningKey.Master): string | null {
2539
- if (!this.crypto) {
2540
- throw new Error("End-to-end encryption disabled");
2541
- }
2542
- return this.crypto.getCrossSigningId(type);
2543
- }
2544
-
2545
- /**
2546
- * Get the cross signing information for a given user.
2547
- *
2548
- * The cross-signing API is currently UNSTABLE and may change without notice.
2549
- *
2550
- * @param userId - the user ID to get the cross-signing info for.
2551
- *
2552
- * @returns the cross signing information for the user.
2553
- * @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi#userHasCrossSigningKeys}
2554
- */
2555
- public getStoredCrossSigningForUser(userId: string): CrossSigningInfo | null {
2556
- if (!this.cryptoBackend) {
2557
- throw new Error("End-to-end encryption disabled");
2558
- }
2559
- return this.cryptoBackend.getStoredCrossSigningForUser(userId);
2560
- }
2561
-
2562
- /**
2563
- * Check whether a given user is trusted.
2564
- *
2565
- * The cross-signing API is currently UNSTABLE and may change without notice.
2566
- *
2567
- * @param userId - The ID of the user to check.
2568
- *
2569
- * @deprecated Use {@link Crypto.CryptoApi.getUserVerificationStatus | `CryptoApi.getUserVerificationStatus`}
2570
- */
2571
- public checkUserTrust(userId: string): UserTrustLevel {
2572
- if (!this.cryptoBackend) {
2573
- throw new Error("End-to-end encryption disabled");
2574
- }
2575
- return this.cryptoBackend.checkUserTrust(userId);
2576
- }
2577
-
2578
- /**
2579
- * Check whether a given device is trusted.
2580
- *
2581
- * The cross-signing API is currently UNSTABLE and may change without notice.
2582
- *
2583
- * @param userId - The ID of the user whose devices is to be checked.
2584
- * @param deviceId - The ID of the device to check
2585
- *
2586
- * @deprecated Use {@link Crypto.CryptoApi.getDeviceVerificationStatus | `CryptoApi.getDeviceVerificationStatus`}
2587
- */
2588
- public checkDeviceTrust(userId: string, deviceId: string): DeviceTrustLevel {
2589
- if (!this.crypto) {
2590
- throw new Error("End-to-end encryption disabled");
2591
- }
2592
- return this.crypto.checkDeviceTrust(userId, deviceId);
2593
- }
2594
-
2595
- /**
2596
- * Check whether one of our own devices is cross-signed by our
2597
- * user's stored keys, regardless of whether we trust those keys yet.
2598
- *
2599
- * @param deviceId - The ID of the device to check
2600
- *
2601
- * @returns true if the device is cross-signed
2602
- *
2603
- * @deprecated Not supported for Rust Cryptography.
2604
- */
2605
- public checkIfOwnDeviceCrossSigned(deviceId: string): boolean {
2606
- if (!this.crypto) {
2607
- throw new Error("End-to-end encryption disabled");
2608
- }
2609
- return this.crypto.checkIfOwnDeviceCrossSigned(deviceId);
2610
- }
2611
-
2612
- /**
2613
- * Check the copy of our cross-signing key that we have in the device list and
2614
- * see if we can get the private key. If so, mark it as trusted.
2615
- * @param opts - ICheckOwnCrossSigningTrustOpts object
2616
- *
2617
- * @deprecated Unneeded for the new crypto
2618
- */
2619
- public checkOwnCrossSigningTrust(opts?: ICheckOwnCrossSigningTrustOpts): Promise<void> {
2620
- if (!this.cryptoBackend) {
2621
- throw new Error("End-to-end encryption disabled");
2622
- }
2623
- return this.cryptoBackend.checkOwnCrossSigningTrust(opts);
2624
- }
2625
-
2626
- /**
2627
- * Checks that a given cross-signing private key matches a given public key.
2628
- * This can be used by the getCrossSigningKey callback to verify that the
2629
- * private key it is about to supply is the one that was requested.
2630
- * @param privateKey - The private key
2631
- * @param expectedPublicKey - The public key
2632
- * @returns true if the key matches, otherwise false
2633
- *
2634
- * @deprecated Not supported for Rust Cryptography.
2635
- */
2636
- public checkCrossSigningPrivateKey(privateKey: Uint8Array, expectedPublicKey: string): boolean {
2637
- if (!this.crypto) {
2638
- throw new Error("End-to-end encryption disabled");
2639
- }
2640
- return this.crypto.checkCrossSigningPrivateKey(privateKey, expectedPublicKey);
2641
- }
2642
-
2643
- /**
2644
- * @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi#requestDeviceVerification}.
2645
- */
2646
- public legacyDeviceVerification(userId: string, deviceId: string, method: string): Promise<VerificationRequest> {
2647
- if (!this.crypto) {
2648
- throw new Error("End-to-end encryption disabled");
2649
- }
2650
- return this.crypto.legacyDeviceVerification(userId, deviceId, method);
2651
- }
2652
-
2653
- /**
2654
- * Perform any background tasks that can be done before a message is ready to
2655
- * send, in order to speed up sending of the message.
2656
- * @param room - the room the event is in
2657
- *
2658
- * @deprecated Prefer {@link CryptoApi.prepareToEncrypt | `CryptoApi.prepareToEncrypt`}:
2659
- *
2660
- * ```javascript
2661
- * client.getCrypto().prepareToEncrypt(room);
2662
- * ```
2663
- */
2664
- public prepareToEncrypt(room: Room): void {
2665
- if (!this.cryptoBackend) {
2666
- throw new Error("End-to-end encryption disabled");
2667
- }
2668
- this.cryptoBackend.prepareToEncrypt(room);
2669
- }
2670
-
2671
- /**
2672
- * Checks if the user has previously published cross-signing keys
2673
- *
2674
- * This means downloading the devicelist for the user and checking if the list includes
2675
- * the cross-signing pseudo-device.
2676
- *
2677
- * @deprecated Prefer {@link CryptoApi.userHasCrossSigningKeys | `CryptoApi.userHasCrossSigningKeys`}:
2678
- *
2679
- * ```javascript
2680
- * result = client.getCrypto().userHasCrossSigningKeys();
2681
- * ```
2682
- */
2683
- public userHasCrossSigningKeys(): Promise<boolean> {
2684
- if (!this.cryptoBackend) {
2685
- throw new Error("End-to-end encryption disabled");
2686
- }
2687
- return this.cryptoBackend.userHasCrossSigningKeys();
2688
- }
2689
-
2690
- /**
2691
- * Checks whether cross signing:
2692
- * - is enabled on this account and trusted by this device
2693
- * - has private keys either cached locally or stored in secret storage
2694
- *
2695
- * If this function returns false, bootstrapCrossSigning() can be used
2696
- * to fix things such that it returns true. That is to say, after
2697
- * bootstrapCrossSigning() completes successfully, this function should
2698
- * return true.
2699
- * @returns True if cross-signing is ready to be used on this device
2700
- * @deprecated Prefer {@link CryptoApi.isCrossSigningReady | `CryptoApi.isCrossSigningReady`}:
2701
- */
2702
- public isCrossSigningReady(): Promise<boolean> {
2703
- if (!this.cryptoBackend) {
2704
- throw new Error("End-to-end encryption disabled");
2705
- }
2706
- return this.cryptoBackend.isCrossSigningReady();
2707
- }
2708
-
2709
- /**
2710
- * Bootstrap cross-signing by creating keys if needed. If everything is already
2711
- * set up, then no changes are made, so this is safe to run to ensure
2712
- * cross-signing is ready for use.
2713
- *
2714
- * This function:
2715
- * - creates new cross-signing keys if they are not found locally cached nor in
2716
- * secret storage (if it has been set up)
2717
- *
2718
- * @deprecated Prefer {@link CryptoApi.bootstrapCrossSigning | `CryptoApi.bootstrapCrossSigning`}.
2719
- */
2720
- public bootstrapCrossSigning(opts: BootstrapCrossSigningOpts): Promise<void> {
2721
- if (!this.cryptoBackend) {
2722
- throw new Error("End-to-end encryption disabled");
2723
- }
2724
- return this.cryptoBackend.bootstrapCrossSigning(opts);
2725
- }
2726
-
2727
- /**
2728
- * Whether to trust a others users signatures of their devices.
2729
- * If false, devices will only be considered 'verified' if we have
2730
- * verified that device individually (effectively disabling cross-signing).
2731
- *
2732
- * Default: true
2733
- *
2734
- * @returns True if trusting cross-signed devices
2735
- *
2736
- * @deprecated Prefer {@link CryptoApi.getTrustCrossSignedDevices | `CryptoApi.getTrustCrossSignedDevices`}.
2737
- */
2738
- public getCryptoTrustCrossSignedDevices(): boolean {
2739
- if (!this.cryptoBackend) {
2740
- throw new Error("End-to-end encryption disabled");
2741
- }
2742
- return this.cryptoBackend.getTrustCrossSignedDevices();
2743
- }
2744
-
2745
- /**
2746
- * See getCryptoTrustCrossSignedDevices
2747
- *
2748
- * @param val - True to trust cross-signed devices
2749
- *
2750
- * @deprecated Prefer {@link CryptoApi.setTrustCrossSignedDevices | `CryptoApi.setTrustCrossSignedDevices`}.
2751
- */
2752
- public setCryptoTrustCrossSignedDevices(val: boolean): void {
2753
- if (!this.cryptoBackend) {
2754
- throw new Error("End-to-end encryption disabled");
2755
- }
2756
- this.cryptoBackend.setTrustCrossSignedDevices(val);
2757
- }
2758
-
2759
- /**
2760
- * Counts the number of end to end session keys that are waiting to be backed up
2761
- * @returns Promise which resolves to the number of sessions requiring backup
2762
- *
2763
- * @deprecated Not supported for Rust Cryptography.
2764
- */
2765
- public countSessionsNeedingBackup(): Promise<number> {
2766
- if (!this.crypto) {
2767
- throw new Error("End-to-end encryption disabled");
2768
- }
2769
- return this.crypto.countSessionsNeedingBackup();
2770
- }
2771
-
2772
- /**
2773
- * Get information about the encryption of an event
2774
- *
2775
- * @param event - event to be checked
2776
- * @returns The event information.
2777
- * @deprecated Prefer {@link Crypto.CryptoApi.getEncryptionInfoForEvent | `CryptoApi.getEncryptionInfoForEvent`}.
2778
- */
2779
- public getEventEncryptionInfo(event: MatrixEvent): IEncryptedEventInfo {
2780
- if (!this.cryptoBackend) {
2781
- throw new Error("End-to-end encryption disabled");
2782
- }
2783
- return this.cryptoBackend.getEventEncryptionInfo(event);
2784
- }
2785
-
2786
- /**
2787
- * Create a recovery key from a user-supplied passphrase.
2788
- *
2789
- * The Secure Secret Storage API is currently UNSTABLE and may change without notice.
2790
- *
2791
- * @param password - Passphrase string that can be entered by the user
2792
- * when restoring the backup as an alternative to entering the recovery key.
2793
- * Optional.
2794
- * @returns Object with public key metadata, encoded private
2795
- * recovery key which should be disposed of after displaying to the user,
2796
- * and raw private key to avoid round tripping if needed.
2797
- *
2798
- * @deprecated Prefer {@link CryptoApi.createRecoveryKeyFromPassphrase | `CryptoApi.createRecoveryKeyFromPassphrase`}.
2799
- */
2800
- public createRecoveryKeyFromPassphrase(password?: string): Promise<IRecoveryKey> {
2801
- if (!this.cryptoBackend) {
2802
- throw new Error("End-to-end encryption disabled");
2803
- }
2804
- return this.cryptoBackend.createRecoveryKeyFromPassphrase(password);
2805
- }
2806
-
2807
- /**
2808
- * Checks whether secret storage:
2809
- * - is enabled on this account
2810
- * - is storing cross-signing private keys
2811
- * - is storing session backup key (if enabled)
2812
- *
2813
- * If this function returns false, bootstrapSecretStorage() can be used
2814
- * to fix things such that it returns true. That is to say, after
2815
- * bootstrapSecretStorage() completes successfully, this function should
2816
- * return true.
2817
- *
2818
- * @returns True if secret storage is ready to be used on this device
2819
- * @deprecated Prefer {@link CryptoApi.isSecretStorageReady | `CryptoApi.isSecretStorageReady`}.
2820
- */
2821
- public isSecretStorageReady(): Promise<boolean> {
2822
- if (!this.cryptoBackend) {
2823
- throw new Error("End-to-end encryption disabled");
2824
- }
2825
- return this.cryptoBackend.isSecretStorageReady();
2826
- }
2827
-
2828
- /**
2829
- * Bootstrap Secure Secret Storage if needed by creating a default key. If everything is
2830
- * already set up, then no changes are made, so this is safe to run to ensure secret
2831
- * storage is ready for use.
2832
- *
2833
- * This function
2834
- * - creates a new Secure Secret Storage key if no default key exists
2835
- * - if a key backup exists, it is migrated to store the key in the Secret
2836
- * Storage
2837
- * - creates a backup if none exists, and one is requested
2838
- * - migrates Secure Secret Storage to use the latest algorithm, if an outdated
2839
- * algorithm is found
2840
- *
2841
- * @deprecated Use {@link CryptoApi.bootstrapSecretStorage | `CryptoApi.bootstrapSecretStorage`}.
2842
- */
2843
- public bootstrapSecretStorage(opts: ICreateSecretStorageOpts): Promise<void> {
2844
- if (!this.cryptoBackend) {
2845
- throw new Error("End-to-end encryption disabled");
2846
- }
2847
- return this.cryptoBackend.bootstrapSecretStorage(opts);
2848
- }
2849
-
2850
- /**
2851
- * Add a key for encrypting secrets.
2852
- *
2853
- * The Secure Secret Storage API is currently UNSTABLE and may change without notice.
2854
- *
2855
- * @param algorithm - the algorithm used by the key
2856
- * @param opts - the options for the algorithm. The properties used
2857
- * depend on the algorithm given.
2858
- * @param keyName - the name of the key. If not given, a random name will be generated.
2859
- *
2860
- * @returns An object with:
2861
- * keyId: the ID of the key
2862
- * keyInfo: details about the key (iv, mac, passphrase)
2863
- *
2864
- * @deprecated Use {@link MatrixClient#secretStorage} and {@link SecretStorage.ServerSideSecretStorage#addKey}.
2865
- */
2866
- public addSecretStorageKey(
2867
- algorithm: string,
2868
- opts: AddSecretStorageKeyOpts,
2869
- keyName?: string,
2870
- ): Promise<{ keyId: string; keyInfo: SecretStorageKeyDescription }> {
2871
- return this.secretStorage.addKey(algorithm, opts, keyName);
2872
- }
2873
-
2874
- /**
2875
- * Check whether we have a key with a given ID.
2876
- *
2877
- * The Secure Secret Storage API is currently UNSTABLE and may change without notice.
2878
- *
2879
- * @param keyId - The ID of the key to check
2880
- * for. Defaults to the default key ID if not provided.
2881
- * @returns Whether we have the key.
2882
- *
2883
- * @deprecated Use {@link MatrixClient#secretStorage} and {@link SecretStorage.ServerSideSecretStorage#hasKey}.
2884
- */
2885
- public hasSecretStorageKey(keyId?: string): Promise<boolean> {
2886
- return this.secretStorage.hasKey(keyId);
2887
- }
2888
-
2889
- /**
2890
- * Store an encrypted secret on the server.
2891
- *
2892
- * The Secure Secret Storage API is currently UNSTABLE and may change without notice.
2893
- *
2894
- * @param name - The name of the secret
2895
- * @param secret - The secret contents.
2896
- * @param keys - The IDs of the keys to use to encrypt the secret or null/undefined
2897
- * to use the default (will throw if no default key is set).
2898
- *
2899
- * @deprecated Use {@link MatrixClient#secretStorage} and {@link SecretStorage.ServerSideSecretStorage#store}.
2900
- */
2901
- public storeSecret(name: string, secret: string, keys?: string[]): Promise<void> {
2902
- return this.secretStorage.store(name, secret, keys);
2903
- }
2904
-
2905
- /**
2906
- * Get a secret from storage.
2907
- *
2908
- * The Secure Secret Storage API is currently UNSTABLE and may change without notice.
2909
- *
2910
- * @param name - the name of the secret
2911
- *
2912
- * @returns the contents of the secret
2913
- *
2914
- * @deprecated Use {@link MatrixClient#secretStorage} and {@link SecretStorage.ServerSideSecretStorage#get}.
2915
- */
2916
- public getSecret(name: string): Promise<string | undefined> {
2917
- return this.secretStorage.get(name);
2918
- }
2919
-
2920
- /**
2921
- * Check if a secret is stored on the server.
2922
- *
2923
- * The Secure Secret Storage API is currently UNSTABLE and may change without notice.
2924
- *
2925
- * @param name - the name of the secret
2926
- * @returns map of key name to key info the secret is encrypted
2927
- * with, or null if it is not present or not encrypted with a trusted
2928
- * key
2929
- *
2930
- * @deprecated Use {@link MatrixClient#secretStorage} and {@link SecretStorage.ServerSideSecretStorage#isStored}.
2931
- */
2932
- public isSecretStored(name: string): Promise<Record<string, SecretStorageKeyDescription> | null> {
2933
- return this.secretStorage.isStored(name);
2934
- }
2935
-
2936
- /**
2937
- * Request a secret from another device.
2938
- *
2939
- * The Secure Secret Storage API is currently UNSTABLE and may change without notice.
2940
- *
2941
- * @param name - the name of the secret to request
2942
- * @param devices - the devices to request the secret from
2943
- *
2944
- * @returns the secret request object
2945
- * @deprecated Not supported for Rust Cryptography.
2946
- */
2947
- public requestSecret(name: string, devices: string[]): ISecretRequest {
2948
- if (!this.crypto) {
2949
- throw new Error("End-to-end encryption disabled");
2950
- }
2951
- return this.crypto.requestSecret(name, devices);
2952
- }
2953
-
2954
- /**
2955
- * Get the current default key ID for encrypting secrets.
2956
- *
2957
- * The Secure Secret Storage API is currently UNSTABLE and may change without notice.
2958
- *
2959
- * @returns The default key ID or null if no default key ID is set
2960
- *
2961
- * @deprecated Use {@link MatrixClient#secretStorage} and {@link SecretStorage.ServerSideSecretStorage#getDefaultKeyId}.
2962
- */
2963
- public getDefaultSecretStorageKeyId(): Promise<string | null> {
2964
- return this.secretStorage.getDefaultKeyId();
2965
- }
2966
-
2967
- /**
2968
- * Set the current default key ID for encrypting secrets.
2969
- *
2970
- * The Secure Secret Storage API is currently UNSTABLE and may change without notice.
2971
- *
2972
- * @param keyId - The new default key ID
2973
- *
2974
- * @deprecated Use {@link MatrixClient#secretStorage} and {@link SecretStorage.ServerSideSecretStorage#setDefaultKeyId}.
2975
- */
2976
- public setDefaultSecretStorageKeyId(keyId: string): Promise<void> {
2977
- return this.secretStorage.setDefaultKeyId(keyId);
2978
- }
2979
-
2980
- /**
2981
- * Checks that a given secret storage private key matches a given public key.
2982
- * This can be used by the getSecretStorageKey callback to verify that the
2983
- * private key it is about to supply is the one that was requested.
2984
- *
2985
- * The Secure Secret Storage API is currently UNSTABLE and may change without notice.
2986
- *
2987
- * @param privateKey - The private key
2988
- * @param expectedPublicKey - The public key
2989
- * @returns true if the key matches, otherwise false
2990
- *
2991
- * @deprecated The use of asymmetric keys for SSSS is deprecated.
2992
- * Use {@link SecretStorage.ServerSideSecretStorage#checkKey} for symmetric keys.
2993
- */
2994
- public checkSecretStoragePrivateKey(privateKey: Uint8Array, expectedPublicKey: string): boolean {
2995
- if (!this.crypto) {
2996
- throw new Error("End-to-end encryption disabled");
2997
- }
2998
- return this.crypto.checkSecretStoragePrivateKey(privateKey, expectedPublicKey);
2999
- }
3000
-
3001
- /**
3002
- * Get e2e information on the device that sent an event
3003
- *
3004
- * @param event - event to be checked
3005
- * @deprecated Not supported for Rust Cryptography.
3006
- */
3007
- public async getEventSenderDeviceInfo(event: MatrixEvent): Promise<DeviceInfo | null> {
3008
- if (!this.crypto) {
3009
- return null;
3010
- }
3011
- return this.crypto.getEventSenderDeviceInfo(event);
3012
- }
3013
-
3014
- /**
3015
- * Check if the sender of an event is verified
3016
- *
3017
- * @param event - event to be checked
3018
- *
3019
- * @returns true if the sender of this event has been verified using
3020
- * {@link MatrixClient#setDeviceVerified}.
3021
- *
3022
- * @deprecated Not supported for Rust Cryptography.
3023
- */
3024
- public async isEventSenderVerified(event: MatrixEvent): Promise<boolean> {
3025
- const device = await this.getEventSenderDeviceInfo(event);
3026
- if (!device) {
3027
- return false;
3028
- }
3029
- return device.isVerified();
3030
- }
3031
-
3032
- /**
3033
- * Get outgoing room key request for this event if there is one.
3034
- * @param event - The event to check for
3035
- *
3036
- * @returns A room key request, or null if there is none
3037
- *
3038
- * @deprecated Not supported for Rust Cryptography.
3039
- */
3040
- public getOutgoingRoomKeyRequest(event: MatrixEvent): Promise<OutgoingRoomKeyRequest | null> {
3041
- if (!this.crypto) {
3042
- throw new Error("End-to-End encryption disabled");
3043
- }
3044
- const wireContent = event.getWireContent();
3045
- const requestBody: IRoomKeyRequestBody = {
3046
- session_id: wireContent.session_id,
3047
- sender_key: wireContent.sender_key,
3048
- algorithm: wireContent.algorithm,
3049
- room_id: event.getRoomId()!,
3050
- };
3051
- if (!requestBody.session_id || !requestBody.sender_key || !requestBody.algorithm || !requestBody.room_id) {
3052
- return Promise.resolve(null);
3053
- }
3054
- return this.crypto.cryptoStore.getOutgoingRoomKeyRequest(requestBody);
3055
- }
3056
-
3057
- /**
3058
- * Cancel a room key request for this event if one is ongoing and resend the
3059
- * request.
3060
- * @param event - event of which to cancel and resend the room
3061
- * key request.
3062
- * @returns A promise that will resolve when the key request is queued
3063
- *
3064
- * @deprecated Not supported for Rust Cryptography.
3065
- */
3066
- public cancelAndResendEventRoomKeyRequest(event: MatrixEvent): Promise<void> {
3067
- if (!this.crypto) {
3068
- throw new Error("End-to-End encryption disabled");
3069
- }
3070
- return event.cancelAndResendKeyRequest(this.crypto, this.getUserId()!);
3071
- }
3072
-
3073
- /**
3074
- * Enable end-to-end encryption for a room. This does not modify room state.
3075
- * Any messages sent before the returned promise resolves will be sent unencrypted.
3076
- * @param roomId - The room ID to enable encryption in.
3077
- * @param config - The encryption config for the room.
3078
- * @returns A promise that will resolve when encryption is set up.
3079
- *
3080
- * @deprecated Not supported for Rust Cryptography. To enable encryption in a room, send an `m.room.encryption`
3081
- * state event.
3082
- */
3083
- public setRoomEncryption(roomId: string, config: IRoomEncryption): Promise<void> {
3084
- if (!this.crypto) {
3085
- throw new Error("End-to-End encryption disabled");
3086
- }
3087
- return this.crypto.setRoomEncryption(roomId, config);
3088
- }
3089
-
3090
- /**
3091
- * Whether encryption is enabled for a room.
3092
- * @param roomId - the room id to query.
3093
- * @returns whether encryption is enabled.
3094
- *
3095
- * @deprecated Not correctly supported for Rust Cryptography. Use {@link CryptoApi.isEncryptionEnabledInRoom} and/or
3096
- * {@link Room.hasEncryptionStateEvent}.
3097
- */
3098
- public isRoomEncrypted(roomId: string): boolean {
3099
- const room = this.getRoom(roomId);
3100
- if (!room) {
3101
- // we don't know about this room, so can't determine if it should be
3102
- // encrypted. Let's assume not.
3103
- return false;
3104
- }
3105
-
3106
- // if there is an 'm.room.encryption' event in this room, it should be
3107
- // encrypted (independently of whether we actually support encryption)
3108
- if (room.hasEncryptionStateEvent()) {
3109
- return true;
3110
- }
3111
-
3112
- // we don't have an m.room.encrypted event, but that might be because
3113
- // the server is hiding it from us. Check the store to see if it was
3114
- // previously encrypted.
3115
- return this.crypto?.isRoomEncrypted(roomId) ?? false;
3116
- }
3117
-
3118
- /**
3119
- * Encrypts and sends a given object via Olm to-device messages to a given
3120
- * set of devices.
3121
- *
3122
- * @param userDeviceInfoArr - list of deviceInfo objects representing the devices to send to
3123
- *
3124
- * @param payload - fields to include in the encrypted payload
3125
- *
3126
- * @returns Promise which
3127
- * resolves once the message has been encrypted and sent to the given
3128
- * userDeviceMap, and returns the `{ contentMap, deviceInfoByDeviceId }`
3129
- * of the successfully sent messages.
3130
- *
3131
- * @deprecated Instead use {@link CryptoApi.encryptToDeviceMessages} followed by {@link queueToDevice}.
3132
- */
3133
- public encryptAndSendToDevices(userDeviceInfoArr: IOlmDevice<DeviceInfo>[], payload: object): Promise<void> {
3134
- if (!this.crypto) {
3135
- throw new Error("End-to-End encryption disabled");
3136
- }
3137
- return this.crypto.encryptAndSendToDevices(userDeviceInfoArr, payload);
3138
- }
3139
-
3140
- /**
3141
- * Forces the current outbound group session to be discarded such
3142
- * that another one will be created next time an event is sent.
3143
- *
3144
- * @param roomId - The ID of the room to discard the session for
3145
- *
3146
- * @deprecated Prefer {@link CryptoApi.forceDiscardSession | `CryptoApi.forceDiscardSession`}:
3147
- */
3148
- public forceDiscardSession(roomId: string): void {
3149
- if (!this.cryptoBackend) {
3150
- throw new Error("End-to-End encryption disabled");
3151
- }
3152
- this.cryptoBackend.forceDiscardSession(roomId);
3153
- }
3154
-
3155
- /**
3156
- * Get a list containing all of the room keys
3157
- *
3158
- * This should be encrypted before returning it to the user.
3159
- *
3160
- * @returns a promise which resolves to a list of session export objects
3161
- *
3162
- * @deprecated Prefer {@link CryptoApi.exportRoomKeys | `CryptoApi.exportRoomKeys`}:
3163
- *
3164
- * ```javascript
3165
- * sessionData = await client.getCrypto().exportRoomKeys();
3166
- * ```
3167
- */
3168
- public exportRoomKeys(): Promise<IMegolmSessionData[]> {
3169
- if (!this.cryptoBackend) {
3170
- return Promise.reject(new Error("End-to-end encryption disabled"));
3171
- }
3172
- return this.cryptoBackend.exportRoomKeys();
3173
- }
3174
-
3175
- /**
3176
- * Import a list of room keys previously exported by exportRoomKeys
3177
- *
3178
- * @param keys - a list of session export objects
3179
- * @param opts - options object
3180
- *
3181
- * @returns a promise which resolves when the keys have been imported
3182
- *
3183
- * @deprecated Prefer {@link CryptoApi.importRoomKeys | `CryptoApi.importRoomKeys`}:
3184
- * ```javascript
3185
- * await client.getCrypto()?.importRoomKeys([..]);
3186
- * ```
3187
- */
3188
- public importRoomKeys(keys: IMegolmSessionData[], opts?: ImportRoomKeysOpts): Promise<void> {
3189
- if (!this.cryptoBackend) {
3190
- throw new Error("End-to-end encryption disabled");
3191
- }
3192
- return this.cryptoBackend.importRoomKeys(keys, opts);
3193
- }
3194
-
3195
- /**
3196
- * Force a re-check of the local key backup status against
3197
- * what's on the server.
3198
- *
3199
- * @returns Object with backup info (as returned by
3200
- * getKeyBackupVersion) in backupInfo and
3201
- * trust information (as returned by isKeyBackupTrusted)
3202
- * in trustInfo.
3203
- *
3204
- * @deprecated Prefer {@link Crypto.CryptoApi.checkKeyBackupAndEnable}.
3205
- */
3206
- public checkKeyBackup(): Promise<IKeyBackupCheck | null> {
3207
- if (!this.crypto) {
3208
- throw new Error("End-to-end encryption disabled");
3209
- }
3210
- return this.crypto.backupManager.checkKeyBackup();
3211
- }
3212
-
3213
- /**
3214
- * Get information about the current key backup from the server.
3215
- *
3216
- * Performs some basic validity checks on the shape of the result, and raises an error if it is not as expected.
3217
- *
3218
- * **Note**: there is no (supported) way to distinguish between "failure to talk to the server" and "another client
3219
- * uploaded a key backup version using an algorithm I don't understand.
3220
- *
3221
- * @returns Information object from API, or null if no backup is present on the server.
3222
- *
3223
- * @deprecated Prefer {@link CryptoApi.getKeyBackupInfo}.
3224
- */
3225
- public async getKeyBackupVersion(): Promise<IKeyBackupInfo | null> {
3226
- let res: IKeyBackupInfo;
3227
- try {
3228
- res = await this.http.authedRequest<IKeyBackupInfo>(
3229
- Method.Get,
3230
- "/room_keys/version",
3231
- undefined,
3232
- undefined,
3233
- { prefix: ClientPrefix.V3 },
3234
- );
3235
- } catch (e) {
3236
- if ((<MatrixError>e).errcode === "M_NOT_FOUND") {
3237
- return null;
3238
- } else {
3239
- throw e;
3240
- }
3241
- }
3242
- BackupManager.checkBackupVersion(res);
3243
- return res;
3244
- }
3245
-
3246
- /**
3247
- * @param info - key backup info dict from getKeyBackupVersion()
3248
- *
3249
- * @deprecated Not supported for Rust Cryptography. Prefer {@link CryptoApi.isKeyBackupTrusted | `CryptoApi.isKeyBackupTrusted`}.
3250
- */
3251
- public isKeyBackupTrusted(info: IKeyBackupInfo): Promise<TrustInfo> {
3252
- if (!this.crypto) {
3253
- throw new Error("End-to-end encryption disabled");
3254
- }
3255
- return this.crypto.backupManager.isKeyBackupTrusted(info);
3256
- }
3257
-
3258
- /**
3259
- * @returns true if the client is configured to back up keys to
3260
- * the server, otherwise false. If we haven't completed a successful check
3261
- * of key backup status yet, returns null.
3262
- *
3263
- * @deprecated Not supported for Rust Cryptography. Prefer direct access to {@link Crypto.CryptoApi.getActiveSessionBackupVersion}:
3264
- *
3265
- * ```javascript
3266
- * let enabled = (await client.getCrypto().getActiveSessionBackupVersion()) !== null;
3267
- * ```
3268
- */
3269
- public getKeyBackupEnabled(): boolean | null {
3270
- if (!this.crypto) {
3271
- throw new Error("End-to-end encryption disabled");
3272
- }
3273
- return this.crypto.backupManager.getKeyBackupEnabled();
3274
- }
3275
-
3276
- /**
3277
- * Enable backing up of keys, using data previously returned from
3278
- * getKeyBackupVersion.
3279
- *
3280
- * @param info - Backup information object as returned by getKeyBackupVersion
3281
- * @returns Promise which resolves when complete.
3282
- *
3283
- * @deprecated Do not call this directly. Instead call {@link Crypto.CryptoApi.checkKeyBackupAndEnable}.
3284
- */
3285
- public enableKeyBackup(info: IKeyBackupInfo): Promise<void> {
3286
- if (!this.crypto) {
3287
- throw new Error("End-to-end encryption disabled");
3288
- }
3289
-
3290
- return this.crypto.backupManager.enableKeyBackup(info);
3291
- }
3292
-
3293
- /**
3294
- * Disable backing up of keys.
3295
- *
3296
- * @deprecated Not supported for Rust Cryptography. It should be unnecessary to disable key backup.
3297
- */
3298
- public disableKeyBackup(): void {
3299
- if (!this.crypto) {
3300
- throw new Error("End-to-end encryption disabled");
3301
- }
3302
-
3303
- this.crypto.backupManager.disableKeyBackup();
3304
- }
3305
-
3306
- /**
3307
- * Set up the data required to create a new backup version. The backup version
3308
- * will not be created and enabled until createKeyBackupVersion is called.
3309
- *
3310
- * @param password - Passphrase string that can be entered by the user
3311
- * when restoring the backup as an alternative to entering the recovery key.
3312
- * Optional.
3313
- *
3314
- * @returns Object that can be passed to createKeyBackupVersion and
3315
- * additionally has a 'recovery_key' member with the user-facing recovery key string.
3316
- *
3317
- * @deprecated Not supported for Rust cryptography. Use {@link Crypto.CryptoApi.resetKeyBackup | `CryptoApi.resetKeyBackup`}.
3318
- */
3319
- public async prepareKeyBackupVersion(
3320
- password?: string | Uint8Array | null,
3321
- opts: IKeyBackupPrepareOpts = { secureSecretStorage: false },
3322
- ): Promise<Pick<IPreparedKeyBackupVersion, "algorithm" | "auth_data" | "recovery_key">> {
3323
- if (!this.crypto) {
3324
- throw new Error("End-to-end encryption disabled");
3325
- }
3326
-
3327
- // eslint-disable-next-line camelcase
3328
- const { algorithm, auth_data, recovery_key, privateKey } =
3329
- await this.crypto.backupManager.prepareKeyBackupVersion(password);
3330
-
3331
- if (opts.secureSecretStorage) {
3332
- await this.secretStorage.store("m.megolm_backup.v1", encodeBase64(privateKey));
3333
- this.logger.info("Key backup private key stored in secret storage");
3334
- }
3335
-
3336
- return {
3337
- algorithm,
3338
- /* eslint-disable camelcase */
3339
- auth_data,
3340
- recovery_key,
3341
- /* eslint-enable camelcase */
3342
- };
3343
- }
3344
-
3345
- /**
3346
- * Check whether the key backup private key is stored in secret storage.
3347
- * @returns map of key name to key info the secret is
3348
- * encrypted with, or null if it is not present or not encrypted with a
3349
- * trusted key
3350
- */
3351
- public isKeyBackupKeyStored(): Promise<Record<string, SecretStorageKeyDescription> | null> {
3352
- return Promise.resolve(this.secretStorage.isStored("m.megolm_backup.v1"));
3353
- }
3354
-
3355
- /**
3356
- * Create a new key backup version and enable it, using the information return
3357
- * from prepareKeyBackupVersion.
3358
- *
3359
- * @param info - Info object from prepareKeyBackupVersion
3360
- * @returns Object with 'version' param indicating the version created
3361
- *
3362
- * @deprecated Use {@link Crypto.CryptoApi.resetKeyBackup | `CryptoApi.resetKeyBackup`}.
3363
- */
3364
- public async createKeyBackupVersion(info: IKeyBackupInfo): Promise<IKeyBackupInfo> {
3365
- if (!this.crypto) {
3366
- throw new Error("End-to-end encryption disabled");
3367
- }
3368
-
3369
- await this.crypto.backupManager.createKeyBackupVersion(info);
3370
-
3371
- const data = {
3372
- algorithm: info.algorithm,
3373
- auth_data: info.auth_data,
3374
- };
3375
-
3376
- // Sign the backup auth data with the device key for backwards compat with
3377
- // older devices with cross-signing. This can probably go away very soon in
3378
- // favour of just signing with the cross-singing master key.
3379
- // XXX: Private member access
3380
- await this.crypto.signObject(data.auth_data);
3381
-
3382
- if (
3383
- this.cryptoCallbacks.getCrossSigningKey &&
3384
- // XXX: Private member access
3385
- this.crypto.crossSigningInfo.getId()
3386
- ) {
3387
- // now also sign the auth data with the cross-signing master key
3388
- // we check for the callback explicitly here because we still want to be able
3389
- // to create an un-cross-signed key backup if there is a cross-signing key but
3390
- // no callback supplied.
3391
- // XXX: Private member access
3392
- await this.crypto.crossSigningInfo.signObject(data.auth_data, "master");
3393
- }
3394
-
3395
- const res = await this.http.authedRequest<IKeyBackupInfo>(Method.Post, "/room_keys/version", undefined, data);
3396
-
3397
- // We could assume everything's okay and enable directly, but this ensures
3398
- // we run the same signature verification that will be used for future
3399
- // sessions.
3400
- await this.checkKeyBackup();
3401
- if (!this.getKeyBackupEnabled()) {
3402
- this.logger.error("Key backup not usable even though we just created it");
3403
- }
3404
-
3405
- return res;
3406
- }
3407
-
3408
- /**
3409
- * @deprecated Use {@link Crypto.CryptoApi.deleteKeyBackupVersion | `CryptoApi.deleteKeyBackupVersion`}.
3410
- */
3411
- public async deleteKeyBackupVersion(version: string): Promise<void> {
3412
- if (!this.cryptoBackend) {
3413
- throw new Error("End-to-end encryption disabled");
3414
- }
3415
-
3416
- await this.cryptoBackend.deleteKeyBackupVersion(version);
3417
- }
3418
-
3419
- private makeKeyBackupPath(roomId?: string, sessionId?: string, version?: string): IKeyBackupPath {
3420
- let path: string;
3421
- if (sessionId !== undefined) {
3422
- path = utils.encodeUri("/room_keys/keys/$roomId/$sessionId", {
3423
- $roomId: roomId!,
3424
- $sessionId: sessionId,
3425
- });
3426
- } else if (roomId !== undefined) {
3427
- path = utils.encodeUri("/room_keys/keys/$roomId", {
3428
- $roomId: roomId,
3429
- });
3430
- } else {
3431
- path = "/room_keys/keys";
3432
- }
3433
- const queryData = version === undefined ? undefined : { version };
3434
- return { path, queryData };
3435
- }
3436
-
3437
- /**
3438
- * Back up session keys to the homeserver.
3439
- * @param roomId - ID of the room that the keys are for Optional.
3440
- * @param sessionId - ID of the session that the keys are for Optional.
3441
- * @param version - backup version Optional.
3442
- * @param data - Object keys to send
3443
- * @returns a promise that will resolve when the keys
3444
- * are uploaded
3445
- *
3446
- * @deprecated Not supported for Rust Cryptography.
1519
+ * Return whether the client is configured for a guest account.
1520
+ * @returns True if this is a guest access_token (or no token is supplied).
3447
1521
  */
3448
- public sendKeyBackup(
3449
- roomId: undefined,
3450
- sessionId: undefined,
3451
- version: string | undefined,
3452
- data: IKeyBackup,
3453
- ): Promise<void>;
3454
- public sendKeyBackup(
3455
- roomId: string,
3456
- sessionId: undefined,
3457
- version: string | undefined,
3458
- data: IKeyBackup,
3459
- ): Promise<void>;
3460
- public sendKeyBackup(
3461
- roomId: string,
3462
- sessionId: string,
3463
- version: string | undefined,
3464
- data: IKeyBackup,
3465
- ): Promise<void>;
3466
- public async sendKeyBackup(
3467
- roomId: string | undefined,
3468
- sessionId: string | undefined,
3469
- version: string | undefined,
3470
- data: IKeyBackup,
3471
- ): Promise<void> {
3472
- if (!this.crypto) {
3473
- throw new Error("End-to-end encryption disabled");
3474
- }
3475
-
3476
- const path = this.makeKeyBackupPath(roomId!, sessionId!, version);
3477
- await this.http.authedRequest(Method.Put, path.path, path.queryData, data, { prefix: ClientPrefix.V3 });
1522
+ public isGuest(): boolean {
1523
+ return this.isGuestAccount;
3478
1524
  }
3479
1525
 
3480
1526
  /**
3481
- * Marks all group sessions as needing to be backed up and schedules them to
3482
- * upload in the background as soon as possible.
3483
- *
3484
- * @deprecated Not supported for Rust Cryptography. This is done automatically as part of
3485
- * {@link CryptoApi.resetKeyBackup}, so there is probably no need to call this manually.
1527
+ * Set whether this client is a guest account. <b>This method is experimental
1528
+ * and may change without warning.</b>
1529
+ * @param guest - True if this is a guest account.
1530
+ * @experimental if the token is a macaroon, it should be encoded in it that it is a 'guest'
1531
+ * access token, which means that the SDK can determine this entirely without
1532
+ * the dev manually flipping this flag.
3486
1533
  */
3487
- public async scheduleAllGroupSessionsForBackup(): Promise<void> {
3488
- if (!this.crypto) {
3489
- throw new Error("End-to-end encryption disabled");
3490
- }
3491
-
3492
- await this.crypto.backupManager.scheduleAllGroupSessionsForBackup();
1534
+ public setGuest(guest: boolean): void {
1535
+ this.isGuestAccount = guest;
3493
1536
  }
3494
1537
 
3495
1538
  /**
3496
- * Marks all group sessions as needing to be backed up without scheduling
3497
- * them to upload in the background.
3498
- *
3499
- * (This is done automatically as part of {@link CryptoApi.resetKeyBackup},
3500
- * so there is probably no need to call this manually.)
3501
- *
3502
- * @returns Promise which resolves to the number of sessions requiring a backup.
3503
- * @deprecated Not supported for Rust Cryptography.
1539
+ * Return the provided scheduler, if any.
1540
+ * @returns The scheduler or undefined
3504
1541
  */
3505
- public flagAllGroupSessionsForBackup(): Promise<number> {
3506
- if (!this.crypto) {
3507
- throw new Error("End-to-end encryption disabled");
3508
- }
3509
-
3510
- return this.crypto.backupManager.flagAllGroupSessionsForBackup();
1542
+ public getScheduler(): MatrixScheduler | undefined {
1543
+ return this.scheduler;
3511
1544
  }
3512
1545
 
3513
1546
  /**
3514
- * Return true if recovery key is valid.
3515
- * Try to decode the recovery key and check if it's successful.
3516
- * @param recoveryKey
3517
- * @deprecated Use {@link decodeRecoveryKey} directly
1547
+ * Retry a backed off syncing request immediately. This should only be used when
1548
+ * the user <b>explicitly</b> attempts to retry their lost connection.
1549
+ * Will also retry any outbound to-device messages currently in the queue to be sent
1550
+ * (retries of regular outgoing events are handled separately, per-event).
1551
+ * @returns True if this resulted in a request being retried.
3518
1552
  */
3519
- public isValidRecoveryKey(recoveryKey: string): boolean {
3520
- try {
3521
- decodeRecoveryKey(recoveryKey);
3522
- return true;
3523
- } catch {
3524
- return false;
3525
- }
1553
+ public retryImmediately(): boolean {
1554
+ // don't await for this promise: we just want to kick it off
1555
+ this.toDeviceMessageQueue.sendQueue();
1556
+ return this.syncApi?.retryImmediately() ?? false;
3526
1557
  }
3527
1558
 
3528
1559
  /**
3529
- * Get the raw key for a key backup from the password
3530
- * Used when migrating key backups into SSSS
3531
- *
3532
- * The cross-signing API is currently UNSTABLE and may change without notice.
1560
+ * Return the global notification EventTimelineSet, if any
3533
1561
  *
3534
- * @param password - Passphrase
3535
- * @param backupInfo - Backup metadata from `checkKeyBackup`
3536
- * @returns key backup key
3537
- * @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.
1562
+ * @returns the globl notification EventTimelineSet
3538
1563
  */
3539
- public keyBackupKeyFromPassword(password: string, backupInfo: IKeyBackupInfo): Promise<Uint8Array> {
3540
- return keyFromAuthData(backupInfo.auth_data, password);
1564
+ public getNotifTimelineSet(): EventTimelineSet | null {
1565
+ return this.notifTimelineSet;
3541
1566
  }
3542
1567
 
3543
1568
  /**
3544
- * Get the raw key for a key backup from the recovery key
3545
- * Used when migrating key backups into SSSS
3546
- *
3547
- * The cross-signing API is currently UNSTABLE and may change without notice.
1569
+ * Set the global notification EventTimelineSet
3548
1570
  *
3549
- * @param recoveryKey - The recovery key
3550
- * @returns key backup key
3551
- * @deprecated Use {@link decodeRecoveryKey} directly
3552
1571
  */
3553
- public keyBackupKeyFromRecoveryKey(recoveryKey: string): Uint8Array {
3554
- return decodeRecoveryKey(recoveryKey);
1572
+ public setNotifTimelineSet(set: EventTimelineSet): void {
1573
+ this.notifTimelineSet = set;
3555
1574
  }
3556
1575
 
3557
1576
  /**
3558
- * Restore from an existing key backup via a passphrase.
3559
- *
3560
- * @param password - Passphrase
3561
- * @param targetRoomId - Room ID to target a specific room.
3562
- * Restores all rooms if omitted.
3563
- * @param targetSessionId - Session ID to target a specific session.
3564
- * Restores all sessions if omitted.
3565
- * @param backupInfo - Backup metadata from `getKeyBackupVersion` or `checkKeyBackup`.`backupInfo`
3566
- * @param opts - Optional params such as callbacks
3567
- * @returns Status of restoration with `total` and `imported`
3568
- * key counts.
1577
+ * Gets the cached capabilities of the homeserver, returning cached ones if available.
1578
+ * If there are no cached capabilities and none can be fetched, throw an exception.
3569
1579
  *
3570
- * @deprecated Prefer {@link CryptoApi.restoreKeyBackupWithPassphrase | `CryptoApi.restoreKeyBackupWithPassphrase`}.
3571
- */
3572
- public async restoreKeyBackupWithPassword(
3573
- password: string,
3574
- targetRoomId: undefined,
3575
- targetSessionId: undefined,
3576
- backupInfo: IKeyBackupInfo,
3577
- opts: IKeyBackupRestoreOpts,
3578
- ): Promise<IKeyBackupRestoreResult>;
3579
- /**
3580
- * @deprecated Prefer {@link CryptoApi.restoreKeyBackupWithPassphrase | `CryptoApi.restoreKeyBackupWithPassphrase`}.
3581
- */
3582
- public async restoreKeyBackupWithPassword(
3583
- password: string,
3584
- targetRoomId: string,
3585
- targetSessionId: undefined,
3586
- backupInfo: IKeyBackupInfo,
3587
- opts: IKeyBackupRestoreOpts,
3588
- ): Promise<IKeyBackupRestoreResult>;
3589
- /**
3590
- * @deprecated Prefer {@link CryptoApi.restoreKeyBackupWithPassphrase | `CryptoApi.restoreKeyBackupWithPassphrase`}.
3591
- */
3592
- public async restoreKeyBackupWithPassword(
3593
- password: string,
3594
- targetRoomId: string,
3595
- targetSessionId: string,
3596
- backupInfo: IKeyBackupInfo,
3597
- opts: IKeyBackupRestoreOpts,
3598
- ): Promise<IKeyBackupRestoreResult>;
3599
- /**
3600
- * @deprecated Prefer {@link CryptoApi.restoreKeyBackupWithPassphrase | `CryptoApi.restoreKeyBackupWithPassphrase`}.
1580
+ * @returns Promise resolving with The capabilities of the homeserver
3601
1581
  */
3602
- public async restoreKeyBackupWithPassword(
3603
- password: string,
3604
- targetRoomId: string | undefined,
3605
- targetSessionId: string | undefined,
3606
- backupInfo: IKeyBackupInfo,
3607
- opts: IKeyBackupRestoreOpts,
3608
- ): Promise<IKeyBackupRestoreResult> {
3609
- const privKey = await keyFromAuthData(backupInfo.auth_data, password);
3610
- return this.restoreKeyBackup(privKey, targetRoomId!, targetSessionId!, backupInfo, opts);
3611
- }
3612
-
3613
- /**
3614
- * Restore from an existing key backup via a private key stored in secret
3615
- * storage.
3616
- *
3617
- * @param backupInfo - Backup metadata from `checkKeyBackup`
3618
- * @param targetRoomId - Room ID to target a specific room.
3619
- * Restores all rooms if omitted.
3620
- * @param targetSessionId - Session ID to target a specific session.
3621
- * Restores all sessions if omitted.
3622
- * @param opts - Optional params such as callbacks
3623
- * @returns Status of restoration with `total` and `imported`
3624
- * key counts.
3625
- *
3626
- * @deprecated Prefer {@link CryptoApi.restoreKeyBackup | `CryptoApi.restoreKeyBackup`}.
3627
- */
3628
- public async restoreKeyBackupWithSecretStorage(
3629
- backupInfo: IKeyBackupInfo,
3630
- targetRoomId?: string,
3631
- targetSessionId?: string,
3632
- opts?: IKeyBackupRestoreOpts,
3633
- ): Promise<IKeyBackupRestoreResult> {
3634
- if (!this.cryptoBackend) {
3635
- throw new Error("End-to-end encryption disabled");
3636
- }
3637
- const storedKey = await this.secretStorage.get("m.megolm_backup.v1");
3638
-
3639
- // ensure that the key is in the right format. If not, fix the key and
3640
- // store the fixed version
3641
- const fixedKey = fixBackupKey(storedKey);
3642
- if (fixedKey) {
3643
- const keys = await this.secretStorage.getKey();
3644
- await this.secretStorage.store("m.megolm_backup.v1", fixedKey, [keys![0]]);
3645
- }
3646
-
3647
- const privKey = decodeBase64(fixedKey || storedKey!);
3648
- return this.restoreKeyBackup(privKey, targetRoomId!, targetSessionId!, backupInfo, opts);
3649
- }
3650
-
3651
- /**
3652
- * Restore from an existing key backup via an encoded recovery key.
3653
- *
3654
- * @param recoveryKey - Encoded recovery key
3655
- * @param targetRoomId - Room ID to target a specific room.
3656
- * Restores all rooms if omitted.
3657
- * @param targetSessionId - Session ID to target a specific session.
3658
- * Restores all sessions if omitted.
3659
- * @param backupInfo - Backup metadata from `checkKeyBackup`
3660
- * @param opts - Optional params such as callbacks
3661
-
3662
- * @returns Status of restoration with `total` and `imported`
3663
- * key counts.
3664
- *
3665
- * @deprecated Prefer {@link CryptoApi.restoreKeyBackup | `CryptoApi.restoreKeyBackup`}.
3666
- */
3667
- public restoreKeyBackupWithRecoveryKey(
3668
- recoveryKey: string,
3669
- targetRoomId: undefined,
3670
- targetSessionId: undefined,
3671
- backupInfo: IKeyBackupInfo,
3672
- opts?: IKeyBackupRestoreOpts,
3673
- ): Promise<IKeyBackupRestoreResult>;
3674
- /**
3675
- * @deprecated Prefer {@link CryptoApi.restoreKeyBackup | `CryptoApi.restoreKeyBackup`}.
3676
- */
3677
- public restoreKeyBackupWithRecoveryKey(
3678
- recoveryKey: string,
3679
- targetRoomId: string,
3680
- targetSessionId: undefined,
3681
- backupInfo: IKeyBackupInfo,
3682
- opts?: IKeyBackupRestoreOpts,
3683
- ): Promise<IKeyBackupRestoreResult>;
3684
- /**
3685
- * @deprecated Prefer {@link CryptoApi.restoreKeyBackup | `CryptoApi.restoreKeyBackup`}.
3686
- */
3687
- public restoreKeyBackupWithRecoveryKey(
3688
- recoveryKey: string,
3689
- targetRoomId: string,
3690
- targetSessionId: string,
3691
- backupInfo: IKeyBackupInfo,
3692
- opts?: IKeyBackupRestoreOpts,
3693
- ): Promise<IKeyBackupRestoreResult>;
3694
- /**
3695
- * @deprecated Prefer {@link CryptoApi.restoreKeyBackup | `CryptoApi.restoreKeyBackup`}.
3696
- */
3697
- public restoreKeyBackupWithRecoveryKey(
3698
- recoveryKey: string,
3699
- targetRoomId: string | undefined,
3700
- targetSessionId: string | undefined,
3701
- backupInfo: IKeyBackupInfo,
3702
- opts?: IKeyBackupRestoreOpts,
3703
- ): Promise<IKeyBackupRestoreResult> {
3704
- const privKey = decodeRecoveryKey(recoveryKey);
3705
- return this.restoreKeyBackup(privKey, targetRoomId!, targetSessionId!, backupInfo, opts);
3706
- }
3707
-
3708
- /**
3709
- * Restore from an existing key backup via a private key stored locally
3710
- * @param targetRoomId
3711
- * @param targetSessionId
3712
- * @param backupInfo
3713
- * @param opts
3714
- *
3715
- * @deprecated Prefer {@link CryptoApi.restoreKeyBackup | `CryptoApi.restoreKeyBackup`}.
3716
- */
3717
- public async restoreKeyBackupWithCache(
3718
- targetRoomId: undefined,
3719
- targetSessionId: undefined,
3720
- backupInfo: IKeyBackupInfo,
3721
- opts?: IKeyBackupRestoreOpts,
3722
- ): Promise<IKeyBackupRestoreResult>;
3723
- /**
3724
- * @deprecated Prefer {@link CryptoApi.restoreKeyBackup | `CryptoApi.restoreKeyBackup`}.
3725
- */
3726
- public async restoreKeyBackupWithCache(
3727
- targetRoomId: string,
3728
- targetSessionId: undefined,
3729
- backupInfo: IKeyBackupInfo,
3730
- opts?: IKeyBackupRestoreOpts,
3731
- ): Promise<IKeyBackupRestoreResult>;
3732
- /**
3733
- * @deprecated Prefer {@link CryptoApi.restoreKeyBackup | `CryptoApi.restoreKeyBackup`}.
3734
- */
3735
- public async restoreKeyBackupWithCache(
3736
- targetRoomId: string,
3737
- targetSessionId: string,
3738
- backupInfo: IKeyBackupInfo,
3739
- opts?: IKeyBackupRestoreOpts,
3740
- ): Promise<IKeyBackupRestoreResult>;
3741
- /**
3742
- * @deprecated Prefer {@link CryptoApi.restoreKeyBackup | `CryptoApi.restoreKeyBackup`}.
3743
- */
3744
- public async restoreKeyBackupWithCache(
3745
- targetRoomId: string | undefined,
3746
- targetSessionId: string | undefined,
3747
- backupInfo: IKeyBackupInfo,
3748
- opts?: IKeyBackupRestoreOpts,
3749
- ): Promise<IKeyBackupRestoreResult> {
3750
- if (!this.cryptoBackend) {
3751
- throw new Error("End-to-end encryption disabled");
3752
- }
3753
- const privKey = await this.cryptoBackend.getSessionBackupPrivateKey();
3754
- if (!privKey) {
3755
- throw new Error("Couldn't get key");
3756
- }
3757
- return this.restoreKeyBackup(privKey, targetRoomId!, targetSessionId!, backupInfo, opts);
3758
- }
3759
-
3760
- private async restoreKeyBackup(
3761
- privKey: ArrayLike<number>,
3762
- targetRoomId: undefined,
3763
- targetSessionId: undefined,
3764
- backupInfo: IKeyBackupInfo,
3765
- opts?: IKeyBackupRestoreOpts,
3766
- ): Promise<IKeyBackupRestoreResult>;
3767
- private async restoreKeyBackup(
3768
- privKey: ArrayLike<number>,
3769
- targetRoomId: string,
3770
- targetSessionId: undefined,
3771
- backupInfo: IKeyBackupInfo,
3772
- opts?: IKeyBackupRestoreOpts,
3773
- ): Promise<IKeyBackupRestoreResult>;
3774
- private async restoreKeyBackup(
3775
- privKey: ArrayLike<number>,
3776
- targetRoomId: string,
3777
- targetSessionId: string,
3778
- backupInfo: IKeyBackupInfo,
3779
- opts?: IKeyBackupRestoreOpts,
3780
- ): Promise<IKeyBackupRestoreResult>;
3781
- private async restoreKeyBackup(
3782
- privKey: ArrayLike<number>,
3783
- targetRoomId: string | undefined,
3784
- targetSessionId: string | undefined,
3785
- backupInfo: IKeyBackupInfo,
3786
- opts?: IKeyBackupRestoreOpts,
3787
- ): Promise<IKeyBackupRestoreResult> {
3788
- const cacheCompleteCallback = opts?.cacheCompleteCallback;
3789
- const progressCallback = opts?.progressCallback;
3790
-
3791
- if (!this.cryptoBackend) {
3792
- throw new Error("End-to-end encryption disabled");
3793
- }
3794
-
3795
- if (!backupInfo.version) {
3796
- throw new Error("Backup version must be defined");
3797
- }
3798
- const backupVersion = backupInfo.version!;
3799
-
3800
- let totalKeyCount = 0;
3801
- let totalFailures = 0;
3802
- let totalImported = 0;
3803
-
3804
- const path = this.makeKeyBackupPath(targetRoomId, targetSessionId, backupVersion);
3805
-
3806
- const backupDecryptor = await this.cryptoBackend.getBackupDecryptor(backupInfo, privKey);
3807
-
3808
- const untrusted = !backupDecryptor.sourceTrusted;
3809
-
3810
- try {
3811
- if (!(privKey instanceof Uint8Array)) {
3812
- // eslint-disable-next-line @typescript-eslint/no-base-to-string
3813
- throw new Error(`restoreKeyBackup expects Uint8Array, got ${privKey}`);
3814
- }
3815
- // Cache the key, if possible.
3816
- // This is async.
3817
- this.cryptoBackend
3818
- .storeSessionBackupPrivateKey(privKey, backupVersion)
3819
- .catch((e) => {
3820
- this.logger.warn("Error caching session backup key:", e);
3821
- })
3822
- .then(cacheCompleteCallback);
3823
-
3824
- if (progressCallback) {
3825
- progressCallback({
3826
- stage: "fetch",
3827
- });
3828
- }
3829
-
3830
- const res = await this.http.authedRequest<IRoomsKeysResponse | IRoomKeysResponse | IKeyBackupSession>(
3831
- Method.Get,
3832
- path.path,
3833
- path.queryData,
3834
- undefined,
3835
- { prefix: ClientPrefix.V3 },
3836
- );
3837
-
3838
- // We have finished fetching the backup, go to next step
3839
- if (progressCallback) {
3840
- progressCallback({
3841
- stage: "load_keys",
3842
- });
3843
- }
3844
-
3845
- if ((res as IRoomsKeysResponse).rooms) {
3846
- // We have a full backup here, it can get quite big, so we need to decrypt and import it in chunks.
3847
-
3848
- // Get the total count as a first pass
3849
- totalKeyCount = this.getTotalKeyCount(res as IRoomsKeysResponse);
3850
- // Now decrypt and import the keys in chunks
3851
- await this.handleDecryptionOfAFullBackup(
3852
- res as IRoomsKeysResponse,
3853
- backupDecryptor,
3854
- 200,
3855
- async (chunk) => {
3856
- // We have a chunk of decrypted keys: import them
3857
- try {
3858
- const backupVersion = backupInfo.version!;
3859
- await this.cryptoBackend!.importBackedUpRoomKeys(chunk, backupVersion, {
3860
- untrusted,
3861
- });
3862
- totalImported += chunk.length;
3863
- } catch (e) {
3864
- totalFailures += chunk.length;
3865
- // We failed to import some keys, but we should still try to import the rest?
3866
- // Log the error and continue
3867
- logger.error("Error importing keys from backup", e);
3868
- }
3869
-
3870
- if (progressCallback) {
3871
- progressCallback({
3872
- total: totalKeyCount,
3873
- successes: totalImported,
3874
- stage: "load_keys",
3875
- failures: totalFailures,
3876
- });
3877
- }
3878
- },
3879
- );
3880
- } else if ((res as IRoomKeysResponse).sessions) {
3881
- // For now we don't chunk for a single room backup, but we could in the future.
3882
- // Currently it is not used by the application.
3883
- const sessions = (res as IRoomKeysResponse).sessions;
3884
- totalKeyCount = Object.keys(sessions).length;
3885
- const keys = await backupDecryptor.decryptSessions(sessions);
3886
- for (const k of keys) {
3887
- k.room_id = targetRoomId!;
3888
- }
3889
- await this.cryptoBackend.importBackedUpRoomKeys(keys, backupVersion, {
3890
- progressCallback,
3891
- untrusted,
3892
- });
3893
- totalImported = keys.length;
3894
- } else {
3895
- totalKeyCount = 1;
3896
- try {
3897
- const [key] = await backupDecryptor.decryptSessions({
3898
- [targetSessionId!]: res as IKeyBackupSession,
3899
- });
3900
- key.room_id = targetRoomId!;
3901
- key.session_id = targetSessionId!;
3902
-
3903
- await this.cryptoBackend.importBackedUpRoomKeys([key], backupVersion, {
3904
- progressCallback,
3905
- untrusted,
3906
- });
3907
- totalImported = 1;
3908
- } catch (e) {
3909
- this.logger.debug("Failed to decrypt megolm session from backup", e);
3910
- }
3911
- }
3912
- } finally {
3913
- backupDecryptor.free();
3914
- }
3915
-
3916
- /// in case entering the passphrase would add a new signature?
3917
- await this.cryptoBackend.checkKeyBackupAndEnable();
3918
-
3919
- return { total: totalKeyCount, imported: totalImported };
1582
+ public async getCapabilities(): Promise<Capabilities> {
1583
+ const caps = this.serverCapabilitiesService.getCachedCapabilities();
1584
+ if (caps) return caps;
1585
+ return this.serverCapabilitiesService.fetchCapabilities();
3920
1586
  }
3921
1587
 
3922
1588
  /**
3923
- * This method calculates the total number of keys present in the response of a `/room_keys/keys` call.
3924
- *
3925
- * @param res - The response from the server containing the keys to be counted.
1589
+ * Gets the cached capabilities of the homeserver. If none have been fetched yet,
1590
+ * return undefined.
3926
1591
  *
3927
- * @returns The total number of keys in the backup.
1592
+ * @returns The capabilities of the homeserver
3928
1593
  */
3929
- private getTotalKeyCount(res: IRoomsKeysResponse): number {
3930
- const rooms = res.rooms;
3931
- let totalKeyCount = 0;
3932
- for (const roomData of Object.values(rooms)) {
3933
- if (!roomData.sessions) continue;
3934
- totalKeyCount += Object.keys(roomData.sessions).length;
3935
- }
3936
- return totalKeyCount;
1594
+ public getCachedCapabilities(): Capabilities | undefined {
1595
+ return this.serverCapabilitiesService.getCachedCapabilities();
3937
1596
  }
3938
1597
 
3939
1598
  /**
3940
- * This method handles the decryption of a full backup, i.e a call to `/room_keys/keys`.
3941
- * It will decrypt the keys in chunks and call the `block` callback for each chunk.
3942
- *
3943
- * @param res - The response from the server containing the keys to be decrypted.
3944
- * @param backupDecryptor - An instance of the BackupDecryptor class used to decrypt the keys.
3945
- * @param chunkSize - The size of the chunks to be processed at a time.
3946
- * @param block - A callback function that is called for each chunk of keys.
1599
+ * Fetches the latest capabilities from the homeserver, ignoring any cached
1600
+ * versions. The newly returned version is cached.
3947
1601
  *
3948
- * @returns A promise that resolves when the decryption is complete.
1602
+ * @returns A promise which resolves to the capabilities of the homeserver
3949
1603
  */
3950
- private async handleDecryptionOfAFullBackup(
3951
- res: IRoomsKeysResponse,
3952
- backupDecryptor: BackupDecryptor,
3953
- chunkSize: number,
3954
- block: (chunk: IMegolmSessionData[]) => Promise<void>,
3955
- ): Promise<void> {
3956
- const rooms = (res as IRoomsKeysResponse).rooms;
3957
-
3958
- let groupChunkCount = 0;
3959
- let chunkGroupByRoom: Map<string, IKeyBackupRoomSessions> = new Map();
3960
-
3961
- const handleChunkCallback = async (roomChunks: Map<string, IKeyBackupRoomSessions>): Promise<void> => {
3962
- const currentChunk: IMegolmSessionData[] = [];
3963
- for (const roomId of roomChunks.keys()) {
3964
- const decryptedSessions = await backupDecryptor.decryptSessions(roomChunks.get(roomId)!);
3965
- for (const sessionId in decryptedSessions) {
3966
- const k = decryptedSessions[sessionId];
3967
- k.room_id = roomId;
3968
- currentChunk.push(k);
3969
- }
3970
- }
3971
- await block(currentChunk);
3972
- };
3973
-
3974
- for (const [roomId, roomData] of Object.entries(rooms)) {
3975
- if (!roomData.sessions) continue;
3976
-
3977
- chunkGroupByRoom.set(roomId, {});
3978
-
3979
- for (const [sessionId, session] of Object.entries(roomData.sessions)) {
3980
- const sessionsForRoom = chunkGroupByRoom.get(roomId)!;
3981
- sessionsForRoom[sessionId] = session;
3982
- groupChunkCount += 1;
3983
- if (groupChunkCount >= chunkSize) {
3984
- // We have enough chunks to decrypt
3985
- await handleChunkCallback(chunkGroupByRoom);
3986
- chunkGroupByRoom = new Map();
3987
- // There might be remaining keys for that room, so add back an entry for the current room.
3988
- chunkGroupByRoom.set(roomId, {});
3989
- groupChunkCount = 0;
3990
- }
3991
- }
3992
- }
3993
-
3994
- // Handle remaining chunk if needed
3995
- if (groupChunkCount > 0) {
3996
- await handleChunkCallback(chunkGroupByRoom);
3997
- }
1604
+ public fetchCapabilities(): Promise<Capabilities> {
1605
+ return this.serverCapabilitiesService.fetchCapabilities();
3998
1606
  }
3999
1607
 
4000
- public deleteKeysFromBackup(roomId: undefined, sessionId: undefined, version?: string): Promise<void>;
4001
- public deleteKeysFromBackup(roomId: string, sessionId: undefined, version?: string): Promise<void>;
4002
- public deleteKeysFromBackup(roomId: string, sessionId: string, version?: string): Promise<void>;
4003
- public async deleteKeysFromBackup(roomId?: string, sessionId?: string, version?: string): Promise<void> {
4004
- const path = this.makeKeyBackupPath(roomId!, sessionId!, version);
4005
- await this.http.authedRequest(Method.Delete, path.path, path.queryData, undefined, { prefix: ClientPrefix.V3 });
1608
+ /**
1609
+ * @deprecated Does nothing.
1610
+ */
1611
+ public async uploadKeys(): Promise<void> {
1612
+ this.logger.warn("MatrixClient.uploadKeys is deprecated");
4006
1613
  }
4007
1614
 
4008
1615
  /**
@@ -4678,18 +2285,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
4678
2285
  }
4679
2286
 
4680
2287
  try {
4681
- let cancelled: boolean;
4682
2288
  this.eventsBeingEncrypted.add(event.getId()!);
4683
- try {
4684
- await this.encryptEventIfNeeded(event, room ?? undefined);
4685
- } finally {
4686
- cancelled = !this.eventsBeingEncrypted.delete(event.getId()!);
4687
- }
4688
-
4689
- if (cancelled) {
4690
- // cancelled via MatrixClient::cancelPendingEvent
4691
- return {} as ISendEventResponse;
4692
- }
4693
2289
 
4694
2290
  // encryptEventIfNeeded may have updated the status from SENDING to ENCRYPTING. If so, we need
4695
2291
  // to put it back.
@@ -4740,70 +2336,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
4740
2336
  }
4741
2337
  }
4742
2338
 
4743
- private async encryptEventIfNeeded(event: MatrixEvent, room?: Room): Promise<void> {
4744
- // If the room is unknown, we cannot encrypt for it
4745
- if (!room) return;
4746
-
4747
- if (!(await this.shouldEncryptEventForRoom(event, room))) return;
4748
-
4749
- if (!this.cryptoBackend && this.usingExternalCrypto) {
4750
- // The client has opted to allow sending messages to encrypted
4751
- // rooms even if the room is encrypted, and we haven't set up
4752
- // crypto. This is useful for users of matrix-org/pantalaimon
4753
- return;
4754
- }
4755
-
4756
- if (!this.cryptoBackend) {
4757
- throw new Error("This room is configured to use encryption, but your client does not support encryption.");
4758
- }
4759
-
4760
- this.updatePendingEventStatus(room, event, EventStatus.ENCRYPTING);
4761
- await this.cryptoBackend.encryptEvent(event, room);
4762
- }
4763
-
4764
- /**
4765
- * Determine whether a given event should be encrypted when we send it to the given room.
4766
- *
4767
- * This takes into account event type and room configuration.
4768
- */
4769
- private async shouldEncryptEventForRoom(event: MatrixEvent, room: Room): Promise<boolean> {
4770
- if (event.isEncrypted()) {
4771
- // this event has already been encrypted; this happens if the
4772
- // encryption step succeeded, but the send step failed on the first
4773
- // attempt.
4774
- return false;
4775
- }
4776
-
4777
- if (event.getType() === EventType.Reaction) {
4778
- // For reactions, there is a very little gained by encrypting the entire
4779
- // event, as relation data is already kept in the clear. Event
4780
- // encryption for a reaction effectively only obscures the event type,
4781
- // but the purpose is still obvious from the relation data, so nothing
4782
- // is really gained. It also causes quite a few problems, such as:
4783
- // * triggers notifications via default push rules
4784
- // * prevents server-side bundling for reactions
4785
- // The reaction key / content / emoji value does warrant encrypting, but
4786
- // this will be handled separately by encrypting just this value.
4787
- // See https://github.com/matrix-org/matrix-doc/pull/1849#pullrequestreview-248763642
4788
- return false;
4789
- }
4790
-
4791
- if (event.isRedaction()) {
4792
- // Redactions do not support encryption in the spec at this time.
4793
- // Whilst it mostly worked in some clients, it wasn't compliant.
4794
- return false;
4795
- }
4796
-
4797
- // If the room has an m.room.encryption event, we should encrypt.
4798
- if (room.hasEncryptionStateEvent()) return true;
4799
-
4800
- // If we have a crypto impl, and *it* thinks we should encrypt, then we should.
4801
- if (await this.cryptoBackend?.isEncryptionEnabledInRoom(room.roomId)) return true;
4802
-
4803
- // Otherwise, no need to encrypt.
4804
- return false;
4805
- }
4806
-
4807
2339
  /**
4808
2340
  * Returns the eventType that should be used taking encryption into account
4809
2341
  * for a given eventType.
@@ -7379,84 +4911,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
7379
4911
  }
7380
4912
  };
7381
4913
 
7382
- /**
7383
- * @returns Promise which resolves: ITurnServerResponse object
7384
- * @returns Rejects: with an error response.
7385
- */
7386
- public turnServer(): Promise<ITurnServerResponse> {
7387
- return this.http.authedRequest(Method.Get, "/voip/turnServer");
7388
- }
7389
-
7390
- /**
7391
- * Get the TURN servers for this homeserver.
7392
- * @returns The servers or an empty list.
7393
- */
7394
- public getTurnServers(): ITurnServer[] {
7395
- return this.turnServers || [];
7396
- }
7397
-
7398
- /**
7399
- * Get the unix timestamp (in milliseconds) at which the current
7400
- * TURN credentials (from getTurnServers) expire
7401
- * @returns The expiry timestamp in milliseconds
7402
- */
7403
- public getTurnServersExpiry(): number {
7404
- return this.turnServersExpiry;
7405
- }
7406
-
7407
- public get pollingTurnServers(): boolean {
7408
- return this.checkTurnServersIntervalID !== undefined;
7409
- }
7410
-
7411
- // XXX: Intended private, used in code.
7412
- public async checkTurnServers(): Promise<boolean | undefined> {
7413
- if (!this.canSupportVoip) {
7414
- return;
7415
- }
7416
-
7417
- let credentialsGood = false;
7418
- const remainingTime = this.turnServersExpiry - Date.now();
7419
- if (remainingTime > TURN_CHECK_INTERVAL) {
7420
- this.logger.debug("TURN creds are valid for another " + remainingTime + " ms: not fetching new ones.");
7421
- credentialsGood = true;
7422
- } else {
7423
- this.logger.debug("Fetching new TURN credentials");
7424
- try {
7425
- const res = await this.turnServer();
7426
- if (res.uris) {
7427
- this.logger.debug("Got TURN URIs: " + res.uris + " refresh in " + res.ttl + " secs");
7428
- // map the response to a format that can be fed to RTCPeerConnection
7429
- const servers: ITurnServer = {
7430
- urls: res.uris,
7431
- username: res.username,
7432
- credential: res.password,
7433
- };
7434
- this.turnServers = [servers];
7435
- // The TTL is in seconds but we work in ms
7436
- this.turnServersExpiry = Date.now() + res.ttl * 1000;
7437
- credentialsGood = true;
7438
- this.emit(ClientEvent.TurnServers, this.turnServers);
7439
- }
7440
- } catch (err) {
7441
- this.logger.error("Failed to get TURN URIs", err);
7442
- if ((<HTTPError>err).httpStatus === 403) {
7443
- // We got a 403, so there's no point in looping forever.
7444
- this.logger.info("TURN access unavailable for this account: stopping credentials checks");
7445
- if (this.checkTurnServersIntervalID !== null) {
7446
- globalThis.clearInterval(this.checkTurnServersIntervalID);
7447
- }
7448
- this.checkTurnServersIntervalID = undefined;
7449
- this.emit(ClientEvent.TurnServersError, <HTTPError>err, true); // fatal
7450
- } else {
7451
- // otherwise, if we failed for whatever reason, try again the next time we're called.
7452
- this.emit(ClientEvent.TurnServersError, <Error>err, false); // non-fatal
7453
- }
7454
- }
7455
- }
7456
-
7457
- return credentialsGood;
7458
- }
7459
-
7460
4914
  /**
7461
4915
  * Set whether to allow a fallback ICE server should be used for negotiating a
7462
4916
  * WebRTC connection if the homeserver doesn't provide any servers. Defaults to
@@ -7798,8 +5252,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
7798
5252
  let events = result.chunk.map(mapper);
7799
5253
 
7800
5254
  if (fetchedEventType === EventType.RoomMessageEncrypted) {
7801
- const allEvents = originalEvent ? events.concat(originalEvent) : events;
7802
- await Promise.all(allEvents.map((e) => this.decryptEventIfNeeded(e)));
7803
5255
  if (eventType !== null) {
7804
5256
  events = events.filter((e) => e.getType() === eventType);
7805
5257
  }
@@ -7816,17 +5268,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
7816
5268
  };
7817
5269
  }
7818
5270
 
7819
- /**
7820
- * The app may wish to see if we have a key cached without
7821
- * triggering a user interaction.
7822
- *
7823
- * @deprecated Not supported for Rust Cryptography.
7824
- */
7825
- public getCrossSigningCacheCallbacks(): ICacheCallbacks | undefined {
7826
- // XXX: Private member access
7827
- return this.crypto?.crossSigningInfo.getCacheCallbacks();
7828
- }
7829
-
7830
5271
  /**
7831
5272
  * Generates a random string suitable for use as a client secret. <strong>This
7832
5273
  * method is experimental and may change.</strong>
@@ -7842,15 +5283,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
7842
5283
  * @returns A decryption promise
7843
5284
  */
7844
5285
  public decryptEventIfNeeded(event: MatrixEvent, options?: IDecryptOptions): Promise<void> {
7845
- if (event.shouldAttemptDecryption() && this.isCryptoEnabled()) {
7846
- event.attemptDecryption(this.cryptoBackend!, options);
7847
- }
7848
-
7849
- if (event.isBeingDecrypted()) {
7850
- return event.getDecryptionPromise()!;
7851
- } else {
7852
- return Promise.resolve();
7853
- }
5286
+ return Promise.resolve();
7854
5287
  }
7855
5288
 
7856
5289
  private termsUrlForService(serviceType: SERVICE_TYPES, baseUrl: string): URL {
@@ -8163,17 +5596,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
8163
5596
  * @returns Promise which resolves: On success, the empty object `{}`
8164
5597
  */
8165
5598
  public async logout(stopClient = false): Promise<{}> {
8166
- if (this.crypto?.backupManager?.getKeyBackupEnabled()) {
8167
- try {
8168
- while ((await this.crypto.backupManager.backupPendingKeys(200)) > 0);
8169
- } catch (err) {
8170
- this.logger.error(
8171
- "Key backup request failed when logging out. Some keys may be missing from backup",
8172
- err,
8173
- );
8174
- }
8175
- }
8176
-
8177
5599
  if (stopClient) {
8178
5600
  this.stopClient();
8179
5601
  this.http.abort();
@@ -9218,87 +6640,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
9218
6640
  return this.http.authedRequest(Method.Post, "/search", queryParams, body, { abortSignal });
9219
6641
  }
9220
6642
 
9221
- /**
9222
- * Upload keys
9223
- *
9224
- * @param content - body of upload request
9225
- *
9226
- * @param opts - this method no longer takes any opts,
9227
- * used to take opts.device_id but this was not removed from the spec as a redundant parameter
9228
- *
9229
- * @returns Promise which resolves: result object. Rejects: with
9230
- * an error response ({@link MatrixError}).
9231
- */
9232
- public uploadKeysRequest(content: IUploadKeysRequest, opts?: void): Promise<IKeysUploadResponse> {
9233
- return this.http.authedRequest(Method.Post, "/keys/upload", undefined, content);
9234
- }
9235
-
9236
- public uploadKeySignatures(content: KeySignatures): Promise<IUploadKeySignaturesResponse> {
9237
- return this.http.authedRequest(Method.Post, "/keys/signatures/upload", undefined, content);
9238
- }
9239
-
9240
- /**
9241
- * Download device keys
9242
- *
9243
- * @param userIds - list of users to get keys for
9244
- *
9245
- * @param token - sync token to pass in the query request, to help
9246
- * the HS give the most recent results
9247
- *
9248
- * @returns Promise which resolves: result object. Rejects: with
9249
- * an error response ({@link MatrixError}).
9250
- */
9251
- public downloadKeysForUsers(userIds: string[], { token }: { token?: string } = {}): Promise<IDownloadKeyResult> {
9252
- const content: IQueryKeysRequest = {
9253
- device_keys: {},
9254
- };
9255
- if (token !== undefined) {
9256
- content.token = token;
9257
- }
9258
- userIds.forEach((u) => {
9259
- content.device_keys[u] = [];
9260
- });
9261
-
9262
- return this.http.authedRequest(Method.Post, "/keys/query", undefined, content);
9263
- }
9264
-
9265
- /**
9266
- * Claim one-time keys
9267
- *
9268
- * @param devices - a list of [userId, deviceId] pairs
9269
- *
9270
- * @param keyAlgorithm - desired key type
9271
- *
9272
- * @param timeout - the time (in milliseconds) to wait for keys from remote
9273
- * servers
9274
- *
9275
- * @returns Promise which resolves: result object. Rejects: with
9276
- * an error response ({@link MatrixError}).
9277
- */
9278
- public claimOneTimeKeys(
9279
- devices: [string, string][],
9280
- keyAlgorithm = "signed_curve25519",
9281
- timeout?: number,
9282
- ): Promise<IClaimOTKsResult> {
9283
- const queries: Record<string, Record<string, string>> = {};
9284
-
9285
- if (keyAlgorithm === undefined) {
9286
- keyAlgorithm = "signed_curve25519";
9287
- }
9288
-
9289
- for (const [userId, deviceId] of devices) {
9290
- const query = queries[userId] || {};
9291
- safeSet(queries, userId, query);
9292
- safeSet(query, deviceId, keyAlgorithm);
9293
- }
9294
- const content: IClaimKeysRequest = { one_time_keys: queries };
9295
- if (timeout) {
9296
- content.timeout = timeout;
9297
- }
9298
- const path = "/keys/claim";
9299
- return this.http.authedRequest(Method.Post, path, undefined, content);
9300
- }
9301
-
9302
6643
  /**
9303
6644
  * Ask the server for a list of users who have changed their device lists
9304
6645
  * between a pair of sync tokens
@@ -9316,15 +6657,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
9316
6657
  return this.http.authedRequest(Method.Get, "/keys/changes", qps);
9317
6658
  }
9318
6659
 
9319
- public uploadDeviceSigningKeys(auth?: AuthDict, keys?: CrossSigningKeys): Promise<{}> {
9320
- // API returns empty object
9321
- const data = Object.assign({}, keys);
9322
- if (auth) Object.assign(data, { auth });
9323
- return this.http.authedRequest(Method.Post, "/keys/device_signing/upload", undefined, data, {
9324
- prefix: ClientPrefix.Unstable,
9325
- });
9326
- }
9327
-
9328
6660
  /**
9329
6661
  * Register with an identity server using the OpenID token from the user's
9330
6662
  * Homeserver, which can be retrieved via
@@ -9953,13 +7285,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
9953
7285
  [UNSTABLE_MSC3088_ENABLED.name]: true,
9954
7286
  },
9955
7287
  },
9956
- {
9957
- type: EventType.RoomEncryption,
9958
- state_key: "",
9959
- content: {
9960
- algorithm: olmlib.MEGOLM_ALGORITHM,
9961
- },
9962
- },
9963
7288
  ],
9964
7289
  });
9965
7290
  return new MSC3089TreeSpace(this, roomId);