Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"amocrm/oauth2-amocrm": "^3.0",
"fig/http-message-util": "1.*",
"guzzlehttp/guzzle": "6.* || 7.*",
"lcobucci/clock": "1.1.0 ||^2.0.0",
"lcobucci/jwt": "^3.4.6 || ^4.0.4 || ^5.0",
"nesbot/carbon": "^2.72.6 || ^3.8.4",
"ramsey/uuid": "^3 || ^4",
Expand Down
16 changes: 9 additions & 7 deletions src/AmoCRM/OAuth/AmoCRMOAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
use AmoCRM\Exceptions\AmoCRMoAuthApiException;
use AmoCRM\Exceptions\BadTypeException;
use AmoCRM\OAuth2\Client\Provider\AmoCRM;
use DateTimeImmutable;
use DateTimeZone;
use Exception;
use Fig\Http\Message\StatusCodeInterface;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\Exception\TooManyRedirectsException;
use GuzzleHttp\Psr7\Uri;
use Lcobucci\Clock\FrozenClock;
use Lcobucci\Clock\SystemClock;
use Lcobucci\JWT\Configuration;
use Lcobucci\JWT\Signer\Hmac\Sha256;
use Lcobucci\JWT\Signer\Hmac\Sha512;
Expand All @@ -40,6 +40,7 @@
use League\OAuth2\Client\Provider\ResourceOwnerInterface;
use League\OAuth2\Client\Token\AccessToken;
use League\OAuth2\Client\Token\AccessTokenInterface;
use Psr\Clock\ClockInterface;
use RuntimeException;
use Throwable;
use Lcobucci\JWT\Validation\Constraint\StrictValidAt;
Expand Down Expand Up @@ -717,11 +718,12 @@ private function createValidAtConstraint(): Constraint

foreach ($availableConstraints as $constraintClass) {
if (class_exists($constraintClass)) {
$clockClass = class_exists(FrozenClock::class)
? FrozenClock::class
: SystemClock::class;

return new $constraintClass($clockClass::fromUTC());
return new $constraintClass(new class implements ClockInterface {
public function now(): DateTimeImmutable
{
return new DateTimeImmutable('now', new DateTimeZone('UTC'));
}
});
}
}

Expand Down