android-components / mozilla.components.service.sync.logins / AsyncLoginsStorage

AsyncLoginsStorage

interface AsyncLoginsStorage : AutoCloseable (source)

An interface equivalent to the LoginsStorage interface, but where operations are asynchronous.

Functions

Name Summary
add abstract fun add(login: ServerPassword): Deferred<String>
Inserts the provided login into the database, returning it’s id.
delete abstract fun delete(id: String): Deferred<Boolean>
Deletes the password with the given ID.
ensureLocked abstract fun ensureLocked(): Deferred<Unit>
Equivalent to lock(), but does not throw in the case that the database is already unlocked. Never rejects.
ensureUnlocked abstract fun ensureUnlocked(encryptionKey: String): Deferred<Unit>
abstract fun ensureUnlocked(encryptionKey: ByteArray): Deferred<Unit>
Equivalent to unlock(encryptionKey), but does not throw in the case that the database is already unlocked.
ensureValid abstract fun ensureValid(login: ServerPassword): Deferred<Unit>
Checks if login already exists and is valid.
get abstract fun get(id: String): Deferred<ServerPassword?>
Fetches a password from the underlying storage layer by ID.
getByBaseDomain abstract fun getByBaseDomain(hostname: String): Deferred<List<ServerPassword>>
Fetch the list of passwords for some hostname from the underlying storage layer.
getHandle abstract fun getHandle(): Long
This should be removed. See: https://github.com/mozilla/application-services/issues/1877
importLoginsAsync abstract fun importLoginsAsync(logins: List<ServerPassword>): Deferred<<ERROR CLASS>>
Bulk-import of a list of ServerPassword. Storage must be empty, otherwise underlying implementation this will throw.
isLocked abstract fun isLocked(): Boolean
Returns true if the storage is locked, false otherwise.
list abstract fun list(): Deferred<List<ServerPassword>>
Fetches the full list of passwords from the underlying storage layer.
lock abstract fun lock(): Deferred<Unit>
Locks the logins storage.
sync abstract fun sync(syncInfo: SyncUnlockInfo): Deferred<SyncTelemetryPing>
Synchronizes the logins storage layer with a remote layer.
touch abstract fun touch(id: String): Deferred<Unit>
Marks the login with the given ID as in-use.
unlock abstract fun unlock(encryptionKey: String): Deferred<Unit>
Unlocks the logins storage using the provided key.abstract fun unlock(encryptionKey: ByteArray): Deferred<Unit>
Unlock (open) the database, using a byte string as the key. This is equivalent to calling unlock() after hex-encoding the bytes (lower case hexadecimal characters are used).
update abstract fun update(login: ServerPassword): Deferred<Unit>
Updates the fields in the provided record.
wipe abstract fun wipe(): Deferred<Unit>
Delete all login records. These deletions will be synced to the server on the next call to sync.
wipeLocal abstract fun wipeLocal(): Deferred<Unit>
Clear out all local state, bringing us back to the state before the first write (or sync).
withUnlocked open suspend fun <T> withUnlocked(key: () -> Deferred<String>, block: suspend (AsyncLoginsStorage) -> T): T
Run some block which operates over an unlocked instance of AsyncLoginsStorage. Database is locked once block is done.

Extension Functions

Name Summary
loadResourceAsString fun Any.loadResourceAsString(path: String): String
Loads a file from the resources folder and returns its content as a string object.

Inheritors

Name Summary
AsyncLoginsStorageAdapter open class AsyncLoginsStorageAdapter<T : LoginsStorage> : AsyncLoginsStorage, AutoCloseable
A helper class to wrap a synchronous LoginsStorage implementation and make it asynchronous.