-
Notifications
You must be signed in to change notification settings - Fork 48
Reference mobile App for TOTP & Push-Based Authentication #195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
DilshanSenarath
wants to merge
51
commits into
asgardeo:main
from
DilshanSenarath:authenticator-app-sample
Closed
Changes from all commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
37412b8
init the authenticator app code base
DilshanSenarath 91b257b
add theme provider
DilshanSenarath f1f8b68
add support to scan qr codes
DilshanSenarath f6ed065
add qr code scanning functionality
DilshanSenarath 29dc8db
add basic push registration implementation
DilshanSenarath 53ac840
add the initial implementation for device regsitration
DilshanSenarath 5d7cc01
implement the crypto service
DilshanSenarath f3eabe0
implement secure storage service
DilshanSenarath 42c2d15
implement async storage
DilshanSenarath e0ba121
implement the firebase messaging core
DilshanSenarath 7afde43
refactor the push device registration logic
DilshanSenarath f94486d
handle error scenarios of push device registration
DilshanSenarath 955fccf
implemenet push authentication implementation
DilshanSenarath 17fbc27
add the logic to display accounts
DilshanSenarath 0770ef9
add totp base implementation
DilshanSenarath fcf4507
add totp generation support for crypto service
DilshanSenarath cfb73f0
add the basic totp implementation
DilshanSenarath 1f4b72f
add push shared account support
DilshanSenarath 86faa01
add support to remove accounts
DilshanSenarath aa9e532
implement totp view
DilshanSenarath dc11749
improve totp view UI
DilshanSenarath 33a7cca
implement push login history page
DilshanSenarath 53247c5
improve app notification view
DilshanSenarath ba93522
add logos and support for totp algorithm and digits
DilshanSenarath ad6db0a
fix the issues in push and totp regsitration flows
DilshanSenarath a003283
fix the background notification issue
DilshanSenarath c5d3fc4
add local authentication for the app
DilshanSenarath e4fcdc4
fix the UI issues
DilshanSenarath 000b5e2
fix styling issues
DilshanSenarath b4c7a5b
init the config and docs
DilshanSenarath 9011479
fix the styling issue
DilshanSenarath ed23df5
update logic extract the host name
DilshanSenarath bb17c33
add domain excluded username
DilshanSenarath 8c5d38b
handle undefined username
DilshanSenarath 3d6830d
handle user store domain
DilshanSenarath 21dd5ce
add deployment configurations
DilshanSenarath ab382ee
add asgardeo root context
DilshanSenarath 2545cf2
refactor the app screens
DilshanSenarath 2093bbb
refactor the home and common components
DilshanSenarath 2ddcb13
honer the stored preference when resolving the theme
DilshanSenarath 14f2ea3
refactor the qr screen code
DilshanSenarath 5be4056
refactor the account deletion logic
DilshanSenarath 30079dc
refactor the push screens
DilshanSenarath 6b0bd14
remove ai instruction file
DilshanSenarath 8a511f1
add instruction file
DilshanSenarath fc5d3f5
add authentication for app opening
DilshanSenarath 67fb2dc
add camera icon support for alert
DilshanSenarath 0f4d237
rename files
DilshanSenarath 058e23c
refactor the code base to have default import
DilshanSenarath 5ea13db
add ending colons
DilshanSenarath dc30069
add full logo for the app header
DilshanSenarath File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| # Copilot Instructions: React Native Sample App Code Review | ||
|
|
||
| ## 🎯 Purpose | ||
| You are reviewing a **React Native sample mobile application** intended to serve as a **reference implementation** for other developers. | ||
| Your goal is to ensure that the codebase is **clean, maintainable, secure, and follows React Native best practices**. | ||
|
|
||
| --- | ||
|
|
||
| ## 🔍 Review Objectives | ||
|
|
||
| ### 1. Code Quality & Structure | ||
| - Ensure the code follows modern **React Native and React** best practices: | ||
| - Prefer **functional components** and **React Hooks**. | ||
| - Use clear and descriptive **naming conventions**. | ||
| - Maintain a **modular structure** with reusable components. | ||
| - Verify that files are logically organized (e.g., `screens/`, `components/`, `hooks/`, `services/`, `assets/`). | ||
| - Identify and highlight **unused code**, constants, or imports. | ||
| - Suggest improvements to **readability** and **maintainability**. | ||
|
|
||
| ### 2. Performance & Optimization | ||
| - Detect potential performance bottlenecks: | ||
| - Unnecessary re-renders. | ||
| - Heavy computations inside render functions. | ||
| - Missing cleanup functions in `useEffect`. | ||
| - Suggest using **`useMemo`**, **`useCallback`**, or **FlatList optimizations** where appropriate. | ||
| - Ensure proper and efficient **image handling**. | ||
|
|
||
| ### 3. Best Practices | ||
| - Ensure **TypeScript** or **PropTypes** are used for type safety. | ||
| - Check for consistent **error handling** and **async flow management**. | ||
| - Confirm configuration values are **not hardcoded** — use environment variables or config files. | ||
| - Verify clean and consistent **navigation setup** (e.g., React Navigation). | ||
| - Review **styling** consistency — recommend StyleSheet, Tailwind, or styled-components, avoiding inline duplication. | ||
|
|
||
| ### 4. Security & Data Handling | ||
| - Ensure no sensitive information (API keys, tokens, credentials) is committed. | ||
| - Suggest secure methods for environment variable management. | ||
| - Validate that local storage (AsyncStorage, MMKV, etc.) safely handles user data. | ||
|
|
||
| ### 5. Documentation & Comments | ||
| - Check if major modules, hooks, or components have brief, meaningful comments. | ||
| - Recommend improvements to the **README** for developer onboarding. | ||
| - Suggest adding usage examples or developer notes for clarity. | ||
|
|
||
| ### 6. Code-Level Issues | ||
| - Identify **linting**, **formatting**, or **naming inconsistencies**. | ||
| - Point out **deprecated APIs** or outdated React Native patterns. | ||
| - Detect **potential bugs**, logical flaws, or anti-patterns. | ||
| - Recommend adding or improving **unit tests** if missing. | ||
|
|
||
| --- | ||
|
|
||
| ## ✅ Expected Output Format | ||
|
|
||
| Copilot should provide structured feedback like this: | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| # Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files | ||
DilshanSenarath marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # dependencies | ||
| node_modules/ | ||
|
|
||
| # Expo | ||
| .expo/ | ||
| dist/ | ||
| web-build/ | ||
| expo-env.d.ts | ||
|
|
||
| # Native | ||
| .kotlin/ | ||
| *.orig.* | ||
| *.jks | ||
| *.p8 | ||
| *.p12 | ||
| *.key | ||
| *.mobileprovision | ||
|
|
||
| # Metro | ||
| .metro-health-check* | ||
|
|
||
| # debug | ||
| npm-debug.* | ||
| yarn-debug.* | ||
| yarn-error.* | ||
|
|
||
| # macOS | ||
| .DS_Store | ||
| *.pem | ||
|
|
||
| # local env files | ||
| .env*.local | ||
|
|
||
| # typescript | ||
| *.tsbuildinfo | ||
|
|
||
| app-example | ||
|
|
||
| android | ||
| ios | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "editor.codeActionsOnSave": { | ||
| "source.fixAll": "explicit", | ||
| "source.organizeImports": "explicit", | ||
| "source.sortMembers": "explicit" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| # Welcome to your Expo app 👋 | ||
|
|
||
| This is an [Expo](https://expo.dev) project created with [`create-expo-app`](https://www.npmjs.com/package/create-expo-app). | ||
|
|
||
| ## Get started | ||
|
|
||
| 1. Install dependencies | ||
|
|
||
| ```bash | ||
| npm install | ||
| ``` | ||
|
|
||
| 2. Start the app | ||
|
|
||
| ```bash | ||
| npx expo start | ||
| ``` | ||
|
|
||
| In the output, you'll find options to open the app in a | ||
|
|
||
| - [development build](https://docs.expo.dev/develop/development-builds/introduction/) | ||
| - [Android emulator](https://docs.expo.dev/workflow/android-studio-emulator/) | ||
| - [iOS simulator](https://docs.expo.dev/workflow/ios-simulator/) | ||
| - [Expo Go](https://expo.dev/go), a limited sandbox for trying out app development with Expo | ||
|
|
||
| You can start developing by editing the files inside the **app** directory. This project uses [file-based routing](https://docs.expo.dev/router/introduction). | ||
|
|
||
| ## Get a fresh project | ||
|
|
||
| When you're ready, run: | ||
|
|
||
| ```bash | ||
| npm run reset-project | ||
| ``` | ||
|
|
||
| This command will move the starter code to the **app-example** directory and create a blank **app** directory where you can start developing. | ||
|
|
||
| ## Learn more | ||
|
|
||
| To learn more about developing your project with Expo, look at the following resources: | ||
|
|
||
| - [Expo documentation](https://docs.expo.dev/): Learn fundamentals, or go into advanced topics with our [guides](https://docs.expo.dev/guides). | ||
| - [Learn Expo tutorial](https://docs.expo.dev/tutorial/introduction/): Follow a step-by-step tutorial where you'll create a project that runs on Android, iOS, and the web. | ||
|
|
||
| ## Join the community | ||
|
|
||
| Join our community of developers creating universal apps. | ||
|
|
||
| - [Expo on GitHub](https://github.com/expo/expo): View our open source platform and contribute. | ||
| - [Discord community](https://chat.expo.dev): Chat with Expo users and ask questions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| { | ||
| "expo": { | ||
| "name": "Asgardeo", | ||
| "slug": "Asgardeo", | ||
| "version": "1.0.0", | ||
| "orientation": "portrait", | ||
| "icon": "./assets/images/logo-icon.png", | ||
| "scheme": "authenticatorapp", | ||
| "userInterfaceStyle": "automatic", | ||
| "newArchEnabled": true, | ||
| "ios": { | ||
| "config": { | ||
| "usesNonExemptEncryption": false | ||
| }, | ||
| "supportsTablet": true, | ||
| "infoPlist": { | ||
| "NSCameraUsageDescription": "This app needs access to the camera to scan QR codes.", | ||
| "UIBackgroundModes": [ | ||
| "remote-notification" | ||
| ] | ||
| }, | ||
| "bundleIdentifier": "io.asgardeo.dev.push.totp.authenticator", | ||
| "googleServicesFile": "./config/GoogleService-Info.plist", | ||
| "entitlements": { | ||
| "aps-environment": "production" | ||
| } | ||
| }, | ||
| "android": { | ||
| "adaptiveIcon": { | ||
| "foregroundImage": "./assets/images/logo-icon.png", | ||
| "backgroundColor": "#ffffff" | ||
| }, | ||
| "edgeToEdgeEnabled": true, | ||
| "package": "io.asgardeo.dev.push.totp.authenticator", | ||
| "permissions": [ | ||
| "CAMERA", | ||
| "android.permission.CAMERA", | ||
| "android.permission.RECORD_AUDIO" | ||
| ], | ||
| "googleServicesFile": "./config/google-services.json" | ||
| }, | ||
| "web": { | ||
| "bundler": "metro", | ||
| "output": "static", | ||
| "favicon": "./assets/images/logo-icon.png" | ||
| }, | ||
| "plugins": [ | ||
| "expo-router", | ||
| "@react-native-firebase/app", | ||
| "@react-native-firebase/messaging", | ||
| [ | ||
| "expo-camera", | ||
| { | ||
| "cameraPermission": "Allow this app to access your camera to scan QR codes." | ||
| } | ||
| ], | ||
| [ | ||
| "expo-splash-screen", | ||
| { | ||
| "image": "./assets/images/logo-icon.png", | ||
| "imageWidth": 200, | ||
| "resizeMode": "contain", | ||
| "backgroundColor": "#ffffff" | ||
| } | ||
| ], | ||
| [ | ||
| "expo-secure-store", | ||
| { | ||
| "configureAndroidBackup": true | ||
| } | ||
| ], | ||
| [ | ||
| "expo-build-properties", | ||
| { | ||
| "ios": { | ||
| "useFrameworks": "static" | ||
| } | ||
| } | ||
| ], | ||
| [ | ||
| "expo-local-authentication", | ||
| { | ||
| "faceIDPermission": "Allow $(PRODUCT_NAME) to use Face ID." | ||
| } | ||
| ] | ||
| ], | ||
| "experiments": { | ||
| "typedRoutes": true | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| /** | ||
| * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com). | ||
| * | ||
| * WSO2 LLC. licenses this file to you under the Apache License, | ||
| * Version 2.0 (the "License"); you may not use this file except | ||
| * in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| import AccountHeaderRight from "../src/components/account/AccountHeaderRight"; | ||
| import { Stack } from "expo-router"; | ||
| import { ReactElement, useEffect, useState } from "react"; | ||
| import HeaderTitle from "../src/components/common/HeaderTitle"; | ||
| import { ThemeConfigs } from "../src/models/ui"; | ||
| import AsgardeoProvider from "../src/contexts/asgardeo/AsgardeoProvider"; | ||
| import AppPaths from "../src/constants/AppPaths"; | ||
| import Theme from "../src/utils/Theme"; | ||
|
|
||
| const theme: ThemeConfigs = Theme.getInstance().getConfigs(); | ||
|
|
||
| /** | ||
| * Root Layout component. | ||
| * | ||
| * @returns Root Layout component. | ||
| */ | ||
| const RootLayout = (): ReactElement => { | ||
| const [mounted, setMounted] = useState(false); | ||
|
|
||
| /** | ||
| * Sets the mounted state to true when the component is mounted. | ||
| */ | ||
| useEffect(() => { | ||
| setMounted(true); | ||
| }, []); | ||
|
|
||
| return ( | ||
| <AsgardeoProvider isAppInitialized={mounted}> | ||
| <Stack> | ||
| <Stack.Screen | ||
| name={AppPaths.ROOT} | ||
| options={{ | ||
| headerShown: false | ||
| }} | ||
| /> | ||
| <Stack.Screen | ||
| name={AppPaths.HOME} | ||
| options={{ | ||
| headerStyle: { backgroundColor: theme.colors.header.background }, | ||
| headerTitle: HeaderTitle | ||
| }} | ||
| /> | ||
| <Stack.Screen | ||
| name={AppPaths.QR_SCANNER} | ||
| options={{ | ||
| headerShown: false, | ||
| presentation: "modal" | ||
| }} | ||
| /> | ||
| <Stack.Screen | ||
| name={AppPaths.PUSH_AUTH} | ||
| options={{ | ||
| headerShown: false | ||
| }} | ||
| /> | ||
| <Stack.Screen | ||
| name={AppPaths.ACCOUNT} | ||
| options={({ route }) => ({ | ||
| headerStyle: { backgroundColor: theme.colors.header.background }, | ||
| headerTitle: HeaderTitle, | ||
| headerRight: (): ReactElement => <AccountHeaderRight params={route.params as Record<string, string>} /> | ||
| })} | ||
| /> | ||
| <Stack.Screen | ||
| name={AppPaths.PUSH_AUTH_HISTORY} | ||
| options={({ route }) => ({ | ||
| headerStyle: { backgroundColor: theme.colors.header.background }, | ||
| headerTitle: HeaderTitle, | ||
| headerRight: (): ReactElement => <AccountHeaderRight params={route.params as Record<string, string>} /> | ||
| })} | ||
| /> | ||
| </Stack> | ||
| </AsgardeoProvider> | ||
| ); | ||
| } | ||
|
|
||
| export default RootLayout; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| /** | ||
| * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com). | ||
| * | ||
| * WSO2 LLC. licenses this file to you under the Apache License, | ||
| * Version 2.0 (the "License"); you may not use this file except | ||
| * in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| import { useLocalSearchParams } from "expo-router"; | ||
| import { FunctionComponent, ReactElement } from "react"; | ||
| import TOTPCode from "../src/components/account/TOTPCode"; | ||
|
|
||
| /** | ||
| * Account Screen component. | ||
| * | ||
| * @returns Account screen component. | ||
| */ | ||
| const AccountScreen: FunctionComponent = (): ReactElement | null => { | ||
| const { id } = useLocalSearchParams<{ id: string }>(); | ||
|
|
||
| return ( | ||
| <TOTPCode id={id} /> | ||
| ); | ||
| } | ||
|
|
||
| export default AccountScreen; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.