nodejs-insta-private-api-mqtt 1.1.6 → 1.1.7

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 CHANGED
@@ -2,24 +2,15 @@ Dear users,
2
2
  First of all, when handling view-once images or videos, please make sure to save the received media in a folder such as /storage/emulated/0/Pictures/, or depending on your device's path. The photos and videos are saved correctly on your phone, but the library currently has some issues with uploading them back to Instagram. This will be resolved as soon as possible.
3
3
  I post many versions of the project because Instagram changes the protocol almost daily, if you like this project leave a star on github https://github.com/Kunboruto20/nodejs-insta-private-api.git
4
4
 
5
- ⚠️ IMPORTANT NOTICE
6
- This is an important announcement regarding the nodejs-insta-private-api library.
7
- The old repository and NPM package were lost and are now associated with a different NPM account.
8
- Starting from today, this NPM account will be the official and active source where this library will be published and maintained.
9
- Please make sure you are using this package from this account only to receive future updates, fixes, and support.
10
5
 
11
- You can subscribe to any Instagram topic in this library visit the bookstore code, it would help me a lot if you like this project and if it helps you!
12
6
 
13
- If you see clones of nodejs-insta-private-api on npm don't download, it could be malicious code and you may have security issues on your Instagram accounts, always use this project or the nodejs-insta-private-api project but that's on the lost account, always use npm install nodejs-insta-private-api-mqtt in your projects
14
-
15
-
16
- # nodejs-insta-private-api-mqtt
7
+ # nodejs-insta-private-api
17
8
 
18
9
  This project implements a complete and production-ready MQTT protocol client for Instagram's real-time messaging infrastructure. Instagram uses MQTT natively for direct messages, notifications, and real-time presence updates. This library replicates that exact implementation, allowing developers to build high-performance bots and automation tools that communicate with Instagram's backend using the same protocol the official app uses.
19
10
 
20
11
  By leveraging MQTT instead of Instagram's REST API, this library achieves sub-500ms message latency, bidirectional real-time communication, and native support for notifications, presence tracking, and thread management. The implementation is reverse-engineered from Instagram's mobile app protocol and tested extensively for reliability and compatibility.
21
12
 
22
- ## Features ( - iOS + Android Full Support)
13
+ ## Features (v5.61.11 - iOS + Android Full Support)
23
14
 
24
15
  - **NEW: FULL iOS SUPPORT** - iPhone 16/15/14/13/12 + iPad Pro/Air device emulation
25
16
  - **NEW: FULL ANDROID SUPPORT** - Samsung, Huawei, Google Pixel, OnePlus, Xiaomi, OPPO
@@ -75,7 +66,7 @@ Requires **Node.js 18 or higher**.
75
66
 
76
67
  ---
77
68
 
78
- ## NEW: Custom Device Emulation ()
69
+ ## NEW: Custom Device Emulation (v5.60.7)
79
70
 
80
71
  **Default Device:** Samsung Galaxy S25 Ultra (Android 15) - used automatically if you don't set a custom device.
81
72
 
@@ -93,7 +84,7 @@ This feature allows you to **choose which phone model Instagram sees** when your
93
84
  The easiest way to set a custom device is using the built-in presets:
94
85
 
