@onairos/react-native 3.0.66 โ†’ 3.0.67

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.
Files changed (27) hide show
  1. package/lib/commonjs/components/EmailVerificationModal.js +7 -6
  2. package/lib/commonjs/components/EmailVerificationModal.js.map +1 -1
  3. package/lib/commonjs/components/TrainingModal.js +17 -9
  4. package/lib/commonjs/components/TrainingModal.js.map +1 -1
  5. package/lib/commonjs/components/UniversalOnboarding.js +9 -9
  6. package/lib/commonjs/components/UniversalOnboarding.js.map +1 -1
  7. package/lib/commonjs/services/platformAuthService.js +80 -40
  8. package/lib/commonjs/services/platformAuthService.js.map +1 -1
  9. package/lib/module/components/EmailVerificationModal.js +7 -6
  10. package/lib/module/components/EmailVerificationModal.js.map +1 -1
  11. package/lib/module/components/TrainingModal.js +17 -9
  12. package/lib/module/components/TrainingModal.js.map +1 -1
  13. package/lib/module/components/UniversalOnboarding.js +9 -9
  14. package/lib/module/components/UniversalOnboarding.js.map +1 -1
  15. package/lib/module/services/platformAuthService.js +80 -40
  16. package/lib/module/services/platformAuthService.js.map +1 -1
  17. package/lib/typescript/components/EmailVerificationModal.d.ts +1 -0
  18. package/lib/typescript/components/EmailVerificationModal.d.ts.map +1 -1
  19. package/lib/typescript/components/TrainingModal.d.ts.map +1 -1
  20. package/lib/typescript/components/UniversalOnboarding.d.ts.map +1 -1
  21. package/lib/typescript/services/platformAuthService.d.ts +4 -3
  22. package/lib/typescript/services/platformAuthService.d.ts.map +1 -1
  23. package/package.json +1 -1
  24. package/src/components/EmailVerificationModal.tsx +10 -6
  25. package/src/components/TrainingModal.tsx +77 -67
  26. package/src/components/UniversalOnboarding.tsx +13 -11
  27. package/src/services/platformAuthService.ts +86 -38
@@ -20,6 +20,7 @@ export interface EmailVerificationModalProps {
20
20
  onClose: () => void;
21
21
  onVerificationComplete: (email: string, isExistingUser: boolean) => void;
22
22
  onVerificationFailed: (error: string) => void;
23
+ testMode?: boolean;
23
24
  }
24
25
 
