CLASS
# MIRACLTrust
Main class of the SDK used for all possible actions like registration and authentication.
# Properties
# users
# projectId
# Methods
# getInstance()
Getting singleton instance of the MIRACLTrust class.
- Returns: singleton instance of the MIRACLTrust class.
# configure(with:)
Configure SDK with values issued by MIRACL and stored in the Configuration object. It is recommended to be called right after the application is launched.
- Parameter configuration:object storing configurations of the SDK.
# updateProjectSettings(projectId:clientId:redirectURI:)
Set SDK project settings when they need to be updated after new session is established.
- Parameters:
- clientId:
clientId
setting for the MIRACL Platform that needs to be updated. - projectId:
projectId
setting for the MIRACL Platform that needs to be updated. - redirectURI:
redirectURI
setting for the MIRACL Platform that needs to be updated.
- clientId:
# sendVerificationEmail(userId:authenticationSessionDetails:completionHandler:)
Sending email for user id verification.
- Parameters:
- userId: identifier of the user identity. To verify identity this identifier needs to be valid email address.
- authenticationSessionDetails: details for an authentication session.
- completionHandler: a closure called when the verification has been completed. It can contain a flag indicating a verification result or an optional error object.
# getActivationToken(verificationURL:completionHandler:)
The method confirms user verification and as a result, an activation token is obtained. This activation token should be used in the registration process.
- Parameters:
- verificationURL: a verification URL received as part of the verification process.
- completionHandler: a closure called when the verification has been confirmed. It can contain an optional ActivationTokenResponse object and an optional error object.
# register(for:activationToken:pushNotificationsToken:didRequestPinHandler:completionHandler:)
Creates a new identity in the MIRACL platform.
- Parameters:
- userId: an identifier of the user (e.g email address).
- activationToken: a token obtained during the user verification process indicating that the user has been already verified.
- pushNotificationsToken: current device push notifications token. This is used when push notifications for authentication are enabled in the platform.
- didRequestPinHandler: a closure called when the PIN code is needed from the SDK. It can be used to show UI for entering the PIN code. Its parameter is another closure that is mandatory to be called after the user finishes their action.
- completionHandler: a closure called when creating a new identity has finished. It can contain an error object or the User where both of them are optional objects.
# authenticate(user:didRequestPinHandler:completionHandler:)
Authenticates identity in the MIRACL platform.
Use this method to authenticate from your application.
This method generates so called authCode
, which needs to be sent to a server for verification.
When verification is finished authentication is successful.
- Parameters:
- user: object that keeps an authentication identity in it.
- didRequestPinHandler: a closure called when the PIN code is needed from the SDK. It can be used to show UI for entering the PIN code. Its parameter is another closure that is mandatory to be called after the user finishes their action.
- completionHandler: a closure called when the auth code is generated. It can contain an optional auth code string value or an optional error object.
# authenticateWithQRCode(user:qrCode:didRequestPinHandler:completionHandler:)
Authenticates identity in the MIRACL platform.
Use this method to authenticate another device or application with the usage of QR Code presented on MIRACL login page.
- Parameters:
- user: object that keeps an authentication identity in it.
- qrCode: a string read from the QR code.
- didRequestPinHandler: a closure called when the PIN code is needed from the SDK. It can be used to show UI for entering the PIN code. Its parameter is another closure that is mandatory to be called after the user finishes their action.
- completionHandler: a closure called when the identity is authenticated. It can contain a boolean flag representing the result of the authentication or an optional error object.
# authenticateWithPushNotificationPayload(payload:didRequestPinHandler:completionHandler:)
Authenticates identity in the MIRACL platform.
Use this method when you want to authenticate another device or application with the usage of Push notifications sent by a MIRACL platform.
- Parameters:
- payload: payload dictionary received from push notification.
- didRequestPinHandler: a closure called when the PIN code is needed from the SDK. It can be used to show UI for entering the PIN code. Its parameter is another closure that is mandatory to be called after the user finishes their action.
- completionHandler: a closure called when the identity is authenticated. It can contain a boolean flag representing the result of the authentication or an optional error object.
# authenticateWithUniversalLinkURL(user:universalLinkURL:didRequestPinHandler:completionHandler:)
Authenticates identity in the MIRACL platform.
Use this method to authenticate another device or application with the usage of Universal Link created by a MIRACL platform.
- Parameters:
- user: object that keeps an authentication identity in it.
- universalLinkURL: universal link for authentication.
- didRequestPinHandler: a closure called when the PIN code is needed from the SDK. It can be used to show UI for entering the PIN code. Its parameter is another closure that is mandatory to be called after the user finishes their action.
- completionHandler: a closure called when the identity is authenticated. It can contain a boolean flag representing the result of the authentication or an optional error object.
# generateOTP(user:didRequestPinHandler:completionHandler:)
Generate OTP against the MIRACL platform.
- Parameters:
- user: an already registered user with authentication identity.
- didRequestPinHandler: a closure called when the PIN code is needed from the SDK. It can be used to show UI for entering the PIN code. Its parameter is another closure that is mandatory to be called after the user finishes their action.
- completionHandler: a closure called when the OTP has been generated. It can contain a generated OTP object or an optional error object.
# generateQuickCode(user:didRequestPinHandler:completionHandler:)
Generate QuickCode against the MIRACL platform.
- Parameters:
- user: an already registered user with authentication identity.
- didRequestPinHandler: a closure called when the PIN code is needed from the SDK. It can be used to show UI for entering the PIN code. Its parameter is another closure that is mandatory to be called after the user finishes their action.
- completionHandler: a closure called when the QuickCode has been generated. It can contain a generated OTP object or an optional error object.
# getAuthenticationSessionDetailsFromQRCode(qrCode:completionHandler:)
Get authentication
session details from MIRACL’s platform based on session identifier.
Use this method to get session details for application that tries to authenticate against MIRACL Platform with the help of QR Code.
- Parameters:
- qrCode: a string read from the QR code.
- completionHandler: a closure called when the authentication session details are fetched.It can contain a newly fetched authentication session details optional object and an optional error object.
# getAuthenticationSessionDetailsFromUniversalLinkURL(universalLinkURL:completionHandler:)
Get authentication
session details from MIRACL’s platform based on session identifier.
Use this method to get authentication session details for application that tries to authenticate against MIRACL Platform with the help of Universal Link URL.
- Parameters:
- universalLinkURL: universal link for authentication.
- completionHandler: a closure called when the authentication session details are fetched.It can contain a newly fetched authentication session details optional object and an optional error object.
# getAuthenticationSessionDetailsFromPushNotificationPayload(pushNotificationPayload:completionHandler:)
Get authentication
session details from MIRACL’s platform based on session identifier.
Use this method to get authentication session details for application that tries to authenticate against MIRACL Platform with the help of push notifications payload
- Parameters:
- pushNotificationPayload: payload dictionary received from push notification.
- completionHandler: a closure called when the authentication session details are fetched.It can contain a newly fetched authentication session details optional object and an optional error object.
# abortAuthenticationSession(authenticationSessionDetails:completionHandler:)
Cancel the authentication session by its SessionDetails
object
- Parameters:
- authenticationSessionDetails: details for authentication session, that is in progress.
- completionHandler: a closure called when the authentication session is aborted. It can contain a boolean flag representing the result of the abortion and an optional error object.
# getSigningSessionDetailsFromQRCode(qrCode:completionHandler:)
Get signing
session details from MIRACL’s platform based on session identifier.
Use this method to get signing session details for application that tries to sign against MIRACL Platform with the usage of QR Code.
- Parameters:
- qrCode: a string read from the QR code.
- completionHandler: a closure called when the session details are fetched.It can contain a newly fetched
signing
session details optional object and an optional error object.
# getSigningSessionDetailsFromUniversalLinkURL(universalLinkURL:completionHandler:)
Get signing
session details from MIRACL’s platform based on session identifier.
Use this method to get signing session details for application that tries to sign against MIRACL Platform with the usage of Universal Link URL.
- Parameters:
- universalLinkURL: universal link for signing.
- completionHandler: a closure called when the session details are fetched.It can contain a newly fetched
signing
session details optional object and an optional error object.
# completeSigningSession(signingSessionDetails:signature:timestamp:completionHandler:)
Finish signing session with returning signature and its timestamp to the MIRACL Platform.
- Parameters:
- signingSessionDetails: session that will be finished.
- signature: signature that needs to be sent to the server.
- timestamp: timestamp of the server.
- completionHandler: a closure called when the session is completed.It can contain a optional result of completion of
signing
session and an optional error object.
# signingRegister(user:didRequestAuthenticationPinHandler:didRequestSigningPinHandler:completionHandler:)
Creates a new signing identity in the MIRACL platform.
- Parameters:
- user: an already registered user with authentication identity.
- didRequestAuthenticationPinHandler: a closure called when the authentication identity PIN code is needed from the SDK. It can be used to show UI for entering the PIN code. Its parameter is another closure that is mandatory to be called after the user finishes their action.
- didRequestSigningPinHandler: a closure called when the signing identity PIN code is needed from the SDK. It can be used to show UI for entering the PIN code. Its parameter is another closure that is mandatory to be called after the user finishes their action.
- completionHandler: a closure called when the signing identity is created. It can contain a newly created signing identity optional object and an optional error object.
# sign(message:timestamp:user:didRequestSigningPinHandler:completionHandler:)
Create a cryptographic signature of a given document.
- Parameters:
- message: the hash of a given document.
- timestamp: when the document has been signed.
- user: an already registered user with signing identity.
- didRequestSigningPinHandler: a closure called when the signing identity PIN code is needed from the SDK. It can be used to show UI for entering the PIN code. Its parameter is another closure that is mandatory to be called after the user finishes their action.
- completionHandler: a closure called when the signing has completed. It can contain a newly created Signature object or an optional error object.
# getUser(by:projectId:)
Getting user by its project Id and its userId.
- Parameters:
- userId: id of the user. Can be email or any other string.
- projectId: project id taken from the portal.
- Returns: User object from the database. Returns nil if there is no such object in the storage.
# delete(user:)
Deletes a user from user storage with its signing and authentication identities.
- Parameter user: object that needs to be deleted.