@onairos/react-native 3.0.65 โ†’ 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 (41) hide show
  1. package/lib/commonjs/components/DataRequestScreen.js +329 -0
  2. package/lib/commonjs/components/DataRequestScreen.js.map +1 -0
  3. package/lib/commonjs/components/EmailVerificationModal.js +7 -6
  4. package/lib/commonjs/components/EmailVerificationModal.js.map +1 -1
  5. package/lib/commonjs/components/TrainingModal.js +17 -9
  6. package/lib/commonjs/components/TrainingModal.js.map +1 -1
  7. package/lib/commonjs/components/UniversalOnboarding.js +23 -36
  8. package/lib/commonjs/components/UniversalOnboarding.js.map +1 -1
  9. package/lib/commonjs/index.js +8 -0
  10. package/lib/commonjs/index.js.map +1 -1
  11. package/lib/commonjs/services/platformAuthService.js +80 -40
  12. package/lib/commonjs/services/platformAuthService.js.map +1 -1
  13. package/lib/module/components/DataRequestScreen.js +321 -0
  14. package/lib/module/components/DataRequestScreen.js.map +1 -0
  15. package/lib/module/components/EmailVerificationModal.js +7 -6
  16. package/lib/module/components/EmailVerificationModal.js.map +1 -1
  17. package/lib/module/components/TrainingModal.js +17 -9
  18. package/lib/module/components/TrainingModal.js.map +1 -1
  19. package/lib/module/components/UniversalOnboarding.js +23 -36
  20. package/lib/module/components/UniversalOnboarding.js.map +1 -1
  21. package/lib/module/index.js +1 -0
  22. package/lib/module/index.js.map +1 -1
  23. package/lib/module/services/platformAuthService.js +80 -40
  24. package/lib/module/services/platformAuthService.js.map +1 -1
  25. package/lib/typescript/components/DataRequestScreen.d.ts +11 -0
  26. package/lib/typescript/components/DataRequestScreen.d.ts.map +1 -0
  27. package/lib/typescript/components/EmailVerificationModal.d.ts +1 -0
  28. package/lib/typescript/components/EmailVerificationModal.d.ts.map +1 -1
  29. package/lib/typescript/components/TrainingModal.d.ts.map +1 -1
  30. package/lib/typescript/components/UniversalOnboarding.d.ts.map +1 -1
  31. package/lib/typescript/index.d.ts +1 -0
  32. package/lib/typescript/index.d.ts.map +1 -1
  33. package/lib/typescript/services/platformAuthService.d.ts +4 -3
  34. package/lib/typescript/services/platformAuthService.d.ts.map +1 -1
  35. package/package.json +1 -1
  36. package/src/components/DataRequestScreen.tsx +356 -0
  37. package/src/components/EmailVerificationModal.tsx +10 -6
  38. package/src/components/TrainingModal.tsx +77 -67
  39. package/src/components/UniversalOnboarding.tsx +40 -53
  40. package/src/index.ts +1 -0
  41. package/src/services/platformAuthService.ts +86 -38
@@ -22,7 +22,7 @@ import Icon from 'react-native-vector-icons/MaterialIcons';
22
22
  import { PlatformList } from './PlatformList';
23
23
  import { PinInput } from './PinInput';
24
24
  import { TrainingModal } from './TrainingModal';
25
- import { DataRequestModal } from './DataRequestModal';
25
+ import { DataRequestScreen } from './DataRequestScreen';
26
26
  import { OAuthWebView } from './onboarding/OAuthWebView';
27
27
  import { useConnections } from '../hooks/useConnections';
28
28
  import { COLORS, DEEP_LINK_CONFIG } from '../constants';
@@ -80,7 +80,7 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
80
80
  const [email, setEmail] = useState<string>('');
81
81
  const [verificationCode, setVerificationCode] = useState<string>('');
82
82
  const [isVerifyingCode, setIsVerifyingCode] = useState<boolean>(false);
83
- const [showDataRequestModal, setShowDataRequestModal] = useState<boolean>(false);
83
+
84
84
  const [isExistingUser, setIsExistingUser] = useState<boolean>(false);
85
85
 
86
86
  // Add refs for cleanup and code inputs
@@ -90,7 +90,7 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
90
90
 
91
91
  // Add state for showing additional platforms
92
92
  const [showAllPlatforms, setShowAllPlatforms] = useState<boolean>(false);
93
- const [showTestDataRequest, setShowTestDataRequest] = useState<boolean>(false);
93
+
94
94
 
95
95
  // Parse test mode options
96
96
  const testModeOptions = typeof test === 'object' ? test : {};
@@ -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
 
@@ -598,7 +598,7 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
598
598
  // Flow 1: Existing User โ†’ Data Request โ†’ Close (return API URL)
599
599
  console.log('๐Ÿงช Test Flow 1: Existing User โ†’ Show Data Request');
600
600
  setIsExistingUser(true);
601
- setShowDataRequestModal(true);
601
+ setStep('dataRequest');
602
602
  return;
