@onairos/react-native 3.6.4 → 3.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/api/index.js +1 -1
- package/lib/commonjs/components/BodyText.js +1 -1
- package/lib/commonjs/components/BrandMark.js +1 -1
- package/lib/commonjs/components/CodeInput.js +1 -1
- package/lib/commonjs/components/EmailInput.js +1 -1
- package/lib/commonjs/components/GoogleButton.js +1 -1
- package/lib/commonjs/components/HeadingGroup.js +1 -1
- package/lib/commonjs/components/LLMDataInputModal.js +1 -1
- package/lib/commonjs/components/ModalHeader.js +1 -1
- package/lib/commonjs/components/ModalSheet.js +1 -1
- package/lib/commonjs/components/Onairos.js +1 -1
- package/lib/commonjs/components/OnairosButton.js +1 -1
- package/lib/commonjs/components/OnairosSignInButton.js +1 -1
- package/lib/commonjs/components/Overlay.js +1 -1
- package/lib/commonjs/components/PersonaImage.js +1 -1
- package/lib/commonjs/components/PersonaLoadingScreen.js +1 -1
- package/lib/commonjs/components/PersonalizationConsentScreen.js +1 -1
- package/lib/commonjs/components/PinCreationScreen.js +1 -1
- package/lib/commonjs/components/PinInput.js +1 -1
- package/lib/commonjs/components/PlatformConnectorsStep.js +1 -1
- package/lib/commonjs/components/PlatformList.js +1 -1
- package/lib/commonjs/components/PlatformToggle.js +1 -1
- package/lib/commonjs/components/PrimaryButton.js +1 -1
- package/lib/commonjs/components/SignInMatchAnimation.js +1 -1
- package/lib/commonjs/components/SignInStep.js +1 -1
- package/lib/commonjs/components/UniversalOnboarding.js +1 -1
- package/lib/commonjs/components/VerificationStep.js +1 -1
- package/lib/commonjs/components/WelcomeScreen.js +1 -1
- package/lib/commonjs/components/icons/Basicproficon.js +1 -1
- package/lib/commonjs/components/icons/Basicprofile.js +1 -1
- package/lib/commonjs/components/icons/Checkbox.js +1 -1
- package/lib/commonjs/components/icons/Checkmark.js +1 -1
- package/lib/commonjs/components/icons/Contentanalysis.js +1 -1
- package/lib/commonjs/components/icons/Contenticon.js +1 -1
- package/lib/commonjs/components/icons/EnochE.js +1 -1
- package/lib/commonjs/components/icons/Personalityicon.js +1 -1
- package/lib/commonjs/components/icons/Personalityprofile.js +1 -1
- package/lib/commonjs/components/icons/Personalitytraits.js +1 -1
- package/lib/commonjs/components/icons/Userpreferences.js +1 -1
- package/lib/commonjs/components/icons/index.js +1 -1
- package/lib/commonjs/components/onboarding/OAuthWebView.js +1 -1
- package/lib/commonjs/components/onboarding/OnboardingHeader.js +1 -1
- package/lib/commonjs/components/onboarding/PinInput.js +1 -1
- package/lib/commonjs/components/onboarding/PlatformConnector.js +1 -1
- package/lib/commonjs/config/api.js +1 -1
- package/lib/commonjs/constants/index.js +1 -1
- package/lib/commonjs/context/AuthContext.js +1 -1
- package/lib/commonjs/hooks/useConnectedAccounts.js +1 -1
- package/lib/commonjs/hooks/useConnections.js +1 -1
- package/lib/commonjs/hooks/useCredentials.js +1 -1
- package/lib/commonjs/hooks/useUserConnections.js +1 -1
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/services/apiClient.js +1 -1
- package/lib/commonjs/services/apiKeyService.js +924 -9
- package/lib/commonjs/services/authService.js +627 -10
- package/lib/commonjs/services/biometricPinService.js +1 -1
- package/lib/commonjs/services/chatGPTConversationExtractor.js +1 -1
- package/lib/commonjs/services/chatGPTConversationService.js +1 -1
- package/lib/commonjs/services/claudeConversationExtractor.js +1 -1
- package/lib/commonjs/services/claudeConversationService.js +1 -1
- package/lib/commonjs/services/connectedAccountsService.js +1 -1
- package/lib/commonjs/services/googleAuthService.js +1 -1
- package/lib/commonjs/services/hingeDataExtractor.js +1 -1
- package/lib/commonjs/services/hingeDataService.js +1 -1
- package/lib/commonjs/services/imageCompressionService.js +1 -1
- package/lib/commonjs/services/instagramDataExtractor.js +1 -1
- package/lib/commonjs/services/instagramDataService.js +1 -1
- package/lib/commonjs/services/jwtStorageService.js +1 -1
- package/lib/commonjs/services/linkedinDOMExtractor.js +1 -1
- package/lib/commonjs/services/linkedinProfileService.js +1 -1
- package/lib/commonjs/services/linkedinScrapingService.js +1 -1
- package/lib/commonjs/services/llmDataStorage.js +1 -1
- package/lib/commonjs/services/mobileTrainingService.js +1 -1
- package/lib/commonjs/services/oauthService.js +391 -11
- package/lib/commonjs/services/pinEncryptionService.js +1 -1
- package/lib/commonjs/services/pinStorageUtils.js +1 -1
- package/lib/commonjs/services/platformAuthService.js +1 -1
- package/lib/commonjs/services/sephoraDataExtractor.js +1 -1
- package/lib/commonjs/services/sephoraDataService.js +1 -1
- package/lib/commonjs/services/storageService.js +1 -1
- package/lib/commonjs/services/telegramDataExtractor.js +1 -1
- package/lib/commonjs/services/telegramDataService.js +1 -1
- package/lib/commonjs/services/trainingApiHelpers.js +1 -1
- package/lib/commonjs/services/userConnectionsService.js +1 -1
- package/lib/commonjs/services/youtubeMigrationService.js +1 -1
- package/lib/commonjs/theme/index.js +1 -1
- package/lib/commonjs/types/index.js +1 -1
- package/lib/commonjs/types.js +1 -1
- package/lib/commonjs/utils/Portal.js +1 -1
- package/lib/commonjs/utils/api.js +1 -1
- package/lib/commonjs/utils/assetRegistry.js +1 -1
- package/lib/commonjs/utils/auth.js +1 -1
- package/lib/commonjs/utils/connectorTests.js +1 -1
- package/lib/commonjs/utils/crypto.js +1 -1
- package/lib/commonjs/utils/debugHelper.js +1 -1
- package/lib/commonjs/utils/encryption.js +1 -1
- package/lib/commonjs/utils/eventUtils.js +1 -1
- package/lib/commonjs/utils/haptics.js +1 -1
- package/lib/commonjs/utils/imagePreloader.js +1 -1
- package/lib/commonjs/utils/networkDiagnostics.js +1 -1
- package/lib/commonjs/utils/onairosApi.js +1 -1
- package/lib/commonjs/utils/programmaticFlow.js +1 -1
- package/lib/commonjs/utils/retryHelper.js +1 -1
- package/lib/commonjs/utils/secureStorage.js +1 -1
- package/lib/commonjs/utils/webviewScripts/chatgpt.js +1 -1
- package/lib/commonjs/utils/webviewScripts/claude.js +1 -1
- package/lib/commonjs/utils/webviewScripts/hinge.js +1 -1
- package/lib/commonjs/utils/webviewScripts/index.js +1 -1
- package/lib/commonjs/utils/webviewScripts/instagram.js +1 -1
- package/lib/commonjs/utils/webviewScripts/linkedin.js +1 -1
- package/lib/commonjs/utils/webviewScripts/sephora.js +1 -1
- package/lib/commonjs/utils/webviewScripts/telegram.js +1 -1
- package/lib/module/api/index.js +1 -1
- package/lib/module/components/BodyText.js +1 -1
- package/lib/module/components/BrandMark.js +1 -1
- package/lib/module/components/CodeInput.js +1 -1
- package/lib/module/components/EmailInput.js +1 -1
- package/lib/module/components/GoogleButton.js +1 -1
- package/lib/module/components/HeadingGroup.js +1 -1
- package/lib/module/components/LLMDataInputModal.js +1 -1
- package/lib/module/components/ModalHeader.js +1 -1
- package/lib/module/components/ModalSheet.js +1 -1
- package/lib/module/components/Onairos.js +1 -1
- package/lib/module/components/OnairosButton.js +1 -1
- package/lib/module/components/OnairosSignInButton.js +1 -1
- package/lib/module/components/Overlay.js +1 -1
- package/lib/module/components/PersonaImage.js +1 -1
- package/lib/module/components/PersonaLoadingScreen.js +1 -1
- package/lib/module/components/PersonalizationConsentScreen.js +1 -1
- package/lib/module/components/PinCreationScreen.js +1 -1
- package/lib/module/components/PinInput.js +1 -1
- package/lib/module/components/PlatformConnectorsStep.js +1 -1
- package/lib/module/components/PlatformList.js +1 -1
- package/lib/module/components/PlatformToggle.js +1 -1
- package/lib/module/components/PrimaryButton.js +1 -1
- package/lib/module/components/SignInMatchAnimation.js +1 -1
- package/lib/module/components/SignInStep.js +1 -1
- package/lib/module/components/UniversalOnboarding.js +1 -1
- package/lib/module/components/VerificationStep.js +1 -1
- package/lib/module/components/WelcomeScreen.js +1 -1
- package/lib/module/components/icons/Basicproficon.js +1 -1
- package/lib/module/components/icons/Basicprofile.js +1 -1
- package/lib/module/components/icons/Checkbox.js +1 -1
- package/lib/module/components/icons/Checkmark.js +1 -1
- package/lib/module/components/icons/Contentanalysis.js +1 -1
- package/lib/module/components/icons/Contenticon.js +1 -1
- package/lib/module/components/icons/EnochE.js +1 -1
- package/lib/module/components/icons/Personalityicon.js +1 -1
- package/lib/module/components/icons/Personalityprofile.js +1 -1
- package/lib/module/components/icons/Personalitytraits.js +1 -1
- package/lib/module/components/icons/Userpreferences.js +1 -1
- package/lib/module/components/onboarding/OAuthWebView.js +1 -1
- package/lib/module/components/onboarding/OnboardingHeader.js +1 -1
- package/lib/module/components/onboarding/PinInput.js +1 -1
- package/lib/module/components/onboarding/PlatformConnector.js +1 -1
- package/lib/module/config/api.js +1 -1
- package/lib/module/constants/index.js +1 -1
- package/lib/module/context/AuthContext.js +1 -1
- package/lib/module/hooks/useConnectedAccounts.js +1 -1
- package/lib/module/hooks/useConnections.js +1 -1
- package/lib/module/hooks/useCredentials.js +1 -1
- package/lib/module/hooks/useUserConnections.js +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/services/apiClient.js +1 -1
- package/lib/module/services/apiKeyService.js +898 -1
- package/lib/module/services/authService.js +602 -1
- package/lib/module/services/biometricPinService.js +1 -1
- package/lib/module/services/chatGPTConversationExtractor.js +1 -1
- package/lib/module/services/chatGPTConversationService.js +1 -1
- package/lib/module/services/claudeConversationExtractor.js +1 -1
- package/lib/module/services/claudeConversationService.js +1 -1
- package/lib/module/services/connectedAccountsService.js +1 -1
- package/lib/module/services/googleAuthService.js +1 -1
- package/lib/module/services/hingeDataExtractor.js +1 -1
- package/lib/module/services/hingeDataService.js +1 -1
- package/lib/module/services/imageCompressionService.js +1 -1
- package/lib/module/services/instagramDataExtractor.js +1 -1
- package/lib/module/services/instagramDataService.js +1 -1
- package/lib/module/services/jwtStorageService.js +1 -1
- package/lib/module/services/linkedinDOMExtractor.js +1 -1
- package/lib/module/services/linkedinProfileService.js +1 -1
- package/lib/module/services/linkedinScrapingService.js +1 -1
- package/lib/module/services/llmDataStorage.js +1 -1
- package/lib/module/services/mobileTrainingService.js +1 -1
- package/lib/module/services/oauthService.js +381 -1
- package/lib/module/services/pinEncryptionService.js +1 -1
- package/lib/module/services/pinStorageUtils.js +1 -1
- package/lib/module/services/platformAuthService.js +1 -1
- package/lib/module/services/sephoraDataExtractor.js +1 -1
- package/lib/module/services/sephoraDataService.js +1 -1
- package/lib/module/services/storageService.js +1 -1
- package/lib/module/services/telegramDataExtractor.js +1 -1
- package/lib/module/services/telegramDataService.js +1 -1
- package/lib/module/services/trainingApiHelpers.js +1 -1
- package/lib/module/services/userConnectionsService.js +1 -1
- package/lib/module/services/youtubeMigrationService.js +1 -1
- package/lib/module/theme/index.js +1 -1
- package/lib/module/types.js +1 -1
- package/lib/module/utils/Portal.js +1 -1
- package/lib/module/utils/api.js +1 -1
- package/lib/module/utils/assetRegistry.js +1 -1
- package/lib/module/utils/auth.js +1 -1
- package/lib/module/utils/connectorTests.js +1 -1
- package/lib/module/utils/crypto.js +1 -1
- package/lib/module/utils/debugHelper.js +1 -1
- package/lib/module/utils/encryption.js +1 -1
- package/lib/module/utils/eventUtils.js +1 -1
- package/lib/module/utils/haptics.js +1 -1
- package/lib/module/utils/networkDiagnostics.js +1 -1
- package/lib/module/utils/onairosApi.js +1 -1
- package/lib/module/utils/programmaticFlow.js +1 -1
- package/lib/module/utils/retryHelper.js +1 -1
- package/lib/module/utils/secureStorage.js +1 -1
- package/lib/module/utils/webviewScripts/chatgpt.js +1 -1
- package/lib/module/utils/webviewScripts/claude.js +1 -1
- package/lib/module/utils/webviewScripts/hinge.js +1 -1
- package/lib/module/utils/webviewScripts/index.js +1 -1
- package/lib/module/utils/webviewScripts/instagram.js +1 -1
- package/lib/module/utils/webviewScripts/linkedin.js +1 -1
- package/lib/module/utils/webviewScripts/sephora.js +1 -1
- package/lib/module/utils/webviewScripts/telegram.js +1 -1
- package/package.json +1 -1
|
@@ -1,9 +1,924 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Object[_0x3f08(0x0)](exports,_0x3f08(0x1),{'value':!![]}),exports[_0x3f08(0x2)]=exports[_0x3f08(0x3)]=exports[_0x3f08(0x4)]=exports['makeUserRequest']=exports[_0x3f08(0x5)]=exports[_0x3f08(0x6)]=exports[_0x3f08(0x7)]=exports[_0x3f08(0x8)]=exports[_0x3f08(0x9)]=exports[_0x3f08(0xa)]=exports['getUserAuthHeaders']=exports[_0x3f08(0xb)]=exports[_0x3f08(0xc)]=exports[_0x3f08(0xd)]=exports[_0x3f08(0xe)]=exports['getApiKey']=exports[_0x3f08(0xf)]=exports[_0x3f08(0x10)]=exports[_0x3f08(0x11)]=exports['decodeJWTPayload']=exports[_0x3f08(0x12)]=exports[_0x3f08(0x13)]=exports['ApiKeyType']=void 0x0;var _asyncStorage=_interopRequireDefault(__ONAIROS_REQ_FUNC__(0x0)),_netinfo=_interopRequireDefault(__ONAIROS_REQ_FUNC__(0x1)),_api=__ONAIROS_REQ_FUNC__(0x2);function _interopRequireDefault(_0x57fced){return _0x57fced&&_0x57fced[_0x3f08(0x1)]?_0x57fced:{'default':_0x57fced};}let ApiKeyType=exports[_0x3f08(0x14)]=function(_0x444718){const _0x178f20={'eJBmI':'developer','nZeGt':_0x3f08(0x15)};return _0x444718[_0x3f08(0x16)]=_0x178f20['eJBmI'],_0x444718[_0x178f20[_0x3f08(0x17)]]=_0x3f08(0x18),_0x444718;}({});const JWT_TOKEN_KEY=_0x3f08(0x19);let globalConfig=null,validationCache=new Map(),isInitialized=![],userToken=null;const CACHE_DURATION=0x5*0x3c*0x3e8,checkNetworkConnectivity=async()=>{const _0x1f5b1a={'MTvdf':function(_0x519ba4,_0x5f1e93){return _0x519ba4===_0x5f1e93;},'DbsIz':function(_0x3cbb67,_0x56f0b7){return _0x3cbb67!==_0x56f0b7;}};try{const _0x394fed=await _netinfo['default']['fetch']();return _0x1f5b1a[_0x3f08(0x1a)](_0x394fed['isConnected'],!![])&&_0x1f5b1a[_0x3f08(0x1b)](_0x394fed[_0x3f08(0x1c)],![]);}catch(_0x4a47f0){return console[_0x3f08(0x1d)](_0x3f08(0x1e),_0x4a47f0),!![];}},API_ENDPOINTS={'production':''+_api[_0x3f08(0x1f)][_0x3f08(0x20)],'staging':''+_api['API_CONFIG']['BASE_URL'],'development':''+_api['API_CONFIG'][_0x3f08(0x20)]},initializeApiKey=async _0x590efe=>{const _0x1214d4={'BTEbg':function(_0x4f60fa,_0x5c0e20){return _0x4f60fa!==_0x5c0e20;},'aThdS':_0x3f08(0x21),'nBWvB':function(_0x482aca,_0x5bb211){return _0x482aca===_0x5bb211;},'yFkXQ':function(_0x44d06a,_0x241e3e){return _0x44d06a!==_0x241e3e;},'GquqI':function(_0x4dd488,_0xea7ca7){return _0x4dd488(_0xea7ca7);},'zcSQD':_0x3f08(0x22),'HcrjA':_0x3f08(0x23),'WZgdM':_0x3f08(0x24),'CQEcT':_0x3f08(0x25),'ievel':function(_0x52f99c,_0x53edc8){return _0x52f99c/_0x53edc8;},'Uhebu':_0x3f08(0x26),'YpBnl':function(_0x3c5ad0,_0x5cd24f){return _0x3c5ad0<_0x5cd24f;},'tglmL':function(_0x12143,_0x66b73f){return _0x12143===_0x66b73f;},'bcnVq':_0x3f08(0x27),'LeRUZ':_0x3f08(0x28),'duCpt':_0x3f08(0x29),'PuQVb':_0x3f08(0x2a),'mxMNG':_0x3f08(0x2b),'FYPDe':function(_0x543eab,_0x10d84e){return _0x543eab+_0x10d84e;},'XIDsf':_0x3f08(0x2c),'iwzym':_0x3f08(0x2d),'RFVTX':'JSON\x20Parse\x20error','FTDDD':'API\x20validation\x20endpoint\x20returned','fZOsl':'timeout','SEWyH':'ENOTFOUND','Nkkwp':_0x3f08(0x2e),'cqxmM':'No\x20network\x20connection','YrTZw':function(_0x1deae0,_0x173306){return _0x1deae0===_0x173306;},'GuymJ':'lgvwb','uqrqk':_0x3f08(0x2f),'NhIZE':'📱\x20SDK\x20initialized\x20in\x20offline\x20mode\x20-\x20will\x20retry\x20validation\x20when\x20network\x20is\x20available','kATLZ':_0x3f08(0x30),'oWxSv':_0x3f08(0x31),'HqKwf':_0x3f08(0x32),'BEMAa':function(_0x5bc4d){return _0x5bc4d();},'YyXZa':_0x3f08(0x33),'hCwDp':_0x3f08(0x34),'qosWr':_0x3f08(0x35),'yDMcz':_0x3f08(0x36),'VMHws':function(_0x4d552a,_0x36a784){return _0x4d552a!==_0x36a784;},'mDqrC':'uYacO'};try{console[_0x3f08(0x37)](_0x3f08(0x38));if(!_0x590efe[_0x3f08(0x39)])throw new Error(_0x1214d4[_0x3f08(0x3a)]);if(_0x1214d4['YpBnl'](_0x590efe[_0x3f08(0x39)][_0x3f08(0x3b)],0x20)){if(_0x1214d4[_0x3f08(0x3c)](_0x1214d4['bcnVq'],_0x1214d4[_0x3f08(0x3d)]))return _0x4a036c&&_0x1214d4[_0x3f08(0x3e)](_0xc74fb,null);else throw new Error('Invalid\x20API\x20key\x20format.\x20Developer\x20keys\x20must\x20be\x20at\x20least\x2032\x20characters\x20long.');}const _0xd6706d=[_0x1214d4[_0x3f08(0x3f)],_0x3f08(0x40),'pk_'],_0x1951f9=_0xd6706d[_0x3f08(0x41)](_0x1d5b68=>_0x590efe[_0x3f08(0x39)][_0x3f08(0x42)](_0x1d5b68));if(!_0x1951f9)throw new Error(_0x1214d4[_0x3f08(0x43)]);globalConfig={'apiKey':_0x590efe['apiKey'],'environment':_0x590efe['environment']||_0x1214d4['WZgdM'],'enableLogging':_0x1214d4['yFkXQ'](_0x590efe['enableLogging'],![]),'timeout':_0x590efe[_0x3f08(0x44)]||0x7530,'retryAttempts':_0x590efe[_0x3f08(0x45)]||0x3};globalConfig[_0x3f08(0x46)]&&(_0x1214d4[_0x3f08(0x47)](_0x3f08(0x48),_0x3f08(0x49))?_0xa85e4d['log'](_0x1214d4[_0x3f08(0x4a)]):console['log'](_0x1214d4[_0x3f08(0x4b)],{'environment':globalConfig['environment'],'timeout':globalConfig['timeout'],'retryAttempts':globalConfig[_0x3f08(0x45)],'apiKeyPrefix':_0x1214d4[_0x3f08(0x4c)](_0x590efe[_0x3f08(0x39)][_0x3f08(0x4d)](0x0,0x8),_0x1214d4[_0x3f08(0x4e)]),'enableLogging':globalConfig[_0x3f08(0x46)]}));const _0x5b5b88=await _0x1214d4[_0x3f08(0x4f)](validateApiKey,_0x590efe[_0x3f08(0x39)]);if(!_0x5b5b88[_0x3f08(0x50)]){const _0x346cf9=_0x5b5b88[_0x3f08(0x51)]||'',_0x3de713=_0x5b5b88['isNetworkError']||_0x346cf9[_0x3f08(0x52)](_0x1214d4[_0x3f08(0x53)])||_0x346cf9[_0x3f08(0x52)]('Network\x20error')||_0x346cf9[_0x3f08(0x52)](_0x1214d4['RFVTX'])||_0x346cf9[_0x3f08(0x52)](_0x1214d4[_0x3f08(0x54)])||_0x346cf9[_0x3f08(0x52)](_0x1214d4[_0x3f08(0x55)])||_0x346cf9[_0x3f08(0x52)](_0x1214d4[_0x3f08(0x56)])||_0x346cf9['includes'](_0x1214d4[_0x3f08(0x57)])||_0x346cf9['includes'](_0x1214d4[_0x3f08(0x58)]);if(_0x3de713){if(_0x1214d4[_0x3f08(0x59)](_0x1214d4['GuymJ'],'KxiHl')){var _0x7dea7c,_0x2c217d,_0xe77ab;_0x4858aa[_0x3f08(0x37)](_0x3f08(0x5a),{'apiKeyId':_0x1214d4[_0x3f08(0x47)](_0x7dea7c=_0x360744[_0x3f08(0x39)],null)||_0x7dea7c===void 0x0?void 0x0:_0x7dea7c['id'],'appName':_0x1214d4[_0x3f08(0x47)](_0x2c217d=_0x1f40c9['application'],null)||_0x2c217d===void 0x0?void 0x0:_0x2c217d['name'],'usageCount':(_0xe77ab=_0x8e620b[_0x3f08(0x39)])===null||_0xe77ab===void 0x0?void 0x0:_0xe77ab[_0x3f08(0x5b)]});}else{const _0x591c0d=_0x3f08(0x5c)[_0x3f08(0x5d)]('|');let _0x40be51=0x0;while(!![]){switch(_0x591c0d[_0x40be51++]){case'0':console['warn'](_0x1214d4[_0x3f08(0x5e)]);continue;case'1':console['log'](_0x1214d4['NhIZE']);continue;case'2':console['warn'](_0x1214d4[_0x3f08(0x5f)]);continue;case'3':console['warn'](_0x1214d4[_0x3f08(0x60)]);continue;case'4':console[_0x3f08(0x1d)](_0x1214d4['HqKwf'],_0x5b5b88[_0x3f08(0x51)]);continue;}break;}}}else throw new Error(_0x3f08(0x61)+_0x5b5b88[_0x3f08(0x51)]);}await _0x1214d4[_0x3f08(0x62)](loadJWT),isInitialized=!![];if(globalConfig[_0x3f08(0x46)]){console[_0x3f08(0x37)](_0x3f08(0x63)),console[_0x3f08(0x37)](_0x3f08(0x64));if(userToken){if(_0x1214d4[_0x3f08(0x47)](_0x3f08(0x33),_0x1214d4[_0x3f08(0x65)]))console[_0x3f08(0x37)](_0x1214d4['aThdS']);else{var _0x4fb91b;if(!((_0x4fb91b=_0x20f31f)!==null&&_0x1214d4['yFkXQ'](_0x4fb91b,void 0x0)&&_0x4fb91b[_0x3f08(0x39)]))throw new _0x4da248(_0x3f08(0x66));const _0x43d282=_0x1214d4[_0x3f08(0x4f)](_0x699d44,_0x5ced62[_0x3f08(0x39)]);return{'Content-Type':'application/json','Authorization':'Bearer\x20'+_0x162f2b[_0x3f08(0x39)],'User-Agent':_0x1214d4[_0x3f08(0x67)],'X-SDK-Version':_0x1214d4[_0x3f08(0x68)],'X-SDK-Environment':_0x1abb6d[_0x3f08(0x69)]||_0x1214d4[_0x3f08(0x6a)],'X-API-Key-Type':_0x43d282,'X-Timestamp':new _0x5e43e0()['toISOString']()};}}_0x5b5b88[_0x3f08(0x6b)]&&console[_0x3f08(0x37)](_0x3f08(0x6c),_0x5b5b88[_0x3f08(0x6b)]);if(_0x5b5b88[_0x3f08(0x6d)]){if(_0x1214d4['hCwDp']!==_0x1214d4[_0x3f08(0x6e)])console[_0x3f08(0x37)](_0x1214d4['yDMcz'],_0x5b5b88[_0x3f08(0x6d)]);else throw new _0x25f741(_0x3f08(0x66));}}}catch(_0x34f401){if(_0x1214d4[_0x3f08(0x6f)](_0x3f08(0x70),_0x1214d4[_0x3f08(0x71)])){const _0x571bda=_0x1166a0['split']('.');if(_0x1214d4[_0x3f08(0x3e)](_0x571bda[_0x3f08(0x3b)],0x3))return _0x197e5b['error'](_0x1214d4[_0x3f08(0x72)]),null;const _0x11d1ba=_0x571bda[0x1],_0x187ced=_0x11d1ba[_0x3f08(0x73)](/-/g,'+')[_0x3f08(0x73)](/_/g,'/'),_0x905192=_0x187ced[_0x3f08(0x74)](_0x222450[_0x3f08(0x75)](_0x1214d4[_0x3f08(0x76)](_0x187ced[_0x3f08(0x3b)],0x4))*0x4,'='),_0x11530f=_0x1214d4[_0x3f08(0x4f)](_0x118b5c,_0x905192);return _0x2e45f1[_0x3f08(0x77)](_0x11530f);}else{console[_0x3f08(0x51)](_0x3f08(0x78),_0x34f401),isInitialized=![];throw _0x34f401;}}};exports[_0x3f08(0xa)]=initializeApiKey;const getApiKeyType=_0x3e293c=>{const _0x47590e={'XSnjJ':_0x3f08(0x79),'UOrNb':'ona_'};if(_0x3e293c[_0x3f08(0x3b)]>=0x20&&(_0x3e293c[_0x3f08(0x42)](_0x3f08(0x29))||_0x3e293c['startsWith'](_0x47590e['XSnjJ'])||_0x3e293c[_0x3f08(0x42)](_0x47590e[_0x3f08(0x7a)])))return ApiKeyType[_0x3f08(0x16)];return ApiKeyType[_0x3f08(0x15)];};exports['getApiKeyType']=getApiKeyType;const validateApiKey=async _0x51d66f=>{const _0x408394={'JrsTv':_0x3f08(0x7b),'gyWln':function(_0x185585,_0x327b40){return _0x185585(_0x327b40);},'iDDgs':function(_0x250f04,_0x533ab8){return _0x250f04===_0x533ab8;},'eAKwe':_0x3f08(0x7c),'mthNh':'⏱️\x20Request\x20timeout\x20for:','HVsMf':_0x3f08(0x7d),'QwDxs':_0x3f08(0x66),'qexek':'❌\x20Failed\x20to\x20store\x20JWT\x20token:','ajDqK':'Developer\x20API\x20key\x20is\x20required\x20for\x20SDK\x20initialization','OUFSZ':_0x3f08(0x7e),'bNQXl':_0x3f08(0x7f),'nxykv':_0x3f08(0x80),'EHLiJ':'🔍\x20Validating\x20developer\x20API\x20key\x20against\x20backend...','Jyrdo':function(_0x14ddc4,_0x5d525e){return _0x14ddc4(_0x5d525e);},'FNgLy':function(_0x2bbb65,_0x10b5c1){return _0x2bbb65<_0x10b5c1;},'MQwXu':function(_0x239f37,_0x2c2cb1){return _0x239f37-_0x2c2cb1;},'YmcBp':function(_0x56b160,_0x9219a5){return _0x56b160!==_0x9219a5;},'jjRUH':_0x3f08(0x81),'GyGHy':function(_0x467f91){return _0x467f91();},'SobdK':_0x3f08(0x82),'bNnVf':'No\x20network\x20connection\x20available.\x20Please\x20check\x20your\x20internet\x20connection\x20and\x20try\x20again.','vppZO':function(_0x543f1e,_0x524833){return _0x543f1e===_0x524833;},'cbPMy':_0x3f08(0x24),'EWpxV':function(_0x3e2916,_0x5370f6){return _0x3e2916===_0x5370f6;},'IuglZ':function(_0x460f05,_0x1158a1){return _0x460f05===_0x1158a1;},'BIwBm':function(_0x4e0bb1,_0x5e1ab9){return _0x4e0bb1<=_0x5e1ab9;},'AJWaG':function(_0x4625da,_0x167df5,_0x438f33){return _0x4625da(_0x167df5,_0x438f33);},'dJuIA':function(_0xd8d98b,_0x1b58d8){return _0xd8d98b>_0x1b58d8;},'jFhbC':_0x3f08(0x83),'CHtuz':_0x3f08(0x84),'qpOqm':function(_0x15a03a,_0x2f19e7){return _0x15a03a(_0x2f19e7);},'DAVSI':_0x3f08(0x85),'oNMcP':'Onairos\x20API\x20is\x20temporarily\x20unavailable\x20(502\x20Bad\x20Gateway).\x20Please\x20try\x20again\x20later.','WBAzR':_0x3f08(0x86),'WVWOF':function(_0x12103a,_0xa998bc){return _0x12103a!==_0xa998bc;},'KgLRD':_0x3f08(0x87),'pXZEM':_0x3f08(0x88),'Uwrcy':_0x3f08(0x89),'kVVUg':_0x3f08(0x8a),'wnpvY':function(_0x27a729,_0x1f992d){return _0x27a729===_0x1f992d;},'dbwAJ':_0x3f08(0x8b),'zjKrj':_0x3f08(0x8c),'PtzWL':function(_0x7a2ca2,_0x47b095){return _0x7a2ca2===_0x47b095;},'HFvCr':_0x3f08(0x8d),'kqpCn':_0x3f08(0x8e),'hcLCT':function(_0x3a42d1,_0x14417c){return _0x3a42d1||_0x14417c;},'tVBCI':'unknown\x20content\x20type','XuWfW':'❌\x20Failed\x20to\x20parse\x20JSON\x20response:','Doono':function(_0x8a6f9b,_0x137afe){return _0x8a6f9b!==_0x137afe;},'dyDHH':_0x3f08(0x8f),'jBWho':function(_0x13bd13,_0x37d393){return _0x13bd13!==_0x37d393;},'jYkwU':function(_0x516e1c,_0x1e11b2){return _0x516e1c===_0x1e11b2;},'tGzdd':function(_0xc7f797,_0x5f145e){return _0xc7f797===_0x5f145e;},'jVCzi':function(_0x1f3111,_0x49a850){return _0x1f3111===_0x49a850;},'tyDiF':function(_0x3f3b13,_0x5485bd){return _0x3f3b13!==_0x5485bd;},'XCgKY':'ltVNQ','jTCuR':function(_0x589b86,_0x73fb09){return _0x589b86>=_0x73fb09;},'MXolW':function(_0x106c4f,_0x41d0d8){return _0x106c4f!==_0x41d0d8;},'uBTRi':function(_0x22bb37,_0x473fe8){return _0x22bb37===_0x473fe8;},'ZpYDG':_0x3f08(0x90),'TRwiI':function(_0x1f9a20,_0x3eccdf){return _0x1f9a20===_0x3eccdf;},'oFLwS':_0x3f08(0x91),'VfRIa':_0x3f08(0x92),'oWKvB':_0x3f08(0x93),'KANXs':_0x3f08(0x94),'DfwdR':function(_0x2b00a8,_0x474362){return _0x2b00a8===_0x474362;},'AFVTL':_0x3f08(0x95),'Gyzcb':_0x3f08(0x96),'Dbvat':_0x3f08(0x2d),'VBQAR':_0x3f08(0x2e),'jbKuI':_0x3f08(0x97),'VQakz':_0x3f08(0x98),'wmRsV':function(_0x194f02,_0x3beb13){return _0x194f02===_0x3beb13;},'bNhhK':'YQosL','yVrQz':_0x3f08(0x99),'uaXcI':function(_0x5c2a32,_0x3e4496){return _0x5c2a32!==_0x3e4496;},'lRfLZ':_0x3f08(0x9a),'vFVmw':function(_0x3aded0,_0x1a83ad){return _0x3aded0*_0x1a83ad;},'Ibueb':function(_0x4ddf08,_0x35302b){return _0x4ddf08-_0x35302b;},'cQpfC':'gHbwG','nQSnC':_0x3f08(0x9b),'EPsDC':'❌\x20API\x20key\x20validation\x20error:'};try{var _0x499dfc,_0x2b1cff,_0x2478e6;console['log'](_0x408394['EHLiJ']);const _0x2bc579=_0x408394[_0x3f08(0x9c)](getApiKeyType,_0x51d66f);if(_0x408394[_0x3f08(0x9d)](_0x2bc579,ApiKeyType[_0x3f08(0x15)]))return{'isValid':![],'error':_0x3f08(0x9e),'keyType':ApiKeyType[_0x3f08(0x15)]};const _0x3e942f=validationCache['get'](_0x51d66f);if(_0x3e942f&&_0x408394[_0x3f08(0x9f)](_0x408394[_0x3f08(0xa0)](Date[_0x3f08(0xa1)](),_0x3e942f[_0x3f08(0xa2)]),CACHE_DURATION)){var _0x3c3a2d;return(_0x3c3a2d=globalConfig)!==null&&_0x408394[_0x3f08(0xa3)](_0x3c3a2d,void 0x0)&&_0x3c3a2d[_0x3f08(0x46)]&&console[_0x3f08(0x37)](_0x408394[_0x3f08(0xa4)]),_0x3e942f[_0x3f08(0xa5)];}const _0x1acb54=await _0x408394[_0x3f08(0xa6)](checkNetworkConnectivity);if(!_0x1acb54)return console[_0x3f08(0x1d)](_0x408394[_0x3f08(0xa7)]),{'isValid':![],'error':_0x408394['bNnVf'],'keyType':_0x2bc579,'isNetworkError':!![]};const _0x70cca0=(_0x408394['vppZO'](_0x499dfc=globalConfig,null)||_0x408394['iDDgs'](_0x499dfc,void 0x0)?void 0x0:_0x499dfc[_0x3f08(0x69)])||_0x408394['cbPMy'],_0x26370e=API_ENDPOINTS[_0x70cca0],_0xfd36f0=(_0x408394[_0x3f08(0x9d)](_0x2b1cff=globalConfig,null)||_0x408394['EWpxV'](_0x2b1cff,void 0x0)?void 0x0:_0x2b1cff[_0x3f08(0x44)])||0x7530,_0x526c4e=((_0x2478e6=globalConfig)===null||_0x408394['IuglZ'](_0x2478e6,void 0x0)?void 0x0:_0x2478e6[_0x3f08(0x45)])||0x3;for(let _0x34d907=0x1;_0x408394[_0x3f08(0xa8)](_0x34d907,_0x526c4e);_0x34d907++){const _0xa02a55=new AbortController(),_0x48b9ea=_0x408394[_0x3f08(0xa9)](setTimeout,()=>_0xa02a55['abort'](),_0xfd36f0);try{var _0x21a40c;(_0x21a40c=globalConfig)!==null&&_0x21a40c!==void 0x0&&_0x21a40c[_0x3f08(0x46)]&&_0x408394['dJuIA'](_0x34d907,0x1)&&console[_0x3f08(0x37)](_0x3f08(0xaa)+_0x34d907+'/'+_0x526c4e+'\x20for\x20API\x20key\x20validation');const _0xc1efdb=await fetch(_0x26370e+_0x3f08(0xab),{'method':'POST','headers':{'Content-Type':'application/json','Authorization':_0x3f08(0xac)+_0x51d66f,'User-Agent':_0x408394[_0x3f08(0xad)],'X-API-Key-Type':_0x2bc579,'X-SDK-Platform':'react-native','X-Retry-Attempt':_0x34d907[_0x3f08(0xae)]()},'body':JSON['stringify']({'environment':_0x70cca0,'sdk_version':_0x408394['CHtuz'],'platform':'react-native','keyType':_0x2bc579,'timestamp':new Date()[_0x3f08(0xaf)](),'attempt':_0x34d907}),'signal':_0xa02a55[_0x3f08(0xb0)]});_0x408394[_0x3f08(0xb1)](clearTimeout,_0x48b9ea);if(!_0xc1efdb)throw new Error(_0x408394['DAVSI']);if(_0xc1efdb[_0x3f08(0xb2)]===0x1f6)throw new Error(_0x408394['oNMcP']);if(_0x408394[_0x3f08(0xb3)](_0xc1efdb[_0x3f08(0xb2)],0x1f7))throw new Error(_0x408394['WBAzR']);if(_0x408394[_0x3f08(0x9d)](_0xc1efdb[_0x3f08(0xb2)],0x1f8)){if(_0x408394[_0x3f08(0xb4)](_0x408394[_0x3f08(0xb5)],_0x408394[_0x3f08(0xb5)])){var _0x277122;return(_0x277122=_0x198e75)!==null&&_0x277122!==void 0x0&&_0x277122[_0x3f08(0x46)]&&_0x462107[_0x3f08(0x51)](_0x408394['JrsTv'],_0x209324),_0x2e5539;}else throw new Error(_0x408394[_0x3f08(0xb6)]);}const _0x16525e=_0xc1efdb['headers']['get'](_0x408394[_0x3f08(0xb7)]),_0x570c22=_0x16525e&&_0x16525e[_0x3f08(0x52)]('application/json');if(!_0x570c22){const _0x224335=await _0xc1efdb[_0x3f08(0xb8)](),_0x225221=_0x224335[_0x3f08(0x4d)](0x0,0xc8);console[_0x3f08(0x51)](_0x408394['kVVUg'],{'status':_0xc1efdb['status'],'statusText':_0xc1efdb[_0x3f08(0xb9)],'contentType':_0x16525e||_0x3f08(0xba),'preview':_0x225221,'url':_0x26370e+_0x3f08(0xab),'attempt':_0x34d907});if(_0x408394[_0x3f08(0xb3)](_0xc1efdb[_0x3f08(0xb2)],0x194)){if(_0x408394[_0x3f08(0xbb)](_0x408394[_0x3f08(0xbc)],_0x408394[_0x3f08(0xbd)])){_0x408394[_0x3f08(0xbe)](_0x306981,_0x2c0f87);if(_0x408394[_0x3f08(0x9d)](_0x485ed0['name'],_0x408394[_0x3f08(0xbf)])){_0x517bf5[_0x3f08(0x51)](_0x408394[_0x3f08(0xc0)],_0x43e8bd);throw new _0x20cb9a(_0x408394[_0x3f08(0xc1)]);}throw _0x298d61;}else throw new Error(_0x3f08(0xc2)+_0x26370e+'/dev/validate-apikey\x20may\x20not\x20exist\x20or\x20be\x20configured\x20correctly.');}else{if(_0x408394[_0x3f08(0xc3)](_0xc1efdb[_0x3f08(0xb2)],0x1f4))throw new Error('Server\x20error\x20(500).\x20The\x20Onairos\x20backend\x20is\x20experiencing\x20issues.');else{if(_0xc1efdb[_0x3f08(0xb2)]===0x1f6||_0xc1efdb[_0x3f08(0xb2)]===0x1f7)throw new Error(_0x3f08(0xc4)+_0xc1efdb[_0x3f08(0xb2)]+_0x3f08(0xc5));else{if(_0x224335['includes'](_0x408394[_0x3f08(0xc6)])||_0x224335['includes'](_0x408394[_0x3f08(0xc7)]))throw new Error(_0x3f08(0xc8));else throw new Error('API\x20validation\x20endpoint\x20returned\x20'+_0xc1efdb[_0x3f08(0xb2)]+_0x3f08(0xc9)+_0xc1efdb[_0x3f08(0xb9)]+_0x3f08(0xca)+_0x408394[_0x3f08(0xcb)](_0x16525e,_0x408394['tVBCI'])+'.');}}}}let _0x319f30;try{_0x319f30=await _0xc1efdb[_0x3f08(0xcc)]();}catch(_0x2c9260){console[_0x3f08(0x51)](_0x408394[_0x3f08(0xcd)],{'error':_0x2c9260[_0x3f08(0xce)],'status':_0xc1efdb[_0x3f08(0xb2)],'contentType':_0x16525e,'attempt':_0x34d907});throw new Error(_0x3f08(0xcf)+_0x2c9260[_0x3f08(0xce)]);}if(_0xc1efdb['ok']&&(_0x319f30['success']||_0x319f30['valid'])){if(_0x408394[_0x3f08(0xd0)](_0x3f08(0x8f),_0x408394[_0x3f08(0xd1)]))throw new _0x190368(_0x408394['QwDxs']);else{var _0x32df09;const _0x1bf022={'isValid':!![],'permissions':_0x319f30[_0x3f08(0x6b)]||[],'rateLimits':_0x319f30[_0x3f08(0x6d)]||null,'keyType':_0x2bc579};validationCache[_0x3f08(0xd2)](_0x51d66f,{'result':_0x1bf022,'timestamp':Date[_0x3f08(0xa1)]()});if((_0x32df09=globalConfig)!==null&&_0x408394[_0x3f08(0xd3)](_0x32df09,void 0x0)&&_0x32df09[_0x3f08(0x46)]){var _0x3c30ac,_0x31479e,_0x3f0aa1;console[_0x3f08(0x37)](_0x3f08(0x5a),{'apiKeyId':_0x408394[_0x3f08(0xd4)](_0x3c30ac=_0x319f30[_0x3f08(0x39)],null)||_0x408394[_0x3f08(0xd5)](_0x3c30ac,void 0x0)?void 0x0:_0x3c30ac['id'],'appName':_0x408394['tGzdd'](_0x31479e=_0x319f30[_0x3f08(0xd6)],null)||_0x31479e===void 0x0?void 0x0:_0x31479e[_0x3f08(0xd7)],'usageCount':_0x408394[_0x3f08(0xd8)](_0x3f0aa1=_0x319f30[_0x3f08(0x39)],null)||_0x408394['jVCzi'](_0x3f0aa1,void 0x0)?void 0x0:_0x3f0aa1['usageCount']});}return _0x1bf022;}}else{if(_0x408394[_0x3f08(0xd9)](_0x408394['XCgKY'],_0x3f08(0xda))){const _0x561b07=_0x319f30[_0x3f08(0x51)]||_0x319f30['message']||_0x3f08(0xdb)+_0xc1efdb[_0x3f08(0xb2)]+':\x20'+_0xc1efdb[_0x3f08(0xb9)],_0x935c30={'isValid':![],'error':_0x561b07,'keyType':_0x2bc579};if(_0x408394['jTCuR'](_0xc1efdb[_0x3f08(0xb2)],0x190)&&_0x408394[_0x3f08(0x9f)](_0xc1efdb[_0x3f08(0xb2)],0x1f4)){var _0x23d745;if(_0x408394[_0x3f08(0xd3)](_0x23d745=globalConfig,null)&&_0x408394['MXolW'](_0x23d745,void 0x0)&&_0x23d745[_0x3f08(0x46)]){if(_0x408394[_0x3f08(0xdc)](_0x408394[_0x3f08(0xdd)],_0x408394[_0x3f08(0xdd)]))console[_0x3f08(0x51)](_0x3f08(0x7b),_0x561b07);else{_0x124ac2[_0x3f08(0x51)](_0x408394[_0x3f08(0xc0)],_0x2e9288);throw new _0x26148b(_0x408394[_0x3f08(0xc1)]);}}return _0x935c30;}throw new Error(_0x561b07);}else throw new _0xc7d82e('SDK\x20not\x20initialized.\x20Call\x20initializeApiKey()\x20first.');}}catch(_0x115ba8){var _0x454542;clearTimeout(_0x48b9ea);if(_0x408394[_0x3f08(0xde)](_0x115ba8['name'],_0x408394['eAKwe'])){const _0x2ac6b1='API\x20key\x20validation\x20timeout\x20('+_0xfd36f0+'ms)';console[_0x3f08(0x51)](_0x408394['oFLwS']);if(_0x408394[_0x3f08(0xdc)](_0x34d907,_0x526c4e)){if(_0x408394['PtzWL'](_0x408394['VfRIa'],_0x408394[_0x3f08(0xdf)])){_0x551173[_0x3f08(0x51)](_0x408394[_0x3f08(0xe0)],_0x4b83ef);throw _0x120ff1;}else return{'isValid':![],'error':_0x2ac6b1,'keyType':_0x2bc579};}continue;}let _0x2d7fb6=_0x3f08(0xe1)+_0x115ba8[_0x3f08(0xce)];if(_0x115ba8['message'][_0x3f08(0x52)](_0x3f08(0xe2))||_0x115ba8[_0x3f08(0xce)][_0x3f08(0x52)](_0x408394[_0x3f08(0xe3)])){if(_0x408394[_0x3f08(0xe4)](_0x408394[_0x3f08(0xe5)],_0x408394[_0x3f08(0xe6)]))throw new _0x4e059b(_0x3f08(0xc2)+_0x3a5465+'/dev/validate-apikey\x20may\x20not\x20exist\x20or\x20be\x20configured\x20correctly.');else _0x2d7fb6='Server\x20returned\x20invalid\x20JSON\x20response.\x20This\x20usually\x20indicates\x20the\x20API\x20endpoint\x20returned\x20HTML\x20instead\x20of\x20JSON\x20(often\x20a\x20404\x20or\x20server\x20error\x20page).\x20'+_0x115ba8[_0x3f08(0xce)];}else{if(_0x115ba8[_0x3f08(0xce)][_0x3f08(0x52)](_0x408394[_0x3f08(0xe7)])||_0x115ba8[_0x3f08(0xce)][_0x3f08(0x52)](_0x408394['VBQAR']))_0x2d7fb6=_0x3f08(0xe8)+_0x115ba8[_0x3f08(0xce)];else{if(_0x115ba8[_0x3f08(0xce)][_0x3f08(0x52)](_0x408394[_0x3f08(0xe9)])||_0x115ba8[_0x3f08(0xce)][_0x3f08(0x52)](_0x408394[_0x3f08(0xea)])){if(_0x408394[_0x3f08(0xeb)]('YQosL',_0x408394['bNhhK']))_0x2d7fb6=_0x3f08(0xec)+_0x26370e+'.\x20Please\x20check\x20network\x20settings\x20and\x20domain\x20accessibility.\x20'+_0x115ba8[_0x3f08(0xce)];else throw new _0xed9b21(_0x408394[_0x3f08(0xed)]);}}}console['error'](_0x408394[_0x3f08(0xee)],{'error':_0x115ba8,'endpoint':_0x26370e+_0x3f08(0xab),'attempt':_0x34d907,'maxRetries':_0x526c4e,'retryable':_0x34d907<_0x526c4e});if(_0x408394[_0x3f08(0xe4)](_0x34d907,_0x526c4e))return _0x408394[_0x3f08(0xef)](_0x408394['lRfLZ'],_0x408394[_0x3f08(0xf0)])?(_0x5c8ac0[_0x3f08(0x51)](_0x408394[_0x3f08(0xf1)],_0x3d7740),null):{'isValid':![],'error':_0x2d7fb6,'keyType':_0x2bc579,'isNetworkError':!![]};const _0x4b1d69=Math[_0x3f08(0xf2)](_0x408394[_0x3f08(0xf3)](0x3e8,Math[_0x3f08(0xf4)](0x2,_0x408394[_0x3f08(0xf5)](_0x34d907,0x1))),0x1388);if((_0x454542=globalConfig)!==null&&_0x454542!==void 0x0&&_0x454542['enableLogging']){if('cwdTp'!==_0x408394[_0x3f08(0xf6)])console['log'](_0x3f08(0xf7)+_0x4b1d69+'ms\x20before\x20retry...');else{_0x59b631[_0x3f08(0x51)](_0x408394[_0x3f08(0xf8)]);throw new _0x4e0ff9(_0x408394[_0x3f08(0xf9)]);}}await new Promise(_0xb7f01a=>setTimeout(()=>_0xb7f01a(),_0x4b1d69));}}return{'isValid':![],'error':_0x408394[_0x3f08(0xfa)],'keyType':_0x2bc579};}catch(_0x53bf10){const _0x1750fc=_0x3f08(0xfb)+_0x53bf10['message'];return console[_0x3f08(0x51)](_0x408394[_0x3f08(0xfc)],_0x53bf10),{'isValid':![],'error':_0x1750fc,'keyType':ApiKeyType['INVALID']};}};exports[_0x3f08(0x2)]=validateApiKey;const getApiConfig=()=>{return globalConfig;};exports['getApiConfig']=getApiConfig;const getApiKey=()=>{const _0x4e84a4={'umltX':function(_0x489097,_0x404d89){return _0x489097===_0x404d89;},'XxhxQ':function(_0x37beec,_0x1cae0c){return _0x37beec===_0x1cae0c;}};var _0x9e2ae2;return(_0x4e84a4['umltX'](_0x9e2ae2=globalConfig,null)||_0x4e84a4[_0x3f08(0xfd)](_0x9e2ae2,void 0x0)?void 0x0:_0x9e2ae2[_0x3f08(0x39)])||null;};exports[_0x3f08(0xfe)]=getApiKey;const isApiKeyInitialized=()=>{return isInitialized&&globalConfig!==null;};exports[_0x3f08(0x9)]=isApiKeyInitialized;function _0x3f08(_0x147d1d,_0x3f08ae){_0x147d1d=_0x147d1d-0x0;const _0x2a1a90=_0x147d();let _0x3071c8=_0x2a1a90[_0x147d1d];return _0x3071c8;}const storeJWT=async _0x570e91=>{const _0xa3f417={'Ygtaa':'User\x20not\x20authenticated.\x20Please\x20verify\x20email\x20first.','grJjF':function(_0x7295c0,_0x1bca67){return _0x7295c0!==_0x1bca67;},'lOghj':_0x3f08(0xff),'okdyP':_0x3f08(0x100),'dWvmL':_0x3f08(0x101),'eSuRJ':_0x3f08(0x102)};try{var _0x353ab6;await _asyncStorage['default'][_0x3f08(0x103)](JWT_TOKEN_KEY,_0x570e91),userToken=_0x570e91;if((_0x353ab6=globalConfig)!==null&&_0xa3f417['grJjF'](_0x353ab6,void 0x0)&&_0x353ab6[_0x3f08(0x46)]){if(_0xa3f417[_0x3f08(0x104)](_0x3f08(0x105),_0xa3f417[_0x3f08(0x106)]))console['log'](_0xa3f417['okdyP']);else throw new _0x5d02ba(_0xa3f417[_0x3f08(0x107)]);}}catch(_0x516691){if(_0xa3f417[_0x3f08(0x108)]!==_0xa3f417['dWvmL']){_0x123e22[_0x3f08(0x51)](_0x3f08(0x109),_0x288a1b);throw new _0x8f314c(_0x3f08(0x7d));}else{console[_0x3f08(0x51)](_0xa3f417[_0x3f08(0x10a)],_0x516691);throw _0x516691;}}};exports[_0x3f08(0x3)]=storeJWT;const loadJWT=async()=>{const _0x3f703a={'bamvb':function(_0x5b5470,_0xe36261){return _0x5b5470||_0xe36261;},'HAWmQ':_0x3f08(0x10b),'cNmcS':function(_0x3dd1fd,_0xbffc0){return _0x3dd1fd(_0xbffc0);},'tKbtG':function(_0x4e21ab,_0x3f1295){return _0x4e21ab!==_0x3f1295;},'Pdbzr':'👤\x20Extracted\x20user\x20data\x20from\x20JWT:','cNXtm':function(_0x277dcf,_0x4442b3){return _0x277dcf===_0x4442b3;},'sIWbm':'SyGmO','PGCHQ':_0x3f08(0x10c)};try{const _0x31e093=await _asyncStorage['default']['getItem'](JWT_TOKEN_KEY);return userToken=_0x31e093,_0x31e093;}catch(_0x4a3437){if(_0x3f703a[_0x3f08(0x10d)](_0x3f703a[_0x3f08(0x10e)],_0x3f08(0x10f))){var _0x4a65da;const _0x497acc=_0x3f703a[_0x3f08(0x110)](_0x584e92,_0x309520);if(!_0x497acc)return _0x295b7a['warn'](_0x3f703a[_0x3f08(0x111)]),null;const _0x1b67a7=_0x3f703a[_0x3f08(0x112)](_0x47853e,_0x497acc);if(!_0x1b67a7)return null;const _0x2d26c8={'id':_0x1b67a7['id'],'email':_0x1b67a7[_0x3f08(0x113)],'userId':_0x1b67a7['userId'],'userName':_0x1b67a7[_0x3f08(0x114)]||_0x1b67a7[_0x3f08(0x115)],'verified':_0x1b67a7[_0x3f08(0x116)],'iat':_0x1b67a7[_0x3f08(0x117)],'exp':_0x1b67a7[_0x3f08(0x118)]};return _0x3f703a[_0x3f08(0x119)](_0x4a65da=_0x116751,null)&&_0x3f703a[_0x3f08(0x119)](_0x4a65da,void 0x0)&&_0x4a65da[_0x3f08(0x46)]&&_0x5e82aa[_0x3f08(0x37)](_0x3f703a[_0x3f08(0x11a)],_0x2d26c8),_0x2d26c8;}else return console[_0x3f08(0x51)](_0x3f703a[_0x3f08(0x11b)],_0x4a3437),null;}};exports[_0x3f08(0x7)]=loadJWT;const getJWT=()=>{return userToken;};exports['getJWT']=getJWT;const clearJWT=async()=>{const _0x5a74e8={'ycNsk':function(_0x12a8bf,_0x30833a){return _0x12a8bf!==_0x30833a;},'UdFGH':'🗑️\x20JWT\x20token\x20cleared','YQOrD':function(_0x4f23b1,_0x1a0962){return _0x4f23b1===_0x1a0962;},'vPwCK':_0x3f08(0x11c)};try{var _0x4db9c4;await _asyncStorage[_0x3f08(0x11d)][_0x3f08(0x11e)](JWT_TOKEN_KEY),userToken=null,(_0x4db9c4=globalConfig)!==null&&_0x5a74e8[_0x3f08(0x11f)](_0x4db9c4,void 0x0)&&_0x4db9c4[_0x3f08(0x46)]&&console[_0x3f08(0x37)](_0x5a74e8[_0x3f08(0x120)]);}catch(_0xcd95dc){_0x5a74e8['YQOrD'](_0x5a74e8[_0x3f08(0x121)],_0x5a74e8['vPwCK'])?console['error']('❌\x20Failed\x20to\x20clear\x20JWT\x20token:',_0xcd95dc):_0x24e191[_0x3f08(0x37)](_0x3f08(0x122)+_0x3cb957);}};function _0x147d(){const _0x30e7be=['defineProperty','__esModule','validateApiKey','storeJWT','resetApiKeyService','makeDeveloperRequest','makeAuthenticatedRequest','loadJWT','isUserAuthenticated','isApiKeyInitialized','initializeApiKey','getJWT','getDeveloperAuthHeaders','getAuthHeaders','getApiKeyType','getApiConfig','extractUsernameFromJWT','extractUserDataFromJWT','clearValidationCache','clearJWT','ApiKeyType','INVALID','DEVELOPER','nZeGt','invalid','onairos_jwt_token','MTvdf','DbsIz','isInternetReachable','warn','⚠️\x20Failed\x20to\x20check\x20network\x20connectivity:','API_CONFIG','BASE_URL','🎫\x20User\x20JWT\x20token\x20loaded\x20from\x20storage','OnairosSDK/1.0.0','3.0.72','production','❌\x20Invalid\x20JWT\x20token\x20format','Developer\x20API\x20key\x20is\x20required\x20for\x20SDK\x20initialization','iugmG','IDiec','dev_','Invalid\x20API\x20key\x20format.\x20Developer\x20keys\x20must\x20start\x20with\x20dev_,\x20ona_,\x20or\x20pk_','📝\x20SDK\x20Configuration:','...','Network\x20request\x20failed','fetch','⚠️\x20API\x20key\x20validation\x20failed\x20due\x20to\x20network/connectivity\x20issues','📝\x20SDK\x20will\x20function\x20with\x20limited\x20validation.\x20Network\x20connectivity\x20will\x20be\x20retried\x20automatically.','🔄\x20Continuing\x20in\x20offline\x20mode\x20with\x20basic\x20validation','🌐\x20Error\x20details:','jVuFI','VzyFe','SAoVG','⏱️\x20Rate\x20Limits:','log','🔑\x20Initializing\x20Onairos\x20SDK\x20with\x20developer\x20API\x20key...','apiKey','Uhebu','length','tglmL','LeRUZ','BTEbg','duCpt','ona_','some','startsWith','PuQVb','timeout','retryAttempts','enableLogging','nBWvB','dKTPa','ZzZZU','aThdS','mxMNG','FYPDe','substring','XIDsf','GquqI','isValid','error','includes','iwzym','FTDDD','fZOsl','SEWyH','Nkkwp','cqxmM','YrTZw','✅\x20API\x20key\x20validation\x20successful','usageCount','0|3|2|4|1','split','uqrqk','kATLZ','oWxSv','API\x20key\x20validation\x20failed:\x20','BEMAa','✅\x20Onairos\x20SDK\x20initialized\x20successfully','🔑\x20Developer\x20API\x20key\x20ready\x20for\x20app-level\x20operations','YyXZa','SDK\x20not\x20initialized.\x20Call\x20initializeApiKey()\x20first.','zcSQD','HcrjA','environment','WZgdM','permissions','🔐\x20API\x20Key\x20Permissions:','rateLimits','qosWr','VMHws','uYacO','mDqrC','CQEcT','replace','padEnd','ceil','ievel','parse','❌\x20Failed\x20to\x20initialize\x20Onairos\x20SDK:','pk_','UOrNb','❌\x20API\x20key\x20validation\x20failed\x20(client\x20error):','AbortError','Request\x20timeout','❌\x20Failed\x20to\x20extract\x20user\x20data\x20from\x20JWT:','❌\x20API\x20key\x20permissions\x20insufficient\x20for\x20this\x20operation.','Insufficient\x20API\x20key\x20permissions','📋\x20Using\x20cached\x20API\x20key\x20validation\x20result','⚠️\x20No\x20network\x20connectivity\x20detected','OnairosReactNative/3.3.1','3.3.1','No\x20response\x20received\x20from\x20server','Onairos\x20API\x20is\x20under\x20maintenance\x20(503\x20Service\x20Unavailable).\x20Please\x20try\x20again\x20later.','TCCSm','Onairos\x20API\x20request\x20timed\x20out\x20(504\x20Gateway\x20Timeout).\x20Please\x20try\x20again.','content-type','❌\x20API\x20endpoint\x20returned\x20non-JSON\x20response:','ITXbf','kmdAN','<html','<!DOCTYPE','KqIPF','hNcZS','⏱️\x20API\x20key\x20validation\x20timeout','WVzdS','gUqea','Unexpected\x20character','TguJM','oVpCZ','DNS','ENOTFOUND','🌐\x20Network\x20error\x20during\x20API\x20key\x20validation:','uCPEd','All\x20retry\x20attempts\x20exhausted','Jyrdo','iDDgs','Invalid\x20API\x20key\x20format.\x20Developer\x20keys\x20must\x20be\x20at\x20least\x2032\x20characters\x20and\x20start\x20with\x20\x22dev_\x22,\x20\x22pk_\x22,\x20or\x20\x22ona_\x22','FNgLy','MQwXu','now','timestamp','YmcBp','jjRUH','result','GyGHy','SobdK','BIwBm','AJWaG','🔄\x20Retry\x20attempt\x20','/dev/validate-apikey','Bearer\x20','jFhbC','toString','toISOString','signal','qpOqm','status','IuglZ','WVWOF','KgLRD','pXZEM','Uwrcy','text','statusText','unknown','wnpvY','dbwAJ','zjKrj','gyWln','eAKwe','mthNh','HVsMf','API\x20validation\x20endpoint\x20not\x20found\x20(404).\x20The\x20endpoint\x20','PtzWL','Service\x20unavailable\x20(',').\x20The\x20Onairos\x20backend\x20may\x20be\x20temporarily\x20down.','HFvCr','kqpCn','Server\x20returned\x20HTML\x20page\x20instead\x20of\x20JSON\x20API\x20response.\x20This\x20often\x20indicates\x20a\x20routing\x20issue\x20or\x20server\x20misconfiguration.','\x20-\x20','.\x20Expected\x20JSON\x20but\x20got\x20','hcLCT','json','XuWfW','message','Failed\x20to\x20parse\x20server\x20response\x20as\x20JSON:\x20','Doono','dyDHH','set','jBWho','EWpxV','jYkwU','application','name','tGzdd','tyDiF','TZglW','HTTP\x20','uBTRi','ZpYDG','TRwiI','oWKvB','qexek','Network\x20error\x20during\x20API\x20key\x20validation:\x20','JSON\x20Parse\x20error','KANXs','DfwdR','AFVTL','Gyzcb','Dbvat','Network\x20connectivity\x20issue.\x20Please\x20check\x20internet\x20connection\x20and\x20verify\x20the\x20Onairos\x20API\x20is\x20accessible.\x20','jbKuI','VQakz','wmRsV','DNS\x20resolution\x20failed\x20for\x20','ajDqK','yVrQz','uaXcI','lRfLZ','OUFSZ','min','vFVmw','pow','Ibueb','cQpfC','⏳\x20Waiting\x20','bNQXl','nxykv','nQSnC','API\x20key\x20validation\x20error:\x20','EPsDC','XxhxQ','getApiKey','WJcxm','🎫\x20JWT\x20token\x20stored\x20successfully','vCoYh','❌\x20Failed\x20to\x20store\x20JWT\x20token:','setItem','grJjF','lXZcA','lOghj','Ygtaa','dWvmL','⏱️\x20Request\x20timeout\x20for:','eSuRJ','⚠️\x20No\x20JWT\x20token\x20available\x20for\x20user\x20data\x20extraction','❌\x20Failed\x20to\x20load\x20JWT\x20token:','cNXtm','sIWbm','ZPxHu','bamvb','HAWmQ','cNmcS','email','userName','username','verified','iat','exp','tKbtG','Pdbzr','PGCHQ','rEWsE','default','removeItem','ycNsk','UdFGH','vPwCK','🌐\x20Making\x20user\x20request\x20to:\x20','ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/','yLfKL','indexOf','charAt','OXgJx','fromCharCode','vJgym','tOHFp','bCYTf','SaDeK','❌\x20Failed\x20to\x20decode\x20JWT\x20token:','ogRMZ','xzXYg','jpYzh','XpKNu','apxXf','wbllR','BYOTc','ZDBbp','zETrB','decodeJWTPayload','fpCqb','⚠️\x20No\x20JWT\x20token\x20available\x20for\x20username\x20extraction','👤\x20Extracted\x20username\x20from\x20JWT:','jAqLC','xjhZf','dgvTb','yljpz','LGcdR','iPRzR','WAydZ','gPMpp','GUykh','Onairos\x20API\x20is\x20temporarily\x20unavailable\x20(502\x20Bad\x20Gateway).\x20Please\x20try\x20again\x20later.','❌\x20Failed\x20to\x20extract\x20username\x20from\x20JWT:','unknown\x20content\x20type','❌\x20API\x20key\x20validation\x20error:','❌\x20API\x20rate\x20limit\x20exceeded.\x20Please\x20try\x20again\x20later.','Rate\x20limit\x20exceeded','qYDLv','MYcof','iNTYU','👤\x20Extracted\x20user\x20data\x20from\x20JWT:','QelqU','OIrSt','cKHRG','RCgoG','MQvCk','LLDjf','API\x20validation\x20endpoint\x20returned\x20','WypYs','RBVuz','nlulQ','userId','FpSgh','eJoZs','rgYfK','ZdJhA','QGzGJ','sdrmK','unDGg','IWKCH','pQtrR','YKBtg','OnairosReactNative/3.0.72','sUCsG','plMSu','BBtFX','Bcryp','pPpSy','lDVER','hcyDw','QtLpk','Ywmun','SZGIK','wfjdG','iyauF','GdlFr','GFavY','User\x20not\x20authenticated.\x20Please\x20verify\x20email\x20first.','IryKr','gBbfX','rcMgF','dcxjY','dotxk','getUserAuthHeaders','RjZIM','Invalid\x20or\x20expired\x20API\x20key','nVllv','FuCjv','ohDjP','fXnWt','iaQio','kQayj','headers','eoSbP','🌐\x20Making\x20authenticated\x20request\x20to:\x20','dRGDA','oMqnS','iRxEb','📡\x20Response\x20status:\x20','\x20for\x20','❌\x20API\x20key\x20authentication\x20failed.\x20Please\x20check\x20your\x20API\x20key.','KtHyf','EUQbE','GUUDs','BQfLJ','dfdMq','nFkju','PKvCx','ebZiq','brSRY','IwEKq','ztCmN','WNPSy','qEkKv','bxPDq','❌\x20Developer\x20API\x20key\x20authentication\x20failed','❌\x20Developer\x20API\x20key\x20permissions\x20insufficient','❌\x20API\x20rate\x20limit\x20exceeded','mQDaz','pqFFW','DfTWn','wUeRa','xOSPG','EajMn','LOAQG','aKsuP','duwPb','🌐\x20Making\x20developer\x20request\x20to:\x20','UlHbL','📡\x20Developer\x20request\x20response:\x20','PwUbc','GSngC','vlgGK','UTsIH','QSBjV','huNLD','BJPCJ','PsVpK','IcEfJ','ljTCd','VpEMo','iFVac','❌\x20JWT\x20token\x20authentication\x20failed\x20-\x20token\x20may\x20be\x20expired','nyata','❌\x20JWT\x20token\x20permissions\x20insufficient','Insufficient\x20permissions\x20for\x20this\x20operation','dPuUK','xFgiG','zKOxn','Server\x20error\x20(500).\x20The\x20Onairos\x20backend\x20is\x20experiencing\x20issues.','KayAF','phhAf','YplLy','AXSZj','abort','gPUfO','lXIIk','xdUwd','📡\x20User\x20request\x20response:\x20','nbOPj','wxbKn','csJrx','PquRt','ATOtw','xmzdP','djfUz','XOgDV','OPdpp','DNAjU','pWWyL','VXigR','MdmWW','jyVdl','qdLhH','makeUserRequest','clear','uUfEj','🔄\x20API\x20key\x20service\x20reset','GGyGD'];_0x147d=function(){return _0x30e7be;};return _0x147d();}exports[_0x3f08(0x13)]=clearJWT;const base64Decode=_0x503ed6=>{const _0xb3cf1e={'yLfKL':_0x3f08(0x123),'OXgJx':function(_0xb15672,_0x3d06f2){return _0xb15672<<_0x3d06f2;},'rtlVu':function(_0x89c8d0,_0x5ebd51){return _0x89c8d0&_0x5ebd51;},'bCYTf':function(_0x42e84b,_0x243fb7){return _0x42e84b>>_0x243fb7;},'vJgym':function(_0x28aa8b,_0x379caa){return _0x28aa8b!==_0x379caa;},'tOHFp':function(_0x7c0f89,_0x3d8207){return _0x7c0f89&_0x3d8207;},'NzZTR':function(_0x4413ee,_0x4229d3){return _0x4413ee!==_0x4229d3;},'SaDeK':function(_0x148c88,_0x923772){return _0x148c88&_0x923772;}},_0x1a2f3b=_0xb3cf1e[_0x3f08(0x124)];let _0x537b85='',_0x533e26=0x0;_0x503ed6=_0x503ed6[_0x3f08(0x73)](/[^A-Za-z0-9+/]/g,'');while(_0x533e26<_0x503ed6[_0x3f08(0x3b)]){const _0x51fac5=_0x1a2f3b[_0x3f08(0x125)](_0x503ed6[_0x3f08(0x126)](_0x533e26++)),_0x2aa356=_0x1a2f3b[_0x3f08(0x125)](_0x503ed6[_0x3f08(0x126)](_0x533e26++)),_0x3a30c6=_0x1a2f3b['indexOf'](_0x503ed6['charAt'](_0x533e26++)),_0xb83500=_0x1a2f3b[_0x3f08(0x125)](_0x503ed6[_0x3f08(0x126)](_0x533e26++)),_0x228bb6=_0x51fac5<<0x12|_0xb3cf1e[_0x3f08(0x127)](_0x2aa356,0xc)|_0xb3cf1e[_0x3f08(0x127)](_0x3a30c6,0x6)|_0xb83500;_0x537b85+=String[_0x3f08(0x128)](_0xb3cf1e['rtlVu'](_0xb3cf1e['bCYTf'](_0x228bb6,0x10),0xff));if(_0xb3cf1e[_0x3f08(0x129)](_0x3a30c6,0x40))_0x537b85+=String[_0x3f08(0x128)](_0xb3cf1e[_0x3f08(0x12a)](_0xb3cf1e[_0x3f08(0x12b)](_0x228bb6,0x8),0xff));if(_0xb3cf1e['NzZTR'](_0xb83500,0x40))_0x537b85+=String[_0x3f08(0x128)](_0xb3cf1e[_0x3f08(0x12c)](_0x228bb6,0xff));}return _0x537b85;},decodeJWTPayload=_0x2644db=>{const _0x954c47={'ZDBbp':function(_0x1923fb,_0x3e7c47){return _0x1923fb!==_0x3e7c47;},'xzXYg':_0x3f08(0x25),'jpYzh':function(_0x9e3808,_0x33f677){return _0x9e3808*_0x33f677;},'zETrB':function(_0x1a17b5,_0x1cbde2){return _0x1a17b5/_0x1cbde2;},'XpKNu':function(_0x8a1ce3,_0x123ead){return _0x8a1ce3(_0x123ead);},'ogRMZ':function(_0x37dc00,_0x9d741){return _0x37dc00!==_0x9d741;},'reIon':function(_0x2976e6,_0x4adf06){return _0x2976e6/_0x4adf06;},'apxXf':function(_0x49d42f,_0x11fed5){return _0x49d42f===_0x11fed5;},'BYOTc':_0x3f08(0x12d)};try{const _0x1d8d8f=_0x2644db[_0x3f08(0x5d)]('.');if(_0x954c47[_0x3f08(0x12e)](_0x1d8d8f[_0x3f08(0x3b)],0x3))return console[_0x3f08(0x51)](_0x954c47[_0x3f08(0x12f)]),null;const _0x59468a=_0x1d8d8f[0x1],_0x361ada=_0x59468a['replace'](/-/g,'+')[_0x3f08(0x73)](/_/g,'/'),_0x2390b7=_0x361ada[_0x3f08(0x74)](_0x954c47[_0x3f08(0x130)](Math[_0x3f08(0x75)](_0x954c47['reIon'](_0x361ada[_0x3f08(0x3b)],0x4)),0x4),'='),_0xc18a1=_0x954c47[_0x3f08(0x131)](base64Decode,_0x2390b7);return JSON[_0x3f08(0x77)](_0xc18a1);}catch(_0xe4cdec){if(_0x954c47[_0x3f08(0x132)](_0x3f08(0x133),_0x3f08(0x133)))return console['error'](_0x954c47[_0x3f08(0x134)],_0xe4cdec),null;else try{const _0x5d938d=_0x3d60fa[_0x3f08(0x5d)]('.');if(_0x954c47[_0x3f08(0x135)](_0x5d938d[_0x3f08(0x3b)],0x3))return _0x72d1b1[_0x3f08(0x51)](_0x954c47[_0x3f08(0x12f)]),null;const _0x225050=_0x5d938d[0x1],_0x29cac6=_0x225050['replace'](/-/g,'+')[_0x3f08(0x73)](/_/g,'/'),_0xaf340d=_0x29cac6[_0x3f08(0x74)](_0x954c47['jpYzh'](_0x3e3457['ceil'](_0x954c47[_0x3f08(0x136)](_0x29cac6[_0x3f08(0x3b)],0x4)),0x4),'='),_0x360915=_0x954c47[_0x3f08(0x131)](_0x2d5fa7,_0xaf340d);return _0x9d3671[_0x3f08(0x77)](_0x360915);}catch(_0x345139){return _0xb9316a['error'](_0x3f08(0x12d),_0x345139),null;}}};exports[_0x3f08(0x137)]=decodeJWTPayload;const extractUsernameFromJWT=_0x5d76ad=>{const _0x1030da={'jAqLC':function(_0x31715d,_0x224c69){return _0x31715d!==_0x224c69;},'dgvTb':_0x3f08(0x138),'yljpz':function(_0x25927a,_0x4bebfd){return _0x25927a||_0x4bebfd;},'UXdXV':'LGcdR','iPRzR':_0x3f08(0x139),'XnbhB':function(_0x25a9be,_0x2d4a4b){return _0x25a9be(_0x2d4a4b);},'WAydZ':function(_0x3a3ef2,_0x4a1965){return _0x3a3ef2!==_0x4a1965;},'gPMpp':_0x3f08(0x13a),'GUykh':function(_0x6d2ada,_0x22a3c4){return _0x6d2ada||_0x22a3c4;}};try{if(_0x1030da[_0x3f08(0x13b)](_0x3f08(0x13c),_0x1030da[_0x3f08(0x13d)])){var _0x26328d;const _0x21b3de=_0x1030da[_0x3f08(0x13e)](_0x5d76ad,userToken);if(!_0x21b3de)return _0x3f08(0x13f)!==_0x1030da['UXdXV']?{'isValid':![],'error':_0xb7ace1,'keyType':_0xbbc444}:(console[_0x3f08(0x1d)](_0x1030da[_0x3f08(0x140)]),null);const _0x3d331d=_0x1030da['XnbhB'](decodeJWTPayload,_0x21b3de);if(!_0x3d331d)return null;const _0x2f9f63=_0x3d331d[_0x3f08(0x114)]||_0x3d331d[_0x3f08(0x115)]||_0x3d331d['userId']||_0x3d331d['email'];return _0x1030da['WAydZ'](_0x26328d=globalConfig,null)&&_0x1030da[_0x3f08(0x141)](_0x26328d,void 0x0)&&_0x26328d[_0x3f08(0x46)]&&console[_0x3f08(0x37)](_0x1030da[_0x3f08(0x142)],_0x2f9f63),_0x1030da[_0x3f08(0x143)](_0x2f9f63,null);}else throw new _0xe99e06(_0x3f08(0x144));}catch(_0x3aa0a7){return console[_0x3f08(0x51)](_0x3f08(0x145),_0x3aa0a7),null;}};exports[_0x3f08(0x10)]=extractUsernameFromJWT;const extractUserDataFromJWT=_0x303765=>{const _0x4dcb22={'WypYs':function(_0x6e116d,_0x1f3e53){return _0x6e116d||_0x1f3e53;},'RBVuz':_0x3f08(0x146),'ZdJhA':_0x3f08(0x147),'IWKCH':_0x3f08(0x148),'pQtrR':_0x3f08(0x149),'OIrSt':function(_0x125da3,_0x4e4b69){return _0x125da3||_0x4e4b69;},'cKHRG':function(_0x534bb7,_0x1b5edc){return _0x534bb7!==_0x1b5edc;},'RCgoG':_0x3f08(0x14a),'MQvCk':_0x3f08(0x14b),'LLDjf':_0x3f08(0x10b),'nlulQ':function(_0x3be3cc,_0x3fdcf9){return _0x3be3cc(_0x3fdcf9);},'FpSgh':function(_0x4bea27,_0x408ca4){return _0x4bea27===_0x408ca4;},'rgYfK':_0x3f08(0x14c),'QGzGJ':_0x3f08(0x14d),'sdrmK':_0x3f08(0x14e),'unDGg':_0x3f08(0x7e)};try{var _0x303d59;const _0x1b3da2=_0x4dcb22[_0x3f08(0x14f)](_0x303765,userToken);if(!_0x1b3da2){if(_0x4dcb22[_0x3f08(0x150)](_0x4dcb22[_0x3f08(0x151)],_0x4dcb22[_0x3f08(0x152)]))return console[_0x3f08(0x1d)](_0x4dcb22[_0x3f08(0x153)]),null;else throw new _0x57e1ef(_0x3f08(0x154)+_0xbf9a9b[_0x3f08(0xb2)]+'\x20-\x20'+_0x2a2bad[_0x3f08(0xb9)]+'.\x20Expected\x20JSON\x20but\x20got\x20'+_0x4dcb22[_0x3f08(0x155)](_0x52deaa,_0x4dcb22[_0x3f08(0x156)])+'.');}const _0x4e0163=_0x4dcb22[_0x3f08(0x157)](decodeJWTPayload,_0x1b3da2);if(!_0x4e0163)return null;const _0x4ac5b9={'id':_0x4e0163['id'],'email':_0x4e0163['email'],'userId':_0x4e0163[_0x3f08(0x158)],'userName':_0x4e0163[_0x3f08(0x114)]||_0x4e0163['username'],'verified':_0x4e0163[_0x3f08(0x116)],'iat':_0x4e0163[_0x3f08(0x117)],'exp':_0x4e0163[_0x3f08(0x118)]};if(_0x4dcb22['cKHRG'](_0x303d59=globalConfig,null)&&_0x4dcb22[_0x3f08(0x150)](_0x303d59,void 0x0)&&_0x303d59[_0x3f08(0x46)]){if(_0x4dcb22[_0x3f08(0x159)](_0x3f08(0x15a),_0x4dcb22[_0x3f08(0x15b)])){const _0x4bf873='API\x20key\x20validation\x20error:\x20'+_0xd2a027[_0x3f08(0xce)];return _0x3ac55f[_0x3f08(0x51)](_0x4dcb22[_0x3f08(0x15c)],_0x2be1b6),{'isValid':![],'error':_0x4bf873,'keyType':_0x5af2d3[_0x3f08(0x15)]};}else console[_0x3f08(0x37)](_0x4dcb22[_0x3f08(0x15d)],_0x4ac5b9);}return _0x4ac5b9;}catch(_0x385f06){if('AvJPi'!==_0x4dcb22[_0x3f08(0x15e)])return console[_0x3f08(0x51)](_0x4dcb22[_0x3f08(0x15f)],_0x385f06),null;else{_0x372e03['error'](_0x4dcb22[_0x3f08(0x160)]);throw new _0x233953(_0x4dcb22[_0x3f08(0x161)]);}}};exports['extractUserDataFromJWT']=extractUserDataFromJWT;const isUserAuthenticated=()=>{return!!userToken;};exports[_0x3f08(0x8)]=isUserAuthenticated;const getAuthHeaders=()=>{const _0x4d4db4={'BBtFX':'User\x20not\x20authenticated.\x20Please\x20verify\x20email\x20first.','EwDfH':'OnairosSDK/1.0.0','Bcryp':_0x3f08(0x23),'pPpSy':function(_0x59dde1,_0x46a094){return _0x59dde1===_0x46a094;},'lDVER':_0x3f08(0x24),'sUCsG':function(_0x42649d,_0x50e28d){return _0x42649d!==_0x50e28d;},'QoPvf':function(_0x5a30f9,_0x1b8414){return _0x5a30f9!==_0x1b8414;},'wnmaD':function(_0x34aa25,_0x57b981){return _0x34aa25===_0x57b981;},'plMSu':_0x3f08(0x162),'izNAu':'HrRbP','hbedX':_0x3f08(0x163)};var _0x38e384;if(!(_0x4d4db4[_0x3f08(0x164)](_0x38e384=globalConfig,null)&&_0x4d4db4['QoPvf'](_0x38e384,void 0x0)&&_0x38e384['apiKey'])){if(_0x4d4db4['wnmaD'](_0x4d4db4[_0x3f08(0x165)],_0x4d4db4['izNAu'])){var _0x482303;if(!_0x5ba966)throw new _0x38b9f7(_0x4d4db4[_0x3f08(0x166)]);return{'Content-Type':'application/json','Authorization':_0x3f08(0xac)+_0x485cf4,'User-Agent':_0x4d4db4['EwDfH'],'X-SDK-Version':_0x4d4db4[_0x3f08(0x167)],'X-SDK-Environment':(_0x4d4db4[_0x3f08(0x168)](_0x482303=_0xec722a,null)||_0x482303===void 0x0?void 0x0:_0x482303['environment'])||_0x4d4db4[_0x3f08(0x169)]};}else throw new Error(_0x3f08(0x66));}const _0x3c5252=getApiKeyType(globalConfig[_0x3f08(0x39)]);return{'Content-Type':'application/json','Authorization':_0x3f08(0xac)+globalConfig[_0x3f08(0x39)],'User-Agent':_0x4d4db4['hbedX'],'X-SDK-Version':_0x4d4db4[_0x3f08(0x167)],'X-SDK-Environment':globalConfig['environment']||_0x4d4db4[_0x3f08(0x169)],'X-API-Key-Type':_0x3c5252,'X-Timestamp':new Date()[_0x3f08(0xaf)]()};};exports['getAuthHeaders']=getAuthHeaders;const getDeveloperAuthHeaders=()=>{const _0x1f9f95={'iyauF':function(_0x589b31,_0x1369fb){return _0x589b31!==_0x1369fb;},'Ywmun':function(_0x56cbb4,_0x9e9cf){return _0x56cbb4!==_0x9e9cf;},'qNJdg':function(_0x197990,_0x5482ae){return _0x197990(_0x5482ae);},'GdlFr':_0x3f08(0x23),'GFavY':'production','QtLpk':function(_0x10aadd,_0x5010c8){return _0x10aadd!==_0x5010c8;},'jbRoO':function(_0x167cae,_0xb7b09b){return _0x167cae===_0xb7b09b;},'SZGIK':_0x3f08(0x16a),'wfjdG':_0x3f08(0x66),'ZEHpS':_0x3f08(0x22)};var _0x3955eb;if(!(_0x1f9f95[_0x3f08(0x16b)](_0x3955eb=globalConfig,null)&&_0x1f9f95[_0x3f08(0x16c)](_0x3955eb,void 0x0)&&_0x3955eb['apiKey'])){if(_0x1f9f95['jbRoO'](_0x1f9f95[_0x3f08(0x16d)],_0x1f9f95['SZGIK']))throw new Error(_0x1f9f95[_0x3f08(0x16e)]);else{var _0x4c2e11;if(!(_0x1f9f95[_0x3f08(0x16f)](_0x4c2e11=_0xf6295d,null)&&_0x1f9f95[_0x3f08(0x16c)](_0x4c2e11,void 0x0)&&_0x4c2e11[_0x3f08(0x39)]))throw new _0x4d6e70(_0x3f08(0x66));const _0x390fc6=_0x1f9f95['qNJdg'](_0x38879d,_0x908fdc['apiKey']);return{'Content-Type':'application/json','Authorization':'Bearer\x20'+_0x20ca2a[_0x3f08(0x39)],'User-Agent':_0x3f08(0x163),'X-SDK-Version':_0x1f9f95[_0x3f08(0x170)],'X-SDK-Environment':_0x454e91[_0x3f08(0x69)]||_0x1f9f95['GFavY'],'X-API-Key-Type':_0x390fc6,'X-Timestamp':new _0x36e682()['toISOString']()};}}const _0x3b9e47=getApiKeyType(globalConfig[_0x3f08(0x39)]);return{'Content-Type':'application/json','Authorization':_0x3f08(0xac)+globalConfig[_0x3f08(0x39)],'User-Agent':_0x1f9f95['ZEHpS'],'X-SDK-Version':_0x1f9f95['GdlFr'],'X-SDK-Environment':globalConfig['environment']||_0x1f9f95[_0x3f08(0x171)],'X-API-Key-Type':_0x3b9e47,'X-Timestamp':new Date()[_0x3f08(0xaf)]()};};exports[_0x3f08(0xc)]=getDeveloperAuthHeaders;const getUserAuthHeaders=()=>{const _0x105dff={'IryKr':function(_0x110aa1,_0x56b3cc){return _0x110aa1!==_0x56b3cc;},'gBbfX':'PpDoV','rcMgF':_0x3f08(0x172),'dcxjY':'OnairosSDK/1.0.0','dotxk':_0x3f08(0x23),'idBGG':function(_0x30d5a6,_0x3382c8){return _0x30d5a6===_0x3382c8;}};var _0x6e29cc;if(!userToken){if(_0x105dff[_0x3f08(0x173)](_0x105dff[_0x3f08(0x174)],_0x105dff[_0x3f08(0x174)])){_0xca5aeb[_0x3f08(0x51)](_0x3f08(0x78),_0x233a87),_0x4970e8=![];throw _0x188404;}else throw new Error(_0x105dff[_0x3f08(0x175)]);}return{'Content-Type':'application/json','Authorization':_0x3f08(0xac)+userToken,'User-Agent':_0x105dff[_0x3f08(0x176)],'X-SDK-Version':_0x105dff[_0x3f08(0x177)],'X-SDK-Environment':(_0x105dff['idBGG'](_0x6e29cc=globalConfig,null)||_0x6e29cc===void 0x0?void 0x0:_0x6e29cc['environment'])||_0x3f08(0x24)};};exports[_0x3f08(0x178)]=getUserAuthHeaders;const makeAuthenticatedRequest=async(_0x27d40e,_0x39d018={})=>{const _0x14d873={'WNPSy':'❌\x20API\x20rate\x20limit\x20exceeded','dfdMq':'Rate\x20limit\x20exceeded','fXnWt':function(_0x26eeba){return _0x26eeba();},'iaQio':'production','kQayj':function(_0x301e1f){return _0x301e1f();},'eoSbP':function(_0x55f03d,_0x42956e,_0x151811){return _0x55f03d(_0x42956e,_0x151811);},'dRGDA':function(_0x7ad6a4,_0x7ff8b5){return _0x7ad6a4!==_0x7ff8b5;},'oMqnS':'KsKsG','iRxEb':_0x3f08(0x179),'KtHyf':_0x3f08(0x17a),'EUQbE':function(_0x348136,_0x5c02bc){return _0x348136===_0x5c02bc;},'IgfhQ':_0x3f08(0x7f),'GUUDs':_0x3f08(0x80),'BQfLJ':'❌\x20API\x20rate\x20limit\x20exceeded.\x20Please\x20try\x20again\x20later.','nFkju':_0x3f08(0x17b),'PKvCx':function(_0x24c2c5,_0x439fdb){return _0x24c2c5(_0x439fdb);},'ebZiq':_0x3f08(0x7c),'brSRY':_0x3f08(0x17c),'IwEKq':_0x3f08(0x17d),'gerUf':'⏱️\x20Request\x20timeout\x20for:','ztCmN':_0x3f08(0x7d)};if(!_0x14d873[_0x3f08(0x17e)](isApiKeyInitialized))throw new Error(_0x3f08(0x66));const _0x6811a8=getApiConfig(),_0x4133cc=API_ENDPOINTS[_0x6811a8['environment']||_0x14d873[_0x3f08(0x17f)]],_0x5b9982=''+_0x4133cc+(_0x27d40e[_0x3f08(0x42)]('/')?'':'/')+_0x27d40e,_0x1d57a0={..._0x14d873[_0x3f08(0x180)](getAuthHeaders),..._0x39d018[_0x3f08(0x181)]||{}},_0x4e71b3=new AbortController(),_0x2b4f34=_0x14d873[_0x3f08(0x182)](setTimeout,()=>_0x4e71b3['abort'](),_0x6811a8[_0x3f08(0x44)]||0x7530);try{_0x6811a8[_0x3f08(0x46)]&&console['log'](_0x3f08(0x183)+_0x27d40e);const _0x19be5c=await _0x14d873[_0x3f08(0x182)](fetch,_0x5b9982,{..._0x39d018,'headers':_0x1d57a0,'signal':_0x4e71b3[_0x3f08(0xb0)]});clearTimeout(_0x2b4f34);if(_0x6811a8[_0x3f08(0x46)]){if(_0x14d873[_0x3f08(0x184)](_0x14d873[_0x3f08(0x185)],_0x14d873[_0x3f08(0x186)]))console[_0x3f08(0x37)](_0x3f08(0x187)+_0x19be5c[_0x3f08(0xb2)]+_0x3f08(0x188)+_0x27d40e);else throw new _0x367687('Invalid\x20API\x20key\x20format.\x20Developer\x20keys\x20must\x20be\x20at\x20least\x2032\x20characters\x20long.');}if(_0x19be5c[_0x3f08(0xb2)]===0x191){console[_0x3f08(0x51)](_0x3f08(0x189));throw new Error(_0x14d873[_0x3f08(0x18a)]);}if(_0x14d873[_0x3f08(0x18b)](_0x19be5c['status'],0x193)){console['error'](_0x14d873['IgfhQ']);throw new Error(_0x14d873[_0x3f08(0x18c)]);}if(_0x19be5c[_0x3f08(0xb2)]===0x1ad){console['error'](_0x14d873[_0x3f08(0x18d)]);throw new Error(_0x14d873[_0x3f08(0x18e)]);}return _0x19be5c;}catch(_0x156cb7){if(_0x14d873[_0x3f08(0x18b)](_0x14d873[_0x3f08(0x18f)],_0x14d873[_0x3f08(0x18f)])){_0x14d873[_0x3f08(0x190)](clearTimeout,_0x2b4f34);if(_0x156cb7[_0x3f08(0xd7)]===_0x14d873[_0x3f08(0x191)]){if(_0x14d873[_0x3f08(0x192)]!==_0x14d873[_0x3f08(0x193)]){console[_0x3f08(0x51)](_0x14d873['gerUf'],_0x27d40e);throw new Error(_0x14d873[_0x3f08(0x194)]);}else _0xa79a18['log'](_0x3f08(0x187)+_0x272c2b[_0x3f08(0xb2)]+_0x3f08(0x188)+_0x5d8d4e);}throw _0x156cb7;}else{_0x34c340[_0x3f08(0x51)](_0x14d873[_0x3f08(0x195)]);throw new _0x16cbbf(_0x14d873[_0x3f08(0x18e)]);}}};exports[_0x3f08(0x6)]=makeAuthenticatedRequest;const makeDeveloperRequest=async(_0x5a2b2d,_0x23d91b={})=>{const _0x3b3f39={'PsVpK':_0x3f08(0x1e),'DfTWn':function(_0x444514){return _0x444514();},'wUeRa':function(_0x24b50a,_0x49fa04){return _0x24b50a===_0x49fa04;},'xOSPG':_0x3f08(0x196),'sdevt':'sQrEL','EajMn':'SDK\x20not\x20initialized.\x20Call\x20initializeApiKey()\x20first.','LOAQG':function(_0x306bcc){return _0x306bcc();},'aKsuP':'production','duwPb':_0x3f08(0x197),'FUgPn':function(_0x4296d9,_0x1da8aa,_0x3359f6){return _0x4296d9(_0x1da8aa,_0x3359f6);},'UlHbL':function(_0x4d3303,_0x4270a9){return _0x4d3303(_0x4270a9);},'PwUbc':function(_0x177e14,_0x25129d){return _0x177e14===_0x25129d;},'GSngC':_0x3f08(0x198),'Krwnn':'Invalid\x20or\x20expired\x20API\x20key','vlgGK':function(_0x2f8b4c,_0x5d6e51){return _0x2f8b4c===_0x5d6e51;},'PSMUg':_0x3f08(0x199),'Gvbkk':function(_0x3fd7c3,_0x5cd2af){return _0x3fd7c3===_0x5cd2af;},'UTsIH':_0x3f08(0x19a),'QSBjV':_0x3f08(0x149),'huNLD':_0x3f08(0x19b),'PzjkA':function(_0x14e17b,_0x1f3dbf){return _0x14e17b!==_0x1f3dbf;},'BJPCJ':_0x3f08(0x19c),'kTYTB':'⏱️\x20Request\x20timeout\x20for:','IcEfJ':_0x3f08(0x7d)};if(!_0x3b3f39[_0x3f08(0x19d)](isApiKeyInitialized)){if(_0x3b3f39[_0x3f08(0x19e)](_0x3b3f39[_0x3f08(0x19f)],_0x3b3f39['sdevt']))return _0x3e1c12;else throw new Error(_0x3b3f39[_0x3f08(0x1a0)]);}const _0x44e6b9=_0x3b3f39[_0x3f08(0x1a1)](getApiConfig),_0x21df5b=API_ENDPOINTS[_0x44e6b9[_0x3f08(0x69)]||_0x3b3f39[_0x3f08(0x1a2)]],_0x4feef7=''+_0x21df5b+(_0x5a2b2d['startsWith']('/')?'':'/')+_0x5a2b2d,_0x3e4a7f={..._0x3b3f39[_0x3f08(0x19d)](getDeveloperAuthHeaders),..._0x23d91b[_0x3f08(0x181)]||{}},_0x38d1e4=new AbortController(),_0x20025f=setTimeout(()=>_0x38d1e4['abort'](),_0x44e6b9[_0x3f08(0x44)]||0x7530);try{_0x44e6b9[_0x3f08(0x46)]&&(_0x3b3f39['duwPb']===_0x3b3f39[_0x3f08(0x1a3)]?console[_0x3f08(0x37)](_0x3f08(0x1a4)+_0x5a2b2d):_0x200151[_0x3f08(0x37)](_0x3f08(0xaa)+_0x27ac69+'/'+_0x48e0ef+'\x20for\x20API\x20key\x20validation'));const _0x3a91f0=await _0x3b3f39['FUgPn'](fetch,_0x4feef7,{..._0x23d91b,'headers':_0x3e4a7f,'signal':_0x38d1e4['signal']});_0x3b3f39[_0x3f08(0x1a5)](clearTimeout,_0x20025f);_0x44e6b9['enableLogging']&&console[_0x3f08(0x37)](_0x3f08(0x1a6)+_0x3a91f0[_0x3f08(0xb2)]+_0x3f08(0x188)+_0x5a2b2d);if(_0x3b3f39[_0x3f08(0x1a7)](_0x3a91f0['status'],0x191)){console[_0x3f08(0x51)](_0x3b3f39[_0x3f08(0x1a8)]);throw new Error(_0x3b3f39['Krwnn']);}if(_0x3b3f39[_0x3f08(0x1a9)](_0x3a91f0[_0x3f08(0xb2)],0x193)){console['error'](_0x3b3f39['PSMUg']);throw new Error(_0x3f08(0x80));}if(_0x3b3f39['Gvbkk'](_0x3a91f0[_0x3f08(0xb2)],0x1ad)){console[_0x3f08(0x51)](_0x3b3f39[_0x3f08(0x1aa)]);throw new Error(_0x3b3f39[_0x3f08(0x1ab)]);}return _0x3a91f0;}catch(_0x41d36d){if(_0x3b3f39[_0x3f08(0x1ac)]===_0x3b3f39[_0x3f08(0x1ac)]){_0x3b3f39[_0x3f08(0x1a5)](clearTimeout,_0x20025f);if(_0x41d36d[_0x3f08(0xd7)]===_0x3f08(0x7c)){if(_0x3b3f39['PzjkA'](_0x3f08(0x19c),_0x3b3f39[_0x3f08(0x1ad)]))return _0x12fbfe['warn'](_0x3b3f39[_0x3f08(0x1ae)],_0x2474e1),!![];else{console[_0x3f08(0x51)](_0x3b3f39['kTYTB'],_0x5a2b2d);throw new Error(_0x3b3f39[_0x3f08(0x1af)]);}}throw _0x41d36d;}else _0x4bcf56['log']('🌐\x20Making\x20developer\x20request\x20to:\x20'+_0x45dd16);}};exports[_0x3f08(0x5)]=makeDeveloperRequest;const makeUserRequest=async(_0x3afce1,_0x3ab8a3={})=>{const _0x406cb5={'aTBmU':function(_0x21a5ac,_0x53fe01){return _0x21a5ac+_0x53fe01;},'ATOtw':'...','jyVdl':_0x3f08(0x14d),'xFgiG':function(_0x3d99c2){return _0x3d99c2();},'BppXA':'dCHZb','YfLhA':_0x3f08(0x172),'KayAF':function(_0x3be0d6){return _0x3be0d6();},'phhAf':_0x3f08(0x24),'YplLy':function(_0x524cb4){return _0x524cb4();},'AXSZj':function(_0x3a9c18,_0x33ed13,_0x16cd56){return _0x3a9c18(_0x33ed13,_0x16cd56);},'QmRxO':function(_0x145a86,_0x6cab83){return _0x145a86!==_0x6cab83;},'gPUfO':_0x3f08(0x1b0),'lXIIk':function(_0xf3bca1,_0x52936a){return _0xf3bca1(_0x52936a);},'nbOPj':function(_0x5568e8,_0x145083){return _0x5568e8===_0x145083;},'JTDII':'nuHYn','xdUwd':_0x3f08(0x1b1),'wxbKn':_0x3f08(0x1b2),'csJrx':_0x3f08(0x1b3),'PquRt':function(_0x810173){return _0x810173();},'xmzdP':function(_0x4b4364,_0x1debfe){return _0x4b4364!==_0x1debfe;},'djfUz':_0x3f08(0x1b4),'XOgDV':_0x3f08(0x1b5),'HJYJN':_0x3f08(0x1b6),'OPdpp':function(_0x1720a2,_0x5438ed){return _0x1720a2(_0x5438ed);},'DNAjU':function(_0x2aca1f,_0x4061a1){return _0x2aca1f===_0x4061a1;},'pWWyL':_0x3f08(0x7c),'XVMdx':function(_0x9117e8,_0x36fe56){return _0x9117e8===_0x36fe56;},'VXigR':_0x3f08(0x1b7),'OtIcX':'⏱️\x20Request\x20timeout\x20for:','qdLhH':_0x3f08(0x7d)};!isUserAuthenticated()&&await _0x406cb5[_0x3f08(0x1b8)](loadJWT);if(!_0x406cb5[_0x3f08(0x1b8)](isUserAuthenticated)){if(_0x3f08(0x1b9)===_0x406cb5['BppXA'])throw new _0x1c9ee5(_0x3f08(0x1ba));else throw new Error(_0x406cb5['YfLhA']);}const _0x1591e5=_0x406cb5[_0x3f08(0x1bb)](getApiConfig)||{'environment':_0x3f08(0x24),'timeout':0x7530,'enableLogging':![]},_0x39e7e4=API_ENDPOINTS[_0x1591e5[_0x3f08(0x69)]||_0x406cb5[_0x3f08(0x1bc)]],_0x16856a=''+_0x39e7e4+(_0x3afce1[_0x3f08(0x42)]('/')?'':'/')+_0x3afce1,_0x49dea7={..._0x406cb5[_0x3f08(0x1bd)](getUserAuthHeaders),..._0x3ab8a3['headers']||{}},_0x1787bd=new AbortController(),_0x2d9195=_0x406cb5[_0x3f08(0x1be)](setTimeout,()=>_0x1787bd[_0x3f08(0x1bf)](),_0x1591e5[_0x3f08(0x44)]||0x7530);try{_0x1591e5[_0x3f08(0x46)]&&(_0x406cb5['QmRxO'](_0x406cb5[_0x3f08(0x1c0)],_0x3f08(0x1b0))?_0xe06fcd=_0x3f08(0xe8)+_0x244343[_0x3f08(0xce)]:console['log'](_0x3f08(0x122)+_0x3afce1));const _0x54bdf3=await _0x406cb5[_0x3f08(0x1be)](fetch,_0x16856a,{..._0x3ab8a3,'headers':_0x49dea7,'signal':_0x1787bd['signal']});_0x406cb5[_0x3f08(0x1c1)](clearTimeout,_0x2d9195);if(_0x1591e5[_0x3f08(0x46)]){if(_0x406cb5['nbOPj'](_0x406cb5['JTDII'],_0x406cb5[_0x3f08(0x1c2)]))throw new _0x829137('Server\x20returned\x20HTML\x20page\x20instead\x20of\x20JSON\x20API\x20response.\x20This\x20often\x20indicates\x20a\x20routing\x20issue\x20or\x20server\x20misconfiguration.');else console[_0x3f08(0x37)](_0x3f08(0x1c3)+_0x54bdf3[_0x3f08(0xb2)]+_0x3f08(0x188)+_0x3afce1);}if(_0x406cb5[_0x3f08(0x1c4)](_0x54bdf3['status'],0x191)){if(_0x406cb5['nbOPj'](_0x406cb5[_0x3f08(0x1c5)],_0x406cb5[_0x3f08(0x1c5)])){console[_0x3f08(0x51)](_0x406cb5[_0x3f08(0x1c6)]),await _0x406cb5[_0x3f08(0x1c7)](clearJWT);throw new Error('Authentication\x20expired.\x20Please\x20verify\x20email\x20again.');}else _0x59c447[_0x3f08(0x37)](_0x3f08(0x2b),{'environment':_0x3de1ae[_0x3f08(0x69)],'timeout':_0x170bff[_0x3f08(0x44)],'retryAttempts':_0x47f54b['retryAttempts'],'apiKeyPrefix':_0x406cb5['aTBmU'](_0x2c524a[_0x3f08(0x39)][_0x3f08(0x4d)](0x0,0x8),_0x406cb5[_0x3f08(0x1c8)]),'enableLogging':_0x3d9263[_0x3f08(0x46)]});}if(_0x406cb5[_0x3f08(0x1c4)](_0x54bdf3[_0x3f08(0xb2)],0x193)){if(_0x406cb5[_0x3f08(0x1c9)](_0x406cb5['djfUz'],_0x406cb5[_0x3f08(0x1ca)]))_0x262ce9[_0x3f08(0x37)]('👤\x20Extracted\x20username\x20from\x20JWT:',_0x45eff8);else{console[_0x3f08(0x51)](_0x406cb5[_0x3f08(0x1cb)]);throw new Error(_0x406cb5['HJYJN']);}}return _0x54bdf3;}catch(_0x4ec62e){_0x406cb5[_0x3f08(0x1cc)](clearTimeout,_0x2d9195);if(_0x406cb5[_0x3f08(0x1cd)](_0x4ec62e[_0x3f08(0xd7)],_0x406cb5[_0x3f08(0x1ce)])){if(_0x406cb5['XVMdx'](_0x406cb5[_0x3f08(0x1cf)],_0x3f08(0x1d0)))_0x56c159[_0x3f08(0x37)](_0x406cb5[_0x3f08(0x1d1)],_0x87f0bd);else{console[_0x3f08(0x51)](_0x406cb5['OtIcX'],_0x3afce1);throw new Error(_0x406cb5[_0x3f08(0x1d2)]);}}throw _0x4ec62e;}};exports[_0x3f08(0x1d3)]=makeUserRequest;const clearValidationCache=()=>{const _0x2e0cc8={'uUfEj':function(_0x455207,_0x582017){return _0x455207!==_0x582017;},'hBhZW':'🗑️\x20API\x20key\x20validation\x20cache\x20cleared'};var _0x2985c5;validationCache[_0x3f08(0x1d4)](),_0x2e0cc8['uUfEj'](_0x2985c5=globalConfig,null)&&_0x2e0cc8[_0x3f08(0x1d5)](_0x2985c5,void 0x0)&&_0x2985c5[_0x3f08(0x46)]&&console['log'](_0x2e0cc8['hBhZW']);};exports[_0x3f08(0x12)]=clearValidationCache;const resetApiKeyService=()=>{const _0x22708f={'GGyGD':_0x3f08(0x1d6)};globalConfig=null,isInitialized=![],clearValidationCache(),console['log'](_0x22708f[_0x3f08(0x1d7)]);};exports[_0x3f08(0x4)]=resetApiKeyService;
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.validateApiKey = exports.storeJWT = exports.resetApiKeyService = exports.makeUserRequest = exports.makeDeveloperRequest = exports.makeAuthenticatedRequest = exports.loadJWT = exports.isUserAuthenticated = exports.isApiKeyInitialized = exports.initializeApiKey = exports.getUserAuthHeaders = exports.getJWT = exports.getDeveloperAuthHeaders = exports.getAuthHeaders = exports.getApiKeyType = exports.getApiKey = exports.getApiConfig = exports.extractUsernameFromJWT = exports.extractUserDataFromJWT = exports.decodeJWTPayload = exports.clearValidationCache = exports.clearJWT = exports.ApiKeyType = void 0;
|
|
7
|
+
var _asyncStorage = _interopRequireDefault(require("@react-native-async-storage/async-storage"));
|
|
8
|
+
var _netinfo = _interopRequireDefault(require("@react-native-community/netinfo"));
|
|
9
|
+
var _api = require("../config/api");
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
// API key types - Only developer keys are supported in client SDK
|
|
12
|
+
let ApiKeyType = exports.ApiKeyType = /*#__PURE__*/function (ApiKeyType) {
|
|
13
|
+
ApiKeyType["DEVELOPER"] = "developer";
|
|
14
|
+
ApiKeyType["INVALID"] = "invalid";
|
|
15
|
+
return ApiKeyType;
|
|
16
|
+
}({}); // JWT token storage key
|
|
17
|
+
const JWT_TOKEN_KEY = 'onairos_jwt_token';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Two-Tier Authentication Service for Onairos React Native SDK
|
|
21
|
+
*
|
|
22
|
+
* This service implements the two-tier authentication system:
|
|
23
|
+
* 1. Developer API Keys: For app-level operations (email verification, app registration)
|
|
24
|
+
* 2. JWT User Tokens: For user-level operations (PIN storage, user profile)
|
|
25
|
+
*
|
|
26
|
+
* How it works:
|
|
27
|
+
* 1. Initialize with developer API key
|
|
28
|
+
* 2. Use API key for email verification requests
|
|
29
|
+
* 3. Store JWT token from email verification response
|
|
30
|
+
* 4. Use JWT token for user-authenticated requests
|
|
31
|
+
* 5. Handle token expiration gracefully
|
|
32
|
+
*
|
|
33
|
+
* Backend Integration:
|
|
34
|
+
* - Developer routes: Authorization: Bearer ${API_KEY}
|
|
35
|
+
* - User routes: Authorization: Bearer ${JWT_TOKEN}
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
// Global configuration state
|
|
39
|
+
let globalConfig = null;
|
|
40
|
+
let validationCache = new Map();
|
|
41
|
+
let isInitialized = false;
|
|
42
|
+
let userToken = null;
|
|
43
|
+
|
|
44
|
+
// Cache duration (5 minutes)
|
|
45
|
+
const CACHE_DURATION = 5 * 60 * 1000;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Check network connectivity
|
|
49
|
+
* @returns Promise<boolean> - true if connected, false otherwise
|
|
50
|
+
*/
|
|
51
|
+
const checkNetworkConnectivity = async () => {
|
|
52
|
+
try {
|
|
53
|
+
const netInfo = await _netinfo.default.fetch();
|
|
54
|
+
return netInfo.isConnected === true && netInfo.isInternetReachable !== false;
|
|
55
|
+
} catch (error) {
|
|
56
|
+
console.warn('⚠️ Failed to check network connectivity:', error);
|
|
57
|
+
// If we can't check connectivity, assume we're connected and let the request fail naturally
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
// API endpoints for different environments (updated to handle non-existent dev endpoint)
|
|
63
|
+
const API_ENDPOINTS = {
|
|
64
|
+
production: `${_api.API_CONFIG.BASE_URL}`,
|
|
65
|
+
staging: `${_api.API_CONFIG.BASE_URL}`,
|
|
66
|
+
// Fallback to production for staging
|
|
67
|
+
development: `${_api.API_CONFIG.BASE_URL}` // Fallback to production since dev-API server doesn't exist
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Initialize the SDK with developer API key
|
|
72
|
+
* @param config API configuration including developer API key
|
|
73
|
+
*/
|
|
74
|
+
const initializeApiKey = async config => {
|
|
75
|
+
try {
|
|
76
|
+
console.log('🔑 Initializing Onairos SDK with developer API key...');
|
|
77
|
+
if (!config.apiKey) {
|
|
78
|
+
throw new Error('Developer API key is required for SDK initialization');
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Validate developer key format
|
|
82
|
+
if (config.apiKey.length < 32) {
|
|
83
|
+
throw new Error('Invalid API key format. Developer keys must be at least 32 characters long.');
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Check for valid developer key prefix
|
|
87
|
+
const validPrefixes = ['dev_', 'ona_', 'pk_'];
|
|
88
|
+
const hasValidPrefix = validPrefixes.some(prefix => config.apiKey.startsWith(prefix));
|
|
89
|
+
if (!hasValidPrefix) {
|
|
90
|
+
throw new Error('Invalid API key format. Developer keys must start with dev_, ona_, or pk_');
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Set global configuration
|
|
94
|
+
globalConfig = {
|
|
95
|
+
apiKey: config.apiKey,
|
|
96
|
+
environment: config.environment || 'production',
|
|
97
|
+
enableLogging: config.enableLogging !== false,
|
|
98
|
+
// Default to true
|
|
99
|
+
timeout: config.timeout || 30000,
|
|
100
|
+
retryAttempts: config.retryAttempts || 3
|
|
101
|
+
};
|
|
102
|
+
if (globalConfig.enableLogging) {
|
|
103
|
+
console.log('📝 SDK Configuration:', {
|
|
104
|
+
environment: globalConfig.environment,
|
|
105
|
+
timeout: globalConfig.timeout,
|
|
106
|
+
retryAttempts: globalConfig.retryAttempts,
|
|
107
|
+
apiKeyPrefix: config.apiKey.substring(0, 8) + '...',
|
|
108
|
+
enableLogging: globalConfig.enableLogging
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Validate the API key (handles both admin and developer keys)
|
|
113
|
+
const validation = await validateApiKey(config.apiKey);
|
|
114
|
+
if (!validation.isValid) {
|
|
115
|
+
// Use defensive coding to handle cases where validation.error might be undefined
|
|
116
|
+
const errorMessage = validation.error || '';
|
|
117
|
+
|
|
118
|
+
// Check if it's a network/connectivity issue (either from error message or the flag)
|
|
119
|
+
const isNetworkError = validation.isNetworkError || errorMessage.includes('Network request failed') || errorMessage.includes('Network error') || errorMessage.includes('JSON Parse error') || errorMessage.includes('API validation endpoint returned') || errorMessage.includes('timeout') || errorMessage.includes('ENOTFOUND') || errorMessage.includes('fetch') || errorMessage.includes('No network connection');
|
|
120
|
+
if (isNetworkError) {
|
|
121
|
+
console.warn('⚠️ API key validation failed due to network/connectivity issues');
|
|
122
|
+
console.warn('🔄 Continuing in offline mode with basic validation');
|
|
123
|
+
console.warn('📝 SDK will function with limited validation. Network connectivity will be retried automatically.');
|
|
124
|
+
console.warn('🌐 Error details:', validation.error);
|
|
125
|
+
|
|
126
|
+
// Continue initialization in offline mode - don't throw error
|
|
127
|
+
console.log('📱 SDK initialized in offline mode - will retry validation when network is available');
|
|
128
|
+
} else {
|
|
129
|
+
// Only throw for actual API key validation errors (not network issues)
|
|
130
|
+
throw new Error(`API key validation failed: ${validation.error}`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Try to load existing JWT token
|
|
135
|
+
await loadJWT();
|
|
136
|
+
isInitialized = true;
|
|
137
|
+
if (globalConfig.enableLogging) {
|
|
138
|
+
console.log('✅ Onairos SDK initialized successfully');
|
|
139
|
+
console.log('🔑 Developer API key ready for app-level operations');
|
|
140
|
+
if (userToken) {
|
|
141
|
+
console.log('🎫 User JWT token loaded from storage');
|
|
142
|
+
}
|
|
143
|
+
if (validation.permissions) {
|
|
144
|
+
console.log('🔐 API Key Permissions:', validation.permissions);
|
|
145
|
+
}
|
|
146
|
+
if (validation.rateLimits) {
|
|
147
|
+
console.log('⏱️ Rate Limits:', validation.rateLimits);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
} catch (error) {
|
|
151
|
+
console.error('❌ Failed to initialize Onairos SDK:', error);
|
|
152
|
+
isInitialized = false;
|
|
153
|
+
throw error;
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Determine API key type
|
|
159
|
+
* @param apiKey The API key to check
|
|
160
|
+
* @returns The type of API key (only DEVELOPER or INVALID - admin keys not supported in client SDK)
|
|
161
|
+
*/
|
|
162
|
+
exports.initializeApiKey = initializeApiKey;
|
|
163
|
+
const getApiKeyType = apiKey => {
|
|
164
|
+
// Developer keys must be at least 32 characters and start with specific prefix
|
|
165
|
+
if (apiKey.length >= 32 && (apiKey.startsWith('dev_') || apiKey.startsWith('pk_') || apiKey.startsWith('ona_'))) {
|
|
166
|
+
return ApiKeyType.DEVELOPER;
|
|
167
|
+
}
|
|
168
|
+
return ApiKeyType.INVALID;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Validate an API key with the Onairos backend
|
|
173
|
+
* All developer keys must be validated against the backend - no local bypass
|
|
174
|
+
* @param apiKey The API key to validate
|
|
175
|
+
* @returns Validation result with permissions and rate limits
|
|
176
|
+
*/
|
|
177
|
+
exports.getApiKeyType = getApiKeyType;
|
|
178
|
+
const validateApiKey = async apiKey => {
|
|
179
|
+
try {
|
|
180
|
+
var _globalConfig2, _globalConfig3, _globalConfig4;
|
|
181
|
+
console.log('🔍 Validating developer API key against backend...');
|
|
182
|
+
|
|
183
|
+
// Check basic format for developer keys
|
|
184
|
+
const keyType = getApiKeyType(apiKey);
|
|
185
|
+
if (keyType === ApiKeyType.INVALID) {
|
|
186
|
+
return {
|
|
187
|
+
isValid: false,
|
|
188
|
+
error: 'Invalid API key format. Developer keys must be at least 32 characters and start with "dev_", "pk_", or "ona_"',
|
|
189
|
+
keyType: ApiKeyType.INVALID
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// Check cache first
|
|
194
|
+
const cached = validationCache.get(apiKey);
|
|
195
|
+
if (cached && Date.now() - cached.timestamp < CACHE_DURATION) {
|
|
196
|
+
var _globalConfig;
|
|
197
|
+
if ((_globalConfig = globalConfig) !== null && _globalConfig !== void 0 && _globalConfig.enableLogging) {
|
|
198
|
+
console.log('📋 Using cached API key validation result');
|
|
199
|
+
}
|
|
200
|
+
return cached.result;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// Check network connectivity before making API calls
|
|
204
|
+
const isConnected = await checkNetworkConnectivity();
|
|
205
|
+
if (!isConnected) {
|
|
206
|
+
console.warn('⚠️ No network connectivity detected');
|
|
207
|
+
return {
|
|
208
|
+
isValid: false,
|
|
209
|
+
error: 'No network connection available. Please check your internet connection and try again.',
|
|
210
|
+
keyType: keyType,
|
|
211
|
+
isNetworkError: true
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
const environment = ((_globalConfig2 = globalConfig) === null || _globalConfig2 === void 0 ? void 0 : _globalConfig2.environment) || 'production';
|
|
215
|
+
const baseUrl = API_ENDPOINTS[environment];
|
|
216
|
+
const timeout = ((_globalConfig3 = globalConfig) === null || _globalConfig3 === void 0 ? void 0 : _globalConfig3.timeout) || 30000;
|
|
217
|
+
const maxRetries = ((_globalConfig4 = globalConfig) === null || _globalConfig4 === void 0 ? void 0 : _globalConfig4.retryAttempts) || 3;
|
|
218
|
+
|
|
219
|
+
// Retry logic for network failures
|
|
220
|
+
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
221
|
+
// Create abort controller for timeout
|
|
222
|
+
const controller = new AbortController();
|
|
223
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
224
|
+
try {
|
|
225
|
+
var _globalConfig5;
|
|
226
|
+
if ((_globalConfig5 = globalConfig) !== null && _globalConfig5 !== void 0 && _globalConfig5.enableLogging && attempt > 1) {
|
|
227
|
+
console.log(`🔄 Retry attempt ${attempt}/${maxRetries} for API key validation`);
|
|
228
|
+
}
|
|
229
|
+
const response = await fetch(`${baseUrl}/dev/validate-apikey`, {
|
|
230
|
+
method: 'POST',
|
|
231
|
+
headers: {
|
|
232
|
+
'Content-Type': 'application/json',
|
|
233
|
+
'Authorization': `Bearer ${apiKey}`,
|
|
234
|
+
'User-Agent': 'OnairosReactNative/3.3.1',
|
|
235
|
+
'X-API-Key-Type': keyType,
|
|
236
|
+
'X-SDK-Platform': 'react-native',
|
|
237
|
+
'X-Retry-Attempt': attempt.toString()
|
|
238
|
+
},
|
|
239
|
+
body: JSON.stringify({
|
|
240
|
+
environment,
|
|
241
|
+
sdk_version: '3.3.1',
|
|
242
|
+
platform: 'react-native',
|
|
243
|
+
keyType,
|
|
244
|
+
timestamp: new Date().toISOString(),
|
|
245
|
+
attempt
|
|
246
|
+
}),
|
|
247
|
+
signal: controller.signal
|
|
248
|
+
});
|
|
249
|
+
clearTimeout(timeoutId);
|
|
250
|
+
|
|
251
|
+
// First check if we got a valid response
|
|
252
|
+
if (!response) {
|
|
253
|
+
throw new Error('No response received from server');
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// Handle common HTTP errors that indicate server issues
|
|
257
|
+
if (response.status === 502) {
|
|
258
|
+
throw new Error('Onairos API is temporarily unavailable (502 Bad Gateway). Please try again later.');
|
|
259
|
+
}
|
|
260
|
+
if (response.status === 503) {
|
|
261
|
+
throw new Error('Onairos API is under maintenance (503 Service Unavailable). Please try again later.');
|
|
262
|
+
}
|
|
263
|
+
if (response.status === 504) {
|
|
264
|
+
throw new Error('Onairos API request timed out (504 Gateway Timeout). Please try again.');
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// Check if response is actually JSON before trying to parse
|
|
268
|
+
const contentType = response.headers.get('content-type');
|
|
269
|
+
const isJsonResponse = contentType && contentType.includes('application/json');
|
|
270
|
+
if (!isJsonResponse) {
|
|
271
|
+
const textContent = await response.text();
|
|
272
|
+
const previewText = textContent.substring(0, 200);
|
|
273
|
+
console.error('❌ API endpoint returned non-JSON response:', {
|
|
274
|
+
status: response.status,
|
|
275
|
+
statusText: response.statusText,
|
|
276
|
+
contentType: contentType || 'unknown',
|
|
277
|
+
preview: previewText,
|
|
278
|
+
url: `${baseUrl}/dev/validate-apikey`,
|
|
279
|
+
attempt: attempt
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
// Handle specific error cases
|
|
283
|
+
if (response.status === 404) {
|
|
284
|
+
throw new Error(`API validation endpoint not found (404). The endpoint ${baseUrl}/dev/validate-apikey may not exist or be configured correctly.`);
|
|
285
|
+
} else if (response.status === 500) {
|
|
286
|
+
throw new Error(`Server error (500). The Onairos backend is experiencing issues.`);
|
|
287
|
+
} else if (response.status === 502 || response.status === 503) {
|
|
288
|
+
throw new Error(`Service unavailable (${response.status}). The Onairos backend may be temporarily down.`);
|
|
289
|
+
} else if (textContent.includes('<html') || textContent.includes('<!DOCTYPE')) {
|
|
290
|
+
throw new Error(`Server returned HTML page instead of JSON API response. This often indicates a routing issue or server misconfiguration.`);
|
|
291
|
+
} else {
|
|
292
|
+
throw new Error(`API validation endpoint returned ${response.status} - ${response.statusText}. Expected JSON but got ${contentType || 'unknown content type'}.`);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// Parse JSON response
|
|
297
|
+
let data;
|
|
298
|
+
try {
|
|
299
|
+
data = await response.json();
|
|
300
|
+
} catch (jsonError) {
|
|
301
|
+
console.error('❌ Failed to parse JSON response:', {
|
|
302
|
+
error: jsonError.message,
|
|
303
|
+
status: response.status,
|
|
304
|
+
contentType,
|
|
305
|
+
attempt: attempt
|
|
306
|
+
});
|
|
307
|
+
throw new Error(`Failed to parse server response as JSON: ${jsonError.message}`);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// Handle successful response
|
|
311
|
+
// Backend returns either {success: true} or {valid: true}
|
|
312
|
+
if (response.ok && (data.success || data.valid)) {
|
|
313
|
+
var _globalConfig6;
|
|
314
|
+
const result = {
|
|
315
|
+
isValid: true,
|
|
316
|
+
permissions: data.permissions || [],
|
|
317
|
+
rateLimits: data.rateLimits || null,
|
|
318
|
+
keyType: keyType
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
// Cache the successful result
|
|
322
|
+
validationCache.set(apiKey, {
|
|
323
|
+
result,
|
|
324
|
+
timestamp: Date.now()
|
|
325
|
+
});
|
|
326
|
+
if ((_globalConfig6 = globalConfig) !== null && _globalConfig6 !== void 0 && _globalConfig6.enableLogging) {
|
|
327
|
+
var _data$apiKey, _data$application, _data$apiKey2;
|
|
328
|
+
console.log('✅ API key validation successful', {
|
|
329
|
+
apiKeyId: (_data$apiKey = data.apiKey) === null || _data$apiKey === void 0 ? void 0 : _data$apiKey.id,
|
|
330
|
+
appName: (_data$application = data.application) === null || _data$application === void 0 ? void 0 : _data$application.name,
|
|
331
|
+
usageCount: (_data$apiKey2 = data.apiKey) === null || _data$apiKey2 === void 0 ? void 0 : _data$apiKey2.usageCount
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
return result;
|
|
335
|
+
} else {
|
|
336
|
+
// Handle API errors (invalid key, etc.)
|
|
337
|
+
const errorMessage = data.error || data.message || `HTTP ${response.status}: ${response.statusText}`;
|
|
338
|
+
const result = {
|
|
339
|
+
isValid: false,
|
|
340
|
+
error: errorMessage,
|
|
341
|
+
keyType: keyType
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
// For client errors (4xx), don't retry
|
|
345
|
+
if (response.status >= 400 && response.status < 500) {
|
|
346
|
+
var _globalConfig7;
|
|
347
|
+
if ((_globalConfig7 = globalConfig) !== null && _globalConfig7 !== void 0 && _globalConfig7.enableLogging) {
|
|
348
|
+
console.error('❌ API key validation failed (client error):', errorMessage);
|
|
349
|
+
}
|
|
350
|
+
return result;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
// For server errors (5xx), retry
|
|
354
|
+
throw new Error(errorMessage);
|
|
355
|
+
}
|
|
356
|
+
} catch (fetchError) {
|
|
357
|
+
var _globalConfig8;
|
|
358
|
+
clearTimeout(timeoutId);
|
|
359
|
+
if (fetchError.name === 'AbortError') {
|
|
360
|
+
const errorMessage = `API key validation timeout (${timeout}ms)`;
|
|
361
|
+
console.error('⏱️ API key validation timeout');
|
|
362
|
+
if (attempt === maxRetries) {
|
|
363
|
+
return {
|
|
364
|
+
isValid: false,
|
|
365
|
+
error: errorMessage,
|
|
366
|
+
keyType: keyType
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
continue; // Retry timeout errors
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
// Enhanced error message based on error type
|
|
373
|
+
let errorMessage = `Network error during API key validation: ${fetchError.message}`;
|
|
374
|
+
|
|
375
|
+
// Add specific guidance for common errors
|
|
376
|
+
if (fetchError.message.includes('JSON Parse error') || fetchError.message.includes('Unexpected character')) {
|
|
377
|
+
errorMessage = `Server returned invalid JSON response. This usually indicates the API endpoint returned HTML instead of JSON (often a 404 or server error page). ${fetchError.message}`;
|
|
378
|
+
} else if (fetchError.message.includes('Network request failed') || fetchError.message.includes('fetch')) {
|
|
379
|
+
errorMessage = `Network connectivity issue. Please check internet connection and verify the Onairos API is accessible. ${fetchError.message}`;
|
|
380
|
+
} else if (fetchError.message.includes('DNS') || fetchError.message.includes('ENOTFOUND')) {
|
|
381
|
+
errorMessage = `DNS resolution failed for ${baseUrl}. Please check network settings and domain accessibility. ${fetchError.message}`;
|
|
382
|
+
}
|
|
383
|
+
console.error('🌐 Network error during API key validation:', {
|
|
384
|
+
error: fetchError,
|
|
385
|
+
endpoint: `${baseUrl}/dev/validate-apikey`,
|
|
386
|
+
attempt: attempt,
|
|
387
|
+
maxRetries: maxRetries,
|
|
388
|
+
retryable: attempt < maxRetries
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
// If this is the last attempt, return the error
|
|
392
|
+
if (attempt === maxRetries) {
|
|
393
|
+
return {
|
|
394
|
+
isValid: false,
|
|
395
|
+
error: errorMessage,
|
|
396
|
+
keyType: keyType,
|
|
397
|
+
isNetworkError: true // Flag to indicate this is a network issue, not an API key issue
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
// Wait before retrying (exponential backoff)
|
|
402
|
+
const backoffDelay = Math.min(1000 * Math.pow(2, attempt - 1), 5000);
|
|
403
|
+
if ((_globalConfig8 = globalConfig) !== null && _globalConfig8 !== void 0 && _globalConfig8.enableLogging) {
|
|
404
|
+
console.log(`⏳ Waiting ${backoffDelay}ms before retry...`);
|
|
405
|
+
}
|
|
406
|
+
await new Promise(resolve => setTimeout(() => resolve(), backoffDelay));
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
// This should never be reached, but just in case
|
|
411
|
+
return {
|
|
412
|
+
isValid: false,
|
|
413
|
+
error: 'All retry attempts exhausted',
|
|
414
|
+
keyType: keyType
|
|
415
|
+
};
|
|
416
|
+
} catch (error) {
|
|
417
|
+
const errorMessage = `API key validation error: ${error.message}`;
|
|
418
|
+
console.error('❌ API key validation error:', error);
|
|
419
|
+
return {
|
|
420
|
+
isValid: false,
|
|
421
|
+
error: errorMessage,
|
|
422
|
+
keyType: ApiKeyType.INVALID
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Get the current API configuration
|
|
429
|
+
* @returns Current API configuration or null if not initialized
|
|
430
|
+
*/
|
|
431
|
+
exports.validateApiKey = validateApiKey;
|
|
432
|
+
const getApiConfig = () => {
|
|
433
|
+
return globalConfig;
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* Get the current API key
|
|
438
|
+
* @returns Current API key or null if not initialized
|
|
439
|
+
*/
|
|
440
|
+
exports.getApiConfig = getApiConfig;
|
|
441
|
+
const getApiKey = () => {
|
|
442
|
+
var _globalConfig9;
|
|
443
|
+
return ((_globalConfig9 = globalConfig) === null || _globalConfig9 === void 0 ? void 0 : _globalConfig9.apiKey) || null;
|
|
444
|
+
};
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* Check if the SDK is properly initialized
|
|
448
|
+
* @returns True if initialized with valid API key
|
|
449
|
+
*/
|
|
450
|
+
exports.getApiKey = getApiKey;
|
|
451
|
+
const isApiKeyInitialized = () => {
|
|
452
|
+
return isInitialized && globalConfig !== null;
|
|
453
|
+
};
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* Store JWT token securely after email verification
|
|
457
|
+
* @param token JWT token from email verification response
|
|
458
|
+
*/
|
|
459
|
+
exports.isApiKeyInitialized = isApiKeyInitialized;
|
|
460
|
+
const storeJWT = async token => {
|
|
461
|
+
try {
|
|
462
|
+
var _globalConfig0;
|
|
463
|
+
await _asyncStorage.default.setItem(JWT_TOKEN_KEY, token);
|
|
464
|
+
userToken = token;
|
|
465
|
+
if ((_globalConfig0 = globalConfig) !== null && _globalConfig0 !== void 0 && _globalConfig0.enableLogging) {
|
|
466
|
+
console.log('🎫 JWT token stored successfully');
|
|
467
|
+
}
|
|
468
|
+
} catch (error) {
|
|
469
|
+
console.error('❌ Failed to store JWT token:', error);
|
|
470
|
+
throw error;
|
|
471
|
+
}
|
|
472
|
+
};
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* Load JWT token from storage
|
|
476
|
+
* @returns JWT token or null if not found
|
|
477
|
+
*/
|
|
478
|
+
exports.storeJWT = storeJWT;
|
|
479
|
+
const loadJWT = async () => {
|
|
480
|
+
try {
|
|
481
|
+
const token = await _asyncStorage.default.getItem(JWT_TOKEN_KEY);
|
|
482
|
+
userToken = token;
|
|
483
|
+
return token;
|
|
484
|
+
} catch (error) {
|
|
485
|
+
console.error('❌ Failed to load JWT token:', error);
|
|
486
|
+
return null;
|
|
487
|
+
}
|
|
488
|
+
};
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* Get current JWT token
|
|
492
|
+
* @returns JWT token or null if not available
|
|
493
|
+
*/
|
|
494
|
+
exports.loadJWT = loadJWT;
|
|
495
|
+
const getJWT = () => {
|
|
496
|
+
return userToken;
|
|
497
|
+
};
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* Clear JWT token (on logout or token expiration)
|
|
501
|
+
*/
|
|
502
|
+
exports.getJWT = getJWT;
|
|
503
|
+
const clearJWT = async () => {
|
|
504
|
+
try {
|
|
505
|
+
var _globalConfig1;
|
|
506
|
+
await _asyncStorage.default.removeItem(JWT_TOKEN_KEY);
|
|
507
|
+
userToken = null;
|
|
508
|
+
if ((_globalConfig1 = globalConfig) !== null && _globalConfig1 !== void 0 && _globalConfig1.enableLogging) {
|
|
509
|
+
console.log('🗑️ JWT token cleared');
|
|
510
|
+
}
|
|
511
|
+
} catch (error) {
|
|
512
|
+
console.error('❌ Failed to clear JWT token:', error);
|
|
513
|
+
}
|
|
514
|
+
};
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* React Native compatible base64 decoder
|
|
518
|
+
* @param str Base64 encoded string
|
|
519
|
+
* @returns Decoded string
|
|
520
|
+
*/
|
|
521
|
+
exports.clearJWT = clearJWT;
|
|
522
|
+
const base64Decode = str => {
|
|
523
|
+
// Simple base64 decoding for React Native
|
|
524
|
+
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
525
|
+
let result = '';
|
|
526
|
+
let i = 0;
|
|
527
|
+
str = str.replace(/[^A-Za-z0-9+/]/g, '');
|
|
528
|
+
while (i < str.length) {
|
|
529
|
+
const a = chars.indexOf(str.charAt(i++));
|
|
530
|
+
const b = chars.indexOf(str.charAt(i++));
|
|
531
|
+
const c = chars.indexOf(str.charAt(i++));
|
|
532
|
+
const d = chars.indexOf(str.charAt(i++));
|
|
533
|
+
const bitmap = a << 18 | b << 12 | c << 6 | d;
|
|
534
|
+
result += String.fromCharCode(bitmap >> 16 & 255);
|
|
535
|
+
if (c !== 64) result += String.fromCharCode(bitmap >> 8 & 255);
|
|
536
|
+
if (d !== 64) result += String.fromCharCode(bitmap & 255);
|
|
537
|
+
}
|
|
538
|
+
return result;
|
|
539
|
+
};
|
|
540
|
+
|
|
541
|
+
/**
|
|
542
|
+
* Decode JWT token payload (React Native compatible)
|
|
543
|
+
* @param token JWT token string
|
|
544
|
+
* @returns Decoded payload or null if invalid
|
|
545
|
+
*/
|
|
546
|
+
const decodeJWTPayload = token => {
|
|
547
|
+
try {
|
|
548
|
+
// Split JWT token (header.payload.signature)
|
|
549
|
+
const parts = token.split('.');
|
|
550
|
+
if (parts.length !== 3) {
|
|
551
|
+
console.error('❌ Invalid JWT token format');
|
|
552
|
+
return null;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
// Decode payload (base64url to base64)
|
|
556
|
+
const payload = parts[1];
|
|
557
|
+
const base64 = payload.replace(/-/g, '+').replace(/_/g, '/');
|
|
558
|
+
|
|
559
|
+
// Add padding if needed
|
|
560
|
+
const padded = base64.padEnd(Math.ceil(base64.length / 4) * 4, '=');
|
|
561
|
+
|
|
562
|
+
// Decode base64 to JSON using React Native compatible decoder
|
|
563
|
+
const decoded = base64Decode(padded);
|
|
564
|
+
return JSON.parse(decoded);
|
|
565
|
+
} catch (error) {
|
|
566
|
+
console.error('❌ Failed to decode JWT token:', error);
|
|
567
|
+
return null;
|
|
568
|
+
}
|
|
569
|
+
};
|
|
570
|
+
|
|
571
|
+
/**
|
|
572
|
+
* Extract username from JWT token
|
|
573
|
+
* @param token JWT token (optional, uses stored token if not provided)
|
|
574
|
+
* @returns Username or null if not found
|
|
575
|
+
*/
|
|
576
|
+
exports.decodeJWTPayload = decodeJWTPayload;
|
|
577
|
+
const extractUsernameFromJWT = token => {
|
|
578
|
+
try {
|
|
579
|
+
var _globalConfig10;
|
|
580
|
+
const jwtToken = token || userToken;
|
|
581
|
+
if (!jwtToken) {
|
|
582
|
+
console.warn('⚠️ No JWT token available for username extraction');
|
|
583
|
+
return null;
|
|
584
|
+
}
|
|
585
|
+
const payload = decodeJWTPayload(jwtToken);
|
|
586
|
+
if (!payload) {
|
|
587
|
+
return null;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
// Try different possible username fields in order of preference
|
|
591
|
+
const username = payload.userName || payload.username || payload.userId || payload.email;
|
|
592
|
+
if ((_globalConfig10 = globalConfig) !== null && _globalConfig10 !== void 0 && _globalConfig10.enableLogging) {
|
|
593
|
+
console.log('👤 Extracted username from JWT:', username);
|
|
594
|
+
}
|
|
595
|
+
return username || null;
|
|
596
|
+
} catch (error) {
|
|
597
|
+
console.error('❌ Failed to extract username from JWT:', error);
|
|
598
|
+
return null;
|
|
599
|
+
}
|
|
600
|
+
};
|
|
601
|
+
|
|
602
|
+
/**
|
|
603
|
+
* Extract user data from JWT token
|
|
604
|
+
* @param token JWT token (optional, uses stored token if not provided)
|
|
605
|
+
* @returns User data object or null if not found
|
|
606
|
+
*/
|
|
607
|
+
exports.extractUsernameFromJWT = extractUsernameFromJWT;
|
|
608
|
+
const extractUserDataFromJWT = token => {
|
|
609
|
+
try {
|
|
610
|
+
var _globalConfig11;
|
|
611
|
+
const jwtToken = token || userToken;
|
|
612
|
+
if (!jwtToken) {
|
|
613
|
+
console.warn('⚠️ No JWT token available for user data extraction');
|
|
614
|
+
return null;
|
|
615
|
+
}
|
|
616
|
+
const payload = decodeJWTPayload(jwtToken);
|
|
617
|
+
if (!payload) {
|
|
618
|
+
return null;
|
|
619
|
+
}
|
|
620
|
+
const userData = {
|
|
621
|
+
id: payload.id,
|
|
622
|
+
email: payload.email,
|
|
623
|
+
userId: payload.userId,
|
|
624
|
+
userName: payload.userName || payload.username,
|
|
625
|
+
verified: payload.verified,
|
|
626
|
+
iat: payload.iat,
|
|
627
|
+
exp: payload.exp
|
|
628
|
+
};
|
|
629
|
+
if ((_globalConfig11 = globalConfig) !== null && _globalConfig11 !== void 0 && _globalConfig11.enableLogging) {
|
|
630
|
+
console.log('👤 Extracted user data from JWT:', userData);
|
|
631
|
+
}
|
|
632
|
+
return userData;
|
|
633
|
+
} catch (error) {
|
|
634
|
+
console.error('❌ Failed to extract user data from JWT:', error);
|
|
635
|
+
return null;
|
|
636
|
+
}
|
|
637
|
+
};
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* Check if user is authenticated with JWT token
|
|
641
|
+
* @returns True if user has valid JWT token
|
|
642
|
+
*/
|
|
643
|
+
exports.extractUserDataFromJWT = extractUserDataFromJWT;
|
|
644
|
+
const isUserAuthenticated = () => {
|
|
645
|
+
return !!userToken;
|
|
646
|
+
};
|
|
647
|
+
|
|
648
|
+
/**
|
|
649
|
+
* Get authenticated headers for API requests
|
|
650
|
+
* @returns Headers object with Authorization and other required headers
|
|
651
|
+
*/
|
|
652
|
+
exports.isUserAuthenticated = isUserAuthenticated;
|
|
653
|
+
const getAuthHeaders = () => {
|
|
654
|
+
var _globalConfig12;
|
|
655
|
+
if (!((_globalConfig12 = globalConfig) !== null && _globalConfig12 !== void 0 && _globalConfig12.apiKey)) {
|
|
656
|
+
throw new Error('SDK not initialized. Call initializeApiKey() first.');
|
|
657
|
+
}
|
|
658
|
+
const keyType = getApiKeyType(globalConfig.apiKey);
|
|
659
|
+
return {
|
|
660
|
+
'Content-Type': 'application/json',
|
|
661
|
+
'Authorization': `Bearer ${globalConfig.apiKey}`,
|
|
662
|
+
'User-Agent': 'OnairosReactNative/3.0.72',
|
|
663
|
+
'X-SDK-Version': '3.0.72',
|
|
664
|
+
'X-SDK-Environment': globalConfig.environment || 'production',
|
|
665
|
+
'X-API-Key-Type': keyType,
|
|
666
|
+
'X-Timestamp': new Date().toISOString()
|
|
667
|
+
};
|
|
668
|
+
};
|
|
669
|
+
|
|
670
|
+
/**
|
|
671
|
+
* Get authentication headers for developer API requests
|
|
672
|
+
* @returns Headers with developer API key
|
|
673
|
+
*/
|
|
674
|
+
exports.getAuthHeaders = getAuthHeaders;
|
|
675
|
+
const getDeveloperAuthHeaders = () => {
|
|
676
|
+
var _globalConfig13;
|
|
677
|
+
if (!((_globalConfig13 = globalConfig) !== null && _globalConfig13 !== void 0 && _globalConfig13.apiKey)) {
|
|
678
|
+
throw new Error('SDK not initialized. Call initializeApiKey() first.');
|
|
679
|
+
}
|
|
680
|
+
const keyType = getApiKeyType(globalConfig.apiKey);
|
|
681
|
+
return {
|
|
682
|
+
'Content-Type': 'application/json',
|
|
683
|
+
'Authorization': `Bearer ${globalConfig.apiKey}`,
|
|
684
|
+
'User-Agent': 'OnairosSDK/1.0.0',
|
|
685
|
+
'X-SDK-Version': '3.0.72',
|
|
686
|
+
'X-SDK-Environment': globalConfig.environment || 'production',
|
|
687
|
+
'X-API-Key-Type': keyType,
|
|
688
|
+
'X-Timestamp': new Date().toISOString()
|
|
689
|
+
};
|
|
690
|
+
};
|
|
691
|
+
|
|
692
|
+
/**
|
|
693
|
+
* Get authentication headers for user JWT requests
|
|
694
|
+
* @returns Headers with user JWT token
|
|
695
|
+
*/
|
|
696
|
+
exports.getDeveloperAuthHeaders = getDeveloperAuthHeaders;
|
|
697
|
+
const getUserAuthHeaders = () => {
|
|
698
|
+
var _globalConfig14;
|
|
699
|
+
if (!userToken) {
|
|
700
|
+
throw new Error('User not authenticated. Please verify email first.');
|
|
701
|
+
}
|
|
702
|
+
return {
|
|
703
|
+
'Content-Type': 'application/json',
|
|
704
|
+
'Authorization': `Bearer ${userToken}`,
|
|
705
|
+
'User-Agent': 'OnairosSDK/1.0.0',
|
|
706
|
+
'X-SDK-Version': '3.0.72',
|
|
707
|
+
'X-SDK-Environment': ((_globalConfig14 = globalConfig) === null || _globalConfig14 === void 0 ? void 0 : _globalConfig14.environment) || 'production'
|
|
708
|
+
};
|
|
709
|
+
};
|
|
710
|
+
|
|
711
|
+
/**
|
|
712
|
+
* Make an authenticated API request
|
|
713
|
+
* @param endpoint The API endpoint (relative to base URL)
|
|
714
|
+
* @param options Fetch options
|
|
715
|
+
* @returns Response promise
|
|
716
|
+
*/
|
|
717
|
+
exports.getUserAuthHeaders = getUserAuthHeaders;
|
|
718
|
+
const makeAuthenticatedRequest = async (endpoint, options = {}) => {
|
|
719
|
+
if (!isApiKeyInitialized()) {
|
|
720
|
+
throw new Error('SDK not initialized. Call initializeApiKey() first.');
|
|
721
|
+
}
|
|
722
|
+
const config = getApiConfig();
|
|
723
|
+
const baseUrl = API_ENDPOINTS[config.environment || 'production'];
|
|
724
|
+
const url = `${baseUrl}${endpoint.startsWith('/') ? '' : '/'}${endpoint}`;
|
|
725
|
+
|
|
726
|
+
// Merge authentication headers
|
|
727
|
+
const headers = {
|
|
728
|
+
...getAuthHeaders(),
|
|
729
|
+
...(options.headers || {})
|
|
730
|
+
};
|
|
731
|
+
|
|
732
|
+
// Add timeout
|
|
733
|
+
const controller = new AbortController();
|
|
734
|
+
const timeoutId = setTimeout(() => controller.abort(), config.timeout || 30000);
|
|
735
|
+
try {
|
|
736
|
+
if (config.enableLogging) {
|
|
737
|
+
console.log(`🌐 Making authenticated request to: ${endpoint}`);
|
|
738
|
+
}
|
|
739
|
+
const response = await fetch(url, {
|
|
740
|
+
...options,
|
|
741
|
+
headers,
|
|
742
|
+
signal: controller.signal
|
|
743
|
+
});
|
|
744
|
+
clearTimeout(timeoutId);
|
|
745
|
+
if (config.enableLogging) {
|
|
746
|
+
console.log(`📡 Response status: ${response.status} for ${endpoint}`);
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
// Handle API key errors
|
|
750
|
+
if (response.status === 401) {
|
|
751
|
+
console.error('❌ API key authentication failed. Please check your API key.');
|
|
752
|
+
throw new Error('Invalid or expired API key');
|
|
753
|
+
}
|
|
754
|
+
if (response.status === 403) {
|
|
755
|
+
console.error('❌ API key permissions insufficient for this operation.');
|
|
756
|
+
throw new Error('Insufficient API key permissions');
|
|
757
|
+
}
|
|
758
|
+
if (response.status === 429) {
|
|
759
|
+
console.error('❌ API rate limit exceeded. Please try again later.');
|
|
760
|
+
throw new Error('Rate limit exceeded');
|
|
761
|
+
}
|
|
762
|
+
return response;
|
|
763
|
+
} catch (error) {
|
|
764
|
+
clearTimeout(timeoutId);
|
|
765
|
+
if (error.name === 'AbortError') {
|
|
766
|
+
console.error('⏱️ Request timeout for:', endpoint);
|
|
767
|
+
throw new Error('Request timeout');
|
|
768
|
+
}
|
|
769
|
+
throw error;
|
|
770
|
+
}
|
|
771
|
+
};
|
|
772
|
+
|
|
773
|
+
/**
|
|
774
|
+
* Make authenticated request with developer API key
|
|
775
|
+
* @param endpoint The API endpoint
|
|
776
|
+
* @param options Fetch options
|
|
777
|
+
* @returns Response promise
|
|
778
|
+
*/
|
|
779
|
+
exports.makeAuthenticatedRequest = makeAuthenticatedRequest;
|
|
780
|
+
const makeDeveloperRequest = async (endpoint, options = {}) => {
|
|
781
|
+
if (!isApiKeyInitialized()) {
|
|
782
|
+
throw new Error('SDK not initialized. Call initializeApiKey() first.');
|
|
783
|
+
}
|
|
784
|
+
const config = getApiConfig();
|
|
785
|
+
const baseUrl = API_ENDPOINTS[config.environment || 'production'];
|
|
786
|
+
const url = `${baseUrl}${endpoint.startsWith('/') ? '' : '/'}${endpoint}`;
|
|
787
|
+
|
|
788
|
+
// Merge developer authentication headers
|
|
789
|
+
const headers = {
|
|
790
|
+
...getDeveloperAuthHeaders(),
|
|
791
|
+
...(options.headers || {})
|
|
792
|
+
};
|
|
793
|
+
|
|
794
|
+
// Add timeout
|
|
795
|
+
const controller = new AbortController();
|
|
796
|
+
const timeoutId = setTimeout(() => controller.abort(), config.timeout || 30000);
|
|
797
|
+
try {
|
|
798
|
+
if (config.enableLogging) {
|
|
799
|
+
console.log(`🌐 Making developer request to: ${endpoint}`);
|
|
800
|
+
}
|
|
801
|
+
const response = await fetch(url, {
|
|
802
|
+
...options,
|
|
803
|
+
headers,
|
|
804
|
+
signal: controller.signal
|
|
805
|
+
});
|
|
806
|
+
clearTimeout(timeoutId);
|
|
807
|
+
if (config.enableLogging) {
|
|
808
|
+
console.log(`📡 Developer request response: ${response.status} for ${endpoint}`);
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
// Handle API key errors
|
|
812
|
+
if (response.status === 401) {
|
|
813
|
+
console.error('❌ Developer API key authentication failed');
|
|
814
|
+
throw new Error('Invalid or expired API key');
|
|
815
|
+
}
|
|
816
|
+
if (response.status === 403) {
|
|
817
|
+
console.error('❌ Developer API key permissions insufficient');
|
|
818
|
+
throw new Error('Insufficient API key permissions');
|
|
819
|
+
}
|
|
820
|
+
if (response.status === 429) {
|
|
821
|
+
console.error('❌ API rate limit exceeded');
|
|
822
|
+
throw new Error('Rate limit exceeded');
|
|
823
|
+
}
|
|
824
|
+
return response;
|
|
825
|
+
} catch (error) {
|
|
826
|
+
clearTimeout(timeoutId);
|
|
827
|
+
if (error.name === 'AbortError') {
|
|
828
|
+
console.error('⏱️ Request timeout for:', endpoint);
|
|
829
|
+
throw new Error('Request timeout');
|
|
830
|
+
}
|
|
831
|
+
throw error;
|
|
832
|
+
}
|
|
833
|
+
};
|
|
834
|
+
|
|
835
|
+
/**
|
|
836
|
+
* Make authenticated request with user JWT token
|
|
837
|
+
* @param endpoint The API endpoint
|
|
838
|
+
* @param options Fetch options
|
|
839
|
+
* @returns Response promise
|
|
840
|
+
*/
|
|
841
|
+
exports.makeDeveloperRequest = makeDeveloperRequest;
|
|
842
|
+
const makeUserRequest = async (endpoint, options = {}) => {
|
|
843
|
+
if (!isUserAuthenticated()) {
|
|
844
|
+
await loadJWT(); // Try to load from storage
|
|
845
|
+
}
|
|
846
|
+
if (!isUserAuthenticated()) {
|
|
847
|
+
throw new Error('User not authenticated. Please verify email first.');
|
|
848
|
+
}
|
|
849
|
+
const config = getApiConfig() || {
|
|
850
|
+
environment: 'production',
|
|
851
|
+
timeout: 30000,
|
|
852
|
+
enableLogging: false
|
|
853
|
+
};
|
|
854
|
+
const baseUrl = API_ENDPOINTS[config.environment || 'production'];
|
|
855
|
+
const url = `${baseUrl}${endpoint.startsWith('/') ? '' : '/'}${endpoint}`;
|
|
856
|
+
|
|
857
|
+
// Merge user authentication headers
|
|
858
|
+
const headers = {
|
|
859
|
+
...getUserAuthHeaders(),
|
|
860
|
+
...(options.headers || {})
|
|
861
|
+
};
|
|
862
|
+
|
|
863
|
+
// Add timeout
|
|
864
|
+
const controller = new AbortController();
|
|
865
|
+
const timeoutId = setTimeout(() => controller.abort(), config.timeout || 30000);
|
|
866
|
+
try {
|
|
867
|
+
if (config.enableLogging) {
|
|
868
|
+
console.log(`🌐 Making user request to: ${endpoint}`);
|
|
869
|
+
}
|
|
870
|
+
const response = await fetch(url, {
|
|
871
|
+
...options,
|
|
872
|
+
headers,
|
|
873
|
+
signal: controller.signal
|
|
874
|
+
});
|
|
875
|
+
clearTimeout(timeoutId);
|
|
876
|
+
if (config.enableLogging) {
|
|
877
|
+
console.log(`📡 User request response: ${response.status} for ${endpoint}`);
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
// Handle JWT token errors
|
|
881
|
+
if (response.status === 401) {
|
|
882
|
+
console.error('❌ JWT token authentication failed - token may be expired');
|
|
883
|
+
await clearJWT(); // Clear expired token
|
|
884
|
+
throw new Error('Authentication expired. Please verify email again.');
|
|
885
|
+
}
|
|
886
|
+
if (response.status === 403) {
|
|
887
|
+
console.error('❌ JWT token permissions insufficient');
|
|
888
|
+
throw new Error('Insufficient permissions for this operation');
|
|
889
|
+
}
|
|
890
|
+
return response;
|
|
891
|
+
} catch (error) {
|
|
892
|
+
clearTimeout(timeoutId);
|
|
893
|
+
if (error.name === 'AbortError') {
|
|
894
|
+
console.error('⏱️ Request timeout for:', endpoint);
|
|
895
|
+
throw new Error('Request timeout');
|
|
896
|
+
}
|
|
897
|
+
throw error;
|
|
898
|
+
}
|
|
899
|
+
};
|
|
900
|
+
|
|
901
|
+
/**
|
|
902
|
+
* Clear the API key validation cache
|
|
903
|
+
*/
|
|
904
|
+
exports.makeUserRequest = makeUserRequest;
|
|
905
|
+
const clearValidationCache = () => {
|
|
906
|
+
var _globalConfig15;
|
|
907
|
+
validationCache.clear();
|
|
908
|
+
if ((_globalConfig15 = globalConfig) !== null && _globalConfig15 !== void 0 && _globalConfig15.enableLogging) {
|
|
909
|
+
console.log('🗑️ API key validation cache cleared');
|
|
910
|
+
}
|
|
911
|
+
};
|
|
912
|
+
|
|
913
|
+
/**
|
|
914
|
+
* Reset the SDK initialization state
|
|
915
|
+
*/
|
|
916
|
+
exports.clearValidationCache = clearValidationCache;
|
|
917
|
+
const resetApiKeyService = () => {
|
|
918
|
+
globalConfig = null;
|
|
919
|
+
isInitialized = false;
|
|
920
|
+
clearValidationCache();
|
|
921
|
+
console.log('🔄 API key service reset');
|
|
922
|
+
};
|
|
923
|
+
exports.resetApiKeyService = resetApiKeyService;
|
|
924
|
+
//# sourceMappingURL=apiKeyService.js.map
|