MIRACLTrust

CLASS

MIRACLTrust

@objc open class MIRACLTrust: NSObject, Loggable

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

Properties

users

@objc public var users: [User] = []

projectId

@objc public var projectId: String

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.

updateProjectSettings(projectId:clientId:redirectURI:)

@objc public func updateProjectSettings(
    projectId: String,
    clientId: String,
    redirectURI: String
) throws

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.

Parameters

Name Description
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.

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(user:didRequestPinHandler:completionHandler:)

public func authenticate(
    user: User,
    didRequestPinHandler: @escaping PinRequestHandler,
    completionHandler: @escaping AuthCodeCompletionHandler
)

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.

Parameters

Name Description
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:)

public func authenticateWithQRCode(
    user: User,
    qrCode: String,
    didRequestPinHandler: @escaping PinRequestHandler,
    completionHandler: @escaping AuthenticationCompletionHandler
)

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: string representation of QR code parsed from the image.
    • 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
user object that keeps an authentication identity in it.
qrCode string representation of QR code parsed from the image.
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:)

public func authenticateWithPushNotificationPayload(
    payload: [AnyHashable: Any],
    didRequestPinHandler: @escaping PinRequestHandler,
    completionHandler: @escaping AuthenticationCompletionHandler
)

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.

Parameters

Name Description
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:)

public func authenticateWithUniversalLinkURL(
    user: User,
    universalLinkURL: URL,
    didRequestPinHandler: @escaping PinRequestHandler,
    completionHandler: @escaping AuthenticationCompletionHandler
)

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.

Parameters

Name Description
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:)

@objc public func generateOTP(
    user: User,
    didRequestPinHandler: @escaping PinRequestHandler,
    completionHandler: @escaping OTPCompletionHandler
)

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.

Parameters

Name Description
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:)

@objc public func generateQuickCode(
    user: User,
    didRequestPinHandler: @escaping PinRequestHandler,
    completionHandler: @escaping QuickCodeCompletionHandler
)

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

Parameters

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

getSessionDetailsFromQRCode(qrCode:completionHandler:)

@objc public func getSessionDetailsFromQRCode(
    qrCode: String,
    completionHandler: @escaping SessionDetailsCompletionHandler
)

Get session details for project in 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: string representation of QR code parsed from the image.
    • completionHandler: a closure called when the session details are fetched.It can contain a newly fetched session details optional object and an optional error object.

Parameters

Name Description
qrCode string representation of QR code parsed from the image.
completionHandler a closure called when the session details are fetched.It can contain a newly fetched session details optional object and an optional error object.

getSessionDetailsFromUniversalLinkURL(universalLinkURL:completionHandler:)

@objc public func getSessionDetailsFromUniversalLinkURL(
    universalLinkURL: URL,
    completionHandler: @escaping SessionDetailsCompletionHandler
)

Get session details for project in 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 Universal Link URL.

  • Parameters:
    • universalLinkURL: universal link for authentication.
    • completionHandler: a closure called when the session details are fetched.It can contain a newly fetched session details optional object and an optional error object.

Parameters

Name Description
universalLinkURL universal link for authentication.
completionHandler a closure called when the session details are fetched.It can contain a newly fetched session details optional object and an optional error object.

getSessionDetailsFromPushNotificationPayload(pushNotificationPayload:completionHandler:)

@objc public func getSessionDetailsFromPushNotificationPayload(
    pushNotificationPayload: [AnyHashable: Any],
    completionHandler: @escaping SessionDetailsCompletionHandler
)

Get session details for project in 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 push notifications payload

  • Parameters:
    • pushNotificationPayload: payload dictionary received from push notification.
    • completionHandler: a closure called when the session details are fetched.It can contain a newly fetched session details optional object and an optional error object.

Parameters

Name Description
pushNotificationPayload payload dictionary received from push notification.
completionHandler a closure called when the session details are fetched.It can contain a newly fetched session details optional object and an optional error object.

abortSession(sessionDetails:completionHandler:)

@objc public func abortSession(
    sessionDetails: SessionsDetails,
    completionHandler: @escaping SessionAborterCompletionHandler
)

Cancel the authentication session by its SessionDetails object

  • Parameters:
    • sessionDetails: 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.

Parameters

Name Description
sessionDetails 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.

signingRegister(user:didRequestAuthenticationPinHandler:didRequestSigningPinHandler:completionHandler:)

@objc public func signingRegister(
    user: User,
    didRequestAuthenticationPinHandler: @escaping PinRequestHandler,
    didRequestSigningPinHandler: @escaping PinRequestHandler,
    completionHandler: @escaping SigningRegistrationCompletionHandler
)

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.

Parameters

Name Description
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:)

@objc public func sign(
    message: Data,
    timestamp: Date,
    user: User,
    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.
    • 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.

Parameters

Name Description
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:)

@objc public func getUser(by userId: String, projectId: String? = nil) -> User?

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.

Parameters

Name Description
userId id of the user. Can be email or any other string.
projectId project id taken from the portal.

delete(user:)

@objc public func delete(user: User) throws

Deletes a user from user storage with its signing and authentication identities.

  • Parameter user: object that needs to be deleted.

Parameters

Name Description
user object that needs to be deleted.