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,437 @@
|
|
|
1
|
+
const EventEmitter = require('events');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const State = require('./state');
|
|
5
|
+
const Request = require('./request');
|
|
6
|
+
const AccountRepository = require('../repositories/account.repository');
|
|
7
|
+
const UserRepository = require('../repositories/user.repository');
|
|
8
|
+
const DirectRepository = require('../repositories/direct.repository');
|
|
9
|
+
const DirectThreadRepository = require('../repositories/direct-thread.repository');
|
|
10
|
+
const MediaRepository = require('../repositories/media.repository');
|
|
11
|
+
const UploadRepository = require('../repositories/upload.repository');
|
|
12
|
+
const StoryRepository = require('../repositories/story.repository');
|
|
13
|
+
const FeedRepository = require('../repositories/feed.repository');
|
|
14
|
+
const FriendshipRepository = require('../repositories/friendship.repository');
|
|
15
|
+
const LocationRepository = require('../repositories/location.repository');
|
|
16
|
+
const HashtagRepository = require('../repositories/hashtag.repository');
|
|
17
|
+
const NewsRepository = require('../repositories/news.repository');
|
|
18
|
+
const CollectionRepository = require('../repositories/collection.repository');
|
|
19
|
+
const CloseFriendsRepository = require('../repositories/close-friends.repository');
|
|
20
|
+
const ClipRepository = require('../repositories/clip.repository');
|
|
21
|
+
const TimelineRepository = require('../repositories/timeline.repository');
|
|
22
|
+
const InsightsRepository = require('../repositories/insights.repository');
|
|
23
|
+
const NoteRepository = require('../repositories/note.repository');
|
|
24
|
+
const NotificationRepository = require('../repositories/notification.repository');
|
|
25
|
+
const SignupRepository = require('../repositories/signup.repository');
|
|
26
|
+
const TOTPRepository = require('../repositories/totp.repository');
|
|
27
|
+
const BloksRepository = require('../repositories/bloks.repository');
|
|
28
|
+
const ChallengeRepository = require('../repositories/challenge.repository');
|
|
29
|
+
const ShareRepository = require('../repositories/share.repository');
|
|
30
|
+
const TrackRepository = require('../repositories/track.repository');
|
|
31
|
+
const ExploreRepository = require('../repositories/explore.repository');
|
|
32
|
+
const FBSearchRepository = require('../repositories/fbsearch.repository');
|
|
33
|
+
const FundraiserRepository = require('../repositories/fundraiser.repository');
|
|
34
|
+
const MultipleAccountsRepository = require('../repositories/multiple-accounts.repository');
|
|
35
|
+
const CaptchaRepository = require('../repositories/captcha.repository');
|
|
36
|
+
const HighlightsRepository = require('../repositories/highlights.repository');
|
|
37
|
+
const SearchService = require('../services/search.service');
|
|
38
|
+
const LiveService = require('../services/live.service');
|
|
39
|
+
/**
|
|
40
|
+
* IgApiClient
|
|
41
|
+
*
|
|
42
|
+
* - Păstrăm în totalitate funcționalitatea existentă (login/logout/isLoggedIn/saveSession/loadSession/isSessionValid/destroy)
|
|
43
|
+
* - Am eliminat complet stratul Realtime (WebSocket). Orice cod dependent de realtime trebuie migrat separat.
|
|
44
|
+
* - Am adăugat un helper generic `retryAsync(fn, opts)` pentru retry/backoff la operații asincrone (utile pentru request-uri).
|
|
45
|
+
*/
|
|
46
|
+
class IgApiClient extends EventEmitter {
|
|
47
|
+
constructor() {
|
|
48
|
+
super();
|
|
49
|
+
this.state = new State();
|
|
50
|
+
this.request = new Request(this);
|
|
51
|
+
this.navChain = this.request.navChain;
|
|
52
|
+
// Initialize repositories
|
|
53
|
+
this.account = new AccountRepository(this);
|
|
54
|
+
this.user = new UserRepository(this);
|
|
55
|
+
this.direct = new DirectRepository(this);
|
|
56
|
+
this.directThread = new DirectThreadRepository(this);
|
|
57
|
+
this.media = new MediaRepository(this);
|
|
58
|
+
this.upload = new UploadRepository(this);
|
|
59
|
+
this.story = new StoryRepository(this);
|
|
60
|
+
this.feed = new FeedRepository(this);
|
|
61
|
+
this.friendship = new FriendshipRepository(this);
|
|
62
|
+
this.location = new LocationRepository(this);
|
|
63
|
+
this.hashtag = new HashtagRepository(this);
|
|
64
|
+
this.news = new NewsRepository(this);
|
|
65
|
+
this.collection = new CollectionRepository(this);
|
|
66
|
+
this.closeFriends = new CloseFriendsRepository(this);
|
|
67
|
+
this.clip = new ClipRepository(this);
|
|
68
|
+
this.timeline = new TimelineRepository(this);
|
|
69
|
+
this.insights = new InsightsRepository(this);
|
|
70
|
+
this.note = new NoteRepository(this);
|
|
71
|
+
this.notification = new NotificationRepository(this);
|
|
72
|
+
this.signup = new SignupRepository(this);
|
|
73
|
+
this.totp = new TOTPRepository(this);
|
|
74
|
+
this.bloks = new BloksRepository(this);
|
|
75
|
+
this.challenge = new ChallengeRepository(this);
|
|
76
|
+
this.share = new ShareRepository(this);
|
|
77
|
+
this.track = new TrackRepository(this);
|
|
78
|
+
this.explore = new ExploreRepository(this);
|
|
79
|
+
this.fbsearch = new FBSearchRepository(this);
|
|
80
|
+
this.fundraiser = new FundraiserRepository(this);
|
|
81
|
+
this.multipleAccounts = new MultipleAccountsRepository(this);
|
|
82
|
+
this.captcha = new CaptchaRepository(this);
|
|
83
|
+
this.highlights = new HighlightsRepository(this);
|
|
84
|
+
// Initialize services
|
|
85
|
+
this.search = new SearchService(this);
|
|
86
|
+
this.live = new LiveService(this);
|
|
87
|
+
// Create dm object for easier access (keeps backward compatibility)
|
|
88
|
+
this.dm = {
|
|
89
|
+
send: this.direct.send.bind(this.direct),
|
|
90
|
+
sendToGroup: this.directThread.sendToGroup.bind(this.directThread),
|
|
91
|
+
sendImage: this.direct.sendImage.bind(this.direct),
|
|
92
|
+
sendVideo: this.direct.sendVideo.bind(this.direct),
|
|
93
|
+
getInbox: this.direct.getInbox.bind(this.direct),
|
|
94
|
+
getThread: this.directThread.getThread.bind(this.directThread)
|
|
95
|
+
};
|
|
96
|
+
// Proxy debug / verbose
|
|
97
|
+
this.state.verbose = this.state.verbose || false;
|
|
98
|
+
// Default retry policy for the new helper retryAsync
|
|
99
|
+
this._defaultRetryPolicy = { retries: 3, delayMs: 500 };
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Login -> uses account.login. Returns whatever account.login returns.
|
|
103
|
+
* NOTE: removed automatic realtime connection attempt.
|
|
104
|
+
*/
|
|
105
|
+
async login(credentials) {
|
|
106
|
+
this.navChain.simulateAppOpen();
|
|
107
|
+
if (this.state.deviceId) {
|
|
108
|
+
try {
|
|
109
|
+
await this.preLoginFlow();
|
|
110
|
+
}
|
|
111
|
+
catch (e) {
|
|
112
|
+
if (this.state.verbose)
|
|
113
|
+
console.warn('[Pre-Login] Flow error (non-fatal):', e.message);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
const result = await this.account.login(credentials);
|
|
117
|
+
try {
|
|
118
|
+
await this.postLoginFlow();
|
|
119
|
+
}
|
|
120
|
+
catch (e) {
|
|
121
|
+
if (this.state.verbose)
|
|
122
|
+
console.warn('[Post-Login] Flow error (non-fatal):', e.message);
|
|
123
|
+
}
|
|
124
|
+
return result;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Additional Android-specific behavior simulation
|
|
128
|
+
*/
|
|
129
|
+
async simulateAndroidBehavior() {
|
|
130
|
+
if (this.state.verbose)
|
|
131
|
+
console.log('[Anti-Bot] Simulating Android-specific background behaviors...');
|
|
132
|
+
// 0. Pre-login notification suppression / Trust signal
|
|
133
|
+
try {
|
|
134
|
+
await this.request.send({
|
|
135
|
+
url: '/api/v1/accounts/get_presence_disabled/',
|
|
136
|
+
method: 'GET',
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
catch (e) { }
|
|
140
|
+
// 1. Fetch Contact Permission (often requested on start/login)
|
|
141
|
+
try {
|
|
142
|
+
await this.request.send({
|
|
143
|
+
url: '/api/v1/accounts/contact_point_pref/',
|
|
144
|
+
method: 'GET',
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
catch (e) { }
|
|
148
|
+
// 2. Fetch Zero Rating (Mobile data settings)
|
|
149
|
+
try {
|
|
150
|
+
await this.request.send({
|
|
151
|
+
url: '/api/v1/zero/get_headers/',
|
|
152
|
+
method: 'GET',
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
catch (e) { }
|
|
156
|
+
// 3. Fetch Banyan (Explore/Search context)
|
|
157
|
+
try {
|
|
158
|
+
await this.request.send({
|
|
159
|
+
url: '/api/v1/banyan/banyan/',
|
|
160
|
+
method: 'GET',
|
|
161
|
+
qs: {
|
|
162
|
+
views: '["direct_user_search","direct_search_context","direct_share_sheet"]',
|
|
163
|
+
},
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
catch (e) { }
|
|
167
|
+
}
|
|
168
|
+
async logout() {
|
|
169
|
+
return await this.account.logout();
|
|
170
|
+
}
|
|
171
|
+
isLoggedIn() {
|
|
172
|
+
try {
|
|
173
|
+
return !!this.state.cookieUserId;
|
|
174
|
+
}
|
|
175
|
+
catch {
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
async saveSession() {
|
|
180
|
+
return await this.state.serialize();
|
|
181
|
+
}
|
|
182
|
+
async loadSession(session) {
|
|
183
|
+
const ret = await this.state.deserialize(session);
|
|
184
|
+
this.navChain.simulateAppOpen();
|
|
185
|
+
return ret;
|
|
186
|
+
}
|
|
187
|
+
async isSessionValid() {
|
|
188
|
+
try {
|
|
189
|
+
await this.account.currentUser();
|
|
190
|
+
return true;
|
|
191
|
+
}
|
|
192
|
+
catch {
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
destroy() {
|
|
197
|
+
// Cleanup resources - keep original behaviour for request streams if present
|
|
198
|
+
try {
|
|
199
|
+
this.request.error$.complete();
|
|
200
|
+
}
|
|
201
|
+
catch (_) { }
|
|
202
|
+
try {
|
|
203
|
+
this.request.end$.complete();
|
|
204
|
+
}
|
|
205
|
+
catch (_) { }
|
|
206
|
+
}
|
|
207
|
+
// -------------------------------
|
|
208
|
+
// === UTILITY HELPER METHODS
|
|
209
|
+
// -------------------------------
|
|
210
|
+
async preLoginFlow() {
|
|
211
|
+
if (this.state.verbose)
|
|
212
|
+
console.log('[Pre-Login] Starting pre-login flow (sync_launcher)...');
|
|
213
|
+
try {
|
|
214
|
+
await this.request.send({
|
|
215
|
+
url: '/api/v1/launcher/sync/',
|
|
216
|
+
method: 'POST',
|
|
217
|
+
form: this.request.sign({
|
|
218
|
+
id: this.state.uuid,
|
|
219
|
+
server_config_retrieval: '1',
|
|
220
|
+
}),
|
|
221
|
+
});
|
|
222
|
+
if (this.state.verbose)
|
|
223
|
+
console.log('[Pre-Login] Launcher Sync: OK');
|
|
224
|
+
}
|
|
225
|
+
catch (e) {
|
|
226
|
+
if (this.state.verbose)
|
|
227
|
+
console.warn('[Pre-Login] Launcher Sync Failed (non-fatal):', e.message);
|
|
228
|
+
}
|
|
229
|
+
await new Promise(resolve => setTimeout(resolve, Math.random() * 700 + 175));
|
|
230
|
+
}
|
|
231
|
+
async postLoginFlow() {
|
|
232
|
+
if (this.state.verbose)
|
|
233
|
+
console.log('[Post-Login] Starting post-login flow...');
|
|
234
|
+
try {
|
|
235
|
+
await this.request.send({
|
|
236
|
+
url: '/api/v1/feed/reels_tray/',
|
|
237
|
+
method: 'POST',
|
|
238
|
+
form: this.request.sign({
|
|
239
|
+
supported_capabilities_new: JSON.stringify(this.state.constants.SUPPORTED_CAPABILITIES),
|
|
240
|
+
reason: 'cold_start',
|
|
241
|
+
timezone_offset: String(this.state.timezoneOffset),
|
|
242
|
+
tray_session_id: this.state.traySessionId,
|
|
243
|
+
request_id: this.state.requestId,
|
|
244
|
+
_uuid: this.state.uuid,
|
|
245
|
+
page_size: 50,
|
|
246
|
+
reel_tray_impressions: {},
|
|
247
|
+
}),
|
|
248
|
+
});
|
|
249
|
+
if (this.state.verbose)
|
|
250
|
+
console.log('[Post-Login] Reels tray: OK');
|
|
251
|
+
}
|
|
252
|
+
catch (e) {
|
|
253
|
+
if (this.state.verbose)
|
|
254
|
+
console.warn('[Post-Login] Reels tray failed (non-fatal):', e.message);
|
|
255
|
+
}
|
|
256
|
+
try {
|
|
257
|
+
const timelineData = JSON.stringify({
|
|
258
|
+
has_camera_permission: '1',
|
|
259
|
+
feed_view_info: '[]',
|
|
260
|
+
phone_id: this.state.phoneId,
|
|
261
|
+
reason: 'cold_start_fetch',
|
|
262
|
+
battery_level: 100,
|
|
263
|
+
timezone_offset: String(this.state.timezoneOffset),
|
|
264
|
+
device_id: this.state.uuid,
|
|
265
|
+
request_id: this.state.requestId,
|
|
266
|
+
_uuid: this.state.uuid,
|
|
267
|
+
is_charging: Math.random() > 0.5 ? 1 : 0,
|
|
268
|
+
is_dark_mode: 1,
|
|
269
|
+
will_sound_on: Math.random() > 0.5 ? 1 : 0,
|
|
270
|
+
session_id: this.state.clientSessionId,
|
|
271
|
+
bloks_versioning_id: this.state.bloksVersionId,
|
|
272
|
+
is_pull_to_refresh: '0',
|
|
273
|
+
});
|
|
274
|
+
await this.request.send({
|
|
275
|
+
url: '/api/v1/feed/timeline/',
|
|
276
|
+
method: 'POST',
|
|
277
|
+
data: timelineData,
|
|
278
|
+
headers: {
|
|
279
|
+
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
|
280
|
+
'X-Ads-Opt-Out': '0',
|
|
281
|
+
'X-DEVICE-ID': this.state.uuid,
|
|
282
|
+
'X-CM-Bandwidth-KBPS': '-1.000',
|
|
283
|
+
'X-CM-Latency': String(Math.floor(Math.random() * 5) + 1),
|
|
284
|
+
},
|
|
285
|
+
});
|
|
286
|
+
if (this.state.verbose)
|
|
287
|
+
console.log('[Post-Login] Timeline feed: OK');
|
|
288
|
+
}
|
|
289
|
+
catch (e) {
|
|
290
|
+
if (this.state.verbose)
|
|
291
|
+
console.warn('[Post-Login] Timeline feed failed (non-fatal):', e.message);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
async simulateAppStart() {
|
|
295
|
+
return this.preLoginFlow();
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Generic retry helper for async functions.
|
|
299
|
+
*
|
|
300
|
+
* Usage:
|
|
301
|
+
* await client.retryAsync(() => client.request.post(...), { retries: 5, delayMs: 1000 });
|
|
302
|
+
*
|
|
303
|
+
* Options:
|
|
304
|
+
* - retries: number (default from this._defaultRetryPolicy.retries)
|
|
305
|
+
* - delayMs: base delay in ms (default from this._defaultRetryPolicy.delayMs)
|
|
306
|
+
* - factor: multiplier for exponential backoff (default 1.5)
|
|
307
|
+
* - onRetry: optional callback (err, attempt) called before next retry
|
|
308
|
+
*/
|
|
309
|
+
async retryAsync(fn, options = {}) {
|
|
310
|
+
const retries = typeof options.retries === 'number' ? options.retries : this._defaultRetryPolicy.retries;
|
|
311
|
+
const delayMs = typeof options.delayMs === 'number' ? options.delayMs : this._defaultRetryPolicy.delayMs;
|
|
312
|
+
const factor = typeof options.factor === 'number' ? options.factor : 1.5;
|
|
313
|
+
const onRetry = typeof options.onRetry === 'function' ? options.onRetry : null;
|
|
314
|
+
let lastErr;
|
|
315
|
+
for (let attempt = 0; attempt <= retries; attempt++) {
|
|
316
|
+
try {
|
|
317
|
+
if (this.state.verbose) {
|
|
318
|
+
console.log(`[Retry] attempt ${attempt + 1}/${retries + 1}`);
|
|
319
|
+
}
|
|
320
|
+
const res = await fn();
|
|
321
|
+
return res;
|
|
322
|
+
}
|
|
323
|
+
catch (err) {
|
|
324
|
+
lastErr = err;
|
|
325
|
+
if (attempt === retries)
|
|
326
|
+
break;
|
|
327
|
+
if (onRetry) {
|
|
328
|
+
try {
|
|
329
|
+
onRetry(err, attempt + 1);
|
|
330
|
+
}
|
|
331
|
+
catch (_) { }
|
|
332
|
+
}
|
|
333
|
+
const backoff = Math.round(delayMs * Math.pow(factor, attempt));
|
|
334
|
+
if (this.state.verbose) {
|
|
335
|
+
console.warn(`[Retry] attempt ${attempt + 1} failed: ${err && err.message ? err.message : err}. Backoff ${backoff}ms`);
|
|
336
|
+
}
|
|
337
|
+
await new Promise(r => setTimeout(r, backoff));
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
throw lastErr || new Error('retryAsync failed without specific error');
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Set default retry policy for retryAsync.
|
|
344
|
+
* Example: client.setDefaultRetryPolicy({ retries: 5, delayMs: 800 });
|
|
345
|
+
*/
|
|
346
|
+
setDefaultRetryPolicy(policy = {}) {
|
|
347
|
+
if (typeof policy.retries === 'number')
|
|
348
|
+
this._defaultRetryPolicy.retries = policy.retries;
|
|
349
|
+
if (typeof policy.delayMs === 'number')
|
|
350
|
+
this._defaultRetryPolicy.delayMs = policy.delayMs;
|
|
351
|
+
return this._defaultRetryPolicy;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Save session object to a file. Path optional (defaults to ./session.json).
|
|
355
|
+
* Will call this.saveSession() internally.
|
|
356
|
+
*/
|
|
357
|
+
async saveSessionToFile(filePath) {
|
|
358
|
+
const p = filePath || path.resolve(process.cwd(), 'session.json');
|
|
359
|
+
const data = await this.saveSession();
|
|
360
|
+
// Ensure JSON string
|
|
361
|
+
const json = typeof data === 'string' ? data : JSON.stringify(data, null, 2);
|
|
362
|
+
await fs.promises.writeFile(p, json, { mode: 0o600 });
|
|
363
|
+
if (this.state.verbose)
|
|
364
|
+
console.log('[Session] Saved session to', p);
|
|
365
|
+
return p;
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Load session from file path (defaults to ./session.json). Returns true on success.
|
|
369
|
+
*/
|
|
370
|
+
async loadSessionFromFile(filePath) {
|
|
371
|
+
const p = filePath || path.resolve(process.cwd(), 'session.json');
|
|
372
|
+
if (!fs.existsSync(p)) {
|
|
373
|
+
if (this.state.verbose)
|
|
374
|
+
console.warn('[Session] loadSessionFromFile: file not found', p);
|
|
375
|
+
return false;
|
|
376
|
+
}
|
|
377
|
+
const raw = await fs.promises.readFile(p, 'utf8');
|
|
378
|
+
let sessionObj;
|
|
379
|
+
try {
|
|
380
|
+
sessionObj = JSON.parse(raw);
|
|
381
|
+
}
|
|
382
|
+
catch (e) {
|
|
383
|
+
if (this.state.verbose)
|
|
384
|
+
console.warn('[Session] loadSessionFromFile: invalid JSON in', p);
|
|
385
|
+
throw e;
|
|
386
|
+
}
|
|
387
|
+
await this.loadSession(sessionObj);
|
|
388
|
+
if (this.state.verbose)
|
|
389
|
+
console.log('[Session] Loaded session from', p);
|
|
390
|
+
return true;
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Attempt to load session JSON if exists and valid, else false.
|
|
394
|
+
* Wrapper helper for convenience.
|
|
395
|
+
*/
|
|
396
|
+
async tryLoadSessionFileIfExists(filePath) {
|
|
397
|
+
try {
|
|
398
|
+
const loaded = await this.loadSessionFromFile(filePath);
|
|
399
|
+
if (!loaded)
|
|
400
|
+
return false;
|
|
401
|
+
return await this.isSessionValid();
|
|
402
|
+
}
|
|
403
|
+
catch (e) {
|
|
404
|
+
if (this.state.verbose)
|
|
405
|
+
console.warn('[Session] tryLoadSessionFileIfExists failed:', e && e.message);
|
|
406
|
+
return false;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Set verbose mode on/off.
|
|
411
|
+
*/
|
|
412
|
+
setVerbose(flag) {
|
|
413
|
+
this.state.verbose = !!flag;
|
|
414
|
+
return this.state.verbose;
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* safeDestroy: a slightly more robust destroy which attempts to stop requests, etc.
|
|
418
|
+
*/
|
|
419
|
+
async safeDestroy() {
|
|
420
|
+
try {
|
|
421
|
+
if (this.request && this.request.error$ && typeof this.request.error$.complete === 'function')
|
|
422
|
+
this.request.error$.complete();
|
|
423
|
+
}
|
|
424
|
+
catch (_) { }
|
|
425
|
+
try {
|
|
426
|
+
if (this.request && this.request.end$ && typeof this.request.end$.complete === 'function')
|
|
427
|
+
this.request.end$.complete();
|
|
428
|
+
}
|
|
429
|
+
catch (_) { }
|
|
430
|
+
// keep original destroy for backward compatibility
|
|
431
|
+
try {
|
|
432
|
+
this.destroy();
|
|
433
|
+
}
|
|
434
|
+
catch (_) { }
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
module.exports = IgApiClient;
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const { random } = require('lodash');
|
|
3
|
+
const SCREEN_IDS = {
|
|
4
|
+
MAIN_FEED: 'MainFeedFragment',
|
|
5
|
+
FEED_TIMELINE: 'FeedTimelineFragment',
|
|
6
|
+
DIRECT_INBOX: 'DirectInboxFragment',
|
|
7
|
+
DIRECT_THREAD: 'DirectThreadFragment',
|
|
8
|
+
DIRECT_PENDING: 'DirectPendingInboxFragment',
|
|
9
|
+
SELF_PROFILE: 'SelfProfileFragment',
|
|
10
|
+
PROFILE: 'ProfileFragment',
|
|
11
|
+
PROFILE_MEDIA_TAB: 'ProfileMediaTabFragment',
|
|
12
|
+
EXPLORE: 'ExploreFragment',
|
|
13
|
+
REELS: 'ReelsFragment',
|
|
14
|
+
STORY_VIEWER: 'StoryViewerFragment',
|
|
15
|
+
SEARCH: 'SearchFragment',
|
|
16
|
+
ACTIVITY: 'ActivityFeedFragment',
|
|
17
|
+
SETTINGS: 'SettingsFragment',
|
|
18
|
+
MEDIA_VIEWER: 'MediaViewerFragment',
|
|
19
|
+
};
|
|
20
|
+
const MODULE_IDS = {
|
|
21
|
+
MAIN_FEED: 'feed_timeline',
|
|
22
|
+
DIRECT_INBOX: 'direct_inbox',
|
|
23
|
+
DIRECT_THREAD: 'direct_thread',
|
|
24
|
+
DIRECT_PENDING: 'direct_pending_inbox',
|
|
25
|
+
SELF_PROFILE: 'self_profile',
|
|
26
|
+
PROFILE: 'profile',
|
|
27
|
+
EXPLORE: 'explore_popular',
|
|
28
|
+
REELS: 'clips_viewer',
|
|
29
|
+
STORY_VIEWER: 'reel_feed_timeline',
|
|
30
|
+
SEARCH: 'search',
|
|
31
|
+
ACTIVITY: 'news',
|
|
32
|
+
SETTINGS: 'settings',
|
|
33
|
+
MEDIA_VIEWER: 'feed_contextual_profile',
|
|
34
|
+
};
|
|
35
|
+
const SHORT_CODES = {
|
|
36
|
+
feed_timeline: '9MV',
|
|
37
|
+
direct_inbox: 'QrA',
|
|
38
|
+
direct_thread: 'MpL',
|
|
39
|
+
direct_pending_inbox: 'QrB',
|
|
40
|
+
self_profile: '9Xf',
|
|
41
|
+
profile: '8wC',
|
|
42
|
+
explore_popular: '6xQ',
|
|
43
|
+
clips_viewer: '9Ly',
|
|
44
|
+
reel_feed_timeline: '5RE',
|
|
45
|
+
search: '7GJ',
|
|
46
|
+
news: '9HR',
|
|
47
|
+
settings: '4Dn',
|
|
48
|
+
feed_contextual_profile: '9z6',
|
|
49
|
+
};
|
|
50
|
+
const ALTERNATIVE_SHORT_CODES = {
|
|
51
|
+
feed_timeline: ['MainFeedFragment', '9MV', 'cold_start'],
|
|
52
|
+
direct_inbox: ['QrA', 'DirectInboxFragment', 'ig_direct'],
|
|
53
|
+
direct_thread: ['MpL', 'DirectThreadFragment', 'ig_direct_thread'],
|
|
54
|
+
self_profile: ['9Xf', 'SelfFragment', 'self_profile'],
|
|
55
|
+
profile: ['8wC', 'ProfileFragment', 'profile'],
|
|
56
|
+
explore_popular: ['6xQ', 'ExploreFragment', 'explore'],
|
|
57
|
+
};
|
|
58
|
+
class NavChainManager {
|
|
59
|
+
constructor() {
|
|
60
|
+
this._chain = [];
|
|
61
|
+
this._stepCounter = 0;
|
|
62
|
+
this._lastActionTimestamp = Date.now();
|
|
63
|
+
this._sessionStarted = false;
|
|
64
|
+
this._currentContext = null;
|
|
65
|
+
}
|
|
66
|
+
reset() {
|
|
67
|
+
this._chain = [];
|
|
68
|
+
this._stepCounter = 0;
|
|
69
|
+
this._lastActionTimestamp = Date.now();
|
|
70
|
+
this._sessionStarted = false;
|
|
71
|
+
this._currentContext = null;
|
|
72
|
+
}
|
|
73
|
+
_pickShortCode(moduleId) {
|
|
74
|
+
const alts = ALTERNATIVE_SHORT_CODES[moduleId];
|
|
75
|
+
if (alts && Math.random() < 0.3) {
|
|
76
|
+
return alts[Math.floor(Math.random() * alts.length)];
|
|
77
|
+
}
|
|
78
|
+
return SHORT_CODES[moduleId] || moduleId;
|
|
79
|
+
}
|
|
80
|
+
_addStep(screenOrShortCode, moduleId) {
|
|
81
|
+
this._stepCounter++;
|
|
82
|
+
const entry = `${screenOrShortCode}:${moduleId}:${this._stepCounter}`;
|
|
83
|
+
this._chain.push(entry);
|
|
84
|
+
if (this._chain.length > 8) {
|
|
85
|
+
this._chain = this._chain.slice(-6);
|
|
86
|
+
}
|
|
87
|
+
this._lastActionTimestamp = Date.now();
|
|
88
|
+
return entry;
|
|
89
|
+
}
|
|
90
|
+
simulateAppOpen() {
|
|
91
|
+
this.reset();
|
|
92
|
+
this._sessionStarted = true;
|
|
93
|
+
const openVariant = Math.random();
|
|
94
|
+
if (openVariant < 0.6) {
|
|
95
|
+
this._addStep(this._pickShortCode('feed_timeline'), 'feed_timeline');
|
|
96
|
+
}
|
|
97
|
+
else if (openVariant < 0.85) {
|
|
98
|
+
this._addStep(this._pickShortCode('feed_timeline'), 'feed_timeline');
|
|
99
|
+
const delay = random(200, 800);
|
|
100
|
+
this._lastActionTimestamp = Date.now() - delay;
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
this._addStep('cold_start', 'feed_timeline');
|
|
104
|
+
}
|
|
105
|
+
this._currentContext = 'feed';
|
|
106
|
+
return this.getChainString();
|
|
107
|
+
}
|
|
108
|
+
navigateToInbox() {
|
|
109
|
+
if (!this._sessionStarted) {
|
|
110
|
+
this.simulateAppOpen();
|
|
111
|
+
}
|
|
112
|
+
this._addStep(this._pickShortCode('direct_inbox'), 'direct_inbox');
|
|
113
|
+
this._currentContext = 'direct_inbox';
|
|
114
|
+
return this.getChainString();
|
|
115
|
+
}
|
|
116
|
+
navigateToThread(threadId) {
|
|
117
|
+
if (this._currentContext !== 'direct_inbox' && this._currentContext !== 'direct_thread') {
|
|
118
|
+
this.navigateToInbox();
|
|
119
|
+
}
|
|
120
|
+
this._addStep(this._pickShortCode('direct_thread'), 'direct_thread');
|
|
121
|
+
this._currentContext = 'direct_thread';
|
|
122
|
+
return this.getChainString();
|
|
123
|
+
}
|
|
124
|
+
navigateToPendingInbox() {
|
|
125
|
+
if (this._currentContext !== 'direct_inbox') {
|
|
126
|
+
this.navigateToInbox();
|
|
127
|
+
}
|
|
128
|
+
this._addStep(this._pickShortCode('direct_pending_inbox'), 'direct_pending_inbox');
|
|
129
|
+
this._currentContext = 'direct_pending';
|
|
130
|
+
return this.getChainString();
|
|
131
|
+
}
|
|
132
|
+
navigateToProfile(isSelf = false) {
|
|
133
|
+
if (!this._sessionStarted) {
|
|
134
|
+
this.simulateAppOpen();
|
|
135
|
+
}
|
|
136
|
+
if (isSelf) {
|
|
137
|
+
this._addStep(this._pickShortCode('self_profile'), 'self_profile');
|
|
138
|
+
this._currentContext = 'self_profile';
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
this._addStep(this._pickShortCode('profile'), 'profile');
|
|
142
|
+
this._currentContext = 'profile';
|
|
143
|
+
}
|
|
144
|
+
return this.getChainString();
|
|
145
|
+
}
|
|
146
|
+
navigateToExplore() {
|
|
147
|
+
if (!this._sessionStarted) {
|
|
148
|
+
this.simulateAppOpen();
|
|
149
|
+
}
|
|
150
|
+
this._addStep(this._pickShortCode('explore_popular'), 'explore_popular');
|
|
151
|
+
this._currentContext = 'explore';
|
|
152
|
+
return this.getChainString();
|
|
153
|
+
}
|
|
154
|
+
navigateToFeed() {
|
|
155
|
+
if (!this._sessionStarted) {
|
|
156
|
+
this.simulateAppOpen();
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
this._addStep(this._pickShortCode('feed_timeline'), 'feed_timeline');
|
|
160
|
+
}
|
|
161
|
+
this._currentContext = 'feed';
|
|
162
|
+
return this.getChainString();
|
|
163
|
+
}
|
|
164
|
+
incrementForAction() {
|
|
165
|
+
if (!this._sessionStarted) {
|
|
166
|
+
this.simulateAppOpen();
|
|
167
|
+
}
|
|
168
|
+
const ctx = this._currentContext || 'feed_timeline';
|
|
169
|
+
const moduleMap = {
|
|
170
|
+
'feed': 'feed_timeline',
|
|
171
|
+
'direct_inbox': 'direct_inbox',
|
|
172
|
+
'direct_thread': 'direct_thread',
|
|
173
|
+
'direct_pending': 'direct_pending_inbox',
|
|
174
|
+
'self_profile': 'self_profile',
|
|
175
|
+
'profile': 'profile',
|
|
176
|
+
'explore': 'explore_popular',
|
|
177
|
+
};
|
|
178
|
+
const moduleId = moduleMap[ctx] || 'feed_timeline';
|
|
179
|
+
this._addStep(this._pickShortCode(moduleId), moduleId);
|
|
180
|
+
return this.getChainString();
|
|
181
|
+
}
|
|
182
|
+
getChainForDMBroadcast(isNewThread = false) {
|
|
183
|
+
if (!this._sessionStarted) {
|
|
184
|
+
this.simulateAppOpen();
|
|
185
|
+
}
|
|
186
|
+
if (this._currentContext !== 'direct_thread') {
|
|
187
|
+
if (this._currentContext !== 'direct_inbox') {
|
|
188
|
+
this.navigateToInbox();
|
|
189
|
+
}
|
|
190
|
+
this.navigateToThread();
|
|
191
|
+
}
|
|
192
|
+
this._stepCounter++;
|
|
193
|
+
this._lastActionTimestamp = Date.now();
|
|
194
|
+
return this.getChainString();
|
|
195
|
+
}
|
|
196
|
+
getChainForDMSequence(messageIndex) {
|
|
197
|
+
if (messageIndex === 0 || !this._sessionStarted) {
|
|
198
|
+
this.simulateAppOpen();
|
|
199
|
+
this.navigateToInbox();
|
|
200
|
+
this.navigateToThread();
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
this._stepCounter++;
|
|
204
|
+
const lastEntry = this._chain[this._chain.length - 1];
|
|
205
|
+
if (lastEntry) {
|
|
206
|
+
const parts = lastEntry.split(':');
|
|
207
|
+
if (parts.length === 3) {
|
|
208
|
+
parts[2] = String(this._stepCounter);
|
|
209
|
+
this._chain[this._chain.length - 1] = parts.join(':');
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
this._lastActionTimestamp = Date.now();
|
|
214
|
+
return this.getChainString();
|
|
215
|
+
}
|
|
216
|
+
getChainForBulkDM(recipientIndex, totalRecipients) {
|
|
217
|
+
if (recipientIndex === 0) {
|
|
218
|
+
this.simulateAppOpen();
|
|
219
|
+
this.navigateToInbox();
|
|
220
|
+
}
|
|
221
|
+
this.navigateToThread();
|
|
222
|
+
this._stepCounter++;
|
|
223
|
+
this._lastActionTimestamp = Date.now();
|
|
224
|
+
if (recipientIndex > 0 && recipientIndex % random(3, 6) === 0) {
|
|
225
|
+
this.navigateToInbox();
|
|
226
|
+
this.navigateToThread();
|
|
227
|
+
}
|
|
228
|
+
return this.getChainString();
|
|
229
|
+
}
|
|
230
|
+
getChainString() {
|
|
231
|
+
if (this._chain.length === 0) {
|
|
232
|
+
this.simulateAppOpen();
|
|
233
|
+
}
|
|
234
|
+
return this._chain.join(',');
|
|
235
|
+
}
|
|
236
|
+
getCurrentContext() {
|
|
237
|
+
return this._currentContext;
|
|
238
|
+
}
|
|
239
|
+
getStepCounter() {
|
|
240
|
+
return this._stepCounter;
|
|
241
|
+
}
|
|
242
|
+
setContext(contextName) {
|
|
243
|
+
this._currentContext = contextName;
|
|
244
|
+
if (!this._sessionStarted) {
|
|
245
|
+
this.simulateAppOpen();
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
NavChainManager.SCREEN_IDS = SCREEN_IDS;
|
|
250
|
+
NavChainManager.MODULE_IDS = MODULE_IDS;
|
|
251
|
+
NavChainManager.SHORT_CODES = SHORT_CODES;
|
|
252
|
+
module.exports = NavChainManager;
|