@onairos/react-native 3.7.1 → 3.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/api/index.js +219 -9
- package/lib/commonjs/assets/icons/spotify.png +0 -0
- package/lib/commonjs/assets/images/spotify.png +0 -0
- package/lib/commonjs/components/BodyText.js +27 -9
- package/lib/commonjs/components/BrandMark.js +111 -10
- package/lib/commonjs/components/CodeInput.js +116 -9
- package/lib/commonjs/components/EmailInput.js +30 -8
- package/lib/commonjs/components/GoogleButton.js +56 -9
- package/lib/commonjs/components/HeadingGroup.js +43 -9
- package/lib/commonjs/components/LLMDataInputModal.js +664 -14
- package/lib/commonjs/components/ModalHeader.js +99 -9
- package/lib/commonjs/components/ModalSheet.js +47 -9
- package/lib/commonjs/components/Onairos.js +380 -14
- package/lib/commonjs/components/OnairosButton.js +313 -13
- package/lib/commonjs/components/OnairosSignInButton.js +130 -12
- package/lib/commonjs/components/Overlay.js +465 -13
- package/lib/commonjs/components/PersonaImage.js +137 -10
- package/lib/commonjs/components/PersonaLoadingScreen.js +318 -12
- package/lib/commonjs/components/PersonalizationConsentScreen.js +467 -13
- package/lib/commonjs/components/PinCreationScreen.js +403 -12
- package/lib/commonjs/components/PinInput.js +464 -9
- package/lib/commonjs/components/PlatformConnectorsStep.js +1311 -23
- package/lib/commonjs/components/PlatformList.js +137 -10
- package/lib/commonjs/components/PlatformToggle.js +180 -9
- package/lib/commonjs/components/PrimaryButton.js +180 -10
- package/lib/commonjs/components/SignInMatchAnimation.js +197 -9
- package/lib/commonjs/components/SignInStep.js +345 -12
- package/lib/commonjs/components/UniversalOnboarding.js +2780 -30
- package/lib/commonjs/components/VerificationStep.js +176 -11
- package/lib/commonjs/components/WelcomeScreen.js +461 -22
- package/lib/commonjs/components/icons/Basicproficon.js +37 -8
- package/lib/commonjs/components/icons/Basicprofile.js +21 -8
- package/lib/commonjs/components/icons/Checkbox.js +21 -8
- package/lib/commonjs/components/icons/Checkmark.js +27 -8
- package/lib/commonjs/components/icons/Contentanalysis.js +21 -8
- package/lib/commonjs/components/icons/Contenticon.js +39 -8
- package/lib/commonjs/components/icons/EnochE.js +41 -8
- package/lib/commonjs/components/icons/Personalityicon.js +30 -8
- package/lib/commonjs/components/icons/Personalityprofile.js +21 -8
- package/lib/commonjs/components/icons/Personalitytraits.js +21 -8
- package/lib/commonjs/components/icons/Userpreferences.js +21 -8
- package/lib/commonjs/components/icons/index.js +84 -17
- package/lib/commonjs/components/onboarding/OAuthWebView.js +1754 -18
- package/lib/commonjs/components/onboarding/OnboardingHeader.js +74 -10
- package/lib/commonjs/components/onboarding/PinInput.js +283 -10
- package/lib/commonjs/components/onboarding/PlatformConnector.js +249 -11
- package/lib/commonjs/config/PLATFORM_APIS.md +849 -0
- package/lib/commonjs/config/api.js +56 -7
- package/lib/commonjs/constants/index.js +120 -7
- package/lib/commonjs/context/AuthContext.js +345 -10
- package/lib/commonjs/hooks/useConnectedAccounts.js +111 -9
- package/lib/commonjs/hooks/useConnections.js +102 -8
- package/lib/commonjs/hooks/useCredentials.js +178 -10
- package/lib/commonjs/hooks/useUserConnections.js +148 -10
- package/lib/commonjs/index.js +439 -34
- package/lib/commonjs/services/apiClient.js +298 -8
- package/lib/commonjs/services/biometricPinService.js +180 -8
- package/lib/commonjs/services/chatGPTConversationExtractor.js +155 -8
- package/lib/commonjs/services/chatGPTConversationService.js +275 -9
- package/lib/commonjs/services/claudeConversationExtractor.js +103 -8
- package/lib/commonjs/services/claudeConversationService.js +158 -9
- package/lib/commonjs/services/connectedAccountsService.js +310 -10
- package/lib/commonjs/services/googleAuthService.js +252 -11
- package/lib/commonjs/services/hingeDataExtractor.js +105 -8
- package/lib/commonjs/services/hingeDataService.js +150 -9
- package/lib/commonjs/services/imageCompressionService.js +260 -7
- package/lib/commonjs/services/instagramDataExtractor.js +126 -8
- package/lib/commonjs/services/instagramDataService.js +163 -9
- package/lib/commonjs/services/jwtStorageService.js +276 -7
- package/lib/commonjs/services/linkedinDOMExtractor.js +245 -7
- package/lib/commonjs/services/linkedinProfileService.js +222 -9
- package/lib/commonjs/services/linkedinScrapingService.js +230 -8
- package/lib/commonjs/services/llmDataStorage.js +294 -8
- package/lib/commonjs/services/mobileTrainingService.js +186 -8
- package/lib/commonjs/services/netflixDataExtractor.js +120 -8
- package/lib/commonjs/services/netflixDataService.js +198 -9
- package/lib/commonjs/services/pinEncryptionService.js +84 -8
- package/lib/commonjs/services/pinStorageUtils.js +105 -7
- package/lib/commonjs/services/platformAuthService.js +1484 -12
- package/lib/commonjs/services/sephoraDataExtractor.js +140 -8
- package/lib/commonjs/services/sephoraDataService.js +200 -9
- package/lib/commonjs/services/spotifyDataExtractor.js +148 -8
- package/lib/commonjs/services/spotifyDataService.js +241 -9
- package/lib/commonjs/services/storageService.js +404 -8
- package/lib/commonjs/services/telegramDataExtractor.js +115 -8
- package/lib/commonjs/services/telegramDataService.js +499 -9
- package/lib/commonjs/services/trainingApiHelpers.js +73 -7
- package/lib/commonjs/services/userConnectionsService.js +340 -10
- package/lib/commonjs/services/youtubeMigrationService.js +416 -10
- package/lib/commonjs/theme/index.js +250 -7
- package/lib/commonjs/types/ambient.d.js +2 -1
- package/lib/commonjs/types/declarations.d.js +2 -1
- package/lib/commonjs/types/index.js +6 -1
- package/lib/commonjs/types/node-fix.d.js +2 -1
- package/lib/commonjs/types/node-override.d.js +2 -1
- package/lib/commonjs/types/opacity.d.js +2 -1
- package/lib/commonjs/types.js +14 -1
- package/lib/commonjs/utils/Portal.js +98 -8
- package/lib/commonjs/utils/api.js +130 -9
- package/lib/commonjs/utils/assetRegistry.js +210 -35
- package/lib/commonjs/utils/auth.js +112 -9
- package/lib/commonjs/utils/connectorTests.js +613 -29
- package/lib/commonjs/utils/crypto.js +62 -8
- package/lib/commonjs/utils/debugHelper.js +64 -1
- package/lib/commonjs/utils/encryption.js +76 -7
- package/lib/commonjs/utils/eventUtils.js +288 -1
- package/lib/commonjs/utils/haptics.js +66 -9
- package/lib/commonjs/utils/imagePreloader.js +6 -1
- package/lib/commonjs/utils/networkDiagnostics.js +226 -8
- package/lib/commonjs/utils/onairosApi.js +350 -9
- package/lib/commonjs/utils/programmaticFlow.js +117 -9
- package/lib/commonjs/utils/retryHelper.js +220 -1
- package/lib/commonjs/utils/secureStorage.js +349 -10
- package/lib/commonjs/utils/webviewScripts/chatgpt.js +551 -1
- package/lib/commonjs/utils/webviewScripts/claude.js +376 -1
- package/lib/commonjs/utils/webviewScripts/hinge.js +411 -1
- package/lib/commonjs/utils/webviewScripts/index.js +698 -15
- package/lib/commonjs/utils/webviewScripts/instagram.js +454 -1
- package/lib/commonjs/utils/webviewScripts/linkedin.js +880 -1
- package/lib/commonjs/utils/webviewScripts/netflix.js +382 -1
- package/lib/commonjs/utils/webviewScripts/sephora.js +516 -1
- package/lib/commonjs/utils/webviewScripts/spotify.js +419 -1
- package/lib/commonjs/utils/webviewScripts/telegram.js +678 -1
- package/lib/module/api/index.js +211 -1
- package/lib/module/assets/icons/spotify.png +0 -0
- package/lib/module/assets/images/spotify.png +0 -0
- package/lib/module/components/BodyText.js +20 -1
- package/lib/module/components/BrandMark.js +104 -1
- package/lib/module/components/CodeInput.js +109 -1
- package/lib/module/components/EmailInput.js +23 -1
- package/lib/module/components/GoogleButton.js +49 -1
- package/lib/module/components/HeadingGroup.js +36 -1
- package/lib/module/components/LLMDataInputModal.js +656 -7
- package/lib/module/components/ModalHeader.js +92 -1
- package/lib/module/components/ModalSheet.js +39 -1
- package/lib/module/components/Onairos.js +373 -1
- package/lib/module/components/OnairosButton.js +305 -1
- package/lib/module/components/OnairosSignInButton.js +121 -1
- package/lib/module/components/Overlay.js +456 -1
- package/lib/module/components/PersonaImage.js +129 -1
- package/lib/module/components/PersonaLoadingScreen.js +310 -1
- package/lib/module/components/PersonalizationConsentScreen.js +460 -1
- package/lib/module/components/PinCreationScreen.js +396 -1
- package/lib/module/components/PinInput.js +456 -1
- package/lib/module/components/PlatformConnectorsStep.js +1302 -6
- package/lib/module/components/PlatformList.js +129 -1
- package/lib/module/components/PlatformToggle.js +173 -1
- package/lib/module/components/PrimaryButton.js +172 -1
- package/lib/module/components/SignInMatchAnimation.js +189 -1
- package/lib/module/components/SignInStep.js +338 -1
- package/lib/module/components/UniversalOnboarding.js +2770 -1
- package/lib/module/components/VerificationStep.js +168 -1
- package/lib/module/components/WelcomeScreen.js +453 -1
- package/lib/module/components/icons/Basicproficon.js +30 -1
- package/lib/module/components/icons/Basicprofile.js +14 -1
- package/lib/module/components/icons/Checkbox.js +14 -1
- package/lib/module/components/icons/Checkmark.js +20 -1
- package/lib/module/components/icons/Contentanalysis.js +14 -1
- package/lib/module/components/icons/Contenticon.js +32 -1
- package/lib/module/components/icons/EnochE.js +34 -1
- package/lib/module/components/icons/Personalityicon.js +23 -1
- package/lib/module/components/icons/Personalityprofile.js +14 -1
- package/lib/module/components/icons/Personalitytraits.js +14 -1
- package/lib/module/components/icons/Userpreferences.js +14 -1
- package/lib/module/components/icons/index.js +13 -1
- package/lib/module/components/onboarding/OAuthWebView.js +1746 -1
- package/lib/module/components/onboarding/OnboardingHeader.js +66 -1
- package/lib/module/components/onboarding/PinInput.js +274 -1
- package/lib/module/components/onboarding/PlatformConnector.js +240 -1
- package/lib/module/config/PLATFORM_APIS.md +849 -0
- package/lib/module/config/api.js +47 -1
- package/lib/module/constants/index.js +114 -1
- package/lib/module/context/AuthContext.js +335 -1
- package/lib/module/hooks/useConnectedAccounts.js +106 -1
- package/lib/module/hooks/useConnections.js +95 -1
- package/lib/module/hooks/useCredentials.js +171 -6
- package/lib/module/hooks/useUserConnections.js +140 -1
- package/lib/module/index.js +172 -1
- package/lib/module/services/apiClient.js +295 -1
- package/lib/module/services/biometricPinService.js +169 -1
- package/lib/module/services/chatGPTConversationExtractor.js +149 -1
- package/lib/module/services/chatGPTConversationService.js +268 -1
- package/lib/module/services/claudeConversationExtractor.js +97 -1
- package/lib/module/services/claudeConversationService.js +151 -1
- package/lib/module/services/connectedAccountsService.js +293 -1
- package/lib/module/services/googleAuthService.js +241 -1
- package/lib/module/services/hingeDataExtractor.js +99 -1
- package/lib/module/services/hingeDataService.js +143 -1
- package/lib/module/services/imageCompressionService.js +250 -1
- package/lib/module/services/instagramDataExtractor.js +120 -1
- package/lib/module/services/instagramDataService.js +156 -1
- package/lib/module/services/jwtStorageService.js +257 -1
- package/lib/module/services/linkedinDOMExtractor.js +234 -1
- package/lib/module/services/linkedinProfileService.js +210 -1
- package/lib/module/services/linkedinScrapingService.js +219 -1
- package/lib/module/services/llmDataStorage.js +277 -1
- package/lib/module/services/mobileTrainingService.js +173 -1
- package/lib/module/services/netflixDataExtractor.js +114 -1
- package/lib/module/services/netflixDataService.js +191 -1
- package/lib/module/services/pinEncryptionService.js +74 -6
- package/lib/module/services/pinStorageUtils.js +93 -1
- package/lib/module/services/platformAuthService.js +1461 -1
- package/lib/module/services/sephoraDataExtractor.js +134 -1
- package/lib/module/services/sephoraDataService.js +193 -1
- package/lib/module/services/spotifyDataExtractor.js +142 -1
- package/lib/module/services/spotifyDataService.js +234 -1
- package/lib/module/services/storageService.js +383 -1
- package/lib/module/services/telegramDataExtractor.js +109 -1
- package/lib/module/services/telegramDataService.js +493 -1
- package/lib/module/services/trainingApiHelpers.js +67 -1
- package/lib/module/services/userConnectionsService.js +329 -1
- package/lib/module/services/youtubeMigrationService.js +405 -1
- package/lib/module/theme/index.js +245 -1
- package/lib/module/types.js +10 -1
- package/lib/module/utils/Portal.js +90 -1
- package/lib/module/utils/api.js +118 -1
- package/lib/module/utils/assetRegistry.js +200 -34
- package/lib/module/utils/auth.js +100 -1
- package/lib/module/utils/connectorTests.js +600 -27
- package/lib/module/utils/crypto.js +54 -1
- package/lib/module/utils/debugHelper.js +54 -1
- package/lib/module/utils/encryption.js +67 -1
- package/lib/module/utils/eventUtils.js +270 -1
- package/lib/module/utils/haptics.js +59 -8
- package/lib/module/utils/imagePreloader.js +3 -1
- package/lib/module/utils/networkDiagnostics.js +217 -1
- package/lib/module/utils/onairosApi.js +333 -1
- package/lib/module/utils/programmaticFlow.js +111 -1
- package/lib/module/utils/retryHelper.js +211 -1
- package/lib/module/utils/secureStorage.js +330 -6
- package/lib/module/utils/webviewScripts/chatgpt.js +545 -1
- package/lib/module/utils/webviewScripts/claude.js +370 -1
- package/lib/module/utils/webviewScripts/hinge.js +405 -1
- package/lib/module/utils/webviewScripts/index.js +434 -1
- package/lib/module/utils/webviewScripts/instagram.js +448 -1
- package/lib/module/utils/webviewScripts/linkedin.js +874 -1
- package/lib/module/utils/webviewScripts/netflix.js +376 -1
- package/lib/module/utils/webviewScripts/sephora.js +510 -1
- package/lib/module/utils/webviewScripts/spotify.js +413 -1
- package/lib/module/utils/webviewScripts/telegram.js +672 -1
- package/package.json +2 -2
|
@@ -1 +1,217 @@
|
|
|
1
|
-
import{Platform}from'react-native';import{API_CONFIG}from'../config/api';function _0x362b(_0x2008be,_0x362bfc){_0x2008be=_0x2008be-0x0;const _0x1d7f18=_0x2008();let _0x5b19de=_0x1d7f18[_0x2008be];return _0x5b19de;}export const runFullDiagnostics=async()=>{const _0x11eefd={'eSLwm':_0x362b(0x0),'ZLVOm':'1|2|4|3|0','yxAiz':_0x362b(0x1),'FPKIX':_0x362b(0x2),'tunOY':function(_0x38a00c,_0x40ec5f){return _0x38a00c===_0x40ec5f;},'hdxAg':_0x362b(0x3),'wzKtQ':function(_0x2815c3,_0x2bbf4a){return _0x2815c3+_0x2bbf4a;},'AKhkQ':_0x362b(0x4),'laDOj':'🔍\x20ONAIROS\x20SDK\x20NETWORK\x20DIAGNOSTICS','FXjiH':_0x362b(0x5),'eRRji':'\x0a🧪\x20Test\x201:\x20Internet\x20Connectivity\x20(google.com)','qeusp':function(_0x393ca3,_0x3102fd,_0x508d0e){return _0x393ca3(_0x3102fd,_0x508d0e);},'GhYfI':_0x362b(0x6),'LWyLa':_0x362b(0x7),'uwhkT':function(_0x5cbe9b,_0x1dde47){return _0x5cbe9b-_0x1dde47;},'omDUD':function(_0xc4c273,_0x6b7678){return _0xc4c273!==_0x6b7678;},'YZszL':_0x362b(0x8),'tNehC':_0x362b(0x9),'xKVHb':function(_0x1091e9,_0x42c632){return _0x1091e9!==_0x42c632;},'RkIaP':_0x362b(0xa),'HkUiM':'vRmIA','CrUPX':function(_0x3ab5cc,_0x4c2f6d){return _0x3ab5cc-_0x4c2f6d;},'PAwYt':_0x362b(0xb),'jfzIz':_0x362b(0xc),'DQwCd':_0x362b(0xd),'RIcJm':_0x362b(0xe),'LFtYO':function(_0x53b532,_0x3c92e8){return _0x53b532===_0x3c92e8;},'WBIfW':_0x362b(0xf),'Hzykv':_0x362b(0x10),'YBmpT':function(_0x45b7d9,_0x57be36){return _0x45b7d9!==_0x57be36;},'UENRX':_0x362b(0x11),'SgOfK':function(_0x2dc6ff,_0x264947){return _0x2dc6ff===_0x264947;},'UySSz':_0x362b(0x12),'MOmMT':_0x362b(0x13),'cpPWc':_0x362b(0x14),'BbwYN':_0x362b(0x15),'GvPPY':function(_0xb5fc93,_0x11e73c){return _0xb5fc93===_0x11e73c;},'PVkdP':_0x362b(0x16),'LOSgi':_0x362b(0x17)};console[_0x362b(0x18)](_0x11eefd[_0x362b(0x19)]),console[_0x362b(0x18)](_0x11eefd[_0x362b(0x1a)]),console[_0x362b(0x18)](_0x11eefd[_0x362b(0x19)]);const _0x404372={'timestamp':new Date()[_0x362b(0x1b)](),'platform':Platform['OS'],'platformVersion':Platform['Version'],'tests':{'googleReachable':![],'apiReachable':![],'apiPostWorks':![],'youtubeOAuthWorks':![]},'errors':[],'recommendations':[],'rawResults':{}};console[_0x362b(0x18)](_0x362b(0x1c)+Platform['OS']+'\x20'+Platform[_0x362b(0x1d)]),console[_0x362b(0x18)](_0x11eefd[_0x362b(0x1e)]),console[_0x362b(0x18)](_0x11eefd[_0x362b(0x1f)]);try{const _0x4cd65f=Date['now'](),_0x4065a8=await _0x11eefd[_0x362b(0x20)](fetch,_0x11eefd[_0x362b(0x21)],{'method':_0x11eefd[_0x362b(0x22)]}),_0x240130=_0x11eefd[_0x362b(0x23)](Date[_0x362b(0x24)](),_0x4cd65f);_0x404372[_0x362b(0x25)]['googleReachable']=!![],_0x404372[_0x362b(0x26)][_0x362b(0x27)]={'status':_0x4065a8[_0x362b(0x28)],'time':_0x240130},console[_0x362b(0x18)](_0x362b(0x29)+_0x240130+'ms)');}catch(_0x29fb99){if(_0x11eefd[_0x362b(0x2a)](_0x11eefd[_0x362b(0x2b)],_0x362b(0x2c))){const _0x182a5b='4|2|0|1|3'['split']('|');let _0x197e39=0x0;while(!![]){switch(_0x182a5b[_0x197e39++]){case'0':_0x404372[_0x362b(0x26)]['google']={'error':_0x29fb99['message']};continue;case'1':console[_0x362b(0x18)](_0x362b(0x2d)+_0x29fb99[_0x362b(0x2e)]);continue;case'2':_0x404372['errors']['push']('Google\x20unreachable:\x20'+_0x29fb99[_0x362b(0x2e)]);continue;case'3':_0x404372[_0x362b(0x2f)]['push'](_0x362b(0x30));continue;case'4':_0x404372[_0x362b(0x25)][_0x362b(0x31)]=![];continue;}break;}}else _0x8f5557[_0x362b(0x2f)][_0x362b(0x32)](_0x11eefd['eSLwm']);}console['log'](_0x11eefd[_0x362b(0x33)]);try{if(_0x11eefd['xKVHb'](_0x11eefd[_0x362b(0x34)],_0x11eefd[_0x362b(0x35)])){const _0x3b0ba7=Date[_0x362b(0x24)](),_0x344657=await fetch(API_CONFIG[_0x362b(0x36)]+_0x362b(0x37),{'method':'GET','headers':{'Accept':'application/json'}}),_0x1a7829=_0x11eefd[_0x362b(0x38)](Date[_0x362b(0x24)](),_0x3b0ba7),_0x2ad33a=await _0x344657[_0x362b(0x39)]()[_0x362b(0x3a)](()=>_0x362b(0x3b));_0x404372[_0x362b(0x25)][_0x362b(0x3c)]=_0x344657['ok'],_0x404372[_0x362b(0x26)][_0x362b(0x3d)]={'status':_0x344657[_0x362b(0x28)],'time':_0x1a7829,'body':_0x2ad33a[_0x362b(0x3e)](0x0,0xc8)},_0x344657['ok']?console[_0x362b(0x18)](_0x362b(0x3f)+_0x1a7829+_0x362b(0x40)):_0x11eefd[_0x362b(0x41)]===_0x11eefd[_0x362b(0x41)]?(console[_0x362b(0x18)](_0x362b(0x42)+_0x344657[_0x362b(0x28)]),_0x404372[_0x362b(0x43)][_0x362b(0x32)](_0x362b(0x44)+_0x344657[_0x362b(0x28)])):_0x47498a[_0x362b(0x2f)][_0x362b(0x32)](_0x362b(0x45));}else return![];}catch(_0x3838c2){_0x404372['tests'][_0x362b(0x3c)]=![],_0x404372['errors']['push'](_0x362b(0x46)+_0x3838c2[_0x362b(0x2e)]),_0x404372[_0x362b(0x26)][_0x362b(0x3d)]={'error':_0x3838c2[_0x362b(0x2e)]},console['log']('\x20\x20\x20❌\x20FAIL\x20-\x20'+_0x3838c2[_0x362b(0x2e)]);if(_0x404372[_0x362b(0x25)][_0x362b(0x31)]){if('OFEMs'!=='yvtOb')_0x404372[_0x362b(0x2f)]['push'](_0x362b(0x45));else{const _0x1f19d5=_0x11eefd[_0x362b(0x47)]['split']('|');let _0x381dfa=0x0;while(!![]){switch(_0x1f19d5[_0x381dfa++]){case'0':_0x4f17f3[_0x362b(0x2f)][_0x362b(0x32)]('POST requests failing. This is the exact issue affecting OAuth.');continue;case'1':_0x217b7c[_0x362b(0x25)][_0x362b(0x48)]=![];continue;case'2':_0x30fa0a[_0x362b(0x43)][_0x362b(0x32)](_0x362b(0x49)+_0xa3fac0[_0x362b(0x2e)]);continue;case'3':_0x557d34['log']('\x20\x20\x20❌\x20FAIL\x20-\x20'+_0x3b9154[_0x362b(0x2e)]);continue;case'4':_0x552367['rawResults'][_0x362b(0x4a)]={'error':_0xecced6['message']};continue;}break;}}}}console[_0x362b(0x18)]('\n\uD83E\uDDEA Test 3: POST Request (OAuth simulation)');try{if(_0x11eefd['tunOY'](_0x362b(0xc),_0x11eefd[_0x362b(0x4b)])){const _0x59abb1=Date[_0x362b(0x24)](),_0x4881d6=await _0x11eefd[_0x362b(0x20)](fetch,API_CONFIG[_0x362b(0x36)]+_0x362b(0x4c),{'method':'POST','headers':{'Content-Type':'application/json','Accept':'application/json'},'body':JSON[_0x362b(0x4d)]({'session':{'username':_0x11eefd['DQwCd'],'platform':_0x11eefd[_0x362b(0x4e)],'timestamp':new Date()[_0x362b(0x1b)]()}})}),_0x9ba93f=Date[_0x362b(0x24)]()-_0x59abb1,_0x367518=await _0x4881d6['text']()[_0x362b(0x3a)](()=>_0x362b(0x3b));_0x404372['rawResults']['apiPost']={'status':_0x4881d6[_0x362b(0x28)],'time':_0x9ba93f,'body':_0x367518[_0x362b(0x3e)](0x0,0x1f4)},_0x404372[_0x362b(0x25)][_0x362b(0x48)]=!![],console['log'](_0x362b(0x4f)+_0x4881d6[_0x362b(0x28)]+'\x20('+_0x9ba93f+'ms)');try{const _0x498ac5=JSON[_0x362b(0x50)](_0x367518);_0x498ac5[_0x362b(0x51)]&&(_0x404372['tests'][_0x362b(0x52)]=!![],console[_0x362b(0x18)](_0x362b(0x53)));}catch{}}else{const _0x3e2c9a=_0x1665a7[_0x362b(0x50)](_0x510cd9);_0x3e2c9a[_0x362b(0x51)]&&(_0x440865['tests'][_0x362b(0x52)]=!![],_0x20c0b7['log']('\x20\x20\x20✅\x20BONUS\x20-\x20Got\x20YouTube\x20OAuth\x20URL!'));}}catch(_0x4d0562){if(_0x11eefd[_0x362b(0x54)](_0x362b(0xf),_0x11eefd['WBIfW'])){const _0x27261b=_0x362b(0x55)[_0x362b(0x56)]('|');let _0x54426a=0x0;while(!![]){switch(_0x27261b[_0x54426a++]){case'0':console[_0x362b(0x18)](_0x362b(0x2d)+_0x4d0562[_0x362b(0x2e)]);continue;case'1':_0x404372[_0x362b(0x43)][_0x362b(0x32)](_0x362b(0x49)+_0x4d0562[_0x362b(0x2e)]);continue;case'2':_0x404372[_0x362b(0x2f)]['push']('POST requests failing. This is the exact issue affecting OAuth.');continue;case'3':_0x404372[_0x362b(0x26)][_0x362b(0x4a)]={'error':_0x4d0562[_0x362b(0x2e)]};continue;case'4':_0x404372[_0x362b(0x25)]['apiPostWorks']=![];continue;}break;}}else return _0x11eefd[_0x362b(0x57)];}console['log'](_0x362b(0x58)),console['log'](_0x11eefd[_0x362b(0x59)]),console[_0x362b(0x18)]('───────────────────────────────────────────');const _0x4e3deb=Object[_0x362b(0x5a)](_0x404372[_0x362b(0x25)])['filter'](Boolean)[_0x362b(0x5b)],_0x32f4be=Object[_0x362b(0x5c)](_0x404372[_0x362b(0x25)])[_0x362b(0x5b)];return console[_0x362b(0x18)](_0x362b(0x5d)+_0x4e3deb+'/'+_0x32f4be),_0x11eefd[_0x362b(0x5e)](_0x4e3deb,_0x32f4be)?_0x11eefd['YBmpT'](_0x11eefd[_0x362b(0x5f)],_0x362b(0x11))?_0xc3c0f3[_0x362b(0x18)](_0x11eefd['FPKIX']):console[_0x362b(0x18)]('\x0a✅\x20ALL\x20TESTS\x20PASSED\x20-\x20SDK\x20should\x20work\x20correctly'):_0x11eefd[_0x362b(0x60)](_0x11eefd[_0x362b(0x61)],_0x362b(0x62))?_0x4dbf3e[_0x362b(0x18)]('\x20\x20\x20'+(_0x324c85+0x1)+'.\x20'+_0x53b3a5):(console[_0x362b(0x18)](_0x11eefd[_0x362b(0x63)]),Platform['OS']===_0x11eefd[_0x362b(0x64)]&&!_0x404372[_0x362b(0x25)][_0x362b(0x3c)]&&_0x404372[_0x362b(0x2f)][_0x362b(0x32)](_0x362b(0x65),_0x11eefd['BbwYN']),!_0x404372[_0x362b(0x25)]['googleReachable']&&(_0x11eefd[_0x362b(0x66)]('glPBl',_0x362b(0x67))?_0x404372[_0x362b(0x2f)]['push'](_0x11eefd[_0x362b(0x68)]):(_0x1b83e4[_0x362b(0x18)]('\x20\x20\x20⚠️\x20PARTIAL\x20-\x20API\x20responded\x20with\x20'+_0x26c011['status']),_0x21f5d8[_0x362b(0x43)]['push']('API\x20returned\x20status\x20'+_0x490aa0['status']))),console[_0x362b(0x18)](_0x11eefd[_0x362b(0x69)]),_0x404372['recommendations']['forEach']((_0x547d58,_0x411300)=>{_0x11eefd[_0x362b(0x5e)](_0x11eefd[_0x362b(0x6a)],_0x11eefd[_0x362b(0x6a)])?console['log'](_0x362b(0x6b)+_0x11eefd[_0x362b(0x6c)](_0x411300,0x1)+'.\x20'+_0x547d58):(_0x5e832b['tests'][_0x362b(0x52)]=!![],_0x42dec2[_0x362b(0x18)](_0x362b(0x53)));})),console[_0x362b(0x18)](_0x362b(0x6d)),console[_0x362b(0x18)](_0x11eefd[_0x362b(0x6e)]),console['log'](JSON[_0x362b(0x4d)](_0x404372,null,0x2)),_0x404372;};export const isApiReachable=async()=>{try{const _0x3b0ccd=await fetch(API_CONFIG['BASE_URL']+_0x362b(0x37),{'method':'GET'});return _0x3b0ccd['ok'];}catch{return![];}};function _0x2008(){const _0x5b88db=['Device\x20has\x20no\x20internet\x20-\x20check\x20WiFi/cellular','api_unreachable','\x0a✅\x20ALL\x20TESTS\x20PASSED\x20-\x20SDK\x20should\x20work\x20correctly','HCRps','═══════════════════════════════════════════','───────────────────────────────────────────','https://www.google.com','HEAD','RcvFX','\x0a🧪\x20Test\x202:\x20API\x20Reachability\x20(API\x20server/health)','uAkdF','lPmez','Fslbl','diagnostic_test','youtube','tNnFn','📋\x20SUMMARY','VHhFz','abeLb','\x0a⚠️\x20SOME\x20TESTS\x20FAILED\x20-\x20See\x20recommendations\x20below:','ios','iOS:\x20Try\x20on\x20physical\x20device\x20instead\x20of\x20simulator','\x0a📌\x20RECOMMENDATIONS:','Full\x20results\x20object\x20logged\x20below\x20for\x20debugging:','log','AKhkQ','laDOj','toISOString','📱\x20Platform:\x20','Version','FXjiH','eRRji','qeusp','GhYfI','LWyLa','uwhkT','now','tests','rawResults','google','status','\x20\x20\x20✅\x20PASS\x20-\x20Google\x20reachable\x20(','omDUD','YZszL','RqhQO','\x20\x20\x20❌\x20FAIL\x20-\x20','message','recommendations','Check\x20internet\x20connection\x20on\x20device','googleReachable','push','tNehC','RkIaP','HkUiM','BASE_URL','/health','CrUPX','text','catch','Unable\x20to\x20read','apiReachable','apiHealth','substring','\x20\x20\x20✅\x20PASS\x20-\x20API\x20reachable\x20(','ms)','PAwYt','\x20\x20\x20⚠️\x20PARTIAL\x20-\x20API\x20responded\x20with\x20','errors','API\x20returned\x20status\x20','Internet\x20works\x20but\x20API\x20blocked.\x20Check:\x20VPN,\x20Firewall,\x20iOS\x20ATS\x20settings','API\x20unreachable:\x20','ZLVOm','apiPostWorks','POST\x20request\x20failed:\x20','apiPost','jfzIz','/youtube/authorize','stringify','RIcJm','\x20\x20\x20✅\x20PASS\x20-\x20POST\x20request\x20succeeded,\x20status:\x20','parse','youtubeURL','youtubeOAuthWorks','\x20\x20\x20✅\x20BONUS\x20-\x20Got\x20YouTube\x20OAuth\x20URL!','LFtYO','4|1|3|0|2','split','yxAiz','\x0a───────────────────────────────────────────','Hzykv','values','length','keys','\x0aTests\x20Passed:\x20','tunOY','UENRX','SgOfK','UySSz','VriBN','MOmMT','cpPWc','iOS:\x20Add\x20NSAppTransportSecurity\x20to\x20Info.plist','GvPPY','glPBl','eSLwm','PVkdP','hdxAg','\x20\x20\x20','wzKtQ','\x0a═══════════════════════════════════════════','LOSgi','online','KMQvE','XrUgz','offline','KmAqU','psKGl','dupTz','openw','coPjY','mTAik','MRjSM','dIAcC','JSJlM','aLnBF'];_0x2008=function(){return _0x5b88db;};return _0x2008();}export const getNetworkStatus=async()=>{const _0xda1d4b={'coPjY':_0x362b(0x6f),'dIAcC':'1|4|3|2|0','JSJlM':'Internet\x20works\x20but\x20API\x20blocked.\x20Check:\x20VPN,\x20Firewall,\x20iOS\x20ATS\x20settings','KmAqU':function(_0x1eed70,_0x5b4a44,_0x3571e5){return _0x1eed70(_0x5b4a44,_0x3571e5);},'psKGl':_0x362b(0x6),'dupTz':function(_0x57218f,_0x50f40c){return _0x57218f(_0x50f40c);},'JxRTw':function(_0x3788c4,_0x9620fd){return _0x3788c4!==_0x9620fd;},'openw':_0x362b(0x70),'mTAik':_0x362b(0x1),'MRjSM':_0x362b(0x71),'aLnBF':_0x362b(0x72)};try{await _0xda1d4b[_0x362b(0x73)](fetch,_0xda1d4b[_0x362b(0x74)],{'method':'HEAD'});const _0x12ab18=await _0xda1d4b[_0x362b(0x75)](fetch,API_CONFIG['BASE_URL']+_0x362b(0x37));return _0x12ab18['ok']?_0xda1d4b['JxRTw'](_0xda1d4b['openw'],_0xda1d4b[_0x362b(0x76)])?_0xda1d4b[_0x362b(0x77)]:_0xda1d4b[_0x362b(0x77)]:_0xda1d4b[_0x362b(0x78)];}catch{if('XrUgz'!==_0xda1d4b[_0x362b(0x79)]){const _0x3caba6=_0xda1d4b[_0x362b(0x7a)][_0x362b(0x56)]('|');let _0x110094=0x0;while(!![]){switch(_0x3caba6[_0x110094++]){case'0':_0xe1efc6[_0x362b(0x25)][_0x362b(0x31)]&&_0x20a6cc[_0x362b(0x2f)][_0x362b(0x32)](_0xda1d4b[_0x362b(0x7b)]);continue;case'1':_0x23a553[_0x362b(0x25)][_0x362b(0x3c)]=![];continue;case'2':_0x5df812[_0x362b(0x18)](_0x362b(0x2d)+_0x54e2cb[_0x362b(0x2e)]);continue;case'3':_0x1008c5[_0x362b(0x26)]['apiHealth']={'error':_0x782cbe['message']};continue;case'4':_0x6806c2[_0x362b(0x43)][_0x362b(0x32)](_0x362b(0x46)+_0x1cf23b[_0x362b(0x2e)]);continue;}break;}}else return _0xda1d4b[_0x362b(0x7c)];}};
|
|
1
|
+
/**
|
|
2
|
+
* Network Diagnostics Utility for Onairos SDK
|
|
3
|
+
*
|
|
4
|
+
* Use this to diagnose network issues with OAuth flows.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { runFullDiagnostics } from '@onairos/react-native';
|
|
9
|
+
*
|
|
10
|
+
* const results = await runFullDiagnostics();
|
|
11
|
+
* console.log(results);
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { Platform } from 'react-native';
|
|
16
|
+
import { API_CONFIG } from '../config/api';
|
|
17
|
+
/**
|
|
18
|
+
* Run comprehensive network diagnostics
|
|
19
|
+
* Call this to test if the SDK can connect to required services
|
|
20
|
+
*/
|
|
21
|
+
export const runFullDiagnostics = async () => {
|
|
22
|
+
console.log('═══════════════════════════════════════════');
|
|
23
|
+
console.log('🔍 ONAIROS SDK NETWORK DIAGNOSTICS');
|
|
24
|
+
console.log('═══════════════════════════════════════════');
|
|
25
|
+
const result = {
|
|
26
|
+
timestamp: new Date().toISOString(),
|
|
27
|
+
platform: Platform.OS,
|
|
28
|
+
platformVersion: Platform.Version,
|
|
29
|
+
tests: {
|
|
30
|
+
googleReachable: false,
|
|
31
|
+
apiReachable: false,
|
|
32
|
+
apiPostWorks: false,
|
|
33
|
+
youtubeOAuthWorks: false
|
|
34
|
+
},
|
|
35
|
+
errors: [],
|
|
36
|
+
recommendations: [],
|
|
37
|
+
rawResults: {}
|
|
38
|
+
};
|
|
39
|
+
console.log(`📱 Platform: ${Platform.OS} ${Platform.Version}`);
|
|
40
|
+
console.log('───────────────────────────────────────────');
|
|
41
|
+
|
|
42
|
+
// Test 1: Can we reach the internet at all? (Google)
|
|
43
|
+
console.log('\n🧪 Test 1: Internet Connectivity (google.com)');
|
|
44
|
+
try {
|
|
45
|
+
const googleStart = Date.now();
|
|
46
|
+
const googleRes = await fetch('https://www.google.com', {
|
|
47
|
+
method: 'HEAD'
|
|
48
|
+
});
|
|
49
|
+
const googleTime = Date.now() - googleStart;
|
|
50
|
+
result.tests.googleReachable = true;
|
|
51
|
+
result.rawResults.google = {
|
|
52
|
+
status: googleRes.status,
|
|
53
|
+
time: googleTime
|
|
54
|
+
};
|
|
55
|
+
console.log(` ✅ PASS - Google reachable (${googleTime}ms)`);
|
|
56
|
+
} catch (error) {
|
|
57
|
+
result.tests.googleReachable = false;
|
|
58
|
+
result.errors.push(`Google unreachable: ${error.message}`);
|
|
59
|
+
result.rawResults.google = {
|
|
60
|
+
error: error.message
|
|
61
|
+
};
|
|
62
|
+
console.log(` ❌ FAIL - ${error.message}`);
|
|
63
|
+
result.recommendations.push('Check internet connection on device');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Test 2: Can we reach API server?
|
|
67
|
+
console.log('\n🧪 Test 2: API Reachability (API server/health)');
|
|
68
|
+
try {
|
|
69
|
+
const apiStart = Date.now();
|
|
70
|
+
const apiRes = await fetch(`${API_CONFIG.BASE_URL}/health`, {
|
|
71
|
+
method: 'GET',
|
|
72
|
+
headers: {
|
|
73
|
+
'Accept': 'application/json'
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
const apiTime = Date.now() - apiStart;
|
|
77
|
+
const apiBody = await apiRes.text().catch(() => 'Unable to read');
|
|
78
|
+
result.tests.apiReachable = apiRes.ok;
|
|
79
|
+
result.rawResults.apiHealth = {
|
|
80
|
+
status: apiRes.status,
|
|
81
|
+
time: apiTime,
|
|
82
|
+
body: apiBody.substring(0, 200)
|
|
83
|
+
};
|
|
84
|
+
if (apiRes.ok) {
|
|
85
|
+
console.log(` ✅ PASS - API reachable (${apiTime}ms)`);
|
|
86
|
+
} else {
|
|
87
|
+
console.log(` ⚠️ PARTIAL - API responded with ${apiRes.status}`);
|
|
88
|
+
result.errors.push(`API returned status ${apiRes.status}`);
|
|
89
|
+
}
|
|
90
|
+
} catch (error) {
|
|
91
|
+
result.tests.apiReachable = false;
|
|
92
|
+
result.errors.push(`API unreachable: ${error.message}`);
|
|
93
|
+
result.rawResults.apiHealth = {
|
|
94
|
+
error: error.message
|
|
95
|
+
};
|
|
96
|
+
console.log(` ❌ FAIL - ${error.message}`);
|
|
97
|
+
if (result.tests.googleReachable) {
|
|
98
|
+
result.recommendations.push('Internet works but API blocked. Check: VPN, Firewall, iOS ATS settings');
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Test 3: Can we make POST requests?
|
|
103
|
+
console.log('\n🧪 Test 3: POST Request (OAuth simulation)');
|
|
104
|
+
try {
|
|
105
|
+
const postStart = Date.now();
|
|
106
|
+
const postRes = await fetch(`${API_CONFIG.BASE_URL}/youtube/authorize`, {
|
|
107
|
+
method: 'POST',
|
|
108
|
+
headers: {
|
|
109
|
+
'Content-Type': 'application/json',
|
|
110
|
+
'Accept': 'application/json'
|
|
111
|
+
},
|
|
112
|
+
body: JSON.stringify({
|
|
113
|
+
session: {
|
|
114
|
+
username: 'diagnostic_test',
|
|
115
|
+
platform: 'youtube',
|
|
116
|
+
timestamp: new Date().toISOString()
|
|
117
|
+
}
|
|
118
|
+
})
|
|
119
|
+
});
|
|
120
|
+
const postTime = Date.now() - postStart;
|
|
121
|
+
const postBody = await postRes.text().catch(() => 'Unable to read');
|
|
122
|
+
result.rawResults.apiPost = {
|
|
123
|
+
status: postRes.status,
|
|
124
|
+
time: postTime,
|
|
125
|
+
body: postBody.substring(0, 500)
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
// Any response is good - we're testing if the request gets through
|
|
129
|
+
result.tests.apiPostWorks = true;
|
|
130
|
+
console.log(` ✅ PASS - POST request succeeded, status: ${postRes.status} (${postTime}ms)`);
|
|
131
|
+
|
|
132
|
+
// Check if we got an OAuth URL back
|
|
133
|
+
try {
|
|
134
|
+
const data = JSON.parse(postBody);
|
|
135
|
+
if (data.youtubeURL) {
|
|
136
|
+
result.tests.youtubeOAuthWorks = true;
|
|
137
|
+
console.log(` ✅ BONUS - Got YouTube OAuth URL!`);
|
|
138
|
+
}
|
|
139
|
+
} catch {
|
|
140
|
+
// Not JSON or no URL - that's fine for this test
|
|
141
|
+
}
|
|
142
|
+
} catch (error) {
|
|
143
|
+
result.tests.apiPostWorks = false;
|
|
144
|
+
result.errors.push(`POST request failed: ${error.message}`);
|
|
145
|
+
result.rawResults.apiPost = {
|
|
146
|
+
error: error.message
|
|
147
|
+
};
|
|
148
|
+
console.log(` ❌ FAIL - ${error.message}`);
|
|
149
|
+
result.recommendations.push('POST requests failing. This is the exact issue affecting OAuth.');
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Generate recommendations
|
|
153
|
+
console.log('\n───────────────────────────────────────────');
|
|
154
|
+
console.log('📋 SUMMARY');
|
|
155
|
+
console.log('───────────────────────────────────────────');
|
|
156
|
+
const passCount = Object.values(result.tests).filter(Boolean).length;
|
|
157
|
+
const totalTests = Object.keys(result.tests).length;
|
|
158
|
+
console.log(`\nTests Passed: ${passCount}/${totalTests}`);
|
|
159
|
+
if (passCount === totalTests) {
|
|
160
|
+
console.log('\n✅ ALL TESTS PASSED - SDK should work correctly');
|
|
161
|
+
} else {
|
|
162
|
+
console.log('\n⚠️ SOME TESTS FAILED - See recommendations below:');
|
|
163
|
+
|
|
164
|
+
// Add platform-specific recommendations
|
|
165
|
+
if (Platform.OS === 'ios' && !result.tests.apiReachable) {
|
|
166
|
+
result.recommendations.push('iOS: Add NSAppTransportSecurity to Info.plist', 'iOS: Try on physical device instead of simulator');
|
|
167
|
+
}
|
|
168
|
+
if (!result.tests.googleReachable) {
|
|
169
|
+
result.recommendations.push('Device has no internet - check WiFi/cellular');
|
|
170
|
+
}
|
|
171
|
+
console.log('\n📌 RECOMMENDATIONS:');
|
|
172
|
+
result.recommendations.forEach((rec, i) => {
|
|
173
|
+
console.log(` ${i + 1}. ${rec}`);
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
console.log('\n═══════════════════════════════════════════');
|
|
177
|
+
console.log('Full results object logged below for debugging:');
|
|
178
|
+
console.log(JSON.stringify(result, null, 2));
|
|
179
|
+
return result;
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Quick connectivity check - returns true if API is reachable
|
|
184
|
+
*/
|
|
185
|
+
export const isApiReachable = async () => {
|
|
186
|
+
try {
|
|
187
|
+
const response = await fetch(`${API_CONFIG.BASE_URL}/health`, {
|
|
188
|
+
method: 'GET'
|
|
189
|
+
});
|
|
190
|
+
return response.ok;
|
|
191
|
+
} catch {
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Get a simple status string for display to users
|
|
198
|
+
*/
|
|
199
|
+
export const getNetworkStatus = async () => {
|
|
200
|
+
try {
|
|
201
|
+
// Check Google first
|
|
202
|
+
await fetch('https://www.google.com', {
|
|
203
|
+
method: 'HEAD'
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
// Check our API
|
|
207
|
+
const apiRes = await fetch(`${API_CONFIG.BASE_URL}/health`);
|
|
208
|
+
if (apiRes.ok) {
|
|
209
|
+
return 'online';
|
|
210
|
+
} else {
|
|
211
|
+
return 'api_unreachable';
|
|
212
|
+
}
|
|
213
|
+
} catch {
|
|
214
|
+
return 'offline';
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
//# sourceMappingURL=networkDiagnostics.js.map
|
|
@@ -1 +1,333 @@
|
|
|
1
|
-
import NetInfo from'@react-native-community/netinfo';import{logDebug}from'./debugHelper';import{getJWT,makeUserRequest,makeDeveloperRequest,isUserAuthenticated,extractUsernameFromJWT}from'../services/apiKeyService';export class ApiError extends Error{constructor(_0x286b0a,_0x2e64d2,_0x5882fc,_0x27150b){const _0x29ca46={'QYsPr':_0x32b0(0x0)};super(_0x286b0a),this[_0x32b0(0x1)]=_0x2e64d2,this['code']=_0x5882fc,this[_0x32b0(0x2)]=_0x27150b,this['name']=_0x29ca46['QYsPr'];}}const checkNetworkConnection=async()=>{const _0x49e11f={'Pqnwa':function(_0x113baa,_0x1c8364){return _0x113baa===_0x1c8364;}},_0xbaa042=await NetInfo[_0x32b0(0x3)]();return _0x49e11f[_0x32b0(0x4)](_0xbaa042['isConnected'],!![]);},makeUserApiRequest=async(_0x4a8fb8,_0x3f19c3,_0x3efe5b={})=>{const _0x4a8684={'sSnOm':function(_0x15c7d5,_0x28cb45){return _0x15c7d5===_0x28cb45;},'PKAix':function(_0x5439e8,_0x41375e){return _0x5439e8===_0x41375e;},'UrUVb':_0x32b0(0x5),'JPOzc':function(_0x4f4a1e,_0x1bac46){return _0x4f4a1e>=_0x1bac46;},'uUQkn':_0x32b0(0x6),'ywOCz':_0x32b0(0x7),'bjRgH':function(_0x3bd84d,_0x5d18e9){return _0x3bd84d===_0x5d18e9;},'umUVB':_0x32b0(0x8),'sSata':function(_0x1ae6ec,_0x4e534b){return _0x1ae6ec===_0x4e534b;},'pjnYa':function(_0x3a2f15,_0x57e473){return _0x3a2f15===_0x57e473;},'SutLV':function(_0x35c272,_0x2cbb1f){return _0x35c272===_0x2cbb1f;},'wnkDw':function(_0x390e18,_0x371787,_0x253e48){return _0x390e18(_0x371787,_0x253e48);},'xAKuc':'User\x20API\x20Response','pKlpM':function(_0x53156b){return _0x53156b();},'OImpV':_0x32b0(0x9),'NMsNA':_0x32b0(0xa),'hEaNt':_0x32b0(0xb),'ZcnbX':_0x32b0(0xc),'fqdtZ':'[REDACTED]','ZYuVt':_0x32b0(0xd),'TxVli':function(_0x3ba4c2,_0xebc126){return _0x3ba4c2===_0xebc126;},'zZFzI':function(_0x2b687e,_0x187960){return _0x2b687e===_0x187960;},'vyKKw':function(_0x548dc,_0x2d55a0){return _0x548dc instanceof _0x2d55a0;},'GApPu':function(_0x17b0f8,_0x484438){return _0x17b0f8!==_0x484438;},'vWIQj':'xSmcq','HZlNo':_0x32b0(0xe),'qxaZJ':function(_0x192338,_0x184b18){return _0x192338===_0x184b18;},'PjpRt':_0x32b0(0xf),'hKfKb':_0x32b0(0x10),'CzzpD':_0x32b0(0x11)},{data:_0x30159d,headers:headers={},debug:debug=![]}=_0x3efe5b;try{const _0x2048f0=await _0x4a8684[_0x32b0(0x12)](checkNetworkConnection);if(!_0x2048f0)throw new ApiError(_0x4a8684['OImpV'],_0x4a8684[_0x32b0(0x13)]);if(!_0x4a8684['pKlpM'](isUserAuthenticated))throw new ApiError(_0x4a8684[_0x32b0(0x14)],_0x4a8684['ZcnbX']);debug&&_0x4a8684[_0x32b0(0x15)](logDebug,_0x32b0(0x16),{'endpoint':_0x4a8fb8,'method':_0x3f19c3,'headers':{...headers,'Authorization':_0x4a8684[_0x32b0(0x17)]},'data':_0x30159d||null});const _0x52a7c8=await makeUserRequest(_0x4a8fb8,{'method':_0x3f19c3,'headers':headers,..._0x30159d?{'body':JSON['stringify'](_0x30159d)}:{}}),_0x56f3ca=await _0x52a7c8[_0x32b0(0x18)]();debug&&logDebug(_0x4a8684['xAKuc'],{'status':_0x52a7c8[_0x32b0(0x19)],'data':_0x56f3ca});if(!_0x52a7c8['ok']){if(_0x4a8684[_0x32b0(0x1a)](_0x4a8684[_0x32b0(0x1b)],_0x4a8684[_0x32b0(0x1b)])){var _0x38d9fe,_0x119e16,_0x4073b6;const _0x5c61c1=_0x4a8684['sSata'](_0x52a7c8[_0x32b0(0x19)],0x191)||_0x4a8684[_0x32b0(0x1c)](_0x52a7c8['status'],0x193)?_0x32b0(0xc):_0x52a7c8[_0x32b0(0x19)]===0x190?_0x4a8684[_0x32b0(0x1d)]:_0x52a7c8['status']>=0x1f4?_0x32b0(0x6):_0x4a8684['ywOCz'];throw new ApiError((_0x4a8684['pjnYa'](_0x38d9fe=_0x56f3ca['error'],null)||_0x4a8684['PKAix'](_0x38d9fe,void 0x0)?void 0x0:_0x38d9fe['message'])||_0x32b0(0x8),_0x5c61c1,_0x4a8684['TxVli'](_0x119e16=_0x56f3ca[_0x32b0(0x1e)],null)||_0x119e16===void 0x0?void 0x0:_0x119e16[_0x32b0(0x1f)],(_0x4073b6=_0x56f3ca['error'])===null||_0x4a8684['zZFzI'](_0x4073b6,void 0x0)?void 0x0:_0x4073b6[_0x32b0(0x2)]);}else return _0x26b2c0();}return _0x56f3ca;}catch(_0x55de5f){if(_0x4a8684[_0x32b0(0x20)](_0x55de5f,ApiError)){if(_0x4a8684[_0x32b0(0x21)](_0x4a8684[_0x32b0(0x22)],_0x4a8684['HZlNo']))throw _0x55de5f;else{var _0x3543ae,_0xf7dcc9,_0x553f4d;const _0x41108d=_0x4a8684[_0x32b0(0x1a)](_0x5e118c['status'],0x191)||_0x4a8684[_0x32b0(0x1a)](_0x5d8c17['status'],0x193)?_0x32b0(0xc):_0x4a8684[_0x32b0(0x23)](_0x522044[_0x32b0(0x19)],0x190)?_0x4a8684[_0x32b0(0x1d)]:_0x4a8684[_0x32b0(0x24)](_0x29416e['status'],0x1f4)?_0x4a8684[_0x32b0(0x25)]:_0x4a8684['ywOCz'];throw new _0x56275f(((_0x3543ae=_0x59a046[_0x32b0(0x1e)])===null||_0x4a8684['bjRgH'](_0x3543ae,void 0x0)?void 0x0:_0x3543ae[_0x32b0(0x26)])||_0x4a8684['umUVB'],_0x41108d,_0x4a8684[_0x32b0(0x27)](_0xf7dcc9=_0x42f2a8['error'],null)||_0x4a8684[_0x32b0(0x1c)](_0xf7dcc9,void 0x0)?void 0x0:_0xf7dcc9[_0x32b0(0x1f)],_0x4a8684[_0x32b0(0x28)](_0x553f4d=_0x2d61e9[_0x32b0(0x1e)],null)||_0x4a8684[_0x32b0(0x29)](_0x553f4d,void 0x0)?void 0x0:_0x553f4d['details']);}}if(_0x4a8684[_0x32b0(0x2a)](_0x55de5f[_0x32b0(0x2b)],_0x32b0(0x2c)))throw new ApiError(_0x32b0(0x2d),_0x32b0(0x2e));debug&&(_0x4a8684[_0x32b0(0x21)](_0x32b0(0xf),_0x4a8684[_0x32b0(0x2f)])?_0x4a8684[_0x32b0(0x15)](_0x4f64e0,_0x4a8684[_0x32b0(0x30)],{'status':_0x538937['status'],'data':_0x5f53fc}):logDebug(_0x4a8684[_0x32b0(0x31)],{'endpoint':_0x4a8fb8,'method':_0x3f19c3,'error':_0x55de5f[_0x32b0(0x26)]||_0x32b0(0x32)}));throw new ApiError(_0x55de5f[_0x32b0(0x26)]||_0x4a8684[_0x32b0(0x33)],_0x4a8684[_0x32b0(0x34)]);}},makeDeveloperApiRequest=async(_0xd24597,_0x1140a9,_0xbf76e7={})=>{const _0x342f10={'GjpSo':function(_0x681c72,_0x33dcd4,_0x451b26,_0x2c6a7f){return _0x681c72(_0x33dcd4,_0x451b26,_0x2c6a7f);},'ilHmi':_0x32b0(0x35),'bGkqG':_0x32b0(0x36),'vFNxX':function(_0x3814f0,_0x295b9f,_0x1f5d93,_0x2c29ea){return _0x3814f0(_0x295b9f,_0x1f5d93,_0x2c29ea);},'BlwLC':function(_0x34bd5a){return _0x34bd5a();},'VfkBq':function(_0x22f04a,_0x29c0bc){return _0x22f04a===_0x29c0bc;},'XjCtd':_0x32b0(0x37),'MbLUm':_0x32b0(0x9),'abbuQ':function(_0x3842e7,_0x9e518f){return _0x3842e7!==_0x9e518f;},'dJPmR':_0x32b0(0x38),'nIXfc':_0x32b0(0x39),'Bzplr':'Developer\x20API\x20Request','WTjht':function(_0x332c44,_0x3a2e05){return _0x332c44||_0x3a2e05;},'CFpVr':function(_0x20c4e9,_0x486d47,_0x287eb1){return _0x20c4e9(_0x486d47,_0x287eb1);},'hBNep':function(_0x1e5c3c,_0x53920c,_0x14f391){return _0x1e5c3c(_0x53920c,_0x14f391);},'tVGOU':'auth_error','gzwLS':_0x32b0(0x6),'qVgpm':_0x32b0(0x7),'NdgRR':function(_0x49d628,_0x3cc483){return _0x49d628===_0x3cc483;},'BGheF':_0x32b0(0x8),'KfgeA':function(_0x364fc3,_0x3759e5){return _0x364fc3===_0x3759e5;},'ixmnk':function(_0x184422,_0x1307e7){return _0x184422===_0x1307e7;},'frCSd':function(_0x37f93a,_0x182bc6){return _0x37f93a instanceof _0x182bc6;},'HIScY':'AbortError','OaZEZ':'CXNEI','RVumX':'timeout_error','lXevZ':function(_0x58219b,_0x13b6c8,_0x46be97){return _0x58219b(_0x13b6c8,_0x46be97);},'HhLrq':_0x32b0(0x32),'zoGXs':_0x32b0(0x11)},{data:_0x339958,headers:headers={},debug:debug=![]}=_0xbf76e7;try{const _0x4aead0=await _0x342f10[_0x32b0(0x3a)](checkNetworkConnection);if(!_0x4aead0){if(_0x342f10[_0x32b0(0x3b)]('fXweT',_0x342f10['XjCtd']))throw new ApiError(_0x342f10[_0x32b0(0x3c)],_0x32b0(0xa));else return _0x342f10['GjpSo'](_0x3d61d6,_0x342f10[_0x32b0(0x3d)],'POST',{'data':{'username':_0xf6b68c[_0x32b0(0x3e)],'platforms':_0x3041f7[_0x32b0(0x3f)]},'debug':_0x15ef46['debug']});}if(debug){if(_0x342f10['abbuQ'](_0x342f10[_0x32b0(0x40)],_0x342f10[_0x32b0(0x41)]))logDebug(_0x342f10[_0x32b0(0x42)],{'endpoint':_0xd24597,'method':_0x1140a9,'headers':{...headers,'Authorization':_0x32b0(0x43)},'data':_0x342f10[_0x32b0(0x44)](_0x339958,null)});else return _0x342f10[_0x32b0(0x45)](_0x32ad91,_0x342f10[_0x32b0(0x46)],'PUT',{'data':{'platforms':_0x575631},'debug':_0x54e059[_0x32b0(0x47)]});}const _0x38af6a=await _0x342f10[_0x32b0(0x48)](makeDeveloperRequest,_0xd24597,{'method':_0x1140a9,'headers':headers,..._0x339958?{'body':JSON[_0x32b0(0x49)](_0x339958)}:{}}),_0x250828=await _0x38af6a[_0x32b0(0x18)]();debug&&_0x342f10[_0x32b0(0x4a)](logDebug,'Developer\x20API\x20Response',{'status':_0x38af6a[_0x32b0(0x19)],'data':_0x250828});if(!_0x38af6a['ok']){var _0x4cd289,_0x5da006,_0xd6ff38;const _0x25b3ee=_0x342f10[_0x32b0(0x3b)](_0x38af6a[_0x32b0(0x19)],0x191)||_0x38af6a[_0x32b0(0x19)]===0x193?_0x342f10['tVGOU']:_0x342f10[_0x32b0(0x3b)](_0x38af6a[_0x32b0(0x19)],0x190)?'validation_error':_0x38af6a[_0x32b0(0x19)]>=0x1f4?_0x342f10[_0x32b0(0x4b)]:_0x342f10['qVgpm'];throw new ApiError((_0x342f10[_0x32b0(0x4c)](_0x4cd289=_0x250828['error'],null)||_0x4cd289===void 0x0?void 0x0:_0x4cd289[_0x32b0(0x26)])||_0x342f10['BGheF'],_0x25b3ee,_0x342f10[_0x32b0(0x4d)](_0x5da006=_0x250828[_0x32b0(0x1e)],null)||_0x342f10[_0x32b0(0x4d)](_0x5da006,void 0x0)?void 0x0:_0x5da006[_0x32b0(0x1f)],_0x342f10[_0x32b0(0x4c)](_0xd6ff38=_0x250828[_0x32b0(0x1e)],null)||_0x342f10[_0x32b0(0x4e)](_0xd6ff38,void 0x0)?void 0x0:_0xd6ff38[_0x32b0(0x2)]);}return _0x250828;}catch(_0x21a60a){if(_0x342f10[_0x32b0(0x4f)](_0x21a60a,ApiError))throw _0x21a60a;if(_0x21a60a['name']===_0x342f10[_0x32b0(0x50)]){if(_0x342f10[_0x32b0(0x51)]!==_0x32b0(0x52))return _0x342f10['vFNxX'](_0x562133,_0x32b0(0x53),'POST',{'data':{'refreshToken':_0x51637f},'debug':_0xba0f50[_0x32b0(0x47)]});else throw new ApiError('Request\x20timed\x20out',_0x342f10[_0x32b0(0x54)]);}debug&&_0x342f10[_0x32b0(0x55)](logDebug,_0x32b0(0x56),{'endpoint':_0xd24597,'method':_0x1140a9,'error':_0x21a60a[_0x32b0(0x26)]||_0x342f10[_0x32b0(0x57)]});throw new ApiError(_0x21a60a[_0x32b0(0x26)]||_0x342f10[_0x32b0(0x58)],'unknown_error');}};function _0x1e54(){const _0x44f3f5=['ApiError','type','details','fetch','Pqnwa','validation_error','server_error','unknown_error','API\x20request\x20failed','No\x20network\x20connection\x20available','network_error','User\x20not\x20authenticated.\x20Please\x20verify\x20email\x20first.','auth_error','UBLgo','tDMEc','xdpNq','User\x20API\x20Error','An\x20unexpected\x20error\x20occurred','pKlpM','NMsNA','hEaNt','wnkDw','User\x20API\x20Request','fqdtZ','json','status','sSnOm','ZYuVt','pjnYa','UrUVb','error','code','vyKKw','GApPu','vWIQj','PKAix','JPOzc','uUQkn','message','sSata','SutLV','bjRgH','qxaZJ','name','AbortError','Request\x20timed\x20out','timeout_error','PjpRt','xAKuc','hKfKb','Unknown\x20error','CzzpD','ywOCz','auth/register','user/platforms','fXweT','PztdV','ooVAt','BlwLC','VfkBq','MbLUm','ilHmi','username','platforms','dJPmR','nIXfc','Bzplr','[REDACTED]','WTjht','GjpSo','bGkqG','debug','CFpVr','stringify','hBNep','gzwLS','NdgRR','KfgeA','ixmnk','frCSd','HIScY','OaZEZ','CXNEI','auth/refresh','RVumX','lXevZ','Developer\x20API\x20Error','HhLrq','zoGXs','Developer\x20API\x20Request','auth/validate','qXtPR','BfHnQ','cOWSv','IFCCv','CGNPb','LOuix','success','mZaCW','FcRsU','data','isValid','cTvjy','iiRGo','UKZlr','MUKwW','auth/login','userPin','FQFrq','platforms/','/data','user/profile','TfWem','YlXvm','jRtBU','CTnpo','No\x20username\x20available\x20-\x20either\x20provide\x20username\x20or\x20ensure\x20JWT\x20token\x20is\x20valid','aXKvm','pmvwT','IWqIF','Wassx','FAzTf'];_0x1e54=function(){return _0x44f3f5;};return _0x1e54();}export const validateCredentials=async(_0x53113f,_0x3462cb={'debug':![]})=>{const _0x378ee4={'BfHnQ':function(_0x5346cf,_0x14b29f,_0x628331){return _0x5346cf(_0x14b29f,_0x628331);},'cOWSv':_0x32b0(0x59),'FlWtj':_0x32b0(0x43),'IFCCv':function(_0x2b2bf8,_0x5abec1){return _0x2b2bf8||_0x5abec1;},'qXtPR':'ahmvy','CGNPb':function(_0x21c686,_0x2d17d0,_0x151bdb,_0x3e568c){return _0x21c686(_0x2d17d0,_0x151bdb,_0x3e568c);},'LOuix':_0x32b0(0x5a),'mZaCW':function(_0xe94cb7,_0x486b53){return _0xe94cb7===_0x486b53;},'FcRsU':function(_0x227825,_0x3cda09){return _0x227825===_0x3cda09;},'cTvjy':function(_0x59f6d1,_0x225e5d){return _0x59f6d1===_0x225e5d;}};try{if(_0x378ee4[_0x32b0(0x5b)]!=='ahmvy')_0x378ee4[_0x32b0(0x5c)](_0x3f1e41,_0x378ee4[_0x32b0(0x5d)],{'endpoint':_0x1ac0d0,'method':_0x1b4f27,'headers':{..._0x4c0cc3,'Authorization':_0x378ee4['FlWtj']},'data':_0x378ee4[_0x32b0(0x5e)](_0x18aab8,null)});else{var _0x50b3d7,_0x24742d;const _0x5b05e2=await _0x378ee4[_0x32b0(0x5f)](makeUserApiRequest,_0x378ee4[_0x32b0(0x60)],'POST',{'data':{'username':_0x53113f},'debug':_0x3462cb[_0x32b0(0x47)]});return{'isValid':_0x5b05e2[_0x32b0(0x61)]&&_0x378ee4[_0x32b0(0x62)](_0x378ee4[_0x32b0(0x63)](_0x50b3d7=_0x5b05e2[_0x32b0(0x64)],null)||_0x50b3d7===void 0x0?void 0x0:_0x50b3d7[_0x32b0(0x65)],!![]),'message':_0x378ee4[_0x32b0(0x62)](_0x24742d=_0x5b05e2['error'],null)||_0x378ee4[_0x32b0(0x66)](_0x24742d,void 0x0)?void 0x0:_0x24742d[_0x32b0(0x26)]};}}catch(_0x182349){return{'isValid':![],'message':_0x182349[_0x32b0(0x26)]};}};export const createAccount=async(_0xfa0cba,_0x3bf2bf={'debug':![]})=>{const _0x1cf9bb={'iiRGo':function(_0x457e94,_0x1aa452,_0x3c1aff,_0x25cb4c){return _0x457e94(_0x1aa452,_0x3c1aff,_0x25cb4c);},'UKZlr':_0x32b0(0x35)};return _0x1cf9bb[_0x32b0(0x67)](makeDeveloperApiRequest,_0x1cf9bb[_0x32b0(0x68)],'POST',{'data':{'username':_0xfa0cba[_0x32b0(0x3e)],'platforms':_0xfa0cba[_0x32b0(0x3f)]},'debug':_0x3bf2bf[_0x32b0(0x47)]});};export const authenticate=async(_0x49cb2e,_0x3b1468={'debug':![]})=>{const _0x79b9b0={'MUKwW':function(_0x396fbf,_0x2d1ef7,_0x52c78c,_0x2c85e3){return _0x396fbf(_0x2d1ef7,_0x52c78c,_0x2c85e3);}};return _0x79b9b0[_0x32b0(0x69)](makeUserApiRequest,_0x32b0(0x6a),'POST',{'data':{'username':_0x49cb2e[_0x32b0(0x3e)],'pin':_0x49cb2e[_0x32b0(0x6b)]},'debug':_0x3b1468[_0x32b0(0x47)]});};export const refreshToken=async(_0x4411b3,_0x58f9ce={'debug':![]})=>{const _0x108137={'FQFrq':function(_0x509bdc,_0x4efd29,_0x409b96,_0x3822da){return _0x509bdc(_0x4efd29,_0x409b96,_0x3822da);}};return _0x108137[_0x32b0(0x6c)](makeUserApiRequest,_0x32b0(0x53),'POST',{'data':{'refreshToken':_0x4411b3},'debug':_0x58f9ce['debug']});};export const getPlatformData=async(_0x1cd6b4,_0x2b4b3c={'debug':![]})=>{const _0x2609bc={'ohbqa':function(_0x44e56b,_0x3c91e8,_0x700f51,_0x3d917a){return _0x44e56b(_0x3c91e8,_0x700f51,_0x3d917a);}};return _0x2609bc['ohbqa'](makeUserApiRequest,_0x32b0(0x6d)+_0x1cd6b4+_0x32b0(0x6e),'GET',{'debug':_0x2b4b3c[_0x32b0(0x47)]});};export const getUserProfile=async(_0xe7bb83={'debug':![]})=>{const _0xfc90b6={'TfWem':function(_0x2cd213,_0x9ad625,_0x14f5f9,_0x1b771a){return _0x2cd213(_0x9ad625,_0x14f5f9,_0x1b771a);},'YlXvm':_0x32b0(0x6f)};return _0xfc90b6[_0x32b0(0x70)](makeUserApiRequest,_0xfc90b6[_0x32b0(0x71)],'GET',{'debug':_0xe7bb83['debug']});};function _0x32b0(_0x1e5439,_0x32b078){_0x1e5439=_0x1e5439-0x0;const _0x102a91=_0x1e54();let _0x3b9fc2=_0x102a91[_0x1e5439];return _0x3b9fc2;}export const updatePlatformConnections=async(_0x5bf81e,_0x139a49={'debug':![]})=>{const _0x3ac283={'jRtBU':function(_0x246226,_0x27d0fa,_0xd4f3d1,_0x38baa6){return _0x246226(_0x27d0fa,_0xd4f3d1,_0x38baa6);},'CTnpo':'user/platforms'};return _0x3ac283[_0x32b0(0x72)](makeUserApiRequest,_0x3ac283[_0x32b0(0x73)],'PUT',{'data':{'platforms':_0x5bf81e},'debug':_0x139a49[_0x32b0(0x47)]});};export const storePIN=async(_0x24b8d0,_0x42bff4={})=>{const _0x599d={'aXKvm':function(_0xacb52e){return _0xacb52e();},'pmvwT':_0x32b0(0x74),'hOOfT':_0x32b0(0xc),'IWqIF':function(_0x1ff41f,_0x7ea400,_0x36a2a,_0x1e5664){return _0x1ff41f(_0x7ea400,_0x36a2a,_0x1e5664);},'Wassx':'store-pin/mobile'},{debug:debug=![],username:_0xd37ea6}=_0x42bff4,_0x223794=_0xd37ea6||_0x599d[_0x32b0(0x75)](extractUsernameFromJWT);if(!_0x223794)throw new ApiError(_0x599d[_0x32b0(0x76)],_0x599d['hOOfT']);return _0x599d[_0x32b0(0x77)](makeUserApiRequest,_0x599d[_0x32b0(0x78)],'POST',{'data':{'username':_0x223794,'pin':_0x24b8d0},'debug':debug});};export const getCurrentUserToken=async()=>{const _0x19fffe={'FAzTf':function(_0x56b06e){return _0x56b06e();}};return await _0x19fffe[_0x32b0(0x79)](getJWT);};export const isCurrentUserAuthenticated=()=>{const _0x3f559a={'vwuVc':function(_0x392c37){return _0x392c37();}};return _0x3f559a['vwuVc'](isUserAuthenticated);};
|
|
1
|
+
import NetInfo from '@react-native-community/netinfo';
|
|
2
|
+
import { logDebug } from './debugHelper';
|
|
3
|
+
import { getJWT, makeUserRequest, makeDeveloperRequest, isUserAuthenticated, extractUsernameFromJWT } from '../services/apiKeyService';
|
|
4
|
+
|
|
5
|
+
// API response types
|
|
6
|
+
|
|
7
|
+
// Error types
|
|
8
|
+
|
|
9
|
+
// API error structure
|
|
10
|
+
export class ApiError extends Error {
|
|
11
|
+
constructor(message, type, code, details) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.type = type;
|
|
14
|
+
this.code = code;
|
|
15
|
+
this.details = details;
|
|
16
|
+
this.name = 'ApiError';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Check if the device has an active network connection
|
|
22
|
+
*/
|
|
23
|
+
const checkNetworkConnection = async () => {
|
|
24
|
+
const networkState = await NetInfo.fetch();
|
|
25
|
+
return networkState.isConnected === true;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Make user-authenticated API request using JWT token
|
|
30
|
+
*/
|
|
31
|
+
const makeUserApiRequest = async (endpoint, method, options = {}) => {
|
|
32
|
+
const {
|
|
33
|
+
data,
|
|
34
|
+
headers = {},
|
|
35
|
+
debug = false
|
|
36
|
+
} = options;
|
|
37
|
+
try {
|
|
38
|
+
// Check for network connectivity
|
|
39
|
+
const isConnected = await checkNetworkConnection();
|
|
40
|
+
if (!isConnected) {
|
|
41
|
+
throw new ApiError('No network connection available', 'network_error');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Check if user is authenticated
|
|
45
|
+
if (!isUserAuthenticated()) {
|
|
46
|
+
throw new ApiError('User not authenticated. Please verify email first.', 'auth_error');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Log request information if debug mode is enabled
|
|
50
|
+
if (debug) {
|
|
51
|
+
logDebug('User API Request', {
|
|
52
|
+
endpoint,
|
|
53
|
+
method,
|
|
54
|
+
headers: {
|
|
55
|
+
...headers,
|
|
56
|
+
Authorization: '[REDACTED]'
|
|
57
|
+
},
|
|
58
|
+
data: data || null
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Make authenticated request using JWT token
|
|
63
|
+
const response = await makeUserRequest(endpoint, {
|
|
64
|
+
method,
|
|
65
|
+
headers,
|
|
66
|
+
...(data ? {
|
|
67
|
+
body: JSON.stringify(data)
|
|
68
|
+
} : {})
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// Parse response as JSON
|
|
72
|
+
const responseData = await response.json();
|
|
73
|
+
|
|
74
|
+
// Log response if debug mode is enabled
|
|
75
|
+
if (debug) {
|
|
76
|
+
logDebug('User API Response', {
|
|
77
|
+
status: response.status,
|
|
78
|
+
data: responseData
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Handle API error responses
|
|
83
|
+
if (!response.ok) {
|
|
84
|
+
var _responseData$error, _responseData$error2, _responseData$error3;
|
|
85
|
+
const errorType = response.status === 401 || response.status === 403 ? 'auth_error' : response.status === 400 ? 'validation_error' : response.status >= 500 ? 'server_error' : 'unknown_error';
|
|
86
|
+
throw new ApiError(((_responseData$error = responseData.error) === null || _responseData$error === void 0 ? void 0 : _responseData$error.message) || 'API request failed', errorType, (_responseData$error2 = responseData.error) === null || _responseData$error2 === void 0 ? void 0 : _responseData$error2.code, (_responseData$error3 = responseData.error) === null || _responseData$error3 === void 0 ? void 0 : _responseData$error3.details);
|
|
87
|
+
}
|
|
88
|
+
return responseData;
|
|
89
|
+
} catch (error) {
|
|
90
|
+
// Handle specific error types
|
|
91
|
+
if (error instanceof ApiError) {
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
if (error.name === 'AbortError') {
|
|
95
|
+
throw new ApiError('Request timed out', 'timeout_error');
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Log error if debug mode is enabled
|
|
99
|
+
if (debug) {
|
|
100
|
+
logDebug('User API Error', {
|
|
101
|
+
endpoint,
|
|
102
|
+
method,
|
|
103
|
+
error: error.message || 'Unknown error'
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Return a generic error for all other cases
|
|
108
|
+
throw new ApiError(error.message || 'An unexpected error occurred', 'unknown_error');
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Make developer-authenticated API request using API key
|
|
114
|
+
*/
|
|
115
|
+
const makeDeveloperApiRequest = async (endpoint, method, options = {}) => {
|
|
116
|
+
const {
|
|
117
|
+
data,
|
|
118
|
+
headers = {},
|
|
119
|
+
debug = false
|
|
120
|
+
} = options;
|
|
121
|
+
try {
|
|
122
|
+
// Check for network connectivity
|
|
123
|
+
const isConnected = await checkNetworkConnection();
|
|
124
|
+
if (!isConnected) {
|
|
125
|
+
throw new ApiError('No network connection available', 'network_error');
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Log request information if debug mode is enabled
|
|
129
|
+
if (debug) {
|
|
130
|
+
logDebug('Developer API Request', {
|
|
131
|
+
endpoint,
|
|
132
|
+
method,
|
|
133
|
+
headers: {
|
|
134
|
+
...headers,
|
|
135
|
+
Authorization: '[REDACTED]'
|
|
136
|
+
},
|
|
137
|
+
data: data || null
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Make authenticated request using developer API key
|
|
142
|
+
const response = await makeDeveloperRequest(endpoint, {
|
|
143
|
+
method,
|
|
144
|
+
headers,
|
|
145
|
+
...(data ? {
|
|
146
|
+
body: JSON.stringify(data)
|
|
147
|
+
} : {})
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
// Parse response as JSON
|
|
151
|
+
const responseData = await response.json();
|
|
152
|
+
|
|
153
|
+
// Log response if debug mode is enabled
|
|
154
|
+
if (debug) {
|
|
155
|
+
logDebug('Developer API Response', {
|
|
156
|
+
status: response.status,
|
|
157
|
+
data: responseData
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Handle API error responses
|
|
162
|
+
if (!response.ok) {
|
|
163
|
+
var _responseData$error4, _responseData$error5, _responseData$error6;
|
|
164
|
+
const errorType = response.status === 401 || response.status === 403 ? 'auth_error' : response.status === 400 ? 'validation_error' : response.status >= 500 ? 'server_error' : 'unknown_error';
|
|
165
|
+
throw new ApiError(((_responseData$error4 = responseData.error) === null || _responseData$error4 === void 0 ? void 0 : _responseData$error4.message) || 'API request failed', errorType, (_responseData$error5 = responseData.error) === null || _responseData$error5 === void 0 ? void 0 : _responseData$error5.code, (_responseData$error6 = responseData.error) === null || _responseData$error6 === void 0 ? void 0 : _responseData$error6.details);
|
|
166
|
+
}
|
|
167
|
+
return responseData;
|
|
168
|
+
} catch (error) {
|
|
169
|
+
// Handle specific error types
|
|
170
|
+
if (error instanceof ApiError) {
|
|
171
|
+
throw error;
|
|
172
|
+
}
|
|
173
|
+
if (error.name === 'AbortError') {
|
|
174
|
+
throw new ApiError('Request timed out', 'timeout_error');
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// Log error if debug mode is enabled
|
|
178
|
+
if (debug) {
|
|
179
|
+
logDebug('Developer API Error', {
|
|
180
|
+
endpoint,
|
|
181
|
+
method,
|
|
182
|
+
error: error.message || 'Unknown error'
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// Return a generic error for all other cases
|
|
187
|
+
throw new ApiError(error.message || 'An unexpected error occurred', 'unknown_error');
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Validate user credentials with the API (uses JWT)
|
|
193
|
+
*/
|
|
194
|
+
export const validateCredentials = async (username, options = {
|
|
195
|
+
debug: false
|
|
196
|
+
}) => {
|
|
197
|
+
try {
|
|
198
|
+
var _response$data, _response$error;
|
|
199
|
+
const response = await makeUserApiRequest('auth/validate', 'POST', {
|
|
200
|
+
data: {
|
|
201
|
+
username
|
|
202
|
+
},
|
|
203
|
+
debug: options.debug
|
|
204
|
+
});
|
|
205
|
+
return {
|
|
206
|
+
isValid: response.success && ((_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.isValid) === true,
|
|
207
|
+
message: (_response$error = response.error) === null || _response$error === void 0 ? void 0 : _response$error.message
|
|
208
|
+
};
|
|
209
|
+
} catch (error) {
|
|
210
|
+
return {
|
|
211
|
+
isValid: false,
|
|
212
|
+
message: error.message
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Create a new user account (uses developer API key)
|
|
219
|
+
*/
|
|
220
|
+
export const createAccount = async (credentials, options = {
|
|
221
|
+
debug: false
|
|
222
|
+
}) => {
|
|
223
|
+
return makeDeveloperApiRequest('auth/register', 'POST', {
|
|
224
|
+
data: {
|
|
225
|
+
username: credentials.username,
|
|
226
|
+
platforms: credentials.platforms
|
|
227
|
+
},
|
|
228
|
+
debug: options.debug
|
|
229
|
+
});
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Authenticate with the API using credentials (uses JWT)
|
|
234
|
+
*/
|
|
235
|
+
export const authenticate = async (credentials, options = {
|
|
236
|
+
debug: false
|
|
237
|
+
}) => {
|
|
238
|
+
return makeUserApiRequest('auth/login', 'POST', {
|
|
239
|
+
data: {
|
|
240
|
+
username: credentials.username,
|
|
241
|
+
pin: credentials.userPin
|
|
242
|
+
},
|
|
243
|
+
debug: options.debug
|
|
244
|
+
});
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Refresh authentication token (uses JWT)
|
|
249
|
+
*/
|
|
250
|
+
export const refreshToken = async (refreshToken, options = {
|
|
251
|
+
debug: false
|
|
252
|
+
}) => {
|
|
253
|
+
return makeUserApiRequest('auth/refresh', 'POST', {
|
|
254
|
+
data: {
|
|
255
|
+
refreshToken
|
|
256
|
+
},
|
|
257
|
+
debug: options.debug
|
|
258
|
+
});
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Get user's connected platform data (uses JWT)
|
|
263
|
+
*/
|
|
264
|
+
export const getPlatformData = async (platform, options = {
|
|
265
|
+
debug: false
|
|
266
|
+
}) => {
|
|
267
|
+
return makeUserApiRequest(`platforms/${platform}/data`, 'GET', {
|
|
268
|
+
debug: options.debug
|
|
269
|
+
});
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Get user profile information (uses JWT)
|
|
274
|
+
*/
|
|
275
|
+
export const getUserProfile = async (options = {
|
|
276
|
+
debug: false
|
|
277
|
+
}) => {
|
|
278
|
+
return makeUserApiRequest('user/profile', 'GET', {
|
|
279
|
+
debug: options.debug
|
|
280
|
+
});
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Update user platform connections (uses JWT)
|
|
285
|
+
*/
|
|
286
|
+
export const updatePlatformConnections = async (platforms, options = {
|
|
287
|
+
debug: false
|
|
288
|
+
}) => {
|
|
289
|
+
return makeUserApiRequest('user/platforms', 'PUT', {
|
|
290
|
+
data: {
|
|
291
|
+
platforms
|
|
292
|
+
},
|
|
293
|
+
debug: options.debug
|
|
294
|
+
});
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Store user PIN (uses JWT and extracts username from JWT)
|
|
299
|
+
*/
|
|
300
|
+
export const storePIN = async (pin, options = {}) => {
|
|
301
|
+
const {
|
|
302
|
+
debug = false,
|
|
303
|
+
username
|
|
304
|
+
} = options;
|
|
305
|
+
|
|
306
|
+
// Extract username from JWT if not provided
|
|
307
|
+
const userToStore = username || extractUsernameFromJWT();
|
|
308
|
+
if (!userToStore) {
|
|
309
|
+
throw new ApiError('No username available - either provide username or ensure JWT token is valid', 'auth_error');
|
|
310
|
+
}
|
|
311
|
+
return makeUserApiRequest('store-pin/mobile', 'POST', {
|
|
312
|
+
data: {
|
|
313
|
+
username: userToStore,
|
|
314
|
+
pin
|
|
315
|
+
},
|
|
316
|
+
debug
|
|
317
|
+
});
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Get current JWT token
|
|
322
|
+
*/
|
|
323
|
+
export const getCurrentUserToken = async () => {
|
|
324
|
+
return await getJWT();
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Check if user is authenticated with JWT
|
|
329
|
+
*/
|
|
330
|
+
export const isCurrentUserAuthenticated = () => {
|
|
331
|
+
return isUserAuthenticated();
|
|
332
|
+
};
|
|
333
|
+
//# sourceMappingURL=onairosApi.js.map
|