95
86
  ```javascript
96
- const { IgApiClient } = require('nodejs-insta-private-api-mqtt');
87
+ const { IgApiClient } = require('nodejs-insta-private-api');
97
88
 
98
89
  const ig = new IgApiClient();
99
90
 
@@ -911,7 +902,7 @@ const {
911
902
  RealtimeClient,
912
903
  downloadContentFromMessage,
913
904
  isViewOnceMedia
914
- } = require('nodejs-insta-private-api-mqtt');
905
+ } = require('nodejs-insta-private-api');
915
906
  const fs = require('fs');
916
907
 
917
908
  const ig = new IgApiClient();
@@ -964,7 +955,7 @@ const {
964
955
  downloadMediaBuffer,
965
956
  hasMedia,
966
957
  getMediaType
967
- } = require('nodejs-insta-private-api');
958
+ } = require('nodejs-insta-private-api-mqtt');
968
959
 
969
960
  realtime.on('message', async (data) => {
970
961
  const msg = data.message;
@@ -13,11 +13,7 @@ class Request {
13
13
  baseURL: 'https://i.instagram.com/',
14
14
  timeout: 30000,
15
15
  headers: {
16
- 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
17
- 'Accept-Encoding': 'gzip, deflate',
18
- 'Connection': 'keep-alive',
19
- 'Accept': '*/*',
20
- 'Accept-Language': 'en-US'
16
+ 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
21
17
  }
22
18
  });
23
19
  }
@@ -179,32 +175,31 @@ class Request {
179
175
  error.response = response;
180
176
  error.status = response.status;
181
177
  error.data = data;
182
- // Anti-bot: Randomize delay on error to mimic human reaction time
183
178
  return error;
184
179
  }
185
180
 
186
181
  getDefaultHeaders() {
187
182
  return {
188
183
  'User-Agent': this.client.state.appUserAgent,
189
- 'X-Ads-Opt-Out': '0', // Always 0 for humans
190
- 'X-IG-App-Locale': 'en_US',
191
- 'X-IG-Device-Locale': 'en_US',
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,
192
187
  'X-Pigeon-Session-Id': this.client.state.pigeonSessionId,
193
188
  'X-Pigeon-Rawclienttime': (Date.now() / 1000).toFixed(3),
194
- 'X-IG-Connection-Speed': `${random(2000, 4000)}kbps`, // Faster 5G/WiFi speeds
189
+ 'X-IG-Connection-Speed': `${random(1000, 3700)}kbps`,
195
190
  'X-IG-Bandwidth-Speed-KBPS': '-1.000',
196
191
  'X-IG-Bandwidth-TotalBytes-B': '0',
197
192
  'X-IG-Bandwidth-TotalTime-MS': '0',
198
193
  'X-IG-Extended-CDN-Thumbnail-Cache-Busting-Value': this.client.state.thumbnailCacheBustingValue.toString(),
199
194
  'X-Bloks-Version-Id': this.client.state.bloksVersionId,
200
195
  'X-IG-WWW-Claim': this.client.state.igWWWClaim || '0',
201
- 'X-Bloks-Is-Layout-RTL': 'false',
202
- 'X-IG-Connection-Type': 'WIFI', // Prefer WIFI for stability
203
- 'X-IG-Capabilities': '3brTv10=', // iOS capabilities
204
- 'X-IG-App-ID': '1217981644879628', // Official iOS App ID
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,
205
200
  'X-IG-Device-ID': this.client.state.uuid,
206
201
  'X-IG-Android-ID': this.client.state.deviceId,
207
- 'Accept-Language': 'en-US',
202
+ 'Accept-Language': this.client.state.language.replace('_', '-'),
208
203
  'X-FB-HTTP-Engine': 'Liger',
209
204
  'Authorization': this.client.state.authorization,
210
205
  'Host': 'i.instagram.com',
@@ -34,12 +34,12 @@ class State {
34
34
  this.parsedAuthorization = undefined;
35
35
 
36
36
  // ===== PLATFORM SUPPORT (iOS + Android) =====
37
- this.platform = 'ios'; // 'android' or 'ios'
37
+ this.platform = 'android'; // 'android' or 'ios'
38
38
  this.iosVersion = '18.1';
39
39
  this.iosAppVersion = '347.0.0.36.89';
40
40
  this.iosAppVersionCode = '618023787';
41
- this.iosDeviceModel = 'iPhone17,1'; // iPhone 16 Pro Max
42
- this.iosDeviceName = 'iPhone 16 Pro Max';
41
+ this.iosDeviceModel = 'iPhone16,2'; // iPhone 15 Pro Max
42
+ this.iosDeviceName = 'iPhone';
43
43
  this.iosBundleId = 'com.burbn.instagram';
44
44
 
45
45
  // cookie jar (tough-cookie)
@@ -101,8 +101,7 @@ class State {
101
101
  }
102
102
 
103
103
  get iosUserAgent() {
104
- // iPhone 16 Pro Max Hardcoded User Agent for Maximum Stealth
105
- return `Instagram 347.0.0.36.89 (iPhone17,1; iOS 18.1; en_US; en_US; scale=3.00; 1320x2868; 618023787) AppleWebKit/420+`;
104
+ return `Instagram ${this.iosAppVersion} (${this.iosDeviceModel}; iOS ${this.iosVersion}; ${this.language}; ${this.language}; scale=3.00; ${this.iosResolution}; ${this.iosAppVersionCode}) AppleWebKit/420+`;
106
105
  }
107
106
 
108
107
  get iosResolution() {
@@ -23,36 +23,12 @@ class MQTToTClient extends mqtts_1.MqttClient {
23
23
  host: options.url,
24
24
  port: 443,
25
25
  proxyOptions: options.socksOptions,
26
- additionalOptions: {
27
- ...options.additionalOptions,
28
- // Anti-Bot: Enforce TLS 1.3 with Unified Cipher Suites (iOS & Android 14/15)
29
- minVersion: 'TLSv1.3',
30
- maxVersion: 'TLSv1.3',
31
- ciphers: [
32
- 'TLS_AES_128_GCM_SHA256',
33
- 'TLS_AES_256_GCM_SHA384',
34
- 'TLS_CHACHA20_POLY1305_SHA256'
35
- ].join(':'),
36
- sigalgs: 'ecdsa_secp256r1_sha256:rsa_pss_rsae_sha256:rsa_pkcs1_sha256:ecdsa_secp384r1_sha384:rsa_pss_rsae_sha384:rsa_pkcs1_sha384:rsa_pss_rsae_sha512:rsa_pkcs1_sha512',
37
- rejectUnauthorized: true,
38
- },
26
+ additionalOptions: options.additionalOptions,
39
27
  })
40
28
  : new mqtts_1.TlsTransport({
41
29
  host: options.url,
42
30
  port: 443,
43
- additionalOptions: {
44
- ...options.additionalOptions,
45
- // Anti-Bot: Enforce TLS 1.3 with Unified Cipher Suites (iOS & Android 14/15)
46
- minVersion: 'TLSv1.3',
47
- maxVersion: 'TLSv1.3',
48
- ciphers: [
49
- 'TLS_AES_128_GCM_SHA256',
50
- 'TLS_AES_256_GCM_SHA384',
51
- 'TLS_CHACHA20_POLY1305_SHA256'
52
- ].join(':'),
53
- sigalgs: 'ecdsa_secp256r1_sha256:rsa_pss_rsae_sha256:rsa_pkcs1_sha256:ecdsa_secp384r1_sha384:rsa_pss_rsae_sha384:rsa_pkcs1_sha384:rsa_pss_rsae_sha512:rsa_pkcs1_sha512',
54
- rejectUnauthorized: true,
55
- },
31
+ additionalOptions: options.additionalOptions,
56
32
  }),
57
33
  });
58
34
  this.mqttotDebug = (msg, ...args) => (0, shared_1.debugChannel)('mqttot')(`${options.url}: ${msg}`, ...args);
@@ -89,17 +65,12 @@ class MQTToTClient extends mqtts_1.MqttClient {
89
65
  * @param {MqttMessage} message
90
66
  * @returns {Promise<MqttMessageOutgoing>}
91
67
  */
92
- mqttotPublish(message) {
68
+ async mqttotPublish(message) {
93
69
  this.mqttotDebug(`Publishing ${message.payload.byteLength}bytes to topic ${message.topic}`);
94
- // Anti-bot: Jitter publishing timestamp slightly to mimic organic network latency
95
- return new Promise(resolve => {
96
- setTimeout(async () => {
97
- resolve(await this.publish({
98
- topic: message.topic,
99
- payload: await (0, shared_1.compressDeflate)(message.payload),
100
- qosLevel: message.qosLevel,
101
- }));
102
- }, Math.random() * 50 + 10); // 10-60ms random jitter
70
+ return await this.publish({
71
+ topic: message.topic,
72
+ payload: await (0, shared_1.compressDeflate)(message.payload),
73
+ qosLevel: message.qosLevel,
103
74
  });
104
75
  }
105
76
  /**
@@ -129,7 +100,7 @@ function mqttotConnectFlow(payload, requirePayload) {
129
100
  type: mqtts_1.PacketType.Connect,
130
101
  options: {
131
102
  payload,
132
- keepAlive: 900, // Increased to 15 minutes (900s) to match mobile app behavior for battery saving
103
+ keepAlive: 60,
133
104
  },
134
105
  }),
135
106
  accept: mqtts_1.isConnAck,
@@ -47,14 +47,10 @@ MQTToTConnection.thriftConfig = [
47
47
  thrift_1.ThriftDescriptors.int64('anotherUnknown', 26),
48
48
  ]),
49
49
  thrift_1.ThriftDescriptors.binary('password', 5),
50
- // polyfill - Anti-Bot Hardening (Order matters for mobile mimicry)
50
+ // polyfill
51
51
  thrift_1.ThriftDescriptors.int16('unknown', 5),
52
52
  thrift_1.ThriftDescriptors.listOfBinary('getDiffsRequests', 6),
53
53
  thrift_1.ThriftDescriptors.binary('zeroRatingTokenHash', 9),
54
54
  thrift_1.ThriftDescriptors.mapBinaryBinary('appSpecificInfo', 10),
55
- // Field 11 is "chat_on" state for presence - often missing in bots
56
- thrift_1.ThriftDescriptors.boolean('chatOn', 11),
57
- // Field 12 is "fg_keepalive" - foreground keepalive flag
58
- thrift_1.ThriftDescriptors.boolean('fgKeepAlive', 12),
59
55
  ];
60
56
  //# sourceMappingURL=mqttot.connection.js.map
@@ -230,37 +230,31 @@ class RealtimeClient extends eventemitter3_1.EventEmitter {
230
230
  this.realtimeDebug(`SessionID generated (fallback): ${sessionid}`);
231
231
  }
232
232
  const password = `sessionid=${sessionid}`;
233
-
234
- // MQTT Client Info - Unified Mobile Profile (iOS & Android)
235
233
  this.connection = new mqttot_1.MQTToTConnection({
236
234
  clientIdentifier: deviceId.substring(0, 20),
237
235
  clientInfo: {
238
236
  userId: BigInt(Number(this.ig.state.cookieUserId)),
239
237
  userAgent,
240
- clientCapabilities: this.ig.state.platform === 'ios' ? 195 : 183, // Platform-specific capabilities
238
+ clientCapabilities: 183,
241
239
  endpointCapabilities: 0,
242
240
  publishFormat: 1,
243
241
  noAutomaticForeground: false,
244
242
  makeUserAvailableInForeground: true,
245
243
  deviceId,
246
244
  isInitiallyForeground: true,
247
- networkType: 1, // WIFI
245
+ networkType: 1,
248
246
  networkSubtype: 0,
249
247
  clientMqttSessionId: BigInt(Date.now()) & BigInt(0xffffffff),
250
- subscribeTopics: this.ig.state.platform === 'ios'
251
- ? [88, 135, 149, 150, 133, 146, 230, 231]
252
- : [88, 135, 149, 150, 133, 146], // Android usually has fewer default subscriptions
248
+ subscribeTopics: [88, 135, 149, 150, 133, 146],
253
249
  clientType: 'cookie_auth',
254
- appId: this.ig.state.platform === 'ios'
255
- ? BigInt(1217981644879628)
256
- : BigInt(1217981644879628), // Same for both on mobile
250
+ appId: BigInt(567067343352427),
257
251
  deviceSecret: '',
258
252
  clientStack: 3,
259
253
  ...(this.initOptions?.connectOverrides || {}),
260
254
  },
261
255
  password,
262
256
  appSpecificInfo: {
263
- app_version: this.ig.state.platform === 'ios' ? '347.0.0.36.89' : this.ig.state.appVersion,
257
+ app_version: this.ig.state.appVersion,
264
258
  'X-IG-Capabilities': this.ig.state.capabilitiesHeader,
265
259
  everclear_subscriptions: JSON.stringify({
266
260
  inapp_notification_subscribe_comment: '17899377895239777',
@@ -269,7 +263,7 @@ class RealtimeClient extends eventemitter3_1.EventEmitter {
269
263
  presence_subscribe: '17846944882223835',
270
264
  }),
271
265
  'User-Agent': userAgent,
272
- 'Accept-Language': this.ig.state.language,
266
+ 'Accept-Language': this.ig.state.language.replace('_', '-'),
273
267
  },
274
268
  });
275
269
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodejs-insta-private-api-mqtt",
3
- "version": "1.1.6",
3
+ "version": "1.1.7",
4
4
  "description": "Complete Instagram MQTT protocol with FULL iOS + Android support. 33 device presets (21 iOS + 12 Android). iPhone 16/15/14/13/12, iPad Pro, Samsung, Pixel, Huawei. Real-time DM messaging, view-once media extraction, sub-500ms latency.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {