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
-
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
-
Throws
AbsioError
Declaration
Swift
public convenience init(apiKey: String, serverUrl: URL, applicationName: String) throwsParameters
apiKeyThe API Key needed for accessing the Absio Broker application
serverUrlThe URL of the Absio Broker application.
applicationNameA unique name for the application.
-
Throws
AbsioError
Declaration
Swift
public init(apiKey: UUID, serverUrl: URL, applicationName: String) throwsParameters
apiKeyThe API Key needed for accessing the Absio Broker application
serverUrlThe URL of the Absio Broker application.
applicationNameA unique name for the application.
-
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
contentThe container payload.
accessLevelsOptional. 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.
typeOptional 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 : EncodableParameters
contentThe container payload.
customHeaderObjectThe optional header portion of the container. This object will be serialized as JSON. Default: null.
accessLevelsOptional. 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.
typeOptional 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 : EncodableParameters
containerIdThe ID of the secured container.
customHeaderObjectOptional. 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
containerIdThe ID of the secured container.
contentOptional. 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 : EncodableParameters
containerIdThe ID of the secured container.
contentThe container payload.
customHeaderObjectThe optional header portion of the container. This object will be serialized as JSON. Default: null.
accessLevelsOptional. 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.
typeOptional 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
containerIdThe ID of the secured container.
accessLevelsOptional. 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
containerIdThe ID of the secured container.
typeOptional 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
containerIdThe 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
containerIdThe 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
containerIdThe 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
containerIdThe 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
containerIdThe 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
containerIdThe ID of the container.
Return Value
The SecuredContainer
-
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
passwordThe password used to encrypt the KeyRing portion of the KeyFile.
passphraseThe passphrase used to encrypt the password portion of the KeyFile.
reminderOptional. 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
passwordThe password used to encrypt the KeyRing portion of the KeyFile.
passphraseThe passphrase used to encrypt the password portion of the KeyFile.
reminderOptional. 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
userIdThe user’s ID.
passwordOptional. The user’s password.
passphraseThe 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
AbsioErrorDeclaration
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
userIdThe user’s ID.
keyTypeThe public key type.
indexKey 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
userIdThe user’s ID.
keyTypeThe 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
Parameters
eventTypeThe event types you are interested in. Default is all types
containerIdhe container ID to get events for.
containerTypeThe type field value to get events for. Only will return events with an exact match on the type. Default is null, meaning all events.
startIdThe starting event id to process. Defaults to the very first event.
endIdThe 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
keyRingThe user’s private key ring.
userIdUser ID
-
This will end an authenticated session. The KeyRing and the authenticated credentials on the rest client will be cleared from memory and
Throws
AbsioErrorDeclaration
Swift
public override func logout() throws -> Promise<Void>
-
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
userIdOptional. 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
keyFileDataNew Key File data
passwordThe password
passphraseThe passphrase
reminderThe reminder. Optional
-
Deletes the authenticated user’s KeyFile from the Absio Broker application.
Throws
AbsioErrorDeclaration
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
passphraseThe 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
keyRingThe user’s private key ring.
userIdUser 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) -> SelfParameters
passwordThe password used to encrypt the KeyRing portion of the KeyFile.
passphraseThe passphrase used to encrypt the password portion of the KeyFile.
reminderOptional. The reminder. This can be used to help remember the users passphrase.
completionHandlerCompletion Handler
errorHandlerError Handler
queueOptional. 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) -> SelfParameters
passwordThe password used to encrypt the KeyRing portion of the KeyFile.
passphraseThe passphrase used to encrypt the password portion of the KeyFile.
reminderOptional. The reminder. This can be used to help remember the users passphrase.
completionHandlerCompletion Handler
errorHandlerError Handler
queueOptional. 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 -> SelfParameters
userIdThe user’s ID.
passwordOptional. The user’s password.
passphraseThe user’s passphrase.
completionHandlerCompletion Handler
errorHandlerError Handler
queueOptional. 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 -> SelfParameters
userIdThe user’s ID.
keyTypeThe public key type.
indexKey Index
completionHandlerCompletion Handler
errorHandlerError Handler
queueOptional. 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 -> SelfParameters
userIdThe user’s ID.
keyTypeThe public key type.
completionHandlerCompletion Handler
errorHandlerError Handler
queueOptional. 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
Parameters
eventTypeThe event types you are interested in. Default is all types
containerIdhe container ID to get events for.
containerTypeThe type field value to get events for. Only will return events with an exact match on the type. Default is null, meaning all events.
startIdThe starting event id to process. Defaults to the very first event.
endIdThe last event id to process. Defaults to null, meaning get all events since the starting id.
completionHandlerCompletion Handler
errorHandlerError Handler
queueOptional. 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 -> SelfParameters
keyRingThe user’s private key ring.
userIdUser ID
completionHandlerCompletion Handler
errorHandlerError Handler
queueOptional. 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 -> SelfParameters
userIdOptional. The user ID. If not supplied the authenticated user’s ID will be used.
completionHandlerCompletion Handler
errorHandlerError Handler
queueOptional. Custom queue to run callback on. If not specified DispatchQueue.main queue will be used
Return Value
The user’s reminder
-
createOrUpdateKeyFile(keyFileData:password: passphrase: reminder: completionHandler: errorHandler: queue: ) 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 -> SelfParameters
keyFileDataNew Key File data
passwordThe password
passphraseThe passphrase
reminderThe reminder. Optional
completionHandlerCompletion Handler
errorHandlerError Handler
queueOptional. 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 -> SelfParameters
completionHandlerCompletion Handler
errorHandlerError Handler
queueOptional. 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 -> SelfParameters
passphraseThe passphrase
completionHandlerCompletion Handler
errorHandlerError Handler
queueOptional. 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 -> SelfParameters
keyRingThe user’s private key ring.
userIdUser ID
completionHandlerCompletion Handler
errorHandlerError Handler
queueOptional. Custom queue to run callback on. If not specified DispatchQueue.main queue will be used
View on GitHub
ServerProvider Class Reference