@capxul/sdk-react 0.1.0-alpha.3 → 0.1.0-alpha.6

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
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
- import { HttpTransport, TransportState, CapxulConfig, BrowserCapxulConfig, AccountId, OrganizationId, ApiKeyId, BalanceLedgerEntryId, ExternalAccountId, MemberId, Account, ApiKey, BalanceLedgerEntry, DocumentId, Document, ExternalAccount, KybProfile, KycProfile, CapxulError as CapxulError$1, Member, OperationId, Operation, Organization, PaymentId, Payment, SafeId, Safe, SubAccountId, SubAccount, TransferId, Transfer, Treasury, VirtualAccountId, VirtualAccount, VirtualCardId, VirtualCard, WebhookEndpointId, WebhookEndpoint, WebhookEventId, WebhookEvent, WithdrawalId, Withdrawal, List, LocalPrivateKeySignerProvider } from '@capxul/sdk';
2
+ import { HttpTransport, TransportState, BrowserCapxulConfig, AuthSessionStore, AccountId, OrganizationId, ApiKeyId, BalanceLedgerEntryId, ExternalAccountId, MemberId, Account, ApiKey, BalanceLedgerEntry, DocumentId, Document, ExternalAccount, KybProfile, KycProfile, CapxulError as CapxulError$1, Member, OperationId, Operation, Organization, PaymentId, Payment, SafeId, Safe, SubAccountId, SubAccount, TokenTransfer, TransferId, Transfer, Treasury, VirtualAccountId, VirtualAccount, VirtualCardId, VirtualCard, WebhookEndpointId, WebhookEndpoint, WebhookEventId, WebhookEvent, WithdrawalId, Withdrawal, List, TokenTransfersListInput, TokenTransfersListPage, LocalPrivateKeySignerProvider } from '@capxul/sdk';
3
3
  export { AuthFlowContext, AuthFlowEvent, BrowserCapxulConfig, OnboardingFlowContext, OnboardingFlowEvent, ProvisioningFlowContext, ProvisioningFlowEvent } from '@capxul/sdk';
4
4
  import { QueryClient, UseQueryResult } from '@tanstack/react-query';
5
5
  import { CapxulClient } from '@capxul/sdk/client';
