@capxul/sdk 0.2.0-alpha.4 → 0.2.0-alpha.5

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.
Files changed (45) hide show
  1. package/README.md +4 -308
  2. package/dist/InMemoryAuthCacheAdapter-BK-B_ERB.mjs +113 -0
  3. package/dist/InMemoryAuthCacheAdapter-BK-B_ERB.mjs.map +1 -0
  4. package/dist/index.d.mts +1263 -0
  5. package/dist/index.d.mts.map +1 -0
  6. package/dist/index.mjs +4740 -0
  7. package/dist/index.mjs.map +1 -0
  8. package/dist/node/index.d.mts +55 -0
  9. package/dist/node/index.d.mts.map +1 -0
  10. package/dist/node/index.mjs +159 -0
  11. package/dist/node/index.mjs.map +1 -0
  12. package/dist/ports/safe-deployment.d.mts +2 -0
  13. package/dist/ports/safe-deployment.mjs +38 -0
  14. package/dist/ports/safe-deployment.mjs.map +1 -0
  15. package/dist/safe-deployment-Vni46k3t.d.mts +137 -0
  16. package/dist/safe-deployment-Vni46k3t.d.mts.map +1 -0
  17. package/dist/signer-oaYGfjDe.d.mts +142 -0
  18. package/dist/signer-oaYGfjDe.d.mts.map +1 -0
  19. package/package.json +37 -70
  20. package/CHANGELOG.md +0 -274
  21. package/LICENSE +0 -44
  22. package/dist/client-CbUeJoM9.d.ts +0 -1335
  23. package/dist/client-UEm2oZbZ.d.cts +0 -1335
  24. package/dist/client.cjs +0 -4042
  25. package/dist/client.d.cts +0 -6
  26. package/dist/client.d.ts +0 -6
  27. package/dist/client.js +0 -4040
  28. package/dist/errors-CwhCWGxm.d.ts +0 -70
  29. package/dist/errors-rqxuUhQP.d.cts +0 -70
  30. package/dist/errors.cjs +0 -35
  31. package/dist/errors.d.cts +0 -2
  32. package/dist/errors.d.ts +0 -2
  33. package/dist/errors.js +0 -31
  34. package/dist/index.cjs +0 -4273
  35. package/dist/index.d.cts +0 -461
  36. package/dist/index.d.ts +0 -461
  37. package/dist/index.js +0 -4234
  38. package/dist/next-action-CTGl8wpy.d.cts +0 -177
  39. package/dist/next-action-CTGl8wpy.d.ts +0 -177
  40. package/dist/types-BD4VAQb5.d.ts +0 -1205
  41. package/dist/types-HlwCIjgQ.d.cts +0 -1205
  42. package/dist/webhooks.cjs +0 -118
  43. package/dist/webhooks.d.cts +0 -33
  44. package/dist/webhooks.d.ts +0 -33
  45. package/dist/webhooks.js +0 -116
