nodejs-insta-private-api-mqt 1.4.8 → 1.4.10

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.
@@ -128,7 +128,7 @@ class IgApiClient extends EventEmitter {
128
128
  */
129
129
  async simulateAndroidBehavior() {
130
130
  if (this.state.verbose)
131
- console.log('[Anti-Bot] Simulating Android-specific background behaviors...');
131
+ console.log('[Android] Simulating Android behavior...');
132
132
  // 0. Pre-login notification suppression / Trust signal
133
133
  try {
134
134
  await this.request.send({
@@ -209,7 +209,7 @@ class IgApiClient extends EventEmitter {
209
209
  // -------------------------------
210
210
  async preLoginFlow() {
211
211
  if (this.state.verbose)
212
- console.log('[Pre-Login] Starting pre-login flow (sync_launcher)...');
212
+ console.log('[Pre-Login] Starting pre-login flow...');
213
213
  try {
214
214
  await this.request.send({
215
215
  url: '/api/v1/launcher/sync/',
@@ -220,7 +220,7 @@ class IgApiClient extends EventEmitter {
220
220
  }),
221
221
  });
222
222
  if (this.state.verbose)
223
- console.log('[Pre-Login] Launcher Sync: OK');
223
+ console.log('[Pre-Login] Launcher Sync OK');
224
224
  }
225
225
  catch (e) {
226
226
  if (this.state.verbose)
@@ -247,7 +247,7 @@ class IgApiClient extends EventEmitter {
247
247
  }),
248
248
  });
249
249
  if (this.state.verbose)
250
- console.log('[Post-Login] Reels tray: OK');
250
+ console.log('[Post-Login] Reels tray OK');
251
251
  }
252
252
  catch (e) {
253
253
  if (this.state.verbose)
@@ -284,7 +284,7 @@ class IgApiClient extends EventEmitter {
284
284
  },
285
285
  });
286
286
  if (this.state.verbose)
287
- console.log('[Post-Login] Timeline feed: OK');
287
+ console.log('[Post-Login] Timeline feed OK');
288
288
  }
289
289
  catch (e) {
290
290
  if (this.state.verbose)
@@ -315,7 +315,6 @@ class IgApiClient extends EventEmitter {
315
315
  for (let attempt = 0; attempt <= retries; attempt++) {
316
316
  try {
317
317
  if (this.state.verbose) {
318
- console.log(`[Retry] attempt ${attempt + 1}/${retries + 1}`);
319
318
  }
320
319
  const res = await fn();
321
320
  return res;
@@ -361,7 +360,7 @@ class IgApiClient extends EventEmitter {
361
360
  const json = typeof data === 'string' ? data : JSON.stringify(data, null, 2);
362
361
  await fs.promises.writeFile(p, json, { mode: 0o600 });
363
362
  if (this.state.verbose)
364
- console.log('[Session] Saved session to', p);
363
+ console.log('[Session] Saved session to file:', p);
365
364
  return p;
366
365
  }
367
366
  /**
@@ -386,7 +385,7 @@ class IgApiClient extends EventEmitter {
386
385
  }
387
386
  await this.loadSession(sessionObj);
388
387
  if (this.state.verbose)
389
- console.log('[Session] Loaded session from', p);
388
+ console.log('[Session] Loaded session from file:', p);
390
389
  return true;
391
390
  }
392
391
  /**
@@ -953,7 +953,6 @@ class State {
953
953
  : this.cookieJar.getCookies(this.constants.HOST);
954
954
  if (Array.isArray(cookies)) {
955
955
  for (const c of cookies) {
956
- console.log(`- ${c.key}=${c.value}`);
957
956
  }
958
957
  return cookies;
959
958
  }
@@ -964,14 +963,6 @@ class State {
964
963
  }
965
964
  }
966
965
  logStateSummary() {
967
- console.log('--- State Summary ---');
968
- console.log(`Device ID: ${this.deviceId}`);
969
- console.log(`UUID: ${this.uuid}`);
970
- console.log(`User Agent: ${this.appUserAgent}`);
971
- console.log(`Language: ${this.language}`);
972
- console.log(`Timezone Offset: ${this.timezoneOffset}`);
973
- console.log(`Authorization: ${this.authorization ? 'Present' : 'Missing'}`);
974
- console.log('----------------------');
975
966
  }
976
967
  //
977
968
  // === NEW UTILITIES ADDED BELOW (non-destructive; keep backwards compat)
@@ -645,12 +645,8 @@ class Utils {
645
645
  };
646
646
  return (codes[color] || codes.reset) + text + codes.reset;
647
647
  }
648
- static logRed(...args) {
649
- console.log(this.colorize(args.map(String).join(' '), 'red'));
650
- }
651
- static logGreen(...args) {
652
- console.log(this.colorize(args.map(String).join(' '), 'green'));
653
- }
648
+ static logRed(...args) {}
649
+ static logGreen(...args) {}
654
650
  /* -------------------------
655
651
  System / environment helpers
656
652
  ------------------------- */
@@ -7,9 +7,9 @@ const Chance = require("chance");
7
7
  const thrift_1 = require("../../thrift");
8
8
 
9
9
  /**
10
- * SerialQueue — Coadă strict serială cu retry și exponential backoff.
11
- * Folosită per-thread pentru a serializa operațiile MQTT și a preveni
12
- * race conditions și mesaje pierdute la reconectare.
10
+ * SerialQueue — Strictly serial queue with retry and exponential backoff.
11
+ * Used per-thread to serialize MQTT operations and prevent
12
+ * race conditions and lost messages on reconnect.
13
13
  */
14
14
  class SerialQueue {
15
15
  constructor(name) {
@@ -70,9 +70,9 @@ class DirectCommands {
70
70
  ];
71
71
  this.client = client;
72
72
  this.chance = new Chance();
73
- // Coadă per-thread pentru operații MQTT
73
+ // Per-thread queue for MQTT operations
74
74
  this._threadQueues = new Map();
75
- // Coadă globală pentru operații non-thread (ex: foreground state)
75
+ // Global queue for non-thread operations (e.g. foreground state)
76
76
  this._globalQueue = new SerialQueue('direct:global');
77
77
  }
78
78
 
@@ -7,9 +7,9 @@ const constants_1 = require("../../constants");
7
7
  const thrift_1 = require("../../thrift");
8
8
 
9
9
  /**
10
- * SerialQueue — Coadă strict serială cu retry și exponential backoff.
11
- * Folosită per-thread pentru a serializa operațiile MQTT și a preveni
12
- * race conditions și mesaje pierdute la reconectare.
10
+ * SerialQueue — Strictly serial queue with retry and exponential backoff.
11
+ * Used per-thread to serialize MQTT operations and prevent
12
+ * race conditions and lost messages on reconnect.
13
13
  */
14
14
  class SerialQueue {
15
15
  constructor(name) {
@@ -81,9 +81,9 @@ class EnhancedDirectCommands {
81
81
  thrift_1.ThriftDescriptors.listOfBinary('unsubscribeGenericTopics', 7),
82
82
  thrift_1.ThriftDescriptors.int64('requestId', 8),
83
83
  ];
84
- // Coadă per-thread pentru operații MQTT
84
+ // Per-thread queue for MQTT operations
85
85
  this._threadQueues = new Map();
86
- // Coadă globală pentru operații non-thread (ex: foreground state)
86
+ // Global queue for non-thread operations (e.g. foreground state)
87
87
  this._globalQueue = new SerialQueue('enhanced:global');
88
88
  }
89
89
  /** Returnează (sau creează) coada pentru un threadId specific */
@@ -67,10 +67,6 @@ class PersistentLogger {
67
67
  return String(a);
68
68
  }).join(' ');
69
69
  const line = `[${timestamp}] [${level.toUpperCase()}] ${message}`;
70
- if (this.logToConsole) {
71
- const consoleFn = level === 'error' ? console.error : (level === 'warn' ? console.warn : console.log);
72
- consoleFn(line);
73
- }
74
70
  this._buffer.push(line);
75
71
  this._totalLines++;
76
72
  if (this._buffer.length >= 50) {
@@ -523,12 +523,10 @@ class MessageSyncMixin extends mixin_1.Mixin {
523
523
  }
524
524
  }
525
525
  catch (inner) {
526
- console.log(`[MESSAGE_SYNC] element handling error: ${inner?.message || inner}`);
527
526
  }
528
527
  }
529
528
  }
530
529
  catch (outer) {
531
- console.log(`[MESSAGE_SYNC] item error: ${outer?.message || outer}`);
532
530
  }
533
531
  }
534
532
  }
@@ -103,7 +103,7 @@ class RealtimeClient extends eventemitter3_1.EventEmitter {
103
103
  }
104
104
  if (!this._debug)
105
105
  return;
106
- const fn = console[level] || console.log;
106
+ const fn = () => {};
107
107
  try {
108
108
  fn(...args);
109
109
  }
@@ -72,9 +72,6 @@ class RealtimeService extends EventEmitter {
72
72
  // Broker URL
73
73
  const brokerUrl = `${this.protocol}://${this.broker}:${this.port}`;
74
74
  if (this.client.state.verbose) {
75
- console.log(`[Realtime] Connecting to MQTT broker: ${brokerUrl}`);
76
- console.log(`[Realtime] Client ID: ${this.clientId}`);
77
- console.log(`[Realtime] Username: ${this.username}`);
78
75
  }
79
76
  // Create MQTT connection
80
77
  this.mqttClient = mqtt.connect(brokerUrl, mqttOptions);
@@ -117,7 +114,6 @@ class RealtimeService extends EventEmitter {
117
114
  disconnect() {
118
115
  if (this.mqttClient && this.isConnected) {
119
116
  if (this.client.state.verbose) {
120
- console.log('[Realtime] Disconnecting from MQTT broker...');
121
117
  }
122
118
  this.mqttClient.end();
123
119
  this.isConnected = false;
@@ -137,7 +133,6 @@ class RealtimeService extends EventEmitter {
137
133
  ping() {
138
134
  if (this.isRealtimeConnected()) {
139
135
  if (this.client.state.verbose) {
140
- console.log('[Realtime] Sending ping...');
141
136
  }
142
137
  // MQTT client handles ping automatically through keepalive
143
138
  // But we can emit an event for debugging
@@ -176,7 +171,6 @@ class RealtimeService extends EventEmitter {
176
171
  this.isConnected = true;
177
172
  this.reconnectAttempts = 0;
178
173
  if (this.client.state.verbose) {
179
- console.log('[Realtime] Connected to MQTT broker');
180
174
  }
181
175
  // Subscribe to all topics
182
176
  this._subscribeToTopics();
@@ -191,7 +185,6 @@ class RealtimeService extends EventEmitter {
191
185
  try {
192
186
  const message = payload.toString();
193
187
  if (this.client.state.verbose) {
194
- console.log(`[Realtime] Received message on ${topic}: ${message}`);
195
188
  }
196
189
  // Find the topic configuration
197
190
  const topicConfig = this._findTopicByPath(topic);
@@ -294,7 +287,6 @@ class RealtimeService extends EventEmitter {
294
287
  _onClose() {
295
288
  this.isConnected = false;
296
289
  if (this.client.state.verbose) {
297
- console.log('[Realtime] MQTT connection closed');
298
290
  }
299
291
  this.emit('disconnected');
300
292
  // Try reconnection if not manually disconnected
@@ -309,7 +301,6 @@ class RealtimeService extends EventEmitter {
309
301
  _onOffline() {
310
302
  this.isConnected = false;
311
303
  if (this.client.state.verbose) {
312
- console.log('[Realtime] MQTT client offline');
313
304
  }
314
305
  this.emit('offline');
315
306
  }
@@ -319,7 +310,6 @@ class RealtimeService extends EventEmitter {
319
310
  */
320
311
  _onReconnect() {
321
312
  if (this.client.state.verbose) {
322
- console.log('[Realtime] MQTT client reconnecting...');
323
313
  }
324
314
  this.emit('reconnecting');
325
315
  }
@@ -340,7 +330,6 @@ class RealtimeService extends EventEmitter {
340
330
  }
341
331
  else {
342
332
  if (this.client.state.verbose) {
343
- console.log(`[Realtime] Subscribed to ${topic.path}`);
344
333
  }
345
334
  }
346
335
  });
@@ -357,7 +346,6 @@ class RealtimeService extends EventEmitter {
357
346
  this.reconnectAttempts++;
358
347
  const delay = this.reconnectDelay * Math.pow(2, this.reconnectAttempts - 1); // Exponential backoff
359
348
  if (this.client.state.verbose) {
360
- console.log(`[Realtime] Scheduling reconnect in ${delay}ms (attempt ${this.reconnectAttempts}/${this.maxReconnectAttempts})`);
361
349
  }
362
350
  setTimeout(() => {
363
351
  if (this.reconnectAttempts <= this.maxReconnectAttempts) {
@@ -12,8 +12,7 @@ class DirectThreadRepository extends Repository {
12
12
  */
13
13
  async requestWithRetry(requestFn, retries = 0) {
14
14
  try {
15
- if (process.env.DEBUG)
16
- console.log(`[DEBUG] Attempt #${retries + 1}`);
15
+ if (process.env.DEBUG) {}
17
16
  const result = await requestFn();
18
17
  return result;
19
18
  }
@@ -26,8 +25,7 @@ class DirectThreadRepository extends Repository {
26
25
  retries < this.maxRetries;
27
26
  if (shouldRetry) {
28
27
  const delay = 1000 * (retries + 1);
29
- if (process.env.DEBUG)
30
- console.log(`[DEBUG] Retrying after ${delay}ms due to ${error.data?.error_type || error.message || error.name || error.status}`);
28
+ if (process.env.DEBUG) {}
31
29
  await new Promise(resolve => setTimeout(resolve, delay));
32
30
  return this.requestWithRetry(requestFn, retries + 1);
33
31
  }
@@ -1514,7 +1514,6 @@ async function useMultiFileAuthState(folder) {
1514
1514
  authState._debouncedSave(['creds']);
1515
1515
  }
1516
1516
  catch (e) { }
1517
- console.log('[useMultiFileAuthState] Credentials saved to', folder);
1518
1517
  };
1519
1518
  const saveMqttSession = async (realtimeClient) => {
1520
1519
  if (!realtimeClient) {
@@ -1612,7 +1611,6 @@ async function useMultiFileAuthState(folder) {
1612
1611
  // Increment stats
1613
1612
  authState.incrementStat('mqttMessages');
1614
1613
  await authState.saveMqttState();
1615
- console.log('[useMultiFileAuthState] MQTT session saved to', folder);
1616
1614
  };
1617
1615
  const loadCreds = async (igClient) => {
1618
1616
  if (!igClient || !igClient.state) {
@@ -1620,11 +1618,9 @@ async function useMultiFileAuthState(folder) {
1620
1618
  return false;
1621
1619
  }
1622
1620
  if (!authState.hasValidSession()) {
1623
- console.log('[useMultiFileAuthState] No valid session found');
1624
1621
  return false;
1625
1622
  }
1626
1623
  await applyStateData(igClient.state, authState);
1627
- console.log('[useMultiFileAuthState] Credentials loaded from', folder);
1628
1624
  return true;
1629
1625
  };
1630
1626
  const getMqttConnectOptions = () => {
@@ -1655,7 +1651,6 @@ async function useMultiFileAuthState(folder) {
1655
1651
  };
1656
1652
  const clearSession = async () => {
1657
1653
  await authState.clearAll();
1658
- console.log('[useMultiFileAuthState] Session cleared');
1659
1654
  };
1660
1655
  const isSessionValid = async (igClient) => {
1661
1656
  if (!authState.hasValidSession())
@@ -211,7 +211,6 @@ class Utils {
211
211
  }
212
212
  static debugLog(message) {
213
213
  if (process.env.DEBUG === 'true') {
214
- console.log(`[DEBUG] ${new Date().toISOString()} - ${message}`);
215
214
  }
216
215
  }
217
216
  static generateAndroidDevice() {
@@ -9,15 +9,15 @@ const async_mutex_1 = require("async-mutex");
9
9
  const p_queue_1 = __importDefault(require("p-queue"));
10
10
  // Logger stub if not provided
11
11
  const defaultLogger = {
12
- trace: (obj, msg) => console.log('[TRACE]', msg, obj),
13
- debug: (obj, msg) => console.log('[DEBUG]', msg, obj),
14
- info: (obj, msg) => console.log('[INFO]', msg, obj),
12
+ trace: () => {},
13
+ debug: () => {},
14
+ info: () => {},
15
15
  warn: (obj, msg) => console.warn('[WARN]', msg, obj),
16
16
  error: (obj, msg) => console.error('[ERROR]', msg, obj),
17
17
  };
18
18
  /**
19
19
  * Adds transaction capability and sequential processing to the Instagram Realtime Client
20
- * ensuring messages are sent in order (e.g. "Salut" before "Ce faci").
20
+ * ensuring messages are sent in order (e.g. "Hello" before "How are you").
21
21
  *
22
22
  * @param client The RealtimeClient instance from nodejs-insta-private-api-mqt
23
23
  * @param logger Optional logger
@@ -26,7 +26,7 @@ const defaultLogger = {
26
26
  const addTransactionCapability = (client, logger = defaultLogger) => {
27
27
  const txStorage = new async_hooks_1.AsyncLocalStorage();
28
28
  // Global queue for all direct thread operations to ensure sequence
29
- // concurrency: 1 is CRITICAL for ensuring messages arrive in order "Salut" -> "Ce faci" -> "Unde esti"
29
+ // concurrency: 1 is CRITICAL for ensuring messages arrive in the correct sequential order
30
30
  const globalQueue = new p_queue_1.default({ concurrency: 1 });
31
31
  // Per-thread queues if we want parallelism across different threads but serial within a thread
32
32
  const threadQueues = new Map();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodejs-insta-private-api-mqt",
3
- "version": "1.4.8",
3
+ "version": "1.4.10",
4
4
  "description": "Complete Instagram MQTT protocol with full-featured REALTIME and REST API — all in one project.",
5
5
 
6
6
  "main": "dist/dist/index.js",