-
Notifications
You must be signed in to change notification settings - Fork 3
/
Sample.cs
39 lines (32 loc) · 826 Bytes
/
Sample.cs
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
using System;
using System.Linq;
using System.Threading.Tasks;
using HidLibrary;
using log4net;
namespace u2fhost.console
{
public static class Sample
{
private static readonly ILog Log = LogManager.GetLogger(typeof (Sample));
public static async Task Run(int vendorId, int productId)
{
Log.Info("Insert U2F device");
IHidDevice hidDevice = null;
while (hidDevice == null)
{
using (hidDevice = HidDevices.Enumerate(vendorId, productId).FirstOrDefault())
{
if (hidDevice == null)
{
await Task.Delay(250);
continue;
}
var appId = "http://localhost";
var facet = "http://localhost";
var registration = await U2FHost.RegisterAsync(hidDevice, appId, facet);
await U2FHost.AuthenticateAsync(hidDevice, registration, appId, facet);
}
}
}
}
}