@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,10 +1,627 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
Object[_0x14c4(0x0)](exports,_0x14c4(0x1),{'value':!![]}),exports[_0x14c4(0x2)]=exports['sendEmailVerificationCode']=exports[_0x14c4(0x3)]=exports['saveAuthToken']=exports['saveAdminStatus']=exports[_0x14c4(0x4)]=exports['isAuthenticated']=exports['isAdminEmail']=exports['getOnairosUsername']=exports[_0x14c4(0x5)]=exports[_0x14c4(0x6)]=exports[_0x14c4(0x7)]=exports['debugAuthStorage']=exports[_0x14c4(0x8)]=exports['clearAllAuthTokens']=exports[_0x14c4(0x9)]=exports['authenticateWithOnairos']=exports[_0x14c4(0xa)]=void 0x0;var _asyncStorage=_interopRequireDefault(__ONAIROS_REQ_FUNC__(0x0)),_api=__ONAIROS_REQ_FUNC__(0x1),_apiKeyService=__ONAIROS_REQ_FUNC__(0x2),_jwtStorageService=__ONAIROS_REQ_FUNC__(0x3);function _0x14c4(_0x24332a,_0x14c4f8){_0x24332a=_0x24332a-0x0;const _0x36a994=_0x2433();let _0x1993a8=_0x36a994[_0x24332a];return _0x1993a8;}function _interopRequireDefault(_0xbc2c1b){return _0xbc2c1b&&_0xbc2c1b['__esModule']?_0xbc2c1b:{'default':_0xbc2c1b};}const API_BASE_URL=_api['API_CONFIG']['BASE_URL'],waitForSDKInit=async(_0x2643df=0x1f40)=>{const _0x9fafa1={'UxqYI':'⏳\x20[AUTH]\x20SDK\x20not\x20yet\x20initialized,\x20waiting...','MDlfY':function(_0x38f19b,_0x4f0b07){return _0x38f19b<_0x4f0b07;},'NiQMY':function(_0x16e8cc,_0x42df5c){return _0x16e8cc-_0x42df5c;},'hEcMM':_0x14c4(0xb),'Lljtq':function(_0x37e8e9,_0x13b1ea){return _0x37e8e9-_0x13b1ea;},'WYHdn':_0x14c4(0xc)};if((0x0,_apiKeyService['isApiKeyInitialized'])())return!![];console[_0x14c4(0xd)](_0x9fafa1[_0x14c4(0xe)]);const _0x1468ec=Date['now']();while(_0x9fafa1[_0x14c4(0xf)](_0x9fafa1[_0x14c4(0x10)](Date[_0x14c4(0x11)](),_0x1468ec),_0x2643df)){await new Promise(_0x5e16b0=>setTimeout(()=>_0x5e16b0(),0x1f4));if((0x0,_apiKeyService[_0x14c4(0x12)])())return console[_0x14c4(0xd)](_0x9fafa1[_0x14c4(0x13)],_0x9fafa1[_0x14c4(0x14)](Date['now'](),_0x1468ec),'ms'),!![];}return console[_0x14c4(0x15)](_0x9fafa1['WYHdn'],_0x2643df,'ms'),![];},authenticateWithOnairos=async _0x30beca=>{const _0xc723c5={'JDYKx':'🔒\x20[Admin\x20Check]\x20No\x20email\x20provided','HDusA':_0x14c4(0x16),'wTNkc':_0x14c4(0x17),'xqhZu':_0x14c4(0x18),'fzGET':'admin@onairos.uk','KvenQ':_0x14c4(0x19),'NAdUN':_0x14c4(0x1a),'yzOLR':_0x14c4(0x1b),'WtoXF':_0x14c4(0x1c),'VmQtC':_0x14c4(0x1d),'uyMyy':_0x14c4(0x1e),'VHFCG':'Onairos\x20User','NqsSt':_0x14c4(0x1f),'VHKkY':'🔑\x20Onairos\x20auth\x20token\x20stored:','KLlkf':_0x14c4(0x20),'ImVmn':function(_0x2f7e83,_0xe4a554){return _0x2f7e83===_0xe4a554;},'QAwUt':_0x14c4(0x21),'OOIxB':_0x14c4(0x22)};try{if(_0xc723c5[_0x14c4(0x23)]!==_0xc723c5[_0x14c4(0x24)]){console[_0x14c4(0xd)](_0xc723c5['VmQtC']),await(0x0,_jwtStorageService[_0x14c4(0x25)])(_0x30beca[_0x14c4(0x26)]);const _0x3be847=await _asyncStorage[_0x14c4(0x27)]['getItem'](_0xc723c5[_0x14c4(0x28)]),_0x59c1f7=_0x3be847||_0x30beca['email'][_0x14c4(0x29)]('@')[0x0]||_0xc723c5[_0x14c4(0x2a)];return await _asyncStorage[_0x14c4(0x27)][_0x14c4(0x2b)](_0xc723c5[_0x14c4(0x28)],_0x59c1f7),await _asyncStorage[_0x14c4(0x27)][_0x14c4(0x2b)](_0xc723c5[_0x14c4(0x2c)],_0x30beca[_0x14c4(0x2d)]),console['log'](_0xc723c5[_0x14c4(0x2e)],_0x30beca[_0x14c4(0x26)]['substring'](0x0,0x14)+'...'),console[_0x14c4(0xd)](_0xc723c5[_0x14c4(0x2f)],{'email':_0x30beca[_0x14c4(0x2d)],'username':_0x59c1f7}),{'token':_0x30beca['token'],'user':{'id':Date[_0x14c4(0x11)]()[_0x14c4(0x30)](),'name':_0x59c1f7,'email':_0x30beca[_0x14c4(0x2d)],'profilePicture':''}};}else{if(!_0x188865)return _0x4a18e3[_0x14c4(0xd)](_0xc723c5[_0x14c4(0x31)]),![];const _0x1858cc=[_0xc723c5['HDusA'],_0xc723c5['wTNkc'],_0xc723c5['xqhZu'],_0xc723c5[_0x14c4(0x32)]],_0x252121=_0x1858cc[_0x14c4(0x33)](_0x4d95e9[_0x14c4(0x34)]());return _0x252121?_0x47bed2[_0x14c4(0xd)](_0xc723c5[_0x14c4(0x35)],_0x24e4ea):_0x573cc8['log']('🚫\x20[Admin\x20Check]\x20No\x20admin\x20access\x20for:',_0x1a688c),_0x252121;}}catch(_0x2fb941){if(_0xc723c5[_0x14c4(0x36)](_0xc723c5[_0x14c4(0x37)],'QSnam')){console[_0x14c4(0x15)](_0xc723c5[_0x14c4(0x38)],_0x2fb941);throw _0x2fb941;}else{_0x1d4d9f[_0x14c4(0x15)](_0xc723c5['NAdUN'],_0x401971);throw _0x276c21;}}};exports[_0x14c4(0x39)]=authenticateWithOnairos;const authenticateWithOnairosSignIn=async _0x2fa35c=>{const _0x1bcf6b={'oXwvQ':_0x14c4(0x3a),'nDHlh':function(_0x44d6bd,_0x248a06){return _0x44d6bd!==_0x248a06;},'NRxnG':_0x14c4(0x3b),'QCzIU':function(_0x1fbe26,_0x1c659c,_0x53a11b){return _0x1fbe26(_0x1c659c,_0x53a11b);},'nolGi':_0x14c4(0x3c),'skphi':_0x14c4(0x3d),'JYUfR':'No\x20authentication\x20token\x20returned\x20from\x20Onairos\x20sign-in','pJppX':'onairos_username','CTHPY':'user_email','KCRJR':_0x14c4(0x3e),'ScLZw':_0x14c4(0x3f)};try{if(_0x1bcf6b[_0x14c4(0x40)](_0x1bcf6b['NRxnG'],_0x14c4(0x3b)))return _0x2d9104[_0x14c4(0xd)](_0x1bcf6b[_0x14c4(0x41)]),!![];else{console[_0x14c4(0xd)](_0x14c4(0x42));const _0x3da2c1=await _0x1bcf6b[_0x14c4(0x43)](fetch,API_BASE_URL+_0x14c4(0x44),{'method':'POST','headers':(0x0,_api[_0x14c4(0x45)])(),'body':JSON['stringify'](_0x2fa35c)});if(!_0x3da2c1['ok']){const _0x467171=await _0x3da2c1[_0x14c4(0x46)]();throw new Error(_0x467171[_0x14c4(0x15)]||_0x1bcf6b[_0x14c4(0x47)]);}const _0x302d32=await _0x3da2c1[_0x14c4(0x46)]();console[_0x14c4(0xd)](_0x1bcf6b[_0x14c4(0x48)]);if(!_0x302d32[_0x14c4(0x26)])throw new Error(_0x1bcf6b[_0x14c4(0x49)]);return await(0x0,_jwtStorageService[_0x14c4(0x25)])(_0x302d32[_0x14c4(0x26)]),_0x302d32[_0x14c4(0x4a)]&&await _asyncStorage[_0x14c4(0x27)][_0x14c4(0x2b)](_0x1bcf6b[_0x14c4(0x4b)],_0x302d32[_0x14c4(0x4a)]),await _asyncStorage['default'][_0x14c4(0x2b)](_0x1bcf6b[_0x14c4(0x4c)],_0x2fa35c[_0x14c4(0x2d)]),console[_0x14c4(0xd)](_0x1bcf6b['KCRJR'],_0x302d32[_0x14c4(0x26)]['substring'](0x0,0x14)+_0x14c4(0x4d)),{'token':_0x302d32['token'],'user':{'id':Date['now']()[_0x14c4(0x30)](),'name':_0x302d32[_0x14c4(0x4a)],'email':_0x2fa35c[_0x14c4(0x2d)],'profilePicture':''}};}}catch(_0x29b501){console['error'](_0x1bcf6b['ScLZw'],_0x29b501);throw _0x29b501;}};exports[_0x14c4(0x9)]=authenticateWithOnairosSignIn;const authenticateWithApple=async _0x5a20c1=>{const _0xb252d={'ptWbB':'🍎\x20Authenticating\x20with\x20Apple\x20via\x20generic\x20SDK\x20endpoint...','EjTvL':function(_0x56c767,_0x158e7c,_0x2ab6cb){return _0x56c767(_0x158e7c,_0x2ab6cb);},'bPQSP':_0x14c4(0x4e),'WqlpD':function(_0x2dac75,_0x49a4d4){return _0x2dac75===_0x49a4d4;},'hohIC':_0x14c4(0x1e),'byeru':_0x14c4(0x4f),'YvuSB':function(_0x5378d2,_0x7f24c5){return _0x5378d2===_0x7f24c5;},'cTuFV':_0x14c4(0x1a)};try{var _0x5cefed,_0x59e96e,_0x446a39,_0x3d9c12;const _0x3c21b8=_0x5a20c1[_0x14c4(0x50)]?((_0x5a20c1['fullName']['givenName']||'')+'\x20'+(_0x5a20c1[_0x14c4(0x50)]['familyName']||''))['trim']():'Onairos\x20User';console[_0x14c4(0xd)](_0xb252d[_0x14c4(0x51)]);const _0x1017bc=await _0xb252d[_0x14c4(0x52)](fetch,API_BASE_URL+_0x14c4(0x53),{'method':'POST','headers':(0x0,_api[_0x14c4(0x45)])(),'body':JSON[_0x14c4(0x54)]({'idToken':_0x5a20c1[_0x14c4(0x55)],'nonce':_0x5a20c1[_0x14c4(0x56)],'name':_0x3c21b8,'email':_0x5a20c1['email']})});if(!_0x1017bc['ok']){const _0x2fdb7b=await _0x1017bc[_0x14c4(0x46)]();throw new Error(_0x2fdb7b[_0x14c4(0x15)]||'Apple\x20authentication\x20failed');}const _0x2f6c90=await _0x1017bc[_0x14c4(0x46)]();console[_0x14c4(0xd)]('✅\x20Apple\x20authentication\x20successful');if(!_0x2f6c90['token'])throw new Error(_0xb252d['bPQSP']);await(0x0,_jwtStorageService[_0x14c4(0x25)])(_0x2f6c90[_0x14c4(0x26)]);const _0x2bcbc4=((_0x5cefed=_0x2f6c90[_0x14c4(0x57)])===null||_0xb252d[_0x14c4(0x58)](_0x5cefed,void 0x0)?void 0x0:_0x5cefed[_0x14c4(0x4a)])||_0x2f6c90[_0x14c4(0x4a)]||_0x3c21b8;await _asyncStorage['default'][_0x14c4(0x2b)](_0xb252d[_0x14c4(0x59)],_0x2bcbc4);const _0x26933c=((_0x59e96e=_0x2f6c90[_0x14c4(0x57)])===null||_0x59e96e===void 0x0?void 0x0:_0x59e96e[_0x14c4(0x2d)])||_0x5a20c1[_0x14c4(0x2d)]||_0x14c4(0x5a)+_0x5a20c1['user']+_0x14c4(0x5b);return await _asyncStorage['default'][_0x14c4(0x2b)](_0x14c4(0x1f),_0x26933c),console['log'](_0xb252d[_0x14c4(0x5c)],_0x2f6c90[_0x14c4(0x26)]['substring'](0x0,0x14)+_0x14c4(0x4d)),{'success':!![],'token':_0x2f6c90[_0x14c4(0x26)],'user':{'id':(_0xb252d[_0x14c4(0x58)](_0x446a39=_0x2f6c90['user'],null)||_0xb252d[_0x14c4(0x58)](_0x446a39,void 0x0)?void 0x0:_0x446a39['id'])||'','odeanId':(_0x3d9c12=_0x2f6c90[_0x14c4(0x57)])===null||_0xb252d[_0x14c4(0x5d)](_0x3d9c12,void 0x0)?void 0x0:_0x3d9c12[_0x14c4(0x5e)],'email':_0x26933c,'username':_0x2bcbc4},'isNewUser':_0x2f6c90['isNewUser']||![]};}catch(_0x57b648){console['error'](_0xb252d['cTuFV'],_0x57b648);throw _0x57b648;}};exports[_0x14c4(0xa)]=authenticateWithApple;const saveAuthToken=async _0x4a1ff8=>{const _0x397d5b={'FnQWn':'auth_token','XqEuP':function(_0x271827,_0xbd9ac0){return _0x271827===_0xbd9ac0;},'JOwBj':_0x14c4(0x5f),'dXxRu':'tqxIo','TEIzj':_0x14c4(0x60)};try{await _asyncStorage[_0x14c4(0x27)]['setItem'](_0x397d5b[_0x14c4(0x61)],_0x4a1ff8);}catch(_0x3371b0){if(_0x397d5b[_0x14c4(0x62)](_0x397d5b['JOwBj'],_0x397d5b[_0x14c4(0x63)]))_0x715137=(0x0,_0x26e745[_0x14c4(0x64)])(),_0x360e5c['log']('🔍\x20[CODE\x20VERIFY]\x20Headers\x20OK');else{console[_0x14c4(0x15)](_0x397d5b[_0x14c4(0x65)],_0x3371b0);throw _0x3371b0;}}};exports[_0x14c4(0x66)]=saveAuthToken;const debugAuthStorage=async()=>{const _0xd97480={'oUzgK':_0x14c4(0x67),'YDcOK':_0x14c4(0x68),'diExC':'user_email','eiypW':_0x14c4(0x69),'taIUI':_0x14c4(0x6a),'LKZqK':'🔑\x20user_email:','xptzY':_0x14c4(0x6b),'LmGIs':'🔑\x20onairos_username:','lPWWX':function(_0x40a89e,_0x261393){return _0x40a89e===_0x261393;},'KIJSi':_0x14c4(0x6c)};console[_0x14c4(0xd)](_0xd97480[_0x14c4(0x6d)]);const _0x154fde=await _asyncStorage['default'][_0x14c4(0x6e)](_0xd97480['YDcOK']),_0x5814c0=await _asyncStorage[_0x14c4(0x27)][_0x14c4(0x6e)](_0xd97480['diExC']),_0xf808ca=await _asyncStorage[_0x14c4(0x27)][_0x14c4(0x6e)]('onairos_username'),_0x4b236a=await _asyncStorage[_0x14c4(0x27)]['getItem'](_0xd97480[_0x14c4(0x6f)]);console[_0x14c4(0xd)](_0xd97480[_0x14c4(0x70)],_0x154fde?'\x22'+_0x154fde[_0x14c4(0x71)](0x0,0x1e)+'...\x22':_0x14c4(0x6b)),console[_0x14c4(0xd)](_0xd97480[_0x14c4(0x72)],_0x5814c0?'\x22'+_0x5814c0+'\x22':_0xd97480[_0x14c4(0x73)]),console['log'](_0xd97480[_0x14c4(0x74)],_0xf808ca?'\x22'+_0xf808ca+'\x22':_0xd97480[_0x14c4(0x73)]),console[_0x14c4(0xd)](_0x14c4(0x75),_0x4b236a?'\x22'+_0x4b236a+'\x22':_0xd97480[_0x14c4(0x73)]);if(_0x154fde){const _0x4eda92=_0xd97480['lPWWX'](_0x154fde[_0x14c4(0x29)]('.')['length'],0x3);console[_0x14c4(0xd)](_0xd97480[_0x14c4(0x76)],_0x4eda92);}};exports[_0x14c4(0x77)]=debugAuthStorage;const clearAllAuthTokens=async()=>{const _0x41fc29={'HsrTi':_0x14c4(0x78),'CEApW':_0x14c4(0x1f),'Gedlz':_0x14c4(0x69),'nFhqT':_0x14c4(0x79),'MgmNt':'✅\x20[AUTH]\x20All\x20auth\x20tokens\x20and\x20data\x20cleared'};console[_0x14c4(0xd)](_0x41fc29[_0x14c4(0x7a)]),await(0x0,_jwtStorageService['clearJWT'])(),await _asyncStorage['default'][_0x14c4(0x7b)]([_0x41fc29['CEApW'],_0x14c4(0x1e),_0x41fc29[_0x14c4(0x7c)],_0x41fc29['nFhqT']]),console[_0x14c4(0xd)](_0x41fc29[_0x14c4(0x7d)]);};exports[_0x14c4(0x7e)]=clearAllAuthTokens;const getAuthToken=async()=>{const _0xcc0d39={'hDfMI':'✅\x20[AUTH]\x20Found\x20JWT\x20token:','SdkiB':_0x14c4(0x7f),'mJsnA':_0x14c4(0x80)};try{const _0x2f8231=await(0x0,_jwtStorageService[_0x14c4(0x81)])();if(_0x2f8231)return console[_0x14c4(0xd)](_0xcc0d39[_0x14c4(0x82)],_0x2f8231['substring'](0x0,0x14)+_0x14c4(0x4d)),_0x2f8231;return console[_0x14c4(0x83)](_0xcc0d39[_0x14c4(0x84)]),null;}catch(_0x48d5bf){return console['error'](_0xcc0d39[_0x14c4(0x85)],_0x48d5bf),null;}};function _0x2433(){const _0x4c05e7=['defineProperty','__esModule','verifyToken','saveOnairosUsername','removeAuthToken','getAuthToken','getAdminStatus','ensureAuthentication','confirmEmailVerificationCode','authenticateWithOnairosSignIn','authenticateWithApple','✅\x20[AUTH]\x20SDK\x20initialized\x20after','❌\x20[AUTH]\x20SDK\x20did\x20not\x20initialize\x20within','log','UxqYI','MDlfY','NiQMY','now','isApiKeyInitialized','hEcMM','Lljtq','error','nicholas.berry@onairos.uk','zion.darko@onairos.uk','admin@enoch.events','🔑\x20[Admin\x20Check]\x20Admin\x20access\x20granted\x20for:','❌\x20Apple\x20authentication\x20error:','SvoKK','JjnDn','🔑\x20Authenticating\x20with\x20Onairos...','onairos_username','user_email','👤\x20User\x20info:','QSnam','❌\x20Onairos\x20authentication\x20error:','yzOLR','WtoXF','storeJWT','token','default','uyMyy','split','VHFCG','setItem','NqsSt','email','VHKkY','KLlkf','toString','JDYKx','fzGET','includes','toLowerCase','KvenQ','ImVmn','QAwUt','OOIxB','authenticateWithOnairos','✅\x20[TOKEN\x20VERIFY]\x20Token\x20is\x20valid','kBNQH','Onairos\x20sign-in\x20failed','✅\x20Onairos\x20sign-in\x20successful','🔑\x20Onairos\x20sign-in\x20token\x20stored:','❌\x20Onairos\x20sign-in\x20error:','nDHlh','oXwvQ','🔑\x20Signing\x20in\x20with\x20Onairos\x20via\x20/login/signin\x20endpoint...','QCzIU','/login/signin','getApiHeaders','json','nolGi','skphi','JYUfR','username','pJppX','CTHPY','...','No\x20authentication\x20token\x20returned\x20from\x20Apple\x20auth','🔑\x20Apple\x20auth\x20token\x20stored:','fullName','ptWbB','EjTvL','/register/apple','stringify','identityToken','nonce','user','WqlpD','hohIC','apple_','@privaterelay.apple.com','byeru','YvuSB','odeanId','Hiqqm','Error\x20saving\x20auth\x20token:','FnQWn','XqEuP','dXxRu','getDeveloperAuthHeaders','TEIzj','saveAuthToken','🔍\x20[AUTH\x20STORAGE\x20DEBUG]\x20Checking\x20all\x20auth-related\x20storage:','sdk_jwt_token','auth_method','🔑\x20sdk_jwt_token:','null','🔍\x20Token\x20appears\x20to\x20be\x20valid\x20JWT:','oUzgK','getItem','eiypW','taIUI','substring','LKZqK','xptzY','LmGIs','🔑\x20auth_method:','KIJSi','debugAuthStorage','🧹\x20[AUTH]\x20Clearing\x20all\x20auth\x20tokens...','onairos_user','HsrTi','multiRemove','Gedlz','MgmNt','clearAllAuthTokens','❌\x20[AUTH]\x20No\x20valid\x20JWT\x20token\x20found','❌\x20[AUTH]\x20Error\x20during\x20token\x20retrieval:','getJWT','hDfMI','warn','SdkiB','mJsnA','removeItem','auth_token','emWse','tXVqI','❌\x20[AUTH\x20VALIDATION]\x20Error\x20checking\x20authentication\x20status:','ixQaf','PVsQT','WHdRk','length','✅\x20[EMAIL\x20VERIFY]\x20Verification\x20code\x20sent\x20successfully','ANOVW','isAuthenticated','aEhKI','GmFbw','yEJfR','⚠️\x20[',']\x20No\x20valid\x20authentication\x20available\x20-\x20API\x20call\x20may\x20return\x20limited\x20data','✅\x20[',']\x20Authentication\x20validated\x20for\x20API\x20call','❌\x20[EMAIL\x20VERIFY]\x20Server\x20error:','Failed\x20to\x20send\x20verification\x20code','vZbYV','🔒\x20[TOKEN\x20VERIFY]\x20No\x20token\x20available\x20for\x20verification','🔒\x20[TOKEN\x20VERIFY]\x20Verifying\x20token\x20with\x20backend...','🔒\x20[TOKEN\x20VERIFY]\x20Verification\x20response\x20status:','NSDkH','aGoLU','❌\x20[TOKEN\x20VERIFY]\x20Token\x20verification\x20failed:','❌\x20[TOKEN\x20VERIFY]\x20Token\x20verification\x20error:','LQNKz','JVzbt','itHsB','No\x20authentication\x20token\x20returned\x20from\x20Onairos\x20sign-in','uVZao','dBBTD','/api/auth/verify','getAuthHeaders','status','YuTWp','QKfZK','pBweO','message','QvdAe','ncXkU','zFihp','text','iPUza','🚫\x20[Admin\x20Check]\x20No\x20admin\x20access\x20for:','mCMcI','🔒\x20[Admin\x20Check]\x20No\x20email\x20provided','admin@onairos.uk','YCzTD','LyhsR','OhPPy','tWxMf','bsiJy','nHWQC','Svkto','FqMSg','wYYoV','Rltmn','isAdminEmail','Error\x20getting\x20Onairos\x20username:','user_admin_status','ftAWy','uOUAw','HHMIc','MEPIw','UCMEI','Error\x20saving\x20admin\x20status:','Error\x20removing\x20auth\x20token:','GunDx','GrzQv','JAeDF','getOnairosUsername','CzTOB','Error\x20saving\x20Onairos\x20username:','ZYQMs','dhpTn','uMsQB','📧\x20[EMAIL\x20VERIFY]\x20Sending\x20verification\x20code\x20to:','📧\x20[EMAIL\x20VERIFY]\x20URL:','SDK\x20is\x20still\x20initializing.\x20Please\x20wait\x20a\x20moment\x20and\x20try\x20again.','Wluhm','XjuGX','VyvoA','❌\x20[EMAIL\x20VERIFY]\x20Failed\x20to\x20get\x20auth\x20headers:','request','CvdTq','📧\x20[EMAIL\x20VERIFY]\x20Response\x20status:','pyOiR','eGbnk','bwonu','/email/verification','ulJhT','PoJVg','BHRwA','BAZnd','RqFvN','Yxtwq','Ccvcf','ERsLh','OyUnQ','PfyRD','Authorization','aKjLb','blyTl','hwfAZ','LlSwB','SDK\x20not\x20properly\x20initialized.\x20Please\x20restart\x20the\x20app\x20and\x20try\x20again.','XeqGx','nvfid','sSJBZ','rxLfg','📧\x20[EMAIL\x20VERIFY]\x20Attempt\x20','abort','signal','hgKco','cpKCU','lNMii','miUtU','tJcDR','diPDZ','pvhXt','name','pyGJJ','\x20failed:','TIMEOUT','Trccm','nDFvf','sVGPN','JlqtT','nRiIx','lnsBP','eXpza','❌\x20[CODE\x20VERIFY]\x20Server\x20error:','🔍\x20[CODE\x20VERIFY]\x20Verifying\x20code\x20for:','VKBGK','🔍\x20[CODE\x20VERIFY]\x20Headers\x20OK','jpPZM','CjAHI','fzzVP','uOcJq','✅\x20[CODE\x20VERIFY]\x20Email\x20verification\x20successful','returning_user','onboarding','ceemq','Verification\x20failed.\x20Please\x20check\x20your\x20connection\x20and\x20try\x20again.','Verification\x20failed.\x20Please\x20try\x20again.','DNMbD','CqrEg','POuXv','nkUVV','GPWuD','DSApt','HuJWH','📧\x20[EMAIL\x20VERIFY]\x20Headers\x20OK,\x20key:','sXoqc','FNjYT','IClsH','VVijz','verify','roeya','nspxg','RsLFN','bZyeC','🔍\x20[CODE\x20VERIFY]\x20Attempt\x20','EcQyn','Xpdkg','🔍\x20[CODE\x20VERIFY]\x20Response\x20status:','NggMX','jwtToken','enLid','ttjNS','lkIjE','existingUser','accountInfo','existingUserData','ZiTUz','umczU','FYcWR','userName','IYOVE','enochInstructions','zyykr','Invalid\x20verification\x20code','qwhaE','MLYjk','Rqxbi','pVEkE','HRUtk','ms...','CeFaJ','HUeYh'];_0x2433=function(){return _0x4c05e7;};return _0x2433();}exports[_0x14c4(0x5)]=getAuthToken;const removeAuthToken=async()=>{const _0x4183e8={'emWse':'Error\x20removing\x20auth\x20token:'};try{await _asyncStorage['default'][_0x14c4(0x86)](_0x14c4(0x87));}catch(_0x4da6f4){console[_0x14c4(0x15)](_0x4183e8[_0x14c4(0x88)],_0x4da6f4);}};exports[_0x14c4(0x4)]=removeAuthToken;const isAuthenticated=async()=>{const _0x29eeec={'WHdRk':function(_0x42c4d3,_0x2b943b){return _0x42c4d3!==_0x2b943b;},'ixQaf':_0x14c4(0x89),'mXnwx':function(_0x3b124a,_0x101120){return _0x3b124a>_0x101120;},'ANOVW':_0x14c4(0x8a)};try{if(_0x29eeec['WHdRk'](_0x29eeec[_0x14c4(0x8b)],_0x14c4(0x8c))){const _0x287851=await getAuthToken();return _0x29eeec[_0x14c4(0x8d)](_0x287851,null)&&_0x29eeec['mXnwx'](_0x287851[_0x14c4(0x8e)],0x32);}else return _0x372717[_0x14c4(0xd)](_0x14c4(0x8f)),{'success':!![]};}catch(_0x1a2876){return console[_0x14c4(0x15)](_0x29eeec[_0x14c4(0x90)],_0x1a2876),![];}};exports[_0x14c4(0x91)]=isAuthenticated;const ensureAuthentication=async _0x3b1ac3=>{const _0x4f4486={'yEJfR':'Error\x20saving\x20Onairos\x20username:','uaeuw':function(_0x365d23,_0x29429a){return _0x365d23!==_0x29429a;},'GmFbw':_0x14c4(0x92)},_0x119007=await isAuthenticated();return!_0x119007?_0x4f4486['uaeuw'](_0x4f4486[_0x14c4(0x93)],_0x4f4486[_0x14c4(0x93)])?_0x110615[_0x14c4(0x15)](_0x4f4486[_0x14c4(0x94)],_0x59327d):console[_0x14c4(0x83)](_0x14c4(0x95)+_0x3b1ac3+_0x14c4(0x96)):console[_0x14c4(0xd)](_0x14c4(0x97)+_0x3b1ac3+_0x14c4(0x98)),_0x119007;};exports[_0x14c4(0x7)]=ensureAuthentication;const verifyToken=async()=>{const _0x3f4572={'FnRXh':_0x14c4(0x99),'QvdAe':_0x14c4(0x9a),'zFihp':_0x14c4(0x22),'LQNKz':function(_0x2cb345){return _0x2cb345();},'JVzbt':_0x14c4(0x9b),'itHsB':'fhbFQ','HZPZZ':_0x14c4(0x9c),'uVZao':_0x14c4(0x9d),'dBBTD':'🔒\x20[TOKEN\x20VERIFY]\x20Token\x20preview:','aRBsv':_0x14c4(0x9e),'YuTWp':function(_0x21e5ea,_0x272c4c){return _0x21e5ea===_0x272c4c;},'QKfZK':_0x14c4(0x9f),'pBweO':_0x14c4(0x3a),'ncXkU':_0x14c4(0xa0),'iPUza':_0x14c4(0xa1),'FSlNo':_0x14c4(0xa2)};try{const _0xe0c806=await _0x3f4572[_0x14c4(0xa3)](getAuthToken);if(!_0xe0c806){if(_0x3f4572[_0x14c4(0xa4)]===_0x3f4572[_0x14c4(0xa5)])throw new _0x2d1112(_0x14c4(0xa6));else return console[_0x14c4(0x83)](_0x3f4572['HZPZZ']),![];}console[_0x14c4(0xd)](_0x3f4572[_0x14c4(0xa7)]),console['log'](_0x3f4572[_0x14c4(0xa8)],_0xe0c806['substring'](0x0,0x14)+_0x14c4(0x4d));const _0x57df44=await fetch(API_BASE_URL+_0x14c4(0xa9),{'method':'GET','headers':(0x0,_api[_0x14c4(0xaa)])(_0xe0c806)});console['log'](_0x3f4572['aRBsv'],_0x57df44[_0x14c4(0xab)]);if(_0x57df44['ok'])return _0x3f4572[_0x14c4(0xac)](_0x3f4572[_0x14c4(0xad)],_0x14c4(0x9f))?(console['log'](_0x3f4572[_0x14c4(0xae)]),!![]):(_0x59a7ec[_0x14c4(0xd)](_0x3f4572['FnRXh'],_0x114210[_0x14c4(0x15)]||_0x2b179e[_0x14c4(0xaf)]),{'success':![],'message':_0x5d95e1[_0x14c4(0x15)]||_0x5498a4['message']||_0x3f4572[_0x14c4(0xb0)]});else{if(_0x3f4572[_0x14c4(0xb1)]!==_0x3f4572[_0x14c4(0xb1)]){_0x340d13[_0x14c4(0x15)](_0x3f4572[_0x14c4(0xb2)],_0x16ab2d);throw _0x553bb4;}else{const _0x1165e3=await _0x57df44[_0x14c4(0xb3)]();return console[_0x14c4(0x83)](_0x3f4572[_0x14c4(0xb4)],_0x57df44['status'],_0x1165e3),![];}}}catch(_0x4d8fd5){return console[_0x14c4(0x15)](_0x3f4572['FSlNo'],_0x4d8fd5),![];}};exports[_0x14c4(0x2)]=verifyToken;const isAdminEmail=_0x110c3a=>{const _0x54390b={'tWxMf':'✅\x20[AUTH]\x20SDK\x20initialized\x20after','Rltmn':_0x14c4(0xb5),'OhPPy':_0x14c4(0xb6),'kbHKc':_0x14c4(0xb7),'bsiJy':_0x14c4(0x16),'Fedxg':_0x14c4(0x18),'nHWQC':_0x14c4(0xb8),'ztrzj':_0x14c4(0x19),'Svkto':function(_0x56871f,_0x2ef1d6){return _0x56871f!==_0x2ef1d6;},'wYYoV':_0x14c4(0xb9)};if(!_0x110c3a)return _0x14c4(0xba)===_0x54390b[_0x14c4(0xbb)]?(_0x2b31ea['log'](_0x54390b[_0x14c4(0xbc)],_0x27d75f['now']()-_0x225793,'ms'),!![]):(console['log'](_0x54390b['kbHKc']),![]);const _0x54bff4=[_0x54390b[_0x14c4(0xbd)],_0x14c4(0x17),_0x54390b['Fedxg'],_0x54390b[_0x14c4(0xbe)]],_0x1ca42f=_0x54bff4['includes'](_0x110c3a['toLowerCase']());return _0x1ca42f?console[_0x14c4(0xd)](_0x54390b['ztrzj'],_0x110c3a):_0x54390b[_0x14c4(0xbf)](_0x14c4(0xc0),_0x54390b[_0x14c4(0xc1)])?console['log'](_0x54390b[_0x14c4(0xc2)],_0x110c3a):_0x2a987f[_0x14c4(0xd)](_0x54390b[_0x14c4(0xc2)],_0x1e24ae),_0x1ca42f;};exports[_0x14c4(0xc3)]=isAdminEmail;const getAdminStatus=async()=>{const _0x56bc94={'OmBEb':_0x14c4(0xc4),'uOUAw':_0x14c4(0xc5),'HHMIc':'true','MEPIw':function(_0x3be6e8,_0x735488){return _0x3be6e8===_0x735488;},'UCMEI':_0x14c4(0xc6),'XmIkS':'Error\x20getting\x20admin\x20status:'};try{const _0x188698=await _asyncStorage[_0x14c4(0x27)][_0x14c4(0x6e)](_0x56bc94[_0x14c4(0xc7)]);return _0x188698===_0x56bc94[_0x14c4(0xc8)];}catch(_0x5a86ce){return _0x56bc94[_0x14c4(0xc9)](_0x56bc94[_0x14c4(0xca)],_0x56bc94['UCMEI'])?(console['error'](_0x56bc94['XmIkS'],_0x5a86ce),![]):(_0x4625d9['error'](_0x56bc94['OmBEb'],_0x487332),null);}};exports['getAdminStatus']=getAdminStatus;const saveAdminStatus=async _0x377316=>{const _0x33917b={'SuGhB':_0x14c4(0xc5),'ryzyM':_0x14c4(0xcb)};try{await _asyncStorage[_0x14c4(0x27)][_0x14c4(0x2b)](_0x33917b['SuGhB'],_0x377316[_0x14c4(0x30)]());}catch(_0x4973d0){console['error'](_0x33917b['ryzyM'],_0x4973d0);}};exports['saveAdminStatus']=saveAdminStatus;const getOnairosUsername=async()=>{const _0x365920={'JAeDF':_0x14c4(0xcc),'GrzQv':_0x14c4(0xcd)};try{if(_0x365920[_0x14c4(0xce)]===_0x365920[_0x14c4(0xce)])return await _asyncStorage[_0x14c4(0x27)][_0x14c4(0x6e)]('onairos_username');else _0x183a71[_0x14c4(0x15)](_0x365920[_0x14c4(0xcf)],_0x46658c);}catch(_0x40abed){return console[_0x14c4(0x15)]('Error\x20getting\x20Onairos\x20username:',_0x40abed),null;}};exports[_0x14c4(0xd0)]=getOnairosUsername;const saveOnairosUsername=async _0x250233=>{const _0x764065={'ZYQMs':_0x14c4(0xd1),'dhpTn':'onairos_username','uMsQB':_0x14c4(0xd2)};try{if(_0x764065[_0x14c4(0xd3)]===_0x764065[_0x14c4(0xd3)])await _asyncStorage[_0x14c4(0x27)][_0x14c4(0x2b)](_0x764065[_0x14c4(0xd4)],_0x250233);else return _0x31d66b[_0x14c4(0x15)](_0x14c4(0xa2),_0x4dd148),![];}catch(_0x5488a9){console['error'](_0x764065[_0x14c4(0xd5)],_0x5488a9);}};exports[_0x14c4(0x3)]=saveOnairosUsername;const sendEmailVerificationCode=async _0x44f560=>{const _0x5b4c00={'XeqGx':'🔒\x20[TOKEN\x20VERIFY]\x20No\x20token\x20available\x20for\x20verification','rxLfg':'Error\x20saving\x20admin\x20status:','LlSwB':function(_0x644c52,_0x1ea81b){return _0x644c52===_0x1ea81b;},'LBTZE':'🔑\x20[Admin\x20Check]\x20Admin\x20access\x20granted\x20for:','ulJhT':_0x14c4(0xd6),'PoJVg':_0x14c4(0xd7),'BHRwA':function(_0x2f9849){return _0x2f9849();},'BAZnd':_0x14c4(0xd8),'RqFvN':function(_0x536c50,_0x3c7b30){return _0x536c50===_0x3c7b30;},'Yxtwq':_0x14c4(0xd9),'Ccvcf':_0x14c4(0xda),'ERsLh':'📧\x20[EMAIL\x20VERIFY]\x20Headers\x20OK,\x20key:','OyUnQ':function(_0x5b8309,_0x2320e0){return _0x5b8309+_0x2320e0;},'PfyRD':function(_0x4588a4,_0x39b3e7){return _0x4588a4===_0x39b3e7;},'aKjLb':_0x14c4(0x4d),'blyTl':function(_0x149c73,_0x2b45f5){return _0x149c73===_0x2b45f5;},'hwfAZ':_0x14c4(0xdb),'rgfrl':_0x14c4(0xdc),'zVbqv':_0x14c4(0xdd),'nvfid':function(_0x948f65,_0x2e8be4){return _0x948f65<=_0x2e8be4;},'zBpBe':function(_0x1bb31f,_0x339f89){return _0x1bb31f!==_0x339f89;},'sSJBZ':_0x14c4(0xde),'hgKco':function(_0x4fc14d,_0x4f212a){return _0x4fc14d(_0x4f212a);},'WeAFO':_0x14c4(0xdf),'cpKCU':_0x14c4(0xe0),'lNMii':_0x14c4(0xe1),'miUtU':'✅\x20[EMAIL\x20VERIFY]\x20Verification\x20code\x20sent\x20successfully','tJcDR':_0x14c4(0x99),'diPDZ':'Failed\x20to\x20send\x20verification\x20code','pvhXt':function(_0xa483b6,_0x118636){return _0xa483b6===_0x118636;},'eXpza':function(_0x46504b,_0x6512dd){return _0x46504b===_0x6512dd;},'pyGJJ':'AbortError','Trccm':function(_0x2bcb33,_0x11a2a6){return _0x2bcb33===_0x11a2a6;},'YTbTk':function(_0x320fbc,_0x52fc9e){return _0x320fbc===_0x52fc9e;},'nDFvf':function(_0x3b2da4,_0x586fae){return _0x3b2da4<_0x586fae;},'sVGPN':function(_0x3495ee,_0x20633c){return _0x3495ee===_0x20633c;},'nRiIx':_0x14c4(0xe2),'lnsBP':function(_0x17f9e2,_0x824901){return _0x17f9e2*_0x824901;},'sDkpl':'Network\x20error.\x20Please\x20check\x20your\x20connection\x20and\x20try\x20again.'},_0x48ad7f=API_BASE_URL+_0x14c4(0xe3);console[_0x14c4(0xd)](_0x5b4c00[_0x14c4(0xe4)],_0x44f560),console['log'](_0x5b4c00[_0x14c4(0xe5)],_0x48ad7f);const _0x557ddd=await _0x5b4c00[_0x14c4(0xe6)](waitForSDKInit);if(!_0x557ddd)return{'success':![],'message':_0x5b4c00[_0x14c4(0xe7)]};let _0x21efdc;try{if(_0x5b4c00[_0x14c4(0xe8)](_0x5b4c00[_0x14c4(0xe9)],_0x5b4c00[_0x14c4(0xea)]))_0x41d1ad[_0x14c4(0xd)](_0x14c4(0x97)+_0x48d4ce+']\x20Authentication\x20validated\x20for\x20API\x20call');else{var _0x2d4dd0;_0x21efdc=(0x0,_apiKeyService[_0x14c4(0x64)])(),console['log'](_0x5b4c00[_0x14c4(0xeb)],_0x5b4c00[_0x14c4(0xec)](_0x5b4c00[_0x14c4(0xed)](_0x2d4dd0=_0x21efdc[_0x14c4(0xee)],null)||_0x2d4dd0===void 0x0?void 0x0:_0x2d4dd0[_0x14c4(0x71)](0x0,0x14),_0x5b4c00[_0x14c4(0xef)]));}}catch(_0x12c75b){return _0x5b4c00[_0x14c4(0xf0)](_0x5b4c00[_0x14c4(0xf1)],_0x5b4c00[_0x14c4(0xf1)])?(console['error'](_0x5b4c00['rgfrl'],_0x5b4c00[_0x14c4(0xf2)](_0x12c75b,null)||_0x5b4c00[_0x14c4(0xf0)](_0x12c75b,void 0x0)?void 0x0:_0x12c75b['message']),{'success':![],'message':_0x14c4(0xf3)}):(_0x4e44f5[_0x14c4(0x83)](_0x5b4c00[_0x14c4(0xf4)]),![]);}const _0x30916f=JSON[_0x14c4(0x54)]({'email':_0x44f560,'action':_0x5b4c00['zVbqv']}),_0x36713c=0x3;for(let _0x593321=0x1;_0x5b4c00[_0x14c4(0xf5)](_0x593321,_0x36713c);_0x593321++){try{if(_0x5b4c00['zBpBe'](_0x5b4c00[_0x14c4(0xf6)],_0x5b4c00['sSJBZ']))_0x19ab3f[_0x14c4(0x15)](_0x5b4c00[_0x14c4(0xf7)],_0x36dcc7);else{console[_0x14c4(0xd)](_0x14c4(0xf8)+_0x593321+'/'+_0x36713c+_0x14c4(0x4d));const _0x552a30=new AbortController(),_0x4eb760=setTimeout(()=>_0x552a30[_0x14c4(0xf9)](),0x3a98),_0x55286f=await fetch(_0x48ad7f,{'method':'POST','headers':_0x21efdc,'body':_0x30916f,'signal':_0x552a30[_0x14c4(0xfa)]});_0x5b4c00[_0x14c4(0xfb)](clearTimeout,_0x4eb760),console[_0x14c4(0xd)](_0x5b4c00['WeAFO'],_0x55286f[_0x14c4(0xab)]);const _0x144a42=await _0x55286f[_0x14c4(0x46)]();if(_0x55286f['ok']&&_0x144a42['success']){if(_0x5b4c00[_0x14c4(0xfc)]!==_0x5b4c00[_0x14c4(0xfd)])return console[_0x14c4(0xd)](_0x5b4c00[_0x14c4(0xfe)]),{'success':!![]};else{const _0x427197=_0x5b4c00[_0x14c4(0xf2)](_0x273c3e[_0x14c4(0x29)]('.')[_0x14c4(0x8e)],0x3);_0x594f41['log'](_0x14c4(0x6c),_0x427197);}}else return console[_0x14c4(0xd)](_0x5b4c00[_0x14c4(0xff)],_0x144a42[_0x14c4(0x15)]||_0x144a42[_0x14c4(0xaf)]),{'success':![],'message':_0x144a42[_0x14c4(0x15)]||_0x144a42['message']||_0x5b4c00[_0x14c4(0x100)]};}}catch(_0x4dbebd){const _0x344b82=_0x5b4c00[_0x14c4(0x101)](_0x5b4c00[_0x14c4(0xed)](_0x4dbebd,null)||_0x5b4c00['eXpza'](_0x4dbebd,void 0x0)?void 0x0:_0x4dbebd[_0x14c4(0x102)],_0x5b4c00[_0x14c4(0x103)]);console['error']('❌\x20[EMAIL\x20VERIFY]\x20Attempt\x20'+_0x593321+_0x14c4(0x104),_0x344b82?_0x14c4(0x105):_0x5b4c00[_0x14c4(0x106)](_0x4dbebd,null)||_0x5b4c00['YTbTk'](_0x4dbebd,void 0x0)?void 0x0:_0x4dbebd[_0x14c4(0xaf)]);if(_0x5b4c00[_0x14c4(0x107)](_0x593321,_0x36713c)){if(_0x5b4c00[_0x14c4(0x108)](_0x14c4(0x109),_0x5b4c00[_0x14c4(0x10a)]))_0x4a2e6e[_0x14c4(0xd)](_0x5b4c00['LBTZE'],_0x48d8d9);else{const _0x3ac362=_0x5b4c00[_0x14c4(0x10b)](0x3e8,_0x593321);console[_0x14c4(0xd)]('🔄\x20[EMAIL\x20VERIFY]\x20Retrying\x20in\x20'+_0x3ac362+'ms...'),await new Promise(_0x1375dc=>setTimeout(()=>_0x1375dc(),_0x3ac362));continue;}}return console[_0x14c4(0x15)]('❌\x20[EMAIL\x20VERIFY]\x20All\x20retries\x20exhausted:',_0x5b4c00[_0x14c4(0x10c)](_0x4dbebd,null)||_0x5b4c00[_0x14c4(0xed)](_0x4dbebd,void 0x0)?void 0x0:_0x4dbebd[_0x14c4(0xaf)]),{'success':![],'message':_0x5b4c00['sDkpl']};}}return{'success':![],'message':'Network\x20error.\x20Please\x20try\x20again.'};};exports['sendEmailVerificationCode']=sendEmailVerificationCode;const confirmEmailVerificationCode=async(_0x3efa27,_0x2a6a87)=>{const _0x37e97f={'nkUVV':'❌\x20[AUTH]\x20Error\x20during\x20token\x20retrieval:','sXoqc':function(_0x4ecece,_0x5d81cd){return _0x4ecece===_0x5d81cd;},'FNjYT':function(_0x3016a0,_0x3f7376){return _0x3016a0===_0x3f7376;},'IClsH':'...','GPWuD':_0x14c4(0xd8),'zyykr':_0x14c4(0x4e),'pVEkE':_0x14c4(0x10d),'HRUtk':'Invalid\x20verification\x20code','kxOzN':_0x14c4(0x10e),'DNMbD':function(_0x2b9d37){return _0x2b9d37();},'CqrEg':function(_0x1ac4e4,_0x34846d){return _0x1ac4e4!==_0x34846d;},'POuXv':_0x14c4(0x10f),'DSApt':_0x14c4(0x110),'yRmbA':'yEIpz','HuJWH':'weTPE','VVijz':'❌\x20[CODE\x20VERIFY]\x20Failed\x20to\x20get\x20auth\x20headers:','mrlGB':'SDK\x20not\x20properly\x20initialized.\x20Please\x20restart\x20the\x20app\x20and\x20try\x20again.','VpRYh':function(_0x38f1ba,_0x3b1c22){return _0x38f1ba<=_0x3b1c22;},'roeya':'zhXOc','nspxg':_0x14c4(0x111),'RsLFN':function(_0x5de371,_0x3fe02a){return _0x5de371!==_0x3fe02a;},'bZyeC':_0x14c4(0x112),'EcQyn':function(_0x996974,_0x35eedd,_0x42296e){return _0x996974(_0x35eedd,_0x42296e);},'Xpdkg':function(_0x1f763e,_0x2c41cf){return _0x1f763e(_0x2c41cf);},'NggMX':'🔍\x20[CODE\x20VERIFY]\x20Response\x20data:','enLid':_0x14c4(0x113),'ttjNS':_0x14c4(0x114),'eXvsW':_0x14c4(0x115),'lkIjE':function(_0x3fe9fa,_0x56fce1){return _0x3fe9fa===_0x56fce1;},'ZiTUz':_0x14c4(0x116),'umczU':_0x14c4(0x117),'FYcWR':_0x14c4(0x1f),'IYOVE':_0x14c4(0x1e),'PCFzk':function(_0x4dcbd0,_0x4b441d){return _0x4dcbd0===_0x4b441d;},'qwhaE':_0x14c4(0x105),'MLYjk':function(_0x19e688,_0x1cdcf5){return _0x19e688<_0x1cdcf5;},'Rqxbi':_0x14c4(0x118),'BVzuo':function(_0x300f55,_0x4f641e){return _0x300f55===_0x4f641e;},'CeFaJ':_0x14c4(0x119),'HUeYh':_0x14c4(0x11a)};console['log'](_0x37e97f['kxOzN'],_0x3efa27);const _0x11b866=await _0x37e97f[_0x14c4(0x11b)](waitForSDKInit);if(!_0x11b866)return _0x37e97f[_0x14c4(0x11c)](_0x37e97f[_0x14c4(0x11d)],_0x14c4(0x10f))?(_0x5883ea[_0x14c4(0x15)](_0x37e97f[_0x14c4(0x11e)],_0x2ffad1),null):{'success':![],'message':_0x37e97f[_0x14c4(0x11f)]};let _0x4e40d1;try{_0x4e40d1=(0x0,_apiKeyService['getDeveloperAuthHeaders'])(),console['log'](_0x37e97f[_0x14c4(0x120)]);}catch(_0x505ab5){if(_0x37e97f['yRmbA']===_0x37e97f[_0x14c4(0x121)]){var _0xbd9da6;_0x34dcec=(0x0,_0x4d0e6a[_0x14c4(0x64)])(),_0x4358cf[_0x14c4(0xd)](_0x14c4(0x122),(_0x37e97f[_0x14c4(0x123)](_0xbd9da6=_0x539e58[_0x14c4(0xee)],null)||_0x37e97f[_0x14c4(0x124)](_0xbd9da6,void 0x0)?void 0x0:_0xbd9da6[_0x14c4(0x71)](0x0,0x14))+_0x37e97f[_0x14c4(0x125)]);}else return console[_0x14c4(0x15)](_0x37e97f[_0x14c4(0x126)],_0x37e97f[_0x14c4(0x123)](_0x505ab5,null)||_0x37e97f[_0x14c4(0x124)](_0x505ab5,void 0x0)?void 0x0:_0x505ab5['message']),{'success':![],'message':_0x37e97f['mrlGB']};}const _0x5cf69b=API_BASE_URL+_0x14c4(0xe3),_0x4022ac=JSON[_0x14c4(0x54)]({'email':_0x3efa27,'code':_0x2a6a87,'action':_0x14c4(0x127)}),_0xcf11d3=0x3;for(let _0x459c29=0x1;_0x37e97f['VpRYh'](_0x459c29,_0xcf11d3);_0x459c29++){if(_0x37e97f[_0x14c4(0x128)]===_0x37e97f[_0x14c4(0x129)])return{'success':![],'message':_0x37e97f['GPWuD']};else try{if(_0x37e97f[_0x14c4(0x12a)](_0x37e97f[_0x14c4(0x12b)],_0x37e97f['bZyeC']))return _0x57270d[_0x14c4(0xd)](_0x14c4(0xb7)),![];else{console[_0x14c4(0xd)](_0x14c4(0x12c)+_0x459c29+'/'+_0xcf11d3+_0x14c4(0x4d));const _0x3ac0a9=new AbortController(),_0x5ee97a=_0x37e97f[_0x14c4(0x12d)](setTimeout,()=>_0x3ac0a9[_0x14c4(0xf9)](),0x3a98),_0x34ecce=await fetch(_0x5cf69b,{'method':'POST','headers':_0x4e40d1,'body':_0x4022ac,'signal':_0x3ac0a9[_0x14c4(0xfa)]});_0x37e97f[_0x14c4(0x12e)](clearTimeout,_0x5ee97a),console[_0x14c4(0xd)](_0x14c4(0x12f),_0x34ecce[_0x14c4(0xab)]);const _0x36eecd=await _0x34ecce[_0x14c4(0x46)]();console[_0x14c4(0xd)](_0x37e97f[_0x14c4(0x130)],JSON[_0x14c4(0x54)](_0x36eecd));const _0x610597=_0x36eecd[_0x14c4(0x26)]||_0x36eecd[_0x14c4(0x131)];if(_0x34ecce['ok']&&_0x36eecd['success']&&_0x610597){if(_0x37e97f[_0x14c4(0x132)]!==_0x37e97f[_0x14c4(0x133)]){var _0xb3e2ff;console[_0x14c4(0xd)](_0x37e97f['eXvsW']);const _0x326d54=_0x37e97f[_0x14c4(0x134)](_0x36eecd[_0x14c4(0x135)],!![]),_0x455576=!_0x326d54,_0x350ce1=((_0xb3e2ff=_0x36eecd[_0x14c4(0x136)])===null||_0x37e97f[_0x14c4(0x123)](_0xb3e2ff,void 0x0)?void 0x0:_0xb3e2ff[_0x14c4(0x137)])||_0x36eecd[_0x14c4(0x137)]||null,_0x2e8c5a=_0x36eecd['flowType']||(_0x326d54?_0x37e97f[_0x14c4(0x138)]:_0x37e97f[_0x14c4(0x139)]);await(0x0,_jwtStorageService[_0x14c4(0x25)])(_0x610597),await _asyncStorage[_0x14c4(0x27)][_0x14c4(0x2b)](_0x37e97f[_0x14c4(0x13a)],_0x3efa27);const _0x2b3dda=_0x36eecd[_0x14c4(0x13b)]||_0x36eecd[_0x14c4(0x4a)]||_0x3efa27[_0x14c4(0x29)]('@')[0x0];return await _asyncStorage['default'][_0x14c4(0x2b)](_0x37e97f[_0x14c4(0x13c)],_0x2b3dda),await _asyncStorage[_0x14c4(0x27)][_0x14c4(0x2b)](_0x14c4(0x79),'true'),{'success':!![],'token':_0x610597,'username':_0x2b3dda,'isNewUser':_0x455576,'flowType':_0x2e8c5a,'existingUserData':_0x350ce1,'enochInstructions':_0x36eecd[_0x14c4(0x13d)]};}else throw new _0x5acf7b(_0x37e97f[_0x14c4(0x13e)]);}else return console[_0x14c4(0xd)](_0x37e97f['pVEkE'],_0x36eecd['error']||_0x36eecd[_0x14c4(0xaf)]),{'success':![],'message':_0x36eecd[_0x14c4(0x15)]||_0x36eecd[_0x14c4(0xaf)]||_0x14c4(0x13f)};}}catch(_0x2ad9d7){const _0x11895d=_0x37e97f[_0x14c4(0x123)](_0x2ad9d7===null||_0x37e97f['PCFzk'](_0x2ad9d7,void 0x0)?void 0x0:_0x2ad9d7[_0x14c4(0x102)],'AbortError');console['error']('❌\x20[CODE\x20VERIFY]\x20Attempt\x20'+_0x459c29+'\x20failed:',_0x11895d?_0x37e97f[_0x14c4(0x140)]:_0x2ad9d7===null||_0x37e97f[_0x14c4(0x124)](_0x2ad9d7,void 0x0)?void 0x0:_0x2ad9d7[_0x14c4(0xaf)]);if(_0x37e97f[_0x14c4(0x141)](_0x459c29,_0xcf11d3)){if(_0x37e97f[_0x14c4(0x142)]!==_0x37e97f[_0x14c4(0x142)])return _0x33018a[_0x14c4(0xd)](_0x37e97f[_0x14c4(0x143)],_0x90a3a7[_0x14c4(0x15)]||_0x53dc51[_0x14c4(0xaf)]),{'success':![],'message':_0x254a24[_0x14c4(0x15)]||_0x4b3078['message']||_0x37e97f[_0x14c4(0x144)]};else{const _0x359bdf=0x3e8*_0x459c29;console[_0x14c4(0xd)]('🔄\x20[CODE\x20VERIFY]\x20Retrying\x20in\x20'+_0x359bdf+_0x14c4(0x145)),await new Promise(_0x45b081=>setTimeout(()=>_0x45b081(),_0x359bdf));continue;}}return console[_0x14c4(0x15)]('❌\x20[CODE\x20VERIFY]\x20All\x20retries\x20exhausted:',_0x37e97f['BVzuo'](_0x2ad9d7,null)||_0x37e97f[_0x14c4(0x124)](_0x2ad9d7,void 0x0)?void 0x0:_0x2ad9d7['message']),{'success':![],'message':_0x37e97f[_0x14c4(0x146)]};}}return{'success':![],'message':_0x37e97f[_0x14c4(0x147)]};};exports[_0x14c4(0x8)]=confirmEmailVerificationCode;
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.verifyToken = exports.sendEmailVerificationCode = exports.saveOnairosUsername = exports.saveAuthToken = exports.saveAdminStatus = exports.removeAuthToken = exports.isAuthenticated = exports.isAdminEmail = exports.getOnairosUsername = exports.getAuthToken = exports.getAdminStatus = exports.ensureAuthentication = exports.debugAuthStorage = exports.confirmEmailVerificationCode = exports.clearAllAuthTokens = exports.authenticateWithOnairosSignIn = exports.authenticateWithOnairos = exports.authenticateWithApple = void 0;
|
|
7
|
+
var _asyncStorage = _interopRequireDefault(require("@react-native-async-storage/async-storage"));
|
|
8
|
+
var _api = require("../config/api");
|
|
9
|
+
var _apiKeyService = require("./apiKeyService");
|
|
10
|
+
var _jwtStorageService = require("./jwtStorageService");
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
// CRITICAL FIX: Use static imports instead of dynamic imports to avoid Hermes transpilation issues
|
|
13
|
+
|
|
14
|
+
// API base URL
|
|
15
|
+
const API_BASE_URL = _api.API_CONFIG.BASE_URL;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Wait for SDK initialization to complete (up to maxWaitMs).
|
|
19
|
+
* Polls isApiKeyInitialized() every 500ms.
|
|
20
|
+
*/
|
|
21
|
+
const waitForSDKInit = async (maxWaitMs = 8000) => {
|
|
22
|
+
if ((0, _apiKeyService.isApiKeyInitialized)()) return true;
|
|
23
|
+
console.log('⏳ [AUTH] SDK not yet initialized, waiting...');
|
|
24
|
+
const start = Date.now();
|
|
25
|
+
while (Date.now() - start < maxWaitMs) {
|
|
26
|
+
await new Promise(resolve => setTimeout(() => resolve(), 500));
|
|
27
|
+
if ((0, _apiKeyService.isApiKeyInitialized)()) {
|
|
28
|
+
console.log('✅ [AUTH] SDK initialized after', Date.now() - start, 'ms');
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
console.error('❌ [AUTH] SDK did not initialize within', maxWaitMs, 'ms');
|
|
33
|
+
return false;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// Legacy AuthResponse interface - kept for backward compatibility
|
|
37
|
+
// New code should use SDKAuthResponse
|
|
38
|
+
|
|
39
|
+
// Interface for Apple authentication payload
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Generic SDK Authentication Response
|
|
43
|
+
* Used by all auth methods (Google, Apple, Email)
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Authenticate with Apple
|
|
48
|
+
* @param appleAuthData Data from Apple authentication
|
|
49
|
+
* @returns Authentication response with token and user data
|
|
50
|
+
*/
|
|
51
|
+
/**
|
|
52
|
+
* Authenticate with Onairos (similar to Apple authentication)
|
|
53
|
+
* @param onairosAuthData Data from Onairos authentication
|
|
54
|
+
* @returns Authentication response with token and user data
|
|
55
|
+
*/
|
|
56
|
+
const authenticateWithOnairos = async onairosAuthData => {
|
|
57
|
+
try {
|
|
58
|
+
console.log('🔑 Authenticating with Onairos...');
|
|
59
|
+
|
|
60
|
+
// Store the token using simplified JWT storage
|
|
61
|
+
await (0, _jwtStorageService.storeJWT)(onairosAuthData.token);
|
|
62
|
+
|
|
63
|
+
// Extract username from email or use stored username
|
|
64
|
+
const storedUsername = await _asyncStorage.default.getItem('onairos_username');
|
|
65
|
+
const userName = storedUsername || onairosAuthData.email.split('@')[0] || 'Onairos User';
|
|
66
|
+
|
|
67
|
+
// Store username and email
|
|
68
|
+
await _asyncStorage.default.setItem('onairos_username', userName);
|
|
69
|
+
await _asyncStorage.default.setItem('user_email', onairosAuthData.email);
|
|
70
|
+
console.log('🔑 Onairos auth token stored:', `${onairosAuthData.token.substring(0, 20)}...`);
|
|
71
|
+
console.log('👤 User info:', {
|
|
72
|
+
email: onairosAuthData.email,
|
|
73
|
+
username: userName
|
|
74
|
+
});
|
|
75
|
+
return {
|
|
76
|
+
token: onairosAuthData.token,
|
|
77
|
+
user: {
|
|
78
|
+
id: Date.now().toString(),
|
|
79
|
+
name: userName,
|
|
80
|
+
email: onairosAuthData.email,
|
|
81
|
+
profilePicture: ''
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
} catch (error) {
|
|
85
|
+
console.error('❌ Onairos authentication error:', error);
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Authenticate with Onairos using the standardized /login/signin endpoint
|
|
92
|
+
* @param credentials Email and password for Onairos sign-in
|
|
93
|
+
* @returns Authentication response with token and user data
|
|
94
|
+
*/
|
|
95
|
+
exports.authenticateWithOnairos = authenticateWithOnairos;
|
|
96
|
+
const authenticateWithOnairosSignIn = async credentials => {
|
|
97
|
+
try {
|
|
98
|
+
console.log('🔑 Signing in with Onairos via /login/signin endpoint...');
|
|
99
|
+
const response = await fetch(`${API_BASE_URL}/login/signin`, {
|
|
100
|
+
method: 'POST',
|
|
101
|
+
headers: (0, _api.getApiHeaders)(),
|
|
102
|
+
body: JSON.stringify(credentials)
|
|
103
|
+
});
|
|
104
|
+
if (!response.ok) {
|
|
105
|
+
const errorData = await response.json();
|
|
106
|
+
throw new Error(errorData.error || 'Onairos sign-in failed');
|
|
107
|
+
}
|
|
108
|
+
const authData = await response.json();
|
|
109
|
+
console.log('✅ Onairos sign-in successful');
|
|
110
|
+
|
|
111
|
+
// Check for authentication token
|
|
112
|
+
if (!authData.token) {
|
|
113
|
+
throw new Error('No authentication token returned from Onairos sign-in');
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Store token using simplified JWT storage
|
|
117
|
+
await (0, _jwtStorageService.storeJWT)(authData.token);
|
|
118
|
+
|
|
119
|
+
// Store username from response
|
|
120
|
+
if (authData.username) {
|
|
121
|
+
await _asyncStorage.default.setItem('onairos_username', authData.username);
|
|
122
|
+
}
|
|
123
|
+
await _asyncStorage.default.setItem('user_email', credentials.email);
|
|
124
|
+
console.log('🔑 Onairos sign-in token stored:', `${authData.token.substring(0, 20)}...`);
|
|
125
|
+
return {
|
|
126
|
+
token: authData.token,
|
|
127
|
+
user: {
|
|
128
|
+
id: Date.now().toString(),
|
|
129
|
+
name: authData.username,
|
|
130
|
+
email: credentials.email,
|
|
131
|
+
profilePicture: ''
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
} catch (error) {
|
|
135
|
+
console.error('❌ Onairos sign-in error:', error);
|
|
136
|
+
throw error;
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Authenticate with Apple using generic SDK endpoint
|
|
142
|
+
* NOTE: This is generic SDK auth - does NOT create EnochUser
|
|
143
|
+
* Consuming apps should call /enoch/users/register after this if needed
|
|
144
|
+
*/
|
|
145
|
+
exports.authenticateWithOnairosSignIn = authenticateWithOnairosSignIn;
|
|
146
|
+
const authenticateWithApple = async appleAuthData => {
|
|
147
|
+
try {
|
|
148
|
+
var _authData$user, _authData$user2, _authData$user3, _authData$user4;
|
|
149
|
+
const userName = appleAuthData.fullName ? `${appleAuthData.fullName.givenName || ''} ${appleAuthData.fullName.familyName || ''}`.trim() : 'Onairos User';
|
|
150
|
+
|
|
151
|
+
// Call the generic Apple authentication endpoint - SDK route, NOT Enoch-specific
|
|
152
|
+
console.log('🍎 Authenticating with Apple via generic SDK endpoint...');
|
|
153
|
+
const appleAuthResponse = await fetch(`${API_BASE_URL}/register/apple`, {
|
|
154
|
+
method: 'POST',
|
|
155
|
+
headers: (0, _api.getApiHeaders)(),
|
|
156
|
+
body: JSON.stringify({
|
|
157
|
+
idToken: appleAuthData.identityToken,
|
|
158
|
+
nonce: appleAuthData.nonce,
|
|
159
|
+
name: userName,
|
|
160
|
+
email: appleAuthData.email
|
|
161
|
+
})
|
|
162
|
+
});
|
|
163
|
+
if (!appleAuthResponse.ok) {
|
|
164
|
+
const errorData = await appleAuthResponse.json();
|
|
165
|
+
throw new Error(errorData.error || 'Apple authentication failed');
|
|
166
|
+
}
|
|
167
|
+
const authData = await appleAuthResponse.json();
|
|
168
|
+
console.log('✅ Apple authentication successful');
|
|
169
|
+
|
|
170
|
+
// Check for authentication token
|
|
171
|
+
if (!authData.token) {
|
|
172
|
+
throw new Error('No authentication token returned from Apple auth');
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Store token using simplified JWT storage
|
|
176
|
+
await (0, _jwtStorageService.storeJWT)(authData.token);
|
|
177
|
+
|
|
178
|
+
// Store username from response
|
|
179
|
+
const username = ((_authData$user = authData.user) === null || _authData$user === void 0 ? void 0 : _authData$user.username) || authData.username || userName;
|
|
180
|
+
await _asyncStorage.default.setItem('onairos_username', username);
|
|
181
|
+
|
|
182
|
+
// Store email - prefer backend's email (correct @placeholder.com format) over Apple's local email
|
|
183
|
+
const userEmail = ((_authData$user2 = authData.user) === null || _authData$user2 === void 0 ? void 0 : _authData$user2.email) || appleAuthData.email || `apple_${appleAuthData.user}@privaterelay.apple.com`;
|
|
184
|
+
await _asyncStorage.default.setItem('user_email', userEmail);
|
|
185
|
+
console.log('🔑 Apple auth token stored:', `${authData.token.substring(0, 20)}...`);
|
|
186
|
+
return {
|
|
187
|
+
success: true,
|
|
188
|
+
token: authData.token,
|
|
189
|
+
user: {
|
|
190
|
+
id: ((_authData$user3 = authData.user) === null || _authData$user3 === void 0 ? void 0 : _authData$user3.id) || '',
|
|
191
|
+
odeanId: (_authData$user4 = authData.user) === null || _authData$user4 === void 0 ? void 0 : _authData$user4.odeanId,
|
|
192
|
+
email: userEmail,
|
|
193
|
+
username: username
|
|
194
|
+
},
|
|
195
|
+
isNewUser: authData.isNewUser || false
|
|
196
|
+
};
|
|
197
|
+
} catch (error) {
|
|
198
|
+
console.error('❌ Apple authentication error:', error);
|
|
199
|
+
throw error;
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Save authentication token
|
|
205
|
+
* @param token JWT token
|
|
206
|
+
*/
|
|
207
|
+
exports.authenticateWithApple = authenticateWithApple;
|
|
208
|
+
const saveAuthToken = async token => {
|
|
209
|
+
try {
|
|
210
|
+
await _asyncStorage.default.setItem('auth_token', token);
|
|
211
|
+
} catch (error) {
|
|
212
|
+
console.error('Error saving auth token:', error);
|
|
213
|
+
throw error;
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Debug function to check all auth-related storage
|
|
219
|
+
*/
|
|
220
|
+
exports.saveAuthToken = saveAuthToken;
|
|
221
|
+
const debugAuthStorage = async () => {
|
|
222
|
+
console.log('🔍 [AUTH STORAGE DEBUG] Checking all auth-related storage:');
|
|
223
|
+
const sdkToken = await _asyncStorage.default.getItem('sdk_jwt_token');
|
|
224
|
+
const userEmail = await _asyncStorage.default.getItem('user_email');
|
|
225
|
+
const onairosUsername = await _asyncStorage.default.getItem('onairos_username');
|
|
226
|
+
const authMethod = await _asyncStorage.default.getItem('auth_method');
|
|
227
|
+
console.log('🔑 sdk_jwt_token:', sdkToken ? `"${sdkToken.substring(0, 30)}..."` : 'null');
|
|
228
|
+
console.log('🔑 user_email:', userEmail ? `"${userEmail}"` : 'null');
|
|
229
|
+
console.log('🔑 onairos_username:', onairosUsername ? `"${onairosUsername}"` : 'null');
|
|
230
|
+
console.log('🔑 auth_method:', authMethod ? `"${authMethod}"` : 'null');
|
|
231
|
+
|
|
232
|
+
// Check if token looks valid
|
|
233
|
+
if (sdkToken) {
|
|
234
|
+
const isValidJWT = sdkToken.split('.').length === 3;
|
|
235
|
+
console.log('🔍 Token appears to be valid JWT:', isValidJWT);
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Clear all auth tokens and start fresh
|
|
241
|
+
*/
|
|
242
|
+
exports.debugAuthStorage = debugAuthStorage;
|
|
243
|
+
const clearAllAuthTokens = async () => {
|
|
244
|
+
console.log('🧹 [AUTH] Clearing all auth tokens...');
|
|
245
|
+
await (0, _jwtStorageService.clearJWT)();
|
|
246
|
+
|
|
247
|
+
// Clear other auth-related data
|
|
248
|
+
await _asyncStorage.default.multiRemove(['user_email', 'onairos_username', 'auth_method', 'onairos_user']);
|
|
249
|
+
console.log('✅ [AUTH] All auth tokens and data cleared');
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Get saved authentication token
|
|
254
|
+
* @returns Saved JWT token or null if not found
|
|
255
|
+
*/
|
|
256
|
+
exports.clearAllAuthTokens = clearAllAuthTokens;
|
|
257
|
+
const getAuthToken = async () => {
|
|
258
|
+
try {
|
|
259
|
+
const token = await (0, _jwtStorageService.getJWT)();
|
|
260
|
+
if (token) {
|
|
261
|
+
console.log('✅ [AUTH] Found JWT token:', `${token.substring(0, 20)}...`);
|
|
262
|
+
return token;
|
|
263
|
+
}
|
|
264
|
+
console.warn('❌ [AUTH] No valid JWT token found');
|
|
265
|
+
return null;
|
|
266
|
+
} catch (error) {
|
|
267
|
+
console.error('❌ [AUTH] Error during token retrieval:', error);
|
|
268
|
+
return null;
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Remove authentication token (logout)
|
|
274
|
+
*/
|
|
275
|
+
exports.getAuthToken = getAuthToken;
|
|
276
|
+
const removeAuthToken = async () => {
|
|
277
|
+
try {
|
|
278
|
+
await _asyncStorage.default.removeItem('auth_token');
|
|
279
|
+
} catch (error) {
|
|
280
|
+
console.error('Error removing auth token:', error);
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Validate if user is properly authenticated
|
|
286
|
+
* @returns boolean indicating if user has valid authentication
|
|
287
|
+
*/
|
|
288
|
+
exports.removeAuthToken = removeAuthToken;
|
|
289
|
+
const isAuthenticated = async () => {
|
|
290
|
+
try {
|
|
291
|
+
const token = await getAuthToken();
|
|
292
|
+
return token !== null && token.length > 50;
|
|
293
|
+
} catch (error) {
|
|
294
|
+
console.error('❌ [AUTH VALIDATION] Error checking authentication status:', error);
|
|
295
|
+
return false;
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Ensure authentication is available before making API calls
|
|
301
|
+
* @param apiName - Name of the API being called (for logging)
|
|
302
|
+
* @returns boolean indicating if authentication is available
|
|
303
|
+
*/
|
|
304
|
+
exports.isAuthenticated = isAuthenticated;
|
|
305
|
+
const ensureAuthentication = async apiName => {
|
|
306
|
+
const isAuth = await isAuthenticated();
|
|
307
|
+
if (!isAuth) {
|
|
308
|
+
console.warn(`⚠️ [${apiName}] No valid authentication available - API call may return limited data`);
|
|
309
|
+
} else {
|
|
310
|
+
console.log(`✅ [${apiName}] Authentication validated for API call`);
|
|
311
|
+
}
|
|
312
|
+
return isAuth;
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
// NOTE: getEnochToken and saveEnochToken have been removed from SDK.
|
|
316
|
+
// SDK now uses a single simplified token. Enoch-specific token management
|
|
317
|
+
// should be handled by the consuming app if needed.
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Verify token with backend
|
|
321
|
+
* @returns Boolean indicating if token is valid
|
|
322
|
+
*/
|
|
323
|
+
exports.ensureAuthentication = ensureAuthentication;
|
|
324
|
+
const verifyToken = async () => {
|
|
325
|
+
try {
|
|
326
|
+
const token = await getAuthToken();
|
|
327
|
+
if (!token) {
|
|
328
|
+
console.warn('🔒 [TOKEN VERIFY] No token available for verification');
|
|
329
|
+
return false;
|
|
330
|
+
}
|
|
331
|
+
console.log('🔒 [TOKEN VERIFY] Verifying token with backend...');
|
|
332
|
+
console.log('🔒 [TOKEN VERIFY] Token preview:', `${token.substring(0, 20)}...`);
|
|
333
|
+
const response = await fetch(`${API_BASE_URL}/api/auth/verify`, {
|
|
334
|
+
method: 'GET',
|
|
335
|
+
headers: (0, _api.getAuthHeaders)(token)
|
|
336
|
+
});
|
|
337
|
+
console.log('🔒 [TOKEN VERIFY] Verification response status:', response.status);
|
|
338
|
+
if (response.ok) {
|
|
339
|
+
console.log('✅ [TOKEN VERIFY] Token is valid');
|
|
340
|
+
return true;
|
|
341
|
+
} else {
|
|
342
|
+
const errorText = await response.text();
|
|
343
|
+
console.warn('❌ [TOKEN VERIFY] Token verification failed:', response.status, errorText);
|
|
344
|
+
return false;
|
|
345
|
+
}
|
|
346
|
+
} catch (error) {
|
|
347
|
+
console.error('❌ [TOKEN VERIFY] Token verification error:', error);
|
|
348
|
+
return false;
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
// NOTE: getUserProfile, createOrUpdateProfile, and updateUserOnboardedStatus
|
|
353
|
+
// have been removed from SDK - these are Enoch-specific functions.
|
|
354
|
+
// Consuming apps (like OnairosEvents) should call these APIs directly.
|
|
355
|
+
|
|
356
|
+
// NOTE: getEventTimer has been removed from SDK - it's Enoch-specific.
|
|
357
|
+
// Consuming apps (like OnairosEvents) should call /enoch/event/timer directly.
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Check if a user email has admin privileges
|
|
361
|
+
* @param email User email to check
|
|
362
|
+
* @returns True if user is an admin
|
|
363
|
+
*/
|
|
364
|
+
exports.verifyToken = verifyToken;
|
|
365
|
+
const isAdminEmail = email => {
|
|
366
|
+
if (!email) {
|
|
367
|
+
console.log('🔒 [Admin Check] No email provided');
|
|
368
|
+
return false;
|
|
369
|
+
}
|
|
370
|
+
const adminEmails = ['nicholas.berry@onairos.uk', 'zion.darko@onairos.uk', 'admin@enoch.events', 'admin@onairos.uk'];
|
|
371
|
+
const isAdmin = adminEmails.includes(email.toLowerCase());
|
|
372
|
+
if (isAdmin) {
|
|
373
|
+
console.log('🔑 [Admin Check] Admin access granted for:', email);
|
|
374
|
+
} else {
|
|
375
|
+
console.log('🚫 [Admin Check] No admin access for:', email);
|
|
376
|
+
}
|
|
377
|
+
return isAdmin;
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Get the current admin status from AsyncStorage
|
|
382
|
+
* This could be used for caching admin status between sessions
|
|
383
|
+
*/
|
|
384
|
+
exports.isAdminEmail = isAdminEmail;
|
|
385
|
+
const getAdminStatus = async () => {
|
|
386
|
+
try {
|
|
387
|
+
const adminStatus = await _asyncStorage.default.getItem('user_admin_status');
|
|
388
|
+
return adminStatus === 'true';
|
|
389
|
+
} catch (error) {
|
|
390
|
+
console.error('Error getting admin status:', error);
|
|
391
|
+
return false;
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Save admin status to AsyncStorage
|
|
397
|
+
* @param isAdmin Whether the user is an admin
|
|
398
|
+
*/
|
|
399
|
+
exports.getAdminStatus = getAdminStatus;
|
|
400
|
+
const saveAdminStatus = async isAdmin => {
|
|
401
|
+
try {
|
|
402
|
+
await _asyncStorage.default.setItem('user_admin_status', isAdmin.toString());
|
|
403
|
+
} catch (error) {
|
|
404
|
+
console.error('Error saving admin status:', error);
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Get stored Onairos username for API calls
|
|
410
|
+
* This is used for data connector APIs (Reddit, etc.) that need the username
|
|
411
|
+
* @returns Stored username or null if not found
|
|
412
|
+
*/
|
|
413
|
+
exports.saveAdminStatus = saveAdminStatus;
|
|
414
|
+
const getOnairosUsername = async () => {
|
|
415
|
+
try {
|
|
416
|
+
return await _asyncStorage.default.getItem('onairos_username');
|
|
417
|
+
} catch (error) {
|
|
418
|
+
console.error('Error getting Onairos username:', error);
|
|
419
|
+
return null;
|
|
420
|
+
}
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* Save Onairos username for API calls
|
|
425
|
+
* @param username Username to store
|
|
426
|
+
*/
|
|
427
|
+
exports.getOnairosUsername = getOnairosUsername;
|
|
428
|
+
const saveOnairosUsername = async username => {
|
|
429
|
+
try {
|
|
430
|
+
await _asyncStorage.default.setItem('onairos_username', username);
|
|
431
|
+
} catch (error) {
|
|
432
|
+
console.error('Error saving Onairos username:', error);
|
|
433
|
+
}
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* Send email verification code
|
|
438
|
+
* @param email Email address to send verification code to
|
|
439
|
+
* @returns Result with success status and optional message
|
|
440
|
+
*/
|
|
441
|
+
exports.saveOnairosUsername = saveOnairosUsername;
|
|
442
|
+
const sendEmailVerificationCode = async email => {
|
|
443
|
+
const url = `${API_BASE_URL}/email/verification`;
|
|
444
|
+
console.log('📧 [EMAIL VERIFY] Sending verification code to:', email);
|
|
445
|
+
console.log('📧 [EMAIL VERIFY] URL:', url);
|
|
446
|
+
|
|
447
|
+
// Wait for SDK to finish initializing (handles race condition)
|
|
448
|
+
const sdkReady = await waitForSDKInit();
|
|
449
|
+
if (!sdkReady) {
|
|
450
|
+
return {
|
|
451
|
+
success: false,
|
|
452
|
+
message: 'SDK is still initializing. Please wait a moment and try again.'
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
let headers;
|
|
456
|
+
try {
|
|
457
|
+
var _headers$Authorizatio;
|
|
458
|
+
headers = (0, _apiKeyService.getDeveloperAuthHeaders)();
|
|
459
|
+
console.log('📧 [EMAIL VERIFY] Headers OK, key:', ((_headers$Authorizatio = headers.Authorization) === null || _headers$Authorizatio === void 0 ? void 0 : _headers$Authorizatio.substring(0, 20)) + '...');
|
|
460
|
+
} catch (headerError) {
|
|
461
|
+
console.error('❌ [EMAIL VERIFY] Failed to get auth headers:', headerError === null || headerError === void 0 ? void 0 : headerError.message);
|
|
462
|
+
return {
|
|
463
|
+
success: false,
|
|
464
|
+
message: 'SDK not properly initialized. Please restart the app and try again.'
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
const body = JSON.stringify({
|
|
468
|
+
email,
|
|
469
|
+
action: 'request'
|
|
470
|
+
});
|
|
471
|
+
const maxRetries = 3;
|
|
472
|
+
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
473
|
+
try {
|
|
474
|
+
console.log(`📧 [EMAIL VERIFY] Attempt ${attempt}/${maxRetries}...`);
|
|
475
|
+
const controller = new AbortController();
|
|
476
|
+
const timeoutId = setTimeout(() => controller.abort(), 15000);
|
|
477
|
+
const response = await fetch(url, {
|
|
478
|
+
method: 'POST',
|
|
479
|
+
headers,
|
|
480
|
+
body,
|
|
481
|
+
signal: controller.signal
|
|
482
|
+
});
|
|
483
|
+
clearTimeout(timeoutId);
|
|
484
|
+
console.log('📧 [EMAIL VERIFY] Response status:', response.status);
|
|
485
|
+
const data = await response.json();
|
|
486
|
+
if (response.ok && data.success) {
|
|
487
|
+
console.log('✅ [EMAIL VERIFY] Verification code sent successfully');
|
|
488
|
+
return {
|
|
489
|
+
success: true
|
|
490
|
+
};
|
|
491
|
+
} else {
|
|
492
|
+
console.log('❌ [EMAIL VERIFY] Server error:', data.error || data.message);
|
|
493
|
+
return {
|
|
494
|
+
success: false,
|
|
495
|
+
message: data.error || data.message || 'Failed to send verification code'
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
} catch (error) {
|
|
499
|
+
const isTimeout = (error === null || error === void 0 ? void 0 : error.name) === 'AbortError';
|
|
500
|
+
console.error(`❌ [EMAIL VERIFY] Attempt ${attempt} failed:`, isTimeout ? 'TIMEOUT' : error === null || error === void 0 ? void 0 : error.message);
|
|
501
|
+
if (attempt < maxRetries) {
|
|
502
|
+
const delay = 1000 * attempt;
|
|
503
|
+
console.log(`🔄 [EMAIL VERIFY] Retrying in ${delay}ms...`);
|
|
504
|
+
await new Promise(resolve => setTimeout(() => resolve(), delay));
|
|
505
|
+
continue;
|
|
506
|
+
}
|
|
507
|
+
console.error('❌ [EMAIL VERIFY] All retries exhausted:', error === null || error === void 0 ? void 0 : error.message);
|
|
508
|
+
return {
|
|
509
|
+
success: false,
|
|
510
|
+
message: 'Network error. Please check your connection and try again.'
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
return {
|
|
515
|
+
success: false,
|
|
516
|
+
message: 'Network error. Please try again.'
|
|
517
|
+
};
|
|
518
|
+
};
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* Confirm email verification code
|
|
522
|
+
* NOTE: This is generic SDK email verification - does NOT create EnochUser
|
|
523
|
+
* Consuming apps should call /enoch/users/register after this if needed
|
|
524
|
+
* @param email Email address that received the code
|
|
525
|
+
* @param code Verification code entered by user
|
|
526
|
+
* @returns Result with success status, optional token, and message
|
|
527
|
+
*/
|
|
528
|
+
exports.sendEmailVerificationCode = sendEmailVerificationCode;
|
|
529
|
+
const confirmEmailVerificationCode = async (email, code) => {
|
|
530
|
+
console.log('🔍 [CODE VERIFY] Verifying code for:', email);
|
|
531
|
+
|
|
532
|
+
// Wait for SDK to finish initializing (handles race condition)
|
|
533
|
+
const sdkReady = await waitForSDKInit();
|
|
534
|
+
if (!sdkReady) {
|
|
535
|
+
return {
|
|
536
|
+
success: false,
|
|
537
|
+
message: 'SDK is still initializing. Please wait a moment and try again.'
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
let headers;
|
|
541
|
+
try {
|
|
542
|
+
headers = (0, _apiKeyService.getDeveloperAuthHeaders)();
|
|
543
|
+
console.log('🔍 [CODE VERIFY] Headers OK');
|
|
544
|
+
} catch (headerError) {
|
|
545
|
+
console.error('❌ [CODE VERIFY] Failed to get auth headers:', headerError === null || headerError === void 0 ? void 0 : headerError.message);
|
|
546
|
+
return {
|
|
547
|
+
success: false,
|
|
548
|
+
message: 'SDK not properly initialized. Please restart the app and try again.'
|
|
549
|
+
};
|
|
550
|
+
}
|
|
551
|
+
const url = `${API_BASE_URL}/email/verification`;
|
|
552
|
+
const body = JSON.stringify({
|
|
553
|
+
email,
|
|
554
|
+
code,
|
|
555
|
+
action: 'verify'
|
|
556
|
+
});
|
|
557
|
+
const maxRetries = 3;
|
|
558
|
+
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
559
|
+
try {
|
|
560
|
+
console.log(`🔍 [CODE VERIFY] Attempt ${attempt}/${maxRetries}...`);
|
|
561
|
+
const controller = new AbortController();
|
|
562
|
+
const timeoutId = setTimeout(() => controller.abort(), 15000);
|
|
563
|
+
const response = await fetch(url, {
|
|
564
|
+
method: 'POST',
|
|
565
|
+
headers,
|
|
566
|
+
body,
|
|
567
|
+
signal: controller.signal
|
|
568
|
+
});
|
|
569
|
+
clearTimeout(timeoutId);
|
|
570
|
+
console.log('🔍 [CODE VERIFY] Response status:', response.status);
|
|
571
|
+
const data = await response.json();
|
|
572
|
+
console.log('🔍 [CODE VERIFY] Response data:', JSON.stringify(data));
|
|
573
|
+
const token = data.token || data.jwtToken;
|
|
574
|
+
if (response.ok && data.success && token) {
|
|
575
|
+
var _data$accountInfo;
|
|
576
|
+
console.log('✅ [CODE VERIFY] Email verification successful');
|
|
577
|
+
const isReturningUser = data.existingUser === true;
|
|
578
|
+
const isNewUser = !isReturningUser;
|
|
579
|
+
const existingUserData = ((_data$accountInfo = data.accountInfo) === null || _data$accountInfo === void 0 ? void 0 : _data$accountInfo.existingUserData) || data.existingUserData || null;
|
|
580
|
+
const flowType = data.flowType || (isReturningUser ? 'returning_user' : 'onboarding');
|
|
581
|
+
await (0, _jwtStorageService.storeJWT)(token);
|
|
582
|
+
await _asyncStorage.default.setItem('user_email', email);
|
|
583
|
+
const username = data.userName || data.username || email.split('@')[0];
|
|
584
|
+
await _asyncStorage.default.setItem('onairos_username', username);
|
|
585
|
+
await _asyncStorage.default.setItem('onairos_user', 'true');
|
|
586
|
+
return {
|
|
587
|
+
success: true,
|
|
588
|
+
token,
|
|
589
|
+
username,
|
|
590
|
+
isNewUser,
|
|
591
|
+
flowType,
|
|
592
|
+
existingUserData,
|
|
593
|
+
enochInstructions: data.enochInstructions
|
|
594
|
+
};
|
|
595
|
+
} else {
|
|
596
|
+
console.log('❌ [CODE VERIFY] Server error:', data.error || data.message);
|
|
597
|
+
return {
|
|
598
|
+
success: false,
|
|
599
|
+
message: data.error || data.message || 'Invalid verification code'
|
|
600
|
+
};
|
|
601
|
+
}
|
|
602
|
+
} catch (error) {
|
|
603
|
+
const isTimeout = (error === null || error === void 0 ? void 0 : error.name) === 'AbortError';
|
|
604
|
+
console.error(`❌ [CODE VERIFY] Attempt ${attempt} failed:`, isTimeout ? 'TIMEOUT' : error === null || error === void 0 ? void 0 : error.message);
|
|
605
|
+
if (attempt < maxRetries) {
|
|
606
|
+
const delay = 1000 * attempt;
|
|
607
|
+
console.log(`🔄 [CODE VERIFY] Retrying in ${delay}ms...`);
|
|
608
|
+
await new Promise(resolve => setTimeout(() => resolve(), delay));
|
|
609
|
+
continue;
|
|
610
|
+
}
|
|
611
|
+
console.error('❌ [CODE VERIFY] All retries exhausted:', error === null || error === void 0 ? void 0 : error.message);
|
|
612
|
+
return {
|
|
613
|
+
success: false,
|
|
614
|
+
message: 'Verification failed. Please check your connection and try again.'
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
return {
|
|
619
|
+
success: false,
|
|
620
|
+
message: 'Verification failed. Please try again.'
|
|
621
|
+
};
|
|
622
|
+
};
|
|
623
|
+
|
|
624
|
+
// NOTE: checkEnochOnairosConnection has been removed from SDK - it's Enoch-specific.
|
|
625
|
+
// Consuming apps (like OnairosEvents) should call /enoch/user/onairos-connection-status directly.
|
|
626
|
+
exports.confirmEmailVerificationCode = confirmEmailVerificationCode;
|
|
627
|
+
//# sourceMappingURL=authService.js.map
|