OathStorage

public protocol OathStorage : Sendable

Protocol for OATH-specific storage operations. Extends the base storage capabilities with OATH-specific functionality.

Implementations of this protocol must be thread-safe and handle concurrent access properly.

  • Store an OATH credential.

    Throws

    OathStorageError.storageFailure if the credential cannot be stored.

    Throws

    OathStorageError.duplicateCredential if a credential with the same ID already exists.

    Declaration

    Swift

    func storeOathCredential(_ credential: OathCredential) async throws

    Parameters

    credential

    The OATH credential to be stored.

  • Retrieve an OATH credential by its ID.

    Throws

    OathStorageError.storageFailure if the credential cannot be retrieved.

    Declaration

    Swift

    func retrieveOathCredential(credentialId: String) async throws -> OathCredential?

    Parameters

    credentialId

    The ID of the credential to retrieve.

    Return Value

    The OATH credential, or nil if not found.

  • Get all OATH credentials.

    Throws

    OathStorageError.storageFailure if the credentials cannot be retrieved.

    Declaration

    Swift

    func getAllOathCredentials() async throws -> [OathCredential]

    Return Value

    A list of all OATH credentials.

  • Remove an OATH credential by its ID.

    Throws

    OathStorageError.storageFailure if the credential cannot be removed.

    Declaration

    Swift

    func removeOathCredential(credentialId: String) async throws -> Bool

    Parameters

    credentialId

    The ID of the credential to remove.

    Return Value

    true if the credential was successfully removed, false if it didn’t exist.

  • Retrieve an OATH credential by issuer and account name. Used for duplicate detection during credential registration.

    Throws

    OathStorageError.storageFailure if the credential cannot be retrieved.

    Declaration

    Swift

    func getCredentialByIssuerAndAccount(issuer: String, accountName: String) async throws -> OathCredential?

    Parameters

    issuer

    The issuer of the credential.

    accountName

    The account name of the credential.

    Return Value

    The OATH credential if found, nil otherwise.

  • clearOathCredentials() Asynchronous

    Clear all OATH credentials from the storage.

    Throws

    OathStorageError.storageFailure if the credentials cannot be cleared.

    Declaration

    Swift

    func clearOathCredentials() async throws