Skip to content

Commit

Permalink
feat(misc): minor change
Browse files Browse the repository at this point in the history
  • Loading branch information
ging-dev committed Jul 9, 2024
1 parent 8bdd5ef commit 69d7b18
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/Api/UnauthenticatedApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@ public function login(array $credentials): AuthenticatedApi
->setAllowedTypes('accessCode', 'string')
;

[$captchaId, $captchaCode] = $this->bypassCaptcha();

$parameters = $resolver->resolve($credentials);
$parameters['captchaId'] = $captchaId;
$parameters['captchaCode'] = $captchaCode;
$parameters = $resolver->resolve($credentials) + $this->bypassCaptcha();

/** @var array{sessionId: string, ...} */
$result = $this->post('signIn', $parameters);
Expand All @@ -45,15 +41,16 @@ public function login(array $credentials): AuthenticatedApi
}

/**
* @return array{string,string}
* @return array{captchaId:string,captchaCode:string}
*/
private function bypassCaptcha(): array
{
$captchaId = Random::generate(9, '0-9a-zA-Z');
$svg = (string) $this->iPayClient->getClient()
->get(sprintf('api/get-captcha/%s', $captchaId))
->getBody();
$captchaCode = CaptchaSolver::solve($svg);

return [$captchaId, CaptchaSolver::solve($svg)];
return compact('captchaId', 'captchaCode');
}
}

0 comments on commit 69d7b18

Please sign in to comment.