@onairos/react-native 3.7.1 → 3.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. package/lib/commonjs/api/index.js +219 -9
  2. package/lib/commonjs/assets/icons/spotify.png +0 -0
  3. package/lib/commonjs/assets/images/spotify.png +0 -0
  4. package/lib/commonjs/components/BodyText.js +27 -9
  5. package/lib/commonjs/components/BrandMark.js +111 -10
  6. package/lib/commonjs/components/CodeInput.js +116 -9
  7. package/lib/commonjs/components/EmailInput.js +30 -8
  8. package/lib/commonjs/components/GoogleButton.js +56 -9
  9. package/lib/commonjs/components/HeadingGroup.js +43 -9
  10. package/lib/commonjs/components/LLMDataInputModal.js +664 -14
  11. package/lib/commonjs/components/ModalHeader.js +99 -9
  12. package/lib/commonjs/components/ModalSheet.js +47 -9
  13. package/lib/commonjs/components/Onairos.js +380 -14
  14. package/lib/commonjs/components/OnairosButton.js +313 -13
  15. package/lib/commonjs/components/OnairosSignInButton.js +130 -12
  16. package/lib/commonjs/components/Overlay.js +465 -13
  17. package/lib/commonjs/components/PersonaImage.js +137 -10
  18. package/lib/commonjs/components/PersonaLoadingScreen.js +318 -12
  19. package/lib/commonjs/components/PersonalizationConsentScreen.js +467 -13
  20. package/lib/commonjs/components/PinCreationScreen.js +403 -12
  21. package/lib/commonjs/components/PinInput.js +464 -9
  22. package/lib/commonjs/components/PlatformConnectorsStep.js +1311 -23
  23. package/lib/commonjs/components/PlatformList.js +137 -10
  24. package/lib/commonjs/components/PlatformToggle.js +180 -9
  25. package/lib/commonjs/components/PrimaryButton.js +180 -10
  26. package/lib/commonjs/components/SignInMatchAnimation.js +197 -9
  27. package/lib/commonjs/components/SignInStep.js +345 -12
  28. package/lib/commonjs/components/UniversalOnboarding.js +2780 -30
  29. package/lib/commonjs/components/VerificationStep.js +176 -11
  30. package/lib/commonjs/components/WelcomeScreen.js +461 -22
  31. package/lib/commonjs/components/icons/Basicproficon.js +37 -8
  32. package/lib/commonjs/components/icons/Basicprofile.js +21 -8
  33. package/lib/commonjs/components/icons/Checkbox.js +21 -8
  34. package/lib/commonjs/components/icons/Checkmark.js +27 -8
  35. package/lib/commonjs/components/icons/Contentanalysis.js +21 -8
  36. package/lib/commonjs/components/icons/Contenticon.js +39 -8
  37. package/lib/commonjs/components/icons/EnochE.js +41 -8
  38. package/lib/commonjs/components/icons/Personalityicon.js +30 -8
  39. package/lib/commonjs/components/icons/Personalityprofile.js +21 -8
  40. package/lib/commonjs/components/icons/Personalitytraits.js +21 -8
  41. package/lib/commonjs/components/icons/Userpreferences.js +21 -8
  42. package/lib/commonjs/components/icons/index.js +84 -17
  43. package/lib/commonjs/components/onboarding/OAuthWebView.js +1754 -18
  44. package/lib/commonjs/components/onboarding/OnboardingHeader.js +74 -10
  45. package/lib/commonjs/components/onboarding/PinInput.js +283 -10
  46. package/lib/commonjs/components/onboarding/PlatformConnector.js +249 -11
  47. package/lib/commonjs/config/PLATFORM_APIS.md +849 -0
  48. package/lib/commonjs/config/api.js +56 -7
  49. package/lib/commonjs/constants/index.js +120 -7
  50. package/lib/commonjs/context/AuthContext.js +345 -10
  51. package/lib/commonjs/hooks/useConnectedAccounts.js +111 -9
  52. package/lib/commonjs/hooks/useConnections.js +102 -8
  53. package/lib/commonjs/hooks/useCredentials.js +178 -10
  54. package/lib/commonjs/hooks/useUserConnections.js +148 -10
  55. package/lib/commonjs/index.js +439 -34
  56. package/lib/commonjs/services/apiClient.js +298 -8
  57. package/lib/commonjs/services/biometricPinService.js +180 -8
  58. package/lib/commonjs/services/chatGPTConversationExtractor.js +155 -8
  59. package/lib/commonjs/services/chatGPTConversationService.js +275 -9
  60. package/lib/commonjs/services/claudeConversationExtractor.js +103 -8
  61. package/lib/commonjs/services/claudeConversationService.js +158 -9
  62. package/lib/commonjs/services/connectedAccountsService.js +310 -10
  63. package/lib/commonjs/services/googleAuthService.js +252 -11
  64. package/lib/commonjs/services/hingeDataExtractor.js +105 -8
  65. package/lib/commonjs/services/hingeDataService.js +150 -9
  66. package/lib/commonjs/services/imageCompressionService.js +260 -7
  67. package/lib/commonjs/services/instagramDataExtractor.js +126 -8
  68. package/lib/commonjs/services/instagramDataService.js +163 -9
  69. package/lib/commonjs/services/jwtStorageService.js +276 -7
  70. package/lib/commonjs/services/linkedinDOMExtractor.js +245 -7
  71. package/lib/commonjs/services/linkedinProfileService.js +222 -9
  72. package/lib/commonjs/services/linkedinScrapingService.js +230 -8
  73. package/lib/commonjs/services/llmDataStorage.js +294 -8
  74. package/lib/commonjs/services/mobileTrainingService.js +186 -8
  75. package/lib/commonjs/services/netflixDataExtractor.js +120 -8
  76. package/lib/commonjs/services/netflixDataService.js +198 -9
  77. package/lib/commonjs/services/pinEncryptionService.js +84 -8
  78. package/lib/commonjs/services/pinStorageUtils.js +105 -7
  79. package/lib/commonjs/services/platformAuthService.js +1484 -12
  80. package/lib/commonjs/services/sephoraDataExtractor.js +140 -8
  81. package/lib/commonjs/services/sephoraDataService.js +200 -9
  82. package/lib/commonjs/services/spotifyDataExtractor.js +148 -8
  83. package/lib/commonjs/services/spotifyDataService.js +241 -9
  84. package/lib/commonjs/services/storageService.js +404 -8
  85. package/lib/commonjs/services/telegramDataExtractor.js +115 -8
  86. package/lib/commonjs/services/telegramDataService.js +499 -9
  87. package/lib/commonjs/services/trainingApiHelpers.js +73 -7
  88. package/lib/commonjs/services/userConnectionsService.js +340 -10
  89. package/lib/commonjs/services/youtubeMigrationService.js +416 -10
  90. package/lib/commonjs/theme/index.js +250 -7
  91. package/lib/commonjs/types/ambient.d.js +2 -1
  92. package/lib/commonjs/types/declarations.d.js +2 -1
  93. package/lib/commonjs/types/index.js +6 -1
  94. package/lib/commonjs/types/node-fix.d.js +2 -1
  95. package/lib/commonjs/types/node-override.d.js +2 -1
  96. package/lib/commonjs/types/opacity.d.js +2 -1
  97. package/lib/commonjs/types.js +14 -1
  98. package/lib/commonjs/utils/Portal.js +98 -8
  99. package/lib/commonjs/utils/api.js +130 -9
  100. package/lib/commonjs/utils/assetRegistry.js +210 -35
  101. package/lib/commonjs/utils/auth.js +112 -9
  102. package/lib/commonjs/utils/connectorTests.js +613 -29
  103. package/lib/commonjs/utils/crypto.js +62 -8
  104. package/lib/commonjs/utils/debugHelper.js +64 -1
  105. package/lib/commonjs/utils/encryption.js +76 -7
  106. package/lib/commonjs/utils/eventUtils.js +288 -1
  107. package/lib/commonjs/utils/haptics.js +66 -9
  108. package/lib/commonjs/utils/imagePreloader.js +6 -1
  109. package/lib/commonjs/utils/networkDiagnostics.js +226 -8
  110. package/lib/commonjs/utils/onairosApi.js +350 -9
  111. package/lib/commonjs/utils/programmaticFlow.js +117 -9
  112. package/lib/commonjs/utils/retryHelper.js +220 -1
  113. package/lib/commonjs/utils/secureStorage.js +349 -10
  114. package/lib/commonjs/utils/webviewScripts/chatgpt.js +551 -1
  115. package/lib/commonjs/utils/webviewScripts/claude.js +376 -1
  116. package/lib/commonjs/utils/webviewScripts/hinge.js +411 -1
  117. package/lib/commonjs/utils/webviewScripts/index.js +698 -15
  118. package/lib/commonjs/utils/webviewScripts/instagram.js +454 -1
  119. package/lib/commonjs/utils/webviewScripts/linkedin.js +880 -1
  120. package/lib/commonjs/utils/webviewScripts/netflix.js +382 -1
  121. package/lib/commonjs/utils/webviewScripts/sephora.js +516 -1
  122. package/lib/commonjs/utils/webviewScripts/spotify.js +419 -1
  123. package/lib/commonjs/utils/webviewScripts/telegram.js +678 -1
  124. package/lib/module/api/index.js +211 -1
  125. package/lib/module/assets/icons/spotify.png +0 -0
  126. package/lib/module/assets/images/spotify.png +0 -0
  127. package/lib/module/components/BodyText.js +20 -1
  128. package/lib/module/components/BrandMark.js +104 -1
  129. package/lib/module/components/CodeInput.js +109 -1
  130. package/lib/module/components/EmailInput.js +23 -1
  131. package/lib/module/components/GoogleButton.js +49 -1
  132. package/lib/module/components/HeadingGroup.js +36 -1
  133. package/lib/module/components/LLMDataInputModal.js +656 -7
  134. package/lib/module/components/ModalHeader.js +92 -1
  135. package/lib/module/components/ModalSheet.js +39 -1
  136. package/lib/module/components/Onairos.js +373 -1
  137. package/lib/module/components/OnairosButton.js +305 -1
  138. package/lib/module/components/OnairosSignInButton.js +121 -1
  139. package/lib/module/components/Overlay.js +456 -1
  140. package/lib/module/components/PersonaImage.js +129 -1
  141. package/lib/module/components/PersonaLoadingScreen.js +310 -1
  142. package/lib/module/components/PersonalizationConsentScreen.js +460 -1
  143. package/lib/module/components/PinCreationScreen.js +396 -1
  144. package/lib/module/components/PinInput.js +456 -1
  145. package/lib/module/components/PlatformConnectorsStep.js +1302 -6
  146. package/lib/module/components/PlatformList.js +129 -1
  147. package/lib/module/components/PlatformToggle.js +173 -1
  148. package/lib/module/components/PrimaryButton.js +172 -1
  149. package/lib/module/components/SignInMatchAnimation.js +189 -1
  150. package/lib/module/components/SignInStep.js +338 -1
  151. package/lib/module/components/UniversalOnboarding.js +2770 -1
  152. package/lib/module/components/VerificationStep.js +168 -1
  153. package/lib/module/components/WelcomeScreen.js +453 -1
  154. package/lib/module/components/icons/Basicproficon.js +30 -1
  155. package/lib/module/components/icons/Basicprofile.js +14 -1
  156. package/lib/module/components/icons/Checkbox.js +14 -1
  157. package/lib/module/components/icons/Checkmark.js +20 -1
  158. package/lib/module/components/icons/Contentanalysis.js +14 -1
  159. package/lib/module/components/icons/Contenticon.js +32 -1
  160. package/lib/module/components/icons/EnochE.js +34 -1
  161. package/lib/module/components/icons/Personalityicon.js +23 -1
  162. package/lib/module/components/icons/Personalityprofile.js +14 -1
  163. package/lib/module/components/icons/Personalitytraits.js +14 -1
  164. package/lib/module/components/icons/Userpreferences.js +14 -1
  165. package/lib/module/components/icons/index.js +13 -1
  166. package/lib/module/components/onboarding/OAuthWebView.js +1746 -1
  167. package/lib/module/components/onboarding/OnboardingHeader.js +66 -1
  168. package/lib/module/components/onboarding/PinInput.js +274 -1
  169. package/lib/module/components/onboarding/PlatformConnector.js +240 -1
  170. package/lib/module/config/PLATFORM_APIS.md +849 -0
  171. package/lib/module/config/api.js +47 -1
  172. package/lib/module/constants/index.js +114 -1
  173. package/lib/module/context/AuthContext.js +335 -1
  174. package/lib/module/hooks/useConnectedAccounts.js +106 -1
  175. package/lib/module/hooks/useConnections.js +95 -1
  176. package/lib/module/hooks/useCredentials.js +171 -6
  177. package/lib/module/hooks/useUserConnections.js +140 -1
  178. package/lib/module/index.js +172 -1
  179. package/lib/module/services/apiClient.js +295 -1
  180. package/lib/module/services/biometricPinService.js +169 -1
  181. package/lib/module/services/chatGPTConversationExtractor.js +149 -1
  182. package/lib/module/services/chatGPTConversationService.js +268 -1
  183. package/lib/module/services/claudeConversationExtractor.js +97 -1
  184. package/lib/module/services/claudeConversationService.js +151 -1
  185. package/lib/module/services/connectedAccountsService.js +293 -1
  186. package/lib/module/services/googleAuthService.js +241 -1
  187. package/lib/module/services/hingeDataExtractor.js +99 -1
  188. package/lib/module/services/hingeDataService.js +143 -1
  189. package/lib/module/services/imageCompressionService.js +250 -1
  190. package/lib/module/services/instagramDataExtractor.js +120 -1
  191. package/lib/module/services/instagramDataService.js +156 -1
  192. package/lib/module/services/jwtStorageService.js +257 -1
  193. package/lib/module/services/linkedinDOMExtractor.js +234 -1
  194. package/lib/module/services/linkedinProfileService.js +210 -1
  195. package/lib/module/services/linkedinScrapingService.js +219 -1
  196. package/lib/module/services/llmDataStorage.js +277 -1
  197. package/lib/module/services/mobileTrainingService.js +173 -1
  198. package/lib/module/services/netflixDataExtractor.js +114 -1
  199. package/lib/module/services/netflixDataService.js +191 -1
  200. package/lib/module/services/pinEncryptionService.js +74 -6
  201. package/lib/module/services/pinStorageUtils.js +93 -1
  202. package/lib/module/services/platformAuthService.js +1461 -1
  203. package/lib/module/services/sephoraDataExtractor.js +134 -1
  204. package/lib/module/services/sephoraDataService.js +193 -1
  205. package/lib/module/services/spotifyDataExtractor.js +142 -1
  206. package/lib/module/services/spotifyDataService.js +234 -1
  207. package/lib/module/services/storageService.js +383 -1
  208. package/lib/module/services/telegramDataExtractor.js +109 -1
  209. package/lib/module/services/telegramDataService.js +493 -1
  210. package/lib/module/services/trainingApiHelpers.js +67 -1
  211. package/lib/module/services/userConnectionsService.js +329 -1
  212. package/lib/module/services/youtubeMigrationService.js +405 -1
  213. package/lib/module/theme/index.js +245 -1
  214. package/lib/module/types.js +10 -1
  215. package/lib/module/utils/Portal.js +90 -1
  216. package/lib/module/utils/api.js +118 -1
  217. package/lib/module/utils/assetRegistry.js +200 -34
  218. package/lib/module/utils/auth.js +100 -1
  219. package/lib/module/utils/connectorTests.js +600 -27
  220. package/lib/module/utils/crypto.js +54 -1
  221. package/lib/module/utils/debugHelper.js +54 -1
  222. package/lib/module/utils/encryption.js +67 -1
  223. package/lib/module/utils/eventUtils.js +270 -1
  224. package/lib/module/utils/haptics.js +59 -8
  225. package/lib/module/utils/imagePreloader.js +3 -1
  226. package/lib/module/utils/networkDiagnostics.js +217 -1
  227. package/lib/module/utils/onairosApi.js +333 -1
  228. package/lib/module/utils/programmaticFlow.js +111 -1
  229. package/lib/module/utils/retryHelper.js +211 -1
  230. package/lib/module/utils/secureStorage.js +330 -6
  231. package/lib/module/utils/webviewScripts/chatgpt.js +545 -1
  232. package/lib/module/utils/webviewScripts/claude.js +370 -1
  233. package/lib/module/utils/webviewScripts/hinge.js +405 -1
  234. package/lib/module/utils/webviewScripts/index.js +434 -1
  235. package/lib/module/utils/webviewScripts/instagram.js +448 -1
  236. package/lib/module/utils/webviewScripts/linkedin.js +874 -1
  237. package/lib/module/utils/webviewScripts/netflix.js +376 -1
  238. package/lib/module/utils/webviewScripts/sephora.js +510 -1
  239. package/lib/module/utils/webviewScripts/spotify.js +413 -1
  240. package/lib/module/utils/webviewScripts/telegram.js +672 -1
  241. package/package.json +2 -2
@@ -1 +1,106 @@
1
- import{useState,useEffect,useCallback}from'react';function _0x12d5(){const _0x259bfb=['onNGw','yltiV','🔍\x20No\x20user\x20available\x20for\x20fetching\x20connected\x20accounts','🚀\x20[HOOK]\x20Starting\x20connected\x20accounts\x20fetch\x20with\x20new\x20smart\x20API...','ZKAKt','❌\x20[HOOK]\x20Error\x20fetching\x20connected\x20accounts:','Failed\x20to\x20load\x20connected\x20accounts','🔄\x20[HOOK]\x20Refreshing\x20connected\x20accounts...','✅\x20[HOOK]\x20Account\x20added\x20locally:','✅\x20[HOOK]\x20Account\x20removed\x20locally:','sPjyc','CuzHo','iVZHe','fBnuf','REVsT','rYIhQ','kmjFr','lFegA','LXKlz','zsFvG','log','PnsXX','IxCIf','stpsf','anlhJ','MLgJk','email','name','ixvmC','JauNh','uXQXM','some','platform','toLowerCase','error','VOqJP','Nggrz','CKEVu','iaOJr','https://','.com/','BoBVL','map','wgpJx','scZzO','filter','AracP','qgmqA','peEZI','PYotO'];_0x12d5=function(){return _0x259bfb;};return _0x12d5();}import{getConnectedAccountsSmart}from'../services/connectedAccountsService';function _0x484c(_0x12d580,_0x484caf){_0x12d580=_0x12d580-0x0;const _0x2f2c4d=_0x12d5();let _0x148401=_0x2f2c4d[_0x12d580];return _0x148401;}import{useAuth}from'../context/AuthContext';export const useConnectedAccounts=()=>{const _0x467c4e={'stpsf':function(_0x1ec05b,_0x30a678){return _0x1ec05b(_0x30a678);},'CuzHo':function(_0x1432d4){return _0x1432d4();},'lJcMd':function(_0x12f7a6,_0x49409b){return _0x12f7a6!==_0x49409b;},'kmjFr':_0x484c(0x0),'lFegA':'CluqD','LXKlz':function(_0xd1b4c,_0x2990a0){return _0xd1b4c===_0x2990a0;},'zsFvG':_0x484c(0x1),'PnsXX':_0x484c(0x2),'IxCIf':function(_0x5413a1,_0x5d4d2b){return _0x5413a1(_0x5d4d2b);},'anlhJ':_0x484c(0x3),'MLgJk':'🚀\x20[HOOK]\x20User\x20info\x20available:','ixvmC':function(_0x32150f,_0x393b54,_0x4e8a00,_0x57d858){return _0x32150f(_0x393b54,_0x4e8a00,_0x57d858);},'JauNh':function(_0x40d8fe,_0x579123){return _0x40d8fe(_0x579123);},'uXQXM':_0x484c(0x4),'VOqJP':_0x484c(0x5),'Nggrz':_0x484c(0x6),'CKEVu':_0x484c(0x7),'iaOJr':function(_0x5f011e){return _0x5f011e();},'PYotO':_0x484c(0x8),'scZzO':function(_0x2b86f,_0x4d6deb){return _0x2b86f(_0x4d6deb);},'AracP':_0x484c(0x9),'peEZI':'jRZVk','iFHxa':_0x484c(0xa),'iVZHe':function(_0x3cf6b2,_0xc6aef7){return _0x3cf6b2(_0xc6aef7);},'fBnuf':function(_0x36a242,_0x2d5a19){return _0x36a242(_0x2d5a19);},'REVsT':function(_0x44990e,_0x412014){return _0x44990e(_0x412014);},'rYIhQ':function(_0x4703e9,_0x44c698,_0x5b2eef){return _0x4703e9(_0x44c698,_0x5b2eef);},'wgpJx':function(_0x166b4e,_0x561946,_0x22db49){return _0x166b4e(_0x561946,_0x22db49);},'qgmqA':function(_0x3f528f,_0x377563,_0x417bd1){return _0x3f528f(_0x377563,_0x417bd1);}},{user:_0x1a5ec9}=_0x467c4e[_0x484c(0xb)](useAuth),[_0x244b6b,_0x5af53f]=_0x467c4e[_0x484c(0xc)](useState,[]),[_0x45d033,_0x10d0ec]=_0x467c4e[_0x484c(0xd)](useState,!![]),[_0x3d4670,_0x408f5b]=_0x467c4e[_0x484c(0xe)](useState,null),_0x502c80=_0x467c4e[_0x484c(0xf)](useCallback,async()=>{if(_0x467c4e['lJcMd'](_0x467c4e[_0x484c(0x10)],_0x467c4e[_0x484c(0x11)])){if(!_0x1a5ec9){if(_0x467c4e[_0x484c(0x12)](_0x467c4e[_0x484c(0x13)],_0x467c4e[_0x484c(0x13)])){console[_0x484c(0x14)](_0x467c4e[_0x484c(0x15)]),_0x467c4e[_0x484c(0x16)](_0x10d0ec,![]);return;}else{_0x1443f1['log']('🔍\x20No\x20user\x20available\x20for\x20fetching\x20connected\x20accounts'),_0x467c4e[_0x484c(0x17)](_0x56b335,![]);return;}}try{_0x467c4e[_0x484c(0x16)](_0x10d0ec,!![]),_0x408f5b(null),console[_0x484c(0x14)](_0x467c4e[_0x484c(0x18)]),console['log'](_0x467c4e[_0x484c(0x19)],{'email':_0x1a5ec9[_0x484c(0x1a)],'id':_0x1a5ec9['id'],'name':_0x1a5ec9[_0x484c(0x1b)]});const _0x5352bd=await _0x467c4e[_0x484c(0x1c)](getConnectedAccountsSmart,_0x1a5ec9[_0x484c(0x1a)],_0x1a5ec9['id'],_0x1a5ec9[_0x484c(0x1b)]);console['log']('✅\x20[HOOK]\x20Connected\x20accounts\x20loaded\x20via\x20smart\x20API:\x20'+_0x5352bd['length']+'\x20accounts'),_0x467c4e[_0x484c(0x1d)](_0x5af53f,_0x5352bd);}catch(_0x1792a2){if(_0x467c4e[_0x484c(0x1e)]!=='ZKAKt'){const _0x598001=_0x29ce93[_0x484c(0x1f)](_0x5a7558=>_0x5a7558[_0x484c(0x20)][_0x484c(0x21)]()===_0x41c5eb[_0x484c(0x21)]());return _0x598001?_0x2b8411['map'](_0xbbe62a=>_0xbbe62a[_0x484c(0x20)]['toLowerCase']()===_0x419d75[_0x484c(0x21)]()?_0x191e84:_0xbbe62a):[..._0x4f8f85,_0x1e32ac];}else console[_0x484c(0x22)](_0x467c4e[_0x484c(0x23)],_0x1792a2),_0x467c4e['IxCIf'](_0x408f5b,_0x467c4e[_0x484c(0x24)]);}finally{_0x10d0ec(![]);}}else _0x467c4e[_0x484c(0xb)](_0x46e013);},[_0x1a5ec9]),_0x3f0c9f=useCallback(async()=>{console[_0x484c(0x14)](_0x467c4e[_0x484c(0x25)]),await _0x467c4e[_0x484c(0x26)](_0x502c80);},[_0x502c80]),_0x1888a2=useCallback((_0x17e008,_0x6ca177)=>{const _0x464d50={'IUtaj':function(_0x373172,_0x551d3c){return _0x373172!==_0x551d3c;}},_0x3a361b=_0x484c(0x27)+_0x17e008[_0x484c(0x21)]()+_0x484c(0x28)+_0x6ca177,_0x7a91f1={'platform':_0x17e008,'username':_0x6ca177,'url':_0x3a361b};_0x5af53f(_0x3e2bf1=>{const _0xd9ac19=_0x3e2bf1['some'](_0x116297=>_0x116297[_0x484c(0x20)]['toLowerCase']()===_0x17e008[_0x484c(0x21)]());return _0xd9ac19?_0x3e2bf1['map'](_0x9981ce=>_0x9981ce[_0x484c(0x20)][_0x484c(0x21)]()===_0x17e008[_0x484c(0x21)]()?_0x7a91f1:_0x9981ce):_0x464d50['IUtaj'](_0x484c(0x29),'yYJPA')?[..._0x3e2bf1,_0x7a91f1]:_0x4b85e7[_0x484c(0x2a)](_0x2b8f9e=>_0x2b8f9e[_0x484c(0x20)][_0x484c(0x21)]()===_0x1a6e59[_0x484c(0x21)]()?_0x176f7b:_0x2b8f9e);}),console['log'](_0x467c4e['PYotO'],_0x7a91f1);},[]),_0x434d90=_0x467c4e[_0x484c(0x2b)](useCallback,_0x3e7222=>{_0x467c4e[_0x484c(0x2c)](_0x5af53f,_0x3d426a=>_0x3d426a[_0x484c(0x2d)](_0x1314e1=>_0x1314e1['platform'][_0x484c(0x21)]()!==_0x3e7222[_0x484c(0x21)]())),console[_0x484c(0x14)](_0x467c4e[_0x484c(0x2e)],_0x3e7222);},[]);return _0x467c4e[_0x484c(0x2f)](useEffect,()=>{if(_0x467c4e['LXKlz'](_0x467c4e[_0x484c(0x30)],_0x467c4e['iFHxa'])){const _0x14d27e=_0x484c(0x27)+_0x3e923c[_0x484c(0x21)]()+_0x484c(0x28)+_0x17d30e,_0x2e9400={'platform':_0xe093b8,'username':_0x3ec34c,'url':_0x14d27e};_0x14f265(_0x23702e=>{const _0x40ea07=_0x23702e[_0x484c(0x1f)](_0x26a2fc=>_0x26a2fc[_0x484c(0x20)]['toLowerCase']()===_0x485b22[_0x484c(0x21)]());return _0x40ea07?_0x23702e['map'](_0xad494b=>_0xad494b[_0x484c(0x20)][_0x484c(0x21)]()===_0x2f0c34[_0x484c(0x21)]()?_0x2e9400:_0xad494b):[..._0x23702e,_0x2e9400];}),_0x3d4f3a[_0x484c(0x14)](_0x467c4e[_0x484c(0x31)],_0x2e9400);}else _0x502c80();},[_0x502c80]),{'connectedAccounts':_0x244b6b,'isLoading':_0x45d033,'error':_0x3d4670,'refreshAccounts':_0x3f0c9f,'addAccount':_0x1888a2,'removeAccount':_0x434d90};};
1
+ import { useState, useEffect, useCallback } from 'react';
2
+ import { getConnectedAccountsSmart
3
+ // Keep legacy imports for any edge cases
4
+ } from '../services/connectedAccountsService';
5
+ import { useAuth } from '../context/AuthContext';
6
+ export const useConnectedAccounts = () => {
7
+ const {
8
+ user
9
+ } = useAuth();
10
+ const [connectedAccounts, setConnectedAccounts] = useState([]);
11
+ const [isLoading, setIsLoading] = useState(true);
12
+ const [error, setError] = useState(null);
13
+ const fetchConnectedAccounts = useCallback(async () => {
14
+ if (!user) {
15
+ console.log('🔍 No user available for fetching connected accounts');
16
+ setIsLoading(false);
17
+ return;
18
+ }
19
+ try {
20
+ setIsLoading(true);
21
+ setError(null);
22
+ console.log('🚀 [HOOK] Starting connected accounts fetch with new smart API...');
23
+ console.log('🚀 [HOOK] User info available:', {
24
+ email: user.email,
25
+ id: user.id,
26
+ name: user.name
27
+ });
28
+
29
+ // Use the new smart API function - makes only ONE request with intelligent fallbacks
30
+ const accounts = await getConnectedAccountsSmart(user.email,
31
+ // Primary identifier (email)
32
+ user.id,
33
+ // Secondary identifier (user ID)
34
+ user.name // Tertiary identifier (username)
35
+ );
36
+ console.log(`✅ [HOOK] Connected accounts loaded via smart API: ${accounts.length} accounts`);
37
+ setConnectedAccounts(accounts);
38
+ } catch (err) {
39
+ console.error('❌ [HOOK] Error fetching connected accounts:', err);
40
+ setError('Failed to load connected accounts');
41
+ } finally {
42
+ setIsLoading(false);
43
+ }
44
+ }, [user]);
45
+ const refreshAccounts = useCallback(async () => {
46
+ console.log('🔄 [HOOK] Refreshing connected accounts...');
47
+ await fetchConnectedAccounts();
48
+ }, [fetchConnectedAccounts]);
49
+ const addAccount = useCallback((platform, username) => {
50
+ // Create a temporary URL for the account
51
+ const tempUrl = `https://${platform.toLowerCase()}.com/${username}`;
52
+ const newAccount = {
53
+ platform,
54
+ username,
55
+ url: tempUrl
56
+ };
57
+ setConnectedAccounts(prev => {
58
+ // Check if account already exists
59
+ const exists = prev.some(acc => acc.platform.toLowerCase() === platform.toLowerCase());
60
+ if (exists) {
61
+ // Update existing account
62
+ return prev.map(acc => acc.platform.toLowerCase() === platform.toLowerCase() ? newAccount : acc);
63
+ } else {
64
+ // Add new account
65
+ return [...prev, newAccount];
66
+ }
67
+ });
68
+ console.log('✅ [HOOK] Account added locally:', newAccount);
69
+
70
+ // TODO: In a real implementation, you would also send this to your backend
71
+ // Example:
72
+ // try {
73
+ // await saveConnectedAccount(user.id, platform, username);
74
+ // } catch (error) {
75
+ // console.error('Failed to save account to backend:', error);
76
+ // // Optionally revert the local change
77
+ // }
78
+ }, []);
79
+ const removeAccount = useCallback(platform => {
80
+ setConnectedAccounts(prev => prev.filter(acc => acc.platform.toLowerCase() !== platform.toLowerCase()));
81
+ console.log('✅ [HOOK] Account removed locally:', platform);
82
+
83
+ // TODO: In a real implementation, you would also remove this from your backend
84
+ // Example:
85
+ // try {
86
+ // await removeConnectedAccount(user.id, platform);
87
+ // } catch (error) {
88
+ // console.error('Failed to remove account from backend:', error);
89
+ // // Optionally revert the local change
90
+ // }
91
+ }, []);
92
+
93
+ // Fetch accounts when component mounts or user changes
94
+ useEffect(() => {
95
+ fetchConnectedAccounts();
96
+ }, [fetchConnectedAccounts]);
97
+ return {
98
+ connectedAccounts,
99
+ isLoading,
100
+ error,
101
+ refreshAccounts,
102
+ addAccount,
103
+ removeAccount
104
+ };
105
+ };
106
+ //# sourceMappingURL=useConnectedAccounts.js.map
@@ -1 +1,95 @@
1
- import{useState,useCallback}from'react';function _0x4f23(){const _0xf6d804=['ℹ️\x20NOTE:\x20Backend\x20sync\x20removed\x20from\x20SDK\x20-\x20app\x20should\x20call\x20/enoch/users/update\x20if\x20needed','nXwlu','gsXsu','yVDpY','QDDZL','TEGgo','deFIJ','youtube','instagram','DGtdH','log','vQTTO','✅\x20Platform\x20','\x20connected\x20locally','KKjdW','Error\x20connecting\x20platform\x20','mHrdz','BEpns','PiOEC','dkTah','nFkEd','oPZxe','fBlGB','error','Error\x20disconnecting\x20platform\x20'];_0x4f23=function(){return _0xf6d804;};return _0x4f23();}import{initiateNativeAuth}from'../services/platformAuthService';function _0xa671(_0x4f2326,_0xa67169){_0x4f2326=_0x4f2326-0x0;const _0x3daf4c=_0x4f23();let _0x3e7c2f=_0x3daf4c[_0x4f2326];return _0x3e7c2f;}export const useConnections=()=>{const _0x45e9bb={'TEGgo':function(_0x1aead8,_0x5b9a2a){return _0x1aead8(_0x5b9a2a);},'deFIJ':function(_0x3cc89e,_0x2c7579){return _0x3cc89e===_0x2c7579;},'DGtdH':'PvJkM','QDDZL':function(_0x10df50,_0x527b87,_0x2ef6a3){return _0x10df50(_0x527b87,_0x2ef6a3);},'KKjdW':_0xa671(0x0),'FaeAj':function(_0x5adcca,_0x9d758f){return _0x5adcca===_0x9d758f;},'BEpns':_0xa671(0x1),'PiOEC':'RgKtO','nFkEd':function(_0x29c5ba,_0x1bfad8){return _0x29c5ba!==_0x1bfad8;},'fBlGB':_0xa671(0x2),'yVDpY':function(_0x126ffb,_0x405026){return _0x126ffb(_0x405026);},'mHrdz':function(_0x1bd814,_0x2f5c55,_0x140149){return _0x1bd814(_0x2f5c55,_0x140149);},'zbxct':function(_0xe2078c,_0x16d1bc,_0x1d9b76){return _0xe2078c(_0x16d1bc,_0x1d9b76);}},[_0x4b702a,_0x555f46]=useState({}),[_0x45eeeb,_0x221894]=_0x45e9bb[_0xa671(0x3)](useState,![]),_0x53ed3b=_0x45e9bb[_0xa671(0x4)](useCallback,async(_0x14231d,_0x22c666)=>{const _0x51dbd5={'vQTTO':_0xa671(0x0)};try{_0x45e9bb[_0xa671(0x5)](_0x221894,!![]);const useNativeSDK=_0x45e9bb[_0xa671(0x6)](_0x14231d,_0xa671(0x7))||_0x14231d===_0xa671(0x8);let _0x4ad32e=![];if(useNativeSDK){if(_0x45e9bb[_0xa671(0x9)]!==_0x45e9bb[_0xa671(0x9)])return _0x285016(_0x560bd8=>({..._0x560bd8,[_0x10d324]:{'userName':_0xe69396,'connected':!![]}})),_0x33a844[_0xa671(0xa)]('✅\x20Platform\x20'+_0x588690+'\x20connected\x20locally'),_0x216d68[_0xa671(0xa)](_0x51dbd5[_0xa671(0xb)]),!![];else _0x4ad32e=await _0x45e9bb[_0xa671(0x4)](initiateNativeAuth,_0x14231d,_0x22c666);}else await new Promise(_0x2c2a55=>setTimeout(()=>_0x2c2a55(undefined),0x3e8)),_0x4ad32e=!![];if(_0x4ad32e)return _0x45e9bb[_0xa671(0x5)](_0x555f46,_0x2676cf=>({..._0x2676cf,[_0x14231d]:{'userName':_0x22c666,'connected':!![]}})),console[_0xa671(0xa)](_0xa671(0xc)+_0x14231d+_0xa671(0xd)),console[_0xa671(0xa)](_0x45e9bb[_0xa671(0xe)]),!![];return![];}catch(_0x4607d9){return console['error'](_0xa671(0xf)+_0x14231d+':',_0x4607d9),![];}finally{_0x45e9bb[_0xa671(0x5)](_0x221894,![]);}},[]),_0x54d699=_0x45e9bb[_0xa671(0x10)](useCallback,async(_0x1ba5ee,_0x2a4bfd)=>{try{return _0x45e9bb['TEGgo'](_0x555f46,_0x21b43f=>{const _0x3067e6={'dkTah':function(_0x2a1af0,_0x594a8b){return _0x45e9bb[_0xa671(0x5)](_0x2a1af0,_0x594a8b);}};if(_0x45e9bb['FaeAj'](_0x45e9bb[_0xa671(0x11)],_0x45e9bb[_0xa671(0x12)]))_0x3067e6[_0xa671(0x13)](_0x4ab59c,![]);else{const _0x3ed30={..._0x21b43f};return delete _0x3ed30[_0x1ba5ee],_0x3ed30;}}),console['log'](_0xa671(0xc)+_0x1ba5ee+'\x20disconnected\x20locally'),console['log'](_0x45e9bb[_0xa671(0xe)]),!![];}catch(_0x178ba6){return _0x45e9bb[_0xa671(0x14)](_0xa671(0x15),_0x45e9bb[_0xa671(0x16)])?(console[_0xa671(0x17)](_0xa671(0x18)+_0x1ba5ee+':',_0x178ba6),![]):_0x2b9208;}},[]),_0x55e298=_0x45e9bb['zbxct'](useCallback,async()=>{return _0x4b702a;},[_0x4b702a]);return{'connections':_0x4b702a,'connectPlatform':_0x53ed3b,'disconnectPlatform':_0x54d699,'getConnectionStatus':_0x55e298,'isConnecting':_0x45eeeb};};
1
+ import { useState, useCallback } from 'react';
2
+ import { initiateNativeAuth } from '../services/platformAuthService';
3
+ /**
4
+ * Hook for managing platform connections
5
+ * NOTE: This hook now only manages LOCAL state
6
+ * Consuming apps are responsible for syncing connection status to their backend
7
+ * (e.g., calling /enoch/users/update for Enoch apps)
8
+ */
9
+ export const useConnections = () => {
10
+ const [connections, setConnections] = useState({});
11
+ const [isConnecting, setIsConnecting] = useState(false);
12
+
13
+ /**
14
+ * Connect a platform using OAuth or native SDK
15
+ * NOTE: Only manages local state - backend sync removed from SDK
16
+ */
17
+ const connectPlatform = useCallback(async (platform, username) => {
18
+ try {
19
+ setIsConnecting(true);
20
+
21
+ // Determine if we should use native SDK or OAuth
22
+ const useNativeSDK = platform === 'youtube' || platform === 'instagram';
23
+ let success = false;
24
+ if (useNativeSDK) {
25
+ // Use native SDK
26
+ success = await initiateNativeAuth(platform, username);
27
+ } else {
28
+ // For demo purposes, we'll simulate a successful connection
29
+ await new Promise(resolve => setTimeout(() => resolve(undefined), 1000));
30
+ success = true;
31
+ }
32
+ if (success) {
33
+ // Update connections state locally only
34
+ // NOTE: Backend sync removed - consuming app should handle this
35
+ setConnections(prev => ({
36
+ ...prev,
37
+ [platform]: {
38
+ userName: username,
39
+ connected: true
40
+ }
41
+ }));
42
+ console.log(`✅ Platform ${platform} connected locally`);
43
+ console.log('ℹ️ NOTE: Backend sync removed from SDK - app should call /enoch/users/update if needed');
44
+ return true;
45
+ }
46
+ return false;
47
+ } catch (error) {
48
+ console.error(`Error connecting platform ${platform}:`, error);
49
+ return false;
50
+ } finally {
51
+ setIsConnecting(false);
52
+ }
53
+ }, []);
54
+
55
+ /**
56
+ * Disconnect a platform
57
+ * NOTE: Only manages local state - backend sync removed from SDK
58
+ */
59
+ const disconnectPlatform = useCallback(async (platform, _username) => {
60
+ try {
61
+ // Update local state only
62
+ // NOTE: Backend sync removed - consuming app should handle this
63
+ setConnections(prev => {
64
+ const newConnections = {
65
+ ...prev
66
+ };
67
+ delete newConnections[platform];
68
+ return newConnections;
69
+ });
70
+ console.log(`✅ Platform ${platform} disconnected locally`);
71
+ console.log('ℹ️ NOTE: Backend sync removed from SDK - app should call /enoch/users/update if needed');
72
+ return true;
73
+ } catch (error) {
74
+ console.error(`Error disconnecting platform ${platform}:`, error);
75
+ return false;
76
+ }
77
+ }, []);
78
+
79
+ /**
80
+ * Get current connection status
81
+ */
82
+ const getConnectionStatus = useCallback(async () => {
83
+ // Returns local connection state
84
+ // Consuming app can fetch from backend if needed
85
+ return connections;
86
+ }, [connections]);
87
+ return {
88
+ connections,
89
+ connectPlatform,
90
+ disconnectPlatform,
91
+ getConnectionStatus,
92
+ isConnecting
93
+ };
94
+ };
95
+ //# sourceMappingURL=useConnections.js.map
@@ -1,7 +1,172 @@
1
+ import { useCallback } from 'react';
2
+ import { STORAGE_KEYS } from '../constants';
3
+ import { API_CONFIG } from '../config/api';
1
4
 
