nodejs-insta-private-api-mqt 1.3.71 → 1.3.73

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
@@ -1,3 +1,10 @@
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/Kunboruto20/Rafael-script-Instagram-/main/file_000000004b007243b8d95187cb5bf425%20(1).png" width="100%" />
3
+ </p>
4
+
5
+
6
+
7
+
1
8
  Full featured Java and nodejs Instagram api private with Mqtt full suport and api rest
2
9
 
3
10
  Dear users The repository on github is currently unavailable will be available soon
@@ -1,5 +1,70 @@
1
1
  'use strict';
2
2
 
3
+ /**
4
+ * Console filter (quiet by default)
5
+ * --------------------------------
6
+ * Some helper functions inside the package may print noisy informational logs like:
7
+ * [useMultiFileAuthState] ...
8
+ * [MESSAGE_SYNC] ...
9
+ * This filter suppresses ONLY those known prefixes while leaving your own logs intact.
10
+ *
11
+ * To disable this filter:
12
+ * IG_SUPPRESS_INTERNAL_LOGS=0 node yourfile.js
13
+ */
14
+ (function installConsoleFilter() {
15
+ const flag = process.env.IG_SUPPRESS_INTERNAL_LOGS;
16
+ const enabled = (flag === undefined || flag === null || flag === '' || flag === '1' || flag.toLowerCase?.() === 'true');
17
+ if (!enabled) return;
18
+
19
+ const DROP_PREFIXES = [
20
+ '[useMultiFileAuthState]',
21
+ '[MESSAGE_SYNC]',
22
+ '[RealtimeClient]', // safety in case any remain
23
+ ];
24
+
25
+ // Also drop any line that contains these tokens anywhere (covers variants like "[MESSAGE_SYNC MIXIN]")
26
+ const DROP_TOKENS = [
27
+ 'MESSAGE_SYNC',
28
+ 'useMultiFileAuthState',
29
+ 'RealtimeClient',
30
+ ];
31
+
32
+ const shouldDrop = (args) => {
33
+ if (!args || !args.length) return false;
34
+
35
+ const first = (typeof args[0] === 'string') ? args[0] : '';
36
+
37
+ // Fast-path: known prefixes
38
+ if (first && DROP_PREFIXES.some((p) => first.startsWith(p) || first.includes(p))) {
39
+ return true;
40
+ }
41
+
42
+ // Robust-path: scan all string args for known tokens
43
+ const joined = args
44
+ .map((a) => (typeof a === 'string' ? a : ''))
45
+ .filter(Boolean)
46
+ .join(' ');
47
+
48
+ if (!joined) return false;
49
+
50
+ return DROP_TOKENS.some((t) => joined.includes(t));
51
+ };
52
+
53
+ const wrap = (methodName) => {
54
+ const original = console[methodName].bind(console);
55
+ console[methodName] = (...args) => {
56
+ if (shouldDrop(args)) return;
57
+ return original(...args);
58
+ };
59
+ };
60
+
61
+ wrap('log');
62
+ wrap('info');
63
+ wrap('warn');
64
+ wrap('error');
65
+ })();
66
+
67
+
3
68
  /*
4
69
  RealtimeClient
5
70
  --------------
@@ -69,6 +134,22 @@ class RealtimeClient extends eventemitter3_1.EventEmitter {
69
134
  */