@@ -1,1335 +0,0 @@
1
- import { Account as Account$1 } from 'viem';
2
- import { AnyStateMachine } from 'xstate';
3
- import { A as AccountId, S as SafeId, c as KycProfileId, b as ExternalAccountId, f as SubAccountId, d as OrganizationId, a as ApiKeyId, X as TimestampIso, U as Username, E as Email, D as DocumentId, O as OperationId, P as PaymentId, g as TransferId, k as WithdrawalId, W as WebhookEndpointId, j as WebhookEventId, M as MemberId, V as VirtualAccountId, i as VirtualCardId } from './next-action-CTGl8wpy.js';
4
- import { d as CapxulResult, C as CapxulError } from './errors-CwhCWGxm.js';
5
- import { A as Account, X as UserIdentifier, a as AccountLookupResult, S as Safe, k as KycProfile, E as ExternalAccount, L as List, F as SubAccount, B as BalanceLedgerEntry, b as ApiKey, a5 as CreateApiKeyRequest, a6 as CreateDocumentRequest, D as Document, O as Operation, q as OperationStatus, p as Money, C as CreatePaymentResult, t as Payment, Q as TransferEndpoint, f as CreateTransferResult, J as Transfer, g as CreateWithdrawalResult, a3 as Withdrawal, a7 as CreateWebhookEndpointRequest, a1 as WebhookEndpoint, a2 as WebhookEvent, s as Organization, W as Treasury, o as MembershipStatus, M as Member, n as MemberInviteResponse, a8 as CreateVirtualAccountRequest, Y as VirtualAccount, a9 as CreateVirtualCardRequest, _ as VirtualCard } from './types-BD4VAQb5.js';
6
-
7
- /**
8
- * Accounts domain — individual user accounts per sdk-surface.md §1a.
9
- *
10
- * Nested namespaces under `accounts.*` follow Pattern A per CANON.md
11
- * §4.30: `accounts.safes.retrieve(safeId)`, `accounts.subAccounts.list()`,
12
- * etc. — no ambient account context; the argument carries the scope.
13
- */
14
-
15
- type AccountLookupInput = UserIdentifier;
16
- type AccountUpdateInput = Partial<{
17
- readonly name: string;
18
- readonly username: string;
19
- readonly countryCode: string;
20
- }>;
21
- type LocalPrivateKeySignerProvider = {
22
- readonly kind: "local-private-key";
23
- readonly signerAddress: string;
24
- };
25
- type AccountProvisionPersonalInput = {
26
- readonly displayName?: string;
27
- readonly username?: string;
28
- readonly countryCode?: string;
29
- readonly signerProvider: LocalPrivateKeySignerProvider;
30
- };
31
- type AccountCreateKycProfileInput = {
32
- readonly accountId: AccountId;
33
- };
34
- type AccountListInput = {
35
- readonly limit?: number;
36
- readonly cursor?: string;
37
- };
38
- type AccountCreateSubAccountInput = {
39
- readonly accountId: AccountId;
40
- readonly name: string;
41
- readonly purpose?: string;
42
- };
43
- type AccountCreateExternalAccountInput = {
44
- readonly accountId: AccountId;
45
- readonly kind: "bank" | "evm" | "solana" | "starknet" | "card_payout";
46
- readonly label?: string;
47
- readonly address?: string;
48
- readonly iban?: string;
49
- readonly bic?: string;
50
- readonly accountHolder?: string;
51
- readonly network?: "visa" | "mastercard";
52
- readonly panToken?: string;
53
- readonly last4?: string;
54
- };
55
- type RetrieveCodes$e = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND";
56
- type LookupCodes = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "INVALID_INPUT";
57
- type UpdateCodes$1 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "INVALID_INPUT";
58
- type ListCodes$b = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "INVALID_INPUT";
59
- type SafeRetrieveCodes$1 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "SAFE_NOT_READY";
60
- type RemoveCodes$5 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND";
61
- type SubAccountRemoveCodes$1 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "INVALID_INPUT";
62
- type AccountSafesClient = {
63
- readonly retrieve: (safeId: SafeId) => Promise<CapxulResult<Safe, SafeRetrieveCodes$1>>;
64
- };
65
- type AccountKycProfilesClient = {
66
- readonly create: (input: AccountCreateKycProfileInput) => Promise<CapxulResult<KycProfile, UpdateCodes$1>>;
67
- readonly retrieve: (kycProfileId: KycProfileId) => Promise<CapxulResult<KycProfile, RetrieveCodes$e>>;
68
- };
69
- type AccountExternalAccountsClient = {
70
- readonly create: (input: AccountCreateExternalAccountInput) => Promise<CapxulResult<ExternalAccount, UpdateCodes$1>>;
71
- readonly list: (input: {
72
- readonly accountId: AccountId;
73
- } & AccountListInput) => Promise<CapxulResult<List<ExternalAccount>, ListCodes$b>>;
74
- readonly retrieve: (externalAccountId: ExternalAccountId) => Promise<CapxulResult<ExternalAccount, RetrieveCodes$e>>;
75
- readonly remove: (externalAccountId: ExternalAccountId) => Promise<CapxulResult<void, RemoveCodes$5>>;
76
- };
77
- type AccountSubAccountsClient = {
78
- readonly create: (input: AccountCreateSubAccountInput) => Promise<CapxulResult<SubAccount, UpdateCodes$1 | "PROVIDER_ERROR">>;
79
- readonly list: (input: {
80
- readonly accountId: AccountId;
81
- } & AccountListInput) => Promise<CapxulResult<List<SubAccount>, ListCodes$b | "PROVIDER_ERROR">>;
82
- readonly retrieve: (subAccountId: SubAccountId) => Promise<CapxulResult<SubAccount, RetrieveCodes$e | "PROVIDER_ERROR">>;
83
- readonly remove: (subAccountId: SubAccountId) => Promise<CapxulResult<SubAccount, SubAccountRemoveCodes$1 | "PROVIDER_ERROR">>;
84
- };
85
- type AccountBalanceLedgerClient = {
86
- readonly list: (input: {
87
- readonly accountId: AccountId;
88
- } & AccountListInput) => Promise<CapxulResult<List<BalanceLedgerEntry>, ListCodes$b>>;
89
- readonly retrieve: (entryId: string) => Promise<CapxulResult<BalanceLedgerEntry, RetrieveCodes$e>>;
90
- };
91
- type AccountsClient = {
92
- readonly retrieve: (accountId: AccountId) => Promise<CapxulResult<Account, RetrieveCodes$e>>;
93
- readonly lookup: (input: AccountLookupInput) => Promise<CapxulResult<AccountLookupResult, LookupCodes>>;
94
- readonly update: (input: {
95
- readonly accountId: AccountId;
96
- } & AccountUpdateInput) => Promise<CapxulResult<Account, UpdateCodes$1>>;
97
- readonly provisionPersonal: (input: AccountProvisionPersonalInput) => Promise<CapxulResult<Account, UpdateCodes$1 | "NETWORK_ERROR">>;
98
- readonly safes: AccountSafesClient;
99
- readonly kycProfiles: AccountKycProfilesClient;
100
- readonly externalAccounts: AccountExternalAccountsClient;
101
- readonly subAccounts: AccountSubAccountsClient;
102
- readonly balanceLedger: AccountBalanceLedgerClient;
103
- };
104
-
105
- /**
106
- * API keys domain — org-issued credentials per sdk-surface.md §1b +
107
- * §4.21 + §4.57. Key types: `cap_test_` / `cap_live_` (secret) and
108
- * `cap_pk_test_` / `cap_pk_live_` (publishable).
109
- *
110
- * All methods are org-nested. The one-time `secret` value is returned
111
- * on `create` only; subsequent reads omit it.
112
- */
113
-
114
- type ApiKeysCreateInput = CreateApiKeyRequest & {
115
- readonly organizationId: OrganizationId;
116
- };
117
- type ApiKeysRetrieveInput = {
118
- readonly organizationId: OrganizationId;
119
- readonly apiKeyId: ApiKeyId;
120
- };
121
- type ApiKeysListInput = {
122
- readonly organizationId: OrganizationId;
123
- readonly limit?: number;
124
- readonly cursor?: string;
125
- };
126
- type ApiKeysRevokeInput = ApiKeysRetrieveInput;
127
- type CreateCodes$8 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "INVALID_INPUT" | "RATE_LIMITED" | "NETWORK_ERROR";
128
- type RetrieveCodes$d = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND";
129
- type ListCodes$a = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "INVALID_INPUT";
130
- type RevokeCodes = RetrieveCodes$d;
131
- /**
132
- * Shape returned by `organizations.apiKeys.create` — the one-time
133
- * secret `value` is included here and omitted from every subsequent
134
- * read.
135
- */
136
- type ApiKeyCreateResult = ApiKey & {
137
- readonly value: string;
138
- };
139
- type ApiKeysClient = {
140
- readonly create: (input: ApiKeysCreateInput) => Promise<CapxulResult<ApiKeyCreateResult, CreateCodes$8>>;
141
- readonly retrieve: (input: ApiKeysRetrieveInput) => Promise<CapxulResult<ApiKey, RetrieveCodes$d>>;
142
- readonly list: (input: ApiKeysListInput) => Promise<CapxulResult<List<ApiKey>, ListCodes$a>>;
143
- readonly revoke: (input: ApiKeysRevokeInput) => Promise<CapxulResult<ApiKey, RevokeCodes>>;
144
- };
145
-
146
- interface CapxulDataClient {
147
- query(name: any, args: any): Promise<any>;
148
- mutation(name: any, args: any): Promise<any>;
149
- action?(name: any, args: any): Promise<any>;
150
- }
151
-
152
- /**
153
- * Authentication domain.
154
- *
155
- * Maps 1:1 to `/v1/auth/*` HTTP endpoints. Human sign-in via email OTP;
156
- * partner servers mint short-lived service tokens from a long-lived
157
- * API key per sdk-surface.md §3.2.
158
- *
159
- * Stack-1 update: outbound HTTP routes through `makeHttpTransport`
160
- * (`packages/sdk/src/transport.ts`) so that `core/auth.ts` no longer
161
- * owns base-URL validation or `fetch` indirection. The BetterAuth
162
- * `/api/auth` path-mangling stays here — it is auth-protocol-specific
163
- * and the transport layer is auth-protocol-agnostic by design.
164
- *
165
- * Lazy transport construction: when `config.auth.baseUrl` is absent the
166
- * SDK is in scaffold/CLI mode and `sendOtp` / `verifyOtp` return the
167
- * `NOT_IMPLEMENTED` `stub` tuple (preserving the prior behavior). Only
168
- * when `baseUrl` is configured do we construct the transport — at
169
- * which point the build-time-urls variant of `BrowserCapxulConfig`
170
- * runs its own `Errors.invalidInput` validation.
171
- */
172
-
173
- type Session = {
174
- readonly authUserId: string;
175
- readonly accountId?: AccountId;
176
- readonly email: string;
177
- readonly token: string;
178
- readonly convexJwt?: string;
179
- readonly expiresAt: TimestampIso;
180
- };
181
- type AuthSessionStore = {
182
- get(): Session | null;
183
- set(session: Session): void;
184
- clear(): void;
185
- };
186
- type AuthBootstrapToken = string & {
187
- readonly __capxulAuthBootstrapTokenBrand: "AuthBootstrapToken";
188
- };
189
- type AuthBootstrapReason = "new_member" | "missing_profile" | "missing_account" | "missing_safe" | "missing_signer_grant";
190
- type VerifyOtpResult = {
191
- readonly kind: "existing_member";
192
- readonly session: Session;
193
- readonly account: Account;
194
- readonly username: Username;
195
- readonly safe: Safe;
196
- } | {
197
- readonly kind: "bootstrap_required";
198
- readonly session: Session;
199
- readonly bootstrapToken: AuthBootstrapToken;
200
- readonly email: Email;
201
- readonly reason: AuthBootstrapReason;
202
- readonly username?: Username;
203
- };
204
- type CompleteBootstrapInput = {
205
- readonly bootstrapToken: AuthBootstrapToken;
206
- readonly username: Username;
207
- readonly displayName?: string;
208
- readonly countryCode?: string;
209
- };
210
- type CompleteBootstrapResult = {
211
- readonly kind: "authenticated";
212
- readonly session: Session;
213
- readonly account: Account;
214
- readonly username: Username;
215
- readonly safe: Safe;
216
- };
217
- /**
218
- * Options bag for auth methods that perform outbound `fetch` work.
219
- *
220
- * Accepts an `AbortSignal` so XState v5 actors (and any other caller
221
- * that wants cancellation) can cancel the in-flight HTTP request when
222
- * the actor stops. The signal flows through `transport.fetch`'s
223
- * `RequestInit.signal` and into the underlying `fetch` impl, so
224
- * `signal.aborted === true` propagates to the network layer per the
225
- * Web Platform `fetch` contract. See PR #406 S5.
226
- */
227
- type AuthMethodOptions = {
228
- readonly signal?: AbortSignal;
229
- };
230
-
231
- /**
232
- * AuthService — unified promise-based auth surface.
233
- *
234
- * Wraps the imperative `AuthClient` tuple API with a class-based,
235
- * promise-based interface. `signOut` preserves the data-client
236
- * reference so provider-owned singletons survive sign-in/sign-out
237
- * cycles.
238
- */
239
-
240
- declare class AuthService {
241
- private authClient;
242
- private sessionStore;
243
- private config;
244
- constructor(config?: CapxulConfig);
245
- sendOtp(email: string, options?: AuthMethodOptions): Promise<void>;
246
- verifyOtp(email: string, otp: string, options?: AuthMethodOptions): Promise<VerifyOtpResult>;
247
- completeBootstrap(params: CompleteBootstrapInput, signer?: Account$1): Promise<CompleteBootstrapResult>;
248
- /**
249
- * Clears the persisted session and, when a transport was pre-injected,
250
- * drops the cached auth header.
251
- *
252
- * **Transport safety note:** `clearAuth()` is only invoked when
253
- * `config._transport` was supplied at construction (e.g. by the React
254
- * provider). If `AuthService` is instantiated directly in a Node/CLI
255
- * context without an injected transport, the transport-side auth cache
256
- * is the caller's responsibility.
257
- */
258
- signOut(): Promise<void>;
259
- getSession(): Promise<Session | null>;
260
- }
261
-
262
- /**
263
- * Documents domain — unified artifact primitive per sdk-surface.md §1a
264
- * + §4.50.
265
- *
266
- * Subsumes the former `invoice` and `org_payroll_entry` top-level
267
- * primitives. The `Document` union discriminates on `type`:
268
- * `invoice | payroll_run | payroll_schedule | receipt | kyc_upload |
269
- * bank_statement | tax_form`.
270
- */
271
-
272
- type DocumentsCreateInput = CreateDocumentRequest;
273
- type DocumentsListInput = {
274
- readonly limit?: number;
275
- readonly cursor?: string;
276
- readonly type?: Document["type"];
277
- };
278
- type OrgDocumentsCreateInput = DocumentsCreateInput & {
279
- readonly organizationId: OrganizationId;
280
- };
281
- type OrgDocumentsRetrieveInput = {
282
- readonly organizationId: OrganizationId;
283
- readonly documentId: DocumentId;
284
- };
285
- type OrgDocumentsListInput = {
286
- readonly organizationId: OrganizationId;
287
- readonly limit?: number;
288
- readonly cursor?: string;
289
- readonly type?: Document["type"];
290
- };
291
- type OrgDocumentsCancelInput = {
292
- readonly organizationId: OrganizationId;
293
- readonly documentId: DocumentId;
294
- };
295
- type CreateCodes$7 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "INVALID_INPUT" | "IDEMPOTENCY_CONFLICT" | "RATE_LIMITED" | "NETWORK_ERROR";
296
- type RetrieveCodes$c = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "INVALID_INPUT";
297
- type ListCodes$9 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "INVALID_INPUT";
298
- type CancelCodes$1 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "INVALID_INPUT" | "OPERATION_CANCELED";
299
- type DocumentsClient = {
300
- readonly create: (input: DocumentsCreateInput) => Promise<CapxulResult<Document, CreateCodes$7>>;
301
- readonly retrieve: (documentId: DocumentId) => Promise<CapxulResult<Document, RetrieveCodes$c>>;
302
- readonly list: (input?: DocumentsListInput) => Promise<CapxulResult<List<Document>, ListCodes$9>>;
303
- readonly cancel: (documentId: DocumentId) => Promise<CapxulResult<Document, CancelCodes$1>>;
304
- };
305
- type OrgDocumentsClient = {
306
- readonly create: (input: OrgDocumentsCreateInput) => Promise<CapxulResult<Document, CreateCodes$7>>;
307
- readonly retrieve: (input: OrgDocumentsRetrieveInput) => Promise<CapxulResult<Document, RetrieveCodes$c>>;
308
- readonly list: (input: OrgDocumentsListInput) => Promise<CapxulResult<List<Document>, ListCodes$9>>;
309
- readonly cancel: (input: OrgDocumentsCancelInput) => Promise<CapxulResult<Document, CancelCodes$1>>;
310
- };
311
-
312
- /**
313
- * External-accounts domain — top-level `capxul.externalAccounts.*`.
314
- *
315
- * Per sdk-surface.md §1a, `external_account` is a reusable withdrawal
316
- * destination. `create` + `list` live under the owner's nested
317
- * namespace (Pattern A — `accounts.externalAccounts.*` or
318
- * `organizations.externalAccounts.*`). The top-level `retrieve` and
319
- * `remove` keep PERSONAL-scope semantics — for org rows route via
320
- * the `organizations.externalAccounts.*` namespace which carries
321
- * `organizationId` end-to-end and pins the row's owner pair to
322
- * prevent cross-org IDOR (revision 1, #464).
323
- *
324
- * Withdrawals v1 W1 (#464) wires these stubs through the
325
- * `externalAccounts/{queries,mutations}` Convex domain. The wire shape
326
- * matches OpenAPI: `{ object: "external_account", id, kind, status,
327
- * ..., operation: { id, status, correlationId } }` — the trust-chain
328
- * ids live under the canonical nested `operation: OperationSummary`
329
- * envelope (revision 3, #464), matching Withdrawal / Payment /
330
- * Transfer / Organization. The SDK rebrands `id` + the nested
331
- * `operation` sub-ids at the read edge.
332
- */
333
-
334
- type RetrieveCodes$b = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND";
335
- type RemoveCodes$4 = RetrieveCodes$b;
336
- type ExternalAccountsClient = {
337
- readonly retrieve: (externalAccountId: ExternalAccountId) => Promise<CapxulResult<ExternalAccount, RetrieveCodes$b>>;
338
- readonly remove: (externalAccountId: ExternalAccountId) => Promise<CapxulResult<void, RemoveCodes$4>>;
339
- };
340
-
341
- /**
342
- * `me` — first-party-only surface for the authenticated user.
343
- *
344
- * Partner SDK code (service-key lens) uses `capxul.accounts.retrieve(id)`
345
- * instead. This namespace exists because the CLI and `useMe()` hook
346
- * in `@capxul/sdk-react` always know the calling user and shouldn't
347
- * need to pass the account id.
348
- *
349
- * See `/docs/internal/reset/sdk-surface` + `packages/sdk/tests/walkthroughs/me-retrieve.ts`.
350
- */
351
-
352
- type MeUpdateInput = Partial<{
353
- readonly name: string;
354
- readonly username: string;
355
- readonly countryCode: string;
356
- }>;
357
- type MeGetCodes = "NOT_AUTHENTICATED" | "PROFILE_NOT_FOUND";
358
- type MeUpdateCodes = "NOT_AUTHENTICATED" | "PROFILE_NOT_FOUND" | "INVALID_INPUT";
359
- type MeClient = {
360
- readonly get: () => Promise<CapxulResult<Account, MeGetCodes>>;
361
- readonly update: (input: MeUpdateInput) => Promise<CapxulResult<Account, MeUpdateCodes>>;
362
- };
363
-
364
- /**
365
- * Operations domain — durable async-work envelope per sdk-surface.md §1b.
366
- *
367
- * `retrieve` is a snapshot read (no polling). `wait` is the opt-in
368
- * polling helper per CANON.md §4.40 — caller explicitly asks to block
369
- * until a terminal condition or timeout.
370
- */
371
-
372
- type OperationsWaitInput = {
373
- readonly until?: readonly OperationStatus[];
374
- readonly timeoutSeconds?: number;
375
- readonly pollIntervalMs?: number;
376
- };
377
- type RetrieveCodes$a = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND";
378
- type WaitCodes = RetrieveCodes$a | "OPERATION_TIMEOUT";
379
- type OperationsClient = {
380
- readonly retrieve: (operationId: OperationId) => Promise<CapxulResult<Operation, RetrieveCodes$a>>;
381
- readonly wait: (operationId: OperationId, input?: OperationsWaitInput) => Promise<CapxulResult<Operation, WaitCodes>>;
382
- };
383
-
384
- /**
385
- * Payments domain.
386
- *
387
- * Exposes both the personal-scope `PaymentsClient` (under
388
- * `capxul.payments.*`) and the org-scoped `OrgPaymentsClient` (under
389
- * `capxul.organizations.payments.*`). The org variant takes
390
- * `organizationId` explicitly on every call; there is no ambient org
391
- * context.
392
- *
393
- * See `/docs/internal/reset/sdk-surface` and the walkthroughs in
394
- * `packages/sdk/tests/walkthroughs/`.
395
- */
396
-
397
- type PaymentsCreateInput = {
398
- readonly to: UserIdentifier;
399
- readonly amount: Money;
400
- readonly reference?: string;
401
- readonly idempotencyKey?: string;
402
- readonly include?: readonly string[];
403
- /**
404
- * Funds v1 (#420): tag the payment with the originating sub-account.
405
- * This personal data-path forwards the field to Convex; broader
406
- * organization and React hook wiring lands in #421 alongside
407
- * `include: ["balancesByCustody"]` read paths.
408
- */
409
- readonly source?: {
410
- readonly subAccountId: SubAccountId;
411
- };
412
- };
413
- type PaymentsListInput = {
414
- readonly limit?: number;
415
- readonly cursor?: string;
416
- readonly include?: readonly string[];
417
- };
418
- type OrgPaymentsCreateInput = {
419
- readonly organizationId: OrganizationId;
420
- readonly source?: {
421
- readonly subAccountId: SubAccountId;
422
- };
423
- readonly to: UserIdentifier;
424
- readonly amount: Money;
425
- readonly reference?: string;
426
- readonly idempotencyKey?: string;
427
- readonly include?: readonly string[];
428
- };
429
- type OrgPaymentsRetrieveInput = {
430
- readonly organizationId: OrganizationId;
431
- readonly paymentId: PaymentId;
432
- };
433
- type OrgPaymentsListInput = {
434
- readonly organizationId: OrganizationId;
435
- readonly limit?: number;
436
- readonly cursor?: string;
437
- readonly include?: readonly string[];
438
- };
439
- type CreateCodes$6 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "INVALID_INPUT" | "INVALID_RECIPIENT" | "INSUFFICIENT_BALANCE" | "IDEMPOTENCY_CONFLICT" | "RATE_LIMITED" | "NETWORK_ERROR";
440
- type OrgCreateCodes = CreateCodes$6 | "POLICY_DENIED" | "SAFE_NOT_READY";
441
- type RetrieveCodes$9 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND";
442
- type ListCodes$8 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "INVALID_INPUT";
443
- type PaymentsClient = {
444
- readonly create: (input: PaymentsCreateInput) => Promise<CapxulResult<CreatePaymentResult, CreateCodes$6>>;
445
- readonly retrieve: (paymentId: PaymentId) => Promise<CapxulResult<Payment, RetrieveCodes$9>>;
446
- readonly list: (input?: PaymentsListInput) => Promise<CapxulResult<List<Payment>, ListCodes$8>>;
447
- };
448
- type OrgPaymentsClient = {
449
- readonly create: (input: OrgPaymentsCreateInput) => Promise<CapxulResult<CreatePaymentResult, OrgCreateCodes>>;
450
- readonly retrieve: (input: OrgPaymentsRetrieveInput) => Promise<CapxulResult<Payment, RetrieveCodes$9>>;
451
- readonly list: (input: OrgPaymentsListInput) => Promise<CapxulResult<List<Payment>, ListCodes$8>>;
452
- };
453
-
454
- /**
455
- * Transfers domain — cross-custody internal moves per CANON.md §4.53.
456
- *
457
- * A transfer moves balance between custody sources owned by the same
458
- * account or organization (e.g. EUR virtual-account → USD stablecoin
459
- * pool). When currencies differ the wire carries an `fx` block with a
460
- * quote id the caller confirms via `transfers.confirm(...)` per §4.58.
461
- */
462
-
463
- type TransfersCreateInput = {
464
- readonly source: TransferEndpoint;
465
- readonly destination: TransferEndpoint;
466
- readonly amount: Money;
467
- readonly idempotencyKey?: string;
468
- readonly include?: readonly string[];
469
- };
470
- type TransfersListInput = {
471
- readonly limit?: number;
472
- readonly cursor?: string;
473
- };
474
- type TransfersConfirmInput = {
475
- readonly transferId: TransferId;
476
- readonly quoteId: string;
477
- };
478
- type OrgTransfersCreateInput = TransfersCreateInput & {
479
- readonly organizationId: OrganizationId;
480
- };
481
- type OrgTransfersRetrieveInput = {
482
- readonly organizationId: OrganizationId;
483
- readonly transferId: TransferId;
484
- };
485
- type OrgTransfersListInput = {
486
- readonly organizationId: OrganizationId;
487
- readonly limit?: number;
488
- readonly cursor?: string;
489
- };
490
- type OrgTransfersConfirmInput = {
491
- readonly organizationId: OrganizationId;
492
- readonly transferId: TransferId;
493
- readonly quoteId: string;
494
- };
495
- type OrgTransfersCancelInput = {
496
- readonly organizationId: OrganizationId;
497
- readonly transferId: TransferId;
498
- };
499
- type CreateCodes$5 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "INVALID_INPUT" | "INSUFFICIENT_BALANCE" | "IDEMPOTENCY_CONFLICT" | "RATE_LIMITED" | "NETWORK_ERROR";
500
- type RetrieveCodes$8 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND";
501
- type ListCodes$7 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "INVALID_INPUT";
502
- type ConfirmCodes = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "QUOTE_EXPIRED" | "QUOTE_NOT_FOUND";
503
- type CancelCodes = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "OPERATION_CANCELED";
504
- type TransfersClient = {
505
- readonly create: (input: TransfersCreateInput) => Promise<CapxulResult<CreateTransferResult, CreateCodes$5>>;
506
- readonly retrieve: (transferId: TransferId) => Promise<CapxulResult<Transfer, RetrieveCodes$8>>;
507
- readonly list: (input?: TransfersListInput) => Promise<CapxulResult<List<Transfer>, ListCodes$7>>;
508
- readonly confirm: (input: TransfersConfirmInput) => Promise<CapxulResult<Transfer, ConfirmCodes>>;
509
- readonly cancel: (transferId: TransferId) => Promise<CapxulResult<Transfer, CancelCodes>>;
510
- };
511
- type OrgTransfersClient = {
512
- readonly create: (input: OrgTransfersCreateInput) => Promise<CapxulResult<CreateTransferResult, CreateCodes$5>>;
513
- readonly retrieve: (input: OrgTransfersRetrieveInput) => Promise<CapxulResult<Transfer, RetrieveCodes$8>>;
514
- readonly list: (input: OrgTransfersListInput) => Promise<CapxulResult<List<Transfer>, ListCodes$7>>;
515
- readonly confirm: (input: OrgTransfersConfirmInput) => Promise<CapxulResult<Transfer, ConfirmCodes>>;
516
- readonly cancel: (input: OrgTransfersCancelInput) => Promise<CapxulResult<Transfer, CancelCodes>>;
517
- };
518
-
519
- /**
520
- * Withdrawals domain — funds exit Capxul via an `external_account` per
521
- * sdk-surface.md §1a + §4.52 + withdrawal-orchestration.mdx.
522
- *
523
- * Withdrawals v1 W2 (#465) refactor:
524
- * - The `kind` shim on `destination` is GONE. The backend now resolves
525
- * the destination row by FK and infers kind + rail. Anything that
526
- * doesn't route to `chain_wallet` returns `VERIFICATION_REQUIRED`.
527
- * - Org-scope `create` is now a real mutation (no longer a stub).
528
- * Personal-scope keeps the on-chain submission tail; org-scope
529
- * returns the `processing` row only — Safe + Zodiac orchestration
530
- * ships in W3+ (D6).
531
- * - All raw `try/catch` blocks have been replaced with `tryCatch` from
532
- * `@repo/observability`, mirroring `core/external-accounts.ts`
533
- * (precedent D2).
534
- */
535
-
536
- type WithdrawalsCreateInput = {
537
- readonly amount: Money;
538
- readonly destination: {
539
- readonly externalAccountId: ExternalAccountId;
540
- };
541
- readonly source?: {
542
- readonly subAccountId: SubAccountId;
543
- };
544
- readonly reference?: string;
545
- readonly idempotencyKey?: string;
546
- readonly include?: readonly string[];
547
- };
548
- type WithdrawalsListInput = {
549
- readonly limit?: number;
550
- readonly cursor?: string;
551
- };
552
- /**
553
- * Withdrawals v1 W4 (#467) — input for the reconciliation pipe.
554
- * Caller passes the same `txHash` that `recordSubmitted` wrote; the
555
- * backend cross-checks the value against the persisted operation row.
556
- *
557
- * `withdrawalId` accepts either the branded `WithdrawalId` or a raw
558
- * string. `txHash` is a raw string at the SDK boundary — the backend
559
- * re-validates the shape via `toTxHash` at the mutation handler (the
560
- * SDK package is no longer coupled to `@repo/types`'s brand surface
561
- * post the alpha-epic decoupling; see
562
- * `packages/sdk/docs/internal/decoupling-prep.md`).
563
- */
564
- type WithdrawalsRecordCompletedInput = {
565
- readonly withdrawalId: WithdrawalId | string;
566
- readonly txHash: string;
567
- };
568
- type OrgWithdrawalsCreateInput = WithdrawalsCreateInput & {
569
- readonly organizationId: OrganizationId;
570
- };
571
- type OrgWithdrawalsRetrieveInput = {
572
- readonly organizationId: OrganizationId;
573
- readonly withdrawalId: WithdrawalId;
574
- };
575
- type OrgWithdrawalsListInput = {
576
- readonly organizationId: OrganizationId;
577
- readonly limit?: number;
578
- readonly cursor?: string;
579
- };
580
- type CreateCodes$4 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "INVALID_INPUT" | "INSUFFICIENT_BALANCE" | "IDEMPOTENCY_CONFLICT" | "KYC_REQUIRED" | "POLICY_DENIED" | "RATE_LIMITED" | "NETWORK_ERROR" | "NOT_FOUND" | "VERIFICATION_REQUIRED";
581
- type RetrieveCodes$7 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND";
582
- type ListCodes$6 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "INVALID_INPUT";
583
- /**
584
- * Narrow code set for `recordCompleted`. Mirror of `recordSubmitted`'s
585
- * code surface — the SDK does NOT export `recordSubmitted` publicly
586
- * (the create signing tail invokes it), but the call shape is the
587
- * reference. Per ADR 9, `recordCompleted` is exposed on personal-scope
588
- * `WithdrawalsClient` ONLY.
589
- */
590
- type RecordCompletedCodes = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "INVALID_INPUT" | "NOT_FOUND" | "NETWORK_ERROR" | "INTERNAL_ERROR";
591
- type WithdrawalsClient = {
592
- readonly create: (input: WithdrawalsCreateInput) => Promise<CapxulResult<CreateWithdrawalResult, CreateCodes$4>>;
593
- readonly retrieve: (withdrawalId: WithdrawalId) => Promise<CapxulResult<Withdrawal, RetrieveCodes$7>>;
594
- readonly list: (input?: WithdrawalsListInput) => Promise<CapxulResult<List<Withdrawal>, ListCodes$6>>;
595
- /**
596
- * Withdrawals v1 W4 (#467) — reconciliation pipe.
597
- *
598
- * Caller invokes this AFTER `withdrawals.create` resolves AND after
599
- * the on-chain receipt confirms (e.g., via the harness's
600
- * `chain.waitReceipt`). The mutation patches the withdrawal +
601
- * execution + attempt + operation rows to terminal happy state and
602
- * emits a single `operation.succeeded` outbox event joined to the
603
- * original correlationId. Idempotent on already-`completed` rows.
604
- *
605
- * Personal-scope only — the org-scope client does NOT expose this
606
- * method (mirror of `recordSubmitted`; see ADR 9 in #467).
607
- */
608
- readonly recordCompleted: (input: WithdrawalsRecordCompletedInput) => Promise<CapxulResult<null, RecordCompletedCodes>>;
609
- };
610
- type OrgWithdrawalsClient = {
611
- readonly create: (input: OrgWithdrawalsCreateInput) => Promise<CapxulResult<CreateWithdrawalResult, CreateCodes$4>>;
612
- readonly retrieve: (input: OrgWithdrawalsRetrieveInput) => Promise<CapxulResult<Withdrawal, RetrieveCodes$7>>;
613
- readonly list: (input: OrgWithdrawalsListInput) => Promise<CapxulResult<List<Withdrawal>, ListCodes$6>>;
614
- };
615
-
616
- /**
617
- * Webhook endpoints domain — developer-registered receivers per
618
- * sdk-surface.md §1b. All methods are org-nested (accessed via
619
- * `capxul.organizations.webhookEndpoints.*` per CANON.md §4.30).
620
- * The top-level `webhookEndpoints` surface on `CapxulClient` is kept
621
- * as an alias for discoverability; its methods proxy to the org
622
- * variant at call time and require `organizationId` explicitly.
623
- */
624
-
625
- type WebhookEndpointsCreateInput = CreateWebhookEndpointRequest & {
626
- readonly organizationId: OrganizationId;
627
- };
628
- type WebhookEndpointsRetrieveInput = {
629
- readonly organizationId: OrganizationId;
630
- readonly webhookEndpointId: WebhookEndpointId;
631
- };
632
- type WebhookEndpointsListInput = {
633
- readonly organizationId: OrganizationId;
634
- readonly limit?: number;
635
- readonly cursor?: string;
636
- };
637
- type WebhookEndpointsRemoveInput = WebhookEndpointsRetrieveInput;
638
- type CreateCodes$3 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "INVALID_INPUT" | "RATE_LIMITED" | "NETWORK_ERROR";
639
- type RetrieveCodes$6 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND";
640
- type ListCodes$5 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "INVALID_INPUT";
641
- type RemoveCodes$3 = RetrieveCodes$6;
642
- /**
643
- * Shape returned by `organizations.webhookEndpoints.create` — the
644
- * one-time `signingSecret` is included here and omitted from every
645
- * subsequent read (per sdk-surface.md §1b).
646
- */
647
- type WebhookEndpointCreateResult = WebhookEndpoint & {
648
- readonly signingSecret: string;
649
- };
650
- type WebhookEndpointsClient = {
651
- readonly create: (input: WebhookEndpointsCreateInput) => Promise<CapxulResult<WebhookEndpointCreateResult, CreateCodes$3>>;
652
- readonly retrieve: (input: WebhookEndpointsRetrieveInput) => Promise<CapxulResult<WebhookEndpoint, RetrieveCodes$6>>;
653
- readonly list: (input: WebhookEndpointsListInput) => Promise<CapxulResult<List<WebhookEndpoint>, ListCodes$5>>;
654
- readonly remove: (input: WebhookEndpointsRemoveInput) => Promise<CapxulResult<void, RemoveCodes$3>>;
655
- };
656
-
657
- /**
658
- * Webhook events domain — individual delivery attempt + payload per
659
- * sdk-surface.md §1b. v1 is read-only (partner replay lands in v1.5
660
- * per §4.20). All methods are org-nested.
661
- */
662
-
663
- type WebhookEventsRetrieveInput = {
664
- readonly organizationId: OrganizationId;
665
- readonly webhookEventId: WebhookEventId;
666
- };
667
- type WebhookEventsListInput = {
668
- readonly organizationId: OrganizationId;
669
- readonly limit?: number;
670
- readonly cursor?: string;
671
- readonly endpointId?: string;
672
- readonly type?: string;
673
- };
674
- type RetrieveCodes$5 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND";
675
- type ListCodes$4 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "INVALID_INPUT";
676
- type WebhookEventsClient = {
677
- readonly retrieve: (input: WebhookEventsRetrieveInput) => Promise<CapxulResult<WebhookEvent, RetrieveCodes$5>>;
678
- readonly list: (input: WebhookEventsListInput) => Promise<CapxulResult<List<WebhookEvent>, ListCodes$4>>;
679
- };
680
-
681
- /**
682
- * Organizations domain per sdk-surface.md §1a.
683
- *
684
- * The org surface is broad because org-scoped flows for every money-
685
- * movement + identity primitive live under `organizations.*` per
686
- * CANON.md §4.30 (Shape A). Sub-client factories delegate to the
687
- * dedicated domain factories in `core/*.ts` so the tuple-return +
688
- * error-narrowing plumbing is shared.
689
- */
690
-
691
- type OrganizationsCreateInput = {
692
- readonly name: string;
693
- readonly country?: string;
694
- };
695
- type OrganizationsListInput = {
696
- readonly limit?: number;
697
- readonly cursor?: string;
698
- };
699
- type OrganizationsUpdateInput = {
700
- readonly organizationId: OrganizationId;
701
- readonly name?: string;
702
- };
703
- type OrgSafeRetrieveInput = {
704
- readonly organizationId: OrganizationId;
705
- readonly safeId: SafeId;
706
- };
707
- type OrgMemberInviteInput = {
708
- readonly organizationId: OrganizationId;
709
- readonly email: string;
710
- readonly role: Member["role"];
711
- };
712
- type OrgMemberAcceptInput = {
713
- readonly token: string;
714
- };
715
- type OrgMemberUpdateRoleInput = {
716
- readonly organizationId: OrganizationId;
717
- readonly memberId: MemberId;
718
- readonly role: Member["role"];
719
- };
720
- type OrgMemberRemoveInput = {
721
- readonly organizationId: OrganizationId;
722
- readonly memberId: MemberId;
723
- };
724
- type OrgMemberRetrieveInput = OrgMemberRemoveInput;
725
- type OrgMemberRevokeInput = OrgMemberRemoveInput;
726
- type OrgMemberResendInput = OrgMemberRemoveInput;
727
- type OrgListInput = {
728
- readonly organizationId: OrganizationId;
729
- readonly limit?: number;
730
- readonly cursor?: string;
731
- };
732
- type OrgMemberListInput = {
733
- readonly organizationId: OrganizationId;
734
- readonly status?: MembershipStatus | "all";
735
- readonly limit?: number;
736
- readonly cursor?: string;
737
- };
738
- type OrgCreateSubAccountInput = {
739
- readonly organizationId: OrganizationId;
740
- readonly name: string;
741
- readonly purpose?: string;
742
- };
743
- type OrgCreateExternalAccountInput = {
744
- readonly organizationId: OrganizationId;
745
- readonly kind: "bank" | "evm" | "solana" | "starknet" | "card_payout";
746
- readonly label?: string;
747
- readonly address?: string;
748
- readonly iban?: string;
749
- readonly bic?: string;
750
- readonly accountHolder?: string;
751
- readonly network?: "visa" | "mastercard";
752
- readonly panToken?: string;
753
- readonly last4?: string;
754
- };
755
- type CreateCodes$2 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "INVALID_INPUT" | "RATE_LIMITED" | "NETWORK_ERROR";
756
- type RetrieveCodes$4 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND";
757
- type ListCodes$3 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "INVALID_INPUT";
758
- type UpdateCodes = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "INVALID_INPUT";
759
- /**
760
- * Org safe retrieve does NOT surface `SAFE_NOT_READY` — a co-member
761
- * who tries to read an in-flight Safe hits `PERMISSION_DENIED` (Safes
762
- * are admin-lens-only), and an admin gets `processing` via the
763
- * operation field. The mid-deploy balance view surfaces via
764
- * `treasury.retrieve` which DOES carry `SAFE_NOT_READY`.
765
- *
766
- * Contrast with `accounts.safes.retrieve` which DOES surface
767
- * `SAFE_NOT_READY` because personal Safes are visible to the owner
768
- * while deploying.
769
- */
770
- type SafeRetrieveCodes = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND";
771
- type TreasuryRetrieveCodes = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "SAFE_NOT_READY";
772
- type RemoveCodes$2 = RetrieveCodes$4;
773
- type SubAccountRemoveCodes = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "INVALID_INPUT";
774
- type OrgSafesClient = {
775
- readonly retrieve: (input: OrgSafeRetrieveInput) => Promise<CapxulResult<Safe, SafeRetrieveCodes>>;
776
- };
777
- type OrgTreasuryClient = {
778
- readonly retrieve: (organizationId: OrganizationId) => Promise<CapxulResult<Treasury, TreasuryRetrieveCodes>>;
779
- };
780
- type OrgMembersClient = {
781
- readonly list: (input: OrgMemberListInput) => Promise<CapxulResult<List<Member>, ListCodes$3>>;
782
- readonly retrieve: (input: OrgMemberRetrieveInput) => Promise<CapxulResult<Member, RetrieveCodes$4>>;
783
- readonly invite: (input: OrgMemberInviteInput) => Promise<CapxulResult<MemberInviteResponse, UpdateCodes>>;
784
- readonly accept: (input: OrgMemberAcceptInput) => Promise<CapxulResult<Member, UpdateCodes>>;
785
- readonly updateRole: (input: OrgMemberUpdateRoleInput) => Promise<CapxulResult<Member, UpdateCodes>>;
786
- readonly revoke: (input: OrgMemberRevokeInput) => Promise<CapxulResult<Member, UpdateCodes>>;
787
- readonly remove: (input: OrgMemberRemoveInput) => Promise<CapxulResult<void, RemoveCodes$2>>;
788
- readonly resend: (input: OrgMemberResendInput) => Promise<CapxulResult<MemberInviteResponse, UpdateCodes>>;
789
- };
790
- type OrgSubAccountsClient = {
791
- readonly create: (input: OrgCreateSubAccountInput) => Promise<CapxulResult<SubAccount, UpdateCodes | "PROVIDER_ERROR">>;
792
- readonly list: (input: OrgListInput) => Promise<CapxulResult<List<SubAccount>, ListCodes$3 | "PROVIDER_ERROR">>;
793
- readonly retrieve: (input: {
794
- readonly organizationId: OrganizationId;
795
- readonly subAccountId: SubAccountId;
796
- }) => Promise<CapxulResult<SubAccount, RetrieveCodes$4 | "PROVIDER_ERROR">>;
797
- readonly remove: (input: {
798
- readonly organizationId: OrganizationId;
799
- readonly subAccountId: SubAccountId;
800
- }) => Promise<CapxulResult<SubAccount, SubAccountRemoveCodes | "PROVIDER_ERROR">>;
801
- };
802
- type OrgExternalAccountsClient = {
803
- readonly create: (input: OrgCreateExternalAccountInput) => Promise<CapxulResult<ExternalAccount, UpdateCodes>>;
804
- readonly list: (input: OrgListInput) => Promise<CapxulResult<List<ExternalAccount>, ListCodes$3>>;
805
- readonly retrieve: (input: {
806
- readonly organizationId: OrganizationId;
807
- readonly externalAccountId: ExternalAccountId;
808
- }) => Promise<CapxulResult<ExternalAccount, RetrieveCodes$4>>;
809
- readonly remove: (input: {
810
- readonly organizationId: OrganizationId;
811
- readonly externalAccountId: ExternalAccountId;
812
- }) => Promise<CapxulResult<void, RemoveCodes$2>>;
813
- };
814
- type OrgBalanceLedgerClient = {
815
- readonly list: (input: OrgListInput) => Promise<CapxulResult<List<BalanceLedgerEntry>, ListCodes$3>>;
816
- readonly retrieve: (input: {
817
- readonly organizationId: OrganizationId;
818
- readonly entryId: string;
819
- }) => Promise<CapxulResult<BalanceLedgerEntry, RetrieveCodes$4>>;
820
- };
821
- type OrgApiKeysClient = ApiKeysClient;
822
- type OrganizationsClient = {
823
- readonly create: (input: OrganizationsCreateInput) => Promise<CapxulResult<Organization, CreateCodes$2>>;
824
- readonly retrieve: (organizationId: OrganizationId) => Promise<CapxulResult<Organization, RetrieveCodes$4>>;
825
- readonly list: (input?: OrganizationsListInput) => Promise<CapxulResult<List<Organization>, ListCodes$3>>;
826
- readonly update: (input: OrganizationsUpdateInput) => Promise<CapxulResult<Organization, UpdateCodes>>;
827
- readonly safes: OrgSafesClient;
828
- readonly treasury: OrgTreasuryClient;
829
- readonly members: OrgMembersClient;
830
- readonly apiKeys: OrgApiKeysClient;
831
- readonly subAccounts: OrgSubAccountsClient;
832
- readonly externalAccounts: OrgExternalAccountsClient;
833
- readonly balanceLedger: OrgBalanceLedgerClient;
834
- readonly payments: OrgPaymentsClient;
835
- readonly transfers: OrgTransfersClient;
836
- readonly withdrawals: OrgWithdrawalsClient;
837
- readonly documents: OrgDocumentsClient;
838
- readonly webhookEndpoints: WebhookEndpointsClient;
839
- readonly webhookEvents: WebhookEventsClient;
840
- };
841
-
842
- /**
843
- * HTTP transport — the SDK's outbound network seam AND the canonical
844
- * lifecycle observable for the publishable-key DX path (ADR #14c).
845
- *
846
- * The transport plays two roles:
847
- *
848
- * 1. **Network seam.** `fetch(path, init?)` resolves a path against
849
- * `authBaseUrl` (absolute URLs are forwarded unchanged). The
850
- * `build-time-urls` arm exposes the URLs immediately; the
851
- * `publishable-key` arm resolves them lazily on first use through
852
- * `/v1/client/bootstrap`, with singleflight + reset-on-failure.
853
- *
854
- * 2. **Lifecycle observable.** A 5-state machine
855
- * (`idle → bootstrapping → ready → authenticated → error`) drives
856
- * the React `useCapxulStatus()` hook. The transport is a stable
857
- * singleton across renders — React subscribes to its lifecycle via
858
- * `useSyncExternalStore` and re-renders only when the state
859
- * transitions, never because the provider rebuilt.
860
- *
861
- * The transport is auth-protocol-agnostic. Path mangling like
862
- * BetterAuth's `/api/auth` prefix lives in `core/auth.ts` and stays
863
- * out of this file.
864
- */
865
-
866
- /**
867
- * Browser-side SDK config — discriminated union per ADR 5.
868
- *
869
- * Stack 2 ships the full union:
870
- * - `mode: "build-time-urls"` for explicit local/dev wiring
871
- * - `mode: "publishable-key"` for browser-safe lazy bootstrap through
872
- * `/v1/client/bootstrap`
873
- */
874
- type BrowserCapxulConfig = {
875
- readonly mode: "build-time-urls";
876
- readonly authBaseUrl: string;
877
- readonly convexUrl: string;
878
- /**
879
- * Inject a `fetch` implementation. Defaults to `globalThis.fetch`.
880
- * Named `fetchImpl` to avoid shadowing the global.
881
- */
882
- readonly fetchImpl?: typeof fetch;
883
- } | {
884
- readonly mode: "publishable-key";
885
- readonly publishableKey: string;
886
- /**
887
- * Override the absolute URL used for `/v1/client/bootstrap`.
888
- *
889
- * Defaults to `${CAPXUL_API_BASE_URL}/v1/client/bootstrap` from
890
- * `@repo/config`. Tests and alternative staging deployments set
891
- * this to point at a local mock server or a non-alpha Convex
892
- * site. A trailing slash is stripped before joining.
893
- */
894
- readonly bootstrapUrl?: string;
895
- readonly fetchImpl?: typeof fetch;
896
- };
897
- /**
898
- * Transport lifecycle state — the canonical state machine for the
899
- * publishable-key DX path per ADR #14c.
900
- *
901
- * Transitions:
902
- * - `idle → bootstrapping` on first network call
903
- * - `bootstrapping → ready` on successful `/v1/client/bootstrap`
904
- * - `bootstrapping → error` on bootstrap failure
905
- * - `error → bootstrapping` when a subsequent caller retries (reset-on-failure)
906
- * - `ready → authenticated` via `markAuthenticated()` after verifyOtp
907
- * - `authenticated → ready` via `signOut()` / `clearAuth()`
908
- *
909
- * The `build-time-urls` arm starts in `ready` immediately because no
910
- * bootstrap is required.
911
- */
912
- type TransportState = {
913
- readonly status: "idle";
914
- } | {
915
- readonly status: "bootstrapping";
916
- } | {
917
- readonly status: "ready";
918
- readonly runtime: TransportRuntime;
919
- } | {
920
- readonly status: "authenticated";
921
- readonly runtime: TransportRuntime;
922
- } | {
923
- readonly status: "error";
924
- readonly error: CapxulError;
925
- };
926
- type TransportRuntime = {
927
- readonly authBaseUrl: string;
928
- readonly convexUrl: string;
929
- };
930
- /**
931
- * HTTP transport surface consumed by every domain client (auth, me,
932
- * payments, …) once Stack 1 task 1.5 routes them through here.
933
- *
934
- * - `fetch(path, init?)` resolves a relative path against
935
- * `authBaseUrl` (absolute URLs are forwarded unchanged).
936
- * - `authBaseUrl` and `convexUrl` are exposed as resolved values so
937
- * downstream consumers (e.g. Convex client construction) can read
938
- * them directly. The publishable-key arm populates these lazily
939
- * after the first bootstrap resolution; before that they are empty
940
- * strings.
941
- * - `getState()` / `subscribe()` are the React-friendly observable
942
- * surface for `useCapxulStatus()`. Use `useSyncExternalStore` on the
943
- * React side.
944
- * - `markAuthenticated()` / `clearAuth()` are the post-verifyOtp /
945
- * post-signOut transition methods (ADR #14c contract item 3 — the
946
- * provider does NOT setState; it lets the transport's state machine
947
- * drive React subscriptions).
948
- */
949
- type HttpTransport = {
950
- readonly fetch: (path: string, init?: RequestInit) => Promise<Response>;
951
- readonly ensureRuntime: () => Promise<TransportRuntime>;
952
- readonly authBaseUrl: string;
953
- readonly convexUrl: string;
954
- readonly getState: () => TransportState;
955
- readonly subscribe: (listener: () => void) => () => void;
956
- readonly getDataClient: () => CapxulDataClient | null;
957
- readonly markAuthenticated: (opts: {
958
- readonly dataClient?: CapxulDataClient;
959
- }) => void;
960
- readonly clearAuth: () => void;
961
- };
962
- /**
963
- * Build an `HttpTransport` from a `BrowserCapxulConfig`.
964
- *
965
- * Throws `CapxulError<"INVALID_INPUT">` with
966
- * `details.source === "sdk-config"` when local transport config is
967
- * malformed. Backend bootstrap failures also throw `CapxulError`, but
968
- * carry `details.source === "backend-bootstrap"` so consumers can
969
- * distinguish setup mistakes from server-side bootstrap refusals.
970
- */
971
- declare function makeHttpTransport(config: BrowserCapxulConfig): HttpTransport;
972
-
973
- /**
974
- * Sub-accounts domain — the top-level `capxul.subAccounts.*` surface.
975
- *
976
- * Per sdk-surface.md §1a, `sub_account` is a named partition under an
977
- * account or organization that aggregates balance across custody
978
- * sources (stablecoin pool + virtual accounts + cards). `create` and
979
- * `list` live on the owner's nested namespace (Pattern A —
980
- * `accounts.subAccounts.create(...)` or
981
- * `organizations.subAccounts.create(...)`), so only `retrieve` and
982
- * `remove` live at the top level.
983
- *
984
- * Wired in PR-2a of the funds-v1 balance-closure stack: the backend
985
- * always returns truthful `balance: Money` per canon §sub_account
986
- * (PR-1 made `toCanonShape` populate it from `computeSubAccountBalance`).
987
- * The SDK brands the wire shape and passes the balance through as-is.
988
- * NO zero-balance fallback exists at the SDK layer — if the backend
989
- * ever omits `balance`, that is a bug to surface, not paper over.
990
- */
991
-
992
- type RetrieveCodes$3 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "PROVIDER_ERROR";
993
- type RemoveCodes$1 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "INVALID_INPUT" | "PROVIDER_ERROR";
994
- type SubAccountsClient = {
995
- readonly retrieve: (subAccountId: SubAccountId) => Promise<CapxulResult<SubAccount, RetrieveCodes$3>>;
996
- readonly remove: (subAccountId: SubAccountId) => Promise<CapxulResult<SubAccount, RemoveCodes$1>>;
997
- };
998
-
999
- /**
1000
- * **NON-CANONICAL surface.**
1001
- *
1002
- * `capxul.tokenTransfers.*` exposes the indexer's raw on-chain ERC-20
1003
- * transfer rows directly to consumers, backed by
1004
- * `packages/backend/convex/tokenTransfers/queries.ts`. Authorized at
1005
- * `slice/02-story2-balance` per the conductor's Option-A verdict —
1006
- * the canonical SDK `transfers.*` namespace assumes a cross-custody
1007
- * internal-move shape (`Transfer = { source, destination, fx,
1008
- * operation, ... }`) that has no canon-aligned backing query yet.
1009
- * Surfacing the on-chain feed under a separate, clearly-marked
1010
- * non-canonical namespace lets the Ink CLI's activity dashboard
1011
- * progress without forcing canon synthesis.
1012
- *
1013
- * **NOT in `packages/api-contract`.** Do NOT use this surface as the
1014
- * basis for new canon. When `transfers.*` shape alignment lands
1015
- * (post-alpha.4 follow-up issue), the canonical `transfers.*` will
1016
- * subsume this and `tokenTransfers.*` becomes a deprecation alias.
1017
- *
1018
- * Stub families that REMAIN deferred at this slice
1019
- * (per `[DEFERRED-CANON]` markers in
1020
- * `.claude/worktrees/post-alpha-wire2/.progress.txt`):
1021
- * - `transfers.{create,retrieve,list,confirm,cancel}` — canon shape mismatch
1022
- * - `accounts.balanceLedger.{list,retrieve}` — no canon backing query
1023
- * - `organizations.balanceLedger.*` — no canon backing query
1024
- * - `organizations.transfers.*` — canon shape mismatch
1025
- * - `organizations.treasury.retrieve` — backing query has different shape
1026
- */
1027
-
1028
- /**
1029
- * Branded id for an on-chain `tokenTransfer` row. Backed by the
1030
- * Convex document id; the brand prevents accidental swaps with other
1031
- * SDK ids without leaking the document-id constraint into call sites.
1032
- *
1033
- * Returned in `TokenTransfer.id` for clients that want a stable
1034
- * back-reference; the canonical lookup key is the
1035
- * `(txHash, logIndex)` composite used by `retrieve`.
1036
- */
1037
- type TokenTransferId = string & {
1038
- readonly __capxulTokenTransferIdBrand: "TokenTransferId";
1039
- };
1040
- declare const toTokenTransferId: (raw: string) => TokenTransferId;
1041
- /**
1042
- * Raw on-chain ERC-20 transfer row. Shape mirrors
1043
- * `tokenTransfers/queries.ts` `list` / `getByTxLogIndex` output. The
1044
- * primitive fields (`txHash`, `tokenAddress`, etc.) match
1045
- * `@repo/api-contract` conventions — `string` for hashes/addresses,
1046
- * `number` for block + chain ids — so consumers don't need to import
1047
- * a brand surface that isn't in the SDK's published deps.
1048
- */
1049
- type TokenTransfer = {
1050
- readonly id: TokenTransferId;
1051
- readonly object: "token_transfer";
1052
- readonly direction: "in" | "out";
1053
- /** Token-units string ("123456" not "1.23456"). Decimals carried in `tokenDecimals`. */
1054
- readonly amount: string;
1055
- readonly tokenSymbol: string;
1056
- readonly tokenDecimals: number;
1057
- readonly tokenAddress: string;
1058
- readonly counterpartyName: string | null;
1059
- readonly counterpartyAddress: string;
1060
- readonly description: string;
1061
- /** Block timestamp in epoch milliseconds. */
1062
- readonly createdAt: number;
1063
- readonly txHash: string;
1064
- readonly blockNumber: number;
1065
- readonly chainId: number;
1066
- };
1067
- type TokenTransfersListPage = {
1068
- readonly object: "list";
1069
- readonly data: readonly TokenTransfer[];
1070
- readonly page: {
1071
- readonly hasMore: boolean;
1072
- /** Block-timestamp cursor (epoch ms) for the next page; null when exhausted. */
1073
- readonly nextCursor: number | null;
1074
- };
1075
- /** Caller's display currency. The backend echoes it so renderers don't need a second round-trip. */
1076
- readonly displayCurrency: string;
1077
- };
1078
- type TokenTransfersListInput = {
1079
- readonly limit?: number;
1080
- /** Block-timestamp cursor (epoch ms) returned in the previous page's `page.nextCursor`. */
1081
- readonly cursor?: number;
1082
- readonly direction?: "in" | "out";
1083
- };
1084
- type TokenTransfersRetrieveInput = {
1085
- readonly txHash: string;
1086
- readonly logIndex: number;
1087
- /** Optional chain filter. When omitted, the first index hit wins (single-chain default). */
1088
- readonly chainId?: number;
1089
- };
1090
- type ListCodes$2 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "INVALID_INPUT";
1091
- type RetrieveCodes$2 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND";
1092
- type TokenTransfersClient = {
1093
- readonly list: (input?: TokenTransfersListInput) => Promise<CapxulResult<TokenTransfersListPage, ListCodes$2>>;
1094
- readonly retrieve: (input: TokenTransfersRetrieveInput) => Promise<CapxulResult<TokenTransfer, RetrieveCodes$2>>;
1095
- };
1096
-
1097
- /**
1098
- * Virtual accounts domain — International Bank Account Number (IBAN)-
1099
- * bearing receive rails per sdk-surface.md §1a + §4.51.
1100
- *
1101
- * Uses Pattern C (ownerKind in body): the caller specifies
1102
- * `owner = { kind: "account" | "sub_account" | "organization", id: ... }`
1103
- * in the create payload rather than nesting the route under the owner.
1104
- */
1105
-
1106
- type VirtualAccountsCreateInput = CreateVirtualAccountRequest;
1107
- type VirtualAccountsListInput = {
1108
- readonly limit?: number;
1109
- readonly cursor?: string;
1110
- readonly ownerKind?: "account" | "sub_account" | "organization";
1111
- readonly ownerId?: string;
1112
- };
1113
- type CreateCodes$1 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "INVALID_INPUT" | "KYC_REQUIRED" | "PROVIDER_UNAVAILABLE" | "RATE_LIMITED" | "NETWORK_ERROR";
1114
- type RetrieveCodes$1 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND";
1115
- type ListCodes$1 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "INVALID_INPUT";
1116
- type RemoveCodes = RetrieveCodes$1;
1117
- type VirtualAccountsClient = {
1118
- readonly create: (input: VirtualAccountsCreateInput) => Promise<CapxulResult<VirtualAccount, CreateCodes$1>>;
1119
- readonly retrieve: (virtualAccountId: VirtualAccountId) => Promise<CapxulResult<VirtualAccount, RetrieveCodes$1>>;
1120
- readonly list: (input?: VirtualAccountsListInput) => Promise<CapxulResult<List<VirtualAccount>, ListCodes$1>>;
1121
- readonly remove: (virtualAccountId: VirtualAccountId) => Promise<CapxulResult<void, RemoveCodes>>;
1122
- };
1123
-
1124
- /**
1125
- * Virtual cards domain — issued Visa / Mastercard spending sub-account
1126
- * balance per sdk-surface.md §1a + §4.51.
1127
- *
1128
- * Uses Pattern C (ownerKind in body).
1129
- */
1130
-
1131
- type VirtualCardsCreateInput = CreateVirtualCardRequest;
1132
- type VirtualCardsListInput = {
1133
- readonly limit?: number;
1134
- readonly cursor?: string;
1135
- readonly ownerKind?: "account" | "sub_account" | "organization";
1136
- readonly ownerId?: string;
1137
- };
1138
- type CreateCodes = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "INVALID_INPUT" | "KYC_REQUIRED" | "PROVIDER_UNAVAILABLE" | "RATE_LIMITED" | "NETWORK_ERROR";
1139
- type RetrieveCodes = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND";
1140
- type ListCodes = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "INVALID_INPUT";
1141
- type MutateCodes = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "PROVIDER_UNAVAILABLE";
1142
- type VirtualCardsClient = {
1143
- readonly create: (input: VirtualCardsCreateInput) => Promise<CapxulResult<VirtualCard, CreateCodes>>;
1144
- readonly retrieve: (virtualCardId: VirtualCardId) => Promise<CapxulResult<VirtualCard, RetrieveCodes>>;
1145
- readonly list: (input?: VirtualCardsListInput) => Promise<CapxulResult<List<VirtualCard>, ListCodes>>;
1146
- readonly freeze: (virtualCardId: VirtualCardId) => Promise<CapxulResult<VirtualCard, MutateCodes>>;
1147
- readonly unfreeze: (virtualCardId: VirtualCardId) => Promise<CapxulResult<VirtualCard, MutateCodes>>;
1148
- readonly cancel: (virtualCardId: VirtualCardId) => Promise<CapxulResult<VirtualCard, MutateCodes>>;
1149
- };
1150
-
1151
- /**
1152
- * Root `@capxul/sdk` client factory.
1153
- *
1154
- * Canonical construction per sdk-surface.md §3a:
1155
- *
1156
- * ```ts
1157
- * import { createCapxulClient, createLocalSigner } from "@capxul/sdk";
1158
- *
1159
- * const capxul = createCapxulClient({
1160
- * apiKey: process.env.CAPXUL_API_KEY!,
1161
- * signer: createLocalSigner(process.env.CAPXUL_PRIVATE_KEY as `0x${string}`),
1162
- * });
1163
- * ```
1164
- *
1165
- * Three auth modes are mutually exclusive:
1166
- * - `apiKey` — server-to-server partner flows (`cap_live_` / `cap_test_`)
1167
- * - `publishableKey` — installed-app flows with OTP-established human
1168
- * sessions (`cap_pk_live_` / `cap_pk_test_`); sessions persist
1169
- * via the SDK's auth adapter (file / cookie depending on runtime)
1170
- * - neither — unauthenticated only; useful for `auth.sendOtp` +
1171
- * `auth.verifyOtp` bootstrap before a session exists
1172
- *
1173
- * The `signer` (viem `Account`) is required for methods that submit
1174
- * on-chain UserOperations (payments, withdrawals, transfers) per
1175
- * CANON.md §4.28.
1176
- */
1177
-
1178
- type CapxulSigningConfig = {
1179
- /** EVM chain ID (currently Base Sepolia). */
1180
- readonly chainId: number;
1181
- /** JSON-RPC URL for UserOperation submission. */
1182
- readonly rpcUrl: string;
1183
- /** Alchemy gas policy ID for UserOperation sponsorship. */
1184
- readonly gasPolicyId: string;
1185
- };
1186
- type CapxulAuthConfig = {
1187
- /**
1188
- * Convex `.site` URL that hosts the BetterAuth endpoints.
1189
- *
1190
- * Optional when the client is configured with a publishable key and
1191
- * lazy bootstrap resolves the runtime URLs instead.
1192
- */
1193
- readonly baseUrl?: string;
1194
- /** Optional explicit Convex token endpoint. Defaults to `${baseUrl}/api/auth/convex/token`. */
1195
- readonly convexTokenUrl?: string;
1196
- /** Scenario/browser-local session store shared by auth + onboarding hooks. */
1197
- readonly sessionStore?: AuthSessionStore;
1198
- };
1199
- type CapxulConfig = {
1200
- /** Server-to-server partner key. Mutually exclusive with `publishableKey`. */
1201
- readonly apiKey?: string;
1202
- /**
1203
- * Installed-app publishable key. Pairs with an OTP-established human
1204
- * session persisted by the SDK's auth adapter.
1205
- */
1206
- readonly publishableKey?: string;
1207
- /**
1208
- * viem `Account` used to sign UserOperations for on-chain methods
1209
- * (payments, withdrawals, transfers) per CANON.md §4.28.
1210
- */
1211
- readonly signer?: Account$1;
1212
- /**
1213
- * @internal
1214
- *
1215
- * Test-only override seam for injecting an authenticated Convex data client.
1216
- * The SDK now owns runtime construction of the data client; this field is
1217
- * reserved for tests and the React provider's singleton lifecycle.
1218
- */
1219
- readonly _data?: CapxulDataClient;
1220
- /**
1221
- * Chain + bundler configuration for on-chain submission.
1222
- *
1223
- * Required alongside `signer` for runtime `payments.create`.
1224
- */
1225
- readonly signing?: CapxulSigningConfig;
1226
- /** Human OTP auth runtime configuration. */
1227
- readonly auth?: CapxulAuthConfig;
1228
- /**
1229
- * Override the API base URL. Defaults to `https://api.capxul.com`
1230
- * in production builds; point at `http://localhost:<port>/v1` for
1231
- * local development against Convex's httpAction router.
1232
- */
1233
- readonly baseUrl?: string;
1234
- /**
1235
- * Inject a `fetch` implementation. Defaults to global `fetch`. Used
1236
- * for testing or to plug in `undici` / `node-fetch` in older Node
1237
- * environments.
1238
- */
1239
- readonly fetch?: typeof fetch;
1240
- /**
1241
- * @internal
1242
- *
1243
- * Inject a pre-built `HttpTransport`. The `@capxul/sdk-react`
1244
- * `CapxulProvider` uses this in the lazy-DX path (ADR #14c) so the
1245
- * provider's externally-built transport is the SAME singleton used by
1246
- * the auth client's bootstrap calls. Without injection, the SDK would
1247
- * build a second transport internally — the `useCapxulStatus()` hook
1248
- * would observe a different state machine than the one auth methods
1249
- * actually drive.
1250
- *
1251
- * Underscored to mark it as an internal SDK seam, not a partner-facing
1252
- * config field. Do not document publicly.
1253
- */
1254
- readonly _transport?: HttpTransport;
1255
- };
1256
- /**
1257
- * Per-call factories for XState v5 flow machines.
1258
- *
1259
- * Each factory returns a fresh machine instance bound to this
1260
- * `CapxulClient`. The consumer is responsible for creating a single
1261
- * actor (e.g. via `createActor` / React's `useMemo` + `useActor`) and
1262
- * keeping it alive for the duration of the flow. Calling a factory
1263
- * twice yields two independent machines — useful for parallel
1264
- * onboarding sessions in tests, never the desired pattern in app code.
1265
- *
1266
- * The return types are intentionally erased to `AnyStateMachine` to
1267
- * keep this surface stable across XState v5 type-parameter changes;
1268
- * downstream consumers (`@capxul/sdk-react` hooks, the e2e harness's
1269
- * `xstateFlowSequence` primitive) re-import the precise types from
1270
- * `./flows/*` when they need them.
1271
- */
1272
- type CapxulFlowFactories = {
1273
- readonly onboarding: () => AnyStateMachine;
1274
- readonly provisioning: () => AnyStateMachine;
1275
- };
1276
- type CapxulClient = {
1277
- /**
1278
- * @internal
1279
- *
1280
- * Per-client UUID minted at construction. Used as a TanStack Query
1281
- * cache-key prefix to isolate per-client cache when multiple
1282
- * `CapxulClient` instances are mounted in the same React tree.
1283
- *
1284
- * MUST NOT be passed to `identify()`, `track()`, or any analytics
1285
- * surface — PostHog has no way to distinguish "namespace UUID" from
1286
- * "person UUID" and conflating the two creates fake users in
1287
- * analytics. Treat as opaque cache implementation detail.
1288
- *
1289
- * Stable for the lifetime of the client; new on every
1290
- * `createCapxulClient()` call. See Codex P1 finding on PR #406.
1291
- */
1292
- readonly id: string;
1293
- readonly auth: AuthService;
1294
- readonly me: MeClient;
1295
- readonly accounts: AccountsClient;
1296
- readonly organizations: OrganizationsClient;
1297
- readonly payments: PaymentsClient;
1298
- readonly transfers: TransfersClient;
1299
- /**
1300
- * **NON-CANONICAL.** On-chain ERC-20 transfer feed (raw indexer
1301
- * rows). NOT part of `packages/api-contract`. Slated for
1302
- * deprecation when canonical `transfers.*` shape alignment lands.
1303
- * See `core/token-transfers.ts` for the doc-comment contract.
1304
- */
1305
- readonly tokenTransfers: TokenTransfersClient;
1306
- readonly withdrawals: WithdrawalsClient;
1307
- readonly documents: DocumentsClient;
1308
- readonly subAccounts: SubAccountsClient;
1309
- readonly virtualAccounts: VirtualAccountsClient;
1310
- readonly virtualCards: VirtualCardsClient;
1311
- readonly externalAccounts: ExternalAccountsClient;
1312
- readonly operations: OperationsClient;
1313
- readonly webhookEndpoints: WebhookEndpointsClient;
1314
- readonly webhookEvents: WebhookEventsClient;
1315
- readonly apiKeys: ApiKeysClient;
1316
- readonly flows: CapxulFlowFactories;
1317
- };
1318
- /**
1319
- * Construct a Capxul client. Every method stub in Slice C throws
1320
- * `NOT_IMPLEMENTED` per CANON.md §2 (types-first scaffold). Slice F.2
1321
- * wires the restart `payments` + `operations` runtime path through an
1322
- * injected authenticated Convex client; the broader `/v1/*` surface is
1323
- * still pending.
1324
- *
1325
- * Two-pass construction: the per-domain clients (`auth`, `me`, …) are
1326
- * built first, then `flows` is assigned with factories that close over
1327
- * the fully-built `client` so the spawned XState machines can call
1328
- * back into `client.accounts.provisionPersonal`, etc. The intermediate
1329
- * `clientWithoutFlows` value is typed without
1330
- * `flows`; `Object.assign` mutates a single `flows` field on it before
1331
- * the returned `CapxulClient` cast — minimal and contained.
1332
- */
1333
- declare function createCapxulClient(config?: CapxulConfig): CapxulClient;
1334
-
1335
- export { type AccountProvisionPersonalInput as A, type BrowserCapxulConfig as B, type CapxulClient as C, type DocumentsClient as D, type ExternalAccountsClient as E, type TokenTransfersListPage as F, type TokenTransfersRetrieveInput as G, type HttpTransport as H, type TransfersClient as I, type TransportRuntime as J, type TransportState as K, type LocalPrivateKeySignerProvider as L, type MeClient as M, type VirtualAccountsClient as N, type OperationsClient as O, type PaymentsClient as P, type VirtualCardsClient as Q, type WebhookEndpointsClient as R, type Session as S, type TokenTransfer as T, type WebhookEventsClient as U, type VerifyOtpResult as V, type WebhookEndpointCreateResult as W, type WithdrawalsClient as X, createCapxulClient as Y, makeHttpTransport as Z, toTokenTransferId as _, type AccountsClient as a, type ApiKeyCreateResult as b, type ApiKeysClient as c, type AuthBootstrapReason as d, type AuthBootstrapToken as e, AuthService as f, type AuthSessionStore as g, type CapxulAuthConfig as h, type CapxulConfig as i, type CapxulDataClient as j, type CapxulFlowFactories as k, type CapxulSigningConfig as l, type CompleteBootstrapInput as m, type CompleteBootstrapResult as n, type OrgDocumentsClient as o, type OrgMembersClient as p, type OrgPaymentsClient as q, type OrgSafesClient as r, type OrgTransfersClient as s, type OrgTreasuryClient as t, type OrgWithdrawalsClient as u, type OrganizationsClient as v, type SubAccountsClient as w, type TokenTransferId as x, type TokenTransfersClient as y, type TokenTransfersListInput as z };