@@ -55,55 +55,64 @@ declare function CapxulTransportProvider({ transport, children, }: CapxulTranspo
55
55
  declare function useCapxulStatus(): TransportState;
56
56
 
57
57
  /**
58
- * `CapxulProvider` — React context provider that wires both the
59
- * `@capxul/sdk` client AND a TanStack Query `QueryClient` for the
60
- * subtree.
58
+ * `CapxulProvider` — public React provider for `@capxul/sdk-react`.
61
59
  *
62
- * Two construction paths:
60
+ * Single-input contract: accepts ONLY `{ config: BrowserCapxulConfig,
61
+ * sessionStore?, queryClient?, children }`. The browser config is the
62
+ * secret-safe discriminated union from `@capxul/sdk` — `apiKey`,
63
+ * `data`, `signer`, and other server-only fields are rejected at
64
+ * compile-time AND at runtime via `createCapxulConfig`'s allow-list
65
+ * validator.
63
66
  *
64
- * 1. **Legacy / harness path** pass an already-assembled
65
- * `config: CapxulConfig`. Used by the e2e harness and CLI-shaped
66
- * integrations that build their own auth/data adapters.
67
+ * The provider builds an `HttpTransport` synchronously and injects it
68
+ * into `createCapxulClient` via the internal `_transport` slot. The
69
+ * transport is exposed through `CapxulTransportContext` so
70
+ * `useCapxulStatus()` can subscribe to its lifecycle state machine.
67
71
  *
68
- * 2. **Lazy-DX path (ADR #14c)** pass either `publishableKey` or
69
- * `browserConfig`. The provider builds an `HttpTransport`
70
- * synchronously, injects it into `createCapxulClient` via the
71
- * internal `_transport` slot, and exposes the transport through
72
- * `CapxulTransportContext` so `useCapxulStatus()` can subscribe
73
- * to its lifecycle state machine.
72
+ * The provider also builds a `ConvexReactClient`-backed data client
73
+ * for the `build-time-urls` arm and feeds it as `config.data` so the
74
+ * SDK domain methods (`me.get`, `accounts.retrieve`, ...) and the
75
+ * React hooks built on top can run authenticated reads against live
76
+ * Convex. The auth lifecycle threads through the optional
77
+ * `sessionStore` prop: `verifyOtp` writes a session to the store
78
+ * (which the SDK auth client persists), and the provider's data
79
+ * client re-reads the JWT on demand via `refreshAuth()`. Without a
80
+ * session store the provider falls back to an in-memory one, which
81
+ * is fine for browser apps that hold the page until next reload but
82
+ * inadequate for CLI / Node consumers that need cross-process
83
+ * persistence — those pass a file-backed store via the prop.
74
84
  *
75
- * The lazy-DX provider mounts synchronously. There is no
76
- * `useState` mutating config, no `useMemo` rebuilding config when
77
- * state changes, and no Suspense gate at mount. State transitions
78
- * happen on the transport (a stable singleton); React subscribes
79
- * via `useSyncExternalStore` and re-renders only the components
80
- * that actually depend on the transport state.
85
+ * Tests and the e2e harness need the server-augmented `CapxulConfig`
86
+ * shape (with `data`, `signer`, `signing`). Those callers use
87
+ * `CapxulTestProvider` from `@capxul/sdk-react/proof` instead.
81
88
  *
82
89
  * Per ADR 4 in the API-first architecture stack PLAN, only
83
90
  * `QueryClientProvider` is allowed to live OUTSIDE the single
84
91
  * `CapxulContext`. The `QueryClientProvider` is the outermost wrap;
85
- * the SDK client provider sits inside it; the optional transport
86
- * provider sits between the two when the lazy-DX path is active.
92
+ * the SDK client provider sits inside it; the transport provider sits
93
+ * between the two.
87
94
  */
88
95
 
89
96
  type CapxulProviderProps = {
90
97
  /**
91
- * Pre-assembled `CapxulConfig` for the legacy / harness path.
92
- * Mutually exclusive with `publishableKey` / `browserConfig`.
98
+ * Browser-safe Capxul config the discriminated union from
99
+ * `@capxul/sdk`. Either the `build-time-urls` arm or the
100
+ * `publishable-key` arm. Server-only fields (`apiKey`, `data`,
101
+ * `signer`, `signing`) are rejected at compile-time and at runtime
102
+ * via `createCapxulConfig`'s allow-list validator.
93
103
  */
94
- readonly config?: CapxulConfig;
104
+ readonly config: BrowserCapxulConfig;
95
105
  /**
96
- * Shorthand for the publishable-key arm of `BrowserCapxulConfig`.
97
- * Provider builds the transport synchronously and injects it into
98
- * the SDK client the canonical lazy-DX entry point per ADR #14c.
106
+ * Auth session persistence adapter. The SDK auth client writes
107
+ * sessions here on `verifyOtp` and clears them on `signOut`. The
108
+ * provider's data client re-reads the JWT from this store on every
109
+ * `refreshAuth` call so reads carry the right auth header.
110
+ *
111
+ * Defaults to an in-memory store scoped to this provider. Pass a
112
+ * file-backed (Node CLI) or `localStorage`-backed (browser) store
113
+ * to persist sessions across process or page lifetimes.
99
114
  */
100
- readonly publishableKey?: string;
101
- /**
102
- * Full `BrowserCapxulConfig` for callers that need
103
- * `mode: "build-time-urls"` or a custom `fetchImpl` (e.g. tests).
104
- * Mutually exclusive with `publishableKey` / `config`.
105
- */
106
- readonly browserConfig?: BrowserCapxulConfig;
115
+ readonly sessionStore?: AuthSessionStore;
107
116
  /**
108
117
  * Optional TanStack Query `QueryClient`. Pass your app's existing
109
118
  * client to share the cache across the SDK hooks and the host
@@ -113,7 +122,7 @@ type CapxulProviderProps = {
113
122
  readonly queryClient?: QueryClient;
114
123
  readonly children: ReactNode;
115
124
  };
116
- declare function CapxulProvider({ config, publishableKey, browserConfig, queryClient, children, }: CapxulProviderProps): ReactNode;
125
+ declare function CapxulProvider({ config, sessionStore, queryClient, children, }: CapxulProviderProps): ReactNode;
117
126
 
118
127
  /**
119
128
  * `QueryResult<T>` — the canonical three-state return shape for every
@@ -220,16 +229,27 @@ declare function useMe(): UseQueryResult<Account, CapxulError$1>;
220
229
  /**
221
230
  * Account by id. Omit `accountId` for the calling user (alias for
222
231
  * `useMe()` from a developer-perspective lens).
232
+ *
233
+ * Slice 2 (#457 story 1): wired via `capxul.accounts.retrieve` for
234
+ * the id-bearing call and `capxul.me.get()` for the self-lens
235
+ * shortcut. Returns the legacy `QueryResult<Account>` shape because
236
+ * only `useMe` has migrated to TanStack Query so far (PLAN.md task
237
+ * 1.8) — per-hook migration is the rollout pattern.
223
238
  */
224
- declare function useAccount(_accountId?: AccountId): QueryResult<Account>;
239
+ declare function useAccount(accountId?: AccountId): QueryResult<Account>;
225
240
  declare function useOrganization(_organizationId: OrganizationId): QueryResult<Organization>;
226
241
  declare function useMember(_args: UseMemberArgs): QueryResult<Member>;
227
242
  /**
228
243
  * Live; status advances as the indexer reconciles the on-chain
229
244
  * deployment. Consumers pattern-match on `data.status` via
230
245
  * `matchStatus` (see `@capxul/sdk`).
246
+ *
247
+ * Slice 2 (#457 story 1): wired via
248
+ * `capxul.accounts.safes.retrieve(safeId)`. The SDK method is real
249
+ * post-Withdrawals v1 slice 1; this hook closes the React-side
250
+ * stub so onboarding can subscribe to Safe deploy progress.
231
251
  */
232
- declare function useSafe(_safeId: SafeId): QueryResult<Safe>;
252
+ declare function useSafe(safeId: SafeId): QueryResult<Safe>;
233
253
  declare function useTreasury(_organizationId: OrganizationId): QueryResult<Treasury>;
234
254
  /**
235
255
  * Org-admin lens only — the hook NEVER returns `secret`.
@@ -237,19 +257,51 @@ declare function useTreasury(_organizationId: OrganizationId): QueryResult<Treas
237
257
  declare function useApiKey(_args: UseApiKeyArgs): QueryResult<ApiKey>;
238
258
  declare function useKycProfile(_accountId: AccountId): QueryResult<KycProfile>;
239
259
  declare function useKybProfile(_organizationId: OrganizationId): QueryResult<KybProfile>;
240
- declare function useExternalAccount(_args: UseExternalAccountArgs): QueryResult<ExternalAccount>;
260
+ /**
261
+ * Withdrawals v1 W1 (#464) — wired through the SDK.
262
+ *
263
+ * Branches on `args.ownerKind` so `account` scope reads via the
264
+ * top-level `capxul.externalAccounts.retrieve(id)` (visibility-gated
265
+ * server-side by the caller's accountId), and `organization` scope
266
+ * reads via `capxul.organizations.externalAccounts.retrieve({ ... })`
267
+ * which adds an org-scope check for cross-org isolation. Both routes
268
+ * resolve to the same Convex query handler — the SDK ergonomics
269
+ * differ but the wire shape is identical.
270
+ */
271
+ declare function useExternalAccount(args: UseExternalAccountArgs): QueryResult<ExternalAccount>;
241
272
  declare function useSubAccount(_subAccountId: SubAccountId): QueryResult<SubAccount>;
242
273
  declare function useVirtualAccount(_virtualAccountId: VirtualAccountId): QueryResult<VirtualAccount>;
243
274
  declare function useVirtualCard(_virtualCardId: VirtualCardId): QueryResult<VirtualCard>;
244
275
  declare function usePayment(_paymentId: PaymentId): QueryResult<Payment>;
245
276
  declare function useTransfer(_transferId: TransferId): QueryResult<Transfer>;
277
+ type UseTokenTransferArgs = {
278
+ readonly txHash: string;
279
+ readonly logIndex: number;
280
+ readonly chainId?: number;
281
+ };
282
+ /**
283
+ * **NON-CANONICAL** raw on-chain ERC-20 transfer detail. Wired through
284
+ * `capxul.tokenTransfers.retrieve` per slice/02-story2-balance
285
+ * Option-A verdict. Identifier is the canonical on-chain composite
286
+ * `(txHash, logIndex)` so consumers don't have to round-trip through
287
+ * the Convex doc id.
288
+ *
289
+ * Intentionally NOT in `packages/sdk-react/ops/proof/hook-manifest.ts`
290
+ * — the canonical proof manifest tracks canon-aligned hooks only.
291
+ */
292
+ declare function useTokenTransfer(args: UseTokenTransferArgs): QueryResult<TokenTransfer>;
246
293
  /**
247
294
  * Immutable once written; `live` semantically only for late
248
295
  * `paymentId` / `transferId` attachment per Doc 02 §"balance_ledger".
249
296
  */
250
297
  declare function useBalanceLedgerEntry(_args: UseBalanceLedgerEntryArgs): QueryResult<BalanceLedgerEntry>;
251
298
  declare function useDocument(_documentId: DocumentId): QueryResult<Document>;
252
- declare function useWithdrawal(_withdrawalId: WithdrawalId): QueryResult<Withdrawal>;
299
+ /**
300
+ * Withdrawals v1 slice 1 (#440) — wired through `capxul.withdrawals.retrieve`.
301
+ * Mirrors `useOperation` (the canonical evidence subscription) since
302
+ * the withdrawal resource is operation-shaped at its core.
303
+ */
304
+ declare function useWithdrawal(withdrawalId: WithdrawalId): QueryResult<Withdrawal>;
253
305
  /**
254
306
  * The canonical evidence subscription per CANON.md §3.3 —
255
307
  * `operationId` + `correlationId` are the cross-layer join keys for
@@ -328,7 +380,17 @@ type OrgDocumentsFilters = OrgScopedFilters & {
328
380
  */
329
381
  declare function useOrganizations(): QueryResult<List<Organization>>;
330
382
  declare function useMembers(_organizationId: OrganizationId): QueryResult<List<Member>>;
331
- declare function useExternalAccounts(_args: OwnerRef): QueryResult<List<ExternalAccount>>;
383
+ /**
384
+ * Withdrawals v1 W1 (#464) — wired through the SDK.
385
+ *
386
+ * Personal scope reads through `capxul.accounts.externalAccounts.list({
387
+ * accountId })` (Pattern A nested namespace); org scope reads through
388
+ * `capxul.organizations.externalAccounts.list({ organizationId })`.
389
+ * Both resolve to the same Convex query handler — the SDK ergonomics
390
+ * differ. Backend filters out `revoked` rows but keeps
391
+ * `pending_verification` rows visible (D5).
392
+ */
393
+ declare function useExternalAccounts(args: OwnerRef): QueryResult<List<ExternalAccount>>;
332
394
  declare function useSubAccounts(_args: OwnerRef): QueryResult<List<SubAccount>>;
333
395
  declare function useVirtualAccounts(_filters?: VirtualAccountsFilters): QueryResult<List<VirtualAccount>>;
334
396
  declare function useVirtualCards(_filters?: VirtualCardsFilters): QueryResult<List<VirtualCard>>;
@@ -340,6 +402,17 @@ declare function usePayments(_filters?: PaymentsFilters): QueryResult<List<Payme
340
402
  declare function useOrgPayments(_args: OrgScopedFilters): QueryResult<List<Payment>>;
341
403
  declare function useTransfers(_filters?: TransfersFilters): QueryResult<List<Transfer>>;
342
404
  declare function useOrgTransfers(_args: OrgScopedFilters): QueryResult<List<Transfer>>;
405
+ /**
406
+ * **NON-CANONICAL** raw on-chain ERC-20 transfer feed. Wired through
407
+ * `capxul.tokenTransfers.list` per slice/02-story2-balance Option-A
408
+ * verdict. Will be subsumed by canonical `useTransfers` once the
409
+ * `transfers.*` shape alignment lands. See `core/token-transfers.ts`
410
+ * doc-comment for the full contract.
411
+ *
412
+ * Intentionally NOT in `packages/sdk-react/ops/proof/hook-manifest.ts`
413
+ * — the canonical proof manifest tracks canon-aligned hooks only.
414
+ */
415
+ declare function useTokenTransfers(filters?: TokenTransfersListInput): QueryResult<TokenTransfersListPage>;
343
416
  /**
344
417
  * Append-only per-owner balance-delta feed. Live for late
345
418
  * `paymentId` / `transferId` attachment per Doc 02.
@@ -352,8 +425,15 @@ declare function useBalanceLedger(_args: OwnerScopedFilters): QueryResult<List<B
352
425
  */
353
426
  declare function useDocuments(_filters?: DocumentsFilters): QueryResult<List<Document>>;
354
427
  declare function useOrgDocuments(_args: OrgDocumentsFilters): QueryResult<List<Document>>;
355
- declare function useWithdrawals(_filters?: WithdrawalsFilters): QueryResult<List<Withdrawal>>;
356
- declare function useOrgWithdrawals(_args: OrgScopedFilters): QueryResult<List<Withdrawal>>;
428
+ /**
429
+ * Withdrawals v1 slice 1 (#440) — wired through `capxul.withdrawals.list`.
430
+ */
431
+ declare function useWithdrawals(filters?: WithdrawalsFilters): QueryResult<List<Withdrawal>>;
432
+ /**
433
+ * Withdrawals v1 slice 1 (#440) — wired through
434
+ * `capxul.organizations.withdrawals.list`.
435
+ */
436
+ declare function useOrgWithdrawals(args: OrgScopedFilters): QueryResult<List<Withdrawal>>;
357
437
  /**
358
438
  * Org-admin lens only — the hook NEVER returns `secret` for any row.
359
439
  */
@@ -458,4 +538,4 @@ declare function injectedConnector(options?: InjectedConnectorOptions): CapxulCo
458
538
  */
459
539
  declare function localPrivateKeyConnector(options: LocalPrivateKeyConnectorOptions): CapxulConnector;
460
540
 
461
- export { CapxulClientProvider, type CapxulClientProviderProps, type CapxulConnector, type CapxulConnectorKind, type CapxulConnectorSession, CapxulProvider, type CapxulProviderProps, CapxulTransportProvider, type CapxulTransportProviderProps, type DocumentsFilters, type InjectedConnectorOptions, type LocalPrivateKeyConnectorOptions, type OrgDocumentsFilters, type OrgScopedFilters, type OwnerRef, type OwnerScopedFilters, type PaginationFilters, type PaymentsFilters, type QueryResult, type TransfersFilters, type UseApiKeyArgs, type UseBalanceLedgerEntryArgs, type UseExternalAccountArgs, type UseMemberArgs, type VirtualAccountsFilters, type VirtualCardsFilters, type WithdrawalsFilters, createCapxulConfig, injectedConnector, localPrivateKeyConnector, useAccount, useApiKey, useApiKeys, useAuthFlow, useBalanceLedger, useBalanceLedgerEntry, useCapxul, useCapxulStatus, useDocument, useDocuments, useExternalAccount, useExternalAccounts, useKybProfile, useKycProfile, useMe, useMember, useMembers, useOnboardingFlow, useOperation, useOrgDocuments, useOrgPayments, useOrgTransfers, useOrgWithdrawals, useOrganization, useOrganizations, usePayment, usePayments, useProvisioningFlow, useSafe, useSubAccount, useSubAccounts, useTransfer, useTransfers, useTreasury, useVirtualAccount, useVirtualAccounts, useVirtualCard, useVirtualCards, useWebhookEndpoint, useWebhookEndpoints, useWebhookEvent, useWithdrawal, useWithdrawals };
541
+ export { CapxulClientProvider, type CapxulClientProviderProps, type CapxulConnector, type CapxulConnectorKind, type CapxulConnectorSession, CapxulProvider, type CapxulProviderProps, CapxulTransportProvider, type CapxulTransportProviderProps, type DocumentsFilters, type InjectedConnectorOptions, type LocalPrivateKeyConnectorOptions, type OrgDocumentsFilters, type OrgScopedFilters, type OwnerRef, type OwnerScopedFilters, type PaginationFilters, type PaymentsFilters, type QueryResult, type TransfersFilters, type UseApiKeyArgs, type UseBalanceLedgerEntryArgs, type UseExternalAccountArgs, type UseMemberArgs, type UseTokenTransferArgs, type VirtualAccountsFilters, type VirtualCardsFilters, type WithdrawalsFilters, createCapxulConfig, injectedConnector, localPrivateKeyConnector, useAccount, useApiKey, useApiKeys, useAuthFlow, useBalanceLedger, useBalanceLedgerEntry, useCapxul, useCapxulStatus, useDocument, useDocuments, useExternalAccount, useExternalAccounts, useKybProfile, useKycProfile, useMe, useMember, useMembers, useOnboardingFlow, useOperation, useOrgDocuments, useOrgPayments, useOrgTransfers, useOrgWithdrawals, useOrganization, useOrganizations, usePayment, usePayments, useProvisioningFlow, useSafe, useSubAccount, useSubAccounts, useTokenTransfer, useTokenTransfers, useTransfer, useTransfers, useTreasury, useVirtualAccount, useVirtualAccounts, useVirtualCard, useVirtualCards, useWebhookEndpoint, useWebhookEndpoints, useWebhookEvent, useWithdrawal, useWithdrawals };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
- import { HttpTransport, TransportState, CapxulConfig, BrowserCapxulConfig, AccountId, OrganizationId, ApiKeyId, BalanceLedgerEntryId, ExternalAccountId, MemberId, Account, ApiKey, BalanceLedgerEntry, DocumentId, Document, ExternalAccount, KybProfile, KycProfile, CapxulError as CapxulError$1, Member, OperationId, Operation, Organization, PaymentId, Payment, SafeId, Safe, SubAccountId, SubAccount, TransferId, Transfer, Treasury, VirtualAccountId, VirtualAccount, VirtualCardId, VirtualCard, WebhookEndpointId, WebhookEndpoint, WebhookEventId, WebhookEvent, WithdrawalId, Withdrawal, List, LocalPrivateKeySignerProvider } from '@capxul/sdk';
2
+ import { HttpTransport, TransportState, BrowserCapxulConfig, AuthSessionStore, AccountId, OrganizationId, ApiKeyId, BalanceLedgerEntryId, ExternalAccountId, MemberId, Account, ApiKey, BalanceLedgerEntry, DocumentId, Document, ExternalAccount, KybProfile, KycProfile, CapxulError as CapxulError$1, Member, OperationId, Operation, Organization, PaymentId, Payment, SafeId, Safe, SubAccountId, SubAccount, TokenTransfer, TransferId, Transfer, Treasury, VirtualAccountId, VirtualAccount, VirtualCardId, VirtualCard, WebhookEndpointId, WebhookEndpoint, WebhookEventId, WebhookEvent, WithdrawalId, Withdrawal, List, TokenTransfersListInput, TokenTransfersListPage, LocalPrivateKeySignerProvider } from '@capxul/sdk';
3
3
  export { AuthFlowContext, AuthFlowEvent, BrowserCapxulConfig, OnboardingFlowContext, OnboardingFlowEvent, ProvisioningFlowContext, ProvisioningFlowEvent } from '@capxul/sdk';
4
4
  import { QueryClient, UseQueryResult } from '@tanstack/react-query';
5
5
  import { CapxulClient } from '@capxul/sdk/client';
@@ -55,55 +55,64 @@ declare function CapxulTransportProvider({ transport, children, }: CapxulTranspo
55
55
  declare function useCapxulStatus(): TransportState;
56
56
 
57
57
  /**
58
- * `CapxulProvider` — React context provider that wires both the
59
- * `@capxul/sdk` client AND a TanStack Query `QueryClient` for the
60
- * subtree.
58
+ * `CapxulProvider` — public React provider for `@capxul/sdk-react`.
61
59
  *
62
- * Two construction paths:
60
+ * Single-input contract: accepts ONLY `{ config: BrowserCapxulConfig,
61
+ * sessionStore?, queryClient?, children }`. The browser config is the
62
+ * secret-safe discriminated union from `@capxul/sdk` — `apiKey`,
63
+ * `data`, `signer`, and other server-only fields are rejected at
64
+ * compile-time AND at runtime via `createCapxulConfig`'s allow-list
65
+ * validator.
63
66
  *
64
- * 1. **Legacy / harness path** pass an already-assembled
65
- * `config: CapxulConfig`. Used by the e2e harness and CLI-shaped
66
- * integrations that build their own auth/data adapters.
67
+ * The provider builds an `HttpTransport` synchronously and injects it
68
+ * into `createCapxulClient` via the internal `_transport` slot. The
69
+ * transport is exposed through `CapxulTransportContext` so
70
+ * `useCapxulStatus()` can subscribe to its lifecycle state machine.
67
71
  *
68
- * 2. **Lazy-DX path (ADR #14c)** pass either `publishableKey` or
69
- * `browserConfig`. The provider builds an `HttpTransport`
70
- * synchronously, injects it into `createCapxulClient` via the
71
- * internal `_transport` slot, and exposes the transport through
72
- * `CapxulTransportContext` so `useCapxulStatus()` can subscribe
73
- * to its lifecycle state machine.
72
+ * The provider also builds a `ConvexReactClient`-backed data client
73
+ * for the `build-time-urls` arm and feeds it as `config.data` so the
74
+ * SDK domain methods (`me.get`, `accounts.retrieve`, ...) and the
75
+ * React hooks built on top can run authenticated reads against live
76
+ * Convex. The auth lifecycle threads through the optional
77
+ * `sessionStore` prop: `verifyOtp` writes a session to the store
78
+ * (which the SDK auth client persists), and the provider's data
79
+ * client re-reads the JWT on demand via `refreshAuth()`. Without a
80
+ * session store the provider falls back to an in-memory one, which
81
+ * is fine for browser apps that hold the page until next reload but
82
+ * inadequate for CLI / Node consumers that need cross-process
83
+ * persistence — those pass a file-backed store via the prop.
74
84
  *
75
- * The lazy-DX provider mounts synchronously. There is no
76
- * `useState` mutating config, no `useMemo` rebuilding config when
77
- * state changes, and no Suspense gate at mount. State transitions
78
- * happen on the transport (a stable singleton); React subscribes
79
- * via `useSyncExternalStore` and re-renders only the components
80
- * that actually depend on the transport state.
85
+ * Tests and the e2e harness need the server-augmented `CapxulConfig`
86
+ * shape (with `data`, `signer`, `signing`). Those callers use
87
+ * `CapxulTestProvider` from `@capxul/sdk-react/proof` instead.
81
88
  *
82
89
  * Per ADR 4 in the API-first architecture stack PLAN, only
83
90
  * `QueryClientProvider` is allowed to live OUTSIDE the single
84
91
  * `CapxulContext`. The `QueryClientProvider` is the outermost wrap;
85
- * the SDK client provider sits inside it; the optional transport
86
- * provider sits between the two when the lazy-DX path is active.
92
+ * the SDK client provider sits inside it; the transport provider sits
93
+ * between the two.
87
94
  */
88
95
 
89
96
  type CapxulProviderProps = {
90
97
  /**
91
- * Pre-assembled `CapxulConfig` for the legacy / harness path.
92
- * Mutually exclusive with `publishableKey` / `browserConfig`.
98
+ * Browser-safe Capxul config the discriminated union from
99
+ * `@capxul/sdk`. Either the `build-time-urls` arm or the
100
+ * `publishable-key` arm. Server-only fields (`apiKey`, `data`,
101
+ * `signer`, `signing`) are rejected at compile-time and at runtime
102
+ * via `createCapxulConfig`'s allow-list validator.
93
103
  */
94
- readonly config?: CapxulConfig;
104
+ readonly config: BrowserCapxulConfig;
95
105
  /**
96
- * Shorthand for the publishable-key arm of `BrowserCapxulConfig`.
97
- * Provider builds the transport synchronously and injects it into
98
- * the SDK client the canonical lazy-DX entry point per ADR #14c.
106
+ * Auth session persistence adapter. The SDK auth client writes
107
+ * sessions here on `verifyOtp` and clears them on `signOut`. The
108
+ * provider's data client re-reads the JWT from this store on every
109
+ * `refreshAuth` call so reads carry the right auth header.
110
+ *
111
+ * Defaults to an in-memory store scoped to this provider. Pass a
112
+ * file-backed (Node CLI) or `localStorage`-backed (browser) store
113
+ * to persist sessions across process or page lifetimes.
99
114
  */
100
- readonly publishableKey?: string;
101
- /**
102
- * Full `BrowserCapxulConfig` for callers that need
103
- * `mode: "build-time-urls"` or a custom `fetchImpl` (e.g. tests).
104
- * Mutually exclusive with `publishableKey` / `config`.
105
- */
106
- readonly browserConfig?: BrowserCapxulConfig;
115
+ readonly sessionStore?: AuthSessionStore;
107
116
  /**
108
117
  * Optional TanStack Query `QueryClient`. Pass your app's existing
109
118
  * client to share the cache across the SDK hooks and the host
@@ -113,7 +122,7 @@ type CapxulProviderProps = {
113
122
  readonly queryClient?: QueryClient;
114
123
  readonly children: ReactNode;
115
124
  };
116
- declare function CapxulProvider({ config, publishableKey, browserConfig, queryClient, children, }: CapxulProviderProps): ReactNode;
125
+ declare function CapxulProvider({ config, sessionStore, queryClient, children, }: CapxulProviderProps): ReactNode;
117
126
 
118
127
  /**
119
128
  * `QueryResult<T>` — the canonical three-state return shape for every
@@ -220,16 +229,27 @@ declare function useMe(): UseQueryResult<Account, CapxulError$1>;
220
229
  /**
221
230
  * Account by id. Omit `accountId` for the calling user (alias for
222
231
  * `useMe()` from a developer-perspective lens).
232
+ *
233
+ * Slice 2 (#457 story 1): wired via `capxul.accounts.retrieve` for
234
+ * the id-bearing call and `capxul.me.get()` for the self-lens
235
+ * shortcut. Returns the legacy `QueryResult<Account>` shape because
236
+ * only `useMe` has migrated to TanStack Query so far (PLAN.md task
237
+ * 1.8) — per-hook migration is the rollout pattern.
223
238
  */
224
- declare function useAccount(_accountId?: AccountId): QueryResult<Account>;
239
+ declare function useAccount(accountId?: AccountId): QueryResult<Account>;
225
240
  declare function useOrganization(_organizationId: OrganizationId): QueryResult<Organization>;
226
241
  declare function useMember(_args: UseMemberArgs): QueryResult<Member>;
227
242
  /**
228
243
  * Live; status advances as the indexer reconciles the on-chain
229
244
  * deployment. Consumers pattern-match on `data.status` via
230
245
  * `matchStatus` (see `@capxul/sdk`).
246
+ *
247
+ * Slice 2 (#457 story 1): wired via
248
+ * `capxul.accounts.safes.retrieve(safeId)`. The SDK method is real
249
+ * post-Withdrawals v1 slice 1; this hook closes the React-side
250
+ * stub so onboarding can subscribe to Safe deploy progress.
231
251
  */
232
- declare function useSafe(_safeId: SafeId): QueryResult<Safe>;
252
+ declare function useSafe(safeId: SafeId): QueryResult<Safe>;
233
253
  declare function useTreasury(_organizationId: OrganizationId): QueryResult<Treasury>;
234
254
  /**
235
255
  * Org-admin lens only — the hook NEVER returns `secret`.
@@ -237,19 +257,51 @@ declare function useTreasury(_organizationId: OrganizationId): QueryResult<Treas
237
257
  declare function useApiKey(_args: UseApiKeyArgs): QueryResult<ApiKey>;
238
258
  declare function useKycProfile(_accountId: AccountId): QueryResult<KycProfile>;
239
259
  declare function useKybProfile(_organizationId: OrganizationId): QueryResult<KybProfile>;
240
- declare function useExternalAccount(_args: UseExternalAccountArgs): QueryResult<ExternalAccount>;
260
+ /**
261
+ * Withdrawals v1 W1 (#464) — wired through the SDK.
262
+ *
263
+ * Branches on `args.ownerKind` so `account` scope reads via the
264
+ * top-level `capxul.externalAccounts.retrieve(id)` (visibility-gated
265
+ * server-side by the caller's accountId), and `organization` scope
266
+ * reads via `capxul.organizations.externalAccounts.retrieve({ ... })`
267
+ * which adds an org-scope check for cross-org isolation. Both routes
268
+ * resolve to the same Convex query handler — the SDK ergonomics
269
+ * differ but the wire shape is identical.
270
+ */
271
+ declare function useExternalAccount(args: UseExternalAccountArgs): QueryResult<ExternalAccount>;
241
272
  declare function useSubAccount(_subAccountId: SubAccountId): QueryResult<SubAccount>;
242
273
  declare function useVirtualAccount(_virtualAccountId: VirtualAccountId): QueryResult<VirtualAccount>;
243
274
  declare function useVirtualCard(_virtualCardId: VirtualCardId): QueryResult<VirtualCard>;
244
275
  declare function usePayment(_paymentId: PaymentId): QueryResult<Payment>;
245
276
  declare function useTransfer(_transferId: TransferId): QueryResult<Transfer>;
277
+ type UseTokenTransferArgs = {
278
+ readonly txHash: string;
279
+ readonly logIndex: number;
280
+ readonly chainId?: number;
281
+ };
282
+ /**
283
+ * **NON-CANONICAL** raw on-chain ERC-20 transfer detail. Wired through
284
+ * `capxul.tokenTransfers.retrieve` per slice/02-story2-balance
285
+ * Option-A verdict. Identifier is the canonical on-chain composite
286
+ * `(txHash, logIndex)` so consumers don't have to round-trip through
287
+ * the Convex doc id.
288
+ *
289
+ * Intentionally NOT in `packages/sdk-react/ops/proof/hook-manifest.ts`
290
+ * — the canonical proof manifest tracks canon-aligned hooks only.
291
+ */
292
+ declare function useTokenTransfer(args: UseTokenTransferArgs): QueryResult<TokenTransfer>;
246
293
  /**
247
294
  * Immutable once written; `live` semantically only for late
248
295
  * `paymentId` / `transferId` attachment per Doc 02 §"balance_ledger".
249
296
  */
250
297
  declare function useBalanceLedgerEntry(_args: UseBalanceLedgerEntryArgs): QueryResult<BalanceLedgerEntry>;
251
298
  declare function useDocument(_documentId: DocumentId): QueryResult<Document>;
252
- declare function useWithdrawal(_withdrawalId: WithdrawalId): QueryResult<Withdrawal>;
299
+ /**
300
+ * Withdrawals v1 slice 1 (#440) — wired through `capxul.withdrawals.retrieve`.
301
+ * Mirrors `useOperation` (the canonical evidence subscription) since
302
+ * the withdrawal resource is operation-shaped at its core.
303
+ */
304
+ declare function useWithdrawal(withdrawalId: WithdrawalId): QueryResult<Withdrawal>;
253
305
  /**
254
306
  * The canonical evidence subscription per CANON.md §3.3 —
255
307
  * `operationId` + `correlationId` are the cross-layer join keys for
@@ -328,7 +380,17 @@ type OrgDocumentsFilters = OrgScopedFilters & {
328
380
  */
329
381
  declare function useOrganizations(): QueryResult<List<Organization>>;
330
382
  declare function useMembers(_organizationId: OrganizationId): QueryResult<List<Member>>;
331
- declare function useExternalAccounts(_args: OwnerRef): QueryResult<List<ExternalAccount>>;
383
+ /**
384
+ * Withdrawals v1 W1 (#464) — wired through the SDK.
385
+ *
386
+ * Personal scope reads through `capxul.accounts.externalAccounts.list({
387
+ * accountId })` (Pattern A nested namespace); org scope reads through
388
+ * `capxul.organizations.externalAccounts.list({ organizationId })`.
389
+ * Both resolve to the same Convex query handler — the SDK ergonomics
390
+ * differ. Backend filters out `revoked` rows but keeps
391
+ * `pending_verification` rows visible (D5).
392
+ */
393
+ declare function useExternalAccounts(args: OwnerRef): QueryResult<List<ExternalAccount>>;
332
394
  declare function useSubAccounts(_args: OwnerRef): QueryResult<List<SubAccount>>;
333
395
  declare function useVirtualAccounts(_filters?: VirtualAccountsFilters): QueryResult<List<VirtualAccount>>;
334
396
  declare function useVirtualCards(_filters?: VirtualCardsFilters): QueryResult<List<VirtualCard>>;
@@ -340,6 +402,17 @@ declare function usePayments(_filters?: PaymentsFilters): QueryResult<List<Payme
340
402
  declare function useOrgPayments(_args: OrgScopedFilters): QueryResult<List<Payment>>;
341
403
  declare function useTransfers(_filters?: TransfersFilters): QueryResult<List<Transfer>>;
342
404
  declare function useOrgTransfers(_args: OrgScopedFilters): QueryResult<List<Transfer>>;
405
+ /**
406
+ * **NON-CANONICAL** raw on-chain ERC-20 transfer feed. Wired through
407
+ * `capxul.tokenTransfers.list` per slice/02-story2-balance Option-A
408
+ * verdict. Will be subsumed by canonical `useTransfers` once the
409
+ * `transfers.*` shape alignment lands. See `core/token-transfers.ts`
410
+ * doc-comment for the full contract.
411
+ *
412
+ * Intentionally NOT in `packages/sdk-react/ops/proof/hook-manifest.ts`
413
+ * — the canonical proof manifest tracks canon-aligned hooks only.
414
+ */
415
+ declare function useTokenTransfers(filters?: TokenTransfersListInput): QueryResult<TokenTransfersListPage>;
343
416
  /**
344
417
  * Append-only per-owner balance-delta feed. Live for late
345
418
  * `paymentId` / `transferId` attachment per Doc 02.
@@ -352,8 +425,15 @@ declare function useBalanceLedger(_args: OwnerScopedFilters): QueryResult<List<B
352
425
  */
353
426
  declare function useDocuments(_filters?: DocumentsFilters): QueryResult<List<Document>>;
354
427
  declare function useOrgDocuments(_args: OrgDocumentsFilters): QueryResult<List<Document>>;
355
- declare function useWithdrawals(_filters?: WithdrawalsFilters): QueryResult<List<Withdrawal>>;
356
- declare function useOrgWithdrawals(_args: OrgScopedFilters): QueryResult<List<Withdrawal>>;
428
+ /**
429
+ * Withdrawals v1 slice 1 (#440) — wired through `capxul.withdrawals.list`.
430
+ */
431
+ declare function useWithdrawals(filters?: WithdrawalsFilters): QueryResult<List<Withdrawal>>;
432
+ /**
433
+ * Withdrawals v1 slice 1 (#440) — wired through
434
+ * `capxul.organizations.withdrawals.list`.
435
+ */
436
+ declare function useOrgWithdrawals(args: OrgScopedFilters): QueryResult<List<Withdrawal>>;
357
437
  /**
358
438
  * Org-admin lens only — the hook NEVER returns `secret` for any row.
359
439
  */
@@ -458,4 +538,4 @@ declare function injectedConnector(options?: InjectedConnectorOptions): CapxulCo
458
538
  */
459
539
  declare function localPrivateKeyConnector(options: LocalPrivateKeyConnectorOptions): CapxulConnector;
460
540
 
461
- export { CapxulClientProvider, type CapxulClientProviderProps, type CapxulConnector, type CapxulConnectorKind, type CapxulConnectorSession, CapxulProvider, type CapxulProviderProps, CapxulTransportProvider, type CapxulTransportProviderProps, type DocumentsFilters, type InjectedConnectorOptions, type LocalPrivateKeyConnectorOptions, type OrgDocumentsFilters, type OrgScopedFilters, type OwnerRef, type OwnerScopedFilters, type PaginationFilters, type PaymentsFilters, type QueryResult, type TransfersFilters, type UseApiKeyArgs, type UseBalanceLedgerEntryArgs, type UseExternalAccountArgs, type UseMemberArgs, type VirtualAccountsFilters, type VirtualCardsFilters, type WithdrawalsFilters, createCapxulConfig, injectedConnector, localPrivateKeyConnector, useAccount, useApiKey, useApiKeys, useAuthFlow, useBalanceLedger, useBalanceLedgerEntry, useCapxul, useCapxulStatus, useDocument, useDocuments, useExternalAccount, useExternalAccounts, useKybProfile, useKycProfile, useMe, useMember, useMembers, useOnboardingFlow, useOperation, useOrgDocuments, useOrgPayments, useOrgTransfers, useOrgWithdrawals, useOrganization, useOrganizations, usePayment, usePayments, useProvisioningFlow, useSafe, useSubAccount, useSubAccounts, useTransfer, useTransfers, useTreasury, useVirtualAccount, useVirtualAccounts, useVirtualCard, useVirtualCards, useWebhookEndpoint, useWebhookEndpoints, useWebhookEvent, useWithdrawal, useWithdrawals };
541
+ export { CapxulClientProvider, type CapxulClientProviderProps, type CapxulConnector, type CapxulConnectorKind, type CapxulConnectorSession, CapxulProvider, type CapxulProviderProps, CapxulTransportProvider, type CapxulTransportProviderProps, type DocumentsFilters, type InjectedConnectorOptions, type LocalPrivateKeyConnectorOptions, type OrgDocumentsFilters, type OrgScopedFilters, type OwnerRef, type OwnerScopedFilters, type PaginationFilters, type PaymentsFilters, type QueryResult, type TransfersFilters, type UseApiKeyArgs, type UseBalanceLedgerEntryArgs, type UseExternalAccountArgs, type UseMemberArgs, type UseTokenTransferArgs, type VirtualAccountsFilters, type VirtualCardsFilters, type WithdrawalsFilters, createCapxulConfig, injectedConnector, localPrivateKeyConnector, useAccount, useApiKey, useApiKeys, useAuthFlow, useBalanceLedger, useBalanceLedgerEntry, useCapxul, useCapxulStatus, useDocument, useDocuments, useExternalAccount, useExternalAccounts, useKybProfile, useKycProfile, useMe, useMember, useMembers, useOnboardingFlow, useOperation, useOrgDocuments, useOrgPayments, useOrgTransfers, useOrgWithdrawals, useOrganization, useOrganizations, usePayment, usePayments, useProvisioningFlow, useSafe, useSubAccount, useSubAccounts, useTokenTransfer, useTokenTransfers, useTransfer, useTransfers, useTreasury, useVirtualAccount, useVirtualAccounts, useVirtualCard, useVirtualCards, useWebhookEndpoint, useWebhookEndpoints, useWebhookEvent, useWithdrawal, useWithdrawals };