@onairos/react-native 3.7.1 → 3.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/api/index.js +219 -9
- package/lib/commonjs/assets/icons/spotify.png +0 -0
- package/lib/commonjs/assets/images/spotify.png +0 -0
- package/lib/commonjs/components/BodyText.js +27 -9
- package/lib/commonjs/components/BrandMark.js +111 -10
- package/lib/commonjs/components/CodeInput.js +116 -9
- package/lib/commonjs/components/EmailInput.js +30 -8
- package/lib/commonjs/components/GoogleButton.js +56 -9
- package/lib/commonjs/components/HeadingGroup.js +43 -9
- package/lib/commonjs/components/LLMDataInputModal.js +664 -14
- package/lib/commonjs/components/ModalHeader.js +99 -9
- package/lib/commonjs/components/ModalSheet.js +47 -9
- package/lib/commonjs/components/Onairos.js +380 -14
- package/lib/commonjs/components/OnairosButton.js +313 -13
- package/lib/commonjs/components/OnairosSignInButton.js +130 -12
- package/lib/commonjs/components/Overlay.js +465 -13
- package/lib/commonjs/components/PersonaImage.js +137 -10
- package/lib/commonjs/components/PersonaLoadingScreen.js +318 -12
- package/lib/commonjs/components/PersonalizationConsentScreen.js +467 -13
- package/lib/commonjs/components/PinCreationScreen.js +403 -12
- package/lib/commonjs/components/PinInput.js +464 -9
- package/lib/commonjs/components/PlatformConnectorsStep.js +1311 -23
- package/lib/commonjs/components/PlatformList.js +137 -10
- package/lib/commonjs/components/PlatformToggle.js +180 -9
- package/lib/commonjs/components/PrimaryButton.js +180 -10
- package/lib/commonjs/components/SignInMatchAnimation.js +197 -9
- package/lib/commonjs/components/SignInStep.js +345 -12
- package/lib/commonjs/components/UniversalOnboarding.js +2780 -30
- package/lib/commonjs/components/VerificationStep.js +176 -11
- package/lib/commonjs/components/WelcomeScreen.js +461 -22
- package/lib/commonjs/components/icons/Basicproficon.js +37 -8
- package/lib/commonjs/components/icons/Basicprofile.js +21 -8
- package/lib/commonjs/components/icons/Checkbox.js +21 -8
- package/lib/commonjs/components/icons/Checkmark.js +27 -8
- package/lib/commonjs/components/icons/Contentanalysis.js +21 -8
- package/lib/commonjs/components/icons/Contenticon.js +39 -8
- package/lib/commonjs/components/icons/EnochE.js +41 -8
- package/lib/commonjs/components/icons/Personalityicon.js +30 -8
- package/lib/commonjs/components/icons/Personalityprofile.js +21 -8
- package/lib/commonjs/components/icons/Personalitytraits.js +21 -8
- package/lib/commonjs/components/icons/Userpreferences.js +21 -8
- package/lib/commonjs/components/icons/index.js +84 -17
- package/lib/commonjs/components/onboarding/OAuthWebView.js +1754 -18
- package/lib/commonjs/components/onboarding/OnboardingHeader.js +74 -10
- package/lib/commonjs/components/onboarding/PinInput.js +283 -10
- package/lib/commonjs/components/onboarding/PlatformConnector.js +249 -11
- package/lib/commonjs/config/PLATFORM_APIS.md +849 -0
- package/lib/commonjs/config/api.js +56 -7
- package/lib/commonjs/constants/index.js +120 -7
- package/lib/commonjs/context/AuthContext.js +345 -10
- package/lib/commonjs/hooks/useConnectedAccounts.js +111 -9
- package/lib/commonjs/hooks/useConnections.js +102 -8
- package/lib/commonjs/hooks/useCredentials.js +178 -10
- package/lib/commonjs/hooks/useUserConnections.js +148 -10
- package/lib/commonjs/index.js +439 -34
- package/lib/commonjs/services/apiClient.js +298 -8
- package/lib/commonjs/services/biometricPinService.js +180 -8
- package/lib/commonjs/services/chatGPTConversationExtractor.js +155 -8
- package/lib/commonjs/services/chatGPTConversationService.js +275 -9
- package/lib/commonjs/services/claudeConversationExtractor.js +103 -8
- package/lib/commonjs/services/claudeConversationService.js +158 -9
- package/lib/commonjs/services/connectedAccountsService.js +310 -10
- package/lib/commonjs/services/googleAuthService.js +252 -11
- package/lib/commonjs/services/hingeDataExtractor.js +105 -8
- package/lib/commonjs/services/hingeDataService.js +150 -9
- package/lib/commonjs/services/imageCompressionService.js +260 -7
- package/lib/commonjs/services/instagramDataExtractor.js +126 -8
- package/lib/commonjs/services/instagramDataService.js +163 -9
- package/lib/commonjs/services/jwtStorageService.js +276 -7
- package/lib/commonjs/services/linkedinDOMExtractor.js +245 -7
- package/lib/commonjs/services/linkedinProfileService.js +222 -9
- package/lib/commonjs/services/linkedinScrapingService.js +230 -8
- package/lib/commonjs/services/llmDataStorage.js +294 -8
- package/lib/commonjs/services/mobileTrainingService.js +186 -8
- package/lib/commonjs/services/netflixDataExtractor.js +120 -8
- package/lib/commonjs/services/netflixDataService.js +198 -9
- package/lib/commonjs/services/pinEncryptionService.js +84 -8
- package/lib/commonjs/services/pinStorageUtils.js +105 -7
- package/lib/commonjs/services/platformAuthService.js +1484 -12
- package/lib/commonjs/services/sephoraDataExtractor.js +140 -8
- package/lib/commonjs/services/sephoraDataService.js +200 -9
- package/lib/commonjs/services/spotifyDataExtractor.js +148 -8
- package/lib/commonjs/services/spotifyDataService.js +241 -9
- package/lib/commonjs/services/storageService.js +404 -8
- package/lib/commonjs/services/telegramDataExtractor.js +115 -8
- package/lib/commonjs/services/telegramDataService.js +499 -9
- package/lib/commonjs/services/trainingApiHelpers.js +73 -7
- package/lib/commonjs/services/userConnectionsService.js +340 -10
- package/lib/commonjs/services/youtubeMigrationService.js +416 -10
- package/lib/commonjs/theme/index.js +250 -7
- package/lib/commonjs/types/ambient.d.js +2 -1
- package/lib/commonjs/types/declarations.d.js +2 -1
- package/lib/commonjs/types/index.js +6 -1
- package/lib/commonjs/types/node-fix.d.js +2 -1
- package/lib/commonjs/types/node-override.d.js +2 -1
- package/lib/commonjs/types/opacity.d.js +2 -1
- package/lib/commonjs/types.js +14 -1
- package/lib/commonjs/utils/Portal.js +98 -8
- package/lib/commonjs/utils/api.js +130 -9
- package/lib/commonjs/utils/assetRegistry.js +210 -35
- package/lib/commonjs/utils/auth.js +112 -9
- package/lib/commonjs/utils/connectorTests.js +613 -29
- package/lib/commonjs/utils/crypto.js +62 -8
- package/lib/commonjs/utils/debugHelper.js +64 -1
- package/lib/commonjs/utils/encryption.js +76 -7
- package/lib/commonjs/utils/eventUtils.js +288 -1
- package/lib/commonjs/utils/haptics.js +66 -9
- package/lib/commonjs/utils/imagePreloader.js +6 -1
- package/lib/commonjs/utils/networkDiagnostics.js +226 -8
- package/lib/commonjs/utils/onairosApi.js +350 -9
- package/lib/commonjs/utils/programmaticFlow.js +117 -9
- package/lib/commonjs/utils/retryHelper.js +220 -1
- package/lib/commonjs/utils/secureStorage.js +349 -10
- package/lib/commonjs/utils/webviewScripts/chatgpt.js +551 -1
- package/lib/commonjs/utils/webviewScripts/claude.js +376 -1
- package/lib/commonjs/utils/webviewScripts/hinge.js +411 -1
- package/lib/commonjs/utils/webviewScripts/index.js +698 -15
- package/lib/commonjs/utils/webviewScripts/instagram.js +454 -1
- package/lib/commonjs/utils/webviewScripts/linkedin.js +880 -1
- package/lib/commonjs/utils/webviewScripts/netflix.js +382 -1
- package/lib/commonjs/utils/webviewScripts/sephora.js +516 -1
- package/lib/commonjs/utils/webviewScripts/spotify.js +419 -1
- package/lib/commonjs/utils/webviewScripts/telegram.js +678 -1
- package/lib/module/api/index.js +211 -1
- package/lib/module/assets/icons/spotify.png +0 -0
- package/lib/module/assets/images/spotify.png +0 -0
- package/lib/module/components/BodyText.js +20 -1
- package/lib/module/components/BrandMark.js +104 -1
- package/lib/module/components/CodeInput.js +109 -1
- package/lib/module/components/EmailInput.js +23 -1
- package/lib/module/components/GoogleButton.js +49 -1
- package/lib/module/components/HeadingGroup.js +36 -1
- package/lib/module/components/LLMDataInputModal.js +656 -7
- package/lib/module/components/ModalHeader.js +92 -1
- package/lib/module/components/ModalSheet.js +39 -1
- package/lib/module/components/Onairos.js +373 -1
- package/lib/module/components/OnairosButton.js +305 -1
- package/lib/module/components/OnairosSignInButton.js +121 -1
- package/lib/module/components/Overlay.js +456 -1
- package/lib/module/components/PersonaImage.js +129 -1
- package/lib/module/components/PersonaLoadingScreen.js +310 -1
- package/lib/module/components/PersonalizationConsentScreen.js +460 -1
- package/lib/module/components/PinCreationScreen.js +396 -1
- package/lib/module/components/PinInput.js +456 -1
- package/lib/module/components/PlatformConnectorsStep.js +1302 -6
- package/lib/module/components/PlatformList.js +129 -1
- package/lib/module/components/PlatformToggle.js +173 -1
- package/lib/module/components/PrimaryButton.js +172 -1
- package/lib/module/components/SignInMatchAnimation.js +189 -1
- package/lib/module/components/SignInStep.js +338 -1
- package/lib/module/components/UniversalOnboarding.js +2770 -1
- package/lib/module/components/VerificationStep.js +168 -1
- package/lib/module/components/WelcomeScreen.js +453 -1
- package/lib/module/components/icons/Basicproficon.js +30 -1
- package/lib/module/components/icons/Basicprofile.js +14 -1
- package/lib/module/components/icons/Checkbox.js +14 -1
- package/lib/module/components/icons/Checkmark.js +20 -1
- package/lib/module/components/icons/Contentanalysis.js +14 -1
- package/lib/module/components/icons/Contenticon.js +32 -1
- package/lib/module/components/icons/EnochE.js +34 -1
- package/lib/module/components/icons/Personalityicon.js +23 -1
- package/lib/module/components/icons/Personalityprofile.js +14 -1
- package/lib/module/components/icons/Personalitytraits.js +14 -1
- package/lib/module/components/icons/Userpreferences.js +14 -1
- package/lib/module/components/icons/index.js +13 -1
- package/lib/module/components/onboarding/OAuthWebView.js +1746 -1
- package/lib/module/components/onboarding/OnboardingHeader.js +66 -1
- package/lib/module/components/onboarding/PinInput.js +274 -1
- package/lib/module/components/onboarding/PlatformConnector.js +240 -1
- package/lib/module/config/PLATFORM_APIS.md +849 -0
- package/lib/module/config/api.js +47 -1
- package/lib/module/constants/index.js +114 -1
- package/lib/module/context/AuthContext.js +335 -1
- package/lib/module/hooks/useConnectedAccounts.js +106 -1
- package/lib/module/hooks/useConnections.js +95 -1
- package/lib/module/hooks/useCredentials.js +171 -6
- package/lib/module/hooks/useUserConnections.js +140 -1
- package/lib/module/index.js +172 -1
- package/lib/module/services/apiClient.js +295 -1
- package/lib/module/services/biometricPinService.js +169 -1
- package/lib/module/services/chatGPTConversationExtractor.js +149 -1
- package/lib/module/services/chatGPTConversationService.js +268 -1
- package/lib/module/services/claudeConversationExtractor.js +97 -1
- package/lib/module/services/claudeConversationService.js +151 -1
- package/lib/module/services/connectedAccountsService.js +293 -1
- package/lib/module/services/googleAuthService.js +241 -1
- package/lib/module/services/hingeDataExtractor.js +99 -1
- package/lib/module/services/hingeDataService.js +143 -1
- package/lib/module/services/imageCompressionService.js +250 -1
- package/lib/module/services/instagramDataExtractor.js +120 -1
- package/lib/module/services/instagramDataService.js +156 -1
- package/lib/module/services/jwtStorageService.js +257 -1
- package/lib/module/services/linkedinDOMExtractor.js +234 -1
- package/lib/module/services/linkedinProfileService.js +210 -1
- package/lib/module/services/linkedinScrapingService.js +219 -1
- package/lib/module/services/llmDataStorage.js +277 -1
- package/lib/module/services/mobileTrainingService.js +173 -1
- package/lib/module/services/netflixDataExtractor.js +114 -1
- package/lib/module/services/netflixDataService.js +191 -1
- package/lib/module/services/pinEncryptionService.js +74 -6
- package/lib/module/services/pinStorageUtils.js +93 -1
- package/lib/module/services/platformAuthService.js +1461 -1
- package/lib/module/services/sephoraDataExtractor.js +134 -1
- package/lib/module/services/sephoraDataService.js +193 -1
- package/lib/module/services/spotifyDataExtractor.js +142 -1
- package/lib/module/services/spotifyDataService.js +234 -1
- package/lib/module/services/storageService.js +383 -1
- package/lib/module/services/telegramDataExtractor.js +109 -1
- package/lib/module/services/telegramDataService.js +493 -1
- package/lib/module/services/trainingApiHelpers.js +67 -1
- package/lib/module/services/userConnectionsService.js +329 -1
- package/lib/module/services/youtubeMigrationService.js +405 -1
- package/lib/module/theme/index.js +245 -1
- package/lib/module/types.js +10 -1
- package/lib/module/utils/Portal.js +90 -1
- package/lib/module/utils/api.js +118 -1
- package/lib/module/utils/assetRegistry.js +200 -34
- package/lib/module/utils/auth.js +100 -1
- package/lib/module/utils/connectorTests.js +600 -27
- package/lib/module/utils/crypto.js +54 -1
- package/lib/module/utils/debugHelper.js +54 -1
- package/lib/module/utils/encryption.js +67 -1
- package/lib/module/utils/eventUtils.js +270 -1
- package/lib/module/utils/haptics.js +59 -8
- package/lib/module/utils/imagePreloader.js +3 -1
- package/lib/module/utils/networkDiagnostics.js +217 -1
- package/lib/module/utils/onairosApi.js +333 -1
- package/lib/module/utils/programmaticFlow.js +111 -1
- package/lib/module/utils/retryHelper.js +211 -1
- package/lib/module/utils/secureStorage.js +330 -6
- package/lib/module/utils/webviewScripts/chatgpt.js +545 -1
- package/lib/module/utils/webviewScripts/claude.js +370 -1
- package/lib/module/utils/webviewScripts/hinge.js +405 -1
- package/lib/module/utils/webviewScripts/index.js +434 -1
- package/lib/module/utils/webviewScripts/instagram.js +448 -1
- package/lib/module/utils/webviewScripts/linkedin.js +874 -1
- package/lib/module/utils/webviewScripts/netflix.js +376 -1
- package/lib/module/utils/webviewScripts/sephora.js +510 -1
- package/lib/module/utils/webviewScripts/spotify.js +413 -1
- package/lib/module/utils/webviewScripts/telegram.js +672 -1
- package/package.json +2 -2
|
@@ -1 +1,405 @@
|
|
|
1
|
-
import{GoogleSignin}from'@react-native-google-signin/google-signin';import{Alert}from'react-native';import AsyncStorage from'@react-native-async-storage/async-storage';import{API_CONFIG}from'../config/api';const WEB_CLIENT_ID=_0x3192(0x0),IOS_CLIENT_ID='1030678346906-lovkuds2ouqmoc8eu5qpo98spa6edv4o.apps.googleusercontent.com',configureGoogleSignInForRefreshTokens=()=>{const _0x228492={'xthhC':_0x3192(0x1),'fOeXb':'openid','KIEsW':_0x3192(0x2),'UrAhP':'email'};GoogleSignin[_0x3192(0x3)]({'webClientId':WEB_CLIENT_ID,'iosClientId':IOS_CLIENT_ID,'offlineAccess':!![],'forceCodeForRefreshToken':!![],'scopes':[_0x228492[_0x3192(0x4)],_0x228492[_0x3192(0x5)],_0x228492[_0x3192(0x6)],_0x228492['UrAhP']],'hostedDomain':'','accountName':''});};export const checkYouTubeMigrationNeeded=async _0x36243=>{const _0x47dfbf={'ccNyS':function(_0x3399d8,_0xef1965){return _0x3399d8===_0xef1965;},'CwTqW':function(_0x42706e,_0x1ae982){return _0x42706e===_0x1ae982;},'crFjJ':function(_0x247e54,_0x1d7d37){return _0x247e54===_0x1d7d37;},'GkYuH':_0x3192(0x7),'INDXI':'⚠️\x20No\x20refresh\x20capability\x20but\x20training\x20can\x20proceed','PkbYO':'🔧\x20User\x20needs\x20YouTube\x20migration\x20for\x20refresh\x20token','UJXDf':_0x3192(0x8),'QBzid':_0x3192(0x9),'mUuRP':_0x3192(0xa),'FASkB':'\x20\x20\x202.\x20forceCodeForRefreshToken:\x20true\x20is\x20missing','upMDN':_0x3192(0xb),'IwuOn':_0x3192(0xc),'TWJUU':'\x20\x20\x203.\x20User\x20did\x20not\x20grant\x20offline\x20access\x20permission','fLPeF':'🚫\x20[MIGRATION]\x20NO\x20MIGRATION\x20NEEDED\x20-\x20user\x20connection\x20is\x20working\x20correctly','CqmEC':'✅\x20[MIGRATION]\x20User\x20can\x20proceed\x20with\x20training\x20normally','YmeVo':function(_0x3ec39f,_0x3092df){return _0x3ec39f!==_0x3092df;},'XkDHq':_0x3192(0xd),'KffSU':_0x3192(0xe),'aeebl':function(_0x3eb51e,_0x16b01e){return _0x3eb51e(_0x16b01e);},'RViRl':function(_0x2ccda0,_0x220050){return _0x2ccda0===_0x220050;},'DmiSY':function(_0x3a2ab1,_0x4be70a){return _0x3a2ab1===_0x4be70a;},'UxAVc':function(_0x21d268,_0x1b21da){return _0x21d268===_0x1b21da;},'ZXVQF':function(_0x20e7e7,_0x363281){return _0x20e7e7===_0x363281;},'MBRwx':'🔄\x20User\x20using\x20temporary\x20mode\x20-\x20connection\x20working\x20correctly','bPIaB':function(_0x4c4c48,_0x31c0a5){return _0x4c4c48!==_0x31c0a5;},'tjtjn':_0x3192(0xf),'satom':_0x3192(0x10),'EShUe':_0x3192(0x11),'ehyea':'wwJad','iAUmJ':'❌\x20Error\x20checking\x20YouTube\x20migration\x20status:'};try{if(_0x47dfbf[_0x3192(0x12)](_0x47dfbf[_0x3192(0x13)],_0x47dfbf['KffSU'])){const _0x16586d=await _0x47dfbf[_0x3192(0x14)](fetch,API_CONFIG['BASE_URL']+_0x3192(0x15)+_0x36243),_0x538ff7=await _0x16586d[_0x3192(0x16)]();if(_0x538ff7['success']&&_0x538ff7[_0x3192(0x17)]){var _0x178567,_0x23e3fc,_0x575cc0;const _0x5da920=_0x47dfbf[_0x3192(0x18)](_0x47dfbf['crFjJ'](_0x178567=_0x538ff7['validation'],null)||_0x47dfbf[_0x3192(0x19)](_0x178567,void 0x0)?void 0x0:_0x178567[_0x3192(0x1a)],!![])||_0x47dfbf[_0x3192(0x1b)]((_0x23e3fc=_0x538ff7[_0x3192(0x1c)])===null||_0x47dfbf['UxAVc'](_0x23e3fc,void 0x0)?void 0x0:_0x23e3fc[_0x3192(0x1d)],!![])||_0x538ff7[_0x3192(0x1a)]===!![]||_0x538ff7[_0x3192(0x1e)]&&_0x538ff7['message']['includes']('temporary\x20access\x20token\x20mode'),_0x177a31=_0x538ff7[_0x3192(0x17)]['needsReconnection'],_0x223433=_0x538ff7[_0x3192(0x17)][_0x3192(0x1f)];console[_0x3192(0x20)](_0x3192(0x21),{'username':_0x36243,'needsReconnection':_0x177a31,'hasRefreshToken':_0x223433,'isTemporaryMode':_0x5da920,'temporaryModeEnabled':_0x47dfbf['ccNyS'](_0x575cc0=_0x538ff7[_0x3192(0x1c)],null)||_0x47dfbf[_0x3192(0x22)](_0x575cc0,void 0x0)?void 0x0:_0x575cc0[_0x3192(0x1d)],'message':_0x538ff7[_0x3192(0x1e)]});if(_0x5da920)return console[_0x3192(0x20)](_0x47dfbf[_0x3192(0x23)]),console[_0x3192(0x20)](_0x47dfbf['INDXI']),![];else{if(_0x177a31){if(_0x47dfbf[_0x3192(0x24)](_0x47dfbf['tjtjn'],_0x47dfbf['satom']))return console['log'](_0x47dfbf['PkbYO']),!![];else{var _0x190292,_0x5aa8ef,_0x126d33;const _0x57b29a=_0x47dfbf[_0x3192(0x18)](_0x47dfbf[_0x3192(0x25)](_0x190292=_0x5715ed['validation'],null)||_0x47dfbf['CwTqW'](_0x190292,void 0x0)?void 0x0:_0x190292[_0x3192(0x1a)],!![])||_0x47dfbf['crFjJ'](_0x47dfbf[_0x3192(0x25)](_0x5aa8ef=_0x496154[_0x3192(0x1c)],null)||_0x47dfbf[_0x3192(0x25)](_0x5aa8ef,void 0x0)?void 0x0:_0x5aa8ef['enabled'],!![])||_0x47dfbf[_0x3192(0x18)](_0x3bc1aa[_0x3192(0x1a)],!![])||_0x805303['message']&&_0x170f73[_0x3192(0x1e)]['includes'](_0x47dfbf['GkYuH']),_0xfd7a8=_0x313159[_0x3192(0x17)][_0x3192(0x26)],_0x48c13d=_0x3a2ce8['validation']['hasRefreshToken'];_0x162f56[_0x3192(0x20)](_0x3192(0x21),{'username':_0x4d6582,'needsReconnection':_0xfd7a8,'hasRefreshToken':_0x48c13d,'isTemporaryMode':_0x57b29a,'temporaryModeEnabled':(_0x126d33=_0x335f46['temporaryMode'])===null||_0x47dfbf['CwTqW'](_0x126d33,void 0x0)?void 0x0:_0x126d33[_0x3192(0x1d)],'message':_0x17f7ee[_0x3192(0x1e)]});if(_0x57b29a)return _0x487e3b[_0x3192(0x20)](_0x3192(0x27)),_0xdb2248['log'](_0x47dfbf['INDXI']),![];else return _0xfd7a8?(_0x15d640[_0x3192(0x20)](_0x47dfbf[_0x3192(0x28)]),!![]):(_0x194396[_0x3192(0x20)](_0x47dfbf[_0x3192(0x29)]),![]);}}else{if(_0x47dfbf[_0x3192(0x2a)]!==_0x3192(0x2b))return console[_0x3192(0x20)](_0x47dfbf['UJXDf']),![];else _0x56b1e6=_0x55b3d9[_0x3192(0x2c)],_0x453526=_0x47dfbf[_0x3192(0x2d)];}}}return![];}else{const _0x3c56ec=_0x47dfbf['mUuRP'][_0x3192(0x2e)]('|');let _0x3cfa39=0x0;while(!![]){switch(_0x3c56ec[_0x3cfa39++]){case'0':_0x30f9df[_0x3192(0x2f)](_0x47dfbf['FASkB']);continue;case'1':_0x27c266[_0x3192(0x2f)](_0x47dfbf[_0x3192(0x30)]);continue;case'2':_0x16fe92['error'](_0x47dfbf[_0x3192(0x31)]);continue;case'3':_0x193523['error']('❌\x20No\x20refresh\x20token\x20received\x20-\x20Google\x20Console\x20configuration\x20may\x20be\x20incorrect');continue;case'4':return![];case'5':_0x103845[_0x3192(0x2f)](_0x47dfbf['TWJUU']);continue;}break;}}}catch(_0x34abf6){return _0x47dfbf[_0x3192(0x24)](_0x47dfbf[_0x3192(0x32)],_0x47dfbf[_0x3192(0x32)])?(_0x21c48f[_0x3192(0x20)](_0x47dfbf[_0x3192(0x33)]),_0x46c343[_0x3192(0x20)](_0x47dfbf[_0x3192(0x34)]),!![]):(console[_0x3192(0x2f)](_0x47dfbf[_0x3192(0x35)],_0x34abf6),![]);}};function _0x465a(){const _0x37008d=['1030678346906-lovkuds2ouqmoc8eu5qpo98spa6edv4o.apps.googleusercontent.com','https://www.googleapis.com/auth/youtube.readonly','profile','configure','xthhC','fOeXb','KIEsW','temporary\x20access\x20token\x20mode','✅\x20YouTube\x20connection\x20fully\x20working\x20with\x20refresh\x20tokens','Current\x20user\x20server\x20auth\x20code','3|2|1|0|5|4','\x20\x20\x201.\x20offlineAccess:\x20true\x20is\x20missing\x20from\x20configuration','💡\x20This\x20usually\x20means:','YjrOl','zymBh','UmgjH','XDAkk','xYpjl','YmeVo','XkDHq','aeebl','/youtube/validate-connection/','json','validation','ccNyS','RViRl','isTemporaryMode','DmiSY','temporaryMode','enabled','message','hasRefreshToken','log','🔍\x20YouTube\x20migration\x20check:','ZXVQF','MBRwx','bPIaB','CwTqW','needsReconnection','🔄\x20User\x20using\x20temporary\x20mode\x20-\x20connection\x20working\x20correctly','PkbYO','UJXDf','EShUe','cATVd','serverAuthCode','QBzid','split','error','upMDN','IwuOn','ehyea','fLPeF','CqmEC','iAUmJ','🚫\x20[MIGRATION\x20WARNING]\x20NO\x20WARNING\x20-\x20user\x20is\x20in\x20temporary\x20mode\x20(working\x20correctly)','⚠️\x20No\x20refresh\x20capability\x20but\x20training\x20can\x20proceed','xZHli','📋\x20Complete\x20YouTube\x20status\x20response:','🔄\x20YouTube\x20connected\x20in\x20temporary\x20mode','✅\x20Training\x20will\x20work,\x20but\x20connection\x20expires\x20in\x20~1\x20hour','full','⚠️\x20YouTube\x20connected\x20but\x20needs\x20migration','limited','none','JLtOU','RnYbs','qqfVR','BASE_URL','tNzim','success','VtUok','QhNEi','FfLys','EeaLh','hDxJt','eKWeL','temporary','xMePX','fyzEj','kmUnz','✅\x20YouTube\x20connected\x20with\x20refresh\x20tokens','❓\x20YouTube\x20connection\x20status\x20unclear','XNwGF','hEwbS','OXcce','DWXDS','oOfUM','ExUJR','FkDXl','YouTube\x20Connection\x20Upgrade','To\x20improve\x20your\x20training\x20experience,\x20we\x20need\x20to\x20upgrade\x20your\x20YouTube\x20connection.\x20This\x20prevents\x20interruptions\x20during\x20data\x20collection.\x0a\x0a✅\x20One-time\x20upgrade\x0a✅\x20Takes\x2030\x20seconds\x0a✅\x20No\x20data\x20loss\x0a\x0aUpgrade\x20now?','cancel','bTeGf','Wkpwj','htEqx','alert','jVUPh','EOquv','HfQHX','default','✅\x20Signed\x20out\x20-\x20consent\x20cache\x20cleared','ℹ️\x20No\x20token\x20cache\x20to\x20clear','None','XmNwC','🔍\x20Token\x20Analysis:','MISSING!','jbXVr','2|3|1|5|0|4','...','onairos_jwt_token','enoch_token','youtube','YouTube\x20Channel','📤\x20Sending\x20migration\x20payload\x20to\x20backend...','ifIRH','❌\x20YouTube\x20migration\x20failed:','Unknown\x20error','psPjc','miQIt','signOut','JZfLA','clearCachedAccessToken','✅\x20Token\x20cache\x20cleared','ZDwvE','hasPlayServices','🔐\x20Initiating\x20sign-in\x20-\x20consent\x20screen\x20should\x20appear...','getTokens','getCurrentUser','FiwAw','Server\x20auth\x20code\x20from\x20sign-in','yjSPV','NxEUe','DHoWn','accessToken','idToken','XbrYS','Ljnkt','vJGmC','user','mLsmN','ZFGpz','pUPCz','YouTube\x20connection\x20upgrade\x20failed.\x20Please\x20try\x20again\x20later\x20or\x20contact\x20support\x20if\x20the\x20problem\x20persists.','VCcDv','jNWKl','dbNxg','PSTvc','zAjHk','getItem','iPyZW','kobnl','warn','⚠️\x20No\x20authentication\x20token\x20found\x20for\x20YouTube\x20migration','OvVul','name','NWSkB','email','CjBhb','zuHua','SXuVn','LAkgJ','CIaql','eyUdJ','Bearer\x20','stringify','tzFHE','✅\x20YouTube\x20migration\x20successful','PnGGS','hllHT','crFzj','📊\x20[MIGRATION\x20WARNING]\x20Status\x20check:','✅\x20[MIGRATION\x20WARNING]\x20NO\x20WARNING\x20-\x20connection\x20is\x20working\x20properly','AzRGz','❌\x20Failed\x20to\x20track\x20migration\x20attempt:','HyAwC','TBbCf','WRpLw','XPbXp','toISOString','usFCQ','cbfyx','nwSaO','connectedAt','PLrKv','TxnWn','ENIYE','agJce','COYPA','✅\x20[MIGRATION]\x20YouTube\x20connection\x20working\x20properly\x20-\x20no\x20migration\x20needed','🔍\x20[MIGRATION\x20WARNING]\x20Checking\x20if\x20user\x20should\x20see\x20migration\x20warning:','⚠️\x20[MIGRATION\x20WARNING]\x20SHOW\x20WARNING\x20-\x20genuinely\x20old\x20connection\x20needs\x20update','ℹ️\x20[MIGRATION\x20WARNING]\x20NO\x20WARNING\x20-\x20no\x20YouTube\x20connection\x20found','❌\x20[MIGRATION\x20WARNING]\x20Error\x20checking\x20migration\x20warning\x20status:','vmMmf','DxCwL','nkYyH','RPKIg','hasAccessToken','cZmpg','AGUvM','GQoyq','LOyqf','ogrYQ','rdPPg','pmZiE','ulOno','gRXmZ','Great!','✅\x20[MIGRATION]\x20User\x20can\x20proceed\x20with\x20training\x20normally','🔧\x20[MIGRATION]\x20User\x20needs\x20YouTube\x20migration\x20for\x20refresh\x20token\x20(genuinely\x20old\x20connection)','IfDGn','ℹ️\x20User\x20declined\x20YouTube\x20migration','Your\x20YouTube\x20connection\x20has\x20been\x20upgraded\x20successfully.\x20Training\x20will\x20now\x20work\x20seamlessly\x20without\x20interruptions.','dhyYV','Upgrade\x20Failed\x20❌','❌\x20Error\x20in\x20YouTube\x20connection\x20check:','RTCLQ','Mppjs','YXvYa','dhfMC','ebkhW','fvpSW','jwyhp','NHWJn','sNRGW','BTiZL','SxZJp','SvPsE','tBYPo','mAstk','rEqBs','xLlsE','uJocc','ezwBe','zIWBu','🔄\x20Manual\x20YouTube\x20reconnection\x20requested\x20for:','pneWU'];_0x465a=function(){return _0x37008d;};return _0x465a();}export const getYouTubeConnectionStatus=async _0x2f8bb2=>{const _0x4a2166={'kmUnz':_0x3192(0x36),'OXcce':_0x3192(0x27),'DWXDS':_0x3192(0x37),'JLtOU':function(_0x548b51,_0xcc27a0){return _0x548b51!==_0xcc27a0;},'RnYbs':'LFRIZ','YqPSI':_0x3192(0x38),'qqfVR':function(_0x3d8bf3,_0x4528c2){return _0x3d8bf3(_0x4528c2);},'tNzim':_0x3192(0x39),'VtUok':function(_0x114db9,_0xa273bb){return _0x114db9===_0xa273bb;},'QhNEi':function(_0x8d40db,_0xa334c7){return _0x8d40db===_0xa334c7;},'FfLys':function(_0x312b9f,_0x1f89bf){return _0x312b9f===_0x1f89bf;},'EeaLh':_0x3192(0x7),'hDxJt':function(_0x56205f,_0x163ce9){return _0x56205f===_0x163ce9;},'eKWeL':_0x3192(0x3a),'Vkpbo':_0x3192(0x3b),'PVHaB':_0x3192(0x3c),'nEVtg':_0x3192(0x3d),'aeBDw':_0x3192(0x3e),'XNwGF':_0x3192(0x3f),'hEwbS':'❌\x20No\x20YouTube\x20connection\x20found','oOfUM':'❌\x20Error\x20getting\x20YouTube\x20connection\x20status:','ezPfc':function(_0x28aa5a,_0x543e89){return _0x28aa5a(_0x543e89);}};try{if(_0x4a2166[_0x3192(0x40)](_0x4a2166[_0x3192(0x41)],_0x4a2166['YqPSI'])){const _0x42185e=await _0x4a2166[_0x3192(0x42)](fetch,API_CONFIG[_0x3192(0x43)]+_0x3192(0x15)+_0x2f8bb2),_0x8dc1ad=await _0x42185e[_0x3192(0x16)]();console[_0x3192(0x20)](_0x4a2166[_0x3192(0x44)],_0x8dc1ad);if(_0x8dc1ad[_0x3192(0x45)]&&_0x8dc1ad[_0x3192(0x17)]){var _0x522821,_0x28725f;const _0x1fd698=_0x4a2166['VtUok'](_0x4a2166['VtUok'](_0x522821=_0x8dc1ad[_0x3192(0x17)],null)||_0x4a2166['VtUok'](_0x522821,void 0x0)?void 0x0:_0x522821[_0x3192(0x1a)],!![])||_0x4a2166[_0x3192(0x46)](_0x4a2166[_0x3192(0x47)](_0x28725f=_0x8dc1ad['temporaryMode'],null)||_0x4a2166[_0x3192(0x48)](_0x28725f,void 0x0)?void 0x0:_0x28725f[_0x3192(0x1d)],!![])||_0x8dc1ad['isTemporaryMode']===!![]||_0x8dc1ad[_0x3192(0x1e)]&&_0x8dc1ad[_0x3192(0x1e)]['includes'](_0x4a2166[_0x3192(0x49)]),_0x547eb0=_0x8dc1ad['validation'][_0x3192(0x1f)]===!![],_0x210a94=_0x4a2166[_0x3192(0x4a)](_0x8dc1ad['validation'][_0x3192(0x26)],!![]);if(_0x1fd698)return console[_0x3192(0x20)](_0x4a2166[_0x3192(0x4b)]),console[_0x3192(0x20)](_0x4a2166['Vkpbo']),{'isReady':!![],'mode':_0x3192(0x4c),'needsMigration':![],'trainingReady':!![],'details':_0x8dc1ad};else{if(_0x547eb0)return _0x4a2166[_0x3192(0x4a)](_0x3192(0x4d),_0x3192(0x4e))?(_0xcccfdb[_0x3192(0x20)](_0x4a2166[_0x3192(0x4f)]),![]):(console['log'](_0x3192(0x50)),{'isReady':!![],'mode':_0x4a2166['PVHaB'],'needsMigration':![],'trainingReady':!![],'details':_0x8dc1ad});else return _0x210a94?(console[_0x3192(0x20)](_0x4a2166['nEVtg']),{'isReady':![],'mode':_0x4a2166['aeBDw'],'needsMigration':!![],'trainingReady':![],'details':_0x8dc1ad}):(console[_0x3192(0x20)](_0x3192(0x51)),{'isReady':![],'mode':_0x4a2166[_0x3192(0x52)],'needsMigration':![],'trainingReady':![],'details':_0x8dc1ad});}}return console[_0x3192(0x20)](_0x4a2166[_0x3192(0x53)]),{'isReady':![],'mode':_0x4a2166[_0x3192(0x52)],'needsMigration':![],'trainingReady':![],'details':_0x8dc1ad};}else return _0x54fc0d[_0x3192(0x20)](_0x4a2166[_0x3192(0x54)]),_0x2ea3dd[_0x3192(0x20)](_0x4a2166[_0x3192(0x55)]),![];}catch(_0x1dab86){return console[_0x3192(0x2f)](_0x4a2166[_0x3192(0x56)],_0x1dab86),{'isReady':![],'mode':_0x4a2166['XNwGF'],'needsMigration':![],'trainingReady':![],'details':{'error':_0x1dab86 instanceof Error?_0x1dab86['message']:_0x4a2166['ezPfc'](String,_0x1dab86)}};}};const showYouTubeMigrationPrompt=async()=>{const _0x40c33b={'bTeGf':function(_0x3a2643,_0x1e97cf){return _0x3a2643===_0x1e97cf;},'Wkpwj':_0x3192(0x57),'htEqx':_0x3192(0x58),'KhldJ':_0x3192(0x59),'AyDgE':_0x3192(0x5a),'jVUPh':'Skip\x20for\x20Now','EOquv':_0x3192(0x5b),'HfQHX':'Upgrade\x20Now'};return new Promise(_0xaeef4b=>{const _0x3bc30a={'OAwJs':_0x3192(0x3f)};if(_0x40c33b[_0x3192(0x5c)](_0x40c33b[_0x3192(0x5d)],_0x40c33b[_0x3192(0x5e)]))return _0x42b696[_0x3192(0x20)](_0x3192(0x51)),{'isReady':![],'mode':_0x3bc30a['OAwJs'],'needsMigration':![],'trainingReady':![],'details':_0x3f2fbf};else Alert[_0x3192(0x5f)](_0x40c33b['KhldJ'],_0x40c33b['AyDgE'],[{'text':_0x40c33b[_0x3192(0x60)],'style':_0x40c33b[_0x3192(0x61)],'onPress':()=>_0xaeef4b(![])},{'text':_0x40c33b[_0x3192(0x62)],'style':_0x3192(0x63),'onPress':()=>_0xaeef4b(!![])}]);});},forceYouTubeReconnection=async _0x51446e=>{const _0x3f3982={'yjSPV':_0x3192(0x3e),'pUPCz':'Upgrade\x20Failed\x20❌','uUMRW':_0x3192(0x63),'psPjc':'🔄\x20Starting\x20YouTube\x20migration\x20for\x20user:','miQIt':function(_0x422e25){return _0x422e25();},'JZfLA':_0x3192(0x64),'ZDwvE':_0x3192(0x65),'XgAQB':_0x3192(0x66),'nWMnh':_0x3192(0x67),'NxEUe':function(_0x28bdaf,_0x2fa98a){return _0x28bdaf!==_0x2fa98a;},'DHoWn':_0x3192(0x68),'XbrYS':function(_0xfda65d,_0x5a4487){return _0xfda65d!==_0x5a4487;},'Ljnkt':'Available','vJGmC':_0x3192(0x69),'mLsmN':function(_0x23b531,_0x463f7f){return _0x23b531===_0x463f7f;},'ZFGpz':_0x3192(0x6a),'QWcaT':_0x3192(0x6b),'evaZc':'\x20\x20\x203.\x20User\x20did\x20not\x20grant\x20offline\x20access\x20permission','VCcDv':'❌\x20No\x20refresh\x20token\x20received\x20-\x20Google\x20Console\x20configuration\x20may\x20be\x20incorrect','jNWKl':_0x3192(0xc),'WHKOy':'\x20\x20\x202.\x20forceCodeForRefreshToken:\x20true\x20is\x20missing','dbNxg':'✅\x20Got\x20refresh\x20token\x20after\x20consent:','PSTvc':function(_0x37a188,_0x2f1a7f){return _0x37a188+_0x2f1a7f;},'zAjHk':_0x3192(0x6c),'qoihp':'🔑\x20Refresh\x20token\x20source:','kIdjh':_0x3192(0x6d),'iPyZW':_0x3192(0x6e),'kobnl':'auth_token','eyUdJ':'migration_token_placeholder','OvVul':_0x3192(0x6f),'NWSkB':_0x3192(0x70),'CjBhb':function(_0x394dcb,_0x412af8){return _0x394dcb===_0x412af8;},'zuHua':function(_0x2f5e17,_0x376f81){return _0x2f5e17===_0x376f81;},'SXuVn':_0x3192(0x71),'LAkgJ':function(_0x4f6362,_0x20f5c3,_0x228f4b){return _0x4f6362(_0x20f5c3,_0x228f4b);},'CIaql':'your-api-key','tzFHE':_0x3192(0x72),'PnGGS':'❌\x20Backend\x20rejected\x20YouTube\x20migration:','ioFJO':function(_0x19d11d,_0x13d7dd,_0x1fefc7,_0x3dabfd){return _0x19d11d(_0x13d7dd,_0x1fefc7,_0x3dabfd);},'FWTjY':_0x3192(0x73),'ZXBNp':function(_0x2c28da,_0x41c9da,_0x5a964e,_0x4c549f){return _0x2c28da(_0x41c9da,_0x5a964e,_0x4c549f);},'hllHT':function(_0x57fe20,_0x3882a2){return _0x57fe20 instanceof _0x3882a2;},'crFzj':_0x3192(0x74)};try{var _0x597d9c,_0x39cbf8,_0x5373a5,_0x23b64f;console[_0x3192(0x20)](_0x3f3982[_0x3192(0x75)],_0x51446e),_0x3f3982[_0x3192(0x76)](configureGoogleSignInForRefreshTokens),await GoogleSignin[_0x3192(0x77)](),console['log'](_0x3f3982[_0x3192(0x78)]);try{const _0x430147=await GoogleSignin['getTokens']();_0x430147['accessToken']&&(await GoogleSignin[_0x3192(0x79)](_0x430147['accessToken']),console[_0x3192(0x20)](_0x3192(0x7a)));}catch(_0x356436){console[_0x3192(0x20)](_0x3f3982[_0x3192(0x7b)]);}await GoogleSignin[_0x3192(0x7c)](),console[_0x3192(0x20)](_0x3192(0x7d));const _0x44999e=await GoogleSignin['signIn'](),_0xce9551=await GoogleSignin[_0x3192(0x7e)](),_0x54c355=await GoogleSignin[_0x3192(0x7f)]();let _0x13b150=null,_0x747afd=_0x3f3982['XgAQB'];if(_0x44999e[_0x3192(0x2c)]){if(_0x3f3982['nWMnh']!==_0x3192(0x80))_0x13b150=_0x44999e[_0x3192(0x2c)],_0x747afd=_0x3192(0x81);else return _0x1a1191[_0x3192(0x20)](_0x3192(0x3d)),{'isReady':![],'mode':_0x3f3982[_0x3192(0x82)],'needsMigration':!![],'trainingReady':![],'details':_0x5a9ca9};}else _0x3f3982[_0x3192(0x83)](_0x54c355,null)&&_0x54c355!==void 0x0&&_0x54c355[_0x3192(0x2c)]&&(_0x13b150=_0x54c355['serverAuthCode'],_0x747afd=_0x3192(0x9));console[_0x3192(0x20)](_0x3f3982[_0x3192(0x84)],{'hasAccessToken':!!_0xce9551[_0x3192(0x85)],'hasIdToken':!!_0xce9551[_0x3192(0x86)],'hasServerAuthCode':!!_0x44999e['serverAuthCode'],'hasCurrentUserAuthCode':!!(_0x54c355!==null&&_0x3f3982[_0x3192(0x87)](_0x54c355,void 0x0)&&_0x54c355[_0x3192(0x2c)]),'refreshTokenSource':_0x747afd,'finalRefreshToken':_0x13b150?_0x3f3982[_0x3192(0x88)]:_0x3f3982[_0x3192(0x89)],'userEmail':(_0x597d9c=_0x44999e[_0x3192(0x8a)])===null||_0x3f3982[_0x3192(0x8b)](_0x597d9c,void 0x0)?void 0x0:_0x597d9c['email']});if(!_0x13b150){if(_0x3f3982[_0x3192(0x8c)]!==_0x3f3982['ZFGpz'])return Alert[_0x3192(0x5f)](_0x3f3982[_0x3192(0x8d)],_0x3192(0x8e),[{'text':'OK','style':_0x3f3982['uUMRW']}]),![];else{const _0x35b3fc=_0x3f3982['QWcaT'][_0x3192(0x2e)]('|');let _0x2a1757=0x0;while(!![]){switch(_0x35b3fc[_0x2a1757++]){case'0':console[_0x3192(0x2f)](_0x3f3982['evaZc']);continue;case'1':console[_0x3192(0x2f)]('\x20\x20\x201.\x20offlineAccess:\x20true\x20is\x20missing\x20from\x20configuration');continue;case'2':console['error'](_0x3f3982[_0x3192(0x8f)]);continue;case'3':console['error'](_0x3f3982[_0x3192(0x90)]);continue;case'4':return![];case'5':console[_0x3192(0x2f)](_0x3f3982['WHKOy']);continue;}break;}}}console[_0x3192(0x20)](_0x3f3982[_0x3192(0x91)],_0x3f3982[_0x3192(0x92)](_0x13b150['substring'](0x0,0x14),_0x3f3982[_0x3192(0x93)])),console[_0x3192(0x20)](_0x3f3982['qoihp'],_0x747afd);let _0x592fe8=await AsyncStorage[_0x3192(0x94)](_0x3f3982['kIdjh'])||await AsyncStorage[_0x3192(0x94)](_0x3f3982[_0x3192(0x95)])||await AsyncStorage[_0x3192(0x94)](_0x3f3982[_0x3192(0x96)]);!_0x592fe8&&(console[_0x3192(0x97)](_0x3192(0x98)),_0x592fe8=_0x3f3982['eyUdJ']);const _0x1655e8={'session':{'username':_0x51446e,'platform':_0x3f3982[_0x3192(0x99)],'channelName':((_0x39cbf8=_0x44999e['user'])===null||_0x3f3982[_0x3192(0x8b)](_0x39cbf8,void 0x0)?void 0x0:_0x39cbf8[_0x3192(0x9a)])||_0x3f3982[_0x3192(0x9b)],'channelId':null},'googleUser':_0x44999e[_0x3192(0x8a)],'accessToken':_0xce9551['accessToken'],'idToken':_0xce9551[_0x3192(0x86)],'refreshToken':_0x13b150,'serverAuthCode':_0x44999e['serverAuthCode'],'userAccountInfo':{'username':_0x51446e,'email':_0x3f3982[_0x3192(0x8b)](_0x5373a5=_0x44999e['user'],null)||_0x3f3982[_0x3192(0x8b)](_0x5373a5,void 0x0)?void 0x0:_0x5373a5[_0x3192(0x9c)],'authToken':_0x592fe8,'channelName':(_0x3f3982[_0x3192(0x9d)](_0x23b64f=_0x44999e['user'],null)||_0x3f3982[_0x3192(0x9e)](_0x23b64f,void 0x0)?void 0x0:_0x23b64f['name'])||'YouTube\x20Channel','channelId':null}};console[_0x3192(0x20)](_0x3f3982[_0x3192(0x9f)]);const _0x268b61=await _0x3f3982[_0x3192(0xa0)](fetch,API_CONFIG[_0x3192(0x43)]+'/youtube/native-auth',{'method':'POST','headers':{'Content-Type':'application/json','x-api-key':_0x3f3982[_0x3192(0xa1)],..._0x3f3982[_0x3192(0x87)](_0x592fe8,_0x3f3982[_0x3192(0xa2)])&&{'Authorization':_0x3192(0xa3)+_0x592fe8}},'body':JSON[_0x3192(0xa4)](_0x1655e8)}),_0x473983=await _0x268b61[_0x3192(0x16)]();return _0x473983[_0x3192(0x45)]?_0x3f3982[_0x3192(0xa5)]!==_0x3f3982[_0x3192(0xa5)]?(_0x24d0d9['log']('✅\x20[MIGRATION\x20WARNING]\x20NO\x20WARNING\x20-\x20connection\x20is\x20working\x20properly'),![]):(console[_0x3192(0x20)](_0x3192(0xa6)),await trackMigrationAttempt(_0x51446e,!![]),!![]):(console['error'](_0x3f3982[_0x3192(0xa7)],_0x473983[_0x3192(0x2f)]),await _0x3f3982['ioFJO'](trackMigrationAttempt,_0x51446e,![],_0x473983[_0x3192(0x2f)]),![]);}catch(_0x3ce877){return console['error'](_0x3f3982['FWTjY'],_0x3ce877),await _0x3f3982['ZXBNp'](trackMigrationAttempt,_0x51446e,![],_0x3f3982[_0x3192(0xa8)](_0x3ce877,Error)?_0x3ce877[_0x3192(0x1e)]:_0x3f3982[_0x3192(0xa9)]),![];}},trackMigrationAttempt=async(_0xdbb515,_0x495bb4,_0x2cabf9)=>{const _0x47627c={'HyAwC':function(_0x1c4333,_0x9d401b){return _0x1c4333===_0x9d401b;},'usFCQ':function(_0x248e0b,_0x17609c){return _0x248e0b===_0x17609c;},'cbfyx':function(_0x3810a0,_0x5d8b81){return _0x3810a0===_0x5d8b81;},'nwSaO':function(_0x2906d2,_0x433096){return _0x2906d2===_0x433096;},'EjsAB':_0x3192(0xaa),'PLrKv':_0x3192(0x36),'TxnWn':function(_0x5594d2,_0x34837f){return _0x5594d2&&_0x34837f;},'ENIYE':'⚠️\x20[MIGRATION\x20WARNING]\x20SHOW\x20WARNING\x20-\x20genuinely\x20old\x20connection\x20needs\x20update','agJce':_0x3192(0xab),'TBbCf':_0x3192(0xac),'WRpLw':function(_0x3e2e3b,_0x47cfa7,_0x12a95e){return _0x3e2e3b(_0x47cfa7,_0x12a95e);},'XPbXp':function(_0x587dd9,_0x5baaa7){return _0x587dd9||_0x5baaa7;},'COYPA':_0x3192(0xad)};try{if(_0x47627c[_0x3192(0xae)](_0x47627c[_0x3192(0xaf)],_0x47627c[_0x3192(0xaf)]))await _0x47627c[_0x3192(0xb0)](fetch,API_CONFIG[_0x3192(0x43)]+'/youtube/migration-status',{'method':'POST','headers':{'Content-Type':'application/json'},'body':JSON[_0x3192(0xa4)]({'username':_0xdbb515,'success':_0x495bb4,'error':_0x47627c[_0x3192(0xb1)](_0x2cabf9,null),'timestamp':new Date()[_0x3192(0xb2)]()})});else{var _0x20326d,_0x36f267;const _0x3cc97c=_0x47627c[_0x3192(0xae)](_0x47627c[_0x3192(0xae)](_0x20326d=_0x5c9fc1[_0x3192(0x17)],null)||_0x47627c['HyAwC'](_0x20326d,void 0x0)?void 0x0:_0x20326d['isTemporaryMode'],!![])||(_0x47627c[_0x3192(0xb3)](_0x36f267=_0xf4e036[_0x3192(0x1c)],null)||_0x36f267===void 0x0?void 0x0:_0x36f267['enabled'])===!![]||_0x47627c[_0x3192(0xb3)](_0x5c8867['isTemporaryMode'],!![]),_0x2339b4=_0x47627c[_0x3192(0xb4)](_0x132e71[_0x3192(0x17)]['hasAccessToken'],!![]),_0x45dc7e=_0x2620c9[_0x3192(0x17)]['hasRefreshToken']===!![],_0x595194=_0x47627c[_0x3192(0xb5)](_0x50246d[_0x3192(0x17)][_0x3192(0x26)],!![]);_0x4b35d6[_0x3192(0x20)](_0x47627c['EjsAB'],{'username':_0x33bbde,'hasAccessToken':_0x2339b4,'hasRefreshToken':_0x45dc7e,'needsReconnection':_0x595194,'isTemporaryMode':_0x3cc97c,'connectedAt':_0x302ec4[_0x3192(0x17)][_0x3192(0xb6)]});if(_0x3cc97c)return _0x24fb44[_0x3192(0x20)](_0x47627c[_0x3192(0xb7)]),![];else return _0x47627c[_0x3192(0xb8)](_0x2339b4,!_0x45dc7e)&&_0x595194?(_0x335a9f['log'](_0x47627c[_0x3192(0xb9)]),!![]):(_0xf06156[_0x3192(0x20)](_0x47627c[_0x3192(0xba)]),![]);}}catch(_0x137072){console['error'](_0x47627c[_0x3192(0xbb)],_0x137072);}};function _0x3192(_0x465ae4,_0x31925c){_0x465ae4=_0x465ae4-0x0;const _0x1658ed=_0x465a();let _0x5c94b4=_0x1658ed[_0x465ae4];return _0x5c94b4;}export const shouldShowYouTubeMigrationWarning=async _0x384ba9=>{const _0x574e43={'ulOno':_0x3192(0xbc),'vmMmf':_0x3192(0xbd),'GWIHY':function(_0x58bae9,_0x1f450d){return _0x58bae9(_0x1f450d);},'DxCwL':function(_0x286dd7,_0x74b11f){return _0x286dd7===_0x74b11f;},'nkYyH':function(_0x2c9dd7,_0x5e9fc0){return _0x2c9dd7===_0x5e9fc0;},'RPKIg':function(_0x3255a2,_0x45f924){return _0x3255a2===_0x45f924;},'cZmpg':function(_0x2fac8d,_0x3dfed8){return _0x2fac8d===_0x3dfed8;},'AGUvM':function(_0x24f702,_0x1bcab6){return _0x24f702===_0x1bcab6;},'GQoyq':_0x3192(0xaa),'LOyqf':function(_0x3fcafd,_0x10d71f){return _0x3fcafd&&_0x10d71f;},'ogrYQ':_0x3192(0xbe),'Oyaju':'✅\x20[MIGRATION\x20WARNING]\x20NO\x20WARNING\x20-\x20connection\x20is\x20working\x20properly','gRXmZ':_0x3192(0xbf),'ISFkc':_0x3192(0xc0)};try{console[_0x3192(0x20)](_0x574e43[_0x3192(0xc1)],_0x384ba9);const _0x3a446a=await _0x574e43['GWIHY'](fetch,API_CONFIG[_0x3192(0x43)]+_0x3192(0x15)+_0x384ba9),_0x9fa81a=await _0x3a446a[_0x3192(0x16)]();if(_0x9fa81a[_0x3192(0x45)]&&_0x9fa81a['validation']){var _0x15002a,_0x49db07;const _0x48a180=_0x574e43[_0x3192(0xc2)]((_0x15002a=_0x9fa81a[_0x3192(0x17)])===null||_0x574e43[_0x3192(0xc3)](_0x15002a,void 0x0)?void 0x0:_0x15002a['isTemporaryMode'],!![])||_0x574e43[_0x3192(0xc2)]((_0x49db07=_0x9fa81a[_0x3192(0x1c)])===null||_0x574e43[_0x3192(0xc4)](_0x49db07,void 0x0)?void 0x0:_0x49db07['enabled'],!![])||_0x574e43[_0x3192(0xc2)](_0x9fa81a['isTemporaryMode'],!![]),_0x2ec602=_0x9fa81a[_0x3192(0x17)][_0x3192(0xc5)]===!![],_0x26a9bc=_0x574e43[_0x3192(0xc6)](_0x9fa81a['validation'][_0x3192(0x1f)],!![]),_0x2668e5=_0x574e43[_0x3192(0xc7)](_0x9fa81a[_0x3192(0x17)][_0x3192(0x26)],!![]);console[_0x3192(0x20)](_0x574e43[_0x3192(0xc8)],{'username':_0x384ba9,'hasAccessToken':_0x2ec602,'hasRefreshToken':_0x26a9bc,'needsReconnection':_0x2668e5,'isTemporaryMode':_0x48a180,'connectedAt':_0x9fa81a['validation'][_0x3192(0xb6)]});if(_0x48a180)return console[_0x3192(0x20)](_0x3192(0x36)),![];else return _0x574e43[_0x3192(0xc9)](_0x2ec602,!_0x26a9bc)&&_0x2668e5?(console['log'](_0x574e43[_0x3192(0xca)]),!![]):_0x3192(0xcb)!==_0x3192(0xcc)?(console[_0x3192(0x20)](_0x574e43['Oyaju']),![]):(_0x166be8['log'](_0x574e43[_0x3192(0xcd)]),!![]);}return console[_0x3192(0x20)](_0x574e43[_0x3192(0xce)]),![];}catch(_0x5c5d98){return console['error'](_0x574e43['ISFkc'],_0x5c5d98),![];}};export const checkAndFixYouTubeConnection=async _0x370ee4=>{const _0x23631f={'rVaUI':_0x3192(0x50),'YXvYa':'full','BTiZL':'🔧\x20User\x20needs\x20YouTube\x20migration\x20for\x20refresh\x20token','ezwBe':'YouTube\x20Upgraded!\x20✅','mAstk':_0x3192(0xcf),'rEqBs':_0x3192(0x63),'RTCLQ':function(_0x379590,_0x48c59c){return _0x379590!==_0x48c59c;},'Mppjs':'pCxQm','gfMAM':'🔄\x20Checking\x20YouTube\x20connection\x20for\x20user:','dhfMC':'🚫\x20[MIGRATION]\x20NO\x20MIGRATION\x20NEEDED\x20-\x20user\x20connection\x20is\x20working\x20correctly','VwJuH':_0x3192(0xd0),'ebkhW':function(_0x48bfb4,_0x2f4cf3){return _0x48bfb4(_0x2f4cf3);},'fvpSW':_0x3192(0xd1),'jwyhp':function(_0x34b751){return _0x34b751();},'NHWJn':function(_0x5cb195,_0xedc577){return _0x5cb195===_0xedc577;},'GdMLa':_0x3192(0xd2),'sNRGW':'KubgX','dRwHl':_0x3192(0xd3),'SxZJp':function(_0x54cdda,_0x5078ca){return _0x54cdda(_0x5078ca);},'nMzRG':'oaZVz','tBYPo':_0x3192(0xd4),'xLlsE':'TgJNy','UtYGK':_0x3192(0xd5),'uJocc':_0x3192(0xd6),'IiLAA':_0x3192(0x8e),'zIWBu':_0x3192(0xd7)};try{if(_0x23631f[_0x3192(0xd8)](_0x23631f[_0x3192(0xd9)],_0x23631f[_0x3192(0xd9)]))return _0x55c34e[_0x3192(0x20)](_0x23631f['rVaUI']),{'isReady':!![],'mode':_0x23631f[_0x3192(0xda)],'needsMigration':![],'trainingReady':!![],'details':_0x3060a6};else{console[_0x3192(0x20)](_0x23631f['gfMAM'],_0x370ee4);const _0x46c6c1=await shouldShowYouTubeMigrationWarning(_0x370ee4);if(!_0x46c6c1)return console[_0x3192(0x20)](_0x23631f[_0x3192(0xdb)]),console[_0x3192(0x20)](_0x23631f['VwJuH']),!![];const _0x5c6a41=await _0x23631f[_0x3192(0xdc)](checkYouTubeMigrationNeeded,_0x370ee4);if(!_0x5c6a41)return console[_0x3192(0x20)](_0x3192(0xbc)),!![];console[_0x3192(0x20)](_0x23631f[_0x3192(0xdd)]);const _0x4cd889=await _0x23631f[_0x3192(0xde)](showYouTubeMigrationPrompt);if(!_0x4cd889)return _0x23631f[_0x3192(0xdf)](_0x23631f['GdMLa'],_0x23631f[_0x3192(0xe0)])?(_0x11c125['log'](_0x23631f[_0x3192(0xe1)]),!![]):(console[_0x3192(0x20)](_0x23631f['dRwHl']),![]);const _0x1c7775=await _0x23631f[_0x3192(0xe2)](forceYouTubeReconnection,_0x370ee4);return _0x1c7775?_0x23631f['NHWJn'](_0x3192(0xe3),_0x23631f['nMzRG'])?(_0x507a1c[_0x3192(0x2f)](_0x3192(0xd7),_0x261a61),![]):(Alert[_0x3192(0x5f)]('YouTube\x20Upgraded!\x20✅',_0x23631f[_0x3192(0xe4)],[{'text':_0x23631f[_0x3192(0xe5)],'style':_0x23631f[_0x3192(0xe6)]}]),!![]):_0x23631f[_0x3192(0xd8)](_0x23631f[_0x3192(0xe7)],_0x23631f['UtYGK'])?(Alert[_0x3192(0x5f)](_0x23631f[_0x3192(0xe8)],_0x23631f['IiLAA'],[{'text':'OK','style':_0x3192(0x63)}]),![]):(Alert[_0x3192(0x5f)](_0x23631f[_0x3192(0xe9)],_0x3192(0xd4),[{'text':_0x23631f[_0x3192(0xe5)],'style':_0x23631f[_0x3192(0xe6)]}]),!![]);}}catch(_0x1ed05b){return console['error'](_0x23631f[_0x3192(0xea)],_0x1ed05b),![];}};export const reconnectYouTube=async _0x432e6c=>{const _0x313e12={'pneWU':_0x3192(0xeb)};return console[_0x3192(0x20)](_0x313e12[_0x3192(0xec)],_0x432e6c),await forceYouTubeReconnection(_0x432e6c);};
|
|
1
|
+
import { GoogleSignin } from '@react-native-google-signin/google-signin';
|
|
2
|
+
import { Alert } from 'react-native';
|
|
3
|
+
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
4
|
+
import { API_CONFIG } from '../config/api';
|
|
5
|
+
|
|
6
|
+
// 🔑 CRITICAL: Using the same client ID for both web and iOS to avoid audience errors
|
|
7
|
+
const WEB_CLIENT_ID = '1030678346906-lovkuds2ouqmoc8eu5qpo98spa6edv4o.apps.googleusercontent.com';
|
|
8
|
+
const IOS_CLIENT_ID = '1030678346906-lovkuds2ouqmoc8eu5qpo98spa6edv4o.apps.googleusercontent.com';
|
|
9
|
+
|
|
10
|
+
// Configuration for Google Sign-In with refresh token support
|
|
11
|
+
const configureGoogleSignInForRefreshTokens = () => {
|
|
12
|
+
GoogleSignin.configure({
|
|
13
|
+
webClientId: WEB_CLIENT_ID,
|
|
14
|
+
// ✅ CRITICAL: Web client ID for refresh tokens
|
|
15
|
+
iosClientId: IOS_CLIENT_ID,
|
|
16
|
+
// ✅ iOS client ID for native auth
|
|
17
|
+
|
|
18
|
+
// 🔑 CRITICAL: These are the missing parameters that fix the refresh token issue
|
|
19
|
+
offlineAccess: true,
|
|
20
|
+
// ← Enables refresh tokens
|
|
21
|
+
forceCodeForRefreshToken: true,
|
|
22
|
+
// ← Forces refresh token generation
|
|
23
|
+
|
|
24
|
+
// ✅ Enhanced scopes for YouTube
|
|
25
|
+
scopes: ['https://www.googleapis.com/auth/youtube.readonly', 'openid', 'profile', 'email'],
|
|
26
|
+
// 🚀 Additional settings (helps with refresh tokens)
|
|
27
|
+
hostedDomain: '',
|
|
28
|
+
accountName: ''
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// Check if user needs YouTube migration
|
|
33
|
+
export const checkYouTubeMigrationNeeded = async username => {
|
|
34
|
+
try {
|
|
35
|
+
const response = await fetch(`${API_CONFIG.BASE_URL}/youtube/validate-connection/${username}`);
|
|
36
|
+
const result = await response.json();
|
|
37
|
+
if (result.success && result.validation) {
|
|
38
|
+
var _result$validation, _result$temporaryMode, _result$temporaryMode2;
|
|
39
|
+
// ✅ NEW: Check if this is temporary mode (matches exact backend response fields)
|
|
40
|
+
const isTemporaryMode = ((_result$validation = result.validation) === null || _result$validation === void 0 ? void 0 : _result$validation.isTemporaryMode) === true || ((_result$temporaryMode = result.temporaryMode) === null || _result$temporaryMode === void 0 ? void 0 : _result$temporaryMode.enabled) === true || result.isTemporaryMode === true || result.message && result.message.includes('temporary access token mode');
|
|
41
|
+
const needsReconnection = result.validation.needsReconnection;
|
|
42
|
+
const hasRefreshToken = result.validation.hasRefreshToken;
|
|
43
|
+
console.log('🔍 YouTube migration check:', {
|
|
44
|
+
username,
|
|
45
|
+
needsReconnection,
|
|
46
|
+
hasRefreshToken,
|
|
47
|
+
isTemporaryMode,
|
|
48
|
+
temporaryModeEnabled: (_result$temporaryMode2 = result.temporaryMode) === null || _result$temporaryMode2 === void 0 ? void 0 : _result$temporaryMode2.enabled,
|
|
49
|
+
message: result.message
|
|
50
|
+
});
|
|
51
|
+
if (isTemporaryMode) {
|
|
52
|
+
console.log('🔄 User using temporary mode - connection working correctly');
|
|
53
|
+
console.log('⚠️ No refresh capability but training can proceed');
|
|
54
|
+
return false; // Don't flag temporary mode as needing migration
|
|
55
|
+
} else if (needsReconnection) {
|
|
56
|
+
console.log('🔧 User needs YouTube migration for refresh token');
|
|
57
|
+
return true; // Only flag genuinely old connections
|
|
58
|
+
} else {
|
|
59
|
+
console.log('✅ YouTube connection fully working with refresh tokens');
|
|
60
|
+
return false; // Connection is perfect
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return false;
|
|
64
|
+
} catch (error) {
|
|
65
|
+
console.error('❌ Error checking YouTube migration status:', error);
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// ✅ NEW: Enhanced function to get detailed YouTube connection status
|
|
71
|
+
export const getYouTubeConnectionStatus = async username => {
|
|
72
|
+
try {
|
|
73
|
+
const response = await fetch(`${API_CONFIG.BASE_URL}/youtube/validate-connection/${username}`);
|
|
74
|
+
const result = await response.json();
|
|
75
|
+
console.log('📋 Complete YouTube status response:', result);
|
|
76
|
+
if (result.success && result.validation) {
|
|
77
|
+
var _result$validation2, _result$temporaryMode3;
|
|
78
|
+
// Check for temporary mode (prioritize exact backend fields)
|
|
79
|
+
const isTemporaryMode = ((_result$validation2 = result.validation) === null || _result$validation2 === void 0 ? void 0 : _result$validation2.isTemporaryMode) === true || ((_result$temporaryMode3 = result.temporaryMode) === null || _result$temporaryMode3 === void 0 ? void 0 : _result$temporaryMode3.enabled) === true || result.isTemporaryMode === true || result.message && result.message.includes('temporary access token mode');
|
|
80
|
+
const hasRefreshToken = result.validation.hasRefreshToken === true;
|
|
81
|
+
const needsReconnection = result.validation.needsReconnection === true;
|
|
82
|
+
if (isTemporaryMode) {
|
|
83
|
+
console.log('🔄 YouTube connected in temporary mode');
|
|
84
|
+
console.log('✅ Training will work, but connection expires in ~1 hour');
|
|
85
|
+
return {
|
|
86
|
+
isReady: true,
|
|
87
|
+
mode: 'temporary',
|
|
88
|
+
needsMigration: false,
|
|
89
|
+
trainingReady: true,
|
|
90
|
+
details: result
|
|
91
|
+
};
|
|
92
|
+
} else if (hasRefreshToken) {
|
|
93
|
+
console.log('✅ YouTube connected with refresh tokens');
|
|
94
|
+
return {
|
|
95
|
+
isReady: true,
|
|
96
|
+
mode: 'full',
|
|
97
|
+
needsMigration: false,
|
|
98
|
+
trainingReady: true,
|
|
99
|
+
details: result
|
|
100
|
+
};
|
|
101
|
+
} else if (needsReconnection) {
|
|
102
|
+
console.log('⚠️ YouTube connected but needs migration');
|
|
103
|
+
return {
|
|
104
|
+
isReady: false,
|
|
105
|
+
mode: 'limited',
|
|
106
|
+
needsMigration: true,
|
|
107
|
+
trainingReady: false,
|
|
108
|
+
details: result
|
|
109
|
+
};
|
|
110
|
+
} else {
|
|
111
|
+
console.log('❓ YouTube connection status unclear');
|
|
112
|
+
return {
|
|
113
|
+
isReady: false,
|
|
114
|
+
mode: 'none',
|
|
115
|
+
needsMigration: false,
|
|
116
|
+
trainingReady: false,
|
|
117
|
+
details: result
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
console.log('❌ No YouTube connection found');
|
|
122
|
+
return {
|
|
123
|
+
isReady: false,
|
|
124
|
+
mode: 'none',
|
|
125
|
+
needsMigration: false,
|
|
126
|
+
trainingReady: false,
|
|
127
|
+
details: result
|
|
128
|
+
};
|
|
129
|
+
} catch (error) {
|
|
130
|
+
console.error('❌ Error getting YouTube connection status:', error);
|
|
131
|
+
return {
|
|
132
|
+
isReady: false,
|
|
133
|
+
mode: 'none',
|
|
134
|
+
needsMigration: false,
|
|
135
|
+
trainingReady: false,
|
|
136
|
+
details: {
|
|
137
|
+
error: error instanceof Error ? error.message : String(error)
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
// Show user-friendly migration prompt
|
|
144
|
+
const showYouTubeMigrationPrompt = async () => {
|
|
145
|
+
return new Promise(resolve => {
|
|
146
|
+
Alert.alert('YouTube Connection Upgrade', 'To improve your training experience, we need to upgrade your YouTube connection. This prevents interruptions during data collection.\n\n✅ One-time upgrade\n✅ Takes 30 seconds\n✅ No data loss\n\nUpgrade now?', [{
|
|
147
|
+
text: 'Skip for Now',
|
|
148
|
+
style: 'cancel',
|
|
149
|
+
onPress: () => resolve(false)
|
|
150
|
+
}, {
|
|
151
|
+
text: 'Upgrade Now',
|
|
152
|
+
style: 'default',
|
|
153
|
+
onPress: () => resolve(true)
|
|
154
|
+
}]);
|
|
155
|
+
});
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
// Force YouTube reconnection with consent screen
|
|
159
|
+
const forceYouTubeReconnection = async username => {
|
|
160
|
+
try {
|
|
161
|
+
var _user, _user2, _user3, _user4;
|
|
162
|
+
console.log('🔄 Starting YouTube migration for user:', username);
|
|
163
|
+
|
|
164
|
+
// 1. Configure for refresh tokens
|
|
165
|
+
configureGoogleSignInForRefreshTokens();
|
|
166
|
+
|
|
167
|
+
// 2. Complete sign out to clear cached consent
|
|
168
|
+
await GoogleSignin.signOut();
|
|
169
|
+
console.log('✅ Signed out - consent cache cleared');
|
|
170
|
+
|
|
171
|
+
// 3. Clear cached tokens if available
|
|
172
|
+
try {
|
|
173
|
+
const existingTokens = await GoogleSignin.getTokens();
|
|
174
|
+
if (existingTokens.accessToken) {
|
|
175
|
+
await GoogleSignin.clearCachedAccessToken(existingTokens.accessToken);
|
|
176
|
+
console.log('✅ Token cache cleared');
|
|
177
|
+
}
|
|
178
|
+
} catch (clearError) {
|
|
179
|
+
console.log('ℹ️ No token cache to clear');
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// 4. Check Google Play Services
|
|
183
|
+
await GoogleSignin.hasPlayServices();
|
|
184
|
+
|
|
185
|
+
// 5. Sign in (this will show consent screen)
|
|
186
|
+
console.log('🔐 Initiating sign-in - consent screen should appear...');
|
|
187
|
+
const userInfo = await GoogleSignin.signIn();
|
|
188
|
+
|
|
189
|
+
// 6. Get tokens after consent
|
|
190
|
+
const tokens = await GoogleSignin.getTokens();
|
|
191
|
+
const currentUser = await GoogleSignin.getCurrentUser();
|
|
192
|
+
|
|
193
|
+
// 7. Analyze tokens thoroughly (serverAuthCode is the refresh token mechanism in React Native)
|
|
194
|
+
let finalRefreshToken = null;
|
|
195
|
+
let refreshTokenSource = 'None';
|
|
196
|
+
|
|
197
|
+
// Check for server auth code from sign-in response (primary method)
|
|
198
|
+
if (userInfo.serverAuthCode) {
|
|
199
|
+
finalRefreshToken = userInfo.serverAuthCode;
|
|
200
|
+
refreshTokenSource = 'Server auth code from sign-in';
|
|
201
|
+
}
|
|
202
|
+
// Check current user server auth code (backup method)
|
|
203
|
+
else if (currentUser !== null && currentUser !== void 0 && currentUser.serverAuthCode) {
|
|
204
|
+
finalRefreshToken = currentUser.serverAuthCode;
|
|
205
|
+
refreshTokenSource = 'Current user server auth code';
|
|
206
|
+
}
|
|
207
|
+
console.log('🔍 Token Analysis:', {
|
|
208
|
+
hasAccessToken: !!tokens.accessToken,
|
|
209
|
+
hasIdToken: !!tokens.idToken,
|
|
210
|
+
hasServerAuthCode: !!userInfo.serverAuthCode,
|
|
211
|
+
hasCurrentUserAuthCode: !!(currentUser !== null && currentUser !== void 0 && currentUser.serverAuthCode),
|
|
212
|
+
refreshTokenSource: refreshTokenSource,
|
|
213
|
+
finalRefreshToken: finalRefreshToken ? 'Available' : 'MISSING!',
|
|
214
|
+
userEmail: (_user = userInfo.user) === null || _user === void 0 ? void 0 : _user.email
|
|
215
|
+
});
|
|
216
|
+
if (!finalRefreshToken) {
|
|
217
|
+
console.error('❌ No refresh token received - Google Console configuration may be incorrect');
|
|
218
|
+
console.error('💡 This usually means:');
|
|
219
|
+
console.error(' 1. offlineAccess: true is missing from configuration');
|
|
220
|
+
console.error(' 2. forceCodeForRefreshToken: true is missing');
|
|
221
|
+
console.error(' 3. User did not grant offline access permission');
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
console.log('✅ Got refresh token after consent:', finalRefreshToken.substring(0, 20) + '...');
|
|
225
|
+
console.log('🔑 Refresh token source:', refreshTokenSource);
|
|
226
|
+
|
|
227
|
+
// 8. Get existing authentication token
|
|
228
|
+
let authToken = (await AsyncStorage.getItem('onairos_jwt_token')) || (await AsyncStorage.getItem('enoch_token')) || (await AsyncStorage.getItem('auth_token'));
|
|
229
|
+
if (!authToken) {
|
|
230
|
+
console.warn('⚠️ No authentication token found for YouTube migration');
|
|
231
|
+
authToken = 'migration_token_placeholder';
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// 9. Send enhanced payload to backend
|
|
235
|
+
const backendPayload = {
|
|
236
|
+
session: {
|
|
237
|
+
username: username,
|
|
238
|
+
platform: 'youtube',
|
|
239
|
+
channelName: ((_user2 = userInfo.user) === null || _user2 === void 0 ? void 0 : _user2.name) || 'YouTube Channel',
|
|
240
|
+
channelId: null
|
|
241
|
+
},
|
|
242
|
+
googleUser: userInfo.user,
|
|
243
|
+
accessToken: tokens.accessToken,
|
|
244
|
+
idToken: tokens.idToken,
|
|
245
|
+
refreshToken: finalRefreshToken,
|
|
246
|
+
serverAuthCode: userInfo.serverAuthCode,
|
|
247
|
+
userAccountInfo: {
|
|
248
|
+
username: username,
|
|
249
|
+
email: (_user3 = userInfo.user) === null || _user3 === void 0 ? void 0 : _user3.email,
|
|
250
|
+
authToken: authToken,
|
|
251
|
+
channelName: ((_user4 = userInfo.user) === null || _user4 === void 0 ? void 0 : _user4.name) || 'YouTube Channel',
|
|
252
|
+
channelId: null
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
console.log('📤 Sending migration payload to backend...');
|
|
256
|
+
|
|
257
|
+
// 10. Send to backend
|
|
258
|
+
const response = await fetch(`${API_CONFIG.BASE_URL}/youtube/native-auth`, {
|
|
259
|
+
method: 'POST',
|
|
260
|
+
headers: {
|
|
261
|
+
'Content-Type': 'application/json',
|
|
262
|
+
'x-api-key': 'your-api-key',
|
|
263
|
+
// Use your existing API key if needed
|
|
264
|
+
...(authToken !== 'migration_token_placeholder' && {
|
|
265
|
+
'Authorization': `Bearer ${authToken}`
|
|
266
|
+
})
|
|
267
|
+
},
|
|
268
|
+
body: JSON.stringify(backendPayload)
|
|
269
|
+
});
|
|
270
|
+
const result = await response.json();
|
|
271
|
+
if (result.success) {
|
|
272
|
+
console.log('✅ YouTube migration successful');
|
|
273
|
+
|
|
274
|
+
// Track migration success
|
|
275
|
+
await trackMigrationAttempt(username, true);
|
|
276
|
+
return true;
|
|
277
|
+
} else {
|
|
278
|
+
console.error('❌ Backend rejected YouTube migration:', result.error);
|
|
279
|
+
await trackMigrationAttempt(username, false, result.error);
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
282
|
+
} catch (error) {
|
|
283
|
+
console.error('❌ YouTube migration failed:', error);
|
|
284
|
+
await trackMigrationAttempt(username, false, error instanceof Error ? error.message : 'Unknown error');
|
|
285
|
+
return false;
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
// Track migration attempts for monitoring
|
|
290
|
+
const trackMigrationAttempt = async (username, success, error) => {
|
|
291
|
+
try {
|
|
292
|
+
await fetch(`${API_CONFIG.BASE_URL}/youtube/migration-status`, {
|
|
293
|
+
method: 'POST',
|
|
294
|
+
headers: {
|
|
295
|
+
'Content-Type': 'application/json'
|
|
296
|
+
},
|
|
297
|
+
body: JSON.stringify({
|
|
298
|
+
username,
|
|
299
|
+
success,
|
|
300
|
+
error: error || null,
|
|
301
|
+
timestamp: new Date().toISOString()
|
|
302
|
+
})
|
|
303
|
+
});
|
|
304
|
+
} catch (trackError) {
|
|
305
|
+
console.error('❌ Failed to track migration attempt:', trackError);
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
// ✅ NEW: Explicit function to check if user should see migration warnings
|
|
310
|
+
export const shouldShowYouTubeMigrationWarning = async username => {
|
|
311
|
+
try {
|
|
312
|
+
console.log('🔍 [MIGRATION WARNING] Checking if user should see migration warning:', username);
|
|
313
|
+
const response = await fetch(`${API_CONFIG.BASE_URL}/youtube/validate-connection/${username}`);
|
|
314
|
+
const result = await response.json();
|
|
315
|
+
if (result.success && result.validation) {
|
|
316
|
+
var _result$validation3, _result$temporaryMode4;
|
|
317
|
+
// Check for temporary mode (prioritize exact backend fields)
|
|
318
|
+
const isTemporaryMode = ((_result$validation3 = result.validation) === null || _result$validation3 === void 0 ? void 0 : _result$validation3.isTemporaryMode) === true || ((_result$temporaryMode4 = result.temporaryMode) === null || _result$temporaryMode4 === void 0 ? void 0 : _result$temporaryMode4.enabled) === true || result.isTemporaryMode === true;
|
|
319
|
+
const hasAccessToken = result.validation.hasAccessToken === true;
|
|
320
|
+
const hasRefreshToken = result.validation.hasRefreshToken === true;
|
|
321
|
+
const needsReconnection = result.validation.needsReconnection === true;
|
|
322
|
+
console.log('📊 [MIGRATION WARNING] Status check:', {
|
|
323
|
+
username,
|
|
324
|
+
hasAccessToken,
|
|
325
|
+
hasRefreshToken,
|
|
326
|
+
needsReconnection,
|
|
327
|
+
isTemporaryMode,
|
|
328
|
+
connectedAt: result.validation.connectedAt
|
|
329
|
+
});
|
|
330
|
+
if (isTemporaryMode) {
|
|
331
|
+
console.log('🚫 [MIGRATION WARNING] NO WARNING - user is in temporary mode (working correctly)');
|
|
332
|
+
return false; // Don't show migration warning
|
|
333
|
+
} else if (hasAccessToken && !hasRefreshToken && needsReconnection) {
|
|
334
|
+
console.log('⚠️ [MIGRATION WARNING] SHOW WARNING - genuinely old connection needs update');
|
|
335
|
+
return true; // Show migration warning for genuinely broken connections
|
|
336
|
+
} else {
|
|
337
|
+
console.log('✅ [MIGRATION WARNING] NO WARNING - connection is working properly');
|
|
338
|
+
return false; // Don't show warning for working connections
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
console.log('ℹ️ [MIGRATION WARNING] NO WARNING - no YouTube connection found');
|
|
342
|
+
return false; // Don't show warning if no connection
|
|
343
|
+
} catch (error) {
|
|
344
|
+
console.error('❌ [MIGRATION WARNING] Error checking migration warning status:', error);
|
|
345
|
+
return false; // Don't show warning on error
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
// Main function to check and fix YouTube connection
|
|
350
|
+
export const checkAndFixYouTubeConnection = async username => {
|
|
351
|
+
try {
|
|
352
|
+
console.log('🔄 Checking YouTube connection for user:', username);
|
|
353
|
+
|
|
354
|
+
// 1. First check if user should see migration warning at all
|
|
355
|
+
const shouldShowWarning = await shouldShowYouTubeMigrationWarning(username);
|
|
356
|
+
if (!shouldShowWarning) {
|
|
357
|
+
console.log('🚫 [MIGRATION] NO MIGRATION NEEDED - user connection is working correctly');
|
|
358
|
+
console.log('✅ [MIGRATION] User can proceed with training normally');
|
|
359
|
+
return true; // Return success - no migration needed
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
// 2. Double-check migration is actually needed (for safety)
|
|
363
|
+
const needsMigration = await checkYouTubeMigrationNeeded(username);
|
|
364
|
+
if (!needsMigration) {
|
|
365
|
+
console.log('✅ [MIGRATION] YouTube connection working properly - no migration needed');
|
|
366
|
+
return true;
|
|
367
|
+
}
|
|
368
|
+
console.log('🔧 [MIGRATION] User needs YouTube migration for refresh token (genuinely old connection)');
|
|
369
|
+
|
|
370
|
+
// 2. Show user-friendly prompt
|
|
371
|
+
const userConfirmed = await showYouTubeMigrationPrompt();
|
|
372
|
+
if (!userConfirmed) {
|
|
373
|
+
console.log('ℹ️ User declined YouTube migration');
|
|
374
|
+
return false;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
// 3. Attempt migration
|
|
378
|
+
const migrationSuccess = await forceYouTubeReconnection(username);
|
|
379
|
+
if (migrationSuccess) {
|
|
380
|
+
// Show success message
|
|
381
|
+
Alert.alert('YouTube Upgraded! ✅', 'Your YouTube connection has been upgraded successfully. Training will now work seamlessly without interruptions.', [{
|
|
382
|
+
text: 'Great!',
|
|
383
|
+
style: 'default'
|
|
384
|
+
}]);
|
|
385
|
+
return true;
|
|
386
|
+
} else {
|
|
387
|
+
// Show failure message
|
|
388
|
+
Alert.alert('Upgrade Failed ❌', 'YouTube connection upgrade failed. Please try again later or contact support if the problem persists.', [{
|
|
389
|
+
text: 'OK',
|
|
390
|
+
style: 'default'
|
|
391
|
+
}]);
|
|
392
|
+
return false;
|
|
393
|
+
}
|
|
394
|
+
} catch (error) {
|
|
395
|
+
console.error('❌ Error in YouTube connection check:', error);
|
|
396
|
+
return false;
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
// Optional: Reconnect function for manual use
|
|
401
|
+
export const reconnectYouTube = async username => {
|
|
402
|
+
console.log('🔄 Manual YouTube reconnection requested for:', username);
|
|
403
|
+
return await forceYouTubeReconnection(username);
|
|
404
|
+
};
|
|
405
|
+
//# sourceMappingURL=youtubeMigrationService.js.map
|