Skip to content

Commit

Permalink
Feat: Security and bug fixes (#15)
Browse files Browse the repository at this point in the history
* Adding Boston package, Creating new account

* Fixing thenewboston, creating new account

* making pop-up(account success page)

* Connecting with bank in connect to the network

* implement transactions view

* Save storage for login info by using redux, update redux for login info

* State management of app data (Redux) - Completed

* Implement my Friends View

* Implement Friends and Account Balances from Server

* Implement Functions of Setting page

* Implement sending coins

* Fixing message ui view and implement exception in all pages

* Implement functions of exit, copy, share, new icon, exception

* Implement etc functions and all ui designs

* Fixing function of create account and making select control in send coin page

* only testing for create account

* Fixing send coins and checking create account and fixing hide password design

* Fixing create account function

* Fixing in using lib newboston, and some account functions

* QR code detect and fingerprint exception function

* Making platform iOS and fixing boston lib in ios

* Changing flow of create and sign account, adding ESP

* fixing new account flow and sign page like diagram

* changing cipher algorithm

* update key gen and cipher

* fixing refactoring / security

* fixing cipher and making function of connecting via qrcode and fingerprint

* changing Selecting From, To control as UI

* Implement Ed25519 cipher algorithm

* update Ios platform and fixing cipher

* Building IOS version in newboston

* Fixing Ed25519 cipher and building in iOS platform

* Fixing Ed25519 by using Tweentnacl Lib

* Fixing Carthage and building IOS

* Completing Ed25519 cipher by using tweetnacl lib

* Fixing QR code detection and running automatically by using deeplink

* updating building android platform

* Fixing QRcode and cleaning codes

* Fixing some bugs and releasing apk

* Fixing password and nickname

* Fixing ip hard-coding, and cleaning code

* commit all changes

* Fixing "connect to the network screen only on first time"

* Fixed #16, #17, #20, #21, #22, #23

* Fixing issue #18, #19 and readMe for android platform
  • Loading branch information
katolykdev authored Aug 9, 2021
1 parent d2db30c commit 827da98
Show file tree
Hide file tree
Showing 19,597 changed files with 63,016 additions and 3,140,954 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
Binary file modified .DS_Store
Binary file not shown.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,5 @@ android/.gradle/6.7/fileHashes/fileHashes.bin
android/.gradle/6.7/fileHashes/fileHashes.lock
android/.gradle/buildOutputCleanup/buildOutputCleanup.lock
android/.gradle/checksums/checksums.lock
android/.gradle/
android/.gradle
35 changes: 27 additions & 8 deletions App.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,41 @@
import * as React from "react";
import { View } from "react-native";
import React, { useEffect, useState } from "react";
import { Provider } from 'react-redux'
import Navigator from "./Navigator";
import { PersistGate } from 'redux-persist/integration/react';
import EncryptedStorage from 'react-native-encrypted-storage';
import configureStore from './src/store/store';
import { persistStore, persistReducer } from 'redux-persist';
const store = configureStore();
import { persistStore, persistReducer } from 'redux-persist';
const store = configureStore();
const persistor = persistStore(store);

const persistor = persistStore(store);

const App = (props) => {
const App = (props) => {
const [connect, setConnect] = useState(false);
const getConnectFlag = async () =>{
try {
const connectInfo = await EncryptedStorage.getItem("connect");
if (connectInfo == "1") {
setConnect(true);
}

}
catch (error) {
console.log(error);
}
}

useEffect(() => {
getConnectFlag();
}, []);


return (
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<Navigator />
<Navigator isLogin={!connect}/>
</PersistGate>
</Provider>
)
};
};

export default App;
182 changes: 121 additions & 61 deletions Navigator.tsx
Original file line number Diff line number Diff line change
@@ -1,42 +1,38 @@
import "react-native-gesture-handler";

import * as React from "react";
import { View, Text, Image } from "react-native";

import { DefaultTheme, NavigationContainer } from "@react-navigation/native";

import ConnectScreen from "./src/views/Connect/Connect";
import CreateAccountScreen from "./src/views/CreateAccount/CreateAccount";
import FriendsScreen from "./src/views/Friends/Friends";
import { View, Text, Image, PermissionsAndroid} from "react-native";
import LinearGradient from "react-native-linear-gradient";
import LoginPasswordScreen from "./src/views/LoginPassword/LoginPassword";
import LoginScreen from "./src/views/Login/Login";
import OverviewScreen from "./src/views/MyAccount/Overview";
import ScanCode from "./src/assets/svg/ScanCode.svg";
import SettingsScreen from "./src/views/Settings/Settings";
import SendCoins1Screen from "./src/views/SendCoins1/SendCoins1";
import SendCoins2Screen from "./src/views/SendCoins2/SendCoins2";
import EditAccountScreen from "./src/views/Settings/EditAccount/EditAccount";

import TNBLogo from "./src/assets/svg/TNBLogo.svg";
import { DefaultTheme, NavigationContainer } from "@react-navigation/native";
import { TouchableOpacity } from "react-native-gesture-handler";
import TransactionsScreen from "./src/views/Transactions/Transactions";
import * as ImagePicker from 'react-native-image-picker';
import { createBottomTabNavigator } from "@react-navigation/bottom-tabs";
import { createStackNavigator } from "@react-navigation/stack";
import { Colors, Custom, Typography } from "styles";
import QRCodeScreen from "./src/views/QRCode/QRcode";;

import ConnectScreen from "views/Connect/Connect";
import CreateAccountScreen from "views/CreateAccount/CreateAccount";
import FriendsScreen from "views/Friends/Friends";
import LoginPasswordScreen from "views/LoginPassword/LoginPassword";
import LoginScreen from "views/Login/Login";
import OverviewScreen from "views/MyAccount/Overview";
import SettingsScreen from "views/Settings/Settings";
import SendCoins1Screen from "views/SendCoins1/SendCoins1";
import SendCoins2Screen from "views/SendCoins2/SendCoins2";
import EditAccountScreen from "views/Settings/EditAccount/EditAccount";
import TransactionsScreen from "views/Transactions/Transactions";

// svg
import Home from "./src/assets/svg/Home.svg";
import Transactions from "./src/assets/svg/Transactions.svg";
import Friends from "./src/assets/svg/Friends.svg";
import Settings from "./src/assets/svg/Settings.svg";
import ArrowBack from "./src/assets/svg/ArrowBack.svg";
import Home from "assets/svg/Home.svg";
import Transactions from "assets/svg/Transactions.svg";
import Friends from "assets/svg/Friends.svg";
import Settings from "assets/svg/Settings.svg";
import ArrowBack from "assets/svg/ArrowBack.svg";
import ScanCode from "assets/svg/ScanCode.svg";
import TNBLogo from "assets/svg/TNBLogo.svg";


const Navigator = ({route}) => {
const Navigator = ({route, isLogin}) => {
const Stack = createStackNavigator();

return (
<LinearGradient
colors={["#62737E", "#040505"]}
Expand All @@ -46,7 +42,9 @@ const Navigator = ({route}) => {
locations={[0, 0.35]}
>
<NavigationContainer theme={MainTheme}>
<Stack.Navigator>
<Stack.Navigator
initialRouteName={isLogin ? "connec" : "login"}
>
<Stack.Screen
name="connec"
component={ConnectScreen}
Expand All @@ -55,21 +53,16 @@ const Navigator = ({route}) => {
}

/>
<Stack.Screen
name="createAccount"
component={CreateAccountScreen}
options={authHeaderOptions}
/>
<Stack.Screen
name="qrCodeScreen"
component={QRCodeScreen}
options={authHeaderOptions}
/>
<Stack.Screen
name="login"
component={LoginScreen}
options={authHeaderOptions}
/>
<Stack.Screen
name="createAccount"
component={CreateAccountScreen}
options={authHeaderOptions}
/>
<Stack.Screen
name="loginPassword"
component={LoginPasswordScreen}
Expand All @@ -78,7 +71,7 @@ const Navigator = ({route}) => {
<Stack.Screen
options={headerOptions}
name="tab"
component={TabNavigator}
component={TabNavigator}
/>
</Stack.Navigator>
</NavigationContainer>
Expand All @@ -88,13 +81,13 @@ const Navigator = ({route}) => {

const TabIcon = ({ icon, text, focused }) => {
return (
<View style={{ alignItems: "center", justifyContent: "center", top: 10 }}>
<View style={{ alignItems: "center", justifyContent: "center", top: -6, borderTopColor:'red', borderTopWidth: focused ? 2 : 0, paddingTop:11}}>
{icon}
<Text
style={{
color: focused ? "#FFF" : "#62737E",
fontSize: 10,
marginTop: 10,
marginTop: 8,
}}
>
{text}
Expand All @@ -104,15 +97,15 @@ const TabIcon = ({ icon, text, focused }) => {
};

const TabNavigator = ({route}) => {
const Tab = createBottomTabNavigator();
const Tab = createBottomTabNavigator();
return (
<Tab.Navigator
tabBarOptions={{ showLabel: false, style: tabStyle, keyboardHidesTabBar: true}}
initialRouteName="overview"
initialRouteName="overview"
>
<Tab.Screen
name="overview"
options={{
name="overview"
options={{
tabBarIcon: ({ focused }) => (
<TabIcon
text="My Accounts"
Expand All @@ -121,7 +114,9 @@ const TabNavigator = ({route}) => {
/>
),
}}
initialParams={{nickname: route.params.nickname, signingKeyHex: route.params.signingKeyHex, accountNumber: route.params.accountNumber, signingKey: route.params.signingKey, accounts: route.params.accounts, validator_accounts: route.params.validator_accounts,bank_url: route.params.bank_url, login: route.params.login}}
initialParams={{nickname: route.params.nickname, signingKeyHex: route.params.signingKeyHex,
accountNumber: route.params.accountNumber, signingKey: route.params.signingKey, accounts: route.params.accounts,
validator_accounts: route.params.validator_accounts,bank_url: route.params.bank_url, login: route.params.login, genKey: route.params.genKey}}
component={OverviewStackScreen}
/>
<Tab.Screen
Expand All @@ -135,7 +130,9 @@ const TabNavigator = ({route}) => {
/>
),
}}
initialParams={{nickname: route.params.nickname, signingKeyHex: route.params.signingKeyHex, accountNumber: route.params.accountNumber, signingKey: route.params.signingKey, accounts: route.params.accounts, validator_accounts: route.params.validator_accounts, bank_url: route.params.bank_url, login: route.params.login}}
initialParams={{nickname: route.params.nickname, signingKeyHex: route.params.signingKeyHex,
accountNumber: route.params.accountNumber, signingKey: route.params.signingKey, accounts: route.params.accounts,
validator_accounts: route.params.validator_accounts, bank_url: route.params.bank_url, login: route.params.login, genKey: route.params.genKey}}
component={TransactionsScreen}
/>
<Tab.Screen
Expand All @@ -149,7 +146,7 @@ const TabNavigator = ({route}) => {
/>
),
}}
initialParams={{nickname: route.params.nickname, signingKeyHex: route.params.signingKeyHex, accountNumber: route.params.accountNumber, signingKey: route.params.signingKey, accounts: route.params.accounts, validator_accounts: route.params.validator_accounts, bank_url: route.params.bank_url, login: route.params.login}}
initialParams={{nickname: route.params.nickname, signingKeyHex: route.params.signingKeyHex, accountNumber: route.params.accountNumber, signingKey: route.params.signingKey, accounts: route.params.accounts, validator_accounts: route.params.validator_accounts, bank_url: route.params.bank_url, login: route.params.login, genKey: route.params.genKey}}
component={FriendsScreen}
/>
<Tab.Screen
Expand Down Expand Up @@ -185,7 +182,7 @@ const SettingsStackScreen = ({route, navigation}) => {
stackheaderOptions("Edit nickname", navigation)
}
name="editaccount"
initialParams={{nickname: route.params.nickname}}
initialParams={{nickname: route.params.nickname, setNickName: route.params.setNickName}}
component={EditAccountScreen}
/>
</SettingStack.Navigator>
Expand All @@ -199,20 +196,20 @@ const OverviewStackScreen = ({route}) => {
<OverviewStack.Screen
options={{ headerShown: false }}
name="overview"
initialParams={{nickname: route.params.nickname, signingKeyHex: route.params.signingKeyHex, accountNumber: route.params.accountNumber, signingKey: route.params.signingKey, accounts: route.params.accounts, validator_accounts: route.params.validator_accounts, bank_url: route.params.bank_url, login: route.params.login}}
initialParams={{nickname: route.params.nickname, signingKeyHex: route.params.signingKeyHex, accountNumber: route.params.accountNumber, signingKey: route.params.signingKey, accounts: route.params.accounts, validator_accounts: route.params.validator_accounts, bank_url: route.params.bank_url, login: route.params.login, genKey: route.params.genKey}}
component={OverviewScreen}
/>
<OverviewStack.Screen
options={({ navigation }) =>
stackheaderOptions("Send Coins", navigation)
stackSendCoinheaderOptions("Send Coins", navigation)
}
name="sendcoins1"
initialParams={{validator_accounts: route.params.validator_accounts, bank_url: route.params.bank_url}}
component={SendCoins1Screen}
/>
<OverviewStack.Screen
options={({ navigation }) =>
stackheaderOptions("Send Coins", navigation)
stackSendCoinheaderOptions("Send Coins", navigation)
}
name="sendcoins2"
component={SendCoins2Screen}
Expand All @@ -239,6 +236,16 @@ const authHeaderOptions = {
headerLeft: () => <TNBLogo />,
};

const nonHeaderOptions = {
headerStyle: {
backgroundColor: "transparent",
elevation: 0,
shadowOpacity: 0,
},
headerTitle: "",
headerLeft: "",
};

const qrCodeHeaderOptions = (title, navigation) => {
return {
headerStyle: {
Expand All @@ -247,23 +254,51 @@ const qrCodeHeaderOptions = (title, navigation) => {
shadowOpacity: 0,
},
headerTitle: title,
headerRight: () => (
<TouchableOpacity onPress={() => navigation.navigate("qrCodeScreen")}>
<ScanCode />
</TouchableOpacity>
),
// headerRight: () => (
// <TouchableOpacity onPress={openCameraWithPermission}>
// <ScanCode />
// </TouchableOpacity>
// ),
headerLeft: () => <TNBLogo />,
};
};

const openCameraWithPermission = async() =>{
const granted = await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.CAMERA,
{
title: 'App Camera Permission',
message: 'App needs access to your camera ',
buttonNeutral: 'Ask Me Later',
buttonNegative: 'Cancel',
buttonPositive: 'OK',
},
);
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
ImagePicker.launchCamera(
{
mediaType: 'mixed',
includeBase64: false,
maxHeight: 200,
maxWidth: 200,
},
(response) => {
console.log(response);
},
);
} else {
console.log('Camera permission denied');
}
}

const headerOptions = {
headerStyle: {
backgroundColor: "transparent",
elevation: 0,
shadowOpacity: 0,
},
headerTitle: "",
headerLeft: () => null,
headerLeft: () => null,
};


Expand All @@ -283,6 +318,29 @@ const stackheaderOptions = (title, navigation) => {
};
};

const stackSendCoinheaderOptions = (title, navigation) => {
return {
headerStyle: {
elevation: 0,
shadowOpacity: 0,
backgroundColor: "transparent",
},
headerLeft: () => (
<TouchableOpacity style={{left:10}} onPress={() => navigation.goBack(null)}>
<ArrowBack />
</TouchableOpacity>
),
headerRight: () => (
<TouchableOpacity onPress={openCameraWithPermission}>
<ScanCode />
</TouchableOpacity>
),
headerTitle: () => <Text style={headingStyle}>{title}</Text>,
};
};



const tabStyle = {
position: "absolute",
bottom: 25,
Expand All @@ -291,9 +349,11 @@ const tabStyle = {
elevation: 0,
borderRadius: 16,
height: 65,
backgroundColor: "#2B4150",
borderWidth: 0,
borderColor: "#62737E",
backgroundColor: "linear-gradient(20.23deg, rgba(53, 96, 104, 0.6) -4.86%, rgba(29, 39, 49, 0.6) 110.32%)",
//borderWidth: 0,
borderColor: "#62737E",
// borderTopColor: 'red',
// borderTopWidth: 1,
};

const headingStyle = {
Expand Down
Loading

0 comments on commit 827da98

Please sign in to comment.