Debian Codegraph @

lib/3rdParty/composer/web-auth/webauthn-lib/src/Event/BackupStatusChangedEvent.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 status flag (BS) changes.
14 *
15 * The BS flag indicates whether the credential is currently backed up.
16 * A change in this flag, especially from true to false, may indicate
17 * that the user should add an additional authenticator for redundancy.
18 */
19 final readonly class BackupStatusChangedEvent implements WebauthnEvent
20 {
21 public function __construct(
22 public CredentialRecord $credentialRecord,
23 public ?bool $previousValue,
24 public ?bool $newValue
25 ) {
26 }
27
28 /**
29 * @deprecated since 5.3, use credentialRecord instead. Will be removed in 6.0.
30 */
31 public function __get(string $name): mixed
32 {
33 if ($name === 'publicKeyCredentialSource') {
34 return $this->getPublicKeyCredentialSource();
35 }
36
37 throw new LogicException(sprintf('Undefined property: %s::$%s', self::class, $name));
38 }
39
40 /**
41 * @deprecated since 5.3, use credentialRecord instead. Will be removed in 6.0.
42 */
43 public function getPublicKeyCredentialSource(): PublicKeyCredentialSource
44 {
45 if ($this->credentialRecord instanceof PublicKeyCredentialSource) {
46 return $this->credentialRecord;
47 }
48
49 return new PublicKeyCredentialSource(
50 $this->credentialRecord->publicKeyCredentialId,
51 $this->credentialRecord->type,
52 $this->credentialRecord->transports,
53 $this->credentialRecord->attestationType,
54 $this->credentialRecord->trustPath,
55 $this->credentialRecord->aaguid,
56 $this->credentialRecord->credentialPublicKey,
57 $this->credentialRecord->userHandle,
58 $this->credentialRecord->counter,
59 $this->credentialRecord->otherUI,
60 $this->credentialRecord->backupEligible,
61 $this->credentialRecord->backupStatus,
62 $this->credentialRecord->uvInitialized,
63 );
64 }
65 }