nodejs-insta-private-api-mqtt 1.0.0
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/README.md +1650 -0
- package/dist/constants/constants.js +280 -0
- package/dist/constants/index.js +41 -0
- package/dist/core/client.js +243 -0
- package/dist/core/repository.js +7 -0
- package/dist/core/request.js +212 -0
- package/dist/core/state.js +1456 -0
- package/dist/core/utils.js +786 -0
- package/dist/downloadMedia.js +381 -0
- package/dist/errors/index.d.ts +16 -0
- package/dist/errors/index.js +30 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/fbns/fbns.client.d.ts +32 -0
- package/dist/fbns/fbns.client.events.d.ts +41 -0
- package/dist/fbns/fbns.client.events.js +3 -0
- package/dist/fbns/fbns.client.events.js.map +1 -0
- package/dist/fbns/fbns.client.js +179 -0
- package/dist/fbns/fbns.client.js.map +1 -0
- package/dist/fbns/fbns.device-auth.d.ts +17 -0
- package/dist/fbns/fbns.device-auth.js +54 -0
- package/dist/fbns/fbns.device-auth.js.map +1 -0
- package/dist/fbns/fbns.types.d.ts +83 -0
- package/dist/fbns/fbns.types.js +3 -0
- package/dist/fbns/fbns.types.js.map +1 -0
- package/dist/fbns/fbns.utilities.d.ts +2 -0
- package/dist/fbns/fbns.utilities.js +79 -0
- package/dist/fbns/fbns.utilities.js.map +1 -0
- package/dist/fbns/index.d.ts +4 -0
- package/dist/fbns/index.js +21 -0
- package/dist/fbns/index.js.map +1 -0
- package/dist/index.js +39 -0
- package/dist/mqttot/index.d.ts +4 -0
- package/dist/mqttot/index.js +21 -0
- package/dist/mqttot/index.js.map +1 -0
- package/dist/mqttot/mqttot.client.d.ts +39 -0
- package/dist/mqttot/mqttot.client.js +120 -0
- package/dist/mqttot/mqttot.client.js.map +1 -0
- package/dist/mqttot/mqttot.connect.request.packet.d.ts +7 -0
- package/dist/mqttot/mqttot.connect.request.packet.js +9 -0
- package/dist/mqttot/mqttot.connect.request.packet.js.map +1 -0
- package/dist/mqttot/mqttot.connect.response.packet.d.ts +7 -0
- package/dist/mqttot/mqttot.connect.response.packet.js +24 -0
- package/dist/mqttot/mqttot.connect.response.packet.js.map +1 -0
- package/dist/mqttot/mqttot.connection.d.ts +57 -0
- package/dist/mqttot/mqttot.connection.js +56 -0
- package/dist/mqttot/mqttot.connection.js.map +1 -0
- package/dist/package.json +59 -0
- package/dist/realtime/commands/commands.d.ts +15 -0
- package/dist/realtime/commands/commands.js +21 -0
- package/dist/realtime/commands/commands.js.map +1 -0
- package/dist/realtime/commands/direct.commands.d.ts +75 -0
- package/dist/realtime/commands/direct.commands.js +186 -0
- package/dist/realtime/commands/direct.commands.js.map +1 -0
- package/dist/realtime/commands/enhanced.direct.commands.js +987 -0
- package/dist/realtime/commands/index.d.ts +2 -0
- package/dist/realtime/commands/index.js +19 -0
- package/dist/realtime/commands/index.js.map +1 -0
- package/dist/realtime/delta-sync.manager.js +293 -0
- package/dist/realtime/features/dm-sender.js +88 -0
- package/dist/realtime/features/error-handler.js +73 -0
- package/dist/realtime/features/gap-handler.js +61 -0
- package/dist/realtime/features/presence.manager.js +66 -0
- package/dist/realtime/index.js +30 -0
- package/dist/realtime/messages/app-presence.event.d.ts +9 -0
- package/dist/realtime/messages/app-presence.event.js +3 -0
- package/dist/realtime/messages/app-presence.event.js.map +1 -0
- package/dist/realtime/messages/index.d.ts +3 -0
- package/dist/realtime/messages/index.js +20 -0
- package/dist/realtime/messages/index.js.map +1 -0
- package/dist/realtime/messages/message-sync.message.d.ts +222 -0
- package/dist/realtime/messages/message-sync.message.js +43 -0
- package/dist/realtime/messages/message-sync.message.js.map +1 -0
- package/dist/realtime/messages/realtime-sub.direct.data.d.ts +11 -0
- package/dist/realtime/messages/realtime-sub.direct.data.js +3 -0
- package/dist/realtime/messages/realtime-sub.direct.data.js.map +1 -0
- package/dist/realtime/messages/thread-update.message.d.ts +68 -0
- package/dist/realtime/messages/thread-update.message.js +3 -0
- package/dist/realtime/messages/thread-update.message.js.map +1 -0
- package/dist/realtime/mixins/index.d.ts +3 -0
- package/dist/realtime/mixins/index.js +20 -0
- package/dist/realtime/mixins/index.js.map +1 -0
- package/dist/realtime/mixins/message-sync.mixin.d.ts +8 -0
- package/dist/realtime/mixins/message-sync.mixin.js +381 -0
- package/dist/realtime/mixins/message-sync.mixin.js.map +1 -0
- package/dist/realtime/mixins/mixin.d.ts +19 -0
- package/dist/realtime/mixins/mixin.js +41 -0
- package/dist/realtime/mixins/mixin.js.map +1 -0
- package/dist/realtime/mixins/presence-typing.mixin.js +33 -0
- package/dist/realtime/mixins/realtime-sub.mixin.d.ts +8 -0
- package/dist/realtime/mixins/realtime-sub.mixin.js +55 -0
- package/dist/realtime/mixins/realtime-sub.mixin.js.map +1 -0
- package/dist/realtime/parsers/graphql-parser.js +43 -0
- package/dist/realtime/parsers/graphql.parser.d.ts +15 -0
- package/dist/realtime/parsers/graphql.parser.js +22 -0
- package/dist/realtime/parsers/graphql.parser.js.map +1 -0
- package/dist/realtime/parsers/index.d.ts +6 -0
- package/dist/realtime/parsers/index.js +23 -0
- package/dist/realtime/parsers/index.js.map +1 -0
- package/dist/realtime/parsers/iris-parser.js +43 -0
- package/dist/realtime/parsers/iris.parser.d.ts +17 -0
- package/dist/realtime/parsers/iris.parser.js +10 -0
- package/dist/realtime/parsers/iris.parser.js.map +1 -0
- package/dist/realtime/parsers/json-parser.js +43 -0
- package/dist/realtime/parsers/json.parser.d.ts +6 -0
- package/dist/realtime/parsers/json.parser.js +10 -0
- package/dist/realtime/parsers/json.parser.js.map +1 -0
- package/dist/realtime/parsers/parser.d.ts +9 -0
- package/dist/realtime/parsers/parser.js +3 -0
- package/dist/realtime/parsers/parser.js.map +1 -0
- package/dist/realtime/parsers/region-hint-parser.js +43 -0
- package/dist/realtime/parsers/region-hint.parser.d.ts +12 -0
- package/dist/realtime/parsers/region-hint.parser.js +15 -0
- package/dist/realtime/parsers/region-hint.parser.js.map +1 -0
- package/dist/realtime/parsers/skywalker-parser.js +43 -0
- package/dist/realtime/parsers/skywalker.parser.d.ts +12 -0
- package/dist/realtime/parsers/skywalker.parser.js +15 -0
- package/dist/realtime/parsers/skywalker.parser.js.map +1 -0
- package/dist/realtime/parsers-advanced.js +158 -0
- package/dist/realtime/proto/common.proto +38 -0
- package/dist/realtime/proto/direct.proto +65 -0
- package/dist/realtime/proto/ig-messages.proto +83 -0
- package/dist/realtime/proto/iris.proto +188 -0
- package/dist/realtime/proto-parser.js +195 -0
- package/dist/realtime/protocols/iris.handshake.js +74 -0
- package/dist/realtime/protocols/proto-definitions.js +80 -0
- package/dist/realtime/protocols/skywalker.protocol.js +91 -0
- package/dist/realtime/realtime.client.events.js +3 -0
- package/dist/realtime/realtime.client.js +449 -0
- package/dist/realtime/realtime.service.js +462 -0
- package/dist/realtime/reconnect.manager.js +94 -0
- package/dist/realtime/session.manager.js +121 -0
- package/dist/realtime/subscriptions/graphql.subscription.d.ts +47 -0
- package/dist/realtime/subscriptions/graphql.subscription.js +99 -0
- package/dist/realtime/subscriptions/graphql.subscription.js.map +1 -0
- package/dist/realtime/subscriptions/index.d.ts +2 -0
- package/dist/realtime/subscriptions/index.js +19 -0
- package/dist/realtime/subscriptions/index.js.map +1 -0
- package/dist/realtime/subscriptions/skywalker.subscription.d.ts +4 -0
- package/dist/realtime/subscriptions/skywalker.subscription.js +13 -0
- package/dist/realtime/subscriptions/skywalker.subscription.js.map +1 -0
- package/dist/realtime/topic-map.js +71 -0
- package/dist/realtime/topic.js +80 -0
- package/dist/repositories/account.repository.js +261 -0
- package/dist/repositories/direct-thread.repository.js +247 -0
- package/dist/repositories/direct.repository.js +153 -0
- package/dist/repositories/feed.repository.js +233 -0
- package/dist/repositories/friendship.repository.js +190 -0
- package/dist/repositories/hashtag.repository.js +101 -0
- package/dist/repositories/highlights.repository.js +127 -0
- package/dist/repositories/location.repository.js +84 -0
- package/dist/repositories/media.repository.js +165 -0
- package/dist/repositories/story.repository.js +156 -0
- package/dist/repositories/upload.repository.js +167 -0
- package/dist/repositories/user.repository.js +94 -0
- package/dist/sendmedia/index.js +11 -0
- package/dist/sendmedia/sendFile.js +154 -0
- package/dist/sendmedia/sendPhoto.js +145 -0
- package/dist/sendmedia/uploadPhoto.js +175 -0
- package/dist/sendmedia/uploadfFile.js +264 -0
- package/dist/services/live.service.js +147 -0
- package/dist/services/search.service.js +116 -0
- package/dist/shared/index.js +35 -0
- package/dist/shared/shared.js +86 -0
- package/dist/thrift/index.d.ts +3 -0
- package/dist/thrift/index.js +20 -0
- package/dist/thrift/index.js.map +1 -0
- package/dist/thrift/thrift.d.ts +59 -0
- package/dist/thrift/thrift.js +101 -0
- package/dist/thrift/thrift.js.map +1 -0
- package/dist/thrift/thrift.reading.d.ts +41 -0
- package/dist/thrift/thrift.reading.js +327 -0
- package/dist/thrift/thrift.reading.js.map +1 -0
- package/dist/thrift/thrift.writing.d.ts +44 -0
- package/dist/thrift/thrift.writing.js +342 -0
- package/dist/thrift/thrift.writing.js.map +1 -0
- package/dist/types/index.js +285 -0
- package/dist/useMultiFileAuthState.js +437 -0
- package/dist/utils/helper-1.js +1 -0
- package/dist/utils/helper-10.js +1 -0
- package/dist/utils/helper-11.js +1 -0
- package/dist/utils/helper-12.js +1 -0
- package/dist/utils/helper-13.js +1 -0
- package/dist/utils/helper-14.js +1 -0
- package/dist/utils/helper-15.js +1 -0
- package/dist/utils/helper-16.js +1 -0
- package/dist/utils/helper-17.js +1 -0
- package/dist/utils/helper-18.js +1 -0
- package/dist/utils/helper-19.js +1 -0
- package/dist/utils/helper-2.js +1 -0
- package/dist/utils/helper-20.js +1 -0
- package/dist/utils/helper-21.js +1 -0
- package/dist/utils/helper-22.js +1 -0
- package/dist/utils/helper-23.js +1 -0
- package/dist/utils/helper-24.js +1 -0
- package/dist/utils/helper-25.js +1 -0
- package/dist/utils/helper-26.js +1 -0
- package/dist/utils/helper-27.js +1 -0
- package/dist/utils/helper-28.js +1 -0
- package/dist/utils/helper-29.js +1 -0
- package/dist/utils/helper-3.js +1 -0
- package/dist/utils/helper-30.js +1 -0
- package/dist/utils/helper-4.js +1 -0
- package/dist/utils/helper-5.js +1 -0
- package/dist/utils/helper-6.js +1 -0
- package/dist/utils/helper-7.js +1 -0
- package/dist/utils/helper-8.js +1 -0
- package/dist/utils/helper-9.js +1 -0
- package/dist/utils/index.js +280 -0
- package/examples/listen-to-messages.js +86 -0
- package/package.json +79 -0
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
const axios = require('axios');
|
|
2
|
+
const crypto = require('crypto');
|
|
3
|
+
const { random } = require('lodash');
|
|
4
|
+
|
|
5
|
+
class Request {
|
|
6
|
+
constructor(client) {
|
|
7
|
+
this.client = client;
|
|
8
|
+
this.end$ = { complete: () => {} };
|
|
9
|
+
this.error$ = { complete: () => {} };
|
|
10
|
+
|
|
11
|
+
// Create axios instance with default config
|
|
12
|
+
this.httpClient = axios.create({
|
|
13
|
+
baseURL: 'https://i.instagram.com/',
|
|
14
|
+
timeout: 30000,
|
|
15
|
+
headers: {
|
|
16
|
+
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
signature(data) {
|
|
22
|
+
return crypto.createHmac('sha256', this.client.state.signatureKey)
|
|
23
|
+
.update(data)
|
|
24
|
+
.digest('hex');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
sign(payload) {
|
|
28
|
+
const json = typeof payload === 'object' ? JSON.stringify(payload) : payload;
|
|
29
|
+
const signature = this.signature(json);
|
|
30
|
+
return {
|
|
31
|
+
ig_sig_key_version: this.client.state.signatureVersion,
|
|
32
|
+
signed_body: `${signature}.${json}`,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
userBreadcrumb(size) {
|
|
37
|
+
const term = random(2, 3) * 1000 + size + random(15, 20) * 1000;
|
|
38
|
+
const textChangeEventCount = Math.round(size / random(2, 3)) || 1;
|
|
39
|
+
const data = `${size} ${term} ${textChangeEventCount} ${Date.now()}`;
|
|
40
|
+
const signature = Buffer.from(
|
|
41
|
+
crypto.createHmac('sha256', this.client.state.userBreadcrumbKey)
|
|
42
|
+
.update(data)
|
|
43
|
+
.digest('hex'),
|
|
44
|
+
).toString('base64');
|
|
45
|
+
const body = Buffer.from(data).toString('base64');
|
|
46
|
+
return `${signature}\n${body}\n`;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async send(options) {
|
|
50
|
+
const config = {
|
|
51
|
+
...options,
|
|
52
|
+
headers: {
|
|
53
|
+
...this.getDefaultHeaders(),
|
|
54
|
+
...(options.headers || {})
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
// Handle form data
|
|
59
|
+
if (options.form) {
|
|
60
|
+
if (options.method === 'POST' || options.method === 'PUT') {
|
|
61
|
+
const formData = new URLSearchParams();
|
|
62
|
+
Object.keys(options.form).forEach(key => {
|
|
63
|
+
formData.append(key, options.form[key]);
|
|
64
|
+
});
|
|
65
|
+
config.data = formData.toString();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Handle query parameters
|
|
70
|
+
if (options.qs) {
|
|
71
|
+
config.params = options.qs;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
try {
|
|
75
|
+
const response = await this.httpClient(config);
|
|
76
|
+
this.updateState(response);
|
|
77
|
+
|
|
78
|
+
if (response.data.status === 'ok' || response.status === 200) {
|
|
79
|
+
return { body: response.data, headers: response.headers };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
throw this.handleResponseError(response);
|
|
83
|
+
} catch (error) {
|
|
84
|
+
if (error.response) {
|
|
85
|
+
throw this.handleResponseError(error.response);
|
|
86
|
+
}
|
|
87
|
+
throw error;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
updateState(response) {
|
|
92
|
+
const headers = response.headers;
|
|
93
|
+
|
|
94
|
+
if (headers['x-ig-set-www-claim']) {
|
|
95
|
+
this.client.state.igWWWClaim = headers['x-ig-set-www-claim'];
|
|
96
|
+
}
|
|
97
|
+
if (headers['ig-set-authorization'] && !headers['ig-set-authorization'].endsWith(':')) {
|
|
98
|
+
this.client.state.authorization = headers['ig-set-authorization'];
|
|
99
|
+
}
|
|
100
|
+
if (headers['ig-set-password-encryption-key-id']) {
|
|
101
|
+
this.client.state.passwordEncryptionKeyId = headers['ig-set-password-encryption-key-id'];
|
|
102
|
+
}
|
|
103
|
+
if (headers['ig-set-password-encryption-pub-key']) {
|
|
104
|
+
this.client.state.passwordEncryptionPubKey = headers['ig-set-password-encryption-pub-key'];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Update cookies from Set-Cookie headers
|
|
108
|
+
const setCookieHeaders = headers['set-cookie'];
|
|
109
|
+
if (setCookieHeaders) {
|
|
110
|
+
setCookieHeaders.forEach(cookieString => {
|
|
111
|
+
try {
|
|
112
|
+
this.client.state.cookieStore.setCookieSync(cookieString, this.client.state.constants.HOST);
|
|
113
|
+
} catch (e) {
|
|
114
|
+
// Ignore cookie parsing errors
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
handleResponseError(response) {
|
|
121
|
+
const data = response.data || {};
|
|
122
|
+
|
|
123
|
+
if (data.spam) {
|
|
124
|
+
const error = new Error('Action blocked as spam');
|
|
125
|
+
error.name = 'IgActionSpamError';
|
|
126
|
+
error.response = response;
|
|
127
|
+
return error;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (response.status === 404) {
|
|
131
|
+
const error = new Error('Not found');
|
|
132
|
+
error.name = 'IgNotFoundError';
|
|
133
|
+
error.response = response;
|
|
134
|
+
return error;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (data.message === 'challenge_required') {
|
|
138
|
+
this.client.state.checkpoint = data;
|
|
139
|
+
const error = new Error('Challenge required');
|
|
140
|
+
error.name = 'IgCheckpointError';
|
|
141
|
+
error.response = response;
|
|
142
|
+
return error;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (data.message === 'user_has_logged_out') {
|
|
146
|
+
const error = new Error('User has logged out');
|
|
147
|
+
error.name = 'IgUserHasLoggedOutError';
|
|
148
|
+
error.response = response;
|
|
149
|
+
return error;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (data.message === 'login_required') {
|
|
153
|
+
const error = new Error('Login required');
|
|
154
|
+
error.name = 'IgLoginRequiredError';
|
|
155
|
+
error.response = response;
|
|
156
|
+
return error;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (data.error_type === 'sentry_block') {
|
|
160
|
+
const error = new Error('Sentry block');
|
|
161
|
+
error.name = 'IgSentryBlockError';
|
|
162
|
+
error.response = response;
|
|
163
|
+
return error;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (data.error_type === 'inactive user') {
|
|
167
|
+
const error = new Error('Inactive user');
|
|
168
|
+
error.name = 'IgInactiveUserError';
|
|
169
|
+
error.response = response;
|
|
170
|
+
return error;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const error = new Error(data.message || 'Request failed');
|
|
174
|
+
error.name = 'IgResponseError';
|
|
175
|
+
error.response = response;
|
|
176
|
+
error.status = response.status;
|
|
177
|
+
error.data = data;
|
|
178
|
+
return error;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
getDefaultHeaders() {
|
|
182
|
+
return {
|
|
183
|
+
'User-Agent': this.client.state.appUserAgent,
|
|
184
|
+
'X-Ads-Opt-Out': this.client.state.adsOptOut ? '1' : '0',
|
|
185
|
+
'X-IG-App-Locale': this.client.state.language,
|
|
186
|
+
'X-IG-Device-Locale': this.client.state.language,
|
|
187
|
+
'X-Pigeon-Session-Id': this.client.state.pigeonSessionId,
|
|
188
|
+
'X-Pigeon-Rawclienttime': (Date.now() / 1000).toFixed(3),
|
|
189
|
+
'X-IG-Connection-Speed': `${random(1000, 3700)}kbps`,
|
|
190
|
+
'X-IG-Bandwidth-Speed-KBPS': '-1.000',
|
|
191
|
+
'X-IG-Bandwidth-TotalBytes-B': '0',
|
|
192
|
+
'X-IG-Bandwidth-TotalTime-MS': '0',
|
|
193
|
+
'X-IG-Extended-CDN-Thumbnail-Cache-Busting-Value': this.client.state.thumbnailCacheBustingValue.toString(),
|
|
194
|
+
'X-Bloks-Version-Id': this.client.state.bloksVersionId,
|
|
195
|
+
'X-IG-WWW-Claim': this.client.state.igWWWClaim || '0',
|
|
196
|
+
'X-Bloks-Is-Layout-RTL': this.client.state.isLayoutRTL.toString(),
|
|
197
|
+
'X-IG-Connection-Type': this.client.state.connectionTypeHeader,
|
|
198
|
+
'X-IG-Capabilities': this.client.state.capabilitiesHeader,
|
|
199
|
+
'X-IG-App-ID': this.client.state.fbAnalyticsApplicationId,
|
|
200
|
+
'X-IG-Device-ID': this.client.state.uuid,
|
|
201
|
+
'X-IG-Android-ID': this.client.state.deviceId,
|
|
202
|
+
'Accept-Language': this.client.state.language.replace('_', '-'),
|
|
203
|
+
'X-FB-HTTP-Engine': 'Liger',
|
|
204
|
+
'Authorization': this.client.state.authorization,
|
|
205
|
+
'Host': 'i.instagram.com',
|
|
206
|
+
'Accept-Encoding': 'gzip, deflate',
|
|
207
|
+
'Connection': 'keep-alive',
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
module.exports = Request;
|