convert DecryptionResult
This commit is contained in:
parent
dea1e7eaf3
commit
7aeda70ff6
2 changed files with 26 additions and 20 deletions
|
@ -26,35 +26,41 @@ limitations under the License.
|
|||
* see DeviceTracker
|
||||
*/
|
||||
|
||||
import type {DeviceIdentity} from "../storage/idb/stores/DeviceIdentityStore";
|
||||
|
||||
type DecryptedEvent = {
|
||||
type?: string,
|
||||
content?: Record<string, any>
|
||||
}
|
||||
|
||||
export class DecryptionResult {
|
||||
constructor(event, senderCurve25519Key, claimedEd25519Key) {
|
||||
this.event = event;
|
||||
this.senderCurve25519Key = senderCurve25519Key;
|
||||
this.claimedEd25519Key = claimedEd25519Key;
|
||||
this._device = null;
|
||||
this._roomTracked = true;
|
||||
private device?: DeviceIdentity;
|
||||
private roomTracked: boolean = true;
|
||||
|
||||
constructor(
|
||||
public readonly event: DecryptedEvent,
|
||||
public readonly senderCurve25519Key: string,
|
||||
public readonly claimedEd25519Key: string
|
||||
) {}
|
||||
|
||||
setDevice(device: DeviceIdentity) {
|
||||
this.device = device;
|
||||
}
|
||||
|
||||
setDevice(device) {
|
||||
this._device = device;
|
||||
setRoomNotTrackedYet(): void {
|
||||
this.roomTracked = false;
|
||||
}
|
||||
|
||||
setRoomNotTrackedYet() {
|
||||
this._roomTracked = false;
|
||||
}
|
||||
|
||||
get isVerified() {
|
||||
if (this._device) {
|
||||
const comesFromDevice = this._device.ed25519Key === this.claimedEd25519Key;
|
||||
get isVerified(): boolean {
|
||||
if (this.device) {
|
||||
const comesFromDevice = this.device.ed25519Key === this.claimedEd25519Key;
|
||||
return comesFromDevice;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
get isUnverified() {
|
||||
if (this._device) {
|
||||
get isUnverified(): boolean {
|
||||
if (this.device) {
|
||||
return !this.isVerified;
|
||||
} else if (this.isVerificationUnknown) {
|
||||
return false;
|
||||
|
@ -63,8 +69,8 @@ export class DecryptionResult {
|
|||
}
|
||||
}
|
||||
|
||||
get isVerificationUnknown() {
|
||||
get isVerificationUnknown(): boolean {
|
||||
// verification is unknown if we haven't yet fetched the devices for the room
|
||||
return !this._device && !this._roomTracked;
|
||||
return !this.device && !this.roomTracked;
|
||||
}
|
||||
}
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import {DecryptionResult} from "../../DecryptionResult.js";
|
||||
import {DecryptionResult} from "../../DecryptionResult";
|
||||
import {DecryptionError} from "../../common.js";
|
||||
import {ReplayDetectionEntry} from "./ReplayDetectionEntry";
|
||||
import type {RoomKey} from "./RoomKey";
|
||||
|
|
Reference in a new issue