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

interface CryptoStore {
    addEndToEndInboundGroupSession(senderCurve25519Key: string, sessionId: string, sessionData: InboundGroupSessionData, txn: unknown): void;
    addParkedSharedHistory(roomId: string, data: ParkedSharedHistory, txn?: unknown): void;
    addSharedHistoryInboundGroupSession(roomId: string, senderKey: string, sessionId: string, txn?: unknown): void;
    containsData(): Promise<boolean>;
    countEndToEndInboundGroupSessions(): Promise<number>;
    countEndToEndSessions(txn: unknown, func: ((count: number) => void)): void;
    countSessionsNeedingBackup(txn?: unknown): Promise<number>;
    deleteAllData(): Promise<void>;
    deleteEndToEndInboundGroupSessionsBatch(sessions: {
        senderKey: string;
        sessionId: string;
    }[]): Promise<void>;
    deleteEndToEndSessionsBatch(sessions: {
        deviceKey?: string;
        sessionId?: string;
    }[]): Promise<void>;
    deleteOutgoingRoomKeyRequest(requestId: string, expectedState: number): Promise<null | OutgoingRoomKeyRequest>;
    doTxn<T>(mode: Mode, stores: Iterable<string, any, any>, func: ((txn: unknown) => T), log?: Logger): Promise<T>;
    filterOutNotifiedErrorDevices(devices: IOlmDevice<DeviceInfo>[]): Promise<IOlmDevice<DeviceInfo>[]>;
    getAccount(txn: unknown, func: ((accountPickle: null | string) => void)): void;
    getAllEndToEndInboundGroupSessions(txn: unknown, func: ((session: null | ISession) => void)): void;
    getAllEndToEndSessions(txn: unknown, func: ((session: null | ISessionInfo) => void)): void;
    getAllOutgoingRoomKeyRequestsByState(wantedState: number): Promise<OutgoingRoomKeyRequest[]>;
    getCrossSigningKeys(txn: unknown, func: ((keys: null | Record<string, CrossSigningKeyInfo>) => void)): void;
    getEndToEndDeviceData(txn: unknown, func: ((deviceData: null | IDeviceData) => 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;
    getEndToEndSessionProblem(deviceKey: string, timestamp: number): Promise<null | IProblem>;
    getEndToEndSessions(deviceKey: string, txn: unknown, func: ((sessions: {
        [sessionId: string]: ISessionInfo;
    }) => void)): void;
    getEndToEndSessionsBatch(): Promise<null | ISessionInfo[]>;
    getMigrationState(): Promise<MigrationState>;
    getOrAddOutgoingRoomKeyRequest(request: OutgoingRoomKeyRequest): Promise<OutgoingRoomKeyRequest>;
    getOutgoingRoomKeyRequest(requestBody: IRoomKeyRequestBody): Promise<null | OutgoingRoomKeyRequest>;
    getOutgoingRoomKeyRequestByState(wantedStates: number[]): Promise<null | OutgoingRoomKeyRequest>;
    getOutgoingRoomKeyRequestsByTarget(userId: string, deviceId: string, wantedStates: number[]): Promise<OutgoingRoomKeyRequest[]>;
    getSecretStorePrivateKey<K>(txn: unknown, func: ((key: null | SecretStorePrivateKeys[K]) => void), type: K): void;
    getSessionsNeedingBackup(limit: number): Promise<ISession[]>;
    getSharedHistoryInboundGroupSessions(roomId: string, txn?: unknown): Promise<[senderKey: string, sessionId: string][]>;
    markSessionsNeedingBackup(sessions: ISession[], txn?: unknown): Promise<void>;
    setMigrationState(migrationState: MigrationState): Promise<void>;
    startup(): Promise<CryptoStore>;
    storeAccount(txn: unknown, accountPickle: string): void;
    storeCrossSigningKeys(txn: unknown, keys: Record<string, CrossSigningKeyInfo>): void;
    storeEndToEndDeviceData(deviceData: IDeviceData, txn: unknown): void;
    storeEndToEndInboundGroupSession(senderCurve25519Key: string, sessionId: string, sessionData: InboundGroupSessionData, txn: unknown): void;
    storeEndToEndInboundGroupSessionWithheld(senderCurve25519Key: string, sessionId: string, sessionData: IWithheld, txn: unknown): void;
    storeEndToEndRoom(roomId: string, roomInfo: IRoomEncryption, txn: unknown): void;
    storeEndToEndSession(deviceKey: string, sessionId: string, sessionInfo: ISessionInfo, txn: unknown): void;
    storeEndToEndSessionProblem(deviceKey: string, type: string, fixed: boolean): Promise<void>;
    storeSecretStorePrivateKey<K>(txn: unknown, type: K, key: SecretStorePrivateKeys[K]): void;
    takeParkedSharedHistory(roomId: string, txn?: unknown): Promise<ParkedSharedHistory[]>;
    unmarkSessionsNeedingBackup(sessions: ISession[], txn?: unknown): Promise<void>;
    updateOutgoingRoomKeyRequest(requestId: string, expectedState: number, updates: Partial<OutgoingRoomKeyRequest>): Promise<null | OutgoingRoomKeyRequest>;
}

Implemented by

Methods

  • Parameters

    • roomId: string
    • senderKey: string
    • sessionId: string
    • Optionaltxn: unknown

    Returns void

  • Parameters

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

          • count: number

          Returns 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)
        • (accountPickle): void
        • Parameters

          • accountPickle: null | string

          Returns void

    Returns void

  • Parameters

    • txn: unknown
    • func: ((session: null | ISession) => void)
        • (session): void
        • Parameters

          Returns void

    Returns void

  • Parameters

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

          Returns void

    Returns void

  • Parameters

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

          Returns void

    Returns void

  • Parameters

    • roomId: string
    • Optionaltxn: unknown

    Returns Promise<[senderKey: string, sessionId: string][]>

  • 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

    • senderCurve25519Key: string
    • sessionId: string
    • sessionData: IWithheld
    • txn: unknown

    Returns void