ServerProvider

public class ServerProvider : BaseProvider

Provider that sources all data (containers, public keys, key files, users, etc from the Absio Broker This provider serves as a user session with the Absio Broker application. Use logIn to start an authenticated

Properties

  • The API Key needed for accessing the Absio Broker application

    Declaration

    Swift

    public let apiKey: UUID
  • A unique name for the application. This is optional, but is helpful if debugging requests on the Absio Broker application.

    Declaration

    Swift

    public let applicationName: String
  • The URL of the Absio Broker application.

    Declaration

    Swift

    public let serverUrl: URL

Initializers

  • Throws

    AbsioError

    Declaration

    Swift

    public convenience init(apiKey: String, serverUrl: URL, applicationName: String) throws

    Parameters

    apiKey

    The API Key needed for accessing the Absio Broker application

    serverUrl

    The URL of the Absio Broker application.

    applicationName

    A unique name for the application.

  • Throws

    AbsioError

    Declaration

    Swift

    public init(apiKey: UUID, serverUrl: URL, applicationName: String) throws

    Parameters

    apiKey

    The API Key needed for accessing the Absio Broker application

    serverUrl

    The URL of the Absio Broker application.

    applicationName

    A unique name for the application.

Container operations.

  • Creates and persists a new SecuredContainer on the Absio Broker application 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 has one access level for creator with default permissions.

    type

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

    Return Value

    The created SecuredContainer.

  • Creates and persists a new SecuredContainer on the Absio Broker application 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 object will be serialized as JSON. Default: null.

    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 has one access level for creator with default permissions.

    type

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

    Return Value

    The created SecuredContainer.

  • 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 header will be nil.

    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, 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 container payload.

    customHeaderObject

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

    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 has one access level for creator with default permissions.

    type

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

    Return Value

    The updated SecuredContainer.

  • Update the access 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 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 has one access level for creator with default permissions.

  • 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 string used to categorize the Container. Default: nil.

    Return Value

    The updated SecuredContainer.

  • Fetches an container with the given ID. 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 container.

    Return Value

    Container with content, header, and container metadata.

  • Gets the decrypted header for a secured container. 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 container.

    Return Value

    The decrypted header from the container.

  • Gets the decrypted content for a secured container. 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 container.

    Return Value

    The decrypted data for the secured container.

  • Gets the metadata for a secured container. 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 container.

    Return Value

    The metadata for the requested container.

  • Deletes the secured container with the given ID from the Absio Broker application. The encrypted content and associated metadata 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 container.

  • This will get the secured container and associated metadata from the Absio Broker application. No decryption will be performed. Calling this method requires an authenticated session. See login for authenticating.

    Throws

    AbsioError

    Declaration

    Swift

    public func getSecuredContainer(containerId: UUID) throws -> Promise<SecuredContainer>

    Parameters

    containerId

    The ID of the container.

    Return Value

    The SecuredContainer

User operations.

  • This will create a new user stored on the Absio Broker application. A KeyRing and UserId will be created for the user. The encrypted KeyRing will be stored on the Absio Broker application 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 exception on failure. When successful the session will be authenticated.

    Throws

    AbsioError

    Declaration

    Swift

    public func register(password: String, passphrase: String, reminder: String? = nil) 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.

    reminder

    Optional. The reminder. This can be used to help remember the users passphrase.

    Return Value

    The encrypted KeyFile data

  • 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). The encrypted KeyFile bytes and the hash of the passprhase are passed to the Absio Broker application for backup. If a reminder is supplied, it will be passed as well. The reminder can be used to help a user recall their passphrase.

    Throws

    AbsioError

    Declaration

    Swift

    public func changeCredentials(password: String, passphrase: String, reminder: String? = nil) 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.

    reminder

    Optional. The reminder. This can be used to help remember the users passphrase.

    Return Value

    The encrypted KeyFile bytes

  • Authenticates the user with the Absio Broker application by decrypting the KeyFile. The KeyFile will be requested from the Absio Broker application using the passphrase. Once decrypted the KeyRing is used to create the authenticated session with the Absio Broker application. The Password is optional, but the passphrase is not. If the password is not included, the passphrase will be used to get the password from the KeyFile. If no passphrase was included the operation will fail. All mappers will be created and initialized. This will throw an exception 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

    The user’s passphrase.

    Return Value

    The encrypted KeyFile bytes

  • Deletes all associated data for the authenticated user. NOTE: This cannot be undone. Ensure you really want to perform this operation before doing so. All data related to the user will be removed from the Absio Broker application.

    Throws

    AbsioError

    Declaration

    Swift

    public override func deleteUser() throws -> Promise<Void>
  • This gets all public keys that match the user ID and type from the Absio Broker application.

    Throws

    AbsioError

    Declaration

    Swift

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

    Parameters

    userId

    The user’s ID.

    keyType

    The public key type.

    index

    Key Index

    Return Value

    Array of requested public Keys

  • This gets the latest active public key that match the user ID and type from the Absio Broker application.

    Throws

    AbsioError

    Declaration

    Swift

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

    Parameters

    userId

    The user’s ID.

    keyType

    The public key type.

    Return Value

    The latest active public key for the user of the specified type

  • Gets all ContainerEvents that match the action type, starting id, ending id, container id and type. No parameters are required. If none are supplied this will return all ContainerEvents for all time for the authenticated user. This can be used to synchronize accounts or keep a store up-to-date with the latest container activity related to the user.

    Throws

    AbsioError

    Declaration

    Swift

    public func getEvents(eventType: EventType? = nil, containerId: UUID? = nil, containerType: String? = nil, startId: Int? = nil, endId: Int? = nil) throws -> Promise<[Event]>

    Parameters

    eventType

    The event types you are interested in. Default is all types

    containerId

    he container ID to get events for.

    containerType

    The type field value to get events for. Only will return events with an exact match on the type. Default is null, meaning all events.

    startId

    The starting event id to process. Defaults to the very first event.

    endId

    The last event id to process. Defaults to null, meaning get all events since the starting id.

    Return Value

    A list of events that match the given criteria.

  • Uses the provided KeyRing to authenticate with the Absio Broker application.

    Throws

    AbsioError

    Declaration

    Swift

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

    Parameters

    keyRing

    The user’s private key ring.

    userId

    User ID

  • This will end an authenticated session. The KeyRing and the authenticated credentials on the rest client will be cleared from memory and

    Throws

    AbsioError

    Declaration

    Swift

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

