OfsProvider

public class OfsProvider : BaseProvider

Provider that sources all data (containers, public keys, key files, users, etc from a local Obfuscating File System (OFS). This provider serves as a user session with the OFS. Use login to start an authenticated session.

Properties

  • Gets defauld ofs url for iOs

    Declaration

    Swift

    public static let defaultOfsURL: URL
  • Gets defauld ofs url for macOs

  • If True the data in the OFS Is partitioned by user.

    Declaration

    Swift

    public let partitionDataByUser: Bool
  • The root OFS directory.

    Declaration

    Swift

    public let ofsRootDirectory: URL

Initializers

  • Declaration

    Swift

    public init(ofsRootDirectory: URL = OfsProvider.defaultOfsURL, partitionDataByUser: Bool = false)

    Parameters

    ofsRootDirectory

    Optional: The root directory where to store data.

    partitionDataByUser

    If True the data in the OFS Is partitioned by user. Default: false.

Container operations.

  • Update the header of the secured container with the given ID. Calling this method requires an authenticated session. See login for authenticating.

    Throws

    AbsioError

    Declaration

    Swift

    public override func updateContainerHeader<T>(containerId: UUID, customHeaderObject: T?) throws -> Promise<SecuredContainer> where T : Decodable, T : Encodable

    Parameters

    containerId

    The ID of the secured container.

    customHeaderObject

    Optional. The header to be encrypted in the secured container. If not supplied the header will be null.

    Return Value

    The updated SecuredContainer.

  • Update the content of the secured container with the given ID. Calling this method requires an authenticated session. See login for authenticating.

    Throws

    AbsioError

    Declaration

    Swift

    public override func updateContainerContent(containerId: UUID, content: Data?) throws -> Promise<SecuredContainer>

    Parameters

    containerId

    The ID of the secured container.

    content

    Optional. The content to be encrypted in the secured container. If not supplied the content will be null.

    Return Value

    The updated SecuredContainer.

  • Update the content of the secured container with the given ID. Calling this method requires an authenticated session. See login for authenticating.

    Throws

    AbsioError

    Declaration

    Swift

    public override func updateContainerAccessLevels(containerId: UUID, accessLevels: [AccessLevel] = []) throws -> Promise<Void>

    Parameters

    containerId

    The ID of the secured container.

    accessLevels

    Optional. This is the defined access for all users. If null, the user updating the container will get full access (ContainerAccessLevel.DefaultOwnerPermissions). If any access is defined then the user creating the container will get the defined access or no access if none is defined. By default this list is null.

    Return Value

    The updated SecuredContainer.

  • Update the type of the secured container with the given ID. Calling this method requires an authenticated session. See login for authenticating.

    Throws

    AbsioError

    Declaration

    Swift

    public override func updateContainerType(containerId: UUID, type: String?) throws -> Promise<Void>

    Parameters

    containerId

    The ID of the secured container.

    type

    Optional. This is used to categorize the Container. Default: null.

    Return Value

    The updated SecuredContainer.

  • Gets the decrypted header of the secured container for the given ID. Calling this method requires an authenticated session. See login for authenticating.

    Throws

    AbsioError

    Declaration

    Swift

    public override func getContainerHeader(containerId: UUID) throws -> Promise<Header?>

    Parameters

    containerId

    The ID of the secured container.

    Return Value

    The decrypted header of the container.

  • Gets the decrypted content of the secured container for the given ID. Calling this method requires an authenticated session. See login for authenticating.

    Throws

    AbsioError

    Declaration

    Swift

    public override func getContainerContent(containerId: UUID) throws -> Promise<Data?>

    Parameters

    containerId

    The ID of the secured container.

    Return Value

    The decrypted content of the secured container.

  • Creates and persists a new SecuredContainer in the OFS and returns it. Use the returned value to learn the assigned ID. Calling this method requires an authenticated session. See login for authenticating.

    Throws

    AbsioError

    Declaration

    Swift

    public override func createContainer(content: Data?, accessLevels: [AccessLevel] = [], type: String? = nil) throws -> Promise<SecuredContainer>

    Parameters

    content

    The container payload.

    accessLevels

    Optional. This is the defined access for all users. If null, the user creating the container will get full access (ContainerAccessLevel.DefaultOwnerPermissions). If any access is defined then the user creating the container will get the defined access or no access if none is defined. By default this list is null.

    type

    Optional string used to categorize the Container. Default: null.

    Return Value

    The created SecuredContainer.

  • Creates and persists a new SecuredContainer in the OFS and returns it. Use the returned value to learn the assigned ID. Calling this method requires an authenticated session. See login for authenticating.

    Throws

    AbsioError

    Declaration

    Swift

    public override func createContainer<T>(content: Data?, customHeaderObject: T?, accessLevels: [AccessLevel] = [], type: String? = nil) throws -> Promise<SecuredContainer> where T : Decodable, T : Encodable

    Parameters

    content

    The container payload.

    customHeaderObject

    The optional header portion of the container. This Codable object will be serialized as JSON. Default: nil.

    accessLevels

    Optional. This is the defined access for all users. If null, the user creating the container will get full access (ContainerAccessLevel.DefaultOwnerPermissions). If any access is defined then the user creating the container will get the defined access or no access if none is defined. By default this list is null.

    type

    Optional string used to categorize the Container. Default: null.

    Return Value

    The created SecuredContainer.

  • Persist the SecuredContainer as a new item in the OFS and returns it. Calling this method requires an authenticated session. See login for authenticating.

    Throws

    AbsioError

    Declaration

    Swift

    public func createContainer(securedContainer: SecuredContainer) throws -> Promise<SecuredContainer>

    Parameters

    securedContainer

    The SecuredContainer to persist in the OFS.

    Return Value

    The SecuredContainer.

  • This is a helper method to persists the SecuredContainer in the OFS. It will determine if the secured container already exists in the OFS (using the id). In that case it will update the existing container. Calling this method requires an authenticated session. See login for authenticating.

    Throws

    AbsioError

    Declaration

    Swift

    public func createOrUpdateContainer(securedContainer: SecuredContainer) throws -> Promise<SecuredContainer>

    Parameters

    securedContainer

    The SecuredContainer to persist in the OFS.

    Return Value

    The SecuredContainer.

  • Deletes the secured container with the given ID from the OFS. The encrypted content and the record in the encrypted database will be removed. Calling this method requires an authenticated session. See login for authenticating.

    Throws

    AbsioError

    Declaration

    Swift

    public override func deleteContainer(containerId: UUID) throws -> Promise<Void>

    Parameters

    containerId

    The ID of the secured container.

  • Gets the SecuredContainer from the OFS (content, header and metadata), decrypts the content and header and returns the resulting container. Calling this method requires an authenticated session. See login for authenticating.

    Throws

    AbsioError

    Declaration

    Swift

    public override func getContainer(containerId: UUID) throws -> Promise<Container>

    Parameters

    containerId

    The ID of the secured container.

    Return Value

    Container with decrypted content, decrypted header, and metadata.

  • Gets the ContainerMetadata of the secured container for the given ID. Calling this method requires an authenticated session. See login for authenticating.

    Throws

    AbsioError

    Declaration

    Swift

    public override func getContainerMetadata(containerId: UUID) throws -> Promise<Container>

    Parameters

    containerId

    The ID of the secured container.

    Return Value

    Container with Metadata.

  • Get all available containers IDs Calling this method requires an authenticated session. See login for authenticating.

    Throws

    AbsioError

    Declaration

    Swift

    public func getAllContainers() throws -> Promise<[UUID]>

    Return Value

    Container IDs array

  • Update the content, header, access and type of the secured container with the given ID. Calling this method requires an authenticated session. See login for authenticating.

    Throws

    AbsioError

    Declaration

    Swift

    public override func updateContainer<T>(containerId: UUID, content: Data?, customHeaderObject: T?, accessLevels: [AccessLevel] = [], type: String? = nil) throws -> Promise<SecuredContainer> where T : Decodable, T : Encodable

    Parameters

    containerId

    The ID of the secured container.

    content

    The content to be encrypted in the secured container.

    customHeaderObject

    Custom Codable header object

    accessLevels

    Optional. This is the defined access for all users. If null, the user updating the container will get full access (ContainerAccessLevel.DefaultOwnerPermissions). If any access is defined then the user creating the container will get the defined access or no access if none is defined. By default this list is null.

    type

    Optional. This is used to categorize the Container. Default: nil.

    Return Value

    The updated SecuredContainer.

Public Keys operations.

  • This is used to create or update public key metadata (including the key itself) in the OFS database of the authenticated user. Calling this method requires an authenticated session. See login for authenticating.

    Throws

    AbsioError

    Declaration

    Swift

    public func createOrUpdatePublicKey(publicKey: PublicKey) throws -> Promise<Void>

    Parameters

    publicKey

    The key data to create or update.

  • This gets the latest active public key that match the user ID and type from the encrypted database in the OFS. This calls GetListAsync and processes the list for active keys. It is needed for the IPublicKeySource interface.

    Throws

    AbsioError

    Declaration

    Swift

    public func getLatestActivePublicKey(userId: UUID, keyType: KeyType, index: Int?) throws -> Promise<PublicKey?>

    Return Value

    The latest active public key metadata (including the key) for the user of the specified type

  • This gets all public keys that match the user ID type and index from the encrypted database in the OFS.

    Throws

    AbsioError

    Declaration

    Swift

    public func getPublicKeys(userId: UUID?, keyType: KeyType?, index: Int?) throws -> Promise<[PublicKey]>

    Parameters

    userId

    The user’s ID.

    keyType

    Key type

    index

    Optional. Key index

    Return Value

    A list of public key metadata (including the key) for the user of the specified type.

  • This deletes all public keys that match the user ID, type and index from the encrypted database in the OFS.

    Declaration

    Swift

    public func deletePublicKeys(userId: UUID, keyType: KeyType? = nil, index: Int? = nil) throws -> Promise<Void>

    Parameters

    userId

    The user’s ID.

    keyType

    Key type

    index

    Optional. Key index

User operations.

  • This will create a new user stored in the OFS. A KeyRing and UserId will be created for the user. The KeyRing will be stored in the OFS as an encrypted KeyFile. All mappers will be created and initialized. NOTE: Both the password and passphrase are required. If they are not supplied an ArgumentException will be thrown. This will throw an error on failure. When successful the session will be authenticated.

    Throws

    AbsioError

    Declaration

    Swift

    public func register(password: String, passphrase: String) throws -> Promise<Data>

    Parameters

    password

    The password used to encrypt the KeyRing portion of the KeyFile.

    passphrase

    The passphrase used to encrypt the password portion of the KeyFile.

    Return Value

    The encrypted KeyFile data

  • Authenticates the user locally by decrypting the KeyFile to get their KeyRing and then logs into the encrypted database in the OFS. Password and passphrase are both listed as optional parameters, but at least one must be included. If the password is not included, the passphrase will be used to get the password from the KeyFile. If no passphrase was included when the KeyFile was created the operation will fail. This will throw an error on failure. When successful the session will be authenticated.

    Throws

    AbsioError

    Declaration

    Swift

    public func logIn(userId: UUID, password: String? = nil, passphrase: String? = nil) throws -> Promise<Data>

    Parameters

    userId

    The user’s ID.

    password

    Optional. The user’s password.

    passphrase

    Optional. The user’s passphrase.

    Return Value

    The encrypted KeyFile data

  • Authenticates the user locally by logging into the encrypted database in the OFS. If there is no encrypted database in the OFS one will be created. All mappers will be created and initialized. This will throw an error on failure. When successful the session will be authenticated.

    Throws

    AbsioError

    Declaration

    Swift

    public func logIn(keyRing: KeyRing) throws -> Promise<Void>

    Parameters

    keyRing

    The user’s private key ring.

  • This is used to change the password and/or passphrase of a user. This will cause the KeyFile to be re-encrypted with the new password (used for the KeyRing portion). If a passphrase is supplied, the user will be allowed to authenticate (see login) with the passphrase in addition to the password. Calling this method requires an authenticated session. See login for authenticating.

    Throws

    AbsioError

    Declaration

    Swift

    public func changeCredentials(password: String, passphrase: String) throws -> Promise<Data>

    Parameters

    password

    The password used to encrypt the KeyRing.

    passphrase

    If not null, used to encrypt the password allowing access to the KeyRing when the password is forgot.

    Return Value

    The encrypted KeyFile data

  • Deletes all associated data for the authenticated user. NOTE: This cannot be undone. Ensure you really want to perform this operation before doing so. The KeyFile, encrypted database and all secured containers will be removed from the OFS. Calling this method requires an authenticated session. See login for authenticating.

    Throws

    AbsioError

    Declaration

    Swift

    public override func deleteUser() throws -> Promise<Void>
  • Creates or updates the user’s KeyFile bytes in the OFS, possibly creating both directory and file.

    Throws

    AbsioError

    Declaration

    Swift

    public func createOrUpdateKeyFile(encryptedKeyFileBlob: Data) throws -> Promise<Data>

    Parameters

    encryptedKeyFileBlob

    The encrypted KeyFile bytes

    Return Value

    The encrypted KeyFile bytes

  • This will return the KeyFile for the passed in user from the OFS in its raw form (bytes). NOTE: KeyFiles are always encrypted. Thus, they bytes returned are encrypted. Calling this method requires an authenticated session. See login for authenticating.

    Throws

    AbsioError

    Declaration

    Swift

    public func getKeyFile() throws -> Promise<Data?>

    Return Value

    The encrypted bytes of the KeyFile

  • Delete the users KeyFile from the OFS.

    Throws

    AbsioError

    Declaration

    Swift

    public func deleteKeyFile() throws -> Promise<Void>

    Return Value

    The encrypted bytes of the KeyFile

  • This will end an authenticated session.

    Throws

    AbsioError

    Declaration

    Swift

    public override func logout() throws -> Promise<Void>

Sync operations.

  • Persist the SecuredContainer as a new item in the OFS and returns it. Calling this method requires an authenticated session. See login for authenticating.

    Throws

    AbsioError

    Declaration

    Swift

    public func createContainer(securedContainer: SecuredContainer, completionHandler: @escaping (SecuredContainer) -> Void, errorHandler: @escaping (Error) -> Void, queue: DispatchQueue? = nil) throws -> Self

    Parameters

    securedContainer

    The SecuredContainer to persist in the OFS.

    Return Value

    The SecuredContainer.

  • Get all available containers IDs Calling this method requires an authenticated session. See login for authenticating.

    Throws

    AbsioError

    Declaration

    Swift

    public func getAllContainers(completionHandler: @escaping ([UUID]) -> Void, errorHandler: @escaping (Error) -> Void, queue: DispatchQueue? = nil) throws -> Self

    Return Value

    Container IDs array

  • This is used to create or update public key metadata (including the key itself) in the OFS database of the authenticated user. Calling this method requires an authenticated session. See login for authenticating.

    Throws

    AbsioError

    Declaration

    Swift

    public func createOrUpdatePublicKey(publicKey: PublicKey, completionHandler: @escaping () -> Void, errorHandler: @escaping (Error) -> Void, queue: DispatchQueue? = nil) throws -> Self

    Parameters

    publicKey

    The key data to create or update.

  • This gets the latest active public key that match the user ID and type from the encrypted database in the OFS. This calls GetListAsync and processes the list for active keys. It is needed for the IPublicKeySource interface.

    Throws

    AbsioError

    Declaration

    Swift

    public func getLatestActivePublicKey(userId: UUID, keyType: KeyType, index: Int?, completionHandler: @escaping (PublicKey?) -> Void, errorHandler: @escaping (Error) -> Void, queue: DispatchQueue? = nil) throws -> Self

    Parameters

    userId

    The user’s ID.

    keyType

    Key type

    index

    Optional. Key index

    Return Value

    The latest active public key metadata (including the key) for the user of the specified type

  • This gets all public keys that match the user ID type and index from the encrypted database in the OFS.

    Throws

    AbsioError

    Declaration

    Swift

    public func getPublicKeys(userId: UUID?, keyType: KeyType?, index: Int?, completionHandler: @escaping ([PublicKey]) -> Void, errorHandler: @escaping (Error) -> Void, queue: DispatchQueue? = nil) throws -> Self

    Parameters

    userId

    The user’s ID.

    keyType

    Key type

    index

    Optional. Key index

    Return Value

    A list of public key metadata (including the key) for the user of the specified type.

  • This deletes all public keys that match the user ID, type and index from the encrypted database in the OFS.

    Declaration

    Swift

    public func deletePublicKeys(userId: UUID, keyType: KeyType? = nil, index: Int? = nil, completionHandler: @escaping () -> Void, errorHandler: @escaping (Error) -> Void, queue: DispatchQueue? = nil) throws -> Self

    Parameters

    userId

    The user’s ID.

    keyType

    Key type

    index

    Optional. Key index

  • This will create a new user stored in the OFS. A KeyRing and UserId will be created for the user. The KeyRing will be stored in the OFS as an encrypted KeyFile. All mappers will be created and initialized. NOTE: Both the password and passphrase are required. If they are not supplied an ArgumentException will be thrown. This will throw an error on failure. When successful the session will be authenticated.

    Throws

    AbsioError

    Declaration

    Swift

    public func register(password: String, passphrase: String, completionHandler: @escaping (Data) -> Void, errorHandler: @escaping (Error) -> Void, queue: DispatchQueue? = nil) throws -> Self

    Parameters

    password

    The password used to encrypt the KeyRing portion of the KeyFile.

    passphrase

    The passphrase used to encrypt the password portion of the KeyFile.

    Return Value

    The encrypted KeyFile data

  • Authenticates the user locally by decrypting the KeyFile to get their KeyRing and then logs into the encrypted database in the OFS. Password and passphrase are both listed as optional parameters, but at least one must be included. If the password is not included, the passphrase will be used to get the password from the KeyFile. If no passphrase was included when the KeyFile was created the operation will fail. This will throw an error on failure. When successful the session will be authenticated.

    Throws

    AbsioError

    Declaration

    Swift

    public func logIn(userId: UUID, password: String? = nil, passphrase: String? = nil, completionHandler: @escaping (Data) -> Void, errorHandler: @escaping (Error) -> Void, queue: DispatchQueue? = nil) throws -> Self

    Parameters

    userId

    The user’s ID.

    password

    Optional. The user’s password.

    passphrase

    Optional. The user’s passphrase.

    Return Value

    The encrypted KeyFile data

  • Authenticates the user locally by logging into the encrypted database in the OFS. If there is no encrypted database in the OFS one will be created. All mappers will be created and initialized. This will throw an error on failure. When successful the session will be authenticated.

    Throws

    AbsioError

    Declaration

    Swift

    public func logIn(keyRing: KeyRing, completionHandler: @escaping () -> Void, errorHandler: @escaping (Error) -> Void, queue: DispatchQueue? = nil) throws -> Self

    Parameters

    keyRing

    The user’s private key ring.

  • This is used to change the password and/or passphrase of a user. This will cause the KeyFile to be re-encrypted with the new password (used for the KeyRing portion). If a passphrase is supplied, the user will be allowed to authenticate (see login) with the passphrase in addition to the password. Calling this method requires an authenticated session. See login for authenticating.

    Throws

    AbsioError

    Declaration

    Swift

    public func changeCredentials(password: String, passphrase: String, completionHandler: @escaping (Data) -> Void, errorHandler: @escaping (Error) -> Void, queue: DispatchQueue? = nil) throws -> Self

    Parameters

    password

    The password used to encrypt the KeyRing.

    passphrase

    If not null, used to encrypt the password allowing access to the KeyRing when the password is forgot.

    Return Value

    The encrypted KeyFile data

  • This will return the KeyFile for the passed in user from the OFS in its raw form (bytes). NOTE: KeyFiles are always encrypted. Thus, they bytes returned are encrypted. Calling this method requires an authenticated session. See login for authenticating.

    Throws

    AbsioError

    Declaration

    Swift

    public func getKeyFile(completionHandler: @escaping (Data?) -> Void, errorHandler: @escaping (Error) -> Void, queue: DispatchQueue? = nil) throws -> Self

    Return Value

    The encrypted bytes of the KeyFile

  • Delete the users KeyFile from the OFS.

    Throws

    AbsioError

    Declaration

    Swift

    public func deleteKeyFile(completionHandler: @escaping () -> Void, errorHandler: @escaping (Error) -> Void, queue: DispatchQueue? = nil) throws -> Self

    Return Value

    The encrypted bytes of the KeyFile

  • Creates or updates the user’s KeyFile bytes in the OFS, possibly creating both directory and file.

    Throws

    AbsioError

    Declaration

    Swift

    public func createOrUpdateKeyFile(encryptedKeyFileBlob: Data, completionHandler: @escaping (Data) -> Void, errorHandler: @escaping (Error) -> Void, queue: DispatchQueue? = nil) throws -> Self

    Parameters

    encryptedKeyFileBlob

    The encrypted KeyFile bytes

    completionHandler

    Completion Handler

    errorHandler

    Error Handler

    queue

    Optional. Custom queue to run callback on. If not specified DispatchQueue.main queue will be used

    Return Value

    The encrypted KeyFile bytes