@onairos/react-native 3.6.3 → 3.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (222) hide show
  1. package/lib/commonjs/api/index.js +1 -1
  2. package/lib/commonjs/components/BodyText.js +1 -1
  3. package/lib/commonjs/components/BrandMark.js +1 -1
  4. package/lib/commonjs/components/CodeInput.js +1 -1
  5. package/lib/commonjs/components/EmailInput.js +1 -1
  6. package/lib/commonjs/components/GoogleButton.js +1 -1
  7. package/lib/commonjs/components/HeadingGroup.js +1 -1
  8. package/lib/commonjs/components/LLMDataInputModal.js +1 -1
  9. package/lib/commonjs/components/ModalHeader.js +1 -1
  10. package/lib/commonjs/components/ModalSheet.js +1 -1
  11. package/lib/commonjs/components/Onairos.js +1 -1
  12. package/lib/commonjs/components/OnairosButton.js +1 -1
  13. package/lib/commonjs/components/OnairosSignInButton.js +1 -1
  14. package/lib/commonjs/components/Overlay.js +1 -1
  15. package/lib/commonjs/components/PersonaImage.js +1 -1
  16. package/lib/commonjs/components/PersonaLoadingScreen.js +1 -1
  17. package/lib/commonjs/components/PersonalizationConsentScreen.js +1 -1
  18. package/lib/commonjs/components/PinCreationScreen.js +1 -1
  19. package/lib/commonjs/components/PinInput.js +1 -1
  20. package/lib/commonjs/components/PlatformConnectorsStep.js +1 -1
  21. package/lib/commonjs/components/PlatformList.js +1 -1
  22. package/lib/commonjs/components/PlatformToggle.js +1 -1
  23. package/lib/commonjs/components/PrimaryButton.js +1 -1
  24. package/lib/commonjs/components/SignInMatchAnimation.js +1 -1
  25. package/lib/commonjs/components/SignInStep.js +1 -1
  26. package/lib/commonjs/components/UniversalOnboarding.js +1 -1
  27. package/lib/commonjs/components/VerificationStep.js +1 -1
  28. package/lib/commonjs/components/WelcomeScreen.js +1 -1
  29. package/lib/commonjs/components/icons/Basicproficon.js +1 -1
  30. package/lib/commonjs/components/icons/Basicprofile.js +1 -1
  31. package/lib/commonjs/components/icons/Checkbox.js +1 -1
  32. package/lib/commonjs/components/icons/Checkmark.js +1 -1
  33. package/lib/commonjs/components/icons/Contentanalysis.js +1 -1
  34. package/lib/commonjs/components/icons/Contenticon.js +1 -1
  35. package/lib/commonjs/components/icons/EnochE.js +1 -1
  36. package/lib/commonjs/components/icons/Personalityicon.js +1 -1
  37. package/lib/commonjs/components/icons/Personalityprofile.js +1 -1
  38. package/lib/commonjs/components/icons/Personalitytraits.js +1 -1
  39. package/lib/commonjs/components/icons/Userpreferences.js +1 -1
  40. package/lib/commonjs/components/icons/index.js +1 -1
  41. package/lib/commonjs/components/onboarding/OAuthWebView.js +1 -1
  42. package/lib/commonjs/components/onboarding/OnboardingHeader.js +1 -1
  43. package/lib/commonjs/components/onboarding/PinInput.js +1 -1
  44. package/lib/commonjs/components/onboarding/PlatformConnector.js +1 -1
  45. package/lib/commonjs/config/api.js +1 -1
  46. package/lib/commonjs/constants/index.js +1 -1
  47. package/lib/commonjs/context/AuthContext.js +1 -1
  48. package/lib/commonjs/hooks/useConnectedAccounts.js +1 -1
  49. package/lib/commonjs/hooks/useConnections.js +1 -1
  50. package/lib/commonjs/hooks/useCredentials.js +1 -1
  51. package/lib/commonjs/hooks/useUserConnections.js +1 -1
  52. package/lib/commonjs/index.js +1 -1
  53. package/lib/commonjs/services/apiClient.js +1 -1
  54. package/lib/commonjs/services/apiKeyService.js +924 -9
  55. package/lib/commonjs/services/authService.js +627 -10
  56. package/lib/commonjs/services/biometricPinService.js +1 -1
  57. package/lib/commonjs/services/chatGPTConversationExtractor.js +1 -1
  58. package/lib/commonjs/services/chatGPTConversationService.js +1 -1
  59. package/lib/commonjs/services/claudeConversationExtractor.js +1 -1
  60. package/lib/commonjs/services/claudeConversationService.js +1 -1
  61. package/lib/commonjs/services/connectedAccountsService.js +1 -1
  62. package/lib/commonjs/services/googleAuthService.js +1 -1
  63. package/lib/commonjs/services/hingeDataExtractor.js +1 -1
  64. package/lib/commonjs/services/hingeDataService.js +1 -1
  65. package/lib/commonjs/services/imageCompressionService.js +1 -1
  66. package/lib/commonjs/services/instagramDataExtractor.js +1 -1
  67. package/lib/commonjs/services/instagramDataService.js +1 -1
  68. package/lib/commonjs/services/jwtStorageService.js +1 -1
  69. package/lib/commonjs/services/linkedinDOMExtractor.js +1 -1
  70. package/lib/commonjs/services/linkedinProfileService.js +1 -1
  71. package/lib/commonjs/services/linkedinScrapingService.js +1 -1
  72. package/lib/commonjs/services/llmDataStorage.js +1 -1
  73. package/lib/commonjs/services/mobileTrainingService.js +1 -1
  74. package/lib/commonjs/services/oauthService.js +391 -11
  75. package/lib/commonjs/services/pinEncryptionService.js +1 -1
  76. package/lib/commonjs/services/pinStorageUtils.js +1 -1
  77. package/lib/commonjs/services/platformAuthService.js +1 -1
  78. package/lib/commonjs/services/sephoraDataExtractor.js +1 -1
  79. package/lib/commonjs/services/sephoraDataService.js +1 -1
  80. package/lib/commonjs/services/storageService.js +1 -1
  81. package/lib/commonjs/services/telegramDataExtractor.js +1 -1
  82. package/lib/commonjs/services/telegramDataService.js +1 -1
  83. package/lib/commonjs/services/trainingApiHelpers.js +1 -1
  84. package/lib/commonjs/services/userConnectionsService.js +1 -1
  85. package/lib/commonjs/services/youtubeMigrationService.js +1 -1
  86. package/lib/commonjs/theme/index.js +1 -1
  87. package/lib/commonjs/types/index.js +1 -1
  88. package/lib/commonjs/types.js +1 -1
  89. package/lib/commonjs/utils/Portal.js +1 -1
  90. package/lib/commonjs/utils/api.js +1 -1
  91. package/lib/commonjs/utils/assetRegistry.js +1 -1
  92. package/lib/commonjs/utils/auth.js +1 -1
  93. package/lib/commonjs/utils/connectorTests.js +1 -1
  94. package/lib/commonjs/utils/crypto.js +1 -1
  95. package/lib/commonjs/utils/debugHelper.js +1 -1
  96. package/lib/commonjs/utils/encryption.js +1 -1
  97. package/lib/commonjs/utils/eventUtils.js +1 -1
  98. package/lib/commonjs/utils/haptics.js +1 -1
  99. package/lib/commonjs/utils/imagePreloader.js +1 -1
  100. package/lib/commonjs/utils/networkDiagnostics.js +1 -1
  101. package/lib/commonjs/utils/onairosApi.js +1 -1
  102. package/lib/commonjs/utils/programmaticFlow.js +1 -1
  103. package/lib/commonjs/utils/retryHelper.js +1 -1
  104. package/lib/commonjs/utils/secureStorage.js +1 -1
  105. package/lib/commonjs/utils/webviewScripts/chatgpt.js +1 -1
  106. package/lib/commonjs/utils/webviewScripts/claude.js +1 -1
  107. package/lib/commonjs/utils/webviewScripts/hinge.js +1 -1
  108. package/lib/commonjs/utils/webviewScripts/index.js +1 -1
  109. package/lib/commonjs/utils/webviewScripts/instagram.js +1 -1
  110. package/lib/commonjs/utils/webviewScripts/linkedin.js +1 -1
  111. package/lib/commonjs/utils/webviewScripts/sephora.js +1 -1
  112. package/lib/commonjs/utils/webviewScripts/telegram.js +1 -1
  113. package/lib/module/api/index.js +1 -1
  114. package/lib/module/components/BodyText.js +1 -1
  115. package/lib/module/components/BrandMark.js +1 -1
  116. package/lib/module/components/CodeInput.js +1 -1
  117. package/lib/module/components/EmailInput.js +1 -1
  118. package/lib/module/components/GoogleButton.js +1 -1
  119. package/lib/module/components/HeadingGroup.js +1 -1
  120. package/lib/module/components/LLMDataInputModal.js +1 -1
  121. package/lib/module/components/ModalHeader.js +1 -1
  122. package/lib/module/components/ModalSheet.js +1 -1
  123. package/lib/module/components/Onairos.js +1 -1
  124. package/lib/module/components/OnairosButton.js +1 -1
  125. package/lib/module/components/OnairosSignInButton.js +1 -1
  126. package/lib/module/components/Overlay.js +1 -1
  127. package/lib/module/components/PersonaImage.js +1 -1
  128. package/lib/module/components/PersonaLoadingScreen.js +1 -1
  129. package/lib/module/components/PersonalizationConsentScreen.js +1 -1
  130. package/lib/module/components/PinCreationScreen.js +1 -1
  131. package/lib/module/components/PinInput.js +1 -1
  132. package/lib/module/components/PlatformConnectorsStep.js +1 -1
  133. package/lib/module/components/PlatformList.js +1 -1
  134. package/lib/module/components/PlatformToggle.js +1 -1
  135. package/lib/module/components/PrimaryButton.js +1 -1
  136. package/lib/module/components/SignInMatchAnimation.js +1 -1
  137. package/lib/module/components/SignInStep.js +1 -1
  138. package/lib/module/components/UniversalOnboarding.js +1 -1
  139. package/lib/module/components/VerificationStep.js +1 -1
  140. package/lib/module/components/WelcomeScreen.js +1 -1
  141. package/lib/module/components/icons/Basicproficon.js +1 -1
  142. package/lib/module/components/icons/Basicprofile.js +1 -1
  143. package/lib/module/components/icons/Checkbox.js +1 -1
  144. package/lib/module/components/icons/Checkmark.js +1 -1
  145. package/lib/module/components/icons/Contentanalysis.js +1 -1
  146. package/lib/module/components/icons/Contenticon.js +1 -1
  147. package/lib/module/components/icons/EnochE.js +1 -1
  148. package/lib/module/components/icons/Personalityicon.js +1 -1
  149. package/lib/module/components/icons/Personalityprofile.js +1 -1
  150. package/lib/module/components/icons/Personalitytraits.js +1 -1
  151. package/lib/module/components/icons/Userpreferences.js +1 -1
  152. package/lib/module/components/onboarding/OAuthWebView.js +1 -1
  153. package/lib/module/components/onboarding/OnboardingHeader.js +1 -1
  154. package/lib/module/components/onboarding/PinInput.js +1 -1
  155. package/lib/module/components/onboarding/PlatformConnector.js +1 -1
  156. package/lib/module/config/api.js +1 -1
  157. package/lib/module/constants/index.js +1 -1
  158. package/lib/module/context/AuthContext.js +1 -1
  159. package/lib/module/hooks/useConnectedAccounts.js +1 -1
  160. package/lib/module/hooks/useConnections.js +1 -1
  161. package/lib/module/hooks/useCredentials.js +1 -1
  162. package/lib/module/hooks/useUserConnections.js +1 -1
  163. package/lib/module/index.js +1 -1
  164. package/lib/module/services/apiClient.js +1 -1
  165. package/lib/module/services/apiKeyService.js +898 -1
  166. package/lib/module/services/authService.js +602 -1
  167. package/lib/module/services/biometricPinService.js +1 -1
  168. package/lib/module/services/chatGPTConversationExtractor.js +1 -1
  169. package/lib/module/services/chatGPTConversationService.js +1 -1
  170. package/lib/module/services/claudeConversationExtractor.js +1 -1
  171. package/lib/module/services/claudeConversationService.js +1 -1
  172. package/lib/module/services/connectedAccountsService.js +1 -1
  173. package/lib/module/services/googleAuthService.js +1 -1
  174. package/lib/module/services/hingeDataExtractor.js +1 -1
  175. package/lib/module/services/hingeDataService.js +1 -1
  176. package/lib/module/services/imageCompressionService.js +1 -1
  177. package/lib/module/services/instagramDataExtractor.js +1 -1
  178. package/lib/module/services/instagramDataService.js +1 -1
  179. package/lib/module/services/jwtStorageService.js +1 -1
  180. package/lib/module/services/linkedinDOMExtractor.js +1 -1
  181. package/lib/module/services/linkedinProfileService.js +1 -1
  182. package/lib/module/services/linkedinScrapingService.js +1 -1
  183. package/lib/module/services/llmDataStorage.js +1 -1
  184. package/lib/module/services/mobileTrainingService.js +1 -1
  185. package/lib/module/services/oauthService.js +381 -1
  186. package/lib/module/services/pinEncryptionService.js +1 -1
  187. package/lib/module/services/pinStorageUtils.js +1 -1
  188. package/lib/module/services/platformAuthService.js +1 -1
  189. package/lib/module/services/sephoraDataExtractor.js +1 -1
  190. package/lib/module/services/sephoraDataService.js +1 -1
  191. package/lib/module/services/storageService.js +1 -1
  192. package/lib/module/services/telegramDataExtractor.js +1 -1
  193. package/lib/module/services/telegramDataService.js +1 -1
  194. package/lib/module/services/trainingApiHelpers.js +1 -1
  195. package/lib/module/services/userConnectionsService.js +1 -1
  196. package/lib/module/services/youtubeMigrationService.js +1 -1
  197. package/lib/module/theme/index.js +1 -1
  198. package/lib/module/types.js +1 -1
  199. package/lib/module/utils/Portal.js +1 -1
  200. package/lib/module/utils/api.js +1 -1
  201. package/lib/module/utils/assetRegistry.js +1 -1
  202. package/lib/module/utils/auth.js +1 -1
  203. package/lib/module/utils/connectorTests.js +1 -1
  204. package/lib/module/utils/crypto.js +1 -1
  205. package/lib/module/utils/debugHelper.js +1 -1
  206. package/lib/module/utils/encryption.js +1 -1
  207. package/lib/module/utils/eventUtils.js +1 -1
  208. package/lib/module/utils/haptics.js +1 -1
  209. package/lib/module/utils/networkDiagnostics.js +1 -1
  210. package/lib/module/utils/onairosApi.js +1 -1
  211. package/lib/module/utils/programmaticFlow.js +1 -1
  212. package/lib/module/utils/retryHelper.js +1 -1
  213. package/lib/module/utils/secureStorage.js +1 -1
  214. package/lib/module/utils/webviewScripts/chatgpt.js +1 -1
  215. package/lib/module/utils/webviewScripts/claude.js +1 -1
  216. package/lib/module/utils/webviewScripts/hinge.js +1 -1
  217. package/lib/module/utils/webviewScripts/index.js +1 -1
  218. package/lib/module/utils/webviewScripts/instagram.js +1 -1
  219. package/lib/module/utils/webviewScripts/linkedin.js +1 -1
  220. package/lib/module/utils/webviewScripts/sephora.js +1 -1
  221. package/lib/module/utils/webviewScripts/telegram.js +1 -1
  222. package/package.json +1 -1
@@ -1 +1,898 @@
1
- import AsyncStorage from'@react-native-async-storage/async-storage';import NetInfo from'@react-native-community/netinfo';import{API_CONFIG}from'../config/api';export let ApiKeyType=function(_0x1e1171){const _0x4e8144={'WZkWZ':'developer'};return _0x1e1171[_0x3061(0x0)]=_0x4e8144[_0x3061(0x1)],_0x1e1171[_0x3061(0x2)]=_0x3061(0x3),_0x1e1171;}({});const JWT_TOKEN_KEY=_0x3061(0x4);let globalConfig=null,validationCache=new Map(),isInitialized=![],userToken=null;const CACHE_DURATION=0x5*0x3c*0x3e8,checkNetworkConnectivity=async()=>{const _0x500269={'LQKmx':'❌\x20API\x20rate\x20limit\x20exceeded','JZKUx':_0x3061(0x5),'CqgBj':function(_0x1682c0,_0x561c88){return _0x1682c0===_0x561c88;},'tuZav':function(_0x2b285f,_0x1445ad){return _0x2b285f!==_0x1445ad;},'rUVAj':_0x3061(0x6),'XQyha':_0x3061(0x7)};try{const _0x2fa7cb=await NetInfo[_0x3061(0x8)]();return _0x500269[_0x3061(0x9)](_0x2fa7cb[_0x3061(0xa)],!![])&&_0x2fa7cb[_0x3061(0xb)]!==![];}catch(_0x26af68){if(_0x500269[_0x3061(0xc)](_0x500269['rUVAj'],_0x500269[_0x3061(0xd)])){_0x4c900d[_0x3061(0xe)](_0x500269[_0x3061(0xf)]);throw new _0x46112f(_0x500269['JZKUx']);}else return console[_0x3061(0x10)](_0x500269[_0x3061(0x11)],_0x26af68),!![];}},API_ENDPOINTS={'production':''+API_CONFIG[_0x3061(0x12)],'staging':''+API_CONFIG[_0x3061(0x12)],'development':''+API_CONFIG[_0x3061(0x12)]};export const initializeApiKey=async _0x230051=>{const _0xc9b7f={'pdxlZ':_0x3061(0x13),'BgbvR':_0x3061(0x14),'tdTIb':function(_0x314b66,_0xbcc34){return _0x314b66(_0xbcc34);},'UcxEF':'AbortError','GgZtR':'⏱️\x20Request\x20timeout\x20for:','ZLetE':_0x3061(0x15),'LUsrg':_0x3061(0x16),'TLkbv':_0x3061(0x17),'YjSGz':_0x3061(0x18),'MGCCj':_0x3061(0x19),'GjrBs':_0x3061(0x1a),'QDnOF':_0x3061(0x1b),'ZvkFN':function(_0x14a5a3,_0x538290){return _0x14a5a3!==_0x538290;},'GOFsx':_0x3061(0x1c),'okXea':function(_0x563a18,_0x387243){return _0x563a18+_0x387243;},'gnsvF':_0x3061(0x1d),'TtApW':_0x3061(0x1e),'YYvpf':'Network\x20error','wPmCp':_0x3061(0x1f),'GvboP':_0x3061(0x20),'XldYu':'ENOTFOUND','AhVit':_0x3061(0x8),'iFshR':_0x3061(0x21),'rchLy':'hTxkk','QZoAv':_0x3061(0x22),'CaFbK':'📱\x20SDK\x20initialized\x20in\x20offline\x20mode\x20-\x20will\x20retry\x20validation\x20when\x20network\x20is\x20available','zPOfV':'🌐\x20Error\x20details:','ICJQb':_0x3061(0x23),'QkLTj':function(_0x4d71dd){return _0x4d71dd();},'DRpVh':_0x3061(0x24),'QfFhD':'🔑\x20Developer\x20API\x20key\x20ready\x20for\x20app-level\x20operations','zLFKV':_0x3061(0x25),'RHSLv':function(_0x1d192b,_0x274e8b){return _0x1d192b!==_0x274e8b;},'FLXsM':_0x3061(0x26),'EEYmZ':'dNAkx','eViiO':_0x3061(0x27),'weQfd':_0x3061(0x28)};try{console[_0x3061(0x29)](_0xc9b7f['ZLetE']);if(!_0x230051['apiKey'])throw new Error(_0x3061(0x2a));if(_0x230051[_0x3061(0x2b)][_0x3061(0x2c)]<0x20){if(_0xc9b7f[_0x3061(0x2d)]===_0xc9b7f[_0x3061(0x2d)])throw new Error(_0x3061(0x2e));else{_0x2d493b[_0x3061(0xe)](_0xc9b7f[_0x3061(0x2f)]);throw new _0x4e6162(_0xc9b7f['BgbvR']);}}const _0x76d3f=[_0xc9b7f[_0x3061(0x30)],_0xc9b7f['YjSGz'],_0xc9b7f[_0x3061(0x31)]],_0xa4b9fb=_0x76d3f[_0x3061(0x32)](_0x7f4c07=>_0x230051[_0x3061(0x2b)][_0x3061(0x33)](_0x7f4c07));if(!_0xa4b9fb)throw new Error(_0xc9b7f['GjrBs']);globalConfig={'apiKey':_0x230051[_0x3061(0x2b)],'environment':_0x230051[_0x3061(0x34)]||_0xc9b7f[_0x3061(0x35)],'enableLogging':_0xc9b7f['ZvkFN'](_0x230051[_0x3061(0x36)],![]),'timeout':_0x230051[_0x3061(0x20)]||0x7530,'retryAttempts':_0x230051[_0x3061(0x37)]||0x3};globalConfig[_0x3061(0x36)]&&console['log'](_0xc9b7f[_0x3061(0x38)],{'environment':globalConfig[_0x3061(0x34)],'timeout':globalConfig['timeout'],'retryAttempts':globalConfig[_0x3061(0x37)],'apiKeyPrefix':_0xc9b7f[_0x3061(0x39)](_0x230051['apiKey']['substring'](0x0,0x8),_0xc9b7f[_0x3061(0x3a)]),'enableLogging':globalConfig[_0x3061(0x36)]});const _0x13c073=await _0xc9b7f['tdTIb'](validateApiKey,_0x230051[_0x3061(0x2b)]);if(!_0x13c073['isValid']){if(_0xc9b7f[_0x3061(0x3b)]('yhhXP',_0xc9b7f[_0x3061(0x3c)])){const _0x3cc7e4=_0x13c073[_0x3061(0xe)]||'',_0x1328b3=_0x13c073[_0x3061(0x3d)]||_0x3cc7e4[_0x3061(0x3e)](_0x3061(0x3f))||_0x3cc7e4[_0x3061(0x3e)](_0xc9b7f[_0x3061(0x40)])||_0x3cc7e4['includes'](_0xc9b7f[_0x3061(0x41)])||_0x3cc7e4[_0x3061(0x3e)]('API\x20validation\x20endpoint\x20returned')||_0x3cc7e4['includes'](_0xc9b7f['GvboP'])||_0x3cc7e4[_0x3061(0x3e)](_0xc9b7f[_0x3061(0x42)])||_0x3cc7e4['includes'](_0xc9b7f[_0x3061(0x43)])||_0x3cc7e4[_0x3061(0x3e)](_0xc9b7f[_0x3061(0x44)]);if(_0x1328b3){if(_0x3061(0x45)===_0xc9b7f['rchLy'])_0x32fdcd=_0x3061(0x46)+_0x1de484['message'];else{const _0x457b90=_0x3061(0x47)[_0x3061(0x48)]('|');let _0x1bc17f=0x0;while(!![]){switch(_0x457b90[_0x1bc17f++]){case'0':console[_0x3061(0x10)](_0xc9b7f['QZoAv']);continue;case'1':console['warn']('⚠️\x20API\x20key\x20validation\x20failed\x20due\x20to\x20network/connectivity\x20issues');continue;case'2':console['log'](_0xc9b7f[_0x3061(0x49)]);continue;case'3':console[_0x3061(0x10)](_0xc9b7f[_0x3061(0x4a)],_0x13c073['error']);continue;case'4':console['warn'](_0xc9b7f[_0x3061(0x4b)]);continue;}break;}}}else throw new Error(_0x3061(0x4c)+_0x13c073['error']);}else return null;}await _0xc9b7f[_0x3061(0x4d)](loadJWT),isInitialized=!![];if(globalConfig[_0x3061(0x36)]){console[_0x3061(0x29)](_0xc9b7f[_0x3061(0x4e)]),console[_0x3061(0x29)](_0xc9b7f[_0x3061(0x4f)]);userToken&&console[_0x3061(0x29)](_0xc9b7f[_0x3061(0x50)]);if(_0x13c073[_0x3061(0x51)]){if(_0xc9b7f[_0x3061(0x52)](_0xc9b7f[_0x3061(0x53)],_0xc9b7f[_0x3061(0x54)]))console['log'](_0xc9b7f[_0x3061(0x55)],_0x13c073['permissions']);else{_0xc9b7f[_0x3061(0x56)](_0x38dc2e,_0xc09f30);if(_0x6783bc[_0x3061(0x57)]===_0xc9b7f[_0x3061(0x58)]){_0x167a8a[_0x3061(0xe)](_0xc9b7f['GgZtR'],_0x36322f);throw new _0xd85537('Request\x20timeout');}throw _0x14d2ba;}}_0x13c073['rateLimits']&&console[_0x3061(0x29)](_0xc9b7f[_0x3061(0x59)],_0x13c073['rateLimits']);}}catch(_0x48cc5f){console['error']('❌\x20Failed\x20to\x20initialize\x20Onairos\x20SDK:',_0x48cc5f),isInitialized=![];throw _0x48cc5f;}};export const getApiKeyType=_0x2673d7=>{const _0x2eacfd={'ULHCC':function(_0x54b3a5,_0x3f7af2){return _0x54b3a5>=_0x3f7af2;},'SXRab':_0x3061(0x19)};if(_0x2eacfd[_0x3061(0x5a)](_0x2673d7['length'],0x20)&&(_0x2673d7[_0x3061(0x33)](_0x3061(0x17))||_0x2673d7[_0x3061(0x33)](_0x2eacfd[_0x3061(0x5b)])||_0x2673d7[_0x3061(0x33)](_0x3061(0x18))))return ApiKeyType[_0x3061(0x0)];return ApiKeyType['INVALID'];};export const validateApiKey=async _0x1c0ffb=>{const _0x5c1467={'vjWoZ':'❌\x20Failed\x20to\x20initialize\x20Onairos\x20SDK:','DzcAw':function(_0x18fe35,_0x53da58){return _0x18fe35|_0x53da58;},'NqHKF':function(_0x3fe262,_0x3d591b){return _0x3fe262<<_0x3d591b;},'dBRqj':function(_0x4efdaf,_0x3957c6){return _0x4efdaf<<_0x3957c6;},'KcYEA':function(_0x344a7b,_0x4edd65){return _0x344a7b<<_0x4edd65;},'jYHeJ':function(_0x1dcbac,_0x1d0991){return _0x1dcbac&_0x1d0991;},'RuUXB':function(_0x36937a,_0x40a2ba){return _0x36937a>>_0x40a2ba;},'pFncE':function(_0x87dece,_0x5f96fe){return _0x87dece!==_0x5f96fe;},'OXuMc':function(_0x57db2a,_0x8a82fa){return _0x57db2a>>_0x8a82fa;},'fGftX':'Onairos\x20API\x20is\x20under\x20maintenance\x20(503\x20Service\x20Unavailable).\x20Please\x20try\x20again\x20later.','dhkZX':_0x3061(0x5c),'DcCbc':function(_0x4b7dde,_0xc737f9){return _0x4b7dde>=_0xc737f9;},'lZzLE':'dev_','otWZc':_0x3061(0x19),'uENsg':_0x3061(0x5d),'fNLOk':function(_0x526100,_0x3b271b){return _0x526100===_0x3b271b;},'nkUMw':function(_0xf65441,_0x38ee26){return _0xf65441===_0x38ee26;},'iPNrv':function(_0x1001f1,_0x438e1b){return _0x1001f1===_0x438e1b;},'MiJMd':function(_0x258db5,_0xe2a087){return _0x258db5===_0xe2a087;},'Wnpae':function(_0xcb8b9,_0x31eae8){return _0xcb8b9===_0x31eae8;},'hstzp':'Network\x20request\x20failed','Rvtvc':_0x3061(0x5e),'IULOT':_0x3061(0x1f),'vdDhB':'API\x20validation\x20endpoint\x20returned','zaOvE':'timeout','Feraq':'ENOTFOUND','wiFWp':_0x3061(0x8),'xRvdp':_0x3061(0x23),'hjvzM':_0x3061(0x22),'sTiqu':_0x3061(0x5f),'zTxrN':'❌\x20Failed\x20to\x20parse\x20JSON\x20response:','bWHJS':_0x3061(0x60),'HqbOf':function(_0x59ab25,_0x479980){return _0x59ab25(_0x479980);},'lwfZM':function(_0x3eb904,_0x67a9c4){return _0x3eb904<_0x67a9c4;},'IEnYr':function(_0xe438b7,_0x585936){return _0xe438b7===_0x585936;},'ycmsi':_0x3061(0x61),'eGnZE':_0x3061(0x62),'pnXem':'⚠️\x20No\x20network\x20connectivity\x20detected','FqUqn':_0x3061(0x63),'cpETT':function(_0xb0a185,_0x4ba789){return _0xb0a185===_0x4ba789;},'bWOAk':function(_0x500966,_0x1bd179){return _0x500966===_0x1bd179;},'rFNJv':_0x3061(0x64),'hPqqj':function(_0x4cd9b7,_0x2617ef,_0x14c32b){return _0x4cd9b7(_0x2617ef,_0x14c32b);},'tGCyZ':function(_0xdfe0b4,_0x2b131e){return _0xdfe0b4>_0x2b131e;},'EsWLV':_0x3061(0x65),'gWfXO':_0x3061(0x66),'XyTvo':_0x3061(0x67),'CrTkD':function(_0x105655,_0x144e09){return _0x105655===_0x144e09;},'CmGcZ':_0x3061(0x68),'RbQkk':function(_0x8fd616,_0x567d6f){return _0x8fd616===_0x567d6f;},'RjGWe':function(_0x48f6b5,_0xd8199){return _0x48f6b5===_0xd8199;},'xFMXZ':function(_0x3c1626,_0x7cb4fa){return _0x3c1626===_0x7cb4fa;},'bLgqE':'ZLeFU','TTOyZ':_0x3061(0x69),'sflwg':'content-type','hwacY':_0x3061(0x6a),'uzlYP':function(_0xec9f74,_0x1d7b0b){return _0xec9f74||_0x1d7b0b;},'RNdaP':'unknown','lFRUa':function(_0xa9f349,_0x13893b){return _0xa9f349===_0x13893b;},'lbaQK':function(_0x39ad2b,_0x2f5bce){return _0x39ad2b===_0x2f5bce;},'oZKWm':_0x3061(0x6b),'bxGjx':_0x3061(0x6c),'whJYU':function(_0x17669b,_0x37d79e){return _0x17669b===_0x37d79e;},'AuAiQ':_0x3061(0x6d),'sBxmC':_0x3061(0x6e),'PfcbU':_0x3061(0x6f),'ZZSkY':_0x3061(0x70),'FjORR':_0x3061(0x71),'tEWrR':function(_0x51a3a,_0x2ea6e8){return _0x51a3a!==_0x2ea6e8;},'SpAbD':function(_0x3adbfe,_0x53edc1){return _0x3adbfe===_0x53edc1;},'Wmbxa':function(_0x3356ef,_0x1ec35b){return _0x3356ef===_0x1ec35b;},'mJGkL':function(_0x5263b9,_0x38eb95){return _0x5263b9===_0x38eb95;},'LMBDw':function(_0x2c790e,_0x25cb78){return _0x2c790e<_0x25cb78;},'WKkUp':function(_0x317286,_0x110106){return _0x317286!==_0x110106;},'DHsZf':function(_0x591507,_0x416765){return _0x591507!==_0x416765;},'uMQRh':_0x3061(0x72),'pwzQh':_0x3061(0x73),'cgcRb':'AbortError','TwbpR':_0x3061(0x74),'RuUdR':_0x3061(0x75),'DROXB':function(_0x429b3a,_0x4f744c){return _0x429b3a===_0x4f744c;},'gWQnV':_0x3061(0x76),'shCuh':function(_0x263ab4,_0x1595b3){return _0x263ab4===_0x1595b3;},'twQfM':_0x3061(0x77),'NyFXM':'rXEXV','azyRw':_0x3061(0x78),'fZbwt':function(_0x38e157,_0x5ef93f){return _0x38e157===_0x5ef93f;},'yumpQ':function(_0xbf76b7,_0x428c7a){return _0xbf76b7*_0x428c7a;},'PlbVg':function(_0x30154d,_0x4d2855){return _0x30154d-_0x4d2855;},'UYaHm':function(_0x36caa2,_0x2c5d8d){return _0x36caa2!==_0x2c5d8d;},'kGGLU':_0x3061(0x79),'jQNSI':_0x3061(0x7a),'zKiXn':'All\x20retry\x20attempts\x20exhausted','hCEvI':_0x3061(0x7b)};try{var _0x4eb900,_0x17ae40,_0x3e1091;console[_0x3061(0x29)](_0x5c1467[_0x3061(0x7c)]);const _0x936f78=_0x5c1467[_0x3061(0x7d)](getApiKeyType,_0x1c0ffb);if(_0x5c1467[_0x3061(0x7e)](_0x936f78,ApiKeyType[_0x3061(0x2)]))return{'isValid':![],'error':_0x3061(0x7f),'keyType':ApiKeyType[_0x3061(0x2)]};const _0x2788fa=validationCache[_0x3061(0x80)](_0x1c0ffb);if(_0x2788fa&&_0x5c1467[_0x3061(0x81)](Date[_0x3061(0x82)]()-_0x2788fa['timestamp'],CACHE_DURATION)){var _0x53077d;return _0x5c1467[_0x3061(0x83)](_0x53077d=globalConfig,null)&&_0x53077d!==void 0x0&&_0x53077d[_0x3061(0x36)]&&(_0x5c1467[_0x3061(0x84)](_0x5c1467[_0x3061(0x85)],_0x5c1467[_0x3061(0x85)])?console[_0x3061(0x29)](_0x5c1467['eGnZE']):_0x52f355[_0x3061(0x29)]('📡\x20User\x20request\x20response:\x20'+_0x4561aa[_0x3061(0x86)]+_0x3061(0x87)+_0x37af4c)),_0x2788fa['result'];}const _0x2b0ce0=await checkNetworkConnectivity();if(!_0x2b0ce0)return console[_0x3061(0x10)](_0x5c1467[_0x3061(0x88)]),{'isValid':![],'error':_0x5c1467[_0x3061(0x89)],'keyType':_0x936f78,'isNetworkError':!![]};const _0x16d1cf=(_0x5c1467[_0x3061(0x84)](_0x4eb900=globalConfig,null)||_0x5c1467['MiJMd'](_0x4eb900,void 0x0)?void 0x0:_0x4eb900[_0x3061(0x34)])||_0x3061(0x1b),_0x38d68a=API_ENDPOINTS[_0x16d1cf],_0x350cd8=(_0x5c1467[_0x3061(0x8a)](_0x17ae40=globalConfig,null)||_0x17ae40===void 0x0?void 0x0:_0x17ae40[_0x3061(0x20)])||0x7530,_0x2eb3e0=((_0x3e1091=globalConfig)===null||_0x5c1467[_0x3061(0x8b)](_0x3e1091,void 0x0)?void 0x0:_0x3e1091[_0x3061(0x37)])||0x3;for(let _0x51997f=0x1;_0x51997f<=_0x2eb3e0;_0x51997f++){if(_0x5c1467[_0x3061(0x8c)](_0x5c1467['rFNJv'],_0x5c1467[_0x3061(0x8d)])){const _0x71dadf=new AbortController(),_0x4b1664=_0x5c1467['hPqqj'](setTimeout,()=>_0x71dadf[_0x3061(0x8e)](),_0x350cd8);try{var _0xc10193;(_0xc10193=globalConfig)!==null&&_0x5c1467['pFncE'](_0xc10193,void 0x0)&&_0xc10193[_0x3061(0x36)]&&_0x5c1467['tGCyZ'](_0x51997f,0x1)&&console[_0x3061(0x29)](_0x3061(0x8f)+_0x51997f+'/'+_0x2eb3e0+_0x3061(0x90));const _0x103cf2=await fetch(_0x38d68a+_0x3061(0x91),{'method':'POST','headers':{'Content-Type':'application/json','Authorization':'Bearer\x20'+_0x1c0ffb,'User-Agent':_0x5c1467['EsWLV'],'X-API-Key-Type':_0x936f78,'X-SDK-Platform':'react-native','X-Retry-Attempt':_0x51997f[_0x3061(0x92)]()},'body':JSON[_0x3061(0x93)]({'environment':_0x16d1cf,'sdk_version':_0x5c1467[_0x3061(0x94)],'platform':'react-native','keyType':_0x936f78,'timestamp':new Date()[_0x3061(0x95)](),'attempt':_0x51997f}),'signal':_0x71dadf['signal']});clearTimeout(_0x4b1664);if(!_0x103cf2)throw new Error(_0x5c1467[_0x3061(0x96)]);if(_0x5c1467[_0x3061(0x97)](_0x103cf2['status'],0x1f6))throw new Error(_0x5c1467[_0x3061(0x98)]);if(_0x5c1467['RbQkk'](_0x103cf2[_0x3061(0x86)],0x1f7))throw new Error(_0x5c1467[_0x3061(0x99)]);if(_0x5c1467['RjGWe'](_0x103cf2['status'],0x1f8)){if(_0x5c1467[_0x3061(0x9a)](_0x3061(0x9b),_0x5c1467[_0x3061(0x9c)])){_0x577af1[_0x3061(0xe)](_0x5c1467[_0x3061(0x9d)],_0x1c2372),_0x1394fb=![];throw _0x4227bd;}else throw new Error(_0x5c1467['TTOyZ']);}const _0x452fcc=_0x103cf2[_0x3061(0x9e)][_0x3061(0x80)](_0x5c1467[_0x3061(0x9f)]),_0x210168=_0x452fcc&&_0x452fcc[_0x3061(0x3e)]('application/json');if(!_0x210168){const _0x19b900=await _0x103cf2[_0x3061(0xa0)](),_0x3e447e=_0x19b900['substring'](0x0,0xc8);console[_0x3061(0xe)](_0x5c1467[_0x3061(0xa1)],{'status':_0x103cf2['status'],'statusText':_0x103cf2['statusText'],'contentType':_0x5c1467[_0x3061(0xa2)](_0x452fcc,_0x5c1467[_0x3061(0xa3)]),'preview':_0x3e447e,'url':_0x38d68a+_0x3061(0x91),'attempt':_0x51997f});if(_0x5c1467[_0x3061(0xa4)](_0x103cf2[_0x3061(0x86)],0x194)){if(_0x5c1467[_0x3061(0xa5)](_0x5c1467['oZKWm'],_0x5c1467[_0x3061(0xa6)])){const _0xbbbd6a=_0x378dfb['indexOf'](_0x7feb92['charAt'](_0x4948de++)),_0x22203b=_0x3e8a5a[_0x3061(0xa7)](_0x5db82b['charAt'](_0x5bf4d5++)),_0x4fb0ab=_0x1f441f[_0x3061(0xa7)](_0x31ed78[_0x3061(0xa8)](_0x3f6340++)),_0x236fe1=_0x4b46d8['indexOf'](_0x11536c[_0x3061(0xa8)](_0xf2b18d++)),_0x10783c=_0x5c1467[_0x3061(0xa9)](_0x5c1467[_0x3061(0xaa)](_0xbbbd6a,0x12),_0x5c1467[_0x3061(0xab)](_0x22203b,0xc))|_0x5c1467[_0x3061(0xac)](_0x4fb0ab,0x6)|_0x236fe1;_0x3c64b8+=_0x4e9245[_0x3061(0xad)](_0x5c1467[_0x3061(0xae)](_0x5c1467['RuUXB'](_0x10783c,0x10),0xff));if(_0x5c1467['pFncE'](_0x4fb0ab,0x40))_0x55d1ba+=_0x4ae3f8[_0x3061(0xad)](_0x5c1467[_0x3061(0xae)](_0x5c1467[_0x3061(0xaf)](_0x10783c,0x8),0xff));if(_0x236fe1!==0x40)_0x1272a6+=_0x57f0b4[_0x3061(0xad)](_0x10783c&0xff);}else throw new Error(_0x3061(0xb0)+_0x38d68a+_0x3061(0xb1));}else{if(_0x5c1467[_0x3061(0x8a)](_0x103cf2[_0x3061(0x86)],0x1f4))throw new Error(_0x3061(0xb2));else{if(_0x5c1467[_0x3061(0xa4)](_0x103cf2[_0x3061(0x86)],0x1f6)||_0x5c1467[_0x3061(0xb3)](_0x103cf2[_0x3061(0x86)],0x1f7))throw new Error(_0x3061(0xb4)+_0x103cf2[_0x3061(0x86)]+_0x3061(0xb5));else{if(_0x19b900[_0x3061(0x3e)](_0x5c1467[_0x3061(0xb6)])||_0x19b900['includes'](_0x5c1467[_0x3061(0xb7)]))throw new Error('Server\x20returned\x20HTML\x20page\x20instead\x20of\x20JSON\x20API\x20response.\x20This\x20often\x20indicates\x20a\x20routing\x20issue\x20or\x20server\x20misconfiguration.');else throw new Error('API\x20validation\x20endpoint\x20returned\x20'+_0x103cf2[_0x3061(0x86)]+_0x3061(0xb8)+_0x103cf2[_0x3061(0xb9)]+_0x3061(0xba)+(_0x452fcc||_0x5c1467[_0x3061(0xbb)])+'.');}}}}let _0x3c6d73;try{if(_0x5c1467['ZZSkY']!==_0x5c1467[_0x3061(0xbc)])_0x3c6d73=await _0x103cf2[_0x3061(0xbd)]();else throw new _0x27e65d(_0x5c1467[_0x3061(0x99)]);}catch(_0xefb4e){console[_0x3061(0xe)](_0x5c1467[_0x3061(0xbe)],{'error':_0xefb4e[_0x3061(0xbf)],'status':_0x103cf2[_0x3061(0x86)],'contentType':_0x452fcc,'attempt':_0x51997f});throw new Error('Failed\x20to\x20parse\x20server\x20response\x20as\x20JSON:\x20'+_0xefb4e[_0x3061(0xbf)]);}if(_0x103cf2['ok']&&(_0x3c6d73[_0x3061(0xc0)]||_0x3c6d73['valid'])){var _0x30964a;const _0x5a524f={'isValid':!![],'permissions':_0x3c6d73[_0x3061(0x51)]||[],'rateLimits':_0x3c6d73[_0x3061(0xc1)]||null,'keyType':_0x936f78};validationCache[_0x3061(0xc2)](_0x1c0ffb,{'result':_0x5a524f,'timestamp':Date[_0x3061(0x82)]()});if(_0x5c1467[_0x3061(0x83)](_0x30964a=globalConfig,null)&&_0x5c1467[_0x3061(0xc3)](_0x30964a,void 0x0)&&_0x30964a[_0x3061(0x36)]){var _0x5b70ef,_0x35d74f,_0x4d0783;console[_0x3061(0x29)](_0x5c1467[_0x3061(0xc4)],{'apiKeyId':(_0x5b70ef=_0x3c6d73[_0x3061(0x2b)])===null||_0x5c1467[_0x3061(0x8c)](_0x5b70ef,void 0x0)?void 0x0:_0x5b70ef['id'],'appName':(_0x35d74f=_0x3c6d73[_0x3061(0xc5)])===null||_0x5c1467['SpAbD'](_0x35d74f,void 0x0)?void 0x0:_0x35d74f[_0x3061(0x57)],'usageCount':_0x5c1467[_0x3061(0xc6)](_0x4d0783=_0x3c6d73[_0x3061(0x2b)],null)||_0x5c1467[_0x3061(0xc7)](_0x4d0783,void 0x0)?void 0x0:_0x4d0783[_0x3061(0xc8)]});}return _0x5a524f;}else{const _0x45033a=_0x3c6d73[_0x3061(0xe)]||_0x3c6d73['message']||_0x3061(0xc9)+_0x103cf2['status']+':\x20'+_0x103cf2[_0x3061(0xb9)],_0x17b4d6={'isValid':![],'error':_0x45033a,'keyType':_0x936f78};if(_0x5c1467[_0x3061(0xca)](_0x103cf2[_0x3061(0x86)],0x190)&&_0x5c1467['LMBDw'](_0x103cf2[_0x3061(0x86)],0x1f4)){var _0x326a75;if(_0x5c1467[_0x3061(0xcb)](_0x326a75=globalConfig,null)&&_0x5c1467[_0x3061(0xcc)](_0x326a75,void 0x0)&&_0x326a75['enableLogging']){if(_0x3061(0xcd)!==_0x5c1467[_0x3061(0xce)])console[_0x3061(0xe)](_0x5c1467[_0x3061(0xcf)],_0x45033a);else throw new _0x3dcd65(_0x5c1467['dhkZX']);}return _0x17b4d6;}throw new Error(_0x45033a);}}catch(_0xbf93d9){var _0x2b1941;_0x5c1467['HqbOf'](clearTimeout,_0x4b1664);if(_0x5c1467['lbaQK'](_0xbf93d9['name'],_0x5c1467[_0x3061(0xd0)])){const _0x513af6=_0x3061(0xd1)+_0x350cd8+_0x3061(0xd2);console['error'](_0x5c1467[_0x3061(0xd3)]);if(_0x5c1467[_0x3061(0xb3)](_0x51997f,_0x2eb3e0))return{'isValid':![],'error':_0x513af6,'keyType':_0x936f78};continue;}let _0x3f7875='Network\x20error\x20during\x20API\x20key\x20validation:\x20'+_0xbf93d9[_0x3061(0xbf)];if(_0xbf93d9['message'][_0x3061(0x3e)](_0x5c1467[_0x3061(0xd4)])||_0xbf93d9['message'][_0x3061(0x3e)](_0x5c1467['RuUdR']))_0x5c1467[_0x3061(0xd5)](_0x5c1467[_0x3061(0xd6)],_0x5c1467[_0x3061(0xd6)])?_0x3f7875=_0x3061(0x46)+_0xbf93d9['message']:_0x5e5cb2['log'](_0x3061(0xd7)+_0x2117c8[_0x3061(0x86)]+'\x20for\x20'+_0x58ea47);else{if(_0xbf93d9['message'][_0x3061(0x3e)](_0x5c1467['hstzp'])||_0xbf93d9[_0x3061(0xbf)][_0x3061(0x3e)](_0x5c1467[_0x3061(0xd8)])){if(_0x5c1467[_0x3061(0xd9)](_0x3061(0xda),_0x5c1467[_0x3061(0xdb)])){if(_0x5c1467[_0x3061(0xca)](_0x23d5c4[_0x3061(0x2c)],0x20)&&(_0x2a5ca8[_0x3061(0x33)](_0x5c1467[_0x3061(0xdc)])||_0x2fbb87[_0x3061(0x33)](_0x5c1467[_0x3061(0xdd)])||_0xe250a1[_0x3061(0x33)](_0x3061(0x18))))return _0x4e3401['DEVELOPER'];return _0x318a62[_0x3061(0x2)];}else _0x3f7875=_0x3061(0xde)+_0xbf93d9[_0x3061(0xbf)];}else{if(_0xbf93d9[_0x3061(0xbf)][_0x3061(0x3e)](_0x3061(0xdf))||_0xbf93d9['message'][_0x3061(0x3e)](_0x5c1467[_0x3061(0xe0)])){if(_0x5c1467[_0x3061(0x83)](_0x5c1467[_0x3061(0xe1)],_0x5c1467[_0x3061(0xe1)])){var _0x2e5cee,_0xd634d4,_0x239e73;_0x1f24c4[_0x3061(0x29)](_0x5c1467[_0x3061(0xc4)],{'apiKeyId':_0x5c1467[_0x3061(0xe2)](_0x2e5cee=_0x32affc[_0x3061(0x2b)],null)||_0x5c1467['nkUMw'](_0x2e5cee,void 0x0)?void 0x0:_0x2e5cee['id'],'appName':_0x5c1467[_0x3061(0xe2)](_0xd634d4=_0x534c7a['application'],null)||_0x5c1467['iPNrv'](_0xd634d4,void 0x0)?void 0x0:_0xd634d4[_0x3061(0x57)],'usageCount':_0x5c1467[_0x3061(0xe3)](_0x239e73=_0x50d4ff['apiKey'],null)||_0x5c1467['Wnpae'](_0x239e73,void 0x0)?void 0x0:_0x239e73[_0x3061(0xc8)]});}else _0x3f7875=_0x3061(0xe4)+_0x38d68a+_0x3061(0xe5)+_0xbf93d9['message'];}}}console[_0x3061(0xe)](_0x5c1467[_0x3061(0xe6)],{'error':_0xbf93d9,'endpoint':_0x38d68a+_0x3061(0x91),'attempt':_0x51997f,'maxRetries':_0x2eb3e0,'retryable':_0x51997f<_0x2eb3e0});if(_0x5c1467[_0x3061(0xe7)](_0x51997f,_0x2eb3e0))return{'isValid':![],'error':_0x3f7875,'keyType':_0x936f78,'isNetworkError':!![]};const _0x4a9f17=Math['min'](_0x5c1467[_0x3061(0xe8)](0x3e8,Math['pow'](0x2,_0x5c1467[_0x3061(0xe9)](_0x51997f,0x1))),0x1388);if(_0x5c1467['pFncE'](_0x2b1941=globalConfig,null)&&_0x2b1941!==void 0x0&&_0x2b1941[_0x3061(0x36)]){if(_0x5c1467[_0x3061(0xea)](_0x5c1467[_0x3061(0xeb)],_0x5c1467['jQNSI']))console[_0x3061(0x29)](_0x3061(0xec)+_0x4a9f17+_0x3061(0xed));else{const _0x333503=_0x4f9e4f[_0x3061(0xe)]||'',_0x1f5041=_0x583567[_0x3061(0x3d)]||_0x333503[_0x3061(0x3e)](_0x5c1467['hstzp'])||_0x333503['includes'](_0x5c1467['Rvtvc'])||_0x333503[_0x3061(0x3e)](_0x5c1467[_0x3061(0xd4)])||_0x333503[_0x3061(0x3e)](_0x5c1467[_0x3061(0xee)])||_0x333503['includes'](_0x5c1467[_0x3061(0xef)])||_0x333503[_0x3061(0x3e)](_0x5c1467[_0x3061(0xe0)])||_0x333503['includes'](_0x5c1467[_0x3061(0xd8)])||_0x333503[_0x3061(0x3e)](_0x3061(0x21));if(_0x1f5041){const _0x30fc90=_0x3061(0xf0)[_0x3061(0x48)]('|');let _0x4afdcd=0x0;while(!![]){switch(_0x30fc90[_0x4afdcd++]){case'0':_0x3f91aa[_0x3061(0x29)](_0x3061(0xf1));continue;case'1':_0x5837f1[_0x3061(0x10)](_0x3061(0xf2),_0x148755[_0x3061(0xe)]);continue;case'2':_0x54996f[_0x3061(0x10)](_0x5c1467[_0x3061(0xf3)]);continue;case'3':_0x1e908a[_0x3061(0x10)](_0x3061(0xf4));continue;case'4':_0x44f7fc[_0x3061(0x10)](_0x5c1467[_0x3061(0xf5)]);continue;}break;}}else throw new _0x341a5e(_0x3061(0x4c)+_0x246207[_0x3061(0xe)]);}}await new Promise(_0x34768e=>setTimeout(()=>_0x34768e(),_0x4a9f17));}}else{const _0x5b8e3a=_0x3061(0xf6)+_0x164cc3[_0x3061(0xbf)];return _0x13bd77[_0x3061(0xe)](_0x5c1467[_0x3061(0xf7)],_0x31d433),{'isValid':![],'error':_0x5b8e3a,'keyType':_0x2ca2d5[_0x3061(0x2)]};}}return{'isValid':![],'error':_0x5c1467[_0x3061(0xf8)],'keyType':_0x936f78};}catch(_0x10c3dc){if(_0x5c1467['pFncE'](_0x5c1467[_0x3061(0xf9)],_0x3061(0xfa))){const _0x4f4c18=_0x3061(0xf6)+_0x10c3dc['message'];return console[_0x3061(0xe)](_0x3061(0x5f),_0x10c3dc),{'isValid':![],'error':_0x4f4c18,'keyType':ApiKeyType['INVALID']};}else{_0x11881b[_0x3061(0xe)](_0x5c1467['zTxrN'],{'error':_0x41df45[_0x3061(0xbf)],'status':_0x3d9836[_0x3061(0x86)],'contentType':_0x4d2d8d,'attempt':_0x113d55});throw new _0x24ae80('Failed\x20to\x20parse\x20server\x20response\x20as\x20JSON:\x20'+_0x3cc97f['message']);}}};export const getApiConfig=()=>{return globalConfig;};export const getApiKey=()=>{const _0x13f70b={'gmgOy':function(_0x24b22d,_0x39a010){return _0x24b22d===_0x39a010;}};var _0x59966b;return((_0x59966b=globalConfig)===null||_0x13f70b[_0x3061(0xfb)](_0x59966b,void 0x0)?void 0x0:_0x59966b['apiKey'])||null;};export const isApiKeyInitialized=()=>{const _0x203898={'nyNsa':function(_0x59196b,_0x719a97){return _0x59196b!==_0x719a97;}};return isInitialized&&_0x203898[_0x3061(0xfc)](globalConfig,null);};export const storeJWT=async _0x4c59fa=>{const _0x4539ca={'eCpmw':function(_0x501172,_0x26b2e1){return _0x501172===_0x26b2e1;},'dKAQt':_0x3061(0xfd),'shuoc':_0x3061(0xfe),'deGNl':function(_0x17d368,_0x1c5d7c){return _0x17d368!==_0x1c5d7c;},'Zxslu':function(_0x294d7d,_0x596750){return _0x294d7d===_0x596750;},'VzTDT':_0x3061(0xff)};try{if(_0x4539ca[_0x3061(0x100)](_0x4539ca[_0x3061(0x101)],_0x4539ca['shuoc']))_0x36fc35[_0x3061(0x29)]('⏳\x20Waiting\x20'+_0x16504f+_0x3061(0xed));else{var _0x47d9fe;await AsyncStorage[_0x3061(0x102)](JWT_TOKEN_KEY,_0x4c59fa),userToken=_0x4c59fa,_0x4539ca[_0x3061(0x103)](_0x47d9fe=globalConfig,null)&&_0x47d9fe!==void 0x0&&_0x47d9fe['enableLogging']&&console['log']('🎫\x20JWT\x20token\x20stored\x20successfully');}}catch(_0x46105e){if(_0x4539ca['Zxslu'](_0x3061(0x104),_0x4539ca['VzTDT']))return _0x35720a;else{console[_0x3061(0xe)](_0x3061(0x105),_0x46105e);throw _0x46105e;}}};export const loadJWT=async()=>{const _0x16e6c8={'SZWls':_0x3061(0x5c),'wRVIu':function(_0x2840e8,_0x31de15){return _0x2840e8===_0x31de15;}};try{if(_0x16e6c8['wRVIu'](_0x3061(0x106),_0x3061(0x107)))throw new _0x555c55(_0x16e6c8[_0x3061(0x108)]);else{const _0x4e4e28=await AsyncStorage[_0x3061(0x109)](JWT_TOKEN_KEY);return userToken=_0x4e4e28,_0x4e4e28;}}catch(_0x4aeaaa){return console['error'](_0x3061(0x10a),_0x4aeaaa),null;}};export const getJWT=()=>{return userToken;};export const clearJWT=async()=>{const _0x328901={'MUKFO':_0x3061(0x10b),'ZlaWZ':'Request\x20timeout','tjZlb':function(_0x37d30c,_0x12ece4){return _0x37d30c!==_0x12ece4;},'snnEd':_0x3061(0x5c),'KOzOb':function(_0x3cc37f,_0x5698cc){return _0x3cc37f(_0x5698cc);},'ShLjX':'OnairosSDK/1.0.0','NDaBX':_0x3061(0x10c),'uJjpH':_0x3061(0x1b),'yGIzB':_0x3061(0x10d),'UdjYG':'🗑️\x20JWT\x20token\x20cleared','Cqdes':_0x3061(0x10e),'kpazs':_0x3061(0x10f)};try{var _0x2a8756;await AsyncStorage[_0x3061(0x110)](JWT_TOKEN_KEY),userToken=null;if(_0x328901[_0x3061(0x111)](_0x2a8756=globalConfig,null)&&_0x2a8756!==void 0x0&&_0x2a8756[_0x3061(0x36)]){if(_0x328901[_0x3061(0x112)]===_0x328901[_0x3061(0x112)])console[_0x3061(0x29)](_0x328901[_0x3061(0x113)]);else{_0x292c0a[_0x3061(0xe)](_0x328901[_0x3061(0x114)],_0x3f2c9b);throw new _0x2c32dd(_0x328901[_0x3061(0x115)]);}}}catch(_0x33264c){if(_0x328901['Cqdes']===_0x328901['Cqdes'])console[_0x3061(0xe)](_0x328901[_0x3061(0x116)],_0x33264c);else{var _0x15a357;if(!(_0x328901[_0x3061(0x111)](_0x15a357=_0x1f23de,null)&&_0x328901['tjZlb'](_0x15a357,void 0x0)&&_0x15a357[_0x3061(0x2b)]))throw new _0xc3902e(_0x328901[_0x3061(0x117)]);const _0x136b2d=_0x328901[_0x3061(0x118)](_0x50f114,_0x5f4c11[_0x3061(0x2b)]);return{'Content-Type':'application/json','Authorization':_0x3061(0x119)+_0x5f3b3c[_0x3061(0x2b)],'User-Agent':_0x328901[_0x3061(0x11a)],'X-SDK-Version':_0x328901['NDaBX'],'X-SDK-Environment':_0x45cfb9[_0x3061(0x34)]||_0x328901['uJjpH'],'X-API-Key-Type':_0x136b2d,'X-Timestamp':new _0x18a01a()[_0x3061(0x95)]()};}}};const base64Decode=_0x51de02=>{const _0x4adc07={'AmWih':_0x3061(0x11b),'yyLHp':function(_0x551e25,_0x1f2148){return _0x551e25<_0x1f2148;},'gczsU':function(_0x689048,_0x3713e4){return _0x689048|_0x3713e4;},'XPRyV':function(_0x1475a9,_0x5300da){return _0x1475a9|_0x5300da;},'VNbKh':function(_0x24081f,_0x21368f){return _0x24081f<<_0x21368f;},'kDltx':function(_0x3d923b,_0x7e2971){return _0x3d923b<<_0x7e2971;},'utgoG':function(_0x522293,_0x76fc87){return _0x522293&_0x76fc87;},'Rgslc':function(_0x595f0a,_0xf118c2){return _0x595f0a!==_0xf118c2;},'WEpla':function(_0x730b46,_0x324544){return _0x730b46&_0x324544;},'QHLbh':function(_0x236199,_0x2b6069){return _0x236199>>_0x2b6069;}},_0x2765d4=_0x4adc07[_0x3061(0x11c)];let _0x13a507='',_0x4d4fa6=0x0;_0x51de02=_0x51de02[_0x3061(0x11d)](/[^A-Za-z0-9+/]/g,'');while(_0x4adc07['yyLHp'](_0x4d4fa6,_0x51de02[_0x3061(0x2c)])){const _0x25e2ce=_0x2765d4[_0x3061(0xa7)](_0x51de02[_0x3061(0xa8)](_0x4d4fa6++)),_0xa8971=_0x2765d4[_0x3061(0xa7)](_0x51de02[_0x3061(0xa8)](_0x4d4fa6++)),_0x7b30dc=_0x2765d4['indexOf'](_0x51de02[_0x3061(0xa8)](_0x4d4fa6++)),_0xf22501=_0x2765d4[_0x3061(0xa7)](_0x51de02[_0x3061(0xa8)](_0x4d4fa6++)),_0x35df04=_0x4adc07['gczsU'](_0x4adc07[_0x3061(0x11e)](_0x4adc07[_0x3061(0x11f)](_0x25e2ce,0x12),_0xa8971<<0xc),_0x4adc07[_0x3061(0x120)](_0x7b30dc,0x6))|_0xf22501;_0x13a507+=String[_0x3061(0xad)](_0x4adc07[_0x3061(0x121)](_0x35df04>>0x10,0xff));if(_0x4adc07[_0x3061(0x122)](_0x7b30dc,0x40))_0x13a507+=String['fromCharCode'](_0x4adc07[_0x3061(0x123)](_0x4adc07[_0x3061(0x124)](_0x35df04,0x8),0xff));if(_0xf22501!==0x40)_0x13a507+=String['fromCharCode'](_0x35df04&0xff);}return _0x13a507;};export const decodeJWTPayload=_0xef090c=>{const _0x2ed011={'EEMeH':'User\x20not\x20authenticated.\x20Please\x20verify\x20email\x20first.','lFXMq':_0x3061(0x125),'ztriU':'3.0.72','uwwym':function(_0x53e57e,_0x13429b){return _0x53e57e===_0x13429b;},'HKSti':function(_0x274f9f,_0x391d39){return _0x274f9f===_0x391d39;},'ZYlDo':function(_0x416752,_0x1d3bf8){return _0x416752!==_0x1d3bf8;},'SjwAP':_0x3061(0x126),'PowvG':function(_0x1e2eef,_0x2410b4){return _0x1e2eef*_0x2410b4;},'AvBWR':function(_0xdf9057,_0x5055ac){return _0xdf9057/_0x5055ac;},'IqlSb':function(_0x1d5bed,_0x53d1fa){return _0x1d5bed(_0x53d1fa);},'IwJaL':_0x3061(0x127)};try{const _0x2e7a66=_0xef090c[_0x3061(0x48)]('.');if(_0x2ed011[_0x3061(0x128)](_0x2e7a66[_0x3061(0x2c)],0x3))return console['error'](_0x2ed011[_0x3061(0x129)]),null;const _0x54124c=_0x2e7a66[0x1],_0x3c2716=_0x54124c[_0x3061(0x11d)](/-/g,'+')[_0x3061(0x11d)](/_/g,'/'),_0x5d41df=_0x3c2716['padEnd'](_0x2ed011[_0x3061(0x12a)](Math[_0x3061(0x12b)](_0x2ed011[_0x3061(0x12c)](_0x3c2716[_0x3061(0x2c)],0x4)),0x4),'='),_0x881ca4=_0x2ed011[_0x3061(0x12d)](base64Decode,_0x5d41df);return JSON[_0x3061(0x12e)](_0x881ca4);}catch(_0x272386){if(_0x2ed011[_0x3061(0x12f)]===_0x2ed011[_0x3061(0x12f)])return console[_0x3061(0xe)]('❌\x20Failed\x20to\x20decode\x20JWT\x20token:',_0x272386),null;else{var _0x35a405;if(!_0x41e6b8)throw new _0x1bd4cf(_0x2ed011['EEMeH']);return{'Content-Type':'application/json','Authorization':'Bearer\x20'+_0x11c765,'User-Agent':_0x2ed011[_0x3061(0x130)],'X-SDK-Version':_0x2ed011[_0x3061(0x131)],'X-SDK-Environment':(_0x2ed011[_0x3061(0x132)](_0x35a405=_0x4a1f28,null)||_0x2ed011['HKSti'](_0x35a405,void 0x0)?void 0x0:_0x35a405[_0x3061(0x34)])||_0x3061(0x1b)};}}};export const extractUsernameFromJWT=_0x47f481=>{const _0x4f1a9e={'hPZcN':function(_0x56bfb7,_0x5d39ac){return _0x56bfb7||_0x5d39ac;},'efGZR':function(_0x4c817f,_0x5963c3){return _0x4c817f!==_0x5963c3;},'eRKiP':'👤\x20Extracted\x20username\x20from\x20JWT:','ISLsM':'BFSYr','bUBBD':_0x3061(0x133)};try{var _0x56b953;const _0x39f5a6=_0x4f1a9e['hPZcN'](_0x47f481,userToken);if(!_0x39f5a6)return console[_0x3061(0x10)](_0x3061(0x134)),null;const _0x2f2457=decodeJWTPayload(_0x39f5a6);if(!_0x2f2457)return null;const _0x1547ac=_0x2f2457[_0x3061(0x135)]||_0x2f2457[_0x3061(0x136)]||_0x2f2457[_0x3061(0x137)]||_0x2f2457[_0x3061(0x138)];return(_0x56b953=globalConfig)!==null&&_0x4f1a9e[_0x3061(0x139)](_0x56b953,void 0x0)&&_0x56b953[_0x3061(0x36)]&&console[_0x3061(0x29)](_0x4f1a9e['eRKiP'],_0x1547ac),_0x1547ac||null;}catch(_0x25372a){return _0x4f1a9e[_0x3061(0x139)](_0x4f1a9e[_0x3061(0x13a)],_0x4f1a9e[_0x3061(0x13a)])?_0x47ec41['DEVELOPER']:(console[_0x3061(0xe)](_0x4f1a9e['bUBBD'],_0x25372a),null);}};export const extractUserDataFromJWT=_0x1d37a5=>{const _0x484ac2={'vIeCC':'❌\x20API\x20key\x20validation\x20failed\x20(client\x20error):','LVfuR':function(_0x395a70,_0x39dd6e){return _0x395a70!==_0x39dd6e;},'EmvAR':function(_0x1e16c2,_0x7802e1){return _0x1e16c2*_0x7802e1;},'IErUH':function(_0x3cb454,_0x4de473){return _0x3cb454/_0x4de473;},'KPchr':function(_0x59a6b1,_0xa60efc){return _0x59a6b1(_0xa60efc);},'xOlpz':_0x3061(0x11b),'QqaLs':function(_0x2ebccf,_0x216924){return _0x2ebccf<_0x216924;},'SsXRZ':function(_0xaa384b,_0x5a011f){return _0xaa384b|_0x5a011f;},'UEmXV':function(_0x31425e,_0x18c3c5){return _0x31425e|_0x18c3c5;},'uPJga':function(_0x199877,_0x15a167){return _0x199877<<_0x15a167;},'gCjNS':function(_0x32d166,_0x2be639){return _0x32d166&_0x2be639;},'iJTBL':function(_0x44015a,_0x35d5b2){return _0x44015a>>_0x35d5b2;},'JefqY':function(_0x1830ea,_0x447cf7){return _0x1830ea&_0x447cf7;},'hvCVm':'👤\x20Extracted\x20user\x20data\x20from\x20JWT:','nwDcW':function(_0x7c510f,_0xb4117b){return _0x7c510f!==_0xb4117b;},'MgEcR':_0x3061(0x13b),'LyrDJ':_0x3061(0x13c),'zDqfR':_0x3061(0x13d),'SAqKw':_0x3061(0x13e),'ZaPbv':function(_0x48559c,_0x316d48){return _0x48559c===_0x316d48;},'HLTAP':'PjeZK','outet':_0x3061(0x13f),'SBnJg':_0x3061(0x140),'nYbVs':_0x3061(0x141)};try{if(_0x484ac2[_0x3061(0x142)](_0x484ac2[_0x3061(0x143)],_0x484ac2['LyrDJ'])){var _0x218d82;const _0x53bb10=_0x1d37a5||userToken;if(!_0x53bb10){if(_0x484ac2[_0x3061(0x144)]==='DtmSC')return console[_0x3061(0x10)](_0x484ac2[_0x3061(0x145)]),null;else _0x928503[_0x3061(0xe)](_0x484ac2[_0x3061(0x146)],_0x20a4cf);}const _0x367ece=_0x484ac2[_0x3061(0x147)](decodeJWTPayload,_0x53bb10);if(!_0x367ece)return _0x484ac2[_0x3061(0x148)](_0x484ac2['HLTAP'],_0x484ac2[_0x3061(0x149)])?null:!!_0x654e49;const _0x215cc4={'id':_0x367ece['id'],'email':_0x367ece[_0x3061(0x138)],'userId':_0x367ece[_0x3061(0x137)],'userName':_0x367ece[_0x3061(0x135)]||_0x367ece[_0x3061(0x136)],'verified':_0x367ece[_0x3061(0x14a)],'iat':_0x367ece[_0x3061(0x14b)],'exp':_0x367ece[_0x3061(0x14c)]};if((_0x218d82=globalConfig)!==null&&_0x484ac2[_0x3061(0x14d)](_0x218d82,void 0x0)&&_0x218d82[_0x3061(0x36)]){if(_0x484ac2[_0x3061(0x148)](_0x484ac2['outet'],_0x484ac2['outet']))console[_0x3061(0x29)](_0x3061(0x14e),_0x215cc4);else try{const _0x42e3a4=_0x4c1521[_0x3061(0x48)]('.');if(_0x484ac2[_0x3061(0x14d)](_0x42e3a4[_0x3061(0x2c)],0x3))return _0x2df272[_0x3061(0xe)](_0x3061(0x126)),null;const _0x154ad4=_0x42e3a4[0x1],_0x2d7365=_0x154ad4['replace'](/-/g,'+')[_0x3061(0x11d)](/_/g,'/'),_0x39f2f3=_0x2d7365[_0x3061(0x14f)](_0x484ac2['EmvAR'](_0x47de7d[_0x3061(0x12b)](_0x484ac2[_0x3061(0x150)](_0x2d7365[_0x3061(0x2c)],0x4)),0x4),'='),_0x11decb=_0x484ac2[_0x3061(0x147)](_0xa3d446,_0x39f2f3);return _0x5c4273[_0x3061(0x12e)](_0x11decb);}catch(_0x59cb56){return _0x40c620[_0x3061(0xe)](_0x3061(0x151),_0x59cb56),null;}}return _0x215cc4;}else{const _0xbabb0=_0x484ac2[_0x3061(0x152)];let _0x31893f='',_0xd5b5ed=0x0;_0x5e8246=_0x3f4e21[_0x3061(0x11d)](/[^A-Za-z0-9+/]/g,'');while(_0x484ac2[_0x3061(0x153)](_0xd5b5ed,_0x91b397[_0x3061(0x2c)])){const _0x100bde=_0xbabb0[_0x3061(0xa7)](_0x56a017[_0x3061(0xa8)](_0xd5b5ed++)),_0x5db38b=_0xbabb0[_0x3061(0xa7)](_0x69dad9[_0x3061(0xa8)](_0xd5b5ed++)),_0x2fd68d=_0xbabb0[_0x3061(0xa7)](_0x360663[_0x3061(0xa8)](_0xd5b5ed++)),_0xfffc47=_0xbabb0['indexOf'](_0x3f09f3[_0x3061(0xa8)](_0xd5b5ed++)),_0x26633f=_0x484ac2[_0x3061(0x154)](_0x484ac2[_0x3061(0x154)](_0x484ac2[_0x3061(0x155)](_0x484ac2[_0x3061(0x156)](_0x100bde,0x12),_0x484ac2[_0x3061(0x156)](_0x5db38b,0xc)),_0x2fd68d<<0x6),_0xfffc47);_0x31893f+=_0x228362[_0x3061(0xad)](_0x484ac2['gCjNS'](_0x26633f>>0x10,0xff));if(_0x2fd68d!==0x40)_0x31893f+=_0x4bb67b[_0x3061(0xad)](_0x484ac2['iJTBL'](_0x26633f,0x8)&0xff);if(_0xfffc47!==0x40)_0x31893f+=_0x123b56[_0x3061(0xad)](_0x484ac2['JefqY'](_0x26633f,0xff));}return _0x31893f;}}catch(_0x2057de){if(_0x484ac2[_0x3061(0x157)]!=='fyBQz')return console[_0x3061(0xe)](_0x484ac2[_0x3061(0x158)],_0x2057de),null;else _0x3e3514[_0x3061(0x29)](_0x484ac2['hvCVm'],_0x244601);}};export const isUserAuthenticated=()=>{return!!userToken;};export const getAuthHeaders=()=>{const _0x173a19={'wBcYO':function(_0x3f7a3a,_0x182a95){return _0x3f7a3a!==_0x182a95;},'ZbFyw':_0x3061(0x5c),'fGmQc':function(_0x455e6f,_0x38eb3c){return _0x455e6f(_0x38eb3c);},'IRgus':'OnairosReactNative/3.0.72','dIpQD':_0x3061(0x10c),'siLYi':_0x3061(0x1b)};var _0x1d83cc;if(!((_0x1d83cc=globalConfig)!==null&&_0x173a19['wBcYO'](_0x1d83cc,void 0x0)&&_0x1d83cc[_0x3061(0x2b)]))throw new Error(_0x173a19[_0x3061(0x159)]);const _0x18cb66=_0x173a19[_0x3061(0x15a)](getApiKeyType,globalConfig[_0x3061(0x2b)]);return{'Content-Type':'application/json','Authorization':_0x3061(0x119)+globalConfig[_0x3061(0x2b)],'User-Agent':_0x173a19['IRgus'],'X-SDK-Version':_0x173a19[_0x3061(0x15b)],'X-SDK-Environment':globalConfig[_0x3061(0x34)]||_0x173a19['siLYi'],'X-API-Key-Type':_0x18cb66,'X-Timestamp':new Date()[_0x3061(0x95)]()};};function _0x3061(_0x539e5b,_0x30615d){_0x539e5b=_0x539e5b-0x0;const _0x1c3b4d=_0x539e();let _0x26d3c4=_0x1c3b4d[_0x539e5b];return _0x26d3c4;}export const getDeveloperAuthHeaders=()=>{const _0x56ee04={'ddbKv':function(_0x43ba69,_0x30d12c){return _0x43ba69!==_0x30d12c;},'iVeHF':function(_0x128571,_0x1284e4){return _0x128571!==_0x1284e4;},'pczXP':_0x3061(0x15c),'fzPpD':_0x3061(0x15d),'CwbtA':_0x3061(0x5c),'LcIZb':function(_0x15d2d6,_0x3d686f){return _0x15d2d6(_0x3d686f);},'OVgcv':_0x3061(0x125),'BvhwS':_0x3061(0x10c),'qYgIY':_0x3061(0x1b)};var _0x5f0509;if(!(_0x56ee04[_0x3061(0x15e)](_0x5f0509=globalConfig,null)&&_0x5f0509!==void 0x0&&_0x5f0509['apiKey'])){if(_0x56ee04[_0x3061(0x15f)](_0x56ee04[_0x3061(0x160)],_0x56ee04[_0x3061(0x161)]))throw new Error(_0x56ee04[_0x3061(0x162)]);else return null;}const _0x50e762=_0x56ee04[_0x3061(0x163)](getApiKeyType,globalConfig[_0x3061(0x2b)]);return{'Content-Type':'application/json','Authorization':_0x3061(0x119)+globalConfig[_0x3061(0x2b)],'User-Agent':_0x56ee04['OVgcv'],'X-SDK-Version':_0x56ee04[_0x3061(0x164)],'X-SDK-Environment':globalConfig[_0x3061(0x34)]||_0x56ee04[_0x3061(0x165)],'X-API-Key-Type':_0x50e762,'X-Timestamp':new Date()[_0x3061(0x95)]()};};export const getUserAuthHeaders=()=>{const _0x59f51c={'puOCC':function(_0x853642,_0x4a03a1){return _0x853642===_0x4a03a1;},'sxCnx':'kFMmn','mPQqM':_0x3061(0x166),'zPoIk':function(_0x3421ba,_0x29fcf4){return _0x3421ba===_0x29fcf4;}};var _0x5e3603;if(!userToken){if(_0x59f51c['puOCC'](_0x59f51c[_0x3061(0x167)],_0x3061(0x168)))throw new _0x149abd('Service\x20unavailable\x20('+_0x4ae3c3['status']+').\x20The\x20Onairos\x20backend\x20may\x20be\x20temporarily\x20down.');else throw new Error(_0x59f51c[_0x3061(0x169)]);}return{'Content-Type':'application/json','Authorization':_0x3061(0x119)+userToken,'User-Agent':_0x3061(0x125),'X-SDK-Version':_0x3061(0x10c),'X-SDK-Environment':(_0x59f51c['zPoIk'](_0x5e3603=globalConfig,null)||_0x59f51c['puOCC'](_0x5e3603,void 0x0)?void 0x0:_0x5e3603['environment'])||_0x3061(0x1b)};};export const makeAuthenticatedRequest=async(_0x15d108,_0x43aa5a={})=>{const _0x3109fb={'TxOSD':function(_0x27356a,_0x54ce98){return _0x27356a!==_0x54ce98;},'EhDwI':_0x3061(0x73),'yEgkt':_0x3061(0x13e),'XIanT':function(_0x4adea1,_0x16ee1e){return _0x4adea1(_0x16ee1e);},'PRQXa':function(_0x4fd1e5,_0x214c62){return _0x4fd1e5!==_0x214c62;},'IQNDz':_0x3061(0x105),'OkSmA':_0x3061(0x7f),'gphSb':_0x3061(0x10b),'dTcFX':'Request\x20timeout','bSkap':_0x3061(0x16a),'bvXGJ':function(_0x41d92d){return _0x41d92d();},'VRLHV':_0x3061(0x1b),'PJifY':function(_0x3d132e,_0x2ee6bc,_0x45e91e){return _0x3d132e(_0x2ee6bc,_0x45e91e);},'JoQVI':function(_0x4584d9,_0x44429a){return _0x4584d9===_0x44429a;},'UghJT':_0x3061(0x16b),'wtKWU':_0x3061(0x16c),'zBQsP':function(_0x51d599,_0x11a85a){return _0x51d599!==_0x11a85a;},'VlwPi':_0x3061(0x16d),'WWzvF':_0x3061(0x16e),'SrhgQ':_0x3061(0x16f),'cThWO':function(_0x2f82c3,_0xee16c6){return _0x2f82c3!==_0xee16c6;},'fEnWC':'xBAdv','MRMqx':_0x3061(0x170),'SYxXX':_0x3061(0x14),'xOONi':function(_0x398d87,_0x5bcb1b){return _0x398d87===_0x5bcb1b;},'TsAho':function(_0x3df789,_0x5a4858){return _0x3df789===_0x5a4858;},'Bvyee':_0x3061(0x171),'Gamqg':'❌\x20API\x20key\x20permissions\x20insufficient\x20for\x20this\x20operation.','OefJj':'FUgmy','qwZft':'❌\x20API\x20rate\x20limit\x20exceeded.\x20Please\x20try\x20again\x20later.','snfZk':_0x3061(0x5),'ohfSD':'AbortError'};if(!isApiKeyInitialized())throw new Error(_0x3061(0x5c));const _0x1e586b=_0x3109fb[_0x3061(0x172)](getApiConfig),_0x1907b7=API_ENDPOINTS[_0x1e586b[_0x3061(0x34)]||_0x3109fb[_0x3061(0x173)]],_0x3710ee=''+_0x1907b7+(_0x15d108[_0x3061(0x33)]('/')?'':'/')+_0x15d108,_0x1f696b={...getAuthHeaders(),..._0x43aa5a['headers']||{}},_0x5cb308=new AbortController(),_0x3aa8b0=_0x3109fb[_0x3061(0x174)](setTimeout,()=>_0x5cb308[_0x3061(0x8e)](),_0x1e586b[_0x3061(0x20)]||0x7530);try{if(_0x3109fb[_0x3061(0x175)](_0x3109fb['UghJT'],_0x3109fb[_0x3061(0x176)])){var _0x4670c6;return(_0x4670c6=_0x53afaf)!==null&&_0x3109fb[_0x3061(0x177)](_0x4670c6,void 0x0)&&_0x4670c6[_0x3061(0x36)]&&_0x32d21d[_0x3061(0xe)](_0x3109fb[_0x3061(0x178)],_0x22edc7),_0x2d6b20;}else{if(_0x1e586b[_0x3061(0x36)]){if(_0x3109fb[_0x3061(0x179)](_0x3109fb['VlwPi'],_0x3109fb['VlwPi'])){var _0xcb41fd;const _0xaa25d5=_0x51cedd||_0x42840f;if(!_0xaa25d5)return _0x348a4a[_0x3061(0x10)](_0x3109fb['yEgkt']),null;const _0x546b6b=_0x3109fb[_0x3061(0x17a)](_0x5f07d2,_0xaa25d5);if(!_0x546b6b)return null;const _0x197ebe={'id':_0x546b6b['id'],'email':_0x546b6b[_0x3061(0x138)],'userId':_0x546b6b[_0x3061(0x137)],'userName':_0x546b6b[_0x3061(0x135)]||_0x546b6b[_0x3061(0x136)],'verified':_0x546b6b['verified'],'iat':_0x546b6b[_0x3061(0x14b)],'exp':_0x546b6b[_0x3061(0x14c)]};return _0x3109fb[_0x3061(0x177)](_0xcb41fd=_0x130833,null)&&_0x3109fb[_0x3061(0x17b)](_0xcb41fd,void 0x0)&&_0xcb41fd[_0x3061(0x36)]&&_0x2df4ac[_0x3061(0x29)]('👤\x20Extracted\x20user\x20data\x20from\x20JWT:',_0x197ebe),_0x197ebe;}else console[_0x3061(0x29)](_0x3061(0x17c)+_0x15d108);}const _0x564461=await _0x3109fb[_0x3061(0x174)](fetch,_0x3710ee,{..._0x43aa5a,'headers':_0x1f696b,'signal':_0x5cb308[_0x3061(0x17d)]});_0x3109fb[_0x3061(0x17a)](clearTimeout,_0x3aa8b0);if(_0x1e586b[_0x3061(0x36)]){if(_0x3109fb[_0x3061(0x175)](_0x3109fb[_0x3061(0x17e)],_0x3109fb[_0x3061(0x17f)])){_0xb7a247[_0x3061(0xe)](_0x3109fb[_0x3061(0x180)],_0x533bb4);throw _0x8edfd1;}else console[_0x3061(0x29)](_0x3061(0x181)+_0x564461[_0x3061(0x86)]+_0x3061(0x87)+_0x15d108);}if(_0x564461[_0x3061(0x86)]===0x191){if(_0x3109fb[_0x3061(0x182)]('OXnMj',_0x3109fb[_0x3061(0x183)])){console[_0x3061(0xe)](_0x3109fb[_0x3061(0x184)]);throw new Error(_0x3109fb[_0x3061(0x185)]);}else return{'isValid':![],'error':_0x3109fb[_0x3061(0x186)],'keyType':_0x310a8e['INVALID']};}if(_0x3109fb['xOONi'](_0x564461['status'],0x193)){if(_0x3109fb[_0x3061(0x187)]('RXJIF',_0x3109fb['Bvyee'])){_0x1bd8f9[_0x3061(0xe)](_0x3109fb[_0x3061(0x188)],_0x5c8c75);throw new _0x15dab5(_0x3109fb['dTcFX']);}else{console[_0x3061(0xe)](_0x3109fb[_0x3061(0x189)]);throw new Error(_0x3061(0x16a));}}if(_0x3109fb[_0x3061(0x18a)](_0x564461['status'],0x1ad)){if(_0x3109fb[_0x3061(0x18b)]===_0x3109fb['OefJj']){console[_0x3061(0xe)](_0x3109fb[_0x3061(0x18c)]);throw new Error(_0x3109fb[_0x3061(0x18d)]);}else{_0x512ca9[_0x3061(0xe)](_0x3061(0x18e));throw new _0x298fb5(_0x3109fb['bSkap']);}}return _0x564461;}}catch(_0x8aaeb7){clearTimeout(_0x3aa8b0);if(_0x8aaeb7[_0x3061(0x57)]===_0x3109fb[_0x3061(0x18f)]){console['error'](_0x3109fb[_0x3061(0x188)],_0x15d108);throw new Error(_0x3109fb[_0x3061(0x190)]);}throw _0x8aaeb7;}};function _0x539e(){const _0x8895d9=['DEVELOPER','WZkWZ','INVALID','invalid','onairos_jwt_token','Rate\x20limit\x20exceeded','Efgkz','⚠️\x20Failed\x20to\x20check\x20network\x20connectivity:','fetch','CqgBj','isConnected','isInternetReachable','tuZav','rUVAj','error','LQKmx','warn','XQyha','BASE_URL','❌\x20Developer\x20API\x20key\x20authentication\x20failed','Invalid\x20or\x20expired\x20API\x20key','🔑\x20Initializing\x20Onairos\x20SDK\x20with\x20developer\x20API\x20key...','QcwpM','dev_','ona_','pk_','Invalid\x20API\x20key\x20format.\x20Developer\x20keys\x20must\x20start\x20with\x20dev_,\x20ona_,\x20or\x20pk_','production','📝\x20SDK\x20Configuration:','...','SpeSl','JSON\x20Parse\x20error','timeout','No\x20network\x20connection','📝\x20SDK\x20will\x20function\x20with\x20limited\x20validation.\x20Network\x20connectivity\x20will\x20be\x20retried\x20automatically.','🔄\x20Continuing\x20in\x20offline\x20mode\x20with\x20basic\x20validation','✅\x20Onairos\x20SDK\x20initialized\x20successfully','🎫\x20User\x20JWT\x20token\x20loaded\x20from\x20storage','qIrwr','🔐\x20API\x20Key\x20Permissions:','⏱️\x20Rate\x20Limits:','log','Developer\x20API\x20key\x20is\x20required\x20for\x20SDK\x20initialization','apiKey','length','LUsrg','Invalid\x20API\x20key\x20format.\x20Developer\x20keys\x20must\x20be\x20at\x20least\x2032\x20characters\x20long.','pdxlZ','TLkbv','MGCCj','some','startsWith','environment','QDnOF','enableLogging','retryAttempts','GOFsx','okXea','gnsvF','ZvkFN','TtApW','isNetworkError','includes','Network\x20request\x20failed','YYvpf','wPmCp','XldYu','AhVit','iFshR','pXQDJ','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','1|4|0|3|2','split','CaFbK','zPOfV','ICJQb','API\x20key\x20validation\x20failed:\x20','QkLTj','DRpVh','QfFhD','zLFKV','permissions','RHSLv','FLXsM','EEYmZ','eViiO','tdTIb','name','UcxEF','weQfd','ULHCC','SXRab','SDK\x20not\x20initialized.\x20Call\x20initializeApiKey()\x20first.','✅\x20API\x20key\x20validation\x20successful','Network\x20error','❌\x20API\x20key\x20validation\x20error:','🔍\x20Validating\x20developer\x20API\x20key\x20against\x20backend...','aNkgg','📋\x20Using\x20cached\x20API\x20key\x20validation\x20result','No\x20network\x20connection\x20available.\x20Please\x20check\x20your\x20internet\x20connection\x20and\x20try\x20again.','nqKhm','OnairosReactNative/3.3.1','3.3.1','No\x20response\x20received\x20from\x20server','Onairos\x20API\x20is\x20temporarily\x20unavailable\x20(502\x20Bad\x20Gateway).\x20Please\x20try\x20again\x20later.','Onairos\x20API\x20request\x20timed\x20out\x20(504\x20Gateway\x20Timeout).\x20Please\x20try\x20again.','❌\x20API\x20endpoint\x20returned\x20non-JSON\x20response:','PkgDR','yzlFs','<html','<!DOCTYPE','unknown\x20content\x20type','ZpuoF','cXrTX','Aqfre','❌\x20API\x20key\x20validation\x20failed\x20(client\x20error):','⏱️\x20API\x20key\x20validation\x20timeout','Unexpected\x20character','Wipsv','cbKHA','🌐\x20Network\x20error\x20during\x20API\x20key\x20validation:','agMRH','LHbNH','tdpsR','bWHJS','HqbOf','nkUMw','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','get','lwfZM','now','pFncE','IEnYr','ycmsi','status','\x20for\x20','pnXem','FqUqn','iPNrv','cpETT','bWOAk','rFNJv','abort','🔄\x20Retry\x20attempt\x20','\x20for\x20API\x20key\x20validation','/dev/validate-apikey','toString','stringify','gWfXO','toISOString','XyTvo','CrTkD','CmGcZ','fGftX','xFMXZ','PvLQE','bLgqE','vjWoZ','headers','sflwg','text','hwacY','uzlYP','RNdaP','lFRUa','lbaQK','bxGjx','indexOf','charAt','DzcAw','NqHKF','dBRqj','KcYEA','fromCharCode','jYHeJ','OXuMc','API\x20validation\x20endpoint\x20not\x20found\x20(404).\x20The\x20endpoint\x20','/dev/validate-apikey\x20may\x20not\x20exist\x20or\x20be\x20configured\x20correctly.','Server\x20error\x20(500).\x20The\x20Onairos\x20backend\x20is\x20experiencing\x20issues.','whJYU','Service\x20unavailable\x20(',').\x20The\x20Onairos\x20backend\x20may\x20be\x20temporarily\x20down.','AuAiQ','sBxmC','\x20-\x20','statusText','.\x20Expected\x20JSON\x20but\x20got\x20','PfcbU','FjORR','json','zTxrN','message','success','rateLimits','set','tEWrR','uENsg','application','Wmbxa','mJGkL','usageCount','HTTP\x20','DcCbc','WKkUp','DHsZf','nNgAt','uMQRh','pwzQh','cgcRb','API\x20key\x20validation\x20timeout\x20(','ms)','TwbpR','IULOT','DROXB','gWQnV','📡\x20Developer\x20request\x20response:\x20','wiFWp','shCuh','rvGRz','twQfM','lZzLE','otWZc','Network\x20connectivity\x20issue.\x20Please\x20check\x20internet\x20connection\x20and\x20verify\x20the\x20Onairos\x20API\x20is\x20accessible.\x20','DNS','Feraq','NyFXM','fNLOk','MiJMd','DNS\x20resolution\x20failed\x20for\x20','.\x20Please\x20check\x20network\x20settings\x20and\x20domain\x20accessibility.\x20','azyRw','fZbwt','yumpQ','PlbVg','UYaHm','kGGLU','⏳\x20Waiting\x20','ms\x20before\x20retry...','vdDhB','zaOvE','3|2|4|1|0','📱\x20SDK\x20initialized\x20in\x20offline\x20mode\x20-\x20will\x20retry\x20validation\x20when\x20network\x20is\x20available','🌐\x20Error\x20details:','xRvdp','⚠️\x20API\x20key\x20validation\x20failed\x20due\x20to\x20network/connectivity\x20issues','hjvzM','API\x20key\x20validation\x20error:\x20','sTiqu','zKiXn','hCEvI','kSdMf','gmgOy','nyNsa','daANp','dUZIK','WqJYd','eCpmw','dKAQt','setItem','deGNl','mjiRL','❌\x20Failed\x20to\x20store\x20JWT\x20token:','Mammy','pTOft','SZWls','getItem','❌\x20Failed\x20to\x20load\x20JWT\x20token:','⏱️\x20Request\x20timeout\x20for:','3.0.72','IIYKo','ldDKb','❌\x20Failed\x20to\x20clear\x20JWT\x20token:','removeItem','tjZlb','yGIzB','UdjYG','MUKFO','ZlaWZ','kpazs','snnEd','KOzOb','Bearer\x20','ShLjX','ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/','AmWih','replace','XPRyV','VNbKh','kDltx','utgoG','Rgslc','WEpla','QHLbh','OnairosSDK/1.0.0','❌\x20Invalid\x20JWT\x20token\x20format','Kdwxq','ZYlDo','SjwAP','PowvG','ceil','AvBWR','IqlSb','parse','IwJaL','lFXMq','ztriU','uwwym','❌\x20Failed\x20to\x20extract\x20username\x20from\x20JWT:','⚠️\x20No\x20JWT\x20token\x20available\x20for\x20username\x20extraction','userName','username','userId','email','efGZR','ISLsM','ZYJec','cOlBX','DtmSC','⚠️\x20No\x20JWT\x20token\x20available\x20for\x20user\x20data\x20extraction','dVRpG','CELZi','❌\x20Failed\x20to\x20extract\x20user\x20data\x20from\x20JWT:','nwDcW','MgEcR','zDqfR','SAqKw','vIeCC','KPchr','ZaPbv','HLTAP','verified','iat','exp','LVfuR','👤\x20Extracted\x20user\x20data\x20from\x20JWT:','padEnd','IErUH','❌\x20Failed\x20to\x20decode\x20JWT\x20token:','xOlpz','QqaLs','SsXRZ','UEmXV','uPJga','SBnJg','nYbVs','ZbFyw','fGmQc','dIpQD','BMfmn','MLnnC','ddbKv','iVeHF','pczXP','fzPpD','CwbtA','LcIZb','BvhwS','qYgIY','User\x20not\x20authenticated.\x20Please\x20verify\x20email\x20first.','sxCnx','uxGdx','mPQqM','Insufficient\x20API\x20key\x20permissions','gJvSS','sJMbM','bsViC','HRzNh','Bksbz','❌\x20API\x20key\x20authentication\x20failed.\x20Please\x20check\x20your\x20API\x20key.','allsW','bvXGJ','VRLHV','PJifY','JoQVI','wtKWU','TxOSD','EhDwI','zBQsP','XIanT','PRQXa','🌐\x20Making\x20authenticated\x20request\x20to:\x20','signal','WWzvF','SrhgQ','IQNDz','📡\x20Response\x20status:\x20','cThWO','fEnWC','MRMqx','SYxXX','OkSmA','TsAho','gphSb','Gamqg','xOONi','OefJj','qwZft','snfZk','❌\x20Developer\x20API\x20key\x20permissions\x20insufficient','ohfSD','dTcFX','XdCNU','gCWyu','ahXwu','lmwAF','nfjOI','❌\x20API\x20rate\x20limit\x20exceeded','Request\x20timeout','kZaFJ','vEUVO','qonxu','BqbgP','🌐\x20Making\x20developer\x20request\x20to:\x20','TFgXy','pryLN','GmtfM','clear','rXSJx','HHefy','fazsz','GteeL','fkHHm','nIQcw','JUkHQ','RcLEC','XjEvg','rIzDD','Vdhdf','xQVCR','uPUwF','vhHaI','❌\x20JWT\x20token\x20authentication\x20failed\x20-\x20token\x20may\x20be\x20expired','❌\x20JWT\x20token\x20permissions\x20insufficient','AbortError','xthrJ','cjsaC','tgxIk','jEgxz','SLUoE','xkYSY','YyWuH','bZccb','PgrwE','XTXsG','lQuMI','BDBoL','jDlYE','Cboio','KkToV','rlhOq','LhTpz','jPVon','ofBEF','rJXew','kUHTK','BJWUS','🗑️\x20API\x20key\x20validation\x20cache\x20cleared','ARwIV','idqYJ','kZbre','cNWuR','UQIXe','YQYAI','🔄\x20API\x20key\x20service\x20reset','twznD','DeeMd'];_0x539e=function(){return _0x8895d9;};return _0x539e();}export const makeDeveloperRequest=async(_0x153131,_0x371b56={})=>{const _0x5d96a0={'BqbgP':'No\x20response\x20received\x20from\x20server','HHefy':'🗑️\x20API\x20key\x20validation\x20cache\x20cleared','rXSJx':function(_0xe26ccd,_0x343146){return _0xe26ccd!==_0x343146;},'Vdhdf':'❌\x20Failed\x20to\x20extract\x20user\x20data\x20from\x20JWT:','kZaFJ':function(_0x544823){return _0x544823();},'vEUVO':_0x3061(0x191),'qonxu':_0x3061(0x5c),'HrKgQ':_0x3061(0x1b),'jPOTn':_0x3061(0x192),'UBHRl':function(_0x1fafa3,_0xd60da8,_0x1a74e3){return _0x1fafa3(_0xd60da8,_0x1a74e3);},'TFgXy':function(_0x5de427,_0x587de7){return _0x5de427===_0x587de7;},'pryLN':_0x3061(0x193),'GmtfM':_0x3061(0x194),'fazsz':function(_0x3c9c18,_0x577105){return _0x3c9c18===_0x577105;},'DrqWY':'❌\x20Developer\x20API\x20key\x20authentication\x20failed','rQwXy':_0x3061(0x14),'fkHHm':function(_0x444a41,_0x41d4cb){return _0x444a41===_0x41d4cb;},'nIQcw':'❌\x20Developer\x20API\x20key\x20permissions\x20insufficient','JUkHQ':_0x3061(0x16a),'RcLEC':function(_0x369181,_0x1136c3){return _0x369181!==_0x1136c3;},'JcjUM':_0x3061(0x195),'rIzDD':_0x3061(0x196),'CbErU':function(_0x40003e,_0x553e92){return _0x40003e(_0x553e92);},'xQVCR':function(_0x5813d,_0x3ea250){return _0x5813d===_0x3ea250;},'uPUwF':'AbortError','sSuoh':_0x3061(0x197)};if(!_0x5d96a0[_0x3061(0x198)](isApiKeyInitialized)){if(_0x5d96a0[_0x3061(0x199)]===_0x5d96a0[_0x3061(0x199)])throw new Error(_0x5d96a0[_0x3061(0x19a)]);else throw new _0x454a70(_0x5d96a0[_0x3061(0x19b)]);}const _0x54b309=getApiConfig(),_0x25718a=API_ENDPOINTS[_0x54b309[_0x3061(0x34)]||_0x5d96a0['HrKgQ']],_0x297843=''+_0x25718a+(_0x153131['startsWith']('/')?'':'/')+_0x153131,_0x138f6a={..._0x5d96a0[_0x3061(0x198)](getDeveloperAuthHeaders),..._0x371b56['headers']||{}},_0x4a9d38=new AbortController(),_0x745721=setTimeout(()=>_0x4a9d38['abort'](),_0x54b309[_0x3061(0x20)]||0x7530);try{_0x54b309['enableLogging']&&(_0x5d96a0['rXSJx'](_0x5d96a0['jPOTn'],_0x3061(0x192))?_0x4a38d0[_0x3061(0x29)](_0x5d96a0['HHefy']):console[_0x3061(0x29)](_0x3061(0x19c)+_0x153131));const _0x375938=await _0x5d96a0['UBHRl'](fetch,_0x297843,{..._0x371b56,'headers':_0x138f6a,'signal':_0x4a9d38['signal']});clearTimeout(_0x745721);if(_0x54b309[_0x3061(0x36)]){if(_0x5d96a0[_0x3061(0x19d)](_0x5d96a0[_0x3061(0x19e)],_0x5d96a0[_0x3061(0x19f)])){var _0x3f429a;_0x547f2e[_0x3061(0x1a0)](),_0x5d96a0[_0x3061(0x1a1)](_0x3f429a=_0x5aa29f,null)&&_0x5d96a0['rXSJx'](_0x3f429a,void 0x0)&&_0x3f429a['enableLogging']&&_0x3e1200[_0x3061(0x29)](_0x5d96a0[_0x3061(0x1a2)]);}else console[_0x3061(0x29)]('📡\x20Developer\x20request\x20response:\x20'+_0x375938[_0x3061(0x86)]+_0x3061(0x87)+_0x153131);}if(_0x5d96a0[_0x3061(0x1a3)](_0x375938[_0x3061(0x86)],0x191)){if(_0x3061(0x1a4)===_0x3061(0x1a4)){console[_0x3061(0xe)](_0x5d96a0['DrqWY']);throw new Error(_0x5d96a0['rQwXy']);}else _0x2301b5[_0x3061(0x29)]('🔐\x20API\x20Key\x20Permissions:',_0x2f869b[_0x3061(0x51)]);}if(_0x5d96a0[_0x3061(0x1a5)](_0x375938[_0x3061(0x86)],0x193)){console[_0x3061(0xe)](_0x5d96a0[_0x3061(0x1a6)]);throw new Error(_0x5d96a0[_0x3061(0x1a7)]);}if(_0x5d96a0[_0x3061(0x1a3)](_0x375938[_0x3061(0x86)],0x1ad)){if(_0x5d96a0[_0x3061(0x1a8)](_0x5d96a0['JcjUM'],_0x3061(0x1a9))){console['error'](_0x5d96a0[_0x3061(0x1aa)]);throw new Error(_0x3061(0x5));}else return _0x512144[_0x3061(0xe)](_0x5d96a0[_0x3061(0x1ab)],_0x348334),null;}return _0x375938;}catch(_0x22ea21){_0x5d96a0['CbErU'](clearTimeout,_0x745721);if(_0x5d96a0[_0x3061(0x1ac)](_0x22ea21[_0x3061(0x57)],_0x5d96a0[_0x3061(0x1ad)])){console[_0x3061(0xe)]('⏱️\x20Request\x20timeout\x20for:',_0x153131);throw new Error(_0x5d96a0['sSuoh']);}throw _0x22ea21;}};export const makeUserRequest=async(_0x479590,_0x382abd={})=>{const _0x4e114b={'bZccb':_0x3061(0x5c),'lQuMI':_0x3061(0x13e),'kUHTK':_0x3061(0x1a),'cjsaC':function(_0x2c486f){return _0x2c486f();},'jEgxz':function(_0x53c674){return _0x53c674();},'tgxIk':_0x3061(0x166),'JJETF':_0x3061(0x1b),'SLUoE':function(_0x5adb42,_0x5c2268){return _0x5adb42===_0x5c2268;},'xkYSY':function(_0x427956,_0x138049){return _0x427956!==_0x138049;},'YyWuH':_0x3061(0x1ae),'PgrwE':function(_0x3c5d36,_0x348803,_0x2e58e0){return _0x3c5d36(_0x348803,_0x2e58e0);},'XTXsG':'McMPo','BDBoL':function(_0xa3b1d8,_0x121b97){return _0xa3b1d8===_0x121b97;},'jDlYE':_0x3061(0x1af),'YAOKm':function(_0x3fce01){return _0x3fce01();},'hWhvW':'Authentication\x20expired.\x20Please\x20verify\x20email\x20again.','KkToV':_0x3061(0x1b0),'rlhOq':function(_0x5b18b7,_0x11e2f2){return _0x5b18b7(_0x11e2f2);},'LhTpz':_0x3061(0x1b1),'jPVon':function(_0x28d268,_0x4e7d29){return _0x28d268===_0x4e7d29;},'ofBEF':_0x3061(0x1b2),'rJXew':'Request\x20timeout'};!_0x4e114b[_0x3061(0x1b3)](isUserAuthenticated)&&await loadJWT();if(!_0x4e114b['jEgxz'](isUserAuthenticated))throw new Error(_0x4e114b[_0x3061(0x1b4)]);const _0x5eeffe=_0x4e114b[_0x3061(0x1b5)](getApiConfig)||{'environment':_0x4e114b['JJETF'],'timeout':0x7530,'enableLogging':![]},_0x4d4c2a=API_ENDPOINTS[_0x5eeffe['environment']||_0x3061(0x1b)],_0x482688=''+_0x4d4c2a+(_0x479590[_0x3061(0x33)]('/')?'':'/')+_0x479590,_0x3a40ce={..._0x4e114b[_0x3061(0x1b3)](getUserAuthHeaders),..._0x382abd[_0x3061(0x9e)]||{}},_0x3d5ad3=new AbortController(),_0x5b55f8=setTimeout(()=>_0x3d5ad3['abort'](),_0x5eeffe['timeout']||0x7530);try{if(_0x4e114b[_0x3061(0x1b6)]('YSGjq','WLebe'))return _0x456960;else{if(_0x5eeffe[_0x3061(0x36)]){if(_0x4e114b[_0x3061(0x1b7)](_0x4e114b[_0x3061(0x1b8)],_0x4e114b[_0x3061(0x1b8)]))throw new _0x27d9c2(_0x4e114b[_0x3061(0x1b9)]);else console['log']('🌐\x20Making\x20user\x20request\x20to:\x20'+_0x479590);}const _0x2df582=await _0x4e114b[_0x3061(0x1ba)](fetch,_0x482688,{..._0x382abd,'headers':_0x3a40ce,'signal':_0x3d5ad3[_0x3061(0x17d)]});clearTimeout(_0x5b55f8);if(_0x5eeffe[_0x3061(0x36)]){if(_0x4e114b[_0x3061(0x1bb)]!=='McMPo')return _0x44a7f2[_0x3061(0x10)](_0x4e114b[_0x3061(0x1bc)]),null;else console[_0x3061(0x29)]('📡\x20User\x20request\x20response:\x20'+_0x2df582['status']+_0x3061(0x87)+_0x479590);}if(_0x4e114b[_0x3061(0x1bd)](_0x2df582[_0x3061(0x86)],0x191)){console[_0x3061(0xe)](_0x4e114b[_0x3061(0x1be)]),await _0x4e114b['YAOKm'](clearJWT);throw new Error(_0x4e114b['hWhvW']);}if(_0x4e114b[_0x3061(0x1b6)](_0x2df582[_0x3061(0x86)],0x193)){if('Cboio'===_0x3061(0x1bf)){console[_0x3061(0xe)](_0x4e114b[_0x3061(0x1c0)]);throw new Error('Insufficient\x20permissions\x20for\x20this\x20operation');}else return{'isValid':![],'error':_0x28d044,'keyType':_0x349e9b};}return _0x2df582;}}catch(_0x973b3a){_0x4e114b[_0x3061(0x1c1)](clearTimeout,_0x5b55f8);if(_0x973b3a[_0x3061(0x57)]===_0x4e114b[_0x3061(0x1c2)]){if(_0x4e114b[_0x3061(0x1c3)](_0x3061(0x1b2),_0x4e114b[_0x3061(0x1c4)])){console[_0x3061(0xe)](_0x3061(0x10b),_0x479590);throw new Error(_0x4e114b[_0x3061(0x1c5)]);}else throw new _0x4c49dd(_0x4e114b[_0x3061(0x1c6)]);}throw _0x973b3a;}};export const clearValidationCache=()=>{const _0x13ff6e={'VmXQK':function(_0x5aef5b){return _0x5aef5b();},'YQYAI':'🔄\x20API\x20key\x20service\x20reset','ARwIV':function(_0x4ff03f,_0x153bf4){return _0x4ff03f!==_0x153bf4;},'idqYJ':function(_0x176007,_0x2c50d9){return _0x176007!==_0x2c50d9;},'kZbre':function(_0x54de8c,_0x4a6dd3){return _0x54de8c===_0x4a6dd3;},'cNWuR':_0x3061(0x1c7),'UQIXe':_0x3061(0x1c8)};var _0x4103e9;validationCache[_0x3061(0x1a0)](),_0x13ff6e[_0x3061(0x1c9)](_0x4103e9=globalConfig,null)&&_0x13ff6e[_0x3061(0x1ca)](_0x4103e9,void 0x0)&&_0x4103e9[_0x3061(0x36)]&&(_0x13ff6e[_0x3061(0x1cb)]('BJWUS',_0x13ff6e[_0x3061(0x1cc)])?console[_0x3061(0x29)](_0x13ff6e[_0x3061(0x1cd)]):(_0x2446b7=null,_0x94d4f4=![],_0x13ff6e['VmXQK'](_0x38afe5),_0x58fad1[_0x3061(0x29)](_0x13ff6e[_0x3061(0x1ce)])));};export const resetApiKeyService=()=>{const _0x9c1b0f={'twznD':function(_0x3b0fcd){return _0x3b0fcd();},'DeeMd':_0x3061(0x1cf)};globalConfig=null,isInitialized=![],_0x9c1b0f[_0x3061(0x1d0)](clearValidationCache),console[_0x3061(0x29)](_0x9c1b0f[_0x3061(0x1d1)]);};
1
+ import AsyncStorage from '@react-native-async-storage/async-storage';
2
+ import NetInfo from '@react-native-community/netinfo';
3
+ import { API_CONFIG } from '../config/api';
4
+
5
+ // API key types - Only developer keys are supported in client SDK
6
+ export let ApiKeyType = /*#__PURE__*/function (ApiKeyType) {
7
+ ApiKeyType["DEVELOPER"] = "developer";
8
+ ApiKeyType["INVALID"] = "invalid";
9
+ return ApiKeyType;
10
+ }({});
11
+
12
+ // JWT token storage key
13
+ const JWT_TOKEN_KEY = 'onairos_jwt_token';
14
+
15
+ /**
16
+ * Two-Tier Authentication Service for Onairos React Native SDK
17
+ *
18
+ * This service implements the two-tier authentication system:
19
+ * 1. Developer API Keys: For app-level operations (email verification, app registration)
20
+ * 2. JWT User Tokens: For user-level operations (PIN storage, user profile)
21
+ *
22
+ * How it works:
23
+ * 1. Initialize with developer API key
24
+ * 2. Use API key for email verification requests
25
+ * 3. Store JWT token from email verification response
26
+ * 4. Use JWT token for user-authenticated requests
27
+ * 5. Handle token expiration gracefully
28
+ *
29
+ * Backend Integration:
30
+ * - Developer routes: Authorization: Bearer ${API_KEY}
31
+ * - User routes: Authorization: Bearer ${JWT_TOKEN}
32
+ */
33
+
34
+ // Global configuration state
35
+ let globalConfig = null;
36
+ let validationCache = new Map();
37
+ let isInitialized = false;
38
+ let userToken = null;
39
+
40
+ // Cache duration (5 minutes)
41
+ const CACHE_DURATION = 5 * 60 * 1000;
42
+
43
+ /**
44
+ * Check network connectivity
45
+ * @returns Promise<boolean> - true if connected, false otherwise
46
+ */
47
+ const checkNetworkConnectivity = async () => {
48
+ try {
49
+ const netInfo = await NetInfo.fetch();
50
+ return netInfo.isConnected === true && netInfo.isInternetReachable !== false;
51
+ } catch (error) {
52
+ console.warn('⚠️ Failed to check network connectivity:', error);
53
+ // If we can't check connectivity, assume we're connected and let the request fail naturally
54
+ return true;
55
+ }
56
+ };
57
+
58
+ // API endpoints for different environments (updated to handle non-existent dev endpoint)
59
+ const API_ENDPOINTS = {
60
+ production: `${API_CONFIG.BASE_URL}`,
61
+ staging: `${API_CONFIG.BASE_URL}`,
62
+ // Fallback to production for staging
63
+ development: `${API_CONFIG.BASE_URL}` // Fallback to production since dev-API server doesn't exist
64
+ };
65
+
66
+ /**
67
+ * Initialize the SDK with developer API key
68
+ * @param config API configuration including developer API key
69
+ */
70
+ export const initializeApiKey = async config => {
71
+ try {
72
+ console.log('🔑 Initializing Onairos SDK with developer API key...');
73
+ if (!config.apiKey) {
74
+ throw new Error('Developer API key is required for SDK initialization');
75
+ }
76
+
77
+ // Validate developer key format
78
+ if (config.apiKey.length < 32) {
79
+ throw new Error('Invalid API key format. Developer keys must be at least 32 characters long.');
80
+ }
81
+
82
+ // Check for valid developer key prefix
83
+ const validPrefixes = ['dev_', 'ona_', 'pk_'];
84
+ const hasValidPrefix = validPrefixes.some(prefix => config.apiKey.startsWith(prefix));
85
+ if (!hasValidPrefix) {
86
+ throw new Error('Invalid API key format. Developer keys must start with dev_, ona_, or pk_');
87
+ }
88
+
89
+ // Set global configuration
90
+ globalConfig = {
91
+ apiKey: config.apiKey,
92
+ environment: config.environment || 'production',
93
+ enableLogging: config.enableLogging !== false,
94
+ // Default to true
95
+ timeout: config.timeout || 30000,
96
+ retryAttempts: config.retryAttempts || 3
97
+ };
98
+ if (globalConfig.enableLogging) {
99
+ console.log('📝 SDK Configuration:', {
100
+ environment: globalConfig.environment,
101
+ timeout: globalConfig.timeout,
102
+ retryAttempts: globalConfig.retryAttempts,
103
+ apiKeyPrefix: config.apiKey.substring(0, 8) + '...',
104
+ enableLogging: globalConfig.enableLogging
105
+ });
106
+ }
107
+
108
+ // Validate the API key (handles both admin and developer keys)
109
+ const validation = await validateApiKey(config.apiKey);
110
+ if (!validation.isValid) {
111
+ // Use defensive coding to handle cases where validation.error might be undefined
112
+ const errorMessage = validation.error || '';
113
+
114
+ // Check if it's a network/connectivity issue (either from error message or the flag)
115
+ 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');
116
+ if (isNetworkError) {
117
+ console.warn('⚠️ API key validation failed due to network/connectivity issues');
118
+ console.warn('🔄 Continuing in offline mode with basic validation');
119
+ console.warn('📝 SDK will function with limited validation. Network connectivity will be retried automatically.');
120
+ console.warn('🌐 Error details:', validation.error);
121
+
122
+ // Continue initialization in offline mode - don't throw error
123
+ console.log('📱 SDK initialized in offline mode - will retry validation when network is available');
124
+ } else {
125
+ // Only throw for actual API key validation errors (not network issues)
126
+ throw new Error(`API key validation failed: ${validation.error}`);
127
+ }
128
+ }
129
+
130
+ // Try to load existing JWT token
131
+ await loadJWT();
132
+ isInitialized = true;
133
+ if (globalConfig.enableLogging) {
134
+ console.log('✅ Onairos SDK initialized successfully');
135
+ console.log('🔑 Developer API key ready for app-level operations');
136
+ if (userToken) {
137
+ console.log('🎫 User JWT token loaded from storage');
138
+ }
139
+ if (validation.permissions) {
140
+ console.log('🔐 API Key Permissions:', validation.permissions);
141
+ }
142
+ if (validation.rateLimits) {
143
+ console.log('⏱️ Rate Limits:', validation.rateLimits);
144
+ }
145
+ }
146
+ } catch (error) {
147
+ console.error('❌ Failed to initialize Onairos SDK:', error);
148
+ isInitialized = false;
149
+ throw error;
150
+ }
151
+ };
152
+
153
+ /**
154
+ * Determine API key type
155
+ * @param apiKey The API key to check
156
+ * @returns The type of API key (only DEVELOPER or INVALID - admin keys not supported in client SDK)
157
+ */
158
+ export const getApiKeyType = apiKey => {
159
+ // Developer keys must be at least 32 characters and start with specific prefix
160
+ if (apiKey.length >= 32 && (apiKey.startsWith('dev_') || apiKey.startsWith('pk_') || apiKey.startsWith('ona_'))) {
161
+ return ApiKeyType.DEVELOPER;
162
+ }
163
+ return ApiKeyType.INVALID;
164
+ };
165
+
166
+ /**
167
+ * Validate an API key with the Onairos backend
168
+ * All developer keys must be validated against the backend - no local bypass
169
+ * @param apiKey The API key to validate
170
+ * @returns Validation result with permissions and rate limits
171
+ */
172
+ export const validateApiKey = async apiKey => {
173
+ try {
174
+ var _globalConfig2, _globalConfig3, _globalConfig4;
175
+ console.log('🔍 Validating developer API key against backend...');
176
+
177
+ // Check basic format for developer keys
178
+ const keyType = getApiKeyType(apiKey);
179
+ if (keyType === ApiKeyType.INVALID) {
180
+ return {
181
+ isValid: false,
182
+ error: 'Invalid API key format. Developer keys must be at least 32 characters and start with "dev_", "pk_", or "ona_"',
183
+ keyType: ApiKeyType.INVALID
184
+ };
185
+ }
186
+
187
+ // Check cache first
188
+ const cached = validationCache.get(apiKey);
189
+ if (cached && Date.now() - cached.timestamp < CACHE_DURATION) {
190
+ var _globalConfig;
191
+ if ((_globalConfig = globalConfig) !== null && _globalConfig !== void 0 && _globalConfig.enableLogging) {
192
+ console.log('📋 Using cached API key validation result');
193
+ }
194
+ return cached.result;
195
+ }
196
+
197
+ // Check network connectivity before making API calls
198
+ const isConnected = await checkNetworkConnectivity();
199
+ if (!isConnected) {
200
+ console.warn('⚠️ No network connectivity detected');
201
+ return {
202
+ isValid: false,
203
+ error: 'No network connection available. Please check your internet connection and try again.',
204
+ keyType: keyType,
205
+ isNetworkError: true
206
+ };
207
+ }
208
+ const environment = ((_globalConfig2 = globalConfig) === null || _globalConfig2 === void 0 ? void 0 : _globalConfig2.environment) || 'production';
209
+ const baseUrl = API_ENDPOINTS[environment];
210
+ const timeout = ((_globalConfig3 = globalConfig) === null || _globalConfig3 === void 0 ? void 0 : _globalConfig3.timeout) || 30000;
211
+ const maxRetries = ((_globalConfig4 = globalConfig) === null || _globalConfig4 === void 0 ? void 0 : _globalConfig4.retryAttempts) || 3;
212
+
213
+ // Retry logic for network failures
214
+ for (let attempt = 1; attempt <= maxRetries; attempt++) {
215
+ // Create abort controller for timeout
216
+ const controller = new AbortController();
217
+ const timeoutId = setTimeout(() => controller.abort(), timeout);
218
+ try {
219
+ var _globalConfig5;
220
+ if ((_globalConfig5 = globalConfig) !== null && _globalConfig5 !== void 0 && _globalConfig5.enableLogging && attempt > 1) {
221
+ console.log(`🔄 Retry attempt ${attempt}/${maxRetries} for API key validation`);
222
+ }
223
+ const response = await fetch(`${baseUrl}/dev/validate-apikey`, {
224
+ method: 'POST',
225
+ headers: {
226
+ 'Content-Type': 'application/json',
227
+ 'Authorization': `Bearer ${apiKey}`,
228
+ 'User-Agent': 'OnairosReactNative/3.3.1',
229
+ 'X-API-Key-Type': keyType,
230
+ 'X-SDK-Platform': 'react-native',
231
+ 'X-Retry-Attempt': attempt.toString()
232
+ },
233
+ body: JSON.stringify({
234
+ environment,
235
+ sdk_version: '3.3.1',
236
+ platform: 'react-native',
237
+ keyType,
238
+ timestamp: new Date().toISOString(),
239
+ attempt
240
+ }),
241
+ signal: controller.signal
242
+ });
243
+ clearTimeout(timeoutId);
244
+
245
+ // First check if we got a valid response
246
+ if (!response) {
247
+ throw new Error('No response received from server');
248
+ }
249
+
250
+ // Handle common HTTP errors that indicate server issues
251
+ if (response.status === 502) {
252
+ throw new Error('Onairos API is temporarily unavailable (502 Bad Gateway). Please try again later.');
253
+ }
254
+ if (response.status === 503) {
255
+ throw new Error('Onairos API is under maintenance (503 Service Unavailable). Please try again later.');
256
+ }
257
+ if (response.status === 504) {
258
+ throw new Error('Onairos API request timed out (504 Gateway Timeout). Please try again.');
259
+ }
260
+
261
+ // Check if response is actually JSON before trying to parse
262
+ const contentType = response.headers.get('content-type');
263
+ const isJsonResponse = contentType && contentType.includes('application/json');
264
+ if (!isJsonResponse) {
265
+ const textContent = await response.text();
266
+ const previewText = textContent.substring(0, 200);
267
+ console.error('❌ API endpoint returned non-JSON response:', {
268
+ status: response.status,
269
+ statusText: response.statusText,
270
+ contentType: contentType || 'unknown',
271
+ preview: previewText,
272
+ url: `${baseUrl}/dev/validate-apikey`,
273
+ attempt: attempt
274
+ });
275
+
276
+ // Handle specific error cases
277
+ if (response.status === 404) {
278
+ throw new Error(`API validation endpoint not found (404). The endpoint ${baseUrl}/dev/validate-apikey may not exist or be configured correctly.`);
279
+ } else if (response.status === 500) {
280
+ throw new Error(`Server error (500). The Onairos backend is experiencing issues.`);
281
+ } else if (response.status === 502 || response.status === 503) {
282
+ throw new Error(`Service unavailable (${response.status}). The Onairos backend may be temporarily down.`);
283
+ } else if (textContent.includes('<html') || textContent.includes('<!DOCTYPE')) {
284
+ throw new Error(`Server returned HTML page instead of JSON API response. This often indicates a routing issue or server misconfiguration.`);
285
+ } else {
286
+ throw new Error(`API validation endpoint returned ${response.status} - ${response.statusText}. Expected JSON but got ${contentType || 'unknown content type'}.`);
287
+ }
288
+ }
289
+
290
+ // Parse JSON response
291
+ let data;
292
+ try {
293
+ data = await response.json();
294
+ } catch (jsonError) {
295
+ console.error('❌ Failed to parse JSON response:', {
296
+ error: jsonError.message,
297
+ status: response.status,
298
+ contentType,
299
+ attempt: attempt
300
+ });
301
+ throw new Error(`Failed to parse server response as JSON: ${jsonError.message}`);
302
+ }
303
+
304
+ // Handle successful response
305
+ // Backend returns either {success: true} or {valid: true}
306
+ if (response.ok && (data.success || data.valid)) {
307
+ var _globalConfig6;
308
+ const result = {
309
+ isValid: true,
310
+ permissions: data.permissions || [],
311
+ rateLimits: data.rateLimits || null,
312
+ keyType: keyType
313
+ };
314
+
315
+ // Cache the successful result
316
+ validationCache.set(apiKey, {
317
+ result,
318
+ timestamp: Date.now()
319
+ });
320
+ if ((_globalConfig6 = globalConfig) !== null && _globalConfig6 !== void 0 && _globalConfig6.enableLogging) {
321
+ var _data$apiKey, _data$application, _data$apiKey2;
322
+ console.log('✅ API key validation successful', {
323
+ apiKeyId: (_data$apiKey = data.apiKey) === null || _data$apiKey === void 0 ? void 0 : _data$apiKey.id,
324
+ appName: (_data$application = data.application) === null || _data$application === void 0 ? void 0 : _data$application.name,
325
+ usageCount: (_data$apiKey2 = data.apiKey) === null || _data$apiKey2 === void 0 ? void 0 : _data$apiKey2.usageCount
326
+ });
327
+ }
328
+ return result;
329
+ } else {
330
+ // Handle API errors (invalid key, etc.)
331
+ const errorMessage = data.error || data.message || `HTTP ${response.status}: ${response.statusText}`;
332
+ const result = {
333
+ isValid: false,
334
+ error: errorMessage,
335
+ keyType: keyType
336
+ };
337
+
338
+ // For client errors (4xx), don't retry
339
+ if (response.status >= 400 && response.status < 500) {
340
+ var _globalConfig7;
341
+ if ((_globalConfig7 = globalConfig) !== null && _globalConfig7 !== void 0 && _globalConfig7.enableLogging) {
342
+ console.error('❌ API key validation failed (client error):', errorMessage);
343
+ }
344
+ return result;
345
+ }
346
+
347
+ // For server errors (5xx), retry
348
+ throw new Error(errorMessage);
349
+ }
350
+ } catch (fetchError) {
351
+ var _globalConfig8;
352
+ clearTimeout(timeoutId);
353
+ if (fetchError.name === 'AbortError') {
354
+ const errorMessage = `API key validation timeout (${timeout}ms)`;
355
+ console.error('⏱️ API key validation timeout');
356
+ if (attempt === maxRetries) {
357
+ return {
358
+ isValid: false,
359
+ error: errorMessage,
360
+ keyType: keyType
361
+ };
362
+ }
363
+ continue; // Retry timeout errors
364
+ }
365
+
366
+ // Enhanced error message based on error type
367
+ let errorMessage = `Network error during API key validation: ${fetchError.message}`;
368
+
369
+ // Add specific guidance for common errors
370
+ if (fetchError.message.includes('JSON Parse error') || fetchError.message.includes('Unexpected character')) {
371
+ 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}`;
372
+ } else if (fetchError.message.includes('Network request failed') || fetchError.message.includes('fetch')) {
373
+ errorMessage = `Network connectivity issue. Please check internet connection and verify the Onairos API is accessible. ${fetchError.message}`;
374
+ } else if (fetchError.message.includes('DNS') || fetchError.message.includes('ENOTFOUND')) {
375
+ errorMessage = `DNS resolution failed for ${baseUrl}. Please check network settings and domain accessibility. ${fetchError.message}`;
376
+ }
377
+ console.error('🌐 Network error during API key validation:', {
378
+ error: fetchError,
379
+ endpoint: `${baseUrl}/dev/validate-apikey`,
380
+ attempt: attempt,
381
+ maxRetries: maxRetries,
382
+ retryable: attempt < maxRetries
383
+ });
384
+
385
+ // If this is the last attempt, return the error
386
+ if (attempt === maxRetries) {
387
+ return {
388
+ isValid: false,
389
+ error: errorMessage,
390
+ keyType: keyType,
391
+ isNetworkError: true // Flag to indicate this is a network issue, not an API key issue
392
+ };
393
+ }
394
+
395
+ // Wait before retrying (exponential backoff)
396
+ const backoffDelay = Math.min(1000 * Math.pow(2, attempt - 1), 5000);
397
+ if ((_globalConfig8 = globalConfig) !== null && _globalConfig8 !== void 0 && _globalConfig8.enableLogging) {
398
+ console.log(`⏳ Waiting ${backoffDelay}ms before retry...`);
399
+ }
400
+ await new Promise(resolve => setTimeout(() => resolve(), backoffDelay));
401
+ }
402
+ }
403
+
404
+ // This should never be reached, but just in case
405
+ return {
406
+ isValid: false,
407
+ error: 'All retry attempts exhausted',
408
+ keyType: keyType
409
+ };
410
+ } catch (error) {
411
+ const errorMessage = `API key validation error: ${error.message}`;
412
+ console.error('❌ API key validation error:', error);
413
+ return {
414
+ isValid: false,
415
+ error: errorMessage,
416
+ keyType: ApiKeyType.INVALID
417
+ };
418
+ }
419
+ };
420
+
421
+ /**
422
+ * Get the current API configuration
423
+ * @returns Current API configuration or null if not initialized
424
+ */
425
+ export const getApiConfig = () => {
426
+ return globalConfig;
427
+ };
428
+
429
+ /**
430
+ * Get the current API key
431
+ * @returns Current API key or null if not initialized
432
+ */
433
+ export const getApiKey = () => {
434
+ var _globalConfig9;
435
+ return ((_globalConfig9 = globalConfig) === null || _globalConfig9 === void 0 ? void 0 : _globalConfig9.apiKey) || null;
436
+ };
437
+
438
+ /**
439
+ * Check if the SDK is properly initialized
440
+ * @returns True if initialized with valid API key
441
+ */
442
+ export const isApiKeyInitialized = () => {
443
+ return isInitialized && globalConfig !== null;
444
+ };
445
+
446
+ /**
447
+ * Store JWT token securely after email verification
448
+ * @param token JWT token from email verification response
449
+ */
450
+ export const storeJWT = async token => {
451
+ try {
452
+ var _globalConfig0;
453
+ await AsyncStorage.setItem(JWT_TOKEN_KEY, token);
454
+ userToken = token;
455
+ if ((_globalConfig0 = globalConfig) !== null && _globalConfig0 !== void 0 && _globalConfig0.enableLogging) {
456
+ console.log('🎫 JWT token stored successfully');
457
+ }
458
+ } catch (error) {
459
+ console.error('❌ Failed to store JWT token:', error);
460
+ throw error;
461
+ }
462
+ };
463
+
464
+ /**
465
+ * Load JWT token from storage
466
+ * @returns JWT token or null if not found
467
+ */
468
+ export const loadJWT = async () => {
469
+ try {
470
+ const token = await AsyncStorage.getItem(JWT_TOKEN_KEY);
471
+ userToken = token;
472
+ return token;
473
+ } catch (error) {
474
+ console.error('❌ Failed to load JWT token:', error);
475
+ return null;
476
+ }
477
+ };
478
+
479
+ /**
480
+ * Get current JWT token
481
+ * @returns JWT token or null if not available
482
+ */
483
+ export const getJWT = () => {
484
+ return userToken;
485
+ };
486
+
487
+ /**
488
+ * Clear JWT token (on logout or token expiration)
489
+ */
490
+ export const clearJWT = async () => {
491
+ try {
492
+ var _globalConfig1;
493
+ await AsyncStorage.removeItem(JWT_TOKEN_KEY);
494
+ userToken = null;
495
+ if ((_globalConfig1 = globalConfig) !== null && _globalConfig1 !== void 0 && _globalConfig1.enableLogging) {
496
+ console.log('🗑️ JWT token cleared');
497
+ }
498
+ } catch (error) {
499
+ console.error('❌ Failed to clear JWT token:', error);
500
+ }
501
+ };
502
+
503
+ /**
504
+ * React Native compatible base64 decoder
505
+ * @param str Base64 encoded string
506
+ * @returns Decoded string
507
+ */
508
+ const base64Decode = str => {
509
+ // Simple base64 decoding for React Native
510
+ const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
511
+ let result = '';
512
+ let i = 0;
513
+ str = str.replace(/[^A-Za-z0-9+/]/g, '');
514
+ while (i < str.length) {
515
+ const a = chars.indexOf(str.charAt(i++));
516
+ const b = chars.indexOf(str.charAt(i++));
517
+ const c = chars.indexOf(str.charAt(i++));
518
+ const d = chars.indexOf(str.charAt(i++));
519
+ const bitmap = a << 18 | b << 12 | c << 6 | d;
520
+ result += String.fromCharCode(bitmap >> 16 & 255);
521
+ if (c !== 64) result += String.fromCharCode(bitmap >> 8 & 255);
522
+ if (d !== 64) result += String.fromCharCode(bitmap & 255);
523
+ }
524
+ return result;
525
+ };
526
+
527
+ /**
528
+ * Decode JWT token payload (React Native compatible)
529
+ * @param token JWT token string
530
+ * @returns Decoded payload or null if invalid
531
+ */
532
+ export const decodeJWTPayload = token => {
533
+ try {
534
+ // Split JWT token (header.payload.signature)
535
+ const parts = token.split('.');
536
+ if (parts.length !== 3) {
537
+ console.error('❌ Invalid JWT token format');
538
+ return null;
539
+ }
540
+
541
+ // Decode payload (base64url to base64)
542
+ const payload = parts[1];
543
+ const base64 = payload.replace(/-/g, '+').replace(/_/g, '/');
544
+
545
+ // Add padding if needed
546
+ const padded = base64.padEnd(Math.ceil(base64.length / 4) * 4, '=');
547
+
548
+ // Decode base64 to JSON using React Native compatible decoder
549
+ const decoded = base64Decode(padded);
550
+ return JSON.parse(decoded);
551
+ } catch (error) {
552
+ console.error('❌ Failed to decode JWT token:', error);
553
+ return null;
554
+ }
555
+ };
556
+
557
+ /**
558
+ * Extract username from JWT token
559
+ * @param token JWT token (optional, uses stored token if not provided)
560
+ * @returns Username or null if not found
561
+ */
562
+ export const extractUsernameFromJWT = token => {
563
+ try {
564
+ var _globalConfig10;
565
+ const jwtToken = token || userToken;
566
+ if (!jwtToken) {
567
+ console.warn('⚠️ No JWT token available for username extraction');
568
+ return null;
569
+ }
570
+ const payload = decodeJWTPayload(jwtToken);
571
+ if (!payload) {
572
+ return null;
573
+ }
574
+
575
+ // Try different possible username fields in order of preference
576
+ const username = payload.userName || payload.username || payload.userId || payload.email;
577
+ if ((_globalConfig10 = globalConfig) !== null && _globalConfig10 !== void 0 && _globalConfig10.enableLogging) {
578
+ console.log('👤 Extracted username from JWT:', username);
579
+ }
580
+ return username || null;
581
+ } catch (error) {
582
+ console.error('❌ Failed to extract username from JWT:', error);
583
+ return null;
584
+ }
585
+ };
586
+
587
+ /**
588
+ * Extract user data from JWT token
589
+ * @param token JWT token (optional, uses stored token if not provided)
590
+ * @returns User data object or null if not found
591
+ */
592
+ export const extractUserDataFromJWT = token => {
593
+ try {
594
+ var _globalConfig11;
595
+ const jwtToken = token || userToken;
596
+ if (!jwtToken) {
597
+ console.warn('⚠️ No JWT token available for user data extraction');
598
+ return null;
599
+ }
600
+ const payload = decodeJWTPayload(jwtToken);
601
+ if (!payload) {
602
+ return null;
603
+ }
604
+ const userData = {
605
+ id: payload.id,
606
+ email: payload.email,
607
+ userId: payload.userId,
608
+ userName: payload.userName || payload.username,
609
+ verified: payload.verified,
610
+ iat: payload.iat,
611
+ exp: payload.exp
612
+ };
613
+ if ((_globalConfig11 = globalConfig) !== null && _globalConfig11 !== void 0 && _globalConfig11.enableLogging) {
614
+ console.log('👤 Extracted user data from JWT:', userData);
615
+ }
616
+ return userData;
617
+ } catch (error) {
618
+ console.error('❌ Failed to extract user data from JWT:', error);
619
+ return null;
620
+ }
621
+ };
622
+
623
+ /**
624
+ * Check if user is authenticated with JWT token
625
+ * @returns True if user has valid JWT token
626
+ */
627
+ export const isUserAuthenticated = () => {
628
+ return !!userToken;
629
+ };
630
+
631
+ /**
632
+ * Get authenticated headers for API requests
633
+ * @returns Headers object with Authorization and other required headers
634
+ */
635
+ export const getAuthHeaders = () => {
636
+ var _globalConfig12;
637
+ if (!((_globalConfig12 = globalConfig) !== null && _globalConfig12 !== void 0 && _globalConfig12.apiKey)) {
638
+ throw new Error('SDK not initialized. Call initializeApiKey() first.');
639
+ }
640
+ const keyType = getApiKeyType(globalConfig.apiKey);
641
+ return {
642
+ 'Content-Type': 'application/json',
643
+ 'Authorization': `Bearer ${globalConfig.apiKey}`,
644
+ 'User-Agent': 'OnairosReactNative/3.0.72',
645
+ 'X-SDK-Version': '3.0.72',
646
+ 'X-SDK-Environment': globalConfig.environment || 'production',
647
+ 'X-API-Key-Type': keyType,
648
+ 'X-Timestamp': new Date().toISOString()
649
+ };
650
+ };
651
+
652
+ /**
653
+ * Get authentication headers for developer API requests
654
+ * @returns Headers with developer API key
655
+ */
656
+ export const getDeveloperAuthHeaders = () => {
657
+ var _globalConfig13;
658
+ if (!((_globalConfig13 = globalConfig) !== null && _globalConfig13 !== void 0 && _globalConfig13.apiKey)) {
659
+ throw new Error('SDK not initialized. Call initializeApiKey() first.');
660
+ }
661
+ const keyType = getApiKeyType(globalConfig.apiKey);
662
+ return {
663
+ 'Content-Type': 'application/json',
664
+ 'Authorization': `Bearer ${globalConfig.apiKey}`,
665
+ 'User-Agent': 'OnairosSDK/1.0.0',
666
+ 'X-SDK-Version': '3.0.72',
667
+ 'X-SDK-Environment': globalConfig.environment || 'production',
668
+ 'X-API-Key-Type': keyType,
669
+ 'X-Timestamp': new Date().toISOString()
670
+ };
671
+ };
672
+
673
+ /**
674
+ * Get authentication headers for user JWT requests
675
+ * @returns Headers with user JWT token
676
+ */
677
+ export const getUserAuthHeaders = () => {
678
+ var _globalConfig14;
679
+ if (!userToken) {
680
+ throw new Error('User not authenticated. Please verify email first.');
681
+ }
682
+ return {
683
+ 'Content-Type': 'application/json',
684
+ 'Authorization': `Bearer ${userToken}`,
685
+ 'User-Agent': 'OnairosSDK/1.0.0',
686
+ 'X-SDK-Version': '3.0.72',
687
+ 'X-SDK-Environment': ((_globalConfig14 = globalConfig) === null || _globalConfig14 === void 0 ? void 0 : _globalConfig14.environment) || 'production'
688
+ };
689
+ };
690
+
691
+ /**
692
+ * Make an authenticated API request
693
+ * @param endpoint The API endpoint (relative to base URL)
694
+ * @param options Fetch options
695
+ * @returns Response promise
696
+ */
697
+ export const makeAuthenticatedRequest = async (endpoint, options = {}) => {
698
+ if (!isApiKeyInitialized()) {
699
+ throw new Error('SDK not initialized. Call initializeApiKey() first.');
700
+ }
701
+ const config = getApiConfig();
702
+ const baseUrl = API_ENDPOINTS[config.environment || 'production'];
703
+ const url = `${baseUrl}${endpoint.startsWith('/') ? '' : '/'}${endpoint}`;
704
+
705
+ // Merge authentication headers
706
+ const headers = {
707
+ ...getAuthHeaders(),
708
+ ...(options.headers || {})
709
+ };
710
+
711
+ // Add timeout
712
+ const controller = new AbortController();
713
+ const timeoutId = setTimeout(() => controller.abort(), config.timeout || 30000);
714
+ try {
715
+ if (config.enableLogging) {
716
+ console.log(`🌐 Making authenticated request to: ${endpoint}`);
717
+ }
718
+ const response = await fetch(url, {
719
+ ...options,
720
+ headers,
721
+ signal: controller.signal
722
+ });
723
+ clearTimeout(timeoutId);
724
+ if (config.enableLogging) {
725
+ console.log(`📡 Response status: ${response.status} for ${endpoint}`);
726
+ }
727
+
728
+ // Handle API key errors
729
+ if (response.status === 401) {
730
+ console.error('❌ API key authentication failed. Please check your API key.');
731
+ throw new Error('Invalid or expired API key');
732
+ }
733
+ if (response.status === 403) {
734
+ console.error('❌ API key permissions insufficient for this operation.');
735
+ throw new Error('Insufficient API key permissions');
736
+ }
737
+ if (response.status === 429) {
738
+ console.error('❌ API rate limit exceeded. Please try again later.');
739
+ throw new Error('Rate limit exceeded');
740
+ }
741
+ return response;
742
+ } catch (error) {
743
+ clearTimeout(timeoutId);
744
+ if (error.name === 'AbortError') {
745
+ console.error('⏱️ Request timeout for:', endpoint);
746
+ throw new Error('Request timeout');
747
+ }
748
+ throw error;
749
+ }
750
+ };
751
+
752
+ /**
753
+ * Make authenticated request with developer API key
754
+ * @param endpoint The API endpoint
755
+ * @param options Fetch options
756
+ * @returns Response promise
757
+ */
758
+ export const makeDeveloperRequest = async (endpoint, options = {}) => {
759
+ if (!isApiKeyInitialized()) {
760
+ throw new Error('SDK not initialized. Call initializeApiKey() first.');
761
+ }
762
+ const config = getApiConfig();
763
+ const baseUrl = API_ENDPOINTS[config.environment || 'production'];
764
+ const url = `${baseUrl}${endpoint.startsWith('/') ? '' : '/'}${endpoint}`;
765
+
766
+ // Merge developer authentication headers
767
+ const headers = {
768
+ ...getDeveloperAuthHeaders(),
769
+ ...(options.headers || {})
770
+ };
771
+
772
+ // Add timeout
773
+ const controller = new AbortController();
774
+ const timeoutId = setTimeout(() => controller.abort(), config.timeout || 30000);
775
+ try {
776
+ if (config.enableLogging) {
777
+ console.log(`🌐 Making developer request to: ${endpoint}`);
778
+ }
779
+ const response = await fetch(url, {
780
+ ...options,
781
+ headers,
782
+ signal: controller.signal
783
+ });
784
+ clearTimeout(timeoutId);
785
+ if (config.enableLogging) {
786
+ console.log(`📡 Developer request response: ${response.status} for ${endpoint}`);
787
+ }
788
+
789
+ // Handle API key errors
790
+ if (response.status === 401) {
791
+ console.error('❌ Developer API key authentication failed');
792
+ throw new Error('Invalid or expired API key');
793
+ }
794
+ if (response.status === 403) {
795
+ console.error('❌ Developer API key permissions insufficient');
796
+ throw new Error('Insufficient API key permissions');
797
+ }
798
+ if (response.status === 429) {
799
+ console.error('❌ API rate limit exceeded');
800
+ throw new Error('Rate limit exceeded');
801
+ }
802
+ return response;
803
+ } catch (error) {
804
+ clearTimeout(timeoutId);
805
+ if (error.name === 'AbortError') {
806
+ console.error('⏱️ Request timeout for:', endpoint);
807
+ throw new Error('Request timeout');
808
+ }
809
+ throw error;
810
+ }
811
+ };
812
+
813
+ /**
814
+ * Make authenticated request with user JWT token
815
+ * @param endpoint The API endpoint
816
+ * @param options Fetch options
817
+ * @returns Response promise
818
+ */
819
+ export const makeUserRequest = async (endpoint, options = {}) => {
820
+ if (!isUserAuthenticated()) {
821
+ await loadJWT(); // Try to load from storage
822
+ }
823
+ if (!isUserAuthenticated()) {
824
+ throw new Error('User not authenticated. Please verify email first.');
825
+ }
826
+ const config = getApiConfig() || {
827
+ environment: 'production',
828
+ timeout: 30000,
829
+ enableLogging: false
830
+ };
831
+ const baseUrl = API_ENDPOINTS[config.environment || 'production'];
832
+ const url = `${baseUrl}${endpoint.startsWith('/') ? '' : '/'}${endpoint}`;
833
+
834
+ // Merge user authentication headers
835
+ const headers = {
836
+ ...getUserAuthHeaders(),
837
+ ...(options.headers || {})
838
+ };
839
+
840
+ // Add timeout
841
+ const controller = new AbortController();
842
+ const timeoutId = setTimeout(() => controller.abort(), config.timeout || 30000);
843
+ try {
844
+ if (config.enableLogging) {
845
+ console.log(`🌐 Making user request to: ${endpoint}`);
846
+ }
847
+ const response = await fetch(url, {
848
+ ...options,
849
+ headers,
850
+ signal: controller.signal
851
+ });
852
+ clearTimeout(timeoutId);
853
+ if (config.enableLogging) {
854
+ console.log(`📡 User request response: ${response.status} for ${endpoint}`);
855
+ }
856
+
857
+ // Handle JWT token errors
858
+ if (response.status === 401) {
859
+ console.error('❌ JWT token authentication failed - token may be expired');
860
+ await clearJWT(); // Clear expired token
861
+ throw new Error('Authentication expired. Please verify email again.');
862
+ }
863
+ if (response.status === 403) {
864
+ console.error('❌ JWT token permissions insufficient');
865
+ throw new Error('Insufficient permissions for this operation');
866
+ }
867
+ return response;
868
+ } catch (error) {
869
+ clearTimeout(timeoutId);
870
+ if (error.name === 'AbortError') {
871
+ console.error('⏱️ Request timeout for:', endpoint);
872
+ throw new Error('Request timeout');
873
+ }
874
+ throw error;
875
+ }
876
+ };
877
+
878
+ /**
879
+ * Clear the API key validation cache
880
+ */
881
+ export const clearValidationCache = () => {
882
+ var _globalConfig15;
883
+ validationCache.clear();
884
+ if ((_globalConfig15 = globalConfig) !== null && _globalConfig15 !== void 0 && _globalConfig15.enableLogging) {
885
+ console.log('🗑️ API key validation cache cleared');
886
+ }
887
+ };
888
+
889
+ /**
890
+ * Reset the SDK initialization state
891
+ */
892
+ export const resetApiKeyService = () => {
893
+ globalConfig = null;
894
+ isInitialized = false;
895
+ clearValidationCache();
896
+ console.log('🔄 API key service reset');
897
+ };
898
+ //# sourceMappingURL=apiKeyService.js.map