Transaction Signing⚓︎
Transaction signing can be initiated from the server or directly from the Mobile SDK. In the latter case, the transaction will only be stored in the server upon successful completion of the signing.
Server-side, the signed transaction can be retrieved from through the server API.
Server-initiated Transactions⚓︎
Server-side, the transaction to be signed is created through the server API. As part of the response qrdata is returned. This data can then be encoded in QR code to be scanned by the app, or a deeplink when working on the same device.
To start the signing flow for a specific qrData:
try {
NextAuth.getNextAuth().getFlowManager().start(qrData);
} catch (NextAuthException e) {
// TODO: Handle exception
}
do {
try flowService.start(with: data)
} catch {
// TODO: Handle error
}
Handle Callbacks⚓︎
The expected sequence of FlowUpdate callbacks (happy path) to be handled is as follows:
PROCESSINGas itsState-- the flow has started, but does not expect any input (yet). See here for more information.WAIT_FOR_INPUTas itsState. TheCurrentUserInteraction.TypeisCONFIRM_TRANSACTION-- asking the user to confirm the transaction to be signed. See here for more information.PROCESSINGas itsState-- the nextAuth Mobile SDK is processing the users confirmation.WAIT_FOR_INPUTas itsState. TheCurrentUserInteraction.TypeisVERIFY_SECOND_FACTOR-- asking the user to enter their second factor for verification. See here for more information. TheRequiredSecondFactorTyperestriction is taken into account when settingAllowedSecondFactorson theCurrentUserInteraction.PROCESSINGas itsState-- the nextAuth Mobile SDK is verifying the user's second factor and signing the transaction.DONEas itsState-- the flow successfully finished, the transaction is signed.
Info
The FlowUpdate callback(s) for a flow with CurrentUserInteraction.Type = VERIFY_SECOND_FACTOR is mandatory for transactions. Contrary to logins, the entry of the second factor cannot be bypassed through caching.
Client-initiated Transactions⚓︎
When directly creating a new transaction for signing in the Mobile SDK, only the clientState (optional, state information), clientAdditionalData (optional, data to sign), and requiredSecondFactorType (optional, which second factor is required) fields can be set. Creating a transaction either immediately starts a Flow of type SIGN_TRANSACTION, or it terminates with an error.
// prepare transaction object
Transaction transaction = new Transaction();
// optional
transaction.setClientAdditionalData(challenge);
transaction.setRequiredSecondFactorType(InteractionSecondFactorInfo.SecondFactorType.PIN);
// select first and only account
List<Account> accounts = NextAuth.getNextAuth().getAccountManager().getAccounts();
Account account = accounts.get(0);
try {
NextAuth.getNextAuth().getTransactionManager().create(transaction, account);
} catch (NextAuthException e) {
// TODO: Handle exception
}
// prepare transaction object
let transaction = Transaction()
// optional
let transaction = Transaction(
clientState: .init(),
clientAdditionalData: .init(),
requiredSecondFactorType: .pin
)
// select first and only account
guard let account = NextAuth.default.accounts.first else {
return
}
do {
try NextAuth.default.create(transaction: transaction)
} catch {
// TODO: Handle error
}
Handle Callbacks⚓︎
The expected sequence of FlowUpdate callbacks (happy path) to be handled is as follows:
PROCESSINGas itsState-- the flow has started, but does not expect any input (yet). See here for more information.WAIT_FOR_INPUTas itsState. TheCurrentUserInteraction.TypeisVERIFY_SECOND_FACTOR-- asking the user to enter their second factor for verification. See here for more information. TheRequiredSecondFactorTyperestriction is taken into account when settingAllowedSecondFactorson theCurrentUserInteraction.PROCESSINGas itsState-- the nextAuth Mobile SDK is verifying the user's second factor and signing the transaction.DONEas itsState-- the flow successfully finished, the transaction is signed.
Info
For client-initiated transactions, no CONFIRM_TRANSACTION interaction is used. The confirmation of the user can be asked before creating the transaction.
Info
The FlowUpdate callback(s) for a flow with CurrentUserInteraction.Type = VERIFY_SECOND_FACTOR is mandatory for transactions. Contrary to logins, the entry of the second factor cannot be bypassed through caching.