// WHETHER THIS PHONE AND THIS APP CAN DO A COTTON ACCOUNT PASSKEY (lane// passkeys-ios, 19 Nov 2026). The sheet takes a passkey for the sign-in host// only when the app is signed with `webcredentials:<host>` and the phone has a// passcode; otherwise it fails after the tap, so the sign-in screen and// Account's passkeys card offer a passkey only when both hold.//// The app cannot read its own entitlements on iOS, so the spec gate stamps// the host it signed the app for into Info.plist (`CottonPasskeyHost`, the// same `$(COTTON_SIGNIN_HOST)` the entitlement says; `scripts/ios-spec-gate.ts`).// A parked or planned app carries neither, and offers no passkey.importFoundation#if canImport(LocalAuthentication)importLocalAuthentication#endifpublicenumPasskeyPlatform {/// The Info.plist key the spec gate stamps with the passkey host.publicstaticlet hostKey = "CottonPasskeyHost"/// A passkey is offered when the app is signed for exactly the host it/// signs in at (`server`, an https URL) and the phone has a passcode.publicstaticfunc offers(stampedHost: String?, server: String, passcodeSet: Bool) -> Bool {guard passcodeSet else { returnfalse }guardlet stamped = stampedHost?.trimmingCharacters(in: .whitespaces).lowercased(), !stamped.isEmpty, !stamped.contains("$(")else { returnfalse }guardlet url = URL(string: server), url.scheme == "https", let host = url.host?.lowercased() else { returnfalse }return host == stamped }/// `offers` for this app, this phone, and the server it signs in at.publicstaticfunc offersHere(server: String) -> Bool { offers(stampedHost: Bundle.main.object(forInfoDictionaryKey: hostKey) as? String, server: server, passcodeSet: passcodeSet()) }/// Whether the phone has a passcode (or Face ID, which needs one): a/// platform passkey asks for one, and a phone without cannot keep one.staticfunc passcodeSet() -> Bool { #if canImport(LocalAuthentication)return LAContext().canEvaluatePolicy(.deviceOwnerAuthentication, error: nil) #elsereturnfalse #endif }}