@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,10 +1,416 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
function _0x1752(_0x57b945,_0x17526c){_0x57b945=_0x57b945-0x0;const _0x4b65e6=_0x57b9();let _0x1fbdc0=_0x4b65e6[_0x57b945];return _0x1fbdc0;}Object['defineProperty'](exports,'__esModule',{'value':!![]}),exports[_0x1752(0x0)]=exports[_0x1752(0x1)]=exports[_0x1752(0x2)]=exports[_0x1752(0x3)]=exports[_0x1752(0x4)]=void 0x0;var _googleSignin=__ONAIROS_REQ_FUNC__(0x0),_reactNative=__ONAIROS_REQ_FUNC__(0x1),_asyncStorage=_interopRequireDefault(__ONAIROS_REQ_FUNC__(0x2)),_api=__ONAIROS_REQ_FUNC__(0x3);function _interopRequireDefault(_0x57b0b9){return _0x57b0b9&&_0x57b0b9[_0x1752(0x5)]?_0x57b0b9:{'default':_0x57b0b9};}const WEB_CLIENT_ID=_0x1752(0x6),IOS_CLIENT_ID=_0x1752(0x6),configureGoogleSignInForRefreshTokens=()=>{const _0x2406fe={'AJYSq':_0x1752(0x7)};_googleSignin['GoogleSignin']['configure']({'webClientId':WEB_CLIENT_ID,'iosClientId':IOS_CLIENT_ID,'offlineAccess':!![],'forceCodeForRefreshToken':!![],'scopes':[_0x1752(0x8),_0x1752(0x9),_0x1752(0xa),_0x2406fe['AJYSq']],'hostedDomain':'','accountName':''});},checkYouTubeMigrationNeeded=async _0x2054f0=>{const _0xa8e917={'CVdWE':_0x1752(0xb),'EXfkY':'none','ArbDl':function(_0x228ed7,_0xb3bf2e){return _0x228ed7===_0xb3bf2e;},'XXupF':function(_0x47d2e4,_0x1ae1dd){return _0x47d2e4===_0x1ae1dd;},'nOXZn':function(_0x525817,_0x4984e5){return _0x525817===_0x4984e5;},'EygUa':function(_0x4358d3,_0x1d12f9){return _0x4358d3===_0x1d12f9;},'fkRhg':_0x1752(0xc),'jEkPn':_0x1752(0xd),'XYPUq':_0x1752(0xe),'RUHbJ':_0x1752(0xf),'TTAyi':'✅\x20YouTube\x20connection\x20fully\x20working\x20with\x20refresh\x20tokens','DAasK':_0x1752(0x10)};try{const _0x2784d5=await fetch(_api['API_CONFIG']['BASE_URL']+_0x1752(0x11)+_0x2054f0),_0x3cae79=await _0x2784d5[_0x1752(0x12)]();if(_0x3cae79[_0x1752(0x13)]&&_0x3cae79[_0x1752(0x14)]){var _0x565d7f,_0x46e7de,_0x51102f;const _0x16d465=_0xa8e917[_0x1752(0x15)](_0xa8e917[_0x1752(0x16)](_0x565d7f=_0x3cae79[_0x1752(0x14)],null)||_0xa8e917['ArbDl'](_0x565d7f,void 0x0)?void 0x0:_0x565d7f['isTemporaryMode'],!![])||(_0xa8e917[_0x1752(0x15)](_0x46e7de=_0x3cae79[_0x1752(0x17)],null)||_0xa8e917[_0x1752(0x18)](_0x46e7de,void 0x0)?void 0x0:_0x46e7de['enabled'])===!![]||_0xa8e917['EygUa'](_0x3cae79[_0x1752(0x19)],!![])||_0x3cae79[_0x1752(0x1a)]&&_0x3cae79['message']['includes'](_0xa8e917[_0x1752(0x1b)]),_0xdbe98c=_0x3cae79[_0x1752(0x14)][_0x1752(0x1c)],_0x1523b9=_0x3cae79[_0x1752(0x14)][_0x1752(0x1d)];console[_0x1752(0x1e)](_0x1752(0x1f),{'username':_0x2054f0,'needsReconnection':_0xdbe98c,'hasRefreshToken':_0x1523b9,'isTemporaryMode':_0x16d465,'temporaryModeEnabled':(_0x51102f=_0x3cae79[_0x1752(0x17)])===null||_0xa8e917[_0x1752(0x20)](_0x51102f,void 0x0)?void 0x0:_0x51102f[_0x1752(0x21)],'message':_0x3cae79[_0x1752(0x1a)]});if(_0x16d465)return console[_0x1752(0x1e)](_0x1752(0x22)),console[_0x1752(0x1e)](_0xa8e917['jEkPn']),![];else return _0xdbe98c?_0xa8e917[_0x1752(0x15)](_0xa8e917[_0x1752(0x23)],_0xa8e917[_0x1752(0x24)])?(_0x39c7e1['log'](_0xa8e917['CVdWE']),{'isReady':![],'mode':_0xa8e917[_0x1752(0x25)],'needsMigration':![],'trainingReady':![],'details':_0x58c62b}):(console[_0x1752(0x1e)](_0x1752(0x26)),!![]):(console[_0x1752(0x1e)](_0xa8e917[_0x1752(0x27)]),![]);}return![];}catch(_0x48674c){return console[_0x1752(0x28)](_0xa8e917[_0x1752(0x29)],_0x48674c),![];}};function _0x57b9(){const _0x3e882b=['shouldShowYouTubeMigrationWarning','reconnectYouTube','getYouTubeConnectionStatus','checkYouTubeMigrationNeeded','checkAndFixYouTubeConnection','__esModule','1030678346906-lovkuds2ouqmoc8eu5qpo98spa6edv4o.apps.googleusercontent.com','email','https://www.googleapis.com/auth/youtube.readonly','openid','profile','❓\x20YouTube\x20connection\x20status\x20unclear','temporary\x20access\x20token\x20mode','⚠️\x20No\x20refresh\x20capability\x20but\x20training\x20can\x20proceed','mLWeK','IOaMH','❌\x20Error\x20checking\x20YouTube\x20migration\x20status:','/youtube/validate-connection/','json','success','validation','ArbDl','XXupF','temporaryMode','nOXZn','isTemporaryMode','message','fkRhg','needsReconnection','hasRefreshToken','log','🔍\x20YouTube\x20migration\x20check:','EygUa','enabled','🔄\x20User\x20using\x20temporary\x20mode\x20-\x20connection\x20working\x20correctly','XYPUq','RUHbJ','EXfkY','🔧\x20User\x20needs\x20YouTube\x20migration\x20for\x20refresh\x20token','TTAyi','error','DAasK','⚠️\x20YouTube\x20connected\x20but\x20needs\x20migration','limited','LHQCx','oJvrj','🔄\x20YouTube\x20connected\x20in\x20temporary\x20mode','✅\x20Training\x20will\x20work,\x20but\x20connection\x20expires\x20in\x20~1\x20hour','temporary','MHKoM','none','HSpiq','RYfaE','📋\x20Complete\x20YouTube\x20status\x20response:','bInbn','XwWBc','dfGqa','ezYLJ','includes','ggBqA','cwMxd','wtYgI','YlHaV','HbuxO','DVYnA','full','hLnNb','AVdTZ','UVCUT','❌\x20No\x20YouTube\x20connection\x20found','doaHo','❌\x20Error\x20getting\x20YouTube\x20connection\x20status:','IbBTX','Tkvzh','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?','Skip\x20for\x20Now','cancel','Upgrade\x20Now','default','Alert','NvOKY','hskRt','HErHz','Current\x20user\x20server\x20auth\x20code','📊\x20[MIGRATION\x20WARNING]\x20Status\x20check:','✅\x20[MIGRATION\x20WARNING]\x20NO\x20WARNING\x20-\x20connection\x20is\x20working\x20properly','Upgrade\x20Failed\x20❌','YouTube\x20connection\x20upgrade\x20failed.\x20Please\x20try\x20again\x20later\x20or\x20contact\x20support\x20if\x20the\x20problem\x20persists.','🚫\x20[MIGRATION\x20WARNING]\x20NO\x20WARNING\x20-\x20user\x20is\x20in\x20temporary\x20mode\x20(working\x20correctly)','ZSnvH','✅\x20Token\x20cache\x20cleared','wqglM','jLiUt','Available','MISSING!','2|0|5|4|1|3','💡\x20This\x20usually\x20means:','\x20\x20\x203.\x20User\x20did\x20not\x20grant\x20offline\x20access\x20permission','❌\x20No\x20refresh\x20token\x20received\x20-\x20Google\x20Console\x20configuration\x20may\x20be\x20incorrect','\x20\x20\x202.\x20forceCodeForRefreshToken:\x20true\x20is\x20missing','\x20\x20\x201.\x20offlineAccess:\x20true\x20is\x20missing\x20from\x20configuration','onairos_jwt_token','enoch_token','⚠️\x20No\x20authentication\x20token\x20found\x20for\x20YouTube\x20migration','youtube','📤\x20Sending\x20migration\x20payload\x20to\x20backend...','✅\x20YouTube\x20migration\x20successful','❌\x20Backend\x20rejected\x20YouTube\x20migration:','❌\x20YouTube\x20migration\x20failed:','Unknown\x20error','kOXxw','YzCtm','luCpw','🔄\x20Starting\x20YouTube\x20migration\x20for\x20user:','bOeSe','GoogleSignin','signOut','✅\x20Signed\x20out\x20-\x20consent\x20cache\x20cleared','getTokens','accessToken','clearCachedAccessToken','mtazg','TbEHO','ℹ️\x20No\x20token\x20cache\x20to\x20clear','serverAuthCode','IulDh','hasPlayServices','Pvkjc','signIn','getCurrentUser','None','lpRWq','Nuudv','ZnraS','FSLFW','hasAccessToken','aKLBk','connectedAt','cTySP','eKFRs','Server\x20auth\x20code\x20from\x20sign-in','lnBwN','🔍\x20Token\x20Analysis:','sgdQx','UaLcy','qFaIT','user','eeDvQ','rgIxf','tfMSr','split','IDopE','SdHft','LYgti','xoioR','alert','XoWoc','frwuQ','uloBO','gbJYA','UzTzN','🔑\x20Refresh\x20token\x20source:','getItem','ybjfM','vkfwQ','uisai','warn','YtpPU','FLyeC','tyShc','jQtEQ','name','idToken','DDMUb','YECZT','tsVrl','GFXAS','API_CONFIG','BASE_URL','/youtube/native-auth','your-api-key','zOnnk','QdnxX','DrLmb','RuSmA','YUkFV','xruPR','masHT','/youtube/migration-status','stringify','jGepp','toISOString','YouTube\x20Upgraded!\x20✅','Your\x20YouTube\x20connection\x20has\x20been\x20upgraded\x20successfully.\x20Training\x20will\x20now\x20work\x20seamlessly\x20without\x20interruptions.','Great!','🔍\x20[MIGRATION\x20WARNING]\x20Checking\x20if\x20user\x20should\x20see\x20migration\x20warning:','krHQU','⚠️\x20[MIGRATION\x20WARNING]\x20SHOW\x20WARNING\x20-\x20genuinely\x20old\x20connection\x20needs\x20update','LdxsU','❌\x20[MIGRATION\x20WARNING]\x20Error\x20checking\x20migration\x20warning\x20status:','ezDxW','vwEDQ','zpAXn','QDpuC','CsWpb','oiUyd','bSqZC','ZXcfY','KjExl','wvhjc','HNdUF','LhnNB','QVsNI','XOZMF','YAKUh','CXIGx','hfBlm','wGdKP','fLmph','mCoCV','✅\x20[MIGRATION]\x20User\x20can\x20proceed\x20with\x20training\x20normally','🔧\x20[MIGRATION]\x20User\x20needs\x20YouTube\x20migration\x20for\x20refresh\x20token\x20(genuinely\x20old\x20connection)','ℹ️\x20User\x20declined\x20YouTube\x20migration','❌\x20Error\x20in\x20YouTube\x20connection\x20check:','🔄\x20Checking\x20YouTube\x20connection\x20for\x20user:','ZjnfA','RfQLX','UUSiN','vAAlt','ryJAA','TJXUG','PrzuU','kbviG','hmHLt','kwmSI','jDdqe','configure','pBTUq','CWjMi','TZHvh','wVTWC'];_0x57b9=function(){return _0x3e882b;};return _0x57b9();}exports[_0x1752(0x3)]=checkYouTubeMigrationNeeded;const getYouTubeConnectionStatus=async _0x3e0b8e=>{const _0x3d6cfa={'hLnNb':_0x1752(0x2a),'AVdTZ':_0x1752(0x2b),'IbBTX':'✅\x20[MIGRATION]\x20YouTube\x20connection\x20working\x20properly\x20-\x20no\x20migration\x20needed','RYfaE':function(_0x3febf2,_0x1de434){return _0x3febf2(_0x1de434);},'bInbn':function(_0x5fff88,_0x4ef56f){return _0x5fff88!==_0x4ef56f;},'UPiIT':_0x1752(0x2c),'XwWBc':_0x1752(0x2d),'dfGqa':function(_0x433654,_0x538734){return _0x433654===_0x538734;},'cwMxd':function(_0x26399e,_0xc759bd){return _0x26399e===_0xc759bd;},'ezYLJ':function(_0x1ee8d8,_0x32a9c2){return _0x1ee8d8===_0x32a9c2;},'ggBqA':'temporary\x20access\x20token\x20mode','wtYgI':_0x1752(0x2e),'YlHaV':_0x1752(0x2f),'HbuxO':_0x1752(0x30),'VMYyj':_0x1752(0x31),'DVYnA':'✅\x20YouTube\x20connected\x20with\x20refresh\x20tokens','UVCUT':_0x1752(0x32),'doaHo':_0x1752(0x33),'nOAZJ':function(_0x4a091e,_0x41e413){return _0x4a091e instanceof _0x41e413;}};try{const _0x330283=await _0x3d6cfa[_0x1752(0x34)](fetch,_api['API_CONFIG']['BASE_URL']+_0x1752(0x11)+_0x3e0b8e),_0x2fe0f6=await _0x330283['json']();console['log'](_0x1752(0x35),_0x2fe0f6);if(_0x2fe0f6[_0x1752(0x13)]&&_0x2fe0f6[_0x1752(0x14)]){if(_0x3d6cfa[_0x1752(0x36)](_0x3d6cfa['UPiIT'],_0x3d6cfa[_0x1752(0x37)])){var _0x8f4567,_0x52a6c9;const _0x31630d=(_0x3d6cfa['dfGqa'](_0x8f4567=_0x2fe0f6[_0x1752(0x14)],null)||_0x3d6cfa[_0x1752(0x38)](_0x8f4567,void 0x0)?void 0x0:_0x8f4567[_0x1752(0x19)])===!![]||_0x3d6cfa['dfGqa'](_0x3d6cfa['cwMxd'](_0x52a6c9=_0x2fe0f6[_0x1752(0x17)],null)||_0x3d6cfa[_0x1752(0x39)](_0x52a6c9,void 0x0)?void 0x0:_0x52a6c9[_0x1752(0x21)],!![])||_0x3d6cfa[_0x1752(0x38)](_0x2fe0f6[_0x1752(0x19)],!![])||_0x2fe0f6[_0x1752(0x1a)]&&_0x2fe0f6[_0x1752(0x1a)][_0x1752(0x3a)](_0x3d6cfa[_0x1752(0x3b)]),_0x4499ae=_0x3d6cfa[_0x1752(0x3c)](_0x2fe0f6['validation'][_0x1752(0x1d)],!![]),_0x130769=_0x2fe0f6[_0x1752(0x14)]['needsReconnection']===!![];if(_0x31630d)return console['log'](_0x3d6cfa[_0x1752(0x3d)]),console[_0x1752(0x1e)](_0x3d6cfa[_0x1752(0x3e)]),{'isReady':!![],'mode':_0x3d6cfa[_0x1752(0x3f)],'needsMigration':![],'trainingReady':!![],'details':_0x2fe0f6};else{if(_0x4499ae){if(_0x3d6cfa[_0x1752(0x38)](_0x3d6cfa['VMYyj'],_0x1752(0x31)))return console[_0x1752(0x1e)](_0x3d6cfa[_0x1752(0x40)]),{'isReady':!![],'mode':_0x1752(0x41),'needsMigration':![],'trainingReady':!![],'details':_0x2fe0f6};else _0x38de3b[_0x1752(0x28)]('❌\x20Failed\x20to\x20track\x20migration\x20attempt:',_0x11d79c);}else return _0x130769?(console[_0x1752(0x1e)](_0x3d6cfa[_0x1752(0x42)]),{'isReady':![],'mode':_0x3d6cfa[_0x1752(0x43)],'needsMigration':!![],'trainingReady':![],'details':_0x2fe0f6}):(console[_0x1752(0x1e)](_0x1752(0xb)),{'isReady':![],'mode':_0x3d6cfa[_0x1752(0x44)],'needsMigration':![],'trainingReady':![],'details':_0x2fe0f6});}}else return _0x235c03[_0x1752(0x1e)](_0x3d6cfa[_0x1752(0x42)]),{'isReady':![],'mode':_0x3d6cfa[_0x1752(0x43)],'needsMigration':!![],'trainingReady':![],'details':_0x400090};}return console[_0x1752(0x1e)](_0x1752(0x45)),{'isReady':![],'mode':_0x3d6cfa[_0x1752(0x44)],'needsMigration':![],'trainingReady':![],'details':_0x2fe0f6};}catch(_0x320963){return _0x3d6cfa['cwMxd'](_0x3d6cfa['doaHo'],_0x3d6cfa[_0x1752(0x46)])?(console[_0x1752(0x28)](_0x1752(0x47),_0x320963),{'isReady':![],'mode':_0x3d6cfa['UVCUT'],'needsMigration':![],'trainingReady':![],'details':{'error':_0x3d6cfa['nOAZJ'](_0x320963,Error)?_0x320963[_0x1752(0x1a)]:_0x3d6cfa[_0x1752(0x34)](String,_0x320963)}}):(_0xe3707d[_0x1752(0x1e)](_0x3d6cfa[_0x1752(0x48)]),!![]);}};exports[_0x1752(0x2)]=getYouTubeConnectionStatus;const showYouTubeMigrationPrompt=async()=>{const _0x3cee1d={'wNyzG':_0x1752(0x49),'NvOKY':_0x1752(0x4a),'hskRt':_0x1752(0x4b),'HErHz':_0x1752(0x4c),'PYRDa':_0x1752(0x4d),'KeerO':_0x1752(0x4e),'dZDXF':_0x1752(0x4f)};return new Promise(_0xf43046=>{if(_0x3cee1d['wNyzG']!=='Tkvzh')return _0x3bb112&&_0x42781f['__esModule']?_0x25f4d9:{'default':_0x5828f7};else _reactNative[_0x1752(0x50)]['alert'](_0x3cee1d[_0x1752(0x51)],_0x3cee1d[_0x1752(0x52)],[{'text':_0x3cee1d[_0x1752(0x53)],'style':_0x3cee1d['PYRDa'],'onPress':()=>_0xf43046(![])},{'text':_0x3cee1d['KeerO'],'style':_0x3cee1d['dZDXF'],'onPress':()=>_0xf43046(!![])}]);});},forceYouTubeReconnection=async _0xc5c83e=>{const _0x2a7782={'YzCtm':'🔄\x20User\x20using\x20temporary\x20mode\x20-\x20connection\x20working\x20correctly','luCpw':_0x1752(0xd),'IulDh':_0x1752(0x54),'pZIMK':function(_0x47b6ca,_0x14d636){return _0x47b6ca===_0x14d636;},'Nuudv':function(_0x3b338c,_0x2d6299){return _0x3b338c===_0x2d6299;},'GztvI':function(_0x192a67,_0x23e447){return _0x192a67===_0x23e447;},'ZnraS':function(_0x2dc4cc,_0x498926){return _0x2dc4cc===_0x498926;},'FSLFW':function(_0x34b5b5,_0x27ec31){return _0x34b5b5===_0x27ec31;},'aKLBk':_0x1752(0x55),'cTySP':function(_0x1853a9,_0x3fa0b9){return _0x1853a9&&_0x3fa0b9;},'eKFRs':'⚠️\x20[MIGRATION\x20WARNING]\x20SHOW\x20WARNING\x20-\x20genuinely\x20old\x20connection\x20needs\x20update','lbLFk':_0x1752(0x56),'XoWoc':_0x1752(0x57),'frwuQ':_0x1752(0x58),'uloBO':_0x1752(0x4f),'AYbOm':_0x1752(0x59),'kOXxw':function(_0xce7510,_0x185a2b){return _0xce7510===_0x185a2b;},'ZlfqD':_0x1752(0x5a),'OuwBf':'IjtTw','bOeSe':function(_0x307b6b){return _0x307b6b();},'SrWRm':_0x1752(0x5b),'lnBwN':function(_0x41d6f3,_0x464827){return _0x41d6f3!==_0x464827;},'TbEHO':_0x1752(0x5c),'Pvkjc':'🔐\x20Initiating\x20sign-in\x20-\x20consent\x20screen\x20should\x20appear...','Saove':_0x1752(0x5d),'sgdQx':_0x1752(0x5e),'UaLcy':_0x1752(0x5f),'qFaIT':function(_0x9b12d7,_0xb3d48){return _0x9b12d7===_0xb3d48;},'eeDvQ':function(_0x445e73,_0x3b6b4a){return _0x445e73===_0x3b6b4a;},'rgIxf':'lBYDm','tfMSr':_0x1752(0x60),'IDopE':_0x1752(0x61),'SdHft':_0x1752(0x62),'LYgti':_0x1752(0x63),'IOtbg':_0x1752(0x64),'xoioR':_0x1752(0x65),'gbJYA':'✅\x20Got\x20refresh\x20token\x20after\x20consent:','UzTzN':'...','ybjfM':_0x1752(0x66),'vkfwQ':_0x1752(0x67),'uisai':'auth_token','YtpPU':_0x1752(0x68),'FLyeC':'migration_token_placeholder','tyShc':_0x1752(0x69),'jQtEQ':function(_0x29b53c,_0x27df97){return _0x29b53c===_0x27df97;},'DDMUb':function(_0x2c8089,_0x12b93c){return _0x2c8089===_0x12b93c;},'YECZT':function(_0x15004b,_0x2995c9){return _0x15004b===_0x2995c9;},'rLiVF':function(_0x2fcfc3,_0x584d50){return _0x2fcfc3===_0x584d50;},'tsVrl':'YouTube\x20Channel','GFXAS':_0x1752(0x6a),'zOnnk':function(_0x4c1783,_0x145d74){return _0x4c1783===_0x145d74;},'DrLmb':'QdnxX','Jpiib':_0x1752(0x6b),'RuSmA':function(_0x1fee9f,_0x157912,_0x739ef7){return _0x1fee9f(_0x157912,_0x739ef7);},'YUkFV':_0x1752(0x6c),'BpLvO':function(_0x4185d4,_0x6bf860,_0xd9b4eb,_0x13ee4a){return _0x4185d4(_0x6bf860,_0xd9b4eb,_0x13ee4a);},'xruPR':_0x1752(0x6d),'bZlpO':function(_0x219e4b,_0x4c89a1){return _0x219e4b instanceof _0x4c89a1;},'LSMqr':_0x1752(0x6e)};try{if(_0x2a7782[_0x1752(0x6f)](_0x2a7782['ZlfqD'],_0x2a7782['OuwBf']))return _0x49b393['log'](_0x2a7782[_0x1752(0x70)]),_0x21bab6[_0x1752(0x1e)](_0x2a7782[_0x1752(0x71)]),![];else{var _0x48ddfb,_0x5a7a7a,_0x52acfd,_0x56f04e;console[_0x1752(0x1e)](_0x1752(0x72),_0xc5c83e),_0x2a7782[_0x1752(0x73)](configureGoogleSignInForRefreshTokens),await _googleSignin[_0x1752(0x74)][_0x1752(0x75)](),console[_0x1752(0x1e)](_0x1752(0x76));try{const _0x57f5fc=await _googleSignin[_0x1752(0x74)][_0x1752(0x77)]();_0x57f5fc[_0x1752(0x78)]&&(await _googleSignin[_0x1752(0x74)][_0x1752(0x79)](_0x57f5fc[_0x1752(0x78)]),console[_0x1752(0x1e)](_0x2a7782['SrWRm']));}catch(_0xec03d5){_0x2a7782['lnBwN'](_0x1752(0x7a),_0x2a7782[_0x1752(0x7b)])?console[_0x1752(0x1e)](_0x1752(0x7c)):(_0x5ae0a1=_0x13919b[_0x1752(0x7d)],_0x4b559f=_0x2a7782[_0x1752(0x7e)]);}await _googleSignin['GoogleSignin'][_0x1752(0x7f)](),console[_0x1752(0x1e)](_0x2a7782[_0x1752(0x80)]);const _0xcade71=await _googleSignin['GoogleSignin'][_0x1752(0x81)](),_0x46965b=await _googleSignin[_0x1752(0x74)][_0x1752(0x77)](),_0x199ff4=await _googleSignin['GoogleSignin'][_0x1752(0x82)]();let _0x5ee180=null,_0x2af7b1=_0x1752(0x83);if(_0xcade71['serverAuthCode']){if(_0x1752(0x84)===_0x2a7782['Saove']){var _0x58a69d,_0x394342;const _0x49569b=(_0x2a7782['pZIMK'](_0x58a69d=_0x62db4a[_0x1752(0x14)],null)||_0x2a7782[_0x1752(0x85)](_0x58a69d,void 0x0)?void 0x0:_0x58a69d[_0x1752(0x19)])===!![]||_0x2a7782['GztvI']((_0x394342=_0x5201a0['temporaryMode'])===null||_0x2a7782[_0x1752(0x86)](_0x394342,void 0x0)?void 0x0:_0x394342['enabled'],!![])||_0x2a7782[_0x1752(0x87)](_0x23ebf5[_0x1752(0x19)],!![]),_0x3e9ee2=_0x2a7782[_0x1752(0x86)](_0x5c73d3[_0x1752(0x14)][_0x1752(0x88)],!![]),_0x173646=_0x3e41bb[_0x1752(0x14)][_0x1752(0x1d)]===!![],_0x3fb4f7=_0x34c46f[_0x1752(0x14)]['needsReconnection']===!![];_0xbe2721['log'](_0x2a7782[_0x1752(0x89)],{'username':_0x5ee784,'hasAccessToken':_0x3e9ee2,'hasRefreshToken':_0x173646,'needsReconnection':_0x3fb4f7,'isTemporaryMode':_0x49569b,'connectedAt':_0x19755a[_0x1752(0x14)][_0x1752(0x8a)]});if(_0x49569b)return _0x5ca5c3[_0x1752(0x1e)](_0x1752(0x59)),![];else return _0x2a7782[_0x1752(0x8b)](_0x3e9ee2,!_0x173646)&&_0x3fb4f7?(_0x11a5a3['log'](_0x2a7782[_0x1752(0x8c)]),!![]):(_0x541fb9[_0x1752(0x1e)](_0x2a7782['lbLFk']),![]);}else _0x5ee180=_0xcade71[_0x1752(0x7d)],_0x2af7b1=_0x1752(0x8d);}else _0x199ff4!==null&&_0x2a7782[_0x1752(0x8e)](_0x199ff4,void 0x0)&&_0x199ff4[_0x1752(0x7d)]&&(_0x5ee180=_0x199ff4[_0x1752(0x7d)],_0x2af7b1=_0x2a7782['IulDh']);console[_0x1752(0x1e)](_0x1752(0x8f),{'hasAccessToken':!!_0x46965b[_0x1752(0x78)],'hasIdToken':!!_0x46965b['idToken'],'hasServerAuthCode':!!_0xcade71['serverAuthCode'],'hasCurrentUserAuthCode':!!(_0x199ff4!==null&&_0x199ff4!==void 0x0&&_0x199ff4[_0x1752(0x7d)]),'refreshTokenSource':_0x2af7b1,'finalRefreshToken':_0x5ee180?_0x2a7782[_0x1752(0x90)]:_0x2a7782[_0x1752(0x91)],'userEmail':_0x2a7782[_0x1752(0x92)](_0x48ddfb=_0xcade71[_0x1752(0x93)],null)||_0x2a7782[_0x1752(0x94)](_0x48ddfb,void 0x0)?void 0x0:_0x48ddfb[_0x1752(0x7)]});if(!_0x5ee180){if(_0x2a7782[_0x1752(0x95)]===_0x2a7782[_0x1752(0x95)]){const _0x19559c=_0x2a7782[_0x1752(0x96)][_0x1752(0x97)]('|');let _0x1338fc=0x0;while(!![]){switch(_0x19559c[_0x1338fc++]){case'0':console['error'](_0x2a7782[_0x1752(0x98)]);continue;case'1':console[_0x1752(0x28)](_0x2a7782[_0x1752(0x99)]);continue;case'2':console['error'](_0x2a7782[_0x1752(0x9a)]);continue;case'3':return![];case'4':console[_0x1752(0x28)](_0x2a7782['IOtbg']);continue;case'5':console[_0x1752(0x28)](_0x2a7782[_0x1752(0x9b)]);continue;}break;}}else return _0x1d4c10[_0x1752(0x50)][_0x1752(0x9c)](_0x2a7782[_0x1752(0x9d)],_0x2a7782[_0x1752(0x9e)],[{'text':'OK','style':_0x2a7782[_0x1752(0x9f)]}]),![];}console[_0x1752(0x1e)](_0x2a7782[_0x1752(0xa0)],_0x5ee180['substring'](0x0,0x14)+_0x2a7782[_0x1752(0xa1)]),console['log'](_0x1752(0xa2),_0x2af7b1);let _0x1ecdbd=await _asyncStorage['default'][_0x1752(0xa3)](_0x2a7782[_0x1752(0xa4)])||await _asyncStorage[_0x1752(0x4f)]['getItem'](_0x2a7782[_0x1752(0xa5)])||await _asyncStorage[_0x1752(0x4f)]['getItem'](_0x2a7782[_0x1752(0xa6)]);!_0x1ecdbd&&(console[_0x1752(0xa7)](_0x2a7782[_0x1752(0xa8)]),_0x1ecdbd=_0x2a7782[_0x1752(0xa9)]);const _0x57851f={'session':{'username':_0xc5c83e,'platform':_0x2a7782[_0x1752(0xaa)],'channelName':((_0x5a7a7a=_0xcade71[_0x1752(0x93)])===null||_0x2a7782[_0x1752(0xab)](_0x5a7a7a,void 0x0)?void 0x0:_0x5a7a7a[_0x1752(0xac)])||'YouTube\x20Channel','channelId':null},'googleUser':_0xcade71[_0x1752(0x93)],'accessToken':_0x46965b[_0x1752(0x78)],'idToken':_0x46965b[_0x1752(0xad)],'refreshToken':_0x5ee180,'serverAuthCode':_0xcade71['serverAuthCode'],'userAccountInfo':{'username':_0xc5c83e,'email':_0x2a7782[_0x1752(0xae)](_0x52acfd=_0xcade71[_0x1752(0x93)],null)||_0x2a7782[_0x1752(0xaf)](_0x52acfd,void 0x0)?void 0x0:_0x52acfd[_0x1752(0x7)],'authToken':_0x1ecdbd,'channelName':(_0x2a7782[_0x1752(0x86)](_0x56f04e=_0xcade71[_0x1752(0x93)],null)||_0x2a7782['rLiVF'](_0x56f04e,void 0x0)?void 0x0:_0x56f04e['name'])||_0x2a7782[_0x1752(0xb0)],'channelId':null}};console[_0x1752(0x1e)](_0x2a7782[_0x1752(0xb1)]);const _0x390157=await fetch(_api[_0x1752(0xb2)][_0x1752(0xb3)]+_0x1752(0xb4),{'method':'POST','headers':{'Content-Type':'application/json','x-api-key':_0x1752(0xb5),..._0x2a7782[_0x1752(0x8e)](_0x1ecdbd,'migration_token_placeholder')&&{'Authorization':'Bearer\x20'+_0x1ecdbd}},'body':JSON['stringify'](_0x57851f)}),_0x22a238=await _0x390157['json']();return _0x22a238[_0x1752(0x13)]?_0x2a7782[_0x1752(0xb6)](_0x1752(0xb7),_0x2a7782[_0x1752(0xb8)])?(console[_0x1752(0x1e)](_0x2a7782['Jpiib']),await _0x2a7782[_0x1752(0xb9)](trackMigrationAttempt,_0xc5c83e,!![]),!![]):(_0x330a8e[_0x1752(0x1e)](_0x2a7782['AYbOm']),![]):(console[_0x1752(0x28)](_0x2a7782[_0x1752(0xba)],_0x22a238[_0x1752(0x28)]),await _0x2a7782['BpLvO'](trackMigrationAttempt,_0xc5c83e,![],_0x22a238[_0x1752(0x28)]),![]);}}catch(_0x11afa8){return console[_0x1752(0x28)](_0x2a7782[_0x1752(0xbb)],_0x11afa8),await trackMigrationAttempt(_0xc5c83e,![],_0x2a7782['bZlpO'](_0x11afa8,Error)?_0x11afa8['message']:_0x2a7782['LSMqr']),![];}},trackMigrationAttempt=async(_0x483ab2,_0x3d970e,_0x16a947)=>{const _0x1888be={'masHT':function(_0x57cbae,_0x181d90,_0x4d7ec7){return _0x57cbae(_0x181d90,_0x4d7ec7);},'jGepp':function(_0x57760f,_0xde6312){return _0x57760f||_0xde6312;},'GmUTR':'❌\x20Failed\x20to\x20track\x20migration\x20attempt:'};try{await _0x1888be[_0x1752(0xbc)](fetch,_api['API_CONFIG'][_0x1752(0xb3)]+_0x1752(0xbd),{'method':'POST','headers':{'Content-Type':'application/json'},'body':JSON[_0x1752(0xbe)]({'username':_0x483ab2,'success':_0x3d970e,'error':_0x1888be[_0x1752(0xbf)](_0x16a947,null),'timestamp':new Date()[_0x1752(0xc0)]()})});}catch(_0x525607){console[_0x1752(0x28)](_0x1888be['GmUTR'],_0x525607);}},shouldShowYouTubeMigrationWarning=async _0x4a5869=>{const _0x6225a2={'QVsNI':'❌\x20Error\x20in\x20YouTube\x20connection\x20check:','hfBlm':_0x1752(0xc1),'wGdKP':_0x1752(0xc2),'fLmph':_0x1752(0xc3),'mCoCV':'default','ezDxW':_0x1752(0xc4),'vwEDQ':function(_0x31bbfd,_0x4cb9b0){return _0x31bbfd(_0x4cb9b0);},'zpAXn':function(_0x249742,_0x46053c){return _0x249742===_0x46053c;},'QDpuC':_0x1752(0xc5),'CsWpb':function(_0x1e3967,_0x763697){return _0x1e3967===_0x763697;},'oiUyd':function(_0x5423e2,_0x2447e3){return _0x5423e2===_0x2447e3;},'bSqZC':function(_0x1591c5,_0x3e5f51){return _0x1591c5===_0x3e5f51;},'ZXcfY':function(_0x1509fa,_0x2adf4f){return _0x1509fa===_0x2adf4f;},'RKfrj':_0x1752(0x55),'KjExl':_0x1752(0x59),'wvhjc':function(_0x5db14a,_0x65a0b8){return _0x5db14a&&_0x65a0b8;},'HNdUF':_0x1752(0xc6),'LhnNB':_0x1752(0x56),'XOZMF':'ℹ️\x20[MIGRATION\x20WARNING]\x20NO\x20WARNING\x20-\x20no\x20YouTube\x20connection\x20found','CXIGx':_0x1752(0xc7),'ZNRVH':_0x1752(0xc8)};try{console[_0x1752(0x1e)](_0x6225a2[_0x1752(0xc9)],_0x4a5869);const _0x1a8230=await _0x6225a2[_0x1752(0xca)](fetch,_api[_0x1752(0xb2)][_0x1752(0xb3)]+'/youtube/validate-connection/'+_0x4a5869),_0x2400aa=await _0x1a8230[_0x1752(0x12)]();if(_0x2400aa['success']&&_0x2400aa[_0x1752(0x14)]){if(_0x6225a2[_0x1752(0xcb)](_0x6225a2[_0x1752(0xcc)],_0x6225a2[_0x1752(0xcc)])){var _0x2b344f,_0x53b9b8;const _0x32a15a=_0x6225a2[_0x1752(0xcd)](_0x6225a2[_0x1752(0xcb)](_0x2b344f=_0x2400aa['validation'],null)||_0x6225a2[_0x1752(0xcd)](_0x2b344f,void 0x0)?void 0x0:_0x2b344f[_0x1752(0x19)],!![])||(_0x6225a2[_0x1752(0xcb)](_0x53b9b8=_0x2400aa[_0x1752(0x17)],null)||_0x6225a2[_0x1752(0xce)](_0x53b9b8,void 0x0)?void 0x0:_0x53b9b8[_0x1752(0x21)])===!![]||_0x6225a2[_0x1752(0xcf)](_0x2400aa['isTemporaryMode'],!![]),_0x58d14d=_0x6225a2['bSqZC'](_0x2400aa[_0x1752(0x14)][_0x1752(0x88)],!![]),_0x59c670=_0x6225a2[_0x1752(0xd0)](_0x2400aa['validation'][_0x1752(0x1d)],!![]),_0x3aa02d=_0x6225a2[_0x1752(0xcb)](_0x2400aa[_0x1752(0x14)][_0x1752(0x1c)],!![]);console[_0x1752(0x1e)](_0x6225a2['RKfrj'],{'username':_0x4a5869,'hasAccessToken':_0x58d14d,'hasRefreshToken':_0x59c670,'needsReconnection':_0x3aa02d,'isTemporaryMode':_0x32a15a,'connectedAt':_0x2400aa['validation'][_0x1752(0x8a)]});if(_0x32a15a)return console[_0x1752(0x1e)](_0x6225a2[_0x1752(0xd1)]),![];else return _0x6225a2[_0x1752(0xd2)](_0x58d14d,!_0x59c670)&&_0x3aa02d?(console[_0x1752(0x1e)](_0x6225a2[_0x1752(0xd3)]),!![]):(console[_0x1752(0x1e)](_0x6225a2[_0x1752(0xd4)]),![]);}else return _0x481dae['error'](_0x6225a2[_0x1752(0xd5)],_0x45df1f),![];}return console[_0x1752(0x1e)](_0x6225a2[_0x1752(0xd6)]),![];}catch(_0x54d153){return _0x1752(0xd7)===_0x6225a2[_0x1752(0xd8)]?(_0x3782bc[_0x1752(0x50)][_0x1752(0x9c)](_0x6225a2[_0x1752(0xd9)],_0x6225a2[_0x1752(0xda)],[{'text':_0x6225a2[_0x1752(0xdb)],'style':_0x6225a2[_0x1752(0xdc)]}]),!![]):(console[_0x1752(0x28)](_0x6225a2['ZNRVH'],_0x54d153),![]);}};exports[_0x1752(0x0)]=shouldShowYouTubeMigrationWarning;const checkAndFixYouTubeConnection=async _0x57eeef=>{const _0x24e13a={'RfQLX':_0x1752(0x68),'UUSiN':'migration_token_placeholder','QmjAK':_0x1752(0x8),'pBTUq':_0x1752(0x9),'eoYfw':function(_0x153404,_0x26d0af){return _0x153404!==_0x26d0af;},'ZjnfA':'bUbOH','vAAlt':'🚫\x20[MIGRATION]\x20NO\x20MIGRATION\x20NEEDED\x20-\x20user\x20connection\x20is\x20working\x20correctly','ryJAA':_0x1752(0xdd),'TJXUG':function(_0x19815b,_0x272b5e){return _0x19815b(_0x272b5e);},'WbfWQ':'✅\x20[MIGRATION]\x20YouTube\x20connection\x20working\x20properly\x20-\x20no\x20migration\x20needed','PrzuU':_0x1752(0xde),'kbviG':function(_0x2e53d7){return _0x2e53d7();},'lHbWn':_0x1752(0xdf),'ktvJO':function(_0xd2c58e,_0x5b0c1e){return _0xd2c58e(_0x5b0c1e);},'hmHLt':'Your\x20YouTube\x20connection\x20has\x20been\x20upgraded\x20successfully.\x20Training\x20will\x20now\x20work\x20seamlessly\x20without\x20interruptions.','iGkCP':'Great!','kwmSI':'default','jDdqe':'QRukq','CWjMi':_0x1752(0x57),'TZHvh':'YouTube\x20connection\x20upgrade\x20failed.\x20Please\x20try\x20again\x20later\x20or\x20contact\x20support\x20if\x20the\x20problem\x20persists.','vjkmj':_0x1752(0xe0)};try{console['log'](_0x1752(0xe1),_0x57eeef);const _0x1a0ec4=await shouldShowYouTubeMigrationWarning(_0x57eeef);if(!_0x1a0ec4){if(_0x24e13a['eoYfw'](_0x24e13a[_0x1752(0xe2)],_0x24e13a[_0x1752(0xe2)]))_0xc40360[_0x1752(0xa7)](_0x24e13a[_0x1752(0xe3)]),_0x247a77=_0x24e13a[_0x1752(0xe4)];else return console[_0x1752(0x1e)](_0x24e13a[_0x1752(0xe5)]),console[_0x1752(0x1e)](_0x24e13a[_0x1752(0xe6)]),!![];}const _0x41a886=await _0x24e13a[_0x1752(0xe7)](checkYouTubeMigrationNeeded,_0x57eeef);if(!_0x41a886)return console[_0x1752(0x1e)](_0x24e13a['WbfWQ']),!![];console['log'](_0x24e13a[_0x1752(0xe8)]);const _0x37be25=await _0x24e13a[_0x1752(0xe9)](showYouTubeMigrationPrompt);if(!_0x37be25)return console[_0x1752(0x1e)](_0x24e13a['lHbWn']),![];const _0x5a2dbc=await _0x24e13a['ktvJO'](forceYouTubeReconnection,_0x57eeef);if(_0x5a2dbc)return _reactNative[_0x1752(0x50)][_0x1752(0x9c)](_0x1752(0xc1),_0x24e13a[_0x1752(0xea)],[{'text':_0x24e13a['iGkCP'],'style':_0x24e13a[_0x1752(0xeb)]}]),!![];else{if(_0x24e13a[_0x1752(0xec)]!==_0x24e13a[_0x1752(0xec)])_0x5d8c75[_0x1752(0x74)][_0x1752(0xed)]({'webClientId':_0xae6435,'iosClientId':_0x3e7bf8,'offlineAccess':!![],'forceCodeForRefreshToken':!![],'scopes':[_0x24e13a['QmjAK'],_0x24e13a[_0x1752(0xee)],_0x1752(0xa),_0x1752(0x7)],'hostedDomain':'','accountName':''});else return _reactNative['Alert'][_0x1752(0x9c)](_0x24e13a[_0x1752(0xef)],_0x24e13a[_0x1752(0xf0)],[{'text':'OK','style':_0x24e13a[_0x1752(0xeb)]}]),![];}}catch(_0xf6c630){return console[_0x1752(0x28)](_0x24e13a['vjkmj'],_0xf6c630),![];}};exports['checkAndFixYouTubeConnection']=checkAndFixYouTubeConnection;const reconnectYouTube=async _0x35887f=>{const _0x43992c={'wVTWC':'🔄\x20Manual\x20YouTube\x20reconnection\x20requested\x20for:'};return console[_0x1752(0x1e)](_0x43992c[_0x1752(0xf1)],_0x35887f),await forceYouTubeReconnection(_0x35887f);};exports['reconnectYouTube']=reconnectYouTube;
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.shouldShowYouTubeMigrationWarning = exports.reconnectYouTube = exports.getYouTubeConnectionStatus = exports.checkYouTubeMigrationNeeded = exports.checkAndFixYouTubeConnection = void 0;
|
|
7
|
+
var _googleSignin = require("@react-native-google-signin/google-signin");
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _asyncStorage = _interopRequireDefault(require("@react-native-async-storage/async-storage"));
|
|
10
|
+
var _api = require("../config/api");
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
// 🔑 CRITICAL: Using the same client ID for both web and iOS to avoid audience errors
|
|
13
|
+
const WEB_CLIENT_ID = '1030678346906-lovkuds2ouqmoc8eu5qpo98spa6edv4o.apps.googleusercontent.com';
|
|
14
|
+
const IOS_CLIENT_ID = '1030678346906-lovkuds2ouqmoc8eu5qpo98spa6edv4o.apps.googleusercontent.com';
|
|
15
|
+
|
|
16
|
+
// Configuration for Google Sign-In with refresh token support
|
|
17
|
+
const configureGoogleSignInForRefreshTokens = () => {
|
|
18
|
+
_googleSignin.GoogleSignin.configure({
|
|
19
|
+
webClientId: WEB_CLIENT_ID,
|
|
20
|
+
// ✅ CRITICAL: Web client ID for refresh tokens
|
|
21
|
+
iosClientId: IOS_CLIENT_ID,
|
|
22
|
+
// ✅ iOS client ID for native auth
|
|
23
|
+
|
|
24
|
+
// 🔑 CRITICAL: These are the missing parameters that fix the refresh token issue
|
|
25
|
+
offlineAccess: true,
|
|
26
|
+
// ← Enables refresh tokens
|
|
27
|
+
forceCodeForRefreshToken: true,
|
|
28
|
+
// ← Forces refresh token generation
|
|
29
|
+
|
|
30
|
+
// ✅ Enhanced scopes for YouTube
|
|
31
|
+
scopes: ['https://www.googleapis.com/auth/youtube.readonly', 'openid', 'profile', 'email'],
|
|
32
|
+
// 🚀 Additional settings (helps with refresh tokens)
|
|
33
|
+
hostedDomain: '',
|
|
34
|
+
accountName: ''
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// Check if user needs YouTube migration
|
|
39
|
+
const checkYouTubeMigrationNeeded = async username => {
|
|
40
|
+
try {
|
|
41
|
+
const response = await fetch(`${_api.API_CONFIG.BASE_URL}/youtube/validate-connection/${username}`);
|
|
42
|
+
const result = await response.json();
|
|
43
|
+
if (result.success && result.validation) {
|
|
44
|
+
var _result$validation, _result$temporaryMode, _result$temporaryMode2;
|
|
45
|
+
// ✅ NEW: Check if this is temporary mode (matches exact backend response fields)
|
|
46
|
+
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');
|
|
47
|
+
const needsReconnection = result.validation.needsReconnection;
|
|
48
|
+
const hasRefreshToken = result.validation.hasRefreshToken;
|
|
49
|
+
console.log('🔍 YouTube migration check:', {
|
|
50
|
+
username,
|
|
51
|
+
needsReconnection,
|
|
52
|
+
hasRefreshToken,
|
|
53
|
+
isTemporaryMode,
|
|
54
|
+
temporaryModeEnabled: (_result$temporaryMode2 = result.temporaryMode) === null || _result$temporaryMode2 === void 0 ? void 0 : _result$temporaryMode2.enabled,
|
|
55
|
+
message: result.message
|
|
56
|
+
});
|
|
57
|
+
if (isTemporaryMode) {
|
|
58
|
+
console.log('🔄 User using temporary mode - connection working correctly');
|
|
59
|
+
console.log('⚠️ No refresh capability but training can proceed');
|
|
60
|
+
return false; // Don't flag temporary mode as needing migration
|
|
61
|
+
} else if (needsReconnection) {
|
|
62
|
+
console.log('🔧 User needs YouTube migration for refresh token');
|
|
63
|
+
return true; // Only flag genuinely old connections
|
|
64
|
+
} else {
|
|
65
|
+
console.log('✅ YouTube connection fully working with refresh tokens');
|
|
66
|
+
return false; // Connection is perfect
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return false;
|
|
70
|
+
} catch (error) {
|
|
71
|
+
console.error('❌ Error checking YouTube migration status:', error);
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// ✅ NEW: Enhanced function to get detailed YouTube connection status
|
|
77
|
+
exports.checkYouTubeMigrationNeeded = checkYouTubeMigrationNeeded;
|
|
78
|
+
const getYouTubeConnectionStatus = async username => {
|
|
79
|
+
try {
|
|
80
|
+
const response = await fetch(`${_api.API_CONFIG.BASE_URL}/youtube/validate-connection/${username}`);
|
|
81
|
+
const result = await response.json();
|
|
82
|
+
console.log('📋 Complete YouTube status response:', result);
|
|
83
|
+
if (result.success && result.validation) {
|
|
84
|
+
var _result$validation2, _result$temporaryMode3;
|
|
85
|
+
// Check for temporary mode (prioritize exact backend fields)
|
|
86
|
+
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');
|
|
87
|
+
const hasRefreshToken = result.validation.hasRefreshToken === true;
|
|
88
|
+
const needsReconnection = result.validation.needsReconnection === true;
|
|
89
|
+
if (isTemporaryMode) {
|
|
90
|
+
console.log('🔄 YouTube connected in temporary mode');
|
|
91
|
+
console.log('✅ Training will work, but connection expires in ~1 hour');
|
|
92
|
+
return {
|
|
93
|
+
isReady: true,
|
|
94
|
+
mode: 'temporary',
|
|
95
|
+
needsMigration: false,
|
|
96
|
+
trainingReady: true,
|
|
97
|
+
details: result
|
|
98
|
+
};
|
|
99
|
+
} else if (hasRefreshToken) {
|
|
100
|
+
console.log('✅ YouTube connected with refresh tokens');
|
|
101
|
+
return {
|
|
102
|
+
isReady: true,
|
|
103
|
+
mode: 'full',
|
|
104
|
+
needsMigration: false,
|
|
105
|
+
trainingReady: true,
|
|
106
|
+
details: result
|
|
107
|
+
};
|
|
108
|
+
} else if (needsReconnection) {
|
|
109
|
+
console.log('⚠️ YouTube connected but needs migration');
|
|
110
|
+
return {
|
|
111
|
+
isReady: false,
|
|
112
|
+
mode: 'limited',
|
|
113
|
+
needsMigration: true,
|
|
114
|
+
trainingReady: false,
|
|
115
|
+
details: result
|
|
116
|
+
};
|
|
117
|
+
} else {
|
|
118
|
+
console.log('❓ YouTube connection status unclear');
|
|
119
|
+
return {
|
|
120
|
+
isReady: false,
|
|
121
|
+
mode: 'none',
|
|
122
|
+
needsMigration: false,
|
|
123
|
+
trainingReady: false,
|
|
124
|
+
details: result
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
console.log('❌ No YouTube connection found');
|
|
129
|
+
return {
|
|
130
|
+
isReady: false,
|
|
131
|
+
mode: 'none',
|
|
132
|
+
needsMigration: false,
|
|
133
|
+
trainingReady: false,
|
|
134
|
+
details: result
|
|
135
|
+
};
|
|
136
|
+
} catch (error) {
|
|
137
|
+
console.error('❌ Error getting YouTube connection status:', error);
|
|
138
|
+
return {
|
|
139
|
+
isReady: false,
|
|
140
|
+
mode: 'none',
|
|
141
|
+
needsMigration: false,
|
|
142
|
+
trainingReady: false,
|
|
143
|
+
details: {
|
|
144
|
+
error: error instanceof Error ? error.message : String(error)
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
// Show user-friendly migration prompt
|
|
151
|
+
exports.getYouTubeConnectionStatus = getYouTubeConnectionStatus;
|
|
152
|
+
const showYouTubeMigrationPrompt = async () => {
|
|
153
|
+
return new Promise(resolve => {
|
|
154
|
+
_reactNative.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?', [{
|
|
155
|
+
text: 'Skip for Now',
|
|
156
|
+
style: 'cancel',
|
|
157
|
+
onPress: () => resolve(false)
|
|
158
|
+
}, {
|
|
159
|
+
text: 'Upgrade Now',
|
|
160
|
+
style: 'default',
|
|
161
|
+
onPress: () => resolve(true)
|
|
162
|
+
}]);
|
|
163
|
+
});
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
// Force YouTube reconnection with consent screen
|
|
167
|
+
const forceYouTubeReconnection = async username => {
|
|
168
|
+
try {
|
|
169
|
+
var _user, _user2, _user3, _user4;
|
|
170
|
+
console.log('🔄 Starting YouTube migration for user:', username);
|
|
171
|
+
|
|
172
|
+
// 1. Configure for refresh tokens
|
|
173
|
+
configureGoogleSignInForRefreshTokens();
|
|
174
|
+
|
|
175
|
+
// 2. Complete sign out to clear cached consent
|
|
176
|
+
await _googleSignin.GoogleSignin.signOut();
|
|
177
|
+
console.log('✅ Signed out - consent cache cleared');
|
|
178
|
+
|
|
179
|
+
// 3. Clear cached tokens if available
|
|
180
|
+
try {
|
|
181
|
+
const existingTokens = await _googleSignin.GoogleSignin.getTokens();
|
|
182
|
+
if (existingTokens.accessToken) {
|
|
183
|
+
await _googleSignin.GoogleSignin.clearCachedAccessToken(existingTokens.accessToken);
|
|
184
|
+
console.log('✅ Token cache cleared');
|
|
185
|
+
}
|
|
186
|
+
} catch (clearError) {
|
|
187
|
+
console.log('ℹ️ No token cache to clear');
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// 4. Check Google Play Services
|
|
191
|
+
await _googleSignin.GoogleSignin.hasPlayServices();
|
|
192
|
+
|
|
193
|
+
// 5. Sign in (this will show consent screen)
|
|
194
|
+
console.log('🔐 Initiating sign-in - consent screen should appear...');
|
|
195
|
+
const userInfo = await _googleSignin.GoogleSignin.signIn();
|
|
196
|
+
|
|
197
|
+
// 6. Get tokens after consent
|
|
198
|
+
const tokens = await _googleSignin.GoogleSignin.getTokens();
|
|
199
|
+
const currentUser = await _googleSignin.GoogleSignin.getCurrentUser();
|
|
200
|
+
|
|
201
|
+
// 7. Analyze tokens thoroughly (serverAuthCode is the refresh token mechanism in React Native)
|
|
202
|
+
let finalRefreshToken = null;
|
|
203
|
+
let refreshTokenSource = 'None';
|
|
204
|
+
|
|
205
|
+
// Check for server auth code from sign-in response (primary method)
|
|
206
|
+
if (userInfo.serverAuthCode) {
|
|
207
|
+
finalRefreshToken = userInfo.serverAuthCode;
|
|
208
|
+
refreshTokenSource = 'Server auth code from sign-in';
|
|
209
|
+
}
|
|
210
|
+
// Check current user server auth code (backup method)
|
|
211
|
+
else if (currentUser !== null && currentUser !== void 0 && currentUser.serverAuthCode) {
|
|
212
|
+
finalRefreshToken = currentUser.serverAuthCode;
|
|
213
|
+
refreshTokenSource = 'Current user server auth code';
|
|
214
|
+
}
|
|
215
|
+
console.log('🔍 Token Analysis:', {
|
|
216
|
+
hasAccessToken: !!tokens.accessToken,
|
|
217
|
+
hasIdToken: !!tokens.idToken,
|
|
218
|
+
hasServerAuthCode: !!userInfo.serverAuthCode,
|
|
219
|
+
hasCurrentUserAuthCode: !!(currentUser !== null && currentUser !== void 0 && currentUser.serverAuthCode),
|
|
220
|
+
refreshTokenSource: refreshTokenSource,
|
|
221
|
+
finalRefreshToken: finalRefreshToken ? 'Available' : 'MISSING!',
|
|
222
|
+
userEmail: (_user = userInfo.user) === null || _user === void 0 ? void 0 : _user.email
|
|
223
|
+
});
|
|
224
|
+
if (!finalRefreshToken) {
|
|
225
|
+
console.error('❌ No refresh token received - Google Console configuration may be incorrect');
|
|
226
|
+
console.error('💡 This usually means:');
|
|
227
|
+
console.error(' 1. offlineAccess: true is missing from configuration');
|
|
228
|
+
console.error(' 2. forceCodeForRefreshToken: true is missing');
|
|
229
|
+
console.error(' 3. User did not grant offline access permission');
|
|
230
|
+
return false;
|
|
231
|
+
}
|
|
232
|
+
console.log('✅ Got refresh token after consent:', finalRefreshToken.substring(0, 20) + '...');
|
|
233
|
+
console.log('🔑 Refresh token source:', refreshTokenSource);
|
|
234
|
+
|
|
235
|
+
// 8. Get existing authentication token
|
|
236
|
+
let authToken = (await _asyncStorage.default.getItem('onairos_jwt_token')) || (await _asyncStorage.default.getItem('enoch_token')) || (await _asyncStorage.default.getItem('auth_token'));
|
|
237
|
+
if (!authToken) {
|
|
238
|
+
console.warn('⚠️ No authentication token found for YouTube migration');
|
|
239
|
+
authToken = 'migration_token_placeholder';
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// 9. Send enhanced payload to backend
|
|
243
|
+
const backendPayload = {
|
|
244
|
+
session: {
|
|
245
|
+
username: username,
|
|
246
|
+
platform: 'youtube',
|
|
247
|
+
channelName: ((_user2 = userInfo.user) === null || _user2 === void 0 ? void 0 : _user2.name) || 'YouTube Channel',
|
|
248
|
+
channelId: null
|
|
249
|
+
},
|
|
250
|
+
googleUser: userInfo.user,
|
|
251
|
+
accessToken: tokens.accessToken,
|
|
252
|
+
idToken: tokens.idToken,
|
|
253
|
+
refreshToken: finalRefreshToken,
|
|
254
|
+
serverAuthCode: userInfo.serverAuthCode,
|
|
255
|
+
userAccountInfo: {
|
|
256
|
+
username: username,
|
|
257
|
+
email: (_user3 = userInfo.user) === null || _user3 === void 0 ? void 0 : _user3.email,
|
|
258
|
+
authToken: authToken,
|
|
259
|
+
channelName: ((_user4 = userInfo.user) === null || _user4 === void 0 ? void 0 : _user4.name) || 'YouTube Channel',
|
|
260
|
+
channelId: null
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
console.log('📤 Sending migration payload to backend...');
|
|
264
|
+
|
|
265
|
+
// 10. Send to backend
|
|
266
|
+
const response = await fetch(`${_api.API_CONFIG.BASE_URL}/youtube/native-auth`, {
|
|
267
|
+
method: 'POST',
|
|
268
|
+
headers: {
|
|
269
|
+
'Content-Type': 'application/json',
|
|
270
|
+
'x-api-key': 'your-api-key',
|
|
271
|
+
// Use your existing API key if needed
|
|
272
|
+
...(authToken !== 'migration_token_placeholder' && {
|
|
273
|
+
'Authorization': `Bearer ${authToken}`
|
|
274
|
+
})
|
|
275
|
+
},
|
|
276
|
+
body: JSON.stringify(backendPayload)
|
|
277
|
+
});
|
|
278
|
+
const result = await response.json();
|
|
279
|
+
if (result.success) {
|
|
280
|
+
console.log('✅ YouTube migration successful');
|
|
281
|
+
|
|
282
|
+
// Track migration success
|
|
283
|
+
await trackMigrationAttempt(username, true);
|
|
284
|
+
return true;
|
|
285
|
+
} else {
|
|
286
|
+
console.error('❌ Backend rejected YouTube migration:', result.error);
|
|
287
|
+
await trackMigrationAttempt(username, false, result.error);
|
|
288
|
+
return false;
|
|
289
|
+
}
|
|
290
|
+
} catch (error) {
|
|
291
|
+
console.error('❌ YouTube migration failed:', error);
|
|
292
|
+
await trackMigrationAttempt(username, false, error instanceof Error ? error.message : 'Unknown error');
|
|
293
|
+
return false;
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
// Track migration attempts for monitoring
|
|
298
|
+
const trackMigrationAttempt = async (username, success, error) => {
|
|
299
|
+
try {
|
|
300
|
+
await fetch(`${_api.API_CONFIG.BASE_URL}/youtube/migration-status`, {
|
|
301
|
+
method: 'POST',
|
|
302
|
+
headers: {
|
|
303
|
+
'Content-Type': 'application/json'
|
|
304
|
+
},
|
|
305
|
+
body: JSON.stringify({
|
|
306
|
+
username,
|
|
307
|
+
success,
|
|
308
|
+
error: error || null,
|
|
309
|
+
timestamp: new Date().toISOString()
|
|
310
|
+
})
|
|
311
|
+
});
|
|
312
|
+
} catch (trackError) {
|
|
313
|
+
console.error('❌ Failed to track migration attempt:', trackError);
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
// ✅ NEW: Explicit function to check if user should see migration warnings
|
|
318
|
+
const shouldShowYouTubeMigrationWarning = async username => {
|
|
319
|
+
try {
|
|
320
|
+
console.log('🔍 [MIGRATION WARNING] Checking if user should see migration warning:', username);
|
|
321
|
+
const response = await fetch(`${_api.API_CONFIG.BASE_URL}/youtube/validate-connection/${username}`);
|
|
322
|
+
const result = await response.json();
|
|
323
|
+
if (result.success && result.validation) {
|
|
324
|
+
var _result$validation3, _result$temporaryMode4;
|
|
325
|
+
// Check for temporary mode (prioritize exact backend fields)
|
|
326
|
+
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;
|
|
327
|
+
const hasAccessToken = result.validation.hasAccessToken === true;
|
|
328
|
+
const hasRefreshToken = result.validation.hasRefreshToken === true;
|
|
329
|
+
const needsReconnection = result.validation.needsReconnection === true;
|
|
330
|
+
console.log('📊 [MIGRATION WARNING] Status check:', {
|
|
331
|
+
username,
|
|
332
|
+
hasAccessToken,
|
|
333
|
+
hasRefreshToken,
|
|
334
|
+
needsReconnection,
|
|
335
|
+
isTemporaryMode,
|
|
336
|
+
connectedAt: result.validation.connectedAt
|
|
337
|
+
});
|
|
338
|
+
if (isTemporaryMode) {
|
|
339
|
+
console.log('🚫 [MIGRATION WARNING] NO WARNING - user is in temporary mode (working correctly)');
|
|
340
|
+
return false; // Don't show migration warning
|
|
341
|
+
} else if (hasAccessToken && !hasRefreshToken && needsReconnection) {
|
|
342
|
+
console.log('⚠️ [MIGRATION WARNING] SHOW WARNING - genuinely old connection needs update');
|
|
343
|
+
return true; // Show migration warning for genuinely broken connections
|
|
344
|
+
} else {
|
|
345
|
+
console.log('✅ [MIGRATION WARNING] NO WARNING - connection is working properly');
|
|
346
|
+
return false; // Don't show warning for working connections
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
console.log('ℹ️ [MIGRATION WARNING] NO WARNING - no YouTube connection found');
|
|
350
|
+
return false; // Don't show warning if no connection
|
|
351
|
+
} catch (error) {
|
|
352
|
+
console.error('❌ [MIGRATION WARNING] Error checking migration warning status:', error);
|
|
353
|
+
return false; // Don't show warning on error
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
// Main function to check and fix YouTube connection
|
|
358
|
+
exports.shouldShowYouTubeMigrationWarning = shouldShowYouTubeMigrationWarning;
|
|
359
|
+
const checkAndFixYouTubeConnection = async username => {
|
|
360
|
+
try {
|
|
361
|
+
console.log('🔄 Checking YouTube connection for user:', username);
|
|
362
|
+
|
|
363
|
+
// 1. First check if user should see migration warning at all
|
|
364
|
+
const shouldShowWarning = await shouldShowYouTubeMigrationWarning(username);
|
|
365
|
+
if (!shouldShowWarning) {
|
|
366
|
+
console.log('🚫 [MIGRATION] NO MIGRATION NEEDED - user connection is working correctly');
|
|
367
|
+
console.log('✅ [MIGRATION] User can proceed with training normally');
|
|
368
|
+
return true; // Return success - no migration needed
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
// 2. Double-check migration is actually needed (for safety)
|
|
372
|
+
const needsMigration = await checkYouTubeMigrationNeeded(username);
|
|
373
|
+
if (!needsMigration) {
|
|
374
|
+
console.log('✅ [MIGRATION] YouTube connection working properly - no migration needed');
|
|
375
|
+
return true;
|
|
376
|
+
}
|
|
377
|
+
console.log('🔧 [MIGRATION] User needs YouTube migration for refresh token (genuinely old connection)');
|
|
378
|
+
|
|
379
|
+
// 2. Show user-friendly prompt
|
|
380
|
+
const userConfirmed = await showYouTubeMigrationPrompt();
|
|
381
|
+
if (!userConfirmed) {
|
|
382
|
+
console.log('ℹ️ User declined YouTube migration');
|
|
383
|
+
return false;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
// 3. Attempt migration
|
|
387
|
+
const migrationSuccess = await forceYouTubeReconnection(username);
|
|
388
|
+
if (migrationSuccess) {
|
|
389
|
+
// Show success message
|
|
390
|
+
_reactNative.Alert.alert('YouTube Upgraded! ✅', 'Your YouTube connection has been upgraded successfully. Training will now work seamlessly without interruptions.', [{
|
|
391
|
+
text: 'Great!',
|
|
392
|
+
style: 'default'
|
|
393
|
+
}]);
|
|
394
|
+
return true;
|
|
395
|
+
} else {
|
|
396
|
+
// Show failure message
|
|
397
|
+
_reactNative.Alert.alert('Upgrade Failed ❌', 'YouTube connection upgrade failed. Please try again later or contact support if the problem persists.', [{
|
|
398
|
+
text: 'OK',
|
|
399
|
+
style: 'default'
|
|
400
|
+
}]);
|
|
401
|
+
return false;
|
|
402
|
+
}
|
|
403
|
+
} catch (error) {
|
|
404
|
+
console.error('❌ Error in YouTube connection check:', error);
|
|
405
|
+
return false;
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
|
|
409
|
+
// Optional: Reconnect function for manual use
|
|
410
|
+
exports.checkAndFixYouTubeConnection = checkAndFixYouTubeConnection;
|
|
411
|
+
const reconnectYouTube = async username => {
|
|
412
|
+
console.log('🔄 Manual YouTube reconnection requested for:', username);
|
|
413
|
+
return await forceYouTubeReconnection(username);
|
|
414
|
+
};
|
|
415
|
+
exports.reconnectYouTube = reconnectYouTube;
|
|
416
|
+
//# sourceMappingURL=youtubeMigrationService.js.map
|