nodejs-insta-private-api-mqt 1.3.83 → 1.3.85
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.
- package/dist-ts/dist/constants/constants.js +341 -0
- package/dist-ts/dist/constants/index.js +53 -0
- package/dist-ts/dist/core/client.js +437 -0
- package/dist-ts/dist/core/nav-chain.js +252 -0
- package/dist-ts/dist/core/repository.js +6 -0
- package/dist-ts/dist/core/request.js +358 -0
- package/dist-ts/dist/core/state.js +1428 -0
- package/dist-ts/dist/core/utils.js +723 -0
- package/dist-ts/dist/downloadMedia.js +336 -0
- package/dist-ts/dist/errors/index.js +37 -0
- package/dist-ts/dist/extend.js +157 -0
- package/dist-ts/dist/fbns/fbns.client.events.js +2 -0
- package/dist-ts/dist/fbns/fbns.client.js +237 -0
- package/dist-ts/dist/fbns/fbns.device-auth.js +59 -0
- package/dist-ts/dist/fbns/fbns.types.js +2 -0
- package/dist-ts/dist/fbns/fbns.utilities.js +78 -0
- package/dist-ts/dist/fbns/index.js +24 -0
- package/dist-ts/dist/index.js +137 -0
- package/dist-ts/dist/mqtt-shim.js +14 -0
- package/dist-ts/dist/mqttot/index.js +24 -0
- package/dist-ts/dist/mqttot/mqttot.client.js +322 -0
- package/dist-ts/dist/mqttot/mqttot.connect.request.packet.js +8 -0
- package/dist-ts/dist/mqttot/mqttot.connect.response.packet.js +23 -0
- package/dist-ts/dist/mqttot/mqttot.connection.js +68 -0
- package/dist-ts/dist/realtime/commands/commands.js +67 -0
- package/dist-ts/dist/realtime/commands/direct.commands.js +415 -0
- package/dist-ts/dist/realtime/commands/enhanced.direct.commands.js +1529 -0
- package/dist-ts/dist/realtime/commands/index.js +23 -0
- package/dist-ts/dist/realtime/delta-sync.manager.js +260 -0
- package/dist-ts/dist/realtime/features/dm-sender.js +94 -0
- package/dist-ts/dist/realtime/features/error-handler.js +167 -0
- package/dist-ts/dist/realtime/features/gap-handler.js +60 -0
- package/dist-ts/dist/realtime/features/persistent-logger.js +174 -0
- package/dist-ts/dist/realtime/features/presence.manager.js +68 -0
- package/dist-ts/dist/realtime/features/session-health-monitor.js +327 -0
- package/dist-ts/dist/realtime/index.js +21 -0
- package/dist-ts/dist/realtime/messages/app-presence.event.js +2 -0
- package/dist-ts/dist/realtime/messages/index.js +23 -0
- package/dist-ts/dist/realtime/messages/message-sync.message.js +42 -0
- package/dist-ts/dist/realtime/messages/realtime-sub.direct.data.js +2 -0
- package/dist-ts/dist/realtime/messages/thread-update.message.js +2 -0
- package/dist-ts/dist/realtime/mixins/index.js +23 -0
- package/dist-ts/dist/realtime/mixins/message-sync.mixin.js +585 -0
- package/dist-ts/dist/realtime/mixins/mixin.js +40 -0
- package/dist-ts/dist/realtime/mixins/presence-typing.mixin.js +29 -0
- package/dist-ts/dist/realtime/mixins/realtime-sub.mixin.js +171 -0
- package/dist-ts/dist/realtime/parsers/graphql-parser.js +43 -0
- package/dist-ts/dist/realtime/parsers/graphql.parser.js +22 -0
- package/dist-ts/dist/realtime/parsers/index.js +26 -0
- package/dist-ts/dist/realtime/parsers/iris-parser.js +43 -0
- package/dist-ts/dist/realtime/parsers/iris.parser.js +9 -0
- package/dist-ts/dist/realtime/parsers/json-parser.js +43 -0
- package/dist-ts/dist/realtime/parsers/json.parser.js +9 -0
- package/dist-ts/dist/realtime/parsers/parser.js +2 -0
- package/dist-ts/dist/realtime/parsers/region-hint-parser.js +43 -0
- package/dist-ts/dist/realtime/parsers/region-hint.parser.js +14 -0
- package/dist-ts/dist/realtime/parsers/skywalker-parser.js +43 -0
- package/dist-ts/dist/realtime/parsers/skywalker.parser.js +14 -0
- package/dist-ts/dist/realtime/parsers-advanced.js +138 -0
- package/dist-ts/dist/realtime/proto-parser.js +186 -0
- package/dist-ts/dist/realtime/protocols/iris.handshake.js +76 -0
- package/dist-ts/dist/realtime/protocols/skywalker.protocol.js +96 -0
- package/dist-ts/dist/realtime/realtime.client.events.js +2 -0
- package/dist-ts/dist/realtime/realtime.client.js +2117 -0
- package/dist-ts/dist/realtime/realtime.service.js +408 -0
- package/dist-ts/dist/realtime/reconnect.manager.js +72 -0
- package/dist-ts/dist/realtime/session.manager.js +106 -0
- package/dist-ts/dist/realtime/subscriptions/graphql.subscription.js +98 -0
- package/dist-ts/dist/realtime/subscriptions/index.js +22 -0
- package/dist-ts/dist/realtime/subscriptions/skywalker.subscription.js +12 -0
- package/dist-ts/dist/realtime/topic-map.js +57 -0
- package/dist-ts/dist/realtime/topic.js +76 -0
- package/dist-ts/dist/repositories/account.repository.js +1267 -0
- package/dist-ts/dist/repositories/bloks.repository.js +66 -0
- package/dist-ts/dist/repositories/captcha.repository.js +40 -0
- package/dist-ts/dist/repositories/challenge.repository.js +108 -0
- package/dist-ts/dist/repositories/clip.repository.js +134 -0
- package/dist-ts/dist/repositories/close-friends.repository.js +41 -0
- package/dist-ts/dist/repositories/collection.repository.js +64 -0
- package/dist-ts/dist/repositories/direct-thread.repository.js +423 -0
- package/dist-ts/dist/repositories/direct.repository.js +246 -0
- package/dist-ts/dist/repositories/explore.repository.js +60 -0
- package/dist-ts/dist/repositories/fbsearch.repository.js +124 -0
- package/dist-ts/dist/repositories/feed.repository.js +237 -0
- package/dist-ts/dist/repositories/friendship.repository.js +277 -0
- package/dist-ts/dist/repositories/fundraiser.repository.js +38 -0
- package/dist-ts/dist/repositories/hashtag.repository.js +80 -0
- package/dist-ts/dist/repositories/highlights.repository.js +100 -0
- package/dist-ts/dist/repositories/insights.repository.js +66 -0
- package/dist-ts/dist/repositories/location.repository.js +67 -0
- package/dist-ts/dist/repositories/media.repository.js +370 -0
- package/dist-ts/dist/repositories/multiple-accounts.repository.js +36 -0
- package/dist-ts/dist/repositories/news.repository.js +32 -0
- package/dist-ts/dist/repositories/note.repository.js +51 -0
- package/dist-ts/dist/repositories/notification.repository.js +77 -0
- package/dist-ts/dist/repositories/share.repository.js +34 -0
- package/dist-ts/dist/repositories/signup.repository.js +178 -0
- package/dist-ts/dist/repositories/story.repository.js +268 -0
- package/dist-ts/dist/repositories/timeline.repository.js +57 -0
- package/dist-ts/dist/repositories/totp.repository.js +124 -0
- package/dist-ts/dist/repositories/track.repository.js +50 -0
- package/dist-ts/dist/repositories/upload.repository.js +191 -0
- package/dist-ts/dist/repositories/user.repository.js +332 -0
- package/dist-ts/dist/sendmedia/index.js +24 -0
- package/dist-ts/dist/sendmedia/sendFile.js +56 -0
- package/dist-ts/dist/sendmedia/sendPhoto.js +132 -0
- package/dist-ts/dist/sendmedia/sendRavenPhoto.js +133 -0
- package/dist-ts/dist/sendmedia/sendRavenVideo.js +136 -0
- package/dist-ts/dist/sendmedia/uploadPhoto.js +89 -0
- package/dist-ts/dist/sendmedia/uploadfFile.js +108 -0
- package/dist-ts/dist/services/live.service.js +113 -0
- package/dist-ts/dist/services/search.service.js +91 -0
- package/dist-ts/dist/shared/index.js +98 -0
- package/dist-ts/dist/shared/shared.js +85 -0
- package/dist-ts/dist/thrift/index.js +23 -0
- package/dist-ts/dist/thrift/thrift.js +105 -0
- package/dist-ts/dist/thrift/thrift.reading.js +339 -0
- package/dist-ts/dist/thrift/thrift.writing.js +393 -0
- package/dist-ts/dist/types/index.js +276 -0
- package/dist-ts/dist/useMultiFileAuthState.js +1878 -0
- package/dist-ts/dist/utils/index.js +244 -0
- package/dist-ts/examples/listen-to-messages.js +73 -0
- package/package.json +10 -2
- package/src-ts/dist/realtime/protocols/proto-definitions.ts +80 -0
- package/src-ts/dist/utils/helper-1.ts +1 -0
- package/src-ts/dist/utils/helper-10.ts +1 -0
- package/src-ts/dist/utils/helper-11.ts +1 -0
- package/src-ts/dist/utils/helper-12.ts +1 -0
- package/src-ts/dist/utils/helper-13.ts +1 -0
- package/src-ts/dist/utils/helper-14.ts +1 -0
- package/src-ts/dist/utils/helper-15.ts +1 -0
- package/src-ts/dist/utils/helper-16.ts +1 -0
- package/src-ts/dist/utils/helper-17.ts +1 -0
- package/src-ts/dist/utils/helper-18.ts +1 -0
- package/src-ts/dist/utils/helper-19.ts +1 -0
- package/src-ts/dist/utils/helper-2.ts +1 -0
- package/src-ts/dist/utils/helper-20.ts +1 -0
- package/src-ts/dist/utils/helper-21.ts +1 -0
- package/src-ts/dist/utils/helper-22.ts +1 -0
- package/src-ts/dist/utils/helper-23.ts +1 -0
- package/src-ts/dist/utils/helper-24.ts +1 -0
- package/src-ts/dist/utils/helper-25.ts +1 -0
- package/src-ts/dist/utils/helper-26.ts +1 -0
- package/src-ts/dist/utils/helper-27.ts +1 -0
- package/src-ts/dist/utils/helper-28.ts +1 -0
- package/src-ts/dist/utils/helper-29.ts +1 -0
- package/src-ts/dist/utils/helper-3.ts +1 -0
- package/src-ts/dist/utils/helper-30.ts +1 -0
- package/src-ts/dist/utils/helper-4.ts +1 -0
- package/src-ts/dist/utils/helper-5.ts +1 -0
- package/src-ts/dist/utils/helper-6.ts +1 -0
- package/src-ts/dist/utils/helper-7.ts +1 -0
- package/src-ts/dist/utils/helper-8.ts +1 -0
- package/src-ts/dist/utils/helper-9.ts +1 -0
- package/src-ts/dist/utils/insta-mqtt-helper.ts +128 -0
- package/src-ts/examples/listen-to-messages.ts +86 -0
- package/dist/errors/index.d.ts +0 -16
- package/dist/errors/index.js.map +0 -1
- package/dist/fbns/fbns.client.d.ts +0 -32
- package/dist/fbns/fbns.client.events.d.ts +0 -41
- package/dist/fbns/fbns.client.events.js.map +0 -1
- package/dist/fbns/fbns.client.js.map +0 -1
- package/dist/fbns/fbns.device-auth.d.ts +0 -17
- package/dist/fbns/fbns.device-auth.js.map +0 -1
- package/dist/fbns/fbns.types.d.ts +0 -83
- package/dist/fbns/fbns.types.js.map +0 -1
- package/dist/fbns/fbns.utilities.d.ts +0 -2
- package/dist/fbns/fbns.utilities.js.map +0 -1
- package/dist/fbns/index.d.ts +0 -4
- package/dist/fbns/index.js.map +0 -1
- package/dist/mqtt-shim.d.ts +0 -96
- package/dist/mqttot/index.d.ts +0 -4
- package/dist/mqttot/index.js.map +0 -1
- package/dist/mqttot/mqttot.client.d.ts +0 -39
- package/dist/mqttot/mqttot.client.js.map +0 -1
- package/dist/mqttot/mqttot.connect.request.packet.d.ts +0 -7
- package/dist/mqttot/mqttot.connect.request.packet.js.map +0 -1
- package/dist/mqttot/mqttot.connect.response.packet.d.ts +0 -7
- package/dist/mqttot/mqttot.connect.response.packet.js.map +0 -1
- package/dist/mqttot/mqttot.connection.d.ts +0 -57
- package/dist/mqttot/mqttot.connection.js.map +0 -1
- package/dist/package.json +0 -59
- package/dist/realtime/commands/commands.d.ts +0 -15
- package/dist/realtime/commands/commands.js.map +0 -1
- package/dist/realtime/commands/direct.commands.d.ts +0 -75
- package/dist/realtime/commands/direct.commands.js.map +0 -1
- package/dist/realtime/commands/enhanced.direct.commands.js.bak +0 -967
- package/dist/realtime/commands/index.d.ts +0 -2
- package/dist/realtime/commands/index.js.map +0 -1
- package/dist/realtime/messages/app-presence.event.d.ts +0 -9
- package/dist/realtime/messages/app-presence.event.js.map +0 -1
- package/dist/realtime/messages/index.d.ts +0 -3
- package/dist/realtime/messages/index.js.map +0 -1
- package/dist/realtime/messages/message-sync.message.d.ts +0 -222
- package/dist/realtime/messages/message-sync.message.js.map +0 -1
- package/dist/realtime/messages/realtime-sub.direct.data.d.ts +0 -11
- package/dist/realtime/messages/realtime-sub.direct.data.js.map +0 -1
- package/dist/realtime/messages/thread-update.message.d.ts +0 -68
- package/dist/realtime/messages/thread-update.message.js.map +0 -1
- package/dist/realtime/mixins/index.d.ts +0 -3
- package/dist/realtime/mixins/index.js.map +0 -1
- package/dist/realtime/mixins/message-sync.mixin.d.ts +0 -8
- package/dist/realtime/mixins/message-sync.mixin.js.map +0 -1
- package/dist/realtime/mixins/mixin.d.ts +0 -19
- package/dist/realtime/mixins/mixin.js.map +0 -1
- package/dist/realtime/mixins/realtime-sub.mixin.d.ts +0 -8
- package/dist/realtime/mixins/realtime-sub.mixin.js.map +0 -1
- package/dist/realtime/parsers/graphql.parser.d.ts +0 -15
- package/dist/realtime/parsers/graphql.parser.js.map +0 -1
- package/dist/realtime/parsers/index.d.ts +0 -6
- package/dist/realtime/parsers/index.js.map +0 -1
- package/dist/realtime/parsers/iris.parser.d.ts +0 -17
- package/dist/realtime/parsers/iris.parser.js.map +0 -1
- package/dist/realtime/parsers/json.parser.d.ts +0 -6
- package/dist/realtime/parsers/json.parser.js.map +0 -1
- package/dist/realtime/parsers/parser.d.ts +0 -9
- package/dist/realtime/parsers/parser.js.map +0 -1
- package/dist/realtime/parsers/region-hint.parser.d.ts +0 -12
- package/dist/realtime/parsers/region-hint.parser.js.map +0 -1
- package/dist/realtime/parsers/skywalker.parser.d.ts +0 -12
- package/dist/realtime/parsers/skywalker.parser.js.map +0 -1
- package/dist/realtime/proto/common.proto +0 -38
- package/dist/realtime/proto/direct.proto +0 -65
- package/dist/realtime/proto/ig-messages.proto +0 -83
- package/dist/realtime/proto/iris.proto +0 -188
- package/dist/realtime/subscriptions/graphql.subscription.d.ts +0 -47
- package/dist/realtime/subscriptions/graphql.subscription.js.map +0 -1
- package/dist/realtime/subscriptions/index.d.ts +0 -2
- package/dist/realtime/subscriptions/index.js.map +0 -1
- package/dist/realtime/subscriptions/skywalker.subscription.d.ts +0 -4
- package/dist/realtime/subscriptions/skywalker.subscription.js.map +0 -1
- package/dist/thrift/index.d.ts +0 -3
- package/dist/thrift/index.js.map +0 -1
- package/dist/thrift/thrift.d.ts +0 -59
- package/dist/thrift/thrift.js.map +0 -1
- package/dist/thrift/thrift.reading.d.ts +0 -41
- package/dist/thrift/thrift.reading.js.map +0 -1
- package/dist/thrift/thrift.writing.d.ts +0 -44
- package/dist/thrift/thrift.writing.js.map +0 -1
- /package/{dist → dist-ts/dist}/realtime/protocols/proto-definitions.js +0 -0
- /package/{dist → dist-ts/dist}/utils/helper-1.js +0 -0
- /package/{dist → dist-ts/dist}/utils/helper-10.js +0 -0
- /package/{dist → dist-ts/dist}/utils/helper-11.js +0 -0
- /package/{dist → dist-ts/dist}/utils/helper-12.js +0 -0
- /package/{dist → dist-ts/dist}/utils/helper-13.js +0 -0
- /package/{dist → dist-ts/dist}/utils/helper-14.js +0 -0
- /package/{dist → dist-ts/dist}/utils/helper-15.js +0 -0
- /package/{dist → dist-ts/dist}/utils/helper-16.js +0 -0
- /package/{dist → dist-ts/dist}/utils/helper-17.js +0 -0
- /package/{dist → dist-ts/dist}/utils/helper-18.js +0 -0
- /package/{dist → dist-ts/dist}/utils/helper-19.js +0 -0
- /package/{dist → dist-ts/dist}/utils/helper-2.js +0 -0
- /package/{dist → dist-ts/dist}/utils/helper-20.js +0 -0
- /package/{dist → dist-ts/dist}/utils/helper-21.js +0 -0
- /package/{dist → dist-ts/dist}/utils/helper-22.js +0 -0
- /package/{dist → dist-ts/dist}/utils/helper-23.js +0 -0
- /package/{dist → dist-ts/dist}/utils/helper-24.js +0 -0
- /package/{dist → dist-ts/dist}/utils/helper-25.js +0 -0
- /package/{dist → dist-ts/dist}/utils/helper-26.js +0 -0
- /package/{dist → dist-ts/dist}/utils/helper-27.js +0 -0
- /package/{dist → dist-ts/dist}/utils/helper-28.js +0 -0
- /package/{dist → dist-ts/dist}/utils/helper-29.js +0 -0
- /package/{dist → dist-ts/dist}/utils/helper-3.js +0 -0
- /package/{dist → dist-ts/dist}/utils/helper-30.js +0 -0
- /package/{dist → dist-ts/dist}/utils/helper-4.js +0 -0
- /package/{dist → dist-ts/dist}/utils/helper-5.js +0 -0
- /package/{dist → dist-ts/dist}/utils/helper-6.js +0 -0
- /package/{dist → dist-ts/dist}/utils/helper-7.js +0 -0
- /package/{dist → dist-ts/dist}/utils/helper-8.js +0 -0
- /package/{dist → dist-ts/dist}/utils/helper-9.js +0 -0
- /package/{dist → dist-ts/dist}/utils/insta-mqtt-helper.js +0 -0
- /package/{dist/constants/constants.js → src-ts/dist/constants/constants.ts} +0 -0
- /package/{dist/constants/index.js → src-ts/dist/constants/index.ts} +0 -0
- /package/{dist/core/client.js → src-ts/dist/core/client.ts} +0 -0
- /package/{dist/core/nav-chain.js → src-ts/dist/core/nav-chain.ts} +0 -0
- /package/{dist/core/repository.js → src-ts/dist/core/repository.ts} +0 -0
- /package/{dist/core/request.js → src-ts/dist/core/request.ts} +0 -0
- /package/{dist/core/state.js → src-ts/dist/core/state.ts} +0 -0
- /package/{dist/core/utils.js → src-ts/dist/core/utils.ts} +0 -0
- /package/{dist/downloadMedia.js → src-ts/dist/downloadMedia.ts} +0 -0
- /package/{dist/errors/index.js → src-ts/dist/errors/index.ts} +0 -0
- /package/{dist/extend.js → src-ts/dist/extend.ts} +0 -0
- /package/{dist/fbns/fbns.client.events.js → src-ts/dist/fbns/fbns.client.events.ts} +0 -0
- /package/{dist/fbns/fbns.client.js → src-ts/dist/fbns/fbns.client.ts} +0 -0
- /package/{dist/fbns/fbns.device-auth.js → src-ts/dist/fbns/fbns.device-auth.ts} +0 -0
- /package/{dist/fbns/fbns.types.js → src-ts/dist/fbns/fbns.types.ts} +0 -0
- /package/{dist/fbns/fbns.utilities.js → src-ts/dist/fbns/fbns.utilities.ts} +0 -0
- /package/{dist/fbns/index.js → src-ts/dist/fbns/index.ts} +0 -0
- /package/{dist/index.js → src-ts/dist/index.ts} +0 -0
- /package/{dist/mqtt-shim.js → src-ts/dist/mqtt-shim.ts} +0 -0
- /package/{dist/mqttot/index.js → src-ts/dist/mqttot/index.ts} +0 -0
- /package/{dist/mqttot/mqttot.client.js → src-ts/dist/mqttot/mqttot.client.ts} +0 -0
- /package/{dist/mqttot/mqttot.connect.request.packet.js → src-ts/dist/mqttot/mqttot.connect.request.packet.ts} +0 -0
- /package/{dist/mqttot/mqttot.connect.response.packet.js → src-ts/dist/mqttot/mqttot.connect.response.packet.ts} +0 -0
- /package/{dist/mqttot/mqttot.connection.js → src-ts/dist/mqttot/mqttot.connection.ts} +0 -0
- /package/{dist/realtime/commands/commands.js → src-ts/dist/realtime/commands/commands.ts} +0 -0
- /package/{dist/realtime/commands/direct.commands.js → src-ts/dist/realtime/commands/direct.commands.ts} +0 -0
- /package/{dist/realtime/commands/enhanced.direct.commands.js → src-ts/dist/realtime/commands/enhanced.direct.commands.ts} +0 -0
- /package/{dist/realtime/commands/index.js → src-ts/dist/realtime/commands/index.ts} +0 -0
- /package/{dist/realtime/delta-sync.manager.js → src-ts/dist/realtime/delta-sync.manager.ts} +0 -0
- /package/{dist/realtime/features/dm-sender.js → src-ts/dist/realtime/features/dm-sender.ts} +0 -0
- /package/{dist/realtime/features/error-handler.js → src-ts/dist/realtime/features/error-handler.ts} +0 -0
- /package/{dist/realtime/features/gap-handler.js → src-ts/dist/realtime/features/gap-handler.ts} +0 -0
- /package/{dist/realtime/features/persistent-logger.js → src-ts/dist/realtime/features/persistent-logger.ts} +0 -0
- /package/{dist/realtime/features/presence.manager.js → src-ts/dist/realtime/features/presence.manager.ts} +0 -0
- /package/{dist/realtime/features/session-health-monitor.js → src-ts/dist/realtime/features/session-health-monitor.ts} +0 -0
- /package/{dist/realtime/index.js → src-ts/dist/realtime/index.ts} +0 -0
- /package/{dist/realtime/messages/app-presence.event.js → src-ts/dist/realtime/messages/app-presence.event.ts} +0 -0
- /package/{dist/realtime/messages/index.js → src-ts/dist/realtime/messages/index.ts} +0 -0
- /package/{dist/realtime/messages/message-sync.message.js → src-ts/dist/realtime/messages/message-sync.message.ts} +0 -0
- /package/{dist/realtime/messages/realtime-sub.direct.data.js → src-ts/dist/realtime/messages/realtime-sub.direct.data.ts} +0 -0
- /package/{dist/realtime/messages/thread-update.message.js → src-ts/dist/realtime/messages/thread-update.message.ts} +0 -0
- /package/{dist/realtime/mixins/index.js → src-ts/dist/realtime/mixins/index.ts} +0 -0
- /package/{dist/realtime/mixins/message-sync.mixin.js → src-ts/dist/realtime/mixins/message-sync.mixin.ts} +0 -0
- /package/{dist/realtime/mixins/mixin.js → src-ts/dist/realtime/mixins/mixin.ts} +0 -0
- /package/{dist/realtime/mixins/presence-typing.mixin.js → src-ts/dist/realtime/mixins/presence-typing.mixin.ts} +0 -0
- /package/{dist/realtime/mixins/realtime-sub.mixin.js → src-ts/dist/realtime/mixins/realtime-sub.mixin.ts} +0 -0
- /package/{dist/realtime/parsers/graphql-parser.js → src-ts/dist/realtime/parsers/graphql-parser.ts} +0 -0
- /package/{dist/realtime/parsers/graphql.parser.js → src-ts/dist/realtime/parsers/graphql.parser.ts} +0 -0
- /package/{dist/realtime/parsers/index.js → src-ts/dist/realtime/parsers/index.ts} +0 -0
- /package/{dist/realtime/parsers/iris-parser.js → src-ts/dist/realtime/parsers/iris-parser.ts} +0 -0
- /package/{dist/realtime/parsers/iris.parser.js → src-ts/dist/realtime/parsers/iris.parser.ts} +0 -0
- /package/{dist/realtime/parsers/json-parser.js → src-ts/dist/realtime/parsers/json-parser.ts} +0 -0
- /package/{dist/realtime/parsers/json.parser.js → src-ts/dist/realtime/parsers/json.parser.ts} +0 -0
- /package/{dist/realtime/parsers/parser.js → src-ts/dist/realtime/parsers/parser.ts} +0 -0
- /package/{dist/realtime/parsers/region-hint-parser.js → src-ts/dist/realtime/parsers/region-hint-parser.ts} +0 -0
- /package/{dist/realtime/parsers/region-hint.parser.js → src-ts/dist/realtime/parsers/region-hint.parser.ts} +0 -0
- /package/{dist/realtime/parsers/skywalker-parser.js → src-ts/dist/realtime/parsers/skywalker-parser.ts} +0 -0
- /package/{dist/realtime/parsers/skywalker.parser.js → src-ts/dist/realtime/parsers/skywalker.parser.ts} +0 -0
- /package/{dist/realtime/parsers-advanced.js → src-ts/dist/realtime/parsers-advanced.ts} +0 -0
- /package/{dist/realtime/proto-parser.js → src-ts/dist/realtime/proto-parser.ts} +0 -0
- /package/{dist/realtime/protocols/iris.handshake.js → src-ts/dist/realtime/protocols/iris.handshake.ts} +0 -0
- /package/{dist/realtime/protocols/skywalker.protocol.js → src-ts/dist/realtime/protocols/skywalker.protocol.ts} +0 -0
- /package/{dist/realtime/realtime.client.events.js → src-ts/dist/realtime/realtime.client.events.ts} +0 -0
- /package/{dist/realtime/realtime.client.js → src-ts/dist/realtime/realtime.client.ts} +0 -0
- /package/{dist/realtime/realtime.service.js → src-ts/dist/realtime/realtime.service.ts} +0 -0
- /package/{dist/realtime/reconnect.manager.js → src-ts/dist/realtime/reconnect.manager.ts} +0 -0
- /package/{dist/realtime/session.manager.js → src-ts/dist/realtime/session.manager.ts} +0 -0
- /package/{dist/realtime/subscriptions/graphql.subscription.js → src-ts/dist/realtime/subscriptions/graphql.subscription.ts} +0 -0
- /package/{dist/realtime/subscriptions/index.js → src-ts/dist/realtime/subscriptions/index.ts} +0 -0
- /package/{dist/realtime/subscriptions/skywalker.subscription.js → src-ts/dist/realtime/subscriptions/skywalker.subscription.ts} +0 -0
- /package/{dist/realtime/topic-map.js → src-ts/dist/realtime/topic-map.ts} +0 -0
- /package/{dist/realtime/topic.js → src-ts/dist/realtime/topic.ts} +0 -0
- /package/{dist/repositories/account.repository.js → src-ts/dist/repositories/account.repository.ts} +0 -0
- /package/{dist/repositories/bloks.repository.js → src-ts/dist/repositories/bloks.repository.ts} +0 -0
- /package/{dist/repositories/captcha.repository.js → src-ts/dist/repositories/captcha.repository.ts} +0 -0
- /package/{dist/repositories/challenge.repository.js → src-ts/dist/repositories/challenge.repository.ts} +0 -0
- /package/{dist/repositories/clip.repository.js → src-ts/dist/repositories/clip.repository.ts} +0 -0
- /package/{dist/repositories/close-friends.repository.js → src-ts/dist/repositories/close-friends.repository.ts} +0 -0
- /package/{dist/repositories/collection.repository.js → src-ts/dist/repositories/collection.repository.ts} +0 -0
- /package/{dist/repositories/direct-thread.repository.js → src-ts/dist/repositories/direct-thread.repository.ts} +0 -0
- /package/{dist/repositories/direct.repository.js → src-ts/dist/repositories/direct.repository.ts} +0 -0
- /package/{dist/repositories/explore.repository.js → src-ts/dist/repositories/explore.repository.ts} +0 -0
- /package/{dist/repositories/fbsearch.repository.js → src-ts/dist/repositories/fbsearch.repository.ts} +0 -0
- /package/{dist/repositories/feed.repository.js → src-ts/dist/repositories/feed.repository.ts} +0 -0
- /package/{dist/repositories/friendship.repository.js → src-ts/dist/repositories/friendship.repository.ts} +0 -0
- /package/{dist/repositories/fundraiser.repository.js → src-ts/dist/repositories/fundraiser.repository.ts} +0 -0
- /package/{dist/repositories/hashtag.repository.js → src-ts/dist/repositories/hashtag.repository.ts} +0 -0
- /package/{dist/repositories/highlights.repository.js → src-ts/dist/repositories/highlights.repository.ts} +0 -0
- /package/{dist/repositories/insights.repository.js → src-ts/dist/repositories/insights.repository.ts} +0 -0
- /package/{dist/repositories/location.repository.js → src-ts/dist/repositories/location.repository.ts} +0 -0
- /package/{dist/repositories/media.repository.js → src-ts/dist/repositories/media.repository.ts} +0 -0
- /package/{dist/repositories/multiple-accounts.repository.js → src-ts/dist/repositories/multiple-accounts.repository.ts} +0 -0
- /package/{dist/repositories/news.repository.js → src-ts/dist/repositories/news.repository.ts} +0 -0
- /package/{dist/repositories/note.repository.js → src-ts/dist/repositories/note.repository.ts} +0 -0
- /package/{dist/repositories/notification.repository.js → src-ts/dist/repositories/notification.repository.ts} +0 -0
- /package/{dist/repositories/share.repository.js → src-ts/dist/repositories/share.repository.ts} +0 -0
- /package/{dist/repositories/signup.repository.js → src-ts/dist/repositories/signup.repository.ts} +0 -0
- /package/{dist/repositories/story.repository.js → src-ts/dist/repositories/story.repository.ts} +0 -0
- /package/{dist/repositories/timeline.repository.js → src-ts/dist/repositories/timeline.repository.ts} +0 -0
- /package/{dist/repositories/totp.repository.js → src-ts/dist/repositories/totp.repository.ts} +0 -0
- /package/{dist/repositories/track.repository.js → src-ts/dist/repositories/track.repository.ts} +0 -0
- /package/{dist/repositories/upload.repository.js → src-ts/dist/repositories/upload.repository.ts} +0 -0
- /package/{dist/repositories/user.repository.js → src-ts/dist/repositories/user.repository.ts} +0 -0
- /package/{dist/sendmedia/index.js → src-ts/dist/sendmedia/index.ts} +0 -0
- /package/{dist/sendmedia/sendFile.js → src-ts/dist/sendmedia/sendFile.ts} +0 -0
- /package/{dist/sendmedia/sendPhoto.js → src-ts/dist/sendmedia/sendPhoto.ts} +0 -0
- /package/{dist/sendmedia/sendRavenPhoto.js → src-ts/dist/sendmedia/sendRavenPhoto.ts} +0 -0
- /package/{dist/sendmedia/sendRavenVideo.js → src-ts/dist/sendmedia/sendRavenVideo.ts} +0 -0
- /package/{dist/sendmedia/uploadPhoto.js → src-ts/dist/sendmedia/uploadPhoto.ts} +0 -0
- /package/{dist/sendmedia/uploadfFile.js → src-ts/dist/sendmedia/uploadfFile.ts} +0 -0
- /package/{dist/services/live.service.js → src-ts/dist/services/live.service.ts} +0 -0
- /package/{dist/services/search.service.js → src-ts/dist/services/search.service.ts} +0 -0
- /package/{dist/shared/index.js → src-ts/dist/shared/index.ts} +0 -0
- /package/{dist/shared/shared.js → src-ts/dist/shared/shared.ts} +0 -0
- /package/{dist/thrift/index.js → src-ts/dist/thrift/index.ts} +0 -0
- /package/{dist/thrift/thrift.reading.js → src-ts/dist/thrift/thrift.reading.ts} +0 -0
- /package/{dist/thrift/thrift.js → src-ts/dist/thrift/thrift.ts} +0 -0
- /package/{dist/thrift/thrift.writing.js → src-ts/dist/thrift/thrift.writing.ts} +0 -0
- /package/{dist/types/index.js → src-ts/dist/types/index.ts} +0 -0
- /package/{dist/useMultiFileAuthState.js → src-ts/dist/useMultiFileAuthState.ts} +0 -0
- /package/{dist/utils/index.js → src-ts/dist/utils/index.ts} +0 -0
|
@@ -0,0 +1,322 @@
|
|
|
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
|
+
const shared_1 = require("../shared");
|
|
7
|
+
const mqttot_connect_request_packet_1 = require("./mqttot.connect.request.packet");
|
|
8
|
+
// Use external mqtts package (must be installed in your project)
|
|
9
|
+
const mqtts_1 = require("mqtts");
|
|
10
|
+
const errors_1 = require("../errors");
|
|
11
|
+
const mqttot_connect_response_packet_1 = require("./mqttot.connect.response.packet");
|
|
12
|
+
/**
|
|
13
|
+
* MQTToTClient
|
|
14
|
+
* - Subclasses external mqtts.MqttClient
|
|
15
|
+
* - Adds Instagram-specific helpers (connect flow, compressed publish)
|
|
16
|
+
* - Adds keepalive (PING) and robust reconnect with exponential backoff
|
|
17
|
+
*
|
|
18
|
+
* Comments/notes are inline. This file is ready to paste into your project.
|
|
19
|
+
*/
|
|
20
|
+
class MQTToTClient extends mqtts_1.MqttClient {
|
|
21
|
+
/**
|
|
22
|
+
* @param {Object} options
|
|
23
|
+
* options:
|
|
24
|
+
* - url: broker host
|
|
25
|
+
* - socksOptions: optional proxy options
|
|
26
|
+
* - autoReconnect: boolean
|
|
27
|
+
* - payloadProvider: async function returning connection payload (Thrift blob)
|
|
28
|
+
* - requirePayload: boolean (legacy behavior)
|
|
29
|
+
* - additionalOptions: transport options passthrough
|
|
30
|
+
*/
|
|
31
|
+
constructor(options) {
|
|
32
|
+
super({
|
|
33
|
+
autoReconnect: options.autoReconnect,
|
|
34
|
+
readMap: {
|
|
35
|
+
...mqtts_1.DefaultPacketReadMap,
|
|
36
|
+
[mqtts_1.PacketType.ConnAck]: mqttot_connect_response_packet_1.readConnectResponsePacket,
|
|
37
|
+
},
|
|
38
|
+
writeMap: {
|
|
39
|
+
...mqtts_1.DefaultPacketWriteMap,
|
|
40
|
+
[mqtts_1.PacketType.Connect]: mqttot_connect_request_packet_1.writeConnectRequestPacket,
|
|
41
|
+
},
|
|
42
|
+
transport: options.socksOptions
|
|
43
|
+
? new mqtts_1.SocksTlsTransport({
|
|
44
|
+
host: options.url,
|
|
45
|
+
port: 443,
|
|
46
|
+
proxyOptions: options.socksOptions,
|
|
47
|
+
additionalOptions: options.additionalOptions,
|
|
48
|
+
})
|
|
49
|
+
: new mqtts_1.TlsTransport({
|
|
50
|
+
host: options.url,
|
|
51
|
+
port: 443,
|
|
52
|
+
additionalOptions: options.additionalOptions,
|
|
53
|
+
}),
|
|
54
|
+
});
|
|
55
|
+
// Save options for reconnect attempts
|
|
56
|
+
this._options = options || {};
|
|
57
|
+
// Debug helper prefixed with broker url
|
|
58
|
+
this.mqttotDebug = (msg, ...args) => (0, shared_1.debugChannel)('mqttot')(`${this._options.url}: ${msg}`, ...args);
|
|
59
|
+
this.connectPayloadProvider = options.payloadProvider;
|
|
60
|
+
this.mqttotDebug(`Creating client`);
|
|
61
|
+
// Register listeners (errors, disconnect, pingresps, etc.)
|
|
62
|
+
this.registerListeners();
|
|
63
|
+
this.requirePayload = options.requirePayload;
|
|
64
|
+
this._keepaliveMs = (typeof options.keepaliveMs === 'number') ? options.keepaliveMs : (8 * 60 * 1000);
|
|
65
|
+
this._consecutivePingFailures = 0;
|
|
66
|
+
this._startKeepalive();
|
|
67
|
+
}
|
|
68
|
+
_startKeepalive() {
|
|
69
|
+
try {
|
|
70
|
+
if (this._keepaliveTimer)
|
|
71
|
+
clearInterval(this._keepaliveTimer);
|
|
72
|
+
const jitter = Math.floor(Math.random() * 30000);
|
|
73
|
+
this._keepaliveTimer = setInterval(() => {
|
|
74
|
+
try {
|
|
75
|
+
if (typeof this.ping === 'function') {
|
|
76
|
+
this.mqttotDebug('Sending PINGREQ (keepalive)');
|
|
77
|
+
const res = this.ping();
|
|
78
|
+
if (res && typeof res.then === 'function') {
|
|
79
|
+
res.then(() => {
|
|
80
|
+
this._consecutivePingFailures = 0;
|
|
81
|
+
}).catch((e) => {
|
|
82
|
+
this._consecutivePingFailures++;
|
|
83
|
+
this.mqttotDebug(`Ping failed (${this._consecutivePingFailures}): ${(e === null || e === void 0 ? void 0 : e.message) || e}`);
|
|
84
|
+
if (this._consecutivePingFailures >= 3) {
|
|
85
|
+
this.mqttotDebug('3 consecutive ping failures - emitting disconnect for reconnect');
|
|
86
|
+
this._consecutivePingFailures = 0;
|
|
87
|
+
this.emit('disconnect', 'ping_failure');
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
this.mqttotDebug('ping() not available - keepalive skipped');
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
catch (e) {
|
|
97
|
+
this.mqttotDebug(`Ping error: ${(e === null || e === void 0 ? void 0 : e.message) || e}`);
|
|
98
|
+
}
|
|
99
|
+
}, this._keepaliveMs + jitter);
|
|
100
|
+
}
|
|
101
|
+
catch (e) {
|
|
102
|
+
this.mqttotDebug(`Keepalive setup error: ${(e === null || e === void 0 ? void 0 : e.message) || e}`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Stop keepalive timer (call on explicit close/disconnect)
|
|
107
|
+
*/
|
|
108
|
+
_stopKeepalive() {
|
|
109
|
+
try {
|
|
110
|
+
if (this._keepaliveTimer) {
|
|
111
|
+
clearInterval(this._keepaliveTimer);
|
|
112
|
+
this._keepaliveTimer = null;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
catch (e) {
|
|
116
|
+
// ignore
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Register event listeners on the underlying mqtt client to handle:
|
|
121
|
+
* - errors / warnings
|
|
122
|
+
* - disconnects -> attempt reconnection with exponential backoff
|
|
123
|
+
* - pingresp events for diagnostics
|
|
124
|
+
*/
|
|
125
|
+
registerListeners() {
|
|
126
|
+
const printErrorOrWarning = (type) => (e) => {
|
|
127
|
+
if (typeof e === 'string') {
|
|
128
|
+
this.mqttotDebug(`${type}: ${e}`);
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
this.mqttotDebug(`${type}: ${e.message}\n\tStack: ${e.stack}`);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
// Attach diagnostics
|
|
135
|
+
this.on('error', printErrorOrWarning('Error'));
|
|
136
|
+
this.on('warning', printErrorOrWarning('Warning'));
|
|
137
|
+
// Listen to ping responses if the library emits them
|
|
138
|
+
this.on('pingresp', () => {
|
|
139
|
+
this.mqttotDebug('Received PINGRESP (keepalive ok)');
|
|
140
|
+
});
|
|
141
|
+
this.on('disconnect', async (reason) => {
|
|
142
|
+
try {
|
|
143
|
+
this.mqttotDebug(`Disconnected. Reason: ${reason}`);
|
|
144
|
+
this._stopKeepalive();
|
|
145
|
+
if (this._options && this._options.autoReconnect === false) {
|
|
146
|
+
this.mqttotDebug('autoReconnect disabled; will not attempt reconnect.');
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
let delay = 3000 + Math.floor(Math.random() * 2000);
|
|
150
|
+
const maxAttempts = 12;
|
|
151
|
+
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
152
|
+
try {
|
|
153
|
+
this.mqttotDebug(`Reconnect attempt #${attempt + 1} (delay ${delay}ms)`);
|
|
154
|
+
try {
|
|
155
|
+
this.reset();
|
|
156
|
+
}
|
|
157
|
+
catch (_e) { }
|
|
158
|
+
try {
|
|
159
|
+
this.transport.reset();
|
|
160
|
+
}
|
|
161
|
+
catch (_e) { }
|
|
162
|
+
try {
|
|
163
|
+
this.transformer = this.createTransformer();
|
|
164
|
+
}
|
|
165
|
+
catch (_e) { }
|
|
166
|
+
await this.connect(this._options);
|
|
167
|
+
this.mqttotDebug('Reconnected successfully');
|
|
168
|
+
this._consecutivePingFailures = 0;
|
|
169
|
+
this._startKeepalive();
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
catch (err) {
|
|
173
|
+
const errMsg = ((err === null || err === void 0 ? void 0 : err.message) || String(err)).toLowerCase();
|
|
174
|
+
const isRateLimit = errMsg.includes('rate') || errMsg.includes('throttl') || errMsg.includes('429');
|
|
175
|
+
this.mqttotDebug(`Reconnect attempt #${attempt + 1} failed: ${(err === null || err === void 0 ? void 0 : err.message) || err}`);
|
|
176
|
+
if (isRateLimit) {
|
|
177
|
+
delay = Math.min(delay * 3, 10 * 60 * 1000);
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
delay = Math.min(delay * 2, 5 * 60 * 1000);
|
|
181
|
+
}
|
|
182
|
+
const jitter = Math.floor(Math.random() * Math.min(delay * 0.2, 5000));
|
|
183
|
+
await new Promise(r => setTimeout(r, delay + jitter));
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
this.mqttotDebug(`Exceeded ${maxAttempts} reconnect attempts. Waiting for external trigger.`);
|
|
187
|
+
}
|
|
188
|
+
catch (e) {
|
|
189
|
+
this.mqttotDebug(`Error in disconnect handler: ${(e === null || e === void 0 ? void 0 : e.message) || e}`);
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* connect override
|
|
195
|
+
* - Waits for connect payload from provider before calling parent connect
|
|
196
|
+
*/
|
|
197
|
+
async connect(options) {
|
|
198
|
+
// Acquire the payload (Thrift serialized connection blob) before connecting.
|
|
199
|
+
if (typeof this.connectPayloadProvider === 'function') {
|
|
200
|
+
try {
|
|
201
|
+
this.connectPayload = await this.connectPayloadProvider();
|
|
202
|
+
}
|
|
203
|
+
catch (e) {
|
|
204
|
+
this.mqttotDebug(`connectPayloadProvider failed: ${(e === null || e === void 0 ? void 0 : e.message) || e}`);
|
|
205
|
+
throw e;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
this.mqttotDebug('No connectPayloadProvider provided; proceeding without payload');
|
|
210
|
+
this.connectPayload = null;
|
|
211
|
+
}
|
|
212
|
+
// Call super.connect to establish connection
|
|
213
|
+
return super.connect(options);
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Return an Instagram-flavored connect flow function for the mqtts client.
|
|
217
|
+
* If payload is missing but CONNACK indicates success, accept it (robustness).
|
|
218
|
+
*/
|
|
219
|
+
getConnectFlow() {
|
|
220
|
+
if (!this.connectPayload) {
|
|
221
|
+
throw new mqtts_1.IllegalStateError('Called getConnectFlow() before calling connect()');
|
|
222
|
+
}
|
|
223
|
+
return mqttotConnectFlow(this.connectPayload, this.requirePayload);
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Compresses payload using shared.compressDeflate and publishes with QoS 0.
|
|
227
|
+
* QoS 0 forced for Instagram edge stability (avoid PUBACK waits causing reconnect loops).
|
|
228
|
+
*/
|
|
229
|
+
async mqttotPublish(message) {
|
|
230
|
+
this.mqttotDebug(`Publishing ${message.payload.byteLength || message.payload.length} bytes to topic ${message.topic}`);
|
|
231
|
+
const compressed = await (0, shared_1.compressDeflate)(message.payload);
|
|
232
|
+
return await this.publish({
|
|
233
|
+
topic: message.topic,
|
|
234
|
+
payload: compressed,
|
|
235
|
+
qosLevel: 0, // FORCED: QoS 0 for stability on Instagram edge
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Helper to listen for a specific topic and run transformer before calling handler.
|
|
240
|
+
*/
|
|
241
|
+
listen(configOrTopic, handler) {
|
|
242
|
+
if (typeof configOrTopic === 'string') {
|
|
243
|
+
const topicId = configOrTopic;
|
|
244
|
+
this.mqttotDebug(`[LISTEN] Setting up raw listener on topic ${topicId}`);
|
|
245
|
+
const listener = async (msg) => {
|
|
246
|
+
if (msg.topic === topicId) {
|
|
247
|
+
try {
|
|
248
|
+
handler(msg);
|
|
249
|
+
}
|
|
250
|
+
catch (e) {
|
|
251
|
+
this.mqttotDebug(`Error in handler for topic ${topicId}: ${(e === null || e === void 0 ? void 0 : e.message) || e}`);
|
|
252
|
+
this.emit('error', e);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
this.on('message', listener);
|
|
257
|
+
return () => { this.removeListener('message', listener); };
|
|
258
|
+
}
|
|
259
|
+
const config = configOrTopic;
|
|
260
|
+
this.mqttotDebug(`[LISTEN] Setting up listener on topic ${config.topic} with transformer`);
|
|
261
|
+
const listener = async (msg) => {
|
|
262
|
+
if (msg.topic === config.topic) {
|
|
263
|
+
try {
|
|
264
|
+
const data = await config.transformer({ payload: msg.payload });
|
|
265
|
+
handler(data);
|
|
266
|
+
}
|
|
267
|
+
catch (e) {
|
|
268
|
+
this.mqttotDebug(`Error in transformer for topic ${config.topic}: ${(e === null || e === void 0 ? void 0 : e.message) || e}`);
|
|
269
|
+
this.emit('error', e);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
this.on('message', listener);
|
|
274
|
+
return () => { this.removeListener('message', listener); };
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Clean shutdown helper: stop keepalive & close
|
|
278
|
+
*/
|
|
279
|
+
async gracefulClose() {
|
|
280
|
+
try {
|
|
281
|
+
this._stopKeepalive();
|
|
282
|
+
if (typeof super.close === 'function') {
|
|
283
|
+
// some libs provide close() or end()
|
|
284
|
+
await super.close();
|
|
285
|
+
}
|
|
286
|
+
else if (typeof super.end === 'function') {
|
|
287
|
+
await super.end();
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
catch (e) {
|
|
291
|
+
this.mqttotDebug(`Error during gracefulClose: ${(e === null || e === void 0 ? void 0 : e.message) || e}`);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
exports.MQTToTClient = MQTToTClient;
|
|
296
|
+
/**
|
|
297
|
+
* mqttotConnectFlow
|
|
298
|
+
* - Returns a flow object that the mqtts client uses to perform CONNECT/CONNACK handshake.
|
|
299
|
+
* - Changed behavior: treat CONNACK success as success even if payload missing (robustness).
|
|
300
|
+
*/
|
|
301
|
+
function mqttotConnectFlow(payload, requirePayload) {
|
|
302
|
+
return (success, error) => ({
|
|
303
|
+
start: () => ({
|
|
304
|
+
type: mqtts_1.PacketType.Connect,
|
|
305
|
+
options: {
|
|
306
|
+
payload,
|
|
307
|
+
keepAlive: 60,
|
|
308
|
+
},
|
|
309
|
+
}),
|
|
310
|
+
accept: mqtts_1.isConnAck,
|
|
311
|
+
next: (packet) => {
|
|
312
|
+
if (packet.isSuccess) {
|
|
313
|
+
// Accept success even if payload is empty to avoid noisy errors
|
|
314
|
+
success(packet);
|
|
315
|
+
}
|
|
316
|
+
else {
|
|
317
|
+
error(new errors_1.ConnectionFailedError(`CONNACK returnCode: ${packet.returnCode} errorName: ${packet.errorName}`));
|
|
318
|
+
}
|
|
319
|
+
},
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
exports.mqttotConnectFlow = mqttotConnectFlow;
|
|
@@ -0,0 +1,8 @@
|
|
|
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;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readConnectResponsePacket = exports.MQTToTConnectResponsePacket = void 0;
|
|
4
|
+
const mqtts_1 = require("mqtts");
|
|
5
|
+
class MQTToTConnectResponsePacket extends mqtts_1.ConnectResponsePacket {
|
|
6
|
+
constructor(ackFlags, returnCode, payload) {
|
|
7
|
+
super(ackFlags, returnCode);
|
|
8
|
+
this.payload = payload;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.MQTToTConnectResponsePacket = MQTToTConnectResponsePacket;
|
|
12
|
+
function readConnectResponsePacket(stream, remaining) {
|
|
13
|
+
const ack = stream.readByte();
|
|
14
|
+
const returnCode = stream.readByte();
|
|
15
|
+
if (ack > 1) {
|
|
16
|
+
throw new Error('Invalid ack');
|
|
17
|
+
}
|
|
18
|
+
else if (returnCode > 5) {
|
|
19
|
+
throw new Error('Invalid return code');
|
|
20
|
+
}
|
|
21
|
+
return new MQTToTConnectResponsePacket(ack, returnCode, remaining > 2 ? stream.readStringAsBuffer() : Buffer.alloc(0));
|
|
22
|
+
}
|
|
23
|
+
exports.readConnectResponsePacket = readConnectResponsePacket;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MQTToTConnection = void 0;
|
|
4
|
+
const thrift_1 = require("../thrift");
|
|
5
|
+
class MQTToTConnection {
|
|
6
|
+
constructor(connectionData) {
|
|
7
|
+
this.fbnsConnectionData = connectionData;
|
|
8
|
+
}
|
|
9
|
+
toThrift() {
|
|
10
|
+
// Clone safely – DO NOT mutate original objects used by MQTT
|
|
11
|
+
const connCopy = Object.assign({}, this.fbnsConnectionData);
|
|
12
|
+
const originalClientInfo = this.fbnsConnectionData && this.fbnsConnectionData.clientInfo;
|
|
13
|
+
const clientInfoCopy = originalClientInfo ? Object.assign({}, originalClientInfo) : undefined;
|
|
14
|
+
if (clientInfoCopy) {
|
|
15
|
+
// ✅ MQTT REQUIRES STRING
|
|
16
|
+
if (typeof clientInfoCopy.userAgent !== 'string' || !clientInfoCopy.userAgent) {
|
|
17
|
+
clientInfoCopy.userAgent = 'Instagram 415.0.0.36.76 Android';
|
|
18
|
+
}
|
|
19
|
+
// ✅ MQTT REQUIRES STRING
|
|
20
|
+
if (typeof clientInfoCopy.clientType !== 'string' || !clientInfoCopy.clientType) {
|
|
21
|
+
clientInfoCopy.clientType = 'com.instagram.android';
|
|
22
|
+
}
|
|
23
|
+
connCopy.clientInfo = clientInfoCopy;
|
|
24
|
+
}
|
|
25
|
+
// ✅ Thrift will serialize binary fields correctly
|
|
26
|
+
return (0, thrift_1.thriftWriteFromObject)(connCopy, MQTToTConnection.thriftConfig);
|
|
27
|
+
}
|
|
28
|
+
toString() {
|
|
29
|
+
return this.toThrift().toString();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.MQTToTConnection = MQTToTConnection;
|
|
33
|
+
MQTToTConnection.thriftConfig = [
|
|
34
|
+
thrift_1.ThriftDescriptors.binary('clientIdentifier', 1),
|
|
35
|
+
thrift_1.ThriftDescriptors.binary('willTopic', 2),
|
|
36
|
+
thrift_1.ThriftDescriptors.binary('willMessage', 3),
|
|
37
|
+
thrift_1.ThriftDescriptors.struct('clientInfo', 4, [
|
|
38
|
+
thrift_1.ThriftDescriptors.int64('userId', 1),
|
|
39
|
+
thrift_1.ThriftDescriptors.binary('userAgent', 2),
|
|
40
|
+
thrift_1.ThriftDescriptors.int64('clientCapabilities', 3),
|
|
41
|
+
thrift_1.ThriftDescriptors.int64('endpointCapabilities', 4),
|
|
42
|
+
thrift_1.ThriftDescriptors.int32('publishFormat', 5),
|
|
43
|
+
thrift_1.ThriftDescriptors.boolean('noAutomaticForeground', 6),
|
|
44
|
+
thrift_1.ThriftDescriptors.boolean('makeUserAvailableInForeground', 7),
|
|
45
|
+
thrift_1.ThriftDescriptors.binary('deviceId', 8),
|
|
46
|
+
thrift_1.ThriftDescriptors.boolean('isInitiallyForeground', 9),
|
|
47
|
+
thrift_1.ThriftDescriptors.int32('networkType', 10),
|
|
48
|
+
thrift_1.ThriftDescriptors.int32('networkSubtype', 11),
|
|
49
|
+
thrift_1.ThriftDescriptors.int64('clientMqttSessionId', 12),
|
|
50
|
+
thrift_1.ThriftDescriptors.binary('clientIpAddress', 13),
|
|
51
|
+
thrift_1.ThriftDescriptors.listOfInt32('subscribeTopics', 14),
|
|
52
|
+
thrift_1.ThriftDescriptors.binary('clientType', 15),
|
|
53
|
+
thrift_1.ThriftDescriptors.int64('appId', 16),
|
|
54
|
+
thrift_1.ThriftDescriptors.boolean('overrideNectarLogging', 17),
|
|
55
|
+
thrift_1.ThriftDescriptors.binary('connectTokenHash', 18),
|
|
56
|
+
thrift_1.ThriftDescriptors.binary('regionPreference', 19),
|
|
57
|
+
thrift_1.ThriftDescriptors.binary('deviceSecret', 20),
|
|
58
|
+
thrift_1.ThriftDescriptors.byte('clientStack', 21),
|
|
59
|
+
thrift_1.ThriftDescriptors.int64('fbnsConnectionKey', 22),
|
|
60
|
+
thrift_1.ThriftDescriptors.binary('fbnsConnectionSecret', 23),
|
|
61
|
+
thrift_1.ThriftDescriptors.binary('fbnsDeviceId', 24),
|
|
62
|
+
thrift_1.ThriftDescriptors.binary('fbnsDeviceSecret', 25),
|
|
63
|
+
thrift_1.ThriftDescriptors.int64('anotherUnknown', 26),
|
|
64
|
+
]),
|
|
65
|
+
thrift_1.ThriftDescriptors.binary('password', 5), thrift_1.ThriftDescriptors.listOfBinary('getDiffsRequests', 6),
|
|
66
|
+
thrift_1.ThriftDescriptors.binary('zeroRatingTokenHash', 9),
|
|
67
|
+
thrift_1.ThriftDescriptors.mapBinaryBinary('appSpecificInfo', 10),
|
|
68
|
+
];
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Commands = void 0;
|
|
4
|
+
const shared_1 = require("../../shared");
|
|
5
|
+
class Commands {
|
|
6
|
+
constructor(client) {
|
|
7
|
+
this.client = client;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Publish a compressed payload to a topic.
|
|
11
|
+
* - Forces QoS 0 (no PUBACK wait) because Instagram internal MQTT often
|
|
12
|
+
* doesn't reply PUBACK for these internal topics and QoS1 causes timeouts
|
|
13
|
+
* and reconnect instability.
|
|
14
|
+
* - No-op if client is not connected to avoid "Socket not writable" errors.
|
|
15
|
+
* - Defensive checks: if the client exposes .connected or .isConnected(), respect them.
|
|
16
|
+
*/
|
|
17
|
+
async publishToTopic(topic, compressedData, qos = 0) {
|
|
18
|
+
try {
|
|
19
|
+
// Defensive: ensure we have a client
|
|
20
|
+
if (!this.client)
|
|
21
|
+
return;
|
|
22
|
+
// If client exposes a boolean 'connected' flag, respect it
|
|
23
|
+
if (typeof this.client.connected !== 'undefined' && !this.client.connected) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
// If client exposes an isConnected() method, respect it
|
|
27
|
+
if (typeof this.client.isConnected === 'function' && !this.client.isConnected()) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
// Build payload buffer
|
|
31
|
+
const payloadBuf = compressedData instanceof Buffer ? compressedData : Buffer.from(compressedData);
|
|
32
|
+
// Always publish with QoS 0 for stability on IG edge MQTT
|
|
33
|
+
return this.client.publish({
|
|
34
|
+
topic,
|
|
35
|
+
payload: payloadBuf,
|
|
36
|
+
qosLevel: 0,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
// Swallow non-fatal publish errors. Upper layers/watchdog should handle reconnections.
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* updateSubscriptions used by RealtimeClient for keepalive / subscription refreshes.
|
|
46
|
+
* - Compresses the subscription payload and publishes with QoS 0.
|
|
47
|
+
* - Skips publishing if the MQTT client doesn't appear ready.
|
|
48
|
+
*/
|
|
49
|
+
async updateSubscriptions(options) {
|
|
50
|
+
try {
|
|
51
|
+
if (!this.client)
|
|
52
|
+
return;
|
|
53
|
+
// Defensive connection checks
|
|
54
|
+
if (typeof this.client.connected !== 'undefined' && !this.client.connected)
|
|
55
|
+
return;
|
|
56
|
+
if (typeof this.client.isConnected === 'function' && !this.client.isConnected())
|
|
57
|
+
return;
|
|
58
|
+
const payload = await (0, shared_1.compressDeflate)(JSON.stringify(options.data || {}));
|
|
59
|
+
return this.publishToTopic(options.topic.id, payload, 0);
|
|
60
|
+
}
|
|
61
|
+
catch (e) {
|
|
62
|
+
// Non-fatal — avoid bubbling errors from keepalive timers
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.Commands = Commands;
|