@onairos/react-native 3.7.2 → 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 (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 +116 -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 +109 -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,120 @@
1
- import{storeInstagramData}from'./instagramDataService';import{Alert}from'react-native';function _0x2831(_0x89556b,_0x28311c){_0x89556b=_0x89556b-0x0;const _0x2129a0=_0x8955();let _0x4629bb=_0x2129a0[_0x89556b];return _0x4629bb;}function _0x8955(){const _0xc18860=['save','EjtoX','⚠️\x20[INSTAGRAM_EXTRACTOR]\x20Invalid\x20save:','rzXMd','⚠️\x20[INSTAGRAM_EXTRACTOR]\x20Invalid\x20like:','❌\x20[INSTAGRAM_EXTRACTOR]\x20Unexpected\x20error\x20during\x20export:','Failed\x20to\x20connect\x20to\x20the\x20data\x20storage\x20service.\x20Please\x20check\x20your\x20network\x20connection.','default','JLWyy','🚀\x20[INSTAGRAM_EXTRACTOR]\x20Initiating\x20data\x20export','👤\x20[INSTAGRAM_EXTRACTOR]\x20Username:','📊\x20[INSTAGRAM_EXTRACTOR]\x20Collections:','NUHBu','📡\x20[INSTAGRAM_EXTRACTOR]\x20Sending\x20to\x20backend...','✅\x20[INSTAGRAM_EXTRACTOR]\x20Export\x20completed\x20successfully','❌\x20[INSTAGRAM_EXTRACTOR]\x20Backend\x20storage\x20failed:','Export\x20Failed','Export\x20Error','qaTRb','oQXtS','KFdBT','kwWfy','ZBznm','kAPZL','XhVcP','WSeyw','PrmoS','qDnsh','log','aIQaB','📊\x20[INSTAGRAM_EXTRACTOR]\x20Saves:','total_saves','❌\x20[INSTAGRAM_EXTRACTOR]\x20Username\x20is\x20required','alert','Error','Username\x20is\x20required\x20to\x20export\x20Instagram\x20data.','otHsj','kvtCQ','XKVKU','likes','length','PdQuN','saves','collections','HuAJj','caykJ','type','warn','buZAF','TEYPv','BoiSY','ORiEu','XSPYB','CrByY','filter','name','⚠️\x20[INSTAGRAM_EXTRACTOR]\x20Invalid\x20collection:','sTeXn','jcpGH','YyBqn','ifCpx','vfcpU','ltHWP','RcXHv','XQQZJ','qbZlB','xYghz','⚠️\x20[INSTAGRAM_EXTRACTOR]\x20Filtered\x20out\x20','\x20invalid\x20items','userId','success','isjFd','error','gFiEw','GoGHP','An\x20unknown\x20error\x20occurred\x20during\x20data\x20storage.','jsblM','YgOlK','BJKBQ','OBwkv'];_0x8955=function(){return _0xc18860;};return _0x8955();}export const useInstagramDataExtractor=()=>{const _0x2806f6={'KusHX':'like','PdQuN':function(_0x4184e0,_0x1069f4){return _0x4184e0===_0x1069f4;},'TEYPv':_0x2831(0x0),'XhVcP':function(_0x112858,_0x13d11b){return _0x112858===_0x13d11b;},'BoiSY':_0x2831(0x1),'ORiEu':_0x2831(0x2),'qaTRb':function(_0x339c5a,_0x232331){return _0x339c5a===_0x232331;},'oQXtS':function(_0x441d92,_0x1714c9){return _0x441d92!==_0x1714c9;},'KFdBT':_0x2831(0x3),'kwWfy':_0x2831(0x4),'ZBznm':_0x2831(0x5),'kAPZL':_0x2831(0x6),'otHsj':_0x2831(0x7),'WSeyw':_0x2831(0x8),'PrmoS':_0x2831(0x9),'qDnsh':_0x2831(0xa),'aIQaB':'📊\x20[INSTAGRAM_EXTRACTOR]\x20Likes:','cpZMh':_0x2831(0xb),'kvtCQ':function(_0x62fc7f,_0x7d2a06){return _0x62fc7f+_0x7d2a06;},'XKVKU':function(_0x16b880,_0x51fbc2){return _0x16b880===_0x51fbc2;},'RcXHv':function(_0x1be955,_0x785930){return _0x1be955===_0x785930;},'sTeXn':function(_0x959dc7,_0x899bbe){return _0x959dc7-_0x899bbe;},'jcpGH':function(_0x142f08,_0x459078){return _0x142f08+_0x459078;},'YyBqn':function(_0x5d2400,_0x466365){return _0x5d2400-_0x466365;},'ifCpx':function(_0x1afbef,_0x2261d8){return _0x1afbef===_0x2261d8;},'vfcpU':function(_0x42aba2,_0x591c41){return _0x42aba2===_0x591c41;},'ltHWP':function(_0x40d20a,_0x289c34){return _0x40d20a===_0x289c34;},'XQQZJ':function(_0x2e9bea,_0x387c99){return _0x2e9bea>_0x387c99;},'qbZlB':_0x2831(0xc),'PMulG':_0x2831(0xd),'isjFd':_0x2831(0xe),'OjwlH':'📊\x20[INSTAGRAM_EXTRACTOR]\x20Backend\x20response:','gFiEw':_0x2831(0xf),'GoGHP':_0x2831(0x10),'jsblM':_0x2831(0x11)},_0x1812ba=async(_0x192b42,_0x41a740)=>{const _0x5d7bd9={'WgEAj':function(_0x41e495,_0x4742c8){return _0x2806f6[_0x2831(0x12)](_0x41e495,_0x4742c8);},'HuAJj':function(_0xcf918e,_0x1c8e8){return _0x2806f6[_0x2831(0x13)](_0xcf918e,_0x1c8e8);},'caykJ':_0x2806f6[_0x2831(0x14)],'buZAF':_0x2806f6[_0x2831(0x15)],'YgOlK':_0x2806f6[_0x2831(0x16)],'dTaiy':_0x2831(0x11),'BJKBQ':_0x2806f6[_0x2831(0x17)],'OBwkv':_0x2806f6['otHsj']};if(_0x2806f6[_0x2831(0x18)](_0x2806f6[_0x2831(0x19)],_0x2806f6[_0x2831(0x19)])){var _0x314f83,_0x4c43b3,_0x2a9416,_0x19d785,_0x156cbd,_0x4a2047;console['log'](_0x2806f6[_0x2831(0x1a)]),console['log'](_0x2806f6[_0x2831(0x1b)],_0x192b42),console[_0x2831(0x1c)](_0x2806f6[_0x2831(0x1d)],_0x41a740['total_likes']),console[_0x2831(0x1c)](_0x2831(0x1e),_0x41a740[_0x2831(0x1f)]),console[_0x2831(0x1c)](_0x2806f6['cpZMh'],_0x41a740['total_collections']);if(!_0x192b42)return console['error'](_0x2831(0x20)),Alert[_0x2831(0x21)](_0x2831(0x22),_0x2831(0x23),[{'text':'OK','style':_0x2806f6[_0x2831(0x24)]}]),![];const _0x220e6e=_0x2806f6['kvtCQ'](_0x2806f6[_0x2831(0x25)]((_0x2806f6[_0x2831(0x26)](_0x314f83=_0x41a740[_0x2831(0x27)],null)||_0x2806f6[_0x2831(0x12)](_0x314f83,void 0x0)?void 0x0:_0x314f83[_0x2831(0x28)])||0x0,(_0x2806f6[_0x2831(0x29)](_0x4c43b3=_0x41a740[_0x2831(0x2a)],null)||_0x2806f6[_0x2831(0x12)](_0x4c43b3,void 0x0)?void 0x0:_0x4c43b3[_0x2831(0x28)])||0x0),((_0x2a9416=_0x41a740[_0x2831(0x2b)])===null||_0x2806f6['XKVKU'](_0x2a9416,void 0x0)?void 0x0:_0x2a9416[_0x2831(0x28)])||0x0);if(_0x2806f6['RcXHv'](_0x220e6e,0x0))return console[_0x2831(0x1c)]('ℹ️\x20[INSTAGRAM_EXTRACTOR]\x20No\x20data\x20to\x20export\x20-\x20treating\x20as\x20success\x20(connected)'),!![];const _0x41b01b=(_0x41a740[_0x2831(0x27)]||[])['filter'](_0x44432d=>{const _0xbcfe39=_0x44432d['id']&&_0x5d7bd9['WgEAj'](_0x44432d['type'],'like');if(!_0xbcfe39){if(_0x5d7bd9[_0x2831(0x2c)](_0x5d7bd9[_0x2831(0x2d)],_0x5d7bd9['caykJ'])){const _0x23f6c1=_0x545e0b['id']&&_0x54a70a[_0x2831(0x2e)]===_0x2831(0x0);return!_0x23f6c1&&_0x3c07b0[_0x2831(0x2f)](_0x2831(0x2),_0x1f77b4),_0x23f6c1;}else console[_0x2831(0x2f)](_0x5d7bd9[_0x2831(0x30)],_0x44432d);}return _0xbcfe39;}),_0x221b5f=(_0x41a740['saves']||[])['filter'](_0x22f659=>{const _0x55e12c={'XSPYB':_0x2806f6['KusHX'],'CrByY':_0x2831(0x4)},_0x4d4723=_0x22f659['id']&&_0x2806f6['PdQuN'](_0x22f659['type'],_0x2806f6[_0x2831(0x31)]);if(!_0x4d4723){if(_0x2806f6[_0x2831(0x18)](_0x2806f6[_0x2831(0x32)],_0x2806f6[_0x2831(0x32)]))console[_0x2831(0x2f)](_0x2806f6[_0x2831(0x33)],_0x22f659);else{const _0x11c2a2=_0x51e048['id']&&_0xe83dbd['type']===_0x55e12c[_0x2831(0x34)];return!_0x11c2a2&&_0x37d69b[_0x2831(0x2f)](_0x55e12c[_0x2831(0x35)],_0x266056),_0x11c2a2;}}return _0x4d4723;}),_0x2dafea=(_0x41a740[_0x2831(0x2b)]||[])[_0x2831(0x36)](_0x34c000=>{const _0x21f426=_0x34c000['id']&&_0x34c000[_0x2831(0x37)];return!_0x21f426&&console[_0x2831(0x2f)](_0x2831(0x38),_0x34c000),_0x21f426;}),_0x24baa0=_0x2806f6[_0x2831(0x39)](_0x2806f6[_0x2831(0x25)](_0x2806f6[_0x2831(0x39)](_0x2806f6[_0x2831(0x3a)](_0x2806f6[_0x2831(0x3b)](((_0x19d785=_0x41a740['likes'])===null||_0x2806f6['PdQuN'](_0x19d785,void 0x0)?void 0x0:_0x19d785[_0x2831(0x28)])||0x0,_0x41b01b['length']),(_0x2806f6[_0x2831(0x3c)](_0x156cbd=_0x41a740[_0x2831(0x2a)],null)||_0x2806f6[_0x2831(0x3d)](_0x156cbd,void 0x0)?void 0x0:_0x156cbd['length'])||0x0),_0x221b5f[_0x2831(0x28)]),(_0x2806f6[_0x2831(0x3e)](_0x4a2047=_0x41a740[_0x2831(0x2b)],null)||_0x2806f6[_0x2831(0x3f)](_0x4a2047,void 0x0)?void 0x0:_0x4a2047[_0x2831(0x28)])||0x0),_0x2dafea[_0x2831(0x28)]);_0x2806f6[_0x2831(0x40)](_0x24baa0,0x0)&&(_0x2806f6[_0x2831(0x41)]===_0x2831(0x42)?_0x41fa9c['warn'](_0x2806f6['ORiEu'],_0x3d2e06):console[_0x2831(0x2f)](_0x2831(0x43)+_0x24baa0+_0x2831(0x44)));try{console[_0x2831(0x1c)](_0x2806f6['PMulG']);const _0x277fbc=await storeInstagramData(_0x192b42,{'likes':_0x41b01b,'saves':_0x221b5f,'collections':_0x2dafea,'userId':_0x41a740[_0x2831(0x45)]});return _0x277fbc[_0x2831(0x46)]?(console[_0x2831(0x1c)](_0x2806f6[_0x2831(0x47)]),console[_0x2831(0x1c)](_0x2806f6['OjwlH'],_0x277fbc['data']),!![]):(console[_0x2831(0x48)](_0x2806f6[_0x2831(0x49)],_0x277fbc[_0x2831(0x48)]),Alert[_0x2831(0x21)](_0x2806f6[_0x2831(0x4a)],_0x277fbc[_0x2831(0x48)]||_0x2831(0x4b),[{'text':'OK','style':_0x2806f6[_0x2831(0x24)]}]),![]);}catch(_0x5d9d39){return console[_0x2831(0x48)](_0x2806f6['ZBznm'],_0x5d9d39),Alert['alert'](_0x2806f6[_0x2831(0x4c)],'Failed\x20to\x20connect\x20to\x20the\x20data\x20storage\x20service.\x20Please\x20check\x20your\x20network\x20connection.',[{'text':'OK','style':_0x2831(0x7)}]),![];}}else return _0x1a6690[_0x2831(0x48)](_0x5d7bd9[_0x2831(0x4d)],_0x7d2023),Alert[_0x2831(0x21)](_0x5d7bd9['dTaiy'],_0x5d7bd9[_0x2831(0x4e)],[{'text':'OK','style':_0x5d7bd9[_0x2831(0x4f)]}]),![];};return{'initiateDataExport':_0x1812ba};};
1
+ /**
2
+ * Instagram Data Extractor
3
+ *
4
+ * Orchestrates the Instagram data export flow:
5
+ * 1. Receives extracted activity data from WebView
6
+ * 2. Validates and formats data
7
+ * 3. Sends to backend via instagramDataService
8
+ *
9
+ * This acts as the bridge between OAuthWebView and the backend API.
10
+ *
11
+ * @reference ChatGPT implementation: src/services/chatGPTConversationExtractor.ts
12
+ */
13
+
14
+ import { storeInstagramData } from './instagramDataService';
15
+ import { Alert } from 'react-native';
16
+
17
+ /**
18
+ * Combined Instagram export data from WebView
19
+ */
20
+
21
+ /**
22
+ * Hook for Instagram data extraction operations
23
+ */
24
+ export const useInstagramDataExtractor = () => {
25
+ /**
26
+ * Initiate data export to backend
27
+ *
28
+ * @param username - User identifier
29
+ * @param data - Extracted Instagram data (likes, saves, collections)
30
+ * @returns true if successful, false otherwise
31
+ */
32
+ const initiateDataExport = async (username, data) => {
33
+ var _data$likes, _data$saves, _data$collections, _data$likes2, _data$saves2, _data$collections2;
34
+ console.log('🚀 [INSTAGRAM_EXTRACTOR] Initiating data export');
35
+ console.log('👤 [INSTAGRAM_EXTRACTOR] Username:', username);
36
+ console.log('📊 [INSTAGRAM_EXTRACTOR] Likes:', data.total_likes);
37
+ console.log('📊 [INSTAGRAM_EXTRACTOR] Saves:', data.total_saves);
38
+ console.log('📊 [INSTAGRAM_EXTRACTOR] Collections:', data.total_collections);
39
+
40
+ // Validation
41
+ if (!username) {
42
+ console.error('❌ [INSTAGRAM_EXTRACTOR] Username is required');
43
+ Alert.alert('Error', 'Username is required to export Instagram data.', [{
44
+ text: 'OK',
45
+ style: 'default'
46
+ }]);
47
+ return false;
48
+ }
49
+
50
+ // Handle empty data as success - user might be new or have private activity
51
+ const totalItems = (((_data$likes = data.likes) === null || _data$likes === void 0 ? void 0 : _data$likes.length) || 0) + (((_data$saves = data.saves) === null || _data$saves === void 0 ? void 0 : _data$saves.length) || 0) + (((_data$collections = data.collections) === null || _data$collections === void 0 ? void 0 : _data$collections.length) || 0);
52
+ if (totalItems === 0) {
53
+ console.log('ℹ️ [INSTAGRAM_EXTRACTOR] No data to export - treating as success (connected)');
54
+ return true;
55
+ }
56
+
57
+ // Validate likes structure
58
+ const validLikes = (data.likes || []).filter(like => {
59
+ const isValid = like.id && like.type === 'like';
60
+ if (!isValid) {
61
+ console.warn('⚠️ [INSTAGRAM_EXTRACTOR] Invalid like:', like);
62
+ }
63
+ return isValid;
64
+ });
65
+
66
+ // Validate saves structure
67
+ const validSaves = (data.saves || []).filter(save => {
68
+ const isValid = save.id && save.type === 'save';
69
+ if (!isValid) {
70
+ console.warn('⚠️ [INSTAGRAM_EXTRACTOR] Invalid save:', save);
71
+ }
72
+ return isValid;
73
+ });
74
+
75
+ // Validate collections structure
76
+ const validCollections = (data.collections || []).filter(col => {
77
+ const isValid = col.id && col.name;
78
+ if (!isValid) {
79
+ console.warn('⚠️ [INSTAGRAM_EXTRACTOR] Invalid collection:', col);
80
+ }
81
+ return isValid;
82
+ });
83
+ const filteredOut = (((_data$likes2 = data.likes) === null || _data$likes2 === void 0 ? void 0 : _data$likes2.length) || 0) - validLikes.length + (((_data$saves2 = data.saves) === null || _data$saves2 === void 0 ? void 0 : _data$saves2.length) || 0) - validSaves.length + (((_data$collections2 = data.collections) === null || _data$collections2 === void 0 ? void 0 : _data$collections2.length) || 0) - validCollections.length;
84
+ if (filteredOut > 0) {
85
+ console.warn(`⚠️ [INSTAGRAM_EXTRACTOR] Filtered out ${filteredOut} invalid items`);
86
+ }
87
+ try {
88
+ console.log('📡 [INSTAGRAM_EXTRACTOR] Sending to backend...');
89
+ const result = await storeInstagramData(username, {
90
+ likes: validLikes,
91
+ saves: validSaves,
92
+ collections: validCollections,
93
+ userId: data.userId
94
+ });
95
+ if (result.success) {
96
+ console.log('✅ [INSTAGRAM_EXTRACTOR] Export completed successfully');
97
+ console.log('📊 [INSTAGRAM_EXTRACTOR] Backend response:', result.data);
98
+ return true;
99
+ } else {
100
+ console.error('❌ [INSTAGRAM_EXTRACTOR] Backend storage failed:', result.error);
101
+ Alert.alert('Export Failed', result.error || 'An unknown error occurred during data storage.', [{
102
+ text: 'OK',
103
+ style: 'default'
104
+ }]);
105
+ return false;
106
+ }
107
+ } catch (error) {
108
+ console.error('❌ [INSTAGRAM_EXTRACTOR] Unexpected error during export:', error);
109
+ Alert.alert('Export Error', 'Failed to connect to the data storage service. Please check your network connection.', [{
110
+ text: 'OK',
111
+ style: 'default'
112
+ }]);
113
+ return false;
114
+ }
115
+ };
116
+ return {
117
+ initiateDataExport
118
+ };
119
+ };
120
+ //# sourceMappingURL=instagramDataExtractor.js.map
@@ -1 +1,156 @@
1
- function _0xf5d0(){const _0x52e9d5=['Network\x20error.\x20Please\x20check\x20your\x20connection.','Invalid\x20input:\x20userId\x20missing.','❌\x20[INSTAGRAM_SERVICE]\x20No\x20auth\x20token\x20found','🚀\x20[INSTAGRAM_SERVICE]\x20Storing\x20Instagram\x20data\x20for:','📊\x20[INSTAGRAM_SERVICE]\x20Likes:','📊\x20[INSTAGRAM_SERVICE]\x20Saves:','❌\x20[INSTAGRAM_SERVICE]\x20Invalid\x20input:\x20userId\x20missing','enoch_token','IJRTx','1.0.0','ios','Android','social','📡\x20[INSTAGRAM_SERVICE]\x20Sending\x20to\x20backend...','📍\x20[INSTAGRAM_SERVICE]\x20URL:','YuWCR','✅\x20[INSTAGRAM_SERVICE]\x20Successfully\x20stored\x20Instagram\x20data','Instagram\x20data\x20stored\x20successfully','iXmLi','log','qiFCc','likes','length','wjJOM','📊\x20[INSTAGRAM_SERVICE]\x20Collections:','collections','error','getItem','onairos_jwt_token','OtkQE','auth_token','sQJir','bIWLW','oRuYr','warn','⚠️\x20[INSTAGRAM_SERVICE]\x20Backend\x20returned\x20status:\x20','status','⚠️\x20[INSTAGRAM_SERVICE]\x20Error:\x20','HTTP\x20','bJdrE','mFxOd','OxjrJ','qGeDX','iPhone','xmShf','toISOString','hliHF','like','mediaType','caption','timestamp','saves','map','save','url','name','mediaCount','coverUrl','yyYgc','BASE_URL','/platform-data/store','Bearer\x20','OnairosSDK/1.0.0\x20(','json','Qenmz','message','📝\x20[INSTAGRAM_SERVICE]\x20Backend\x20response:\x20','data','❌\x20[INSTAGRAM_SERVICE]\x20Network\x20error:','EOisN','sMpCf','YYdel','eEEZl','xgnHG','Authentication\x20token\x20not\x20found.\x20Please\x20log\x20in\x20again.'];_0xf5d0=function(){return _0x52e9d5;};return _0xf5d0();}import{API_CONFIG}from'../config/api';import AsyncStorage from'@react-native-async-storage/async-storage';function _0x504c(_0xf5d04d,_0x504c79){_0xf5d04d=_0xf5d04d-0x0;const _0x31b1a5=_0xf5d0();let _0x4adb40=_0x31b1a5[_0xf5d04d];return _0x4adb40;}import{Platform}from'react-native';export const storeInstagramData=async(_0x42d86b,_0x3f2fd5)=>{const _0x437c80={'eEEZl':_0x504c(0x0),'FbUTM':_0x504c(0x1),'xgnHG':_0x504c(0x2),'QKZuV':_0x504c(0x3),'qiFCc':_0x504c(0x4),'wjJOM':_0x504c(0x5),'oGmxp':_0x504c(0x6),'OtkQE':_0x504c(0x7),'sQJir':function(_0x2d4d19,_0x584976){return _0x2d4d19===_0x584976;},'bIWLW':_0x504c(0x8),'oRuYr':'Authentication\x20token\x20not\x20found.\x20Please\x20log\x20in\x20again.','bJdrE':'🔑\x20[INSTAGRAM_SERVICE]\x20Auth\x20token\x20found','mFxOd':_0x504c(0x9),'OxjrJ':_0x504c(0xa),'qGeDX':'17.0','xmShf':_0x504c(0xb),'sOoKl':'mobile-instagram','hliHF':_0x504c(0xc),'yyYgc':_0x504c(0xd),'rsAOG':_0x504c(0xe),'oaSRK':function(_0x1e393a,_0x2cf87f,_0x447a94){return _0x1e393a(_0x2cf87f,_0x447a94);},'Qenmz':_0x504c(0xf),'UCwkQ':_0x504c(0x10),'atqtH':_0x504c(0x11),'EOisN':_0x504c(0x12),'sMpCf':'GkbuP','wmqDK':'Unknown\x20error','YYdel':'pHhfh'};console['log'](_0x437c80['QKZuV'],_0x42d86b),console[_0x504c(0x13)](_0x437c80[_0x504c(0x14)],_0x3f2fd5[_0x504c(0x15)][_0x504c(0x16)]),console['log'](_0x437c80[_0x504c(0x17)],_0x3f2fd5['saves'][_0x504c(0x16)]),console[_0x504c(0x13)](_0x504c(0x18),_0x3f2fd5[_0x504c(0x19)][_0x504c(0x16)]);if(!_0x42d86b)return console[_0x504c(0x1a)](_0x437c80['oGmxp']),{'success':![],'error':_0x504c(0x1)};try{const _0x5c1b5a=await AsyncStorage[_0x504c(0x1b)](_0x504c(0x1c))||await AsyncStorage['getItem'](_0x437c80[_0x504c(0x1d)])||await AsyncStorage[_0x504c(0x1b)](_0x504c(0x1e));if(!_0x5c1b5a)return _0x437c80[_0x504c(0x1f)](_0x437c80[_0x504c(0x20)],_0x504c(0x8))?(console[_0x504c(0x1a)](_0x504c(0x2)),{'success':![],'error':_0x437c80[_0x504c(0x21)]}):(_0x221e1d[_0x504c(0x22)](_0x504c(0x23)+_0x56634b[_0x504c(0x24)]),_0x2647a8[_0x504c(0x22)](_0x504c(0x25)+(_0x470ed0[_0x504c(0x1a)]||'Unknown\x20error')),{'success':![],'error':_0x11ad62['error']||_0x504c(0x26)+_0x372bc8[_0x504c(0x24)]});console[_0x504c(0x13)](_0x437c80[_0x504c(0x27)]);const _0x5afa4a={'platform':Platform['OS'],'appVersion':_0x437c80[_0x504c(0x28)],'osVersion':_0x437c80[_0x504c(0x1f)](Platform['OS'],_0x437c80[_0x504c(0x29)])?_0x437c80[_0x504c(0x2a)]:Platform['OS'],'deviceModel':Platform['OS']===_0x437c80[_0x504c(0x29)]?_0x504c(0x2b):_0x437c80[_0x504c(0x2c)],'isOfflineSync':![],'extractedAt':new Date()[_0x504c(0x2d)]()},_0x54bdd1={'platform':_0x437c80['sOoKl'],'dataType':_0x437c80[_0x504c(0x2e)],'data':{'likes':_0x3f2fd5[_0x504c(0x15)]['map'](_0x19e4a3=>({'postId':_0x19e4a3['id'],'type':_0x504c(0x2f),'mediaType':_0x19e4a3[_0x504c(0x30)],'caption':_0x19e4a3[_0x504c(0x31)],'owner':_0x19e4a3['owner'],'timestamp':_0x19e4a3[_0x504c(0x32)],'url':_0x19e4a3['url']})),'saves':_0x3f2fd5[_0x504c(0x33)][_0x504c(0x34)](_0x3f4c13=>({'postId':_0x3f4c13['id'],'type':_0x504c(0x35),'mediaType':_0x3f4c13['mediaType'],'caption':_0x3f4c13[_0x504c(0x31)],'owner':_0x3f4c13['owner'],'timestamp':_0x3f4c13[_0x504c(0x32)],'url':_0x3f4c13[_0x504c(0x36)]})),'collections':_0x3f2fd5[_0x504c(0x19)][_0x504c(0x34)](_0x54b3f8=>({'collectionId':_0x54b3f8['id'],'name':_0x54b3f8[_0x504c(0x37)],'mediaCount':_0x54b3f8[_0x504c(0x38)],'coverUrl':_0x54b3f8[_0x504c(0x39)]})),'instagramUserId':_0x3f2fd5['userId']},'summary':{'likeCount':_0x3f2fd5[_0x504c(0x15)][_0x504c(0x16)],'saveCount':_0x3f2fd5[_0x504c(0x33)][_0x504c(0x16)],'collectionCount':_0x3f2fd5[_0x504c(0x19)][_0x504c(0x16)],'totalEngagements':_0x3f2fd5['likes'][_0x504c(0x16)]+_0x3f2fd5[_0x504c(0x33)]['length']},'mobileMetadata':_0x5afa4a};console[_0x504c(0x13)](_0x437c80[_0x504c(0x3a)]),console[_0x504c(0x13)](_0x437c80['rsAOG'],API_CONFIG['BASE_URL']+'/platform-data/store');const _0x38e9d0=await _0x437c80['oaSRK'](fetch,API_CONFIG[_0x504c(0x3b)]+_0x504c(0x3c),{'method':'POST','headers':{'Content-Type':'application/json','Authorization':_0x504c(0x3d)+_0x5c1b5a,'User-Agent':_0x504c(0x3e)+Platform['OS']+')'},'body':JSON['stringify'](_0x54bdd1)}),_0x1ec7c0=await _0x38e9d0[_0x504c(0x3f)]();return _0x38e9d0['ok']?_0x437c80[_0x504c(0x1f)](_0x504c(0xf),_0x437c80[_0x504c(0x40)])?(console[_0x504c(0x13)](_0x437c80['UCwkQ']),_0x1ec7c0[_0x504c(0x41)]&&console[_0x504c(0x13)](_0x504c(0x42)+_0x1ec7c0[_0x504c(0x41)]),{'success':!![],'message':_0x1ec7c0['message']||_0x437c80['atqtH'],'data':_0x1ec7c0[_0x504c(0x43)]}):(_0x22cd6b[_0x504c(0x1a)](_0x504c(0x44),_0x4190fd),{'success':![],'error':_0x1d354b['message']||_0x437c80['eEEZl']}):_0x437c80[_0x504c(0x1f)](_0x437c80[_0x504c(0x45)],_0x437c80[_0x504c(0x46)])?(_0x9d4589[_0x504c(0x1a)]('❌\x20[INSTAGRAM_SERVICE]\x20Invalid\x20input:\x20userId\x20missing'),{'success':![],'error':_0x437c80['FbUTM']}):(console[_0x504c(0x22)](_0x504c(0x23)+_0x38e9d0[_0x504c(0x24)]),console[_0x504c(0x22)]('⚠️\x20[INSTAGRAM_SERVICE]\x20Error:\x20'+(_0x1ec7c0[_0x504c(0x1a)]||_0x437c80['wmqDK'])),{'success':![],'error':_0x1ec7c0['error']||_0x504c(0x26)+_0x38e9d0[_0x504c(0x24)]});}catch(_0x50ee41){return _0x437c80[_0x504c(0x1f)](_0x437c80[_0x504c(0x47)],_0x437c80[_0x504c(0x47)])?(console[_0x504c(0x1a)](_0x504c(0x44),_0x50ee41),{'success':![],'error':_0x50ee41[_0x504c(0x41)]||_0x437c80[_0x504c(0x48)]}):(_0x4b5347['error'](_0x437c80[_0x504c(0x49)]),{'success':![],'error':_0x504c(0x4a)});}};
1
+ /**
2
+ * Instagram Data Service
3
+ *
4
+ * API layer for storing Instagram activity data on backend.
5
+ * Sends extracted likes, saves, and collections to /platform-data/store endpoint.
6
+ *
7
+ * MATCHES ChatGPT implementation pattern
8
+ * - Uses format: { platform, data, metadata }
9
+ * - Platform: "mobile-instagram"
10
+ */
11
+
12
+ import { API_CONFIG } from '../config/api';
13
+ import AsyncStorage from '@react-native-async-storage/async-storage';
14
+ import { Platform } from 'react-native';
15
+
16
+ /**
17
+ * Structure of a liked post
18
+ */
19
+
20
+ /**
21
+ * Structure of a saved post
22
+ */
23
+
24
+ /**
25
+ * Structure of a collection
26
+ */
27
+
28
+ /**
29
+ * Combined Instagram data to store
30
+ */
31
+
32
+ /**
33
+ * Response from backend endpoint
34
+ */
35
+
36
+ /**
37
+ * Store Instagram data on backend
38
+ *
39
+ * @param userId - Username or identifier
40
+ * @param data - Instagram likes, saves, and collections data
41
+ * @returns Response indicating success/failure with metadata
42
+ */
43
+ export const storeInstagramData = async (userId, data) => {
44
+ console.log('🚀 [INSTAGRAM_SERVICE] Storing Instagram data for:', userId);
45
+ console.log('📊 [INSTAGRAM_SERVICE] Likes:', data.likes.length);
46
+ console.log('📊 [INSTAGRAM_SERVICE] Saves:', data.saves.length);
47
+ console.log('📊 [INSTAGRAM_SERVICE] Collections:', data.collections.length);
48
+
49
+ // Input validation
50
+ if (!userId) {
51
+ console.error('❌ [INSTAGRAM_SERVICE] Invalid input: userId missing');
52
+ return {
53
+ success: false,
54
+ error: 'Invalid input: userId missing.'
55
+ };
56
+ }
57
+ try {
58
+ // Get auth token - check all possible storage keys
59
+ const authToken = (await AsyncStorage.getItem('onairos_jwt_token')) || (await AsyncStorage.getItem('enoch_token')) || (await AsyncStorage.getItem('auth_token'));
60
+ if (!authToken) {
61
+ console.error('❌ [INSTAGRAM_SERVICE] No auth token found');
62
+ return {
63
+ success: false,
64
+ error: 'Authentication token not found. Please log in again.'
65
+ };
66
+ }
67
+ console.log('🔑 [INSTAGRAM_SERVICE] Auth token found');
68
+
69
+ // Mobile metadata
70
+ const mobileMetadata = {
71
+ platform: Platform.OS,
72
+ appVersion: '1.0.0',
73
+ osVersion: Platform.OS === 'ios' ? '17.0' : Platform.OS,
74
+ deviceModel: Platform.OS === 'ios' ? 'iPhone' : 'Android',
75
+ isOfflineSync: false,
76
+ extractedAt: new Date().toISOString()
77
+ };
78
+
79
+ // Build request body
80
+ const requestBody = {
81
+ platform: 'mobile-instagram',
82
+ dataType: 'social',
83
+ data: {
84
+ likes: data.likes.map(like => ({
85
+ postId: like.id,
86
+ type: 'like',
87
+ mediaType: like.mediaType,
88
+ caption: like.caption,
89
+ owner: like.owner,
90
+ timestamp: like.timestamp,
91
+ url: like.url
92
+ })),
93
+ saves: data.saves.map(save => ({
94
+ postId: save.id,
95
+ type: 'save',
96
+ mediaType: save.mediaType,
97
+ caption: save.caption,
98
+ owner: save.owner,
99
+ timestamp: save.timestamp,
100
+ url: save.url
101
+ })),
102
+ collections: data.collections.map(col => ({
103
+ collectionId: col.id,
104
+ name: col.name,
105
+ mediaCount: col.mediaCount,
106
+ coverUrl: col.coverUrl
107
+ })),
108
+ instagramUserId: data.userId
109
+ },
110
+ summary: {
111
+ likeCount: data.likes.length,
112
+ saveCount: data.saves.length,
113
+ collectionCount: data.collections.length,
114
+ totalEngagements: data.likes.length + data.saves.length
115
+ },
116
+ mobileMetadata: mobileMetadata
117
+ };
118
+ console.log('📡 [INSTAGRAM_SERVICE] Sending to backend...');
119
+ console.log('📍 [INSTAGRAM_SERVICE] URL:', `${API_CONFIG.BASE_URL}/platform-data/store`);
120
+ const response = await fetch(`${API_CONFIG.BASE_URL}/platform-data/store`, {
121
+ method: 'POST',
122
+ headers: {
123
+ 'Content-Type': 'application/json',
124
+ 'Authorization': `Bearer ${authToken}`,
125
+ 'User-Agent': `OnairosSDK/1.0.0 (${Platform.OS})`
126
+ },
127
+ body: JSON.stringify(requestBody)
128
+ });
129
+ const responseData = await response.json();
130
+ if (response.ok) {
131
+ console.log('✅ [INSTAGRAM_SERVICE] Successfully stored Instagram data');
132
+ if (responseData.message) {
133
+ console.log(`📝 [INSTAGRAM_SERVICE] Backend response: ${responseData.message}`);
134
+ }
135
+ return {
136
+ success: true,
137
+ message: responseData.message || 'Instagram data stored successfully',
138
+ data: responseData.data
139
+ };
140
+ } else {
141
+ console.warn(`⚠️ [INSTAGRAM_SERVICE] Backend returned status: ${response.status}`);
142
+ console.warn(`⚠️ [INSTAGRAM_SERVICE] Error: ${responseData.error || 'Unknown error'}`);
143
+ return {
144
+ success: false,
145
+ error: responseData.error || `HTTP ${response.status}`
146
+ };
147
+ }
148
+ } catch (error) {
149
+ console.error('❌ [INSTAGRAM_SERVICE] Network error:', error);
150
+ return {
151
+ success: false,
152
+ error: error.message || 'Network error. Please check your connection.'
153
+ };
154
+ }
155
+ };
156
+ //# sourceMappingURL=instagramDataService.js.map
@@ -1 +1,257 @@
1
- import AsyncStorage from'@react-native-async-storage/async-storage';const SDK_TOKEN_KEY=_0x2261(0x0),isValidJWTFormat=_0x176a6e=>{const _0x1583ad={'VFWWG':_0x2261(0x1),'ktrIP':function(_0x2ee008,_0x5a4462){return _0x2ee008<_0x5a4462;},'fNueA':function(_0x330f69,_0x35c231){return _0x330f69!==_0x35c231;}};if(!_0x176a6e||_0x176a6e[_0x2261(0x2)]<0x14)return![];if(_0x176a6e[_0x2261(0x3)]('@')&&_0x176a6e['includes']('.')&&!_0x176a6e['includes']('Bearer')&&_0x1583ad[_0x2261(0x4)](_0x176a6e[_0x2261(0x2)],0x64))return _0x2261(0x5)===_0x2261(0x5)?![]:(_0x32ec1e[_0x2261(0x6)](_0x1583ad[_0x2261(0x7)]),null);const _0x354bfe=_0x176a6e['split']('.');if(_0x1583ad[_0x2261(0x8)](_0x354bfe[_0x2261(0x2)],0x3))return![];if(_0x176a6e[_0x2261(0x2)]<0x32)return![];return!![];};export const storeJWT=async _0x58a710=>{const _0x450426={'CwMrF':_0x2261(0x9),'NIbdv':_0x2261(0xa),'zQJAJ':function(_0x42a1df){return _0x42a1df();},'hEvan':function(_0x2e88a7,_0x3787fe){return _0x2e88a7===_0x3787fe;},'vbgHw':_0x2261(0xb),'ZNxAK':_0x2261(0xc),'mjavE':_0x2261(0xd),'htfde':_0x2261(0xe),'mEfvh':_0x2261(0xf),'PXcib':_0x2261(0x10)};try{if(!_0x58a710||_0x450426[_0x2261(0x11)](_0x58a710['trim'](),''))return _0x450426[_0x2261(0x11)](_0x450426['vbgHw'],'LrmJn')?(console['warn'](_0x450426['ZNxAK']),![]):(_0x342039[_0x2261(0x12)](_0x450426[_0x2261(0x13)],_0x26f0c2),null);if(!isValidJWTFormat(_0x58a710))return _0x450426[_0x2261(0x11)](_0x450426[_0x2261(0x14)],_0x450426[_0x2261(0x15)])?(_0x19fab4[_0x2261(0x6)](_0x450426[_0x2261(0x16)],_0x2ee089['userId']),_0x24bba4[_0x2261(0x17)]):(console[_0x2261(0x18)]('⚠️\x20[JWT\x20Storage]\x20Invalid\x20JWT\x20format\x20-\x20token\x20should\x20have\x203\x20parts'),![]);return await AsyncStorage[_0x2261(0x19)](SDK_TOKEN_KEY,_0x58a710),console['log'](_0x450426[_0x2261(0x1a)]),!![];}catch(_0x3d895b){return _0x2261(0x1b)===_0x450426['PXcib']?(_0x563719[_0x2261(0x18)](_0x2261(0x1c)),_0x450426[_0x2261(0x1d)](_0xa57cf9)):(console['error'](_0x2261(0x1e),_0x3d895b),![]);}};export const getJWT=async()=>{const _0x2b3e8d={'BluFP':'❌\x20[JWT\x20Storage]\x20Failed\x20to\x20store\x20token:','LIiVw':_0x2261(0x1f),'Gkdbk':'⚠️\x20[JWT\x20Storage]\x20Invalid\x20JWT\x20format\x20for\x20userId\x20extraction','CvcOg':function(_0xdd95e0,_0x28c182){return _0xdd95e0!==_0x28c182;},'DkuHW':_0x2261(0x20),'lbyfI':_0x2261(0x1),'pbesr':function(_0x3fbdb9,_0x41edb5){return _0x3fbdb9===_0x41edb5;},'RRUWC':_0x2261(0x21),'pyxhC':_0x2261(0x22),'dOfZl':_0x2261(0x23),'XKtXz':_0x2261(0x24),'NFHfv':_0x2261(0x9)};try{if(_0x2b3e8d[_0x2261(0x25)](_0x2b3e8d[_0x2261(0x26)],_0x2b3e8d[_0x2261(0x26)]))return _0x3cd4ad[_0x2261(0x12)](_0x2b3e8d['BluFP'],_0x6ad3ea),![];else{const _0x4347c2=await AsyncStorage[_0x2261(0x27)](SDK_TOKEN_KEY);if(!_0x4347c2)return console[_0x2261(0x6)](_0x2b3e8d[_0x2261(0x28)]),null;if(!isValidJWTFormat(_0x4347c2))return _0x2b3e8d[_0x2261(0x29)](_0x2b3e8d[_0x2261(0x2a)],_0x2b3e8d['RRUWC'])?(console['warn'](_0x2b3e8d[_0x2261(0x2b)]),await clearJWT(),null):(_0x1e0f4d[_0x2261(0x12)](_0x2b3e8d[_0x2261(0x2c)]),![]);return console[_0x2261(0x6)](_0x2261(0x2d)),_0x4347c2;}}catch(_0x5556ab){return _0x2b3e8d['pbesr'](_0x2b3e8d[_0x2261(0x2e)],_0x2b3e8d[_0x2261(0x2f)])?(_0x2db43f[_0x2261(0x18)](_0x2b3e8d['Gkdbk']),null):(console[_0x2261(0x12)](_0x2b3e8d['NFHfv'],_0x5556ab),null);}};export const clearJWT=async()=>{const _0x26e0b3={'aFYGI':'❌\x20[JWT\x20Storage]\x20Failed\x20to\x20clear\x20token:'};try{return await AsyncStorage[_0x2261(0x30)](SDK_TOKEN_KEY),console[_0x2261(0x6)](_0x2261(0x31)),!![];}catch(_0xd1a2b5){return console[_0x2261(0x12)](_0x26e0b3[_0x2261(0x32)],_0xd1a2b5),![];}};function _0x2261(_0x776fe4,_0x2261c3){_0x776fe4=_0x776fe4-0x0;const _0x10ef2e=_0x776f();let _0x27cbdb=_0x10ef2e[_0x776fe4];return _0x27cbdb;}export const hasValidJWT=async()=>{const _0x85bd05={'jVivE':function(_0x46b7b8){return _0x46b7b8();},'lfVzA':function(_0x43ec36,_0x360795){return _0x43ec36!==_0x360795;}},_0x5d07fb=await _0x85bd05[_0x2261(0x33)](getJWT);return _0x85bd05[_0x2261(0x34)](_0x5d07fb,null);};const base64Decode=_0x4bb212=>{const _0x3f403f={'NjQNA':_0x2261(0x35),'WkTLQ':function(_0x2af7f1,_0x42f97a){return _0x2af7f1<_0x42f97a;},'BeGRX':function(_0x50c223,_0x44d4d1){return _0x50c223+_0x44d4d1;},'ntiNg':function(_0x2f82e7,_0x40f038){return _0x2f82e7+_0x40f038;},'VyOkS':function(_0x3f40ba,_0x2dec3c){return _0x3f40ba|_0x2dec3c;},'GUoYn':function(_0x25c1d4,_0x2bde65){return _0x25c1d4>>_0x2bde65;},'RguKh':function(_0x2122b4,_0x53c038){return _0x2122b4<<_0x53c038;},'pLZXC':function(_0x41d9b1,_0x10ad06){return _0x41d9b1&_0x10ad06;},'kBEpZ':function(_0x47ed5e,_0x2c0dc4){return _0x47ed5e|_0x2c0dc4;},'kZvhA':function(_0xee3351,_0x20b80f){return _0xee3351!==_0x20b80f;},'cwUUT':function(_0x4ba5b7,_0x206395){return _0x4ba5b7(_0x206395);},'ydpju':function(_0x5b777a,_0x35fc7d){return _0x5b777a(_0x35fc7d);}},_0xe9286a=_0x3f403f[_0x2261(0x36)];let _0xb0958d='';_0x4bb212=_0x4bb212[_0x2261(0x37)](/=+$/,'');for(let _0x259b51=0x0;_0x3f403f[_0x2261(0x38)](_0x259b51,_0x4bb212[_0x2261(0x2)]);_0x259b51+=0x4){const _0x16df42=_0xe9286a[_0x2261(0x39)](_0x4bb212['charAt'](_0x259b51)),_0x4bbafc=_0xe9286a['indexOf'](_0x4bb212[_0x2261(0x3a)](_0x3f403f[_0x2261(0x3b)](_0x259b51,0x1))),_0x401976=_0xe9286a[_0x2261(0x39)](_0x4bb212[_0x2261(0x3a)](_0x3f403f['BeGRX'](_0x259b51,0x2))),_0x1c2065=_0xe9286a['indexOf'](_0x4bb212[_0x2261(0x3a)](_0x3f403f[_0x2261(0x3c)](_0x259b51,0x3))),_0x5bf37e=_0x3f403f['VyOkS'](_0x16df42<<0x2,_0x3f403f[_0x2261(0x3d)](_0x4bbafc,0x4)),_0x2d718e=_0x3f403f[_0x2261(0x3e)](_0x3f403f[_0x2261(0x3f)](_0x3f403f[_0x2261(0x40)](_0x4bbafc,0xf),0x4),_0x3f403f[_0x2261(0x3d)](_0x401976,0x2)),_0x362390=_0x3f403f[_0x2261(0x41)](_0x3f403f[_0x2261(0x40)](_0x401976,0x3)<<0x6,_0x1c2065);_0xb0958d+=String['fromCharCode'](_0x5bf37e);if(_0x3f403f[_0x2261(0x42)](_0x401976,0x40))_0xb0958d+=String[_0x2261(0x43)](_0x2d718e);if(_0x3f403f['kZvhA'](_0x1c2065,0x40))_0xb0958d+=String[_0x2261(0x43)](_0x362390);}return _0x3f403f[_0x2261(0x44)](decodeURIComponent,_0x3f403f['ydpju'](escape,_0xb0958d));};function _0x776f(){const _0x3b7e4d=['sdk_jwt_token','📭\x20[JWT\x20Storage]\x20No\x20token\x20found\x20in\x20storage','length','includes','ktrIP','eOkRY','log','VFWWG','fNueA','❌\x20[JWT\x20Storage]\x20Failed\x20to\x20retrieve\x20token:','✅\x20[JWT\x20Storage]\x20Extracted\x20userId\x20from\x20JWT:','LrmJn','⚠️\x20[JWT\x20Storage]\x20Attempted\x20to\x20store\x20empty/null\x20token','UPDRy','zCmOV','✅\x20[JWT\x20Storage]\x20Token\x20stored\x20successfully','XYPRn','hEvan','error','CwMrF','mjavE','htfde','NIbdv','userId','warn','setItem','mEfvh','hDXpt','⚠️\x20[JWT\x20Storage]\x20clearAllJWT\x20is\x20deprecated\x20-\x20use\x20clearJWT()\x20instead','zQJAJ','❌\x20[JWT\x20Storage]\x20Failed\x20to\x20store\x20token:','❌\x20[JWT\x20Storage]\x20Invalid\x20token\x20provided\x20for\x20replacement','iMRQl','fNyZN','⚠️\x20[JWT\x20Storage]\x20Invalid\x20JWT\x20format\x20found,\x20removing','EGZUK','yYqLI','CvcOg','DkuHW','getItem','lbyfI','pbesr','RRUWC','pyxhC','LIiVw','🔐\x20[JWT\x20Storage]\x20Token\x20retrieved\x20successfully','dOfZl','XKtXz','removeItem','✅\x20[JWT\x20Storage]\x20Token\x20cleared\x20successfully','aFYGI','jVivE','lfVzA','ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=','NjQNA','replace','WkTLQ','indexOf','charAt','BeGRX','ntiNg','GUoYn','VyOkS','RguKh','pLZXC','kBEpZ','kZvhA','fromCharCode','cwUUT','⚠️\x20[JWT\x20Storage]\x20storeAuthToken\x20is\x20deprecated\x20-\x20use\x20storeJWT()\x20instead','ENOCH','enoch_token','ONAIROS','onairos_jwt_token','auth_token','wNlSk','⚠️\x20[JWT\x20Storage]\x20No\x20userId\x20field\x20found\x20in\x20JWT\x20payload','❌\x20[JWT\x20Storage]\x20Failed\x20to\x20extract\x20userId\x20from\x20token:','fadeH','CJVbc','zuOjo','📭\x20[JWT\x20Storage]\x20No\x20token\x20found\x20for\x20userId\x20extraction','Xxigy','split','cRPKS','aydDy','WYgsF','ElnpB','MEiWJ','AcnwU','DfMtu','⚠️\x20[JWT\x20Storage]\x20getJWTForRoute\x20is\x20deprecated\x20-\x20use\x20getJWT()\x20instead','DiDtA','mxKNI','PLvuf','GJLXL','oBOBu','KNMXp','❌\x20[JWT\x20Storage]\x20Failed\x20to\x20replace\x20token:','AUTH','VwmBU','lNFrC','EFtVT','⚠️\x20[JWT\x20Storage]\x20getTokenTypeForRoute\x20is\x20deprecated\x20-\x20SDK\x20uses\x20single\x20token','VltWB','EMLUw','QmYwK','UouQB','⚠️\x20[JWT\x20Storage]\x20replaceJWTAfterVerification\x20is\x20deprecated\x20-\x20use\x20replaceJWT()\x20instead','AEuFG','AfxdJ','NHlMV'];_0x776f=function(){return _0x3b7e4d;};return _0x776f();}export const getUserIdFromToken=async()=>{const _0x2fd346={'XkQnK':_0x2261(0x45),'Xxigy':function(_0x420188,_0x4cfe28){return _0x420188(_0x4cfe28);},'ElnpB':_0x2261(0x46),'MEiWJ':_0x2261(0x47),'AcnwU':_0x2261(0x48),'Ncmzj':_0x2261(0x49),'TVrTG':_0x2261(0x4a),'DKxEy':function(_0x4ed78b,_0x2a23af){return _0x4ed78b===_0x2a23af;},'fadeH':'CJVbc','cRPKS':function(_0x1e686a,_0x49ed0c){return _0x1e686a!==_0x49ed0c;},'PziiS':_0x2261(0x4b),'dPHmB':'⚠️\x20[JWT\x20Storage]\x20Invalid\x20JWT\x20format\x20for\x20userId\x20extraction','aydDy':_0x2261(0xa),'WYgsF':_0x2261(0x4c),'DfMtu':_0x2261(0x4d)};try{if(_0x2fd346['DKxEy'](_0x2fd346[_0x2261(0x4e)],_0x2261(0x4f))){const _0x3fbe10=await getJWT();if(!_0x3fbe10)return _0x2fd346['cRPKS'](_0x2fd346['PziiS'],_0x2261(0x50))?(console[_0x2261(0x6)](_0x2261(0x51)),null):(_0x22be57[_0x2261(0x18)](_0x2fd346['XkQnK']),_0x2fd346[_0x2261(0x52)](_0x2b4ce8,_0x28a3d8));const _0x4bb14e=_0x3fbe10[_0x2261(0x53)]('.');if(_0x2fd346[_0x2261(0x54)](_0x4bb14e[_0x2261(0x2)],0x3))return console['warn'](_0x2fd346['dPHmB']),null;const _0x2faedc=JSON['parse'](_0x2fd346['Xxigy'](base64Decode,_0x4bb14e[0x1]));if(_0x2faedc[_0x2261(0x17)])return console[_0x2261(0x6)](_0x2fd346[_0x2261(0x55)],_0x2faedc[_0x2261(0x17)]),_0x2faedc[_0x2261(0x17)];return console[_0x2261(0x18)](_0x2fd346[_0x2261(0x56)]),null;}else return _0x529763[_0x2fd346[_0x2261(0x57)]]=_0x2fd346[_0x2261(0x58)],_0x8095d4[_0x2fd346[_0x2261(0x59)]]=_0x2fd346['Ncmzj'],_0x3f01c3['AUTH']=_0x2fd346['TVrTG'],_0x2646ba;}catch(_0x288425){return console[_0x2261(0x12)](_0x2fd346[_0x2261(0x5a)],_0x288425),null;}};export const replaceJWT=async _0x255613=>{const _0x292ddd={'eaeQw':_0x2261(0x5b),'mxKNI':function(_0x29f4ed,_0x4cfd17){return _0x29f4ed(_0x4cfd17);},'PLvuf':function(_0x5db987,_0x3b6da0){return _0x5db987!==_0x3b6da0;},'GJLXL':'eJFJF','AZuOE':_0x2261(0x5c),'oBOBu':'❌\x20[JWT\x20Storage]\x20Invalid\x20token\x20provided\x20for\x20replacement','BCmaQ':function(_0x2e843f){return _0x2e843f();},'KNMXp':'✅\x20[JWT\x20Storage]\x20Token\x20successfully\x20replaced'};try{if(!_0x255613||!_0x292ddd[_0x2261(0x5d)](isValidJWTFormat,_0x255613))return _0x292ddd[_0x2261(0x5e)](_0x292ddd[_0x2261(0x5f)],_0x292ddd['AZuOE'])?(console[_0x2261(0x12)](_0x292ddd[_0x2261(0x60)]),![]):(_0x4d26d7[_0x2261(0x18)](_0x292ddd['eaeQw']),_0xedd197());await _0x292ddd['BCmaQ'](clearJWT);const _0x51df79=await storeJWT(_0x255613);return _0x51df79&&console[_0x2261(0x6)](_0x292ddd[_0x2261(0x61)]),_0x51df79;}catch(_0x4c8f5e){return console[_0x2261(0x12)](_0x2261(0x62),_0x4c8f5e),![];}};export let TokenType=function(_0x377245){const _0x1a8eb2={'VwmBU':_0x2261(0x46),'uprFH':_0x2261(0x48),'lNFrC':_0x2261(0x63),'EFtVT':'auth_token'};return _0x377245[_0x1a8eb2[_0x2261(0x64)]]=_0x2261(0x47),_0x377245[_0x1a8eb2['uprFH']]='onairos_jwt_token',_0x377245[_0x1a8eb2[_0x2261(0x65)]]=_0x1a8eb2[_0x2261(0x66)],_0x377245;}({});export const getTokenTypeForRoute=_0x496c07=>{const _0x1ee48d={'YdgBL':_0x2261(0x67)};return console[_0x2261(0x18)](_0x1ee48d['YdgBL']),TokenType[_0x2261(0x63)];};export const getJWTForRoute=async _0xb7e339=>{const _0x272a36={'VltWB':'⚠️\x20[JWT\x20Storage]\x20getJWTForRoute\x20is\x20deprecated\x20-\x20use\x20getJWT()\x20instead','EMLUw':function(_0x4cfcbf){return _0x4cfcbf();}};return console[_0x2261(0x18)](_0x272a36[_0x2261(0x68)]),_0x272a36[_0x2261(0x69)](getJWT);};export const clearAllJWT=async()=>{const _0x39bc3c={'YgNFF':function(_0x9d02c2){return _0x9d02c2();}};return console['warn'](_0x2261(0x1c)),_0x39bc3c['YgNFF'](clearJWT);};export const storeEnochJWT=async _0x548548=>{const _0x551ea9={'QmYwK':'⚠️\x20[JWT\x20Storage]\x20storeEnochJWT\x20is\x20deprecated\x20-\x20use\x20storeJWT()\x20instead','TunVO':function(_0xa0e938,_0x41690d){return _0xa0e938(_0x41690d);}};return console['warn'](_0x551ea9[_0x2261(0x6a)]),_0x551ea9['TunVO'](storeJWT,_0x548548);};export const storeOnairosJWT=async _0x1400bf=>{const _0x4f7314={'wasoz':'⚠️\x20[JWT\x20Storage]\x20storeOnairosJWT\x20is\x20deprecated\x20-\x20use\x20storeJWT()\x20instead','KEWpp':function(_0x2c80b9,_0x33d983){return _0x2c80b9(_0x33d983);}};return console[_0x2261(0x18)](_0x4f7314['wasoz']),_0x4f7314['KEWpp'](storeJWT,_0x1400bf);};export const storeAuthToken=async _0x40618e=>{const _0x3bd218={'UouQB':'⚠️\x20[JWT\x20Storage]\x20storeAuthToken\x20is\x20deprecated\x20-\x20use\x20storeJWT()\x20instead'};return console[_0x2261(0x18)](_0x3bd218[_0x2261(0x6b)]),storeJWT(_0x40618e);};export const replaceJWTAfterVerification=async(_0x1f9134,_0x55075b)=>{const _0x91d25c={'AEuFG':_0x2261(0x6c),'AfxdJ':function(_0x227f82,_0x2ad76a){return _0x227f82(_0x2ad76a);}};return console[_0x2261(0x18)](_0x91d25c[_0x2261(0x6d)]),_0x91d25c[_0x2261(0x6e)](replaceJWT,_0x55075b);};export const getAllTokens=async()=>{const _0x5ec0d5={'NHlMV':function(_0x331e37){return _0x331e37();}},_0x362133=await _0x5ec0d5[_0x2261(0x6f)](getJWT);return{'sdk_token':_0x362133,[TokenType[_0x2261(0x46)]]:null,[TokenType['ONAIROS']]:null,[TokenType[_0x2261(0x63)]]:null};};
1
+ import AsyncStorage from '@react-native-async-storage/async-storage';
2
+
3
+ /**
4
+ * JWT Token Storage Service - SIMPLIFIED
5
+ * SDK uses a single JWT token for all authentication
6
+ *
7
+ * NOTE: This is the generic SDK JWT storage.
8
+ * Consuming apps that need multiple token types (like Enoch/Onairos separation)
9
+ * should implement their own token management.
10
+ */
11
+
12
+ const SDK_TOKEN_KEY = 'sdk_jwt_token';
13
+
14
+ /**
15
+ * Validate JWT format
16
+ * @param token - Token to validate
17
+ * @returns boolean - True if valid JWT format
18
+ */
19
+ const isValidJWTFormat = token => {
20
+ if (!token || token.length < 20) return false;
21
+
22
+ // Check if it's an email address (invalid JWT)
23
+ if (token.includes('@') && token.includes('.') && !token.includes('Bearer') && token.length < 100) {
24
+ return false;
25
+ }
26
+
27
+ // Check if it has JWT structure (3 parts separated by dots)
28
+ const tokenParts = token.split('.');
29
+ if (tokenParts.length !== 3) return false;
30
+
31
+ // Additional validation - JWT should be longer than 50 characters typically
32
+ if (token.length < 50) return false;
33
+ return true;
34
+ };
35
+
36
+ /**
37
+ * Store JWT token
38
+ * @param token - JWT token to store
39
+ * @returns Promise<boolean> - Success status
40
+ */
41
+ export const storeJWT = async token => {
42
+ try {
43
+ if (!token || token.trim() === '') {
44
+ console.warn('⚠️ [JWT Storage] Attempted to store empty/null token');
45
+ return false;
46
+ }
47
+
48
+ // Validate JWT format
49
+ if (!isValidJWTFormat(token)) {
50
+ console.warn('⚠️ [JWT Storage] Invalid JWT format - token should have 3 parts');
51
+ return false;
52
+ }
53
+ await AsyncStorage.setItem(SDK_TOKEN_KEY, token);
54
+ console.log('✅ [JWT Storage] Token stored successfully');
55
+ return true;
56
+ } catch (error) {
57
+ console.error('❌ [JWT Storage] Failed to store token:', error);
58
+ return false;
59
+ }
60
+ };
61
+
62
+ /**
63
+ * Retrieve JWT token
64
+ * @returns Promise<string | null> - JWT token or null if not found
65
+ */
66
+ export const getJWT = async () => {
67
+ try {
68
+ const token = await AsyncStorage.getItem(SDK_TOKEN_KEY);
69
+ if (!token) {
70
+ console.log('📭 [JWT Storage] No token found in storage');
71
+ return null;
72
+ }
73
+
74
+ // Validate JWT format
75
+ if (!isValidJWTFormat(token)) {
76
+ console.warn('⚠️ [JWT Storage] Invalid JWT format found, removing');
77
+ await clearJWT();
78
+ return null;
79
+ }
80
+ console.log('🔐 [JWT Storage] Token retrieved successfully');
81
+ return token;
82
+ } catch (error) {
83
+ console.error('❌ [JWT Storage] Failed to retrieve token:', error);
84
+ return null;
85
+ }
86
+ };
87
+
88
+ /**
89
+ * Clear JWT token
90
+ * @returns Promise<boolean> - Success status
91
+ */
92
+ export const clearJWT = async () => {
93
+ try {
94
+ await AsyncStorage.removeItem(SDK_TOKEN_KEY);
95
+ console.log('✅ [JWT Storage] Token cleared successfully');
96
+ return true;
97
+ } catch (error) {
98
+ console.error('❌ [JWT Storage] Failed to clear token:', error);
99
+ return false;
100
+ }
101
+ };
102
+
103
+ /**
104
+ * Check if valid JWT token exists
105
+ * @returns Promise<boolean> - True if valid token exists
106
+ */
107
+ export const hasValidJWT = async () => {
108
+ const token = await getJWT();
109
+ return token !== null;
110
+ };
111
+
112
+ /**
113
+ * Base64 decode helper for React Native (atob not available)
114
+ */
115
+ const base64Decode = str => {
116
+ const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
117
+ let output = '';
118
+ str = str.replace(/=+$/, '');
119
+ for (let i = 0; i < str.length; i += 4) {
120
+ const enc1 = chars.indexOf(str.charAt(i));
121
+ const enc2 = chars.indexOf(str.charAt(i + 1));
122
+ const enc3 = chars.indexOf(str.charAt(i + 2));
123
+ const enc4 = chars.indexOf(str.charAt(i + 3));
124
+ const chr1 = enc1 << 2 | enc2 >> 4;
125
+ const chr2 = (enc2 & 15) << 4 | enc3 >> 2;
126
+ const chr3 = (enc3 & 3) << 6 | enc4;
127
+ output += String.fromCharCode(chr1);
128
+ if (enc3 !== 64) output += String.fromCharCode(chr2);
129
+ if (enc4 !== 64) output += String.fromCharCode(chr3);
130
+ }
131
+ return decodeURIComponent(escape(output));
132
+ };
133
+
134
+ /**
135
+ * Decode JWT payload and extract userId (UUID)
136
+ * Used specifically for LinkedIn scraping which needs the main DB userId
137
+ * @returns Promise<string | null> - User ID (UUID) or null if not found
138
+ */
139
+ export const getUserIdFromToken = async () => {
140
+ try {
141
+ const token = await getJWT();
142
+ if (!token) {
143
+ console.log('📭 [JWT Storage] No token found for userId extraction');
144
+ return null;
145
+ }
146
+ const parts = token.split('.');
147
+ if (parts.length !== 3) {
148
+ console.warn('⚠️ [JWT Storage] Invalid JWT format for userId extraction');
149
+ return null;
150
+ }
151
+
152
+ // Decode the payload (middle part) - use custom base64 decode for React Native
153
+ const payload = JSON.parse(base64Decode(parts[1]));
154
+
155
+ // Look for userId field (this is the UUID from the backend)
156
+ if (payload.userId) {
157
+ console.log('✅ [JWT Storage] Extracted userId from JWT:', payload.userId);
158
+ return payload.userId;
159
+ }
160
+ console.warn('⚠️ [JWT Storage] No userId field found in JWT payload');
161
+ return null;
162
+ } catch (error) {
163
+ console.error('❌ [JWT Storage] Failed to extract userId from token:', error);
164
+ return null;
165
+ }
166
+ };
167
+
168
+ /**
169
+ * Replace JWT token (for token refresh scenarios)
170
+ * @param newToken - New JWT token
171
+ * @returns Promise<boolean> - Success status
172
+ */
173
+ export const replaceJWT = async newToken => {
174
+ try {
175
+ if (!newToken || !isValidJWTFormat(newToken)) {
176
+ console.error('❌ [JWT Storage] Invalid token provided for replacement');
177
+ return false;
178
+ }
179
+ await clearJWT();
180
+ const stored = await storeJWT(newToken);
181
+ if (stored) {
182
+ console.log('✅ [JWT Storage] Token successfully replaced');
183
+ }
184
+ return stored;
185
+ } catch (error) {
186
+ console.error('❌ [JWT Storage] Failed to replace token:', error);
187
+ return false;
188
+ }
189
+ };
190
+
191
+ // ============================================
192
+ // DEPRECATED: Legacy token type support
193
+ // These are kept for backward compatibility but should not be used
194
+ // ============================================
195
+
196
+ /** @deprecated Use storeJWT instead */
197
+ export let TokenType = /*#__PURE__*/function (TokenType) {
198
+ TokenType["ENOCH"] = "enoch_token";
199
+ TokenType["ONAIROS"] = "onairos_jwt_token";
200
+ TokenType["AUTH"] = "auth_token";
201
+ return TokenType;
202
+ }({});
203
+
204
+ /** @deprecated Route-based token selection removed - SDK uses single token */
205
+ export const getTokenTypeForRoute = _route => {
206
+ console.warn('⚠️ [JWT Storage] getTokenTypeForRoute is deprecated - SDK uses single token');
207
+ return TokenType.AUTH;
208
+ };
209
+
210
+ /** @deprecated Use getJWT() instead */
211
+ export const getJWTForRoute = async _route => {
212
+ console.warn('⚠️ [JWT Storage] getJWTForRoute is deprecated - use getJWT() instead');
213
+ return getJWT();
214
+ };
215
+
216
+ /** @deprecated Use clearJWT() instead */
217
+ export const clearAllJWT = async () => {
218
+ console.warn('⚠️ [JWT Storage] clearAllJWT is deprecated - use clearJWT() instead');
219
+ return clearJWT();
220
+ };
221
+
222
+ /** @deprecated Use storeJWT() instead */
223
+ export const storeEnochJWT = async token => {
224
+ console.warn('⚠️ [JWT Storage] storeEnochJWT is deprecated - use storeJWT() instead');
225
+ return storeJWT(token);
226
+ };
227
+
228
+ /** @deprecated Use storeJWT() instead */
229
+ export const storeOnairosJWT = async token => {
230
+ console.warn('⚠️ [JWT Storage] storeOnairosJWT is deprecated - use storeJWT() instead');
231
+ return storeJWT(token);
232
+ };
233
+
234
+ /** @deprecated Use storeJWT() instead */
235
+ export const storeAuthToken = async token => {
236
+ console.warn('⚠️ [JWT Storage] storeAuthToken is deprecated - use storeJWT() instead');
237
+ return storeJWT(token);
238
+ };
239
+
240
+ /** @deprecated Use replaceJWT() instead */
241
+ export const replaceJWTAfterVerification = async (_tokenType, newToken) => {
242
+ console.warn('⚠️ [JWT Storage] replaceJWTAfterVerification is deprecated - use replaceJWT() instead');
243
+ return replaceJWT(newToken);
244
+ };
245
+
246
+ /** @deprecated For debugging only */
247
+ export const getAllTokens = async () => {
248
+ const token = await getJWT();
249
+ return {
250
+ sdk_token: token,
251
+ // Legacy keys for debugging
252
+ [TokenType.ENOCH]: null,
253
+ [TokenType.ONAIROS]: null,
254
+ [TokenType.AUTH]: null
255
+ };
256
+ };
257
+ //# sourceMappingURL=jwtStorageService.js.map