nodejs-insta-private-api-mqt 1.3.89 → 1.3.91
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/dist/realtime/proto/common.proto +38 -0
- package/dist/dist/realtime/proto/direct.proto +65 -0
- package/dist/dist/realtime/proto/ig-messages.proto +83 -0
- package/dist/dist/realtime/proto/iris.proto +188 -0
- package/dist/dist/repositories/account.repository.js +40 -8
- package/package.json +1 -1
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package ig.common;
|
|
4
|
+
|
|
5
|
+
// Shared message types used across Instagram
|
|
6
|
+
|
|
7
|
+
message Timestamp {
|
|
8
|
+
int64 unix_time_ms = 1;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
message UserId {
|
|
12
|
+
int64 id = 1;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
message ThreadId {
|
|
16
|
+
int64 id = 1;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
message Reaction {
|
|
20
|
+
string emoji = 1;
|
|
21
|
+
int32 count = 2;
|
|
22
|
+
int64 created_at = 3;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
message MediaAttachment {
|
|
26
|
+
int64 media_id = 1;
|
|
27
|
+
string type = 2; // image, video, carousel
|
|
28
|
+
string url = 3;
|
|
29
|
+
int32 width = 4;
|
|
30
|
+
int32 height = 5;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
message Link {
|
|
34
|
+
string url = 1;
|
|
35
|
+
string title = 2;
|
|
36
|
+
string description = 3;
|
|
37
|
+
string image_url = 4;
|
|
38
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package ig.direct;
|
|
4
|
+
|
|
5
|
+
import "common.proto";
|
|
6
|
+
|
|
7
|
+
// Direct message protocol - Specific implementation for DMs
|
|
8
|
+
|
|
9
|
+
message DirectInboxMessageContent {
|
|
10
|
+
string text = 1;
|
|
11
|
+
repeated ig.common.MediaAttachment media = 2;
|
|
12
|
+
repeated ig.common.Link links = 3;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
message DirectInboxMessage {
|
|
16
|
+
string id = 1;
|
|
17
|
+
int64 user_id = 2;
|
|
18
|
+
int64 timestamp = 3;
|
|
19
|
+
|
|
20
|
+
string item_type = 4; // text, media_share, animated_media, etc
|
|
21
|
+
DirectInboxMessageContent content = 5;
|
|
22
|
+
|
|
23
|
+
map<string, string> reactions = 6;
|
|
24
|
+
|
|
25
|
+
bool is_sent = 7;
|
|
26
|
+
bool is_delivered = 8;
|
|
27
|
+
bool is_seen = 9;
|
|
28
|
+
|
|
29
|
+
int32 is_forward = 10;
|
|
30
|
+
int32 forwarded_from_id = 11;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
message DirectInboxThread {
|
|
34
|
+
int64 thread_id = 1;
|
|
35
|
+
repeated int64 user_ids = 2;
|
|
36
|
+
|
|
37
|
+
string thread_title = 3;
|
|
38
|
+
int64 last_activity_at = 4;
|
|
39
|
+
|
|
40
|
+
DirectInboxMessage last_message = 5;
|
|
41
|
+
|
|
42
|
+
int32 unfollowers_count = 6;
|
|
43
|
+
int32 thread_v2_id = 7;
|
|
44
|
+
|
|
45
|
+
bool is_pin = 8;
|
|
46
|
+
bool is_muted = 9;
|
|
47
|
+
bool is_archived = 10;
|
|
48
|
+
bool has_newer = 11;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
message DirectInbox {
|
|
52
|
+
repeated DirectInboxThread threads = 1;
|
|
53
|
+
string cursor = 2;
|
|
54
|
+
bool has_older = 3;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
message DirectSync {
|
|
58
|
+
int64 seq_id = 1;
|
|
59
|
+
int64 timestamp = 2;
|
|
60
|
+
|
|
61
|
+
repeated DirectInboxMessage messages = 3;
|
|
62
|
+
repeated DirectInboxThread threads = 4;
|
|
63
|
+
|
|
64
|
+
map<string, int64> seq_ids = 5; // per-thread seq tracking
|
|
65
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// Instagram Direct Messages Protocol (Protobuf)
|
|
2
|
+
// Used for real-time message sync via MQTT
|
|
3
|
+
|
|
4
|
+
syntax = "proto3";
|
|
5
|
+
|
|
6
|
+
package ig.iris;
|
|
7
|
+
|
|
8
|
+
// DirectMessage - Single message in a thread
|
|
9
|
+
message DirectMessage {
|
|
10
|
+
int64 message_id = 1;
|
|
11
|
+
int64 user_id = 2;
|
|
12
|
+
string content = 3;
|
|
13
|
+
int64 timestamp = 4;
|
|
14
|
+
|
|
15
|
+
// Message type: text, photo, video, etc.
|
|
16
|
+
string type = 5;
|
|
17
|
+
|
|
18
|
+
// Reactions: emoji -> count
|
|
19
|
+
map<string, int32> reactions = 6;
|
|
20
|
+
|
|
21
|
+
// Whether user has seen
|
|
22
|
+
bool is_sent = 7;
|
|
23
|
+
bool is_delivered = 8;
|
|
24
|
+
bool is_read = 9;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// DirectThread - Conversation thread
|
|
28
|
+
message DirectThread {
|
|
29
|
+
int64 thread_id = 1;
|
|
30
|
+
repeated int64 participant_ids = 2;
|
|
31
|
+
string thread_title = 3;
|
|
32
|
+
int64 last_message_ts = 4;
|
|
33
|
+
|
|
34
|
+
// Admin user ID
|
|
35
|
+
int64 admin_user_id = 5;
|
|
36
|
+
|
|
37
|
+
// Is group thread
|
|
38
|
+
bool is_group = 6;
|
|
39
|
+
|
|
40
|
+
// Is archived
|
|
41
|
+
bool is_archived = 7;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// TypingIndicator - User typing signal
|
|
45
|
+
message TypingIndicator {
|
|
46
|
+
int64 thread_id = 1;
|
|
47
|
+
int64 from_user_id = 2;
|
|
48
|
+
int64 timestamp = 3;
|
|
49
|
+
|
|
50
|
+
// 0 = typing, 1 = stopped
|
|
51
|
+
int32 state = 4;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// PresenceStatus - User online/offline
|
|
55
|
+
message PresenceStatus {
|
|
56
|
+
int64 user_id = 1;
|
|
57
|
+
|
|
58
|
+
// 0 = offline, 1 = active, 2 = idle
|
|
59
|
+
int32 status = 2;
|
|
60
|
+
|
|
61
|
+
int64 timestamp = 3;
|
|
62
|
+
int64 last_active = 4;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// DeltaMessage - Incremental sync update
|
|
66
|
+
message DeltaMessage {
|
|
67
|
+
int64 sequence_id = 1;
|
|
68
|
+
string operation = 2; // add, update, delete
|
|
69
|
+
|
|
70
|
+
oneof data {
|
|
71
|
+
DirectMessage message = 3;
|
|
72
|
+
DirectThread thread = 4;
|
|
73
|
+
TypingIndicator typing = 5;
|
|
74
|
+
PresenceStatus presence = 6;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Acknowledgment - Server expects ACK for delivery
|
|
79
|
+
message Acknowledgment {
|
|
80
|
+
int64 message_id = 1;
|
|
81
|
+
int64 thread_id = 2;
|
|
82
|
+
int64 timestamp = 3;
|
|
83
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package ig.iris;
|
|
4
|
+
|
|
5
|
+
import "common.proto";
|
|
6
|
+
|
|
7
|
+
// Real Instagram Iris Protocol - Direct Messages & Realtime
|
|
8
|
+
// Based on reverse-engineered instagram_mqtt package
|
|
9
|
+
|
|
10
|
+
message IrisPayload {
|
|
11
|
+
string action = 1;
|
|
12
|
+
int64 seq_id = 2;
|
|
13
|
+
repeated IrisItem items = 3;
|
|
14
|
+
map<string, string> metadata = 4;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
message IrisItem {
|
|
18
|
+
string id = 1;
|
|
19
|
+
string type = 2; // message, thread, typing, presence, deletion
|
|
20
|
+
int64 timestamp = 3;
|
|
21
|
+
|
|
22
|
+
oneof data {
|
|
23
|
+
MessageSyncMessage message = 4;
|
|
24
|
+
ThreadUpdate thread = 5;
|
|
25
|
+
TypingIndicator typing = 6;
|
|
26
|
+
PresenceIndicator presence = 7;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
string op = 8; // add, replace, delete
|
|
30
|
+
string path = 9; // JSON path to item
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Message from sync - includes text, media, reactions
|
|
34
|
+
message MessageSyncMessage {
|
|
35
|
+
string item_id = 1;
|
|
36
|
+
int64 user_id = 2;
|
|
37
|
+
int64 timestamp = 3;
|
|
38
|
+
|
|
39
|
+
string thread_id = 4;
|
|
40
|
+
string thread_v2_id = 5;
|
|
41
|
+
|
|
42
|
+
// Message type: text, media, like, hashtag, media_share, location, voice_media, animated_media
|
|
43
|
+
string item_type = 6;
|
|
44
|
+
string text = 7;
|
|
45
|
+
|
|
46
|
+
// Media references
|
|
47
|
+
MediaData media = 8;
|
|
48
|
+
VoiceMediaData voice_media = 9;
|
|
49
|
+
AnimatedMediaData animated_media = 10;
|
|
50
|
+
MediaShareData media_share = 11;
|
|
51
|
+
|
|
52
|
+
// Reactions
|
|
53
|
+
ReactionData reactions = 12;
|
|
54
|
+
|
|
55
|
+
// Metadata
|
|
56
|
+
bool is_sent = 13;
|
|
57
|
+
bool is_delivered = 14;
|
|
58
|
+
bool is_read = 15;
|
|
59
|
+
|
|
60
|
+
// Voice/Video Call info
|
|
61
|
+
string raven_media_type = 16;
|
|
62
|
+
map<string, string> extra_data = 17;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
message MediaData {
|
|
66
|
+
string id = 1;
|
|
67
|
+
int32 media_type = 2; // 1=image, 2=video, 8=album
|
|
68
|
+
|
|
69
|
+
int32 original_width = 3;
|
|
70
|
+
int32 original_height = 4;
|
|
71
|
+
|
|
72
|
+
repeated string image_urls = 5;
|
|
73
|
+
repeated string video_urls = 6;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
message VoiceMediaData {
|
|
77
|
+
string id = 1;
|
|
78
|
+
string audio_src = 2;
|
|
79
|
+
int32 duration = 3;
|
|
80
|
+
repeated int32 waveform_data = 4;
|
|
81
|
+
|
|
82
|
+
bool seen = 5;
|
|
83
|
+
int32 seen_count = 6;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
message AnimatedMediaData {
|
|
87
|
+
string id = 1;
|
|
88
|
+
string url = 2;
|
|
89
|
+
bool is_sticker = 3;
|
|
90
|
+
bool is_random = 4;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
message MediaShareData {
|
|
94
|
+
string id = 1;
|
|
95
|
+
string code = 2;
|
|
96
|
+
int32 media_type = 3;
|
|
97
|
+
|
|
98
|
+
int32 original_width = 4;
|
|
99
|
+
int32 original_height = 5;
|
|
100
|
+
|
|
101
|
+
string caption = 6;
|
|
102
|
+
int32 like_count = 7;
|
|
103
|
+
int32 comment_count = 8;
|
|
104
|
+
int64 taken_at = 9;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
message ReactionData {
|
|
108
|
+
map<int64, string> emojis = 1; // user_id -> emoji
|
|
109
|
+
int32 likes_count = 2;
|
|
110
|
+
int32 emojis_count = 3;
|
|
111
|
+
|
|
112
|
+
repeated ReactionItem likes = 4;
|
|
113
|
+
repeated ReactionItem emoji_reactions = 5;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
message ReactionItem {
|
|
117
|
+
int64 sender_id = 1;
|
|
118
|
+
int64 timestamp = 2;
|
|
119
|
+
string client_context = 3;
|
|
120
|
+
string emoji = 4;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Thread Update - conversation data
|
|
124
|
+
message ThreadUpdate {
|
|
125
|
+
string thread_id = 1;
|
|
126
|
+
string thread_v2_id = 2;
|
|
127
|
+
|
|
128
|
+
// Participants
|
|
129
|
+
repeated int64 user_ids = 3;
|
|
130
|
+
repeated int64 left_user_ids = 4;
|
|
131
|
+
repeated int64 admin_user_ids = 5;
|
|
132
|
+
|
|
133
|
+
// Thread info
|
|
134
|
+
string thread_title = 6;
|
|
135
|
+
int64 last_activity_at = 7;
|
|
136
|
+
|
|
137
|
+
bool is_group = 8;
|
|
138
|
+
bool is_archived = 9;
|
|
139
|
+
bool is_muted = 10;
|
|
140
|
+
bool is_pinned = 11;
|
|
141
|
+
bool is_spam = 12;
|
|
142
|
+
|
|
143
|
+
string thread_type = 13; // private, group
|
|
144
|
+
int32 folder = 14;
|
|
145
|
+
|
|
146
|
+
// Last message in thread
|
|
147
|
+
MessageSyncMessage last_message = 15;
|
|
148
|
+
|
|
149
|
+
// Pagination
|
|
150
|
+
bool has_older = 16;
|
|
151
|
+
bool has_newer = 17;
|
|
152
|
+
string newest_cursor = 18;
|
|
153
|
+
string oldest_cursor = 19;
|
|
154
|
+
string next_cursor = 20;
|
|
155
|
+
|
|
156
|
+
map<string, ThreadMetadata> metadata = 21;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
message ThreadMetadata {
|
|
160
|
+
string key = 1;
|
|
161
|
+
string value = 2;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Typing indicator
|
|
165
|
+
message TypingIndicator {
|
|
166
|
+
int64 thread_id = 1;
|
|
167
|
+
int64 from_user_id = 2;
|
|
168
|
+
string state = 3; // started, stopped
|
|
169
|
+
int64 timestamp = 4;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// User presence indicator
|
|
173
|
+
message PresenceIndicator {
|
|
174
|
+
int64 user_id = 1;
|
|
175
|
+
string status = 2; // active, inactive
|
|
176
|
+
int64 last_seen_at = 3;
|
|
177
|
+
int64 timestamp = 4;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// Delta - incremental update
|
|
181
|
+
message Delta {
|
|
182
|
+
string operation = 1; // add, update, delete
|
|
183
|
+
string path = 2;
|
|
184
|
+
|
|
185
|
+
IrisItem item = 3;
|
|
186
|
+
|
|
187
|
+
map<string, string> context = 4;
|
|
188
|
+
}
|
|
@@ -731,6 +731,31 @@ class AccountRepository extends Repository {
|
|
|
731
731
|
headers,
|
|
732
732
|
});
|
|
733
733
|
|
|
734
|
+
// NEW: salvăm cheia de criptare a parolei direct din headers de la mobileconfig
|
|
735
|
+
try {
|
|
736
|
+
const mcHeaders = response.headers || {};
|
|
737
|
+
const mcLower = {};
|
|
738
|
+
for (const k of Object.keys(mcHeaders)) {
|
|
739
|
+
mcLower[k.toLowerCase()] = mcHeaders[k];
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
const mcKeyIdStr =
|
|
743
|
+
mcLower['ig-set-password-encryption-key-id'];
|
|
744
|
+
const mcPubKey =
|
|
745
|
+
mcLower['ig-set-password-encryption-pub-key'];
|
|
746
|
+
|
|
747
|
+
if (mcKeyIdStr) {
|
|
748
|
+
const parsedKeyId = parseInt(mcKeyIdStr, 10);
|
|
749
|
+
if (!Number.isNaN(parsedKeyId)) {
|
|
750
|
+
state.passwordEncryptionKeyId = parsedKeyId;
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
if (mcPubKey) {
|
|
755
|
+
state.passwordEncryptionPubKey = mcPubKey;
|
|
756
|
+
}
|
|
757
|
+
} catch (e) {}
|
|
758
|
+
|
|
734
759
|
try {
|
|
735
760
|
const fs = require('fs');
|
|
736
761
|
const path = require('path');
|
|
@@ -1059,18 +1084,23 @@ class AccountRepository extends Repository {
|
|
|
1059
1084
|
throw new Error('Username and password are required');
|
|
1060
1085
|
}
|
|
1061
1086
|
|
|
1087
|
+
// 0: ne asigurăm că avem csrf + cookies de bază
|
|
1088
|
+
await this.ensureCsrfToken();
|
|
1089
|
+
|
|
1090
|
+
// 1: încercăm să luăm cheia de criptare a parolei din /launcher/mobileconfig/
|
|
1091
|
+
try {
|
|
1092
|
+
await this._launcherMobileConfig(true);
|
|
1093
|
+
} catch (e) {}
|
|
1094
|
+
|
|
1095
|
+
// Fallback: dacă mobileconfig nu a setat cheia, folosim mecanismul vechi de LOGIN_EXPERIMENTS
|
|
1062
1096
|
if (!this.client.state.passwordEncryptionPubKey) {
|
|
1063
1097
|
await this.syncLoginExperiments();
|
|
1064
1098
|
}
|
|
1065
1099
|
|
|
1100
|
+
// Acum parola este criptată CU cheia venită din mobileconfig (dacă a existat)
|
|
1066
1101
|
const { encrypted, time } = this.encryptPassword(password);
|
|
1067
1102
|
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
// Step 1–5: mobileconfig, keystore attestation, TOS preload, process client data, phone prefill
|
|
1071
|
-
try {
|
|
1072
|
-
await this._launcherMobileConfig(true);
|
|
1073
|
-
} catch (e) {}
|
|
1103
|
+
// Step 2–5: keystore attestation, TOS preload, process client data, phone prefill
|
|
1074
1104
|
try {
|
|
1075
1105
|
await this._createAndroidKeystoreAttestation();
|
|
1076
1106
|
} catch (e) {}
|
|
@@ -2291,10 +2321,12 @@ class AccountRepository extends Repository {
|
|
|
2291
2321
|
phone_id: this.client.state.phoneId,
|
|
2292
2322
|
device_token: '',
|
|
2293
2323
|
guid: this.client.state.uuid,
|
|
2294
|
-
users:
|
|
2324
|
+
users: preferen1gces,
|
|
2295
2325
|
}),
|
|
2296
2326
|
});
|
|
2297
2327
|
return response.body;
|
|
2298
2328
|
});
|
|
2299
2329
|
}
|
|
2300
|
-
}
|
|
2330
|
+
}
|
|
2331
|
+
|
|
2332
|
+
module.exports = AccountRepository;
|
package/package.json
CHANGED