Skip to content

Commit

Permalink
detect checkpoint (#39)
Browse files Browse the repository at this point in the history
* detect checkpoint

* make usage of pk_id consistent
  • Loading branch information
sooluh authored Jul 10, 2023
1 parent 6563413 commit eff376c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ class Client extends EventEmitter {
const text = await response.text();
const bloks = parseBloksResponse(text);

if ('error' in bloks && bloks.error.error_user_msg === "challenge_required") {
throw new Error('Your Instagram account is facing a checkpoint.')
}

if (bloks.two_factor_required) {
const {
two_factor_identifier,
Expand Down Expand Up @@ -116,8 +120,8 @@ class Client extends EventEmitter {
const json = await response.json();
const header = response.headers.get('Ig-Set-Authorization');

if (json.logged_in_user.pk) {
self.userId = json.logged_in_user.pk;
if (json.logged_in_user.pk_id) {
self.userId = json.logged_in_user.pk_id;
}

clearInterval(interval);
Expand All @@ -132,7 +136,7 @@ class Client extends EventEmitter {
return;
}

if (bloks.login_response && bloks.login_response.logged_in_user.pk) {
if (bloks.login_response.logged_in_user.pk_id) {
this.userId = bloks.login_response.logged_in_user.pk_id;
}

Expand Down

0 comments on commit eff376c

Please sign in to comment.