diff --git a/Cargo.toml b/Cargo.toml index 2a6b687..1a50471 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,4 @@ base64 = "0.21.4" phf = { version = "0.11.2", features = ["macros"] } rsa = { version = "0.9.2" } getrandom = { version = "0.2.10", features = ["custom"] } -p256 = {version = "0.13.2", features = ["ecdsa-core", "arithmetic", "serde"]} -webauthn-rs = { git = "https://github.com/burnt-labs/webauthn-rs.git", features = ["danger-credential-internals"] } -webauthn-rs-proto = { git = "https://github.com/burnt-labs/webauthn-rs.git" } -webauthn-rs-core = { git = "https://github.com/burnt-labs/webauthn-rs.git" } +p256 = {version = "0.13.2", features = ["ecdsa-core", "arithmetic", "serde"]} \ No newline at end of file diff --git a/account/Cargo.toml b/account/Cargo.toml index 0258664..6b095da 100644 --- a/account/Cargo.toml +++ b/account/Cargo.toml @@ -27,11 +27,6 @@ phf = { workspace = true } rsa = { workspace = true } getrandom = { workspace = true } p256 = { workspace = true } -#webauthn-rs = { workspace = true } -#webauthn-rs-proto = { workspace = true } -#webauthn-rs-core = { workspace = true } -#passkey = { git="https://github.com/aptos-labs/passkey-rs.git", branch = "fix-passkey-rs"} -#passkey-authenticator = { git="https://github.com/aptos-labs/passkey-rs.git", branch = "fix-passkey-rs", features = ["testable"] } url = "2.4.1" coset = "0.3.5" futures = "0.3.29" diff --git a/account/src/auth/passkey.rs b/account/src/auth/passkey.rs index dc67981..e3bf67b 100644 --- a/account/src/auth/passkey.rs +++ b/account/src/auth/passkey.rs @@ -70,121 +70,3 @@ pub fn verify( Ok(true) } - -// use crate::error::{ContractError, ContractResult}; -// use cosmwasm_std::{from_binary, Binary}; -// use webauthn_rs::prelude::{Passkey, PasskeyAuthentication, PasskeyRegistration, Url}; -// // use webauthn_rs::prelude::*; -// use crate::error::ContractError::InvalidToken; -// use webauthn_rs::WebauthnBuilder; -// use webauthn_rs_core::interface::{AuthenticationState, RegistrationState}; -// use webauthn_rs_proto::{COSEAlgorithm, PublicKeyCredential, UserVerificationPolicy}; -// -// -// -// pub fn register(url: String, cred: &Binary, challenge: Vec) -> ContractResult { -// let rp_origin = match Url::parse(&url) { -// Ok(u) => u, -// Err(_) => return Err(ContractError::URLParse { url }), -// }; -// -// let reg = from_binary(cred)?; -// -// let rp_id = rp_origin.domain().ok_or(ContractError::URLParse { url })?; -// let builder = WebauthnBuilder::new(rp_id, &rp_origin)?; -// let webauthn = builder.build()?; -// -// let registration_state = RegistrationState { -// policy: UserVerificationPolicy::Preferred, -// exclude_credentials: vec![], -// challenge: challenge.into(), -// credential_algorithms: vec![COSEAlgorithm::ES256], -// require_resident_key: false, -// authenticator_attachment: None, -// extensions: Default::default(), -// experimental_allow_passkeys: true, -// }; -// -// let passkey = webauthn.finish_passkey_registration( -// ®, -// &PasskeyRegistration { -// rs: registration_state, -// }, -// )?; -// -// Ok(passkey) -// } -// -// pub fn verify( -// url: String, -// passkey_bytes: &Binary, -// cred: &Binary, -// tx_bytes: Vec, -// ) -> ContractResult<()> { -// let rp_origin = match Url::parse(&url) { -// Ok(u) => u, -// Err(_err) => return Err(ContractError::URLParse { url }), -// }; -// -// let rp_id = rp_origin.domain().ok_or(ContractError::URLParse { url })?; -// let builder = WebauthnBuilder::new(rp_id, &rp_origin).expect("Invalid configuration"); -// let webauthn = builder.build().expect("Invalid configuration"); -// -// let passkey: Passkey = from_binary(passkey_bytes)?; -// -// let authentication_state = AuthenticationState { -// credentials: vec![passkey.into()], -// policy: UserVerificationPolicy::Preferred, -// challenge: tx_bytes.into(), -// appid: None, -// allow_backup_eligible_upgrade: false, -// }; -// -// let public_key_credential: PublicKeyCredential = from_binary(cred)?; -// -// webauthn.finish_passkey_authentication( -// &public_key_credential, -// &PasskeyAuthentication { -// ast: authentication_state, -// }, -// )?; -// -// Ok(()) -// } -// -// #[cfg(test)] -// mod tests { -// use crate::auth::passkey::{register, verify}; -// use cosmwasm_std::to_binary; -// use webauthn_rs::prelude::*; -// -// #[test] -// fn test_passkey_example() { -// let challenge = "test-challenge"; -// -// let rp_origin = -// Url::parse("https://xion-dapp-example-git-feat-faceid-burntfinance.vercel.app") -// .expect("Invalid URL"); -// let register_credential: RegisterPublicKeyCredential = serde_json::from_str(r#"{"type":"public-key","id":"6BnpSHlIXwOndHhxfPw4l3SylupnZIvTVP9Vp_aK34w","rawId":"6BnpSHlIXwOndHhxfPw4l3SylupnZIvTVP9Vp_aK34w","authenticatorAttachment":"platform","response":{"clientDataJSON":"eyJ0eXBlIjoid2ViYXV0aG4uY3JlYXRlIiwiY2hhbGxlbmdlIjoiZEdWemRDMWphR0ZzYkdWdVoyVSIsIm9yaWdpbiI6Imh0dHBzOi8veGlvbi1kYXBwLWV4YW1wbGUtZ2l0LWZlYXQtZmFjZWlkLWJ1cm50ZmluYW5jZS52ZXJjZWwuYXBwIiwiY3Jvc3NPcmlnaW4iOmZhbHNlfQ","attestationObject":"o2NmbXRkbm9uZWdhdHRTdG10oGhhdXRoRGF0YViksGMBiDcEppiMfxQ10TPCe2-FaKrLeTkvpzxczngTMw1BAAAAAK3OAAI1vMYKZIsLJfHwVQMAIOgZ6Uh5SF8Dp3R4cXz8OJd0spbqZ2SL01T_Vaf2it-MpQECAyYgASFYINnBKEMfG6wkb9W1grSXgNAQ8lx6H7j6EcMyTSbZ91-XIlggdk2OOxV_bISxCsqFac6ZE8-gEurV4xQd7kFFYdfMqtE","transports":["internal"]},"clientExtensionResults":{}}"#).unwrap(); -// -// let reg_bytes = to_binary(®ister_credential).unwrap(); -// let passkey = register( -// rp_origin.to_string(), -// ®_bytes, -// challenge.as_bytes().to_vec(), -// ) -// .unwrap(); -// let passkey_bytes = to_binary(&passkey).unwrap(); -// -// let authenticate_credential: PublicKeyCredential = serde_json::from_str(r#"{"type":"public-key","id":"6BnpSHlIXwOndHhxfPw4l3SylupnZIvTVP9Vp_aK34w","rawId":"6BnpSHlIXwOndHhxfPw4l3SylupnZIvTVP9Vp_aK34w","authenticatorAttachment":"platform","response":{"clientDataJSON":"eyJ0eXBlIjoid2ViYXV0aG4uZ2V0IiwiY2hhbGxlbmdlIjoiZEdWemRDMWphR0ZzYkdWdVoyVSIsIm9yaWdpbiI6Imh0dHBzOi8veGlvbi1kYXBwLWV4YW1wbGUtZ2l0LWZlYXQtZmFjZWlkLWJ1cm50ZmluYW5jZS52ZXJjZWwuYXBwIiwiY3Jvc3NPcmlnaW4iOmZhbHNlfQ","authenticatorData":"sGMBiDcEppiMfxQ10TPCe2-FaKrLeTkvpzxczngTMw0BAAAAAA","signature":"MEQCIF1Fm_XjFV5FjBRYXNN1WcDm0V4xbPn3sQ85gC34_FGmAiBzLYGsat3HwDcn4jh50gTW4mgGcmYqkvT2g1bfdFxElA","userHandle":null},"clientExtensionResults":{}}"#).unwrap(); -// let authenticate_credential_bytes = to_binary(&authenticate_credential).unwrap(); -// -// verify( -// rp_origin.to_string(), -// &passkey_bytes, -// &authenticate_credential_bytes, -// challenge.as_bytes().to_vec(), -// ) -// .unwrap(); -// } -// }