File tree 1 file changed +34
-5
lines changed
1 file changed +34
-5
lines changed Original file line number Diff line number Diff line change @@ -2,23 +2,52 @@ package plugin
2
2
3
3
import (
4
4
"errors"
5
- "github.com/keys-pub/go-libfido2 "
5
+ "slices "
6
6
"time"
7
+
8
+ "github.com/keys-pub/go-libfido2"
7
9
)
8
10
9
11
func FindDevice () (* libfido2.Device , error ) {
10
12
locs , err := libfido2 .DeviceLocations ()
11
-
12
13
if err != nil {
13
14
return nil , err
14
15
}
15
16
16
- if len (locs ) > 1 {
17
+ devs := []* libfido2.Device {}
18
+ for _ , loc := range locs {
19
+ dev , err := libfido2 .NewDevice (loc .Path )
20
+ if err != nil {
21
+ return nil , err
22
+ }
23
+
24
+ isFido , err := dev .IsFIDO2 ()
25
+ if err != nil {
26
+ return nil , err
27
+ }
28
+
29
+ if ! isFido {
30
+ continue
31
+ }
32
+
33
+ info , err := dev .Info ()
34
+ if err != nil {
35
+ return nil , err
36
+ }
37
+
38
+ if ! slices .Contains (info .Extensions , string (libfido2 .HMACSecretExtension )) {
39
+ continue
40
+ }
41
+
42
+ devs = append (devs , dev )
43
+ }
44
+
45
+ if len (devs ) > 1 {
17
46
return nil , errors .New ("Too many devices" )
18
47
}
19
48
20
- if len (locs ) == 1 {
21
- return libfido2 . NewDevice ( locs [0 ]. Path )
49
+ if len (devs ) == 1 {
50
+ return devs [0 ], nil
22
51
}
23
52
24
53
return nil , nil
You can’t perform that action at this time.
0 commit comments