Skip to content

Commit

Permalink
Refactoring of the registration, verification, and login processes (#75)
Browse files Browse the repository at this point in the history
* update package.json

add @react-native-async-storage/async-storage

* Implement a new logic for device verification

* Close the current session before opening the signup page

* Change ConfirmDevice page to use the new public key name (with oid)

* The getCustomer function shouldn't run if there's no oid or public key

* Axios requestInterceptor and responseInterceptorError logic changed

* Store oid in secure store and Fix idToken iss compare problem

* Implement new sign up process

* The device verification process has been moved to after the Azure sign up process.
* Store the private key and the public key with the oid.
* Improve WelcomeScreen by handling new errors.

* Implement page type on WelcomeStack to fix the signup and login process

* Change App ready state logic

* Request tracking permission for azure signup.
* Check app first install.

* Update package.json

install expo-tracking-transparency package

* Refactor azureService functions

* Implement renew token function.
* Change logout function
* Change getUserSession function

* Change AzureAuthProvider to add email and phoneNumber

* Refactor createCustomer and useCustomer functions

* Fix auth related types

* Implement AppStateContext to handle the registration process

* Fix balances refetch interval

* Fix transactions refetch interval

* Remove unnecessary code in logout function

* Change ConsumerRegistration to set isRegistered on success response

* Refactor UserProfile to handle failed requests and retry them

* Refactor axios functions

* Create functions.ts: Implement all necessary functions

* remove expo-constants from App.ts

* Add retry option to useAccount query

* Add logout functionality to ConfirmDevice screen

* Add disabled state to Create account button

* Implement retryFetchData function in UserProfile and Withdraw components

* Remove error notification in SignIn component

* Fix renew function in authService

* Remove unnecessary codes from customer context

* Remove Sentry integration

* Removed unused code from App.tsx

* Change error handling in axios.ts

* Fix device verification and remove some unused functions

* Refactor WelcomeStack

* fix checkScreenLockMechanism type issue

* Deleted all old verification tests and wrote new ones.

* Fix Consumer Registration tests

* Remove oid and tokens on fresh install

* fix biometric support check function

* Implement account removal

* Update FullScreenMessage component with background and text color options

* Add RemoveAccount menu item

* Implement ConsumerRegistration screen input validation

* Export QPA_TOKEN_KEY enum in authStorageService to be used in other files

* Update customerContext.interface.ts with additional properties and types

* Update period value in SecurityCode to 120 seconds

* No need to logout on signup

* Update CustomerContext to include is_business property in state and handle customer different status

* Change getCustomer function to handle error response

* Update biometric validation logic and OTP code handling

* Fix axios retry on 401 error to handle token refresh

* Refactor ConfirmDevice to handle the second device issue

* Refactor WelcomeStack to work with new logic

* remove useless code on getCustomer func

* Removed unused functions

* removed console log on biometricValidation catch

* delete useDeviceVerification file

* remove useDeviceHasScreenLock file

* Update package.json: testPathIgnorePatterns added to test script

* There are some tests that need to be changed. They were temporarily skipped.

* There are some tests that need to be changed. They were temporarily skipped.

* Fix some tests for BalanceList, TransactionList, and PaymentRequestsList

* remove useBiometricValidation file (unused)

* Fix SecureStore key types: SECURE_STORE_KEYS

* Fix customer status types: CustomerStateType

* Update ci-test in package.json to skip some tests

* Remove some comments

---------

Co-authored-by: Wayne <[email protected]>
  • Loading branch information
arash817 and WJRobert authored Apr 17, 2024
1 parent 28d896a commit 142fdcb
Show file tree
Hide file tree
Showing 52 changed files with 4,835 additions and 21,229 deletions.
62 changes: 36 additions & 26 deletions mobile/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,28 @@ import { appNavigationState } from "./src/config/config";
import FullScreenLoadingSpinner from "./src/components/FullScreenLoadingSpinner";
import { CustomerProvider } from "./src/context/CustomerContext";
import { Feather } from "@expo/vector-icons";
import * as Sentry from "sentry-expo";
import Constants from "expo-constants";
import { ToastProvider } from "./src/context/NotificationContext";
import { AppStateProvider } from './src/context/AppStateContext';
import { removeStoredData } from "./src/utils/functions";
import AsyncStorage from "@react-native-async-storage/async-storage";
import { QPA_TOKEN_KEY } from "./src/auth/authStorageService";
import { SECURE_STORE_KEYS } from "./src/auth/types";

const prefix = Linking.createURL("/");
const queryClient = new QueryClient();

Sentry.init({
dsn: Constants.expoConfig?.extra?.SENTRY_DSN,
enableInExpoDevelopment:
Constants.expoConfig?.extra?.APP_ENV !== "development",
debug: Constants.expoConfig?.extra?.APP_ENV !== "development",
});
const APP_INSTALLED_KEY = 'APP_INSTALLED';

async function checkAppInstalled() {
const appInstalled = await AsyncStorage.getItem(APP_INSTALLED_KEY);
if (!appInstalled) {
await AsyncStorage.setItem(APP_INSTALLED_KEY, 'true');
// remove oid
await removeStoredData([SECURE_STORE_KEYS.OID, QPA_TOKEN_KEY.QPA_ACCESS_TOKEN, QPA_TOKEN_KEY.QPA_ID_TOKEN, QPA_TOKEN_KEY.QPA_REFRESH_TOKEN]);
}

return true;
}
export default function App() {
const [appReady, setAppReady] = useState(false);

Expand All @@ -43,23 +51,23 @@ export default function App() {
config: appNavigationState,
};

const loadFontsAsync = async() => {
await Font.loadAsync({
"Lato-Light": require("./assets/fonts/Lato-Light.ttf"),
"Lato-Regular": require("./assets/fonts/Lato-Regular.ttf"),
"Lato-Bold": require("./assets/fonts/Lato-Bold.ttf"),
});
await Font.loadAsync(FontAwesome5.font);
await Font.loadAsync(Ionicons.font);
await Font.loadAsync(Feather.font);
await checkAppInstalled();
setAppReady(true);
}
useEffect(() => {
async function loadFontsAsync() {
await Font.loadAsync({
"Lato-Light": require("./assets/fonts/Lato-Light.ttf"),
"Lato-Regular": require("./assets/fonts/Lato-Regular.ttf"),
"Lato-Bold": require("./assets/fonts/Lato-Bold.ttf"),
});
await Font.loadAsync(FontAwesome5.font);
await Font.loadAsync(Ionicons.font);
await Font.loadAsync(Feather.font);

setAppReady(true);
}

loadFontsAsync();
}, []);


if (!appReady) {
return null;
}
Expand All @@ -75,11 +83,13 @@ export default function App() {
>
<QueryClientProvider client={queryClient}>
<CustomerProvider>
<ToastProvider>
<ErrorBoundary>
<WelcomeStackNavigator />
</ErrorBoundary>
</ToastProvider>
<ToastProvider>
<ErrorBoundary>
<AppStateProvider>
<WelcomeStackNavigator />
</AppStateProvider>
</ErrorBoundary>
</ToastProvider>
</CustomerProvider>
</QueryClientProvider>
</NavigationContainer>
Expand Down
Loading

0 comments on commit 142fdcb

Please sign in to comment.