fix: Autofill OTP #553

This commit is contained in:
J-Jamet committed 2025-12-19 13:03:59 +01:00
1 parent 524aaa9771
commit 3dca7db14d
6 files changed
+51 -7

No files matched your search

+2 -2
View File
@@ -6,8 +6,8 @@ KeePassDX(4.3.0)
* Remove Clipboard notifications #2301
* Field reference placeholders S: #2270 (@thegards)
* Password Credential Provider API #2139
* Fix Passkey in passwordless mode #2282
* Small fixes #2289 #2277 #2068 #2288 #2276 #1793
* Improve Autofill recognition #553
* Small fixes #2289 #2277 #2068 #2288 #2276 #1793 #2282
KeePassDX(4.2.4)
* Fix remembering database location #2262
@@ -324,6 +324,14 @@ object AutofillHelper {
}
}
// OTP
struct.otpTokenId?.let { otpTokenId ->
datasetBuilder.addValueToDatasetBuilder(
otpTokenId,
AutofillValue.forText(entryInfo.getOtpToken())
)
}
val dataset = datasetBuilder.build()
Log.d(TAG, "Autofill Dataset $dataset created")
return dataset
@@ -277,6 +277,25 @@ class StructureParser(private val structure: AssistStructure) {
result?.cardVerificationValueId = autofillId
result?.cardVerificationValue = node.autofillValue?.textValue?.toString()
}
it.contains("2fa", true)
|| it.contains("2fpin", true)
|| it.contains("auth", true)
|| it.contains("challenge", true)
|| it.contains("code", true)
|| it.contains("idvpin", true)
|| it.contains("mfa", true)
|| it.contains("one-time-code", true)
|| it.contains("one_time_password", true)
|| it.contains("otp", true)
|| it.contains("token", true)
|| it.contains("twofa", true)
|| it.contains("two-factor", true)
|| it.contains("twofactor", true)
|| it.contains("verification_pin", true) -> {
Log.d(TAG, "Autofill OTP token")
result?.otpTokenId = autofillId
result?.otpTokenValue = node.autofillValue?.textValue?.toString()
}
// Ignore autocomplete="off"
// https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion
it.equals("off", true) ||
@@ -499,9 +518,10 @@ class StructureParser(private val structure: AssistStructure) {
var creditCardExpirationMonthId: AutofillId? = null
var creditCardExpirationDayId: AutofillId? = null
var cardVerificationValueId: AutofillId? = null
var otpTokenId: AutofillId? = null
fun isValid(): Boolean {
return passwordId != null || creditCardNumberId != null
return passwordId != null || creditCardNumberId != null || otpTokenId != null
}
fun allAutofillIds(): Array<AutofillId> {
@@ -521,6 +541,9 @@ class StructureParser(private val structure: AssistStructure) {
cardVerificationValueId?.let {
all.add(it)
}
otpTokenId?.let {
all.add(it)
}
return all.toTypedArray()
}
@@ -584,6 +607,13 @@ class StructureParser(private val structure: AssistStructure) {
if (allowSaveValues)
field = value
}
// OTP Token
var otpTokenValue: String? = null
set(value) {
if (allowSaveValues)
field = value
}
}
companion object {
@@ -111,6 +111,12 @@ class EntryInfo : NodeInfo {
parcel.writeBooleanCompat(isTemplate)
}
fun getOtpToken(): String? {
return otpModel?.let {
OtpElement(it).token
}
}
fun getCustomFieldsForFilling(): List<Field> {
return customFields.filter {
!it.isOTP() && !it.isPasskey()
@@ -5,5 +5,5 @@
* Remove Clipboard notifications #2301
* Field reference placeholders S: #2270 (@thegards)
* Password Credential Provider API #2139
* Fix Passkey in passwordless mode #2282
* Small fixes #2289 #2277 #2068 #2288 #2276 #1793
* Improve Autofill recognition #553
* Small fixes #2289 #2277 #2068 #2288 #2276 #1793 #2282
@@ -5,5 +5,5 @@
* Suppression des notifications de copie dans le presse-papier #2301
* Référence de champ S: #2270 (@thegards)
* API du fournisseur d'identification par mot de passe #2139
* Correction de Passkey en mode passwordless #2282
* Petites corrections #2289 #2277 #2068 #2288 #2276 #1793
* Meilleure reconnaissance de formulaires #553
* Petites corrections #2289 #2277 #2068 #2288 #2276 #1793 #2282