@onairos/react-native 3.1.12 โ 3.1.14
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/README.md +403 -374
- package/lib/commonjs/api/index.js +75 -1
- package/lib/commonjs/api/index.js.map +1 -1
- package/lib/commonjs/assets/fonts/EBGaramond-VariableFont_wght.ttf +0 -0
- package/lib/commonjs/assets/fonts/IBMPlexSans-VariableFont_wdth,wght.ttf +0 -0
- package/lib/commonjs/assets/icons/Facebookicon.png +0 -0
- package/lib/commonjs/assets/icons/Gmail.png +0 -0
- package/lib/commonjs/assets/icons/Linkedinicon.png +0 -0
- package/lib/commonjs/assets/icons/Redditicon.png +0 -0
- package/lib/commonjs/assets/icons/YouTubeicon2.png +0 -0
- package/lib/commonjs/assets/icons/YouTubeicon3.png +0 -0
- package/lib/commonjs/assets/icons/farcaster.png +0 -0
- package/lib/commonjs/assets/icons/instagram.png +0 -0
- package/lib/commonjs/assets/icons/pinterest.png +0 -0
- package/lib/commonjs/assets/icons/swerv_logo.png +0 -0
- package/lib/commonjs/assets/icons/twitter.jpg +0 -0
- package/lib/commonjs/assets/images/Checkbox.svg +3 -0
- package/lib/commonjs/assets/images/EnochE.svg +19 -0
- package/lib/commonjs/assets/images/Enochicon1.png +0 -0
- package/lib/commonjs/assets/images/Face_ID_logo.png +0 -0
- package/lib/commonjs/assets/images/Facebookicon.png +0 -0
- package/lib/commonjs/assets/images/Gmail.png +0 -0
- package/lib/commonjs/assets/images/Googlelogo.png +0 -0
- package/lib/commonjs/assets/images/Linkedinicon.png +0 -0
- package/lib/commonjs/assets/images/Onairoslogo.png +0 -0
- package/lib/commonjs/assets/images/Personalityprofile.svg +3 -0
- package/lib/commonjs/assets/images/Personalitytraits.svg +3 -0
- package/lib/commonjs/assets/images/Redditicon.png +0 -0
- package/lib/commonjs/assets/images/Userpreferences.svg +3 -0
- package/lib/commonjs/assets/images/YouTubeicon3.png +0 -0
- package/lib/commonjs/assets/images/arrow.svg +20 -0
- package/lib/commonjs/assets/images/basicproficon.svg +43 -0
- package/lib/commonjs/assets/images/basicprofile.svg +3 -0
- package/lib/commonjs/assets/images/checkmark.svg +4 -0
- package/lib/commonjs/assets/images/contentanalysis.svg +3 -0
- package/lib/commonjs/assets/images/contenticon.svg +23 -0
- package/lib/commonjs/assets/images/persona1.png +0 -0
- package/lib/commonjs/assets/images/persona2.png +0 -0
- package/lib/commonjs/assets/images/persona3.png +0 -0
- package/lib/commonjs/assets/images/persona4.png +0 -0
- package/lib/commonjs/assets/images/persona5.png +0 -0
- package/lib/commonjs/assets/images/personalityicon.svg +18 -0
- package/lib/commonjs/assets/images/x-close.svg +3 -0
- package/lib/commonjs/components/BodyText.js +27 -0
- package/lib/commonjs/components/BodyText.js.map +1 -0
- package/lib/commonjs/components/BrandMark.js +44 -0
- package/lib/commonjs/components/BrandMark.js.map +1 -0
- package/lib/commonjs/components/CodeInput.js +30 -0
- package/lib/commonjs/components/CodeInput.js.map +1 -0
- package/lib/commonjs/components/EmailInput.js +30 -0
- package/lib/commonjs/components/EmailInput.js.map +1 -0
- package/lib/commonjs/components/ExistingUserDataConfirmation.js +474 -0
- package/lib/commonjs/components/ExistingUserDataConfirmation.js.map +1 -0
- package/lib/commonjs/components/GoogleButton.js +55 -0
- package/lib/commonjs/components/GoogleButton.js.map +1 -0
- package/lib/commonjs/components/HeadingGroup.js +43 -0
- package/lib/commonjs/components/HeadingGroup.js.map +1 -0
- package/lib/commonjs/components/ModalHeader.js +99 -0
- package/lib/commonjs/components/ModalHeader.js.map +1 -0
- package/lib/commonjs/components/ModalSheet.js +41 -0
- package/lib/commonjs/components/ModalSheet.js.map +1 -0
- package/lib/commonjs/components/Onairos.js +1 -3
- package/lib/commonjs/components/Onairos.js.map +1 -1
- package/lib/commonjs/components/OnairosButton.js +171 -190
- package/lib/commonjs/components/OnairosButton.js.map +1 -1
- package/lib/commonjs/components/OnairosSignInButton.js +169 -0
- package/lib/commonjs/components/OnairosSignInButton.js.map +1 -0
- package/lib/commonjs/components/Overlay.js +5 -5
- package/lib/commonjs/components/Overlay.js.map +1 -1
- package/lib/commonjs/components/PersonaImage.js +60 -0
- package/lib/commonjs/components/PersonaImage.js.map +1 -0
- package/lib/commonjs/components/PersonaLoadingScreen.js +156 -0
- package/lib/commonjs/components/PersonaLoadingScreen.js.map +1 -0
- package/lib/commonjs/components/PersonalizationConsentScreen.js +316 -0
- package/lib/commonjs/components/PersonalizationConsentScreen.js.map +1 -0
- package/lib/commonjs/components/PinCreationScreen.js +393 -0
- package/lib/commonjs/components/PinCreationScreen.js.map +1 -0
- package/lib/commonjs/components/PinInput.js +282 -120
- package/lib/commonjs/components/PinInput.js.map +1 -1
- package/lib/commonjs/components/PlatformConnectorsStep.js +828 -0
- package/lib/commonjs/components/PlatformConnectorsStep.js.map +1 -0
- package/lib/commonjs/components/PlatformToggle.js +180 -0
- package/lib/commonjs/components/PlatformToggle.js.map +1 -0
- package/lib/commonjs/components/PrimaryButton.js +180 -0
- package/lib/commonjs/components/PrimaryButton.js.map +1 -0
- package/lib/commonjs/components/SignInMatchAnimation.js +197 -0
- package/lib/commonjs/components/SignInMatchAnimation.js.map +1 -0
- package/lib/commonjs/components/SignInStep.js +179 -0
- package/lib/commonjs/components/SignInStep.js.map +1 -0
- package/lib/commonjs/components/TrainingModal.js +808 -563
- package/lib/commonjs/components/TrainingModal.js.map +1 -1
- package/lib/commonjs/components/UniversalOnboarding.js +2304 -1283
- package/lib/commonjs/components/UniversalOnboarding.js.map +1 -1
- package/lib/commonjs/components/VerificationStep.js +154 -0
- package/lib/commonjs/components/VerificationStep.js.map +1 -0
- package/lib/commonjs/components/WelcomeScreen.js +385 -0
- package/lib/commonjs/components/WelcomeScreen.js.map +1 -0
- package/lib/commonjs/components/icons/Basicproficon.js +37 -0
- package/lib/commonjs/components/icons/Basicproficon.js.map +1 -0
- package/lib/commonjs/components/icons/Basicprofile.js +21 -0
- package/lib/commonjs/components/icons/Basicprofile.js.map +1 -0
- package/lib/commonjs/components/icons/Checkbox.js +21 -0
- package/lib/commonjs/components/icons/Checkbox.js.map +1 -0
- package/lib/commonjs/components/icons/Checkmark.js +27 -0
- package/lib/commonjs/components/icons/Checkmark.js.map +1 -0
- package/lib/commonjs/components/icons/Contentanalysis.js +21 -0
- package/lib/commonjs/components/icons/Contentanalysis.js.map +1 -0
- package/lib/commonjs/components/icons/Contenticon.js +39 -0
- package/lib/commonjs/components/icons/Contenticon.js.map +1 -0
- package/lib/commonjs/components/icons/EnochE.js +41 -0
- package/lib/commonjs/components/icons/EnochE.js.map +1 -0
- package/lib/commonjs/components/icons/Personalityicon.js +30 -0
- package/lib/commonjs/components/icons/Personalityicon.js.map +1 -0
- package/lib/commonjs/components/icons/Personalityprofile.js +21 -0
- package/lib/commonjs/components/icons/Personalityprofile.js.map +1 -0
- package/lib/commonjs/components/icons/Personalitytraits.js +21 -0
- package/lib/commonjs/components/icons/Personalitytraits.js.map +1 -0
- package/lib/commonjs/components/icons/Userpreferences.js +21 -0
- package/lib/commonjs/components/icons/Userpreferences.js.map +1 -0
- package/lib/commonjs/components/icons/index.js +84 -0
- package/lib/commonjs/components/icons/index.js.map +1 -0
- package/lib/commonjs/components/onboarding/OAuthWebView.js +134 -743
- package/lib/commonjs/components/onboarding/OAuthWebView.js.map +1 -1
- package/lib/commonjs/config/api.js +34 -0
- package/lib/commonjs/config/api.js.map +1 -0
- package/lib/commonjs/context/AuthContext.js +345 -0
- package/lib/commonjs/context/AuthContext.js.map +1 -0
- package/lib/commonjs/hooks/useConnectedAccounts.js +111 -0
- package/lib/commonjs/hooks/useConnectedAccounts.js.map +1 -0
- package/lib/commonjs/hooks/useConnections.js +120 -125
- package/lib/commonjs/hooks/useConnections.js.map +1 -1
- package/lib/commonjs/hooks/useUserConnections.js +148 -0
- package/lib/commonjs/hooks/useUserConnections.js.map +1 -0
- package/lib/commonjs/index.js +12 -100
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/services/apiClient.js +302 -0
- package/lib/commonjs/services/apiClient.js.map +1 -0
- package/lib/commonjs/services/apiKeyService.js +8 -9
- package/lib/commonjs/services/apiKeyService.js.map +1 -1
- package/lib/commonjs/services/authService.js +935 -0
- package/lib/commonjs/services/authService.js.map +1 -0
- package/lib/commonjs/services/biometricPinService.js +184 -0
- package/lib/commonjs/services/biometricPinService.js.map +1 -0
- package/lib/commonjs/services/connectedAccountsService.js +268 -0
- package/lib/commonjs/services/connectedAccountsService.js.map +1 -0
- package/lib/commonjs/services/googleAuthService.js +268 -0
- package/lib/commonjs/services/googleAuthService.js.map +1 -0
- package/lib/commonjs/services/imageCompressionService.js +260 -0
- package/lib/commonjs/services/imageCompressionService.js.map +1 -0
- package/lib/commonjs/services/jwtStorageService.js +256 -0
- package/lib/commonjs/services/jwtStorageService.js.map +1 -0
- package/lib/commonjs/services/mobileTrainingService.js +185 -0
- package/lib/commonjs/services/mobileTrainingService.js.map +1 -0
- package/lib/commonjs/services/pinEncryptionService.js +84 -0
- package/lib/commonjs/services/pinEncryptionService.js.map +1 -0
- package/lib/commonjs/services/pinStorageUtils.js +105 -0
- package/lib/commonjs/services/pinStorageUtils.js.map +1 -0
- package/lib/commonjs/services/platformAuthService.js +956 -722
- package/lib/commonjs/services/platformAuthService.js.map +1 -1
- package/lib/commonjs/services/storageService.js +404 -0
- package/lib/commonjs/services/storageService.js.map +1 -0
- package/lib/commonjs/services/trainingApiHelpers.js +73 -0
- package/lib/commonjs/services/trainingApiHelpers.js.map +1 -0
- package/lib/commonjs/services/userConnectionsService.js +486 -0
- package/lib/commonjs/services/userConnectionsService.js.map +1 -0
- package/lib/commonjs/services/youtubeMigrationService.js +415 -0
- package/lib/commonjs/services/youtubeMigrationService.js.map +1 -0
- package/lib/commonjs/theme/index.js +249 -0
- package/lib/commonjs/theme/index.js.map +1 -0
- package/lib/commonjs/utils/eventUtils.js +288 -0
- package/lib/commonjs/utils/eventUtils.js.map +1 -0
- package/lib/commonjs/utils/haptics.js +66 -0
- package/lib/commonjs/utils/haptics.js.map +1 -0
- package/lib/commonjs/utils/imagePreloader.js +6 -0
- package/lib/commonjs/utils/imagePreloader.js.map +1 -0
- package/lib/module/api/index.js +72 -0
- package/lib/module/api/index.js.map +1 -1
- package/lib/module/assets/fonts/EBGaramond-VariableFont_wght.ttf +0 -0
- package/lib/module/assets/fonts/IBMPlexSans-VariableFont_wdth,wght.ttf +0 -0
- package/lib/module/assets/icons/Facebookicon.png +0 -0
- package/lib/module/assets/icons/Gmail.png +0 -0
- package/lib/module/assets/icons/Linkedinicon.png +0 -0
- package/lib/module/assets/icons/Redditicon.png +0 -0
- package/lib/module/assets/icons/YouTubeicon2.png +0 -0
- package/lib/module/assets/icons/YouTubeicon3.png +0 -0
- package/lib/module/assets/icons/farcaster.png +0 -0
- package/lib/module/assets/icons/instagram.png +0 -0
- package/lib/module/assets/icons/pinterest.png +0 -0
- package/lib/module/assets/icons/swerv_logo.png +0 -0
- package/lib/module/assets/icons/twitter.jpg +0 -0
- package/lib/module/assets/images/Checkbox.svg +3 -0
- package/lib/module/assets/images/EnochE.svg +19 -0
- package/lib/module/assets/images/Enochicon1.png +0 -0
- package/lib/module/assets/images/Face_ID_logo.png +0 -0
- package/lib/module/assets/images/Facebookicon.png +0 -0
- package/lib/module/assets/images/Gmail.png +0 -0
- package/lib/module/assets/images/Googlelogo.png +0 -0
- package/lib/module/assets/images/Linkedinicon.png +0 -0
- package/lib/module/assets/images/Onairoslogo.png +0 -0
- package/lib/module/assets/images/Personalityprofile.svg +3 -0
- package/lib/module/assets/images/Personalitytraits.svg +3 -0
- package/lib/module/assets/images/Redditicon.png +0 -0
- package/lib/module/assets/images/Userpreferences.svg +3 -0
- package/lib/module/assets/images/YouTubeicon3.png +0 -0
- package/lib/module/assets/images/arrow.svg +20 -0
- package/lib/module/assets/images/basicproficon.svg +43 -0
- package/lib/module/assets/images/basicprofile.svg +3 -0
- package/lib/module/assets/images/checkmark.svg +4 -0
- package/lib/module/assets/images/contentanalysis.svg +3 -0
- package/lib/module/assets/images/contenticon.svg +23 -0
- package/lib/module/assets/images/persona1.png +0 -0
- package/lib/module/assets/images/persona2.png +0 -0
- package/lib/module/assets/images/persona3.png +0 -0
- package/lib/module/assets/images/persona4.png +0 -0
- package/lib/module/assets/images/persona5.png +0 -0
- package/lib/module/assets/images/personalityicon.svg +18 -0
- package/lib/module/assets/images/x-close.svg +3 -0
- package/lib/module/components/BodyText.js +20 -0
- package/lib/module/components/BodyText.js.map +1 -0
- package/lib/module/components/BrandMark.js +37 -0
- package/lib/module/components/BrandMark.js.map +1 -0
- package/lib/module/components/CodeInput.js +23 -0
- package/lib/module/components/CodeInput.js.map +1 -0
- package/lib/module/components/EmailInput.js +23 -0
- package/lib/module/components/EmailInput.js.map +1 -0
- package/lib/module/components/ExistingUserDataConfirmation.js +465 -0
- package/lib/module/components/ExistingUserDataConfirmation.js.map +1 -0
- package/lib/module/components/GoogleButton.js +48 -0
- package/lib/module/components/GoogleButton.js.map +1 -0
- package/lib/module/components/HeadingGroup.js +36 -0
- package/lib/module/components/HeadingGroup.js.map +1 -0
- package/lib/module/components/ModalHeader.js +92 -0
- package/lib/module/components/ModalHeader.js.map +1 -0
- package/lib/module/components/ModalSheet.js +34 -0
- package/lib/module/components/ModalSheet.js.map +1 -0
- package/lib/module/components/Onairos.js +1 -3
- package/lib/module/components/Onairos.js.map +1 -1
- package/lib/module/components/OnairosButton.js +172 -192
- package/lib/module/components/OnairosButton.js.map +1 -1
- package/lib/module/components/OnairosSignInButton.js +160 -0
- package/lib/module/components/OnairosSignInButton.js.map +1 -0
- package/lib/module/components/Overlay.js +5 -5
- package/lib/module/components/Overlay.js.map +1 -1
- package/lib/module/components/PersonaImage.js +53 -0
- package/lib/module/components/PersonaImage.js.map +1 -0
- package/lib/module/components/PersonaLoadingScreen.js +148 -0
- package/lib/module/components/PersonaLoadingScreen.js.map +1 -0
- package/lib/module/components/PersonalizationConsentScreen.js +309 -0
- package/lib/module/components/PersonalizationConsentScreen.js.map +1 -0
- package/lib/module/components/PinCreationScreen.js +386 -0
- package/lib/module/components/PinCreationScreen.js.map +1 -0
- package/lib/module/components/PinInput.js +283 -120
- package/lib/module/components/PinInput.js.map +1 -1
- package/lib/module/components/PlatformConnectorsStep.js +820 -0
- package/lib/module/components/PlatformConnectorsStep.js.map +1 -0
- package/lib/module/components/PlatformToggle.js +173 -0
- package/lib/module/components/PlatformToggle.js.map +1 -0
- package/lib/module/components/PrimaryButton.js +172 -0
- package/lib/module/components/PrimaryButton.js.map +1 -0
- package/lib/module/components/SignInMatchAnimation.js +189 -0
- package/lib/module/components/SignInMatchAnimation.js.map +1 -0
- package/lib/module/components/SignInStep.js +171 -0
- package/lib/module/components/SignInStep.js.map +1 -0
- package/lib/module/components/TrainingModal.js +809 -565
- package/lib/module/components/TrainingModal.js.map +1 -1
- package/lib/module/components/UniversalOnboarding.js +2307 -1284
- package/lib/module/components/UniversalOnboarding.js.map +1 -1
- package/lib/module/components/VerificationStep.js +146 -0
- package/lib/module/components/VerificationStep.js.map +1 -0
- package/lib/module/components/WelcomeScreen.js +378 -0
- package/lib/module/components/WelcomeScreen.js.map +1 -0
- package/lib/module/components/icons/Basicproficon.js +30 -0
- package/lib/module/components/icons/Basicproficon.js.map +1 -0
- package/lib/module/components/icons/Basicprofile.js +14 -0
- package/lib/module/components/icons/Basicprofile.js.map +1 -0
- package/lib/module/components/icons/Checkbox.js +14 -0
- package/lib/module/components/icons/Checkbox.js.map +1 -0
- package/lib/module/components/icons/Checkmark.js +20 -0
- package/lib/module/components/icons/Checkmark.js.map +1 -0
- package/lib/module/components/icons/Contentanalysis.js +14 -0
- package/lib/module/components/icons/Contentanalysis.js.map +1 -0
- package/lib/module/components/icons/Contenticon.js +32 -0
- package/lib/module/components/icons/Contenticon.js.map +1 -0
- package/lib/module/components/icons/EnochE.js +34 -0
- package/lib/module/components/icons/EnochE.js.map +1 -0
- package/lib/module/components/icons/Personalityicon.js +23 -0
- package/lib/module/components/icons/Personalityicon.js.map +1 -0
- package/lib/module/components/icons/Personalityprofile.js +14 -0
- package/lib/module/components/icons/Personalityprofile.js.map +1 -0
- package/lib/module/components/icons/Personalitytraits.js +14 -0
- package/lib/module/components/icons/Personalitytraits.js.map +1 -0
- package/lib/module/components/icons/Userpreferences.js +14 -0
- package/lib/module/components/icons/Userpreferences.js.map +1 -0
- package/lib/module/components/icons/index.js +13 -0
- package/lib/module/components/icons/index.js.map +1 -0
- package/lib/module/components/onboarding/OAuthWebView.js +136 -744
- package/lib/module/components/onboarding/OAuthWebView.js.map +1 -1
- package/lib/module/config/api.js +26 -0
- package/lib/module/config/api.js.map +1 -0
- package/lib/module/context/AuthContext.js +335 -0
- package/lib/module/context/AuthContext.js.map +1 -0
- package/lib/module/hooks/useConnectedAccounts.js +106 -0
- package/lib/module/hooks/useConnectedAccounts.js.map +1 -0
- package/lib/module/hooks/useConnections.js +119 -125
- package/lib/module/hooks/useConnections.js.map +1 -1
- package/lib/module/hooks/useUserConnections.js +140 -0
- package/lib/module/hooks/useUserConnections.js.map +1 -0
- package/lib/module/index.js +51 -15
- package/lib/module/index.js.map +1 -1
- package/lib/module/services/apiClient.js +298 -0
- package/lib/module/services/apiClient.js.map +1 -0
- package/lib/module/services/apiKeyService.js +8 -9
- package/lib/module/services/apiKeyService.js.map +1 -1
- package/lib/module/services/authService.js +905 -0
- package/lib/module/services/authService.js.map +1 -0
- package/lib/module/services/biometricPinService.js +173 -0
- package/lib/module/services/biometricPinService.js.map +1 -0
- package/lib/module/services/connectedAccountsService.js +255 -0
- package/lib/module/services/connectedAccountsService.js.map +1 -0
- package/lib/module/services/googleAuthService.js +258 -0
- package/lib/module/services/googleAuthService.js.map +1 -0
- package/lib/module/services/imageCompressionService.js +250 -0
- package/lib/module/services/imageCompressionService.js.map +1 -0
- package/lib/module/services/jwtStorageService.js +239 -0
- package/lib/module/services/jwtStorageService.js.map +1 -0
- package/lib/module/services/mobileTrainingService.js +172 -0
- package/lib/module/services/mobileTrainingService.js.map +1 -0
- package/lib/module/services/pinEncryptionService.js +75 -0
- package/lib/module/services/pinEncryptionService.js.map +1 -0
- package/lib/module/services/pinStorageUtils.js +93 -0
- package/lib/module/services/pinStorageUtils.js.map +1 -0
- package/lib/module/services/platformAuthService.js +943 -704
- package/lib/module/services/platformAuthService.js.map +1 -1
- package/lib/module/services/storageService.js +383 -0
- package/lib/module/services/storageService.js.map +1 -0
- package/lib/module/services/trainingApiHelpers.js +67 -0
- package/lib/module/services/trainingApiHelpers.js.map +1 -0
- package/lib/module/services/userConnectionsService.js +476 -0
- package/lib/module/services/userConnectionsService.js.map +1 -0
- package/lib/module/services/youtubeMigrationService.js +404 -0
- package/lib/module/services/youtubeMigrationService.js.map +1 -0
- package/lib/module/theme/index.js +244 -0
- package/lib/module/theme/index.js.map +1 -0
- package/lib/module/utils/eventUtils.js +270 -0
- package/lib/module/utils/eventUtils.js.map +1 -0
- package/lib/module/utils/haptics.js +59 -0
- package/lib/module/utils/haptics.js.map +1 -0
- package/lib/module/utils/imagePreloader.js +3 -0
- package/lib/module/utils/imagePreloader.js.map +1 -0
- package/lib/typescript/api/index.d.ts +8 -0
- package/lib/typescript/api/index.d.ts.map +1 -1
- package/lib/typescript/components/BodyText.d.ts +10 -0
- package/lib/typescript/components/BodyText.d.ts.map +1 -0
- package/lib/typescript/components/BrandMark.d.ts +11 -0
- package/lib/typescript/components/BrandMark.d.ts.map +1 -0
- package/lib/typescript/components/CodeInput.d.ts +10 -0
- package/lib/typescript/components/CodeInput.d.ts.map +1 -0
- package/lib/typescript/components/EmailInput.d.ts +8 -0
- package/lib/typescript/components/EmailInput.d.ts.map +1 -0
- package/lib/typescript/components/ExistingUserDataConfirmation.d.ts +12 -0
- package/lib/typescript/components/ExistingUserDataConfirmation.d.ts.map +1 -0
- package/lib/typescript/components/GoogleButton.d.ts +11 -0
- package/lib/typescript/components/GoogleButton.d.ts.map +1 -0
- package/lib/typescript/components/HeadingGroup.d.ts +11 -0
- package/lib/typescript/components/HeadingGroup.d.ts.map +1 -0
- package/lib/typescript/components/ModalHeader.d.ts +11 -0
- package/lib/typescript/components/ModalHeader.d.ts.map +1 -0
- package/lib/typescript/components/ModalSheet.d.ts +13 -0
- package/lib/typescript/components/ModalSheet.d.ts.map +1 -0
- package/lib/typescript/components/Onairos.d.ts.map +1 -1
- package/lib/typescript/components/OnairosButton.d.ts +29 -4
- package/lib/typescript/components/OnairosButton.d.ts.map +1 -1
- package/lib/typescript/components/OnairosSignInButton.d.ts +14 -0
- package/lib/typescript/components/OnairosSignInButton.d.ts.map +1 -0
- package/lib/typescript/components/PersonaImage.d.ts +8 -0
- package/lib/typescript/components/PersonaImage.d.ts.map +1 -0
- package/lib/typescript/components/PersonaLoadingScreen.d.ts +10 -0
- package/lib/typescript/components/PersonaLoadingScreen.d.ts.map +1 -0
- package/lib/typescript/components/PersonalizationConsentScreen.d.ts +10 -0
- package/lib/typescript/components/PersonalizationConsentScreen.d.ts.map +1 -0
- package/lib/typescript/components/PinCreationScreen.d.ts +10 -0
- package/lib/typescript/components/PinCreationScreen.d.ts.map +1 -0
- package/lib/typescript/components/PinInput.d.ts +11 -1
- package/lib/typescript/components/PinInput.d.ts.map +1 -1
- package/lib/typescript/components/PlatformConnectorsStep.d.ts +11 -0
- package/lib/typescript/components/PlatformConnectorsStep.d.ts.map +1 -0
- package/lib/typescript/components/PlatformToggle.d.ts +20 -0
- package/lib/typescript/components/PlatformToggle.d.ts.map +1 -0
- package/lib/typescript/components/PrimaryButton.d.ts +22 -0
- package/lib/typescript/components/PrimaryButton.d.ts.map +1 -0
- package/lib/typescript/components/SignInMatchAnimation.d.ts +9 -0
- package/lib/typescript/components/SignInMatchAnimation.d.ts.map +1 -0
- package/lib/typescript/components/SignInStep.d.ts +12 -0
- package/lib/typescript/components/SignInStep.d.ts.map +1 -0
- package/lib/typescript/components/TrainingModal.d.ts +12 -1
- package/lib/typescript/components/TrainingModal.d.ts.map +1 -1
- package/lib/typescript/components/UniversalOnboarding.d.ts +14 -1
- package/lib/typescript/components/UniversalOnboarding.d.ts.map +1 -1
- package/lib/typescript/components/VerificationStep.d.ts +13 -0
- package/lib/typescript/components/VerificationStep.d.ts.map +1 -0
- package/lib/typescript/components/WelcomeScreen.d.ts +9 -0
- package/lib/typescript/components/WelcomeScreen.d.ts.map +1 -0
- package/lib/typescript/components/icons/Basicproficon.d.ts +5 -0
- package/lib/typescript/components/icons/Basicproficon.d.ts.map +1 -0
- package/lib/typescript/components/icons/Basicprofile.d.ts +5 -0
- package/lib/typescript/components/icons/Basicprofile.d.ts.map +1 -0
- package/lib/typescript/components/icons/Checkbox.d.ts +5 -0
- package/lib/typescript/components/icons/Checkbox.d.ts.map +1 -0
- package/lib/typescript/components/icons/Checkmark.d.ts +5 -0
- package/lib/typescript/components/icons/Checkmark.d.ts.map +1 -0
- package/lib/typescript/components/icons/Contentanalysis.d.ts +5 -0
- package/lib/typescript/components/icons/Contentanalysis.d.ts.map +1 -0
- package/lib/typescript/components/icons/Contenticon.d.ts +5 -0
- package/lib/typescript/components/icons/Contenticon.d.ts.map +1 -0
- package/lib/typescript/components/icons/EnochE.d.ts +5 -0
- package/lib/typescript/components/icons/EnochE.d.ts.map +1 -0
- package/lib/typescript/components/icons/Personalityicon.d.ts +5 -0
- package/lib/typescript/components/icons/Personalityicon.d.ts.map +1 -0
- package/lib/typescript/components/icons/Personalityprofile.d.ts +5 -0
- package/lib/typescript/components/icons/Personalityprofile.d.ts.map +1 -0
- package/lib/typescript/components/icons/Personalitytraits.d.ts +5 -0
- package/lib/typescript/components/icons/Personalitytraits.d.ts.map +1 -0
- package/lib/typescript/components/icons/Userpreferences.d.ts +5 -0
- package/lib/typescript/components/icons/Userpreferences.d.ts.map +1 -0
- package/lib/typescript/components/icons/index.d.ts +12 -0
- package/lib/typescript/components/icons/index.d.ts.map +1 -0
- package/lib/typescript/components/onboarding/OAuthWebView.d.ts.map +1 -1
- package/lib/typescript/config/api.d.ts +24 -0
- package/lib/typescript/config/api.d.ts.map +1 -0
- package/lib/typescript/context/AuthContext.d.ts +34 -0
- package/lib/typescript/context/AuthContext.d.ts.map +1 -0
- package/lib/typescript/hooks/useConnectedAccounts.d.ts +11 -0
- package/lib/typescript/hooks/useConnectedAccounts.d.ts.map +1 -0
- package/lib/typescript/hooks/useConnections.d.ts +10 -5
- package/lib/typescript/hooks/useConnections.d.ts.map +1 -1
- package/lib/typescript/hooks/useUserConnections.d.ts +12 -0
- package/lib/typescript/hooks/useUserConnections.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +24 -6
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/services/apiClient.d.ts +91 -0
- package/lib/typescript/services/apiClient.d.ts.map +1 -0
- package/lib/typescript/services/apiKeyService.d.ts.map +1 -1
- package/lib/typescript/services/authService.d.ts +216 -0
- package/lib/typescript/services/authService.d.ts.map +1 -0
- package/lib/typescript/services/biometricPinService.d.ts +29 -0
- package/lib/typescript/services/biometricPinService.d.ts.map +1 -0
- package/lib/typescript/services/connectedAccountsService.d.ts +56 -0
- package/lib/typescript/services/connectedAccountsService.d.ts.map +1 -0
- package/lib/typescript/services/googleAuthService.d.ts +63 -0
- package/lib/typescript/services/googleAuthService.d.ts.map +1 -0
- package/lib/typescript/services/imageCompressionService.d.ts +37 -0
- package/lib/typescript/services/imageCompressionService.d.ts.map +1 -0
- package/lib/typescript/services/jwtStorageService.d.ts +86 -0
- package/lib/typescript/services/jwtStorageService.d.ts.map +1 -0
- package/lib/typescript/services/mobileTrainingService.d.ts +45 -0
- package/lib/typescript/services/mobileTrainingService.d.ts.map +1 -0
- package/lib/typescript/services/pinEncryptionService.d.ts +17 -0
- package/lib/typescript/services/pinEncryptionService.d.ts.map +1 -0
- package/lib/typescript/services/pinStorageUtils.d.ts +25 -0
- package/lib/typescript/services/pinStorageUtils.d.ts.map +1 -0
- package/lib/typescript/services/platformAuthService.d.ts +34 -109
- package/lib/typescript/services/platformAuthService.d.ts.map +1 -1
- package/lib/typescript/services/storageService.d.ts +128 -0
- package/lib/typescript/services/storageService.d.ts.map +1 -0
- package/lib/typescript/services/trainingApiHelpers.d.ts +38 -0
- package/lib/typescript/services/trainingApiHelpers.d.ts.map +1 -0
- package/lib/typescript/services/userConnectionsService.d.ts +90 -0
- package/lib/typescript/services/userConnectionsService.d.ts.map +1 -0
- package/lib/typescript/services/youtubeMigrationService.d.ts +12 -0
- package/lib/typescript/services/youtubeMigrationService.d.ts.map +1 -0
- package/lib/typescript/theme/index.d.ts +416 -0
- package/lib/typescript/theme/index.d.ts.map +1 -0
- package/lib/typescript/types/index.d.ts +39 -0
- package/lib/typescript/types/index.d.ts.map +1 -1
- package/lib/typescript/utils/eventUtils.d.ts +108 -0
- package/lib/typescript/utils/eventUtils.d.ts.map +1 -0
- package/lib/typescript/utils/haptics.d.ts +11 -0
- package/lib/typescript/utils/haptics.d.ts.map +1 -0
- package/lib/typescript/utils/imagePreloader.d.ts +2 -0
- package/lib/typescript/utils/imagePreloader.d.ts.map +1 -0
- package/package.json +163 -145
- package/src/api/index.ts +41 -0
- package/src/assets/fonts/EBGaramond-VariableFont_wght.ttf +0 -0
- package/src/assets/fonts/IBMPlexSans-VariableFont_wdth,wght.ttf +0 -0
- package/src/assets/icons/Facebookicon.png +0 -0
- package/src/assets/icons/Gmail.png +0 -0
- package/src/assets/icons/Linkedinicon.png +0 -0
- package/src/assets/icons/Redditicon.png +0 -0
- package/src/assets/icons/YouTubeicon2.png +0 -0
- package/src/assets/icons/YouTubeicon3.png +0 -0
- package/src/assets/icons/farcaster.png +0 -0
- package/src/assets/icons/instagram.png +0 -0
- package/src/assets/icons/pinterest.png +0 -0
- package/src/assets/icons/swerv_logo.png +0 -0
- package/src/assets/icons/twitter.jpg +0 -0
- package/src/assets/images/Checkbox.svg +3 -0
- package/src/assets/images/EnochE.svg +19 -0
- package/src/assets/images/Enochicon1.png +0 -0
- package/src/assets/images/Face_ID_logo.png +0 -0
- package/src/assets/images/Facebookicon.png +0 -0
- package/src/assets/images/Gmail.png +0 -0
- package/src/assets/images/Googlelogo.png +0 -0
- package/src/assets/images/Linkedinicon.png +0 -0
- package/src/assets/images/Onairoslogo.png +0 -0
- package/src/assets/images/Personalityprofile.svg +3 -0
- package/src/assets/images/Personalitytraits.svg +3 -0
- package/src/assets/images/Redditicon.png +0 -0
- package/src/assets/images/Userpreferences.svg +3 -0
- package/src/assets/images/YouTubeicon3.png +0 -0
- package/src/assets/images/arrow.svg +20 -0
- package/src/assets/images/basicproficon.svg +43 -0
- package/src/assets/images/basicprofile.svg +3 -0
- package/src/assets/images/checkmark.svg +4 -0
- package/src/assets/images/contentanalysis.svg +3 -0
- package/src/assets/images/contenticon.svg +23 -0
- package/src/assets/images/persona1.png +0 -0
- package/src/assets/images/persona2.png +0 -0
- package/src/assets/images/persona3.png +0 -0
- package/src/assets/images/persona4.png +0 -0
- package/src/assets/images/persona5.png +0 -0
- package/src/assets/images/personalityicon.svg +18 -0
- package/src/assets/images/x-close.svg +3 -0
- package/src/components/BodyText.tsx +33 -0
- package/src/components/BrandMark.tsx +62 -0
- package/src/components/CodeInput.tsx +32 -0
- package/src/components/EmailInput.tsx +31 -0
- package/src/components/ExistingUserDataConfirmation.tsx +507 -0
- package/src/components/GoogleButton.tsx +55 -0
- package/src/components/HeadingGroup.tsx +49 -0
- package/src/components/ModalHeader.tsx +125 -0
- package/src/components/ModalSheet.tsx +57 -0
- package/src/components/Onairos.tsx +422 -424
- package/src/components/OnairosButton.tsx +339 -359
- package/src/components/OnairosSignInButton.tsx +166 -0
- package/src/components/Overlay.tsx +506 -506
- package/src/components/PersonaImage.tsx +79 -0
- package/src/components/PersonaLoadingScreen.tsx +201 -0
- package/src/components/PersonalizationConsentScreen.tsx +410 -0
- package/src/components/PinCreationScreen.tsx +492 -0
- package/src/components/PinInput.tsx +555 -343
- package/src/components/PlatformConnectorsStep.tsx +892 -0
- package/src/components/PlatformToggle.tsx +226 -0
- package/src/components/PrimaryButton.tsx +214 -0
- package/src/components/SignInMatchAnimation.tsx +225 -0
- package/src/components/SignInStep.tsx +217 -0
- package/src/components/TrainingModal.tsx +1047 -737
- package/src/components/UniversalOnboarding.tsx +2888 -1820
- package/src/components/VerificationStep.tsx +198 -0
- package/src/components/WelcomeScreen.tsx +473 -0
- package/src/components/icons/Basicproficon.tsx +30 -0
- package/src/components/icons/Basicprofile.tsx +17 -0
- package/src/components/icons/Checkbox.tsx +17 -0
- package/src/components/icons/Checkmark.tsx +24 -0
- package/src/components/icons/Contentanalysis.tsx +17 -0
- package/src/components/icons/Contenticon.tsx +30 -0
- package/src/components/icons/EnochE.tsx +39 -0
- package/src/components/icons/Personalityicon.tsx +22 -0
- package/src/components/icons/Personalityprofile.tsx +17 -0
- package/src/components/icons/Personalitytraits.tsx +17 -0
- package/src/components/icons/Userpreferences.tsx +17 -0
- package/src/components/icons/index.ts +12 -0
- package/src/components/onboarding/OAuthWebView.tsx +232 -838
- package/src/config/api.ts +25 -0
- package/src/context/AuthContext.tsx +393 -0
- package/src/hooks/useConnectedAccounts.ts +139 -0
- package/src/hooks/useConnections.ts +129 -131
- package/src/hooks/useUserConnections.ts +166 -0
- package/src/index.ts +94 -49
- package/src/services/apiClient.ts +337 -0
- package/src/services/apiKeyService.ts +9 -11
- package/src/services/authService.ts +1008 -0
- package/src/services/biometricPinService.ts +193 -0
- package/src/services/connectedAccountsService.ts +290 -0
- package/src/services/googleAuthService.ts +279 -0
- package/src/services/imageCompressionService.ts +303 -0
- package/src/services/jwtStorageService.ts +257 -0
- package/src/services/mobileTrainingService.ts +204 -0
- package/src/services/pinEncryptionService.ts +76 -0
- package/src/services/pinStorageUtils.ts +97 -0
- package/src/services/platformAuthService.ts +1346 -1113
- package/src/services/storageService.ts +452 -0
- package/src/services/trainingApiHelpers.ts +67 -0
- package/src/services/userConnectionsService.ts +557 -0
- package/src/services/youtubeMigrationService.ts +454 -0
- package/src/theme/index.ts +239 -0
- package/src/types/index.ts +265 -238
- package/src/utils/eventUtils.ts +303 -0
- package/src/utils/haptics.ts +59 -0
- package/src/utils/imagePreloader.ts +2 -0
- package/lib/commonjs/assets/images/email.png +0 -0
- package/lib/commonjs/assets/images/linkedin.png +0 -0
- package/lib/commonjs/assets/images/reddit.png +0 -0
- package/lib/commonjs/assets/images/youtube.png +0 -0
- package/lib/commonjs/components/UniversalOnboarding.tsx.new +0 -455
- package/lib/module/assets/images/email.png +0 -0
- package/lib/module/assets/images/linkedin.png +0 -0
- package/lib/module/assets/images/reddit.png +0 -0
- package/lib/module/assets/images/youtube.png +0 -0
- package/lib/module/components/UniversalOnboarding.tsx.new +0 -455
- package/src/assets/images/email.png +0 -0
- package/src/assets/images/linkedin.png +0 -0
- package/src/assets/images/reddit.png +0 -0
- package/src/assets/images/youtube.png +0 -0
- package/src/components/UniversalOnboarding.tsx.new +0 -455
|
@@ -1,1113 +1,1346 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
hasNativeSDK: true
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
clientId: '
|
|
47
|
-
redirectUri: 'onairosevents://auth/callback',
|
|
48
|
-
scope: '
|
|
49
|
-
responseType: 'code',
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
console.log('
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
//
|
|
281
|
-
const
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
console.log('
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
console.
|
|
478
|
-
console.
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
console.
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
}
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
//
|
|
1061
|
-
const
|
|
1062
|
-
'
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
}
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Platform Authentication Service
|
|
3
|
+
* Handles OAuth flows for different platforms
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { Platform, Linking } from 'react-native';
|
|
7
|
+
import { GoogleSignin, statusCodes } from '@react-native-google-signin/google-signin';
|
|
8
|
+
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
9
|
+
import { API_CONFIG, getApiHeaders, getAuthHeaders } from '../config/api';
|
|
10
|
+
|
|
11
|
+
// ๐ CRITICAL: Using the same client ID for both web and iOS to avoid audience errors
|
|
12
|
+
const WEB_CLIENT_ID = '1030678346906-lovkuds2ouqmoc8eu5qpo98spa6edv4o.apps.googleusercontent.com';
|
|
13
|
+
const IOS_CLIENT_ID = '1030678346906-lovkuds2ouqmoc8eu5qpo98spa6edv4o.apps.googleusercontent.com';
|
|
14
|
+
|
|
15
|
+
type OAuthConfig = {
|
|
16
|
+
[key: string]: {
|
|
17
|
+
authUrl?: string;
|
|
18
|
+
clientId?: string;
|
|
19
|
+
redirectUri?: string;
|
|
20
|
+
scope?: string;
|
|
21
|
+
responseType?: string;
|
|
22
|
+
hasNativeSDK: boolean;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// OAuth configuration for different platforms
|
|
27
|
+
const OAUTH_CONFIG: OAuthConfig = {
|
|
28
|
+
instagram: {
|
|
29
|
+
authUrl: 'https://api.instagram.com/oauth/authorize',
|
|
30
|
+
clientId: 'demo_instagram_client_id',
|
|
31
|
+
redirectUri: 'onairosevents://auth/callback',
|
|
32
|
+
scope: 'user_profile,user_media',
|
|
33
|
+
responseType: 'code',
|
|
34
|
+
hasNativeSDK: false
|
|
35
|
+
},
|
|
36
|
+
youtube: {
|
|
37
|
+
authUrl: 'https://api2.onairos.uk/youtube/authorize',
|
|
38
|
+
clientId: '1030678346906-lovkuds2ouqmoc8eu5qpo98spa6edv4o.apps.googleusercontent.com',
|
|
39
|
+
redirectUri: 'onairosevents://auth/callback',
|
|
40
|
+
scope: 'https://www.googleapis.com/auth/youtube.readonly',
|
|
41
|
+
responseType: 'code',
|
|
42
|
+
hasNativeSDK: true // Changed to true for native SDK
|
|
43
|
+
},
|
|
44
|
+
reddit: {
|
|
45
|
+
authUrl: 'https://api2.onairos.uk/reddit/authorize',
|
|
46
|
+
clientId: 'demo_reddit_client_id',
|
|
47
|
+
redirectUri: 'onairosevents://auth/callback',
|
|
48
|
+
scope: 'identity,read',
|
|
49
|
+
responseType: 'code',
|
|
50
|
+
hasNativeSDK: false
|
|
51
|
+
},
|
|
52
|
+
pinterest: {
|
|
53
|
+
authUrl: 'https://api2.onairos.uk/pinterest/authorize',
|
|
54
|
+
clientId: 'demo_pinterest_client_id',
|
|
55
|
+
redirectUri: 'onairosevents://auth/callback',
|
|
56
|
+
scope: 'boards:read,pins:read',
|
|
57
|
+
responseType: 'code',
|
|
58
|
+
hasNativeSDK: false
|
|
59
|
+
},
|
|
60
|
+
facebook: {
|
|
61
|
+
authUrl: 'https://www.facebook.com/v12.0/dialog/oauth',
|
|
62
|
+
clientId: 'demo_facebook_client_id',
|
|
63
|
+
redirectUri: 'onairosevents://auth/callback',
|
|
64
|
+
scope: 'public_profile,email',
|
|
65
|
+
responseType: 'code',
|
|
66
|
+
hasNativeSDK: false
|
|
67
|
+
},
|
|
68
|
+
// GitHub connector is temporarily commented out
|
|
69
|
+
// github: {
|
|
70
|
+
// authUrl: 'https://github.com/login/oauth/authorize',
|
|
71
|
+
// clientId: 'demo_github_client_id',
|
|
72
|
+
// redirectUri: 'onairosevents://auth/callback',
|
|
73
|
+
// scope: 'repo,user',
|
|
74
|
+
// responseType: 'code',
|
|
75
|
+
// hasNativeSDK: false
|
|
76
|
+
// },
|
|
77
|
+
linkedin: {
|
|
78
|
+
authUrl: 'https://api2.onairos.uk/linkedin/authorize',
|
|
79
|
+
clientId: '', // No client ID needed - backend handles OAuth
|
|
80
|
+
redirectUri: 'onairosevents://auth/callback',
|
|
81
|
+
scope: 'openid profile email', // Updated to OpenID Connect scopes as per your backend
|
|
82
|
+
responseType: 'code',
|
|
83
|
+
hasNativeSDK: false // LinkedIn has no modern native SDK
|
|
84
|
+
},
|
|
85
|
+
gmail: {
|
|
86
|
+
authUrl: 'https://api2.onairos.uk/gmail/authorize',
|
|
87
|
+
clientId: 'demo_gmail_client_id',
|
|
88
|
+
redirectUri: 'onairosevents://auth/callback',
|
|
89
|
+
scope: 'https://www.googleapis.com/auth/gmail.readonly',
|
|
90
|
+
responseType: 'code',
|
|
91
|
+
hasNativeSDK: false
|
|
92
|
+
},
|
|
93
|
+
email: {
|
|
94
|
+
// Email doesn't use OAuth but we still need to handle it in the flow
|
|
95
|
+
hasNativeSDK: false,
|
|
96
|
+
authUrl: 'https://api2.onairos.uk/email/authorize' // Proxy endpoint for email verification
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Check if the platform has a native SDK
|
|
102
|
+
*/
|
|
103
|
+
export const hasNativeSDK = (platform: string): boolean => {
|
|
104
|
+
return OAUTH_CONFIG[platform]?.hasNativeSDK || false;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Initiate OAuth flow for a platform
|
|
109
|
+
*/
|
|
110
|
+
export const initiateOAuth = async (platform: string, username: string): Promise<string | null> => {
|
|
111
|
+
try {
|
|
112
|
+
console.log(`๐ [OAUTH] Starting OAuth for platform: ${platform}, username: "${username}"`);
|
|
113
|
+
|
|
114
|
+
// Validate username
|
|
115
|
+
if (!username || username.trim() === '') {
|
|
116
|
+
console.error(`โ [OAUTH] Username is required for ${platform} OAuth`);
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// For platforms that don't need OAuth (like email), handle differently
|
|
121
|
+
if (platform === 'email') {
|
|
122
|
+
console.log('๐ง [OAUTH] Email platform selected, returning mock auth URL');
|
|
123
|
+
return 'https://api2.onairos.uk/email/authorize?action=verify';
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Construct the proxy URL
|
|
127
|
+
const proxyUrl = `https://api2.onairos.uk/${platform}/authorize`;
|
|
128
|
+
console.log(`๐ [OAUTH] Proxy URL: ${proxyUrl}`);
|
|
129
|
+
|
|
130
|
+
const requestBody = {
|
|
131
|
+
session: {
|
|
132
|
+
username: username.trim(),
|
|
133
|
+
platform: platform,
|
|
134
|
+
timestamp: new Date().toISOString()
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
console.log(`๐ค [OAUTH] Request body:`, requestBody);
|
|
138
|
+
console.log(`๐ [OAUTH] Headers:`, getApiHeaders());
|
|
139
|
+
|
|
140
|
+
// Make a POST request to the proxy
|
|
141
|
+
const response = await fetch(proxyUrl, {
|
|
142
|
+
method: 'POST',
|
|
143
|
+
headers: getApiHeaders(),
|
|
144
|
+
body: JSON.stringify(requestBody)
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
console.log(`๐ก [OAUTH] Response status: ${response.status} ${response.statusText}`);
|
|
148
|
+
|
|
149
|
+
if (!response.ok) {
|
|
150
|
+
const errorText = await response.text();
|
|
151
|
+
console.error(`โ [OAUTH] Error initiating OAuth for ${platform}: ${response.status} - ${errorText}`);
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const data = await response.json();
|
|
156
|
+
console.log(`๐ [OAUTH] Response data for ${platform}:`, data);
|
|
157
|
+
|
|
158
|
+
// Get the authorization URL from the response
|
|
159
|
+
// Different platforms might use different keys (e.g., pinterestURL, youtubeURL)
|
|
160
|
+
const urlKey = `${platform}URL`;
|
|
161
|
+
const authUrl = data[urlKey] || data.url || null;
|
|
162
|
+
|
|
163
|
+
console.log(`๐ [OAUTH] Auth URL for ${platform} (key: ${urlKey}):`, authUrl);
|
|
164
|
+
return authUrl;
|
|
165
|
+
} catch (error) {
|
|
166
|
+
console.error(`Error initiating OAuth for ${platform}:`, error);
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Initialize Google Sign-In configuration with enhanced refresh token support
|
|
173
|
+
* Updated with CRITICAL parameters for refresh token generation
|
|
174
|
+
*/
|
|
175
|
+
const initializeGoogleSignIn = () => {
|
|
176
|
+
GoogleSignin.configure({
|
|
177
|
+
webClientId: WEB_CLIENT_ID, // โ
CRITICAL: Web client ID for refresh tokens
|
|
178
|
+
iosClientId: IOS_CLIENT_ID, // โ
iOS client ID for native auth
|
|
179
|
+
|
|
180
|
+
// ๐ CRITICAL: These parameters are REQUIRED for refresh tokens
|
|
181
|
+
offlineAccess: true, // โ CRITICAL: Enables refresh tokens
|
|
182
|
+
forceCodeForRefreshToken: true, // โ CRITICAL: Forces refresh token generation
|
|
183
|
+
|
|
184
|
+
// โ
Enhanced scopes for YouTube
|
|
185
|
+
scopes: [
|
|
186
|
+
'https://www.googleapis.com/auth/youtube.readonly',
|
|
187
|
+
'openid',
|
|
188
|
+
'profile',
|
|
189
|
+
'email'
|
|
190
|
+
],
|
|
191
|
+
|
|
192
|
+
// โ
Clear settings to avoid conflicts
|
|
193
|
+
hostedDomain: '',
|
|
194
|
+
accountName: '',
|
|
195
|
+
});
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Force YouTube reconnection with consent screen to get refresh tokens
|
|
200
|
+
* This is the key function to fix YouTube token expiry issues
|
|
201
|
+
*/
|
|
202
|
+
export const forceYouTubeReconnectionWithConsent = async (username: string): Promise<boolean> => {
|
|
203
|
+
try {
|
|
204
|
+
console.log('๐ FORCING fresh YouTube consent for refresh token...');
|
|
205
|
+
console.log('๐ค User:', username);
|
|
206
|
+
|
|
207
|
+
// Step 1: โ
CRITICAL: Complete sign out (clears all cached consent)
|
|
208
|
+
try {
|
|
209
|
+
await GoogleSignin.signOut();
|
|
210
|
+
console.log('โ
Signed out - consent cache cleared');
|
|
211
|
+
} catch (signOutError) {
|
|
212
|
+
console.log('โน๏ธ Sign out not needed:', signOutError);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// Step 2: โ
CRITICAL: Clear cached tokens if available
|
|
216
|
+
try {
|
|
217
|
+
const existingTokens = await GoogleSignin.getTokens();
|
|
218
|
+
if (existingTokens.accessToken) {
|
|
219
|
+
await GoogleSignin.clearCachedAccessToken(existingTokens.accessToken);
|
|
220
|
+
console.log('โ
Token cache cleared');
|
|
221
|
+
}
|
|
222
|
+
} catch (clearError) {
|
|
223
|
+
console.log('โน๏ธ No token cache to clear');
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// Step 3: โ
CRITICAL: Configure Google Sign-In for FORCED consent
|
|
227
|
+
console.log('๐ง Configuring Google Sign-In for forced consent...');
|
|
228
|
+
GoogleSignin.configure({
|
|
229
|
+
webClientId: WEB_CLIENT_ID, // โ
CRITICAL: Web client ID for refresh tokens
|
|
230
|
+
iosClientId: IOS_CLIENT_ID, // โ
iOS client ID for native auth
|
|
231
|
+
|
|
232
|
+
// ๐ FORCE REFRESH TOKEN SETTINGS:
|
|
233
|
+
offlineAccess: true, // Request offline access
|
|
234
|
+
forceCodeForRefreshToken: true, // Force refresh token generation
|
|
235
|
+
|
|
236
|
+
// ๐ FORCE CONSENT SCREEN:
|
|
237
|
+
scopes: [
|
|
238
|
+
'https://www.googleapis.com/auth/youtube.readonly',
|
|
239
|
+
'openid',
|
|
240
|
+
'profile',
|
|
241
|
+
'email'
|
|
242
|
+
],
|
|
243
|
+
|
|
244
|
+
// โ
CRITICAL: Clear settings to force fresh consent
|
|
245
|
+
hostedDomain: '',
|
|
246
|
+
accountName: '',
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
// Step 4: โ
Check Play Services
|
|
250
|
+
await GoogleSignin.hasPlayServices();
|
|
251
|
+
console.log('โ
Play Services available');
|
|
252
|
+
|
|
253
|
+
// Step 5: โ
CRITICAL: Sign in (this SHOULD show consent screen)
|
|
254
|
+
console.log('๐ Initiating sign-in - consent screen should appear...');
|
|
255
|
+
console.log('๐ฑ User should see: "Allow [App] to access your YouTube account when you\'re not using the app?"');
|
|
256
|
+
|
|
257
|
+
const userInfo = await GoogleSignin.signIn();
|
|
258
|
+
console.log('โ
Sign-in completed - checking for refresh token...');
|
|
259
|
+
console.log('๐ค User email:', userInfo.data?.user?.email);
|
|
260
|
+
|
|
261
|
+
// Step 6: โ
Get tokens after consent
|
|
262
|
+
const tokens = await GoogleSignin.getTokens();
|
|
263
|
+
const currentUser = await GoogleSignin.getCurrentUser();
|
|
264
|
+
|
|
265
|
+
console.log('๐ FULL userInfo object from forceYouTubeReconnectionWithConsent:');
|
|
266
|
+
console.log(JSON.stringify(userInfo, null, 2));
|
|
267
|
+
|
|
268
|
+
console.log('๐ FULL tokens object from forceYouTubeReconnectionWithConsent:');
|
|
269
|
+
console.log(JSON.stringify(tokens, null, 2));
|
|
270
|
+
|
|
271
|
+
console.log('๐ FULL currentUser object from forceYouTubeReconnectionWithConsent:');
|
|
272
|
+
console.log(JSON.stringify(currentUser, null, 2));
|
|
273
|
+
|
|
274
|
+
console.log('๐ Token analysis:');
|
|
275
|
+
console.log('- Access token:', tokens.accessToken ? `${tokens.accessToken.substring(0, 20)}...` : 'Missing');
|
|
276
|
+
console.log('- ID token:', tokens.idToken ? 'Present' : 'Missing');
|
|
277
|
+
console.log('- ServerAuthCode (userInfo):', userInfo.data?.serverAuthCode ? `${userInfo.data.serverAuthCode.substring(0, 20)}...` : 'Missing');
|
|
278
|
+
console.log('- ServerAuthCode (currentUser):', currentUser?.serverAuthCode ? `${currentUser.serverAuthCode.substring(0, 20)}...` : 'Missing');
|
|
279
|
+
|
|
280
|
+
// Step 7: โ
Extract refresh capability
|
|
281
|
+
const refreshToken = userInfo.data?.serverAuthCode || currentUser?.serverAuthCode;
|
|
282
|
+
|
|
283
|
+
if (refreshToken) {
|
|
284
|
+
console.log('โ
SUCCESS: Got refresh token after consent!');
|
|
285
|
+
console.log('๐ Refresh token type:', refreshToken.startsWith('4/') ? 'serverAuthCode' : 'refreshToken');
|
|
286
|
+
console.log('๐ Refresh token preview:', `${refreshToken.substring(0, 20)}...`);
|
|
287
|
+
|
|
288
|
+
// Step 8: โ
Get YouTube channel info
|
|
289
|
+
let channelName = 'Unknown Channel';
|
|
290
|
+
let channelId = null;
|
|
291
|
+
|
|
292
|
+
try {
|
|
293
|
+
console.log('๐บ Fetching YouTube channel information...');
|
|
294
|
+
const channelResponse = await fetch('https://www.googleapis.com/youtube/v3/channels?part=snippet&mine=true', {
|
|
295
|
+
headers: {
|
|
296
|
+
'Authorization': `Bearer ${tokens.accessToken}`,
|
|
297
|
+
'Accept': 'application/json'
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
if (channelResponse.ok) {
|
|
302
|
+
const channelData = await channelResponse.json();
|
|
303
|
+
if (channelData.items && channelData.items.length > 0) {
|
|
304
|
+
channelName = channelData.items[0].snippet.title;
|
|
305
|
+
channelId = channelData.items[0].id;
|
|
306
|
+
console.log('โ
YouTube channel found:', channelName, 'ID:', channelId);
|
|
307
|
+
} else {
|
|
308
|
+
console.log('โ ๏ธ No YouTube channel found for user');
|
|
309
|
+
channelName = userInfo.data?.user?.name || userInfo.data?.user?.email || 'No Channel';
|
|
310
|
+
}
|
|
311
|
+
} else {
|
|
312
|
+
console.log('โ ๏ธ Failed to fetch YouTube channel info:', channelResponse.status);
|
|
313
|
+
channelName = userInfo.data?.user?.name || userInfo.data?.user?.email || 'Unknown Channel';
|
|
314
|
+
}
|
|
315
|
+
} catch (channelError) {
|
|
316
|
+
console.log('โ ๏ธ Error fetching YouTube channel info:', channelError);
|
|
317
|
+
channelName = userInfo.data?.user?.name || userInfo.data?.user?.email || 'Unknown Channel';
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// Step 9: โ
Get authentication token
|
|
321
|
+
let authToken = await AsyncStorage.getItem('onairos_jwt_token') ||
|
|
322
|
+
await AsyncStorage.getItem('enoch_token') ||
|
|
323
|
+
await AsyncStorage.getItem('auth_token');
|
|
324
|
+
|
|
325
|
+
if (!authToken || authToken.trim().length < 20) {
|
|
326
|
+
console.log('๐ Creating authentication token for YouTube connection...');
|
|
327
|
+
// Create token logic here if needed
|
|
328
|
+
authToken = 'temp_token_for_youtube_connection';
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// Step 10: โ
Send comprehensive data to backend
|
|
332
|
+
const backendPayload = {
|
|
333
|
+
session: {
|
|
334
|
+
username: username,
|
|
335
|
+
platform: 'youtube',
|
|
336
|
+
timestamp: new Date().toISOString(),
|
|
337
|
+
channelName: channelName,
|
|
338
|
+
channelId: channelId,
|
|
339
|
+
forceConsent: true // Flag to indicate this was forced consent
|
|
340
|
+
},
|
|
341
|
+
googleUser: userInfo.data?.user,
|
|
342
|
+
accessToken: tokens.accessToken,
|
|
343
|
+
idToken: tokens.idToken,
|
|
344
|
+
refreshToken: refreshToken, // โ
CRITICAL: The refresh token!
|
|
345
|
+
serverAuthCode: refreshToken, // โ
Same as refresh token
|
|
346
|
+
|
|
347
|
+
// โ
CRITICAL: Additional compatibility fields for backend
|
|
348
|
+
refresh_token: refreshToken, // Snake case version
|
|
349
|
+
server_auth_code: refreshToken, // Snake case version
|
|
350
|
+
authCode: refreshToken, // Alternative naming
|
|
351
|
+
|
|
352
|
+
userAccountInfo: {
|
|
353
|
+
username: username,
|
|
354
|
+
email: userInfo.data?.user?.email,
|
|
355
|
+
authToken: authToken,
|
|
356
|
+
channelName: channelName,
|
|
357
|
+
channelId: channelId,
|
|
358
|
+
userIdentifier: authToken ? `user-${authToken.substring(0, 10)}` : `youtube-${userInfo.data?.user?.email}`,
|
|
359
|
+
googleId: userInfo.data?.user?.id,
|
|
360
|
+
// โ
CRITICAL: Also include refresh token in userAccountInfo
|
|
361
|
+
refreshToken: refreshToken,
|
|
362
|
+
serverAuthCode: refreshToken
|
|
363
|
+
},
|
|
364
|
+
tokenExpiry: new Date(Date.now() + 3600 * 1000).toISOString(), // 1 hour from now
|
|
365
|
+
requestRefreshToken: true,
|
|
366
|
+
debugInfo: {
|
|
367
|
+
hasRefreshToken: true,
|
|
368
|
+
refreshTokenType: refreshToken.startsWith('4/') ? 'serverAuthCode' : 'refreshToken',
|
|
369
|
+
configuredForRefresh: true,
|
|
370
|
+
forcedConsent: true,
|
|
371
|
+
consentMethod: 'signOut_and_configure',
|
|
372
|
+
refreshTokenValue: refreshToken // Include actual value for debugging
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
console.log('๐ค Sending comprehensive payload with REFRESH TOKEN to backend:', {
|
|
377
|
+
hasAccessToken: !!backendPayload.accessToken,
|
|
378
|
+
hasRefreshToken: !!backendPayload.refreshToken,
|
|
379
|
+
hasServerAuthCode: !!backendPayload.serverAuthCode,
|
|
380
|
+
refreshTokenType: backendPayload.debugInfo.refreshTokenType,
|
|
381
|
+
userEmail: userInfo.data?.user?.email,
|
|
382
|
+
forcedConsent: true
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
// Step 11: โ
Send to backend with ENHANCED LOGGING
|
|
386
|
+
console.log('๐ [YOUTUBE REAUTH] ===== SENDING REAUTH SIGNAL TO BACKEND =====');
|
|
387
|
+
console.log('๐ [YOUTUBE REAUTH] Endpoint: https://api2.onairos.uk/youtube/native-auth');
|
|
388
|
+
console.log('๐ [YOUTUBE REAUTH] Method: POST');
|
|
389
|
+
console.log('๐ [YOUTUBE REAUTH] Headers:', {
|
|
390
|
+
'Content-Type': 'application/json',
|
|
391
|
+
'Authorization': authToken ? `${authToken.substring(0, 20)}...` : 'NO AUTH TOKEN'
|
|
392
|
+
});
|
|
393
|
+
console.log('๐ [YOUTUBE REAUTH] Payload Summary:', {
|
|
394
|
+
hasAccessToken: !!backendPayload.accessToken,
|
|
395
|
+
hasRefreshToken: !!backendPayload.refreshToken,
|
|
396
|
+
hasServerAuthCode: !!backendPayload.serverAuthCode,
|
|
397
|
+
refreshTokenType: backendPayload.debugInfo.refreshTokenType,
|
|
398
|
+
userEmail: userInfo.data?.user?.email,
|
|
399
|
+
channelName: channelName,
|
|
400
|
+
forcedConsent: true,
|
|
401
|
+
requestRefreshToken: true
|
|
402
|
+
});
|
|
403
|
+
console.log('๐ [YOUTUBE REAUTH] FULL PAYLOAD:', JSON.stringify(backendPayload, null, 2));
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
const backendResponse = await fetch('https://api2.onairos.uk/youtube/native-auth', {
|
|
408
|
+
method: 'POST',
|
|
409
|
+
headers: {
|
|
410
|
+
'Content-Type': 'application/json',
|
|
411
|
+
...(authToken && { 'Authorization': authToken })
|
|
412
|
+
},
|
|
413
|
+
body: JSON.stringify(backendPayload)
|
|
414
|
+
});
|
|
415
|
+
|
|
416
|
+
console.log('๐ก [YOUTUBE REAUTH] Response Status:', backendResponse.status);
|
|
417
|
+
console.log('๐ก [YOUTUBE REAUTH] Response Status Text:', backendResponse.statusText);
|
|
418
|
+
console.log('๐ก [YOUTUBE REAUTH] Response Headers:', backendResponse.headers);
|
|
419
|
+
|
|
420
|
+
if (backendResponse.ok) {
|
|
421
|
+
const responseData = await backendResponse.json();
|
|
422
|
+
console.log('โ
[YOUTUBE REAUTH] Backend Response SUCCESS:', JSON.stringify(responseData, null, 2));
|
|
423
|
+
|
|
424
|
+
// Enhanced verification with detailed logging and temporary mode detection (exact backend fields)
|
|
425
|
+
const isTemporaryMode = responseData.validation?.isTemporaryMode === true ||
|
|
426
|
+
responseData.temporaryMode?.enabled === true ||
|
|
427
|
+
responseData.isTemporaryMode === true ||
|
|
428
|
+
(responseData.message && responseData.message.includes('temporary access token mode'));
|
|
429
|
+
|
|
430
|
+
if (isTemporaryMode) {
|
|
431
|
+
console.log('๐ [YOUTUBE REAUTH] YouTube connected in temporary mode');
|
|
432
|
+
console.log('โ
[YOUTUBE REAUTH] Training will work, but connection expires in ~1 hour');
|
|
433
|
+
console.log('๐ [YOUTUBE REAUTH] SUCCESS: Temporary YouTube connection established!');
|
|
434
|
+
|
|
435
|
+
console.log('๐ [YOUTUBE REAUTH] Connection Details:');
|
|
436
|
+
console.log('๐ [YOUTUBE REAUTH] Mode: Temporary (expires ~1 hour)');
|
|
437
|
+
console.log('๐ [YOUTUBE REAUTH] Training Ready: Yes');
|
|
438
|
+
console.log('๐ [YOUTUBE REAUTH] Refresh token sent:', refreshToken ? 'Yes' : 'No');
|
|
439
|
+
} else if (responseData.hasRefreshToken || responseData.refreshTokenReceived) {
|
|
440
|
+
console.log('โ
[YOUTUBE REAUTH] Backend CONFIRMED refresh token received');
|
|
441
|
+
console.log('โ
[YOUTUBE REAUTH] Response hasRefreshToken:', responseData.hasRefreshToken);
|
|
442
|
+
console.log('๐ [YOUTUBE REAUTH] SUCCESS: Full YouTube connection with refresh tokens!');
|
|
443
|
+
|
|
444
|
+
// CRITICAL: Print the refresh token that was sent for debugging
|
|
445
|
+
console.log('๐ [YOUTUBE REAUTH] REFRESH TOKEN SENT TO BACKEND:');
|
|
446
|
+
console.log('๐ [YOUTUBE REAUTH] Full refresh token:', refreshToken);
|
|
447
|
+
console.log('๐ [YOUTUBE REAUTH] Refresh token type:', refreshToken.startsWith('4/') ? 'serverAuthCode' : 'refreshToken');
|
|
448
|
+
console.log('๐ [YOUTUBE REAUTH] Refresh token length:', refreshToken.length);
|
|
449
|
+
} else {
|
|
450
|
+
console.warn('โ ๏ธ [YOUTUBE REAUTH] Backend did NOT confirm refresh token reception');
|
|
451
|
+
console.warn('โ ๏ธ [YOUTUBE REAUTH] Response data:', responseData);
|
|
452
|
+
console.warn('โ ๏ธ [YOUTUBE REAUTH] Expected hasRefreshToken or refreshTokenReceived in response');
|
|
453
|
+
return false;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
// CRITICAL: Signal training system to restart with new connection
|
|
457
|
+
console.log('๐ [YOUTUBE REAUTH] Signaling training system to restart...');
|
|
458
|
+
try {
|
|
459
|
+
await triggerTrainingRestart(username, authToken);
|
|
460
|
+
console.log('โ
[YOUTUBE REAUTH] Training restart signal sent successfully');
|
|
461
|
+
} catch (restartError) {
|
|
462
|
+
console.warn('โ ๏ธ [YOUTUBE REAUTH] Training restart signal failed:', restartError);
|
|
463
|
+
console.warn('โ ๏ธ [YOUTUBE REAUTH] User may need to manually restart training');
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
return true;
|
|
467
|
+
} else {
|
|
468
|
+
const errorData = await backendResponse.text();
|
|
469
|
+
console.error('โ [YOUTUBE REAUTH] Backend processing FAILED:', backendResponse.status, errorData);
|
|
470
|
+
console.error('โ [YOUTUBE REAUTH] This means the reauth signal was not processed');
|
|
471
|
+
return false;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
} else {
|
|
475
|
+
console.error('โ CRITICAL: No refresh token even after consent screen');
|
|
476
|
+
console.error('โ This means consent screen did not appear or user denied permissions');
|
|
477
|
+
console.error('๐ก Solutions:');
|
|
478
|
+
console.error(' 1. Try the revoke method: forceYouTubeReconnectionWithRevoke()');
|
|
479
|
+
console.error(' 2. Check Google Console OAuth configuration');
|
|
480
|
+
console.error(' 3. Ensure user clicks "Allow" on consent screen');
|
|
481
|
+
return false;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
} catch (error: any) {
|
|
485
|
+
console.error('โ Error forcing YouTube consent:', error);
|
|
486
|
+
|
|
487
|
+
if (error.code === statusCodes.SIGN_IN_CANCELLED) {
|
|
488
|
+
console.error('โ User cancelled sign-in - no refresh token obtained');
|
|
489
|
+
console.error('๐ก User must click "Allow" to get refresh token');
|
|
490
|
+
} else if (error.code === statusCodes.IN_PROGRESS) {
|
|
491
|
+
console.error('โ Sign-in already in progress');
|
|
492
|
+
} else if (error.code === statusCodes.PLAY_SERVICES_NOT_AVAILABLE) {
|
|
493
|
+
console.error('โ Google Play Services not available');
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
return false;
|
|
497
|
+
}
|
|
498
|
+
};
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* Alternative method: Force consent by revoking existing permissions
|
|
502
|
+
*/
|
|
503
|
+
export const forceYouTubeReconnectionWithRevoke = async (username: string): Promise<boolean> => {
|
|
504
|
+
try {
|
|
505
|
+
console.log('๐ FORCING YouTube consent via REVOKE method...');
|
|
506
|
+
console.log('๐ค User:', username);
|
|
507
|
+
|
|
508
|
+
// Step 1: Initialize Google Sign-In
|
|
509
|
+
initializeGoogleSignIn();
|
|
510
|
+
await GoogleSignin.hasPlayServices();
|
|
511
|
+
|
|
512
|
+
// Step 2: โ
CRITICAL: Revoke existing permissions (forces fresh consent)
|
|
513
|
+
try {
|
|
514
|
+
await GoogleSignin.revokeAccess();
|
|
515
|
+
console.log('โ
Revoked existing permissions - fresh consent REQUIRED');
|
|
516
|
+
} catch (revokeError) {
|
|
517
|
+
console.log('โน๏ธ No existing permissions to revoke:', revokeError);
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
// Step 3: Sign out completely
|
|
521
|
+
await GoogleSignin.signOut();
|
|
522
|
+
console.log('โ
Signed out completely');
|
|
523
|
+
|
|
524
|
+
// Step 4: โ
Now sign in again (will DEFINITELY show consent screen)
|
|
525
|
+
console.log('๐ Signing in after revoke - consent screen MUST appear...');
|
|
526
|
+
const userInfo = await GoogleSignin.signIn();
|
|
527
|
+
|
|
528
|
+
// Step 5: โ
User will definitely see consent screen now
|
|
529
|
+
const tokens = await GoogleSignin.getTokens();
|
|
530
|
+
const currentUser = await GoogleSignin.getCurrentUser();
|
|
531
|
+
const refreshToken = userInfo.data?.serverAuthCode || currentUser?.serverAuthCode;
|
|
532
|
+
|
|
533
|
+
if (refreshToken) {
|
|
534
|
+
console.log('โ
SUCCESS: Got refresh token after REVOKE + consent!');
|
|
535
|
+
console.log('๐ Refresh token preview:', `${refreshToken.substring(0, 20)}...`);
|
|
536
|
+
|
|
537
|
+
// Continue with the same backend submission logic as above
|
|
538
|
+
// (Similar to forceYouTubeReconnectionWithConsent)
|
|
539
|
+
|
|
540
|
+
return true;
|
|
541
|
+
} else {
|
|
542
|
+
console.error('โ Still no refresh token after revoke method');
|
|
543
|
+
return false;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
} catch (error) {
|
|
547
|
+
console.error('โ Error with revoke method:', error);
|
|
548
|
+
return false;
|
|
549
|
+
}
|
|
550
|
+
};
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* Fix YouTube connection for a specific user (like nicholase50)
|
|
554
|
+
*/
|
|
555
|
+
export const fixUserYouTubeConnection = async (username: string): Promise<boolean> => {
|
|
556
|
+
console.log(`๐ง Fixing YouTube connection for user: ${username}`);
|
|
557
|
+
|
|
558
|
+
// Method 1: Try forced consent via configuration
|
|
559
|
+
console.log('๐ Method 1: Trying forced consent via configuration...');
|
|
560
|
+
let success = await forceYouTubeReconnectionWithConsent(username);
|
|
561
|
+
|
|
562
|
+
if (success) {
|
|
563
|
+
console.log(`โ
${username} YouTube connection fixed via Method 1!`);
|
|
564
|
+
return true;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
// Method 2: Try forced consent via revoke
|
|
568
|
+
console.log('๐ Method 2: Trying forced consent via revoke...');
|
|
569
|
+
success = await forceYouTubeReconnectionWithRevoke(username);
|
|
570
|
+
|
|
571
|
+
if (success) {
|
|
572
|
+
console.log(`โ
${username} YouTube connection fixed via Method 2!`);
|
|
573
|
+
return true;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
console.error(`โ Failed to fix ${username} YouTube connection with both methods`);
|
|
577
|
+
return false;
|
|
578
|
+
};
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* Get fresh tokens using refresh token
|
|
582
|
+
*/
|
|
583
|
+
const refreshGoogleTokens = async (): Promise<{ accessToken: string; idToken?: string } | null> => {
|
|
584
|
+
try {
|
|
585
|
+
console.log('๐ Attempting to refresh Google tokens...');
|
|
586
|
+
|
|
587
|
+
// Check if user is signed in
|
|
588
|
+
const currentUser = await GoogleSignin.getCurrentUser();
|
|
589
|
+
if (!currentUser) {
|
|
590
|
+
console.log('โ User not signed in to Google, cannot refresh tokens');
|
|
591
|
+
return null;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
// Get fresh tokens
|
|
595
|
+
const tokens = await GoogleSignin.getTokens();
|
|
596
|
+
console.log('โ
Successfully refreshed Google tokens');
|
|
597
|
+
|
|
598
|
+
return {
|
|
599
|
+
accessToken: tokens.accessToken,
|
|
600
|
+
idToken: tokens.idToken
|
|
601
|
+
};
|
|
602
|
+
} catch (error) {
|
|
603
|
+
console.error('โ Failed to refresh Google tokens:', error);
|
|
604
|
+
|
|
605
|
+
// If refresh fails, try to sign in again
|
|
606
|
+
try {
|
|
607
|
+
console.log('๐ Refresh failed, attempting re-authentication...');
|
|
608
|
+
const userInfo = await GoogleSignin.signIn();
|
|
609
|
+
const tokens = await GoogleSignin.getTokens();
|
|
610
|
+
|
|
611
|
+
console.log('โ
Re-authentication successful');
|
|
612
|
+
return {
|
|
613
|
+
accessToken: tokens.accessToken,
|
|
614
|
+
idToken: tokens.idToken
|
|
615
|
+
};
|
|
616
|
+
} catch (signInError) {
|
|
617
|
+
console.error('โ Re-authentication also failed:', signInError);
|
|
618
|
+
return null;
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
};
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
* Debug YouTube tokens to verify refresh token availability
|
|
625
|
+
*/
|
|
626
|
+
const debugYouTubeTokens = async (): Promise<{ hasRefreshToken: boolean; refreshTokenType: string }> => {
|
|
627
|
+
try {
|
|
628
|
+
const tokens = await GoogleSignin.getTokens();
|
|
629
|
+
const currentUser = await GoogleSignin.getCurrentUser();
|
|
630
|
+
|
|
631
|
+
console.log('๐ YouTube Token Debug:', {
|
|
632
|
+
accessToken: tokens.accessToken ? `${tokens.accessToken.substring(0, 20)}...` : 'Missing',
|
|
633
|
+
idToken: tokens.idToken ? 'Present' : 'Missing',
|
|
634
|
+
serverAuthCode: currentUser?.serverAuthCode ? `${currentUser.serverAuthCode.substring(0, 20)}...` : 'Missing',
|
|
635
|
+
userEmail: currentUser?.user?.email || 'Missing'
|
|
636
|
+
});
|
|
637
|
+
|
|
638
|
+
return {
|
|
639
|
+
hasRefreshToken: !!(currentUser?.serverAuthCode),
|
|
640
|
+
refreshTokenType: currentUser?.serverAuthCode ? 'serverAuthCode' : 'none'
|
|
641
|
+
};
|
|
642
|
+
} catch (error) {
|
|
643
|
+
console.error('โ Debug tokens failed:', error);
|
|
644
|
+
return { hasRefreshToken: false, refreshTokenType: 'error' };
|
|
645
|
+
}
|
|
646
|
+
};
|
|
647
|
+
|
|
648
|
+
/**
|
|
649
|
+
* Force fresh YouTube reconnection with proper refresh token
|
|
650
|
+
*/
|
|
651
|
+
export const reconnectYouTube = async (username: string): Promise<boolean> => {
|
|
652
|
+
try {
|
|
653
|
+
console.log('๐ Forcing fresh YouTube reconnection for refresh token...');
|
|
654
|
+
|
|
655
|
+
// 1. Sign out completely to force fresh consent
|
|
656
|
+
try {
|
|
657
|
+
await GoogleSignin.signOut();
|
|
658
|
+
console.log('โ
Signed out from Google');
|
|
659
|
+
} catch (signOutError) {
|
|
660
|
+
console.log('โน๏ธ Already signed out or sign out failed:', signOutError);
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
// 2. Clear any cached tokens
|
|
664
|
+
try {
|
|
665
|
+
const currentTokens = await GoogleSignin.getTokens();
|
|
666
|
+
if (currentTokens.accessToken) {
|
|
667
|
+
await GoogleSignin.clearCachedAccessToken(currentTokens.accessToken);
|
|
668
|
+
console.log('โ
Cleared cached access token');
|
|
669
|
+
}
|
|
670
|
+
} catch (clearError) {
|
|
671
|
+
console.log('โน๏ธ Token clearing failed or not needed:', clearError);
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
// 3. Re-authenticate with fresh consent
|
|
675
|
+
const result = await initiateNativeAuth('youtube', username);
|
|
676
|
+
|
|
677
|
+
if (result) {
|
|
678
|
+
console.log('โ
YouTube reconnected successfully with refresh token');
|
|
679
|
+
|
|
680
|
+
// 4. Verify we now have a refresh token
|
|
681
|
+
const debugInfo = await debugYouTubeTokens();
|
|
682
|
+
if (debugInfo.hasRefreshToken) {
|
|
683
|
+
console.log('โ
Refresh token confirmed:', debugInfo.refreshTokenType);
|
|
684
|
+
} else {
|
|
685
|
+
console.warn('โ ๏ธ Still no refresh token after reconnection');
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
return true;
|
|
689
|
+
} else {
|
|
690
|
+
console.error('โ YouTube reconnection failed');
|
|
691
|
+
return false;
|
|
692
|
+
}
|
|
693
|
+
} catch (error) {
|
|
694
|
+
console.error('โ YouTube reconnection error:', error);
|
|
695
|
+
return false;
|
|
696
|
+
}
|
|
697
|
+
};
|
|
698
|
+
|
|
699
|
+
/**
|
|
700
|
+
* Initiate native authentication for platforms with SDKs
|
|
701
|
+
*/
|
|
702
|
+
export const initiateNativeAuth = async (platform: string, username?: string): Promise<boolean> => {
|
|
703
|
+
if (platform === 'youtube') {
|
|
704
|
+
console.log('๐ Initiating native Google Sign-In for YouTube');
|
|
705
|
+
|
|
706
|
+
// Validate username for YouTube
|
|
707
|
+
if (!username || username.trim() === '') {
|
|
708
|
+
console.error('โ [YOUTUBE AUTH] Username is required for YouTube authentication');
|
|
709
|
+
return false;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
try {
|
|
713
|
+
// Initialize Google Sign-In if not already done
|
|
714
|
+
// โ
CRITICAL: Initialize with CORRECT iOS Client ID
|
|
715
|
+
initializeGoogleSignIn();
|
|
716
|
+
|
|
717
|
+
// Check if Google Play Services are available
|
|
718
|
+
await GoogleSignin.hasPlayServices();
|
|
719
|
+
|
|
720
|
+
// โ
CRITICAL: Force sign out first to ensure fresh consent
|
|
721
|
+
try {
|
|
722
|
+
await GoogleSignin.signOut();
|
|
723
|
+
console.log('๐ Signed out to force fresh consent');
|
|
724
|
+
} catch (signOutError) {
|
|
725
|
+
console.log('โน๏ธ Sign out not needed or failed:', signOutError);
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
// Sign in with Google (this will show consent screen due to our config)
|
|
729
|
+
const userInfo = await GoogleSignin.signIn();
|
|
730
|
+
console.log('โ
Google Sign-In successful:', userInfo.data?.user?.email);
|
|
731
|
+
|
|
732
|
+
console.log('๐ FULL userInfo object:');
|
|
733
|
+
console.log(JSON.stringify(userInfo, null, 2));
|
|
734
|
+
|
|
735
|
+
// Get access token for API calls
|
|
736
|
+
const tokens = await GoogleSignin.getTokens();
|
|
737
|
+
console.log('๐ Got Google tokens');
|
|
738
|
+
console.log('๐ FULL tokens object:');
|
|
739
|
+
console.log(JSON.stringify(tokens, null, 2));
|
|
740
|
+
|
|
741
|
+
// CRITICAL: Get the current user info which contains the refresh token
|
|
742
|
+
const currentUser = await GoogleSignin.getCurrentUser();
|
|
743
|
+
console.log('๐ค Current user info:', currentUser?.user?.email);
|
|
744
|
+
console.log('๐ FULL currentUser object:');
|
|
745
|
+
console.log(JSON.stringify(currentUser, null, 2));
|
|
746
|
+
|
|
747
|
+
// โ
CRITICAL: Extract refresh token properly using serverAuthCode
|
|
748
|
+
let refreshToken = null;
|
|
749
|
+
|
|
750
|
+
console.log('๐ REFRESH TOKEN EXTRACTION:');
|
|
751
|
+
console.log('- userInfo.data?.serverAuthCode:', userInfo.data?.serverAuthCode ? `Present: ${userInfo.data.serverAuthCode.substring(0, 20)}...` : 'Missing');
|
|
752
|
+
console.log('- currentUser?.serverAuthCode:', currentUser?.serverAuthCode ? `Present: ${currentUser.serverAuthCode.substring(0, 20)}...` : 'Missing');
|
|
753
|
+
console.log('- tokens.idToken:', tokens.idToken ? `Present: ${tokens.idToken.substring(0, 20)}...` : 'Missing');
|
|
754
|
+
console.log('- tokens.accessToken:', tokens.accessToken ? `Present: ${tokens.accessToken.substring(0, 20)}...` : 'Missing');
|
|
755
|
+
|
|
756
|
+
// The serverAuthCode is the refresh token mechanism for React Native Google Sign-In
|
|
757
|
+
if (currentUser?.serverAuthCode) {
|
|
758
|
+
refreshToken = currentUser.serverAuthCode;
|
|
759
|
+
console.log('โ
Got serverAuthCode (refresh token mechanism)');
|
|
760
|
+
console.log('๐ Refresh token preview:', `${refreshToken.substring(0, 20)}...`);
|
|
761
|
+
} else if (userInfo.data?.serverAuthCode) {
|
|
762
|
+
refreshToken = userInfo.data.serverAuthCode;
|
|
763
|
+
console.log('โ
Got serverAuthCode from sign-in response');
|
|
764
|
+
console.log('๐ Refresh token preview:', `${refreshToken.substring(0, 20)}...`);
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
// โ
CRITICAL: Verify refresh token availability
|
|
768
|
+
if (!refreshToken) {
|
|
769
|
+
console.error('โ CRITICAL: No refresh token available - YouTube connection will fail when token expires');
|
|
770
|
+
console.error('๐ก User needs to reconnect with proper consent screen');
|
|
771
|
+
console.error('๐ก Check Google Sign-In configuration: offlineAccess, forceCodeForRefreshToken');
|
|
772
|
+
|
|
773
|
+
// Still continue but warn about the issue
|
|
774
|
+
console.warn('โ ๏ธ Continuing without refresh token - connection may fail later');
|
|
775
|
+
} else {
|
|
776
|
+
console.log('โ
Refresh token available for YouTube connection');
|
|
777
|
+
console.log('๐ Refresh token type:', refreshToken.startsWith('4/') ? 'serverAuthCode' : 'refreshToken');
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
// Fetch YouTube channel information using the access token
|
|
781
|
+
let channelName = 'Unknown Channel';
|
|
782
|
+
let channelId = null;
|
|
783
|
+
try {
|
|
784
|
+
console.log('๐บ Fetching YouTube channel information...');
|
|
785
|
+
const channelResponse = await fetch('https://www.googleapis.com/youtube/v3/channels?part=snippet&mine=true', {
|
|
786
|
+
headers: {
|
|
787
|
+
'Authorization': `Bearer ${tokens.accessToken}`,
|
|
788
|
+
'Accept': 'application/json'
|
|
789
|
+
}
|
|
790
|
+
});
|
|
791
|
+
|
|
792
|
+
if (channelResponse.ok) {
|
|
793
|
+
const channelData = await channelResponse.json();
|
|
794
|
+
if (channelData.items && channelData.items.length > 0) {
|
|
795
|
+
channelName = channelData.items[0].snippet.title;
|
|
796
|
+
channelId = channelData.items[0].id;
|
|
797
|
+
console.log('โ
YouTube channel found:', channelName, 'ID:', channelId);
|
|
798
|
+
} else {
|
|
799
|
+
console.log('โ ๏ธ No YouTube channel found for user');
|
|
800
|
+
channelName = userInfo.data?.user?.name || userInfo.data?.user?.email || 'No Channel';
|
|
801
|
+
}
|
|
802
|
+
} else {
|
|
803
|
+
console.log('โ ๏ธ Failed to fetch YouTube channel info:', channelResponse.status);
|
|
804
|
+
channelName = userInfo.data?.user?.name || userInfo.data?.user?.email || 'Unknown Channel';
|
|
805
|
+
}
|
|
806
|
+
} catch (channelError) {
|
|
807
|
+
console.log('โ ๏ธ Error fetching YouTube channel info:', channelError);
|
|
808
|
+
channelName = userInfo.data?.user?.name || userInfo.data?.user?.email || 'Unknown Channel';
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
// Get stored authentication info to link YouTube data to user account
|
|
812
|
+
let authToken = await AsyncStorage.getItem('onairos_jwt_token') || await AsyncStorage.getItem('enoch_token') || await AsyncStorage.getItem('auth_token');
|
|
813
|
+
const storedUsername = await AsyncStorage.getItem('onairos_username');
|
|
814
|
+
const finalUsername = storedUsername || username || userInfo.data?.user?.email || 'youtube_user';
|
|
815
|
+
|
|
816
|
+
// If no auth token exists, create one now to ensure YouTube data is linked to user account
|
|
817
|
+
if (!authToken || authToken.trim().length < 20) {
|
|
818
|
+
console.log('๐ No valid authentication token found, creating one for YouTube authentication...');
|
|
819
|
+
|
|
820
|
+
try {
|
|
821
|
+
// Create user accounts and get proper Enoch token
|
|
822
|
+
const fallbackEmail = userInfo.data?.user?.email || `${finalUsername}@youtube.temp`;
|
|
823
|
+
|
|
824
|
+
// Step 1: Create Enoch user first
|
|
825
|
+
console.log('๐ Step 1: Creating Enoch user for YouTube auth...');
|
|
826
|
+
try {
|
|
827
|
+
const enochRegisterResponse = await fetch('https://api2.onairos.uk/enoch/users/register', {
|
|
828
|
+
method: 'POST',
|
|
829
|
+
headers: {
|
|
830
|
+
'Content-Type': 'application/json'
|
|
831
|
+
},
|
|
832
|
+
body: JSON.stringify({
|
|
833
|
+
email: fallbackEmail,
|
|
834
|
+
name: finalUsername,
|
|
835
|
+
photoUrl: userInfo.data?.user?.photo || ''
|
|
836
|
+
})
|
|
837
|
+
});
|
|
838
|
+
|
|
839
|
+
console.log('๐ก Enoch register response status:', enochRegisterResponse.status);
|
|
840
|
+
const enochResponseData = await enochRegisterResponse.json();
|
|
841
|
+
console.log('๐ Enoch user creation response:', enochResponseData);
|
|
842
|
+
} catch (enochError) {
|
|
843
|
+
console.warn('โ ๏ธ Enoch user creation failed (continuing):', enochError);
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
// Step 2: Create Onairos account to get JWT token
|
|
847
|
+
console.log('๐ Step 2: Creating Onairos account for YouTube auth...');
|
|
848
|
+
const onairosSignupResponse = await fetch('https://api2.onairos.uk/register/enoch', {
|
|
849
|
+
method: 'POST',
|
|
850
|
+
headers: {
|
|
851
|
+
'Content-Type': 'application/json'
|
|
852
|
+
},
|
|
853
|
+
body: JSON.stringify({
|
|
854
|
+
email: fallbackEmail,
|
|
855
|
+
username: finalUsername,
|
|
856
|
+
name: finalUsername
|
|
857
|
+
})
|
|
858
|
+
});
|
|
859
|
+
|
|
860
|
+
console.log('๐ก Onairos register response status:', onairosSignupResponse.status);
|
|
861
|
+
|
|
862
|
+
if (onairosSignupResponse.ok) {
|
|
863
|
+
const onairosResponseData = await onairosSignupResponse.json();
|
|
864
|
+
console.log('๐ Onairos account creation response:', onairosResponseData);
|
|
865
|
+
|
|
866
|
+
// Extract the token from the response
|
|
867
|
+
if (onairosResponseData.token) {
|
|
868
|
+
authToken = onairosResponseData.token;
|
|
869
|
+
} else if (onairosResponseData.data?.token) {
|
|
870
|
+
authToken = onairosResponseData.data.token;
|
|
871
|
+
} else if (onairosResponseData.jwt) {
|
|
872
|
+
authToken = onairosResponseData.jwt;
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
if (authToken) {
|
|
876
|
+
// Store the Enoch token in all the standard locations
|
|
877
|
+
await AsyncStorage.setItem('onairos_jwt_token', authToken);
|
|
878
|
+
await AsyncStorage.setItem('enoch_token', authToken);
|
|
879
|
+
await AsyncStorage.setItem('auth_token', authToken);
|
|
880
|
+
await AsyncStorage.setItem('onairos_username', onairosResponseData.username || finalUsername);
|
|
881
|
+
|
|
882
|
+
console.log('โ
Successfully created and stored Enoch authentication token for YouTube');
|
|
883
|
+
console.log('๐ Enoch token preview:', `${authToken.substring(0, 20)}...`);
|
|
884
|
+
}
|
|
885
|
+
} else {
|
|
886
|
+
const errorText = await onairosSignupResponse.text();
|
|
887
|
+
console.warn('โ ๏ธ Could not create Enoch auth token for YouTube:', errorText);
|
|
888
|
+
}
|
|
889
|
+
} catch (tokenError) {
|
|
890
|
+
console.warn('โ ๏ธ Error creating Enoch auth token for YouTube:', tokenError);
|
|
891
|
+
// Continue without token - backend will handle gracefully
|
|
892
|
+
}
|
|
893
|
+
} else {
|
|
894
|
+
console.log('โ
Found existing authentication token for YouTube auth');
|
|
895
|
+
console.log('๐ Token preview:', `${authToken.substring(0, 20)}...`);
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
console.log('๐ Linking YouTube data to user:', finalUsername);
|
|
899
|
+
console.log('๐ Using auth token for linking:', authToken ? `${authToken.substring(0, 20)}...` : 'No token');
|
|
900
|
+
console.log('๐บ YouTube channel name:', channelName);
|
|
901
|
+
|
|
902
|
+
// โ
CRITICAL: Enhanced payload with comprehensive refresh token data
|
|
903
|
+
const backendPayload = {
|
|
904
|
+
session: {
|
|
905
|
+
username: finalUsername,
|
|
906
|
+
platform: 'youtube',
|
|
907
|
+
timestamp: new Date().toISOString(),
|
|
908
|
+
channelName: channelName,
|
|
909
|
+
channelId: channelId
|
|
910
|
+
},
|
|
911
|
+
googleUser: userInfo.data?.user,
|
|
912
|
+
accessToken: tokens.accessToken,
|
|
913
|
+
idToken: tokens.idToken,
|
|
914
|
+
refreshToken: refreshToken, // โ
CRITICAL: Include refresh token
|
|
915
|
+
serverAuthCode: refreshToken, // โ
Alternative refresh mechanism (same as refreshToken)
|
|
916
|
+
|
|
917
|
+
// โ
CRITICAL: Additional compatibility fields for backend
|
|
918
|
+
refresh_token: refreshToken, // Snake case version
|
|
919
|
+
server_auth_code: refreshToken, // Snake case version
|
|
920
|
+
authCode: refreshToken, // Alternative naming
|
|
921
|
+
|
|
922
|
+
// Include user account linking information
|
|
923
|
+
userAccountInfo: {
|
|
924
|
+
username: finalUsername,
|
|
925
|
+
email: userInfo.data?.user?.email,
|
|
926
|
+
authToken: authToken,
|
|
927
|
+
channelName: channelName,
|
|
928
|
+
channelId: channelId,
|
|
929
|
+
// CRITICAL: Include user identifier that matches your database
|
|
930
|
+
userIdentifier: authToken ? `user-${authToken.substring(0, 10)}` : `youtube-${userInfo.data?.user?.email}`,
|
|
931
|
+
googleId: userInfo.data?.user?.id,
|
|
932
|
+
appleUserId: authToken?.includes('apple') ? authToken.split('.')[1] : null,
|
|
933
|
+
// โ
CRITICAL: Also include refresh token in userAccountInfo
|
|
934
|
+
refreshToken: refreshToken,
|
|
935
|
+
serverAuthCode: refreshToken
|
|
936
|
+
},
|
|
937
|
+
// Token expiry information
|
|
938
|
+
tokenExpiry: new Date(Date.now() + 3600 * 1000).toISOString(), // 1 hour from now
|
|
939
|
+
// Force refresh token request
|
|
940
|
+
requestRefreshToken: true,
|
|
941
|
+
// โ
CRITICAL: Debug information for backend
|
|
942
|
+
debugInfo: {
|
|
943
|
+
hasRefreshToken: !!refreshToken,
|
|
944
|
+
refreshTokenType: refreshToken ?
|
|
945
|
+
(refreshToken.startsWith('4/') ? 'serverAuthCode' : 'refreshToken') : 'none',
|
|
946
|
+
configuredForRefresh: true,
|
|
947
|
+
forcedConsent: true,
|
|
948
|
+
refreshTokenValue: refreshToken // Include actual value for debugging
|
|
949
|
+
}
|
|
950
|
+
};
|
|
951
|
+
|
|
952
|
+
console.log('๐ค BACKEND PAYLOAD SUMMARY:');
|
|
953
|
+
console.log('- hasAccessToken:', !!backendPayload.accessToken);
|
|
954
|
+
console.log('- hasRefreshToken:', !!backendPayload.refreshToken);
|
|
955
|
+
console.log('- hasServerAuthCode:', !!backendPayload.serverAuthCode);
|
|
956
|
+
console.log('- refreshTokenType:', backendPayload.debugInfo.refreshTokenType);
|
|
957
|
+
console.log('- userEmail:', userInfo.data?.user?.email);
|
|
958
|
+
console.log('- channelName:', channelName);
|
|
959
|
+
|
|
960
|
+
console.log('๐ COMPLETE BACKEND PAYLOAD:');
|
|
961
|
+
console.log(JSON.stringify(backendPayload, null, 2));
|
|
962
|
+
|
|
963
|
+
// Send the tokens to your backend for YouTube data processing with ENHANCED LOGGING
|
|
964
|
+
console.log('๐ค Sending YouTube auth to backend with refresh token:', !!refreshToken);
|
|
965
|
+
|
|
966
|
+
const backendResponse = await fetch('https://api2.onairos.uk/youtube/native-auth', {
|
|
967
|
+
method: 'POST',
|
|
968
|
+
headers: {
|
|
969
|
+
'Content-Type': 'application/json',
|
|
970
|
+
...(authToken && { 'Authorization': authToken }) // Include auth token if available
|
|
971
|
+
},
|
|
972
|
+
body: JSON.stringify(backendPayload)
|
|
973
|
+
});
|
|
974
|
+
|
|
975
|
+
console.log('๐ก Backend response status:', backendResponse.status);
|
|
976
|
+
console.log('๐ก Backend response headers:', backendResponse.headers);
|
|
977
|
+
|
|
978
|
+
if (backendResponse.ok) {
|
|
979
|
+
const responseData = await backendResponse.json();
|
|
980
|
+
console.log('โ
YouTube connection successful');
|
|
981
|
+
console.log('๐ COMPLETE BACKEND RESPONSE:');
|
|
982
|
+
console.log(JSON.stringify(responseData, null, 2));
|
|
983
|
+
|
|
984
|
+
// โ
Enhanced verification with temporary mode detection (exact backend fields)
|
|
985
|
+
const isTemporaryMode = responseData.validation?.isTemporaryMode === true ||
|
|
986
|
+
responseData.temporaryMode?.enabled === true ||
|
|
987
|
+
responseData.isTemporaryMode === true ||
|
|
988
|
+
(responseData.message && responseData.message.includes('temporary access token mode'));
|
|
989
|
+
|
|
990
|
+
if (isTemporaryMode) {
|
|
991
|
+
console.log('๐ [YOUTUBE AUTH] YouTube connected in temporary mode');
|
|
992
|
+
console.log('โ
[YOUTUBE AUTH] Training will work, but connection expires in ~1 hour');
|
|
993
|
+
console.log('โน๏ธ [YOUTUBE AUTH] User can reconnect later for refresh tokens if needed');
|
|
994
|
+
} else if (responseData.hasRefreshToken || responseData.refreshTokenReceived) {
|
|
995
|
+
console.log('โ
[YOUTUBE AUTH] Backend confirmed refresh token received');
|
|
996
|
+
console.log('โ
[YOUTUBE AUTH] Full YouTube connection with persistent access');
|
|
997
|
+
} else {
|
|
998
|
+
console.warn('โ ๏ธ [YOUTUBE AUTH] Backend did not confirm refresh token');
|
|
999
|
+
console.warn('๐ [YOUTUBE AUTH] Response data keys:', Object.keys(responseData));
|
|
1000
|
+
console.warn('โ ๏ธ [YOUTUBE AUTH] Connection may fail when tokens expire');
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
return true;
|
|
1004
|
+
} else {
|
|
1005
|
+
const errorData = await backendResponse.text();
|
|
1006
|
+
console.error('โ YouTube auth failed:', backendResponse.status);
|
|
1007
|
+
console.error('๐ BACKEND ERROR RESPONSE:');
|
|
1008
|
+
console.error(errorData);
|
|
1009
|
+
return false;
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
} catch (error: any) {
|
|
1013
|
+
console.error('โ Google Sign-In error:', error);
|
|
1014
|
+
|
|
1015
|
+
if (error.code === statusCodes.SIGN_IN_CANCELLED) {
|
|
1016
|
+
console.log('User cancelled Google Sign-In');
|
|
1017
|
+
} else if (error.code === statusCodes.IN_PROGRESS) {
|
|
1018
|
+
console.log('Google Sign-In already in progress');
|
|
1019
|
+
} else if (error.code === statusCodes.PLAY_SERVICES_NOT_AVAILABLE) {
|
|
1020
|
+
console.log('Google Play Services not available');
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
return false;
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
// Instagram is commented out in the UI, but keeping the code for future use
|
|
1028
|
+
if (platform === 'instagram') {
|
|
1029
|
+
// Simulate Facebook Login SDK for Instagram
|
|
1030
|
+
console.log('Initiating Facebook Login for Instagram');
|
|
1031
|
+
return new Promise(resolve => {
|
|
1032
|
+
setTimeout(() => {
|
|
1033
|
+
console.log('Facebook Login completed successfully');
|
|
1034
|
+
resolve(true);
|
|
1035
|
+
}, 1000);
|
|
1036
|
+
});
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
return false;
|
|
1040
|
+
};
|
|
1041
|
+
|
|
1042
|
+
/**
|
|
1043
|
+
* Check if a URL is an OAuth callback
|
|
1044
|
+
*/
|
|
1045
|
+
export const isOAuthCallback = (url: string): boolean => {
|
|
1046
|
+
return url.includes('auth/callback') || url.includes('code=');
|
|
1047
|
+
};
|
|
1048
|
+
|
|
1049
|
+
/**
|
|
1050
|
+
* Exchange authorization code for access token
|
|
1051
|
+
* This would typically be done on a server, but we're simulating it here
|
|
1052
|
+
*/
|
|
1053
|
+
export const exchangeCodeForToken = async (code: string, platform: string): Promise<any> => {
|
|
1054
|
+
console.log(`Exchanging code for token for platform: ${platform}`);
|
|
1055
|
+
|
|
1056
|
+
try {
|
|
1057
|
+
// Use the proxy server to exchange the code for a token
|
|
1058
|
+
const tokenUrl = `https://api2.onairos.uk/${platform}/token`;
|
|
1059
|
+
|
|
1060
|
+
// Make a POST request to the proxy
|
|
1061
|
+
const response = await fetch(tokenUrl, {
|
|
1062
|
+
method: 'POST',
|
|
1063
|
+
headers: {
|
|
1064
|
+
'Content-Type': 'application/json'
|
|
1065
|
+
},
|
|
1066
|
+
body: JSON.stringify({
|
|
1067
|
+
code: code,
|
|
1068
|
+
platform: platform
|
|
1069
|
+
})
|
|
1070
|
+
});
|
|
1071
|
+
|
|
1072
|
+
if (!response.ok) {
|
|
1073
|
+
console.error(`Error exchanging code for token: ${response.status}`);
|
|
1074
|
+
throw new Error(`Token exchange failed with status ${response.status}`);
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
const data = await response.json();
|
|
1078
|
+
console.log(`Token exchange successful for ${platform}`);
|
|
1079
|
+
return data;
|
|
1080
|
+
} catch (error) {
|
|
1081
|
+
console.error(`Error exchanging code for token:`, error);
|
|
1082
|
+
|
|
1083
|
+
// Fallback to simulation if the API call fails
|
|
1084
|
+
console.log('Falling back to simulated token response');
|
|
1085
|
+
return {
|
|
1086
|
+
access_token: `${platform}_access_token_${Math.random().toString(36).substring(7)}`,
|
|
1087
|
+
refresh_token: `${platform}_refresh_token_${Math.random().toString(36).substring(7)}`,
|
|
1088
|
+
expires_in: 3600,
|
|
1089
|
+
};
|
|
1090
|
+
}
|
|
1091
|
+
};
|
|
1092
|
+
|
|
1093
|
+
/**
|
|
1094
|
+
* Refresh YouTube tokens when they expire
|
|
1095
|
+
* This should be called when the backend reports token expiry
|
|
1096
|
+
*/
|
|
1097
|
+
export const refreshYouTubeTokens = async (): Promise<boolean> => {
|
|
1098
|
+
try {
|
|
1099
|
+
console.log('๐ Refreshing YouTube tokens...');
|
|
1100
|
+
|
|
1101
|
+
// Get fresh tokens from Google SDK
|
|
1102
|
+
const freshTokens = await GoogleSignin.getTokens();
|
|
1103
|
+
if (!freshTokens) {
|
|
1104
|
+
console.error('โ Failed to get fresh tokens from Google SDK');
|
|
1105
|
+
return false;
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
// Get current user info
|
|
1109
|
+
const currentUser = await GoogleSignin.getCurrentUser();
|
|
1110
|
+
if (!currentUser) {
|
|
1111
|
+
console.error('โ No current Google user found');
|
|
1112
|
+
return false;
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
// Get stored auth token
|
|
1116
|
+
const authToken = await AsyncStorage.getItem('onairos_jwt_token') ||
|
|
1117
|
+
await AsyncStorage.getItem('enoch_token') ||
|
|
1118
|
+
await AsyncStorage.getItem('auth_token');
|
|
1119
|
+
|
|
1120
|
+
if (!authToken) {
|
|
1121
|
+
console.error('โ No auth token found for YouTube refresh');
|
|
1122
|
+
return false;
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
// Send refreshed tokens to backend
|
|
1126
|
+
const refreshResponse = await fetch('https://api2.onairos.uk/youtube/refresh-token', {
|
|
1127
|
+
method: 'POST',
|
|
1128
|
+
headers: {
|
|
1129
|
+
'Content-Type': 'application/json',
|
|
1130
|
+
'Authorization': authToken
|
|
1131
|
+
},
|
|
1132
|
+
body: JSON.stringify({
|
|
1133
|
+
accessToken: freshTokens.accessToken,
|
|
1134
|
+
idToken: freshTokens.idToken,
|
|
1135
|
+
refreshToken: currentUser.serverAuthCode,
|
|
1136
|
+
userEmail: currentUser.user?.email,
|
|
1137
|
+
tokenExpiry: new Date(Date.now() + 3600 * 1000).toISOString(), // 1 hour from now
|
|
1138
|
+
timestamp: new Date().toISOString()
|
|
1139
|
+
})
|
|
1140
|
+
});
|
|
1141
|
+
|
|
1142
|
+
if (refreshResponse.ok) {
|
|
1143
|
+
const responseData = await refreshResponse.json();
|
|
1144
|
+
console.log('โ
YouTube tokens refreshed successfully:', responseData);
|
|
1145
|
+
return true;
|
|
1146
|
+
} else {
|
|
1147
|
+
const errorData = await refreshResponse.text();
|
|
1148
|
+
console.error('โ YouTube token refresh failed:', refreshResponse.status, errorData);
|
|
1149
|
+
return false;
|
|
1150
|
+
}
|
|
1151
|
+
} catch (error) {
|
|
1152
|
+
console.error('โ Error refreshing YouTube tokens:', error);
|
|
1153
|
+
return false;
|
|
1154
|
+
}
|
|
1155
|
+
};
|
|
1156
|
+
|
|
1157
|
+
/**
|
|
1158
|
+
* Trigger training restart after YouTube re-authentication
|
|
1159
|
+
* This signals the backend to restart training with the new refresh token
|
|
1160
|
+
*/
|
|
1161
|
+
const triggerTrainingRestart = async (username: string, authToken: string): Promise<void> => {
|
|
1162
|
+
try {
|
|
1163
|
+
console.log('๐ [TRAINING RESTART] Triggering training restart for user:', username);
|
|
1164
|
+
|
|
1165
|
+
const response = await fetch('https://api2.onairos.uk/mobile-training/restart', {
|
|
1166
|
+
method: 'POST',
|
|
1167
|
+
headers: {
|
|
1168
|
+
'Content-Type': 'application/json',
|
|
1169
|
+
'Authorization': authToken
|
|
1170
|
+
},
|
|
1171
|
+
body: JSON.stringify({
|
|
1172
|
+
username: username,
|
|
1173
|
+
reason: 'youtube_reauth',
|
|
1174
|
+
platform: 'youtube',
|
|
1175
|
+
timestamp: new Date().toISOString(),
|
|
1176
|
+
requestNewTraining: true
|
|
1177
|
+
})
|
|
1178
|
+
});
|
|
1179
|
+
|
|
1180
|
+
if (response.ok) {
|
|
1181
|
+
const responseData = await response.json();
|
|
1182
|
+
console.log('โ
[TRAINING RESTART] Training restart successful:', responseData);
|
|
1183
|
+
} else {
|
|
1184
|
+
const errorData = await response.text();
|
|
1185
|
+
console.error('โ [TRAINING RESTART] Training restart failed:', response.status, errorData);
|
|
1186
|
+
throw new Error(`Training restart failed: ${response.status}`);
|
|
1187
|
+
}
|
|
1188
|
+
} catch (error) {
|
|
1189
|
+
console.error('โ [TRAINING RESTART] Error triggering training restart:', error);
|
|
1190
|
+
throw error;
|
|
1191
|
+
}
|
|
1192
|
+
};
|
|
1193
|
+
|
|
1194
|
+
/**
|
|
1195
|
+
* Test function to verify YouTube refresh token functionality
|
|
1196
|
+
* Call this in your app to test the YouTube connection
|
|
1197
|
+
*/
|
|
1198
|
+
export const testYouTubeRefreshToken = async (username: string): Promise<void> => {
|
|
1199
|
+
console.log('๐งช Testing YouTube refresh token functionality...');
|
|
1200
|
+
console.log('๐ค User:', username);
|
|
1201
|
+
|
|
1202
|
+
try {
|
|
1203
|
+
// Test the debug function first
|
|
1204
|
+
const debugInfo = await debugYouTubeTokens();
|
|
1205
|
+
console.log('๐ Current token status:', debugInfo);
|
|
1206
|
+
|
|
1207
|
+
if (!debugInfo.hasRefreshToken) {
|
|
1208
|
+
console.log('โ ๏ธ No refresh token found - attempting to fix...');
|
|
1209
|
+
const success = await fixUserYouTubeConnection(username);
|
|
1210
|
+
|
|
1211
|
+
if (success) {
|
|
1212
|
+
console.log('โ
YouTube connection fixed! Testing again...');
|
|
1213
|
+
const newDebugInfo = await debugYouTubeTokens();
|
|
1214
|
+
console.log('๐ New token status:', newDebugInfo);
|
|
1215
|
+
} else {
|
|
1216
|
+
console.error('โ Failed to fix YouTube connection');
|
|
1217
|
+
}
|
|
1218
|
+
} else {
|
|
1219
|
+
console.log('โ
Refresh token already available');
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
} catch (error) {
|
|
1223
|
+
console.error('โ Error testing YouTube refresh token:', error);
|
|
1224
|
+
}
|
|
1225
|
+
};
|
|
1226
|
+
|
|
1227
|
+
/**
|
|
1228
|
+
* Request email verification code
|
|
1229
|
+
*/
|
|
1230
|
+
export const requestEmailVerification = async (email: string, testMode: boolean = false): Promise<any> => {
|
|
1231
|
+
try {
|
|
1232
|
+
console.log('๐ง Requesting email verification for:', email);
|
|
1233
|
+
|
|
1234
|
+
const response = await fetch(`${API_CONFIG.BASE_URL}/email/verification`, {
|
|
1235
|
+
method: 'POST',
|
|
1236
|
+
headers: getApiHeaders(),
|
|
1237
|
+
body: JSON.stringify({
|
|
1238
|
+
email,
|
|
1239
|
+
action: 'request',
|
|
1240
|
+
testMode
|
|
1241
|
+
}),
|
|
1242
|
+
});
|
|
1243
|
+
|
|
1244
|
+
const result = await response.json();
|
|
1245
|
+
|
|
1246
|
+
if (response.ok) {
|
|
1247
|
+
return {
|
|
1248
|
+
success: true,
|
|
1249
|
+
message: result.message || 'Verification code sent to your email'
|
|
1250
|
+
};
|
|
1251
|
+
} else {
|
|
1252
|
+
return {
|
|
1253
|
+
success: false,
|
|
1254
|
+
error: result.message || 'Failed to send verification code'
|
|
1255
|
+
};
|
|
1256
|
+
}
|
|
1257
|
+
} catch (error) {
|
|
1258
|
+
console.error('โ Error requesting email verification:', error);
|
|
1259
|
+
return {
|
|
1260
|
+
success: false,
|
|
1261
|
+
error: 'Network error. Please check your connection and try again.'
|
|
1262
|
+
};
|
|
1263
|
+
}
|
|
1264
|
+
};
|
|
1265
|
+
|
|
1266
|
+
/**
|
|
1267
|
+
* Verify email code
|
|
1268
|
+
*/
|
|
1269
|
+
export const verifyEmailCode = async (email: string, code: string, testMode: boolean = false): Promise<any> => {
|
|
1270
|
+
try {
|
|
1271
|
+
console.log('๐ Verifying email code for:', email);
|
|
1272
|
+
|
|
1273
|
+
const response = await fetch(`${API_CONFIG.BASE_URL}/email/verification`, {
|
|
1274
|
+
method: 'POST',
|
|
1275
|
+
headers: getApiHeaders(),
|
|
1276
|
+
body: JSON.stringify({
|
|
1277
|
+
email,
|
|
1278
|
+
code,
|
|
1279
|
+
action: 'verify',
|
|
1280
|
+
testMode
|
|
1281
|
+
}),
|
|
1282
|
+
});
|
|
1283
|
+
|
|
1284
|
+
const result = await response.json();
|
|
1285
|
+
|
|
1286
|
+
if (response.ok) {
|
|
1287
|
+
return {
|
|
1288
|
+
success: true,
|
|
1289
|
+
message: result.message || 'Email verified successfully',
|
|
1290
|
+
existingUser: result.existingUser || false,
|
|
1291
|
+
token: result.token
|
|
1292
|
+
};
|
|
1293
|
+
} else {
|
|
1294
|
+
return {
|
|
1295
|
+
success: false,
|
|
1296
|
+
error: result.message || 'Invalid verification code'
|
|
1297
|
+
};
|
|
1298
|
+
}
|
|
1299
|
+
} catch (error) {
|
|
1300
|
+
console.error('โ Error verifying email code:', error);
|
|
1301
|
+
return {
|
|
1302
|
+
success: false,
|
|
1303
|
+
error: 'Network error. Please check your connection and try again.'
|
|
1304
|
+
};
|
|
1305
|
+
}
|
|
1306
|
+
};
|
|
1307
|
+
|
|
1308
|
+
/**
|
|
1309
|
+
* Check email verification status
|
|
1310
|
+
*/
|
|
1311
|
+
export const checkEmailVerificationStatus = async (email: string, testMode: boolean = false): Promise<any> => {
|
|
1312
|
+
try {
|
|
1313
|
+
const response = await fetch(`${API_CONFIG.BASE_URL}/email/verification/status`, {
|
|
1314
|
+
method: 'POST',
|
|
1315
|
+
headers: getApiHeaders(),
|
|
1316
|
+
body: JSON.stringify({
|
|
1317
|
+
email,
|
|
1318
|
+
testMode
|
|
1319
|
+
}),
|
|
1320
|
+
});
|
|
1321
|
+
|
|
1322
|
+
const result = await response.json();
|
|
1323
|
+
|
|
1324
|
+
return {
|
|
1325
|
+
success: response.ok,
|
|
1326
|
+
isPending: result.isPending || false,
|
|
1327
|
+
message: result.message
|
|
1328
|
+
};
|
|
1329
|
+
} catch (error) {
|
|
1330
|
+
console.error('โ Error checking email verification status:', error);
|
|
1331
|
+
return {
|
|
1332
|
+
success: false,
|
|
1333
|
+
isPending: false,
|
|
1334
|
+
error: 'Network error'
|
|
1335
|
+
};
|
|
1336
|
+
}
|
|
1337
|
+
};
|
|
1338
|
+
|
|
1339
|
+
/**
|
|
1340
|
+
* Initialize platform auth service
|
|
1341
|
+
*/
|
|
1342
|
+
export const initializePlatformAuthService = () => {
|
|
1343
|
+
console.log('๐ง Platform auth service initialized');
|
|
1344
|
+
// Initialize Google Sign-In
|
|
1345
|
+
initializeGoogleSignIn();
|
|
1346
|
+
};
|