1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | /* |
||
6 | * The MIT License (MIT) |
||
7 | * |
||
8 | * Copyright (c) 2018 Spomky-Labs |
||
9 | * |
||
10 | * This software may be modified and distributed under the terms |
||
11 | * of the MIT license. See the LICENSE file for details. |
||
12 | */ |
||
13 | |||
14 | namespace U2FAuthentication\Fido2; |
||
15 | |||
16 | use Base64Url\Base64Url; |
||
17 | use CBOR\Decoder; |
||
18 | |||
19 | class AttestationObjectParser |
||
20 | { |
||
21 | /** |
||
22 | * @var Decoder |
||
23 | */ |
||
24 | private $decoder; |
||
25 | |||
26 | /** |
||
27 | * AttestationObjectParser constructor. |
||
28 | * |
||
29 | * @param Decoder $decoder |
||
30 | */ |
||
31 | public function __construct(Decoder $decoder) |
||
32 | { |
||
33 | $this->decoder = $decoder; |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * @param string $attestationObject |
||
38 | * |
||
39 | * @return array |
||
40 | */ |
||
41 | public function parse(string $attestationObject): array |
||
42 | { |
||
43 | $decodedAttestationObject = Base64Url::decode($attestationObject); |
||
44 | $stream = new StringStream($decodedAttestationObject); |
||
45 | $data = $this->decoder->decode($stream); |
||
46 | |||
47 | return $data->getNormalizedData(); |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
48 | } |
||
49 | } |
||
50 |