@onairos/react-native 3.7.2 → 3.7.4

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 (237) hide show
  1. package/lib/commonjs/api/index.js +219 -9
  2. package/lib/commonjs/components/BodyText.js +27 -9
  3. package/lib/commonjs/components/BrandMark.js +111 -10
  4. package/lib/commonjs/components/CodeInput.js +120 -9
  5. package/lib/commonjs/components/EmailInput.js +30 -8
  6. package/lib/commonjs/components/GoogleButton.js +56 -9
  7. package/lib/commonjs/components/HeadingGroup.js +43 -9
  8. package/lib/commonjs/components/LLMDataInputModal.js +664 -14
  9. package/lib/commonjs/components/ModalHeader.js +99 -9
  10. package/lib/commonjs/components/ModalSheet.js +47 -9
  11. package/lib/commonjs/components/Onairos.js +380 -14
  12. package/lib/commonjs/components/OnairosButton.js +313 -13
  13. package/lib/commonjs/components/OnairosSignInButton.js +130 -12
  14. package/lib/commonjs/components/Overlay.js +465 -13
  15. package/lib/commonjs/components/PersonaImage.js +137 -10
  16. package/lib/commonjs/components/PersonaLoadingScreen.js +318 -12
  17. package/lib/commonjs/components/PersonalizationConsentScreen.js +467 -13
  18. package/lib/commonjs/components/PinCreationScreen.js +403 -12
  19. package/lib/commonjs/components/PinInput.js +464 -9
  20. package/lib/commonjs/components/PlatformConnectorsStep.js +1311 -23
  21. package/lib/commonjs/components/PlatformList.js +137 -10
  22. package/lib/commonjs/components/PlatformToggle.js +180 -9
  23. package/lib/commonjs/components/PrimaryButton.js +180 -10
  24. package/lib/commonjs/components/SignInMatchAnimation.js +197 -9
  25. package/lib/commonjs/components/SignInStep.js +345 -12
  26. package/lib/commonjs/components/UniversalOnboarding.js +2780 -30
  27. package/lib/commonjs/components/VerificationStep.js +176 -11
  28. package/lib/commonjs/components/WelcomeScreen.js +461 -22
  29. package/lib/commonjs/components/icons/Basicproficon.js +37 -8
  30. package/lib/commonjs/components/icons/Basicprofile.js +21 -8
  31. package/lib/commonjs/components/icons/Checkbox.js +21 -8
  32. package/lib/commonjs/components/icons/Checkmark.js +27 -8
  33. package/lib/commonjs/components/icons/Contentanalysis.js +21 -8
  34. package/lib/commonjs/components/icons/Contenticon.js +39 -8
  35. package/lib/commonjs/components/icons/EnochE.js +41 -8
  36. package/lib/commonjs/components/icons/Personalityicon.js +30 -8
  37. package/lib/commonjs/components/icons/Personalityprofile.js +21 -8
  38. package/lib/commonjs/components/icons/Personalitytraits.js +21 -8
  39. package/lib/commonjs/components/icons/Userpreferences.js +21 -8
  40. package/lib/commonjs/components/icons/index.js +84 -17
  41. package/lib/commonjs/components/onboarding/OAuthWebView.js +1754 -18
  42. package/lib/commonjs/components/onboarding/OnboardingHeader.js +74 -10
  43. package/lib/commonjs/components/onboarding/PinInput.js +283 -10
  44. package/lib/commonjs/components/onboarding/PlatformConnector.js +249 -11
  45. package/lib/commonjs/config/PLATFORM_APIS.md +849 -0
  46. package/lib/commonjs/config/api.js +56 -7
  47. package/lib/commonjs/constants/index.js +120 -7
  48. package/lib/commonjs/context/AuthContext.js +345 -10
  49. package/lib/commonjs/hooks/useConnectedAccounts.js +111 -9
  50. package/lib/commonjs/hooks/useConnections.js +102 -8
  51. package/lib/commonjs/hooks/useCredentials.js +178 -10
  52. package/lib/commonjs/hooks/useUserConnections.js +148 -10
  53. package/lib/commonjs/index.js +439 -34
  54. package/lib/commonjs/services/apiClient.js +298 -8
  55. package/lib/commonjs/services/biometricPinService.js +180 -8
  56. package/lib/commonjs/services/chatGPTConversationExtractor.js +155 -8
  57. package/lib/commonjs/services/chatGPTConversationService.js +275 -9
  58. package/lib/commonjs/services/claudeConversationExtractor.js +103 -8
  59. package/lib/commonjs/services/claudeConversationService.js +158 -9
  60. package/lib/commonjs/services/connectedAccountsService.js +310 -10
  61. package/lib/commonjs/services/googleAuthService.js +252 -11
  62. package/lib/commonjs/services/hingeDataExtractor.js +105 -8
  63. package/lib/commonjs/services/hingeDataService.js +150 -9
  64. package/lib/commonjs/services/imageCompressionService.js +260 -7
  65. package/lib/commonjs/services/instagramDataExtractor.js +126 -8
  66. package/lib/commonjs/services/instagramDataService.js +163 -9
  67. package/lib/commonjs/services/jwtStorageService.js +276 -7
  68. package/lib/commonjs/services/linkedinDOMExtractor.js +245 -7
  69. package/lib/commonjs/services/linkedinProfileService.js +222 -9
  70. package/lib/commonjs/services/linkedinScrapingService.js +230 -8
  71. package/lib/commonjs/services/llmDataStorage.js +294 -8
  72. package/lib/commonjs/services/mobileTrainingService.js +186 -8
  73. package/lib/commonjs/services/netflixDataExtractor.js +120 -8
  74. package/lib/commonjs/services/netflixDataService.js +198 -9
  75. package/lib/commonjs/services/pinEncryptionService.js +84 -8
  76. package/lib/commonjs/services/pinStorageUtils.js +105 -7
  77. package/lib/commonjs/services/platformAuthService.js +1484 -12
  78. package/lib/commonjs/services/sephoraDataExtractor.js +140 -8
  79. package/lib/commonjs/services/sephoraDataService.js +200 -9
  80. package/lib/commonjs/services/spotifyDataExtractor.js +148 -8
  81. package/lib/commonjs/services/spotifyDataService.js +241 -9
  82. package/lib/commonjs/services/storageService.js +404 -8
  83. package/lib/commonjs/services/telegramDataExtractor.js +115 -8
  84. package/lib/commonjs/services/telegramDataService.js +499 -9
  85. package/lib/commonjs/services/trainingApiHelpers.js +73 -7
  86. package/lib/commonjs/services/userConnectionsService.js +340 -10
  87. package/lib/commonjs/services/youtubeMigrationService.js +416 -10
  88. package/lib/commonjs/theme/index.js +250 -7
  89. package/lib/commonjs/types/ambient.d.js +2 -1
  90. package/lib/commonjs/types/declarations.d.js +2 -1
  91. package/lib/commonjs/types/index.js +6 -1
  92. package/lib/commonjs/types/node-fix.d.js +2 -1
  93. package/lib/commonjs/types/node-override.d.js +2 -1
  94. package/lib/commonjs/types/opacity.d.js +2 -1
  95. package/lib/commonjs/types.js +14 -1
  96. package/lib/commonjs/utils/Portal.js +98 -8
  97. package/lib/commonjs/utils/api.js +130 -9
  98. package/lib/commonjs/utils/assetRegistry.js +210 -35
  99. package/lib/commonjs/utils/auth.js +112 -9
  100. package/lib/commonjs/utils/connectorTests.js +613 -29
  101. package/lib/commonjs/utils/crypto.js +62 -8
  102. package/lib/commonjs/utils/debugHelper.js +64 -1
  103. package/lib/commonjs/utils/encryption.js +76 -7
  104. package/lib/commonjs/utils/eventUtils.js +288 -1
  105. package/lib/commonjs/utils/haptics.js +66 -9
  106. package/lib/commonjs/utils/imagePreloader.js +6 -1
  107. package/lib/commonjs/utils/networkDiagnostics.js +226 -8
  108. package/lib/commonjs/utils/onairosApi.js +350 -9
  109. package/lib/commonjs/utils/programmaticFlow.js +117 -9
  110. package/lib/commonjs/utils/retryHelper.js +220 -1
  111. package/lib/commonjs/utils/secureStorage.js +349 -10
  112. package/lib/commonjs/utils/webviewScripts/chatgpt.js +551 -1
  113. package/lib/commonjs/utils/webviewScripts/claude.js +376 -1
  114. package/lib/commonjs/utils/webviewScripts/hinge.js +411 -1
  115. package/lib/commonjs/utils/webviewScripts/index.js +698 -15
  116. package/lib/commonjs/utils/webviewScripts/instagram.js +454 -1
  117. package/lib/commonjs/utils/webviewScripts/linkedin.js +880 -1
  118. package/lib/commonjs/utils/webviewScripts/netflix.js +382 -1
  119. package/lib/commonjs/utils/webviewScripts/sephora.js +516 -1
  120. package/lib/commonjs/utils/webviewScripts/spotify.js +419 -1
  121. package/lib/commonjs/utils/webviewScripts/telegram.js +678 -1
  122. package/lib/module/api/index.js +211 -1
  123. package/lib/module/components/BodyText.js +20 -1
  124. package/lib/module/components/BrandMark.js +104 -1
  125. package/lib/module/components/CodeInput.js +113 -1
  126. package/lib/module/components/EmailInput.js +23 -1
  127. package/lib/module/components/GoogleButton.js +49 -1
  128. package/lib/module/components/HeadingGroup.js +36 -1
  129. package/lib/module/components/LLMDataInputModal.js +656 -7
  130. package/lib/module/components/ModalHeader.js +92 -1
  131. package/lib/module/components/ModalSheet.js +39 -1
  132. package/lib/module/components/Onairos.js +373 -1
  133. package/lib/module/components/OnairosButton.js +305 -1
  134. package/lib/module/components/OnairosSignInButton.js +121 -1
  135. package/lib/module/components/Overlay.js +456 -1
  136. package/lib/module/components/PersonaImage.js +129 -1
  137. package/lib/module/components/PersonaLoadingScreen.js +310 -1
  138. package/lib/module/components/PersonalizationConsentScreen.js +460 -1
  139. package/lib/module/components/PinCreationScreen.js +396 -1
  140. package/lib/module/components/PinInput.js +456 -1
  141. package/lib/module/components/PlatformConnectorsStep.js +1302 -6
  142. package/lib/module/components/PlatformList.js +129 -1
  143. package/lib/module/components/PlatformToggle.js +173 -1
  144. package/lib/module/components/PrimaryButton.js +172 -1
  145. package/lib/module/components/SignInMatchAnimation.js +189 -1
  146. package/lib/module/components/SignInStep.js +338 -1
  147. package/lib/module/components/UniversalOnboarding.js +2770 -1
  148. package/lib/module/components/VerificationStep.js +168 -1
  149. package/lib/module/components/WelcomeScreen.js +453 -1
  150. package/lib/module/components/icons/Basicproficon.js +30 -1
  151. package/lib/module/components/icons/Basicprofile.js +14 -1
  152. package/lib/module/components/icons/Checkbox.js +14 -1
  153. package/lib/module/components/icons/Checkmark.js +20 -1
  154. package/lib/module/components/icons/Contentanalysis.js +14 -1
  155. package/lib/module/components/icons/Contenticon.js +32 -1
  156. package/lib/module/components/icons/EnochE.js +34 -1
  157. package/lib/module/components/icons/Personalityicon.js +23 -1
  158. package/lib/module/components/icons/Personalityprofile.js +14 -1
  159. package/lib/module/components/icons/Personalitytraits.js +14 -1
  160. package/lib/module/components/icons/Userpreferences.js +14 -1
  161. package/lib/module/components/icons/index.js +13 -1
  162. package/lib/module/components/onboarding/OAuthWebView.js +1746 -1
  163. package/lib/module/components/onboarding/OnboardingHeader.js +66 -1
  164. package/lib/module/components/onboarding/PinInput.js +274 -1
  165. package/lib/module/components/onboarding/PlatformConnector.js +240 -1
  166. package/lib/module/config/PLATFORM_APIS.md +849 -0
  167. package/lib/module/config/api.js +47 -1
  168. package/lib/module/constants/index.js +114 -1
  169. package/lib/module/context/AuthContext.js +335 -1
  170. package/lib/module/hooks/useConnectedAccounts.js +106 -1
  171. package/lib/module/hooks/useConnections.js +95 -1
  172. package/lib/module/hooks/useCredentials.js +171 -6
  173. package/lib/module/hooks/useUserConnections.js +140 -1
  174. package/lib/module/index.js +172 -1
  175. package/lib/module/services/apiClient.js +295 -1
  176. package/lib/module/services/biometricPinService.js +169 -1
  177. package/lib/module/services/chatGPTConversationExtractor.js +149 -1
  178. package/lib/module/services/chatGPTConversationService.js +268 -1
  179. package/lib/module/services/claudeConversationExtractor.js +97 -1
  180. package/lib/module/services/claudeConversationService.js +151 -1
  181. package/lib/module/services/connectedAccountsService.js +293 -1
  182. package/lib/module/services/googleAuthService.js +241 -1
  183. package/lib/module/services/hingeDataExtractor.js +99 -1
  184. package/lib/module/services/hingeDataService.js +143 -1
  185. package/lib/module/services/imageCompressionService.js +250 -1
  186. package/lib/module/services/instagramDataExtractor.js +120 -1
  187. package/lib/module/services/instagramDataService.js +156 -1
  188. package/lib/module/services/jwtStorageService.js +257 -1
  189. package/lib/module/services/linkedinDOMExtractor.js +234 -1
  190. package/lib/module/services/linkedinProfileService.js +210 -1
  191. package/lib/module/services/linkedinScrapingService.js +219 -1
  192. package/lib/module/services/llmDataStorage.js +277 -1
  193. package/lib/module/services/mobileTrainingService.js +173 -1
  194. package/lib/module/services/netflixDataExtractor.js +114 -1
  195. package/lib/module/services/netflixDataService.js +191 -1
  196. package/lib/module/services/pinEncryptionService.js +74 -6
  197. package/lib/module/services/pinStorageUtils.js +93 -1
  198. package/lib/module/services/platformAuthService.js +1461 -1
  199. package/lib/module/services/sephoraDataExtractor.js +134 -1
  200. package/lib/module/services/sephoraDataService.js +193 -1
  201. package/lib/module/services/spotifyDataExtractor.js +142 -1
  202. package/lib/module/services/spotifyDataService.js +234 -1
  203. package/lib/module/services/storageService.js +383 -1
  204. package/lib/module/services/telegramDataExtractor.js +109 -1
  205. package/lib/module/services/telegramDataService.js +493 -1
  206. package/lib/module/services/trainingApiHelpers.js +67 -1
  207. package/lib/module/services/userConnectionsService.js +329 -1
  208. package/lib/module/services/youtubeMigrationService.js +405 -1
  209. package/lib/module/theme/index.js +245 -1
  210. package/lib/module/types.js +10 -1
  211. package/lib/module/utils/Portal.js +90 -1
  212. package/lib/module/utils/api.js +118 -1
  213. package/lib/module/utils/assetRegistry.js +200 -34
  214. package/lib/module/utils/auth.js +100 -1
  215. package/lib/module/utils/connectorTests.js +600 -27
  216. package/lib/module/utils/crypto.js +54 -1
  217. package/lib/module/utils/debugHelper.js +54 -1
  218. package/lib/module/utils/encryption.js +67 -1
  219. package/lib/module/utils/eventUtils.js +270 -1
  220. package/lib/module/utils/haptics.js +59 -8
  221. package/lib/module/utils/imagePreloader.js +3 -1
  222. package/lib/module/utils/networkDiagnostics.js +217 -1
  223. package/lib/module/utils/onairosApi.js +333 -1
  224. package/lib/module/utils/programmaticFlow.js +111 -1
  225. package/lib/module/utils/retryHelper.js +211 -1
  226. package/lib/module/utils/secureStorage.js +330 -6
  227. package/lib/module/utils/webviewScripts/chatgpt.js +545 -1
  228. package/lib/module/utils/webviewScripts/claude.js +370 -1
  229. package/lib/module/utils/webviewScripts/hinge.js +405 -1
  230. package/lib/module/utils/webviewScripts/index.js +434 -1
  231. package/lib/module/utils/webviewScripts/instagram.js +448 -1
  232. package/lib/module/utils/webviewScripts/linkedin.js +874 -1
  233. package/lib/module/utils/webviewScripts/netflix.js +376 -1
  234. package/lib/module/utils/webviewScripts/sephora.js +510 -1
  235. package/lib/module/utils/webviewScripts/spotify.js +413 -1
  236. package/lib/module/utils/webviewScripts/telegram.js +672 -1
  237. 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[_0x2d59(0x0)],getDeveloperAuthHeaders=()=>{const _0x3789f5={'KEvaY':'⚠️\x20SDK\x20not\x20initialized\x20-\x20using\x20basic\x20headers','OOtzy':function(_0x53dab8){return _0x53dab8();},'LaSHU':function(_0xe1556d,_0x2cdcb4){return _0xe1556d!==_0x2cdcb4;},'jJjtW':function(_0x44fe98,_0x3691db){return _0x44fe98!==_0x3691db;},'mqdgV':_0x2d59(0x1)};if(!isApiKeyInitialized())return console['warn'](_0x3789f5[_0x2d59(0x2)]),getApiHeaders();const _0x598dcf=_0x3789f5[_0x2d59(0x3)](getApiConfig);if(!(_0x3789f5['LaSHU'](_0x598dcf,null)&&_0x3789f5[_0x2d59(0x4)](_0x598dcf,void 0x0)&&_0x598dcf['apiKey']))return _0x3789f5['OOtzy'](getApiHeaders);return{..._0x3789f5[_0x2d59(0x3)](getApiHeaders),'Authorization':_0x2d59(0x5)+_0x598dcf[_0x2d59(0x6)],'X-SDK-Version':_0x3789f5[_0x2d59(0x7)],'X-SDK-Platform':'react-native'};};export const getConnectedAccountsLookup=async _0x142419=>{const _0x25e129={'CllpR':_0x2d59(0x8),'xmTNL':function(_0x447709,_0xa4c573,_0x55c4ee){return _0x447709(_0xa4c573,_0x55c4ee);},'zvotq':function(_0x1b88a3,_0x5771ed){return _0x1b88a3(_0x5771ed);},'IZzMx':function(_0x341f18,_0x4e9b49){return _0x341f18(_0x4e9b49);},'pNUbD':function(_0x9baf62){return _0x9baf62();},'aOWft':_0x2d59(0x9),'IkPyk':function(_0x4d5f33,_0x146c14){return _0x4d5f33>_0x146c14;},'iGMOf':'ℹ️\x20[NEW\x20API]\x20No\x20connected\x20accounts\x20found\x20for\x20user','BoJQd':_0x2d59(0xa)};try{console[_0x2d59(0xb)](_0x25e129[_0x2d59(0xc)],_0x142419);const _0x25b8f1=await getAuthToken(),_0xdfed97=await _0x25e129[_0x2d59(0xd)](fetch,API_BASE_URL+_0x2d59(0xe)+_0x25e129['zvotq'](encodeURIComponent,_0x142419),{'method':'GET','headers':_0x25b8f1?_0x25e129[_0x2d59(0xf)](getAuthHeaders,_0x25b8f1):_0x25e129[_0x2d59(0x10)](getDeveloperAuthHeaders)});if(_0xdfed97['ok']){const _0x316a6e=await _0xdfed97['json']();return console[_0x2d59(0xb)](_0x25e129[_0x2d59(0x11)],_0x316a6e),_0x316a6e[_0x2d59(0x12)]&&_0x316a6e[_0x2d59(0x13)]&&_0x25e129[_0x2d59(0x14)](_0x316a6e[_0x2d59(0x13)][_0x2d59(0x15)],0x0)?(console['log'](_0x2d59(0x16)+_0x316a6e['connectedAccounts'][_0x2d59(0x15)]+_0x2d59(0x17)),_0x316a6e['connectedAccounts']):(console[_0x2d59(0xb)](_0x25e129[_0x2d59(0x18)]),[]);}else return console[_0x2d59(0xb)]('⚠️\x20[NEW\x20API]\x20Response\x20not\x20OK:\x20'+_0xdfed97['status']+'\x20'+_0xdfed97['statusText']),[];}catch(_0x5e85d2){return console['log'](_0x25e129[_0x2d59(0x19)],_0x5e85d2),[];}};function _0x2d59(_0x61c21c,_0x2d5954){_0x61c21c=_0x61c21c-0x0;const _0x53019d=_0x61c2();let _0x4b0fe1=_0x53019d[_0x61c21c];return _0x4b0fe1;}export const getConnectedAccountsSmart=async(_0x6160fb,_0x5bfccd,_0x421814)=>{const _0x3b43c6={'ygxyL':'🧠\x20[SMART\x20API]\x20Available\x20identifiers:','PuOPS':_0x2d59(0x1a),'VajSx':function(_0x43a812,_0x1b3283){return _0x43a812(_0x1b3283);},'SeUsH':function(_0x1486df,_0x403459){return _0x1486df>_0x403459;},'XqzbV':'✅\x20[SMART\x20API]\x20Success\x20with\x20new\x20unified\x20lookup\x20via\x20email','zUJfl':_0x2d59(0x1b),'xcPTw':function(_0x196f2d,_0x282fdd){return _0x196f2d===_0x282fdd;},'bziDp':'🔄\x20[SMART\x20API]\x20Trying\x20old\x20API\x20with\x20email:','ILzhq':function(_0x54ebea,_0xada574){return _0x54ebea===_0xada574;},'tNDbj':_0x2d59(0x1c),'zAqrf':function(_0x59000c,_0x1a5465){return _0x59000c>_0x1a5465;}};console[_0x2d59(0xb)](_0x2d59(0x1d)),console[_0x2d59(0xb)](_0x3b43c6['ygxyL'],{'userEmail':_0x6160fb,'userId':_0x5bfccd,'username':_0x421814});if(_0x6160fb){console['log'](_0x3b43c6[_0x2d59(0x1e)],_0x6160fb);const _0x745c21=await _0x3b43c6[_0x2d59(0x1f)](getConnectedAccountsLookup,_0x6160fb);if(_0x3b43c6[_0x2d59(0x20)](_0x745c21[_0x2d59(0x15)],0x0))return console['log'](_0x3b43c6[_0x2d59(0x21)]),_0x745c21;console[_0x2d59(0xb)](_0x2d59(0x22));}console[_0x2d59(0xb)](_0x3b43c6['zUJfl']);let _0x5b9134=[];return _0x6160fb&&_0x3b43c6['xcPTw'](_0x5b9134[_0x2d59(0x15)],0x0)&&(console['log'](_0x3b43c6[_0x2d59(0x23)],_0x6160fb),_0x5b9134=await _0x3b43c6[_0x2d59(0x1f)](getConnectedAccountsByEmail,_0x6160fb)),_0x3b43c6['xcPTw'](_0x5b9134['length'],0x0)&&_0x5bfccd&&(console[_0x2d59(0xb)]('🔄\x20[SMART\x20API]\x20Trying\x20old\x20API\x20with\x20userId:',_0x5bfccd),_0x5b9134=await _0x3b43c6[_0x2d59(0x1f)](getConnectedAccountsByUserId,_0x5bfccd)),_0x3b43c6[_0x2d59(0x24)](_0x5b9134[_0x2d59(0x15)],0x0)&&_0x421814&&(console['log'](_0x3b43c6[_0x2d59(0x25)],_0x421814),_0x5b9134=await getConnectedAccountsByUsername(_0x421814)),_0x3b43c6['zAqrf'](_0x5b9134[_0x2d59(0x15)],0x0)?console[_0x2d59(0xb)](_0x2d59(0x26)+_0x5b9134[_0x2d59(0x15)]+_0x2d59(0x27)):console[_0x2d59(0xb)]('⚠️\x20[SMART\x20API]\x20No\x20connected\x20accounts\x20found\x20with\x20any\x20method'),_0x5b9134;};export const getConnectedAccountsByUsername=async _0x24ba11=>{const _0x291cf9={'HLtWH':function(_0x44e497){return _0x44e497();},'ZdtJF':_0x2d59(0x28),'sBVSD':function(_0x4baabe){return _0x4baabe();},'tegky':function(_0x411aa7,_0x449d88){return _0x411aa7!==_0x449d88;},'gEaFy':function(_0x1e473b,_0x58d29f){return _0x1e473b!==_0x58d29f;},'CmqWi':function(_0xe8f3de){return _0xe8f3de();},'AYWAX':function(_0x26b96d){return _0x26b96d();},'QwXms':function(_0x321397,_0x4f74f4){return _0x321397===_0x4f74f4;},'WQZvE':_0x2d59(0x29),'CKTWx':_0x2d59(0x2a),'TgjOR':function(_0x3666c6,_0x4ff597){return _0x3666c6(_0x4ff597);},'OWTHc':function(_0x8386b,_0x30b14c){return _0x8386b>_0x30b14c;},'rNmKZ':function(_0x294668,_0x113cc2){return _0x294668!==_0x113cc2;},'zCjEt':_0x2d59(0x2b),'bowIY':_0x2d59(0x2c),'dkSPX':_0x2d59(0x2d)};try{if(_0x291cf9[_0x2d59(0x2e)](_0x291cf9[_0x2d59(0x2f)],_0x291cf9[_0x2d59(0x2f)])){console[_0x2d59(0xb)](_0x291cf9[_0x2d59(0x30)],_0x24ba11);const _0x180cc7=await getAuthToken(),_0x5a0a21=await fetch(API_BASE_URL+_0x2d59(0x31)+_0x291cf9['TgjOR'](encodeURIComponent,_0x24ba11),{'method':'GET','headers':_0x180cc7?_0x291cf9[_0x2d59(0x32)](getAuthHeaders,_0x180cc7):_0x291cf9[_0x2d59(0x33)](getDeveloperAuthHeaders)});if(_0x5a0a21['ok']){const _0x2eff5d=await _0x5a0a21[_0x2d59(0x34)]();console['log'](_0x2d59(0x35),_0x2eff5d);if(_0x2eff5d[_0x2d59(0x12)]&&_0x2eff5d[_0x2d59(0x13)]&&_0x291cf9['OWTHc'](_0x2eff5d[_0x2d59(0x13)]['length'],0x0))return _0x2eff5d[_0x2d59(0x13)];}return console['log'](_0x2d59(0x36)),[];}else return _0x27be74[_0x2d59(0xb)](_0x2d59(0x37)),_0x1b399b;}catch(_0x5216bc){if(_0x291cf9['rNmKZ'](_0x291cf9[_0x2d59(0x38)],_0x291cf9[_0x2d59(0x39)]))return console['log'](_0x291cf9[_0x2d59(0x3a)],_0x5216bc),[];else{if(!_0x291cf9[_0x2d59(0x33)](_0x58f2ec))return _0x25b74e['warn'](_0x291cf9[_0x2d59(0x3b)]),_0xcac8ce();const _0x47210d=_0x291cf9[_0x2d59(0x3c)](_0x535179);if(!(_0x291cf9['tegky'](_0x47210d,null)&&_0x291cf9['gEaFy'](_0x47210d,void 0x0)&&_0x47210d[_0x2d59(0x6)]))return _0x291cf9[_0x2d59(0x3d)](_0x18218a);return{..._0x291cf9['AYWAX'](_0x4aa1ce),'Authorization':'Bearer\x20'+_0x47210d['apiKey'],'X-SDK-Version':_0x2d59(0x1),'X-SDK-Platform':'react-native'};}}};export const getConnectedAccountsByEmail=async _0x1dc27e=>{const _0x5af77d={'btqJk':function(_0x450280,_0x25cb85,_0x4b32a7){return _0x450280(_0x25cb85,_0x4b32a7);},'yogiE':function(_0xe8a69f,_0x50f4be){return _0xe8a69f(_0x50f4be);},'wQRJI':function(_0x2caafe){return _0x2caafe();},'Boiwr':'✅\x20[LEGACY]\x20Connected\x20accounts\x20fetched:','uikvN':function(_0x13bd81,_0x3abb13){return _0x13bd81>_0x3abb13;},'vIHcA':function(_0x3b362b,_0x191002){return _0x3b362b!==_0x191002;},'GFOTI':'ngZYk','RHQUJ':'LZrKh','NLBdq':_0x2d59(0x36),'cEDto':function(_0x1751a2,_0x357ac5){return _0x1751a2===_0x357ac5;},'WFurY':_0x2d59(0x3e),'IVJJH':_0x2d59(0x3f)};try{console[_0x2d59(0xb)]('🔍\x20[LEGACY]\x20Fetching\x20connected\x20accounts\x20for\x20email:',_0x1dc27e);const _0x3ae034=await getAuthToken(),_0x26cf92=await _0x5af77d[_0x2d59(0x40)](fetch,API_BASE_URL+'/connectedAccounts?email='+_0x5af77d[_0x2d59(0x41)](encodeURIComponent,_0x1dc27e),{'method':'GET','headers':_0x3ae034?_0x5af77d[_0x2d59(0x41)](getAuthHeaders,_0x3ae034):_0x5af77d[_0x2d59(0x42)](getDeveloperAuthHeaders)});if(_0x26cf92['ok']){const _0x2599c0=await _0x26cf92[_0x2d59(0x34)]();console['log'](_0x5af77d['Boiwr'],_0x2599c0);if(_0x2599c0[_0x2d59(0x12)]&&_0x2599c0['connectedAccounts']&&_0x5af77d[_0x2d59(0x43)](_0x2599c0[_0x2d59(0x13)]['length'],0x0))return _0x5af77d[_0x2d59(0x44)](_0x5af77d['GFOTI'],_0x5af77d['RHQUJ'])?_0x2599c0[_0x2d59(0x13)]:_0xb5a0ec[_0x2d59(0x13)];}return console[_0x2d59(0xb)](_0x5af77d[_0x2d59(0x45)]),[];}catch(_0x2c1f15){return _0x5af77d[_0x2d59(0x46)](_0x5af77d[_0x2d59(0x47)],_0x5af77d['IVJJH'])?(_0x47af89[_0x2d59(0xb)](_0x2d59(0x48)+_0x3acd98[_0x2d59(0x49)]+'\x20'+_0x57fb2b[_0x2d59(0x4a)]),[]):(console[_0x2d59(0xb)](_0x2d59(0x4b),_0x2c1f15),[]);}};export const getConnectedAccountsByUserId=async _0x1d1e09=>{const _0x5bb97e={'TquTx':'❌\x20[NEW\x20API]\x20Error\x20fetching\x20connected\x20accounts\x20via\x20lookup:','efcLV':'🔍\x20[LEGACY]\x20Fetching\x20connected\x20accounts\x20for\x20userId:','mTbzo':function(_0x291b0e,_0x41ae77,_0x53d39e){return _0x291b0e(_0x41ae77,_0x53d39e);},'pIuOq':function(_0x39ddad,_0x70df71){return _0x39ddad(_0x70df71);},'UFdXz':function(_0x5187d1){return _0x5187d1();},'ANBGT':_0x2d59(0x35),'lulJR':_0x2d59(0x4c),'ZMNpV':'pRGoi','zqlPa':_0x2d59(0x36),'Zzirt':_0x2d59(0x4d)};try{console[_0x2d59(0xb)](_0x5bb97e['efcLV'],_0x1d1e09);const _0x1e3434=await getAuthToken(),_0x8ab9d7=await _0x5bb97e[_0x2d59(0x4e)](fetch,API_BASE_URL+_0x2d59(0x4f)+_0x5bb97e['pIuOq'](encodeURIComponent,_0x1d1e09),{'method':'GET','headers':_0x1e3434?getAuthHeaders(_0x1e3434):_0x5bb97e[_0x2d59(0x50)](getDeveloperAuthHeaders)});if(_0x8ab9d7['ok']){const _0x1ec96a=await _0x8ab9d7['json']();console[_0x2d59(0xb)](_0x5bb97e[_0x2d59(0x51)],_0x1ec96a);if(_0x1ec96a[_0x2d59(0x12)]&&_0x1ec96a[_0x2d59(0x13)]&&_0x1ec96a['connectedAccounts'][_0x2d59(0x15)]>0x0)return _0x5bb97e[_0x2d59(0x52)]!==_0x5bb97e['ZMNpV']?_0x1ec96a['connectedAccounts']:(_0x3c273d[_0x2d59(0xb)](_0x5bb97e[_0x2d59(0x53)],_0xbb5adb),[]);}return console[_0x2d59(0xb)](_0x5bb97e[_0x2d59(0x54)]),[];}catch(_0x5a6ff2){return console[_0x2d59(0xb)](_0x5bb97e[_0x2d59(0x55)],_0x5a6ff2),[];}};export{getPlatformIconFromRegistry as getPlatformIcon}from'../utils/assetRegistry';function _0x61c2(){const _0x44db5b=['BASE_URL','3.0.72','KEvaY','OOtzy','jJjtW','Bearer\x20','apiKey','mqdgV','🔍\x20[NEW\x20API]\x20Fetching\x20connected\x20accounts\x20via\x20unified\x20lookup\x20for:','✅\x20[NEW\x20API]\x20Connected\x20accounts\x20fetched\x20successfully:','❌\x20[NEW\x20API]\x20Error\x20fetching\x20connected\x20accounts\x20via\x20lookup:','log','CllpR','xmTNL','/connectedAccounts/lookup/','IZzMx','pNUbD','aOWft','success','connectedAccounts','IkPyk','length','✅\x20[NEW\x20API]\x20Found\x20','\x20connected\x20accounts','iGMOf','BoJQd','🧠\x20[SMART\x20API]\x20Trying\x20new\x20unified\x20lookup\x20with\x20email:','🔄\x20[SMART\x20API]\x20Falling\x20back\x20to\x20old\x20API\x20methods...','🔄\x20[SMART\x20API]\x20Trying\x20old\x20API\x20with\x20username:','🧠\x20[SMART\x20API]\x20Starting\x20smart\x20connected\x20accounts\x20fetch...','PuOPS','VajSx','SeUsH','XqzbV','🔄\x20[SMART\x20API]\x20New\x20API\x20returned\x20no\x20results,\x20trying\x20fallbacks...','bziDp','ILzhq','tNDbj','✅\x20[SMART\x20API]\x20Success\x20with\x20old\x20API\x20fallback:\x20','\x20accounts','⚠️\x20SDK\x20not\x20initialized\x20-\x20using\x20basic\x20headers','Jpvuy','🔍\x20[LEGACY]\x20Fetching\x20connected\x20accounts\x20for\x20username:','lzhZH','pBPJB','❌\x20[LEGACY]\x20Error\x20fetching\x20connected\x20accounts\x20by\x20username:','QwXms','WQZvE','CKTWx','/connectedAccounts?username=','TgjOR','HLtWH','json','✅\x20[LEGACY]\x20Connected\x20accounts\x20fetched:','⚠️\x20[LEGACY]\x20API\x20response\x20not\x20successful\x20or\x20empty','✅\x20[SMART\x20API]\x20Success\x20with\x20new\x20unified\x20lookup\x20via\x20email','zCjEt','bowIY','dkSPX','ZdtJF','sBVSD','CmqWi','WJrwL','opkmR','btqJk','yogiE','wQRJI','uikvN','vIHcA','NLBdq','cEDto','WFurY','⚠️\x20[NEW\x20API]\x20Response\x20not\x20OK:\x20','status','statusText','❌\x20[LEGACY]\x20Error\x20fetching\x20connected\x20accounts\x20by\x20email:','kNsuI','❌\x20[LEGACY]\x20Error\x20fetching\x20connected\x20accounts\x20by\x20userId:','mTbzo','/connectedAccounts?userId=','UFdXz','ANBGT','lulJR','TquTx','zqlPa','Zzirt','youtube','#FF0000','#FF4500','linkedin','#0077B5','facebook','#1877F2','pinterest','email','#EA4335','twitter','#1DA1F2','farcaster','chatgpt','#10A37F','claude','#000000','gemini','google_ai','#7C3AED','#E1306C','sephora','telegram','netflix','#1DB954','toLowerCase','hdwTx','CvDDE','reddit','hDcHJ','vGtrT','vxvCF','instagram','vHydm','KdtQR','CNoSO','#E60023','aNUfY','vwWPf','HkUcb','mUlly','ttlxx','#8A63D2','openai','AznNq','eBczG','anthropic','#D4A574','itpex','IvZCk','#4285F4','rPgIq','nDznN','ZzfJO','BlMPf','#0088CC','sbwxu','uJEVM','#666666'];_0x61c2=function(){return _0x44db5b;};return _0x61c2();}export const getPlatformColor=_0x5e0570=>{const _0x2ea1f7={'hdwTx':_0x2d59(0x56),'CvDDE':_0x2d59(0x57),'hDcHJ':_0x2d59(0x58),'vGtrT':_0x2d59(0x59),'vxvCF':_0x2d59(0x5a),'vHydm':_0x2d59(0x5b),'KdtQR':_0x2d59(0x5c),'CNoSO':_0x2d59(0x5d),'BIEJH':'gmail','aNUfY':_0x2d59(0x5e),'vwWPf':_0x2d59(0x5f),'HkUcb':_0x2d59(0x60),'mUlly':_0x2d59(0x61),'ttlxx':_0x2d59(0x62),'sEWlw':_0x2d59(0x63),'AznNq':_0x2d59(0x64),'eBczG':_0x2d59(0x65),'FVyva':'grok','itpex':_0x2d59(0x66),'xPxUO':_0x2d59(0x67),'IvZCk':_0x2d59(0x68),'rPgIq':'hinge','nDznN':_0x2d59(0x69),'ZzfJO':_0x2d59(0x6a),'BlMPf':_0x2d59(0x6b),'tGeDC':_0x2d59(0x6c),'sbwxu':_0x2d59(0x6d),'uJEVM':'#E50914','OUbJq':'spotify','ipMkR':_0x2d59(0x6e)},_0x4bc61e=_0x5e0570[_0x2d59(0x6f)]();switch(_0x4bc61e){case _0x2ea1f7[_0x2d59(0x70)]:return _0x2ea1f7[_0x2d59(0x71)];case _0x2d59(0x72):return _0x2ea1f7[_0x2d59(0x73)];case _0x2ea1f7[_0x2d59(0x74)]:return _0x2ea1f7[_0x2d59(0x75)];case _0x2d59(0x76):return _0x2d59(0x6a);case _0x2ea1f7[_0x2d59(0x77)]:return _0x2ea1f7[_0x2d59(0x78)];case _0x2ea1f7[_0x2d59(0x79)]:return _0x2d59(0x7a);case _0x2ea1f7['BIEJH']:case _0x2ea1f7[_0x2d59(0x7b)]:return _0x2ea1f7[_0x2d59(0x7c)];case _0x2ea1f7[_0x2d59(0x7d)]:case'x':return _0x2ea1f7[_0x2d59(0x7e)];case _0x2ea1f7[_0x2d59(0x7f)]:return _0x2d59(0x80);case _0x2ea1f7['sEWlw']:case _0x2d59(0x81):return _0x2ea1f7[_0x2d59(0x82)];case _0x2ea1f7[_0x2d59(0x83)]:case _0x2d59(0x84):return _0x2d59(0x85);case _0x2ea1f7['FVyva']:return _0x2ea1f7[_0x2d59(0x86)];case _0x2ea1f7['xPxUO']:case _0x2ea1f7[_0x2d59(0x87)]:return _0x2d59(0x88);case _0x2ea1f7[_0x2d59(0x89)]:return _0x2ea1f7[_0x2d59(0x8a)];case _0x2d59(0x76):return _0x2ea1f7[_0x2d59(0x8b)];case _0x2ea1f7[_0x2d59(0x8c)]:return _0x2ea1f7[_0x2d59(0x86)];case _0x2ea1f7['tGeDC']:return _0x2d59(0x8d);case _0x2ea1f7[_0x2d59(0x8e)]:return _0x2ea1f7[_0x2d59(0x8f)];case _0x2ea1f7['OUbJq']:return _0x2ea1f7['ipMkR'];default:return _0x2d59(0x90);}};
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=_0x5019(0x0),IOS_CLIENT_ID=_0x5019(0x0);function _0x5019(_0x4a54da,_0x5019be){_0x4a54da=_0x4a54da-0x0;const _0x10ab90=_0x4a54();let _0x5868fd=_0x10ab90[_0x4a54da];return _0x5868fd;}export const updateGoogleClientIds=_0x463c60=>{const _0x5d90ef={'NRUBo':_0x5019(0x1)};_0x463c60[_0x5019(0x2)]&&(WEB_CLIENT_ID=_0x463c60[_0x5019(0x2)]),_0x463c60[_0x5019(0x3)]&&(IOS_CLIENT_ID=_0x463c60[_0x5019(0x3)]),console[_0x5019(0x4)](_0x5d90ef[_0x5019(0x5)],{'webClientId':WEB_CLIENT_ID,'iosClientId':IOS_CLIENT_ID});};function _0x4a54(){const _0x1e0bc8=['1030678346906-lovkuds2ouqmoc8eu5qpo98spa6edv4o.apps.googleusercontent.com','✅\x20Google\x20client\x20IDs\x20updated:','webClientId','iosClientId','log','NRUBo','profile','email','configure','EabAf','Ejumf','Google\x20Sign-In\x20failed','ZyNBF','🔗\x20Initiating\x20Google\x20Sign-In\x20for\x20user\x20authentication','🔄\x20Signed\x20out\x20to\x20ensure\x20fresh\x20consent','ℹ️\x20Sign\x20out\x20not\x20needed\x20or\x20failed:','kyUyO','👤\x20Google\x20user\x20data:','3|4|1|0|5|2|6','onairos_username','user_email','✅\x20User\x20account\x20created/authenticated\x20successfully','auth_method','gRWKv','Failed\x20to\x20create\x20user\x20account','jkRzb','Google\x20Sign-In\x20was\x20cancelled','Google\x20Sign-In\x20is\x20already\x20in\x20progress','Google\x20Play\x20Services\x20not\x20available','cJfxx','WtoIx','rTphy','signOut','CeWEw','UKgOK','✅\x20Google\x20Sign-In\x20successful:','pACEm','data','gHrtz','user','YQkDw','NmPhc','fkFTI','No\x20user\x20data\x20received\x20from\x20Google','ofhFb','name','photo','getTokens','🔑\x20Got\x20Google\x20tokens','hEtaf','split','accessToken','idToken','success','setItem','HaWfu','qXAGg','token','hpVlg','iueHO','google','isNewUser','hyBCc','message','pSqle','mAjfR','MoPgT','YsMfl','error','OqVvp','Ntnit','code','SIGN_IN_CANCELLED','jUsfV','IN_PROGRESS','EeFpe','PLAY_SERVICES_NOT_AVAILABLE','WYzvV','siimJ','🔐\x20Calling\x20generic\x20/register/google\x20endpoint...','🔗\x20Account\x20creation\x20response:','Account\x20created/authenticated\x20successfully','Failed\x20to\x20create\x20account','❌\x20Error\x20creating\x20user\x20account:','🔐\x20Creating/authenticating\x20user\x20account\x20for:','ffoQX','ekGqM','BASE_URL','/register/google','stringify','iUFoF','status','json','zIODx','OTefU','DGpuq','ffoKX','BCOVZ','qeYtE','getCurrentUser','UASVO','QJwGR','MEURf','ueIVT','❌\x20Error\x20checking\x20Google\x20sign-in\x20status:','iZCNU','❌\x20Google\x20sign-out\x20error:','cefML','JMbHn','umgfF'];_0x4a54=function(){return _0x1e0bc8;};return _0x4a54();}const initializeGoogleAuth=()=>{const _0x58b9e0={'pXxTg':'openid','EabAf':_0x5019(0x6),'Ejumf':_0x5019(0x7)};GoogleSignin[_0x5019(0x8)]({'webClientId':WEB_CLIENT_ID,'iosClientId':IOS_CLIENT_ID,'scopes':[_0x58b9e0['pXxTg'],_0x58b9e0[_0x5019(0x9)],_0x58b9e0[_0x5019(0xa)]],'offlineAccess':!![],'forceCodeForRefreshToken':!![],'hostedDomain':'','accountName':''});};export const signInWithGoogle=async()=>{const _0x247065={'fkFTI':_0x5019(0xb),'mAjfR':'No\x20user\x20data\x20received\x20from\x20Google','pACEm':function(_0x3da9cd,_0x4a0a72){return _0x3da9cd===_0x4a0a72;},'OqVvp':'❌\x20Error\x20checking\x20Google\x20sign-in\x20status:','kKBSM':_0x5019(0x1),'WsKth':'VTKuH','WtoIx':_0x5019(0xc),'rTphy':_0x5019(0xd),'CeWEw':_0x5019(0xe),'UKgOK':_0x5019(0xf),'gHrtz':function(_0x5a24cf,_0xc26c67){return _0x5a24cf===_0xc26c67;},'YQkDw':function(_0x126966,_0x3e14a8){return _0x126966===_0x3e14a8;},'NmPhc':_0x5019(0x10),'ofhFb':_0x5019(0x11),'hEtaf':function(_0x1bd3c1,_0x446902){return _0x1bd3c1(_0x446902);},'PtiEJ':_0x5019(0x12),'HaWfu':_0x5019(0x13),'qXAGg':_0x5019(0x14),'hpVlg':_0x5019(0x15),'iueHO':_0x5019(0x16),'hyBCc':_0x5019(0x17),'pSqle':_0x5019(0x18),'MoPgT':function(_0xd3849f,_0x14beca){return _0xd3849f!==_0x14beca;},'YsMfl':_0x5019(0x19),'Ntnit':function(_0x5e93ad,_0x15687d){return _0x5e93ad===_0x15687d;},'jUsfV':_0x5019(0x1a),'EeFpe':_0x5019(0x1b),'WYzvV':_0x5019(0x1c),'siimJ':_0x5019(0x1d)};try{if(_0x247065['WsKth']!==_0x247065[_0x5019(0x1e)]){var _0x24584d,_0x48f371;console[_0x5019(0x4)](_0x247065[_0x5019(0x1f)]),initializeGoogleAuth(),await GoogleSignin['hasPlayServices']();try{await GoogleSignin[_0x5019(0x20)](),console[_0x5019(0x4)](_0x247065[_0x5019(0x21)]);}catch(_0x265e44){console[_0x5019(0x4)](_0x247065[_0x5019(0x22)],_0x265e44);}const _0x3050be=await GoogleSignin['signIn']();console[_0x5019(0x4)](_0x5019(0x23),_0x247065[_0x5019(0x24)](_0x24584d=_0x3050be[_0x5019(0x25)],null)||_0x24584d===void 0x0||_0x247065[_0x5019(0x26)](_0x24584d=_0x24584d[_0x5019(0x27)],null)||_0x247065[_0x5019(0x24)](_0x24584d,void 0x0)?void 0x0:_0x24584d[_0x5019(0x7)]);const _0x510b10=_0x247065[_0x5019(0x28)](_0x48f371=_0x3050be['data'],null)||_0x247065[_0x5019(0x24)](_0x48f371,void 0x0)?void 0x0:_0x48f371[_0x5019(0x27)];if(!_0x510b10||!_0x510b10[_0x5019(0x7)]){if(_0x247065[_0x5019(0x29)]!==_0x5019(0x10))return{'success':![],'message':_0x17469d['message']||_0x247065[_0x5019(0x2a)]};else throw new Error(_0x5019(0x2b));}console[_0x5019(0x4)](_0x247065[_0x5019(0x2c)],{'email':_0x510b10['email'],'name':_0x510b10[_0x5019(0x2d)],'photo':_0x510b10[_0x5019(0x2e)],'id':_0x510b10['id']});const _0x27e8fd=await GoogleSignin[_0x5019(0x2f)]();console[_0x5019(0x4)](_0x5019(0x30));const _0x3808ee=await _0x247065[_0x5019(0x31)](createUserAccount,{'email':_0x510b10[_0x5019(0x7)],'name':_0x510b10[_0x5019(0x2d)]||_0x510b10[_0x5019(0x7)][_0x5019(0x32)]('@')[0x0],'photoUrl':_0x510b10[_0x5019(0x2e)]||'','googleId':_0x510b10['id'],'accessToken':_0x27e8fd[_0x5019(0x33)],'idToken':_0x27e8fd[_0x5019(0x34)]});if(_0x3808ee[_0x5019(0x35)]){const _0x9a024f=_0x247065['PtiEJ'][_0x5019(0x32)]('|');let _0x581101=0x0;while(!![]){switch(_0x9a024f[_0x581101++]){case'0':await AsyncStorage[_0x5019(0x36)](_0x247065[_0x5019(0x37)],_0x510b10['email']['split']('@')[0x0]);continue;case'1':await AsyncStorage['setItem'](_0x247065[_0x5019(0x38)],_0x510b10['email']);continue;case'2':_0x3808ee[_0x5019(0x39)]&&await _0x247065['hEtaf'](storeJWT,_0x3808ee[_0x5019(0x39)]);continue;case'3':var _0x5e4e79,_0x450ef8;continue;case'4':console[_0x5019(0x4)](_0x247065[_0x5019(0x3a)]);continue;case'5':await AsyncStorage[_0x5019(0x36)](_0x247065[_0x5019(0x3b)],_0x5019(0x3c));continue;case'6':return{'success':!![],'user':{'id':((_0x5e4e79=_0x3808ee[_0x5019(0x27)])===null||_0x5e4e79===void 0x0?void 0x0:_0x5e4e79['id'])||'','email':_0x510b10[_0x5019(0x7)],'username':_0x510b10['name']||_0x510b10[_0x5019(0x7)]['split']('@')[0x0],'odeanId':(_0x450ef8=_0x3808ee['user'])===null||_0x450ef8===void 0x0?void 0x0:_0x450ef8['odeanId']},'token':_0x3808ee['token'],'isNewUser':_0x3808ee[_0x5019(0x3d)]||![]};}break;}}else{if(_0x247065[_0x5019(0x24)](_0x247065[_0x5019(0x3e)],_0x247065[_0x5019(0x3e)]))throw new Error(_0x3808ee[_0x5019(0x3f)]||_0x247065[_0x5019(0x40)]);else throw new _0x56b103(_0x247065[_0x5019(0x41)]);}}else return{'isSignedIn':!![],'user':_0x247065[_0x5019(0x24)](_0x3cbdfd,null)||_0x247065[_0x5019(0x24)](_0x33b278,void 0x0)?void 0x0:_0x5782ad[_0x5019(0x27)]};}catch(_0x28cd32){if(_0x247065[_0x5019(0x42)](_0x5019(0x19),_0x247065[_0x5019(0x43)]))return _0x66a894[_0x5019(0x44)](_0x247065[_0x5019(0x45)],_0x15e5f1),{'isSignedIn':![]};else{console[_0x5019(0x44)]('❌\x20Google\x20Sign-In\x20error:',_0x28cd32);if(_0x247065[_0x5019(0x46)](_0x28cd32[_0x5019(0x47)],statusCodes[_0x5019(0x48)]))return{'success':![],'message':_0x247065[_0x5019(0x49)],'cancelled':!![]};else{if(_0x28cd32['code']===statusCodes[_0x5019(0x4a)])return{'success':![],'message':_0x247065[_0x5019(0x4b)]};else{if(_0x247065[_0x5019(0x24)](_0x28cd32[_0x5019(0x47)],statusCodes[_0x5019(0x4c)]))return{'success':![],'message':_0x247065[_0x5019(0x4d)]};else{if(_0x5019(0x1d)!==_0x247065[_0x5019(0x4e)])_0x53c5e2[_0x5019(0x2)]&&(_0x128554=_0x4d74b5['webClientId']),_0x1da69f[_0x5019(0x3)]&&(_0x2171dc=_0x461920['iosClientId']),_0x19ed51['log'](_0x247065['kKBSM'],{'webClientId':_0x5a0f1f,'iosClientId':_0x26429a});else return{'success':![],'message':_0x28cd32[_0x5019(0x3f)]||_0x247065[_0x5019(0x2a)]};}}}}}};const createUserAccount=async _0x4a9503=>{const _0x187347={'ffoQX':_0x5019(0x4f),'IuiCH':function(_0x29aa1c){return _0x29aa1c();},'ekGqM':function(_0x879f15,_0x3f824e,_0x47433f){return _0x879f15(_0x3f824e,_0x47433f);},'iUFoF':'📡\x20Google\x20register\x20response\x20status:','zIODx':_0x5019(0x50),'OTefU':_0x5019(0x51),'DGpuq':_0x5019(0x52),'ffoKX':_0x5019(0x53),'BCOVZ':_0x5019(0x18)};try{console[_0x5019(0x4)](_0x5019(0x54),_0x4a9503['email']),console['log'](_0x187347[_0x5019(0x55)]);const _0x15c66f=await _0x187347['IuiCH'](getDeveloperAuthHeaders),_0x303095=await _0x187347[_0x5019(0x56)](fetch,API_CONFIG[_0x5019(0x57)]+_0x5019(0x58),{'method':'POST','headers':_0x15c66f,'body':JSON[_0x5019(0x59)]({'credential':_0x4a9503[_0x5019(0x34)],'email':_0x4a9503[_0x5019(0x7)],'name':_0x4a9503[_0x5019(0x2d)],'photoUrl':_0x4a9503['photoUrl']})});console[_0x5019(0x4)](_0x187347[_0x5019(0x5a)],_0x303095[_0x5019(0x5b)]);const _0x498071=await _0x303095[_0x5019(0x5c)]();return console['log'](_0x187347[_0x5019(0x5d)],_0x498071),_0x303095['ok']&&_0x498071['token']?{'success':!![],'token':_0x498071[_0x5019(0x39)],'user':_0x498071[_0x5019(0x27)],'isNewUser':_0x498071['isNewUser']||![],'message':_0x187347[_0x5019(0x5e)]}:{'success':![],'message':_0x498071[_0x5019(0x3f)]||_0x498071[_0x5019(0x44)]||_0x187347[_0x5019(0x5f)]};}catch(_0x4c0a05){return console[_0x5019(0x44)](_0x187347[_0x5019(0x60)],_0x4c0a05),{'success':![],'message':_0x4c0a05[_0x5019(0x3f)]||_0x187347[_0x5019(0x61)]};}};export const isGoogleSignedIn=async()=>{const _0x42c9af={'ueIVT':_0x5019(0x51),'UASVO':function(_0xeb8f33,_0x1fbd3b){return _0xeb8f33!==_0x1fbd3b;},'QJwGR':function(_0x15c32b,_0x595e0e){return _0x15c32b===_0x595e0e;},'vlPRg':function(_0x1d77f1,_0xd8b9cb){return _0x1d77f1===_0xd8b9cb;},'MEURf':_0x5019(0x62),'tzWwf':'DhBJj'};try{const _0x202860=await GoogleSignin[_0x5019(0x63)](),_0x2f2592=_0x42c9af[_0x5019(0x64)](_0x202860,null);if(_0x2f2592)return{'isSignedIn':!![],'user':_0x202860===null||_0x42c9af[_0x5019(0x65)](_0x202860,void 0x0)?void 0x0:_0x202860['user']};return{'isSignedIn':![]};}catch(_0x494e64){return _0x42c9af['vlPRg'](_0x42c9af[_0x5019(0x66)],_0x42c9af['tzWwf'])?{'success':!![],'token':_0x45776d['token'],'user':_0x23f8c8['user'],'isNewUser':_0xacc5d5['isNewUser']||![],'message':_0x42c9af[_0x5019(0x67)]}:(console[_0x5019(0x44)](_0x5019(0x68),_0x494e64),{'isSignedIn':![]});}};export const signOutFromGoogle=async()=>{const _0x59d1a9={'cefML':function(_0x20f396,_0x4c6bab){return _0x20f396!==_0x4c6bab;},'JMbHn':_0x5019(0x69),'umgfF':_0x5019(0x6a)};try{return _0x59d1a9[_0x5019(0x6b)](_0x59d1a9[_0x5019(0x6c)],_0x59d1a9[_0x5019(0x6c)])?{'success':![],'message':_0x5019(0x1c)}:(await GoogleSignin['signOut'](),console[_0x5019(0x4)]('✅\x20Google\x20sign-out\x20successful'),!![]);}catch(_0x193110){return console[_0x5019(0x44)](_0x59d1a9[_0x5019(0x6d)],_0x193110),![];}};
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