@volr/react 0.1.135 → 0.2.1

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.d.cts CHANGED
@@ -218,6 +218,27 @@ type SignRequest = {
218
218
  * Resolve to proceed, reject to cancel
219
219
  */
220
220
  type OnSignRequest = (request: SignRequest) => Promise<void>;
221
+ /**
222
+ * Wallet required request types for deferred wallet creation flows.
223
+ *
224
+ * Called when the SDK needs a Volr-managed wallet provider (passkey/MPC) but
225
+ * the current user does not have one available yet.
226
+ */
227
+ type WalletRequiredRequest = {
228
+ type: "transaction";
229
+ chainId: number;
230
+ } | {
231
+ type: "message";
232
+ } | {
233
+ type: "typedData";
234
+ };
235
+ /**
236
+ * Callback invoked when a wallet is required for an operation.
237
+ *
238
+ * - If you return a provider, the SDK will use it for the current operation.
239
+ * - If you return void/null, the SDK will throw WALLET_REQUIRED so the caller can retry.
240
+ */
241
+ type OnWalletRequired = (request: WalletRequiredRequest) => Promise<WalletProviderPort | void | null>;
221
242
 
222
243
  /**
223
244
  * ERC-20 token configuration
@@ -265,7 +286,6 @@ interface VolrUser {
265
286
  * Volr configuration
266
287
  */
267
288
  type VolrConfig = {
268
- defaultChainId: number;
269
289
  projectApiKey: string;
270
290
  rpcOverrides?: Record<string, string>;
271
291
  autoRecoverOnLogin?: boolean;
@@ -283,6 +303,12 @@ type VolrConfig = {
283
303
  * Used by @volr/react-ui to show sign confirmation modal.
284
304
  */
285
305
  onSignRequest?: OnSignRequest;
306
+ /**
307
+ * Callback invoked when a wallet provider is required (passkey/MPC not yet created).
308
+ * Used by @volr/react-ui to show "Create account in 1 second" style onboarding
309
+ * only when the user actually needs a wallet (payments/transactions/signing).
310
+ */
311
+ onWalletRequired?: OnWalletRequired;
286
312
  };
287
313
  /**
288
314
  * Public context value
@@ -293,7 +319,6 @@ type VolrContextValue = {
293
319
  provider: WalletProviderPort | null;
294
320
  setProvider: (provider: WalletProviderPort) => Promise<void>;
295
321
  setUser: (user: VolrUser | null) => void;
296
- chainId: number;
297
322
  precheck: (input: PrecheckInput) => Promise<PrecheckQuote>;
298
323
  relay: (input: RelayInput, opts?: {
299
324
  idempotencyKey?: string;
@@ -585,6 +610,10 @@ type VolrClient = {
585
610
  * How the user signs transactions
586
611
  */
587
612
  signerType: SignerType | undefined;
613
+ /**
614
+ * Whether the user has created a Volr-managed wallet (passkey/MPC).
615
+ */
616
+ hasWallet: boolean;
588
617
  /**
589
618
  * Logout the user
590
619
  */
@@ -603,6 +632,28 @@ type VolrClient = {
603
632
  */
604
633
  declare function useVolr(): VolrClient;
605
634
 
635
+ type SetSessionParams = {
636
+ accessToken: string;
637
+ refreshToken: string;
638
+ };
639
+ type OidcExchangeResult = {
640
+ userId: string;
641
+ isNewUser: boolean;
642
+ keyStorageType: KeyStorageType | null;
643
+ signerType?: SignerType | null;
644
+ accessToken: string;
645
+ };
646
+ /**
647
+ * BYO Auth helpers:
648
+ * - A) setSession: inject server-minted Volr tokens and refresh user profile.
649
+ * - B) exchangeOidc: exchange an OIDC idToken (JWT) for Volr tokens.
650
+ */
651
+ declare function useVolrSession(): {
652
+ setSession: (session: SetSessionParams) => Promise<VolrUser>;
653
+ clearSession: () => Promise<void>;
654
+ exchangeOidc: (idToken: string) => Promise<OidcExchangeResult>;
655
+ };
656
+
606
657
  /**
607
658
  * usePrecheck hook - Precheck transaction batch
608
659
  */
@@ -1378,6 +1429,22 @@ declare function isWebAuthnBusyError(error: unknown): boolean;
1378
1429
  */
1379
1430
  declare function isInAppBrowserNotSupportedError(error: unknown): boolean;
1380
1431
 
1432
+ /**
1433
+ * Wallet-related error classes
1434
+ */
1435
+ type WalletRequiredAction = "send_transaction" | "sign_message" | "sign_typed_data";
1436
+ /**
1437
+ * Error thrown when a Volr-managed wallet provider is required but not available.
1438
+ *
1439
+ * This is expected in the deferred-wallet flow (BYO Auth + optional wallet creation).
1440
+ */
1441
+ declare class WalletRequiredError extends Error {
1442
+ readonly code = "WALLET_REQUIRED";
1443
+ readonly action: WalletRequiredAction;
1444
+ constructor(action: WalletRequiredAction, message?: string);
1445
+ }
1446
+ declare function isWalletRequiredError(error: unknown): error is WalletRequiredError;
1447
+
1381
1448
  /**
1382
1449
  * Platform compatibility check utilities
1383
1450
  * Detects PRF extension support and provides guidance for cross-device authentication
@@ -1702,4 +1769,4 @@ declare function useEIP6963(): UseEIP6963Return;
1702
1769
  */
1703
1770
  declare function detectWalletConnector(provider: any, providerInfo: EIP6963ProviderInfo | null): string;
1704
1771
 
1705
- export { type ApiResponse, type AuthRefreshResponseDto, type AuthResult, type BrandingData, type BuildCallOptions, type ContractAnalysisResult, DEFAULT_EXPIRES_IN_SEC, DEFAULT_MODE, type DecryptEntropyParams, type DepositAsset$1 as DepositAsset, type DepositConfig, type EIP6963AnnounceProviderEvent, type EIP6963ProviderDetail, type EIP6963ProviderInfo, type ERC20BalanceComparison, type Erc20Token$1 as Erc20Token, type EvmChainClient, type EvmClient, type EvmNamespace, InAppBrowserNotSupportedError, type KeyStorageType, type MigrationCompleteParams, type MigrationCompleteResult, type MigrationError, type MigrationMessage, type MigrationRequestParams, type MigrationRequestResult, type MigrationSeedRequest, type MigrationSeedResponse, type MpcConnectionStep, type NetworkDto, type NetworkInfo, type OnSignRequest, type PasskeyAdapterOptions, type PasskeyEnrollmentStep, PasskeyNotFoundError, type PayOptions, type PaymentContext, type PaymentError, type PaymentHandle, type PaymentHandlers, type PaymentHistoryOptions, type PaymentHistoryResult, type PaymentItem, type PaymentResult, type PaymentStatus, type PaymentToken, type PlatformCheckResult, type PrfCompatibilityResult, type PrfInputDto, PrfNotSupportedError, type RegisteredPasskeyDto, type SendBatchOverloads, type SendTxOptions, type SignRequest, type SignerType, type SiweSession, type SiweSessionStatus, type SocialProvider, type TokenBalance, type TransactionDto, type TransactionStatus, type UseEIP6963Return, type UseMpcConnectionReturn, type UsePasskeyEnrollmentReturn, type UseUserBalancesReturn, type UseVolrAuthCallbackOptions, type UseVolrAuthCallbackReturn, type UseVolrLoginReturn, type UseVolrPaymentApiReturn, type UseWithdrawReturn, UserCancelledError, type UserDto, type VolrClient, type VolrConfig, type VolrContextValue, VolrProvider, type VolrUser, type WalletDisplayInfo, type WalletStateComparison, WebAuthnBusyError, type WithdrawParams, analyzeContractForEIP7702, buildCall, buildCalls, checkPrfCompatibility, checkPrfExtensionAvailable, checkPrfSupport, compareERC20Balances, compareWalletStates, completeMigration, createGetNetworkInfo, createPasskeyAdapter, debugTransactionFailure, decryptEntropyForMigration, defaultIdempotencyKey, detectWalletConnector, diagnoseTransactionFailure, getBrowserVersion, getERC20Balance, getIOSVersion, getPasskeyAuthGuidance, getPlatformHint, getUserCredentials, getWalletState, isEIP7702Delegated, isInAppBrowser, isInAppBrowserNotSupportedError, isUserCancelledError, isWebAuthnBusyError, listenForSeedRequests, normalizeHex, normalizeHexArray, openMigrationPopup, requestMigration, requestSeedFromOpener, sendSeedToPopup, uploadBlobViaPresign, useDepositListener, useEIP6963, useInternalAuth, useMpcConnection, usePasskeyEnrollment, usePrecheck, useRelay, useUserBalances, useVolr, useVolrAuthCallback, useVolrContext, useVolrLogin, useVolrPaymentApi, useWithdraw };
1772
+ export { type ApiResponse, type AuthRefreshResponseDto, type AuthResult, type BrandingData, type BuildCallOptions, type ContractAnalysisResult, DEFAULT_EXPIRES_IN_SEC, DEFAULT_MODE, type DecryptEntropyParams, type DepositAsset$1 as DepositAsset, type DepositConfig, type EIP6963AnnounceProviderEvent, type EIP6963ProviderDetail, type EIP6963ProviderInfo, type ERC20BalanceComparison, type Erc20Token$1 as Erc20Token, type EvmChainClient, type EvmClient, type EvmNamespace, InAppBrowserNotSupportedError, type KeyStorageType, type MigrationCompleteParams, type MigrationCompleteResult, type MigrationError, type MigrationMessage, type MigrationRequestParams, type MigrationRequestResult, type MigrationSeedRequest, type MigrationSeedResponse, type MpcConnectionStep, type NetworkDto, type NetworkInfo, type OidcExchangeResult, type OnSignRequest, type OnWalletRequired, type PasskeyAdapterOptions, type PasskeyEnrollmentStep, PasskeyNotFoundError, type PayOptions, type PaymentContext, type PaymentError, type PaymentHandle, type PaymentHandlers, type PaymentHistoryOptions, type PaymentHistoryResult, type PaymentItem, type PaymentResult, type PaymentStatus, type PaymentToken, type PlatformCheckResult, type PrfCompatibilityResult, type PrfInputDto, PrfNotSupportedError, type RegisteredPasskeyDto, type SendBatchOverloads, type SendTxOptions, type SetSessionParams, type SignRequest, type SignerType, type SiweSession, type SiweSessionStatus, type SocialProvider, type TokenBalance, type TransactionDto, type TransactionStatus, type UseEIP6963Return, type UseMpcConnectionReturn, type UsePasskeyEnrollmentReturn, type UseUserBalancesReturn, type UseVolrAuthCallbackOptions, type UseVolrAuthCallbackReturn, type UseVolrLoginReturn, type UseVolrPaymentApiReturn, type UseWithdrawReturn, UserCancelledError, type UserDto, type VolrClient, type VolrConfig, type VolrContextValue, VolrProvider, type VolrUser, type WalletDisplayInfo, type WalletRequiredAction, WalletRequiredError, type WalletRequiredRequest, type WalletStateComparison, WebAuthnBusyError, type WithdrawParams, analyzeContractForEIP7702, buildCall, buildCalls, checkPrfCompatibility, checkPrfExtensionAvailable, checkPrfSupport, compareERC20Balances, compareWalletStates, completeMigration, createGetNetworkInfo, createPasskeyAdapter, debugTransactionFailure, decryptEntropyForMigration, defaultIdempotencyKey, detectWalletConnector, diagnoseTransactionFailure, getBrowserVersion, getERC20Balance, getIOSVersion, getPasskeyAuthGuidance, getPlatformHint, getUserCredentials, getWalletState, isEIP7702Delegated, isInAppBrowser, isInAppBrowserNotSupportedError, isUserCancelledError, isWalletRequiredError, isWebAuthnBusyError, listenForSeedRequests, normalizeHex, normalizeHexArray, openMigrationPopup, requestMigration, requestSeedFromOpener, sendSeedToPopup, uploadBlobViaPresign, useDepositListener, useEIP6963, useInternalAuth, useMpcConnection, usePasskeyEnrollment, usePrecheck, useRelay, useUserBalances, useVolr, useVolrAuthCallback, useVolrContext, useVolrLogin, useVolrPaymentApi, useVolrSession, useWithdraw };
package/dist/index.d.ts CHANGED
@@ -218,6 +218,27 @@ type SignRequest = {
218
218
  * Resolve to proceed, reject to cancel
219
219
  */
220
220
  type OnSignRequest = (request: SignRequest) => Promise<void>;
221
+ /**
222
+ * Wallet required request types for deferred wallet creation flows.
223
+ *
224
+ * Called when the SDK needs a Volr-managed wallet provider (passkey/MPC) but
225
+ * the current user does not have one available yet.
226
+ */
227
+ type WalletRequiredRequest = {
228
+ type: "transaction";
229
+ chainId: number;
230
+ } | {
231
+ type: "message";
232
+ } | {
233
+ type: "typedData";
234
+ };
235
+ /**
236
+ * Callback invoked when a wallet is required for an operation.
237
+ *
238
+ * - If you return a provider, the SDK will use it for the current operation.
239
+ * - If you return void/null, the SDK will throw WALLET_REQUIRED so the caller can retry.
240
+ */
241
+ type OnWalletRequired = (request: WalletRequiredRequest) => Promise<WalletProviderPort | void | null>;
221
242
 
222
243
  /**
223
244
  * ERC-20 token configuration
@@ -265,7 +286,6 @@ interface VolrUser {
265
286
  * Volr configuration
266
287
  */
267
288
  type VolrConfig = {
268
- defaultChainId: number;
269
289
  projectApiKey: string;
270
290
  rpcOverrides?: Record<string, string>;
271
291
  autoRecoverOnLogin?: boolean;
@@ -283,6 +303,12 @@ type VolrConfig = {
283
303
  * Used by @volr/react-ui to show sign confirmation modal.
284
304
  */
285
305
  onSignRequest?: OnSignRequest;
306
+ /**
307
+ * Callback invoked when a wallet provider is required (passkey/MPC not yet created).
308
+ * Used by @volr/react-ui to show "Create account in 1 second" style onboarding
309
+ * only when the user actually needs a wallet (payments/transactions/signing).
310
+ */
311
+ onWalletRequired?: OnWalletRequired;
286
312
  };
287
313
  /**
288
314
  * Public context value
@@ -293,7 +319,6 @@ type VolrContextValue = {
293
319
  provider: WalletProviderPort | null;
294
320
  setProvider: (provider: WalletProviderPort) => Promise<void>;
295
321
  setUser: (user: VolrUser | null) => void;
296
- chainId: number;
297
322
  precheck: (input: PrecheckInput) => Promise<PrecheckQuote>;
298
323
  relay: (input: RelayInput, opts?: {
299
324
  idempotencyKey?: string;
@@ -585,6 +610,10 @@ type VolrClient = {
585
610
  * How the user signs transactions
586
611
  */
587
612
  signerType: SignerType | undefined;
613
+ /**
614
+ * Whether the user has created a Volr-managed wallet (passkey/MPC).
615
+ */
616
+ hasWallet: boolean;
588
617
  /**
589
618
  * Logout the user
590
619
  */
@@ -603,6 +632,28 @@ type VolrClient = {
603
632
  */
604
633
  declare function useVolr(): VolrClient;
605
634
 
635
+ type SetSessionParams = {
636
+ accessToken: string;
637
+ refreshToken: string;
638
+ };
639
+ type OidcExchangeResult = {
640
+ userId: string;
641
+ isNewUser: boolean;
642
+ keyStorageType: KeyStorageType | null;
643
+ signerType?: SignerType | null;
644
+ accessToken: string;
645
+ };
646
+ /**
647
+ * BYO Auth helpers:
648
+ * - A) setSession: inject server-minted Volr tokens and refresh user profile.
649
+ * - B) exchangeOidc: exchange an OIDC idToken (JWT) for Volr tokens.
650
+ */
651
+ declare function useVolrSession(): {
652
+ setSession: (session: SetSessionParams) => Promise<VolrUser>;
653
+ clearSession: () => Promise<void>;
654
+ exchangeOidc: (idToken: string) => Promise<OidcExchangeResult>;
655
+ };
656
+
606
657
  /**
607
658
  * usePrecheck hook - Precheck transaction batch
608
659
  */
@@ -1378,6 +1429,22 @@ declare function isWebAuthnBusyError(error: unknown): boolean;
1378
1429
  */
1379
1430
  declare function isInAppBrowserNotSupportedError(error: unknown): boolean;
1380
1431
 
1432
+ /**
1433
+ * Wallet-related error classes
1434
+ */
1435
+ type WalletRequiredAction = "send_transaction" | "sign_message" | "sign_typed_data";
1436
+ /**
1437
+ * Error thrown when a Volr-managed wallet provider is required but not available.
1438
+ *
1439
+ * This is expected in the deferred-wallet flow (BYO Auth + optional wallet creation).
1440
+ */
1441
+ declare class WalletRequiredError extends Error {
1442
+ readonly code = "WALLET_REQUIRED";
1443
+ readonly action: WalletRequiredAction;
1444
+ constructor(action: WalletRequiredAction, message?: string);
1445
+ }
1446
+ declare function isWalletRequiredError(error: unknown): error is WalletRequiredError;
1447
+
1381
1448
  /**
1382
1449
  * Platform compatibility check utilities
1383
1450
  * Detects PRF extension support and provides guidance for cross-device authentication
@@ -1702,4 +1769,4 @@ declare function useEIP6963(): UseEIP6963Return;
1702
1769
  */
1703
1770
  declare function detectWalletConnector(provider: any, providerInfo: EIP6963ProviderInfo | null): string;
1704
1771
 
1705
- export { type ApiResponse, type AuthRefreshResponseDto, type AuthResult, type BrandingData, type BuildCallOptions, type ContractAnalysisResult, DEFAULT_EXPIRES_IN_SEC, DEFAULT_MODE, type DecryptEntropyParams, type DepositAsset$1 as DepositAsset, type DepositConfig, type EIP6963AnnounceProviderEvent, type EIP6963ProviderDetail, type EIP6963ProviderInfo, type ERC20BalanceComparison, type Erc20Token$1 as Erc20Token, type EvmChainClient, type EvmClient, type EvmNamespace, InAppBrowserNotSupportedError, type KeyStorageType, type MigrationCompleteParams, type MigrationCompleteResult, type MigrationError, type MigrationMessage, type MigrationRequestParams, type MigrationRequestResult, type MigrationSeedRequest, type MigrationSeedResponse, type MpcConnectionStep, type NetworkDto, type NetworkInfo, type OnSignRequest, type PasskeyAdapterOptions, type PasskeyEnrollmentStep, PasskeyNotFoundError, type PayOptions, type PaymentContext, type PaymentError, type PaymentHandle, type PaymentHandlers, type PaymentHistoryOptions, type PaymentHistoryResult, type PaymentItem, type PaymentResult, type PaymentStatus, type PaymentToken, type PlatformCheckResult, type PrfCompatibilityResult, type PrfInputDto, PrfNotSupportedError, type RegisteredPasskeyDto, type SendBatchOverloads, type SendTxOptions, type SignRequest, type SignerType, type SiweSession, type SiweSessionStatus, type SocialProvider, type TokenBalance, type TransactionDto, type TransactionStatus, type UseEIP6963Return, type UseMpcConnectionReturn, type UsePasskeyEnrollmentReturn, type UseUserBalancesReturn, type UseVolrAuthCallbackOptions, type UseVolrAuthCallbackReturn, type UseVolrLoginReturn, type UseVolrPaymentApiReturn, type UseWithdrawReturn, UserCancelledError, type UserDto, type VolrClient, type VolrConfig, type VolrContextValue, VolrProvider, type VolrUser, type WalletDisplayInfo, type WalletStateComparison, WebAuthnBusyError, type WithdrawParams, analyzeContractForEIP7702, buildCall, buildCalls, checkPrfCompatibility, checkPrfExtensionAvailable, checkPrfSupport, compareERC20Balances, compareWalletStates, completeMigration, createGetNetworkInfo, createPasskeyAdapter, debugTransactionFailure, decryptEntropyForMigration, defaultIdempotencyKey, detectWalletConnector, diagnoseTransactionFailure, getBrowserVersion, getERC20Balance, getIOSVersion, getPasskeyAuthGuidance, getPlatformHint, getUserCredentials, getWalletState, isEIP7702Delegated, isInAppBrowser, isInAppBrowserNotSupportedError, isUserCancelledError, isWebAuthnBusyError, listenForSeedRequests, normalizeHex, normalizeHexArray, openMigrationPopup, requestMigration, requestSeedFromOpener, sendSeedToPopup, uploadBlobViaPresign, useDepositListener, useEIP6963, useInternalAuth, useMpcConnection, usePasskeyEnrollment, usePrecheck, useRelay, useUserBalances, useVolr, useVolrAuthCallback, useVolrContext, useVolrLogin, useVolrPaymentApi, useWithdraw };
1772
+ export { type ApiResponse, type AuthRefreshResponseDto, type AuthResult, type BrandingData, type BuildCallOptions, type ContractAnalysisResult, DEFAULT_EXPIRES_IN_SEC, DEFAULT_MODE, type DecryptEntropyParams, type DepositAsset$1 as DepositAsset, type DepositConfig, type EIP6963AnnounceProviderEvent, type EIP6963ProviderDetail, type EIP6963ProviderInfo, type ERC20BalanceComparison, type Erc20Token$1 as Erc20Token, type EvmChainClient, type EvmClient, type EvmNamespace, InAppBrowserNotSupportedError, type KeyStorageType, type MigrationCompleteParams, type MigrationCompleteResult, type MigrationError, type MigrationMessage, type MigrationRequestParams, type MigrationRequestResult, type MigrationSeedRequest, type MigrationSeedResponse, type MpcConnectionStep, type NetworkDto, type NetworkInfo, type OidcExchangeResult, type OnSignRequest, type OnWalletRequired, type PasskeyAdapterOptions, type PasskeyEnrollmentStep, PasskeyNotFoundError, type PayOptions, type PaymentContext, type PaymentError, type PaymentHandle, type PaymentHandlers, type PaymentHistoryOptions, type PaymentHistoryResult, type PaymentItem, type PaymentResult, type PaymentStatus, type PaymentToken, type PlatformCheckResult, type PrfCompatibilityResult, type PrfInputDto, PrfNotSupportedError, type RegisteredPasskeyDto, type SendBatchOverloads, type SendTxOptions, type SetSessionParams, type SignRequest, type SignerType, type SiweSession, type SiweSessionStatus, type SocialProvider, type TokenBalance, type TransactionDto, type TransactionStatus, type UseEIP6963Return, type UseMpcConnectionReturn, type UsePasskeyEnrollmentReturn, type UseUserBalancesReturn, type UseVolrAuthCallbackOptions, type UseVolrAuthCallbackReturn, type UseVolrLoginReturn, type UseVolrPaymentApiReturn, type UseWithdrawReturn, UserCancelledError, type UserDto, type VolrClient, type VolrConfig, type VolrContextValue, VolrProvider, type VolrUser, type WalletDisplayInfo, type WalletRequiredAction, WalletRequiredError, type WalletRequiredRequest, type WalletStateComparison, WebAuthnBusyError, type WithdrawParams, analyzeContractForEIP7702, buildCall, buildCalls, checkPrfCompatibility, checkPrfExtensionAvailable, checkPrfSupport, compareERC20Balances, compareWalletStates, completeMigration, createGetNetworkInfo, createPasskeyAdapter, debugTransactionFailure, decryptEntropyForMigration, defaultIdempotencyKey, detectWalletConnector, diagnoseTransactionFailure, getBrowserVersion, getERC20Balance, getIOSVersion, getPasskeyAuthGuidance, getPlatformHint, getUserCredentials, getWalletState, isEIP7702Delegated, isInAppBrowser, isInAppBrowserNotSupportedError, isUserCancelledError, isWalletRequiredError, isWebAuthnBusyError, listenForSeedRequests, normalizeHex, normalizeHexArray, openMigrationPopup, requestMigration, requestSeedFromOpener, sendSeedToPopup, uploadBlobViaPresign, useDepositListener, useEIP6963, useInternalAuth, useMpcConnection, usePasskeyEnrollment, usePrecheck, useRelay, useUserBalances, useVolr, useVolrAuthCallback, useVolrContext, useVolrLogin, useVolrPaymentApi, useVolrSession, useWithdraw };