diff --git a/composer.json b/composer.json index 764c3373..e0551eb3 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/src/AmoCRM/OAuth/AmoCRMOAuth.php b/src/AmoCRM/OAuth/AmoCRMOAuth.php index d5a52c6a..64c60343 100755 --- a/src/AmoCRM/OAuth/AmoCRMOAuth.php +++ b/src/AmoCRM/OAuth/AmoCRMOAuth.php @@ -17,6 +17,8 @@ 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; @@ -24,8 +26,6 @@ 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; @@ -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; @@ -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')); + } + }); } }