Get the number of minutes until the token expiry.

@param  \Tymon\JWTAuth\Payload  $payload

@return int
766447
protected function getMinutesUntilExpired(Payload $payload)
    {
        $exp = Utils::timestamp($payload['exp']);
        $iat = Utils::timestamp($payload['iat']);

        // get the latter of the two expiration dates and find
        // the number of minutes until the expiration date,
        // plus 1 minute to avoid overlap
        return $exp->max($iat->addMinutes($this->refreshTTL))->addMinute()->diffInMinutes();
    }
539943
public function expireToken($token)
    {
        $tokenData = $this->getTokenData($token);
        if ($tokenData == false) {
            return false;
        }

        $tokenData->date_of_expiry = time() - 1;
        return $tokenData->save();
    }
453546
public function addForever(Payload $payload)
    {
        $this->storage->forever($this->getKey($payload), 'forever');

        return true;
    }
878755
public function handlePayload(Payload $payload): void
    {
        $app = $this->getClientApplication();

        $this->logger->debug('Handling payload: ' . $payload->getPayload());

        switch ($type = $payload->getType()) {
            case Protocol::TYPE_TEXT:
                if (method_exists($app, 'onData')) {
                    $app->onData((string)$payload, $this);
                }
                return;

            case Protocol::TYPE_BINARY:
                if (method_exists($app, 'onBinaryData')) {
                    $app->onBinaryData((string)$payload, $this);
                } else {
                    $this->close(1003);
                }
                break;

            case Protocol::TYPE_PING:
                $this->logger->info('Ping received', 'notice');
                $this->send($payload->getPayload(), Protocol::TYPE_PONG);
                $this->logger->info('Pong!', 'debug');
                break;

            /**
             * A Pong frame MAY be sent unsolicited.  This serves as a
             * unidirectional heartbeat.  A response to an unsolicited Pong
             * frame is not expected.
             */
            case Protocol::TYPE_PONG:
                $this->logger->info('Received unsolicited pong');
                break;

            case Protocol::TYPE_CLOSE:
                $this->logger->notice('Close frame received');
                $this->close();
                $this->logger->info('Disconnected');
                break;

            default:
                throw new ConnectionException('Unhandled payload type');
        }
    }
1111076
public function isExpired()
    {
        $payload = $this->getPayload();

        if (isset($payload['exp'])) {
            $now = new \DateTime('now');

            if (is_int($payload['exp'])) {
                return ($now->getTimestamp() - $payload['exp']) > 0;
            }

            if (is_numeric($payload['exp'])) {
                return ($now->format('U') - $payload['exp']) > 0;
            }
        }

        return false;
    }
561693
public function verify(Payload $payload)
    {
        $response = $this->service->call($payload);

        $string = $response->getBody();

        $pattern = sprintf('/(%s|%s)/', self::IPN_VERIFIED, self::IPN_INVALID);

        if (!preg_match($pattern, $string)) {
            throw new UnexpectedValueException(
                sprintf('Unexpected verification status encountered: %s', $string)
            );
        }

        return $response;
    }
1262116
public function isWebsocketPushPayload($payload): bool
    {
        if (! is_array($payload)) {
            return false;
        }

        return $this->isServerWebsocket
            && ($payload['action'] ?? null) === Websocket::PUSH_ACTION
            && array_key_exists('data', $payload);
    }
1192359
public function getTokenExpire()
    {
        return $this->_state->token->obtained
            + $this->_state->token->data->expires_in - time();
    }
195861
public function add(Payload $payload)
    {
        // if there is no exp claim then add the jwt to
        // the blacklist indefinitely
        if (! $payload->hasKey('exp')) {
            return $this->addForever($payload);
        }

        // if we have already added this token to the blacklist
        if (! empty($this->storage->get($this->getKey($payload)))) {
            return true;
        }

        $this->storage->add(
            $this->getKey($payload),
            ['valid_until' => $this->getGraceTimestamp()],
            $this->getMinutesUntilExpired($payload)
        );

        return true;
    }
497758
public static function get($payload)
    {
        switch ($payload) {
            case 'OK':
            case 'QUEUED':
                if (isset(self::$$payload)) {
                    return self::$$payload;
                }

                return self::$$payload = new self($payload);

            default:
                return new self($payload);
        }
    }
1059688
public function triggerEvent($event, Payload $payload)
    {
        if ($payload->state() === null) {
            $this->updatePayload($this->process->initialState(), $payload);
        }

        $state = $this->process->state($payload->state());

        $nextStateName = $state->triggerEvent($event, $payload);
        if ($nextStateName === null) {
            return;
        }

        $state = $this->process->state($nextStateName);

        $this->updatePayload($state, $payload);
        $this->handleOnStateWasSet($state, $payload);
    }
1001120
def _calculate_session_expiry(self, request, user_info):
        """"""
        access_token_expiry_timestamp = self._get_access_token_expiry(request)
        id_token_expiry_timestamp = self._get_id_token_expiry(user_info)
        now_in_seconds = int(time.time())

        # The session length is set to match whichever token expiration time is closer.
        earliest_expiration_timestamp = min(access_token_expiry_timestamp, id_token_expiry_timestamp)
        seconds_until_expiry = earliest_expiration_timestamp - now_in_seconds

        if seconds_until_expiry <= 0:
            raise AuthError('Session expiry time has already passed!')

        return seconds_until_expiry
1152727
public function afterSaved($payload)
    {
        if (!request()->is('cms/revert/*') && !request()->is('cms/rollback/*/*')) {
            unset($payload->attributes['created_at']);
            unset($payload->attributes['updated_at']);
            unset($payload->original['created_at']);
            unset($payload->original['updated_at']);

            if ($payload->attributes != $payload->original) {
                Archive::create([
                    'token' => md5(time()),
                    'entity_id' => $payload->attributes['id'],
                    'entity_type' => get_class($payload),
                    'entity_data' => json_encode($payload->attributes),
                ]);
                Log::info(get_class($payload).' #'.$payload->attributes['id'].' was archived');
            }
        }
    }
124754
public function process($payload)
    {
        foreach ($this->stages as $stage) {
            $payload = call_user_func($stage, $payload);
        }
        return $payload;
    }
1271547
public function fill($payload)
    {
        $payload = $this->determineTypeAndMessage($payload);
        $payload = $this->fillBlanks($payload);
        return $payload;
    }
1113513
protected function validateTimestamps(array $payload)
    {
        if (isset($payload['nbf']) && Utils::timestamp($payload['nbf'])->isFuture()) {
            throw new TokenInvalidException('Not Before (nbf) timestamp cannot be in the future', 400);
        }

        if (isset($payload['iat']) && Utils::timestamp($payload['iat'])->isFuture()) {
            throw new TokenInvalidException('Issued At (iat) timestamp cannot be in the future', 400);
        }

        if (Utils::timestamp($payload['exp'])->isPast()) {
            throw new TokenExpiredException('Token has expired');
        }

        return true;
    }
1009524
public function encode(array $payload, array $header = [])
    {
        $header = ['typ' => 'JWT', 'alg' => $this->algo] + $header;

        $this->validateKid($header);

        if (!isset($payload['iat']) && !isset($payload['exp'])) {
            $payload['exp'] = ($this->timestamp ?: \time()) + $this->maxAge;
        }

        $header    = $this->urlSafeEncode($header);
        $payload   = $this->urlSafeEncode($payload);
        $signature = $this->urlSafeEncode($this->sign($header . '.' . $payload));

        return $header . '.' . $payload . '.' . $signature;
    }