matrix-js-sdk 28.1.0 → 28.2.0-rc.1

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 (287) hide show
  1. package/CHANGELOG.md +17 -1
  2. package/dist/browser-matrix.js +1458 -391
  3. package/dist/browser-matrix.js.map +32 -22
  4. package/dist/browser-matrix.min.js +5 -5
  5. package/dist/browser-matrix.min.js.map +1 -1
  6. package/git-revision.txt +1 -1
  7. package/lib/ReEmitter.js +1 -1
  8. package/lib/ReEmitter.js.map +1 -1
  9. package/lib/ToDeviceMessageQueue.js +1 -1
  10. package/lib/ToDeviceMessageQueue.js.map +1 -1
  11. package/lib/autodiscovery.js +17 -18
  12. package/lib/autodiscovery.js.map +1 -1
  13. package/lib/client.d.ts +14 -0
  14. package/lib/client.d.ts.map +1 -1
  15. package/lib/client.js +59 -85
  16. package/lib/client.js.map +1 -1
  17. package/lib/common-crypto/CryptoBackend.d.ts +41 -0
  18. package/lib/common-crypto/CryptoBackend.d.ts.map +1 -1
  19. package/lib/common-crypto/CryptoBackend.js.map +1 -1
  20. package/lib/common-crypto/base64.d.ts +22 -0
  21. package/lib/common-crypto/base64.d.ts.map +1 -0
  22. package/lib/common-crypto/base64.js +55 -0
  23. package/lib/common-crypto/base64.js.map +1 -0
  24. package/lib/content-helpers.js +16 -16
  25. package/lib/content-helpers.js.map +1 -1
  26. package/lib/crypto/CrossSigning.js +3 -3
  27. package/lib/crypto/CrossSigning.js.map +1 -1
  28. package/lib/crypto/DeviceList.js +11 -14
  29. package/lib/crypto/DeviceList.js.map +1 -1
  30. package/lib/crypto/EncryptionSetup.js +3 -10
  31. package/lib/crypto/EncryptionSetup.js.map +1 -1
  32. package/lib/crypto/OlmDevice.js +1 -1
  33. package/lib/crypto/OlmDevice.js.map +1 -1
  34. package/lib/crypto/OutgoingRoomKeyRequestManager.js +19 -20
  35. package/lib/crypto/OutgoingRoomKeyRequestManager.js.map +1 -1
  36. package/lib/crypto/RoomList.js +1 -1
  37. package/lib/crypto/RoomList.js.map +1 -1
  38. package/lib/crypto/SecretSharing.js +1 -1
  39. package/lib/crypto/SecretSharing.js.map +1 -1
  40. package/lib/crypto/SecretStorage.js +0 -4
  41. package/lib/crypto/SecretStorage.js.map +1 -1
  42. package/lib/crypto/algorithms/base.js +0 -14
  43. package/lib/crypto/algorithms/base.js.map +1 -1
  44. package/lib/crypto/algorithms/megolm.js +22 -31
  45. package/lib/crypto/algorithms/megolm.js.map +1 -1
  46. package/lib/crypto/backup.d.ts +17 -0
  47. package/lib/crypto/backup.d.ts.map +1 -1
  48. package/lib/crypto/backup.js +29 -8
  49. package/lib/crypto/backup.js.map +1 -1
  50. package/lib/crypto/dehydration.js +1 -5
  51. package/lib/crypto/dehydration.js.map +1 -1
  52. package/lib/crypto/deviceinfo.js +1 -1
  53. package/lib/crypto/deviceinfo.js.map +1 -1
  54. package/lib/crypto/index.d.ts +10 -2
  55. package/lib/crypto/index.d.ts.map +1 -1
  56. package/lib/crypto/index.js +133 -68
  57. package/lib/crypto/index.js.map +1 -1
  58. package/lib/crypto/keybackup.d.ts +1 -16
  59. package/lib/crypto/keybackup.d.ts.map +1 -1
  60. package/lib/crypto/keybackup.js.map +1 -1
  61. package/lib/crypto/olmlib.js +21 -21
  62. package/lib/crypto/olmlib.js.map +1 -1
  63. package/lib/crypto/recoverykey.d.ts.map +1 -1
  64. package/lib/crypto/recoverykey.js +3 -2
  65. package/lib/crypto/recoverykey.js.map +1 -1
  66. package/lib/crypto/store/indexeddb-crypto-store-backend.js +1 -1
  67. package/lib/crypto/store/indexeddb-crypto-store-backend.js.map +1 -1
  68. package/lib/crypto/store/indexeddb-crypto-store.js +0 -2
  69. package/lib/crypto/store/indexeddb-crypto-store.js.map +1 -1
  70. package/lib/crypto/store/memory-crypto-store.js +16 -16
  71. package/lib/crypto/store/memory-crypto-store.js.map +1 -1
  72. package/lib/crypto/verification/Base.js +6 -13
  73. package/lib/crypto/verification/Base.js.map +1 -1
  74. package/lib/crypto/verification/QRCode.js +0 -1
  75. package/lib/crypto/verification/QRCode.js.map +1 -1
  76. package/lib/crypto/verification/SAS.js +0 -4
  77. package/lib/crypto/verification/SAS.js.map +1 -1
  78. package/lib/crypto/verification/request/InRoomChannel.js +0 -1
  79. package/lib/crypto/verification/request/InRoomChannel.js.map +1 -1
  80. package/lib/crypto/verification/request/ToDeviceChannel.js +0 -1
  81. package/lib/crypto/verification/request/ToDeviceChannel.js.map +1 -1
  82. package/lib/crypto/verification/request/VerificationRequest.js +5 -7
  83. package/lib/crypto/verification/request/VerificationRequest.js.map +1 -1
  84. package/lib/crypto-api/keybackup.d.ts +15 -0
  85. package/lib/crypto-api/keybackup.d.ts.map +1 -1
  86. package/lib/crypto-api/keybackup.js.map +1 -1
  87. package/lib/crypto-api.d.ts +53 -0
  88. package/lib/crypto-api.d.ts.map +1 -1
  89. package/lib/crypto-api.js +55 -29
  90. package/lib/crypto-api.js.map +1 -1
  91. package/lib/embedded.d.ts +2 -1
  92. package/lib/embedded.d.ts.map +1 -1
  93. package/lib/embedded.js +29 -14
  94. package/lib/embedded.js.map +1 -1
  95. package/lib/event-mapper.js +17 -17
  96. package/lib/event-mapper.js.map +1 -1
  97. package/lib/extensible_events_v1/MessageEvent.js +31 -31
  98. package/lib/extensible_events_v1/MessageEvent.js.map +1 -1
  99. package/lib/extensible_events_v1/PollEndEvent.js +24 -24
  100. package/lib/extensible_events_v1/PollEndEvent.js.map +1 -1
  101. package/lib/extensible_events_v1/PollResponseEvent.js +0 -1
  102. package/lib/extensible_events_v1/PollResponseEvent.js.map +1 -1
  103. package/lib/extensible_events_v1/PollStartEvent.js +44 -44
  104. package/lib/extensible_events_v1/PollStartEvent.js.map +1 -1
  105. package/lib/filter.js +17 -19
  106. package/lib/filter.js.map +1 -1
  107. package/lib/http-api/errors.js +4 -6
  108. package/lib/http-api/errors.js.map +1 -1
  109. package/lib/http-api/fetch.js +1 -1
  110. package/lib/http-api/fetch.js.map +1 -1
  111. package/lib/http-api/index.js +1 -1
  112. package/lib/http-api/index.js.map +1 -1
  113. package/lib/interactive-auth.js +6 -16
  114. package/lib/interactive-auth.js.map +1 -1
  115. package/lib/matrixrtc/CallMembership.d.ts +31 -0
  116. package/lib/matrixrtc/CallMembership.d.ts.map +1 -0
  117. package/lib/matrixrtc/CallMembership.js +80 -0
  118. package/lib/matrixrtc/CallMembership.js.map +1 -0
  119. package/lib/matrixrtc/MatrixRTCSession.d.ts +81 -0
  120. package/lib/matrixrtc/MatrixRTCSession.d.ts.map +1 -0
  121. package/lib/matrixrtc/MatrixRTCSession.js +345 -0
  122. package/lib/matrixrtc/MatrixRTCSession.js.map +1 -0
  123. package/lib/matrixrtc/MatrixRTCSessionManager.d.ts +38 -0
  124. package/lib/matrixrtc/MatrixRTCSessionManager.d.ts.map +1 -0
  125. package/lib/matrixrtc/MatrixRTCSessionManager.js +116 -0
  126. package/lib/matrixrtc/MatrixRTCSessionManager.js.map +1 -0
  127. package/lib/matrixrtc/focus.d.ts +9 -0
  128. package/lib/matrixrtc/focus.d.ts.map +1 -0
  129. package/lib/matrixrtc/focus.js +6 -0
  130. package/lib/matrixrtc/focus.js.map +1 -0
  131. package/lib/models/MSC3089Branch.js +16 -16
  132. package/lib/models/MSC3089Branch.js.map +1 -1
  133. package/lib/models/MSC3089TreeSpace.js +16 -17
  134. package/lib/models/MSC3089TreeSpace.js.map +1 -1
  135. package/lib/models/beacon.js +3 -8
  136. package/lib/models/beacon.js.map +1 -1
  137. package/lib/models/device.js +14 -16
  138. package/lib/models/device.js.map +1 -1
  139. package/lib/models/event-context.js +1 -2
  140. package/lib/models/event-context.js.map +1 -1
  141. package/lib/models/event-timeline-set.js +1 -7
  142. package/lib/models/event-timeline-set.js.map +1 -1
  143. package/lib/models/event-timeline.js +4 -8
  144. package/lib/models/event-timeline.js.map +1 -1
  145. package/lib/models/event.d.ts +1 -1
  146. package/lib/models/event.js +7 -25
  147. package/lib/models/event.js.map +1 -1
  148. package/lib/models/poll.js +4 -8
  149. package/lib/models/poll.js.map +1 -1
  150. package/lib/models/read-receipt.js +0 -1
  151. package/lib/models/read-receipt.js.map +1 -1
  152. package/lib/models/related-relations.js +0 -3
  153. package/lib/models/related-relations.js.map +1 -1
  154. package/lib/models/relations-container.js +2 -2
  155. package/lib/models/relations-container.js.map +1 -1
  156. package/lib/models/relations.js +3 -4
  157. package/lib/models/relations.js.map +1 -1
  158. package/lib/models/room-member.js +2 -20
  159. package/lib/models/room-member.js.map +1 -1
  160. package/lib/models/room-state.js +3 -3
  161. package/lib/models/room-state.js.map +1 -1
  162. package/lib/models/room.d.ts +1 -1
  163. package/lib/models/room.d.ts.map +1 -1
  164. package/lib/models/room.js +40 -76
  165. package/lib/models/room.js.map +1 -1
  166. package/lib/models/thread.js +21 -32
  167. package/lib/models/thread.js.map +1 -1
  168. package/lib/models/user.js +1 -20
  169. package/lib/models/user.js.map +1 -1
  170. package/lib/oidc/authorize.js +16 -16
  171. package/lib/oidc/authorize.js.map +1 -1
  172. package/lib/oidc/discovery.js +16 -16
  173. package/lib/oidc/discovery.js.map +1 -1
  174. package/lib/pushprocessor.js +17 -17
  175. package/lib/pushprocessor.js.map +1 -1
  176. package/lib/receipt-accumulator.js +1 -1
  177. package/lib/receipt-accumulator.js.map +1 -1
  178. package/lib/rendezvous/MSC3906Rendezvous.js +2 -5
  179. package/lib/rendezvous/MSC3906Rendezvous.js.map +1 -1
  180. package/lib/rendezvous/channels/MSC3903ECDHv2RendezvousChannel.js +1 -4
  181. package/lib/rendezvous/channels/MSC3903ECDHv2RendezvousChannel.js.map +1 -1
  182. package/lib/rendezvous/transports/MSC3886SimpleHttpRendezvousTransport.js +1 -8
  183. package/lib/rendezvous/transports/MSC3886SimpleHttpRendezvousTransport.js.map +1 -1
  184. package/lib/room-hierarchy.js +4 -8
  185. package/lib/room-hierarchy.js.map +1 -1
  186. package/lib/rust-crypto/CrossSigningIdentity.d.ts +1 -5
  187. package/lib/rust-crypto/CrossSigningIdentity.d.ts.map +1 -1
  188. package/lib/rust-crypto/CrossSigningIdentity.js +1 -4
  189. package/lib/rust-crypto/CrossSigningIdentity.js.map +1 -1
  190. package/lib/rust-crypto/KeyClaimManager.js +1 -2
  191. package/lib/rust-crypto/KeyClaimManager.js.map +1 -1
  192. package/lib/rust-crypto/OutgoingRequestProcessor.js +16 -16
  193. package/lib/rust-crypto/OutgoingRequestProcessor.js.map +1 -1
  194. package/lib/rust-crypto/RoomEncryptor.js +0 -3
  195. package/lib/rust-crypto/RoomEncryptor.js.map +1 -1
  196. package/lib/rust-crypto/backup.d.ts +20 -2
  197. package/lib/rust-crypto/backup.d.ts.map +1 -1
  198. package/lib/rust-crypto/backup.js +39 -4
  199. package/lib/rust-crypto/backup.js.map +1 -1
  200. package/lib/rust-crypto/index.d.ts.map +1 -1
  201. package/lib/rust-crypto/index.js +1 -0
  202. package/lib/rust-crypto/index.js.map +1 -1
  203. package/lib/rust-crypto/rust-crypto.d.ts +39 -3
  204. package/lib/rust-crypto/rust-crypto.d.ts.map +1 -1
  205. package/lib/rust-crypto/rust-crypto.js +260 -61
  206. package/lib/rust-crypto/rust-crypto.js.map +1 -1
  207. package/lib/rust-crypto/verification.js +5 -7
  208. package/lib/rust-crypto/verification.js.map +1 -1
  209. package/lib/scheduler.js +2 -2
  210. package/lib/scheduler.js.map +1 -1
  211. package/lib/sliding-sync-sdk.js +4 -7
  212. package/lib/sliding-sync-sdk.js.map +1 -1
  213. package/lib/sliding-sync.js +23 -28
  214. package/lib/sliding-sync.js.map +1 -1
  215. package/lib/store/indexeddb-local-backend.js +6 -10
  216. package/lib/store/indexeddb-local-backend.js.map +1 -1
  217. package/lib/store/indexeddb-remote-backend.js +8 -11
  218. package/lib/store/indexeddb-remote-backend.js.map +1 -1
  219. package/lib/store/indexeddb-store-worker.js +1 -2
  220. package/lib/store/indexeddb-store-worker.js.map +1 -1
  221. package/lib/store/indexeddb.js +0 -1
  222. package/lib/store/indexeddb.js.map +1 -1
  223. package/lib/store/memory.js +0 -3
  224. package/lib/store/memory.js.map +1 -1
  225. package/lib/sync-accumulator.d.ts +11 -1
  226. package/lib/sync-accumulator.d.ts.map +1 -1
  227. package/lib/sync-accumulator.js +55 -4
  228. package/lib/sync-accumulator.js.map +1 -1
  229. package/lib/sync.d.ts.map +1 -1
  230. package/lib/sync.js +53 -39
  231. package/lib/sync.js.map +1 -1
  232. package/lib/timeline-window.js +2 -6
  233. package/lib/timeline-window.js.map +1 -1
  234. package/lib/utils.js +18 -18
  235. package/lib/utils.js.map +1 -1
  236. package/lib/webrtc/audioContext.js +1 -1
  237. package/lib/webrtc/audioContext.js.map +1 -1
  238. package/lib/webrtc/call.js +35 -73
  239. package/lib/webrtc/call.js.map +1 -1
  240. package/lib/webrtc/callEventHandler.js +1 -6
  241. package/lib/webrtc/callEventHandler.js.map +1 -1
  242. package/lib/webrtc/callFeed.js +2 -17
  243. package/lib/webrtc/callFeed.js.map +1 -1
  244. package/lib/webrtc/groupCall.d.ts +7 -1
  245. package/lib/webrtc/groupCall.d.ts.map +1 -1
  246. package/lib/webrtc/groupCall.js +47 -33
  247. package/lib/webrtc/groupCall.js.map +1 -1
  248. package/lib/webrtc/groupCallEventHandler.d.ts.map +1 -1
  249. package/lib/webrtc/groupCallEventHandler.js +3 -2
  250. package/lib/webrtc/groupCallEventHandler.js.map +1 -1
  251. package/lib/webrtc/mediaHandler.js +3 -7
  252. package/lib/webrtc/mediaHandler.js.map +1 -1
  253. package/lib/webrtc/stats/callStatsReportGatherer.js +19 -22
  254. package/lib/webrtc/stats/callStatsReportGatherer.js.map +1 -1
  255. package/lib/webrtc/stats/groupCallStats.js +4 -5
  256. package/lib/webrtc/stats/groupCallStats.js.map +1 -1
  257. package/lib/webrtc/stats/media/mediaSsrcHandler.js +1 -1
  258. package/lib/webrtc/stats/media/mediaSsrcHandler.js.map +1 -1
  259. package/lib/webrtc/stats/media/mediaTrackStats.js +3 -3
  260. package/lib/webrtc/stats/media/mediaTrackStats.js.map +1 -1
  261. package/lib/webrtc/stats/media/mediaTrackStatsHandler.js +1 -1
  262. package/lib/webrtc/stats/media/mediaTrackStatsHandler.js.map +1 -1
  263. package/package.json +4 -4
  264. package/src/client.ts +66 -23
  265. package/src/common-crypto/CryptoBackend.ts +45 -0
  266. package/src/common-crypto/base64.ts +46 -0
  267. package/src/crypto/backup.ts +30 -0
  268. package/src/crypto/index.ts +90 -3
  269. package/src/crypto/keybackup.ts +3 -20
  270. package/src/crypto/recoverykey.ts +3 -4
  271. package/src/crypto-api/keybackup.ts +19 -0
  272. package/src/crypto-api.ts +63 -0
  273. package/src/embedded.ts +28 -1
  274. package/src/matrixrtc/CallMembership.ts +95 -0
  275. package/src/matrixrtc/MatrixRTCSession.ts +418 -0
  276. package/src/matrixrtc/MatrixRTCSessionManager.ts +128 -0
  277. package/src/matrixrtc/focus.ts +24 -0
  278. package/src/models/event.ts +1 -1
  279. package/src/models/room.ts +11 -5
  280. package/src/rust-crypto/CrossSigningIdentity.ts +0 -4
  281. package/src/rust-crypto/backup.ts +56 -2
  282. package/src/rust-crypto/index.ts +3 -0
  283. package/src/rust-crypto/rust-crypto.ts +282 -44
  284. package/src/sync-accumulator.ts +63 -1
  285. package/src/sync.ts +26 -1
  286. package/src/webrtc/groupCall.ts +43 -6
  287. package/src/webrtc/groupCallEventHandler.ts +3 -0
