Commit a77c7cb
authored
Simplify PasscodeManager API and decouple passcode/biometrics libraries (#73)
* Refactor biometric authentication logic into a generalized external authentication framework.
* Rename all biometric-related references to "ExternalAuth" across `PasscodeManager`, `PasscodeScreen`, and associated components to support a broader range of authentication methods.
* Introduce `BiometricStorageAdapter` interface and implementation to decouple biometric registration data from the core passcode module.
* Deprecate registration-related methods in `PasscodeStorageAdapter` in favor of the new `BiometricStorageAdapter`.
* Update `PasscodeManager` initialization and `PasscodeState` to use `isExternalAuthEnabled` instead of specific biometric flags.
* Rename `PasscodeAction` and `PasscodeEvent` cases, such as `BiometricUnlockSuccess` to `ExternalUnlockSuccess` and `DisableBiometrics` to `DisableExternalAuth`.
* Update `PasscodeScreen` and `PasscodeKeys` to use `externalAuthButton` as a generic slot for platform-specific authentication triggers.
* Refactor navigation and setup logic in the sample app to integrate the new storage adapters and renamed callbacks.
* Update string resource keys to reflect the transition from biometric-specific naming to external authentication.
* Refactor `PasscodeManager` and `PasscodeScreen` to use a direct method API and a unified result callback.
* **Passcode Logic and State Management**:
* Refactor `PasscodeManager` to remove `CoroutineScope` and internal `Action`/`Event` channels, replacing them with direct method calls (e.g., `enterKey`, `changePasscode`, `logOut`).
* Introduce `PasscodeResult` sealed interface to consolidate all operation outcomes (Verified, Created, Changed, etc.) into a single callback.
* Add `shakeAnimationTrigger` to `PasscodeState` to handle UI feedback for rejected passcodes without relying on one-shot events.
* Simplify `PasscodeManager` initialization by passing `isExternalAuthEnabled` directly to the constructor.
* **UI Components**:
* Update `PasscodeScreen` to use a single `onResult` lambda instead of multiple individual event callbacks.
* Replace `LaunchedEffect` event collection with a `DisposableEffect` that registers the result callback.
* Rename `biometricButton` to `externalAuthButton` in `PasscodeScreen` to be more agnostic of the authentication mechanism.
* Update `PasscodeKeys`, `PasscodeLengthSwitch`, and `PasscodeForgotButton` to invoke manager methods directly.
* **Integration and Navigation**:
* Update `SampleAppNavigation` to map `PasscodeResult` values to navigation routes and storage updates.
* Refactor `BiometricKey` and `BiometricSetupScreen` to interact with the updated `PasscodeManager` API, manually handling external auth status updates.
* Update `BiometricStorageAdapter` implementation to separate biometric persistence from passcode persistence.
* **Documentation and API**:
* Update `README.md` for both passcode and biometrics modules to reflect the new API patterns and integration steps.
* Add `UserCancelled` state to `RegistrationResult` and `AuthenticationResult` in the biometrics module.
* Refine `PasscodeStorageAdapter` interface to focus exclusively on passcode data.
* Refactor sample app navigation and modularize screen components.
* Extract `HomeScreen`, `LoginScreen`, and `BiometricKey` into dedicated files within the `cmp-sample-shared` module to improve project structure.
* Update `SampleAppNavigation` to handle consolidated `PasscodeResult` events, including verified, created, changed, and forgotten states.
* Ensure consistent backstack management by using `popUpTo(0)` when navigating to top-level screens like `HomeScreen` and `LoginScreen`.
* Update `PasscodeManager` to fully reset the internal state, including `isChangeFlow` and `isExternalAuthEnabled` flags, when clearing all security data.
* Remove the redundant `SettingsPasscodeScreen` route.
* Enhance `HomeScreen` with logic for toggling biometric authentication and triggering the passcode change flow.
* Refactor `BiometricKey` to handle biometric authentication results and provide appropriate user feedback via callbacks.1 parent fb256fe commit a77c7cb
19 files changed
Lines changed: 864 additions & 727 deletions
File tree
- mifos-authenticator-biometrics
- src/commonMain/kotlin/org/mifos/authenticator/biometrics
- mifos-authenticator-passcode
- src/commonMain
- composeResources/values
- kotlin/org/mifos/authenticator/passcode
- components
- screen
Lines changed: 31 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
Lines changed: 7 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
| 15 | + | |
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
| |||
30 | 29 | | |
31 | 30 | | |
32 | 31 | | |
33 | | - | |
34 | | - | |
35 | | - | |
| 32 | + | |
| 33 | + | |
36 | 34 | | |
37 | | - | |
38 | | - | |
39 | | - | |
| 35 | + | |
| 36 | + | |
40 | 37 | | |
41 | | - | |
42 | | - | |
43 | | - | |
| 38 | + | |
| 39 | + | |
44 | 40 | | |
Lines changed: 6 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | | - | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| 26 | + | |
25 | 27 | | |
26 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
27 | 31 | | |
28 | 32 | | |
29 | 33 | | |
| |||
Lines changed: 0 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | 26 | | |
0 commit comments