src/PbjxTokenSigner.php
public function validate(string $content, string $aud, string $token): void
    {
        $actualToken = PbjxToken::fromString($token);
        $expectedToken = PbjxToken::create(
            $content,
            $aud,
            $actualToken->getKid(),
            $this->getSecret($actualToken->getKid()),
            [
                'exp' => $actualToken->getExp(),
                'iat' => $actualToken->getIat(),
            ]
        );

        if (!$actualToken->equals($expectedToken)) {
            throw new \InvalidArgumentException('PbjxTokens do not match.', Code::INVALID_ARGUMENT);
        }
    }
public function validate(string $content, string $aud, string $token): void
    {
        $actualToken = PbjxToken::fromString($token);
        $expectedToken = PbjxToken::create(
            $content,
            $aud,
            $actualToken->getKid(),
            $this->getSecret($actualToken->getKid()),
            [
                'exp' => $actualToken->getExp(),
                'iat' => $actualToken->getIat(),
            ]
        );

        if (!$actualToken->equals($expectedToken)) {
            throw new \InvalidArgumentException('PbjxTokens do not match.', Code::INVALID_ARGUMENT);
        }
    }
public function validate ( string $ content , string $ aud , string $ token ) : void { $ actualToken = PbjxToken :: fromString ( $ token ) ; $ expectedToken = PbjxToken :: create ( $ content , $ aud , $ actualToken -> getKid ( ) , $ this -> getSecret ( $ actualToken -> getKid ( ) ) , [ 'exp' => $ actualToken -> getExp ( ) , 'iat' => $ actualToken -> getIat ( ) , ] ) ; if ( ! $ actualToken -> equals ( $ expectedToken ) ) { throw new \ InvalidArgumentException ( 'PbjxTokens do not match.' , Code :: INVALID_ARGUMENT ) ; } }
Validates that the provided token is valid and okay to use
and also creates a new token with the same secret and content
and compares our result to the provided token to determine
if they are an exact match.

If no exception is thrown the token is valid.

@param string $content Pbjx content that has been signed
@param string $aud     Pbjx endpoint this token was sent to
@param string $token   The token string (typically from header x-pbjx-token)

@throws \Throwable
Validates that the provided token is valid and okay to use and also creates a new token with the same secret and content and compares our result to the provided token to determine if they are an exact match .