@onairos/react-native 3.7.1 → 3.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. package/lib/commonjs/api/index.js +219 -9
  2. package/lib/commonjs/assets/icons/spotify.png +0 -0
  3. package/lib/commonjs/assets/images/spotify.png +0 -0
  4. package/lib/commonjs/components/BodyText.js +27 -9
  5. package/lib/commonjs/components/BrandMark.js +111 -10
  6. package/lib/commonjs/components/CodeInput.js +116 -9
  7. package/lib/commonjs/components/EmailInput.js +30 -8
  8. package/lib/commonjs/components/GoogleButton.js +56 -9
  9. package/lib/commonjs/components/HeadingGroup.js +43 -9
  10. package/lib/commonjs/components/LLMDataInputModal.js +664 -14
  11. package/lib/commonjs/components/ModalHeader.js +99 -9
  12. package/lib/commonjs/components/ModalSheet.js +47 -9
  13. package/lib/commonjs/components/Onairos.js +380 -14
  14. package/lib/commonjs/components/OnairosButton.js +313 -13
  15. package/lib/commonjs/components/OnairosSignInButton.js +130 -12
  16. package/lib/commonjs/components/Overlay.js +465 -13
  17. package/lib/commonjs/components/PersonaImage.js +137 -10
  18. package/lib/commonjs/components/PersonaLoadingScreen.js +318 -12
  19. package/lib/commonjs/components/PersonalizationConsentScreen.js +467 -13
  20. package/lib/commonjs/components/PinCreationScreen.js +403 -12
  21. package/lib/commonjs/components/PinInput.js +464 -9
  22. package/lib/commonjs/components/PlatformConnectorsStep.js +1311 -23
  23. package/lib/commonjs/components/PlatformList.js +137 -10
  24. package/lib/commonjs/components/PlatformToggle.js +180 -9
  25. package/lib/commonjs/components/PrimaryButton.js +180 -10
  26. package/lib/commonjs/components/SignInMatchAnimation.js +197 -9
  27. package/lib/commonjs/components/SignInStep.js +345 -12
  28. package/lib/commonjs/components/UniversalOnboarding.js +2780 -30
  29. package/lib/commonjs/components/VerificationStep.js +176 -11
  30. package/lib/commonjs/components/WelcomeScreen.js +461 -22
  31. package/lib/commonjs/components/icons/Basicproficon.js +37 -8
  32. package/lib/commonjs/components/icons/Basicprofile.js +21 -8
  33. package/lib/commonjs/components/icons/Checkbox.js +21 -8
  34. package/lib/commonjs/components/icons/Checkmark.js +27 -8
  35. package/lib/commonjs/components/icons/Contentanalysis.js +21 -8
  36. package/lib/commonjs/components/icons/Contenticon.js +39 -8
  37. package/lib/commonjs/components/icons/EnochE.js +41 -8
  38. package/lib/commonjs/components/icons/Personalityicon.js +30 -8
  39. package/lib/commonjs/components/icons/Personalityprofile.js +21 -8
  40. package/lib/commonjs/components/icons/Personalitytraits.js +21 -8
  41. package/lib/commonjs/components/icons/Userpreferences.js +21 -8
  42. package/lib/commonjs/components/icons/index.js +84 -17
  43. package/lib/commonjs/components/onboarding/OAuthWebView.js +1754 -18
  44. package/lib/commonjs/components/onboarding/OnboardingHeader.js +74 -10
  45. package/lib/commonjs/components/onboarding/PinInput.js +283 -10
  46. package/lib/commonjs/components/onboarding/PlatformConnector.js +249 -11
  47. package/lib/commonjs/config/PLATFORM_APIS.md +849 -0
  48. package/lib/commonjs/config/api.js +56 -7
  49. package/lib/commonjs/constants/index.js +120 -7
  50. package/lib/commonjs/context/AuthContext.js +345 -10
  51. package/lib/commonjs/hooks/useConnectedAccounts.js +111 -9
  52. package/lib/commonjs/hooks/useConnections.js +102 -8
  53. package/lib/commonjs/hooks/useCredentials.js +178 -10
  54. package/lib/commonjs/hooks/useUserConnections.js +148 -10
  55. package/lib/commonjs/index.js +439 -34
  56. package/lib/commonjs/services/apiClient.js +298 -8
  57. package/lib/commonjs/services/biometricPinService.js +180 -8
  58. package/lib/commonjs/services/chatGPTConversationExtractor.js +155 -8
  59. package/lib/commonjs/services/chatGPTConversationService.js +275 -9
  60. package/lib/commonjs/services/claudeConversationExtractor.js +103 -8
  61. package/lib/commonjs/services/claudeConversationService.js +158 -9
  62. package/lib/commonjs/services/connectedAccountsService.js +310 -10
  63. package/lib/commonjs/services/googleAuthService.js +252 -11
  64. package/lib/commonjs/services/hingeDataExtractor.js +105 -8
  65. package/lib/commonjs/services/hingeDataService.js +150 -9
  66. package/lib/commonjs/services/imageCompressionService.js +260 -7
  67. package/lib/commonjs/services/instagramDataExtractor.js +126 -8
  68. package/lib/commonjs/services/instagramDataService.js +163 -9
  69. package/lib/commonjs/services/jwtStorageService.js +276 -7
  70. package/lib/commonjs/services/linkedinDOMExtractor.js +245 -7
  71. package/lib/commonjs/services/linkedinProfileService.js +222 -9
  72. package/lib/commonjs/services/linkedinScrapingService.js +230 -8
  73. package/lib/commonjs/services/llmDataStorage.js +294 -8
  74. package/lib/commonjs/services/mobileTrainingService.js +186 -8
  75. package/lib/commonjs/services/netflixDataExtractor.js +120 -8
  76. package/lib/commonjs/services/netflixDataService.js +198 -9
  77. package/lib/commonjs/services/pinEncryptionService.js +84 -8
  78. package/lib/commonjs/services/pinStorageUtils.js +105 -7
  79. package/lib/commonjs/services/platformAuthService.js +1484 -12
  80. package/lib/commonjs/services/sephoraDataExtractor.js +140 -8
  81. package/lib/commonjs/services/sephoraDataService.js +200 -9
  82. package/lib/commonjs/services/spotifyDataExtractor.js +148 -8
  83. package/lib/commonjs/services/spotifyDataService.js +241 -9
  84. package/lib/commonjs/services/storageService.js +404 -8
  85. package/lib/commonjs/services/telegramDataExtractor.js +115 -8
  86. package/lib/commonjs/services/telegramDataService.js +499 -9
  87. package/lib/commonjs/services/trainingApiHelpers.js +73 -7
  88. package/lib/commonjs/services/userConnectionsService.js +340 -10
  89. package/lib/commonjs/services/youtubeMigrationService.js +416 -10
  90. package/lib/commonjs/theme/index.js +250 -7
  91. package/lib/commonjs/types/ambient.d.js +2 -1
  92. package/lib/commonjs/types/declarations.d.js +2 -1
  93. package/lib/commonjs/types/index.js +6 -1
  94. package/lib/commonjs/types/node-fix.d.js +2 -1
  95. package/lib/commonjs/types/node-override.d.js +2 -1
  96. package/lib/commonjs/types/opacity.d.js +2 -1
  97. package/lib/commonjs/types.js +14 -1
  98. package/lib/commonjs/utils/Portal.js +98 -8
  99. package/lib/commonjs/utils/api.js +130 -9
  100. package/lib/commonjs/utils/assetRegistry.js +210 -35
  101. package/lib/commonjs/utils/auth.js +112 -9
  102. package/lib/commonjs/utils/connectorTests.js +613 -29
  103. package/lib/commonjs/utils/crypto.js +62 -8
  104. package/lib/commonjs/utils/debugHelper.js +64 -1
  105. package/lib/commonjs/utils/encryption.js +76 -7
  106. package/lib/commonjs/utils/eventUtils.js +288 -1
  107. package/lib/commonjs/utils/haptics.js +66 -9
  108. package/lib/commonjs/utils/imagePreloader.js +6 -1
  109. package/lib/commonjs/utils/networkDiagnostics.js +226 -8
  110. package/lib/commonjs/utils/onairosApi.js +350 -9
  111. package/lib/commonjs/utils/programmaticFlow.js +117 -9
  112. package/lib/commonjs/utils/retryHelper.js +220 -1
  113. package/lib/commonjs/utils/secureStorage.js +349 -10
  114. package/lib/commonjs/utils/webviewScripts/chatgpt.js +551 -1
  115. package/lib/commonjs/utils/webviewScripts/claude.js +376 -1
  116. package/lib/commonjs/utils/webviewScripts/hinge.js +411 -1
  117. package/lib/commonjs/utils/webviewScripts/index.js +698 -15
  118. package/lib/commonjs/utils/webviewScripts/instagram.js +454 -1
  119. package/lib/commonjs/utils/webviewScripts/linkedin.js +880 -1
  120. package/lib/commonjs/utils/webviewScripts/netflix.js +382 -1
  121. package/lib/commonjs/utils/webviewScripts/sephora.js +516 -1
  122. package/lib/commonjs/utils/webviewScripts/spotify.js +419 -1
  123. package/lib/commonjs/utils/webviewScripts/telegram.js +678 -1
  124. package/lib/module/api/index.js +211 -1
  125. package/lib/module/assets/icons/spotify.png +0 -0
  126. package/lib/module/assets/images/spotify.png +0 -0
  127. package/lib/module/components/BodyText.js +20 -1
  128. package/lib/module/components/BrandMark.js +104 -1
  129. package/lib/module/components/CodeInput.js +109 -1
  130. package/lib/module/components/EmailInput.js +23 -1
  131. package/lib/module/components/GoogleButton.js +49 -1
  132. package/lib/module/components/HeadingGroup.js +36 -1
  133. package/lib/module/components/LLMDataInputModal.js +656 -7
  134. package/lib/module/components/ModalHeader.js +92 -1
  135. package/lib/module/components/ModalSheet.js +39 -1
  136. package/lib/module/components/Onairos.js +373 -1
  137. package/lib/module/components/OnairosButton.js +305 -1
  138. package/lib/module/components/OnairosSignInButton.js +121 -1
  139. package/lib/module/components/Overlay.js +456 -1
  140. package/lib/module/components/PersonaImage.js +129 -1
  141. package/lib/module/components/PersonaLoadingScreen.js +310 -1
  142. package/lib/module/components/PersonalizationConsentScreen.js +460 -1
  143. package/lib/module/components/PinCreationScreen.js +396 -1
  144. package/lib/module/components/PinInput.js +456 -1
  145. package/lib/module/components/PlatformConnectorsStep.js +1302 -6
  146. package/lib/module/components/PlatformList.js +129 -1
  147. package/lib/module/components/PlatformToggle.js +173 -1
  148. package/lib/module/components/PrimaryButton.js +172 -1
  149. package/lib/module/components/SignInMatchAnimation.js +189 -1
  150. package/lib/module/components/SignInStep.js +338 -1
  151. package/lib/module/components/UniversalOnboarding.js +2770 -1
  152. package/lib/module/components/VerificationStep.js +168 -1
  153. package/lib/module/components/WelcomeScreen.js +453 -1
  154. package/lib/module/components/icons/Basicproficon.js +30 -1
  155. package/lib/module/components/icons/Basicprofile.js +14 -1
  156. package/lib/module/components/icons/Checkbox.js +14 -1
  157. package/lib/module/components/icons/Checkmark.js +20 -1
  158. package/lib/module/components/icons/Contentanalysis.js +14 -1
  159. package/lib/module/components/icons/Contenticon.js +32 -1
  160. package/lib/module/components/icons/EnochE.js +34 -1
  161. package/lib/module/components/icons/Personalityicon.js +23 -1
  162. package/lib/module/components/icons/Personalityprofile.js +14 -1
  163. package/lib/module/components/icons/Personalitytraits.js +14 -1
  164. package/lib/module/components/icons/Userpreferences.js +14 -1
  165. package/lib/module/components/icons/index.js +13 -1
  166. package/lib/module/components/onboarding/OAuthWebView.js +1746 -1
  167. package/lib/module/components/onboarding/OnboardingHeader.js +66 -1
  168. package/lib/module/components/onboarding/PinInput.js +274 -1
  169. package/lib/module/components/onboarding/PlatformConnector.js +240 -1
  170. package/lib/module/config/PLATFORM_APIS.md +849 -0
  171. package/lib/module/config/api.js +47 -1
  172. package/lib/module/constants/index.js +114 -1
  173. package/lib/module/context/AuthContext.js +335 -1
  174. package/lib/module/hooks/useConnectedAccounts.js +106 -1
  175. package/lib/module/hooks/useConnections.js +95 -1
  176. package/lib/module/hooks/useCredentials.js +171 -6
  177. package/lib/module/hooks/useUserConnections.js +140 -1
  178. package/lib/module/index.js +172 -1
  179. package/lib/module/services/apiClient.js +295 -1
  180. package/lib/module/services/biometricPinService.js +169 -1
  181. package/lib/module/services/chatGPTConversationExtractor.js +149 -1
  182. package/lib/module/services/chatGPTConversationService.js +268 -1
  183. package/lib/module/services/claudeConversationExtractor.js +97 -1
  184. package/lib/module/services/claudeConversationService.js +151 -1
  185. package/lib/module/services/connectedAccountsService.js +293 -1
  186. package/lib/module/services/googleAuthService.js +241 -1
  187. package/lib/module/services/hingeDataExtractor.js +99 -1
  188. package/lib/module/services/hingeDataService.js +143 -1
  189. package/lib/module/services/imageCompressionService.js +250 -1
  190. package/lib/module/services/instagramDataExtractor.js +120 -1
  191. package/lib/module/services/instagramDataService.js +156 -1
  192. package/lib/module/services/jwtStorageService.js +257 -1
  193. package/lib/module/services/linkedinDOMExtractor.js +234 -1
  194. package/lib/module/services/linkedinProfileService.js +210 -1
  195. package/lib/module/services/linkedinScrapingService.js +219 -1
  196. package/lib/module/services/llmDataStorage.js +277 -1
  197. package/lib/module/services/mobileTrainingService.js +173 -1
  198. package/lib/module/services/netflixDataExtractor.js +114 -1
  199. package/lib/module/services/netflixDataService.js +191 -1
  200. package/lib/module/services/pinEncryptionService.js +74 -6
  201. package/lib/module/services/pinStorageUtils.js +93 -1
  202. package/lib/module/services/platformAuthService.js +1461 -1
  203. package/lib/module/services/sephoraDataExtractor.js +134 -1
  204. package/lib/module/services/sephoraDataService.js +193 -1
  205. package/lib/module/services/spotifyDataExtractor.js +142 -1
  206. package/lib/module/services/spotifyDataService.js +234 -1
  207. package/lib/module/services/storageService.js +383 -1
  208. package/lib/module/services/telegramDataExtractor.js +109 -1
  209. package/lib/module/services/telegramDataService.js +493 -1
  210. package/lib/module/services/trainingApiHelpers.js +67 -1
  211. package/lib/module/services/userConnectionsService.js +329 -1
  212. package/lib/module/services/youtubeMigrationService.js +405 -1
  213. package/lib/module/theme/index.js +245 -1
  214. package/lib/module/types.js +10 -1
  215. package/lib/module/utils/Portal.js +90 -1
  216. package/lib/module/utils/api.js +118 -1
  217. package/lib/module/utils/assetRegistry.js +200 -34
  218. package/lib/module/utils/auth.js +100 -1
  219. package/lib/module/utils/connectorTests.js +600 -27
  220. package/lib/module/utils/crypto.js +54 -1
  221. package/lib/module/utils/debugHelper.js +54 -1
  222. package/lib/module/utils/encryption.js +67 -1
  223. package/lib/module/utils/eventUtils.js +270 -1
  224. package/lib/module/utils/haptics.js +59 -8
  225. package/lib/module/utils/imagePreloader.js +3 -1
  226. package/lib/module/utils/networkDiagnostics.js +217 -1
  227. package/lib/module/utils/onairosApi.js +333 -1
  228. package/lib/module/utils/programmaticFlow.js +111 -1
  229. package/lib/module/utils/retryHelper.js +211 -1
  230. package/lib/module/utils/secureStorage.js +330 -6
  231. package/lib/module/utils/webviewScripts/chatgpt.js +545 -1
  232. package/lib/module/utils/webviewScripts/claude.js +370 -1
  233. package/lib/module/utils/webviewScripts/hinge.js +405 -1
  234. package/lib/module/utils/webviewScripts/index.js +434 -1
  235. package/lib/module/utils/webviewScripts/instagram.js +448 -1
  236. package/lib/module/utils/webviewScripts/linkedin.js +874 -1
  237. package/lib/module/utils/webviewScripts/netflix.js +376 -1
  238. package/lib/module/utils/webviewScripts/sephora.js +510 -1
  239. package/lib/module/utils/webviewScripts/spotify.js +413 -1
  240. package/lib/module/utils/webviewScripts/telegram.js +672 -1
  241. package/package.json +2 -2
