Skip to content

fix: safe biometry state #613

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

Merged
merged 3 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/screens/PinScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
resetOnLockScreen,
onExceptionCaptured,
} from '../actions';
import { PIN_SIZE } from '../constants';
import { PIN_SIZE, SAFE_BIOMETRY_MODE_FEATURE_TOGGLE } from '../constants';
import { COLORS } from '../styles/themes';
import { STORE } from '../store';
import baseStyle from '../styles/init';
Expand All @@ -43,7 +43,7 @@ const log = logger('PIN_SCREEN');
const mapStateToProps = (state) => ({
loadHistoryActive: state.loadHistoryStatus.active,
wallet: state.wallet,
safeBiometryEnabled: state.safeBiometryEnabled,
safeBiometryEnabled: state.featureToggles[SAFE_BIOMETRY_MODE_FEATURE_TOGGLE],
});

const mapDispatchToProps = (dispatch) => ({
Expand Down
5 changes: 4 additions & 1 deletion src/screens/Security.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ import { HathorList, ListItem, ListMenu } from '../components/HathorList';
import { lockScreen, onExceptionCaptured } from '../actions';
import { COLORS } from '../styles/themes';
import { STORE } from '../store';
import { SAFE_BIOMETRY_MODE_FEATURE_TOGGLE } from '../constants';

const mapStateToProps = (state) => ({
wallet: state.wallet,
safeBiometryEnabled: state.safeBiometryEnabled,
safeBiometryEnabled: state.featureToggles[SAFE_BIOMETRY_MODE_FEATURE_TOGGLE],
});

const mapDispatchToProps = (dispatch) => ({
Expand Down Expand Up @@ -152,6 +153,8 @@ export class Security extends React.Component {
render() {
const switchDisabled = !this.supportedBiometry;
const biometryText = (switchDisabled ? t`No biometry supported` : t`Use ${this.supportedBiometry}`);
console.log(`Security biometryEnabled ${this.state.biometryEnabled}`);
console.log(`Security safeBiometryEnabled ${this.props.safeBiometryEnabled}`);
const safeBiometryActive = this.state.biometryEnabled && this.props.safeBiometryEnabled;
return (
<View style={{ flex: 1, backgroundColor: COLORS.lowContrastDetail }}>
Expand Down
11 changes: 11 additions & 0 deletions src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ export const walletKeys = [
REGISTERED_NANO_CONTRACTS_KEY,
];

export const cleanOnWalletReset = [
PIN_BACKUP_KEY,
IS_BIOMETRY_ENABLED_KEY,
IS_OLD_BIOMETRY_ENABLED_KEY,
SUPPORTED_BIOMETRY_KEY,
];

/* eslint-disable class-methods-use-this */
/**
* The hybrid store will use the mobile native AsyncStorage to persist data and
Expand Down Expand Up @@ -280,6 +287,10 @@ class AsyncStorageStore {
}
// This will delete any wallet data of the legacy storage
await this.clearItems(true);
AsyncStorage.multiRemove(cleanOnWalletReset);
for (const key of cleanOnWalletReset) {
delete this.hathorMemoryStorage[key];
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export const getTokenLabel = (token) => `${token.name} (${token.symbol})`;
*
* @param {string} currentPassword
* @param {bool} safeBiometryEnabled
* @return {string} The actual pin/password for the application.
* @return {Promise<string>} The actual pin/password for the application.
*/
export async function biometricsMigration(currentPassword, safeBiometryEnabled) {
const oldBiometry = STORE.getItem(IS_OLD_BIOMETRY_ENABLED_KEY);
Expand Down