1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
<?php
declare(strict_types=1);
namespace PhpMyAdmin\WebAuthn;
use Psr\Http\Message\ServerRequestInterface;
/**
* Web Authentication API server.
*
* @see https://www.w3.org/TR/webauthn-3/
* @see https://developer.mozilla.org/en-US/docs/Web/API/Web_Authentication_API
* @see https://webauthn.guide/
*/
interface Server
{
/**
* @psalm-return array{
* challenge: non-empty-string,
* rp: array{name: string, id: string},
* user: array{id: string, name: string, displayName: string},
* pubKeyCredParams: list<array{alg: int, type: 'public-key'}>,
* authenticatorSelection: array<string, string>,
* timeout: positive-int,
* attestation: non-empty-string
* }
*
* @throws WebAuthnException
*/
public function getCredentialCreationOptions(string $userName, string $userId, string $relyingPartyId): array;
/**
* @psalm-param list<array{id: non-empty-string, type: non-empty-string}> $allowedCredentials
*
* @return array<string, array<int, array<string, string>>|int|string>
*
* @throws WebAuthnException
*/
public function getCredentialRequestOptions(
string $userName,
string $userId,
string $relyingPartyId,
array $allowedCredentials
): array;
/**
* @see https://www.w3.org/TR/webauthn-3/#sctn-verifying-assertion
*
* @psalm-param non-empty-string $assertionResponseJson
* @psalm-param list<array{id: non-empty-string, type: non-empty-string}> $allowedCredentials
* @psalm-param non-empty-string $challenge
*
* @throws WebAuthnException
*/
public function parseAndValidateAssertionResponse(
string $assertionResponseJson,
array $allowedCredentials,
string $challenge,
ServerRequestInterface $request
): void;
/**
* @see https://www.w3.org/TR/webauthn-3/#sctn-registering-a-new-credential
*
* @psalm-param non-empty-string $attestationResponse
* @psalm-param non-empty-string $credentialCreationOptions
*
* @return mixed[]
*
* @throws WebAuthnException
*/
public function parseAndValidateAttestationResponse(
string $attestationResponse,
string $credentialCreationOptions,
ServerRequestInterface $request
): array;
}
|