matrix-js-sdk 42.3.0 → 42.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/lib/@types/json.d.ts.map +1 -1
- package/lib/@types/json.js.map +1 -1
- package/lib/client.d.ts +74 -5
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +83 -7
- package/lib/client.js.map +1 -1
- package/lib/common-crypto/CryptoBackend.d.ts +42 -23
- package/lib/common-crypto/CryptoBackend.d.ts.map +1 -1
- package/lib/common-crypto/CryptoBackend.js +7 -0
- package/lib/common-crypto/CryptoBackend.js.map +1 -1
- package/lib/embedded.d.ts +35 -1
- package/lib/embedded.d.ts.map +1 -1
- package/lib/embedded.js +49 -1
- package/lib/embedded.js.map +1 -1
- package/lib/http-api/fetch.d.ts +0 -1
- package/lib/http-api/fetch.d.ts.map +1 -1
- package/lib/http-api/fetch.js +3 -22
- package/lib/http-api/fetch.js.map +1 -1
- package/lib/http-api/logging.d.ts +10 -0
- package/lib/http-api/logging.d.ts.map +1 -0
- package/lib/http-api/logging.js +46 -0
- package/lib/http-api/logging.js.map +1 -0
- package/lib/matrixrtc/EncryptionManager.d.ts +5 -0
- package/lib/matrixrtc/EncryptionManager.d.ts.map +1 -1
- package/lib/matrixrtc/EncryptionManager.js.map +1 -1
- package/lib/matrixrtc/LivekitTransport.d.ts +82 -0
- package/lib/matrixrtc/LivekitTransport.d.ts.map +1 -1
- package/lib/matrixrtc/LivekitTransport.js +25 -0
- package/lib/matrixrtc/LivekitTransport.js.map +1 -1
- package/lib/matrixrtc/MatrixRTCSession.d.ts +41 -2
- package/lib/matrixrtc/MatrixRTCSession.d.ts.map +1 -1
- package/lib/matrixrtc/MatrixRTCSession.js +59 -1
- package/lib/matrixrtc/MatrixRTCSession.js.map +1 -1
- package/lib/matrixrtc/MembershipManager.js +7 -4
- package/lib/matrixrtc/MembershipManager.js.map +1 -1
- package/lib/matrixrtc/RTCEncryptionManager.d.ts +17 -0
- package/lib/matrixrtc/RTCEncryptionManager.d.ts.map +1 -1
- package/lib/matrixrtc/RTCEncryptionManager.js +68 -29
- package/lib/matrixrtc/RTCEncryptionManager.js.map +1 -1
- package/lib/models/room-receipts.d.ts +9 -3
- package/lib/models/room-receipts.d.ts.map +1 -1
- package/lib/models/room-receipts.js +51 -11
- package/lib/models/room-receipts.js.map +1 -1
- package/lib/oauth/authorize.d.ts +7 -2
- package/lib/oauth/authorize.d.ts.map +1 -1
- package/lib/oauth/authorize.js +10 -4
- package/lib/oauth/authorize.js.map +1 -1
- package/lib/oauth/fetch.d.ts +17 -0
- package/lib/oauth/fetch.d.ts.map +1 -0
- package/lib/oauth/fetch.js +47 -0
- package/lib/oauth/fetch.js.map +1 -0
- package/lib/oauth/index.d.ts +15 -2
- package/lib/oauth/index.d.ts.map +1 -1
- package/lib/oauth/index.js +33 -12
- package/lib/oauth/index.js.map +1 -1
- package/lib/rust-crypto/index.d.ts +17 -0
- package/lib/rust-crypto/index.d.ts.map +1 -1
- package/lib/rust-crypto/index.js +4 -2
- package/lib/rust-crypto/index.js.map +1 -1
- package/lib/rust-crypto/rust-crypto.d.ts +6 -26
- package/lib/rust-crypto/rust-crypto.d.ts.map +1 -1
- package/lib/rust-crypto/rust-crypto.js +19 -54
- package/lib/rust-crypto/rust-crypto.js.map +1 -1
- package/lib/sliding-sync-sdk.d.ts.map +1 -1
- package/lib/sliding-sync-sdk.js +65 -27
- package/lib/sliding-sync-sdk.js.map +1 -1
- package/lib/sliding-sync.d.ts +17 -0
- package/lib/sliding-sync.d.ts.map +1 -1
- package/lib/sliding-sync.js +21 -9
- package/lib/sliding-sync.js.map +1 -1
- package/lib/sync.d.ts +9 -1
- package/lib/sync.d.ts.map +1 -1
- package/lib/sync.js +54 -29
- package/lib/sync.js.map +1 -1
- package/package.json +5 -5
- package/src/@types/json.ts +11 -2
- package/src/client.ts +126 -11
- package/src/common-crypto/CryptoBackend.ts +45 -23
- package/src/embedded.ts +67 -4
- package/src/http-api/fetch.ts +2 -23
- package/src/http-api/logging.ts +46 -0
- package/src/matrixrtc/EncryptionManager.ts +6 -0
- package/src/matrixrtc/LivekitTransport.ts +86 -0
- package/src/matrixrtc/MatrixRTCSession.ts +81 -1
- package/src/matrixrtc/MembershipManager.ts +7 -7
- package/src/matrixrtc/RTCEncryptionManager.ts +80 -31
- package/src/models/room-receipts.ts +54 -10
- package/src/oauth/authorize.ts +10 -2
- package/src/oauth/fetch.ts +54 -0
- package/src/oauth/index.ts +29 -10
- package/src/rust-crypto/index.ts +23 -0
- package/src/rust-crypto/rust-crypto.ts +25 -67
- package/src/sliding-sync-sdk.ts +73 -33
- package/src/sliding-sync.ts +31 -14
- package/src/sync.ts +58 -35
|
@@ -86,40 +86,59 @@ export interface CryptoBackend extends SyncCryptoCallbacks, CryptoApi {
|
|
|
86
86
|
*/
|
|
87
87
|
markRoomAsPendingKeyBundle(roomId: string, inviterId: string): Promise<void>;
|
|
88
88
|
}
|
|
89
|
-
/**
|
|
89
|
+
/**
|
|
90
|
+
* The parts of a sync response which are relevant to encryption, as passed to
|
|
91
|
+
* {@link SyncCryptoCallbacks.processSyncChanges}.
|
|
90
92
|
*
|
|
91
93
|
* @internal
|
|
92
94
|
*/
|
|
93
|
-
export interface
|
|
95
|
+
export interface SyncCryptoChanges {
|
|
96
|
+
/** The to-device events from the sync response (`to_device.events`), or an empty list if there were none. */
|
|
97
|
+
toDeviceEvents: IToDeviceEvent[];
|
|
98
|
+
/** The `device_lists` field from the sync response, if any. */
|
|
99
|
+
deviceLists?: IDeviceLists;
|
|
94
100
|
/**
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
* The implementation may preprocess the received messages (eg, decrypt them) and return an
|
|
98
|
-
* updated list of messages for dispatch to the rest of the system.
|
|
99
|
-
*
|
|
100
|
-
* Note that, unlike {@link ClientEvent.ToDeviceEvent} events, this is called on the raw to-device
|
|
101
|
-
* messages, rather than the results of any decryption attempts.
|
|
102
|
-
*
|
|
103
|
-
* @param events - the received to-device messages
|
|
104
|
-
* @returns A list of preprocessed to-device messages. This will not map 1:1 to the input list, as some messages may be invalid or
|
|
105
|
-
* failed to decrypt, and so will be omitted from the output list.
|
|
101
|
+
* The `device_one_time_keys_count` field from the sync response, if any.
|
|
106
102
|
*
|
|
103
|
+
* The meaning of an algorithm missing from the map (or of an absent field) depends on {@link useMsc4186}: in
|
|
104
|
+
* sync v2 it means that there are no one-time keys of that algorithm on the server; in sliding sync it means that
|
|
105
|
+
* the count is unchanged since the previous response.
|
|
107
106
|
*/
|
|
108
|
-
|
|
107
|
+
oneTimeKeysCounts?: Record<string, number>;
|
|
109
108
|
/**
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
* @param oneTimeKeysCounts - the received one time key counts
|
|
113
|
-
* @param unusedFallbackKeys - the received unused fallback keys
|
|
109
|
+
* The `device_unused_fallback_key_types` field from the sync response, or `undefined` if the response did not
|
|
110
|
+
* include it (which means that the server does not support fallback keys).
|
|
114
111
|
*/
|
|
115
|
-
|
|
112
|
+
unusedFallbackKeys?: string[];
|
|
116
113
|
/**
|
|
117
|
-
*
|
|
118
|
-
*
|
|
114
|
+
* Whether to interpret the response with MSC4186 (simplified sliding sync) semantics rather than sync v2. This
|
|
115
|
+
* selects the meaning of missing one-time key counts: see {@link oneTimeKeysCounts}. Defaults to `false`.
|
|
116
|
+
*/
|
|
117
|
+
useMsc4186?: boolean;
|
|
118
|
+
}
|
|
119
|
+
/** The methods which crypto implementations should expose to the Sync api
|
|
120
|
+
*
|
|
121
|
+
* @internal
|
|
122
|
+
*/
|
|
123
|
+
export interface SyncCryptoCallbacks {
|
|
124
|
+
/**
|
|
125
|
+
* Called by the sync loop once per sync response, with the parts of the response which are relevant to
|
|
126
|
+
* encryption: to-device messages, device list changes, one-time key counts and unused fallback key types.
|
|
127
|
+
*
|
|
128
|
+
* All of this data must be passed together, in a single call per sync response, because the OlmMachine
|
|
129
|
+
* interprets it as the complete E2EE state from a sync response. In particular, per the sync v2 specification,
|
|
130
|
+
* an absent `device_one_time_keys_count` means that there are no one-time keys on the server, so calling this
|
|
131
|
+
* without the counts from the response would trigger a spurious one-time key upload. (Sliding sync responses
|
|
132
|
+
* omit the count when it is unchanged; {@link SyncCryptoChanges.useMsc4186} selects that interpretation.)
|
|
133
|
+
*
|
|
134
|
+
* This must be called before the room events in the sync response are processed, so that any room keys received
|
|
135
|
+
* in to-device messages are available when decrypting room events.
|
|
119
136
|
*
|
|
120
|
-
* @param
|
|
137
|
+
* @param changes - the E2EE-relevant parts of the sync response
|
|
138
|
+
* @returns A list of processed to-device messages. This will not map 1:1 to the input list, as some messages may
|
|
139
|
+
* be invalid or fail to decrypt, and so will be omitted from the output list.
|
|
121
140
|
*/
|
|
122
|
-
|
|
141
|
+
processSyncChanges(changes: SyncCryptoChanges): Promise<ReceivedToDeviceMessage[]>;
|
|
123
142
|
/**
|
|
124
143
|
* Called by the /sync loop whenever an m.room.encryption event is received.
|
|
125
144
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CryptoBackend.d.ts","sourceRoot":"","sources":["../../src/common-crypto/CryptoBackend.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACpG,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,qBAAqB,EAAE,KAAK,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC7G,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACvF,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE9D;;;;GAIG;AACH,MAAM,WAAW,aAAc,SAAQ,m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,MAAM,CAAC;CAC3B;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC5B;;;;;;OAMG;IACH,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAEhC;;;;;;;OAOG;IACH,eAAe,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC;IAE9F;;;;OAIG;IACH,IAAI,IAAI,IAAI,CAAC;CAChB;AAED;;;;;;;;;GASG;AACH,qBAAa,eAAgB,SAAQ,KAAK;aAIlB,IAAI,EAAE,qBAAqB;IAH/C,SAAgB,cAAc,EAAE,MAAM,CAAC;IAEvC,YACoB,IAAI,EAAE,qBAAqB,EAC3C,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC,EAK3C;CACJ"}
|
|
@@ -21,6 +21,13 @@ limitations under the License.
|
|
|
21
21
|
* @internal
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
* The parts of a sync response which are relevant to encryption, as passed to
|
|
26
|
+
* {@link SyncCryptoCallbacks.processSyncChanges}.
|
|
27
|
+
*
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
30
|
+
|
|
24
31
|
/** The methods which crypto implementations should expose to the Sync api
|
|
25
32
|
*
|
|
26
33
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CryptoBackend.js","names":[],"sources":["../../src/common-crypto/CryptoBackend.ts"],"sourcesContent":["/*\nCopyright 2022 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport type { IDeviceLists, IToDeviceEvent, ReceivedToDeviceMessage } from \"../sync-accumulator.ts\";\nimport { type IClearEvent, type MatrixEvent } from \"../models/event.ts\";\nimport { type Room } from \"../models/room.ts\";\nimport { type CryptoApi, type DecryptionFailureCode, type ImportRoomKeysOpts } from \"../crypto-api/index.ts\";\nimport { type KeyBackupInfo, type KeyBackupSession } from \"../crypto-api/keybackup.ts\";\nimport { type IMegolmSessionData } from \"../@types/crypto.ts\";\n\n/**\n * Common interface for the crypto implementations\n *\n * @internal\n */\nexport interface CryptoBackend extends SyncCryptoCallbacks, CryptoApi {\n /**\n * Whether sendMessage in a room with unknown and unverified devices\n * should throw an error and not send the message. This has 'Global' for\n * symmetry with setGlobalBlacklistUnverifiedDevices but there is currently\n * no room-level equivalent for this setting.\n *\n * @remarks This has no effect in Rust Crypto; it exists only for the sake of\n * the accessors in MatrixClient.\n */\n globalErrorOnUnknownDevices: boolean;\n\n /**\n * Shut down any background processes related to crypto\n */\n stop(): void;\n\n /**\n * Encrypt an event according to the configuration of the room.\n *\n * @param event - event to be sent\n *\n * @param room - destination room.\n *\n * @returns Promise which resolves when the event has been\n * encrypted, or null if nothing was needed\n */\n encryptEvent(event: MatrixEvent, room: Room): Promise<void>;\n\n /**\n * Decrypt a received event\n *\n * @returns a promise which resolves once we have finished decrypting.\n * Rejects with an error if there is a problem decrypting the event.\n */\n decryptEvent(event: MatrixEvent): Promise<EventDecryptionResult>;\n\n /**\n * Get a backup decryptor capable of decrypting megolm session data encrypted with the given backup information.\n * @param backupInfo - The backup information\n * @param privKey - The private decryption key.\n */\n getBackupDecryptor(backupInfo: KeyBackupInfo, privKey: Uint8Array): Promise<BackupDecryptor>;\n\n /**\n * Import a list of room keys restored from backup\n *\n * @param keys - a list of session export objects\n * @param backupVersion - the version of the backup these keys came from.\n * @param opts - options object\n * @returns a promise which resolves once the keys have been imported\n */\n importBackedUpRoomKeys(keys: IMegolmSessionData[], backupVersion: string, opts?: ImportRoomKeysOpts): Promise<void>;\n\n ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n //\n // Room key history sharing (MSC4268)\n //\n ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n\n /**\n * Share any shareable E2EE history in the given room with the given recipient,\n * as per [MSC4268](https://github.com/matrix-org/matrix-spec-proposals/pull/4268)\n */\n shareRoomHistoryWithUser(roomId: string, userId: string): Promise<void>;\n\n /**\n * Having accepted an invite for the given room from the given user, attempt to\n * find information about a room key bundle and, if found, download the\n * bundle and import the room keys, as per {@link https://github.com/matrix-org/matrix-spec-proposals/pull/4268|MSC4268}.\n *\n * @param roomId - The room we were invited to, for which we want to check if a room\n * key bundle was received.\n *\n * @param inviter - The user who invited us to the room and is expected to have\n * sent the room key bundle.\n *\n * @returns `true` if the key bundle was successfuly downloaded and imported.\n */\n maybeAcceptKeyBundle(roomId: string, inviter: string): Promise<boolean>;\n\n /**\n * Mark a room as pending a key bundle under MSC4268. The backend will listen for room key bundle messages, and if\n * it sees one matching the room specified, it will automatically import it as long as the message author's ID matches\n * the inviter's ID.\n *\n * @param roomId - The room we were invited to, for which we did not receive a key bundle before accepting the invite.\n * @param inviterId - The user who invited us to the room and is expected to send the room key bundle.\n */\n markRoomAsPendingKeyBundle(roomId: string, inviterId: string): Promise<void>;\n}\n\n/** The methods which crypto implementations should expose to the Sync api\n *\n * @internal\n */\nexport interface SyncCryptoCallbacks {\n /**\n * Called by the /sync loop whenever there are incoming to-device messages.\n *\n * The implementation may preprocess the received messages (eg, decrypt them) and return an\n * updated list of messages for dispatch to the rest of the system.\n *\n * Note that, unlike {@link ClientEvent.ToDeviceEvent} events, this is called on the raw to-device\n * messages, rather than the results of any decryption attempts.\n *\n * @param events - the received to-device messages\n * @returns A list of preprocessed to-device messages. This will not map 1:1 to the input list, as some messages may be invalid or\n * failed to decrypt, and so will be omitted from the output list.\n *\n */\n preprocessToDeviceMessages(events: IToDeviceEvent[]): Promise<ReceivedToDeviceMessage[]>;\n\n /**\n * Called by the /sync loop when one time key counts and unused fallback key details are received.\n *\n * @param oneTimeKeysCounts - the received one time key counts\n * @param unusedFallbackKeys - the received unused fallback keys\n */\n processKeyCounts(oneTimeKeysCounts?: Record<string, number>, unusedFallbackKeys?: string[]): Promise<void>;\n\n /**\n * Handle the notification from /sync that device lists have\n * been changed.\n *\n * @param deviceLists - device_lists field from /sync\n */\n processDeviceLists(deviceLists: IDeviceLists): Promise<void>;\n\n /**\n * Called by the /sync loop whenever an m.room.encryption event is received.\n *\n * This is called before RoomStateEvents are emitted for any of the events in the /sync\n * response (even if the other events technically happened first). This works around a problem\n * if the client uses a RoomStateEvent (typically a membership event) as a trigger to send a message\n * in a new room (or one where encryption has been newly enabled): that would otherwise leave the\n * crypto layer confused because it expects crypto to be set up, but it has not yet been.\n *\n * @param room - in which the event was received\n * @param event - encryption event to be processed\n */\n onCryptoEvent(room: Room, event: MatrixEvent): Promise<void>;\n\n /**\n * Called by the /sync loop after each /sync response is processed.\n *\n * Used to complete batch processing, or to initiate background processes\n *\n * @param syncState - information about the completed sync.\n */\n onSyncCompleted(syncState: OnSyncCompletedData): void;\n\n /**\n * Mark all tracked users' device lists as dirty.\n *\n * This method will cause additional `/keys/query` requests on the server, so should be used only\n * when the client has desynced tracking device list deltas from the server.\n * In MSC4186: Simplified Sliding Sync, this can happen when the server expires the connection.\n */\n markAllTrackedUsersAsDirty(): Promise<void>;\n}\n\n/**\n * @internal\n */\nexport interface OnSyncCompletedData {\n /**\n * The 'next_batch' result from /sync, which will become the 'since' token for the next call to /sync.\n */\n nextSyncToken?: string;\n\n /**\n * True if we are working our way through a backlog of events after connecting.\n */\n catchingUp?: boolean;\n}\n\n/**\n * The result of a (successful) call to {@link CryptoBackend.decryptEvent}\n */\nexport interface EventDecryptionResult {\n /**\n * The plaintext payload for the event (typically containing <tt>type</tt> and <tt>content</tt> fields).\n */\n clearEvent: IClearEvent;\n /**\n * No longer used.\n * See {@link MatrixEvent#getForwardingCurve25519KeyChain}.\n * @deprecated\n */\n forwardingCurve25519KeyChain?: string[];\n /**\n * Key owned by the sender of this event. See {@link MatrixEvent#getSenderKey}.\n */\n senderCurve25519Key?: string;\n /**\n * ed25519 key claimed by the sender of this event. See {@link MatrixEvent#getClaimedEd25519Key}.\n */\n claimedEd25519Key?: string;\n\n /**\n * If another user forwarded the key to this message\n * (eg via [MSC4268](https://github.com/matrix-org/matrix-spec-proposals/pull/4268)),\n * the ID of that user.\n */\n keyForwardedBy?: string;\n}\n\n/**\n * Responsible for decrypting megolm session data retrieved from a remote backup.\n * The result of {@link CryptoBackend#getBackupDecryptor}.\n */\nexport interface BackupDecryptor {\n /**\n * Whether keys retrieved from this backup can be trusted.\n *\n * Depending on the backup algorithm, keys retrieved from the backup can be trusted or not.\n * If false, keys retrieved from the backup must be considered unsafe (authenticity cannot be guaranteed).\n * It could be by design (deniability) or for some technical reason (eg asymmetric encryption).\n */\n readonly sourceTrusted: boolean;\n\n /**\n *\n * Decrypt megolm session data retrieved from backup.\n *\n * @param ciphertexts - a Record of sessionId to session data.\n *\n * @returns An array of decrypted `IMegolmSessionData`\n */\n decryptSessions(ciphertexts: Record<string, KeyBackupSession>): Promise<IMegolmSessionData[]>;\n\n /**\n * Free any resources held by this decryptor.\n *\n * Should be called once the decryptor is no longer needed.\n */\n free(): void;\n}\n\n/**\n * Exception thrown when decryption fails\n *\n * @param code - Reason code for the failure.\n *\n * @param msg - user-visible message describing the problem\n *\n * @param details - key/value pairs reported in the logs but not shown\n * to the user.\n */\nexport class DecryptionError extends Error {\n public readonly detailedString: string;\n\n public constructor(\n public readonly code: DecryptionFailureCode,\n msg: string,\n details?: Record<string, string | Error>,\n ) {\n super(msg);\n this.name = \"DecryptionError\";\n this.detailedString = detailedStringForDecryptionError(this, details);\n }\n}\n\nfunction detailedStringForDecryptionError(err: DecryptionError, details?: Record<string, string | Error>): string {\n let result = err.name + \"[msg: \" + err.message;\n\n if (details) {\n result +=\n \", \" +\n Object.keys(details)\n .map((k) => k + \": \" + details[k])\n .join(\", \");\n }\n\n result += \"]\";\n\n return result;\n}\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;;AA6FA;AACA;AACA;AACA;;AAmEA;AACA;AACA;;AAaA;AACA;AACA;;AA6BA;AACA;AACA;AACA;;AA6BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAM,eAAe,SAAS,KAAK,CAAC;EAGhC,WAAW,CACE,IAA2B,EAC3C,GAAW,EACX,OAAwC,EAC1C;IACE,KAAK,CAAC,GAAG,CAAC;IAAC;IAAA,KAJK,IAA2B,GAA3B,IAA2B;IAK3C,IAAI,CAAC,IAAI,GAAG,iBAAiB;IAC7B,IAAI,CAAC,cAAc,GAAG,gCAAgC,CAAC,IAAI,EAAE,OAAO,CAAC;EACzE;AACJ;AAEA,SAAS,gCAAgC,CAAC,GAAoB,EAAE,OAAwC,EAAU;EAC9G,IAAI,MAAM,GAAG,GAAG,CAAC,IAAI,GAAG,QAAQ,GAAG,GAAG,CAAC,OAAO;EAE9C,IAAI,OAAO,EAAE;IACT,MAAM,IACF,IAAI,GACJ,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CACf,GAAG,CAAE,CAAC,IAAK,CAAC,GAAG,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CACjC,IAAI,CAAC,IAAI,CAAC;EACvB;EAEA,MAAM,IAAI,GAAG;EAEb,OAAO,MAAM;AACjB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"CryptoBackend.js","names":[],"sources":["../../src/common-crypto/CryptoBackend.ts"],"sourcesContent":["/*\nCopyright 2022 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport type { IDeviceLists, IToDeviceEvent, ReceivedToDeviceMessage } from \"../sync-accumulator.ts\";\nimport { type IClearEvent, type MatrixEvent } from \"../models/event.ts\";\nimport { type Room } from \"../models/room.ts\";\nimport { type CryptoApi, type DecryptionFailureCode, type ImportRoomKeysOpts } from \"../crypto-api/index.ts\";\nimport { type KeyBackupInfo, type KeyBackupSession } from \"../crypto-api/keybackup.ts\";\nimport { type IMegolmSessionData } from \"../@types/crypto.ts\";\n\n/**\n * Common interface for the crypto implementations\n *\n * @internal\n */\nexport interface CryptoBackend extends SyncCryptoCallbacks, CryptoApi {\n /**\n * Whether sendMessage in a room with unknown and unverified devices\n * should throw an error and not send the message. This has 'Global' for\n * symmetry with setGlobalBlacklistUnverifiedDevices but there is currently\n * no room-level equivalent for this setting.\n *\n * @remarks This has no effect in Rust Crypto; it exists only for the sake of\n * the accessors in MatrixClient.\n */\n globalErrorOnUnknownDevices: boolean;\n\n /**\n * Shut down any background processes related to crypto\n */\n stop(): void;\n\n /**\n * Encrypt an event according to the configuration of the room.\n *\n * @param event - event to be sent\n *\n * @param room - destination room.\n *\n * @returns Promise which resolves when the event has been\n * encrypted, or null if nothing was needed\n */\n encryptEvent(event: MatrixEvent, room: Room): Promise<void>;\n\n /**\n * Decrypt a received event\n *\n * @returns a promise which resolves once we have finished decrypting.\n * Rejects with an error if there is a problem decrypting the event.\n */\n decryptEvent(event: MatrixEvent): Promise<EventDecryptionResult>;\n\n /**\n * Get a backup decryptor capable of decrypting megolm session data encrypted with the given backup information.\n * @param backupInfo - The backup information\n * @param privKey - The private decryption key.\n */\n getBackupDecryptor(backupInfo: KeyBackupInfo, privKey: Uint8Array): Promise<BackupDecryptor>;\n\n /**\n * Import a list of room keys restored from backup\n *\n * @param keys - a list of session export objects\n * @param backupVersion - the version of the backup these keys came from.\n * @param opts - options object\n * @returns a promise which resolves once the keys have been imported\n */\n importBackedUpRoomKeys(keys: IMegolmSessionData[], backupVersion: string, opts?: ImportRoomKeysOpts): Promise<void>;\n\n ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n //\n // Room key history sharing (MSC4268)\n //\n ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n\n /**\n * Share any shareable E2EE history in the given room with the given recipient,\n * as per [MSC4268](https://github.com/matrix-org/matrix-spec-proposals/pull/4268)\n */\n shareRoomHistoryWithUser(roomId: string, userId: string): Promise<void>;\n\n /**\n * Having accepted an invite for the given room from the given user, attempt to\n * find information about a room key bundle and, if found, download the\n * bundle and import the room keys, as per {@link https://github.com/matrix-org/matrix-spec-proposals/pull/4268|MSC4268}.\n *\n * @param roomId - The room we were invited to, for which we want to check if a room\n * key bundle was received.\n *\n * @param inviter - The user who invited us to the room and is expected to have\n * sent the room key bundle.\n *\n * @returns `true` if the key bundle was successfuly downloaded and imported.\n */\n maybeAcceptKeyBundle(roomId: string, inviter: string): Promise<boolean>;\n\n /**\n * Mark a room as pending a key bundle under MSC4268. The backend will listen for room key bundle messages, and if\n * it sees one matching the room specified, it will automatically import it as long as the message author's ID matches\n * the inviter's ID.\n *\n * @param roomId - The room we were invited to, for which we did not receive a key bundle before accepting the invite.\n * @param inviterId - The user who invited us to the room and is expected to send the room key bundle.\n */\n markRoomAsPendingKeyBundle(roomId: string, inviterId: string): Promise<void>;\n}\n\n/**\n * The parts of a sync response which are relevant to encryption, as passed to\n * {@link SyncCryptoCallbacks.processSyncChanges}.\n *\n * @internal\n */\nexport interface SyncCryptoChanges {\n /** The to-device events from the sync response (`to_device.events`), or an empty list if there were none. */\n toDeviceEvents: IToDeviceEvent[];\n\n /** The `device_lists` field from the sync response, if any. */\n deviceLists?: IDeviceLists;\n\n /**\n * The `device_one_time_keys_count` field from the sync response, if any.\n *\n * The meaning of an algorithm missing from the map (or of an absent field) depends on {@link useMsc4186}: in\n * sync v2 it means that there are no one-time keys of that algorithm on the server; in sliding sync it means that\n * the count is unchanged since the previous response.\n */\n oneTimeKeysCounts?: Record<string, number>;\n\n /**\n * The `device_unused_fallback_key_types` field from the sync response, or `undefined` if the response did not\n * include it (which means that the server does not support fallback keys).\n */\n unusedFallbackKeys?: string[];\n\n /**\n * Whether to interpret the response with MSC4186 (simplified sliding sync) semantics rather than sync v2. This\n * selects the meaning of missing one-time key counts: see {@link oneTimeKeysCounts}. Defaults to `false`.\n */\n useMsc4186?: boolean;\n}\n\n/** The methods which crypto implementations should expose to the Sync api\n *\n * @internal\n */\nexport interface SyncCryptoCallbacks {\n /**\n * Called by the sync loop once per sync response, with the parts of the response which are relevant to\n * encryption: to-device messages, device list changes, one-time key counts and unused fallback key types.\n *\n * All of this data must be passed together, in a single call per sync response, because the OlmMachine\n * interprets it as the complete E2EE state from a sync response. In particular, per the sync v2 specification,\n * an absent `device_one_time_keys_count` means that there are no one-time keys on the server, so calling this\n * without the counts from the response would trigger a spurious one-time key upload. (Sliding sync responses\n * omit the count when it is unchanged; {@link SyncCryptoChanges.useMsc4186} selects that interpretation.)\n *\n * This must be called before the room events in the sync response are processed, so that any room keys received\n * in to-device messages are available when decrypting room events.\n *\n * @param changes - the E2EE-relevant parts of the sync response\n * @returns A list of processed to-device messages. This will not map 1:1 to the input list, as some messages may\n * be invalid or fail to decrypt, and so will be omitted from the output list.\n */\n processSyncChanges(changes: SyncCryptoChanges): Promise<ReceivedToDeviceMessage[]>;\n\n /**\n * Called by the /sync loop whenever an m.room.encryption event is received.\n *\n * This is called before RoomStateEvents are emitted for any of the events in the /sync\n * response (even if the other events technically happened first). This works around a problem\n * if the client uses a RoomStateEvent (typically a membership event) as a trigger to send a message\n * in a new room (or one where encryption has been newly enabled): that would otherwise leave the\n * crypto layer confused because it expects crypto to be set up, but it has not yet been.\n *\n * @param room - in which the event was received\n * @param event - encryption event to be processed\n */\n onCryptoEvent(room: Room, event: MatrixEvent): Promise<void>;\n\n /**\n * Called by the /sync loop after each /sync response is processed.\n *\n * Used to complete batch processing, or to initiate background processes\n *\n * @param syncState - information about the completed sync.\n */\n onSyncCompleted(syncState: OnSyncCompletedData): void;\n\n /**\n * Mark all tracked users' device lists as dirty.\n *\n * This method will cause additional `/keys/query` requests on the server, so should be used only\n * when the client has desynced tracking device list deltas from the server.\n * In MSC4186: Simplified Sliding Sync, this can happen when the server expires the connection.\n */\n markAllTrackedUsersAsDirty(): Promise<void>;\n}\n\n/**\n * @internal\n */\nexport interface OnSyncCompletedData {\n /**\n * The 'next_batch' result from /sync, which will become the 'since' token for the next call to /sync.\n */\n nextSyncToken?: string;\n\n /**\n * True if we are working our way through a backlog of events after connecting.\n */\n catchingUp?: boolean;\n}\n\n/**\n * The result of a (successful) call to {@link CryptoBackend.decryptEvent}\n */\nexport interface EventDecryptionResult {\n /**\n * The plaintext payload for the event (typically containing <tt>type</tt> and <tt>content</tt> fields).\n */\n clearEvent: IClearEvent;\n /**\n * No longer used.\n * See {@link MatrixEvent#getForwardingCurve25519KeyChain}.\n * @deprecated\n */\n forwardingCurve25519KeyChain?: string[];\n /**\n * Key owned by the sender of this event. See {@link MatrixEvent#getSenderKey}.\n */\n senderCurve25519Key?: string;\n /**\n * ed25519 key claimed by the sender of this event. See {@link MatrixEvent#getClaimedEd25519Key}.\n */\n claimedEd25519Key?: string;\n\n /**\n * If another user forwarded the key to this message\n * (eg via [MSC4268](https://github.com/matrix-org/matrix-spec-proposals/pull/4268)),\n * the ID of that user.\n */\n keyForwardedBy?: string;\n}\n\n/**\n * Responsible for decrypting megolm session data retrieved from a remote backup.\n * The result of {@link CryptoBackend#getBackupDecryptor}.\n */\nexport interface BackupDecryptor {\n /**\n * Whether keys retrieved from this backup can be trusted.\n *\n * Depending on the backup algorithm, keys retrieved from the backup can be trusted or not.\n * If false, keys retrieved from the backup must be considered unsafe (authenticity cannot be guaranteed).\n * It could be by design (deniability) or for some technical reason (eg asymmetric encryption).\n */\n readonly sourceTrusted: boolean;\n\n /**\n *\n * Decrypt megolm session data retrieved from backup.\n *\n * @param ciphertexts - a Record of sessionId to session data.\n *\n * @returns An array of decrypted `IMegolmSessionData`\n */\n decryptSessions(ciphertexts: Record<string, KeyBackupSession>): Promise<IMegolmSessionData[]>;\n\n /**\n * Free any resources held by this decryptor.\n *\n * Should be called once the decryptor is no longer needed.\n */\n free(): void;\n}\n\n/**\n * Exception thrown when decryption fails\n *\n * @param code - Reason code for the failure.\n *\n * @param msg - user-visible message describing the problem\n *\n * @param details - key/value pairs reported in the logs but not shown\n * to the user.\n */\nexport class DecryptionError extends Error {\n public readonly detailedString: string;\n\n public constructor(\n public readonly code: DecryptionFailureCode,\n msg: string,\n details?: Record<string, string | Error>,\n ) {\n super(msg);\n this.name = \"DecryptionError\";\n this.detailedString = detailedStringForDecryptionError(this, details);\n }\n}\n\nfunction detailedStringForDecryptionError(err: DecryptionError, details?: Record<string, string | Error>): string {\n let result = err.name + \"[msg: \" + err.message;\n\n if (details) {\n result +=\n \", \" +\n Object.keys(details)\n .map((k) => k + \": \" + details[k])\n .join(\", \");\n }\n\n result += \"]\";\n\n return result;\n}\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;;AA6FA;AACA;AACA;AACA;AACA;AACA;;AA8BA;AACA;AACA;AACA;;AAsDA;AACA;AACA;;AAaA;AACA;AACA;;AA6BA;AACA;AACA;AACA;;AA6BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAM,eAAe,SAAS,KAAK,CAAC;EAGhC,WAAW,CACE,IAA2B,EAC3C,GAAW,EACX,OAAwC,EAC1C;IACE,KAAK,CAAC,GAAG,CAAC;IAAC;IAAA,KAJK,IAA2B,GAA3B,IAA2B;IAK3C,IAAI,CAAC,IAAI,GAAG,iBAAiB;IAC7B,IAAI,CAAC,cAAc,GAAG,gCAAgC,CAAC,IAAI,EAAE,OAAO,CAAC;EACzE;AACJ;AAEA,SAAS,gCAAgC,CAAC,GAAoB,EAAE,OAAwC,EAAU;EAC9G,IAAI,MAAM,GAAG,GAAG,CAAC,IAAI,GAAG,QAAQ,GAAG,GAAG,CAAC,OAAO;EAE9C,IAAI,OAAO,EAAE;IACT,MAAM,IACF,IAAI,GACJ,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CACf,GAAG,CAAE,CAAC,IAAK,CAAC,GAAG,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CACjC,IAAI,CAAC,IAAI,CAAC;EACvB;EAEA,MAAM,IAAI,GAAG;EAEb,OAAO,MAAM;AACjB","ignoreList":[]}
|
package/lib/embedded.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type WidgetApi } from "matrix-widget-api";
|
|
2
|
-
import { type Transport } from "./matrixrtc/index.ts";
|
|
2
|
+
import { type LivekitDelegateDelayedLeaveRequest, type LivekitGetTokenRequest, type LivekitGetTokenResponse, type Transport } from "./matrixrtc/index.ts";
|
|
3
3
|
import { MatrixEvent } from "./models/event.ts";
|
|
4
4
|
import { type ISendEventResponse, type SendDelayedEventRequestOpts, type SendDelayedEventResponse, UpdateDelayedEventAction } from "./@types/requests.ts";
|
|
5
5
|
import { type StateEvents } from "./@types/event.ts";
|
|
@@ -83,6 +83,19 @@ export interface ICapabilities {
|
|
|
83
83
|
* @defaultValue false
|
|
84
84
|
*/
|
|
85
85
|
rtcTransports?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Whether this client needs to be able to obtain LiveKit SFU tokens through the host.
|
|
88
|
+
* @experimental Part of MSC4195 & MSC4533
|
|
89
|
+
* @defaultValue false
|
|
90
|
+
*/
|
|
91
|
+
rtcLivekitGetToken?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Whether this client needs to be able to hand delayed MatrixRTC leave events over to the
|
|
94
|
+
* homeserver through the host.
|
|
95
|
+
* @experimental Part of MSC4195 & MSC4533
|
|
96
|
+
* @defaultValue false
|
|
97
|
+
*/
|
|
98
|
+
rtcLivekitDelegateDelayedLeave?: boolean;
|
|
86
99
|
}
|
|
87
100
|
export declare enum RoomWidgetClientEvent {
|
|
88
101
|
PendingEventsChanged = "PendingEvent.pendingEventsChanged"
|
|
@@ -169,6 +182,27 @@ export declare class RoomWidgetClient extends MatrixClient {
|
|
|
169
182
|
* advertises the `org.matrix.msc4515` API version (otherwise the request throws).
|
|
170
183
|
*/
|
|
171
184
|
_unstable_getRTCTransports(): Promise<Transport[]>;
|
|
185
|
+
/**
|
|
186
|
+
* Requests a token to authenticate against a LiveKit SFU with.
|
|
187
|
+
*
|
|
188
|
+
* Overrides the homeserver-side {@link MatrixClient._unstable_getLivekitToken} (MSC4195): a widget
|
|
189
|
+
* cannot make authenticated homeserver calls itself, so we ask the host to make the call on our
|
|
190
|
+
* behalf over the widget API instead (MSC4533). Requires the `rtcLivekitGetToken` capability and a
|
|
191
|
+
* host that advertises the `org.matrix.msc4533` API version (otherwise the request throws).
|
|
192
|
+
*
|
|
193
|
+
* `server_name` defaults to our own homeserver, matching what the endpoint would do server-side.
|
|
194
|
+
*/
|
|
195
|
+
_unstable_getLivekitToken(body: LivekitGetTokenRequest): Promise<LivekitGetTokenResponse>;
|
|
196
|
+
/**
|
|
197
|
+
* Hands over the management of a delayed MatrixRTC leave event to the homeserver.
|
|
198
|
+
*
|
|
199
|
+
* Overrides the homeserver-side {@link MatrixClient._unstable_delegateDelayedLeave} (MSC4195): a
|
|
200
|
+
* widget cannot make authenticated homeserver calls itself, so we ask the host to make the call on
|
|
201
|
+
* our behalf over the widget API instead (MSC4533). Requires the `rtcLivekitDelegateDelayedLeave`
|
|
202
|
+
* capability and a host that advertises the `org.matrix.msc4533` API version (otherwise the request
|
|
203
|
+
* throws).
|
|
204
|
+
*/
|
|
205
|
+
_unstable_delegateDelayedLeave(body: LivekitDelegateDelayedLeaveRequest): Promise<EmptyObject>;
|
|
172
206
|
queueToDevice({ eventType, batch }: ToDeviceBatch): Promise<void>;
|
|
173
207
|
/**
|
|
174
208
|
* Send an event to a specific list of devices via the widget API. Optionally encrypts the event.
|
package/lib/embedded.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embedded.d.ts","sourceRoot":"","sources":["../src/embedded.ts"],"names":[],"mappings":"AAgBA,OAAO,EACH,KAAK,SAAS,EAejB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,
|
|
1
|
+
{"version":3,"file":"embedded.d.ts","sourceRoot":"","sources":["../src/embedded.ts"],"names":[],"mappings":"AAgBA,OAAO,EACH,KAAK,SAAS,EAejB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACH,KAAK,kCAAkC,EACvC,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,SAAS,EACjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,WAAW,EAA4B,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EACH,KAAK,kBAAkB,EACvB,KAAK,2BAA2B,EAChC,KAAK,wBAAwB,EAC7B,wBAAwB,EAE3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhE,OAAO,EACH,YAAY,EAEZ,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,YAAY,EAEpB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAW,SAAS,EAAE,MAAM,WAAW,CAAC;AAI/C,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACvF,OAAO,EAAkB,KAAK,SAAS,EAAwB,MAAM,YAAY,CAAC;AAClF,OAAO,EAAE,KAAK,WAAW,EAA4D,MAAM,aAAa,CAAC;AAEzG,UAAU,kBAAkB;I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,IAAI,EAAE,kCAAkC,GACzC,OAAO,CAAC,WAAW,CAAC,CAGtB;IAEY,aAAa,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAU7E;IAED;;;;;;;;;;;;OAYG;IACU,wBAAwB,CACjC,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,OAAO,EAClB,UAAU,EAAE,sBAAsB,GACnC,OAAO,CAAC,IAAI,CAAC,CAIf;IAIY,gBAAgB,IAAI,OAAO,CAAC,OAAO,CAAC,CAEhD;IAGM,YAAY,IAAI,SAAS,GAAG,IAAI,CAEtC;IAED,OAAO,CAAC,YAAY;YAMN,GAAG;IAIjB,OAAO,CAAC,UAAU,CAwChB;IAEF,OAAO,CAAC,OAAO,CAwCb;IAEF,OAAO,CAAC,UAAU,CAchB;IAEF,OAAO,CAAC,aAAa,CA6BnB;YAEY,gBAAgB;CAyBjC"}
|
package/lib/embedded.js
CHANGED
|
@@ -260,6 +260,12 @@ export class RoomWidgetClient extends MatrixClient {
|
|
|
260
260
|
if (capabilities.rtcTransports) {
|
|
261
261
|
this.widgetApi.requestCapability(MatrixCapabilities.MSC4515RtcTransports);
|
|
262
262
|
}
|
|
263
|
+
if (capabilities.rtcLivekitGetToken) {
|
|
264
|
+
this.widgetApi.requestCapability(MatrixCapabilities.MSC4533RtcLivekitGetToken);
|
|
265
|
+
}
|
|
266
|
+
if (capabilities.rtcLivekitDelegateDelayedLeave) {
|
|
267
|
+
this.widgetApi.requestCapability(MatrixCapabilities.MSC4533RtcLivekitDelegateDelayedLeave);
|
|
268
|
+
}
|
|
263
269
|
}
|
|
264
270
|
async supportUpdateState() {
|
|
265
271
|
return (await this.widgetApi.getClientVersions()).includes(UnstableApiVersion.MSC2762_UPDATE_STATE);
|
|
@@ -313,7 +319,12 @@ export class RoomWidgetClient extends MatrixClient {
|
|
|
313
319
|
});
|
|
314
320
|
}) ?? []);
|
|
315
321
|
}
|
|
316
|
-
|
|
322
|
+
|
|
323
|
+
// Only poll the client well-known when a poll period was configured: leaving
|
|
324
|
+
// `clientWellKnownPollPeriod` undefined disables the lookups entirely.
|
|
325
|
+
if (opts.clientWellKnownPollPeriod !== undefined) {
|
|
326
|
+
this.cachedWellKnown.start(1000 * opts.clientWellKnownPollPeriod);
|
|
327
|
+
}
|
|
317
328
|
this.setSyncState(SyncState.Syncing);
|
|
318
329
|
logger.info("Finished initial sync");
|
|
319
330
|
this.matrixRTC.start();
|
|
@@ -520,6 +531,43 @@ export class RoomWidgetClient extends MatrixClient {
|
|
|
520
531
|
} = await this.widgetApi.getRtcTransports().catch(timeoutToConnectionError);
|
|
521
532
|
return rtcTransports;
|
|
522
533
|
}
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* Requests a token to authenticate against a LiveKit SFU with.
|
|
537
|
+
*
|
|
538
|
+
* Overrides the homeserver-side {@link MatrixClient._unstable_getLivekitToken} (MSC4195): a widget
|
|
539
|
+
* cannot make authenticated homeserver calls itself, so we ask the host to make the call on our
|
|
540
|
+
* behalf over the widget API instead (MSC4533). Requires the `rtcLivekitGetToken` capability and a
|
|
541
|
+
* host that advertises the `org.matrix.msc4533` API version (otherwise the request throws).
|
|
542
|
+
*
|
|
543
|
+
* `server_name` defaults to our own homeserver, matching what the endpoint would do server-side.
|
|
544
|
+
*/
|
|
545
|
+
async _unstable_getLivekitToken(body) {
|
|
546
|
+
const serverName = body.server_name ?? this.getDomain();
|
|
547
|
+
if (serverName === null) throw new Error("Cannot determine the server name to request a token from");
|
|
548
|
+
const {
|
|
549
|
+
jwt
|
|
550
|
+
} = await this.widgetApi.getRtcLivekitToken(_objectSpread(_objectSpread({}, body), {}, {
|
|
551
|
+
server_name: serverName
|
|
552
|
+
})).catch(timeoutToConnectionError);
|
|
553
|
+
return {
|
|
554
|
+
jwt
|
|
555
|
+
};
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* Hands over the management of a delayed MatrixRTC leave event to the homeserver.
|
|
560
|
+
*
|
|
561
|
+
* Overrides the homeserver-side {@link MatrixClient._unstable_delegateDelayedLeave} (MSC4195): a
|
|
562
|
+
* widget cannot make authenticated homeserver calls itself, so we ask the host to make the call on
|
|
563
|
+
* our behalf over the widget API instead (MSC4533). Requires the `rtcLivekitDelegateDelayedLeave`
|
|
564
|
+
* capability and a host that advertises the `org.matrix.msc4533` API version (otherwise the request
|
|
565
|
+
* throws).
|
|
566
|
+
*/
|
|
567
|
+
async _unstable_delegateDelayedLeave(body) {
|
|
568
|
+
await this.widgetApi.delegateRtcLivekitDelayedLeave(body).catch(timeoutToConnectionError);
|
|
569
|
+
return {};
|
|
570
|
+
}
|
|
523
571
|
async queueToDevice({
|
|
524
572
|
eventType,
|
|
525
573
|
batch
|