Conditions | 4 |
Paths | 3 |
Total Lines | 17 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
26 | public static function decode(string $jwt, string $serverKey): Payload |
||
27 | { |
||
28 | try { |
||
29 | $payload = JWT::decode( |
||
30 | $jwt, // jwt The JWT |
||
31 | $serverKey, // key The key, or map of keys. |
||
32 | [self::ALGORITHM_HS256], // allowed_algs List of supported verification algorithms |
||
33 | ); |
||
34 | } catch (\Throwable $e) { |
||
35 | throw new JwtException($e->getMessage(), $e); |
||
36 | } |
||
37 | |||
38 | if (!\property_exists($payload, 'sub') || !\property_exists($payload, 'clientKey')) { |
||
39 | throw new JwtException('Token is missing required data.'); |
||
40 | } |
||
41 | |||
42 | return new Payload($payload->sub, $payload->clientKey); |
||
43 | } |
||
45 |