@cavos/kit 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,6 @@
1
1
  import { Account } from 'starknet';
2
2
  import { PublicKey, Connection, TransactionInstruction, Keypair } from '@solana/web3.js';
3
+ import { Keypair as Keypair$1 } from '@stellar/stellar-sdk';
3
4
 
4
5
  /**
5
6
  * Identity for a Cavos wallet. Login (email / social / OTP) only ever produces a
@@ -114,6 +115,39 @@ declare class InMemoryWalletRegistry implements WalletRegistry {
114
115
  }): Promise<void>;
115
116
  }
116
117
 
118
+ /** A parsed passkey assertion, chain-agnostic. */
119
+ interface PasskeyAssertion {
120
+ authenticatorData: Uint8Array;
121
+ clientDataJSON: Uint8Array;
122
+ /** ECDSA signature components (raw, as returned by the authenticator). */
123
+ r: bigint;
124
+ s: bigint;
125
+ /** Byte index where the base64url challenge starts inside clientDataJSON. */
126
+ challengeOffset: number;
127
+ }
128
+ /** base64url (no padding) of a byte array. */
129
+ declare function base64urlEncode(bytes: Uint8Array): string;
130
+ /**
131
+ * Batch challenge over ordered per-chain leaves: `sha256(leaf_0 ‖ … ‖ leaf_n)`.
132
+ * A single passkey assertion over this challenge authorizes `add_signer` on every
133
+ * chain in the batch (each chain verifies only its own leaf sits at its index).
134
+ * For a single chain the batch is one leaf, so the challenge is `sha256(leaf)`.
135
+ */
136
+ declare function batchChallenge(leaves: Uint8Array[]): Uint8Array;
137
+ /** The WebAuthn signed digest: `sha256(authenticatorData || sha256(clientDataJSON))`. */
138
+ declare function webauthnDigest(authenticatorData: Uint8Array, clientDataJSON: Uint8Array): Uint8Array;
139
+ /** Both candidate public keys recoverable from `(r, s)` over `digest`, tagged
140
+ * with their y-parity. On a fresh browser the assertion does not carry the
141
+ * pubkey, so the caller identifies the real one via the on-chain `is_approver`
142
+ * view. */
143
+ declare function recoverCandidatePublicKeys(r: bigint, s: bigint, digest: Uint8Array): {
144
+ publicKey: DevicePublicKey;
145
+ yParity: boolean;
146
+ }[];
147
+ /** Normalize `s` to the low half of the curve order (required by the Stellar
148
+ * and Solana verifiers, which do not normalize on-chain). */
149
+ declare function lowS(s: bigint): bigint;
150
+
117
151
  /** An account meta candidate for a CPI instruction inside `execute`. Mirrors the
118
152
  * on-chain `AccountMetaCandidate` (Borsh). */
