MIRACLTrust

CLASS

MIRACLTrust

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: [AuthenticationUser] = []

Array of already registered authentication identities.

signingUsers

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

Array of already registered signing identities.

Methods

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.

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

@objc public class func register(for userId: String,
                                 activationToken: ActivationToken,
                                 deviceName: String = UIDevice.current.modelName,
                                 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.
    • deviceName: a device identifier used to recognise device in the portal.
    • 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.
deviceName a device identifier used to recognise device in the portal.
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(for:accessId:didRequestPinHandler:completionHandler:)

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

Authenticates identity in the MIRACL platform

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

signingRegister(user:accessId:deviceName:didRequestAuthenticationPinHandler:didRequestSigningPinHandler:completionHandler:)

@objc public class func signingRegister(
    user: AuthenticationUser,
    accessId: String,
    deviceName: String = UIDevice.current.modelName,
    didRequestAuthenticationPinHandler: @escaping PinRequestHandler,
    didRequestSigningPinHandler: @escaping PinRequestHandler,
    completionHandler: @escaping SigningRegistrationCompletionHandler
)

Creates a new signing identity in the MIRACL platform.

  • Parameters:
    • user: an already registered identity.
    • accessId: a session identifier used to get information from web session.
    • deviceName: a device identifier used to recognise device in the portal.
    • 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 identity.
accessId a session identifier used to get information from web session.
deviceName a device identifier used to recognise device in the portal.
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 class 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.

verify(userId:deviceName:accessId:completionHandler:)

@objc public class func verify(
    userId: String,
    deviceName: String = UIDevice.current.modelName,
    accessId: String,
    completionHandler: @escaping VerificationCompletionHandler)

Default method to verify user identity against the MIRACL platform. In the current implementation it is done by sending an email message.

  • Parameters:
  • userId: identifier of the user identity. To verify identity this identifier needs to be valid email address.
  • deviceName: a device identifier used to recognise device in the portal.
  • 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(from:completionHandler:)

@objc public class func getActivationToken(
    from universalLinkURL: 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:
    • universalLinkURL: 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
universalLinkURL 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.

deleteUser(user:)

@objc public class func deleteUser(user: AuthenticationUser) -> Bool

Deletes a user object from the local storage.

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

Parameters

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

deleteSigningUser(signingUser:)

@objc public class func deleteSigningUser(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.