public function toCompactJSON($id)
{
$signature = $this->getSignature($id);
Assertion::true(empty($signature->getHeaders()), 'The signature contains unprotected headers and cannot be converted into compact JSON');
Assertion::true($this->isPayloadEncoded($signature) || empty($this->getEncodedPayload($signature)), 'Unable to convert the JWS with non-encoded payload.');
return sprintf('%s.%s.%s', $signature->getEncodedProtectedHeaders(), $this->getEncodedPayload($signature), Base64Url::encode($signature->getSignature()));
}