@@ -1 +1,120 @@
1
- import{storeInstagramData}from'./instagramDataService';function _0x3840(_0x11014c,_0x384001){_0x11014c=_0x11014c-0x0;const _0xdf880f=_0x1101();let _0x5a0a32=_0xdf880f[_0x11014c];return _0x5a0a32;}function _0x1101(){const _0x31bfdf=['Error','Username\x20is\x20required\x20to\x20export\x20Instagram\x20data.','default','⚠️\x20[INSTAGRAM_EXTRACTOR]\x20Invalid\x20collection:','EHTAC','⚠️\x20[INSTAGRAM_EXTRACTOR]\x20Invalid\x20save:','like','NKZRq','🚀\x20[INSTAGRAM_EXTRACTOR]\x20Initiating\x20data\x20export','📊\x20[INSTAGRAM_EXTRACTOR]\x20Likes:','📊\x20[INSTAGRAM_EXTRACTOR]\x20Saves:','📊\x20[INSTAGRAM_EXTRACTOR]\x20Collections:','RQCjb','✅\x20[INSTAGRAM_EXTRACTOR]\x20Export\x20completed\x20successfully','📊\x20[INSTAGRAM_EXTRACTOR]\x20Backend\x20response:','DbExn','❌\x20[INSTAGRAM_EXTRACTOR]\x20Backend\x20storage\x20failed:','Export\x20Failed','❌\x20[INSTAGRAM_EXTRACTOR]\x20Unexpected\x20error\x20during\x20export:','Export\x20Error','MlChw','ZFHQc','nnbkJ','mhMYN','nEtZs','EwxKg','qmkMp','warn','⚠️\x20[INSTAGRAM_EXTRACTOR]\x20Filtered\x20out\x20','\x20invalid\x20items','log','ilPAT','EpUGo','total_likes','ppSVU','total_saves','yJOcc','total_collections','CRmbn','ULQgB','❌\x20[INSTAGRAM_EXTRACTOR]\x20Username\x20is\x20required','alert','Feynu','error','qBMlo','yApRt','likes','xqlCC','length','egSWJ','saves','collections','iakTh','khDmT','rizOp','filter','type','WBjgk','JgDBu','hlhCu','EDJUI','qJoAX','xnjlA','Ccozu','jSFjM','name','qAbBC','BNzOJ','ieSGv','irexy','BBxFJ','tXQHz','UmzKK','uJtNb','KSfFE','Jaaun','JMaUV','dAQEO','lwgFc','OmqnN','userId','success','tsVQz','fKkeF','BjsPs','data','zQPWt'];_0x1101=function(){return _0x31bfdf;};return _0x1101();}import{Alert}from'react-native';export const useInstagramDataExtractor=()=>{const _0x4c7afc={'NEMNr':_0x3840(0x0),'Feynu':_0x3840(0x1),'qJoAX':_0x3840(0x2),'hlhCu':_0x3840(0x3),'EDJUI':'Failed\x20to\x20connect\x20to\x20the\x20data\x20storage\x20service.\x20Please\x20check\x20your\x20network\x20connection.','xnjlA':function(_0x1908b9,_0x1372db){return _0x1908b9!==_0x1372db;},'Ccozu':'MtyAu','khDmT':function(_0x5744ca,_0x357e77){return _0x5744ca===_0x357e77;},'qAbBC':_0x3840(0x4),'mhMYN':'save','wigwu':_0x3840(0x5),'MlChw':_0x3840(0x6),'ZFHQc':'⚠️\x20[INSTAGRAM_EXTRACTOR]\x20Invalid\x20like:','nnbkJ':function(_0x34fc33,_0x1bab40){return _0x34fc33===_0x1bab40;},'nEtZs':function(_0x5e8ba2,_0x80e810){return _0x5e8ba2===_0x80e810;},'EwxKg':'EijMH','qmkMp':_0x3840(0x7),'rYoHO':_0x3840(0x8),'ilPAT':'👤\x20[INSTAGRAM_EXTRACTOR]\x20Username:','EpUGo':_0x3840(0x9),'ppSVU':_0x3840(0xa),'yJOcc':_0x3840(0xb),'CRmbn':function(_0x31aec7,_0x3cded4){return _0x31aec7!==_0x3cded4;},'raJaI':'fHHzY','qBMlo':function(_0x5cceda,_0x44e8d6){return _0x5cceda+_0x44e8d6;},'yApRt':function(_0xd7550d,_0x4b3fd6){return _0xd7550d===_0x4b3fd6;},'xqlCC':function(_0x3a0917,_0x59e534){return _0x3a0917===_0x59e534;},'egSWJ':function(_0x59952d,_0x3fe914){return _0x59952d===_0x3fe914;},'iakTh':function(_0x210ccf,_0x9ef801){return _0x210ccf===_0x9ef801;},'rizOp':'ℹ️\x20[INSTAGRAM_EXTRACTOR]\x20No\x20data\x20to\x20export\x20-\x20treating\x20as\x20success\x20(connected)','BBxFJ':function(_0x5f26ff,_0x4c8410){return _0x5f26ff+_0x4c8410;},'tXQHz':function(_0x5a1a6b,_0x16643b){return _0x5a1a6b-_0x16643b;},'UmzKK':function(_0x5a8d8a,_0x56672d){return _0x5a8d8a===_0x56672d;},'uJtNb':function(_0x247d9a,_0x4f72c0){return _0x247d9a===_0x4f72c0;},'KSfFE':function(_0x33a6b2,_0x4b6396){return _0x33a6b2>_0x4b6396;},'Jaaun':function(_0x44caa1,_0x436521){return _0x44caa1!==_0x436521;},'JMaUV':_0x3840(0xc),'dAQEO':'OMGZE','lwgFc':'📡\x20[INSTAGRAM_EXTRACTOR]\x20Sending\x20to\x20backend...','OmqnN':function(_0x4f11dc,_0x42c565,_0x40ac7b){return _0x4f11dc(_0x42c565,_0x40ac7b);},'tsVQz':_0x3840(0xd),'KRXNm':_0x3840(0xe),'IQHFQ':_0x3840(0xf),'fhaYi':_0x3840(0x10),'fKkeF':_0x3840(0x11),'zQPWt':_0x3840(0x12),'WqcRT':_0x3840(0x13)},_0x1cf6cb=async(_0x5e9815,_0xfdb8eb)=>{const _0x327d0e={'WBjgk':_0x4c7afc[_0x3840(0x14)],'GanZK':_0x4c7afc[_0x3840(0x15)],'qbCAG':function(_0x25c7e7,_0xc0d040){return _0x4c7afc[_0x3840(0x16)](_0x25c7e7,_0xc0d040);},'JgDBu':_0x4c7afc[_0x3840(0x17)],'BjsPs':'✅\x20[INSTAGRAM_EXTRACTOR]\x20Export\x20completed\x20successfully'};if(_0x4c7afc[_0x3840(0x18)](_0x4c7afc[_0x3840(0x19)],_0x4c7afc[_0x3840(0x1a)]))_0x15e76c[_0x3840(0x1b)](_0x3840(0x1c)+_0x49cf7a+_0x3840(0x1d));else{var _0x2c1adc,_0xe11ef8,_0x853695,_0x3f9409,_0xe82efa,_0x365767;console['log'](_0x4c7afc['rYoHO']),console[_0x3840(0x1e)](_0x4c7afc[_0x3840(0x1f)],_0x5e9815),console[_0x3840(0x1e)](_0x4c7afc[_0x3840(0x20)],_0xfdb8eb[_0x3840(0x21)]),console[_0x3840(0x1e)](_0x4c7afc[_0x3840(0x22)],_0xfdb8eb[_0x3840(0x23)]),console[_0x3840(0x1e)](_0x4c7afc[_0x3840(0x24)],_0xfdb8eb[_0x3840(0x25)]);if(!_0x5e9815)return _0x4c7afc[_0x3840(0x26)](_0x3840(0x27),_0x4c7afc['raJaI'])?(console['error'](_0x3840(0x28)),Alert[_0x3840(0x29)](_0x3840(0x0),_0x4c7afc[_0x3840(0x2a)],[{'text':'OK','style':_0x4c7afc['qJoAX']}]),![]):(_0x48f2a4[_0x3840(0x2b)](_0x3840(0x28)),Alert[_0x3840(0x29)](_0x4c7afc['NEMNr'],_0x4c7afc[_0x3840(0x2a)],[{'text':'OK','style':_0x4c7afc['qJoAX']}]),![]);const _0x2a750f=_0x4c7afc[_0x3840(0x2c)](((_0x4c7afc[_0x3840(0x2d)](_0x2c1adc=_0xfdb8eb[_0x3840(0x2e)],null)||_0x4c7afc[_0x3840(0x2f)](_0x2c1adc,void 0x0)?void 0x0:_0x2c1adc[_0x3840(0x30)])||0x0)+((_0x4c7afc[_0x3840(0x31)](_0xe11ef8=_0xfdb8eb[_0x3840(0x32)],null)||_0x4c7afc[_0x3840(0x2d)](_0xe11ef8,void 0x0)?void 0x0:_0xe11ef8[_0x3840(0x30)])||0x0),(_0x4c7afc['egSWJ'](_0x853695=_0xfdb8eb[_0x3840(0x33)],null)||_0x4c7afc[_0x3840(0x34)](_0x853695,void 0x0)?void 0x0:_0x853695['length'])||0x0);if(_0x4c7afc[_0x3840(0x35)](_0x2a750f,0x0))return console[_0x3840(0x1e)](_0x4c7afc[_0x3840(0x36)]),!![];const _0x513ece=(_0xfdb8eb[_0x3840(0x2e)]||[])[_0x3840(0x37)](_0x3d1b2b=>{const _0x3ceeba=_0x3d1b2b['id']&&_0x3d1b2b[_0x3840(0x38)]===_0x327d0e[_0x3840(0x39)];return!_0x3ceeba&&console[_0x3840(0x1b)](_0x327d0e['GanZK'],_0x3d1b2b),_0x3ceeba;}),_0x400d4e=(_0xfdb8eb[_0x3840(0x32)]||[])[_0x3840(0x37)](_0x4f55a4=>{const _0x5b45f0=_0x4f55a4['id']&&_0x327d0e['qbCAG'](_0x4f55a4['type'],_0x327d0e[_0x3840(0x3a)]);return!_0x5b45f0&&console[_0x3840(0x1b)](_0x3840(0x5),_0x4f55a4),_0x5b45f0;}),_0x40a418=(_0xfdb8eb[_0x3840(0x33)]||[])[_0x3840(0x37)](_0x51405b=>{const _0x5bcc86={'jSFjM':_0x4c7afc[_0x3840(0x3b)],'BNzOJ':'❌\x20[INSTAGRAM_EXTRACTOR]\x20Unexpected\x20error\x20during\x20export:','ieSGv':_0x4c7afc[_0x3840(0x3c)],'irexy':_0x4c7afc[_0x3840(0x3d)]};if(_0x4c7afc[_0x3840(0x3e)](_0x4c7afc['Ccozu'],_0x4c7afc[_0x3840(0x3f)]))_0x26fc00[_0x3840(0x1b)](_0x5bcc86[_0x3840(0x40)],_0x5379af);else{const _0x21f2e9=_0x51405b['id']&&_0x51405b[_0x3840(0x41)];if(!_0x21f2e9){if(_0x4c7afc['khDmT']('OTANk',_0x4c7afc[_0x3840(0x42)]))return _0x2e0ec8[_0x3840(0x2b)](_0x5bcc86[_0x3840(0x43)],_0x968729),Alert[_0x3840(0x29)](_0x3840(0x13),_0x5bcc86[_0x3840(0x44)],[{'text':'OK','style':_0x5bcc86[_0x3840(0x45)]}]),![];else console[_0x3840(0x1b)](_0x4c7afc[_0x3840(0x3b)],_0x51405b);}return _0x21f2e9;}}),_0x261162=_0x4c7afc['BBxFJ'](_0x4c7afc[_0x3840(0x46)](_0x4c7afc[_0x3840(0x47)]((_0x4c7afc[_0x3840(0x18)](_0x3f9409=_0xfdb8eb[_0x3840(0x2e)],null)||_0x4c7afc[_0x3840(0x48)](_0x3f9409,void 0x0)?void 0x0:_0x3f9409[_0x3840(0x30)])||0x0,_0x513ece[_0x3840(0x30)]),((_0xe82efa=_0xfdb8eb[_0x3840(0x32)])===null||_0xe82efa===void 0x0?void 0x0:_0xe82efa[_0x3840(0x30)])||0x0)-_0x400d4e[_0x3840(0x30)],(_0x4c7afc[_0x3840(0x49)](_0x365767=_0xfdb8eb[_0x3840(0x33)],null)||_0x365767===void 0x0?void 0x0:_0x365767[_0x3840(0x30)])||0x0)-_0x40a418[_0x3840(0x30)];_0x4c7afc[_0x3840(0x4a)](_0x261162,0x0)&&console[_0x3840(0x1b)]('⚠️\x20[INSTAGRAM_EXTRACTOR]\x20Filtered\x20out\x20'+_0x261162+_0x3840(0x1d));try{if(_0x4c7afc[_0x3840(0x4b)](_0x4c7afc[_0x3840(0x4c)],_0x4c7afc[_0x3840(0x4d)])){console[_0x3840(0x1e)](_0x4c7afc[_0x3840(0x4e)]);const _0x2596e5=await _0x4c7afc[_0x3840(0x4f)](storeInstagramData,_0x5e9815,{'likes':_0x513ece,'saves':_0x400d4e,'collections':_0x40a418,'userId':_0xfdb8eb[_0x3840(0x50)]});if(_0x2596e5[_0x3840(0x51)])return console[_0x3840(0x1e)](_0x4c7afc[_0x3840(0x52)]),console[_0x3840(0x1e)](_0x4c7afc['KRXNm'],_0x2596e5['data']),!![];else{if(_0x4c7afc[_0x3840(0x18)](_0x3840(0xf),_0x4c7afc['IQHFQ']))return console[_0x3840(0x2b)](_0x4c7afc['fhaYi'],_0x2596e5[_0x3840(0x2b)]),Alert[_0x3840(0x29)](_0x4c7afc[_0x3840(0x53)],_0x2596e5[_0x3840(0x2b)]||'An\x20unknown\x20error\x20occurred\x20during\x20data\x20storage.',[{'text':'OK','style':'default'}]),![];else{const _0x34c611=_0x1cf71b['id']&&_0x4c7afc['khDmT'](_0x3d3d0f[_0x3840(0x38)],_0x4c7afc[_0x3840(0x17)]);return!_0x34c611&&_0x748bc3[_0x3840(0x1b)](_0x4c7afc['wigwu'],_0x12bfdb),_0x34c611;}}}else return _0x3cb2e1[_0x3840(0x1e)](_0x327d0e[_0x3840(0x54)]),_0x2ce1ea[_0x3840(0x1e)]('📊\x20[INSTAGRAM_EXTRACTOR]\x20Backend\x20response:',_0xf64850[_0x3840(0x55)]),!![];}catch(_0x103d91){return console[_0x3840(0x2b)](_0x4c7afc[_0x3840(0x56)],_0x103d91),Alert['alert'](_0x4c7afc['WqcRT'],_0x4c7afc[_0x3840(0x3c)],[{'text':'OK','style':_0x4c7afc[_0x3840(0x3d)]}]),![];}}};return{'initiateDataExport':_0x1cf6cb};};
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
- import{API_CONFIG}from'../config/api';import AsyncStorage from'@react-native-async-storage/async-storage';function _0x3808(){const _0x18f3c0=['❌\x20[INSTAGRAM_SERVICE]\x20Network\x20error:','Network\x20error.\x20Please\x20check\x20your\x20connection.','❌\x20[INSTAGRAM_SERVICE]\x20Invalid\x20input:\x20userId\x20missing','✅\x20[INSTAGRAM_SERVICE]\x20Successfully\x20stored\x20Instagram\x20data','🚀\x20[INSTAGRAM_SERVICE]\x20Storing\x20Instagram\x20data\x20for:','📊\x20[INSTAGRAM_SERVICE]\x20Collections:','xnlcO','Zmydx','ELVvy','onairos_jwt_token','enoch_token','auth_token','Authentication\x20token\x20not\x20found.\x20Please\x20log\x20in\x20again.','ios','17.0','Android','📡\x20[INSTAGRAM_SERVICE]\x20Sending\x20to\x20backend...','📍\x20[INSTAGRAM_SERVICE]\x20URL:','bqYnA','log','MxIRy','likes','length','📊\x20[INSTAGRAM_SERVICE]\x20Saves:','saves','MAKli','collections','YPYtM','zaUQe','error','IkymW','message','qLEwO','xOYFd','qjVSW','getItem','gTOhN','GGAKI','❌\x20[INSTAGRAM_SERVICE]\x20No\x20auth\x20token\x20found','jiYmx','kBQIj','LucJm','RSqWu','TvGDB','vEzzV','toISOString','mobile-instagram','social','map','like','mediaType','owner','timestamp','url','save','caption','name','mediaCount','coverUrl','userId','nvdfP','BASE_URL','/platform-data/store','LEvdc','Bearer\x20','OnairosSDK/1.0.0\x20(','stringify','json','vlPfg','📝\x20[INSTAGRAM_SERVICE]\x20Backend\x20response:\x20','data','cGAIB','warn','status','⚠️\x20[INSTAGRAM_SERVICE]\x20Error:\x20','Unknown\x20error','HTTP\x20','rjqeJ','Instagram\x20data\x20stored\x20successfully','kFfKD'];_0x3808=function(){return _0x18f3c0;};return _0x3808();}import{Platform}from'react-native';function _0x1e66(_0x38087f,_0x1e6679){_0x38087f=_0x38087f-0x0;const _0x5e293f=_0x3808();let _0x1e1700=_0x5e293f[_0x38087f];return _0x1e1700;}export const storeInstagramData=async(_0x32ed3c,_0x2c26a2)=>{const _0x18c88d={'IkymW':_0x1e66(0x0),'kFfKD':_0x1e66(0x1),'Sewwo':_0x1e66(0x2),'qLEwO':'Invalid\x20input:\x20userId\x20missing.','vlPfg':_0x1e66(0x3),'xddLy':_0x1e66(0x4),'MxIRy':'📊\x20[INSTAGRAM_SERVICE]\x20Likes:','MAKli':_0x1e66(0x5),'YPYtM':function(_0xb6b337,_0x2e79b7){return _0xb6b337===_0x2e79b7;},'gATRy':_0x1e66(0x6),'zaUQe':_0x1e66(0x7),'ZGdxl':function(_0x32d5e4,_0xa903a8){return _0x32d5e4!==_0xa903a8;},'xOYFd':'NJRYc','qjVSW':_0x1e66(0x8),'nrWKF':_0x1e66(0x9),'gTOhN':_0x1e66(0xa),'GGAKI':_0x1e66(0xb),'jiYmx':_0x1e66(0xc),'VWnoo':'🔑\x20[INSTAGRAM_SERVICE]\x20Auth\x20token\x20found','kBQIj':'1.0.0','LucJm':function(_0x5dd44f,_0x22522b){return _0x5dd44f===_0x22522b;},'RSqWu':_0x1e66(0xd),'feYAx':_0x1e66(0xe),'TvGDB':'iPhone','vEzzV':_0x1e66(0xf),'UZmEj':function(_0x2f205e,_0x2b3c93){return _0x2f205e+_0x2b3c93;},'pUsDq':_0x1e66(0x10),'nvdfP':_0x1e66(0x11),'LEvdc':function(_0x2e36e2,_0x39fb5e,_0x367621){return _0x2e36e2(_0x39fb5e,_0x367621);},'cGAIB':_0x1e66(0x12)};console[_0x1e66(0x13)](_0x18c88d['xddLy'],_0x32ed3c),console['log'](_0x18c88d[_0x1e66(0x14)],_0x2c26a2[_0x1e66(0x15)][_0x1e66(0x16)]),console[_0x1e66(0x13)](_0x1e66(0x17),_0x2c26a2[_0x1e66(0x18)][_0x1e66(0x16)]),console[_0x1e66(0x13)](_0x18c88d[_0x1e66(0x19)],_0x2c26a2[_0x1e66(0x1a)]['length']);if(!_0x32ed3c)return _0x18c88d[_0x1e66(0x1b)](_0x18c88d['gATRy'],_0x18c88d[_0x1e66(0x1c)])?(_0x69f124[_0x1e66(0x1d)](_0x18c88d[_0x1e66(0x1e)],_0x42410f),{'success':![],'error':_0x4f668c[_0x1e66(0x1f)]||_0x18c88d['kFfKD']}):(console['error'](_0x18c88d['Sewwo']),{'success':![],'error':_0x18c88d[_0x1e66(0x20)]});try{if(_0x18c88d['ZGdxl'](_0x18c88d[_0x1e66(0x21)],_0x18c88d[_0x1e66(0x22)])){const _0x292c6b=await AsyncStorage[_0x1e66(0x23)](_0x18c88d['nrWKF'])||await AsyncStorage[_0x1e66(0x23)](_0x18c88d[_0x1e66(0x24)])||await AsyncStorage[_0x1e66(0x23)](_0x18c88d[_0x1e66(0x25)]);if(!_0x292c6b)return console['error'](_0x1e66(0x26)),{'success':![],'error':_0x18c88d[_0x1e66(0x27)]};console['log'](_0x18c88d['VWnoo']);const _0x6c5a9={'platform':Platform['OS'],'appVersion':_0x18c88d[_0x1e66(0x28)],'osVersion':_0x18c88d[_0x1e66(0x29)](Platform['OS'],_0x18c88d[_0x1e66(0x2a)])?_0x18c88d['feYAx']:Platform['OS'],'deviceModel':_0x18c88d['YPYtM'](Platform['OS'],_0x18c88d[_0x1e66(0x2a)])?_0x18c88d[_0x1e66(0x2b)]:_0x18c88d[_0x1e66(0x2c)],'isOfflineSync':![],'extractedAt':new Date()[_0x1e66(0x2d)]()},_0x52855c={'platform':_0x1e66(0x2e),'dataType':_0x1e66(0x2f),'data':{'likes':_0x2c26a2[_0x1e66(0x15)][_0x1e66(0x30)](_0x413c80=>({'postId':_0x413c80['id'],'type':_0x1e66(0x31),'mediaType':_0x413c80[_0x1e66(0x32)],'caption':_0x413c80['caption'],'owner':_0x413c80[_0x1e66(0x33)],'timestamp':_0x413c80[_0x1e66(0x34)],'url':_0x413c80[_0x1e66(0x35)]})),'saves':_0x2c26a2['saves'][_0x1e66(0x30)](_0x336a6c=>({'postId':_0x336a6c['id'],'type':_0x1e66(0x36),'mediaType':_0x336a6c[_0x1e66(0x32)],'caption':_0x336a6c[_0x1e66(0x37)],'owner':_0x336a6c[_0x1e66(0x33)],'timestamp':_0x336a6c[_0x1e66(0x34)],'url':_0x336a6c[_0x1e66(0x35)]})),'collections':_0x2c26a2[_0x1e66(0x1a)][_0x1e66(0x30)](_0x59aee2=>({'collectionId':_0x59aee2['id'],'name':_0x59aee2[_0x1e66(0x38)],'mediaCount':_0x59aee2[_0x1e66(0x39)],'coverUrl':_0x59aee2[_0x1e66(0x3a)]})),'instagramUserId':_0x2c26a2[_0x1e66(0x3b)]},'summary':{'likeCount':_0x2c26a2[_0x1e66(0x15)][_0x1e66(0x16)],'saveCount':_0x2c26a2[_0x1e66(0x18)]['length'],'collectionCount':_0x2c26a2[_0x1e66(0x1a)]['length'],'totalEngagements':_0x18c88d['UZmEj'](_0x2c26a2[_0x1e66(0x15)][_0x1e66(0x16)],_0x2c26a2[_0x1e66(0x18)][_0x1e66(0x16)])},'mobileMetadata':_0x6c5a9};console[_0x1e66(0x13)](_0x18c88d['pUsDq']),console['log'](_0x18c88d[_0x1e66(0x3c)],API_CONFIG[_0x1e66(0x3d)]+_0x1e66(0x3e));const _0xc6826=await _0x18c88d[_0x1e66(0x3f)](fetch,API_CONFIG[_0x1e66(0x3d)]+_0x1e66(0x3e),{'method':'POST','headers':{'Content-Type':'application/json','Authorization':_0x1e66(0x40)+_0x292c6b,'User-Agent':_0x1e66(0x41)+Platform['OS']+')'},'body':JSON[_0x1e66(0x42)](_0x52855c)}),_0x4ba00a=await _0xc6826[_0x1e66(0x43)]();if(_0xc6826['ok'])return console[_0x1e66(0x13)](_0x18c88d[_0x1e66(0x44)]),_0x4ba00a[_0x1e66(0x1f)]&&console['log'](_0x1e66(0x45)+_0x4ba00a[_0x1e66(0x1f)]),{'success':!![],'message':_0x4ba00a['message']||'Instagram\x20data\x20stored\x20successfully','data':_0x4ba00a[_0x1e66(0x46)]};else{if(_0x18c88d[_0x1e66(0x47)]!==_0x18c88d[_0x1e66(0x47)])_0x50d0b8[_0x1e66(0x13)](_0x1e66(0x45)+_0x1191a1[_0x1e66(0x1f)]);else return console[_0x1e66(0x48)]('⚠️\x20[INSTAGRAM_SERVICE]\x20Backend\x20returned\x20status:\x20'+_0xc6826[_0x1e66(0x49)]),console['warn'](_0x1e66(0x4a)+(_0x4ba00a['error']||_0x1e66(0x4b))),{'success':![],'error':_0x4ba00a[_0x1e66(0x1d)]||_0x1e66(0x4c)+_0xc6826[_0x1e66(0x49)]};}}else return _0xe931c[_0x1e66(0x1d)](_0x18c88d['Sewwo']),{'success':![],'error':_0x18c88d[_0x1e66(0x20)]};}catch(_0x1bc310){return _0x18c88d['ZGdxl'](_0x1e66(0x4d),'rjqeJ')?(_0x580ef5[_0x1e66(0x13)](_0x18c88d[_0x1e66(0x44)]),_0x1d5c84[_0x1e66(0x1f)]&&_0x4320cc[_0x1e66(0x13)](_0x1e66(0x45)+_0x213a73['message']),{'success':!![],'message':_0x4a33a4[_0x1e66(0x1f)]||_0x1e66(0x4e),'data':_0x47cc1e[_0x1e66(0x46)]}):(console[_0x1e66(0x1d)](_0x18c88d[_0x1e66(0x1e)],_0x1bc310),{'success':![],'error':_0x1bc310[_0x1e66(0x1f)]||_0x18c88d[_0x1e66(0x4f)]});}};
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';function _0x3dc8(){const _0x288e3b=['sdk_jwt_token','QXGFS','yDkcJ','length','includes','vIZwX','error','❌\x20[JWT\x20Storage]\x20Failed\x20to\x20clear\x20token:','split','❌\x20[JWT\x20Storage]\x20Failed\x20to\x20store\x20token:','warn','FANbf','⚠️\x20[JWT\x20Storage]\x20Invalid\x20JWT\x20format\x20-\x20token\x20should\x20have\x203\x20parts','setItem','log','YPPOG','ENOCH','enoch_token','ONAIROS','🔐\x20[JWT\x20Storage]\x20Token\x20retrieved\x20successfully','SwPry','getItem','📭\x20[JWT\x20Storage]\x20No\x20token\x20found\x20in\x20storage','⚠️\x20[JWT\x20Storage]\x20Invalid\x20JWT\x20format\x20found,\x20removing','xYjAJ','❌\x20[JWT\x20Storage]\x20Failed\x20to\x20retrieve\x20token:','LfOZq','AUTH','⚠️\x20[JWT\x20Storage]\x20replaceJWTAfterVerification\x20is\x20deprecated\x20-\x20use\x20replaceJWT()\x20instead','✅\x20[JWT\x20Storage]\x20Token\x20cleared\x20successfully','FYRlu','removeItem','zaRZF','prCsp','bZVNb','ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=','qBQZQ','xAedb','TZNcd','VRpBM','❌\x20[JWT\x20Storage]\x20Invalid\x20token\x20provided\x20for\x20replacement','charAt','aAPfd','indexOf','cZGKa','ksXZP','XZDnR','CNcwS','fromCharCode','KXory','JhAKr','⚠️\x20[JWT\x20Storage]\x20storeOnairosJWT\x20is\x20deprecated\x20-\x20use\x20storeJWT()\x20instead','📭\x20[JWT\x20Storage]\x20No\x20token\x20found\x20for\x20userId\x20extraction','⚠️\x20[JWT\x20Storage]\x20Invalid\x20JWT\x20format\x20for\x20userId\x20extraction','QikeB','⚠️\x20[JWT\x20Storage]\x20No\x20userId\x20field\x20found\x20in\x20JWT\x20payload','RDKCy','byNiB','Cdkvm','rPIgB','xJjiW','lJXOM','jPMBS','bpIQQ','FWFot','LQVsL','YVVSR','FmlAc','parse','userId','VgwEW','ZdAiP','KvBOB','aRabM','✅\x20[JWT\x20Storage]\x20Extracted\x20userId\x20from\x20JWT:','FNhSQ','❌\x20[JWT\x20Storage]\x20Failed\x20to\x20extract\x20userId\x20from\x20token:','✅\x20[JWT\x20Storage]\x20Token\x20successfully\x20replaced','qeHef','EIpty','bOLDk','pNDhI','QuUFR','Tkejy','Gzwjn','YPIlG','LEmlH','❌\x20[JWT\x20Storage]\x20Failed\x20to\x20replace\x20token:','auth_token','BBSYn','oeuNa','YVhXT','hAkUb','uGhdE','⚠️\x20[JWT\x20Storage]\x20getTokenTypeForRoute\x20is\x20deprecated\x20-\x20SDK\x20uses\x20single\x20token','QyVyz','iwnRA','flKVs','raAnR','⚠️\x20[JWT\x20Storage]\x20storeEnochJWT\x20is\x20deprecated\x20-\x20use\x20storeJWT()\x20instead','hyhZt','sTpfy','⚠️\x20[JWT\x20Storage]\x20storeAuthToken\x20is\x20deprecated\x20-\x20use\x20storeJWT()\x20instead','fxQeq','BpwMs','JqUPm'];_0x3dc8=function(){return _0x288e3b;};return _0x3dc8();}const SDK_TOKEN_KEY=_0x48ec(0x0),isValidJWTFormat=_0x2e2d6b=>{const _0x43d91c={'yDkcJ':function(_0x2fe961,_0x307dda){return _0x2fe961<_0x307dda;},'vIZwX':_0x48ec(0x1),'HIwUA':function(_0x5e0469,_0x3f5381){return _0x5e0469!==_0x3f5381;}};if(!_0x2e2d6b||_0x43d91c[_0x48ec(0x2)](_0x2e2d6b[_0x48ec(0x3)],0x14))return![];if(_0x2e2d6b[_0x48ec(0x4)]('@')&&_0x2e2d6b['includes']('.')&&!_0x2e2d6b[_0x48ec(0x4)]('Bearer')&&_0x2e2d6b[_0x48ec(0x3)]<0x64)return _0x43d91c[_0x48ec(0x5)]!==_0x48ec(0x1)?(_0x199893[_0x48ec(0x6)](_0x48ec(0x7),_0x1b3059),![]):![];const _0x30b4d3=_0x2e2d6b[_0x48ec(0x8)]('.');if(_0x43d91c['HIwUA'](_0x30b4d3[_0x48ec(0x3)],0x3))return![];if(_0x43d91c[_0x48ec(0x2)](_0x2e2d6b[_0x48ec(0x3)],0x32))return![];return!![];};export const storeJWT=async _0x12cf51=>{const _0x18c2b6={'FANbf':function(_0x216e39,_0x554219){return _0x216e39(_0x554219);},'UWLaz':'✅\x20[JWT\x20Storage]\x20Token\x20stored\x20successfully','YPPOG':_0x48ec(0x9)};try{if(!_0x12cf51||_0x12cf51['trim']()==='')return console[_0x48ec(0xa)]('⚠️\x20[JWT\x20Storage]\x20Attempted\x20to\x20store\x20empty/null\x20token'),![];if(!_0x18c2b6[_0x48ec(0xb)](isValidJWTFormat,_0x12cf51))return console[_0x48ec(0xa)](_0x48ec(0xc)),![];return await AsyncStorage[_0x48ec(0xd)](SDK_TOKEN_KEY,_0x12cf51),console[_0x48ec(0xe)](_0x18c2b6['UWLaz']),!![];}catch(_0xf3df96){return console[_0x48ec(0x6)](_0x18c2b6[_0x48ec(0xf)],_0xf3df96),![];}};export const getJWT=async()=>{const _0x438b02={'LfOZq':_0x48ec(0x10),'nTmtR':_0x48ec(0x11),'HXwDc':_0x48ec(0x12),'Dwoyy':'onairos_jwt_token','xDkpU':function(_0x1466e9,_0x2597d1){return _0x1466e9(_0x2597d1);},'xYjAJ':_0x48ec(0x13),'DWmTy':_0x48ec(0x14)};try{const _0x540fc0=await AsyncStorage[_0x48ec(0x15)](SDK_TOKEN_KEY);if(!_0x540fc0)return console['log'](_0x48ec(0x16)),null;if(!_0x438b02['xDkpU'](isValidJWTFormat,_0x540fc0))return console['warn'](_0x48ec(0x17)),await clearJWT(),null;return console[_0x48ec(0xe)](_0x438b02[_0x48ec(0x18)]),_0x540fc0;}catch(_0x4fb536){return _0x438b02['DWmTy']===_0x48ec(0x14)?(console[_0x48ec(0x6)](_0x48ec(0x19),_0x4fb536),null):(_0xfb5a59[_0x438b02[_0x48ec(0x1a)]]=_0x438b02['nTmtR'],_0x593b51[_0x438b02['HXwDc']]=_0x438b02['Dwoyy'],_0x50cd1a[_0x48ec(0x1b)]='auth_token',_0x2d6ffe);}};export const clearJWT=async()=>{const _0x346be7={'prCsp':_0x48ec(0x1c),'ZamRh':function(_0x2c8567,_0x4e0d10){return _0x2c8567(_0x4e0d10);},'FYRlu':'CJKEp','zaRZF':_0x48ec(0x1d)};try{return _0x346be7[_0x48ec(0x1e)]===_0x346be7[_0x48ec(0x1e)]?(await AsyncStorage[_0x48ec(0x1f)](SDK_TOKEN_KEY),console['log'](_0x346be7[_0x48ec(0x20)]),!![]):(_0x1de223['warn'](_0x346be7[_0x48ec(0x21)]),_0x346be7['ZamRh'](_0x5e3407,_0x4cd11c));}catch(_0x458e2a){return console[_0x48ec(0x6)](_0x48ec(0x7),_0x458e2a),![];}};function _0x48ec(_0x3dc815,_0x48ec8f){_0x3dc815=_0x3dc815-0x0;const _0x1b165f=_0x3dc8();let _0x10c6ce=_0x1b165f[_0x3dc815];return _0x10c6ce;}export const hasValidJWT=async()=>{const _0xa0bba={'bZVNb':function(_0x54ea0d,_0xa11b23){return _0x54ea0d!==_0xa11b23;}},_0x3fac65=await getJWT();return _0xa0bba[_0x48ec(0x22)](_0x3fac65,null);};const base64Decode=_0x2af607=>{const _0x36fe82={'xAedb':_0x48ec(0x23),'SOxpa':function(_0x1d552c,_0x12cab6){return _0x1d552c<_0x12cab6;},'TZNcd':function(_0x50d702,_0x2fb9a1){return _0x50d702!==_0x2fb9a1;},'VRpBM':_0x48ec(0x24),'aAPfd':function(_0x297820,_0xcc6db9){return _0x297820+_0xcc6db9;},'ToYaz':function(_0x162ecb,_0xeffdb9){return _0x162ecb+_0xeffdb9;},'ksXZP':function(_0x29531c,_0x303e2f){return _0x29531c|_0x303e2f;},'cZGKa':function(_0x272d86,_0x1637fc){return _0x272d86<<_0x1637fc;},'XZDnR':function(_0x105503,_0x40dca3){return _0x105503&_0x40dca3;},'NjHNT':function(_0x326b2f,_0x269e76){return _0x326b2f>>_0x269e76;},'CNcwS':function(_0x3767d7,_0x1f9221){return _0x3767d7<<_0x1f9221;},'KXory':function(_0x455e78,_0x494fce){return _0x455e78!==_0x494fce;},'JhAKr':function(_0x28c36f,_0x226a7c){return _0x28c36f(_0x226a7c);}},_0x4cb0f4=_0x36fe82[_0x48ec(0x25)];let _0x4bc77f='';_0x2af607=_0x2af607['replace'](/=+$/,'');for(let _0x392f55=0x0;_0x36fe82['SOxpa'](_0x392f55,_0x2af607[_0x48ec(0x3)]);_0x392f55+=0x4){if(_0x36fe82[_0x48ec(0x26)](_0x48ec(0x24),_0x36fe82[_0x48ec(0x27)]))return _0x3a5f46[_0x48ec(0x6)](_0x48ec(0x28)),![];else{const _0x3b4984=_0x4cb0f4['indexOf'](_0x2af607[_0x48ec(0x29)](_0x392f55)),_0x373d57=_0x4cb0f4['indexOf'](_0x2af607[_0x48ec(0x29)](_0x36fe82[_0x48ec(0x2a)](_0x392f55,0x1))),_0x4a3afd=_0x4cb0f4[_0x48ec(0x2b)](_0x2af607[_0x48ec(0x29)](_0x36fe82[_0x48ec(0x2a)](_0x392f55,0x2))),_0x28321a=_0x4cb0f4[_0x48ec(0x2b)](_0x2af607[_0x48ec(0x29)](_0x36fe82['ToYaz'](_0x392f55,0x3))),_0x95d074=_0x36fe82['ksXZP'](_0x36fe82[_0x48ec(0x2c)](_0x3b4984,0x2),_0x373d57>>0x4),_0x499524=_0x36fe82[_0x48ec(0x2d)](_0x36fe82[_0x48ec(0x2c)](_0x36fe82[_0x48ec(0x2e)](_0x373d57,0xf),0x4),_0x36fe82['NjHNT'](_0x4a3afd,0x2)),_0x24b03f=_0x36fe82[_0x48ec(0x2d)](_0x36fe82[_0x48ec(0x2f)](_0x36fe82[_0x48ec(0x2e)](_0x4a3afd,0x3),0x6),_0x28321a);_0x4bc77f+=String[_0x48ec(0x30)](_0x95d074);if(_0x36fe82[_0x48ec(0x26)](_0x4a3afd,0x40))_0x4bc77f+=String[_0x48ec(0x30)](_0x499524);if(_0x36fe82[_0x48ec(0x31)](_0x28321a,0x40))_0x4bc77f+=String[_0x48ec(0x30)](_0x24b03f);}}return _0x36fe82[_0x48ec(0x32)](decodeURIComponent,escape(_0x4bc77f));};export const getUserIdFromToken=async()=>{const _0x395fb7={'lJXOM':function(_0x86fd10,_0xceb0fe){return _0x86fd10+_0xceb0fe;},'jPMBS':function(_0x4a1f47,_0x54508e){return _0x4a1f47|_0x54508e;},'bpIQQ':function(_0x6f5da,_0xfec204){return _0x6f5da<<_0xfec204;},'FWFot':function(_0x41692f,_0xb0c3a6){return _0x41692f|_0xb0c3a6;},'LQVsL':function(_0x13bb9a,_0x28df67){return _0x13bb9a&_0x28df67;},'YVVSR':function(_0x55ae9c,_0x2656dd){return _0x55ae9c>>_0x2656dd;},'FmlAc':function(_0x292607,_0x16433e){return _0x292607!==_0x16433e;},'KvBOB':_0x48ec(0x33),'aRabM':function(_0x3c3a5f,_0x41dfaa){return _0x3c3a5f(_0x41dfaa);},'RDKCy':function(_0x305535){return _0x305535();},'byNiB':function(_0x12ce78,_0x15621c){return _0x12ce78===_0x15621c;},'rPIgB':'Cdkvm','xJjiW':_0x48ec(0x34),'VgwEW':function(_0xa1a596,_0x35a7df){return _0xa1a596!==_0x35a7df;},'eByBA':_0x48ec(0x35),'vWAvS':function(_0x30b14d,_0x3324dd){return _0x30b14d(_0x3324dd);},'ZdAiP':_0x48ec(0x36),'FNhSQ':_0x48ec(0x37)};try{const _0x55fee1=await _0x395fb7[_0x48ec(0x38)](getJWT);if(!_0x55fee1){if(_0x395fb7[_0x48ec(0x39)](_0x48ec(0x3a),_0x395fb7[_0x48ec(0x3b)]))return console[_0x48ec(0xe)](_0x395fb7[_0x48ec(0x3c)]),null;else{const _0x55b99b=_0x1157f9[_0x48ec(0x2b)](_0x1999ce[_0x48ec(0x29)](_0x16378a)),_0x1eff9c=_0x2eb455['indexOf'](_0x3b3746[_0x48ec(0x29)](_0xee9041+0x1)),_0x157fa4=_0x25b03a['indexOf'](_0x5bf87e[_0x48ec(0x29)](_0x395fb7[_0x48ec(0x3d)](_0x155de4,0x2))),_0xd78320=_0x4fd436[_0x48ec(0x2b)](_0x2b8b2e[_0x48ec(0x29)](_0x395fb7[_0x48ec(0x3d)](_0x37d0c5,0x3))),_0x541300=_0x395fb7[_0x48ec(0x3e)](_0x395fb7[_0x48ec(0x3f)](_0x55b99b,0x2),_0x1eff9c>>0x4),_0x51f8aa=_0x395fb7[_0x48ec(0x40)](_0x395fb7[_0x48ec(0x41)](_0x1eff9c,0xf)<<0x4,_0x395fb7[_0x48ec(0x42)](_0x157fa4,0x2)),_0x443142=_0x395fb7[_0x48ec(0x3e)](_0x395fb7[_0x48ec(0x3f)](_0x395fb7[_0x48ec(0x41)](_0x157fa4,0x3),0x6),_0xd78320);_0x58c484+=_0x535057['fromCharCode'](_0x541300);if(_0x395fb7[_0x48ec(0x43)](_0x157fa4,0x40))_0x5029bf+=_0x339c56[_0x48ec(0x30)](_0x51f8aa);if(_0x395fb7[_0x48ec(0x43)](_0xd78320,0x40))_0x3e8215+=_0x385ed2[_0x48ec(0x30)](_0x443142);}}const _0x21a390=_0x55fee1['split']('.');if(_0x395fb7['VgwEW'](_0x21a390[_0x48ec(0x3)],0x3))return console[_0x48ec(0xa)](_0x395fb7['eByBA']),null;const _0x565ed1=JSON[_0x48ec(0x44)](_0x395fb7['vWAvS'](base64Decode,_0x21a390[0x1]));if(_0x565ed1[_0x48ec(0x45)])return _0x395fb7[_0x48ec(0x46)](_0x395fb7[_0x48ec(0x47)],_0x395fb7[_0x48ec(0x47)])?(_0x15826a[_0x48ec(0xa)](_0x395fb7[_0x48ec(0x48)]),_0x395fb7[_0x48ec(0x49)](_0x2f8c06,_0x4ddcd6)):(console[_0x48ec(0xe)](_0x48ec(0x4a),_0x565ed1[_0x48ec(0x45)]),_0x565ed1[_0x48ec(0x45)]);return console[_0x48ec(0xa)](_0x395fb7[_0x48ec(0x4b)]),null;}catch(_0x4f8f02){return console[_0x48ec(0x6)](_0x48ec(0x4c),_0x4f8f02),null;}};export const replaceJWT=async _0x3bede4=>{const _0x367e36={'pNDhI':_0x48ec(0x35),'vdUYB':function(_0x24ad6e,_0x2e5a89){return _0x24ad6e===_0x2e5a89;},'EIpty':'iEMxd','bOLDk':'UJnZd','QuUFR':function(_0x277c5e,_0x2341e7){return _0x277c5e(_0x2341e7);},'Tkejy':'❌\x20[JWT\x20Storage]\x20Invalid\x20token\x20provided\x20for\x20replacement','bnReA':function(_0x59e603,_0x44d32a){return _0x59e603(_0x44d32a);},'Gzwjn':_0x48ec(0x4d),'YPIlG':'axWoL','LEmlH':_0x48ec(0x4e)};try{if(_0x367e36['vdUYB'](_0x367e36[_0x48ec(0x4f)],_0x367e36[_0x48ec(0x50)]))return _0x155003[_0x48ec(0xa)](_0x367e36[_0x48ec(0x51)]),null;else{if(!_0x3bede4||!_0x367e36[_0x48ec(0x52)](isValidJWTFormat,_0x3bede4))return console[_0x48ec(0x6)](_0x367e36[_0x48ec(0x53)]),![];await clearJWT();const _0x1e032d=await _0x367e36['bnReA'](storeJWT,_0x3bede4);return _0x1e032d&&console[_0x48ec(0xe)](_0x367e36[_0x48ec(0x54)]),_0x1e032d;}}catch(_0x448a40){return _0x367e36[_0x48ec(0x55)]!==_0x367e36[_0x48ec(0x56)]?(console[_0x48ec(0x6)](_0x48ec(0x57),_0x448a40),![]):(_0x4d650f[_0x48ec(0x6)]('❌\x20[JWT\x20Storage]\x20Failed\x20to\x20store\x20token:',_0x1178a2),![]);}};export let TokenType=function(_0x5e2fa8){const _0x2b122c={'BBSYn':_0x48ec(0x10),'oeuNa':_0x48ec(0x11),'YVhXT':'ONAIROS','hAkUb':_0x48ec(0x1b),'uGhdE':_0x48ec(0x58)};return _0x5e2fa8[_0x2b122c[_0x48ec(0x59)]]=_0x2b122c[_0x48ec(0x5a)],_0x5e2fa8[_0x2b122c[_0x48ec(0x5b)]]='onairos_jwt_token',_0x5e2fa8[_0x2b122c[_0x48ec(0x5c)]]=_0x2b122c[_0x48ec(0x5d)],_0x5e2fa8;}({});export const getTokenTypeForRoute=_0x1d32eb=>{const _0x55adbf={'QyVyz':_0x48ec(0x5e)};return console[_0x48ec(0xa)](_0x55adbf[_0x48ec(0x5f)]),TokenType[_0x48ec(0x1b)];};export const getJWTForRoute=async _0x2206b8=>{const _0x58165a={'iwnRA':'⚠️\x20[JWT\x20Storage]\x20getJWTForRoute\x20is\x20deprecated\x20-\x20use\x20getJWT()\x20instead'};return console[_0x48ec(0xa)](_0x58165a[_0x48ec(0x60)]),getJWT();};export const clearAllJWT=async()=>{const _0x234d25={'flKVs':'⚠️\x20[JWT\x20Storage]\x20clearAllJWT\x20is\x20deprecated\x20-\x20use\x20clearJWT()\x20instead','raAnR':function(_0xd20fec){return _0xd20fec();}};return console['warn'](_0x234d25[_0x48ec(0x61)]),_0x234d25[_0x48ec(0x62)](clearJWT);};export const storeEnochJWT=async _0x3d48f5=>{const _0x53ad53={'hyhZt':_0x48ec(0x63),'jboAR':function(_0xad3ea9,_0x406f9b){return _0xad3ea9(_0x406f9b);}};return console[_0x48ec(0xa)](_0x53ad53[_0x48ec(0x64)]),_0x53ad53['jboAR'](storeJWT,_0x3d48f5);};export const storeOnairosJWT=async _0x3b6fd6=>{const _0x4419c2={'sTpfy':_0x48ec(0x33)};return console[_0x48ec(0xa)](_0x4419c2[_0x48ec(0x65)]),storeJWT(_0x3b6fd6);};export const storeAuthToken=async _0x17c212=>{const _0x28b557={'fxQeq':_0x48ec(0x66)};return console[_0x48ec(0xa)](_0x28b557[_0x48ec(0x67)]),storeJWT(_0x17c212);};export const replaceJWTAfterVerification=async(_0x12b849,_0x37cb0a)=>{const _0x23697a={'BpwMs':_0x48ec(0x1c)};return console[_0x48ec(0xa)](_0x23697a[_0x48ec(0x68)]),replaceJWT(_0x37cb0a);};export const getAllTokens=async()=>{const _0x1e731f={'JqUPm':function(_0x56e16c){return _0x56e16c();}},_0x1a8a2a=await _0x1e731f[_0x48ec(0x69)](getJWT);return{'sdk_token':_0x1a8a2a,[TokenType[_0x48ec(0x10)]]:null,[TokenType[_0x48ec(0x12)]]:null,[TokenType['AUTH']]: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