MFA SDK - Mobile (iOS)
TrustBuilder Safe-T SDK for mobile enables the integration of MFA capabilities into a mobile app.
It provides a set of functions that allow applications to manage authentication and transaction confirmation flows.
The SDK exposes the following functionalities:
Validate an authentication request
Confirm a transaction
Retrieve pending operations requiring user action
Reject an operation
Register a secure token for a given login
Generate an activation code to register a new secure token
Update the push notification identifier (Push ID) of the device
Retrieve secure tokens stored locally on the device
Change secret code
Reset a blocked secret code
Generate a reset code
Change the display name of a secure token
The SDK also provides in-app MFA interactions, allowing authentication and transaction flows to be handled directly within the application UI:
Request authorization for authentication or transaction confirmation within the app
Validate an authentication request in-app
Confirm a transaction in-app
Register biometric authentication as a secure factor
This integration guide uses specific terms:
Device
The device represents the possession factor of the user. It refers to the mobile device on which the application and secure token are installed.
Secure Token
A cryptographic object stored on a registered device that enables authentication.
Transaction confirmation
A process where the user explicitly approves a transaction in its specific context. The generated authentication code binds the transaction context to the user’s credentials, making it unforgeable and usable as a proof of consent.
Requirements
Download TrustBuilder sample app for iOS
Xcode: latest version currently supported by Apple
Minimum deployment target: iOS 15.0
The mobile application must be registered as a custom application in TrustBuilder administration console. You should provide Service Account JSON and Application ID to administrator. Once the application is registered in the TrustBuilder system an App Alias is automatically generated. It is required during SDK initialization.
Installation
Xcode project configuration: when creating your Xcode project, ensure that the Minimum Deployments is set to iOS 15.0 at minimum.
Add the TrustBuilder MFA library file (.xcframework) to your project with the correct version.Sample application configuration: The sample app reads its configuration from the app's
Info.plist. Add the following keys:CODE<key>App_Alias</key> <string>your_app_alias</string> <key>App_Id</key> <string>com.yourcompany.yourapp</string> <key>App_Name</key> <string>YourAppName</string>app_Alias-> the unique identifier of the custom application declared in TrustBuilder console (See Requirements)app_Id→ the bundle identifier of the application.app_Name-> the display name of the application.
Initialization
There is one interface to implement:
Implementing
IHostinterfaceIHostdescribes general properties of the host application and device:CODEimport TrustBuilderMfaLibSwift import UIKit public struct Host: IHost { public var appInfo: ApplicationInfo public var osInfo: OsInfo public var serial: String public var name: String public var type: String public var appAlias: String public init() { appInfo = ApplicationInfo( id: Bundle.main.object(forInfoDictionaryKey: "App_Id") as! String, name: Bundle.main.object(forInfoDictionaryKey: "App_Name") as! String, version: "1", type: "iOS SDK" ) osInfo = OsInfo( name: "iOS", version: UIDevice.current.systemVersion ) appAlias = Bundle.main.object(forInfoDictionaryKey: "App_Alias") as! String serial = "serial" name = "localhost" type = "IW_MOBILE" } }
Property | Description |
|---|---|
| Hardware serial identifier |
| Name given to the secure token on this host |
| Token type - always |
| Custom application alias (see Requirements) |
| Application bundle identifier |
| Application display name |
| Application version |
| Build type (e.g. |
| OS name ( |
| iOS version string |
Creating the library instance
TheTrustBuilderMfaLibinstance should be a singleton, created once and reused across activities:CODEimport TrustBuilderMfaLibSwift class TrustBuilderMfaLibHolder { static var instance: TrustBuilderMfaLibHolder = TrustBuilderMfaLibHolder() let clientLib: TrustBuilderMfaLib private init() { clientLib = TrustBuilderMfaLib(host: Host()) } public static func getClientLib() -> TrustBuilderMfaLib { return instance.clientLib } }
General principles
Use Case pattern
The SDK exposes its features as use cases. There are two types:
<SingleUseCase> → one-step use case: it exposes a single
executefunction to process it.<UseCase> → two-step use case: it exposes two functions
setupandexecuteto process it. This allows the management of data to be entered or read by the user (typically user credentials management).
The naming format of the methods exposed by the TrustBuilder MFA library looks like this:
start<UseCaseName>(param: UseCaseNameParams);
Example:
let authentication = try clientLib.startAuthentication(param: authenticationParams)
let setup = await authentication.setup();
let credValue: CredValue = CredValue(credType: .SECRET_CODE, value: Array(secretCode .utf8))
let execute = try await authentication.execute(input: credValue)
Authentication flows
There are two authentication flows:
Out-Of-Band → the authentication request is initiated from a web channel and validated on the mobile.
In-App → the authentication request is initiated from the current application and validated in the current application.
Some exposed methods are different depending on the flow type.
Features implementation
This section describes the features implemented in the sample application available in the TrustBuilder MFA Swift SDK.
For now, the TrustBuilder MFA library is named ClientLib.
Validate an authentication request
Out-Of-Band authentication
Use case name | Authentication |
|---|---|
Use case type | Use case |
Description | Authenticate a user: this generates a One-Time-Password and calls TrustBuilder server to validate it. |
Input parameter(s) |
|
Errors |
|
Example |
JAVA
See the source code of the sample application for additional information |
In-App authentication
Use case name | InAppAuthentication |
|---|---|
Use case type | UseCase |
Description | Authenticate a user in the current application. This generates a token if the authentication is successful. IN-APP |
Input parameter(s) |
|
Errors |
|
Example |
JAVA
See the source code of the sample application for additional information |
Activate a Secure Token
Use case name | SecureTokenEnrollment |
|---|---|
Use case type | Use case |
Description | Activate a Secure Token for a given login (enrollment process) |
Input parameter(s) |
|
Errors |
|
Example |
JAVA
See the source code of the sample application for additional information |
Retrieve all Secure Tokens
Use case name | SecureTokensListing |
|---|---|
Use case type | SingleUseCase |
Description | Retrieve the secure tokens stored in the local storage |
Input parameter(s) | / |
Errors |
|
Example |
JAVA
See the source code of the sample application for additional information |
Retrieve the pending operations
Use case name | PendingAuthSessionsRetrieval |
|---|---|
Use case type | SingleUseCase |
Description | Retrieve the pending operations i.e operations that need validation to be processed |
Input parameter(s) |
|
Errors |
|
Example |
JAVA
See the source code of the sample application for additional information |
Reject an operation
Use case name | AuthSessionCancellation |
|---|---|
Use case type | SingleUseCase |
Description | Reject an authentication request or a transaction confirmation request |
Input parameter(s) |
|
Errors |
|
Example |
JAVA
See the source code of the sample application for additional information |
Confirm a transaction
Out-Of-Band transaction
Use case name | Sealing |
|---|---|
Use case type | UseCase |
Description | Confirm an electronic transaction on top of authentication. This displays the business data provided by the Service Provider. Then this generates One-Time-Password and calls TrustBuilder server to validate it. |
Input parameter(s) |
|
Errors |
|
Example |
JAVA
See the source code of the sample application |
In-App transaction
Use case name | InAppSealing |
|---|---|
Use case type | UseCase |
Description | Confirm an electronic transaction on top of authentication in the current application. This generates a token if the authentication is successful. IN-APP |
Input parameter(s) |
|
Errors |
|
Example |
JAVA
See the source code of the sample application for additional information |
Request an authorization
Use case name | AuthorizationRequest |
|---|---|
Use case type | SingleUseCase |
Description | Request an authorization for an in-app authentication or for an in-app transaction confirmation. It will provide a sessionId to execute the requested operation. IN-APP |
Input parameter(s) |
|
Errors |
|
Example |
JAVA
See the source code of the sample application for additional information |
Generate an activation code
Use case name | ActivationCodeGeneration |
|---|---|
Use case type | UseCase |
Description | Generate an activation code to activate a new Secure Token on another device |
Input parameter(s) |
|
Errors |
|
Example |
JAVA
See the source code of the sample application for additional information |
Change Secret Code
Use case name | SecretCodeChange |
|---|---|
Use case type | UseCase |
Description | Change a secret code (the user knows the current secret code but wants to change its value) |
Input parameter(s) |
|
Errors |
|
Example |
JAVA
See the source code of the sample application for additional information |
Reset a Secret code
Use case name | secretCodeReset |
|---|---|
Use case type | UseCase |
Description | Reset a blocked secret code |
Input parameter(s) |
|
Errors |
|
Example |
SWIFT
See the source code of the sample application |
Generate a Reset code
Use case name | ResetCodeGeneration |
|---|---|
Use case type | SingleUseCase |
Description | Generate a reset code and send it by email to the user An error is returned:
|
Input parameter(s) |
|
Errors |
|
Example |
JAVA
See the source code of the sample application for additional information |
Change the Secure token name
Use case name | SecureTokenFriendlyNameUpdate |
|---|---|
Use case type | SingleUseCase |
Description | Update the friendly name of the secure token -optional, used to identify more easily the secure token |
Input parameter(s) |
|
Errors |
|
Example |
JAVA
See the source code of the sample application for additional information |
Update the push ID
Use case name | pushIdRegistration |
|---|---|
Use case type | SingleUseCase |
Description | Update the push ID generated for the host application |
Input parameter(s) |
|
Errors |
|
Example |
JAVA
See the source code of the sample application for additional information |
Register a biometric factor
Use case name | BiokeyRegistration |
|---|---|
Use case type | UseCase |
Description | Register biometric data. A key pair is generated in the keychain to be used on a successful biometric matching on the trusted device. The public key is provided to inWebo for a verification of the challenge signature during authentication. |
Input parameter(s) |
|
Errors |
|
Example |
SWIFT
See the source code of the sample application |
Data Types
Data | Description | Parameters |
|---|---|---|
CredentialProvider | Object containing the information needed to request a credential from the user |
|
CredValue | Object containing the credential data |
|
CredType | Credential type |
|
BoolResult | Object encapsulating a Boolean |
|
SecureToken | Data of a secure token exposed by the library |
|
AuthSessionDto | Data of an authentication session or a sealing session |
|