Skip to content

Adds OAuth Controller required for seedless onboarding #14889

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

Open
wants to merge 37 commits into
base: main
Choose a base branch
from

Conversation

ieow
Copy link

@ieow ieow commented Apr 25, 2025

Description

Integration the following social login via the OAuth Service and SeedlessController,

Google
Apple

Proposed Authentication Flow using seedless onboarding
Screenshot 2025-04-29 at 8 25 46 PM

This PR mainly integrate the Seedless Controller and the OAuthServices into Metamask.
It does not include the Login UI Flow.
The Login UI Flow will be added on top of the new SRP UI Flow

Related issues

Fixes:

Manual testing steps

  1. Go to this page...

Screenshots/Recordings

Before

After

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Copy link
Contributor

github-actions bot commented Apr 25, 2025

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@ieow
Copy link
Author

ieow commented Apr 28, 2025

I have read the CLA Document and I hereby sign the CLA

@chaitanyapotti chaitanyapotti added the No QA Needed Apply this label when your PR does not need any QA effort. label Apr 28, 2025
@chaitanyapotti chaitanyapotti marked this pull request as ready for review April 29, 2025 09:17
@chaitanyapotti chaitanyapotti requested review from a team as code owners April 29, 2025 09:17
@chaitanyapotti chaitanyapotti changed the title Feat/main seedless onboarding controller integration Adds OAuth Controller required for seedless onboarding Apr 29, 2025
@@ -0,0 +1,80 @@
import { AuthSessionResult } from 'expo-auth-session';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chaitanyapotti I would recommend that you add these directories to the .github/CODEOWNERS file.

Copy link
Contributor

@Cal-L Cal-L left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments

} from '@metamask/seedless-onboarding-controller';
import { Encryptor, LEGACY_DERIVATION_OPTIONS } from '../../../Encryptor';

export const web3AuthNetwork = process.env.Web3AuthNetwork as Web3AuthNetwork;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export const web3AuthNetwork = process.env.Web3AuthNetwork as Web3AuthNetwork;
export const web3AuthNetwork = process.env.WEB3_AUTH_NETWORK as Web3AuthNetwork;

Also, should this be moved into a constants file or just use the env var inline

export const web3AuthNetwork = process.env.Web3AuthNetwork as Web3AuthNetwork;

if (!web3AuthNetwork) {
throw new Error('Missing environment variables');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
throw new Error('Missing environment variables');
throw new Error('Missing environment variable WEB3_AUTH_NETWORK');

}

const encryptor = new Encryptor({
keyDerivationOptions: LEGACY_DERIVATION_OPTIONS,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not familiar with the different types of derivation options but I know we're using it in many places. @ccharly Can you take a look at this if it's fine?

) {
return baseControllerMessenger.getRestricted({
name: 'SeedlessOnboardingController',
allowedEvents: [],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have visibility to the seedless onboarding controller. Does the controller use actions or events of other controllers?

@@ -485,5 +485,8 @@
}
]
}
},
"SeedlessOnboardingController": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be safe, let's also create a new migration to prepopulate the controller with this state

@@ -332,6 +340,7 @@
"react-native-fs": "^2.20.0",
"react-native-gesture-handler": "^1.10.3",
"react-native-get-random-values": "^1.8.0",
"react-native-google-acm": "git+https://github.com/Web3Auth/react-native-google-acm.git#edf4e52397f766d56d1644d908246e358f3cf774",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we bypass the paid version by forking our own and adding our own implementation?

}

export class OAuthService {
public localState: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extract types

ReduxService.store.dispatch({
type: UserActionType.LOADING_SET,
payload: {
loadingMsg: 'Logging in...',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not necessary to pass in payload since this is static. We can just set it in the reducer itself

data: AuthResponse,
authConnection: AuthConnection,
): Promise<{
type: 'success' | 'error';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extract into enum

}

if (!AuthServerUrl || !AuthConnectionId || !GroupedAuthConnectionId) {
throw new Error('Missing environment variables');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move this condition to the top of the file below imports and specify explicitly, which env vars are missing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-onboarding No QA Needed Apply this label when your PR does not need any QA effort. team-web3auth
Projects
Status: Needs dev review
Development

Successfully merging this pull request may close these issues.

4 participants