Skip to content

Commit

Permalink
Fix up comments on globalErrorOnUnknownDevices (#3834)
Browse files Browse the repository at this point in the history
The current deprecation notice advises you to use a method which does something
completely different.

Fixing this "properly" is slightly challenging because we don't want to support
setting it to `true` in Rust Crypto; yet I don't really want to change the
default for legacy crypto.

Let's just document the behaviour for now.
  • Loading branch information
richvdh authored Oct 25, 2023
1 parent 73a8765 commit 084beaa
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2679,12 +2679,12 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
*
* This API is currently UNSTABLE and may change or be removed without notice.
*
* @param value - whether error on unknown devices
* It has no effect with the Rust crypto implementation.
*
* @deprecated Prefer direct access to {@link CryptoApi.globalBlacklistUnverifiedDevices}:
* @param value - whether error on unknown devices
*
* ```ts
* client.getCrypto().globalBlacklistUnverifiedDevices = value;
* client.getCrypto().globalErrorOnUnknownDevices = value;
* ```
*/
public setGlobalErrorOnUnknownDevices(value: boolean): void {
Expand Down
4 changes: 2 additions & 2 deletions src/common-crypto/CryptoBackend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export interface CryptoBackend extends SyncCryptoCallbacks, CryptoApi {
* symmetry with setGlobalBlacklistUnverifiedDevices but there is currently
* no room-level equivalent for this setting.
*
* @remarks this is here, rather than in `CryptoApi`, because I don't think we're
* going to support it in the rust crypto implementation.
* @remarks This has no effect in Rust Crypto; it exists only for the sake of
* the accessors in MatrixClient.
*/
globalErrorOnUnknownDevices: boolean;

Expand Down
10 changes: 9 additions & 1 deletion src/rust-crypto/rust-crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ const KEY_BACKUP_CHECK_RATE_LIMIT = 5000; // ms
* @internal
*/
export class RustCrypto extends TypedEventEmitter<RustCryptoEvents, RustCryptoEventMap> implements CryptoBackend {
public globalErrorOnUnknownDevices = false;
private _trustCrossSignedDevices = true;

/** whether {@link stop} has been called */
Expand Down Expand Up @@ -220,6 +219,15 @@ export class RustCrypto extends TypedEventEmitter<RustCryptoEvents, RustCryptoEv
//
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

public set globalErrorOnUnknownDevices(_v: boolean) {
// Not implemented for rust crypto.
}

public get globalErrorOnUnknownDevices(): boolean {
// Not implemented for rust crypto.
return false;
}

public stop(): void {
// stop() may be called multiple times, but attempting to close() the OlmMachine twice
// will cause an error.
Expand Down

0 comments on commit 084beaa

Please sign in to comment.