@@ -4,6 +4,8 @@ import { Room } from "../models/room";
4
4
  import { CryptoApi } from "../crypto-api";
5
5
  import { CrossSigningInfo, UserTrustLevel } from "../crypto/CrossSigning";
6
6
  import { IEncryptedEventInfo } from "../crypto/api";
7
+ import { KeyBackupInfo, KeyBackupSession } from "../crypto-api/keybackup";
8
+ import { IMegolmSessionData } from "../@types/crypto";
7
9
  /**
8
10
  * Common interface for the crypto implementations
9
11
  *
@@ -75,6 +77,12 @@ export interface CryptoBackend extends SyncCryptoCallbacks, CryptoApi {
75
77
  * @deprecated Unneeded for the new crypto
76
78
  */
77
79
  checkOwnCrossSigningTrust(opts?: CheckOwnCrossSigningTrustOpts): Promise<void>;
80
+ /**
81
+ * Get a backup decryptor capable of decrypting megolm session data encrypted with the given backup information.
82
+ * @param backupInfo - The backup information
83
+ * @param privKey - The private decryption key.
84
+ */
85
+ getBackupDecryptor(backupInfo: KeyBackupInfo, privKey: ArrayLike<number>): Promise<BackupDecryptor>;
78
86
  }
79
87
  /** The methods which crypto implementations should expose to the Sync api
80
88
  *
@@ -170,10 +178,43 @@ export interface EventDecryptionResult {
170
178
  * ed25519 key claimed by the sender of this event. See {@link MatrixEvent#getClaimedEd25519Key}.
171
179
  */
