@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
package/lib/http.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Performs a web request to a server.
|
|
3
|
+
* @category Unit testing
|
|
4
|
+
* @param {string} baseUrl The base URL to apply to the call.
|
|
5
|
+
* @param {"GET"|"POST"|"PUT"|"DELETE"} method The HTTP method to use in the request
|
|
6
|
+
* @param {string} endpoint The endpoint to call. For example: "/_matrix/client/v3/account/whoami"
|
|
7
|
+
* @param {any} qs The query string to send. Optional.
|
|
8
|
+
* @param {any} body The request body to send. Optional. Will be converted to JSON unless the type is a Buffer.
|
|
9
|
+
* @param {any} headers Additional headers to send in the request.
|
|
10
|
+
* @param {number} timeout The number of milliseconds to wait before timing out.
|
|
11
|
+
* @param {boolean} raw If true, the raw response will be returned instead of the response body.
|
|
12
|
+
* @param {string} contentType The content type to send. Only used if the `body` is a Buffer.
|
|
13
|
+
* @param {string} noEncoding Set to true to disable encoding, and return a Buffer. Defaults to false
|
|
14
|
+
* @returns {Promise<any>} Resolves to the response (body), rejected if a non-2xx status code was returned.
|
|
15
|
+
*/
|
|
16
|
+
export declare function doHttpRequest(baseUrl: string, method: "GET" | "POST" | "PUT" | "DELETE", endpoint: string, qs?: any, body?: any, headers?: {}, timeout?: number, raw?: boolean, contentType?: string, noEncoding?: boolean): Promise<any>;
|
|
17
|
+
export declare function redactObjectForLogging(input: any): any;
|
package/lib/http.js
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.doHttpRequest = doHttpRequest;
|
|
4
|
+
exports.redactObjectForLogging = redactObjectForLogging;
|
|
5
|
+
const LogService_1 = require("./logging/LogService");
|
|
6
|
+
const request_1 = require("./request");
|
|
7
|
+
const MatrixError_1 = require("./models/MatrixError");
|
|
8
|
+
let lastRequestId = 0;
|
|
9
|
+
/**
|
|
10
|
+
* Performs a web request to a server.
|
|
11
|
+
* @category Unit testing
|
|
12
|
+
* @param {string} baseUrl The base URL to apply to the call.
|
|
13
|
+
* @param {"GET"|"POST"|"PUT"|"DELETE"} method The HTTP method to use in the request
|
|
14
|
+
* @param {string} endpoint The endpoint to call. For example: "/_matrix/client/v3/account/whoami"
|
|
15
|
+
* @param {any} qs The query string to send. Optional.
|
|
16
|
+
* @param {any} body The request body to send. Optional. Will be converted to JSON unless the type is a Buffer.
|
|
17
|
+
* @param {any} headers Additional headers to send in the request.
|
|
18
|
+
* @param {number} timeout The number of milliseconds to wait before timing out.
|
|
19
|
+
* @param {boolean} raw If true, the raw response will be returned instead of the response body.
|
|
20
|
+
* @param {string} contentType The content type to send. Only used if the `body` is a Buffer.
|
|
21
|
+
* @param {string} noEncoding Set to true to disable encoding, and return a Buffer. Defaults to false
|
|
22
|
+
* @returns {Promise<any>} Resolves to the response (body), rejected if a non-2xx status code was returned.
|
|
23
|
+
*/
|
|
24
|
+
async function doHttpRequest(baseUrl, method, endpoint, qs = null, body = null, headers = {}, timeout = 60000, raw = false, contentType = "application/json", noEncoding = false) {
|
|
25
|
+
if (!endpoint.startsWith('/')) {
|
|
26
|
+
endpoint = '/' + endpoint;
|
|
27
|
+
}
|
|
28
|
+
const requestId = ++lastRequestId;
|
|
29
|
+
const url = baseUrl + endpoint;
|
|
30
|
+
// This is logged at info so that when a request fails people can figure out which one.
|
|
31
|
+
LogService_1.LogService.debug("MatrixHttpClient", "(REQ-" + requestId + ")", method + " " + url);
|
|
32
|
+
// Don't log the request unless we're in debug mode. It can be large.
|
|
33
|
+
if (LogService_1.LogService.level.includes(LogService_1.LogLevel.TRACE)) {
|
|
34
|
+
if (qs)
|
|
35
|
+
LogService_1.LogService.trace("MatrixHttpClient", "(REQ-" + requestId + ")", "qs = " + JSON.stringify(qs));
|
|
36
|
+
if (body && !Buffer.isBuffer(body))
|
|
37
|
+
LogService_1.LogService.trace("MatrixHttpClient", "(REQ-" + requestId + ")", "body = " + JSON.stringify(redactObjectForLogging(body)));
|
|
38
|
+
if (body && Buffer.isBuffer(body))
|
|
39
|
+
LogService_1.LogService.trace("MatrixHttpClient", "(REQ-" + requestId + ")", "body = <Buffer>");
|
|
40
|
+
}
|
|
41
|
+
const params = {
|
|
42
|
+
uri: url,
|
|
43
|
+
method: method,
|
|
44
|
+
qs: qs,
|
|
45
|
+
// If this is undefined, then a string will be returned. If it's null, a Buffer will be returned.
|
|
46
|
+
encoding: noEncoding === false ? undefined : null,
|
|
47
|
+
useQuerystring: true,
|
|
48
|
+
qsStringifyOptions: {
|
|
49
|
+
options: { arrayFormat: 'repeat' },
|
|
50
|
+
},
|
|
51
|
+
timeout: timeout,
|
|
52
|
+
headers: headers,
|
|
53
|
+
// Enable KeepAlive for HTTP
|
|
54
|
+
forever: true,
|
|
55
|
+
};
|
|
56
|
+
if (body) {
|
|
57
|
+
if (Buffer.isBuffer(body)) {
|
|
58
|
+
params.headers["Content-Type"] = contentType;
|
|
59
|
+
params.body = body;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
params.headers["Content-Type"] = "application/json";
|
|
63
|
+
params.body = JSON.stringify(body);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const { response, resBody } = await new Promise((resolve, reject) => {
|
|
67
|
+
(0, request_1.getRequestFn)()(params, (err, res, rBody) => {
|
|
68
|
+
if (err) {
|
|
69
|
+
LogService_1.LogService.error("MatrixHttpClient", "(REQ-" + requestId + ")", err);
|
|
70
|
+
reject(err);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (typeof (rBody) === 'string') {
|
|
74
|
+
try {
|
|
75
|
+
rBody = JSON.parse(rBody);
|
|
76
|
+
}
|
|
77
|
+
catch (e) {
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (typeof (res.body) === 'string') {
|
|
81
|
+
try {
|
|
82
|
+
res.body = JSON.parse(res.body);
|
|
83
|
+
}
|
|
84
|
+
catch (e) {
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
resolve({ response: res, resBody: rBody });
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
const respIsBuffer = (response.body instanceof Buffer);
|
|
91
|
+
// Check for errors.
|
|
92
|
+
const errBody = response.body || resBody;
|
|
93
|
+
if (typeof (errBody) === "object" && 'errcode' in errBody) {
|
|
94
|
+
const redactedBody = respIsBuffer ? '<Buffer>' : redactObjectForLogging(errBody);
|
|
95
|
+
LogService_1.LogService.error("MatrixHttpClient", "(REQ-" + requestId + ")", redactedBody);
|
|
96
|
+
throw new MatrixError_1.MatrixError(errBody, response.statusCode);
|
|
97
|
+
}
|
|
98
|
+
// Don't log the body unless we're in debug mode. They can be large.
|
|
99
|
+
if (LogService_1.LogService.level.includes(LogService_1.LogLevel.TRACE)) {
|
|
100
|
+
const redactedBody = respIsBuffer ? '<Buffer>' : redactObjectForLogging(response.body);
|
|
101
|
+
LogService_1.LogService.trace("MatrixHttpClient", "(REQ-" + requestId + " RESP-H" + response.statusCode + ")", redactedBody);
|
|
102
|
+
}
|
|
103
|
+
if (response.statusCode < 200 || response.statusCode >= 300) {
|
|
104
|
+
const redactedBody = respIsBuffer ? '<Buffer>' : redactObjectForLogging(response.body);
|
|
105
|
+
LogService_1.LogService.error("MatrixHttpClient", "(REQ-" + requestId + ")", redactedBody);
|
|
106
|
+
throw response;
|
|
107
|
+
}
|
|
108
|
+
return raw ? response : resBody;
|
|
109
|
+
}
|
|
110
|
+
function redactObjectForLogging(input) {
|
|
111
|
+
if (!input)
|
|
112
|
+
return input;
|
|
113
|
+
const fieldsToRedact = [
|
|
114
|
+
'access_token',
|
|
115
|
+
'password',
|
|
116
|
+
'new_password',
|
|
117
|
+
];
|
|
118
|
+
const redactFn = (i) => {
|
|
119
|
+
if (!i)
|
|
120
|
+
return i;
|
|
121
|
+
// Don't treat strings like arrays/objects
|
|
122
|
+
if (typeof i === 'string')
|
|
123
|
+
return i;
|
|
124
|
+
if (Array.isArray(i)) {
|
|
125
|
+
const rebuilt = [];
|
|
126
|
+
for (const v of i) {
|
|
127
|
+
rebuilt.push(redactFn(v));
|
|
128
|
+
}
|
|
129
|
+
return rebuilt;
|
|
130
|
+
}
|
|
131
|
+
if (i instanceof Object) {
|
|
132
|
+
const rebuilt = {};
|
|
133
|
+
for (const key of Object.keys(i)) {
|
|
134
|
+
if (fieldsToRedact.includes(key)) {
|
|
135
|
+
rebuilt[key] = '<redacted>';
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
rebuilt[key] = redactFn(i[key]);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return rebuilt;
|
|
142
|
+
}
|
|
143
|
+
return i; // It's a primitive value
|
|
144
|
+
};
|
|
145
|
+
return redactFn(input);
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=http.js.map
|
package/lib/http.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":";;AAqBA,sCAuGC;AAED,wDAuCC;AArKD,qDAA4D;AAC5D,uCAAyC;AACzC,sDAAmD;AAEnD,IAAI,aAAa,GAAG,CAAC,CAAC;AAEtB;;;;;;;;;;;;;;GAcG;AACI,KAAK,UAAU,aAAa,CAC/B,OAAe,EACf,MAAyC,EACzC,QAAgB,EAChB,EAAE,GAAG,IAAI,EACT,IAAI,GAAG,IAAI,EACX,OAAO,GAAG,EAAE,EACZ,OAAO,GA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CAAC;gBAC/B,IAAI,cAAc,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;oBAC/B,OAAO,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC;gBAChC,CAAC;qBAAM,CAAC;oBACJ,OAAO,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;gBACpC,CAAC;YACL,CAAC;YACD,OAAO,OAAO,CAAC;QACnB,CAAC;QAED,OAAO,CAAC,CAAC,CAAC,yBAAyB;IACvC,CAAC,CAAC;IAEF,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { OpenIDConnectToken } from "../models/OpenIDConnect";
|
|
2
|
+
import { Policies } from "../models/Policies";
|
|
3
|
+
import { Metrics } from "../metrics/Metrics";
|
|
4
|
+
import { Threepid } from "../models/Threepid";
|
|
5
|
+
import { MatrixClient } from "../MatrixClient";
|
|
6
|
+
import { IdentityServerAccount, IdentityServerInvite } from "../models/IdentityServerModels";
|
|
7
|
+
/**
|
|
8
|
+
* A way to access an Identity Server using the Identity Service API from a MatrixClient.
|
|
9
|
+
* @category Identity Servers
|
|
10
|
+
*/
|
|
11
|
+
export declare class IdentityClient {
|
|
12
|
+
readonly accessToken: string;
|
|
13
|
+
readonly serverUrl: string;
|
|
14
|
+
readonly matrixClient: MatrixClient;
|
|
15
|
+
/**
|
|
16
|
+
* The metrics instance for this client. Note that metrics for the underlying MatrixClient will
|
|
17
|
+
* not be available here.
|
|
18
|
+
*/
|
|
19
|
+
readonly metrics: Metrics;
|
|
20
|
+
/**
|
|
21
|
+
* If truthy, this is a string that will be supplied as `?brand=$brand` where endpoints can
|
|
22
|
+
* result in communications to a user.
|
|
23
|
+
*/
|
|
24
|
+
brand: string;
|
|
25
|
+
private constructor();
|
|
26
|
+
/**
|
|
27
|
+
* Gets account information for the logged in user.
|
|
28
|
+
* @returns {Promise<IdentityServerAccount>} Resolves to the account information
|
|
29
|
+
*/
|
|
30
|
+
getAccount(): Promise<IdentityServerAccount>;
|
|
31
|
+
/**
|
|
32
|
+
* Gets the terms of service for which the identity server has.
|
|
33
|
+
* @returns {Promise<Policies>} Resolves to the policies of the server.
|
|
34
|
+
*/
|
|
35
|
+
getTermsOfService(): Promise<Policies>;
|
|
36
|
+
/**
|
|
37
|
+
* Accepts a given set of URLs from Policy objects returned by the server. This implies acceptance of
|
|
38
|
+
* the terms. Note that this will not update the user's account data to consider these terms accepted
|
|
39
|
+
* in the future - that is an exercise left to the caller.
|
|
40
|
+
* @param {string[]} termsUrls The URLs to count as accepted.
|
|
41
|
+
* @returns {Promise<void>} Resolves when complete.
|
|
42
|
+
*/
|
|
43
|
+
acceptTerms(termsUrls: string[]): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Accepts all the terms of service offered by the identity server. Note that this is only meant to be
|
|
46
|
+
* used by automated bots where terms acceptance is implicit - the terms of service need to be presented
|
|
47
|
+
* to the user in most cases.
|
|
48
|
+
* @returns {Promise<void>} Resolves when complete.
|
|
49
|
+
*/
|
|
50
|
+
acceptAllTerms(): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Looks up a series of third party identifiers (email addresses or phone numbers) to see if they have
|
|
53
|
+
* associated mappings. The returned array will be ordered the same as the input, and have falsey values
|
|
54
|
+
* in place of any failed/missing lookups (eg: no mapping).
|
|
55
|
+
* @param {Threepid[]} identifiers The identifiers to look up.
|
|
56
|
+
* @param {boolean} allowPlaintext If true, the function will accept the server's offer to use plaintext
|
|
57
|
+
* lookups when no other methods are available. The function will always prefer hashed methods.
|
|
58
|
+
* @returns {Promise<string[]>} Resolves to the user IDs (or falsey values) in the same order as the input.
|
|
59
|
+
*/
|
|
60
|
+
lookup(identifiers: Threepid[], allowPlaintext?: boolean): Promise<string[]>;
|
|
61
|
+
/**
|
|
62
|
+
* Creates a third party email invite. This will store the invite in the identity server, but
|
|
63
|
+
* not publish the invite to the room - the caller is expected to handle the remaining part. Note
|
|
64
|
+
* that this function is not required to be called when using the Client-Server API for inviting
|
|
65
|
+
* third party addresses to a room. This will make several calls into the room state to populate
|
|
66
|
+
* the invite details, therefore the inviter (the client backing this identity client) must be
|
|
67
|
+
* present in the room.
|
|
68
|
+
* @param {string} emailAddress The email address to invite.
|
|
69
|
+
* @param {string} roomId The room ID to invite to.
|
|
70
|
+
* @returns {Promise<IdentityServerInvite>} Resolves to the identity server's stored invite.
|
|
71
|
+
*/
|
|
72
|
+
makeEmailInvite(emailAddress: string, roomId: string): Promise<IdentityServerInvite>;
|
|
73
|
+
/**
|
|
74
|
+
* Performs a web request to the server, applying appropriate authorization headers for
|
|
75
|
+
* this client.
|
|
76
|
+
* @param {"GET"|"POST"|"PUT"|"DELETE"} method The HTTP method to use in the request
|
|
77
|
+
* @param {string} endpoint The endpoint to call. For example: "/_matrix/identity/v2/account"
|
|
78
|
+
* @param {any} qs The query string to send. Optional.
|
|
79
|
+
* @param {any} body The request body to send. Optional. Will be converted to JSON unless the type is a Buffer.
|
|
80
|
+
* @param {number} timeout The number of milliseconds to wait before timing out.
|
|
81
|
+
* @param {boolean} raw If true, the raw response will be returned instead of the response body.
|
|
82
|
+
* @param {string} contentType The content type to send. Only used if the `body` is a Buffer.
|
|
83
|
+
* @param {string} noEncoding Set to true to disable encoding, and return a Buffer. Defaults to false
|
|
84
|
+
* @returns {Promise<any>} Resolves to the response (body), rejected if a non-2xx status code was returned.
|
|
85
|
+
*/
|
|
86
|
+
doRequest(method: any, endpoint: any, qs?: any, body?: any, timeout?: number, raw?: boolean, contentType?: string, noEncoding?: boolean): Promise<any>;
|
|
87
|
+
/**
|
|
88
|
+
* Gets an instance of an identity client.
|
|
89
|
+
* @param {OpenIDConnectToken} oidc The OpenID Connect token to register to the identity server with.
|
|
90
|
+
* @param {string} serverUrl The full URL where the identity server can be reached at.
|
|
91
|
+
*/
|
|
92
|
+
static acquire(oidc: OpenIDConnectToken, serverUrl: string, mxClient: MatrixClient): Promise<IdentityClient>;
|
|
93
|
+
}
|
|
@@ -0,0 +1,248 @@
|
|
|
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.IdentityClient = void 0;
|
|
13
|
+
const crypto = require("crypto");
|
|
14
|
+
const http_1 = require("../http");
|
|
15
|
+
const decorators_1 = require("../metrics/decorators");
|
|
16
|
+
const Metrics_1 = require("../metrics/Metrics");
|
|
17
|
+
const UnpaddedBase64_1 = require("../helpers/UnpaddedBase64");
|
|
18
|
+
const MatrixProfile_1 = require("../models/MatrixProfile");
|
|
19
|
+
/**
|
|
20
|
+
* A way to access an Identity Server using the Identity Service API from a MatrixClient.
|
|
21
|
+
* @category Identity Servers
|
|
22
|
+
*/
|
|
23
|
+
class IdentityClient {
|
|
24
|
+
constructor(accessToken, serverUrl, matrixClient) {
|
|
25
|
+
this.accessToken = accessToken;
|
|
26
|
+
this.serverUrl = serverUrl;
|
|
27
|
+
this.matrixClient = matrixClient;
|
|
28
|
+
this.metrics = new Metrics_1.Metrics();
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Gets account information for the logged in user.
|
|
32
|
+
* @returns {Promise<IdentityServerAccount>} Resolves to the account information
|
|
33
|
+
*/
|
|
34
|
+
getAccount() {
|
|
35
|
+
return this.doRequest("GET", "/_matrix/identity/v2/account");
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Gets the terms of service for which the identity server has.
|
|
39
|
+
* @returns {Promise<Policies>} Resolves to the policies of the server.
|
|
40
|
+
*/
|
|
41
|
+
getTermsOfService() {
|
|
42
|
+
return this.doRequest("GET", "/_matrix/identity/v2/terms");
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Accepts a given set of URLs from Policy objects returned by the server. This implies acceptance of
|
|
46
|
+
* the terms. Note that this will not update the user's account data to consider these terms accepted
|
|
47
|
+
* in the future - that is an exercise left to the caller.
|
|
48
|
+
* @param {string[]} termsUrls The URLs to count as accepted.
|
|
49
|
+
* @returns {Promise<void>} Resolves when complete.
|
|
50
|
+
*/
|
|
51
|
+
acceptTerms(termsUrls) {
|
|
52
|
+
return this.doRequest("POST", "/_matrix/identity/v2/terms", null, {
|
|
53
|
+
user_accepts: termsUrls,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Accepts all the terms of service offered by the identity server. Note that this is only meant to be
|
|
58
|
+
* used by automated bots where terms acceptance is implicit - the terms of service need to be presented
|
|
59
|
+
* to the user in most cases.
|
|
60
|
+
* @returns {Promise<void>} Resolves when complete.
|
|
61
|
+
*/
|
|
62
|
+
async acceptAllTerms() {
|
|
63
|
+
const terms = await this.getTermsOfService();
|
|
64
|
+
const urls = new Set();
|
|
65
|
+
for (const policy of Object.values(terms.policies)) {
|
|
66
|
+
let chosenLang = policy["en"];
|
|
67
|
+
if (!chosenLang) {
|
|
68
|
+
chosenLang = policy[Object.keys(policy).find(k => k !== "version")];
|
|
69
|
+
}
|
|
70
|
+
if (!chosenLang)
|
|
71
|
+
continue; // skip - invalid
|
|
72
|
+
urls.add(chosenLang.url);
|
|
73
|
+
}
|
|
74
|
+
return await this.acceptTerms(Array.from(urls));
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Looks up a series of third party identifiers (email addresses or phone numbers) to see if they have
|
|
78
|
+
* associated mappings. The returned array will be ordered the same as the input, and have falsey values
|
|
79
|
+
* in place of any failed/missing lookups (eg: no mapping).
|
|
80
|
+
* @param {Threepid[]} identifiers The identifiers to look up.
|
|
81
|
+
* @param {boolean} allowPlaintext If true, the function will accept the server's offer to use plaintext
|
|
82
|
+
* lookups when no other methods are available. The function will always prefer hashed methods.
|
|
83
|
+
* @returns {Promise<string[]>} Resolves to the user IDs (or falsey values) in the same order as the input.
|
|
84
|
+
*/
|
|
85
|
+
async lookup(identifiers, allowPlaintext = false) {
|
|
86
|
+
const hashInfo = await this.doRequest("GET", "/_matrix/identity/v2/hash_details");
|
|
87
|
+
if (!hashInfo?.["algorithms"])
|
|
88
|
+
throw new Error("Server not supported: invalid response");
|
|
89
|
+
const algorithms = hashInfo?.["algorithms"];
|
|
90
|
+
let algorithm = algorithms.find(a => a === "sha256");
|
|
91
|
+
if (!algorithm && allowPlaintext)
|
|
92
|
+
algorithm = algorithms.find(a => a === "none");
|
|
93
|
+
if (!algorithm)
|
|
94
|
+
throw new Error("No supported hashing algorithm found");
|
|
95
|
+
const body = {
|
|
96
|
+
algorithm,
|
|
97
|
+
pepper: hashInfo["lookup_pepper"],
|
|
98
|
+
addresses: [],
|
|
99
|
+
};
|
|
100
|
+
for (const pid of identifiers) {
|
|
101
|
+
let transformed = null;
|
|
102
|
+
switch (algorithm) {
|
|
103
|
+
case "none":
|
|
104
|
+
transformed = `${pid.address.toLowerCase()} ${pid.kind}`;
|
|
105
|
+
break;
|
|
106
|
+
case "sha256":
|
|
107
|
+
transformed = UnpaddedBase64_1.UnpaddedBase64.encodeBufferUrlSafe(crypto.createHash("sha256")
|
|
108
|
+
.update(`${pid.address.toLowerCase()} ${pid.kind} ${body.pepper}`).digest());
|
|
109
|
+
break;
|
|
110
|
+
default:
|
|
111
|
+
throw new Error("Unsupported hashing algorithm (programming error)");
|
|
112
|
+
}
|
|
113
|
+
body.addresses.push(transformed);
|
|
114
|
+
}
|
|
115
|
+
const resp = await this.doRequest("POST", "/_matrix/identity/v2/lookup", null, body);
|
|
116
|
+
const mappings = resp?.["mappings"] || {};
|
|
117
|
+
const mxids = [];
|
|
118
|
+
for (const addr of body.addresses) {
|
|
119
|
+
mxids.push(mappings[addr]);
|
|
120
|
+
}
|
|
121
|
+
return mxids;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Creates a third party email invite. This will store the invite in the identity server, but
|
|
125
|
+
* not publish the invite to the room - the caller is expected to handle the remaining part. Note
|
|
126
|
+
* that this function is not required to be called when using the Client-Server API for inviting
|
|
127
|
+
* third party addresses to a room. This will make several calls into the room state to populate
|
|
128
|
+
* the invite details, therefore the inviter (the client backing this identity client) must be
|
|
129
|
+
* present in the room.
|
|
130
|
+
* @param {string} emailAddress The email address to invite.
|
|
131
|
+
* @param {string} roomId The room ID to invite to.
|
|
132
|
+
* @returns {Promise<IdentityServerInvite>} Resolves to the identity server's stored invite.
|
|
133
|
+
*/
|
|
134
|
+
async makeEmailInvite(emailAddress, roomId) {
|
|
135
|
+
const req = {
|
|
136
|
+
address: emailAddress,
|
|
137
|
+
medium: "email",
|
|
138
|
+
room_id: roomId,
|
|
139
|
+
sender: await this.matrixClient.getUserId(),
|
|
140
|
+
};
|
|
141
|
+
const tryFetch = async (eventType, stateKey) => {
|
|
142
|
+
try {
|
|
143
|
+
return await this.matrixClient.getRoomStateEvent(roomId, eventType, stateKey);
|
|
144
|
+
}
|
|
145
|
+
catch (e) {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
const canonicalAlias = (await tryFetch("m.room.canonical_alias", ""))?.["alias"];
|
|
150
|
+
const roomName = (await tryFetch("m.room.name", ""))?.["name"];
|
|
151
|
+
req["room_alias"] = canonicalAlias;
|
|
152
|
+
req["room_avatar_url"] = (await tryFetch("m.room.avatar", ""))?.["url"];
|
|
153
|
+
req["room_name"] = roomName || canonicalAlias;
|
|
154
|
+
req["room_join_rules"] = (await tryFetch("m.room.join_rules", ""))?.["join_rule"];
|
|
155
|
+
let profileInfo;
|
|
156
|
+
try {
|
|
157
|
+
profileInfo = await this.matrixClient.getUserProfile(await this.matrixClient.getUserId());
|
|
158
|
+
}
|
|
159
|
+
catch (e) {
|
|
160
|
+
// ignore
|
|
161
|
+
}
|
|
162
|
+
const senderProfile = new MatrixProfile_1.MatrixProfile(await this.matrixClient.getUserId(), profileInfo);
|
|
163
|
+
req["sender_avatar_url"] = senderProfile.avatarUrl;
|
|
164
|
+
req["sender_display_name"] = senderProfile.displayName;
|
|
165
|
+
const inviteReq = {};
|
|
166
|
+
for (const entry of Object.entries(req)) {
|
|
167
|
+
if (entry[1])
|
|
168
|
+
inviteReq[entry[0]] = entry[1];
|
|
169
|
+
}
|
|
170
|
+
const qs = {};
|
|
171
|
+
if (this.brand)
|
|
172
|
+
qs['brand'] = this.brand;
|
|
173
|
+
return await this.doRequest("POST", "/_matrix/identity/v2/store-invite", qs, inviteReq);
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Performs a web request to the server, applying appropriate authorization headers for
|
|
177
|
+
* this client.
|
|
178
|
+
* @param {"GET"|"POST"|"PUT"|"DELETE"} method The HTTP method to use in the request
|
|
179
|
+
* @param {string} endpoint The endpoint to call. For example: "/_matrix/identity/v2/account"
|
|
180
|
+
* @param {any} qs The query string to send. Optional.
|
|
181
|
+
* @param {any} body The request body to send. Optional. Will be converted to JSON unless the type is a Buffer.
|
|
182
|
+
* @param {number} timeout The number of milliseconds to wait before timing out.
|
|
183
|
+
* @param {boolean} raw If true, the raw response will be returned instead of the response body.
|
|
184
|
+
* @param {string} contentType The content type to send. Only used if the `body` is a Buffer.
|
|
185
|
+
* @param {string} noEncoding Set to true to disable encoding, and return a Buffer. Defaults to false
|
|
186
|
+
* @returns {Promise<any>} Resolves to the response (body), rejected if a non-2xx status code was returned.
|
|
187
|
+
*/
|
|
188
|
+
doRequest(method, endpoint, qs = null, body = null, timeout = 60000, raw = false, contentType = "application/json", noEncoding = false) {
|
|
189
|
+
const headers = {};
|
|
190
|
+
if (this.accessToken) {
|
|
191
|
+
headers["Authorization"] = `Bearer ${this.accessToken}`;
|
|
192
|
+
}
|
|
193
|
+
return (0, http_1.doHttpRequest)(this.serverUrl, method, endpoint, qs, body, headers, timeout, raw, contentType, noEncoding);
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Gets an instance of an identity client.
|
|
197
|
+
* @param {OpenIDConnectToken} oidc The OpenID Connect token to register to the identity server with.
|
|
198
|
+
* @param {string} serverUrl The full URL where the identity server can be reached at.
|
|
199
|
+
*/
|
|
200
|
+
static async acquire(oidc, serverUrl, mxClient) {
|
|
201
|
+
const account = await (0, http_1.doHttpRequest)(serverUrl, "POST", "/_matrix/identity/v2/account/register", null, oidc);
|
|
202
|
+
return new IdentityClient(account['token'], serverUrl, mxClient);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
exports.IdentityClient = IdentityClient;
|
|
206
|
+
__decorate([
|
|
207
|
+
(0, decorators_1.timedIdentityClientFunctionCall)(),
|
|
208
|
+
__metadata("design:type", Function),
|
|
209
|
+
__metadata("design:paramtypes", []),
|
|
210
|
+
__metadata("design:returntype", Promise)
|
|
211
|
+
], IdentityClient.prototype, "getAccount", null);
|
|
212
|
+
__decorate([
|
|
213
|
+
(0, decorators_1.timedIdentityClientFunctionCall)(),
|
|
214
|
+
__metadata("design:type", Function),
|
|
215
|
+
__metadata("design:paramtypes", []),
|
|
216
|
+
__metadata("design:returntype", Promise)
|
|
217
|
+
], IdentityClient.prototype, "getTermsOfService", null);
|
|
218
|
+
__decorate([
|
|
219
|
+
(0, decorators_1.timedIdentityClientFunctionCall)(),
|
|
220
|
+
__metadata("design:type", Function),
|
|
221
|
+
__metadata("design:paramtypes", [Array]),
|
|
222
|
+
__metadata("design:returntype", Promise)
|
|
223
|
+
], IdentityClient.prototype, "acceptTerms", null);
|
|
224
|
+
__decorate([
|
|
225
|
+
(0, decorators_1.timedIdentityClientFunctionCall)(),
|
|
226
|
+
__metadata("design:type", Function),
|
|
227
|
+
__metadata("design:paramtypes", []),
|
|
228
|
+
__metadata("design:returntype", Promise)
|
|
229
|
+
], IdentityClient.prototype, "acceptAllTerms", null);
|
|
230
|
+
__decorate([
|
|
231
|
+
(0, decorators_1.timedIdentityClientFunctionCall)(),
|
|
232
|
+
__metadata("design:type", Function),
|
|
233
|
+
__metadata("design:paramtypes", [Array, Object]),
|
|
234
|
+
__metadata("design:returntype", Promise)
|
|
235
|
+
], IdentityClient.prototype, "lookup", null);
|
|
236
|
+
__decorate([
|
|
237
|
+
(0, decorators_1.timedIdentityClientFunctionCall)(),
|
|
238
|
+
__metadata("design:type", Function),
|
|
239
|
+
__metadata("design:paramtypes", [String, String]),
|
|
240
|
+
__metadata("design:returntype", Promise)
|
|
241
|
+
], IdentityClient.prototype, "makeEmailInvite", null);
|
|
242
|
+
__decorate([
|
|
243
|
+
(0, decorators_1.timedIdentityClientFunctionCall)(),
|
|
244
|
+
__metadata("design:type", Function),
|
|
245
|
+
__metadata("design:paramtypes", [Object, Object, Object, Object, Object, Object, Object, Object]),
|
|
246
|
+
__metadata("design:returntype", Promise)
|
|
247
|
+
], IdentityClient.prototype, "doRequest", null);
|
|
248
|
+
//# sourceMappingURL=IdentityClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IdentityClient.js","sourceRoot":"","sources":["../../src/identity/IdentityClient.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iCAAiC;AAGjC,kCAAwC;AACxC,sDAAwE;AAExE,gDAA6C;AAE7C,8DAA2D;AAE3D,2DAA2E;AAG3E;;;GAGG;AACH,MAAa,cAAc;IAavB,YAAoC,WAAmB,EAAkB,SAAiB,EAAkB,YAA0B;QAAlG,gBAAW,GAAX,WAAW,CAAQ;QAAkB,cAAS,GAAT,S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IADZ,IAAA,4CAA+B,GAAE;;;;4CAuCjC;AAcY;IADZ,IAAA,4CAA+B,GAAE;;;;qDA2CjC;AAgBM;IADN,IAAA,4CAA+B,GAAE;;;;+CAOjC"}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
export * from "./appservice/Appservice";
|
|
2
|
+
export * from "./appservice/Intent";
|
|
3
|
+
export * from "./appservice/MatrixBridge";
|
|
4
|
+
export * from "./appservice/http_responses";
|
|
5
|
+
export * from "./appservice/UnstableAppserviceApis";
|
|
6
|
+
export * from "./e2ee/RoomTracker";
|
|
7
|
+
export * from "./e2ee/CryptoClient";
|
|
8
|
+
export * from "./e2ee/decorators";
|
|
9
|
+
export { passwordUiaCallback, UIACallback, EnsureCrossSigningOptions, EnsureCrossSigningResult, EnsureSecretStorageResult, } from "./e2ee/CrossSigningBootstrap";
|
|
10
|
+
export * from "./e2ee/ICryptoRoomInformation";
|
|
11
|
+
export * from "./helpers/RichReply";
|
|
12
|
+
export * from "./helpers/MentionPill";
|
|
13
|
+
export * from "./helpers/Permalinks";
|
|
14
|
+
export * from "./helpers/MatrixGlob";
|
|
15
|
+
export * from "./helpers/ProfileCache";
|
|
16
|
+
export * from "./helpers/MatrixEntity";
|
|
17
|
+
export * from "./helpers/UnpaddedBase64";
|
|
18
|
+
export * from "./logging/ConsoleLogger";
|
|
19
|
+
export * from "./logging/RichConsoleLogger";
|
|
20
|
+
export * from "./logging/ILogger";
|
|
21
|
+
export * from "./logging/LogService";
|
|
22
|
+
export * from "./metrics/contexts";
|
|
23
|
+
export * from "./metrics/names";
|
|
24
|
+
export * from "./metrics/decorators";
|
|
25
|
+
export * from "./metrics/IMetricListener";
|
|
26
|
+
export * from "./metrics/Metrics";
|
|
27
|
+
export * from "./mixins/AutojoinRoomsMixin";
|
|
28
|
+
export * from "./mixins/AutojoinUpgradedRoomsMixin";
|
|
29
|
+
export * from "./models/Presence";
|
|
30
|
+
export * from "./models/MatrixProfile";
|
|
31
|
+
export * from "./models/EventContext";
|
|
32
|
+
export * from "./models/PowerLevelBounds";
|
|
33
|
+
export * from "./models/OpenIDConnect";
|
|
34
|
+
export * from "./models/Policies";
|
|
35
|
+
export * from "./models/Threepid";
|
|
36
|
+
export * from "./models/Spaces";
|
|
37
|
+
export * from "./models/IdentityServerModels";
|
|
38
|
+
export * from "./models/Crypto";
|
|
39
|
+
export * from "./models/MSC2176";
|
|
40
|
+
export * from "./models/Account";
|
|
41
|
+
export * from "./models/PowerLevelAction";
|
|
42
|
+
export * from "./models/ServerVersions";
|
|
43
|
+
export * from "./models/MatrixError";
|
|
44
|
+
export * from "./models/CreateRoom";
|
|
45
|
+
export * from "./models/unstable/MediaInfo";
|
|
46
|
+
export * from "./models/events/EventKind";
|
|
47
|
+
export * from "./models/events/converter";
|
|
48
|
+
export * from "./models/events/InvalidEventError";
|
|
49
|
+
export * from "./models/events/Event";
|
|
50
|
+
export * from "./models/events/RoomEvent";
|
|
51
|
+
export * from "./models/events/PresenceEvent";
|
|
52
|
+
export * from "./models/events/MembershipEvent";
|
|
53
|
+
export * from "./models/events/MessageEvent";
|
|
54
|
+
export * from "./models/events/AliasesEvent";
|
|
55
|
+
export * from "./models/events/CanonicalAliasEvent";
|
|
56
|
+
export * from "./models/events/CreateEvent";
|
|
57
|
+
export * from "./models/events/JoinRulesEvent";
|
|
58
|
+
export * from "./models/events/PowerLevelsEvent";
|
|
59
|
+
export * from "./models/events/RedactionEvent";
|
|
60
|
+
export * from "./models/events/PinnedEventsEvent";
|
|
61
|
+
export * from "./models/events/RoomAvatarEvent";
|
|
62
|
+
export * from "./models/events/RoomNameEvent";
|
|
63
|
+
export * from "./models/events/RoomTopicEvent";
|
|
64
|
+
export * from "./models/events/SpaceChildEvent";
|
|
65
|
+
export * from "./models/events/EncryptionEvent";
|
|
66
|
+
export * from "./models/events/EncryptedRoomEvent";
|
|
67
|
+
export * from "./preprocessors/IPreprocessor";
|
|
68
|
+
export * from "./preprocessors/RichRepliesPreprocessor";
|
|
69
|
+
export * from "./storage/IAppserviceStorageProvider";
|
|
70
|
+
export * from "./storage/IStorageProvider";
|
|
71
|
+
export * from "./storage/MemoryStorageProvider";
|
|
72
|
+
export * from "./storage/SimpleFsStorageProvider";
|
|
73
|
+
export * from "./storage/ICryptoStorageProvider";
|
|
74
|
+
export * from "./storage/RustSdkCryptoStorageProvider";
|
|
75
|
+
export * from "./storage/SimplePostgresStorageProvider";
|
|
76
|
+
export * from "./strategies/AppserviceJoinRoomStrategy";
|
|
77
|
+
export * from "./strategies/JoinRoomStrategy";
|
|
78
|
+
export * from "./identity/IdentityClient";
|
|
79
|
+
export * from "./IFilter";
|
|
80
|
+
export * from "./MatrixClient";
|
|
81
|
+
export * from "./MatrixAuth";
|
|
82
|
+
export * from "./UnstableApis";
|
|
83
|
+
export * from "./AdminApis";
|
|
84
|
+
export * from "./request";
|
|
85
|
+
export * from "./PantalaimonClient";
|
|
86
|
+
export * from "./SynchronousMatrixClient";
|
|
87
|
+
export * from "./SynapseAdminApis";
|
|
88
|
+
export * from "./simple-validation";
|
|
89
|
+
export * from "./b64";
|
|
90
|
+
export * from "./http";
|
|
91
|
+
export * from "./DMs";
|