insta-api-wrapper 1.1.4 → 1.2.1
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/lib/lib/login.bloks.js +23 -9
- package/package.json +1 -1
package/lib/lib/login.bloks.js
CHANGED
|
@@ -341,7 +341,8 @@ export function bloksDetectAirwave(rawStr) {
|
|
|
341
341
|
rawStr.includes('AIRWAVE') || rawStr.includes('airwave');
|
|
342
342
|
}
|
|
343
343
|
export function bloksExtractSession(rawStr) {
|
|
344
|
-
const
|
|
344
|
+
const igtMarker = 'IGT:2:';
|
|
345
|
+
const idx = rawStr.indexOf(igtMarker);
|
|
345
346
|
if (idx === -1)
|
|
346
347
|
return null;
|
|
347
348
|
let end = rawStr.length;
|
|
@@ -351,15 +352,28 @@ export function bloksExtractSession(rawStr) {
|
|
|
351
352
|
break;
|
|
352
353
|
}
|
|
353
354
|
}
|
|
354
|
-
const
|
|
355
|
-
const
|
|
356
|
-
const uidIdx = rawStr.indexOf(uidMarker);
|
|
355
|
+
const token = rawStr.slice(idx, end);
|
|
356
|
+
const authorization = `Bearer ${token}`;
|
|
357
357
|
let userId = '';
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
358
|
+
const lastColon = token.lastIndexOf(':');
|
|
359
|
+
if (lastColon > 0) {
|
|
360
|
+
try {
|
|
361
|
+
const decoded = Buffer.from(token.slice(lastColon + 1), 'base64').toString('utf-8');
|
|
362
|
+
const parsed = JSON.parse(decoded);
|
|
363
|
+
if (parsed.ds_user_id)
|
|
364
|
+
userId = String(parsed.ds_user_id);
|
|
365
|
+
}
|
|
366
|
+
catch (_) { }
|
|
367
|
+
}
|
|
368
|
+
if (!userId) {
|
|
369
|
+
const uidMarker = '"ds_user_id":"';
|
|
370
|
+
const uidIdx = rawStr.indexOf(uidMarker);
|
|
371
|
+
if (uidIdx !== -1) {
|
|
372
|
+
const uStart = uidIdx + uidMarker.length;
|
|
373
|
+
const uEnd = rawStr.indexOf('"', uStart);
|
|
374
|
+
if (uEnd > uStart)
|
|
375
|
+
userId = rawStr.slice(uStart, uEnd);
|
|
376
|
+
}
|
|
363
377
|
}
|
|
364
378
|
return { authorization, userId };
|
|
365
379
|
}
|