@unwanted/matrix-sdk-mini 34.12.0 → 34.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (698) hide show
  1. package/git-revision.txt +1 -1
  2. package/lib/@types/event.d.ts +0 -19
  3. package/lib/@types/event.d.ts.map +1 -1
  4. package/lib/@types/event.js.map +1 -1
  5. package/lib/@types/global.d.js +0 -2
  6. package/lib/@types/global.d.js.map +1 -1
  7. package/lib/autodiscovery.d.ts +1 -1
  8. package/lib/autodiscovery.d.ts.map +1 -1
  9. package/lib/autodiscovery.js.map +1 -1
  10. package/lib/base64.d.ts +3 -6
  11. package/lib/base64.d.ts.map +1 -1
  12. package/lib/base64.js +43 -36
  13. package/lib/base64.js.map +1 -1
  14. package/lib/browser-index.d.ts.map +1 -1
  15. package/lib/browser-index.js +0 -11
  16. package/lib/browser-index.js.map +1 -1
  17. package/lib/client.d.ts +2 -1298
  18. package/lib/client.d.ts.map +1 -1
  19. package/lib/client.js +348 -2967
  20. package/lib/client.js.map +1 -1
  21. package/lib/digest.d.ts +2 -2
  22. package/lib/digest.d.ts.map +1 -1
  23. package/lib/digest.js +2 -2
  24. package/lib/digest.js.map +1 -1
  25. package/lib/embedded.d.ts +0 -22
  26. package/lib/embedded.d.ts.map +1 -1
  27. package/lib/embedded.js +58 -168
  28. package/lib/embedded.js.map +1 -1
  29. package/lib/event-mapper.d.ts.map +1 -1
  30. package/lib/event-mapper.js +0 -4
  31. package/lib/event-mapper.js.map +1 -1
  32. package/lib/matrix.d.ts +0 -25
  33. package/lib/matrix.d.ts.map +1 -1
  34. package/lib/matrix.js +1 -30
  35. package/lib/matrix.js.map +1 -1
  36. package/lib/models/MSC3089Branch.d.ts.map +1 -1
  37. package/lib/models/MSC3089Branch.js +0 -3
  38. package/lib/models/MSC3089Branch.js.map +1 -1
  39. package/lib/models/event-timeline-set.d.ts +6 -10
  40. package/lib/models/event-timeline-set.d.ts.map +1 -1
  41. package/lib/models/event-timeline-set.js +28 -36
  42. package/lib/models/event-timeline-set.js.map +1 -1
  43. package/lib/models/event-timeline.d.ts +7 -2
  44. package/lib/models/event-timeline.d.ts.map +1 -1
  45. package/lib/models/event-timeline.js +8 -9
  46. package/lib/models/event-timeline.js.map +1 -1
  47. package/lib/models/event.d.ts +1 -95
  48. package/lib/models/event.d.ts.map +1 -1
  49. package/lib/models/event.js +11 -281
  50. package/lib/models/event.js.map +1 -1
  51. package/lib/models/poll.d.ts.map +1 -1
  52. package/lib/models/poll.js +1 -5
  53. package/lib/models/poll.js.map +1 -1
  54. package/lib/models/relations-container.d.ts.map +1 -1
  55. package/lib/models/relations-container.js +1 -7
  56. package/lib/models/relations-container.js.map +1 -1
  57. package/lib/models/relations.d.ts +0 -1
  58. package/lib/models/relations.d.ts.map +1 -1
  59. package/lib/models/relations.js +0 -8
  60. package/lib/models/relations.js.map +1 -1
  61. package/lib/models/room-state.d.ts +2 -13
  62. package/lib/models/room-state.d.ts.map +1 -1
  63. package/lib/models/room-state.js +12 -56
  64. package/lib/models/room-state.js.map +1 -1
  65. package/lib/models/room.d.ts +2 -20
  66. package/lib/models/room.d.ts.map +1 -1
  67. package/lib/models/room.js +121 -162
  68. package/lib/models/room.js.map +1 -1
  69. package/lib/models/thread.d.ts.map +1 -1
  70. package/lib/models/thread.js +5 -4
  71. package/lib/models/thread.js.map +1 -1
  72. package/lib/sliding-sync-sdk.d.ts +3 -4
  73. package/lib/sliding-sync-sdk.d.ts.map +1 -1
  74. package/lib/sliding-sync-sdk.js +55 -102
  75. package/lib/sliding-sync-sdk.js.map +1 -1
  76. package/lib/sliding-sync.js +9 -6
  77. package/lib/sliding-sync.js.map +1 -1
  78. package/lib/store/indexeddb.d.ts +1 -1
  79. package/lib/store/indexeddb.d.ts.map +1 -1
  80. package/lib/store/indexeddb.js.map +1 -1
  81. package/lib/sync-accumulator.d.ts +6 -4
  82. package/lib/sync-accumulator.d.ts.map +1 -1
  83. package/lib/sync-accumulator.js +23 -12
  84. package/lib/sync-accumulator.js.map +1 -1
  85. package/lib/sync.d.ts +10 -13
  86. package/lib/sync.d.ts.map +1 -1
  87. package/lib/sync.js +94 -115
  88. package/lib/sync.js.map +1 -1
  89. package/lib/testing.d.ts +0 -48
  90. package/lib/testing.d.ts.map +1 -1
  91. package/lib/testing.js +0 -105
  92. package/lib/testing.js.map +1 -1
  93. package/lib/types.d.ts +0 -1
  94. package/lib/types.d.ts.map +1 -1
  95. package/lib/types.js.map +1 -1
  96. package/package.json +10 -11
  97. package/src/@types/event.ts +2 -36
  98. package/src/@types/global.d.ts +21 -4
  99. package/src/autodiscovery.ts +1 -1
  100. package/src/base64.ts +38 -40
  101. package/src/browser-index.ts +0 -11
  102. package/src/client.ts +68 -3087
  103. package/src/digest.ts +3 -3
  104. package/src/embedded.ts +38 -134
  105. package/src/event-mapper.ts +0 -4
  106. package/src/matrix.ts +0 -41
  107. package/src/models/MSC3089Branch.ts +0 -3
  108. package/src/models/event-timeline-set.ts +17 -38
  109. package/src/models/event-timeline.ts +10 -5
  110. package/src/models/event.ts +8 -295
  111. package/src/models/poll.ts +0 -6
  112. package/src/models/relations-container.ts +1 -8
  113. package/src/models/relations.ts +0 -8
  114. package/src/models/room-state.ts +4 -37
  115. package/src/models/room.ts +18 -68
  116. package/src/models/thread.ts +4 -3
  117. package/src/sliding-sync-sdk.ts +10 -83
  118. package/src/sliding-sync.ts +6 -6
  119. package/src/store/indexeddb.ts +1 -1
  120. package/src/sync-accumulator.ts +33 -16
  121. package/src/sync.ts +112 -143
  122. package/src/testing.ts +0 -108
  123. package/src/types.ts +0 -1
  124. package/CHANGELOG.md +0 -5910
  125. package/lib/@types/AESEncryptedSecretStoragePayload.d.ts +0 -14
  126. package/lib/@types/AESEncryptedSecretStoragePayload.d.ts.map +0 -1
  127. package/lib/@types/AESEncryptedSecretStoragePayload.js +0 -1
  128. package/lib/@types/AESEncryptedSecretStoragePayload.js.map +0 -1
  129. package/lib/@types/crypto.d.ts +0 -47
  130. package/lib/@types/crypto.d.ts.map +0 -1
  131. package/lib/@types/crypto.js +0 -1
  132. package/lib/@types/crypto.js.map +0 -1
  133. package/lib/@types/matrix-sdk-crypto-wasm.d.js +0 -1
  134. package/lib/@types/matrix-sdk-crypto-wasm.d.js.map +0 -1
  135. package/lib/common-crypto/CryptoBackend.d.ts +0 -240
  136. package/lib/common-crypto/CryptoBackend.d.ts.map +0 -1
  137. package/lib/common-crypto/CryptoBackend.js +0 -73
  138. package/lib/common-crypto/CryptoBackend.js.map +0 -1
  139. package/lib/common-crypto/key-passphrase.d.ts +0 -14
  140. package/lib/common-crypto/key-passphrase.d.ts.map +0 -1
  141. package/lib/common-crypto/key-passphrase.js +0 -33
  142. package/lib/common-crypto/key-passphrase.js.map +0 -1
  143. package/lib/crypto/CrossSigning.d.ts +0 -184
  144. package/lib/crypto/CrossSigning.d.ts.map +0 -1
  145. package/lib/crypto/CrossSigning.js +0 -718
  146. package/lib/crypto/CrossSigning.js.map +0 -1
  147. package/lib/crypto/DeviceList.d.ts +0 -216
  148. package/lib/crypto/DeviceList.d.ts.map +0 -1
  149. package/lib/crypto/DeviceList.js +0 -892
  150. package/lib/crypto/DeviceList.js.map +0 -1
  151. package/lib/crypto/EncryptionSetup.d.ts +0 -152
  152. package/lib/crypto/EncryptionSetup.d.ts.map +0 -1
  153. package/lib/crypto/EncryptionSetup.js +0 -356
  154. package/lib/crypto/EncryptionSetup.js.map +0 -1
  155. package/lib/crypto/OlmDevice.d.ts +0 -457
  156. package/lib/crypto/OlmDevice.d.ts.map +0 -1
  157. package/lib/crypto/OlmDevice.js +0 -1241
  158. package/lib/crypto/OlmDevice.js.map +0 -1
  159. package/lib/crypto/OutgoingRoomKeyRequestManager.d.ts +0 -109
  160. package/lib/crypto/OutgoingRoomKeyRequestManager.d.ts.map +0 -1
  161. package/lib/crypto/OutgoingRoomKeyRequestManager.js +0 -415
  162. package/lib/crypto/OutgoingRoomKeyRequestManager.js.map +0 -1
  163. package/lib/crypto/RoomList.d.ts +0 -26
  164. package/lib/crypto/RoomList.d.ts.map +0 -1
  165. package/lib/crypto/RoomList.js +0 -71
  166. package/lib/crypto/RoomList.js.map +0 -1
  167. package/lib/crypto/SecretSharing.d.ts +0 -24
  168. package/lib/crypto/SecretSharing.d.ts.map +0 -1
  169. package/lib/crypto/SecretSharing.js +0 -194
  170. package/lib/crypto/SecretSharing.js.map +0 -1
  171. package/lib/crypto/SecretStorage.d.ts +0 -55
  172. package/lib/crypto/SecretStorage.d.ts.map +0 -1
  173. package/lib/crypto/SecretStorage.js +0 -118
  174. package/lib/crypto/SecretStorage.js.map +0 -1
  175. package/lib/crypto/aes.d.ts +0 -6
  176. package/lib/crypto/aes.d.ts.map +0 -1
  177. package/lib/crypto/aes.js +0 -24
  178. package/lib/crypto/aes.js.map +0 -1
  179. package/lib/crypto/algorithms/base.d.ts +0 -156
  180. package/lib/crypto/algorithms/base.d.ts.map +0 -1
  181. package/lib/crypto/algorithms/base.js +0 -187
  182. package/lib/crypto/algorithms/base.js.map +0 -1
  183. package/lib/crypto/algorithms/index.d.ts +0 -4
  184. package/lib/crypto/algorithms/index.d.ts.map +0 -1
  185. package/lib/crypto/algorithms/index.js +0 -20
  186. package/lib/crypto/algorithms/index.js.map +0 -1
  187. package/lib/crypto/algorithms/megolm.d.ts +0 -385
  188. package/lib/crypto/algorithms/megolm.d.ts.map +0 -1
  189. package/lib/crypto/algorithms/megolm.js +0 -1822
  190. package/lib/crypto/algorithms/megolm.js.map +0 -1
  191. package/lib/crypto/algorithms/olm.d.ts +0 -5
  192. package/lib/crypto/algorithms/olm.d.ts.map +0 -1
  193. package/lib/crypto/algorithms/olm.js +0 -299
  194. package/lib/crypto/algorithms/olm.js.map +0 -1
  195. package/lib/crypto/api.d.ts +0 -32
  196. package/lib/crypto/api.d.ts.map +0 -1
  197. package/lib/crypto/api.js +0 -22
  198. package/lib/crypto/api.js.map +0 -1
  199. package/lib/crypto/backup.d.ts +0 -227
  200. package/lib/crypto/backup.d.ts.map +0 -1
  201. package/lib/crypto/backup.js +0 -824
  202. package/lib/crypto/backup.js.map +0 -1
  203. package/lib/crypto/crypto.d.ts +0 -3
  204. package/lib/crypto/crypto.d.ts.map +0 -1
  205. package/lib/crypto/crypto.js +0 -19
  206. package/lib/crypto/crypto.js.map +0 -1
  207. package/lib/crypto/dehydration.d.ts +0 -34
  208. package/lib/crypto/dehydration.d.ts.map +0 -1
  209. package/lib/crypto/dehydration.js +0 -252
  210. package/lib/crypto/dehydration.js.map +0 -1
  211. package/lib/crypto/device-converter.d.ts +0 -9
  212. package/lib/crypto/device-converter.d.ts.map +0 -1
  213. package/lib/crypto/device-converter.js +0 -42
  214. package/lib/crypto/device-converter.js.map +0 -1
  215. package/lib/crypto/deviceinfo.d.ts +0 -99
  216. package/lib/crypto/deviceinfo.d.ts.map +0 -1
  217. package/lib/crypto/deviceinfo.js +0 -148
  218. package/lib/crypto/deviceinfo.js.map +0 -1
  219. package/lib/crypto/index.d.ts +0 -1210
  220. package/lib/crypto/index.d.ts.map +0 -1
  221. package/lib/crypto/index.js +0 -4101
  222. package/lib/crypto/index.js.map +0 -1
  223. package/lib/crypto/key_passphrase.d.ts +0 -14
  224. package/lib/crypto/key_passphrase.d.ts.map +0 -1
  225. package/lib/crypto/key_passphrase.js +0 -44
  226. package/lib/crypto/key_passphrase.js.map +0 -1
  227. package/lib/crypto/keybackup.d.ts +0 -18
  228. package/lib/crypto/keybackup.d.ts.map +0 -1
  229. package/lib/crypto/keybackup.js +0 -1
  230. package/lib/crypto/keybackup.js.map +0 -1
  231. package/lib/crypto/olmlib.d.ts +0 -129
  232. package/lib/crypto/olmlib.d.ts.map +0 -1
  233. package/lib/crypto/olmlib.js +0 -492
  234. package/lib/crypto/olmlib.js.map +0 -1
  235. package/lib/crypto/recoverykey.d.ts +0 -2
  236. package/lib/crypto/recoverykey.d.ts.map +0 -1
  237. package/lib/crypto/recoverykey.js +0 -19
  238. package/lib/crypto/recoverykey.js.map +0 -1
  239. package/lib/crypto/store/base.d.ts +0 -252
  240. package/lib/crypto/store/base.d.ts.map +0 -1
  241. package/lib/crypto/store/base.js +0 -64
  242. package/lib/crypto/store/base.js.map +0 -1
  243. package/lib/crypto/store/indexeddb-crypto-store-backend.d.ts +0 -187
  244. package/lib/crypto/store/indexeddb-crypto-store-backend.d.ts.map +0 -1
  245. package/lib/crypto/store/indexeddb-crypto-store-backend.js +0 -1145
  246. package/lib/crypto/store/indexeddb-crypto-store-backend.js.map +0 -1
  247. package/lib/crypto/store/indexeddb-crypto-store.d.ts +0 -432
  248. package/lib/crypto/store/indexeddb-crypto-store.d.ts.map +0 -1
  249. package/lib/crypto/store/indexeddb-crypto-store.js +0 -728
  250. package/lib/crypto/store/indexeddb-crypto-store.js.map +0 -1
  251. package/lib/crypto/store/localStorage-crypto-store.d.ts +0 -119
  252. package/lib/crypto/store/localStorage-crypto-store.d.ts.map +0 -1
  253. package/lib/crypto/store/localStorage-crypto-store.js +0 -531
  254. package/lib/crypto/store/localStorage-crypto-store.js.map +0 -1
  255. package/lib/crypto/store/memory-crypto-store.d.ts +0 -215
  256. package/lib/crypto/store/memory-crypto-store.d.ts.map +0 -1
  257. package/lib/crypto/store/memory-crypto-store.js +0 -622
  258. package/lib/crypto/store/memory-crypto-store.js.map +0 -1
  259. package/lib/crypto/verification/Base.d.ts +0 -105
  260. package/lib/crypto/verification/Base.d.ts.map +0 -1
  261. package/lib/crypto/verification/Base.js +0 -372
  262. package/lib/crypto/verification/Base.js.map +0 -1
  263. package/lib/crypto/verification/Error.d.ts +0 -35
  264. package/lib/crypto/verification/Error.d.ts.map +0 -1
  265. package/lib/crypto/verification/Error.js +0 -86
  266. package/lib/crypto/verification/Error.js.map +0 -1
  267. package/lib/crypto/verification/IllegalMethod.d.ts +0 -15
  268. package/lib/crypto/verification/IllegalMethod.d.ts.map +0 -1
  269. package/lib/crypto/verification/IllegalMethod.js +0 -43
  270. package/lib/crypto/verification/IllegalMethod.js.map +0 -1
  271. package/lib/crypto/verification/QRCode.d.ts +0 -51
  272. package/lib/crypto/verification/QRCode.d.ts.map +0 -1
  273. package/lib/crypto/verification/QRCode.js +0 -277
  274. package/lib/crypto/verification/QRCode.js.map +0 -1
  275. package/lib/crypto/verification/SAS.d.ts +0 -27
  276. package/lib/crypto/verification/SAS.d.ts.map +0 -1
  277. package/lib/crypto/verification/SAS.js +0 -485
  278. package/lib/crypto/verification/SAS.js.map +0 -1
  279. package/lib/crypto/verification/SASDecimal.d.ts +0 -8
  280. package/lib/crypto/verification/SASDecimal.d.ts.map +0 -1
  281. package/lib/crypto/verification/SASDecimal.js +0 -34
  282. package/lib/crypto/verification/SASDecimal.js.map +0 -1
  283. package/lib/crypto/verification/request/Channel.d.ts +0 -18
  284. package/lib/crypto/verification/request/Channel.d.ts.map +0 -1
  285. package/lib/crypto/verification/request/Channel.js +0 -1
  286. package/lib/crypto/verification/request/Channel.js.map +0 -1
  287. package/lib/crypto/verification/request/InRoomChannel.d.ts +0 -113
  288. package/lib/crypto/verification/request/InRoomChannel.d.ts.map +0 -1
  289. package/lib/crypto/verification/request/InRoomChannel.js +0 -351
  290. package/lib/crypto/verification/request/InRoomChannel.js.map +0 -1
  291. package/lib/crypto/verification/request/ToDeviceChannel.d.ts +0 -105
  292. package/lib/crypto/verification/request/ToDeviceChannel.d.ts.map +0 -1
  293. package/lib/crypto/verification/request/ToDeviceChannel.js +0 -328
  294. package/lib/crypto/verification/request/ToDeviceChannel.js.map +0 -1
  295. package/lib/crypto/verification/request/VerificationRequest.d.ts +0 -227
  296. package/lib/crypto/verification/request/VerificationRequest.d.ts.map +0 -1
  297. package/lib/crypto/verification/request/VerificationRequest.js +0 -937
  298. package/lib/crypto/verification/request/VerificationRequest.js.map +0 -1
  299. package/lib/crypto-api/CryptoEvent.d.ts +0 -69
  300. package/lib/crypto-api/CryptoEvent.d.ts.map +0 -1
  301. package/lib/crypto-api/CryptoEvent.js +0 -33
  302. package/lib/crypto-api/CryptoEvent.js.map +0 -1
  303. package/lib/crypto-api/CryptoEventHandlerMap.d.ts +0 -16
  304. package/lib/crypto-api/CryptoEventHandlerMap.d.ts.map +0 -1
  305. package/lib/crypto-api/CryptoEventHandlerMap.js +0 -22
  306. package/lib/crypto-api/CryptoEventHandlerMap.js.map +0 -1
  307. package/lib/crypto-api/index.d.ts +0 -978
  308. package/lib/crypto-api/index.d.ts.map +0 -1
  309. package/lib/crypto-api/index.js +0 -304
  310. package/lib/crypto-api/index.js.map +0 -1
  311. package/lib/crypto-api/key-passphrase.d.ts +0 -11
  312. package/lib/crypto-api/key-passphrase.d.ts.map +0 -1
  313. package/lib/crypto-api/key-passphrase.js +0 -51
  314. package/lib/crypto-api/key-passphrase.js.map +0 -1
  315. package/lib/crypto-api/keybackup.d.ts +0 -88
  316. package/lib/crypto-api/keybackup.d.ts.map +0 -1
  317. package/lib/crypto-api/keybackup.js +0 -1
  318. package/lib/crypto-api/keybackup.js.map +0 -1
  319. package/lib/crypto-api/recovery-key.d.ts +0 -11
  320. package/lib/crypto-api/recovery-key.d.ts.map +0 -1
  321. package/lib/crypto-api/recovery-key.js +0 -65
  322. package/lib/crypto-api/recovery-key.js.map +0 -1
  323. package/lib/crypto-api/verification.d.ts +0 -344
  324. package/lib/crypto-api/verification.d.ts.map +0 -1
  325. package/lib/crypto-api/verification.js +0 -91
  326. package/lib/crypto-api/verification.js.map +0 -1
  327. package/lib/matrixrtc/CallMembership.d.ts +0 -66
  328. package/lib/matrixrtc/CallMembership.d.ts.map +0 -1
  329. package/lib/matrixrtc/CallMembership.js +0 -197
  330. package/lib/matrixrtc/CallMembership.js.map +0 -1
  331. package/lib/matrixrtc/LivekitFocus.d.ts +0 -16
  332. package/lib/matrixrtc/LivekitFocus.d.ts.map +0 -1
  333. package/lib/matrixrtc/LivekitFocus.js +0 -20
  334. package/lib/matrixrtc/LivekitFocus.js.map +0 -1
  335. package/lib/matrixrtc/MatrixRTCSession.d.ts +0 -295
  336. package/lib/matrixrtc/MatrixRTCSession.d.ts.map +0 -1
  337. package/lib/matrixrtc/MatrixRTCSession.js +0 -1043
  338. package/lib/matrixrtc/MatrixRTCSession.js.map +0 -1
  339. package/lib/matrixrtc/MatrixRTCSessionManager.d.ts +0 -40
  340. package/lib/matrixrtc/MatrixRTCSessionManager.d.ts.map +0 -1
  341. package/lib/matrixrtc/MatrixRTCSessionManager.js +0 -146
  342. package/lib/matrixrtc/MatrixRTCSessionManager.js.map +0 -1
  343. package/lib/matrixrtc/focus.d.ts +0 -10
  344. package/lib/matrixrtc/focus.d.ts.map +0 -1
  345. package/lib/matrixrtc/focus.js +0 -1
  346. package/lib/matrixrtc/focus.js.map +0 -1
  347. package/lib/matrixrtc/index.d.ts +0 -7
  348. package/lib/matrixrtc/index.d.ts.map +0 -1
  349. package/lib/matrixrtc/index.js +0 -21
  350. package/lib/matrixrtc/index.js.map +0 -1
  351. package/lib/matrixrtc/types.d.ts +0 -19
  352. package/lib/matrixrtc/types.d.ts.map +0 -1
  353. package/lib/matrixrtc/types.js +0 -1
  354. package/lib/matrixrtc/types.js.map +0 -1
  355. package/lib/rendezvous/MSC4108SignInWithQR.d.ts +0 -112
  356. package/lib/rendezvous/MSC4108SignInWithQR.d.ts.map +0 -1
  357. package/lib/rendezvous/MSC4108SignInWithQR.js +0 -392
  358. package/lib/rendezvous/MSC4108SignInWithQR.js.map +0 -1
  359. package/lib/rendezvous/RendezvousChannel.d.ts +0 -27
  360. package/lib/rendezvous/RendezvousChannel.d.ts.map +0 -1
  361. package/lib/rendezvous/RendezvousChannel.js +0 -1
  362. package/lib/rendezvous/RendezvousChannel.js.map +0 -1
  363. package/lib/rendezvous/RendezvousCode.d.ts +0 -9
  364. package/lib/rendezvous/RendezvousCode.d.ts.map +0 -1
  365. package/lib/rendezvous/RendezvousCode.js +0 -1
  366. package/lib/rendezvous/RendezvousCode.js.map +0 -1
  367. package/lib/rendezvous/RendezvousError.d.ts +0 -6
  368. package/lib/rendezvous/RendezvousError.d.ts.map +0 -1
  369. package/lib/rendezvous/RendezvousError.js +0 -23
  370. package/lib/rendezvous/RendezvousError.js.map +0 -1
  371. package/lib/rendezvous/RendezvousFailureReason.d.ts +0 -31
  372. package/lib/rendezvous/RendezvousFailureReason.d.ts.map +0 -1
  373. package/lib/rendezvous/RendezvousFailureReason.js +0 -38
  374. package/lib/rendezvous/RendezvousFailureReason.js.map +0 -1
  375. package/lib/rendezvous/RendezvousIntent.d.ts +0 -5
  376. package/lib/rendezvous/RendezvousIntent.d.ts.map +0 -1
  377. package/lib/rendezvous/RendezvousIntent.js +0 -22
  378. package/lib/rendezvous/RendezvousIntent.js.map +0 -1
  379. package/lib/rendezvous/RendezvousTransport.d.ts +0 -36
  380. package/lib/rendezvous/RendezvousTransport.d.ts.map +0 -1
  381. package/lib/rendezvous/RendezvousTransport.js +0 -1
  382. package/lib/rendezvous/RendezvousTransport.js.map +0 -1
  383. package/lib/rendezvous/channels/MSC4108SecureChannel.d.ts +0 -58
  384. package/lib/rendezvous/channels/MSC4108SecureChannel.d.ts.map +0 -1
  385. package/lib/rendezvous/channels/MSC4108SecureChannel.js +0 -246
  386. package/lib/rendezvous/channels/MSC4108SecureChannel.js.map +0 -1
  387. package/lib/rendezvous/channels/index.d.ts +0 -2
  388. package/lib/rendezvous/channels/index.d.ts.map +0 -1
  389. package/lib/rendezvous/channels/index.js +0 -18
  390. package/lib/rendezvous/channels/index.js.map +0 -1
  391. package/lib/rendezvous/index.d.ts +0 -10
  392. package/lib/rendezvous/index.d.ts.map +0 -1
  393. package/lib/rendezvous/index.js +0 -23
  394. package/lib/rendezvous/index.js.map +0 -1
  395. package/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts +0 -61
  396. package/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts.map +0 -1
  397. package/lib/rendezvous/transports/MSC4108RendezvousSession.js +0 -253
  398. package/lib/rendezvous/transports/MSC4108RendezvousSession.js.map +0 -1
  399. package/lib/rendezvous/transports/index.d.ts +0 -2
  400. package/lib/rendezvous/transports/index.d.ts.map +0 -1
  401. package/lib/rendezvous/transports/index.js +0 -18
  402. package/lib/rendezvous/transports/index.js.map +0 -1
  403. package/lib/rust-crypto/CrossSigningIdentity.d.ts +0 -33
  404. package/lib/rust-crypto/CrossSigningIdentity.d.ts.map +0 -1
  405. package/lib/rust-crypto/CrossSigningIdentity.js +0 -157
  406. package/lib/rust-crypto/CrossSigningIdentity.js.map +0 -1
  407. package/lib/rust-crypto/DehydratedDeviceManager.d.ts +0 -98
  408. package/lib/rust-crypto/DehydratedDeviceManager.d.ts.map +0 -1
  409. package/lib/rust-crypto/DehydratedDeviceManager.js +0 -285
  410. package/lib/rust-crypto/DehydratedDeviceManager.js.map +0 -1
  411. package/lib/rust-crypto/KeyClaimManager.d.ts +0 -33
  412. package/lib/rust-crypto/KeyClaimManager.d.ts.map +0 -1
  413. package/lib/rust-crypto/KeyClaimManager.js +0 -82
  414. package/lib/rust-crypto/KeyClaimManager.js.map +0 -1
  415. package/lib/rust-crypto/OutgoingRequestProcessor.d.ts +0 -43
  416. package/lib/rust-crypto/OutgoingRequestProcessor.d.ts.map +0 -1
  417. package/lib/rust-crypto/OutgoingRequestProcessor.js +0 -195
  418. package/lib/rust-crypto/OutgoingRequestProcessor.js.map +0 -1
  419. package/lib/rust-crypto/OutgoingRequestsManager.d.ts +0 -47
  420. package/lib/rust-crypto/OutgoingRequestsManager.d.ts.map +0 -1
  421. package/lib/rust-crypto/OutgoingRequestsManager.js +0 -148
  422. package/lib/rust-crypto/OutgoingRequestsManager.js.map +0 -1
  423. package/lib/rust-crypto/PerSessionKeyBackupDownloader.d.ts +0 -120
  424. package/lib/rust-crypto/PerSessionKeyBackupDownloader.d.ts.map +0 -1
  425. package/lib/rust-crypto/PerSessionKeyBackupDownloader.js +0 -467
  426. package/lib/rust-crypto/PerSessionKeyBackupDownloader.js.map +0 -1
  427. package/lib/rust-crypto/RoomEncryptor.d.ts +0 -98
  428. package/lib/rust-crypto/RoomEncryptor.d.ts.map +0 -1
  429. package/lib/rust-crypto/RoomEncryptor.js +0 -299
  430. package/lib/rust-crypto/RoomEncryptor.js.map +0 -1
  431. package/lib/rust-crypto/backup.d.ts +0 -254
  432. package/lib/rust-crypto/backup.d.ts.map +0 -1
  433. package/lib/rust-crypto/backup.js +0 -837
  434. package/lib/rust-crypto/backup.js.map +0 -1
  435. package/lib/rust-crypto/constants.d.ts +0 -3
  436. package/lib/rust-crypto/constants.d.ts.map +0 -1
  437. package/lib/rust-crypto/constants.js +0 -19
  438. package/lib/rust-crypto/constants.js.map +0 -1
  439. package/lib/rust-crypto/device-converter.d.ts +0 -28
  440. package/lib/rust-crypto/device-converter.d.ts.map +0 -1
  441. package/lib/rust-crypto/device-converter.js +0 -123
  442. package/lib/rust-crypto/device-converter.js.map +0 -1
  443. package/lib/rust-crypto/index.d.ts +0 -61
  444. package/lib/rust-crypto/index.d.ts.map +0 -1
  445. package/lib/rust-crypto/index.js +0 -152
  446. package/lib/rust-crypto/index.js.map +0 -1
  447. package/lib/rust-crypto/libolm_migration.d.ts +0 -81
  448. package/lib/rust-crypto/libolm_migration.d.ts.map +0 -1
  449. package/lib/rust-crypto/libolm_migration.js +0 -459
  450. package/lib/rust-crypto/libolm_migration.js.map +0 -1
  451. package/lib/rust-crypto/rust-crypto.d.ts +0 -556
  452. package/lib/rust-crypto/rust-crypto.d.ts.map +0 -1
  453. package/lib/rust-crypto/rust-crypto.js +0 -2016
  454. package/lib/rust-crypto/rust-crypto.js.map +0 -1
  455. package/lib/rust-crypto/secret-storage.d.ts +0 -22
  456. package/lib/rust-crypto/secret-storage.d.ts.map +0 -1
  457. package/lib/rust-crypto/secret-storage.js +0 -63
  458. package/lib/rust-crypto/secret-storage.js.map +0 -1
  459. package/lib/rust-crypto/verification.d.ts +0 -319
  460. package/lib/rust-crypto/verification.d.ts.map +0 -1
  461. package/lib/rust-crypto/verification.js +0 -816
  462. package/lib/rust-crypto/verification.js.map +0 -1
  463. package/lib/secret-storage.d.ts +0 -370
  464. package/lib/secret-storage.d.ts.map +0 -1
  465. package/lib/secret-storage.js +0 -466
  466. package/lib/secret-storage.js.map +0 -1
  467. package/lib/utils/decryptAESSecretStorageItem.d.ts +0 -12
  468. package/lib/utils/decryptAESSecretStorageItem.d.ts.map +0 -1
  469. package/lib/utils/decryptAESSecretStorageItem.js +0 -50
  470. package/lib/utils/decryptAESSecretStorageItem.js.map +0 -1
  471. package/lib/utils/encryptAESSecretStorageItem.d.ts +0 -16
  472. package/lib/utils/encryptAESSecretStorageItem.d.ts.map +0 -1
  473. package/lib/utils/encryptAESSecretStorageItem.js +0 -68
  474. package/lib/utils/encryptAESSecretStorageItem.js.map +0 -1
  475. package/lib/utils/internal/deriveKeys.d.ts +0 -10
  476. package/lib/utils/internal/deriveKeys.d.ts.map +0 -1
  477. package/lib/utils/internal/deriveKeys.js +0 -60
  478. package/lib/utils/internal/deriveKeys.js.map +0 -1
  479. package/lib/webrtc/audioContext.d.ts +0 -15
  480. package/lib/webrtc/audioContext.d.ts.map +0 -1
  481. package/lib/webrtc/audioContext.js +0 -46
  482. package/lib/webrtc/audioContext.js.map +0 -1
  483. package/lib/webrtc/call.d.ts +0 -560
  484. package/lib/webrtc/call.d.ts.map +0 -1
  485. package/lib/webrtc/call.js +0 -2541
  486. package/lib/webrtc/call.js.map +0 -1
  487. package/lib/webrtc/callEventHandler.d.ts +0 -37
  488. package/lib/webrtc/callEventHandler.d.ts.map +0 -1
  489. package/lib/webrtc/callEventHandler.js +0 -344
  490. package/lib/webrtc/callEventHandler.js.map +0 -1
  491. package/lib/webrtc/callEventTypes.d.ts +0 -73
  492. package/lib/webrtc/callEventTypes.d.ts.map +0 -1
  493. package/lib/webrtc/callEventTypes.js +0 -13
  494. package/lib/webrtc/callEventTypes.js.map +0 -1
  495. package/lib/webrtc/callFeed.d.ts +0 -128
  496. package/lib/webrtc/callFeed.d.ts.map +0 -1
  497. package/lib/webrtc/callFeed.js +0 -289
  498. package/lib/webrtc/callFeed.js.map +0 -1
  499. package/lib/webrtc/groupCall.d.ts +0 -323
  500. package/lib/webrtc/groupCall.d.ts.map +0 -1
  501. package/lib/webrtc/groupCall.js +0 -1337
  502. package/lib/webrtc/groupCall.js.map +0 -1
  503. package/lib/webrtc/groupCallEventHandler.d.ts +0 -31
  504. package/lib/webrtc/groupCallEventHandler.d.ts.map +0 -1
  505. package/lib/webrtc/groupCallEventHandler.js +0 -178
  506. package/lib/webrtc/groupCallEventHandler.js.map +0 -1
  507. package/lib/webrtc/mediaHandler.d.ts +0 -89
  508. package/lib/webrtc/mediaHandler.d.ts.map +0 -1
  509. package/lib/webrtc/mediaHandler.js +0 -437
  510. package/lib/webrtc/mediaHandler.js.map +0 -1
  511. package/lib/webrtc/stats/callFeedStatsReporter.d.ts +0 -8
  512. package/lib/webrtc/stats/callFeedStatsReporter.d.ts.map +0 -1
  513. package/lib/webrtc/stats/callFeedStatsReporter.js +0 -82
  514. package/lib/webrtc/stats/callFeedStatsReporter.js.map +0 -1
  515. package/lib/webrtc/stats/callStatsReportGatherer.d.ts +0 -25
  516. package/lib/webrtc/stats/callStatsReportGatherer.d.ts.map +0 -1
  517. package/lib/webrtc/stats/callStatsReportGatherer.js +0 -199
  518. package/lib/webrtc/stats/callStatsReportGatherer.js.map +0 -1
  519. package/lib/webrtc/stats/callStatsReportSummary.d.ts +0 -17
  520. package/lib/webrtc/stats/callStatsReportSummary.d.ts.map +0 -1
  521. package/lib/webrtc/stats/callStatsReportSummary.js +0 -1
  522. package/lib/webrtc/stats/callStatsReportSummary.js.map +0 -1
  523. package/lib/webrtc/stats/connectionStats.d.ts +0 -28
  524. package/lib/webrtc/stats/connectionStats.d.ts.map +0 -1
  525. package/lib/webrtc/stats/connectionStats.js +0 -26
  526. package/lib/webrtc/stats/connectionStats.js.map +0 -1
  527. package/lib/webrtc/stats/connectionStatsBuilder.d.ts +0 -5
  528. package/lib/webrtc/stats/connectionStatsBuilder.d.ts.map +0 -1
  529. package/lib/webrtc/stats/connectionStatsBuilder.js +0 -27
  530. package/lib/webrtc/stats/connectionStatsBuilder.js.map +0 -1
  531. package/lib/webrtc/stats/connectionStatsReportBuilder.d.ts +0 -7
  532. package/lib/webrtc/stats/connectionStatsReportBuilder.d.ts.map +0 -1
  533. package/lib/webrtc/stats/connectionStatsReportBuilder.js +0 -121
  534. package/lib/webrtc/stats/connectionStatsReportBuilder.js.map +0 -1
  535. package/lib/webrtc/stats/groupCallStats.d.ts +0 -22
  536. package/lib/webrtc/stats/groupCallStats.d.ts.map +0 -1
  537. package/lib/webrtc/stats/groupCallStats.js +0 -78
  538. package/lib/webrtc/stats/groupCallStats.js.map +0 -1
  539. package/lib/webrtc/stats/media/mediaSsrcHandler.d.ts +0 -10
  540. package/lib/webrtc/stats/media/mediaSsrcHandler.d.ts.map +0 -1
  541. package/lib/webrtc/stats/media/mediaSsrcHandler.js +0 -57
  542. package/lib/webrtc/stats/media/mediaSsrcHandler.js.map +0 -1
  543. package/lib/webrtc/stats/media/mediaTrackHandler.d.ts +0 -12
  544. package/lib/webrtc/stats/media/mediaTrackHandler.d.ts.map +0 -1
  545. package/lib/webrtc/stats/media/mediaTrackHandler.js +0 -62
  546. package/lib/webrtc/stats/media/mediaTrackHandler.js.map +0 -1
  547. package/lib/webrtc/stats/media/mediaTrackStats.d.ts +0 -86
  548. package/lib/webrtc/stats/media/mediaTrackStats.d.ts.map +0 -1
  549. package/lib/webrtc/stats/media/mediaTrackStats.js +0 -142
  550. package/lib/webrtc/stats/media/mediaTrackStats.js.map +0 -1
  551. package/lib/webrtc/stats/media/mediaTrackStatsHandler.d.ts +0 -22
  552. package/lib/webrtc/stats/media/mediaTrackStatsHandler.d.ts.map +0 -1
  553. package/lib/webrtc/stats/media/mediaTrackStatsHandler.js +0 -76
  554. package/lib/webrtc/stats/media/mediaTrackStatsHandler.js.map +0 -1
  555. package/lib/webrtc/stats/statsReport.d.ts +0 -99
  556. package/lib/webrtc/stats/statsReport.d.ts.map +0 -1
  557. package/lib/webrtc/stats/statsReport.js +0 -32
  558. package/lib/webrtc/stats/statsReport.js.map +0 -1
  559. package/lib/webrtc/stats/statsReportEmitter.d.ts +0 -15
  560. package/lib/webrtc/stats/statsReportEmitter.d.ts.map +0 -1
  561. package/lib/webrtc/stats/statsReportEmitter.js +0 -33
  562. package/lib/webrtc/stats/statsReportEmitter.js.map +0 -1
  563. package/lib/webrtc/stats/summaryStatsReportGatherer.d.ts +0 -16
  564. package/lib/webrtc/stats/summaryStatsReportGatherer.d.ts.map +0 -1
  565. package/lib/webrtc/stats/summaryStatsReportGatherer.js +0 -116
  566. package/lib/webrtc/stats/summaryStatsReportGatherer.js.map +0 -1
  567. package/lib/webrtc/stats/trackStatsBuilder.d.ts +0 -19
  568. package/lib/webrtc/stats/trackStatsBuilder.d.ts.map +0 -1
  569. package/lib/webrtc/stats/trackStatsBuilder.js +0 -168
  570. package/lib/webrtc/stats/trackStatsBuilder.js.map +0 -1
  571. package/lib/webrtc/stats/transportStats.d.ts +0 -11
  572. package/lib/webrtc/stats/transportStats.d.ts.map +0 -1
  573. package/lib/webrtc/stats/transportStats.js +0 -1
  574. package/lib/webrtc/stats/transportStats.js.map +0 -1
  575. package/lib/webrtc/stats/transportStatsBuilder.d.ts +0 -5
  576. package/lib/webrtc/stats/transportStatsBuilder.d.ts.map +0 -1
  577. package/lib/webrtc/stats/transportStatsBuilder.js +0 -34
  578. package/lib/webrtc/stats/transportStatsBuilder.js.map +0 -1
  579. package/lib/webrtc/stats/valueFormatter.d.ts +0 -4
  580. package/lib/webrtc/stats/valueFormatter.d.ts.map +0 -1
  581. package/lib/webrtc/stats/valueFormatter.js +0 -25
  582. package/lib/webrtc/stats/valueFormatter.js.map +0 -1
  583. package/src/@types/AESEncryptedSecretStoragePayload.ts +0 -29
  584. package/src/@types/crypto.ts +0 -73
  585. package/src/@types/matrix-sdk-crypto-wasm.d.ts +0 -44
  586. package/src/common-crypto/CryptoBackend.ts +0 -302
  587. package/src/common-crypto/README.md +0 -4
  588. package/src/common-crypto/key-passphrase.ts +0 -43
  589. package/src/crypto/CrossSigning.ts +0 -773
  590. package/src/crypto/DeviceList.ts +0 -989
  591. package/src/crypto/EncryptionSetup.ts +0 -351
  592. package/src/crypto/OlmDevice.ts +0 -1500
  593. package/src/crypto/OutgoingRoomKeyRequestManager.ts +0 -485
  594. package/src/crypto/RoomList.ts +0 -70
  595. package/src/crypto/SecretSharing.ts +0 -240
  596. package/src/crypto/SecretStorage.ts +0 -136
  597. package/src/crypto/aes.ts +0 -23
  598. package/src/crypto/algorithms/base.ts +0 -236
  599. package/src/crypto/algorithms/index.ts +0 -20
  600. package/src/crypto/algorithms/megolm.ts +0 -2216
  601. package/src/crypto/algorithms/olm.ts +0 -381
  602. package/src/crypto/api.ts +0 -70
  603. package/src/crypto/backup.ts +0 -922
  604. package/src/crypto/crypto.ts +0 -18
  605. package/src/crypto/dehydration.ts +0 -272
  606. package/src/crypto/device-converter.ts +0 -45
  607. package/src/crypto/deviceinfo.ts +0 -158
  608. package/src/crypto/index.ts +0 -4418
  609. package/src/crypto/key_passphrase.ts +0 -42
  610. package/src/crypto/keybackup.ts +0 -47
  611. package/src/crypto/olmlib.ts +0 -539
  612. package/src/crypto/recoverykey.ts +0 -18
  613. package/src/crypto/store/base.ts +0 -348
  614. package/src/crypto/store/indexeddb-crypto-store-backend.ts +0 -1250
  615. package/src/crypto/store/indexeddb-crypto-store.ts +0 -845
  616. package/src/crypto/store/localStorage-crypto-store.ts +0 -579
  617. package/src/crypto/store/memory-crypto-store.ts +0 -680
  618. package/src/crypto/verification/Base.ts +0 -409
  619. package/src/crypto/verification/Error.ts +0 -76
  620. package/src/crypto/verification/IllegalMethod.ts +0 -50
  621. package/src/crypto/verification/QRCode.ts +0 -310
  622. package/src/crypto/verification/SAS.ts +0 -494
  623. package/src/crypto/verification/SASDecimal.ts +0 -37
  624. package/src/crypto/verification/request/Channel.ts +0 -34
  625. package/src/crypto/verification/request/InRoomChannel.ts +0 -371
  626. package/src/crypto/verification/request/ToDeviceChannel.ts +0 -354
  627. package/src/crypto/verification/request/VerificationRequest.ts +0 -976
  628. package/src/crypto-api/CryptoEvent.ts +0 -93
  629. package/src/crypto-api/CryptoEventHandlerMap.ts +0 -32
  630. package/src/crypto-api/index.ts +0 -1175
  631. package/src/crypto-api/key-passphrase.ts +0 -58
  632. package/src/crypto-api/keybackup.ts +0 -115
  633. package/src/crypto-api/recovery-key.ts +0 -69
  634. package/src/crypto-api/verification.ts +0 -408
  635. package/src/matrixrtc/CallMembership.ts +0 -247
  636. package/src/matrixrtc/LivekitFocus.ts +0 -39
  637. package/src/matrixrtc/MatrixRTCSession.ts +0 -1319
  638. package/src/matrixrtc/MatrixRTCSessionManager.ts +0 -166
  639. package/src/matrixrtc/focus.ts +0 -25
  640. package/src/matrixrtc/index.ts +0 -22
  641. package/src/matrixrtc/types.ts +0 -36
  642. package/src/rendezvous/MSC4108SignInWithQR.ts +0 -444
  643. package/src/rendezvous/RendezvousChannel.ts +0 -48
  644. package/src/rendezvous/RendezvousCode.ts +0 -25
  645. package/src/rendezvous/RendezvousError.ts +0 -26
  646. package/src/rendezvous/RendezvousFailureReason.ts +0 -49
  647. package/src/rendezvous/RendezvousIntent.ts +0 -20
  648. package/src/rendezvous/RendezvousTransport.ts +0 -58
  649. package/src/rendezvous/channels/MSC4108SecureChannel.ts +0 -270
  650. package/src/rendezvous/channels/index.ts +0 -17
  651. package/src/rendezvous/index.ts +0 -25
  652. package/src/rendezvous/transports/MSC4108RendezvousSession.ts +0 -270
  653. package/src/rendezvous/transports/index.ts +0 -17
  654. package/src/rust-crypto/CrossSigningIdentity.ts +0 -183
  655. package/src/rust-crypto/DehydratedDeviceManager.ts +0 -306
  656. package/src/rust-crypto/KeyClaimManager.ts +0 -86
  657. package/src/rust-crypto/OutgoingRequestProcessor.ts +0 -236
  658. package/src/rust-crypto/OutgoingRequestsManager.ts +0 -143
  659. package/src/rust-crypto/PerSessionKeyBackupDownloader.ts +0 -501
  660. package/src/rust-crypto/RoomEncryptor.ts +0 -352
  661. package/src/rust-crypto/backup.ts +0 -881
  662. package/src/rust-crypto/constants.ts +0 -18
  663. package/src/rust-crypto/device-converter.ts +0 -128
  664. package/src/rust-crypto/index.ts +0 -237
  665. package/src/rust-crypto/libolm_migration.ts +0 -530
  666. package/src/rust-crypto/rust-crypto.ts +0 -2205
  667. package/src/rust-crypto/secret-storage.ts +0 -60
  668. package/src/rust-crypto/verification.ts +0 -830
  669. package/src/secret-storage.ts +0 -693
  670. package/src/utils/decryptAESSecretStorageItem.ts +0 -54
  671. package/src/utils/encryptAESSecretStorageItem.ts +0 -73
  672. package/src/utils/internal/deriveKeys.ts +0 -63
  673. package/src/webrtc/audioContext.ts +0 -44
  674. package/src/webrtc/call.ts +0 -3074
  675. package/src/webrtc/callEventHandler.ts +0 -425
  676. package/src/webrtc/callEventTypes.ts +0 -93
  677. package/src/webrtc/callFeed.ts +0 -364
  678. package/src/webrtc/groupCall.ts +0 -1735
  679. package/src/webrtc/groupCallEventHandler.ts +0 -234
  680. package/src/webrtc/mediaHandler.ts +0 -484
  681. package/src/webrtc/stats/callFeedStatsReporter.ts +0 -94
  682. package/src/webrtc/stats/callStatsReportGatherer.ts +0 -219
  683. package/src/webrtc/stats/callStatsReportSummary.ts +0 -30
  684. package/src/webrtc/stats/connectionStats.ts +0 -47
  685. package/src/webrtc/stats/connectionStatsBuilder.ts +0 -28
  686. package/src/webrtc/stats/connectionStatsReportBuilder.ts +0 -140
  687. package/src/webrtc/stats/groupCallStats.ts +0 -93
  688. package/src/webrtc/stats/media/mediaSsrcHandler.ts +0 -57
  689. package/src/webrtc/stats/media/mediaTrackHandler.ts +0 -76
  690. package/src/webrtc/stats/media/mediaTrackStats.ts +0 -176
  691. package/src/webrtc/stats/media/mediaTrackStatsHandler.ts +0 -90
  692. package/src/webrtc/stats/statsReport.ts +0 -133
  693. package/src/webrtc/stats/statsReportEmitter.ts +0 -49
  694. package/src/webrtc/stats/summaryStatsReportGatherer.ts +0 -148
  695. package/src/webrtc/stats/trackStatsBuilder.ts +0 -207
  696. package/src/webrtc/stats/transportStats.ts +0 -26
  697. package/src/webrtc/stats/transportStatsBuilder.ts +0 -48
  698. package/src/webrtc/stats/valueFormatter.ts +0 -27
