@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,383 @@
|
|
|
1
|
-
import AsyncStorage from'@react-native-async-storage/async-storage';import{clearStoredPin}from'./pinStorageUtils';export const STORAGE_KEYS={'AUTH_TOKEN':'auth_token','ONAIROS_JWT_TOKEN':_0x4cca(0x0),'ENOCH_TOKEN':_0x4cca(0x1),'USER':'user','USER_PROFILE':_0x4cca(0x2),'USER_PROFILE_FALLBACK':_0x4cca(0x3),'USER_PROGRESS':_0x4cca(0x4),'ONBOARDING_COMPLETED':'onboardingCompleted','IS_FIRST_TIME_USER':_0x4cca(0x5),'USER_ATTENDANCE_CONFIRMED':_0x4cca(0x6),'ONBOARDING_COMPLETE_TOKEN':_0x4cca(0x7),'EVENT_ACCESS_TOKEN':_0x4cca(0x8),'ONAIROS_USER':_0x4cca(0x9),'APPLE_USER':_0x4cca(0xa),'AUTH_METHOD':'auth_method','CURRENT_EVENT_DATA':_0x4cca(0xb),'CONNECTED_PLATFORMS':'connectedPlatforms','PROFILE_IMAGE':'profileImage','USER_ADMIN_STATUS':_0x4cca(0xc)};export const saveUserProgress=async _0x53ff22=>{const _0x5e503d={'SQYQI':'❌\x20Error\x20getting\x20debug\x20storage\x20info:','jaJTI':_0x4cca(0xd),'fCvRR':_0x4cca(0xe),'mgHXy':function(_0x41ff4a){return _0x41ff4a();},'cLMtA':_0x4cca(0xf),'gKzaB':function(_0x20ea2f,_0x2c85b5){return _0x20ea2f===_0x2c85b5;},'kBVUB':_0x4cca(0x10),'QZgvw':_0x4cca(0x11)};try{if(_0x5e503d[_0x4cca(0x12)]===_0x4cca(0xe)){const _0x17c0f0=await _0x5e503d[_0x4cca(0x13)](getUserProgress),_0x454c46={..._0x17c0f0,..._0x53ff22,'timestamp':Date[_0x4cca(0x14)]()};await AsyncStorage[_0x4cca(0x15)](STORAGE_KEYS[_0x4cca(0x16)],JSON['stringify'](_0x454c46)),console[_0x4cca(0x17)](_0x5e503d[_0x4cca(0x18)],_0x454c46);}else{_0x4dbe42[_0x4cca(0x19)](_0x5e503d[_0x4cca(0x1a)],_0x5c353d);throw _0x4445e3;}}catch(_0x3e8a21){if(_0x5e503d[_0x4cca(0x1b)](_0x4cca(0x10),_0x5e503d[_0x4cca(0x1c)]))console[_0x4cca(0x19)](_0x5e503d[_0x4cca(0x1d)],_0x3e8a21);else return{'screen':_0x5e503d['jaJTI'],'params':{'isNewUser':!![],'activateCamera':!![]}};}};export const getUserProgress=async()=>{const _0x31a60d={'MNmwc':_0x4cca(0x1e),'RpNOJ':function(_0x25fbb3,_0x124013){return _0x25fbb3===_0x124013;},'gJlJG':_0x4cca(0x1f),'ncBJA':'❌\x20Error\x20getting\x20user\x20progress:','vJOXK':'Welcome'};try{const _0x30e728=await AsyncStorage[_0x4cca(0x20)](STORAGE_KEYS['USER_PROGRESS']);if(_0x30e728)return JSON['parse'](_0x30e728);}catch(_0x23b372){if(_0x31a60d[_0x4cca(0x21)](_0x31a60d['gJlJG'],_0x31a60d['gJlJG']))console['error'](_0x31a60d['ncBJA'],_0x23b372);else return _0x501383[_0x4cca(0x19)](_0x31a60d['MNmwc'],_0x3fa376),![];}return{'lastScreen':_0x31a60d[_0x4cca(0x22)],'completedSteps':[],'authMethod':null,'hasProfilePhoto':![],'hasCompletedProfile':![],'hasSelectedIntentions':![],'hasViewedResults':![],'hasEnteredEventCode':![],'hasRegisteredForEvent':![],'hasReachedEventPage':![],'timestamp':Date[_0x4cca(0x14)]()};};export const saveAuthState=async _0x490298=>{const _0x2514b4={'FsYYB':_0x4cca(0x23),'VGmfv':function(_0x1437d4,_0x2899d0){return _0x1437d4!==_0x2899d0;},'BxKmp':_0x4cca(0x24),'JxwaR':_0x4cca(0x25),'xfEss':_0x4cca(0x26)};try{const _0x464b85=await getAuthState(),_0x555725={..._0x464b85,..._0x490298};_0x490298[_0x4cca(0x27)]&&(_0x2514b4[_0x4cca(0x28)](_0x2514b4[_0x4cca(0x29)],_0x2514b4[_0x4cca(0x29)])?_0x2a65d0[_0x4cca(0x2a)](_0x2514b4[_0x4cca(0x2b)],_0x390158):await AsyncStorage['setItem'](STORAGE_KEYS[_0x4cca(0x2c)],_0x490298[_0x4cca(0x27)])),console['log'](_0x2514b4[_0x4cca(0x2d)],_0x555725);}catch(_0x8b6bb5){console['error'](_0x2514b4[_0x4cca(0x2e)],_0x8b6bb5);}};function _0x4cca(_0x342816,_0x4ccacc){_0x342816=_0x342816-0x0;const _0x3d0ea1=_0x3428();let _0x3731a0=_0x3d0ea1[_0x342816];return _0x3731a0;}export const getAuthState=async()=>{const _0x565c47={'tJMBr':_0x4cca(0x2f)};try{const _0x468a26=await AsyncStorage[_0x4cca(0x20)](STORAGE_KEYS[_0x4cca(0x2c)]),_0x2be9f2=!!await AsyncStorage[_0x4cca(0x20)](STORAGE_KEYS['AUTH_TOKEN']);return{'isAuthenticated':_0x2be9f2,'authMethod':_0x468a26,'hasValidToken':_0x2be9f2};}catch(_0x9cf790){return console[_0x4cca(0x19)](_0x565c47[_0x4cca(0x30)],_0x9cf790),{'isAuthenticated':![],'authMethod':null,'hasValidToken':![]};}};function _0x3428(){const _0x40f880=['onairos_jwt_token','enoch_token','userProfile','userProfileFallback','user_progress','isFirstTimeUser','userAttendanceConfirmed','onboarding_complete_token','event_access_token','onairos_user','apple_user','currentEventData','user_admin_status','Welcome','Epbbb','✅\x20User\x20progress\x20saved:','IWSRr','❌\x20Error\x20saving\x20user\x20progress:','fCvRR','mgHXy','now','setItem','USER_PROGRESS','log','cLMtA','error','SQYQI','gKzaB','kBVUB','QZgvw','❌\x20Error\x20checking\x20event\x20access\x20token:','zzBxc','getItem','RpNOJ','vJOXK','⚠️\x20Error\x20clearing\x20stored\x20PIN\x20(continuing):','QvkJc','✅\x20Auth\x20state\x20saved:','❌\x20Error\x20saving\x20auth\x20state:','authMethod','VGmfv','BxKmp','warn','FsYYB','AUTH_METHOD','JxwaR','xfEss','❌\x20Error\x20getting\x20auth\x20state:','tJMBr','❌\x20Error\x20marking\x20app\x20as\x20active:','zvJpe','✅\x20Biometrically\x20stored\x20PIN\x20cleared','VMtgV','USER','USER_PROFILE','USER_PROFILE_FALLBACK','AUTH_TOKEN','ONAIROS_JWT_TOKEN','ONAIROS_USER','APPLE_USER','IS_FIRST_TIME_USER','USER_ATTENDANCE_CONFIRMED','PROFILE_IMAGE','ONBOARDING_COMPLETED','IAXqh','kqnOU','RkqRR','uJWhP','ASPSe','nrrOm','parse','❌\x20Error\x20clearing\x20user\x20data:','Home','❌\x20Error\x20checking\x20returning\x20user\x20status:','lPJcS','IoCIY','nQZvW','fqAVt','qDsQN','CreateFreshProfile','Intention','Results','❌\x20Error\x20determining\x20resume\x20target:','SgNXL','zkTHk','EWbat','hasReachedEventPage','avfQv','NBhma','xpBKD','isAuthenticated','rKsRY','ZVDvD','UItgl','completedSteps','length','omOvW','IBlcZ','iEECD','hasProfilePhoto','bHMMN','❌\x20Error\x20updating\x20last\x20screen:','ZFBrn','onairos','hasSelectedIntentions','oCycW','fuuAh','wrOmU','❌\x20Error\x20checking\x20onboarding\x20status:','hasCompletedProfile','yUHyx','true','✅\x20User\x20marked\x20as\x20having\x20reached\x20event\x20page\x20-\x20will\x20always\x20return\x20to\x20Results','QNMeM','nBAzX','❌\x20Error\x20marking\x20event\x20page\x20reached:','anBSj','SNiXe','eventData','xVvcd','VdzAT','EVENT_ACCESS_TOKEN','JkRMF','KzdPH','VERWH','fryDl','zcSMt','xCqxi','ytPwN','PZcUi','hNNOX','ONBOARDING_COMPLETE_TOKEN','HqfZx','ALdWc','TSXtI','JmDih','bJGqw','AprpY','includes','gaecL','RuXTV','push','XeEMt','❌\x20Error\x20marking\x20step\x20completed:','TJoXm','dReTG','noajL','WqodB','OPSwF','VpRkC','InUcs','lVFYH','❌\x20Error\x20getting\x20user\x20progress:','QuFSl','ooEQu','GRXqM','✅\x20App\x20marked\x20as\x20active','DTINc','xshuL','NKsWS','xRyEp','GGzRQ','CgolE','mXtGs','❌\x20Error\x20getting\x20debug\x20storage\x20info:','gdPoq','dsFSb','kRrNu','ygzBZ','✅\x20All\x20progress\x20data\x20cleared','xXibb','DnjQL','❌\x20Error\x20clearing\x20progress\x20data:'];_0x3428=function(){return _0x40f880;};return _0x3428();}export const clearUserData=async()=>{const _0x313925={'oouNa':_0x4cca(0x31),'IAXqh':function(_0x255a3d,_0x5b9751){return _0x255a3d===_0x5b9751;},'kqnOU':_0x4cca(0x32),'RkqRR':function(_0x27960c){return _0x27960c();},'uJWhP':_0x4cca(0x33),'ASPSe':'⚠️\x20Error\x20clearing\x20stored\x20PIN\x20(continuing):','nrrOm':_0x4cca(0x34)};try{const _0x8008f0=[STORAGE_KEYS[_0x4cca(0x35)],STORAGE_KEYS[_0x4cca(0x36)],STORAGE_KEYS[_0x4cca(0x37)],STORAGE_KEYS['USER_PROGRESS'],STORAGE_KEYS[_0x4cca(0x38)],STORAGE_KEYS[_0x4cca(0x39)],STORAGE_KEYS['ENOCH_TOKEN'],STORAGE_KEYS[_0x4cca(0x3a)],STORAGE_KEYS[_0x4cca(0x3b)],STORAGE_KEYS[_0x4cca(0x2c)],STORAGE_KEYS[_0x4cca(0x3c)],STORAGE_KEYS[_0x4cca(0x3d)],STORAGE_KEYS[_0x4cca(0x3e)],STORAGE_KEYS[_0x4cca(0x3f)],STORAGE_KEYS['ONBOARDING_COMPLETE_TOKEN'],STORAGE_KEYS['EVENT_ACCESS_TOKEN']];await AsyncStorage['multiRemove'](_0x8008f0);try{_0x313925[_0x4cca(0x40)](_0x313925[_0x4cca(0x41)],_0x4cca(0x32))?(await _0x313925[_0x4cca(0x42)](clearStoredPin),console[_0x4cca(0x17)](_0x313925[_0x4cca(0x43)])):_0x1d4bdb[_0x4cca(0x19)](_0x313925['oouNa'],_0x55a644);}catch(_0x128de4){console['warn'](_0x313925[_0x4cca(0x44)],_0x128de4);}console[_0x4cca(0x17)]('✅\x20User\x20data\x20cleared\x20including\x20onboarding\x20completion\x20tokens');}catch(_0x191246){if(_0x313925[_0x4cca(0x45)]!==_0x4cca(0x34))return _0x5f4815[_0x4cca(0x46)](_0x39823f);else console[_0x4cca(0x19)](_0x4cca(0x47),_0x191246);}};export const getResumeTarget=async()=>{const _0x41cf6a={'NBhma':_0x4cca(0x11),'xpBKD':'🎯\x20User\x20has\x20completed\x20onboarding\x20(verified\x20by\x20token)\x20-\x20returning\x20to\x20Home\x20screen','UItgl':_0x4cca(0x48),'IBlcZ':_0x4cca(0x49),'zRVBa':_0x4cca(0x47),'SgNXL':function(_0x414fde,_0x26da19){return _0x414fde!==_0x26da19;},'zkTHk':_0x4cca(0x4a),'EWbat':_0x4cca(0x4b),'Vasum':function(_0x465a7d){return _0x465a7d();},'itLyw':function(_0x56c451,_0x38e769){return _0x56c451===_0x38e769;},'yyGxu':_0x4cca(0x4c),'avfQv':_0x4cca(0x4d),'rKsRY':function(_0x161463,_0x292b9b){return _0x161463===_0x292b9b;},'ZVDvD':'fDUdg','gXxSO':_0x4cca(0x4e),'iEECD':_0x4cca(0xd),'SreEE':'PnFSA','FMxWt':_0x4cca(0x4f),'ZFBrn':function(_0x385552,_0x11544c){return _0x385552===_0x11544c;},'oCycW':_0x4cca(0x50),'fuuAh':_0x4cca(0x51),'wrOmU':_0x4cca(0x52)};try{if(_0x41cf6a[_0x4cca(0x53)](_0x41cf6a[_0x4cca(0x54)],_0x41cf6a[_0x4cca(0x55)])){const _0x5a5e37=await _0x41cf6a['Vasum'](getUserProgress),_0x15a761=await getAuthState(),_0x47906c=await hasEventAccessToken();if(_0x47906c||_0x5a5e37[_0x4cca(0x56)]&&_0x5a5e37['hasViewedResults']){if(_0x41cf6a['itLyw'](_0x41cf6a['yyGxu'],_0x41cf6a[_0x4cca(0x57)]))_0x4ef200[_0x4cca(0x19)](_0x41cf6a[_0x4cca(0x58)],_0x83013d);else return console[_0x4cca(0x17)](_0x41cf6a[_0x4cca(0x59)]),{'screen':_0x4cca(0x48)};}if(!_0x15a761[_0x4cca(0x5a)])return _0x41cf6a[_0x4cca(0x5b)](_0x41cf6a['ZVDvD'],_0x41cf6a[_0x4cca(0x5c)])?{'screen':_0x4cca(0xd)}:(_0x86d1de[_0x4cca(0x17)](_0x41cf6a['xpBKD']),{'screen':_0x41cf6a[_0x4cca(0x5d)]});if(_0x5a5e37[_0x4cca(0x5e)][_0x4cca(0x5f)]===0x0)return _0x41cf6a['rKsRY'](_0x41cf6a['gXxSO'],_0x4cca(0x60))?(_0x495082['error'](_0x41cf6a[_0x4cca(0x61)],_0x3ce45f),![]):{'screen':_0x41cf6a[_0x4cca(0x62)],'params':{'isNewUser':!![],'activateCamera':!![]}};if(!_0x5a5e37[_0x4cca(0x63)]){if(_0x4cca(0x64)!==_0x41cf6a['SreEE'])return{'screen':_0x41cf6a[_0x4cca(0x62)],'params':{'isNewUser':!![],'activateCamera':!![]}};else _0x2f7d73['error'](_0x4cca(0x65),_0x4c0647);}if(!_0x5a5e37['hasCompletedProfile']){const _0x27fdd8=await AsyncStorage[_0x4cca(0x20)](STORAGE_KEYS[_0x4cca(0x3e)]);return{'screen':_0x41cf6a['FMxWt'],'params':{'photo':_0x27fdd8,'isReviewerBypass':_0x41cf6a[_0x4cca(0x66)](_0x15a761['authMethod'],_0x4cca(0x67))}};}if(!_0x5a5e37[_0x4cca(0x68)]){const _0x102351=await AsyncStorage[_0x4cca(0x20)](STORAGE_KEYS[_0x4cca(0x36)]);return{'screen':_0x41cf6a[_0x4cca(0x69)],'params':{'userProfile':_0x102351?JSON[_0x4cca(0x46)](_0x102351):null}};}const _0x2ce20c=await AsyncStorage[_0x4cca(0x20)](STORAGE_KEYS['USER_PROFILE']);return{'screen':_0x41cf6a[_0x4cca(0x6a)],'params':{'userProfile':_0x2ce20c?JSON[_0x4cca(0x46)](_0x2ce20c):null}};}else _0x2d49a2[_0x4cca(0x19)](_0x41cf6a['zRVBa'],_0x3538ab);}catch(_0x26253c){return console[_0x4cca(0x19)](_0x41cf6a[_0x4cca(0x6b)],_0x26253c),{'screen':_0x41cf6a[_0x4cca(0x62)]};}};export const hasCompletedOnboarding=async()=>{const _0x3ad058={'OppNc':function(_0x2adbca){return _0x2adbca();},'QXDyw':_0x4cca(0x6c)};try{const _0x3c2e01=await _0x3ad058['OppNc'](getUserProgress);return _0x3c2e01[_0x4cca(0x6d)]&&_0x3c2e01['hasViewedResults'];}catch(_0x3d4175){return console[_0x4cca(0x19)](_0x3ad058['QXDyw'],_0x3d4175),![];}};export const markEventPageReached=async _0x1cf000=>{const _0x3a2f32={'KzdPH':_0x4cca(0x52),'VERWH':_0x4cca(0xd),'ytPwN':'❌\x20Error\x20marking\x20step\x20completed:','anBSj':function(_0x48f193,_0x5b8e9d){return _0x48f193===_0x5b8e9d;},'SNiXe':_0x4cca(0x6e),'xVvcd':function(_0x2c37ac,_0x8ad31){return _0x2c37ac(_0x8ad31);},'VdzAT':_0x4cca(0x6f),'JkRMF':_0x4cca(0x70),'fryDl':function(_0x3f9f2b,_0x45047f){return _0x3f9f2b!==_0x45047f;},'zcSMt':_0x4cca(0x71),'ojefg':_0x4cca(0x72),'xCqxi':_0x4cca(0x73)};try{if(_0x3a2f32[_0x4cca(0x74)](_0x4cca(0x6e),_0x3a2f32[_0x4cca(0x75)])){const _0x1790a3=await getUserProgress(),_0x958ba7={..._0x1790a3,'hasReachedEventPage':!![],'hasViewedResults':!![],'eventData':_0x1cf000||_0x1790a3[_0x4cca(0x76)],'timestamp':Date[_0x4cca(0x14)]()};await _0x3a2f32[_0x4cca(0x77)](saveUserProgress,_0x958ba7),await AsyncStorage['setItem'](STORAGE_KEYS['ONBOARDING_COMPLETE_TOKEN'],_0x3a2f32[_0x4cca(0x78)]),await AsyncStorage[_0x4cca(0x15)](STORAGE_KEYS[_0x4cca(0x79)],JSON['stringify']({'timestamp':Date[_0x4cca(0x14)](),'eventData':_0x1cf000,'hasAccess':!![]})),console[_0x4cca(0x17)](_0x3a2f32[_0x4cca(0x7a)]);}else return _0x2a2715[_0x4cca(0x19)](_0x3a2f32[_0x4cca(0x7b)],_0x25f26b),{'screen':_0x3a2f32[_0x4cca(0x7c)]};}catch(_0x520778){_0x3a2f32[_0x4cca(0x7d)](_0x3a2f32[_0x4cca(0x7e)],_0x3a2f32['ojefg'])?console[_0x4cca(0x19)](_0x3a2f32[_0x4cca(0x7f)],_0x520778):_0xe393c5[_0x4cca(0x19)](_0x3a2f32[_0x4cca(0x80)],_0xd5d0c4);}};export const hasEventAccessToken=async()=>{const _0x46b6cd={'JmDih':_0x4cca(0x73),'HqfZx':function(_0x12680b,_0x5ac1f6){return _0x12680b===_0x5ac1f6;},'ALdWc':_0x4cca(0x81),'TSXtI':_0x4cca(0x82)};try{const _0x68b77f=await AsyncStorage['getItem'](STORAGE_KEYS[_0x4cca(0x83)]),_0x1af3da=await getUserProgress();return _0x68b77f===_0x4cca(0x6f)&&_0x1af3da[_0x4cca(0x56)];}catch(_0x386b03){if(_0x46b6cd[_0x4cca(0x84)](_0x46b6cd[_0x4cca(0x85)],_0x46b6cd[_0x4cca(0x86)]))_0x1db05f[_0x4cca(0x19)](_0x46b6cd[_0x4cca(0x87)],_0x5431ae);else return console[_0x4cca(0x19)](_0x4cca(0x1e),_0x386b03),![];}};export const markStepCompleted=async _0x2ae42a=>{const _0x3673d2={'AprpY':function(_0xd2e68a){return _0xd2e68a();},'gaecL':function(_0xea6672,_0xf789e2){return _0xea6672===_0xf789e2;},'RuXTV':_0x4cca(0x88),'XeEMt':function(_0xedfb6f,_0x433498){return _0xedfb6f(_0x433498);}};try{const _0x45659f=await _0x3673d2[_0x4cca(0x89)](getUserProgress);!_0x45659f[_0x4cca(0x5e)][_0x4cca(0x8a)](_0x2ae42a)&&(_0x3673d2[_0x4cca(0x8b)](_0x4cca(0x88),_0x3673d2[_0x4cca(0x8c)])?(_0x45659f[_0x4cca(0x5e)][_0x4cca(0x8d)](_0x2ae42a),await _0x3673d2[_0x4cca(0x8e)](saveUserProgress,_0x45659f)):_0x276874[_0x4cca(0x19)]('❌\x20Error\x20clearing\x20progress\x20data:',_0x505b8c));}catch(_0x3b4a74){console[_0x4cca(0x19)](_0x4cca(0x8f),_0x3b4a74);}};export const updateLastScreen=async(_0x2ffb5d,_0x1dd226)=>{const _0xe9ccd1={'TJoXm':function(_0x179bce,_0x3b08a1){return _0x179bce===_0x3b08a1;},'xqvjy':function(_0x397f51,_0x13834f){return _0x397f51(_0x13834f);},'noajL':_0x4cca(0x65)};try{if(_0xe9ccd1[_0x4cca(0x90)](_0x4cca(0x91),'TsTdq'))return{'screen':_0x4cca(0xd)};else await _0xe9ccd1['xqvjy'](saveUserProgress,{'lastScreen':_0x2ffb5d,'timestamp':Date[_0x4cca(0x14)]()});}catch(_0x2726fe){console['error'](_0xe9ccd1[_0x4cca(0x92)],_0x2726fe);}};export const isReturningUser=async()=>{const _0x18606a={'ooEQu':_0x4cca(0xd),'VpRkC':_0x4cca(0x93),'InUcs':function(_0x4aac2e){return _0x4aac2e();},'lVFYH':function(_0x4be4f6,_0x5f1dfa){return _0x4be4f6>_0x5f1dfa;},'QuFSl':_0x4cca(0x94),'GLWDS':_0x4cca(0x49)};try{if(_0x18606a[_0x4cca(0x95)]!=='LywIy'){const _0x2e1391=await _0x18606a[_0x4cca(0x96)](getUserProgress),_0x1b1fa5=await _0x18606a['InUcs'](getAuthState);return _0x1b1fa5[_0x4cca(0x5a)]&&_0x18606a[_0x4cca(0x97)](_0x2e1391['completedSteps'][_0x4cca(0x5f)],0x0);}else _0x55818e[_0x4cca(0x19)](_0x4cca(0x98),_0x13e5ec);}catch(_0x51b215){return _0x18606a[_0x4cca(0x99)]===_0x18606a[_0x4cca(0x99)]?(console['error'](_0x18606a['GLWDS'],_0x51b215),![]):{'screen':_0x18606a[_0x4cca(0x9a)],'params':{'isNewUser':!![],'activateCamera':!![]}};}};export const markAppActive=async()=>{const _0x2b0b13={'DTINc':function(_0x26d362,_0x3c2072){return _0x26d362===_0x3c2072;},'xshuL':_0x4cca(0x9b),'OvLjR':function(_0x4665c1,_0x2658aa){return _0x4665c1(_0x2658aa);},'NKsWS':_0x4cca(0x9c),'xRyEp':function(_0x303b14,_0x24db3a){return _0x303b14!==_0x24db3a;},'CgolE':'qBqHN','mXtGs':'❌\x20Error\x20marking\x20app\x20as\x20active:'};try{if(_0x2b0b13[_0x4cca(0x9d)](_0x2b0b13[_0x4cca(0x9e)],_0x2b0b13[_0x4cca(0x9e)]))await _0x2b0b13['OvLjR'](saveUserProgress,{'timestamp':Date[_0x4cca(0x14)]()}),console[_0x4cca(0x17)](_0x2b0b13[_0x4cca(0x9f)]);else return _0x1cb23a[_0x4cca(0x19)](_0x4cca(0x6c),_0x248d76),![];}catch(_0x537f5d){_0x2b0b13[_0x4cca(0xa0)](_0x4cca(0xa1),_0x2b0b13[_0x4cca(0xa2)])?console['error'](_0x2b0b13[_0x4cca(0xa3)],_0x537f5d):_0x16cd96[_0x4cca(0x19)](_0x4cca(0x26),_0x2301f1);}};export const getDebugStorageInfo=async()=>{const _0xb5fc2b={'gdPoq':function(_0x293315,_0x692478){return _0x293315!==_0x692478;},'kRrNu':function(_0x41728a){return _0x41728a();},'ygzBZ':_0x4cca(0xa4)};try{if(_0xb5fc2b[_0x4cca(0xa5)]('dsFSb',_0x4cca(0xa6)))return _0x141678[_0x4cca(0x19)](_0x4cca(0x2f),_0xcd6006),{'isAuthenticated':![],'authMethod':null,'hasValidToken':![]};else{const _0x1502df=await _0xb5fc2b[_0x4cca(0xa7)](getUserProgress),_0x50548a=await _0xb5fc2b['kRrNu'](getAuthState),_0x5b7739=await _0xb5fc2b['kRrNu'](isReturningUser),_0x1cd0ce=await _0xb5fc2b[_0x4cca(0xa7)](getResumeTarget);return{'progress':_0x1502df,'authState':_0x50548a,'isReturning':_0x5b7739,'resumeTarget':_0x1cd0ce};}}catch(_0x5a2de7){console[_0x4cca(0x19)](_0xb5fc2b[_0x4cca(0xa8)],_0x5a2de7);throw _0x5a2de7;}};export const clearAllProgress=async()=>{const _0x421d8b={'xXibb':function(_0x14a947){return _0x14a947();},'DnjQL':_0x4cca(0xa9)};try{await _0x421d8b[_0x4cca(0xaa)](clearUserData),console[_0x4cca(0x17)](_0x421d8b[_0x4cca(0xab)]);}catch(_0x441e01){console['error'](_0x4cca(0xac),_0x441e01);}};
|
|
1
|
+
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
2
|
+
import { clearStoredPin } from './pinStorageUtils';
|
|
3
|
+
|
|
4
|
+
// Storage keys
|
|
5
|
+
export const STORAGE_KEYS = {
|
|
6
|
+
// Authentication
|
|
7
|
+
AUTH_TOKEN: 'auth_token',
|
|
8
|
+
ONAIROS_JWT_TOKEN: 'onairos_jwt_token',
|
|
9
|
+
ENOCH_TOKEN: 'enoch_token',
|
|
10
|
+
// User data
|
|
11
|
+
USER: 'user',
|
|
12
|
+
USER_PROFILE: 'userProfile',
|
|
13
|
+
USER_PROFILE_FALLBACK: 'userProfileFallback',
|
|
14
|
+
// App state
|
|
15
|
+
USER_PROGRESS: 'user_progress',
|
|
16
|
+
ONBOARDING_COMPLETED: 'onboardingCompleted',
|
|
17
|
+
IS_FIRST_TIME_USER: 'isFirstTimeUser',
|
|
18
|
+
USER_ATTENDANCE_CONFIRMED: 'userAttendanceConfirmed',
|
|
19
|
+
// New: Token for completed onboarding with Results access
|
|
20
|
+
ONBOARDING_COMPLETE_TOKEN: 'onboarding_complete_token',
|
|
21
|
+
EVENT_ACCESS_TOKEN: 'event_access_token',
|
|
22
|
+
// Authentication method tracking
|
|
23
|
+
ONAIROS_USER: 'onairos_user',
|
|
24
|
+
APPLE_USER: 'apple_user',
|
|
25
|
+
AUTH_METHOD: 'auth_method',
|
|
26
|
+
// Session data
|
|
27
|
+
CURRENT_EVENT_DATA: 'currentEventData',
|
|
28
|
+
CONNECTED_PLATFORMS: 'connectedPlatforms',
|
|
29
|
+
PROFILE_IMAGE: 'profileImage',
|
|
30
|
+
// Admin status
|
|
31
|
+
USER_ADMIN_STATUS: 'user_admin_status'
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// User progress tracking
|
|
35
|
+
|
|
36
|
+
// Authentication state
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Save user progress to track where they left off
|
|
40
|
+
*/
|
|
41
|
+
export const saveUserProgress = async progress => {
|
|
42
|
+
try {
|
|
43
|
+
const existingProgress = await getUserProgress();
|
|
44
|
+
const updatedProgress = {
|
|
45
|
+
...existingProgress,
|
|
46
|
+
...progress,
|
|
47
|
+
timestamp: Date.now()
|
|
48
|
+
};
|
|
49
|
+
await AsyncStorage.setItem(STORAGE_KEYS.USER_PROGRESS, JSON.stringify(updatedProgress));
|
|
50
|
+
console.log('✅ User progress saved:', updatedProgress);
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.error('❌ Error saving user progress:', error);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Get user progress to determine where to resume
|
|
58
|
+
*/
|
|
59
|
+
export const getUserProgress = async () => {
|
|
60
|
+
try {
|
|
61
|
+
const progressData = await AsyncStorage.getItem(STORAGE_KEYS.USER_PROGRESS);
|
|
62
|
+
if (progressData) {
|
|
63
|
+
return JSON.parse(progressData);
|
|
64
|
+
}
|
|
65
|
+
} catch (error) {
|
|
66
|
+
console.error('❌ Error getting user progress:', error);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Return default progress
|
|
70
|
+
return {
|
|
71
|
+
lastScreen: 'Welcome',
|
|
72
|
+
completedSteps: [],
|
|
73
|
+
authMethod: null,
|
|
74
|
+
hasProfilePhoto: false,
|
|
75
|
+
hasCompletedProfile: false,
|
|
76
|
+
hasSelectedIntentions: false,
|
|
77
|
+
hasViewedResults: false,
|
|
78
|
+
hasEnteredEventCode: false,
|
|
79
|
+
hasRegisteredForEvent: false,
|
|
80
|
+
hasReachedEventPage: false,
|
|
81
|
+
timestamp: Date.now()
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Save authentication state
|
|
87
|
+
*/
|
|
88
|
+
export const saveAuthState = async authState => {
|
|
89
|
+
try {
|
|
90
|
+
const existingState = await getAuthState();
|
|
91
|
+
const updatedState = {
|
|
92
|
+
...existingState,
|
|
93
|
+
...authState
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
// Also save the auth method separately for quick access
|
|
97
|
+
if (authState.authMethod) {
|
|
98
|
+
await AsyncStorage.setItem(STORAGE_KEYS.AUTH_METHOD, authState.authMethod);
|
|
99
|
+
}
|
|
100
|
+
console.log('✅ Auth state saved:', updatedState);
|
|
101
|
+
} catch (error) {
|
|
102
|
+
console.error('❌ Error saving auth state:', error);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Get authentication state
|
|
108
|
+
*/
|
|
109
|
+
export const getAuthState = async () => {
|
|
110
|
+
try {
|
|
111
|
+
const authMethod = await AsyncStorage.getItem(STORAGE_KEYS.AUTH_METHOD);
|
|
112
|
+
const hasToken = !!(await AsyncStorage.getItem(STORAGE_KEYS.AUTH_TOKEN));
|
|
113
|
+
return {
|
|
114
|
+
isAuthenticated: hasToken,
|
|
115
|
+
authMethod,
|
|
116
|
+
hasValidToken: hasToken
|
|
117
|
+
};
|
|
118
|
+
} catch (error) {
|
|
119
|
+
console.error('❌ Error getting auth state:', error);
|
|
120
|
+
return {
|
|
121
|
+
isAuthenticated: false,
|
|
122
|
+
authMethod: null,
|
|
123
|
+
hasValidToken: false
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Clear all user data (for logout)
|
|
130
|
+
*/
|
|
131
|
+
export const clearUserData = async () => {
|
|
132
|
+
try {
|
|
133
|
+
const keysToRemove = [STORAGE_KEYS.USER, STORAGE_KEYS.USER_PROFILE, STORAGE_KEYS.USER_PROFILE_FALLBACK, STORAGE_KEYS.USER_PROGRESS, STORAGE_KEYS.AUTH_TOKEN, STORAGE_KEYS.ONAIROS_JWT_TOKEN, STORAGE_KEYS.ENOCH_TOKEN, STORAGE_KEYS.ONAIROS_USER, STORAGE_KEYS.APPLE_USER, STORAGE_KEYS.AUTH_METHOD, STORAGE_KEYS.IS_FIRST_TIME_USER, STORAGE_KEYS.USER_ATTENDANCE_CONFIRMED, STORAGE_KEYS.PROFILE_IMAGE, STORAGE_KEYS.ONBOARDING_COMPLETED,
|
|
134
|
+
// Clear the new onboarding completion tokens
|
|
135
|
+
STORAGE_KEYS.ONBOARDING_COMPLETE_TOKEN, STORAGE_KEYS.EVENT_ACCESS_TOKEN];
|
|
136
|
+
await AsyncStorage.multiRemove(keysToRemove);
|
|
137
|
+
|
|
138
|
+
// Also clear biometrically stored PIN
|
|
139
|
+
try {
|
|
140
|
+
await clearStoredPin();
|
|
141
|
+
console.log('✅ Biometrically stored PIN cleared');
|
|
142
|
+
} catch (error) {
|
|
143
|
+
console.warn('⚠️ Error clearing stored PIN (continuing):', error);
|
|
144
|
+
}
|
|
145
|
+
console.log('✅ User data cleared including onboarding completion tokens');
|
|
146
|
+
} catch (error) {
|
|
147
|
+
console.error('❌ Error clearing user data:', error);
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Get resume navigation target based on user progress
|
|
153
|
+
*/
|
|
154
|
+
export const getResumeTarget = async () => {
|
|
155
|
+
try {
|
|
156
|
+
const progress = await getUserProgress();
|
|
157
|
+
const authState = await getAuthState();
|
|
158
|
+
|
|
159
|
+
// HIGHEST PRIORITY: Check event access token first (regardless of auth state)
|
|
160
|
+
// This ensures release mode reliability when network auth fails
|
|
161
|
+
const hasEventToken = await hasEventAccessToken();
|
|
162
|
+
if (hasEventToken || progress.hasReachedEventPage && progress.hasViewedResults) {
|
|
163
|
+
console.log('🎯 User has completed onboarding (verified by token) - returning to Home screen');
|
|
164
|
+
|
|
165
|
+
// After completing first event, users go to Home screen instead of Results
|
|
166
|
+
// This provides a better post-event experience and central hub
|
|
167
|
+
return {
|
|
168
|
+
screen: 'Home'
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// If not authenticated, start from Welcome
|
|
173
|
+
if (!authState.isAuthenticated) {
|
|
174
|
+
return {
|
|
175
|
+
screen: 'Welcome'
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// If authenticated but no progress, start camera flow
|
|
180
|
+
if (progress.completedSteps.length === 0) {
|
|
181
|
+
return {
|
|
182
|
+
screen: 'Welcome',
|
|
183
|
+
params: {
|
|
184
|
+
isNewUser: true,
|
|
185
|
+
activateCamera: true
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// Resume based on last completed step for users still in onboarding
|
|
191
|
+
if (!progress.hasProfilePhoto) {
|
|
192
|
+
return {
|
|
193
|
+
screen: 'Welcome',
|
|
194
|
+
params: {
|
|
195
|
+
isNewUser: true,
|
|
196
|
+
activateCamera: true
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
if (!progress.hasCompletedProfile) {
|
|
201
|
+
const profileImage = await AsyncStorage.getItem(STORAGE_KEYS.PROFILE_IMAGE);
|
|
202
|
+
return {
|
|
203
|
+
screen: 'CreateFreshProfile',
|
|
204
|
+
params: {
|
|
205
|
+
photo: profileImage,
|
|
206
|
+
isReviewerBypass: authState.authMethod === 'onairos'
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
if (!progress.hasSelectedIntentions) {
|
|
211
|
+
const userProfile = await AsyncStorage.getItem(STORAGE_KEYS.USER_PROFILE);
|
|
212
|
+
return {
|
|
213
|
+
screen: 'Intention',
|
|
214
|
+
params: {
|
|
215
|
+
userProfile: userProfile ? JSON.parse(userProfile) : null
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// Default to Results if everything is complete
|
|
221
|
+
const userProfile = await AsyncStorage.getItem(STORAGE_KEYS.USER_PROFILE);
|
|
222
|
+
return {
|
|
223
|
+
screen: 'Results',
|
|
224
|
+
params: {
|
|
225
|
+
userProfile: userProfile ? JSON.parse(userProfile) : null
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
} catch (error) {
|
|
229
|
+
console.error('❌ Error determining resume target:', error);
|
|
230
|
+
return {
|
|
231
|
+
screen: 'Welcome'
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Check if user has completed onboarding flow
|
|
238
|
+
*/
|
|
239
|
+
export const hasCompletedOnboarding = async () => {
|
|
240
|
+
try {
|
|
241
|
+
const progress = await getUserProgress();
|
|
242
|
+
return progress.hasCompletedProfile && progress.hasViewedResults;
|
|
243
|
+
} catch (error) {
|
|
244
|
+
console.error('❌ Error checking onboarding status:', error);
|
|
245
|
+
return false;
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Mark user as having reached the event page (completed full onboarding)
|
|
251
|
+
* This creates the token that ensures they always return to Results
|
|
252
|
+
*/
|
|
253
|
+
export const markEventPageReached = async eventData => {
|
|
254
|
+
try {
|
|
255
|
+
const progress = await getUserProgress();
|
|
256
|
+
const updatedProgress = {
|
|
257
|
+
...progress,
|
|
258
|
+
hasReachedEventPage: true,
|
|
259
|
+
hasViewedResults: true,
|
|
260
|
+
eventData: eventData || progress.eventData,
|
|
261
|
+
timestamp: Date.now()
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
// Save the updated progress
|
|
265
|
+
await saveUserProgress(updatedProgress);
|
|
266
|
+
|
|
267
|
+
// Save the onboarding completion token for extra security
|
|
268
|
+
await AsyncStorage.setItem(STORAGE_KEYS.ONBOARDING_COMPLETE_TOKEN, 'true');
|
|
269
|
+
await AsyncStorage.setItem(STORAGE_KEYS.EVENT_ACCESS_TOKEN, JSON.stringify({
|
|
270
|
+
timestamp: Date.now(),
|
|
271
|
+
eventData: eventData,
|
|
272
|
+
hasAccess: true
|
|
273
|
+
}));
|
|
274
|
+
console.log('✅ User marked as having reached event page - will always return to Results');
|
|
275
|
+
} catch (error) {
|
|
276
|
+
console.error('❌ Error marking event page reached:', error);
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Check if user has the event access token (completed onboarding)
|
|
282
|
+
*/
|
|
283
|
+
export const hasEventAccessToken = async () => {
|
|
284
|
+
try {
|
|
285
|
+
const token = await AsyncStorage.getItem(STORAGE_KEYS.ONBOARDING_COMPLETE_TOKEN);
|
|
286
|
+
const progress = await getUserProgress();
|
|
287
|
+
return token === 'true' && progress.hasReachedEventPage;
|
|
288
|
+
} catch (error) {
|
|
289
|
+
console.error('❌ Error checking event access token:', error);
|
|
290
|
+
return false;
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Mark a step as completed
|
|
296
|
+
*/
|
|
297
|
+
export const markStepCompleted = async step => {
|
|
298
|
+
try {
|
|
299
|
+
const progress = await getUserProgress();
|
|
300
|
+
if (!progress.completedSteps.includes(step)) {
|
|
301
|
+
progress.completedSteps.push(step);
|
|
302
|
+
await saveUserProgress(progress);
|
|
303
|
+
}
|
|
304
|
+
} catch (error) {
|
|
305
|
+
console.error('❌ Error marking step completed:', error);
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Update user's last screen
|
|
311
|
+
*/
|
|
312
|
+
export const updateLastScreen = async (screen, params) => {
|
|
313
|
+
try {
|
|
314
|
+
await saveUserProgress({
|
|
315
|
+
lastScreen: screen,
|
|
316
|
+
timestamp: Date.now()
|
|
317
|
+
});
|
|
318
|
+
} catch (error) {
|
|
319
|
+
console.error('❌ Error updating last screen:', error);
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Check if this is a returning user with existing progress
|
|
325
|
+
*/
|
|
326
|
+
export const isReturningUser = async () => {
|
|
327
|
+
try {
|
|
328
|
+
const progress = await getUserProgress();
|
|
329
|
+
const authState = await getAuthState();
|
|
330
|
+
return authState.isAuthenticated && progress.completedSteps.length > 0;
|
|
331
|
+
} catch (error) {
|
|
332
|
+
console.error('❌ Error checking returning user status:', error);
|
|
333
|
+
return false;
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Mark app as active (call this when app becomes active)
|
|
339
|
+
*/
|
|
340
|
+
export const markAppActive = async () => {
|
|
341
|
+
try {
|
|
342
|
+
await saveUserProgress({
|
|
343
|
+
timestamp: Date.now()
|
|
344
|
+
});
|
|
345
|
+
console.log('✅ App marked as active');
|
|
346
|
+
} catch (error) {
|
|
347
|
+
console.error('❌ Error marking app as active:', error);
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Development utility: Get all stored progress data for debugging
|
|
353
|
+
*/
|
|
354
|
+
export const getDebugStorageInfo = async () => {
|
|
355
|
+
try {
|
|
356
|
+
const progress = await getUserProgress();
|
|
357
|
+
const authState = await getAuthState();
|
|
358
|
+
const isReturning = await isReturningUser();
|
|
359
|
+
const resumeTarget = await getResumeTarget();
|
|
360
|
+
return {
|
|
361
|
+
progress,
|
|
362
|
+
authState,
|
|
363
|
+
isReturning,
|
|
364
|
+
resumeTarget
|
|
365
|
+
};
|
|
366
|
+
} catch (error) {
|
|
367
|
+
console.error('❌ Error getting debug storage info:', error);
|
|
368
|
+
throw error;
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* Development utility: Clear all progress (for testing)
|
|
374
|
+
*/
|
|
375
|
+
export const clearAllProgress = async () => {
|
|
376
|
+
try {
|
|
377
|
+
await clearUserData();
|
|
378
|
+
console.log('✅ All progress data cleared');
|
|
379
|
+
} catch (error) {
|
|
380
|
+
console.error('❌ Error clearing progress data:', error);
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
//# sourceMappingURL=storageService.js.map
|
|
@@ -1 +1,109 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Telegram Data Extractor
|
|
3
|
+
*
|
|
4
|
+
* Orchestrates the Telegram data export flow:
|
|
5
|
+
* 1. Receives extracted dialogs/messages from WebView
|
|
6
|
+
* 2. Validates and formats data
|
|
7
|
+
* 3. Sends to backend via telegramDataService
|
|
8
|
+
*
|
|
9
|
+
* This acts as the bridge between OAuthWebView and the backend API.
|
|
10
|
+
*
|
|
11
|
+
* @reference ChatGPT implementation: src/services/chatGPTConversationExtractor.ts
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { storeTelegramData } from './telegramDataService';
|
|
15
|
+
import { Alert } from 'react-native';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Combined Telegram export data from WebView
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Hook for Telegram data extraction operations
|
|
23
|
+
*/
|
|
24
|
+
export const useTelegramDataExtractor = () => {
|
|
25
|
+
/**
|
|
26
|
+
* Initiate data export to backend
|
|
27
|
+
*
|
|
28
|
+
* @param username - User identifier
|
|
29
|
+
* @param data - Extracted Telegram data (dialogs and messages)
|
|
30
|
+
* @returns true if successful, false otherwise
|
|
31
|
+
*/
|
|
32
|
+
const initiateDataExport = async (username, data) => {
|
|
33
|
+
var _data$summary, _data$summary2, _data$dialogs, _data$messages, _data$dialogs2, _data$messages2;
|
|
34
|
+
console.log('🚀 [TELEGRAM_EXTRACTOR] Initiating data export');
|
|
35
|
+
console.log('👤 [TELEGRAM_EXTRACTOR] Username:', username);
|
|
36
|
+
console.log('📊 [TELEGRAM_EXTRACTOR] Dialogs:', (_data$summary = data.summary) === null || _data$summary === void 0 ? void 0 : _data$summary.dialogCount);
|
|
37
|
+
console.log('📊 [TELEGRAM_EXTRACTOR] Messages:', (_data$summary2 = data.summary) === null || _data$summary2 === void 0 ? void 0 : _data$summary2.messageCount);
|
|
38
|
+
|
|
39
|
+
// Validation
|
|
40
|
+
if (!username) {
|
|
41
|
+
console.error('❌ [TELEGRAM_EXTRACTOR] Username is required');
|
|
42
|
+
Alert.alert('Error', 'Username is required to export Telegram data.', [{
|
|
43
|
+
text: 'OK',
|
|
44
|
+
style: 'default'
|
|
45
|
+
}]);
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Handle empty data as success - user might have no recent messages
|
|
50
|
+
const totalItems = (((_data$dialogs = data.dialogs) === null || _data$dialogs === void 0 ? void 0 : _data$dialogs.length) || 0) + (((_data$messages = data.messages) === null || _data$messages === void 0 ? void 0 : _data$messages.length) || 0);
|
|
51
|
+
if (totalItems === 0) {
|
|
52
|
+
console.log('ℹ️ [TELEGRAM_EXTRACTOR] No data to export - treating as success (connected)');
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Validate dialogs structure
|
|
57
|
+
const validDialogs = (data.dialogs || []).filter(dialog => {
|
|
58
|
+
const isValid = dialog.id && dialog.title;
|
|
59
|
+
if (!isValid) {
|
|
60
|
+
console.warn('⚠️ [TELEGRAM_EXTRACTOR] Invalid dialog:', dialog);
|
|
61
|
+
}
|
|
62
|
+
return isValid;
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// Validate messages structure
|
|
66
|
+
const validMessages = (data.messages || []).filter(msg => {
|
|
67
|
+
const isValid = msg.id && (msg.text || msg.type);
|
|
68
|
+
if (!isValid) {
|
|
69
|
+
console.warn('⚠️ [TELEGRAM_EXTRACTOR] Invalid message:', msg);
|
|
70
|
+
}
|
|
71
|
+
return isValid;
|
|
72
|
+
});
|
|
73
|
+
const filteredOut = (((_data$dialogs2 = data.dialogs) === null || _data$dialogs2 === void 0 ? void 0 : _data$dialogs2.length) || 0) - validDialogs.length + (((_data$messages2 = data.messages) === null || _data$messages2 === void 0 ? void 0 : _data$messages2.length) || 0) - validMessages.length;
|
|
74
|
+
if (filteredOut > 0) {
|
|
75
|
+
console.warn(`⚠️ [TELEGRAM_EXTRACTOR] Filtered out ${filteredOut} invalid items`);
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
console.log('📡 [TELEGRAM_EXTRACTOR] Sending to backend...');
|
|
79
|
+
const result = await storeTelegramData(username, {
|
|
80
|
+
dialogs: validDialogs,
|
|
81
|
+
messages: validMessages,
|
|
82
|
+
userId: data.userId
|
|
83
|
+
});
|
|
84
|
+
if (result.success) {
|
|
85
|
+
console.log('✅ [TELEGRAM_EXTRACTOR] Export completed successfully');
|
|
86
|
+
console.log('📊 [TELEGRAM_EXTRACTOR] Backend response:', result.data);
|
|
87
|
+
return true;
|
|
88
|
+
} else {
|
|
89
|
+
console.error('❌ [TELEGRAM_EXTRACTOR] Backend storage failed:', result.error);
|
|
90
|
+
Alert.alert('Export Failed', result.error || 'An unknown error occurred during data storage.', [{
|
|
91
|
+
text: 'OK',
|
|
92
|
+
style: 'default'
|
|
93
|
+
}]);
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
} catch (error) {
|
|
97
|
+
console.error('❌ [TELEGRAM_EXTRACTOR] Unexpected error during export:', error);
|
|
98
|
+
Alert.alert('Export Error', 'Failed to connect to the data storage service. Please check your network connection.', [{
|
|
99
|
+
text: 'OK',
|
|
100
|
+
style: 'default'
|
|
101
|
+
}]);
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
return {
|
|
106
|
+
initiateDataExport
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
//# sourceMappingURL=telegramDataExtractor.js.map
|