25
26
  export const EmailVerificationModal: React.FC<EmailVerificationModalProps> = ({
@@ -28,6 +29,7 @@ export const EmailVerificationModal: React.FC<EmailVerificationModalProps> = ({
28
29
  onClose,
29
30
  onVerificationComplete,
30
31
  onVerificationFailed,
32
+ testMode = false,
31
33
  }) => {
32
34
  const [step, setStep] = useState<'request' | 'verify'>('request');
33
35
  const [verificationCode, setVerificationCode] = useState<string>('');
@@ -45,7 +47,7 @@ export const EmailVerificationModal: React.FC<EmailVerificationModalProps> = ({
45
47
  console.log('๐Ÿ“ง Requesting email verification for:', email);
46
48
 
47
49
  // First check if there's already a pending verification
48
- const statusCheck = await checkEmailVerificationStatus(email);
50
+ const statusCheck = await checkEmailVerificationStatus(email, testMode);
49
51
  if (statusCheck.success && statusCheck.isPending) {
50
52
  console.log('โœ… Email verification already pending');
51
53
  setCodeSent(true);
@@ -55,7 +57,7 @@ export const EmailVerificationModal: React.FC<EmailVerificationModalProps> = ({
55
57
  }
56
58
 
57
59
  // Request new verification code
58
- const result = await requestEmailVerification(email);
60
+ const result = await requestEmailVerification(email, testMode);
59
61
 
60
62
  if (result.success) {
61
63
  console.log('โœ… Email verification code requested successfully');
@@ -91,7 +93,7 @@ export const EmailVerificationModal: React.FC<EmailVerificationModalProps> = ({
91
93
  try {
92
94
  console.log('๐Ÿ” Verifying email code for:', email);
93
95
 
94
- const result = await verifyEmailCode(email, verificationCode.trim());
96
+ const result = await verifyEmailCode(email, verificationCode.trim(), testMode);
95
97
 
96
98
  if (result.success) {
97
99
  console.log('โœ… Email verification successful');
@@ -190,9 +192,11 @@ export const EmailVerificationModal: React.FC<EmailVerificationModalProps> = ({
190
192
  We've sent a 6-digit code to {email}
191
193
  </Text>
192
194
 
193
- <Text style={styles.testingNote}>
194
- ๐Ÿ” Development Mode: Any 6-digit code will work for verification
195
- </Text>
195
+ {testMode && (
196
+ <Text style={styles.testingNote}>
197
+ ๐Ÿ” Test Mode: Any 6-digit code will work for verification
198
+ </Text>
199
+ )}
196
200
 
197
201
  <TextInput
198
202
  style={styles.codeInput}
@@ -63,6 +63,7 @@ export const TrainingModal: React.FC<TrainingModalProps> = ({
63
63
  }
64
64
 
65
65
  console.log('๐Ÿš€ Starting Enoch training with socketId:', socketId);
66
+ console.log('๐Ÿ” Production mode: Using live training API');
66
67
 
67
68
  // Prepare user data for training
68
69
  const trainingData = {
@@ -95,16 +96,18 @@ export const TrainingModal: React.FC<TrainingModalProps> = ({
95
96
  console.error('Training start failed:', result.error);
96
97
  setTrainingStatus(`Error: ${result.error}`);
97
98
  setHasError(true);
98
- // Fallback to simulation if API call fails
99
- console.log('๐Ÿš€ Falling back to simulated training');
100
- setTrainingStatus('Training model...');
101
- setInternalProgress(20);
99
+
100
+ // In production mode, don't fallback to simulation on API failure
101
+ console.error('๐Ÿšจ Production mode: Training failed, not falling back to simulation');
102
102
  }
103
103
 
104
104
  } catch (error) {
105
105
  console.error('Training start error:', error);
106
106
  setTrainingStatus(`Error: ${error instanceof Error ? error.message : 'Unknown error'}`);
107
107
  setHasError(true);
108
+
109
+ // In production mode, show the actual error
110
+ console.error('๐Ÿšจ Production mode: Training failed with error:', error);
108
111
  }
109
112
  };
110
113
 
@@ -170,72 +173,79 @@ export const TrainingModal: React.FC<TrainingModalProps> = ({
170
173
 
171
174
  // Initialize real socket connection - backend confirmed this is working
172
175
  try {
173
- // Initialize socket connection
174
- socketRef.current = io('https://api2.onairos.uk', {
175
- transports: ['websocket'],
176
- autoConnect: false
177
- });
178
-
179
- // Socket event listeners
180
- socketRef.current.on('connect', () => {
181
- console.log('โœ… Socket connected for training');
182
- setSocketConnected(true);
183
- const socketId = socketRef.current?.id;
184
- if (socketId) {
185
- startEnochTraining(socketId);
186
- }
187
- });
188
-
189
- socketRef.current.on('disconnect', () => {
190
- console.log('โŒ Socket disconnected');
191
- setSocketConnected(false);
192
- });
193
-
194
- socketRef.current.on('trainingCompleted', (data) => {
195
- console.log('โœ… Training Complete:', data);
196
- setTrainingStatus('Running test inference...');
197
- setInternalProgress(60);
198
- });
199
-
200
- socketRef.current.on('inferenceCompleted', (data) => {
201
- console.log('๐Ÿง  Inference Complete:', data);
202
- setTrainingStatus('Uploading to S3...');
203
- setInternalProgress(80);
204
- setUserTraits(data.traits);
205
- setInferenceResults(data.inferenceResults);
206
- });
207
-
208
- socketRef.current.on('modelStandby', (data) => {
209
- console.log('๐ŸŽ‰ All Complete:', data);
210
- setIsTrainingComplete(true);
211
- setTrainingStatus('Complete!');
212
- setInternalProgress(100);
176
+ console.log('๐Ÿ”Œ Production mode: Initializing real socket connection');
213
177
 
214
- // Auto-complete after a short delay
215
- setTimeout(() => {
216
- onComplete && onComplete();
217
- }, 1500);
218
- });
219
-
220
- socketRef.current.on('trainingUpdate', (data) => {
221
- if (data.error) {
222
- console.error('Training update error:', data.error);
223
- setTrainingStatus(`Error: ${data.error}`);
178
+ // Initialize socket connection
179
+ socketRef.current = io('https://api2.onairos.uk', {
180
+ transports: ['websocket'],
181
+ autoConnect: false
182
+ });
183
+
184
+ // Socket event listeners
185
+ socketRef.current.on('connect', () => {
186
+ console.log('โœ… Socket connected for training');
187
+ setSocketConnected(true);
188
+ const socketId = socketRef.current?.id;
189
+ if (socketId) {
190
+ startEnochTraining(socketId);
191
+ }
192
+ });
193
+
194
+ socketRef.current.on('disconnect', () => {
195
+ console.log('โŒ Socket disconnected');
196
+ setSocketConnected(false);
197
+ });
198
+
199
+ socketRef.current.on('connect_error', (error) => {
200
+ console.error('โŒ Socket connection error:', error);
201
+ setTrainingStatus('Connection failed');
224
202
  setHasError(true);
225
- } else if (data.progress) {
226
- setInternalProgress(data.progress);
227
- setTrainingStatus(data.status || 'Training in progress...');
228
- }
229
- });
230
-
231
- // Connect to socket
232
- socketRef.current.connect();
203
+ });
204
+
205
+ socketRef.current.on('trainingCompleted', (data) => {
206
+ console.log('โœ… Training Complete:', data);
207
+ setTrainingStatus('Running test inference...');
208
+ setInternalProgress(60);
209
+ });
210
+
211
+ socketRef.current.on('inferenceCompleted', (data) => {
212
+ console.log('๐Ÿง  Inference Complete:', data);
213
+ setTrainingStatus('Uploading to S3...');
214
+ setInternalProgress(80);
215
+ setUserTraits(data.traits);
216
+ setInferenceResults(data.inferenceResults);
217
+ });
218
+
219
+ socketRef.current.on('modelStandby', (data) => {
220
+ console.log('๐ŸŽ‰ All Complete:', data);
221
+ setIsTrainingComplete(true);
222
+ setTrainingStatus('Complete!');
223
+ setInternalProgress(100);
224
+
225
+ // Auto-complete after a short delay
226
+ setTimeout(() => {
227
+ onComplete && onComplete();
228
+ }, 1500);
229
+ });
230
+
231
+ socketRef.current.on('trainingUpdate', (data) => {
232
+ if (data.error) {
233
+ console.error('Training update error:', data.error);
234
+ setTrainingStatus(`Error: ${data.error}`);
235
+ setHasError(true);
236
+ } else if (data.progress) {
237
+ setInternalProgress(data.progress);
238
+ setTrainingStatus(data.status || 'Training in progress...');
239
+ }
240
+ });
241
+
242
+ // Connect to socket
243
+ socketRef.current.connect();
244
+
233
245
  } catch (socketError) {
234
- console.error('Socket connection failed, falling back to simulation:', socketError);
235
- // Fallback to simulation if socket fails
236
- console.log('๐Ÿ”Œ Falling back to simulated socket connection...');
237
- setSocketConnected(true);
238
- simulateTraining();
246
+ console.error('๐Ÿšจ Production mode: Socket connection failed:', socketError);
247
+ setTrainingStatus('Failed to connect to training service');
248
+ setHasError(true);
239
249
  }
240
250
 
241
251
  // Cleanup function
@@ -503,9 +503,9 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
503
503
 
504
504
  console.log('๐Ÿ“ง Email validation passed, proceeding...');
505
505
 
506
- // For development mode, just proceed to verification step without API call
507
- if (debug || test) {
508
- console.log('๐Ÿงช Debug/test mode: Skipping API call, proceeding to verification');
506
+ // For test mode, just proceed to verification step without API call
507
+ if (isTestMode) {
508
+ console.log('๐Ÿงช Test mode: Skipping API call, proceeding to verification');
509
509
  setStep('verify');
510
510
  return;
511
511
  }
@@ -538,7 +538,7 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
538
538
 
539
539
  // Race between API call and timeout
540
540
  const result = await Promise.race([
541
- requestEmailVerification(email.trim()),
541
+ requestEmailVerification(email.trim(), isTestMode),
542
542
  timeoutPromise
543
543
  ]) as any;
544
544
 
@@ -610,14 +610,14 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
610
610
  }
611
611
  }
612
612
 
613
- // Real API call (production)
614
- const result = await verifyEmailCode(email.trim(), verificationCode.trim());
613
+ // Real API call (production) or test mode
614
+ const result = await verifyEmailCode(email.trim(), verificationCode.trim(), isTestMode);
615
615
 
616
616
  if (result.success) {
617
617
  console.log('โœ… Email verification successful');
618
618
 
619
- // Check if user exists in backend
620
- const existingUser = (result as any).existingUser || false;
619
+ // Check if user exists in backend (properly typed now)
620
+ const existingUser = result.existingUser || false;
621
621
  setIsExistingUser(existingUser);
622
622
 
623
623
  if (existingUser) {
@@ -844,9 +844,11 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
844
844
  <Text style={styles.emailSubtitle}>
845
845
  We've sent a 6-digit code to {email}
846
846
  </Text>
847
- <Text style={styles.developmentNote}>
848
- ๐Ÿ” Development Mode: Any 6-digit code will work
849
- </Text>
847
+ {isTestMode && (
848
+ <Text style={styles.developmentNote}>
849
+ ๐Ÿ” Test Mode: Any 6-digit code will work
850
+ </Text>
851
+ )}
850
852
  </View>
851
853
 
852
854
  <View style={styles.emailInputSection}>
@@ -654,15 +654,17 @@ export const updateGoogleClientIds = (config: {
654
654
  * ๐Ÿ“ง EMAIL VERIFICATION FUNCTIONS
655
655
  * Using the correct Onairos email verification endpoints
656
656
  */
657
- export const requestEmailVerification = async (email: string): Promise<{
657
+ export const requestEmailVerification = async (email: string, testMode = false): Promise<{
658
658
  success: boolean;
659
659
  message?: string;
660
660
  error?: string;
661
661
  }> => {
662
662
  try {
663
663
  console.log('๐Ÿ“ง Requesting email verification for:', email);
664
+ console.log('๐Ÿ” Test mode:', testMode);
664
665
 
665
- const response = await fetch('https://api2.onairos.uk/email/verification', {
666
+ // Use the correct endpoint: /email/verify
667
+ const response = await fetch('https://api2.onairos.uk/email/verify', {
666
668
  method: 'POST',
667
669
  headers: {
668
670
  'Content-Type': 'application/json',
@@ -674,10 +676,14 @@ export const requestEmailVerification = async (email: string): Promise<{
674
676
 
675
677
  if (response.ok && result.success) {
676
678
  console.log('โœ… Email verification requested successfully');
677
- console.log('๐Ÿ” Testing mode: Code logged to server console, but accepts any code');
679
+
680
+ const message = testMode
681
+ ? 'Verification code sent to your email (testing mode: any code accepted)'
682
+ : result.message || 'Verification code sent to your email';
683
+
678
684
  return {
679
685
  success: true,
680
- message: result.message || 'Verification code sent to your email (testing mode: any code accepted)',
686
+ message,
681
687
  };
682
688
  } else {
683
689
  console.error('โŒ Email verification request failed:', result.error);
@@ -695,49 +701,72 @@ export const requestEmailVerification = async (email: string): Promise<{
695
701
  }
696
702
  };
697
703
 
698
- export const verifyEmailCode = async (email: string, code: string): Promise<{
704
+ export const verifyEmailCode = async (email: string, code: string, testMode = false): Promise<{
699
705
  success: boolean;
700
706
  message?: string;
701
707
  error?: string;
708
+ existingUser?: boolean;
702
709
  }> => {
703
710
  try {
704
711
  console.log('๐Ÿ” Verifying email code for:', email);
705
- console.log('๐Ÿ” Development mode: All codes will pass through for now');
712
+ console.log('๐Ÿ” Test mode:', testMode);
713
+
714
+ // In test mode, accept any code
715
+ if (testMode) {
716
+ console.log('๐Ÿงช Test mode: All codes will pass through');
717
+ // Simulate 30% chance of existing user in test mode
718
+ const simulateExistingUser = Math.random() < 0.3;
719
+ return {
720
+ success: true,
721
+ message: 'Email verified successfully (test mode: all codes accepted)',
722
+ existingUser: simulateExistingUser,
723
+ };
724
+ }
706
725
 
707
- // For now, allow all codes to pass through
708
- // Still make the API call to set up the routing, but don't rely on response
726
+ // Production mode: Make real API call with proper validation
709
727
  try {
710
- const response = await fetch('https://api2.onairos.uk/email/verification', {
728
+ const response = await fetch('https://api2.onairos.uk/email/verify', {
711
729
  method: 'POST',
712
730
  headers: {
713
731
  'Content-Type': 'application/json',
714
732
  },
715
- body: JSON.stringify({ email, code, action: 'verify' }),
733
+ body: JSON.stringify({ email, code }),
716
734
  });
717
735
 
718
736
  const result = await response.json();
719
737
  console.log('๐Ÿ“ก Email verification API response:', result);
738
+
739
+ if (response.ok && result.success) {
740
+ console.log('โœ… Email verification successful');
741
+ return {
742
+ success: true,
743
+ message: result.message || 'Email verified successfully',
744
+ existingUser: result.existingUser || false, // Backend should return this flag
745
+ };
746
+ } else {
747
+ console.error('โŒ Email verification failed:', result.error);
748
+ return {
749
+ success: false,
750
+ error: result.error || 'Invalid verification code',
751
+ };
752
+ }
720
753
  } catch (apiError) {
721
- console.warn('โš ๏ธ Email verification API call failed, but continuing with bypass:', apiError);
754
+ console.error('โŒ Email verification API call failed:', apiError);
755
+ return {
756
+ success: false,
757
+ error: 'Network error during verification',
758
+ };
722
759
  }
723
-
724
- // Always return success for now
725
- console.log('โœ… Email verification successful (bypass mode)');
726
- return {
727
- success: true,
728
- message: 'Email verified successfully (development mode: all codes accepted)',
729
- };
730
760
  } catch (error) {
731
761
  console.error('โŒ Email verification error:', error);
732
- // Even on error, return success for now
733
762
  return {
734
- success: true,
735
- message: 'Email verified successfully (development mode: all codes accepted)',
763
+ success: false,
764
+ error: error instanceof Error ? error.message : 'Unknown error',
736
765
  };
737
766
  }
738
767
  };
739
768
 
740
- export const checkEmailVerificationStatus = async (email: string): Promise<{
769
+ export const checkEmailVerificationStatus = async (email: string, testMode = false): Promise<{
741
770
  success: boolean;
742
771
  isPending?: boolean;
743
772
  message?: string;
@@ -745,11 +774,21 @@ export const checkEmailVerificationStatus = async (email: string): Promise<{
745
774
  }> => {
746
775
  try {
747
776
  console.log('๐Ÿ” Checking email verification status for:', email);
748
- console.log('๐Ÿ” Development mode: Always returning no pending verification');
777
+ console.log('๐Ÿ” Test mode:', testMode);
778
+
779
+ // In test mode, always return no pending verification
780
+ if (testMode) {
781
+ console.log('๐Ÿงช Test mode: Always returning no pending verification');
782
+ return {
783
+ success: true,
784
+ isPending: false,
785
+ message: 'Status retrieved successfully (test mode)',
786
+ };
787
+ }
749
788
 
750
- // Make API call to set up routing, but don't rely on response for now
789
+ // Production mode: Make real API call
751
790
  try {
752
- const response = await fetch(`https://api2.onairos.uk/email/verification/status/${encodeURIComponent(email)}`, {
791
+ const response = await fetch(`https://api2.onairos.uk/email/verify/status/${encodeURIComponent(email)}`, {
753
792
  method: 'GET',
754
793
  headers: {
755
794
  'Content-Type': 'application/json',
@@ -758,24 +797,33 @@ export const checkEmailVerificationStatus = async (email: string): Promise<{
758
797
 
759
798
  const result = await response.json();
760
799
  console.log('๐Ÿ“ก Email verification status API response:', result);
800
+
801
+ if (response.ok && result.success) {
802
+ console.log('โœ… Email verification status retrieved');
803
+ return {
804
+ success: true,
805
+ isPending: result.isPending || false,
806
+ message: result.message || 'Status retrieved successfully',
807
+ };
808
+ } else {
809
+ console.error('โŒ Email verification status failed:', result.error);
810
+ return {
811
+ success: false,
812
+ error: result.error || 'Failed to check verification status',
813
+ };
814
+ }
761
815
  } catch (apiError) {
762
- console.warn('โš ๏ธ Email verification status API call failed, but continuing with bypass:', apiError);
816
+ console.error('โŒ Email verification status API call failed:', apiError);
817
+ return {
818
+ success: false,
819
+ error: 'Network error while checking status',
820
+ };
763
821
  }
764
-
765
- // For development, always return no pending verification
766
- console.log('โœ… Email verification status retrieved (bypass mode)');
767
- return {
768
- success: true,
769
- isPending: false, // Always false so verification flow starts fresh
770
- message: 'Status retrieved successfully (development mode)',
771
- };
772
822
  } catch (error) {
773
823
  console.error('โŒ Email verification status error:', error);
774
- // Even on error, return success for development
775
824
  return {
776
- success: true,
777
- isPending: false,
778
- message: 'Status retrieved successfully (development mode)',
825
+ success: false,
826
+ error: error instanceof Error ? error.message : 'Unknown error',
779
827
  };
780
828
  }
781
829
  };