-
-
Notifications
You must be signed in to change notification settings - Fork 606
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Begin factoring out a CryptoBackend interface (#2955)
Part of element-hq/element-web#21972. Eventually I want to replace the whole of the current `Crypto` implementation with an alternative implementation, but in order to get from here to there, I'm factoring out a common interface which will be implemented by both implementations. I'm also determined to fix the problem where the innards of the crypto implementation are exposed to applications via the `MatrixClient.crypto` property. It's not (yet) entirely clear what shape this interface should be, so I'm going with a minimal approach and adding things as we know we need them. This means that we need to keep the old `client.crypto` property around as well as a new `client.cryptoBackend` property. Eventually `client.crypto` will go away, but that will be a breaking change in the js-sdk.
- Loading branch information
Showing
11 changed files
with
255 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
Copyright 2022 The Matrix.org Foundation C.I.C. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
import type { IEventDecryptionResult } from "../@types/crypto"; | ||
import { MatrixEvent } from "../models/event"; | ||
|
||
/** | ||
* Common interface for the crypto implementations | ||
*/ | ||
export interface CryptoBackend { | ||
/** | ||
* Global override for whether the client should ever send encrypted | ||
* messages to unverified devices. This provides the default for rooms which | ||
* do not specify a value. | ||
* | ||
* If true, all unverified devices will be blacklisted by default | ||
*/ | ||
globalBlacklistUnverifiedDevices: boolean; | ||
|
||
/** | ||
* Whether sendMessage in a room with unknown and unverified devices | ||
* should throw an error and not send the message. This has 'Global' for | ||
* symmetry with setGlobalBlacklistUnverifiedDevices but there is currently | ||
* no room-level equivalent for this setting. | ||
*/ | ||
globalErrorOnUnknownDevices: boolean; | ||
|
||
/** | ||
* Shut down any background processes related to crypto | ||
*/ | ||
stop(): void; | ||
|
||
/** | ||
* Checks if the user has previously published cross-signing keys | ||
* | ||
* This means downloading the devicelist for the user and checking if the list includes | ||
* the cross-signing pseudo-device. | ||
* @returns true if the user has previously published cross-signing keys | ||
*/ | ||
userHasCrossSigningKeys(): Promise<boolean>; | ||
|
||
/** | ||
* Decrypt a received event | ||
* | ||
* @returns a promise which resolves once we have finished decrypting. | ||
* Rejects with an error if there is a problem decrypting the event. | ||
*/ | ||
decryptEvent(event: MatrixEvent): Promise<IEventDecryptionResult>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
This directory contains functionality which is common to both the legacy (libolm-based) crypto implementation, | ||
and the new rust-based implementation. | ||
|
||
It is an internal module, and is _not_ directly exposed to applications. |
Oops, something went wrong.