nodejs-insta-private-api-mqt 1.3.75 → 1.3.76

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.
@@ -188,11 +188,19 @@ class State {
188
188
  } catch {
189
189
  // fallback to parsed authorization if available
190
190
  this.updateAuthorization();
191
- if (!this.parsedAuthorization) throw new Error('Could not find ds_user_id');
192
- return this.parsedAuthorization.ds_user_id;
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');
@@ -1228,7 +1228,13 @@ async function extractStateData(igState) {
1228
1228
  const cookieFields = await extractCookieFields(igState);
1229
1229
 
1230
1230
  // Primary identifiers
1231
- const userIdFromState = igState.cookieUserId || igState.userId || igState.user_id || null;
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
- if (creds.userId && !igState.cookieUserId) igState.cookieUserId = creds.userId;
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodejs-insta-private-api-mqt",
3
- "version": "1.3.75",
3
+ "version": "1.3.76",
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": {