Skip to content
This repository was archived by the owner on Dec 15, 2020. It is now read-only.

Commit 1157c1b

Browse files
authored
Merge pull request #36 from github/check-laptop-open
Don't try using SEP keys if laptop is closed
2 parents 256ef14 + 1ef7298 commit 1157c1b

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

SoftU2FTool/U2FAuthenticator.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ class U2FAuthenticator {
3232
return ua.stop()
3333
}
3434

35+
private var laptopIsOpen: Bool {
36+
guard let screens = NSScreen.screens() else { return true }
37+
38+
return screens.contains { screen in
39+
guard let screenID = screen.deviceDescription["NSScreenNumber"] as? uint32 else { return true }
40+
return CGDisplayIsBuiltin(screenID) == 1
41+
}
42+
}
43+
3544
init?() {
3645
guard let uh: U2FHID = U2FHID.shared else { return nil }
3746

@@ -144,6 +153,12 @@ class U2FAuthenticator {
144153
return
145154
}
146155

156+
if reg.inSEP && !laptopIsOpen {
157+
// Can't use SEP/TouchID if laptop is closed.
158+
sendError(status: .OtherError, cid: cid)
159+
return
160+
}
161+
147162
let facet = KnownFacets[req.applicationParameter]
148163
let notification = UserPresence.Notification.Authenticate(facet: facet)
149164
let skipTUP = reg.inSEP

0 commit comments

Comments
 (0)