| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace Webauthn; |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
class PublicKeyCredential extends Credential |
| 11 |
{ |
| 12 |
public function __construct( |
| 13 |
string $type, |
| 14 |
string $rawId, |
| 15 |
public readonly AuthenticatorResponse $response |
| 16 |
) { |
| 17 |
parent::__construct($type, $rawId); |
| 18 |
} |
| 19 |
|
| 20 |
public static function create(string $type, string $rawId, AuthenticatorResponse $response): self |
| 21 |
{ |
| 22 |
return new self($type, $rawId, $response); |
| 23 |
} |
| 24 |
|
| 25 |
public function getPublicKeyCredentialDescriptor(): PublicKeyCredentialDescriptor |
| 26 |
{ |
| 27 |
$transport = $this->response instanceof AuthenticatorAttestationResponse ? $this->response->transports : []; |
| 28 |
|
| 29 |
return PublicKeyCredentialDescriptor::create($this->type, $this->rawId, $transport); |
| 30 |
} |
| 31 |
} |