@onairos/react-native 3.7.2 → 3.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (237) hide show
  1. package/lib/commonjs/api/index.js +219 -9
  2. package/lib/commonjs/components/BodyText.js +27 -9
  3. package/lib/commonjs/components/BrandMark.js +111 -10
  4. package/lib/commonjs/components/CodeInput.js +116 -9
  5. package/lib/commonjs/components/EmailInput.js +30 -8
  6. package/lib/commonjs/components/GoogleButton.js +56 -9
  7. package/lib/commonjs/components/HeadingGroup.js +43 -9
  8. package/lib/commonjs/components/LLMDataInputModal.js +664 -14
  9. package/lib/commonjs/components/ModalHeader.js +99 -9
  10. package/lib/commonjs/components/ModalSheet.js +47 -9
  11. package/lib/commonjs/components/Onairos.js +380 -14
  12. package/lib/commonjs/components/OnairosButton.js +313 -13
  13. package/lib/commonjs/components/OnairosSignInButton.js +130 -12
  14. package/lib/commonjs/components/Overlay.js +465 -13
  15. package/lib/commonjs/components/PersonaImage.js +137 -10
  16. package/lib/commonjs/components/PersonaLoadingScreen.js +318 -12
  17. package/lib/commonjs/components/PersonalizationConsentScreen.js +467 -13
  18. package/lib/commonjs/components/PinCreationScreen.js +403 -12
  19. package/lib/commonjs/components/PinInput.js +464 -9
  20. package/lib/commonjs/components/PlatformConnectorsStep.js +1311 -23
  21. package/lib/commonjs/components/PlatformList.js +137 -10
  22. package/lib/commonjs/components/PlatformToggle.js +180 -9
  23. package/lib/commonjs/components/PrimaryButton.js +180 -10
  24. package/lib/commonjs/components/SignInMatchAnimation.js +197 -9
  25. package/lib/commonjs/components/SignInStep.js +345 -12
  26. package/lib/commonjs/components/UniversalOnboarding.js +2780 -30
  27. package/lib/commonjs/components/VerificationStep.js +176 -11
  28. package/lib/commonjs/components/WelcomeScreen.js +461 -22
  29. package/lib/commonjs/components/icons/Basicproficon.js +37 -8
  30. package/lib/commonjs/components/icons/Basicprofile.js +21 -8
  31. package/lib/commonjs/components/icons/Checkbox.js +21 -8
  32. package/lib/commonjs/components/icons/Checkmark.js +27 -8
  33. package/lib/commonjs/components/icons/Contentanalysis.js +21 -8
  34. package/lib/commonjs/components/icons/Contenticon.js +39 -8
  35. package/lib/commonjs/components/icons/EnochE.js +41 -8
  36. package/lib/commonjs/components/icons/Personalityicon.js +30 -8
  37. package/lib/commonjs/components/icons/Personalityprofile.js +21 -8
  38. package/lib/commonjs/components/icons/Personalitytraits.js +21 -8
  39. package/lib/commonjs/components/icons/Userpreferences.js +21 -8
  40. package/lib/commonjs/components/icons/index.js +84 -17
  41. package/lib/commonjs/components/onboarding/OAuthWebView.js +1754 -18
  42. package/lib/commonjs/components/onboarding/OnboardingHeader.js +74 -10
  43. package/lib/commonjs/components/onboarding/PinInput.js +283 -10
  44. package/lib/commonjs/components/onboarding/PlatformConnector.js +249 -11
  45. package/lib/commonjs/config/PLATFORM_APIS.md +849 -0
  46. package/lib/commonjs/config/api.js +56 -7
  47. package/lib/commonjs/constants/index.js +120 -7
  48. package/lib/commonjs/context/AuthContext.js +345 -10
  49. package/lib/commonjs/hooks/useConnectedAccounts.js +111 -9
  50. package/lib/commonjs/hooks/useConnections.js +102 -8
  51. package/lib/commonjs/hooks/useCredentials.js +178 -10
  52. package/lib/commonjs/hooks/useUserConnections.js +148 -10
  53. package/lib/commonjs/index.js +439 -34
  54. package/lib/commonjs/services/apiClient.js +298 -8
  55. package/lib/commonjs/services/biometricPinService.js +180 -8
  56. package/lib/commonjs/services/chatGPTConversationExtractor.js +155 -8
  57. package/lib/commonjs/services/chatGPTConversationService.js +275 -9
  58. package/lib/commonjs/services/claudeConversationExtractor.js +103 -8
  59. package/lib/commonjs/services/claudeConversationService.js +158 -9
  60. package/lib/commonjs/services/connectedAccountsService.js +310 -10
  61. package/lib/commonjs/services/googleAuthService.js +252 -11
  62. package/lib/commonjs/services/hingeDataExtractor.js +105 -8
  63. package/lib/commonjs/services/hingeDataService.js +150 -9
  64. package/lib/commonjs/services/imageCompressionService.js +260 -7
  65. package/lib/commonjs/services/instagramDataExtractor.js +126 -8
  66. package/lib/commonjs/services/instagramDataService.js +163 -9
  67. package/lib/commonjs/services/jwtStorageService.js +276 -7
  68. package/lib/commonjs/services/linkedinDOMExtractor.js +245 -7
  69. package/lib/commonjs/services/linkedinProfileService.js +222 -9
  70. package/lib/commonjs/services/linkedinScrapingService.js +230 -8
  71. package/lib/commonjs/services/llmDataStorage.js +294 -8
  72. package/lib/commonjs/services/mobileTrainingService.js +186 -8
  73. package/lib/commonjs/services/netflixDataExtractor.js +120 -8
  74. package/lib/commonjs/services/netflixDataService.js +198 -9
  75. package/lib/commonjs/services/pinEncryptionService.js +84 -8
  76. package/lib/commonjs/services/pinStorageUtils.js +105 -7
  77. package/lib/commonjs/services/platformAuthService.js +1484 -12
  78. package/lib/commonjs/services/sephoraDataExtractor.js +140 -8
  79. package/lib/commonjs/services/sephoraDataService.js +200 -9
  80. package/lib/commonjs/services/spotifyDataExtractor.js +148 -8
  81. package/lib/commonjs/services/spotifyDataService.js +241 -9
  82. package/lib/commonjs/services/storageService.js +404 -8
  83. package/lib/commonjs/services/telegramDataExtractor.js +115 -8
  84. package/lib/commonjs/services/telegramDataService.js +499 -9
  85. package/lib/commonjs/services/trainingApiHelpers.js +73 -7
  86. package/lib/commonjs/services/userConnectionsService.js +340 -10
  87. package/lib/commonjs/services/youtubeMigrationService.js +416 -10
  88. package/lib/commonjs/theme/index.js +250 -7
  89. package/lib/commonjs/types/ambient.d.js +2 -1
  90. package/lib/commonjs/types/declarations.d.js +2 -1
  91. package/lib/commonjs/types/index.js +6 -1
  92. package/lib/commonjs/types/node-fix.d.js +2 -1
  93. package/lib/commonjs/types/node-override.d.js +2 -1
  94. package/lib/commonjs/types/opacity.d.js +2 -1
  95. package/lib/commonjs/types.js +14 -1
  96. package/lib/commonjs/utils/Portal.js +98 -8
  97. package/lib/commonjs/utils/api.js +130 -9
  98. package/lib/commonjs/utils/assetRegistry.js +210 -35
  99. package/lib/commonjs/utils/auth.js +112 -9
  100. package/lib/commonjs/utils/connectorTests.js +613 -29
  101. package/lib/commonjs/utils/crypto.js +62 -8
  102. package/lib/commonjs/utils/debugHelper.js +64 -1
  103. package/lib/commonjs/utils/encryption.js +76 -7
  104. package/lib/commonjs/utils/eventUtils.js +288 -1
  105. package/lib/commonjs/utils/haptics.js +66 -9
  106. package/lib/commonjs/utils/imagePreloader.js +6 -1
  107. package/lib/commonjs/utils/networkDiagnostics.js +226 -8
  108. package/lib/commonjs/utils/onairosApi.js +350 -9
  109. package/lib/commonjs/utils/programmaticFlow.js +117 -9
  110. package/lib/commonjs/utils/retryHelper.js +220 -1
  111. package/lib/commonjs/utils/secureStorage.js +349 -10
  112. package/lib/commonjs/utils/webviewScripts/chatgpt.js +551 -1
  113. package/lib/commonjs/utils/webviewScripts/claude.js +376 -1
  114. package/lib/commonjs/utils/webviewScripts/hinge.js +411 -1
  115. package/lib/commonjs/utils/webviewScripts/index.js +698 -15
  116. package/lib/commonjs/utils/webviewScripts/instagram.js +454 -1
  117. package/lib/commonjs/utils/webviewScripts/linkedin.js +880 -1
  118. package/lib/commonjs/utils/webviewScripts/netflix.js +382 -1
  119. package/lib/commonjs/utils/webviewScripts/sephora.js +516 -1
  120. package/lib/commonjs/utils/webviewScripts/spotify.js +419 -1
  121. package/lib/commonjs/utils/webviewScripts/telegram.js +678 -1
  122. package/lib/module/api/index.js +211 -1
  123. package/lib/module/components/BodyText.js +20 -1
  124. package/lib/module/components/BrandMark.js +104 -1
  125. package/lib/module/components/CodeInput.js +109 -1
  126. package/lib/module/components/EmailInput.js +23 -1
  127. package/lib/module/components/GoogleButton.js +49 -1
  128. package/lib/module/components/HeadingGroup.js +36 -1
  129. package/lib/module/components/LLMDataInputModal.js +656 -7
  130. package/lib/module/components/ModalHeader.js +92 -1
  131. package/lib/module/components/ModalSheet.js +39 -1
  132. package/lib/module/components/Onairos.js +373 -1
  133. package/lib/module/components/OnairosButton.js +305 -1
  134. package/lib/module/components/OnairosSignInButton.js +121 -1
  135. package/lib/module/components/Overlay.js +456 -1
  136. package/lib/module/components/PersonaImage.js +129 -1
  137. package/lib/module/components/PersonaLoadingScreen.js +310 -1
  138. package/lib/module/components/PersonalizationConsentScreen.js +460 -1
  139. package/lib/module/components/PinCreationScreen.js +396 -1
  140. package/lib/module/components/PinInput.js +456 -1
  141. package/lib/module/components/PlatformConnectorsStep.js +1302 -6
  142. package/lib/module/components/PlatformList.js +129 -1
  143. package/lib/module/components/PlatformToggle.js +173 -1
  144. package/lib/module/components/PrimaryButton.js +172 -1
  145. package/lib/module/components/SignInMatchAnimation.js +189 -1
  146. package/lib/module/components/SignInStep.js +338 -1
  147. package/lib/module/components/UniversalOnboarding.js +2770 -1
  148. package/lib/module/components/VerificationStep.js +168 -1
  149. package/lib/module/components/WelcomeScreen.js +453 -1
  150. package/lib/module/components/icons/Basicproficon.js +30 -1
  151. package/lib/module/components/icons/Basicprofile.js +14 -1
  152. package/lib/module/components/icons/Checkbox.js +14 -1
  153. package/lib/module/components/icons/Checkmark.js +20 -1
  154. package/lib/module/components/icons/Contentanalysis.js +14 -1
  155. package/lib/module/components/icons/Contenticon.js +32 -1
  156. package/lib/module/components/icons/EnochE.js +34 -1
  157. package/lib/module/components/icons/Personalityicon.js +23 -1
  158. package/lib/module/components/icons/Personalityprofile.js +14 -1
  159. package/lib/module/components/icons/Personalitytraits.js +14 -1
  160. package/lib/module/components/icons/Userpreferences.js +14 -1
  161. package/lib/module/components/icons/index.js +13 -1
  162. package/lib/module/components/onboarding/OAuthWebView.js +1746 -1
  163. package/lib/module/components/onboarding/OnboardingHeader.js +66 -1
  164. package/lib/module/components/onboarding/PinInput.js +274 -1
  165. package/lib/module/components/onboarding/PlatformConnector.js +240 -1
  166. package/lib/module/config/PLATFORM_APIS.md +849 -0
  167. package/lib/module/config/api.js +47 -1
  168. package/lib/module/constants/index.js +114 -1
  169. package/lib/module/context/AuthContext.js +335 -1
  170. package/lib/module/hooks/useConnectedAccounts.js +106 -1
  171. package/lib/module/hooks/useConnections.js +95 -1
  172. package/lib/module/hooks/useCredentials.js +171 -6
  173. package/lib/module/hooks/useUserConnections.js +140 -1
  174. package/lib/module/index.js +172 -1
  175. package/lib/module/services/apiClient.js +295 -1
  176. package/lib/module/services/biometricPinService.js +169 -1
  177. package/lib/module/services/chatGPTConversationExtractor.js +149 -1
  178. package/lib/module/services/chatGPTConversationService.js +268 -1
  179. package/lib/module/services/claudeConversationExtractor.js +97 -1
  180. package/lib/module/services/claudeConversationService.js +151 -1
  181. package/lib/module/services/connectedAccountsService.js +293 -1
  182. package/lib/module/services/googleAuthService.js +241 -1
  183. package/lib/module/services/hingeDataExtractor.js +99 -1
  184. package/lib/module/services/hingeDataService.js +143 -1
  185. package/lib/module/services/imageCompressionService.js +250 -1
  186. package/lib/module/services/instagramDataExtractor.js +120 -1
  187. package/lib/module/services/instagramDataService.js +156 -1
  188. package/lib/module/services/jwtStorageService.js +257 -1
  189. package/lib/module/services/linkedinDOMExtractor.js +234 -1
  190. package/lib/module/services/linkedinProfileService.js +210 -1
  191. package/lib/module/services/linkedinScrapingService.js +219 -1
  192. package/lib/module/services/llmDataStorage.js +277 -1
  193. package/lib/module/services/mobileTrainingService.js +173 -1
  194. package/lib/module/services/netflixDataExtractor.js +114 -1
  195. package/lib/module/services/netflixDataService.js +191 -1
  196. package/lib/module/services/pinEncryptionService.js +74 -6
  197. package/lib/module/services/pinStorageUtils.js +93 -1
  198. package/lib/module/services/platformAuthService.js +1461 -1
  199. package/lib/module/services/sephoraDataExtractor.js +134 -1
  200. package/lib/module/services/sephoraDataService.js +193 -1
  201. package/lib/module/services/spotifyDataExtractor.js +142 -1
  202. package/lib/module/services/spotifyDataService.js +234 -1
  203. package/lib/module/services/storageService.js +383 -1
  204. package/lib/module/services/telegramDataExtractor.js +109 -1
  205. package/lib/module/services/telegramDataService.js +493 -1
  206. package/lib/module/services/trainingApiHelpers.js +67 -1
  207. package/lib/module/services/userConnectionsService.js +329 -1
  208. package/lib/module/services/youtubeMigrationService.js +405 -1
  209. package/lib/module/theme/index.js +245 -1
  210. package/lib/module/types.js +10 -1
  211. package/lib/module/utils/Portal.js +90 -1
  212. package/lib/module/utils/api.js +118 -1
  213. package/lib/module/utils/assetRegistry.js +200 -34
  214. package/lib/module/utils/auth.js +100 -1
  215. package/lib/module/utils/connectorTests.js +600 -27
  216. package/lib/module/utils/crypto.js +54 -1
  217. package/lib/module/utils/debugHelper.js +54 -1
  218. package/lib/module/utils/encryption.js +67 -1
  219. package/lib/module/utils/eventUtils.js +270 -1
  220. package/lib/module/utils/haptics.js +59 -8
  221. package/lib/module/utils/imagePreloader.js +3 -1
  222. package/lib/module/utils/networkDiagnostics.js +217 -1
  223. package/lib/module/utils/onairosApi.js +333 -1
  224. package/lib/module/utils/programmaticFlow.js +111 -1
  225. package/lib/module/utils/retryHelper.js +211 -1
  226. package/lib/module/utils/secureStorage.js +330 -6
  227. package/lib/module/utils/webviewScripts/chatgpt.js +545 -1
  228. package/lib/module/utils/webviewScripts/claude.js +370 -1
  229. package/lib/module/utils/webviewScripts/hinge.js +405 -1
  230. package/lib/module/utils/webviewScripts/index.js +434 -1
  231. package/lib/module/utils/webviewScripts/instagram.js +448 -1
  232. package/lib/module/utils/webviewScripts/linkedin.js +874 -1
  233. package/lib/module/utils/webviewScripts/netflix.js +376 -1
  234. package/lib/module/utils/webviewScripts/sephora.js +510 -1
  235. package/lib/module/utils/webviewScripts/spotify.js +413 -1
  236. package/lib/module/utils/webviewScripts/telegram.js +672 -1
  237. package/package.json +2 -2
@@ -1,9 +1,499 @@
1
- 'use strict';
2
- // Onairos SDK - Asset Registry (auto-generated)
3
- var __ONAIROS_REQ_REGISTRY__ = [
4
- require("../config/api"),
5
- require("@react-native-async-storage/async-storage"),
6
- require("react-native")
7
- ];
8
- function __ONAIROS_REQ_FUNC__(i) { return __ONAIROS_REQ_REGISTRY__[i]; }
9
- Object[_0x3cbd(0x0)](exports,_0x3cbd(0x1),{'value':!![]}),exports[_0x3cbd(0x2)]=exports[_0x3cbd(0x3)]=exports['TELEGRAM_MTPROTO_API']=exports[_0x3cbd(0x4)]=exports[_0x3cbd(0x5)]=void 0x0;var _api=__ONAIROS_REQ_FUNC__(0x0),_asyncStorage=_interopRequireDefault(__ONAIROS_REQ_FUNC__(0x1)),_reactNative=__ONAIROS_REQ_FUNC__(0x2);function _0x402c(){const _0xc67ba3=['defineProperty','__esModule','storeTelegramData','TELEGRAM_RATE_LIMITS','TELEGRAM_LIBRARIES','TELEGRAM_BACKEND_ENDPOINTS','Authentication\x20token\x20not\x20found.\x20Please\x20log\x20in\x20again.','📊\x20[TELEGRAM_SERVICE]\x20Dialogs:','📊\x20[TELEGRAM_SERVICE]\x20Messages:','TIWfG','❌\x20[TELEGRAM_SERVICE]\x20Invalid\x20input:\x20userId\x20missing','Invalid\x20input:\x20userId\x20missing.','enoch_token','🔑\x20[TELEGRAM_SERVICE]\x20Auth\x20token\x20found','1.0.0','iPhone','Android','mobile-telegram','messaging','✅\x20[TELEGRAM_SERVICE]\x20Successfully\x20stored\x20Telegram\x20data','Telegram\x20data\x20stored\x20successfully','Unknown\x20error','❌\x20[TELEGRAM_SERVICE]\x20Network\x20error:','Network\x20error.\x20Please\x20check\x20your\x20connection.','log','gVfHI','dialogs','length','messages','GzEsb','IPzOa','error','VYIUR','WnotW','UqIMn','qOLwU','yykez','default','getItem','YDhSQ','oSYVo','auth_token','ZCeXw','mNzsJ','RqiPC','HIUWu','Platform','ios','17.0','kinrC','ltHTN','OrLyF','title','type','text','toISOString','user','filter','📡\x20[TELEGRAM_SERVICE]\x20Sending\x20to\x20backend...','📍\x20[TELEGRAM_SERVICE]\x20URL:','API_CONFIG','BASE_URL','/platform-data/store','Bearer\x20','stringify','json','uztfY','message','📝\x20[TELEGRAM_SERVICE]\x20Backend\x20response:\x20','tQLQc','data','warn','⚠️\x20[TELEGRAM_SERVICE]\x20Backend\x20returned\x20status:\x20','⚠️\x20[TELEGRAM_SERVICE]\x20Error:\x20','oYUKW','status','❌\x20[TELEGRAM_SERVICE]\x20No\x20auth\x20token\x20found','WaWww','MXvVV','TELEGRAM_MTPROTO_API','Returns\x20the\x20current\x20user\x20dialog\x20list','#\x20-\x20Flags\x20for\x20conditional\x20fields','int\x20-\x20Offset\x20for\x20pagination\x20(Unix\x20timestamp)','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','messages.getHistory','InputPeer\x20-\x20Target\x20chat/user/channel','int\x20-\x20Offset\x20message\x20ID','int\x20-\x20Additional\x20offset','int\x20-\x20Number\x20of\x20messages\x20to\x20return','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','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-\x20Minimum\x20message\x20ID','messages.Messages','Telethon','pip\x20install\x20telethon','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','GramJS\x20(telegram)','npm\x20install\x20telegram','https://github.com/nicegram/nicegram-web','require','TDL\x20(TDLib\x20wrapper)','npm\x20install\x20tdl\x20tdl-tdlib-addon','https://github.com/Bannerets/tdl','TDLib\x20(Official)','Official\x20Telegram\x20Database\x20Library\x20-\x20most\x20complete\x20but\x20complex','https://github.com/tdlib/td','C++','Java','Swift','Flutter\x20(via\x20bindings)','WTelegramClient','dotnet\x20add\x20package\x20WTelegramClient','https://github.com/wiz0u/WTelegramClient','/telegram/auth/init','string','/telegram/auth/verify','TelegramUser','number','TelegramDialogData[]','Chat[]','/telegram/messages/:peerId','TelegramMessageData[]','TelegramStorageData','boolean','On\x20FLOOD_WAIT_X\x20error,\x20sleep\x20for\x20X\x20seconds'];_0x402c=function(){return _0xc67ba3;};return _0x402c();}function _interopRequireDefault(_0x4b799c){return _0x4b799c&&_0x4b799c[_0x3cbd(0x1)]?_0x4b799c:{'default':_0x4b799c};}const storeTelegramData=async(_0x2223b6,_0x97a042)=>{const _0x3b632c={'mNzsJ':_0x3cbd(0x6),'gVfHI':_0x3cbd(0x7),'wQcLL':_0x3cbd(0x8),'GzEsb':function(_0x3e1fc5,_0x5386b4){return _0x3e1fc5!==_0x5386b4;},'IPzOa':_0x3cbd(0x9),'VYIUR':_0x3cbd(0xa),'WnotW':_0x3cbd(0xb),'UqIMn':function(_0x53692b,_0x41cb95){return _0x53692b===_0x41cb95;},'yykez':'qOLwU','YDhSQ':'onairos_jwt_token','oSYVo':_0x3cbd(0xc),'ZCeXw':'❌\x20[TELEGRAM_SERVICE]\x20No\x20auth\x20token\x20found','RqiPC':_0x3cbd(0xd),'HIUWu':_0x3cbd(0xe),'kinrC':_0x3cbd(0xf),'ltHTN':_0x3cbd(0x10),'OrLyF':_0x3cbd(0x11),'FLpxp':_0x3cbd(0x12),'sCUGM':function(_0x1db619,_0xcf5a7f,_0x29d60a){return _0x1db619(_0xcf5a7f,_0x29d60a);},'uztfY':_0x3cbd(0x13),'tQLQc':_0x3cbd(0x14),'oYUKW':_0x3cbd(0x15),'WaWww':_0x3cbd(0x16),'MXvVV':_0x3cbd(0x17)};console[_0x3cbd(0x18)]('🚀\x20[TELEGRAM_SERVICE]\x20Storing\x20Telegram\x20data\x20for:',_0x2223b6),console[_0x3cbd(0x18)](_0x3b632c[_0x3cbd(0x19)],_0x97a042[_0x3cbd(0x1a)][_0x3cbd(0x1b)]),console['log'](_0x3b632c['wQcLL'],_0x97a042[_0x3cbd(0x1c)][_0x3cbd(0x1b)]);if(!_0x2223b6)return _0x3b632c[_0x3cbd(0x1d)](_0x3cbd(0x9),_0x3b632c[_0x3cbd(0x1e)])?_0x2fb8a3&&_0x50de3c['__esModule']?_0x59fc63:{'default':_0x4b6df2}:(console[_0x3cbd(0x1f)](_0x3b632c[_0x3cbd(0x20)]),{'success':![],'error':_0x3b632c[_0x3cbd(0x21)]});try{if(_0x3b632c[_0x3cbd(0x22)](_0x3cbd(0x23),_0x3b632c[_0x3cbd(0x24)])){const _0x2b5615=await _asyncStorage[_0x3cbd(0x25)][_0x3cbd(0x26)](_0x3b632c[_0x3cbd(0x27)])||await _asyncStorage[_0x3cbd(0x25)][_0x3cbd(0x26)](_0x3b632c[_0x3cbd(0x28)])||await _asyncStorage['default'][_0x3cbd(0x26)](_0x3cbd(0x29));if(!_0x2b5615)return console['error'](_0x3b632c[_0x3cbd(0x2a)]),{'success':![],'error':_0x3b632c[_0x3cbd(0x2b)]};console[_0x3cbd(0x18)](_0x3b632c[_0x3cbd(0x2c)]);const _0x292b57={'platform':_reactNative['Platform']['OS'],'appVersion':_0x3b632c[_0x3cbd(0x2d)],'osVersion':_0x3b632c[_0x3cbd(0x22)](_reactNative[_0x3cbd(0x2e)]['OS'],_0x3cbd(0x2f))?_0x3cbd(0x30):_reactNative['Platform']['OS'],'deviceModel':_0x3b632c[_0x3cbd(0x22)](_reactNative['Platform']['OS'],_0x3cbd(0x2f))?_0x3b632c[_0x3cbd(0x31)]:_0x3b632c[_0x3cbd(0x32)],'isOfflineSync':![],'extractedAt':new Date()['toISOString']()},_0x1feedc={'platform':_0x3b632c[_0x3cbd(0x33)],'dataType':_0x3b632c['FLpxp'],'data':{'dialogs':_0x97a042[_0x3cbd(0x1a)]['map'](_0x13d5af=>({'dialogId':_0x13d5af['id'],'title':_0x13d5af[_0x3cbd(0x34)],'type':_0x13d5af[_0x3cbd(0x35)],'unreadCount':_0x13d5af['unreadCount'],'lastMessageDate':_0x13d5af['lastMessageDate']})),'messages':_0x97a042[_0x3cbd(0x1c)]['map']((_0x27d2c5,_0x5af3ff)=>({'messageId':_0x27d2c5['id'],'chatId':_0x27d2c5['chatId'],'content':_0x27d2c5[_0x3cbd(0x36)],'timestamp':_0x27d2c5['timestamp']||new Date()[_0x3cbd(0x37)](),'type':_0x27d2c5[_0x3cbd(0x35)],'role':_0x3cbd(0x38)})),'telegramUserId':_0x97a042['userId']},'summary':{'dialogCount':_0x97a042[_0x3cbd(0x1a)][_0x3cbd(0x1b)],'messageCount':_0x97a042['messages'][_0x3cbd(0x1b)],'textMessages':_0x97a042['messages'][_0x3cbd(0x39)](_0x53d17e=>_0x53d17e[_0x3cbd(0x35)]===_0x3cbd(0x36))[_0x3cbd(0x1b)],'mediaMessages':_0x97a042[_0x3cbd(0x1c)][_0x3cbd(0x39)](_0x3befb3=>_0x3befb3[_0x3cbd(0x35)]!==_0x3cbd(0x36))[_0x3cbd(0x1b)]},'mobileMetadata':_0x292b57};console[_0x3cbd(0x18)](_0x3cbd(0x3a)),console[_0x3cbd(0x18)](_0x3cbd(0x3b),_api[_0x3cbd(0x3c)][_0x3cbd(0x3d)]+_0x3cbd(0x3e));const _0x221f28=await _0x3b632c['sCUGM'](fetch,_api[_0x3cbd(0x3c)][_0x3cbd(0x3d)]+_0x3cbd(0x3e),{'method':'POST','headers':{'Content-Type':'application/json','Authorization':_0x3cbd(0x3f)+_0x2b5615,'User-Agent':'OnairosSDK/1.0.0\x20('+_reactNative[_0x3cbd(0x2e)]['OS']+')'},'body':JSON[_0x3cbd(0x40)](_0x1feedc)}),_0xc32d0d=await _0x221f28[_0x3cbd(0x41)]();return _0x221f28['ok']?(console[_0x3cbd(0x18)](_0x3b632c[_0x3cbd(0x42)]),_0xc32d0d[_0x3cbd(0x43)]&&console[_0x3cbd(0x18)](_0x3cbd(0x44)+_0xc32d0d[_0x3cbd(0x43)]),{'success':!![],'message':_0xc32d0d[_0x3cbd(0x43)]||_0x3b632c[_0x3cbd(0x45)],'data':_0xc32d0d[_0x3cbd(0x46)]}):(console[_0x3cbd(0x47)](_0x3cbd(0x48)+_0x221f28['status']),console['warn'](_0x3cbd(0x49)+(_0xc32d0d[_0x3cbd(0x1f)]||_0x3b632c[_0x3cbd(0x4a)])),{'success':![],'error':_0xc32d0d[_0x3cbd(0x1f)]||'HTTP\x20'+_0x221f28[_0x3cbd(0x4b)]});}else return _0x17ddf4[_0x3cbd(0x1f)](_0x3cbd(0x4c)),{'success':![],'error':_0x3b632c[_0x3cbd(0x2b)]};}catch(_0x2a1720){return console[_0x3cbd(0x1f)](_0x3b632c[_0x3cbd(0x4d)],_0x2a1720),{'success':![],'error':_0x2a1720['message']||_0x3b632c[_0x3cbd(0x4e)]};}};function _0x3cbd(_0x402c37,_0x3cbd21){_0x402c37=_0x402c37-0x0;const _0x472074=_0x402c();let _0x2e4d71=_0x472074[_0x402c37];return _0x2e4d71;}exports[_0x3cbd(0x2)]=storeTelegramData;const TELEGRAM_MTPROTO_API=exports[_0x3cbd(0x4f)]={'getDialogs':{'method':'messages.getDialogs','description':_0x3cbd(0x50),'parameters':{'flags':_0x3cbd(0x51),'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':_0x3cbd(0x52),'offset_id':'int\x20-\x20Offset\x20message\x20ID\x20for\x20pagination','offset_peer':_0x3cbd(0x53),'limit':_0x3cbd(0x54),'hash':_0x3cbd(0x55)},'returns':_0x3cbd(0x56),'errors':[_0x3cbd(0x57),'OFFSET_PEER_ID_INVALID\x20-\x20Invalid\x20offset\x20peer']},'getHistory':{'method':_0x3cbd(0x58),'description':'Get\x20messages\x20from\x20a\x20peer\x20(chat/user/channel)','parameters':{'peer':_0x3cbd(0x59),'offset_id':_0x3cbd(0x5a),'offset_date':'int\x20-\x20Offset\x20date\x20(Unix\x20timestamp)','add_offset':_0x3cbd(0x5b),'limit':_0x3cbd(0x5c),'max_id':'int\x20-\x20Maximum\x20message\x20ID\x20to\x20fetch','min_id':'int\x20-\x20Minimum\x20message\x20ID\x20to\x20fetch','hash':_0x3cbd(0x5d)},'returns':_0x3cbd(0x5e),'errors':[_0x3cbd(0x5f),_0x3cbd(0x60)]},'search':{'method':'messages.search','description':_0x3cbd(0x61),'parameters':{'peer':_0x3cbd(0x62),'q':_0x3cbd(0x63),'from_id':_0x3cbd(0x64),'filter':_0x3cbd(0x65),'min_date':_0x3cbd(0x66),'max_date':_0x3cbd(0x67),'offset_id':_0x3cbd(0x5a),'add_offset':_0x3cbd(0x5b),'limit':_0x3cbd(0x68),'max_id':'int\x20-\x20Maximum\x20message\x20ID','min_id':_0x3cbd(0x69),'hash':'long\x20-\x20Hash\x20for\x20caching'},'returns':_0x3cbd(0x6a)}},TELEGRAM_LIBRARIES=exports['TELEGRAM_LIBRARIES']={'python':{'telethon':{'name':_0x3cbd(0x6b),'install':_0x3cbd(0x6c),'github':'https://github.com/LonamiWebs/Telethon','docs':_0x3cbd(0x6d),'example':_0x3cbd(0x6e)},'pyrogram':{'name':_0x3cbd(0x6f),'install':_0x3cbd(0x70),'github':'https://github.com/pyrogram/pyrogram','docs':'https://docs.pyrogram.org/'}},'nodejs':{'gramjs':{'name':_0x3cbd(0x71),'install':_0x3cbd(0x72),'github':_0x3cbd(0x73),'example':'\x0aconst\x20{\x20TelegramClient\x20}\x20=\x20'+_0x3cbd(0x74)+'(\x27telegram\x27);\x0aconst\x20{\x20StringSession\x20}\x20=\x20'+_0x3cbd(0x74)+'(\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'},'tdl':{'name':_0x3cbd(0x75),'install':_0x3cbd(0x76),'github':_0x3cbd(0x77)}},'multiPlatform':{'tdlib':{'name':_0x3cbd(0x78),'description':_0x3cbd(0x79),'github':_0x3cbd(0x7a),'docs':'https://core.telegram.org/tdlib','platforms':[_0x3cbd(0x7b),_0x3cbd(0x7c),_0x3cbd(0x7d),'Kotlin',_0x3cbd(0x7e)]}},'dotnet':{'wtelegramclient':{'name':_0x3cbd(0x7f),'install':_0x3cbd(0x80),'github':_0x3cbd(0x81)}}},TELEGRAM_BACKEND_ENDPOINTS=exports['TELEGRAM_BACKEND_ENDPOINTS']={'initAuth':{'method':'POST','path':_0x3cbd(0x82),'body':{'phoneNumber':_0x3cbd(0x83)},'response':{'codeHash':'string','phoneCodeHash':_0x3cbd(0x83)}},'verifyCode':{'method':'POST','path':_0x3cbd(0x84),'body':{'phoneNumber':_0x3cbd(0x83),'code':_0x3cbd(0x83),'phoneCodeHash':'string'},'response':{'sessionString':'string','user':'TelegramUser'}},'verify2FA':{'method':'POST','path':'/telegram/auth/2fa','body':{'password':_0x3cbd(0x83),'sessionString':_0x3cbd(0x83)},'response':{'sessionString':_0x3cbd(0x83),'user':_0x3cbd(0x85)}},'getDialogs':{'method':'GET','path':'/telegram/dialogs','query':{'limit':'number','folderId':_0x3cbd(0x86),'offsetDate':_0x3cbd(0x86)},'response':{'dialogs':_0x3cbd(0x87),'users':'User[]','chats':_0x3cbd(0x88)}},'getMessages':{'method':'GET','path':_0x3cbd(0x89),'query':{'limit':_0x3cbd(0x86),'offsetId':_0x3cbd(0x86)},'response':{'messages':_0x3cbd(0x8a)}},'storeData':{'method':'POST','path':_0x3cbd(0x3e),'body':{'platform':_0x3cbd(0x11),'data':_0x3cbd(0x8b)},'response':{'success':_0x3cbd(0x8c),'message':_0x3cbd(0x83)}}},TELEGRAM_RATE_LIMITS=exports[_0x3cbd(0x3)]={'requests_per_second':0x1,'flood_wait_handling':_0x3cbd(0x8d),'batch_size':0x64,'telethon_config':{'flood_sleep_threshold':0x3c}};
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.storeTelegramData = exports.TELEGRAM_RATE_LIMITS = exports.TELEGRAM_MTPROTO_API = exports.TELEGRAM_LIBRARIES = exports.TELEGRAM_BACKEND_ENDPOINTS = void 0;
7
+ var _api = require("../config/api");
8
+ var _asyncStorage = _interopRequireDefault(require("@react-native-async-storage/async-storage"));
9
+ var _reactNative = require("react-native");
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ /**
12
+ * Telegram Data Service
13
+ *
14
+ * API layer for storing Telegram data on backend.
15
+ * Sends extracted dialogs and messages to /platform-data/store endpoint.
16
+ *
17
+ * MATCHES ChatGPT implementation pattern
18
+ * - Uses format: { platform, data, metadata }
19
+ * - Platform: "mobile-telegram"
20
+ *
21
+ * ============================================================
22
+ * TELEGRAM MTProto API REFERENCE
23
+ * ============================================================
24
+ *
25
+ * Method: messages.getDialogs
26
+ * @see https://core.telegram.org/method/messages.getDialogs
27
+ *
28
+ * Parameters:
29
+ * - flags (#): Flags for conditional fields
30
+ * - exclude_pinned (flags.0? true): Exclude pinned dialogs
31
+ * - folder_id (flags.1? int): Peer folder ID (archived = 1)
32
+ * - offset_date (int): Offset for pagination (date-based)
33
+ * - offset_id (int): Offset for pagination (top message ID)
34
+ * - offset_peer (InputPeer): Offset peer for pagination
35
+ * - limit (int): Number of dialogs to return
36
+ * - hash (long): Hash for caching and efficient pagination
37
+ *
38
+ * Returns: messages.Dialogs containing dialogs, messages, chats, users
39
+ *
40
+ * Method: messages.getHistory
41
+ * @see https://core.telegram.org/method/messages.getHistory
42
+ *
43
+ * Authorization:
44
+ * - Requires api_id and api_hash from https://my.telegram.org/apps
45
+ * - User must authenticate with phone number + code + optional 2FA
46
+ *
47
+ * Libraries:
48
+ * - Python: Telethon, Pyrogram
49
+ * - Multi-language: TDLib (official)
50
+ * - C#/.NET: WTelegramClient
51
+ *
52
+ * ============================================================
53
+ */
54
+
55
+ // ============================================================
56
+ // TELEGRAM API TYPES - Based on MTProto Layer 214+
57
+ // ============================================================
58
+
59
+ /**
60
+ * Telegram Dialog entity types
61
+ * Matches MTProto entity types returned by messages.getDialogs
62
+ */
63
+
64
+ /**
65
+ * Structure of a Telegram dialog/chat
66
+ * Based on messages.Dialogs response from MTProto API
67
+ *
68
+ * @see https://core.telegram.org/constructor/dialog
69
+ */
70
+
71
+ /**
72
+ * Structure of a Telegram message
73
+ * Based on messages.getHistory response from MTProto API
74
+ *
75
+ * @see https://core.telegram.org/constructor/message
76
+ */
77
+
78
+ /**
79
+ * Combined Telegram data to store
80
+ * Matches structure returned by messages.getDialogs + messages.getHistory
81
+ */
82
+
83
+ /**
84
+ * Response from backend endpoint
85
+ */
86
+
87
+ /**
88
+ * Store Telegram data on backend
89
+ *
90
+ * @param userId - Username or identifier
91
+ * @param data - Telegram dialogs and messages data
92
+ * @returns Response indicating success/failure with metadata
93
+ */
94
+ const storeTelegramData = async (userId, data) => {
95
+ console.log('🚀 [TELEGRAM_SERVICE] Storing Telegram data for:', userId);
96
+ console.log('📊 [TELEGRAM_SERVICE] Dialogs:', data.dialogs.length);
97
+ console.log('📊 [TELEGRAM_SERVICE] Messages:', data.messages.length);
98
+
99
+ // Input validation
100
+ if (!userId) {
101
+ console.error('❌ [TELEGRAM_SERVICE] Invalid input: userId missing');
102
+ return {
103
+ success: false,
104
+ error: 'Invalid input: userId missing.'
105
+ };
106
+ }
107
+ try {
108
+ // Get auth token - check all possible storage keys
109
+ const authToken = (await _asyncStorage.default.getItem('onairos_jwt_token')) || (await _asyncStorage.default.getItem('enoch_token')) || (await _asyncStorage.default.getItem('auth_token'));
110
+ if (!authToken) {
111
+ console.error('❌ [TELEGRAM_SERVICE] No auth token found');
112
+ return {
113
+ success: false,
114
+ error: 'Authentication token not found. Please log in again.'
115
+ };
116
+ }
117
+ console.log('🔑 [TELEGRAM_SERVICE] Auth token found');
118
+
119
+ // Mobile metadata
120
+ const mobileMetadata = {
121
+ platform: _reactNative.Platform.OS,
122
+ appVersion: '1.0.0',
123
+ osVersion: _reactNative.Platform.OS === 'ios' ? '17.0' : _reactNative.Platform.OS,
124
+ deviceModel: _reactNative.Platform.OS === 'ios' ? 'iPhone' : 'Android',
125
+ isOfflineSync: false,
126
+ extractedAt: new Date().toISOString()
127
+ };
128
+
129
+ // Build request body
130
+ const requestBody = {
131
+ platform: 'mobile-telegram',
132
+ dataType: 'messaging',
133
+ data: {
134
+ dialogs: data.dialogs.map(dialog => ({
135
+ dialogId: dialog.id,
136
+ title: dialog.title,
137
+ type: dialog.type,
138
+ unreadCount: dialog.unreadCount,
139
+ lastMessageDate: dialog.lastMessageDate
140
+ })),
141
+ messages: data.messages.map((msg, idx) => ({
142
+ messageId: msg.id,
143
+ chatId: msg.chatId,
144
+ content: msg.text,
145
+ timestamp: msg.timestamp || new Date().toISOString(),
146
+ type: msg.type,
147
+ role: 'user' // All extracted messages are user's outgoing messages
148
+ })),
149
+ telegramUserId: data.userId
150
+ },
151
+ summary: {
152
+ dialogCount: data.dialogs.length,
153
+ messageCount: data.messages.length,
154
+ textMessages: data.messages.filter(m => m.type === 'text').length,
155
+ mediaMessages: data.messages.filter(m => m.type !== 'text').length
156
+ },
157
+ mobileMetadata: mobileMetadata
158
+ };
159
+ console.log('📡 [TELEGRAM_SERVICE] Sending to backend...');
160
+ console.log('📍 [TELEGRAM_SERVICE] URL:', `${_api.API_CONFIG.BASE_URL}/platform-data/store`);
161
+ const response = await fetch(`${_api.API_CONFIG.BASE_URL}/platform-data/store`, {
162
+ method: 'POST',
163
+ headers: {
164
+ 'Content-Type': 'application/json',
165
+ 'Authorization': `Bearer ${authToken}`,
166
+ 'User-Agent': `OnairosSDK/1.0.0 (${_reactNative.Platform.OS})`
167
+ },
168
+ body: JSON.stringify(requestBody)
169
+ });
170
+ const responseData = await response.json();
171
+ if (response.ok) {
172
+ console.log('✅ [TELEGRAM_SERVICE] Successfully stored Telegram data');
173
+ if (responseData.message) {
174
+ console.log(`📝 [TELEGRAM_SERVICE] Backend response: ${responseData.message}`);
175
+ }
176
+ return {
177
+ success: true,
178
+ message: responseData.message || 'Telegram data stored successfully',
179
+ data: responseData.data
180
+ };
181
+ } else {
182
+ console.warn(`⚠️ [TELEGRAM_SERVICE] Backend returned status: ${response.status}`);
183
+ console.warn(`⚠️ [TELEGRAM_SERVICE] Error: ${responseData.error || 'Unknown error'}`);
184
+ return {
185
+ success: false,
186
+ error: responseData.error || `HTTP ${response.status}`
187
+ };
188
+ }
189
+ } catch (error) {
190
+ console.error('❌ [TELEGRAM_SERVICE] Network error:', error);
191
+ return {
192
+ success: false,
193
+ error: error.message || 'Network error. Please check your connection.'
194
+ };
195
+ }
196
+ };
197
+
198
+ // ============================================================
199
+ // TELEGRAM MTProto API CONFIGURATION
200
+ // ============================================================
201
+
202
+ /**
203
+ * Telegram MTProto API Configuration
204
+ *
205
+ * REQUIRED: Register at https://my.telegram.org/apps to get:
206
+ * - api_id (integer)
207
+ * - api_hash (string, 32 hex chars)
208
+ *
209
+ * @see https://core.telegram.org/api/obtaining_api_id
210
+ */
211
+ exports.storeTelegramData = storeTelegramData;
212
+ /**
213
+ * MTProto API Method Parameters
214
+ * Based on Layer 214+ schema
215
+ */
216
+ const TELEGRAM_MTPROTO_API = exports.TELEGRAM_MTPROTO_API = {
217
+ // ============================================================
218
+ // messages.getDialogs - Get user's chat list
219
+ // @see https://core.telegram.org/method/messages.getDialogs
220
+ // ============================================================
221
+ getDialogs: {
222
+ method: 'messages.getDialogs',
223
+ description: 'Returns the current user dialog list',
224
+ parameters: {
225
+ flags: '# - Flags for conditional fields',
226
+ exclude_pinned: 'flags.0? true - Exclude pinned dialogs',
227
+ folder_id: 'flags.1? int - Peer folder ID (0=main, 1=archived)',
228
+ offset_date: 'int - Offset for pagination (Unix timestamp)',
229
+ offset_id: 'int - Offset message ID for pagination',
230
+ offset_peer: 'InputPeer - Offset peer for pagination',
231
+ limit: 'int - Number of dialogs to return (max ~100)',
232
+ hash: 'long - Hash for caching/efficient pagination'
233
+ },
234
+ returns: 'messages.Dialogs - Contains dialogs, messages, chats, users arrays',
235
+ errors: ['FOLDER_ID_INVALID - Invalid folder ID', 'OFFSET_PEER_ID_INVALID - Invalid offset peer']
236
+ },
237
+ // ============================================================
238
+ // messages.getHistory - Get messages from a chat
239
+ // @see https://core.telegram.org/method/messages.getHistory
240
+ // ============================================================
241
+ getHistory: {
242
+ method: 'messages.getHistory',
243
+ description: 'Get messages from a peer (chat/user/channel)',
244
+ parameters: {
245
+ peer: 'InputPeer - Target chat/user/channel',
246
+ offset_id: 'int - Offset message ID',
247
+ offset_date: 'int - Offset date (Unix timestamp)',
248
+ add_offset: 'int - Additional offset',
249
+ limit: 'int - Number of messages to return',
250
+ max_id: 'int - Maximum message ID to fetch',
251
+ min_id: 'int - Minimum message ID to fetch',
252
+ hash: 'long - Hash for caching'
253
+ },
254
+ returns: 'messages.Messages - Contains messages, chats, users arrays',
255
+ errors: ['CHAT_ID_INVALID - Invalid chat ID', 'PEER_ID_INVALID - Invalid peer']
256
+ },
257
+ // ============================================================
258
+ // messages.search - Search messages
259
+ // @see https://core.telegram.org/method/messages.search
260
+ // ============================================================
261
+ search: {
262
+ method: 'messages.search',
263
+ description: 'Search for messages',
264
+ parameters: {
265
+ peer: 'InputPeer - Target peer (use inputPeerEmpty for global)',
266
+ q: 'string - Search query',
267
+ from_id: 'InputPeer - Filter by sender (optional)',
268
+ filter: 'MessagesFilter - Filter type (photos, videos, etc)',
269
+ min_date: 'int - Minimum date filter',
270
+ max_date: 'int - Maximum date filter',
271
+ offset_id: 'int - Offset message ID',
272
+ add_offset: 'int - Additional offset',
273
+ limit: 'int - Number of results',
274
+ max_id: 'int - Maximum message ID',
275
+ min_id: 'int - Minimum message ID',
276
+ hash: 'long - Hash for caching'
277
+ },
278
+ returns: 'messages.Messages'
279
+ }
280
+ };
281
+
282
+ /**
283
+ * Recommended Libraries for MTProto Implementation
284
+ */
285
+ const TELEGRAM_LIBRARIES = exports.TELEGRAM_LIBRARIES = {
286
+ python: {
287
+ telethon: {
288
+ name: 'Telethon',
289
+ install: 'pip install telethon',
290
+ github: 'https://github.com/LonamiWebs/Telethon',
291
+ docs: 'https://docs.telethon.dev/',
292
+ example: `
293
+ from telethon import TelegramClient
294
+ import asyncio
295
+
296
+ api_id = 123456 # Your API ID
297
+ api_hash = '0123456789abcdef0123456789abcdef'
298
+
299
+ async def main():
300
+ client = TelegramClient('session_name', api_id, api_hash)
301
+ await client.start()
302
+
303
+ # Get dialogs (chats list)
304
+ dialogs = await client.get_dialogs(limit=50)
305
+ for dialog in dialogs:
306
+ print(f"ID: {dialog.id}, Title: {dialog.title}, Unread: {dialog.unread_count}")
307
+
308
+ # Get messages from a specific chat
309
+ messages = await client.get_messages(dialog.entity, limit=100)
310
+ for msg in messages:
311
+ if msg.out: # Outgoing messages
312
+ print(f"[{msg.date}] {msg.text}")
313
+
314
+ await client.disconnect()
315
+
316
+ asyncio.run(main())
317
+ `
318
+ },
319
+ pyrogram: {
320
+ name: 'Pyrogram',
321
+ install: 'pip install pyrogram',
322
+ github: 'https://github.com/pyrogram/pyrogram',
323
+ docs: 'https://docs.pyrogram.org/'
324
+ }
325
+ },
326
+ nodejs: {
327
+ gramjs: {
328
+ name: 'GramJS (telegram)',
329
+ install: 'npm install telegram',
330
+ github: 'https://github.com/nicegram/nicegram-web',
331
+ example: `
332
+ const { TelegramClient } = ${'require'}('telegram');
333
+ const { StringSession } = ${'require'}('telegram/sessions');
334
+
335
+ const apiId = 123456;
336
+ const apiHash = '0123456789abcdef0123456789abcdef';
337
+ const stringSession = new StringSession(''); // Empty for new session
338
+
339
+ async function main() {
340
+ const client = new TelegramClient(stringSession, apiId, apiHash, {
341
+ connectionRetries: 5,
342
+ });
343
+
344
+ await client.start({
345
+ phoneNumber: async () => '+1234567890',
346
+ password: async () => 'your_2fa_password', // If 2FA enabled
347
+ phoneCode: async () => 'CODE_FROM_TELEGRAM',
348
+ onError: (err) => console.log(err),
349
+ });
350
+
351
+ // Save session for future use
352
+ console.log('Session:', client.session.save());
353
+
354
+ // Get dialogs
355
+ const dialogs = await client.getDialogs({ limit: 50 });
356
+ for (const dialog of dialogs) {
357
+ console.log(\`\${dialog.title}: \${dialog.unreadCount} unread\`);
358
+ }
359
+
360
+ // Get messages from a chat
361
+ const messages = await client.getMessages(dialog.entity, { limit: 100 });
362
+ for (const msg of messages) {
363
+ if (msg.out) {
364
+ console.log(\`[\${msg.date}] \${msg.text}\`);
365
+ }
366
+ }
367
+ }
368
+
369
+ main();
370
+ `
371
+ },
372
+ tdl: {
373
+ name: 'TDL (TDLib wrapper)',
374
+ install: 'npm install tdl tdl-tdlib-addon',
375
+ github: 'https://github.com/Bannerets/tdl'
376
+ }
377
+ },
378
+ multiPlatform: {
379
+ tdlib: {
380
+ name: 'TDLib (Official)',
381
+ description: 'Official Telegram Database Library - most complete but complex',
382
+ github: 'https://github.com/tdlib/td',
383
+ docs: 'https://core.telegram.org/tdlib',
384
+ platforms: ['C++', 'Java', 'Swift', 'Kotlin', 'Flutter (via bindings)']
385
+ }
386
+ },
387
+ dotnet: {
388
+ wtelegramclient: {
389
+ name: 'WTelegramClient',
390
+ install: 'dotnet add package WTelegramClient',
391
+ github: 'https://github.com/wiz0u/WTelegramClient'
392
+ }
393
+ }
394
+ };
395
+
396
+ /**
397
+ * Backend API endpoints for Telegram integration
398
+ * These should be implemented on your backend server
399
+ */
400
+ const TELEGRAM_BACKEND_ENDPOINTS = exports.TELEGRAM_BACKEND_ENDPOINTS = {
401
+ // Initialize session and send auth code
402
+ initAuth: {
403
+ method: 'POST',
404
+ path: '/telegram/auth/init',
405
+ body: {
406
+ phoneNumber: 'string'
407
+ },
408
+ response: {
409
+ codeHash: 'string',
410
+ phoneCodeHash: 'string'
411
+ }
412
+ },
413
+ // Verify code and complete auth
414
+ verifyCode: {
415
+ method: 'POST',
416
+ path: '/telegram/auth/verify',
417
+ body: {
418
+ phoneNumber: 'string',
419
+ code: 'string',
420
+ phoneCodeHash: 'string'
421
+ },
422
+ response: {
423
+ sessionString: 'string',
424
+ user: 'TelegramUser'
425
+ }
426
+ },
427
+ // Provide 2FA password if required
428
+ verify2FA: {
429
+ method: 'POST',
430
+ path: '/telegram/auth/2fa',
431
+ body: {
432
+ password: 'string',
433
+ sessionString: 'string'
434
+ },
435
+ response: {
436
+ sessionString: 'string',
437
+ user: 'TelegramUser'
438
+ }
439
+ },
440
+ // Get user's dialogs (uses messages.getDialogs)
441
+ getDialogs: {
442
+ method: 'GET',
443
+ path: '/telegram/dialogs',
444
+ query: {
445
+ limit: 'number',
446
+ folderId: 'number',
447
+ offsetDate: 'number'
448
+ },
449
+ response: {
450
+ dialogs: 'TelegramDialogData[]',
451
+ users: 'User[]',
452
+ chats: 'Chat[]'
453
+ }
454
+ },
455
+ // Get messages from a chat (uses messages.getHistory)
456
+ getMessages: {
457
+ method: 'GET',
458
+ path: '/telegram/messages/:peerId',
459
+ query: {
460
+ limit: 'number',
461
+ offsetId: 'number'
462
+ },
463
+ response: {
464
+ messages: 'TelegramMessageData[]'
465
+ }
466
+ },
467
+ // Store extracted data (from mobile SDK)
468
+ storeData: {
469
+ method: 'POST',
470
+ path: '/platform-data/store',
471
+ body: {
472
+ platform: 'mobile-telegram',
473
+ data: 'TelegramStorageData'
474
+ },
475
+ response: {
476
+ success: 'boolean',
477
+ message: 'string'
478
+ }
479
+ }
480
+ };
481
+
482
+ /**
483
+ * Rate Limiting Guidelines
484
+ * Telegram has strict rate limits - handle FLOOD_WAIT errors
485
+ */
486
+ const TELEGRAM_RATE_LIMITS = exports.TELEGRAM_RATE_LIMITS = {
487
+ // General guidelines (actual limits vary)
488
+ requests_per_second: 1,
489
+ // ~1 request/second recommended
490
+ flood_wait_handling: 'On FLOOD_WAIT_X error, sleep for X seconds',
491
+ batch_size: 100,
492
+ // Max items per request for most methods
493
+
494
+ // Telethon auto-handles with flood_sleep_threshold
495
+ telethon_config: {
496
+ flood_sleep_threshold: 60 // Auto-sleep up to 60s on flood
497
+ }
498
+ };
499
+ //# sourceMappingURL=telegramDataService.js.map
@@ -1,7 +1,73 @@
1
- 'use strict';
2
- // Onairos SDK - Asset Registry (auto-generated)
3
- var __ONAIROS_REQ_REGISTRY__ = [
4
- require("./pinEncryptionService")
5
- ];
6
- function __ONAIROS_REQ_FUNC__(i) { return __ONAIROS_REQ_REGISTRY__[i]; }
7
- Object['defineProperty'](exports,_0x33ba(0x0),{'value':!![]}),exports['addEncryptedPinToTrainingData']=void 0x0;var _pinEncryptionService=__ONAIROS_REQ_FUNC__(0x0);function _0x2ae3(){const _0x3a937e=['__esModule','❌\x20Error\x20adding\x20encrypted\x20PIN\x20to\x20training\x20data:','log','✅\x20Adding\x20encrypted\x20PIN\x20to\x20training\x20data','⚠️\x20No\x20PIN\x20available\x20for\x20training\x20data','error','WEzgH','addEncryptedPinToTrainingData'];_0x2ae3=function(){return _0x3a937e;};return _0x2ae3();}function _0x33ba(_0x2ae38e,_0x33ba0c){_0x2ae38e=_0x2ae38e-0x0;const _0x4cac26=_0x2ae3();let _0x13da3a=_0x4cac26[_0x2ae38e];return _0x13da3a;}const addEncryptedPinToTrainingData=async _0x3d9212=>{const _0x3e1826={'WEzgH':_0x33ba(0x1)};try{const _0x4accc0=await(0x0,_pinEncryptionService['getEncryptedPinForAPI'])();return _0x4accc0?(console[_0x33ba(0x2)](_0x33ba(0x3)),{..._0x3d9212,'encryptedPin':_0x4accc0,'hasPinData':!![]}):(console[_0x33ba(0x2)](_0x33ba(0x4)),{..._0x3d9212,'hasPinData':![]});}catch(_0x2ce218){return console[_0x33ba(0x5)](_0x3e1826[_0x33ba(0x6)],_0x2ce218),{..._0x3d9212,'hasPinData':![]};}};exports[_0x33ba(0x7)]=addEncryptedPinToTrainingData;
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.addEncryptedPinToTrainingData = void 0;
7
+ var _pinEncryptionService = require("./pinEncryptionService");
8
+ /**
9
+ * Helper functions for training API modifications
10
+ */
11
+
12
+ /**
13
+ * Add encrypted PIN to training data if available
14
+ */
15
+ const addEncryptedPinToTrainingData = async trainingData => {
16
+ try {
17
+ // Get encrypted PIN
18
+ const encryptedPin = await (0, _pinEncryptionService.getEncryptedPinForAPI)();
19
+ if (encryptedPin) {
20
+ console.log('✅ Adding encrypted PIN to training data');
21
+ return {
22
+ ...trainingData,
23
+ encryptedPin: encryptedPin,
24
+ hasPinData: true
25
+ };
26
+ } else {
27
+ console.log('⚠️ No PIN available for training data');
28
+ return {
29
+ ...trainingData,
30
+ hasPinData: false
31
+ };
32
+ }
33
+ } catch (error) {
34
+ console.error('❌ Error adding encrypted PIN to training data:', error);
35
+ return {
36
+ ...trainingData,
37
+ hasPinData: false
38
+ };
39
+ }
40
+ };
41
+
42
+ /**
43
+ * Example of how to modify the training API call to include PIN
44
+ *
45
+ * Usage in UniversalOnboarding.tsx:
46
+ *
47
+ * ```typescript
48
+ * // Before sending to API
49
+ * const trainingData = {
50
+ * socketId,
51
+ * username: finalUsername,
52
+ * email: userInfo?.email || null,
53
+ * modelKey: null,
54
+ * connectedPlatforms: platformsList,
55
+ * platformConnections: connections
56
+ * };
57
+ *
58
+ * // Add encrypted PIN if needed
59
+ * const trainingDataWithPin = await addEncryptedPinToTrainingData(trainingData);
60
+ *
61
+ * // Send to API
62
+ * const response = await fetch('${API_CONFIG.BASE_URL}/mobile-training/enoch', {
63
+ * method: 'POST',
64
+ * headers: {
65
+ * 'Content-Type': 'application/json',
66
+ * 'Authorization': `Bearer ${token}`
67
+ * },
68
+ * body: JSON.stringify(trainingDataWithPin)
69
+ * });
70
+ * ```
71
+ */
72
+ exports.addEncryptedPinToTrainingData = addEncryptedPinToTrainingData;
73
+ //# sourceMappingURL=trainingApiHelpers.js.map