From afc177cb53ba7c390d41cc289e80d6c448359776 Mon Sep 17 00:00:00 2001 From: Sofiya Tepikin Date: Mon, 19 Sep 2022 15:07:03 +0200 Subject: [PATCH] Use jshashes on Confirmation with password --- .../settings/common/confirm-with-password.js | 24 +++++-------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/components/settings/common/confirm-with-password.js b/components/settings/common/confirm-with-password.js index 4462937..5986cfd 100644 --- a/components/settings/common/confirm-with-password.js +++ b/components/settings/common/confirm-with-password.js @@ -1,12 +1,12 @@ -import React, { useState, useEffect } from 'react' +import React, { useState } from 'react' import PropTypes from 'prop-types' import { Alert, KeyboardAvoidingView, StyleSheet, View } from 'react-native' -import nodejs from 'nodejs-mobile-react-native' +import { SHA512 } from 'jshashes' import AppTextInput from '../../common/app-text-input' import Button from '../../common/button' -import { requestHash, openDb } from '../../../db' +import { openDb } from '../../../db' import { Containers } from '../../../styles' import settings from '../../../i18n/en/settings' import { shared } from '../../../i18n/en/labels' @@ -14,7 +14,8 @@ import { shared } from '../../../i18n/en/labels' const ConfirmWithPassword = ({ onSuccess, onCancel }) => { const [password, setPassword] = useState(null) - const checkPassword = async (hash) => { + const checkPassword = async () => { + const hash = new SHA512().hex(password) try { await openDb(hash) onSuccess() @@ -23,15 +24,6 @@ const ConfirmWithPassword = ({ onSuccess, onCancel }) => { } } - useEffect(() => { - const listener = nodejs.channel.addListener( - 'password-check', - checkPassword, - this - ) - return () => listener.remove() - }, []) - const onIncorrectPassword = () => { Alert.alert(shared.incorrectPassword, shared.incorrectPasswordMessage, [ { @@ -45,10 +37,6 @@ const ConfirmWithPassword = ({ onSuccess, onCancel }) => { ]) } - const initPasswordCheck = () => { - requestHash('password-check', password) - } - const labels = settings.passwordSettings const isPassword = password !== null @@ -65,7 +53,7 @@ const ConfirmWithPassword = ({ onSuccess, onCancel }) => {