Key File operations.

  • Gets the reminder for a user. The reminder can be used to help a user recall their passphrase. If the session is authenticated the user ID is not required. If not supplied the authenticated user’s ID will be used.

    Throws

    AbsioError

    Declaration

    Swift

    public func getReminder(userId: UUID? = nil) throws -> Promise<String>

    Parameters

    userId

    Optional. The user ID. If not supplied the authenticated user’s ID will be used.

    Return Value

    The user’s reminder

  • Creates or updates the KeyFile on the Absio Broker application. The passphrase is used to securely store the KeyFile on the server. The reminder can be used to help the user recall their passphrase.

    Throws

    AbsioError

    Declaration

    Swift

    public func createOrUpdateKeyFile(keyFileData: Data, password: String, passphrase: String, reminder: String?) throws -> Promise<Data>

    Parameters

    keyFileData

    New Key File data

    password

    The password

    passphrase

    The passphrase

    reminder

    The reminder. Optional

  • Deletes the authenticated user’s KeyFile from the Absio Broker application.

    Throws

    AbsioError

    Declaration

    Swift

    public func deleteKeyFile() throws -> Promise<Void>
  • Gets a user’s KeyFile.

    Throws

    AbsioError

    Declaration

    Swift

    public func getKeyFile(passphrase: String) throws -> Promise<Data>

    Parameters

    passphrase

    The passphrase

    Return Value

    The encrypted KeyFile bytes from the server.

  • Checks if the encrypted KeyFile bytes are different on the Absio Broker application for the user. This can be used to determine if the KeyFile on the Absio Broker application needs to be synced locally.

    Throws

    AbsioError

    Declaration

    Swift

    public func needToSyncAccount(userId: UUID, keyFileData: Data) throws -> Promise<Bool>

    Parameters

    keyRing

    The user’s private key ring.

    userId

    User ID

  • This will create a new user stored on the Absio Broker application. A KeyRing and UserId will be created for the user. The encrypted KeyRing will be stored on the Absio Broker application 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 exception on failure. When successful the session will be authenticated.

    Throws

    AbsioError

    Declaration

    Swift

    public func register(password: String, passphrase: String, reminder: String? = nil, completionHandler: @escaping (Data) -> Void, errorHandler: @escaping (Error) -> Void, queue: DispatchQueue? = nil) -> 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.

    reminder

    Optional. The reminder. This can be used to help remember the users passphrase.

    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 data

  • 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). The encrypted KeyFile bytes and the hash of the passprhase are passed to the Absio Broker application for backup. If a reminder is supplied, it will be passed as well. The reminder can be used to help a user recall their passphrase.

    Throws

    AbsioError

    Declaration

    Swift

    public func changeCredentials(password: String, passphrase: String, reminder: String? = nil, completionHandler: @escaping (Data) -> Void, errorHandler: @escaping (Error) -> Void, queue: DispatchQueue? = nil) -> 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.

    reminder

    Optional. The reminder. This can be used to help remember the users passphrase.

    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

  • Authenticates the user with the Absio Broker application by decrypting the KeyFile. The KeyFile will be requested from the Absio Broker application using the passphrase. Once decrypted the KeyRing is used to create the authenticated session with the Absio Broker application. The Password is optional, but the passphrase is not. If the password is not included, the passphrase will be used to get the password from the KeyFile. If no passphrase was included the operation will fail. All mappers will be created and initialized. This will throw an exception 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

    The user’s passphrase.

    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

  • This gets all public keys that match the user ID and type from the Absio Broker application.

    Throws

    AbsioError

    Declaration

    Swift

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

    Parameters

    userId

    The user’s ID.

    keyType

    The public key type.

    index

    Key Index

    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

    Array of requested public Keys

  • This gets the latest active public key that match the user ID and type from the Absio Broker application.

    Throws

    AbsioError

    Declaration

    Swift

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

    Parameters

    userId

    The user’s ID.

    keyType

    The public key type.

    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 latest active public key for the user of the specified type

  • Gets all ContainerEvents that match the action type, starting id, ending id, container id and type. No parameters are required. If none are supplied this will return all ContainerEvents for all time for the authenticated user. This can be used to synchronize accounts or keep a store up-to-date with the latest container activity related to the user.

    Throws

    AbsioError

    Declaration

    Swift

    public func getEvents(eventType: EventType? = nil, containerId: UUID? = nil, containerType: String? = nil, startId: Int? = nil, endId: Int? = nil, completionHandler: @escaping ([Event]) -> Void, errorHandler: @escaping (Error) -> Void, queue: DispatchQueue? = nil) throws -> Self

    Parameters

    eventType

    The event types you are interested in. Default is all types

    containerId

    he container ID to get events for.

    containerType

    The type field value to get events for. Only will return events with an exact match on the type. Default is null, meaning all events.

    startId

    The starting event id to process. Defaults to the very first event.

    endId

    The last event id to process. Defaults to null, meaning get all events since the starting id.

    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

    A list of events that match the given criteria.

  • Uses the provided KeyRing to authenticate with the Absio Broker application.

    Throws

    AbsioError

    Declaration

    Swift

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

    Parameters

    keyRing

    The user’s private key ring.

    userId

    User ID

    completionHandler

    Completion Handler

    errorHandler

    Error Handler

    queue

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

  • Gets the reminder for a user. The reminder can be used to help a user recall their passphrase. If the session is authenticated the user ID is not required. If not supplied the authenticated user’s ID will be used.

    Throws

    AbsioError

    Declaration

    Swift

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

    Parameters

    userId

    Optional. The user ID. If not supplied the authenticated user’s ID will be used.

    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 user’s reminder

  • Creates or updates the KeyFile on the Absio Broker application. The passphrase is used to securely store the KeyFile on the server. The reminder can be used to help the user recall their passphrase.

    Throws

    AbsioError

    Declaration

    Swift

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

    Parameters

    keyFileData

    New Key File data

    password

    The password

    passphrase

    The passphrase

    reminder

    The reminder. Optional

    completionHandler

    Completion Handler

    errorHandler

    Error Handler

    queue

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

  • Deletes the authenticated user’s KeyFile from the Absio Broker application.

    Throws

    AbsioError

    Declaration

    Swift

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

    Parameters

    completionHandler

    Completion Handler

    errorHandler

    Error Handler

    queue

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

  • Gets a user’s KeyFile.

    Throws

    AbsioError

    Declaration

    Swift

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

    Parameters

    passphrase

    The passphrase

    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 from the server.

  • Checks if the encrypted KeyFile bytes are different on the Absio Broker application for the user. This can be used to determine if the KeyFile on the Absio Broker application needs to be synced locally.

    Throws

    AbsioError

    Declaration

    Swift

    public func needToSyncAccount(userId: UUID, keyFileData: Data, completionHandler: @escaping (Bool) -> Void, errorHandler: @escaping (Error) -> Void, queue: DispatchQueue? = nil) throws -> Self

    Parameters

    keyRing

    The user’s private key ring.

    userId

    User ID

    completionHandler

    Completion Handler

    errorHandler

    Error Handler

    queue

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