Skip to content

Commit ca73a14

Browse files
authored
Add availability APIs (#41)
This adds some centralized hints for platform availability, which should make addressing #30 easier and clearer. For now this is being kept internal, but it's intended to become public in short order.
1 parent 86c70d4 commit ca73a14

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

Sources/SnapAuth/Availability.swift

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/// Platform availability hints for passkeys and hardware authenticators
2+
struct SAAvailability {
3+
4+
/// Indicates whether passkey autofill requests are supported on the current
5+
/// platform/device.
6+
static var autofill: Bool {
7+
#if (os(iOS) || os(visionOS))
8+
if #available(iOS 16, visionOS 1, *) {
9+
return true
10+
}
11+
#endif
12+
return false
13+
}
14+
15+
/// Indicates whether external security keys are supported on the current
16+
/// platform/device.
17+
static var securityKeys: Bool {
18+
#if HARDWARE_KEY_SUPPORT
19+
return true
20+
#else
21+
return false
22+
#endif
23+
}
24+
25+
/// Indicates whether automatic passkey upgrades are supported on the
26+
/// current platform/device.
27+
static var passkeyUpgrades: Bool {
28+
#if (os(iOS) || os(macOS) || os(visionOS))
29+
if #available(iOS 18, macOS 15, visionOS 2, *) {
30+
return true
31+
}
32+
#endif
33+
return false
34+
}
35+
}

0 commit comments

Comments
 (0)