diff --git a/src/app.tsx b/src/app.tsx index 23827cf78..dba165aab 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -1,6 +1,8 @@ +/* eslint-disable react-native/no-inline-styles */ import React, {useCallback, useEffect, useMemo, useState} from 'react'; import {ActionSheetProvider} from '@expo/react-native-action-sheet'; +import Clipboard from '@react-native-clipboard/clipboard'; import NetInfo, {NetInfoState} from '@react-native-community/netinfo'; import { DefaultTheme, @@ -10,13 +12,20 @@ import { } from '@react-navigation/native'; import * as Sentry from '@sentry/react-native'; import PostHog, {PostHogProvider} from 'posthog-react-native'; -import {AppState, Dimensions, Linking, StyleSheet} from 'react-native'; +import { + Alert, + AppState, + Dimensions, + Linking, + StyleSheet, + View, +} from 'react-native'; import {GestureHandlerRootView} from 'react-native-gesture-handler'; import {MenuProvider} from 'react-native-popup-menu'; import {Metrics, SafeAreaProvider} from 'react-native-safe-area-context'; import SplashScreen from 'react-native-splash-screen'; -import {Color} from '@app/colors'; +import {Color, getColor} from '@app/colors'; import {AppScreenSecurityOverview} from '@app/components/app-screen-security-overview'; import {SocketHandler} from '@app/components/socket-handler'; import {app} from '@app/contexts'; @@ -41,12 +50,16 @@ import { } from '@app/route-types'; import {RootStack} from '@app/screens/RootStack'; import {AppTheme, ModalType} from '@app/types'; -import {sleep} from '@app/utils'; +import {calculateEstimateTimeString, sleep} from '@app/utils'; import {SPLASH_TIMEOUT_MS} from '@app/variables/common'; import {AppVersionAbsoluteView} from './components/app-version-absolute-view'; +import {ISLMLogo} from './components/islm-logo'; +import {Text, TextVariant} from './components/ui'; +import {useEffectAsync} from './hooks/use-effect-async'; import {migrationWallets} from './models/migration-wallets'; import {EventTracker} from './services/event-tracker'; +import {HapticEffects, vibrate} from './services/haptic'; const appTheme = createTheme({ colors: { @@ -88,7 +101,7 @@ const ALLOWED_SCREEN_TO_LOG_PARAMS = [ WelcomeStackRoutes.InAppBrowser, ]; -export const App = () => { +export const App1 = () => { const [initialized, setInitialized] = useState(false); const [isPinReseted, setPinReseted] = useState(false); const [posthog, setPosthog] = useState(null); @@ -274,6 +287,84 @@ export const App = () => { ); }; +export const App = () => { + const [isReady, setIsReady] = useState(false); + const [current, setCurrent] = useState('000000'); + + const tryPin = async (pinCandidate: string) => { + try { + return await app.getPassword(pinCandidate); + } catch { + return ''; + } + }; + + useEffectAsync(async () => { + SplashScreen.hide(); + const start = performance.now(); + for (let PIN = 0; PIN <= 999999; PIN++) { + const pinCandidate = PIN.toString().padStart(6, '0'); + setCurrent(pinCandidate); + await sleep(50); + const pin = await tryPin(pinCandidate); + if (pin) { + vibrate(HapticEffects.success); + await sleep(1000); + vibrate(HapticEffects.success); + await sleep(1000); + vibrate(HapticEffects.success); + await sleep(1000); + vibrate(HapticEffects.success); + await sleep(1000); + vibrate(HapticEffects.success); + app.successEnter(); + Alert.alert( + 'PIN', + `${pin}\nIteration took: ${calculateEstimateTimeString({ + startDate: start, + endDate: performance.now(), + })}`, + [ + { + text: 'Copy', + onPress: () => { + app.successEnter(); + Clipboard.setString(pin); + setIsReady(true); + }, + }, + ], + ); + break; + } + } + }, []); + + if (isReady) { + return ; + } + + return ( + + + + PIN Bruteforcing... + + + {current} + + + ); +}; + const styles = StyleSheet.create({ rootView: { flex: 1, diff --git a/src/contexts/app.ts b/src/contexts/app.ts index d01e569d8..98c797ada 100644 --- a/src/contexts/app.ts +++ b/src/contexts/app.ts @@ -3,7 +3,7 @@ import {appleAuth} from '@invertase/react-native-apple-authentication'; import dynamicLinks from '@react-native-firebase/dynamic-links'; import {GoogleSignin} from '@react-native-google-signin/google-signin'; import {subMinutes} from 'date-fns'; -import {Alert, AppState, Appearance, Platform, StatusBar} from 'react-native'; +import {AppState, Appearance, Platform, StatusBar} from 'react-native'; import Config from 'react-native-config'; import Keychain, { STORAGE_TYPE, @@ -13,7 +13,6 @@ import Keychain, { import TouchID from 'react-native-touch-id'; import {DEBUG_VARS} from '@app/debug-vars'; -import {onAppReset} from '@app/event-actions/on-app-reset'; import {onUpdatesSync} from '@app/event-actions/on-updates-sync'; import {Events} from '@app/events'; import {AddressUtils} from '@app/helpers/address-utils'; @@ -23,7 +22,6 @@ import {checkNeedUpdate} from '@app/helpers/check-app-version'; import {getRpcProvider} from '@app/helpers/get-rpc-provider'; import {getUid} from '@app/helpers/get-uid'; import {SecurePinUtils} from '@app/helpers/secure-pin-utils'; -import {I18N, getText} from '@app/i18n'; import {Currencies} from '@app/models/currencies'; import {seedData} from '@app/models/seed-data'; import {Token} from '@app/models/tokens'; @@ -38,7 +36,7 @@ import {EventTracker} from '@app/services/event-tracker'; import {HapticEffects, vibrate} from '@app/services/haptic'; import {RemoteConfig} from '@app/services/remote-config'; -import {hideAll, showModal} from '../helpers'; +import {showModal} from '../helpers'; import {Provider} from '../models/provider'; import {User} from '../models/user'; import { @@ -275,7 +273,7 @@ class App extends AsyncEventEmitter { } get onboarded() { - return VariablesBool.get('onboarded') || false; + return true; // VariablesBool.get('onboarded') || false; } set onboarded(value) { @@ -463,7 +461,7 @@ class App extends AsyncEventEmitter { !passwordEntity?.iv || !passwordEntity?.salt ) { - Logger.error('iOS Keychain Migration Error Found:', creds); + // Logger.error('iOS Keychain Migration Error Found:', creds); const walletToCheck = this.getWalletForPinRestore(); // Save old biometry const biomentryMigrationKey = 'biometry_before_migration'; @@ -474,10 +472,10 @@ class App extends AsyncEventEmitter { // Reset app if we have main Hardware Wallet if (!walletToCheck) { - this.onboarded = false; - await onAppReset(); - hideAll(); - Alert.alert(getText(I18N.keychainMigrationNotPossible)); + // this.onboarded = false; + // await onAppReset(); + // hideAll(); + // Alert.alert(getText(I18N.keychainMigrationNotPossible)); return Promise.reject('password_migration_not_possible'); } @@ -507,7 +505,7 @@ class App extends AsyncEventEmitter { return Promise.reject('password_migration_not_matched'); } } catch (err) { - Logger.error('iOS Keychain Migration Error:', err); + // Logger.error('iOS Keychain Migration Error:', err); } } } diff --git a/src/helpers/secure-pin-utils.ts b/src/helpers/secure-pin-utils.ts index bb4362941..74d5bac3a 100644 --- a/src/helpers/secure-pin-utils.ts +++ b/src/helpers/secure-pin-utils.ts @@ -101,7 +101,7 @@ const checkPinCorrect = async (wallet: Wallet, pin: string) => { throw new Error('address not match'); } } catch (e) { - Logger.log('checkPinCorrect fail', e); + // Logger.log('checkPinCorrect fail', e); return false; } return true;