@onairos/react-native 3.6.3 → 3.6.5
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 +1 -1
- package/lib/commonjs/components/BodyText.js +1 -1
- package/lib/commonjs/components/BrandMark.js +1 -1
- package/lib/commonjs/components/CodeInput.js +1 -1
- package/lib/commonjs/components/EmailInput.js +1 -1
- package/lib/commonjs/components/GoogleButton.js +1 -1
- package/lib/commonjs/components/HeadingGroup.js +1 -1
- package/lib/commonjs/components/LLMDataInputModal.js +1 -1
- package/lib/commonjs/components/ModalHeader.js +1 -1
- package/lib/commonjs/components/ModalSheet.js +1 -1
- package/lib/commonjs/components/Onairos.js +1 -1
- package/lib/commonjs/components/OnairosButton.js +1 -1
- package/lib/commonjs/components/OnairosSignInButton.js +1 -1
- package/lib/commonjs/components/Overlay.js +1 -1
- package/lib/commonjs/components/PersonaImage.js +1 -1
- package/lib/commonjs/components/PersonaLoadingScreen.js +1 -1
- package/lib/commonjs/components/PersonalizationConsentScreen.js +1 -1
- package/lib/commonjs/components/PinCreationScreen.js +1 -1
- package/lib/commonjs/components/PinInput.js +1 -1
- package/lib/commonjs/components/PlatformConnectorsStep.js +1 -1
- package/lib/commonjs/components/PlatformList.js +1 -1
- package/lib/commonjs/components/PlatformToggle.js +1 -1
- package/lib/commonjs/components/PrimaryButton.js +1 -1
- package/lib/commonjs/components/SignInMatchAnimation.js +1 -1
- package/lib/commonjs/components/SignInStep.js +1 -1
- package/lib/commonjs/components/UniversalOnboarding.js +1 -1
- package/lib/commonjs/components/VerificationStep.js +1 -1
- package/lib/commonjs/components/WelcomeScreen.js +1 -1
- package/lib/commonjs/components/icons/Basicproficon.js +1 -1
- package/lib/commonjs/components/icons/Basicprofile.js +1 -1
- package/lib/commonjs/components/icons/Checkbox.js +1 -1
- package/lib/commonjs/components/icons/Checkmark.js +1 -1
- package/lib/commonjs/components/icons/Contentanalysis.js +1 -1
- package/lib/commonjs/components/icons/Contenticon.js +1 -1
- package/lib/commonjs/components/icons/EnochE.js +1 -1
- package/lib/commonjs/components/icons/Personalityicon.js +1 -1
- package/lib/commonjs/components/icons/Personalityprofile.js +1 -1
- package/lib/commonjs/components/icons/Personalitytraits.js +1 -1
- package/lib/commonjs/components/icons/Userpreferences.js +1 -1
- package/lib/commonjs/components/icons/index.js +1 -1
- package/lib/commonjs/components/onboarding/OAuthWebView.js +1 -1
- package/lib/commonjs/components/onboarding/OnboardingHeader.js +1 -1
- package/lib/commonjs/components/onboarding/PinInput.js +1 -1
- package/lib/commonjs/components/onboarding/PlatformConnector.js +1 -1
- package/lib/commonjs/config/api.js +1 -1
- package/lib/commonjs/constants/index.js +1 -1
- package/lib/commonjs/context/AuthContext.js +1 -1
- package/lib/commonjs/hooks/useConnectedAccounts.js +1 -1
- package/lib/commonjs/hooks/useConnections.js +1 -1
- package/lib/commonjs/hooks/useCredentials.js +1 -1
- package/lib/commonjs/hooks/useUserConnections.js +1 -1
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/services/apiClient.js +1 -1
- package/lib/commonjs/services/apiKeyService.js +924 -9
- package/lib/commonjs/services/authService.js +627 -10
- package/lib/commonjs/services/biometricPinService.js +1 -1
- package/lib/commonjs/services/chatGPTConversationExtractor.js +1 -1
- package/lib/commonjs/services/chatGPTConversationService.js +1 -1
- package/lib/commonjs/services/claudeConversationExtractor.js +1 -1
- package/lib/commonjs/services/claudeConversationService.js +1 -1
- package/lib/commonjs/services/connectedAccountsService.js +1 -1
- package/lib/commonjs/services/googleAuthService.js +1 -1
- package/lib/commonjs/services/hingeDataExtractor.js +1 -1
- package/lib/commonjs/services/hingeDataService.js +1 -1
- package/lib/commonjs/services/imageCompressionService.js +1 -1
- package/lib/commonjs/services/instagramDataExtractor.js +1 -1
- package/lib/commonjs/services/instagramDataService.js +1 -1
- package/lib/commonjs/services/jwtStorageService.js +1 -1
- package/lib/commonjs/services/linkedinDOMExtractor.js +1 -1
- package/lib/commonjs/services/linkedinProfileService.js +1 -1
- package/lib/commonjs/services/linkedinScrapingService.js +1 -1
- package/lib/commonjs/services/llmDataStorage.js +1 -1
- package/lib/commonjs/services/mobileTrainingService.js +1 -1
- package/lib/commonjs/services/oauthService.js +391 -11
- package/lib/commonjs/services/pinEncryptionService.js +1 -1
- package/lib/commonjs/services/pinStorageUtils.js +1 -1
- package/lib/commonjs/services/platformAuthService.js +1 -1
- package/lib/commonjs/services/sephoraDataExtractor.js +1 -1
- package/lib/commonjs/services/sephoraDataService.js +1 -1
- package/lib/commonjs/services/storageService.js +1 -1
- package/lib/commonjs/services/telegramDataExtractor.js +1 -1
- package/lib/commonjs/services/telegramDataService.js +1 -1
- package/lib/commonjs/services/trainingApiHelpers.js +1 -1
- package/lib/commonjs/services/userConnectionsService.js +1 -1
- package/lib/commonjs/services/youtubeMigrationService.js +1 -1
- package/lib/commonjs/theme/index.js +1 -1
- package/lib/commonjs/types/index.js +1 -1
- package/lib/commonjs/types.js +1 -1
- package/lib/commonjs/utils/Portal.js +1 -1
- package/lib/commonjs/utils/api.js +1 -1
- package/lib/commonjs/utils/assetRegistry.js +1 -1
- package/lib/commonjs/utils/auth.js +1 -1
- package/lib/commonjs/utils/connectorTests.js +1 -1
- package/lib/commonjs/utils/crypto.js +1 -1
- package/lib/commonjs/utils/debugHelper.js +1 -1
- package/lib/commonjs/utils/encryption.js +1 -1
- package/lib/commonjs/utils/eventUtils.js +1 -1
- package/lib/commonjs/utils/haptics.js +1 -1
- package/lib/commonjs/utils/imagePreloader.js +1 -1
- package/lib/commonjs/utils/networkDiagnostics.js +1 -1
- package/lib/commonjs/utils/onairosApi.js +1 -1
- package/lib/commonjs/utils/programmaticFlow.js +1 -1
- package/lib/commonjs/utils/retryHelper.js +1 -1
- package/lib/commonjs/utils/secureStorage.js +1 -1
- package/lib/commonjs/utils/webviewScripts/chatgpt.js +1 -1
- package/lib/commonjs/utils/webviewScripts/claude.js +1 -1
- package/lib/commonjs/utils/webviewScripts/hinge.js +1 -1
- package/lib/commonjs/utils/webviewScripts/index.js +1 -1
- package/lib/commonjs/utils/webviewScripts/instagram.js +1 -1
- package/lib/commonjs/utils/webviewScripts/linkedin.js +1 -1
- package/lib/commonjs/utils/webviewScripts/sephora.js +1 -1
- package/lib/commonjs/utils/webviewScripts/telegram.js +1 -1
- package/lib/module/api/index.js +1 -1
- package/lib/module/components/BodyText.js +1 -1
- package/lib/module/components/BrandMark.js +1 -1
- package/lib/module/components/CodeInput.js +1 -1
- package/lib/module/components/EmailInput.js +1 -1
- package/lib/module/components/GoogleButton.js +1 -1
- package/lib/module/components/HeadingGroup.js +1 -1
- package/lib/module/components/LLMDataInputModal.js +1 -1
- package/lib/module/components/ModalHeader.js +1 -1
- package/lib/module/components/ModalSheet.js +1 -1
- package/lib/module/components/Onairos.js +1 -1
- package/lib/module/components/OnairosButton.js +1 -1
- package/lib/module/components/OnairosSignInButton.js +1 -1
- package/lib/module/components/Overlay.js +1 -1
- package/lib/module/components/PersonaImage.js +1 -1
- package/lib/module/components/PersonaLoadingScreen.js +1 -1
- package/lib/module/components/PersonalizationConsentScreen.js +1 -1
- package/lib/module/components/PinCreationScreen.js +1 -1
- package/lib/module/components/PinInput.js +1 -1
- package/lib/module/components/PlatformConnectorsStep.js +1 -1
- package/lib/module/components/PlatformList.js +1 -1
- package/lib/module/components/PlatformToggle.js +1 -1
- package/lib/module/components/PrimaryButton.js +1 -1
- package/lib/module/components/SignInMatchAnimation.js +1 -1
- package/lib/module/components/SignInStep.js +1 -1
- package/lib/module/components/UniversalOnboarding.js +1 -1
- package/lib/module/components/VerificationStep.js +1 -1
- package/lib/module/components/WelcomeScreen.js +1 -1
- package/lib/module/components/icons/Basicproficon.js +1 -1
- package/lib/module/components/icons/Basicprofile.js +1 -1
- package/lib/module/components/icons/Checkbox.js +1 -1
- package/lib/module/components/icons/Checkmark.js +1 -1
- package/lib/module/components/icons/Contentanalysis.js +1 -1
- package/lib/module/components/icons/Contenticon.js +1 -1
- package/lib/module/components/icons/EnochE.js +1 -1
- package/lib/module/components/icons/Personalityicon.js +1 -1
- package/lib/module/components/icons/Personalityprofile.js +1 -1
- package/lib/module/components/icons/Personalitytraits.js +1 -1
- package/lib/module/components/icons/Userpreferences.js +1 -1
- package/lib/module/components/onboarding/OAuthWebView.js +1 -1
- package/lib/module/components/onboarding/OnboardingHeader.js +1 -1
- package/lib/module/components/onboarding/PinInput.js +1 -1
- package/lib/module/components/onboarding/PlatformConnector.js +1 -1
- package/lib/module/config/api.js +1 -1
- package/lib/module/constants/index.js +1 -1
- package/lib/module/context/AuthContext.js +1 -1
- package/lib/module/hooks/useConnectedAccounts.js +1 -1
- package/lib/module/hooks/useConnections.js +1 -1
- package/lib/module/hooks/useCredentials.js +1 -1
- package/lib/module/hooks/useUserConnections.js +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/services/apiClient.js +1 -1
- package/lib/module/services/apiKeyService.js +898 -1
- package/lib/module/services/authService.js +602 -1
- package/lib/module/services/biometricPinService.js +1 -1
- package/lib/module/services/chatGPTConversationExtractor.js +1 -1
- package/lib/module/services/chatGPTConversationService.js +1 -1
- package/lib/module/services/claudeConversationExtractor.js +1 -1
- package/lib/module/services/claudeConversationService.js +1 -1
- package/lib/module/services/connectedAccountsService.js +1 -1
- package/lib/module/services/googleAuthService.js +1 -1
- package/lib/module/services/hingeDataExtractor.js +1 -1
- package/lib/module/services/hingeDataService.js +1 -1
- package/lib/module/services/imageCompressionService.js +1 -1
- package/lib/module/services/instagramDataExtractor.js +1 -1
- package/lib/module/services/instagramDataService.js +1 -1
- package/lib/module/services/jwtStorageService.js +1 -1
- package/lib/module/services/linkedinDOMExtractor.js +1 -1
- package/lib/module/services/linkedinProfileService.js +1 -1
- package/lib/module/services/linkedinScrapingService.js +1 -1
- package/lib/module/services/llmDataStorage.js +1 -1
- package/lib/module/services/mobileTrainingService.js +1 -1
- package/lib/module/services/oauthService.js +381 -1
- package/lib/module/services/pinEncryptionService.js +1 -1
- package/lib/module/services/pinStorageUtils.js +1 -1
- package/lib/module/services/platformAuthService.js +1 -1
- package/lib/module/services/sephoraDataExtractor.js +1 -1
- package/lib/module/services/sephoraDataService.js +1 -1
- package/lib/module/services/storageService.js +1 -1
- package/lib/module/services/telegramDataExtractor.js +1 -1
- package/lib/module/services/telegramDataService.js +1 -1
- package/lib/module/services/trainingApiHelpers.js +1 -1
- package/lib/module/services/userConnectionsService.js +1 -1
- package/lib/module/services/youtubeMigrationService.js +1 -1
- package/lib/module/theme/index.js +1 -1
- package/lib/module/types.js +1 -1
- package/lib/module/utils/Portal.js +1 -1
- package/lib/module/utils/api.js +1 -1
- package/lib/module/utils/assetRegistry.js +1 -1
- package/lib/module/utils/auth.js +1 -1
- package/lib/module/utils/connectorTests.js +1 -1
- package/lib/module/utils/crypto.js +1 -1
- package/lib/module/utils/debugHelper.js +1 -1
- package/lib/module/utils/encryption.js +1 -1
- package/lib/module/utils/eventUtils.js +1 -1
- package/lib/module/utils/haptics.js +1 -1
- package/lib/module/utils/networkDiagnostics.js +1 -1
- package/lib/module/utils/onairosApi.js +1 -1
- package/lib/module/utils/programmaticFlow.js +1 -1
- package/lib/module/utils/retryHelper.js +1 -1
- package/lib/module/utils/secureStorage.js +1 -1
- package/lib/module/utils/webviewScripts/chatgpt.js +1 -1
- package/lib/module/utils/webviewScripts/claude.js +1 -1
- package/lib/module/utils/webviewScripts/hinge.js +1 -1
- package/lib/module/utils/webviewScripts/index.js +1 -1
- package/lib/module/utils/webviewScripts/instagram.js +1 -1
- package/lib/module/utils/webviewScripts/linkedin.js +1 -1
- package/lib/module/utils/webviewScripts/sephora.js +1 -1
- package/lib/module/utils/webviewScripts/telegram.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1,602 @@
|
|
|
1
|
-
import AsyncStorage from'@react-native-async-storage/async-storage';import{API_CONFIG,getApiHeaders,getAuthHeaders}from'../config/api';import{getDeveloperAuthHeaders,isApiKeyInitialized}from'./apiKeyService';import{storeJWT,getJWT,clearJWT}from'./jwtStorageService';const API_BASE_URL=API_CONFIG[_0x2d75(0x0)],waitForSDKInit=async(_0x5f3ef1=0x1f40)=>{const _0x41f83f={'sgDIy':_0x2d75(0x1),'KSzLG':_0x2d75(0x2),'buuPA':function(_0x5e83c6){return _0x5e83c6();},'UaxmX':_0x2d75(0x3),'kaLic':function(_0x3897ef,_0x8e172b){return _0x3897ef<_0x8e172b;},'iCKnH':_0x2d75(0x4),'Nfcry':function(_0x554062){return _0x554062();},'rmBZn':function(_0x396398,_0x40d035){return _0x396398===_0x40d035;},'LeLcd':_0x2d75(0x5),'dctHA':'✅\x20[AUTH]\x20SDK\x20initialized\x20after','iKTik':function(_0x110029,_0x41ae57){return _0x110029-_0x41ae57;},'UWhnE':_0x2d75(0x6)};if(_0x41f83f[_0x2d75(0x7)](isApiKeyInitialized))return!![];console[_0x2d75(0x8)](_0x41f83f['UaxmX']);const _0x45c174=Date[_0x2d75(0x9)]();while(_0x41f83f[_0x2d75(0xa)](Date[_0x2d75(0x9)]()-_0x45c174,_0x5f3ef1)){if(_0x41f83f[_0x2d75(0xb)]===_0x41f83f[_0x2d75(0xb)]){await new Promise(_0x2d3beb=>setTimeout(()=>_0x2d3beb(),0x1f4));if(_0x41f83f[_0x2d75(0xc)](isApiKeyInitialized))return _0x41f83f[_0x2d75(0xd)](_0x2d75(0x5),_0x41f83f['LeLcd'])?(console[_0x2d75(0x8)](_0x41f83f['dctHA'],_0x41f83f[_0x2d75(0xe)](Date[_0x2d75(0x9)](),_0x45c174),'ms'),!![]):(_0xb4004e[_0x2d75(0x8)](_0x41f83f[_0x2d75(0xf)],_0x5e3379[_0x2d75(0x10)](0x0,0x14)+'...'),_0x4c0caa);}else return _0xeddd06[_0x2d75(0x11)](_0x41f83f[_0x2d75(0x12)],_0x5b0b27),![];}return console['error'](_0x41f83f[_0x2d75(0x13)],_0x5f3ef1,'ms'),![];};export const authenticateWithOnairos=async _0x1a9378=>{const _0x5f20f4={'zyfdY':_0x2d75(0x14),'kpdpY':function(_0x3571aa,_0x3faea8){return _0x3571aa(_0x3faea8);},'PXVnk':_0x2d75(0x15),'zCaHA':_0x2d75(0x16),'gzolx':_0x2d75(0x17),'ptHwE':'🔑\x20Onairos\x20auth\x20token\x20stored:','ksuOG':_0x2d75(0x18),'ywaPj':function(_0x59385f,_0x13b2f8){return _0x59385f===_0x13b2f8;},'HNDtH':_0x2d75(0x19)};try{console[_0x2d75(0x8)](_0x5f20f4['zyfdY']),await _0x5f20f4[_0x2d75(0x1a)](storeJWT,_0x1a9378[_0x2d75(0x1b)]);const _0x2d396e=await AsyncStorage['getItem'](_0x2d75(0x16)),_0xe5b333=_0x2d396e||_0x1a9378[_0x2d75(0x1c)][_0x2d75(0x1d)]('@')[0x0]||_0x5f20f4[_0x2d75(0x1e)];return await AsyncStorage['setItem'](_0x5f20f4[_0x2d75(0x1f)],_0xe5b333),await AsyncStorage[_0x2d75(0x20)](_0x5f20f4['gzolx'],_0x1a9378['email']),console[_0x2d75(0x8)](_0x5f20f4[_0x2d75(0x21)],_0x1a9378[_0x2d75(0x1b)][_0x2d75(0x10)](0x0,0x14)+_0x2d75(0x22)),console[_0x2d75(0x8)](_0x5f20f4[_0x2d75(0x23)],{'email':_0x1a9378['email'],'username':_0xe5b333}),{'token':_0x1a9378[_0x2d75(0x1b)],'user':{'id':Date[_0x2d75(0x9)]()[_0x2d75(0x24)](),'name':_0xe5b333,'email':_0x1a9378[_0x2d75(0x1c)],'profilePicture':''}};}catch(_0x2959bc){if(_0x5f20f4[_0x2d75(0x25)](_0x2d75(0x26),_0x5f20f4[_0x2d75(0x27)]))return _0x46135b['error'](_0x2d75(0x28),_0x62db9e),![];else{console[_0x2d75(0x11)](_0x2d75(0x29),_0x2959bc);throw _0x2959bc;}}};export const authenticateWithOnairosSignIn=async _0x3b38b9=>{const _0x27abae={'QQGgb':_0x2d75(0x2a),'fhoGg':'🔒\x20[Admin\x20Check]\x20No\x20email\x20provided','eswRL':'zion.darko@onairos.uk','eWgXj':_0x2d75(0x2b),'zIMFN':_0x2d75(0x2c),'sNvKX':_0x2d75(0x2d),'ctolm':function(_0x368eab,_0x515a84){return _0x368eab===_0x515a84;},'DsYcn':function(_0x2c232f,_0x434058){return _0x2c232f===_0x434058;},'mtEqo':'SDK\x20not\x20properly\x20initialized.\x20Please\x20restart\x20the\x20app\x20and\x20try\x20again.','oZdzY':function(_0x14aa9a,_0x457d91){return _0x14aa9a!==_0x457d91;},'VTzSq':'ykecF','kdogT':'🔑\x20Signing\x20in\x20with\x20Onairos\x20via\x20/login/signin\x20endpoint...','jywQL':function(_0x44ba6e,_0x79efb1,_0x334738){return _0x44ba6e(_0x79efb1,_0x334738);},'LLbCs':function(_0x1c29c4){return _0x1c29c4();},'pkvNj':'✅\x20Onairos\x20sign-in\x20successful','omUoZ':_0x2d75(0x2e),'rnGDD':_0x2d75(0x2f),'iCjlj':function(_0xa066be,_0x226826){return _0xa066be(_0x226826);},'WfEhm':function(_0x3af523,_0x4e7df7){return _0x3af523===_0x4e7df7;},'pmpvf':_0x2d75(0x30),'VlDZF':_0x2d75(0x31),'yseNq':_0x2d75(0x17),'ZdYEI':_0x2d75(0x32),'opeyC':_0x2d75(0x33)};try{if(_0x27abae[_0x2d75(0x34)]('ykecF',_0x27abae[_0x2d75(0x35)]))return _0x1f7d47[_0x2d75(0x8)](_0x27abae['QQGgb']),!![];else{console[_0x2d75(0x8)](_0x27abae[_0x2d75(0x36)]);const _0x2fbb40=await _0x27abae[_0x2d75(0x37)](fetch,API_BASE_URL+_0x2d75(0x38),{'method':'POST','headers':_0x27abae[_0x2d75(0x39)](getApiHeaders),'body':JSON[_0x2d75(0x3a)](_0x3b38b9)});if(!_0x2fbb40['ok']){const _0x23b810=await _0x2fbb40[_0x2d75(0x3b)]();throw new Error(_0x23b810['error']||_0x2d75(0x3c));}const _0x4c19a3=await _0x2fbb40['json']();console[_0x2d75(0x8)](_0x27abae[_0x2d75(0x3d)]);if(!_0x4c19a3['token']){if(_0x27abae[_0x2d75(0x3e)](_0x2d75(0x2e),_0x27abae[_0x2d75(0x3f)]))throw new Error(_0x27abae[_0x2d75(0x40)]);else{if(!_0x4bc79e)return _0x42ec28[_0x2d75(0x8)](_0x27abae[_0x2d75(0x41)]),![];const _0xd0b389=[_0x2d75(0x42),_0x27abae['eswRL'],_0x27abae[_0x2d75(0x43)],_0x27abae['zIMFN']],_0x150b09=_0xd0b389[_0x2d75(0x44)](_0x52c678[_0x2d75(0x45)]());return _0x150b09?_0x1a877f[_0x2d75(0x8)](_0x2d75(0x46),_0x38c847):_0x322257[_0x2d75(0x8)](_0x27abae[_0x2d75(0x47)],_0x70630b),_0x150b09;}}await _0x27abae[_0x2d75(0x48)](storeJWT,_0x4c19a3[_0x2d75(0x1b)]);if(_0x4c19a3[_0x2d75(0x49)]){if(_0x27abae[_0x2d75(0x4a)](_0x27abae['pmpvf'],_0x27abae['VlDZF']))return _0x13dad2[_0x2d75(0x11)](_0x2d75(0x4b),_0x27abae[_0x2d75(0x4c)](_0x3ad0f6,null)||_0x27abae[_0x2d75(0x3e)](_0xe65325,void 0x0)?void 0x0:_0x17c415[_0x2d75(0x4d)]),{'success':![],'message':_0x27abae['mtEqo']};else await AsyncStorage[_0x2d75(0x20)](_0x2d75(0x16),_0x4c19a3[_0x2d75(0x49)]);}return await AsyncStorage[_0x2d75(0x20)](_0x27abae[_0x2d75(0x4e)],_0x3b38b9[_0x2d75(0x1c)]),console[_0x2d75(0x8)](_0x27abae[_0x2d75(0x4f)],_0x4c19a3[_0x2d75(0x1b)][_0x2d75(0x10)](0x0,0x14)+'...'),{'token':_0x4c19a3[_0x2d75(0x1b)],'user':{'id':Date[_0x2d75(0x9)]()[_0x2d75(0x24)](),'name':_0x4c19a3['username'],'email':_0x3b38b9['email'],'profilePicture':''}};}}catch(_0x124c80){console['error'](_0x27abae[_0x2d75(0x50)],_0x124c80);throw _0x124c80;}};function _0x1c71(){const _0x529616=['BASE_URL','✅\x20[AUTH]\x20Found\x20JWT\x20token:','Error\x20getting\x20admin\x20status:','⏳\x20[AUTH]\x20SDK\x20not\x20yet\x20initialized,\x20waiting...','ZDURQ','rMoaE','❌\x20[AUTH]\x20SDK\x20did\x20not\x20initialize\x20within','buuPA','log','now','kaLic','iCKnH','Nfcry','rmBZn','iKTik','sgDIy','substring','error','KSzLG','UWhnE','🔑\x20Authenticating\x20with\x20Onairos...','Onairos\x20User','onairos_username','user_email','👤\x20User\x20info:','sJfph','kpdpY','token','email','split','PXVnk','zCaHA','setItem','ptHwE','...','ksuOG','toString','ywaPj','DlplC','HNDtH','❌\x20[TOKEN\x20VERIFY]\x20Token\x20verification\x20error:','❌\x20Onairos\x20authentication\x20error:','✅\x20[TOKEN\x20VERIFY]\x20Token\x20is\x20valid','admin@enoch.events','admin@onairos.uk','🚫\x20[Admin\x20Check]\x20No\x20admin\x20access\x20for:','pvVnQ','No\x20authentication\x20token\x20returned\x20from\x20Onairos\x20sign-in','gvMRm','KcFMm','🔑\x20Onairos\x20sign-in\x20token\x20stored:','❌\x20Onairos\x20sign-in\x20error:','oZdzY','VTzSq','kdogT','jywQL','/login/signin','LLbCs','stringify','json','Onairos\x20sign-in\x20failed','pkvNj','DsYcn','omUoZ','rnGDD','fhoGg','nicholas.berry@onairos.uk','eWgXj','includes','toLowerCase','🔑\x20[Admin\x20Check]\x20Admin\x20access\x20granted\x20for:','sNvKX','iCjlj','username','WfEhm','❌\x20[CODE\x20VERIFY]\x20Failed\x20to\x20get\x20auth\x20headers:','ctolm','message','yseNq','ZdYEI','opeyC','Error\x20saving\x20Onairos\x20username:','✅\x20Apple\x20authentication\x20successful','🔑\x20Apple\x20auth\x20token\x20stored:','Advdc','fullName','trim','fBHTR','/register/apple','yRgDs','nonce','KHduc','eIqBv','user','YuZIf','LgHxs','bKGAY','apple_','@privaterelay.apple.com','QOVZN','PIled','QQkri','nuBGM','odeanId','isNewUser','JTDoh','hFZOR','AzFth','auth_token','xKWMQ','Error\x20saving\x20auth\x20token:','🔒\x20[Admin\x20Check]\x20No\x20email\x20provided','sdk_jwt_token','auth_method','null','🔑\x20user_email:','🔑\x20onairos_username:','oZRaW','uscmj','getItem','uoRuN','VWMkx','...\x22','QsxGs','hNRcx','iheFI','🔑\x20auth_method:','TXjyM','fTchY','DOzZN','length','iwopJ','multiRemove','fFGyM','vUiow','onairos_user','✅\x20[AUTH]\x20All\x20auth\x20tokens\x20and\x20data\x20cleared','❌\x20[AUTH]\x20Error\x20during\x20token\x20retrieval:','oyAWO','DJMWO','removeItem','IQUPY','HklYl','Error\x20removing\x20auth\x20token:','Otdkv','📧\x20[EMAIL\x20VERIFY]\x20Headers\x20OK,\x20key:','WVNpH','bMfpj','kedXq','xABqG','GVqEH','tBgln','dwKIn','fNGxq','pzWCj','Authorization','snKYq','wBNXa','NsWPi','warn','⚠️\x20[',']\x20No\x20valid\x20authentication\x20available\x20-\x20API\x20call\x20may\x20return\x20limited\x20data','✅\x20[',']\x20Authentication\x20validated\x20for\x20API\x20call','🔒\x20[TOKEN\x20VERIFY]\x20No\x20token\x20available\x20for\x20verification','🔒\x20[TOKEN\x20VERIFY]\x20Verifying\x20token\x20with\x20backend...','🔒\x20[TOKEN\x20VERIFY]\x20Verification\x20response\x20status:','hYIyN','❌\x20[TOKEN\x20VERIFY]\x20Token\x20verification\x20failed:','TLhOK','wDxui','WHayB','PNGev','🔒\x20[TOKEN\x20VERIFY]\x20Token\x20preview:','QlaLq','/api/auth/verify','upuDk','RGPDa','status','TJwzw','text','QJhxh','yqRDC','❌\x20[AUTH\x20VALIDATION]\x20Error\x20checking\x20authentication\x20status:','zion.darko@onairos.uk','WuqWO','EGLpW','fewnR','WHTKu','true','rhnhU','JGdTV','xPlAf','WJvmy','zSBtE','user_admin_status','uKArS','Epagf','Error\x20saving\x20admin\x20status:','unQhj','cryEO','HxWlX','SwWwr','Error\x20getting\x20Onairos\x20username:','ZwqzL','dAEGU','SDK\x20is\x20still\x20initializing.\x20Please\x20wait\x20a\x20moment\x20and\x20try\x20again.','❌\x20[EMAIL\x20VERIFY]\x20Failed\x20to\x20get\x20auth\x20headers:','request','rXlCV','📧\x20[EMAIL\x20VERIFY]\x20Response\x20status:','✅\x20[EMAIL\x20VERIFY]\x20Verification\x20code\x20sent\x20successfully','❌\x20[EMAIL\x20VERIFY]\x20Server\x20error:','Failed\x20to\x20send\x20verification\x20code','TIMEOUT','tICKj','❌\x20[EMAIL\x20VERIFY]\x20All\x20retries\x20exhausted:','Network\x20error.\x20Please\x20check\x20your\x20connection\x20and\x20try\x20again.','/email/verification','DUTsa','gcpbc','sCKLV','kOJVb','TKsRn','KeGvU','NwSrH','bsCSm','BWVdT','UZtjY','BIiAv','YkOLH','📧\x20[EMAIL\x20VERIFY]\x20Attempt\x20','abort','YQRsA','hkkaX','success','TasMS','yoqZl','nJRcd','yxufM','name','NdIBA','❌\x20[EMAIL\x20VERIFY]\x20Attempt\x20','\x20failed:','uMffR','LeOCA','bRPjl','ms...','BeXxz','tekjb','iFCcw','✅\x20[AUTH]\x20SDK\x20initialized\x20after','🔍\x20[CODE\x20VERIFY]\x20Headers\x20OK','szvNO','SDK\x20not\x20properly\x20initialized.\x20Please\x20restart\x20the\x20app\x20and\x20try\x20again.','🔍\x20[CODE\x20VERIFY]\x20Response\x20status:','🔍\x20[CODE\x20VERIFY]\x20Response\x20data:','✅\x20[CODE\x20VERIFY]\x20Email\x20verification\x20successful','❌\x20[CODE\x20VERIFY]\x20Server\x20error:','efURw','pCPIE','Verification\x20failed.\x20Please\x20check\x20your\x20connection\x20and\x20try\x20again.','Verification\x20failed.\x20Please\x20try\x20again.','uHSbe','iNhnY','Gksks','uHqJv','PMmaZ','rVeAY','BTXDx','Ijnox','vfmaY','gVFPW','verify','RFgkG','🔍\x20[CODE\x20VERIFY]\x20Attempt\x20','ZdQuM','signal','pxbtT','xhSYr','jwtToken','iaLLJ','accountInfo','wjMdk','flowType','SntzB','onboarding','xmOBa','nsyXI','userName','enochInstructions','qfaYZ','IobhB','vRKFi','dEaaR','AbortError','❌\x20[CODE\x20VERIFY]\x20Attempt\x20','hTdua','tvgQu','hMEVh','ULyxW','lqVEU','GFzPk','🔄\x20[CODE\x20VERIFY]\x20Retrying\x20in\x20','JeisK','hhoqP','JApdV'];_0x1c71=function(){return _0x529616;};return _0x1c71();}export const authenticateWithApple=async _0x547367=>{const _0x37d923={'AzFth':_0x2d75(0x51),'yXWuK':_0x2d75(0x15),'fBHTR':'🍎\x20Authenticating\x20with\x20Apple\x20via\x20generic\x20SDK\x20endpoint...','yRgDs':function(_0xf9866){return _0xf9866();},'KHduc':_0x2d75(0x52),'kwZgE':'No\x20authentication\x20token\x20returned\x20from\x20Apple\x20auth','OBlPj':function(_0x14fa3e,_0x49853e){return _0x14fa3e(_0x49853e);},'eIqBv':function(_0x59c8b4,_0xd7c635){return _0x59c8b4===_0xd7c635;},'YuZIf':function(_0x4f12f5,_0x3c14d0){return _0x4f12f5===_0x3c14d0;},'LgHxs':'onairos_username','bKGAY':function(_0x59bd1e,_0x3a7c4a){return _0x59bd1e===_0x3a7c4a;},'QOVZN':_0x2d75(0x17),'PIled':_0x2d75(0x53),'QQkri':function(_0x404766,_0x541e13){return _0x404766===_0x541e13;},'nuBGM':function(_0xf1e77c,_0x4a7021){return _0xf1e77c===_0x4a7021;},'JTDoh':_0x2d75(0x54),'hFZOR':'❌\x20Apple\x20authentication\x20error:'};try{var _0x2b8d68,_0x899be3,_0x1c9754,_0x51c029;const _0x351004=_0x547367[_0x2d75(0x55)]?((_0x547367[_0x2d75(0x55)]['givenName']||'')+'\x20'+(_0x547367[_0x2d75(0x55)]['familyName']||''))[_0x2d75(0x56)]():_0x37d923['yXWuK'];console[_0x2d75(0x8)](_0x37d923[_0x2d75(0x57)]);const _0x1c9783=await fetch(API_BASE_URL+_0x2d75(0x58),{'method':'POST','headers':_0x37d923[_0x2d75(0x59)](getApiHeaders),'body':JSON[_0x2d75(0x3a)]({'idToken':_0x547367['identityToken'],'nonce':_0x547367[_0x2d75(0x5a)],'name':_0x351004,'email':_0x547367[_0x2d75(0x1c)]})});if(!_0x1c9783['ok']){const _0x21af60=await _0x1c9783[_0x2d75(0x3b)]();throw new Error(_0x21af60[_0x2d75(0x11)]||'Apple\x20authentication\x20failed');}const _0x3ae3d3=await _0x1c9783[_0x2d75(0x3b)]();console[_0x2d75(0x8)](_0x37d923[_0x2d75(0x5b)]);if(!_0x3ae3d3[_0x2d75(0x1b)])throw new Error(_0x37d923['kwZgE']);await _0x37d923['OBlPj'](storeJWT,_0x3ae3d3[_0x2d75(0x1b)]);const _0x337fa8=(_0x37d923[_0x2d75(0x5c)](_0x2b8d68=_0x3ae3d3[_0x2d75(0x5d)],null)||_0x37d923[_0x2d75(0x5e)](_0x2b8d68,void 0x0)?void 0x0:_0x2b8d68[_0x2d75(0x49)])||_0x3ae3d3[_0x2d75(0x49)]||_0x351004;await AsyncStorage[_0x2d75(0x20)](_0x37d923[_0x2d75(0x5f)],_0x337fa8);const _0x5ac884=(_0x37d923[_0x2d75(0x60)](_0x899be3=_0x3ae3d3[_0x2d75(0x5d)],null)||_0x37d923[_0x2d75(0x5e)](_0x899be3,void 0x0)?void 0x0:_0x899be3[_0x2d75(0x1c)])||_0x547367[_0x2d75(0x1c)]||_0x2d75(0x61)+_0x547367[_0x2d75(0x5d)]+_0x2d75(0x62);return await AsyncStorage[_0x2d75(0x20)](_0x37d923[_0x2d75(0x63)],_0x5ac884),console[_0x2d75(0x8)](_0x37d923[_0x2d75(0x64)],_0x3ae3d3[_0x2d75(0x1b)][_0x2d75(0x10)](0x0,0x14)+_0x2d75(0x22)),{'success':!![],'token':_0x3ae3d3['token'],'user':{'id':((_0x1c9754=_0x3ae3d3[_0x2d75(0x5d)])===null||_0x1c9754===void 0x0?void 0x0:_0x1c9754['id'])||'','odeanId':_0x37d923[_0x2d75(0x65)](_0x51c029=_0x3ae3d3[_0x2d75(0x5d)],null)||_0x37d923[_0x2d75(0x66)](_0x51c029,void 0x0)?void 0x0:_0x51c029[_0x2d75(0x67)],'email':_0x5ac884,'username':_0x337fa8},'isNewUser':_0x3ae3d3[_0x2d75(0x68)]||![]};}catch(_0x19dc64){if(_0x37d923[_0x2d75(0x69)]===_0x37d923['JTDoh']){console[_0x2d75(0x11)](_0x37d923[_0x2d75(0x6a)],_0x19dc64);throw _0x19dc64;}else _0x4ebb8c['error'](_0x37d923[_0x2d75(0x6b)],_0x3a77a4);}};export const saveAuthToken=async _0x1df3bf=>{const _0x3a7a85={'xKWMQ':_0x2d75(0x6c)};try{await AsyncStorage['setItem'](_0x3a7a85[_0x2d75(0x6d)],_0x1df3bf);}catch(_0x179f09){console[_0x2d75(0x11)](_0x2d75(0x6e),_0x179f09);throw _0x179f09;}};export const debugAuthStorage=async()=>{const _0x451972={'fTchY':_0x2d75(0x6f),'NMXyT':'🔍\x20[AUTH\x20STORAGE\x20DEBUG]\x20Checking\x20all\x20auth-related\x20storage:','uscmj':_0x2d75(0x70),'Uddvb':_0x2d75(0x16),'uoRuN':_0x2d75(0x71),'VWMkx':'🔑\x20sdk_jwt_token:','hNRcx':_0x2d75(0x72),'QsxGs':_0x2d75(0x73),'iheFI':_0x2d75(0x74),'DOzZN':function(_0x50f029,_0x440821){return _0x50f029===_0x440821;},'TXjyM':_0x2d75(0x75)};console[_0x2d75(0x8)](_0x451972['NMXyT']);const _0x96706a=await AsyncStorage['getItem'](_0x451972[_0x2d75(0x76)]),_0x47833b=await AsyncStorage[_0x2d75(0x77)](_0x2d75(0x17)),_0x390ca2=await AsyncStorage[_0x2d75(0x77)](_0x451972['Uddvb']),_0x49f351=await AsyncStorage['getItem'](_0x451972[_0x2d75(0x78)]);console[_0x2d75(0x8)](_0x451972[_0x2d75(0x79)],_0x96706a?'\x22'+_0x96706a['substring'](0x0,0x1e)+_0x2d75(0x7a):_0x451972['hNRcx']),console['log'](_0x451972[_0x2d75(0x7b)],_0x47833b?'\x22'+_0x47833b+'\x22':_0x451972[_0x2d75(0x7c)]),console[_0x2d75(0x8)](_0x451972[_0x2d75(0x7d)],_0x390ca2?'\x22'+_0x390ca2+'\x22':_0x451972[_0x2d75(0x7c)]),console['log'](_0x2d75(0x7e),_0x49f351?'\x22'+_0x49f351+'\x22':_0x451972[_0x2d75(0x7c)]);if(_0x96706a){if(_0x451972['DOzZN']('njqLH',_0x451972[_0x2d75(0x7f)]))return _0x51493e['log'](_0x451972[_0x2d75(0x80)]),![];else{const _0x415648=_0x451972[_0x2d75(0x81)](_0x96706a['split']('.')[_0x2d75(0x82)],0x3);console[_0x2d75(0x8)]('🔍\x20Token\x20appears\x20to\x20be\x20valid\x20JWT:',_0x415648);}}};export const clearAllAuthTokens=async()=>{const _0x44a42d={'iwopJ':'🧹\x20[AUTH]\x20Clearing\x20all\x20auth\x20tokens...','fFGyM':_0x2d75(0x17),'ThcGE':_0x2d75(0x16),'vUiow':_0x2d75(0x71)};console['log'](_0x44a42d[_0x2d75(0x83)]),await clearJWT(),await AsyncStorage[_0x2d75(0x84)]([_0x44a42d[_0x2d75(0x85)],_0x44a42d['ThcGE'],_0x44a42d[_0x2d75(0x86)],_0x2d75(0x87)]),console[_0x2d75(0x8)](_0x2d75(0x88));};export const getAuthToken=async()=>{const _0x53dea4={'nJRGV':'❌\x20[AUTH]\x20No\x20valid\x20JWT\x20token\x20found'};try{const _0x3ea9df=await getJWT();if(_0x3ea9df)return console[_0x2d75(0x8)](_0x2d75(0x1),_0x3ea9df[_0x2d75(0x10)](0x0,0x14)+_0x2d75(0x22)),_0x3ea9df;return console['warn'](_0x53dea4['nJRGV']),null;}catch(_0x193dc3){return console['error'](_0x2d75(0x89),_0x193dc3),null;}};export const removeAuthToken=async()=>{const _0x3aa3b1={'Otdkv':_0x2d75(0x33),'IQUPY':'auth_token','HklYl':_0x2d75(0x8a),'rYBLB':_0x2d75(0x8b)};try{await AsyncStorage[_0x2d75(0x8c)](_0x3aa3b1[_0x2d75(0x8d)]);}catch(_0x2dac2f){if(_0x3aa3b1[_0x2d75(0x8e)]!==_0x3aa3b1['rYBLB'])console[_0x2d75(0x11)](_0x2d75(0x8f),_0x2dac2f);else{_0x5accc3['error'](_0x3aa3b1[_0x2d75(0x90)],_0x5dc197);throw _0x5d49a9;}}};export const isAuthenticated=async()=>{const _0x19223f={'TYbwn':_0x2d75(0x91),'fNGxq':function(_0x59a803,_0x574447){return _0x59a803+_0x574447;},'pzWCj':function(_0x18a17b,_0x41f046){return _0x18a17b===_0x41f046;},'snKYq':function(_0x336538,_0x26954d){return _0x336538===_0x26954d;},'bMfpj':function(_0x1d66f8,_0x17f00f){return _0x1d66f8!==_0x17f00f;},'kedXq':'QeHhk','xABqG':_0x2d75(0x92),'GVqEH':function(_0x2b0dad){return _0x2b0dad();},'tBgln':function(_0x435a02,_0x290848){return _0x435a02!==_0x290848;},'dwKIn':function(_0x2b6169,_0x2c8258){return _0x2b6169>_0x2c8258;},'wBNXa':'❌\x20[AUTH\x20VALIDATION]\x20Error\x20checking\x20authentication\x20status:'};try{if(_0x19223f[_0x2d75(0x93)](_0x19223f[_0x2d75(0x94)],_0x19223f[_0x2d75(0x95)])){const _0x368410=await _0x19223f[_0x2d75(0x96)](getAuthToken);return _0x19223f[_0x2d75(0x97)](_0x368410,null)&&_0x19223f[_0x2d75(0x98)](_0x368410[_0x2d75(0x82)],0x32);}else{var _0x5bda9b;_0x5cab58=_0x5300fb(),_0x21d7a8[_0x2d75(0x8)](_0x19223f['TYbwn'],_0x19223f[_0x2d75(0x99)](_0x19223f[_0x2d75(0x9a)](_0x5bda9b=_0xbaa05d[_0x2d75(0x9b)],null)||_0x19223f[_0x2d75(0x9c)](_0x5bda9b,void 0x0)?void 0x0:_0x5bda9b[_0x2d75(0x10)](0x0,0x14),_0x2d75(0x22)));}}catch(_0x5bc1ef){return console[_0x2d75(0x11)](_0x19223f[_0x2d75(0x9d)],_0x5bc1ef),![];}};export const ensureAuthentication=async _0x8b7814=>{const _0x2a732f={'NsWPi':function(_0x4ee805){return _0x4ee805();}},_0x2b91d3=await _0x2a732f[_0x2d75(0x9e)](isAuthenticated);return!_0x2b91d3?console[_0x2d75(0x9f)](_0x2d75(0xa0)+_0x8b7814+_0x2d75(0xa1)):console[_0x2d75(0x8)](_0x2d75(0xa2)+_0x8b7814+_0x2d75(0xa3)),_0x2b91d3;};export const verifyToken=async()=>{const _0x17023b={'WHayB':'❌\x20Apple\x20authentication\x20error:','TLhOK':function(_0xac59ba,_0x587db8){return _0xac59ba!==_0x587db8;},'wDxui':'oljgT','LpVqU':_0x2d75(0xa4),'PNGev':_0x2d75(0xa5),'QlaLq':function(_0xa213ea,_0x247801,_0x3b6c1d){return _0xa213ea(_0x247801,_0x3b6c1d);},'upuDk':function(_0x517bb6,_0x32f036){return _0x517bb6(_0x32f036);},'RGPDa':_0x2d75(0xa6),'mpMOt':function(_0x1879c2,_0x3fcc78){return _0x1879c2!==_0x3fcc78;},'TJwzw':_0x2d75(0xa7),'QJhxh':_0x2d75(0xa8),'yqRDC':_0x2d75(0x28)};try{if(_0x17023b[_0x2d75(0xa9)](_0x17023b[_0x2d75(0xaa)],_0x17023b[_0x2d75(0xaa)])){_0x1722ce['error'](_0x17023b[_0x2d75(0xab)],_0x5eaadc);throw _0x1dbb10;}else{const _0x595e81=await getAuthToken();if(!_0x595e81)return console[_0x2d75(0x9f)](_0x17023b['LpVqU']),![];console[_0x2d75(0x8)](_0x17023b[_0x2d75(0xac)]),console[_0x2d75(0x8)](_0x2d75(0xad),_0x595e81[_0x2d75(0x10)](0x0,0x14)+_0x2d75(0x22));const _0x3ff4ca=await _0x17023b[_0x2d75(0xae)](fetch,API_BASE_URL+_0x2d75(0xaf),{'method':'GET','headers':_0x17023b[_0x2d75(0xb0)](getAuthHeaders,_0x595e81)});console[_0x2d75(0x8)](_0x17023b[_0x2d75(0xb1)],_0x3ff4ca[_0x2d75(0xb2)]);if(_0x3ff4ca['ok'])return _0x17023b['mpMOt'](_0x17023b[_0x2d75(0xb3)],_0x2d75(0xa7))?(_0x500b09[_0x2d75(0x8)]('❌\x20[CODE\x20VERIFY]\x20Server\x20error:',_0x430a12['error']||_0x47f562['message']),{'success':![],'message':_0x744311[_0x2d75(0x11)]||_0x588dc2[_0x2d75(0x4d)]||'Invalid\x20verification\x20code'}):(console[_0x2d75(0x8)](_0x2d75(0x2a)),!![]);else{const _0x10fef4=await _0x3ff4ca[_0x2d75(0xb4)]();return console[_0x2d75(0x9f)](_0x17023b[_0x2d75(0xb5)],_0x3ff4ca[_0x2d75(0xb2)],_0x10fef4),![];}}}catch(_0x307012){return console[_0x2d75(0x11)](_0x17023b[_0x2d75(0xb6)],_0x307012),![];}};export const isAdminEmail=_0x4881c9=>{const _0xab5501={'KRzmM':_0x2d75(0xb7),'WuqWO':_0x2d75(0x6f),'EGLpW':_0x2d75(0x42),'viStp':_0x2d75(0xb8),'fewnR':_0x2d75(0x2b),'WrWmD':_0x2d75(0x2c),'WDOFp':_0x2d75(0x46),'GjaKA':function(_0x24045e,_0x30f6c8){return _0x24045e!==_0x30f6c8;},'WHTKu':'iQkJC'};if(!_0x4881c9)return console[_0x2d75(0x8)](_0xab5501[_0x2d75(0xb9)]),![];const _0x2ae874=[_0xab5501[_0x2d75(0xba)],_0xab5501['viStp'],_0xab5501[_0x2d75(0xbb)],_0xab5501['WrWmD']],_0x7918c6=_0x2ae874[_0x2d75(0x44)](_0x4881c9['toLowerCase']());if(_0x7918c6)console['log'](_0xab5501['WDOFp'],_0x4881c9);else{if(_0xab5501['GjaKA'](_0xab5501[_0x2d75(0xbc)],_0xab5501[_0x2d75(0xbc)]))return _0x3d4fc9['error'](_0xab5501['KRzmM'],_0x2fb02a),![];else console[_0x2d75(0x8)](_0x2d75(0x2d),_0x4881c9);}return _0x7918c6;};export const getAdminStatus=async()=>{const _0x286952={'rhnhU':'user_admin_status','JGdTV':function(_0x1215d6,_0x3f86cc){return _0x1215d6===_0x3f86cc;},'xPlAf':_0x2d75(0xbd),'WJvmy':_0x2d75(0x2)};try{const _0x240209=await AsyncStorage[_0x2d75(0x77)](_0x286952[_0x2d75(0xbe)]);return _0x286952[_0x2d75(0xbf)](_0x240209,_0x286952[_0x2d75(0xc0)]);}catch(_0x4169af){return console[_0x2d75(0x11)](_0x286952[_0x2d75(0xc1)],_0x4169af),![];}};export const saveAdminStatus=async _0x366c8c=>{const _0x39e178={'unQhj':_0x2d75(0x29),'uKArS':function(_0xd0e40,_0x1880ff){return _0xd0e40!==_0x1880ff;},'UEzik':_0x2d75(0xc2),'Epagf':'oTBIW'};try{await AsyncStorage[_0x2d75(0x20)](_0x2d75(0xc3),_0x366c8c[_0x2d75(0x24)]());}catch(_0x236505){if(_0x39e178[_0x2d75(0xc4)](_0x39e178['UEzik'],_0x39e178[_0x2d75(0xc5)]))console[_0x2d75(0x11)](_0x2d75(0xc6),_0x236505);else{_0x4414f9[_0x2d75(0x11)](_0x39e178[_0x2d75(0xc7)],_0x4d6890);throw _0x2cce00;}}};export const getOnairosUsername=async()=>{const _0x108f6f={'SwWwr':_0x2d75(0x8f),'HxWlX':_0x2d75(0xc8)};try{if(_0x108f6f[_0x2d75(0xc9)]!==_0x108f6f['HxWlX'])_0xaedc2e['error'](_0x108f6f[_0x2d75(0xca)],_0x4a67df);else return await AsyncStorage['getItem'](_0x2d75(0x16));}catch(_0x12f892){return console[_0x2d75(0x11)](_0x2d75(0xcb),_0x12f892),null;}};export const saveOnairosUsername=async _0x36d3f3=>{const _0x435868={'ZwqzL':_0x2d75(0x16),'dAEGU':_0x2d75(0x51)};try{await AsyncStorage['setItem'](_0x435868[_0x2d75(0xcc)],_0x36d3f3);}catch(_0x437fb9){console[_0x2d75(0x11)](_0x435868[_0x2d75(0xcd)],_0x437fb9);}};function _0x2d75(_0x1c71de,_0x2d75d4){_0x1c71de=_0x1c71de-0x0;const _0x1722f5=_0x1c71();let _0x16f94a=_0x1722f5[_0x1c71de];return _0x16f94a;}export const sendEmailVerificationCode=async _0x2c4239=>{const _0x3a6bf2={'kOJVb':_0x2d75(0xce),'UvUDl':function(_0x3a0abc){return _0x3a0abc();},'YZdur':'🔍\x20[CODE\x20VERIFY]\x20Headers\x20OK','DUTsa':'📧\x20[EMAIL\x20VERIFY]\x20URL:','BPBrg':function(_0x12457e){return _0x12457e();},'gcpbc':function(_0x1ded1f,_0xca43a){return _0x1ded1f===_0xca43a;},'sCKLV':'xuwvW','TKsRn':_0x2d75(0x91),'KeGvU':function(_0x5c3136,_0x1bc13d){return _0x5c3136+_0x1bc13d;},'NwSrH':_0x2d75(0xcf),'uDMLu':'SDK\x20not\x20properly\x20initialized.\x20Please\x20restart\x20the\x20app\x20and\x20try\x20again.','bsCSm':_0x2d75(0xd0),'BWVdT':function(_0x105c4c,_0x318f92){return _0x105c4c<=_0x318f92;},'UZtjY':'cJBwq','BIiAv':_0x2d75(0xd1),'YkOLH':'dDhBW','JBBYV':'ueCKp','XUyMM':function(_0x4d61fd,_0x27608c,_0x7a0006){return _0x4d61fd(_0x27608c,_0x7a0006);},'YQRsA':function(_0x359ac8,_0xac7bb1){return _0x359ac8(_0xac7bb1);},'hkkaX':_0x2d75(0xd2),'aKDgh':_0x2d75(0xd3),'TasMS':function(_0x12cd46,_0x917af1){return _0x12cd46===_0x917af1;},'yoqZl':'FANNa','nJRcd':_0x2d75(0xd4),'yxufM':_0x2d75(0xd5),'NdIBA':'AbortError','xbNzC':_0x2d75(0xd6),'uMffR':function(_0x2260b6,_0x3e714d){return _0x2260b6===_0x3e714d;},'LeOCA':function(_0x10617a,_0x449087){return _0x10617a<_0x449087;},'ibicq':function(_0x1db418,_0x311209){return _0x1db418===_0x311209;},'cjtyB':_0x2d75(0xd7),'bRPjl':function(_0x1c7edf,_0x2cfa91){return _0x1c7edf*_0x2cfa91;},'BeXxz':_0x2d75(0xd8),'tekjb':_0x2d75(0xd9),'iFCcw':'Network\x20error.\x20Please\x20try\x20again.'},_0x15de90=API_BASE_URL+_0x2d75(0xda);console[_0x2d75(0x8)]('📧\x20[EMAIL\x20VERIFY]\x20Sending\x20verification\x20code\x20to:',_0x2c4239),console['log'](_0x3a6bf2[_0x2d75(0xdb)],_0x15de90);const _0x24cb81=await _0x3a6bf2['BPBrg'](waitForSDKInit);if(!_0x24cb81)return _0x3a6bf2[_0x2d75(0xdc)](_0x3a6bf2[_0x2d75(0xdd)],_0x3a6bf2[_0x2d75(0xdd)])?{'success':![],'message':_0x2d75(0xce)}:{'success':![],'message':_0x3a6bf2[_0x2d75(0xde)]};let _0xfbe252;try{var _0x248522;_0xfbe252=_0x3a6bf2['UvUDl'](getDeveloperAuthHeaders),console[_0x2d75(0x8)](_0x3a6bf2[_0x2d75(0xdf)],_0x3a6bf2[_0x2d75(0xe0)]((_0x248522=_0xfbe252['Authorization'])===null||_0x248522===void 0x0?void 0x0:_0x248522[_0x2d75(0x10)](0x0,0x14),_0x2d75(0x22)));}catch(_0x286f62){return console[_0x2d75(0x11)](_0x3a6bf2[_0x2d75(0xe1)],_0x3a6bf2[_0x2d75(0xdc)](_0x286f62,null)||_0x3a6bf2['gcpbc'](_0x286f62,void 0x0)?void 0x0:_0x286f62[_0x2d75(0x4d)]),{'success':![],'message':_0x3a6bf2['uDMLu']};}const _0x213e15=JSON[_0x2d75(0x3a)]({'email':_0x2c4239,'action':_0x3a6bf2[_0x2d75(0xe2)]}),_0x20e4be=0x3;for(let _0x43dbad=0x1;_0x3a6bf2[_0x2d75(0xe3)](_0x43dbad,_0x20e4be);_0x43dbad++){if(_0x3a6bf2['gcpbc'](_0x3a6bf2[_0x2d75(0xe4)],_0x3a6bf2[_0x2d75(0xe5)]))_0x2db485['error'](_0x2d75(0xc6),_0x382371);else try{if(_0x3a6bf2['gcpbc'](_0x3a6bf2[_0x2d75(0xe6)],_0x3a6bf2['JBBYV']))_0x2cd888=_0x3a6bf2['UvUDl'](_0x1af289),_0xf61135[_0x2d75(0x8)](_0x3a6bf2['YZdur']);else{console[_0x2d75(0x8)](_0x2d75(0xe7)+_0x43dbad+'/'+_0x20e4be+_0x2d75(0x22));const _0x2211c7=new AbortController(),_0x14025a=_0x3a6bf2['XUyMM'](setTimeout,()=>_0x2211c7[_0x2d75(0xe8)](),0x3a98),_0x5b525b=await fetch(_0x15de90,{'method':'POST','headers':_0xfbe252,'body':_0x213e15,'signal':_0x2211c7['signal']});_0x3a6bf2[_0x2d75(0xe9)](clearTimeout,_0x14025a),console[_0x2d75(0x8)](_0x3a6bf2[_0x2d75(0xea)],_0x5b525b[_0x2d75(0xb2)]);const _0x39be43=await _0x5b525b[_0x2d75(0x3b)]();return _0x5b525b['ok']&&_0x39be43[_0x2d75(0xeb)]?(console[_0x2d75(0x8)](_0x3a6bf2['aKDgh']),{'success':!![]}):_0x3a6bf2[_0x2d75(0xec)](_0x3a6bf2[_0x2d75(0xed)],_0x3a6bf2[_0x2d75(0xed)])?(console[_0x2d75(0x8)](_0x3a6bf2[_0x2d75(0xee)],_0x39be43[_0x2d75(0x11)]||_0x39be43['message']),{'success':![],'message':_0x39be43[_0x2d75(0x11)]||_0x39be43[_0x2d75(0x4d)]||_0x3a6bf2[_0x2d75(0xef)]}):(_0x131f82[_0x2d75(0x8)](_0x2d75(0xd3)),{'success':!![]});}}catch(_0x4224ed){const _0x47f431=_0x3a6bf2[_0x2d75(0xec)](_0x4224ed===null||_0x4224ed===void 0x0?void 0x0:_0x4224ed[_0x2d75(0xf0)],_0x3a6bf2[_0x2d75(0xf1)]);console['error'](_0x2d75(0xf2)+_0x43dbad+_0x2d75(0xf3),_0x47f431?_0x3a6bf2['xbNzC']:_0x3a6bf2[_0x2d75(0xf4)](_0x4224ed,null)||_0x3a6bf2[_0x2d75(0xec)](_0x4224ed,void 0x0)?void 0x0:_0x4224ed[_0x2d75(0x4d)]);if(_0x3a6bf2[_0x2d75(0xf5)](_0x43dbad,_0x20e4be)){if(_0x3a6bf2['ibicq'](_0x2d75(0xd7),_0x3a6bf2['cjtyB'])){const _0x519f11=_0x3a6bf2[_0x2d75(0xf6)](0x3e8,_0x43dbad);console[_0x2d75(0x8)]('🔄\x20[EMAIL\x20VERIFY]\x20Retrying\x20in\x20'+_0x519f11+_0x2d75(0xf7)),await new Promise(_0x4a39db=>setTimeout(()=>_0x4a39db(),_0x519f11));continue;}else _0x54e6a8[_0x2d75(0x9f)](_0x2d75(0xa0)+_0x41611d+_0x2d75(0xa1));}return console[_0x2d75(0x11)](_0x3a6bf2[_0x2d75(0xf8)],_0x3a6bf2['uMffR'](_0x4224ed,null)||_0x4224ed===void 0x0?void 0x0:_0x4224ed[_0x2d75(0x4d)]),{'success':![],'message':_0x3a6bf2[_0x2d75(0xf9)]};}}return{'success':![],'message':_0x3a6bf2[_0x2d75(0xfa)]};};export const confirmEmailVerificationCode=async(_0x4dff62,_0x2b9acc)=>{const _0x206000={'vfmaY':_0x2d75(0xfb),'gVFPW':function(_0xd7b018,_0x23a711){return _0xd7b018-_0x23a711;},'rVeAY':function(_0x14ca58,_0x1f62c8){return _0x14ca58===_0x1f62c8;},'lqVEU':'🔍\x20Token\x20appears\x20to\x20be\x20valid\x20JWT:','uHSbe':'🔍\x20[CODE\x20VERIFY]\x20Verifying\x20code\x20for:','iNhnY':function(_0xa895f0){return _0xa895f0();},'Gksks':_0x2d75(0xce),'dRfll':function(_0x356ea7){return _0x356ea7();},'uHqJv':_0x2d75(0xfc),'oJhvM':function(_0xf1198c,_0x3f99a2){return _0xf1198c===_0x3f99a2;},'PMmaZ':_0x2d75(0xfd),'igeNp':_0x2d75(0x4b),'BTXDx':function(_0x1134b6,_0x3febd0){return _0x1134b6===_0x3febd0;},'Ijnox':_0x2d75(0xfe),'RFgkG':function(_0x3ffc71,_0x1f82f9){return _0x3ffc71<=_0x1f82f9;},'ZdQuM':function(_0x56643e,_0x3f6cce,_0x52b0ba){return _0x56643e(_0x3f6cce,_0x52b0ba);},'pxbtT':_0x2d75(0xff),'xhSYr':_0x2d75(0x100),'iaLLJ':_0x2d75(0x101),'wjMdk':function(_0x501e19,_0x28569a){return _0x501e19===_0x28569a;},'SntzB':'returning_user','xmOBa':function(_0x446250,_0x8b0c00){return _0x446250(_0x8b0c00);},'nsyXI':_0x2d75(0x17),'zGByu':_0x2d75(0x16),'WXuua':_0x2d75(0x87),'PWJXp':_0x2d75(0xbd),'qfaYZ':'WRwCd','bvLmi':_0x2d75(0x102),'IobhB':'Invalid\x20verification\x20code','vRKFi':function(_0x21178a,_0x500b10){return _0x21178a===_0x500b10;},'dEaaR':function(_0x586051,_0xacf4b){return _0x586051===_0xacf4b;},'hTdua':_0x2d75(0xd6),'tvgQu':function(_0x1588ca,_0x5bbdbc){return _0x1588ca===_0x5bbdbc;},'kvYtQ':function(_0xaa9e95,_0x3250b7){return _0xaa9e95<_0x3250b7;},'hMEVh':_0x2d75(0x103),'ULyxW':_0x2d75(0x104),'GFzPk':function(_0x12f1e7,_0x34f74d){return _0x12f1e7*_0x34f74d;},'PqlAf':'❌\x20[CODE\x20VERIFY]\x20All\x20retries\x20exhausted:','JeisK':function(_0x1c7029,_0x3aea22){return _0x1c7029===_0x3aea22;},'hhoqP':_0x2d75(0x105),'JApdV':_0x2d75(0x106)};console['log'](_0x206000[_0x2d75(0x107)],_0x4dff62);const _0x3612dd=await _0x206000[_0x2d75(0x108)](waitForSDKInit);if(!_0x3612dd)return{'success':![],'message':_0x206000[_0x2d75(0x109)]};let _0x2225f0;try{_0x2225f0=_0x206000['dRfll'](getDeveloperAuthHeaders),console[_0x2d75(0x8)](_0x206000[_0x2d75(0x10a)]);}catch(_0x21f7aa){return _0x206000['oJhvM'](_0x206000['PMmaZ'],_0x206000[_0x2d75(0x10b)])?(console[_0x2d75(0x11)](_0x206000['igeNp'],_0x206000[_0x2d75(0x10c)](_0x21f7aa,null)||_0x206000[_0x2d75(0x10d)](_0x21f7aa,void 0x0)?void 0x0:_0x21f7aa[_0x2d75(0x4d)]),{'success':![],'message':_0x206000[_0x2d75(0x10e)]}):(_0x4712c6[_0x2d75(0x8)](_0x206000[_0x2d75(0x10f)],_0x206000[_0x2d75(0x110)](_0xb26481['now'](),_0x541e4a),'ms'),!![]);}const _0x2262bd=API_BASE_URL+_0x2d75(0xda),_0x5b681f=JSON[_0x2d75(0x3a)]({'email':_0x4dff62,'code':_0x2b9acc,'action':_0x2d75(0x111)}),_0x42a59d=0x3;for(let _0x2d695e=0x1;_0x206000[_0x2d75(0x112)](_0x2d695e,_0x42a59d);_0x2d695e++){try{console[_0x2d75(0x8)](_0x2d75(0x113)+_0x2d695e+'/'+_0x42a59d+'...');const _0x41353d=new AbortController(),_0x357857=setTimeout(()=>_0x41353d['abort'](),0x3a98),_0x5e40fc=await _0x206000[_0x2d75(0x114)](fetch,_0x2262bd,{'method':'POST','headers':_0x2225f0,'body':_0x5b681f,'signal':_0x41353d[_0x2d75(0x115)]});clearTimeout(_0x357857),console['log'](_0x206000[_0x2d75(0x116)],_0x5e40fc[_0x2d75(0xb2)]);const _0x3e3970=await _0x5e40fc[_0x2d75(0x3b)]();console[_0x2d75(0x8)](_0x206000[_0x2d75(0x117)],JSON[_0x2d75(0x3a)](_0x3e3970));const _0x17ff0f=_0x3e3970[_0x2d75(0x1b)]||_0x3e3970[_0x2d75(0x118)];if(_0x5e40fc['ok']&&_0x3e3970[_0x2d75(0xeb)]&&_0x17ff0f){var _0x2911ad;console[_0x2d75(0x8)](_0x206000[_0x2d75(0x119)]);const _0x32ad21=_0x206000['BTXDx'](_0x3e3970['existingUser'],!![]),_0x2fe6de=!_0x32ad21,_0x1a9d8d=(_0x206000['BTXDx'](_0x2911ad=_0x3e3970[_0x2d75(0x11a)],null)||_0x206000[_0x2d75(0x11b)](_0x2911ad,void 0x0)?void 0x0:_0x2911ad['existingUserData'])||_0x3e3970['existingUserData']||null,_0x166cb9=_0x3e3970[_0x2d75(0x11c)]||(_0x32ad21?_0x206000[_0x2d75(0x11d)]:_0x2d75(0x11e));await _0x206000[_0x2d75(0x11f)](storeJWT,_0x17ff0f),await AsyncStorage[_0x2d75(0x20)](_0x206000[_0x2d75(0x120)],_0x4dff62);const _0xc6903a=_0x3e3970[_0x2d75(0x121)]||_0x3e3970[_0x2d75(0x49)]||_0x4dff62['split']('@')[0x0];return await AsyncStorage['setItem'](_0x206000['zGByu'],_0xc6903a),await AsyncStorage[_0x2d75(0x20)](_0x206000['WXuua'],_0x206000['PWJXp']),{'success':!![],'token':_0x17ff0f,'username':_0xc6903a,'isNewUser':_0x2fe6de,'flowType':_0x166cb9,'existingUserData':_0x1a9d8d,'enochInstructions':_0x3e3970[_0x2d75(0x122)]};}else{if(_0x206000[_0x2d75(0x123)]===_0x206000['qfaYZ'])return console[_0x2d75(0x8)](_0x206000['bvLmi'],_0x3e3970[_0x2d75(0x11)]||_0x3e3970['message']),{'success':![],'message':_0x3e3970[_0x2d75(0x11)]||_0x3e3970[_0x2d75(0x4d)]||_0x206000[_0x2d75(0x124)]};else throw new _0x5378ad('No\x20authentication\x20token\x20returned\x20from\x20Onairos\x20sign-in');}}catch(_0x50c430){const _0x57e55a=_0x206000['oJhvM'](_0x206000[_0x2d75(0x125)](_0x50c430,null)||_0x206000[_0x2d75(0x126)](_0x50c430,void 0x0)?void 0x0:_0x50c430['name'],_0x2d75(0x127));console['error'](_0x2d75(0x128)+_0x2d695e+_0x2d75(0xf3),_0x57e55a?_0x206000[_0x2d75(0x129)]:_0x50c430===null||_0x206000[_0x2d75(0x12a)](_0x50c430,void 0x0)?void 0x0:_0x50c430[_0x2d75(0x4d)]);if(_0x206000['kvYtQ'](_0x2d695e,_0x42a59d)){if(_0x206000[_0x2d75(0x11b)](_0x206000[_0x2d75(0x12b)],_0x206000[_0x2d75(0x12c)])){const _0x33dbec=_0x206000[_0x2d75(0x10c)](_0x523bde[_0x2d75(0x1d)]('.')[_0x2d75(0x82)],0x3);_0x486123['log'](_0x206000[_0x2d75(0x12d)],_0x33dbec);}else{const _0x393012=_0x206000[_0x2d75(0x12e)](0x3e8,_0x2d695e);console['log'](_0x2d75(0x12f)+_0x393012+_0x2d75(0xf7)),await new Promise(_0x15914a=>setTimeout(()=>_0x15914a(),_0x393012));continue;}}return console[_0x2d75(0x11)](_0x206000['PqlAf'],_0x206000[_0x2d75(0x130)](_0x50c430,null)||_0x50c430===void 0x0?void 0x0:_0x50c430[_0x2d75(0x4d)]),{'success':![],'message':_0x206000[_0x2d75(0x131)]};}}return{'success':![],'message':_0x206000[_0x2d75(0x132)]};};
|
|
1
|
+
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
2
|
+
import { API_CONFIG, getApiHeaders, getAuthHeaders } from '../config/api';
|
|
3
|
+
import { getDeveloperAuthHeaders, isApiKeyInitialized } from './apiKeyService';
|
|
4
|
+
// CRITICAL FIX: Use static imports instead of dynamic imports to avoid Hermes transpilation issues
|
|
5
|
+
import { storeJWT, getJWT, clearJWT } from './jwtStorageService';
|
|
6
|
+
|
|
7
|
+
// API base URL
|
|
8
|
+
const API_BASE_URL = API_CONFIG.BASE_URL;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Wait for SDK initialization to complete (up to maxWaitMs).
|
|
12
|
+
* Polls isApiKeyInitialized() every 500ms.
|
|
13
|
+
*/
|
|
14
|
+
const waitForSDKInit = async (maxWaitMs = 8000) => {
|
|
15
|
+
if (isApiKeyInitialized()) return true;
|
|
16
|
+
console.log('⏳ [AUTH] SDK not yet initialized, waiting...');
|
|
17
|
+
const start = Date.now();
|
|
18
|
+
while (Date.now() - start < maxWaitMs) {
|
|
19
|
+
await new Promise(resolve => setTimeout(() => resolve(), 500));
|
|
20
|
+
if (isApiKeyInitialized()) {
|
|
21
|
+
console.log('✅ [AUTH] SDK initialized after', Date.now() - start, 'ms');
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
console.error('❌ [AUTH] SDK did not initialize within', maxWaitMs, 'ms');
|
|
26
|
+
return false;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// Legacy AuthResponse interface - kept for backward compatibility
|
|
30
|
+
// New code should use SDKAuthResponse
|
|
31
|
+
|
|
32
|
+
// Interface for Apple authentication payload
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Generic SDK Authentication Response
|
|
36
|
+
* Used by all auth methods (Google, Apple, Email)
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Authenticate with Apple
|
|
41
|
+
* @param appleAuthData Data from Apple authentication
|
|
42
|
+
* @returns Authentication response with token and user data
|
|
43
|
+
*/
|
|
44
|
+
/**
|
|
45
|
+
* Authenticate with Onairos (similar to Apple authentication)
|
|
46
|
+
* @param onairosAuthData Data from Onairos authentication
|
|
47
|
+
* @returns Authentication response with token and user data
|
|
48
|
+
*/
|
|
49
|
+
export const authenticateWithOnairos = async onairosAuthData => {
|
|
50
|
+
try {
|
|
51
|
+
console.log('🔑 Authenticating with Onairos...');
|
|
52
|
+
|
|
53
|
+
// Store the token using simplified JWT storage
|
|
54
|
+
await storeJWT(onairosAuthData.token);
|
|
55
|
+
|
|
56
|
+
// Extract username from email or use stored username
|
|
57
|
+
const storedUsername = await AsyncStorage.getItem('onairos_username');
|
|
58
|
+
const userName = storedUsername || onairosAuthData.email.split('@')[0] || 'Onairos User';
|
|
59
|
+
|
|
60
|
+
// Store username and email
|
|
61
|
+
await AsyncStorage.setItem('onairos_username', userName);
|
|
62
|
+
await AsyncStorage.setItem('user_email', onairosAuthData.email);
|
|
63
|
+
console.log('🔑 Onairos auth token stored:', `${onairosAuthData.token.substring(0, 20)}...`);
|
|
64
|
+
console.log('👤 User info:', {
|
|
65
|
+
email: onairosAuthData.email,
|
|
66
|
+
username: userName
|
|
67
|
+
});
|
|
68
|
+
return {
|
|
69
|
+
token: onairosAuthData.token,
|
|
70
|
+
user: {
|
|
71
|
+
id: Date.now().toString(),
|
|
72
|
+
name: userName,
|
|
73
|
+
email: onairosAuthData.email,
|
|
74
|
+
profilePicture: ''
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
} catch (error) {
|
|
78
|
+
console.error('❌ Onairos authentication error:', error);
|
|
79
|
+
throw error;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Authenticate with Onairos using the standardized /login/signin endpoint
|
|
85
|
+
* @param credentials Email and password for Onairos sign-in
|
|
86
|
+
* @returns Authentication response with token and user data
|
|
87
|
+
*/
|
|
88
|
+
export const authenticateWithOnairosSignIn = async credentials => {
|
|
89
|
+
try {
|
|
90
|
+
console.log('🔑 Signing in with Onairos via /login/signin endpoint...');
|
|
91
|
+
const response = await fetch(`${API_BASE_URL}/login/signin`, {
|
|
92
|
+
method: 'POST',
|
|
93
|
+
headers: getApiHeaders(),
|
|
94
|
+
body: JSON.stringify(credentials)
|
|
95
|
+
});
|
|
96
|
+
if (!response.ok) {
|
|
97
|
+
const errorData = await response.json();
|
|
98
|
+
throw new Error(errorData.error || 'Onairos sign-in failed');
|
|
99
|
+
}
|
|
100
|
+
const authData = await response.json();
|
|
101
|
+
console.log('✅ Onairos sign-in successful');
|
|
102
|
+
|
|
103
|
+
// Check for authentication token
|
|
104
|
+
if (!authData.token) {
|
|
105
|
+
throw new Error('No authentication token returned from Onairos sign-in');
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Store token using simplified JWT storage
|
|
109
|
+
await storeJWT(authData.token);
|
|
110
|
+
|
|
111
|
+
// Store username from response
|
|
112
|
+
if (authData.username) {
|
|
113
|
+
await AsyncStorage.setItem('onairos_username', authData.username);
|
|
114
|
+
}
|
|
115
|
+
await AsyncStorage.setItem('user_email', credentials.email);
|
|
116
|
+
console.log('🔑 Onairos sign-in token stored:', `${authData.token.substring(0, 20)}...`);
|
|
117
|
+
return {
|
|
118
|
+
token: authData.token,
|
|
119
|
+
user: {
|
|
120
|
+
id: Date.now().toString(),
|
|
121
|
+
name: authData.username,
|
|
122
|
+
email: credentials.email,
|
|
123
|
+
profilePicture: ''
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
} catch (error) {
|
|
127
|
+
console.error('❌ Onairos sign-in error:', error);
|
|
128
|
+
throw error;
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Authenticate with Apple using generic SDK endpoint
|
|
134
|
+
* NOTE: This is generic SDK auth - does NOT create EnochUser
|
|
135
|
+
* Consuming apps should call /enoch/users/register after this if needed
|
|
136
|
+
*/
|
|
137
|
+
export const authenticateWithApple = async appleAuthData => {
|
|
138
|
+
try {
|
|
139
|
+
var _authData$user, _authData$user2, _authData$user3, _authData$user4;
|
|
140
|
+
const userName = appleAuthData.fullName ? `${appleAuthData.fullName.givenName || ''} ${appleAuthData.fullName.familyName || ''}`.trim() : 'Onairos User';
|
|
141
|
+
|
|
142
|
+
// Call the generic Apple authentication endpoint - SDK route, NOT Enoch-specific
|
|
143
|
+
console.log('🍎 Authenticating with Apple via generic SDK endpoint...');
|
|
144
|
+
const appleAuthResponse = await fetch(`${API_BASE_URL}/register/apple`, {
|
|
145
|
+
method: 'POST',
|
|
146
|
+
headers: getApiHeaders(),
|
|
147
|
+
body: JSON.stringify({
|
|
148
|
+
idToken: appleAuthData.identityToken,
|
|
149
|
+
nonce: appleAuthData.nonce,
|
|
150
|
+
name: userName,
|
|
151
|
+
email: appleAuthData.email
|
|
152
|
+
})
|
|
153
|
+
});
|
|
154
|
+
if (!appleAuthResponse.ok) {
|
|
155
|
+
const errorData = await appleAuthResponse.json();
|
|
156
|
+
throw new Error(errorData.error || 'Apple authentication failed');
|
|
157
|
+
}
|
|
158
|
+
const authData = await appleAuthResponse.json();
|
|
159
|
+
console.log('✅ Apple authentication successful');
|
|
160
|
+
|
|
161
|
+
// Check for authentication token
|
|
162
|
+
if (!authData.token) {
|
|
163
|
+
throw new Error('No authentication token returned from Apple auth');
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// Store token using simplified JWT storage
|
|
167
|
+
await storeJWT(authData.token);
|
|
168
|
+
|
|
169
|
+
// Store username from response
|
|
170
|
+
const username = ((_authData$user = authData.user) === null || _authData$user === void 0 ? void 0 : _authData$user.username) || authData.username || userName;
|
|
171
|
+
await AsyncStorage.setItem('onairos_username', username);
|
|
172
|
+
|
|
173
|
+
// Store email - prefer backend's email (correct @placeholder.com format) over Apple's local email
|
|
174
|
+
const userEmail = ((_authData$user2 = authData.user) === null || _authData$user2 === void 0 ? void 0 : _authData$user2.email) || appleAuthData.email || `apple_${appleAuthData.user}@privaterelay.apple.com`;
|
|
175
|
+
await AsyncStorage.setItem('user_email', userEmail);
|
|
176
|
+
console.log('🔑 Apple auth token stored:', `${authData.token.substring(0, 20)}...`);
|
|
177
|
+
return {
|
|
178
|
+
success: true,
|
|
179
|
+
token: authData.token,
|
|
180
|
+
user: {
|
|
181
|
+
id: ((_authData$user3 = authData.user) === null || _authData$user3 === void 0 ? void 0 : _authData$user3.id) || '',
|
|
182
|
+
odeanId: (_authData$user4 = authData.user) === null || _authData$user4 === void 0 ? void 0 : _authData$user4.odeanId,
|
|
183
|
+
email: userEmail,
|
|
184
|
+
username: username
|
|
185
|
+
},
|
|
186
|
+
isNewUser: authData.isNewUser || false
|
|
187
|
+
};
|
|
188
|
+
} catch (error) {
|
|
189
|
+
console.error('❌ Apple authentication error:', error);
|
|
190
|
+
throw error;
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Save authentication token
|
|
196
|
+
* @param token JWT token
|
|
197
|
+
*/
|
|
198
|
+
export const saveAuthToken = async token => {
|
|
199
|
+
try {
|
|
200
|
+
await AsyncStorage.setItem('auth_token', token);
|
|
201
|
+
} catch (error) {
|
|
202
|
+
console.error('Error saving auth token:', error);
|
|
203
|
+
throw error;
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Debug function to check all auth-related storage
|
|
209
|
+
*/
|
|
210
|
+
export const debugAuthStorage = async () => {
|
|
211
|
+
console.log('🔍 [AUTH STORAGE DEBUG] Checking all auth-related storage:');
|
|
212
|
+
const sdkToken = await AsyncStorage.getItem('sdk_jwt_token');
|
|
213
|
+
const userEmail = await AsyncStorage.getItem('user_email');
|
|
214
|
+
const onairosUsername = await AsyncStorage.getItem('onairos_username');
|
|
215
|
+
const authMethod = await AsyncStorage.getItem('auth_method');
|
|
216
|
+
console.log('🔑 sdk_jwt_token:', sdkToken ? `"${sdkToken.substring(0, 30)}..."` : 'null');
|
|
217
|
+
console.log('🔑 user_email:', userEmail ? `"${userEmail}"` : 'null');
|
|
218
|
+
console.log('🔑 onairos_username:', onairosUsername ? `"${onairosUsername}"` : 'null');
|
|
219
|
+
console.log('🔑 auth_method:', authMethod ? `"${authMethod}"` : 'null');
|
|
220
|
+
|
|
221
|
+
// Check if token looks valid
|
|
222
|
+
if (sdkToken) {
|
|
223
|
+
const isValidJWT = sdkToken.split('.').length === 3;
|
|
224
|
+
console.log('🔍 Token appears to be valid JWT:', isValidJWT);
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Clear all auth tokens and start fresh
|
|
230
|
+
*/
|
|
231
|
+
export const clearAllAuthTokens = async () => {
|
|
232
|
+
console.log('🧹 [AUTH] Clearing all auth tokens...');
|
|
233
|
+
await clearJWT();
|
|
234
|
+
|
|
235
|
+
// Clear other auth-related data
|
|
236
|
+
await AsyncStorage.multiRemove(['user_email', 'onairos_username', 'auth_method', 'onairos_user']);
|
|
237
|
+
console.log('✅ [AUTH] All auth tokens and data cleared');
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Get saved authentication token
|
|
242
|
+
* @returns Saved JWT token or null if not found
|
|
243
|
+
*/
|
|
244
|
+
export const getAuthToken = async () => {
|
|
245
|
+
try {
|
|
246
|
+
const token = await getJWT();
|
|
247
|
+
if (token) {
|
|
248
|
+
console.log('✅ [AUTH] Found JWT token:', `${token.substring(0, 20)}...`);
|
|
249
|
+
return token;
|
|
250
|
+
}
|
|
251
|
+
console.warn('❌ [AUTH] No valid JWT token found');
|
|
252
|
+
return null;
|
|
253
|
+
} catch (error) {
|
|
254
|
+
console.error('❌ [AUTH] Error during token retrieval:', error);
|
|
255
|
+
return null;
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Remove authentication token (logout)
|
|
261
|
+
*/
|
|
262
|
+
export const removeAuthToken = async () => {
|
|
263
|
+
try {
|
|
264
|
+
await AsyncStorage.removeItem('auth_token');
|
|
265
|
+
} catch (error) {
|
|
266
|
+
console.error('Error removing auth token:', error);
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Validate if user is properly authenticated
|
|
272
|
+
* @returns boolean indicating if user has valid authentication
|
|
273
|
+
*/
|
|
274
|
+
export const isAuthenticated = async () => {
|
|
275
|
+
try {
|
|
276
|
+
const token = await getAuthToken();
|
|
277
|
+
return token !== null && token.length > 50;
|
|
278
|
+
} catch (error) {
|
|
279
|
+
console.error('❌ [AUTH VALIDATION] Error checking authentication status:', error);
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Ensure authentication is available before making API calls
|
|
286
|
+
* @param apiName - Name of the API being called (for logging)
|
|
287
|
+
* @returns boolean indicating if authentication is available
|
|
288
|
+
*/
|
|
289
|
+
export const ensureAuthentication = async apiName => {
|
|
290
|
+
const isAuth = await isAuthenticated();
|
|
291
|
+
if (!isAuth) {
|
|
292
|
+
console.warn(`⚠️ [${apiName}] No valid authentication available - API call may return limited data`);
|
|
293
|
+
} else {
|
|
294
|
+
console.log(`✅ [${apiName}] Authentication validated for API call`);
|
|
295
|
+
}
|
|
296
|
+
return isAuth;
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
// NOTE: getEnochToken and saveEnochToken have been removed from SDK.
|
|
300
|
+
// SDK now uses a single simplified token. Enoch-specific token management
|
|
301
|
+
// should be handled by the consuming app if needed.
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Verify token with backend
|
|
305
|
+
* @returns Boolean indicating if token is valid
|
|
306
|
+
*/
|
|
307
|
+
export const verifyToken = async () => {
|
|
308
|
+
try {
|
|
309
|
+
const token = await getAuthToken();
|
|
310
|
+
if (!token) {
|
|
311
|
+
console.warn('🔒 [TOKEN VERIFY] No token available for verification');
|
|
312
|
+
return false;
|
|
313
|
+
}
|
|
314
|
+
console.log('🔒 [TOKEN VERIFY] Verifying token with backend...');
|
|
315
|
+
console.log('🔒 [TOKEN VERIFY] Token preview:', `${token.substring(0, 20)}...`);
|
|
316
|
+
const response = await fetch(`${API_BASE_URL}/api/auth/verify`, {
|
|
317
|
+
method: 'GET',
|
|
318
|
+
headers: getAuthHeaders(token)
|
|
319
|
+
});
|
|
320
|
+
console.log('🔒 [TOKEN VERIFY] Verification response status:', response.status);
|
|
321
|
+
if (response.ok) {
|
|
322
|
+
console.log('✅ [TOKEN VERIFY] Token is valid');
|
|
323
|
+
return true;
|
|
324
|
+
} else {
|
|
325
|
+
const errorText = await response.text();
|
|
326
|
+
console.warn('❌ [TOKEN VERIFY] Token verification failed:', response.status, errorText);
|
|
327
|
+
return false;
|
|
328
|
+
}
|
|
329
|
+
} catch (error) {
|
|
330
|
+
console.error('❌ [TOKEN VERIFY] Token verification error:', error);
|
|
331
|
+
return false;
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
// NOTE: getUserProfile, createOrUpdateProfile, and updateUserOnboardedStatus
|
|
336
|
+
// have been removed from SDK - these are Enoch-specific functions.
|
|
337
|
+
// Consuming apps (like OnairosEvents) should call these APIs directly.
|
|
338
|
+
|
|
339
|
+
// NOTE: getEventTimer has been removed from SDK - it's Enoch-specific.
|
|
340
|
+
// Consuming apps (like OnairosEvents) should call /enoch/event/timer directly.
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Check if a user email has admin privileges
|
|
344
|
+
* @param email User email to check
|
|
345
|
+
* @returns True if user is an admin
|
|
346
|
+
*/
|
|
347
|
+
export const isAdminEmail = email => {
|
|
348
|
+
if (!email) {
|
|
349
|
+
console.log('🔒 [Admin Check] No email provided');
|
|
350
|
+
return false;
|
|
351
|
+
}
|
|
352
|
+
const adminEmails = ['nicholas.berry@onairos.uk', 'zion.darko@onairos.uk', 'admin@enoch.events', 'admin@onairos.uk'];
|
|
353
|
+
const isAdmin = adminEmails.includes(email.toLowerCase());
|
|
354
|
+
if (isAdmin) {
|
|
355
|
+
console.log('🔑 [Admin Check] Admin access granted for:', email);
|
|
356
|
+
} else {
|
|
357
|
+
console.log('🚫 [Admin Check] No admin access for:', email);
|
|
358
|
+
}
|
|
359
|
+
return isAdmin;
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Get the current admin status from AsyncStorage
|
|
364
|
+
* This could be used for caching admin status between sessions
|
|
365
|
+
*/
|
|
366
|
+
export const getAdminStatus = async () => {
|
|
367
|
+
try {
|
|
368
|
+
const adminStatus = await AsyncStorage.getItem('user_admin_status');
|
|
369
|
+
return adminStatus === 'true';
|
|
370
|
+
} catch (error) {
|
|
371
|
+
console.error('Error getting admin status:', error);
|
|
372
|
+
return false;
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Save admin status to AsyncStorage
|
|
378
|
+
* @param isAdmin Whether the user is an admin
|
|
379
|
+
*/
|
|
380
|
+
export const saveAdminStatus = async isAdmin => {
|
|
381
|
+
try {
|
|
382
|
+
await AsyncStorage.setItem('user_admin_status', isAdmin.toString());
|
|
383
|
+
} catch (error) {
|
|
384
|
+
console.error('Error saving admin status:', error);
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Get stored Onairos username for API calls
|
|
390
|
+
* This is used for data connector APIs (Reddit, etc.) that need the username
|
|
391
|
+
* @returns Stored username or null if not found
|
|
392
|
+
*/
|
|
393
|
+
export const getOnairosUsername = async () => {
|
|
394
|
+
try {
|
|
395
|
+
return await AsyncStorage.getItem('onairos_username');
|
|
396
|
+
} catch (error) {
|
|
397
|
+
console.error('Error getting Onairos username:', error);
|
|
398
|
+
return null;
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* Save Onairos username for API calls
|
|
404
|
+
* @param username Username to store
|
|
405
|
+
*/
|
|
406
|
+
export const saveOnairosUsername = async username => {
|
|
407
|
+
try {
|
|
408
|
+
await AsyncStorage.setItem('onairos_username', username);
|
|
409
|
+
} catch (error) {
|
|
410
|
+
console.error('Error saving Onairos username:', error);
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Send email verification code
|
|
416
|
+
* @param email Email address to send verification code to
|
|
417
|
+
* @returns Result with success status and optional message
|
|
418
|
+
*/
|
|
419
|
+
export const sendEmailVerificationCode = async email => {
|
|
420
|
+
const url = `${API_BASE_URL}/email/verification`;
|
|
421
|
+
console.log('📧 [EMAIL VERIFY] Sending verification code to:', email);
|
|
422
|
+
console.log('📧 [EMAIL VERIFY] URL:', url);
|
|
423
|
+
|
|
424
|
+
// Wait for SDK to finish initializing (handles race condition)
|
|
425
|
+
const sdkReady = await waitForSDKInit();
|
|
426
|
+
if (!sdkReady) {
|
|
427
|
+
return {
|
|
428
|
+
success: false,
|
|
429
|
+
message: 'SDK is still initializing. Please wait a moment and try again.'
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
let headers;
|
|
433
|
+
try {
|
|
434
|
+
var _headers$Authorizatio;
|
|
435
|
+
headers = getDeveloperAuthHeaders();
|
|
436
|
+
console.log('📧 [EMAIL VERIFY] Headers OK, key:', ((_headers$Authorizatio = headers.Authorization) === null || _headers$Authorizatio === void 0 ? void 0 : _headers$Authorizatio.substring(0, 20)) + '...');
|
|
437
|
+
} catch (headerError) {
|
|
438
|
+
console.error('❌ [EMAIL VERIFY] Failed to get auth headers:', headerError === null || headerError === void 0 ? void 0 : headerError.message);
|
|
439
|
+
return {
|
|
440
|
+
success: false,
|
|
441
|
+
message: 'SDK not properly initialized. Please restart the app and try again.'
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
const body = JSON.stringify({
|
|
445
|
+
email,
|
|
446
|
+
action: 'request'
|
|
447
|
+
});
|
|
448
|
+
const maxRetries = 3;
|
|
449
|
+
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
450
|
+
try {
|
|
451
|
+
console.log(`📧 [EMAIL VERIFY] Attempt ${attempt}/${maxRetries}...`);
|
|
452
|
+
const controller = new AbortController();
|
|
453
|
+
const timeoutId = setTimeout(() => controller.abort(), 15000);
|
|
454
|
+
const response = await fetch(url, {
|
|
455
|
+
method: 'POST',
|
|
456
|
+
headers,
|
|
457
|
+
body,
|
|
458
|
+
signal: controller.signal
|
|
459
|
+
});
|
|
460
|
+
clearTimeout(timeoutId);
|
|
461
|
+
console.log('📧 [EMAIL VERIFY] Response status:', response.status);
|
|
462
|
+
const data = await response.json();
|
|
463
|
+
if (response.ok && data.success) {
|
|
464
|
+
console.log('✅ [EMAIL VERIFY] Verification code sent successfully');
|
|
465
|
+
return {
|
|
466
|
+
success: true
|
|
467
|
+
};
|
|
468
|
+
} else {
|
|
469
|
+
console.log('❌ [EMAIL VERIFY] Server error:', data.error || data.message);
|
|
470
|
+
return {
|
|
471
|
+
success: false,
|
|
472
|
+
message: data.error || data.message || 'Failed to send verification code'
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
} catch (error) {
|
|
476
|
+
const isTimeout = (error === null || error === void 0 ? void 0 : error.name) === 'AbortError';
|
|
477
|
+
console.error(`❌ [EMAIL VERIFY] Attempt ${attempt} failed:`, isTimeout ? 'TIMEOUT' : error === null || error === void 0 ? void 0 : error.message);
|
|
478
|
+
if (attempt < maxRetries) {
|
|
479
|
+
const delay = 1000 * attempt;
|
|
480
|
+
console.log(`🔄 [EMAIL VERIFY] Retrying in ${delay}ms...`);
|
|
481
|
+
await new Promise(resolve => setTimeout(() => resolve(), delay));
|
|
482
|
+
continue;
|
|
483
|
+
}
|
|
484
|
+
console.error('❌ [EMAIL VERIFY] All retries exhausted:', error === null || error === void 0 ? void 0 : error.message);
|
|
485
|
+
return {
|
|
486
|
+
success: false,
|
|
487
|
+
message: 'Network error. Please check your connection and try again.'
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
return {
|
|
492
|
+
success: false,
|
|
493
|
+
message: 'Network error. Please try again.'
|
|
494
|
+
};
|
|
495
|
+
};
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* Confirm email verification code
|
|
499
|
+
* NOTE: This is generic SDK email verification - does NOT create EnochUser
|
|
500
|
+
* Consuming apps should call /enoch/users/register after this if needed
|
|
501
|
+
* @param email Email address that received the code
|
|
502
|
+
* @param code Verification code entered by user
|
|
503
|
+
* @returns Result with success status, optional token, and message
|
|
504
|
+
*/
|
|
505
|
+
export const confirmEmailVerificationCode = async (email, code) => {
|
|
506
|
+
console.log('🔍 [CODE VERIFY] Verifying code for:', email);
|
|
507
|
+
|
|
508
|
+
// Wait for SDK to finish initializing (handles race condition)
|
|
509
|
+
const sdkReady = await waitForSDKInit();
|
|
510
|
+
if (!sdkReady) {
|
|
511
|
+
return {
|
|
512
|
+
success: false,
|
|
513
|
+
message: 'SDK is still initializing. Please wait a moment and try again.'
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
let headers;
|
|
517
|
+
try {
|
|
518
|
+
headers = getDeveloperAuthHeaders();
|
|
519
|
+
console.log('🔍 [CODE VERIFY] Headers OK');
|
|
520
|
+
} catch (headerError) {
|
|
521
|
+
console.error('❌ [CODE VERIFY] Failed to get auth headers:', headerError === null || headerError === void 0 ? void 0 : headerError.message);
|
|
522
|
+
return {
|
|
523
|
+
success: false,
|
|
524
|
+
message: 'SDK not properly initialized. Please restart the app and try again.'
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
const url = `${API_BASE_URL}/email/verification`;
|
|
528
|
+
const body = JSON.stringify({
|
|
529
|
+
email,
|
|
530
|
+
code,
|
|
531
|
+
action: 'verify'
|
|
532
|
+
});
|
|
533
|
+
const maxRetries = 3;
|
|
534
|
+
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
535
|
+
try {
|
|
536
|
+
console.log(`🔍 [CODE VERIFY] Attempt ${attempt}/${maxRetries}...`);
|
|
537
|
+
const controller = new AbortController();
|
|
538
|
+
const timeoutId = setTimeout(() => controller.abort(), 15000);
|
|
539
|
+
const response = await fetch(url, {
|
|
540
|
+
method: 'POST',
|
|
541
|
+
headers,
|
|
542
|
+
body,
|
|
543
|
+
signal: controller.signal
|
|
544
|
+
});
|
|
545
|
+
clearTimeout(timeoutId);
|
|
546
|
+
console.log('🔍 [CODE VERIFY] Response status:', response.status);
|
|
547
|
+
const data = await response.json();
|
|
548
|
+
console.log('🔍 [CODE VERIFY] Response data:', JSON.stringify(data));
|
|
549
|
+
const token = data.token || data.jwtToken;
|
|
550
|
+
if (response.ok && data.success && token) {
|
|
551
|
+
var _data$accountInfo;
|
|
552
|
+
console.log('✅ [CODE VERIFY] Email verification successful');
|
|
553
|
+
const isReturningUser = data.existingUser === true;
|
|
554
|
+
const isNewUser = !isReturningUser;
|
|
555
|
+
const existingUserData = ((_data$accountInfo = data.accountInfo) === null || _data$accountInfo === void 0 ? void 0 : _data$accountInfo.existingUserData) || data.existingUserData || null;
|
|
556
|
+
const flowType = data.flowType || (isReturningUser ? 'returning_user' : 'onboarding');
|
|
557
|
+
await storeJWT(token);
|
|
558
|
+
await AsyncStorage.setItem('user_email', email);
|
|
559
|
+
const username = data.userName || data.username || email.split('@')[0];
|
|
560
|
+
await AsyncStorage.setItem('onairos_username', username);
|
|
561
|
+
await AsyncStorage.setItem('onairos_user', 'true');
|
|
562
|
+
return {
|
|
563
|
+
success: true,
|
|
564
|
+
token,
|
|
565
|
+
username,
|
|
566
|
+
isNewUser,
|
|
567
|
+
flowType,
|
|
568
|
+
existingUserData,
|
|
569
|
+
enochInstructions: data.enochInstructions
|
|
570
|
+
};
|
|
571
|
+
} else {
|
|
572
|
+
console.log('❌ [CODE VERIFY] Server error:', data.error || data.message);
|
|
573
|
+
return {
|
|
574
|
+
success: false,
|
|
575
|
+
message: data.error || data.message || 'Invalid verification code'
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
} catch (error) {
|
|
579
|
+
const isTimeout = (error === null || error === void 0 ? void 0 : error.name) === 'AbortError';
|
|
580
|
+
console.error(`❌ [CODE VERIFY] Attempt ${attempt} failed:`, isTimeout ? 'TIMEOUT' : error === null || error === void 0 ? void 0 : error.message);
|
|
581
|
+
if (attempt < maxRetries) {
|
|
582
|
+
const delay = 1000 * attempt;
|
|
583
|
+
console.log(`🔄 [CODE VERIFY] Retrying in ${delay}ms...`);
|
|
584
|
+
await new Promise(resolve => setTimeout(() => resolve(), delay));
|
|
585
|
+
continue;
|
|
586
|
+
}
|
|
587
|
+
console.error('❌ [CODE VERIFY] All retries exhausted:', error === null || error === void 0 ? void 0 : error.message);
|
|
588
|
+
return {
|
|
589
|
+
success: false,
|
|
590
|
+
message: 'Verification failed. Please check your connection and try again.'
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
return {
|
|
595
|
+
success: false,
|
|
596
|
+
message: 'Verification failed. Please try again.'
|
|
597
|
+
};
|
|
598
|
+
};
|
|
599
|
+
|
|
600
|
+
// NOTE: checkEnochOnairosConnection has been removed from SDK - it's Enoch-specific.
|
|
601
|
+
// Consuming apps (like OnairosEvents) should call /enoch/user/onairos-connection-status directly.
|
|
602
|
+
//# sourceMappingURL=authService.js.map
|