@onairos/react-native 3.0.51 → 3.0.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/components/EmailVerificationModal.js +2 -2
- package/lib/commonjs/components/EmailVerificationModal.js.map +1 -1
- package/lib/commonjs/components/TrainingModal.js.map +1 -1
- package/lib/commonjs/components/UniversalOnboarding.js +173 -46
- package/lib/commonjs/components/UniversalOnboarding.js.map +1 -1
- package/lib/commonjs/services/platformAuthService.js +69 -55
- package/lib/commonjs/services/platformAuthService.js.map +1 -1
- package/lib/module/components/EmailVerificationModal.js +2 -2
- package/lib/module/components/EmailVerificationModal.js.map +1 -1
- package/lib/module/components/TrainingModal.js.map +1 -1
- package/lib/module/components/UniversalOnboarding.js +171 -44
- package/lib/module/components/UniversalOnboarding.js.map +1 -1
- package/lib/module/index.js +8 -70
- package/lib/module/index.js.map +1 -1
- package/lib/module/services/platformAuthService.js +69 -55
- package/lib/module/services/platformAuthService.js.map +1 -1
- package/lib/typescript/components/UniversalOnboarding.d.ts.map +1 -1
- package/lib/typescript/services/platformAuthService.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/components/EmailVerificationModal.tsx +2 -2
- package/src/components/TrainingModal.tsx +59 -59
- package/src/components/UniversalOnboarding.tsx +212 -74
- package/src/services/platformAuthService.ts +89 -78
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
Switch,
|
|
17
17
|
Linking,
|
|
18
18
|
Alert,
|
|
19
|
+
TextInput,
|
|
19
20
|
} from 'react-native';
|
|
20
21
|
import Icon from 'react-native-vector-icons/MaterialIcons';
|
|
21
22
|
import { PlatformList } from './PlatformList';
|
|
@@ -25,12 +26,23 @@ import { OAuthWebView } from './onboarding/OAuthWebView';
|
|
|
25
26
|
import { useConnections } from '../hooks/useConnections';
|
|
26
27
|
import { COLORS, DEEP_LINK_CONFIG } from '../constants';
|
|
27
28
|
import { initiateOAuth, initiateNativeAuth, hasNativeSDK, isOAuthCallback, testApiConnectivity, handleOAuthCallbackUrl, refreshYouTubeTokens, requestEmailVerification, verifyEmailCode, checkEmailVerificationStatus, disconnectPlatform } from '../services/platformAuthService';
|
|
29
|
+
import { EmailVerificationModal } from './EmailVerificationModal';
|
|
28
30
|
import type { UniversalOnboardingProps, ConnectionStatus } from '../types';
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
|
|
32
|
+
// Optional Opacity SDK imports with error handling
|
|
33
|
+
let opacityInit: any = null;
|
|
34
|
+
let OpacityEnvironment: any = null;
|
|
35
|
+
let opacityGet: any = null;
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
const opacitySDK = require('@opacity-labs/react-native-opacity');
|
|
39
|
+
opacityInit = opacitySDK.init;
|
|
40
|
+
OpacityEnvironment = opacitySDK.OpacityEnvironment;
|
|
41
|
+
opacityGet = opacitySDK.get;
|
|
42
|
+
} catch (error) {
|
|
43
|
+
console.warn('Opacity SDK not available:', error);
|
|
44
|
+
// Opacity SDK will be disabled if not available
|
|
45
|
+
}
|
|
34
46
|
|
|
35
47
|
const { height, width } = Dimensions.get('window');
|
|
36
48
|
|
|
@@ -49,7 +61,7 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
|
|
|
49
61
|
auto = false,
|
|
50
62
|
partner,
|
|
51
63
|
}) => {
|
|
52
|
-
const [step, setStep] = useState<'connect' | 'pin' | 'training' | 'oauth' | 'success'>('
|
|
64
|
+
const [step, setStep] = useState<'email' | 'connect' | 'pin' | 'training' | 'oauth' | 'success'>('email');
|
|
53
65
|
const [connections, setConnections] = useState<ConnectionStatus>({});
|
|
54
66
|
const [pin, setPin] = useState<string>('');
|
|
55
67
|
const [selectedTier, setSelectedTier] = useState<'Small' | 'Medium' | 'Large'>('Medium');
|
|
@@ -64,6 +76,8 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
|
|
|
64
76
|
const [username, setUsername] = useState<string>('Avatar');
|
|
65
77
|
const [isConnectingPlatform, setIsConnectingPlatform] = useState<boolean>(false);
|
|
66
78
|
const [showLoginWebView, setShowLoginWebView] = useState<boolean>(false);
|
|
79
|
+
const [email, setEmail] = useState<string>('');
|
|
80
|
+
const [showEmailVerification, setShowEmailVerification] = useState<boolean>(false);
|
|
67
81
|
|
|
68
82
|
// Add refs for cleanup
|
|
69
83
|
const successTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
@@ -74,7 +88,7 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
|
|
|
74
88
|
{ id: 'youtube', name: 'YouTube', icon: require('../assets/images/youtube.png') },
|
|
75
89
|
{ id: 'reddit', name: 'Reddit', icon: require('../assets/images/reddit.png') },
|
|
76
90
|
{ id: 'pinterest', name: 'Pinterest', icon: require('../assets/images/pinterest.png') },
|
|
77
|
-
{ id: 'email', name: '
|
|
91
|
+
{ id: 'email', name: 'Gmail', icon: require('../assets/images/email.png') },
|
|
78
92
|
];
|
|
79
93
|
|
|
80
94
|
const {
|
|
@@ -223,8 +237,25 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
|
|
|
223
237
|
|
|
224
238
|
console.log('✅ API connectivity confirmed');
|
|
225
239
|
|
|
226
|
-
// Instagram: Use Opacity SDK exclusively
|
|
240
|
+
// Instagram: Use Opacity SDK exclusively (if available)
|
|
227
241
|
if (platformId === 'instagram') {
|
|
242
|
+
// Check if Opacity SDK is available
|
|
243
|
+
if (!opacityInit || !OpacityEnvironment || !opacityGet) {
|
|
244
|
+
console.warn('⚠️ Opacity SDK not available, falling back to OAuth for Instagram');
|
|
245
|
+
// Fall back to OAuth flow for Instagram
|
|
246
|
+
const oauthUrl = await initiateOAuth(platformId, username, AppName);
|
|
247
|
+
|
|
248
|
+
if (oauthUrl) {
|
|
249
|
+
console.log(`✅ Received OAuth URL for ${platformId}:`, oauthUrl);
|
|
250
|
+
setCurrentPlatform(platformId);
|
|
251
|
+
setOauthUrl(oauthUrl);
|
|
252
|
+
setStep('oauth');
|
|
253
|
+
} else {
|
|
254
|
+
throw new Error(`Failed to get authorization URL for ${platformId}. Please try again.`);
|
|
255
|
+
}
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
|
|
228
259
|
console.log('🔌 Initializing Opacity SDK for Instagram...');
|
|
229
260
|
|
|
230
261
|
// Initialize Opacity SDK with your API key
|
|
@@ -275,39 +306,39 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
|
|
|
275
306
|
}
|
|
276
307
|
} else {
|
|
277
308
|
// For all other platforms (non-Instagram), check if they have native SDK
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
309
|
+
if (hasNativeSDK(platformId)) {
|
|
310
|
+
console.log(`📱 Using native SDK for ${platformId}`);
|
|
311
|
+
// Use native SDK for authentication
|
|
281
312
|
const success = await initiateNativeAuth(platformId, username);
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
313
|
+
if (success) {
|
|
314
|
+
console.log(`✅ Native authentication successful for ${platformId}`);
|
|
315
|
+
// Update platform toggle state
|
|
316
|
+
setPlatformToggles(prev => ({
|
|
317
|
+
...prev,
|
|
318
|
+
[platformId]: true
|
|
319
|
+
}));
|
|
320
|
+
|
|
321
|
+
// Update connections state
|
|
322
|
+
setConnections(prev => ({
|
|
323
|
+
...prev,
|
|
324
|
+
[platformId]: { userName: username, connected: true }
|
|
325
|
+
}));
|
|
295
326
|
} else {
|
|
296
327
|
throw new Error(`Native authentication failed for ${platformId}`);
|
|
297
|
-
|
|
298
|
-
|
|
328
|
+
}
|
|
329
|
+
} else {
|
|
299
330
|
// Use OAuth WebView flow
|
|
300
|
-
|
|
331
|
+
console.log(`🌐 Initiating OAuth flow for ${platformId}`);
|
|
301
332
|
|
|
302
|
-
|
|
333
|
+
const oauthUrl = await initiateOAuth(platformId, username, AppName);
|
|
303
334
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
335
|
+
if (oauthUrl) {
|
|
336
|
+
console.log(`✅ Received OAuth URL for ${platformId}:`, oauthUrl);
|
|
337
|
+
setCurrentPlatform(platformId);
|
|
338
|
+
setOauthUrl(oauthUrl);
|
|
339
|
+
setStep('oauth');
|
|
340
|
+
} else {
|
|
341
|
+
console.error(`❌ No OAuth URL returned for ${platformId}`);
|
|
311
342
|
throw new Error(`Failed to get authorization URL for ${platformId}. Please try again.`);
|
|
312
343
|
}
|
|
313
344
|
}
|
|
@@ -419,11 +450,7 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
|
|
|
419
450
|
setStep('connect');
|
|
420
451
|
}, [currentPlatform, username]);
|
|
421
452
|
|
|
422
|
-
|
|
423
|
-
const handleAlreadyHaveAccount = useCallback(() => {
|
|
424
|
-
console.log('Already have an account clicked - opening Onairos login WebView');
|
|
425
|
-
setShowLoginWebView(true);
|
|
426
|
-
}, []);
|
|
453
|
+
|
|
427
454
|
|
|
428
455
|
// Function to check for existing account (spoofed for now)
|
|
429
456
|
const checkExistingAccount = useCallback(async () => {
|
|
@@ -433,24 +460,50 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
|
|
|
433
460
|
return false;
|
|
434
461
|
}, []);
|
|
435
462
|
|
|
436
|
-
// Function to handle
|
|
437
|
-
const
|
|
438
|
-
|
|
439
|
-
|
|
463
|
+
// Function to handle email submission
|
|
464
|
+
const handleEmailSubmit = useCallback(() => {
|
|
465
|
+
if (!email.trim()) {
|
|
466
|
+
Alert.alert('Error', 'Please enter your email address');
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
440
469
|
|
|
441
|
-
//
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
470
|
+
// Basic email validation
|
|
471
|
+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
472
|
+
if (!emailRegex.test(email.trim())) {
|
|
473
|
+
Alert.alert('Error', 'Please enter a valid email address');
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
console.log('📧 Email submitted:', email.trim());
|
|
478
|
+
setShowEmailVerification(true);
|
|
479
|
+
}, [email]);
|
|
480
|
+
|
|
481
|
+
// Function to handle email verification completion
|
|
482
|
+
const handleEmailVerificationComplete = useCallback((verifiedEmail: string, isExistingUser: boolean) => {
|
|
483
|
+
console.log('✅ Email verification completed:', { verifiedEmail, isExistingUser });
|
|
484
|
+
setShowEmailVerification(false);
|
|
485
|
+
|
|
486
|
+
if (isExistingUser) {
|
|
487
|
+
console.log('Existing user detected, skipping onboarding');
|
|
445
488
|
onComplete('https://api2.onairos.uk', 'existing-session-token', {
|
|
446
489
|
existingAccount: true,
|
|
447
|
-
|
|
490
|
+
email: verifiedEmail,
|
|
448
491
|
skipOnboarding: true,
|
|
449
492
|
});
|
|
493
|
+
} else {
|
|
494
|
+
console.log('New user, proceeding to platform connection');
|
|
495
|
+
setUsername(verifiedEmail.split('@')[0]); // Use email prefix as username
|
|
496
|
+
setStep('connect');
|
|
450
497
|
}
|
|
451
|
-
// If no existing account found, continue with normal onboarding
|
|
452
498
|
}, [onComplete]);
|
|
453
499
|
|
|
500
|
+
// Function to handle email verification failure
|
|
501
|
+
const handleEmailVerificationFailed = useCallback((error: string) => {
|
|
502
|
+
console.error('❌ Email verification failed:', error);
|
|
503
|
+
setShowEmailVerification(false);
|
|
504
|
+
Alert.alert('Verification Failed', error);
|
|
505
|
+
}, []);
|
|
506
|
+
|
|
454
507
|
const handlePinSubmit = useCallback(async (userPin: string) => {
|
|
455
508
|
setPin(userPin);
|
|
456
509
|
setStep('training');
|
|
@@ -575,6 +628,43 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
|
|
|
575
628
|
<View style={styles.handle} />
|
|
576
629
|
</View>
|
|
577
630
|
|
|
631
|
+
{step === 'email' && (
|
|
632
|
+
<View style={styles.emailInputContainer}>
|
|
633
|
+
<View style={styles.emailHeader}>
|
|
634
|
+
<View style={styles.onairosIcon}>
|
|
635
|
+
<Image
|
|
636
|
+
source={require('../assets/images/onairos_logo.png')}
|
|
637
|
+
style={styles.onairosLogo}
|
|
638
|
+
resizeMode="contain"
|
|
639
|
+
/>
|
|
640
|
+
</View>
|
|
641
|
+
<Text style={styles.emailTitle}>Welcome to Onairos</Text>
|
|
642
|
+
<Text style={styles.emailSubtitle}>Enter your email to get started</Text>
|
|
643
|
+
</View>
|
|
644
|
+
|
|
645
|
+
<View style={styles.emailInputSection}>
|
|
646
|
+
<TextInput
|
|
647
|
+
style={styles.emailInput}
|
|
648
|
+
value={email}
|
|
649
|
+
onChangeText={setEmail}
|
|
650
|
+
placeholder="Enter your email address"
|
|
651
|
+
keyboardType="email-address"
|
|
652
|
+
autoCapitalize="none"
|
|
653
|
+
autoCorrect={false}
|
|
654
|
+
autoFocus
|
|
655
|
+
/>
|
|
656
|
+
|
|
657
|
+
<TouchableOpacity
|
|
658
|
+
style={[styles.emailSubmitButton, !email.trim() && styles.emailSubmitButtonDisabled]}
|
|
659
|
+
onPress={handleEmailSubmit}
|
|
660
|
+
disabled={!email.trim()}
|
|
661
|
+
>
|
|
662
|
+
<Text style={styles.emailSubmitButtonText}>Continue</Text>
|
|
663
|
+
</TouchableOpacity>
|
|
664
|
+
</View>
|
|
665
|
+
</View>
|
|
666
|
+
)}
|
|
667
|
+
|
|
578
668
|
{step === 'connect' && (
|
|
579
669
|
<>
|
|
580
670
|
{/* Header with app icon and arrow to Onairos icon */}
|
|
@@ -587,17 +677,15 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
|
|
|
587
677
|
</View>
|
|
588
678
|
<Icon name="arrow-forward" size={24} color="#666" style={styles.arrow} />
|
|
589
679
|
<View style={styles.onairosIcon}>
|
|
590
|
-
<
|
|
680
|
+
<Image
|
|
681
|
+
source={require('../assets/images/onairos_logo.png')}
|
|
682
|
+
style={styles.onairosLogo}
|
|
683
|
+
resizeMode="contain"
|
|
684
|
+
/>
|
|
591
685
|
</View>
|
|
592
686
|
</View>
|
|
593
687
|
|
|
594
|
-
|
|
595
|
-
<TouchableOpacity
|
|
596
|
-
style={styles.alreadyHaveAccountButton}
|
|
597
|
-
onPress={handleAlreadyHaveAccount}
|
|
598
|
-
>
|
|
599
|
-
<Text style={styles.alreadyHaveAccountText}>Already have an account?</Text>
|
|
600
|
-
</TouchableOpacity>
|
|
688
|
+
|
|
601
689
|
</View>
|
|
602
690
|
|
|
603
691
|
<ScrollView
|
|
@@ -751,16 +839,17 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
|
|
|
751
839
|
/>
|
|
752
840
|
)}
|
|
753
841
|
|
|
754
|
-
{/*
|
|
755
|
-
{
|
|
756
|
-
<
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
onClose={() =>
|
|
760
|
-
|
|
761
|
-
|
|
842
|
+
{/* Email Verification Modal */}
|
|
843
|
+
{showEmailVerification && (
|
|
844
|
+
<EmailVerificationModal
|
|
845
|
+
visible={showEmailVerification}
|
|
846
|
+
email={email.trim()}
|
|
847
|
+
onClose={() => setShowEmailVerification(false)}
|
|
848
|
+
onVerificationComplete={handleEmailVerificationComplete}
|
|
849
|
+
onVerificationFailed={handleEmailVerificationFailed}
|
|
762
850
|
/>
|
|
763
851
|
)}
|
|
852
|
+
|
|
764
853
|
</SafeAreaView>
|
|
765
854
|
</Animated.View>
|
|
766
855
|
</TouchableWithoutFeedback>
|
|
@@ -838,6 +927,10 @@ const styles = StyleSheet.create({
|
|
|
838
927
|
fontSize: 24,
|
|
839
928
|
color: '#000',
|
|
840
929
|
},
|
|
930
|
+
onairosLogo: {
|
|
931
|
+
width: 32,
|
|
932
|
+
height: 32,
|
|
933
|
+
},
|
|
841
934
|
titleContainer: {
|
|
842
935
|
marginBottom: 20,
|
|
843
936
|
},
|
|
@@ -924,14 +1017,7 @@ const styles = StyleSheet.create({
|
|
|
924
1017
|
fontSize: 16,
|
|
925
1018
|
fontWeight: '600',
|
|
926
1019
|
},
|
|
927
|
-
|
|
928
|
-
paddingVertical: 8,
|
|
929
|
-
paddingHorizontal: 16,
|
|
930
|
-
},
|
|
931
|
-
alreadyHaveAccountText: {
|
|
932
|
-
color: '#666',
|
|
933
|
-
fontSize: 16,
|
|
934
|
-
},
|
|
1020
|
+
|
|
935
1021
|
successContainer: {
|
|
936
1022
|
flex: 1,
|
|
937
1023
|
justifyContent: 'center',
|
|
@@ -1008,4 +1094,56 @@ const styles = StyleSheet.create({
|
|
|
1008
1094
|
color: '#000',
|
|
1009
1095
|
marginLeft: 8,
|
|
1010
1096
|
},
|
|
1097
|
+
// Email input styles
|
|
1098
|
+
emailInputContainer: {
|
|
1099
|
+
flex: 1,
|
|
1100
|
+
justifyContent: 'center',
|
|
1101
|
+
alignItems: 'center',
|
|
1102
|
+
padding: 24,
|
|
1103
|
+
},
|
|
1104
|
+
emailHeader: {
|
|
1105
|
+
alignItems: 'center',
|
|
1106
|
+
marginBottom: 32,
|
|
1107
|
+
},
|
|
1108
|
+
emailTitle: {
|
|
1109
|
+
fontSize: 24,
|
|
1110
|
+
fontWeight: '600',
|
|
1111
|
+
color: '#000',
|
|
1112
|
+
textAlign: 'center',
|
|
1113
|
+
marginTop: 16,
|
|
1114
|
+
marginBottom: 8,
|
|
1115
|
+
},
|
|
1116
|
+
emailSubtitle: {
|
|
1117
|
+
fontSize: 16,
|
|
1118
|
+
color: '#666',
|
|
1119
|
+
textAlign: 'center',
|
|
1120
|
+
},
|
|
1121
|
+
emailInputSection: {
|
|
1122
|
+
width: '100%',
|
|
1123
|
+
maxWidth: 320,
|
|
1124
|
+
},
|
|
1125
|
+
emailInput: {
|
|
1126
|
+
borderWidth: 1,
|
|
1127
|
+
borderColor: '#ddd',
|
|
1128
|
+
borderRadius: 12,
|
|
1129
|
+
padding: 16,
|
|
1130
|
+
fontSize: 16,
|
|
1131
|
+
marginBottom: 16,
|
|
1132
|
+
backgroundColor: '#fff',
|
|
1133
|
+
},
|
|
1134
|
+
emailSubmitButton: {
|
|
1135
|
+
backgroundColor: '#4CAF50',
|
|
1136
|
+
paddingVertical: 16,
|
|
1137
|
+
paddingHorizontal: 32,
|
|
1138
|
+
borderRadius: 12,
|
|
1139
|
+
alignItems: 'center',
|
|
1140
|
+
},
|
|
1141
|
+
emailSubmitButtonDisabled: {
|
|
1142
|
+
opacity: 0.5,
|
|
1143
|
+
},
|
|
1144
|
+
emailSubmitButtonText: {
|
|
1145
|
+
color: '#fff',
|
|
1146
|
+
fontSize: 16,
|
|
1147
|
+
fontWeight: '600',
|
|
1148
|
+
},
|
|
1011
1149
|
});
|
|
@@ -42,7 +42,7 @@ let PLATFORM_AUTH_CONFIG: Record<string, PlatformAuthConfig> = {
|
|
|
42
42
|
},
|
|
43
43
|
email: {
|
|
44
44
|
hasNativeSDK: false,
|
|
45
|
-
authEndpoint: 'https://api2.onairos.uk/
|
|
45
|
+
authEndpoint: 'https://api2.onairos.uk/gmail/authorize',
|
|
46
46
|
color: '#4285F4',
|
|
47
47
|
},
|
|
48
48
|
};
|
|
@@ -206,32 +206,40 @@ export const initiateOAuth = async (platform: string, username: string, appName?
|
|
|
206
206
|
* @returns A Promise that resolves to the authentication result
|
|
207
207
|
*/
|
|
208
208
|
export const initiateNativeAuth = async (platform: string, username?: string): Promise<boolean> => {
|
|
209
|
-
|
|
209
|
+
if (platform === 'youtube') {
|
|
210
210
|
console.log('🔗 Initiating native Google Sign-In for YouTube');
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
211
|
+
try {
|
|
212
|
+
// Check if Google Sign-In package is available
|
|
213
|
+
let GoogleSignin, statusCodes;
|
|
214
|
+
try {
|
|
215
|
+
const googleSignInModule = require('@react-native-google-signin/google-signin');
|
|
216
|
+
GoogleSignin = googleSignInModule.GoogleSignin;
|
|
217
|
+
statusCodes = googleSignInModule.statusCodes;
|
|
218
|
+
} catch (importError) {
|
|
219
|
+
console.error('❌ Google Sign-In package not available:', importError);
|
|
220
|
+
throw new Error('Google Sign-In SDK not installed. Please install @react-native-google-signin/google-signin');
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// Configure Google Sign-In
|
|
224
|
+
await GoogleSignin.configure({
|
|
217
225
|
webClientId: '1030678346906-lovkuds2ouqmoc8eu5qpo98spa6edv4o.apps.googleusercontent.com', // Replace with your web client ID
|
|
218
226
|
iosClientId: '1030678346906-lovkuds2ouqmoc8eu5qpo98spa6edv4o.apps.googleusercontent.com', // Replace with your iOS client ID
|
|
219
|
-
|
|
227
|
+
scopes: ['https://www.googleapis.com/auth/youtube.readonly'],
|
|
220
228
|
offlineAccess: true, // CRITICAL: This ensures we get refresh tokens
|
|
221
|
-
|
|
229
|
+
hostedDomain: '',
|
|
222
230
|
forceCodeForRefreshToken: true, // CRITICAL: Force refresh token on first sign-in
|
|
223
231
|
accountName: '', // Clear to avoid conflicts
|
|
224
|
-
|
|
225
|
-
|
|
232
|
+
});
|
|
233
|
+
|
|
226
234
|
// Check if Google Play Services are available
|
|
227
|
-
|
|
228
|
-
|
|
235
|
+
await GoogleSignin.hasPlayServices();
|
|
236
|
+
|
|
229
237
|
// Sign in with Google
|
|
230
|
-
|
|
238
|
+
const userInfo = await GoogleSignin.signIn();
|
|
231
239
|
console.log('✅ Google Sign-In successful:', userInfo.user?.email);
|
|
232
|
-
|
|
240
|
+
|
|
233
241
|
// Get access token for API calls
|
|
234
|
-
|
|
242
|
+
const tokens = await GoogleSignin.getTokens();
|
|
235
243
|
console.log('🔑 Got Google tokens');
|
|
236
244
|
|
|
237
245
|
// Get current user info with refresh token
|
|
@@ -371,23 +379,23 @@ export const initiateNativeAuth = async (platform: string, username?: string): P
|
|
|
371
379
|
return false;
|
|
372
380
|
}
|
|
373
381
|
|
|
374
|
-
|
|
382
|
+
} catch (error: any) {
|
|
375
383
|
console.error('❌ Google Sign-In error:', error);
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
384
|
+
|
|
385
|
+
const { statusCodes: StatusCodes } = require('@react-native-google-signin/google-signin');
|
|
386
|
+
|
|
387
|
+
if (error.code === StatusCodes.SIGN_IN_CANCELLED) {
|
|
380
388
|
console.log('User cancelled Google Sign-In');
|
|
381
|
-
|
|
389
|
+
} else if (error.code === StatusCodes.IN_PROGRESS) {
|
|
382
390
|
console.log('Google Sign-In already in progress');
|
|
383
|
-
|
|
391
|
+
} else if (error.code === StatusCodes.PLAY_SERVICES_NOT_AVAILABLE) {
|
|
384
392
|
console.log('Google Play Services not available');
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
return false;
|
|
385
396
|
}
|
|
386
|
-
|
|
387
|
-
return false;
|
|
388
397
|
}
|
|
389
|
-
|
|
390
|
-
|
|
398
|
+
|
|
391
399
|
return false;
|
|
392
400
|
};
|
|
393
401
|
|
|
@@ -626,7 +634,7 @@ export const requestEmailVerification = async (email: string): Promise<{
|
|
|
626
634
|
try {
|
|
627
635
|
console.log('📧 Requesting email verification for:', email);
|
|
628
636
|
|
|
629
|
-
const response = await fetch('https://api2.onairos.uk/email/
|
|
637
|
+
const response = await fetch('https://api2.onairos.uk/email/verification', {
|
|
630
638
|
method: 'POST',
|
|
631
639
|
headers: {
|
|
632
640
|
'Content-Type': 'application/json',
|
|
@@ -666,36 +674,37 @@ export const verifyEmailCode = async (email: string, code: string): Promise<{
|
|
|
666
674
|
}> => {
|
|
667
675
|
try {
|
|
668
676
|
console.log('🔍 Verifying email code for:', email);
|
|
677
|
+
console.log('🔍 Development mode: All codes will pass through for now');
|
|
669
678
|
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
console.log('
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
message: result.message || 'Email verified successfully',
|
|
686
|
-
};
|
|
687
|
-
} else {
|
|
688
|
-
console.error('❌ Email verification failed:', result.error);
|
|
689
|
-
return {
|
|
690
|
-
success: false,
|
|
691
|
-
error: result.error || 'Invalid verification code',
|
|
692
|
-
};
|
|
679
|
+
// For now, allow all codes to pass through
|
|
680
|
+
// Still make the API call to set up the routing, but don't rely on response
|
|
681
|
+
try {
|
|
682
|
+
const response = await fetch('https://api2.onairos.uk/email/verification', {
|
|
683
|
+
method: 'POST',
|
|
684
|
+
headers: {
|
|
685
|
+
'Content-Type': 'application/json',
|
|
686
|
+
},
|
|
687
|
+
body: JSON.stringify({ email, code, action: 'verify' }),
|
|
688
|
+
});
|
|
689
|
+
|
|
690
|
+
const result = await response.json();
|
|
691
|
+
console.log('📡 Email verification API response:', result);
|
|
692
|
+
} catch (apiError) {
|
|
693
|
+
console.warn('⚠️ Email verification API call failed, but continuing with bypass:', apiError);
|
|
693
694
|
}
|
|
695
|
+
|
|
696
|
+
// Always return success for now
|
|
697
|
+
console.log('✅ Email verification successful (bypass mode)');
|
|
698
|
+
return {
|
|
699
|
+
success: true,
|
|
700
|
+
message: 'Email verified successfully (development mode: all codes accepted)',
|
|
701
|
+
};
|
|
694
702
|
} catch (error) {
|
|
695
703
|
console.error('❌ Email verification error:', error);
|
|
704
|
+
// Even on error, return success for now
|
|
696
705
|
return {
|
|
697
|
-
success:
|
|
698
|
-
|
|
706
|
+
success: true,
|
|
707
|
+
message: 'Email verified successfully (development mode: all codes accepted)',
|
|
699
708
|
};
|
|
700
709
|
}
|
|
701
710
|
};
|
|
@@ -708,35 +717,37 @@ export const checkEmailVerificationStatus = async (email: string): Promise<{
|
|
|
708
717
|
}> => {
|
|
709
718
|
try {
|
|
710
719
|
console.log('🔍 Checking email verification status for:', email);
|
|
720
|
+
console.log('🔍 Development mode: Always returning no pending verification');
|
|
711
721
|
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
console.log('
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
isPending: result.isPending || false,
|
|
726
|
-
message: result.message || 'Status retrieved successfully',
|
|
727
|
-
};
|
|
728
|
-
} else {
|
|
729
|
-
console.error('❌ Email verification status check failed:', result.error);
|
|
730
|
-
return {
|
|
731
|
-
success: false,
|
|
732
|
-
error: result.error || 'Failed to check verification status',
|
|
733
|
-
};
|
|
722
|
+
// Make API call to set up routing, but don't rely on response for now
|
|
723
|
+
try {
|
|
724
|
+
const response = await fetch(`https://api2.onairos.uk/email/verification/status/${encodeURIComponent(email)}`, {
|
|
725
|
+
method: 'GET',
|
|
726
|
+
headers: {
|
|
727
|
+
'Content-Type': 'application/json',
|
|
728
|
+
},
|
|
729
|
+
});
|
|
730
|
+
|
|
731
|
+
const result = await response.json();
|
|
732
|
+
console.log('📡 Email verification status API response:', result);
|
|
733
|
+
} catch (apiError) {
|
|
734
|
+
console.warn('⚠️ Email verification status API call failed, but continuing with bypass:', apiError);
|
|
734
735
|
}
|
|
736
|
+
|
|
737
|
+
// For development, always return no pending verification
|
|
738
|
+
console.log('✅ Email verification status retrieved (bypass mode)');
|
|
739
|
+
return {
|
|
740
|
+
success: true,
|
|
741
|
+
isPending: false, // Always false so verification flow starts fresh
|
|
742
|
+
message: 'Status retrieved successfully (development mode)',
|
|
743
|
+
};
|
|
735
744
|
} catch (error) {
|
|
736
745
|
console.error('❌ Email verification status error:', error);
|
|
746
|
+
// Even on error, return success for development
|
|
737
747
|
return {
|
|
738
|
-
success:
|
|
739
|
-
|
|
748
|
+
success: true,
|
|
749
|
+
isPending: false,
|
|
750
|
+
message: 'Status retrieved successfully (development mode)',
|
|
740
751
|
};
|
|
741
752
|
}
|
|
742
753
|
};
|