nodejs-insta-private-api-mqt 1.3.70

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 (240) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +3677 -0
  3. package/dist/constants/constants.js +342 -0
  4. package/dist/constants/index.js +58 -0
  5. package/dist/core/client.js +419 -0
  6. package/dist/core/nav-chain.js +282 -0
  7. package/dist/core/repository.js +7 -0
  8. package/dist/core/request.js +390 -0
  9. package/dist/core/state.js +1473 -0
  10. package/dist/core/utils.js +786 -0
  11. package/dist/downloadMedia.js +381 -0
  12. package/dist/errors/index.d.ts +16 -0
  13. package/dist/errors/index.js +38 -0
  14. package/dist/errors/index.js.map +1 -0
  15. package/dist/extend.js +167 -0
  16. package/dist/fbns/fbns.client.d.ts +32 -0
  17. package/dist/fbns/fbns.client.events.d.ts +41 -0
  18. package/dist/fbns/fbns.client.events.js +3 -0
  19. package/dist/fbns/fbns.client.events.js.map +1 -0
  20. package/dist/fbns/fbns.client.js +252 -0
  21. package/dist/fbns/fbns.client.js.map +1 -0
  22. package/dist/fbns/fbns.device-auth.d.ts +17 -0
  23. package/dist/fbns/fbns.device-auth.js +54 -0
  24. package/dist/fbns/fbns.device-auth.js.map +1 -0
  25. package/dist/fbns/fbns.types.d.ts +83 -0
  26. package/dist/fbns/fbns.types.js +3 -0
  27. package/dist/fbns/fbns.types.js.map +1 -0
  28. package/dist/fbns/fbns.utilities.d.ts +2 -0
  29. package/dist/fbns/fbns.utilities.js +79 -0
  30. package/dist/fbns/fbns.utilities.js.map +1 -0
  31. package/dist/fbns/index.d.ts +4 -0
  32. package/dist/fbns/index.js +21 -0
  33. package/dist/fbns/index.js.map +1 -0
  34. package/dist/index.js +139 -0
  35. package/dist/mqtt-shim.d.ts +96 -0
  36. package/dist/mqtt-shim.js +15 -0
  37. package/dist/mqttot/index.d.ts +4 -0
  38. package/dist/mqttot/index.js +21 -0
  39. package/dist/mqttot/index.js.map +1 -0
  40. package/dist/mqttot/mqttot.client.d.ts +39 -0
  41. package/dist/mqttot/mqttot.client.js +318 -0
  42. package/dist/mqttot/mqttot.client.js.map +1 -0
  43. package/dist/mqttot/mqttot.connect.request.packet.d.ts +7 -0
  44. package/dist/mqttot/mqttot.connect.request.packet.js +9 -0
  45. package/dist/mqttot/mqttot.connect.request.packet.js.map +1 -0
  46. package/dist/mqttot/mqttot.connect.response.packet.d.ts +7 -0
  47. package/dist/mqttot/mqttot.connect.response.packet.js +24 -0
  48. package/dist/mqttot/mqttot.connect.response.packet.js.map +1 -0
  49. package/dist/mqttot/mqttot.connection.d.ts +57 -0
  50. package/dist/mqttot/mqttot.connection.js +79 -0
  51. package/dist/mqttot/mqttot.connection.js.map +1 -0
  52. package/dist/package.json +59 -0
  53. package/dist/realtime/commands/commands.d.ts +15 -0
  54. package/dist/realtime/commands/commands.js +71 -0
  55. package/dist/realtime/commands/commands.js.map +1 -0
  56. package/dist/realtime/commands/direct.commands.d.ts +75 -0
  57. package/dist/realtime/commands/direct.commands.js +417 -0
  58. package/dist/realtime/commands/direct.commands.js.map +1 -0
  59. package/dist/realtime/commands/enhanced.direct.commands.js +1731 -0
  60. package/dist/realtime/commands/enhanced.direct.commands.js.bak +967 -0
  61. package/dist/realtime/commands/index.d.ts +2 -0
  62. package/dist/realtime/commands/index.js +20 -0
  63. package/dist/realtime/commands/index.js.map +1 -0
  64. package/dist/realtime/delta-sync.manager.js +293 -0
  65. package/dist/realtime/features/dm-sender.js +88 -0
  66. package/dist/realtime/features/error-handler.js +185 -0
  67. package/dist/realtime/features/gap-handler.js +61 -0
  68. package/dist/realtime/features/persistent-logger.js +186 -0
  69. package/dist/realtime/features/presence.manager.js +66 -0
  70. package/dist/realtime/features/session-health-monitor.js +345 -0
  71. package/dist/realtime/index.js +30 -0
  72. package/dist/realtime/messages/app-presence.event.d.ts +9 -0
  73. package/dist/realtime/messages/app-presence.event.js +3 -0
  74. package/dist/realtime/messages/app-presence.event.js.map +1 -0
  75. package/dist/realtime/messages/index.d.ts +3 -0
  76. package/dist/realtime/messages/index.js +20 -0
  77. package/dist/realtime/messages/index.js.map +1 -0
  78. package/dist/realtime/messages/message-sync.message.d.ts +222 -0
  79. package/dist/realtime/messages/message-sync.message.js +43 -0
  80. package/dist/realtime/messages/message-sync.message.js.map +1 -0
  81. package/dist/realtime/messages/realtime-sub.direct.data.d.ts +11 -0
  82. package/dist/realtime/messages/realtime-sub.direct.data.js +3 -0
  83. package/dist/realtime/messages/realtime-sub.direct.data.js.map +1 -0
  84. package/dist/realtime/messages/thread-update.message.d.ts +68 -0
  85. package/dist/realtime/messages/thread-update.message.js +3 -0
  86. package/dist/realtime/messages/thread-update.message.js.map +1 -0
  87. package/dist/realtime/mixins/index.d.ts +3 -0
  88. package/dist/realtime/mixins/index.js +20 -0
  89. package/dist/realtime/mixins/index.js.map +1 -0
  90. package/dist/realtime/mixins/message-sync.mixin.d.ts +8 -0
  91. package/dist/realtime/mixins/message-sync.mixin.js +596 -0
  92. package/dist/realtime/mixins/message-sync.mixin.js.map +1 -0
  93. package/dist/realtime/mixins/mixin.d.ts +19 -0
  94. package/dist/realtime/mixins/mixin.js +41 -0
  95. package/dist/realtime/mixins/mixin.js.map +1 -0
  96. package/dist/realtime/mixins/presence-typing.mixin.js +33 -0
  97. package/dist/realtime/mixins/realtime-sub.mixin.d.ts +8 -0
  98. package/dist/realtime/mixins/realtime-sub.mixin.js +181 -0
  99. package/dist/realtime/mixins/realtime-sub.mixin.js.map +1 -0
  100. package/dist/realtime/parsers/graphql-parser.js +43 -0
  101. package/dist/realtime/parsers/graphql.parser.d.ts +15 -0
  102. package/dist/realtime/parsers/graphql.parser.js +22 -0
  103. package/dist/realtime/parsers/graphql.parser.js.map +1 -0
  104. package/dist/realtime/parsers/index.d.ts +6 -0
  105. package/dist/realtime/parsers/index.js +23 -0
  106. package/dist/realtime/parsers/index.js.map +1 -0
  107. package/dist/realtime/parsers/iris-parser.js +43 -0
  108. package/dist/realtime/parsers/iris.parser.d.ts +17 -0
  109. package/dist/realtime/parsers/iris.parser.js +10 -0
  110. package/dist/realtime/parsers/iris.parser.js.map +1 -0
  111. package/dist/realtime/parsers/json-parser.js +43 -0
  112. package/dist/realtime/parsers/json.parser.d.ts +6 -0
  113. package/dist/realtime/parsers/json.parser.js +10 -0
  114. package/dist/realtime/parsers/json.parser.js.map +1 -0
  115. package/dist/realtime/parsers/parser.d.ts +9 -0
  116. package/dist/realtime/parsers/parser.js +3 -0
  117. package/dist/realtime/parsers/parser.js.map +1 -0
  118. package/dist/realtime/parsers/region-hint-parser.js +43 -0
  119. package/dist/realtime/parsers/region-hint.parser.d.ts +12 -0
  120. package/dist/realtime/parsers/region-hint.parser.js +15 -0
  121. package/dist/realtime/parsers/region-hint.parser.js.map +1 -0
  122. package/dist/realtime/parsers/skywalker-parser.js +43 -0
  123. package/dist/realtime/parsers/skywalker.parser.d.ts +12 -0
  124. package/dist/realtime/parsers/skywalker.parser.js +15 -0
  125. package/dist/realtime/parsers/skywalker.parser.js.map +1 -0
  126. package/dist/realtime/parsers-advanced.js +158 -0
  127. package/dist/realtime/proto/common.proto +38 -0
  128. package/dist/realtime/proto/direct.proto +65 -0
  129. package/dist/realtime/proto/ig-messages.proto +83 -0
  130. package/dist/realtime/proto/iris.proto +188 -0
  131. package/dist/realtime/proto-parser.js +195 -0
  132. package/dist/realtime/protocols/iris.handshake.js +74 -0
  133. package/dist/realtime/protocols/proto-definitions.js +80 -0
  134. package/dist/realtime/protocols/skywalker.protocol.js +91 -0
  135. package/dist/realtime/realtime.client.events.js +3 -0
  136. package/dist/realtime/realtime.client.js +1915 -0
  137. package/dist/realtime/realtime.service.js +462 -0
  138. package/dist/realtime/reconnect.manager.js +88 -0
  139. package/dist/realtime/session.manager.js +121 -0
  140. package/dist/realtime/subscriptions/graphql.subscription.d.ts +47 -0
  141. package/dist/realtime/subscriptions/graphql.subscription.js +99 -0
  142. package/dist/realtime/subscriptions/graphql.subscription.js.map +1 -0
  143. package/dist/realtime/subscriptions/index.d.ts +2 -0
  144. package/dist/realtime/subscriptions/index.js +19 -0
  145. package/dist/realtime/subscriptions/index.js.map +1 -0
  146. package/dist/realtime/subscriptions/skywalker.subscription.d.ts +4 -0
  147. package/dist/realtime/subscriptions/skywalker.subscription.js +13 -0
  148. package/dist/realtime/subscriptions/skywalker.subscription.js.map +1 -0
  149. package/dist/realtime/topic-map.js +71 -0
  150. package/dist/realtime/topic.js +80 -0
  151. package/dist/repositories/account.repository.js +575 -0
  152. package/dist/repositories/bloks.repository.js +70 -0
  153. package/dist/repositories/captcha.repository.js +44 -0
  154. package/dist/repositories/challenge.repository.js +120 -0
  155. package/dist/repositories/clip.repository.js +165 -0
  156. package/dist/repositories/close-friends.repository.js +46 -0
  157. package/dist/repositories/collection.repository.js +68 -0
  158. package/dist/repositories/direct-thread.repository.js +446 -0
  159. package/dist/repositories/direct.repository.js +232 -0
  160. package/dist/repositories/explore.repository.js +70 -0
  161. package/dist/repositories/fbsearch.repository.js +140 -0
  162. package/dist/repositories/feed.repository.js +245 -0
  163. package/dist/repositories/friendship.repository.js +296 -0
  164. package/dist/repositories/fundraiser.repository.js +49 -0
  165. package/dist/repositories/hashtag.repository.js +99 -0
  166. package/dist/repositories/highlights.repository.js +121 -0
  167. package/dist/repositories/insights.repository.js +82 -0
  168. package/dist/repositories/location.repository.js +84 -0
  169. package/dist/repositories/media.repository.js +395 -0
  170. package/dist/repositories/multiple-accounts.repository.js +41 -0
  171. package/dist/repositories/news.repository.js +35 -0
  172. package/dist/repositories/note.repository.js +57 -0
  173. package/dist/repositories/notification.repository.js +79 -0
  174. package/dist/repositories/share.repository.js +35 -0
  175. package/dist/repositories/signup.repository.js +218 -0
  176. package/dist/repositories/story.repository.js +290 -0
  177. package/dist/repositories/timeline.repository.js +60 -0
  178. package/dist/repositories/totp.repository.js +139 -0
  179. package/dist/repositories/track.repository.js +53 -0
  180. package/dist/repositories/upload.repository.js +204 -0
  181. package/dist/repositories/user.repository.js +360 -0
  182. package/dist/sendmedia/index.js +27 -0
  183. package/dist/sendmedia/sendFile.js +72 -0
  184. package/dist/sendmedia/sendPhoto.js +142 -0
  185. package/dist/sendmedia/sendRavenPhoto.js +153 -0
  186. package/dist/sendmedia/sendRavenVideo.js +158 -0
  187. package/dist/sendmedia/uploadPhoto.js +107 -0
  188. package/dist/sendmedia/uploadfFile.js +130 -0
  189. package/dist/services/live.service.js +139 -0
  190. package/dist/services/search.service.js +115 -0
  191. package/dist/shared/index.js +96 -0
  192. package/dist/shared/shared.js +86 -0
  193. package/dist/thrift/index.d.ts +3 -0
  194. package/dist/thrift/index.js +20 -0
  195. package/dist/thrift/index.js.map +1 -0
  196. package/dist/thrift/thrift.d.ts +59 -0
  197. package/dist/thrift/thrift.js +101 -0
  198. package/dist/thrift/thrift.js.map +1 -0
  199. package/dist/thrift/thrift.reading.d.ts +41 -0
  200. package/dist/thrift/thrift.reading.js +327 -0
  201. package/dist/thrift/thrift.reading.js.map +1 -0
  202. package/dist/thrift/thrift.writing.d.ts +44 -0
  203. package/dist/thrift/thrift.writing.js +342 -0
  204. package/dist/thrift/thrift.writing.js.map +1 -0
  205. package/dist/types/index.js +285 -0
  206. package/dist/useMultiFileAuthState.js +1768 -0
  207. package/dist/utils/helper-1.js +1 -0
  208. package/dist/utils/helper-10.js +1 -0
  209. package/dist/utils/helper-11.js +1 -0
  210. package/dist/utils/helper-12.js +1 -0
  211. package/dist/utils/helper-13.js +1 -0
  212. package/dist/utils/helper-14.js +1 -0
  213. package/dist/utils/helper-15.js +1 -0
  214. package/dist/utils/helper-16.js +1 -0
  215. package/dist/utils/helper-17.js +1 -0
  216. package/dist/utils/helper-18.js +1 -0
  217. package/dist/utils/helper-19.js +1 -0
  218. package/dist/utils/helper-2.js +1 -0
  219. package/dist/utils/helper-20.js +1 -0
  220. package/dist/utils/helper-21.js +1 -0
  221. package/dist/utils/helper-22.js +1 -0
  222. package/dist/utils/helper-23.js +1 -0
  223. package/dist/utils/helper-24.js +1 -0
  224. package/dist/utils/helper-25.js +1 -0
  225. package/dist/utils/helper-26.js +1 -0
  226. package/dist/utils/helper-27.js +1 -0
  227. package/dist/utils/helper-28.js +1 -0
  228. package/dist/utils/helper-29.js +1 -0
  229. package/dist/utils/helper-3.js +1 -0
  230. package/dist/utils/helper-30.js +1 -0
  231. package/dist/utils/helper-4.js +1 -0
  232. package/dist/utils/helper-5.js +1 -0
  233. package/dist/utils/helper-6.js +1 -0
  234. package/dist/utils/helper-7.js +1 -0
  235. package/dist/utils/helper-8.js +1 -0
  236. package/dist/utils/helper-9.js +1 -0
  237. package/dist/utils/index.js +280 -0
  238. package/dist/utils/insta-mqtt-helper.js +128 -0
  239. package/examples/listen-to-messages.js +86 -0
  240. package/package.json +82 -0
