A Swift library for integrating Unforgettable account recovery into your iOS, macOS, tvOS, and watchOS applications.
Add the following to your Package.swift file:
dependencies: [
.package(url: "https://github.com/rarimo/unforgettable-sdk", from: "1.0.0")
]Or add it through Xcode:
- File → Add Package Dependencies
- Enter the repository URL
- Select the version you want to use
import UnforgettableSDK
do {
let sdk = try UnforgettableSDK(options: UnforgettableSdkOptions(
mode: .create,
factors: [.face, .image, .password],
walletAddress: "0x1234567890abcdef",
group: "my-organization", // Optional
customParams: ["theme": "dark", "lang": "en"] // Optional
))
let recoveryUrl = sdk.getRecoveryUrl()
print("Recovery URL: \(recoveryUrl)")
} catch {
print("Error initializing SDK: \(error)")
}import UnforgettableSDK
do {
let sdk = try UnforgettableSDK(options: UnforgettableSdkOptions(
mode: .restore,
factors: [.face, .image, .password],
))
let recoveryUrl = sdk.getRecoveryUrl()
// After the user completes the recovery process...
let recoveredData = try await sdk.getRecoveredData()
print("Recovery Key: \(recoveredData.recoveryKey)")
} catch {
print("Error during recovery: \(error)")
}public enum RecoveryFactor: Int {
case face = 1
case image = 2
case password = 3
case geolocation = 4
}The main SDK class.
init(options: UnforgettableSdkOptions) throwsParameters:
options: Configuration options for the SDK
Throws: CryptoError if key generation fails
Generates the recovery URL to present to the user.
func getRecoveryUrl() -> StringReturns: The recovery URL as a string
Retrieves the recovered data from the API.
func getRecoveredData() async throws -> RecoveredDataReturns: The recovered data including the recovery key
Throws: UnforgettableSDKError on failure
Retrieves only the recovered key.
func getRecoveredKey() async throws -> StringReturns: The recovered key as a string
Throws: UnforgettableSDKError on failure
Configuration options for the SDK.
public struct UnforgettableSdkOptions {
public let mode: UnforgettableMode
public let appUrl: String
public let apiUrl: String
public let factors: [RecoveryFactor]
public let walletAddress: String?
public let group: String?
public let customParams: [String: String]?
}Parameters:
mode: Either.createor.restoreappUrl: The Unforgettable app URL (default:https://unforgettable.app)apiUrl: The Unforgettable API URL (default:https://api.unforgettable.app)factors: Array of recovery factors to usewalletAddress: Optional wallet address to associate with the recoverygroup: Optional group identifier for organizing recovery keyscustomParams: Optional custom URL parameters to pass to the recovery app
Errors related to cryptographic operations:
keyGenerationFailedencryptionFaileddecryptionFailedinvalidPublicKeyencodingFaileddecodingFailed
Errors related to SDK operations:
networkError(Error)invalidResponsenotFounddecodingError(Error)cryptoError(Error)
- iOS 13.0+ / macOS 10.15+ / tvOS 13.0+ / watchOS 6.0+
- Swift 5.9+
- Xcode 15.0+
MIT License - see LICENSE file for details