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