@pollar/react 0.11.5 → 0.12.0-rc.2

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.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { pollarPaths, PollarClient, PollarClientConfig, PollarAdapters, OnStorageDegrade, WalletInfo, PollarLoginOptions, SessionsState, CosignState, PendingConfirmation, TransactionState, TxBuildBody, BuildOutcome, SubmitOutcome, SignOutcome, SendPaymentParams, StellarNetwork, WalletBalanceState, EnabledAssetsState, TrustlineOutcome, TxHistoryState, SwapVenue, SwapToken, SwapQuoteParams, SwapQuote, EarnProviderId, EarnOpportunity, EarnPositionParams, EarnPosition, EarnTxParams, PollarAdapter, PasskeyCeremony, PasskeySigner, WalletChain, CosignRequest, CosignVerification, CosignQuorumReport, CosignDevicesContent, KycStatus as KycStatus$1, RampQuote, WalletId, AuthState, KycProvider, KycStartResponse, RampDirection, RampCountry, RampQuoteRequirement, RampTxStatus, RampDepositInstructions, EnabledAssetRecord, WalletBalanceRecord, SwapProvider, DistributionRulesState, DistributionRule } from '@pollar/core';
2
+ import { pollarPaths, PollarClient, PollarClientConfig, PollarAdapters, OnStorageDegrade, WalletInfo, CosignCustody, PollarLoginOptions, SessionsState, CosignState, RecoveryState, CustodyMigrationState, PendingConfirmation, TransactionState, TxBuildBody, BuildOutcome, SubmitOutcome, SignOutcome, SendPaymentParams, StellarNetwork, WalletBalanceState, EnabledAssetsState, TrustlineOutcome, TxHistoryState, SwapVenue, SwapToken, SwapQuoteParams, SwapQuote, EarnProviderId, EarnOpportunity, EarnPositionParams, EarnPosition, EarnTxParams, PollarAdapter, PasskeyCeremony, PasskeySigner, RecoveryPasskeyCeremony, WalletChain, CosignRequest, CosignVerification, CosignQuorumReport, CosignDevicesContent, KycStatus as KycStatus$1, RampQuote, WalletId, AuthState, KycProvider, KycStartResponse, RampDirection, RampCountry, RampQuoteRequirement, RampTxStatus, RampDepositInstructions, EnabledAssetRecord, WalletBalanceRecord, SwapProvider, DistributionRulesState, DistributionRule, RampSnapshot, RampsTransactionResponse } from '@pollar/core';
3
3
  export { AuthProviderContext, PollarAuthProvider, SessionsState } from '@pollar/core';
4
4
  import { ReactNode, CSSProperties } from 'react';
5
5
 
@@ -43,8 +43,13 @@ interface PollarContextValue {
43
43
  * creates none.
44
44
  */
45
45
  hasWallet: boolean;
46
- /** Create the signed-in user's wallet; see `PollarClient.createWallet`. */
47
- createWallet: () => Promise<WalletInfo>;
46
+ /**
47
+ * Create the signed-in user's wallet; see `PollarClient.createWallet`. An app
48
+ * whose custody mode is USER_CHOICE needs `custody`: the user's pick.
49
+ */
50
+ createWallet: (options?: {
51
+ custody?: CosignCustody;
52
+ }) => Promise<WalletInfo>;
48
53
  /**
49
54
  * `true` once the server has confirmed the session (login / refresh /
50
55
  * `/auth/session/resume`). `false` while a cold-start session is still
@@ -60,6 +65,24 @@ interface PollarContextValue {
60
65
  cosign: CosignState;
61
66
  /** Open the approval prompt of a co-signed wallet. Opens by itself when a request arrives. */
62
67
  openCosignModal: () => void;
68
+ /**
69
+ * The recovery state of the user's Turnkey wallet: null until read, or for a
70
+ * session without one. `recoveryLocked` is true while the wallet has no way
71
+ * to be recovered without this device: it signs nothing but its own setup.
72
+ */
73
+ recovery: RecoveryState | null;
74
+ recoveryLocked: boolean;
75
+ /** Read the recovery state again (after a method changed elsewhere). */
76
+ refreshRecovery: () => void;
77
+ /** Open the recovery methods modal: passkeys, email, devices, export. */
78
+ openRecoveryModal: () => void;
79
+ /**
80
+ * Whether the user's wallet, one Pollar custodies, has to move to this
81
+ * device because the app keeps its wallets in Turnkey. While `required`, the
82
+ * provider shows the move and nothing else; null until read.
83
+ */
84
+ custodyMigration: CustodyMigrationState | null;
85
+ refreshCustodyMigration: () => void;
63
86
  /** Signing calls waiting for the user under `confirmation: 'prompt'`; the provider shows the first one. */
64
87
  confirmations: PendingConfirmation[];
65
88
  appConfig: PollarConfig;
@@ -277,6 +300,15 @@ declare const browserPasskeyCeremony: PasskeyCeremony;
277
300
  * entry. The secp256r1 key never leaves the device.
278
301
  */
279
302
  declare const browserPasskeySigner: PasskeySigner;
303
+ /**
304
+ * Browser passkey ceremonies for a Turnkey wallet's recovery: register a
305
+ * passkey as a way back in, and sign a Turnkey request with one to add a new
306
+ * device. rpId is the page's hostname, like the smart-wallet ceremony, so a
307
+ * passkey made on the app's domain recovers the wallet on that domain.
308
+ * `challenge` arrives base64url already: for `get()` it is what Turnkey checks
309
+ * (the hex SHA-256 of the request body).
310
+ */
311
+ declare const browserRecoveryPasskey: RecoveryPasskeyCeremony;
280
312
 
281
313
  /**
282
314
  * The one place the widget decides whether a wallet can act on-chain, and what
@@ -318,6 +350,13 @@ interface WalletButtonTemplateProps {
318
350
  * custom template written before this existed keeps compiling.
319
351
  */
320
352
  notReadyReason?: string | null;
353
+ /**
354
+ * The wallet has no recovery method yet and signs nothing but its own setup.
355
+ * Shown at the top of the menu with a way to fix it. Optional for custom templates.
356
+ */
357
+ recoveryLocked?: boolean;
358
+ /** Open the recovery methods; the item shows only when set. */
359
+ onRecovery?: () => void;
321
360
  creatingAccount: boolean;
322
361
  /**
323
362
  * Signed in with no wallet yet (an app that creates wallets on demand, or
@@ -328,7 +367,13 @@ interface WalletButtonTemplateProps {
328
367
  signedIn?: boolean;
329
368
  creatingWallet?: boolean;
330
369
  createWalletError?: string | null;
331
- onCreateWallet?: () => void;
370
+ /**
371
+ * The app leaves the custody to the user (USER_CHOICE): Create wallet offers
372
+ * co-signed and self-custody, and calls `onCreateWallet` with the pick. A
373
+ * self-custody wallet is created only after the user accepts its risks.
374
+ */
375
+ custodyChoice?: boolean;
376
+ onCreateWallet?: (custody?: CosignCustody) => void;
332
377
  onToggleOpen: () => void;
333
378
  onCreateAccount: () => void;
334
379
  onCopy: () => void;
@@ -343,7 +388,7 @@ interface WalletButtonTemplateProps {
343
388
  onLogout: () => void;
344
389
  onLogin: () => void;
345
390
  }
346
- declare function WalletButtonTemplate({ walletAddress, accentColor, open, copied, dropdownBg, dropdownBorder, itemColor, wrapperRef, isInProgress, showCreateAccount, notReadyReason, creatingAccount, onToggleOpen, onCreateAccount, onCopy, onWalletBalance, onTxHistory, onSend, onReceive, onSessions, onKyc, onRamp, onDistributionRules, onLogout, onLogin, signedIn, creatingWallet, createWalletError, onCreateWallet, }: WalletButtonTemplateProps): react_jsx_runtime.JSX.Element;
391
+ declare function WalletButtonTemplate({ walletAddress, accentColor, open, copied, dropdownBg, dropdownBorder, itemColor, wrapperRef, isInProgress, showCreateAccount, notReadyReason, recoveryLocked, onRecovery, creatingAccount, onToggleOpen, onCreateAccount, onCopy, onWalletBalance, onTxHistory, onSend, onReceive, onSessions, onKyc, onRamp, onDistributionRules, onLogout, onLogin, signedIn, creatingWallet, createWalletError, custodyChoice, onCreateWallet, }: WalletButtonTemplateProps): react_jsx_runtime.JSX.Element;
347
392
 
348
393
  /**
349
394
  * The chain a record lives on, with the legacy shape folded in: sessions and
@@ -418,7 +463,7 @@ interface UseCosignResult {
418
463
  reject: (request: CosignRequest) => Promise<CosignRequest>;
419
464
  /** The verification a UI can show before the user decides. */
420
465
  verify: (request: CosignRequest) => Promise<CosignVerification>;
421
- /** Read the sub-organization from Turnkey with the device key and record whether it is the promised 2-of-2. */
466
+ /** Read the sub-organization from Turnkey with the device key and record whether it is the quorum its custody promises. */
422
467
  inspectQuorum: () => Promise<CosignQuorumReport>;
423
468
  /** The user's enrolled devices and the quorum state as sdk-api records it. */
424
469
  devices: () => Promise<CosignDevicesContent>;
@@ -426,6 +471,8 @@ interface UseCosignResult {
426
471
  revokeDevice: (deviceId: string, options?: {
427
472
  force?: boolean;
428
473
  }) => Promise<CosignDevicesContent>;
474
+ /** Move the wallet between co-signed and self-custody; only an app in USER_CHOICE custody allows it. */
475
+ switchCustody: (to: CosignCustody) => Promise<CosignQuorumReport>;
429
476
  }
430
477
  /**
431
478
  * The user's side of a Turnkey co-signed wallet, for an app that renders its
@@ -574,6 +621,18 @@ interface CosignModalProps {
574
621
  */
575
622
  declare function CosignModal({ onClose }: CosignModalProps): react_jsx_runtime.JSX.Element;
576
623
 
624
+ interface RecoveryModalProps {
625
+ onClose: () => void;
626
+ }
627
+ /**
628
+ * The recovery methods of a Turnkey wallet: add and remove passkeys, confirm
629
+ * an email, approve another device, export the recovery phrase, and, on a
630
+ * device that is not part of the wallet, get back in. Until one method exists
631
+ * the wallet signs nothing but its own setup, so this is also where a locked
632
+ * wallet sends the user.
633
+ */
634
+ declare function RecoveryModal({ onClose }: RecoveryModalProps): react_jsx_runtime.JSX.Element;
635
+
577
636
  interface DistributionRulesModalProps {
578
637
  onClose: () => void;
579
638
  }
@@ -704,7 +763,7 @@ interface RampFieldSpec {
704
763
  key: string;
705
764
  label: string;
706
765
  type: 'text' | 'email' | 'tel' | 'select';
707
- bankType?: 'CLABE' | 'PIX' | 'PSE' | 'ACH' | 'BREB';
766
+ bankType?: string;
708
767
  /** For `type: 'select'` - dropdown choices (e.g. Stereum's Bolivian banks). */
709
768
  options?: {
710
769
  value: string;
@@ -725,6 +784,8 @@ interface RampFieldSpec {
725
784
  hint?: string;
726
785
  }
727
786
  interface RampWidgetTemplateProps {
787
+ workflowContent?: React.ReactNode;
788
+ routeSelector?: React.ReactNode;
728
789
  theme: string;
729
790
  accentColor: string;
730
791
  /** Per-app modal chrome overrides (background, card + button radius). */
@@ -786,6 +847,14 @@ interface RampWidgetTemplateProps {
786
847
  depositInstructions: RampDepositInstructions | null;
787
848
  canComplete: boolean;
788
849
  completing: boolean;
850
+ savedRamps?: Array<{
851
+ txId: string;
852
+ provider: string;
853
+ }>;
854
+ onResumeRamp?: (id: string) => void;
855
+ onDismissRamp?: (id: string) => void;
856
+ onDismissCurrentRamp?: (() => void) | undefined;
857
+ onExploreRoutes?: (() => void) | undefined;
789
858
  errorMsg: string | null;
790
859
  /** Neutral guidance on the route list, e.g. after identity verification sent the user back to it. */
791
860
  noticeMsg?: string | null;
@@ -807,7 +876,7 @@ interface RampWidgetTemplateProps {
807
876
  onRefresh: () => void;
808
877
  onClose: () => void;
809
878
  }
810
- declare function RampWidgetTemplate({ theme, accentColor, styleOverrides, step, flowSteps, flowStepIndex, startingQuoteId, direction, amount, currency, country, requiredFields, fieldValues, countries, countriesLoading, refreshing, quotes, kycRequired, isLoading, provider, txStatus, kycUrl, tosUrl, kycBlocking, onboardingStatus, kycJustApproved, stellarTxHash, txHash, txChain, explorerUrl, fundsInTransit, retrying, onRetryTransit, depositInstructions, canComplete, completing, errorMsg, noticeMsg, onDirectionChange, onAmountChange, onFieldChange, onCountryChange, onFindRoute, onSelectQuote, onVerifyRoute, onContactContinue, onOpenKyc, onOpenTos, onCompleteWithdraw, onBack, onRetry, onRefresh, onClose, }: RampWidgetTemplateProps): react_jsx_runtime.JSX.Element;
879
+ declare function RampWidgetTemplate({ workflowContent, routeSelector, theme, accentColor, styleOverrides, step, flowSteps, flowStepIndex, startingQuoteId, direction, amount, currency, country, requiredFields, fieldValues, countries, countriesLoading, refreshing, quotes, kycRequired, isLoading, provider, txStatus, kycUrl, tosUrl, kycBlocking, onboardingStatus, kycJustApproved, stellarTxHash, txHash, txChain, explorerUrl, fundsInTransit, retrying, onRetryTransit, depositInstructions, canComplete, completing, savedRamps, onResumeRamp, onDismissRamp, onDismissCurrentRamp, onExploreRoutes, errorMsg, noticeMsg, onDirectionChange, onAmountChange, onFieldChange, onCountryChange, onFindRoute, onSelectQuote, onVerifyRoute, onContactContinue, onOpenKyc, onOpenTos, onCompleteWithdraw, onBack, onRetry, onRefresh, onClose, }: RampWidgetTemplateProps): react_jsx_runtime.JSX.Element;
811
880
 
812
881
  interface TransactionModalTemplateProps {
813
882
  theme: string;
@@ -1070,10 +1139,17 @@ interface ReceiveModalTemplateProps {
1070
1139
  * custom template written before this existed keeps compiling.
1071
1140
  */
1072
1141
  notReadyReason?: string | null;
1142
+ /**
1143
+ * The wallet has no way to be recovered without this device yet. The address
1144
+ * stays hidden until the user adds one, so nobody is handed an address whose
1145
+ * funds a lost phone would take with it. Optional for custom templates.
1146
+ */
1147
+ recoveryLocked?: boolean;
1148
+ onSetupRecovery?: () => void;
1073
1149
  onCopy: () => void;
1074
1150
  onClose: () => void;
1075
1151
  }
1076
- declare function ReceiveModalTemplate({ theme, accentColor, styleOverrides, walletAddress, chains, selectedChain, onSelectChain, copied, notReadyReason, onCopy, onClose, }: ReceiveModalTemplateProps): react_jsx_runtime.JSX.Element;
1152
+ declare function ReceiveModalTemplate({ theme, accentColor, styleOverrides, walletAddress, chains, selectedChain, onSelectChain, copied, notReadyReason, recoveryLocked, onSetupRecovery, onCopy, onClose, }: ReceiveModalTemplateProps): react_jsx_runtime.JSX.Element;
1077
1153
 
1078
1154
  interface SessionsModalTemplateProps {
1079
1155
  theme: string;
@@ -1117,6 +1193,78 @@ interface CosignModalTemplateProps {
1117
1193
  }
1118
1194
  declare function CosignModalTemplate({ theme, accentColor, styleOverrides, pending, current, verification, busy, error, approveBlocked, lastResolved, explorerUrl, onSelect, onApprove, onReject, onClose, }: CosignModalTemplateProps): react_jsx_runtime.JSX.Element;
1119
1195
 
1196
+ interface CustodyMigrationModalProps {
1197
+ state: CustodyMigrationState;
1198
+ /** The wallets moved: the provider reads their state again and asks for a recovery method. */
1199
+ onMoved: () => void;
1200
+ /** A blocked wallet waits for what is pending; the provider stops asking until the next session. */
1201
+ onLater: () => void;
1202
+ }
1203
+ declare function CustodyMigrationModal({ state, onMoved, onLater }: CustodyMigrationModalProps): react_jsx_runtime.JSX.Element;
1204
+
1205
+ interface CustodyMigrationModalTemplateProps {
1206
+ theme: string;
1207
+ accentColor: string;
1208
+ styleOverrides?: ModalStyleOverrides;
1209
+ state: CustodyMigrationState;
1210
+ busy: boolean;
1211
+ error: string | null;
1212
+ /** What still points at a wallet that cannot move yet (an open ramp order, a transaction in flight). */
1213
+ blockedReasons: string[] | null;
1214
+ onMove: (custody?: CosignCustody) => void;
1215
+ /** Only offered while a wallet is blocked: the move waits for what is pending. */
1216
+ onLater: () => void;
1217
+ onLogout: () => void;
1218
+ }
1219
+ /**
1220
+ * The move of the wallets Pollar custodies to ones the user's device signs for.
1221
+ * It cannot be put off: the app's wallets live in Turnkey now, so the only ways
1222
+ * out are moving or logging out, unless something still pending holds a
1223
+ * wallet back.
1224
+ */
1225
+ declare function CustodyMigrationModalTemplate(p: CustodyMigrationModalTemplateProps): react_jsx_runtime.JSX.Element;
1226
+
1227
+ type RecoveryView = 'overview' | 'email' | 'export' | 'recover-email';
1228
+ interface RecoveryModalTemplateProps {
1229
+ theme: string;
1230
+ accentColor: string;
1231
+ styleOverrides?: ModalStyleOverrides;
1232
+ /** Null while the first read is in flight. */
1233
+ state: RecoveryState | null;
1234
+ devices: CosignDevicesContent | null;
1235
+ thisDeviceKey: string | null;
1236
+ /** Whether this device's key is one of the wallet's credentials. */
1237
+ thisDeviceEnrolled: boolean;
1238
+ /** Whether the runtime can run passkey ceremonies here. */
1239
+ passkeyAvailable: boolean;
1240
+ /** A self-custody wallet of an app that never asked the user to accept its risks. */
1241
+ selfCustodyRisks: boolean;
1242
+ view: RecoveryView;
1243
+ /** The action in flight, by key, for its button's spinner. */
1244
+ busy: string | null;
1245
+ error: string | null;
1246
+ notice: string | null;
1247
+ emailDraft: string;
1248
+ codeSent: boolean;
1249
+ /** The recovery phrase, once exported. */
1250
+ phrase: string | null;
1251
+ onView: (view: RecoveryView) => void;
1252
+ onEmailDraft: (email: string) => void;
1253
+ onAddPasskey: () => void;
1254
+ onRemovePasskey: (authenticatorId: string) => void;
1255
+ onSendEmailCode: () => void;
1256
+ onConfirmEmail: (code: string) => void;
1257
+ onApproveDevice: (enrollmentId: string) => void;
1258
+ onRejectDevice: (enrollmentId: string) => void;
1259
+ onRequestEnrollment: () => void;
1260
+ onRecoverWithPasskey: () => void;
1261
+ onSendRecoveryCode: () => void;
1262
+ onRecoverWithCode: (code: string) => void;
1263
+ onExport: () => void;
1264
+ onClose: () => void;
1265
+ }
1266
+ declare function RecoveryModalTemplate(p: RecoveryModalTemplateProps): react_jsx_runtime.JSX.Element;
1267
+
1120
1268
  interface DistributionRulesModalTemplateProps {
1121
1269
  theme: string;
1122
1270
  accentColor: string;
@@ -1132,4 +1280,11 @@ interface DistributionRulesModalTemplateProps {
1132
1280
  }
1133
1281
  declare function DistributionRulesModalTemplate({ theme, accentColor, styleOverrides, state, claimingId, claimErrors, claimedIds, onRefresh, onClaim, onClose, }: DistributionRulesModalTemplateProps): react_jsx_runtime.JSX.Element;
1134
1282
 
1135
- export { type AuthModalProps, CardModal, ChainSelect, type ChainSelectProps, CosignModal, CosignModalTemplate, type CosignModalTemplateProps, type CustomTrustlineModalTemplateProps, DistributionRulesModal, DistributionRulesModalTemplate, EarnModal, EnabledAssetsModal, EnabledAssetsModalTemplate, type EnabledAssetsModalTemplateProps, KycModal, KycModalTemplate, KycStatus, type KycStep, type LoginButtonProps, LoginModalTemplate, type ModalChrome, type ModalStyleOverrides, type ModalVariant, type PollarConfig, PollarProvider, type PollarStyles, ProviderRegistrationModal, type RampStep, RampWidget, RampWidgetTemplate, ReceiveModal, ReceiveModalTemplate, type ReceiveModalTemplateProps, RegistryCheckModal, RequirementFormModal, RouteDisplay, type SendMemoType, SendModal, SendModalTemplate, type SendModalTemplateProps, SessionsModal, SessionsModalTemplate, type SessionsModalTemplateProps, type SwapAssetOption, SwapModal, SwapModalTemplate, type SwapModalTemplateProps, TransactionModalTemplate, type TransactionModalTemplateProps, TxHistoryModalTemplate, TxStatusView, type TxStatusViewProps, type UseChainsResult, type UseCosignResult, WalletBalanceModal, WalletBalanceModalTemplate, type WalletBalanceModalTemplateProps, WalletButton, WalletButtonTemplate, type WalletButtonTemplateProps, addressForChain, browserPasskeyCeremony, browserPasskeySigner, buildModalCssVars, chainsOf, createPollarAdapterHook, modalChrome, readableTextOn, resolveChain, useChains, useCosign, usePollar, walletNotReadyReason };
1283
+ declare function RampWorkflow({ client, snapshot, onChange, onBusyChange, }: {
1284
+ client: PollarClient;
1285
+ snapshot: RampSnapshot;
1286
+ onChange: (next: RampsTransactionResponse) => void;
1287
+ onBusyChange?: (busy: boolean) => void;
1288
+ }): react_jsx_runtime.JSX.Element;
1289
+
1290
+ export { type AuthModalProps, CardModal, ChainSelect, type ChainSelectProps, CosignModal, CosignModalTemplate, type CosignModalTemplateProps, CustodyMigrationModal, CustodyMigrationModalTemplate, type CustodyMigrationModalTemplateProps, type CustomTrustlineModalTemplateProps, DistributionRulesModal, DistributionRulesModalTemplate, EarnModal, EnabledAssetsModal, EnabledAssetsModalTemplate, type EnabledAssetsModalTemplateProps, KycModal, KycModalTemplate, KycStatus, type KycStep, type LoginButtonProps, LoginModalTemplate, type ModalChrome, type ModalStyleOverrides, type ModalVariant, type PollarConfig, PollarProvider, type PollarStyles, ProviderRegistrationModal, type RampStep, RampWidget, RampWidgetTemplate, RampWorkflow, ReceiveModal, ReceiveModalTemplate, type ReceiveModalTemplateProps, RecoveryModal, RecoveryModalTemplate, type RecoveryModalTemplateProps, type RecoveryView, RegistryCheckModal, RequirementFormModal, RouteDisplay, type SendMemoType, SendModal, SendModalTemplate, type SendModalTemplateProps, SessionsModal, SessionsModalTemplate, type SessionsModalTemplateProps, type SwapAssetOption, SwapModal, SwapModalTemplate, type SwapModalTemplateProps, TransactionModalTemplate, type TransactionModalTemplateProps, TxHistoryModalTemplate, TxStatusView, type TxStatusViewProps, type UseChainsResult, type UseCosignResult, WalletBalanceModal, WalletBalanceModalTemplate, type WalletBalanceModalTemplateProps, WalletButton, WalletButtonTemplate, type WalletButtonTemplateProps, addressForChain, browserPasskeyCeremony, browserPasskeySigner, browserRecoveryPasskey, buildModalCssVars, chainsOf, createPollarAdapterHook, modalChrome, readableTextOn, resolveChain, useChains, useCosign, usePollar, walletNotReadyReason };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { pollarPaths, PollarClient, PollarClientConfig, PollarAdapters, OnStorageDegrade, WalletInfo, PollarLoginOptions, SessionsState, CosignState, PendingConfirmation, TransactionState, TxBuildBody, BuildOutcome, SubmitOutcome, SignOutcome, SendPaymentParams, StellarNetwork, WalletBalanceState, EnabledAssetsState, TrustlineOutcome, TxHistoryState, SwapVenue, SwapToken, SwapQuoteParams, SwapQuote, EarnProviderId, EarnOpportunity, EarnPositionParams, EarnPosition, EarnTxParams, PollarAdapter, PasskeyCeremony, PasskeySigner, WalletChain, CosignRequest, CosignVerification, CosignQuorumReport, CosignDevicesContent, KycStatus as KycStatus$1, RampQuote, WalletId, AuthState, KycProvider, KycStartResponse, RampDirection, RampCountry, RampQuoteRequirement, RampTxStatus, RampDepositInstructions, EnabledAssetRecord, WalletBalanceRecord, SwapProvider, DistributionRulesState, DistributionRule } from '@pollar/core';
2
+ import { pollarPaths, PollarClient, PollarClientConfig, PollarAdapters, OnStorageDegrade, WalletInfo, CosignCustody, PollarLoginOptions, SessionsState, CosignState, RecoveryState, CustodyMigrationState, PendingConfirmation, TransactionState, TxBuildBody, BuildOutcome, SubmitOutcome, SignOutcome, SendPaymentParams, StellarNetwork, WalletBalanceState, EnabledAssetsState, TrustlineOutcome, TxHistoryState, SwapVenue, SwapToken, SwapQuoteParams, SwapQuote, EarnProviderId, EarnOpportunity, EarnPositionParams, EarnPosition, EarnTxParams, PollarAdapter, PasskeyCeremony, PasskeySigner, RecoveryPasskeyCeremony, WalletChain, CosignRequest, CosignVerification, CosignQuorumReport, CosignDevicesContent, KycStatus as KycStatus$1, RampQuote, WalletId, AuthState, KycProvider, KycStartResponse, RampDirection, RampCountry, RampQuoteRequirement, RampTxStatus, RampDepositInstructions, EnabledAssetRecord, WalletBalanceRecord, SwapProvider, DistributionRulesState, DistributionRule, RampSnapshot, RampsTransactionResponse } from '@pollar/core';
3
3
  export { AuthProviderContext, PollarAuthProvider, SessionsState } from '@pollar/core';
4
4
  import { ReactNode, CSSProperties } from 'react';
5
5
 
@@ -43,8 +43,13 @@ interface PollarContextValue {
43
43
  * creates none.
44
44
  */
45
45
  hasWallet: boolean;
46
- /** Create the signed-in user's wallet; see `PollarClient.createWallet`. */
47
- createWallet: () => Promise<WalletInfo>;
46
+ /**
47
+ * Create the signed-in user's wallet; see `PollarClient.createWallet`. An app
48
+ * whose custody mode is USER_CHOICE needs `custody`: the user's pick.
49
+ */
50
+ createWallet: (options?: {
51
+ custody?: CosignCustody;
52
+ }) => Promise<WalletInfo>;
48
53
  /**
49
54
  * `true` once the server has confirmed the session (login / refresh /
50
55
  * `/auth/session/resume`). `false` while a cold-start session is still
@@ -60,6 +65,24 @@ interface PollarContextValue {
60
65
  cosign: CosignState;
61
66
  /** Open the approval prompt of a co-signed wallet. Opens by itself when a request arrives. */
62
67
  openCosignModal: () => void;
68
+ /**
69
+ * The recovery state of the user's Turnkey wallet: null until read, or for a
70
+ * session without one. `recoveryLocked` is true while the wallet has no way
71
+ * to be recovered without this device: it signs nothing but its own setup.
72
+ */
73
+ recovery: RecoveryState | null;
74
+ recoveryLocked: boolean;
75
+ /** Read the recovery state again (after a method changed elsewhere). */
76
+ refreshRecovery: () => void;
77
+ /** Open the recovery methods modal: passkeys, email, devices, export. */
78
+ openRecoveryModal: () => void;
79
+ /**
80
+ * Whether the user's wallet, one Pollar custodies, has to move to this
81
+ * device because the app keeps its wallets in Turnkey. While `required`, the
82
+ * provider shows the move and nothing else; null until read.
83
+ */
84
+ custodyMigration: CustodyMigrationState | null;
85
+ refreshCustodyMigration: () => void;
63
86
  /** Signing calls waiting for the user under `confirmation: 'prompt'`; the provider shows the first one. */
64
87
  confirmations: PendingConfirmation[];
65
88
  appConfig: PollarConfig;
@@ -277,6 +300,15 @@ declare const browserPasskeyCeremony: PasskeyCeremony;
277
300
  * entry. The secp256r1 key never leaves the device.
278
301
  */
279
302
  declare const browserPasskeySigner: PasskeySigner;
303
+ /**
304
+ * Browser passkey ceremonies for a Turnkey wallet's recovery: register a
305
+ * passkey as a way back in, and sign a Turnkey request with one to add a new
306
+ * device. rpId is the page's hostname, like the smart-wallet ceremony, so a
307
+ * passkey made on the app's domain recovers the wallet on that domain.
308
+ * `challenge` arrives base64url already: for `get()` it is what Turnkey checks
309
+ * (the hex SHA-256 of the request body).
310
+ */
311
+ declare const browserRecoveryPasskey: RecoveryPasskeyCeremony;
280
312
 
281
313
  /**
282
314
  * The one place the widget decides whether a wallet can act on-chain, and what
@@ -318,6 +350,13 @@ interface WalletButtonTemplateProps {
318
350
  * custom template written before this existed keeps compiling.
319
351
  */
320
352
  notReadyReason?: string | null;
353
+ /**
354
+ * The wallet has no recovery method yet and signs nothing but its own setup.
355
+ * Shown at the top of the menu with a way to fix it. Optional for custom templates.
356
+ */
357
+ recoveryLocked?: boolean;
358
+ /** Open the recovery methods; the item shows only when set. */
359
+ onRecovery?: () => void;
321
360
  creatingAccount: boolean;
322
361
  /**
323
362
  * Signed in with no wallet yet (an app that creates wallets on demand, or
@@ -328,7 +367,13 @@ interface WalletButtonTemplateProps {
328
367
  signedIn?: boolean;
329
368
  creatingWallet?: boolean;
330
369
  createWalletError?: string | null;
331
- onCreateWallet?: () => void;
370
+ /**
371
+ * The app leaves the custody to the user (USER_CHOICE): Create wallet offers
372
+ * co-signed and self-custody, and calls `onCreateWallet` with the pick. A
373
+ * self-custody wallet is created only after the user accepts its risks.
374
+ */
375
+ custodyChoice?: boolean;
376
+ onCreateWallet?: (custody?: CosignCustody) => void;
332
377
  onToggleOpen: () => void;
333
378
  onCreateAccount: () => void;
334
379
  onCopy: () => void;
@@ -343,7 +388,7 @@ interface WalletButtonTemplateProps {
343
388
  onLogout: () => void;
344
389
  onLogin: () => void;
345
390
  }
346
- declare function WalletButtonTemplate({ walletAddress, accentColor, open, copied, dropdownBg, dropdownBorder, itemColor, wrapperRef, isInProgress, showCreateAccount, notReadyReason, creatingAccount, onToggleOpen, onCreateAccount, onCopy, onWalletBalance, onTxHistory, onSend, onReceive, onSessions, onKyc, onRamp, onDistributionRules, onLogout, onLogin, signedIn, creatingWallet, createWalletError, onCreateWallet, }: WalletButtonTemplateProps): react_jsx_runtime.JSX.Element;
391
+ declare function WalletButtonTemplate({ walletAddress, accentColor, open, copied, dropdownBg, dropdownBorder, itemColor, wrapperRef, isInProgress, showCreateAccount, notReadyReason, recoveryLocked, onRecovery, creatingAccount, onToggleOpen, onCreateAccount, onCopy, onWalletBalance, onTxHistory, onSend, onReceive, onSessions, onKyc, onRamp, onDistributionRules, onLogout, onLogin, signedIn, creatingWallet, createWalletError, custodyChoice, onCreateWallet, }: WalletButtonTemplateProps): react_jsx_runtime.JSX.Element;
347
392
 
348
393
  /**
349
394
  * The chain a record lives on, with the legacy shape folded in: sessions and
@@ -418,7 +463,7 @@ interface UseCosignResult {
418
463
  reject: (request: CosignRequest) => Promise<CosignRequest>;
419
464
  /** The verification a UI can show before the user decides. */
420
465
  verify: (request: CosignRequest) => Promise<CosignVerification>;
421
- /** Read the sub-organization from Turnkey with the device key and record whether it is the promised 2-of-2. */
466
+ /** Read the sub-organization from Turnkey with the device key and record whether it is the quorum its custody promises. */
422
467
  inspectQuorum: () => Promise<CosignQuorumReport>;
423
468
  /** The user's enrolled devices and the quorum state as sdk-api records it. */
424
469
  devices: () => Promise<CosignDevicesContent>;
@@ -426,6 +471,8 @@ interface UseCosignResult {
426
471
  revokeDevice: (deviceId: string, options?: {
427
472
  force?: boolean;
428
473
  }) => Promise<CosignDevicesContent>;
474
+ /** Move the wallet between co-signed and self-custody; only an app in USER_CHOICE custody allows it. */
475
+ switchCustody: (to: CosignCustody) => Promise<CosignQuorumReport>;
429
476
  }
430
477
  /**
431
478
  * The user's side of a Turnkey co-signed wallet, for an app that renders its
@@ -574,6 +621,18 @@ interface CosignModalProps {
574
621
  */
575
622
  declare function CosignModal({ onClose }: CosignModalProps): react_jsx_runtime.JSX.Element;
576
623
 
624
+ interface RecoveryModalProps {
625
+ onClose: () => void;
626
+ }
627
+ /**
628
+ * The recovery methods of a Turnkey wallet: add and remove passkeys, confirm
629
+ * an email, approve another device, export the recovery phrase, and, on a
630
+ * device that is not part of the wallet, get back in. Until one method exists
631
+ * the wallet signs nothing but its own setup, so this is also where a locked
632
+ * wallet sends the user.
633
+ */
634
+ declare function RecoveryModal({ onClose }: RecoveryModalProps): react_jsx_runtime.JSX.Element;
635
+
577
636
  interface DistributionRulesModalProps {
578
637
  onClose: () => void;
579
638
  }
@@ -704,7 +763,7 @@ interface RampFieldSpec {
704
763
  key: string;
705
764
  label: string;
706
765
  type: 'text' | 'email' | 'tel' | 'select';
707
- bankType?: 'CLABE' | 'PIX' | 'PSE' | 'ACH' | 'BREB';
766
+ bankType?: string;
708
767
  /** For `type: 'select'` - dropdown choices (e.g. Stereum's Bolivian banks). */
709
768
  options?: {
710
769
  value: string;
@@ -725,6 +784,8 @@ interface RampFieldSpec {
725
784
  hint?: string;
726
785
  }
727
786
  interface RampWidgetTemplateProps {
787
+ workflowContent?: React.ReactNode;
788
+ routeSelector?: React.ReactNode;
728
789
  theme: string;
729
790
  accentColor: string;
730
791
  /** Per-app modal chrome overrides (background, card + button radius). */
@@ -786,6 +847,14 @@ interface RampWidgetTemplateProps {
786
847
  depositInstructions: RampDepositInstructions | null;
787
848
  canComplete: boolean;
788
849
  completing: boolean;
850
+ savedRamps?: Array<{
851
+ txId: string;
852
+ provider: string;
853
+ }>;
854
+ onResumeRamp?: (id: string) => void;
855
+ onDismissRamp?: (id: string) => void;
856
+ onDismissCurrentRamp?: (() => void) | undefined;
857
+ onExploreRoutes?: (() => void) | undefined;
789
858
  errorMsg: string | null;
790
859
  /** Neutral guidance on the route list, e.g. after identity verification sent the user back to it. */
791
860
  noticeMsg?: string | null;
@@ -807,7 +876,7 @@ interface RampWidgetTemplateProps {
807
876
  onRefresh: () => void;
808
877
  onClose: () => void;
809
878
  }
810
- declare function RampWidgetTemplate({ theme, accentColor, styleOverrides, step, flowSteps, flowStepIndex, startingQuoteId, direction, amount, currency, country, requiredFields, fieldValues, countries, countriesLoading, refreshing, quotes, kycRequired, isLoading, provider, txStatus, kycUrl, tosUrl, kycBlocking, onboardingStatus, kycJustApproved, stellarTxHash, txHash, txChain, explorerUrl, fundsInTransit, retrying, onRetryTransit, depositInstructions, canComplete, completing, errorMsg, noticeMsg, onDirectionChange, onAmountChange, onFieldChange, onCountryChange, onFindRoute, onSelectQuote, onVerifyRoute, onContactContinue, onOpenKyc, onOpenTos, onCompleteWithdraw, onBack, onRetry, onRefresh, onClose, }: RampWidgetTemplateProps): react_jsx_runtime.JSX.Element;
879
+ declare function RampWidgetTemplate({ workflowContent, routeSelector, theme, accentColor, styleOverrides, step, flowSteps, flowStepIndex, startingQuoteId, direction, amount, currency, country, requiredFields, fieldValues, countries, countriesLoading, refreshing, quotes, kycRequired, isLoading, provider, txStatus, kycUrl, tosUrl, kycBlocking, onboardingStatus, kycJustApproved, stellarTxHash, txHash, txChain, explorerUrl, fundsInTransit, retrying, onRetryTransit, depositInstructions, canComplete, completing, savedRamps, onResumeRamp, onDismissRamp, onDismissCurrentRamp, onExploreRoutes, errorMsg, noticeMsg, onDirectionChange, onAmountChange, onFieldChange, onCountryChange, onFindRoute, onSelectQuote, onVerifyRoute, onContactContinue, onOpenKyc, onOpenTos, onCompleteWithdraw, onBack, onRetry, onRefresh, onClose, }: RampWidgetTemplateProps): react_jsx_runtime.JSX.Element;
811
880
 
812
881
  interface TransactionModalTemplateProps {
813
882
  theme: string;
@@ -1070,10 +1139,17 @@ interface ReceiveModalTemplateProps {
1070
1139
  * custom template written before this existed keeps compiling.
1071
1140
  */
1072
1141
  notReadyReason?: string | null;
1142
+ /**
1143
+ * The wallet has no way to be recovered without this device yet. The address
1144
+ * stays hidden until the user adds one, so nobody is handed an address whose
1145
+ * funds a lost phone would take with it. Optional for custom templates.
1146
+ */
1147
+ recoveryLocked?: boolean;
1148
+ onSetupRecovery?: () => void;
1073
1149
  onCopy: () => void;
1074
1150
  onClose: () => void;
1075
1151
  }
1076
- declare function ReceiveModalTemplate({ theme, accentColor, styleOverrides, walletAddress, chains, selectedChain, onSelectChain, copied, notReadyReason, onCopy, onClose, }: ReceiveModalTemplateProps): react_jsx_runtime.JSX.Element;
1152
+ declare function ReceiveModalTemplate({ theme, accentColor, styleOverrides, walletAddress, chains, selectedChain, onSelectChain, copied, notReadyReason, recoveryLocked, onSetupRecovery, onCopy, onClose, }: ReceiveModalTemplateProps): react_jsx_runtime.JSX.Element;
1077
1153
 
1078
1154
  interface SessionsModalTemplateProps {
1079
1155
  theme: string;
@@ -1117,6 +1193,78 @@ interface CosignModalTemplateProps {
1117
1193
  }
1118
1194
  declare function CosignModalTemplate({ theme, accentColor, styleOverrides, pending, current, verification, busy, error, approveBlocked, lastResolved, explorerUrl, onSelect, onApprove, onReject, onClose, }: CosignModalTemplateProps): react_jsx_runtime.JSX.Element;
1119
1195
 
1196
+ interface CustodyMigrationModalProps {
1197
+ state: CustodyMigrationState;
1198
+ /** The wallets moved: the provider reads their state again and asks for a recovery method. */
1199
+ onMoved: () => void;
1200
+ /** A blocked wallet waits for what is pending; the provider stops asking until the next session. */
1201
+ onLater: () => void;
1202
+ }
1203
+ declare function CustodyMigrationModal({ state, onMoved, onLater }: CustodyMigrationModalProps): react_jsx_runtime.JSX.Element;
1204
+
1205
+ interface CustodyMigrationModalTemplateProps {
1206
+ theme: string;
1207
+ accentColor: string;
1208
+ styleOverrides?: ModalStyleOverrides;
1209
+ state: CustodyMigrationState;
1210
+ busy: boolean;
1211
+ error: string | null;
1212
+ /** What still points at a wallet that cannot move yet (an open ramp order, a transaction in flight). */
1213
+ blockedReasons: string[] | null;
1214
+ onMove: (custody?: CosignCustody) => void;
1215
+ /** Only offered while a wallet is blocked: the move waits for what is pending. */
1216
+ onLater: () => void;
1217
+ onLogout: () => void;
1218
+ }
1219
+ /**
1220
+ * The move of the wallets Pollar custodies to ones the user's device signs for.
1221
+ * It cannot be put off: the app's wallets live in Turnkey now, so the only ways
1222
+ * out are moving or logging out, unless something still pending holds a
1223
+ * wallet back.
1224
+ */
1225
+ declare function CustodyMigrationModalTemplate(p: CustodyMigrationModalTemplateProps): react_jsx_runtime.JSX.Element;
1226
+
1227
+ type RecoveryView = 'overview' | 'email' | 'export' | 'recover-email';
1228
+ interface RecoveryModalTemplateProps {
1229
+ theme: string;
1230
+ accentColor: string;
1231
+ styleOverrides?: ModalStyleOverrides;
1232
+ /** Null while the first read is in flight. */
1233
+ state: RecoveryState | null;
1234
+ devices: CosignDevicesContent | null;
1235
+ thisDeviceKey: string | null;
1236
+ /** Whether this device's key is one of the wallet's credentials. */
1237
+ thisDeviceEnrolled: boolean;
1238
+ /** Whether the runtime can run passkey ceremonies here. */
1239
+ passkeyAvailable: boolean;
1240
+ /** A self-custody wallet of an app that never asked the user to accept its risks. */
1241
+ selfCustodyRisks: boolean;
1242
+ view: RecoveryView;
1243
+ /** The action in flight, by key, for its button's spinner. */
1244
+ busy: string | null;
1245
+ error: string | null;
1246
+ notice: string | null;
1247
+ emailDraft: string;
1248
+ codeSent: boolean;
1249
+ /** The recovery phrase, once exported. */
1250
+ phrase: string | null;
1251
+ onView: (view: RecoveryView) => void;
1252
+ onEmailDraft: (email: string) => void;
1253
+ onAddPasskey: () => void;
1254
+ onRemovePasskey: (authenticatorId: string) => void;
1255
+ onSendEmailCode: () => void;
1256
+ onConfirmEmail: (code: string) => void;
1257
+ onApproveDevice: (enrollmentId: string) => void;
1258
+ onRejectDevice: (enrollmentId: string) => void;
1259
+ onRequestEnrollment: () => void;
1260
+ onRecoverWithPasskey: () => void;
1261
+ onSendRecoveryCode: () => void;
1262
+ onRecoverWithCode: (code: string) => void;
1263
+ onExport: () => void;
1264
+ onClose: () => void;
1265
+ }
1266
+ declare function RecoveryModalTemplate(p: RecoveryModalTemplateProps): react_jsx_runtime.JSX.Element;
1267
+
1120
1268
  interface DistributionRulesModalTemplateProps {
1121
1269
  theme: string;
1122
1270
  accentColor: string;
@@ -1132,4 +1280,11 @@ interface DistributionRulesModalTemplateProps {
1132
1280
  }
1133
1281
  declare function DistributionRulesModalTemplate({ theme, accentColor, styleOverrides, state, claimingId, claimErrors, claimedIds, onRefresh, onClaim, onClose, }: DistributionRulesModalTemplateProps): react_jsx_runtime.JSX.Element;
1134
1282
 
1135
- export { type AuthModalProps, CardModal, ChainSelect, type ChainSelectProps, CosignModal, CosignModalTemplate, type CosignModalTemplateProps, type CustomTrustlineModalTemplateProps, DistributionRulesModal, DistributionRulesModalTemplate, EarnModal, EnabledAssetsModal, EnabledAssetsModalTemplate, type EnabledAssetsModalTemplateProps, KycModal, KycModalTemplate, KycStatus, type KycStep, type LoginButtonProps, LoginModalTemplate, type ModalChrome, type ModalStyleOverrides, type ModalVariant, type PollarConfig, PollarProvider, type PollarStyles, ProviderRegistrationModal, type RampStep, RampWidget, RampWidgetTemplate, ReceiveModal, ReceiveModalTemplate, type ReceiveModalTemplateProps, RegistryCheckModal, RequirementFormModal, RouteDisplay, type SendMemoType, SendModal, SendModalTemplate, type SendModalTemplateProps, SessionsModal, SessionsModalTemplate, type SessionsModalTemplateProps, type SwapAssetOption, SwapModal, SwapModalTemplate, type SwapModalTemplateProps, TransactionModalTemplate, type TransactionModalTemplateProps, TxHistoryModalTemplate, TxStatusView, type TxStatusViewProps, type UseChainsResult, type UseCosignResult, WalletBalanceModal, WalletBalanceModalTemplate, type WalletBalanceModalTemplateProps, WalletButton, WalletButtonTemplate, type WalletButtonTemplateProps, addressForChain, browserPasskeyCeremony, browserPasskeySigner, buildModalCssVars, chainsOf, createPollarAdapterHook, modalChrome, readableTextOn, resolveChain, useChains, useCosign, usePollar, walletNotReadyReason };
1283
+ declare function RampWorkflow({ client, snapshot, onChange, onBusyChange, }: {
1284
+ client: PollarClient;
1285
+ snapshot: RampSnapshot;
1286
+ onChange: (next: RampsTransactionResponse) => void;
1287
+ onBusyChange?: (busy: boolean) => void;
1288
+ }): react_jsx_runtime.JSX.Element;
1289
+
1290
+ export { type AuthModalProps, CardModal, ChainSelect, type ChainSelectProps, CosignModal, CosignModalTemplate, type CosignModalTemplateProps, CustodyMigrationModal, CustodyMigrationModalTemplate, type CustodyMigrationModalTemplateProps, type CustomTrustlineModalTemplateProps, DistributionRulesModal, DistributionRulesModalTemplate, EarnModal, EnabledAssetsModal, EnabledAssetsModalTemplate, type EnabledAssetsModalTemplateProps, KycModal, KycModalTemplate, KycStatus, type KycStep, type LoginButtonProps, LoginModalTemplate, type ModalChrome, type ModalStyleOverrides, type ModalVariant, type PollarConfig, PollarProvider, type PollarStyles, ProviderRegistrationModal, type RampStep, RampWidget, RampWidgetTemplate, RampWorkflow, ReceiveModal, ReceiveModalTemplate, type ReceiveModalTemplateProps, RecoveryModal, RecoveryModalTemplate, type RecoveryModalTemplateProps, type RecoveryView, RegistryCheckModal, RequirementFormModal, RouteDisplay, type SendMemoType, SendModal, SendModalTemplate, type SendModalTemplateProps, SessionsModal, SessionsModalTemplate, type SessionsModalTemplateProps, type SwapAssetOption, SwapModal, SwapModalTemplate, type SwapModalTemplateProps, TransactionModalTemplate, type TransactionModalTemplateProps, TxHistoryModalTemplate, TxStatusView, type TxStatusViewProps, type UseChainsResult, type UseCosignResult, WalletBalanceModal, WalletBalanceModalTemplate, type WalletBalanceModalTemplateProps, WalletButton, WalletButtonTemplate, type WalletButtonTemplateProps, addressForChain, browserPasskeyCeremony, browserPasskeySigner, browserRecoveryPasskey, buildModalCssVars, chainsOf, createPollarAdapterHook, modalChrome, readableTextOn, resolveChain, useChains, useCosign, usePollar, walletNotReadyReason };