Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 4 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@metamask/sdk": "^0.33.0",
"@react-native-async-storage/async-storage": "2.1.2",
"@react-native-community/netinfo": "11.4.1",
"@react-native-google-signin/google-signin": "^14.0.1",
"@react-native-google-signin/google-signin": "^18.0.0",
"@react-navigation/native": "^7.1.6",
"@walletconnect/react-native-compat": "^2.20.1",
"@walletconnect/react-native-dapp": "^1.8.0",
Expand All @@ -32,7 +32,6 @@
"expo": "53.0.11",
"expo-apple-authentication": "^7.2.4",
"expo-application": "6.1.4",
"expo-auth-session": "^6.2.0",
"expo-blur": "~14.1.4",
"expo-build-properties": "0.14.6",
"expo-clipboard": "~7.1.4",
Expand Down
27 changes: 20 additions & 7 deletions src/contexts/AuthContext.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import React, { createContext, useContext, useEffect, useState, ReactNode } from 'react';
import AsyncStorage from '@react-native-async-storage/async-storage';
import * as Google from 'expo-auth-session/providers/google';
import {
GoogleOneTapSignIn,
isSuccessResponse,
isNoSavedCredentialFoundResponse,
} from '@react-native-google-signin/google-signin';
import * as AppleAuthentication from 'expo-apple-authentication';
import * as Keychain from 'react-native-keychain';
import * as Passkey from 'react-native-passkey';
Expand Down Expand Up @@ -45,6 +49,10 @@ export function AuthProvider({ children }: AuthProviderProps) {
apiService.setAuthExpiredHandler(() => logout());
}, []);

useEffect(() => {
GoogleOneTapSignIn.configure({ webClientId: 'autoDetect' });
}, []);

useEffect(() => {
initializeAuth();
}, []);
Expand Down Expand Up @@ -171,12 +179,17 @@ export function AuthProvider({ children }: AuthProviderProps) {
}

if (config.strategy === 'google') {
const result = await Google.logInAsync({
clientId: process.env.EXPO_PUBLIC_GOOGLE_CLIENT_ID || '',
scopes: ['profile', 'email'],
});
if (result.type !== 'success') throw new Error('Google login cancelled');
providerToken = result.idToken || '';
await GoogleOneTapSignIn.checkPlayServices();
const result = await GoogleOneTapSignIn.signIn();
if (isNoSavedCredentialFoundResponse(result)) {
const explicit = await GoogleOneTapSignIn.presentExplicitSignIn();
if (!isSuccessResponse(explicit)) throw new Error('Google login cancelled');
providerToken = explicit.data.idToken ?? '';
} else if (isSuccessResponse(result)) {
providerToken = result.data.idToken ?? '';
} else {
throw new Error('Google login failed');
}
} else if (config.strategy === 'apple') {
const res = await AppleAuthentication.signInAsync({
requestedScopes: [AppleAuthentication.AppleAuthenticationScope.EMAIL],
Expand Down