@onairos/react-native 3.7.2 → 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/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/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,8 +1,226 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Object[_0xad52(0x0)](exports,_0xad52(0x1),{'value':!![]}),exports['runFullDiagnostics']=exports[_0xad52(0x2)]=exports[_0xad52(0x3)]=void 0x0;var _reactNative=__ONAIROS_REQ_FUNC__(0x0),_api=__ONAIROS_REQ_FUNC__(0x1);const runFullDiagnostics=async()=>{const _0x3ba972={'QOOoI':_0xad52(0x4),'sTgnm':_0xad52(0x5),'uUKAk':_0xad52(0x6),'ylwht':'offline','MxVUn':function(_0xc84bcf,_0x388179){return _0xc84bcf+_0x388179;},'eOwhh':_0xad52(0x7),'XqEoM':_0xad52(0x8),'SZpxi':_0xad52(0x9),'AUWNZ':_0xad52(0xa),'GZFsh':function(_0x5bd05f,_0xfc967f){return _0x5bd05f===_0xfc967f;},'wCKwf':_0xad52(0xb),'wPMgf':_0xad52(0xc),'zstOj':function(_0x6f7980,_0x1cbd90){return _0x6f7980-_0x1cbd90;},'FihcP':'Check\x20internet\x20connection\x20on\x20device','zOMIp':'\x0a🧪\x20Test\x202:\x20API\x20Reachability\x20(API\x20server/health)','hUNoh':function(_0x5b05de,_0x41d4b8,_0x5d0273){return _0x5b05de(_0x41d4b8,_0x5d0273);},'VNAAk':function(_0x5668df,_0x30d794){return _0x5668df-_0x30d794;},'xlTUL':_0xad52(0xd),'SeWsS':'Internet\x20works\x20but\x20API\x20blocked.\x20Check:\x20VPN,\x20Firewall,\x20iOS\x20ATS\x20settings','fNLfr':function(_0x1c4972,_0x596269){return _0x1c4972!==_0x596269;},'tiMrL':_0xad52(0xe),'VhrOi':'youtube','jOChw':function(_0x5ba5d3,_0x1e774e){return _0x5ba5d3-_0x1e774e;},'StRkk':_0xad52(0xf),'hKrEW':_0xad52(0x10),'aqHYu':_0xad52(0x11),'wOWns':_0xad52(0x12),'jzCXN':function(_0x306f2a,_0x160671){return _0x306f2a===_0x160671;},'BbnAB':function(_0x1bf9df,_0x3bd0bf){return _0x1bf9df===_0x3bd0bf;},'FFRxR':_0xad52(0x13),'CERMe':_0xad52(0x14),'ACQRd':'\x0a⚠️\x20SOME\x20TESTS\x20FAILED\x20-\x20See\x20recommendations\x20below:','aLcWo':'ios','qkDaB':_0xad52(0x15),'LDpvi':_0xad52(0x16),'XRbap':_0xad52(0x17),'ndgSy':_0xad52(0x18),'UFFiS':_0xad52(0x19)};console[_0xad52(0x1a)](_0x3ba972['eOwhh']),console[_0xad52(0x1a)](_0x3ba972['XqEoM']),console[_0xad52(0x1a)](_0x3ba972[_0xad52(0x1b)]);const _0x46f434={'timestamp':new Date()['toISOString'](),'platform':_reactNative['Platform']['OS'],'platformVersion':_reactNative[_0xad52(0x1c)][_0xad52(0x1d)],'tests':{'googleReachable':![],'apiReachable':![],'apiPostWorks':![],'youtubeOAuthWorks':![]},'errors':[],'recommendations':[],'rawResults':{}};console['log'](_0xad52(0x1e)+_reactNative[_0xad52(0x1c)]['OS']+'\x20'+_reactNative[_0xad52(0x1c)][_0xad52(0x1d)]),console[_0xad52(0x1a)](_0x3ba972[_0xad52(0x1f)]),console['log'](_0x3ba972[_0xad52(0x20)]);try{if(_0x3ba972[_0xad52(0x21)](_0xad52(0xb),_0x3ba972[_0xad52(0x22)])){const _0x286e14=Date[_0xad52(0x23)](),_0x32dbf8=await fetch('https://www.google.com',{'method':_0x3ba972[_0xad52(0x24)]}),_0xa0a774=_0x3ba972[_0xad52(0x25)](Date[_0xad52(0x23)](),_0x286e14);_0x46f434[_0xad52(0x26)]['googleReachable']=!![],_0x46f434[_0xad52(0x27)][_0xad52(0x28)]={'status':_0x32dbf8[_0xad52(0x29)],'time':_0xa0a774},console[_0xad52(0x1a)](_0xad52(0x2a)+_0xa0a774+_0xad52(0x2b));}else _0x2d8e38[_0xad52(0x26)]['youtubeOAuthWorks']=!![],_0x121236[_0xad52(0x1a)]('\x20\x20\x20✅\x20BONUS\x20-\x20Got\x20YouTube\x20OAuth\x20URL!');}catch(_0x50a590){const _0x421df1='4|3|1|0|2'[_0xad52(0x2c)]('|');let _0x21e1d8=0x0;while(!![]){switch(_0x421df1[_0x21e1d8++]){case'0':console[_0xad52(0x1a)](_0xad52(0x2d)+_0x50a590[_0xad52(0x2e)]);continue;case'1':_0x46f434[_0xad52(0x27)]['google']={'error':_0x50a590['message']};continue;case'2':_0x46f434[_0xad52(0x2f)][_0xad52(0x30)](_0x3ba972[_0xad52(0x31)]);continue;case'3':_0x46f434['errors'][_0xad52(0x30)]('Google\x20unreachable:\x20'+_0x50a590['message']);continue;case'4':_0x46f434[_0xad52(0x26)][_0xad52(0x32)]=![];continue;}break;}}console[_0xad52(0x1a)](_0x3ba972['zOMIp']);try{const _0x4c5ef8=Date[_0xad52(0x23)](),_0x3a64e3=await _0x3ba972['hUNoh'](fetch,_api[_0xad52(0x33)][_0xad52(0x34)]+'/health',{'method':'GET','headers':{'Accept':'application/json'}}),_0x50aed3=_0x3ba972[_0xad52(0x35)](Date[_0xad52(0x23)](),_0x4c5ef8),_0x241baf=await _0x3a64e3[_0xad52(0x36)]()['catch'](()=>_0xad52(0x37));_0x46f434[_0xad52(0x26)][_0xad52(0x38)]=_0x3a64e3['ok'],_0x46f434[_0xad52(0x27)][_0xad52(0x39)]={'status':_0x3a64e3[_0xad52(0x29)],'time':_0x50aed3,'body':_0x241baf['substring'](0x0,0xc8)},_0x3a64e3['ok']?console[_0xad52(0x1a)]('\x20\x20\x20✅\x20PASS\x20-\x20API\x20reachable\x20('+_0x50aed3+'ms)'):(console[_0xad52(0x1a)]('\x20\x20\x20⚠️\x20PARTIAL\x20-\x20API\x20responded\x20with\x20'+_0x3a64e3['status']),_0x46f434[_0xad52(0x3a)]['push']('API\x20returned\x20status\x20'+_0x3a64e3[_0xad52(0x29)]));}catch(_0x416eec){const _0x4a6490=_0x3ba972[_0xad52(0x3b)][_0xad52(0x2c)]('|');let _0x584831=0x0;while(!![]){switch(_0x4a6490[_0x584831++]){case'0':_0x46f434[_0xad52(0x26)][_0xad52(0x32)]&&_0x46f434['recommendations']['push'](_0x3ba972[_0xad52(0x3c)]);continue;case'1':_0x46f434[_0xad52(0x27)][_0xad52(0x39)]={'error':_0x416eec['message']};continue;case'2':console[_0xad52(0x1a)](_0xad52(0x2d)+_0x416eec[_0xad52(0x2e)]);continue;case'3':_0x46f434['tests']['apiReachable']=![];continue;case'4':_0x46f434[_0xad52(0x3a)]['push'](_0xad52(0x3d)+_0x416eec['message']);continue;}break;}}console[_0xad52(0x1a)]('\n\uD83E\uDDEA Test 3: POST Request (OAuth simulation)');try{if(_0x3ba972[_0xad52(0x3e)]('geYIN',_0x3ba972[_0xad52(0x3f)])){const _0x485e93=Date[_0xad52(0x23)](),_0x22cb64=await _0x3ba972[_0xad52(0x40)](fetch,_api['API_CONFIG'][_0xad52(0x34)]+_0xad52(0x41),{'method':'POST','headers':{'Content-Type':'application/json','Accept':'application/json'},'body':JSON['stringify']({'session':{'username':_0xad52(0x42),'platform':_0x3ba972[_0xad52(0x43)],'timestamp':new Date()[_0xad52(0x44)]()}})}),_0x1a3931=_0x3ba972[_0xad52(0x45)](Date[_0xad52(0x23)](),_0x485e93),_0x2f3913=await _0x22cb64[_0xad52(0x36)]()[_0xad52(0x46)](()=>_0xad52(0x37));_0x46f434[_0xad52(0x27)][_0xad52(0x47)]={'status':_0x22cb64[_0xad52(0x29)],'time':_0x1a3931,'body':_0x2f3913[_0xad52(0x48)](0x0,0x1f4)},_0x46f434['tests'][_0xad52(0x49)]=!![],console[_0xad52(0x1a)](_0xad52(0x4a)+_0x22cb64[_0xad52(0x29)]+'\x20('+_0x1a3931+_0xad52(0x2b));try{const _0x4436b2=JSON[_0xad52(0x4b)](_0x2f3913);_0x4436b2['youtubeURL']&&(_0x3ba972[_0xad52(0x3e)](_0x3ba972[_0xad52(0x4c)],_0x3ba972[_0xad52(0x4c)])?_0x273ad3[_0xad52(0x2f)][_0xad52(0x30)](_0x3ba972[_0xad52(0x4d)],_0x3ba972[_0xad52(0x4e)]):(_0x46f434[_0xad52(0x26)][_0xad52(0x4f)]=!![],console[_0xad52(0x1a)](_0xad52(0x50))));}catch{}}else{const _0xb78fcf=_0x3ba972[_0xad52(0x51)][_0xad52(0x2c)]('|');let _0x1f2496=0x0;while(!![]){switch(_0xb78fcf[_0x1f2496++]){case'0':_0x174d93[_0xad52(0x3a)][_0xad52(0x30)](_0xad52(0x52)+_0x5e625e[_0xad52(0x2e)]);continue;case'1':_0x27c68b[_0xad52(0x1a)](_0xad52(0x2d)+_0x5641f1['message']);continue;case'2':_0x502ced[_0xad52(0x27)]['apiPost']={'error':_0xc438ac[_0xad52(0x2e)]};continue;case'3':_0x9e64ba[_0xad52(0x2f)]['push']('POST requests failing. This is the exact issue affecting OAuth.');continue;case'4':_0x4fd5c3[_0xad52(0x26)][_0xad52(0x49)]=![];continue;}break;}}}catch(_0x4e20cb){if(_0x3ba972['GZFsh'](_0x3ba972['hKrEW'],_0x3ba972[_0xad52(0x53)])){const _0x5bab7d=_0x3ba972[_0xad52(0x54)]['split']('|');let _0x24a27b=0x0;while(!![]){switch(_0x5bab7d[_0x24a27b++]){case'0':_0x46f434['tests'][_0xad52(0x49)]=![];continue;case'1':_0x46f434[_0xad52(0x27)]['apiPost']={'error':_0x4e20cb[_0xad52(0x2e)]};continue;case'2':_0x46f434['recommendations'][_0xad52(0x30)]('POST requests failing. This is the exact issue affecting OAuth.');continue;case'3':_0x46f434[_0xad52(0x3a)][_0xad52(0x30)](_0xad52(0x52)+_0x4e20cb['message']);continue;case'4':console['log'](_0xad52(0x2d)+_0x4e20cb[_0xad52(0x2e)]);continue;}break;}}else{const _0x4d5ed9=_0x1187e2[_0xad52(0x4b)](_0x5e7204);_0x4d5ed9[_0xad52(0x55)]&&(_0x4b3702[_0xad52(0x26)][_0xad52(0x4f)]=!![],_0x5ae676[_0xad52(0x1a)](_0xad52(0x50)));}}console[_0xad52(0x1a)](_0xad52(0x56)),console['log'](_0x3ba972[_0xad52(0x57)]),console[_0xad52(0x1a)](_0x3ba972['SZpxi']);const _0x1621b8=Object[_0xad52(0x58)](_0x46f434['tests'])[_0xad52(0x59)](Boolean)[_0xad52(0x5a)],_0x5cfc3a=Object['keys'](_0x46f434[_0xad52(0x26)])[_0xad52(0x5a)];console[_0xad52(0x1a)]('\x0aTests\x20Passed:\x20'+_0x1621b8+'/'+_0x5cfc3a);if(_0x3ba972[_0xad52(0x5b)](_0x1621b8,_0x5cfc3a)){if(_0x3ba972[_0xad52(0x5c)](_0x3ba972[_0xad52(0x5d)],'PzCGI'))console[_0xad52(0x1a)](_0x3ba972['CERMe']);else return _0xad52(0x5e);}else{console[_0xad52(0x1a)](_0x3ba972[_0xad52(0x5f)]);_reactNative[_0xad52(0x1c)]['OS']===_0x3ba972['aLcWo']&&!_0x46f434[_0xad52(0x26)][_0xad52(0x38)]&&_0x46f434[_0xad52(0x2f)][_0xad52(0x30)](_0x3ba972[_0xad52(0x4d)],_0x3ba972['sTgnm']);if(!_0x46f434['tests'][_0xad52(0x32)]){if(_0x3ba972[_0xad52(0x5c)](_0x3ba972[_0xad52(0x60)],_0x3ba972[_0xad52(0x60)]))_0x46f434['recommendations'][_0xad52(0x30)](_0x3ba972[_0xad52(0x61)]);else return _0x3ba972['ylwht'];}console[_0xad52(0x1a)](_0x3ba972[_0xad52(0x62)]),_0x46f434[_0xad52(0x2f)]['forEach']((_0x5c5871,_0x595211)=>{console[_0xad52(0x1a)]('\x20\x20\x20'+_0x3ba972[_0xad52(0x63)](_0x595211,0x1)+'.\x20'+_0x5c5871);});}return console[_0xad52(0x1a)](_0x3ba972[_0xad52(0x64)]),console[_0xad52(0x1a)](_0x3ba972[_0xad52(0x65)]),console[_0xad52(0x1a)](JSON['stringify'](_0x46f434,null,0x2)),_0x46f434;};exports[_0xad52(0x66)]=runFullDiagnostics;function _0xad52(_0x345d4e,_0xad5280){_0x345d4e=_0x345d4e-0x0;const _0x106376=_0x345d();let _0x2375aa=_0x106376[_0x345d4e];return _0x2375aa;}const isApiReachable=async()=>{const _0x116221={'UgrUM':function(_0x5a7dcc,_0x437ad0,_0x2ad2db){return _0x5a7dcc(_0x437ad0,_0x2ad2db);}};try{const _0x413657=await _0x116221[_0xad52(0x67)](fetch,_api[_0xad52(0x33)][_0xad52(0x34)]+_0xad52(0x68),{'method':'GET'});return _0x413657['ok'];}catch{return![];}};exports[_0xad52(0x2)]=isApiReachable;const getNetworkStatus=async()=>{const _0x5ba058={'VhrWK':_0xad52(0x69),'wfvUY':'ios','CsMha':'iOS:\x20Add\x20NSAppTransportSecurity\x20to\x20Info.plist','wbrUD':_0xad52(0x5),'OIlQn':_0xad52(0x17),'hAOBv':function(_0x1fab4d,_0x2c505f,_0x368b6f){return _0x1fab4d(_0x2c505f,_0x368b6f);},'URjQw':'https://www.google.com','dXtWj':function(_0x290351,_0x45c091){return _0x290351(_0x45c091);},'dAvjZ':function(_0x2b9dff,_0x3538a7){return _0x2b9dff!==_0x3538a7;},'jvUDA':_0xad52(0x6a),'qXhGv':_0xad52(0x5e),'OwLtD':'offline'};try{await _0x5ba058['hAOBv'](fetch,_0x5ba058[_0xad52(0x6b)],{'method':_0xad52(0xc)});const _0x6cfdbd=await _0x5ba058[_0xad52(0x6c)](fetch,_api[_0xad52(0x33)][_0xad52(0x34)]+'/health');if(_0x6cfdbd['ok']){if(_0x5ba058[_0xad52(0x6d)](_0x5ba058[_0xad52(0x6e)],_0x5ba058['jvUDA'])){const _0x385104=_0xad52(0x6f)[_0xad52(0x2c)]('|');let _0x41f278=0x0;while(!![]){switch(_0x385104[_0x41f278++]){case'0':_0x481b04['recommendations'][_0xad52(0x70)]((_0x4050c5,_0x4ca6ad)=>{_0x1b5fa1[_0xad52(0x1a)](_0xad52(0x71)+(_0x4ca6ad+0x1)+'.\x20'+_0x4050c5);});continue;case'1':_0x4552cc[_0xad52(0x1a)](_0x5ba058[_0xad52(0x72)]);continue;case'2':!_0x181b4d[_0xad52(0x26)]['googleReachable']&&_0x5e9d46[_0xad52(0x2f)][_0xad52(0x30)](_0xad52(0x16));continue;case'3':_0x3cea48[_0xad52(0x1c)]['OS']===_0x5ba058[_0xad52(0x73)]&&!_0x2e6df6[_0xad52(0x26)][_0xad52(0x38)]&&_0xb98fbb[_0xad52(0x2f)][_0xad52(0x30)](_0x5ba058[_0xad52(0x74)],_0x5ba058[_0xad52(0x75)]);continue;case'4':_0x14d694[_0xad52(0x1a)](_0x5ba058['OIlQn']);continue;}break;}}else return _0xad52(0x76);}else return _0x5ba058[_0xad52(0x77)];}catch{return _0x5ba058[_0xad52(0x78)];}};exports[_0xad52(0x3)]=getNetworkStatus;function _0x345d(){const _0x53123b=['defineProperty','__esModule','isApiReachable','getNetworkStatus','iOS:\x20Add\x20NSAppTransportSecurity\x20to\x20Info.plist','iOS:\x20Try\x20on\x20physical\x20device\x20instead\x20of\x20simulator','4|0|2|1|3','═══════════════════════════════════════════','🔍\x20ONAIROS\x20SDK\x20NETWORK\x20DIAGNOSTICS','───────────────────────────────────────────','\x0a🧪\x20Test\x201:\x20Internet\x20Connectivity\x20(google.com)','IRRBo','HEAD','3|4|1|2|0','mEciM','nJrEx','aQCGU','0|3|1|4|2','📋\x20SUMMARY','PzCGI','\x0a✅\x20ALL\x20TESTS\x20PASSED\x20-\x20SDK\x20should\x20work\x20correctly','qxIzl','Device\x20has\x20no\x20internet\x20-\x20check\x20WiFi/cellular','\x0a📌\x20RECOMMENDATIONS:','\x0a═══════════════════════════════════════════','Full\x20results\x20object\x20logged\x20below\x20for\x20debugging:','log','eOwhh','Platform','Version','📱\x20Platform:\x20','SZpxi','AUWNZ','GZFsh','wCKwf','now','wPMgf','zstOj','tests','rawResults','google','status','\x20\x20\x20✅\x20PASS\x20-\x20Google\x20reachable\x20(','ms)','split','\x20\x20\x20❌\x20FAIL\x20-\x20','message','recommendations','push','FihcP','googleReachable','API_CONFIG','BASE_URL','VNAAk','text','Unable\x20to\x20read','apiReachable','apiHealth','errors','xlTUL','SeWsS','API\x20unreachable:\x20','fNLfr','tiMrL','hUNoh','/youtube/authorize','diagnostic_test','VhrOi','toISOString','jOChw','catch','apiPost','substring','apiPostWorks','\x20\x20\x20✅\x20PASS\x20-\x20POST\x20request\x20succeeded,\x20status:\x20','parse','StRkk','QOOoI','sTgnm','youtubeOAuthWorks','\x20\x20\x20✅\x20BONUS\x20-\x20Got\x20YouTube\x20OAuth\x20URL!','uUKAk','POST\x20request\x20failed:\x20','hKrEW','aqHYu','youtubeURL','\x0a───────────────────────────────────────────','wOWns','values','filter','length','jzCXN','BbnAB','FFRxR','api_unreachable','ACQRd','qkDaB','LDpvi','XRbap','MxVUn','ndgSy','UFFiS','runFullDiagnostics','UgrUM','/health','\x0a⚠️\x20SOME\x20TESTS\x20FAILED\x20-\x20See\x20recommendations\x20below:','vrFnY','URjQw','dXtWj','dAvjZ','jvUDA','1|3|2|4|0','forEach','\x20\x20\x20','VhrWK','wfvUY','CsMha','wbrUD','online','qXhGv','OwLtD'];_0x345d=function(){return _0x53123b;};return _0x345d();}
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.runFullDiagnostics = exports.isApiReachable = exports.getNetworkStatus = void 0;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
var _api = require("../config/api");
|
|
9
|
+
/**
|
|
10
|
+
* Network Diagnostics Utility for Onairos SDK
|
|
11
|
+
*
|
|
12
|
+
* Use this to diagnose network issues with OAuth flows.
|
|
13
|
+
*
|
|
14
|
+
* Usage:
|
|
15
|
+
* ```typescript
|
|
16
|
+
* import { runFullDiagnostics } from '@onairos/react-native';
|
|
17
|
+
*
|
|
18
|
+
* const results = await runFullDiagnostics();
|
|
19
|
+
* console.log(results);
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Run comprehensive network diagnostics
|
|
25
|
+
* Call this to test if the SDK can connect to required services
|
|
26
|
+
*/
|
|
27
|
+
const runFullDiagnostics = async () => {
|
|
28
|
+
console.log('═══════════════════════════════════════════');
|
|
29
|
+
console.log('🔍 ONAIROS SDK NETWORK DIAGNOSTICS');
|
|
30
|
+
console.log('═══════════════════════════════════════════');
|
|
31
|
+
const result = {
|
|
32
|
+
timestamp: new Date().toISOString(),
|
|
33
|
+
platform: _reactNative.Platform.OS,
|
|
34
|
+
platformVersion: _reactNative.Platform.Version,
|
|
35
|
+
tests: {
|
|
36
|
+
googleReachable: false,
|
|
37
|
+
apiReachable: false,
|
|
38
|
+
apiPostWorks: false,
|
|
39
|
+
youtubeOAuthWorks: false
|
|
40
|
+
},
|
|
41
|
+
errors: [],
|
|
42
|
+
recommendations: [],
|
|
43
|
+
rawResults: {}
|
|
44
|
+
};
|
|
45
|
+
console.log(`📱 Platform: ${_reactNative.Platform.OS} ${_reactNative.Platform.Version}`);
|
|
46
|
+
console.log('───────────────────────────────────────────');
|
|
47
|
+
|
|
48
|
+
// Test 1: Can we reach the internet at all? (Google)
|
|
49
|
+
console.log('\n🧪 Test 1: Internet Connectivity (google.com)');
|
|
50
|
+
try {
|
|
51
|
+
const googleStart = Date.now();
|
|
52
|
+
const googleRes = await fetch('https://www.google.com', {
|
|
53
|
+
method: 'HEAD'
|
|
54
|
+
});
|
|
55
|
+
const googleTime = Date.now() - googleStart;
|
|
56
|
+
result.tests.googleReachable = true;
|
|
57
|
+
result.rawResults.google = {
|
|
58
|
+
status: googleRes.status,
|
|
59
|
+
time: googleTime
|
|
60
|
+
};
|
|
61
|
+
console.log(` ✅ PASS - Google reachable (${googleTime}ms)`);
|
|
62
|
+
} catch (error) {
|
|
63
|
+
result.tests.googleReachable = false;
|
|
64
|
+
result.errors.push(`Google unreachable: ${error.message}`);
|
|
65
|
+
result.rawResults.google = {
|
|
66
|
+
error: error.message
|
|
67
|
+
};
|
|
68
|
+
console.log(` ❌ FAIL - ${error.message}`);
|
|
69
|
+
result.recommendations.push('Check internet connection on device');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Test 2: Can we reach API server?
|
|
73
|
+
console.log('\n🧪 Test 2: API Reachability (API server/health)');
|
|
74
|
+
try {
|
|
75
|
+
const apiStart = Date.now();
|
|
76
|
+
const apiRes = await fetch(`${_api.API_CONFIG.BASE_URL}/health`, {
|
|
77
|
+
method: 'GET',
|
|
78
|
+
headers: {
|
|
79
|
+
'Accept': 'application/json'
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
const apiTime = Date.now() - apiStart;
|
|
83
|
+
const apiBody = await apiRes.text().catch(() => 'Unable to read');
|
|
84
|
+
result.tests.apiReachable = apiRes.ok;
|
|
85
|
+
result.rawResults.apiHealth = {
|
|
86
|
+
status: apiRes.status,
|
|
87
|
+
time: apiTime,
|
|
88
|
+
body: apiBody.substring(0, 200)
|
|
89
|
+
};
|
|
90
|
+
if (apiRes.ok) {
|
|
91
|
+
console.log(` ✅ PASS - API reachable (${apiTime}ms)`);
|
|
92
|
+
} else {
|
|
93
|
+
console.log(` ⚠️ PARTIAL - API responded with ${apiRes.status}`);
|
|
94
|
+
result.errors.push(`API returned status ${apiRes.status}`);
|
|
95
|
+
}
|
|
96
|
+
} catch (error) {
|
|
97
|
+
result.tests.apiReachable = false;
|
|
98
|
+
result.errors.push(`API unreachable: ${error.message}`);
|
|
99
|
+
result.rawResults.apiHealth = {
|
|
100
|
+
error: error.message
|
|
101
|
+
};
|
|
102
|
+
console.log(` ❌ FAIL - ${error.message}`);
|
|
103
|
+
if (result.tests.googleReachable) {
|
|
104
|
+
result.recommendations.push('Internet works but API blocked. Check: VPN, Firewall, iOS ATS settings');
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Test 3: Can we make POST requests?
|
|
109
|
+
console.log('\n🧪 Test 3: POST Request (OAuth simulation)');
|
|
110
|
+
try {
|
|
111
|
+
const postStart = Date.now();
|
|
112
|
+
const postRes = await fetch(`${_api.API_CONFIG.BASE_URL}/youtube/authorize`, {
|
|
113
|
+
method: 'POST',
|
|
114
|
+
headers: {
|
|
115
|
+
'Content-Type': 'application/json',
|
|
116
|
+
'Accept': 'application/json'
|
|
117
|
+
},
|
|
118
|
+
body: JSON.stringify({
|
|
119
|
+
session: {
|
|
120
|
+
username: 'diagnostic_test',
|
|
121
|
+
platform: 'youtube',
|
|
122
|
+
timestamp: new Date().toISOString()
|
|
123
|
+
}
|
|
124
|
+
})
|
|
125
|
+
});
|
|
126
|
+
const postTime = Date.now() - postStart;
|
|
127
|
+
const postBody = await postRes.text().catch(() => 'Unable to read');
|
|
128
|
+
result.rawResults.apiPost = {
|
|
129
|
+
status: postRes.status,
|
|
130
|
+
time: postTime,
|
|
131
|
+
body: postBody.substring(0, 500)
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
// Any response is good - we're testing if the request gets through
|
|
135
|
+
result.tests.apiPostWorks = true;
|
|
136
|
+
console.log(` ✅ PASS - POST request succeeded, status: ${postRes.status} (${postTime}ms)`);
|
|
137
|
+
|
|
138
|
+
// Check if we got an OAuth URL back
|
|
139
|
+
try {
|
|
140
|
+
const data = JSON.parse(postBody);
|
|
141
|
+
if (data.youtubeURL) {
|
|
142
|
+
result.tests.youtubeOAuthWorks = true;
|
|
143
|
+
console.log(` ✅ BONUS - Got YouTube OAuth URL!`);
|
|
144
|
+
}
|
|
145
|
+
} catch {
|
|
146
|
+
// Not JSON or no URL - that's fine for this test
|
|
147
|
+
}
|
|
148
|
+
} catch (error) {
|
|
149
|
+
result.tests.apiPostWorks = false;
|
|
150
|
+
result.errors.push(`POST request failed: ${error.message}`);
|
|
151
|
+
result.rawResults.apiPost = {
|
|
152
|
+
error: error.message
|
|
153
|
+
};
|
|
154
|
+
console.log(` ❌ FAIL - ${error.message}`);
|
|
155
|
+
result.recommendations.push('POST requests failing. This is the exact issue affecting OAuth.');
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Generate recommendations
|
|
159
|
+
console.log('\n───────────────────────────────────────────');
|
|
160
|
+
console.log('📋 SUMMARY');
|
|
161
|
+
console.log('───────────────────────────────────────────');
|
|
162
|
+
const passCount = Object.values(result.tests).filter(Boolean).length;
|
|
163
|
+
const totalTests = Object.keys(result.tests).length;
|
|
164
|
+
console.log(`\nTests Passed: ${passCount}/${totalTests}`);
|
|
165
|
+
if (passCount === totalTests) {
|
|
166
|
+
console.log('\n✅ ALL TESTS PASSED - SDK should work correctly');
|
|
167
|
+
} else {
|
|
168
|
+
console.log('\n⚠️ SOME TESTS FAILED - See recommendations below:');
|
|
169
|
+
|
|
170
|
+
// Add platform-specific recommendations
|
|
171
|
+
if (_reactNative.Platform.OS === 'ios' && !result.tests.apiReachable) {
|
|
172
|
+
result.recommendations.push('iOS: Add NSAppTransportSecurity to Info.plist', 'iOS: Try on physical device instead of simulator');
|
|
173
|
+
}
|
|
174
|
+
if (!result.tests.googleReachable) {
|
|
175
|
+
result.recommendations.push('Device has no internet - check WiFi/cellular');
|
|
176
|
+
}
|
|
177
|
+
console.log('\n📌 RECOMMENDATIONS:');
|
|
178
|
+
result.recommendations.forEach((rec, i) => {
|
|
179
|
+
console.log(` ${i + 1}. ${rec}`);
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
console.log('\n═══════════════════════════════════════════');
|
|
183
|
+
console.log('Full results object logged below for debugging:');
|
|
184
|
+
console.log(JSON.stringify(result, null, 2));
|
|
185
|
+
return result;
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Quick connectivity check - returns true if API is reachable
|
|
190
|
+
*/
|
|
191
|
+
exports.runFullDiagnostics = runFullDiagnostics;
|
|
192
|
+
const isApiReachable = async () => {
|
|
193
|
+
try {
|
|
194
|
+
const response = await fetch(`${_api.API_CONFIG.BASE_URL}/health`, {
|
|
195
|
+
method: 'GET'
|
|
196
|
+
});
|
|
197
|
+
return response.ok;
|
|
198
|
+
} catch {
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Get a simple status string for display to users
|
|
205
|
+
*/
|
|
206
|
+
exports.isApiReachable = isApiReachable;
|
|
207
|
+
const getNetworkStatus = async () => {
|
|
208
|
+
try {
|
|
209
|
+
// Check Google first
|
|
210
|
+
await fetch('https://www.google.com', {
|
|
211
|
+
method: 'HEAD'
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
// Check our API
|
|
215
|
+
const apiRes = await fetch(`${_api.API_CONFIG.BASE_URL}/health`);
|
|
216
|
+
if (apiRes.ok) {
|
|
217
|
+
return 'online';
|
|
218
|
+
} else {
|
|
219
|
+
return 'api_unreachable';
|
|
220
|
+
}
|
|
221
|
+
} catch {
|
|
222
|
+
return 'offline';
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
exports.getNetworkStatus = getNetworkStatus;
|
|
226
|
+
//# sourceMappingURL=networkDiagnostics.js.map
|
|
@@ -1,9 +1,350 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Object[_0x3805(0x0)](exports,_0x3805(0x1),{'value':!![]}),exports['validateCredentials']=exports[_0x3805(0x2)]=exports[_0x3805(0x3)]=exports[_0x3805(0x4)]=exports[_0x3805(0x5)]=exports['getUserProfile']=exports[_0x3805(0x6)]=exports[_0x3805(0x7)]=exports[_0x3805(0x8)]=exports[_0x3805(0x9)]=exports[_0x3805(0xa)]=void 0x0;var _netinfo=_interopRequireDefault(__ONAIROS_REQ_FUNC__(0x0)),_debugHelper=__ONAIROS_REQ_FUNC__(0x1),_apiKeyService=__ONAIROS_REQ_FUNC__(0x2);function _interopRequireDefault(_0x5125e0){return _0x5125e0&&_0x5125e0[_0x3805(0x1)]?_0x5125e0:{'default':_0x5125e0};}class ApiError extends Error{constructor(_0x316745,_0x11c268,_0xd89f6b,_0x5ae20d){const _0x21ecf3={'VmdQr':_0x3805(0xb),'APOWR':_0x3805(0xa)},_0x47ef78=_0x21ecf3['VmdQr']['split']('|');let _0x162d97=0x0;while(!![]){switch(_0x47ef78[_0x162d97++]){case'0':this[_0x3805(0xc)]=_0x11c268;continue;case'1':super(_0x316745);continue;case'2':this[_0x3805(0xd)]=_0x5ae20d;continue;case'3':this['name']=_0x21ecf3[_0x3805(0xe)];continue;case'4':this[_0x3805(0xf)]=_0xd89f6b;continue;}break;}}}exports[_0x3805(0xa)]=ApiError;const checkNetworkConnection=async()=>{const _0x4f3cbb={'oRBxE':function(_0x5205d6,_0x3c7ca1){return _0x5205d6===_0x3c7ca1;}},_0x3ff637=await _netinfo[_0x3805(0x10)][_0x3805(0x11)]();return _0x4f3cbb[_0x3805(0x12)](_0x3ff637[_0x3805(0x13)],!![]);},makeUserApiRequest=async(_0x4dcea3,_0x182bd0,_0x2d1188={})=>{const _0x280df5={'AINNf':function(_0x1f138d,_0x524c80){return _0x1f138d instanceof _0x524c80;},'JfEkO':function(_0x3a8ece,_0x37a667){return _0x3a8ece===_0x37a667;},'qhGPh':'AbortError','TfFZj':'Request\x20timed\x20out','XLaOU':_0x3805(0x14),'TFvje':'Developer\x20API\x20Error','rTcMH':'Unknown\x20error','pQoWC':_0x3805(0x15),'LvZSC':'unknown_error','IkhHq':function(_0x15f046){return _0x15f046();},'mFTaH':_0x3805(0x16),'UgHhs':_0x3805(0x17),'GTtLc':_0x3805(0x18),'ESGOS':_0x3805(0x19),'vbsJn':function(_0x29387c,_0x5c3477){return _0x29387c===_0x5c3477;},'ftouz':_0x3805(0x1a),'smwwZ':function(_0x2eaa1e,_0x11aba4){return _0x2eaa1e>=_0x11aba4;},'KvccW':_0x3805(0x1b),'rliwy':_0x3805(0x1c),'ZTetg':_0x3805(0x1d),'qvZBw':function(_0x23a9d0,_0x496a8a){return _0x23a9d0===_0x496a8a;},'ksaql':_0x3805(0x1e)},{data:_0x2a153c,headers:headers={},debug:debug=![]}=_0x2d1188;try{const _0x31f8b4=await _0x280df5['IkhHq'](checkNetworkConnection);if(!_0x31f8b4){if(_0x3805(0x1f)!=='dZlFm'){if(_0x280df5[_0x3805(0x20)](_0x369904,_0x3ff0da))throw _0x5cd4b7;if(_0x280df5['JfEkO'](_0x4f5f80['name'],_0x280df5['qhGPh']))throw new _0x36a005(_0x280df5[_0x3805(0x21)],_0x280df5[_0x3805(0x22)]);_0xc2c79&&(0x0,_0x57e110[_0x3805(0x23)])(_0x280df5[_0x3805(0x24)],{'endpoint':_0x10ff6d,'method':_0x103a3c,'error':_0x4e1cd2[_0x3805(0x25)]||_0x280df5['rTcMH']});throw new _0x225d72(_0x524340[_0x3805(0x25)]||_0x280df5[_0x3805(0x26)],_0x280df5[_0x3805(0x27)]);}else throw new ApiError(_0x280df5[_0x3805(0x28)],_0x280df5[_0x3805(0x29)]);}if(!(0x0,_apiKeyService[_0x3805(0x2a)])())throw new ApiError(_0x3805(0x2b),'auth_error');debug&&(0x0,_debugHelper['logDebug'])(_0x280df5[_0x3805(0x2c)],{'endpoint':_0x4dcea3,'method':_0x182bd0,'headers':{...headers,'Authorization':_0x280df5['ESGOS']},'data':_0x2a153c||null});const _0x265397=await(0x0,_apiKeyService[_0x3805(0x2d)])(_0x4dcea3,{'method':_0x182bd0,'headers':headers,..._0x2a153c?{'body':JSON[_0x3805(0x2e)](_0x2a153c)}:{}}),_0x3c950=await _0x265397[_0x3805(0x2f)]();debug&&(0x0,_debugHelper[_0x3805(0x23)])(_0x3805(0x30),{'status':_0x265397[_0x3805(0x31)],'data':_0x3c950});if(!_0x265397['ok']){var _0x3fd6c4,_0x218eab,_0x145cd8;const _0x20715a=_0x265397[_0x3805(0x31)]===0x191||_0x280df5['vbsJn'](_0x265397[_0x3805(0x31)],0x193)?_0x280df5[_0x3805(0x32)]:_0x280df5[_0x3805(0x33)](_0x265397['status'],0x190)?_0x3805(0x34):_0x280df5[_0x3805(0x35)](_0x265397['status'],0x1f4)?_0x3805(0x36):_0x280df5[_0x3805(0x27)];throw new ApiError(((_0x3fd6c4=_0x3c950[_0x3805(0x37)])===null||_0x3fd6c4===void 0x0?void 0x0:_0x3fd6c4['message'])||_0x280df5[_0x3805(0x38)],_0x20715a,_0x280df5[_0x3805(0x39)](_0x218eab=_0x3c950[_0x3805(0x37)],null)||_0x280df5[_0x3805(0x33)](_0x218eab,void 0x0)?void 0x0:_0x218eab[_0x3805(0xf)],(_0x145cd8=_0x3c950[_0x3805(0x37)])===null||_0x280df5[_0x3805(0x33)](_0x145cd8,void 0x0)?void 0x0:_0x145cd8[_0x3805(0xd)]);}return _0x3c950;}catch(_0x7e280){if(_0x280df5['AINNf'](_0x7e280,ApiError)){if(_0x280df5[_0x3805(0x3a)]===_0x280df5['ZTetg'])(0x0,_0x962186[_0x3805(0x23)])(_0x3805(0x30),{'status':_0xbd0423['status'],'data':_0x9907ae});else throw _0x7e280;}if(_0x280df5[_0x3805(0x3b)](_0x7e280[_0x3805(0x3c)],_0x280df5[_0x3805(0x3d)]))throw new ApiError(_0x3805(0x3e),_0x280df5[_0x3805(0x22)]);debug&&(0x0,_debugHelper[_0x3805(0x23)])(_0x280df5['ksaql'],{'endpoint':_0x4dcea3,'method':_0x182bd0,'error':_0x7e280[_0x3805(0x25)]||_0x3805(0x3f)});throw new ApiError(_0x7e280[_0x3805(0x25)]||_0x280df5[_0x3805(0x26)],_0x280df5[_0x3805(0x27)]);}},makeDeveloperApiRequest=async(_0x5fd635,_0xeb93da,_0x5112bb={})=>{const _0x9d2a7b={'zzwlI':_0x3805(0x17),'JpGwa':function(_0x39b76e){return _0x39b76e();},'bwMqC':'No\x20network\x20connection\x20available','itLjk':_0x3805(0x40),'UDUBZ':function(_0xdc172d,_0x450942){return _0xdc172d||_0x450942;},'RxJAb':'UcRpB','KGxyN':function(_0x5ac827,_0x54ebbe){return _0x5ac827===_0x54ebbe;},'dhktj':_0x3805(0x34),'mGskL':function(_0x5b18e8,_0x33f219){return _0x5b18e8>=_0x33f219;},'PFoag':_0x3805(0x36),'hoTMl':_0x3805(0x41),'pTcaZ':'API\x20request\x20failed','XTjBD':_0x3805(0x42),'KCTvh':_0x3805(0x43),'jLMcx':function(_0x247f7b,_0x50b40f){return _0x247f7b instanceof _0x50b40f;},'zPMCi':function(_0xb9b652,_0x4b4e22){return _0xb9b652===_0x4b4e22;},'sOQCL':_0x3805(0x44),'QbYdF':'Request\x20timed\x20out','VEWrl':_0x3805(0x45),'MWoAQ':_0x3805(0x3f)},{data:_0xf74359,headers:headers={},debug:debug=![]}=_0x5112bb;try{const _0x54f816=await _0x9d2a7b[_0x3805(0x46)](checkNetworkConnection);if(!_0x54f816)throw new ApiError(_0x9d2a7b[_0x3805(0x47)],_0x9d2a7b['zzwlI']);debug&&(0x0,_debugHelper['logDebug'])(_0x9d2a7b[_0x3805(0x48)],{'endpoint':_0x5fd635,'method':_0xeb93da,'headers':{...headers,'Authorization':_0x3805(0x19)},'data':_0x9d2a7b[_0x3805(0x49)](_0xf74359,null)});const _0x558422=await(0x0,_apiKeyService['makeDeveloperRequest'])(_0x5fd635,{'method':_0xeb93da,'headers':headers,..._0xf74359?{'body':JSON[_0x3805(0x2e)](_0xf74359)}:{}}),_0x3cde42=await _0x558422[_0x3805(0x2f)]();if(debug){if('nTTRa'!==_0x9d2a7b['RxJAb'])(0x0,_debugHelper[_0x3805(0x23)])(_0x3805(0x4a),{'status':_0x558422[_0x3805(0x31)],'data':_0x3cde42});else throw new _0x37852e('No\x20network\x20connection\x20available',_0x9d2a7b[_0x3805(0x4b)]);}if(!_0x558422['ok']){var _0x52496a,_0x4f6cdd,_0x4c578e;const _0x4b7925=_0x558422['status']===0x191||_0x558422['status']===0x193?_0x3805(0x1a):_0x9d2a7b['KGxyN'](_0x558422['status'],0x190)?_0x9d2a7b[_0x3805(0x4c)]:_0x9d2a7b['mGskL'](_0x558422[_0x3805(0x31)],0x1f4)?_0x9d2a7b[_0x3805(0x4d)]:_0x9d2a7b[_0x3805(0x4e)];throw new ApiError(((_0x52496a=_0x3cde42['error'])===null||_0x9d2a7b['KGxyN'](_0x52496a,void 0x0)?void 0x0:_0x52496a['message'])||_0x9d2a7b[_0x3805(0x4f)],_0x4b7925,_0x9d2a7b[_0x3805(0x50)](_0x4f6cdd=_0x3cde42[_0x3805(0x37)],null)||_0x9d2a7b[_0x3805(0x50)](_0x4f6cdd,void 0x0)?void 0x0:_0x4f6cdd[_0x3805(0xf)],(_0x4c578e=_0x3cde42[_0x3805(0x37)])===null||_0x4c578e===void 0x0?void 0x0:_0x4c578e['details']);}return _0x3cde42;}catch(_0x3f85bf){if(_0x9d2a7b['XTjBD']===_0x9d2a7b['KCTvh'])throw _0x2b607d;else{if(_0x9d2a7b[_0x3805(0x51)](_0x3f85bf,ApiError))throw _0x3f85bf;if(_0x9d2a7b['zPMCi'](_0x3f85bf[_0x3805(0x3c)],_0x9d2a7b[_0x3805(0x52)]))throw new ApiError(_0x9d2a7b[_0x3805(0x53)],_0x3805(0x14));debug&&(0x0,_debugHelper[_0x3805(0x23)])(_0x9d2a7b[_0x3805(0x54)],{'endpoint':_0x5fd635,'method':_0xeb93da,'error':_0x3f85bf['message']||_0x9d2a7b[_0x3805(0x55)]});throw new ApiError(_0x3f85bf[_0x3805(0x25)]||'An\x20unexpected\x20error\x20occurred',_0x9d2a7b[_0x3805(0x4e)]);}}},validateCredentials=async(_0x4314d5,_0x262b06={'debug':![]})=>{const _0x14819b={'oIUqw':function(_0x48a9c7,_0x45cc12,_0x184483,_0x48410c){return _0x48a9c7(_0x45cc12,_0x184483,_0x48410c);},'oAnjz':function(_0x2d1c26,_0x392f56){return _0x2d1c26===_0x392f56;},'rkVNz':function(_0x537986,_0x10a1f8){return _0x537986===_0x10a1f8;},'RBExy':function(_0x5c6051,_0x197558){return _0x5c6051===_0x197558;},'WLPrJ':function(_0x10304e,_0x1a1208){return _0x10304e===_0x1a1208;}};try{var _0x297370,_0x3323c0;const _0x45b189=await _0x14819b[_0x3805(0x56)](makeUserApiRequest,_0x3805(0x57),'POST',{'data':{'username':_0x4314d5},'debug':_0x262b06[_0x3805(0x58)]});return{'isValid':_0x45b189[_0x3805(0x59)]&&_0x14819b[_0x3805(0x5a)]((_0x297370=_0x45b189['data'])===null||_0x14819b['rkVNz'](_0x297370,void 0x0)?void 0x0:_0x297370['isValid'],!![]),'message':_0x14819b['RBExy'](_0x3323c0=_0x45b189['error'],null)||_0x14819b['WLPrJ'](_0x3323c0,void 0x0)?void 0x0:_0x3323c0[_0x3805(0x25)]};}catch(_0xfcb0d){return{'isValid':![],'message':_0xfcb0d[_0x3805(0x25)]};}};exports[_0x3805(0x5b)]=validateCredentials;const createAccount=async(_0x33dfb5,_0xeeefe0={'debug':![]})=>{const _0x463f38={'ILGjp':function(_0x10e1b3,_0x3470d0,_0x225c8c,_0xcb0778){return _0x10e1b3(_0x3470d0,_0x225c8c,_0xcb0778);},'KVKWL':_0x3805(0x5c)};return _0x463f38['ILGjp'](makeDeveloperApiRequest,_0x463f38[_0x3805(0x5d)],'POST',{'data':{'username':_0x33dfb5[_0x3805(0x5e)],'platforms':_0x33dfb5[_0x3805(0x5f)]},'debug':_0xeeefe0[_0x3805(0x58)]});};exports[_0x3805(0x8)]=createAccount;const authenticate=async(_0x3ba78e,_0x3d93e3={'debug':![]})=>{const _0xa53f35={'iutVQ':function(_0x586ebd,_0x4bce46,_0x37156b,_0x5f5103){return _0x586ebd(_0x4bce46,_0x37156b,_0x5f5103);}};return _0xa53f35['iutVQ'](makeUserApiRequest,_0x3805(0x60),'POST',{'data':{'username':_0x3ba78e[_0x3805(0x5e)],'pin':_0x3ba78e[_0x3805(0x61)]},'debug':_0x3d93e3['debug']});};exports['authenticate']=authenticate;const refreshToken=async(_0x21db1e,_0x4d2c21={'debug':![]})=>{const _0x3260b8={'LeMWP':function(_0x50d9a7,_0x2d09b1,_0x5202ab,_0x34d3ad){return _0x50d9a7(_0x2d09b1,_0x5202ab,_0x34d3ad);},'iwHDx':_0x3805(0x62)};return _0x3260b8[_0x3805(0x63)](makeUserApiRequest,_0x3260b8[_0x3805(0x64)],'POST',{'data':{'refreshToken':_0x21db1e},'debug':_0x4d2c21[_0x3805(0x58)]});};exports[_0x3805(0x4)]=refreshToken;const getPlatformData=async(_0x5f46e6,_0x509d8e={'debug':![]})=>{return makeUserApiRequest('platforms/'+_0x5f46e6+_0x3805(0x65),'GET',{'debug':_0x509d8e['debug']});};exports[_0x3805(0x6)]=getPlatformData;const getUserProfile=async(_0x2a721b={'debug':![]})=>{const _0x1670cd={'JRsno':function(_0x244b9e,_0x517f09,_0x1d7a4f,_0x428860){return _0x244b9e(_0x517f09,_0x1d7a4f,_0x428860);},'jqeFb':_0x3805(0x66)};return _0x1670cd['JRsno'](makeUserApiRequest,_0x1670cd[_0x3805(0x67)],'GET',{'debug':_0x2a721b[_0x3805(0x58)]});};exports[_0x3805(0x68)]=getUserProfile;const updatePlatformConnections=async(_0xcc06e5,_0x25c89e={'debug':![]})=>{const _0xb63db3={'bffvf':function(_0x178536,_0x11300b,_0xce9984,_0x178895){return _0x178536(_0x11300b,_0xce9984,_0x178895);},'KufEs':_0x3805(0x69)};return _0xb63db3[_0x3805(0x6a)](makeUserApiRequest,_0xb63db3[_0x3805(0x6b)],'PUT',{'data':{'platforms':_0xcc06e5},'debug':_0x25c89e['debug']});};function _0x509a(){const _0x354283=['defineProperty','__esModule','updatePlatformConnections','storePIN','refreshToken','isCurrentUserAuthenticated','getPlatformData','getCurrentUserToken','createAccount','authenticate','ApiError','1|0|4|2|3','type','details','APOWR','code','default','fetch','oRBxE','isConnected','timeout_error','An\x20unexpected\x20error\x20occurred','No\x20network\x20connection\x20available','network_error','User\x20API\x20Request','[REDACTED]','auth_error','API\x20request\x20failed','VTgQM','WxTqf','User\x20API\x20Error','dZlFm','AINNf','TfFZj','XLaOU','logDebug','TFvje','message','pQoWC','LvZSC','mFTaH','UgHhs','isUserAuthenticated','User\x20not\x20authenticated.\x20Please\x20verify\x20email\x20first.','GTtLc','makeUserRequest','stringify','json','User\x20API\x20Response','status','ftouz','vbsJn','validation_error','smwwZ','server_error','error','KvccW','JfEkO','rliwy','qvZBw','name','qhGPh','Request\x20timed\x20out','Unknown\x20error','Developer\x20API\x20Request','unknown_error','amdbR','anIXy','AbortError','Developer\x20API\x20Error','JpGwa','bwMqC','itLjk','UDUBZ','Developer\x20API\x20Response','zzwlI','dhktj','PFoag','hoTMl','pTcaZ','KGxyN','jLMcx','sOQCL','QbYdF','VEWrl','MWoAQ','oIUqw','auth/validate','debug','success','oAnjz','validateCredentials','auth/register','KVKWL','username','platforms','auth/login','userPin','auth/refresh','LeMWP','iwHDx','/data','user/profile','jqeFb','getUserProfile','user/platforms','bffvf','KufEs','store-pin/mobile','extractUsernameFromJWT','No\x20username\x20available\x20-\x20either\x20provide\x20username\x20or\x20ensure\x20JWT\x20token\x20is\x20valid','tuAea','ztURG','getJWT'];_0x509a=function(){return _0x354283;};return _0x509a();}exports['updatePlatformConnections']=updatePlatformConnections;const storePIN=async(_0xe6bcfa,_0xbdc36c={})=>{const _0x5414d1={'tuAea':_0x3805(0x1a),'ztURG':_0x3805(0x6c)},{debug:debug=![],username:_0x4311b3}=_0xbdc36c,_0x25afd9=_0x4311b3||(0x0,_apiKeyService[_0x3805(0x6d)])();if(!_0x25afd9)throw new ApiError(_0x3805(0x6e),_0x5414d1[_0x3805(0x6f)]);return makeUserApiRequest(_0x5414d1[_0x3805(0x70)],'POST',{'data':{'username':_0x25afd9,'pin':_0xe6bcfa},'debug':debug});};exports[_0x3805(0x3)]=storePIN;const getCurrentUserToken=async()=>{return await(0x0,_apiKeyService[_0x3805(0x71)])();};exports['getCurrentUserToken']=getCurrentUserToken;function _0x3805(_0x509aff,_0x3805c1){_0x509aff=_0x509aff-0x0;const _0x382a29=_0x509a();let _0x58f069=_0x382a29[_0x509aff];return _0x58f069;}const isCurrentUserAuthenticated=()=>{return(0x0,_apiKeyService[_0x3805(0x2a)])();};exports[_0x3805(0x5)]=isCurrentUserAuthenticated;
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.validateCredentials = exports.updatePlatformConnections = exports.storePIN = exports.refreshToken = exports.isCurrentUserAuthenticated = exports.getUserProfile = exports.getPlatformData = exports.getCurrentUserToken = exports.createAccount = exports.authenticate = exports.ApiError = void 0;
|
|
7
|
+
var _netinfo = _interopRequireDefault(require("@react-native-community/netinfo"));
|
|
8
|
+
var _debugHelper = require("./debugHelper");
|
|
9
|
+
var _apiKeyService = require("../services/apiKeyService");
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
// API response types
|
|
12
|
+
|
|
13
|
+
// Error types
|
|
14
|
+
|
|
15
|
+
// API error structure
|
|
16
|
+
class ApiError extends Error {
|
|
17
|
+
constructor(message, type, code, details) {
|
|
18
|
+
super(message);
|
|
19
|
+
this.type = type;
|
|
20
|
+
this.code = code;
|
|
21
|
+
this.details = details;
|
|
22
|
+
this.name = 'ApiError';
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Check if the device has an active network connection
|
|
28
|
+
*/
|
|
29
|
+
exports.ApiError = ApiError;
|
|
30
|
+
const checkNetworkConnection = async () => {
|
|
31
|
+
const networkState = await _netinfo.default.fetch();
|
|
32
|
+
return networkState.isConnected === true;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Make user-authenticated API request using JWT token
|
|
37
|
+
*/
|
|
38
|
+
const makeUserApiRequest = async (endpoint, method, options = {}) => {
|
|
39
|
+
const {
|
|
40
|
+
data,
|
|
41
|
+
headers = {},
|
|
42
|
+
debug = false
|
|
43
|
+
} = options;
|
|
44
|
+
try {
|
|
45
|
+
// Check for network connectivity
|
|
46
|
+
const isConnected = await checkNetworkConnection();
|
|
47
|
+
if (!isConnected) {
|
|
48
|
+
throw new ApiError('No network connection available', 'network_error');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Check if user is authenticated
|
|
52
|
+
if (!(0, _apiKeyService.isUserAuthenticated)()) {
|
|
53
|
+
throw new ApiError('User not authenticated. Please verify email first.', 'auth_error');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Log request information if debug mode is enabled
|
|
57
|
+
if (debug) {
|
|
58
|
+
(0, _debugHelper.logDebug)('User API Request', {
|
|
59
|
+
endpoint,
|
|
60
|
+
method,
|
|
61
|
+
headers: {
|
|
62
|
+
...headers,
|
|
63
|
+
Authorization: '[REDACTED]'
|
|
64
|
+
},
|
|
65
|
+
data: data || null
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Make authenticated request using JWT token
|
|
70
|
+
const response = await (0, _apiKeyService.makeUserRequest)(endpoint, {
|
|
71
|
+
method,
|
|
72
|
+
headers,
|
|
73
|
+
...(data ? {
|
|
74
|
+
body: JSON.stringify(data)
|
|
75
|
+
} : {})
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// Parse response as JSON
|
|
79
|
+
const responseData = await response.json();
|
|
80
|
+
|
|
81
|
+
// Log response if debug mode is enabled
|
|
82
|
+
if (debug) {
|
|
83
|
+
(0, _debugHelper.logDebug)('User API Response', {
|
|
84
|
+
status: response.status,
|
|
85
|
+
data: responseData
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Handle API error responses
|
|
90
|
+
if (!response.ok) {
|
|
91
|
+
var _responseData$error, _responseData$error2, _responseData$error3;
|
|
92
|
+
const errorType = response.status === 401 || response.status === 403 ? 'auth_error' : response.status === 400 ? 'validation_error' : response.status >= 500 ? 'server_error' : 'unknown_error';
|
|
93
|
+
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);
|
|
94
|
+
}
|
|
95
|
+
return responseData;
|
|
96
|
+
} catch (error) {
|
|
97
|
+
// Handle specific error types
|
|
98
|
+
if (error instanceof ApiError) {
|
|
99
|
+
throw error;
|
|
100
|
+
}
|
|
101
|
+
if (error.name === 'AbortError') {
|
|
102
|
+
throw new ApiError('Request timed out', 'timeout_error');
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Log error if debug mode is enabled
|
|
106
|
+
if (debug) {
|
|
107
|
+
(0, _debugHelper.logDebug)('User API Error', {
|
|
108
|
+
endpoint,
|
|
109
|
+
method,
|
|
110
|
+
error: error.message || 'Unknown error'
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Return a generic error for all other cases
|
|
115
|
+
throw new ApiError(error.message || 'An unexpected error occurred', 'unknown_error');
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Make developer-authenticated API request using API key
|
|
121
|
+
*/
|
|
122
|
+
const makeDeveloperApiRequest = async (endpoint, method, options = {}) => {
|
|
123
|
+
const {
|
|
124
|
+
data,
|
|
125
|
+
headers = {},
|
|
126
|
+
debug = false
|
|
127
|
+
} = options;
|
|
128
|
+
try {
|
|
129
|
+
// Check for network connectivity
|
|
130
|
+
const isConnected = await checkNetworkConnection();
|
|
131
|
+
if (!isConnected) {
|
|
132
|
+
throw new ApiError('No network connection available', 'network_error');
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Log request information if debug mode is enabled
|
|
136
|
+
if (debug) {
|
|
137
|
+
(0, _debugHelper.logDebug)('Developer API Request', {
|
|
138
|
+
endpoint,
|
|
139
|
+
method,
|
|
140
|
+
headers: {
|
|
141
|
+
...headers,
|
|
142
|
+
Authorization: '[REDACTED]'
|
|
143
|
+
},
|
|
144
|
+
data: data || null
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Make authenticated request using developer API key
|
|
149
|
+
const response = await (0, _apiKeyService.makeDeveloperRequest)(endpoint, {
|
|
150
|
+
method,
|
|
151
|
+
headers,
|
|
152
|
+
...(data ? {
|
|
153
|
+
body: JSON.stringify(data)
|
|
154
|
+
} : {})
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
// Parse response as JSON
|
|
158
|
+
const responseData = await response.json();
|
|
159
|
+
|
|
160
|
+
// Log response if debug mode is enabled
|
|
161
|
+
if (debug) {
|
|
162
|
+
(0, _debugHelper.logDebug)('Developer API Response', {
|
|
163
|
+
status: response.status,
|
|
164
|
+
data: responseData
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Handle API error responses
|
|
169
|
+
if (!response.ok) {
|
|
170
|
+
var _responseData$error4, _responseData$error5, _responseData$error6;
|
|
171
|
+
const errorType = response.status === 401 || response.status === 403 ? 'auth_error' : response.status === 400 ? 'validation_error' : response.status >= 500 ? 'server_error' : 'unknown_error';
|
|
172
|
+
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);
|
|
173
|
+
}
|
|
174
|
+
return responseData;
|
|
175
|
+
} catch (error) {
|
|
176
|
+
// Handle specific error types
|
|
177
|
+
if (error instanceof ApiError) {
|
|
178
|
+
throw error;
|
|
179
|
+
}
|
|
180
|
+
if (error.name === 'AbortError') {
|
|
181
|
+
throw new ApiError('Request timed out', 'timeout_error');
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// Log error if debug mode is enabled
|
|
185
|
+
if (debug) {
|
|
186
|
+
(0, _debugHelper.logDebug)('Developer API Error', {
|
|
187
|
+
endpoint,
|
|
188
|
+
method,
|
|
189
|
+
error: error.message || 'Unknown error'
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// Return a generic error for all other cases
|
|
194
|
+
throw new ApiError(error.message || 'An unexpected error occurred', 'unknown_error');
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Validate user credentials with the API (uses JWT)
|
|
200
|
+
*/
|
|
201
|
+
const validateCredentials = async (username, options = {
|
|
202
|
+
debug: false
|
|
203
|
+
}) => {
|
|
204
|
+
try {
|
|
205
|
+
var _response$data, _response$error;
|
|
206
|
+
const response = await makeUserApiRequest('auth/validate', 'POST', {
|
|
207
|
+
data: {
|
|
208
|
+
username
|
|
209
|
+
},
|
|
210
|
+
debug: options.debug
|
|
211
|
+
});
|
|
212
|
+
return {
|
|
213
|
+
isValid: response.success && ((_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.isValid) === true,
|
|
214
|
+
message: (_response$error = response.error) === null || _response$error === void 0 ? void 0 : _response$error.message
|
|
215
|
+
};
|
|
216
|
+
} catch (error) {
|
|
217
|
+
return {
|
|
218
|
+
isValid: false,
|
|
219
|
+
message: error.message
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Create a new user account (uses developer API key)
|
|
226
|
+
*/
|
|
227
|
+
exports.validateCredentials = validateCredentials;
|
|
228
|
+
const createAccount = async (credentials, options = {
|
|
229
|
+
debug: false
|
|
230
|
+
}) => {
|
|
231
|
+
return makeDeveloperApiRequest('auth/register', 'POST', {
|
|
232
|
+
data: {
|
|
233
|
+
username: credentials.username,
|
|
234
|
+
platforms: credentials.platforms
|
|
235
|
+
},
|
|
236
|
+
debug: options.debug
|
|
237
|
+
});
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Authenticate with the API using credentials (uses JWT)
|
|
242
|
+
*/
|
|
243
|
+
exports.createAccount = createAccount;
|
|
244
|
+
const authenticate = async (credentials, options = {
|
|
245
|
+
debug: false
|
|
246
|
+
}) => {
|
|
247
|
+
return makeUserApiRequest('auth/login', 'POST', {
|
|
248
|
+
data: {
|
|
249
|
+
username: credentials.username,
|
|
250
|
+
pin: credentials.userPin
|
|
251
|
+
},
|
|
252
|
+
debug: options.debug
|
|
253
|
+
});
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Refresh authentication token (uses JWT)
|
|
258
|
+
*/
|
|
259
|
+
exports.authenticate = authenticate;
|
|
260
|
+
const refreshToken = async (refreshToken, options = {
|
|
261
|
+
debug: false
|
|
262
|
+
}) => {
|
|
263
|
+
return makeUserApiRequest('auth/refresh', 'POST', {
|
|
264
|
+
data: {
|
|
265
|
+
refreshToken
|
|
266
|
+
},
|
|
267
|
+
debug: options.debug
|
|
268
|
+
});
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Get user's connected platform data (uses JWT)
|
|
273
|
+
*/
|
|
274
|
+
exports.refreshToken = refreshToken;
|
|
275
|
+
const getPlatformData = async (platform, options = {
|
|
276
|
+
debug: false
|
|
277
|
+
}) => {
|
|
278
|
+
return makeUserApiRequest(`platforms/${platform}/data`, 'GET', {
|
|
279
|
+
debug: options.debug
|
|
280
|
+
});
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Get user profile information (uses JWT)
|
|
285
|
+
*/
|
|
286
|
+
exports.getPlatformData = getPlatformData;
|
|
287
|
+
const getUserProfile = async (options = {
|
|
288
|
+
debug: false
|
|
289
|
+
}) => {
|
|
290
|
+
return makeUserApiRequest('user/profile', 'GET', {
|
|
291
|
+
debug: options.debug
|
|
292
|
+
});
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Update user platform connections (uses JWT)
|
|
297
|
+
*/
|
|
298
|
+
exports.getUserProfile = getUserProfile;
|
|
299
|
+
const updatePlatformConnections = async (platforms, options = {
|
|
300
|
+
debug: false
|
|
301
|
+
}) => {
|
|
302
|
+
return makeUserApiRequest('user/platforms', 'PUT', {
|
|
303
|
+
data: {
|
|
304
|
+
platforms
|
|
305
|
+
},
|
|
306
|
+
debug: options.debug
|
|
307
|
+
});
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Store user PIN (uses JWT and extracts username from JWT)
|
|
312
|
+
*/
|
|
313
|
+
exports.updatePlatformConnections = updatePlatformConnections;
|
|
314
|
+
const storePIN = async (pin, options = {}) => {
|
|
315
|
+
const {
|
|
316
|
+
debug = false,
|
|
317
|
+
username
|
|
318
|
+
} = options;
|
|
319
|
+
|
|
320
|
+
// Extract username from JWT if not provided
|
|
321
|
+
const userToStore = username || (0, _apiKeyService.extractUsernameFromJWT)();
|
|
322
|
+
if (!userToStore) {
|
|
323
|
+
throw new ApiError('No username available - either provide username or ensure JWT token is valid', 'auth_error');
|
|
324
|
+
}
|
|
325
|
+
return makeUserApiRequest('store-pin/mobile', 'POST', {
|
|
326
|
+
data: {
|
|
327
|
+
username: userToStore,
|
|
328
|
+
pin
|
|
329
|
+
},
|
|
330
|
+
debug
|
|
331
|
+
});
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Get current JWT token
|
|
336
|
+
*/
|
|
337
|
+
exports.storePIN = storePIN;
|
|
338
|
+
const getCurrentUserToken = async () => {
|
|
339
|
+
return await (0, _apiKeyService.getJWT)();
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Check if user is authenticated with JWT
|
|
344
|
+
*/
|
|
345
|
+
exports.getCurrentUserToken = getCurrentUserToken;
|
|
346
|
+
const isCurrentUserAuthenticated = () => {
|
|
347
|
+
return (0, _apiKeyService.isUserAuthenticated)();
|
|
348
|
+
};
|
|
349
|
+
exports.isCurrentUserAuthenticated = isCurrentUserAuthenticated;
|
|
350
|
+
//# sourceMappingURL=onairosApi.js.map
|