@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,293 @@
1
- import{getAuthToken}from'./authService';import{API_CONFIG,getApiHeaders,getAuthHeaders}from'../config/api';import{getApiConfig,isApiKeyInitialized}from'./apiKeyService';const API_BASE_URL=API_CONFIG[_0x236f(0x0)],getDeveloperAuthHeaders=()=>{const _0x2e6150={'XoIVV':function(_0x798c66){return _0x798c66();},'pVGWY':'⚠️\x20SDK\x20not\x20initialized\x20-\x20using\x20basic\x20headers','MpmVF':function(_0x587eb4,_0x2d450e){return _0x587eb4!==_0x2d450e;},'lGhiK':function(_0x2ecab2,_0xc3434b){return _0x2ecab2!==_0xc3434b;},'rehDF':function(_0x1068ec){return _0x1068ec();},'QRBJr':_0x236f(0x1)};if(!_0x2e6150['XoIVV'](isApiKeyInitialized))return console[_0x236f(0x2)](_0x2e6150[_0x236f(0x3)]),getApiHeaders();const _0xab7dca=getApiConfig();if(!(_0x2e6150['MpmVF'](_0xab7dca,null)&&_0x2e6150[_0x236f(0x4)](_0xab7dca,void 0x0)&&_0xab7dca[_0x236f(0x5)]))return _0x2e6150['XoIVV'](getApiHeaders);return{..._0x2e6150[_0x236f(0x6)](getApiHeaders),'Authorization':_0x236f(0x7)+_0xab7dca[_0x236f(0x5)],'X-SDK-Version':_0x2e6150['QRBJr'],'X-SDK-Platform':'react-native'};};export const getConnectedAccountsLookup=async _0x2356ae=>{const _0x27948f={'nZiJg':function(_0x1c5cb0,_0x7e80fa){return _0x1c5cb0===_0x7e80fa;},'VJXaQ':_0x236f(0x8),'qUxYg':_0x236f(0x9),'KxDKj':function(_0x58e98b){return _0x58e98b();},'EikeQ':function(_0x44617d,_0x2e1cf,_0x3ab800){return _0x44617d(_0x2e1cf,_0x3ab800);},'Tybhs':function(_0x1471b2,_0x2fa303){return _0x1471b2(_0x2fa303);},'OdXYg':_0x236f(0xa),'eRJyi':function(_0x5500bd,_0x819172){return _0x5500bd>_0x819172;},'PgSnF':_0x236f(0xb),'UAtHA':'jCPel','kuzbY':'ℹ️\x20[NEW\x20API]\x20No\x20connected\x20accounts\x20found\x20for\x20user','jlmVN':_0x236f(0xc)};try{if(_0x27948f[_0x236f(0xd)](_0x27948f['VJXaQ'],_0x27948f[_0x236f(0xe)])){console[_0x236f(0xf)](_0x27948f['qUxYg'],_0x2356ae);const _0x435774=await _0x27948f[_0x236f(0x10)](getAuthToken),_0x190221=await _0x27948f[_0x236f(0x11)](fetch,API_BASE_URL+_0x236f(0x12)+_0x27948f['Tybhs'](encodeURIComponent,_0x2356ae),{'method':'GET','headers':_0x435774?_0x27948f[_0x236f(0x13)](getAuthHeaders,_0x435774):_0x27948f[_0x236f(0x10)](getDeveloperAuthHeaders)});if(_0x190221['ok']){const _0x5c6f57=await _0x190221[_0x236f(0x14)]();return console[_0x236f(0xf)](_0x27948f[_0x236f(0x15)],_0x5c6f57),_0x5c6f57[_0x236f(0x16)]&&_0x5c6f57['connectedAccounts']&&_0x27948f['eRJyi'](_0x5c6f57[_0x236f(0x17)]['length'],0x0)?_0x27948f['PgSnF']!==_0x27948f[_0x236f(0x18)]?(console[_0x236f(0xf)](_0x236f(0x19)+_0x5c6f57[_0x236f(0x17)]['length']+_0x236f(0x1a)),_0x5c6f57[_0x236f(0x17)]):(_0xe52258[_0x236f(0xf)]('✅\x20[NEW\x20API]\x20Found\x20'+_0x12ee28[_0x236f(0x17)]['length']+_0x236f(0x1a)),_0x4320ac['connectedAccounts']):(console[_0x236f(0xf)](_0x27948f[_0x236f(0x1b)]),[]);}else return console[_0x236f(0xf)]('⚠️\x20[NEW\x20API]\x20Response\x20not\x20OK:\x20'+_0x190221['status']+'\x20'+_0x190221[_0x236f(0x1c)]),[];}else return _0x259fc8[_0x236f(0xf)]('❌\x20[LEGACY]\x20Error\x20fetching\x20connected\x20accounts\x20by\x20userId:',_0x416fd2),[];}catch(_0x25cb7c){return console['log'](_0x27948f[_0x236f(0x1d)],_0x25cb7c),[];}};export const getConnectedAccountsSmart=async(_0x8f66c1,_0x244d25,_0x3123c7)=>{const _0x516f36={'fpXDA':_0x236f(0x1e),'YkvCQ':function(_0x3808ff){return _0x3808ff();},'wjflz':'youtube','uNaCu':_0x236f(0x1f),'vgqlq':_0x236f(0x20),'BLDqt':_0x236f(0x21),'yRwSS':_0x236f(0x22),'DDFcN':_0x236f(0x23),'iiFpj':_0x236f(0x24),'aftif':_0x236f(0x25),'lLEXv':_0x236f(0x26),'jXsvS':_0x236f(0x27),'jAGei':'#8A63D2','snRgc':'chatgpt','qJfIH':_0x236f(0x28),'PmqWu':_0x236f(0x29),'DdfAf':_0x236f(0x2a),'bxJDu':'anthropic','RPQiA':_0x236f(0x2b),'gsfXc':_0x236f(0x2c),'ybBWO':_0x236f(0x2d),'XaJyY':_0x236f(0x2e),'lcvMV':_0x236f(0x2f),'xguVX':_0x236f(0x30),'vvLXe':'sephora','apWZU':_0x236f(0x31),'WYyFO':_0x236f(0x32),'mMdgO':_0x236f(0x33),'lsXZH':_0x236f(0x34),'KEUwz':_0x236f(0x35),'uSqNP':'#1DB954','ZhIyn':_0x236f(0x36),'lhjeI':_0x236f(0x37),'sdppd':function(_0x2b6886,_0xa2896){return _0x2b6886!==_0xa2896;},'HePnw':'🧠\x20[SMART\x20API]\x20Trying\x20new\x20unified\x20lookup\x20with\x20email:','WcMpC':function(_0x257bef,_0x2ab2c2){return _0x257bef(_0x2ab2c2);},'fVdCE':function(_0x40c3ca,_0x51ad6b){return _0x40c3ca>_0x51ad6b;},'GhzUG':'✅\x20[SMART\x20API]\x20Success\x20with\x20new\x20unified\x20lookup\x20via\x20email','dDFaf':_0x236f(0x38),'iqZqO':function(_0x4280c0,_0x3b0e4c){return _0x4280c0===_0x3b0e4c;},'qMTbW':_0x236f(0x39),'yLfIk':'FEigP','oJMre':_0x236f(0x3a),'XUQCq':function(_0x28296e,_0x592c8c){return _0x28296e(_0x592c8c);},'FQvxB':function(_0x4f2fef,_0x4d4aeb){return _0x4f2fef!==_0x4d4aeb;},'LJLhL':_0x236f(0x3b),'CXMdz':_0x236f(0x3c),'jSJgm':'NRRvN','VKWhP':_0x236f(0x3d)};console[_0x236f(0xf)](_0x516f36[_0x236f(0x3e)]),console[_0x236f(0xf)]('🧠\x20[SMART\x20API]\x20Available\x20identifiers:',{'userEmail':_0x8f66c1,'userId':_0x244d25,'username':_0x3123c7});if(_0x8f66c1){if(_0x516f36['sdppd'](_0x236f(0x3f),'wNtUa'))return _0x104261['log'](_0x236f(0x40),_0x409eee),[];else{console[_0x236f(0xf)](_0x516f36[_0x236f(0x41)],_0x8f66c1);const _0x5aadf1=await _0x516f36[_0x236f(0x42)](getConnectedAccountsLookup,_0x8f66c1);if(_0x516f36['fVdCE'](_0x5aadf1[_0x236f(0x43)],0x0))return console['log'](_0x516f36[_0x236f(0x44)]),_0x5aadf1;console['log'](_0x516f36[_0x236f(0x45)]);}}console[_0x236f(0xf)]('🔄\x20[SMART\x20API]\x20Falling\x20back\x20to\x20old\x20API\x20methods...');let _0x1be088=[];if(_0x8f66c1&&_0x516f36[_0x236f(0x46)](_0x1be088['length'],0x0)){if(_0x516f36[_0x236f(0x47)](_0x516f36['qMTbW'],_0x516f36[_0x236f(0x48)]))console[_0x236f(0xf)](_0x516f36['oJMre'],_0x8f66c1),_0x1be088=await _0x516f36[_0x236f(0x49)](getConnectedAccountsByEmail,_0x8f66c1);else return _0xb0b375[_0x236f(0x2)](_0x516f36[_0x236f(0x4a)]),_0x516f36[_0x236f(0x4b)](_0x87fe01);}if(_0x516f36[_0x236f(0x46)](_0x1be088[_0x236f(0x43)],0x0)&&_0x244d25){if(_0x516f36[_0x236f(0x4c)](_0x516f36[_0x236f(0x4d)],'hrZnj')){const _0x831691=_0x4a08f1[_0x236f(0x4e)]();switch(_0x831691){case _0x516f36['wjflz']:return _0x516f36[_0x236f(0x4f)];case _0x236f(0x50):return'#FF4500';case _0x236f(0x51):return _0x516f36[_0x236f(0x52)];case _0x516f36[_0x236f(0x53)]:return _0x516f36[_0x236f(0x54)];case _0x516f36[_0x236f(0x55)]:return _0x236f(0x56);case _0x236f(0x57):return _0x516f36[_0x236f(0x58)];case _0x516f36[_0x236f(0x59)]:case'email':return _0x516f36[_0x236f(0x5a)];case _0x236f(0x5b):case'x':return _0x516f36['jXsvS'];case _0x236f(0x5c):return _0x516f36[_0x236f(0x5d)];case _0x516f36['snRgc']:case _0x516f36[_0x236f(0x5e)]:return _0x516f36[_0x236f(0x5f)];case _0x516f36[_0x236f(0x60)]:case _0x516f36[_0x236f(0x61)]:return _0x516f36[_0x236f(0x62)];case _0x516f36[_0x236f(0x63)]:return _0x236f(0x31);case _0x516f36[_0x236f(0x64)]:case _0x236f(0x65):return _0x516f36[_0x236f(0x66)];case _0x516f36[_0x236f(0x67)]:return _0x516f36[_0x236f(0x68)];case _0x516f36[_0x236f(0x53)]:return _0x236f(0x22);case _0x516f36[_0x236f(0x69)]:return _0x516f36[_0x236f(0x6a)];case _0x516f36['WYyFO']:return _0x516f36['mMdgO'];case _0x516f36['lsXZH']:return _0x516f36[_0x236f(0x6b)];case _0x236f(0x6c):return _0x516f36[_0x236f(0x6d)];default:return _0x516f36[_0x236f(0x6e)];}}else console['log'](_0x236f(0x6f),_0x244d25),_0x1be088=await _0x516f36[_0x236f(0x42)](getConnectedAccountsByUserId,_0x244d25);}_0x516f36[_0x236f(0x46)](_0x1be088[_0x236f(0x43)],0x0)&&_0x3123c7&&(console[_0x236f(0xf)]('🔄\x20[SMART\x20API]\x20Trying\x20old\x20API\x20with\x20username:',_0x3123c7),_0x1be088=await _0x516f36[_0x236f(0x42)](getConnectedAccountsByUsername,_0x3123c7));if(_0x1be088[_0x236f(0x43)]>0x0){if(_0x516f36[_0x236f(0x47)](_0x236f(0x3c),_0x516f36[_0x236f(0x70)]))return _0x124fc9[_0x236f(0x17)];else console[_0x236f(0xf)]('✅\x20[SMART\x20API]\x20Success\x20with\x20old\x20API\x20fallback:\x20'+_0x1be088[_0x236f(0x43)]+_0x236f(0x71));}else _0x516f36[_0x236f(0x72)]===_0x236f(0x73)?console[_0x236f(0xf)](_0x516f36[_0x236f(0x74)]):_0x3ec743[_0x236f(0xf)](_0x236f(0x75)+_0x2dc92a[_0x236f(0x43)]+_0x236f(0x71));return _0x1be088;};function _0x14a0(){const _0x26e1c9=['BASE_URL','3.0.72','warn','pVGWY','lGhiK','apiKey','rehDF','Bearer\x20','oDZwz','🔍\x20[NEW\x20API]\x20Fetching\x20connected\x20accounts\x20via\x20unified\x20lookup\x20for:','✅\x20[NEW\x20API]\x20Connected\x20accounts\x20fetched\x20successfully:','zYyLb','❌\x20[NEW\x20API]\x20Error\x20fetching\x20connected\x20accounts\x20via\x20lookup:','nZiJg','VJXaQ','log','KxDKj','EikeQ','/connectedAccounts/lookup/','Tybhs','json','OdXYg','success','connectedAccounts','UAtHA','✅\x20[NEW\x20API]\x20Found\x20','\x20connected\x20accounts','kuzbY','statusText','jlmVN','⚠️\x20SDK\x20not\x20initialized\x20-\x20using\x20basic\x20headers','#FF0000','#0077B5','instagram','#E1306C','facebook','#E60023','gmail','#EA4335','#1DA1F2','openai','#10A37F','claude','#D4A574','grok','gemini','#4285F4','hinge','#7C3AED','#000000','telegram','#0088CC','netflix','#E50914','#666666','🧠\x20[SMART\x20API]\x20Starting\x20smart\x20connected\x20accounts\x20fetch...','🔄\x20[SMART\x20API]\x20New\x20API\x20returned\x20no\x20results,\x20trying\x20fallbacks...','HIlEm','🔄\x20[SMART\x20API]\x20Trying\x20old\x20API\x20with\x20email:','hrZnj','sBQZx','⚠️\x20[SMART\x20API]\x20No\x20connected\x20accounts\x20found\x20with\x20any\x20method','lhjeI','wNtUa','❌\x20[LEGACY]\x20Error\x20fetching\x20connected\x20accounts\x20by\x20email:','HePnw','WcMpC','length','GhzUG','dDFaf','iqZqO','sdppd','yLfIk','XUQCq','fpXDA','YkvCQ','FQvxB','LJLhL','toLowerCase','uNaCu','reddit','linkedin','vgqlq','BLDqt','yRwSS','DDFcN','#1877F2','pinterest','iiFpj','aftif','lLEXv','twitter','farcaster','jAGei','qJfIH','PmqWu','DdfAf','bxJDu','RPQiA','gsfXc','ybBWO','google_ai','XaJyY','lcvMV','xguVX','vvLXe','apWZU','KEUwz','spotify','uSqNP','ZhIyn','🔄\x20[SMART\x20API]\x20Trying\x20old\x20API\x20with\x20userId:','CXMdz','\x20accounts','jSJgm','NRRvN','VKWhP','✅\x20[SMART\x20API]\x20Success\x20with\x20old\x20API\x20fallback:\x20','CJsWN','🔍\x20[LEGACY]\x20Fetching\x20connected\x20accounts\x20for\x20username:','✅\x20[LEGACY]\x20Connected\x20accounts\x20fetched:','⚠️\x20[LEGACY]\x20API\x20response\x20not\x20successful\x20or\x20empty','HkxZS','PbfZt','PATvf','ggXBL','/connectedAccounts?username=','zTSOS','KLLgr','punyX','qJsbA','ExihM','RLOUn','emXVS','XQejy','❌\x20[LEGACY]\x20Error\x20fetching\x20connected\x20accounts\x20by\x20username:','LQVTj','🔍\x20[LEGACY]\x20Fetching\x20connected\x20accounts\x20for\x20email:','HdFre','yCYTR','ylqxK','uocPZ','/connectedAccounts?email=','yxKzQ','JczNG','YseoN','bbNfB','🔍\x20[LEGACY]\x20Fetching\x20connected\x20accounts\x20for\x20userId:','RBiXX','toxmY','/connectedAccounts?userId=','YIKiQ','hYmzC','ujTWn','cSvCH','lGsRC','#FF4500','chatgpt','sephora','ylrot','tVtwt','jwYmI','CTnMD','zXBkF','okTUJ','email','XvzZc','gfvbj','lLCXS','WTapd','rCosh','tutsW','TFYmh','haBuI'];_0x14a0=function(){return _0x26e1c9;};return _0x14a0();}export const getConnectedAccountsByUsername=async _0x3364ad=>{const _0x532d8f={'XQejy':'❌\x20[LEGACY]\x20Error\x20fetching\x20connected\x20accounts\x20by\x20username:','HkxZS':function(_0x5135cc,_0x484867){return _0x5135cc===_0x484867;},'PbfZt':_0x236f(0x76),'PATvf':_0x236f(0x77),'ggXBL':function(_0x341f33,_0x332a71,_0x1b6348){return _0x341f33(_0x332a71,_0x1b6348);},'zTSOS':function(_0x41b4ab,_0xfdcfb0){return _0x41b4ab(_0xfdcfb0);},'KLLgr':function(_0x2f1684){return _0x2f1684();},'punyX':_0x236f(0x78),'pOCIj':function(_0x3f7278,_0x28c9c9){return _0x3f7278>_0x28c9c9;},'qJsbA':function(_0x38a7c0,_0x424b73){return _0x38a7c0!==_0x424b73;},'ExihM':'RLOUn','emXVS':_0x236f(0x79)};try{if(_0x532d8f[_0x236f(0x7a)](_0x532d8f[_0x236f(0x7b)],_0x236f(0x76))){console[_0x236f(0xf)](_0x532d8f[_0x236f(0x7c)],_0x3364ad);const _0x2f2419=await getAuthToken(),_0x1a8932=await _0x532d8f[_0x236f(0x7d)](fetch,API_BASE_URL+_0x236f(0x7e)+encodeURIComponent(_0x3364ad),{'method':'GET','headers':_0x2f2419?_0x532d8f[_0x236f(0x7f)](getAuthHeaders,_0x2f2419):_0x532d8f[_0x236f(0x80)](getDeveloperAuthHeaders)});if(_0x1a8932['ok']){const _0x526887=await _0x1a8932[_0x236f(0x14)]();console[_0x236f(0xf)](_0x532d8f[_0x236f(0x81)],_0x526887);if(_0x526887['success']&&_0x526887[_0x236f(0x17)]&&_0x532d8f['pOCIj'](_0x526887[_0x236f(0x17)][_0x236f(0x43)],0x0))return _0x532d8f[_0x236f(0x82)](_0x532d8f[_0x236f(0x83)],_0x236f(0x84))?_0x27ab33[_0x236f(0x17)]:_0x526887['connectedAccounts'];}return console[_0x236f(0xf)](_0x532d8f[_0x236f(0x85)]),[];}else return _0x127f5e['log'](_0x532d8f[_0x236f(0x86)],_0x18b099),[];}catch(_0x554374){return console[_0x236f(0xf)](_0x236f(0x87),_0x554374),[];}};function _0x236f(_0x14a05e,_0x236fb9){_0x14a05e=_0x14a05e-0x0;const _0x53e694=_0x14a0();let _0x182f58=_0x53e694[_0x14a05e];return _0x182f58;}export const getConnectedAccountsByEmail=async _0x200c6d=>{const _0x15dcfa={'WBHWi':_0x236f(0xc),'HdFre':function(_0xa21f8e,_0x34368b){return _0xa21f8e!==_0x34368b;},'yCYTR':_0x236f(0x88),'ylqxK':_0x236f(0x89),'uocPZ':function(_0x4b5861){return _0x4b5861();},'yxKzQ':function(_0x119bec,_0x28ba5d){return _0x119bec(_0x28ba5d);},'JczNG':_0x236f(0x78),'YseoN':function(_0x2fc044,_0x366630){return _0x2fc044>_0x366630;},'bbNfB':_0x236f(0x79)};try{if(_0x15dcfa[_0x236f(0x8a)](_0x15dcfa[_0x236f(0x8b)],_0x236f(0x88)))return _0xdfa1e5[_0x236f(0xf)](_0x15dcfa['WBHWi'],_0x33ced4),[];else{console[_0x236f(0xf)](_0x15dcfa[_0x236f(0x8c)],_0x200c6d);const _0x2818ec=await _0x15dcfa[_0x236f(0x8d)](getAuthToken),_0x210785=await fetch(API_BASE_URL+_0x236f(0x8e)+_0x15dcfa[_0x236f(0x8f)](encodeURIComponent,_0x200c6d),{'method':'GET','headers':_0x2818ec?_0x15dcfa[_0x236f(0x8f)](getAuthHeaders,_0x2818ec):_0x15dcfa['uocPZ'](getDeveloperAuthHeaders)});if(_0x210785['ok']){const _0x46b68c=await _0x210785[_0x236f(0x14)]();console[_0x236f(0xf)](_0x15dcfa[_0x236f(0x90)],_0x46b68c);if(_0x46b68c[_0x236f(0x16)]&&_0x46b68c[_0x236f(0x17)]&&_0x15dcfa[_0x236f(0x91)](_0x46b68c[_0x236f(0x17)]['length'],0x0))return _0x46b68c[_0x236f(0x17)];}return console[_0x236f(0xf)](_0x15dcfa[_0x236f(0x92)]),[];}}catch(_0x262417){return console[_0x236f(0xf)](_0x236f(0x40),_0x262417),[];}};export const getConnectedAccountsByUserId=async _0x5ecc1b=>{const _0x5738a4={'kcexD':'✅\x20[SMART\x20API]\x20Success\x20with\x20new\x20unified\x20lookup\x20via\x20email','VXJjn':'zayXL','RBiXX':_0x236f(0x93),'rAEOY':function(_0x296509){return _0x296509();},'toxmY':function(_0x1b731d,_0x28159d,_0x11e42d){return _0x1b731d(_0x28159d,_0x11e42d);},'YIKiQ':function(_0x4e9987,_0x1cea88){return _0x4e9987(_0x1cea88);},'hYmzC':function(_0x1d38f1){return _0x1d38f1();},'ujTWn':_0x236f(0x78),'cSvCH':_0x236f(0x79),'lGsRC':'❌\x20[LEGACY]\x20Error\x20fetching\x20connected\x20accounts\x20by\x20userId:'};try{if(_0x5738a4['VXJjn']!=='jYymN'){console[_0x236f(0xf)](_0x5738a4[_0x236f(0x94)],_0x5ecc1b);const _0x28eb55=await _0x5738a4['rAEOY'](getAuthToken),_0x132fd2=await _0x5738a4[_0x236f(0x95)](fetch,API_BASE_URL+_0x236f(0x96)+_0x5738a4['YIKiQ'](encodeURIComponent,_0x5ecc1b),{'method':'GET','headers':_0x28eb55?_0x5738a4[_0x236f(0x97)](getAuthHeaders,_0x28eb55):_0x5738a4[_0x236f(0x98)](getDeveloperAuthHeaders)});if(_0x132fd2['ok']){const _0x14c170=await _0x132fd2['json']();console['log'](_0x5738a4[_0x236f(0x99)],_0x14c170);if(_0x14c170['success']&&_0x14c170[_0x236f(0x17)]&&_0x14c170[_0x236f(0x17)]['length']>0x0)return _0x14c170['connectedAccounts'];}return console[_0x236f(0xf)](_0x5738a4[_0x236f(0x9a)]),[];}else return _0x4d79e2['log'](_0x5738a4['kcexD']),_0x324d6a;}catch(_0x251076){return console['log'](_0x5738a4[_0x236f(0x9b)],_0x251076),[];}};export{getPlatformIconFromRegistry as getPlatformIcon}from'../utils/assetRegistry';export const getPlatformColor=_0x4c4c49=>{const _0x511bc8={'LNLwv':_0x236f(0x1f),'ylrot':_0x236f(0x50),'rwRNX':_0x236f(0x9c),'tVtwt':_0x236f(0x51),'jwYmI':'instagram','CTnMD':_0x236f(0x22),'zXBkF':'facebook','dTIbB':_0x236f(0x56),'KdLbT':_0x236f(0x57),'UrWhC':_0x236f(0x24),'okTUJ':_0x236f(0x25),'ZUamI':_0x236f(0x5b),'XvzZc':_0x236f(0x27),'gfvbj':_0x236f(0x5c),'NBkLy':'#8A63D2','YDbTF':_0x236f(0x9d),'lLCXS':_0x236f(0x29),'WTapd':'#D4A574','BbuDa':_0x236f(0x2c),'mIVFI':_0x236f(0x31),'rCosh':_0x236f(0x2d),'jHkGC':_0x236f(0x65),'tutsW':_0x236f(0x2f),'bmmcb':_0x236f(0x30),'TFYmh':_0x236f(0x9e),'haBuI':_0x236f(0x32),'KVVGg':_0x236f(0x6c),'SKZAt':'#1DB954'},_0x5ec161=_0x4c4c49['toLowerCase']();switch(_0x5ec161){case'youtube':return _0x511bc8['LNLwv'];case _0x511bc8[_0x236f(0x9f)]:return _0x511bc8['rwRNX'];case _0x511bc8[_0x236f(0xa0)]:return _0x236f(0x20);case _0x511bc8[_0x236f(0xa1)]:return _0x511bc8[_0x236f(0xa2)];case _0x511bc8[_0x236f(0xa3)]:return _0x511bc8['dTIbB'];case _0x511bc8['KdLbT']:return _0x511bc8['UrWhC'];case _0x511bc8[_0x236f(0xa4)]:case _0x236f(0xa5):return _0x236f(0x26);case _0x511bc8['ZUamI']:case'x':return _0x511bc8[_0x236f(0xa6)];case _0x511bc8[_0x236f(0xa7)]:return _0x511bc8['NBkLy'];case _0x511bc8['YDbTF']:case'openai':return _0x511bc8[_0x236f(0xa8)];case _0x236f(0x2a):case'anthropic':return _0x511bc8[_0x236f(0xa9)];case _0x511bc8['BbuDa']:return _0x511bc8['mIVFI'];case _0x511bc8[_0x236f(0xaa)]:case _0x511bc8['jHkGC']:return _0x236f(0x2e);case _0x511bc8[_0x236f(0xab)]:return _0x511bc8['bmmcb'];case _0x511bc8[_0x236f(0xa1)]:return _0x511bc8[_0x236f(0xa2)];case _0x511bc8[_0x236f(0xac)]:return _0x511bc8['mIVFI'];case _0x511bc8[_0x236f(0xad)]:return'#0088CC';case _0x236f(0x34):return'#E50914';case _0x511bc8['KVVGg']:return _0x511bc8['SKZAt'];default:return _0x236f(0x36);}};
1
+ import { getAuthToken } from './authService';
2
+ import { API_CONFIG, getApiHeaders, getAuthHeaders } from '../config/api';
3
+ import { getApiConfig, isApiKeyInitialized } from './apiKeyService';
4
+ const API_BASE_URL = API_CONFIG.BASE_URL;
5
+
6
+ /**
7
+ * Get developer API key authorization headers
8
+ * Falls back when no user JWT token is available
9
+ */
10
+ const getDeveloperAuthHeaders = () => {
11
+ if (!isApiKeyInitialized()) {
12
+ console.warn('⚠️ SDK not initialized - using basic headers');
13
+ return getApiHeaders();
14
+ }
15
+ const config = getApiConfig();
16
+ if (!(config !== null && config !== void 0 && config.apiKey)) {
17
+ return getApiHeaders();
18
+ }
19
+ return {
20
+ ...getApiHeaders(),
21
+ 'Authorization': `Bearer ${config.apiKey}`,
22
+ 'X-SDK-Version': '3.0.72',
23
+ 'X-SDK-Platform': 'react-native'
24
+ };
25
+ };
26
+
27
+ // Interface for connected account from API
28
+
29
+ // Interface for API response
30
+
31
+ /**
32
+ * NEW UNIFIED LOOKUP - Get connected accounts using the simplified lookup endpoint
33
+ * This is the preferred method that makes only ONE request to the backend
34
+ * @param userIdentifier - Can be email, username, userId, or any user identifier
35
+ * @returns Promise<ConnectedAccount[]>
36
+ */
37
+ export const getConnectedAccountsLookup = async userIdentifier => {
38
+ try {
39
+ console.log('🔍 [NEW API] Fetching connected accounts via unified lookup for:', userIdentifier);
40
+ const token = await getAuthToken();
41
+
42
+ // Use the new simplified endpoint format
43
+ // 🔒 Use user JWT if available, otherwise use developer API key
44
+ const response = await fetch(`${API_BASE_URL}/connectedAccounts/lookup/${encodeURIComponent(userIdentifier)}`, {
45
+ method: 'GET',
46
+ headers: token ? getAuthHeaders(token) : getDeveloperAuthHeaders()
47
+ });
48
+ if (response.ok) {
49
+ const data = await response.json();
50
+ console.log('✅ [NEW API] Connected accounts fetched successfully:', data);
51
+ if (data.success && data.connectedAccounts && data.connectedAccounts.length > 0) {
52
+ console.log(`✅ [NEW API] Found ${data.connectedAccounts.length} connected accounts`);
53
+ return data.connectedAccounts;
54
+ } else {
55
+ console.log('ℹ️ [NEW API] No connected accounts found for user');
56
+ return [];
57
+ }
58
+ } else {
59
+ console.log(`⚠️ [NEW API] Response not OK: ${response.status} ${response.statusText}`);
60
+ return [];
61
+ }
62
+ } catch (error) {
63
+ console.log('❌ [NEW API] Error fetching connected accounts via lookup:', error);
64
+ return [];
65
+ }
66
+ };
67
+
68
+ /**
69
+ * SMART CONNECTED ACCOUNTS FETCHER - Uses new API with old API fallback
70
+ * This function tries the new unified lookup first, then falls back to old methods if needed
71
+ * @param userEmail - User's email (primary identifier)
72
+ * @param userId - User's ID (fallback)
73
+ * @param username - User's username (fallback)
74
+ * @returns Promise<ConnectedAccount[]>
75
+ */
76
+ export const getConnectedAccountsSmart = async (userEmail, userId, username) => {
77
+ console.log('🧠 [SMART API] Starting smart connected accounts fetch...');
78
+ console.log('🧠 [SMART API] Available identifiers:', {
79
+ userEmail,
80
+ userId,
81
+ username
82
+ });
83
+
84
+ // Try the new unified lookup API first (preferred method)
85
+ if (userEmail) {
86
+ console.log('🧠 [SMART API] Trying new unified lookup with email:', userEmail);
87
+ const accounts = await getConnectedAccountsLookup(userEmail);
88
+ if (accounts.length > 0) {
89
+ console.log('✅ [SMART API] Success with new unified lookup via email');
90
+ return accounts;
91
+ }
92
+ console.log('🔄 [SMART API] New API returned no results, trying fallbacks...');
93
+ }
94
+
95
+ // If new API didn't work or no email, try fallbacks
96
+ console.log('🔄 [SMART API] Falling back to old API methods...');
97
+
98
+ // Try old API methods as fallback
99
+ let accounts = [];
100
+
101
+ // Prioritize email for profile views
102
+ if (userEmail && accounts.length === 0) {
103
+ console.log('🔄 [SMART API] Trying old API with email:', userEmail);
104
+ accounts = await getConnectedAccountsByEmail(userEmail);
105
+ }
106
+ if (accounts.length === 0 && userId) {
107
+ console.log('🔄 [SMART API] Trying old API with userId:', userId);
108
+ accounts = await getConnectedAccountsByUserId(userId);
109
+ }
110
+ if (accounts.length === 0 && username) {
111
+ console.log('🔄 [SMART API] Trying old API with username:', username);
112
+ accounts = await getConnectedAccountsByUsername(username);
113
+ }
114
+ if (accounts.length > 0) {
115
+ console.log(`✅ [SMART API] Success with old API fallback: ${accounts.length} accounts`);
116
+ } else {
117
+ console.log('⚠️ [SMART API] No connected accounts found with any method');
118
+ }
119
+ return accounts;
120
+ };
121
+
122
+ // =============================================================================
123
+ // LEGACY API FUNCTIONS - Keep for backward compatibility and fallback
124
+ // These will be used as fallbacks if the new unified lookup fails
125
+ // =============================================================================
126
+
127
+ /**
128
+ * Get connected accounts by username
129
+ * @param username - Username to fetch connected accounts for
130
+ * @returns Promise<ConnectedAccount[]>
131
+ */
132
+ export const getConnectedAccountsByUsername = async username => {
133
+ try {
134
+ console.log('🔍 [LEGACY] Fetching connected accounts for username:', username);
135
+ const token = await getAuthToken();
136
+
137
+ // 🔒 Use user JWT if available, otherwise use developer API key
138
+ const response = await fetch(`${API_BASE_URL}/connectedAccounts?username=${encodeURIComponent(username)}`, {
139
+ method: 'GET',
140
+ headers: token ? getAuthHeaders(token) : getDeveloperAuthHeaders()
141
+ });
142
+ if (response.ok) {
143
+ const data = await response.json();
144
+ console.log('✅ [LEGACY] Connected accounts fetched:', data);
145
+ if (data.success && data.connectedAccounts && data.connectedAccounts.length > 0) {
146
+ return data.connectedAccounts;
147
+ }
148
+ }
149
+ console.log('⚠️ [LEGACY] API response not successful or empty');
150
+ return [];
151
+ } catch (error) {
152
+ console.log('❌ [LEGACY] Error fetching connected accounts by username:', error);
153
+ return [];
154
+ }
155
+ };
156
+
157
+ /**
158
+ * Get connected accounts by email
159
+ * @param email - Email to fetch connected accounts for
160
+ * @returns Promise<ConnectedAccount[]>
161
+ */
162
+ export const getConnectedAccountsByEmail = async email => {
163
+ try {
164
+ console.log('🔍 [LEGACY] Fetching connected accounts for email:', email);
165
+ const token = await getAuthToken();
166
+
167
+ // 🔒 Use user JWT if available, otherwise use developer API key
168
+ const response = await fetch(`${API_BASE_URL}/connectedAccounts?email=${encodeURIComponent(email)}`, {
169
+ method: 'GET',
170
+ headers: token ? getAuthHeaders(token) : getDeveloperAuthHeaders()
171
+ });
172
+ if (response.ok) {
173
+ const data = await response.json();
174
+ console.log('✅ [LEGACY] Connected accounts fetched:', data);
175
+ if (data.success && data.connectedAccounts && data.connectedAccounts.length > 0) {
176
+ return data.connectedAccounts;
177
+ }
178
+ }
179
+ console.log('⚠️ [LEGACY] API response not successful or empty');
180
+ return [];
181
+ } catch (error) {
182
+ console.log('❌ [LEGACY] Error fetching connected accounts by email:', error);
183
+ return [];
184
+ }
185
+ };
186
+
187
+ /**
188
+ * Get connected accounts by user ID
189
+ * @param userId - User ID to fetch connected accounts for
190
+ * @returns Promise<ConnectedAccount[]>
191
+ */
192
+ export const getConnectedAccountsByUserId = async userId => {
193
+ try {
194
+ console.log('🔍 [LEGACY] Fetching connected accounts for userId:', userId);
195
+ const token = await getAuthToken();
196
+
197
+ // 🔒 Use user JWT if available, otherwise use developer API key
198
+ const response = await fetch(`${API_BASE_URL}/connectedAccounts?userId=${encodeURIComponent(userId)}`, {
199
+ method: 'GET',
200
+ headers: token ? getAuthHeaders(token) : getDeveloperAuthHeaders()
201
+ });
202
+ if (response.ok) {
203
+ const data = await response.json();
204
+ console.log('✅ [LEGACY] Connected accounts fetched:', data);
205
+ if (data.success && data.connectedAccounts && data.connectedAccounts.length > 0) {
206
+ return data.connectedAccounts;
207
+ }
208
+ }
209
+ console.log('⚠️ [LEGACY] API response not successful or empty');
210
+ return [];
211
+ } catch (error) {
212
+ console.log('❌ [LEGACY] Error fetching connected accounts by userId:', error);
213
+ return [];
214
+ }
215
+ };
216
+
217
+ /**
218
+ * Get platform icon based on platform name
219
+ * @param platform - Platform name (case insensitive)
220
+ * @returns Image source for the platform icon
221
+ */
222
+ export { getPlatformIconFromRegistry as getPlatformIcon } from '../utils/assetRegistry';
223
+
224
+ /**
225
+ * Get platform color based on platform name
226
+ * @param platform - Platform name (case insensitive)
227
+ * @returns Hex color code for the platform
228
+ */
229
+ export const getPlatformColor = platform => {
230
+ const platformLower = platform.toLowerCase();
231
+ switch (platformLower) {
232
+ case 'youtube':
233
+ return '#FF0000';
234
+ case 'reddit':
235
+ return '#FF4500';
236
+ case 'linkedin':
237
+ return '#0077B5';
238
+ case 'instagram':
239
+ return '#E1306C';
240
+ case 'facebook':
241
+ return '#1877F2';
242
+ case 'pinterest':
243
+ return '#E60023';
244
+ case 'gmail':
245
+ case 'email':
246
+ return '#EA4335';
247
+ case 'twitter':
248
+ case 'x':
249
+ return '#1DA1F2';
250
+ case 'farcaster':
251
+ return '#8A63D2';
252
+ // LLM Platforms
253
+ case 'chatgpt':
254
+ case 'openai':
255
+ return '#10A37F';
256
+ // OpenAI green
257
+ case 'claude':
258
+ case 'anthropic':
259
+ return '#D4A574';
260
+ // Claude tan/orange
261
+ case 'grok':
262
+ return '#000000';
263
+ // X/Grok black
264
+ case 'gemini':
265
+ case 'google_ai':
266
+ return '#4285F4';
267
+ // Google blue
268
+ // New platforms
269
+ case 'hinge':
270
+ return '#7C3AED';
271
+ // Hinge Purple
272
+ case 'instagram':
273
+ return '#E1306C';
274
+ // Instagram Pink/Magenta
275
+ case 'sephora':
276
+ return '#000000';
277
+ // Sephora Black
278
+ case 'telegram':
279
+ return '#0088CC';
280
+ // Telegram Blue
281
+ // Streaming Platforms
282
+ case 'netflix':
283
+ return '#E50914';
284
+ // Netflix Red
285
+ case 'spotify':
286
+ return '#1DB954';
287
+ // Spotify Green
288
+ default:
289
+ return '#666666';
290
+ // Default gray
291
+ }
292
+ };
293
+ //# sourceMappingURL=connectedAccountsService.js.map
@@ -1 +1,241 @@
1
- import{GoogleSignin,statusCodes}from'@react-native-google-signin/google-signin';import AsyncStorage from'@react-native-async-storage/async-storage';import{API_CONFIG}from'../config/api';import{getDeveloperAuthHeaders}from'./apiKeyService';import{storeJWT}from'./jwtStorageService';let WEB_CLIENT_ID=_0x24be(0x0),IOS_CLIENT_ID=_0x24be(0x0);export const updateGoogleClientIds=_0x137d35=>{const _0x555011={'iAmYr':_0x24be(0x1),'nwUEQ':function(_0x5b166a,_0x2df356){return _0x5b166a===_0x2df356;},'FLTMU':'EmMPJ','jNtLQ':'✅\x20Google\x20client\x20IDs\x20updated:'};if(_0x137d35[_0x24be(0x2)]){if(_0x555011[_0x24be(0x3)]('HQOgE',_0x555011[_0x24be(0x4)]))return{'success':![],'message':_0x5581e8[_0x24be(0x5)]||_0x367400[_0x24be(0x6)]||_0x555011['iAmYr']};else WEB_CLIENT_ID=_0x137d35['webClientId'];}_0x137d35[_0x24be(0x7)]&&(IOS_CLIENT_ID=_0x137d35[_0x24be(0x7)]),console[_0x24be(0x8)](_0x555011[_0x24be(0x9)],{'webClientId':WEB_CLIENT_ID,'iosClientId':IOS_CLIENT_ID});};const initializeGoogleAuth=()=>{const _0x49fcfb={'ZbSls':'openid','ZfquH':_0x24be(0xa)};GoogleSignin['configure']({'webClientId':WEB_CLIENT_ID,'iosClientId':IOS_CLIENT_ID,'scopes':[_0x49fcfb['ZbSls'],_0x49fcfb[_0x24be(0xb)],_0x24be(0xc)],'offlineAccess':!![],'forceCodeForRefreshToken':!![],'hostedDomain':'','accountName':''});};export const signInWithGoogle=async()=>{const _0x42e890={'SEiAh':_0x24be(0xd),'eGoSa':'❌\x20Error\x20checking\x20Google\x20sign-in\x20status:','IoMHC':'openid','YbisM':'profile','EYOGY':_0x24be(0xc),'SeTVK':'Account\x20created/authenticated\x20successfully','cnKoJ':function(_0x13b03a,_0x21c8ba){return _0x13b03a!==_0x21c8ba;},'jHmVj':_0x24be(0xe),'dawLN':function(_0xf5820f){return _0xf5820f();},'NPZWu':function(_0x5b9e4f,_0x294c3c){return _0x5b9e4f!==_0x294c3c;},'nAuCd':_0x24be(0xf),'WZvVw':_0x24be(0x10),'sQVdS':_0x24be(0x11),'AcBwZ':_0x24be(0x12),'JrnPx':'✅\x20Google\x20Sign-In\x20successful:','ONQMp':function(_0x1c12e1,_0x101097){return _0x1c12e1===_0x101097;},'XOKAE':function(_0x8fceb7,_0x3a76ab){return _0x8fceb7===_0x3a76ab;},'NCOVd':function(_0x578c87,_0x3ff836){return _0x578c87===_0x3ff836;},'QKtup':function(_0x4b9a0e,_0x1809c4){return _0x4b9a0e!==_0x1809c4;},'tVuHg':_0x24be(0x13),'mVDEO':_0x24be(0x14),'EzJnc':'No\x20user\x20data\x20received\x20from\x20Google','ZsrMW':_0x24be(0x15),'RuIBl':'🔑\x20Got\x20Google\x20tokens','IITrD':function(_0xe03f51,_0x3885fd){return _0xe03f51(_0x3885fd);},'XQdpx':function(_0x53a0c4,_0x336c7c){return _0x53a0c4!==_0x336c7c;},'aUaQZ':_0x24be(0x16),'HqULu':'1|3|5|4|2|6|0','KiMIv':function(_0x43bfd6,_0x4fd0da){return _0x43bfd6===_0x4fd0da;},'eqasZ':'auth_method','zeyUI':'google','SkFxM':_0x24be(0x17),'EwAEM':_0x24be(0x18),'LQSSG':_0x24be(0x19),'AltAC':_0x24be(0x1a),'letTh':function(_0x3e43b0,_0x29522d){return _0x3e43b0===_0x29522d;},'KPIsa':'iwSWW','pazDb':_0x24be(0x1b),'dmstQ':_0x24be(0x1c),'jfxbA':function(_0x40aebe,_0x4b429b){return _0x40aebe===_0x4b429b;},'IoYOT':_0x24be(0x1d),'VbSSu':_0x24be(0x1e),'URtyf':_0x24be(0x1f)};try{if(_0x42e890[_0x24be(0x20)](_0x42e890[_0x24be(0x21)],_0x24be(0xe)))_0x398b27=_0x3bb528[_0x24be(0x7)];else{var _0x36f805,_0x3fcff6;console[_0x24be(0x8)](_0x24be(0x22)),_0x42e890[_0x24be(0x23)](initializeGoogleAuth),await GoogleSignin[_0x24be(0x24)]();try{if(_0x42e890[_0x24be(0x25)](_0x42e890[_0x24be(0x26)],_0x42e890[_0x24be(0x27)]))await GoogleSignin[_0x24be(0x28)](),console[_0x24be(0x8)](_0x42e890[_0x24be(0x29)]);else return{'success':![],'message':_0x42e890[_0x24be(0x2a)]};}catch(_0x56d135){if(_0x42e890[_0x24be(0x20)](_0x42e890[_0x24be(0x2b)],_0x42e890[_0x24be(0x2b)]))return _0xc22117[_0x24be(0x6)](_0x42e890[_0x24be(0x2c)],_0x4093a6),{'isSignedIn':![]};else console[_0x24be(0x8)](_0x24be(0x2d),_0x56d135);}const _0x1b92d9=await GoogleSignin[_0x24be(0x2e)]();console[_0x24be(0x8)](_0x42e890[_0x24be(0x2f)],(_0x36f805=_0x1b92d9[_0x24be(0x30)])===null||_0x42e890[_0x24be(0x31)](_0x36f805,void 0x0)||_0x42e890['XOKAE'](_0x36f805=_0x36f805['user'],null)||_0x42e890['XOKAE'](_0x36f805,void 0x0)?void 0x0:_0x36f805['email']);const _0x45cc2b=(_0x3fcff6=_0x1b92d9['data'])===null||_0x42e890['NCOVd'](_0x3fcff6,void 0x0)?void 0x0:_0x3fcff6['user'];if(!_0x45cc2b||!_0x45cc2b['email']){if(_0x42e890[_0x24be(0x32)](_0x42e890[_0x24be(0x33)],_0x42e890[_0x24be(0x34)]))throw new Error(_0x42e890[_0x24be(0x35)]);else GoogleSignin[_0x24be(0x36)]({'webClientId':_0x2e25d9,'iosClientId':_0x19c130,'scopes':[_0x42e890['IoMHC'],_0x42e890[_0x24be(0x37)],_0x42e890['EYOGY']],'offlineAccess':!![],'forceCodeForRefreshToken':!![],'hostedDomain':'','accountName':''});}console[_0x24be(0x8)](_0x42e890[_0x24be(0x38)],{'email':_0x45cc2b[_0x24be(0xc)],'name':_0x45cc2b[_0x24be(0x39)],'photo':_0x45cc2b[_0x24be(0x3a)],'id':_0x45cc2b['id']});const _0x4cd9e7=await GoogleSignin[_0x24be(0x3b)]();console[_0x24be(0x8)](_0x42e890[_0x24be(0x3c)]);const _0x1fc633=await _0x42e890['IITrD'](createUserAccount,{'email':_0x45cc2b[_0x24be(0xc)],'name':_0x45cc2b[_0x24be(0x39)]||_0x45cc2b[_0x24be(0xc)][_0x24be(0x3d)]('@')[0x0],'photoUrl':_0x45cc2b[_0x24be(0x3a)]||'','googleId':_0x45cc2b['id'],'accessToken':_0x4cd9e7[_0x24be(0x3e)],'idToken':_0x4cd9e7[_0x24be(0x3f)]});if(_0x1fc633['success']){if(_0x42e890[_0x24be(0x40)](_0x42e890[_0x24be(0x41)],'vDsXN')){const _0x4e967=_0x42e890[_0x24be(0x42)]['split']('|');let _0x464819=0x0;while(!![]){switch(_0x4e967[_0x464819++]){case'0':return{'success':!![],'user':{'id':(_0x42e890[_0x24be(0x43)](_0x14afc7=_0x1fc633[_0x24be(0x44)],null)||_0x42e890[_0x24be(0x45)](_0x14afc7,void 0x0)?void 0x0:_0x14afc7['id'])||'','email':_0x45cc2b[_0x24be(0xc)],'username':_0x45cc2b[_0x24be(0x39)]||_0x45cc2b[_0x24be(0xc)][_0x24be(0x3d)]('@')[0x0],'odeanId':_0x42e890[_0x24be(0x45)](_0x5af18b=_0x1fc633[_0x24be(0x44)],null)||_0x5af18b===void 0x0?void 0x0:_0x5af18b['odeanId']},'token':_0x1fc633[_0x24be(0x46)],'isNewUser':_0x1fc633[_0x24be(0x47)]||![]};case'1':var _0x14afc7,_0x5af18b;continue;case'2':await AsyncStorage[_0x24be(0x48)](_0x42e890[_0x24be(0x49)],_0x42e890[_0x24be(0x4a)]);continue;case'3':console[_0x24be(0x8)](_0x42e890['SkFxM']);continue;case'4':await AsyncStorage['setItem'](_0x42e890[_0x24be(0x4b)],_0x45cc2b[_0x24be(0xc)][_0x24be(0x3d)]('@')[0x0]);continue;case'5':await AsyncStorage[_0x24be(0x48)](_0x42e890['LQSSG'],_0x45cc2b['email']);continue;case'6':_0x1fc633[_0x24be(0x46)]&&await _0x42e890[_0x24be(0x4c)](storeJWT,_0x1fc633[_0x24be(0x46)]);continue;}break;}}else _0x46a737['webClientId']&&(_0x370ef9=_0x4189ac[_0x24be(0x2)]),_0x32e1c4[_0x24be(0x7)]&&(_0x4f79fa=_0x1e9972[_0x24be(0x7)]),_0x283ef2[_0x24be(0x8)](_0x24be(0x4d),{'webClientId':_0x3b8948,'iosClientId':_0x553e29});}else throw new Error(_0x1fc633[_0x24be(0x5)]||_0x42e890[_0x24be(0x4e)]);}}catch(_0x36c43f){console[_0x24be(0x6)]('❌\x20Google\x20Sign-In\x20error:',_0x36c43f);if(_0x42e890[_0x24be(0x4f)](_0x36c43f[_0x24be(0x50)],statusCodes[_0x24be(0x51)]))return _0x42e890[_0x24be(0x43)](_0x42e890[_0x24be(0x52)],_0x24be(0x53))?{'isSignedIn':!![],'user':_0x1f4b5e===null||_0x260a34===void 0x0?void 0x0:_0x44b026['user']}:{'success':![],'message':_0x42e890[_0x24be(0x54)],'cancelled':!![]};else{if(_0x36c43f[_0x24be(0x50)]===statusCodes[_0x24be(0x55)])return _0x24be(0x56)!==_0x24be(0x57)?{'success':![],'message':_0x42e890[_0x24be(0x58)]}:{'success':![],'message':_0x24be(0x1c)};else return _0x42e890[_0x24be(0x43)](_0x36c43f[_0x24be(0x50)],statusCodes['PLAY_SERVICES_NOT_AVAILABLE'])?{'success':![],'message':_0x42e890[_0x24be(0x2a)]}:_0x42e890['jfxbA'](_0x42e890['IoYOT'],_0x42e890[_0x24be(0x59)])?{'success':!![],'token':_0x5bbfad[_0x24be(0x46)],'user':_0x168f70[_0x24be(0x44)],'isNewUser':_0x5ead5c[_0x24be(0x47)]||![],'message':_0x42e890[_0x24be(0x5a)]}:{'success':![],'message':_0x36c43f[_0x24be(0x5)]||_0x42e890[_0x24be(0x5b)]};}}};const createUserAccount=async _0x46644f=>{const _0x56db19={'nHlNF':'Google\x20Sign-In\x20failed','hRgYz':function(_0x12136c,_0x300786){return _0x12136c===_0x300786;},'iPOGH':'Lrqwe','QfYoF':'QYwwd','yTWHC':'🔐\x20Creating/authenticating\x20user\x20account\x20for:','fsmTg':function(_0x570da7){return _0x570da7();},'wUOBb':function(_0x446d68,_0x5969a8,_0x42b4f4){return _0x446d68(_0x5969a8,_0x42b4f4);},'jzOwQ':_0x24be(0x5c),'WZWQV':_0x24be(0x5d),'iAmWC':_0x24be(0x5e),'bzllB':_0x24be(0x1),'bKOvI':_0x24be(0x5f)};try{if(_0x56db19[_0x24be(0x60)](_0x56db19[_0x24be(0x61)],_0x56db19[_0x24be(0x62)]))return{'success':![],'message':_0x2afdfe['message']||_0x56db19[_0x24be(0x63)]};else{console['log'](_0x56db19['yTWHC'],_0x46644f[_0x24be(0xc)]),console[_0x24be(0x8)](_0x24be(0x64));const _0x41b1e0=await _0x56db19[_0x24be(0x65)](getDeveloperAuthHeaders),_0x3f48ff=await _0x56db19[_0x24be(0x66)](fetch,API_CONFIG[_0x24be(0x67)]+_0x24be(0x68),{'method':'POST','headers':_0x41b1e0,'body':JSON[_0x24be(0x69)]({'credential':_0x46644f[_0x24be(0x3f)],'email':_0x46644f[_0x24be(0xc)],'name':_0x46644f[_0x24be(0x39)],'photoUrl':_0x46644f[_0x24be(0x6a)]})});console[_0x24be(0x8)](_0x56db19['jzOwQ'],_0x3f48ff['status']);const _0x55b4ff=await _0x3f48ff[_0x24be(0x6b)]();console['log'](_0x24be(0x6c),_0x55b4ff);if(_0x3f48ff['ok']&&_0x55b4ff[_0x24be(0x46)]){if(_0x56db19[_0x24be(0x60)](_0x56db19[_0x24be(0x6d)],_0x56db19[_0x24be(0x6d)]))return{'success':!![],'token':_0x55b4ff[_0x24be(0x46)],'user':_0x55b4ff[_0x24be(0x44)],'isNewUser':_0x55b4ff[_0x24be(0x47)]||![],'message':_0x56db19[_0x24be(0x6e)]};else _0x5b855f[_0x24be(0x8)]('ℹ️\x20Sign\x20out\x20not\x20needed\x20or\x20failed:',_0x3ecbf9);}else return{'success':![],'message':_0x55b4ff[_0x24be(0x5)]||_0x55b4ff[_0x24be(0x6)]||_0x56db19[_0x24be(0x6f)]};}}catch(_0x3d16df){return console['error'](_0x56db19[_0x24be(0x70)],_0x3d16df),{'success':![],'message':_0x3d16df[_0x24be(0x5)]||_0x24be(0x1a)};}};function _0x24be(_0x22b8a7,_0x24bed0){_0x22b8a7=_0x22b8a7-0x0;const _0x26498b=_0x22b8();let _0x58a162=_0x26498b[_0x22b8a7];return _0x58a162;}export const isGoogleSignedIn=async()=>{const _0x1e194b={'MtYsn':function(_0x38b7b6,_0x29a9cc){return _0x38b7b6!==_0x29a9cc;},'IVKyZ':function(_0x2da1f7,_0x4984ac){return _0x2da1f7===_0x4984ac;},'QfFEU':_0x24be(0x71)};try{const _0x33f6f8=await GoogleSignin[_0x24be(0x72)](),_0x52250d=_0x1e194b[_0x24be(0x73)](_0x33f6f8,null);if(_0x52250d)return{'isSignedIn':!![],'user':_0x1e194b[_0x24be(0x74)](_0x33f6f8,null)||_0x1e194b[_0x24be(0x74)](_0x33f6f8,void 0x0)?void 0x0:_0x33f6f8['user']};return{'isSignedIn':![]};}catch(_0x469515){return console['error'](_0x1e194b['QfFEU'],_0x469515),{'isSignedIn':![]};}};export const signOutFromGoogle=async()=>{const _0x257280={'QWeHu':'✅\x20Google\x20sign-out\x20successful'};try{return await GoogleSignin[_0x24be(0x28)](),console[_0x24be(0x8)](_0x257280[_0x24be(0x75)]),!![];}catch(_0x4f61a4){return console[_0x24be(0x6)](_0x24be(0x76),_0x4f61a4),![];}};function _0x22b8(){const _0x5969d6=['1030678346906-lovkuds2ouqmoc8eu5qpo98spa6edv4o.apps.googleusercontent.com','Failed\x20to\x20create\x20account','webClientId','nwUEQ','FLTMU','message','error','iosClientId','log','jNtLQ','profile','ZfquH','email','Google\x20Play\x20Services\x20not\x20available','uGNtZ','AKgNb','AstwI','🔄\x20Signed\x20out\x20to\x20ensure\x20fresh\x20consent','ffMgf','jJVEg','mUNsJ','👤\x20Google\x20user\x20data:','HlsQM','✅\x20User\x20account\x20created/authenticated\x20successfully','onairos_username','user_email','Failed\x20to\x20create\x20user\x20account','Google\x20Sign-In\x20was\x20cancelled','Google\x20Sign-In\x20is\x20already\x20in\x20progress','wEqlF','vFKmj','Google\x20Sign-In\x20failed','cnKoJ','jHmVj','🔗\x20Initiating\x20Google\x20Sign-In\x20for\x20user\x20authentication','dawLN','hasPlayServices','NPZWu','nAuCd','WZvVw','signOut','sQVdS','SEiAh','AcBwZ','eGoSa','ℹ️\x20Sign\x20out\x20not\x20needed\x20or\x20failed:','signIn','JrnPx','data','ONQMp','QKtup','tVuHg','mVDEO','EzJnc','configure','YbisM','ZsrMW','name','photo','getTokens','RuIBl','split','accessToken','idToken','XQdpx','aUaQZ','HqULu','NCOVd','user','KiMIv','token','isNewUser','setItem','eqasZ','zeyUI','EwAEM','IITrD','✅\x20Google\x20client\x20IDs\x20updated:','AltAC','letTh','code','SIGN_IN_CANCELLED','KPIsa','OGAWn','pazDb','IN_PROGRESS','qrNCn','gbXtA','dmstQ','VbSSu','SeTVK','URtyf','📡\x20Google\x20register\x20response\x20status:','mjSdp','Account\x20created/authenticated\x20successfully','❌\x20Error\x20creating\x20user\x20account:','hRgYz','iPOGH','QfYoF','nHlNF','🔐\x20Calling\x20generic\x20/register/google\x20endpoint...','fsmTg','wUOBb','BASE_URL','/register/google','stringify','photoUrl','json','🔗\x20Account\x20creation\x20response:','WZWQV','iAmWC','bzllB','bKOvI','❌\x20Error\x20checking\x20Google\x20sign-in\x20status:','getCurrentUser','MtYsn','IVKyZ','QWeHu','❌\x20Google\x20sign-out\x20error:'];_0x22b8=function(){return _0x5969d6;};return _0x22b8();}
1
+ /**
2
+ * Google Authentication Service
3
+ * Handles Google Sign-In for user authentication and account creation
4
+ */
5
+
6
+ import { GoogleSignin, statusCodes } from '@react-native-google-signin/google-signin';
7
+ import AsyncStorage from '@react-native-async-storage/async-storage';
8
+ import { API_CONFIG } from '../config/api';
9
+ import { getDeveloperAuthHeaders } from './apiKeyService';
10
+ // CRITICAL FIX: Use static imports to avoid Hermes transpilation issues
11
+ import { storeJWT } from './jwtStorageService';
12
+
13
+ // 🔑 Using the same client ID configuration as platform auth
14
+ let WEB_CLIENT_ID = '1030678346906-lovkuds2ouqmoc8eu5qpo98spa6edv4o.apps.googleusercontent.com';
15
+ let IOS_CLIENT_ID = '1030678346906-lovkuds2ouqmoc8eu5qpo98spa6edv4o.apps.googleusercontent.com';
16
+
17
+ /**
18
+ * Update Google OAuth client IDs for custom configurations
19
+ */
20
+ export const updateGoogleClientIds = config => {
21
+ if (config.webClientId) {
22
+ WEB_CLIENT_ID = config.webClientId;
23
+ }
24
+ if (config.iosClientId) {
25
+ IOS_CLIENT_ID = config.iosClientId;
26
+ }
27
+ console.log('✅ Google client IDs updated:', {
28
+ webClientId: WEB_CLIENT_ID,
29
+ iosClientId: IOS_CLIENT_ID
30
+ });
31
+ };
32
+
33
+ /**
34
+ * Initialize Google Sign-In for user authentication
35
+ */
36
+ const initializeGoogleAuth = () => {
37
+ GoogleSignin.configure({
38
+ webClientId: WEB_CLIENT_ID,
39
+ iosClientId: IOS_CLIENT_ID,
40
+ // Basic scopes for user authentication
41
+ scopes: ['openid', 'profile', 'email'],
42
+ // Enable offline access for refresh tokens
43
+ offlineAccess: true,
44
+ forceCodeForRefreshToken: true,
45
+ // Clear settings to avoid conflicts
46
+ hostedDomain: '',
47
+ accountName: ''
48
+ });
49
+ };
50
+
51
+ /**
52
+ * Sign in with Google and create/authenticate user account
53
+ */
54
+ export const signInWithGoogle = async () => {
55
+ try {
56
+ var _userInfo$data, _userInfo$data2;
57
+ console.log('🔗 Initiating Google Sign-In for user authentication');
58
+
59
+ // Initialize Google Sign-In
60
+ initializeGoogleAuth();
61
+
62
+ // Check if Google Play Services are available
63
+ await GoogleSignin.hasPlayServices();
64
+
65
+ // Sign out first to ensure fresh consent
66
+ try {
67
+ await GoogleSignin.signOut();
68
+ console.log('🔄 Signed out to ensure fresh consent');
69
+ } catch (signOutError) {
70
+ console.log('ℹ️ Sign out not needed or failed:', signOutError);
71
+ }
72
+
73
+ // Sign in with Google
74
+ const userInfo = await GoogleSignin.signIn();
75
+ console.log('✅ Google Sign-In successful:', (_userInfo$data = userInfo.data) === null || _userInfo$data === void 0 || (_userInfo$data = _userInfo$data.user) === null || _userInfo$data === void 0 ? void 0 : _userInfo$data.email);
76
+ const googleUser = (_userInfo$data2 = userInfo.data) === null || _userInfo$data2 === void 0 ? void 0 : _userInfo$data2.user;
77
+ if (!googleUser || !googleUser.email) {
78
+ throw new Error('No user data received from Google');
79
+ }
80
+ console.log('👤 Google user data:', {
81
+ email: googleUser.email,
82
+ name: googleUser.name,
83
+ photo: googleUser.photo,
84
+ id: googleUser.id
85
+ });
86
+
87
+ // Get tokens for account creation
88
+ const tokens = await GoogleSignin.getTokens();
89
+ console.log('🔑 Got Google tokens');
90
+
91
+ // Create user account on backend
92
+ const accountResult = await createUserAccount({
93
+ email: googleUser.email,
94
+ name: googleUser.name || googleUser.email.split('@')[0],
95
+ photoUrl: googleUser.photo || '',
96
+ googleId: googleUser.id,
97
+ accessToken: tokens.accessToken,
98
+ idToken: tokens.idToken
99
+ });
100
+ if (accountResult.success) {
101
+ var _accountResult$user, _accountResult$user2;
102
+ console.log('✅ User account created/authenticated successfully');
103
+
104
+ // Store authentication data
105
+ await AsyncStorage.setItem('user_email', googleUser.email);
106
+ // ✅ FIX: Always use email prefix for username (matches backend userName field)
107
+ // This ensures LinkedIn scraper can find the user by userName
108
+ await AsyncStorage.setItem('onairos_username', googleUser.email.split('@')[0]);
109
+ await AsyncStorage.setItem('auth_method', 'google');
110
+
111
+ // Use simplified JWT storage
112
+ if (accountResult.token) {
113
+ await storeJWT(accountResult.token);
114
+ }
115
+ return {
116
+ success: true,
117
+ user: {
118
+ id: ((_accountResult$user = accountResult.user) === null || _accountResult$user === void 0 ? void 0 : _accountResult$user.id) || '',
119
+ email: googleUser.email,
120
+ username: googleUser.name || googleUser.email.split('@')[0],
121
+ odeanId: (_accountResult$user2 = accountResult.user) === null || _accountResult$user2 === void 0 ? void 0 : _accountResult$user2.odeanId
122
+ },
123
+ token: accountResult.token,
124
+ isNewUser: accountResult.isNewUser || false
125
+ };
126
+ } else {
127
+ throw new Error(accountResult.message || 'Failed to create user account');
128
+ }
129
+ } catch (error) {
130
+ console.error('❌ Google Sign-In error:', error);
131
+
132
+ // Handle specific Google Sign-In errors
133
+ if (error.code === statusCodes.SIGN_IN_CANCELLED) {
134
+ return {
135
+ success: false,
136
+ message: 'Google Sign-In was cancelled',
137
+ cancelled: true
138
+ };
139
+ } else if (error.code === statusCodes.IN_PROGRESS) {
140
+ return {
141
+ success: false,
142
+ message: 'Google Sign-In is already in progress'
143
+ };
144
+ } else if (error.code === statusCodes.PLAY_SERVICES_NOT_AVAILABLE) {
145
+ return {
146
+ success: false,
147
+ message: 'Google Play Services not available'
148
+ };
149
+ } else {
150
+ return {
151
+ success: false,
152
+ message: error.message || 'Google Sign-In failed'
153
+ };
154
+ }
155
+ }
156
+ };
157
+
158
+ /**
159
+ * Create or authenticate user account on backend using generic SDK endpoint
160
+ * NOTE: This is generic SDK auth - does NOT create EnochUser
161
+ * Consuming apps should call /enoch/users/register after this if needed
162
+ */
163
+ const createUserAccount = async userData => {
164
+ try {
165
+ console.log('🔐 Creating/authenticating user account for:', userData.email);
166
+ console.log('🔐 Calling generic /register/google endpoint...');
167
+ const headers = await getDeveloperAuthHeaders();
168
+ const response = await fetch(`${API_CONFIG.BASE_URL}/register/google`, {
169
+ method: 'POST',
170
+ headers,
171
+ body: JSON.stringify({
172
+ credential: userData.idToken,
173
+ email: userData.email,
174
+ name: userData.name,
175
+ photoUrl: userData.photoUrl
176
+ })
177
+ });
178
+ console.log('📡 Google register response status:', response.status);
179
+ const responseData = await response.json();
180
+ console.log('🔗 Account creation response:', responseData);
181
+ if (response.ok && responseData.token) {
182
+ return {
183
+ success: true,
184
+ token: responseData.token,
185
+ user: responseData.user,
186
+ isNewUser: responseData.isNewUser || false,
187
+ message: 'Account created/authenticated successfully'
188
+ };
189
+ } else {
190
+ return {
191
+ success: false,
192
+ message: responseData.message || responseData.error || 'Failed to create account'
193
+ };
194
+ }
195
+ } catch (error) {
196
+ console.error('❌ Error creating user account:', error);
197
+ return {
198
+ success: false,
199
+ message: error.message || 'Failed to create user account'
200
+ };
201
+ }
202
+ };
203
+
204
+ /**
205
+ * Check if user is already signed in with Google
206
+ */
207
+ export const isGoogleSignedIn = async () => {
208
+ try {
209
+ const currentUser = await GoogleSignin.getCurrentUser();
210
+ const isSignedIn = currentUser !== null;
211
+ if (isSignedIn) {
212
+ return {
213
+ isSignedIn: true,
214
+ user: currentUser === null || currentUser === void 0 ? void 0 : currentUser.user
215
+ };
216
+ }
217
+ return {
218
+ isSignedIn: false
219
+ };
220
+ } catch (error) {
221
+ console.error('❌ Error checking Google sign-in status:', error);
222
+ return {
223
+ isSignedIn: false
224
+ };
225
+ }
226
+ };
227
+
228
+ /**
229
+ * Sign out from Google
230
+ */
231
+ export const signOutFromGoogle = async () => {
232
+ try {
233
+ await GoogleSignin.signOut();
234
+ console.log('✅ Google sign-out successful');
235
+ return true;
236
+ } catch (error) {
237
+ console.error('❌ Google sign-out error:', error);
238
+ return false;
239
+ }
240
+ };
241
+ //# sourceMappingURL=googleAuthService.js.map