Please note that when the Compact Serialization mode is used, the characters of the payload must be limited to the following ASCII ranges:
This feature is built in the framework and is enabled when the
b64header parameter is set to
false. As per the RFC, this header MUST be protected and also listed as a critical (
crit) header parameter.
$jws = $jwsBuilder
->addSignature($jwk, ['alg' => 'HS256', 'b64' => false, 'crit' => ['b64']])
As a remainder, both
critparameters MUST be in the protected header.