/** * Typed signer abstraction for the flat `Signatures` map. * * A {@link Signer} knows how to authenticate a signature payload (the 32-byte * hash from `buildSignaturePayload`) and produce the on-chain * `(SignerKey, Signature)` pair the wallet's `__check_auth` expects. This * replaces the old `sign({ keyId | keypair | policy })` option trio, where the * caller had to pass exactly one of three mutually-exclusive fields, with three * explicit signer classes: * * - {@link PasskeySigner} — a WebAuthn secp256r1 passkey (default). * - {@link Ed25519Signer} — a local Stellar keypair. * - {@link PolicySigner} — a policy contract co-signer (no signature bytes). * * @packageDocumentation */ import { Keypair } from "@stellar/stellar-sdk"; import type { AuthenticationResponseJSON, PublicKeyCredentialRequestOptionsJSON } from "@simplewebauthn/browser"; import type { Signature as SDKSignature, SignerKey as SDKSignerKey } from "passkey-kit-sdk"; /** The WebAuthn `startAuthentication` surface a {@link PasskeySigner} needs. */ export interface WebAuthnAuthenticator { startAuthentication(args: { optionsJSON: PublicKeyCredentialRequestOptionsJSON; }): Promise; } /** Ambient context passed to every {@link Signer.sign} call by the kit. */ export interface SignerContext { /** WebAuthn Relying Party id (domain); defaults to the current origin. */ rpId?: string; /** The WebAuthn implementation (overridable for tests). */ webAuthn: WebAuthnAuthenticator; /** The connected wallet's default passkey keyId (base64url), when known. */ defaultKeyId?: string; } /** The on-chain `(SignerKey, Signature)` pair a signer produces. */ export interface PreparedSignature { key: SDKSignerKey; /** `undefined` for policy signers (the map stores `scvVoid` for the value). */ value: SDKSignature | undefined; } /** A signer for the wallet's flat `Signatures` map. */ export interface Signer { /** Authenticate a signature payload into an on-chain signature pair. */ sign(payload: Buffer, context: SignerContext): Promise | PreparedSignature; } /** * An Ed25519 signer backed by a local Stellar keypair. */ export declare class Ed25519Signer implements Signer { private readonly keypair; constructor(keypair: Keypair); /** * Build an {@link Ed25519Signer} from a Stellar secret key (`S…`). * * @throws {ValidationError} If the secret key is invalid. */ static fromSecret(secretKey: string): Ed25519Signer; /** The signer's `G…` public key. */ get address(): string; sign(payload: Buffer): PreparedSignature; } /** * A policy signer: a policy contract co-authorizes the entry. The map value is * `scvVoid`; the wallet calls the policy's `policy__` during `__check_auth`. */ export declare class PolicySigner implements Signer { private readonly policy; constructor(policy: string); sign(): PreparedSignature; } /** * A WebAuthn secp256r1 passkey signer. * * Pass a specific `keyId` to require that credential, `"any"` to let the * authenticator pick a discoverable credential, or omit it to use the kit's * connected passkey ({@link SignerContext.defaultKeyId}). */ export declare class PasskeySigner implements Signer { private readonly keyId; constructor(keyId?: "any" | string | Uint8Array); sign(payload: Buffer, context: SignerContext): Promise; } //# sourceMappingURL=signers.d.ts.map