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,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* uploadPhoto.fixed.js
|
|
3
|
+
*
|
|
4
|
+
* Fixed and hardened version of uploadPhoto for nodejs-insta-private-api(-mqtt).
|
|
5
|
+
* - sends Buffer in `data` (axios uses `data`, not `body`)
|
|
6
|
+
* - sets axios-friendly headers (X-Entity-Type uses provided mimeType)
|
|
7
|
+
* - removes explicit Accept-Encoding header (axios handles it)
|
|
8
|
+
* - sets maxContentLength / maxBodyLength via Request httpClient (should be patched there too)
|
|
9
|
+
* - returns the rupload/uploadId (server-provided when available, otherwise local uploadId)
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
* const uploadPhoto = require('./uploadPhoto.fixed');
|
|
13
|
+
* const uploadId = await uploadPhoto(session, photoBuffer, { mimeType: 'image/jpeg' });
|
|
14
|
+
*
|
|
15
|
+
* Note: session.request.send(...) is expected to accept axios-like options.
|
|
16
|
+
*/
|
|
17
|
+
const { v4: uuidv4 } = require('uuid');
|
|
18
|
+
function validateImageInput(photoBuffer, mimeType) {
|
|
19
|
+
if (!photoBuffer || !Buffer.isBuffer(photoBuffer) || photoBuffer.length === 0) {
|
|
20
|
+
throw new Error('uploadPhoto: photoBuffer must be a non-empty Buffer.');
|
|
21
|
+
}
|
|
22
|
+
const allowed = ['image/jpeg', 'image/jpg', 'image/png'];
|
|
23
|
+
if (!allowed.includes(mimeType)) {
|
|
24
|
+
throw new Error(`uploadPhoto: mimeType must be one of ${allowed.join(', ')}.`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function buildRuploadParams(uploadId, mimeType) {
|
|
28
|
+
const isJpeg = mimeType === 'image/jpeg' || mimeType === 'image/jpg';
|
|
29
|
+
const compression = isJpeg
|
|
30
|
+
? { lib_name: 'moz', lib_version: '3.1.m', quality: '80' }
|
|
31
|
+
: { lib_name: 'png', lib_version: '1.0', quality: '100' };
|
|
32
|
+
// Match instagram-private-api shape; include is_sidecar for compatibility
|
|
33
|
+
return {
|
|
34
|
+
retry_context: JSON.stringify({ num_step_auto_retry: 0, num_reupload: 0, num_step_manual_retry: 0 }),
|
|
35
|
+
media_type: '1',
|
|
36
|
+
upload_id: uploadId.toString(),
|
|
37
|
+
xsharing_user_ids: JSON.stringify([]),
|
|
38
|
+
image_compression: JSON.stringify(compression),
|
|
39
|
+
is_sidecar: '0'
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Upload a photo buffer to Instagram rupload endpoint.
|
|
44
|
+
*
|
|
45
|
+
* @param {Object} session - client/session object that exposes session.request.send(options)
|
|
46
|
+
* @param {Buffer} photoBuffer - binary buffer of the image
|
|
47
|
+
* @param {Object} options - { mimeType = 'image/jpeg', fileName?, signal? }
|
|
48
|
+
* @returns {Promise<string>} uploadId (server upload_id when available, otherwise local uploadId)
|
|
49
|
+
*/
|
|
50
|
+
async function uploadPhoto(session, photoBuffer, options = {}) {
|
|
51
|
+
const { mimeType = 'image/jpeg', fileName, signal } = options;
|
|
52
|
+
validateImageInput(photoBuffer, mimeType);
|
|
53
|
+
// local upload id similar to insta clients
|
|
54
|
+
const uploadId = Date.now().toString();
|
|
55
|
+
// create an entity name similar to instagram-private-api naming
|
|
56
|
+
const randomSuffix = Math.floor(Math.random() * (9999999999 - 1000000000) + 1000000000);
|
|
57
|
+
const name = `${uploadId}_0_${randomSuffix}`;
|
|
58
|
+
const contentLength = photoBuffer.byteLength;
|
|
59
|
+
const ruploadParams = buildRuploadParams(uploadId, mimeType);
|
|
60
|
+
const headers = {
|
|
61
|
+
'X_FB_PHOTO_WATERFALL_ID': uuidv4(),
|
|
62
|
+
'X-Entity-Type': mimeType, // use actual mimeType
|
|
63
|
+
'Offset': '0',
|
|
64
|
+
'X-Instagram-Rupload-Params': JSON.stringify(ruploadParams),
|
|
65
|
+
'X-Entity-Name': name,
|
|
66
|
+
'X-Entity-Length': String(contentLength),
|
|
67
|
+
'Content-Type': 'application/octet-stream',
|
|
68
|
+
'Content-Length': String(contentLength),
|
|
69
|
+
// remove explicit Accept-Encoding to avoid conflicts; axios handles compression
|
|
70
|
+
// 'Accept-Encoding': 'gzip',
|
|
71
|
+
};
|
|
72
|
+
const url = `/rupload_igphoto/${name}`;
|
|
73
|
+
try {
|
|
74
|
+
// session.request.send is expected to forward options to axios (or similar)
|
|
75
|
+
// We MUST use `data` (not `body`) for axios-friendly request.
|
|
76
|
+
const response = await session.request.send({
|
|
77
|
+
url,
|
|
78
|
+
method: 'POST',
|
|
79
|
+
headers,
|
|
80
|
+
data: photoBuffer,
|
|
81
|
+
signal,
|
|
82
|
+
// ensure axios does not apply any transform that would corrupt binary
|
|
83
|
+
transformRequest: [(d) => d]
|
|
84
|
+
});
|
|
85
|
+
if (!response) {
|
|
86
|
+
throw new Error('uploadPhoto: Empty response from Instagram rupload endpoint.');
|
|
87
|
+
}
|
|
88
|
+
// The request wrapper in different forks may return { body, headers } OR axios response
|
|
89
|
+
// Normalize possible shapes:
|
|
90
|
+
let respBody = null;
|
|
91
|
+
if (response.body !== undefined) {
|
|
92
|
+
// wrapper returned { body, headers }
|
|
93
|
+
respBody = response.body;
|
|
94
|
+
}
|
|
95
|
+
else if (response.data !== undefined) {
|
|
96
|
+
respBody = response.data;
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
respBody = response;
|
|
100
|
+
}
|
|
101
|
+
// If respBody is a string, try parse JSON
|
|
102
|
+
let parsed = null;
|
|
103
|
+
if (typeof respBody === 'string') {
|
|
104
|
+
try {
|
|
105
|
+
parsed = JSON.parse(respBody);
|
|
106
|
+
}
|
|
107
|
+
catch (e) {
|
|
108
|
+
parsed = null;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
else if (typeof respBody === 'object') {
|
|
112
|
+
parsed = respBody;
|
|
113
|
+
}
|
|
114
|
+
// server might return upload_id inside parsed
|
|
115
|
+
const serverUploadId = parsed && (parsed.upload_id || parsed.uploadId || parsed.media && parsed.media.upload_id);
|
|
116
|
+
if (serverUploadId) {
|
|
117
|
+
return serverUploadId.toString();
|
|
118
|
+
}
|
|
119
|
+
// fallback: some endpoints respond with status only; return our local uploadId
|
|
120
|
+
return uploadId;
|
|
121
|
+
}
|
|
122
|
+
catch (err) {
|
|
123
|
+
// try to unwrap axios error message
|
|
124
|
+
let msg = '';
|
|
125
|
+
if (err && err.message)
|
|
126
|
+
msg = err.message;
|
|
127
|
+
else
|
|
128
|
+
msg = String(err);
|
|
129
|
+
throw new Error(`uploadPhoto: Upload failed — ${msg}`);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
module.exports = uploadPhoto;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
const { v4: uuidv4 } = require('uuid');
|
|
2
|
+
const axios = require('axios');
|
|
3
|
+
function buildRavenPhotoRuploadParams(uploadId) {
|
|
4
|
+
return {
|
|
5
|
+
retry_context: JSON.stringify({ num_step_auto_retry: 0, num_reupload: 0, num_step_manual_retry: 0 }),
|
|
6
|
+
media_type: '1',
|
|
7
|
+
upload_id: uploadId.toString(),
|
|
8
|
+
image_compression: JSON.stringify({ lib_name: 'moz', lib_version: '3.1.m', quality: '95' }),
|
|
9
|
+
xsharing_user_ids: JSON.stringify([]),
|
|
10
|
+
direct_v2: '1',
|
|
11
|
+
is_optimistic_upload: 'false',
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
async function sendRavenPhoto(session, photoBuffer, options = {}) {
|
|
15
|
+
var _a, _b, _c, _d;
|
|
16
|
+
const { threadId, viewMode = 'replayable', mimeType = 'image/jpeg', } = options;
|
|
17
|
+
if (!photoBuffer || !Buffer.isBuffer(photoBuffer) || photoBuffer.length === 0) {
|
|
18
|
+
throw new Error('sendRavenPhoto: photoBuffer must be a non-empty Buffer.');
|
|
19
|
+
}
|
|
20
|
+
if (!threadId) {
|
|
21
|
+
throw new Error('sendRavenPhoto: threadId is required.');
|
|
22
|
+
}
|
|
23
|
+
const uploadId = Date.now().toString();
|
|
24
|
+
const randomSuffix = Math.floor(Math.random() * (9999999999 - 1000000000) + 1000000000);
|
|
25
|
+
const name = `${uploadId}_0_${randomSuffix}`;
|
|
26
|
+
const waterfallId = uuidv4();
|
|
27
|
+
const ruploadParams = buildRavenPhotoRuploadParams(uploadId);
|
|
28
|
+
const defaultHeaders = session.request.getDefaultHeaders();
|
|
29
|
+
const messengerUploadHeaders = {
|
|
30
|
+
...defaultHeaders,
|
|
31
|
+
'X_FB_PHOTO_WATERFALL_ID': waterfallId,
|
|
32
|
+
'X-Entity-Type': mimeType,
|
|
33
|
+
'Offset': '0',
|
|
34
|
+
'X-Instagram-Rupload-Params': JSON.stringify(ruploadParams),
|
|
35
|
+
'X-Entity-Name': name,
|
|
36
|
+
'X-Entity-Length': String(photoBuffer.length),
|
|
37
|
+
'Content-Type': 'application/octet-stream',
|
|
38
|
+
'Content-Length': String(photoBuffer.length),
|
|
39
|
+
'ephemeral_media_view_mode': viewMode === 'replayable' ? '1' : '0',
|
|
40
|
+
'ig_raven_metadata': '{}',
|
|
41
|
+
'image_type': 'FILE_ATTACHMENT',
|
|
42
|
+
'Host': 'rupload.facebook.com',
|
|
43
|
+
};
|
|
44
|
+
const uploadResp = await axios({
|
|
45
|
+
url: `https://rupload.facebook.com/messenger_image/${name}`,
|
|
46
|
+
method: 'POST',
|
|
47
|
+
headers: messengerUploadHeaders,
|
|
48
|
+
data: photoBuffer,
|
|
49
|
+
maxBodyLength: Infinity,
|
|
50
|
+
maxContentLength: Infinity,
|
|
51
|
+
transformRequest: [(d) => d],
|
|
52
|
+
});
|
|
53
|
+
const uploadParsed = uploadResp.data;
|
|
54
|
+
const serverUploadId = (uploadParsed.upload_id || uploadId).toString();
|
|
55
|
+
const attachmentFbid = uploadParsed.media_id
|
|
56
|
+
|| (uploadParsed.media && uploadParsed.media.pk)
|
|
57
|
+
|| (uploadParsed.media && uploadParsed.media.id)
|
|
58
|
+
|| null;
|
|
59
|
+
const clientContext = BigInt(Math.floor(Math.random() * 2 ** 62)).toString();
|
|
60
|
+
const compositionId = uuidv4();
|
|
61
|
+
const cameraSessionId = uuidv4();
|
|
62
|
+
const now = Math.floor(Date.now() / 1000);
|
|
63
|
+
const form = {
|
|
64
|
+
allow_multi_configures: '1',
|
|
65
|
+
recipient_users: '[]',
|
|
66
|
+
view_mode: viewMode,
|
|
67
|
+
is_shh_mode: '0',
|
|
68
|
+
camera_entry_point: '3',
|
|
69
|
+
thread_ids: JSON.stringify([String(threadId)]),
|
|
70
|
+
reshare_mode: 'allow_reshare',
|
|
71
|
+
original_media_type: '1',
|
|
72
|
+
send_attribution: 'direct_thread_camera',
|
|
73
|
+
client_context: clientContext,
|
|
74
|
+
camera_session_id: cameraSessionId,
|
|
75
|
+
include_e2ee_mentioned_user_list: '1',
|
|
76
|
+
hide_from_profile_grid: 'false',
|
|
77
|
+
scene_capture_type: '',
|
|
78
|
+
timezone_offset: String(new Date().getTimezoneOffset() * -60),
|
|
79
|
+
client_shared_at: String(now),
|
|
80
|
+
configure_mode: '2',
|
|
81
|
+
source_type: '4',
|
|
82
|
+
camera_position: 'unknown',
|
|
83
|
+
_uid: String(session.state.cookieUserId || session.state.igUserId),
|
|
84
|
+
device_id: session.state.deviceId,
|
|
85
|
+
composition_id: compositionId,
|
|
86
|
+
mutation_token: clientContext,
|
|
87
|
+
_uuid: session.state.uuid,
|
|
88
|
+
creation_tool_info: '[]',
|
|
89
|
+
creation_surface: 'camera',
|
|
90
|
+
capture_type: 'normal',
|
|
91
|
+
audience: 'default',
|
|
92
|
+
upload_id: serverUploadId,
|
|
93
|
+
client_timestamp: String(now),
|
|
94
|
+
sampled: 'true',
|
|
95
|
+
media_transformation_info: JSON.stringify({
|
|
96
|
+
width: '720', height: '1280',
|
|
97
|
+
x_transform: '0', y_transform: '0',
|
|
98
|
+
zoom: '1.0', rotation: '0.0', background_coverage: '0.0',
|
|
99
|
+
}),
|
|
100
|
+
edits: JSON.stringify({ filter_type: 0, filter_strength: 0.5, crop_original_size: [720.0, 1280.0] }),
|
|
101
|
+
extra: JSON.stringify({ source_width: 720, source_height: 1280 }),
|
|
102
|
+
device: JSON.stringify({
|
|
103
|
+
manufacturer: ((_a = session.state.devicePayload) === null || _a === void 0 ? void 0 : _a.manufacturer) || 'samsung',
|
|
104
|
+
model: ((_b = session.state.devicePayload) === null || _b === void 0 ? void 0 : _b.model) || 'SM-S938B',
|
|
105
|
+
android_version: ((_c = session.state.devicePayload) === null || _c === void 0 ? void 0 : _c.android_version) || 35,
|
|
106
|
+
android_release: ((_d = session.state.devicePayload) === null || _d === void 0 ? void 0 : _d.android_release) || '15',
|
|
107
|
+
}),
|
|
108
|
+
};
|
|
109
|
+
if (attachmentFbid) {
|
|
110
|
+
form.attachment_fbid = String(attachmentFbid);
|
|
111
|
+
}
|
|
112
|
+
const signedForm = (session.request && typeof session.request.sign === 'function')
|
|
113
|
+
? session.request.sign(form)
|
|
114
|
+
: form;
|
|
115
|
+
const broadcastResponse = await session.request.send({
|
|
116
|
+
url: '/api/v1/direct_v2/threads/broadcast/raven_attachment/',
|
|
117
|
+
method: 'POST',
|
|
118
|
+
form: signedForm,
|
|
119
|
+
qs: { use_unified_inbox: true },
|
|
120
|
+
});
|
|
121
|
+
const body = broadcastResponse && (broadcastResponse.body || broadcastResponse.data || broadcastResponse);
|
|
122
|
+
return typeof body === 'string' ? JSON.parse(body) : body;
|
|
123
|
+
}
|
|
124
|
+
async function sendRavenPhotoOnce(session, photoBuffer, options = {}) {
|
|
125
|
+
return sendRavenPhoto(session, photoBuffer, { ...options, viewMode: 'once' });
|
|
126
|
+
}
|
|
127
|
+
async function sendRavenPhotoReplayable(session, photoBuffer, options = {}) {
|
|
128
|
+
return sendRavenPhoto(session, photoBuffer, { ...options, viewMode: 'replayable' });
|
|
129
|
+
}
|
|
130
|
+
module.exports = sendRavenPhoto;
|
|
131
|
+
module.exports.sendRavenPhoto = sendRavenPhoto;
|
|
132
|
+
module.exports.sendRavenPhotoOnce = sendRavenPhotoOnce;
|
|
133
|
+
module.exports.sendRavenPhotoReplayable = sendRavenPhotoReplayable;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
const { v4: uuidv4 } = require('uuid');
|
|
2
|
+
const axios = require('axios');
|
|
3
|
+
function buildRavenVideoRuploadParams(uploadId, options = {}) {
|
|
4
|
+
return {
|
|
5
|
+
retry_context: JSON.stringify({ num_step_auto_retry: 0, num_reupload: 0, num_step_manual_retry: 0 }),
|
|
6
|
+
media_type: '2',
|
|
7
|
+
upload_id: uploadId.toString(),
|
|
8
|
+
upload_media_duration_ms: String(Math.round((options.duration || 0) * 1000)),
|
|
9
|
+
upload_media_width: String(options.width || 720),
|
|
10
|
+
upload_media_height: String(options.height || 1280),
|
|
11
|
+
xsharing_user_ids: JSON.stringify([]),
|
|
12
|
+
direct_v2: '1',
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
async function sendRavenVideo(session, videoBuffer, options = {}) {
|
|
16
|
+
var _a, _b, _c, _d;
|
|
17
|
+
const { threadId, viewMode = 'replayable', duration = 0, width = 720, height = 1280, } = options;
|
|
18
|
+
if (!videoBuffer || !Buffer.isBuffer(videoBuffer) || videoBuffer.length === 0) {
|
|
19
|
+
throw new Error('sendRavenVideo: videoBuffer must be a non-empty Buffer.');
|
|
20
|
+
}
|
|
21
|
+
if (!threadId) {
|
|
22
|
+
throw new Error('sendRavenVideo: threadId is required.');
|
|
23
|
+
}
|
|
24
|
+
const uploadId = Date.now().toString();
|
|
25
|
+
const randomSuffix = Math.floor(Math.random() * (9999999999 - 1000000000) + 1000000000);
|
|
26
|
+
const name = `${uploadId}_0_${randomSuffix}`;
|
|
27
|
+
const waterfallId = uuidv4();
|
|
28
|
+
const ruploadParams = buildRavenVideoRuploadParams(uploadId, { duration, width, height });
|
|
29
|
+
const defaultHeaders = session.request.getDefaultHeaders();
|
|
30
|
+
const messengerUploadHeaders = {
|
|
31
|
+
...defaultHeaders,
|
|
32
|
+
'X_FB_VIDEO_WATERFALL_ID': waterfallId,
|
|
33
|
+
'X-Entity-Type': 'video/mp4',
|
|
34
|
+
'Offset': '0',
|
|
35
|
+
'X-Instagram-Rupload-Params': JSON.stringify(ruploadParams),
|
|
36
|
+
'X-Entity-Name': name,
|
|
37
|
+
'X-Entity-Length': String(videoBuffer.length),
|
|
38
|
+
'Content-Type': 'application/octet-stream',
|
|
39
|
+
'Content-Length': String(videoBuffer.length),
|
|
40
|
+
'ephemeral_media_view_mode': '1',
|
|
41
|
+
'ig_raven_metadata': '{}',
|
|
42
|
+
'video_type': 'FILE_ATTACHMENT',
|
|
43
|
+
'x-fb-congestion-signal': '1',
|
|
44
|
+
'Host': 'rupload.facebook.com',
|
|
45
|
+
};
|
|
46
|
+
const uploadResp = await axios({
|
|
47
|
+
url: `https://rupload.facebook.com/messenger_video/${name}`,
|
|
48
|
+
method: 'POST',
|
|
49
|
+
headers: messengerUploadHeaders,
|
|
50
|
+
data: videoBuffer,
|
|
51
|
+
maxBodyLength: Infinity,
|
|
52
|
+
maxContentLength: Infinity,
|
|
53
|
+
transformRequest: [(d) => d],
|
|
54
|
+
});
|
|
55
|
+
const uploadParsed = uploadResp.data;
|
|
56
|
+
const serverUploadId = (uploadParsed.upload_id || uploadId).toString();
|
|
57
|
+
const attachmentFbid = uploadParsed.media_id
|
|
58
|
+
|| (uploadParsed.media && uploadParsed.media.pk)
|
|
59
|
+
|| (uploadParsed.media && uploadParsed.media.id)
|
|
60
|
+
|| null;
|
|
61
|
+
const clientContext = BigInt(Math.floor(Math.random() * 2 ** 62)).toString();
|
|
62
|
+
const compositionId = uuidv4();
|
|
63
|
+
const cameraSessionId = uuidv4();
|
|
64
|
+
const now = Math.floor(Date.now() / 1000);
|
|
65
|
+
const form = {
|
|
66
|
+
allow_multi_configures: '1',
|
|
67
|
+
recipient_users: '[]',
|
|
68
|
+
view_mode: viewMode,
|
|
69
|
+
is_shh_mode: '0',
|
|
70
|
+
camera_entry_point: '3',
|
|
71
|
+
thread_ids: JSON.stringify([String(threadId)]),
|
|
72
|
+
reshare_mode: 'allow_reshare',
|
|
73
|
+
original_media_type: '1',
|
|
74
|
+
send_attribution: 'direct_thread_camera',
|
|
75
|
+
client_context: clientContext,
|
|
76
|
+
camera_session_id: cameraSessionId,
|
|
77
|
+
include_e2ee_mentioned_user_list: '1',
|
|
78
|
+
hide_from_profile_grid: 'false',
|
|
79
|
+
scene_capture_type: '',
|
|
80
|
+
timezone_offset: String(new Date().getTimezoneOffset() * -60),
|
|
81
|
+
client_shared_at: String(now),
|
|
82
|
+
configure_mode: '2',
|
|
83
|
+
source_type: '4',
|
|
84
|
+
camera_position: 'unknown',
|
|
85
|
+
_uid: String(session.state.cookieUserId || session.state.igUserId),
|
|
86
|
+
device_id: session.state.deviceId,
|
|
87
|
+
composition_id: compositionId,
|
|
88
|
+
mutation_token: clientContext,
|
|
89
|
+
_uuid: session.state.uuid,
|
|
90
|
+
creation_tool_info: '[]',
|
|
91
|
+
creation_surface: 'camera',
|
|
92
|
+
capture_type: 'normal',
|
|
93
|
+
audience: 'default',
|
|
94
|
+
upload_id: serverUploadId,
|
|
95
|
+
client_timestamp: String(now),
|
|
96
|
+
sampled: 'true',
|
|
97
|
+
video_result: '',
|
|
98
|
+
media_type: '1',
|
|
99
|
+
media_transformation_info: JSON.stringify({
|
|
100
|
+
width: String(width), height: String(height),
|
|
101
|
+
x_transform: '0', y_transform: '0',
|
|
102
|
+
zoom: '1.0', rotation: '0.0', background_coverage: '0.0',
|
|
103
|
+
}),
|
|
104
|
+
extra: JSON.stringify({ source_width: width, source_height: height }),
|
|
105
|
+
device: JSON.stringify({
|
|
106
|
+
manufacturer: ((_a = session.state.devicePayload) === null || _a === void 0 ? void 0 : _a.manufacturer) || 'samsung',
|
|
107
|
+
model: ((_b = session.state.devicePayload) === null || _b === void 0 ? void 0 : _b.model) || 'SM-S938B',
|
|
108
|
+
android_version: ((_c = session.state.devicePayload) === null || _c === void 0 ? void 0 : _c.android_version) || 35,
|
|
109
|
+
android_release: ((_d = session.state.devicePayload) === null || _d === void 0 ? void 0 : _d.android_release) || '15',
|
|
110
|
+
}),
|
|
111
|
+
};
|
|
112
|
+
if (attachmentFbid) {
|
|
113
|
+
form.attachment_fbid = String(attachmentFbid);
|
|
114
|
+
}
|
|
115
|
+
const signedForm = (session.request && typeof session.request.sign === 'function')
|
|
116
|
+
? session.request.sign(form)
|
|
117
|
+
: form;
|
|
118
|
+
const broadcastResponse = await session.request.send({
|
|
119
|
+
url: '/api/v1/direct_v2/threads/broadcast/raven_attachment/',
|
|
120
|
+
method: 'POST',
|
|
121
|
+
form: signedForm,
|
|
122
|
+
qs: { use_unified_inbox: true },
|
|
123
|
+
});
|
|
124
|
+
const body = broadcastResponse && (broadcastResponse.body || broadcastResponse.data || broadcastResponse);
|
|
125
|
+
return typeof body === 'string' ? JSON.parse(body) : body;
|
|
126
|
+
}
|
|
127
|
+
async function sendRavenVideoOnce(session, videoBuffer, options = {}) {
|
|
128
|
+
return sendRavenVideo(session, videoBuffer, { ...options, viewMode: 'once' });
|
|
129
|
+
}
|
|
130
|
+
async function sendRavenVideoReplayable(session, videoBuffer, options = {}) {
|
|
131
|
+
return sendRavenVideo(session, videoBuffer, { ...options, viewMode: 'replayable' });
|
|
132
|
+
}
|
|
133
|
+
module.exports = sendRavenVideo;
|
|
134
|
+
module.exports.sendRavenVideo = sendRavenVideo;
|
|
135
|
+
module.exports.sendRavenVideoOnce = sendRavenVideoOnce;
|
|
136
|
+
module.exports.sendRavenVideoReplayable = sendRavenVideoReplayable;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* uploadPhoto.js - FIXED version based on instagram-private-api
|
|
3
|
+
*/
|
|
4
|
+
const { v4: uuidv4 } = require('uuid');
|
|
5
|
+
/**
|
|
6
|
+
* Validate buffer and mime type
|
|
7
|
+
*/
|
|
8
|
+
function validateImageInput(photoBuffer, mimeType) {
|
|
9
|
+
if (!photoBuffer || !Buffer.isBuffer(photoBuffer) || photoBuffer.length === 0) {
|
|
10
|
+
throw new Error('uploadPhoto: photoBuffer must be a non-empty Buffer.');
|
|
11
|
+
}
|
|
12
|
+
const allowed = ['image/jpeg', 'image/jpg', 'image/png'];
|
|
13
|
+
if (!allowed.includes(mimeType)) {
|
|
14
|
+
throw new Error(`uploadPhoto: mimeType must be one of ${allowed.join(', ')}.`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Build Instagram rupload params for photo - Matching instagram-private-api
|
|
19
|
+
*/
|
|
20
|
+
function buildRuploadParams(uploadId, mimeType) {
|
|
21
|
+
const isJpeg = mimeType === 'image/jpeg' || mimeType === 'image/jpg';
|
|
22
|
+
const compression = isJpeg
|
|
23
|
+
? JSON.stringify({ lib_name: 'moz', lib_version: '3.1.m', quality: '80' })
|
|
24
|
+
: JSON.stringify({ lib_name: 'png', lib_version: '1.0', quality: '100' });
|
|
25
|
+
return {
|
|
26
|
+
retry_context: JSON.stringify({ num_step_auto_retry: 0, num_reupload: 0, num_step_manual_retry: 0 }),
|
|
27
|
+
media_type: '1', // String '1' per instagram-private-api
|
|
28
|
+
upload_id: uploadId.toString(),
|
|
29
|
+
xsharing_user_ids: JSON.stringify([]),
|
|
30
|
+
image_compression: compression,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Upload a photo to Instagram's rupload endpoint.
|
|
35
|
+
*/
|
|
36
|
+
async function uploadPhoto(session, photoBuffer, options = {}) {
|
|
37
|
+
const { mimeType = 'image/jpeg', fileName, signal, } = options;
|
|
38
|
+
validateImageInput(photoBuffer, mimeType);
|
|
39
|
+
const uploadId = Date.now().toString();
|
|
40
|
+
const name = `${uploadId}_0_${Math.floor(Math.random() * (9999999999 - 1000000000) + 1000000000)}`;
|
|
41
|
+
const contentLength = photoBuffer.byteLength;
|
|
42
|
+
const ruploadParams = buildRuploadParams(uploadId, mimeType);
|
|
43
|
+
// Headers expected by Instagram rupload (matched with instagram-private-api)
|
|
44
|
+
const headers = {
|
|
45
|
+
'X_FB_PHOTO_WATERFALL_ID': uuidv4(),
|
|
46
|
+
'X-Entity-Type': 'image/jpeg',
|
|
47
|
+
'Offset': '0',
|
|
48
|
+
'X-Instagram-Rupload-Params': JSON.stringify(ruploadParams),
|
|
49
|
+
'X-Entity-Name': name,
|
|
50
|
+
'X-Entity-Length': String(contentLength),
|
|
51
|
+
'Content-Type': 'application/octet-stream',
|
|
52
|
+
'Content-Length': String(contentLength),
|
|
53
|
+
'Accept-Encoding': 'gzip',
|
|
54
|
+
};
|
|
55
|
+
// If it's png, maybe we should adjust X-Entity-Type?
|
|
56
|
+
// instagram-private-api seems to hardcode 'image/jpeg' in the trace for 'photo' method.
|
|
57
|
+
// We'll stick to 'image/jpeg' for X-Entity-Type as per reference unless user provided PNG which might work anyway.
|
|
58
|
+
const url = `/rupload_igphoto/${name}`;
|
|
59
|
+
try {
|
|
60
|
+
const response = await session.request.send({
|
|
61
|
+
url,
|
|
62
|
+
method: 'POST',
|
|
63
|
+
headers,
|
|
64
|
+
body: photoBuffer,
|
|
65
|
+
signal,
|
|
66
|
+
});
|
|
67
|
+
if (!response) {
|
|
68
|
+
throw new Error('uploadPhoto: Empty response from Instagram rupload endpoint.');
|
|
69
|
+
}
|
|
70
|
+
// Try to get upload_id from response
|
|
71
|
+
let serverUploadId = null;
|
|
72
|
+
if (typeof response === 'object' && response.body) {
|
|
73
|
+
try {
|
|
74
|
+
const body = typeof response.body === 'string' ? JSON.parse(response.body) : response.body;
|
|
75
|
+
serverUploadId = body.upload_id;
|
|
76
|
+
}
|
|
77
|
+
catch (e) {
|
|
78
|
+
// ignore parse error
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return serverUploadId || uploadId;
|
|
82
|
+
}
|
|
83
|
+
catch (err) {
|
|
84
|
+
// If error, try to extract message
|
|
85
|
+
const msg = err.message || err.toString();
|
|
86
|
+
throw new Error(`uploadPhoto: Upload failed — ${msg}`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
module.exports = uploadPhoto;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* uploadfFile.js - FIXED version based on instagram-private-api
|
|
3
|
+
*/
|
|
4
|
+
const { v4: uuidv4 } = require('uuid');
|
|
5
|
+
const DEFAULT_CHUNK_SIZE = 512 * 1024; // 512KB
|
|
6
|
+
/**
|
|
7
|
+
* Validate upload input
|
|
8
|
+
*/
|
|
9
|
+
function validateFileInput(fileBuffer, mimeType) {
|
|
10
|
+
if (!fileBuffer || !Buffer.isBuffer(fileBuffer) || fileBuffer.length === 0) {
|
|
11
|
+
throw new Error('uploadFile: fileBuffer must be a non-empty Buffer.');
|
|
12
|
+
}
|
|
13
|
+
if (typeof mimeType !== 'string' || mimeType.length === 0) {
|
|
14
|
+
throw new Error('uploadFile: mimeType must be a non-empty string.');
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Build rupload params - Matching instagram-private-api
|
|
19
|
+
*/
|
|
20
|
+
function buildRuploadParams(uploadId, mimeType, opts) {
|
|
21
|
+
var _a, _b, _c;
|
|
22
|
+
const isVideo = mimeType.startsWith('video/');
|
|
23
|
+
const isAudio = mimeType.startsWith('audio/');
|
|
24
|
+
const params = {
|
|
25
|
+
retry_context: JSON.stringify({ num_step_auto_retry: 0, num_reupload: 0, num_step_manual_retry: 0 }),
|
|
26
|
+
media_type: isVideo ? '2' : '3', // 2 for video, 3 for audio/others?
|
|
27
|
+
upload_id: uploadId.toString(),
|
|
28
|
+
xsharing_user_ids: JSON.stringify([]),
|
|
29
|
+
};
|
|
30
|
+
if (isVideo) {
|
|
31
|
+
params.upload_media_duration_ms = ((_a = opts.duration) === null || _a === void 0 ? void 0 : _a.toString()) || '0';
|
|
32
|
+
params.upload_media_width = ((_b = opts.width) === null || _b === void 0 ? void 0 : _b.toString()) || '720';
|
|
33
|
+
params.upload_media_height = ((_c = opts.height) === null || _c === void 0 ? void 0 : _c.toString()) || '1280';
|
|
34
|
+
params.direct_v2 = '1';
|
|
35
|
+
}
|
|
36
|
+
return params;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Upload file via rupload with chunking.
|
|
40
|
+
*/
|
|
41
|
+
async function uploadFile(session, fileBuffer, options = {}) {
|
|
42
|
+
const { mimeType = 'video/mp4', fileName, chunkSize = DEFAULT_CHUNK_SIZE, signal, } = options;
|
|
43
|
+
validateFileInput(fileBuffer, mimeType);
|
|
44
|
+
const uploadId = Date.now().toString();
|
|
45
|
+
const name = `${uploadId}_0_${Math.floor(Math.random() * 9000000000 + 1000000000)}`;
|
|
46
|
+
const totalLength = fileBuffer.length;
|
|
47
|
+
const waterfallId = uuidv4();
|
|
48
|
+
const ruploadParams = buildRuploadParams(uploadId, mimeType, options);
|
|
49
|
+
const endpoint = mimeType.startsWith('image/')
|
|
50
|
+
? `/rupload_igphoto/${name}`
|
|
51
|
+
: `/rupload_igvideo/${name}`;
|
|
52
|
+
// Start upload
|
|
53
|
+
let offset = 0;
|
|
54
|
+
const size = Math.max(64 * 1024, Math.min(4 * 1024 * 1024, chunkSize));
|
|
55
|
+
try {
|
|
56
|
+
while (offset < totalLength) {
|
|
57
|
+
const end = Math.min(offset + size, totalLength);
|
|
58
|
+
const chunk = fileBuffer.subarray(offset, end);
|
|
59
|
+
const headers = {
|
|
60
|
+
'X-Instagram-Rupload-Params': JSON.stringify(ruploadParams),
|
|
61
|
+
'X_FB_VIDEO_WATERFALL_ID': waterfallId,
|
|
62
|
+
'X-Entity-Type': mimeType,
|
|
63
|
+
'X-Entity-Name': name,
|
|
64
|
+
'X-Entity-Length': String(totalLength),
|
|
65
|
+
'Offset': String(offset),
|
|
66
|
+
'Content-Type': 'application/octet-stream',
|
|
67
|
+
'Content-Length': String(chunk.length),
|
|
68
|
+
'Accept-Encoding': 'gzip',
|
|
69
|
+
};
|
|
70
|
+
const res = await session.request.send({
|
|
71
|
+
url: endpoint,
|
|
72
|
+
method: 'POST',
|
|
73
|
+
headers,
|
|
74
|
+
body: chunk,
|
|
75
|
+
signal,
|
|
76
|
+
});
|
|
77
|
+
if (!res)
|
|
78
|
+
throw new Error(`uploadFile: Empty response at offset ${offset}`);
|
|
79
|
+
offset = end;
|
|
80
|
+
}
|
|
81
|
+
// Finalize
|
|
82
|
+
const confirm = await session.request.send({
|
|
83
|
+
url: endpoint,
|
|
84
|
+
method: 'POST',
|
|
85
|
+
headers: {
|
|
86
|
+
'X-Instagram-Rupload-Params': JSON.stringify(ruploadParams),
|
|
87
|
+
'X_FB_VIDEO_WATERFALL_ID': waterfallId,
|
|
88
|
+
'X-Entity-Type': mimeType,
|
|
89
|
+
'Offset': String(totalLength),
|
|
90
|
+
'Content-Length': '0',
|
|
91
|
+
},
|
|
92
|
+
signal,
|
|
93
|
+
});
|
|
94
|
+
let serverUploadId = null;
|
|
95
|
+
if (confirm && confirm.body) {
|
|
96
|
+
try {
|
|
97
|
+
const body = typeof confirm.body === 'string' ? JSON.parse(confirm.body) : confirm.body;
|
|
98
|
+
serverUploadId = body.upload_id;
|
|
99
|
+
}
|
|
100
|
+
catch (e) { }
|
|
101
|
+
}
|
|
102
|
+
return serverUploadId || uploadId;
|
|
103
|
+
}
|
|
104
|
+
catch (err) {
|
|
105
|
+
throw new Error(`uploadFile: Upload failed — ${err.message}`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
module.exports = uploadFile;
|