@@ -296,7 +296,7 @@ export interface ICreateClientOpts {
296
296
* specified, uses a default implementation (indexeddb in the browser,
297
297
* in-memory otherwise).
298
298
*
299
- * This is only used for the legacy crypto implementation (as used by { @link MatrixClient#initLegacyCrypto}) ,
299
+ * This is only used for the legacy crypto implementation,
300
300
* but if you use the rust crypto implementation ({@link MatrixClient#initRustCrypto}) and the device
301
301
* previously used legacy crypto (so must be migrated), then this must still be provided, so that the
302
302
* data can be migrated from the legacy store.
@@ -391,7 +391,7 @@ export interface ICreateClientOpts {
391
391
*
392
392
* This must be set to the same value every time the client is initialised for the same device.
393
393
*
394
- * This is only used for the legacy crypto implementation (as used by { @link MatrixClient#initLegacyCrypto}) ,
394
+ * This is only used for the legacy crypto implementation,
395
395
* but if you use the rust crypto implementation ({@link MatrixClient#initRustCrypto}) and the device
396
396
* previously used legacy crypto (so must be migrated), then this must still be provided, so that the
397
397
* data can be migrated from the legacy store.
@@ -2138,92 +2138,9 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
2138
2138
return this . serverCapabilitiesService . fetchCapabilities ( ) ;
2139
2139
}
2140
2140
2141
- /**
2142
- * Initialise support for end-to-end encryption in this client, using libolm.
2143
- *
2144
- * You should call this method after creating the matrixclient, but *before*
2145
- * calling `startClient`, if you want to support end-to-end encryption.
2146
- *
2147
- * It will return a Promise which will resolve when the crypto layer has been
2148
- * successfully initialised.
2149
- *
2150
- * @deprecated libolm is deprecated. Prefer {@link initRustCrypto}.
2151
- */
2152
- public async initLegacyCrypto ( ) : Promise < void > {
2153
- if ( ! isCryptoAvailable ( ) ) {
2154
- throw new Error (
2155
- `End-to-end encryption not supported in this js-sdk build: did ` +
2156
- `you remember to load the olm library?` ,
2157
- ) ;
2158
- }
2159
-
2160
- if ( this . cryptoBackend ) {
2161
- this . logger . warn ( "Attempt to re-initialise e2e encryption on MatrixClient" ) ;
2162
- return ;
2163
- }
2164
-
2165
- if ( ! this . cryptoStore ) {
2166
- // the cryptostore is provided by sdk.createClient, so this shouldn't happen
2167
- throw new Error ( `Cannot enable encryption: no cryptoStore provided` ) ;
2168
- }
2169
-
2170
- this . logger . debug ( "Crypto: Starting up crypto store..." ) ;
2171
- await this . cryptoStore . startup ( ) ;
2172
-
2173
- const userId = this . getUserId ( ) ;
2174
- if ( userId === null ) {
2175
- throw new Error (
2176
- `Cannot enable encryption on MatrixClient with unknown userId: ` +
2177
- `ensure userId is passed in createClient().` ,
2178
- ) ;
2179
- }
2180
- if ( this . deviceId === null ) {
2181
- throw new Error (
2182
- `Cannot enable encryption on MatrixClient with unknown deviceId: ` +
2183
- `ensure deviceId is passed in createClient().` ,
2184
- ) ;
2185
- }
2186
-
2187
- const crypto = new Crypto ( this , userId , this . deviceId , this . store , this . cryptoStore , this . verificationMethods ! ) ;
2188
-
2189
- this . reEmitter . reEmit ( crypto , [
2190
- LegacyCryptoEvent . KeyBackupFailed ,
2191
- LegacyCryptoEvent . KeyBackupSessionsRemaining ,
2192
- LegacyCryptoEvent . RoomKeyRequest ,
2193
- LegacyCryptoEvent . RoomKeyRequestCancellation ,
2194
- LegacyCryptoEvent . Warning ,
2195
- LegacyCryptoEvent . DevicesUpdated ,
2196
- LegacyCryptoEvent . WillUpdateDevices ,
2197
- LegacyCryptoEvent . DeviceVerificationChanged ,
2198
- LegacyCryptoEvent . UserTrustStatusChanged ,
2199
- LegacyCryptoEvent . KeysChanged ,
2200
- ] ) ;
2201
-
2202
- this . logger . debug ( "Crypto: initialising crypto object..." ) ;
2203
- await crypto . init ( {
2204
- exportedOlmDevice : this . exportedOlmDeviceToImport ,
2205
- pickleKey : this . pickleKey ,
2206
- } ) ;
2207
- delete this . exportedOlmDeviceToImport ;
2208
-
2209
- this . olmVersion = Crypto . getOlmVersion ( ) ;
2210
-
2211
- // if crypto initialisation was successful, tell it to attach its event handlers.
2212
- crypto . registerEventHandlers ( this as Parameters < Crypto [ "registerEventHandlers" ] > [ 0 ] ) ;
2213
- this . cryptoBackend = this . crypto = crypto ;
2214
-
2215
- // upload our keys in the background
2216
- this . crypto . uploadDeviceKeys ( ) . catch ( ( e ) => {
2217
- // TODO: throwing away this error is a really bad idea.
2218
- this . logger . error ( "Error uploading device keys" , e ) ;
2219
- } ) ;
2220
- }
2221
-
2222
2141
/**
2223
2142
* Initialise support for end-to-end encryption in this client, using the rust matrix-sdk-crypto.
2224
2143
*
2225
- * An alternative to {@link initLegacyCrypto}.
2226
- *
2227
2144
* **WARNING**: the cryptography stack is not thread-safe. Having multiple `MatrixClient` instances connected to
2228
2145
* the same Indexed DB will cause data corruption and decryption failures. The application layer is responsible for
2229
2146
* ensuring that only one `MatrixClient` issue is instantiated at a time.
@@ -2323,7 +2240,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
2323
2240
/**
2324
2241
* Access the crypto API for this client.
2325
2242
*
2326
- * If end-to-end encryption has been enabled for this client (via {@link initLegacyCrypto} or { @link initRustCrypto}),
2243
+ * If end-to-end encryption has been enabled for this client (via {@link initRustCrypto}),
2327
2244
* returns an object giving access to the crypto API. Otherwise, returns `undefined`.
2328
2245
*/
2329
2246
public getCrypto ( ) : CryptoApi | undefined {
0 commit comments