addNewPasskeySigner

suspend fun addNewPasskeySigner(contextRuleId: UInt, userName: String, selectedSigners: List<SelectedSigner> = emptyList(), forceMethod: SubmissionMethod? = null): AddPasskeySignerResult

Registers a new WebAuthn passkey and adds it as a signer to a context rule.

Performs the full end-to-end flow of creating a new passkey via the platform's WebAuthn API, persisting the credential locally, and adding it as a signer on the smart account contract. This is the high-level method for adding passkey signers; use addPasskey if you already have the public key and credential ID.

Flow:

  1. Validates that a wallet is connected and a WebAuthnProvider is configured

  2. Generates cryptographically secure random challenge and user ID (32 bytes each)

  3. Triggers the platform WebAuthn registration ceremony (biometric prompt)

  4. Base64URL-encodes the credential ID for storage

  5. Saves the credential locally via OZCredentialManager.createPendingCredential

  6. Emits a SmartAccountEvent.CredentialCreated event

  7. Adds the passkey signer on-chain via addPasskey

The on-chain addition requires authorization from an existing signer on the specified context rule. The user will be prompted for biometric authentication twice: once for the new passkey registration and once for the existing signer to authorize the on-chain transaction.

Return

AddPasskeySignerResult containing the credential ID, public key, and transaction result

Parameters

contextRuleId

The context rule ID to add the signer to (e.g., 0 for Default)

userName

User-friendly name for the new passkey (displayed by the authenticator)

selectedSigners

Optional list of signers for multi-signer authorization. When empty (default), uses single-signer auth with the connected passkey. When non-empty, coordinates signatures from all listed signers.

forceMethod

Optional submission method override. When null (default), uses the configured submission method (relayer if available, RPC otherwise).

Throws

if no WebAuthnProvider is configured

if no wallet is connected

if the WebAuthn registration ceremony fails or the user cancels

if credential storage or on-chain signer addition fails

Example:

val result = signerManager.addNewPasskeySigner(
contextRuleId = 0u,
userName = "Recovery Passkey"
)

println("Credential ID: ${result.credentialId}")
println("On-chain result: ${result.transactionResult.success}")