From 9b7d2baaad5f03acfbcf9b8e059c9669c0581e0d Mon Sep 17 00:00:00 2001 From: Nouman Tahir Date: Tue, 26 Jul 2022 14:37:51 +0500 Subject: [PATCH 01/11] installed biometric scanner --- android/app/src/main/AndroidManifest.xml | 2 ++ ios/Ecency/Info.plist | 2 ++ ios/Podfile.lock | 8 +++++++- package.json | 1 + yarn.lock | 5 +++++ 5 files changed, 17 insertions(+), 1 deletion(-) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index c884a92f7..8deddd2c4 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -10,6 +10,8 @@ + + diff --git a/ios/Ecency/Info.plist b/ios/Ecency/Info.plist index 5ef57e16a..f8d3be6ec 100644 --- a/ios/Ecency/Info.plist +++ b/ios/Ecency/Info.plist @@ -74,6 +74,8 @@ Photo Library Access for allowing user to download and upload photos NSPhotoLibraryUsageDescription Photo Usage Access for allowing user to upload photos + NSFaceIDUsageDescription + Ecency requires FaceID access to allow you quick and secure access. UIAppFonts Entypo.ttf diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 7811fec77..7608fde70 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -346,6 +346,8 @@ PODS: - React-Core - react-native-date-picker (4.2.0): - React-Core + - react-native-fingerprint-scanner (6.0.0): + - React - react-native-matomo-sdk (0.4.1): - MatomoTracker (~> 7) - React (~> 0.60) @@ -530,6 +532,7 @@ DEPENDENCIES: - "react-native-cameraroll (from `../node_modules/@react-native-community/cameraroll`)" - react-native-config (from `../node_modules/react-native-config`) - react-native-date-picker (from `../node_modules/react-native-date-picker`) + - react-native-fingerprint-scanner (from `../node_modules/react-native-fingerprint-scanner`) - react-native-matomo-sdk (from `../node_modules/react-native-matomo-sdk`) - "react-native-netinfo (from `../node_modules/@react-native-community/netinfo`)" - react-native-orientation-locker (from `../node_modules/react-native-orientation-locker`) @@ -652,6 +655,8 @@ EXTERNAL SOURCES: :path: "../node_modules/react-native-config" react-native-date-picker: :path: "../node_modules/react-native-date-picker" + react-native-fingerprint-scanner: + :path: "../node_modules/react-native-fingerprint-scanner" react-native-matomo-sdk: :path: "../node_modules/react-native-matomo-sdk" react-native-netinfo: @@ -784,6 +789,7 @@ SPEC CHECKSUMS: react-native-cameraroll: e2917a5e62da9f10c3d525e157e25e694d2d6dfa react-native-config: c98128a72bc2c3a1ca72caec0b021f0fa944aa29 react-native-date-picker: d83ab9cccbc497642a93fdca783ae76ecd6b17b6 + react-native-fingerprint-scanner: ac6656f18c8e45a7459302b84da41a44ad96dbbe react-native-matomo-sdk: 025c54f92e1e26a4d0acee7c3f28cb0fc7e4729c react-native-netinfo: 30fb89fa913c342be82a887b56e96be6d71201dd react-native-orientation-locker: 2da91e5391971dace445495821c899c111dcad7a @@ -833,4 +839,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 0282022703ad578ab2d9afbf3147ba3b373b4311 -COCOAPODS: 1.11.2 +COCOAPODS: 1.11.3 diff --git a/package.json b/package.json index 7effffa93..85b8b58a7 100644 --- a/package.json +++ b/package.json @@ -93,6 +93,7 @@ "react-native-dynamic": "^1.0.0", "react-native-extended-stylesheet": "^0.10.0", "react-native-fast-image": "^8.3.2", + "react-native-fingerprint-scanner": "^6.0.0", "react-native-gesture-handler": "^1.9.0", "react-native-highlight-words": "^1.0.1", "react-native-iap": "^7.5.6", diff --git a/yarn.lock b/yarn.lock index 5d346ba07..80633aee1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8782,6 +8782,11 @@ react-native-fast-image@^8.3.2: resolved "https://registry.yarnpkg.com/react-native-fast-image/-/react-native-fast-image-8.3.4.tgz#79edca177e30311b19d59ff335625bcbe22650d7" integrity sha512-LpzAdjUphihUpVEBn5fEv5AILe55rHav0YiZroPZ1rumKDhAl4u2cG01ku2Pb7l8sayjTsNu7FuURAlXUUDsow== +react-native-fingerprint-scanner@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/react-native-fingerprint-scanner/-/react-native-fingerprint-scanner-6.0.0.tgz#ecb47ad0682d2a66a5e126d2b9e4d95e73c8dbf2" + integrity sha512-8VoKSA0Z0kWnIni96yABZfUUzfmWFXQEXcELwWr1CNLloPt3WoPptYb/6pGsBcH0YxSsW3X4+C8tl0clgyBsvA== + react-native-flipper@^0.34.0: version "0.34.0" resolved "https://registry.yarnpkg.com/react-native-flipper/-/react-native-flipper-0.34.0.tgz#7df1f38ba5d97a9321125fe0fccbe47d99e6fa1d" From be0806f3c87f2813cce0fea289ea783bce0ca3cd Mon Sep 17 00:00:00 2001 From: Nouman Tahir Date: Tue, 26 Jul 2022 14:38:50 +0500 Subject: [PATCH 02/11] enabled biometric app unlock --- .../pinCode/container/pinCodeContainer.js | 34 +++++++++++++++++++ .../{pinCodeScreen.js => pinCodeScreen.tsx} | 23 ++++++++++--- 2 files changed, 52 insertions(+), 5 deletions(-) rename src/screens/pinCode/screen/{pinCodeScreen.js => pinCodeScreen.tsx} (87%) diff --git a/src/screens/pinCode/container/pinCodeContainer.js b/src/screens/pinCode/container/pinCodeContainer.js index 794493694..6015408eb 100644 --- a/src/screens/pinCode/container/pinCodeContainer.js +++ b/src/screens/pinCode/container/pinCodeContainer.js @@ -4,6 +4,7 @@ import { connect } from 'react-redux'; import { injectIntl } from 'react-intl'; import Config from 'react-native-config'; import get from 'lodash/get'; +import FingerprintScanner from 'react-native-fingerprint-scanner'; //Contstants import AUTH_TYPE from '../../../constants/authType'; @@ -47,6 +48,8 @@ import { getUnreadNotificationCount } from '../../../providers/ecency/ecency'; import { fetchSubscribedCommunities } from '../../../redux/actions/communitiesAction'; class PinCodeContainer extends Component { + screenRef = null; + constructor(props) { super(props); this.state = { @@ -80,6 +83,8 @@ class PinCodeContainer extends Component { }); } }); + + this._processBiometric(); } _getDataFromStorage = () => @@ -94,6 +99,33 @@ class PinCodeContainer extends Component { }); }); + _processBiometric = async () => { + try { + const { + pinCodeParams: { isReset }, + applicationPinCode, + } = this.props; + + if (isReset) { + return; + } + + const biometryType = await FingerprintScanner.isSensorAvailable(); + console.log('biometryType is => ', biometryType); + + await FingerprintScanner.authenticate({ description: 'Scan your biometric to continue' }); + console.log('successfully passed biometric auth'); + + //code gets here means biometeric succeeded + if (this.screenRef) { + const verifiedPin = decryptKey(applicationPinCode, Config.PIN_KEY, this._onDecryptFail); + this.screenRef.setPinThroughBiometric(verifiedPin); + } + } catch (err) { + console.warn('Failed to process biometric', err); + } + }; + //this function updates realm with appropriate master key required for encyrption //this function is important: must run while chaning pin //and even logging in with existing pin code @@ -515,12 +547,14 @@ class PinCodeContainer extends Component { return ( (this.screenRef = ref)} informationText={informationText} setPinCode={(pin) => this._setPinCode(pin, isReset)} showForgotButton={!isOldPinVerified} username={currentAccount.name} intl={intl} handleForgotButton={() => this._handleForgotButton()} + isReset={isReset} {...this.props} /> ); diff --git a/src/screens/pinCode/screen/pinCodeScreen.js b/src/screens/pinCode/screen/pinCodeScreen.tsx similarity index 87% rename from src/screens/pinCode/screen/pinCodeScreen.js rename to src/screens/pinCode/screen/pinCodeScreen.tsx index db18685a4..318bfc73c 100644 --- a/src/screens/pinCode/screen/pinCodeScreen.js +++ b/src/screens/pinCode/screen/pinCodeScreen.tsx @@ -1,27 +1,39 @@ -import React, { useState, useEffect } from 'react'; +import React, { useState, useEffect, forwardRef, useImperativeHandle } from 'react'; import { useIntl } from 'react-intl'; import { Text, TouchableOpacity, View } from 'react-native'; - import { NumericKeyboard, PinAnimatedInput, UserAvatar } from '../../../components'; import styles from './pinCodeStyles'; -const PinCodeScreen = ({ +const PinCodeScreen = forwardRef(({ informationText, showForgotButton, username, handleForgotButton, setPinCode, -}) => { +}, ref) => { const [pin, setPin] = useState(''); const [loading, setLoading] = useState(false); const intl = useIntl(); + useImperativeHandle(ref, () => ({ + setPinThroughBiometric(bioPin){ + if(bioPin && bioPin.length === 4){ + setLoading(true); + setPin(bioPin) + } + } + })); + + + useEffect(() => { _handlePinComplete(); }, [pin]); + + const _handlePinComplete = async () => { if (pin.length === 4) { setLoading(true); @@ -31,6 +43,7 @@ const PinCodeScreen = ({ } }; + const _handleKeyboardOnPress = async (value) => { try { if (loading) { @@ -82,6 +95,6 @@ const PinCodeScreen = ({ )} ); -}; +}) export default PinCodeScreen; From 51850eb5a53f6ad2628874c1bd02bdbfcbac80cd Mon Sep 17 00:00:00 2001 From: Nouman Tahir Date: Tue, 26 Jul 2022 15:32:12 +0500 Subject: [PATCH 03/11] added setting to enable disable biometric unlock --- src/config/locales/en-US.json | 1 + src/redux/actions/applicationActions.ts | 8 +++++++- src/redux/constants/constants.js | 1 + src/redux/reducers/applicationReducer.ts | 9 +++++++++ .../pinCode/container/pinCodeContainer.js | 4 +++- .../settings/container/settingsContainer.js | 10 ++++++++++ src/screens/settings/screen/settingsScreen.js | 20 ++++++++++--------- 7 files changed, 42 insertions(+), 11 deletions(-) diff --git a/src/config/locales/en-US.json b/src/config/locales/en-US.json index 4292e1593..1f4725b54 100644 --- a/src/config/locales/en-US.json +++ b/src/config/locales/en-US.json @@ -229,6 +229,7 @@ "delegations": "Delegations" }, "pincode": "PIN code", + "biometric": "TouchId / FaceId Unlock", "reset_pin": "Reset Pin Code", "reset": "Reset", "nsfw_content": "NSFW", diff --git a/src/redux/actions/applicationActions.ts b/src/redux/actions/applicationActions.ts index 65effa481..4d36b1e7b 100644 --- a/src/redux/actions/applicationActions.ts +++ b/src/redux/actions/applicationActions.ts @@ -31,7 +31,8 @@ import { SET_COLOR_THEME, SET_SETTINGS_MIGRATED, HIDE_POSTS_THUMBNAILS, - SET_TERMS_ACCEPTED + SET_TERMS_ACCEPTED, + SET_IS_BIOMETRIC_ENABLED } from '../constants/constants'; export const login = (payload) => ({ @@ -209,4 +210,9 @@ export const setIsTermsAccepted = (isTermsAccepted:boolean) => ({ type: SET_TERMS_ACCEPTED }) +export const setIsBiometricEnabled = (enabled:boolean) => ({ + payload:enabled, + type: SET_IS_BIOMETRIC_ENABLED +}) + diff --git a/src/redux/constants/constants.js b/src/redux/constants/constants.js index 74d54ee44..e2b15891b 100644 --- a/src/redux/constants/constants.js +++ b/src/redux/constants/constants.js @@ -36,6 +36,7 @@ export const SET_LAST_APP_VERSION = 'SET_LAST_APP_VERSION'; export const SET_COLOR_THEME = 'SET_COLOR_THEME'; export const SET_SETTINGS_MIGRATED = 'SET_SETTINGS_MIGRATED'; export const SET_TERMS_ACCEPTED = 'SET_TERMS_ACCEPTED'; +export const SET_IS_BIOMETRIC_ENABLED = 'SET_IS_BIOMETRIC_ENABLED'; // Accounts export const ADD_OTHER_ACCOUNT = 'ADD_OTHER_ACCOUNT'; diff --git a/src/redux/reducers/applicationReducer.ts b/src/redux/reducers/applicationReducer.ts index 6d02dfe8d..1414e0c84 100644 --- a/src/redux/reducers/applicationReducer.ts +++ b/src/redux/reducers/applicationReducer.ts @@ -30,6 +30,7 @@ import { SET_SETTINGS_MIGRATED, HIDE_POSTS_THUMBNAILS, SET_TERMS_ACCEPTED, + SET_IS_BIOMETRIC_ENABLED } from '../constants/constants'; interface State { @@ -69,6 +70,7 @@ interface State { settingsMigrated: boolean; hidePostsThumbnails: boolean; isTermsAccepted: boolean; + isBiometricEnabled: boolean; } const initialState:State = { @@ -108,6 +110,7 @@ const initialState:State = { settingsMigrated: false, hidePostsThumbnails: false, isTermsAccepted: false, + isBiometricEnabled: false }; export default function (state = initialState, action) { @@ -282,6 +285,12 @@ export default function (state = initialState, action) { ...state, isTermsAccepted:action.payload } + + case SET_IS_BIOMETRIC_ENABLED: + return { + ...state, + isBiometricEnabled:action.payload + } default: return state; diff --git a/src/screens/pinCode/container/pinCodeContainer.js b/src/screens/pinCode/container/pinCodeContainer.js index 6015408eb..d3266794c 100644 --- a/src/screens/pinCode/container/pinCodeContainer.js +++ b/src/screens/pinCode/container/pinCodeContainer.js @@ -104,9 +104,10 @@ class PinCodeContainer extends Component { const { pinCodeParams: { isReset }, applicationPinCode, + isBiometricEnabled, } = this.props; - if (isReset) { + if (isReset || !isBiometricEnabled) { return; } @@ -566,6 +567,7 @@ const mapStateToProps = (state) => ({ applicationPinCode: state.application.pin, otherAccounts: state.account.otherAccounts, pinCodeParams: state.application.pinCodeNavigation, + isBiometricEnabled: state.application.isBiometricEnabled, }); export default injectIntl(connect(mapStateToProps)(PinCodeContainer)); diff --git a/src/screens/settings/container/settingsContainer.js b/src/screens/settings/container/settingsContainer.js index f958cf8b0..dc371303f 100644 --- a/src/screens/settings/container/settingsContainer.js +++ b/src/screens/settings/container/settingsContainer.js @@ -43,6 +43,7 @@ import { logoutDone, closePinCodeModal, setColorTheme, + setIsBiometricEnabled, } from '../../../redux/actions/applicationActions'; import { toastNotification } from '../../../redux/actions/uiAction'; import { setPushToken, getNodes } from '../../../providers/ecency/ecency'; @@ -239,6 +240,14 @@ class SettingsContainer extends Component { ); } break; + + case 'biometric': + dispatch( + openPinCodeModal({ + callback: () => dispatch(setIsBiometricEnabled(action)), + }), + ); + break; default: break; } @@ -483,6 +492,7 @@ const mapStateToProps = (state) => ({ isDarkTheme: state.application.isDarkTheme, colorTheme: state.application.colorTheme, isPinCodeOpen: state.application.isPinCodeOpen, + isBiometricEnabled: state.application.isBiometricEnabled, pinCode: state.application.pin, isDefaultFooter: state.application.isDefaultFooter, isLoggedIn: state.application.isLoggedIn, diff --git a/src/screens/settings/screen/settingsScreen.js b/src/screens/settings/screen/settingsScreen.js index 5aa362e50..95ff12486 100644 --- a/src/screens/settings/screen/settingsScreen.js +++ b/src/screens/settings/screen/settingsScreen.js @@ -24,6 +24,7 @@ const SettingsScreen = ({ isDarkTheme, colorThemeIndex, isPinCodeOpen, + isBiometricEnabled, isLoggedIn, isNotificationSettingsOpen, nsfw, @@ -147,6 +148,16 @@ const SettingsScreen = ({ {!!isLoggedIn && !!isPinCodeOpen && ( + + - // )} {!!isLoggedIn && ( From 8d364a809aa0637080d129bbc77e602dd613af0d Mon Sep 17 00:00:00 2001 From: Nouman Tahir Date: Tue, 26 Jul 2022 15:49:17 +0500 Subject: [PATCH 04/11] updated setting label --- src/config/locales/en-US.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config/locales/en-US.json b/src/config/locales/en-US.json index 1f4725b54..48f8820db 100644 --- a/src/config/locales/en-US.json +++ b/src/config/locales/en-US.json @@ -229,7 +229,7 @@ "delegations": "Delegations" }, "pincode": "PIN code", - "biometric": "TouchId / FaceId Unlock", + "biometric": "Finger Print / Face Unlock", "reset_pin": "Reset Pin Code", "reset": "Reset", "nsfw_content": "NSFW", From f23489b58c5d18e1dcceca8822686ae3099620ac Mon Sep 17 00:00:00 2001 From: Nouman Tahir Date: Tue, 26 Jul 2022 16:07:22 +0500 Subject: [PATCH 05/11] fixed android jcenter issue for biometric --- android/build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/android/build.gradle b/android/build.gradle index 66a28dcc2..18115dae5 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -64,6 +64,7 @@ allprojects { includeGroup("com.henninghall.android") includeGroup("org.matomo.sdk") includeModule("com.yqritc", "android-scalablevideoview") + includeModule("com.wei.android.lib", "fingerprintidentify") } } } From a9df0aa2544106ddb5dc5eb4d2a41b92851690c0 Mon Sep 17 00:00:00 2001 From: Nouman Tahir Date: Tue, 26 Jul 2022 16:07:32 +0500 Subject: [PATCH 06/11] removed description for now --- src/screens/pinCode/container/pinCodeContainer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/screens/pinCode/container/pinCodeContainer.js b/src/screens/pinCode/container/pinCodeContainer.js index d3266794c..687045d1b 100644 --- a/src/screens/pinCode/container/pinCodeContainer.js +++ b/src/screens/pinCode/container/pinCodeContainer.js @@ -114,7 +114,7 @@ class PinCodeContainer extends Component { const biometryType = await FingerprintScanner.isSensorAvailable(); console.log('biometryType is => ', biometryType); - await FingerprintScanner.authenticate({ description: 'Scan your biometric to continue' }); + await FingerprintScanner.authenticate(); console.log('successfully passed biometric auth'); //code gets here means biometeric succeeded From df8df111e25bcf72438e7964ae4f98b8c9c726ee Mon Sep 17 00:00:00 2001 From: Nouman Tahir Date: Tue, 26 Jul 2022 16:12:18 +0500 Subject: [PATCH 07/11] added translated description --- src/config/locales/en-US.json | 3 ++- src/screens/pinCode/container/pinCodeContainer.js | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/config/locales/en-US.json b/src/config/locales/en-US.json index 48f8820db..b28ba99f3 100644 --- a/src/config/locales/en-US.json +++ b/src/config/locales/en-US.json @@ -420,7 +420,8 @@ "forgot_text": "Oh, I forgot it...", "pin_not_matched":"PIN do not match, Please try again.", "attempts_postfix":"failed attempt(s)", - "message_reset_warning":"User data will be wiped on next failed attempt" + "message_reset_warning":"User data will be wiped on next failed attempt", + "biometric_desc":"Scan your biometric to continue" }, "alert": { "success": "Success!", diff --git a/src/screens/pinCode/container/pinCodeContainer.js b/src/screens/pinCode/container/pinCodeContainer.js index 687045d1b..5a93caf94 100644 --- a/src/screens/pinCode/container/pinCodeContainer.js +++ b/src/screens/pinCode/container/pinCodeContainer.js @@ -102,6 +102,7 @@ class PinCodeContainer extends Component { _processBiometric = async () => { try { const { + intl, pinCodeParams: { isReset }, applicationPinCode, isBiometricEnabled, @@ -114,7 +115,9 @@ class PinCodeContainer extends Component { const biometryType = await FingerprintScanner.isSensorAvailable(); console.log('biometryType is => ', biometryType); - await FingerprintScanner.authenticate(); + await FingerprintScanner.authenticate({ + description: intl.formatMessage({ id: 'pincode.biometric_desc' }), + }); console.log('successfully passed biometric auth'); //code gets here means biometeric succeeded From 70990e3b86c95921ad7153f5fa6f134a3218ee3a Mon Sep 17 00:00:00 2001 From: noumantahir Date: Tue, 26 Jul 2022 22:06:30 +0500 Subject: [PATCH 08/11] updated fingerprint package and added release routine --- package.json | 2 +- src/screens/pinCode/container/pinCodeContainer.js | 6 ++++++ yarn.lock | 5 ++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 85b8b58a7..6696d682e 100644 --- a/package.json +++ b/package.json @@ -93,7 +93,7 @@ "react-native-dynamic": "^1.0.0", "react-native-extended-stylesheet": "^0.10.0", "react-native-fast-image": "^8.3.2", - "react-native-fingerprint-scanner": "^6.0.0", + "react-native-fingerprint-scanner": "hieuvp/react-native-fingerprint-scanner", "react-native-gesture-handler": "^1.9.0", "react-native-highlight-words": "^1.0.1", "react-native-iap": "^7.5.6", diff --git a/src/screens/pinCode/container/pinCodeContainer.js b/src/screens/pinCode/container/pinCodeContainer.js index 5a93caf94..7726d8042 100644 --- a/src/screens/pinCode/container/pinCodeContainer.js +++ b/src/screens/pinCode/container/pinCodeContainer.js @@ -128,11 +128,14 @@ class PinCodeContainer extends Component { } catch (err) { console.warn('Failed to process biometric', err); } + + FingerprintScanner.release(); }; //this function updates realm with appropriate master key required for encyrption //this function is important: must run while chaning pin //and even logging in with existing pin code + //TODO: make sure this routine is not called _updatePinCodeRealm = async (pinData) => { try { const { currentAccount, dispatch } = this.props; @@ -256,12 +259,14 @@ class PinCodeContainer extends Component { } = this.props; const { oldPinCode } = this.state; + //TOOD: make sure user is set with defualt pin here. const pinData = { pinCode: pin, password: currentAccount ? currentAccount.password : '', username: currentAccount ? currentAccount.name : '', accessToken, }; + setUserDataWithPinCode(pinData).then((response) => { getUser(currentAccount.name).then((user) => { const _currentAccount = user; @@ -390,6 +395,7 @@ class PinCodeContainer extends Component { }); }); + //TODO: make sure pinCode is rather saved as different redux state, encryptedUnlockPin _savePinCode = (pin) => { const { dispatch } = this.props; const encryptedPin = encryptKey(pin, Config.PIN_KEY); diff --git a/yarn.lock b/yarn.lock index 80633aee1..1b30c18a4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8782,10 +8782,9 @@ react-native-fast-image@^8.3.2: resolved "https://registry.yarnpkg.com/react-native-fast-image/-/react-native-fast-image-8.3.4.tgz#79edca177e30311b19d59ff335625bcbe22650d7" integrity sha512-LpzAdjUphihUpVEBn5fEv5AILe55rHav0YiZroPZ1rumKDhAl4u2cG01ku2Pb7l8sayjTsNu7FuURAlXUUDsow== -react-native-fingerprint-scanner@^6.0.0: +react-native-fingerprint-scanner@hieuvp/react-native-fingerprint-scanner: version "6.0.0" - resolved "https://registry.yarnpkg.com/react-native-fingerprint-scanner/-/react-native-fingerprint-scanner-6.0.0.tgz#ecb47ad0682d2a66a5e126d2b9e4d95e73c8dbf2" - integrity sha512-8VoKSA0Z0kWnIni96yABZfUUzfmWFXQEXcELwWr1CNLloPt3WoPptYb/6pGsBcH0YxSsW3X4+C8tl0clgyBsvA== + resolved "https://codeload.github.com/hieuvp/react-native-fingerprint-scanner/tar.gz/9cecc0db326471c571553ea85f7c016fee2f803d" react-native-flipper@^0.34.0: version "0.34.0" From 0b10062a9804ead5e1acf323e7a8508aeb7edd8a Mon Sep 17 00:00:00 2001 From: noumantahir Date: Tue, 26 Jul 2022 22:10:13 +0500 Subject: [PATCH 09/11] updated translation --- src/config/locales/en-US.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config/locales/en-US.json b/src/config/locales/en-US.json index b28ba99f3..82271b924 100644 --- a/src/config/locales/en-US.json +++ b/src/config/locales/en-US.json @@ -421,7 +421,7 @@ "pin_not_matched":"PIN do not match, Please try again.", "attempts_postfix":"failed attempt(s)", "message_reset_warning":"User data will be wiped on next failed attempt", - "biometric_desc":"Scan your biometric to continue" + "biometric_desc":"Scan your fingerprint on the device scanner to continue" }, "alert": { "success": "Success!", From d2cb3f6c7e67c369f12361f31b1e6f43317e977a Mon Sep 17 00:00:00 2001 From: noumantahir Date: Tue, 26 Jul 2022 22:12:12 +0500 Subject: [PATCH 10/11] revert TODO comments --- src/screens/pinCode/container/pinCodeContainer.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/screens/pinCode/container/pinCodeContainer.js b/src/screens/pinCode/container/pinCodeContainer.js index 7726d8042..a0f1b4884 100644 --- a/src/screens/pinCode/container/pinCodeContainer.js +++ b/src/screens/pinCode/container/pinCodeContainer.js @@ -135,7 +135,7 @@ class PinCodeContainer extends Component { //this function updates realm with appropriate master key required for encyrption //this function is important: must run while chaning pin //and even logging in with existing pin code - //TODO: make sure this routine is not called + _updatePinCodeRealm = async (pinData) => { try { const { currentAccount, dispatch } = this.props; @@ -259,7 +259,6 @@ class PinCodeContainer extends Component { } = this.props; const { oldPinCode } = this.state; - //TOOD: make sure user is set with defualt pin here. const pinData = { pinCode: pin, password: currentAccount ? currentAccount.password : '', @@ -395,7 +394,6 @@ class PinCodeContainer extends Component { }); }); - //TODO: make sure pinCode is rather saved as different redux state, encryptedUnlockPin _savePinCode = (pin) => { const { dispatch } = this.props; const encryptedPin = encryptKey(pin, Config.PIN_KEY); From a2e095dcf9e91bec02d9234b5f55ec9c6552fd6d Mon Sep 17 00:00:00 2001 From: Nouman Tahir Date: Thu, 28 Jul 2022 12:17:45 +0500 Subject: [PATCH 11/11] updated logic failed token injection report --- src/config/ecencyApi.ts | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/src/config/ecencyApi.ts b/src/config/ecencyApi.ts index 47f92fe24..c58b89376 100644 --- a/src/config/ecencyApi.ts +++ b/src/config/ecencyApi.ts @@ -17,39 +17,42 @@ const api = axios.create({ api.interceptors.request.use((request) => { console.log('Starting ecency Request', request); - + //skip code addition is register and token refresh endpoint is triggered - if(request.url === '/private-api/account-create' - || request.url === '/auth-api/hs-token-refresh' + if (request.url === '/private-api/account-create' + || request.url === '/auth-api/hs-token-refresh' || request.url === '/private-api/promoted-entries' || request.url.startsWith('private-api/leaderboard') || request.url.startsWith('/private-api/received-vesting/') || request.url.startsWith('/private-api/referrals/') || request.url.startsWith('/private-api/market-data') || request.url.startsWith('/private-api/comment-history') - ){ + ) { return request } - //decrypt access token - const state = store.getState(); - const token = get(state, 'account.currentAccount.local.accessToken'); - const pin = get(state, 'application.pin'); - const digitPinCode = getDigitPinCode(pin); - const accessToken = decryptKey(token, digitPinCode); + if (!request.data?.code) { + //if access code not already set, decrypt access token + const state = store.getState(); + const token = get(state, 'account.currentAccount.local.accessToken'); + const pin = get(state, 'application.pin'); + const digitPinCode = getDigitPinCode(pin); + const accessToken = decryptKey(token, digitPinCode); - if (accessToken && !request.data?.code ) { - if (!request.data){ - request.data = {}; + if (accessToken) { + if (!request.data) { + request.data = {}; + } + request.data.code = accessToken; + console.log('Added access token:', accessToken); + } else { + const isLoggedIn = state.application.isLoggedIn; + console.warn("Failed to inject accessToken", `isLoggedIn:${isLoggedIn}`) + bugsnagInstance.notify(new Error(`Failed to inject accessToken in ${request.url} call. isLoggedIn:${isLoggedIn}, local.acccessToken:${token}, pin:${pin}`)) } - request.data.code = accessToken; - console.log('Added access token:', accessToken); - } else { - const isLoggedIn = state.application.isLoggedIn; - console.warn("Failed to inject accessToken", `isLoggedIn:${isLoggedIn}`) - bugsnagInstance.notify(new Error(`Failed to inject accessToken in ${request.url} call. isLoggedIn:${isLoggedIn}`)) } + return request; });