172
180
  claimedEd25519Key?: string;
181
+ /**
182
+ * Whether the keys for this event have been received via an unauthenticated source (eg via key forwards, or
183
+ * restored from backup)
184
+ */
173
185
  untrusted?: boolean;
174
186
  /**
175
187
  * The sender doesn't authorize the unverified devices to decrypt his messages
176
188
  */
177
189
  encryptedDisabledForUnverifiedDevices?: boolean;
178
190
  }
191
+ /**
192
+ * Responsible for decrypting megolm session data retrieved from a remote backup.
193
+ * The result of {@link CryptoBackend#getBackupDecryptor}.
194
+ */
195
+ export interface BackupDecryptor {
196
+ /**
197
+ * Whether keys retrieved from this backup can be trusted.
198
+ *
199
+ * Depending on the backup algorithm, keys retrieved from the backup can be trusted or not.
200
+ * If false, keys retrieved from the backup must be considered unsafe (authenticity cannot be guaranteed).
201
+ * It could be by design (deniability) or for some technical reason (eg asymmetric encryption).
202
+ */
203
+ readonly sourceTrusted: boolean;
204
+ /**
205
+ *
206
+ * Decrypt megolm session data retrieved from backup.
207
+ *
208
+ * @param ciphertexts - a Record of sessionId to session data.
209
+ *
210
+ * @returns An array of decrypted `IMegolmSessionData`
211
+ */
212
+ decryptSessions(ciphertexts: Record<string, KeyBackupSession>): Promise<IMegolmSessionData[]>;
213
+ /**
214
+ * Free any resources held by this decryptor.
215
+ *
216
+ * Should be called once the decryptor is no longer needed.
217
+ */
218
+ free(): void;
219
+ }
179
220
  //# sourceMappingURL=CryptoBackend.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Crypt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;;OAMG;IACH,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAEhC;;;;;;;OAOG;IACH,eAAe,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC;IAE9F;;;;OAIG;IACH,IAAI,IAAI,IAAI,CAAC;CAChB"}
