@textrp/briij-js-sdk 41.0.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 (1104) hide show
  1. package/CHANGELOG.md +6464 -0
  2. package/LICENSE +177 -0
  3. package/README.md +477 -0
  4. package/lib/@types/AESEncryptedSecretStoragePayload.d.ts +14 -0
  5. package/lib/@types/AESEncryptedSecretStoragePayload.d.ts.map +1 -0
  6. package/lib/@types/AESEncryptedSecretStoragePayload.js +1 -0
  7. package/lib/@types/AESEncryptedSecretStoragePayload.js.map +1 -0
  8. package/lib/@types/IIdentityServerProvider.d.ts +9 -0
  9. package/lib/@types/IIdentityServerProvider.d.ts.map +1 -0
  10. package/lib/@types/IIdentityServerProvider.js +1 -0
  11. package/lib/@types/IIdentityServerProvider.js.map +1 -0
  12. package/lib/@types/PushRules.d.ts +140 -0
  13. package/lib/@types/PushRules.d.ts.map +1 -0
  14. package/lib/@types/PushRules.js +94 -0
  15. package/lib/@types/PushRules.js.map +1 -0
  16. package/lib/@types/another-json.d.js +0 -0
  17. package/lib/@types/another-json.d.js.map +1 -0
  18. package/lib/@types/auth.d.ts +213 -0
  19. package/lib/@types/auth.d.ts.map +1 -0
  20. package/lib/@types/auth.js +107 -0
  21. package/lib/@types/auth.js.map +1 -0
  22. package/lib/@types/beacon.d.ts +106 -0
  23. package/lib/@types/beacon.d.ts.map +1 -0
  24. package/lib/@types/beacon.js +119 -0
  25. package/lib/@types/beacon.js.map +1 -0
  26. package/lib/@types/common.d.ts +10 -0
  27. package/lib/@types/common.d.ts.map +1 -0
  28. package/lib/@types/common.js +1 -0
  29. package/lib/@types/common.js.map +1 -0
  30. package/lib/@types/crypto.d.ts +46 -0
  31. package/lib/@types/crypto.d.ts.map +1 -0
  32. package/lib/@types/crypto.js +1 -0
  33. package/lib/@types/crypto.js.map +1 -0
  34. package/lib/@types/event.d.ts +356 -0
  35. package/lib/@types/event.d.ts.map +1 -0
  36. package/lib/@types/event.js +280 -0
  37. package/lib/@types/event.js.map +1 -0
  38. package/lib/@types/events.d.ts +92 -0
  39. package/lib/@types/events.d.ts.map +1 -0
  40. package/lib/@types/events.js +1 -0
  41. package/lib/@types/events.js.map +1 -0
  42. package/lib/@types/extensible_events.d.ts +98 -0
  43. package/lib/@types/extensible_events.d.ts.map +1 -0
  44. package/lib/@types/extensible_events.js +116 -0
  45. package/lib/@types/extensible_events.js.map +1 -0
  46. package/lib/@types/global.d.js +18 -0
  47. package/lib/@types/global.d.js.map +1 -0
  48. package/lib/@types/local_notifications.d.ts +4 -0
  49. package/lib/@types/local_notifications.d.ts.map +1 -0
  50. package/lib/@types/local_notifications.js +1 -0
  51. package/lib/@types/local_notifications.js.map +1 -0
  52. package/lib/@types/location.d.ts +60 -0
  53. package/lib/@types/location.d.ts.map +1 -0
  54. package/lib/@types/location.js +66 -0
  55. package/lib/@types/location.js.map +1 -0
  56. package/lib/@types/matrix-sdk-crypto-wasm.d.js +1 -0
  57. package/lib/@types/matrix-sdk-crypto-wasm.d.js.map +1 -0
  58. package/lib/@types/media.d.ts +220 -0
  59. package/lib/@types/media.d.ts.map +1 -0
  60. package/lib/@types/media.js +1 -0
  61. package/lib/@types/media.js.map +1 -0
  62. package/lib/@types/membership.d.ts +41 -0
  63. package/lib/@types/membership.d.ts.map +1 -0
  64. package/lib/@types/membership.js +58 -0
  65. package/lib/@types/membership.js.map +1 -0
  66. package/lib/@types/partials.d.ts +72 -0
  67. package/lib/@types/partials.d.ts.map +1 -0
  68. package/lib/@types/partials.js +71 -0
  69. package/lib/@types/partials.js.map +1 -0
  70. package/lib/@types/polls.d.ts +89 -0
  71. package/lib/@types/polls.d.ts.map +1 -0
  72. package/lib/@types/polls.js +86 -0
  73. package/lib/@types/polls.js.map +1 -0
  74. package/lib/@types/read_receipts.d.ts +36 -0
  75. package/lib/@types/read_receipts.d.ts.map +1 -0
  76. package/lib/@types/read_receipts.js +27 -0
  77. package/lib/@types/read_receipts.js.map +1 -0
  78. package/lib/@types/registration.d.ts +85 -0
  79. package/lib/@types/registration.d.ts.map +1 -0
  80. package/lib/@types/registration.js +1 -0
  81. package/lib/@types/registration.js.map +1 -0
  82. package/lib/@types/requests.d.ts +267 -0
  83. package/lib/@types/requests.d.ts.map +1 -0
  84. package/lib/@types/requests.js +42 -0
  85. package/lib/@types/requests.js.map +1 -0
  86. package/lib/@types/search.d.ts +90 -0
  87. package/lib/@types/search.d.ts.map +1 -0
  88. package/lib/@types/search.js +30 -0
  89. package/lib/@types/search.js.map +1 -0
  90. package/lib/@types/signed.d.ts +9 -0
  91. package/lib/@types/signed.d.ts.map +1 -0
  92. package/lib/@types/signed.js +1 -0
  93. package/lib/@types/signed.js.map +1 -0
  94. package/lib/@types/spaces.d.ts +16 -0
  95. package/lib/@types/spaces.d.ts.map +1 -0
  96. package/lib/@types/spaces.js +1 -0
  97. package/lib/@types/spaces.js.map +1 -0
  98. package/lib/@types/state_events.d.ts +121 -0
  99. package/lib/@types/state_events.d.ts.map +1 -0
  100. package/lib/@types/state_events.js +1 -0
  101. package/lib/@types/state_events.js.map +1 -0
  102. package/lib/@types/synapse.d.ts +19 -0
  103. package/lib/@types/synapse.d.ts.map +1 -0
  104. package/lib/@types/synapse.js +1 -0
  105. package/lib/@types/synapse.js.map +1 -0
  106. package/lib/@types/sync.d.ts +8 -0
  107. package/lib/@types/sync.d.ts.map +1 -0
  108. package/lib/@types/sync.js +25 -0
  109. package/lib/@types/sync.js.map +1 -0
  110. package/lib/@types/threepids.d.ts +12 -0
  111. package/lib/@types/threepids.d.ts.map +1 -0
  112. package/lib/@types/threepids.js +24 -0
  113. package/lib/@types/threepids.js.map +1 -0
  114. package/lib/@types/topic.d.ts +55 -0
  115. package/lib/@types/topic.d.ts.map +1 -0
  116. package/lib/@types/topic.js +62 -0
  117. package/lib/@types/topic.js.map +1 -0
  118. package/lib/@types/uia.d.ts +8 -0
  119. package/lib/@types/uia.d.ts.map +1 -0
  120. package/lib/@types/uia.js +1 -0
  121. package/lib/@types/uia.js.map +1 -0
  122. package/lib/NamespacedValue.d.ts +32 -0
  123. package/lib/NamespacedValue.d.ts.map +1 -0
  124. package/lib/NamespacedValue.js +113 -0
  125. package/lib/NamespacedValue.js.map +1 -0
  126. package/lib/ReEmitter.d.ts +15 -0
  127. package/lib/ReEmitter.d.ts.map +1 -0
  128. package/lib/ReEmitter.js +87 -0
  129. package/lib/ReEmitter.js.map +1 -0
  130. package/lib/ToDeviceMessageQueue.d.ts +30 -0
  131. package/lib/ToDeviceMessageQueue.d.ts.map +1 -0
  132. package/lib/ToDeviceMessageQueue.js +135 -0
  133. package/lib/ToDeviceMessageQueue.js.map +1 -0
  134. package/lib/autodiscovery.d.ts +136 -0
  135. package/lib/autodiscovery.d.ts.map +1 -0
  136. package/lib/autodiscovery.js +464 -0
  137. package/lib/autodiscovery.js.map +1 -0
  138. package/lib/base64.d.ts +25 -0
  139. package/lib/base64.d.ts.map +1 -0
  140. package/lib/base64.js +95 -0
  141. package/lib/base64.js.map +1 -0
  142. package/lib/briij.d.ts +116 -0
  143. package/lib/briij.d.ts.map +1 -0
  144. package/lib/briij.js +145 -0
  145. package/lib/briij.js.map +1 -0
  146. package/lib/browser-index.d.ts +8 -0
  147. package/lib/browser-index.d.ts.map +1 -0
  148. package/lib/browser-index.js +35 -0
  149. package/lib/browser-index.js.map +1 -0
  150. package/lib/client.d.ts +3493 -0
  151. package/lib/client.d.ts.map +1 -0
  152. package/lib/client.js +7482 -0
  153. package/lib/client.js.map +1 -0
  154. package/lib/common-crypto/CryptoBackend.d.ts +234 -0
  155. package/lib/common-crypto/CryptoBackend.d.ts.map +1 -0
  156. package/lib/common-crypto/CryptoBackend.js +69 -0
  157. package/lib/common-crypto/CryptoBackend.js.map +1 -0
  158. package/lib/common-crypto/key-passphrase.d.ts +14 -0
  159. package/lib/common-crypto/key-passphrase.d.ts.map +1 -0
  160. package/lib/common-crypto/key-passphrase.js +33 -0
  161. package/lib/common-crypto/key-passphrase.js.map +1 -0
  162. package/lib/content-helpers.d.ts +90 -0
  163. package/lib/content-helpers.d.ts.map +1 -0
  164. package/lib/content-helpers.js +262 -0
  165. package/lib/content-helpers.js.map +1 -0
  166. package/lib/content-repo.d.ts +25 -0
  167. package/lib/content-repo.d.ts.map +1 -0
  168. package/lib/content-repo.js +109 -0
  169. package/lib/content-repo.js.map +1 -0
  170. package/lib/crypto/store/base.d.ts +301 -0
  171. package/lib/crypto/store/base.d.ts.map +1 -0
  172. package/lib/crypto/store/base.js +145 -0
  173. package/lib/crypto/store/base.js.map +1 -0
  174. package/lib/crypto/store/indexeddb-crypto-store-backend.d.ts +94 -0
  175. package/lib/crypto/store/indexeddb-crypto-store-backend.d.ts.map +1 -0
  176. package/lib/crypto/store/indexeddb-crypto-store-backend.js +604 -0
  177. package/lib/crypto/store/indexeddb-crypto-store-backend.js.map +1 -0
  178. package/lib/crypto/store/indexeddb-crypto-store.d.ts +251 -0
  179. package/lib/crypto/store/indexeddb-crypto-store.d.ts.map +1 -0
  180. package/lib/crypto/store/indexeddb-crypto-store.js +477 -0
  181. package/lib/crypto/store/indexeddb-crypto-store.js.map +1 -0
  182. package/lib/crypto/store/localStorage-crypto-store.d.ts +102 -0
  183. package/lib/crypto/store/localStorage-crypto-store.d.ts.map +1 -0
  184. package/lib/crypto/store/localStorage-crypto-store.js +374 -0
  185. package/lib/crypto/store/localStorage-crypto-store.js.map +1 -0
  186. package/lib/crypto/store/memory-crypto-store.d.ts +117 -0
  187. package/lib/crypto/store/memory-crypto-store.d.ts.map +1 -0
  188. package/lib/crypto/store/memory-crypto-store.js +311 -0
  189. package/lib/crypto/store/memory-crypto-store.js.map +1 -0
  190. package/lib/crypto-api/CryptoEvent.d.ts +120 -0
  191. package/lib/crypto-api/CryptoEvent.d.ts.map +1 -0
  192. package/lib/crypto-api/CryptoEvent.js +137 -0
  193. package/lib/crypto-api/CryptoEvent.js.map +1 -0
  194. package/lib/crypto-api/CryptoEventHandlerMap.d.ts +26 -0
  195. package/lib/crypto-api/CryptoEventHandlerMap.d.ts.map +1 -0
  196. package/lib/crypto-api/CryptoEventHandlerMap.js +1 -0
  197. package/lib/crypto-api/CryptoEventHandlerMap.js.map +1 -0
  198. package/lib/crypto-api/index.d.ts +1160 -0
  199. package/lib/crypto-api/index.d.ts.map +1 -0
  200. package/lib/crypto-api/index.js +410 -0
  201. package/lib/crypto-api/index.js.map +1 -0
  202. package/lib/crypto-api/key-passphrase.d.ts +11 -0
  203. package/lib/crypto-api/key-passphrase.d.ts.map +1 -0
  204. package/lib/crypto-api/key-passphrase.js +51 -0
  205. package/lib/crypto-api/key-passphrase.js.map +1 -0
  206. package/lib/crypto-api/keybackup.d.ts +87 -0
  207. package/lib/crypto-api/keybackup.d.ts.map +1 -0
  208. package/lib/crypto-api/keybackup.js +1 -0
  209. package/lib/crypto-api/keybackup.js.map +1 -0
  210. package/lib/crypto-api/recovery-key.d.ts +11 -0
  211. package/lib/crypto-api/recovery-key.d.ts.map +1 -0
  212. package/lib/crypto-api/recovery-key.js +65 -0
  213. package/lib/crypto-api/recovery-key.js.map +1 -0
  214. package/lib/crypto-api/verification.d.ts +315 -0
  215. package/lib/crypto-api/verification.d.ts.map +1 -0
  216. package/lib/crypto-api/verification.js +130 -0
  217. package/lib/crypto-api/verification.js.map +1 -0
  218. package/lib/digest.d.ts +10 -0
  219. package/lib/digest.d.ts.map +1 -0
  220. package/lib/digest.js +40 -0
  221. package/lib/digest.js.map +1 -0
  222. package/lib/embedded.d.ts +182 -0
  223. package/lib/embedded.d.ts.map +1 -0
  224. package/lib/embedded.js +746 -0
  225. package/lib/embedded.js.map +1 -0
  226. package/lib/errors.d.ts +38 -0
  227. package/lib/errors.d.ts.map +1 -0
  228. package/lib/errors.js +73 -0
  229. package/lib/errors.js.map +1 -0
  230. package/lib/event-mapper.d.ts +9 -0
  231. package/lib/event-mapper.d.ts.map +1 -0
  232. package/lib/event-mapper.js +74 -0
  233. package/lib/event-mapper.js.map +1 -0
  234. package/lib/extensible_events_v1/ExtensibleEvent.d.ts +38 -0
  235. package/lib/extensible_events_v1/ExtensibleEvent.d.ts.map +1 -0
  236. package/lib/extensible_events_v1/ExtensibleEvent.js +57 -0
  237. package/lib/extensible_events_v1/ExtensibleEvent.js.map +1 -0
  238. package/lib/extensible_events_v1/InvalidEventError.d.ts +7 -0
  239. package/lib/extensible_events_v1/InvalidEventError.d.ts.map +1 -0
  240. package/lib/extensible_events_v1/InvalidEventError.js +25 -0
  241. package/lib/extensible_events_v1/InvalidEventError.js.map +1 -0
  242. package/lib/extensible_events_v1/MessageEvent.d.ts +44 -0
  243. package/lib/extensible_events_v1/MessageEvent.d.ts.map +1 -0
  244. package/lib/extensible_events_v1/MessageEvent.js +134 -0
  245. package/lib/extensible_events_v1/MessageEvent.js.map +1 -0
  246. package/lib/extensible_events_v1/PollEndEvent.d.ts +33 -0
  247. package/lib/extensible_events_v1/PollEndEvent.d.ts.map +1 -0
  248. package/lib/extensible_events_v1/PollEndEvent.js +88 -0
  249. package/lib/extensible_events_v1/PollEndEvent.js.map +1 -0
  250. package/lib/extensible_events_v1/PollResponseEvent.d.ts +49 -0
  251. package/lib/extensible_events_v1/PollResponseEvent.d.ts.map +1 -0
  252. package/lib/extensible_events_v1/PollResponseEvent.js +135 -0
  253. package/lib/extensible_events_v1/PollResponseEvent.js.map +1 -0
  254. package/lib/extensible_events_v1/PollStartEvent.d.ts +71 -0
  255. package/lib/extensible_events_v1/PollStartEvent.d.ts.map +1 -0
  256. package/lib/extensible_events_v1/PollStartEvent.js +185 -0
  257. package/lib/extensible_events_v1/PollStartEvent.js.map +1 -0
  258. package/lib/extensible_events_v1/utilities.d.ts +14 -0
  259. package/lib/extensible_events_v1/utilities.d.ts.map +1 -0
  260. package/lib/extensible_events_v1/utilities.js +34 -0
  261. package/lib/extensible_events_v1/utilities.js.map +1 -0
  262. package/lib/feature.d.ts +20 -0
  263. package/lib/feature.d.ts.map +1 -0
  264. package/lib/feature.js +89 -0
  265. package/lib/feature.js.map +1 -0
  266. package/lib/filter-component.d.ts +64 -0
  267. package/lib/filter-component.d.ts.map +1 -0
  268. package/lib/filter-component.js +170 -0
  269. package/lib/filter-component.js.map +1 -0
  270. package/lib/filter.d.ts +97 -0
  271. package/lib/filter.d.ts.map +1 -0
  272. package/lib/filter.js +207 -0
  273. package/lib/filter.js.map +1 -0
  274. package/lib/http-api/errors.d.ts +117 -0
  275. package/lib/http-api/errors.d.ts.map +1 -0
  276. package/lib/http-api/errors.js +245 -0
  277. package/lib/http-api/errors.js.map +1 -0
  278. package/lib/http-api/fetch.d.ts +80 -0
  279. package/lib/http-api/fetch.d.ts.map +1 -0
  280. package/lib/http-api/fetch.js +332 -0
  281. package/lib/http-api/fetch.js.map +1 -0
  282. package/lib/http-api/index.d.ts +33 -0
  283. package/lib/http-api/index.d.ts.map +1 -0
  284. package/lib/http-api/index.js +178 -0
  285. package/lib/http-api/index.js.map +1 -0
  286. package/lib/http-api/interface.d.ts +186 -0
  287. package/lib/http-api/interface.d.ts.map +1 -0
  288. package/lib/http-api/interface.js +39 -0
  289. package/lib/http-api/interface.js.map +1 -0
  290. package/lib/http-api/method.d.ts +10 -0
  291. package/lib/http-api/method.d.ts.map +1 -0
  292. package/lib/http-api/method.js +27 -0
  293. package/lib/http-api/method.js.map +1 -0
  294. package/lib/http-api/prefix.d.ts +31 -0
  295. package/lib/http-api/prefix.d.ts.map +1 -0
  296. package/lib/http-api/prefix.js +50 -0
  297. package/lib/http-api/prefix.js.map +1 -0
  298. package/lib/http-api/refresh.d.ts +53 -0
  299. package/lib/http-api/refresh.d.ts.map +1 -0
  300. package/lib/http-api/refresh.js +174 -0
  301. package/lib/http-api/refresh.js.map +1 -0
  302. package/lib/http-api/utils.d.ts +37 -0
  303. package/lib/http-api/utils.d.ts.map +1 -0
  304. package/lib/http-api/utils.js +182 -0
  305. package/lib/http-api/utils.js.map +1 -0
  306. package/lib/index.d.ts +4 -0
  307. package/lib/index.d.ts.map +1 -0
  308. package/lib/index.js +24 -0
  309. package/lib/index.js.map +1 -0
  310. package/lib/indexeddb-helpers.d.ts +10 -0
  311. package/lib/indexeddb-helpers.d.ts.map +1 -0
  312. package/lib/indexeddb-helpers.js +51 -0
  313. package/lib/indexeddb-helpers.js.map +1 -0
  314. package/lib/indexeddb-worker.d.ts +7 -0
  315. package/lib/indexeddb-worker.d.ts.map +1 -0
  316. package/lib/indexeddb-worker.js +25 -0
  317. package/lib/indexeddb-worker.js.map +1 -0
  318. package/lib/interactive-auth.d.ts +341 -0
  319. package/lib/interactive-auth.d.ts.map +1 -0
  320. package/lib/interactive-auth.js +563 -0
  321. package/lib/interactive-auth.js.map +1 -0
  322. package/lib/logger.d.ts +124 -0
  323. package/lib/logger.d.ts.map +1 -0
  324. package/lib/logger.js +230 -0
  325. package/lib/logger.js.map +1 -0
  326. package/lib/matrixrtc/CallMembership.d.ts +154 -0
  327. package/lib/matrixrtc/CallMembership.d.ts.map +1 -0
  328. package/lib/matrixrtc/CallMembership.js +469 -0
  329. package/lib/matrixrtc/CallMembership.js.map +1 -0
  330. package/lib/matrixrtc/EncryptionManager.d.ts +44 -0
  331. package/lib/matrixrtc/EncryptionManager.d.ts.map +1 -0
  332. package/lib/matrixrtc/EncryptionManager.js +13 -0
  333. package/lib/matrixrtc/EncryptionManager.js.map +1 -0
  334. package/lib/matrixrtc/IKeyTransport.d.ts +37 -0
  335. package/lib/matrixrtc/IKeyTransport.d.ts.map +1 -0
  336. package/lib/matrixrtc/IKeyTransport.js +27 -0
  337. package/lib/matrixrtc/IKeyTransport.js.map +1 -0
  338. package/lib/matrixrtc/IMembershipManager.d.ts +94 -0
  339. package/lib/matrixrtc/IMembershipManager.d.ts.map +1 -0
  340. package/lib/matrixrtc/IMembershipManager.js +40 -0
  341. package/lib/matrixrtc/IMembershipManager.js.map +1 -0
  342. package/lib/matrixrtc/LivekitTransport.d.ts +23 -0
  343. package/lib/matrixrtc/LivekitTransport.d.ts.map +1 -0
  344. package/lib/matrixrtc/LivekitTransport.js +29 -0
  345. package/lib/matrixrtc/LivekitTransport.js.map +1 -0
  346. package/lib/matrixrtc/MatrixRTCSession.d.ts +343 -0
  347. package/lib/matrixrtc/MatrixRTCSession.d.ts.map +1 -0
  348. package/lib/matrixrtc/MatrixRTCSession.js +623 -0
  349. package/lib/matrixrtc/MatrixRTCSession.js.map +1 -0
  350. package/lib/matrixrtc/MatrixRTCSessionManager.d.ts +46 -0
  351. package/lib/matrixrtc/MatrixRTCSessionManager.d.ts.map +1 -0
  352. package/lib/matrixrtc/MatrixRTCSessionManager.js +149 -0
  353. package/lib/matrixrtc/MatrixRTCSessionManager.js.map +1 -0
  354. package/lib/matrixrtc/MembershipManager.d.ts +210 -0
  355. package/lib/matrixrtc/MembershipManager.d.ts.map +1 -0
  356. package/lib/matrixrtc/MembershipManager.js +977 -0
  357. package/lib/matrixrtc/MembershipManager.js.map +1 -0
  358. package/lib/matrixrtc/MembershipManagerActionScheduler.d.ts +59 -0
  359. package/lib/matrixrtc/MembershipManagerActionScheduler.d.ts.map +1 -0
  360. package/lib/matrixrtc/MembershipManagerActionScheduler.js +125 -0
  361. package/lib/matrixrtc/MembershipManagerActionScheduler.js.map +1 -0
  362. package/lib/matrixrtc/RTCEncryptionManager.d.ts +110 -0
  363. package/lib/matrixrtc/RTCEncryptionManager.d.ts.map +1 -0
  364. package/lib/matrixrtc/RTCEncryptionManager.js +376 -0
  365. package/lib/matrixrtc/RTCEncryptionManager.js.map +1 -0
  366. package/lib/matrixrtc/ToDeviceKeyTransport.d.ts +30 -0
  367. package/lib/matrixrtc/ToDeviceKeyTransport.d.ts.map +1 -0
  368. package/lib/matrixrtc/ToDeviceKeyTransport.js +164 -0
  369. package/lib/matrixrtc/ToDeviceKeyTransport.js.map +1 -0
  370. package/lib/matrixrtc/index.d.ts +9 -0
  371. package/lib/matrixrtc/index.d.ts.map +1 -0
  372. package/lib/matrixrtc/index.js +23 -0
  373. package/lib/matrixrtc/index.js.map +1 -0
  374. package/lib/matrixrtc/membershipData/common.d.ts +8 -0
  375. package/lib/matrixrtc/membershipData/common.d.ts.map +1 -0
  376. package/lib/matrixrtc/membershipData/common.js +26 -0
  377. package/lib/matrixrtc/membershipData/common.js.map +1 -0
  378. package/lib/matrixrtc/membershipData/index.d.ts +4 -0
  379. package/lib/matrixrtc/membershipData/index.d.ts.map +1 -0
  380. package/lib/matrixrtc/membershipData/index.js +20 -0
  381. package/lib/matrixrtc/membershipData/index.js.map +1 -0
  382. package/lib/matrixrtc/membershipData/rtc.d.ts +33 -0
  383. package/lib/matrixrtc/membershipData/rtc.d.ts.map +1 -0
  384. package/lib/matrixrtc/membershipData/rtc.js +137 -0
  385. package/lib/matrixrtc/membershipData/rtc.js.map +1 -0
  386. package/lib/matrixrtc/membershipData/session.d.ts +77 -0
  387. package/lib/matrixrtc/membershipData/session.d.ts.map +1 -0
  388. package/lib/matrixrtc/membershipData/session.js +62 -0
  389. package/lib/matrixrtc/membershipData/session.js.map +1 -0
  390. package/lib/matrixrtc/types.d.ts +169 -0
  391. package/lib/matrixrtc/types.d.ts.map +1 -0
  392. package/lib/matrixrtc/types.js +117 -0
  393. package/lib/matrixrtc/types.js.map +1 -0
  394. package/lib/matrixrtc/utils.d.ts +27 -0
  395. package/lib/matrixrtc/utils.d.ts.map +1 -0
  396. package/lib/matrixrtc/utils.js +72 -0
  397. package/lib/matrixrtc/utils.js.map +1 -0
  398. package/lib/models/MSC3089Branch.d.ts +98 -0
  399. package/lib/models/MSC3089Branch.d.ts.map +1 -0
  400. package/lib/models/MSC3089Branch.js +240 -0
  401. package/lib/models/MSC3089Branch.js.map +1 -0
  402. package/lib/models/MSC3089TreeSpace.d.ts +166 -0
  403. package/lib/models/MSC3089TreeSpace.d.ts.map +1 -0
  404. package/lib/models/MSC3089TreeSpace.js +521 -0
  405. package/lib/models/MSC3089TreeSpace.js.map +1 -0
  406. package/lib/models/ToDeviceMessage.d.ts +17 -0
  407. package/lib/models/ToDeviceMessage.d.ts.map +1 -0
  408. package/lib/models/ToDeviceMessage.js +1 -0
  409. package/lib/models/ToDeviceMessage.js.map +1 -0
  410. package/lib/models/beacon.d.ts +52 -0
  411. package/lib/models/beacon.d.ts.map +1 -0
  412. package/lib/models/beacon.js +174 -0
  413. package/lib/models/beacon.js.map +1 -0
  414. package/lib/models/compare-event-ordering.d.ts +24 -0
  415. package/lib/models/compare-event-ordering.d.ts.map +1 -0
  416. package/lib/models/compare-event-ordering.js +120 -0
  417. package/lib/models/compare-event-ordering.js.map +1 -0
  418. package/lib/models/device.d.ts +45 -0
  419. package/lib/models/device.d.ts.map +1 -0
  420. package/lib/models/device.js +77 -0
  421. package/lib/models/device.js.map +1 -0
  422. package/lib/models/event-context.d.ts +62 -0
  423. package/lib/models/event-context.d.ts.map +1 -0
  424. package/lib/models/event-context.js +113 -0
  425. package/lib/models/event-context.js.map +1 -0
  426. package/lib/models/event-status.d.ts +19 -0
  427. package/lib/models/event-status.d.ts.map +1 -0
  428. package/lib/models/event-status.js +36 -0
  429. package/lib/models/event-status.js.map +1 -0
  430. package/lib/models/event-timeline-set.d.ts +308 -0
  431. package/lib/models/event-timeline-set.d.ts.map +1 -0
  432. package/lib/models/event-timeline-set.js +805 -0
  433. package/lib/models/event-timeline-set.js.map +1 -0
  434. package/lib/models/event-timeline.d.ts +224 -0
  435. package/lib/models/event-timeline.d.ts.map +1 -0
  436. package/lib/models/event-timeline.js +434 -0
  437. package/lib/models/event-timeline.js.map +1 -0
  438. package/lib/models/event.d.ts +844 -0
  439. package/lib/models/event.d.ts.map +1 -0
  440. package/lib/models/event.js +1600 -0
  441. package/lib/models/event.js.map +1 -0
  442. package/lib/models/invites-ignorer-types.d.ts +27 -0
  443. package/lib/models/invites-ignorer-types.d.ts.map +1 -0
  444. package/lib/models/invites-ignorer-types.js +56 -0
  445. package/lib/models/invites-ignorer-types.js.map +1 -0
  446. package/lib/models/invites-ignorer.d.ts +112 -0
  447. package/lib/models/invites-ignorer.d.ts.map +1 -0
  448. package/lib/models/invites-ignorer.js +357 -0
  449. package/lib/models/invites-ignorer.js.map +1 -0
  450. package/lib/models/poll.d.ts +67 -0
  451. package/lib/models/poll.d.ts.map +1 -0
  452. package/lib/models/poll.js +241 -0
  453. package/lib/models/poll.js.map +1 -0
  454. package/lib/models/profile-keys.d.ts +17 -0
  455. package/lib/models/profile-keys.d.ts.map +1 -0
  456. package/lib/models/profile-keys.js +34 -0
  457. package/lib/models/profile-keys.js.map +1 -0
  458. package/lib/models/read-receipt.d.ts +115 -0
  459. package/lib/models/read-receipt.d.ts.map +1 -0
  460. package/lib/models/read-receipt.js +366 -0
  461. package/lib/models/read-receipt.js.map +1 -0
  462. package/lib/models/related-relations.d.ts +11 -0
  463. package/lib/models/related-relations.d.ts.map +1 -0
  464. package/lib/models/related-relations.js +33 -0
  465. package/lib/models/related-relations.js.map +1 -0
  466. package/lib/models/relations-container.d.ts +44 -0
  467. package/lib/models/relations-container.d.ts.map +1 -0
  468. package/lib/models/relations-container.js +132 -0
  469. package/lib/models/relations-container.js.map +1 -0
  470. package/lib/models/relations.d.ts +123 -0
  471. package/lib/models/relations.d.ts.map +1 -0
  472. package/lib/models/relations.js +378 -0
  473. package/lib/models/relations.js.map +1 -0
  474. package/lib/models/room-member.d.ts +221 -0
  475. package/lib/models/room-member.d.ts.map +1 -0
  476. package/lib/models/room-member.js +376 -0
  477. package/lib/models/room-member.js.map +1 -0
  478. package/lib/models/room-receipts.d.ts +39 -0
  479. package/lib/models/room-receipts.d.ts.map +1 -0
  480. package/lib/models/room-receipts.js +392 -0
  481. package/lib/models/room-receipts.js.map +1 -0
  482. package/lib/models/room-state.d.ts +463 -0
  483. package/lib/models/room-state.d.ts.map +1 -0
  484. package/lib/models/room-state.js +1066 -0
  485. package/lib/models/room-state.js.map +1 -0
  486. package/lib/models/room-sticky-events.d.ts +110 -0
  487. package/lib/models/room-sticky-events.d.ts.map +1 -0
  488. package/lib/models/room-sticky-events.js +353 -0
  489. package/lib/models/room-sticky-events.js.map +1 -0
  490. package/lib/models/room-summary.d.ts +59 -0
  491. package/lib/models/room-summary.d.ts.map +1 -0
  492. package/lib/models/room-summary.js +39 -0
  493. package/lib/models/room-summary.js.map +1 -0
  494. package/lib/models/room.d.ts +1285 -0
  495. package/lib/models/room.d.ts.map +1 -0
  496. package/lib/models/room.js +3548 -0
  497. package/lib/models/room.js.map +1 -0
  498. package/lib/models/search-result.d.ts +20 -0
  499. package/lib/models/search-result.d.ts.map +1 -0
  500. package/lib/models/search-result.js +52 -0
  501. package/lib/models/search-result.js.map +1 -0
  502. package/lib/models/thread.d.ts +245 -0
  503. package/lib/models/thread.d.ts.map +1 -0
  504. package/lib/models/thread.js +866 -0
  505. package/lib/models/thread.js.map +1 -0
  506. package/lib/models/typed-event-emitter.d.ts +157 -0
  507. package/lib/models/typed-event-emitter.d.ts.map +1 -0
  508. package/lib/models/typed-event-emitter.js +227 -0
  509. package/lib/models/typed-event-emitter.js.map +1 -0
  510. package/lib/models/user.d.ts +195 -0
  511. package/lib/models/user.d.ts.map +1 -0
  512. package/lib/models/user.js +218 -0
  513. package/lib/models/user.js.map +1 -0
  514. package/lib/oidc/authorize.d.ts +93 -0
  515. package/lib/oidc/authorize.d.ts.map +1 -0
  516. package/lib/oidc/authorize.js +282 -0
  517. package/lib/oidc/authorize.js.map +1 -0
  518. package/lib/oidc/discovery.d.ts +22 -0
  519. package/lib/oidc/discovery.d.ts.map +1 -0
  520. package/lib/oidc/discovery.js +78 -0
  521. package/lib/oidc/discovery.js.map +1 -0
  522. package/lib/oidc/error.d.ts +18 -0
  523. package/lib/oidc/error.d.ts.map +1 -0
  524. package/lib/oidc/error.js +35 -0
  525. package/lib/oidc/error.js.map +1 -0
  526. package/lib/oidc/index.d.ts +16 -0
  527. package/lib/oidc/index.d.ts.map +1 -0
  528. package/lib/oidc/index.js +29 -0
  529. package/lib/oidc/index.js.map +1 -0
  530. package/lib/oidc/register.d.ts +70 -0
  531. package/lib/oidc/register.d.ts.map +1 -0
  532. package/lib/oidc/register.js +135 -0
  533. package/lib/oidc/register.js.map +1 -0
  534. package/lib/oidc/tokenRefresher.d.ts +91 -0
  535. package/lib/oidc/tokenRefresher.d.ts.map +1 -0
  536. package/lib/oidc/tokenRefresher.js +187 -0
  537. package/lib/oidc/tokenRefresher.js.map +1 -0
  538. package/lib/oidc/validate.d.ts +78 -0
  539. package/lib/oidc/validate.d.ts.map +1 -0
  540. package/lib/oidc/validate.js +181 -0
  541. package/lib/oidc/validate.js.map +1 -0
  542. package/lib/pushprocessor.d.ts +140 -0
  543. package/lib/pushprocessor.d.ts.map +1 -0
  544. package/lib/pushprocessor.js +702 -0
  545. package/lib/pushprocessor.js.map +1 -0
  546. package/lib/randomstring.d.ts +32 -0
  547. package/lib/randomstring.d.ts.map +1 -0
  548. package/lib/randomstring.js +97 -0
  549. package/lib/randomstring.js.map +1 -0
  550. package/lib/realtime-callbacks.d.ts +18 -0
  551. package/lib/realtime-callbacks.d.ts.map +1 -0
  552. package/lib/realtime-callbacks.js +177 -0
  553. package/lib/realtime-callbacks.js.map +1 -0
  554. package/lib/receipt-accumulator.d.ts +51 -0
  555. package/lib/receipt-accumulator.d.ts.map +1 -0
  556. package/lib/receipt-accumulator.js +164 -0
  557. package/lib/receipt-accumulator.js.map +1 -0
  558. package/lib/rendezvous/MSC4108SignInWithQR.d.ts +112 -0
  559. package/lib/rendezvous/MSC4108SignInWithQR.d.ts.map +1 -0
  560. package/lib/rendezvous/MSC4108SignInWithQR.js +389 -0
  561. package/lib/rendezvous/MSC4108SignInWithQR.js.map +1 -0
  562. package/lib/rendezvous/RendezvousChannel.d.ts +27 -0
  563. package/lib/rendezvous/RendezvousChannel.d.ts.map +1 -0
  564. package/lib/rendezvous/RendezvousChannel.js +1 -0
  565. package/lib/rendezvous/RendezvousChannel.js.map +1 -0
  566. package/lib/rendezvous/RendezvousCode.d.ts +9 -0
  567. package/lib/rendezvous/RendezvousCode.d.ts.map +1 -0
  568. package/lib/rendezvous/RendezvousCode.js +1 -0
  569. package/lib/rendezvous/RendezvousCode.js.map +1 -0
  570. package/lib/rendezvous/RendezvousError.d.ts +6 -0
  571. package/lib/rendezvous/RendezvousError.d.ts.map +1 -0
  572. package/lib/rendezvous/RendezvousError.js +23 -0
  573. package/lib/rendezvous/RendezvousError.js.map +1 -0
  574. package/lib/rendezvous/RendezvousFailureReason.d.ts +31 -0
  575. package/lib/rendezvous/RendezvousFailureReason.d.ts.map +1 -0
  576. package/lib/rendezvous/RendezvousFailureReason.js +47 -0
  577. package/lib/rendezvous/RendezvousFailureReason.js.map +1 -0
  578. package/lib/rendezvous/RendezvousIntent.d.ts +5 -0
  579. package/lib/rendezvous/RendezvousIntent.d.ts.map +1 -0
  580. package/lib/rendezvous/RendezvousIntent.js +22 -0
  581. package/lib/rendezvous/RendezvousIntent.js.map +1 -0
  582. package/lib/rendezvous/RendezvousTransport.d.ts +36 -0
  583. package/lib/rendezvous/RendezvousTransport.d.ts.map +1 -0
  584. package/lib/rendezvous/RendezvousTransport.js +1 -0
  585. package/lib/rendezvous/RendezvousTransport.js.map +1 -0
  586. package/lib/rendezvous/channels/MSC4108SecureChannel.d.ts +58 -0
  587. package/lib/rendezvous/channels/MSC4108SecureChannel.d.ts.map +1 -0
  588. package/lib/rendezvous/channels/MSC4108SecureChannel.js +246 -0
  589. package/lib/rendezvous/channels/MSC4108SecureChannel.js.map +1 -0
  590. package/lib/rendezvous/channels/index.d.ts +2 -0
  591. package/lib/rendezvous/channels/index.d.ts.map +1 -0
  592. package/lib/rendezvous/channels/index.js +18 -0
  593. package/lib/rendezvous/channels/index.js.map +1 -0
  594. package/lib/rendezvous/index.d.ts +10 -0
  595. package/lib/rendezvous/index.d.ts.map +1 -0
  596. package/lib/rendezvous/index.js +23 -0
  597. package/lib/rendezvous/index.js.map +1 -0
  598. package/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts +61 -0
  599. package/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts.map +1 -0
  600. package/lib/rendezvous/transports/MSC4108RendezvousSession.js +254 -0
  601. package/lib/rendezvous/transports/MSC4108RendezvousSession.js.map +1 -0
  602. package/lib/rendezvous/transports/index.d.ts +2 -0
  603. package/lib/rendezvous/transports/index.d.ts.map +1 -0
  604. package/lib/rendezvous/transports/index.js +18 -0
  605. package/lib/rendezvous/transports/index.js.map +1 -0
  606. package/lib/room-hierarchy.d.ts +35 -0
  607. package/lib/room-hierarchy.d.ts.map +1 -0
  608. package/lib/room-hierarchy.js +136 -0
  609. package/lib/room-hierarchy.js.map +1 -0
  610. package/lib/rust-crypto/CrossSigningIdentity.d.ts +35 -0
  611. package/lib/rust-crypto/CrossSigningIdentity.d.ts.map +1 -0
  612. package/lib/rust-crypto/CrossSigningIdentity.js +163 -0
  613. package/lib/rust-crypto/CrossSigningIdentity.js.map +1 -0
  614. package/lib/rust-crypto/DehydratedDeviceManager.d.ts +118 -0
  615. package/lib/rust-crypto/DehydratedDeviceManager.d.ts.map +1 -0
  616. package/lib/rust-crypto/DehydratedDeviceManager.js +361 -0
  617. package/lib/rust-crypto/DehydratedDeviceManager.js.map +1 -0
  618. package/lib/rust-crypto/KeyClaimManager.d.ts +33 -0
  619. package/lib/rust-crypto/KeyClaimManager.d.ts.map +1 -0
  620. package/lib/rust-crypto/KeyClaimManager.js +82 -0
  621. package/lib/rust-crypto/KeyClaimManager.js.map +1 -0
  622. package/lib/rust-crypto/OutgoingRequestProcessor.d.ts +36 -0
  623. package/lib/rust-crypto/OutgoingRequestProcessor.d.ts.map +1 -0
  624. package/lib/rust-crypto/OutgoingRequestProcessor.js +194 -0
  625. package/lib/rust-crypto/OutgoingRequestProcessor.js.map +1 -0
  626. package/lib/rust-crypto/OutgoingRequestsManager.d.ts +47 -0
  627. package/lib/rust-crypto/OutgoingRequestsManager.d.ts.map +1 -0
  628. package/lib/rust-crypto/OutgoingRequestsManager.js +175 -0
  629. package/lib/rust-crypto/OutgoingRequestsManager.js.map +1 -0
  630. package/lib/rust-crypto/PerSessionKeyBackupDownloader.d.ts +120 -0
  631. package/lib/rust-crypto/PerSessionKeyBackupDownloader.d.ts.map +1 -0
  632. package/lib/rust-crypto/PerSessionKeyBackupDownloader.js +469 -0
  633. package/lib/rust-crypto/PerSessionKeyBackupDownloader.js.map +1 -0
  634. package/lib/rust-crypto/RoomEncryptor.d.ts +100 -0
  635. package/lib/rust-crypto/RoomEncryptor.d.ts.map +1 -0
  636. package/lib/rust-crypto/RoomEncryptor.js +308 -0
  637. package/lib/rust-crypto/RoomEncryptor.js.map +1 -0
  638. package/lib/rust-crypto/backup.d.ts +278 -0
  639. package/lib/rust-crypto/backup.d.ts.map +1 -0
  640. package/lib/rust-crypto/backup.js +898 -0
  641. package/lib/rust-crypto/backup.js.map +1 -0
  642. package/lib/rust-crypto/constants.d.ts +3 -0
  643. package/lib/rust-crypto/constants.d.ts.map +1 -0
  644. package/lib/rust-crypto/constants.js +19 -0
  645. package/lib/rust-crypto/constants.js.map +1 -0
  646. package/lib/rust-crypto/device-converter.d.ts +28 -0
  647. package/lib/rust-crypto/device-converter.d.ts.map +1 -0
  648. package/lib/rust-crypto/device-converter.js +123 -0
  649. package/lib/rust-crypto/device-converter.js.map +1 -0
  650. package/lib/rust-crypto/index.d.ts +65 -0
  651. package/lib/rust-crypto/index.d.ts.map +1 -0
  652. package/lib/rust-crypto/index.js +149 -0
  653. package/lib/rust-crypto/index.js.map +1 -0
  654. package/lib/rust-crypto/libolm_migration.d.ts +81 -0
  655. package/lib/rust-crypto/libolm_migration.d.ts.map +1 -0
  656. package/lib/rust-crypto/libolm_migration.js +456 -0
  657. package/lib/rust-crypto/libolm_migration.js.map +1 -0
  658. package/lib/rust-crypto/rust-crypto.d.ts +576 -0
  659. package/lib/rust-crypto/rust-crypto.d.ts.map +1 -0
  660. package/lib/rust-crypto/rust-crypto.js +2324 -0
  661. package/lib/rust-crypto/rust-crypto.js.map +1 -0
  662. package/lib/rust-crypto/secret-storage.d.ts +22 -0
  663. package/lib/rust-crypto/secret-storage.d.ts.map +1 -0
  664. package/lib/rust-crypto/secret-storage.js +63 -0
  665. package/lib/rust-crypto/secret-storage.js.map +1 -0
  666. package/lib/rust-crypto/verification.d.ts +321 -0
  667. package/lib/rust-crypto/verification.d.ts.map +1 -0
  668. package/lib/rust-crypto/verification.js +817 -0
  669. package/lib/rust-crypto/verification.js.map +1 -0
  670. package/lib/scheduler.d.ts +132 -0
  671. package/lib/scheduler.d.ts.map +1 -0
  672. package/lib/scheduler.js +259 -0
  673. package/lib/scheduler.js.map +1 -0
  674. package/lib/secret-storage.d.ts +383 -0
  675. package/lib/secret-storage.d.ts.map +1 -0
  676. package/lib/secret-storage.js +487 -0
  677. package/lib/secret-storage.js.map +1 -0
  678. package/lib/serverCapabilities.d.ts +78 -0
  679. package/lib/serverCapabilities.d.ts.map +1 -0
  680. package/lib/serverCapabilities.js +104 -0
  681. package/lib/serverCapabilities.js.map +1 -0
  682. package/lib/service-types.d.ts +5 -0
  683. package/lib/service-types.d.ts.map +1 -0
  684. package/lib/service-types.js +23 -0
  685. package/lib/service-types.js.map +1 -0
  686. package/lib/sliding-sync-sdk.d.ts +107 -0
  687. package/lib/sliding-sync-sdk.d.ts.map +1 -0
  688. package/lib/sliding-sync-sdk.js +892 -0
  689. package/lib/sliding-sync-sdk.js.map +1 -0
  690. package/lib/sliding-sync.d.ts +306 -0
  691. package/lib/sliding-sync.d.ts.map +1 -0
  692. package/lib/sliding-sync.js +585 -0
  693. package/lib/sliding-sync.js.map +1 -0
  694. package/lib/store/index.d.ts +201 -0
  695. package/lib/store/index.d.ts.map +1 -0
  696. package/lib/store/index.js +1 -0
  697. package/lib/store/index.js.map +1 -0
  698. package/lib/store/indexeddb-backend.d.ts +24 -0
  699. package/lib/store/indexeddb-backend.d.ts.map +1 -0
  700. package/lib/store/indexeddb-backend.js +1 -0
  701. package/lib/store/indexeddb-backend.js.map +1 -0
  702. package/lib/store/indexeddb-local-backend.d.ts +129 -0
  703. package/lib/store/indexeddb-local-backend.d.ts.map +1 -0
  704. package/lib/store/indexeddb-local-backend.js +599 -0
  705. package/lib/store/indexeddb-local-backend.js.map +1 -0
  706. package/lib/store/indexeddb-remote-backend.d.ts +79 -0
  707. package/lib/store/indexeddb-remote-backend.d.ts.map +1 -0
  708. package/lib/store/indexeddb-remote-backend.js +209 -0
  709. package/lib/store/indexeddb-remote-backend.js.map +1 -0
  710. package/lib/store/indexeddb-store-worker.d.ts +35 -0
  711. package/lib/store/indexeddb-store-worker.d.ts.map +1 -0
  712. package/lib/store/indexeddb-store-worker.js +146 -0
  713. package/lib/store/indexeddb-store-worker.js.map +1 -0
  714. package/lib/store/indexeddb.d.ts +142 -0
  715. package/lib/store/indexeddb.d.ts.map +1 -0
  716. package/lib/store/indexeddb.js +347 -0
  717. package/lib/store/indexeddb.js.map +1 -0
  718. package/lib/store/local-storage-events-emitter.d.ts +30 -0
  719. package/lib/store/local-storage-events-emitter.d.ts.map +1 -0
  720. package/lib/store/local-storage-events-emitter.js +37 -0
  721. package/lib/store/local-storage-events-emitter.js.map +1 -0
  722. package/lib/store/memory.d.ts +209 -0
  723. package/lib/store/memory.d.ts.map +1 -0
  724. package/lib/store/memory.js +432 -0
  725. package/lib/store/memory.js.map +1 -0
  726. package/lib/store/stub.d.ts +161 -0
  727. package/lib/store/stub.d.ts.map +1 -0
  728. package/lib/store/stub.js +268 -0
  729. package/lib/store/stub.js.map +1 -0
  730. package/lib/sync-accumulator.d.ts +207 -0
  731. package/lib/sync-accumulator.d.ts.map +1 -0
  732. package/lib/sync-accumulator.js +588 -0
  733. package/lib/sync-accumulator.js.map +1 -0
  734. package/lib/sync.d.ts +273 -0
  735. package/lib/sync.d.ts.map +1 -0
  736. package/lib/sync.js +1764 -0
  737. package/lib/sync.js.map +1 -0
  738. package/lib/testing.d.ts +98 -0
  739. package/lib/testing.d.ts.map +1 -0
  740. package/lib/testing.js +205 -0
  741. package/lib/testing.js.map +1 -0
  742. package/lib/thread-utils.d.ts +10 -0
  743. package/lib/thread-utils.d.ts.map +1 -0
  744. package/lib/thread-utils.js +31 -0
  745. package/lib/thread-utils.js.map +1 -0
  746. package/lib/timeline-window.d.ts +168 -0
  747. package/lib/timeline-window.d.ts.map +1 -0
  748. package/lib/timeline-window.js +494 -0
  749. package/lib/timeline-window.js.map +1 -0
  750. package/lib/types.d.ts +33 -0
  751. package/lib/types.d.ts.map +1 -0
  752. package/lib/types.js +52 -0
  753. package/lib/types.js.map +1 -0
  754. package/lib/utils/decryptAESSecretStorageItem.d.ts +12 -0
  755. package/lib/utils/decryptAESSecretStorageItem.d.ts.map +1 -0
  756. package/lib/utils/decryptAESSecretStorageItem.js +50 -0
  757. package/lib/utils/decryptAESSecretStorageItem.js.map +1 -0
  758. package/lib/utils/encryptAESSecretStorageItem.d.ts +16 -0
  759. package/lib/utils/encryptAESSecretStorageItem.d.ts.map +1 -0
  760. package/lib/utils/encryptAESSecretStorageItem.js +68 -0
  761. package/lib/utils/encryptAESSecretStorageItem.js.map +1 -0
  762. package/lib/utils/internal/deriveKeys.d.ts +10 -0
  763. package/lib/utils/internal/deriveKeys.d.ts.map +1 -0
  764. package/lib/utils/internal/deriveKeys.js +60 -0
  765. package/lib/utils/internal/deriveKeys.js.map +1 -0
  766. package/lib/utils/roomVersion.d.ts +13 -0
  767. package/lib/utils/roomVersion.d.ts.map +1 -0
  768. package/lib/utils/roomVersion.js +36 -0
  769. package/lib/utils/roomVersion.js.map +1 -0
  770. package/lib/utils.d.ts +270 -0
  771. package/lib/utils.d.ts.map +1 -0
  772. package/lib/utils.js +764 -0
  773. package/lib/utils.js.map +1 -0
  774. package/lib/version-support.d.ts +19 -0
  775. package/lib/version-support.d.ts.map +1 -0
  776. package/lib/version-support.js +37 -0
  777. package/lib/version-support.js.map +1 -0
  778. package/lib/webrtc/audioContext.d.ts +15 -0
  779. package/lib/webrtc/audioContext.d.ts.map +1 -0
  780. package/lib/webrtc/audioContext.js +46 -0
  781. package/lib/webrtc/audioContext.js.map +1 -0
  782. package/lib/webrtc/call.d.ts +560 -0
  783. package/lib/webrtc/call.d.ts.map +1 -0
  784. package/lib/webrtc/call.js +2596 -0
  785. package/lib/webrtc/call.js.map +1 -0
  786. package/lib/webrtc/callEventHandler.d.ts +37 -0
  787. package/lib/webrtc/callEventHandler.d.ts.map +1 -0
  788. package/lib/webrtc/callEventHandler.js +344 -0
  789. package/lib/webrtc/callEventHandler.js.map +1 -0
  790. package/lib/webrtc/callEventTypes.d.ts +79 -0
  791. package/lib/webrtc/callEventTypes.d.ts.map +1 -0
  792. package/lib/webrtc/callEventTypes.js +13 -0
  793. package/lib/webrtc/callEventTypes.js.map +1 -0
  794. package/lib/webrtc/callFeed.d.ts +128 -0
  795. package/lib/webrtc/callFeed.d.ts.map +1 -0
  796. package/lib/webrtc/callFeed.js +289 -0
  797. package/lib/webrtc/callFeed.js.map +1 -0
  798. package/lib/webrtc/groupCall.d.ts +319 -0
  799. package/lib/webrtc/groupCall.d.ts.map +1 -0
  800. package/lib/webrtc/groupCall.js +1334 -0
  801. package/lib/webrtc/groupCall.js.map +1 -0
  802. package/lib/webrtc/groupCallEventHandler.d.ts +31 -0
  803. package/lib/webrtc/groupCallEventHandler.d.ts.map +1 -0
  804. package/lib/webrtc/groupCallEventHandler.js +178 -0
  805. package/lib/webrtc/groupCallEventHandler.js.map +1 -0
  806. package/lib/webrtc/mediaHandler.d.ts +89 -0
  807. package/lib/webrtc/mediaHandler.d.ts.map +1 -0
  808. package/lib/webrtc/mediaHandler.js +454 -0
  809. package/lib/webrtc/mediaHandler.js.map +1 -0
  810. package/lib/webrtc/stats/callFeedStatsReporter.d.ts +8 -0
  811. package/lib/webrtc/stats/callFeedStatsReporter.d.ts.map +1 -0
  812. package/lib/webrtc/stats/callFeedStatsReporter.js +79 -0
  813. package/lib/webrtc/stats/callFeedStatsReporter.js.map +1 -0
  814. package/lib/webrtc/stats/callStatsReportGatherer.d.ts +25 -0
  815. package/lib/webrtc/stats/callStatsReportGatherer.d.ts.map +1 -0
  816. package/lib/webrtc/stats/callStatsReportGatherer.js +199 -0
  817. package/lib/webrtc/stats/callStatsReportGatherer.js.map +1 -0
  818. package/lib/webrtc/stats/callStatsReportSummary.d.ts +17 -0
  819. package/lib/webrtc/stats/callStatsReportSummary.d.ts.map +1 -0
  820. package/lib/webrtc/stats/callStatsReportSummary.js +1 -0
  821. package/lib/webrtc/stats/callStatsReportSummary.js.map +1 -0
  822. package/lib/webrtc/stats/connectionStats.d.ts +28 -0
  823. package/lib/webrtc/stats/connectionStats.d.ts.map +1 -0
  824. package/lib/webrtc/stats/connectionStats.js +26 -0
  825. package/lib/webrtc/stats/connectionStats.js.map +1 -0
  826. package/lib/webrtc/stats/connectionStatsBuilder.d.ts +5 -0
  827. package/lib/webrtc/stats/connectionStatsBuilder.d.ts.map +1 -0
  828. package/lib/webrtc/stats/connectionStatsBuilder.js +27 -0
  829. package/lib/webrtc/stats/connectionStatsBuilder.js.map +1 -0
  830. package/lib/webrtc/stats/connectionStatsReportBuilder.d.ts +7 -0
  831. package/lib/webrtc/stats/connectionStatsReportBuilder.d.ts.map +1 -0
  832. package/lib/webrtc/stats/connectionStatsReportBuilder.js +121 -0
  833. package/lib/webrtc/stats/connectionStatsReportBuilder.js.map +1 -0
  834. package/lib/webrtc/stats/groupCallStats.d.ts +22 -0
  835. package/lib/webrtc/stats/groupCallStats.d.ts.map +1 -0
  836. package/lib/webrtc/stats/groupCallStats.js +78 -0
  837. package/lib/webrtc/stats/groupCallStats.js.map +1 -0
  838. package/lib/webrtc/stats/media/mediaSsrcHandler.d.ts +10 -0
  839. package/lib/webrtc/stats/media/mediaSsrcHandler.d.ts.map +1 -0
  840. package/lib/webrtc/stats/media/mediaSsrcHandler.js +57 -0
  841. package/lib/webrtc/stats/media/mediaSsrcHandler.js.map +1 -0
  842. package/lib/webrtc/stats/media/mediaTrackHandler.d.ts +12 -0
  843. package/lib/webrtc/stats/media/mediaTrackHandler.d.ts.map +1 -0
  844. package/lib/webrtc/stats/media/mediaTrackHandler.js +58 -0
  845. package/lib/webrtc/stats/media/mediaTrackHandler.js.map +1 -0
  846. package/lib/webrtc/stats/media/mediaTrackStats.d.ts +86 -0
  847. package/lib/webrtc/stats/media/mediaTrackStats.d.ts.map +1 -0
  848. package/lib/webrtc/stats/media/mediaTrackStats.js +142 -0
  849. package/lib/webrtc/stats/media/mediaTrackStats.js.map +1 -0
  850. package/lib/webrtc/stats/media/mediaTrackStatsHandler.d.ts +22 -0
  851. package/lib/webrtc/stats/media/mediaTrackStatsHandler.d.ts.map +1 -0
  852. package/lib/webrtc/stats/media/mediaTrackStatsHandler.js +76 -0
  853. package/lib/webrtc/stats/media/mediaTrackStatsHandler.js.map +1 -0
  854. package/lib/webrtc/stats/statsReport.d.ts +99 -0
  855. package/lib/webrtc/stats/statsReport.d.ts.map +1 -0
  856. package/lib/webrtc/stats/statsReport.js +32 -0
  857. package/lib/webrtc/stats/statsReport.js.map +1 -0
  858. package/lib/webrtc/stats/statsReportEmitter.d.ts +15 -0
  859. package/lib/webrtc/stats/statsReportEmitter.d.ts.map +1 -0
  860. package/lib/webrtc/stats/statsReportEmitter.js +33 -0
  861. package/lib/webrtc/stats/statsReportEmitter.js.map +1 -0
  862. package/lib/webrtc/stats/summaryStatsReportGatherer.d.ts +16 -0
  863. package/lib/webrtc/stats/summaryStatsReportGatherer.d.ts.map +1 -0
  864. package/lib/webrtc/stats/summaryStatsReportGatherer.js +116 -0
  865. package/lib/webrtc/stats/summaryStatsReportGatherer.js.map +1 -0
  866. package/lib/webrtc/stats/trackStatsBuilder.d.ts +19 -0
  867. package/lib/webrtc/stats/trackStatsBuilder.d.ts.map +1 -0
  868. package/lib/webrtc/stats/trackStatsBuilder.js +168 -0
  869. package/lib/webrtc/stats/trackStatsBuilder.js.map +1 -0
  870. package/lib/webrtc/stats/transportStats.d.ts +11 -0
  871. package/lib/webrtc/stats/transportStats.d.ts.map +1 -0
  872. package/lib/webrtc/stats/transportStats.js +1 -0
  873. package/lib/webrtc/stats/transportStats.js.map +1 -0
  874. package/lib/webrtc/stats/transportStatsBuilder.d.ts +5 -0
  875. package/lib/webrtc/stats/transportStatsBuilder.d.ts.map +1 -0
  876. package/lib/webrtc/stats/transportStatsBuilder.js +34 -0
  877. package/lib/webrtc/stats/transportStatsBuilder.js.map +1 -0
  878. package/lib/webrtc/stats/valueFormatter.d.ts +4 -0
  879. package/lib/webrtc/stats/valueFormatter.d.ts.map +1 -0
  880. package/lib/webrtc/stats/valueFormatter.js +25 -0
  881. package/lib/webrtc/stats/valueFormatter.js.map +1 -0
  882. package/package.json +129 -0
  883. package/src/@types/AESEncryptedSecretStoragePayload.ts +29 -0
  884. package/src/@types/IIdentityServerProvider.ts +24 -0
  885. package/src/@types/PushRules.ts +208 -0
  886. package/src/@types/another-json.d.ts +19 -0
  887. package/src/@types/auth.ts +258 -0
  888. package/src/@types/beacon.ts +140 -0
  889. package/src/@types/common.ts +24 -0
  890. package/src/@types/crypto.ts +71 -0
  891. package/src/@types/event.ts +449 -0
  892. package/src/@types/events.ts +119 -0
  893. package/src/@types/extensible_events.ts +147 -0
  894. package/src/@types/global.d.ts +67 -0
  895. package/src/@types/local_notifications.ts +19 -0
  896. package/src/@types/location.ts +92 -0
  897. package/src/@types/matrix-sdk-crypto-wasm.d.ts +39 -0
  898. package/src/@types/media.ts +245 -0
  899. package/src/@types/membership.ts +57 -0
  900. package/src/@types/partials.ts +103 -0
  901. package/src/@types/polls.ts +120 -0
  902. package/src/@types/read_receipts.ts +61 -0
  903. package/src/@types/registration.ts +102 -0
  904. package/src/@types/requests.ts +346 -0
  905. package/src/@types/search.ts +119 -0
  906. package/src/@types/signed.ts +25 -0
  907. package/src/@types/spaces.ts +37 -0
  908. package/src/@types/state_events.ts +153 -0
  909. package/src/@types/synapse.ts +40 -0
  910. package/src/@types/sync.ts +27 -0
  911. package/src/@types/threepids.ts +29 -0
  912. package/src/@types/topic.ts +69 -0
  913. package/src/@types/uia.ts +24 -0
  914. package/src/NamespacedValue.ts +121 -0
  915. package/src/ReEmitter.ts +93 -0
  916. package/src/ToDeviceMessageQueue.ts +156 -0
  917. package/src/autodiscovery.ts +505 -0
  918. package/src/base64.ts +86 -0
  919. package/src/briij.ts +173 -0
  920. package/src/browser-index.ts +44 -0
  921. package/src/client.ts +9031 -0
  922. package/src/common-crypto/CryptoBackend.ts +295 -0
  923. package/src/common-crypto/README.md +4 -0
  924. package/src/common-crypto/key-passphrase.ts +43 -0
  925. package/src/content-helpers.ts +298 -0
  926. package/src/content-repo.ts +122 -0
  927. package/src/crypto/store/base.ts +388 -0
  928. package/src/crypto/store/indexeddb-crypto-store-backend.ts +655 -0
  929. package/src/crypto/store/indexeddb-crypto-store.ts +555 -0
  930. package/src/crypto/store/localStorage-crypto-store.ts +409 -0
  931. package/src/crypto/store/memory-crypto-store.ts +326 -0
  932. package/src/crypto-api/CryptoEvent.ts +152 -0
  933. package/src/crypto-api/CryptoEventHandlerMap.ts +42 -0
  934. package/src/crypto-api/index.ts +1362 -0
  935. package/src/crypto-api/key-passphrase.ts +58 -0
  936. package/src/crypto-api/keybackup.ts +114 -0
  937. package/src/crypto-api/recovery-key.ts +69 -0
  938. package/src/crypto-api/verification.ts +382 -0
  939. package/src/digest.ts +34 -0
  940. package/src/embedded.ts +865 -0
  941. package/src/errors.ts +87 -0
  942. package/src/event-mapper.ts +88 -0
  943. package/src/extensible_events_v1/ExtensibleEvent.ts +58 -0
  944. package/src/extensible_events_v1/InvalidEventError.ts +24 -0
  945. package/src/extensible_events_v1/MessageEvent.ts +143 -0
  946. package/src/extensible_events_v1/PollEndEvent.ts +97 -0
  947. package/src/extensible_events_v1/PollResponseEvent.ts +148 -0
  948. package/src/extensible_events_v1/PollStartEvent.ts +207 -0
  949. package/src/extensible_events_v1/utilities.ts +35 -0
  950. package/src/feature.ts +88 -0
  951. package/src/filter-component.ts +209 -0
  952. package/src/filter.ts +245 -0
  953. package/src/http-api/errors.ts +261 -0
  954. package/src/http-api/fetch.ts +377 -0
  955. package/src/http-api/index.ts +194 -0
  956. package/src/http-api/interface.ts +229 -0
  957. package/src/http-api/method.ts +25 -0
  958. package/src/http-api/prefix.ts +48 -0
  959. package/src/http-api/refresh.ts +167 -0
  960. package/src/http-api/utils.ts +217 -0
  961. package/src/index.ts +25 -0
  962. package/src/indexeddb-helpers.ts +50 -0
  963. package/src/indexeddb-worker.ts +24 -0
  964. package/src/interactive-auth.ts +700 -0
  965. package/src/logger.ts +279 -0
  966. package/src/matrixrtc/CallMembership.ts +438 -0
  967. package/src/matrixrtc/EncryptionManager.ts +54 -0
  968. package/src/matrixrtc/IKeyTransport.ts +63 -0
  969. package/src/matrixrtc/IMembershipManager.ts +120 -0
  970. package/src/matrixrtc/LivekitTransport.ts +46 -0
  971. package/src/matrixrtc/MatrixRTCSession.ts +934 -0
  972. package/src/matrixrtc/MatrixRTCSessionManager.ts +170 -0
  973. package/src/matrixrtc/MembershipManager.ts +1122 -0
  974. package/src/matrixrtc/MembershipManagerActionScheduler.ts +135 -0
  975. package/src/matrixrtc/RTCEncryptionManager.ts +459 -0
  976. package/src/matrixrtc/ToDeviceKeyTransport.ts +197 -0
  977. package/src/matrixrtc/index.ts +24 -0
  978. package/src/matrixrtc/membershipData/common.ts +27 -0
  979. package/src/matrixrtc/membershipData/index.ts +19 -0
  980. package/src/matrixrtc/membershipData/rtc.ts +156 -0
  981. package/src/matrixrtc/membershipData/session.ts +146 -0
  982. package/src/matrixrtc/types.ts +227 -0
  983. package/src/matrixrtc/utils.ts +71 -0
  984. package/src/models/MSC3089Branch.ts +272 -0
  985. package/src/models/MSC3089TreeSpace.ts +565 -0
  986. package/src/models/ToDeviceMessage.ts +38 -0
  987. package/src/models/beacon.ts +213 -0
  988. package/src/models/compare-event-ordering.ts +139 -0
  989. package/src/models/device.ts +85 -0
  990. package/src/models/event-context.ts +110 -0
  991. package/src/models/event-status.ts +39 -0
  992. package/src/models/event-timeline-set.ts +962 -0
  993. package/src/models/event-timeline.ts +461 -0
  994. package/src/models/event.ts +1819 -0
  995. package/src/models/invites-ignorer-types.ts +58 -0
  996. package/src/models/invites-ignorer.ts +341 -0
  997. package/src/models/poll.ts +285 -0
  998. package/src/models/profile-keys.ts +33 -0
  999. package/src/models/read-receipt.ts +422 -0
  1000. package/src/models/related-relations.ts +39 -0
  1001. package/src/models/relations-container.ts +149 -0
  1002. package/src/models/relations.ts +392 -0
  1003. package/src/models/room-member.ts +486 -0
  1004. package/src/models/room-receipts.ts +439 -0
  1005. package/src/models/room-state.ts +1230 -0
  1006. package/src/models/room-sticky-events.ts +383 -0
  1007. package/src/models/room-summary.ts +78 -0
  1008. package/src/models/room.ts +4067 -0
  1009. package/src/models/search-result.ts +57 -0
  1010. package/src/models/thread.ts +928 -0
  1011. package/src/models/typed-event-emitter.ts +246 -0
  1012. package/src/models/user.ts +302 -0
  1013. package/src/oidc/authorize.ts +279 -0
  1014. package/src/oidc/discovery.ts +67 -0
  1015. package/src/oidc/error.ts +33 -0
  1016. package/src/oidc/index.ts +33 -0
  1017. package/src/oidc/register.ts +163 -0
  1018. package/src/oidc/tokenRefresher.ts +184 -0
  1019. package/src/oidc/validate.ts +265 -0
  1020. package/src/pushprocessor.ts +856 -0
  1021. package/src/randomstring.ts +103 -0
  1022. package/src/realtime-callbacks.ts +191 -0
  1023. package/src/receipt-accumulator.ts +189 -0
  1024. package/src/rendezvous/MSC4108SignInWithQR.ts +443 -0
  1025. package/src/rendezvous/RendezvousChannel.ts +48 -0
  1026. package/src/rendezvous/RendezvousCode.ts +25 -0
  1027. package/src/rendezvous/RendezvousError.ts +26 -0
  1028. package/src/rendezvous/RendezvousFailureReason.ts +49 -0
  1029. package/src/rendezvous/RendezvousIntent.ts +20 -0
  1030. package/src/rendezvous/RendezvousTransport.ts +58 -0
  1031. package/src/rendezvous/channels/MSC4108SecureChannel.ts +270 -0
  1032. package/src/rendezvous/channels/index.ts +17 -0
  1033. package/src/rendezvous/index.ts +25 -0
  1034. package/src/rendezvous/transports/MSC4108RendezvousSession.ts +272 -0
  1035. package/src/rendezvous/transports/index.ts +17 -0
  1036. package/src/room-hierarchy.ts +152 -0
  1037. package/src/rust-crypto/CrossSigningIdentity.ts +195 -0
  1038. package/src/rust-crypto/DehydratedDeviceManager.ts +392 -0
  1039. package/src/rust-crypto/KeyClaimManager.ts +86 -0
  1040. package/src/rust-crypto/OutgoingRequestProcessor.ts +233 -0
  1041. package/src/rust-crypto/OutgoingRequestsManager.ts +170 -0
  1042. package/src/rust-crypto/PerSessionKeyBackupDownloader.ts +501 -0
  1043. package/src/rust-crypto/RoomEncryptor.ts +362 -0
  1044. package/src/rust-crypto/backup.ts +942 -0
  1045. package/src/rust-crypto/constants.ts +18 -0
  1046. package/src/rust-crypto/device-converter.ts +128 -0
  1047. package/src/rust-crypto/index.ts +251 -0
  1048. package/src/rust-crypto/libolm_migration.ts +532 -0
  1049. package/src/rust-crypto/rust-crypto.ts +2542 -0
  1050. package/src/rust-crypto/secret-storage.ts +60 -0
  1051. package/src/rust-crypto/verification.ts +833 -0
  1052. package/src/scheduler.ts +309 -0
  1053. package/src/secret-storage.ts +714 -0
  1054. package/src/serverCapabilities.ts +146 -0
  1055. package/src/service-types.ts +20 -0
  1056. package/src/sliding-sync-sdk.ts +1005 -0
  1057. package/src/sliding-sync.ts +674 -0
  1058. package/src/store/index.ts +261 -0
  1059. package/src/store/indexeddb-backend.ts +41 -0
  1060. package/src/store/indexeddb-local-backend.ts +610 -0
  1061. package/src/store/indexeddb-remote-backend.ts +212 -0
  1062. package/src/store/indexeddb-store-worker.ts +157 -0
  1063. package/src/store/indexeddb.ts +397 -0
  1064. package/src/store/local-storage-events-emitter.ts +46 -0
  1065. package/src/store/memory.ts +448 -0
  1066. package/src/store/stub.ts +280 -0
  1067. package/src/sync-accumulator.ts +779 -0
  1068. package/src/sync.ts +2020 -0
  1069. package/src/testing.ts +231 -0
  1070. package/src/thread-utils.ts +31 -0
  1071. package/src/timeline-window.ts +534 -0
  1072. package/src/types.ts +59 -0
  1073. package/src/utils/decryptAESSecretStorageItem.ts +54 -0
  1074. package/src/utils/encryptAESSecretStorageItem.ts +73 -0
  1075. package/src/utils/internal/deriveKeys.ts +63 -0
  1076. package/src/utils/roomVersion.ts +35 -0
  1077. package/src/utils.ts +775 -0
  1078. package/src/version-support.ts +50 -0
  1079. package/src/webrtc/audioContext.ts +44 -0
  1080. package/src/webrtc/call.ts +3061 -0
  1081. package/src/webrtc/callEventHandler.ts +425 -0
  1082. package/src/webrtc/callEventTypes.ts +101 -0
  1083. package/src/webrtc/callFeed.ts +364 -0
  1084. package/src/webrtc/groupCall.ts +1729 -0
  1085. package/src/webrtc/groupCallEventHandler.ts +234 -0
  1086. package/src/webrtc/mediaHandler.ts +501 -0
  1087. package/src/webrtc/stats/callFeedStatsReporter.ts +91 -0
  1088. package/src/webrtc/stats/callStatsReportGatherer.ts +219 -0
  1089. package/src/webrtc/stats/callStatsReportSummary.ts +30 -0
  1090. package/src/webrtc/stats/connectionStats.ts +47 -0
  1091. package/src/webrtc/stats/connectionStatsBuilder.ts +28 -0
  1092. package/src/webrtc/stats/connectionStatsReportBuilder.ts +140 -0
  1093. package/src/webrtc/stats/groupCallStats.ts +93 -0
  1094. package/src/webrtc/stats/media/mediaSsrcHandler.ts +57 -0
  1095. package/src/webrtc/stats/media/mediaTrackHandler.ts +70 -0
  1096. package/src/webrtc/stats/media/mediaTrackStats.ts +176 -0
  1097. package/src/webrtc/stats/media/mediaTrackStatsHandler.ts +90 -0
  1098. package/src/webrtc/stats/statsReport.ts +133 -0
  1099. package/src/webrtc/stats/statsReportEmitter.ts +49 -0
  1100. package/src/webrtc/stats/summaryStatsReportGatherer.ts +148 -0
  1101. package/src/webrtc/stats/trackStatsBuilder.ts +207 -0
  1102. package/src/webrtc/stats/transportStats.ts +26 -0
  1103. package/src/webrtc/stats/transportStatsBuilder.ts +48 -0
  1104. package/src/webrtc/stats/valueFormatter.ts +27 -0
