matrix-js-sdk

    Interface CryptoStore

    Abstraction of things that can store data required for end-to-end encryption

    interface CryptoStore {
        containsData(): Promise<boolean>;
        countEndToEndInboundGroupSessions(): Promise<number>;
        countEndToEndSessions(txn: unknown, func: (count: number) => void): void;
        deleteAllData(): Promise<void>;
        deleteEndToEndInboundGroupSessionsBatch(
            sessions: { senderKey: string; sessionId: string }[],
        ): Promise<void>;
        deleteEndToEndSessionsBatch(
            sessions: { deviceKey?: string; sessionId?: string }[],
        ): Promise<void>;
        doTxn<T>(
            mode: Mode,
            stores: Iterable<string>,
            func: (txn: unknown) => T,
            log?: Logger,
        ): Promise<T>;
        getAccount(
            txn: unknown,
            func: (accountPickle: null | string) => void,
        ): void;
        getCrossSigningKeys(
            txn: unknown,
            func: (keys: null | Record<string, CrossSigningKeyInfo>) => void,
        ): void;
        getEndToEndInboundGroupSession(
            senderCurve25519Key: string,
            sessionId: string,
            txn: unknown,
            func: (
                groupSession: null | InboundGroupSessionData,
                groupSessionWithheld: null | IWithheld,
            ) => void,
        ): void;
        getEndToEndInboundGroupSessionsBatch(): Promise<null | SessionExtended[]>;
        getEndToEndRooms(
            txn: unknown,
            func: (rooms: Record<string, IRoomEncryption>) => void,
        ): void;
        getEndToEndSession(
            deviceKey: string,
            sessionId: string,
            txn: unknown,
            func: (session: null | ISessionInfo) => void,
        ): void;
        getEndToEndSessions(
            deviceKey: string,
            txn: unknown,
            func: (sessions: { [sessionId: string]: ISessionInfo }) => void,
        ): void;
        getEndToEndSessionsBatch(): Promise<null | ISessionInfo[]>;
        getMigrationState(): Promise<MigrationState>;
        getSecretStorePrivateKey<K extends "m.megolm_backup.v1">(
            txn: unknown,
            func: (key: null | SecretStorePrivateKeys[K]) => void,
            type: K,
        ): void;
        markSessionsNeedingBackup(
            sessions: ISession[],
            txn?: unknown,
        ): Promise<void>;
        setMigrationState(migrationState: MigrationState): Promise<void>;
        startup(): Promise<CryptoStore>;
        storeAccount(txn: unknown, accountPickle: string): void;
        storeEndToEndInboundGroupSession(
            senderCurve25519Key: string,
            sessionId: string,
            sessionData: InboundGroupSessionData,
            txn: unknown,
        ): void;
        storeEndToEndSession(
            deviceKey: string,
            sessionId: string,
            sessionInfo: ISessionInfo,
            txn: unknown,
        ): void;
        storeSecretStorePrivateKey<K extends "m.megolm_backup.v1">(
            txn: unknown,
            type: K,
            key: SecretStorePrivateKeys[K],
        ): void;
    }

    Implemented by

    Index

    Methods

    • Parameters

      • txn: unknown
      • func: (count: number) => void

      Returns void

    • Internal

      Delete a batch of Megolm sessions from the database.

      Any sessions in the list which are not found are silently ignored.

      Parameters

      • sessions: { senderKey: string; sessionId: string }[]

      Returns Promise<void>

    • Internal

      Delete a batch of end-to-end sessions from the database.

      Any sessions in the list which are not found are silently ignored.

      Parameters

      • sessions: { deviceKey?: string; sessionId?: string }[]

      Returns Promise<void>

    • Parameters

      • txn: unknown
      • func: (accountPickle: null | string) => void

      Returns void

    • Parameters

      • senderCurve25519Key: string
      • sessionId: string
      • txn: unknown
      • func: (
            groupSession: null | InboundGroupSessionData,
            groupSessionWithheld: null | IWithheld,
        ) => void

      Returns void

    • Parameters

      • deviceKey: string
      • sessionId: string
      • txn: unknown
      • func: (session: null | ISessionInfo) => void

      Returns void

    • Parameters

      • deviceKey: string
      • txn: unknown
      • func: (sessions: { [sessionId: string]: ISessionInfo }) => void

      Returns void

    • Initialise this crypto store.

      Typically, this involves provisioning storage, and migrating any existing data to the current version of the storage schema where appropriate.

      Must be called before any of the rest of the methods in this interface.

      Returns Promise<CryptoStore>

    • Parameters

      • txn: unknown
      • accountPickle: string

      Returns void

    • Parameters

      • deviceKey: string
      • sessionId: string
      • sessionInfo: ISessionInfo
      • txn: unknown

      Returns void

    MMNEPVFCICPMFPCPTTAAATR