@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.
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { BackupSigner, Cavos, CavosAuth, CavosSolana, DEVICE_ACCOUNT_CLASS_HASH, DEVICE_ACCOUNT_PROGRAM_ID, HttpRecoveryClient, HttpWalletRegistry, InMemoryWalletRegistry, SECP256R1_PROGRAM_ID, SOLANA_NETWORKS, STARKNET_NETWORKS, SolanaAdapter, SolanaRelayer, StarknetAdapter, StarknetDeviceSigner, UDC_ADDRESS, WebCryptoSigner, anchorDiscriminator, bigIntTo32Bytes, buildSecp256r1Instruction, bytesToBigInt, bytesToHex, compressedPubkey, deriveAddressSeed, deriveAddressSeedSolana, deriveBackupKey, encodeLowSSignature, generateRecoveryCode, hexToBytes, recoverYParity, serializeInstructions, signatureToFelts, u256ToFelts } from './chunk-PEUQQZB5.mjs';
1
+ export { BackupSigner, Cavos, CavosAuth, CavosSolana, CavosStellar, DEVICE_ACCOUNT_CLASS_HASH, DEVICE_ACCOUNT_PROGRAM_ID, DEVICE_ACCOUNT_WASM_HASH, FACTORY_CONTRACT_ID, HttpRecoveryClient, HttpWalletRegistry, InMemoryWalletRegistry, NATIVE_SAC_ID, PasskeySigner, SECP256R1_PROGRAM_ID, SOLANA_NETWORKS, STARKNET_NETWORKS, STELLAR_NETWORKS, SolanaAdapter, SolanaRelayer, StarknetAdapter, StarknetDeviceSigner, StellarAdapter, StellarRelayer, UDC_ADDRESS, WebCryptoSigner, anchorDiscriminator, approveDeviceEverywhere, base64urlEncode, batchChallenge, bigIntTo32Bytes, buildSecp256r1Instruction, bytesToBigInt, bytesToHex, compressedPubkey, deriveAddressSeed, deriveAddressSeedSolana, deriveAddressSeedStellar, deriveBackupKey, deviceSignatureScVal, encodeLowSSignature, encodeLowSSignature2 as encodeStellarLowSSignature, generateRecoveryCode, hexToBytes, lowS, recoverCandidatePublicKeys, recoverYParity, sec1Pubkey, serializeInstructions, signatureToFelts, u256ToFelts, webauthnDigest } from './chunk-F2J25XSL.mjs';
2
2
 
3
3
  // src/auth/AuthProvider.ts
