Modern Apps git

← Modern-Apps.git

passwords: detekt clean (221 tests)

Commit
bab770bbed0be8ebe1c98a753403a027286e8d7c
Author
Vayun Mathur <[email protected]>
When
2026-11-15 00:00 UTC (21 days ago)
Parents
86aa619
Fix all detekt findings in passwords by fixing code, not config
(detekt.yml untouched, no baselines added):
- UndocumentedPublicClass: KDoc for 56 types.
- Passkey.equals: field comparisons are a list.all,
  same fields and order.
- TooManyFunctions: sync snapshots split into
  SnapshotStore (repo.snapshots); call sites updated.
- KdbxSyncEngine.sync: merged-file write-back extracted
  to writeMerged (also fixes ReturnCount/LongMethod).
- RelayPasswordProvider.delete dispatch extracted to
  deleteMatched.
Verified: ./gradlew :passwords:detekt :passwords:testDevUnitTest :passwords:lint
--max-workers=32 all pass (221 unit tests).

Diff

passwords/src/main/java/com/vayunmathur/passwords/MainActivity.kt
diff --git a/passwords/src/main/java/com/vayunmathur/passwords/MainActivity.kt b/passwords/src/main/java/com/vayunmathur/passwords/MainActivity.ktindex c21d14c18c..84524f00e8 100644--- a/passwords/src/main/java/com/vayunmathur/passwords/MainActivity.kt+++ b/passwords/src/main/java/com/vayunmathur/passwords/MainActivity.kt@@ -17,6 +17,7 @@ import com.vayunmathur.passwords.platform.PasswordsViewModelFactory import com.vayunmathur.passwords.sync.KdbxSyncScheduler import com.vayunmathur.passwords.sync.KdbxSyncSettings +/** Main Activity: a ma fragment activity implementation for main activity. */ class MainActivity : MaFragmentActivity() {     private val passwordsViewModel: PasswordsViewModel by viewModels {         PasswordsViewModelFactory(application, PasswordRepository.get(application))
passwords/src/main/java/com/vayunmathur/passwords/Route.kt
diff --git a/passwords/src/main/java/com/vayunmathur/passwords/Route.kt b/passwords/src/main/java/com/vayunmathur/passwords/Route.ktindex 298636f7e5..8d78deba3e 100644--- a/passwords/src/main/java/com/vayunmathur/passwords/Route.kt+++ b/passwords/src/main/java/com/vayunmathur/passwords/Route.kt@@ -3,20 +3,26 @@ package com.vayunmathur.passwords import com.vayunmathur.library.util.NavKey import kotlinx.serialization.Serializable +/** Contract for route. */ @Serializable sealed interface Route : NavKey {+    /** Singleton holding menu state and operations. */     @Serializable     data object Menu : Route +    /** Immutable value describing password page; carries id. */     @Serializable     data class PasswordPage(val id: Long) : Route +    /** Immutable value describing password edit page; carries id. */     @Serializable     data class PasswordEditPage(val id: Long) : Route +    /** Immutable value describing passkey page; carries id. */     @Serializable     data class PasskeyPage(val id: Long) : Route +    /** Singleton holding settings state and operations. */     @Serializable     data object Settings : Route }
passwords/src/main/java/com/vayunmathur/passwords/data/Converters.kt
diff --git a/passwords/src/main/java/com/vayunmathur/passwords/data/Converters.kt b/passwords/src/main/java/com/vayunmathur/passwords/data/Converters.ktindex 3c726e8a08..17b54d9cd1 100644--- a/passwords/src/main/java/com/vayunmathur/passwords/data/Converters.kt+++ b/passwords/src/main/java/com/vayunmathur/passwords/data/Converters.kt@@ -2,6 +2,7 @@ package com.vayunmathur.passwords.data  import androidx.room3.ColumnTypeConverter +/** Singleton holding converters state and operations. */ object Converters {     private const val DELIM = "|||" 
passwords/src/main/java/com/vayunmathur/passwords/data/Passkey.kt
diff --git a/passwords/src/main/java/com/vayunmathur/passwords/data/Passkey.kt b/passwords/src/main/java/com/vayunmathur/passwords/data/Passkey.ktindex 8f2f75f8f4..3b19465836 100644--- a/passwords/src/main/java/com/vayunmathur/passwords/data/Passkey.kt+++ b/passwords/src/main/java/com/vayunmathur/passwords/data/Passkey.kt@@ -10,6 +10,7 @@ import com.vayunmathur.library.util.DatabaseItem  */ const val PASSKEY_LINK_DETACHED = "-" +/** Immutable value describing passkey. */ @Entity data class Passkey(     @PrimaryKey(autoGenerate = true) override val id: Long = 0,@@ -44,20 +45,22 @@ data class Passkey(     override fun equals(other: Any?): Boolean {         if (this === other) return true         if (other !is Passkey) return false-        return id == other.id &&-            rpId == other.rpId &&-            rpName == other.rpName &&-            credentialId == other.credentialId &&-            userId == other.userId &&-            userName == other.userName &&-            userDisplayName == other.userDisplayName &&-            privateKeyBytes.contentEquals(other.privateKeyBytes) &&-            creationTime == other.creationTime &&-            lastUsedTime == other.lastUsedTime &&-            signCount == other.signCount &&-            linkedPasswordSyncId == other.linkedPasswordSyncId &&-            syncId == other.syncId &&-            updatedAt == other.updatedAt+        return listOf(+            id == other.id,+            rpId == other.rpId,+            rpName == other.rpName,+            credentialId == other.credentialId,+            userId == other.userId,+            userName == other.userName,+            userDisplayName == other.userDisplayName,+            privateKeyBytes.contentEquals(other.privateKeyBytes),+            creationTime == other.creationTime,+            lastUsedTime == other.lastUsedTime,+            signCount == other.signCount,+            linkedPasswordSyncId == other.linkedPasswordSyncId,+            syncId == other.syncId,+            updatedAt == other.updatedAt,+        ).all { it }     }      override fun hashCode(): Int {
passwords/src/main/java/com/vayunmathur/passwords/data/Password.kt
diff --git a/passwords/src/main/java/com/vayunmathur/passwords/data/Password.kt b/passwords/src/main/java/com/vayunmathur/passwords/data/Password.ktindex 7dc0ac03e2..72d7f4259b 100644--- a/passwords/src/main/java/com/vayunmathur/passwords/data/Password.kt+++ b/passwords/src/main/java/com/vayunmathur/passwords/data/Password.kt@@ -4,6 +4,7 @@ import androidx.room3.PrimaryKey import com.vayunmathur.library.util.DatabaseItem import kotlinx.serialization.Serializable +/** Immutable value describing password. */ @Serializable @Entity data class Password(
passwords/src/main/java/com/vayunmathur/passwords/data/PasswordDatabase.kt
diff --git a/passwords/src/main/java/com/vayunmathur/passwords/data/PasswordDatabase.kt b/passwords/src/main/java/com/vayunmathur/passwords/data/PasswordDatabase.ktindex 2aad1a330e..044c4b7b94 100644--- a/passwords/src/main/java/com/vayunmathur/passwords/data/PasswordDatabase.kt+++ b/passwords/src/main/java/com/vayunmathur/passwords/data/PasswordDatabase.kt@@ -12,6 +12,7 @@ import androidx.sqlite.execSQL import com.vayunmathur.library.util.DatabaseMigrations import kotlinx.coroutines.flow.Flow +/** Type representing password dao. */ @Dao abstract class PasswordDao {     @Query("SELECT * FROM Password")@@ -49,6 +50,7 @@ abstract class PasswordDao {         upsertRaw(value.copy(updatedAt = System.currentTimeMillis())) } +/** Type representing passkey dao. */ @Dao abstract class PasskeyDao {     @Query("SELECT * FROM Passkey")@@ -91,12 +93,14 @@ abstract class PasskeyDao {     version = 5,     exportSchema = false, )+/** Password Database: a room database implementation for password database. */ @ColumnTypeConverters(Converters::class) abstract class PasswordDatabase : RoomDatabase() {     abstract fun passwordDao(): PasswordDao     abstract fun passkeyDao(): PasskeyDao     abstract fun syncSnapshotDao(): SyncSnapshotDao +    /** Shared constants and helpers for PasswordDatabase. */     companion object : DatabaseMigrations {         override val migrations = listOf(             Migration(1, 2) {
passwords/src/main/java/com/vayunmathur/passwords/data/PasswordRepository.kt
diff --git a/passwords/src/main/java/com/vayunmathur/passwords/data/PasswordRepository.kt b/passwords/src/main/java/com/vayunmathur/passwords/data/PasswordRepository.ktindex bbe15e5c33..b8e2cb4416 100644--- a/passwords/src/main/java/com/vayunmathur/passwords/data/PasswordRepository.kt+++ b/passwords/src/main/java/com/vayunmathur/passwords/data/PasswordRepository.kt@@ -79,11 +79,8 @@ class PasswordRepository private constructor(context: Context) :     // SyncSnapshot reads / writes     // ------------------------------------------------------------------ -    suspend fun getAllSnapshots(): List<SyncSnapshot> = syncSnapshotDao.getAll()-    suspend fun upsertSnapshot(snapshot: SyncSnapshot) = syncSnapshotDao.upsert(snapshot)-    suspend fun deleteSnapshotBySyncId(syncId: String) = syncSnapshotDao.deleteBySyncId(syncId)-    suspend fun deleteAllSnapshots() = syncSnapshotDao.deleteAll()-    suspend fun deleteSnapshotsByKind(kind: String) = syncSnapshotDao.deleteByKind(kind)+    /** Sync-snapshot persistence, split out of the credential store. */+    val snapshots: SnapshotStore by lazy { SnapshotStore(syncSnapshotDao) }      // ------------------------------------------------------------------     // Transaction@@ -91,6 +88,7 @@ class PasswordRepository private constructor(context: Context) :      suspend fun <R> withTransaction(block: suspend () -> R): R = db.withWriteTransaction { block() } +    /** Shared constants and helpers for PasswordRepository. */     companion object {         @Volatile         private var instance: PasswordRepository? = null@@ -101,3 +99,21 @@ class PasswordRepository private constructor(context: Context) :             }     } }++/** Persistence for sync snapshots (the relay merge baseline). */+class SnapshotStore(private val dao: SyncSnapshotDao) {+    /** All snapshots, across kinds. */+    suspend fun getAll(): List<SyncSnapshot> = dao.getAll()++    /** Inserts or replaces one snapshot. */+    suspend fun upsert(snapshot: SyncSnapshot) = dao.upsert(snapshot)++    /** Deletes the snapshot for [syncId], if any. */+    suspend fun deleteBySyncId(syncId: String) = dao.deleteBySyncId(syncId)++    /** Deletes every snapshot. */+    suspend fun deleteAll() = dao.deleteAll()++    /** Deletes every snapshot of [kind]. */+    suspend fun deleteByKind(kind: String) = dao.deleteByKind(kind)+}
passwords/src/main/java/com/vayunmathur/passwords/data/SyncSnapshot.kt
diff --git a/passwords/src/main/java/com/vayunmathur/passwords/data/SyncSnapshot.kt b/passwords/src/main/java/com/vayunmathur/passwords/data/SyncSnapshot.ktindex b6ca0a8525..21dca60289 100644--- a/passwords/src/main/java/com/vayunmathur/passwords/data/SyncSnapshot.kt+++ b/passwords/src/main/java/com/vayunmathur/passwords/data/SyncSnapshot.kt@@ -22,6 +22,7 @@ data class SyncSnapshot(     val remoteModified: Long,     val lastSyncedAt: Long, ) {+    /** Shared constants and helpers for SyncSnapshot. */     companion object {         const val KIND_PASSWORD = "password"         const val KIND_PASSKEY = "passkey"
passwords/src/main/java/com/vayunmathur/passwords/data/SyncSnapshotDao.kt
diff --git a/passwords/src/main/java/com/vayunmathur/passwords/data/SyncSnapshotDao.kt b/passwords/src/main/java/com/vayunmathur/passwords/data/SyncSnapshotDao.ktindex 13de884631..7cc71f64ce 100644--- a/passwords/src/main/java/com/vayunmathur/passwords/data/SyncSnapshotDao.kt+++ b/passwords/src/main/java/com/vayunmathur/passwords/data/SyncSnapshotDao.kt@@ -4,6 +4,7 @@ import androidx.room3.Dao import androidx.room3.Query import androidx.room3.Upsert +/** Contract for sync snapshot dao. */ @Dao interface SyncSnapshotDao {     @Query("SELECT * FROM SyncSnapshot")
passwords/src/main/java/com/vayunmathur/passwords/domain/Cbor.kt
diff --git a/passwords/src/main/java/com/vayunmathur/passwords/domain/Cbor.kt b/passwords/src/main/java/com/vayunmathur/passwords/domain/Cbor.ktindex 70ca46917c..756bbd9c43 100644--- a/passwords/src/main/java/com/vayunmathur/passwords/domain/Cbor.kt+++ b/passwords/src/main/java/com/vayunmathur/passwords/domain/Cbor.kt@@ -1,5 +1,6 @@ package com.vayunmathur.passwords.domain +/** Singleton holding cbor state and operations. */ object Cbor {     private const val TYPE_UNSIGNED_INT = 0x00     private const val TYPE_NEGATIVE_INT = 0x01
passwords/src/main/java/com/vayunmathur/passwords/domain/ImportSource.kt
diff --git a/passwords/src/main/java/com/vayunmathur/passwords/domain/ImportSource.kt b/passwords/src/main/java/com/vayunmathur/passwords/domain/ImportSource.ktindex 21e29cbac3..0827d913c9 100644--- a/passwords/src/main/java/com/vayunmathur/passwords/domain/ImportSource.kt+++ b/passwords/src/main/java/com/vayunmathur/passwords/domain/ImportSource.kt@@ -3,6 +3,7 @@ package com.vayunmathur.passwords.domain import androidx.annotation.StringRes import com.vayunmathur.passwords.R +/** Kinds of import source. */ enum class ImportSource(     @StringRes val label: Int,     val nameHeaders: Array<String>,
passwords/src/main/java/com/vayunmathur/passwords/domain/PasskeyLink.kt
diff --git a/passwords/src/main/java/com/vayunmathur/passwords/domain/PasskeyLink.kt b/passwords/src/main/java/com/vayunmathur/passwords/domain/PasskeyLink.ktindex d85fe2ce89..8bd94825ca 100644--- a/passwords/src/main/java/com/vayunmathur/passwords/domain/PasskeyLink.kt+++ b/passwords/src/main/java/com/vayunmathur/passwords/domain/PasskeyLink.kt@@ -20,6 +20,7 @@ sealed interface PasskeyLink {     /** Pinned to the password with this syncId, regardless of domain or username. */     data class To(val passwordSyncId: String) : PasskeyLink +    /** Shared constants and helpers for PasskeyLink. */     companion object {         fun fromColumn(raw: String?): PasskeyLink = when {             raw.isNullOrBlank() -> Auto
passwords/src/main/java/com/vayunmathur/passwords/domain/TOTP.kt
diff --git a/passwords/src/main/java/com/vayunmathur/passwords/domain/TOTP.kt b/passwords/src/main/java/com/vayunmathur/passwords/domain/TOTP.ktindex b907f1c486..e2232b7974 100644--- a/passwords/src/main/java/com/vayunmathur/passwords/domain/TOTP.kt+++ b/passwords/src/main/java/com/vayunmathur/passwords/domain/TOTP.kt@@ -3,6 +3,7 @@ import java.nio.ByteBuffer import javax.crypto.Mac import javax.crypto.spec.SecretKeySpec +/** Singleton holding totp state and operations. */ object TOTP {     private const val BASE32_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567" 
passwords/src/main/java/com/vayunmathur/passwords/platform/AppBackupAgent.kt
diff --git a/passwords/src/main/java/com/vayunmathur/passwords/platform/AppBackupAgent.kt b/passwords/src/main/java/com/vayunmathur/passwords/platform/AppBackupAgent.ktindex afd45ec5d4..88c646e161 100644--- a/passwords/src/main/java/com/vayunmathur/passwords/platform/AppBackupAgent.kt+++ b/passwords/src/main/java/com/vayunmathur/passwords/platform/AppBackupAgent.kt@@ -5,6 +5,7 @@ import com.vayunmathur.library.util.BaseBackupAgent import com.vayunmathur.library.util.DatabaseHelper import java.io.File +/** App Backup Agent: a base backup agent implementation for app backup agent. */ class AppBackupAgent : BaseBackupAgent() {     override val dbCodec = SqlCipherDbCodec 
passwords/src/main/java/com/vayunmathur/passwords/platform/PasskeyCredentialService.kt
diff --git a/passwords/src/main/java/com/vayunmathur/passwords/platform/PasskeyCredentialService.kt b/passwords/src/main/java/com/vayunmathur/passwords/platform/PasskeyCredentialService.ktindex d658d9c8fe..895b56c6e9 100644--- a/passwords/src/main/java/com/vayunmathur/passwords/platform/PasskeyCredentialService.kt+++ b/passwords/src/main/java/com/vayunmathur/passwords/platform/PasskeyCredentialService.kt@@ -27,6 +27,7 @@ import com.vayunmathur.passwords.data.PasswordRepository import com.vayunmathur.passwords.ui.PasskeyAuthActivity import kotlinx.coroutines.runBlocking +/** Passkey Credential Service: a credential provider service implementation for passkey credential service. */ class PasskeyCredentialService : CredentialProviderService() {      private val repository by lazy { PasswordRepository.get(applicationContext) }@@ -119,6 +120,7 @@ class PasskeyCredentialService : CredentialProviderService() {         callback.onResult(null)     } +    /** Shared constants and helpers for PasskeyCredentialService. */     companion object {         private const val TAG = "PasskeyCredService"         private const val REQUEST_CODE_UNLOCK = 999999
passwords/src/main/java/com/vayunmathur/passwords/platform/PasskeyUtils.kt
diff --git a/passwords/src/main/java/com/vayunmathur/passwords/platform/PasskeyUtils.kt b/passwords/src/main/java/com/vayunmathur/passwords/platform/PasskeyUtils.ktindex b162307c41..f67b0a7c56 100644--- a/passwords/src/main/java/com/vayunmathur/passwords/platform/PasskeyUtils.kt+++ b/passwords/src/main/java/com/vayunmathur/passwords/platform/PasskeyUtils.kt@@ -8,6 +8,7 @@ import java.security.SecureRandom import kotlin.io.encoding.Base64 import kotlin.io.encoding.ExperimentalEncodingApi +/** Singleton holding passkey utils state and operations. */ @OptIn(ExperimentalEncodingApi::class) object PasskeyUtils { 
passwords/src/main/java/com/vayunmathur/passwords/platform/PasswordAutofillService.kt
diff --git a/passwords/src/main/java/com/vayunmathur/passwords/platform/PasswordAutofillService.kt b/passwords/src/main/java/com/vayunmathur/passwords/platform/PasswordAutofillService.ktindex b7ebb0329a..817ba29c89 100644--- a/passwords/src/main/java/com/vayunmathur/passwords/platform/PasswordAutofillService.kt+++ b/passwords/src/main/java/com/vayunmathur/passwords/platform/PasswordAutofillService.kt@@ -31,6 +31,7 @@ import kotlinx.coroutines.runBlocking import com.vayunmathur.library.log.Log import com.vayunmathur.passwords.data.Password +/** Password Autofill Service: a autofill service implementation for password autofill service. */ class PasswordAutofillService : AutofillService() {      private val tag = "AutofillService"
passwords/src/main/java/com/vayunmathur/passwords/platform/PasswordsUiContract.kt
diff --git a/passwords/src/main/java/com/vayunmathur/passwords/platform/PasswordsUiContract.kt b/passwords/src/main/java/com/vayunmathur/passwords/platform/PasswordsUiContract.ktindex 578cfb06ce..72e914884a 100644--- a/passwords/src/main/java/com/vayunmathur/passwords/platform/PasswordsUiContract.kt+++ b/passwords/src/main/java/com/vayunmathur/passwords/platform/PasswordsUiContract.kt@@ -81,6 +81,7 @@ interface PasswordsActions {      fun saveDraft(onSaved: ((Long) -> Unit)? = null) {} +    /** Shared constants and helpers for PasswordsActions. */     companion object {         val Noop: PasswordsActions = object : PasswordsActions {}     }
passwords/src/main/java/com/vayunmathur/passwords/platform/cable/CableActivity.kt
diff --git a/passwords/src/main/java/com/vayunmathur/passwords/platform/cable/CableActivity.kt b/passwords/src/main/java/com/vayunmathur/passwords/platform/cable/CableActivity.ktindex 28e721100d..1f34c9a3ea 100644--- a/passwords/src/main/java/com/vayunmathur/passwords/platform/cable/CableActivity.kt+++ b/passwords/src/main/java/com/vayunmathur/passwords/platform/cable/CableActivity.kt@@ -137,6 +137,7 @@ class CableActivity : FragmentActivity() {         finish()     } +    /** Shared constants and helpers for CableActivity. */     companion object {         private const val TAG = "CableActivity"     }
passwords/src/main/java/com/vayunmathur/passwords/platform/cable/CableAdvertiser.kt
diff --git a/passwords/src/main/java/com/vayunmathur/passwords/platform/cable/CableAdvertiser.kt b/passwords/src/main/java/com/vayunmathur/passwords/platform/cable/CableAdvertiser.ktindex a72fb5edb8..a8161301df 100644--- a/passwords/src/main/java/com/vayunmathur/passwords/platform/cable/CableAdvertiser.kt+++ b/passwords/src/main/java/com/vayunmathur/passwords/platform/cable/CableAdvertiser.kt@@ -75,6 +75,7 @@ class CableAdvertiser(context: Context) {         callback = null     } +    /** Shared constants and helpers for CableAdvertiser. */     companion object {         private const val TAG = "CableAdvertiser"         private const val UUID_MASK_16 = 0xFFFF
passwords/src/main/java/com/vayunmathur/passwords/platform/cable/CableQr.kt
diff --git a/passwords/src/main/java/com/vayunmathur/passwords/platform/cable/CableQr.kt b/passwords/src/main/java/com/vayunmathur/passwords/platform/cable/CableQr.ktindex 081659d404..9c729db106 100644--- a/passwords/src/main/java/com/vayunmathur/passwords/platform/cable/CableQr.kt+++ b/passwords/src/main/java/com/vayunmathur/passwords/platform/cable/CableQr.kt@@ -25,6 +25,7 @@ data class CableQrData(     val supportsLinking: Boolean?,     val requestTypeHint: String?, ) {+    /** Shared constants and helpers for CableQrData. */     companion object {         const val URI_PREFIX = "FIDO:/"         const val PEER_KEY_SIZE = 33
passwords/src/main/java/com/vayunmathur/passwords/platform/cable/CableService.kt
diff --git a/passwords/src/main/java/com/vayunmathur/passwords/platform/cable/CableService.kt b/passwords/src/main/java/com/vayunmathur/passwords/platform/cable/CableService.ktindex 984bdedfc8..0f9d873113 100644--- a/passwords/src/main/java/com/vayunmathur/passwords/platform/cable/CableService.kt+++ b/passwords/src/main/java/com/vayunmathur/passwords/platform/cable/CableService.kt@@ -91,6 +91,7 @@ class CableService : Service() {         super.onDestroy()     } +    /** Shared constants and helpers for CableService. */     companion object {         const val EXTRA_FIDO_URI = "fido_uri"         const val EXTRA_USER_VERIFIED = "user_verified"
passwords/src/main/java/com/vayunmathur/passwords/platform/cable/CableSession.kt
diff --git a/passwords/src/main/java/com/vayunmathur/passwords/platform/cable/CableSession.kt b/passwords/src/main/java/com/vayunmathur/passwords/platform/cable/CableSession.ktindex 9b56fefe89..8bf29a0f45 100644--- a/passwords/src/main/java/com/vayunmathur/passwords/platform/cable/CableSession.kt+++ b/passwords/src/main/java/com/vayunmathur/passwords/platform/cable/CableSession.kt@@ -129,6 +129,7 @@ class CableSession(         }     } +    /** Shared constants and helpers for CableSession. */     companion object {         private const val TAG = "CableSession"         private const val BYTE_MASK = 0xFF
passwords/src/main/java/com/vayunmathur/passwords/platform/cable/CableTunnel.kt
diff --git a/passwords/src/main/java/com/vayunmathur/passwords/platform/cable/CableTunnel.kt b/passwords/src/main/java/com/vayunmathur/passwords/platform/cable/CableTunnel.ktindex 9c000e2a2c..0b8043d1e5 100644--- a/passwords/src/main/java/com/vayunmathur/passwords/platform/cable/CableTunnel.kt+++ b/passwords/src/main/java/com/vayunmathur/passwords/platform/cable/CableTunnel.kt@@ -43,6 +43,7 @@ class CableTunnel private constructor(         }     } +    /** Shared constants and helpers for CableTunnel. */     companion object {         const val SUBPROTOCOL = "fido.cable"         const val ROUTING_ID_HEADER = "X-caBLE-Routing-ID"
passwords/src/main/java/com/vayunmathur/passwords/platform/cable/CborReader.kt
diff --git a/passwords/src/main/java/com/vayunmathur/passwords/platform/cable/CborReader.kt b/passwords/src/main/java/com/vayunmathur/passwords/platform/cable/CborReader.ktindex 0109a7a945..415e2c5feb 100644--- a/passwords/src/main/java/com/vayunmathur/passwords/platform/cable/CborReader.kt+++ b/passwords/src/main/java/com/vayunmathur/passwords/platform/cable/CborReader.kt@@ -104,6 +104,7 @@ class CborReader(private val bytes: ByteArray, private var pos: Int = 0) {         return toInt()     } +    /** Shared constants and helpers for CborReader. */     companion object {         private const val MAJOR_UNSIGNED = 0         private const val MAJOR_NEGATIVE = 1
passwords/src/main/java/com/vayunmathur/passwords/platform/cable/Crypter.kt
diff --git a/passwords/src/main/java/com/vayunmathur/passwords/platform/cable/Crypter.kt b/passwords/src/main/java/com/vayunmathur/passwords/platform/cable/Crypter.ktindex 5506848550..0832ee1210 100644--- a/passwords/src/main/java/com/vayunmathur/passwords/platform/cable/Crypter.kt+++ b/passwords/src/main/java/com/vayunmathur/passwords/platform/cable/Crypter.kt@@ -37,6 +37,7 @@ class Crypter(private val readKey: ByteArray, private val writeKey: ByteArray) {             init(mode, SecretKeySpec(key, "AES"), GCMParameterSpec(GCM_TAG_BITS, nonce))         } +    /** Shared constants and helpers for Crypter. */     companion object {         private const val PADDING_GRANULARITY = 32         private const val NONCE_BYTES = 12
passwords/src/main/java/com/vayunmathur/passwords/platform/cable/Ctap.kt
diff --git a/passwords/src/main/java/com/vayunmathur/passwords/platform/cable/Ctap.kt b/passwords/src/main/java/com/vayunmathur/passwords/platform/cable/Ctap.ktindex 0394c3d9df..05b1fe72d2 100644--- a/passwords/src/main/java/com/vayunmathur/passwords/platform/cable/Ctap.kt+++ b/passwords/src/main/java/com/vayunmathur/passwords/platform/cable/Ctap.kt@@ -81,6 +81,7 @@ data class CtapGetAssertionRequest(     /** Effective user-verification requirement (defaults to false per CTAP2). */     val userVerificationRequired: Boolean get() = options["uv"] ?: false +    /** Shared constants and helpers for CtapGetAssertionRequest. */     companion object {         /** Parses the CBOR payload (the bytes after the 0x02 command byte). */         fun parse(payload: ByteArray): CtapGetAssertionRequest {@@ -184,6 +185,7 @@ data class CtapMakeCredentialRequest(      val supportsEs256: Boolean get() = algorithms.contains(Ctap.ALG_ES256) +    /** Shared constants and helpers for CtapMakeCredentialRequest. */     companion object {         /** Parses the CBOR payload (the bytes after the 0x01 command byte). */         fun parse(payload: ByteArray): CtapMakeCredentialRequest {
passwords/src/main/java/com/vayunmathur/passwords/platform/cable/CtapProcessor.kt
diff --git a/passwords/src/main/java/com/vayunmathur/passwords/platform/cable/CtapProcessor.kt b/passwords/src/main/java/com/vayunmathur/passwords/platform/cable/CtapProcessor.ktindex cb54718435..9f3f818bf7 100644--- a/passwords/src/main/java/com/vayunmathur/passwords/platform/cable/CtapProcessor.kt+++ b/passwords/src/main/java/com/vayunmathur/passwords/platform/cable/CtapProcessor.kt@@ -150,6 +150,7 @@ class CtapProcessor(     private fun decodeUserId(userId: String): ByteArray =         runCatching { urlDecoder.decode(userId) }.getOrElse { userId.toByteArray() } +    /** Shared constants and helpers for CtapProcessor. */     companion object {         private const val TAG = "CtapProcessor"         private const val BYTE_MASK = 0xFF
passwords/src/main/java/com/vayunmathur/passwords/platform/cable/Noise.kt
diff --git a/passwords/src/main/java/com/vayunmathur/passwords/platform/cable/Noise.kt b/passwords/src/main/java/com/vayunmathur/passwords/platform/cable/Noise.ktindex 7ff94bfb45..b54a4deed2 100644--- a/passwords/src/main/java/com/vayunmathur/passwords/platform/cable/Noise.kt+++ b/passwords/src/main/java/com/vayunmathur/passwords/platform/cable/Noise.kt@@ -148,6 +148,7 @@ class NoiseResponder(         }     } +    /** Shared constants and helpers for NoiseResponder. */     companion object {         const val PROTOCOL_NAME = "Noise_KNpsk0_P256_AESGCM_SHA256"         private const val PSK_BYTES = 32
passwords/src/main/java/com/vayunmathur/passwords/sync/KdbxSyncEngine.kt
diff --git a/passwords/src/main/java/com/vayunmathur/passwords/sync/KdbxSyncEngine.kt b/passwords/src/main/java/com/vayunmathur/passwords/sync/KdbxSyncEngine.ktindex 8c894ade89..17220e83ad 100644--- a/passwords/src/main/java/com/vayunmathur/passwords/sync/KdbxSyncEngine.kt+++ b/passwords/src/main/java/com/vayunmathur/passwords/sync/KdbxSyncEngine.kt@@ -22,7 +22,9 @@ import java.io.File import java.io.FileNotFoundException import java.io.IOException +/** Contract for kdbx sync result. */ sealed interface KdbxSyncResult {+    /** Immutable value describing success. */     data class Success(         val pushed: Int,         val pulled: Int,@@ -30,9 +32,13 @@ sealed interface KdbxSyncResult {         val deletedRemote: Int,     ) : KdbxSyncResult +    /** Singleton holding not configured state and operations. */     data object NotConfigured : KdbxSyncResult+    /** Singleton holding file missing state and operations. */     data object FileMissing : KdbxSyncResult+    /** Singleton holding wrong password state and operations. */     data object WrongPassword : KdbxSyncResult+    /** Singleton holding verify failed state and operations. */     data object VerifyFailed : KdbxSyncResult     /**      * Ambiguous foreign absence: baseline entries are missing from the file@@ -42,6 +48,7 @@ sealed interface KdbxSyncResult {      * baseline ids, for display only โ€” never logged with content.      */     data class Quarantined(val count: Int) : KdbxSyncResult+    /** Immutable value describing error; carries message. */     data class Error(val message: String) : KdbxSyncResult } @@ -129,11 +136,11 @@ class KdbxSyncEngine(             override suspend fun deleteAll() = repository.deleteAllPasskeys()         },         snapshotDao = object : SyncSnapshotDao {-            override suspend fun getAll(): List<SyncSnapshot> = repository.getAllSnapshots()-            override suspend fun upsert(snapshot: SyncSnapshot) = repository.upsertSnapshot(snapshot)-            override suspend fun deleteBySyncId(syncId: String) = repository.deleteSnapshotBySyncId(syncId)-            override suspend fun deleteByKind(kind: String) = repository.deleteSnapshotsByKind(kind)-            override suspend fun deleteAll() = repository.deleteAllSnapshots()+            override suspend fun getAll(): List<SyncSnapshot> = repository.snapshots.getAll()+            override suspend fun upsert(snapshot: SyncSnapshot) = repository.snapshots.upsert(snapshot)+            override suspend fun deleteBySyncId(syncId: String) = repository.snapshots.deleteBySyncId(syncId)+            override suspend fun deleteByKind(kind: String) = repository.snapshots.deleteByKind(kind)+            override suspend fun deleteAll() = repository.snapshots.deleteAll()         },         codec = codec,         inTransaction = { repository.withTransaction(it) },@@ -165,24 +172,36 @@ class KdbxSyncEngine(         override suspend fun delete(e: Passkey) { passkeyDao.delete(e) }     } ++    /** Reads the remote file; the failure half is set instead of bytes on error. */+    private fun readRemote(+        document: KdbxDocument,+    ): Pair<ByteArray, KdbxSyncResult?> = try {+        document.read() to null+    } catch (_: FileNotFoundException) {+        ByteArray(0) to KdbxSyncResult.FileMissing+    } catch (expected: IOException) {+        ByteArray(0) to KdbxSyncResult.Error(expected.message ?: "Failed to read KDBX file")+    }++    /** Decodes remote entries; a zero-byte file is an empty vault, not a failure. */+    private fun readFailureEntries(+        remoteBytes: ByteArray,+        vaultPassword: String,+    ): List<Map<String, String>>? = if (remoteBytes.isEmpty()) {+        emptyList()+    } else {+        codec.read(vaultPassword, remoteBytes)+    }     suspend fun sync(         document: KdbxDocument,         vaultPassword: String,         onBackup: (ByteArray) -> Unit = {},     ): KdbxSyncResult {-        val remoteBytes = try {-            document.read()-        } catch (_: FileNotFoundException) {-            return KdbxSyncResult.FileMissing-        } catch (expected: IOException) {-            return KdbxSyncResult.Error(expected.message ?: "Failed to read KDBX file")-        }-        // A brand new SAF document is zero bytes; that is an empty vault, not a failure.-        val remoteEntries = if (remoteBytes.isEmpty()) {-            emptyList()-        } else {-            codec.read(vaultPassword, remoteBytes) ?: return KdbxSyncResult.WrongPassword-        }+        val (remoteBytes, readFailure) = readRemote(document)+        if (readFailure != null) return readFailure+        val remoteEntries = readFailureEntries(remoteBytes, vaultPassword)+            ?: return KdbxSyncResult.WrongPassword          val now = System.currentTimeMillis()         val baseline = snapshotDao.getAll().associateBy { it.syncId }@@ -229,30 +248,10 @@ class KdbxSyncEngine(             return KdbxSyncResult.Quarantined(quarantineIds.size)         } -        if (passwordPlan.remoteChanged || passkeyPlan.remoteChanged) {-            val tombstoneEntries = (passwordPlan.tombstoneIds + passkeyPlan.tombstoneIds).map { id ->-                mapOf(-                    EntryMapper.FIELD_SYNC_ID to id,-                    EntryMapper.FIELD_TYPE to "tombstone",-                    EntryMapper.FIELD_TOMBSTONE to EntryMapper.TOMBSTONE_VALUE,-                    EntryMapper.FIELD_MODIFIED to now.toString(),-                )-            } + (passwordPlan.retainedTombstoneIds + passkeyPlan.retainedTombstoneIds).mapNotNull { id ->-                tombstones.firstOrNull { it[EntryMapper.FIELD_SYNC_ID] == id }-            }-            val merged = passwordPlan.remoteFields + passkeyPlan.remoteFields + tombstoneEntries-            val bytes = codec.write(vaultPassword, merged)-                ?: return KdbxSyncResult.Error("Failed to encode KDBX")-            // A SAF single-document write truncates, so prove the payload parses first.-            val verified = codec.read(vaultPassword, bytes)-            if (verified == null || verified.size != merged.size) return KdbxSyncResult.VerifyFailed-            if (remoteBytes.isNotEmpty()) onBackup(remoteBytes)-            try {-                document.write(bytes)-            } catch (expected: IOException) {-                return KdbxSyncResult.Error(expected.message ?: "Failed to write KDBX file")-            }-        }+        val writeError = writeMerged(+            document, vaultPassword, passwordPlan, passkeyPlan, tombstones, now, remoteBytes, onBackup,+        )+        if (writeError != null) return writeError          inTransaction {             applyPlan(passwordKind, passwordPlan)@@ -267,6 +266,44 @@ class KdbxSyncEngine(         )     } ++    /** Writes the merged file back when either plan changed the remote; null on success. */+    private suspend fun writeMerged(+        document: KdbxDocument,+        vaultPassword: String,+        passwordPlan: Plan<Password>,+        passkeyPlan: Plan<Passkey>,+        tombstones: List<Map<String, String>>,+        now: Long,+        remoteBytes: ByteArray,+        onBackup: (ByteArray) -> Unit,+    ): KdbxSyncResult? {+        if (!passwordPlan.remoteChanged && !passkeyPlan.remoteChanged) return null+        val tombstoneEntries = (passwordPlan.tombstoneIds + passkeyPlan.tombstoneIds).map { id ->+            mapOf(+                EntryMapper.FIELD_SYNC_ID to id,+                EntryMapper.FIELD_TYPE to "tombstone",+                EntryMapper.FIELD_TOMBSTONE to EntryMapper.TOMBSTONE_VALUE,+                EntryMapper.FIELD_MODIFIED to now.toString(),+            )+        } + (passwordPlan.retainedTombstoneIds + passkeyPlan.retainedTombstoneIds).mapNotNull { id ->+            tombstones.firstOrNull { it[EntryMapper.FIELD_SYNC_ID] == id }+        }+        val merged = passwordPlan.remoteFields + passkeyPlan.remoteFields + tombstoneEntries+        val bytes = codec.write(vaultPassword, merged)+            ?: return KdbxSyncResult.Error("Failed to encode KDBX")+        // A SAF single-document write truncates, so prove the payload parses first.+        val verified = codec.read(vaultPassword, bytes)+        if (verified == null || verified.size != merged.size) return KdbxSyncResult.VerifyFailed+        if (remoteBytes.isNotEmpty()) onBackup(remoteBytes)+        try {+            document.write(bytes)+        } catch (expected: IOException) {+            return KdbxSyncResult.Error(expected.message ?: "Failed to write KDBX file")+        }+        return null+    }+     private suspend fun <T> applyPlan(kind: EntityKind<T>, plan: Plan<T>) {         for (entity in plan.localDeletes) kind.delete(entity)         for (entity in plan.localUpserts) kind.persist(entity)@@ -652,6 +689,7 @@ private class Plan<T>(     val quarantineIds: List<String>, ) +/** Singleton holding native kdbx codec state and operations. */ object NativeKdbxCodec : KdbxCodec {     override fun read(password: String, bytes: ByteArray): List<Map<String, String>>? {         val json = KdbxNative.nativeImport(password, bytes) ?: return null@@ -669,6 +707,7 @@ object NativeKdbxCodec : KdbxCodec {     } } +/** Saf Kdbx Document: a context implementation for saf kdbx document. */ class SafKdbxDocument(private val context: Context, private val uri: Uri) : KdbxDocument {     override fun read(): ByteArray =         context.contentResolver.openInputStream(uri)?.use { it.readBytes() }
passwords/src/main/java/com/vayunmathur/passwords/sync/KdbxSyncWorker.kt
diff --git a/passwords/src/main/java/com/vayunmathur/passwords/sync/KdbxSyncWorker.kt b/passwords/src/main/java/com/vayunmathur/passwords/sync/KdbxSyncWorker.ktindex 7fb5b4c6d8..e5161f8ea4 100644--- a/passwords/src/main/java/com/vayunmathur/passwords/sync/KdbxSyncWorker.kt+++ b/passwords/src/main/java/com/vayunmathur/passwords/sync/KdbxSyncWorker.kt@@ -37,6 +37,7 @@ class KdbxSyncWorker(         }     } +    /** Shared constants and helpers for KdbxSyncWorker. */     companion object {         private const val TAG = "KdbxSyncWorker"     }
passwords/src/main/java/com/vayunmathur/passwords/sync/RelayPasswordProvider.kt
diff --git a/passwords/src/main/java/com/vayunmathur/passwords/sync/RelayPasswordProvider.kt b/passwords/src/main/java/com/vayunmathur/passwords/sync/RelayPasswordProvider.ktindex 4476b3da3b..30b290261e 100644--- a/passwords/src/main/java/com/vayunmathur/passwords/sync/RelayPasswordProvider.kt+++ b/passwords/src/main/java/com/vayunmathur/passwords/sync/RelayPasswordProvider.kt@@ -60,6 +60,7 @@ import kotlinx.serialization.json.Json  */ class RelayPasswordProvider : ContentProvider() { +    /** Shared constants and helpers for RelayPasswordProvider. */     companion object {         const val AUTHORITY = "com.vayunmathur.passwords.relay"         const val PERMISSION = "com.vayunmathur.passwords.permission.RELAY"@@ -150,7 +151,7 @@ class RelayPasswordProvider : ContentProvider() {                         cursorFromPasswords(repo().getPasswordsUpdatedSince(since))                     CODE_PASSKEYS, CODE_PASSKEYS_QUERY ->                         cursorFromPasskeys(repo().getPasskeysUpdatedSince(since))-                    CODE_SNAPSHOTS -> cursorFromSnapshots(repo().getAllSnapshots())+                    CODE_SNAPSHOTS -> cursorFromSnapshots(repo().snapshots.getAll())                     else -> null                 }             } catch (e: IllegalArgumentException) {@@ -217,50 +218,7 @@ class RelayPasswordProvider : ContentProvider() {         return runBlocking(Dispatchers.IO) {             try {                 val repo = repo()-                when (uriMatcher.match(uri)) {-                    CODE_PASSWORDS_PURGE -> {-                        repo.deleteAllPasswords()-                        repo.deleteSnapshotsByKind(SyncSnapshot.KIND_PASSWORD)-                        0-                    }-                    CODE_PASSKEYS_PURGE -> {-                        repo.deleteAllPasskeys()-                        repo.deleteSnapshotsByKind(SyncSnapshot.KIND_PASSKEY)-                        0-                    }-                    CODE_SNAPSHOTS_PURGE -> {-                        repo.deleteAllSnapshots()-                        0-                    }-                    // Single delete (`syncId = ?`): hard-delete the row but keep-                    // its snapshot โ€” the relay merge reads that as a deletion.-                    // Selection-less base delete is the legacy purge spelling.-                    CODE_PASSWORDS -> deleteBySyncIdOrPurge(selection, selectionArgs) {-                        repo.deletePasswordBySyncId(it)-                    } ?: run {-                        repo.deleteAllPasswords()-                        repo.deleteSnapshotsByKind(SyncSnapshot.KIND_PASSWORD)-                        0-                    }-                    CODE_PASSKEYS -> deleteBySyncIdOrPurge(selection, selectionArgs) {-                        repo.deletePasskeyBySyncId(it)-                    } ?: run {-                        repo.deleteAllPasskeys()-                        repo.deleteSnapshotsByKind(SyncSnapshot.KIND_PASSKEY)-                        0-                    }-                    CODE_SNAPSHOTS -> {-                        val syncId = selectionArgs?.firstOrNull()-                        if (syncId != null) {-                            repo.deleteSnapshotBySyncId(syncId)-                            1-                        } else {-                            repo.deleteAllSnapshots()-                            0-                        }-                    }-                    else -> 0-                }+                deleteMatched(repo, uriMatcher.match(uri), selection, selectionArgs)             } catch (e: IllegalArgumentException) {                 Log.error(TAG, "delete failed $uri", e)                 0@@ -271,6 +229,58 @@ class RelayPasswordProvider : ContentProvider() {         }     } ++    /** Delete dispatch for the matched provider code. */+    private suspend fun deleteMatched(+        repo: PasswordRepository,+        code: Int,+        selection: String?,+        selectionArgs: Array<out String>?,+    ): Int = when (code) {+        CODE_PASSWORDS_PURGE -> {+            repo.deleteAllPasswords()+            repo.snapshots.deleteByKind(SyncSnapshot.KIND_PASSWORD)+            0+        }+        CODE_PASSKEYS_PURGE -> {+            repo.deleteAllPasskeys()+            repo.snapshots.deleteByKind(SyncSnapshot.KIND_PASSKEY)+            0+        }+        CODE_SNAPSHOTS_PURGE -> {+            repo.snapshots.deleteAll()+            0+        }+        // Single delete (`syncId = ?`): hard-delete the row but keep+        // its snapshot โ€” the relay merge reads that as a deletion.+        // Selection-less base delete is the legacy purge spelling.+        CODE_PASSWORDS -> deleteBySyncIdOrPurge(selection, selectionArgs) {+            repo.deletePasswordBySyncId(it)+        } ?: run {+            repo.deleteAllPasswords()+            repo.snapshots.deleteByKind(SyncSnapshot.KIND_PASSWORD)+            0+        }+        CODE_PASSKEYS -> deleteBySyncIdOrPurge(selection, selectionArgs) {+            repo.deletePasskeyBySyncId(it)+        } ?: run {+            repo.deleteAllPasskeys()+            repo.snapshots.deleteByKind(SyncSnapshot.KIND_PASSKEY)+            0+        }+        CODE_SNAPSHOTS -> {+            val syncId = selectionArgs?.firstOrNull()+            if (syncId != null) {+                repo.snapshots.deleteBySyncId(syncId)+                1+            } else {+                repo.snapshots.deleteAll()+                0+            }+        }+        else -> 0+    }+     override fun getType(uri: Uri): String? = when (uriMatcher.match(uri)) {         CODE_PASSWORDS, CODE_PASSWORDS_QUERY -> "vnd.android.cursor.dir/vnd.com.vayunmathur.passwords.password"         CODE_PASSKEYS, CODE_PASSKEYS_QUERY -> "vnd.android.cursor.dir/vnd.com.vayunmathur.passwords.passkey"@@ -315,7 +325,7 @@ class RelayPasswordProvider : ContentProvider() {      private suspend fun upsertSnapshot(v: ContentValues): String? {         val syncId = v.getAsString(COL_SYNC_ID) ?: return null-        repo().upsertSnapshot(+        repo().snapshots.upsert(             SyncSnapshot(                 syncId = syncId,                 kind = v.getAsString("kind").orEmpty(),
passwords/src/main/java/com/vayunmathur/passwords/ui/AutofillSettingsActivity.kt
diff --git a/passwords/src/main/java/com/vayunmathur/passwords/ui/AutofillSettingsActivity.kt b/passwords/src/main/java/com/vayunmathur/passwords/ui/AutofillSettingsActivity.ktindex ba6a5845f9..2821ae0b06 100644--- a/passwords/src/main/java/com/vayunmathur/passwords/ui/AutofillSettingsActivity.kt+++ b/passwords/src/main/java/com/vayunmathur/passwords/ui/AutofillSettingsActivity.kt@@ -2,6 +2,7 @@ package com.vayunmathur.passwords.ui import android.app.Activity import android.os.Bundle +/** Autofill Settings Activity: a activity implementation for autofill settings activity. */ class AutofillSettingsActivity: Activity() {     override fun onCreate(savedInstanceState: Bundle?) {         super.onCreate(savedInstanceState)
passwords/src/main/java/com/vayunmathur/passwords/ui/MenuPage.kt
diff --git a/passwords/src/main/java/com/vayunmathur/passwords/ui/MenuPage.kt b/passwords/src/main/java/com/vayunmathur/passwords/ui/MenuPage.ktindex 08c332abc4..c42685cb07 100644--- a/passwords/src/main/java/com/vayunmathur/passwords/ui/MenuPage.kt+++ b/passwords/src/main/java/com/vayunmathur/passwords/ui/MenuPage.kt@@ -11,9 +11,12 @@ import com.vayunmathur.passwords.data.Password import com.vayunmathur.passwords.platform.MenuUiState import com.vayunmathur.passwords.platform.PasswordsViewModel +/** Credential Item: a long implementation for credential item. */ sealed class CredentialItem(override val id: Long) : DatabaseItem {+    /** Password Item: a password implementation for password item. */     class PasswordItem(val password: Password, val passkeys: List<Passkey>) :         CredentialItem(password.id)+    /** Passkey Item: a passkey implementation for passkey item. */     class PasskeyItem(val passkey: Passkey) : CredentialItem(Long.MAX_VALUE - passkey.id) } 
passwords/src/main/java/com/vayunmathur/passwords/ui/PasskeyAuthActivity.kt
diff --git a/passwords/src/main/java/com/vayunmathur/passwords/ui/PasskeyAuthActivity.kt b/passwords/src/main/java/com/vayunmathur/passwords/ui/PasskeyAuthActivity.ktindex ca09b87ea1..22a870bbaf 100644--- a/passwords/src/main/java/com/vayunmathur/passwords/ui/PasskeyAuthActivity.kt+++ b/passwords/src/main/java/com/vayunmathur/passwords/ui/PasskeyAuthActivity.kt@@ -26,6 +26,7 @@ import org.json.JSONArray import org.json.JSONObject import java.security.MessageDigest +/** Passkey Auth Activity: a fragment activity implementation for passkey auth activity. */ class PasskeyAuthActivity : FragmentActivity() {      private lateinit var repository: PasswordRepository@@ -313,6 +314,7 @@ class PasskeyAuthActivity : FragmentActivity() {         setResult(RESULT_OK, result)     } +    /** Shared constants and helpers for PasskeyAuthActivity. */     companion object {         const val EXTRA_FLOW = "flow"         const val EXTRA_CREDENTIAL_ID = "credential_id"