@@ -1 +1 @@
1
- {"version":3,"file":"CryptoBackend.js","names":[],"sources":["../../src/common-crypto/CryptoBackend.ts"],"sourcesContent":["/*\nCopyright 2022 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport type { IDeviceLists, IToDeviceEvent } from \"../sync-accumulator\";\nimport { IClearEvent, MatrixEvent } from \"../models/event\";\nimport { Room } from \"../models/room\";\nimport { CryptoApi } from \"../crypto-api\";\nimport { CrossSigningInfo, UserTrustLevel } from \"../crypto/CrossSigning\";\nimport { IEncryptedEventInfo } from \"../crypto/api\";\n\n/**\n * Common interface for the crypto implementations\n *\n * @internal\n */\nexport interface CryptoBackend extends SyncCryptoCallbacks, CryptoApi {\n /**\n * Whether sendMessage in a room with unknown and unverified devices\n * should throw an error and not send the message. This has 'Global' for\n * symmetry with setGlobalBlacklistUnverifiedDevices but there is currently\n * no room-level equivalent for this setting.\n *\n * @remarks this is here, rather than in `CryptoApi`, because I don't think we're\n * going to support it in the rust crypto implementation.\n */\n globalErrorOnUnknownDevices: boolean;\n\n /**\n * Shut down any background processes related to crypto\n */\n stop(): void;\n\n /**\n * Get the verification level for a given user\n *\n * @param userId - user to be checked\n *\n * @deprecated Superceded by {@link CryptoApi#getUserVerificationStatus}.\n */\n checkUserTrust(userId: string): UserTrustLevel;\n\n /**\n * Encrypt an event according to the configuration of the room.\n *\n * @param event - event to be sent\n *\n * @param room - destination room.\n *\n * @returns Promise which resolves when the event has been\n * encrypted, or null if nothing was needed\n */\n encryptEvent(event: MatrixEvent, room: Room): Promise<void>;\n\n /**\n * Decrypt a received event\n *\n * @returns a promise which resolves once we have finished decrypting.\n * Rejects with an error if there is a problem decrypting the event.\n */\n decryptEvent(event: MatrixEvent): Promise<EventDecryptionResult>;\n\n /**\n * Get information about the encryption of an event\n *\n * @param event - event to be checked\n */\n getEventEncryptionInfo(event: MatrixEvent): IEncryptedEventInfo;\n\n /**\n * Get the cross signing information for a given user.\n *\n * The cross-signing API is currently UNSTABLE and may change without notice.\n *\n * @param userId - the user ID to get the cross-signing info for.\n *\n * @returns the cross signing information for the user.\n * @deprecated Prefer {@link CryptoApi#userHasCrossSigningKeys}\n */\n getStoredCrossSigningForUser(userId: string): CrossSigningInfo | null;\n\n /**\n * Check the cross signing trust of the current user\n *\n * @param opts - Options object.\n *\n * @deprecated Unneeded for the new crypto\n */\n checkOwnCrossSigningTrust(opts?: CheckOwnCrossSigningTrustOpts): Promise<void>;\n}\n\n/** The methods which crypto implementations should expose to the Sync api\n *\n * @internal\n */\nexport interface SyncCryptoCallbacks {\n /**\n * Called by the /sync loop whenever there are incoming to-device messages.\n *\n * The implementation may preprocess the received messages (eg, decrypt them) and return an\n * updated list of messages for dispatch to the rest of the system.\n *\n * Note that, unlike {@link ClientEvent.ToDeviceEvent} events, this is called on the raw to-device\n * messages, rather than the results of any decryption attempts.\n *\n * @param events - the received to-device messages\n * @returns A list of preprocessed to-device messages.\n */\n preprocessToDeviceMessages(events: IToDeviceEvent[]): Promise<IToDeviceEvent[]>;\n\n /**\n * Called by the /sync loop when one time key counts and unused fallback key details are received.\n *\n * @param oneTimeKeysCounts - the received one time key counts\n * @param unusedFallbackKeys - the received unused fallback keys\n */\n processKeyCounts(oneTimeKeysCounts?: Record<string, number>, unusedFallbackKeys?: string[]): Promise<void>;\n\n /**\n * Handle the notification from /sync that device lists have\n * been changed.\n *\n * @param deviceLists - device_lists field from /sync\n */\n processDeviceLists(deviceLists: IDeviceLists): Promise<void>;\n\n /**\n * Called by the /sync loop whenever an m.room.encryption event is received.\n *\n * This is called before RoomStateEvents are emitted for any of the events in the /sync\n * response (even if the other events technically happened first). This works around a problem\n * if the client uses a RoomStateEvent (typically a membership event) as a trigger to send a message\n * in a new room (or one where encryption has been newly enabled): that would otherwise leave the\n * crypto layer confused because it expects crypto to be set up, but it has not yet been.\n *\n * @param room - in which the event was received\n * @param event - encryption event to be processed\n */\n onCryptoEvent(room: Room, event: MatrixEvent): Promise<void>;\n\n /**\n * Called by the /sync loop after each /sync response is processed.\n *\n * Used to complete batch processing, or to initiate background processes\n *\n * @param syncState - information about the completed sync.\n */\n onSyncCompleted(syncState: OnSyncCompletedData): void;\n}\n\n/**\n * @internal\n */\nexport interface OnSyncCompletedData {\n /**\n * The 'next_batch' result from /sync, which will become the 'since' token for the next call to /sync.\n */\n nextSyncToken?: string;\n\n /**\n * True if we are working our way through a backlog of events after connecting.\n */\n catchingUp?: boolean;\n}\n\n/**\n * Options object for {@link CryptoBackend#checkOwnCrossSigningTrust}.\n */\nexport interface CheckOwnCrossSigningTrustOpts {\n allowPrivateKeyRequests?: boolean;\n}\n\n/**\n * The result of a (successful) call to {@link CryptoBackend.decryptEvent}\n */\nexport interface EventDecryptionResult {\n /**\n * The plaintext payload for the event (typically containing <tt>type</tt> and <tt>content</tt> fields).\n */\n clearEvent: IClearEvent;\n /**\n * List of curve25519 keys involved in telling us about the senderCurve25519Key and claimedEd25519Key.\n * See {@link MatrixEvent#getForwardingCurve25519KeyChain}.\n */\n forwardingCurve25519KeyChain?: string[];\n /**\n * Key owned by the sender of this event. See {@link MatrixEvent#getSenderKey}.\n */\n senderCurve25519Key?: string;\n /**\n * ed25519 key claimed by the sender of this event. See {@link MatrixEvent#getClaimedEd25519Key}.\n */\n claimedEd25519Key?: string;\n untrusted?: boolean;\n /**\n * The sender doesn't authorize the unverified devices to decrypt his messages\n */\n encryptedDisabledForUnverifiedDevices?: boolean;\n}\n"],"mappings":""}
1
+ {"version":3,"file":"CryptoBackend.js","names":[],"sources":["../../src/common-crypto/CryptoBackend.ts"],"sourcesContent":["/*\nCopyright 2022 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport type { IDeviceLists, IToDeviceEvent } from \"../sync-accumulator\";\nimport { IClearEvent, MatrixEvent } from \"../models/event\";\nimport { Room } from \"../models/room\";\nimport { CryptoApi } from \"../crypto-api\";\nimport { CrossSigningInfo, UserTrustLevel } from \"../crypto/CrossSigning\";\nimport { IEncryptedEventInfo } from \"../crypto/api\";\nimport { KeyBackupInfo, KeyBackupSession } from \"../crypto-api/keybackup\";\nimport { IMegolmSessionData } from \"../@types/crypto\";\n\n/**\n * Common interface for the crypto implementations\n *\n * @internal\n */\nexport interface CryptoBackend extends SyncCryptoCallbacks, CryptoApi {\n /**\n * Whether sendMessage in a room with unknown and unverified devices\n * should throw an error and not send the message. This has 'Global' for\n * symmetry with setGlobalBlacklistUnverifiedDevices but there is currently\n * no room-level equivalent for this setting.\n *\n * @remarks this is here, rather than in `CryptoApi`, because I don't think we're\n * going to support it in the rust crypto implementation.\n */\n globalErrorOnUnknownDevices: boolean;\n\n /**\n * Shut down any background processes related to crypto\n */\n stop(): void;\n\n /**\n * Get the verification level for a given user\n *\n * @param userId - user to be checked\n *\n * @deprecated Superceded by {@link CryptoApi#getUserVerificationStatus}.\n */\n checkUserTrust(userId: string): UserTrustLevel;\n\n /**\n * Encrypt an event according to the configuration of the room.\n *\n * @param event - event to be sent\n *\n * @param room - destination room.\n *\n * @returns Promise which resolves when the event has been\n * encrypted, or null if nothing was needed\n */\n encryptEvent(event: MatrixEvent, room: Room): Promise<void>;\n\n /**\n * Decrypt a received event\n *\n * @returns a promise which resolves once we have finished decrypting.\n * Rejects with an error if there is a problem decrypting the event.\n */\n decryptEvent(event: MatrixEvent): Promise<EventDecryptionResult>;\n\n /**\n * Get information about the encryption of an event\n *\n * @param event - event to be checked\n */\n getEventEncryptionInfo(event: MatrixEvent): IEncryptedEventInfo;\n\n /**\n * Get the cross signing information for a given user.\n *\n * The cross-signing API is currently UNSTABLE and may change without notice.\n *\n * @param userId - the user ID to get the cross-signing info for.\n *\n * @returns the cross signing information for the user.\n * @deprecated Prefer {@link CryptoApi#userHasCrossSigningKeys}\n */\n getStoredCrossSigningForUser(userId: string): CrossSigningInfo | null;\n\n /**\n * Check the cross signing trust of the current user\n *\n * @param opts - Options object.\n *\n * @deprecated Unneeded for the new crypto\n */\n checkOwnCrossSigningTrust(opts?: CheckOwnCrossSigningTrustOpts): Promise<void>;\n\n /**\n * Get a backup decryptor capable of decrypting megolm session data encrypted with the given backup information.\n * @param backupInfo - The backup information\n * @param privKey - The private decryption key.\n */\n getBackupDecryptor(backupInfo: KeyBackupInfo, privKey: ArrayLike<number>): Promise<BackupDecryptor>;\n}\n\n/** The methods which crypto implementations should expose to the Sync api\n *\n * @internal\n */\nexport interface SyncCryptoCallbacks {\n /**\n * Called by the /sync loop whenever there are incoming to-device messages.\n *\n * The implementation may preprocess the received messages (eg, decrypt them) and return an\n * updated list of messages for dispatch to the rest of the system.\n *\n * Note that, unlike {@link ClientEvent.ToDeviceEvent} events, this is called on the raw to-device\n * messages, rather than the results of any decryption attempts.\n *\n * @param events - the received to-device messages\n * @returns A list of preprocessed to-device messages.\n */\n preprocessToDeviceMessages(events: IToDeviceEvent[]): Promise<IToDeviceEvent[]>;\n\n /**\n * Called by the /sync loop when one time key counts and unused fallback key details are received.\n *\n * @param oneTimeKeysCounts - the received one time key counts\n * @param unusedFallbackKeys - the received unused fallback keys\n */\n processKeyCounts(oneTimeKeysCounts?: Record<string, number>, unusedFallbackKeys?: string[]): Promise<void>;\n\n /**\n * Handle the notification from /sync that device lists have\n * been changed.\n *\n * @param deviceLists - device_lists field from /sync\n */\n processDeviceLists(deviceLists: IDeviceLists): Promise<void>;\n\n /**\n * Called by the /sync loop whenever an m.room.encryption event is received.\n *\n * This is called before RoomStateEvents are emitted for any of the events in the /sync\n * response (even if the other events technically happened first). This works around a problem\n * if the client uses a RoomStateEvent (typically a membership event) as a trigger to send a message\n * in a new room (or one where encryption has been newly enabled): that would otherwise leave the\n * crypto layer confused because it expects crypto to be set up, but it has not yet been.\n *\n * @param room - in which the event was received\n * @param event - encryption event to be processed\n */\n onCryptoEvent(room: Room, event: MatrixEvent): Promise<void>;\n\n /**\n * Called by the /sync loop after each /sync response is processed.\n *\n * Used to complete batch processing, or to initiate background processes\n *\n * @param syncState - information about the completed sync.\n */\n onSyncCompleted(syncState: OnSyncCompletedData): void;\n}\n\n/**\n * @internal\n */\nexport interface OnSyncCompletedData {\n /**\n * The 'next_batch' result from /sync, which will become the 'since' token for the next call to /sync.\n */\n nextSyncToken?: string;\n\n /**\n * True if we are working our way through a backlog of events after connecting.\n */\n catchingUp?: boolean;\n}\n\n/**\n * Options object for {@link CryptoBackend#checkOwnCrossSigningTrust}.\n */\nexport interface CheckOwnCrossSigningTrustOpts {\n allowPrivateKeyRequests?: boolean;\n}\n\n/**\n * The result of a (successful) call to {@link CryptoBackend.decryptEvent}\n */\nexport interface EventDecryptionResult {\n /**\n * The plaintext payload for the event (typically containing <tt>type</tt> and <tt>content</tt> fields).\n */\n clearEvent: IClearEvent;\n /**\n * List of curve25519 keys involved in telling us about the senderCurve25519Key and claimedEd25519Key.\n * See {@link MatrixEvent#getForwardingCurve25519KeyChain}.\n */\n forwardingCurve25519KeyChain?: string[];\n /**\n * Key owned by the sender of this event. See {@link MatrixEvent#getSenderKey}.\n */\n senderCurve25519Key?: string;\n /**\n * ed25519 key claimed by the sender of this event. See {@link MatrixEvent#getClaimedEd25519Key}.\n */\n claimedEd25519Key?: string;\n /**\n * Whether the keys for this event have been received via an unauthenticated source (eg via key forwards, or\n * restored from backup)\n */\n untrusted?: boolean;\n /**\n * The sender doesn't authorize the unverified devices to decrypt his messages\n */\n encryptedDisabledForUnverifiedDevices?: boolean;\n}\n\n/**\n * Responsible for decrypting megolm session data retrieved from a remote backup.\n * The result of {@link CryptoBackend#getBackupDecryptor}.\n */\nexport interface BackupDecryptor {\n /**\n * Whether keys retrieved from this backup can be trusted.\n *\n * Depending on the backup algorithm, keys retrieved from the backup can be trusted or not.\n * If false, keys retrieved from the backup must be considered unsafe (authenticity cannot be guaranteed).\n * It could be by design (deniability) or for some technical reason (eg asymmetric encryption).\n */\n readonly sourceTrusted: boolean;\n\n /**\n *\n * Decrypt megolm session data retrieved from backup.\n *\n * @param ciphertexts - a Record of sessionId to session data.\n *\n * @returns An array of decrypted `IMegolmSessionData`\n */\n decryptSessions(ciphertexts: Record<string, KeyBackupSession>): Promise<IMegolmSessionData[]>;\n\n /**\n * Free any resources held by this decryptor.\n *\n * Should be called once the decryptor is no longer needed.\n */\n free(): void;\n}\n"],"mappings":""}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Base64 encoding and decoding utility for crypo.
3
+ */
4
+ /**
5
+ * Encode a typed array of uint8 as base64.
6
+ * @param uint8Array - The data to encode.
7
+ * @returns The base64.
8
+ */
9
+ export declare function encodeBase64(uint8Array: ArrayBuffer | Uint8Array): string;
10
+ /**
11
+ * Encode a typed array of uint8 as unpadded base64.
12
+ * @param uint8Array - The data to encode.
13
+ * @returns The unpadded base64.
14
+ */
15
+ export declare function encodeUnpaddedBase64(uint8Array: ArrayBuffer | Uint8Array): string;
16
+ /**
17
+ * Decode a base64 string to a typed array of uint8.
18
+ * @param base64 - The base64 to decode.
19
+ * @returns The decoded data.
20
+ */
21
+ export declare function decodeBase64(base64: string): Uint8Array;
22
+ //# sourceMappingURL=base64.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base64.d.ts","sourceRoot":"","sources":["../../src/common-crypto/base64.ts"],"names":[],"mappings":"AAgBA;;GAEG;AAEH;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,WAAW,GAAG,UAAU,GAAG,MAAM,CAEzE;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,WAAW,GAAG,UAAU,GAAG,MAAM,CAEjF;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAEvD"}
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.decodeBase64 = decodeBase64;
7
+ exports.encodeBase64 = encodeBase64;
8
+ exports.encodeUnpaddedBase64 = encodeUnpaddedBase64;
9
+ /*
10
+ Copyright 2023 The Matrix.org Foundation C.I.C.
11
+
12
+ Licensed under the Apache License, Version 2.0 (the "License");
13
+ you may not use this file except in compliance with the License.
14
+ You may obtain a copy of the License at
15
+
16
+ http://www.apache.org/licenses/LICENSE-2.0
17
+
18
+ Unless required by applicable law or agreed to in writing, software
19
+ distributed under the License is distributed on an "AS IS" BASIS,
20
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
+ See the License for the specific language governing permissions and
22
+ limitations under the License.
23
+ */
24
+
25
+ /**
26
+ * Base64 encoding and decoding utility for crypo.
27
+ */
28
+
29
+ /**
30
+ * Encode a typed array of uint8 as base64.
31
+ * @param uint8Array - The data to encode.
32
+ * @returns The base64.
33
+ */
34
+ function encodeBase64(uint8Array) {
35
+ return Buffer.from(uint8Array).toString("base64");
36
+ }
37
+
38
+ /**
39
+ * Encode a typed array of uint8 as unpadded base64.
40
+ * @param uint8Array - The data to encode.
41
+ * @returns The unpadded base64.
42
+ */
43
+ function encodeUnpaddedBase64(uint8Array) {
44
+ return encodeBase64(uint8Array).replace(/={1,2}$/, "");
45
+ }
46
+
47
+ /**
48
+ * Decode a base64 string to a typed array of uint8.
49
+ * @param base64 - The base64 to decode.
50
+ * @returns The decoded data.
51
+ */
52
+ function decodeBase64(base64) {
53
+ return Buffer.from(base64, "base64");
54
+ }
55
+ //# sourceMappingURL=base64.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base64.js","names":["encodeBase64","uint8Array","Buffer","from","toString","encodeUnpaddedBase64","replace","decodeBase64","base64"],"sources":["../../src/common-crypto/base64.ts"],"sourcesContent":["/*\nCopyright 2023 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\n/**\n * Base64 encoding and decoding utility for crypo.\n */\n\n/**\n * Encode a typed array of uint8 as base64.\n * @param uint8Array - The data to encode.\n * @returns The base64.\n */\nexport function encodeBase64(uint8Array: ArrayBuffer | Uint8Array): string {\n return Buffer.from(uint8Array).toString(\"base64\");\n}\n\n/**\n * Encode a typed array of uint8 as unpadded base64.\n * @param uint8Array - The data to encode.\n * @returns The unpadded base64.\n */\nexport function encodeUnpaddedBase64(uint8Array: ArrayBuffer | Uint8Array): string {\n return encodeBase64(uint8Array).replace(/={1,2}$/, \"\");\n}\n\n/**\n * Decode a base64 string to a typed array of uint8.\n * @param base64 - The base64 to decode.\n * @returns The decoded data.\n */\nexport function decodeBase64(base64: string): Uint8Array {\n return Buffer.from(base64, \"base64\");\n}\n"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASA,YAAYA,CAACC,UAAoC,EAAU;EACvE,OAAOC,MAAM,CAACC,IAAI,CAACF,UAAU,CAAC,CAACG,QAAQ,CAAC,QAAQ,CAAC;AACrD;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASC,oBAAoBA,CAACJ,UAAoC,EAAU;EAC/E,OAAOD,YAAY,CAACC,UAAU,CAAC,CAACK,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;AAC1D;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASC,YAAYA,CAACC,MAAc,EAAc;EACrD,OAAON,MAAM,CAACC,IAAI,CAACK,MAAM,EAAE,QAAQ,CAAC;AACxC"}
@@ -19,22 +19,22 @@ var _extensible_events = require("./@types/extensible_events");
19
19
  var _utilities = require("./extensible_events_v1/utilities");
