| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace Webauthn; |
| 6 |
|
| 7 |
use Symfony\Component\Uid\Uuid; |
| 8 |
use Webauthn\TrustPath\TrustPath; |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
class CredentialRecord |
| 17 |
{ |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
public function __construct( |
| 23 |
public string $publicKeyCredentialId, |
| 24 |
public string $type, |
| 25 |
public array $transports, |
| 26 |
public string $attestationType, |
| 27 |
public TrustPath $trustPath, |
| 28 |
public Uuid $aaguid, |
| 29 |
public string $credentialPublicKey, |
| 30 |
public string $userHandle, |
| 31 |
public int $counter, |
| 32 |
public ?array $otherUI = null, |
| 33 |
public ?bool $backupEligible = null, |
| 34 |
public ?bool $backupStatus = null, |
| 35 |
public ?bool $uvInitialized = null, |
| 36 |
) { |
| 37 |
} |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
public static function create( |
| 44 |
string $publicKeyCredentialId, |
| 45 |
string $type, |
| 46 |
array $transports, |
| 47 |
string $attestationType, |
| 48 |
TrustPath $trustPath, |
| 49 |
Uuid $aaguid, |
| 50 |
string $credentialPublicKey, |
| 51 |
string $userHandle, |
| 52 |
int $counter, |
| 53 |
?array $otherUI = null, |
| 54 |
?bool $backupEligible = null, |
| 55 |
?bool $backupStatus = null, |
| 56 |
?bool $uvInitialized = null, |
| 57 |
): self { |
| 58 |
return new self( |
| 59 |
$publicKeyCredentialId, |
| 60 |
$type, |
| 61 |
$transports, |
| 62 |
$attestationType, |
| 63 |
$trustPath, |
| 64 |
$aaguid, |
| 65 |
$credentialPublicKey, |
| 66 |
$userHandle, |
| 67 |
$counter, |
| 68 |
$otherUI, |
| 69 |
$backupEligible, |
| 70 |
$backupStatus, |
| 71 |
$uvInitialized |
| 72 |
); |
| 73 |
} |
| 74 |
|
| 75 |
public function getPublicKeyCredentialDescriptor(): PublicKeyCredentialDescriptor |
| 76 |
{ |
| 77 |
return PublicKeyCredentialDescriptor::create($this->type, $this->publicKeyCredentialId, $this->transports); |
| 78 |
} |
| 79 |
|
| 80 |
public function getAttestedCredentialData(): AttestedCredentialData |
| 81 |
{ |
| 82 |
return AttestedCredentialData::create($this->aaguid, $this->publicKeyCredentialId, $this->credentialPublicKey); |
| 83 |
} |
| 84 |
} |