2
- // Onairos SDK - Asset Registry (auto-generated)
3
- var __ONAIROS_REQ_REGISTRY__ = [
4
- require('react-native-keychain')
5
- ];
6
- function __ONAIROS_REQ_FUNC__(i) { return __ONAIROS_REQ_REGISTRY__[i]; }
7
- function _0x1885(){const _0x21ab7d=['warn','Error\x20checking\x20credentials:','ckEcq','function','nUDgO','WzCfe','NDfBT','error','gUySt','ntURV','getGenericPassword','ghSte','default','OSXuP','OPwkT','BKYPZ','Wpqqw','ICwBZ','NstCA','service','sIeHk','ndRWG','RAApC','kRvNB','OUpIE','smIXK','pNiwk','YehgK','Keychain\x20access\x20failed,\x20using\x20mock\x20storage','kyDMl','fZizU','HLPnk','gDlwc','ksXnH','kwgSA','setGenericPassword','OiWGi','qdmbm','ueFrl','uMYdK','WdEcs','Error\x20validating\x20credentials:','PJxlA','qPqCJ','cBpuc','LDNNs','voMMn','kKAvq','nBrWm','HSzgM','vVyfj','password','UBspr','tdXaY','BrlLx','NVjyr','Error\x20clearing\x20credentials:','gcjFf','avvLp','Error\x20getting\x20credentials:','BSSju','LYRVk','zYslM','eXPLm','lFbnf','IhGAN','NNPsn','accessControl','WkMaV','ACCESS_CONTROL','BIOMETRY_ANY','accessible','ACCESSIBLE','ctiKX','Error\x20storing\x20credentials:','VihHZ','ioSuS','NnAoi','YfPqj','GdBME','LKxaM','credentials','ePdjj','RnrKC','parse','zWovL','oJeLj','UwmIH','fkKkK','dqApj','XozdN','IoUWE','nudLa','toosq','WHEN_UNLOCKED','sYzBU','mjkjc','xmUPh','xZXjA','ZBCwK','VeYXE','fLLDx','BASE_URL','stringify','json','valid'];_0x1885=function(){return _0x21ab7d;};return _0x1885();}import{useCallback}from'react';function _0xbd5e(_0x1885e1,_0xbd5eda){_0x1885e1=_0x1885e1-0x0;const _0x11bd40=_0x1885();let _0x1f9907=_0x11bd40[_0x1885e1];return _0x1f9907;}import{STORAGE_KEYS}from'../constants';import{API_CONFIG}from'../config/api';const mockCredentialStorage={};let Keychain=null;try{Keychain=__ONAIROS_REQ_FUNC__(0x0);}catch(_0x3d3e11){console[_0xbd5e(0x0)]('react-native-keychain module not available in useCredentials, using mock storage');}const isKeychainAvailable=()=>{const _0x1e141e={'gUySt':_0xbd5e(0x1),'nUDgO':function(_0x4501ba,_0x4d8d06){return _0x4501ba===_0x4d8d06;},'WzCfe':'FGzFD','NDfBT':_0xbd5e(0x2),'ntURV':function(_0x17cc19,_0x3b91ab){return _0x17cc19===_0x3b91ab;},'ghSte':_0xbd5e(0x3)};try{return _0x1e141e[_0xbd5e(0x4)](_0x1e141e[_0xbd5e(0x5)],_0x1e141e[_0xbd5e(0x6)])?(_0x57ca71[_0xbd5e(0x7)](_0x1e141e[_0xbd5e(0x8)],_0x3b5455),![]):Keychain&&_0x1e141e[_0xbd5e(0x9)](typeof Keychain[_0xbd5e(0xa)],_0x1e141e[_0xbd5e(0xb)]);}catch(_0x3a7b34){return![];}},safeGetGenericPassword=async _0xf66f84=>{const _0x1a3502={'kRvNB':function(_0x319f6e,_0x5d2191){return _0x319f6e===_0x5d2191;},'sIeHk':_0xbd5e(0xc),'OUpIE':_0xbd5e(0x3),'kyDMl':'Keychain\x20access\x20failed,\x20using\x20mock\x20storage','Wpqqw':function(_0x11ced3,_0x36e604){return _0x11ced3===_0x36e604;},'ICwBZ':_0xbd5e(0xd),'ndRWG':function(_0x5a30bc){return _0x5a30bc();},'smIXK':function(_0x158bef,_0x3480ca){return _0x158bef!==_0x3480ca;},'RAApC':_0xbd5e(0xe),'pNiwk':_0xbd5e(0xf)};try{if(_0x1a3502[_0xbd5e(0x10)](_0x1a3502[_0xbd5e(0x11)],_0xbd5e(0x12))){const _0x292dd0=(_0x1a3502['kRvNB'](_0x3d90fe,null)||_0xfc0fd3===void 0x0?void 0x0:_0x501b1f[_0xbd5e(0x13)])||_0x1a3502[_0xbd5e(0x14)];return delete _0x3ba5c6[_0x292dd0],!![];}else{if(_0x1a3502[_0xbd5e(0x15)](isKeychainAvailable))return await Keychain[_0xbd5e(0xa)](_0xf66f84);else{if(_0x1a3502['smIXK'](_0x1a3502[_0xbd5e(0x16)],_0x1a3502[_0xbd5e(0x16)]))try{return Keychain&&_0x1a3502[_0xbd5e(0x17)](typeof Keychain[_0xbd5e(0xa)],_0x1a3502[_0xbd5e(0x18)]);}catch(_0x33e4f2){return![];}else{const _0x28f806=(_0x1a3502['Wpqqw'](_0xf66f84,null)||_0xf66f84===void 0x0?void 0x0:_0xf66f84[_0xbd5e(0x13)])||_0x1a3502[_0xbd5e(0x14)];return mockCredentialStorage[_0x28f806]||null;}}}}catch(_0x5c6df6){if(_0x1a3502[_0xbd5e(0x19)](_0x1a3502[_0xbd5e(0x1a)],_0xbd5e(0x1b))){console[_0xbd5e(0x0)](_0xbd5e(0x1c),_0x5c6df6);const _0x2fd4c1=(_0x1a3502[_0xbd5e(0x10)](_0xf66f84,null)||_0x1a3502[_0xbd5e(0x17)](_0xf66f84,void 0x0)?void 0x0:_0xf66f84[_0xbd5e(0x13)])||_0x1a3502[_0xbd5e(0x14)];return mockCredentialStorage[_0x2fd4c1]||null;}else{_0x10eb08[_0xbd5e(0x0)](_0x1a3502[_0xbd5e(0x1d)],_0x9e84fc);const _0x29a75f=(_0x3beb17===null||_0x305941===void 0x0?void 0x0:_0x10c056[_0xbd5e(0x13)])||_0xbd5e(0xc);return _0x622732[_0x29a75f]||null;}}},safeSetGenericPassword=async(_0x5603d7,_0xb44ca3,_0x2c4e77)=>{const _0x459907={'ueFrl':function(_0x513959,_0x47552b){return _0x513959(_0x47552b);},'gDlwc':function(_0x91a001,_0x30b53c){return _0x91a001!==_0x30b53c;},'ksXnH':_0xbd5e(0x1e),'kwgSA':_0xbd5e(0x1f),'OiWGi':function(_0x459fbc,_0x4c1046){return _0x459fbc===_0x4c1046;},'YEniN':function(_0x38c1c9,_0x3d18c6){return _0x38c1c9===_0x3d18c6;},'qdmbm':_0xbd5e(0xc),'lvOyI':_0xbd5e(0x1c),'uMYdK':function(_0x42ad16,_0x3bbb19){return _0x42ad16===_0x3bbb19;},'WdEcs':function(_0x2adf14,_0x44aa73){return _0x2adf14===_0x44aa73;}};try{if(_0x459907[_0xbd5e(0x20)](_0x459907[_0xbd5e(0x21)],_0x459907[_0xbd5e(0x22)])){if(isKeychainAvailable())return await Keychain[_0xbd5e(0x23)](_0x5603d7,_0xb44ca3,_0x2c4e77);else{const _0x20863a=(_0x459907[_0xbd5e(0x24)](_0x2c4e77,null)||_0x459907['YEniN'](_0x2c4e77,void 0x0)?void 0x0:_0x2c4e77[_0xbd5e(0x13)])||_0x459907[_0xbd5e(0x25)];return mockCredentialStorage[_0x20863a]={'username':_0x5603d7,'password':_0xb44ca3},!![];}}else Keychain=_0x459907[_0xbd5e(0x26)](_0x2cfa7e,0x0);}catch(_0x3f8f41){console[_0xbd5e(0x0)](_0x459907['lvOyI'],_0x3f8f41);const _0x206840=(_0x459907[_0xbd5e(0x27)](_0x2c4e77,null)||_0x459907[_0xbd5e(0x28)](_0x2c4e77,void 0x0)?void 0x0:_0x2c4e77['service'])||_0xbd5e(0xc);return mockCredentialStorage[_0x206840]={'username':_0x5603d7,'password':_0xb44ca3},!![];}},safeResetGenericPassword=async _0x514a85=>{const _0x3ae687={'HSzgM':'Keychain\x20access\x20failed,\x20using\x20mock\x20storage','kKAvq':function(_0x11cfd5,_0xabf96c){return _0x11cfd5===_0xabf96c;},'vVyfj':_0xbd5e(0xc),'BrlLx':_0xbd5e(0x29),'voMMn':function(_0x3a09c3){return _0x3a09c3();},'nBrWm':_0xbd5e(0x2a),'yXwTg':_0xbd5e(0x2b),'seqLS':_0xbd5e(0x2c),'UBspr':function(_0x23a388,_0xf617ee){return _0x23a388===_0xf617ee;},'tdXaY':_0xbd5e(0x2d)};try{if(_0x3ae687[_0xbd5e(0x2e)](isKeychainAvailable)){if(_0x3ae687[_0xbd5e(0x2f)](_0x3ae687[_0xbd5e(0x30)],_0x3ae687['yXwTg'])){_0x49be83[_0xbd5e(0x0)](_0x3ae687[_0xbd5e(0x31)],_0x160c11);const _0x41a1f8=(_0x46ecf1===null||_0x3ae687[_0xbd5e(0x2f)](_0x4764b3,void 0x0)?void 0x0:_0x666159['service'])||_0x3ae687[_0xbd5e(0x32)];return delete _0x35f505[_0x41a1f8],!![];}else return await Keychain['resetGenericPassword'](_0x514a85);}else{if('cBpuc'===_0x3ae687['seqLS']){const _0xf24794=(_0x514a85===null||_0x3ae687[_0xbd5e(0x2f)](_0x514a85,void 0x0)?void 0x0:_0x514a85[_0xbd5e(0x13)])||_0x3ae687[_0xbd5e(0x32)];return delete mockCredentialStorage[_0xf24794],!![];}else return _0x931c83['parse'](_0x1f95db[_0xbd5e(0x33)]);}}catch(_0x4fb492){if(_0x3ae687[_0xbd5e(0x34)]('LDNNs',_0x3ae687[_0xbd5e(0x35)])){console[_0xbd5e(0x0)](_0x3ae687[_0xbd5e(0x31)],_0x4fb492);const _0x52c3d6=(_0x514a85===null||_0x514a85===void 0x0?void 0x0:_0x514a85[_0xbd5e(0x13)])||_0xbd5e(0xc);return delete mockCredentialStorage[_0x52c3d6],!![];}else return _0xdca375[_0xbd5e(0x7)](_0x3ae687[_0xbd5e(0x36)],_0x3ddb97),{'success':![],'isValid':![]};}};export const useCredentials=()=>{const _0x520c0d={'WkMaV':function(_0x8c197d,_0x38b26b){return _0x8c197d===_0x38b26b;},'xmUPh':function(_0x10c988,_0x2e11a6){return _0x10c988===_0x2e11a6;},'zYslM':_0xbd5e(0x37),'eXPLm':function(_0x2486f3,_0xd7e244){return _0x2486f3(_0xd7e244);},'lFbnf':function(_0x1c3533,_0x3a7dc5){return _0x1c3533===_0x3a7dc5;},'QiSaR':'IhGAN','NNPsn':_0xbd5e(0x1),'ZBCwK':_0xbd5e(0x38),'VihHZ':function(_0x5edb21,_0x277c9a){return _0x5edb21===_0x277c9a;},'NnAoi':function(_0x3c10d2,_0x2413ef){return _0x3c10d2===_0x2413ef;},'LKxaM':function(_0x128923,_0x50e564){return _0x128923(_0x50e564);},'ePdjj':'hwMwo','zWovL':function(_0x1ed218,_0x30f1b6){return _0x1ed218!==_0x30f1b6;},'oJeLj':_0xbd5e(0x39),'UwmIH':_0xbd5e(0x3a),'fkKkK':_0xbd5e(0x3b),'upVaZ':'Keychain\x20access\x20failed,\x20using\x20mock\x20storage','XozdN':function(_0x2be174){return _0x2be174();},'IoUWE':_0xbd5e(0x3c),'toosq':function(_0x1f27be,_0x4848cf){return _0x1f27be===_0x4848cf;},'EfBUk':function(_0x4aa72a,_0x2f94ed,_0x5f7122,_0x543fc5){return _0x4aa72a(_0x2f94ed,_0x5f7122,_0x543fc5);},'xZXjA':_0xbd5e(0xc),'mjkjc':_0xbd5e(0x3d),'VeYXE':'ZdZxY','fLLDx':'XQwVZ','ctiKX':function(_0x53c5e5,_0x2fb5e1,_0x392777){return _0x53c5e5(_0x2fb5e1,_0x392777);}},_0x28a824=useCallback(async()=>{const _0x54d736={'qDrEf':_0xbd5e(0x3b)};try{if(_0x520c0d['xmUPh'](_0xbd5e(0x37),_0x520c0d[_0xbd5e(0x3e)])){const _0x2d1b17=await _0x520c0d[_0xbd5e(0x3f)](safeGetGenericPassword,{'service':STORAGE_KEYS['credentials']});return!!_0x2d1b17;}else return _0x28ee14[_0xbd5e(0x7)](_0x54d736['qDrEf'],_0x24b261),null;}catch(_0x4f74b6){if(_0x520c0d[_0xbd5e(0x40)](_0xbd5e(0x41),_0x520c0d['QiSaR']))return console[_0xbd5e(0x7)](_0x520c0d[_0xbd5e(0x42)],_0x4f74b6),![];else{var _0x571808,_0x257ec1;_0x285330[_0xbd5e(0x43)]=_0x520c0d[_0xbd5e(0x44)](_0x571808=Keychain[_0xbd5e(0x45)],null)||_0x520c0d[_0xbd5e(0x44)](_0x571808,void 0x0)?void 0x0:_0x571808[_0xbd5e(0x46)],_0x337909[_0xbd5e(0x47)]=_0x520c0d[_0xbd5e(0x44)](_0x257ec1=Keychain[_0xbd5e(0x48)],null)||_0x257ec1===void 0x0?void 0x0:_0x257ec1['WHEN_UNLOCKED'];}}},[]),_0x3c9037=_0x520c0d[_0xbd5e(0x49)](useCallback,async()=>{const _0x1de6e8={'GdBME':_0x520c0d['ZBCwK'],'RnrKC':_0xbd5e(0x4a),'dqApj':_0xbd5e(0x3)};if(_0x520c0d[_0xbd5e(0x4b)](_0xbd5e(0x4c),_0xbd5e(0x4c)))try{if(_0x520c0d[_0xbd5e(0x4d)](_0xbd5e(0x4e),'Ldpan'))_0xa9a14b[_0xbd5e(0x7)](_0x1de6e8[_0xbd5e(0x4f)],_0x4d3cde);else{const _0x1dfd8a=await _0x520c0d[_0xbd5e(0x50)](safeGetGenericPassword,{'service':STORAGE_KEYS[_0xbd5e(0x51)]});if(_0x1dfd8a)return _0x520c0d[_0xbd5e(0x44)]('ChBIQ',_0x520c0d[_0xbd5e(0x52)])?(_0x2f2941[_0xbd5e(0x7)](_0x1de6e8[_0xbd5e(0x53)],_0x4a62b7),![]):JSON[_0xbd5e(0x54)](_0x1dfd8a[_0xbd5e(0x33)]);return null;}}catch(_0xa03311){if(_0x520c0d[_0xbd5e(0x55)](_0x520c0d[_0xbd5e(0x56)],_0x520c0d[_0xbd5e(0x57)]))return console[_0xbd5e(0x7)](_0x520c0d[_0xbd5e(0x58)],_0xa03311),null;else{const _0x3936de=(_0x67bba7===null||_0x58558b===void 0x0?void 0x0:_0x406256[_0xbd5e(0x13)])||_0xbd5e(0xc);return _0x4ae58f[_0x3936de]={'username':_0xf3a188,'password':_0x60bb5a},!![];}}else return Keychain&&typeof Keychain[_0xbd5e(0xa)]===_0x1de6e8[_0xbd5e(0x59)];},[]),_0x2441a3=useCallback(async(_0x15fc1b,_0x2c936d,_0x2192d0)=>{const _0xcecf73={'sYzBU':_0x520c0d['upVaZ']};try{const _0x4515cb={'service':STORAGE_KEYS[_0xbd5e(0x51)]};if(_0x520c0d[_0xbd5e(0x5a)](isKeychainAvailable)){if(_0x520c0d['zWovL'](_0x520c0d[_0xbd5e(0x5b)],_0xbd5e(0x5c))){var _0x11afbf,_0x4a4b0b;_0x4515cb[_0xbd5e(0x43)]=_0x520c0d[_0xbd5e(0x5d)](_0x11afbf=Keychain[_0xbd5e(0x45)],null)||_0x11afbf===void 0x0?void 0x0:_0x11afbf[_0xbd5e(0x46)],_0x4515cb['accessible']=_0x520c0d['NnAoi'](_0x4a4b0b=Keychain[_0xbd5e(0x48)],null)||_0x4a4b0b===void 0x0?void 0x0:_0x4a4b0b[_0xbd5e(0x5e)];}else{_0x2f24fc['warn'](_0xcecf73[_0xbd5e(0x5f)],_0x4610f7);const _0x2c0578=(_0x219178===null||_0x234e69===void 0x0?void 0x0:_0x6ab576[_0xbd5e(0x13)])||_0xbd5e(0xc);return _0x4df6fd[_0x2c0578]={'username':_0x3a5e2e,'password':_0x5715dc},!![];}}return await _0x520c0d['EfBUk'](safeSetGenericPassword,_0x15fc1b,JSON['stringify']({'userPin':_0x2c936d,'accessToken':_0x2192d0}),_0x4515cb),!![];}catch(_0x2431df){return console[_0xbd5e(0x7)](_0xbd5e(0x4a),_0x2431df),![];}},[]),_0x5c3408=_0x520c0d[_0xbd5e(0x49)](useCallback,async()=>{try{if(_0x520c0d[_0xbd5e(0x4d)](_0x520c0d[_0xbd5e(0x60)],_0xbd5e(0x3d)))await safeResetGenericPassword({'service':STORAGE_KEYS[_0xbd5e(0x51)]});else{const _0x3030a3=(_0x520c0d[_0xbd5e(0x4d)](_0x300157,null)||_0x520c0d[_0xbd5e(0x61)](_0xb05381,void 0x0)?void 0x0:_0x1af2ac['service'])||_0x520c0d[_0xbd5e(0x62)];return _0x37d444[_0x3030a3]||null;}}catch(_0x5194ba){console[_0xbd5e(0x7)](_0x520c0d[_0xbd5e(0x63)],_0x5194ba);}},[]),_0x3e9666=_0x520c0d['ctiKX'](useCallback,async _0x25f5f3=>{if(_0x520c0d['VihHZ'](_0x520c0d[_0xbd5e(0x64)],_0x520c0d[_0xbd5e(0x64)]))try{if(_0x520c0d[_0xbd5e(0x65)]==='XQwVZ'){const _0x4ad782=await _0x520c0d[_0xbd5e(0x49)](fetch,API_CONFIG[_0xbd5e(0x66)]+'/validate',{'method':'POST','headers':{'Content-Type':'application/json'},'body':JSON[_0xbd5e(0x67)]({'username':_0x25f5f3})}),_0x502a53=await _0x4ad782[_0xbd5e(0x68)]();return{'success':!![],'isValid':_0x502a53[_0xbd5e(0x69)],'credentials':_0x502a53[_0xbd5e(0x51)]};}else _0x3789ff[_0xbd5e(0x0)]('react-native-keychain module not available in useCredentials, using mock storage');}catch(_0xbaecc6){return console[_0xbd5e(0x7)](_0xbd5e(0x29),_0xbaecc6),{'success':![],'isValid':![]};}else return![];},[]);return{'hasCredentials':_0x28a824,'getCredentials':_0x3c9037,'storeCredentials':_0x2441a3,'clearCredentials':_0x5c3408,'validateCredentials':_0x3e9666};};
5
+ // Create a mock storage for environments without Keychain access
6
+ const mockCredentialStorage = {};
7
+
8
+ // Try to import Keychain, but provide fallbacks if not available
9
+ let Keychain = null;
10
+ try {
11
+ Keychain = require('react-native-keychain');
12
+ } catch (error) {
13
+ console.warn('react-native-keychain module not available in useCredentials, using mock storage');
14
+ }
15
+
16
+ // Check if Keychain is properly initialized and available
17
+ const isKeychainAvailable = () => {
18
+ try {
19
+ return Keychain && typeof Keychain.getGenericPassword === 'function';
20
+ } catch (e) {
21
+ return false;
22
+ }
23
+ };
24
+
25
+ // Safe wrapper for getGenericPassword
26
+ const safeGetGenericPassword = async options => {
27
+ try {
28
+ if (isKeychainAvailable()) {
29
+ return await Keychain.getGenericPassword(options);
30
+ } else {
31
+ const key = (options === null || options === void 0 ? void 0 : options.service) || 'default';
32
+ return mockCredentialStorage[key] || null;
33
+ }
34
+ } catch (error) {
35
+ console.warn('Keychain access failed, using mock storage', error);
36
+ const key = (options === null || options === void 0 ? void 0 : options.service) || 'default';
37
+ return mockCredentialStorage[key] || null;
38
+ }
39
+ };
40
+
41
+ // Safe wrapper for setGenericPassword
42
+ const safeSetGenericPassword = async (username, password, options) => {
43
+ try {
44
+ if (isKeychainAvailable()) {
45
+ return await Keychain.setGenericPassword(username, password, options);
46
+ } else {
47
+ const key = (options === null || options === void 0 ? void 0 : options.service) || 'default';
48
+ mockCredentialStorage[key] = {
49
+ username,
50
+ password
51
+ };
52
+ return true;
53
+ }
54
+ } catch (error) {
55
+ console.warn('Keychain access failed, using mock storage', error);
56
+ const key = (options === null || options === void 0 ? void 0 : options.service) || 'default';
57
+ mockCredentialStorage[key] = {
58
+ username,
59
+ password
60
+ };
61
+ return true;
62
+ }
63
+ };
64
+
65
+ // Safe wrapper for resetGenericPassword
66
+ const safeResetGenericPassword = async options => {
67
+ try {
68
+ if (isKeychainAvailable()) {
69
+ return await Keychain.resetGenericPassword(options);
70
+ } else {
71
+ const key = (options === null || options === void 0 ? void 0 : options.service) || 'default';
72
+ delete mockCredentialStorage[key];
73
+ return true;
74
+ }
75
+ } catch (error) {
76
+ console.warn('Keychain access failed, using mock storage', error);
77
+ const key = (options === null || options === void 0 ? void 0 : options.service) || 'default';
78
+ delete mockCredentialStorage[key];
79
+ return true;
80
+ }
81
+ };
82
+ export const useCredentials = () => {
83
+ const hasCredentials = useCallback(async () => {
84
+ try {
85
+ const credentials = await safeGetGenericPassword({
86
+ service: STORAGE_KEYS.credentials
87
+ });
88
+ return !!credentials;
89
+ } catch (error) {
90
+ console.error('Error checking credentials:', error);
91
+ return false;
92
+ }
93
+ }, []);
94
+ const getCredentials = useCallback(async () => {
95
+ try {
96
+ const credentials = await safeGetGenericPassword({
97
+ service: STORAGE_KEYS.credentials
98
+ });
99
+ if (credentials) {
100
+ return JSON.parse(credentials.password);
101
+ }
102
+ return null;
103
+ } catch (error) {
104
+ console.error('Error getting credentials:', error);
105
+ return null;
106
+ }
107
+ }, []);
108
+ const storeCredentials = useCallback(async (username, userPin, accessToken) => {
109
+ try {
110
+ const options = {
111
+ service: STORAGE_KEYS.credentials
112
+ };
113
+
114
+ // Only use secure storage options on real devices
115
+ if (isKeychainAvailable()) {
116
+ var _Keychain$ACCESS_CONT, _Keychain$ACCESSIBLE;
117
+ options.accessControl = (_Keychain$ACCESS_CONT = Keychain.ACCESS_CONTROL) === null || _Keychain$ACCESS_CONT === void 0 ? void 0 : _Keychain$ACCESS_CONT.BIOMETRY_ANY;
118
+ options.accessible = (_Keychain$ACCESSIBLE = Keychain.ACCESSIBLE) === null || _Keychain$ACCESSIBLE === void 0 ? void 0 : _Keychain$ACCESSIBLE.WHEN_UNLOCKED;
119
+ }
120
+ await safeSetGenericPassword(username, JSON.stringify({
121
+ userPin,
122
+ accessToken
123
+ }), options);
124
+ return true;
125
+ } catch (error) {
126
+ console.error('Error storing credentials:', error);
127
+ return false;
128
+ }
129
+ }, []);
130
+ const clearCredentials = useCallback(async () => {
131
+ try {
132
+ await safeResetGenericPassword({
133
+ service: STORAGE_KEYS.credentials
134
+ });
135
+ } catch (error) {
136
+ console.error('Error clearing credentials:', error);
137
+ }
138
+ }, []);
139
+ const validateCredentials = useCallback(async username => {
140
+ try {
141
+ const response = await fetch(`${API_CONFIG.BASE_URL}/validate`, {
142
+ method: 'POST',
143
+ headers: {
144
+ 'Content-Type': 'application/json'
145
+ },
146
+ body: JSON.stringify({
147
+ username
148
+ })
149
+ });
150
+ const data = await response.json();
151
+ return {
152
+ success: true,
153
+ isValid: data.valid,
154
+ credentials: data.credentials
155
+ };
156
+ } catch (error) {
157
+ console.error('Error validating credentials:', error);
158
+ return {
159
+ success: false,
160
+ isValid: false
161
+ };
162
+ }
163
+ }, []);
164
+ return {
165
+ hasCredentials,
166
+ getCredentials,
167
+ storeCredentials,
168
+ clearCredentials,
169
+ validateCredentials
170
+ };
171
+ };
172
+ //# sourceMappingURL=useCredentials.js.map
@@ -1 +1,140 @@
1
- import{useState,useEffect,useCallback}from'react';function _0x56af(_0x5b68ad,_0x56af3a){_0x5b68ad=_0x5b68ad-0x0;const _0x1226f4=_0x5b68();let _0x57ca2f=_0x1226f4[_0x5b68ad];return _0x57ca2f;}import{getUserConnections,getUserConnectionsByUsername,getUserConnectionsByUserId,uploadProfilePicture}from'../services/userConnectionsService';import{getAuthToken}from'../services/authService';function _0x5b68(){const _0x2a924d=['0|1|3|2|4','⚠️\x20[CONNECTIONS\x20HOOK]\x20Skipping\x20API\x20call\x20to\x20prevent\x20unauthenticated\x20requests','❌\x20[CONNECTIONS\x20HOOK]\x20Unexpected\x20null\x20token\x20after\x20validation','🔄\x20Loading\x20user\x20connections\x20with\x20authentication...','🔑\x20[CONNECTIONS\x20HOOK]\x20Using\x20auth\x20token:','✅\x20Connections\x20loaded:','MkQSJ','xzqRQ','🔄\x20[CONNECTIONS\x20HOOK]\x20Refreshing\x20connections...','✅\x20[CONNECTIONS\x20HOOK]\x20Connections\x20refresh\x20completed','Failed\x20to\x20load\x20connections','fxfRD','🔍\x20Fetching\x20connections\x20by\x20username:','SfUVJ','❌\x20Error\x20fetching\x20connections\x20by\x20username:','Authentication\x20error','mquCQ','zCqyL','⚠️\x20[CONNECTIONS\x20HOOK]\x20No\x20authentication\x20token\x20available\x20for\x20user\x20ID\x20connections','🔍\x20Fetching\x20connections\x20by\x20userId:','ZnnKc','📷\x20Uploading\x20profile\x20picture\x20for\x20user:','❌\x20Error\x20uploading\x20profile\x20picture:','🎯\x20[DEMO\x20MODE]\x20Reviewer\x20bypass\x20detected\x20-\x20skipping\x20API\x20call\x20for\x20demo','DhgSl','getItem','onairos_jwt_token','tyBBm','IhrnO','kGqTQ','split','warn','STvcl','IAcIj','PwyFi','aJNCq','log','KMQPr','error','rRczH','DpLba','bpHAN','...','length','qjSEN','eZYYz','❌\x20Error\x20loading\x20connections:','TlErc','CKLfu','rIGdK','NzsQS','ibTyq','mnNXV','dhjCd','AqdCG','hhibJ','uodNF','kaIGe','CmtPe','KkszJ','OYgDN','qBQfG','substring','qiAYg','bzkDa','message','Vydco','IeAQX','GtIvy','NXBsl','OWhuu','Ndfcr','ihDoc','hnfLO','wGqjB','Udwkm','McTRl','GvrCY','BlQhU','adDVI','jpg','success','jnzio','nJkbR'];_0x5b68=function(){return _0x2a924d;};return _0x5b68();}import AsyncStorage from'@react-native-async-storage/async-storage';export const useUserConnections=()=>{const _0x2a8345={'KMQPr':function(_0xbf615e,_0x318945){return _0xbf615e(_0x318945);},'DhgSl':function(_0x15327e){return _0x15327e();},'qjSEN':function(_0x3ed1ba,_0x176564){return _0x3ed1ba===_0x176564;},'tyBBm':'reviewer-bypass-token','IhrnO':function(_0x5a4727,_0x1c6e23){return _0x5a4727&&_0x1c6e23;},'kGqTQ':_0x56af(0x0),'STvcl':'⚠️\x20[CONNECTIONS\x20HOOK]\x20No\x20authentication\x20token\x20available\x20for\x20connections\x20refresh','IAcIj':_0x56af(0x1),'PwyFi':'Authentication\x20required\x20for\x20connections','aJNCq':function(_0x54f572,_0x1740c9){return _0x54f572(_0x1740c9);},'lRZGp':_0x56af(0x2),'aSPrT':function(_0x464f2e,_0x33558e){return _0x464f2e(_0x33558e);},'rRczH':function(_0x1661e9,_0x507651){return _0x1661e9(_0x507651);},'DpLba':_0x56af(0x3),'bpHAN':_0x56af(0x4),'pqjxx':_0x56af(0x5),'eZYYz':_0x56af(0x6),'CKLfu':function(_0x4ad806,_0x31ae48){return _0x4ad806===_0x31ae48;},'rIGdK':_0x56af(0x7),'NzsQS':'nxWqd','ibTyq':function(_0x3929f7,_0x3163d7){return _0x3929f7(_0x3163d7);},'dhjCd':_0x56af(0x8),'AqdCG':_0x56af(0x9),'OYgDN':'⚠️\x20[CONNECTIONS\x20HOOK]\x20No\x20authentication\x20token\x20available\x20for\x20username\x20connections','uodNF':_0x56af(0xa),'kaIGe':function(_0x141971,_0x556bea){return _0x141971(_0x556bea);},'CmtPe':function(_0x7d6960,_0x1e35a5){return _0x7d6960(_0x1e35a5);},'KkszJ':_0x56af(0xb),'MxmRV':'zVVVk','qBQfG':_0x56af(0xc),'qiAYg':function(_0x158d71,_0x3fd7c2){return _0x158d71(_0x3fd7c2);},'bzkDa':_0x56af(0xd),'TLGjU':_0x56af(0xe),'NXBsl':function(_0x586daf,_0x3e6620){return _0x586daf(_0x3e6620);},'OWhuu':_0x56af(0xf),'LQepG':function(_0x16f4c5,_0x2a313d){return _0x16f4c5!==_0x2a313d;},'GezAB':_0x56af(0x10),'Ndfcr':'GnjaN','ihDoc':_0x56af(0x11),'xIzCN':_0x56af(0x12),'hnfLO':_0x56af(0x13),'wGqjB':function(_0x252d6e,_0x2d603e){return _0x252d6e(_0x2d603e);},'Udwkm':_0x56af(0x14),'McTRl':'❌\x20Error\x20fetching\x20connections\x20by\x20userId:','UTDTG':_0x56af(0x15),'mnNXV':function(_0x4ee654,_0x567906,_0x30644e){return _0x4ee654(_0x567906,_0x30644e);},'jnzio':_0x56af(0x16),'hhibJ':function(_0xf78859,_0x291d24,_0x987657){return _0xf78859(_0x291d24,_0x987657);},'GtIvy':function(_0x41359f,_0x4860ad,_0x360d83){return _0x41359f(_0x4860ad,_0x360d83);},'nJkbR':function(_0x3d6b94,_0x1c2960,_0x1f5492){return _0x3d6b94(_0x1c2960,_0x1f5492);}},[_0x38e402,_0x2d277]=useState([]),[_0x5c2c76,_0x38a8bd]=useState(!![]),[_0x22dd23,_0x2ce265]=useState(null),_0x26e41d=useCallback(async()=>{const _0x430f73={'TlErc':_0x56af(0x17)};try{_0x38a8bd(!![]),_0x2a8345['KMQPr'](_0x2ce265,null);const _0x25bc04=await _0x2a8345[_0x56af(0x18)](getAuthToken),_0x1c03b9=await AsyncStorage[_0x56af(0x19)](_0x56af(0x1a)),_0x4c2a53=_0x2a8345['qjSEN'](_0x1c03b9,_0x2a8345[_0x56af(0x1b)]);if(_0x2a8345[_0x56af(0x1c)](!_0x25bc04,!_0x4c2a53)){const _0x5c69d0=_0x2a8345[_0x56af(0x1d)][_0x56af(0x1e)]('|');let _0x34f78a=0x0;while(!![]){switch(_0x5c69d0[_0x34f78a++]){case'0':console[_0x56af(0x1f)](_0x2a8345[_0x56af(0x20)]);continue;case'1':console['warn'](_0x2a8345[_0x56af(0x21)]);continue;case'2':_0x2a8345['KMQPr'](_0x2ce265,_0x2a8345[_0x56af(0x22)]);continue;case'3':_0x2a8345[_0x56af(0x23)](_0x2d277,[]);continue;case'4':return;}break;}}if(_0x4c2a53){console[_0x56af(0x24)](_0x56af(0x17)),_0x2a8345[_0x56af(0x25)](_0x2d277,[]),_0x2a8345['aJNCq'](_0x2ce265,null);return;}if(!_0x25bc04){console[_0x56af(0x26)](_0x2a8345['lRZGp']),_0x2a8345['aSPrT'](_0x2d277,[]),_0x2a8345[_0x56af(0x27)](_0x2ce265,'Authentication\x20error');return;}console['log'](_0x2a8345[_0x56af(0x28)]),console['log'](_0x2a8345[_0x56af(0x29)],_0x25bc04['substring'](0x0,0x14)+_0x56af(0x2a));const _0x8657b0=await getUserConnections();_0x2d277(_0x8657b0),console[_0x56af(0x24)](_0x2a8345['pqjxx'],_0x8657b0[_0x56af(0x2b)]);}catch(_0x2b4aac){if(_0x2a8345[_0x56af(0x2c)](_0x56af(0x6),_0x2a8345[_0x56af(0x2d)])){const _0x4ec017=_0x2b4aac instanceof Error?_0x2b4aac['message']:_0x56af(0xa);console[_0x56af(0x26)](_0x56af(0x2e),_0x4ec017),_0x2ce265(_0x4ec017),_0x2a8345[_0x56af(0x23)](_0x2d277,[]);}else{_0x467d12[_0x56af(0x24)](_0x430f73[_0x56af(0x2f)]),_0x103756([]),_0x4ce336(null);return;}}finally{if(_0x2a8345[_0x56af(0x30)](_0x2a8345[_0x56af(0x31)],_0x2a8345[_0x56af(0x32)]))return _0x182539['warn'](_0x56af(0x12)),[];else _0x2a8345[_0x56af(0x33)](_0x38a8bd,![]);}},[]),_0x41847b=_0x2a8345[_0x56af(0x34)](useCallback,async()=>{console[_0x56af(0x24)](_0x2a8345[_0x56af(0x35)]),await _0x2a8345[_0x56af(0x18)](_0x26e41d),console[_0x56af(0x24)](_0x2a8345[_0x56af(0x36)]);},[_0x26e41d]),_0x15a858=_0x2a8345[_0x56af(0x37)](useCallback,async _0x1201e0=>{const _0x5c798c={'Vydco':_0x2a8345[_0x56af(0x38)],'IeAQX':function(_0x58060b,_0x4ce62d){return _0x2a8345[_0x56af(0x39)](_0x58060b,_0x4ce62d);},'bWPSl':function(_0x124117,_0x2537dc){return _0x2a8345[_0x56af(0x3a)](_0x124117,_0x2537dc);}};if(_0x2a8345[_0x56af(0x3b)]!==_0x2a8345['MxmRV'])try{const _0x5593dc=await _0x2a8345[_0x56af(0x18)](getAuthToken);if(!_0x5593dc)return console[_0x56af(0x1f)](_0x2a8345[_0x56af(0x3c)]),[];return console[_0x56af(0x24)](_0x2a8345[_0x56af(0x3d)],_0x1201e0),console[_0x56af(0x24)](_0x2a8345[_0x56af(0x29)],_0x5593dc[_0x56af(0x3e)](0x0,0x14)+_0x56af(0x2a)),await _0x2a8345[_0x56af(0x3f)](getUserConnectionsByUsername,_0x1201e0);}catch(_0x453957){if(_0x2a8345[_0x56af(0x40)]===_0x2a8345[_0x56af(0x40)])return console[_0x56af(0x26)](_0x2a8345['TLGjU'],_0x453957),[];else{const _0x56975a=_0x1a62ce instanceof _0x42e928?_0x3cafbe[_0x56af(0x41)]:_0x5c798c[_0x56af(0x42)];_0x4a485f[_0x56af(0x26)]('❌\x20Error\x20loading\x20connections:',_0x56975a),_0x5c798c[_0x56af(0x43)](_0x560f9f,_0x56975a),_0x5c798c['bWPSl'](_0x5783f1,[]);}}else return _0xaa4184['warn'](_0x2a8345[_0x56af(0x3c)]),[];},[]),_0x13750c=_0x2a8345[_0x56af(0x44)](useCallback,async _0x515329=>{const _0x1f0a6a={'GvrCY':function(_0x1f5ac4,_0x396287){return _0x2a8345[_0x56af(0x45)](_0x1f5ac4,_0x396287);},'AViiL':_0x2a8345['lRZGp'],'BlQhU':function(_0x5d2c99,_0x4e3d14){return _0x2a8345[_0x56af(0x25)](_0x5d2c99,_0x4e3d14);},'adDVI':_0x2a8345[_0x56af(0x46)]};if(_0x2a8345['LQepG'](_0x2a8345['GezAB'],_0x2a8345[_0x56af(0x47)]))try{const _0x148c04=await getAuthToken();if(!_0x148c04)return _0x2a8345[_0x56af(0x48)]===_0x2a8345['ihDoc']?(console[_0x56af(0x1f)](_0x2a8345['xIzCN']),[]):(_0x478960[_0x56af(0x26)](_0x56af(0xe),_0x253efa),[]);return console[_0x56af(0x24)](_0x2a8345[_0x56af(0x49)],_0x515329),console['log'](_0x2a8345[_0x56af(0x29)],_0x148c04[_0x56af(0x3e)](0x0,0x14)+_0x56af(0x2a)),await _0x2a8345[_0x56af(0x4a)](getUserConnectionsByUserId,_0x515329);}catch(_0x3871e0){if(_0x2a8345['CKLfu'](_0x2a8345['Udwkm'],_0x2a8345[_0x56af(0x4b)]))return console['error'](_0x2a8345[_0x56af(0x4c)],_0x3871e0),[];else _0x1f0a6a[_0x56af(0x4d)](_0x53e0db,![]);}else{_0x4d39f2['error'](_0x1f0a6a['AViiL']),_0x1f0a6a[_0x56af(0x4d)](_0x4d6841,[]),_0x1f0a6a[_0x56af(0x4e)](_0x1a47bd,_0x1f0a6a[_0x56af(0x4f)]);return;}},[]),_0x48b6dc=_0x2a8345['hhibJ'](useCallback,async(_0x11e4ef,_0x4f76ec=_0x56af(0x50))=>{try{console[_0x56af(0x24)](_0x2a8345['UTDTG']);const _0x232ec7=await _0x2a8345[_0x56af(0x34)](uploadProfilePicture,_0x11e4ef,_0x4f76ec);return _0x232ec7[_0x56af(0x51)];}catch(_0x3a9614){return console[_0x56af(0x26)](_0x2a8345[_0x56af(0x52)],_0x3a9614),![];}},[]);return _0x2a8345[_0x56af(0x53)](useEffect,()=>{_0x26e41d();},[_0x26e41d]),{'connections':_0x38e402,'isLoading':_0x5c2c76,'error':_0x22dd23,'refreshConnections':_0x41847b,'getConnectionsByUsername':_0x15a858,'getConnectionsByUserId':_0x13750c,'uploadUserProfilePicture':_0x48b6dc};};
1
+ import { useState, useEffect, useCallback } from 'react';
2
+ import { getUserConnections, getUserConnectionsByUsername, getUserConnectionsByUserId, uploadProfilePicture } from '../services/userConnectionsService';
3
+ import { getAuthToken } from '../services/authService';
4
+ import AsyncStorage from '@react-native-async-storage/async-storage';
5
+ export const useUserConnections = () => {
6
+ const [connections, setConnections] = useState([]);
7
+ const [isLoading, setIsLoading] = useState(true);
8
+ const [error, setError] = useState(null);
9
+
10
+ /**
11
+ * Load connections from API with authentication validation
12
+ */
13
+ const loadConnections = useCallback(async () => {
14
+ try {
15
+ setIsLoading(true);
16
+ setError(null);
17
+
18
+ // ✅ CRITICAL: Validate authentication before making API calls
19
+ const authToken = await getAuthToken();
20
+
21
+ // Check for demo mode (reviewer bypass)
22
+ const reviewerToken = await AsyncStorage.getItem('onairos_jwt_token');
23
+ const isDemoMode = reviewerToken === 'reviewer-bypass-token';
24
+ if (!authToken && !isDemoMode) {
25
+ console.warn('⚠️ [CONNECTIONS HOOK] No authentication token available for connections refresh');
26
+ console.warn('⚠️ [CONNECTIONS HOOK] Skipping API call to prevent unauthenticated requests');
27
+ setConnections([]);
28
+ setError('Authentication required for connections');
29
+ return;
30
+ }
31
+ if (isDemoMode) {
32
+ console.log('🎯 [DEMO MODE] Reviewer bypass detected - skipping API call for demo');
33
+ // For demo mode, return empty connections - ResultsScreen will use fallback data
34
+ setConnections([]);
35
+ setError(null);
36
+ return;
37
+ }
38
+
39
+ // At this point, authToken must be valid (not null) because we've checked both cases above
40
+ if (!authToken) {
41
+ console.error('❌ [CONNECTIONS HOOK] Unexpected null token after validation');
42
+ setConnections([]);
43
+ setError('Authentication error');
44
+ return;
45
+ }
46
+ console.log('🔄 Loading user connections with authentication...');
47
+ console.log('🔑 [CONNECTIONS HOOK] Using auth token:', `${authToken.substring(0, 20)}...`);
48
+ const fetchedConnections = await getUserConnections();
49
+ setConnections(fetchedConnections);
50
+ console.log('✅ Connections loaded:', fetchedConnections.length);
51
+ } catch (err) {
52
+ const errorMessage = err instanceof Error ? err.message : 'Failed to load connections';
53
+ console.error('❌ Error loading connections:', errorMessage);
54
+ setError(errorMessage);
55
+
56
+ // Set empty array on error - screens will handle their own fallbacks
57
+ setConnections([]);
58
+ } finally {
59
+ setIsLoading(false);
60
+ }
61
+ }, []);
62
+
63
+ /**
64
+ * Refresh connections with authentication validation
65
+ */
66
+ const refreshConnections = useCallback(async () => {
67
+ console.log('🔄 [CONNECTIONS HOOK] Refreshing connections...');
68
+ await loadConnections();
69
+ console.log('✅ [CONNECTIONS HOOK] Connections refresh completed');
70
+ }, [loadConnections]);
71
+
72
+ /**
73
+ * Get connections by username with authentication validation
74
+ */
75
+ const getConnectionsByUsername = useCallback(async username => {
76
+ try {
77
+ // ✅ Validate authentication before making API calls
78
+ const authToken = await getAuthToken();
79
+ if (!authToken) {
80
+ console.warn('⚠️ [CONNECTIONS HOOK] No authentication token available for username connections');
81
+ return [];
82
+ }
83
+ console.log('🔍 Fetching connections by username:', username);
84
+ console.log('🔑 [CONNECTIONS HOOK] Using auth token:', `${authToken.substring(0, 20)}...`);
85
+ return await getUserConnectionsByUsername(username);
86
+ } catch (error) {
87
+ console.error('❌ Error fetching connections by username:', error);
88
+ return [];
89
+ }
90
+ }, []);
91
+
92
+ /**
93
+ * Get connections by user ID with authentication validation
94
+ */
95
+ const getConnectionsByUserId = useCallback(async userId => {
96
+ try {
97
+ // ✅ Validate authentication before making API calls
98
+ const authToken = await getAuthToken();
99
+ if (!authToken) {
100
+ console.warn('⚠️ [CONNECTIONS HOOK] No authentication token available for user ID connections');
101
+ return [];
102
+ }
103
+ console.log('🔍 Fetching connections by userId:', userId);
104
+ console.log('🔑 [CONNECTIONS HOOK] Using auth token:', `${authToken.substring(0, 20)}...`);
105
+ return await getUserConnectionsByUserId(userId);
106
+ } catch (error) {
107
+ console.error('❌ Error fetching connections by userId:', error);
108
+ return [];
109
+ }
110
+ }, []);
111
+
112
+ /**
113
+ * Upload profile picture
114
+ */
115
+ const uploadUserProfilePicture = useCallback(async (imageData, fileType = 'jpg') => {
116
+ try {
117
+ console.log('📷 Uploading profile picture for user:');
118
+ const result = await uploadProfilePicture(imageData, fileType);
119
+ return result.success;
120
+ } catch (error) {
121
+ console.error('❌ Error uploading profile picture:', error);
122
+ return false;
123
+ }
124
+ }, []);
125
+
126
+ // Load connections on mount
127
+ useEffect(() => {
128
+ loadConnections();
129
+ }, [loadConnections]);
130
+ return {
131
+ connections,
132
+ isLoading,
133
+ error,
134
+ refreshConnections,
135
+ getConnectionsByUsername,
136
+ getConnectionsByUserId,
137
+ uploadUserProfilePicture
138
+ };
139
+ };
140
+ //# sourceMappingURL=useUserConnections.js.map