import { BaseObservableValue } from "../../observable/value"; import { SASVerification } from "./SAS/SASVerification"; import { ObservableMap } from "../../observable/map"; import { SASRequest } from "./SAS/SASRequest"; import type { SecretStorage } from "../ssss/SecretStorage"; import type { Storage } from "../storage/idb/Storage"; import type { Platform } from "../../platform/web/Platform"; import type { DeviceTracker } from "../e2ee/DeviceTracker"; import type { HomeServerApi } from "../net/HomeServerApi"; import type { Account } from "../e2ee/Account"; import type { ILogItem } from "../../logging/types"; import type { DeviceMessageHandler } from "../DeviceMessageHandler.js"; import type { SignedValue, DeviceKey } from "../e2ee/common"; import type * as OlmNamespace from "@matrix-org/olm"; type Olm = typeof OlmNamespace; export type CrossSigningKey = SignedValue & { readonly user_id: string; readonly usage: ReadonlyArray; readonly keys: { [keyId: string]: string; }; }; export declare enum KeyUsage { Master = "master", SelfSigning = "self_signing", UserSigning = "user_signing" } export declare enum UserTrust { /** We trust the user, the whole signature chain checks out from our MSK to all of their device keys. */ Trusted = 1, /** We haven't signed this user's identity yet. Verify this user first to sign it. */ UserNotSigned = 2, /** We have signed the user already, but the signature isn't valid. One possible cause could be that an attacker is uploading signatures in our name. */ UserSignatureMismatch = 3, /** We trust the user, but they don't trust one of their devices. */ UserDeviceNotSigned = 4, /** We trust the user, but the signatures of one of their devices is invalid. * One possible cause could be that an attacker is uploading signatures in their name. */ UserDeviceSignatureMismatch = 5, /** The user doesn't have a valid signature for the SSK with their MSK, or the SSK is missing. * This likely means bootstrapping cross-signing on their end didn't finish correctly. */ UserSetupError = 6, /** We don't have a valid signature for our SSK with our MSK, the SSK is missing, or we don't trust our own MSK. * This likely means bootstrapping cross-signing on our end didn't finish correctly. */ OwnSetupError = 7 } export declare class CrossSigning { private readonly storage; private readonly secretStorage; private readonly platform; private readonly deviceTracker; private readonly olm; private readonly olmUtil; private readonly hsApi; private readonly ownUserId; private readonly e2eeAccount; private readonly deviceMessageHandler; private _isMasterKeyTrusted; private readonly observedUsers; private readonly deviceId; private sasVerificationInProgress?; receivedSASVerifications: ObservableMap; constructor(options: { storage: Storage; secretStorage: SecretStorage; deviceTracker: DeviceTracker; platform: Platform; olm: Olm; olmUtil: Olm.Utility; ownUserId: string; deviceId: string; hsApi: HomeServerApi; e2eeAccount: Account; deviceMessageHandler: DeviceMessageHandler; }); /** @return {boolean} whether cross signing has been enabled on this account */ load(log: ILogItem): Promise; start(log: ILogItem): Promise; private verifyMSKFrom4S; get isMasterKeyTrusted(): boolean; startVerification(requestOrUserId: SASRequest, log: ILogItem): SASVerification | undefined; startVerification(requestOrUserId: string, log: ILogItem): SASVerification | undefined; private handleSASDeviceMessage; /** returns our own device key signed by our self-signing key. Other signatures will be missing. */ signOwnDevice(log: ILogItem): Promise; /** @return the signed device key for the given device id */ signDevice(deviceId: string, log: ILogItem): Promise; /** @return the signed MSK for the given user id */ signUser(userId: string, log: ILogItem): Promise; getUserTrust(userId: string, log: ILogItem): Promise; dispose(): void; observeUserTrust(userId: string, log: ILogItem): BaseObservableValue; private signDeviceKey; private getSigningKey; private signKey; private hasValidSignatureFrom; private emitUserTrustUpdate; } export declare function getKeyUsage(keyInfo: CrossSigningKey): KeyUsage | undefined; export declare function getKeyEd25519Key(keyInfo: CrossSigningKey): string | undefined; export declare function getKeyUserId(keyInfo: CrossSigningKey): string | undefined; export {};