Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (password === this.password) {
const biometryType = await SecureKeychain.getSupportedBiometryType();
if (biometryType) {
this.setState({ biometryType, biometryChoice: true });
}
const authOptions = {
accessControl: this.state.biometryChoice
? SecureKeychain.ACCESS_CONTROL.BIOMETRY_CURRENT_SET_OR_DEVICE_PASSCODE
: SecureKeychain.ACCESS_CONTROL.DEVICE_PASSCODE
};
await SecureKeychain.setGenericPassword('metamask-user', password, authOptions);
if (!this.state.biometryChoice) {
await AsyncStorage.removeItem('@MetaMask:biometryChoice');
} else {
// If the user enables biometrics, we're trying to read the password
// immediately so we get the permission prompt
try {
if (Platform.OS === 'ios') {
await SecureKeychain.getGenericPassword();
}
await AsyncStorage.setItem('@MetaMask:biometryChoice', this.state.biometryType);
} catch (e) {
Logger.error('User cancelled biometrics permission', e);
await AsyncStorage.removeItem('@MetaMask:biometryChoice');
}
}
}
try {
export function unsetUserLocally() {
// Remove token
AsyncStorage.removeItem('token')
AsyncStorage.removeItem('user')
}
static clearData = async () => {
await AsyncStorage.removeItem(DATA_SETTINGS);
await AsyncStorage.removeItem(DATA_PIN_HASH);
await AsyncStorage.removeItem(DATA_ASSETS);
await AsyncStorage.removeItem(DATA_PRICES);
await AsyncStorage.removeItem(DATA_PRICES_FETCHTIME);
// remove transactions
const keys = await AsyncStorage.getAllKeys();
for (let k = 0; k < keys.length; k += 1) {
const key = keys[k];
if (key.includes(DATA_ASSET_HIST)) {
await AsyncStorage.removeItem(key);
}
}
};
InteractionManager.runAfterInteractions(async () => {
const { KeyringController } = Engine.context;
await Engine.resetState();
await KeyringController.createNewVaultAndKeychain('');
await SecureKeychain.setGenericPassword('metamask-user', '');
await AsyncStorage.removeItem('@MetaMask:biometryChoice');
await AsyncStorage.removeItem('@MetaMask:nextMakerReminder');
await AsyncStorage.setItem('@MetaMask:existingUser', 'true');
// Get onboarding wizard state
const onboardingWizard = await AsyncStorage.getItem('@MetaMask:onboardingWizard');
// Check if user passed through metrics opt-in screen
const metricsOptIn = await AsyncStorage.getItem('@MetaMask:metricsOptIn');
// Making sure we reset the flag while going to
// the first time flow
this.props.passwordUnset();
this.props.setLockTime(-1);
this.props.seedphraseNotBackedUp();
setTimeout(() => {
if (!metricsOptIn) {
this.props.navigation.navigate('OptinMetrics');
} else if (onboardingWizard) {
this.props.navigation.navigate('HomeNav');
} else {
cleanUp: async () => {
await AsyncStorage.removeItem('@MetaMask:InstaPayUsername');
await AsyncStorage.removeItem('@MetaMask:InstaPayMnemonic');
await AsyncStorage.removeItem('@MetaMask:InstaPay');
await AsyncStorage.removeItem('@MetaMask:lastKnownInstantPaymentID');
await AsyncStorage.removeItem('@MetaMask:InstaPayVersion');
Store.reset();
instance.stop();
},
reloadClient,
export const handleLoginFacebook = async () => {
let accessData;
try {
accessData = await getAccessData();
const info = await getAccountInfo(accessData);
return { user: info };
} catch (err) {
await AsyncStorage.removeItem('@facebook:accessData');
return { error: 'Houve um erro ao recuperar os dados!' };
}
};
const clearPushTracking = async (): Promise =>
AsyncStorage.removeItem(PUSH_TRACKING_KEY)
export const clearSession = () => AsyncStorage.removeItem(getStorageKey());
static async updateItem(key, value) {
if (value !== null && value !== undefined) {
await AsyncStorage.setItem(key, value);
} else {
await AsyncStorage.removeItem(key);
}
}
export async function persistData(key, data) {
try {
await AsyncStorage.removeItem(key);
await AsyncStorage.setItem(key, JSON.stringify(data));
return data;
} catch (error) {
throw new Error('Error saving data');
}
}