Debian Codegraph @

lib/3rdParty/composer/web-auth/webauthn-lib/src/MetadataService/Statement/StatusReport.php

raw symbols SCIP
1 <?php
2
3 declare(strict_types=1);
4
5 namespace Webauthn\MetadataService\Statement;
6
7 use function in_array;
8 use Webauthn\Exception\MetadataStatementLoadingException;
9
10 readonly class StatusReport
11 {
12 /**
13 * @see AuthenticatorStatus
14 */
15 public function __construct(
16 public string $status,
17 public ?string $effectiveDate,
18 public ?string $certificate,
19 public ?string $url,
20 public ?string $certificationDescriptor,
21 public ?string $certificateNumber,
22 public ?string $certificationPolicyVersion,
23 public ?string $certificationRequirementsVersion
24 ) {
25 in_array($status, AuthenticatorStatus::STATUSES, true) || throw MetadataStatementLoadingException::create(
26 'The value of the key "status" is not acceptable'
27 );
28 }
29
30 public static function create(
31 string $status,
32 ?string $effectiveDate,
33 ?string $certificate,
34 ?string $url,
35 ?string $certificationDescriptor,
36 ?string $certificateNumber,
37 ?string $certificationPolicyVersion,
38 ?string $certificationRequirementsVersion
39 ): self {
40 return new self(
41 $status,
42 $effectiveDate,
43 $certificate,
44 $url,
45 $certificationDescriptor,
46 $certificateNumber,
47 $certificationPolicyVersion,
48 $certificationRequirementsVersion
49 );
50 }
51
52 public function isCompromised(): bool
53 {
54 return in_array($this->status, [
55 AuthenticatorStatus::ATTESTATION_KEY_COMPROMISE,
56 AuthenticatorStatus::USER_KEY_PHYSICAL_COMPROMISE,
57 AuthenticatorStatus::USER_KEY_REMOTE_COMPROMISE,
58 AuthenticatorStatus::USER_VERIFICATION_BYPASS,
59 ], true);
60 }
61 }