Skip to content

Commit

Permalink
Remove sign timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
tarrencev committed Jul 31, 2024
1 parent c16b199 commit 90e3622
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 21 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,6 @@ Cargo.lock
# MSVC Windows builds of rustc generate these, which store debugging information
**/*.pdb

# Envs
**/.cargo/

# Scarb
**/Scarb.lock

Expand Down
9 changes: 6 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,13 @@ wasm-bindgen = "0.2"
wasm-bindgen-futures = "0.4.42"
wasm-webauthn = { git = "https://github.com/cartridge-gg/wasm-webauthn", rev = "972693f" }
tokio = { version = "1", features = ["macros", "time"] }
base64urlsafedata = { git = "https://github.com/cartridge-gg/webauthn-rs", rev = "a20501d" }
base64urlsafedata = { git = "https://github.com/cartridge-gg/webauthn-rs", rev = "a6cea88" }
serde_cbor_2 = { version = "0.12.0-dev" }
webauthn-rs-core = { git = "https://github.com/cartridge-gg/webauthn-rs", rev = "a20501d" }
webauthn-rs-proto = { git = "https://github.com/cartridge-gg/webauthn-rs", rev = "a20501d" }
webauthn-rs-core = { git = "https://github.com/cartridge-gg/webauthn-rs", rev = "a6cea88" }
webauthn-rs-proto = { git = "https://github.com/cartridge-gg/webauthn-rs", rev = "a6cea88" }
webauthn-authenticator-rs = { git = "https://github.com/cartridge-gg/webauthn-rs", rev = "a6cea88", features = [
"softpasskey",
] }

[patch.crates-io]
# Remove this patch once the following PR is merged: <https://github.com/xJonathanLEI/starknet-rs/pull/615>
Expand Down
Binary file modified packages/account-wasm/pkg/account_wasm_bg.wasm
Binary file not shown.
13 changes: 7 additions & 6 deletions packages/account-wasm/src/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ use futures::channel::oneshot;
use wasm_bindgen::UnwrapThrowExt;
use wasm_bindgen_futures::{spawn_local, JsFuture};
use web_sys::Window;
use webauthn_rs_proto::*;
use webauthn_rs_proto::{
auth::PublicKeyCredentialRequestOptions, CreationChallengeResponse, PublicKeyCredential,
PublicKeyCredentialCreationOptions, RegisterPublicKeyCredential, RequestChallengeResponse,
};

pub fn window() -> Window {
web_sys::window().expect("Unable to retrieve window")
Expand All @@ -15,18 +18,16 @@ pub fn window() -> Window {
pub struct BrowserBackend {}

#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
#[cfg_attr(target_arch = "wasm32", async_trait(?Send), )]
impl WebauthnBackend for BrowserBackend {
async fn get_assertion(
&self,
options: PublicKeyCredentialRequestOptions,
) -> Result<PublicKeyCredential, DeviceError> {
let (tx, rx) = oneshot::channel();

spawn_local(async move {
let promise = window()
.navigator()
.credentials()
let credentials = window().navigator().credentials();
let promise = credentials
.get_with_options(
&RequestChallengeResponse {
public_key: options,
Expand Down
10 changes: 4 additions & 6 deletions packages/account_sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ crate-type = ["lib"]
[dependencies]
anyhow.workspace = true
async-trait.workspace = true
base64urlsafedata = { git = "https://github.com/cartridge-gg/webauthn-rs", rev = "a20501d" }
base64urlsafedata.workspace = true
base64.workspace = true
cainome.workspace = true
coset.workspace = true
Expand All @@ -37,15 +37,13 @@ wasm-bindgen.workspace = true
web-sys = "0.3.69"
indexmap.workspace = true
num-traits.workspace = true
webauthn-rs-proto = { git = "https://github.com/cartridge-gg/webauthn-rs", rev = "a20501d" }
webauthn-rs-proto.workspace = true

[dev-dependencies]
rand_core = { version = "0.6", features = ["getrandom"] }
once_cell.workspace = true
webauthn-authenticator-rs = { git = "https://github.com/cartridge-gg/webauthn-rs", rev = "a20501d", features = [
"softpasskey",
] }
webauthn-rs-core = { git = "https://github.com/cartridge-gg/webauthn-rs", rev = "a20501d" }
webauthn-authenticator-rs = { workspace = true, features = ["softpasskey"] }
webauthn-rs-core.workspace = true

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
tokio.workspace = true
Expand Down
10 changes: 7 additions & 3 deletions packages/account_sdk/src/signers/webauthn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ use starknet::core::types::Felt;
use std::collections::BTreeMap;
use std::ops::Neg;
use std::result::Result;
use webauthn_rs_proto::{PublicKeyCredential, RegisterPublicKeyCredential};
use webauthn_rs_proto::{
AllowCredentials, AttestationConveyancePreference, AuthenticatorSelectionCriteria,
CredentialProtectionPolicy, PubKeyCredParams, PublicKeyCredential,
PublicKeyCredentialCreationOptions, PublicKeyCredentialRequestOptions,
RegisterPublicKeyCredential, RelyingParty, User, UserVerificationPolicy,
};

use super::{DeviceError, HashSigner, SignError};
use crate::abigen::controller::Signature;
Expand All @@ -29,7 +34,6 @@ use nom::{
};
use serde::de::DeserializeOwned;
use serde_cbor_2::error::Error as CBORError;
use webauthn_rs_proto::*;

/// Marker type parameter for data related to registration ceremony
#[derive(Debug)]
Expand Down Expand Up @@ -306,7 +310,7 @@ where

let options = PublicKeyCredentialRequestOptions {
challenge: Base64UrlSafeData::from(challenge),
timeout: Some(500),
timeout: None,
rp_id: self.rp_id.clone(),
allow_credentials: vec![AllowCredentials {
type_: "public-key".to_string(),
Expand Down

0 comments on commit 90e3622

Please sign in to comment.