1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-08 04:33:38 +00:00

Normalize Registration+Assertion Request to be same as macos

This commit is contained in:
Anders Åberg
2025-07-07 15:52:40 +02:00
parent 22b272e4a3
commit e4a2326ada
6 changed files with 27 additions and 73 deletions

View File

@@ -196,22 +196,6 @@ export declare namespace passkey_authenticator {
userName: string
userHandle: string
}
export interface PasskeyAssertionRequest {
rpId: string
transactionId: string
clientDataHash: Array<number>
allowedCredentials: Array<Array<number>>
userVerification: boolean
}
export interface PasskeyRegistrationRequest {
rpId: string
transactionId: string
userHandle: Array<number>
userName: string
clientDataHash: Array<number>
userVerification: boolean
supportedAlgorithms: Array<number>
}
export interface PasskeySyncRequest {
rpId: string
}

View File

@@ -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<u8>,
pub allowed_credentials: Vec<Vec<u8>>,
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<u8>,
pub user_name: String,
pub client_data_hash: Vec<u8>,
pub user_verification: bool,
pub supported_algorithms: Vec<i32>,
}
#[napi(object)]
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]

View File

@@ -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!(

View File

@@ -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(),
};

View File

@@ -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<String> 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<u8>,
pub allowed_credentials: Vec<Vec<u8>>,
pub user_verification: UserVerificationRequirement,
pub allowed_credentials: Vec<Vec<u8>>,
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<u8>,
pub user_name: String,
pub user_handle: Vec<u8>,
pub client_data_hash: Vec<u8>,
pub user_verification: UserVerificationRequirement,
pub supported_algorithms: Vec<i32>, // COSE algorithm identifiers
pub excluded_credentials: Vec<Vec<u8>>, // Credentials to exclude from creation
pub supported_algorithms: Vec<i32>,
pub window_xy: Position,
pub excluded_credentials: Vec<Vec<u8>>,
pub transaction_id: String,
}
/// Sync request structure

View File

@@ -59,19 +59,9 @@ export class NativeAutofillMain {
});
}
private async handleAssertionRequest(
request: passkey_authenticator.PasskeyAssertionRequest,
): Promise<string> {
private async handleAssertionRequest(request: autofill.PasskeyAssertionRequest): Promise<string> {
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<string> {
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 },
);