-
-
Notifications
You must be signed in to change notification settings - Fork 528
feat(android): add confirmationRequired option to authenticationPrompt #755
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(android): add confirmationRequired option to authenticationPrompt #755
Conversation
If you default this to true it will change the behavior of existing apps who upgrade to the latest version. |
487ae2c
to
a635a21
Compare
Thanks for the feedback! 🙌 I confused it with the default behavior in a project I’m currently working on. You’re absolutely right — I’ve updated the code to restore the default to false. Appreciate the heads-up! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a new confirmationRequired
option to Android’s biometric auth prompt, defaulting to false
for a faster UX.
- Extend the TS
AuthenticationPrompt
type withconfirmationRequired?: boolean
. - Read the new field in
KeychainModule.kt
and apply it viaPromptInfo.Builder.setConfirmationRequired()
.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
src/types.ts | Declare confirmationRequired?: boolean in AuthenticationPrompt |
android/src/main/java/com/oblador/keychain/KeychainModule.kt | Define and consume confirmationRequired when building the prompt |
Comments suppressed due to low confidence (2)
android/src/main/java/com/oblador/keychain/KeychainModule.kt:783
- Consider adding an Android unit/integration test to verify that
confirmationRequired
defaults tofalse
and respects the override when set totrue
.
// Default is false — no confirmation required unless explicitly set
android/src/main/java/com/oblador/keychain/KeychainModule.kt:786
- The code refers to
AuthPromptOptions.CONFIRMATION_REQUIRED
, but the constant is defined in the companion object ofKeychainModule
. Either moveCONFIRMATION_REQUIRED
intoAuthPromptOptions
or update this reference to useKeychainModule.CONFIRMATION_REQUIRED
for consistency.
if (it.hasKey(AuthPromptOptions.CONFIRMATION_REQUIRED)) {
var confirmationRequired = false | ||
promptInfoOptionsMap?.let { | ||
if (it.hasKey(AuthPromptOptions.CONFIRMATION_REQUIRED)) { | ||
confirmationRequired = it.getBoolean(AuthPromptOptions.CONFIRMATION_REQUIRED) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can simplify this block by using a single expression with a default value, e.g.: val confirmationRequired = promptInfoOptionsMap?.getBoolean(CONFIRMATION_REQUIRED) ?: false
.
var confirmationRequired = false | |
promptInfoOptionsMap?.let { | |
if (it.hasKey(AuthPromptOptions.CONFIRMATION_REQUIRED)) { | |
confirmationRequired = it.getBoolean(AuthPromptOptions.CONFIRMATION_REQUIRED) | |
} | |
} | |
val confirmationRequired = promptInfoOptionsMap?.getBoolean(AuthPromptOptions.CONFIRMATION_REQUIRED) ?: false |
Copilot uses AI. Check for mistakes.
@herbig Well, that's not really true. It defaults to true |
RNC currently sets this field to false. @quangsuong was proposing to set this to true, unless the user sets the field in the RNC prompt props. The Android API default isn't used in either case, since we're always setting it explicitly. |
🔥 Feature: Add
confirmationRequired
Option to Android Authentication Prompt✨ Summary
This PR introduces a new optional field
confirmationRequired
in theauthenticationPrompt
config for Android. It allows developers to control whether the user must press an explicit confirmation (OK) button after biometric authentication.By default,
confirmationRequired
is now set tofalse
, enabling a faster, more seamless biometric UX unless explicitly overridden.✅ Changes
Android Native:
KeychainModule.kt
:confirmationRequired
fromauthenticationPrompt
.PromptInfo.Builder.setConfirmationRequired(...)
.false
(user does not need to confirm after authentication unless specified).TypeScript Types:
AuthenticationPrompt
type to support: