A Kotlin library for integrating Unforgettable account recovery into your Android applications.
Add JitPack repository and dependency to your build.gradle.kts:
repositories {
maven { url = uri("https://jitpack.io") }
}
dependencies {
implementation("com.github.rarimo.unforgettable-sdk:android:1.0.0")
}Add to your build.gradle:
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.github.rarimo.unforgettable-sdk:android:1.0.0'
}<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.rarimo.unforgettable-sdk</groupId>
<artifactId>android</artifactId>
<version>1.0.0</version>
</dependency>import com.rarimo.unforgettable.*
val sdk = UnforgettableSDK(
UnforgettableSdkOptions(
mode = UnforgettableMode.CREATE,
factors = listOf(RecoveryFactor.FACE, RecoveryFactor.IMAGE, RecoveryFactor.PASSWORD),
walletAddress = "0x1234567890abcdef",
group = "my-organization", // Optional
customParams = mapOf("theme" to "dark", "lang" to "en") // Optional
)
)
val recoveryUrl = sdk.getRecoveryUrl()
println("Recovery URL: $recoveryUrl")import com.rarimo.unforgettable.*
import kotlinx.coroutines.*
val sdk = UnforgettableSDK(
UnforgettableSdkOptions(
mode = UnforgettableMode.RESTORE,
factors = listOf(RecoveryFactor.FACE, RecoveryFactor.PASSWORD)
)
)
val recoveryUrl = sdk.getRecoveryUrl()
// After the user completes the recovery process...
lifecycleScope.launch {
try {
val recoveredData = sdk.getRecoveredData()
println("Recovery Key: ${recoveredData.recoveryKey}")
} catch (e: UnforgettableSDKError) {
println("Error during recovery: $e")
}
}enum class RecoveryFactor(val value: Int) {
FACE(1),
IMAGE(2),
PASSWORD(3),
GEOLOCATION(4)
}The main SDK class.
UnforgettableSDK(options: UnforgettableSdkOptions)Parameters:
options: Configuration options for the SDK
Generates the recovery URL to present to the user.
fun getRecoveryUrl(): StringReturns: The recovery URL as a string
Retrieves the recovered data from the API (suspending function).
suspend fun getRecoveredData(): RecoveredDataReturns: The recovered data including the recovery key
Throws: UnforgettableSDKError on failure
Retrieves only the recovered key (suspending function).
suspend fun getRecoveredKey(): StringReturns: The recovered key as a string
Throws: UnforgettableSDKError on failure
Configuration options for the SDK.
data class UnforgettableSdkOptions(
val mode: UnforgettableMode,
val appUrl: String = UNFORGETTABLE_APP_URL,
val apiUrl: String = UNFORGETTABLE_API_URL,
val factors: List<RecoveryFactor> = emptyList(),
val walletAddress: String? = null,
val group: String? = null,
val customParams: Map<String, String>? = null
)Parameters:
mode: EitherUnforgettableMode.CREATEorUnforgettableMode.RESTOREappUrl: The Unforgettable app URL (default:https://unforgettable.app)apiUrl: The Unforgettable API URL (default:https://api.unforgettable.app)factors: Optional list 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(cause: Throwable)InvalidResponseNotFoundDecodingError(cause: Throwable)CryptoError(cause: Throwable)
Errors related to URL hash parsing:
InvalidParametersInvalidFactorId(factorId: String)NonIntegerFactor(factor: String)
Add to your AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET" />- Android SDK 21+ (Android 5.0 Lollipop)
- Kotlin 1.9+
- Java 17+
If you use ProGuard, add these rules to your proguard-rules.pro:
# Keep SDK classes
-keep class com.rarimo.unforgettable.** { *; }
# Keep serialization classes
-keepclassmembers class com.rarimo.unforgettable.** {
@kotlinx.serialization.* <fields>;
}
MIT License - see LICENSE file for details