@onairos/react-native 3.0.50 → 3.0.51

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 (30) hide show
  1. package/lib/commonjs/components/EmailVerificationModal.js +317 -0
  2. package/lib/commonjs/components/EmailVerificationModal.js.map +1 -0
  3. package/lib/commonjs/components/TrainingModal.js +66 -75
  4. package/lib/commonjs/components/TrainingModal.js.map +1 -1
  5. package/lib/commonjs/index.js +31 -2
  6. package/lib/commonjs/index.js.map +1 -1
  7. package/lib/commonjs/services/platformAuthService.js +156 -1
  8. package/lib/commonjs/services/platformAuthService.js.map +1 -1
  9. package/lib/module/components/EmailVerificationModal.js +308 -0
  10. package/lib/module/components/EmailVerificationModal.js.map +1 -0
  11. package/lib/module/components/TrainingModal.js +66 -75
  12. package/lib/module/components/TrainingModal.js.map +1 -1
  13. package/lib/module/components/UniversalOnboarding.js.map +1 -1
  14. package/lib/module/index.js +3 -2
  15. package/lib/module/index.js.map +1 -1
  16. package/lib/module/services/platformAuthService.js +151 -0
  17. package/lib/module/services/platformAuthService.js.map +1 -1
  18. package/lib/typescript/components/EmailVerificationModal.d.ts +10 -0
  19. package/lib/typescript/components/EmailVerificationModal.d.ts.map +1 -0
  20. package/lib/typescript/components/TrainingModal.d.ts.map +1 -1
  21. package/lib/typescript/index.d.ts +4 -2
  22. package/lib/typescript/index.d.ts.map +1 -1
  23. package/lib/typescript/services/platformAuthService.d.ts +29 -0
  24. package/lib/typescript/services/platformAuthService.d.ts.map +1 -1
  25. package/package.json +1 -1
  26. package/src/components/EmailVerificationModal.tsx +356 -0
  27. package/src/components/TrainingModal.tsx +69 -73
  28. package/src/components/UniversalOnboarding.tsx +1 -1
  29. package/src/index.ts +7 -1
  30. package/src/services/platformAuthService.ts +176 -0
@@ -613,3 +613,179 @@ export const updateGoogleClientIds = (config: {
613
613
  console.log('✅ Google client IDs updated successfully');
614
614
  }
615
615
  };
616
+
617
+ /**
618
+ * 📧 EMAIL VERIFICATION FUNCTIONS
619
+ * Using the correct Onairos email verification endpoints
620
+ */
621
+ export const requestEmailVerification = async (email: string): Promise<{
622
+ success: boolean;
623
+ message?: string;
624
+ error?: string;
625
+ }> => {
626
+ try {
627
+ console.log('📧 Requesting email verification for:', email);
628
+
629
+ const response = await fetch('https://api2.onairos.uk/email/verify', {
630
+ method: 'POST',
631
+ headers: {
632
+ 'Content-Type': 'application/json',
633
+ },
634
+ body: JSON.stringify({ email }),
635
+ });
636
+
637
+ const result = await response.json();
638
+
639
+ if (response.ok && result.success) {
640
+ console.log('✅ Email verification requested successfully');
641
+ console.log('🔍 Testing mode: Code logged to server console, but accepts any code');
642
+ return {
643
+ success: true,
644
+ message: result.message || 'Verification code sent to your email (testing mode: any code accepted)',
645
+ };
646
+ } else {
647
+ console.error('❌ Email verification request failed:', result.error);
648
+ return {
649
+ success: false,
650
+ error: result.error || 'Failed to send verification code',
651
+ };
652
+ }
653
+ } catch (error) {
654
+ console.error('❌ Email verification request error:', error);
655
+ return {
656
+ success: false,
657
+ error: error instanceof Error ? error.message : 'Network error',
658
+ };
659
+ }
660
+ };
661
+
662
+ export const verifyEmailCode = async (email: string, code: string): Promise<{
663
+ success: boolean;
664
+ message?: string;
665
+ error?: string;
666
+ }> => {
667
+ try {
668
+ console.log('🔍 Verifying email code for:', email);
669
+
670
+ const response = await fetch('https://api2.onairos.uk/email/verify/confirm', {
671
+ method: 'POST',
672
+ headers: {
673
+ 'Content-Type': 'application/json',
674
+ },
675
+ body: JSON.stringify({ email, code }),
676
+ });
677
+
678
+ const result = await response.json();
679
+
680
+ if (response.ok && result.success) {
681
+ console.log('✅ Email verification successful');
682
+ console.log('🔍 Testing mode: Any code accepted for verification');
683
+ return {
684
+ success: true,
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
+ };
693
+ }
694
+ } catch (error) {
695
+ console.error('❌ Email verification error:', error);
696
+ return {
697
+ success: false,
698
+ error: error instanceof Error ? error.message : 'Network error',
699
+ };
700
+ }
701
+ };
702
+
703
+ export const checkEmailVerificationStatus = async (email: string): Promise<{
704
+ success: boolean;
705
+ isPending?: boolean;
706
+ message?: string;
707
+ error?: string;
708
+ }> => {
709
+ try {
710
+ console.log('🔍 Checking email verification status for:', email);
711
+
712
+ const response = await fetch(`https://api2.onairos.uk/email/verify/status/${encodeURIComponent(email)}`, {
713
+ method: 'GET',
714
+ headers: {
715
+ 'Content-Type': 'application/json',
716
+ },
717
+ });
718
+
719
+ const result = await response.json();
720
+
721
+ if (response.ok) {
722
+ console.log('✅ Email verification status retrieved');
723
+ return {
724
+ success: true,
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
+ };
734
+ }
735
+ } catch (error) {
736
+ console.error('❌ Email verification status error:', error);
737
+ return {
738
+ success: false,
739
+ error: error instanceof Error ? error.message : 'Network error',
740
+ };
741
+ }
742
+ };
743
+
744
+ /**
745
+ * 🔌 UNIVERSAL PLATFORM DISCONNECTION
746
+ * Backend confirmed this endpoint is fully implemented
747
+ */
748
+ export const disconnectPlatform = async (platform: string, username: string): Promise<{
749
+ success: boolean;
750
+ message?: string;
751
+ error?: string;
752
+ }> => {
753
+ try {
754
+ console.log(`🔌 Disconnecting ${platform} for user:`, username);
755
+
756
+ const response = await fetch('https://api2.onairos.uk/revoke', {
757
+ method: 'POST',
758
+ headers: {
759
+ 'Content-Type': 'application/json',
760
+ },
761
+ body: JSON.stringify({
762
+ Info: {
763
+ connection: platform.charAt(0).toUpperCase() + platform.slice(1), // Capitalize platform name
764
+ username: username,
765
+ },
766
+ }),
767
+ });
768
+
769
+ const result = await response.json();
770
+
771
+ if (response.ok && result.success) {
772
+ console.log(`✅ ${platform} disconnected successfully`);
773
+ return {
774
+ success: true,
775
+ message: result.message || `${platform} disconnected successfully`,
776
+ };
777
+ } else {
778
+ console.error(`❌ ${platform} disconnection failed:`, result.error);
779
+ return {
780
+ success: false,
781
+ error: result.error || `Failed to disconnect ${platform}`,
782
+ };
783
+ }
784
+ } catch (error) {
785
+ console.error(`❌ ${platform} disconnection error:`, error);
786
+ return {
787
+ success: false,
788
+ error: error instanceof Error ? error.message : 'Network error',
789
+ };
790
+ }
791
+ };