@@ -0,0 +1,1600 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+ /*
4
+ Copyright 2015 - 2023 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
+ /**
20
+ * This is an internal module. See {@link BriijEvent} and {@link RoomEvent} for
21
+ * the public classes.
22
+ */
23
+
24
+ import { ExtensibleEvents } from "matrix-events-sdk";
25
+ import { logger } from "../logger.js";
26
+ import { EVENT_VISIBILITY_CHANGE_TYPE, EventType, RelationType, ToDeviceMessageId, UNSIGNED_THREAD_ID_FIELD, UNSIGNED_MEMBERSHIP_FIELD } from "../@types/event.js";
27
+ import { deepSortedObjectEntries, internaliseString } from "../utils.js";
28
+ import { THREAD_RELATION_TYPE, ThreadEvent } from "./thread.js";
29
+ import { TypedReEmitter } from "../ReEmitter.js";
30
+ import { TypedEventEmitter } from "./typed-event-emitter.js";
31
+ import { DecryptionError } from "../common-crypto/CryptoBackend.js";
32
+ import { EventTimeline } from "./event-timeline.js";
33
+ import { DecryptionFailureCode } from "../crypto-api/index.js";
34
+ export { EventStatus } from "./event-status.js";
35
+
36
+ /* eslint-disable camelcase */
37
+
38
+ /**
39
+ * When an event is a visibility change event, as per MSC3531,
40
+ * the visibility change implied by the event.
41
+ */
42
+
43
+ /* eslint-enable camelcase */
44
+
45
+ /**
46
+ * Message hiding, as specified by https://github.com/matrix-org/matrix-doc/pull/3531.
47
+ */
48
+
49
+ /**
50
+ * Variant of `MessageVisibility` for the case in which the message should be displayed.
51
+ */
52
+
53
+ /**
54
+ * Variant of `MessageVisibility` for the case in which the message should be hidden.
55
+ */
56
+
57
+ // A singleton implementing `IMessageVisibilityVisible`.
58
+ var MESSAGE_VISIBLE = Object.freeze({
59
+ visible: true
60
+ });
61
+ export var MAX_STICKY_DURATION_MS = 3600000;
62
+ export var BriijEventEvent = /*#__PURE__*/function (BriijEventEvent) {
63
+ /**
64
+ * An event has been decrypted, or we have failed to decrypt it.
65
+ *
66
+ * The payload consists of:
67
+ *
68
+ * * `event` - The {@link BriijEvent} which we attempted to decrypt.
69
+ *
70
+ * * `err` - The error that occurred during decryption, or `undefined` if no error occurred.
71
+ * Avoid use of this: {@link BriijEvent.decryptionFailureReason} is more useful.
72
+ */
73
+ BriijEventEvent["Decrypted"] = "Event.decrypted";
74
+ BriijEventEvent["BeforeRedaction"] = "Event.beforeRedaction";
75
+ BriijEventEvent["VisibilityChange"] = "Event.visibilityChange";
76
+ BriijEventEvent["LocalEventIdReplaced"] = "Event.localEventIdReplaced";
77
+ BriijEventEvent["Status"] = "Event.status";
78
+ BriijEventEvent["Replaced"] = "Event.replaced";
79
+ BriijEventEvent["RelationsCreated"] = "Event.relationsCreated";
80
+ BriijEventEvent["SentinelUpdated"] = "Event.sentinelUpdated";
81
+ return BriijEventEvent;
82
+ }({});
83
+ export class BriijEvent extends TypedEventEmitter {
84
+ /**
85
+ * Update the sentinels and forwardLooking flag for this event.
86
+ * @param stateContext - the room state to be queried
87
+ * @param toStartOfTimeline - if true the event's forwardLooking flag is set false
88
+ * @internal
89
+ */
90
+ setMetadata(stateContext, toStartOfTimeline) {
91
+ var _this$sender, _this$target;
92
+ // If an event is an m.room.member state event then we should set the sentinels again in case setEventMetadata
93
+ // was already called before the state was applied and thus the sentinel points at the member from before this event.
94
+ var affectsSelf = this.isState() && this.getType() === EventType.RoomMember && this.getSender() === this.getStateKey();
95
+ var changed = false;
96
+ // When we try to generate a sentinel member before we have that member
97
+ // in the members object, we still generate a sentinel but it doesn't
98
+ // have a membership event, so test to see if events.member is set. We
99
+ // check this to avoid overriding non-sentinel members by sentinel ones
100
+ // when adding the event to a filtered timeline
101
+ if (affectsSelf || !((_this$sender = this.sender) !== null && _this$sender !== void 0 && (_this$sender = _this$sender.events) !== null && _this$sender !== void 0 && _this$sender.member)) {
102
+ var newSender = stateContext.getSentinelMember(this.getSender());
103
+ if (newSender !== this.sender) changed = true;
104
+ this.sender = newSender;
105
+ }
106
+ if (affectsSelf || !((_this$target = this.target) !== null && _this$target !== void 0 && (_this$target = _this$target.events) !== null && _this$target !== void 0 && _this$target.member) && this.getType() === EventType.RoomMember) {
107
+ var newTarget = stateContext.getSentinelMember(this.getStateKey());
108
+ if (newTarget !== this.target) changed = true;
109
+ this.target = newTarget;
110
+ }
111
+ if (this.isState()) {
112
+ // room state has no concept of 'old' or 'current', but we want the
113
+ // room state to regress back to previous values if toStartOfTimeline
114
+ // is set, which means inspecting prev_content if it exists. This
115
+ // is done by toggling the forwardLooking flag.
116
+ if (toStartOfTimeline) {
117
+ this.forwardLooking = false;
118
+ }
119
+ }
120
+ if (changed) {
121
+ this.emit(BriijEventEvent.SentinelUpdated);
122
+ }
123
+ }
124
+
125
+ /**
126
+ * The sending status of the event.
127
+ * @privateRemarks
128
+ * Should be read-only
129
+ */
130
+
131
+ /**
132
+ * Construct a Matrix Event object
133
+ *
134
+ * @param event - The raw (possibly encrypted) event. <b>Do not access
135
+ * this property</b> directly unless you absolutely have to. Prefer the getter
136
+ * methods defined on this class. Using the getter methods shields your app
137
+ * from changes to event JSON between Matrix versions.
138
+ */
139
+ constructor() {
140
+ var _this$getTs;
141
+ var event = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
142
+ super();
143
+
144
+ // intern the values of matrix events to force share strings and reduce the
145
+ // amount of needless string duplication. This can save moderate amounts of
146
+ // memory (~10% on a 350MB heap).
147
+ // 'membership' at the event level (rather than the content level) is a legacy
148
+ // field that Element never otherwise looks at, but it will still take up a lot
149
+ // of space if we don't intern it.
150
+ this.event = event;
151
+ // applied push rule and action for this event
152
+ _defineProperty(this, "pushDetails", {});
153
+ _defineProperty(this, "_replacingEvent", null);
154
+ _defineProperty(this, "_localRedactionEvent", null);
155
+ _defineProperty(this, "_isCancelled", false);
156
+ _defineProperty(this, "clearEvent", void 0);
157
+ /* Message hiding, as specified by https://github.com/matrix-org/matrix-doc/pull/3531.
158
+ Note: We're returning this object, so any value stored here MUST be frozen.
159
+ */
160
+ _defineProperty(this, "visibility", MESSAGE_VISIBLE);
161
+ // Not all events will be extensible-event compatible, so cache a flag in
162
+ // addition to a falsy cached event value. We check the flag later on in
163
+ // a public getter to decide if the cache is valid.
164
+ _defineProperty(this, "_hasCachedExtEv", false);
165
+ _defineProperty(this, "_cachedExtEv", undefined);
166
+ /** If we failed to decrypt this event, the reason for the failure. Otherwise, `null`. */
167
+ _defineProperty(this, "_decryptionFailureReason", null);
168
+ /* curve25519 key which we believe belongs to the sender of the event. See
169
+ * getSenderKey()
170
+ */
171
+ _defineProperty(this, "senderCurve25519Key", null);
172
+ /* ed25519 key which the sender of this event (for olm) or the creator of
173
+ * the megolm session (for megolm) claims to own. See getClaimedEd25519Key()
174
+ */
175
+ _defineProperty(this, "claimedEd25519Key", null);
176
+ /**
177
+ * If another user forwarded the key to this message
178
+ * (eg via [MSC4268](https://github.com/matrix-org/matrix-spec-proposals/pull/4268)),
179
+ * the ID of that user.
180
+ */
181
+ _defineProperty(this, "keyForwardedBy", void 0);
182
+ /* if we have a process decrypting this event, a Promise which resolves
183
+ * when it is finished. Normally null.
184
+ */
185
+ _defineProperty(this, "decryptionPromise", null);
186
+ /* flag to indicate if we should retry decrypting this event after the
187
+ * first attempt (eg, we have received new data which means that a second
188
+ * attempt may succeed)
189
+ */
190
+ _defineProperty(this, "retryDecryption", false);
191
+ /* The txnId with which this event was sent if it was during this session,
192
+ * allows for a unique ID which does not change when the event comes back down sync.
193
+ */
194
+ _defineProperty(this, "txnId", void 0);
195
+ /**
196
+ * A reference to the thread this event belongs to
197
+ */
198
+ _defineProperty(this, "thread", void 0);
199
+ _defineProperty(this, "threadId", void 0);
200
+ /* Set an approximate timestamp for the event relative the local clock.
201
+ * This will inherently be approximate because it doesn't take into account
202
+ * the time between the server putting the 'age' field on the event as it sent
203
+ * it to us and the time we're now constructing this event, but that's better
204
+ * than assuming the local clock is in sync with the origin HS's clock.
205
+ */
206
+ _defineProperty(this, "localTimestamp", void 0);
207
+ /**
208
+ * The room member who sent this event, or null e.g.
209
+ * this is a presence event. This is only guaranteed to be set for events that
210
+ * appear in a timeline, ie. do not guarantee that it will be set on state
211
+ * events.
212
+ * @privateRemarks
213
+ * Should be read-only
214
+ */
215
+ _defineProperty(this, "sender", null);
216
+ /**
217
+ * The room member who is the target of this event, e.g.
218
+ * the invitee, the person being banned, etc.
219
+ * @privateRemarks
220
+ * Should be read-only
221
+ */
222
+ _defineProperty(this, "target", null);
223
+ _defineProperty(this, "status", null);
224
+ /**
225
+ * most recent error associated with sending the event, if any
226
+ * @privateRemarks
227
+ * Should be read-only. May not be a BriijError.
228
+ */
229
+ _defineProperty(this, "error", null);
230
+ /**
231
+ * True if this event is 'forward looking', meaning
232
+ * that getDirectionalContent() will return event.content and not event.prev_content.
233
+ * Only state events may be backwards looking
234
+ * Default: true. <strong>This property is experimental and may change.</strong>
235
+ * @privateRemarks
236
+ * Should be read-only
237
+ */
238
+ _defineProperty(this, "forwardLooking", true);
239
+ _defineProperty(this, "reEmitter", void 0);
240
+ /**
241
+ * The timestamp for when this event should expire, in milliseconds.
242
+ * Prefers using the server-provided value, but will fall back to local calculation.
243
+ *
244
+ * This value is **safe** to use, as malicious start time and duration are appropriately capped.
245
+ *
246
+ * If the event is not a sticky event (or not supported by the server),
247
+ * then this returns `undefined`.
248
+ */
249
+ _defineProperty(this, "unstableStickyExpiresAt", void 0);
250
+ ["state_key", "type", "sender", "room_id", "membership"].forEach(prop => {
251
+ if (typeof event[prop] !== "string") return;
252
+ event[prop] = internaliseString(event[prop]);
253
+ });
254
+ ["membership", "avatar_url", "displayname"].forEach(prop => {
255
+ var _event$content;
256
+ if (typeof ((_event$content = event.content) === null || _event$content === void 0 ? void 0 : _event$content[prop]) !== "string") return;
257
+ event.content[prop] = internaliseString(event.content[prop]);
258
+ });
259
+ ["rel_type"].forEach(prop => {
260
+ var _event$content2;
261
+ if (typeof ((_event$content2 = event.content) === null || _event$content2 === void 0 || (_event$content2 = _event$content2["m.relates_to"]) === null || _event$content2 === void 0 ? void 0 : _event$content2[prop]) !== "string") return;
262
+ event.content["m.relates_to"][prop] = internaliseString(event.content["m.relates_to"][prop]);
263
+ });
264
+ this.txnId = event.txn_id;
265
+ // The localTimestamp is calculated using the age.
266
+ // Some events lack an `age` property, either because they are EDUs such as typing events,
267
+ // or due to server-side bugs such as https://github.com/matrix-org/synapse/issues/8429.
268
+ // The fallback in these cases will be to use the origin_server_ts.
269
+ // For EDUs, the origin_server_ts also is not defined so we use Date.now().
270
+ var age = this.getAge();
271
+ var now = Date.now();
272
+ this.localTimestamp = age !== undefined ? now - age : (_this$getTs = this.getTs()) !== null && _this$getTs !== void 0 ? _this$getTs : now;
273
+ this.reEmitter = new TypedReEmitter(this);
274
+ if (this.unstableStickyInfo) {
275
+ if (this.unstableStickyInfo.duration_ttl_ms) {
276
+ this.unstableStickyExpiresAt = now + this.unstableStickyInfo.duration_ttl_ms;
277
+ } else {
278
+ // Bound the timestamp so it doesn't come from the future.
279
+ this.unstableStickyExpiresAt = Math.min(now, this.getTs()) + this.unstableStickyInfo.duration_ms;
280
+ }
281
+ }
282
+ }
283
+
284
+ /**
285
+ * Unstable getter to try and get an extensible event. Note that this might
286
+ * return a falsy value if the event could not be parsed as an extensible
287
+ * event.
288
+ *
289
+ * @deprecated Use stable functions where possible.
290
+ */
291
+ get unstableExtensibleEvent() {
292
+ if (!this._hasCachedExtEv) {
293
+ var _ExtensibleEvents$par;
294
+ this._cachedExtEv = (_ExtensibleEvents$par = ExtensibleEvents.parse(this.getEffectiveEvent())) !== null && _ExtensibleEvents$par !== void 0 ? _ExtensibleEvents$par : undefined;
295
+ }
296
+ return this._cachedExtEv;
297
+ }
298
+ invalidateExtensibleEvent() {
299
+ // just reset the flag - that'll trick the getter into parsing a new event
300
+ this._hasCachedExtEv = false;
301
+ }
302
+
303
+ /**
304
+ * Gets the event as it would appear if it had been sent unencrypted.
305
+ *
306
+ * If the event is encrypted, we attempt to mock up an event as it would have looked had the sender not encrypted it.
307
+ * If the event is not encrypted, a copy of it is simply returned as-is.
308
+ *
309
+ * @returns A shallow copy of the event, in wire format, as it would have been had it not been encrypted.
310
+ */
311
+ getEffectiveEvent() {
312
+ var content = Object.assign({}, this.getContent()); // clone for mutation
313
+
314
+ if (this.getWireType() === EventType.RoomMessageEncrypted) {
315
+ // Encrypted events sometimes aren't symmetrical on the `content` so we'll copy
316
+ // that over too, but only for missing properties. We don't copy over mismatches
317
+ // between the plain and decrypted copies of `content` because we assume that the
318
+ // app is relying on the decrypted version, so we want to expose that as a source
319
+ // of truth here too.
320
+ for (var [_key, value] of Object.entries(this.getWireContent())) {
321
+ // Skip fields from the encrypted event schema though - we don't want to leak
322
+ // these.
323
+ if (["algorithm", "ciphertext", "device_id", "sender_key", "session_id"].includes(_key)) {
324
+ continue;
325
+ }
326
+ if (content[_key] === undefined) content[_key] = value;
327
+ }
328
+ }
329
+
330
+ // clearEvent doesn't have all the fields, so we'll copy what we can from this.event.
331
+ // We also copy over our "fixed" content key.
332
+ return Object.assign({}, this.event, this.clearEvent, {
333
+ content
334
+ });
335
+ }
336
+
337
+ /**
338
+ * Get the event_id for this event.
339
+ * @returns The event ID, e.g. <code>$143350589368169JsLZx:localhost
340
+ * </code>
341
+ */
342
+ getId() {
343
+ return this.event.event_id;
344
+ }
345
+
346
+ /**
347
+ * Get the user_id for this event.
348
+ * @returns The user ID, e.g. `@alice:matrix.org`
349
+ */
350
+ getSender() {
351
+ return this.event.sender; // v2 / v1
352
+ }
353
+
354
+ /**
355
+ * Get the (decrypted, if necessary) type of event.
356
+ *
357
+ * @returns The event type, e.g. `m.room.message`
358
+ */
359
+ getType() {
360
+ if (this.clearEvent) {
361
+ return this.clearEvent.type;
362
+ }
363
+ return this.event.type;
364
+ }
365
+
366
+ /**
367
+ * Get the (possibly encrypted) type of the event that will be sent to the
368
+ * homeserver.
369
+ *
370
+ * @returns The event type.
371
+ */
372
+ getWireType() {
373
+ return this.event.type;
374
+ }
375
+
376
+ /**
377
+ * Get the room_id for this event. This will return `undefined`
378
+ * for `m.presence` events.
379
+ * @returns The room ID, e.g. <code>!cURbafjkfsMDVwdRDQ:matrix.org
380
+ * </code>
381
+ */
382
+ getRoomId() {
383
+ return this.event.room_id;
384
+ }
385
+
386
+ /**
387
+ * Get the timestamp of this event.
388
+ * @returns The event timestamp, e.g. `1433502692297`
389
+ */
390
+ getTs() {
391
+ return this.event.origin_server_ts;
392
+ }
393
+
394
+ /**
395
+ * Get the timestamp of this event, as a Date object.
396
+ * @returns The event date, e.g. `new Date(1433502692297)`
397
+ */
398
+ getDate() {
399
+ return this.event.origin_server_ts ? new Date(this.event.origin_server_ts) : null;
400
+ }
401
+
402
+ /**
403
+ * Get a string containing details of this event
404
+ *
405
+ * This is intended for logging, to help trace errors. Example output:
406
+ *
407
+ * @example
408
+ * ```
409
+ * id=$HjnOHV646n0SjLDAqFrgIjim7RCpB7cdMXFrekWYAn type=m.room.encrypted
410
+ * sender=@user:example.com room=!room:example.com ts=2022-10-25T17:30:28.404Z
411
+ * ```
412
+ */
413
+ getDetails() {
414
+ var room = this.getRoomId();
415
+ if (room) {
416
+ var _this$getDate;
417
+ // in-room event
418
+ return "id=".concat(this.getId(), " type=").concat(this.getWireType(), " sender=").concat(this.getSender(), " room=").concat(room, " ts=").concat((_this$getDate = this.getDate()) === null || _this$getDate === void 0 ? void 0 : _this$getDate.toISOString());
419
+ } else {
420
+ // to-device event
421
+ var msgid = this.getContent()[ToDeviceMessageId];
422
+ return "msgid=".concat(msgid, " type=").concat(this.getWireType(), " sender=").concat(this.getSender());
423
+ }
424
+ }
425
+
426
+ /**
427
+ * Get the (decrypted, if necessary) event content JSON, even if the event
428
+ * was replaced by another event.
429
+ *
430
+ * @returns The event content JSON, or an empty object.
431
+ */
432
+ getOriginalContent() {
433
+ var _this$event$content;
434
+ if (this._localRedactionEvent) {
435
+ return {};
436
+ }
437
+ if (this.clearEvent) {
438
+ var _this$clearEvent$cont;
439
+ return (_this$clearEvent$cont = this.clearEvent.content) !== null && _this$clearEvent$cont !== void 0 ? _this$clearEvent$cont : {};
440
+ }
441
+ return (_this$event$content = this.event.content) !== null && _this$event$content !== void 0 ? _this$event$content : {};
442
+ }
443
+
444
+ /**
445
+ * Get the (decrypted, if necessary) event content JSON,
446
+ * or the content from the replacing event, if any.
447
+ * See `makeReplaced`.
448
+ *
449
+ * @returns The event content JSON, or an empty object.
450
+ */
451
+ getContent() {
452
+ if (this._localRedactionEvent) {
453
+ return {};
454
+ } else if (this._replacingEvent) {
455
+ var _this$_replacingEvent;
456
+ return (_this$_replacingEvent = this._replacingEvent.getContent()["m.new_content"]) !== null && _this$_replacingEvent !== void 0 ? _this$_replacingEvent : {};
457
+ } else {
458
+ return this.getOriginalContent();
459
+ }
460
+ }
461
+
462
+ /**
463
+ * Get the (possibly encrypted) event content JSON that will be sent to the
464
+ * homeserver.
465
+ *
466
+ * @returns The event content JSON, or an empty object.
467
+ */
468
+ getWireContent() {
469
+ return this.event.content || {};
470
+ }
471
+
472
+ /**
473
+ * Get the event ID of the thread head
474
+ */
475
+ get threadRootId() {
476
+ var _this$getWireContent;
477
+ // don't allow state events to be threaded as per the spec
478
+ if (this.isState()) {
479
+ return undefined;
480
+ }
481
+ var relatesTo = (_this$getWireContent = this.getWireContent()) === null || _this$getWireContent === void 0 ? void 0 : _this$getWireContent["m.relates_to"];
482
+ if ((relatesTo === null || relatesTo === void 0 ? void 0 : relatesTo.rel_type) === THREAD_RELATION_TYPE.name) {
483
+ return relatesTo.event_id;
484
+ }
485
+ if (this.thread) {
486
+ return this.thread.id;
487
+ }
488
+ if (this.threadId !== undefined) {
489
+ return this.threadId;
490
+ }
491
+ var unsigned = this.getUnsigned();
492
+ if (typeof unsigned[UNSIGNED_THREAD_ID_FIELD.name] === "string") {
493
+ return unsigned[UNSIGNED_THREAD_ID_FIELD.name];
494
+ }
495
+ return undefined;
496
+ }
497
+
498
+ /**
499
+ * A helper to check if an event is a thread's head or not
500
+ */
501
+ get isThreadRoot() {
502
+ // don't allow state events to be threaded as per the spec
503
+ if (this.isState()) {
504
+ return false;
505
+ }
506
+ var threadDetails = this.getServerAggregatedRelation(THREAD_RELATION_TYPE.name);
507
+
508
+ // Bundled relationships only returned when the sync response is limited
509
+ // hence us having to check both bundled relation and inspect the thread
510
+ // model
511
+ return !!threadDetails || this.threadRootId === this.getId();
512
+ }
513
+ get replyEventId() {
514
+ var _this$getWireContent$;
515
+ return (_this$getWireContent$ = this.getWireContent()["m.relates_to"]) === null || _this$getWireContent$ === void 0 || (_this$getWireContent$ = _this$getWireContent$["m.in_reply_to"]) === null || _this$getWireContent$ === void 0 ? void 0 : _this$getWireContent$.event_id;
516
+ }
517
+ get relationEventId() {
518
+ var _this$getWireContent2;
519
+ return (_this$getWireContent2 = this.getWireContent()) === null || _this$getWireContent2 === void 0 || (_this$getWireContent2 = _this$getWireContent2["m.relates_to"]) === null || _this$getWireContent2 === void 0 ? void 0 : _this$getWireContent2.event_id;
520
+ }
521
+
522
+ /**
523
+ * Get the previous event content JSON. This will only return something for
524
+ * state events which exist in the timeline.
525
+ * @returns The previous event content JSON, or an empty object.
526
+ */
527
+ getPrevContent() {
528
+ // v2 then v1 then default
529
+ return this.getUnsigned().prev_content || {};
530
+ }
531
+
532
+ /**
533
+ * Get either 'content' or 'prev_content' depending on if this event is
534
+ * 'forward-looking' or not. This can be modified via event.forwardLooking.
535
+ * In practice, this means we get the chronologically earlier content value
536
+ * for this event (this method should surely be called getEarlierContent)
537
+ * <strong>This method is experimental and may change.</strong>
538
+ * @returns event.content if this event is forward-looking, else
539
+ * event.prev_content.
540
+ */
541
+ getDirectionalContent() {
542
+ return this.forwardLooking ? this.getContent() : this.getPrevContent();
543
+ }
544
+
545
+ /**
546
+ * Get the age of this event. This represents the age of the event when the
547
+ * event arrived at the device, and not the age of the event when this
548
+ * function was called.
549
+ * Can only be returned once the server has echo'ed back
550
+ * @returns The age of this event in milliseconds.
551
+ */
552
+ getAge() {
553
+ return this.getUnsigned().age;
554
+ }
555
+
556
+ /**
557
+ * Get the age of the event when this function was called.
558
+ * This is the 'age' field adjusted according to how long this client has
559
+ * had the event.
560
+ * @returns The age of this event in milliseconds.
561
+ */
562
+ getLocalAge() {
563
+ return Date.now() - this.localTimestamp;
564
+ }
565
+
566
+ /**
567
+ * Get the event state_key if it has one. If necessary, this will perform
568
+ * string-unpacking on the state key, as per MSC4362. This will return
569
+ * <code>undefined</code> for message events.
570
+ * @returns The event's `state_key`.
571
+ */
572
+ getStateKey() {
573
+ if (this.clearEvent) {
574
+ return this.clearEvent.state_key;
575
+ }
576
+ return this.event.state_key;
577
+ }
578
+
579
+ /**
580
+ * Get the raw event state_key if it has one. This may be string-packed as per
581
+ * MSC4362 if the state event is encrypted. This will return <code>undefined
582
+ * </code> for message events.
583
+ * @returns The event's `state_key`.
584
+ */
585
+ getWireStateKey() {
586
+ return this.event.state_key;
587
+ }
588
+
589
+ /**
590
+ * Check if this event is a state event.
591
+ * @returns True if this is a state event.
592
+ */
593
+ isState() {
594
+ return this.event.state_key !== undefined;
595
+ }
596
+
597
+ /**
598
+ * Get the user's room membership at the time the event was sent, as reported
599
+ * by the server. This uses MSC4115.
600
+ *
601
+ * @returns The user's room membership, or `undefined` if the server does
602
+ * not report it.
603
+ */
604
+ getMembershipAtEvent() {
605
+ var unsigned = this.getUnsigned();
606
+ return UNSIGNED_MEMBERSHIP_FIELD.findIn(unsigned);
607
+ }
608
+
609
+ /**
610
+ * Replace the content of this event with encrypted versions.
611
+ * (This is used when sending an event; it should not be used by applications).
612
+ *
613
+ * @internal
614
+ *
615
+ * @param cryptoType - type of the encrypted event - typically
616
+ * <tt>"m.room.encrypted"</tt>
617
+ *
618
+ * @param cryptoContent - raw 'content' for the encrypted event.
619
+ *
620
+ * @param senderCurve25519Key - curve25519 key to record for the
621
+ * sender of this event.
622
+ * See {@link BriijEvent#getSenderKey}.
623
+ *
624
+ * @param claimedEd25519Key - claimed ed25519 key to record for the
625
+ * sender if this event.
626
+ * See {@link BriijEvent#getClaimedEd25519Key}
627
+ */
628
+ makeEncrypted(cryptoType, cryptoContent, senderCurve25519Key, claimedEd25519Key) {
629
+ // keep the plain-text data for 'view source'
630
+ this.clearEvent = {
631
+ type: this.event.type,
632
+ content: this.event.content,
633
+ state_key: this.event.state_key
634
+ };
635
+ this.event.type = cryptoType;
636
+ this.event.content = cryptoContent;
637
+ this.senderCurve25519Key = senderCurve25519Key;
638
+ this.claimedEd25519Key = claimedEd25519Key;
639
+
640
+ // if this is a state event, pack cleartext type and statekey
641
+ if (this.isState()) {
642
+ this.event.state_key = "".concat(this.clearEvent.type, ":").concat(this.clearEvent.state_key);
643
+ }
644
+ }
645
+
646
+ /**
647
+ * Check if this event is currently being decrypted.
648
+ *
649
+ * @returns True if this event is currently being decrypted, else false.
650
+ */
651
+ isBeingDecrypted() {
652
+ return this.decryptionPromise != null;
653
+ }
654
+ getDecryptionPromise() {
655
+ return this.decryptionPromise;
656
+ }
657
+
658
+ /**
659
+ * Check if this event is an encrypted event which we failed to decrypt
660
+ *
661
+ * (This implies that we might retry decryption at some point in the future)
662
+ *
663
+ * @returns True if this event is an encrypted event which we
664
+ * couldn't decrypt.
665
+ */
666
+ isDecryptionFailure() {
667
+ return this._decryptionFailureReason !== null;
668
+ }
669
+
670
+ /** If we failed to decrypt this event, the reason for the failure. Otherwise, `null`. */
671
+ get decryptionFailureReason() {
672
+ return this._decryptionFailureReason;
673
+ }
674
+ shouldAttemptDecryption() {
675
+ if (this.isRedacted()) return false;
676
+ if (this.isBeingDecrypted()) return false;
677
+ if (this.clearEvent) return false;
678
+ if (!this.isEncrypted()) return false;
679
+ return true;
680
+ }
681
+
682
+ /**
683
+ * Start the process of trying to decrypt this event.
684
+ *
685
+ * (This is used within the SDK: it isn't intended for use by applications)
686
+ *
687
+ * @internal
688
+ *
689
+ * @param crypto - crypto module
690
+ *
691
+ * @returns promise which resolves (to undefined) when the decryption
692
+ * attempt is completed.
693
+ */
694
+ attemptDecryption(crypto) {
695
+ var _arguments = arguments,
696
+ _this = this;
697
+ return _asyncToGenerator(function* () {
698
+ var options = _arguments.length > 1 && _arguments[1] !== undefined ? _arguments[1] : {};
699
+ // start with a couple of sanity checks.
700
+ if (!_this.isEncrypted()) {
701
+ throw new Error("Attempt to decrypt event which isn't encrypted");
702
+ }
703
+ var alreadyDecrypted = _this.clearEvent && !_this.isDecryptionFailure();
704
+ if (alreadyDecrypted) {
705
+ // we may want to just ignore this? let's start with rejecting it.
706
+ throw new Error("Attempt to decrypt event which has already been decrypted");
707
+ }
708
+
709
+ // if we already have a decryption attempt in progress, then it may
710
+ // fail because it was using outdated info. We now have reason to
711
+ // succeed where it failed before, but we don't want to have multiple
712
+ // attempts going at the same time, so just set a flag that says we have
713
+ // new info.
714
+ //
715
+ if (_this.decryptionPromise) {
716
+ logger.log("Event ".concat(_this.getId(), " already being decrypted; queueing a retry"));
717
+ _this.retryDecryption = true;
718
+ return _this.decryptionPromise;
719
+ }
720
+ _this.decryptionPromise = _this.decryptionLoop(crypto, options);
721
+ return _this.decryptionPromise;
722
+ })();
723
+ }
724
+
725
+ /**
726
+ * Calculate the recipients for keyshare requests.
727
+ *
728
+ * @param userId - the user who received this event.
729
+ *
730
+ * @returns array of recipients
731
+ */
732
+ getKeyRequestRecipients(userId) {
733
+ // send the request to all of our own devices
734
+ var recipients = [{
735
+ userId,
736
+ deviceId: "*"
737
+ }];
738
+ return recipients;
739
+ }
740
+ decryptionLoop(crypto) {
741
+ var _arguments2 = arguments,
742
+ _this2 = this;
743
+ return _asyncToGenerator(function* () {
744
+ var options = _arguments2.length > 1 && _arguments2[1] !== undefined ? _arguments2[1] : {};
745
+ // make sure that this method never runs completely synchronously.
746
+ // (doing so would mean that we would clear decryptionPromise *before*
747
+ // it is set in attemptDecryption - and hence end up with a stuck
748
+ // `decryptionPromise`).
749
+ yield Promise.resolve();
750
+
751
+ // eslint-disable-next-line no-constant-condition
752
+ while (true) {
753
+ _this2.retryDecryption = false;
754
+ var err = undefined;
755
+ try {
756
+ var res = yield crypto.decryptEvent(_this2);
757
+ if (options.isRetry === true) {
758
+ logger.info("Decrypted event on retry (".concat(_this2.getDetails(), ")"));
759
+ }
760
+ _this2.setClearData(res);
761
+ _this2._decryptionFailureReason = null;
762
+ } catch (e) {
763
+ var detailedError = e instanceof DecryptionError ? e.detailedString : String(e);
764
+ err = e;
765
+
766
+ // see if we have a retry queued.
767
+ //
768
+ // NB: make sure to keep this check in the same tick of the
769
+ // event loop as `decryptionPromise = null` below - otherwise we
770
+ // risk a race:
771
+ //
772
+ // * A: we check retryDecryption here and see that it is
773
+ // false
774
+ // * B: we get a second call to attemptDecryption, which sees
775
+ // that decryptionPromise is set so sets
776
+ // retryDecryption
777
+ // * A: we continue below, clear decryptionPromise, and
778
+ // never do the retry.
779
+ //
780
+ if (_this2.retryDecryption) {
781
+ // decryption error, but we have a retry queued.
782
+ logger.log("Error decrypting event (".concat(_this2.getDetails(), "), but retrying: ").concat(detailedError));
783
+ continue;
784
+ }
785
+
786
+ // decryption error, no retries queued. Warn about the error and
787
+ // set it to m.bad.encrypted.
788
+ //
789
+ // the detailedString already includes the name and message of the error, and the stack isn't much use,
790
+ // so we don't bother to log `e` separately.
791
+ logger.warn("Error decrypting event (".concat(_this2.getDetails(), "): ").concat(detailedError));
792
+ _this2.setClearDataForDecryptionFailure(String(e));
793
+ _this2._decryptionFailureReason = e instanceof DecryptionError ? e.code : DecryptionFailureCode.UNKNOWN_ERROR;
794
+ }
795
+
796
+ // Make sure we clear 'decryptionPromise' before sending the 'Event.decrypted' event,
797
+ // otherwise the app will be confused to see `isBeingDecrypted` still set when
798
+ // there isn't an `Event.decrypted` on the way.
799
+ //
800
+ // see also notes on retryDecryption above.
801
+ //
802
+ _this2.decryptionPromise = null;
803
+ _this2.retryDecryption = false;
804
+
805
+ // Before we emit the event, clear the push actions so that they can be recalculated
806
+ // by relevant code. We do this because the clear event has now changed, making it
807
+ // so that existing rules can be re-run over the applicable properties. Stuff like
808
+ // highlighting when the user's name is mentioned rely on this happening. We also want
809
+ // to set the push actions before emitting so that any notification listeners don't
810
+ // pick up the wrong contents.
811
+ _this2.setPushDetails();
812
+ if (options.emit !== false) {
813
+ _this2.emit(BriijEventEvent.Decrypted, _this2, err);
814
+ }
815
+ return;
816
+ }
817
+ })();
818
+ }
819
+
820
+ /**
821
+ * Update the cleartext data on this event.
822
+ *
823
+ * (This is used after decrypting an event; it should not be used by applications).
824
+ *
825
+ * @internal
826
+ *
827
+ * @param decryptionResult - the decryption result, including the plaintext and some key info
828
+ */
829
+ setClearData(decryptionResult) {
830
+ var _decryptionResult$sen, _decryptionResult$cla;
831
+ this.clearEvent = decryptionResult.clearEvent;
832
+ this.senderCurve25519Key = (_decryptionResult$sen = decryptionResult.senderCurve25519Key) !== null && _decryptionResult$sen !== void 0 ? _decryptionResult$sen : null;
833
+ this.claimedEd25519Key = (_decryptionResult$cla = decryptionResult.claimedEd25519Key) !== null && _decryptionResult$cla !== void 0 ? _decryptionResult$cla : null;
834
+ this.keyForwardedBy = decryptionResult.keyForwardedBy;
835
+ this.invalidateExtensibleEvent();
836
+ }
837
+
838
+ /**
839
+ * Update the cleartext data on this event after a decryption failure.
840
+ *
841
+ * @param reason - the textual reason for the failure
842
+ */
843
+ setClearDataForDecryptionFailure(reason) {
844
+ this.clearEvent = {
845
+ type: EventType.RoomMessage,
846
+ content: {
847
+ msgtype: "m.bad.encrypted",
848
+ body: "** Unable to decrypt: ".concat(reason, " **")
849
+ }
850
+ };
851
+ this.senderCurve25519Key = null;
852
+ this.claimedEd25519Key = null;
853
+ this.invalidateExtensibleEvent();
854
+ }
855
+
856
+ /**
857
+ * Gets the cleartext content for this event. If the event is not encrypted,
858
+ * or encryption has not been completed, this will return null.
859
+ *
860
+ * @returns The cleartext (decrypted) content for the event
861
+ */
862
+ getClearContent() {
863
+ return this.clearEvent ? this.clearEvent.content : null;
864
+ }
865
+
866
+ /**
867
+ * Check if the event is encrypted.
868
+ * @returns True if this event is encrypted.
869
+ */
870
+ isEncrypted() {
871
+ return this.event.type === EventType.RoomMessageEncrypted;
872
+ }
873
+
874
+ /**
875
+ * The curve25519 key for the device that we think sent this event
876
+ *
877
+ * For an Olm-encrypted event, this is inferred directly from the DH
878
+ * exchange at the start of the session: the curve25519 key is involved in
879
+ * the DH exchange, so only a device which holds the private part of that
880
+ * key can establish such a session.
881
+ *
882
+ * For a megolm-encrypted event, it is inferred from the Olm message which
883
+ * established the megolm session
884
+ */
885
+ getSenderKey() {
886
+ return this.senderCurve25519Key;
887
+ }
888
+
889
+ /**
890
+ * The additional keys the sender of this encrypted event claims to possess.
891
+ *
892
+ * Just a wrapper for #getClaimedEd25519Key (q.v.)
893
+ */
894
+ getKeysClaimed() {
895
+ if (!this.claimedEd25519Key) return {};
896
+ return {
897
+ ed25519: this.claimedEd25519Key
898
+ };
899
+ }
900
+
901
+ /**
902
+ * Get the ed25519 the sender of this event claims to own.
903
+ *
904
+ * For Olm messages, this claim is encoded directly in the plaintext of the
905
+ * event itself. For megolm messages, it is implied by the m.room_key event
906
+ * which established the megolm session.
907
+ *
908
+ * Until we download the device list of the sender, it's just a claim: the
909
+ * device list gives a proof that the owner of the curve25519 key used for
910
+ * this event (and returned by #getSenderKey) also owns the ed25519 key by
911
+ * signing the public curve25519 key with the ed25519 key.
912
+ *
913
+ * In general, applications should not use this method directly, but should
914
+ * instead use {@link crypto-api!CryptoApi#getEncryptionInfoForEvent}.
915
+ */
916
+ getClaimedEd25519Key() {
917
+ return this.claimedEd25519Key;
918
+ }
919
+
920
+ /**
921
+ * Returns an empty array.
922
+ *
923
+ * Previously, this returned the chain of Curve25519 keys through which
924
+ * this session was forwarded, via `m.forwarded_room_key` events.
925
+ * However, that is not cryptographically reliable, and clients should not
926
+ * be using it.
927
+ *
928
+ * @see https://github.com/matrix-org/matrix-spec/issues/1089
929
+ * @deprecated
930
+ */
931
+ getForwardingCurve25519KeyChain() {
932
+ return [];
933
+ }
934
+
935
+ /**
936
+ * @deprecated always returns false
937
+ */
938
+ isKeySourceUntrusted() {
939
+ return false;
940
+ }
941
+
942
+ /**
943
+ * If another user forwarded the key to this message
944
+ * (eg via [MSC4268](https://github.com/matrix-org/matrix-spec-proposals/pull/4268)),
945
+ * get the ID of that user.
946
+ */
947
+ getKeyForwardingUser() {
948
+ return this.keyForwardedBy;
949
+ }
950
+ getUnsigned() {
951
+ return this.event.unsigned || {};
952
+ }
953
+ setUnsigned(unsigned) {
954
+ this.event.unsigned = unsigned;
955
+ }
956
+ unmarkLocallyRedacted() {
957
+ var value = this._localRedactionEvent;
958
+ this._localRedactionEvent = null;
959
+ if (this.event.unsigned) {
960
+ this.event.unsigned.redacted_because = undefined;
961
+ }
962
+ return !!value;
963
+ }
964
+ markLocallyRedacted(redactionEvent) {
965
+ if (this._localRedactionEvent) return;
966
+ this.emit(BriijEventEvent.BeforeRedaction, this, redactionEvent);
967
+ this._localRedactionEvent = redactionEvent;
968
+ if (!this.event.unsigned) {
969
+ this.event.unsigned = {};
970
+ }
971
+ this.event.unsigned.redacted_because = redactionEvent.event;
972
+ }
973
+
974
+ /**
975
+ * Change the visibility of an event, as per https://github.com/matrix-org/matrix-doc/pull/3531 .
976
+ *
977
+ * @param visibilityChange - event holding a hide/unhide payload, or nothing
978
+ * if the event is being reset to its original visibility (presumably
979
+ * by a visibility event being redacted).
980
+ *
981
+ * @remarks
982
+ * Fires {@link BriijEventEvent.VisibilityChange} if `visibilityEvent`
983
+ * caused a change in the actual visibility of this event, either by making it
984
+ * visible (if it was hidden), by making it hidden (if it was visible) or by
985
+ * changing the reason (if it was hidden).
986
+ */
987
+ applyVisibilityEvent(visibilityChange) {
988
+ var _visibilityChange$vis, _visibilityChange$rea;
989
+ var visible = (_visibilityChange$vis = visibilityChange === null || visibilityChange === void 0 ? void 0 : visibilityChange.visible) !== null && _visibilityChange$vis !== void 0 ? _visibilityChange$vis : true;
990
+ var reason = (_visibilityChange$rea = visibilityChange === null || visibilityChange === void 0 ? void 0 : visibilityChange.reason) !== null && _visibilityChange$rea !== void 0 ? _visibilityChange$rea : null;
991
+ var change = false;
992
+ if (this.visibility.visible !== visible) {
993
+ change = true;
994
+ } else if (!this.visibility.visible && this.visibility["reason"] !== reason) {
995
+ change = true;
996
+ }
997
+ if (change) {
998
+ if (visible) {
999
+ this.visibility = MESSAGE_VISIBLE;
1000
+ } else {
1001
+ this.visibility = Object.freeze({
1002
+ visible: false,
1003
+ reason
1004
+ });
1005
+ }
1006
+ this.emit(BriijEventEvent.VisibilityChange, this, visible);
1007
+ }
1008
+ }
1009
+
1010
+ /**
1011
+ * Return instructions to display or hide the message.
1012
+ *
1013
+ * @returns Instructions determining whether the message
1014
+ * should be displayed.
1015
+ */
1016
+ messageVisibility() {
1017
+ // Note: We may return `this.visibility` without fear, as
1018
+ // this is a shallow frozen object.
1019
+ return this.visibility;
1020
+ }
1021
+
1022
+ /**
1023
+ * Update the content of an event in the same way it would be by the server
1024
+ * if it were redacted before it was sent to us
1025
+ *
1026
+ * @param redactionEvent - event causing the redaction
1027
+ * @param room - the room in which the event exists
1028
+ */
1029
+ makeRedacted(redactionEvent, room) {
1030
+ // quick sanity-check
1031
+ if (!redactionEvent.event) {
1032
+ throw new Error("invalid redactionEvent in makeRedacted");
1033
+ }
1034
+ this._localRedactionEvent = null;
1035
+ this.emit(BriijEventEvent.BeforeRedaction, this, redactionEvent);
1036
+ this._replacingEvent = null;
1037
+ // we attempt to replicate what we would see from the server if
1038
+ // the event had been redacted before we saw it.
1039
+ //
1040
+ // The server removes (most of) the content of the event, and adds a
1041
+ // "redacted_because" key to the unsigned section containing the
1042
+ // redacted event.
1043
+ if (!this.event.unsigned) {
1044
+ this.event.unsigned = {};
1045
+ }
1046
+ this.event.unsigned.redacted_because = redactionEvent.event;
1047
+ for (var _key2 in this.event) {
1048
+ if (this.event.hasOwnProperty(_key2) && !REDACT_KEEP_KEYS.has(_key2)) {
1049
+ delete this.event[_key2];
1050
+ }
1051
+ }
1052
+
1053
+ // If the event is encrypted prune the decrypted bits
1054
+ if (this.isEncrypted()) {
1055
+ this.clearEvent = undefined;
1056
+ }
1057
+ var keeps = this.getType() in REDACT_KEEP_CONTENT_MAP ? REDACT_KEEP_CONTENT_MAP[this.getType()] : {};
1058
+ var content = this.getContent();
1059
+ for (var _key3 in content) {
1060
+ if (content.hasOwnProperty(_key3) && !keeps[_key3]) {
1061
+ delete content[_key3];
1062
+ }
1063
+ }
1064
+
1065
+ // If the redacted event was in a thread (but not thread root), move it
1066
+ // to the main timeline. This will change if MSC3389 is merged.
1067
+ if (!this.isThreadRoot && this.threadRootId && this.threadRootId !== this.getId()) {
1068
+ this.moveAllRelatedToMainTimeline(room);
1069
+ redactionEvent.moveToMainTimeline(room);
1070
+ }
1071
+ this.invalidateExtensibleEvent();
1072
+ }
1073
+ moveAllRelatedToMainTimeline(room) {
1074
+ var thread = this.thread;
1075
+ this.moveToMainTimeline(room);
1076
+
1077
+ // If we dont have access to the thread, we can only move this
1078
+ // event, not things related to it.
1079
+ if (thread) {
1080
+ for (var _event of thread.events) {
1081
+ var _event$getRelation;
1082
+ if (((_event$getRelation = _event.getRelation()) === null || _event$getRelation === void 0 ? void 0 : _event$getRelation.event_id) === this.getId()) {
1083
+ _event.moveAllRelatedToMainTimeline(room);
1084
+ }
1085
+ }
1086
+ }
1087
+ }
1088
+ moveToMainTimeline(room) {
1089
+ var _this$thread;
1090
+ // Remove it from its thread
1091
+ (_this$thread = this.thread) === null || _this$thread === void 0 || _this$thread.timelineSet.removeEvent(this.getId());
1092
+ this.setThread(undefined);
1093
+
1094
+ // And insert it into the main timeline
1095
+ var timeline = room.getLiveTimeline();
1096
+ // We use insertEventIntoTimeline to insert it in timestamp order,
1097
+ // because we don't know where it should go (until we have MSC4033).
1098
+ timeline.getTimelineSet().insertEventIntoTimeline(this, timeline, timeline.getState(EventTimeline.FORWARDS), false);
1099
+ }
1100
+
1101
+ /**
1102
+ * Check if this event has been redacted
1103
+ *
1104
+ * @returns True if this event has been redacted
1105
+ */
1106
+ isRedacted() {
1107
+ return Boolean(this.getUnsigned().redacted_because);
1108
+ }
1109
+
1110
+ /**
1111
+ * Check if this event is a redaction of another event
1112
+ *
1113
+ * @returns True if this event is a redaction
1114
+ */
1115
+ isRedaction() {
1116
+ return this.getType() === EventType.RoomRedaction;
1117
+ }
1118
+
1119
+ /**
1120
+ * Return the visibility change caused by this event,
1121
+ * as per https://github.com/matrix-org/matrix-doc/pull/3531.
1122
+ *
1123
+ * @returns If the event is a well-formed visibility change event,
1124
+ * an instance of `IVisibilityChange`, otherwise `null`.
1125
+ */
1126
+ asVisibilityChange() {
1127
+ if (!EVENT_VISIBILITY_CHANGE_TYPE.matches(this.getType())) {
1128
+ // Not a visibility change event.
1129
+ return null;
1130
+ }
1131
+ var relation = this.getRelation();
1132
+ if (!relation || relation.rel_type != "m.reference") {
1133
+ // Ill-formed, ignore this event.
1134
+ return null;
1135
+ }
1136
+ var eventId = relation.event_id;
1137
+ if (!eventId) {
1138
+ // Ill-formed, ignore this event.
1139
+ return null;
1140
+ }
1141
+ var content = this.getWireContent();
1142
+ var visible = !!content.visible;
1143
+ var reason = content.reason;
1144
+ if (reason && typeof reason != "string") {
1145
+ // Ill-formed, ignore this event.
1146
+ return null;
1147
+ }
1148
+ // Well-formed visibility change event.
1149
+ return {
1150
+ visible,
1151
+ reason,
1152
+ eventId
1153
+ };
1154
+ }
1155
+
1156
+ /**
1157
+ * Check if this event alters the visibility of another event,
1158
+ * as per https://github.com/matrix-org/matrix-doc/pull/3531.
1159
+ *
1160
+ * @returns True if this event alters the visibility
1161
+ * of another event.
1162
+ */
1163
+ isVisibilityEvent() {
1164
+ return EVENT_VISIBILITY_CHANGE_TYPE.matches(this.getType());
1165
+ }
1166
+
1167
+ /**
1168
+ * Get the (decrypted, if necessary) redaction event JSON
1169
+ * if event was redacted
1170
+ *
1171
+ * @returns The redaction event JSON, or an empty object
1172
+ */
1173
+ getRedactionEvent() {
1174
+ var _this$clearEvent, _this$event$unsigned;
1175
+ if (!this.isRedacted()) return null;
1176
+ if ((_this$clearEvent = this.clearEvent) !== null && _this$clearEvent !== void 0 && _this$clearEvent.unsigned) {
1177
+ var _this$clearEvent$unsi, _this$clearEvent2;
1178
+ return (_this$clearEvent$unsi = (_this$clearEvent2 = this.clearEvent) === null || _this$clearEvent2 === void 0 ? void 0 : _this$clearEvent2.unsigned.redacted_because) !== null && _this$clearEvent$unsi !== void 0 ? _this$clearEvent$unsi : null;
1179
+ } else if ((_this$event$unsigned = this.event.unsigned) !== null && _this$event$unsigned !== void 0 && _this$event$unsigned.redacted_because) {
1180
+ return this.event.unsigned.redacted_because;
1181
+ } else {
1182
+ return {};
1183
+ }
1184
+ }
1185
+
1186
+ /**
1187
+ * Get the push actions, if known, for this event
1188
+ *
1189
+ * @returns push actions
1190
+ */
1191
+ getPushActions() {
1192
+ return this.pushDetails.actions || null;
1193
+ }
1194
+
1195
+ /**
1196
+ * Get the push details, if known, for this event
1197
+ *
1198
+ * @returns push actions
1199
+ */
1200
+ getPushDetails() {
1201
+ return this.pushDetails;
1202
+ }
1203
+
1204
+ /**
1205
+ * Set the push details for this event.
1206
+ *
1207
+ * @param pushActions - push actions
1208
+ * @param rule - the executed push rule
1209
+ */
1210
+ setPushDetails(pushActions, rule) {
1211
+ this.pushDetails = {
1212
+ actions: pushActions,
1213
+ rule
1214
+ };
1215
+ }
1216
+
1217
+ /**
1218
+ * Replace the `event` property and recalculate any properties based on it.
1219
+ * @param event - the object to assign to the `event` property
1220
+ */
1221
+ handleRemoteEcho(event) {
1222
+ var _this$getAge;
1223
+ var oldUnsigned = this.getUnsigned();
1224
+ var oldId = this.getId();
1225
+ this.event = event;
1226
+ // if this event was redacted before it was sent, it's locally marked as redacted.
1227
+ // At this point, we've received the remote echo for the event, but not yet for
1228
+ // the redaction that we are sending ourselves. Preserve the locally redacted
1229
+ // state by copying over redacted_because so we don't get a flash of
1230
+ // redacted, not-redacted, redacted as remote echos come in
1231
+ if (oldUnsigned.redacted_because) {
1232
+ if (!this.event.unsigned) {
1233
+ this.event.unsigned = {};
1234
+ }
1235
+ this.event.unsigned.redacted_because = oldUnsigned.redacted_because;
1236
+ }
1237
+ // successfully sent.
1238
+ this.setStatus(null);
1239
+ if (this.getId() !== oldId) {
1240
+ // emit the event if it changed
1241
+ this.emit(BriijEventEvent.LocalEventIdReplaced, this);
1242
+ }
1243
+ this.localTimestamp = Date.now() - ((_this$getAge = this.getAge()) !== null && _this$getAge !== void 0 ? _this$getAge : 0);
1244
+ }
1245
+
1246
+ /**
1247
+ * Whether the event is in any phase of sending, send failure, waiting for
1248
+ * remote echo, etc.
1249
+ */
1250
+ isSending() {
1251
+ return !!this.status;
1252
+ }
1253
+
1254
+ /**
1255
+ * Update the event's sending status and emit an event as well.
1256
+ *
1257
+ * @param status - The new status
1258
+ */
1259
+ setStatus(status) {
1260
+ this.status = status;
1261
+ this.emit(BriijEventEvent.Status, this, status);
1262
+ }
1263
+ replaceLocalEventId(eventId) {
1264
+ this.event.event_id = eventId;
1265
+ this.emit(BriijEventEvent.LocalEventIdReplaced, this);
1266
+ }
1267
+
1268
+ /**
1269
+ * Get whether the event is a relation event, and of a given type if
1270
+ * `relType` is passed in. State events cannot be relation events
1271
+ *
1272
+ * @param relType - if given, checks that the relation is of the
1273
+ * given type
1274
+ */
1275
+ isRelation(relType) {
1276
+ var _this$getWireContent3;
1277
+ // Relation info is lifted out of the encrypted content when sent to
1278
+ // encrypted rooms, so we have to check `getWireContent` for this.
1279
+ var relation = (_this$getWireContent3 = this.getWireContent()) === null || _this$getWireContent3 === void 0 ? void 0 : _this$getWireContent3["m.relates_to"];
1280
+ if (this.isState() && !!(relation !== null && relation !== void 0 && relation.rel_type) && [RelationType.Replace, RelationType.Thread].includes(relation.rel_type)) {
1281
+ // State events cannot be m.replace or m.thread relations
1282
+ return false;
1283
+ }
1284
+ return !!(relation !== null && relation !== void 0 && relation.rel_type && relation.event_id && (relType ? relation.rel_type === relType : true));
1285
+ }
1286
+
1287
+ /**
1288
+ * Get relation info for the event, if any.
1289
+ */
1290
+ getRelation() {
1291
+ var _this$getWireContent$2;
1292
+ if (!this.isRelation()) {
1293
+ return null;
1294
+ }
1295
+ return (_this$getWireContent$2 = this.getWireContent()["m.relates_to"]) !== null && _this$getWireContent$2 !== void 0 ? _this$getWireContent$2 : null;
1296
+ }
1297
+
1298
+ /**
1299
+ * Set an event that replaces the content of this event, through an m.replace relation.
1300
+ *
1301
+ * @param newEvent - the event with the replacing content, if any.
1302
+ *
1303
+ * @remarks
1304
+ * Fires {@link BriijEventEvent.Replaced}
1305
+ */
1306
+ makeReplaced(newEvent) {
1307
+ // don't allow redacted events to be replaced.
1308
+ // if newEvent is null we allow to go through though,
1309
+ // as with local redaction, the replacing event might get
1310
+ // cancelled, which should be reflected on the target event.
1311
+ if (this.isRedacted() && newEvent) {
1312
+ return;
1313
+ }
1314
+ // don't allow state events to be replaced using this mechanism as per MSC2676
1315
+ if (this.isState()) {
1316
+ return;
1317
+ }
1318
+ if (this._replacingEvent !== newEvent) {
1319
+ this._replacingEvent = newEvent !== null && newEvent !== void 0 ? newEvent : null;
1320
+ this.emit(BriijEventEvent.Replaced, this);
1321
+ this.invalidateExtensibleEvent();
1322
+ }
1323
+ }
1324
+
1325
+ /**
1326
+ * Returns the status of any associated edit or redaction
1327
+ * (not for reactions/annotations as their local echo doesn't affect the original event),
1328
+ * or else the status of the event.
1329
+ */
1330
+ getAssociatedStatus() {
1331
+ if (this._replacingEvent) {
1332
+ return this._replacingEvent.status;
1333
+ } else if (this._localRedactionEvent) {
1334
+ return this._localRedactionEvent.status;
1335
+ }
1336
+ return this.status;
1337
+ }
1338
+ getServerAggregatedRelation(relType) {
1339
+ var _this$getUnsigned$mR;
1340
+ return (_this$getUnsigned$mR = this.getUnsigned()["m.relations"]) === null || _this$getUnsigned$mR === void 0 ? void 0 : _this$getUnsigned$mR[relType];
1341
+ }
1342
+
1343
+ /**
1344
+ * Returns the event ID of the event replacing the content of this event, if any.
1345
+ */
1346
+ replacingEventId() {
1347
+ var replaceRelation = this.getServerAggregatedRelation(RelationType.Replace);
1348
+ if (replaceRelation) {
1349
+ return replaceRelation.event_id;
1350
+ } else if (this._replacingEvent) {
1351
+ return this._replacingEvent.getId();
1352
+ }
1353
+ }
1354
+
1355
+ /**
1356
+ * Returns the event replacing the content of this event, if any.
1357
+ * Replacements are aggregated on the server, so this would only
1358
+ * return an event in case it came down the sync, or for local echo of edits.
1359
+ */
1360
+ replacingEvent() {
1361
+ return this._replacingEvent;
1362
+ }
1363
+
1364
+ /**
1365
+ * Returns the origin_server_ts of the event replacing the content of this event, if any.
1366
+ */
1367
+ replacingEventDate() {
1368
+ var replaceRelation = this.getServerAggregatedRelation(RelationType.Replace);
1369
+ if (replaceRelation) {
1370
+ var ts = replaceRelation.origin_server_ts;
1371
+ if (Number.isFinite(ts)) {
1372
+ return new Date(ts);
1373
+ }
1374
+ } else if (this._replacingEvent) {
1375
+ var _this$_replacingEvent2;
1376
+ return (_this$_replacingEvent2 = this._replacingEvent.getDate()) !== null && _this$_replacingEvent2 !== void 0 ? _this$_replacingEvent2 : undefined;
1377
+ }
1378
+ }
1379
+
1380
+ /**
1381
+ * Returns the event that wants to redact this event, but hasn't been sent yet.
1382
+ * @returns the event
1383
+ */
1384
+ localRedactionEvent() {
1385
+ return this._localRedactionEvent;
1386
+ }
1387
+
1388
+ /**
1389
+ * For relations and redactions, returns the event_id this event is referring to.
1390
+ */
1391
+ getAssociatedId() {
1392
+ var relation = this.getRelation();
1393
+ if (this.replyEventId) {
1394
+ return this.replyEventId;
1395
+ } else if (relation) {
1396
+ return relation.event_id;
1397
+ } else if (this.isRedaction()) {
1398
+ return this.event.redacts;
1399
+ }
1400
+ }
1401
+
1402
+ /**
1403
+ * Checks if this event is associated with another event. See `getAssociatedId`.
1404
+ */
1405
+ hasAssociation() {
1406
+ return !!this.getAssociatedId();
1407
+ }
1408
+
1409
+ /**
1410
+ * Update the related id with a new one.
1411
+ *
1412
+ * Used to replace a local id with remote one before sending
1413
+ * an event with a related id.
1414
+ *
1415
+ * @param eventId - the new event id
1416
+ */
1417
+ updateAssociatedId(eventId) {
1418
+ var relation = this.getRelation();
1419
+ if (relation) {
1420
+ relation.event_id = eventId;
1421
+ } else if (this.isRedaction()) {
1422
+ this.event.redacts = eventId;
1423
+ }
1424
+ }
1425
+
1426
+ /**
1427
+ * Flags an event as cancelled due to future conditions. For example, a verification
1428
+ * request event in the same sync transaction may be flagged as cancelled to warn
1429
+ * listeners that a cancellation event is coming down the same pipe shortly.
1430
+ * @param cancelled - Whether the event is to be cancelled or not.
1431
+ */
1432
+ flagCancelled() {
1433
+ var cancelled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
1434
+ this._isCancelled = cancelled;
1435
+ }
1436
+
1437
+ /**
1438
+ * Gets whether or not the event is flagged as cancelled. See flagCancelled() for
1439
+ * more information.
1440
+ * @returns True if the event is cancelled, false otherwise.
1441
+ */
1442
+ isCancelled() {
1443
+ return this._isCancelled;
1444
+ }
1445
+
1446
+ /**
1447
+ * Get a copy/snapshot of this event. The returned copy will be loosely linked
1448
+ * back to this instance, though will have "frozen" event information. Other
1449
+ * properties of this BriijEvent instance will be copied verbatim, which can
1450
+ * mean they are in reference to this instance despite being on the copy too.
1451
+ * The reference the snapshot uses does not change, however members aside from
1452
+ * the underlying event will not be deeply cloned, thus may be mutated internally.
1453
+ * For example, the sender profile will be copied over at snapshot time, and
1454
+ * the sender profile internally may mutate without notice to the consumer.
1455
+ *
1456
+ * This is meant to be used to snapshot the event details themselves, not the
1457
+ * features (such as sender) surrounding the event.
1458
+ * @returns A snapshot of this event.
1459
+ */
1460
+ toSnapshot() {
1461
+ var ev = new BriijEvent(JSON.parse(JSON.stringify(this.event)));
1462
+ for (var [p, v] of Object.entries(this)) {
1463
+ if (p !== "event") {
1464
+ // exclude the thing we just cloned
1465
+ // @ts-ignore - XXX: this is just nasty
1466
+ ev[p] = v;
1467
+ }
1468
+ }
1469
+ return ev;
1470
+ }
1471
+
1472
+ /**
1473
+ * Determines if this event is equivalent to the given event. This only checks
1474
+ * the event object itself, not the other properties of the event. Intended for
1475
+ * use with toSnapshot() to identify events changing.
1476
+ * @param otherEvent - The other event to check against.
1477
+ * @returns True if the events are the same, false otherwise.
1478
+ */
1479
+ isEquivalentTo(otherEvent) {
1480
+ if (!otherEvent) return false;
1481
+ if (otherEvent === this) return true;
1482
+ var myProps = deepSortedObjectEntries(this.event);
1483
+ var theirProps = deepSortedObjectEntries(otherEvent.event);
1484
+ return JSON.stringify(myProps) === JSON.stringify(theirProps);
1485
+ }
1486
+
1487
+ /**
1488
+ * Summarise the event as JSON.
1489
+ *
1490
+ * If encrypted, include both the decrypted and encrypted view of the event.
1491
+ *
1492
+ * This is named `toJSON` for use with `JSON.stringify` which checks objects
1493
+ * for functions named `toJSON` and will call them to customise the output
1494
+ * if they are defined.
1495
+ *
1496
+ * **WARNING** Do not log the result of this method; otherwise, it will end up
1497
+ * in rageshakes, leading to a privacy violation.
1498
+ *
1499
+ * @deprecated Prefer to use {@link BriijEvent#getEffectiveEvent} or similar.
1500
+ * This method will be removed soon; it is too easy to use it accidentally
1501
+ * and cause a privacy violation (cf https://github.com/vector-im/element-web/issues/26380).
1502
+ * In any case, the value it returns is not a faithful serialization of the object.
1503
+ */
1504
+ toJSON() {
1505
+ var event = this.getEffectiveEvent();
1506
+ if (!this.isEncrypted()) {
1507
+ return event;
1508
+ }
1509
+ return {
1510
+ decrypted: event,
1511
+ encrypted: this.event
1512
+ };
1513
+ }
1514
+ setTxnId(txnId) {
1515
+ this.txnId = txnId;
1516
+ }
1517
+ getTxnId() {
1518
+ return this.txnId;
1519
+ }
1520
+
1521
+ /**
1522
+ * Set the instance of a thread associated with the current event
1523
+ * @param thread - the thread
1524
+ */
1525
+ setThread(thread) {
1526
+ // don't allow state events to be threaded as per the spec
1527
+ if (this.isState()) {
1528
+ return;
1529
+ }
1530
+ if (this.thread) {
1531
+ this.reEmitter.stopReEmitting(this.thread, [ThreadEvent.Update]);
1532
+ }
1533
+ this.thread = thread;
1534
+ this.setThreadId(thread === null || thread === void 0 ? void 0 : thread.id);
1535
+ if (thread) {
1536
+ this.reEmitter.reEmit(thread, [ThreadEvent.Update]);
1537
+ }
1538
+ }
1539
+
1540
+ /**
1541
+ * Get the instance of the thread associated with the current event
1542
+ */
1543
+ getThread() {
1544
+ return this.thread;
1545
+ }
1546
+ setThreadId(threadId) {
1547
+ this.threadId = threadId;
1548
+ }
1549
+
1550
+ /**
1551
+ * Unstable getter to try and get the sticky information for the event.
1552
+ * If the event is not a sticky event (or not supported by the server),
1553
+ * then this returns `undefined`.
1554
+ *
1555
+ * `duration_ms` is safely bounded to a hour.
1556
+ */
1557
+ get unstableStickyInfo() {
1558
+ var _this$event$msc4354_s, _this$event$unsigned2;
1559
+ if (!((_this$event$msc4354_s = this.event.msc4354_sticky) !== null && _this$event$msc4354_s !== void 0 && _this$event$msc4354_s.duration_ms)) {
1560
+ return undefined;
1561
+ }
1562
+ return {
1563
+ duration_ms: Math.min(MAX_STICKY_DURATION_MS, this.event.msc4354_sticky.duration_ms),
1564
+ // This is assumed to be bounded server-side.
1565
+ duration_ttl_ms: (_this$event$unsigned2 = this.event.unsigned) === null || _this$event$unsigned2 === void 0 ? void 0 : _this$event$unsigned2.msc4354_sticky_duration_ttl_ms
1566
+ };
1567
+ }
1568
+ }
1569
+
1570
+ /* REDACT_KEEP_KEYS gives the keys we keep when an event is redacted
1571
+ *
1572
+ * This is specified here:
1573
+ * http://matrix.org/speculator/spec/HEAD/client_server/latest.html#redactions
1574
+ *
1575
+ * Also:
1576
+ * - We keep 'unsigned' since that is created by the local server
1577
+ * - We keep user_id for backwards-compat with v1
1578
+ */
1579
+ var REDACT_KEEP_KEYS = new Set(["event_id", "type", "room_id", "user_id", "sender", "state_key", "prev_state", "content", "unsigned", "origin_server_ts"]);
1580
+
1581
+ // a map from state event type to the .content keys we keep when an event is redacted
1582
+ var REDACT_KEEP_CONTENT_MAP = {
1583
+ [EventType.RoomMember]: {
1584
+ membership: 1
1585
+ },
1586
+ [EventType.RoomJoinRules]: {
1587
+ join_rule: 1
1588
+ },
1589
+ [EventType.RoomPowerLevels]: {
1590
+ ban: 1,
1591
+ events: 1,
1592
+ events_default: 1,
1593
+ kick: 1,
1594
+ redact: 1,
1595
+ state_default: 1,
1596
+ users: 1,
1597
+ users_default: 1
1598
+ }
1599
+ };
1600
+ //# sourceMappingURL=event.js.map