UNPKG

@biconomy/passkey

Version:

Passkey validator plug in for Biconomy SDK

65 lines 2.4 kB
import { type Module, type NexusAccount, type ToModuleParameters } from "@biconomy/sdk"; import type { WebAuthnKey } from "./toWebAuthnKey"; export type ToPasskeyValidatorParameters = Omit<ToModuleParameters, "accountAddress" | "signer"> & { account: NexusAccount; webAuthnKey: WebAuthnKey; }; /** * Creates a passkey validator module * * @param params - The parameters for creating the passkey validator * @param params.webAuthnKey - The WebAuthn key data containing public key coordinates and authenticator info * @param params.chainId - The chain ID of the network * @param params.account - The Nexus account instance * * @returns A Promise that resolves to a Module instance configured for passkey validation through the @biconomy/sdk * * @example * ```typescript * import { createNexusClient, moduleActivator } from "@biconomy/sdk"; * import { http } from "viem"; * import { baseSepolia } from "viem/chains"; * import { WebAuthnMode, toWebAuthnKey } from "@biconomy/passkey"; * * // Initialize Nexus client * const nexusClient = await createNexusClient({ * signer: account, * chain: baseSepolia, * transport: http(), * bundlerTransport: http("https://bundler.biconomy.io/api/v3/...") * }); * * // Create WebAuthn credentials * const webAuthnKey = await toWebAuthnKey({ * passkeyName: "nexus", * mode: WebAuthnMode.Register // Use Register for new passkey, Login for existing * }); * * // Create and initialize the passkey validator * const passkeyValidator = await toPasskeyValidator({ * webAuthnKey, * chainId: baseSepolia.id, * account: nexusClient.account * }); * * // Install the validator module * const opHash = await nexusClient.installModule({ module: passkeyValidator }); * await nexusClient.waitForUserOperationReceipt({ hash: opHash }); * * // Activate the passkey validator * nexusClient.extend(moduleActivator(passkeyValidator)); * * // Use the passkey validator to sign and send transactions * const txHash = await nexusClient.sendTransaction({ * calls: [{ * to: "0x...", * value: 0n * }] * }); * * // Wait for transaction confirmation * const receipt = await nexusClient.waitForTransactionReceipt({ hash: txHash }); * ``` */ export declare function toPasskeyValidator({ webAuthnKey, account }: ToPasskeyValidatorParameters): Promise<Module>; //# sourceMappingURL=toPasskeyValidator.d.ts.map