$header: Optional associative map of additional header fields (e.g., ["kid" => "key-1"]). Defaults to ["alg" => "HS256", "typ" => "JWT"].
Returns: Compact JWT string.
jwt_decode(string $token, string $secret, int $leeway = 0, int $now = -1)
Verifies a JWT's format, header algorithm (HS256), HMAC-SHA256 signature (in constant time), and nbf / exp claims, then returns the decoded payload map.
$token: Compact JWT string.
$secret: Non-empty HMAC-SHA256 secret key.
$leeway: Optional clock-skew tolerance in seconds (must be >= 0, default 0).
$now: Optional Unix timestamp override for testing (default -1, which uses time()).
Returns: Decoded payload map.
jwt_verify(string $token, string $secret, int $leeway = 0, int $now = -1): bool
Returns true if jwt_decode(...) succeeds, or false if any validation or signature check fails.
jwt_decode_unverified(string $token)
Decodes the header and payload of a JWT without verifying its signature or time claims.
Returns: Map with "header" and "payload" keys.
Base64URL & Crypto Helpers
jwt_base64url_encode(string $data): string — URL-safe Base64 encoding without = padding.
jwt_base64url_decode(string $data): string — Strict URL-safe Base64 decoding (throws on invalid characters or length).
jwt_sha256_raw(string $data): string — Pure-HolyPHP SHA-256 returning 32 raw bytes.