diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 084c6e146..67c603768 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -20,6 +20,7 @@ coil = "2.6.0" compose-lint-checks = "1.3.1" coroutines = "1.8.1" datastore = "1.1.1" +fingerprint-js = "2.1.0" junit = "4.13.2" kotlin = "2.0.0" kotlin-immutable-collections = "0.3.7" @@ -90,6 +91,7 @@ compose-lint-checks = { module = "com.slack.lint.compose:compose-lint-checks", v coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" } coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" } datastore = { module = "androidx.datastore:datastore-preferences", version.ref = "datastore" } +fingerprint-js = { module = "com.github.fingerprintjs:fingerprint-android", version.ref = "fingerprint-js" } junit = { module = "junit:junit", version.ref = "junit" } kotlin-immutable-collections = { module = "org.jetbrains.kotlinx:kotlinx-collections-immutable", version.ref = "kotlin-immutable-collections" } leakcanary = { module = "com.squareup.leakcanary:leakcanary-android", version.ref = "leakcanary" } diff --git a/lib/lib.gradle.kts b/lib/lib.gradle.kts index 8045c9768..cdde2f818 100644 --- a/lib/lib.gradle.kts +++ b/lib/lib.gradle.kts @@ -221,6 +221,8 @@ dependencies { testImplementation(libs.mockk) androidTestImplementation(libs.mockk.android) + implementation(libs.fingerprint.js) + androidTestImplementation(libs.androidx.test.core) androidTestImplementation(libs.androidx.test.rules) androidTestImplementation(libs.androidx.test.junit) diff --git a/lib/src/main/java/com/smileidentity/SmileID.kt b/lib/src/main/java/com/smileidentity/SmileID.kt index 5c4c7e2cd..99867e506 100644 --- a/lib/src/main/java/com/smileidentity/SmileID.kt +++ b/lib/src/main/java/com/smileidentity/SmileID.kt @@ -3,6 +3,8 @@ package com.smileidentity import android.content.Context import android.content.Context.MODE_PRIVATE import android.content.pm.ApplicationInfo.FLAG_DEBUGGABLE +import com.fingerprintjs.android.fingerprint.Fingerprinter +import com.fingerprintjs.android.fingerprint.FingerprinterFactory import com.google.android.gms.common.moduleinstall.ModuleInstall import com.google.android.gms.common.moduleinstall.ModuleInstallRequest import com.google.mlkit.common.sdkinternal.MlKitContext @@ -85,6 +87,7 @@ object SmileID { internal var apiKey: String? = null internal lateinit var fileSavePath: String + internal lateinit var fingerprint: String /** * Initialize the SDK. This must be called before any other SDK methods. @@ -137,6 +140,10 @@ object SmileID { // Usually looks like: /data/user/0//app_SmileID fileSavePath = context.getDir("SmileID", MODE_PRIVATE).absolutePath + FingerprinterFactory.create(context).getFingerprint(version = Fingerprinter.Version.V_5) { + // Returns empty string if there was an error + fingerprint = it + } } /** diff --git a/lib/src/main/java/com/smileidentity/models/v2/Metadata.kt b/lib/src/main/java/com/smileidentity/models/v2/Metadata.kt index 118475207..7ce760aa1 100644 --- a/lib/src/main/java/com/smileidentity/models/v2/Metadata.kt +++ b/lib/src/main/java/com/smileidentity/models/v2/Metadata.kt @@ -2,6 +2,7 @@ package com.smileidentity.models.v2 import android.os.Parcelable import com.smileidentity.BuildConfig +import com.smileidentity.SmileID import com.squareup.moshi.Json import com.squareup.moshi.JsonClass import dev.zacsweers.moshix.sealed.annotations.TypeLabel @@ -14,7 +15,9 @@ import kotlinx.parcelize.Parcelize @Parcelize data class Metadata(val items: List) : Parcelable { companion object { - fun default(): Metadata = Metadata(listOf(Metadatum.Sdk, Metadatum.SdkVersion)) + fun default(): Metadata = Metadata( + listOf(Metadatum.Sdk, Metadatum.SdkVersion, Metadatum.Fingerprint), + ) } } @@ -34,6 +37,10 @@ sealed class Metadatum( @TypeLabel(label = "sdk_version") data object SdkVersion : Metadatum(BuildConfig.VERSION_NAME) + @Parcelize + @TypeLabel(label = "fingerprints") + data object Fingerprint : Metadatum(SmileID.fingerprint) + @Parcelize @TypeLabel(label = "document_front_image_origin") data class DocumentFrontImageOrigin(val origin: DocumentImageOriginValue) : diff --git a/settings.gradle.kts b/settings.gradle.kts index a2127bb39..26498b611 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -19,5 +19,8 @@ dependencyResolutionManagement { repositories { google() mavenCentral() + // TODO: Remove once https://github.com/fingerprintjs/fingerprintjs-android/issues/76 is + // resolved + maven("https://jitpack.io") } }