@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,9 +1,924 @@
1
- 'use strict';
2
- // Onairos SDK - Asset Registry (auto-generated)
3
- var __ONAIROS_REQ_REGISTRY__ = [
4
- require("@react-native-async-storage/async-storage"),
5
- require("@react-native-community/netinfo"),
6
- require("../config/api")
7
- ];
8
- function __ONAIROS_REQ_FUNC__(i) { return __ONAIROS_REQ_REGISTRY__[i]; }
9
- Object[_0x3f91(0x0)](exports,'__esModule',{'value':!![]}),exports[_0x3f91(0x1)]=exports[_0x3f91(0x2)]=exports['resetApiKeyService']=exports[_0x3f91(0x3)]=exports[_0x3f91(0x4)]=exports[_0x3f91(0x5)]=exports[_0x3f91(0x6)]=exports[_0x3f91(0x7)]=exports[_0x3f91(0x8)]=exports['initializeApiKey']=exports[_0x3f91(0x9)]=exports['getJWT']=exports[_0x3f91(0xa)]=exports[_0x3f91(0xb)]=exports['getApiKeyType']=exports[_0x3f91(0xc)]=exports[_0x3f91(0xd)]=exports[_0x3f91(0xe)]=exports['extractUserDataFromJWT']=exports[_0x3f91(0xf)]=exports[_0x3f91(0x10)]=exports['clearJWT']=exports[_0x3f91(0x11)]=void 0x0;var _asyncStorage=_interopRequireDefault(__ONAIROS_REQ_FUNC__(0x0)),_netinfo=_interopRequireDefault(__ONAIROS_REQ_FUNC__(0x1)),_api=__ONAIROS_REQ_FUNC__(0x2);function _interopRequireDefault(_0x52ef85){return _0x52ef85&&_0x52ef85['__esModule']?_0x52ef85:{'default':_0x52ef85};}let ApiKeyType=exports[_0x3f91(0x11)]=function(_0x5ff73d){const _0x3512bc={'cnnkt':_0x3f91(0x12),'rofWa':_0x3f91(0x13),'eecmT':'INVALID','dGoCh':_0x3f91(0x14)};return _0x5ff73d[_0x3512bc['cnnkt']]=_0x3512bc['rofWa'],_0x5ff73d[_0x3512bc[_0x3f91(0x15)]]=_0x3512bc['dGoCh'],_0x5ff73d;}({});const JWT_TOKEN_KEY='onairos_jwt_token';let globalConfig=null,validationCache=new Map(),isInitialized=![],userToken=null;const CACHE_DURATION=0x5*0x3c*0x3e8,checkNetworkConnectivity=async()=>{const _0x4a5ece={'CIOqS':function(_0x23b59a,_0x27e973){return _0x23b59a===_0x27e973;},'YqPdO':function(_0x561383,_0x171094){return _0x561383!==_0x171094;},'FLIbg':_0x3f91(0x16)};try{const _0x19b35e=await _netinfo[_0x3f91(0x17)][_0x3f91(0x18)]();return _0x4a5ece[_0x3f91(0x19)](_0x19b35e[_0x3f91(0x1a)],!![])&&_0x4a5ece[_0x3f91(0x1b)](_0x19b35e[_0x3f91(0x1c)],![]);}catch(_0x2cfbd4){return console[_0x3f91(0x1d)](_0x4a5ece['FLIbg'],_0x2cfbd4),!![];}},API_ENDPOINTS={'production':''+_api[_0x3f91(0x1e)]['BASE_URL'],'staging':''+_api[_0x3f91(0x1e)][_0x3f91(0x1f)],'development':''+_api[_0x3f91(0x1e)][_0x3f91(0x1f)]},initializeApiKey=async _0x5bee42=>{const _0x31fc8b={'hhnXT':function(_0xc91646,_0x235558){return _0xc91646!==_0x235558;},'yyqaL':_0x3f91(0x20),'XbLCg':function(_0x209ff4,_0x3afb88){return _0x209ff4(_0x3afb88);},'YKUmT':'3.0.72','bGqUW':_0x3f91(0x21),'Xvrns':_0x3f91(0x22),'JGCBk':_0x3f91(0x23),'wshuG':function(_0xf7b926,_0x48c72f){return _0xf7b926===_0x48c72f;},'OOnys':'GCkFO','SsNBV':_0x3f91(0x24),'dPCHC':function(_0x3f9016,_0x112108){return _0x3f9016<_0x112108;},'oHDpn':_0x3f91(0x25),'SUhMh':_0x3f91(0x26),'hGRdZ':_0x3f91(0x27),'rdhfd':_0x3f91(0x28),'ZKWrF':_0x3f91(0x29),'PVOnE':'📝\x20SDK\x20Configuration:','jDpUB':function(_0x10c88d,_0x414a15){return _0x10c88d+_0x414a15;},'wMvaN':_0x3f91(0x2a),'fZPuA':'JSON\x20Parse\x20error','QQgPc':_0x3f91(0x2b),'tXZth':_0x3f91(0x2c),'ZFsLb':_0x3f91(0x2d),'EtOCD':_0x3f91(0x2e),'Oxlno':_0x3f91(0x2f),'Sbfjk':_0x3f91(0x30),'xgyGj':_0x3f91(0x31),'IczMp':'✅\x20Onairos\x20SDK\x20initialized\x20successfully','tDzxT':_0x3f91(0x32),'jtabz':_0x3f91(0x33),'LXxET':function(_0x44099a,_0x3ddcd0){return _0x44099a!==_0x3ddcd0;},'fGIhc':_0x3f91(0x34),'jcDPQ':'⏱️\x20Rate\x20Limits:','KqjRn':_0x3f91(0x35),'MZuMI':'SVlBc','pJaEG':'❌\x20Failed\x20to\x20initialize\x20Onairos\x20SDK:'};try{console[_0x3f91(0x36)](_0x31fc8b[_0x3f91(0x37)]);if(!_0x5bee42[_0x3f91(0x38)]){if(_0x31fc8b[_0x3f91(0x39)](_0x31fc8b[_0x3f91(0x3a)],_0x31fc8b['OOnys']))throw new Error(_0x31fc8b[_0x3f91(0x3b)]);else{var _0x13ee34;if(!((_0x13ee34=_0x6c9c48)!==null&&_0x31fc8b[_0x3f91(0x3c)](_0x13ee34,void 0x0)&&_0x13ee34[_0x3f91(0x38)]))throw new _0xd6215b(_0x31fc8b[_0x3f91(0x3d)]);const _0x1b23c4=_0x31fc8b[_0x3f91(0x3e)](_0x1a4ace,_0x586c62[_0x3f91(0x38)]);return{'Content-Type':'application/json','Authorization':_0x3f91(0x3f)+_0x5b70f6[_0x3f91(0x38)],'User-Agent':_0x3f91(0x40),'X-SDK-Version':_0x31fc8b['YKUmT'],'X-SDK-Environment':_0x23bfed[_0x3f91(0x41)]||_0x3f91(0x42),'X-API-Key-Type':_0x1b23c4,'X-Timestamp':new _0x2c49fb()[_0x3f91(0x43)]()};}}if(_0x31fc8b[_0x3f91(0x44)](_0x5bee42['apiKey'][_0x3f91(0x45)],0x20))throw new Error(_0x31fc8b['oHDpn']);const _0xdf45e5=[_0x31fc8b[_0x3f91(0x46)],_0x3f91(0x47),_0x31fc8b[_0x3f91(0x48)]],_0x346052=_0xdf45e5[_0x3f91(0x49)](_0x2a2f07=>_0x5bee42[_0x3f91(0x38)][_0x3f91(0x4a)](_0x2a2f07));if(!_0x346052)throw new Error(_0x31fc8b[_0x3f91(0x4b)]);globalConfig={'apiKey':_0x5bee42[_0x3f91(0x38)],'environment':_0x5bee42[_0x3f91(0x41)]||'production','enableLogging':_0x31fc8b['hhnXT'](_0x5bee42[_0x3f91(0x4c)],![]),'timeout':_0x5bee42[_0x3f91(0x2b)]||0x7530,'retryAttempts':_0x5bee42[_0x3f91(0x4d)]||0x3};globalConfig[_0x3f91(0x4c)]&&(_0x31fc8b[_0x3f91(0x4e)]!==_0x31fc8b[_0x3f91(0x4e)]?_0x202060[_0x3f91(0x36)](_0x3f91(0x4f),_0xdb8456):console[_0x3f91(0x36)](_0x31fc8b[_0x3f91(0x50)],{'environment':globalConfig[_0x3f91(0x41)],'timeout':globalConfig[_0x3f91(0x2b)],'retryAttempts':globalConfig['retryAttempts'],'apiKeyPrefix':_0x31fc8b[_0x3f91(0x51)](_0x5bee42[_0x3f91(0x38)]['substring'](0x0,0x8),_0x3f91(0x52)),'enableLogging':globalConfig[_0x3f91(0x4c)]}));const _0x1efb9e=await validateApiKey(_0x5bee42['apiKey']);if(!_0x1efb9e[_0x3f91(0x53)]){const _0x2588f4=_0x1efb9e[_0x3f91(0x54)]||'',_0x268e1c=_0x1efb9e['isNetworkError']||_0x2588f4[_0x3f91(0x55)]('Network\x20request\x20failed')||_0x2588f4['includes'](_0x31fc8b['wMvaN'])||_0x2588f4[_0x3f91(0x55)](_0x31fc8b[_0x3f91(0x56)])||_0x2588f4[_0x3f91(0x55)](_0x3f91(0x57))||_0x2588f4['includes'](_0x31fc8b[_0x3f91(0x58)])||_0x2588f4['includes'](_0x31fc8b[_0x3f91(0x59)])||_0x2588f4[_0x3f91(0x55)](_0x3f91(0x18))||_0x2588f4[_0x3f91(0x55)]('No\x20network\x20connection');if(_0x268e1c){const _0x58acc0=_0x31fc8b[_0x3f91(0x5a)][_0x3f91(0x5b)]('|');let _0x46e45a=0x0;while(!![]){switch(_0x58acc0[_0x46e45a++]){case'0':console[_0x3f91(0x1d)](_0x31fc8b[_0x3f91(0x5c)]);continue;case'1':console[_0x3f91(0x36)](_0x3f91(0x5d));continue;case'2':console['warn'](_0x31fc8b[_0x3f91(0x5e)],_0x1efb9e[_0x3f91(0x54)]);continue;case'3':console[_0x3f91(0x1d)](_0x31fc8b[_0x3f91(0x5f)]);continue;case'4':console['warn'](_0x31fc8b[_0x3f91(0x60)]);continue;}break;}}else throw new Error('API\x20key\x20validation\x20failed:\x20'+_0x1efb9e[_0x3f91(0x54)]);}await loadJWT(),isInitialized=!![];if(globalConfig[_0x3f91(0x4c)]){console[_0x3f91(0x36)](_0x31fc8b[_0x3f91(0x61)]),console[_0x3f91(0x36)](_0x3f91(0x62));userToken&&console[_0x3f91(0x36)](_0x31fc8b[_0x3f91(0x63)]);_0x1efb9e[_0x3f91(0x64)]&&console[_0x3f91(0x36)](_0x31fc8b[_0x3f91(0x65)],_0x1efb9e[_0x3f91(0x64)]);if(_0x1efb9e[_0x3f91(0x66)]){if(_0x31fc8b[_0x3f91(0x67)](_0x31fc8b['fGIhc'],_0x31fc8b['fGIhc'])){_0x2913af[_0x3f91(0x54)](_0x31fc8b[_0x3f91(0x68)],{'error':_0x4539c9[_0x3f91(0x69)],'status':_0x1f8e73[_0x3f91(0x6a)],'contentType':_0x89eb77,'attempt':_0x21094a});throw new _0x51cfe3(_0x3f91(0x6b)+_0x46763c[_0x3f91(0x69)]);}else console[_0x3f91(0x36)](_0x31fc8b['jcDPQ'],_0x1efb9e[_0x3f91(0x66)]);}}}catch(_0x4a6b90){if(_0x31fc8b[_0x3f91(0x6c)]!==_0x31fc8b[_0x3f91(0x6d)]){console[_0x3f91(0x54)](_0x31fc8b['pJaEG'],_0x4a6b90),isInitialized=![];throw _0x4a6b90;}else throw new _0x550ef7(_0x31fc8b[_0x3f91(0x6e)]);}};exports[_0x3f91(0x6f)]=initializeApiKey;const getApiKeyType=_0x429176=>{const _0x3ba56d={'mENBC':'pk_','ASLyZ':_0x3f91(0x47)};if(_0x429176['length']>=0x20&&(_0x429176['startsWith'](_0x3f91(0x26))||_0x429176[_0x3f91(0x4a)](_0x3ba56d['mENBC'])||_0x429176[_0x3f91(0x4a)](_0x3ba56d[_0x3f91(0x70)])))return ApiKeyType['DEVELOPER'];return ApiKeyType[_0x3f91(0x71)];};function _0x2f4d(){const _0x3310ed=['defineProperty','validateApiKey','storeJWT','makeUserRequest','makeDeveloperRequest','makeAuthenticatedRequest','loadJWT','isUserAuthenticated','isApiKeyInitialized','getUserAuthHeaders','getDeveloperAuthHeaders','getAuthHeaders','getApiKey','getApiConfig','extractUsernameFromJWT','decodeJWTPayload','clearValidationCache','ApiKeyType','DEVELOPER','developer','invalid','eecmT','⚠️\x20Failed\x20to\x20check\x20network\x20connectivity:','default','fetch','CIOqS','isConnected','YqPdO','isInternetReachable','warn','API_CONFIG','BASE_URL','SDK\x20not\x20initialized.\x20Call\x20initializeApiKey()\x20first.','❌\x20Failed\x20to\x20parse\x20JSON\x20response:','Onairos\x20API\x20is\x20temporarily\x20unavailable\x20(502\x20Bad\x20Gateway).\x20Please\x20try\x20again\x20later.','🔑\x20Initializing\x20Onairos\x20SDK\x20with\x20developer\x20API\x20key...','Developer\x20API\x20key\x20is\x20required\x20for\x20SDK\x20initialization','Invalid\x20API\x20key\x20format.\x20Developer\x20keys\x20must\x20be\x20at\x20least\x2032\x20characters\x20long.','dev_','pk_','Invalid\x20API\x20key\x20format.\x20Developer\x20keys\x20must\x20start\x20with\x20dev_,\x20ona_,\x20or\x20pk_','XpwIu','Network\x20error','timeout','ENOTFOUND','3|4|0|2|1','📝\x20SDK\x20will\x20function\x20with\x20limited\x20validation.\x20Network\x20connectivity\x20will\x20be\x20retried\x20automatically.','🌐\x20Error\x20details:','⚠️\x20API\x20key\x20validation\x20failed\x20due\x20to\x20network/connectivity\x20issues','🔄\x20Continuing\x20in\x20offline\x20mode\x20with\x20basic\x20validation','🎫\x20User\x20JWT\x20token\x20loaded\x20from\x20storage','🔐\x20API\x20Key\x20Permissions:','opMJe','xiYuj','log','JGCBk','apiKey','wshuG','OOnys','SsNBV','hhnXT','yyqaL','XbLCg','Bearer\x20','OnairosSDK/1.0.0','environment','production','toISOString','dPCHC','length','SUhMh','ona_','hGRdZ','some','startsWith','rdhfd','enableLogging','retryAttempts','ZKWrF','👤\x20Extracted\x20username\x20from\x20JWT:','PVOnE','jDpUB','...','isValid','error','includes','fZPuA','API\x20validation\x20endpoint\x20returned','QQgPc','tXZth','ZFsLb','split','EtOCD','📱\x20SDK\x20initialized\x20in\x20offline\x20mode\x20-\x20will\x20retry\x20validation\x20when\x20network\x20is\x20available','Oxlno','Sbfjk','xgyGj','IczMp','🔑\x20Developer\x20API\x20key\x20ready\x20for\x20app-level\x20operations','tDzxT','permissions','jtabz','rateLimits','LXxET','bGqUW','message','status','Failed\x20to\x20parse\x20server\x20response\x20as\x20JSON:\x20','KqjRn','MZuMI','Xvrns','initializeApiKey','ASLyZ','INVALID','getApiKeyType','1|4|3|2|0','⏱️\x20Rate\x20Limits:','🗑️\x20API\x20key\x20validation\x20cache\x20cleared','❌\x20API\x20key\x20validation\x20failed\x20(client\x20error):','Insufficient\x20permissions\x20for\x20this\x20operation','❌\x20Invalid\x20JWT\x20token\x20format','JSON\x20Parse\x20error','evWAw','KJcQD','🔍\x20Validating\x20developer\x20API\x20key\x20against\x20backend...','nVUko','⚠️\x20No\x20network\x20connectivity\x20detected','3.3.1','UOeoW','Onairos\x20API\x20is\x20under\x20maintenance\x20(503\x20Service\x20Unavailable).\x20Please\x20try\x20again\x20later.','wVBba','Onairos\x20API\x20request\x20timed\x20out\x20(504\x20Gateway\x20Timeout).\x20Please\x20try\x20again.','content-type','❌\x20API\x20endpoint\x20returned\x20non-JSON\x20response:','unknown','JdcQM','<!DOCTYPE','unknown\x20content\x20type','✅\x20API\x20key\x20validation\x20successful','fDdZu','ZFaPz','haBtL','Unexpected\x20character','NXAiH','NiNUr','wYszL','JfbmL','UMgbF','HZIdn','AjNdo','🌐\x20Making\x20authenticated\x20request\x20to:\x20','QtZRS','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','JrlPW','timestamp','kaJRL','📋\x20Using\x20cached\x20API\x20key\x20validation\x20result','result','BlLQg','zRnLl','tMLwL','Request\x20timeout','zRuaD','rsBQc','CawgC','abort','cnUYh','fwXxy','\x20for\x20API\x20key\x20validation','BDZVy','/dev/validate-apikey','OnairosReactNative/3.3.1','toString','signal','DazhY','DrXEs','iyiZs','✅\x20Onairos\x20SDK\x20initialized\x20successfully','OiYwK','BOhiQ','TbJeW','oJess','WrPld','CdDrv','ZIfIj','headers','MBnGl','text','substring','WDjQq','statusText','UjGrW','EVPSr','API\x20validation\x20endpoint\x20not\x20found\x20(404).\x20The\x20endpoint\x20','/dev/validate-apikey\x20may\x20not\x20exist\x20or\x20be\x20configured\x20correctly.','TWwMe','uuRXH','Server\x20error\x20(500).\x20The\x20Onairos\x20backend\x20is\x20experiencing\x20issues.','aznVA','Service\x20unavailable\x20(','<html','Server\x20returned\x20HTML\x20page\x20instead\x20of\x20JSON\x20API\x20response.\x20This\x20often\x20indicates\x20a\x20routing\x20issue\x20or\x20server\x20misconfiguration.','API\x20validation\x20endpoint\x20returned\x20','\x20-\x20','.\x20Expected\x20JSON\x20but\x20got\x20','GwPdv','json','success','valid','IyOfq','bpxfA','set','now','KAIHK','rZAQm','ZBVJA','gFpsg','name','ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/','replace','iVWqO','indexOf','charAt','DJrGz','QtrsD','shrMp','KZPdK','ocPgV','UgHEm','yqmXP','fromCharCode','GtIPB','HTTP\x20','pcIGV','RpPzi','EfHHE','tdLxT','❌\x20JWT\x20token\x20permissions\x20insufficient','FmrqA','jYlRF','qXzWL','🌐\x20Making\x20user\x20request\x20to:\x20','API\x20key\x20validation\x20timeout\x20(','ms)','⏱️\x20API\x20key\x20validation\x20timeout','pxVFr','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','gjmkK','MgORb','API\x20key\x20validation\x20failed:\x20','kjeSK','DNS\x20resolution\x20failed\x20for\x20','.\x20Please\x20check\x20network\x20settings\x20and\x20domain\x20accessibility.\x20','🌐\x20Network\x20error\x20during\x20API\x20key\x20validation:','MUBas','User\x20not\x20authenticated.\x20Please\x20verify\x20email\x20first.','cFwUe','jUPiK','⏳\x20Waiting\x20','ms\x20before\x20retry...','eCDsH','OJcsG','ceil','All\x20retry\x20attempts\x20exhausted','UdkJU','BriAc','JOWcJ','API\x20key\x20validation\x20error:\x20','❌\x20API\x20key\x20validation\x20error:','ssBVz','No\x20network\x20connection','1|2|0|4|3','vNmAV','jUeRq','🎫\x20JWT\x20token\x20stored\x20successfully','❌\x20Failed\x20to\x20store\x20JWT\x20token:','setItem','LVIpp','cNwjO','BkNCJ','❌\x20Failed\x20to\x20load\x20JWT\x20token:','zsiqS','🗑️\x20JWT\x20token\x20cleared','❌\x20Failed\x20to\x20clear\x20JWT\x20token:','removeItem','cUmno','mzDvs','clearJWT','No\x20response\x20received\x20from\x20server','VKmiA','fCxWs','zLMtn','sysLh','rZqBe','naFJN','ZwLMO','cJqbi','MkAwd','CKULb','WANqK','zxlzs','❌\x20Failed\x20to\x20decode\x20JWT\x20token:','SEFRc','EnhYY','MAozJ','🔄\x20Retry\x20attempt\x20','KpjoV','padEnd','HMEcU','pxrhT','fhOhH','Insufficient\x20API\x20key\x20permissions','hRxoL','⚠️\x20No\x20JWT\x20token\x20available\x20for\x20username\x20extraction','UvVaD','qZnLi','qHqff','❌\x20API\x20key\x20permissions\x20insufficient\x20for\x20this\x20operation.','userName','userId','aDHiT','yOVWM','WdgeJ','NhLXk','wrwjI','WzNsD','Qqksj','sAwrx','cUYVi','email','verified','exp','pZLMK','RvDvZ','vRCVT','👤\x20Extracted\x20user\x20data\x20from\x20JWT:','extractUserDataFromJWT','ZERQI','3.0.72','RDSXa','NZsFK','YynAo','Zovvl','ofwkh','sFCiy','usageCount','txppS','dYcWz','OnairosReactNative/3.0.72','fjmBe','QQAKE','cZEln','jzjkI','qPluM','GIXBW','ITVBx','AeFtS','QjSDs','eubcc','KOZUV','qqULu','qtIcw','yvUlZ','wmLTr','ikGjM','xyWPp','Invalid\x20or\x20expired\x20API\x20key','tZyLh','AbortError','CAkdz','RLgjj','cgFcv','AGKSn','WQuSW','qPRWb','GnSiU','zCvMU','📡\x20Response\x20status:\x20','DfjQG','WtnhP','YfXda','VYdpp','Rate\x20limit\x20exceeded','IDNUb','oGcPR','rmzsc','vpwYv','⏱️\x20Request\x20timeout\x20for:','nHOiJ','vRDCS','LVLkt','❌\x20Developer\x20API\x20key\x20authentication\x20failed','FFxdi','KFuPC','rLNfj','iHkBT','mogDa','yQiXb','LEeif','JHwZj','tZIqa','iujfx','aVaET','🌐\x20Making\x20developer\x20request\x20to:\x20','📡\x20Developer\x20request\x20response:\x20','\x20for\x20','bTILE','tmlqx','TNgRZ','alcJA','hpCnu','reVgQ','HIvfw','iEjql','❌\x20Developer\x20API\x20key\x20permissions\x20insufficient','RWkFp','bjgNw','❌\x20API\x20rate\x20limit\x20exceeded','CWmLC','BDrKz','NLLqk','lfyxU','ABmbi','iYeRS','eNqmn','SpbWf','shjpC','❌\x20JWT\x20token\x20authentication\x20failed\x20-\x20token\x20may\x20be\x20expired','Authentication\x20expired.\x20Please\x20verify\x20email\x20again.','ZsSwG','sRcWb','juavE','wnaMO','GvwpG','FnAss','puqfE','AYcCi','ofnyu','GNDfv','xewQZ','jskLe','gdInB','FEMfJ','jvMHQ','OpNWJ','fhIEJ','DgvMk','VUNhF','SpoPw','🔄\x20API\x20key\x20service\x20reset','BAWQI'];_0x2f4d=function(){return _0x3310ed;};return _0x2f4d();}exports[_0x3f91(0x72)]=getApiKeyType;const validateApiKey=async _0x3ee35b=>{const _0x358629={'tMLwL':'⏱️\x20Request\x20timeout\x20for:','vqFwW':_0x3f91(0x73),'iyiZs':_0x3f91(0x74),'OiYwK':'🎫\x20User\x20JWT\x20token\x20loaded\x20from\x20storage','ZIfIj':_0x3f91(0x33),'uuRXH':_0x3f91(0x75),'iVWqO':function(_0x104f9d,_0x4ff8ce){return _0x104f9d<_0x4ff8ce;},'DJrGz':function(_0x16a894,_0x3cf21c){return _0x16a894|_0x3cf21c;},'QtrsD':function(_0x18e62f,_0x5c0329){return _0x18e62f|_0x5c0329;},'shrMp':function(_0x27db2c,_0x1285ce){return _0x27db2c<<_0x1285ce;},'KZPdK':function(_0x525666,_0x7d9dd){return _0x525666<<_0x7d9dd;},'ocPgV':function(_0x5e2e1c,_0x10683d){return _0x5e2e1c>>_0x10683d;},'cnUYh':function(_0x352489,_0x17bd66){return _0x352489!==_0x17bd66;},'UgHEm':function(_0x12bca4,_0x23d7f4){return _0x12bca4&_0x23d7f4;},'yqmXP':function(_0x5abd59,_0xc53088){return _0x5abd59>>_0xc53088;},'RpPzi':function(_0x863c05,_0x3a3542){return _0x863c05>=_0x3a3542;},'EfHHE':function(_0x771537,_0x57236a){return _0x771537<_0x57236a;},'tdLxT':_0x3f91(0x76),'FmrqA':_0x3f91(0x77),'eCDsH':_0x3f91(0x78),'OJcsG':function(_0x105788,_0x38ba12){return _0x105788*_0x38ba12;},'FgQvL':function(_0x174bfe,_0xf7821a){return _0x174bfe/_0xf7821a;},'DazhY':function(_0x108a3f,_0x25e3f7){return _0x108a3f(_0x25e3f7);},'qtfYT':'❌\x20Failed\x20to\x20decode\x20JWT\x20token:','ssBVz':_0x3f91(0x2a),'pxVFr':_0x3f91(0x79),'Nbbal':_0x3f91(0x57),'kjeSK':_0x3f91(0x2c),'gjmkK':_0x3f91(0x18),'hmJGE':_0x3f91(0x2e),'pJrsk':'⚠️\x20API\x20key\x20validation\x20failed\x20due\x20to\x20network/connectivity\x20issues','WlHwL':'🔄\x20Continuing\x20in\x20offline\x20mode\x20with\x20basic\x20validation','mswHQ':_0x3f91(0x5d),'UMgbF':function(_0x136ccc,_0x58a127){return _0x136ccc===_0x58a127;},'HZIdn':_0x3f91(0x7a),'AjNdo':_0x3f91(0x7b),'QtZRS':_0x3f91(0x7c),'JrlPW':function(_0x43115d,_0x33ef29){return _0x43115d<_0x33ef29;},'kaJRL':function(_0x193e6c,_0x316b29){return _0x193e6c!==_0x316b29;},'BlLQg':function(_0xecf584){return _0xecf584();},'zRuaD':function(_0x207dcf,_0x57b085){return _0x207dcf===_0x57b085;},'zRnLl':_0x3f91(0x7d),'AihWU':_0x3f91(0x7e),'rsBQc':function(_0x27d601,_0x359f6e){return _0x27d601===_0x359f6e;},'plptd':function(_0x2f002d,_0x71cc01){return _0x2f002d<=_0x71cc01;},'CawgC':function(_0x518193,_0x36d69f,_0x3e8e1d){return _0x518193(_0x36d69f,_0x3e8e1d);},'fwXxy':function(_0x4957d6,_0x1f87e5){return _0x4957d6>_0x1f87e5;},'BDZVy':function(_0x5b3131,_0x4c6f2c,_0x47879f){return _0x5b3131(_0x4c6f2c,_0x47879f);},'FyNHc':_0x3f91(0x7f),'PXRLH':'No\x20response\x20received\x20from\x20server','fDuat':'Onairos\x20API\x20is\x20temporarily\x20unavailable\x20(502\x20Bad\x20Gateway).\x20Please\x20try\x20again\x20later.','gFpsg':function(_0x3e0623,_0x34d0c7){return _0x3e0623===_0x34d0c7;},'DrXEs':_0x3f91(0x80),'BOhiQ':_0x3f91(0x81),'TbJeW':function(_0x26628b,_0x3b0028){return _0x26628b!==_0x3b0028;},'oJess':'MnNVq','WrPld':_0x3f91(0x82),'CdDrv':_0x3f91(0x83),'MBnGl':_0x3f91(0x84),'WDjQq':_0x3f91(0x85),'UjGrW':_0x3f91(0x86),'EVPSr':function(_0x1a5e20,_0x2fdac1){return _0x1a5e20===_0x2fdac1;},'TWwMe':_0x3f91(0x87),'aznVA':function(_0x56208f,_0xc134a0){return _0x56208f===_0xc134a0;},'IyOfq':function(_0x4cfc03,_0x494b18){return _0x4cfc03===_0x494b18;},'ZDTct':_0x3f91(0x88),'GwPdv':_0x3f91(0x89),'WSwAc':_0x3f91(0x21),'KAIHK':function(_0x5d0510,_0x4e6fdb){return _0x5d0510!==_0x4e6fdb;},'rZAQm':_0x3f91(0x8a),'ZBVJA':function(_0x1cc117,_0x4d5cb1){return _0x1cc117===_0x4d5cb1;},'XdkZx':_0x3f91(0x8b),'GtIPB':_0x3f91(0x8c),'pcIGV':_0x3f91(0x8d),'qXzWL':'jYlRF','hMNts':_0x3f91(0x8e),'MgORb':'gqWcL','MUBas':_0x3f91(0x8f),'YcqFS':function(_0x4d40aa,_0x4086ed){return _0x4d40aa-_0x4086ed;},'FZegM':function(_0x515b6a,_0x49e2d1){return _0x515b6a!==_0x49e2d1;},'AKdZd':function(_0x2c9375,_0x40bd65){return _0x2c9375!==_0x40bd65;},'cFwUe':'dRTZZ','jUPiK':_0x3f91(0x90),'UdkJU':function(_0x292c86,_0x45b94d){return _0x292c86!==_0x45b94d;},'BriAc':_0x3f91(0x91),'JOWcJ':_0x3f91(0x92)};try{if(_0x358629[_0x3f91(0x93)](_0x358629[_0x3f91(0x94)],_0x358629[_0x3f91(0x95)]))_0x4d3d5d[_0x3f91(0x36)](_0x3f91(0x96)+_0x519105);else{var _0x4c0895,_0x51f61d,_0x17431b;console['log'](_0x358629[_0x3f91(0x97)]);const _0x283af4=getApiKeyType(_0x3ee35b);if(_0x283af4===ApiKeyType[_0x3f91(0x71)])return{'isValid':![],'error':_0x3f91(0x98),'keyType':ApiKeyType[_0x3f91(0x71)]};const _0x7821ed=validationCache[_0x3f91(0x99)](_0x3ee35b);if(_0x7821ed&&_0x358629[_0x3f91(0x9a)](Date['now']()-_0x7821ed[_0x3f91(0x9b)],CACHE_DURATION)){var _0x42ed37;return _0x358629[_0x3f91(0x9c)](_0x42ed37=globalConfig,null)&&_0x358629['kaJRL'](_0x42ed37,void 0x0)&&_0x42ed37[_0x3f91(0x4c)]&&console[_0x3f91(0x36)](_0x3f91(0x9d)),_0x7821ed[_0x3f91(0x9e)];}const _0x4198fc=await _0x358629[_0x3f91(0x9f)](checkNetworkConnectivity);if(!_0x4198fc){if(_0x358629['zRuaD']('nVUko',_0x358629[_0x3f91(0xa0)]))return console[_0x3f91(0x1d)](_0x358629['AihWU']),{'isValid':![],'error':'No\x20network\x20connection\x20available.\x20Please\x20check\x20your\x20internet\x20connection\x20and\x20try\x20again.','keyType':_0x283af4,'isNetworkError':!![]};else{_0x1fd15e['error'](_0x358629[_0x3f91(0xa1)],_0x510c5b);throw new _0x506ee5(_0x3f91(0xa2));}}const _0x2018d5=(_0x358629[_0x3f91(0x93)](_0x4c0895=globalConfig,null)||_0x358629[_0x3f91(0x93)](_0x4c0895,void 0x0)?void 0x0:_0x4c0895[_0x3f91(0x41)])||_0x3f91(0x42),_0x482810=API_ENDPOINTS[_0x2018d5],_0xebc5cb=(_0x358629['UMgbF'](_0x51f61d=globalConfig,null)||_0x358629[_0x3f91(0xa3)](_0x51f61d,void 0x0)?void 0x0:_0x51f61d[_0x3f91(0x2b)])||0x7530,_0x57c5d7=(_0x358629[_0x3f91(0xa4)](_0x17431b=globalConfig,null)||_0x358629['rsBQc'](_0x17431b,void 0x0)?void 0x0:_0x17431b['retryAttempts'])||0x3;for(let _0x394d06=0x1;_0x358629['plptd'](_0x394d06,_0x57c5d7);_0x394d06++){const _0xbde6b5=new AbortController(),_0x59cee1=_0x358629[_0x3f91(0xa5)](setTimeout,()=>_0xbde6b5[_0x3f91(0xa6)](),_0xebc5cb);try{var _0x44a8ee;_0x358629[_0x3f91(0xa7)](_0x44a8ee=globalConfig,null)&&_0x44a8ee!==void 0x0&&_0x44a8ee[_0x3f91(0x4c)]&&_0x358629[_0x3f91(0xa8)](_0x394d06,0x1)&&console[_0x3f91(0x36)]('🔄\x20Retry\x20attempt\x20'+_0x394d06+'/'+_0x57c5d7+_0x3f91(0xa9));const _0x2c97d3=await _0x358629[_0x3f91(0xaa)](fetch,_0x482810+_0x3f91(0xab),{'method':'POST','headers':{'Content-Type':'application/json','Authorization':'Bearer\x20'+_0x3ee35b,'User-Agent':_0x3f91(0xac),'X-API-Key-Type':_0x283af4,'X-SDK-Platform':'react-native','X-Retry-Attempt':_0x394d06[_0x3f91(0xad)]()},'body':JSON['stringify']({'environment':_0x2018d5,'sdk_version':_0x358629['FyNHc'],'platform':'react-native','keyType':_0x283af4,'timestamp':new Date()[_0x3f91(0x43)](),'attempt':_0x394d06}),'signal':_0xbde6b5[_0x3f91(0xae)]});_0x358629[_0x3f91(0xaf)](clearTimeout,_0x59cee1);if(!_0x2c97d3)throw new Error(_0x358629['PXRLH']);if(_0x2c97d3['status']===0x1f6)throw new Error(_0x358629['fDuat']);if(_0x358629['gFpsg'](_0x2c97d3[_0x3f91(0x6a)],0x1f7)){if(_0x358629[_0x3f91(0xa7)](_0x3f91(0x80),_0x358629[_0x3f91(0xb0)])){const _0xe847a8=_0x358629['vqFwW'][_0x3f91(0x5b)]('|');let _0x42b5ff=0x0;while(!![]){switch(_0xe847a8[_0x42b5ff++]){case'0':_0x446595['rateLimits']&&_0x19fb73[_0x3f91(0x36)](_0x358629[_0x3f91(0xb1)],_0x240879[_0x3f91(0x66)]);continue;case'1':_0x5c4fe4[_0x3f91(0x36)](_0x3f91(0xb2));continue;case'2':_0x1e5d19['permissions']&&_0xe19869[_0x3f91(0x36)]('🔐\x20API\x20Key\x20Permissions:',_0x68e53e['permissions']);continue;case'3':_0x38ed10&&_0x317515[_0x3f91(0x36)](_0x358629[_0x3f91(0xb3)]);continue;case'4':_0x4b3818[_0x3f91(0x36)](_0x3f91(0x62));continue;}break;}}else throw new Error(_0x358629[_0x3f91(0xb4)]);}if(_0x2c97d3[_0x3f91(0x6a)]===0x1f8){if(_0x358629[_0x3f91(0xb5)](_0x358629[_0x3f91(0xb6)],_0x358629[_0x3f91(0xb7)]))throw new Error(_0x358629[_0x3f91(0xb8)]);else _0x314c92[_0x3f91(0x36)](_0x358629[_0x3f91(0xb9)],_0x154a62['permissions']);}const _0x43280e=_0x2c97d3[_0x3f91(0xba)][_0x3f91(0x99)](_0x358629[_0x3f91(0xbb)]),_0x792221=_0x43280e&&_0x43280e['includes']('application/json');if(!_0x792221){const _0x3ab722=await _0x2c97d3[_0x3f91(0xbc)](),_0x824a6a=_0x3ab722[_0x3f91(0xbd)](0x0,0xc8);console['error'](_0x358629[_0x3f91(0xbe)],{'status':_0x2c97d3[_0x3f91(0x6a)],'statusText':_0x2c97d3[_0x3f91(0xbf)],'contentType':_0x43280e||_0x358629[_0x3f91(0xc0)],'preview':_0x824a6a,'url':_0x482810+_0x3f91(0xab),'attempt':_0x394d06});if(_0x358629[_0x3f91(0xc1)](_0x2c97d3[_0x3f91(0x6a)],0x194))throw new Error(_0x3f91(0xc2)+_0x482810+_0x3f91(0xc3));else{if(_0x358629[_0x3f91(0x93)](_0x2c97d3['status'],0x1f4)){if(_0x358629[_0x3f91(0xc4)]!==_0x358629[_0x3f91(0xc4)])_0x198882[_0x3f91(0x36)](_0x358629[_0x3f91(0xc5)]);else throw new Error(_0x3f91(0xc6));}else{if(_0x358629[_0x3f91(0xc7)](_0x2c97d3[_0x3f91(0x6a)],0x1f6)||_0x358629['IyOfq'](_0x2c97d3[_0x3f91(0x6a)],0x1f7))throw new Error(_0x3f91(0xc8)+_0x2c97d3[_0x3f91(0x6a)]+').\x20The\x20Onairos\x20backend\x20may\x20be\x20temporarily\x20down.');else{if(_0x3ab722[_0x3f91(0x55)](_0x3f91(0xc9))||_0x3ab722['includes'](_0x358629['ZDTct']))throw new Error(_0x3f91(0xca));else throw new Error(_0x3f91(0xcb)+_0x2c97d3[_0x3f91(0x6a)]+_0x3f91(0xcc)+_0x2c97d3[_0x3f91(0xbf)]+_0x3f91(0xcd)+(_0x43280e||_0x358629[_0x3f91(0xce)])+'.');}}}}let _0x285b2f;try{_0x285b2f=await _0x2c97d3[_0x3f91(0xcf)]();}catch(_0x3cf705){console[_0x3f91(0x54)](_0x358629['WSwAc'],{'error':_0x3cf705[_0x3f91(0x69)],'status':_0x2c97d3[_0x3f91(0x6a)],'contentType':_0x43280e,'attempt':_0x394d06});throw new Error(_0x3f91(0x6b)+_0x3cf705[_0x3f91(0x69)]);}if(_0x2c97d3['ok']&&(_0x285b2f[_0x3f91(0xd0)]||_0x285b2f[_0x3f91(0xd1)])){if(_0x358629[_0x3f91(0xd2)]('bpxfA',_0x3f91(0xd3))){var _0x244481;const _0x4adbd4={'isValid':!![],'permissions':_0x285b2f['permissions']||[],'rateLimits':_0x285b2f[_0x3f91(0x66)]||null,'keyType':_0x283af4};validationCache[_0x3f91(0xd4)](_0x3ee35b,{'result':_0x4adbd4,'timestamp':Date[_0x3f91(0xd5)]()});if(_0x358629[_0x3f91(0x9c)](_0x244481=globalConfig,null)&&_0x358629[_0x3f91(0xd6)](_0x244481,void 0x0)&&_0x244481['enableLogging']){var _0x3aac0a,_0x3021af,_0x5877a2;console[_0x3f91(0x36)](_0x358629[_0x3f91(0xd7)],{'apiKeyId':_0x358629[_0x3f91(0x93)](_0x3aac0a=_0x285b2f['apiKey'],null)||_0x358629[_0x3f91(0xd8)](_0x3aac0a,void 0x0)?void 0x0:_0x3aac0a['id'],'appName':_0x358629[_0x3f91(0xd9)](_0x3021af=_0x285b2f['application'],null)||_0x3021af===void 0x0?void 0x0:_0x3021af[_0x3f91(0xda)],'usageCount':(_0x5877a2=_0x285b2f[_0x3f91(0x38)])===null||_0x5877a2===void 0x0?void 0x0:_0x5877a2['usageCount']});}return _0x4adbd4;}else{const _0x2fbc94=_0x3f91(0xdb);let _0x481bac='',_0x1c7432=0x0;_0x3881dd=_0x377475[_0x3f91(0xdc)](/[^A-Za-z0-9+/]/g,'');while(_0x358629[_0x3f91(0xdd)](_0x1c7432,_0x25452a[_0x3f91(0x45)])){const _0x4a2be6=_0x2fbc94[_0x3f91(0xde)](_0x110d39[_0x3f91(0xdf)](_0x1c7432++)),_0x441395=_0x2fbc94[_0x3f91(0xde)](_0x1e24ab[_0x3f91(0xdf)](_0x1c7432++)),_0x1446bc=_0x2fbc94[_0x3f91(0xde)](_0x2dfe94['charAt'](_0x1c7432++)),_0x1bac9f=_0x2fbc94[_0x3f91(0xde)](_0x344b20[_0x3f91(0xdf)](_0x1c7432++)),_0x4c8add=_0x358629[_0x3f91(0xe0)](_0x358629[_0x3f91(0xe1)](_0x358629[_0x3f91(0xe0)](_0x358629[_0x3f91(0xe2)](_0x4a2be6,0x12),_0x358629[_0x3f91(0xe2)](_0x441395,0xc)),_0x358629[_0x3f91(0xe3)](_0x1446bc,0x6)),_0x1bac9f);_0x481bac+=_0xb53d63['fromCharCode'](_0x358629[_0x3f91(0xe4)](_0x4c8add,0x10)&0xff);if(_0x358629[_0x3f91(0xa7)](_0x1446bc,0x40))_0x481bac+=_0x5c1e72['fromCharCode'](_0x358629[_0x3f91(0xe5)](_0x358629[_0x3f91(0xe6)](_0x4c8add,0x8),0xff));if(_0x358629[_0x3f91(0xa7)](_0x1bac9f,0x40))_0x481bac+=_0xa0ec5f[_0x3f91(0xe7)](_0x358629['UgHEm'](_0x4c8add,0xff));}return _0x481bac;}}else{if(_0x358629[_0x3f91(0xd6)](_0x358629['XdkZx'],_0x358629[_0x3f91(0xe8)])){const _0x74475c=_0x285b2f[_0x3f91(0x54)]||_0x285b2f[_0x3f91(0x69)]||_0x3f91(0xe9)+_0x2c97d3[_0x3f91(0x6a)]+':\x20'+_0x2c97d3[_0x3f91(0xbf)],_0x4b7c64={'isValid':![],'error':_0x74475c,'keyType':_0x283af4};if(_0x2c97d3[_0x3f91(0x6a)]>=0x190&&_0x2c97d3[_0x3f91(0x6a)]<0x1f4){var _0x5977d8;if((_0x5977d8=globalConfig)!==null&&_0x358629[_0x3f91(0xd6)](_0x5977d8,void 0x0)&&_0x5977d8['enableLogging']){if(_0x358629[_0x3f91(0xb5)](_0x358629[_0x3f91(0xea)],_0x358629[_0x3f91(0xea)])){const _0x2f1000=_0x3f31da[_0x3f91(0x54)]||_0x5c182a[_0x3f91(0x69)]||_0x3f91(0xe9)+_0xa443a8[_0x3f91(0x6a)]+':\x20'+_0x513ade[_0x3f91(0xbf)],_0x506505={'isValid':![],'error':_0x2f1000,'keyType':_0x208cf4};if(_0x358629[_0x3f91(0xeb)](_0x551625[_0x3f91(0x6a)],0x190)&&_0x358629[_0x3f91(0xec)](_0x4c3589[_0x3f91(0x6a)],0x1f4)){var _0x576c3c;return _0x358629[_0x3f91(0xa7)](_0x576c3c=_0x3b8b37,null)&&_0x576c3c!==void 0x0&&_0x576c3c[_0x3f91(0x4c)]&&_0x5d9a9c['error'](_0x358629[_0x3f91(0xed)],_0x2f1000),_0x506505;}throw new _0x24a966(_0x2f1000);}else console[_0x3f91(0x54)](_0x358629[_0x3f91(0xed)],_0x74475c);}return _0x4b7c64;}throw new Error(_0x74475c);}else{_0x204052['error'](_0x3f91(0xee));throw new _0x292c4c(_0x358629[_0x3f91(0xef)]);}}}catch(_0x1a9141){var _0x4d4a91;_0x358629[_0x3f91(0xaf)](clearTimeout,_0x59cee1);if(_0x358629[_0x3f91(0xc1)](_0x1a9141[_0x3f91(0xda)],'AbortError')){if(_0x358629[_0x3f91(0x9c)](_0x3f91(0xf0),_0x358629[_0x3f91(0xf1)]))_0x1701c6['log'](_0x3f91(0xf2)+_0x2e4530);else{const _0x3c148e=_0x3f91(0xf3)+_0xebc5cb+_0x3f91(0xf4);console[_0x3f91(0x54)](_0x3f91(0xf5));if(_0x358629[_0x3f91(0xa3)](_0x394d06,_0x57c5d7))return{'isValid':![],'error':_0x3c148e,'keyType':_0x283af4};continue;}}let _0x11e786='Network\x20error\x20during\x20API\x20key\x20validation:\x20'+_0x1a9141[_0x3f91(0x69)];if(_0x1a9141[_0x3f91(0x69)]['includes'](_0x358629[_0x3f91(0xf6)])||_0x1a9141[_0x3f91(0x69)]['includes'](_0x358629['hMNts']))_0x11e786=_0x3f91(0xf7)+_0x1a9141[_0x3f91(0x69)];else{if(_0x1a9141[_0x3f91(0x69)][_0x3f91(0x55)]('Network\x20request\x20failed')||_0x1a9141[_0x3f91(0x69)][_0x3f91(0x55)](_0x358629[_0x3f91(0xf8)])){if(_0x358629[_0x3f91(0xf9)]!==_0x358629['MgORb'])throw new _0x1fab8c(_0x3f91(0xfa)+_0x614209[_0x3f91(0x54)]);else _0x11e786='Network\x20connectivity\x20issue.\x20Please\x20check\x20internet\x20connection\x20and\x20verify\x20the\x20Onairos\x20API\x20is\x20accessible.\x20'+_0x1a9141[_0x3f91(0x69)];}else(_0x1a9141[_0x3f91(0x69)][_0x3f91(0x55)]('DNS')||_0x1a9141[_0x3f91(0x69)][_0x3f91(0x55)](_0x358629[_0x3f91(0xfb)]))&&(_0x11e786=_0x3f91(0xfc)+_0x482810+_0x3f91(0xfd)+_0x1a9141[_0x3f91(0x69)]);}console['error'](_0x3f91(0xfe),{'error':_0x1a9141,'endpoint':_0x482810+_0x3f91(0xab),'attempt':_0x394d06,'maxRetries':_0x57c5d7,'retryable':_0x394d06<_0x57c5d7});if(_0x394d06===_0x57c5d7){if(_0x358629[_0x3f91(0xc7)](_0x358629[_0x3f91(0xff)],_0x358629[_0x3f91(0xff)]))return{'isValid':![],'error':_0x11e786,'keyType':_0x283af4,'isNetworkError':!![]};else throw new _0x1e01e6(_0x3f91(0x100));}const _0x10aca4=Math['min'](0x3e8*Math['pow'](0x2,_0x358629['YcqFS'](_0x394d06,0x1)),0x1388);if((_0x4d4a91=globalConfig)!==null&&_0x358629['FZegM'](_0x4d4a91,void 0x0)&&_0x4d4a91[_0x3f91(0x4c)]){if(_0x358629['AKdZd'](_0x358629[_0x3f91(0x101)],_0x358629[_0x3f91(0x102)]))console[_0x3f91(0x36)](_0x3f91(0x103)+_0x10aca4+_0x3f91(0x104));else try{const _0x171f98=_0xc19309[_0x3f91(0x5b)]('.');if(_0x358629[_0x3f91(0xa7)](_0x171f98['length'],0x3))return _0x496e8e['error'](_0x358629[_0x3f91(0x105)]),null;const _0x448cbe=_0x171f98[0x1],_0x50f63d=_0x448cbe[_0x3f91(0xdc)](/-/g,'+')[_0x3f91(0xdc)](/_/g,'/'),_0x3a76d5=_0x50f63d['padEnd'](_0x358629[_0x3f91(0x106)](_0x478785[_0x3f91(0x107)](_0x358629['FgQvL'](_0x50f63d[_0x3f91(0x45)],0x4)),0x4),'='),_0x38090a=_0x358629[_0x3f91(0xaf)](_0x2479ee,_0x3a76d5);return _0x21d5dc['parse'](_0x38090a);}catch(_0x52a597){return _0x163738[_0x3f91(0x54)](_0x358629['qtfYT'],_0x52a597),null;}}await new Promise(_0x1ec0c6=>setTimeout(()=>_0x1ec0c6(),_0x10aca4));}}return{'isValid':![],'error':_0x3f91(0x108),'keyType':_0x283af4};}}catch(_0x24ec02){if(_0x358629[_0x3f91(0x109)](_0x358629[_0x3f91(0x10a)],_0x358629[_0x3f91(0x10b)])){const _0x3a84e2=_0x3f91(0x10c)+_0x24ec02['message'];return console[_0x3f91(0x54)](_0x3f91(0x10d),_0x24ec02),{'isValid':![],'error':_0x3a84e2,'keyType':ApiKeyType[_0x3f91(0x71)]};}else{const _0x31599a=_0x3368fd[_0x3f91(0x54)]||'',_0x4de607=_0x677df6['isNetworkError']||_0x31599a[_0x3f91(0x55)]('Network\x20request\x20failed')||_0x31599a['includes'](_0x358629[_0x3f91(0x10e)])||_0x31599a[_0x3f91(0x55)](_0x358629[_0x3f91(0xf6)])||_0x31599a['includes'](_0x358629['Nbbal'])||_0x31599a[_0x3f91(0x55)]('timeout')||_0x31599a['includes'](_0x358629[_0x3f91(0xfb)])||_0x31599a[_0x3f91(0x55)](_0x358629[_0x3f91(0xf8)])||_0x31599a[_0x3f91(0x55)](_0x3f91(0x10f));if(_0x4de607){const _0x3cdb13=_0x3f91(0x110)[_0x3f91(0x5b)]('|');let _0x5db555=0x0;while(!![]){switch(_0x3cdb13[_0x5db555++]){case'0':_0x5a0698[_0x3f91(0x1d)](_0x358629['hmJGE']);continue;case'1':_0xdeddf5[_0x3f91(0x1d)](_0x358629['pJrsk']);continue;case'2':_0xdd0fa5[_0x3f91(0x1d)](_0x358629['WlHwL']);continue;case'3':_0x2be3b4['log'](_0x358629['mswHQ']);continue;case'4':_0x167ed7[_0x3f91(0x1d)]('🌐\x20Error\x20details:',_0x2ba49b[_0x3f91(0x54)]);continue;}break;}}else throw new _0x3d7b1a(_0x3f91(0xfa)+_0x32f12a[_0x3f91(0x54)]);}}};exports[_0x3f91(0x1)]=validateApiKey;const getApiConfig=()=>{return globalConfig;};exports[_0x3f91(0xd)]=getApiConfig;const getApiKey=()=>{const _0x540e9e={'vNmAV':function(_0x49f7ba,_0x433107){return _0x49f7ba===_0x433107;},'jUeRq':function(_0x406ec3,_0x2735e1){return _0x406ec3===_0x2735e1;}};var _0x4a3c7a;return(_0x540e9e[_0x3f91(0x111)](_0x4a3c7a=globalConfig,null)||_0x540e9e[_0x3f91(0x112)](_0x4a3c7a,void 0x0)?void 0x0:_0x4a3c7a['apiKey'])||null;};exports[_0x3f91(0xc)]=getApiKey;const isApiKeyInitialized=()=>{return isInitialized&&globalConfig!==null;};exports['isApiKeyInitialized']=isApiKeyInitialized;const storeJWT=async _0x4b0f15=>{const _0x5412a9={'LVIpp':function(_0x4390ec,_0x4184d8){return _0x4390ec!==_0x4184d8;},'cNwjO':function(_0x32ce7c,_0x443f75){return _0x32ce7c!==_0x443f75;},'BkNCJ':_0x3f91(0x113),'jsxpx':_0x3f91(0x114)};try{var _0x2cb6d5;await _asyncStorage['default'][_0x3f91(0x115)](JWT_TOKEN_KEY,_0x4b0f15),userToken=_0x4b0f15,_0x5412a9[_0x3f91(0x116)](_0x2cb6d5=globalConfig,null)&&_0x5412a9[_0x3f91(0x117)](_0x2cb6d5,void 0x0)&&_0x2cb6d5['enableLogging']&&console[_0x3f91(0x36)](_0x5412a9[_0x3f91(0x118)]);}catch(_0x5719f0){console['error'](_0x5412a9['jsxpx'],_0x5719f0);throw _0x5719f0;}};exports[_0x3f91(0x2)]=storeJWT;const loadJWT=async()=>{const _0x29df2d={'zsiqS':_0x3f91(0x119)};try{const _0x240dbd=await _asyncStorage[_0x3f91(0x17)]['getItem'](JWT_TOKEN_KEY);return userToken=_0x240dbd,_0x240dbd;}catch(_0x21af46){return console[_0x3f91(0x54)](_0x29df2d[_0x3f91(0x11a)],_0x21af46),null;}};exports['loadJWT']=loadJWT;const getJWT=()=>{return userToken;};function _0x3f91(_0x2f4d43,_0x3f914d){_0x2f4d43=_0x2f4d43-0x0;const _0x34ee0e=_0x2f4d();let _0x11fedd=_0x34ee0e[_0x2f4d43];return _0x11fedd;}exports['getJWT']=getJWT;const clearJWT=async()=>{const _0x7e4b7f={'cUmno':function(_0x3aee2a,_0x4d1068){return _0x3aee2a!==_0x4d1068;},'Hsmyp':_0x3f91(0x11b),'mzDvs':_0x3f91(0x11c)};try{var _0xc752d2;await _asyncStorage[_0x3f91(0x17)][_0x3f91(0x11d)](JWT_TOKEN_KEY),userToken=null,_0x7e4b7f[_0x3f91(0x11e)](_0xc752d2=globalConfig,null)&&_0xc752d2!==void 0x0&&_0xc752d2['enableLogging']&&console[_0x3f91(0x36)](_0x7e4b7f['Hsmyp']);}catch(_0x4f2254){console[_0x3f91(0x54)](_0x7e4b7f[_0x3f91(0x11f)],_0x4f2254);}};exports[_0x3f91(0x120)]=clearJWT;const base64Decode=_0x242d72=>{const _0x33e9d1={'HKPCq':_0x3f91(0x121),'fCxWs':_0x3f91(0xdb),'zLMtn':function(_0x566b1e,_0x248677){return _0x566b1e<_0x248677;},'sysLh':function(_0x4478d4,_0x3d1d9c){return _0x4478d4!==_0x3d1d9c;},'rZqBe':_0x3f91(0x122),'naFJN':function(_0xcdc14d,_0x1e3286){return _0xcdc14d|_0x1e3286;},'zkrfE':function(_0x2734f8,_0x1cfa68){return _0x2734f8<<_0x1cfa68;},'ZwLMO':function(_0x3a0f9b,_0x5ce3be){return _0x3a0f9b&_0x5ce3be;},'cJqbi':function(_0xbf1042,_0x49537b){return _0xbf1042!==_0x49537b;},'MkAwd':function(_0x433f85,_0x4af6be){return _0x433f85>>_0x4af6be;},'CKULb':function(_0x309c7d,_0x58f2e8){return _0x309c7d!==_0x58f2e8;},'WANqK':function(_0x4e590c,_0x46dd2d){return _0x4e590c&_0x46dd2d;}},_0x55cbf2=_0x33e9d1[_0x3f91(0x123)];let _0x47187='',_0x2abd8e=0x0;_0x242d72=_0x242d72[_0x3f91(0xdc)](/[^A-Za-z0-9+/]/g,'');while(_0x33e9d1[_0x3f91(0x124)](_0x2abd8e,_0x242d72[_0x3f91(0x45)])){if(_0x33e9d1[_0x3f91(0x125)](_0x33e9d1[_0x3f91(0x126)],_0x33e9d1[_0x3f91(0x126)]))throw new _0x2aee1(_0x33e9d1['HKPCq']);else{const _0x45ec4e=_0x55cbf2[_0x3f91(0xde)](_0x242d72[_0x3f91(0xdf)](_0x2abd8e++)),_0x346035=_0x55cbf2[_0x3f91(0xde)](_0x242d72['charAt'](_0x2abd8e++)),_0xaef4db=_0x55cbf2[_0x3f91(0xde)](_0x242d72['charAt'](_0x2abd8e++)),_0x271525=_0x55cbf2['indexOf'](_0x242d72[_0x3f91(0xdf)](_0x2abd8e++)),_0xa3d420=_0x33e9d1[_0x3f91(0x127)](_0x33e9d1[_0x3f91(0x127)](_0x45ec4e<<0x12|_0x33e9d1['zkrfE'](_0x346035,0xc),_0xaef4db<<0x6),_0x271525);_0x47187+=String[_0x3f91(0xe7)](_0x33e9d1[_0x3f91(0x128)](_0xa3d420>>0x10,0xff));if(_0x33e9d1[_0x3f91(0x129)](_0xaef4db,0x40))_0x47187+=String['fromCharCode'](_0x33e9d1[_0x3f91(0x128)](_0x33e9d1[_0x3f91(0x12a)](_0xa3d420,0x8),0xff));if(_0x33e9d1[_0x3f91(0x12b)](_0x271525,0x40))_0x47187+=String[_0x3f91(0xe7)](_0x33e9d1[_0x3f91(0x12c)](_0xa3d420,0xff));}}return _0x47187;},decodeJWTPayload=_0x1bf151=>{const _0x3c887d={'SEFRc':function(_0x4c5d46,_0xbc14b0){return _0x4c5d46===_0xbc14b0;},'EnhYY':'dhYJr','MAozJ':_0x3f91(0x12d),'BtFox':function(_0x4b0285,_0x22c3a7){return _0x4b0285!==_0x22c3a7;},'KpjoV':_0x3f91(0x78),'SIxcZ':function(_0x256c2a,_0xe6d4b1){return _0x256c2a*_0xe6d4b1;},'HMEcU':function(_0x2d9799,_0x252021){return _0x2d9799/_0x252021;},'pxrhT':function(_0x51472c,_0x572133){return _0x51472c(_0x572133);},'fhOhH':_0x3f91(0x12e)};try{if(_0x3c887d[_0x3f91(0x12f)](_0x3c887d[_0x3f91(0x130)],_0x3c887d[_0x3f91(0x131)]))_0x15dec2['log'](_0x3f91(0x132)+_0x32958b+'/'+_0x2677e1+_0x3f91(0xa9));else{const _0x4a422d=_0x1bf151[_0x3f91(0x5b)]('.');if(_0x3c887d['BtFox'](_0x4a422d[_0x3f91(0x45)],0x3))return console[_0x3f91(0x54)](_0x3c887d[_0x3f91(0x133)]),null;const _0x18eadc=_0x4a422d[0x1],_0x2375f0=_0x18eadc[_0x3f91(0xdc)](/-/g,'+')[_0x3f91(0xdc)](/_/g,'/'),_0x4c2da8=_0x2375f0[_0x3f91(0x134)](_0x3c887d['SIxcZ'](Math[_0x3f91(0x107)](_0x3c887d[_0x3f91(0x135)](_0x2375f0[_0x3f91(0x45)],0x4)),0x4),'='),_0x36c29b=_0x3c887d[_0x3f91(0x136)](base64Decode,_0x4c2da8);return JSON['parse'](_0x36c29b);}}catch(_0x647734){return console['error'](_0x3c887d[_0x3f91(0x137)],_0x647734),null;}};exports[_0x3f91(0xf)]=decodeJWTPayload;const extractUsernameFromJWT=_0x4896c7=>{const _0x221bec={'dmlsQ':_0x3f91(0x138),'qZnLi':function(_0x4788dd,_0x5be91a){return _0x4788dd||_0x5be91a;},'YjSDu':function(_0x4364b6,_0x209591){return _0x4364b6===_0x209591;},'VfEQb':_0x3f91(0x139),'bdiew':_0x3f91(0x13a),'Mjejw':function(_0x4146d0,_0x112701){return _0x4146d0(_0x112701);},'qHqff':_0x3f91(0x13b),'aDHiT':_0x3f91(0x4f),'anorJ':'❌\x20Failed\x20to\x20extract\x20username\x20from\x20JWT:'};try{var _0x4abdfc;const _0x1fe5bf=_0x221bec[_0x3f91(0x13c)](_0x4896c7,userToken);if(!_0x1fe5bf){if(_0x221bec['YjSDu'](_0x3f91(0x139),_0x221bec['VfEQb']))return console[_0x3f91(0x1d)](_0x221bec['bdiew']),null;else _0x34dbba=_0x3f91(0xf7)+_0xb5b372['message'];}const _0x5b8644=_0x221bec['Mjejw'](decodeJWTPayload,_0x1fe5bf);if(!_0x5b8644){if(_0x221bec['YjSDu'](_0x221bec[_0x3f91(0x13d)],_0x221bec[_0x3f91(0x13d)]))return null;else{_0x3e7eb3[_0x3f91(0x54)](_0x3f91(0x13e));throw new _0x47fa15(_0x221bec['dmlsQ']);}}const _0x2d51b9=_0x5b8644[_0x3f91(0x13f)]||_0x5b8644['username']||_0x5b8644[_0x3f91(0x140)]||_0x5b8644['email'];return(_0x4abdfc=globalConfig)!==null&&_0x4abdfc!==void 0x0&&_0x4abdfc[_0x3f91(0x4c)]&&console[_0x3f91(0x36)](_0x221bec[_0x3f91(0x141)],_0x2d51b9),_0x221bec['qZnLi'](_0x2d51b9,null);}catch(_0x5ec5ff){return console[_0x3f91(0x54)](_0x221bec['anorJ'],_0x5ec5ff),null;}};exports[_0x3f91(0xe)]=extractUsernameFromJWT;const extractUserDataFromJWT=_0x583f34=>{const _0xf12dc0={'WzNsD':_0x3f91(0x119),'oghvq':function(_0x3a6266,_0x350a9e){return _0x3a6266===_0x350a9e;},'wfGBl':_0x3f91(0x142),'wrwjI':'⚠️\x20No\x20JWT\x20token\x20available\x20for\x20user\x20data\x20extraction','Qqksj':function(_0x4a5088,_0x5e8312){return _0x4a5088(_0x5e8312);},'sAwrx':function(_0x1431b7,_0x3ddce3){return _0x1431b7!==_0x3ddce3;},'cUYVi':_0x3f91(0x143),'pZLMK':function(_0x44ef2e,_0x38b0c3){return _0x44ef2e!==_0x38b0c3;},'RvDvZ':_0x3f91(0x144)};try{var _0x2bcfa8;const _0x41baf6=_0x583f34||userToken;if(!_0x41baf6)return _0xf12dc0['oghvq']('yOVWM',_0xf12dc0['wfGBl'])?(console[_0x3f91(0x1d)](_0xf12dc0[_0x3f91(0x145)]),null):(_0x55cc4e[_0x3f91(0x54)](_0xf12dc0[_0x3f91(0x146)],_0x315a56),null);const _0x1d6c13=_0xf12dc0[_0x3f91(0x147)](decodeJWTPayload,_0x41baf6);if(!_0x1d6c13)return _0xf12dc0[_0x3f91(0x148)](_0xf12dc0[_0x3f91(0x149)],_0xf12dc0['cUYVi'])?{'isValid':![],'error':_0x5aa63d,'keyType':_0x4479c,'isNetworkError':!![]}:null;const _0x36a14f={'id':_0x1d6c13['id'],'email':_0x1d6c13[_0x3f91(0x14a)],'userId':_0x1d6c13['userId'],'userName':_0x1d6c13[_0x3f91(0x13f)]||_0x1d6c13['username'],'verified':_0x1d6c13[_0x3f91(0x14b)],'iat':_0x1d6c13['iat'],'exp':_0x1d6c13[_0x3f91(0x14c)]};return _0xf12dc0[_0x3f91(0x148)](_0x2bcfa8=globalConfig,null)&&_0xf12dc0[_0x3f91(0x14d)](_0x2bcfa8,void 0x0)&&_0x2bcfa8['enableLogging']&&(_0xf12dc0['pZLMK'](_0xf12dc0[_0x3f91(0x14e)],_0x3f91(0x14f))?console[_0x3f91(0x36)](_0x3f91(0x150),_0x36a14f):_0x298cfa=_0x3f91(0xfc)+_0x1c9784+_0x3f91(0xfd)+_0x11e53c['message']),_0x36a14f;}catch(_0x5ad70d){return console[_0x3f91(0x54)]('❌\x20Failed\x20to\x20extract\x20user\x20data\x20from\x20JWT:',_0x5ad70d),null;}};exports[_0x3f91(0x151)]=extractUserDataFromJWT;const isUserAuthenticated=()=>{return!!userToken;};exports[_0x3f91(0x7)]=isUserAuthenticated;const getAuthHeaders=()=>{const _0x3cdf3b={'Zovvl':function(_0x44d0e1,_0x2f2124){return _0x44d0e1===_0x2f2124;},'ofwkh':function(_0x552e25,_0x4f554c){return _0x552e25===_0x4f554c;},'sFCiy':function(_0x5e9f71,_0x411e6c){return _0x5e9f71===_0x411e6c;},'RDSXa':function(_0x288529,_0x389fed){return _0x288529!==_0x389fed;},'NZsFK':_0x3f91(0x152),'txppS':_0x3f91(0x20),'dYcWz':function(_0x8a2054,_0x39bdfe){return _0x8a2054(_0x39bdfe);},'fjmBe':_0x3f91(0x153),'TDvdG':_0x3f91(0x42)};var _0x20505c;if(!(_0x3cdf3b[_0x3f91(0x154)](_0x20505c=globalConfig,null)&&_0x3cdf3b[_0x3f91(0x154)](_0x20505c,void 0x0)&&_0x20505c['apiKey'])){if(_0x3cdf3b[_0x3f91(0x155)]===_0x3f91(0x156)){var _0x29cdff,_0xc51afd,_0x431787;_0x215501[_0x3f91(0x36)](_0x3f91(0x8a),{'apiKeyId':(_0x29cdff=_0x408a87[_0x3f91(0x38)])===null||_0x3cdf3b[_0x3f91(0x157)](_0x29cdff,void 0x0)?void 0x0:_0x29cdff['id'],'appName':(_0xc51afd=_0xad87d2['application'])===null||_0x3cdf3b[_0x3f91(0x158)](_0xc51afd,void 0x0)?void 0x0:_0xc51afd[_0x3f91(0xda)],'usageCount':(_0x431787=_0x50b2ef[_0x3f91(0x38)])===null||_0x3cdf3b[_0x3f91(0x159)](_0x431787,void 0x0)?void 0x0:_0x431787[_0x3f91(0x15a)]});}else throw new Error(_0x3cdf3b[_0x3f91(0x15b)]);}const _0x1ceaf4=_0x3cdf3b[_0x3f91(0x15c)](getApiKeyType,globalConfig[_0x3f91(0x38)]);return{'Content-Type':'application/json','Authorization':'Bearer\x20'+globalConfig[_0x3f91(0x38)],'User-Agent':_0x3f91(0x15d),'X-SDK-Version':_0x3cdf3b[_0x3f91(0x15e)],'X-SDK-Environment':globalConfig[_0x3f91(0x41)]||_0x3cdf3b['TDvdG'],'X-API-Key-Type':_0x1ceaf4,'X-Timestamp':new Date()[_0x3f91(0x43)]()};};exports[_0x3f91(0xb)]=getAuthHeaders;const getDeveloperAuthHeaders=()=>{const _0x569489={'wHeja':_0x3f91(0x78),'QQAKE':function(_0x3f23ac,_0x2d96e3){return _0x3f23ac!==_0x2d96e3;},'cZEln':function(_0x72e838,_0x36d3e0){return _0x72e838===_0x36d3e0;},'jzjkI':'Fhjwj','qPluM':_0x3f91(0x20),'GIXBW':function(_0x50d8f1,_0x104d0d){return _0x50d8f1(_0x104d0d);},'ITVBx':'OnairosSDK/1.0.0','AeFtS':_0x3f91(0x153),'QjSDs':_0x3f91(0x42)};var _0x166ccf;if(!((_0x166ccf=globalConfig)!==null&&_0x569489[_0x3f91(0x15f)](_0x166ccf,void 0x0)&&_0x166ccf[_0x3f91(0x38)])){if(_0x569489[_0x3f91(0x160)](_0x569489[_0x3f91(0x161)],_0x569489['jzjkI']))throw new Error(_0x569489[_0x3f91(0x162)]);else return _0x392c48[_0x3f91(0x54)](_0x569489['wHeja']),null;}const _0x189958=_0x569489[_0x3f91(0x163)](getApiKeyType,globalConfig[_0x3f91(0x38)]);return{'Content-Type':'application/json','Authorization':_0x3f91(0x3f)+globalConfig[_0x3f91(0x38)],'User-Agent':_0x569489[_0x3f91(0x164)],'X-SDK-Version':_0x569489[_0x3f91(0x165)],'X-SDK-Environment':globalConfig['environment']||_0x569489[_0x3f91(0x166)],'X-API-Key-Type':_0x189958,'X-Timestamp':new Date()[_0x3f91(0x43)]()};};exports[_0x3f91(0xa)]=getDeveloperAuthHeaders;const getUserAuthHeaders=()=>{const _0x3f31d2={'KOZUV':function(_0x1a2246,_0x24c43d){return _0x1a2246!==_0x24c43d;},'qqULu':_0x3f91(0x167),'wpRFU':_0x3f91(0x100),'qtIcw':_0x3f91(0x40),'zxmmR':_0x3f91(0x153),'yvUlZ':function(_0x595ea0,_0x219596){return _0x595ea0===_0x219596;},'wmLTr':_0x3f91(0x42)};var _0x46fa66;if(!userToken){if(_0x3f31d2[_0x3f91(0x168)](_0x3f31d2[_0x3f91(0x169)],_0x3f91(0x167)))throw new _0x1a61d9('Server\x20returned\x20HTML\x20page\x20instead\x20of\x20JSON\x20API\x20response.\x20This\x20often\x20indicates\x20a\x20routing\x20issue\x20or\x20server\x20misconfiguration.');else throw new Error(_0x3f31d2['wpRFU']);}return{'Content-Type':'application/json','Authorization':'Bearer\x20'+userToken,'User-Agent':_0x3f31d2[_0x3f91(0x16a)],'X-SDK-Version':_0x3f31d2['zxmmR'],'X-SDK-Environment':(_0x3f31d2['yvUlZ'](_0x46fa66=globalConfig,null)||_0x3f31d2[_0x3f91(0x16b)](_0x46fa66,void 0x0)?void 0x0:_0x46fa66[_0x3f91(0x41)])||_0x3f31d2[_0x3f91(0x16c)]};};exports[_0x3f91(0x9)]=getUserAuthHeaders;const makeAuthenticatedRequest=async(_0x34c689,_0x1439a8={})=>{const _0x3de061={'AGKSn':'User\x20not\x20authenticated.\x20Please\x20verify\x20email\x20first.','Ehahp':_0x3f91(0x28),'CAkdz':'KigNs','RLgjj':_0x3f91(0x16d),'cgFcv':_0x3f91(0x20),'WQuSW':function(_0x3f573a){return _0x3f573a();},'qPRWb':function(_0x2e5fd9){return _0x2e5fd9();},'kuAqc':_0x3f91(0x16e),'GnSiU':'LBZWz','zCvMU':function(_0x124908,_0x1fa8d0,_0x2245f0){return _0x124908(_0x1fa8d0,_0x2245f0);},'RBfpw':function(_0x271770,_0x323424){return _0x271770(_0x323424);},'DfjQG':function(_0x3f756b,_0x4246e8){return _0x3f756b===_0x4246e8;},'WtnhP':'❌\x20API\x20key\x20authentication\x20failed.\x20Please\x20check\x20your\x20API\x20key.','YfXda':_0x3f91(0x16f),'AQJsF':function(_0x50e2c3,_0x2413da){return _0x50e2c3===_0x2413da;},'nglEe':_0x3f91(0x13e),'VYdpp':_0x3f91(0x138),'IDNUb':function(_0xe4d9b,_0xeb6cc2){return _0xe4d9b===_0xeb6cc2;},'oGcPR':_0x3f91(0x170),'fasWq':function(_0x3676a8,_0x519f62){return _0x3676a8(_0x519f62);},'rmzsc':function(_0x445415,_0x25297c){return _0x445415===_0x25297c;},'vpwYv':_0x3f91(0x171),'hhvrq':_0x3f91(0xa2)};if(!isApiKeyInitialized()){if(_0x3de061[_0x3f91(0x172)]!==_0x3de061[_0x3f91(0x173)])throw new Error(_0x3de061[_0x3f91(0x174)]);else throw new _0x5a0ec2(_0x3de061[_0x3f91(0x175)]);}const _0x58e545=_0x3de061[_0x3f91(0x176)](getApiConfig),_0x226b13=API_ENDPOINTS[_0x58e545['environment']||_0x3f91(0x42)],_0x2f5d5e=''+_0x226b13+(_0x34c689[_0x3f91(0x4a)]('/')?'':'/')+_0x34c689,_0xf1550={..._0x3de061[_0x3f91(0x177)](getAuthHeaders),..._0x1439a8[_0x3f91(0xba)]||{}},_0x17f04c=new AbortController(),_0x8579f1=setTimeout(()=>_0x17f04c['abort'](),_0x58e545[_0x3f91(0x2b)]||0x7530);try{if(_0x58e545[_0x3f91(0x4c)]){if(_0x3de061['kuAqc']!==_0x3de061[_0x3f91(0x178)])console[_0x3f91(0x36)](_0x3f91(0x96)+_0x34c689);else throw new _0x132fcb(_0x3f91(0xc6));}const _0x19f496=await _0x3de061[_0x3f91(0x179)](fetch,_0x2f5d5e,{..._0x1439a8,'headers':_0xf1550,'signal':_0x17f04c[_0x3f91(0xae)]});_0x3de061['RBfpw'](clearTimeout,_0x8579f1);_0x58e545[_0x3f91(0x4c)]&&console[_0x3f91(0x36)](_0x3f91(0x17a)+_0x19f496[_0x3f91(0x6a)]+'\x20for\x20'+_0x34c689);if(_0x3de061[_0x3f91(0x17b)](_0x19f496[_0x3f91(0x6a)],0x191)){console[_0x3f91(0x54)](_0x3de061[_0x3f91(0x17c)]);throw new Error(_0x3de061[_0x3f91(0x17d)]);}if(_0x3de061['AQJsF'](_0x19f496[_0x3f91(0x6a)],0x193)){console[_0x3f91(0x54)](_0x3de061['nglEe']);throw new Error(_0x3de061[_0x3f91(0x17e)]);}if(_0x3de061[_0x3f91(0x17b)](_0x19f496[_0x3f91(0x6a)],0x1ad)){console[_0x3f91(0x54)]('❌\x20API\x20rate\x20limit\x20exceeded.\x20Please\x20try\x20again\x20later.');throw new Error(_0x3f91(0x17f));}return _0x19f496;}catch(_0x3b1abb){if(_0x3de061[_0x3f91(0x180)](_0x3de061[_0x3f91(0x181)],_0x3de061['oGcPR'])){_0x3de061['fasWq'](clearTimeout,_0x8579f1);if(_0x3de061[_0x3f91(0x182)](_0x3b1abb[_0x3f91(0xda)],_0x3de061[_0x3f91(0x183)])){console[_0x3f91(0x54)](_0x3f91(0x184),_0x34c689);throw new Error(_0x3de061['hhvrq']);}throw _0x3b1abb;}else throw new _0x4312fb(_0x3de061['Ehahp']);}};exports[_0x3f91(0x5)]=makeAuthenticatedRequest;const makeDeveloperRequest=async(_0x226416,_0x10e59a={})=>{const _0x5e3a17={'tmlqx':function(_0x3a2ca9,_0x21a97f){return _0x3a2ca9===_0x21a97f;},'TNgRZ':_0x3f91(0x171),'alcJA':'⏱️\x20Request\x20timeout\x20for:','FqZVl':_0x3f91(0xa2),'eNqmn':_0x3f91(0x113),'tZIqa':function(_0x2cc9e2,_0x52e58f){return _0x2cc9e2!==_0x52e58f;},'iHkBT':_0x3f91(0x185),'mogDa':_0x3f91(0x20),'LEeif':function(_0x8d8501){return _0x8d8501();},'yQiXb':_0x3f91(0x42),'JHwZj':function(_0x3dc70b,_0xdab0be,_0x42fea9){return _0x3dc70b(_0xdab0be,_0x42fea9);},'aVaET':_0x3f91(0x186),'chUhM':function(_0x1436f5,_0xfa88d4){return _0x1436f5===_0xfa88d4;},'OhjdV':function(_0x52826d,_0x1fabea){return _0x52826d===_0x1fabea;},'pInaC':_0x3f91(0x187),'bTILE':'dBYAJ','hpCnu':_0x3f91(0x188),'reVgQ':function(_0x410557,_0x1d19e4){return _0x410557===_0x1d19e4;},'HIvfw':_0x3f91(0x189),'RWkFp':'Insufficient\x20API\x20key\x20permissions','bjgNw':function(_0x19a586,_0x3ebe59){return _0x19a586===_0x3ebe59;},'CWmLC':_0x3f91(0x17f),'uMaCC':function(_0x4253e4,_0x39dfaf){return _0x4253e4!==_0x39dfaf;},'BDrKz':'kkzEM','NLLqk':_0x3f91(0x18a),'lfyxU':function(_0x446251,_0x25dab3){return _0x446251(_0x25dab3);},'ABmbi':function(_0x43186d,_0xca1312){return _0x43186d===_0xca1312;},'iYeRS':_0x3f91(0x18b)};if(!isApiKeyInitialized()){if(_0x5e3a17['tZIqa'](_0x3f91(0x185),_0x5e3a17[_0x3f91(0x18c)]))return _0x266dd7[_0x3f91(0x54)](_0x3f91(0x12e),_0x13c995),null;else throw new Error(_0x5e3a17[_0x3f91(0x18d)]);}const _0xe8b5aa=_0x5e3a17['LEeif'](getApiConfig),_0x3f2e9e=API_ENDPOINTS[_0xe8b5aa[_0x3f91(0x41)]||_0x5e3a17[_0x3f91(0x18e)]],_0x3ccd1f=''+_0x3f2e9e+(_0x226416['startsWith']('/')?'':'/')+_0x226416,_0x125896={..._0x5e3a17[_0x3f91(0x18f)](getDeveloperAuthHeaders),..._0x10e59a[_0x3f91(0xba)]||{}},_0x1d980f=new AbortController(),_0x4863a4=_0x5e3a17[_0x3f91(0x190)](setTimeout,()=>_0x1d980f[_0x3f91(0xa6)](),_0xe8b5aa[_0x3f91(0x2b)]||0x7530);try{if(_0x5e3a17[_0x3f91(0x191)](_0x3f91(0x192),_0x5e3a17[_0x3f91(0x193)])){_0xe8b5aa['enableLogging']&&console[_0x3f91(0x36)](_0x3f91(0x194)+_0x226416);const _0x357c22=await _0x5e3a17['JHwZj'](fetch,_0x3ccd1f,{..._0x10e59a,'headers':_0x125896,'signal':_0x1d980f['signal']});clearTimeout(_0x4863a4);_0xe8b5aa[_0x3f91(0x4c)]&&console[_0x3f91(0x36)](_0x3f91(0x195)+_0x357c22['status']+_0x3f91(0x196)+_0x226416);if(_0x5e3a17['chUhM'](_0x357c22[_0x3f91(0x6a)],0x191)){if(_0x5e3a17['OhjdV'](_0x5e3a17['pInaC'],_0x5e3a17[_0x3f91(0x197)])){_0x722ddb(_0x8e059a);if(_0x5e3a17[_0x3f91(0x198)](_0x3f1c80[_0x3f91(0xda)],_0x5e3a17[_0x3f91(0x199)])){_0x33b2a9['error'](_0x5e3a17[_0x3f91(0x19a)],_0x5e7bba);throw new _0x4f6e4d(_0x5e3a17['FqZVl']);}throw _0x5e10b3;}else{console[_0x3f91(0x54)](_0x5e3a17[_0x3f91(0x19b)]);throw new Error(_0x3f91(0x16f));}}if(_0x5e3a17[_0x3f91(0x19c)](_0x357c22[_0x3f91(0x6a)],0x193)){if(_0x5e3a17[_0x3f91(0x191)](_0x5e3a17[_0x3f91(0x19d)],_0x3f91(0x19e))){console[_0x3f91(0x54)](_0x3f91(0x19f));throw new Error(_0x5e3a17[_0x3f91(0x1a0)]);}else return null;}if(_0x5e3a17[_0x3f91(0x1a1)](_0x357c22[_0x3f91(0x6a)],0x1ad)){console[_0x3f91(0x54)](_0x3f91(0x1a2));throw new Error(_0x5e3a17[_0x3f91(0x1a3)]);}return _0x357c22;}else _0x3e616e='Network\x20connectivity\x20issue.\x20Please\x20check\x20internet\x20connection\x20and\x20verify\x20the\x20Onairos\x20API\x20is\x20accessible.\x20'+_0x4743c0[_0x3f91(0x69)];}catch(_0x50f1af){if(_0x5e3a17['uMaCC'](_0x5e3a17[_0x3f91(0x1a4)],_0x5e3a17[_0x3f91(0x1a5)])){_0x5e3a17[_0x3f91(0x1a6)](clearTimeout,_0x4863a4);if(_0x5e3a17['chUhM'](_0x50f1af[_0x3f91(0xda)],_0x3f91(0x171))){if(_0x5e3a17[_0x3f91(0x1a7)](_0x5e3a17[_0x3f91(0x1a8)],_0x5e3a17['iYeRS'])){console[_0x3f91(0x54)](_0x5e3a17[_0x3f91(0x19a)],_0x226416);throw new Error(_0x5e3a17['FqZVl']);}else _0x3ccd32[_0x3f91(0x36)](_0x5e3a17[_0x3f91(0x1a9)]);}throw _0x50f1af;}else return{'isValid':![],'error':_0x4b780c,'keyType':_0x4a1658};}};exports[_0x3f91(0x4)]=makeDeveloperRequest;const makeUserRequest=async(_0x11d733,_0xcc6427={})=>{const _0x29cb49={'GvwpG':'🎫\x20User\x20JWT\x20token\x20loaded\x20from\x20storage','xewQZ':_0x3f91(0x13a),'VFehe':function(_0x3c4d7f,_0x4661b0){return _0x3c4d7f(_0x4661b0);},'fhIEJ':function(_0x5922e7,_0x25d4f4){return _0x5922e7===_0x25d4f4;},'VUNhF':_0x3f91(0x184),'gdInB':_0x3f91(0xa2),'sRcWb':function(_0x3bb733){return _0x3bb733();},'SwtmP':function(_0x28c9e3,_0x417da2){return _0x28c9e3===_0x417da2;},'wnaMO':_0x3f91(0x1aa),'pxYJS':'production','FnAss':function(_0x2cae39,_0x146c30,_0x5bea19){return _0x2cae39(_0x146c30,_0x5bea19);},'puqfE':function(_0x3f5141,_0x3a6833){return _0x3f5141(_0x3a6833);},'AYcCi':function(_0x559b24,_0x487395){return _0x559b24!==_0x487395;},'ofnyu':_0x3f91(0x1ab),'uqUdI':function(_0x1ab9df,_0x58d572){return _0x1ab9df===_0x58d572;},'cIlUC':_0x3f91(0x1ac),'MANlH':_0x3f91(0x1ad),'EmUmb':_0x3f91(0xee),'jskLe':'pFPCn','FEMfJ':function(_0xab24a9,_0x370b59){return _0xab24a9(_0x370b59);},'jvMHQ':function(_0x59b6b7,_0x52064d){return _0x59b6b7===_0x52064d;},'OpNWJ':'AbortError','DgvMk':_0x3f91(0x1ae)};!_0x29cb49[_0x3f91(0x1af)](isUserAuthenticated)&&(_0x29cb49['SwtmP'](_0x3f91(0x1b0),_0x29cb49[_0x3f91(0x1b1)])?_0xb13749[_0x3f91(0x36)](_0x29cb49[_0x3f91(0x1b2)]):await _0x29cb49[_0x3f91(0x1af)](loadJWT));if(!_0x29cb49[_0x3f91(0x1af)](isUserAuthenticated))throw new Error(_0x3f91(0x100));const _0x5d0833=getApiConfig()||{'environment':_0x3f91(0x42),'timeout':0x7530,'enableLogging':![]},_0x2419a9=API_ENDPOINTS[_0x5d0833['environment']||_0x29cb49['pxYJS']],_0x538ce7=''+_0x2419a9+(_0x11d733[_0x3f91(0x4a)]('/')?'':'/')+_0x11d733,_0x187a25={..._0x29cb49[_0x3f91(0x1af)](getUserAuthHeaders),..._0xcc6427[_0x3f91(0xba)]||{}},_0x3fafc7=new AbortController(),_0x232a38=_0x29cb49[_0x3f91(0x1b3)](setTimeout,()=>_0x3fafc7[_0x3f91(0xa6)](),_0x5d0833[_0x3f91(0x2b)]||0x7530);try{_0x5d0833[_0x3f91(0x4c)]&&console[_0x3f91(0x36)](_0x3f91(0xf2)+_0x11d733);const _0x2051a8=await _0x29cb49[_0x3f91(0x1b3)](fetch,_0x538ce7,{..._0xcc6427,'headers':_0x187a25,'signal':_0x3fafc7['signal']});_0x29cb49[_0x3f91(0x1b4)](clearTimeout,_0x232a38);if(_0x5d0833[_0x3f91(0x4c)]){if(_0x29cb49[_0x3f91(0x1b5)](_0x29cb49[_0x3f91(0x1b6)],_0x3f91(0x1b7)))console[_0x3f91(0x36)]('📡\x20User\x20request\x20response:\x20'+_0x2051a8['status']+_0x3f91(0x196)+_0x11d733);else return _0x3f6e24['warn'](_0x29cb49[_0x3f91(0x1b8)]),null;}if(_0x29cb49['uqUdI'](_0x2051a8[_0x3f91(0x6a)],0x191)){console['error'](_0x29cb49['cIlUC']),await _0x29cb49[_0x3f91(0x1af)](clearJWT);throw new Error(_0x29cb49['MANlH']);}if(_0x2051a8['status']===0x193){console['error'](_0x29cb49['EmUmb']);throw new Error(_0x3f91(0x77));}return _0x2051a8;}catch(_0xd6315a){if(_0x29cb49['jskLe']!==_0x29cb49[_0x3f91(0x1b9)]){_0x29cb49['VFehe'](_0x4712a5,_0x3b2d43);if(_0x29cb49['fhIEJ'](_0x3d50b5['name'],_0x3f91(0x171))){_0x5de050[_0x3f91(0x54)](_0x29cb49['VUNhF'],_0x3870c5);throw new _0x4944b7(_0x29cb49[_0x3f91(0x1ba)]);}throw _0x12688a;}else{_0x29cb49[_0x3f91(0x1bb)](clearTimeout,_0x232a38);if(_0x29cb49[_0x3f91(0x1bc)](_0xd6315a[_0x3f91(0xda)],_0x29cb49[_0x3f91(0x1bd)])){if(_0x29cb49[_0x3f91(0x1be)](_0x29cb49['DgvMk'],_0x29cb49[_0x3f91(0x1bf)])){console[_0x3f91(0x54)](_0x29cb49[_0x3f91(0x1c0)],_0x11d733);throw new Error(_0x29cb49[_0x3f91(0x1ba)]);}else throw new _0xf258c4(_0x3f91(0x25));}throw _0xd6315a;}}};exports[_0x3f91(0x3)]=makeUserRequest;const clearValidationCache=()=>{const _0x52c3a8={'smJmz':function(_0x1a93da,_0x56c1e4){return _0x1a93da!==_0x56c1e4;},'IFijw':function(_0x2ac310,_0x40cb61){return _0x2ac310!==_0x40cb61;},'SpoPw':_0x3f91(0x75)};var _0x461f11;validationCache['clear'](),_0x52c3a8['smJmz'](_0x461f11=globalConfig,null)&&_0x52c3a8['IFijw'](_0x461f11,void 0x0)&&_0x461f11[_0x3f91(0x4c)]&&console[_0x3f91(0x36)](_0x52c3a8[_0x3f91(0x1c1)]);};exports[_0x3f91(0x10)]=clearValidationCache;const resetApiKeyService=()=>{const _0x3eb349={'BAWQI':function(_0x5f0f0b){return _0x5f0f0b();},'nfsWK':_0x3f91(0x1c2)};globalConfig=null,isInitialized=![],_0x3eb349[_0x3f91(0x1c3)](clearValidationCache),console[_0x3f91(0x36)](_0x3eb349['nfsWK']);};exports['resetApiKeyService']=resetApiKeyService;
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.validateApiKey = exports.storeJWT = exports.resetApiKeyService = exports.makeUserRequest = exports.makeDeveloperRequest = exports.makeAuthenticatedRequest = exports.loadJWT = exports.isUserAuthenticated = exports.isApiKeyInitialized = exports.initializeApiKey = exports.getUserAuthHeaders = exports.getJWT = exports.getDeveloperAuthHeaders = exports.getAuthHeaders = exports.getApiKeyType = exports.getApiKey = exports.getApiConfig = exports.extractUsernameFromJWT = exports.extractUserDataFromJWT = exports.decodeJWTPayload = exports.clearValidationCache = exports.clearJWT = exports.ApiKeyType = void 0;
7
+ var _asyncStorage = _interopRequireDefault(require("@react-native-async-storage/async-storage"));
8
+ var _netinfo = _interopRequireDefault(require("@react-native-community/netinfo"));
9
+ var _api = require("../config/api");
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ // API key types - Only developer keys are supported in client SDK
12
+ let ApiKeyType = exports.ApiKeyType = /*#__PURE__*/function (ApiKeyType) {
13
+ ApiKeyType["DEVELOPER"] = "developer";
14
+ ApiKeyType["INVALID"] = "invalid";
15
+ return ApiKeyType;
16
+ }({}); // JWT token storage key
17
+ const JWT_TOKEN_KEY = 'onairos_jwt_token';
18
+
19
+ /**
20
+ * Two-Tier Authentication Service for Onairos React Native SDK
21
+ *
22
+ * This service implements the two-tier authentication system:
23
+ * 1. Developer API Keys: For app-level operations (email verification, app registration)
24
+ * 2. JWT User Tokens: For user-level operations (PIN storage, user profile)
25
+ *
26
+ * How it works:
27
+ * 1. Initialize with developer API key
28
+ * 2. Use API key for email verification requests
29
+ * 3. Store JWT token from email verification response
30
+ * 4. Use JWT token for user-authenticated requests
31
+ * 5. Handle token expiration gracefully
32
+ *
33
+ * Backend Integration:
34
+ * - Developer routes: Authorization: Bearer ${API_KEY}
35
+ * - User routes: Authorization: Bearer ${JWT_TOKEN}
36
+ */
37
+
38
+ // Global configuration state
39
+ let globalConfig = null;
40
+ let validationCache = new Map();
41
+ let isInitialized = false;
42
+ let userToken = null;
43
+
44
+ // Cache duration (5 minutes)
45
+ const CACHE_DURATION = 5 * 60 * 1000;
46
+
47
+ /**
48
+ * Check network connectivity
49
+ * @returns Promise<boolean> - true if connected, false otherwise
50
+ */
51
+ const checkNetworkConnectivity = async () => {
52
+ try {
53
+ const netInfo = await _netinfo.default.fetch();
54
+ return netInfo.isConnected === true && netInfo.isInternetReachable !== false;
55
+ } catch (error) {
56
+ console.warn('⚠️ Failed to check network connectivity:', error);
57
+ // If we can't check connectivity, assume we're connected and let the request fail naturally
58
+ return true;
59
+ }
60
+ };
61
+
62
+ // API endpoints for different environments (updated to handle non-existent dev endpoint)
63
+ const API_ENDPOINTS = {
64
+ production: `${_api.API_CONFIG.BASE_URL}`,
65
+ staging: `${_api.API_CONFIG.BASE_URL}`,
66
+ // Fallback to production for staging
67
+ development: `${_api.API_CONFIG.BASE_URL}` // Fallback to production since dev-API server doesn't exist
68
+ };
69
+
70
+ /**
71
+ * Initialize the SDK with developer API key
72
+ * @param config API configuration including developer API key
73
+ */
74
+ const initializeApiKey = async config => {
75
+ try {
76
+ console.log('🔑 Initializing Onairos SDK with developer API key...');
77
+ if (!config.apiKey) {
78
+ throw new Error('Developer API key is required for SDK initialization');
79
+ }
80
+
81
+ // Validate developer key format
82
+ if (config.apiKey.length < 32) {
83
+ throw new Error('Invalid API key format. Developer keys must be at least 32 characters long.');
84
+ }
85
+
86
+ // Check for valid developer key prefix
87
+ const validPrefixes = ['dev_', 'ona_', 'pk_'];
88
+ const hasValidPrefix = validPrefixes.some(prefix => config.apiKey.startsWith(prefix));
89
+ if (!hasValidPrefix) {
90
+ throw new Error('Invalid API key format. Developer keys must start with dev_, ona_, or pk_');
91
+ }
92
+
93
+ // Set global configuration
94
+ globalConfig = {
95
+ apiKey: config.apiKey,
96
+ environment: config.environment || 'production',
97
+ enableLogging: config.enableLogging !== false,
98
+ // Default to true
99
+ timeout: config.timeout || 30000,
100
+ retryAttempts: config.retryAttempts || 3
101
+ };
102
+ if (globalConfig.enableLogging) {
103
+ console.log('📝 SDK Configuration:', {
104
+ environment: globalConfig.environment,
105
+ timeout: globalConfig.timeout,
106
+ retryAttempts: globalConfig.retryAttempts,
107
+ apiKeyPrefix: config.apiKey.substring(0, 8) + '...',
108
+ enableLogging: globalConfig.enableLogging
109
+ });
110
+ }
111
+
112
+ // Validate the API key (handles both admin and developer keys)
113
+ const validation = await validateApiKey(config.apiKey);
114
+ if (!validation.isValid) {
115
+ // Use defensive coding to handle cases where validation.error might be undefined
116
+ const errorMessage = validation.error || '';
117
+
118
+ // Check if it's a network/connectivity issue (either from error message or the flag)
119
+ const isNetworkError = validation.isNetworkError || errorMessage.includes('Network request failed') || errorMessage.includes('Network error') || errorMessage.includes('JSON Parse error') || errorMessage.includes('API validation endpoint returned') || errorMessage.includes('timeout') || errorMessage.includes('ENOTFOUND') || errorMessage.includes('fetch') || errorMessage.includes('No network connection');
120
+ if (isNetworkError) {
121
+ console.warn('⚠️ API key validation failed due to network/connectivity issues');
122
+ console.warn('🔄 Continuing in offline mode with basic validation');
123
+ console.warn('📝 SDK will function with limited validation. Network connectivity will be retried automatically.');
124
+ console.warn('🌐 Error details:', validation.error);
125
+
126
+ // Continue initialization in offline mode - don't throw error
127
+ console.log('📱 SDK initialized in offline mode - will retry validation when network is available');
128
+ } else {
129
+ // Only throw for actual API key validation errors (not network issues)
130
+ throw new Error(`API key validation failed: ${validation.error}`);
131
+ }
132
+ }
133
+
134
+ // Try to load existing JWT token
135
+ await loadJWT();
136
+ isInitialized = true;
137
+ if (globalConfig.enableLogging) {
138
+ console.log('✅ Onairos SDK initialized successfully');
139
+ console.log('🔑 Developer API key ready for app-level operations');
140
+ if (userToken) {
141
+ console.log('🎫 User JWT token loaded from storage');
142
+ }
143
+ if (validation.permissions) {
144
+ console.log('🔐 API Key Permissions:', validation.permissions);
145
+ }
146
+ if (validation.rateLimits) {
147
+ console.log('⏱️ Rate Limits:', validation.rateLimits);
148
+ }
149
+ }
150
+ } catch (error) {
151
+ console.error('❌ Failed to initialize Onairos SDK:', error);
152
+ isInitialized = false;
153
+ throw error;
154
+ }
155
+ };
156
+
157
+ /**
158
+ * Determine API key type
159
+ * @param apiKey The API key to check
160
+ * @returns The type of API key (only DEVELOPER or INVALID - admin keys not supported in client SDK)
161
+ */
162
+ exports.initializeApiKey = initializeApiKey;
163
+ const getApiKeyType = apiKey => {
164
+ // Developer keys must be at least 32 characters and start with specific prefix
165
+ if (apiKey.length >= 32 && (apiKey.startsWith('dev_') || apiKey.startsWith('pk_') || apiKey.startsWith('ona_'))) {
166
+ return ApiKeyType.DEVELOPER;
167
+ }
168
+ return ApiKeyType.INVALID;
169
+ };
170
+
171
+ /**
172
+ * Validate an API key with the Onairos backend
173
+ * All developer keys must be validated against the backend - no local bypass
174
+ * @param apiKey The API key to validate
175
+ * @returns Validation result with permissions and rate limits
176
+ */
177
+ exports.getApiKeyType = getApiKeyType;
178
+ const validateApiKey = async apiKey => {
179
+ try {
180
+ var _globalConfig2, _globalConfig3, _globalConfig4;
181
+ console.log('🔍 Validating developer API key against backend...');
182
+
183
+ // Check basic format for developer keys
184
+ const keyType = getApiKeyType(apiKey);
185
+ if (keyType === ApiKeyType.INVALID) {
186
+ return {
187
+ isValid: false,
188
+ error: 'Invalid API key format. Developer keys must be at least 32 characters and start with "dev_", "pk_", or "ona_"',
189
+ keyType: ApiKeyType.INVALID
190
+ };
191
+ }
192
+
193
+ // Check cache first
194
+ const cached = validationCache.get(apiKey);
195
+ if (cached && Date.now() - cached.timestamp < CACHE_DURATION) {
196
+ var _globalConfig;
197
+ if ((_globalConfig = globalConfig) !== null && _globalConfig !== void 0 && _globalConfig.enableLogging) {
198
+ console.log('📋 Using cached API key validation result');
199
+ }
200
+ return cached.result;
201
+ }
202
+
203
+ // Check network connectivity before making API calls
204
+ const isConnected = await checkNetworkConnectivity();
205
+ if (!isConnected) {
206
+ console.warn('⚠️ No network connectivity detected');
207
+ return {
208
+ isValid: false,
209
+ error: 'No network connection available. Please check your internet connection and try again.',
210
+ keyType: keyType,
211
+ isNetworkError: true
212
+ };
213
+ }
214
+ const environment = ((_globalConfig2 = globalConfig) === null || _globalConfig2 === void 0 ? void 0 : _globalConfig2.environment) || 'production';
215
+ const baseUrl = API_ENDPOINTS[environment];
216
+ const timeout = ((_globalConfig3 = globalConfig) === null || _globalConfig3 === void 0 ? void 0 : _globalConfig3.timeout) || 30000;
217
+ const maxRetries = ((_globalConfig4 = globalConfig) === null || _globalConfig4 === void 0 ? void 0 : _globalConfig4.retryAttempts) || 3;
218
+
219
+ // Retry logic for network failures
220
+ for (let attempt = 1; attempt <= maxRetries; attempt++) {
221
+ // Create abort controller for timeout
222
+ const controller = new AbortController();
223
+ const timeoutId = setTimeout(() => controller.abort(), timeout);
224
+ try {
225
+ var _globalConfig5;
226
+ if ((_globalConfig5 = globalConfig) !== null && _globalConfig5 !== void 0 && _globalConfig5.enableLogging && attempt > 1) {
227
+ console.log(`🔄 Retry attempt ${attempt}/${maxRetries} for API key validation`);
228
+ }
229
+ const response = await fetch(`${baseUrl}/dev/validate-apikey`, {
230
+ method: 'POST',
231
+ headers: {
232
+ 'Content-Type': 'application/json',
233
+ 'Authorization': `Bearer ${apiKey}`,
234
+ 'User-Agent': 'OnairosReactNative/3.3.1',
235
+ 'X-API-Key-Type': keyType,
236
+ 'X-SDK-Platform': 'react-native',
237
+ 'X-Retry-Attempt': attempt.toString()
238
+ },
239
+ body: JSON.stringify({
240
+ environment,
241
+ sdk_version: '3.3.1',
242
+ platform: 'react-native',
243
+ keyType,
244
+ timestamp: new Date().toISOString(),
245
+ attempt
246
+ }),
247
+ signal: controller.signal
248
+ });
249
+ clearTimeout(timeoutId);
250
+
251
+ // First check if we got a valid response
252
+ if (!response) {
253
+ throw new Error('No response received from server');
254
+ }
255
+
256
+ // Handle common HTTP errors that indicate server issues
257
+ if (response.status === 502) {
258
+ throw new Error('Onairos API is temporarily unavailable (502 Bad Gateway). Please try again later.');
259
+ }
260
+ if (response.status === 503) {
261
+ throw new Error('Onairos API is under maintenance (503 Service Unavailable). Please try again later.');
262
+ }
263
+ if (response.status === 504) {
264
+ throw new Error('Onairos API request timed out (504 Gateway Timeout). Please try again.');
265
+ }
266
+
267
+ // Check if response is actually JSON before trying to parse
268
+ const contentType = response.headers.get('content-type');
269
+ const isJsonResponse = contentType && contentType.includes('application/json');
270
+ if (!isJsonResponse) {
271
+ const textContent = await response.text();
272
+ const previewText = textContent.substring(0, 200);
273
+ console.error('❌ API endpoint returned non-JSON response:', {
274
+ status: response.status,
275
+ statusText: response.statusText,
276
+ contentType: contentType || 'unknown',
277
+ preview: previewText,
278
+ url: `${baseUrl}/dev/validate-apikey`,
279
+ attempt: attempt
280
+ });
281
+
282
+ // Handle specific error cases
283
+ if (response.status === 404) {
284
+ throw new Error(`API validation endpoint not found (404). The endpoint ${baseUrl}/dev/validate-apikey may not exist or be configured correctly.`);
285
+ } else if (response.status === 500) {
286
+ throw new Error(`Server error (500). The Onairos backend is experiencing issues.`);
287
+ } else if (response.status === 502 || response.status === 503) {
288
+ throw new Error(`Service unavailable (${response.status}). The Onairos backend may be temporarily down.`);
289
+ } else if (textContent.includes('<html') || textContent.includes('<!DOCTYPE')) {
290
+ throw new Error(`Server returned HTML page instead of JSON API response. This often indicates a routing issue or server misconfiguration.`);
291
+ } else {
292
+ throw new Error(`API validation endpoint returned ${response.status} - ${response.statusText}. Expected JSON but got ${contentType || 'unknown content type'}.`);
293
+ }
294
+ }
295
+
296
+ // Parse JSON response
297
+ let data;
298
+ try {
299
+ data = await response.json();
300
+ } catch (jsonError) {
301
+ console.error('❌ Failed to parse JSON response:', {
302
+ error: jsonError.message,
303
+ status: response.status,
304
+ contentType,
305
+ attempt: attempt
306
+ });
307
+ throw new Error(`Failed to parse server response as JSON: ${jsonError.message}`);
308
+ }
309
+
310
+ // Handle successful response
311
+ // Backend returns either {success: true} or {valid: true}
312
+ if (response.ok && (data.success || data.valid)) {
313
+ var _globalConfig6;
314
+ const result = {
315
+ isValid: true,
316
+ permissions: data.permissions || [],
317
+ rateLimits: data.rateLimits || null,
318
+ keyType: keyType
319
+ };
320
+
321
+ // Cache the successful result
322
+ validationCache.set(apiKey, {
323
+ result,
324
+ timestamp: Date.now()
325
+ });
326
+ if ((_globalConfig6 = globalConfig) !== null && _globalConfig6 !== void 0 && _globalConfig6.enableLogging) {
327
+ var _data$apiKey, _data$application, _data$apiKey2;
328
+ console.log('✅ API key validation successful', {
329
+ apiKeyId: (_data$apiKey = data.apiKey) === null || _data$apiKey === void 0 ? void 0 : _data$apiKey.id,
330
+ appName: (_data$application = data.application) === null || _data$application === void 0 ? void 0 : _data$application.name,
331
+ usageCount: (_data$apiKey2 = data.apiKey) === null || _data$apiKey2 === void 0 ? void 0 : _data$apiKey2.usageCount
332
+ });
333
+ }
334
+ return result;
335
+ } else {
336
+ // Handle API errors (invalid key, etc.)
337
+ const errorMessage = data.error || data.message || `HTTP ${response.status}: ${response.statusText}`;
338
+ const result = {
339
+ isValid: false,
340
+ error: errorMessage,
341
+ keyType: keyType
342
+ };
343
+
344
+ // For client errors (4xx), don't retry
345
+ if (response.status >= 400 && response.status < 500) {
346
+ var _globalConfig7;
347
+ if ((_globalConfig7 = globalConfig) !== null && _globalConfig7 !== void 0 && _globalConfig7.enableLogging) {
348
+ console.error('❌ API key validation failed (client error):', errorMessage);
349
+ }
350
+ return result;
351
+ }
352
+
353
+ // For server errors (5xx), retry
354
+ throw new Error(errorMessage);
355
+ }
356
+ } catch (fetchError) {
357
+ var _globalConfig8;
358
+ clearTimeout(timeoutId);
359
+ if (fetchError.name === 'AbortError') {
360
+ const errorMessage = `API key validation timeout (${timeout}ms)`;
361
+ console.error('⏱️ API key validation timeout');
362
+ if (attempt === maxRetries) {
363
+ return {
364
+ isValid: false,
365
+ error: errorMessage,
366
+ keyType: keyType
367
+ };
368
+ }
369
+ continue; // Retry timeout errors
370
+ }
371
+
372
+ // Enhanced error message based on error type
373
+ let errorMessage = `Network error during API key validation: ${fetchError.message}`;
374
+
375
+ // Add specific guidance for common errors
376
+ if (fetchError.message.includes('JSON Parse error') || fetchError.message.includes('Unexpected character')) {
377
+ errorMessage = `Server returned invalid JSON response. This usually indicates the API endpoint returned HTML instead of JSON (often a 404 or server error page). ${fetchError.message}`;
378
+ } else if (fetchError.message.includes('Network request failed') || fetchError.message.includes('fetch')) {
379
+ errorMessage = `Network connectivity issue. Please check internet connection and verify the Onairos API is accessible. ${fetchError.message}`;
380
+ } else if (fetchError.message.includes('DNS') || fetchError.message.includes('ENOTFOUND')) {
381
+ errorMessage = `DNS resolution failed for ${baseUrl}. Please check network settings and domain accessibility. ${fetchError.message}`;
382
+ }
383
+ console.error('🌐 Network error during API key validation:', {
384
+ error: fetchError,
385
+ endpoint: `${baseUrl}/dev/validate-apikey`,
386
+ attempt: attempt,
387
+ maxRetries: maxRetries,
388
+ retryable: attempt < maxRetries
389
+ });
390
+
391
+ // If this is the last attempt, return the error
392
+ if (attempt === maxRetries) {
393
+ return {
394
+ isValid: false,
395
+ error: errorMessage,
396
+ keyType: keyType,
397
+ isNetworkError: true // Flag to indicate this is a network issue, not an API key issue
398
+ };
399
+ }
400
+
401
+ // Wait before retrying (exponential backoff)
402
+ const backoffDelay = Math.min(1000 * Math.pow(2, attempt - 1), 5000);
403
+ if ((_globalConfig8 = globalConfig) !== null && _globalConfig8 !== void 0 && _globalConfig8.enableLogging) {
404
+ console.log(`⏳ Waiting ${backoffDelay}ms before retry...`);
405
+ }
406
+ await new Promise(resolve => setTimeout(() => resolve(), backoffDelay));
407
+ }
408
+ }
409
+
410
+ // This should never be reached, but just in case
411
+ return {
412
+ isValid: false,
413
+ error: 'All retry attempts exhausted',
414
+ keyType: keyType
415
+ };
416
+ } catch (error) {
417
+ const errorMessage = `API key validation error: ${error.message}`;
418
+ console.error('❌ API key validation error:', error);
419
+ return {
420
+ isValid: false,
421
+ error: errorMessage,
422
+ keyType: ApiKeyType.INVALID
423
+ };
424
+ }
425
+ };
426
+
427
+ /**
428
+ * Get the current API configuration
429
+ * @returns Current API configuration or null if not initialized
430
+ */
431
+ exports.validateApiKey = validateApiKey;
432
+ const getApiConfig = () => {
433
+ return globalConfig;
434
+ };
435
+
436
+ /**
437
+ * Get the current API key
438
+ * @returns Current API key or null if not initialized
439
+ */
440
+ exports.getApiConfig = getApiConfig;
441
+ const getApiKey = () => {
442
+ var _globalConfig9;
443
+ return ((_globalConfig9 = globalConfig) === null || _globalConfig9 === void 0 ? void 0 : _globalConfig9.apiKey) || null;
444
+ };
445
+
446
+ /**
447
+ * Check if the SDK is properly initialized
448
+ * @returns True if initialized with valid API key
449
+ */
450
+ exports.getApiKey = getApiKey;
451
+ const isApiKeyInitialized = () => {
452
+ return isInitialized && globalConfig !== null;
453
+ };
454
+
455
+ /**
456
+ * Store JWT token securely after email verification
457
+ * @param token JWT token from email verification response
458
+ */
459
+ exports.isApiKeyInitialized = isApiKeyInitialized;
460
+ const storeJWT = async token => {
461
+ try {
462
+ var _globalConfig0;
463
+ await _asyncStorage.default.setItem(JWT_TOKEN_KEY, token);
464
+ userToken = token;
465
+ if ((_globalConfig0 = globalConfig) !== null && _globalConfig0 !== void 0 && _globalConfig0.enableLogging) {
466
+ console.log('🎫 JWT token stored successfully');
467
+ }
468
+ } catch (error) {
469
+ console.error('❌ Failed to store JWT token:', error);
470
+ throw error;
471
+ }
472
+ };
473
+
474
+ /**
475
+ * Load JWT token from storage
476
+ * @returns JWT token or null if not found
477
+ */
478
+ exports.storeJWT = storeJWT;
479
+ const loadJWT = async () => {
480
+ try {
481
+ const token = await _asyncStorage.default.getItem(JWT_TOKEN_KEY);
482
+ userToken = token;
483
+ return token;
484
+ } catch (error) {
485
+ console.error('❌ Failed to load JWT token:', error);
486
+ return null;
487
+ }
488
+ };
489
+
490
+ /**
491
+ * Get current JWT token
492
+ * @returns JWT token or null if not available
493
+ */
494
+ exports.loadJWT = loadJWT;
495
+ const getJWT = () => {
496
+ return userToken;
497
+ };
498
+
499
+ /**
500
+ * Clear JWT token (on logout or token expiration)
501
+ */
502
+ exports.getJWT = getJWT;
503
+ const clearJWT = async () => {
504
+ try {
505
+ var _globalConfig1;
506
+ await _asyncStorage.default.removeItem(JWT_TOKEN_KEY);
507
+ userToken = null;
508
+ if ((_globalConfig1 = globalConfig) !== null && _globalConfig1 !== void 0 && _globalConfig1.enableLogging) {
509
+ console.log('🗑️ JWT token cleared');
510
+ }
511
+ } catch (error) {
512
+ console.error('❌ Failed to clear JWT token:', error);
513
+ }
514
+ };
515
+
516
+ /**
517
+ * React Native compatible base64 decoder
518
+ * @param str Base64 encoded string
519
+ * @returns Decoded string
520
+ */
521
+ exports.clearJWT = clearJWT;
522
+ const base64Decode = str => {
523
+ // Simple base64 decoding for React Native
524
+ const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
525
+ let result = '';
526
+ let i = 0;
527
+ str = str.replace(/[^A-Za-z0-9+/]/g, '');
528
+ while (i < str.length) {
529
+ const a = chars.indexOf(str.charAt(i++));
530
+ const b = chars.indexOf(str.charAt(i++));
531
+ const c = chars.indexOf(str.charAt(i++));
532
+ const d = chars.indexOf(str.charAt(i++));
533
+ const bitmap = a << 18 | b << 12 | c << 6 | d;
534
+ result += String.fromCharCode(bitmap >> 16 & 255);
535
+ if (c !== 64) result += String.fromCharCode(bitmap >> 8 & 255);
536
+ if (d !== 64) result += String.fromCharCode(bitmap & 255);
537
+ }
538
+ return result;
539
+ };
540
+
541
+ /**
542
+ * Decode JWT token payload (React Native compatible)
543
+ * @param token JWT token string
544
+ * @returns Decoded payload or null if invalid
545
+ */
546
+ const decodeJWTPayload = token => {
547
+ try {
548
+ // Split JWT token (header.payload.signature)
549
+ const parts = token.split('.');
550
+ if (parts.length !== 3) {
551
+ console.error('❌ Invalid JWT token format');
552
+ return null;
553
+ }
554
+
555
+ // Decode payload (base64url to base64)
556
+ const payload = parts[1];
557
+ const base64 = payload.replace(/-/g, '+').replace(/_/g, '/');
558
+
559
+ // Add padding if needed
560
+ const padded = base64.padEnd(Math.ceil(base64.length / 4) * 4, '=');
561
+
562
+ // Decode base64 to JSON using React Native compatible decoder
563
+ const decoded = base64Decode(padded);
564
+ return JSON.parse(decoded);
565
+ } catch (error) {
566
+ console.error('❌ Failed to decode JWT token:', error);
567
+ return null;
568
+ }
569
+ };
570
+
571
+ /**
572
+ * Extract username from JWT token
573
+ * @param token JWT token (optional, uses stored token if not provided)
574
+ * @returns Username or null if not found
575
+ */
576
+ exports.decodeJWTPayload = decodeJWTPayload;
577
+ const extractUsernameFromJWT = token => {
578
+ try {
579
+ var _globalConfig10;
580
+ const jwtToken = token || userToken;
581
+ if (!jwtToken) {
582
+ console.warn('⚠️ No JWT token available for username extraction');
583
+ return null;
584
+ }
585
+ const payload = decodeJWTPayload(jwtToken);
586
+ if (!payload) {
587
+ return null;
588
+ }
589
+
590
+ // Try different possible username fields in order of preference
591
+ const username = payload.userName || payload.username || payload.userId || payload.email;
592
+ if ((_globalConfig10 = globalConfig) !== null && _globalConfig10 !== void 0 && _globalConfig10.enableLogging) {
593
+ console.log('👤 Extracted username from JWT:', username);
594
+ }
595
+ return username || null;
596
+ } catch (error) {
597
+ console.error('❌ Failed to extract username from JWT:', error);
598
+ return null;
599
+ }
600
+ };
601
+
602
+ /**
603
+ * Extract user data from JWT token
604
+ * @param token JWT token (optional, uses stored token if not provided)
605
+ * @returns User data object or null if not found
606
+ */
607
+ exports.extractUsernameFromJWT = extractUsernameFromJWT;
608
+ const extractUserDataFromJWT = token => {
609
+ try {
610
+ var _globalConfig11;
611
+ const jwtToken = token || userToken;
612
+ if (!jwtToken) {
613
+ console.warn('⚠️ No JWT token available for user data extraction');
614
+ return null;
615
+ }
616
+ const payload = decodeJWTPayload(jwtToken);
617
+ if (!payload) {
618
+ return null;
619
+ }
620
+ const userData = {
621
+ id: payload.id,
622
+ email: payload.email,
623
+ userId: payload.userId,
624
+ userName: payload.userName || payload.username,
625
+ verified: payload.verified,
626
+ iat: payload.iat,
627
+ exp: payload.exp
628
+ };
629
+ if ((_globalConfig11 = globalConfig) !== null && _globalConfig11 !== void 0 && _globalConfig11.enableLogging) {
630
+ console.log('👤 Extracted user data from JWT:', userData);
631
+ }
632
+ return userData;
633
+ } catch (error) {
634
+ console.error('❌ Failed to extract user data from JWT:', error);
635
+ return null;
636
+ }
637
+ };
638
+
639
+ /**
640
+ * Check if user is authenticated with JWT token
641
+ * @returns True if user has valid JWT token
642
+ */
643
+ exports.extractUserDataFromJWT = extractUserDataFromJWT;
644
+ const isUserAuthenticated = () => {
645
+ return !!userToken;
646
+ };
647
+
648
+ /**
649
+ * Get authenticated headers for API requests
650
+ * @returns Headers object with Authorization and other required headers
651
+ */
652
+ exports.isUserAuthenticated = isUserAuthenticated;
653
+ const getAuthHeaders = () => {
654
+ var _globalConfig12;
655
+ if (!((_globalConfig12 = globalConfig) !== null && _globalConfig12 !== void 0 && _globalConfig12.apiKey)) {
656
+ throw new Error('SDK not initialized. Call initializeApiKey() first.');
657
+ }
658
+ const keyType = getApiKeyType(globalConfig.apiKey);
659
+ return {
660
+ 'Content-Type': 'application/json',
661
+ 'Authorization': `Bearer ${globalConfig.apiKey}`,
662
+ 'User-Agent': 'OnairosReactNative/3.0.72',
663
+ 'X-SDK-Version': '3.0.72',
664
+ 'X-SDK-Environment': globalConfig.environment || 'production',
665
+ 'X-API-Key-Type': keyType,
666
+ 'X-Timestamp': new Date().toISOString()
667
+ };
668
+ };
669
+
670
+ /**
671
+ * Get authentication headers for developer API requests
672
+ * @returns Headers with developer API key
673
+ */
674
+ exports.getAuthHeaders = getAuthHeaders;
675
+ const getDeveloperAuthHeaders = () => {
676
+ var _globalConfig13;
677
+ if (!((_globalConfig13 = globalConfig) !== null && _globalConfig13 !== void 0 && _globalConfig13.apiKey)) {
678
+ throw new Error('SDK not initialized. Call initializeApiKey() first.');
679
+ }
680
+ const keyType = getApiKeyType(globalConfig.apiKey);
681
+ return {
682
+ 'Content-Type': 'application/json',
683
+ 'Authorization': `Bearer ${globalConfig.apiKey}`,
684
+ 'User-Agent': 'OnairosSDK/1.0.0',
685
+ 'X-SDK-Version': '3.0.72',
686
+ 'X-SDK-Environment': globalConfig.environment || 'production',
687
+ 'X-API-Key-Type': keyType,
688
+ 'X-Timestamp': new Date().toISOString()
689
+ };
690
+ };
691
+
692
+ /**
693
+ * Get authentication headers for user JWT requests
694
+ * @returns Headers with user JWT token
695
+ */
696
+ exports.getDeveloperAuthHeaders = getDeveloperAuthHeaders;
697
+ const getUserAuthHeaders = () => {
698
+ var _globalConfig14;
699
+ if (!userToken) {
700
+ throw new Error('User not authenticated. Please verify email first.');
701
+ }
702
+ return {
703
+ 'Content-Type': 'application/json',
704
+ 'Authorization': `Bearer ${userToken}`,
705
+ 'User-Agent': 'OnairosSDK/1.0.0',
706
+ 'X-SDK-Version': '3.0.72',
707
+ 'X-SDK-Environment': ((_globalConfig14 = globalConfig) === null || _globalConfig14 === void 0 ? void 0 : _globalConfig14.environment) || 'production'
708
+ };
709
+ };
710
+
711
+ /**
712
+ * Make an authenticated API request
713
+ * @param endpoint The API endpoint (relative to base URL)
714
+ * @param options Fetch options
715
+ * @returns Response promise
716
+ */
717
+ exports.getUserAuthHeaders = getUserAuthHeaders;
718
+ const makeAuthenticatedRequest = async (endpoint, options = {}) => {
719
+ if (!isApiKeyInitialized()) {
720
+ throw new Error('SDK not initialized. Call initializeApiKey() first.');
721
+ }
722
+ const config = getApiConfig();
723
+ const baseUrl = API_ENDPOINTS[config.environment || 'production'];
724
+ const url = `${baseUrl}${endpoint.startsWith('/') ? '' : '/'}${endpoint}`;
725
+
726
+ // Merge authentication headers
727
+ const headers = {
728
+ ...getAuthHeaders(),
729
+ ...(options.headers || {})
730
+ };
731
+
732
+ // Add timeout
733
+ const controller = new AbortController();
734
+ const timeoutId = setTimeout(() => controller.abort(), config.timeout || 30000);
735
+ try {
736
+ if (config.enableLogging) {
737
+ console.log(`🌐 Making authenticated request to: ${endpoint}`);
738
+ }
739
+ const response = await fetch(url, {
740
+ ...options,
741
+ headers,
742
+ signal: controller.signal
743
+ });
744
+ clearTimeout(timeoutId);
745
+ if (config.enableLogging) {
746
+ console.log(`📡 Response status: ${response.status} for ${endpoint}`);
747
+ }
748
+
749
+ // Handle API key errors
750
+ if (response.status === 401) {
751
+ console.error('❌ API key authentication failed. Please check your API key.');
752
+ throw new Error('Invalid or expired API key');
753
+ }
754
+ if (response.status === 403) {
755
+ console.error('❌ API key permissions insufficient for this operation.');
756
+ throw new Error('Insufficient API key permissions');
757
+ }
758
+ if (response.status === 429) {
759
+ console.error('❌ API rate limit exceeded. Please try again later.');
760
+ throw new Error('Rate limit exceeded');
761
+ }
762
+ return response;
763
+ } catch (error) {
764
+ clearTimeout(timeoutId);
765
+ if (error.name === 'AbortError') {
766
+ console.error('⏱️ Request timeout for:', endpoint);
767
+ throw new Error('Request timeout');
768
+ }
769
+ throw error;
770
+ }
771
+ };
772
+
773
+ /**
774
+ * Make authenticated request with developer API key
775
+ * @param endpoint The API endpoint
776
+ * @param options Fetch options
777
+ * @returns Response promise
778
+ */
779
+ exports.makeAuthenticatedRequest = makeAuthenticatedRequest;
780
+ const makeDeveloperRequest = async (endpoint, options = {}) => {
781
+ if (!isApiKeyInitialized()) {
782
+ throw new Error('SDK not initialized. Call initializeApiKey() first.');
783
+ }
784
+ const config = getApiConfig();
785
+ const baseUrl = API_ENDPOINTS[config.environment || 'production'];
786
+ const url = `${baseUrl}${endpoint.startsWith('/') ? '' : '/'}${endpoint}`;
787
+
788
+ // Merge developer authentication headers
789
+ const headers = {
790
+ ...getDeveloperAuthHeaders(),
791
+ ...(options.headers || {})
792
+ };
793
+
794
+ // Add timeout
795
+ const controller = new AbortController();
796
+ const timeoutId = setTimeout(() => controller.abort(), config.timeout || 30000);
797
+ try {
798
+ if (config.enableLogging) {
799
+ console.log(`🌐 Making developer request to: ${endpoint}`);
800
+ }
801
+ const response = await fetch(url, {
802
+ ...options,
803
+ headers,
804
+ signal: controller.signal
805
+ });
806
+ clearTimeout(timeoutId);
807
+ if (config.enableLogging) {
808
+ console.log(`📡 Developer request response: ${response.status} for ${endpoint}`);
809
+ }
810
+
811
+ // Handle API key errors
812
+ if (response.status === 401) {
813
+ console.error('❌ Developer API key authentication failed');
814
+ throw new Error('Invalid or expired API key');
815
+ }
816
+ if (response.status === 403) {
817
+ console.error('❌ Developer API key permissions insufficient');
818
+ throw new Error('Insufficient API key permissions');
819
+ }
820
+ if (response.status === 429) {
821
+ console.error('❌ API rate limit exceeded');
822
+ throw new Error('Rate limit exceeded');
823
+ }
824
+ return response;
825
+ } catch (error) {
826
+ clearTimeout(timeoutId);
827
+ if (error.name === 'AbortError') {
828
+ console.error('⏱️ Request timeout for:', endpoint);
829
+ throw new Error('Request timeout');
830
+ }
831
+ throw error;
832
+ }
833
+ };
834
+
835
+ /**
836
+ * Make authenticated request with user JWT token
837
+ * @param endpoint The API endpoint
838
+ * @param options Fetch options
839
+ * @returns Response promise
840
+ */
841
+ exports.makeDeveloperRequest = makeDeveloperRequest;
842
+ const makeUserRequest = async (endpoint, options = {}) => {
843
+ if (!isUserAuthenticated()) {
844
+ await loadJWT(); // Try to load from storage
845
+ }
846
+ if (!isUserAuthenticated()) {
847
+ throw new Error('User not authenticated. Please verify email first.');
848
+ }
849
+ const config = getApiConfig() || {
850
+ environment: 'production',
851
+ timeout: 30000,
852
+ enableLogging: false
853
+ };
854
+ const baseUrl = API_ENDPOINTS[config.environment || 'production'];
855
+ const url = `${baseUrl}${endpoint.startsWith('/') ? '' : '/'}${endpoint}`;
856
+
857
+ // Merge user authentication headers
858
+ const headers = {
859
+ ...getUserAuthHeaders(),
860
+ ...(options.headers || {})
861
+ };
862
+
863
+ // Add timeout
864
+ const controller = new AbortController();
865
+ const timeoutId = setTimeout(() => controller.abort(), config.timeout || 30000);
866
+ try {
867
+ if (config.enableLogging) {
868
+ console.log(`🌐 Making user request to: ${endpoint}`);
869
+ }
870
+ const response = await fetch(url, {
871
+ ...options,
872
+ headers,
873
+ signal: controller.signal
874
+ });
875
+ clearTimeout(timeoutId);
876
+ if (config.enableLogging) {
877
+ console.log(`📡 User request response: ${response.status} for ${endpoint}`);
878
+ }
879
+
880
+ // Handle JWT token errors
881
+ if (response.status === 401) {
882
+ console.error('❌ JWT token authentication failed - token may be expired');
883
+ await clearJWT(); // Clear expired token
884
+ throw new Error('Authentication expired. Please verify email again.');
885
+ }
886
+ if (response.status === 403) {
887
+ console.error('❌ JWT token permissions insufficient');
888
+ throw new Error('Insufficient permissions for this operation');
889
+ }
890
+ return response;
891
+ } catch (error) {
892
+ clearTimeout(timeoutId);
893
+ if (error.name === 'AbortError') {
894
+ console.error('⏱️ Request timeout for:', endpoint);
895
+ throw new Error('Request timeout');
896
+ }
897
+ throw error;
898
+ }
899
+ };
900
+
901
+ /**
902
+ * Clear the API key validation cache
903
+ */
904
+ exports.makeUserRequest = makeUserRequest;
905
+ const clearValidationCache = () => {
906
+ var _globalConfig15;
907
+ validationCache.clear();
908
+ if ((_globalConfig15 = globalConfig) !== null && _globalConfig15 !== void 0 && _globalConfig15.enableLogging) {
909
+ console.log('🗑️ API key validation cache cleared');
910
+ }
911
+ };
912
+
913
+ /**
914
+ * Reset the SDK initialization state
915
+ */
916
+ exports.clearValidationCache = clearValidationCache;
917
+ const resetApiKeyService = () => {
918
+ globalConfig = null;
919
+ isInitialized = false;
920
+ clearValidationCache();
921
+ console.log('🔄 API key service reset');
922
+ };
923
+ exports.resetApiKeyService = resetApiKeyService;
924
+ //# sourceMappingURL=apiKeyService.js.map