603
603
  } else if (isNewUserFlow) {
604
604
  // Flow 2: New User โ†’ Platform Connect โ†’ PIN โ†’ Training
@@ -610,19 +610,19 @@ 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) {
624
- console.log('๐Ÿ‘ค Existing user detected, showing data request modal');
625
- setShowDataRequestModal(true);
624
+ console.log('๐Ÿ‘ค Existing user detected, showing data request screen');
625
+ setStep('dataRequest');
626
626
  } else {
627
627
  console.log('๐Ÿ†• New user, proceeding to platform connection');
628
628
  // Safely set username from email prefix
@@ -715,7 +715,6 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
715
715
 
716
716
  const handleDataRequestAccept = useCallback(() => {
717
717
  console.log('Data request accepted for existing user');
718
- setShowDataRequestModal(false);
719
718
 
720
719
  // Complete onboarding for existing user
721
720
  onComplete('https://api2.onairos.uk', 'existing-session-token', {
@@ -728,7 +727,6 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
728
727
 
729
728
  const handleDataRequestDecline = useCallback(() => {
730
729
  console.log('Data request declined');
731
- setShowDataRequestModal(false);
732
730
  handleClose();
733
731
  }, [handleClose]);
734
732
 
@@ -846,9 +844,11 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
846
844
  <Text style={styles.emailSubtitle}>
847
845
  We've sent a 6-digit code to {email}
848
846
  </Text>
849
- <Text style={styles.developmentNote}>
850
- ๐Ÿ” Development Mode: Any 6-digit code will work
851
- </Text>
847
+ {isTestMode && (
848
+ <Text style={styles.developmentNote}>
849
+ ๐Ÿ” Test Mode: Any 6-digit code will work
850
+ </Text>
851
+ )}
852
852
  </View>
853
853
 
854
854
  <View style={styles.emailInputSection}>
@@ -1031,14 +1031,14 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
1031
1031
  <View style={styles.testModeContainer}>
1032
1032
  <Text style={styles.testModeTitle}>๐Ÿงช Test Mode - 2 Main Flows</Text>
1033
1033
 
1034
- <TouchableOpacity
1035
- style={styles.testExistingUserButton}
1036
- onPress={() => {
1037
- // Flow 1: Existing User
1038
- setIsExistingUser(true);
1039
- setShowDataRequestModal(true);
1040
- }}
1041
- >
1034
+ <TouchableOpacity
1035
+ style={styles.testExistingUserButton}
1036
+ onPress={() => {
1037
+ // Flow 1: Existing User
1038
+ setIsExistingUser(true);
1039
+ setStep('dataRequest');
1040
+ }}
1041
+ >
1042
1042
  <Icon name="person" size={20} color="#28a745" />
1043
1043
  <Text style={styles.testExistingUserButtonText}>
1044
1044
  Flow 1: Existing User (Email โ†’ Code โ†’ Data Request โ†’ Close)
@@ -1060,11 +1060,11 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
1060
1060
 
1061
1061
  <TouchableOpacity
1062
1062
  style={styles.testDataRequestButton}
1063
- onPress={() => setShowTestDataRequest(true)}
1063
+ onPress={() => setStep('dataRequest')}
1064
1064
  >
1065
1065
  <Icon name="preview" size={20} color={COLORS.primary} />
1066
1066
  <Text style={styles.testDataRequestButtonText}>
1067
- Preview Data Request Modal
1067
+ Preview Data Request Screen
1068
1068
  </Text>
1069
1069
  </TouchableOpacity>
1070
1070
  </View>
@@ -1145,6 +1145,16 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
1145
1145
  test={isTestMode}
1146
1146
  />
1147
1147
  )}
1148
+
1149
+ {step === 'dataRequest' && (
1150
+ <DataRequestScreen
1151
+ onAccept={handleDataRequestAccept}
1152
+ onDecline={handleDataRequestDecline}
1153
+ requestData={requestData || {}}
1154
+ AppName={AppName}
1155
+ appIcon={appIcon}
1156
+ />
1157
+ )}
1148
1158
 
1149
1159
  {step === 'oauth' && oauthUrl && (
1150
1160
  <OAuthWebView
@@ -1167,30 +1177,7 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
1167
1177
  </View>
1168
1178
  </TouchableWithoutFeedback>
1169
1179
 
1170
- {/* Data Request Modal for existing users */}
1171
- {showDataRequestModal && requestData && (
1172
- <DataRequestModal
1173
- visible={showDataRequestModal}
1174
- onClose={handleDataRequestDecline}
1175
- onAccept={handleDataRequestAccept}
1176
- requestData={requestData}
1177
- AppName={AppName}
1178
- />
1179
- )}
1180
-
1181
- {/* Test mode data request modal */}
1182
- {showTestDataRequest && requestData && (
1183
- <DataRequestModal
1184
- visible={showTestDataRequest}
1185
- onClose={() => setShowTestDataRequest(false)}
1186
- onAccept={() => {
1187
- setShowTestDataRequest(false);
1188
- Alert.alert('Test Mode', 'This is a preview of the data request. In actual implementation, this would proceed with the data sharing agreement.');
1189
- }}
1190
- requestData={requestData}
1191
- AppName={`${AppName} (Test Preview)`}
1192
- />
1193
- )}
1180
+
1194
1181
  </Modal>
1195
1182
  );
1196
1183
  };
package/src/index.ts CHANGED
@@ -110,6 +110,7 @@ export { PlatformList } from './components/PlatformList';
110
110
  export { PinInput } from './components/PinInput';
111
111
  export { TrainingModal } from './components/TrainingModal';
112
112
  export { EmailVerificationModal } from './components/EmailVerificationModal';
113
+ export { DataRequestScreen } from './components/DataRequestScreen';
113
114
  export { Overlay } from './components/Overlay';
114
115
  export { UniversalOnboarding } from './components/UniversalOnboarding';
115
116
  export { OnairosButton } from './components/OnairosButton';
@@ -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
  };