@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,493 @@
1
- function _0x3b36(){const _0x46299b=['❌\x20[TELEGRAM_SERVICE]\x20Network\x20error:','Network\x20error.\x20Please\x20check\x20your\x20connection.','Telegram\x20data\x20stored\x20successfully','❌\x20[TELEGRAM_SERVICE]\x20No\x20auth\x20token\x20found','🚀\x20[TELEGRAM_SERVICE]\x20Storing\x20Telegram\x20data\x20for:','Invalid\x20input:\x20userId\x20missing.','onairos_jwt_token','enoch_token','Android','mobile-telegram','📡\x20[TELEGRAM_SERVICE]\x20Sending\x20to\x20backend...','📍\x20[TELEGRAM_SERVICE]\x20URL:','xufmM','KBdpI','kROrr','log','AvIQO','dialogs','📊\x20[TELEGRAM_SERVICE]\x20Messages:','messages','length','❌\x20[TELEGRAM_SERVICE]\x20Invalid\x20input:\x20userId\x20missing','getItem','tjrfc','error','qRyLn','YGqyR','vORor','OPLXd','iPhone','pzjqa','toISOString','ehQFV','map','type','unreadCount','lastMessageDate','chatId','text','user','userId','filter','UnBix','IbNef','BASE_URL','/platform-data/store','Bearer\x20','OnairosSDK/1.0.0\x20(','stringify','json','QsLLY','uOphy','message','etXry','✅\x20[TELEGRAM_SERVICE]\x20Successfully\x20stored\x20Telegram\x20data','OHisj','📝\x20[TELEGRAM_SERVICE]\x20Backend\x20response:\x20','OVtyG','data','COoRM','warn','⚠️\x20[TELEGRAM_SERVICE]\x20Backend\x20returned\x20status:\x20','status','⚠️\x20[TELEGRAM_SERVICE]\x20Error:\x20','HTTP\x20','#\x20-\x20Flags\x20for\x20conditional\x20fields','int\x20-\x20Offset\x20message\x20ID\x20for\x20pagination','InputPeer\x20-\x20Offset\x20peer\x20for\x20pagination','int\x20-\x20Number\x20of\x20dialogs\x20to\x20return\x20(max\x20~100)','long\x20-\x20Hash\x20for\x20caching/efficient\x20pagination','messages.Dialogs\x20-\x20Contains\x20dialogs,\x20messages,\x20chats,\x20users\x20arrays','FOLDER_ID_INVALID\x20-\x20Invalid\x20folder\x20ID','OFFSET_PEER_ID_INVALID\x20-\x20Invalid\x20offset\x20peer','messages.getHistory','Get\x20messages\x20from\x20a\x20peer\x20(chat/user/channel)','InputPeer\x20-\x20Target\x20chat/user/channel','int\x20-\x20Offset\x20message\x20ID','int\x20-\x20Offset\x20date\x20(Unix\x20timestamp)','int\x20-\x20Additional\x20offset','int\x20-\x20Number\x20of\x20messages\x20to\x20return','int\x20-\x20Maximum\x20message\x20ID\x20to\x20fetch','int\x20-\x20Minimum\x20message\x20ID\x20to\x20fetch','long\x20-\x20Hash\x20for\x20caching','messages.Messages\x20-\x20Contains\x20messages,\x20chats,\x20users\x20arrays','CHAT_ID_INVALID\x20-\x20Invalid\x20chat\x20ID','PEER_ID_INVALID\x20-\x20Invalid\x20peer','messages.search','Search\x20for\x20messages','InputPeer\x20-\x20Target\x20peer\x20(use\x20inputPeerEmpty\x20for\x20global)','string\x20-\x20Search\x20query','InputPeer\x20-\x20Filter\x20by\x20sender\x20(optional)','MessagesFilter\x20-\x20Filter\x20type\x20(photos,\x20videos,\x20etc)','int\x20-\x20Minimum\x20date\x20filter','int\x20-\x20Maximum\x20date\x20filter','int\x20-\x20Number\x20of\x20results','int\x20-\x20Maximum\x20message\x20ID','int\x20-\x20Minimum\x20message\x20ID','Telethon','pip\x20install\x20telethon','https://github.com/LonamiWebs/Telethon','https://docs.telethon.dev/','\x0afrom\x20telethon\x20import\x20TelegramClient\x0aimport\x20asyncio\x0a\x0aapi_id\x20=\x20123456\x20\x20#\x20Your\x20API\x20ID\x0aapi_hash\x20=\x20\x270123456789abcdef0123456789abcdef\x27\x0a\x0aasync\x20def\x20main():\x0a\x20\x20\x20\x20client\x20=\x20TelegramClient(\x27session_name\x27,\x20api_id,\x20api_hash)\x0a\x20\x20\x20\x20await\x20client.start()\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20#\x20Get\x20dialogs\x20(chats\x20list)\x0a\x20\x20\x20\x20dialogs\x20=\x20await\x20client.get_dialogs(limit=50)\x0a\x20\x20\x20\x20for\x20dialog\x20in\x20dialogs:\x0a\x20\x20\x20\x20\x20\x20\x20\x20print(f\x22ID:\x20{dialog.id},\x20Title:\x20{dialog.title},\x20Unread:\x20{dialog.unread_count}\x22)\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20#\x20Get\x20messages\x20from\x20a\x20specific\x20chat\x0a\x20\x20\x20\x20messages\x20=\x20await\x20client.get_messages(dialog.entity,\x20limit=100)\x0a\x20\x20\x20\x20for\x20msg\x20in\x20messages:\x0a\x20\x20\x20\x20\x20\x20\x20\x20if\x20msg.out:\x20\x20#\x20Outgoing\x20messages\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20print(f\x22[{msg.date}]\x20{msg.text}\x22)\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20await\x20client.disconnect()\x0a\x0aasyncio.run(main())\x0a\x20\x20\x20\x20\x20\x20','Pyrogram','pip\x20install\x20pyrogram','https://github.com/pyrogram/pyrogram','https://docs.pyrogram.org/','npm\x20install\x20telegram','require','(\x27telegram/sessions\x27);\x0a\x0aconst\x20apiId\x20=\x20123456;\x0aconst\x20apiHash\x20=\x20\x270123456789abcdef0123456789abcdef\x27;\x0aconst\x20stringSession\x20=\x20new\x20StringSession(\x27\x27);\x20//\x20Empty\x20for\x20new\x20session\x0a\x0aasync\x20function\x20main()\x20{\x0a\x20\x20\x20\x20const\x20client\x20=\x20new\x20TelegramClient(stringSession,\x20apiId,\x20apiHash,\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20connectionRetries:\x205,\x0a\x20\x20\x20\x20});\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20await\x20client.start({\x0a\x20\x20\x20\x20\x20\x20\x20\x20phoneNumber:\x20async\x20()\x20=>\x20\x27+1234567890\x27,\x0a\x20\x20\x20\x20\x20\x20\x20\x20password:\x20async\x20()\x20=>\x20\x27your_2fa_password\x27,\x20//\x20If\x202FA\x20enabled\x0a\x20\x20\x20\x20\x20\x20\x20\x20phoneCode:\x20async\x20()\x20=>\x20\x27CODE_FROM_TELEGRAM\x27,\x0a\x20\x20\x20\x20\x20\x20\x20\x20onError:\x20(err)\x20=>\x20console.log(err),\x0a\x20\x20\x20\x20});\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20//\x20Save\x20session\x20for\x20future\x20use\x0a\x20\x20\x20\x20console.log(\x27Session:\x27,\x20client.session.save());\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20//\x20Get\x20dialogs\x0a\x20\x20\x20\x20const\x20dialogs\x20=\x20await\x20client.getDialogs({\x20limit:\x2050\x20});\x0a\x20\x20\x20\x20for\x20(const\x20dialog\x20of\x20dialogs)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20console.log(`${dialog.title}:\x20${dialog.unreadCount}\x20unread`);\x0a\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20//\x20Get\x20messages\x20from\x20a\x20chat\x0a\x20\x20\x20\x20const\x20messages\x20=\x20await\x20client.getMessages(dialog.entity,\x20{\x20limit:\x20100\x20});\x0a\x20\x20\x20\x20for\x20(const\x20msg\x20of\x20messages)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20if\x20(msg.out)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20console.log(`[${msg.date}]\x20${msg.text}`);\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20}\x0a}\x0a\x0amain();\x0a\x20\x20\x20\x20\x20\x20','npm\x20install\x20tdl\x20tdl-tdlib-addon','https://github.com/Bannerets/tdl','TDLib\x20(Official)','https://github.com/tdlib/td','C++','Java','Swift','Flutter\x20(via\x20bindings)','WTelegramClient','dotnet\x20add\x20package\x20WTelegramClient','/telegram/auth/init','string','/telegram/auth/verify','TelegramUser','/telegram/dialogs','number','TelegramDialogData[]','User[]','Chat[]','/telegram/messages/:peerId','TelegramMessageData[]','TelegramStorageData','boolean','On\x20FLOOD_WAIT_X\x20error,\x20sleep\x20for\x20X\x20seconds'];_0x3b36=function(){return _0x46299b;};return _0x3b36();}import{API_CONFIG}from'../config/api';import AsyncStorage from'@react-native-async-storage/async-storage';import{Platform}from'react-native';export const storeTelegramData=async(_0x2e6993,_0x2078f9)=>{const _0x2f7d2f={'uOphy':_0x52b9(0x0),'etXry':_0x52b9(0x1),'OVtyG':_0x52b9(0x2),'GqimT':_0x52b9(0x3),'rvqlv':_0x52b9(0x4),'AvIQO':'📊\x20[TELEGRAM_SERVICE]\x20Dialogs:','nEfKM':_0x52b9(0x5),'ifiUT':_0x52b9(0x6),'tjrfc':_0x52b9(0x7),'VBVjG':'auth_token','qRyLn':'Authentication\x20token\x20not\x20found.\x20Please\x20log\x20in\x20again.','YGqyR':'1.0.0','vORor':function(_0x33e28d,_0xcc2d19){return _0x33e28d===_0xcc2d19;},'OPLXd':'ios','rQWEw':'17.0','pzjqa':_0x52b9(0x8),'ehQFV':_0x52b9(0x9),'APCvi':'messaging','UnBix':_0x52b9(0xa),'IbNef':_0x52b9(0xb),'QsLLY':_0x52b9(0xc),'oKIcm':'OHisj','COoRM':_0x52b9(0xd),'MGSTa':_0x52b9(0xe)};console[_0x52b9(0xf)](_0x2f7d2f['rvqlv'],_0x2e6993),console[_0x52b9(0xf)](_0x2f7d2f[_0x52b9(0x10)],_0x2078f9[_0x52b9(0x11)]['length']),console[_0x52b9(0xf)](_0x52b9(0x12),_0x2078f9[_0x52b9(0x13)][_0x52b9(0x14)]);if(!_0x2e6993)return console['error'](_0x52b9(0x15)),{'success':![],'error':_0x2f7d2f['nEfKM']};try{const _0xe42378=await AsyncStorage[_0x52b9(0x16)](_0x2f7d2f['ifiUT'])||await AsyncStorage[_0x52b9(0x16)](_0x2f7d2f[_0x52b9(0x17)])||await AsyncStorage['getItem'](_0x2f7d2f['VBVjG']);if(!_0xe42378)return console[_0x52b9(0x18)](_0x52b9(0x3)),{'success':![],'error':_0x2f7d2f[_0x52b9(0x19)]};console[_0x52b9(0xf)]('🔑\x20[TELEGRAM_SERVICE]\x20Auth\x20token\x20found');const _0x5358f6={'platform':Platform['OS'],'appVersion':_0x2f7d2f[_0x52b9(0x1a)],'osVersion':_0x2f7d2f[_0x52b9(0x1b)](Platform['OS'],_0x2f7d2f[_0x52b9(0x1c)])?_0x2f7d2f['rQWEw']:Platform['OS'],'deviceModel':_0x2f7d2f['vORor'](Platform['OS'],_0x2f7d2f[_0x52b9(0x1c)])?_0x52b9(0x1d):_0x2f7d2f[_0x52b9(0x1e)],'isOfflineSync':![],'extractedAt':new Date()[_0x52b9(0x1f)]()},_0x37e891={'platform':_0x2f7d2f[_0x52b9(0x20)],'dataType':_0x2f7d2f['APCvi'],'data':{'dialogs':_0x2078f9['dialogs'][_0x52b9(0x21)](_0x23c567=>({'dialogId':_0x23c567['id'],'title':_0x23c567['title'],'type':_0x23c567[_0x52b9(0x22)],'unreadCount':_0x23c567[_0x52b9(0x23)],'lastMessageDate':_0x23c567[_0x52b9(0x24)]})),'messages':_0x2078f9[_0x52b9(0x13)][_0x52b9(0x21)]((_0x40ab87,_0x170c32)=>({'messageId':_0x40ab87['id'],'chatId':_0x40ab87[_0x52b9(0x25)],'content':_0x40ab87[_0x52b9(0x26)],'timestamp':_0x40ab87['timestamp']||new Date()[_0x52b9(0x1f)](),'type':_0x40ab87[_0x52b9(0x22)],'role':_0x52b9(0x27)})),'telegramUserId':_0x2078f9[_0x52b9(0x28)]},'summary':{'dialogCount':_0x2078f9[_0x52b9(0x11)][_0x52b9(0x14)],'messageCount':_0x2078f9[_0x52b9(0x13)]['length'],'textMessages':_0x2078f9[_0x52b9(0x13)][_0x52b9(0x29)](_0x591f76=>_0x591f76[_0x52b9(0x22)]===_0x52b9(0x26))[_0x52b9(0x14)],'mediaMessages':_0x2078f9[_0x52b9(0x13)]['filter'](_0x5b0555=>_0x5b0555['type']!==_0x52b9(0x26))[_0x52b9(0x14)]},'mobileMetadata':_0x5358f6};console['log'](_0x2f7d2f[_0x52b9(0x2a)]),console['log'](_0x2f7d2f[_0x52b9(0x2b)],API_CONFIG[_0x52b9(0x2c)]+_0x52b9(0x2d));const _0x377826=await fetch(API_CONFIG[_0x52b9(0x2c)]+_0x52b9(0x2d),{'method':'POST','headers':{'Content-Type':'application/json','Authorization':_0x52b9(0x2e)+_0xe42378,'User-Agent':_0x52b9(0x2f)+Platform['OS']+')'},'body':JSON[_0x52b9(0x30)](_0x37e891)}),_0x1e53a9=await _0x377826[_0x52b9(0x31)]();if(_0x377826['ok']){if(_0x2f7d2f[_0x52b9(0x32)]!==_0x52b9(0xc))return _0x148fe3[_0x52b9(0x18)](_0x2f7d2f[_0x52b9(0x33)],_0x6fd47e),{'success':![],'error':_0x5556c4[_0x52b9(0x34)]||_0x2f7d2f[_0x52b9(0x35)]};else{console[_0x52b9(0xf)](_0x52b9(0x36));if(_0x1e53a9['message']){if(_0x52b9(0x37)===_0x2f7d2f['oKIcm'])console['log'](_0x52b9(0x38)+_0x1e53a9[_0x52b9(0x34)]);else return _0x1ab731[_0x52b9(0xf)](_0x52b9(0x36)),_0x85b7b1[_0x52b9(0x34)]&&_0x14a32a[_0x52b9(0xf)]('📝\x20[TELEGRAM_SERVICE]\x20Backend\x20response:\x20'+_0x146a38[_0x52b9(0x34)]),{'success':!![],'message':_0x1e7c41['message']||_0x2f7d2f[_0x52b9(0x39)],'data':_0xa82d22['data']};}return{'success':!![],'message':_0x1e53a9['message']||_0x2f7d2f[_0x52b9(0x39)],'data':_0x1e53a9[_0x52b9(0x3a)]};}}else return _0x2f7d2f[_0x52b9(0x3b)]===_0x2f7d2f['MGSTa']?(_0x3cb2fd[_0x52b9(0x18)](_0x2f7d2f['GqimT']),{'success':![],'error':'Authentication\x20token\x20not\x20found.\x20Please\x20log\x20in\x20again.'}):(console[_0x52b9(0x3c)](_0x52b9(0x3d)+_0x377826[_0x52b9(0x3e)]),console['warn'](_0x52b9(0x3f)+(_0x1e53a9['error']||'Unknown\x20error')),{'success':![],'error':_0x1e53a9[_0x52b9(0x18)]||_0x52b9(0x40)+_0x377826[_0x52b9(0x3e)]});}catch(_0x5a1413){return console[_0x52b9(0x18)](_0x52b9(0x0),_0x5a1413),{'success':![],'error':_0x5a1413[_0x52b9(0x34)]||_0x52b9(0x1)};}};export const TELEGRAM_MTPROTO_API={'getDialogs':{'method':'messages.getDialogs','description':'Returns\x20the\x20current\x20user\x20dialog\x20list','parameters':{'flags':_0x52b9(0x41),'exclude_pinned':'flags.0?\x20true\x20-\x20Exclude\x20pinned\x20dialogs','folder_id':'flags.1?\x20int\x20-\x20Peer\x20folder\x20ID\x20(0=main,\x201=archived)','offset_date':'int\x20-\x20Offset\x20for\x20pagination\x20(Unix\x20timestamp)','offset_id':_0x52b9(0x42),'offset_peer':_0x52b9(0x43),'limit':_0x52b9(0x44),'hash':_0x52b9(0x45)},'returns':_0x52b9(0x46),'errors':[_0x52b9(0x47),_0x52b9(0x48)]},'getHistory':{'method':_0x52b9(0x49),'description':_0x52b9(0x4a),'parameters':{'peer':_0x52b9(0x4b),'offset_id':_0x52b9(0x4c),'offset_date':_0x52b9(0x4d),'add_offset':_0x52b9(0x4e),'limit':_0x52b9(0x4f),'max_id':_0x52b9(0x50),'min_id':_0x52b9(0x51),'hash':_0x52b9(0x52)},'returns':_0x52b9(0x53),'errors':[_0x52b9(0x54),_0x52b9(0x55)]},'search':{'method':_0x52b9(0x56),'description':_0x52b9(0x57),'parameters':{'peer':_0x52b9(0x58),'q':_0x52b9(0x59),'from_id':_0x52b9(0x5a),'filter':_0x52b9(0x5b),'min_date':_0x52b9(0x5c),'max_date':_0x52b9(0x5d),'offset_id':_0x52b9(0x4c),'add_offset':_0x52b9(0x4e),'limit':_0x52b9(0x5e),'max_id':_0x52b9(0x5f),'min_id':_0x52b9(0x60),'hash':_0x52b9(0x52)},'returns':'messages.Messages'}};export const TELEGRAM_LIBRARIES={'python':{'telethon':{'name':_0x52b9(0x61),'install':_0x52b9(0x62),'github':_0x52b9(0x63),'docs':_0x52b9(0x64),'example':_0x52b9(0x65)},'pyrogram':{'name':_0x52b9(0x66),'install':_0x52b9(0x67),'github':_0x52b9(0x68),'docs':_0x52b9(0x69)}},'nodejs':{'gramjs':{'name':'GramJS\x20(telegram)','install':_0x52b9(0x6a),'github':'https://github.com/nicegram/nicegram-web','example':'\x0aconst\x20{\x20TelegramClient\x20}\x20=\x20'+_0x52b9(0x6b)+'(\x27telegram\x27);\x0aconst\x20{\x20StringSession\x20}\x20=\x20'+_0x52b9(0x6b)+_0x52b9(0x6c)},'tdl':{'name':'TDL\x20(TDLib\x20wrapper)','install':_0x52b9(0x6d),'github':_0x52b9(0x6e)}},'multiPlatform':{'tdlib':{'name':_0x52b9(0x6f),'description':'Official\x20Telegram\x20Database\x20Library\x20-\x20most\x20complete\x20but\x20complex','github':_0x52b9(0x70),'docs':'https://core.telegram.org/tdlib','platforms':[_0x52b9(0x71),_0x52b9(0x72),_0x52b9(0x73),'Kotlin',_0x52b9(0x74)]}},'dotnet':{'wtelegramclient':{'name':_0x52b9(0x75),'install':_0x52b9(0x76),'github':'https://github.com/wiz0u/WTelegramClient'}}};function _0x52b9(_0x3b360a,_0x52b9eb){_0x3b360a=_0x3b360a-0x0;const _0x1c4fea=_0x3b36();let _0x5d034e=_0x1c4fea[_0x3b360a];return _0x5d034e;}export const TELEGRAM_BACKEND_ENDPOINTS={'initAuth':{'method':'POST','path':_0x52b9(0x77),'body':{'phoneNumber':'string'},'response':{'codeHash':_0x52b9(0x78),'phoneCodeHash':_0x52b9(0x78)}},'verifyCode':{'method':'POST','path':_0x52b9(0x79),'body':{'phoneNumber':_0x52b9(0x78),'code':'string','phoneCodeHash':_0x52b9(0x78)},'response':{'sessionString':_0x52b9(0x78),'user':_0x52b9(0x7a)}},'verify2FA':{'method':'POST','path':'/telegram/auth/2fa','body':{'password':_0x52b9(0x78),'sessionString':_0x52b9(0x78)},'response':{'sessionString':_0x52b9(0x78),'user':'TelegramUser'}},'getDialogs':{'method':'GET','path':_0x52b9(0x7b),'query':{'limit':_0x52b9(0x7c),'folderId':_0x52b9(0x7c),'offsetDate':_0x52b9(0x7c)},'response':{'dialogs':_0x52b9(0x7d),'users':_0x52b9(0x7e),'chats':_0x52b9(0x7f)}},'getMessages':{'method':'GET','path':_0x52b9(0x80),'query':{'limit':'number','offsetId':_0x52b9(0x7c)},'response':{'messages':_0x52b9(0x81)}},'storeData':{'method':'POST','path':_0x52b9(0x2d),'body':{'platform':_0x52b9(0x9),'data':_0x52b9(0x82)},'response':{'success':_0x52b9(0x83),'message':'string'}}};export const TELEGRAM_RATE_LIMITS={'requests_per_second':0x1,'flood_wait_handling':_0x52b9(0x84),'batch_size':0x64,'telethon_config':{'flood_sleep_threshold':0x3c}};
1
+ /**
2
+ * Telegram Data Service
3
+ *
4
+ * API layer for storing Telegram data on backend.
5
+ * Sends extracted dialogs and messages to /platform-data/store endpoint.
6
+ *
7
+ * MATCHES ChatGPT implementation pattern
8
+ * - Uses format: { platform, data, metadata }
9
+ * - Platform: "mobile-telegram"
10
+ *
11
+ * ============================================================
12
+ * TELEGRAM MTProto API REFERENCE
13
+ * ============================================================
14
+ *
15
+ * Method: messages.getDialogs
16
+ * @see https://core.telegram.org/method/messages.getDialogs
17
+ *
18
+ * Parameters:
19
+ * - flags (#): Flags for conditional fields
20
+ * - exclude_pinned (flags.0? true): Exclude pinned dialogs
21
+ * - folder_id (flags.1? int): Peer folder ID (archived = 1)
22
+ * - offset_date (int): Offset for pagination (date-based)
23
+ * - offset_id (int): Offset for pagination (top message ID)
24
+ * - offset_peer (InputPeer): Offset peer for pagination
25
+ * - limit (int): Number of dialogs to return
26
+ * - hash (long): Hash for caching and efficient pagination
27
+ *
28
+ * Returns: messages.Dialogs containing dialogs, messages, chats, users
29
+ *
30
+ * Method: messages.getHistory
31
+ * @see https://core.telegram.org/method/messages.getHistory
32
+ *
33
+ * Authorization:
34
+ * - Requires api_id and api_hash from https://my.telegram.org/apps
35
+ * - User must authenticate with phone number + code + optional 2FA
36
+ *
37
+ * Libraries:
38
+ * - Python: Telethon, Pyrogram
39
+ * - Multi-language: TDLib (official)
40
+ * - C#/.NET: WTelegramClient
41
+ *
42
+ * ============================================================
43
+ */
44
+
45
+ import { API_CONFIG } from '../config/api';
46
+ import AsyncStorage from '@react-native-async-storage/async-storage';
47
+ import { Platform } from 'react-native';
48
+
49
+ // ============================================================
50
+ // TELEGRAM API TYPES - Based on MTProto Layer 214+
51
+ // ============================================================
52
+
53
+ /**
54
+ * Telegram Dialog entity types
55
+ * Matches MTProto entity types returned by messages.getDialogs
56
+ */
57
+
58
+ /**
59
+ * Structure of a Telegram dialog/chat
60
+ * Based on messages.Dialogs response from MTProto API
61
+ *
62
+ * @see https://core.telegram.org/constructor/dialog
63
+ */
64
+
65
+ /**
66
+ * Structure of a Telegram message
67
+ * Based on messages.getHistory response from MTProto API
68
+ *
69
+ * @see https://core.telegram.org/constructor/message
70
+ */
71
+
72
+ /**
73
+ * Combined Telegram data to store
74
+ * Matches structure returned by messages.getDialogs + messages.getHistory
75
+ */
76
+
77
+ /**
78
+ * Response from backend endpoint
79
+ */
80
+
81
+ /**
82
+ * Store Telegram data on backend
83
+ *
84
+ * @param userId - Username or identifier
85
+ * @param data - Telegram dialogs and messages data
86
+ * @returns Response indicating success/failure with metadata
87
+ */
88
+ export const storeTelegramData = async (userId, data) => {
89
+ console.log('🚀 [TELEGRAM_SERVICE] Storing Telegram data for:', userId);
90
+ console.log('📊 [TELEGRAM_SERVICE] Dialogs:', data.dialogs.length);
91
+ console.log('📊 [TELEGRAM_SERVICE] Messages:', data.messages.length);
92
+
93
+ // Input validation
94
+ if (!userId) {
95
+ console.error('❌ [TELEGRAM_SERVICE] Invalid input: userId missing');
96
+ return {
97
+ success: false,
98
+ error: 'Invalid input: userId missing.'
99
+ };
100
+ }
101
+ try {
102
+ // Get auth token - check all possible storage keys
103
+ const authToken = (await AsyncStorage.getItem('onairos_jwt_token')) || (await AsyncStorage.getItem('enoch_token')) || (await AsyncStorage.getItem('auth_token'));
104
+ if (!authToken) {
105
+ console.error('❌ [TELEGRAM_SERVICE] No auth token found');
106
+ return {
107
+ success: false,
108
+ error: 'Authentication token not found. Please log in again.'
109
+ };
110
+ }
111
+ console.log('🔑 [TELEGRAM_SERVICE] Auth token found');
112
+
113
+ // Mobile metadata
114
+ const mobileMetadata = {
115
+ platform: Platform.OS,
116
+ appVersion: '1.0.0',
117
+ osVersion: Platform.OS === 'ios' ? '17.0' : Platform.OS,
118
+ deviceModel: Platform.OS === 'ios' ? 'iPhone' : 'Android',
119
+ isOfflineSync: false,
120
+ extractedAt: new Date().toISOString()
121
+ };
122
+
123
+ // Build request body
124
+ const requestBody = {
125
+ platform: 'mobile-telegram',
126
+ dataType: 'messaging',
127
+ data: {
128
+ dialogs: data.dialogs.map(dialog => ({
129
+ dialogId: dialog.id,
130
+ title: dialog.title,
131
+ type: dialog.type,
132
+ unreadCount: dialog.unreadCount,
133
+ lastMessageDate: dialog.lastMessageDate
134
+ })),
135
+ messages: data.messages.map((msg, idx) => ({
136
+ messageId: msg.id,
137
+ chatId: msg.chatId,
138
+ content: msg.text,
139
+ timestamp: msg.timestamp || new Date().toISOString(),
140
+ type: msg.type,
141
+ role: 'user' // All extracted messages are user's outgoing messages
142
+ })),
143
+ telegramUserId: data.userId
144
+ },
145
+ summary: {
146
+ dialogCount: data.dialogs.length,
147
+ messageCount: data.messages.length,
148
+ textMessages: data.messages.filter(m => m.type === 'text').length,
149
+ mediaMessages: data.messages.filter(m => m.type !== 'text').length
150
+ },
151
+ mobileMetadata: mobileMetadata
152
+ };
153
+ console.log('📡 [TELEGRAM_SERVICE] Sending to backend...');
154
+ console.log('📍 [TELEGRAM_SERVICE] URL:', `${API_CONFIG.BASE_URL}/platform-data/store`);
155
+ const response = await fetch(`${API_CONFIG.BASE_URL}/platform-data/store`, {
156
+ method: 'POST',
157
+ headers: {
158
+ 'Content-Type': 'application/json',
159
+ 'Authorization': `Bearer ${authToken}`,
160
+ 'User-Agent': `OnairosSDK/1.0.0 (${Platform.OS})`
161
+ },
162
+ body: JSON.stringify(requestBody)
163
+ });
164
+ const responseData = await response.json();
165
+ if (response.ok) {
166
+ console.log('✅ [TELEGRAM_SERVICE] Successfully stored Telegram data');
167
+ if (responseData.message) {
168
+ console.log(`📝 [TELEGRAM_SERVICE] Backend response: ${responseData.message}`);
169
+ }
170
+ return {
171
+ success: true,
172
+ message: responseData.message || 'Telegram data stored successfully',
173
+ data: responseData.data
174
+ };
175
+ } else {
176
+ console.warn(`⚠️ [TELEGRAM_SERVICE] Backend returned status: ${response.status}`);
177
+ console.warn(`⚠️ [TELEGRAM_SERVICE] Error: ${responseData.error || 'Unknown error'}`);
178
+ return {
179
+ success: false,
180
+ error: responseData.error || `HTTP ${response.status}`
181
+ };
182
+ }
183
+ } catch (error) {
184
+ console.error('❌ [TELEGRAM_SERVICE] Network error:', error);
185
+ return {
186
+ success: false,
187
+ error: error.message || 'Network error. Please check your connection.'
188
+ };
189
+ }
190
+ };
191
+
192
+ // ============================================================
193
+ // TELEGRAM MTProto API CONFIGURATION
194
+ // ============================================================
195
+
196
+ /**
197
+ * Telegram MTProto API Configuration
198
+ *
199
+ * REQUIRED: Register at https://my.telegram.org/apps to get:
200
+ * - api_id (integer)
201
+ * - api_hash (string, 32 hex chars)
202
+ *
203
+ * @see https://core.telegram.org/api/obtaining_api_id
204
+ */
205
+
206
+ /**
207
+ * MTProto API Method Parameters
208
+ * Based on Layer 214+ schema
209
+ */
210
+ export const TELEGRAM_MTPROTO_API = {
211
+ // ============================================================
212
+ // messages.getDialogs - Get user's chat list
213
+ // @see https://core.telegram.org/method/messages.getDialogs
214
+ // ============================================================
215
+ getDialogs: {
216
+ method: 'messages.getDialogs',
217
+ description: 'Returns the current user dialog list',
218
+ parameters: {
219
+ flags: '# - Flags for conditional fields',
220
+ exclude_pinned: 'flags.0? true - Exclude pinned dialogs',
221
+ folder_id: 'flags.1? int - Peer folder ID (0=main, 1=archived)',
222
+ offset_date: 'int - Offset for pagination (Unix timestamp)',
223
+ offset_id: 'int - Offset message ID for pagination',
224
+ offset_peer: 'InputPeer - Offset peer for pagination',
225
+ limit: 'int - Number of dialogs to return (max ~100)',
226
+ hash: 'long - Hash for caching/efficient pagination'
227
+ },
228
+ returns: 'messages.Dialogs - Contains dialogs, messages, chats, users arrays',
229
+ errors: ['FOLDER_ID_INVALID - Invalid folder ID', 'OFFSET_PEER_ID_INVALID - Invalid offset peer']
230
+ },
231
+ // ============================================================
232
+ // messages.getHistory - Get messages from a chat
233
+ // @see https://core.telegram.org/method/messages.getHistory
234
+ // ============================================================
235
+ getHistory: {
236
+ method: 'messages.getHistory',
237
+ description: 'Get messages from a peer (chat/user/channel)',
238
+ parameters: {
239
+ peer: 'InputPeer - Target chat/user/channel',
240
+ offset_id: 'int - Offset message ID',
241
+ offset_date: 'int - Offset date (Unix timestamp)',
242
+ add_offset: 'int - Additional offset',
243
+ limit: 'int - Number of messages to return',
244
+ max_id: 'int - Maximum message ID to fetch',
245
+ min_id: 'int - Minimum message ID to fetch',
246
+ hash: 'long - Hash for caching'
247
+ },
248
+ returns: 'messages.Messages - Contains messages, chats, users arrays',
249
+ errors: ['CHAT_ID_INVALID - Invalid chat ID', 'PEER_ID_INVALID - Invalid peer']
250
+ },
251
+ // ============================================================
252
+ // messages.search - Search messages
253
+ // @see https://core.telegram.org/method/messages.search
254
+ // ============================================================
255
+ search: {
256
+ method: 'messages.search',
257
+ description: 'Search for messages',
258
+ parameters: {
259
+ peer: 'InputPeer - Target peer (use inputPeerEmpty for global)',
260
+ q: 'string - Search query',
261
+ from_id: 'InputPeer - Filter by sender (optional)',
262
+ filter: 'MessagesFilter - Filter type (photos, videos, etc)',
263
+ min_date: 'int - Minimum date filter',
264
+ max_date: 'int - Maximum date filter',
265
+ offset_id: 'int - Offset message ID',
266
+ add_offset: 'int - Additional offset',
267
+ limit: 'int - Number of results',
268
+ max_id: 'int - Maximum message ID',
269
+ min_id: 'int - Minimum message ID',
270
+ hash: 'long - Hash for caching'
271
+ },
272
+ returns: 'messages.Messages'
273
+ }
274
+ };
275
+
276
+ /**
277
+ * Recommended Libraries for MTProto Implementation
278
+ */
279
+ export const TELEGRAM_LIBRARIES = {
280
+ python: {
281
+ telethon: {
282
+ name: 'Telethon',
283
+ install: 'pip install telethon',
284
+ github: 'https://github.com/LonamiWebs/Telethon',
285
+ docs: 'https://docs.telethon.dev/',
286
+ example: `
287
+ from telethon import TelegramClient
288
+ import asyncio
289
+
290
+ api_id = 123456 # Your API ID
291
+ api_hash = '0123456789abcdef0123456789abcdef'
292
+
293
+ async def main():
294
+ client = TelegramClient('session_name', api_id, api_hash)
295
+ await client.start()
296
+
297
+ # Get dialogs (chats list)
298
+ dialogs = await client.get_dialogs(limit=50)
299
+ for dialog in dialogs:
300
+ print(f"ID: {dialog.id}, Title: {dialog.title}, Unread: {dialog.unread_count}")
301
+
302
+ # Get messages from a specific chat
303
+ messages = await client.get_messages(dialog.entity, limit=100)
304
+ for msg in messages:
305
+ if msg.out: # Outgoing messages
306
+ print(f"[{msg.date}] {msg.text}")
307
+
308
+ await client.disconnect()
309
+
310
+ asyncio.run(main())
311
+ `
312
+ },
313
+ pyrogram: {
314
+ name: 'Pyrogram',
315
+ install: 'pip install pyrogram',
316
+ github: 'https://github.com/pyrogram/pyrogram',
317
+ docs: 'https://docs.pyrogram.org/'
318
+ }
319
+ },
320
+ nodejs: {
321
+ gramjs: {
322
+ name: 'GramJS (telegram)',
323
+ install: 'npm install telegram',
324
+ github: 'https://github.com/nicegram/nicegram-web',
325
+ example: `
326
+ const { TelegramClient } = ${'require'}('telegram');
327
+ const { StringSession } = ${'require'}('telegram/sessions');
328
+
329
+ const apiId = 123456;
330
+ const apiHash = '0123456789abcdef0123456789abcdef';
331
+ const stringSession = new StringSession(''); // Empty for new session
332
+
333
+ async function main() {
334
+ const client = new TelegramClient(stringSession, apiId, apiHash, {
335
+ connectionRetries: 5,
336
+ });
337
+
338
+ await client.start({
339
+ phoneNumber: async () => '+1234567890',
340
+ password: async () => 'your_2fa_password', // If 2FA enabled
341
+ phoneCode: async () => 'CODE_FROM_TELEGRAM',
342
+ onError: (err) => console.log(err),
343
+ });
344
+
345
+ // Save session for future use
346
+ console.log('Session:', client.session.save());
347
+
348
+ // Get dialogs
349
+ const dialogs = await client.getDialogs({ limit: 50 });
350
+ for (const dialog of dialogs) {
351
+ console.log(\`\${dialog.title}: \${dialog.unreadCount} unread\`);
352
+ }
353
+
354
+ // Get messages from a chat
355
+ const messages = await client.getMessages(dialog.entity, { limit: 100 });
356
+ for (const msg of messages) {
357
+ if (msg.out) {
358
+ console.log(\`[\${msg.date}] \${msg.text}\`);
359
+ }
360
+ }
361
+ }
362
+
363
+ main();
364
+ `
365
+ },
366
+ tdl: {
367
+ name: 'TDL (TDLib wrapper)',
368
+ install: 'npm install tdl tdl-tdlib-addon',
369
+ github: 'https://github.com/Bannerets/tdl'
370
+ }
371
+ },
372
+ multiPlatform: {
373
+ tdlib: {
374
+ name: 'TDLib (Official)',
375
+ description: 'Official Telegram Database Library - most complete but complex',
376
+ github: 'https://github.com/tdlib/td',
377
+ docs: 'https://core.telegram.org/tdlib',
378
+ platforms: ['C++', 'Java', 'Swift', 'Kotlin', 'Flutter (via bindings)']
379
+ }
380
+ },
381
+ dotnet: {
382
+ wtelegramclient: {
383
+ name: 'WTelegramClient',
384
+ install: 'dotnet add package WTelegramClient',
385
+ github: 'https://github.com/wiz0u/WTelegramClient'
386
+ }
387
+ }
388
+ };
389
+
390
+ /**
391
+ * Backend API endpoints for Telegram integration
392
+ * These should be implemented on your backend server
393
+ */
394
+ export const TELEGRAM_BACKEND_ENDPOINTS = {
395
+ // Initialize session and send auth code
396
+ initAuth: {
397
+ method: 'POST',
398
+ path: '/telegram/auth/init',
399
+ body: {
400
+ phoneNumber: 'string'
401
+ },
402
+ response: {
403
+ codeHash: 'string',
404
+ phoneCodeHash: 'string'
405
+ }
406
+ },
407
+ // Verify code and complete auth
408
+ verifyCode: {
409
+ method: 'POST',
410
+ path: '/telegram/auth/verify',
411
+ body: {
412
+ phoneNumber: 'string',
413
+ code: 'string',
414
+ phoneCodeHash: 'string'
415
+ },
416
+ response: {
417
+ sessionString: 'string',
418
+ user: 'TelegramUser'
419
+ }
420
+ },
421
+ // Provide 2FA password if required
422
+ verify2FA: {
423
+ method: 'POST',
424
+ path: '/telegram/auth/2fa',
425
+ body: {
426
+ password: 'string',
427
+ sessionString: 'string'
428
+ },
429
+ response: {
430
+ sessionString: 'string',
431
+ user: 'TelegramUser'
432
+ }
433
+ },
434
+ // Get user's dialogs (uses messages.getDialogs)
435
+ getDialogs: {
436
+ method: 'GET',
437
+ path: '/telegram/dialogs',
438
+ query: {
439
+ limit: 'number',
440
+ folderId: 'number',
441
+ offsetDate: 'number'
442
+ },
443
+ response: {
444
+ dialogs: 'TelegramDialogData[]',
445
+ users: 'User[]',
446
+ chats: 'Chat[]'
447
+ }
448
+ },
449
+ // Get messages from a chat (uses messages.getHistory)
450
+ getMessages: {
451
+ method: 'GET',
452
+ path: '/telegram/messages/:peerId',
453
+ query: {
454
+ limit: 'number',
455
+ offsetId: 'number'
456
+ },
457
+ response: {
458
+ messages: 'TelegramMessageData[]'
459
+ }
460
+ },
461
+ // Store extracted data (from mobile SDK)
462
+ storeData: {
463
+ method: 'POST',
464
+ path: '/platform-data/store',
465
+ body: {
466
+ platform: 'mobile-telegram',
467
+ data: 'TelegramStorageData'
468
+ },
469
+ response: {
470
+ success: 'boolean',
471
+ message: 'string'
472
+ }
473
+ }
474
+ };
475
+
476
+ /**
477
+ * Rate Limiting Guidelines
478
+ * Telegram has strict rate limits - handle FLOOD_WAIT errors
479
+ */
480
+ export const TELEGRAM_RATE_LIMITS = {
481
+ // General guidelines (actual limits vary)
482
+ requests_per_second: 1,
483
+ // ~1 request/second recommended
484
+ flood_wait_handling: 'On FLOOD_WAIT_X error, sleep for X seconds',
485
+ batch_size: 100,
486
+ // Max items per request for most methods
487
+
488
+ // Telethon auto-handles with flood_sleep_threshold
489
+ telethon_config: {
490
+ flood_sleep_threshold: 60 // Auto-sleep up to 60s on flood
491
+ }
492
+ };
493
+ //# sourceMappingURL=telegramDataService.js.map
@@ -1 +1,67 @@
1
- function _0x21d6(){const _0x11685e=['MnWfP','NUlEz','⚠️\x20No\x20PIN\x20available\x20for\x20training\x20data','❌\x20Error\x20adding\x20encrypted\x20PIN\x20to\x20training\x20data:'];_0x21d6=function(){return _0x11685e;};return _0x21d6();}import{getEncryptedPinForAPI}from'./pinEncryptionService';function _0x5f31(_0x21d631,_0x5f31cb){_0x21d631=_0x21d631-0x0;const _0x2147a0=_0x21d6();let _0x3aacb0=_0x2147a0[_0x21d631];return _0x3aacb0;}export const addEncryptedPinToTrainingData=async _0x34ae37=>{const _0x4405f0={'MnWfP':function(_0xe5ba07){return _0xe5ba07();},'NUlEz':'✅\x20Adding\x20encrypted\x20PIN\x20to\x20training\x20data'};try{const _0x3d6b50=await _0x4405f0[_0x5f31(0x0)](getEncryptedPinForAPI);return _0x3d6b50?(console['log'](_0x4405f0[_0x5f31(0x1)]),{..._0x34ae37,'encryptedPin':_0x3d6b50,'hasPinData':!![]}):(console['log'](_0x5f31(0x2)),{..._0x34ae37,'hasPinData':![]});}catch(_0x2c830b){return console['error'](_0x5f31(0x3),_0x2c830b),{..._0x34ae37,'hasPinData':![]};}};
1
+ import { getEncryptedPinForAPI } from './pinEncryptionService';
2
+
3
+ /**
4
+ * Helper functions for training API modifications
5
+ */
6
+
7
+ /**
8
+ * Add encrypted PIN to training data if available
9
+ */
10
+ export const addEncryptedPinToTrainingData = async trainingData => {
11
+ try {
12
+ // Get encrypted PIN
13
+ const encryptedPin = await getEncryptedPinForAPI();
14
+ if (encryptedPin) {
15
+ console.log('✅ Adding encrypted PIN to training data');
16
+ return {
17
+ ...trainingData,
18
+ encryptedPin: encryptedPin,
19
+ hasPinData: true
20
+ };
21
+ } else {
22
+ console.log('⚠️ No PIN available for training data');
23
+ return {
24
+ ...trainingData,
25
+ hasPinData: false
26
+ };
27
+ }
28
+ } catch (error) {
29
+ console.error('❌ Error adding encrypted PIN to training data:', error);
30
+ return {
31
+ ...trainingData,
32
+ hasPinData: false
33
+ };
34
+ }
35
+ };
36
+
37
+ /**
38
+ * Example of how to modify the training API call to include PIN
39
+ *
40
+ * Usage in UniversalOnboarding.tsx:
41
+ *
42
+ * ```typescript
43
+ * // Before sending to API
44
+ * const trainingData = {
45
+ * socketId,
46
+ * username: finalUsername,
47
+ * email: userInfo?.email || null,
48
+ * modelKey: null,
49
+ * connectedPlatforms: platformsList,
50
+ * platformConnections: connections
51
+ * };
52
+ *
53
+ * // Add encrypted PIN if needed
54
+ * const trainingDataWithPin = await addEncryptedPinToTrainingData(trainingData);
55
+ *
56
+ * // Send to API
57
+ * const response = await fetch('${API_CONFIG.BASE_URL}/mobile-training/enoch', {
58
+ * method: 'POST',
59
+ * headers: {
60
+ * 'Content-Type': 'application/json',
61
+ * 'Authorization': `Bearer ${token}`
62
+ * },
63
+ * body: JSON.stringify(trainingDataWithPin)
64
+ * });
65
+ * ```
66
+ */
67
+ //# sourceMappingURL=trainingApiHelpers.js.map