Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Make passkey authentication work on iOS (#520)

Leendert de Borst00023ea9445f
diff --git a/apps/mobile-app/ios/Autofill/CredentialProviderViewController.swift b/apps/mobile-app/ios/Autofill/CredentialProviderViewController.swift
index f6b54b402..09e2f9fcf 100644
--- a/apps/mobile-app/ios/Autofill/CredentialProviderViewController.swift
+++ b/apps/mobile-app/ios/Autofill/CredentialProviderViewController.swift
@@ -138,9 +138,8 @@ public class CredentialProviderViewController: ASCredentialProviderViewControlle
override public func provideCredentialWithoutUserInteraction(for credentialIdentity: ASPasswordCredentialIdentity) {
// QuickType bar suggestions are disabled on iOS <26, so this should only be called on iOS 26+
- if #available(iOS 26.0, *) {
- // iOS 26+ - proceed with background authentication
- } else {
+ if #unavailable(iOS 26.0) {
+ // iOS < 26 - we do not support quick autofill due to buggy behavior
print("provideCredentialWithoutUserInteraction called on iOS <26 (unexpected)")
self.extensionContext.cancelRequest(
withError: NSError(
diff --git a/apps/mobile-app/ios/VaultStoreKit/PasskeyAuthenticator.swift b/apps/mobile-app/ios/VaultStoreKit/PasskeyAuthenticator.swift
index f0bf8eff7..e47a3427a 100644
--- a/apps/mobile-app/ios/VaultStoreKit/PasskeyAuthenticator.swift
+++ b/apps/mobile-app/ios/VaultStoreKit/PasskeyAuthenticator.swift
@@ -249,8 +249,8 @@ public class PasskeyAuthenticator {
* Import private key from JWK format
*/
private static func importPrivateKeyFromJWK(jwkData: Data) throws -> P256.Signing.PrivateKey {
- guard let jwk = try JSONSerialization.jsonObject(with: jwkData) as? [String: String],
- let dBase64url = jwk["d"] else {
+ guard let jwk = try JSONSerialization.jsonObject(with: jwkData) as? [String: Any],
+ let dBase64url = jwk["d"] as? String else {
throw PasskeyError.invalidJWK
}
@@ -389,8 +389,9 @@ public class PasskeyAuthenticator {
throw PasskeyError.invalidSignature
}
- let rVal = rawSig[0..<32]
- let sVal = rawSig[32..<64]
+ // Convert SubSequence to Data to avoid indexing issues
+ let rVal = Data(rawSig[0..<32])
+ let sVal = Data(rawSig[32..<64])
let rDER = derInteger(rVal)
let sDER = derInteger(sVal)
@@ -408,16 +409,16 @@ public class PasskeyAuthenticator {
* Encode a positive big integer as DER INTEGER
*/
private static func derInteger(_ bytes: Data) -> Data {
- var trimmed = bytes
-
- // Trim leading zeros
- while trimmed.count > 1 && trimmed[0] == 0x00 {
- trimmed = trimmed.dropFirst()
+ // Trim leading zeros, but keep at least 1 byte
+ var startIndex = 0
+ while startIndex < bytes.count - 1 && bytes[startIndex] == 0x00 {
+ startIndex += 1
}
+ var trimmed = bytes.suffix(from: startIndex)
// If MSB is set, prepend 0x00 to keep it positive
var value = trimmed
- if (trimmed[0] & 0x80) != 0 {
+ if !trimmed.isEmpty && (trimmed[trimmed.startIndex] & 0x80) != 0 {
value = Data([0x00]) + trimmed
}
diff --git a/apps/mobile-app/ios/VaultStoreKit/VaultStore+Passkey.swift b/apps/mobile-app/ios/VaultStoreKit/VaultStore+Passkey.swift
index 496f75826..2a58119f4 100644
--- a/apps/mobile-app/ios/VaultStoreKit/VaultStore+Passkey.swift
+++ b/apps/mobile-app/ios/VaultStoreKit/VaultStore+Passkey.swift
@@ -37,9 +37,14 @@ extension VaultStore {
print("VaultStore+Passkey: Looking up passkey by credentialId: \(credentialId.base64EncodedString().prefix(20))...")
- let credentialIdBlob = Blob(bytes: [UInt8](credentialId))
+ // The Passkeys.Id column is a string UUID (not a blob), so we need to convert the credentialId bytes to a UUID string.
+ // Use PasskeyHelper to convert the credentialId (Data) to a UUID string for lookup.
+ guard let credentialIdString = try? PasskeyHelper.bytesToGuid(credentialId) else {
+ print("VaultStore+Passkey: Failed to convert credentialId bytes to UUID string")
+ return nil
+ }
let query = Self.passkeysTable
- .filter(Self.colAdditionalData == credentialIdBlob)
+ .filter(Self.colId == credentialIdString)
.filter(Self.colIsDeleted == 0)
.limit(1)