CredentialRegistryService

open class CredentialRegistryService

Utility class with wrappers for the various Credential Registry API endpoints.

  • The error that’s returned when the response from the server is invalid.

    Declaration

    Swift

    public static let errRevokeFailed = "The revoke operation failed."
  • The error that’s returned when we fail to register the recovery key.

    Declaration

    Swift

    public static let errRegisterKeyFailed = "Failed to register the new recovery key."
  • The error that’s returned when we fail to recover the root credential.

    Declaration

    Swift

    public static let errRecoverFailed = "Failed to recover the identity."
  • The error that’s returned when we fail to retrieve status for a transaction.

    Declaration

    Swift

    public static let errGetTransactionStatusFailed = "Failed to retrieve the status of the given transaction."
  • Undocumented

    Declaration

    Swift

    public let backendUrl : String
  • Initialize the validation API with the given backend URL.

    Declaration

    Swift

    public init(backendUrl : String)

    Parameters

    backendUrl

    The URL of the backend REST APIs.

  • Revoke our default credential by sending a request to the blockchain. The receiver must have been registered as a delegate in the smart contract. A challenge is signed by the default registered credential, which is verified by the smart contract.

    func revokeIdentity() { let ISSUER_ADDRESS = 0x1729cd37769f33d3c24e348d9766fbec309c4a01 credentialRegistryApi.revokeDefaultCredential(delegateAddress: ISSUER_ADDRESS, onSuccess: { _ in }, onError: { _ in }) }

    Declaration

    Swift

    open func revokeDefaultCredential(delegateAddress : String, onSuccess: @escaping (TransactionID) -> Void, onError: @escaping (String) -> Void)

    Parameters

    delegateAddress

    The hex-encoded blockchain address of the registered delegate credential.

    onSuccess

    Success callback, invoked on the main (UI) thread.

    onError

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

  • Revoke credentials using a given private key. This assumes that the revocation/recovery address has been previously registered with the backend/blockchain, otherwise this will fail.

    Declaration

    Swift

    open func revokeByRecoveryKey(recoveryKey: Data, onSuccess: @escaping (TransactionID) -> Void, onError: @escaping (String) -> Void)

    Parameters

    recoveryKey

    The private key data to sign the revocation.

    onSuccess

    Success callback, invoked on the main (UI) thread.

    onError

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

  • Initiates a credential recovery

    Declaration

    Swift

    open func recoverCredential(recoveryKey: Data, onSuccess: @escaping (TransactionID) -> Void, onError: @escaping (String) -> Void)

    Parameters

    recoveryKey

    A 32-byte data structure for the recovery key.

    onSuccess

    Success callback, invoked on the main (UI) thread.

    onError

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

  • Registers a recovery address with the backend.

    Declaration

    Swift

    open func registerRecoveryKey(recoveryKey: Data, onSuccess: @escaping (TransactionID) -> Void, onError: @escaping (String) -> Void)

    Parameters

    recoveryKey

    A 32-byte data structure for the recovery key used to sign recovery rights.

    onSuccess

    Success callback, invoked on the main (UI) thread.

    onError

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

  • Registers a recovery address with the backend for Wallet Sponsor Recovery flow.

    Declaration

    Swift

    open func registerWalletSponsorRecoveryKey(recoverySignature: Data, recoveryAddress: String, onSuccess: @escaping (TransactionID) -> Void, onError: @escaping (String) -> Void)

    Parameters

    recoverySignatureHex

    The recovery Signature

    recoveryAddress

    The address of the recovery key

    onSuccess

    Success callback, invoked on the main (UI) thread.

    onError

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

  • Initiates a Wallet Sponsor flow credential recovery

    Declaration

    Swift

    open func recoverWalletSponsorCredential(recoverySignature: Data, recoveryAddress: String, onSuccess: @escaping (TransactionID) -> Void, onError: @escaping (String) -> Void)

    Parameters

    recoverySignatureHex

    The recovery Signature

    recoveryAddress

    The recovery address

    onSuccess

    Success callback, invoked on the main (UI) thread.

    onError

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

  • Revoke the given claim.

    Declaration

    Swift

    open func revokeClaim(claim: Claim, onSuccess: @escaping (TransactionID) -> Void, onError: @escaping (String) -> Void)

    Parameters

    delegateAddress

    The hex-encoded blockchain address of the registered delegate credential.

    onSuccess

    Success callback, invoked on the main (UI) thread.

    onError

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

  • Retrieves the status of the given transaction.

    Declaration

    Swift

    open func getTransactionStatus(txID: TransactionID, onSuccess: @escaping (TransactionStatus) -> Void, onError: @escaping (String) -> Void)

    Parameters

    txID

    The transaction ID as returned by the other CredentialRegistryService APIs.

    onSuccess

    Success callback, invoked on the main (UI) thread.

    onError

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

  • Waits for the given transaction to complete, or fail.

    Declaration

    Swift

    open func waitForTransaction(txID: TransactionID, seconds: TimeInterval, completion: @escaping (TransactionStatus,String?) -> Void)

    Parameters

    txID

    The transaction ID as returned by the other CredentialRegistryService APIs.

    seconds

    The number of seconds to wait for completion (or failure)

    completion

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