Skip to content

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

Implement swift passkey create logic and unittest (#520)

Leendert de Borstfa4c80858c2a
diff --git a/apps/mobile-app/ios/AliasVault.xcodeproj/project.pbxproj b/apps/mobile-app/ios/AliasVault.xcodeproj/project.pbxproj
index d220e2ca8..3ec5169cf 100644
--- a/apps/mobile-app/ios/AliasVault.xcodeproj/project.pbxproj
+++ b/apps/mobile-app/ios/AliasVault.xcodeproj/project.pbxproj
@@ -670,6 +670,7 @@
ru,
uk,
he,
+ pt,
);
mainGroup = 83CBB9F61A601CBA00E9B192;
productRefGroup = 83CBBA001A601CBA00E9B192 /* Products */;
diff --git a/apps/mobile-app/ios/Autofill/CredentialProviderViewController+Passkey.swift b/apps/mobile-app/ios/Autofill/CredentialProviderViewController+Passkey.swift
index 8b407d23c..93acd000d 100644
--- a/apps/mobile-app/ios/Autofill/CredentialProviderViewController+Passkey.swift
+++ b/apps/mobile-app/ios/Autofill/CredentialProviderViewController+Passkey.swift
@@ -137,58 +137,44 @@ extension CredentialProviderViewController: PasskeyProviderDelegate {
return
}
- // Generate a unique request ID
- let requestId = UUID().uuidString
-
// Extract registration request data
let credentialIdentity = passkeyRequest.credentialIdentity as? ASPasskeyCredentialIdentity
let rpId = credentialIdentity?.relyingPartyIdentifier ?? ""
let userId = credentialIdentity?.userHandle
let userName = credentialIdentity?.userName
+ let userDisplayName = credentialIdentity?.userName // Use userName as displayName for now
let clientDataHash = passkeyRequest.clientDataHash
- // Build request data dictionary
- var requestData: [String: Any] = [
- "requestId": requestId,
- "origin": "https://\(rpId)",
- "rpId": rpId,
- "challenge": clientDataHash.base64EncodedString(),
- "enablePrf": false // TODO: Extract from extensions if available
- ]
-
- if let userId = userId {
- requestData["userId"] = userId.base64EncodedString()
- }
+ // Initialize vault store
+ let vaultStore = VaultStore()
- if let userName = userName {
- requestData["userName"] = userName
+ // Check vault state
+ guard sanityChecks(vaultStore: vaultStore) else {
+ return
}
+ // Unlock vault
do {
- // Convert to JSON string
- let jsonData = try JSONSerialization.data(withJSONObject: requestData)
- let jsonString = String(data: jsonData, encoding: .utf8) ?? ""
-
- // Store request in shared storage
- let vaultStore = VaultStore()
- try vaultStore.storePasskeyRegistrationRequest(requestId: requestId, requestData: jsonString)
-
- // Show passkey registration UI
- showPasskeyRegistrationView(
- requestId: requestId,
- rpId: rpId,
- userName: userName,
- vaultStore: vaultStore
- )
-
+ try vaultStore.unlockVault()
} catch {
- print("PasskeyRegistration error: \(error)")
+ print("PasskeyRegistration: Failed to unlock vault: \(error)")
extensionContext.cancelRequest(withError: NSError(
domain: ASExtensionErrorDomain,
code: ASExtensionError.failed.rawValue,
- userInfo: [NSLocalizedDescriptionKey: error.localizedDescription]
+ userInfo: [NSLocalizedDescriptionKey: "Failed to unlock vault"]
))
+ return
}
+
+ // Show passkey registration UI
+ showPasskeyRegistrationView(
+ rpId: rpId,
+ userName: userName,
+ userDisplayName: userDisplayName,
+ userId: userId,
+ clientDataHash: clientDataHash,
+ vaultStore: vaultStore
+ )
}
@@ -196,37 +182,38 @@ extension CredentialProviderViewController: PasskeyProviderDelegate {
* Show the passkey registration view
*/
internal func showPasskeyRegistrationView(
- requestId: String,
rpId: String,
userName: String?,
+ userDisplayName: String?,
+ userId: Data?,
+ clientDataHash: Data,
vaultStore: VaultStore
) {
// Create view model with handlers
let viewModel = PasskeyRegistrationViewModel(
- requestId: requestId,
+ requestId: "", // Not needed for direct creation
rpId: rpId,
origin: "https://\(rpId)",
userName: userName,
- userDisplayName: userName,
+ userDisplayName: userDisplayName,
completionHandler: { [weak self] success in
guard let self = self else { return }
- if success {
- print("PasskeyRegistration: App opened successfully, starting to poll for result")
- // The app was opened successfully
- // Now we need to poll for the result or cancellation
- self.pollForPasskeyRegistrationResult(requestId: requestId, vaultStore: vaultStore)
- } else {
- print("PasskeyRegistration: Failed to open app")
- self.extensionContext.cancelRequest(withError: NSError(
- domain: ASExtensionErrorDomain,
- code: ASExtensionError.failed.rawValue,
- userInfo: [NSLocalizedDescriptionKey: "Failed to open main app"]
- ))
- }
+ // Button was clicked - create the passkey directly in Swift
+ self.createPasskeyInSwift(
+ rpId: rpId,
+ userName: userName,
+ userDisplayName: userDisplayName,
+ userId: userId,
+ clientDataHash: clientDataHash,
+ vaultStore: vaultStore
+ )
},
cancelHandler: { [weak self] in
- self?.cancelPasskeyRegistration(requestId: requestId, vaultStore: vaultStore)
+ self?.extensionContext.cancelRequest(withError: NSError(
+ domain: ASExtensionErrorDomain,
+ code: ASExtensionError.userCanceled.rawValue
+ ))
}
)
@@ -257,6 +244,94 @@ extension CredentialProviderViewController: PasskeyProviderDelegate {
self.currentHostingController = hostingController
}
+ /**
+ * Create passkey directly in Swift (called when user clicks the button)
+ */
+ internal func createPasskeyInSwift(
+ rpId: String,
+ userName: String?,
+ userDisplayName: String?,
+ userId: Data?,
+ clientDataHash: Data,
+ vaultStore: VaultStore
+ ) {
+ do {
+ print("PasskeyRegistration: Creating passkey directly in Swift layer")
+
+ // Generate new credential ID (UUID that will be used as the passkey ID)
+ let passkeyId = UUID()
+ let credentialId = try PasskeyHelper.guidToBytes(passkeyId.uuidString)
+
+ // Create the passkey using PasskeyAuthenticator
+ let passkeyResult = try PasskeyAuthenticator.createPasskey(
+ credentialId: credentialId,
+ clientDataHash: clientDataHash,
+ rpId: rpId,
+ userId: userId,
+ userName: userName,
+ userDisplayName: userDisplayName,
+ uvPerformed: true,
+ enablePrf: false
+ )
+
+ print("PasskeyRegistration: Passkey created successfully")
+
+ // Create a Passkey model object
+ let now = Date()
+ let passkey = Passkey(
+ id: passkeyId,
+ parentCredentialId: UUID(), // Will be set by createCredentialWithPasskey
+ rpId: rpId,
+ userHandle: userId,
+ userName: userName,
+ publicKey: passkeyResult.publicKey,
+ privateKey: passkeyResult.privateKey,
+ prfKey: passkeyResult.prfSecret,
+ displayName: userDisplayName ?? userName ?? rpId,
+ createdAt: now,
+ updatedAt: now,
+ isDeleted: false
+ )
+
+ // Begin transaction
+ try vaultStore.beginTransaction()
+
+ // Store credential with passkey in database
+ let credential = try vaultStore.createCredentialWithPasskey(
+ rpId: rpId,
+ userName: userName,
+ userDisplayName: userDisplayName,
+ passkey: passkey
+ )
+
+ // Commit transaction to persist the data
+ try vaultStore.commitTransaction()
+
+ print("PasskeyRegistration: Credential and passkey stored in database - credentialId=\(credential.id.uuidString)")
+
+ // Create the ASPasskeyRegistrationCredential to return to the system
+ let asCredential = ASPasskeyRegistrationCredential(
+ relyingParty: rpId,
+ clientDataHash: clientDataHash,
+ credentialID: credentialId,
+ attestationObject: passkeyResult.attestationObject
+ )
+
+ print("PasskeyRegistration: Completing registration request")
+
+ // Complete the registration request
+ extensionContext.completeRegistrationRequest(using: asCredential)
+
+ } catch {
+ print("PasskeyRegistration error: \(error)")
+ extensionContext.cancelRequest(withError: NSError(
+ domain: ASExtensionErrorDomain,
+ code: ASExtensionError.failed.rawValue,
+ userInfo: [NSLocalizedDescriptionKey: "Failed to create passkey: \(error.localizedDescription)"]
+ ))
+ }
+ }
+
/**
* Cancel passkey registration
*/
diff --git a/apps/mobile-app/ios/VaultStoreKit/PasskeyAuthenticator.swift b/apps/mobile-app/ios/VaultStoreKit/PasskeyAuthenticator.swift
index e47a3427a..c43021160 100644
--- a/apps/mobile-app/ios/VaultStoreKit/PasskeyAuthenticator.swift
+++ b/apps/mobile-app/ios/VaultStoreKit/PasskeyAuthenticator.swift
@@ -201,13 +201,20 @@ public class PasskeyAuthenticator {
private static func exportPublicKeyAsJWK(publicKey: P256.Signing.PublicKey) throws -> Data {
let rawRepresentation = publicKey.rawRepresentation
- // P-256 raw representation is 65 bytes: 0x04 || x (32 bytes) || y (32 bytes)
- guard rawRepresentation.count == 65, rawRepresentation[0] == 0x04 else {
+ // CryptoKit's rawRepresentation is 64 bytes (x || y) without the 0x04 prefix
+ guard rawRepresentation.count == 64 else {
+ print("PasskeyAuthenticator: exportPublicKeyAsJWK - Expected 64 bytes but got \(rawRepresentation.count)")
throw PasskeyError.invalidPublicKey
}
-
- let xBytes = rawRepresentation[1...32]
- let yBytes = rawRepresentation[33...64]
+
+ // Get bytes and normalize: accept 64 (x||y) or 65 (0x04||x||y)
+ var bytes = [UInt8](publicKey.rawRepresentation)
+ if bytes.count == 65, bytes[0] == 0x04 { bytes.removeFirst() }
+ guard bytes.count == 64 else { throw PasskeyError.invalidPublicKey }
+
+ // Safe slicing without Data.subdata
+ let xBytes = Data(bytes[0..<32])
+ let yBytes = Data(bytes[32..<64])
let jwk: [String: Any] = [
"kty": "EC",
@@ -224,14 +231,17 @@ public class PasskeyAuthenticator {
*/
private static func exportPrivateKeyAsJWK(privateKey: P256.Signing.PrivateKey) throws -> Data {
let rawRepresentation = privateKey.rawRepresentation
- let publicKey = privateKey.publicKey.rawRepresentation
-
- guard publicKey.count == 65, publicKey[0] == 0x04 else {
- throw PasskeyError.invalidPublicKey
- }
+ let publicKey = privateKey.publicKey
+
+ // Get bytes and normalize: accept 64 (x||y) or 65 (0x04||x||y)
+ var bytes = [UInt8](publicKey.rawRepresentation)
+ if bytes.count == 65, bytes[0] == 0x04 { bytes.removeFirst() }
+ guard bytes.count == 64 else { throw PasskeyError.invalidPublicKey }
+
+ // Safe slicing without Data.subdata
+ let xBytes = Data(bytes[0..<32])
+ let yBytes = Data(bytes[32..<64])
- let xBytes = publicKey[1...32]
- let yBytes = publicKey[33...64]
let dBytes = rawRepresentation
let jwk: [String: Any] = [
@@ -267,12 +277,24 @@ public class PasskeyAuthenticator {
private static func buildCoseEc2Es256(publicKey: P256.Signing.PublicKey) throws -> Data {
let rawRepresentation = publicKey.rawRepresentation
- guard rawRepresentation.count == 65, rawRepresentation[0] == 0x04 else {
+ print("PasskeyAuthenticator: rawRepresentation count = \(rawRepresentation.count)")
+ print("PasskeyAuthenticator: rawRepresentation hex = \(rawRepresentation.map { String(format: "%02x", $0) }.joined())")
+
+ // CryptoKit's rawRepresentation is 64 bytes (x || y) without the 0x04 prefix
+ // Unlike X9.63 format which is 65 bytes (0x04 || x || y)
+ guard rawRepresentation.count == 64 else {
+ print("PasskeyAuthenticator: ERROR - Expected 64 bytes but got \(rawRepresentation.count)")
throw PasskeyError.invalidPublicKey
}
- let xBytes = rawRepresentation[1...32]
- let yBytes = rawRepresentation[33...64]
+ // Get bytes and normalize: accept 64 (x||y) or 65 (0x04||x||y)
+ var bytes = [UInt8](publicKey.rawRepresentation)
+ if bytes.count == 65, bytes[0] == 0x04 { bytes.removeFirst() }
+ guard bytes.count == 64 else { throw PasskeyError.invalidPublicKey }
+
+ // Safe slicing without Data.subdata
+ let xBytes = bytes[0..<32]
+ let yBytes = bytes[32..<64]
// Build CBOR map manually
var cbor = Data()
diff --git a/apps/mobile-app/ios/VaultStoreKit/VaultStore+Passkey.swift b/apps/mobile-app/ios/VaultStoreKit/VaultStore+Passkey.swift
index 2a58119f4..f78be86ba 100644
--- a/apps/mobile-app/ios/VaultStoreKit/VaultStore+Passkey.swift
+++ b/apps/mobile-app/ios/VaultStoreKit/VaultStore+Passkey.swift
@@ -370,6 +370,114 @@ extension VaultStore {
)
}
+ // MARK: - Passkey Storage
+
+ /**
+ * Create a credential with a passkey (proof of concept for passkey registration)
+ * This creates a minimal credential record and links the passkey to it
+ */
+ public func createCredentialWithPasskey(
+ rpId: String,
+ userName: String?,
+ userDisplayName: String?,
+ passkey: Passkey
+ ) throws -> Credential {
+ guard let dbConn = dbConnection else {
+ throw VaultStoreError.vaultNotUnlocked
+ }
+
+ print("VaultStore+Passkey: Creating credential with passkey for rpId=\(rpId)")
+
+ let credentialId = passkey.parentCredentialId
+ let now = Date()
+ let timestamp = ISO8601DateFormatter().string(from: now)
+
+ // Create a minimal service for the RP
+ let serviceId = UUID()
+ let serviceTable = Table("Services")
+ let serviceInsert = serviceTable.insert(
+ Expression<String>("Id") <- serviceId.uuidString,
+ Expression<String?>("Name") <- rpId,
+ Expression<String?>("Url") <- "https://\(rpId)",
+ Expression<SQLite.Blob?>("Logo") <- nil,
+ Expression<String>("CreatedAt") <- timestamp,
+ Expression<String>("UpdatedAt") <- timestamp,
+ Expression<Int64>("IsDeleted") <- 0
+ )
+ try dbConn.run(serviceInsert)
+
+ // Create the credential
+ let credentialsTable = Table("Credentials")
+ let credentialInsert = credentialsTable.insert(
+ Expression<String>("Id") <- credentialId.uuidString,
+ Expression<String>("ServiceId") <- serviceId.uuidString,
+ Expression<String?>("AliasId") <- nil,
+ Expression<String?>("Username") <- userName,
+ Expression<String?>("Notes") <- "Passkey for \(rpId)",
+ Expression<String>("CreatedAt") <- timestamp,
+ Expression<String>("UpdatedAt") <- timestamp,
+ Expression<Int64>("IsDeleted") <- 0
+ )
+ try dbConn.run(credentialInsert)
+
+ print("VaultStore+Passkey: Created credential \(credentialId.uuidString)")
+
+ // Insert the passkey
+ try insertPasskey(passkey)
+
+ // Return the credential
+ let service = Service(
+ id: serviceId,
+ name: rpId,
+ url: "https://\(rpId)",
+ logo: nil,
+ createdAt: now,
+ updatedAt: now,
+ isDeleted: false
+ )
+
+ return Credential(
+ id: credentialId,
+ alias: nil,
+ service: service,
+ username: userName,
+ notes: "Passkey for \(rpId)",
+ password: nil,
+ passkeys: [passkey],
+ createdAt: now,
+ updatedAt: now,
+ isDeleted: false
+ )
+ }
+
+ /**
+ * Insert a new passkey into the database
+ */
+ public func insertPasskey(_ passkey: Passkey) throws {
+ guard let dbConn = dbConnection else {
+ throw VaultStoreError.vaultNotUnlocked
+ }
+
+ print("VaultStore+Passkey: Inserting new passkey - id=\(passkey.id.uuidString), rpId=\(passkey.rpId)")
+
+ let insert = Self.passkeysTable.insert(
+ Self.colId <- passkey.id.uuidString,
+ Self.colCredentialId <- passkey.parentCredentialId.uuidString,
+ Self.colRpId <- passkey.rpId,
+ Self.colUserId <- passkey.userHandle?.base64EncodedString(),
+ Self.colPublicKey <- String(data: passkey.publicKey, encoding: .utf8)!,
+ Self.colPrivateKey <- String(data: passkey.privateKey, encoding: .utf8)!,
+ Self.colPrfKey <- passkey.prfKey.map { Blob(bytes: [UInt8]($0)) },
+ Self.colDisplayName <- passkey.displayName,
+ Self.colCreatedAt <- ISO8601DateFormatter().string(from: passkey.createdAt),
+ Self.colUpdatedAt <- ISO8601DateFormatter().string(from: passkey.updatedAt),
+ Self.colIsDeleted <- Int64(passkey.isDeleted ? 1 : 0)
+ )
+
+ try dbConn.run(insert)
+ print("VaultStore+Passkey: Successfully inserted passkey")
+ }
+
/**
* Parse a date string to a Date object for use in queries.
*/
diff --git a/apps/mobile-app/ios/VaultStoreKitTests/PasskeyAuthenticatorTests.swift b/apps/mobile-app/ios/VaultStoreKitTests/PasskeyAuthenticatorTests.swift
new file mode 100644
index 000000000..c9faf3068
--- /dev/null
+++ b/apps/mobile-app/ios/VaultStoreKitTests/PasskeyAuthenticatorTests.swift
@@ -0,0 +1,182 @@
+import XCTest
+@testable import VaultStoreKit
+
+final class PasskeyAuthenticatorTests: XCTestCase {
+
+ override func setUp() {
+ super.setUp()
+ }
+
+ override func tearDown() {
+ super.tearDown()
+ }
+
+ /**
+ * Test that PasskeyAuthenticator can successfully create a passkey
+ * This validates the entire flow including key generation, CBOR encoding, and JWK export
+ */
+ func testCreatePasskey() throws {
+ print("PasskeyAuthenticatorTests: Starting passkey creation test")
+
+ // Test data
+ let rpId = "example.com"
+ let userName = "[email protected]"
+ let userDisplayName = "Test User"
+ let userId = Data("test-user-id".utf8)
+ let clientDataHash = Data(repeating: 0xAB, count: 32) // Mock 32-byte hash
+ let credentialId = Data(repeating: 0x12, count: 16) // Mock 16-byte credential ID
+
+ print("PasskeyAuthenticatorTests: Test parameters:")
+ print(" - rpId: \(rpId)")
+ print(" - userName: \(userName ?? "nil")")
+ print(" - userId: \(userId.base64EncodedString())")
+ print(" - clientDataHash: \(clientDataHash.count) bytes")
+ print(" - credentialId: \(credentialId.count) bytes")
+
+ // Attempt to create the passkey
+ let result: PasskeyCreationResult
+ do {
+ result = try PasskeyAuthenticator.createPasskey(
+ credentialId: credentialId,
+ clientDataHash: clientDataHash,
+ rpId: rpId,
+ userId: userId,
+ userName: userName,
+ userDisplayName: userDisplayName,
+ uvPerformed: true,
+ enablePrf: false
+ )
+ print("PasskeyAuthenticatorTests: ✅ Passkey created successfully")
+ } catch {
+ XCTFail("Failed to create passkey: \(error)")
+ return
+ }
+
+ // Validate the result
+ print("PasskeyAuthenticatorTests: Validating result...")
+
+ // Check credential ID
+ XCTAssertEqual(result.credentialId, credentialId, "Credential ID should match input")
+ print(" ✅ Credential ID matches")
+
+ // Check attestation object exists and has reasonable size
+ XCTAssertGreaterThan(result.attestationObject.count, 50, "Attestation object should be at least 50 bytes")
+ print(" ✅ Attestation object size: \(result.attestationObject.count) bytes")
+
+ // Check public key JWK
+ XCTAssertGreaterThan(result.publicKey.count, 0, "Public key JWK should not be empty")
+ print(" ✅ Public key JWK size: \(result.publicKey.count) bytes")
+
+ // Validate public key JWK structure
+ if let publicKeyJson = try? JSONSerialization.jsonObject(with: result.publicKey) as? [String: Any] {
+ XCTAssertEqual(publicKeyJson["kty"] as? String, "EC", "Key type should be EC")
+ XCTAssertEqual(publicKeyJson["crv"] as? String, "P-256", "Curve should be P-256")
+ XCTAssertNotNil(publicKeyJson["x"], "Public key should have x coordinate")
+ XCTAssertNotNil(publicKeyJson["y"], "Public key should have y coordinate")
+ print(" ✅ Public key JWK structure is valid")
+ } else {
+ XCTFail("Public key should be valid JSON")
+ }
+
+ // Check private key JWK
+ XCTAssertGreaterThan(result.privateKey.count, 0, "Private key JWK should not be empty")
+ print(" ✅ Private key JWK size: \(result.privateKey.count) bytes")
+
+ // Validate private key JWK structure
+ if let privateKeyJson = try? JSONSerialization.jsonObject(with: result.privateKey) as? [String: Any] {
+ XCTAssertEqual(privateKeyJson["kty"] as? String, "EC", "Key type should be EC")
+ XCTAssertEqual(privateKeyJson["crv"] as? String, "P-256", "Curve should be P-256")
+ XCTAssertNotNil(privateKeyJson["x"], "Private key should have x coordinate")
+ XCTAssertNotNil(privateKeyJson["y"], "Private key should have y coordinate")
+ XCTAssertNotNil(privateKeyJson["d"], "Private key should have d value")
+ print(" ✅ Private key JWK structure is valid")
+ } else {
+ XCTFail("Private key should be valid JSON")
+ }
+
+ // Check RP ID
+ XCTAssertEqual(result.rpId, rpId, "RP ID should match input")
+ print(" ✅ RP ID matches")
+
+ // Check user ID
+ XCTAssertEqual(result.userId, userId, "User ID should match input")
+ print(" ✅ User ID matches")
+
+ // Check user name
+ XCTAssertEqual(result.userName, userName, "User name should match input")
+ print(" ✅ User name matches")
+
+ // Check user display name
+ XCTAssertEqual(result.userDisplayName, userDisplayName, "User display name should match input")
+ print(" ✅ User display name matches")
+
+ // Check PRF secret (should be nil since enablePrf = false)
+ XCTAssertNil(result.prfSecret, "PRF secret should be nil when not enabled")
+ print(" ✅ PRF secret is nil (as expected)")
+
+ print("PasskeyAuthenticatorTests: ✅ All validations passed!")
+ }
+
+ /**
+ * Test passkey creation with PRF extension enabled
+ */
+ func testCreatePasskeyWithPrf() throws {
+ print("PasskeyAuthenticatorTests: Starting passkey creation test with PRF")
+
+ let rpId = "example.com"
+ let clientDataHash = Data(repeating: 0xAB, count: 32)
+ let credentialId = Data(repeating: 0x12, count: 16)
+
+ let result = try PasskeyAuthenticator.createPasskey(
+ credentialId: credentialId,
+ clientDataHash: clientDataHash,
+ rpId: rpId,
+ userId: nil,
+ userName: nil,
+ userDisplayName: nil,
+ uvPerformed: true,
+ enablePrf: true
+ )
+
+ // Check PRF secret exists
+ XCTAssertNotNil(result.prfSecret, "PRF secret should exist when enabled")
+ XCTAssertEqual(result.prfSecret?.count, 32, "PRF secret should be 32 bytes")
+ print(" ✅ PRF secret generated: \(result.prfSecret!.count) bytes")
+
+ print("PasskeyAuthenticatorTests: ✅ PRF test passed!")
+ }
+
+ /**
+ * Test passkey creation with minimal parameters
+ */
+ func testCreatePasskeyMinimal() throws {
+ print("PasskeyAuthenticatorTests: Starting minimal passkey creation test")
+
+ let rpId = "example.com"
+ let clientDataHash = Data(repeating: 0xAB, count: 32)
+ let credentialId = Data(repeating: 0x12, count: 16)
+
+ let result = try PasskeyAuthenticator.createPasskey(
+ credentialId: credentialId,
+ clientDataHash: clientDataHash,
+ rpId: rpId,
+ userId: nil,
+ userName: nil,
+ userDisplayName: nil,
+ uvPerformed: false,
+ enablePrf: false
+ )
+
+ XCTAssertEqual(result.credentialId, credentialId)
+ XCTAssertGreaterThan(result.attestationObject.count, 0)
+ XCTAssertGreaterThan(result.publicKey.count, 0)
+ XCTAssertGreaterThan(result.privateKey.count, 0)
+ XCTAssertEqual(result.rpId, rpId)
+ XCTAssertNil(result.userId)
+ XCTAssertNil(result.userName)
+ XCTAssertNil(result.userDisplayName)
+ XCTAssertNil(result.prfSecret)
+
+ print("PasskeyAuthenticatorTests: ✅ Minimal test passed!")
+ }
+}
diff --git a/apps/mobile-app/ios/VaultUI/Views/PasskeyRegistrationView.swift b/apps/mobile-app/ios/VaultUI/Views/PasskeyRegistrationView.swift
index 474407332..a783317ea 100644
--- a/apps/mobile-app/ios/VaultUI/Views/PasskeyRegistrationView.swift
+++ b/apps/mobile-app/ios/VaultUI/Views/PasskeyRegistrationView.swift
@@ -81,11 +81,11 @@ public struct PasskeyRegistrationView: View {
// Action buttons
VStack(spacing: 12) {
Button(action: {
- viewModel.openMainApp()
+ viewModel.createPasskey()
}, label: {
HStack {
- Image(systemName: "arrow.right.circle.fill")
- Text(NSLocalizedString("open_app_to_create", comment: ""))
+ Image(systemName: "key.fill")
+ Text("Create Passkey")
}
.padding()
.frame(maxWidth: .infinity)
@@ -176,6 +176,12 @@ public class PasskeyRegistrationViewModel: ObservableObject {
self.cancelHandler = cancelHandler
}
+ public func createPasskey() {
+ // Trigger passkey creation in Swift
+ print("PasskeyRegistration: Create passkey button clicked")
+ completionHandler(true)
+ }
+
public func openMainApp() {
// Build the deep link URL
var urlString = "net.aliasvault.app://credentials/passkey-create"