Debian Codegraph @

lib/3rdParty/composer/web-auth/webauthn-lib/src/Event/BackupEligibilityChangedEvent.php

raw symbols SCIP
1 <?php
2
3 declare(strict_types=1);
4
5 namespace Webauthn\Event;
6
7 use LogicException;
8 use function sprintf;
9 use Webauthn\CredentialRecord;
10 use Webauthn\PublicKeyCredentialSource;
11
12 /**
13 * Event dispatched when the backup eligibility flag (BE) changes.
14 *
15 * The BE flag indicates whether the authenticator is capable of backing up
16 * the credential. A change in this flag may indicate device capabilities have changed.
17 */
18 final readonly class BackupEligibilityChangedEvent implements WebauthnEvent
19 {
20 public function __construct(
21 public CredentialRecord $credentialRecord,
22 public ?bool $previousValue,
23 public ?bool $newValue
24 ) {
25 }
26
27 /**
28 * @deprecated since 5.3, use credentialRecord instead. Will be removed in 6.0.
29 */
30 public function __get(string $name): mixed
31 {
32 if ($name === 'publicKeyCredentialSource') {
33 return $this->getPublicKeyCredentialSource();
34 }
35
36 throw new LogicException(sprintf('Undefined property: %s::$%s', self::class, $name));
37 }
38
39 /**
40 * @deprecated since 5.3, use credentialRecord instead. Will be removed in 6.0.
41 */
42 public function getPublicKeyCredentialSource(): PublicKeyCredentialSource
43 {
44 if ($this->credentialRecord instanceof PublicKeyCredentialSource) {
45 return $this->credentialRecord;
46 }
47
48 return new PublicKeyCredentialSource(
49 $this->credentialRecord->publicKeyCredentialId,
50 $this->credentialRecord->type,
51 $this->credentialRecord->transports,
52 $this->credentialRecord->attestationType,
53 $this->credentialRecord->trustPath,
54 $this->credentialRecord->aaguid,
55 $this->credentialRecord->credentialPublicKey,
56 $this->credentialRecord->userHandle,
57 $this->credentialRecord->counter,
58 $this->credentialRecord->otherUI,
59 $this->credentialRecord->backupEligible,
60 $this->credentialRecord->backupStatus,
61 $this->credentialRecord->uvInitialized,
62 );
63 }
64 }