@capxul/sdk 0.1.0-alpha.0
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/CHANGELOG.md +26 -0
- package/LICENSE +44 -0
- package/README.md +143 -0
- package/dist/client-BNGGubL2.d.cts +1147 -0
- package/dist/client-o4R-ZFh2.d.ts +1147 -0
- package/dist/client.cjs +2272 -0
- package/dist/client.d.cts +7 -0
- package/dist/client.d.ts +7 -0
- package/dist/client.js +2270 -0
- package/dist/errors.cjs +35 -0
- package/dist/errors.d.cts +55 -0
- package/dist/errors.d.ts +55 -0
- package/dist/errors.js +31 -0
- package/dist/index.cjs +2504 -0
- package/dist/index.d.cts +495 -0
- package/dist/index.d.ts +495 -0
- package/dist/index.js +2469 -0
- package/dist/types-Cokyqgwm.d.cts +202 -0
- package/dist/types-Cokyqgwm.d.ts +202 -0
- package/dist/webhooks.cjs +118 -0
- package/dist/webhooks.d.cts +34 -0
- package/dist/webhooks.d.ts +34 -0
- package/dist/webhooks.js +116 -0
- package/package.json +89 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,495 @@
|
|
|
1
|
+
import { S as Session, C as CapxulClient, A as AccountProvisionPersonalInput } from './client-BNGGubL2.cjs';
|
|
2
|
+
export { a as AccountsClient, b as ApiKeyCreateResult, c as ApiKeysClient, d as AuthClient, e as AuthSessionStore, B as BrowserCapxulConfig, f as CapxulAuthConfig, g as CapxulConfig, h as CapxulDataClient, i as CapxulFlowFactories, j as CapxulSigningConfig, D as DocumentsClient, E as ExternalAccountsClient, H as HttpTransport, L as LocalPrivateKeySignerProvider, M as MeClient, O as OperationsClient, k as OrgDocumentsClient, l as OrgPaymentsClient, m as OrgSafesClient, n as OrgTransfersClient, o as OrgTreasuryClient, p as OrgWithdrawalsClient, q as OrganizationsClient, P as PaymentsClient, r as SubAccountsClient, T as TransfersClient, s as TransportRuntime, t as TransportState, V as VirtualAccountsClient, u as VirtualCardsClient, W as WebhookEndpointCreateResult, v as WebhookEndpointsClient, w as WebhookEventsClient, x as WithdrawalsClient, y as createCapxulClient, z as makeHttpTransport } from './client-BNGGubL2.cjs';
|
|
3
|
+
import * as xstate from 'xstate';
|
|
4
|
+
import { CapxulError as CapxulError$1 } from '@repo/config';
|
|
5
|
+
import { Email, Username, OperationId, NextAction, CapxulErrorCode } from '@repo/platform-kernel';
|
|
6
|
+
export { AccountId, ApiKeyId, BalanceLedgerEntryId, CapxulErrorCode, CapxulErrorDetails, CapxulErrorEnvelope, CorrelationId, DocumentId, Email, ExternalAccountId, KybProfileId, KycProfileId, MemberId, NextAction, OperationId, OrganizationId, PaymentId, PhoneNumber, SafeId, SubAccountId, TransactionIntentId, TransferId, TreasuryId, Username, VirtualAccountId, VirtualCardId, WebhookEndpointId, WebhookEventId, WithdrawalId, toAccountId, toApiKeyId, toBalanceLedgerEntryId, toDocumentId, toEmail, toExternalAccountId, toKybProfileId, toKycProfileId, toMemberId, toOperationId, toOrganizationId, toPaymentId, toPhoneNumber, toSafeId, toSubAccountId, toTransferId, toTreasuryId, toUsername, toVirtualAccountId, toVirtualCardId, toWebhookEndpointId, toWebhookEventId, toWithdrawalId } from '@repo/platform-kernel';
|
|
7
|
+
import { CapxulError } from './errors.cjs';
|
|
8
|
+
export { CapxulResult } from './errors.cjs';
|
|
9
|
+
import { A as Account } from './types-Cokyqgwm.cjs';
|
|
10
|
+
export { a as AccountLookupResult, b as ApiKey, c as ApiKeyEnvironment, d as ApiKeyType, B as BalanceLedgerEntry, e as BankStatementDocument, C as CreatePaymentResult, f as CreateTransferResult, g as CreateWithdrawalResult, D as Document, E as ExternalAccount, h as ExternalAccountKind, I as InvoiceDocument, K as KybProfile, i as KycProfile, j as KycUploadDocument, L as List, M as Member, k as Money, O as Operation, l as OperationStatus, m as OperationSummary, n as Organization, P as PageInfo, o as Payment, p as PaymentParty, q as PaymentStatus, r as PayrollRunDocument, s as PayrollScheduleDocument, R as ReceiptDocument, S as Safe, t as Scope, u as Settlement, v as SubAccount, w as SubAccountOwnerKind, T as TaxFormDocument, x as TimestampIso, y as Transfer, z as TransferCustody, F as TransferEndpoint, G as TransferFx, H as TransferStatus, J as Treasury, U as UserIdentifier, V as VirtualAccount, N as VirtualAccountOwnerKind, Q as VirtualCard, W as VirtualCardLimits, X as VirtualCardOwnerKind, Y as WebhookEndpoint, Z as WebhookEvent, _ as Withdrawal, $ as WithdrawalStatus } from './types-Cokyqgwm.cjs';
|
|
11
|
+
import { Account as Account$1 } from 'viem';
|
|
12
|
+
export { WebhookVerificationOptions, WebhookVerificationResult, verifyWebhook } from './webhooks.cjs';
|
|
13
|
+
import '@repo/api-contract/gen/types';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Auth flow errors may originate from two CapxulError surfaces:
|
|
17
|
+
* - the SDK-local generic `CapxulError<Codes>` returned by
|
|
18
|
+
* `client.auth.*` tuple methods
|
|
19
|
+
* - the `@repo/config` `CapxulError` produced by the `Errors.xxx()`
|
|
20
|
+
* factory family (per `error-handling.md`)
|
|
21
|
+
*
|
|
22
|
+
* Both share `.code`, `.message`, `.details`, and extend `Error`. The
|
|
23
|
+
* union keeps either origin assignable to `context.error` without an
|
|
24
|
+
* `as` cast at the call site.
|
|
25
|
+
*/
|
|
26
|
+
type AuthFlowError = CapxulError | CapxulError$1;
|
|
27
|
+
type AuthFlowContext = {
|
|
28
|
+
readonly email: Email | null;
|
|
29
|
+
readonly session: Session | null;
|
|
30
|
+
readonly error: AuthFlowError | null;
|
|
31
|
+
};
|
|
32
|
+
type AuthFlowEvent = {
|
|
33
|
+
readonly type: "REQUEST_OTP";
|
|
34
|
+
readonly email: Email;
|
|
35
|
+
} | {
|
|
36
|
+
readonly type: "VERIFY";
|
|
37
|
+
readonly code: string;
|
|
38
|
+
} | {
|
|
39
|
+
readonly type: "RESET";
|
|
40
|
+
} | {
|
|
41
|
+
readonly type: "SIGN_OUT";
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Build the auth state machine bound to a `CapxulClient` instance.
|
|
45
|
+
*
|
|
46
|
+
* States: `idle -> sending_otp -> otp_requested -> verifying ->
|
|
47
|
+
* authenticated -> signing_out -> idle`, with `error` as a sidecar
|
|
48
|
+
* from any async step.
|
|
49
|
+
*/
|
|
50
|
+
declare function createAuthFlowMachine(client: CapxulClient): xstate.StateMachine<AuthFlowContext, {
|
|
51
|
+
readonly type: "REQUEST_OTP";
|
|
52
|
+
readonly email: Email;
|
|
53
|
+
} | {
|
|
54
|
+
readonly type: "VERIFY";
|
|
55
|
+
readonly code: string;
|
|
56
|
+
} | {
|
|
57
|
+
readonly type: "RESET";
|
|
58
|
+
} | {
|
|
59
|
+
readonly type: "SIGN_OUT";
|
|
60
|
+
}, {
|
|
61
|
+
[x: string]: xstate.ActorRefFromLogic<xstate.PromiseActorLogic<void, {
|
|
62
|
+
email: Email;
|
|
63
|
+
}, xstate.EventObject>> | xstate.ActorRefFromLogic<xstate.PromiseActorLogic<Session, {
|
|
64
|
+
email: Email;
|
|
65
|
+
code: string;
|
|
66
|
+
}, xstate.EventObject>> | xstate.ActorRefFromLogic<xstate.PromiseActorLogic<void, void, xstate.EventObject>> | undefined;
|
|
67
|
+
}, {
|
|
68
|
+
src: "sendOtp";
|
|
69
|
+
logic: xstate.PromiseActorLogic<void, {
|
|
70
|
+
email: Email;
|
|
71
|
+
}, xstate.EventObject>;
|
|
72
|
+
id: string | undefined;
|
|
73
|
+
} | {
|
|
74
|
+
src: "verifyOtp";
|
|
75
|
+
logic: xstate.PromiseActorLogic<Session, {
|
|
76
|
+
email: Email;
|
|
77
|
+
code: string;
|
|
78
|
+
}, xstate.EventObject>;
|
|
79
|
+
id: string | undefined;
|
|
80
|
+
} | {
|
|
81
|
+
src: "signOut";
|
|
82
|
+
logic: xstate.PromiseActorLogic<void, void, xstate.EventObject>;
|
|
83
|
+
id: string | undefined;
|
|
84
|
+
}, {
|
|
85
|
+
type: "trackOtpRequested";
|
|
86
|
+
params: unknown;
|
|
87
|
+
} | {
|
|
88
|
+
type: "trackOtpFailed";
|
|
89
|
+
params: unknown;
|
|
90
|
+
} | {
|
|
91
|
+
type: "trackTimeoutFailed";
|
|
92
|
+
params: unknown;
|
|
93
|
+
} | {
|
|
94
|
+
type: "trackVerified";
|
|
95
|
+
params: unknown;
|
|
96
|
+
} | {
|
|
97
|
+
type: "identifyAndTrack";
|
|
98
|
+
params: unknown;
|
|
99
|
+
} | {
|
|
100
|
+
type: "trackSignedOut";
|
|
101
|
+
params: unknown;
|
|
102
|
+
}, never, never, "idle" | "authenticated" | "error" | "sending_otp" | "otp_requested" | "verifying" | "signing_out", string, xstate.NonReducibleUnknown, xstate.NonReducibleUnknown, xstate.EventObject, xstate.MetaObject, {
|
|
103
|
+
id: "auth";
|
|
104
|
+
states: {
|
|
105
|
+
readonly idle: {};
|
|
106
|
+
readonly sending_otp: {};
|
|
107
|
+
readonly otp_requested: {};
|
|
108
|
+
readonly verifying: {};
|
|
109
|
+
readonly authenticated: {};
|
|
110
|
+
readonly signing_out: {};
|
|
111
|
+
readonly error: {};
|
|
112
|
+
};
|
|
113
|
+
}>;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Provisioning flow errors may originate from two CapxulError surfaces:
|
|
117
|
+
* - the SDK-local generic `CapxulError<Codes>` returned by
|
|
118
|
+
* `client.accounts.provisionPersonal`
|
|
119
|
+
* - the `@repo/config` `CapxulError` produced by the `Errors.xxx()`
|
|
120
|
+
* factory family (per `error-handling.md`) used for non-CapxulError
|
|
121
|
+
* cause wrapping and the timeout error
|
|
122
|
+
*
|
|
123
|
+
* Both share `.code`, `.message`, `.details`, and extend `Error`.
|
|
124
|
+
*/
|
|
125
|
+
type ProvisioningFlowError = CapxulError | CapxulError$1;
|
|
126
|
+
type ProvisioningFlowContext = {
|
|
127
|
+
readonly input: AccountProvisionPersonalInput | null;
|
|
128
|
+
readonly account: Account | null;
|
|
129
|
+
readonly error: ProvisioningFlowError | null;
|
|
130
|
+
};
|
|
131
|
+
type ProvisioningFlowEvent = {
|
|
132
|
+
readonly type: "START";
|
|
133
|
+
readonly input: AccountProvisionPersonalInput;
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Input accepted at machine startup. Optional — when present the
|
|
137
|
+
* machine seeds context from it and skips `idle`. When absent the
|
|
138
|
+
* machine sits in `idle` and waits for a `START` event.
|
|
139
|
+
*
|
|
140
|
+
* The `| undefined` half of this union is what lets standalone
|
|
141
|
+
* callers write `createActor(machine, { input: undefined })` (or pass
|
|
142
|
+
* no input via `{}`), because XState v5's `RequiredActorOptionsKeys`
|
|
143
|
+
* computes `undefined extends InputFrom<TLogic> ? never : 'input'`
|
|
144
|
+
* and standalone callers need that to resolve to `never`. Invoked-by-
|
|
145
|
+
* parent callsites pass the populated `{ input }` shape via
|
|
146
|
+
* `invoke.input` and the `context` factory below narrows it.
|
|
147
|
+
*/
|
|
148
|
+
type ProvisioningFlowInput = {
|
|
149
|
+
readonly input: AccountProvisionPersonalInput;
|
|
150
|
+
} | undefined;
|
|
151
|
+
/**
|
|
152
|
+
* Output emitted when the machine reaches a top-level final state
|
|
153
|
+
* (`done` or `error`). Parents that invoke this machine (e.g.
|
|
154
|
+
* onboarding) read this via `event.output` on their `onDone`
|
|
155
|
+
* transition and branch with a guard on `event.output.error`.
|
|
156
|
+
*/
|
|
157
|
+
type ProvisioningFlowOutput = {
|
|
158
|
+
readonly account: Account;
|
|
159
|
+
readonly error?: undefined;
|
|
160
|
+
} | {
|
|
161
|
+
readonly account?: undefined;
|
|
162
|
+
readonly error: ProvisioningFlowError;
|
|
163
|
+
};
|
|
164
|
+
/**
|
|
165
|
+
* Build the provisioning state machine bound to a `CapxulClient`
|
|
166
|
+
* instance.
|
|
167
|
+
*
|
|
168
|
+
* States: `starting -> idle | running -> done | error`. `starting` is
|
|
169
|
+
* a transient routing state: if the machine was created with input,
|
|
170
|
+
* it goes straight to `running`; otherwise it falls back to `idle`
|
|
171
|
+
* and waits for a `START` event. Both `done` and `error` are
|
|
172
|
+
* top-level XState v5 `final` states; the machine's root-level
|
|
173
|
+
* `output` mapper inspects `context` to produce
|
|
174
|
+
* `{ account } | { error }` for the parent's `onDone` event.
|
|
175
|
+
*
|
|
176
|
+
* Per-state-node `output` is not supported in XState v5 — only the
|
|
177
|
+
* machine root has an `output` mapper, which is why this file derives
|
|
178
|
+
* the discriminated payload from `context.error` vs `context.account`.
|
|
179
|
+
*/
|
|
180
|
+
declare function createProvisioningMachine(client: CapxulClient): xstate.StateMachine<ProvisioningFlowContext, {
|
|
181
|
+
readonly type: "START";
|
|
182
|
+
readonly input: AccountProvisionPersonalInput;
|
|
183
|
+
}, {
|
|
184
|
+
[x: string]: xstate.ActorRefFromLogic<xstate.PromiseActorLogic<Account, {
|
|
185
|
+
input: AccountProvisionPersonalInput;
|
|
186
|
+
}, xstate.EventObject>> | undefined;
|
|
187
|
+
}, {
|
|
188
|
+
src: "provisionPersonal";
|
|
189
|
+
logic: xstate.PromiseActorLogic<Account, {
|
|
190
|
+
input: AccountProvisionPersonalInput;
|
|
191
|
+
}, xstate.EventObject>;
|
|
192
|
+
id: string | undefined;
|
|
193
|
+
}, {
|
|
194
|
+
type: "trackWalletCreated";
|
|
195
|
+
params: unknown;
|
|
196
|
+
} | {
|
|
197
|
+
type: "trackSafeCreated";
|
|
198
|
+
params: unknown;
|
|
199
|
+
}, {
|
|
200
|
+
type: "hasInput";
|
|
201
|
+
params: unknown;
|
|
202
|
+
}, never, "idle" | "error" | "done" | "starting" | "running", string, {
|
|
203
|
+
readonly input: AccountProvisionPersonalInput;
|
|
204
|
+
}, {
|
|
205
|
+
readonly account: Account;
|
|
206
|
+
readonly error?: undefined;
|
|
207
|
+
} | {
|
|
208
|
+
readonly account?: undefined;
|
|
209
|
+
readonly error: ProvisioningFlowError;
|
|
210
|
+
}, xstate.EventObject, xstate.MetaObject, {
|
|
211
|
+
id: "provisioning";
|
|
212
|
+
states: {
|
|
213
|
+
readonly starting: {};
|
|
214
|
+
readonly idle: {};
|
|
215
|
+
readonly running: {};
|
|
216
|
+
readonly done: {};
|
|
217
|
+
readonly error: {};
|
|
218
|
+
};
|
|
219
|
+
}>;
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Onboarding flow errors may originate from two CapxulError surfaces:
|
|
223
|
+
* - the SDK-local generic `CapxulError<Codes>` returned by
|
|
224
|
+
* `client.accounts.provisionPersonal` and constructed for synchronous
|
|
225
|
+
* pre-actor rejections (NOT_IMPLEMENTED, INVALID_INPUT)
|
|
226
|
+
* - the `@repo/config` `CapxulError` produced by the `Errors.xxx()`
|
|
227
|
+
* factory family (per `error-handling.md`) used for non-CapxulError
|
|
228
|
+
* cause wrapping and the timeout error
|
|
229
|
+
*
|
|
230
|
+
* Both share `.code`, `.message`, `.details`, and extend `Error`.
|
|
231
|
+
*/
|
|
232
|
+
type OnboardingFlowError = CapxulError | CapxulError$1;
|
|
233
|
+
/** Subjects supported by the onboarding flow. */
|
|
234
|
+
type OnboardingSubjectKind = "account" | "organization";
|
|
235
|
+
/**
|
|
236
|
+
* Input captured by the "profile" step before Safe provisioning.
|
|
237
|
+
*
|
|
238
|
+
* For `kind: "organization"`, `organizationName` is required (this lift
|
|
239
|
+
* does not implement the org branch — see `error.code = "NOT_IMPLEMENTED"`).
|
|
240
|
+
*/
|
|
241
|
+
type OnboardingProfileInput = {
|
|
242
|
+
readonly kind: OnboardingSubjectKind;
|
|
243
|
+
readonly username?: Username;
|
|
244
|
+
readonly displayName?: string;
|
|
245
|
+
readonly country?: string;
|
|
246
|
+
readonly organizationName?: string;
|
|
247
|
+
readonly signerProvider?: AccountProvisionPersonalInput["signerProvider"];
|
|
248
|
+
};
|
|
249
|
+
type OnboardingFlowContext = {
|
|
250
|
+
readonly input: OnboardingProfileInput | null;
|
|
251
|
+
readonly operationId: OperationId | null;
|
|
252
|
+
readonly account: Account | null;
|
|
253
|
+
readonly error: OnboardingFlowError | null;
|
|
254
|
+
};
|
|
255
|
+
type OnboardingFlowEvent = {
|
|
256
|
+
readonly type: "START_PROVISIONING";
|
|
257
|
+
readonly input: OnboardingProfileInput;
|
|
258
|
+
} | {
|
|
259
|
+
readonly type: "PROCEED";
|
|
260
|
+
} | {
|
|
261
|
+
readonly type: "RESET";
|
|
262
|
+
};
|
|
263
|
+
/**
|
|
264
|
+
* Build the onboarding state machine bound to a `CapxulClient`
|
|
265
|
+
* instance.
|
|
266
|
+
*
|
|
267
|
+
* States: `profile -> provisioning -> complete` on the happy path,
|
|
268
|
+
* with `error` reachable from `profile` (validation rejections) or
|
|
269
|
+
* `provisioning` (spawned-machine reported error / outer timeout /
|
|
270
|
+
* unhandled child throw). `action_required` is declared for parity
|
|
271
|
+
* with the public `OnboardingFlowState` type but is unreachable in
|
|
272
|
+
* this lift.
|
|
273
|
+
*
|
|
274
|
+
* The `provisioning` state invokes a spawned `provisioningMachine`
|
|
275
|
+
* (built from `createProvisioningMachine(client)`) rather than the
|
|
276
|
+
* `provisionPersonal` actor directly. The child machine reports its
|
|
277
|
+
* outcome via its root-level `output` (`{ account } | { error }`),
|
|
278
|
+
* which the parent observes on `onDone` and branches on via guards.
|
|
279
|
+
*/
|
|
280
|
+
declare function createOnboardingFlowMachine(client: CapxulClient): xstate.StateMachine<OnboardingFlowContext, {
|
|
281
|
+
readonly type: "START_PROVISIONING";
|
|
282
|
+
readonly input: OnboardingProfileInput;
|
|
283
|
+
} | {
|
|
284
|
+
readonly type: "PROCEED";
|
|
285
|
+
} | {
|
|
286
|
+
readonly type: "RESET";
|
|
287
|
+
}, {
|
|
288
|
+
[x: string]: xstate.ActorRefFromLogic<xstate.StateMachine<ProvisioningFlowContext, {
|
|
289
|
+
readonly type: "START";
|
|
290
|
+
readonly input: AccountProvisionPersonalInput;
|
|
291
|
+
}, {
|
|
292
|
+
[x: string]: xstate.ActorRefFromLogic<xstate.PromiseActorLogic<Account, {
|
|
293
|
+
input: AccountProvisionPersonalInput;
|
|
294
|
+
}, xstate.EventObject>> | undefined;
|
|
295
|
+
}, {
|
|
296
|
+
src: "provisionPersonal";
|
|
297
|
+
logic: xstate.PromiseActorLogic<Account, {
|
|
298
|
+
input: AccountProvisionPersonalInput;
|
|
299
|
+
}, xstate.EventObject>;
|
|
300
|
+
id: string | undefined;
|
|
301
|
+
}, {
|
|
302
|
+
type: "trackWalletCreated";
|
|
303
|
+
params: unknown;
|
|
304
|
+
} | {
|
|
305
|
+
type: "trackSafeCreated";
|
|
306
|
+
params: unknown;
|
|
307
|
+
}, {
|
|
308
|
+
type: "hasInput";
|
|
309
|
+
params: unknown;
|
|
310
|
+
}, never, "idle" | "error" | "done" | "starting" | "running", string, {
|
|
311
|
+
readonly input: AccountProvisionPersonalInput;
|
|
312
|
+
}, {
|
|
313
|
+
readonly account: Account;
|
|
314
|
+
readonly error?: undefined;
|
|
315
|
+
} | {
|
|
316
|
+
readonly account?: undefined;
|
|
317
|
+
readonly error: ProvisioningFlowError;
|
|
318
|
+
}, xstate.EventObject, xstate.MetaObject, {
|
|
319
|
+
id: "provisioning";
|
|
320
|
+
states: {
|
|
321
|
+
readonly starting: {};
|
|
322
|
+
readonly idle: {};
|
|
323
|
+
readonly running: {};
|
|
324
|
+
readonly done: {};
|
|
325
|
+
readonly error: {};
|
|
326
|
+
};
|
|
327
|
+
}>> | undefined;
|
|
328
|
+
}, {
|
|
329
|
+
src: "provisioningMachine";
|
|
330
|
+
logic: xstate.StateMachine<ProvisioningFlowContext, {
|
|
331
|
+
readonly type: "START";
|
|
332
|
+
readonly input: AccountProvisionPersonalInput;
|
|
333
|
+
}, {
|
|
334
|
+
[x: string]: xstate.ActorRefFromLogic<xstate.PromiseActorLogic<Account, {
|
|
335
|
+
input: AccountProvisionPersonalInput;
|
|
336
|
+
}, xstate.EventObject>> | undefined;
|
|
337
|
+
}, {
|
|
338
|
+
src: "provisionPersonal";
|
|
339
|
+
logic: xstate.PromiseActorLogic<Account, {
|
|
340
|
+
input: AccountProvisionPersonalInput;
|
|
341
|
+
}, xstate.EventObject>;
|
|
342
|
+
id: string | undefined;
|
|
343
|
+
}, {
|
|
344
|
+
type: "trackWalletCreated";
|
|
345
|
+
params: unknown;
|
|
346
|
+
} | {
|
|
347
|
+
type: "trackSafeCreated";
|
|
348
|
+
params: unknown;
|
|
349
|
+
}, {
|
|
350
|
+
type: "hasInput";
|
|
351
|
+
params: unknown;
|
|
352
|
+
}, never, "idle" | "error" | "done" | "starting" | "running", string, {
|
|
353
|
+
readonly input: AccountProvisionPersonalInput;
|
|
354
|
+
}, {
|
|
355
|
+
readonly account: Account;
|
|
356
|
+
readonly error?: undefined;
|
|
357
|
+
} | {
|
|
358
|
+
readonly account?: undefined;
|
|
359
|
+
readonly error: ProvisioningFlowError;
|
|
360
|
+
}, xstate.EventObject, xstate.MetaObject, {
|
|
361
|
+
id: "provisioning";
|
|
362
|
+
states: {
|
|
363
|
+
readonly starting: {};
|
|
364
|
+
readonly idle: {};
|
|
365
|
+
readonly running: {};
|
|
366
|
+
readonly done: {};
|
|
367
|
+
readonly error: {};
|
|
368
|
+
};
|
|
369
|
+
}>;
|
|
370
|
+
id: string | undefined;
|
|
371
|
+
}, {
|
|
372
|
+
type: "assignOperationIdAndInput";
|
|
373
|
+
params: unknown;
|
|
374
|
+
} | {
|
|
375
|
+
type: "assignOrgNotImplemented";
|
|
376
|
+
params: unknown;
|
|
377
|
+
} | {
|
|
378
|
+
type: "assignMissingSigner";
|
|
379
|
+
params: unknown;
|
|
380
|
+
} | {
|
|
381
|
+
type: "trackOrgSubmitted";
|
|
382
|
+
params: unknown;
|
|
383
|
+
} | {
|
|
384
|
+
type: "trackPersonalSubmitted";
|
|
385
|
+
params: unknown;
|
|
386
|
+
} | {
|
|
387
|
+
type: "trackOrgNotImplementedError";
|
|
388
|
+
params: unknown;
|
|
389
|
+
} | {
|
|
390
|
+
type: "trackMissingSignerError";
|
|
391
|
+
params: unknown;
|
|
392
|
+
} | {
|
|
393
|
+
type: "trackWalletCreating";
|
|
394
|
+
params: unknown;
|
|
395
|
+
} | {
|
|
396
|
+
type: "trackOnboardingCompleted";
|
|
397
|
+
params: unknown;
|
|
398
|
+
} | {
|
|
399
|
+
type: "trackProvisioningFailed";
|
|
400
|
+
params: unknown;
|
|
401
|
+
} | {
|
|
402
|
+
type: "assignChildReportedError";
|
|
403
|
+
params: unknown;
|
|
404
|
+
} | {
|
|
405
|
+
type: "assignChildThrown";
|
|
406
|
+
params: unknown;
|
|
407
|
+
} | {
|
|
408
|
+
type: "assignAccountFromChild";
|
|
409
|
+
params: unknown;
|
|
410
|
+
} | {
|
|
411
|
+
type: "resetContext";
|
|
412
|
+
params: unknown;
|
|
413
|
+
}, {
|
|
414
|
+
type: "isOrg";
|
|
415
|
+
params: unknown;
|
|
416
|
+
} | {
|
|
417
|
+
type: "missingSigner";
|
|
418
|
+
params: unknown;
|
|
419
|
+
} | {
|
|
420
|
+
type: "childReportedError";
|
|
421
|
+
params: unknown;
|
|
422
|
+
}, never, "action_required" | "provisioning" | "error" | "profile" | "complete", string, xstate.NonReducibleUnknown, xstate.NonReducibleUnknown, xstate.EventObject, xstate.MetaObject, {
|
|
423
|
+
id: "onboarding";
|
|
424
|
+
states: {
|
|
425
|
+
readonly profile: {};
|
|
426
|
+
readonly provisioning: {};
|
|
427
|
+
readonly action_required: {};
|
|
428
|
+
readonly complete: {};
|
|
429
|
+
readonly error: {};
|
|
430
|
+
};
|
|
431
|
+
}>;
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* Exhaustive error-code dispatch per CANON.md §4.44.
|
|
435
|
+
*
|
|
436
|
+
* Given a `CapxulError<Codes>` and a handlers object keyed by `Codes`,
|
|
437
|
+
* routes to the matching arm. TypeScript enforces exhaustiveness via
|
|
438
|
+
* the mapped-key union: missing a code the method can produce is a
|
|
439
|
+
* compile error, and handling a code the method CANNOT produce is a
|
|
440
|
+
* compile error (the handler key isn't assignable to `Codes`).
|
|
441
|
+
*
|
|
442
|
+
* No `default:` arm needed — the compile-time exhaustiveness check is
|
|
443
|
+
* the contract.
|
|
444
|
+
*/
|
|
445
|
+
declare function matchError<Codes extends CapxulErrorCode, R>(err: CapxulError<Codes>, handlers: {
|
|
446
|
+
[K in Codes]: (err: CapxulError<K>) => R;
|
|
447
|
+
}): R;
|
|
448
|
+
/**
|
|
449
|
+
* Exhaustive resource-status dispatch per CANON.md §4.44.
|
|
450
|
+
*
|
|
451
|
+
* The generic `T extends { status: string }` lets downstream callers
|
|
452
|
+
* pass any discriminated-union resource (Payment, Safe, Transfer,
|
|
453
|
+
* Operation, etc.). Handlers are keyed on the literal `status` values
|
|
454
|
+
* declared by `T`, so passing a status not in `T["status"]` is a
|
|
455
|
+
* compile error.
|
|
456
|
+
*/
|
|
457
|
+
declare function matchStatus<T extends {
|
|
458
|
+
status: string;
|
|
459
|
+
}, R>(value: T, handlers: {
|
|
460
|
+
[K in T["status"]]: (value: Extract<T, {
|
|
461
|
+
status: K;
|
|
462
|
+
}>) => R;
|
|
463
|
+
}): R;
|
|
464
|
+
/**
|
|
465
|
+
* Exhaustive NextAction.kind dispatch per CANON.md §4.44.
|
|
466
|
+
*
|
|
467
|
+
* Handlers must cover every `kind` in the union `A`. `A` defaults to
|
|
468
|
+
* `NextAction` from `@repo/platform-kernel` — the 8-variant canonical
|
|
469
|
+
* union. CANON.md §4.58 adds a 9th variant (`confirm_fx_quote`); once
|
|
470
|
+
* the kernel's `NextAction` grows, this helper automatically picks it
|
|
471
|
+
* up via the generic default.
|
|
472
|
+
*
|
|
473
|
+
* Pass `A extends NextAction` explicitly when you need a narrower
|
|
474
|
+
* variant subset (e.g. a per-method narrowing that excludes
|
|
475
|
+
* `contact_support`).
|
|
476
|
+
*/
|
|
477
|
+
declare function matchAction<A extends NextAction, R>(action: A, handlers: {
|
|
478
|
+
[K in A["kind"]]: (action: Extract<A, {
|
|
479
|
+
kind: K;
|
|
480
|
+
}>) => R;
|
|
481
|
+
}): R;
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* Convenience constructor for a viem `Account` backed by a raw private
|
|
485
|
+
* key — the CLI / server-side signer per CANON.md §4.28.
|
|
486
|
+
*
|
|
487
|
+
* The SDK accepts `viem.Account` directly; this helper just saves the
|
|
488
|
+
* caller an import. For Openfort / MetaMask / other browser signers,
|
|
489
|
+
* use `@capxul/sdk-react` (follow-up slice).
|
|
490
|
+
*
|
|
491
|
+
* @param privateKey `0x`-prefixed 32-byte hex string (64 hex chars).
|
|
492
|
+
*/
|
|
493
|
+
declare function createLocalSigner(privateKey: `0x${string}`): Account$1;
|
|
494
|
+
|
|
495
|
+
export { Account, AccountProvisionPersonalInput, type AuthFlowContext, type AuthFlowError, type AuthFlowEvent, CapxulClient, CapxulError, type OnboardingFlowContext, type OnboardingFlowError, type OnboardingFlowEvent, type OnboardingProfileInput, type OnboardingSubjectKind, type ProvisioningFlowContext, type ProvisioningFlowError, type ProvisioningFlowEvent, type ProvisioningFlowInput, type ProvisioningFlowOutput, Session, createAuthFlowMachine, createLocalSigner, createOnboardingFlowMachine, createProvisioningMachine as createProvisioningFlowMachine, matchAction, matchError, matchStatus };
|