nodejs-insta-private-api-mqt 1.3.82 → 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/{dist/repositories/account.repository.js → src-ts/dist/repositories/account.repository.ts} +54 -14
- 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/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,423 @@
|
|
|
1
|
+
const Repository = require('../core/repository');
|
|
2
|
+
const Chance = require('chance');
|
|
3
|
+
class DirectThreadRepository extends Repository {
|
|
4
|
+
constructor(client) {
|
|
5
|
+
super(client);
|
|
6
|
+
this.maxRetries = 3; // default max retries for requests
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Generic request wrapper with retry and debug logging
|
|
10
|
+
* @param {Function} requestFn - async function performing request
|
|
11
|
+
* @param {number} retries - current retry count
|
|
12
|
+
*/
|
|
13
|
+
async requestWithRetry(requestFn, retries = 0) {
|
|
14
|
+
var _a, _b, _c;
|
|
15
|
+
try {
|
|
16
|
+
if (process.env.DEBUG)
|
|
17
|
+
console.log(`[DEBUG] Attempt #${retries + 1}`);
|
|
18
|
+
const result = await requestFn();
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
const shouldRetry = (((_a = error.data) === null || _a === void 0 ? void 0 : _a.error_type) === 'server_error' ||
|
|
23
|
+
((_b = error.data) === null || _b === void 0 ? void 0 : _b.error_type) === 'rate_limited' ||
|
|
24
|
+
error.name === 'IgActionSpamError' ||
|
|
25
|
+
error.status === 503 ||
|
|
26
|
+
error.status === 429) &&
|
|
27
|
+
retries < this.maxRetries;
|
|
28
|
+
if (shouldRetry) {
|
|
29
|
+
const delay = 1000 * (retries + 1);
|
|
30
|
+
if (process.env.DEBUG)
|
|
31
|
+
console.log(`[DEBUG] Retrying after ${delay}ms due to ${((_c = error.data) === null || _c === void 0 ? void 0 : _c.error_type) || error.message || error.name || error.status}`);
|
|
32
|
+
await new Promise(resolve => setTimeout(resolve, delay));
|
|
33
|
+
return this.requestWithRetry(requestFn, retries + 1);
|
|
34
|
+
}
|
|
35
|
+
throw error;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Send a text message to a group thread
|
|
40
|
+
* @param {Object} options - { threadId, message }
|
|
41
|
+
*/
|
|
42
|
+
async sendToGroup(options) {
|
|
43
|
+
const { threadId, message } = options;
|
|
44
|
+
if (!threadId || !message)
|
|
45
|
+
throw new Error('threadId and message are required');
|
|
46
|
+
return this.broadcast({
|
|
47
|
+
threadIds: [threadId],
|
|
48
|
+
item: 'text',
|
|
49
|
+
form: { text: message },
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Fetch a specific thread by its ID
|
|
54
|
+
* @param {string} threadId
|
|
55
|
+
*/
|
|
56
|
+
async getThread(threadId) {
|
|
57
|
+
return this.requestWithRetry(async () => {
|
|
58
|
+
const response = await this.client.request.send({
|
|
59
|
+
method: 'GET',
|
|
60
|
+
url: `/api/v1/direct_v2/threads/${threadId}/`,
|
|
61
|
+
});
|
|
62
|
+
return response.body || response.data || response;
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Fetch threads by participants
|
|
67
|
+
* @param {Array} recipientUsers
|
|
68
|
+
*/
|
|
69
|
+
async getByParticipants(recipientUsers) {
|
|
70
|
+
return this.requestWithRetry(async () => {
|
|
71
|
+
const response = await this.client.request.send({
|
|
72
|
+
method: 'GET',
|
|
73
|
+
url: '/api/v1/direct_v2/threads/get_by_participants/',
|
|
74
|
+
qs: { recipient_users: JSON.stringify(recipientUsers) },
|
|
75
|
+
});
|
|
76
|
+
return response.body || response.data || response;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Broadcast a message to multiple threads or users
|
|
81
|
+
*/
|
|
82
|
+
async broadcast(options) {
|
|
83
|
+
const mutationToken = new Chance().guid();
|
|
84
|
+
const recipients = options.threadIds || options.userIds;
|
|
85
|
+
const recipientsType = options.threadIds ? 'thread_ids' : 'recipient_users';
|
|
86
|
+
const recipientsIds = Array.isArray(recipients) ? recipients : [recipients];
|
|
87
|
+
const recipientsValue = recipientsType === 'thread_ids'
|
|
88
|
+
? JSON.stringify(recipientsIds)
|
|
89
|
+
: JSON.stringify([recipientsIds]);
|
|
90
|
+
const form = {
|
|
91
|
+
action: 'send_item',
|
|
92
|
+
[recipientsType]: recipientsValue,
|
|
93
|
+
client_context: mutationToken,
|
|
94
|
+
_csrftoken: this.client.state.cookieCsrfToken,
|
|
95
|
+
device_id: this.client.state.deviceId,
|
|
96
|
+
mutation_token: mutationToken,
|
|
97
|
+
_uuid: this.client.state.uuid,
|
|
98
|
+
...options.form,
|
|
99
|
+
};
|
|
100
|
+
return this.requestWithRetry(async () => {
|
|
101
|
+
const payloadForm = options.signed && this.client.request && typeof this.client.request.sign === 'function'
|
|
102
|
+
? this.client.request.sign(form)
|
|
103
|
+
: form;
|
|
104
|
+
const response = await this.client.request.send({
|
|
105
|
+
url: `/api/v1/direct_v2/threads/broadcast/${options.item}/`,
|
|
106
|
+
method: 'POST',
|
|
107
|
+
form: payloadForm,
|
|
108
|
+
qs: options.qs,
|
|
109
|
+
});
|
|
110
|
+
return response.body || response.data || response;
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Broadcast a photo to one or more threads (uses REST configure_photo)
|
|
115
|
+
* Options:
|
|
116
|
+
* - uploadId (required) : upload_id returned from rupload
|
|
117
|
+
* - threadIds or threadId (required) : target thread id(s)
|
|
118
|
+
* - caption (optional) : caption/text to attach
|
|
119
|
+
* - signed (optional, default true) : whether to sign the form (if client.request.sign available)
|
|
120
|
+
*/
|
|
121
|
+
async broadcastPhoto(options) {
|
|
122
|
+
// normalize inputs
|
|
123
|
+
const uploadId = options.uploadId || options.upload_id || options.uploadIdStr;
|
|
124
|
+
const threadIds = options.threadIds || (options.threadId ? [options.threadId] : []);
|
|
125
|
+
const caption = options.caption || options.text || '';
|
|
126
|
+
const signed = (options.signed === undefined) ? true : !!options.signed; // default to true for media
|
|
127
|
+
const mutationToken = new Chance().guid();
|
|
128
|
+
const clientContext = mutationToken;
|
|
129
|
+
if (!uploadId)
|
|
130
|
+
throw new Error('broadcastPhoto: uploadId is required');
|
|
131
|
+
if (!threadIds || !Array.isArray(threadIds) || threadIds.length === 0)
|
|
132
|
+
throw new Error('broadcastPhoto: at least one threadId is required');
|
|
133
|
+
const form = {
|
|
134
|
+
action: 'send_item',
|
|
135
|
+
upload_id: uploadId.toString(),
|
|
136
|
+
thread_ids: JSON.stringify(threadIds),
|
|
137
|
+
client_context: clientContext,
|
|
138
|
+
_csrftoken: this.client.state.cookieCsrfToken,
|
|
139
|
+
mutation_token: mutationToken,
|
|
140
|
+
offline_threading_id: clientContext,
|
|
141
|
+
device_id: this.client.state.deviceId,
|
|
142
|
+
_uuid: this.client.state.uuid,
|
|
143
|
+
};
|
|
144
|
+
if (caption) {
|
|
145
|
+
// Instagram often expects 'text' for the message body
|
|
146
|
+
form.text = caption;
|
|
147
|
+
}
|
|
148
|
+
// perform request with retry wrapper
|
|
149
|
+
return this.requestWithRetry(async () => {
|
|
150
|
+
const payloadForm = (signed && this.client.request && typeof this.client.request.sign === 'function')
|
|
151
|
+
? this.client.request.sign(form)
|
|
152
|
+
: form;
|
|
153
|
+
const response = await this.client.request.send({
|
|
154
|
+
url: `/api/v1/direct_v2/threads/broadcast/configure_photo/`,
|
|
155
|
+
method: 'POST',
|
|
156
|
+
form: payloadForm,
|
|
157
|
+
qs: {
|
|
158
|
+
use_unified_inbox: true,
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
// normalize: some wrappers return { body } or axios response
|
|
162
|
+
const body = response && (response.body || response.data || response);
|
|
163
|
+
if (!body) {
|
|
164
|
+
const err = new Error('broadcastPhoto: empty response');
|
|
165
|
+
throw err;
|
|
166
|
+
}
|
|
167
|
+
// parse if string
|
|
168
|
+
let parsed = null;
|
|
169
|
+
if (typeof body === 'string') {
|
|
170
|
+
try {
|
|
171
|
+
parsed = JSON.parse(body);
|
|
172
|
+
}
|
|
173
|
+
catch (e) {
|
|
174
|
+
parsed = null;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
else if (typeof body === 'object') {
|
|
178
|
+
parsed = body;
|
|
179
|
+
}
|
|
180
|
+
// Typical success: parsed.status === 'ok' OR parsed.media/parsed.result/payload present
|
|
181
|
+
const ok = parsed && (parsed.status === 'ok' || parsed.media || parsed.result || parsed.payload || parsed.items || parsed.thread);
|
|
182
|
+
if (ok)
|
|
183
|
+
return parsed;
|
|
184
|
+
// If we reach here, treat as error to trigger retry logic
|
|
185
|
+
const error = new Error('broadcastPhoto: Request failed');
|
|
186
|
+
error.response = response;
|
|
187
|
+
if (parsed)
|
|
188
|
+
error.data = parsed;
|
|
189
|
+
throw error;
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Broadcast a raven (view-once/ephemeral) attachment to one or more threads via REST.
|
|
194
|
+
* IMPORTANT: Media must be uploaded to rupload.facebook.com/messenger_image/ first!
|
|
195
|
+
* Uses endpoint: /api/v1/direct_v2/threads/broadcast/raven_attachment/
|
|
196
|
+
*
|
|
197
|
+
* Options:
|
|
198
|
+
* - uploadId (required): upload_id from messenger_image rupload
|
|
199
|
+
* - attachmentFbid (optional): media_id from messenger_image upload response
|
|
200
|
+
* - threadIds or threadId (required): target thread id(s)
|
|
201
|
+
* - viewMode (optional, default 'replayable'): 'once' or 'replayable'
|
|
202
|
+
* - mediaType (optional, default '1'): '1' = photo, '2' = video
|
|
203
|
+
*/
|
|
204
|
+
async broadcastRaven(options) {
|
|
205
|
+
var _a, _b, _c, _d;
|
|
206
|
+
const uploadId = options.uploadId || options.upload_id;
|
|
207
|
+
const threadIds = options.threadIds || (options.threadId ? [options.threadId] : []);
|
|
208
|
+
const viewMode = options.viewMode || 'replayable';
|
|
209
|
+
const mediaType = String(options.mediaType || '1');
|
|
210
|
+
const attachmentFbid = options.attachmentFbid || options.attachment_fbid || null;
|
|
211
|
+
if (!uploadId)
|
|
212
|
+
throw new Error('broadcastRaven: uploadId is required');
|
|
213
|
+
if (!threadIds || !Array.isArray(threadIds) || threadIds.length === 0)
|
|
214
|
+
throw new Error('broadcastRaven: at least one threadId is required');
|
|
215
|
+
const { v4: uuidv4 } = require('uuid');
|
|
216
|
+
const clientContext = BigInt(Math.floor(Math.random() * 2 ** 62)).toString();
|
|
217
|
+
const now = Math.floor(Date.now() / 1000);
|
|
218
|
+
const form = {
|
|
219
|
+
allow_multi_configures: '1',
|
|
220
|
+
recipient_users: '[]',
|
|
221
|
+
view_mode: viewMode,
|
|
222
|
+
is_shh_mode: '0',
|
|
223
|
+
camera_entry_point: '3',
|
|
224
|
+
thread_ids: JSON.stringify(threadIds.map(String)),
|
|
225
|
+
reshare_mode: 'allow_reshare',
|
|
226
|
+
original_media_type: mediaType,
|
|
227
|
+
send_attribution: 'direct_thread_camera',
|
|
228
|
+
client_context: clientContext,
|
|
229
|
+
camera_session_id: uuidv4(),
|
|
230
|
+
include_e2ee_mentioned_user_list: '1',
|
|
231
|
+
hide_from_profile_grid: 'false',
|
|
232
|
+
scene_capture_type: '',
|
|
233
|
+
timezone_offset: String(new Date().getTimezoneOffset() * -60),
|
|
234
|
+
client_shared_at: String(now),
|
|
235
|
+
configure_mode: '2',
|
|
236
|
+
source_type: '4',
|
|
237
|
+
camera_position: 'unknown',
|
|
238
|
+
_uid: String(this.client.state.cookieUserId || this.client.state.igUserId),
|
|
239
|
+
device_id: this.client.state.deviceId,
|
|
240
|
+
composition_id: uuidv4(),
|
|
241
|
+
mutation_token: clientContext,
|
|
242
|
+
_uuid: this.client.state.uuid,
|
|
243
|
+
creation_tool_info: '[]',
|
|
244
|
+
creation_surface: 'camera',
|
|
245
|
+
capture_type: 'normal',
|
|
246
|
+
audience: 'default',
|
|
247
|
+
upload_id: uploadId.toString(),
|
|
248
|
+
client_timestamp: String(now),
|
|
249
|
+
sampled: 'true',
|
|
250
|
+
media_transformation_info: JSON.stringify({
|
|
251
|
+
width: '720', height: '1280',
|
|
252
|
+
x_transform: '0', y_transform: '0',
|
|
253
|
+
zoom: '1.0', rotation: '0.0', background_coverage: '0.0',
|
|
254
|
+
}),
|
|
255
|
+
edits: JSON.stringify({ filter_type: 0, filter_strength: 0.5, crop_original_size: [720.0, 1280.0] }),
|
|
256
|
+
extra: JSON.stringify({ source_width: 720, source_height: 1280 }),
|
|
257
|
+
device: JSON.stringify({
|
|
258
|
+
manufacturer: ((_a = this.client.state.devicePayload) === null || _a === void 0 ? void 0 : _a.manufacturer) || 'samsung',
|
|
259
|
+
model: ((_b = this.client.state.devicePayload) === null || _b === void 0 ? void 0 : _b.model) || 'SM-S938B',
|
|
260
|
+
android_version: ((_c = this.client.state.devicePayload) === null || _c === void 0 ? void 0 : _c.android_version) || 35,
|
|
261
|
+
android_release: ((_d = this.client.state.devicePayload) === null || _d === void 0 ? void 0 : _d.android_release) || '15',
|
|
262
|
+
}),
|
|
263
|
+
};
|
|
264
|
+
if (attachmentFbid) {
|
|
265
|
+
form.attachment_fbid = String(attachmentFbid);
|
|
266
|
+
}
|
|
267
|
+
return this.requestWithRetry(async () => {
|
|
268
|
+
const payloadForm = (this.client.request && typeof this.client.request.sign === 'function')
|
|
269
|
+
? this.client.request.sign(form)
|
|
270
|
+
: form;
|
|
271
|
+
const response = await this.client.request.send({
|
|
272
|
+
url: `/api/v1/direct_v2/threads/broadcast/raven_attachment/`,
|
|
273
|
+
method: 'POST',
|
|
274
|
+
form: payloadForm,
|
|
275
|
+
qs: {
|
|
276
|
+
use_unified_inbox: true,
|
|
277
|
+
},
|
|
278
|
+
});
|
|
279
|
+
const body = response && (response.body || response.data || response);
|
|
280
|
+
if (!body) {
|
|
281
|
+
throw new Error('broadcastRaven: empty response');
|
|
282
|
+
}
|
|
283
|
+
let parsed = null;
|
|
284
|
+
if (typeof body === 'string') {
|
|
285
|
+
try {
|
|
286
|
+
parsed = JSON.parse(body);
|
|
287
|
+
}
|
|
288
|
+
catch (e) {
|
|
289
|
+
parsed = null;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
else if (typeof body === 'object') {
|
|
293
|
+
parsed = body;
|
|
294
|
+
}
|
|
295
|
+
const ok = parsed && (parsed.status === 'ok' || parsed.media || parsed.result || parsed.payload || parsed.items || parsed.thread);
|
|
296
|
+
if (ok)
|
|
297
|
+
return parsed;
|
|
298
|
+
const error = new Error('broadcastRaven: Request failed');
|
|
299
|
+
error.response = response;
|
|
300
|
+
if (parsed)
|
|
301
|
+
error.data = parsed;
|
|
302
|
+
throw error;
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Mark a specific item in a thread as seen
|
|
307
|
+
*/
|
|
308
|
+
async markItemSeen(threadId, threadItemId) {
|
|
309
|
+
return this.requestWithRetry(async () => {
|
|
310
|
+
const response = await this.client.request.send({
|
|
311
|
+
url: `/api/v1/direct_v2/threads/${threadId}/items/${threadItemId}/seen/`,
|
|
312
|
+
method: 'POST',
|
|
313
|
+
form: {
|
|
314
|
+
_uuid: this.client.state.uuid,
|
|
315
|
+
use_unified_inbox: true,
|
|
316
|
+
action: 'mark_seen',
|
|
317
|
+
thread_id: threadId,
|
|
318
|
+
item_id: threadItemId,
|
|
319
|
+
},
|
|
320
|
+
});
|
|
321
|
+
return response.body || response.data || response;
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Delete an item from a thread
|
|
326
|
+
*/
|
|
327
|
+
async deleteItem(threadId, itemId) {
|
|
328
|
+
return this.requestWithRetry(async () => {
|
|
329
|
+
const response = await this.client.request.send({
|
|
330
|
+
url: `/api/v1/direct_v2/threads/${threadId}/items/${itemId}/delete/`,
|
|
331
|
+
method: 'POST',
|
|
332
|
+
});
|
|
333
|
+
return response.body || response.data || response;
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Approve a pending thread
|
|
338
|
+
*/
|
|
339
|
+
async approve(threadId) {
|
|
340
|
+
return this.requestWithRetry(async () => {
|
|
341
|
+
const response = await this.client.request.send({
|
|
342
|
+
url: `/api/v1/direct_v2/threads/${threadId}/approve/`,
|
|
343
|
+
method: 'POST',
|
|
344
|
+
});
|
|
345
|
+
return response.body || response.data || response;
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Decline a pending thread
|
|
350
|
+
*/
|
|
351
|
+
async decline(threadId) {
|
|
352
|
+
return this.requestWithRetry(async () => {
|
|
353
|
+
const response = await this.client.request.send({
|
|
354
|
+
url: `/api/v1/direct_v2/threads/${threadId}/decline/`,
|
|
355
|
+
method: 'POST',
|
|
356
|
+
});
|
|
357
|
+
return response.body || response.data || response;
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Mute a thread
|
|
362
|
+
*/
|
|
363
|
+
async mute(threadId) {
|
|
364
|
+
return this.requestWithRetry(async () => {
|
|
365
|
+
const response = await this.client.request.send({
|
|
366
|
+
url: `/api/v1/direct_v2/threads/${threadId}/mute/`,
|
|
367
|
+
method: 'POST',
|
|
368
|
+
});
|
|
369
|
+
return response.body || response.data || response;
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Unmute a thread
|
|
374
|
+
*/
|
|
375
|
+
async unmute(threadId) {
|
|
376
|
+
return this.requestWithRetry(async () => {
|
|
377
|
+
const response = await this.client.request.send({
|
|
378
|
+
url: `/api/v1/direct_v2/threads/${threadId}/unmute/`,
|
|
379
|
+
method: 'POST',
|
|
380
|
+
});
|
|
381
|
+
return response.body || response.data || response;
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Add users to a thread
|
|
386
|
+
*/
|
|
387
|
+
async addUser(threadId, userIds) {
|
|
388
|
+
if (!Array.isArray(userIds))
|
|
389
|
+
throw new Error('userIds must be an array');
|
|
390
|
+
return this.requestWithRetry(async () => {
|
|
391
|
+
const response = await this.client.request.send({
|
|
392
|
+
url: `/api/v1/direct_v2/threads/${threadId}/add_user/`,
|
|
393
|
+
method: 'POST',
|
|
394
|
+
});
|
|
395
|
+
return response.body || response.data || response;
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Leave a thread
|
|
400
|
+
*/
|
|
401
|
+
async leave(threadId) {
|
|
402
|
+
return this.requestWithRetry(async () => {
|
|
403
|
+
const response = await this.client.request.send({
|
|
404
|
+
url: `/api/v1/direct_v2/threads/${threadId}/leave/`,
|
|
405
|
+
method: 'POST',
|
|
406
|
+
});
|
|
407
|
+
return response.body || response.data || response;
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Update thread title
|
|
412
|
+
*/
|
|
413
|
+
async updateTitle(threadId, title) {
|
|
414
|
+
return this.requestWithRetry(async () => {
|
|
415
|
+
const response = await this.client.request.send({
|
|
416
|
+
url: `/api/v1/direct_v2/threads/${threadId}/update_title/`,
|
|
417
|
+
method: 'POST',
|
|
418
|
+
});
|
|
419
|
+
return response.body || response.data || response;
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
module.exports = DirectThreadRepository;
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
const Repository = require('../core/repository');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
class DirectRepository extends Repository {
|
|
4
|
+
constructor(client) {
|
|
5
|
+
super(client);
|
|
6
|
+
this.maxRetries = 3;
|
|
7
|
+
}
|
|
8
|
+
async requestWithRetry(requestFn, retries = 0) {
|
|
9
|
+
var _a, _b, _c, _d, _e, _f;
|
|
10
|
+
try {
|
|
11
|
+
const result = await requestFn();
|
|
12
|
+
return result;
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
const errorCode = ((_b = (_a = error.data) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.error_code) || ((_c = error.data) === null || _c === void 0 ? void 0 : _c.error_code);
|
|
16
|
+
const errorType = (_d = error.data) === null || _d === void 0 ? void 0 : _d.error_type;
|
|
17
|
+
const statusCode = error.status || ((_e = error.data) === null || _e === void 0 ? void 0 : _e.status_code);
|
|
18
|
+
const isPromptContribution = errorCode === 4415001;
|
|
19
|
+
const isAuthIssue = statusCode === 400 && isPromptContribution;
|
|
20
|
+
const isServerError = errorType === 'server_error';
|
|
21
|
+
const isRateLimited = errorType === 'rate_limited';
|
|
22
|
+
const isLoginRequired = ((_f = error.data) === null || _f === void 0 ? void 0 : _f.message) === 'login_required' || errorType === 'login_required';
|
|
23
|
+
if ((isAuthIssue || isLoginRequired) && retries < this.maxRetries) {
|
|
24
|
+
try {
|
|
25
|
+
if (this.client.state.authorization) {
|
|
26
|
+
this.client.state.updateAuthorization();
|
|
27
|
+
}
|
|
28
|
+
if (this.client.account && typeof this.client.account.syncPostLoginExperiments === 'function') {
|
|
29
|
+
await this.client.account.syncPostLoginExperiments().catch(() => { });
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
catch (syncErr) { }
|
|
33
|
+
const delay = 2000 * (retries + 1);
|
|
34
|
+
await new Promise(resolve => setTimeout(resolve, delay));
|
|
35
|
+
return this.requestWithRetry(requestFn, retries + 1);
|
|
36
|
+
}
|
|
37
|
+
const shouldRetry = (isServerError || isRateLimited) && retries < this.maxRetries;
|
|
38
|
+
if (shouldRetry) {
|
|
39
|
+
const delay = 1000 * (retries + 1);
|
|
40
|
+
await new Promise(resolve => setTimeout(resolve, delay));
|
|
41
|
+
return this.requestWithRetry(requestFn, retries + 1);
|
|
42
|
+
}
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
async send(options) {
|
|
47
|
+
const { to, message } = options;
|
|
48
|
+
if (!to || !message)
|
|
49
|
+
throw new Error('Recipient (to) and message are required');
|
|
50
|
+
return this.requestWithRetry(async () => {
|
|
51
|
+
const user = await this.client.user.infoByUsername(to);
|
|
52
|
+
const thread = await this.client.directThread.getByParticipants([user.pk]);
|
|
53
|
+
return this.client.directThread.broadcast({
|
|
54
|
+
threadIds: [thread.thread_id],
|
|
55
|
+
item: 'text',
|
|
56
|
+
form: { text: message },
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
async sendToUserId(userId, message) {
|
|
61
|
+
return this.requestWithRetry(async () => {
|
|
62
|
+
return this.client.directThread.broadcast({
|
|
63
|
+
userIds: [userId],
|
|
64
|
+
item: 'text',
|
|
65
|
+
form: { text: message },
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
async sendImage(options) {
|
|
70
|
+
const { to, imagePath } = options;
|
|
71
|
+
if (!to || !imagePath)
|
|
72
|
+
throw new Error('Recipient (to) and imagePath are required');
|
|
73
|
+
return this.requestWithRetry(async () => {
|
|
74
|
+
const imageBuffer = fs.readFileSync(imagePath);
|
|
75
|
+
const uploadResult = await this.client.upload.photo({ file: imageBuffer, uploadId: Date.now() });
|
|
76
|
+
const user = await this.client.user.infoByUsername(to);
|
|
77
|
+
const thread = await this.client.directThread.getByParticipants([user.pk]);
|
|
78
|
+
return this.client.directThread.broadcast({
|
|
79
|
+
threadIds: [thread.thread_id],
|
|
80
|
+
item: 'configure_photo',
|
|
81
|
+
form: { upload_id: uploadResult.upload_id, allow_full_aspect_ratio: true },
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
async sendVideo(options) {
|
|
86
|
+
const { to, videoPath } = options;
|
|
87
|
+
if (!to || !videoPath)
|
|
88
|
+
throw new Error('Recipient (to) and videoPath are required');
|
|
89
|
+
return this.requestWithRetry(async () => {
|
|
90
|
+
const videoBuffer = fs.readFileSync(videoPath);
|
|
91
|
+
const uploadResult = await this.client.upload.video({ video: videoBuffer, uploadId: Date.now() });
|
|
92
|
+
const user = await this.client.user.infoByUsername(to);
|
|
93
|
+
const thread = await this.client.directThread.getByParticipants([user.pk]);
|
|
94
|
+
return this.client.directThread.broadcast({
|
|
95
|
+
threadIds: [thread.thread_id],
|
|
96
|
+
item: 'configure_video',
|
|
97
|
+
form: { upload_id: uploadResult.upload_id, video_result: 'deprecated' },
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
async sendLink(options) {
|
|
102
|
+
const { to, text, urls } = options;
|
|
103
|
+
return this.requestWithRetry(async () => {
|
|
104
|
+
const user = await this.client.user.infoByUsername(to);
|
|
105
|
+
const thread = await this.client.directThread.getByParticipants([user.pk]);
|
|
106
|
+
return this.client.directThread.broadcast({
|
|
107
|
+
threadIds: [thread.thread_id],
|
|
108
|
+
item: 'link',
|
|
109
|
+
form: {
|
|
110
|
+
link_text: text || '',
|
|
111
|
+
link_urls: JSON.stringify(urls || []),
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
async sendMediaShare(options) {
|
|
117
|
+
const { to, mediaId } = options;
|
|
118
|
+
return this.requestWithRetry(async () => {
|
|
119
|
+
const user = await this.client.user.infoByUsername(to);
|
|
120
|
+
const thread = await this.client.directThread.getByParticipants([user.pk]);
|
|
121
|
+
return this.client.directThread.broadcast({
|
|
122
|
+
threadIds: [thread.thread_id],
|
|
123
|
+
item: 'media_share',
|
|
124
|
+
form: { media_id: mediaId },
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
async sendProfile(options) {
|
|
129
|
+
const { to, profileUserId } = options;
|
|
130
|
+
return this.requestWithRetry(async () => {
|
|
131
|
+
const user = await this.client.user.infoByUsername(to);
|
|
132
|
+
const thread = await this.client.directThread.getByParticipants([user.pk]);
|
|
133
|
+
return this.client.directThread.broadcast({
|
|
134
|
+
threadIds: [thread.thread_id],
|
|
135
|
+
item: 'profile',
|
|
136
|
+
form: { profile_user_id: profileUserId },
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
async sendHashtag(options) {
|
|
141
|
+
const { to, hashtag, text } = options;
|
|
142
|
+
return this.requestWithRetry(async () => {
|
|
143
|
+
const user = await this.client.user.infoByUsername(to);
|
|
144
|
+
const thread = await this.client.directThread.getByParticipants([user.pk]);
|
|
145
|
+
return this.client.directThread.broadcast({
|
|
146
|
+
threadIds: [thread.thread_id],
|
|
147
|
+
item: 'hashtag',
|
|
148
|
+
form: {
|
|
149
|
+
hashtag,
|
|
150
|
+
text: text || '',
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
async sendLocation(options) {
|
|
156
|
+
const { to, locationId, text } = options;
|
|
157
|
+
return this.requestWithRetry(async () => {
|
|
158
|
+
const user = await this.client.user.infoByUsername(to);
|
|
159
|
+
const thread = await this.client.directThread.getByParticipants([user.pk]);
|
|
160
|
+
return this.client.directThread.broadcast({
|
|
161
|
+
threadIds: [thread.thread_id],
|
|
162
|
+
item: 'location',
|
|
163
|
+
form: {
|
|
164
|
+
venue_id: locationId,
|
|
165
|
+
text: text || '',
|
|
166
|
+
},
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
async getInbox(cursor = null, limit = 20) {
|
|
171
|
+
if (!this.client.state.authorization) {
|
|
172
|
+
throw new Error('Not authenticated. Please login first before accessing inbox.');
|
|
173
|
+
}
|
|
174
|
+
const userId = this.client.state.cookieUserId || this.client.state._userId;
|
|
175
|
+
if (!userId || userId === '0' || userId === 0) {
|
|
176
|
+
this.client.state.updateAuthorization();
|
|
177
|
+
if (this.client.state.parsedAuthorization && this.client.state.parsedAuthorization.ds_user_id) {
|
|
178
|
+
this.client.state._userId = this.client.state.parsedAuthorization.ds_user_id;
|
|
179
|
+
this.client.state.cookieUserId = this.client.state.parsedAuthorization.ds_user_id;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return this.requestWithRetry(async () => {
|
|
183
|
+
const qs = { persistentBadging: true, limit };
|
|
184
|
+
if (cursor)
|
|
185
|
+
qs.cursor = cursor;
|
|
186
|
+
const response = await this.client.request.send({ method: 'GET', url: '/api/v1/direct_v2/inbox/', qs });
|
|
187
|
+
return response.body;
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
async getPendingInbox(cursor = null) {
|
|
191
|
+
return this.requestWithRetry(async () => {
|
|
192
|
+
const qs = cursor ? { cursor } : {};
|
|
193
|
+
const response = await this.client.request.send({ method: 'GET', url: '/api/v1/direct_v2/pending_inbox/', qs });
|
|
194
|
+
return response.body;
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
async createGroupThread(recipientUsers, threadTitle) {
|
|
198
|
+
if (!Array.isArray(recipientUsers) || !threadTitle)
|
|
199
|
+
throw new Error('recipientUsers must be array and threadTitle required');
|
|
200
|
+
return this.requestWithRetry(async () => {
|
|
201
|
+
const response = await this.client.request.send({
|
|
202
|
+
method: 'POST',
|
|
203
|
+
url: '/api/v1/direct_v2/create_group_thread/',
|
|
204
|
+
form: this.client.request.sign({
|
|
205
|
+
_uuid: this.client.state.uuid,
|
|
206
|
+
_uid: this.client.state.cookieUserId,
|
|
207
|
+
recipient_users: JSON.stringify(recipientUsers),
|
|
208
|
+
thread_title: threadTitle,
|
|
209
|
+
}),
|
|
210
|
+
});
|
|
211
|
+
return response.body;
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
async rankedRecipients(mode = 'raven', query = '') {
|
|
215
|
+
return this.requestWithRetry(async () => {
|
|
216
|
+
const response = await this.client.request.send({
|
|
217
|
+
method: 'GET',
|
|
218
|
+
url: '/api/v1/direct_v2/ranked_recipients/',
|
|
219
|
+
qs: { mode, query, show_threads: true },
|
|
220
|
+
});
|
|
221
|
+
return response.body;
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
async getPresence() {
|
|
225
|
+
return this.requestWithRetry(async () => {
|
|
226
|
+
const response = await this.client.request.send({ method: 'GET', url: '/api/v1/direct_v2/get_presence/' });
|
|
227
|
+
return response.body;
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
async markAsSeen(threadId, itemId) {
|
|
231
|
+
return this.client.directThread.markItemSeen(threadId, itemId);
|
|
232
|
+
}
|
|
233
|
+
async hideThread(threadId) {
|
|
234
|
+
return this.requestWithRetry(async () => {
|
|
235
|
+
const response = await this.client.request.send({
|
|
236
|
+
method: 'POST',
|
|
237
|
+
url: `/api/v1/direct_v2/threads/${threadId}/hide/`,
|
|
238
|
+
form: this.client.request.sign({
|
|
239
|
+
_uuid: this.client.state.uuid,
|
|
240
|
+
}),
|
|
241
|
+
});
|
|
242
|
+
return response.body;
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
module.exports = DirectRepository;
|