nodejs-insta-private-api-mqt 1.3.72 → 1.3.74
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 +7 -0
- package/dist/mqttot/mqttot.client.js +3 -54
- package/dist/mqttot/mqttot.connect.request.packet.js +1 -1
- package/dist/mqttot/mqttot.connection.js +1 -3
- package/dist/realtime/topic.js +1 -1
- package/dist/thrift/thrift.js +99 -89
- package/dist/thrift/thrift.reading.js +335 -294
- package/dist/thrift/thrift.writing.js +380 -326
- package/package.json +1 -1
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
|
|
@@ -65,23 +65,15 @@ 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 : (8 * 60 * 1000);
|
|
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
|
-
|
|
78
70
|
this._startKeepalive();
|
|
79
71
|
}
|
|
80
72
|
|
|
81
73
|
_startKeepalive() {
|
|
82
74
|
try {
|
|
83
75
|
if (this._keepaliveTimer) clearInterval(this._keepaliveTimer);
|
|
84
|
-
const jitter = Math.floor(Math.random() *
|
|
76
|
+
const jitter = Math.floor(Math.random() * 30000);
|
|
85
77
|
this._keepaliveTimer = setInterval(() => {
|
|
86
78
|
try {
|
|
87
79
|
if (typeof this.ping === 'function') {
|
|
@@ -112,41 +104,7 @@ class MQTToTClient extends mqtts_1.MqttClient {
|
|
|
112
104
|
}
|
|
113
105
|
}
|
|
114
106
|
|
|
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
|
-
/**
|
|
107
|
+
/**
|
|
150
108
|
* Stop keepalive timer (call on explicit close/disconnect)
|
|
151
109
|
*/
|
|
152
110
|
_stopKeepalive() {
|
|
@@ -179,14 +137,9 @@ class MQTToTClient extends mqtts_1.MqttClient {
|
|
|
179
137
|
// Attach diagnostics
|
|
180
138
|
this.on('error', printErrorOrWarning('Error'));
|
|
181
139
|
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) {} });
|
|
186
140
|
|
|
187
141
|
// Listen to ping responses if the library emits them
|
|
188
142
|
this.on('pingresp', () => {
|
|
189
|
-
try { this._lastRxTs = Date.now(); } catch (e) {}
|
|
190
143
|
this.mqttotDebug('Received PINGRESP (keepalive ok)');
|
|
191
144
|
});
|
|
192
145
|
|
|
@@ -194,7 +147,6 @@ class MQTToTClient extends mqtts_1.MqttClient {
|
|
|
194
147
|
try {
|
|
195
148
|
this.mqttotDebug(`Disconnected. Reason: ${reason}`);
|
|
196
149
|
this._stopKeepalive();
|
|
197
|
-
this._stopStallWatchdog();
|
|
198
150
|
|
|
199
151
|
if (this._options && this._options.autoReconnect === false) {
|
|
200
152
|
this.mqttotDebug('autoReconnect disabled; will not attempt reconnect.');
|
|
@@ -212,8 +164,6 @@ class MQTToTClient extends mqtts_1.MqttClient {
|
|
|
212
164
|
await this.connect(this._options);
|
|
213
165
|
this.mqttotDebug('Reconnected successfully');
|
|
214
166
|
this._consecutivePingFailures = 0;
|
|
215
|
-
this._lastRxTs = Date.now();
|
|
216
|
-
this._startStallWatchdog();
|
|
217
167
|
this._startKeepalive();
|
|
218
168
|
return;
|
|
219
169
|
} catch (err) {
|
|
@@ -326,7 +276,6 @@ class MQTToTClient extends mqtts_1.MqttClient {
|
|
|
326
276
|
async gracefulClose() {
|
|
327
277
|
try {
|
|
328
278
|
this._stopKeepalive();
|
|
329
|
-
this._stopStallWatchdog();
|
|
330
279
|
if (typeof super.close === 'function') {
|
|
331
280
|
// some libs provide close() or end()
|
|
332
281
|
await super.close();
|
|
@@ -71,9 +71,7 @@ MQTToTConnection.thriftConfig = [
|
|
|
71
71
|
thrift_1.ThriftDescriptors.binary('fbnsDeviceSecret', 25),
|
|
72
72
|
thrift_1.ThriftDescriptors.int64('anotherUnknown', 26),
|
|
73
73
|
]),
|
|
74
|
-
thrift_1.ThriftDescriptors.binary('password', 5),
|
|
75
|
-
thrift_1.ThriftDescriptors.int16('unknown', 5),
|
|
76
|
-
thrift_1.ThriftDescriptors.listOfBinary('getDiffsRequests', 6),
|
|
74
|
+
thrift_1.ThriftDescriptors.binary('password', 5), thrift_1.ThriftDescriptors.listOfBinary('getDiffsRequests', 6),
|
|
77
75
|
thrift_1.ThriftDescriptors.binary('zeroRatingTokenHash', 9),
|
|
78
76
|
thrift_1.ThriftDescriptors.mapBinaryBinary('appSpecificInfo', 10),
|
|
79
77
|
];
|
package/dist/realtime/topic.js
CHANGED
package/dist/thrift/thrift.js
CHANGED
|
@@ -1,101 +1,111 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.int64ToNumber = exports.ThriftDescriptors = exports.isThriftBoolean = exports.ThriftTypes = void 0;
|
|
3
|
+
exports.isSafeInt64 = exports.int64ToBigInt = exports.int64ToNumberSafe = exports.int64ToNumber = exports.ThriftDescriptors = exports.isThriftBoolean = exports.ThriftTypes = void 0;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Thrift Compact Protocol (subset) helpers used by nodejs-insta-private-api-mqt.
|
|
7
|
+
* Notes:
|
|
8
|
+
* - Instagram's MQTT-over-Thrift payloads can contain INT_64 values that exceed JS Number safe range.
|
|
9
|
+
* - This module keeps backward compatibility (int64ToNumber) but also exposes safe helpers.
|
|
10
|
+
*/
|
|
11
|
+
|
|
4
12
|
exports.ThriftTypes = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
13
|
+
STOP: 0x00,
|
|
14
|
+
TRUE: 0x01,
|
|
15
|
+
FALSE: 0x02,
|
|
16
|
+
BYTE: 0x03,
|
|
17
|
+
INT_16: 0x04,
|
|
18
|
+
INT_32: 0x05,
|
|
19
|
+
INT_64: 0x06,
|
|
20
|
+
DOUBLE: 0x07,
|
|
21
|
+
BINARY: 0x08,
|
|
22
|
+
LIST: 0x09,
|
|
23
|
+
SET: 0x0a,
|
|
24
|
+
MAP: 0x0b,
|
|
25
|
+
STRUCT: 0x0c,
|
|
26
|
+
|
|
27
|
+
// Common "packed" meta-types used by this project:
|
|
28
|
+
LIST_INT_16: (0x04 << 8) | 0x09,
|
|
29
|
+
LIST_INT_32: (0x05 << 8) | 0x09,
|
|
30
|
+
LIST_INT_64: (0x06 << 8) | 0x09,
|
|
31
|
+
LIST_BINARY: (0x08 << 8) | 0x09,
|
|
32
|
+
MAP_BINARY_BINARY: (0x88 << 8) | 0x0b,
|
|
33
|
+
|
|
34
|
+
// internal!
|
|
35
|
+
BOOLEAN: 0xa1,
|
|
25
36
|
};
|
|
37
|
+
|
|
26
38
|
function isThriftBoolean(type) {
|
|
27
|
-
|
|
28
|
-
|
|
39
|
+
type &= 0x0f;
|
|
40
|
+
return (
|
|
41
|
+
type === exports.ThriftTypes.TRUE ||
|
|
42
|
+
type === exports.ThriftTypes.FALSE ||
|
|
43
|
+
type === exports.ThriftTypes.BOOLEAN
|
|
44
|
+
);
|
|
29
45
|
}
|
|
30
46
|
exports.isThriftBoolean = isThriftBoolean;
|
|
47
|
+
|
|
31
48
|
exports.ThriftDescriptors = {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
fieldName,
|
|
51
|
-
type: exports.ThriftTypes.INT_64,
|
|
52
|
-
}),
|
|
53
|
-
double: (fieldName, field) => ({
|
|
54
|
-
field,
|
|
55
|
-
fieldName,
|
|
56
|
-
type: exports.ThriftTypes.DOUBLE,
|
|
57
|
-
}),
|
|
58
|
-
binary: (fieldName, field) => ({
|
|
59
|
-
field,
|
|
60
|
-
fieldName,
|
|
61
|
-
type: exports.ThriftTypes.BINARY,
|
|
62
|
-
}),
|
|
63
|
-
listOfInt16: (fieldName, field) => ({
|
|
64
|
-
field,
|
|
65
|
-
fieldName,
|
|
66
|
-
type: exports.ThriftTypes.LIST_INT_16,
|
|
67
|
-
}),
|
|
68
|
-
listOfInt32: (fieldName, field) => ({
|
|
69
|
-
field,
|
|
70
|
-
fieldName,
|
|
71
|
-
type: exports.ThriftTypes.LIST_INT_32,
|
|
72
|
-
}),
|
|
73
|
-
listOfInt64: (fieldName, field) => ({
|
|
74
|
-
field,
|
|
75
|
-
fieldName,
|
|
76
|
-
type: exports.ThriftTypes.LIST_INT_64,
|
|
77
|
-
}),
|
|
78
|
-
listOfBinary: (fieldName, field) => ({
|
|
79
|
-
field,
|
|
80
|
-
fieldName,
|
|
81
|
-
type: exports.ThriftTypes.LIST_BINARY,
|
|
82
|
-
}),
|
|
83
|
-
mapBinaryBinary: (fieldName, field) => ({
|
|
84
|
-
field,
|
|
85
|
-
fieldName,
|
|
86
|
-
type: exports.ThriftTypes.MAP_BINARY_BINARY,
|
|
87
|
-
}),
|
|
88
|
-
struct: (fieldName, field, descriptors) => ({
|
|
89
|
-
field,
|
|
90
|
-
fieldName,
|
|
91
|
-
type: exports.ThriftTypes.STRUCT,
|
|
92
|
-
structDescriptors: descriptors,
|
|
93
|
-
}),
|
|
49
|
+
boolean: (fieldName, field) => ({ field, fieldName, type: exports.ThriftTypes.BOOLEAN }),
|
|
50
|
+
byte: (fieldName, field) => ({ field, fieldName, type: exports.ThriftTypes.BYTE }),
|
|
51
|
+
int16: (fieldName, field) => ({ field, fieldName, type: exports.ThriftTypes.INT_16 }),
|
|
52
|
+
int32: (fieldName, field) => ({ field, fieldName, type: exports.ThriftTypes.INT_32 }),
|
|
53
|
+
int64: (fieldName, field) => ({ field, fieldName, type: exports.ThriftTypes.INT_64 }),
|
|
54
|
+
double: (fieldName, field) => ({ field, fieldName, type: exports.ThriftTypes.DOUBLE }),
|
|
55
|
+
binary: (fieldName, field) => ({ field, fieldName, type: exports.ThriftTypes.BINARY }),
|
|
56
|
+
listOfInt16: (fieldName, field) => ({ field, fieldName, type: exports.ThriftTypes.LIST_INT_16 }),
|
|
57
|
+
listOfInt32: (fieldName, field) => ({ field, fieldName, type: exports.ThriftTypes.LIST_INT_32 }),
|
|
58
|
+
listOfInt64: (fieldName, field) => ({ field, fieldName, type: exports.ThriftTypes.LIST_INT_64 }),
|
|
59
|
+
listOfBinary: (fieldName, field) => ({ field, fieldName, type: exports.ThriftTypes.LIST_BINARY }),
|
|
60
|
+
mapBinaryBinary: (fieldName, field) => ({ field, fieldName, type: exports.ThriftTypes.MAP_BINARY_BINARY }),
|
|
61
|
+
struct: (fieldName, field, descriptors) => ({
|
|
62
|
+
field,
|
|
63
|
+
fieldName,
|
|
64
|
+
type: exports.ThriftTypes.STRUCT,
|
|
65
|
+
structDescriptors: descriptors,
|
|
66
|
+
}),
|
|
94
67
|
};
|
|
68
|
+
|
|
69
|
+
function int64ToBigInt(i64) {
|
|
70
|
+
if (typeof i64 === "bigint") return i64;
|
|
71
|
+
if (typeof i64 === "number") return BigInt(i64);
|
|
72
|
+
if (typeof i64 === "string") return BigInt(i64);
|
|
73
|
+
if (i64 && typeof i64 === "object") {
|
|
74
|
+
// Support patterns: { int: bigint } (our reader), Long-like, etc.
|
|
75
|
+
if (typeof i64.int === "bigint") return i64.int;
|
|
76
|
+
if (typeof i64.toString === "function") return BigInt(i64.toString());
|
|
77
|
+
}
|
|
78
|
+
// Fallback (may throw)
|
|
79
|
+
return BigInt(i64);
|
|
80
|
+
}
|
|
81
|
+
exports.int64ToBigInt = int64ToBigInt;
|
|
82
|
+
|
|
83
|
+
function isSafeInt64(i64) {
|
|
84
|
+
const bi = int64ToBigInt(i64);
|
|
85
|
+
const max = BigInt(Number.MAX_SAFE_INTEGER);
|
|
86
|
+
const min = BigInt(Number.MIN_SAFE_INTEGER);
|
|
87
|
+
return bi <= max && bi >= min;
|
|
88
|
+
}
|
|
89
|
+
exports.isSafeInt64 = isSafeInt64;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Backward compatible: converts to Number (may lose precision if out of range).
|
|
93
|
+
*/
|
|
95
94
|
function int64ToNumber(i64) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
95
|
+
if (typeof i64 === "number") return i64;
|
|
96
|
+
// Preserve previous behavior (Number(...) fallback)
|
|
97
|
+
return Number(i64 && typeof i64 === "object" && "int" in i64 ? i64.int : i64);
|
|
99
98
|
}
|
|
100
99
|
exports.int64ToNumber = int64ToNumber;
|
|
101
|
-
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Safe conversion: throws if out of safe range.
|
|
103
|
+
*/
|
|
104
|
+
function int64ToNumberSafe(i64) {
|
|
105
|
+
const bi = int64ToBigInt(i64);
|
|
106
|
+
if (!isSafeInt64(bi)) {
|
|
107
|
+
throw new RangeError(`int64 out of safe Number range: ${bi.toString()}`);
|
|
108
|
+
}
|
|
109
|
+
return Number(bi);
|
|
110
|
+
}
|
|
111
|
+
exports.int64ToNumberSafe = int64ToNumberSafe;
|