WalletUtils

public class WalletUtils

A utility class with functions for handling universal links or login requests for wallets.

  • Create the cryptographic signature for the document digest using the default registered credential.

    Declaration

    Swift

    public static func createDocumentSignature(digest: String) -> String

    Parameters

    digest

    The document’s digest.

    Return Value

    The base64-encoded signature, calculated using the default registered credential.

  • Assemble the URL components for the login request callback using the default registered credential.

    static func onReject() { if loginInfo != nil { let url = WalletUtils.buildLoginCallback(loginInfo: loginInfo, result: false) UIApplication.shared.openURL(url) } }

    Declaration

    Swift

    public static func buildLoginCallback(loginInfo: SignatureRequest, result: Bool) -> URL

    Parameters

    loginInfo

    The SignatureRequest object, as received from the notification or pending request.

    result

    Either true or false, signifying acceptance or denial, respectively.

    Return Value

    The final callback URL, with all required query parameters.

  • Assemble the URL components for the claim request callback using the default registered credential.

    Declaration

    Swift

    public static func buildClaimCallback(loginInfo: SignatureRequest, claims: [String]?, issuers: [String]?) -> URL

    Parameters

    loginInfo

    The SignatureRequest object, as received from the notification or pending request.

    claims

    An array with the Base64 encoded claims, or nil if the request was denied.

    issuer

    An array with the Base64 encoded claims of the claim issuer(s).

    Return Value

    The final callback URL, with all required query parameters.

  • Assemble the URL components for the claim request callback using the default registered credential and execute a HTTP request.

    Declaration

    Swift

    public static func invokeClaimCallback(loginInfo: SignatureRequest, claims: [String]?, issuers: [String]?, onSuccess: @escaping HttpUtils.SuccessCallback, onError: @escaping (String) -> Void)

    Parameters

    loginInfo

    The SignatureRequest object, as received from the notification or pending request.

    claims

    An array with the Base64 encoded claims, or nil if the request was denied.

    issuer

    An array with the Base64 encoded claims of the claim issuer(s).

    onSuccess

    Success callback, invoked on the main (UI) thread with the parsed JSON body.

    onError

    Failure callback, invoked on the main (UI) thread with error message.

  • Assemble the URL components for the login request callback using the default registered credential and execute a HTTP request.

    viewController.rejectCallback = { _ in
        WalletUtils.invokeLoginCallback(loginInfo: loginInfo, result: false, onSuccess: { _ in }, onError: {_ in })
        gotoNextViewController()
    }
    

    Declaration

    Swift

    public static func invokeLoginCallback(loginInfo: SignatureRequest, result: Bool, onSuccess: @escaping HttpUtils.SuccessCallback, onError: @escaping (String) -> Void)

    Parameters

    loginInfo

    The SignatureRequest object, as received from the notification or pending request.

    result

    Either true or false, signifying acceptance or denial, respectively.

    onSuccess

    Success callback, invoked on the main (UI) thread with the parsed JSON body.

    onError

    Failure callback, invoked on the main (UI) thread with error message.

  • Enum that specifies how to invoke the callback URL.

    See more

    Declaration

    Swift

    public enum CallbackType : String
  • A class with all fields related to a particular login request.

    See more

    Declaration

    Swift

    public class SignatureRequest
  • Parse the universal link for this login request.

    Declaration

    Swift

    public static func parseLoginUniversalLink(url: URL) -> SignatureRequest?

    Parameters

    url

    The universal link that was received by the wallet application.

    Return Value

    A new SignatureRequest object with all fields related to a particular login request, or nil if the link was not a suitable universal link.

  • Parse the notification payload for this login request.

    func application(_ application: UIApplication, didReceiveRemoteNotification userInfo:[AnyHashable: Any], fetchCompletionHandler:@escaping (UIBackgroundFetchResult) -> Void) { let loginInfo = WalletUtils.parseLoginNotification(userInfo: userInfo as NSDictionary) //… }

    Declaration

    Swift

    public static func parseLoginNotification(userInfo: NSDictionary) -> SignatureRequest?

    Parameters

    url

    The userInfo dictionary, as received from didReceiveRemoteNotification.

    Return Value

    A new SignatureRequest object with all fields related to a particular login request.

  • Parse a login request obtained from getPendingRequest API.

    Declaration

    Swift

    public static func parseLoginRequest(userInfo: NSDictionary) -> SignatureRequest?

    Parameters

    url

    The userInfo dictionary, as received from getPendingRequest API.

    Return Value

    A new SignatureRequest object with all fields related to a particular login request.