public static async Task <FidoHidDevice> OpenAsync(HidDevice hidDevice) { var device = new FidoHidDevice(hidDevice); try { await device.InitAsync().ConfigureAwait(false); } catch (FidoException fe) when(fe.Type == FidoError.TokenBusy || fe.Type == FidoError.InterruptedIO || fe.Type == FidoError.Timeout) { return(null); } return(device); }
/// <summary> /// Waits until at least one FIDO token is present, returns one of the available /// </summary> public static async Task <FidoUsbToken> WaitForFirstToken(CancellationToken cancellationToken) => new FidoUsbToken(await FidoHidDevice.WaitForFidoHidDevice(cancellationToken).ConfigureAwait(false));
/// <summary> /// Waits until at least one FIDO token is present, returns a list of all available tokens /// </summary> public static async Task <IList <FidoUsbToken> > WaitForTokens(CancellationToken cancellationToken) => (await FidoHidDevice.WaitForFidoHidDevices(cancellationToken).ConfigureAwait(false)) .Select(h => new FidoUsbToken(h)) .ToList();
private FidoUsbToken(FidoHidDevice fidoHidTransport) : base(fidoHidTransport) { }