Debian Codegraph @

lib/3rdParty/composer/web-token/jwt-library/Signature/JWSTokenSupport.php

raw symbols SCIP
1 <?php
2
3 declare(strict_types=1);
4
5 namespace Jose\Component\Signature;
6
7 use InvalidArgumentException;
8 use Jose\Component\Checker\TokenTypeSupport;
9 use Jose\Component\Core\JWT;
10
11 final class JWSTokenSupport implements TokenTypeSupport
12 {
13 public function supports(JWT $jwt): bool
14 {
15 return $jwt instanceof JWS;
16 }
17
18 /**
19 * @param array<string, mixed> $protectedHeader
20 * @param array<string, mixed> $unprotectedHeader
21 */
22 public function retrieveTokenHeaders(JWT $jwt, int $index, array &$protectedHeader, array &$unprotectedHeader): void
23 {
24 if (! $jwt instanceof JWS) {
25 return;
26 }
27
28 if ($index > $jwt->countSignatures()) {
29 throw new InvalidArgumentException('Unknown signature index.');
30 }
31 $protectedHeader = $jwt->getSignature($index)
32 ->getProtectedHeader();
33 $unprotectedHeader = $jwt->getSignature($index)
34 ->getHeader();
35 }
36 }