70
135
  constructor(ig, mixins = [new mixins_1.MessageSyncMixin(), new mixins_1.RealtimeSubMixin(), new presence_typing_mixin_1.PresenceTypingMixin()]) {
71
136
  super();
137
+ // --- Logging (quiet by default, Baileys-like) ---
138
+ // Enable logs by setting IG_REALTIME_DEBUG=1 or IG_MQTT_DEBUG=1
139
+ this._debug = Boolean(process.env.IG_REALTIME_DEBUG || process.env.IG_MQTT_DEBUG);
140
+ // Optional external logger (pino-like): { debug/info/warn/error }
141
+ this._logger = (ig && ig.logger) ? ig.logger : null;
142
+ this._log = (level, ...args) => {
143
+ const logger = this._logger;
144
+ if (logger && typeof logger[level] === 'function') {
145
+ try { return logger[level](...args); } catch (_) {}
146
+ }
147
+ if (!this._debug) return;
148
+ const fn = console[level] || console.log;
149
+ try { fn(...args); } catch (_) {}
150
+ };
151
+ // ----------------------------------------------
152
+
72
153
  // debug helpers
73
154
  this.realtimeDebug = (0, shared_1.debugChannel)('realtime');
74
155
  this.messageDebug = this.realtimeDebug.extend('message');
@@ -222,40 +303,40 @@ class RealtimeClient extends eventemitter3_1.EventEmitter {
222
303
  setTimeout(async () => {
223
304
  try {
224
305
  if (this._mqttConnected || this._connectInProgress) {
225
- console.log('[REALTIME] Auto-start skipped — MQTT already connected or connect in progress.');
306
+ this._log('debug', '[REALTIME] Auto-start skipped — MQTT already connected or connect in progress.');
226
307
  return;
227
308
  }
228
309
  const auth = await useMultiFileAuthState(this._authFolder);
229
310
  this._attachedAuthState = auth;
230
311
  if (auth.hasSession && auth.hasSession()) {
231
312
  if (this._mqttConnected || this._connectInProgress) {
232
- console.log('[REALTIME] Auto-start skipped (after auth load) — MQTT already connected or connect in progress.');
313
+ this._log('debug', '[REALTIME] Auto-start skipped (after auth load) — MQTT already connected or connect in progress.');
233
314
  return;
234
315
  }
235
- console.log('[REALTIME] Auto-start candidate session detected — loading creds...');
316
+ this._log('debug', '[REALTIME] Auto-start candidate session detected — loading creds...');
236
317
  try {
237
318
  await auth.loadCreds(this.ig);
238
319
  } catch (e) {
239
- console.warn('[REALTIME] loadCreds warning:', e?.message || e);
320
+ this._log('warn', '[REALTIME] loadCreds warning:', e?.message || e);
240
321
  }
241
322
  const ready = await waitForMqttCredentials(auth, 20000, 300);
242
323
  if (!ready) {
243
- console.warn('[REALTIME] MQTT/device credentials not found within timeout — auto-connect aborted (will still allow manual connect).');
324
+ this._log('warn', '[REALTIME] MQTT/device credentials not found within timeout — auto-connect aborted (will still allow manual connect).');
244
325
  return;
245
326
  }
246
327
  if (this._mqttConnected || this._connectInProgress) {
247
- console.log('[REALTIME] Auto-start skipped (after wait) — MQTT already connected or connect in progress.');
328
+ this._log('debug', '[REALTIME] Auto-start skipped (after wait) — MQTT already connected or connect in progress.');
248
329
  return;
249
330
  }
250
- console.log('[REALTIME] Device/MQTT credentials present — attempting connectFromSavedSession...');
331
+ this._log('debug', '[REALTIME] Device/MQTT credentials present — attempting connectFromSavedSession...');
251
332
  try {
252
333
  await this.connectFromSavedSession(auth);
253
334
  } catch (e) {
254
- console.error('[REALTIME] Constructor auto-connect failed:', e?.message || e);
335
+ this._log('error', '[REALTIME] Constructor auto-connect failed:', e?.message || e);
255
336
  }
256
337
  }
257
338
  } catch (e) {
258
- console.error('[REALTIME] Constructor auto-start exception:', e?.message || e);
339
+ this._log('error', '[REALTIME] Constructor auto-start exception:', e?.message || e);
259
340
  }
260
341
  }, 100);
261
342
  }
@@ -303,10 +384,10 @@ class RealtimeClient extends eventemitter3_1.EventEmitter {
303
384
  async startRealTimeListener(options = {}) {
304
385
  this._connectInProgress = true;
305
386
  try {
306
- console.log('[REALTIME] Starting Real-Time Listener...');
307
- console.log('[REALTIME] Fetching inbox (IRIS data)...');
387
+ this._log('debug', '[REALTIME] Starting Real-Time Listener...');
388
+ this._log('debug', '[REALTIME] Fetching inbox (IRIS data)...');
308
389
  const inboxData = await this.ig.direct.getInbox();
309
- console.log('[REALTIME] Connecting to MQTT with IRIS subscription...');
390
+ this._log('debug', '[REALTIME] Connecting to MQTT with IRIS subscription...');
310
391
  await this.connect({
311
392
  graphQlSubs: [
312
393
  'ig_sub_direct',
@@ -318,11 +399,11 @@ class RealtimeClient extends eventemitter3_1.EventEmitter {
318
399
  ],
319
400
  irisData: inboxData
320
401
  });
321
- console.log('[REALTIME] MQTT Connected with IRIS');
322
- console.log('----------------------------------------');
323
- console.log('[REALTIME] Real-Time Listener ACTIVE');
324
- console.log('[REALTIME] Waiting for messages...');
325
- console.log('----------------------------------------');
402
+ this._log('debug', '[REALTIME] MQTT Connected with IRIS');
403
+ this._log('debug', '----------------------------------------');
404
+ this._log('debug', '[REALTIME] Real-Time Listener ACTIVE');
405
+ this._log('debug', '[REALTIME] Waiting for messages...');
406
+ this._log('debug', '----------------------------------------');
326
407
  this._setupMessageHandlers();
327
408
 
328
409
  if (options.enableHealthMonitor !== false) {
@@ -334,7 +415,7 @@ class RealtimeClient extends eventemitter3_1.EventEmitter {
334
415
 
335
416
  return { success: true };
336
417
  } catch (error) {
337
- console.error('[REALTIME] Failed:', error.message);
418
+ this._log('error', '[REALTIME] Failed:', error.message);
338
419
  throw error;
339
420
  }
340
421
  }
@@ -1077,14 +1158,14 @@ class RealtimeClient extends eventemitter3_1.EventEmitter {
1077
1158
  await this.irisSubscribe(this.initOptions.irisData);
1078
1159
  } else {
1079
1160
  try {
1080
- console.log('[REALTIME] Auto-fetching IRIS data...');
1161
+ this._log('debug', '[REALTIME] Auto-fetching IRIS data...');
1081
1162
  const autoIrisData = await this.ig.direct.getInbox();
1082
1163
  if (autoIrisData) {
1083
1164
  await this.irisSubscribe(autoIrisData);
1084
- console.log('[REALTIME] IRIS subscription successful');
1165
+ this._log('debug', '[REALTIME] IRIS subscription successful');
1085
1166
  }
1086
1167
  } catch (e) {
1087
- console.log('[REALTIME] Could not auto-fetch IRIS data:', e.message);
1168
+ this._log('debug', '[REALTIME] Could not auto-fetch IRIS data:', e.message);
1088
1169
  }
1089
1170
  }
1090
1171
  if ((this.initOptions.skywalkerSubs ?? []).length > 0) {
@@ -1637,16 +1718,16 @@ class RealtimeClient extends eventemitter3_1.EventEmitter {
1637
1718
  }
1638
1719
 
1639
1720
  if (this._mqttConnected) {
1640
- console.log('[RealtimeClient] connectFromSavedSession skipped — already connected.');
1721
+ this._log('debug', 'connectFromSavedSession skipped — already connected.');
1641
1722
  return this;
1642
1723
  }
1643
1724
  if (this._connectInProgress) {
1644
- console.log('[RealtimeClient] connectFromSavedSession skipped — connect already in progress.');
1725
+ this._log('debug', 'connectFromSavedSession skipped — connect already in progress.');
1645
1726
  return this;
1646
1727
  }
1647
1728
 
1648
1729
  this._connectInProgress = true;
1649
- console.log('[RealtimeClient] Connecting from saved session...');
1730
+ this._log('debug', 'Connecting from saved session...');
1650
1731
  try { this._attachedAuthState = authStateHelper; } catch (e) {}
1651
1732
 
1652
1733
  const savedOptions = authStateHelper.getMqttConnectOptions?.() || {};
@@ -1658,19 +1739,19 @@ class RealtimeClient extends eventemitter3_1.EventEmitter {
1658
1739
  const maxAttempts = 3;
1659
1740
  for (let attempt = 1; attempt <= maxAttempts; attempt++) {
1660
1741
  try {
1661
- console.log(`[RealtimeClient] Attempting to fetch fresh IRIS inbox snapshot (attempt ${attempt}/${maxAttempts})...`);
1742
+ this._log('debug', `Attempting to fetch fresh IRIS inbox snapshot (attempt ${attempt}/${maxAttempts})...`);
1662
1743
  fetchedInbox = await this.ig.direct.getInbox();
1663
1744
  if (fetchedInbox) {
1664
1745
  irisData = fetchedInbox;
1665
- console.log('[RealtimeClient] Fetched IRIS snapshot successfully.');
1746
+ this._log('debug', 'Fetched IRIS snapshot successfully.');
1666
1747
  break;
1667
1748
  }
1668
1749
  } catch (e) {
1669
1750
  const msg = (e?.message || String(e)).toLowerCase();
1670
1751
  const isAuthIssue = msg.includes('login_required') || msg.includes('401') || msg.includes('403') || msg.includes('not authorized') || msg.includes('checkpoint');
1671
- console.warn(`[RealtimeClient] Failed to fetch IRIS snapshot (attempt ${attempt}):`, e?.message || e);
1752
+ this._log('warn', `Failed to fetch IRIS snapshot (attempt ${attempt}):`, e?.message || e);
1672
1753
  if (isAuthIssue) {
1673
- console.warn('[RealtimeClient] IRIS fetch failed due to auth issue — session may be expired.');
1754
+ this._log('warn', 'IRIS fetch failed due to auth issue — session may be expired.');
1674
1755
  this.emit('warning', { type: 'auth_issue', message: 'Session may be expired - IRIS fetch returned auth error', error: e?.message });
1675
1756
  break;
1676
1757
  }
@@ -1680,9 +1761,9 @@ class RealtimeClient extends eventemitter3_1.EventEmitter {
1680
1761
  if (!fetchedInbox) {
1681
1762
  if (savedOptions.irisData) {
1682
1763
  irisData = savedOptions.irisData;
1683
- console.warn('[RealtimeClient] Could not fetch fresh IRIS snapshot — falling back to saved irisData (may be stale).');
1764
+ this._log('warn', 'Could not fetch fresh IRIS snapshot — falling back to saved irisData (may be stale).');
1684
1765
  } else if (!irisData) {
1685
- console.warn('[RealtimeClient] No IRIS snapshot available (neither fetched nor saved). Proceeding without irisData — server may not replay missed events.');
1766
+ this._log('warn', 'No IRIS snapshot available (neither fetched nor saved). Proceeding without irisData — server may not replay missed events.');
1686
1767
  }
1687
1768
  }
1688
1769
  }
@@ -1694,7 +1775,7 @@ class RealtimeClient extends eventemitter3_1.EventEmitter {
1694
1775
  ...options
1695
1776
  };
1696
1777
 
1697
- console.log('[RealtimeClient] Using saved subscriptions:', {
1778
+ this._log('debug', 'Using saved subscriptions:', {
1698
1779
  graphQlSubs: connectOptions.graphQlSubs,
1699
1780
  skywalkerSubs: connectOptions.skywalkerSubs,
1700
1781
  hasIrisData: !!connectOptions.irisData
@@ -1706,7 +1787,7 @@ class RealtimeClient extends eventemitter3_1.EventEmitter {
1706
1787
  if (mqttAuth && mqttAuth.expiresAt) {
1707
1788
  const t = new Date(mqttAuth.expiresAt).getTime();
1708
1789
  if (!isNaN(t) && Date.now() > t) {
1709
- console.warn('[RealtimeClient] Warning: saved mqttAuth token appears expired.');
1790
+ this._log('warn', 'Warning: saved mqttAuth token appears expired.');
1710
1791
  }
1711
1792
  }
1712
1793
  } catch (e) {}
@@ -1716,9 +1797,9 @@ class RealtimeClient extends eventemitter3_1.EventEmitter {
1716
1797
  if (authStateHelper.saveMqttSession) {
1717
1798
  try {
1718
1799
  await authStateHelper.saveMqttSession(this);
1719
- console.log('[RealtimeClient] MQTT session saved after connect');
1800
+ this._log('debug', 'MQTT session saved after connect');
1720
1801
  } catch (e) {
1721
- console.warn('[RealtimeClient] Failed to save MQTT session:', e.message);
1802
+ this._log('warn', 'Failed to save MQTT session:', e.message);
1722
1803
  }
1723
1804
  }
1724
1805
 
@@ -1731,7 +1812,7 @@ class RealtimeClient extends eventemitter3_1.EventEmitter {
1731
1812
  */
1732
1813
  async saveSession(authStateHelper) {
1733
1814
  if (!authStateHelper || !authStateHelper.saveMqttSession) {
1734
- console.warn('[RealtimeClient] No authStateHelper provided');
1815
+ this._log('warn', 'No authStateHelper provided');
1735
1816
  return false;
1736
1817
  }
1737
1818
  await authStateHelper.saveMqttSession(this);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodejs-insta-private-api-mqt",
3
- "version": "1.3.71",
3
+ "version": "1.3.73",
4
4
  "description": "Complete Instagram MQTT protocol with FULL Featured REALTIME And api Rest All in one project .",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {