import * as react from 'react'; import { BitcoinAddressType, WalletImportSource, CustodyStateResult, PublicWallet, EphemeralSigner, ListEphemeralSignersResult, ProvisionEphemeralSignerParams, ProvisionEphemeralSignerResult, RevokeEphemeralSignerParams, CustodyState } from '../types/index.mjs'; import { h as PresenceOtpCodeProvider, B as BulkImportKeySpec, l as RegisterCreateWalletSpec, m as RegisterCreatedWallet, a as BulkImportFailure } from '../bulk-import-wallets-UL-FxpVM.mjs'; import { P as PasskeyMetadata } from '../passkey-metadata-QqFF2SWQ.mjs'; import '../interfaces-DFpFie68.mjs'; import '../post-message-ufv3D_fs.mjs'; /** * The minimal SDK surface the shared hooks rely on. Both platform * SDKs (web's AuthSDK and RN's SDK instance) implement this — and more. * * Methods are loosely typed (the parameter/result shapes live in * `@moon-x/core/types`) so this interface stays single-source-of-truth * for "what shared hooks need" without dragging in every overload. */ interface MoonXHookSDK { user?: unknown | null; isAuthenticated?: boolean; ready?: boolean; refreshUser?: () => Promise; revalidatedAt?: number; signEthereumMessageHeadless: (params: unknown) => Promise; signEthereumTransactionHeadless: (params: unknown) => Promise; signEthereumTypedDataHeadless: (params: unknown) => Promise; signEthereumHashHeadless: (params: unknown) => Promise; signEthereum7702AuthorizationHeadless: (params: unknown) => Promise; sendEthereumTransactionHeadless: (params: unknown) => Promise; sendEthereumTransactionsHeadless?: (params: unknown) => Promise; sendEthereumBatchAtomicHeadless?: (params: unknown) => Promise; getEthereumBalance: (params: unknown) => Promise; getEthereumTokenAccountsByOwner?: (params: unknown) => Promise; signSolanaMessageHeadless: (params: unknown) => Promise; signSolanaTransactionHeadless: (params: unknown) => Promise; sendSolanaTransactionHeadless: (params: unknown) => Promise; getSolanaBalance: (params: unknown) => Promise; getSolanaTokenAccountsByOwner?: (params: unknown) => Promise; signTronMessageHeadless?: (params: unknown) => Promise; signTronTransactionHeadless?: (params: unknown) => Promise; sendTronTransactionHeadless?: (params: unknown) => Promise; getTronBalance?: (params: unknown) => Promise; signBitcoinMessageHeadless?: (params: unknown) => Promise; signBitcoinTransactionHeadless?: (params: unknown) => Promise; sendBitcoinTransactionHeadless?: (params: unknown) => Promise; getBitcoinBalance?: (params: unknown) => Promise; getBitcoinUtxos?: (params: unknown) => Promise; getWallets: (walletType: "ethereum" | "solana" | "tron" | "bitcoin") => Promise; createWallet: (walletType: "ethereum" | "solana" | "tron" | "bitcoin", options?: unknown) => Promise; findOrCreateWallet?: (walletType: "ethereum" | "solana" | "tron" | "bitcoin", options?: { addressType?: BitcoinAddressType; }) => Promise; importKey: (walletType: "ethereum" | "solana" | "tron" | "bitcoin", source: string | WalletImportSource, options?: { addressType?: "p2tr" | "p2wpkh" | "p2pkh"; }) => Promise; bulkImport: (keys: BulkImportKeySpec[]) => Promise; getUser: () => Promise; logout: () => Promise; getPasskeyStatus: () => Promise; getCustodyState?: (options?: { waitForClaim?: boolean; }) => Promise; removePasskey: (credentialIdB64url: string) => Promise; provisionEphemeralSigner: (params: unknown) => Promise; listEphemeralSigners: () => Promise; revokeEphemeralSigner: (params: unknown) => Promise; prepareSigning?: (params: unknown) => Promise; sendCode: (params: { email: string; disableSignup?: boolean; }) => Promise; loginWithCode: (params: { code: string; }) => Promise; sendEmailLinkCode?: (params: { email: string; }) => Promise; linkEmailWithCode?: (params: { email: string; code: string; }) => Promise; sendEmailChangeCode?: (params: { email: string; }) => Promise; confirmEmailChangeCurrentCode?: (params: { code: string; }) => Promise; confirmEmailChangeNewCode?: (params: { code: string; }) => Promise; sendSmsCode?: (params: { phone: string; }) => Promise; loginWithSmsCode?: (params: { code: string; }) => Promise; sendPhoneLinkCode?: (params: { phone: string; }) => Promise; linkPhoneWithCode?: (params: { challengeId: string; code: string; }) => Promise; /** Returns null only for an authoritative no-session response; transport failures reject. */ getCurrentSession?: () => Promise; registerPasskey?: (params?: { displayName?: string; createWallets?: Array<{ chain: "solana" | "ethereum" | "tron"; }>; requestOtpCode?: PresenceOtpCodeProvider; }) => Promise; addPasskey?: (params?: AddPasskeyParams) => Promise; enableAccountRecovery?: () => Promise<{ enabled: true; }>; } interface AddPasskeyParams { displayName?: string; preferCrossDevice?: boolean; /** * React Native: collects the email step-up code for an account-recovery * user. Takes precedence over registerPresenceOtpCodeProvider. Web * collects the code inside its own modal and ignores this. */ requestOtpCode?: PresenceOtpCodeProvider; } declare const SDKProvider: react.Provider; /** * Read the active SDK instance. Throws if no Provider is in the tree — * shared hooks can rely on a non-null return. */ declare const useMoonXSDK: () => MoonXHookSDK; type LoginWithEmailState = { status: "idle"; } | { status: "sending"; } | { status: "awaiting-code"; email: string; } | { status: "verifying"; } | { status: "complete"; } | { status: "error"; error: Error; }; interface UseLoginWithEmailCallbacks { onComplete?: (user: unknown) => void; onError?: (error: Error) => void; } declare const useLoginWithEmail: (callbacks?: UseLoginWithEmailCallbacks) => { state: LoginWithEmailState; sendCode: (params: { email: string; disableSignup?: boolean; }) => Promise; loginWithCode: (params: { code: string; }) => Promise; reset: () => void; }; type LinkEmailState = { status: "idle"; } | { status: "sending"; } | { status: "awaiting-code"; email: string; expiresAt: number | null; } | { status: "linking"; } | { status: "complete"; email: string; isNewLink: boolean; } | { status: "error"; error: Error; }; interface LinkEmailResult { email: string; /** False when the address was already this account's, making a repeat a no-op. */ isNewLink: boolean; } interface UseLinkEmailCallbacks { /** Unix seconds the code expires, straight from the platform. */ onCodeSent?: (expiresAt: number | null) => void; onComplete?: (result: LinkEmailResult) => void; onError?: (error: Error) => void; } /** * Attach a verified email to the signed-in account. * * `sendCode` mails a single-use OTP to the address; `linkEmail` redeems it and * attaches it. Once attached, a later email OTP login for that address resolves * to this same account instead of creating a second one. No session is minted * or replaced. * * Attach only, never change. An account that already holds a different address * is rejected, and an address owned by another live account rejects with * `email_already_in_use` while leaving both accounts untouched. */ declare const useLinkEmail: (callbacks?: UseLinkEmailCallbacks) => { state: LinkEmailState; sendCode: (params: { email: string; }) => Promise; linkEmail: (params: { email: string; code: string; }) => Promise; reset: () => void; }; /** The input a change-email UI shows: the new address, or one of the codes. */ type ChangeEmailStep = "enter-email" | "current-code" | "new-code"; type ChangeEmailState = { status: "idle"; } | { status: "sending"; newEmail: string; } | { status: "awaiting-current-code"; newEmail: string; expiresAt: number | null; } | { status: "confirming-current"; newEmail: string; expiresAt: number | null; } | { status: "awaiting-new-code"; newEmail: string; expiresAt: number | null; } | { status: "changing"; newEmail: string; expiresAt: number | null; } | { status: "complete"; email: string; } | { status: "error"; error: Error; /** The input to show again: the step that failed. */ step: ChangeEmailStep; /** The requested new address, or null if none was accepted yet. */ newEmail: string | null; /** Unix seconds the code for `step` expires, when one was sent. */ expiresAt: number | null; }; interface ChangeEmailResult { email: string; } interface UseChangeEmailCallbacks { /** Unix seconds the current-address code expires, straight from the platform. */ onCurrentCodeSent?: (expiresAt: number | null) => void; /** Unix seconds the new-address code expires, straight from the platform. */ onNewCodeSent?: (expiresAt: number | null) => void; onComplete?: (result: ChangeEmailResult) => void; onError?: (error: Error) => void; } /** * Change the signed-in account's email. * * The change applies in every app the account uses, not only this one. The * list of affected apps is emailed to the current address with the first code, * so the account holder sees it before confirming. * * `sendCode({ email })` takes the new address and mails a code to the current * address. `confirmCurrent({ code })` redeems it and mails a code to the new * address. `changeEmail({ code })` redeems that and switches the account. * The current session stays signed in and other sessions are signed out. * * When a step fails, `state` is `error` with the `step` whose input to show * again, the requested `newEmail` and that code's `expiresAt`. * * Rejects with `email_already_in_use` when the new address belongs to another * live account, and with `email_change_blocked` when the account cannot change * its email right now. Neither changes anything. */ declare const useChangeEmail: (callbacks?: UseChangeEmailCallbacks) => { state: ChangeEmailState; sendCode: (params: { email: string; }) => Promise; confirmCurrent: (params: { code: string; }) => Promise; changeEmail: (params: { code: string; }) => Promise; reset: () => void; }; type LoginWithSmsState = { status: "idle"; } | { status: "sending"; } | { status: "awaiting-code"; phone: string; expiresAt: number | null; } | { status: "verifying"; } | { status: "complete"; } | { status: "error"; error: Error; }; interface UseLoginWithSmsCallbacks { /** Unix seconds the code expires, straight from the platform. */ onCodeSent?: (expiresAt: number | null) => void; onComplete?: (user: unknown) => void; onError?: (error: Error) => void; } /** * Sign in with a one-time code sent by SMS. * * Offer it only when the app config's `sms_otp.enabled` is true; a missing * `sms_otp` means the platform does not support SMS sign-in. * * `sendCode` takes an international number with a leading + (E.164). The * platform only sends to the countries in the app config's * `sms_otp.allowed_countries` and rejects others with * `phone country not supported`. A `loginWithCode` rejection with * `error_type` `phone_login_restart_required` means the code is spent, so call * `sendCode` again. */ declare const useLoginWithSms: (callbacks?: UseLoginWithSmsCallbacks) => { state: LoginWithSmsState; sendCode: (params: { phone: string; }) => Promise; loginWithCode: (params: { code: string; }) => Promise; reset: () => void; }; type LinkPhoneState = { status: "idle"; } | { status: "sending"; } | { status: "awaiting-code"; phone: string; challengeId: string; expiresAt: number | null; } | { status: "linking"; } | { status: "complete"; phone: string; isNewLink: boolean; } | { status: "error"; error: Error; }; interface LinkPhoneResult { /** The E.164 form the platform stored. */ phone: string; /** False when the number was already this account's, making a repeat a no-op. */ isNewLink: boolean; } interface UseLinkPhoneCallbacks { /** Unix seconds the code expires, straight from the platform. */ onCodeSent?: (expiresAt: number | null) => void; onComplete?: (result: LinkPhoneResult) => void; onError?: (error: Error) => void; } /** * Attach a verified phone number to the signed-in account. * * `sendCode` texts a single-use code to the number; `linkPhone` redeems it and * attaches it. Once attached, a later SMS login for that number resolves to * this same account. No session is minted or replaced. Offer it only when the * app config's `phone_link.enabled` is true. * * A user with a passkey or email OTP is asked for a step-up before the code * is sent. * * An account holds one phone number. `linkPhone` rejects with * `phone already linked` (status 409) when the number belongs to another * account or this account already holds a different one; remove the old one * first. A rejection with `error_type` `phone_link_restart_required` means the * code is spent, so call `sendCode` again. A pending pre-generated account * rejects with `claim_required` until its claim finishes. */ declare const useLinkPhone: (callbacks?: UseLinkPhoneCallbacks) => { state: LinkPhoneState; sendCode: (params: { phone: string; }) => Promise; linkPhone: (params: { code: string; challengeId?: string; }) => Promise; reset: () => void; }; interface RegisterPasskeyResult { /** Credential id of the enrolled passkey (RN headless + web modal paths) */ credential_id?: string; /** true on successful enroll (both platforms); false only on web skip */ passkey_registered?: boolean; /** * Whether the enrolled credential can be backed up or synced by its * authenticator. False is accepted for backwards compatibility, but callers * should warn that losing the device may permanently remove wallet access. */ backup_eligible?: boolean; /** * Wallets created on the same prompt when `createWallets` was passed * (register+create on one ceremony). Empty/undefined for a plain enroll, * or when the backend could not provide the complete one-prompt token set. * In that case, call `createWallet` from a fresh user action. */ wallets?: RegisterCreatedWallet[]; } interface RegisterPasskeyParams { displayName?: string; /** * Create the user's first wallet(s) on the SAME WebAuthn prompt as the * passkey registration. The resolved result then includes `wallets`. * * Available on web and React Native. If the backend cannot provide the * complete one-prompt token set, registration still succeeds and `wallets` * is empty; call `createWallet` from a fresh user action. */ createWallets?: RegisterCreateWalletSpec[]; /** * React Native: collects the email step-up code for an account-recovery * user. Takes precedence over registerPresenceOtpCodeProvider. Web * collects the code inside its own modal and ignores this. */ requestOtpCode?: PresenceOtpCodeProvider; } interface UseRegisterPasskeyResult { registerPasskey: (params?: RegisterPasskeyParams) => Promise; isRegistering: boolean; error: string | null; } declare const useRegisterPasskey: () => UseRegisterPasskeyResult; declare const useUser: () => { user: any; loading: boolean; refresh: () => Promise; refreshUser: () => Promise; }; declare const useWallets: (walletType: "ethereum" | "solana" | "tron" | "bitcoin") => { wallets: unknown[]; loading: boolean; error: Error | null; refresh: () => Promise; refetch: () => Promise; }; declare const useLogout: () => { logout: () => Promise; }; declare const useCreateWallet: () => { createWallet: (walletType: "ethereum" | "solana" | "tron" | "bitcoin", options?: { createAdditional?: boolean; walletIndex?: number; addressType?: "p2tr" | "p2wpkh" | "p2pkh"; purpose?: "card"; }) => Promise<{ wallet: PublicWallet; }>; findOrCreateWallet: (walletType: "ethereum" | "solana" | "tron" | "bitcoin", options?: { addressType?: BitcoinAddressType; }) => Promise<{ wallet: PublicWallet; }>; }; declare const useImportKey: () => { importKey: (walletType: "ethereum" | "solana" | "tron" | "bitcoin", source: string | WalletImportSource, options?: { addressType?: "p2tr" | "p2wpkh" | "p2pkh"; }) => Promise<{ wallet: PublicWallet; }>; }; declare const useBulkImport: () => { bulkImport: (keys: BulkImportKeySpec[]) => Promise<{ wallets: PublicWallet[]; failures: BulkImportFailure[]; }>; }; interface UseEphemeralSignerResult { /** Non-revoked signers for the current user and app, including expired signers. */ signers: EphemeralSigner[]; /** True only on the very first load; false during background re-fetches. */ isLoading: boolean; /** True during background re-fetches (e.g. after provision/revoke). */ isRefreshing: boolean; /** Manual re-fetch. Usually unnecessary — provision/revoke trigger it automatically. */ refresh: () => Promise; /** * Provision a new ephemeral signer. Resolves to the full result, * including the one-time api_priv hex — unless `apiPubHex` was * supplied in `params`, in which case the caller already holds the * private half and the result omits it. Triggers a list refresh on * success. */ provision: (params: ProvisionEphemeralSignerParams) => Promise; isProvisioning: boolean; /** * The most recent successful provision result. Stays populated so * the caller can render the one-time priv-key surface until they * call `reset()`. */ lastProvisioned: ProvisionEphemeralSignerResult | null; /** * Soft-revoke an ephemeral signer (and forward the revoke to SES). * Triggers a list refresh on success. The SDK obtains a presence token * from a passkey or an eligible identity-backed session. */ revoke: (params: RevokeEphemeralSignerParams) => Promise; isRevoking: boolean; /** Most recent error across list/provision/revoke. Cleared by reset() or by the next successful op. */ error: string | null; /** Clear `lastProvisioned` + `error`. Use after dismissing the success surface. */ reset: () => void; } declare const useEphemeralSigner: () => UseEphemeralSignerResult; type WalletClaimStatus = "idle" | "claiming" | "claimed" | "failed"; interface UseWalletClaimResult { /** * `claiming` while the iframe re-encrypts the user's keys, `claimed` once * the account is the user's own, `failed` if the claim did not commit * (wallet operations retry it), `idle` otherwise. On `failed`, `error` is * `claim_failed`, followed by the server's code when there is one (for * example `claim_failed: claim_not_pending`). */ status: WalletClaimStatus; /** Null before the first answer and while logged out. */ custodyState: CustodyState | null; /** * While claiming: how many wallets Vertex has refreshed so far. Null when * not claiming or when the iframe does not report it. */ progress: { refreshed: number; total: number; } | null; error: string | null; } declare const useWalletClaim: () => UseWalletClaimResult; interface PasskeyStatusEntry { id: string; credential_id: string; created_at: string; last_used_at: string | null; aaguid?: string; transports?: string[]; backup_eligible?: boolean; backup_state?: boolean; registered_browser?: string; registered_os?: string; /** Display-ready label, e.g. "1Password on Chrome" */ label: string; /** Parsed metadata used to render the label */ metadata: PasskeyMetadata; } interface UsePasskeyStatusResult { hasPasskey: boolean | null; hasBackupEligiblePasskey: boolean | null; passkeys: PasskeyStatusEntry[]; /** * Whether the app has opted into identity-backed (KMS) wallet encryption. * null before the first fetch, and on backends that predate the field. */ kmsWrapEnabled: boolean | null; /** * Whether this user holds a KMS wrap that is usable under the app's current * broker configuration. A wrap frozen to a superseded configuration reads as * false, because it can no longer unwrap the DEK. */ hasKmsWrap: boolean | null; loading: boolean; error: string | null; refresh: () => Promise; } declare const usePasskeyStatus: () => UsePasskeyStatusResult; interface UseAddPasskeyResult { addPasskey: (params?: AddPasskeyParams) => Promise<{ credential_id: string; }>; isAdding: boolean; error: string | null; } declare const useAddPasskey: () => UseAddPasskeyResult; interface UseRemovePasskeyResult { removePasskey: (credentialIdB64url: string) => Promise; isRemoving: boolean; error: string | null; } declare const useRemovePasskey: () => UseRemovePasskeyResult; export { type AddPasskeyParams, type ChangeEmailResult, type ChangeEmailState, type ChangeEmailStep, type LinkEmailResult, type LinkEmailState, type LinkPhoneResult, type LinkPhoneState, type LoginWithEmailState, type LoginWithSmsState, type MoonXHookSDK, type PasskeyStatusEntry, RegisterCreatedWallet, type RegisterPasskeyParams, type RegisterPasskeyResult, SDKProvider, type UseAddPasskeyResult, type UseChangeEmailCallbacks, type UseEphemeralSignerResult, type UseLinkEmailCallbacks, type UseLinkPhoneCallbacks, type UseLoginWithEmailCallbacks, type UseLoginWithSmsCallbacks, type UsePasskeyStatusResult, type UseRegisterPasskeyResult, type UseRemovePasskeyResult, type UseWalletClaimResult, type WalletClaimStatus, useAddPasskey, useBulkImport, useChangeEmail, useCreateWallet, useEphemeralSigner, useImportKey, useLinkEmail, useLinkPhone, useLoginWithEmail, useLoginWithSms, useLogout, useMoonXSDK, usePasskeyStatus, useRegisterPasskey, useRemovePasskey, useUser, useWalletClaim, useWallets };