119
153
  interface InstructionAccount {
@@ -159,6 +193,27 @@ declare class SolanaAdapter {
159
193
  buildAddSigner(account: string, newSigner: DevicePublicKey): Promise<TransactionInstruction[]>;
160
194
  /** `[precompile, remove_signer]` bundle, authorized by an existing device signer. */
161
195
  buildRemoveSigner(account: string, signer: DevicePublicKey): Promise<TransactionInstruction[]>;
196
+ /** `[precompile, add_approver]` bundle enrolling a passkey approver (device-signed). */
197
+ buildAddApprover(account: string, passkey: DevicePublicKey): Promise<TransactionInstruction[]>;
198
+ /** `[precompile, remove_approver]` bundle (device-signed). */
199
+ buildRemoveApprover(account: string, passkey: DevicePublicKey): Promise<TransactionInstruction[]>;
200
+ /** This chain's leaf for approving `add_signer(newSigner)` at `nonce`:
201
+ * `sha256(compressed(new_signer) || passkey_nonce_le8)`. The batch challenge the
202
+ * passkey signs is `sha256(concat(leaves))` across chains. */
203
+ passkeyLeaf(newSigner: DevicePublicKey, nonce: bigint): Uint8Array;
204
+ /**
205
+ * `[precompile(passkey), add_signer_via_passkey]` bundle. The precompile ix
206
+ * verifies the PASSKEY's WebAuthn assertion over `authData || sha256(clientDataJSON)`;
207
+ * the program ix binds the challenge to `newSigner` + the passkey nonce and adds
208
+ * the signer. No device signature — a gasless relayer can submit it.
209
+ */
210
+ buildAddSignerViaPasskey(account: string, newSigner: DevicePublicKey, passkey: DevicePublicKey, leaves: Uint8Array[], leafIndex: number, assertion: PasskeyAssertion): TransactionInstruction[];
211
+ /** Read whether `passkey` is a registered approver. */
212
+ /** True if the account has at least one passkey registered as an approver. */
213
+ hasPasskeyApprover(account: string): Promise<boolean>;
214
+ isApprover(account: string, passkey: DevicePublicKey): Promise<boolean>;
215
+ /** Read the current passkey-approval nonce. */
216
+ passkeyNonce(account: string): Promise<bigint>;
162
217
  /** `[precompile, execute_transfer]` bundle moving lamports out of the account. */
163
218
  buildExecuteTransfer(account: string, destination: string, amount: bigint): Promise<TransactionInstruction[]>;
164
219
  /**
@@ -179,6 +234,7 @@ declare class SolanaAdapter {
179
234
  private signToPrecompile;
180
235
  private fetchNonce;
181
236
  private fetchSigners;
237
+ private fetchApprovers;
182
238
  private requireConnection;
183
239
  }
184
240
  /** Compressed SEC1 P-256 pubkey (33 bytes) from {x, y}. */
@@ -234,6 +290,49 @@ declare class SolanaRelayer {
234
290
  send(instructions: TransactionInstruction[]): Promise<string>;
235
291
  }
236
292
 
293
+ interface PasskeySignerOptions {
294
+ /** Relying-Party id (usually the eTLD+1). Defaults to `window.location.hostname`. */
295
+ rpId?: string;
296
+ /** Human-readable RP name shown in the OS passkey UI. */
297
+ rpName?: string;
298
+ }
299
+ interface PasskeyEnrollParams {
300
+ /** Stable user handle for the credential (e.g. the account address or userId). */
301
+ userId: string;
302
+ /** Account name shown in the OS passkey UI (e.g. an email). */
303
+ userName: string;
304
+ displayName?: string;
305
+ }
306
+ interface EnrolledPasskey {
307
+ publicKey: DevicePublicKey;
308
+ credentialId: Uint8Array;
309
+ }
310
+ /**
311
+ * Browser passkey signer. Creates a discoverable (resident) secp256r1 credential
312
+ * that syncs across the user's devices (iCloud Keychain / Google Password
313
+ * Manager), and produces WebAuthn assertions used to authorize `add_signer`.
314
+ *
315
+ * This is a step-up primitive: the app decides WHEN to enroll (e.g. after
316
+ * onboarding, as a "turn on device approvals" / 2FA moment). Enrollment
317
+ * registers the passkey on-chain as an approver; later, from any browser, an
318
+ * assertion approves adding that browser's new device key.
319
+ */
320
+ declare class PasskeySigner {
321
+ private readonly rpId;
322
+ private readonly rpName;
323
+ constructor(opts?: PasskeySignerOptions);
324
+ /** True if this platform advertises a usable passkey (platform authenticator). */
325
+ static isSupported(): Promise<boolean>;
326
+ /** Create a new synced passkey and return its P-256 public key. */
327
+ enroll(params: PasskeyEnrollParams): Promise<EnrolledPasskey>;
328
+ /**
329
+ * Produce a WebAuthn assertion over `challenge` (a 32-byte value the caller
330
+ * derives from the signer being added + the on-chain nonce). Uses discoverable
331
+ * credentials — no `allowCredentials` — so it works on a brand-new browser.
332
+ */
333
+ assert(challenge: Uint8Array): Promise<PasskeyAssertion>;
334
+ }
335
+
237
336
  interface ConnectSolanaOptions {
238
337
  network: SolanaNetwork;
239
338
  /** Authenticated user (pass `identity` directly, or an `auth` provider). */
@@ -263,7 +362,7 @@ interface ConnectSolanaOptions {
263
362
  */
264
363
  feePayer?: Keypair;
265
364
  }
266
- type ConnectStatus$1 = "ready" | "needs-device-approval";
365
+ type ConnectStatus$2 = "ready" | "needs-device-approval";
267
366
  /**
268
367
  * Options for recovering a Solana account after losing every device signer.
269
368
  * Mirrors `RecoveryOptions` (Starknet), adapted to the Solana path: the backup
@@ -308,7 +407,7 @@ interface RecoverSolanaOptions {
308
407
  declare class CavosSolana {
309
408
  readonly identity: Identity;
310
409
  readonly address: string;
311
- readonly status: ConnectStatus$1;
410
+ readonly status: ConnectStatus$2;
312
411
  readonly connection: Connection;
313
412
  private readonly adapter;
314
413
  private readonly devicePubkey;
@@ -316,11 +415,48 @@ declare class CavosSolana {
316
415
  private readonly feePayer?;
317
416
  /** Discriminant for the `CavosWallet` union — narrows `execute()` per chain. */
318
417
  readonly chain: "solana";
418
+ /** True when this connect just created a brand-new account (first sign-up). */
419
+ isNewAccount: boolean;
319
420
  private constructor();
320
421
  get publicKey(): DevicePublicKey;
321
422
  static connect(opts: ConnectSolanaOptions): Promise<CavosSolana>;
322
423
  /** Authorize an additional device signer (device-signed via precompile). */
323
424
  addSigner(pubkey: DevicePublicKey): Promise<string>;
425
+ /**
426
+ * Enroll a passkey as an approver (2FA-style step-up). Device-signed + gasless;
427
+ * requires a ready device. Idempotent. Returns the passkey pubkey + tx hash.
428
+ */
429
+ enrollPasskey(passkey: PasskeySigner, params: PasskeyEnrollParams): Promise<{
430
+ publicKey: DevicePublicKey;
431
+ transactionHash?: string;
432
+ }>;
433
+ /** Register an already-enrolled passkey pubkey as an approver (gasless).
434
+ * Idempotent. Lets one passkey be registered across chains without re-prompting. */
435
+ addApprover(pubkey: DevicePublicKey): Promise<{
436
+ transactionHash?: string;
437
+ }>;
438
+ /** True if this account already has a passkey enrolled as an approver, so a
439
+ * new device can be approved with the passkey instead of the email flow. */
440
+ hasPasskey(): Promise<boolean>;
441
+ /** Re-read (from chain) whether THIS device is now an authorized signer.
442
+ * Used to poll for readiness after a passkey approval before it's indexed. */
443
+ isReady(): Promise<boolean>;
444
+ /**
445
+ * From a fresh browser (status `needs-device-approval`), approve adding THIS
446
+ * device with the user's synced passkey. Gasless via the relayer — the bundle
447
+ * carries the passkey's WebAuthn assertion, so no device signature is needed.
448
+ */
449
+ approveThisDeviceWithPasskey(passkey: PasskeySigner): Promise<string>;
450
+ /** This device's leaf + passkey nonce for a (possibly multi-chain) batch. */
451
+ passkeyLeafForThisDevice(): Promise<{
452
+ leaf: Uint8Array;
453
+ nonce: bigint;
454
+ }>;
455
+ /** Submit `add_signer_via_passkey` given a shared assertion + batch position.
456
+ * Used by `approveThisDeviceWithPasskey` and `approveDeviceEverywhere`. */
457
+ submitPasskeyApproval(assertion: PasskeyAssertion, leaves: Uint8Array[], leafIndex: number, _nonce: bigint): Promise<{
458
+ transactionHash: string;
459
+ }>;
324
460
  /** Move `amount` lamports out of the account to `destination` (device-signed). */
325
461
  execute(amount: bigint, destination: string): Promise<string>;
326
462
  /**
@@ -362,6 +498,204 @@ declare class CavosSolana {
362
498
  private send;
363
499
  }
364
500
 
501
+ /** Cavos device-account primitives on Stellar / Soroban. */
502
+ /**
503
+ * Deployed `cavos-account-factory` contract id per network (see
504
+ * account-contracts/stellar/deployments). The factory is the fixed deployer that
505
+ * makes account addresses a deterministic function of (identity, device pubkey).
506
+ */
507
+ declare const FACTORY_CONTRACT_ID: {
508
+ readonly "stellar-testnet": "CBCJIODXIEBOXXD66KCUCF7ZDYJARKI4ZIVQOVWPULOBH5XGNCDP6W3I";
509
+ readonly "stellar-mainnet": "";
510
+ };
511
+ /** Uploaded Wasm hash of `cavos-device-account` (informational / verification). */
512
+ declare const DEVICE_ACCOUNT_WASM_HASH: {
513
+ readonly "stellar-testnet": "2671b085578e59a385ef5a5664e42f0450322fe3249539f588e1263ed5a31dce";
514
+ readonly "stellar-mainnet": "";
515
+ };
516
+ declare const STELLAR_NETWORKS: {
517
+ readonly "stellar-testnet": {
518
+ readonly rpcUrl: "https://soroban-testnet.stellar.org";
519
+ readonly passphrase: "Test SDF Network ; September 2015";
520
+ };
521
+ readonly "stellar-mainnet": {
522
+ readonly rpcUrl: "https://soroban-rpc.mainnet.stellar.gateway.fm";
523
+ readonly passphrase: "Public Global Stellar Network ; September 2015";
524
+ };
525
+ };
526
+ type StellarNetwork = keyof typeof STELLAR_NETWORKS;
527
+ /** Native XLM Stellar Asset Contract (SAC) id per network — the token the demo
528
+ * moves. Any SEP-41 token contract works; this is a convenience default. */
529
+ declare const NATIVE_SAC_ID: {
530
+ readonly "stellar-testnet": "CDLZFC3SYJYDZT7K67VZ75HPJVIEUVNIXF47ZG2FB2RMQQVU2HHGCYSC";
531
+ readonly "stellar-mainnet": "CAS3J7GYLGXMF6TDJBBYYSE3HQ6BBSMLNUQ34T6TZMYMW2EVH34XOWMA";
532
+ };
533
+
534
+ interface StellarRelayerOptions {
535
+ /** Base URL of the Cavos backend exposing /api/stellar/relay. */
536
+ baseUrl: string;
537
+ /** Cavos App ID (authorizes the sponsored request). */
538
+ appId: string;
539
+ network: StellarNetwork;
540
+ }
541
+ /**
542
+ * Client for the Cavos Stellar sponsoring relayer. On Stellar the account is a
543
+ * *contract*, which cannot be a transaction source — so the relayer's own
544
+ * G-account is the transaction source AND fee payer. The user's silent device
545
+ * key never pays: it only signs the Soroban *authorization entry* (verified by
546
+ * the account's `__check_auth`), which is independent of who submits or pays.
547
+ * That gives a seedless, gasless experience with no fee-payer keypair on the
548
+ * integrator side — the same "relayer pays, device authorizes" split as Solana.
549
+ *
550
+ * The SDK builds the fully-assembled transaction (source = relayer, Soroban auth
551
+ * entries already device-signed) and hands its unsigned XDR to the relayer, which
552
+ * validates it against its allowlist, signs the envelope and submits.
553
+ */
554
+ declare class StellarRelayer {
555
+ private readonly opts;
556
+ private source?;
557
+ constructor(opts: StellarRelayerOptions);
558
+ /** The relayer's source/fee-payer G-account (fetched + cached from the backend). */
559
+ getSource(): Promise<string>;
560
+ /**
561
+ * POST the assembled, device-authorized transaction XDR to the relayer to sign
562
+ * the envelope + submit. Returns the confirmed transaction hash.
563
+ */
564
+ submit(transactionXdr: string): Promise<string>;
565
+ }
566
+
567
+ interface ConnectStellarOptions {
568
+ network: StellarNetwork;
569
+ /** Authenticated user (pass `identity` directly, or an `auth` provider). */
570
+ auth?: AuthProvider;
571
+ identity?: Identity;
572
+ appSalt: string;
573
+ appId?: string;
574
+ backendUrl?: string;
575
+ registry?: WalletRegistry;
576
+ /** RPC override (else the network default). */
577
+ rpcUrl?: string;
578
+ /** Factory contract id override (else the per-network default). */
579
+ factoryId?: string;
580
+ /** Override the device signer factory (native / tests); default WebCrypto. */
581
+ createSigner?: (keyId: string) => Promise<DeviceSigner>;
582
+ /**
583
+ * Gasless sponsorship via the Cavos relayer. When set (or when `appId` +
584
+ * `backendUrl` are given) the relayer is the transaction source + fee payer, so
585
+ * the integrator needs NO Stellar keypair — the silent device key (which holds
586
+ * no XLM) gets a seedless, gasless experience.
587
+ */
588
+ relayer?: StellarRelayer;
589
+ /**
590
+ * Self-funded fallback: a Stellar `Keypair` that is the transaction source +
591
+ * fee payer. Used only when no `relayer` is configured (tests / advanced).
592
+ */
593
+ sourceKeypair?: Keypair$1;
594
+ }
595
+ interface RecoverStellarOptions extends Omit<ConnectStellarOptions, "auth"> {
596
+ /** The recovery code the user stored when they ran setupRecovery. */
597
+ code: string;
598
+ /** Authenticated identity (same user who owns the account). */
599
+ identity: Identity;
600
+ }
601
+ type ConnectStatus$1 = "ready" | "needs-device-approval";
602
+ /**
603
+ * High-level Stellar entry — the Soroban analogue of `Cavos.connect` /
604
+ * `CavosSolana.connect`. One call derives the deterministic device-bound account,
605
+ * deploys it via the factory if needed, registers it for cross-device
606
+ * recognition, and returns a ready handle whose silent P-256 device key
607
+ * authorizes every action through the account's `__check_auth`.
608
+ *
609
+ * const cavos = await CavosStellar.connect({ network: "stellar-testnet", identity, appSalt, relayer });
610
+ * if (cavos.status === "ready") await cavos.execute(10_000_000n, dest); // 1 XLM
611
+ *
612
+ * Gasless by default: with an `appId` the Cavos relayer is the tx source + fee
613
+ * payer. `sourceKeypair` is the self-funded fallback.
614
+ */
615
+ declare class CavosStellar {
616
+ readonly identity: Identity;
617
+ readonly address: string;
618
+ readonly status: ConnectStatus$1;
619
+ readonly network: StellarNetwork;
620
+ private readonly adapter;
621
+ private readonly devicePubkey;
622
+ private readonly relayer?;
623
+ private readonly sourceKeypair?;
624
+ /** Discriminant for the `CavosWallet` union — narrows `execute()` per chain. */
625
+ readonly chain: "stellar";
626
+ /** True when this connect just created a brand-new account (first sign-up). */
627
+ isNewAccount: boolean;
628
+ private constructor();
629
+ get publicKey(): DevicePublicKey;
630
+ static connect(opts: ConnectStellarOptions): Promise<CavosStellar>;
631
+ /** Authorize an additional device signer (device-signed via `__check_auth`). */
632
+ addSigner(pubkey: DevicePublicKey): Promise<string>;
633
+ /**
634
+ * Enroll a passkey as an approver (2FA-style step-up). Device-signed + gasless;
635
+ * requires a ready device. Idempotent. Returns the passkey pubkey + tx hash.
636
+ */
637
+ enrollPasskey(passkey: PasskeySigner, params: PasskeyEnrollParams): Promise<{
638
+ publicKey: DevicePublicKey;
639
+ transactionHash?: string;
640
+ }>;
641
+ /** Register an already-enrolled passkey pubkey as an approver (gasless).
642
+ * Idempotent. Lets one passkey be registered across chains without re-prompting. */
643
+ addApprover(pubkey: DevicePublicKey): Promise<{
644
+ transactionHash?: string;
645
+ }>;
646
+ /** True if this account already has a passkey enrolled as an approver, so a
647
+ * new device can be approved with the passkey instead of the email flow. */
648
+ hasPasskey(): Promise<boolean>;
649
+ /** Re-read (from chain) whether THIS device is now an authorized signer.
650
+ * Used to poll for readiness after a passkey approval before it's indexed. */
651
+ isReady(): Promise<boolean>;
652
+ /**
653
+ * From a fresh browser (status `needs-device-approval`), approve adding THIS
654
+ * device using the user's synced passkey. Gasless via the relayer — the call
655
+ * carries the WebAuthn assertion, so no device signature is needed. Returns the
656
+ * tx hash. No trip back to an already-authorized device.
657
+ */
658
+ approveThisDeviceWithPasskey(passkey: PasskeySigner): Promise<string>;
659
+ /** This device's leaf + passkey nonce for a (possibly multi-chain) batch. */
660
+ passkeyLeafForThisDevice(): Promise<{
661
+ leaf: Uint8Array;
662
+ nonce: bigint;
663
+ }>;
664
+ /** Submit `add_signer_via_passkey` given a shared assertion + batch position.
665
+ * No device auth entry — authorized purely by the passkey assertion. */
666
+ submitPasskeyApproval(assertion: PasskeyAssertion, leaves: Uint8Array[], leafIndex: number, nonce: bigint): Promise<{
667
+ transactionHash: string;
668
+ }>;
669
+ /** Move `amount` stroops of native XLM to `destination` (device-signed). */
670
+ execute(amount: bigint, destination: string): Promise<string>;
671
+ /** Read this account's balance of `tokenId` (defaults to native XLM), in stroops. */
672
+ balance(tokenId?: string): Promise<bigint>;
673
+ /** Transfer `amount` of any SEP-41 token out of the account (device-signed). */
674
+ executeTransfer(tokenId: string, amount: bigint, destination: string): Promise<string>;
675
+ /**
676
+ * Register the backup signer derived from `code` as an authorized signer of
677
+ * this account (device-signed). Idempotent. The code never leaves the device —
678
+ * only the derived public key travels on-chain. Mirrors the other chains.
679
+ */
680
+ setupRecovery(code: string): Promise<string | undefined>;
681
+ /**
682
+ * Recover an account after losing every device signer: derive the backup key
683
+ * from `code`, use it (not the new device) to authorize `add_signer(newDevice)`,
684
+ * and return a ready handle bound to the new device. The address is unchanged.
685
+ */
686
+ static recover(opts: RecoverStellarOptions): Promise<CavosStellar>;
687
+ /** The transaction source/fee-payer G-address (relayer or self-funded). */
688
+ private resolveSource;
689
+ /**
690
+ * Build → simulate → device-sign auth → assemble → submit an invoke-contract
691
+ * host function. `authAccount` is the account whose `__check_auth` must sign the
692
+ * operation's Soroban auth entry (undefined for a plain factory deploy).
693
+ */
694
+ private submitHostFunction;
695
+ /** Submit a signed tx via RPC and poll to confirmation. Returns the hash. */
696
+ private sendAndConfirm;
697
+ }
698
+
365
699
  /** A chain-native contract call (Starknet `Call`-shaped; generic for portability). */
366
700
  interface ChainCall {
367
701
  contractAddress: string;
@@ -445,14 +779,14 @@ interface PendingDeviceRequest {
445
779
  }
446
780
 
447
781
  /** The chains the unified `Cavos.connect` can target. */
448
- type Chain = "starknet" | "solana";
782
+ type Chain = "starknet" | "solana" | "stellar";
449
783
  /**
450
784
  * Environment selector. `Cavos.connect` resolves it to the chain's concrete
451
785
  * network: starknet → sepolia/mainnet, solana → solana-devnet/solana-mainnet.
452
786
  */
453
787
  type NetworkEnv = "mainnet" | "testnet";
454
788
  /** A connected wallet: discriminated by `chain`, so `execute()` stays native. */
455
- type CavosWallet = Cavos | CavosSolana;
789
+ type CavosWallet = Cavos | CavosSolana | CavosStellar;
456
790
  interface ConnectOptions {
457
791
  /** Target chain. The returned wallet is discriminated by this same value. */
458
792
  chain: Chain;
@@ -493,6 +827,12 @@ interface ConnectOptions {
493
827
  relayer?: SolanaRelayer;
494
828
  /** Self-funded fee-payer fallback when no relayer is configured. */
495
829
  feePayer?: Keypair;
830
+ /** Gasless sponsorship relayer (defaults to the hosted one when `appId` set). */
831
+ stellarRelayer?: StellarRelayer;
832
+ /** Self-funded source/fee-payer Stellar keypair when no relayer is configured. */
833
+ stellarSourceKeypair?: Keypair$1;
834
+ /** Factory contract id override (else the per-network default). */
835
+ factoryId?: string;
496
836
  }
497
837
  /** Whether this device can already operate the wallet, or needs to be added. */
498
838
  type ConnectStatus = "ready" | "needs-device-approval";
@@ -535,10 +875,15 @@ declare class Cavos {
535
875
  readonly account: Account;
536
876
  private readonly adapter;
537
877
  private readonly devicePubkey;
878
+ /** Paymaster URL + API key, for the sponsored passkey-approval path. */
879
+ private readonly paymaster?;
538
880
  /** Discriminant for the `CavosWallet` union — narrows `execute()` per chain. */
539
881
  readonly chain: "starknet";
540
882
  /** Request id of the pending device-addition, when status is needs-device-approval. */
541
883
  pendingRequestId: string | null;
884
+ /** True when this connect just created & deployed a brand-new account (first
885
+ * sign-up), so the UI can offer a one-time "secure your account" step. */
886
+ isNewAccount: boolean;
542
887
  private constructor();
543
888
  /**
544
889
  * Unified entry point. Pick a `chain` and an `network` environment; the kit
@@ -562,6 +907,67 @@ declare class Cavos {
562
907
  addSigner(pubkey: DevicePublicKey): Promise<{
563
908
  transactionHash: string;
564
909
  }>;
910
+ /**
911
+ * Enroll a passkey as an APPROVER so the user can later add devices from any
912
+ * browser (2FA-style step-up). Requires a ready device (the enrollment call is
913
+ * device-signed and gasless). Idempotent: a no-op if the passkey is already an
914
+ * approver. Call this whenever the app decides to prompt "turn on device
915
+ * approvals". Returns the passkey's public key + the enrollment tx hash.
916
+ */
917
+ enrollPasskey(passkey: PasskeySigner, params: PasskeyEnrollParams): Promise<{
918
+ publicKey: DevicePublicKey;
919
+ transactionHash?: string;
920
+ }>;
921
+ /**
922
+ * Register an ALREADY-enrolled passkey public key as an approver (gasless,
923
+ * device-signed). Idempotent. Use this to register ONE passkey across multiple
924
+ * chains without re-prompting `passkey.enroll()` on each: enroll once, then
925
+ * call `addApprover(pubkey)` on each chain's wallet.
926
+ */
927
+ addApprover(pubkey: DevicePublicKey): Promise<{
928
+ transactionHash?: string;
929
+ }>;
930
+ /** True if this account already has a passkey enrolled as an approver, so a
931
+ * new device can be approved with the passkey instead of the email flow. */
932
+ hasPasskey(): Promise<boolean>;
933
+ /** Re-read (from chain) whether THIS device is now an authorized signer.
934
+ * Cheap and side-effect free — used to poll for readiness after a passkey /
935
+ * device approval submits, before the new signer is indexed. */
936
+ isReady(): Promise<boolean>;
937
+ /**
938
+ * From a brand-new browser (status `needs-device-approval`), use the user's
939
+ * synced passkey to authorize adding THIS device — no trip back to an already-
940
+ * authorized device.
941
+ *
942
+ * `add_signer_via_passkey` is a public external authorized by the embedded
943
+ * WebAuthn assertion (no device signature), so by default we sponsor it through
944
+ * the Cavos paymaster's `paymaster_executeDirectTransaction` (the forwarder's
945
+ * `execute_sponsored` runs a generic call — it does NOT require SNIP-9). Pass a
946
+ * custom `submit` to route it through your own relayer instead. Returns the tx.
947
+ */
948
+ approveThisDeviceWithPasskey(opts: {
949
+ passkey: PasskeySigner;
950
+ submit?: (call: ChainCall) => Promise<{
951
+ transactionHash: string;
952
+ }>;
953
+ }): Promise<{
954
+ transactionHash: string;
955
+ }>;
956
+ /** This device's leaf + the current passkey nonce, for a (possibly multi-chain)
957
+ * passkey approval batch. See `approveDeviceEverywhere`. */
958
+ passkeyLeafForThisDevice(): Promise<{
959
+ leaf: Uint8Array;
960
+ nonce: bigint;
961
+ }>;
962
+ /** Submit `add_signer_via_passkey` given a (shared) assertion + this chain's
963
+ * position in the batch. The assertion doesn't carry the passkey pubkey, so we
964
+ * recover both candidates and pick the enrolled approver via the on-chain view
965
+ * (no backend). Defaults to sponsoring through the paymaster. */
966
+ submitPasskeyApproval(assertion: PasskeyAssertion, leaves: Uint8Array[], leafIndex: number, nonce: bigint, submit?: (call: ChainCall) => Promise<{
967
+ transactionHash: string;
968
+ }>): Promise<{
969
+ transactionHash: string;
970
+ }>;
565
971
  /**
566
972
  * Register a self-custodial backup signer derived from `code`, so the account
567
973
  * can be recovered after the user loses every device. Idempotent: if the
@@ -586,5 +992,32 @@ declare class Cavos {
586
992
  */
587
993
  static recover(opts: RecoveryOptions): Promise<Cavos>;
588
994
  }
995
+ /** A chain wallet that can approve THIS device via a passkey (implemented by
996
+ * `Cavos`, `CavosSolana`, `CavosStellar`). */
997
+ interface PasskeyApprovable {
998
+ readonly chain: string;
999
+ readonly status: string;
1000
+ passkeyLeafForThisDevice(): Promise<{
1001
+ leaf: Uint8Array;
1002
+ nonce: bigint;
1003
+ }>;
1004
+ submitPasskeyApproval(assertion: PasskeyAssertion, leaves: Uint8Array[], leafIndex: number, nonce: bigint): Promise<{
1005
+ transactionHash: string;
1006
+ }>;
1007
+ }
1008
+ /**
1009
+ * Approve THIS device across several chains with a SINGLE passkey prompt. Each
1010
+ * chain is a separate account, so the device must be added per chain — but one
1011
+ * WebAuthn assertion over the batch challenge (`sha256(concat(leaves))`) suffices
1012
+ * for all of them. Only wallets whose status is `needs-device-approval` are
1013
+ * touched. Returns the per-chain tx hashes.
1014
+ *
1015
+ * await approveDeviceEverywhere([starknet, solana, stellar], passkey);
1016
+ */
1017
+ declare function approveDeviceEverywhere(wallets: PasskeyApprovable[], passkey: PasskeySigner): Promise<{
1018
+ chain: string;
1019
+ transactionHash?: string;
1020
+ error?: string;
1021
+ }[]>;
589
1022
 
590
- export { type AuthProvider as A, buildSecp256r1Instruction as B, type ChainAdapter as C, type DevicePublicKey as D, compressedPubkey as E, encodeLowSSignature as F, serializeInstructions as G, type Identity as I, type NetworkEnv as N, type PendingDeviceRequest as P, type RegisteredWallet as R, SECP256R1_PROGRAM_ID as S, type WalletRegistry as W, type RecoveryClient as a, type DeviceSigner as b, type DeviceSignature as c, type ComputeAddressParams as d, type ChainCall as e, Cavos as f, CavosSolana as g, type CavosWallet as h, type Chain as i, type ConnectOptions as j, type ConnectSolanaOptions as k, type ConnectStatus as l, DEVICE_ACCOUNT_PROGRAM_ID as m, InMemoryWalletRegistry as n, type InstructionAccount as o, type InstructionData as p, type RecoverSolanaOptions as q, type RecoveryOptions as r, SOLANA_NETWORKS as s, SolanaAdapter as t, type SolanaAdapterOptions as u, type SolanaNetwork as v, SolanaRelayer as w, type SolanaRelayerOptions as x, StaticIdentity as y, anchorDiscriminator as z };
1023
+ export { batchChallenge as $, type AuthProvider as A, type RecoverStellarOptions as B, type ChainAdapter as C, type DevicePublicKey as D, type EnrolledPasskey as E, FACTORY_CONTRACT_ID as F, type RecoveryOptions as G, SECP256R1_PROGRAM_ID as H, type Identity as I, SOLANA_NETWORKS as J, STELLAR_NETWORKS as K, SolanaAdapter as L, type SolanaAdapterOptions as M, NATIVE_SAC_ID as N, type SolanaNetwork as O, type PendingDeviceRequest as P, SolanaRelayer as Q, type RegisteredWallet as R, type StellarNetwork as S, type SolanaRelayerOptions as T, StaticIdentity as U, StellarRelayer as V, type WalletRegistry as W, type StellarRelayerOptions as X, anchorDiscriminator as Y, approveDeviceEverywhere as Z, base64urlEncode as _, type RecoveryClient as a, buildSecp256r1Instruction as a0, compressedPubkey as a1, encodeLowSSignature as a2, lowS as a3, recoverCandidatePublicKeys as a4, serializeInstructions as a5, webauthnDigest as a6, type DeviceSigner as b, type DeviceSignature as c, type ComputeAddressParams as d, type ChainCall as e, type PasskeyAssertion as f, Cavos as g, CavosSolana as h, CavosStellar as i, type CavosWallet as j, type Chain as k, type ConnectOptions as l, type ConnectSolanaOptions as m, type ConnectStatus as n, type ConnectStellarOptions as o, DEVICE_ACCOUNT_PROGRAM_ID as p, DEVICE_ACCOUNT_WASM_HASH as q, InMemoryWalletRegistry as r, type InstructionAccount as s, type InstructionData as t, type NetworkEnv as u, type PasskeyApprovable as v, type PasskeyEnrollParams as w, PasskeySigner as x, type PasskeySignerOptions as y, type RecoverSolanaOptions as z };