Skip to content

Commit

Permalink
set explicit timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
kalepail committed Jul 10, 2024
1 parent 4d33bae commit 5099524
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion PROPOSAL.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Smart Wallet Interface
# WebAuthn smart wallet contract interface

With the release of [Protocol 21](https://stellar.org/blog/developers/announcing-protocol-21) (and specifically the inclusion of the secp256r1 verification curve) Soroban now has tremendous first class support for passkey powered smart wallets.

Expand Down
7 changes: 7 additions & 0 deletions contracts/contract-webauthn-factory/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ use soroban_sdk::{
contract, contracterror, contractimpl, symbol_short, vec, Address, Bytes, BytesN, Env, Symbol,
};

// mod wallet {
// use soroban_sdk::auth::Context;
// soroban_sdk::contractimport!(file = "../target/wasm32-unknown-unknown/release/webauthn_secp256r1.wasm");
// }

#[contract]
pub struct Contract;

Expand Down Expand Up @@ -58,6 +63,8 @@ impl Contract {

let address = env.deployer().with_current_contract(salt).deploy(wasm_hash);

// wallet::Client::new(&env, &address).add(&id, &pk, &true);

let () = env.invoke_contract(
&address,
&symbol_short!("add"),
Expand Down
2 changes: 1 addition & 1 deletion contracts/contract-webauthn-secp256r1/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ impl CustomAccountInterface for Contract {
base64_url::encode(&mut expected_challenge, &signature_payload.to_array());

// Check that the challenge inside the client data JSON that was signed is identical to the expected challenge.
// TODO is this check actually necessary or is the secp256r1_verify enough? I think it's necessary
// TODO is this check actually necessary or is the secp256r1_verify enough?
if client_data_json.challenge.as_bytes() != expected_challenge {
return Err(Error::ClientDataJsonChallengeIncorrect);
}
Expand Down
8 changes: 6 additions & 2 deletions src/kit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class PasskeyKit extends PasskeyBase {
public async createKey(app: string, user: string) {
const now = new Date()
const displayName = `${user}${now.toLocaleString()}`
const { id, response} = await startRegistration({
const { id, response } = await startRegistration({
challenge: base64url("stellaristhebetterblockchain"),
rp: {
// id: undefined,
Expand All @@ -93,6 +93,7 @@ export class PasskeyKit extends PasskeyBase {
},
pubKeyCredParams: [{ alg: -7, type: "public-key" }],
attestation: "none",
timeout: 120_000
});

if (!this.keyId)
Expand All @@ -116,6 +117,7 @@ export class PasskeyKit extends PasskeyBase {
challenge: base64url("stellaristhebetterblockchain"),
// rpId: undefined,
userVerification: "discouraged",
timeout: 120_000
});

console.log(response);
Expand Down Expand Up @@ -151,7 +153,7 @@ export class PasskeyKit extends PasskeyBase {
// TODO what is the error if the entry exists but is archived?
await this.rpc.getContractData(contractId, xdr.ScVal.scvLedgerKeyContractInstance())
}
// if that fails look up from the factory mapper
// if that fails look up from the `getContractId` function
catch {
contractId = undefined

Expand Down Expand Up @@ -203,6 +205,7 @@ export class PasskeyKit extends PasskeyBase {
challenge: base64url(payload),
// rpId: undefined,
userVerification: "discouraged",
timeout: 120_000
}
: {
challenge: base64url(payload),
Expand All @@ -216,6 +219,7 @@ export class PasskeyKit extends PasskeyBase {
},
],
userVerification: "discouraged",
timeout: 120_000
}
);

Expand Down

0 comments on commit 5099524

Please sign in to comment.