PreKeyRepository

internal interface PreKeyRepository

Inheritors

Functions

Link copied to clipboard
abstract suspend fun establishSessions(proteusContext: ProteusCoreCryptoContext, missingContactClients: Map<UserId, List<ClientId>>): Either<CoreFailure, UsersWithoutSessions>
Link copied to clipboard
abstract suspend fun fetchRemotelyAvailablePrekeys(): Either<CoreFailure, List<Int>>

Fetches the IDs of the prekeys currently available on the backend.

Link copied to clipboard
abstract suspend fun forceInsertMostRecentPreKeyId(newId: Int): Either<StorageFailure, Unit>

Forces the insert of the ID of the most recent "rolling" prekey that was generated. Useful

Link copied to clipboard
abstract suspend fun generateNewLastResortKey(): Either<ProteusFailure, PreKeyCrypto>

Also known as "last prekey", it's the prekey that the backend will share with other clients when it runs out of prekeys for this client. For "rolling" prekeys, see generateNewPreKeysAuto.

Link copied to clipboard
abstract suspend fun generateNewPreKeysAuto(keysCount: Int): Either<CoreFailure, List<PreKeyCrypto>>

Generates rolling prekeys, with Core Crypto automatically selecting the next available prekey ID. The generated prekeys can be uploaded to the backend and shared with other clients in order to initialise a new conversation with this client.

Link copied to clipboard
abstract fun lastPreKeyRefillCheckInstantFlow(): Flow<Instant?>

Observes the last pre-key check instant.

Link copied to clipboard
abstract suspend fun mostRecentPreKeyId(): Either<StorageFailure, Int>

Returns the ID of the most recent "rolling" prekey that was generated.

Link copied to clipboard
abstract suspend fun setLastPreKeyRefillCheckInstant(instant: Instant): Either<StorageFailure, Unit>

Sets the last prekey refill check date.

Link copied to clipboard
abstract suspend fun updateMostRecentPreKeyId(newId: Int): Either<StorageFailure, Unit>

Updates the ID of the most recent "rolling" prekey that was generated.

Link copied to clipboard
abstract suspend fun uploadNewPrekeyBatch(batch: List<PreKeyCrypto>): Either<CoreFailure, Unit>

Uploads a batch of prekeys to the backend, so they become available for other clients to start sessions with this client.