Class PasskeyCeremonyPrefetch<TCeremony>
Begins a passkey ceremony on the service ahead of the person's action that shows its prompt, such as a tap on a button, so that the prompt can follow the action right away: browsers such as Safari only allow a WebAuthn operation shortly after a user action, and a request to the service in between can take longer than that. A begun ceremony is kept for another try until its credential is sent to the service, which ends it, and one that is about to expire is begun again. A credential whose sending failed for a reason that may not last is sent again on the next try instead of asking for another passkey, unless it is discarded (see DiscardUnsentCredential()).
Namespace: Singulink.Net.Http.Api.Client.Passkeys
Assembly: Singulink.Net.Http.Api.Client.dll
Syntax
public sealed class PasskeyCeremonyPrefetch<TCeremony>
Type Parameters
| Name | Description |
|---|---|
| TCeremony | The type of a begun ceremony: PasskeyCeremony, or a type of the app's own that holds one with what the app needs to finish it, such as the Pkce pair that a sign-in is bound to. |
Remarks
A ceremony expires on the service at the end of its Lifetime, which the service counts from before it sent the ceremony, and the credential has to reach the service before then. A ceremony is begun again once it is in the last fifth of its lifetime, counted from when it was received.
Its members are not thread safe: a UI runs one try at a time.
Constructors
| Name | Description |
|---|---|
| PasskeyCeremonyPrefetch(Func<CancellationToken, Task<TCeremony>>, Func<TCeremony, PasskeyCeremony>, TimeProvider?) | Initializes a new instance of the PasskeyCeremonyPrefetch<TCeremony> class. |
Properties
| Name | Description |
|---|---|
| ResentCredential | Gets a value indicating whether the last try (see RunAsync<TResult>(Func<string, CancellationToken, Task<PasskeyCredential>>, Func<TCeremony, PasskeyCredential, CancellationToken, Task<TResult>>, CancellationToken)) sent the credential of the try before it again, instead of showing the prompt. The service may have received that credential although its answer was lost, in which case it ended the ceremony, and the credential that was sent again fails as expired (CeremonyExpired). |
Methods
| Name | Description |
|---|---|
| DiscardUnsentCredential() | Discards the credential of the last try if sending it failed (see RunAsync<TResult>(Func<string, CancellationToken, Task<PasskeyCredential>>, Func<TCeremony, PasskeyCredential, CancellationToken, Task<TResult>>, CancellationToken)), so that the next try shows the passkey prompt again. |
| Prefetch() | Begins a ceremony in the background, unless one that can still be used was begun or is being begun. A failure isn't reported: the next try begins the ceremony again, and reports its failure. |
| RunAsync(Func<string, CancellationToken, Task<PasskeyCredential>>, Func<TCeremony, PasskeyCredential, CancellationToken, Task>, CancellationToken) | Shows the passkey prompt for the begun ceremony and sends the credential to the service. Begins the ceremony now if none was begun, it failed to begin or it is about to expire. Sends the credential of the last try again instead, without showing the prompt, if sending it failed for a reason that may not last (see IsTransient(Exception)) or was cancelled, and its ceremony is not about to expire. |
| RunAsync<TResult>(Func<string, CancellationToken, Task<PasskeyCredential>>, Func<TCeremony, PasskeyCredential, CancellationToken, Task<TResult>>, CancellationToken) | Shows the passkey prompt for the begun ceremony and sends the credential to the service. Begins the ceremony now if none was begun, it failed to begin or it is about to expire. Sends the credential of the last try again instead, without showing the prompt, if sending it failed for a reason that may not last (see IsTransient(Exception)) or was cancelled, and its ceremony is not about to expire. |