20
20
  var _location = require("./@types/location");
21
21
  var _topic = require("./@types/topic");
22
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
23
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } /*
24
- Copyright 2018 - 2022 The Matrix.org Foundation C.I.C.
25
-
26
- Licensed under the Apache License, Version 2.0 (the "License");
27
- you may not use this file except in compliance with the License.
28
- You may obtain a copy of the License at
29
-
30
- http://www.apache.org/licenses/LICENSE-2.0
31
-
32
- Unless required by applicable law or agreed to in writing, software
33
- distributed under the License is distributed on an "AS IS" BASIS,
34
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
35
- See the License for the specific language governing permissions and
36
- limitations under the License.
37
- */
22
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
23
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } /*
24
+ Copyright 2018 - 2022 The Matrix.org Foundation C.I.C.
25
+
26
+ Licensed under the Apache License, Version 2.0 (the "License");
27
+ you may not use this file except in compliance with the License.
28
+ You may obtain a copy of the License at
29
+
30
+ http://www.apache.org/licenses/LICENSE-2.0
31
+
32
+ Unless required by applicable law or agreed to in writing, software
33
+ distributed under the License is distributed on an "AS IS" BASIS,
34
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
35
+ See the License for the specific language governing permissions and
36
+ limitations under the License.
37
+ */
38
38
  /**
39
39
  * Generates the content for a HTML Message event
40
40
  * @param body - the plaintext body of the message
@@ -1 +1 @@
1
- {"version":3,"file":"content-helpers.js","names":["_event","require","_extensible_events","_utilities","_location","_topic","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty2","default","getOwnPropertyDescriptors","defineProperties","defineProperty","makeHtmlMessage","body","htmlBody","msgtype","MsgType","Text","format","formatted_body","makeHtmlNotice","Notice","makeHtmlEmote","Emote","makeTextMessage","makeNotice","makeEmoteMessage","getTextForLocationEvent","uri","assetType","timestamp","description","date","Date","toISOString","assetName","LocationAssetType","Self","undefined","quotedDescription","Boolean","join","exports","makeLocationContent","text","defaultedText","timestampEvent","M_TIMESTAMP","name","Location","geo_uri","M_LOCATION","M_ASSET","type","M_TEXT","parseLocationEvent","wireEventContent","_location$uri","_asset$type","location","findIn","asset","geoUri","fallbackText","makeTopicContent","topic","htmlTopic","renderings","mimetype","isProvided","M_TOPIC","parseTopicContent","content","_mtopic$find$body","_mtopic$find","_mtopic$find2","mtopic","Array","isArray","find","r","html","makeBeaconInfoContent","timeout","isLive","live","now","parseBeaconInfoContent","_M_TIMESTAMP$findIn","makeBeaconContent","beaconInfoEventId","rel_type","REFERENCE_RELATION","event_id","parseBeaconContent","_M_TIMESTAMP$findIn2"],"sources":["../src/content-helpers.ts"],"sourcesContent":["/*\nCopyright 2018 - 2022 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { MBeaconEventContent, MBeaconInfoContent, MBeaconInfoEventContent } from \"./@types/beacon\";\nimport { MsgType } from \"./@types/event\";\nimport { M_TEXT, REFERENCE_RELATION } from \"./@types/extensible_events\";\nimport { isProvided } from \"./extensible_events_v1/utilities\";\nimport {\n M_ASSET,\n LocationAssetType,\n M_LOCATION,\n M_TIMESTAMP,\n LocationEventWireContent,\n MLocationEventContent,\n MLocationContent,\n MAssetContent,\n LegacyLocationEventContent,\n} from \"./@types/location\";\nimport { MRoomTopicEventContent, MTopicContent, M_TOPIC } from \"./@types/topic\";\nimport { IContent } from \"./models/event\";\n\n/**\n * Generates the content for a HTML Message event\n * @param body - the plaintext body of the message\n * @param htmlBody - the HTML representation of the message\n * @returns\n */\nexport function makeHtmlMessage(body: string, htmlBody: string): IContent {\n return {\n msgtype: MsgType.Text,\n format: \"org.matrix.custom.html\",\n body: body,\n formatted_body: htmlBody,\n };\n}\n\n/**\n * Generates the content for a HTML Notice event\n * @param body - the plaintext body of the notice\n * @param htmlBody - the HTML representation of the notice\n * @returns\n */\nexport function makeHtmlNotice(body: string, htmlBody: string): IContent {\n return {\n msgtype: MsgType.Notice,\n format: \"org.matrix.custom.html\",\n body: body,\n formatted_body: htmlBody,\n };\n}\n\n/**\n * Generates the content for a HTML Emote event\n * @param body - the plaintext body of the emote\n * @param htmlBody - the HTML representation of the emote\n * @returns\n */\nexport function makeHtmlEmote(body: string, htmlBody: string): IContent {\n return {\n msgtype: MsgType.Emote,\n format: \"org.matrix.custom.html\",\n body: body,\n formatted_body: htmlBody,\n };\n}\n\n/**\n * Generates the content for a Plaintext Message event\n * @param body - the plaintext body of the emote\n * @returns\n */\nexport function makeTextMessage(body: string): IContent {\n return {\n msgtype: MsgType.Text,\n body: body,\n };\n}\n\n/**\n * Generates the content for a Plaintext Notice event\n * @param body - the plaintext body of the notice\n * @returns\n */\nexport function makeNotice(body: string): IContent {\n return {\n msgtype: MsgType.Notice,\n body: body,\n };\n}\n\n/**\n * Generates the content for a Plaintext Emote event\n * @param body - the plaintext body of the emote\n * @returns\n */\nexport function makeEmoteMessage(body: string): IContent {\n return {\n msgtype: MsgType.Emote,\n body: body,\n };\n}\n\n/** Location content helpers */\n\nexport const getTextForLocationEvent = (\n uri: string | undefined,\n assetType: LocationAssetType,\n timestamp?: number,\n description?: string | null,\n): string => {\n const date = `at ${new Date(timestamp!).toISOString()}`;\n const assetName = assetType === LocationAssetType.Self ? \"User\" : undefined;\n const quotedDescription = description ? `\"${description}\"` : undefined;\n\n return [assetName, \"Location\", quotedDescription, uri, date].filter(Boolean).join(\" \");\n};\n\n/**\n * Generates the content for a Location event\n * @param uri - a geo:// uri for the location\n * @param timestamp - the timestamp when the location was correct (milliseconds since the UNIX epoch)\n * @param description - the (optional) label for this location on the map\n * @param assetType - the (optional) asset type of this location e.g. \"m.self\"\n * @param text - optional. A text for the location\n */\nexport const makeLocationContent = (\n // this is first but optional\n // to avoid a breaking change\n text?: string,\n uri?: string,\n timestamp?: number,\n description?: string | null,\n assetType?: LocationAssetType,\n): LegacyLocationEventContent & MLocationEventContent => {\n const defaultedText =\n text ?? getTextForLocationEvent(uri, assetType || LocationAssetType.Self, timestamp, description);\n const timestampEvent = timestamp ? { [M_TIMESTAMP.name]: timestamp } : {};\n return {\n msgtype: MsgType.Location,\n body: defaultedText,\n geo_uri: uri,\n [M_LOCATION.name]: {\n description,\n uri,\n },\n [M_ASSET.name]: {\n type: assetType || LocationAssetType.Self,\n },\n [M_TEXT.name]: defaultedText,\n ...timestampEvent,\n } as LegacyLocationEventContent & MLocationEventContent;\n};\n\n/**\n * Parse location event content and transform to\n * a backwards compatible modern m.location event format\n */\nexport const parseLocationEvent = (wireEventContent: LocationEventWireContent): MLocationEventContent => {\n const location = M_LOCATION.findIn<MLocationContent>(wireEventContent);\n const asset = M_ASSET.findIn<MAssetContent>(wireEventContent);\n const timestamp = M_TIMESTAMP.findIn<number>(wireEventContent);\n const text = M_TEXT.findIn<string>(wireEventContent);\n\n const geoUri = location?.uri ?? wireEventContent?.geo_uri;\n const description = location?.description;\n const assetType = asset?.type ?? LocationAssetType.Self;\n const fallbackText = text ?? wireEventContent.body;\n\n return makeLocationContent(fallbackText, geoUri, timestamp ?? undefined, description, assetType);\n};\n\n/**\n * Topic event helpers\n */\nexport type MakeTopicContent = (topic: string, htmlTopic?: string) => MRoomTopicEventContent;\n\nexport const makeTopicContent: MakeTopicContent = (topic, htmlTopic) => {\n const renderings = [{ body: topic, mimetype: \"text/plain\" }];\n if (isProvided(htmlTopic)) {\n renderings.push({ body: htmlTopic!, mimetype: \"text/html\" });\n }\n return { topic, [M_TOPIC.name]: renderings };\n};\n\nexport type TopicState = {\n text: string;\n html?: string;\n};\n\nexport const parseTopicContent = (content: MRoomTopicEventContent): TopicState => {\n const mtopic = M_TOPIC.findIn<MTopicContent>(content);\n if (!Array.isArray(mtopic)) {\n return { text: content.topic };\n }\n const text = mtopic?.find((r) => !isProvided(r.mimetype) || r.mimetype === \"text/plain\")?.body ?? content.topic;\n const html = mtopic?.find((r) => r.mimetype === \"text/html\")?.body;\n return { text, html };\n};\n\n/**\n * Beacon event helpers\n */\nexport type MakeBeaconInfoContent = (\n timeout: number,\n isLive?: boolean,\n description?: string,\n assetType?: LocationAssetType,\n timestamp?: number,\n) => MBeaconInfoEventContent;\n\nexport const makeBeaconInfoContent: MakeBeaconInfoContent = (timeout, isLive, description, assetType, timestamp) => ({\n description,\n timeout,\n live: isLive,\n [M_TIMESTAMP.name]: timestamp || Date.now(),\n [M_ASSET.name]: {\n type: assetType ?? LocationAssetType.Self,\n },\n});\n\nexport type BeaconInfoState = MBeaconInfoContent & {\n assetType?: LocationAssetType;\n timestamp?: number;\n};\n/**\n * Flatten beacon info event content\n */\nexport const parseBeaconInfoContent = (content: MBeaconInfoEventContent): BeaconInfoState => {\n const { description, timeout, live } = content;\n const timestamp = M_TIMESTAMP.findIn<number>(content) ?? undefined;\n const asset = M_ASSET.findIn<MAssetContent>(content);\n\n return {\n description,\n timeout,\n live,\n assetType: asset?.type,\n timestamp,\n };\n};\n\nexport type MakeBeaconContent = (\n uri: string,\n timestamp: number,\n beaconInfoEventId: string,\n description?: string,\n) => MBeaconEventContent;\n\nexport const makeBeaconContent: MakeBeaconContent = (uri, timestamp, beaconInfoEventId, description) => ({\n [M_LOCATION.name]: {\n description,\n uri,\n },\n [M_TIMESTAMP.name]: timestamp,\n \"m.relates_to\": {\n rel_type: REFERENCE_RELATION.name,\n event_id: beaconInfoEventId,\n },\n});\n\nexport type BeaconLocationState = Omit<MLocationContent, \"uri\"> & {\n uri?: string; // override from MLocationContent to allow optionals\n timestamp?: number;\n};\n\nexport const parseBeaconContent = (content: MBeaconEventContent): BeaconLocationState => {\n const location = M_LOCATION.findIn<MLocationContent>(content);\n const timestamp = M_TIMESTAMP.findIn<number>(content) ?? undefined;\n\n return {\n description: location?.description,\n uri: location?.uri,\n timestamp,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AAWA,IAAAI,MAAA,GAAAJ,OAAA;AAAgF,SAAAK,QAAAC,MAAA,EAAAC,cAAA,QAAAC,IAAA,GAAAC,MAAA,CAAAD,IAAA,CAAAF,MAAA,OAAAG,MAAA,CAAAC,qBAAA,QAAAC,OAAA,GAAAF,MAAA,CAAAC,qBAAA,CAAAJ,MAAA,GAAAC,cAAA,KAAAI,OAAA,GAAAA,OAAA,CAAAC,MAAA,WAAAC,GAAA,WAAAJ,MAAA,CAAAK,wBAAA,CAAAR,MAAA,EAAAO,GAAA,EAAAE,UAAA,OAAAP,IAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,IAAA,EAAAG,OAAA,YAAAH,IAAA;AAAA,SAAAU,cAAAC,MAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAC,SAAA,CAAAC,MAAA,EAAAF,CAAA,UAAAG,MAAA,WAAAF,SAAA,CAAAD,CAAA,IAAAC,SAAA,CAAAD,CAAA,QAAAA,CAAA,OAAAf,OAAA,CAAAI,MAAA,CAAAc,MAAA,OAAAC,OAAA,WAAAC,GAAA,QAAAC,gBAAA,CAAAC,OAAA,EAAAR,MAAA,EAAAM,GAAA,EAAAF,MAAA,CAAAE,GAAA,SAAAhB,MAAA,CAAAmB,yBAAA,GAAAnB,MAAA,CAAAoB,gBAAA,CAAAV,MAAA,EAAAV,MAAA,CAAAmB,yBAAA,CAAAL,MAAA,KAAAlB,OAAA,CAAAI,MAAA,C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AAS,EAAE4D,iBAAiB,EAAE3D,WAAW,MAAM;EACrG,CAACoB,oBAAU,CAACH,IAAI,GAAG;IACfjB,WAAW;IACXH;EACJ,CAAC;EACD,CAACmB,qBAAW,CAACC,IAAI,GAAGlB,SAAS;EAC7B,cAAc,EAAE;IACZ6D,QAAQ,EAAEC,qCAAkB,CAAC5C,IAAI;IACjC6C,QAAQ,EAAEH;EACd;AACJ,CAAC,CAAC;AAAChD,OAAA,CAAA+C,iBAAA,GAAAA,iBAAA;AAOI,MAAMK,kBAAkB,GAAItB,OAA4B,IAA0B;EAAA,IAAAuB,oBAAA;EACrF,MAAMpC,QAAQ,GAAGR,oBAAU,CAACS,MAAM,CAAmBY,OAAO,CAAC;EAC7D,MAAM1C,SAAS,IAAAiE,oBAAA,GAAGhD,qBAAW,CAACa,MAAM,CAASY,OAAO,CAAC,cAAAuB,oBAAA,cAAAA,oBAAA,GAAIzD,SAAS;EAElE,OAAO;IACHP,WAAW,EAAE4B,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAE5B,WAAW;IAClCH,GAAG,EAAE+B,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAE/B,GAAG;IAClBE;EACJ,CAAC;AACL,CAAC;AAACY,OAAA,CAAAoD,kBAAA,GAAAA,kBAAA"}
1
+ {"version":3,"file":"content-helpers.js","names":["_event","require","_extensible_events","_utilities","_location","_topic","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","default","getOwnPropertyDescriptors","defineProperties","defineProperty","makeHtmlMessage","body","htmlBody","msgtype","MsgType","Text","format","formatted_body","makeHtmlNotice","Notice","makeHtmlEmote","Emote","makeTextMessage","makeNotice","makeEmoteMessage","getTextForLocationEvent","uri","assetType","timestamp","description","date","Date","toISOString","assetName","LocationAssetType","Self","undefined","quotedDescription","Boolean","join","exports","makeLocationContent","text","defaultedText","timestampEvent","M_TIMESTAMP","name","Location","geo_uri","M_LOCATION","M_ASSET","type","M_TEXT","parseLocationEvent","wireEventContent","_location$uri","_asset$type","location","findIn","asset","geoUri","fallbackText","makeTopicContent","topic","htmlTopic","renderings","mimetype","isProvided","M_TOPIC","parseTopicContent","content","_mtopic$find$body","_mtopic$find","_mtopic$find2","mtopic","Array","isArray","find","html","makeBeaconInfoContent","timeout","isLive","live","now","parseBeaconInfoContent","_M_TIMESTAMP$findIn","makeBeaconContent","beaconInfoEventId","rel_type","REFERENCE_RELATION","event_id","parseBeaconContent","_M_TIMESTAMP$findIn2"],"sources":["../src/content-helpers.ts"],"sourcesContent":["/*\nCopyright 2018 - 2022 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { MBeaconEventContent, MBeaconInfoContent, MBeaconInfoEventContent } from \"./@types/beacon\";\nimport { MsgType } from \"./@types/event\";\nimport { M_TEXT, REFERENCE_RELATION } from \"./@types/extensible_events\";\nimport { isProvided } from \"./extensible_events_v1/utilities\";\nimport {\n M_ASSET,\n LocationAssetType,\n M_LOCATION,\n M_TIMESTAMP,\n LocationEventWireContent,\n MLocationEventContent,\n MLocationContent,\n MAssetContent,\n LegacyLocationEventContent,\n} from \"./@types/location\";\nimport { MRoomTopicEventContent, MTopicContent, M_TOPIC } from \"./@types/topic\";\nimport { IContent } from \"./models/event\";\n\n/**\n * Generates the content for a HTML Message event\n * @param body - the plaintext body of the message\n * @param htmlBody - the HTML representation of the message\n * @returns\n */\nexport function makeHtmlMessage(body: string, htmlBody: string): IContent {\n return {\n msgtype: MsgType.Text,\n format: \"org.matrix.custom.html\",\n body: body,\n formatted_body: htmlBody,\n };\n}\n\n/**\n * Generates the content for a HTML Notice event\n * @param body - the plaintext body of the notice\n * @param htmlBody - the HTML representation of the notice\n * @returns\n */\nexport function makeHtmlNotice(body: string, htmlBody: string): IContent {\n return {\n msgtype: MsgType.Notice,\n format: \"org.matrix.custom.html\",\n body: body,\n formatted_body: htmlBody,\n };\n}\n\n/**\n * Generates the content for a HTML Emote event\n * @param body - the plaintext body of the emote\n * @param htmlBody - the HTML representation of the emote\n * @returns\n */\nexport function makeHtmlEmote(body: string, htmlBody: string): IContent {\n return {\n msgtype: MsgType.Emote,\n format: \"org.matrix.custom.html\",\n body: body,\n formatted_body: htmlBody,\n };\n}\n\n/**\n * Generates the content for a Plaintext Message event\n * @param body - the plaintext body of the emote\n * @returns\n */\nexport function makeTextMessage(body: string): IContent {\n return {\n msgtype: MsgType.Text,\n body: body,\n };\n}\n\n/**\n * Generates the content for a Plaintext Notice event\n * @param body - the plaintext body of the notice\n * @returns\n */\nexport function makeNotice(body: string): IContent {\n return {\n msgtype: MsgType.Notice,\n body: body,\n };\n}\n\n/**\n * Generates the content for a Plaintext Emote event\n * @param body - the plaintext body of the emote\n * @returns\n */\nexport function makeEmoteMessage(body: string): IContent {\n return {\n msgtype: MsgType.Emote,\n body: body,\n };\n}\n\n/** Location content helpers */\n\nexport const getTextForLocationEvent = (\n uri: string | undefined,\n assetType: LocationAssetType,\n timestamp?: number,\n description?: string | null,\n): string => {\n const date = `at ${new Date(timestamp!).toISOString()}`;\n const assetName = assetType === LocationAssetType.Self ? \"User\" : undefined;\n const quotedDescription = description ? `\"${description}\"` : undefined;\n\n return [assetName, \"Location\", quotedDescription, uri, date].filter(Boolean).join(\" \");\n};\n\n/**\n * Generates the content for a Location event\n * @param uri - a geo:// uri for the location\n * @param timestamp - the timestamp when the location was correct (milliseconds since the UNIX epoch)\n * @param description - the (optional) label for this location on the map\n * @param assetType - the (optional) asset type of this location e.g. \"m.self\"\n * @param text - optional. A text for the location\n */\nexport const makeLocationContent = (\n // this is first but optional\n // to avoid a breaking change\n text?: string,\n uri?: string,\n timestamp?: number,\n description?: string | null,\n assetType?: LocationAssetType,\n): LegacyLocationEventContent & MLocationEventContent => {\n const defaultedText =\n text ?? getTextForLocationEvent(uri, assetType || LocationAssetType.Self, timestamp, description);\n const timestampEvent = timestamp ? { [M_TIMESTAMP.name]: timestamp } : {};\n return {\n msgtype: MsgType.Location,\n body: defaultedText,\n geo_uri: uri,\n [M_LOCATION.name]: {\n description,\n uri,\n },\n [M_ASSET.name]: {\n type: assetType || LocationAssetType.Self,\n },\n [M_TEXT.name]: defaultedText,\n ...timestampEvent,\n } as LegacyLocationEventContent & MLocationEventContent;\n};\n\n/**\n * Parse location event content and transform to\n * a backwards compatible modern m.location event format\n */\nexport const parseLocationEvent = (wireEventContent: LocationEventWireContent): MLocationEventContent => {\n const location = M_LOCATION.findIn<MLocationContent>(wireEventContent);\n const asset = M_ASSET.findIn<MAssetContent>(wireEventContent);\n const timestamp = M_TIMESTAMP.findIn<number>(wireEventContent);\n const text = M_TEXT.findIn<string>(wireEventContent);\n\n const geoUri = location?.uri ?? wireEventContent?.geo_uri;\n const description = location?.description;\n const assetType = asset?.type ?? LocationAssetType.Self;\n const fallbackText = text ?? wireEventContent.body;\n\n return makeLocationContent(fallbackText, geoUri, timestamp ?? undefined, description, assetType);\n};\n\n/**\n * Topic event helpers\n */\nexport type MakeTopicContent = (topic: string, htmlTopic?: string) => MRoomTopicEventContent;\n\nexport const makeTopicContent: MakeTopicContent = (topic, htmlTopic) => {\n const renderings = [{ body: topic, mimetype: \"text/plain\" }];\n if (isProvided(htmlTopic)) {\n renderings.push({ body: htmlTopic!, mimetype: \"text/html\" });\n }\n return { topic, [M_TOPIC.name]: renderings };\n};\n\nexport type TopicState = {\n text: string;\n html?: string;\n};\n\nexport const parseTopicContent = (content: MRoomTopicEventContent): TopicState => {\n const mtopic = M_TOPIC.findIn<MTopicContent>(content);\n if (!Array.isArray(mtopic)) {\n return { text: content.topic };\n }\n const text = mtopic?.find((r) => !isProvided(r.mimetype) || r.mimetype === \"text/plain\")?.body ?? content.topic;\n const html = mtopic?.find((r) => r.mimetype === \"text/html\")?.body;\n return { text, html };\n};\n\n/**\n * Beacon event helpers\n */\nexport type MakeBeaconInfoContent = (\n timeout: number,\n isLive?: boolean,\n description?: string,\n assetType?: LocationAssetType,\n timestamp?: number,\n) => MBeaconInfoEventContent;\n\nexport const makeBeaconInfoContent: MakeBeaconInfoContent = (timeout, isLive, description, assetType, timestamp) => ({\n description,\n timeout,\n live: isLive,\n [M_TIMESTAMP.name]: timestamp || Date.now(),\n [M_ASSET.name]: {\n type: assetType ?? LocationAssetType.Self,\n },\n});\n\nexport type BeaconInfoState = MBeaconInfoContent & {\n assetType?: LocationAssetType;\n timestamp?: number;\n};\n/**\n * Flatten beacon info event content\n */\nexport const parseBeaconInfoContent = (content: MBeaconInfoEventContent): BeaconInfoState => {\n const { description, timeout, live } = content;\n const timestamp = M_TIMESTAMP.findIn<number>(content) ?? undefined;\n const asset = M_ASSET.findIn<MAssetContent>(content);\n\n return {\n description,\n timeout,\n live,\n assetType: asset?.type,\n timestamp,\n };\n};\n\nexport type MakeBeaconContent = (\n uri: string,\n timestamp: number,\n beaconInfoEventId: string,\n description?: string,\n) => MBeaconEventContent;\n\nexport const makeBeaconContent: MakeBeaconContent = (uri, timestamp, beaconInfoEventId, description) => ({\n [M_LOCATION.name]: {\n description,\n uri,\n },\n [M_TIMESTAMP.name]: timestamp,\n \"m.relates_to\": {\n rel_type: REFERENCE_RELATION.name,\n event_id: beaconInfoEventId,\n },\n});\n\nexport type BeaconLocationState = Omit<MLocationContent, \"uri\"> & {\n uri?: string; // override from MLocationContent to allow optionals\n timestamp?: number;\n};\n\nexport const parseBeaconContent = (content: MBeaconEventContent): BeaconLocationState => {\n const location = M_LOCATION.findIn<MLocationContent>(content);\n const timestamp = M_TIMESTAMP.findIn<number>(content) ?? undefined;\n\n return {\n description: location?.description,\n uri: location?.uri,\n timestamp,\n };\n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;IACZ4D,QAAQ,EAAEC,qCAAkB,CAAC3C,IAAI;IACjC4C,QAAQ,EAAEH;EACd;AACJ,CAAC,CAAC;AAAC/C,OAAA,CAAA8C,iBAAA,GAAAA,iBAAA;AAOI,MAAMK,kBAAkB,GAAIrB,OAA4B,IAA0B;EAAA,IAAAsB,oBAAA;EACrF,MAAMnC,QAAQ,GAAGR,oBAAU,CAACS,MAAM,CAAmBY,OAAO,CAAC;EAC7D,MAAM1C,SAAS,IAAAgE,oBAAA,GAAG/C,qBAAW,CAACa,MAAM,CAASY,OAAO,CAAC,cAAAsB,oBAAA,cAAAA,oBAAA,GAAIxD,SAAS;EAElE,OAAO;IACHP,WAAW,EAAE4B,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAE5B,WAAW;IAClCH,GAAG,EAAE+B,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAE/B,GAAG;IAClBE;EACJ,CAAC;AACL,CAAC;AAACY,OAAA,CAAAmD,kBAAA,GAAAA,kBAAA"}
@@ -58,9 +58,6 @@ class CrossSigningInfo {
58
58
  * @param cacheCallbacks - Callbacks used to interact with the cache
59
59
  */
60
60
  constructor(userId, callbacks = {}, cacheCallbacks = {}) {
61
- this.userId = userId;
62
- this.callbacks = callbacks;
63
- this.cacheCallbacks = cacheCallbacks;
64
61
  (0, _defineProperty2.default)(this, "keys", {});
65
62
  (0, _defineProperty2.default)(this, "firstUse", true);
66
63
  // This tracks whether we've ever verified this user with any identity.
@@ -69,6 +66,9 @@ class CrossSigningInfo {
69
66
  // and can use it in the future to detect cases where the user has
70
67
  // become unverified later for any reason.
71
68
  (0, _defineProperty2.default)(this, "crossSigningVerifiedBefore", false);
69
+ this.userId = userId;
70
+ this.callbacks = callbacks;
71
+ this.cacheCallbacks = cacheCallbacks;
72
72
  }
73
73
  static fromStorage(obj, userId) {
74
74
  const res = new CrossSigningInfo(userId);