nodejs-insta-private-api-mqt 1.3.83 → 1.3.84

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 (392) hide show
  1. package/dist-ts/dist/constants/constants.js +341 -0
  2. package/dist-ts/dist/constants/index.js +53 -0
  3. package/dist-ts/dist/core/client.js +437 -0
  4. package/dist-ts/dist/core/nav-chain.js +252 -0
  5. package/dist-ts/dist/core/repository.js +6 -0
  6. package/dist-ts/dist/core/request.js +358 -0
  7. package/dist-ts/dist/core/state.js +1428 -0
  8. package/dist-ts/dist/core/utils.js +723 -0
  9. package/dist-ts/dist/downloadMedia.js +336 -0
  10. package/dist-ts/dist/errors/index.js +37 -0
  11. package/dist-ts/dist/extend.js +157 -0
  12. package/dist-ts/dist/fbns/fbns.client.events.js +2 -0
  13. package/dist-ts/dist/fbns/fbns.client.js +237 -0
  14. package/dist-ts/dist/fbns/fbns.device-auth.js +59 -0
  15. package/dist-ts/dist/fbns/fbns.types.js +2 -0
  16. package/dist-ts/dist/fbns/fbns.utilities.js +78 -0
  17. package/dist-ts/dist/fbns/index.js +24 -0
  18. package/dist-ts/dist/index.js +137 -0
  19. package/dist-ts/dist/mqtt-shim.js +14 -0
  20. package/dist-ts/dist/mqttot/index.js +24 -0
  21. package/dist-ts/dist/mqttot/mqttot.client.js +322 -0
  22. package/dist-ts/dist/mqttot/mqttot.connect.request.packet.js +8 -0
  23. package/dist-ts/dist/mqttot/mqttot.connect.response.packet.js +23 -0
  24. package/dist-ts/dist/mqttot/mqttot.connection.js +68 -0
  25. package/dist-ts/dist/realtime/commands/commands.js +67 -0
  26. package/dist-ts/dist/realtime/commands/direct.commands.js +415 -0
  27. package/dist-ts/dist/realtime/commands/enhanced.direct.commands.js +1529 -0
  28. package/dist-ts/dist/realtime/commands/index.js +23 -0
  29. package/dist-ts/dist/realtime/delta-sync.manager.js +260 -0
  30. package/dist-ts/dist/realtime/features/dm-sender.js +94 -0
  31. package/dist-ts/dist/realtime/features/error-handler.js +167 -0
  32. package/dist-ts/dist/realtime/features/gap-handler.js +60 -0
  33. package/dist-ts/dist/realtime/features/persistent-logger.js +174 -0
  34. package/dist-ts/dist/realtime/features/presence.manager.js +68 -0
  35. package/dist-ts/dist/realtime/features/session-health-monitor.js +327 -0
  36. package/dist-ts/dist/realtime/index.js +21 -0
  37. package/dist-ts/dist/realtime/messages/app-presence.event.js +2 -0
  38. package/dist-ts/dist/realtime/messages/index.js +23 -0
  39. package/dist-ts/dist/realtime/messages/message-sync.message.js +42 -0
  40. package/dist-ts/dist/realtime/messages/realtime-sub.direct.data.js +2 -0
  41. package/dist-ts/dist/realtime/messages/thread-update.message.js +2 -0
  42. package/dist-ts/dist/realtime/mixins/index.js +23 -0
  43. package/dist-ts/dist/realtime/mixins/message-sync.mixin.js +585 -0
  44. package/dist-ts/dist/realtime/mixins/mixin.js +40 -0
  45. package/dist-ts/dist/realtime/mixins/presence-typing.mixin.js +29 -0
  46. package/dist-ts/dist/realtime/mixins/realtime-sub.mixin.js +171 -0
  47. package/dist-ts/dist/realtime/parsers/graphql-parser.js +43 -0
  48. package/dist-ts/dist/realtime/parsers/graphql.parser.js +22 -0
  49. package/dist-ts/dist/realtime/parsers/index.js +26 -0
  50. package/dist-ts/dist/realtime/parsers/iris-parser.js +43 -0
  51. package/dist-ts/dist/realtime/parsers/iris.parser.js +9 -0
  52. package/dist-ts/dist/realtime/parsers/json-parser.js +43 -0
  53. package/dist-ts/dist/realtime/parsers/json.parser.js +9 -0
  54. package/dist-ts/dist/realtime/parsers/parser.js +2 -0
  55. package/dist-ts/dist/realtime/parsers/region-hint-parser.js +43 -0
  56. package/dist-ts/dist/realtime/parsers/region-hint.parser.js +14 -0
  57. package/dist-ts/dist/realtime/parsers/skywalker-parser.js +43 -0
  58. package/dist-ts/dist/realtime/parsers/skywalker.parser.js +14 -0
  59. package/dist-ts/dist/realtime/parsers-advanced.js +138 -0
  60. package/dist-ts/dist/realtime/proto-parser.js +186 -0
  61. package/dist-ts/dist/realtime/protocols/iris.handshake.js +76 -0
  62. package/dist-ts/dist/realtime/protocols/skywalker.protocol.js +96 -0
  63. package/dist-ts/dist/realtime/realtime.client.events.js +2 -0
  64. package/dist-ts/dist/realtime/realtime.client.js +2117 -0
  65. package/dist-ts/dist/realtime/realtime.service.js +408 -0
  66. package/dist-ts/dist/realtime/reconnect.manager.js +72 -0
  67. package/dist-ts/dist/realtime/session.manager.js +106 -0
  68. package/dist-ts/dist/realtime/subscriptions/graphql.subscription.js +98 -0
  69. package/dist-ts/dist/realtime/subscriptions/index.js +22 -0
  70. package/dist-ts/dist/realtime/subscriptions/skywalker.subscription.js +12 -0
  71. package/dist-ts/dist/realtime/topic-map.js +57 -0
  72. package/dist-ts/dist/realtime/topic.js +76 -0
  73. package/dist-ts/dist/repositories/account.repository.js +1267 -0
  74. package/dist-ts/dist/repositories/bloks.repository.js +66 -0
  75. package/dist-ts/dist/repositories/captcha.repository.js +40 -0
  76. package/dist-ts/dist/repositories/challenge.repository.js +108 -0
  77. package/dist-ts/dist/repositories/clip.repository.js +134 -0
  78. package/dist-ts/dist/repositories/close-friends.repository.js +41 -0
  79. package/dist-ts/dist/repositories/collection.repository.js +64 -0
  80. package/dist-ts/dist/repositories/direct-thread.repository.js +423 -0
  81. package/dist-ts/dist/repositories/direct.repository.js +246 -0
  82. package/dist-ts/dist/repositories/explore.repository.js +60 -0
  83. package/dist-ts/dist/repositories/fbsearch.repository.js +124 -0
  84. package/dist-ts/dist/repositories/feed.repository.js +237 -0
  85. package/dist-ts/dist/repositories/friendship.repository.js +277 -0
  86. package/dist-ts/dist/repositories/fundraiser.repository.js +38 -0
  87. package/dist-ts/dist/repositories/hashtag.repository.js +80 -0
  88. package/dist-ts/dist/repositories/highlights.repository.js +100 -0
  89. package/dist-ts/dist/repositories/insights.repository.js +66 -0
  90. package/dist-ts/dist/repositories/location.repository.js +67 -0
  91. package/dist-ts/dist/repositories/media.repository.js +370 -0
  92. package/dist-ts/dist/repositories/multiple-accounts.repository.js +36 -0
  93. package/dist-ts/dist/repositories/news.repository.js +32 -0
  94. package/dist-ts/dist/repositories/note.repository.js +51 -0
  95. package/dist-ts/dist/repositories/notification.repository.js +77 -0
  96. package/dist-ts/dist/repositories/share.repository.js +34 -0
  97. package/dist-ts/dist/repositories/signup.repository.js +178 -0
  98. package/dist-ts/dist/repositories/story.repository.js +268 -0
  99. package/dist-ts/dist/repositories/timeline.repository.js +57 -0
  100. package/dist-ts/dist/repositories/totp.repository.js +124 -0
  101. package/dist-ts/dist/repositories/track.repository.js +50 -0
  102. package/dist-ts/dist/repositories/upload.repository.js +191 -0
  103. package/dist-ts/dist/repositories/user.repository.js +332 -0
  104. package/dist-ts/dist/sendmedia/index.js +24 -0
  105. package/dist-ts/dist/sendmedia/sendFile.js +56 -0
  106. package/dist-ts/dist/sendmedia/sendPhoto.js +132 -0
  107. package/dist-ts/dist/sendmedia/sendRavenPhoto.js +133 -0
  108. package/dist-ts/dist/sendmedia/sendRavenVideo.js +136 -0
  109. package/dist-ts/dist/sendmedia/uploadPhoto.js +89 -0
  110. package/dist-ts/dist/sendmedia/uploadfFile.js +108 -0
  111. package/dist-ts/dist/services/live.service.js +113 -0
  112. package/dist-ts/dist/services/search.service.js +91 -0
  113. package/dist-ts/dist/shared/index.js +98 -0
  114. package/dist-ts/dist/shared/shared.js +85 -0
  115. package/dist-ts/dist/thrift/index.js +23 -0
  116. package/dist-ts/dist/thrift/thrift.js +105 -0
  117. package/dist-ts/dist/thrift/thrift.reading.js +339 -0
  118. package/dist-ts/dist/thrift/thrift.writing.js +393 -0
  119. package/dist-ts/dist/types/index.js +276 -0
  120. package/dist-ts/dist/useMultiFileAuthState.js +1878 -0
  121. package/dist-ts/dist/utils/index.js +244 -0
  122. package/dist-ts/examples/listen-to-messages.js +73 -0
  123. package/package.json +1 -1
  124. package/src-ts/dist/realtime/protocols/proto-definitions.ts +80 -0
  125. package/src-ts/dist/utils/helper-1.ts +1 -0
  126. package/src-ts/dist/utils/helper-10.ts +1 -0
  127. package/src-ts/dist/utils/helper-11.ts +1 -0
  128. package/src-ts/dist/utils/helper-12.ts +1 -0
  129. package/src-ts/dist/utils/helper-13.ts +1 -0
  130. package/src-ts/dist/utils/helper-14.ts +1 -0
  131. package/src-ts/dist/utils/helper-15.ts +1 -0
  132. package/src-ts/dist/utils/helper-16.ts +1 -0
  133. package/src-ts/dist/utils/helper-17.ts +1 -0
  134. package/src-ts/dist/utils/helper-18.ts +1 -0
  135. package/src-ts/dist/utils/helper-19.ts +1 -0
  136. package/src-ts/dist/utils/helper-2.ts +1 -0
  137. package/src-ts/dist/utils/helper-20.ts +1 -0
  138. package/src-ts/dist/utils/helper-21.ts +1 -0
  139. package/src-ts/dist/utils/helper-22.ts +1 -0
  140. package/src-ts/dist/utils/helper-23.ts +1 -0
  141. package/src-ts/dist/utils/helper-24.ts +1 -0
  142. package/src-ts/dist/utils/helper-25.ts +1 -0
  143. package/src-ts/dist/utils/helper-26.ts +1 -0
  144. package/src-ts/dist/utils/helper-27.ts +1 -0
  145. package/src-ts/dist/utils/helper-28.ts +1 -0
  146. package/src-ts/dist/utils/helper-29.ts +1 -0
  147. package/src-ts/dist/utils/helper-3.ts +1 -0
  148. package/src-ts/dist/utils/helper-30.ts +1 -0
  149. package/src-ts/dist/utils/helper-4.ts +1 -0
  150. package/src-ts/dist/utils/helper-5.ts +1 -0
  151. package/src-ts/dist/utils/helper-6.ts +1 -0
  152. package/src-ts/dist/utils/helper-7.ts +1 -0
  153. package/src-ts/dist/utils/helper-8.ts +1 -0
  154. package/src-ts/dist/utils/helper-9.ts +1 -0
  155. package/src-ts/dist/utils/insta-mqtt-helper.ts +128 -0
  156. package/src-ts/examples/listen-to-messages.ts +86 -0
  157. package/dist/errors/index.d.ts +0 -16
  158. package/dist/errors/index.js.map +0 -1
  159. package/dist/fbns/fbns.client.d.ts +0 -32
  160. package/dist/fbns/fbns.client.events.d.ts +0 -41
  161. package/dist/fbns/fbns.client.events.js.map +0 -1
  162. package/dist/fbns/fbns.client.js.map +0 -1
  163. package/dist/fbns/fbns.device-auth.d.ts +0 -17
  164. package/dist/fbns/fbns.device-auth.js.map +0 -1
  165. package/dist/fbns/fbns.types.d.ts +0 -83
  166. package/dist/fbns/fbns.types.js.map +0 -1
  167. package/dist/fbns/fbns.utilities.d.ts +0 -2
  168. package/dist/fbns/fbns.utilities.js.map +0 -1
  169. package/dist/fbns/index.d.ts +0 -4
  170. package/dist/fbns/index.js.map +0 -1
  171. package/dist/mqtt-shim.d.ts +0 -96
  172. package/dist/mqttot/index.d.ts +0 -4
  173. package/dist/mqttot/index.js.map +0 -1
  174. package/dist/mqttot/mqttot.client.d.ts +0 -39
  175. package/dist/mqttot/mqttot.client.js.map +0 -1
  176. package/dist/mqttot/mqttot.connect.request.packet.d.ts +0 -7
  177. package/dist/mqttot/mqttot.connect.request.packet.js.map +0 -1
  178. package/dist/mqttot/mqttot.connect.response.packet.d.ts +0 -7
  179. package/dist/mqttot/mqttot.connect.response.packet.js.map +0 -1
  180. package/dist/mqttot/mqttot.connection.d.ts +0 -57
  181. package/dist/mqttot/mqttot.connection.js.map +0 -1
  182. package/dist/package.json +0 -59
  183. package/dist/realtime/commands/commands.d.ts +0 -15
  184. package/dist/realtime/commands/commands.js.map +0 -1
  185. package/dist/realtime/commands/direct.commands.d.ts +0 -75
  186. package/dist/realtime/commands/direct.commands.js.map +0 -1
  187. package/dist/realtime/commands/enhanced.direct.commands.js.bak +0 -967
  188. package/dist/realtime/commands/index.d.ts +0 -2
  189. package/dist/realtime/commands/index.js.map +0 -1
  190. package/dist/realtime/messages/app-presence.event.d.ts +0 -9
  191. package/dist/realtime/messages/app-presence.event.js.map +0 -1
  192. package/dist/realtime/messages/index.d.ts +0 -3
  193. package/dist/realtime/messages/index.js.map +0 -1
  194. package/dist/realtime/messages/message-sync.message.d.ts +0 -222
  195. package/dist/realtime/messages/message-sync.message.js.map +0 -1
  196. package/dist/realtime/messages/realtime-sub.direct.data.d.ts +0 -11
  197. package/dist/realtime/messages/realtime-sub.direct.data.js.map +0 -1
  198. package/dist/realtime/messages/thread-update.message.d.ts +0 -68
  199. package/dist/realtime/messages/thread-update.message.js.map +0 -1
  200. package/dist/realtime/mixins/index.d.ts +0 -3
  201. package/dist/realtime/mixins/index.js.map +0 -1
  202. package/dist/realtime/mixins/message-sync.mixin.d.ts +0 -8
  203. package/dist/realtime/mixins/message-sync.mixin.js.map +0 -1
  204. package/dist/realtime/mixins/mixin.d.ts +0 -19
  205. package/dist/realtime/mixins/mixin.js.map +0 -1
  206. package/dist/realtime/mixins/realtime-sub.mixin.d.ts +0 -8
  207. package/dist/realtime/mixins/realtime-sub.mixin.js.map +0 -1
  208. package/dist/realtime/parsers/graphql.parser.d.ts +0 -15
  209. package/dist/realtime/parsers/graphql.parser.js.map +0 -1
  210. package/dist/realtime/parsers/index.d.ts +0 -6
  211. package/dist/realtime/parsers/index.js.map +0 -1
  212. package/dist/realtime/parsers/iris.parser.d.ts +0 -17
  213. package/dist/realtime/parsers/iris.parser.js.map +0 -1
  214. package/dist/realtime/parsers/json.parser.d.ts +0 -6
  215. package/dist/realtime/parsers/json.parser.js.map +0 -1
  216. package/dist/realtime/parsers/parser.d.ts +0 -9
  217. package/dist/realtime/parsers/parser.js.map +0 -1
  218. package/dist/realtime/parsers/region-hint.parser.d.ts +0 -12
  219. package/dist/realtime/parsers/region-hint.parser.js.map +0 -1
  220. package/dist/realtime/parsers/skywalker.parser.d.ts +0 -12
  221. package/dist/realtime/parsers/skywalker.parser.js.map +0 -1
  222. package/dist/realtime/proto/common.proto +0 -38
  223. package/dist/realtime/proto/direct.proto +0 -65
  224. package/dist/realtime/proto/ig-messages.proto +0 -83
  225. package/dist/realtime/proto/iris.proto +0 -188
  226. package/dist/realtime/subscriptions/graphql.subscription.d.ts +0 -47
  227. package/dist/realtime/subscriptions/graphql.subscription.js.map +0 -1
  228. package/dist/realtime/subscriptions/index.d.ts +0 -2
  229. package/dist/realtime/subscriptions/index.js.map +0 -1
  230. package/dist/realtime/subscriptions/skywalker.subscription.d.ts +0 -4
  231. package/dist/realtime/subscriptions/skywalker.subscription.js.map +0 -1
  232. package/dist/thrift/index.d.ts +0 -3
  233. package/dist/thrift/index.js.map +0 -1
  234. package/dist/thrift/thrift.d.ts +0 -59
  235. package/dist/thrift/thrift.js.map +0 -1
  236. package/dist/thrift/thrift.reading.d.ts +0 -41
  237. package/dist/thrift/thrift.reading.js.map +0 -1
  238. package/dist/thrift/thrift.writing.d.ts +0 -44
  239. package/dist/thrift/thrift.writing.js.map +0 -1
  240. /package/{dist → dist-ts/dist}/realtime/protocols/proto-definitions.js +0 -0
  241. /package/{dist → dist-ts/dist}/utils/helper-1.js +0 -0
  242. /package/{dist → dist-ts/dist}/utils/helper-10.js +0 -0
  243. /package/{dist → dist-ts/dist}/utils/helper-11.js +0 -0
  244. /package/{dist → dist-ts/dist}/utils/helper-12.js +0 -0
  245. /package/{dist → dist-ts/dist}/utils/helper-13.js +0 -0
  246. /package/{dist → dist-ts/dist}/utils/helper-14.js +0 -0
  247. /package/{dist → dist-ts/dist}/utils/helper-15.js +0 -0
  248. /package/{dist → dist-ts/dist}/utils/helper-16.js +0 -0
  249. /package/{dist → dist-ts/dist}/utils/helper-17.js +0 -0
  250. /package/{dist → dist-ts/dist}/utils/helper-18.js +0 -0
  251. /package/{dist → dist-ts/dist}/utils/helper-19.js +0 -0
  252. /package/{dist → dist-ts/dist}/utils/helper-2.js +0 -0
  253. /package/{dist → dist-ts/dist}/utils/helper-20.js +0 -0
  254. /package/{dist → dist-ts/dist}/utils/helper-21.js +0 -0
  255. /package/{dist → dist-ts/dist}/utils/helper-22.js +0 -0
  256. /package/{dist → dist-ts/dist}/utils/helper-23.js +0 -0
  257. /package/{dist → dist-ts/dist}/utils/helper-24.js +0 -0
  258. /package/{dist → dist-ts/dist}/utils/helper-25.js +0 -0
  259. /package/{dist → dist-ts/dist}/utils/helper-26.js +0 -0
  260. /package/{dist → dist-ts/dist}/utils/helper-27.js +0 -0
  261. /package/{dist → dist-ts/dist}/utils/helper-28.js +0 -0
  262. /package/{dist → dist-ts/dist}/utils/helper-29.js +0 -0
  263. /package/{dist → dist-ts/dist}/utils/helper-3.js +0 -0
  264. /package/{dist → dist-ts/dist}/utils/helper-30.js +0 -0
  265. /package/{dist → dist-ts/dist}/utils/helper-4.js +0 -0
  266. /package/{dist → dist-ts/dist}/utils/helper-5.js +0 -0
  267. /package/{dist → dist-ts/dist}/utils/helper-6.js +0 -0
  268. /package/{dist → dist-ts/dist}/utils/helper-7.js +0 -0
  269. /package/{dist → dist-ts/dist}/utils/helper-8.js +0 -0
  270. /package/{dist → dist-ts/dist}/utils/helper-9.js +0 -0
  271. /package/{dist → dist-ts/dist}/utils/insta-mqtt-helper.js +0 -0
  272. /package/{dist/constants/constants.js → src-ts/dist/constants/constants.ts} +0 -0
  273. /package/{dist/constants/index.js → src-ts/dist/constants/index.ts} +0 -0
  274. /package/{dist/core/client.js → src-ts/dist/core/client.ts} +0 -0
  275. /package/{dist/core/nav-chain.js → src-ts/dist/core/nav-chain.ts} +0 -0
  276. /package/{dist/core/repository.js → src-ts/dist/core/repository.ts} +0 -0
  277. /package/{dist/core/request.js → src-ts/dist/core/request.ts} +0 -0
  278. /package/{dist/core/state.js → src-ts/dist/core/state.ts} +0 -0
  279. /package/{dist/core/utils.js → src-ts/dist/core/utils.ts} +0 -0
  280. /package/{dist/downloadMedia.js → src-ts/dist/downloadMedia.ts} +0 -0
  281. /package/{dist/errors/index.js → src-ts/dist/errors/index.ts} +0 -0
  282. /package/{dist/extend.js → src-ts/dist/extend.ts} +0 -0
  283. /package/{dist/fbns/fbns.client.events.js → src-ts/dist/fbns/fbns.client.events.ts} +0 -0
  284. /package/{dist/fbns/fbns.client.js → src-ts/dist/fbns/fbns.client.ts} +0 -0
  285. /package/{dist/fbns/fbns.device-auth.js → src-ts/dist/fbns/fbns.device-auth.ts} +0 -0
  286. /package/{dist/fbns/fbns.types.js → src-ts/dist/fbns/fbns.types.ts} +0 -0
  287. /package/{dist/fbns/fbns.utilities.js → src-ts/dist/fbns/fbns.utilities.ts} +0 -0
  288. /package/{dist/fbns/index.js → src-ts/dist/fbns/index.ts} +0 -0
  289. /package/{dist/index.js → src-ts/dist/index.ts} +0 -0
  290. /package/{dist/mqtt-shim.js → src-ts/dist/mqtt-shim.ts} +0 -0
  291. /package/{dist/mqttot/index.js → src-ts/dist/mqttot/index.ts} +0 -0
  292. /package/{dist/mqttot/mqttot.client.js → src-ts/dist/mqttot/mqttot.client.ts} +0 -0
  293. /package/{dist/mqttot/mqttot.connect.request.packet.js → src-ts/dist/mqttot/mqttot.connect.request.packet.ts} +0 -0
  294. /package/{dist/mqttot/mqttot.connect.response.packet.js → src-ts/dist/mqttot/mqttot.connect.response.packet.ts} +0 -0
  295. /package/{dist/mqttot/mqttot.connection.js → src-ts/dist/mqttot/mqttot.connection.ts} +0 -0
  296. /package/{dist/realtime/commands/commands.js → src-ts/dist/realtime/commands/commands.ts} +0 -0
  297. /package/{dist/realtime/commands/direct.commands.js → src-ts/dist/realtime/commands/direct.commands.ts} +0 -0
  298. /package/{dist/realtime/commands/enhanced.direct.commands.js → src-ts/dist/realtime/commands/enhanced.direct.commands.ts} +0 -0
  299. /package/{dist/realtime/commands/index.js → src-ts/dist/realtime/commands/index.ts} +0 -0
  300. /package/{dist/realtime/delta-sync.manager.js → src-ts/dist/realtime/delta-sync.manager.ts} +0 -0
  301. /package/{dist/realtime/features/dm-sender.js → src-ts/dist/realtime/features/dm-sender.ts} +0 -0
  302. /package/{dist/realtime/features/error-handler.js → src-ts/dist/realtime/features/error-handler.ts} +0 -0
  303. /package/{dist/realtime/features/gap-handler.js → src-ts/dist/realtime/features/gap-handler.ts} +0 -0
  304. /package/{dist/realtime/features/persistent-logger.js → src-ts/dist/realtime/features/persistent-logger.ts} +0 -0
  305. /package/{dist/realtime/features/presence.manager.js → src-ts/dist/realtime/features/presence.manager.ts} +0 -0
  306. /package/{dist/realtime/features/session-health-monitor.js → src-ts/dist/realtime/features/session-health-monitor.ts} +0 -0
  307. /package/{dist/realtime/index.js → src-ts/dist/realtime/index.ts} +0 -0
  308. /package/{dist/realtime/messages/app-presence.event.js → src-ts/dist/realtime/messages/app-presence.event.ts} +0 -0
  309. /package/{dist/realtime/messages/index.js → src-ts/dist/realtime/messages/index.ts} +0 -0
  310. /package/{dist/realtime/messages/message-sync.message.js → src-ts/dist/realtime/messages/message-sync.message.ts} +0 -0
  311. /package/{dist/realtime/messages/realtime-sub.direct.data.js → src-ts/dist/realtime/messages/realtime-sub.direct.data.ts} +0 -0
  312. /package/{dist/realtime/messages/thread-update.message.js → src-ts/dist/realtime/messages/thread-update.message.ts} +0 -0
  313. /package/{dist/realtime/mixins/index.js → src-ts/dist/realtime/mixins/index.ts} +0 -0
  314. /package/{dist/realtime/mixins/message-sync.mixin.js → src-ts/dist/realtime/mixins/message-sync.mixin.ts} +0 -0
  315. /package/{dist/realtime/mixins/mixin.js → src-ts/dist/realtime/mixins/mixin.ts} +0 -0
  316. /package/{dist/realtime/mixins/presence-typing.mixin.js → src-ts/dist/realtime/mixins/presence-typing.mixin.ts} +0 -0
  317. /package/{dist/realtime/mixins/realtime-sub.mixin.js → src-ts/dist/realtime/mixins/realtime-sub.mixin.ts} +0 -0
  318. /package/{dist/realtime/parsers/graphql-parser.js → src-ts/dist/realtime/parsers/graphql-parser.ts} +0 -0
  319. /package/{dist/realtime/parsers/graphql.parser.js → src-ts/dist/realtime/parsers/graphql.parser.ts} +0 -0
  320. /package/{dist/realtime/parsers/index.js → src-ts/dist/realtime/parsers/index.ts} +0 -0
  321. /package/{dist/realtime/parsers/iris-parser.js → src-ts/dist/realtime/parsers/iris-parser.ts} +0 -0
  322. /package/{dist/realtime/parsers/iris.parser.js → src-ts/dist/realtime/parsers/iris.parser.ts} +0 -0
  323. /package/{dist/realtime/parsers/json-parser.js → src-ts/dist/realtime/parsers/json-parser.ts} +0 -0
  324. /package/{dist/realtime/parsers/json.parser.js → src-ts/dist/realtime/parsers/json.parser.ts} +0 -0
  325. /package/{dist/realtime/parsers/parser.js → src-ts/dist/realtime/parsers/parser.ts} +0 -0
  326. /package/{dist/realtime/parsers/region-hint-parser.js → src-ts/dist/realtime/parsers/region-hint-parser.ts} +0 -0
  327. /package/{dist/realtime/parsers/region-hint.parser.js → src-ts/dist/realtime/parsers/region-hint.parser.ts} +0 -0
  328. /package/{dist/realtime/parsers/skywalker-parser.js → src-ts/dist/realtime/parsers/skywalker-parser.ts} +0 -0
  329. /package/{dist/realtime/parsers/skywalker.parser.js → src-ts/dist/realtime/parsers/skywalker.parser.ts} +0 -0
  330. /package/{dist/realtime/parsers-advanced.js → src-ts/dist/realtime/parsers-advanced.ts} +0 -0
  331. /package/{dist/realtime/proto-parser.js → src-ts/dist/realtime/proto-parser.ts} +0 -0
  332. /package/{dist/realtime/protocols/iris.handshake.js → src-ts/dist/realtime/protocols/iris.handshake.ts} +0 -0
  333. /package/{dist/realtime/protocols/skywalker.protocol.js → src-ts/dist/realtime/protocols/skywalker.protocol.ts} +0 -0
  334. /package/{dist/realtime/realtime.client.events.js → src-ts/dist/realtime/realtime.client.events.ts} +0 -0
  335. /package/{dist/realtime/realtime.client.js → src-ts/dist/realtime/realtime.client.ts} +0 -0
  336. /package/{dist/realtime/realtime.service.js → src-ts/dist/realtime/realtime.service.ts} +0 -0
  337. /package/{dist/realtime/reconnect.manager.js → src-ts/dist/realtime/reconnect.manager.ts} +0 -0
  338. /package/{dist/realtime/session.manager.js → src-ts/dist/realtime/session.manager.ts} +0 -0
  339. /package/{dist/realtime/subscriptions/graphql.subscription.js → src-ts/dist/realtime/subscriptions/graphql.subscription.ts} +0 -0
  340. /package/{dist/realtime/subscriptions/index.js → src-ts/dist/realtime/subscriptions/index.ts} +0 -0
  341. /package/{dist/realtime/subscriptions/skywalker.subscription.js → src-ts/dist/realtime/subscriptions/skywalker.subscription.ts} +0 -0
  342. /package/{dist/realtime/topic-map.js → src-ts/dist/realtime/topic-map.ts} +0 -0
  343. /package/{dist/realtime/topic.js → src-ts/dist/realtime/topic.ts} +0 -0
  344. /package/{dist/repositories/account.repository.js → src-ts/dist/repositories/account.repository.ts} +0 -0
  345. /package/{dist/repositories/bloks.repository.js → src-ts/dist/repositories/bloks.repository.ts} +0 -0
  346. /package/{dist/repositories/captcha.repository.js → src-ts/dist/repositories/captcha.repository.ts} +0 -0
  347. /package/{dist/repositories/challenge.repository.js → src-ts/dist/repositories/challenge.repository.ts} +0 -0
  348. /package/{dist/repositories/clip.repository.js → src-ts/dist/repositories/clip.repository.ts} +0 -0
  349. /package/{dist/repositories/close-friends.repository.js → src-ts/dist/repositories/close-friends.repository.ts} +0 -0
  350. /package/{dist/repositories/collection.repository.js → src-ts/dist/repositories/collection.repository.ts} +0 -0
  351. /package/{dist/repositories/direct-thread.repository.js → src-ts/dist/repositories/direct-thread.repository.ts} +0 -0
  352. /package/{dist/repositories/direct.repository.js → src-ts/dist/repositories/direct.repository.ts} +0 -0
  353. /package/{dist/repositories/explore.repository.js → src-ts/dist/repositories/explore.repository.ts} +0 -0
  354. /package/{dist/repositories/fbsearch.repository.js → src-ts/dist/repositories/fbsearch.repository.ts} +0 -0
  355. /package/{dist/repositories/feed.repository.js → src-ts/dist/repositories/feed.repository.ts} +0 -0
  356. /package/{dist/repositories/friendship.repository.js → src-ts/dist/repositories/friendship.repository.ts} +0 -0
  357. /package/{dist/repositories/fundraiser.repository.js → src-ts/dist/repositories/fundraiser.repository.ts} +0 -0
  358. /package/{dist/repositories/hashtag.repository.js → src-ts/dist/repositories/hashtag.repository.ts} +0 -0
  359. /package/{dist/repositories/highlights.repository.js → src-ts/dist/repositories/highlights.repository.ts} +0 -0
  360. /package/{dist/repositories/insights.repository.js → src-ts/dist/repositories/insights.repository.ts} +0 -0
  361. /package/{dist/repositories/location.repository.js → src-ts/dist/repositories/location.repository.ts} +0 -0
  362. /package/{dist/repositories/media.repository.js → src-ts/dist/repositories/media.repository.ts} +0 -0
  363. /package/{dist/repositories/multiple-accounts.repository.js → src-ts/dist/repositories/multiple-accounts.repository.ts} +0 -0
  364. /package/{dist/repositories/news.repository.js → src-ts/dist/repositories/news.repository.ts} +0 -0
  365. /package/{dist/repositories/note.repository.js → src-ts/dist/repositories/note.repository.ts} +0 -0
  366. /package/{dist/repositories/notification.repository.js → src-ts/dist/repositories/notification.repository.ts} +0 -0
  367. /package/{dist/repositories/share.repository.js → src-ts/dist/repositories/share.repository.ts} +0 -0
  368. /package/{dist/repositories/signup.repository.js → src-ts/dist/repositories/signup.repository.ts} +0 -0
  369. /package/{dist/repositories/story.repository.js → src-ts/dist/repositories/story.repository.ts} +0 -0
  370. /package/{dist/repositories/timeline.repository.js → src-ts/dist/repositories/timeline.repository.ts} +0 -0
  371. /package/{dist/repositories/totp.repository.js → src-ts/dist/repositories/totp.repository.ts} +0 -0
  372. /package/{dist/repositories/track.repository.js → src-ts/dist/repositories/track.repository.ts} +0 -0
  373. /package/{dist/repositories/upload.repository.js → src-ts/dist/repositories/upload.repository.ts} +0 -0
  374. /package/{dist/repositories/user.repository.js → src-ts/dist/repositories/user.repository.ts} +0 -0
  375. /package/{dist/sendmedia/index.js → src-ts/dist/sendmedia/index.ts} +0 -0
  376. /package/{dist/sendmedia/sendFile.js → src-ts/dist/sendmedia/sendFile.ts} +0 -0
  377. /package/{dist/sendmedia/sendPhoto.js → src-ts/dist/sendmedia/sendPhoto.ts} +0 -0
  378. /package/{dist/sendmedia/sendRavenPhoto.js → src-ts/dist/sendmedia/sendRavenPhoto.ts} +0 -0
  379. /package/{dist/sendmedia/sendRavenVideo.js → src-ts/dist/sendmedia/sendRavenVideo.ts} +0 -0
  380. /package/{dist/sendmedia/uploadPhoto.js → src-ts/dist/sendmedia/uploadPhoto.ts} +0 -0
  381. /package/{dist/sendmedia/uploadfFile.js → src-ts/dist/sendmedia/uploadfFile.ts} +0 -0
  382. /package/{dist/services/live.service.js → src-ts/dist/services/live.service.ts} +0 -0
  383. /package/{dist/services/search.service.js → src-ts/dist/services/search.service.ts} +0 -0
  384. /package/{dist/shared/index.js → src-ts/dist/shared/index.ts} +0 -0
  385. /package/{dist/shared/shared.js → src-ts/dist/shared/shared.ts} +0 -0
  386. /package/{dist/thrift/index.js → src-ts/dist/thrift/index.ts} +0 -0
  387. /package/{dist/thrift/thrift.reading.js → src-ts/dist/thrift/thrift.reading.ts} +0 -0
  388. /package/{dist/thrift/thrift.js → src-ts/dist/thrift/thrift.ts} +0 -0
  389. /package/{dist/thrift/thrift.writing.js → src-ts/dist/thrift/thrift.writing.ts} +0 -0
  390. /package/{dist/types/index.js → src-ts/dist/types/index.ts} +0 -0
  391. /package/{dist/useMultiFileAuthState.js → src-ts/dist/useMultiFileAuthState.ts} +0 -0
  392. /package/{dist/utils/index.js → src-ts/dist/utils/index.ts} +0 -0
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function (o, m, k, k2) {
3
+ if (k2 === undefined)
4
+ k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function () { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function (o, m, k, k2) {
11
+ if (k2 === undefined)
12
+ k2 = k;
13
+ o[k2] = m[k];
14
+ }));
15
+ var __exportStar = (this && this.__exportStar) || function (m, exports) {
16
+ for (var p in m)
17
+ if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p))
18
+ __createBinding(exports, m, p);
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ __exportStar(require("./mixin"), exports);
22
+ __exportStar(require("./message-sync.mixin"), exports);
23
+ __exportStar(require("./realtime-sub.mixin"), exports);
@@ -0,0 +1,585 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MessageSyncMixin = void 0;
4
+ const mixin_1 = require("./mixin");
5
+ const constants_1 = require("../../constants");
6
+ const shared_1 = require("../../shared");
7
+ const mqtts_1 = require("mqtts");
8
+ /**
9
+ * MessageSyncMixin - patched for 2026 (robust parsing + safe username fetch + tolerant timestamp handling)
10
+ *
11
+ * Changes applied:
12
+ * - tolerant parsing for e.value (string / object / already-parsed)
13
+ * - support for several path shapes when extracting thread id
14
+ * - safer timestamp parsing (accepts seconds, milliseconds, microseconds, nanoseconds)
15
+ * - username fetch uses a pending map + small backoff to reduce rush/rate-limit risk
16
+ * - defensive try/catch around JSON.parse and all external calls
17
+ * - keeps original API: apply(client) registers post-connect hook and emits same events
18
+ *
19
+ * Additional change requested:
20
+ * - set message status to 'received' for incoming messages and 'sent' for messages authored by the logged-in account,
21
+ * instead of the previous 'good'.
22
+ *
23
+ * Note: No rate-limiting code is included.
24
+ */
25
+ class MessageSyncMixin extends mixin_1.Mixin {
26
+ constructor() {
27
+ super();
28
+ this.userCache = new Map();
29
+ this.pendingUserFetches = new Map();
30
+ }
31
+ apply(client) {
32
+ console.log(`\n[MESSAGE_SYNC MIXIN] Applying mixin...`);
33
+ (0, mixin_1.hook)(client, 'connect', {
34
+ post: async () => {
35
+ console.log(`[MESSAGE_SYNC] Post-connect hook called`);
36
+ let retries = 0;
37
+ while (!client.mqtt && retries < 50) {
38
+ await new Promise(r => setTimeout(r, 100));
39
+ retries++;
40
+ }
41
+ if (!client.mqtt) {
42
+ throw new mqtts_1.IllegalStateError('No mqtt client created after retries');
43
+ }
44
+ console.log(`[MESSAGE_SYNC] MQTT ready, registering listen() on topic 146 (MESSAGE_SYNC)`);
45
+ if (client.mqtt.listen) {
46
+ console.log(`[MESSAGE_SYNC] mqtt.listen() method found, registering callback...`);
47
+ client.mqtt.listen({
48
+ topic: constants_1.Topics.MESSAGE_SYNC.id,
49
+ transformer: async ({ payload }) => {
50
+ try {
51
+ const unzipped = await (0, shared_1.tryUnzipAsync)(payload);
52
+ const parsed = constants_1.Topics.MESSAGE_SYNC.parser
53
+ .parseMessage(constants_1.Topics.MESSAGE_SYNC, unzipped)
54
+ .map(msg => msg.data);
55
+ return parsed;
56
+ }
57
+ catch (err) {
58
+ // If transformer fails, return empty array so handler is tolerant
59
+ console.warn('[MESSAGE_SYNC] transformer parse failed:', (err === null || err === void 0 ? void 0 : err.message) || err);
60
+ return [];
61
+ }
62
+ },
63
+ }, data => {
64
+ this.handleMessageSync(client, data);
65
+ });
66
+ }
67
+ else {
68
+ console.log(`[MESSAGE_SYNC] mqtt.listen() NOT FOUND - using fallback 'receive' event`);
69
+ client.on('receive', (topic, messages) => {
70
+ try {
71
+ if (topic.id === constants_1.Topics.MESSAGE_SYNC.id) {
72
+ const data = messages.map(m => m.data);
73
+ this.handleMessageSync(client, data);
74
+ }
75
+ }
76
+ catch (err) {
77
+ console.warn('[MESSAGE_SYNC] receive fallback handler error:', (err === null || err === void 0 ? void 0 : err.message) || err);
78
+ }
79
+ });
80
+ }
81
+ },
82
+ });
83
+ }
84
+ async getUsernameFromId(client, userId) {
85
+ if (!userId)
86
+ return null;
87
+ const userIdStr = String(userId);
88
+ if (this.userCache.has(userIdStr)) {
89
+ return this.userCache.get(userIdStr);
90
+ }
91
+ if (this.pendingUserFetches.has(userIdStr)) {
92
+ try {
93
+ return await this.pendingUserFetches.get(userIdStr);
94
+ }
95
+ catch (e) {
96
+ // if pending fetch failed, continue to fresh attempt
97
+ }
98
+ }
99
+ const fetchPromise = (async () => {
100
+ try {
101
+ // small backoff to avoid immediate burst of parallel requests
102
+ await new Promise(r => setTimeout(r, 120));
103
+ if (client.ig && client.ig.user && client.ig.user.info) {
104
+ try {
105
+ const userInfo = await client.ig.user.info(userIdStr);
106
+ if (userInfo && userInfo.username) {
107
+ this.userCache.set(userIdStr, userInfo.username);
108
+ return userInfo.username;
109
+ }
110
+ }
111
+ catch (innerErr) {
112
+ // rate-limited or not found - swallow
113
+ }
114
+ }
115
+ }
116
+ catch (err) {
117
+ // Silently fail - will use ID instead
118
+ }
119
+ return null;
120
+ })();
121
+ this.pendingUserFetches.set(userIdStr, fetchPromise);
122
+ const result = await fetchPromise;
123
+ this.pendingUserFetches.delete(userIdStr);
124
+ return result;
125
+ }
126
+ extractMessageContent(msgValue, itemType) {
127
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
128
+ let content = '';
129
+ let mediaInfo = '';
130
+ try {
131
+ switch (itemType) {
132
+ case 'text':
133
+ content = msgValue.text || msgValue.body || '';
134
+ break;
135
+ case 'media':
136
+ case 'raven_media':
137
+ content = '[PHOTO/VIDEO]';
138
+ if (msgValue.media) {
139
+ const media = msgValue.media;
140
+ if (media.image_versions2) {
141
+ content = '[PHOTO]';
142
+ mediaInfo = ` URL: ${((_c = (_b = (_a = media.image_versions2) === null || _a === void 0 ? void 0 : _a.candidates) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.url) || 'N/A'}`;
143
+ }
144
+ else if (media.video_versions) {
145
+ content = '[VIDEO]';
146
+ mediaInfo = ` Duration: ${media.video_duration || 'N/A'}s`;
147
+ }
148
+ }
149
+ if (msgValue.visual_media) {
150
+ content = '[DISAPPEARING MEDIA]';
151
+ }
152
+ break;
153
+ case 'voice_media':
154
+ content = '[VOICE MESSAGE]';
155
+ if ((_e = (_d = msgValue.voice_media) === null || _d === void 0 ? void 0 : _d.media) === null || _e === void 0 ? void 0 : _e.audio) {
156
+ const duration = msgValue.voice_media.media.audio.duration || 0;
157
+ content = `[VOICE MESSAGE] Duration: ${duration}ms`;
158
+ }
159
+ break;
160
+ case 'animated_media':
161
+ content = '[GIF]';
162
+ if ((_h = (_g = (_f = msgValue.animated_media) === null || _f === void 0 ? void 0 : _f.images) === null || _g === void 0 ? void 0 : _g.fixed_height) === null || _h === void 0 ? void 0 : _h.url) {
163
+ mediaInfo = ` URL: ${msgValue.animated_media.images.fixed_height.url}`;
164
+ }
165
+ break;
166
+ case 'media_share':
167
+ content = '[SHARED POST]';
168
+ if (msgValue.media_share) {
169
+ const share = msgValue.media_share;
170
+ content = `[SHARED POST] From: @${((_j = share.user) === null || _j === void 0 ? void 0 : _j.username) || 'unknown'}`;
171
+ if ((_k = share.caption) === null || _k === void 0 ? void 0 : _k.text) {
172
+ content += ` Caption: "${String(share.caption.text).substring(0, 50)}..."`;
173
+ }
174
+ }
175
+ break;
176
+ case 'reel_share':
177
+ content = '[SHARED REEL]';
178
+ if (msgValue.reel_share) {
179
+ const reel = msgValue.reel_share;
180
+ content = `[SHARED REEL] From: @${((_m = (_l = reel.media) === null || _l === void 0 ? void 0 : _l.user) === null || _m === void 0 ? void 0 : _m.username) || 'unknown'}`;
181
+ if (reel.text) {
182
+ content += ` Text: "${reel.text}"`;
183
+ }
184
+ }
185
+ break;
186
+ case 'story_share':
187
+ content = '[SHARED STORY]';
188
+ if (msgValue.story_share) {
189
+ const story = msgValue.story_share;
190
+ content = `[SHARED STORY] From: @${((_p = (_o = story.media) === null || _o === void 0 ? void 0 : _o.user) === null || _p === void 0 ? void 0 : _p.username) || 'unknown'}`;
191
+ if (story.message) {
192
+ content += ` Message: "${story.message}"`;
193
+ }
194
+ }
195
+ break;
196
+ case 'felix_share':
197
+ content = '[SHARED IGTV/VIDEO]';
198
+ if ((_q = msgValue.felix_share) === null || _q === void 0 ? void 0 : _q.video) {
199
+ content = `[SHARED IGTV] Title: "${msgValue.felix_share.video.title || 'N/A'}"`;
200
+ }
201
+ break;
202
+ case 'clip':
203
+ content = '[SHARED CLIP]';
204
+ if ((_r = msgValue.clip) === null || _r === void 0 ? void 0 : _r.clip) {
205
+ content = `[SHARED CLIP] From: @${((_s = msgValue.clip.clip.user) === null || _s === void 0 ? void 0 : _s.username) || 'unknown'}`;
206
+ }
207
+ break;
208
+ case 'profile':
209
+ content = '[SHARED PROFILE]';
210
+ if (msgValue.profile) {
211
+ content = `[SHARED PROFILE] @${msgValue.profile.username || 'unknown'}`;
212
+ }
213
+ break;
214
+ case 'location':
215
+ content = '[LOCATION]';
216
+ if (msgValue.location) {
217
+ content = `[LOCATION] ${msgValue.location.name || msgValue.location.address || 'Unknown location'}`;
218
+ }
219
+ break;
220
+ case 'hashtag':
221
+ content = '[HASHTAG]';
222
+ if (msgValue.hashtag) {
223
+ content = `[HASHTAG] #${msgValue.hashtag.name || 'unknown'}`;
224
+ }
225
+ break;
226
+ case 'like':
227
+ content = '[LIKE]';
228
+ break;
229
+ case 'link':
230
+ content = '[LINK]';
231
+ if (msgValue.link) {
232
+ content = `[LINK] ${msgValue.link.text || msgValue.link.link_url || 'N/A'}`;
233
+ }
234
+ break;
235
+ case 'action_log':
236
+ content = '[ACTION]';
237
+ if (msgValue.action_log) {
238
+ content = `[ACTION] ${msgValue.action_log.description || 'N/A'}`;
239
+ }
240
+ break;
241
+ case 'placeholder':
242
+ content = '[PLACEHOLDER]';
243
+ if ((_t = msgValue.placeholder) === null || _t === void 0 ? void 0 : _t.message) {
244
+ content = `[PLACEHOLDER] ${msgValue.placeholder.message}`;
245
+ }
246
+ break;
247
+ case 'xma':
248
+ case 'xma_media_share':
249
+ content = '[XMA SHARE]';
250
+ if (msgValue.xma_link_url) {
251
+ content = `[XMA SHARE] ${msgValue.xma_link_url}`;
252
+ }
253
+ break;
254
+ case 'video_call_event':
255
+ content = '[VIDEO CALL EVENT]';
256
+ if (msgValue.video_call_event) {
257
+ content = `[VIDEO CALL] ${msgValue.video_call_event.action || 'event'}`;
258
+ }
259
+ break;
260
+ default:
261
+ if (msgValue && (msgValue.text || msgValue.body)) {
262
+ content = msgValue.text || msgValue.body;
263
+ }
264
+ else {
265
+ content = `[${(itemType || 'UNKNOWN').toUpperCase()}]`;
266
+ }
267
+ }
268
+ }
269
+ catch (e) {
270
+ // defensive fallback
271
+ try {
272
+ if (msgValue && (msgValue.text || msgValue.body)) {
273
+ content = msgValue.text || msgValue.body;
274
+ }
275
+ else {
276
+ content = `[${(itemType || 'UNKNOWN').toUpperCase()}]`;
277
+ }
278
+ }
279
+ catch (e2) {
280
+ content = `[${(itemType || 'UNKNOWN').toUpperCase()}]`;
281
+ }
282
+ }
283
+ return content + mediaInfo;
284
+ }
285
+ formatMessageForConsole(msgData) {
286
+ const separator = '----------------------------------------';
287
+ // robust timestamp formatting into readable date+time in Europe/Bucharest
288
+ let ts = 'N/A';
289
+ try {
290
+ const parsed = this.parseTimestamp(msgData.timestamp);
291
+ if (parsed) {
292
+ const d = new Date(parsed);
293
+ ts = d.toLocaleString('ro-RO', {
294
+ year: 'numeric',
295
+ month: '2-digit',
296
+ day: '2-digit',
297
+ hour: '2-digit',
298
+ minute: '2-digit',
299
+ second: '2-digit',
300
+ hour12: false,
301
+ timeZone: 'Europe/Bucharest'
302
+ });
303
+ }
304
+ }
305
+ catch (e) {
306
+ ts = 'N/A';
307
+ }
308
+ const lines = [
309
+ '',
310
+ separator,
311
+ '[NEW MESSAGE]',
312
+ separator,
313
+ `Username: ${msgData.username || 'unknown'}`,
314
+ `ID: ${msgData.userId || 'unknown'}`,
315
+ `Text: ${msgData.text || 'N/A'}`,
316
+ `Type: ${msgData.itemType || 'text'}`,
317
+ `Thread: ${msgData.threadId || 'unknown'}`,
318
+ `Message ID: ${msgData.messageId || 'unknown'}`,
319
+ `Timestamp: ${ts}`,
320
+ `Status: ${msgData.status || 'unknown'}`,
321
+ separator,
322
+ ''
323
+ ];
324
+ return lines.join('\n');
325
+ }
326
+ /**
327
+ * parseTimestamp
328
+ * - accepts numeric strings or numbers in seconds, milliseconds, microseconds, nanoseconds
329
+ * - normalizes to milliseconds
330
+ * - sanity-checks to avoid absurd future dates; returns Date.now() fallback if out of range
331
+ */
332
+ parseTimestamp(ts) {
333
+ try {
334
+ if (ts === undefined || ts === null)
335
+ return null;
336
+ // if object with .ms or similar, try common fields
337
+ if (typeof ts === 'object') {
338
+ if (ts.ms)
339
+ return Number(ts.ms);
340
+ if (ts.seconds)
341
+ return Number(ts.seconds) * 1000;
342
+ if (ts.nano)
343
+ return Math.floor(Number(ts.nano) / 1e6);
344
+ // fallback to toString
345
+ ts = String(ts);
346
+ }
347
+ let n = Number(ts);
348
+ if (!Number.isFinite(n))
349
+ return null;
350
+ // Heuristics:
351
+ // nanoseconds ~ 1e18+, microseconds ~ 1e15+, milliseconds ~ 1e12, seconds ~ 1e9
352
+ if (n > 1e17) {
353
+ // nanoseconds -> ms
354
+ n = Math.floor(n / 1e6);
355
+ }
356
+ else if (n > 1e14) {
357
+ // microseconds -> ms
358
+ n = Math.floor(n / 1e3);
359
+ }
360
+ else if (n > 1e12) {
361
+ // likely already ms (leave)
362
+ n = Math.floor(n);
363
+ }
364
+ else if (n > 1e9) {
365
+ // seconds -> ms
366
+ n = Math.floor(n * 1000);
367
+ }
368
+ else if (n > 1e6) {
369
+ // ambiguous (older formats) -> treat as seconds -> ms
370
+ n = Math.floor(n * 1000);
371
+ }
372
+ else {
373
+ // too small -> invalid
374
+ return null;
375
+ }
376
+ // sanity range: allow roughly 2010-2036 (ms)
377
+ const min = 1262304000000; // 2010-01-01
378
+ const max = 2114380800000; // 2037-01-01 (safe future upper bound)
379
+ if (!Number.isFinite(n) || n < min || n > max) {
380
+ // fallback to now to avoid huge future years displayed
381
+ return Date.now();
382
+ }
383
+ return n;
384
+ }
385
+ catch (e) {
386
+ return null;
387
+ }
388
+ }
389
+ async handleMessageSync(client, syncData) {
390
+ var _a, _b, _c, _d;
391
+ if (!syncData || !Array.isArray(syncData)) {
392
+ console.log(`[MESSAGE_SYNC] No sync data received`);
393
+ return;
394
+ }
395
+ for (const element of syncData) {
396
+ try {
397
+ const data = element.data;
398
+ if (!data) {
399
+ // fallback: emit iris with original element
400
+ client.emit('iris', element);
401
+ continue;
402
+ }
403
+ // ensure element.data removed in downstream parsed message (keeps original behavior)
404
+ delete element.data;
405
+ for (const e of data) {
406
+ try {
407
+ // tolerant handling: e.value may be string, object, null, or already parsed
408
+ let parsedValue = {};
409
+ if (e.value === undefined || e.value === null) {
410
+ parsedValue = {};
411
+ }
412
+ else if (typeof e.value === 'string') {
413
+ const str = e.value.trim();
414
+ if (str.length === 0) {
415
+ parsedValue = {};
416
+ }
417
+ else {
418
+ try {
419
+ parsedValue = JSON.parse(str);
420
+ }
421
+ catch (errJson) {
422
+ // If not JSON, attempt basic fallback (sometimes server sends plain key=value or quoted)
423
+ try {
424
+ // try to safe-evaluate limited forms like a bare object without quotes (rare)
425
+ parsedValue = {};
426
+ }
427
+ catch (err2) {
428
+ parsedValue = {};
429
+ }
430
+ }
431
+ }
432
+ }
433
+ else if (typeof e.value === 'object') {
434
+ parsedValue = e.value;
435
+ }
436
+ else {
437
+ parsedValue = {};
438
+ }
439
+ // Sometimes the message payload is nested under 'message' or similar
440
+ const msgValue = parsedValue.message || parsedValue.data || parsedValue || {};
441
+ if (!e.path) {
442
+ // no path means iris-like delta; merge element + e
443
+ client.emit('iris', { ...element, ...e, value: msgValue });
444
+ continue;
445
+ }
446
+ // normalize path check for thread messages
447
+ if ((e.path && e.path.startsWith('/direct_v2/threads')) ||
448
+ (e.path && e.path.startsWith('/direct_v2/inbox/threads')) ||
449
+ (e.path && e.path.indexOf('/direct_v2/threads/') !== -1)) {
450
+ if (msgValue && (msgValue.item_type || msgValue.itemType || msgValue.type || msgValue.msg_type)) {
451
+ // determine item type as robustly as possible
452
+ const itemType = msgValue.item_type || msgValue.itemType || msgValue.type || msgValue.msg_type || 'text';
453
+ // thread id extraction
454
+ const threadId = MessageSyncMixin.getThreadIdFromPath(e.path);
455
+ // user id resolution: try many possible fields
456
+ const userId = msgValue.user_id || msgValue.from_user_id || msgValue.sender_id || msgValue.userId || msgValue.senderId || null;
457
+ // username resolution: prefer embedded username, otherwise fetch
458
+ let username = msgValue.username || msgValue.from_username || null;
459
+ if (!username && userId) {
460
+ try {
461
+ username = await this.getUsernameFromId(client, userId);
462
+ }
463
+ catch (ux) {
464
+ username = null;
465
+ }
466
+ }
467
+ if (!username) {
468
+ username = `user_${userId || 'unknown'}`;
469
+ }
470
+ const textContent = this.extractMessageContent(msgValue, itemType);
471
+ const messageId = msgValue.item_id || msgValue.id || msgValue.client_context || msgValue.client_context_id || msgValue.message_id || msgValue.messageId || null;
472
+ const timestamp = msgValue.timestamp || msgValue.ts || msgValue.client_time || null;
473
+ // determine status based on whether message author is the logged-in account
474
+ let status = 'received';
475
+ try {
476
+ const ownId = ((_b = (_a = client === null || client === void 0 ? void 0 : client.ig) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.cookieUserId) || ((_d = (_c = client === null || client === void 0 ? void 0 : client.ig) === null || _c === void 0 ? void 0 : _c.state) === null || _d === void 0 ? void 0 : _d.userId) || null;
477
+ if (ownId && userId && String(userId) === String(ownId)) {
478
+ status = 'sent';
479
+ }
480
+ else {
481
+ status = 'received';
482
+ }
483
+ }
484
+ catch (stErr) {
485
+ status = 'received';
486
+ }
487
+ const msgData = {
488
+ username: username,
489
+ userId: userId,
490
+ text: textContent,
491
+ itemType: itemType,
492
+ threadId: threadId,
493
+ messageId: messageId,
494
+ timestamp: timestamp,
495
+ status: status,
496
+ rawData: msgValue
497
+ };
498
+ // console output (keeps original formatted block)
499
+ try {
500
+ console.log(this.formatMessageForConsole(msgData));
501
+ }
502
+ catch (eLog) {
503
+ // don't let logging break processing
504
+ }
505
+ const parsedMessage = {
506
+ ...element,
507
+ message: {
508
+ path: e.path,
509
+ op: e.op,
510
+ thread_id: threadId,
511
+ ...msgValue,
512
+ },
513
+ parsed: msgData
514
+ };
515
+ client.emit('message', parsedMessage);
516
+ continue;
517
+ } // end if msgValue has item_type
518
+ } // end if path matches threads
519
+ // If not a thread message, emit as threadUpdate or iris depending on payload
520
+ try {
521
+ const updateValue = e.value ? (typeof e.value === 'string' ? (() => {
522
+ try {
523
+ return JSON.parse(e.value);
524
+ }
525
+ catch {
526
+ return e.value;
527
+ }
528
+ })() : e.value) : {};
529
+ client.emit('threadUpdate', {
530
+ ...element,
531
+ meta: {
532
+ path: e.path,
533
+ op: e.op,
534
+ thread_id: MessageSyncMixin.getThreadIdFromPath(e.path),
535
+ },
536
+ update: updateValue,
537
+ });
538
+ }
539
+ catch (errUpdate) {
540
+ client.emit('iris', { ...element, ...e, value: parsedValue });
541
+ }
542
+ }
543
+ catch (inner) {
544
+ console.log(`[MESSAGE_SYNC] element handling error: ${(inner === null || inner === void 0 ? void 0 : inner.message) || inner}`);
545
+ }
546
+ }
547
+ }
548
+ catch (outer) {
549
+ console.log(`[MESSAGE_SYNC] item error: ${(outer === null || outer === void 0 ? void 0 : outer.message) || outer}`);
550
+ }
551
+ }
552
+ }
553
+ static getThreadIdFromPath(path) {
554
+ if (!path)
555
+ return undefined;
556
+ // Common patterns:
557
+ // /direct_v2/threads/<thread_id>/...
558
+ // /direct_v2/inbox/threads/<thread_id>/...
559
+ // /direct_v2/threads/<thread_id>
560
+ // possibly with trailing segments
561
+ try {
562
+ let m = path.match(/\/direct_v2\/threads\/(\d+)/);
563
+ if (m && m[1])
564
+ return m[1];
565
+ m = path.match(/\/direct_v2\/inbox\/threads\/(\d+)/);
566
+ if (m && m[1])
567
+ return m[1];
568
+ m = path.match(/\/direct_v2\/inbox\/(\d+)/);
569
+ if (m && m[1])
570
+ return m[1];
571
+ // last resort: look for any long numeric id in path
572
+ const anyId = path.match(/(\d{6,})/);
573
+ if (anyId && anyId[1])
574
+ return anyId[1];
575
+ }
576
+ catch (e) {
577
+ // ignore
578
+ }
579
+ return undefined;
580
+ }
581
+ get name() {
582
+ return 'Message Sync';
583
+ }
584
+ }
585
+ exports.MessageSyncMixin = MessageSyncMixin;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hook = exports.applyMixins = exports.Mixin = void 0;
4
+ class Mixin {
5
+ }
6
+ exports.Mixin = Mixin;
7
+ function applyMixins(mixins, client, ig) {
8
+ for (const mixin of mixins)
9
+ mixin.apply(client, ig);
10
+ }
11
+ exports.applyMixins = applyMixins;
12
+ function hook(target, key, hooks) {
13
+ const base = target[key];
14
+ const wrapper = (...args) => {
15
+ let returnValue;
16
+ let overrideReturn = false;
17
+ if (hooks.pre) {
18
+ const res = hooks.pre.apply(target, args);
19
+ if (typeof res === 'object' && res.overrideReturn) {
20
+ overrideReturn = true;
21
+ returnValue = res.returnValue;
22
+ }
23
+ }
24
+ const actualReturn = base.apply(target, args);
25
+ if (!overrideReturn)
26
+ returnValue = actualReturn;
27
+ if (hooks.post) {
28
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- it's always defined
29
+ const res = hooks.post.apply(target, [returnValue, ...args]);
30
+ if (typeof res === 'object' && res.overrideReturn) {
31
+ returnValue = res.returnValue;
32
+ }
33
+ }
34
+ // @ts-expect-error -- return value will be set [if pre sets it, else overrideReturn is false and it will be set by the actual function
35
+ return returnValue;
36
+ };
37
+ // @ts-expect-error -- any[] vs Parameters<Fn>
38
+ target[key] = wrapper.bind(target);
39
+ }
40
+ exports.hook = hook;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PresenceTypingMixin = void 0;
4
+ const presence_manager_1 = require("../features/presence.manager");
5
+ const skywalker_protocol_1 = require("../protocols/skywalker.protocol");
6
+ /**
7
+ * Mixin for handling Presence and Typing Indicators
8
+ */
9
+ class PresenceTypingMixin {
10
+ apply(client) {
11
+ // Initialize managers
12
+ client.presenceManager = new presence_manager_1.PresenceManager(client);
13
+ client.skywalkerProtocol = new skywalker_protocol_1.SkywalkerProtocol(client);
14
+ // Add public methods
15
+ client.sendTyping = async (threadId, isTyping = true) => {
16
+ return client.skywalkerProtocol.sendTypingIndicator(threadId, isTyping);
17
+ };
18
+ client.sendReaction = async (messageId, threadId, emoji) => {
19
+ return client.skywalkerProtocol.sendReaction(messageId, threadId, emoji);
20
+ };
21
+ client.broadcastPresence = async (status = 'online') => {
22
+ return client.presenceManager.broadcastPresence(status);
23
+ };
24
+ }
25
+ get name() {
26
+ return 'Presence & Typing';
27
+ }
28
+ }
29
+ exports.PresenceTypingMixin = PresenceTypingMixin;