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