nodejs-insta-private-api-mqt 1.3.70 → 1.3.72
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/mqttot/mqttot.client.js +54 -3
- package/dist/realtime/realtime.client.js +120 -39
- package/package.json +1 -1
|
@@ -65,15 +65,23 @@ class MQTToTClient extends mqtts_1.MqttClient {
|
|
|
65
65
|
this.registerListeners();
|
|
66
66
|
this.requirePayload = options.requirePayload;
|
|
67
67
|
|
|
68
|
-
this._keepaliveMs = (typeof options.keepaliveMs === 'number') ? options.keepaliveMs : (
|
|
68
|
+
this._keepaliveMs = (typeof options.keepaliveMs === 'number') ? options.keepaliveMs : (30 * 1000); // default ~30s (mobile-like) to stay well within CONNECT keepAlive=60
|
|
69
69
|
this._consecutivePingFailures = 0;
|
|
70
|
+
|
|
71
|
+
// Stall detection (mobile-like): if we don't receive any traffic for too long,
|
|
72
|
+
// force a reconnect. This helps recover from half-open sockets.
|
|
73
|
+
this._lastRxTs = Date.now();
|
|
74
|
+
this._stallMs = (typeof options.stallMs === 'number') ? options.stallMs : (180 * 1000); // 3 min default
|
|
75
|
+
this._stallCheckMs = (typeof options.stallCheckMs === 'number') ? options.stallCheckMs : (30 * 1000); // check every 30s
|
|
76
|
+
this._startStallWatchdog();
|
|
77
|
+
|
|
70
78
|
this._startKeepalive();
|
|
71
79
|
}
|
|
72
80
|
|
|
73
81
|
_startKeepalive() {
|
|
74
82
|
try {
|
|
75
83
|
if (this._keepaliveTimer) clearInterval(this._keepaliveTimer);
|
|
76
|
-
const jitter = Math.floor(Math.random() *
|
|
84
|
+
const jitter = Math.floor(Math.random() * 3000);
|
|
77
85
|
this._keepaliveTimer = setInterval(() => {
|
|
78
86
|
try {
|
|
79
87
|
if (typeof this.ping === 'function') {
|
|
@@ -104,7 +112,41 @@ class MQTToTClient extends mqtts_1.MqttClient {
|
|
|
104
112
|
}
|
|
105
113
|
}
|
|
106
114
|
|
|
107
|
-
|
|
115
|
+
|
|
116
|
+
_startStallWatchdog() {
|
|
117
|
+
try {
|
|
118
|
+
if (this._stallTimer) clearInterval(this._stallTimer);
|
|
119
|
+
this._stallTimer = setInterval(() => {
|
|
120
|
+
try {
|
|
121
|
+
// only check if we appear connected
|
|
122
|
+
const now = Date.now();
|
|
123
|
+
const last = this._lastRxTs || 0;
|
|
124
|
+
if (last && (now - last) > this._stallMs) {
|
|
125
|
+
this.mqttotDebug(`Stall detected: no inbound traffic for ${Math.round((now - last) / 1000)}s (threshold ${Math.round(this._stallMs/1000)}s). Forcing reconnect.`);
|
|
126
|
+
this._lastRxTs = now;
|
|
127
|
+
this.emit('disconnect', 'stall_timeout');
|
|
128
|
+
}
|
|
129
|
+
} catch (e) {
|
|
130
|
+
this.mqttotDebug(`Stall watchdog error: ${e?.message || e}`);
|
|
131
|
+
}
|
|
132
|
+
}, this._stallCheckMs);
|
|
133
|
+
} catch (e) {
|
|
134
|
+
this.mqttotDebug(`Stall watchdog setup error: ${e?.message || e}`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
_stopStallWatchdog() {
|
|
139
|
+
try {
|
|
140
|
+
if (this._stallTimer) {
|
|
141
|
+
clearInterval(this._stallTimer);
|
|
142
|
+
this._stallTimer = null;
|
|
143
|
+
}
|
|
144
|
+
} catch (e) {
|
|
145
|
+
// ignore
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
108
150
|
* Stop keepalive timer (call on explicit close/disconnect)
|
|
109
151
|
*/
|
|
110
152
|
_stopKeepalive() {
|
|
@@ -137,9 +179,14 @@ class MQTToTClient extends mqtts_1.MqttClient {
|
|
|
137
179
|
// Attach diagnostics
|
|
138
180
|
this.on('error', printErrorOrWarning('Error'));
|
|
139
181
|
this.on('warning', printErrorOrWarning('Warning'));
|
|
182
|
+
this.on('connect', () => { try { this._lastRxTs = Date.now(); } catch (e) {} });
|
|
183
|
+
|
|
184
|
+
// Update last-receive timestamp for stall detection
|
|
185
|
+
this.on('message', () => { try { this._lastRxTs = Date.now(); } catch (e) {} });
|
|
140
186
|
|
|
141
187
|
// Listen to ping responses if the library emits them
|
|
142
188
|
this.on('pingresp', () => {
|
|
189
|
+
try { this._lastRxTs = Date.now(); } catch (e) {}
|
|
143
190
|
this.mqttotDebug('Received PINGRESP (keepalive ok)');
|
|
144
191
|
});
|
|
145
192
|
|
|
@@ -147,6 +194,7 @@ class MQTToTClient extends mqtts_1.MqttClient {
|
|
|
147
194
|
try {
|
|
148
195
|
this.mqttotDebug(`Disconnected. Reason: ${reason}`);
|
|
149
196
|
this._stopKeepalive();
|
|
197
|
+
this._stopStallWatchdog();
|
|
150
198
|
|
|
151
199
|
if (this._options && this._options.autoReconnect === false) {
|
|
152
200
|
this.mqttotDebug('autoReconnect disabled; will not attempt reconnect.');
|
|
@@ -164,6 +212,8 @@ class MQTToTClient extends mqtts_1.MqttClient {
|
|
|
164
212
|
await this.connect(this._options);
|
|
165
213
|
this.mqttotDebug('Reconnected successfully');
|
|
166
214
|
this._consecutivePingFailures = 0;
|
|
215
|
+
this._lastRxTs = Date.now();
|
|
216
|
+
this._startStallWatchdog();
|
|
167
217
|
this._startKeepalive();
|
|
168
218
|
return;
|
|
169
219
|
} catch (err) {
|
|
@@ -276,6 +326,7 @@ class MQTToTClient extends mqtts_1.MqttClient {
|
|
|
276
326
|
async gracefulClose() {
|
|
277
327
|
try {
|
|
278
328
|
this._stopKeepalive();
|
|
329
|
+
this._stopStallWatchdog();
|
|
279
330
|
if (typeof super.close === 'function') {
|
|
280
331
|
// some libs provide close() or end()
|
|
281
332
|
await super.close();
|
|
@@ -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
|
-
|
|
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
|
-
|
|
313
|
+
this._log('debug', '[REALTIME] Auto-start skipped (after auth load) — MQTT already connected or connect in progress.');
|
|
233
314
|
return;
|
|
234
315
|
}
|
|
235
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
328
|
+
this._log('debug', '[REALTIME] Auto-start skipped (after wait) — MQTT already connected or connect in progress.');
|
|
248
329
|
return;
|
|
249
330
|
}
|
|
250
|
-
|
|
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
|
-
|
|
335
|
+
this._log('error', '[REALTIME] Constructor auto-connect failed:', e?.message || e);
|
|
255
336
|
}
|
|
256
337
|
}
|
|
257
338
|
} catch (e) {
|
|
258
|
-
|
|
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
|
-
|
|
307
|
-
|
|
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
|
-
|
|
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
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
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
|
-
|
|
418
|
+
this._log('error', '[REALTIME] Failed:', error.message);
|
|
338
419
|
throw error;
|
|
339
420
|
}
|
|
340
421
|
}
|
|
@@ -786,7 +867,7 @@ class RealtimeClient extends eventemitter3_1.EventEmitter {
|
|
|
786
867
|
this.connection = new mqttot_1.MQTToTConnection({
|
|
787
868
|
clientIdentifier: deviceId.substring(0, 20),
|
|
788
869
|
clientInfo: {
|
|
789
|
-
userId: BigInt(
|
|
870
|
+
userId: BigInt(String(this.ig.state.cookieUserId || this.ig.state.userId || '0')), // keep full precision (avoid Number() > 2^53),
|
|
790
871
|
userAgent,
|
|
791
872
|
clientCapabilities: 439,
|
|
792
873
|
endpointCapabilities: 128,
|
|
@@ -946,10 +1027,10 @@ class RealtimeClient extends eventemitter3_1.EventEmitter {
|
|
|
946
1027
|
this.on('message', updateLast);
|
|
947
1028
|
this.on('iris', updateLast);
|
|
948
1029
|
|
|
949
|
-
const KEEPALIVE_FOREGROUND_MS = (this.initOptions && this.initOptions.keepaliveForegroundMs) ? this.initOptions.keepaliveForegroundMs :
|
|
1030
|
+
const KEEPALIVE_FOREGROUND_MS = (this.initOptions && this.initOptions.keepaliveForegroundMs) ? this.initOptions.keepaliveForegroundMs : 45000; // 45s keepalive pulse
|
|
950
1031
|
const MESSAGE_SYNC_REFRESH_MS = (this.initOptions && this.initOptions.messageSyncRefreshMs) ? this.initOptions.messageSyncRefreshMs : 300000;
|
|
951
|
-
const TRAFFIC_INACTIVITY_MS = (this.initOptions && this.initOptions.trafficInactivityMs) ? this.initOptions.trafficInactivityMs :
|
|
952
|
-
const HEARTBEAT_MS = (this.initOptions && this.initOptions.heartbeatMs) ? this.initOptions.heartbeatMs :
|
|
1032
|
+
const TRAFFIC_INACTIVITY_MS = (this.initOptions && this.initOptions.trafficInactivityMs) ? this.initOptions.trafficInactivityMs : 180000; // 3 min default for faster recovery
|
|
1033
|
+
const HEARTBEAT_MS = (this.initOptions && this.initOptions.heartbeatMs) ? this.initOptions.heartbeatMs : 90000; // 90s mobile-like heartbeat
|
|
953
1034
|
|
|
954
1035
|
try {
|
|
955
1036
|
if (this._foregroundTimer) clearInterval(this._foregroundTimer);
|
|
@@ -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
|
-
|
|
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
|
-
|
|
1165
|
+
this._log('debug', '[REALTIME] IRIS subscription successful');
|
|
1085
1166
|
}
|
|
1086
1167
|
} catch (e) {
|
|
1087
|
-
|
|
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
|
-
|
|
1721
|
+
this._log('debug', 'connectFromSavedSession skipped — already connected.');
|
|
1641
1722
|
return this;
|
|
1642
1723
|
}
|
|
1643
1724
|
if (this._connectInProgress) {
|
|
1644
|
-
|
|
1725
|
+
this._log('debug', 'connectFromSavedSession skipped — connect already in progress.');
|
|
1645
1726
|
return this;
|
|
1646
1727
|
}
|
|
1647
1728
|
|
|
1648
1729
|
this._connectInProgress = true;
|
|
1649
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1752
|
+
this._log('warn', `Failed to fetch IRIS snapshot (attempt ${attempt}):`, e?.message || e);
|
|
1672
1753
|
if (isAuthIssue) {
|
|
1673
|
-
|
|
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
|
-
|
|
1764
|
+
this._log('warn', 'Could not fetch fresh IRIS snapshot — falling back to saved irisData (may be stale).');
|
|
1684
1765
|
} else if (!irisData) {
|
|
1685
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1800
|
+
this._log('debug', 'MQTT session saved after connect');
|
|
1720
1801
|
} catch (e) {
|
|
1721
|
-
|
|
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
|
-
|
|
1815
|
+
this._log('warn', 'No authStateHelper provided');
|
|
1735
1816
|
return false;
|
|
1736
1817
|
}
|
|
1737
1818
|
await authStateHelper.saveMqttSession(this);
|
package/package.json
CHANGED