package/dist/index.js ADDED
@@ -0,0 +1,139 @@
1
+ const IgApiClient = require('./core/client');
2
+ const NavChainManager = require('./core/nav-chain');
3
+ const { IgApiClientError } = require('./errors');
4
+ const { APP_VERSION } = require('./constants/constants');
5
+ const { RealtimeClient, IrisHandshake, SkywalkerProtocol, PresenceManager, DMSender, ErrorHandler, GapHandler, EnhancedDirectCommands, PresenceTypingMixin } = require('./realtime');
6
+ const constants = require('./constants/constants');
7
+ const sendmedia = require('./sendmedia');
8
+ const { sendRavenPhoto, sendRavenPhotoOnce, sendRavenPhotoReplayable, sendRavenVideo, sendRavenVideoOnce, sendRavenVideoReplayable } = sendmedia;
9
+ const { useMultiFileAuthState, MultiFileAuthState, extractStateData, applyStateData } = require('./useMultiFileAuthState');
10
+ const { downloadContentFromMessage, downloadMediaBuffer, extractMediaUrls, hasMedia, getMediaType, isViewOnceMedia, MEDIA_TYPES } = require('./downloadMedia');
11
+ const { GraphQLSubscriptions, QueryIDs } = require('./realtime/subscriptions/graphql.subscription');
12
+ const { SkywalkerSubscriptions } = require('./realtime/subscriptions/skywalker.subscription');
13
+ let FbnsClient;
14
+ try {
15
+ FbnsClient = require('./fbns/fbns.client').FbnsClient;
16
+ } catch (e) {
17
+ FbnsClient = class FbnsClient {
18
+ constructor() { throw new Error('FbnsClient requires mqtt-shim dependency which is not installed. Install it with: npm install mqtt-shim'); }
19
+ };
20
+ }
21
+ const { MQTToTClient, mqttotConnectFlow, INSTAGRAM_VERSION } = require('./mqttot/mqttot.client');
22
+ const { MQTToTConnection } = require('./mqttot/mqttot.connection');
23
+ const { IgApiClientExt, withFbns, withRealtime, withFbnsAndRealtime } = require('./extend');
24
+
25
+ const AccountRepository = require('./repositories/account.repository');
26
+ const UserRepository = require('./repositories/user.repository');
27
+ const MediaRepository = require('./repositories/media.repository');
28
+ const FeedRepository = require('./repositories/feed.repository');
29
+ const UploadRepository = require('./repositories/upload.repository');
30
+ const StoryRepository = require('./repositories/story.repository');
31
+ const DirectRepository = require('./repositories/direct.repository');
32
+ const DirectThreadRepository = require('./repositories/direct-thread.repository');
33
+ const FriendshipRepository = require('./repositories/friendship.repository');
34
+ const LocationRepository = require('./repositories/location.repository');
35
+ const HashtagRepository = require('./repositories/hashtag.repository');
36
+ const NewsRepository = require('./repositories/news.repository');
37
+ const CollectionRepository = require('./repositories/collection.repository');
38
+ const CloseFriendsRepository = require('./repositories/close-friends.repository');
39
+ const HighlightsRepository = require('./repositories/highlights.repository');
40
+ const ClipRepository = require('./repositories/clip.repository');
41
+ const TimelineRepository = require('./repositories/timeline.repository');
42
+ const InsightsRepository = require('./repositories/insights.repository');
43
+ const NoteRepository = require('./repositories/note.repository');
44
+ const NotificationRepository = require('./repositories/notification.repository');
45
+ const SignupRepository = require('./repositories/signup.repository');
46
+ const TOTPRepository = require('./repositories/totp.repository');
47
+ const BloksRepository = require('./repositories/bloks.repository');
48
+ const ChallengeRepository = require('./repositories/challenge.repository');
49
+ const ShareRepository = require('./repositories/share.repository');
50
+ const TrackRepository = require('./repositories/track.repository');
51
+ const ExploreRepository = require('./repositories/explore.repository');
52
+ const FBSearchRepository = require('./repositories/fbsearch.repository');
53
+ const FundraiserRepository = require('./repositories/fundraiser.repository');
54
+ const MultipleAccountsRepository = require('./repositories/multiple-accounts.repository');
55
+ const CaptchaRepository = require('./repositories/captcha.repository');
56
+
57
+ const { SessionHealthMonitor } = require('./realtime/features/session-health-monitor');
58
+ const { PersistentLogger } = require('./realtime/features/persistent-logger');
59
+
60
+ module.exports = {
61
+ IgApiClient,
62
+ NavChainManager,
63
+ IgApiClientError,
64
+ RealtimeClient,
65
+ IrisHandshake,
66
+ SkywalkerProtocol,
67
+ PresenceManager,
68
+ DMSender,
69
+ ErrorHandler,
70
+ GapHandler,
71
+ EnhancedDirectCommands,
72
+ PresenceTypingMixin,
73
+ Topics: constants.Topics,
74
+ REALTIME: constants.REALTIME,
75
+ sendmedia,
76
+ sendRavenPhoto,
77
+ sendRavenPhotoOnce,
78
+ sendRavenPhotoReplayable,
79
+ sendRavenVideo,
80
+ sendRavenVideoOnce,
81
+ sendRavenVideoReplayable,
82
+ useMultiFileAuthState,
83
+ MultiFileAuthState,
84
+ extractStateData,
85
+ applyStateData,
86
+ downloadContentFromMessage,
87
+ downloadMediaBuffer,
88
+ extractMediaUrls,
89
+ hasMedia,
90
+ getMediaType,
91
+ isViewOnceMedia,
92
+ MEDIA_TYPES,
93
+ GraphQLSubscriptions,
94
+ QueryIDs,
95
+ SkywalkerSubscriptions,
96
+ FbnsClient,
97
+ MQTToTClient,
98
+ mqttotConnectFlow,
99
+ MQTToTConnection,
100
+ INSTAGRAM_VERSION,
101
+ IgApiClientExt,
102
+ withFbns,
103
+ withRealtime,
104
+ withFbnsAndRealtime,
105
+ APP_VERSION,
106
+ SessionHealthMonitor,
107
+ PersistentLogger,
108
+ AccountRepository,
109
+ UserRepository,
110
+ MediaRepository,
111
+ FeedRepository,
112
+ UploadRepository,
113
+ StoryRepository,
114
+ DirectRepository,
115
+ DirectThreadRepository,
116
+ FriendshipRepository,
117
+ LocationRepository,
118
+ HashtagRepository,
119
+ NewsRepository,
120
+ CollectionRepository,
121
+ CloseFriendsRepository,
122
+ HighlightsRepository,
123
+ ClipRepository,
124
+ TimelineRepository,
125
+ InsightsRepository,
126
+ NoteRepository,
127
+ NotificationRepository,
128
+ SignupRepository,
129
+ TOTPRepository,
130
+ BloksRepository,
131
+ ChallengeRepository,
132
+ ShareRepository,
133
+ TrackRepository,
134
+ ExploreRepository,
135
+ FBSearchRepository,
136
+ FundraiserRepository,
137
+ MultipleAccountsRepository,
138
+ CaptchaRepository,
139
+ };
@@ -0,0 +1,96 @@
1
+ import { EventEmitter } from 'events';
2
+
3
+ export class PacketType {
4
+ static Connect: number;
5
+ static ConnAck: number;
6
+ static Publish: number;
7
+ static PubAck: number;
8
+ static Subscribe: number;
9
+ static SubAck: number;
10
+ static Unsubscribe: number;
11
+ static UnsubAck: number;
12
+ static PingReq: number;
13
+ static PingResp: number;
14
+ static Disconnect: number;
15
+ }
16
+
17
+ export class ConnectResponsePacket {
18
+ ackFlags: number;
19
+ returnCode: number;
20
+ payload?: Buffer;
21
+ get isSuccess(): boolean;
22
+ get errorName(): string | null;
23
+ constructor(ackFlags: number, returnCode: number, payload?: Buffer);
24
+ }
25
+
26
+ export class IllegalStateError extends Error {}
27
+
28
+ export interface MqttMessage {
29
+ topic: string;
30
+ payload: Buffer;
31
+ qosLevel?: number;
32
+ }
33
+
34
+ export interface MqttMessageOutgoing {
35
+ topic: string;
36
+ payload: Buffer;
37
+ qosLevel?: number;
38
+ }
39
+
40
+ export interface PacketFlowFunc {
41
+ (success: (packet: any) => void, error: (error: Error) => void): {
42
+ start: () => any;
43
+ accept: (packet: any) => boolean;
44
+ next: (packet: any) => void;
45
+ };
46
+ }
47
+
48
+ export class MqttClient extends EventEmitter {
49
+ constructor(options: any);
50
+ connect(options?: any): Promise<void>;
51
+ publish(message: MqttMessageOutgoing): Promise<any>;
52
+ subscribe(topic: string, qos?: number): Promise<void>;
53
+ disconnect(): void;
54
+ topicMap: Map<string, any>;
55
+ }
56
+
57
+ export class TlsTransport { constructor(options: any); }
58
+ export class SocksTlsTransport { constructor(options: any); }
59
+
60
+ export class PacketStream {
61
+ constructor(buffer: Buffer);
62
+ readByte(): number;
63
+ readStringAsBuffer(): Buffer;
64
+ readWord(): number;
65
+ }
66
+
67
+ export const DefaultPacketReadMap: any;
68
+ export const DefaultPacketWriteMap: any;
69
+ export function isConnAck(packet: any): boolean;
70
+
71
+ export interface ConnectRequestOptions {
72
+ payload?: Buffer;
73
+ keepAlive?: number;
74
+ [key: string]: any;
75
+ }
76
+
77
+ export interface DefaultPacketReadResultMap {
78
+ [key: number]: (stream: PacketStream, length: number) => any;
79
+ }
80
+
81
+ export interface DefaultPacketWriteOptions {
82
+ [key: string]: any;
83
+ }
84
+
85
+ export interface PacketWriteResult {
86
+ [key: string]: any;
87
+ }
88
+
89
+ export enum ConnectReturnCode {
90
+ ACCEPTED = 0,
91
+ UNACCEPTABLE_PROTOCOL_VERSION = 1,
92
+ IDENTIFIER_REJECTED = 2,
93
+ SERVER_UNAVAILABLE = 3,
94
+ BAD_USERNAME_OR_PASSWORD = 4,
95
+ NOT_AUTHORIZED = 5,
96
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const mqtts = require("mqtts");
4
+
5
+ exports.PacketType = mqtts.PacketType;
6
+ exports.ConnectResponsePacket = mqtts.ConnectResponsePacket;
7
+ exports.IllegalStateError = mqtts.IllegalStateError;
8
+ exports.MqttClient = mqtts.MqttClient;
9
+ exports.TlsTransport = mqtts.TlsTransport;
10
+ exports.SocksTlsTransport = mqtts.SocksTlsTransport;
11
+ exports.PacketStream = mqtts.PacketStream;
12
+ exports.DefaultPacketReadMap = mqtts.DefaultPacketReadMap;
13
+ exports.DefaultPacketWriteMap = mqtts.DefaultPacketWriteMap;
14
+ exports.isConnAck = mqtts.isConnAck;
15
+ exports.ConnectReturnCode = mqtts.ConnectReturnCode;
@@ -0,0 +1,4 @@
1
+ export * from './mqttot.client';
2
+ export * from './mqttot.connect.request.packet';
3
+ export * from './mqttot.connect.response.packet';
4
+ export * from './mqttot.connection';
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./mqttot.client"), exports);
18
+ __exportStar(require("./mqttot.connect.request.packet"), exports);
19
+ __exportStar(require("./mqttot.connect.response.packet"), exports);
20
+ __exportStar(require("./mqttot.connection"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mqttot/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,kEAAgD;AAChD,mEAAiD;AACjD,sDAAoC"}
@@ -0,0 +1,39 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import { MQTToTConnectPacketOptions } from './mqttot.connect.request.packet';
4
+ import * as mqtts_1 from '../mqtt-shim';
5
+ import { MQTToTConnectResponsePacket } from './mqttot.connect.response.packet';
6
+ import { SocksProxy } from 'socks';
7
+ import { ConnectionOptions } from 'tls';
8
+ type MQTToTReadMap = Omit<DefaultPacketReadResultMap, PacketType.ConnAck> & {
9
+ [PacketType.ConnAck]: MQTToTConnectResponsePacket;
10
+ };
11
+ type MQTToTWriteMap = Omit<DefaultPacketWriteOptions, PacketType.Connect> & {
12
+ [PacketType.Connect]: MQTToTConnectPacketOptions;
13
+ };
14
+ export declare class MQTToTClient extends MqttClient<MQTToTReadMap, MQTToTWriteMap> {
15
+ protected connectPayloadProvider: () => Promise<Buffer>;
16
+ protected connectPayload?: Buffer;
17
+ protected requirePayload: boolean;
18
+ protected mqttotDebug: (msg: string) => void;
19
+ constructor(options: {
20
+ url: string;
21
+ payloadProvider: () => Promise<Buffer>;
22
+ enableTrace?: boolean;
23
+ autoReconnect: boolean;
24
+ requirePayload: boolean;
25
+ socksOptions?: SocksProxy;
26
+ additionalOptions?: ConnectionOptions;
27
+ });
28
+ protected registerListeners(): void;
29
+ connect(options?: ConnectRequestOptions): Promise<any>;
30
+ protected getConnectFlow(): PacketFlowFunc<MQTToTReadMap, MQTToTWriteMap, any>;
31
+ /**
32
+ * Compresses the payload
33
+ * @param {MqttMessage} message
34
+ * @returns {Promise<MqttMessageOutgoing>}
35
+ */
36
+ mqttotPublish(message: MqttMessage): Promise<MqttMessageOutgoing>;
37
+ }
38
+ export declare function mqttotConnectFlow(payload: Buffer, requirePayload: boolean): PacketFlowFunc<MQTToTReadMap, MQTToTWriteMap, MQTToTConnectResponsePacket>;
39
+ export {};
@@ -0,0 +1,318 @@
1
+ 'use strict';
2
+ // Instagram version marker (adjust as you like)
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.mqttotConnectFlow = exports.MQTToTClient = void 0;
5
+ exports.INSTAGRAM_VERSION = '415.0.0.36.76';
6
+
7
+ const shared_1 = require("../shared");
8
+ const mqttot_connect_request_packet_1 = require("./mqttot.connect.request.packet");
9
+ // Use external mqtts package (must be installed in your project)
10
+ const mqtts_1 = require("mqtts");
11
+ const errors_1 = require("../errors");
12
+ const mqttot_connect_response_packet_1 = require("./mqttot.connect.response.packet");
13
+
14
+ /**
15
+ * MQTToTClient
16
+ * - Subclasses external mqtts.MqttClient
17
+ * - Adds Instagram-specific helpers (connect flow, compressed publish)
18
+ * - Adds keepalive (PING) and robust reconnect with exponential backoff
19
+ *
20
+ * Comments/notes are inline. This file is ready to paste into your project.
21
+ */
22
+ class MQTToTClient extends mqtts_1.MqttClient {
23
+ /**
24
+ * @param {Object} options
25
+ * options:
26
+ * - url: broker host
27
+ * - socksOptions: optional proxy options
28
+ * - autoReconnect: boolean
29
+ * - payloadProvider: async function returning connection payload (Thrift blob)
30
+ * - requirePayload: boolean (legacy behavior)
31
+ * - additionalOptions: transport options passthrough
32
+ */
33
+ constructor(options) {
34
+ super({
35
+ autoReconnect: options.autoReconnect,
36
+ readMap: {
37
+ ...mqtts_1.DefaultPacketReadMap,
38
+ [mqtts_1.PacketType.ConnAck]: mqttot_connect_response_packet_1.readConnectResponsePacket,
39
+ },
40
+ writeMap: {
41
+ ...mqtts_1.DefaultPacketWriteMap,
42
+ [mqtts_1.PacketType.Connect]: mqttot_connect_request_packet_1.writeConnectRequestPacket,
43
+ },
44
+ transport: options.socksOptions
45
+ ? new mqtts_1.SocksTlsTransport({
46
+ host: options.url,
47
+ port: 443,
48
+ proxyOptions: options.socksOptions,
49
+ additionalOptions: options.additionalOptions,
50
+ })
51
+ : new mqtts_1.TlsTransport({
52
+ host: options.url,
53
+ port: 443,
54
+ additionalOptions: options.additionalOptions,
55
+ }),
56
+ });
57
+
58
+ // Save options for reconnect attempts
59
+ this._options = options || {};
60
+ // Debug helper prefixed with broker url
61
+ this.mqttotDebug = (msg, ...args) => (0, shared_1.debugChannel)('mqttot')(`${this._options.url}: ${msg}`, ...args);
62
+ this.connectPayloadProvider = options.payloadProvider;
63
+ this.mqttotDebug(`Creating client`);
64
+ // Register listeners (errors, disconnect, pingresps, etc.)
65
+ this.registerListeners();
66
+ this.requirePayload = options.requirePayload;
67
+
68
+ this._keepaliveMs = (typeof options.keepaliveMs === 'number') ? options.keepaliveMs : (8 * 60 * 1000);
69
+ this._consecutivePingFailures = 0;
70
+ this._startKeepalive();
71
+ }
72
+
73
+ _startKeepalive() {
74
+ try {
75
+ if (this._keepaliveTimer) clearInterval(this._keepaliveTimer);
76
+ const jitter = Math.floor(Math.random() * 30000);
77
+ this._keepaliveTimer = setInterval(() => {
78
+ try {
79
+ if (typeof this.ping === 'function') {
80
+ this.mqttotDebug('Sending PINGREQ (keepalive)');
81
+ const res = this.ping();
82
+ if (res && typeof res.then === 'function') {
83
+ res.then(() => {
84
+ this._consecutivePingFailures = 0;
85
+ }).catch((e) => {
86
+ this._consecutivePingFailures++;
87
+ this.mqttotDebug(`Ping failed (${this._consecutivePingFailures}): ${e?.message || e}`);
88
+ if (this._consecutivePingFailures >= 3) {
89
+ this.mqttotDebug('3 consecutive ping failures - emitting disconnect for reconnect');
90
+ this._consecutivePingFailures = 0;
91
+ this.emit('disconnect', 'ping_failure');
92
+ }
93
+ });
94
+ }
95
+ } else {
96
+ this.mqttotDebug('ping() not available - keepalive skipped');
97
+ }
98
+ } catch (e) {
99
+ this.mqttotDebug(`Ping error: ${e?.message || e}`);
100
+ }
101
+ }, this._keepaliveMs + jitter);
102
+ } catch (e) {
103
+ this.mqttotDebug(`Keepalive setup error: ${e?.message || e}`);
104
+ }
105
+ }
106
+
107
+ /**
108
+ * Stop keepalive timer (call on explicit close/disconnect)
109
+ */
110
+ _stopKeepalive() {
111
+ try {
112
+ if (this._keepaliveTimer) {
113
+ clearInterval(this._keepaliveTimer);
114
+ this._keepaliveTimer = null;
115
+ }
116
+ } catch (e) {
117
+ // ignore
118
+ }
119
+ }
120
+
121
+ /**
122
+ * Register event listeners on the underlying mqtt client to handle:
123
+ * - errors / warnings
124
+ * - disconnects -> attempt reconnection with exponential backoff
125
+ * - pingresp events for diagnostics
126
+ */
127
+ registerListeners() {
128
+ const printErrorOrWarning = (type) => (e) => {
129
+ if (typeof e === 'string') {
130
+ this.mqttotDebug(`${type}: ${e}`);
131
+ }
132
+ else {
133
+ this.mqttotDebug(`${type}: ${e.message}\n\tStack: ${e.stack}`);
134
+ }
135
+ };
136
+
137
+ // Attach diagnostics
138
+ this.on('error', printErrorOrWarning('Error'));
139
+ this.on('warning', printErrorOrWarning('Warning'));
140
+
141
+ // Listen to ping responses if the library emits them
142
+ this.on('pingresp', () => {
143
+ this.mqttotDebug('Received PINGRESP (keepalive ok)');
144
+ });
145
+
146
+ this.on('disconnect', async (reason) => {
147
+ try {
148
+ this.mqttotDebug(`Disconnected. Reason: ${reason}`);
149
+ this._stopKeepalive();
150
+
151
+ if (this._options && this._options.autoReconnect === false) {
152
+ this.mqttotDebug('autoReconnect disabled; will not attempt reconnect.');
153
+ return;
154
+ }
155
+
156
+ let delay = 3000 + Math.floor(Math.random() * 2000);
157
+ const maxAttempts = 12;
158
+ for (let attempt = 0; attempt < maxAttempts; attempt++) {
159
+ try {
160
+ this.mqttotDebug(`Reconnect attempt #${attempt + 1} (delay ${delay}ms)`);
161
+ try { this.reset(); } catch (_e) {}
162
+ try { this.transport.reset(); } catch (_e) {}
163
+ try { this.transformer = this.createTransformer(); } catch (_e) {}
164
+ await this.connect(this._options);
165
+ this.mqttotDebug('Reconnected successfully');
166
+ this._consecutivePingFailures = 0;
167
+ this._startKeepalive();
168
+ return;
169
+ } catch (err) {
170
+ const errMsg = (err?.message || String(err)).toLowerCase();
171
+ const isRateLimit = errMsg.includes('rate') || errMsg.includes('throttl') || errMsg.includes('429');
172
+ this.mqttotDebug(`Reconnect attempt #${attempt + 1} failed: ${err?.message || err}`);
173
+ if (isRateLimit) {
174
+ delay = Math.min(delay * 3, 10 * 60 * 1000);
175
+ } else {
176
+ delay = Math.min(delay * 2, 5 * 60 * 1000);
177
+ }
178
+ const jitter = Math.floor(Math.random() * Math.min(delay * 0.2, 5000));
179
+ await new Promise(r => setTimeout(r, delay + jitter));
180
+ }
181
+ }
182
+ this.mqttotDebug(`Exceeded ${maxAttempts} reconnect attempts. Waiting for external trigger.`);
183
+ } catch (e) {
184
+ this.mqttotDebug(`Error in disconnect handler: ${e?.message || e}`);
185
+ }
186
+ });
187
+ }
188
+
189
+ /**
190
+ * connect override
191
+ * - Waits for connect payload from provider before calling parent connect
192
+ */
193
+ async connect(options) {
194
+ // Acquire the payload (Thrift serialized connection blob) before connecting.
195
+ if (typeof this.connectPayloadProvider === 'function') {
196
+ try {
197
+ this.connectPayload = await this.connectPayloadProvider();
198
+ } catch (e) {
199
+ this.mqttotDebug(`connectPayloadProvider failed: ${e?.message || e}`);
200
+ throw e;
201
+ }
202
+ } else {
203
+ this.mqttotDebug('No connectPayloadProvider provided; proceeding without payload');
204
+ this.connectPayload = null;
205
+ }
206
+ // Call super.connect to establish connection
207
+ return super.connect(options);
208
+ }
209
+
210
+ /**
211
+ * Return an Instagram-flavored connect flow function for the mqtts client.
212
+ * If payload is missing but CONNACK indicates success, accept it (robustness).
213
+ */
214
+ getConnectFlow() {
215
+ if (!this.connectPayload) {
216
+ throw new mqtts_1.IllegalStateError('Called getConnectFlow() before calling connect()');
217
+ }
218
+ return mqttotConnectFlow(this.connectPayload, this.requirePayload);
219
+ }
220
+
221
+ /**
222
+ * Compresses payload using shared.compressDeflate and publishes with QoS 0.
223
+ * QoS 0 forced for Instagram edge stability (avoid PUBACK waits causing reconnect loops).
224
+ */
225
+ async mqttotPublish(message) {
226
+ this.mqttotDebug(`Publishing ${message.payload.byteLength || message.payload.length} bytes to topic ${message.topic}`);
227
+ const compressed = await (0, shared_1.compressDeflate)(message.payload);
228
+ return await this.publish({
229
+ topic: message.topic,
230
+ payload: compressed,
231
+ qosLevel: 0, // FORCED: QoS 0 for stability on Instagram edge
232
+ });
233
+ }
234
+
235
+ /**
236
+ * Helper to listen for a specific topic and run transformer before calling handler.
237
+ */
238
+ listen(configOrTopic, handler) {
239
+ if (typeof configOrTopic === 'string') {
240
+ const topicId = configOrTopic;
241
+ this.mqttotDebug(`[LISTEN] Setting up raw listener on topic ${topicId}`);
242
+ const listener = async (msg) => {
243
+ if (msg.topic === topicId) {
244
+ try {
245
+ handler(msg);
246
+ } catch (e) {
247
+ this.mqttotDebug(`Error in handler for topic ${topicId}: ${e?.message || e}`);
248
+ this.emit('error', e);
249
+ }
250
+ }
251
+ };
252
+ this.on('message', listener);
253
+ return () => { this.removeListener('message', listener); };
254
+ }
255
+
256
+ const config = configOrTopic;
257
+ this.mqttotDebug(`[LISTEN] Setting up listener on topic ${config.topic} with transformer`);
258
+ const listener = async (msg) => {
259
+ if (msg.topic === config.topic) {
260
+ try {
261
+ const data = await config.transformer({ payload: msg.payload });
262
+ handler(data);
263
+ } catch (e) {
264
+ this.mqttotDebug(`Error in transformer for topic ${config.topic}: ${e?.message || e}`);
265
+ this.emit('error', e);
266
+ }
267
+ }
268
+ };
269
+ this.on('message', listener);
270
+ return () => { this.removeListener('message', listener); };
271
+ }
272
+
273
+ /**
274
+ * Clean shutdown helper: stop keepalive & close
275
+ */
276
+ async gracefulClose() {
277
+ try {
278
+ this._stopKeepalive();
279
+ if (typeof super.close === 'function') {
280
+ // some libs provide close() or end()
281
+ await super.close();
282
+ } else if (typeof super.end === 'function') {
283
+ await super.end();
284
+ }
285
+ } catch (e) {
286
+ this.mqttotDebug(`Error during gracefulClose: ${e?.message || e}`);
287
+ }
288
+ }
289
+ }
290
+ exports.MQTToTClient = MQTToTClient;
291
+
292
+ /**
293
+ * mqttotConnectFlow
294
+ * - Returns a flow object that the mqtts client uses to perform CONNECT/CONNACK handshake.
295
+ * - Changed behavior: treat CONNACK success as success even if payload missing (robustness).
296
+ */
297
+ function mqttotConnectFlow(payload, requirePayload) {
298
+ return (success, error) => ({
299
+ start: () => ({
300
+ type: mqtts_1.PacketType.Connect,
301
+ options: {
302
+ payload,
303
+ keepAlive: 60,
304
+ },
305
+ }),
306
+ accept: mqtts_1.isConnAck,
307
+ next: (packet) => {
308
+ if (packet.isSuccess) {
309
+ // Accept success even if payload is empty to avoid noisy errors
310
+ success(packet);
311
+ }
312
+ else {
313
+ error(new errors_1.ConnectionFailedError(`CONNACK returnCode: ${packet.returnCode} errorName: ${packet.errorName}`));
314
+ }
315
+ },
316
+ });
317
+ }
318
+ exports.mqttotConnectFlow = mqttotConnectFlow;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mqttot.client.js","sourceRoot":"","sources":["../../src/mqttot/mqttot.client.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,7 @@
1
+ /// <reference types="node" />
2
+ import * as mqtts_1 from '../mqtt-shim';
3
+ export interface MQTToTConnectPacketOptions {
4
+ keepAlive: number;
5
+ payload: Buffer;
6
+ }
7
+ export declare function writeConnectRequestPacket(stream: PacketStream, options: MQTToTConnectPacketOptions): PacketWriteResult;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.writeConnectRequestPacket = void 0;
4
+ function writeConnectRequestPacket(stream, options) {
5
+ stream.writeString('MQTToT').writeByte(3).writeByte(194).writeWord(options.keepAlive).write(options.payload);
6
+ return {};
7
+ }
8
+ exports.writeConnectRequestPacket = writeConnectRequestPacket;
9
+ //# sourceMappingURL=mqttot.connect.request.packet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mqttot.connect.request.packet.js","sourceRoot":"","sources":["../../src/mqttot/mqttot.connect.request.packet.ts"],"names":[],"mappings":";;;AAMA,SAAgB,yBAAyB,CACtC,MAAoB,EACpB,OAAmC;IAEnC,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC7G,OAAO,EAAE,CAAC;AACb,CAAC;AAND,8DAMC"}
@@ -0,0 +1,7 @@
1
+ /// <reference types="node" />
2
+ import * as mqtts_1 from '../mqtt-shim';
3
+ export declare class MQTToTConnectResponsePacket extends ConnectResponsePacket {
4
+ readonly payload: Buffer;
5
+ constructor(ackFlags: number, returnCode: ConnectReturnCode, payload: Buffer);
6
+ }
7
+ export declare function readConnectResponsePacket(stream: PacketStream, remaining: number): MQTToTConnectResponsePacket;