MIRACLTrust

CLASS

MIRACLTrust

@objc open class MIRACLTrust: NSObject, Loggable

Main class of the SDK used for all possible actions like registration and authentication.

Properties

authenticationUsers

@objc public var authenticationUsers: [AuthenticationUser] = []

Array of already registered authentication identities.

signingUsers

@objc public var signingUsers: [SigningUser] = []

Array of already registered signing identities.

Methods

getInstance()

@objc public class func getInstance() -> MIRACLTrust

Getting singleton instance of the MIRACLTrust class.

  • Returns: singleton instance of the MIRACLTrust class.

configure(with:)

@objc public class func configure(with configuration: Configuration) throws

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.

Parameters

Name Description
configuration object storing configurations of the SDK.

sendVerificationEmail(userId:completionHandler:)

@objc public func sendVerificationEmail(
    userId: String,
    completionHandler: @escaping VerificationCompletionHandler
)

Sending email for user id verification.

  • Parameters:
  • userId: identifier of the user identity. To verify identity this identifier needs to be valid email address.
  • accessId: a session identifier used to get information from web 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:)

@objc public func getActivationToken(
    verificationURL: URL,
    completionHandler: @escaping ActivationTokenCompletionHandler
)

Method that confirms an identity, created using the default verification. Activation token is generated from universal link received by the application. This method must be called from Application or Scene delegate.

  • Parameters:
    • verificationURL: URL clicked in the email message and opened as a universal link.
    • completionHandler: a closure called when the verification has been confirmed. It can contain an optional ActivationToken, optional identifier of the user that is currently verified and an optional error object.

Parameters

Name Description
verificationURL URL clicked in the email message and opened as a universal link.
completionHandler a closure called when the verification has been confirmed. It can contain an optional ActivationToken, optional identifier of the user that is currently verified and an optional error object.

register(for:activationToken:pushNotificationsToken:didRequestPinHandler:completionHandler:)

@objc public func register(
    for userId: String,
    activationToken: ActivationToken,
    pushNotificationsToken: String? = nil,
    didRequestPinHandler: @escaping PinRequestHandler,
    completionHandler: @escaping RegistrationCompletionHandler
)

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.

Parameters

Name Description
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(authenticationUser:accessId:didRequestPinHandler:completionHandler:)

@objc public func authenticate(
    authenticationUser: AuthenticationUser,
    accessId: String,
    didRequestPinHandler: @escaping PinRequestHandler,
    completionHandler: @escaping AuthenticationCompletionHandler
)

Authenticates identity in the MIRACL platform

  • Parameters:
    • authenticationUser: object that keeps an identity in it.
    • accessId: a session identifier used to get information from web session.
    • 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.

Parameters

Name Description
authenticationUser object that keeps an identity in it.
accessId a session identifier used to get information from web session.
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.

generateAuthCode(authenticationUser:didRequestPinHandler:completionHandler:)

@objc public func generateAuthCode(
    authenticationUser: AuthenticationUser,
    didRequestPinHandler: @escaping PinRequestHandler,
    completionHandler: @escaping AuthCodeCompletionHandler
)

Generates authentication code against the MIRACL platform.

  • Parameters:
    • authenticationUser: object that keeps an 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.

Parameters

Name Description
authenticationUser object that keeps an 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.

generateOTP(authenticationUser:didRequestPinHandler:completionHandler:)

@objc public func generateOTP(
    authenticationUser: AuthenticationUser,
    didRequestPinHandler: @escaping PinRequestHandler,
    completionHandler: @escaping OTPCompletionHandler
)

Generate OTP against the MIRACL platform.

  • Parameters:
    • authenticationUser: an already registered 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.

Parameters

Name Description
authenticationUser an already registered 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(authenticationUser:didRequestPinHandler:completionHandler:)

@objc public func generateQuickCode(
    authenticationUser: AuthenticationUser,
    didRequestPinHandler: @escaping PinRequestHandler,
    completionHandler: @escaping QuickCodeCompletionHandler
)

Generate Quick Code against the MIRACL platform.

  • Parameters:
    • authenticationUser: an already registered 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 Quick Code has been generated. It can contain a generated OTP object or an optional error object.

Parameters

Name Description
authenticationUser an already registered 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 Quick Code has been generated. It can contain a generated OTP object or an optional error object.

signingRegister(authenticationUser:didRequestAuthenticationPinHandler:didRequestSigningPinHandler:completionHandler:)

@objc public func signingRegister(
    authenticationUser: AuthenticationUser,
    didRequestAuthenticationPinHandler: @escaping PinRequestHandler,
    didRequestSigningPinHandler: @escaping PinRequestHandler,
    completionHandler: @escaping SigningRegistrationCompletionHandler
)

Creates a new signing identity in the MIRACL platform.

  • Parameters:
    • authenticationUser: an already registered 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.

Parameters

Name Description
authenticationUser an already registered 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:signingUser:didRequestSigningPinHandler:completionHandler:)

@objc public func sign(
    message: Data,
    timestamp: Date,
    signingUser: SigningUser,
    didRequestSigningPinHandler: @escaping PinRequestHandler,
    completionHandler: @escaping SigningCompletionHandler
)

Create a cryptographic signature of a given document.

  • Parameters:
    • message: the hash of a given document.
    • timestamp: when the document has been signed.
    • signingUser: an already registered 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.

Parameters

Name Description
message the hash of a given document.
timestamp when the document has been signed.
signingUser an already registered 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.

delete(authenticationUser:)

@objc public func delete(authenticationUser: AuthenticationUser) -> Bool

Deletes a user object from the local storage.

  • Parameter authenticationUser: an object that keeps an identity in it.

Parameters

Name Description
authenticationUser an object that keeps an identity in it.

delete(signingUser:)

@objc public func delete(signingUser: SigningUser) -> Bool

Deletes a signing user object from the local storage.

  • Parameter signingUser: an object that keeps an identity in it.

Parameters

Name Description
signingUser an object that keeps an identity in it.