@jeongsu816/matrix-bot-sdk 0.0.0-stage → 0.8.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.
- package/LICENSE +21 -0
- package/README.md +50 -2
- package/lib/AdminApis.d.ts +52 -0
- package/lib/AdminApis.js +29 -0
- package/lib/AdminApis.js.map +1 -0
- package/lib/DMs.d.ts +48 -0
- package/lib/DMs.js +160 -0
- package/lib/DMs.js.map +1 -0
- package/lib/IFilter.d.ts +7 -0
- package/lib/IFilter.js +3 -0
- package/lib/IFilter.js.map +1 -0
- package/lib/MatrixAuth.d.ts +45 -0
- package/lib/MatrixAuth.js +125 -0
- package/lib/MatrixAuth.js.map +1 -0
- package/lib/MatrixClient.d.ts +834 -0
- package/lib/MatrixClient.js +2268 -0
- package/lib/MatrixClient.js.map +1 -0
- package/lib/PantalaimonClient.d.ts +42 -0
- package/lib/PantalaimonClient.js +44 -0
- package/lib/PantalaimonClient.js.map +1 -0
- package/lib/SynapseAdminApis.d.ts +350 -0
- package/lib/SynapseAdminApis.js +244 -0
- package/lib/SynapseAdminApis.js.map +1 -0
- package/lib/SynchronousMatrixClient.d.ts +82 -0
- package/lib/SynchronousMatrixClient.js +130 -0
- package/lib/SynchronousMatrixClient.js.map +1 -0
- package/lib/UnstableApis.d.ts +43 -0
- package/lib/UnstableApis.js +74 -0
- package/lib/UnstableApis.js.map +1 -0
- package/lib/appservice/Appservice.d.ts +328 -0
- package/lib/appservice/Appservice.js +803 -0
- package/lib/appservice/Appservice.js.map +1 -0
- package/lib/appservice/Intent.d.ts +113 -0
- package/lib/appservice/Intent.js +363 -0
- package/lib/appservice/Intent.js.map +1 -0
- package/lib/appservice/MatrixBridge.d.ts +85 -0
- package/lib/appservice/MatrixBridge.js +111 -0
- package/lib/appservice/MatrixBridge.js.map +1 -0
- package/lib/appservice/UnstableAppserviceApis.d.ts +41 -0
- package/lib/appservice/UnstableAppserviceApis.js +62 -0
- package/lib/appservice/UnstableAppserviceApis.js.map +1 -0
- package/lib/appservice/http_responses.d.ts +77 -0
- package/lib/appservice/http_responses.js +3 -0
- package/lib/appservice/http_responses.js.map +1 -0
- package/lib/b64.d.ts +42 -0
- package/lib/b64.js +68 -0
- package/lib/b64.js.map +1 -0
- package/lib/e2ee/CrossSigningBootstrap.d.ts +73 -0
- package/lib/e2ee/CrossSigningBootstrap.js +86 -0
- package/lib/e2ee/CrossSigningBootstrap.js.map +1 -0
- package/lib/e2ee/CryptoClient.d.ts +163 -0
- package/lib/e2ee/CryptoClient.js +382 -0
- package/lib/e2ee/CryptoClient.js.map +1 -0
- package/lib/e2ee/ICryptoRoomInformation.d.ts +8 -0
- package/lib/e2ee/ICryptoRoomInformation.js +3 -0
- package/lib/e2ee/ICryptoRoomInformation.js.map +1 -0
- package/lib/e2ee/RoomTracker.d.ts +41 -0
- package/lib/e2ee/RoomTracker.js +96 -0
- package/lib/e2ee/RoomTracker.js.map +1 -0
- package/lib/e2ee/RustEngine.d.ts +149 -0
- package/lib/e2ee/RustEngine.js +467 -0
- package/lib/e2ee/RustEngine.js.map +1 -0
- package/lib/e2ee/decorators.d.ts +10 -0
- package/lib/e2ee/decorators.js +37 -0
- package/lib/e2ee/decorators.js.map +1 -0
- package/lib/helpers/MatrixEntity.d.ts +37 -0
- package/lib/helpers/MatrixEntity.js +67 -0
- package/lib/helpers/MatrixEntity.js.map +1 -0
- package/lib/helpers/MatrixGlob.d.ts +22 -0
- package/lib/helpers/MatrixGlob.js +35 -0
- package/lib/helpers/MatrixGlob.js.map +1 -0
- package/lib/helpers/MentionPill.d.ts +40 -0
- package/lib/helpers/MentionPill.js +91 -0
- package/lib/helpers/MentionPill.js.map +1 -0
- package/lib/helpers/Permalinks.d.ts +58 -0
- package/lib/helpers/Permalinks.js +73 -0
- package/lib/helpers/Permalinks.js.map +1 -0
- package/lib/helpers/ProfileCache.d.ts +48 -0
- package/lib/helpers/ProfileCache.js +114 -0
- package/lib/helpers/ProfileCache.js.map +1 -0
- package/lib/helpers/RichReply.d.ts +17 -0
- package/lib/helpers/RichReply.js +47 -0
- package/lib/helpers/RichReply.js.map +1 -0
- package/lib/helpers/UnpaddedBase64.d.ts +31 -0
- package/lib/helpers/UnpaddedBase64.js +45 -0
- package/lib/helpers/UnpaddedBase64.js.map +1 -0
- package/lib/http.d.ts +17 -0
- package/lib/http.js +147 -0
- package/lib/http.js.map +1 -0
- package/lib/identity/IdentityClient.d.ts +93 -0
- package/lib/identity/IdentityClient.js +248 -0
- package/lib/identity/IdentityClient.js.map +1 -0
- package/lib/index.d.ts +91 -0
- package/lib/index.js +125 -0
- package/lib/index.js.map +1 -0
- package/lib/logging/ConsoleLogger.d.ts +12 -0
- package/lib/logging/ConsoleLogger.js +28 -0
- package/lib/logging/ConsoleLogger.js.map +1 -0
- package/lib/logging/ILogger.d.ts +36 -0
- package/lib/logging/ILogger.js +3 -0
- package/lib/logging/ILogger.js.map +1 -0
- package/lib/logging/LogService.d.ts +100 -0
- package/lib/logging/LogService.js +169 -0
- package/lib/logging/LogService.js.map +1 -0
- package/lib/logging/RichConsoleLogger.d.ts +20 -0
- package/lib/logging/RichConsoleLogger.js +41 -0
- package/lib/logging/RichConsoleLogger.js.map +1 -0
- package/lib/metrics/IMetricListener.d.ts +52 -0
- package/lib/metrics/IMetricListener.js +3 -0
- package/lib/metrics/IMetricListener.js.map +1 -0
- package/lib/metrics/Metrics.d.ts +66 -0
- package/lib/metrics/Metrics.js +128 -0
- package/lib/metrics/Metrics.js.map +1 -0
- package/lib/metrics/contexts.d.ts +51 -0
- package/lib/metrics/contexts.js +3 -0
- package/lib/metrics/contexts.js.map +1 -0
- package/lib/metrics/decorators.d.ts +15 -0
- package/lib/metrics/decorators.js +92 -0
- package/lib/metrics/decorators.js.map +1 -0
- package/lib/metrics/names.d.ts +45 -0
- package/lib/metrics/names.js +49 -0
- package/lib/metrics/names.js.map +1 -0
- package/lib/mixins/AutojoinRoomsMixin.d.ts +10 -0
- package/lib/mixins/AutojoinRoomsMixin.js +25 -0
- package/lib/mixins/AutojoinRoomsMixin.js.map +1 -0
- package/lib/mixins/AutojoinUpgradedRoomsMixin.d.ts +10 -0
- package/lib/mixins/AutojoinUpgradedRoomsMixin.js +40 -0
- package/lib/mixins/AutojoinUpgradedRoomsMixin.js.map +1 -0
- package/lib/models/Account.d.ts +8 -0
- package/lib/models/Account.js +3 -0
- package/lib/models/Account.js.map +1 -0
- package/lib/models/CreateRoom.d.ts +125 -0
- package/lib/models/CreateRoom.js +3 -0
- package/lib/models/CreateRoom.js.map +1 -0
- package/lib/models/Crypto.d.ts +167 -0
- package/lib/models/Crypto.js +31 -0
- package/lib/models/Crypto.js.map +1 -0
- package/lib/models/EventContext.d.ts +19 -0
- package/lib/models/EventContext.js +3 -0
- package/lib/models/EventContext.js.map +1 -0
- package/lib/models/IdentityServerModels.d.ts +20 -0
- package/lib/models/IdentityServerModels.js +3 -0
- package/lib/models/IdentityServerModels.js.map +1 -0
- package/lib/models/MSC2176.d.ts +42 -0
- package/lib/models/MSC2176.js +3 -0
- package/lib/models/MSC2176.js.map +1 -0
- package/lib/models/MatrixError.d.ts +38 -0
- package/lib/models/MatrixError.js +30 -0
- package/lib/models/MatrixError.js.map +1 -0
- package/lib/models/MatrixProfile.d.ts +43 -0
- package/lib/models/MatrixProfile.js +43 -0
- package/lib/models/MatrixProfile.js.map +1 -0
- package/lib/models/OpenIDConnect.d.ts +10 -0
- package/lib/models/OpenIDConnect.js +3 -0
- package/lib/models/OpenIDConnect.js.map +1 -0
- package/lib/models/Policies.d.ts +25 -0
- package/lib/models/Policies.js +3 -0
- package/lib/models/Policies.js.map +1 -0
- package/lib/models/PowerLevelAction.d.ts +27 -0
- package/lib/models/PowerLevelAction.js +32 -0
- package/lib/models/PowerLevelAction.js.map +1 -0
- package/lib/models/PowerLevelBounds.d.ts +15 -0
- package/lib/models/PowerLevelBounds.js +3 -0
- package/lib/models/PowerLevelBounds.js.map +1 -0
- package/lib/models/Presence.d.ts +25 -0
- package/lib/models/Presence.js +38 -0
- package/lib/models/Presence.js.map +1 -0
- package/lib/models/ServerVersions.d.ts +8 -0
- package/lib/models/ServerVersions.js +3 -0
- package/lib/models/ServerVersions.js.map +1 -0
- package/lib/models/Spaces.d.ts +116 -0
- package/lib/models/Spaces.js +91 -0
- package/lib/models/Spaces.js.map +1 -0
- package/lib/models/Threepid.d.ts +8 -0
- package/lib/models/Threepid.js +3 -0
- package/lib/models/Threepid.js.map +1 -0
- package/lib/models/events/AliasesEvent.d.ts +27 -0
- package/lib/models/events/AliasesEvent.js +27 -0
- package/lib/models/events/AliasesEvent.js.map +1 -0
- package/lib/models/events/CanonicalAliasEvent.d.ts +23 -0
- package/lib/models/events/CanonicalAliasEvent.js +21 -0
- package/lib/models/events/CanonicalAliasEvent.js.map +1 -0
- package/lib/models/events/CreateEvent.d.ts +63 -0
- package/lib/models/events/CreateEvent.js +33 -0
- package/lib/models/events/CreateEvent.js.map +1 -0
- package/lib/models/events/EncryptedRoomEvent.d.ts +42 -0
- package/lib/models/events/EncryptedRoomEvent.js +28 -0
- package/lib/models/events/EncryptedRoomEvent.js.map +1 -0
- package/lib/models/events/EncryptionEvent.d.ts +47 -0
- package/lib/models/events/EncryptionEvent.js +42 -0
- package/lib/models/events/EncryptionEvent.js.map +1 -0
- package/lib/models/events/Event.d.ts +26 -0
- package/lib/models/events/Event.js +40 -0
- package/lib/models/events/Event.js.map +1 -0
- package/lib/models/events/EventKind.d.ts +15 -0
- package/lib/models/events/EventKind.js +20 -0
- package/lib/models/events/EventKind.js.map +1 -0
- package/lib/models/events/InvalidEventError.d.ts +14 -0
- package/lib/models/events/InvalidEventError.js +24 -0
- package/lib/models/events/InvalidEventError.js.map +1 -0
- package/lib/models/events/JoinRulesEvent.d.ts +29 -0
- package/lib/models/events/JoinRulesEvent.js +21 -0
- package/lib/models/events/JoinRulesEvent.js.map +1 -0
- package/lib/models/events/MembershipEvent.d.ts +54 -0
- package/lib/models/events/MembershipEvent.js +49 -0
- package/lib/models/events/MembershipEvent.js.map +1 -0
- package/lib/models/events/MessageEvent.d.ts +233 -0
- package/lib/models/events/MessageEvent.js +49 -0
- package/lib/models/events/MessageEvent.js.map +1 -0
- package/lib/models/events/PinnedEventsEvent.d.ts +23 -0
- package/lib/models/events/PinnedEventsEvent.js +21 -0
- package/lib/models/events/PinnedEventsEvent.js.map +1 -0
- package/lib/models/events/PowerLevelsEvent.d.ts +96 -0
- package/lib/models/events/PowerLevelsEvent.js +70 -0
- package/lib/models/events/PowerLevelsEvent.js.map +1 -0
- package/lib/models/events/PresenceEvent.d.ts +56 -0
- package/lib/models/events/PresenceEvent.js +21 -0
- package/lib/models/events/PresenceEvent.js.map +1 -0
- package/lib/models/events/RedactionEvent.d.ts +28 -0
- package/lib/models/events/RedactionEvent.js +36 -0
- package/lib/models/events/RedactionEvent.js.map +1 -0
- package/lib/models/events/RoomAvatarEvent.d.ts +28 -0
- package/lib/models/events/RoomAvatarEvent.js +21 -0
- package/lib/models/events/RoomAvatarEvent.js.map +1 -0
- package/lib/models/events/RoomEvent.d.ts +58 -0
- package/lib/models/events/RoomEvent.js +57 -0
- package/lib/models/events/RoomEvent.js.map +1 -0
- package/lib/models/events/RoomNameEvent.d.ts +20 -0
- package/lib/models/events/RoomNameEvent.js +21 -0
- package/lib/models/events/RoomNameEvent.js.map +1 -0
- package/lib/models/events/RoomTopicEvent.d.ts +20 -0
- package/lib/models/events/RoomTopicEvent.js +21 -0
- package/lib/models/events/RoomTopicEvent.js.map +1 -0
- package/lib/models/events/SpaceChildEvent.d.ts +53 -0
- package/lib/models/events/SpaceChildEvent.js +49 -0
- package/lib/models/events/SpaceChildEvent.js.map +1 -0
- package/lib/models/events/converter.d.ts +8 -0
- package/lib/models/events/converter.js +50 -0
- package/lib/models/events/converter.js.map +1 -0
- package/lib/models/unstable/MediaInfo.d.ts +16 -0
- package/lib/models/unstable/MediaInfo.js +3 -0
- package/lib/models/unstable/MediaInfo.js.map +1 -0
- package/lib/preprocessors/IPreprocessor.d.ts +22 -0
- package/lib/preprocessors/IPreprocessor.js +3 -0
- package/lib/preprocessors/IPreprocessor.js.map +1 -0
- package/lib/preprocessors/RichRepliesPreprocessor.d.ts +67 -0
- package/lib/preprocessors/RichRepliesPreprocessor.js +112 -0
- package/lib/preprocessors/RichRepliesPreprocessor.js.map +1 -0
- package/lib/request.d.ts +13 -0
- package/lib/request.js +23 -0
- package/lib/request.js.map +1 -0
- package/lib/simple-validation.d.ts +10 -0
- package/lib/simple-validation.js +30 -0
- package/lib/simple-validation.js.map +1 -0
- package/lib/storage/IAppserviceStorageProvider.d.ts +48 -0
- package/lib/storage/IAppserviceStorageProvider.js +3 -0
- package/lib/storage/IAppserviceStorageProvider.js.map +1 -0
- package/lib/storage/ICryptoStorageProvider.d.ts +32 -0
- package/lib/storage/ICryptoStorageProvider.js +3 -0
- package/lib/storage/ICryptoStorageProvider.js.map +1 -0
- package/lib/storage/IStorageProvider.d.ts +47 -0
- package/lib/storage/IStorageProvider.js +3 -0
- package/lib/storage/IStorageProvider.js.map +1 -0
- package/lib/storage/MemoryStorageProvider.d.ts +26 -0
- package/lib/storage/MemoryStorageProvider.js +55 -0
- package/lib/storage/MemoryStorageProvider.js.map +1 -0
- package/lib/storage/RustSdkCryptoStorageProvider.d.ts +38 -0
- package/lib/storage/RustSdkCryptoStorageProvider.js +69 -0
- package/lib/storage/RustSdkCryptoStorageProvider.js.map +1 -0
- package/lib/storage/SimpleFsStorageProvider.d.ts +31 -0
- package/lib/storage/SimpleFsStorageProvider.js +122 -0
- package/lib/storage/SimpleFsStorageProvider.js.map +1 -0
- package/lib/storage/SimplePostgresStorageProvider.d.ts +32 -0
- package/lib/storage/SimplePostgresStorageProvider.js +148 -0
- package/lib/storage/SimplePostgresStorageProvider.js.map +1 -0
- package/lib/strategies/AppserviceJoinRoomStrategy.d.ts +14 -0
- package/lib/strategies/AppserviceJoinRoomStrategy.js +54 -0
- package/lib/strategies/AppserviceJoinRoomStrategy.js.map +1 -0
- package/lib/strategies/JoinRoomStrategy.d.ts +11 -0
- package/lib/strategies/JoinRoomStrategy.js +44 -0
- package/lib/strategies/JoinRoomStrategy.js.map +1 -0
- package/package.json +136 -4
- package/src/AdminApis.ts +60 -0
- package/src/DMs.ts +164 -0
- package/src/IFilter.ts +7 -0
- package/src/MatrixAuth.ts +129 -0
- package/src/MatrixClient.ts +2046 -0
- package/src/PantalaimonClient.ts +62 -0
- package/src/SynapseAdminApis.ts +482 -0
- package/src/SynchronousMatrixClient.ts +129 -0
- package/src/UnstableApis.ts +75 -0
- package/src/appservice/Appservice.ts +1089 -0
- package/src/appservice/Intent.ts +342 -0
- package/src/appservice/MatrixBridge.ts +139 -0
- package/src/appservice/UnstableAppserviceApis.ts +63 -0
- package/src/appservice/http_responses.ts +77 -0
- package/src/b64.ts +63 -0
- package/src/e2ee/CrossSigningBootstrap.ts +141 -0
- package/src/e2ee/CryptoClient.ts +378 -0
- package/src/e2ee/ICryptoRoomInformation.ts +9 -0
- package/src/e2ee/RoomTracker.ts +99 -0
- package/src/e2ee/RustEngine.ts +580 -0
- package/src/e2ee/decorators.ts +38 -0
- package/src/helpers/MatrixEntity.ts +65 -0
- package/src/helpers/MatrixGlob.ts +38 -0
- package/src/helpers/MentionPill.ts +95 -0
- package/src/helpers/Permalinks.ts +101 -0
- package/src/helpers/ProfileCache.ts +119 -0
- package/src/helpers/RichReply.ts +46 -0
- package/src/helpers/UnpaddedBase64.ts +44 -0
- package/src/http.ts +166 -0
- package/src/identity/IdentityClient.ts +225 -0
- package/src/index.ts +125 -0
- package/src/logging/ConsoleLogger.ts +31 -0
- package/src/logging/ILogger.ts +40 -0
- package/src/logging/LogService.ts +167 -0
- package/src/logging/RichConsoleLogger.ts +70 -0
- package/src/metrics/IMetricListener.ts +57 -0
- package/src/metrics/Metrics.ts +134 -0
- package/src/metrics/contexts.ts +56 -0
- package/src/metrics/decorators.ts +94 -0
- package/src/metrics/names.ts +53 -0
- package/src/mixins/AutojoinRoomsMixin.ts +24 -0
- package/src/mixins/AutojoinUpgradedRoomsMixin.ts +37 -0
- package/src/models/Account.ts +8 -0
- package/src/models/CreateRoom.ts +144 -0
- package/src/models/Crypto.ts +188 -0
- package/src/models/EventContext.ts +23 -0
- package/src/models/IdentityServerModels.ts +18 -0
- package/src/models/MSC2176.ts +47 -0
- package/src/models/MatrixError.ts +39 -0
- package/src/models/MatrixProfile.ts +55 -0
- package/src/models/OpenIDConnect.ts +10 -0
- package/src/models/Policies.ts +28 -0
- package/src/models/PowerLevelAction.ts +31 -0
- package/src/models/PowerLevelBounds.ts +16 -0
- package/src/models/Presence.ts +38 -0
- package/src/models/ServerVersions.ts +8 -0
- package/src/models/Spaces.ts +167 -0
- package/src/models/Threepid.ts +8 -0
- package/src/models/events/AliasesEvent.ts +37 -0
- package/src/models/events/CanonicalAliasEvent.ts +30 -0
- package/src/models/events/CreateEvent.ts +82 -0
- package/src/models/events/EncryptedRoomEvent.ts +58 -0
- package/src/models/events/EncryptionEvent.ts +63 -0
- package/src/models/events/Event.ts +38 -0
- package/src/models/events/EventKind.ts +16 -0
- package/src/models/events/InvalidEventError.ts +19 -0
- package/src/models/events/JoinRulesEvent.ts +37 -0
- package/src/models/events/MembershipEvent.ts +77 -0
- package/src/models/events/MessageEvent.ts +292 -0
- package/src/models/events/PinnedEventsEvent.ts +30 -0
- package/src/models/events/PowerLevelsEvent.ts +135 -0
- package/src/models/events/PresenceEvent.ts +69 -0
- package/src/models/events/RedactionEvent.ts +44 -0
- package/src/models/events/RoomAvatarEvent.ts +36 -0
- package/src/models/events/RoomEvent.ts +83 -0
- package/src/models/events/RoomNameEvent.ts +27 -0
- package/src/models/events/RoomTopicEvent.ts +27 -0
- package/src/models/events/SpaceChildEvent.ts +74 -0
- package/src/models/events/_MissingEvents.md +35 -0
- package/src/models/events/converter.ts +47 -0
- package/src/models/unstable/MediaInfo.ts +16 -0
- package/src/preprocessors/IPreprocessor.ts +24 -0
- package/src/preprocessors/RichRepliesPreprocessor.ts +159 -0
- package/src/request.ts +21 -0
- package/src/simple-validation.ts +30 -0
- package/src/storage/IAppserviceStorageProvider.ts +54 -0
- package/src/storage/ICryptoStorageProvider.ts +36 -0
- package/src/storage/IStorageProvider.ts +53 -0
- package/src/storage/MemoryStorageProvider.ts +65 -0
- package/src/storage/RustSdkCryptoStorageProvider.ts +81 -0
- package/src/storage/SimpleFsStorageProvider.ts +142 -0
- package/src/storage/SimplePostgresStorageProvider.ts +168 -0
- package/src/strategies/AppserviceJoinRoomStrategy.ts +47 -0
- package/src/strategies/JoinRoomStrategy.ts +45 -0
- package/tsconfig.json +22 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { MatrixClient } from "../MatrixClient";
|
|
2
|
+
import { IMegolmEncrypted, IOlmEncrypted, IToDeviceMessage, OTKAlgorithm, OTKCounts, Signatures } from "../models/Crypto";
|
|
3
|
+
import { EncryptedRoomEvent } from "../models/events/EncryptedRoomEvent";
|
|
4
|
+
import { RoomEvent } from "../models/events/RoomEvent";
|
|
5
|
+
import { EncryptedFile } from "../models/events/MessageEvent";
|
|
6
|
+
import { UIACallback } from "./RustEngine";
|
|
7
|
+
import { EnsureCrossSigningOptions, EnsureCrossSigningResult, EnsureSecretStorageResult } from "./CrossSigningBootstrap";
|
|
8
|
+
/**
|
|
9
|
+
* Manages encryption for a MatrixClient. Get an instance from a MatrixClient directly
|
|
10
|
+
* rather than creating one manually.
|
|
11
|
+
* @category Encryption
|
|
12
|
+
*/
|
|
13
|
+
export declare class CryptoClient {
|
|
14
|
+
private client;
|
|
15
|
+
private ready;
|
|
16
|
+
private deviceId;
|
|
17
|
+
private deviceEd25519;
|
|
18
|
+
private deviceCurve25519;
|
|
19
|
+
private roomTracker;
|
|
20
|
+
private engine;
|
|
21
|
+
constructor(client: MatrixClient);
|
|
22
|
+
private get storage();
|
|
23
|
+
/**
|
|
24
|
+
* The device ID for the MatrixClient.
|
|
25
|
+
*/
|
|
26
|
+
get clientDeviceId(): string;
|
|
27
|
+
/**
|
|
28
|
+
* The device's Ed25519 identity
|
|
29
|
+
*/
|
|
30
|
+
get clientDeviceEd25519(): string;
|
|
31
|
+
/**
|
|
32
|
+
* Whether or not the crypto client is ready to be used. If not ready, prepare() should be called.
|
|
33
|
+
* @see prepare
|
|
34
|
+
*/
|
|
35
|
+
get isReady(): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Prepares the crypto client for usage.
|
|
38
|
+
* @param {string[]} roomIds The room IDs the MatrixClient is joined to.
|
|
39
|
+
*/
|
|
40
|
+
prepare(roomIds: string[]): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Handles a room event.
|
|
43
|
+
* @internal
|
|
44
|
+
* @param roomId The room ID.
|
|
45
|
+
* @param event The event.
|
|
46
|
+
*/
|
|
47
|
+
onRoomEvent(roomId: string, event: any): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Handles a room join.
|
|
50
|
+
* @internal
|
|
51
|
+
* @param roomId The room ID.
|
|
52
|
+
*/
|
|
53
|
+
onRoomJoin(roomId: string): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Checks if a room is encrypted.
|
|
56
|
+
* @param {string} roomId The room ID to check.
|
|
57
|
+
* @returns {Promise<boolean>} Resolves to true if encrypted, false otherwise.
|
|
58
|
+
*/
|
|
59
|
+
isRoomEncrypted(roomId: string): Promise<boolean>;
|
|
60
|
+
/**
|
|
61
|
+
* Updates the client's sync-related data.
|
|
62
|
+
* @param {Array.<IToDeviceMessage<IOlmEncrypted>>} toDeviceMessages The to-device messages received.
|
|
63
|
+
* @param {OTKCounts} otkCounts The current OTK counts.
|
|
64
|
+
* @param {OTKAlgorithm[]} unusedFallbackKeyAlgs The unused fallback key algorithms.
|
|
65
|
+
* @param {string[]} changedDeviceLists The user IDs which had device list changes.
|
|
66
|
+
* @param {string[]} leftDeviceLists The user IDs which the server believes we no longer need to track.
|
|
67
|
+
* @returns {Promise<void>} Resolves when complete.
|
|
68
|
+
*/
|
|
69
|
+
updateSyncData(toDeviceMessages: IToDeviceMessage<IOlmEncrypted>[], otkCounts: OTKCounts, unusedFallbackKeyAlgs: OTKAlgorithm[], changedDeviceLists: string[], leftDeviceLists: string[]): Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* Signs an object using the device keys.
|
|
72
|
+
* @param {object} obj The object to sign.
|
|
73
|
+
* @returns {Promise<Signatures>} The signatures for the object.
|
|
74
|
+
*/
|
|
75
|
+
sign(obj: object): Promise<Signatures>;
|
|
76
|
+
/**
|
|
77
|
+
* Encrypts the details of a room event, returning an encrypted payload to be sent in an
|
|
78
|
+
* `m.room.encrypted` event to the room. If needed, this function will send decryption keys
|
|
79
|
+
* to the appropriate devices in the room (this happens when the Megolm session rotates or
|
|
80
|
+
* gets created).
|
|
81
|
+
* @param {string} roomId The room ID to encrypt within. If the room is not encrypted, an
|
|
82
|
+
* error is thrown.
|
|
83
|
+
* @param {string} eventType The event type being encrypted.
|
|
84
|
+
* @param {any} content The event content being encrypted.
|
|
85
|
+
* @returns {Promise<IMegolmEncrypted>} Resolves to the encrypted content for an `m.room.encrypted` event.
|
|
86
|
+
*/
|
|
87
|
+
encryptRoomEvent(roomId: string, eventType: string, content: any): Promise<IMegolmEncrypted>;
|
|
88
|
+
/**
|
|
89
|
+
* Decrypts a room event. Currently only supports Megolm-encrypted events (default for this SDK).
|
|
90
|
+
* @param {EncryptedRoomEvent} event The encrypted event.
|
|
91
|
+
* @param {string} roomId The room ID where the event was sent.
|
|
92
|
+
* @returns {Promise<RoomEvent<unknown>>} Resolves to a decrypted room event, or rejects/throws with
|
|
93
|
+
* an error if the event is undecryptable.
|
|
94
|
+
*/
|
|
95
|
+
decryptRoomEvent(event: EncryptedRoomEvent, roomId: string): Promise<RoomEvent<unknown>>;
|
|
96
|
+
/**
|
|
97
|
+
* Encrypts a file for uploading in a room, returning the encrypted data and information
|
|
98
|
+
* to include in a message event (except media URL) for sending.
|
|
99
|
+
* @param {Buffer} file The file to encrypt.
|
|
100
|
+
* @returns {{buffer: Buffer, file: Omit<EncryptedFile, "url">}} Resolves to the encrypted
|
|
101
|
+
* contents and file information.
|
|
102
|
+
*/
|
|
103
|
+
encryptMedia(file: Buffer): Promise<{
|
|
104
|
+
buffer: Buffer;
|
|
105
|
+
file: Omit<EncryptedFile, "url">;
|
|
106
|
+
}>;
|
|
107
|
+
/**
|
|
108
|
+
* Decrypts a previously-uploaded encrypted file, validating the fields along the way.
|
|
109
|
+
* @param {EncryptedFile} file The file to decrypt.
|
|
110
|
+
* @returns {Promise<Buffer>} Resolves to the decrypted file contents.
|
|
111
|
+
*/
|
|
112
|
+
decryptMedia(file: EncryptedFile): Promise<Buffer>;
|
|
113
|
+
/**
|
|
114
|
+
* Creates and uploads a cross-signing identity, then signs this device with it.
|
|
115
|
+
* @param {UIACallback} uiaCallback Answers the UIA challenge for the key upload.
|
|
116
|
+
* @param {boolean} reset Whether to replace an existing local identity.
|
|
117
|
+
*/
|
|
118
|
+
bootstrapCrossSigning(uiaCallback: UIACallback, reset?: boolean): Promise<void>;
|
|
119
|
+
/**
|
|
120
|
+
* Sets up secret storage (4S) from a passphrase and stores the cross-signing
|
|
121
|
+
* keys in it. Requires the cross-signing private keys to be available locally.
|
|
122
|
+
* @param {string} passphrase The secret storage passphrase.
|
|
123
|
+
* @param opts Whether to also set up server-side key backup, and whether to reset.
|
|
124
|
+
*/
|
|
125
|
+
bootstrapSecretStorageFromPassphrase(passphrase: string, opts?: {
|
|
126
|
+
withKeyBackup?: boolean;
|
|
127
|
+
reset?: boolean;
|
|
128
|
+
}): Promise<void>;
|
|
129
|
+
/**
|
|
130
|
+
* Restores the cross-signing keys from secret storage, e.g. after losing the
|
|
131
|
+
* crypto store, without invalidating other devices' trust.
|
|
132
|
+
* @param {string} passphrase The secret storage passphrase.
|
|
133
|
+
*/
|
|
134
|
+
restoreSecretsFromSecretStorage(passphrase: string): Promise<void>;
|
|
135
|
+
/**
|
|
136
|
+
* Whether this device is signed by the account's self-signing key.
|
|
137
|
+
*/
|
|
138
|
+
isOwnDeviceCrossSigned(): Promise<boolean>;
|
|
139
|
+
/**
|
|
140
|
+
* Whether the account has a default secret storage key.
|
|
141
|
+
*/
|
|
142
|
+
hasSecretStorage(): Promise<boolean>;
|
|
143
|
+
/**
|
|
144
|
+
* Makes sure this device is cross-signed. In order: does nothing if it already
|
|
145
|
+
* is; restores the keys from secret storage if a passphrase is given and the
|
|
146
|
+
* account has secret storage; otherwise creates a new identity (replacing the
|
|
147
|
+
* account's existing one) if a UIA callback is given. Errors are thrown.
|
|
148
|
+
* @param {EnsureCrossSigningOptions} opts Credentials for restoring or bootstrapping.
|
|
149
|
+
* @returns {Promise<EnsureCrossSigningResult>} What was done.
|
|
150
|
+
*/
|
|
151
|
+
ensureCrossSigning(opts?: EnsureCrossSigningOptions): Promise<EnsureCrossSigningResult>;
|
|
152
|
+
/**
|
|
153
|
+
* Sets up secret storage from a passphrase unless the account already has it.
|
|
154
|
+
* Call after {@link ensureCrossSigning}, since the cross-signing private keys
|
|
155
|
+
* must be available locally to be stored.
|
|
156
|
+
* @param {string} passphrase The secret storage passphrase.
|
|
157
|
+
* @param opts Whether to also set up server-side key backup (default true).
|
|
158
|
+
* @returns {Promise<EnsureSecretStorageResult>} What was done.
|
|
159
|
+
*/
|
|
160
|
+
ensureSecretStorage(passphrase: string, opts?: {
|
|
161
|
+
withKeyBackup?: boolean;
|
|
162
|
+
}): Promise<EnsureSecretStorageResult>;
|
|
163
|
+
}
|
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.CryptoClient = void 0;
|
|
13
|
+
const matrix_sdk_crypto_nodejs_1 = require("@matrix-org/matrix-sdk-crypto-nodejs");
|
|
14
|
+
const LogService_1 = require("../logging/LogService");
|
|
15
|
+
const decorators_1 = require("./decorators");
|
|
16
|
+
const RoomTracker_1 = require("./RoomTracker");
|
|
17
|
+
const EncryptedRoomEvent_1 = require("../models/events/EncryptedRoomEvent");
|
|
18
|
+
const RoomEvent_1 = require("../models/events/RoomEvent");
|
|
19
|
+
const RustEngine_1 = require("./RustEngine");
|
|
20
|
+
const CrossSigningBootstrap_1 = require("./CrossSigningBootstrap");
|
|
21
|
+
const MembershipEvent_1 = require("../models/events/MembershipEvent");
|
|
22
|
+
/**
|
|
23
|
+
* Manages encryption for a MatrixClient. Get an instance from a MatrixClient directly
|
|
24
|
+
* rather than creating one manually.
|
|
25
|
+
* @category Encryption
|
|
26
|
+
*/
|
|
27
|
+
class CryptoClient {
|
|
28
|
+
constructor(client) {
|
|
29
|
+
this.client = client;
|
|
30
|
+
this.ready = false;
|
|
31
|
+
this.roomTracker = new RoomTracker_1.RoomTracker(this.client);
|
|
32
|
+
}
|
|
33
|
+
get storage() {
|
|
34
|
+
return this.client.cryptoStore;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The device ID for the MatrixClient.
|
|
38
|
+
*/
|
|
39
|
+
get clientDeviceId() {
|
|
40
|
+
return this.deviceId;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The device's Ed25519 identity
|
|
44
|
+
*/
|
|
45
|
+
get clientDeviceEd25519() {
|
|
46
|
+
return this.deviceEd25519;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Whether or not the crypto client is ready to be used. If not ready, prepare() should be called.
|
|
50
|
+
* @see prepare
|
|
51
|
+
*/
|
|
52
|
+
get isReady() {
|
|
53
|
+
return this.ready;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Prepares the crypto client for usage.
|
|
57
|
+
* @param {string[]} roomIds The room IDs the MatrixClient is joined to.
|
|
58
|
+
*/
|
|
59
|
+
async prepare(roomIds) {
|
|
60
|
+
await this.roomTracker.prepare(roomIds);
|
|
61
|
+
if (this.ready)
|
|
62
|
+
return; // stop re-preparing here
|
|
63
|
+
const storedDeviceId = await this.client.cryptoStore.getDeviceId();
|
|
64
|
+
if (storedDeviceId) {
|
|
65
|
+
this.deviceId = storedDeviceId;
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
const deviceId = (await this.client.getWhoAmI())['device_id'];
|
|
69
|
+
if (!deviceId) {
|
|
70
|
+
throw new Error("Encryption not possible: server not revealing device ID");
|
|
71
|
+
}
|
|
72
|
+
this.deviceId = deviceId;
|
|
73
|
+
await this.client.cryptoStore.setDeviceId(this.deviceId);
|
|
74
|
+
}
|
|
75
|
+
LogService_1.LogService.info("CryptoClient", "Starting with device ID:", this.deviceId); // info so all bots know for debugging
|
|
76
|
+
const machine = await matrix_sdk_crypto_nodejs_1.OlmMachine.initialize(new matrix_sdk_crypto_nodejs_1.UserId(await this.client.getUserId()), new matrix_sdk_crypto_nodejs_1.DeviceId(this.deviceId), this.storage.storagePath, "", this.storage.storageType);
|
|
77
|
+
this.engine = new RustEngine_1.RustEngine(machine, this.client);
|
|
78
|
+
await this.engine.run();
|
|
79
|
+
const identity = this.engine.machine.identityKeys;
|
|
80
|
+
this.deviceCurve25519 = identity.curve25519.toBase64();
|
|
81
|
+
this.deviceEd25519 = identity.ed25519.toBase64();
|
|
82
|
+
LogService_1.LogService.debug("CryptoClient", "Running with device Ed25519 identity:", this.deviceEd25519); // info so all bots know for debugging
|
|
83
|
+
this.ready = true;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Handles a room event.
|
|
87
|
+
* @internal
|
|
88
|
+
* @param roomId The room ID.
|
|
89
|
+
* @param event The event.
|
|
90
|
+
*/
|
|
91
|
+
async onRoomEvent(roomId, event) {
|
|
92
|
+
await this.roomTracker.onRoomEvent(roomId, event);
|
|
93
|
+
if (typeof event['state_key'] !== 'string')
|
|
94
|
+
return;
|
|
95
|
+
if (event['type'] === 'm.room.member') {
|
|
96
|
+
const membership = new MembershipEvent_1.MembershipEvent(event);
|
|
97
|
+
if (membership.effectiveMembership !== 'join' && membership.effectiveMembership !== 'invite')
|
|
98
|
+
return;
|
|
99
|
+
await this.engine.addTrackedUsers([membership.membershipFor]);
|
|
100
|
+
}
|
|
101
|
+
else if (event['type'] === 'm.room.encryption') {
|
|
102
|
+
const members = await this.client.getRoomMembers(roomId, null, ['join', 'invite']);
|
|
103
|
+
await this.engine.addTrackedUsers(members.map(e => e.membershipFor));
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Handles a room join.
|
|
108
|
+
* @internal
|
|
109
|
+
* @param roomId The room ID.
|
|
110
|
+
*/
|
|
111
|
+
async onRoomJoin(roomId) {
|
|
112
|
+
await this.roomTracker.onRoomJoin(roomId);
|
|
113
|
+
if (await this.isRoomEncrypted(roomId)) {
|
|
114
|
+
const members = await this.client.getRoomMembers(roomId, null, ['join', 'invite']);
|
|
115
|
+
await this.engine.addTrackedUsers(members.map(e => e.membershipFor));
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Checks if a room is encrypted.
|
|
120
|
+
* @param {string} roomId The room ID to check.
|
|
121
|
+
* @returns {Promise<boolean>} Resolves to true if encrypted, false otherwise.
|
|
122
|
+
*/
|
|
123
|
+
async isRoomEncrypted(roomId) {
|
|
124
|
+
const config = await this.roomTracker.getRoomCryptoConfig(roomId);
|
|
125
|
+
return !!config?.algorithm;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Updates the client's sync-related data.
|
|
129
|
+
* @param {Array.<IToDeviceMessage<IOlmEncrypted>>} toDeviceMessages The to-device messages received.
|
|
130
|
+
* @param {OTKCounts} otkCounts The current OTK counts.
|
|
131
|
+
* @param {OTKAlgorithm[]} unusedFallbackKeyAlgs The unused fallback key algorithms.
|
|
132
|
+
* @param {string[]} changedDeviceLists The user IDs which had device list changes.
|
|
133
|
+
* @param {string[]} leftDeviceLists The user IDs which the server believes we no longer need to track.
|
|
134
|
+
* @returns {Promise<void>} Resolves when complete.
|
|
135
|
+
*/
|
|
136
|
+
async updateSyncData(toDeviceMessages, otkCounts, unusedFallbackKeyAlgs, changedDeviceLists, leftDeviceLists) {
|
|
137
|
+
const deviceMessages = JSON.stringify(toDeviceMessages);
|
|
138
|
+
const deviceLists = new matrix_sdk_crypto_nodejs_1.DeviceLists(changedDeviceLists.map(u => new matrix_sdk_crypto_nodejs_1.UserId(u)), leftDeviceLists.map(u => new matrix_sdk_crypto_nodejs_1.UserId(u)));
|
|
139
|
+
await this.engine.lock.acquire(RustEngine_1.SYNC_LOCK_NAME, async () => {
|
|
140
|
+
const syncResp = await this.engine.machine.receiveSyncChanges(deviceMessages, deviceLists, otkCounts, unusedFallbackKeyAlgs);
|
|
141
|
+
const decryptedToDeviceMessages = JSON.parse(syncResp);
|
|
142
|
+
if (Array.isArray(decryptedToDeviceMessages)) {
|
|
143
|
+
for (const msg of decryptedToDeviceMessages) {
|
|
144
|
+
this.client.emit("to_device.decrypted", msg);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
await this.engine.run();
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Signs an object using the device keys.
|
|
152
|
+
* @param {object} obj The object to sign.
|
|
153
|
+
* @returns {Promise<Signatures>} The signatures for the object.
|
|
154
|
+
*/
|
|
155
|
+
async sign(obj) {
|
|
156
|
+
obj = JSON.parse(JSON.stringify(obj));
|
|
157
|
+
const existingSignatures = obj['signatures'] || {};
|
|
158
|
+
delete obj['signatures'];
|
|
159
|
+
delete obj['unsigned'];
|
|
160
|
+
const container = await this.engine.machine.sign(JSON.stringify(obj));
|
|
161
|
+
const userSignature = container.get(new matrix_sdk_crypto_nodejs_1.UserId(await this.client.getUserId()));
|
|
162
|
+
const sig = {
|
|
163
|
+
[await this.client.getUserId()]: {},
|
|
164
|
+
};
|
|
165
|
+
for (const [key, maybeSignature] of Object.entries(userSignature)) {
|
|
166
|
+
if (maybeSignature.isValid) {
|
|
167
|
+
sig[await this.client.getUserId()][key] = maybeSignature.signature.toBase64();
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return {
|
|
171
|
+
...sig,
|
|
172
|
+
...existingSignatures,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Encrypts the details of a room event, returning an encrypted payload to be sent in an
|
|
177
|
+
* `m.room.encrypted` event to the room. If needed, this function will send decryption keys
|
|
178
|
+
* to the appropriate devices in the room (this happens when the Megolm session rotates or
|
|
179
|
+
* gets created).
|
|
180
|
+
* @param {string} roomId The room ID to encrypt within. If the room is not encrypted, an
|
|
181
|
+
* error is thrown.
|
|
182
|
+
* @param {string} eventType The event type being encrypted.
|
|
183
|
+
* @param {any} content The event content being encrypted.
|
|
184
|
+
* @returns {Promise<IMegolmEncrypted>} Resolves to the encrypted content for an `m.room.encrypted` event.
|
|
185
|
+
*/
|
|
186
|
+
async encryptRoomEvent(roomId, eventType, content) {
|
|
187
|
+
if (!(await this.isRoomEncrypted(roomId))) {
|
|
188
|
+
throw new Error("Room is not encrypted");
|
|
189
|
+
}
|
|
190
|
+
await this.engine.prepareEncrypt(roomId, await this.roomTracker.getRoomCryptoConfig(roomId));
|
|
191
|
+
const encrypted = JSON.parse(await this.engine.machine.encryptRoomEvent(new matrix_sdk_crypto_nodejs_1.RoomId(roomId), eventType, JSON.stringify(content)));
|
|
192
|
+
await this.engine.run();
|
|
193
|
+
return encrypted;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Decrypts a room event. Currently only supports Megolm-encrypted events (default for this SDK).
|
|
197
|
+
* @param {EncryptedRoomEvent} event The encrypted event.
|
|
198
|
+
* @param {string} roomId The room ID where the event was sent.
|
|
199
|
+
* @returns {Promise<RoomEvent<unknown>>} Resolves to a decrypted room event, or rejects/throws with
|
|
200
|
+
* an error if the event is undecryptable.
|
|
201
|
+
*/
|
|
202
|
+
async decryptRoomEvent(event, roomId) {
|
|
203
|
+
const decrypted = await this.engine.machine.decryptRoomEvent(JSON.stringify(event.raw), new matrix_sdk_crypto_nodejs_1.RoomId(roomId));
|
|
204
|
+
const clearEvent = JSON.parse(decrypted.event);
|
|
205
|
+
return new RoomEvent_1.RoomEvent({
|
|
206
|
+
...event.raw,
|
|
207
|
+
type: clearEvent.type || "io.t2bot.unknown",
|
|
208
|
+
content: (typeof (clearEvent.content) === 'object') ? clearEvent.content : {},
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Encrypts a file for uploading in a room, returning the encrypted data and information
|
|
213
|
+
* to include in a message event (except media URL) for sending.
|
|
214
|
+
* @param {Buffer} file The file to encrypt.
|
|
215
|
+
* @returns {{buffer: Buffer, file: Omit<EncryptedFile, "url">}} Resolves to the encrypted
|
|
216
|
+
* contents and file information.
|
|
217
|
+
*/
|
|
218
|
+
async encryptMedia(file) {
|
|
219
|
+
const encrypted = matrix_sdk_crypto_nodejs_1.Attachment.encrypt(file);
|
|
220
|
+
const info = JSON.parse(encrypted.mediaEncryptionInfo);
|
|
221
|
+
return {
|
|
222
|
+
buffer: Buffer.from(encrypted.encryptedData),
|
|
223
|
+
file: info,
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Decrypts a previously-uploaded encrypted file, validating the fields along the way.
|
|
228
|
+
* @param {EncryptedFile} file The file to decrypt.
|
|
229
|
+
* @returns {Promise<Buffer>} Resolves to the decrypted file contents.
|
|
230
|
+
*/
|
|
231
|
+
async decryptMedia(file) {
|
|
232
|
+
const contents = (await this.client.downloadContent(file.url)).data;
|
|
233
|
+
const encrypted = new matrix_sdk_crypto_nodejs_1.EncryptedAttachment(contents, JSON.stringify(file));
|
|
234
|
+
const decrypted = matrix_sdk_crypto_nodejs_1.Attachment.decrypt(encrypted);
|
|
235
|
+
return Buffer.from(decrypted);
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Creates and uploads a cross-signing identity, then signs this device with it.
|
|
239
|
+
* @param {UIACallback} uiaCallback Answers the UIA challenge for the key upload.
|
|
240
|
+
* @param {boolean} reset Whether to replace an existing local identity.
|
|
241
|
+
*/
|
|
242
|
+
async bootstrapCrossSigning(uiaCallback, reset = false) {
|
|
243
|
+
return this.engine.bootstrapCrossSigning(uiaCallback, reset);
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Sets up secret storage (4S) from a passphrase and stores the cross-signing
|
|
247
|
+
* keys in it. Requires the cross-signing private keys to be available locally.
|
|
248
|
+
* @param {string} passphrase The secret storage passphrase.
|
|
249
|
+
* @param opts Whether to also set up server-side key backup, and whether to reset.
|
|
250
|
+
*/
|
|
251
|
+
async bootstrapSecretStorageFromPassphrase(passphrase, opts = {}) {
|
|
252
|
+
return this.engine.bootstrapSecretStorageFromPassphrase(passphrase, opts);
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Restores the cross-signing keys from secret storage, e.g. after losing the
|
|
256
|
+
* crypto store, without invalidating other devices' trust.
|
|
257
|
+
* @param {string} passphrase The secret storage passphrase.
|
|
258
|
+
*/
|
|
259
|
+
async restoreSecretsFromSecretStorage(passphrase) {
|
|
260
|
+
return this.engine.restoreSecretsFromSecretStorage(passphrase);
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Whether this device is signed by the account's self-signing key.
|
|
264
|
+
*/
|
|
265
|
+
async isOwnDeviceCrossSigned() {
|
|
266
|
+
return (0, CrossSigningBootstrap_1.isOwnDeviceCrossSigned)(this.client, this.deviceId);
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Whether the account has a default secret storage key.
|
|
270
|
+
*/
|
|
271
|
+
async hasSecretStorage() {
|
|
272
|
+
return (0, CrossSigningBootstrap_1.hasSecretStorage)(this.client);
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Makes sure this device is cross-signed. In order: does nothing if it already
|
|
276
|
+
* is; restores the keys from secret storage if a passphrase is given and the
|
|
277
|
+
* account has secret storage; otherwise creates a new identity (replacing the
|
|
278
|
+
* account's existing one) if a UIA callback is given. Errors are thrown.
|
|
279
|
+
* @param {EnsureCrossSigningOptions} opts Credentials for restoring or bootstrapping.
|
|
280
|
+
* @returns {Promise<EnsureCrossSigningResult>} What was done.
|
|
281
|
+
*/
|
|
282
|
+
async ensureCrossSigning(opts = {}) {
|
|
283
|
+
return (0, CrossSigningBootstrap_1.ensureCrossSigning)(this.client, this.engine, this.deviceId, opts);
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Sets up secret storage from a passphrase unless the account already has it.
|
|
287
|
+
* Call after {@link ensureCrossSigning}, since the cross-signing private keys
|
|
288
|
+
* must be available locally to be stored.
|
|
289
|
+
* @param {string} passphrase The secret storage passphrase.
|
|
290
|
+
* @param opts Whether to also set up server-side key backup (default true).
|
|
291
|
+
* @returns {Promise<EnsureSecretStorageResult>} What was done.
|
|
292
|
+
*/
|
|
293
|
+
async ensureSecretStorage(passphrase, opts = {}) {
|
|
294
|
+
return (0, CrossSigningBootstrap_1.ensureSecretStorage)(this.client, this.engine, passphrase, opts);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
exports.CryptoClient = CryptoClient;
|
|
298
|
+
__decorate([
|
|
299
|
+
(0, decorators_1.requiresReady)(),
|
|
300
|
+
__metadata("design:type", Function),
|
|
301
|
+
__metadata("design:paramtypes", [String]),
|
|
302
|
+
__metadata("design:returntype", Promise)
|
|
303
|
+
], CryptoClient.prototype, "isRoomEncrypted", null);
|
|
304
|
+
__decorate([
|
|
305
|
+
(0, decorators_1.requiresReady)(),
|
|
306
|
+
__metadata("design:type", Function),
|
|
307
|
+
__metadata("design:paramtypes", [Array, Object, Array, Array, Array]),
|
|
308
|
+
__metadata("design:returntype", Promise)
|
|
309
|
+
], CryptoClient.prototype, "updateSyncData", null);
|
|
310
|
+
__decorate([
|
|
311
|
+
(0, decorators_1.requiresReady)(),
|
|
312
|
+
__metadata("design:type", Function),
|
|
313
|
+
__metadata("design:paramtypes", [Object]),
|
|
314
|
+
__metadata("design:returntype", Promise)
|
|
315
|
+
], CryptoClient.prototype, "sign", null);
|
|
316
|
+
__decorate([
|
|
317
|
+
(0, decorators_1.requiresReady)(),
|
|
318
|
+
__metadata("design:type", Function),
|
|
319
|
+
__metadata("design:paramtypes", [String, String, Object]),
|
|
320
|
+
__metadata("design:returntype", Promise)
|
|
321
|
+
], CryptoClient.prototype, "encryptRoomEvent", null);
|
|
322
|
+
__decorate([
|
|
323
|
+
(0, decorators_1.requiresReady)(),
|
|
324
|
+
__metadata("design:type", Function),
|
|
325
|
+
__metadata("design:paramtypes", [EncryptedRoomEvent_1.EncryptedRoomEvent, String]),
|
|
326
|
+
__metadata("design:returntype", Promise)
|
|
327
|
+
], CryptoClient.prototype, "decryptRoomEvent", null);
|
|
328
|
+
__decorate([
|
|
329
|
+
(0, decorators_1.requiresReady)(),
|
|
330
|
+
__metadata("design:type", Function),
|
|
331
|
+
__metadata("design:paramtypes", [Buffer]),
|
|
332
|
+
__metadata("design:returntype", Promise)
|
|
333
|
+
], CryptoClient.prototype, "encryptMedia", null);
|
|
334
|
+
__decorate([
|
|
335
|
+
(0, decorators_1.requiresReady)(),
|
|
336
|
+
__metadata("design:type", Function),
|
|
337
|
+
__metadata("design:paramtypes", [Object]),
|
|
338
|
+
__metadata("design:returntype", Promise)
|
|
339
|
+
], CryptoClient.prototype, "decryptMedia", null);
|
|
340
|
+
__decorate([
|
|
341
|
+
(0, decorators_1.requiresReady)(),
|
|
342
|
+
__metadata("design:type", Function),
|
|
343
|
+
__metadata("design:paramtypes", [Function, Object]),
|
|
344
|
+
__metadata("design:returntype", Promise)
|
|
345
|
+
], CryptoClient.prototype, "bootstrapCrossSigning", null);
|
|
346
|
+
__decorate([
|
|
347
|
+
(0, decorators_1.requiresReady)(),
|
|
348
|
+
__metadata("design:type", Function),
|
|
349
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
350
|
+
__metadata("design:returntype", Promise)
|
|
351
|
+
], CryptoClient.prototype, "bootstrapSecretStorageFromPassphrase", null);
|
|
352
|
+
__decorate([
|
|
353
|
+
(0, decorators_1.requiresReady)(),
|
|
354
|
+
__metadata("design:type", Function),
|
|
355
|
+
__metadata("design:paramtypes", [String]),
|
|
356
|
+
__metadata("design:returntype", Promise)
|
|
357
|
+
], CryptoClient.prototype, "restoreSecretsFromSecretStorage", null);
|
|
358
|
+
__decorate([
|
|
359
|
+
(0, decorators_1.requiresReady)(),
|
|
360
|
+
__metadata("design:type", Function),
|
|
361
|
+
__metadata("design:paramtypes", []),
|
|
362
|
+
__metadata("design:returntype", Promise)
|
|
363
|
+
], CryptoClient.prototype, "isOwnDeviceCrossSigned", null);
|
|
364
|
+
__decorate([
|
|
365
|
+
(0, decorators_1.requiresReady)(),
|
|
366
|
+
__metadata("design:type", Function),
|
|
367
|
+
__metadata("design:paramtypes", []),
|
|
368
|
+
__metadata("design:returntype", Promise)
|
|
369
|
+
], CryptoClient.prototype, "hasSecretStorage", null);
|
|
370
|
+
__decorate([
|
|
371
|
+
(0, decorators_1.requiresReady)(),
|
|
372
|
+
__metadata("design:type", Function),
|
|
373
|
+
__metadata("design:paramtypes", [Object]),
|
|
374
|
+
__metadata("design:returntype", Promise)
|
|
375
|
+
], CryptoClient.prototype, "ensureCrossSigning", null);
|
|
376
|
+
__decorate([
|
|
377
|
+
(0, decorators_1.requiresReady)(),
|
|
378
|
+
__metadata("design:type", Function),
|
|
379
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
380
|
+
__metadata("design:returntype", Promise)
|
|
381
|
+
], CryptoClient.prototype, "ensureSecretStorage", null);
|
|
382
|
+
//# sourceMappingURL=CryptoClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CryptoClient.js","sourceRoot":"","sources":["../../src/e2ee/CryptoClient.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mFAQ8C;AAG9C,sDAAmD;AASnD,6CAA6C;AAC7C,+CAA4C;AAC5C,4EAAyE;AACzE,0DAAuD;AAGvD,6CAAuE;AACvE,mEAQiC;AACjC,sEAAmE;AAEnE;;;;GAIG;AACH,MAAa,YAAY;IAQrB,YAA2B,MAAoB;QAApB,WAAM,GAAN,MAAM,CAAc;QAPvC,UAAK,GAAG,KAAK,CAAC;QAQlB,IAAI,CAAC,WAAW,GAAG,IAAI,yBAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACpD,CAAC;IAED,IAAY,OAAO;QACf,OAAsC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;IAClE,CAAC;IAED;;OAEG;IACH,IAAW,cAAc;QACrB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,IAAW,mBAAmB;QAC1B,OAAO,IAAI,CAAC,aAAa,CAAC;IAC9B,CAAC;IAED;;;OAGG;IACH,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,OAAO,CAAC,OAAiB;QAClC,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAExC,IAAI,IAAI,CAAC,KAAK;YAAE,OAAO,CAAC,yBAAyB;QAEjD,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC;QACnE,IAAI,cAAc,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BAAa,GAAE;;;;mEAGf;AAMY;IADZ,IAAA,0BAAa,GAAE;;;;0DAGf;AAMY;IADZ,IAAA,0BAAa,GAAE;;;;oDAGf;AAWY;IADZ,IAAA,0BAAa,GAAE;;;;sDAGf;AAWY;IADZ,IAAA,0BAAa,GAAE;;;;uDAGf"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { EncryptionEventContent } from "../models/events/EncryptionEvent";
|
|
2
|
+
/**
|
|
3
|
+
* Information about a room for the purposes of crypto.
|
|
4
|
+
* @category Encryption
|
|
5
|
+
*/
|
|
6
|
+
export interface ICryptoRoomInformation extends Partial<EncryptionEventContent> {
|
|
7
|
+
historyVisibility?: string;
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ICryptoRoomInformation.js","sourceRoot":"","sources":["../../src/e2ee/ICryptoRoomInformation.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { MatrixClient } from "../MatrixClient";
|
|
2
|
+
import { ICryptoRoomInformation } from "./ICryptoRoomInformation";
|
|
3
|
+
/**
|
|
4
|
+
* Tracks room encryption status for a MatrixClient.
|
|
5
|
+
* @category Encryption
|
|
6
|
+
*/
|
|
7
|
+
export declare class RoomTracker {
|
|
8
|
+
private client;
|
|
9
|
+
constructor(client: MatrixClient);
|
|
10
|
+
/**
|
|
11
|
+
* Handles a room join
|
|
12
|
+
* @internal
|
|
13
|
+
* @param roomId The room ID.
|
|
14
|
+
*/
|
|
15
|
+
onRoomJoin(roomId: string): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Handles a room event.
|
|
18
|
+
* @internal
|
|
19
|
+
* @param roomId The room ID.
|
|
20
|
+
* @param event The event.
|
|
21
|
+
*/
|
|
22
|
+
onRoomEvent(roomId: string, event: any): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Prepares the room tracker to track the given rooms.
|
|
25
|
+
* @param {string[]} roomIds The room IDs to track. This should be the joined rooms set.
|
|
26
|
+
*/
|
|
27
|
+
prepare(roomIds: string[]): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Queues a room check for the tracker. If the room needs an update to the store, an
|
|
30
|
+
* update will be made.
|
|
31
|
+
* @param {string} roomId The room ID to check.
|
|
32
|
+
*/
|
|
33
|
+
queueRoomCheck(roomId: string): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Gets the room's crypto configuration, as known by the underlying store. If the room is
|
|
36
|
+
* not encrypted then this will return an empty object.
|
|
37
|
+
* @param {string} roomId The room ID to get the config for.
|
|
38
|
+
* @returns {Promise<ICryptoRoomInformation>} Resolves to the encryption config.
|
|
39
|
+
*/
|
|
40
|
+
getRoomCryptoConfig(roomId: string): Promise<ICryptoRoomInformation>;
|
|
41
|
+
}
|