@@ -1 +0,0 @@
1
- {"version":3,"file":"backup.js","names":["MatrixClient","logger","MEGOLM_ALGORITHM","verifySignature","keyFromPassphrase","encodeUri","safeSet","sleep","IndexedDBCryptoStore","UnstableValue","CryptoEvent","ClientPrefix","MatrixError","Method","encodeRecoveryKey","decryptAESSecretStorageItem","encryptAESSecretStorageItem","calculateKeyCheck","KEY_BACKUP_KEYS_PER_REQUEST","KEY_BACKUP_CHECK_RATE_LIMIT","BackupManager","constructor","baseApis","getKey","_defineProperty","checkedForBackup","sendingBackups","stop","clientRunning","version","backupInfo","checkBackupVersion","info","Algorithm","algorithmsByName","algorithm","Error","auth_data","makeAlgorithm","init","enableKeyBackup","_this","_asyncToGenerator","free","emit","KeyBackupStatus","scheduleKeyBackupSend","disableKeyBackup","undefined","getKeyBackupEnabled","Boolean","prepareKeyBackupVersion","key","DefaultAlgorithm","privateKey","authData","prepare","recoveryKey","algorithmName","recovery_key","createKeyBackupVersion","_this2","deleteAllKeyBackupVersions","_this3","_yield$_this3$baseApi","_yield$_this3$baseApi2","current","getKeyBackupVersion","_yield$_this3$baseApi3","_yield$_this3$baseApi4","deleteKeyBackupVersion","_this4","path","$version","http","authedRequest","Delete","prefix","V3","checkAndStart","_this5","log","isGuest","_yield$_this5$baseApi","e","httpStatus","trustInfo","isKeyBackupTrusted","usable","concat","scheduleAllGroupSessionsForBackup","checkKeyBackup","_this6","queryKeyBackupRateLimited","targetRoomId","targetSessionId","_this7","now","Date","getTime","sessionLastCheckAttemptedTime","restoreKeyBackupWithCache","_this8","ret","trusted_locally","sigs","signatures","JSON","stringify","userId","getUserId","privKey","crypto","getSessionBackupPrivateKey","keyMatches","_unused","_algorithm","mySigs","keyId","Object","keys","keyIdParts","split","sigInfo","deviceId","crossSigningId","crossSigningInfo","getId","olmDevice","valid","warn","push","device","deviceList","getStoredDevice","deviceTrust","checkDeviceTrust","getFingerprint","some","s","_s$deviceTrust","isVerified","_arguments","arguments","_this9","maxDelay","length","debug","delay","Math","random","numFailures","numBackedUp","backupPendingKeys","err","errCode","data","errcode","KeyBackupFailed","pow","min","limit","_this10","sessions","cryptoStore","getSessionsNeedingBackup","remaining","countSessionsNeedingBackup","KeyBackupSessionsRemaining","rooms","session","_deviceList$getDevice","roomId","sessionData","room_id","exportInboundGroupSession","senderKey","sessionId","forwardedCount","forwarding_curve25519_key_chain","getUserByIdentityKey","getDeviceByIdentityKey","verified","checkDeviceInfoTrust","first_message_index","first_known_index","forwarded_count","is_verified","session_data","encryptSession","sendKeyBackup","unmarkSessionsNeedingBackup","backupGroupSession","_this11","markSessionsNeedingBackup","_this12","flagAllGroupSessionsForBackup","_this13","doTxn","STORE_INBOUND_GROUP_SESSIONS","STORE_BACKUP","txn","getAllEndToEndInboundGroupSessions","Curve25519","publicKey","globalThis","Olm","PkEncryption","set_recipient_key","public_key","decryption","PkDecryption","generate_key","Uint8Array","init_with_private_key","derivation","private_key_salt","salt","private_key_iterations","iterations","get_private_key","untrusted","_this14","plainText","assign","session_id","encrypt","decryptSessions","_this15","backupPubKey","RESTORE_BACKUP_ERROR_BAD_KEY","entries","decrypted","parse","decrypt","ephemeral","mac","ciphertext","_this16","pubKey","randomBytes","size","buf","getRandomValues","UNSTABLE_MSC3270_NAME","Aes256","iv","replace","outKey","_this17","_this18","fill","name","backupTrustInfoFromLegacyTrustInfo","_trustInfo$trusted_lo","trusted","matchesDecryptionKey","LibOlmBackupDecryptor","sourceTrusted","_this19"],"sources":["../../src/crypto/backup.ts"],"sourcesContent":["/*\nCopyright 2021 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\n/**\n * Classes for dealing with key backup.\n */\n\nimport type { IMegolmSessionData } from \"../@types/crypto.ts\";\nimport { MatrixClient } from \"../client.ts\";\nimport { logger } from \"../logger.ts\";\nimport { MEGOLM_ALGORITHM, verifySignature } from \"./olmlib.ts\";\nimport { DeviceInfo } from \"./deviceinfo.ts\";\nimport { DeviceTrustLevel } from \"./CrossSigning.ts\";\nimport { keyFromPassphrase } from \"./key_passphrase.ts\";\nimport { encodeUri, safeSet, sleep } from \"../utils.ts\";\nimport { IndexedDBCryptoStore } from \"./store/indexeddb-crypto-store.ts\";\nimport {\n Curve25519SessionData,\n IAes256AuthData,\n ICurve25519AuthData,\n IKeyBackupInfo,\n IKeyBackupSession,\n} from \"./keybackup.ts\";\nimport { UnstableValue } from \"../NamespacedValue.ts\";\nimport { CryptoEvent } from \"./index.ts\";\nimport { ClientPrefix, HTTPError, MatrixError, Method } from \"../http-api/index.ts\";\nimport { BackupTrustInfo } from \"../crypto-api/keybackup.ts\";\nimport { BackupDecryptor } from \"../common-crypto/CryptoBackend.ts\";\nimport { encodeRecoveryKey } from \"../crypto-api/index.ts\";\nimport decryptAESSecretStorageItem from \"../utils/decryptAESSecretStorageItem.ts\";\nimport encryptAESSecretStorageItem from \"../utils/encryptAESSecretStorageItem.ts\";\nimport { AESEncryptedSecretStoragePayload } from \"../@types/AESEncryptedSecretStoragePayload.ts\";\nimport { calculateKeyCheck } from \"../secret-storage.ts\";\n\nconst KEY_BACKUP_KEYS_PER_REQUEST = 200;\nconst KEY_BACKUP_CHECK_RATE_LIMIT = 5000; // ms\n\ntype AuthData = IKeyBackupInfo[\"auth_data\"];\n\ntype SigInfo = {\n deviceId: string;\n valid?: boolean | null; // true: valid, false: invalid, null: cannot attempt validation\n device?: DeviceInfo | null;\n crossSigningId?: boolean;\n deviceTrust?: DeviceTrustLevel;\n};\n\n/** @deprecated Prefer {@link BackupTrustInfo} */\nexport type TrustInfo = {\n usable: boolean; // is the backup trusted, true iff there is a sig that is valid & from a trusted device\n sigs: SigInfo[];\n // eslint-disable-next-line camelcase\n trusted_locally?: boolean;\n};\n\nexport interface IKeyBackupCheck {\n backupInfo?: IKeyBackupInfo;\n trustInfo: TrustInfo;\n}\n\n/* eslint-disable camelcase */\nexport interface IPreparedKeyBackupVersion {\n algorithm: string;\n auth_data: AuthData;\n recovery_key: string;\n privateKey: Uint8Array;\n}\n/* eslint-enable camelcase */\n\n/** A function used to get the secret key for a backup.\n */\ntype GetKey = () => Promise<ArrayLike<number>>;\n\ninterface BackupAlgorithmClass {\n algorithmName: string;\n // initialize from an existing backup\n init(authData: AuthData, getKey: GetKey): Promise<BackupAlgorithm>;\n\n // prepare a brand new backup\n prepare(key?: string | Uint8Array | null): Promise<[Uint8Array, AuthData]>;\n\n checkBackupVersion(info: IKeyBackupInfo): void;\n}\n\ninterface BackupAlgorithm {\n untrusted: boolean;\n encryptSession(data: Record<string, any>): Promise<Curve25519SessionData | AESEncryptedSecretStoragePayload>;\n decryptSessions(ciphertexts: Record<string, IKeyBackupSession>): Promise<IMegolmSessionData[]>;\n authData: AuthData;\n keyMatches(key: ArrayLike<number>): Promise<boolean>;\n free(): void;\n}\n\nexport interface IKeyBackup {\n rooms: {\n [roomId: string]: {\n sessions: {\n [sessionId: string]: IKeyBackupSession;\n };\n };\n };\n}\n\n/**\n * Manages the key backup.\n */\nexport class BackupManager {\n private algorithm: BackupAlgorithm | undefined;\n public backupInfo: IKeyBackupInfo | undefined; // The info dict from /room_keys/version\n public checkedForBackup: boolean; // Have we checked the server for a backup we can use?\n private sendingBackups: boolean; // Are we currently sending backups?\n private sessionLastCheckAttemptedTime: Record<string, number> = {}; // When did we last try to check the server for a given session id?\n // The backup manager will schedule backup of keys when active (`scheduleKeyBackupSend`), this allows cancel when client is stopped\n private clientRunning = true;\n\n public constructor(\n private readonly baseApis: MatrixClient,\n public readonly getKey: GetKey,\n ) {\n this.checkedForBackup = false;\n this.sendingBackups = false;\n }\n\n /**\n * Stop the backup manager from backing up keys and allow a clean shutdown.\n */\n public stop(): void {\n this.clientRunning = false;\n }\n\n public get version(): string | undefined {\n return this.backupInfo && this.backupInfo.version;\n }\n\n /**\n * Performs a quick check to ensure that the backup info looks sane.\n *\n * Throws an error if a problem is detected.\n *\n * @param info - the key backup info\n */\n public static checkBackupVersion(info: IKeyBackupInfo): void {\n const Algorithm = algorithmsByName[info.algorithm];\n if (!Algorithm) {\n throw new Error(\"Unknown backup algorithm: \" + info.algorithm);\n }\n if (typeof info.auth_data !== \"object\") {\n throw new Error(\"Invalid backup data returned\");\n }\n return Algorithm.checkBackupVersion(info);\n }\n\n public static makeAlgorithm(info: IKeyBackupInfo, getKey: GetKey): Promise<BackupAlgorithm> {\n const Algorithm = algorithmsByName[info.algorithm];\n if (!Algorithm) {\n throw new Error(\"Unknown backup algorithm\");\n }\n return Algorithm.init(info.auth_data, getKey);\n }\n\n public async enableKeyBackup(info: IKeyBackupInfo): Promise<void> {\n this.backupInfo = info;\n if (this.algorithm) {\n this.algorithm.free();\n }\n\n this.algorithm = await BackupManager.makeAlgorithm(info, this.getKey);\n\n this.baseApis.emit(CryptoEvent.KeyBackupStatus, true);\n\n // There may be keys left over from a partially completed backup, so\n // schedule a send to check.\n this.scheduleKeyBackupSend();\n }\n\n /**\n * Disable backing up of keys.\n */\n public disableKeyBackup(): void {\n if (this.algorithm) {\n this.algorithm.free();\n }\n this.algorithm = undefined;\n\n this.backupInfo = undefined;\n\n this.baseApis.emit(CryptoEvent.KeyBackupStatus, false);\n }\n\n public getKeyBackupEnabled(): boolean | null {\n if (!this.checkedForBackup) {\n return null;\n }\n return Boolean(this.algorithm);\n }\n\n public async prepareKeyBackupVersion(\n key?: string | Uint8Array | null,\n algorithm?: string | undefined,\n ): Promise<IPreparedKeyBackupVersion> {\n const Algorithm = algorithm ? algorithmsByName[algorithm] : DefaultAlgorithm;\n if (!Algorithm) {\n throw new Error(\"Unknown backup algorithm\");\n }\n\n const [privateKey, authData] = await Algorithm.prepare(key);\n const recoveryKey = encodeRecoveryKey(privateKey)!;\n return {\n algorithm: Algorithm.algorithmName,\n auth_data: authData,\n recovery_key: recoveryKey,\n privateKey,\n };\n }\n\n public async createKeyBackupVersion(info: IKeyBackupInfo): Promise<void> {\n this.algorithm = await BackupManager.makeAlgorithm(info, this.getKey);\n }\n\n /**\n * Deletes all key backups.\n *\n * Will call the API to delete active backup until there is no more present.\n */\n public async deleteAllKeyBackupVersions(): Promise<void> {\n // there could be several backup versions, delete all to be safe.\n let current = (await this.baseApis.getKeyBackupVersion())?.version ?? null;\n while (current != null) {\n await this.deleteKeyBackupVersion(current);\n this.disableKeyBackup();\n current = (await this.baseApis.getKeyBackupVersion())?.version ?? null;\n }\n }\n\n /**\n * Deletes the given key backup.\n *\n * @param version - The backup version to delete.\n */\n public async deleteKeyBackupVersion(version: string): Promise<void> {\n const path = encodeUri(\"/room_keys/version/$version\", { $version: version });\n await this.baseApis.http.authedRequest<void>(Method.Delete, path, undefined, undefined, {\n prefix: ClientPrefix.V3,\n });\n }\n\n /**\n * Check the server for an active key backup and\n * if one is present and has a valid signature from\n * one of the user's verified devices, start backing up\n * to it.\n */\n public async checkAndStart(): Promise<IKeyBackupCheck | null> {\n logger.log(\"Checking key backup status...\");\n if (this.baseApis.isGuest()) {\n logger.log(\"Skipping key backup check since user is guest\");\n this.checkedForBackup = true;\n return null;\n }\n let backupInfo: IKeyBackupInfo | undefined;\n try {\n backupInfo = (await this.baseApis.getKeyBackupVersion()) ?? undefined;\n } catch (e) {\n logger.log(\"Error checking for active key backup\", e);\n if ((<HTTPError>e).httpStatus === 404) {\n // 404 is returned when the key backup does not exist, so that\n // counts as successfully checking.\n this.checkedForBackup = true;\n }\n return null;\n }\n this.checkedForBackup = true;\n\n const trustInfo = await this.isKeyBackupTrusted(backupInfo);\n\n if (trustInfo.usable && !this.backupInfo) {\n logger.log(`Found usable key backup v${backupInfo!.version}: enabling key backups`);\n await this.enableKeyBackup(backupInfo!);\n } else if (!trustInfo.usable && this.backupInfo) {\n logger.log(\"No usable key backup: disabling key backup\");\n this.disableKeyBackup();\n } else if (!trustInfo.usable && !this.backupInfo) {\n logger.log(\"No usable key backup: not enabling key backup\");\n } else if (trustInfo.usable && this.backupInfo) {\n // may not be the same version: if not, we should switch\n if (backupInfo!.version !== this.backupInfo.version) {\n logger.log(\n `On backup version ${this.backupInfo.version} but ` +\n `found version ${backupInfo!.version}: switching.`,\n );\n this.disableKeyBackup();\n await this.enableKeyBackup(backupInfo!);\n // We're now using a new backup, so schedule all the keys we have to be\n // uploaded to the new backup. This is a bit of a workaround to upload\n // keys to a new backup in *most* cases, but it won't cover all cases\n // because we don't remember what backup version we uploaded keys to:\n // see https://github.com/vector-im/element-web/issues/14833\n await this.scheduleAllGroupSessionsForBackup();\n } else {\n logger.log(`Backup version ${backupInfo!.version} still current`);\n }\n }\n\n return { backupInfo, trustInfo };\n }\n\n /**\n * Forces a re-check of the key backup and enables/disables it\n * as appropriate.\n *\n * @returns Object with backup info (as returned by\n * getKeyBackupVersion) in backupInfo and\n * trust information (as returned by isKeyBackupTrusted)\n * in trustInfo.\n */\n public async checkKeyBackup(): Promise<IKeyBackupCheck | null> {\n this.checkedForBackup = false;\n return this.checkAndStart();\n }\n\n /**\n * Attempts to retrieve a session from a key backup, if enough time\n * has elapsed since the last check for this session id.\n */\n public async queryKeyBackupRateLimited(\n targetRoomId: string | undefined,\n targetSessionId: string | undefined,\n ): Promise<void> {\n if (!this.backupInfo) {\n return;\n }\n\n const now = new Date().getTime();\n if (\n !this.sessionLastCheckAttemptedTime[targetSessionId!] ||\n now - this.sessionLastCheckAttemptedTime[targetSessionId!] > KEY_BACKUP_CHECK_RATE_LIMIT\n ) {\n this.sessionLastCheckAttemptedTime[targetSessionId!] = now;\n await this.baseApis.restoreKeyBackupWithCache(targetRoomId!, targetSessionId!, this.backupInfo, {});\n }\n }\n\n /**\n * Check if the given backup info is trusted.\n *\n * @param backupInfo - key backup info dict from /room_keys/version\n */\n public async isKeyBackupTrusted(backupInfo?: IKeyBackupInfo): Promise<TrustInfo> {\n const ret = {\n usable: false,\n trusted_locally: false,\n sigs: [] as SigInfo[],\n };\n\n if (!backupInfo || !backupInfo.algorithm || !backupInfo.auth_data || !backupInfo.auth_data.signatures) {\n logger.info(`Key backup is absent or missing required data: ${JSON.stringify(backupInfo)}`);\n return ret;\n }\n\n const userId = this.baseApis.getUserId()!;\n const privKey = await this.baseApis.crypto!.getSessionBackupPrivateKey();\n if (privKey) {\n let algorithm: BackupAlgorithm | null = null;\n try {\n algorithm = await BackupManager.makeAlgorithm(backupInfo, async () => privKey);\n\n if (await algorithm.keyMatches(privKey)) {\n logger.info(\"Backup is trusted locally\");\n ret.trusted_locally = true;\n }\n } catch {\n // do nothing -- if we have an error, then we don't mark it as\n // locally trusted\n } finally {\n algorithm?.free();\n }\n }\n\n const mySigs = backupInfo.auth_data.signatures[userId] || {};\n\n for (const keyId of Object.keys(mySigs)) {\n const keyIdParts = keyId.split(\":\");\n if (keyIdParts[0] !== \"ed25519\") {\n logger.log(\"Ignoring unknown signature type: \" + keyIdParts[0]);\n continue;\n }\n // Could be a cross-signing master key, but just say this is the device\n // ID for backwards compat\n const sigInfo: SigInfo = { deviceId: keyIdParts[1] };\n\n // first check to see if it's from our cross-signing key\n const crossSigningId = this.baseApis.crypto!.crossSigningInfo.getId();\n if (crossSigningId === sigInfo.deviceId) {\n sigInfo.crossSigningId = true;\n try {\n await verifySignature(\n this.baseApis.crypto!.olmDevice,\n backupInfo.auth_data,\n userId,\n sigInfo.deviceId,\n crossSigningId,\n );\n sigInfo.valid = true;\n } catch (e) {\n logger.warn(\"Bad signature from cross signing key \" + crossSigningId, e);\n sigInfo.valid = false;\n }\n ret.sigs.push(sigInfo);\n continue;\n }\n\n // Now look for a sig from a device\n // At some point this can probably go away and we'll just support\n // it being signed by the cross-signing master key\n const device = this.baseApis.crypto!.deviceList.getStoredDevice(userId, sigInfo.deviceId);\n if (device) {\n sigInfo.device = device;\n sigInfo.deviceTrust = this.baseApis.checkDeviceTrust(userId, sigInfo.deviceId);\n try {\n await verifySignature(\n this.baseApis.crypto!.olmDevice,\n backupInfo.auth_data,\n userId,\n device.deviceId,\n device.getFingerprint(),\n );\n sigInfo.valid = true;\n } catch (e) {\n logger.info(\n \"Bad signature from key ID \" +\n keyId +\n \" userID \" +\n this.baseApis.getUserId() +\n \" device ID \" +\n device.deviceId +\n \" fingerprint: \" +\n device.getFingerprint(),\n backupInfo.auth_data,\n e,\n );\n sigInfo.valid = false;\n }\n } else {\n sigInfo.valid = null; // Can't determine validity because we don't have the signing device\n logger.info(\"Ignoring signature from unknown key \" + keyId);\n }\n ret.sigs.push(sigInfo);\n }\n\n ret.usable = ret.sigs.some((s) => {\n return s.valid && ((s.device && s.deviceTrust?.isVerified()) || s.crossSigningId);\n });\n return ret;\n }\n\n /**\n * Schedules sending all keys waiting to be sent to the backup, if not already\n * scheduled. Retries if necessary.\n *\n * @param maxDelay - Maximum delay to wait in ms. 0 means no delay.\n */\n public async scheduleKeyBackupSend(maxDelay = 10000): Promise<void> {\n logger.debug(`Key backup: scheduleKeyBackupSend currentSending:${this.sendingBackups} delay:${maxDelay}`);\n if (this.sendingBackups) return;\n\n this.sendingBackups = true;\n\n try {\n // wait between 0 and `maxDelay` seconds, to avoid backup\n // requests from different clients hitting the server all at\n // the same time when a new key is sent\n const delay = Math.random() * maxDelay;\n await sleep(delay);\n if (!this.clientRunning) {\n this.sendingBackups = false;\n return;\n }\n let numFailures = 0; // number of consecutive failures\n for (;;) {\n if (!this.algorithm) {\n return;\n }\n try {\n const numBackedUp = await this.backupPendingKeys(KEY_BACKUP_KEYS_PER_REQUEST);\n if (numBackedUp === 0) {\n // no sessions left needing backup: we're done\n this.sendingBackups = false;\n return;\n }\n numFailures = 0;\n } catch (err) {\n numFailures++;\n logger.log(\"Key backup request failed\", err);\n if (err instanceof MatrixError) {\n const errCode = err.data.errcode;\n if (errCode == \"M_NOT_FOUND\" || errCode == \"M_WRONG_ROOM_KEYS_VERSION\") {\n // Set to false now as `checkKeyBackup` might schedule a backupsend before this one ends.\n this.sendingBackups = false;\n // Backup version has changed or this backup version\n // has been deleted\n this.baseApis.crypto!.emit(CryptoEvent.KeyBackupFailed, errCode);\n // Re-check key backup status on error, so we can be\n // sure to present the current situation when asked.\n // This call might restart the backup loop if new backup version is trusted\n await this.checkKeyBackup();\n return;\n }\n }\n }\n if (numFailures) {\n // exponential backoff if we have failures\n await sleep(1000 * Math.pow(2, Math.min(numFailures - 1, 4)));\n }\n\n if (!this.clientRunning) {\n logger.debug(\"Key backup send loop aborted, client stopped\");\n this.sendingBackups = false;\n return;\n }\n }\n } catch (err) {\n // No one actually checks errors on this promise, it's spawned internally.\n // Just log, apps/client should use events to check status\n logger.log(`Backup loop failed ${err}`);\n this.sendingBackups = false;\n }\n }\n\n /**\n * Take some e2e keys waiting to be backed up and send them\n * to the backup.\n *\n * @param limit - Maximum number of keys to back up\n * @returns Number of sessions backed up\n */\n public async backupPendingKeys(limit: number): Promise<number> {\n const sessions = await this.baseApis.crypto!.cryptoStore.getSessionsNeedingBackup(limit);\n if (!sessions.length) {\n return 0;\n }\n\n let remaining = await this.baseApis.crypto!.cryptoStore.countSessionsNeedingBackup();\n this.baseApis.crypto!.emit(CryptoEvent.KeyBackupSessionsRemaining, remaining);\n\n const rooms: IKeyBackup[\"rooms\"] = {};\n for (const session of sessions) {\n const roomId = session.sessionData!.room_id;\n safeSet(rooms, roomId, rooms[roomId] || { sessions: {} });\n\n const sessionData = this.baseApis.crypto!.olmDevice.exportInboundGroupSession(\n session.senderKey,\n session.sessionId,\n session.sessionData!,\n );\n sessionData.algorithm = MEGOLM_ALGORITHM;\n\n const forwardedCount = (sessionData.forwarding_curve25519_key_chain || []).length;\n\n const userId = this.baseApis.crypto!.deviceList.getUserByIdentityKey(MEGOLM_ALGORITHM, session.senderKey);\n const device =\n this.baseApis.crypto!.deviceList.getDeviceByIdentityKey(MEGOLM_ALGORITHM, session.senderKey) ??\n undefined;\n const verified = this.baseApis.crypto!.checkDeviceInfoTrust(userId!, device).isVerified();\n\n safeSet(rooms[roomId][\"sessions\"], session.sessionId, {\n first_message_index: sessionData.first_known_index,\n forwarded_count: forwardedCount,\n is_verified: verified,\n session_data: await this.algorithm!.encryptSession(sessionData),\n });\n }\n\n await this.baseApis.sendKeyBackup(undefined, undefined, this.backupInfo!.version, { rooms });\n\n await this.baseApis.crypto!.cryptoStore.unmarkSessionsNeedingBackup(sessions);\n remaining = await this.baseApis.crypto!.cryptoStore.countSessionsNeedingBackup();\n this.baseApis.crypto!.emit(CryptoEvent.KeyBackupSessionsRemaining, remaining);\n\n return sessions.length;\n }\n\n public async backupGroupSession(senderKey: string, sessionId: string): Promise<void> {\n await this.baseApis.crypto!.cryptoStore.markSessionsNeedingBackup([\n {\n senderKey: senderKey,\n sessionId: sessionId,\n },\n ]);\n\n if (this.backupInfo) {\n // don't wait for this to complete: it will delay so\n // happens in the background\n this.scheduleKeyBackupSend();\n }\n // if this.backupInfo is not set, then the keys will be backed up when\n // this.enableKeyBackup is called\n }\n\n /**\n * Marks all group sessions as needing to be backed up and schedules them to\n * upload in the background as soon as possible.\n */\n public async scheduleAllGroupSessionsForBackup(): Promise<void> {\n await this.flagAllGroupSessionsForBackup();\n\n // Schedule keys to upload in the background as soon as possible.\n this.scheduleKeyBackupSend(0 /* maxDelay */);\n }\n\n /**\n * Marks all group sessions as needing to be backed up without scheduling\n * them to upload in the background.\n * @returns Promise which resolves to the number of sessions now requiring a backup\n * (which will be equal to the number of sessions in the store).\n */\n public async flagAllGroupSessionsForBackup(): Promise<number> {\n await this.baseApis.crypto!.cryptoStore.doTxn(\n \"readwrite\",\n [IndexedDBCryptoStore.STORE_INBOUND_GROUP_SESSIONS, IndexedDBCryptoStore.STORE_BACKUP],\n (txn) => {\n this.baseApis.crypto!.cryptoStore.getAllEndToEndInboundGroupSessions(txn, (session) => {\n if (session !== null) {\n this.baseApis.crypto!.cryptoStore.markSessionsNeedingBackup([session], txn);\n }\n });\n },\n );\n\n const remaining = await this.baseApis.crypto!.cryptoStore.countSessionsNeedingBackup();\n this.baseApis.emit(CryptoEvent.KeyBackupSessionsRemaining, remaining);\n return remaining;\n }\n\n /**\n * Counts the number of end to end session keys that are waiting to be backed up\n * @returns Promise which resolves to the number of sessions requiring backup\n */\n public countSessionsNeedingBackup(): Promise<number> {\n return this.baseApis.crypto!.cryptoStore.countSessionsNeedingBackup();\n }\n}\n\nexport class Curve25519 implements BackupAlgorithm {\n public static algorithmName = \"m.megolm_backup.v1.curve25519-aes-sha2\";\n\n public constructor(\n public authData: ICurve25519AuthData,\n private publicKey: any, // FIXME: PkEncryption\n private getKey: () => Promise<Uint8Array>,\n ) {}\n\n public static async init(authData: AuthData, getKey: () => Promise<Uint8Array>): Promise<Curve25519> {\n if (!authData || !(\"public_key\" in authData)) {\n throw new Error(\"auth_data missing required information\");\n }\n const publicKey = new globalThis.Olm.PkEncryption();\n publicKey.set_recipient_key(authData.public_key);\n return new Curve25519(authData as ICurve25519AuthData, publicKey, getKey);\n }\n\n public static async prepare(key?: string | Uint8Array | null): Promise<[Uint8Array, AuthData]> {\n const decryption = new globalThis.Olm.PkDecryption();\n try {\n const authData: Partial<ICurve25519AuthData> = {};\n if (!key) {\n authData.public_key = decryption.generate_key();\n } else if (key instanceof Uint8Array) {\n authData.public_key = decryption.init_with_private_key(key);\n } else {\n const derivation = await keyFromPassphrase(key);\n authData.private_key_salt = derivation.salt;\n authData.private_key_iterations = derivation.iterations;\n authData.public_key = decryption.init_with_private_key(derivation.key);\n }\n const publicKey = new globalThis.Olm.PkEncryption();\n publicKey.set_recipient_key(authData.public_key);\n\n return [decryption.get_private_key(), authData as AuthData];\n } finally {\n decryption.free();\n }\n }\n\n public static checkBackupVersion(info: IKeyBackupInfo): void {\n if (!(\"public_key\" in info.auth_data)) {\n throw new Error(\"Invalid backup data returned\");\n }\n }\n\n public get untrusted(): boolean {\n return true;\n }\n\n public async encryptSession(data: Record<string, any>): Promise<Curve25519SessionData> {\n const plainText: Record<string, any> = Object.assign({}, data);\n delete plainText.session_id;\n delete plainText.room_id;\n delete plainText.first_known_index;\n return this.publicKey.encrypt(JSON.stringify(plainText));\n }\n\n public async decryptSessions(\n sessions: Record<string, IKeyBackupSession<Curve25519SessionData>>,\n ): Promise<IMegolmSessionData[]> {\n const privKey = await this.getKey();\n const decryption = new globalThis.Olm.PkDecryption();\n try {\n const backupPubKey = decryption.init_with_private_key(privKey);\n\n if (backupPubKey !== this.authData.public_key) {\n throw new MatrixError({ errcode: MatrixClient.RESTORE_BACKUP_ERROR_BAD_KEY });\n }\n\n const keys: IMegolmSessionData[] = [];\n\n for (const [sessionId, sessionData] of Object.entries(sessions)) {\n try {\n const decrypted = JSON.parse(\n decryption.decrypt(\n sessionData.session_data.ephemeral,\n sessionData.session_data.mac,\n sessionData.session_data.ciphertext,\n ),\n );\n decrypted.session_id = sessionId;\n keys.push(decrypted);\n } catch (e) {\n logger.log(\"Failed to decrypt megolm session from backup\", e, sessionData);\n }\n }\n return keys;\n } finally {\n decryption.free();\n }\n }\n\n public async keyMatches(key: Uint8Array): Promise<boolean> {\n const decryption = new globalThis.Olm.PkDecryption();\n let pubKey: string;\n try {\n pubKey = decryption.init_with_private_key(key);\n } finally {\n decryption.free();\n }\n\n return pubKey === this.authData.public_key;\n }\n\n public free(): void {\n this.publicKey.free();\n }\n}\n\nfunction randomBytes(size: number): Uint8Array {\n const buf = new Uint8Array(size);\n globalThis.crypto.getRandomValues(buf);\n return buf;\n}\n\nconst UNSTABLE_MSC3270_NAME = new UnstableValue(\n \"m.megolm_backup.v1.aes-hmac-sha2\",\n \"org.matrix.msc3270.v1.aes-hmac-sha2\",\n);\n\nexport class Aes256 implements BackupAlgorithm {\n public static algorithmName = UNSTABLE_MSC3270_NAME.name;\n\n public constructor(\n public readonly authData: IAes256AuthData,\n private readonly key: Uint8Array,\n ) {}\n\n public static async init(authData: IAes256AuthData, getKey: () => Promise<Uint8Array>): Promise<Aes256> {\n if (!authData) {\n throw new Error(\"auth_data missing\");\n }\n const key = await getKey();\n if (authData.mac) {\n const { mac } = await calculateKeyCheck(key, authData.iv);\n if (authData.mac.replace(/=+$/g, \"\") !== mac.replace(/=+/g, \"\")) {\n throw new Error(\"Key does not match\");\n }\n }\n return new Aes256(authData, key);\n }\n\n public static async prepare(key?: string | Uint8Array | null): Promise<[Uint8Array, AuthData]> {\n let outKey: Uint8Array;\n const authData: Partial<IAes256AuthData> = {};\n if (!key) {\n outKey = randomBytes(32);\n } else if (key instanceof Uint8Array) {\n outKey = new Uint8Array(key);\n } else {\n const derivation = await keyFromPassphrase(key);\n authData.private_key_salt = derivation.salt;\n authData.private_key_iterations = derivation.iterations;\n outKey = derivation.key;\n }\n\n const { iv, mac } = await calculateKeyCheck(outKey);\n authData.iv = iv;\n authData.mac = mac;\n\n return [outKey, authData as AuthData];\n }\n\n public static checkBackupVersion(info: IKeyBackupInfo): void {\n if (!(\"iv\" in info.auth_data && \"mac\" in info.auth_data)) {\n throw new Error(\"Invalid backup data returned\");\n }\n }\n\n public get untrusted(): boolean {\n return false;\n }\n\n public encryptSession(data: Record<string, any>): Promise<AESEncryptedSecretStoragePayload> {\n const plainText: Record<string, any> = Object.assign({}, data);\n delete plainText.session_id;\n delete plainText.room_id;\n delete plainText.first_known_index;\n return encryptAESSecretStorageItem(JSON.stringify(plainText), this.key, data.session_id);\n }\n\n public async decryptSessions(\n sessions: Record<string, IKeyBackupSession<AESEncryptedSecretStoragePayload>>,\n ): Promise<IMegolmSessionData[]> {\n const keys: IMegolmSessionData[] = [];\n\n for (const [sessionId, sessionData] of Object.entries(sessions)) {\n try {\n const decrypted = JSON.parse(\n await decryptAESSecretStorageItem(sessionData.session_data, this.key, sessionId),\n );\n decrypted.session_id = sessionId;\n keys.push(decrypted);\n } catch (e) {\n logger.log(\"Failed to decrypt megolm session from backup\", e, sessionData);\n }\n }\n return keys;\n }\n\n public async keyMatches(key: Uint8Array): Promise<boolean> {\n if (this.authData.mac) {\n const { mac } = await calculateKeyCheck(key, this.authData.iv);\n return this.authData.mac.replace(/=+$/g, \"\") === mac.replace(/=+/g, \"\");\n } else {\n // if we have no information, we have to assume the key is right\n return true;\n }\n }\n\n public free(): void {\n this.key.fill(0);\n }\n}\n\nexport const algorithmsByName: Record<string, BackupAlgorithmClass> = {\n [Curve25519.algorithmName]: Curve25519,\n [Aes256.algorithmName]: Aes256,\n};\n\n// the linter doesn't like this but knip does\n// eslint-disable-next-line tsdoc/syntax\n/** @alias */\nexport const DefaultAlgorithm: BackupAlgorithmClass = Curve25519;\n\n/**\n * Map a legacy {@link TrustInfo} into a new-style {@link BackupTrustInfo}.\n *\n * @param trustInfo - trustInfo to convert\n */\nexport function backupTrustInfoFromLegacyTrustInfo(trustInfo: TrustInfo): BackupTrustInfo {\n return {\n trusted: trustInfo.usable,\n matchesDecryptionKey: trustInfo.trusted_locally ?? false,\n };\n}\n\n/**\n * Implementation of {@link BackupDecryptor} for the libolm crypto backend.\n */\nexport class LibOlmBackupDecryptor implements BackupDecryptor {\n private algorithm: BackupAlgorithm;\n public readonly sourceTrusted: boolean;\n\n public constructor(algorithm: BackupAlgorithm) {\n this.algorithm = algorithm;\n this.sourceTrusted = !algorithm.untrusted;\n }\n\n /**\n * Implements {@link BackupDecryptor#free}\n */\n public free(): void {\n this.algorithm.free();\n }\n\n /**\n * Implements {@link BackupDecryptor#decryptSessions}\n */\n public async decryptSessions(\n sessions: Record<string, IKeyBackupSession<Curve25519SessionData>>,\n ): Promise<IMegolmSessionData[]> {\n return await this.algorithm.decryptSessions(sessions);\n }\n}\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAGA,SAASA,YAAY,QAAQ,cAAc;AAC3C,SAASC,MAAM,QAAQ,cAAc;AACrC,SAASC,gBAAgB,EAAEC,eAAe,QAAQ,aAAa;AAG/D,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ClE,CAACyK,UAAU,CAACjJ,aAAa,GAAGiJ,UAAU;EACtC,CAAC0C,MAAM,CAAC3L,aAAa,GAAG2L;AAC5B,CAAC;;AAED;AACA;AACA;AACA,OAAO,IAAMhM,gBAAsC,GAAGsJ,UAAU;;AAEhE;AACA;AACA;AACA;AACA;AACA,OAAO,SAASkD,kCAAkCA,CAACvK,SAAoB,EAAmB;EAAA,IAAAwK,qBAAA;EACtF,OAAO;IACHC,OAAO,EAAEzK,SAAS,CAACE,MAAM;IACzBwK,oBAAoB,GAAAF,qBAAA,GAAExK,SAAS,CAACkB,eAAe,cAAAsJ,qBAAA,cAAAA,qBAAA,GAAI;EACvD,CAAC;AACL;;AAEA;AACA;AACA;AACA,OAAO,MAAMG,qBAAqB,CAA4B;EAInD5O,WAAWA,CAACc,SAA0B,EAAE;IAAAX,eAAA;IAAAA,eAAA;IAC3C,IAAI,CAACW,SAAS,GAAGA,SAAS;IAC1B,IAAI,CAAC+N,aAAa,GAAG,CAAC/N,SAAS,CAAC0L,SAAS;EAC7C;;EAEA;AACJ;AACA;EACWlL,IAAIA,CAAA,EAAS;IAChB,IAAI,CAACR,SAAS,CAACQ,IAAI,CAAC,CAAC;EACzB;;EAEA;AACJ;AACA;EACiBwL,eAAeA,CACxBhE,QAAkE,EACrC;IAAA,IAAAgG,OAAA;IAAA,OAAAzN,iBAAA;MAC7B,aAAayN,OAAI,CAAChO,SAAS,CAACgM,eAAe,CAAChE,QAAQ,CAAC;IAAC;EAC1D;AACJ","ignoreList":[]}
@@ -1,3 +0,0 @@
1
- /** @deprecated this is a no-op and should no longer be called. */
2
- export declare function setCrypto(_crypto: Crypto): void;
3
- //# sourceMappingURL=crypto.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../src/crypto/crypto.ts"],"names":[],"mappings":"AAgBA,kEAAkE;AAClE,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAG"}
@@ -1,19 +0,0 @@
1
- /*
2
- Copyright 2022 The Matrix.org Foundation C.I.C.
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- */
16
-
17
- /** @deprecated this is a no-op and should no longer be called. */
18
- export function setCrypto(_crypto) {}
19
- //# sourceMappingURL=crypto.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"crypto.js","names":["setCrypto","_crypto"],"sources":["../../src/crypto/crypto.ts"],"sourcesContent":["/*\nCopyright 2022 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\n/** @deprecated this is a no-op and should no longer be called. */\nexport function setCrypto(_crypto: Crypto): void {}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,OAAO,SAASA,SAASA,CAACC,OAAe,EAAQ,CAAC","ignoreList":[]}
@@ -1,34 +0,0 @@
1
- import { Crypto } from "./index.ts";
2
- import { SecretStorageKeyDescription } from "../secret-storage.ts";
3
- export interface IDehydratedDevice {
4
- device_id: string;
5
- device_data: SecretStorageKeyDescription & {
6
- algorithm: string;
7
- account: string;
8
- };
9
- }
10
- export interface IDehydratedDeviceKeyInfo {
11
- passphrase?: string;
12
- }
13
- export declare const DEHYDRATION_ALGORITHM = "org.matrix.msc2697.v1.olm.libolm_pickle";
14
- export declare class DehydrationManager {
15
- private readonly crypto;
16
- private inProgress;
17
- private timeoutId;
18
- private key?;
19
- private keyInfo?;
20
- private deviceDisplayName?;
21
- constructor(crypto: Crypto);
22
- getDehydrationKeyFromCache(): Promise<void>;
23
- /** set the key, and queue periodic dehydration to the server in the background */
24
- setKeyAndQueueDehydration(key: Uint8Array, keyInfo?: {
25
- [props: string]: any;
26
- }, deviceDisplayName?: string): Promise<void>;
27
- setKey(key: Uint8Array, keyInfo?: {
28
- [props: string]: any;
29
- }, deviceDisplayName?: string): Promise<boolean | undefined>;
30
- /** returns the device id of the newly created dehydrated device */
31
- dehydrateDevice(): Promise<string | undefined>;
32
- stop(): void;
33
- }
34
- //# sourceMappingURL=dehydration.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dehydration.d.ts","sourceRoot":"","sources":["../../src/crypto/dehydration.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAInE,MAAM,WAAW,iBAAiB;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,2BAA2B,GAAG;QAEvC,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;KACnB,CAAC;CACL;AAED,MAAM,WAAW,wBAAwB;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,eAAO,MAAM,qBAAqB,4CAA4C,CAAC;AAI/E,qBAAa,kBAAkB;IAOR,OAAO,CAAC,QAAQ,CAAC,MAAM;IAN1C,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,SAAS,CAAM;IACvB,OAAO,CAAC,GAAG,CAAC,CAAa;IACzB,OAAO,CAAC,OAAO,CAAC,CAA2B;IAC3C,OAAO,CAAC,iBAAiB,CAAC,CAAS;gBAEC,MAAM,EAAE,MAAM;IAI3C,0BAA0B,IAAI,OAAO,CAAC,IAAI,CAAC;IAsBlD,kFAAkF;IACrE,yBAAyB,CAClC,GAAG,EAAE,UAAU,EACf,OAAO,GAAE;QAAE,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,CAAA;KAAO,EACtC,iBAAiB,CAAC,EAAE,MAAM,GAC3B,OAAO,CAAC,IAAI,CAAC;IAQH,MAAM,CACf,GAAG,EAAE,UAAU,EACf,OAAO,GAAE;QAAE,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,CAAA;KAAO,EACtC,iBAAiB,CAAC,EAAE,MAAM,GAC3B,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC;IAkC/B,mEAAmE;IACtD,eAAe,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAuIpD,IAAI,IAAI,IAAI;CAMtB"}
@@ -1,252 +0,0 @@
1
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
- /*
4
- Copyright 2020-2021 The Matrix.org Foundation C.I.C.
5
-
6
- Licensed under the Apache License, Version 2.0 (the "License");
7
- you may not use this file except in compliance with the License.
8
- You may obtain a copy of the License at
9
-
10
- http://www.apache.org/licenses/LICENSE-2.0
11
-
12
- Unless required by applicable law or agreed to in writing, software
13
- distributed under the License is distributed on an "AS IS" BASIS,
14
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- See the License for the specific language governing permissions and
16
- limitations under the License.
17
- */
18
-
19
- import anotherjson from "another-json";
20
- import { decodeBase64, encodeBase64 } from "../base64.js";
21
- import { IndexedDBCryptoStore } from "../crypto/store/indexeddb-crypto-store.js";
22
- import { logger } from "../logger.js";
23
- import { Method } from "../http-api/index.js";
24
- import decryptAESSecretStorageItem from "../utils/decryptAESSecretStorageItem.js";
25
- import encryptAESSecretStorageItem from "../utils/encryptAESSecretStorageItem.js";
26
- export var DEHYDRATION_ALGORITHM = "org.matrix.msc2697.v1.olm.libolm_pickle";
27
- var oneweek = 7 * 24 * 60 * 60 * 1000;
28
- export class DehydrationManager {
29
- constructor(crypto) {
30
- this.crypto = crypto;
31
- _defineProperty(this, "inProgress", false);
32
- _defineProperty(this, "timeoutId", void 0);
33
- _defineProperty(this, "key", void 0);
34
- _defineProperty(this, "keyInfo", void 0);
35
- _defineProperty(this, "deviceDisplayName", void 0);
36
- this.getDehydrationKeyFromCache();
37
- }
38
- getDehydrationKeyFromCache() {
39
- var _this = this;
40
- return this.crypto.cryptoStore.doTxn("readonly", [IndexedDBCryptoStore.STORE_ACCOUNT], txn => {
41
- this.crypto.cryptoStore.getSecretStorePrivateKey(txn, /*#__PURE__*/function () {
42
- var _ref = _asyncToGenerator(function* (result) {
43
- if (result) {
44
- var {
45
- key,
46
- keyInfo,
47
- deviceDisplayName,
48
- time
49
- } = result;
50
- var pickleKey = Buffer.from(_this.crypto.olmDevice.pickleKey);
51
- var decrypted = yield decryptAESSecretStorageItem(key, pickleKey, DEHYDRATION_ALGORITHM);
52
- _this.key = decodeBase64(decrypted);
53
- _this.keyInfo = keyInfo;
54
- _this.deviceDisplayName = deviceDisplayName;
55
- var now = Date.now();
56
- var delay = Math.max(1, time + oneweek - now);
57
- _this.timeoutId = globalThis.setTimeout(_this.dehydrateDevice.bind(_this), delay);
58
- }
59
- });
60
- return function (_x) {
61
- return _ref.apply(this, arguments);
62
- };
63
- }(), "dehydration");
64
- });
65
- }
66
-
67
- /** set the key, and queue periodic dehydration to the server in the background */
68
- setKeyAndQueueDehydration(key) {
69
- var _arguments = arguments,
70
- _this2 = this;
71
- return _asyncToGenerator(function* () {
72
- var keyInfo = _arguments.length > 1 && _arguments[1] !== undefined ? _arguments[1] : {};
73
- var deviceDisplayName = _arguments.length > 2 ? _arguments[2] : undefined;
74
- var matches = yield _this2.setKey(key, keyInfo, deviceDisplayName);
75
- if (!matches) {
76
- // start dehydration in the background
77
- _this2.dehydrateDevice();
78
- }
79
- })();
80
- }
81
- setKey(key) {
82
- var _arguments2 = arguments,
83
- _this3 = this;
84
- return _asyncToGenerator(function* () {
85
- var keyInfo = _arguments2.length > 1 && _arguments2[1] !== undefined ? _arguments2[1] : {};
86
- var deviceDisplayName = _arguments2.length > 2 ? _arguments2[2] : undefined;
87
- if (!key) {
88
- // unsetting the key -- cancel any pending dehydration task
89
- if (_this3.timeoutId) {
90
- globalThis.clearTimeout(_this3.timeoutId);
91
- _this3.timeoutId = undefined;
92
- }
93
- // clear storage
94
- yield _this3.crypto.cryptoStore.doTxn("readwrite", [IndexedDBCryptoStore.STORE_ACCOUNT], txn => {
95
- _this3.crypto.cryptoStore.storeSecretStorePrivateKey(txn, "dehydration", null);
96
- });
97
- _this3.key = undefined;
98
- _this3.keyInfo = undefined;
99
- return;
100
- }
101
-
102
- // Check to see if it's the same key as before. If it's different,
103
- // dehydrate a new device. If it's the same, we can keep the same
104
- // device. (Assume that keyInfo and deviceDisplayName will be the
105
- // same if the key is the same.)
106
- var matches = !!_this3.key && key.length == _this3.key.length;
107
- for (var i = 0; matches && i < key.length; i++) {
108
- if (key[i] != _this3.key[i]) {
109
- matches = false;
110
- }
111
- }
112
- if (!matches) {
113
- _this3.key = key;
114
- _this3.keyInfo = keyInfo;
115
- _this3.deviceDisplayName = deviceDisplayName;
116
- }
117
- return matches;
118
- })();
119
- }
120
-
121
- /** returns the device id of the newly created dehydrated device */
122
- dehydrateDevice() {
123
- var _this4 = this;
124
- return _asyncToGenerator(function* () {
125
- if (_this4.inProgress) {
126
- logger.log("Dehydration already in progress -- not starting new dehydration");
127
- return;
128
- }
129
- _this4.inProgress = true;
130
- if (_this4.timeoutId) {
131
- globalThis.clearTimeout(_this4.timeoutId);
132
- _this4.timeoutId = undefined;
133
- }
134
- try {
135
- var pickleKey = Buffer.from(_this4.crypto.olmDevice.pickleKey);
136
-
137
- // update the crypto store with the timestamp
138
- var key = yield encryptAESSecretStorageItem(encodeBase64(_this4.key), pickleKey, DEHYDRATION_ALGORITHM);
139
- yield _this4.crypto.cryptoStore.doTxn("readwrite", [IndexedDBCryptoStore.STORE_ACCOUNT], txn => {
140
- _this4.crypto.cryptoStore.storeSecretStorePrivateKey(txn, "dehydration", {
141
- keyInfo: _this4.keyInfo,
142
- key,
143
- deviceDisplayName: _this4.deviceDisplayName,
144
- time: Date.now()
145
- });
146
- });
147
- logger.log("Attempting to dehydrate device");
148
- logger.log("Creating account");
149
- // create the account and all the necessary keys
150
- var account = new globalThis.Olm.Account();
151
- account.create();
152
- var e2eKeys = JSON.parse(account.identity_keys());
153
- var maxKeys = account.max_number_of_one_time_keys();
154
- // FIXME: generate in small batches?
155
- account.generate_one_time_keys(maxKeys / 2);
156
- account.generate_fallback_key();
157
- var otks = JSON.parse(account.one_time_keys());
158
- var fallbacks = JSON.parse(account.fallback_key());
159
- account.mark_keys_as_published();
160
-
161
- // dehydrate the account and store it on the server
162
- var pickledAccount = account.pickle(new Uint8Array(_this4.key));
163
- var deviceData = {
164
- algorithm: DEHYDRATION_ALGORITHM,
165
- account: pickledAccount
166
- };
167
- if (_this4.keyInfo.passphrase) {
168
- deviceData.passphrase = _this4.keyInfo.passphrase;
169
- }
170
- logger.log("Uploading account to server");
171
- // eslint-disable-next-line camelcase
172
- var dehydrateResult = yield _this4.crypto.baseApis.http.authedRequest(Method.Put, "/dehydrated_device", undefined, {
173
- device_data: deviceData,
174
- initial_device_display_name: _this4.deviceDisplayName
175
- }, {
176
- prefix: "/_matrix/client/unstable/org.matrix.msc2697.v2"
177
- });
178
-
179
- // send the keys to the server
180
- var deviceId = dehydrateResult.device_id;
181
- logger.log("Preparing device keys", deviceId);
182
- var deviceKeys = {
183
- algorithms: _this4.crypto.supportedAlgorithms,
184
- device_id: deviceId,
185
- user_id: _this4.crypto.userId,
186
- keys: {
187
- ["ed25519:".concat(deviceId)]: e2eKeys.ed25519,
188
- ["curve25519:".concat(deviceId)]: e2eKeys.curve25519
189
- }
190
- };
191
- var deviceSignature = account.sign(anotherjson.stringify(deviceKeys));
192
- deviceKeys.signatures = {
193
- [_this4.crypto.userId]: {
194
- ["ed25519:".concat(deviceId)]: deviceSignature
195
- }
196
- };
197
- if (_this4.crypto.crossSigningInfo.getId("self_signing")) {
198
- yield _this4.crypto.crossSigningInfo.signObject(deviceKeys, "self_signing");
199
- }
200
- logger.log("Preparing one-time keys");
201
- var oneTimeKeys = {};
202
- for (var [keyId, _key] of Object.entries(otks.curve25519)) {
203
- var k = {
204
- key: _key
205
- };
206
- var signature = account.sign(anotherjson.stringify(k));
207
- k.signatures = {
208
- [_this4.crypto.userId]: {
209
- ["ed25519:".concat(deviceId)]: signature
210
- }
211
- };
212
- oneTimeKeys["signed_curve25519:".concat(keyId)] = k;
213
- }
214
- logger.log("Preparing fallback keys");
215
- var fallbackKeys = {};
216
- for (var [_keyId, _key2] of Object.entries(fallbacks.curve25519)) {
217
- var _k = {
218
- key: _key2,
219
- fallback: true
220
- };
221
- var _signature = account.sign(anotherjson.stringify(_k));
222
- _k.signatures = {
223
- [_this4.crypto.userId]: {
224
- ["ed25519:".concat(deviceId)]: _signature
225
- }
226
- };
227
- fallbackKeys["signed_curve25519:".concat(_keyId)] = _k;
228
- }
229
- logger.log("Uploading keys to server");
230
- yield _this4.crypto.baseApis.http.authedRequest(Method.Post, "/keys/upload/" + encodeURI(deviceId), undefined, {
231
- "device_keys": deviceKeys,
232
- "one_time_keys": oneTimeKeys,
233
- "org.matrix.msc2732.fallback_keys": fallbackKeys
234
- });
235
- logger.log("Done dehydrating");
236
-
237
- // dehydrate again in a week
238
- _this4.timeoutId = globalThis.setTimeout(_this4.dehydrateDevice.bind(_this4), oneweek);
239
- return deviceId;
240
- } finally {
241
- _this4.inProgress = false;
242
- }
243
- })();
244
- }
245
- stop() {
246
- if (this.timeoutId) {
247
- globalThis.clearTimeout(this.timeoutId);
248
- this.timeoutId = undefined;
249
- }
250
- }
251
- }
252
- //# sourceMappingURL=dehydration.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dehydration.js","names":["anotherjson","decodeBase64","encodeBase64","IndexedDBCryptoStore","logger","Method","decryptAESSecretStorageItem","encryptAESSecretStorageItem","DEHYDRATION_ALGORITHM","oneweek","DehydrationManager","constructor","crypto","_defineProperty","getDehydrationKeyFromCache","_this","cryptoStore","doTxn","STORE_ACCOUNT","txn","getSecretStorePrivateKey","_ref","_asyncToGenerator","result","key","keyInfo","deviceDisplayName","time","pickleKey","Buffer","from","olmDevice","decrypted","now","Date","delay","Math","max","timeoutId","globalThis","setTimeout","dehydrateDevice","bind","_x","apply","arguments","setKeyAndQueueDehydration","_arguments","_this2","length","undefined","matches","setKey","_arguments2","_this3","clearTimeout","storeSecretStorePrivateKey","i","_this4","inProgress","log","account","Olm","Account","create","e2eKeys","JSON","parse","identity_keys","maxKeys","max_number_of_one_time_keys","generate_one_time_keys","generate_fallback_key","otks","one_time_keys","fallbacks","fallback_key","mark_keys_as_published","pickledAccount","pickle","Uint8Array","deviceData","algorithm","passphrase","dehydrateResult","baseApis","http","authedRequest","Put","device_data","initial_device_display_name","prefix","deviceId","device_id","deviceKeys","algorithms","supportedAlgorithms","user_id","userId","keys","concat","ed25519","curve25519","deviceSignature","sign","stringify","signatures","crossSigningInfo","getId","signObject","oneTimeKeys","keyId","Object","entries","k","signature","fallbackKeys","fallback","Post","encodeURI","stop"],"sources":["../../src/crypto/dehydration.ts"],"sourcesContent":["/*\nCopyright 2020-2021 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport anotherjson from \"another-json\";\n\nimport type { IDeviceKeys, IOneTimeKey } from \"../@types/crypto.ts\";\nimport { decodeBase64, encodeBase64 } from \"../base64.ts\";\nimport { IndexedDBCryptoStore } from \"../crypto/store/indexeddb-crypto-store.ts\";\nimport { logger } from \"../logger.ts\";\nimport { Crypto } from \"./index.ts\";\nimport { Method } from \"../http-api/index.ts\";\nimport { SecretStorageKeyDescription } from \"../secret-storage.ts\";\nimport decryptAESSecretStorageItem from \"../utils/decryptAESSecretStorageItem.ts\";\nimport encryptAESSecretStorageItem from \"../utils/encryptAESSecretStorageItem.ts\";\n\nexport interface IDehydratedDevice {\n device_id: string; // eslint-disable-line camelcase\n device_data: SecretStorageKeyDescription & {\n // eslint-disable-line camelcase\n algorithm: string;\n account: string; // pickle\n };\n}\n\nexport interface IDehydratedDeviceKeyInfo {\n passphrase?: string;\n}\n\nexport const DEHYDRATION_ALGORITHM = \"org.matrix.msc2697.v1.olm.libolm_pickle\";\n\nconst oneweek = 7 * 24 * 60 * 60 * 1000;\n\nexport class DehydrationManager {\n private inProgress = false;\n private timeoutId: any;\n private key?: Uint8Array;\n private keyInfo?: { [props: string]: any };\n private deviceDisplayName?: string;\n\n public constructor(private readonly crypto: Crypto) {\n this.getDehydrationKeyFromCache();\n }\n\n public getDehydrationKeyFromCache(): Promise<void> {\n return this.crypto.cryptoStore.doTxn(\"readonly\", [IndexedDBCryptoStore.STORE_ACCOUNT], (txn) => {\n this.crypto.cryptoStore.getSecretStorePrivateKey(\n txn,\n async (result) => {\n if (result) {\n const { key, keyInfo, deviceDisplayName, time } = result;\n const pickleKey = Buffer.from(this.crypto.olmDevice.pickleKey);\n const decrypted = await decryptAESSecretStorageItem(key, pickleKey, DEHYDRATION_ALGORITHM);\n this.key = decodeBase64(decrypted);\n this.keyInfo = keyInfo;\n this.deviceDisplayName = deviceDisplayName;\n const now = Date.now();\n const delay = Math.max(1, time + oneweek - now);\n this.timeoutId = globalThis.setTimeout(this.dehydrateDevice.bind(this), delay);\n }\n },\n \"dehydration\",\n );\n });\n }\n\n /** set the key, and queue periodic dehydration to the server in the background */\n public async setKeyAndQueueDehydration(\n key: Uint8Array,\n keyInfo: { [props: string]: any } = {},\n deviceDisplayName?: string,\n ): Promise<void> {\n const matches = await this.setKey(key, keyInfo, deviceDisplayName);\n if (!matches) {\n // start dehydration in the background\n this.dehydrateDevice();\n }\n }\n\n public async setKey(\n key: Uint8Array,\n keyInfo: { [props: string]: any } = {},\n deviceDisplayName?: string,\n ): Promise<boolean | undefined> {\n if (!key) {\n // unsetting the key -- cancel any pending dehydration task\n if (this.timeoutId) {\n globalThis.clearTimeout(this.timeoutId);\n this.timeoutId = undefined;\n }\n // clear storage\n await this.crypto.cryptoStore.doTxn(\"readwrite\", [IndexedDBCryptoStore.STORE_ACCOUNT], (txn) => {\n this.crypto.cryptoStore.storeSecretStorePrivateKey(txn, \"dehydration\", null);\n });\n this.key = undefined;\n this.keyInfo = undefined;\n return;\n }\n\n // Check to see if it's the same key as before. If it's different,\n // dehydrate a new device. If it's the same, we can keep the same\n // device. (Assume that keyInfo and deviceDisplayName will be the\n // same if the key is the same.)\n let matches: boolean = !!this.key && key.length == this.key.length;\n for (let i = 0; matches && i < key.length; i++) {\n if (key[i] != this.key![i]) {\n matches = false;\n }\n }\n if (!matches) {\n this.key = key;\n this.keyInfo = keyInfo;\n this.deviceDisplayName = deviceDisplayName;\n }\n return matches;\n }\n\n /** returns the device id of the newly created dehydrated device */\n public async dehydrateDevice(): Promise<string | undefined> {\n if (this.inProgress) {\n logger.log(\"Dehydration already in progress -- not starting new dehydration\");\n return;\n }\n this.inProgress = true;\n if (this.timeoutId) {\n globalThis.clearTimeout(this.timeoutId);\n this.timeoutId = undefined;\n }\n try {\n const pickleKey = Buffer.from(this.crypto.olmDevice.pickleKey);\n\n // update the crypto store with the timestamp\n const key = await encryptAESSecretStorageItem(encodeBase64(this.key!), pickleKey, DEHYDRATION_ALGORITHM);\n await this.crypto.cryptoStore.doTxn(\"readwrite\", [IndexedDBCryptoStore.STORE_ACCOUNT], (txn) => {\n this.crypto.cryptoStore.storeSecretStorePrivateKey(txn, \"dehydration\", {\n keyInfo: this.keyInfo,\n key,\n deviceDisplayName: this.deviceDisplayName!,\n time: Date.now(),\n });\n });\n logger.log(\"Attempting to dehydrate device\");\n\n logger.log(\"Creating account\");\n // create the account and all the necessary keys\n const account = new globalThis.Olm.Account();\n account.create();\n const e2eKeys = JSON.parse(account.identity_keys());\n\n const maxKeys = account.max_number_of_one_time_keys();\n // FIXME: generate in small batches?\n account.generate_one_time_keys(maxKeys / 2);\n account.generate_fallback_key();\n const otks: Record<string, string> = JSON.parse(account.one_time_keys());\n const fallbacks: Record<string, string> = JSON.parse(account.fallback_key());\n account.mark_keys_as_published();\n\n // dehydrate the account and store it on the server\n const pickledAccount = account.pickle(new Uint8Array(this.key!));\n\n const deviceData: { [props: string]: any } = {\n algorithm: DEHYDRATION_ALGORITHM,\n account: pickledAccount,\n };\n if (this.keyInfo!.passphrase) {\n deviceData.passphrase = this.keyInfo!.passphrase;\n }\n\n logger.log(\"Uploading account to server\");\n // eslint-disable-next-line camelcase\n const dehydrateResult = await this.crypto.baseApis.http.authedRequest<{ device_id: string }>(\n Method.Put,\n \"/dehydrated_device\",\n undefined,\n {\n device_data: deviceData,\n initial_device_display_name: this.deviceDisplayName,\n },\n {\n prefix: \"/_matrix/client/unstable/org.matrix.msc2697.v2\",\n },\n );\n\n // send the keys to the server\n const deviceId = dehydrateResult.device_id;\n logger.log(\"Preparing device keys\", deviceId);\n const deviceKeys: IDeviceKeys = {\n algorithms: this.crypto.supportedAlgorithms,\n device_id: deviceId,\n user_id: this.crypto.userId,\n keys: {\n [`ed25519:${deviceId}`]: e2eKeys.ed25519,\n [`curve25519:${deviceId}`]: e2eKeys.curve25519,\n },\n };\n const deviceSignature = account.sign(anotherjson.stringify(deviceKeys));\n deviceKeys.signatures = {\n [this.crypto.userId]: {\n [`ed25519:${deviceId}`]: deviceSignature,\n },\n };\n if (this.crypto.crossSigningInfo.getId(\"self_signing\")) {\n await this.crypto.crossSigningInfo.signObject(deviceKeys, \"self_signing\");\n }\n\n logger.log(\"Preparing one-time keys\");\n const oneTimeKeys: Record<string, IOneTimeKey> = {};\n for (const [keyId, key] of Object.entries(otks.curve25519)) {\n const k: IOneTimeKey = { key };\n const signature = account.sign(anotherjson.stringify(k));\n k.signatures = {\n [this.crypto.userId]: {\n [`ed25519:${deviceId}`]: signature,\n },\n };\n oneTimeKeys[`signed_curve25519:${keyId}`] = k;\n }\n\n logger.log(\"Preparing fallback keys\");\n const fallbackKeys: Record<string, IOneTimeKey> = {};\n for (const [keyId, key] of Object.entries(fallbacks.curve25519)) {\n const k: IOneTimeKey = { key, fallback: true };\n const signature = account.sign(anotherjson.stringify(k));\n k.signatures = {\n [this.crypto.userId]: {\n [`ed25519:${deviceId}`]: signature,\n },\n };\n fallbackKeys[`signed_curve25519:${keyId}`] = k;\n }\n\n logger.log(\"Uploading keys to server\");\n await this.crypto.baseApis.http.authedRequest(\n Method.Post,\n \"/keys/upload/\" + encodeURI(deviceId),\n undefined,\n {\n \"device_keys\": deviceKeys,\n \"one_time_keys\": oneTimeKeys,\n \"org.matrix.msc2732.fallback_keys\": fallbackKeys,\n },\n );\n logger.log(\"Done dehydrating\");\n\n // dehydrate again in a week\n this.timeoutId = globalThis.setTimeout(this.dehydrateDevice.bind(this), oneweek);\n\n return deviceId;\n } finally {\n this.inProgress = false;\n }\n }\n\n public stop(): void {\n if (this.timeoutId) {\n globalThis.clearTimeout(this.timeoutId);\n this.timeoutId = undefined;\n }\n }\n}\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,WAAW,MAAM,cAAc;AAGtC,SAASC,YAAY,EAAEC,YAAY,QAAQ,cAAc;AACzD,SAASC,oBAAoB,QAAQ,2CAA2C;AAChF,SAASC,MAAM,QAAQ,cAAc;AAErC,SAASC,MAAM,QAAQ,sBAAsB;AAE7C,OAAOC,2BAA2B,MAAM,yCAAyC;AACjF,OAAOC,2BAA2B,MAAM,yCAAyC;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"./deviceinfo.ts";
3
- /**
4
- * Convert a {@link DeviceInfo} to a {@link Device}.
5
- * @param deviceInfo - deviceInfo to convert
6
- * @param userId - id of the user that owns the device.
7
- */
8
- export declare function deviceInfoToDevice(deviceInfo: DeviceInfo, userId: string): Device;
9
- //# sourceMappingURL=device-converter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"device-converter.d.ts","sourceRoot":"","sources":["../../src/crypto/device-converter.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAoBjF"}
@@ -1,42 +0,0 @@
1
- /*
2
- Copyright 2023 The Matrix.org Foundation C.I.C.
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- */
16
-
17
- import { Device } from "../models/device.js";
18
- /**
19
- * Convert a {@link DeviceInfo} to a {@link Device}.
20
- * @param deviceInfo - deviceInfo to convert
21
- * @param userId - id of the user that owns the device.
22
- */
23
- export function deviceInfoToDevice(deviceInfo, userId) {
24
- var keys = new Map(Object.entries(deviceInfo.keys));
25
- var displayName = deviceInfo.getDisplayName() || undefined;
26
- var signatures = new Map();
27
- if (deviceInfo.signatures) {
28
- for (var _userId in deviceInfo.signatures) {
29
- signatures.set(_userId, new Map(Object.entries(deviceInfo.signatures[_userId])));
30
- }
31
- }
32
- return new Device({
33
- deviceId: deviceInfo.deviceId,
34
- userId: userId,
35
- keys,
36
- algorithms: deviceInfo.algorithms,
37
- verified: deviceInfo.verified,
38
- signatures,
39
- displayName
40
- });
41
- }
42
- //# sourceMappingURL=device-converter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"device-converter.js","names":["Device","deviceInfoToDevice","deviceInfo","userId","keys","Map","Object","entries","displayName","getDisplayName","undefined","signatures","set","deviceId","algorithms","verified"],"sources":["../../src/crypto/device-converter.ts"],"sourcesContent":["/*\nCopyright 2023 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { Device } from \"../models/device.ts\";\nimport { DeviceInfo } from \"./deviceinfo.ts\";\n\n/**\n * Convert a {@link DeviceInfo} to a {@link Device}.\n * @param deviceInfo - deviceInfo to convert\n * @param userId - id of the user that owns the device.\n */\nexport function deviceInfoToDevice(deviceInfo: DeviceInfo, userId: string): Device {\n const keys = new Map<string, string>(Object.entries(deviceInfo.keys));\n const displayName = deviceInfo.getDisplayName() || undefined;\n\n const signatures = new Map<string, Map<string, string>>();\n if (deviceInfo.signatures) {\n for (const userId in deviceInfo.signatures) {\n signatures.set(userId, new Map(Object.entries(deviceInfo.signatures[userId])));\n }\n }\n\n return new Device({\n deviceId: deviceInfo.deviceId,\n userId: userId,\n keys,\n algorithms: deviceInfo.algorithms,\n verified: deviceInfo.verified,\n signatures,\n displayName,\n });\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,MAAM,QAAQ,qBAAqB;AAG5C;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAACC,UAAsB,EAAEC,MAAc,EAAU;EAC/E,IAAMC,IAAI,GAAG,IAAIC,GAAG,CAAiBC,MAAM,CAACC,OAAO,CAACL,UAAU,CAACE,IAAI,CAAC,CAAC;EACrE,IAAMI,WAAW,GAAGN,UAAU,CAACO,cAAc,CAAC,CAAC,IAAIC,SAAS;EAE5D,IAAMC,UAAU,GAAG,IAAIN,GAAG,CAA8B,CAAC;EACzD,IAAIH,UAAU,CAACS,UAAU,EAAE;IACvB,KAAK,IAAMR,OAAM,IAAID,UAAU,CAACS,UAAU,EAAE;MACxCA,UAAU,CAACC,GAAG,CAACT,OAAM,EAAE,IAAIE,GAAG,CAACC,MAAM,CAACC,OAAO,CAACL,UAAU,CAACS,UAAU,CAACR,OAAM,CAAC,CAAC,CAAC,CAAC;IAClF;EACJ;EAEA,OAAO,IAAIH,MAAM,CAAC;IACda,QAAQ,EAAEX,UAAU,CAACW,QAAQ;IAC7BV,MAAM,EAAEA,MAAM;IACdC,IAAI;IACJU,UAAU,EAAEZ,UAAU,CAACY,UAAU;IACjCC,QAAQ,EAAEb,UAAU,CAACa,QAAQ;IAC7BJ,UAAU;IACVH;EACJ,CAAC,CAAC;AACN","ignoreList":[]}