From e4a2326adad217f60f6827426657463e2de9e08c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20=C3=85berg?= Date: Mon, 7 Jul 2025 15:52:40 +0200 Subject: [PATCH] Normalize Registration+Assertion Request to be same as macos --- apps/desktop/desktop_native/napi/index.d.ts | 16 ---------- apps/desktop/desktop_native/napi/src/lib.rs | 25 ---------------- .../src/assert.rs | 1 + .../src/make_credential.rs | 1 + .../windows_plugin_authenticator/src/types.rs | 29 ++++++++++++++----- .../main/autofill/native-autofill.main.ts | 28 +++--------------- 6 files changed, 27 insertions(+), 73 deletions(-) diff --git a/apps/desktop/desktop_native/napi/index.d.ts b/apps/desktop/desktop_native/napi/index.d.ts index 0e34d818763..7d816170884 100644 --- a/apps/desktop/desktop_native/napi/index.d.ts +++ b/apps/desktop/desktop_native/napi/index.d.ts @@ -196,22 +196,6 @@ export declare namespace passkey_authenticator { userName: string userHandle: string } - export interface PasskeyAssertionRequest { - rpId: string - transactionId: string - clientDataHash: Array - allowedCredentials: Array> - userVerification: boolean - } - export interface PasskeyRegistrationRequest { - rpId: string - transactionId: string - userHandle: Array - userName: string - clientDataHash: Array - userVerification: boolean - supportedAlgorithms: Array - } export interface PasskeySyncRequest { rpId: string } diff --git a/apps/desktop/desktop_native/napi/src/lib.rs b/apps/desktop/desktop_native/napi/src/lib.rs index 5d2a6074e45..5ee7c4b49d6 100644 --- a/apps/desktop/desktop_native/napi/src/lib.rs +++ b/apps/desktop/desktop_native/napi/src/lib.rs @@ -828,31 +828,6 @@ pub mod passkey_authenticator { pub user_handle: String, // base64url encoded } - #[napi(object)] - #[derive(serde::Serialize, serde::Deserialize)] - #[serde(rename_all = "camelCase")] - pub struct PasskeyAssertionRequest { - pub rp_id: String, - pub transaction_id: String, - pub client_data_hash: Vec, - pub allowed_credentials: Vec>, - pub user_verification: bool, - } - - #[napi(object)] - #[derive(serde::Serialize, serde::Deserialize)] - #[serde(rename_all = "camelCase")] - - pub struct PasskeyRegistrationRequest { - pub rp_id: String, - pub transaction_id: String, - pub user_handle: Vec, - pub user_name: String, - pub client_data_hash: Vec, - pub user_verification: bool, - pub supported_algorithms: Vec, - } - #[napi(object)] #[derive(serde::Serialize, serde::Deserialize)] #[serde(rename_all = "camelCase")] diff --git a/apps/desktop/desktop_native/windows_plugin_authenticator/src/assert.rs b/apps/desktop/desktop_native/windows_plugin_authenticator/src/assert.rs index 774773a368e..08b24a9704a 100644 --- a/apps/desktop/desktop_native/windows_plugin_authenticator/src/assert.rs +++ b/apps/desktop/desktop_native/windows_plugin_authenticator/src/assert.rs @@ -135,6 +135,7 @@ pub fn send_assertion_request( client_data_hash: request.client_data_hash.clone(), allowed_credentials: request.allowed_credentials.clone(), user_verification: request.user_verification.clone(), + window_xy: Position { x: 400, y: 400 }, }; util::message(&format!( diff --git a/apps/desktop/desktop_native/windows_plugin_authenticator/src/make_credential.rs b/apps/desktop/desktop_native/windows_plugin_authenticator/src/make_credential.rs index 7cb63e047ff..36a3e5baa12 100644 --- a/apps/desktop/desktop_native/windows_plugin_authenticator/src/make_credential.rs +++ b/apps/desktop/desktop_native/windows_plugin_authenticator/src/make_credential.rs @@ -196,6 +196,7 @@ pub fn send_registration_request( user_name: request.user_name.clone(), client_data_hash: request.client_data_hash.clone(), user_verification: request.user_verification.clone(), + window_xy: Position { x: 400, y: 400 }, supported_algorithms: request.supported_algorithms.clone(), excluded_credentials: request.excluded_credentials.clone(), }; diff --git a/apps/desktop/desktop_native/windows_plugin_authenticator/src/types.rs b/apps/desktop/desktop_native/windows_plugin_authenticator/src/types.rs index d6957bba306..d743b6339ee 100644 --- a/apps/desktop/desktop_native/windows_plugin_authenticator/src/types.rs +++ b/apps/desktop/desktop_native/windows_plugin_authenticator/src/types.rs @@ -1,3 +1,4 @@ +use serde::{Deserialize, Serialize}; use tokio::sync::oneshot; /// User verification requirement as defined by WebAuthn spec @@ -36,29 +37,41 @@ impl Into for UserVerificationRequirement { } } -/// Assertion request structure +/// IDENTICAL to napi/lib.rs/PasskeyAssertionRequest #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] #[serde(rename_all = "camelCase")] pub struct PasskeyAssertionRequest { pub rp_id: String, - pub transaction_id: String, pub client_data_hash: Vec, - pub allowed_credentials: Vec>, pub user_verification: UserVerificationRequirement, + pub allowed_credentials: Vec>, + pub window_xy: Position, + + pub transaction_id: String, } -/// Registration request structure +// Identical to napi/lib.rs/Position +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct Position { + pub x: i32, + pub y: i32, +} + +/// IDENTICAL to napi/lib.rs/PasskeyRegistrationRequest #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] #[serde(rename_all = "camelCase")] pub struct PasskeyRegistrationRequest { pub rp_id: String, - pub transaction_id: String, - pub user_handle: Vec, pub user_name: String, + pub user_handle: Vec, pub client_data_hash: Vec, pub user_verification: UserVerificationRequirement, - pub supported_algorithms: Vec, // COSE algorithm identifiers - pub excluded_credentials: Vec>, // Credentials to exclude from creation + pub supported_algorithms: Vec, + pub window_xy: Position, + pub excluded_credentials: Vec>, + + pub transaction_id: String, } /// Sync request structure diff --git a/apps/desktop/src/platform/main/autofill/native-autofill.main.ts b/apps/desktop/src/platform/main/autofill/native-autofill.main.ts index 5bf1fd7d30e..b9f6e2cf46a 100644 --- a/apps/desktop/src/platform/main/autofill/native-autofill.main.ts +++ b/apps/desktop/src/platform/main/autofill/native-autofill.main.ts @@ -59,19 +59,9 @@ export class NativeAutofillMain { }); } - private async handleAssertionRequest( - request: passkey_authenticator.PasskeyAssertionRequest, - ): Promise { + private async handleAssertionRequest(request: autofill.PasskeyAssertionRequest): Promise { this.logService.info("Handling assertion request for rpId:", request.rpId); - const normalized_request: autofill.PasskeyAssertionRequest = { - rpId: request.rpId, - allowedCredentials: request.allowedCredentials, - clientDataHash: request.clientDataHash, - userVerification: autofill.UserVerification.Required, - windowXy: { x: 400, y: 400 }, - }; - try { // Generate unique identifiers for tracking this request const clientId = Date.now(); @@ -83,7 +73,7 @@ export class NativeAutofillMain { { clientId, sequenceNumber, - request: normalized_request, + request: request, }, { waitForResponse: true, timeout: 60000 }, ); @@ -113,20 +103,10 @@ export class NativeAutofillMain { } private async handleRegistrationRequest( - request: passkey_authenticator.PasskeyRegistrationRequest, + request: autofill.PasskeyRegistrationRequest, ): Promise { this.logService.info("Handling registration request for rpId:", request.rpId); - const normalized_request: autofill.PasskeyRegistrationRequest = { - rpId: request.rpId, - clientDataHash: request.clientDataHash, - userName: request.userName, - userHandle: request.userHandle, - userVerification: autofill.UserVerification.Required, - supportedAlgorithms: request.supportedAlgorithms, - windowXy: { x: 400, y: 400 }, - }; - try { // Generate unique identifiers for tracking this request const clientId = Date.now(); @@ -138,7 +118,7 @@ export class NativeAutofillMain { { clientId, sequenceNumber, - request: normalized_request, + request: request, }, { waitForResponse: true, timeout: 60000 }, );