nodejs-insta-private-api-mqt 1.3.75 → 1.3.77
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/core/request.js
CHANGED
|
@@ -185,12 +185,17 @@ class Request {
|
|
|
185
185
|
|
|
186
186
|
// Update cookies from Set-Cookie headers (if cookieJar is available)
|
|
187
187
|
const setCookieHeaders = headers['set-cookie'] || headers['Set-Cookie'];
|
|
188
|
-
|
|
189
|
-
|
|
188
|
+
const jar = this.client.state && (this.client.state.cookieJar || this.client.state.cookieStore);
|
|
189
|
+
if (setCookieHeaders && jar) {
|
|
190
|
+
const cookieArray = Array.isArray(setCookieHeaders) ? setCookieHeaders : [setCookieHeaders];
|
|
191
|
+
cookieArray.forEach(cookieString => {
|
|
190
192
|
try {
|
|
191
|
-
// host constant fallback if available
|
|
192
193
|
const host = (this.client.state.constants && this.client.state.constants.HOST) ? this.client.state.constants.HOST : 'https://i.instagram.com';
|
|
193
|
-
|
|
194
|
+
if (typeof jar.setCookieSync === 'function') {
|
|
195
|
+
jar.setCookieSync(cookieString, host);
|
|
196
|
+
} else if (typeof jar.setCookie === 'function') {
|
|
197
|
+
jar.setCookie(cookieString, host, () => {});
|
|
198
|
+
}
|
|
194
199
|
} catch (e) {
|
|
195
200
|
// ignore cookie parsing errors
|
|
196
201
|
}
|
package/dist/core/state.js
CHANGED
|
@@ -188,11 +188,19 @@ class State {
|
|
|
188
188
|
} catch {
|
|
189
189
|
// fallback to parsed authorization if available
|
|
190
190
|
this.updateAuthorization();
|
|
191
|
-
if (
|
|
192
|
-
|
|
191
|
+
if (this.parsedAuthorization && this.parsedAuthorization.ds_user_id) {
|
|
192
|
+
return this.parsedAuthorization.ds_user_id;
|
|
193
|
+
}
|
|
194
|
+
// fallback: check if userId was set directly on state
|
|
195
|
+
if (this._userId) return this._userId;
|
|
196
|
+
return null;
|
|
193
197
|
}
|
|
194
198
|
}
|
|
195
199
|
|
|
200
|
+
set cookieUserId(val) {
|
|
201
|
+
this._userId = val;
|
|
202
|
+
}
|
|
203
|
+
|
|
196
204
|
get cookieUsername() {
|
|
197
205
|
try {
|
|
198
206
|
return this.extractCookieValue('ds_user');
|
|
@@ -114,8 +114,8 @@ class AccountRepository extends Repository {
|
|
|
114
114
|
'X-FB-Connection-Type': 'MOBILE.LTE',
|
|
115
115
|
'X-FB-Network-Properties': 'VPN;Metered;Validated;LocalAddrs=/10.0.0.2,;',
|
|
116
116
|
'X-FB-Conn-UUID-Client': crypto.randomBytes(16).toString('hex'),
|
|
117
|
-
'Accept-Encoding': '
|
|
118
|
-
'X-FB-HTTP-Engine': '
|
|
117
|
+
'Accept-Encoding': 'gzip, deflate',
|
|
118
|
+
'X-FB-HTTP-Engine': 'Liger',
|
|
119
119
|
};
|
|
120
120
|
|
|
121
121
|
const response = await this.client.request.send({
|
|
@@ -183,6 +183,41 @@ class AccountRepository extends Repository {
|
|
|
183
183
|
err.challengeInfo = body.challenge || null;
|
|
184
184
|
throw err;
|
|
185
185
|
}
|
|
186
|
+
|
|
187
|
+
const bearerMatch = layoutStr.match(/Bearer IGT:2:[A-Za-z0-9+\/=]+/);
|
|
188
|
+
if (bearerMatch) {
|
|
189
|
+
this.client.state.authorization = bearerMatch[0];
|
|
190
|
+
this.client.state.updateAuthorization();
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const pkMatch = layoutStr.match(/\\"pk\\":(\d+)/);
|
|
194
|
+
if (pkMatch) {
|
|
195
|
+
this.client.state.cookieUserId = pkMatch[1];
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const wwwClaimMatch = layoutStr.match(/IG-Set-WWW-Claim[\\"\s:]+([a-f0-9]+)/i);
|
|
199
|
+
if (wwwClaimMatch) {
|
|
200
|
+
this.client.state.igWWWClaim = wwwClaimMatch[1];
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const encKeyIdMatch = layoutStr.match(/IG-Set-Password-Encryption-Key-Id[\\"\s:]+(\d+)/i);
|
|
204
|
+
if (encKeyIdMatch) {
|
|
205
|
+
this.client.state.passwordEncryptionKeyId = parseInt(encKeyIdMatch[1]);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const encPubKeyMatch = layoutStr.match(/IG-Set-Password-Encryption-Pub-Key[\\"\s:]+([A-Za-z0-9+\/=]+)/i);
|
|
209
|
+
if (encPubKeyMatch) {
|
|
210
|
+
this.client.state.passwordEncryptionPubKey = encPubKeyMatch[1];
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const loginResponseMatch = layoutStr.match(/\\"logged_in_user\\":\{[^}]*\\"pk\\":(\d+)[^}]*\\"username\\":\\"([^"\\]+)\\"/);
|
|
214
|
+
if (loginResponseMatch) {
|
|
215
|
+
return {
|
|
216
|
+
pk: parseInt(loginResponseMatch[1]),
|
|
217
|
+
pk_id: loginResponseMatch[1],
|
|
218
|
+
username: loginResponseMatch[2],
|
|
219
|
+
};
|
|
220
|
+
}
|
|
186
221
|
}
|
|
187
222
|
|
|
188
223
|
if (body.logged_in_user) {
|
|
@@ -1228,7 +1228,13 @@ async function extractStateData(igState) {
|
|
|
1228
1228
|
const cookieFields = await extractCookieFields(igState);
|
|
1229
1229
|
|
|
1230
1230
|
// Primary identifiers
|
|
1231
|
-
|
|
1231
|
+
let userIdFromState = null;
|
|
1232
|
+
try {
|
|
1233
|
+
userIdFromState = igState.cookieUserId || null;
|
|
1234
|
+
} catch (e) {}
|
|
1235
|
+
if (!userIdFromState) {
|
|
1236
|
+
userIdFromState = igState.userId || igState.user_id || null;
|
|
1237
|
+
}
|
|
1232
1238
|
const dsUserIdFromCookies = cookieFields.dsUserIdCookie || igState.dsUserId || igState.ds_user_id || null;
|
|
1233
1239
|
const sessionIdFromCookies = cookieFields.sessionIdCookie || null;
|
|
1234
1240
|
const csrfFromCookies = cookieFields.csrfTokenCookie || null;
|
|
@@ -1297,7 +1303,9 @@ async function applyStateData(igState, authState) {
|
|
|
1297
1303
|
|
|
1298
1304
|
// apply new creds-derived fields if state supports them (non-intrusive)
|
|
1299
1305
|
try {
|
|
1300
|
-
|
|
1306
|
+
let _hasCookieUserId = false;
|
|
1307
|
+
try { _hasCookieUserId = !!igState.cookieUserId; } catch (e) {}
|
|
1308
|
+
if (creds.userId && !_hasCookieUserId) igState.cookieUserId = creds.userId;
|
|
1301
1309
|
if (creds.username && !igState.username) igState.username = creds.username;
|
|
1302
1310
|
if (creds.rankToken && !igState.rankToken) igState.rankToken = creds.rankToken;
|
|
1303
1311
|
if (creds.sessionId && !igState.sessionId) igState.sessionId = creds.sessionId;
|
package/package.json
CHANGED