nodejs-insta-private-api-mqt 1.3.83 → 1.3.84
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +1 -1
- 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,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function (o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined)
|
|
4
|
+
k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function () { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function (o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined)
|
|
12
|
+
k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __exportStar = (this && this.__exportStar) || function (m, exports) {
|
|
16
|
+
for (var p in m)
|
|
17
|
+
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p))
|
|
18
|
+
__createBinding(exports, m, p);
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
__exportStar(require("./commands"), exports);
|
|
22
|
+
__exportStar(require("./direct.commands"), exports);
|
|
23
|
+
__exportStar(require("./enhanced.direct.commands"), exports);
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
const debug = require('debug')('ig:delta');
|
|
2
|
+
/**
|
|
3
|
+
* Delta Sync Manager - Apply real Instagram delta updates to local state
|
|
4
|
+
* Based on MessageSync format from reverse-engineered instagram_mqtt
|
|
5
|
+
*/
|
|
6
|
+
class DeltaSyncManager {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.state = {
|
|
9
|
+
threads: {}, // thread_id → ThreadUpdate
|
|
10
|
+
messages: {}, // item_id → MessageSyncMessage
|
|
11
|
+
typing: {}, // thread_id → TypingIndicator
|
|
12
|
+
presence: {} // user_id → PresenceIndicator
|
|
13
|
+
};
|
|
14
|
+
this.listeners = [];
|
|
15
|
+
this.operations = { add: 0, update: 0, delete: 0 };
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Apply delta operations (add/update/delete) to local state
|
|
19
|
+
*/
|
|
20
|
+
applyDelta(delta) {
|
|
21
|
+
if (!delta || !delta.items || delta.items.length === 0) {
|
|
22
|
+
return { applied: 0, errors: [], stats: this.operations };
|
|
23
|
+
}
|
|
24
|
+
let applied = 0;
|
|
25
|
+
const errors = [];
|
|
26
|
+
delta.items.forEach(item => {
|
|
27
|
+
try {
|
|
28
|
+
const result = this.applyItem(item);
|
|
29
|
+
if (result)
|
|
30
|
+
applied++;
|
|
31
|
+
}
|
|
32
|
+
catch (e) {
|
|
33
|
+
errors.push({
|
|
34
|
+
itemId: item.id || item.item_id,
|
|
35
|
+
error: e.message,
|
|
36
|
+
operation: item.op || item.type
|
|
37
|
+
});
|
|
38
|
+
debug(`❌ Error applying item:`, e.message);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
// Notify listeners
|
|
42
|
+
if (applied > 0) {
|
|
43
|
+
this.notifyListeners(delta);
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
applied,
|
|
47
|
+
errors,
|
|
48
|
+
total: delta.items.length,
|
|
49
|
+
stats: this.operations
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Apply single item (message, thread, typing, presence)
|
|
54
|
+
*/
|
|
55
|
+
applyItem(item) {
|
|
56
|
+
var _a, _b, _c, _d;
|
|
57
|
+
if (!item)
|
|
58
|
+
return false;
|
|
59
|
+
// Get operation type from IrisItem
|
|
60
|
+
const operation = item.op || item.type || 'add'; // add, replace, delete
|
|
61
|
+
// Extract data from 'data' oneof field
|
|
62
|
+
if ((_a = item.data) === null || _a === void 0 ? void 0 : _a.message) {
|
|
63
|
+
return this.applyMessage(operation, item.data.message);
|
|
64
|
+
}
|
|
65
|
+
if ((_b = item.data) === null || _b === void 0 ? void 0 : _b.thread) {
|
|
66
|
+
return this.applyThread(operation, item.data.thread);
|
|
67
|
+
}
|
|
68
|
+
if ((_c = item.data) === null || _c === void 0 ? void 0 : _c.typing) {
|
|
69
|
+
return this.applyTyping(operation, item.data.typing);
|
|
70
|
+
}
|
|
71
|
+
if ((_d = item.data) === null || _d === void 0 ? void 0 : _d.presence) {
|
|
72
|
+
return this.applyPresence(operation, item.data.presence);
|
|
73
|
+
}
|
|
74
|
+
// Fallback for direct objects
|
|
75
|
+
if (item.message) {
|
|
76
|
+
return this.applyMessage(operation, item.message);
|
|
77
|
+
}
|
|
78
|
+
if (item.thread) {
|
|
79
|
+
return this.applyThread(operation, item.thread);
|
|
80
|
+
}
|
|
81
|
+
if (item.typing) {
|
|
82
|
+
return this.applyTyping(operation, item.typing);
|
|
83
|
+
}
|
|
84
|
+
if (item.presence) {
|
|
85
|
+
return this.applyPresence(operation, item.presence);
|
|
86
|
+
}
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Apply message delta (real Instagram MessageSyncMessage format)
|
|
91
|
+
*/
|
|
92
|
+
applyMessage(operation, message) {
|
|
93
|
+
var _a, _b;
|
|
94
|
+
const msgId = message.item_id;
|
|
95
|
+
if (operation === 'delete' || operation === 'deletion') {
|
|
96
|
+
delete this.state.messages[msgId];
|
|
97
|
+
this.operations.delete++;
|
|
98
|
+
debug(`🗑️ Deleted message ${msgId}`);
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
if (operation === 'replace' || operation === 'update') {
|
|
102
|
+
if (!this.state.messages[msgId]) {
|
|
103
|
+
debug(`⚠️ Message ${msgId} not found for update`);
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
Object.assign(this.state.messages[msgId], message);
|
|
107
|
+
this.operations.update++;
|
|
108
|
+
debug(`✏️ Updated message ${msgId}: "${(_a = message.text) === null || _a === void 0 ? void 0 : _a.substring(0, 30)}"`);
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
// add/default
|
|
112
|
+
this.state.messages[msgId] = message;
|
|
113
|
+
this.operations.add++;
|
|
114
|
+
debug(`➕ Added message ${msgId}: "${((_b = message.text) === null || _b === void 0 ? void 0 : _b.substring(0, 30)) || 'media'}"`);
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Apply thread delta (real Instagram ThreadUpdate format)
|
|
119
|
+
*/
|
|
120
|
+
applyThread(operation, thread) {
|
|
121
|
+
var _a;
|
|
122
|
+
const threadId = thread.thread_id || thread.thread_v2_id;
|
|
123
|
+
if (operation === 'delete') {
|
|
124
|
+
delete this.state.threads[threadId];
|
|
125
|
+
this.operations.delete++;
|
|
126
|
+
debug(`🗑️ Deleted thread ${threadId}`);
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
if (operation === 'replace' || operation === 'update') {
|
|
130
|
+
if (!this.state.threads[threadId]) {
|
|
131
|
+
// Create new thread on update if doesn't exist
|
|
132
|
+
this.state.threads[threadId] = thread;
|
|
133
|
+
this.operations.add++;
|
|
134
|
+
debug(`➕ Created thread from update: ${thread.thread_title}`);
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
Object.assign(this.state.threads[threadId], thread);
|
|
138
|
+
this.operations.update++;
|
|
139
|
+
debug(`✏️ Updated thread ${threadId}: "${thread.thread_title}"`);
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
// add/default
|
|
143
|
+
this.state.threads[threadId] = thread;
|
|
144
|
+
this.operations.add++;
|
|
145
|
+
debug(`➕ Added thread: "${thread.thread_title}" (${((_a = thread.user_ids) === null || _a === void 0 ? void 0 : _a.length) || 1} members)`);
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Apply typing indicator delta
|
|
150
|
+
*/
|
|
151
|
+
applyTyping(operation, typing) {
|
|
152
|
+
const threadId = typing.thread_id;
|
|
153
|
+
if (operation === 'delete' || typing.state === 'stopped') {
|
|
154
|
+
delete this.state.typing[threadId];
|
|
155
|
+
this.operations.delete++;
|
|
156
|
+
debug(`⌨️ User ${typing.from_user_id} stopped typing in ${threadId}`);
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
159
|
+
this.state.typing[threadId] = typing;
|
|
160
|
+
this.operations.add++;
|
|
161
|
+
debug(`⌨️ User ${typing.from_user_id} typing in ${threadId}`);
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Apply presence indicator delta
|
|
166
|
+
*/
|
|
167
|
+
applyPresence(operation, presence) {
|
|
168
|
+
const userId = presence.user_id;
|
|
169
|
+
if (operation === 'delete' || presence.status === 'inactive') {
|
|
170
|
+
delete this.state.presence[userId];
|
|
171
|
+
this.operations.delete++;
|
|
172
|
+
debug(`🔴 User ${userId} offline`);
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
175
|
+
this.state.presence[userId] = presence;
|
|
176
|
+
this.operations.add++;
|
|
177
|
+
debug(`🟢 User ${userId} ${presence.status}`);
|
|
178
|
+
return true;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Subscribe to state changes
|
|
182
|
+
*/
|
|
183
|
+
subscribe(callback) {
|
|
184
|
+
this.listeners.push(callback);
|
|
185
|
+
return () => {
|
|
186
|
+
this.listeners = this.listeners.filter(l => l !== callback);
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Notify listeners of changes
|
|
191
|
+
*/
|
|
192
|
+
notifyListeners(delta) {
|
|
193
|
+
this.listeners.forEach(callback => {
|
|
194
|
+
try {
|
|
195
|
+
callback(delta, this.getState());
|
|
196
|
+
}
|
|
197
|
+
catch (e) {
|
|
198
|
+
debug('Listener error:', e.message);
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Get current synchronized state
|
|
204
|
+
*/
|
|
205
|
+
getState() {
|
|
206
|
+
return {
|
|
207
|
+
threads: JSON.parse(JSON.stringify(this.state.threads)),
|
|
208
|
+
messages: JSON.parse(JSON.stringify(this.state.messages)),
|
|
209
|
+
typing: JSON.parse(JSON.stringify(this.state.typing)),
|
|
210
|
+
presence: JSON.parse(JSON.stringify(this.state.presence))
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Query methods
|
|
215
|
+
*/
|
|
216
|
+
getThread(threadId) {
|
|
217
|
+
return this.state.threads[threadId] || null;
|
|
218
|
+
}
|
|
219
|
+
getThreadMessages(threadId) {
|
|
220
|
+
return Object.values(this.state.messages).filter(m => m.thread_id === threadId || m.thread_v2_id === threadId);
|
|
221
|
+
}
|
|
222
|
+
getThreads() {
|
|
223
|
+
return Object.values(this.state.threads);
|
|
224
|
+
}
|
|
225
|
+
getAllMessages() {
|
|
226
|
+
return Object.values(this.state.messages);
|
|
227
|
+
}
|
|
228
|
+
getTypingInThread(threadId) {
|
|
229
|
+
return this.state.typing[threadId] || null;
|
|
230
|
+
}
|
|
231
|
+
getUserPresence(userId) {
|
|
232
|
+
return this.state.presence[userId] || null;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Stats
|
|
236
|
+
*/
|
|
237
|
+
getStats() {
|
|
238
|
+
return {
|
|
239
|
+
threads: Object.keys(this.state.threads).length,
|
|
240
|
+
messages: Object.keys(this.state.messages).length,
|
|
241
|
+
typing: Object.keys(this.state.typing).length,
|
|
242
|
+
presence: Object.keys(this.state.presence).length,
|
|
243
|
+
operations: this.operations
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Clear all state
|
|
248
|
+
*/
|
|
249
|
+
clear() {
|
|
250
|
+
this.state = {
|
|
251
|
+
threads: {},
|
|
252
|
+
messages: {},
|
|
253
|
+
typing: {},
|
|
254
|
+
presence: {}
|
|
255
|
+
};
|
|
256
|
+
this.operations = { add: 0, update: 0, delete: 0 };
|
|
257
|
+
debug('✓ State cleared');
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
module.exports = DeltaSyncManager;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DMSender = void 0;
|
|
4
|
+
const shared_1 = require("../../shared");
|
|
5
|
+
const uuid_1 = require("uuid");
|
|
6
|
+
/**
|
|
7
|
+
* Direct Message Sender via MQTT
|
|
8
|
+
*/
|
|
9
|
+
class DMSender {
|
|
10
|
+
constructor(client) {
|
|
11
|
+
this.dmDebug = (0, shared_1.debugChannel)('realtime', 'dm-sender');
|
|
12
|
+
this.client = client;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Send text message via MQTT
|
|
16
|
+
*/
|
|
17
|
+
async sendTextMessage(threadId, text, clientContext = null) {
|
|
18
|
+
var _a;
|
|
19
|
+
this.dmDebug(`Sending text message to thread ${threadId}: "${text.substring(0, 50)}..."`);
|
|
20
|
+
const command = {
|
|
21
|
+
action: 'send_item',
|
|
22
|
+
thread_id: threadId,
|
|
23
|
+
item_type: 'text',
|
|
24
|
+
text,
|
|
25
|
+
timestamp: Date.now(),
|
|
26
|
+
client_context: clientContext || (0, uuid_1.v4)(),
|
|
27
|
+
};
|
|
28
|
+
try {
|
|
29
|
+
return await ((_a = this.client.directCommands) === null || _a === void 0 ? void 0 : _a.sendCommand({
|
|
30
|
+
action: 'send_item',
|
|
31
|
+
data: command,
|
|
32
|
+
threadId,
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
this.dmDebug(`Failed to send message: ${err.message}`);
|
|
37
|
+
throw err;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Send media message via MQTT (photo/video)
|
|
42
|
+
*/
|
|
43
|
+
async sendMediaMessage(threadId, mediaId, mediaType = 'photo', clientContext = null) {
|
|
44
|
+
var _a;
|
|
45
|
+
this.dmDebug(`Sending ${mediaType} to thread ${threadId}`);
|
|
46
|
+
const command = {
|
|
47
|
+
action: 'send_item',
|
|
48
|
+
thread_id: threadId,
|
|
49
|
+
item_type: mediaType,
|
|
50
|
+
media_id: mediaId,
|
|
51
|
+
timestamp: Date.now(),
|
|
52
|
+
client_context: clientContext || (0, uuid_1.v4)(),
|
|
53
|
+
};
|
|
54
|
+
try {
|
|
55
|
+
return await ((_a = this.client.directCommands) === null || _a === void 0 ? void 0 : _a.sendCommand({
|
|
56
|
+
action: 'send_item',
|
|
57
|
+
data: command,
|
|
58
|
+
threadId,
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
this.dmDebug(`Failed to send media: ${err.message}`);
|
|
63
|
+
throw err;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Send link message
|
|
68
|
+
*/
|
|
69
|
+
async sendLinkMessage(threadId, url, title = null, clientContext = null) {
|
|
70
|
+
var _a;
|
|
71
|
+
this.dmDebug(`Sending link to thread ${threadId}: ${url}`);
|
|
72
|
+
const command = {
|
|
73
|
+
action: 'send_item',
|
|
74
|
+
thread_id: threadId,
|
|
75
|
+
item_type: 'link',
|
|
76
|
+
url,
|
|
77
|
+
title: title || url,
|
|
78
|
+
timestamp: Date.now(),
|
|
79
|
+
client_context: clientContext || (0, uuid_1.v4)(),
|
|
80
|
+
};
|
|
81
|
+
try {
|
|
82
|
+
return await ((_a = this.client.directCommands) === null || _a === void 0 ? void 0 : _a.sendCommand({
|
|
83
|
+
action: 'send_item',
|
|
84
|
+
data: command,
|
|
85
|
+
threadId,
|
|
86
|
+
}));
|
|
87
|
+
}
|
|
88
|
+
catch (err) {
|
|
89
|
+
this.dmDebug(`Failed to send link: ${err.message}`);
|
|
90
|
+
throw err;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
exports.DMSender = DMSender;
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ErrorHandler = void 0;
|
|
4
|
+
const shared_1 = require("../../shared");
|
|
5
|
+
const ERROR_TYPES = {
|
|
6
|
+
RATE_LIMIT: 'rate_limit',
|
|
7
|
+
AUTH_FAILURE: 'auth_failure',
|
|
8
|
+
NETWORK: 'network',
|
|
9
|
+
PROTOCOL: 'protocol',
|
|
10
|
+
SERVER: 'server',
|
|
11
|
+
UNKNOWN: 'unknown',
|
|
12
|
+
};
|
|
13
|
+
const RATE_LIMIT_PATTERNS = [
|
|
14
|
+
'rate limit', 'too many', 'throttl', 'spam', 'please wait',
|
|
15
|
+
'action blocked', 'try again later', 'temporarily blocked',
|
|
16
|
+
'429', 'flood',
|
|
17
|
+
];
|
|
18
|
+
const AUTH_PATTERNS = [
|
|
19
|
+
'auth', 'login', 'session', 'credential', 'token', 'expired',
|
|
20
|
+
'unauthorized', '401', 'forbidden', '403', 'password',
|
|
21
|
+
'challenge_required', 'checkpoint', 'checkpoint_required',
|
|
22
|
+
'login_required', 'consent_required', 'two_factor',
|
|
23
|
+
];
|
|
24
|
+
const NETWORK_PATTERNS = [
|
|
25
|
+
'ECONNRESET', 'ECONNREFUSED', 'ETIMEDOUT', 'ENOTFOUND',
|
|
26
|
+
'ENETUNREACH', 'socket hang up', 'network', 'dns',
|
|
27
|
+
'getaddrinfo', 'connect EHOSTUNREACH', 'EPIPE', 'EAI_AGAIN',
|
|
28
|
+
];
|
|
29
|
+
class ErrorHandler {
|
|
30
|
+
constructor(client) {
|
|
31
|
+
this.errorDebug = (0, shared_1.debugChannel)('realtime', 'errors');
|
|
32
|
+
this.errorCount = 0;
|
|
33
|
+
this.maxRetries = 15;
|
|
34
|
+
this.client = client;
|
|
35
|
+
this.errorHistory = [];
|
|
36
|
+
this.rateLimitUntil = 0;
|
|
37
|
+
this.consecutiveAuthFailures = 0;
|
|
38
|
+
}
|
|
39
|
+
classifyError(error) {
|
|
40
|
+
const msg = ((error === null || error === void 0 ? void 0 : error.message) || String(error)).toLowerCase();
|
|
41
|
+
for (const pattern of RATE_LIMIT_PATTERNS) {
|
|
42
|
+
if (msg.includes(pattern))
|
|
43
|
+
return ERROR_TYPES.RATE_LIMIT;
|
|
44
|
+
}
|
|
45
|
+
for (const pattern of AUTH_PATTERNS) {
|
|
46
|
+
if (msg.includes(pattern))
|
|
47
|
+
return ERROR_TYPES.AUTH_FAILURE;
|
|
48
|
+
}
|
|
49
|
+
for (const pattern of NETWORK_PATTERNS) {
|
|
50
|
+
if (msg.includes(pattern.toLowerCase()))
|
|
51
|
+
return ERROR_TYPES.NETWORK;
|
|
52
|
+
}
|
|
53
|
+
if (msg.includes('connack') || msg.includes('protocol') || msg.includes('thrift') || msg.includes('parse')) {
|
|
54
|
+
return ERROR_TYPES.PROTOCOL;
|
|
55
|
+
}
|
|
56
|
+
if (msg.includes('500') || msg.includes('502') || msg.includes('503') || msg.includes('server')) {
|
|
57
|
+
return ERROR_TYPES.SERVER;
|
|
58
|
+
}
|
|
59
|
+
return ERROR_TYPES.UNKNOWN;
|
|
60
|
+
}
|
|
61
|
+
getBackoffForType(errorType, attemptNumber) {
|
|
62
|
+
const jitter = Math.floor(Math.random() * 2000);
|
|
63
|
+
switch (errorType) {
|
|
64
|
+
case ERROR_TYPES.RATE_LIMIT:
|
|
65
|
+
return Math.min(60000 * Math.pow(1.5, attemptNumber - 1), 600000) + jitter;
|
|
66
|
+
case ERROR_TYPES.AUTH_FAILURE:
|
|
67
|
+
return Math.min(10000 * Math.pow(2, attemptNumber - 1), 120000) + jitter;
|
|
68
|
+
case ERROR_TYPES.NETWORK:
|
|
69
|
+
return Math.min(2000 * Math.pow(2, attemptNumber - 1), 60000) + jitter;
|
|
70
|
+
case ERROR_TYPES.SERVER:
|
|
71
|
+
return Math.min(5000 * Math.pow(2, attemptNumber - 1), 120000) + jitter;
|
|
72
|
+
case ERROR_TYPES.PROTOCOL:
|
|
73
|
+
return Math.min(5000 * Math.pow(2, attemptNumber - 1), 60000) + jitter;
|
|
74
|
+
default:
|
|
75
|
+
return Math.min(3000 * Math.pow(2, attemptNumber - 1), 90000) + jitter;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
handleConnectionError(error) {
|
|
79
|
+
this.errorCount++;
|
|
80
|
+
const errorType = this.classifyError(error);
|
|
81
|
+
const delay = this.getBackoffForType(errorType, this.errorCount);
|
|
82
|
+
this.errorHistory.push({
|
|
83
|
+
type: errorType,
|
|
84
|
+
message: (error === null || error === void 0 ? void 0 : error.message) || String(error),
|
|
85
|
+
timestamp: Date.now(),
|
|
86
|
+
attempt: this.errorCount,
|
|
87
|
+
});
|
|
88
|
+
if (this.errorHistory.length > 50)
|
|
89
|
+
this.errorHistory.shift();
|
|
90
|
+
this.errorDebug(`[${errorType.toUpperCase()}] Error (${this.errorCount}/${this.maxRetries}): ${(error === null || error === void 0 ? void 0 : error.message) || error}`);
|
|
91
|
+
if (errorType === ERROR_TYPES.RATE_LIMIT) {
|
|
92
|
+
this.rateLimitUntil = Date.now() + delay;
|
|
93
|
+
this.errorDebug(`Rate limited. Waiting ${Math.round(delay / 1000)}s before retry.`);
|
|
94
|
+
}
|
|
95
|
+
if (errorType === ERROR_TYPES.AUTH_FAILURE) {
|
|
96
|
+
this.consecutiveAuthFailures++;
|
|
97
|
+
if (this.consecutiveAuthFailures >= 3) {
|
|
98
|
+
this.errorDebug('Multiple auth failures. Credentials may need refresh.');
|
|
99
|
+
this.client.emit('auth_failure', {
|
|
100
|
+
count: this.consecutiveAuthFailures,
|
|
101
|
+
error: (error === null || error === void 0 ? void 0 : error.message) || String(error),
|
|
102
|
+
});
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
this.consecutiveAuthFailures = 0;
|
|
108
|
+
}
|
|
109
|
+
if (this.errorCount >= this.maxRetries) {
|
|
110
|
+
this.client.emit('error', new Error(`Max retries (${this.maxRetries}) exceeded. Last error type: ${errorType}`));
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
this.errorDebug(`Scheduling retry in ${Math.round(delay / 1000)}s (type: ${errorType})`);
|
|
114
|
+
setTimeout(() => {
|
|
115
|
+
if (typeof this.client.reconnect === 'function') {
|
|
116
|
+
this.client.reconnect();
|
|
117
|
+
}
|
|
118
|
+
else if (typeof this.client._attemptReconnectSafely === 'function') {
|
|
119
|
+
this.client._attemptReconnectSafely().catch(() => { });
|
|
120
|
+
}
|
|
121
|
+
}, delay);
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
isRateLimited() {
|
|
125
|
+
return Date.now() < this.rateLimitUntil;
|
|
126
|
+
}
|
|
127
|
+
getRateLimitRemainingMs() {
|
|
128
|
+
return Math.max(0, this.rateLimitUntil - Date.now());
|
|
129
|
+
}
|
|
130
|
+
handlePayloadError(error, topic) {
|
|
131
|
+
this.errorDebug(`Payload Error on topic ${topic}: ${error.message}`);
|
|
132
|
+
this.client.emit('warning', {
|
|
133
|
+
type: 'payload_error',
|
|
134
|
+
topic,
|
|
135
|
+
error: error.message,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
handleProtocolError(error) {
|
|
139
|
+
this.errorDebug(`Protocol Error: ${error.message}`);
|
|
140
|
+
this.client.emit('error', new Error(`MQTT Protocol Error: ${error.message}`));
|
|
141
|
+
}
|
|
142
|
+
resetErrorCounter() {
|
|
143
|
+
this.errorCount = 0;
|
|
144
|
+
this.consecutiveAuthFailures = 0;
|
|
145
|
+
this.errorDebug('Error counter reset');
|
|
146
|
+
}
|
|
147
|
+
getErrorStats() {
|
|
148
|
+
const recentErrors = this.errorHistory.filter(e => Date.now() - e.timestamp < 3600000);
|
|
149
|
+
const typeBreakdown = {};
|
|
150
|
+
for (const e of recentErrors) {
|
|
151
|
+
typeBreakdown[e.type] = (typeBreakdown[e.type] || 0) + 1;
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
errorCount: this.errorCount,
|
|
155
|
+
maxRetries: this.maxRetries,
|
|
156
|
+
canRetry: this.errorCount < this.maxRetries,
|
|
157
|
+
isRateLimited: this.isRateLimited(),
|
|
158
|
+
rateLimitRemainingMs: this.getRateLimitRemainingMs(),
|
|
159
|
+
consecutiveAuthFailures: this.consecutiveAuthFailures,
|
|
160
|
+
recentErrorCount: recentErrors.length,
|
|
161
|
+
typeBreakdown,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
ErrorHandler.ERROR_TYPES = ERROR_TYPES;
|
|
166
|
+
exports.ErrorHandler = ErrorHandler;
|
|
167
|
+
exports.ERROR_TYPES = ERROR_TYPES;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GapHandler = void 0;
|
|
4
|
+
const shared_1 = require("../../shared");
|
|
5
|
+
/**
|
|
6
|
+
* Gap Handler - Handle message gaps and synchronization
|
|
7
|
+
*/
|
|
8
|
+
class GapHandler {
|
|
9
|
+
constructor(client) {
|
|
10
|
+
this.gapDebug = (0, shared_1.debugChannel)('realtime', 'gap');
|
|
11
|
+
this.threadGaps = new Map();
|
|
12
|
+
this.client = client;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Detect message gap in thread
|
|
16
|
+
*/
|
|
17
|
+
detectGap(threadId, lastMessageId, newMessageId) {
|
|
18
|
+
const lastId = parseInt(lastMessageId, 10);
|
|
19
|
+
const newId = parseInt(newMessageId, 10);
|
|
20
|
+
const gap = Math.abs(newId - lastId) > 1;
|
|
21
|
+
if (gap) {
|
|
22
|
+
this.gapDebug(`Gap detected in thread ${threadId}: ${lastMessageId} -> ${newMessageId}`);
|
|
23
|
+
this.threadGaps.set(threadId, { from: lastMessageId, to: newMessageId });
|
|
24
|
+
this.client.emit('gap', {
|
|
25
|
+
thread_id: threadId,
|
|
26
|
+
gap_from: lastMessageId,
|
|
27
|
+
gap_to: newMessageId,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return gap;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Handle gap by requesting missing messages
|
|
34
|
+
*/
|
|
35
|
+
async handleGap(threadId, gapFrom, gapTo) {
|
|
36
|
+
this.gapDebug(`Handling gap in ${threadId}: fetching messages ${gapFrom}-${gapTo}`);
|
|
37
|
+
try {
|
|
38
|
+
// Request missing messages from REST API
|
|
39
|
+
const thread = await this.client.ig.direct.getThread(threadId);
|
|
40
|
+
const messages = await thread.getMessages({ limit: 50 });
|
|
41
|
+
this.client.emit('gap_filled', {
|
|
42
|
+
thread_id: threadId,
|
|
43
|
+
messages_count: messages.length,
|
|
44
|
+
});
|
|
45
|
+
return messages;
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
this.gapDebug(`Failed to handle gap: ${err.message}`);
|
|
49
|
+
this.client.emit('error', new Error(`Gap handling failed for thread ${threadId}`));
|
|
50
|
+
return [];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Clear gap tracking for thread
|
|
55
|
+
*/
|
|
56
|
+
clearGap(threadId) {
|
|
57
|
+
this.threadGaps.delete(threadId);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.GapHandler = GapHandler;
|