4
4
  var StaticIdentity = class {
@@ -1,8 +1,9 @@
1
1
  import * as react from 'react';
2
2
  import react__default, { ReactNode } from 'react';
3
- import { i as Chain, N as NetworkEnv, h as CavosWallet, e as ChainCall } from '../Cavos-C2KHZxxu.mjs';
3
+ import { k as Chain, u as NetworkEnv, j as CavosWallet, e as ChainCall, x as PasskeySigner, w as PasskeyEnrollParams } from '../Cavos-x9qFpOvJ.mjs';
4
4
  import 'starknet';
5
5
  import '@solana/web3.js';
6
+ import '@stellar/stellar-sdk';
6
7
 
7
8
  interface CavosConfig {
8
9
  /** Cavos App ID from the dashboard. */
@@ -43,6 +44,12 @@ interface WalletStatus {
43
44
  awaitingApproval: boolean;
44
45
  /** The pending device-addition request id, when awaitingApproval. */
45
46
  pendingRequestId: string | null;
47
+ /** True if the account already has a passkey enrolled as an approver, so the
48
+ * modal can offer passkey approval over email on the new-device path. */
49
+ hasPasskey: boolean;
50
+ /** True right after a brand-new account is created (first sign-up), so the UI
51
+ * can offer a one-time "secure your account" step. Cleared once handled. */
52
+ isNewAccount: boolean;
46
53
  }
47
54
  interface UserInfo {
48
55
  userId: string;
@@ -55,12 +62,12 @@ interface CavosContextValue {
55
62
  closeModal: () => void;
56
63
  isAuthenticated: boolean;
57
64
  user: UserInfo | null;
58
- /** The active chain ('starknet' | 'solana'). */
65
+ /** The active chain ('starknet' | 'solana' | 'stellar'). */
59
66
  chain: Chain;
60
67
  /**
61
- * The raw connected wallet, discriminated by `wallet.chain`. Use this for
62
- * chain-native calls (e.g. Solana `wallet.execute(amount, dest)`); narrow on
63
- * `wallet.chain` first. Null until connected.
68
+ * The connected wallet, discriminated by `wallet.chain`. Narrow on
69
+ * `wallet.chain` before chain-native calls (e.g. Solana `wallet.execute(amount,
70
+ * dest)`). Null until connected.
64
71
  */
65
72
  wallet: CavosWallet | null;
66
73
  address: string | null;
@@ -81,7 +88,7 @@ interface CavosContextValue {
81
88
  verifyOtp: (email: string, code: string) => Promise<void>;
82
89
  /** Resolve identity from an OAuth callback (?auth_data=…) and deploy. */
83
90
  handleCallback: (authData: string) => Promise<void>;
84
- /** Execute a sponsored (gasless) multicall, signed by the device key. */
91
+ /** Execute a sponsored (gasless) multicall, signed by the device key (Starknet). */
85
92
  execute: (calls: ChainCall[]) => Promise<{
86
93
  transactionHash: string;
87
94
  }>;
@@ -95,34 +102,59 @@ interface CavosContextValue {
95
102
  /** Re-request the device-approval email for the current pending request. */
96
103
  resendDeviceApproval: () => Promise<void>;
97
104
  /**
98
- * Register a backup signer derived from `code` on the current account
99
- * (gasless). The code is generated by the kit and shown to the user once.
100
- * Resolves with the code so the caller can display it.
105
+ * Enroll a passkey as an approver (2FA-style step-up). Requires a ready device;
106
+ * returns the passkey's public key.
107
+ */
108
+ enrollPasskey: (passkey: PasskeySigner, params: PasskeyEnrollParams) => Promise<{
109
+ publicKey: {
110
+ x: bigint;
111
+ y: bigint;
112
+ };
113
+ transactionHash?: string;
114
+ }>;
115
+ /** Whether this device can use a platform passkey (Face ID / Touch ID / PIN). */
116
+ passkeySupported: boolean;
117
+ /**
118
+ * Modal-friendly wrapper: enroll a synced passkey as an approver using the
119
+ * signed-in user's identity + the app name. Requires a ready device.
120
+ */
121
+ enrollPasskeyDefault: () => Promise<void>;
122
+ /**
123
+ * Modal-friendly wrapper for the new-device flow: prompt the user's synced
124
+ * passkey to approve THIS device, then refresh to a ready state. Sponsored by
125
+ * the default paymaster/relayer.
126
+ */
127
+ approveDeviceWithPasskey: () => Promise<void>;
128
+ /**
129
+ * Register a backup signer derived from a generated recovery code (gasless).
130
+ * Resolves with the code so the caller can display it once.
101
131
  */
102
132
  setupRecovery: () => Promise<string>;
103
133
  /**
104
- * Recover access after losing every device. Requires the recovery code. Runs
105
- * the full Cavos.recover flow and brings the provider to a ready state.
134
+ * Recover access after losing every device. Requires the recovery code. Brings
135
+ * the provider to a ready state.
106
136
  */
107
137
  recover: (code: string) => Promise<void>;
108
138
  logout: () => void;
109
139
  }
110
140
  interface CavosProviderProps {
141
+ /** A single chain config. The provider manages exactly one chain. */
111
142
  config: CavosConfig;
112
143
  modal?: CavosModalConfig;
113
144
  children: ReactNode;
114
145
  }
115
146
  /**
116
- * Drop-in Cavos provider. Wrap your app once; descendants call `useCavos()`.
147
+ * Drop-in Cavos provider for ONE chain. Wrap your app once; descendants call
148
+ * `useCavos()`.
117
149
  *
118
- * <CavosProvider config={{ network: 'sepolia', appSalt, paymasterApiKey }}
119
- * modal={{ appName: 'My App', theme: 'dark', emailMode: 'otp' }}>
150
+ * <CavosProvider config={{ chain: 'solana', network: 'testnet', appId, appSalt }}
151
+ * modal={{ appName: 'My App', theme: 'dark' }}>
120
152
  * <App />
121
153
  * </CavosProvider>
122
154
  *
123
155
  * Behind the scenes: login (social / email) resolves a stable identity, the kit
124
- * deploys a device-signer smart account gaslessly, and `execute()` submits
125
- * gasless multicalls signed silently by the browser's device key.
156
+ * deploys a device-signer smart account gaslessly, and the wallet handle submits
157
+ * gasless transactions signed silently by the browser's device key.
126
158
  */
127
159
  declare function CavosProvider({ config, modal, children }: CavosProviderProps): react.JSX.Element;
128
160
  declare function useCavos(): CavosContextValue;
@@ -1,8 +1,9 @@
1
1
  import * as react from 'react';
2
2
  import react__default, { ReactNode } from 'react';
3
- import { i as Chain, N as NetworkEnv, h as CavosWallet, e as ChainCall } from '../Cavos-C2KHZxxu.js';
3
+ import { k as Chain, u as NetworkEnv, j as CavosWallet, e as ChainCall, x as PasskeySigner, w as PasskeyEnrollParams } from '../Cavos-x9qFpOvJ.js';
4
4
  import 'starknet';
5
5
  import '@solana/web3.js';
6
+ import '@stellar/stellar-sdk';
6
7
 
7
8
  interface CavosConfig {
8
9
  /** Cavos App ID from the dashboard. */
@@ -43,6 +44,12 @@ interface WalletStatus {
43
44
  awaitingApproval: boolean;
44
45
  /** The pending device-addition request id, when awaitingApproval. */
45
46
  pendingRequestId: string | null;
47
+ /** True if the account already has a passkey enrolled as an approver, so the
48
+ * modal can offer passkey approval over email on the new-device path. */
49
+ hasPasskey: boolean;
50
+ /** True right after a brand-new account is created (first sign-up), so the UI
51
+ * can offer a one-time "secure your account" step. Cleared once handled. */
52
+ isNewAccount: boolean;
46
53
  }
47
54
  interface UserInfo {
48
55
  userId: string;
@@ -55,12 +62,12 @@ interface CavosContextValue {
55
62
  closeModal: () => void;
56
63
  isAuthenticated: boolean;
57
64
  user: UserInfo | null;
58
- /** The active chain ('starknet' | 'solana'). */
65
+ /** The active chain ('starknet' | 'solana' | 'stellar'). */
59
66
  chain: Chain;
60
67
  /**
61
- * The raw connected wallet, discriminated by `wallet.chain`. Use this for
62
- * chain-native calls (e.g. Solana `wallet.execute(amount, dest)`); narrow on
63
- * `wallet.chain` first. Null until connected.
68
+ * The connected wallet, discriminated by `wallet.chain`. Narrow on
69
+ * `wallet.chain` before chain-native calls (e.g. Solana `wallet.execute(amount,
70
+ * dest)`). Null until connected.
64
71
  */
65
72
  wallet: CavosWallet | null;
66
73
  address: string | null;
@@ -81,7 +88,7 @@ interface CavosContextValue {
81
88
  verifyOtp: (email: string, code: string) => Promise<void>;
82
89
  /** Resolve identity from an OAuth callback (?auth_data=…) and deploy. */
83
90
  handleCallback: (authData: string) => Promise<void>;
84
- /** Execute a sponsored (gasless) multicall, signed by the device key. */
91
+ /** Execute a sponsored (gasless) multicall, signed by the device key (Starknet). */
85
92
  execute: (calls: ChainCall[]) => Promise<{
86
93
  transactionHash: string;
87
94
  }>;
@@ -95,34 +102,59 @@ interface CavosContextValue {
95
102
  /** Re-request the device-approval email for the current pending request. */
96
103
  resendDeviceApproval: () => Promise<void>;
97
104
  /**
98
- * Register a backup signer derived from `code` on the current account
99
- * (gasless). The code is generated by the kit and shown to the user once.
100
- * Resolves with the code so the caller can display it.
105
+ * Enroll a passkey as an approver (2FA-style step-up). Requires a ready device;
106
+ * returns the passkey's public key.
107
+ */
108
+ enrollPasskey: (passkey: PasskeySigner, params: PasskeyEnrollParams) => Promise<{
109
+ publicKey: {
110
+ x: bigint;
111
+ y: bigint;
112
+ };
113
+ transactionHash?: string;
114
+ }>;
115
+ /** Whether this device can use a platform passkey (Face ID / Touch ID / PIN). */
116
+ passkeySupported: boolean;
117
+ /**
118
+ * Modal-friendly wrapper: enroll a synced passkey as an approver using the
119
+ * signed-in user's identity + the app name. Requires a ready device.
120
+ */
121
+ enrollPasskeyDefault: () => Promise<void>;
122
+ /**
123
+ * Modal-friendly wrapper for the new-device flow: prompt the user's synced
124
+ * passkey to approve THIS device, then refresh to a ready state. Sponsored by
125
+ * the default paymaster/relayer.
126
+ */
127
+ approveDeviceWithPasskey: () => Promise<void>;
128
+ /**
129
+ * Register a backup signer derived from a generated recovery code (gasless).
130
+ * Resolves with the code so the caller can display it once.
101
131
  */
102
132
  setupRecovery: () => Promise<string>;
103
133
  /**
104
- * Recover access after losing every device. Requires the recovery code. Runs
105
- * the full Cavos.recover flow and brings the provider to a ready state.
134
+ * Recover access after losing every device. Requires the recovery code. Brings
135
+ * the provider to a ready state.
106
136
  */
107
137
  recover: (code: string) => Promise<void>;
108
138
  logout: () => void;
109
139
  }
110
140
  interface CavosProviderProps {
141
+ /** A single chain config. The provider manages exactly one chain. */
111
142
  config: CavosConfig;
112
143
  modal?: CavosModalConfig;
113
144
  children: ReactNode;
114
145
  }
115
146
  /**
116
- * Drop-in Cavos provider. Wrap your app once; descendants call `useCavos()`.
147
+ * Drop-in Cavos provider for ONE chain. Wrap your app once; descendants call
148
+ * `useCavos()`.
117
149
  *
118
- * <CavosProvider config={{ network: 'sepolia', appSalt, paymasterApiKey }}
119
- * modal={{ appName: 'My App', theme: 'dark', emailMode: 'otp' }}>
150
+ * <CavosProvider config={{ chain: 'solana', network: 'testnet', appId, appSalt }}
151
+ * modal={{ appName: 'My App', theme: 'dark' }}>
120
152
  * <App />
121
153
  * </CavosProvider>
122
154
  *
123
155
  * Behind the scenes: login (social / email) resolves a stable identity, the kit
124
- * deploys a device-signer smart account gaslessly, and `execute()` submits
125
- * gasless multicalls signed silently by the browser's device key.
156
+ * deploys a device-signer smart account gaslessly, and the wallet handle submits
157
+ * gasless transactions signed silently by the browser's device key.
126
158
  */
127
159
  declare function CavosProvider({ config, modal, children }: CavosProviderProps): react.JSX.Element;
128
160
  declare function useCavos(): CavosContextValue;