Making WordPress.org

Changeset 14331


Ignore:
Timestamp:
01/03/2025 01:58:57 PM (15 months ago)
Author:
aidvu
Message:

api: upgrade adhocore-php-jwt from github

https://github.com/adhocore/php-jwt/tree/main/src

Location:
sites/trunk/api.wordpress.org/public_html/dotorg/trac/pr/adhocore-php-jwt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/api.wordpress.org/public_html/dotorg/trac/pr/adhocore-php-jwt/JWT.php

    r9564 r14331  
    144144     *
    145145     * @param string $token
     146     * @param bool   $verify
    146147     *
    147148     * @throws JWTException
     
    149150     * @return array
    150151     */
    151     public function decode(string $token): array
     152    public function decode(string $token, bool $verify = true): array
    152153    {
    153154        if (\substr_count($token, '.') < 2) {
     
    156157
    157158        $token = \explode('.', $token, 3);
     159        if (!$verify) {
     160            return (array) $this->urlSafeDecode($token[1]);
     161        }
     162
    158163        $this->validateHeader((array) $this->urlSafeDecode($token[0]));
    159164
  • sites/trunk/api.wordpress.org/public_html/dotorg/trac/pr/adhocore-php-jwt/ValidatesJWT.php

    r14329 r14331  
    8787            ['exp', $this->leeway /*          */ , static::ERROR_TOKEN_EXPIRED, 'Expired'],
    8888            ['iat', $this->maxAge - $this->leeway, static::ERROR_TOKEN_EXPIRED, 'Expired'],
    89             ['nbf', $this->maxAge - $this->leeway, static::ERROR_TOKEN_NOT_NOW, 'Not now'],
     89            ['nbf', -$this->leeway, static::ERROR_TOKEN_NOT_NOW, 'Not now'],
    9090        ];
    9191
     
    115115        }
    116116
    117         if ($this->key===false) {
     117        if (\PHP_VERSION_ID < 80000 && !\is_resource($this->key)) {
     118            throw new JWTException('Invalid key: Should be resource of private key', static::ERROR_KEY_INVALID);
     119        }
     120
     121        if (\PHP_VERSION_ID > 80000 && !(
     122            $this->key instanceof \OpenSSLAsymmetricKey
     123            || $this->key instanceof \OpenSSLCertificate
     124            || $this->key instanceof \OpenSSLCertificateSigningRequest
     125        )) {
    118126            throw new JWTException('Invalid key: Should be resource of private key', static::ERROR_KEY_INVALID);
    119127        }
Note: See TracChangeset for help on using the changeset viewer.