@capxul/sdk 0.1.0-alpha.9 → 0.2.0-alpha.4
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 +126 -0
- package/README.md +103 -16
- package/dist/{client-ChZrdf3R.d.ts → client-CbUeJoM9.d.ts} +84 -235
- package/dist/{client-DG6ODWu6.d.cts → client-UEm2oZbZ.d.cts} +84 -235
- package/dist/client.cjs +1655 -1073
- package/dist/client.d.cts +4 -4
- package/dist/client.d.ts +4 -4
- package/dist/client.js +1655 -1073
- package/dist/{errors-QHD5Tlok.d.ts → errors-CwhCWGxm.d.ts} +1 -1
- package/dist/{errors-GgKrSUKp.d.cts → errors-rqxuUhQP.d.cts} +1 -1
- package/dist/errors.d.cts +2 -2
- package/dist/errors.d.ts +2 -2
- package/dist/index.cjs +1655 -1076
- package/dist/index.d.cts +73 -112
- package/dist/index.d.ts +73 -112
- package/dist/index.js +1654 -1076
- package/dist/{next-action-DkrwXYay.d.cts → next-action-CTGl8wpy.d.cts} +2 -2
- package/dist/{next-action-DkrwXYay.d.ts → next-action-CTGl8wpy.d.ts} +2 -2
- package/dist/{types-PM4AQRLP.d.ts → types-BD4VAQb5.d.ts} +77 -8
- package/dist/{types-hfcOE7Oi.d.cts → types-HlwCIjgQ.d.cts} +77 -8
- package/dist/webhooks.cjs +1 -1
- package/dist/webhooks.d.cts +2 -2
- package/dist/webhooks.d.ts +2 -2
- package/dist/webhooks.js +1 -1
- package/package.json +6 -5
package/dist/index.d.cts
CHANGED
|
@@ -1,114 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { A as AccountProvisionPersonalInput, C as CapxulClient } from './client-UEm2oZbZ.cjs';
|
|
2
|
+
export { a as AccountsClient, b as ApiKeyCreateResult, c as ApiKeysClient, d as AuthBootstrapReason, e as AuthBootstrapToken, f as AuthService, g as AuthSessionStore, B as BrowserCapxulConfig, h as CapxulAuthConfig, i as CapxulConfig, j as CapxulDataClient, k as CapxulFlowFactories, l as CapxulSigningConfig, m as CompleteBootstrapInput, n as CompleteBootstrapResult, D as DocumentsClient, E as ExternalAccountsClient, H as HttpTransport, L as LocalPrivateKeySignerProvider, M as MeClient, O as OperationsClient, o as OrgDocumentsClient, p as OrgMembersClient, q as OrgPaymentsClient, r as OrgSafesClient, s as OrgTransfersClient, t as OrgTreasuryClient, u as OrgWithdrawalsClient, v as OrganizationsClient, P as PaymentsClient, S as Session, w as SubAccountsClient, T as TokenTransfer, x as TokenTransferId, y as TokenTransfersClient, z as TokenTransfersListInput, F as TokenTransfersListPage, G as TokenTransfersRetrieveInput, I as TransfersClient, J as TransportRuntime, K as TransportState, V as VerifyOtpResult, N as VirtualAccountsClient, Q as VirtualCardsClient, W as WebhookEndpointCreateResult, R as WebhookEndpointsClient, U as WebhookEventsClient, X as WithdrawalsClient, Y as createCapxulClient, Z as makeHttpTransport, _ as toTokenTransferId } from './client-UEm2oZbZ.cjs';
|
|
3
3
|
import * as xstate from 'xstate';
|
|
4
|
-
import {
|
|
5
|
-
export {
|
|
6
|
-
import {
|
|
7
|
-
export { b as
|
|
8
|
-
import {
|
|
9
|
-
export {
|
|
4
|
+
import { C as CapxulError$1, a as CapxulErrorCode$1 } from './errors-rqxuUhQP.cjs';
|
|
5
|
+
export { b as CapxulErrorDetails, c as CapxulErrorEnvelope, d as CapxulResult } from './errors-rqxuUhQP.cjs';
|
|
6
|
+
import { A as Account } from './types-HlwCIjgQ.cjs';
|
|
7
|
+
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-HlwCIjgQ.cjs';
|
|
8
|
+
import { U as Username, O as OperationId, N as NextAction } from './next-action-CTGl8wpy.cjs';
|
|
9
|
+
export { A as AccountId, a as ApiKeyId, B as BalanceLedgerEntryId, C as CorrelationId, D as DocumentId, E as Email, 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.cjs';
|
|
10
10
|
import { Account as Account$1 } from 'viem';
|
|
11
11
|
export { WebhookVerificationOptions, WebhookVerificationResult, verifyWebhook } from './webhooks.cjs';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
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.
|
|
14
|
+
* Unified error type used across the entire stack: backend, SDK, and frontend.
|
|
15
|
+
* One class, one set of codes, one language.
|
|
43
16
|
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* from any async step.
|
|
17
|
+
* Backend throws CapxulError → withErrorBoundary serializes to ConvexError →
|
|
18
|
+
* SDK deserializes back to CapxulError → frontend routes on err.code.
|
|
47
19
|
*/
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
readonly
|
|
51
|
-
|
|
52
|
-
readonly
|
|
53
|
-
readonly
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
}>;
|
|
20
|
+
type CapxulErrorCode = "NOT_AUTHENTICATED" | "EMAIL_DELIVERY_FAILED" | "API_KEY_INVALID" | "API_KEY_EXPIRED" | "PROFILE_NOT_FOUND" | "SMART_ACCOUNT_MISSING" | "PLAYER_NOT_FOUND" | "ACCOUNT_NOT_FOUND" | "PROVIDER_ERROR" | "INVALID_INPUT" | "ENV_MISSING" | "NOT_IMPLEMENTED" | "VERIFICATION_REQUIRED" | "INSUFFICIENT_BALANCE" | "INVALID_RECIPIENT" | "TRANSACTION_FAILED" | "RATE_LIMITED" | "NETWORK_ERROR" | "PERMISSION_DENIED" | "IDEMPOTENCY_CONFLICT" | "NOT_FOUND" | "OPERATION_CANCELED" | "OPERATION_TIMEOUT" | "ACTION_REQUIRED" | "KYC_REQUIRED" | "POLICY_DENIED" | "SAFE_NOT_READY" | "PROVIDER_UNAVAILABLE" | "PROVIDER_REJECTED" | "RECONCILIATION_FAILED" | "INTERNAL_ERROR" | "QUOTE_EXPIRED" | "QUOTE_NOT_FOUND" | "INDEXER_DELIVERY_TIMEOUT" | "UNKNOWN";
|
|
21
|
+
declare class CapxulError extends Error {
|
|
22
|
+
readonly code: CapxulErrorCode;
|
|
23
|
+
readonly details?: Record<string, unknown>;
|
|
24
|
+
readonly correlationId?: string;
|
|
25
|
+
readonly layer?: string;
|
|
26
|
+
constructor(code: CapxulErrorCode, message: string, options?: {
|
|
27
|
+
cause?: unknown;
|
|
28
|
+
details?: Record<string, unknown>;
|
|
29
|
+
correlationId?: string;
|
|
30
|
+
layer?: string;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
112
33
|
|
|
113
34
|
/**
|
|
114
35
|
* Provisioning flow errors may originate from two CapxulError surfaces:
|
|
@@ -120,7 +41,7 @@ declare function createAuthFlowMachine(client: CapxulClient): xstate.StateMachin
|
|
|
120
41
|
*
|
|
121
42
|
* Both share `.code`, `.message`, `.details`, and extend `Error`.
|
|
122
43
|
*/
|
|
123
|
-
type ProvisioningFlowError = CapxulError | CapxulError
|
|
44
|
+
type ProvisioningFlowError = CapxulError$1 | CapxulError;
|
|
124
45
|
type ProvisioningFlowContext = {
|
|
125
46
|
readonly input: AccountProvisionPersonalInput | null;
|
|
126
47
|
readonly account: Account | null;
|
|
@@ -197,7 +118,7 @@ declare function createProvisioningMachine(client: CapxulClient): xstate.StateMa
|
|
|
197
118
|
}, {
|
|
198
119
|
type: "hasInput";
|
|
199
120
|
params: unknown;
|
|
200
|
-
}, never, "
|
|
121
|
+
}, never, "done" | "error" | "idle" | "starting" | "running", string, {
|
|
201
122
|
readonly input: AccountProvisionPersonalInput;
|
|
202
123
|
}, {
|
|
203
124
|
readonly account: Account;
|
|
@@ -227,7 +148,7 @@ declare function createProvisioningMachine(client: CapxulClient): xstate.StateMa
|
|
|
227
148
|
*
|
|
228
149
|
* Both share `.code`, `.message`, `.details`, and extend `Error`.
|
|
229
150
|
*/
|
|
230
|
-
type OnboardingFlowError = CapxulError | CapxulError
|
|
151
|
+
type OnboardingFlowError = CapxulError$1 | CapxulError;
|
|
231
152
|
/** Subjects supported by the onboarding flow. */
|
|
232
153
|
type OnboardingSubjectKind = "account" | "organization";
|
|
233
154
|
/**
|
|
@@ -305,7 +226,7 @@ declare function createOnboardingFlowMachine(client: CapxulClient): xstate.State
|
|
|
305
226
|
}, {
|
|
306
227
|
type: "hasInput";
|
|
307
228
|
params: unknown;
|
|
308
|
-
}, never, "
|
|
229
|
+
}, never, "done" | "error" | "idle" | "starting" | "running", string, {
|
|
309
230
|
readonly input: AccountProvisionPersonalInput;
|
|
310
231
|
}, {
|
|
311
232
|
readonly account: Account;
|
|
@@ -347,7 +268,7 @@ declare function createOnboardingFlowMachine(client: CapxulClient): xstate.State
|
|
|
347
268
|
}, {
|
|
348
269
|
type: "hasInput";
|
|
349
270
|
params: unknown;
|
|
350
|
-
}, never, "
|
|
271
|
+
}, never, "done" | "error" | "idle" | "starting" | "running", string, {
|
|
351
272
|
readonly input: AccountProvisionPersonalInput;
|
|
352
273
|
}, {
|
|
353
274
|
readonly account: Account;
|
|
@@ -440,8 +361,8 @@ declare function createOnboardingFlowMachine(client: CapxulClient): xstate.State
|
|
|
440
361
|
* No `default:` arm needed — the compile-time exhaustiveness check is
|
|
441
362
|
* the contract.
|
|
442
363
|
*/
|
|
443
|
-
declare function matchError<Codes extends CapxulErrorCode, R>(err: CapxulError<Codes>, handlers: {
|
|
444
|
-
[K in Codes]: (err: CapxulError<K>) => R;
|
|
364
|
+
declare function matchError<Codes extends CapxulErrorCode$1, R>(err: CapxulError$1<Codes>, handlers: {
|
|
365
|
+
[K in Codes]: (err: CapxulError$1<K>) => R;
|
|
445
366
|
}): R;
|
|
446
367
|
/**
|
|
447
368
|
* Exhaustive resource-status dispatch per CANON.md §4.44.
|
|
@@ -497,4 +418,44 @@ declare function tryCatch<T>(promise: Promise<T>): Promise<[Error, null] | [null
|
|
|
497
418
|
*/
|
|
498
419
|
declare function createLocalSigner(privateKey: `0x${string}`): Account$1;
|
|
499
420
|
|
|
500
|
-
|
|
421
|
+
type SignerProvisionResult = {
|
|
422
|
+
readonly signer: Account$1;
|
|
423
|
+
readonly safeAddress: `0x${string}`;
|
|
424
|
+
};
|
|
425
|
+
/**
|
|
426
|
+
* Headless signer auto-provisioner.
|
|
427
|
+
*
|
|
428
|
+
* Generates a fresh viem private-key account and deterministically derives
|
|
429
|
+
* the corresponding Safe v1.4.1 address.
|
|
430
|
+
*
|
|
431
|
+
* No consumer computes `safeAddress` — it is derived internally and
|
|
432
|
+
* returned alongside the signer so `AuthService.completeBootstrap`
|
|
433
|
+
* can supply it to the backend.
|
|
434
|
+
*
|
|
435
|
+
* **Key persistence note:** Every call to `provision()` mints a fresh
|
|
436
|
+
* private key. The caller MUST persist the returned `signer` (or its
|
|
437
|
+
* private key) if the derived `safeAddress` must be recoverable in
|
|
438
|
+
* future sessions. The bootstrap flow persists the signer via the
|
|
439
|
+
* backend (`signerProvider` row), but direct API consumers are
|
|
440
|
+
* responsible for their own key storage.
|
|
441
|
+
*/
|
|
442
|
+
declare class SignerProvisioner {
|
|
443
|
+
provision(): SignerProvisionResult;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
type PaymentToken = {
|
|
447
|
+
readonly address: `0x${string}`;
|
|
448
|
+
readonly decimals: number;
|
|
449
|
+
readonly symbol: string;
|
|
450
|
+
};
|
|
451
|
+
/**
|
|
452
|
+
* Resolve a currency code to its on-chain payment token metadata.
|
|
453
|
+
*
|
|
454
|
+
* Currently supports USDC only (USD and USDC codes map to the same
|
|
455
|
+
* token). Non-USDC codes return a `NOT_IMPLEMENTED` stub so callers
|
|
456
|
+
* can scaffold multi-currency flows before the registry is fully
|
|
457
|
+
* populated.
|
|
458
|
+
*/
|
|
459
|
+
declare function resolvePaymentToken(currency: string): PaymentToken;
|
|
460
|
+
|
|
461
|
+
export { Account, AccountProvisionPersonalInput, CapxulClient, CapxulError$1 as CapxulError, CapxulErrorCode$1 as CapxulErrorCode, NextAction, type OnboardingFlowContext, type OnboardingFlowError, type OnboardingFlowEvent, type OnboardingProfileInput, type OnboardingSubjectKind, OperationId, type PaymentToken, type ProvisioningFlowContext, type ProvisioningFlowError, type ProvisioningFlowEvent, type ProvisioningFlowInput, type ProvisioningFlowOutput, type SignerProvisionResult, SignerProvisioner, Username, createLocalSigner, createOnboardingFlowMachine, createProvisioningMachine as createProvisioningFlowMachine, matchAction, matchError, matchStatus, resolvePaymentToken, tryCatch };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,114 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { A as AccountProvisionPersonalInput, C as CapxulClient } from './client-CbUeJoM9.js';
|
|
2
|
+
export { a as AccountsClient, b as ApiKeyCreateResult, c as ApiKeysClient, d as AuthBootstrapReason, e as AuthBootstrapToken, f as AuthService, g as AuthSessionStore, B as BrowserCapxulConfig, h as CapxulAuthConfig, i as CapxulConfig, j as CapxulDataClient, k as CapxulFlowFactories, l as CapxulSigningConfig, m as CompleteBootstrapInput, n as CompleteBootstrapResult, D as DocumentsClient, E as ExternalAccountsClient, H as HttpTransport, L as LocalPrivateKeySignerProvider, M as MeClient, O as OperationsClient, o as OrgDocumentsClient, p as OrgMembersClient, q as OrgPaymentsClient, r as OrgSafesClient, s as OrgTransfersClient, t as OrgTreasuryClient, u as OrgWithdrawalsClient, v as OrganizationsClient, P as PaymentsClient, S as Session, w as SubAccountsClient, T as TokenTransfer, x as TokenTransferId, y as TokenTransfersClient, z as TokenTransfersListInput, F as TokenTransfersListPage, G as TokenTransfersRetrieveInput, I as TransfersClient, J as TransportRuntime, K as TransportState, V as VerifyOtpResult, N as VirtualAccountsClient, Q as VirtualCardsClient, W as WebhookEndpointCreateResult, R as WebhookEndpointsClient, U as WebhookEventsClient, X as WithdrawalsClient, Y as createCapxulClient, Z as makeHttpTransport, _ as toTokenTransferId } from './client-CbUeJoM9.js';
|
|
3
3
|
import * as xstate from 'xstate';
|
|
4
|
-
import {
|
|
5
|
-
export {
|
|
6
|
-
import {
|
|
7
|
-
export { b as
|
|
8
|
-
import {
|
|
9
|
-
export {
|
|
4
|
+
import { C as CapxulError$1, a as CapxulErrorCode$1 } from './errors-CwhCWGxm.js';
|
|
5
|
+
export { b as CapxulErrorDetails, c as CapxulErrorEnvelope, d as CapxulResult } from './errors-CwhCWGxm.js';
|
|
6
|
+
import { A as Account } from './types-BD4VAQb5.js';
|
|
7
|
+
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-BD4VAQb5.js';
|
|
8
|
+
import { U as Username, O as OperationId, N as NextAction } from './next-action-CTGl8wpy.js';
|
|
9
|
+
export { A as AccountId, a as ApiKeyId, B as BalanceLedgerEntryId, C as CorrelationId, D as DocumentId, E as Email, 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';
|
|
10
10
|
import { Account as Account$1 } from 'viem';
|
|
11
11
|
export { WebhookVerificationOptions, WebhookVerificationResult, verifyWebhook } from './webhooks.js';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
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.
|
|
14
|
+
* Unified error type used across the entire stack: backend, SDK, and frontend.
|
|
15
|
+
* One class, one set of codes, one language.
|
|
43
16
|
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* from any async step.
|
|
17
|
+
* Backend throws CapxulError → withErrorBoundary serializes to ConvexError →
|
|
18
|
+
* SDK deserializes back to CapxulError → frontend routes on err.code.
|
|
47
19
|
*/
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
readonly
|
|
51
|
-
|
|
52
|
-
readonly
|
|
53
|
-
readonly
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
}>;
|
|
20
|
+
type CapxulErrorCode = "NOT_AUTHENTICATED" | "EMAIL_DELIVERY_FAILED" | "API_KEY_INVALID" | "API_KEY_EXPIRED" | "PROFILE_NOT_FOUND" | "SMART_ACCOUNT_MISSING" | "PLAYER_NOT_FOUND" | "ACCOUNT_NOT_FOUND" | "PROVIDER_ERROR" | "INVALID_INPUT" | "ENV_MISSING" | "NOT_IMPLEMENTED" | "VERIFICATION_REQUIRED" | "INSUFFICIENT_BALANCE" | "INVALID_RECIPIENT" | "TRANSACTION_FAILED" | "RATE_LIMITED" | "NETWORK_ERROR" | "PERMISSION_DENIED" | "IDEMPOTENCY_CONFLICT" | "NOT_FOUND" | "OPERATION_CANCELED" | "OPERATION_TIMEOUT" | "ACTION_REQUIRED" | "KYC_REQUIRED" | "POLICY_DENIED" | "SAFE_NOT_READY" | "PROVIDER_UNAVAILABLE" | "PROVIDER_REJECTED" | "RECONCILIATION_FAILED" | "INTERNAL_ERROR" | "QUOTE_EXPIRED" | "QUOTE_NOT_FOUND" | "INDEXER_DELIVERY_TIMEOUT" | "UNKNOWN";
|
|
21
|
+
declare class CapxulError extends Error {
|
|
22
|
+
readonly code: CapxulErrorCode;
|
|
23
|
+
readonly details?: Record<string, unknown>;
|
|
24
|
+
readonly correlationId?: string;
|
|
25
|
+
readonly layer?: string;
|
|
26
|
+
constructor(code: CapxulErrorCode, message: string, options?: {
|
|
27
|
+
cause?: unknown;
|
|
28
|
+
details?: Record<string, unknown>;
|
|
29
|
+
correlationId?: string;
|
|
30
|
+
layer?: string;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
112
33
|
|
|
113
34
|
/**
|
|
114
35
|
* Provisioning flow errors may originate from two CapxulError surfaces:
|
|
@@ -120,7 +41,7 @@ declare function createAuthFlowMachine(client: CapxulClient): xstate.StateMachin
|
|
|
120
41
|
*
|
|
121
42
|
* Both share `.code`, `.message`, `.details`, and extend `Error`.
|
|
122
43
|
*/
|
|
123
|
-
type ProvisioningFlowError = CapxulError | CapxulError
|
|
44
|
+
type ProvisioningFlowError = CapxulError$1 | CapxulError;
|
|
124
45
|
type ProvisioningFlowContext = {
|
|
125
46
|
readonly input: AccountProvisionPersonalInput | null;
|
|
126
47
|
readonly account: Account | null;
|
|
@@ -197,7 +118,7 @@ declare function createProvisioningMachine(client: CapxulClient): xstate.StateMa
|
|
|
197
118
|
}, {
|
|
198
119
|
type: "hasInput";
|
|
199
120
|
params: unknown;
|
|
200
|
-
}, never, "
|
|
121
|
+
}, never, "done" | "error" | "idle" | "starting" | "running", string, {
|
|
201
122
|
readonly input: AccountProvisionPersonalInput;
|
|
202
123
|
}, {
|
|
203
124
|
readonly account: Account;
|
|
@@ -227,7 +148,7 @@ declare function createProvisioningMachine(client: CapxulClient): xstate.StateMa
|
|
|
227
148
|
*
|
|
228
149
|
* Both share `.code`, `.message`, `.details`, and extend `Error`.
|
|
229
150
|
*/
|
|
230
|
-
type OnboardingFlowError = CapxulError | CapxulError
|
|
151
|
+
type OnboardingFlowError = CapxulError$1 | CapxulError;
|
|
231
152
|
/** Subjects supported by the onboarding flow. */
|
|
232
153
|
type OnboardingSubjectKind = "account" | "organization";
|
|
233
154
|
/**
|
|
@@ -305,7 +226,7 @@ declare function createOnboardingFlowMachine(client: CapxulClient): xstate.State
|
|
|
305
226
|
}, {
|
|
306
227
|
type: "hasInput";
|
|
307
228
|
params: unknown;
|
|
308
|
-
}, never, "
|
|
229
|
+
}, never, "done" | "error" | "idle" | "starting" | "running", string, {
|
|
309
230
|
readonly input: AccountProvisionPersonalInput;
|
|
310
231
|
}, {
|
|
311
232
|
readonly account: Account;
|
|
@@ -347,7 +268,7 @@ declare function createOnboardingFlowMachine(client: CapxulClient): xstate.State
|
|
|
347
268
|
}, {
|
|
348
269
|
type: "hasInput";
|
|
349
270
|
params: unknown;
|
|
350
|
-
}, never, "
|
|
271
|
+
}, never, "done" | "error" | "idle" | "starting" | "running", string, {
|
|
351
272
|
readonly input: AccountProvisionPersonalInput;
|
|
352
273
|
}, {
|
|
353
274
|
readonly account: Account;
|
|
@@ -440,8 +361,8 @@ declare function createOnboardingFlowMachine(client: CapxulClient): xstate.State
|
|
|
440
361
|
* No `default:` arm needed — the compile-time exhaustiveness check is
|
|
441
362
|
* the contract.
|
|
442
363
|
*/
|
|
443
|
-
declare function matchError<Codes extends CapxulErrorCode, R>(err: CapxulError<Codes>, handlers: {
|
|
444
|
-
[K in Codes]: (err: CapxulError<K>) => R;
|
|
364
|
+
declare function matchError<Codes extends CapxulErrorCode$1, R>(err: CapxulError$1<Codes>, handlers: {
|
|
365
|
+
[K in Codes]: (err: CapxulError$1<K>) => R;
|
|
445
366
|
}): R;
|
|
446
367
|
/**
|
|
447
368
|
* Exhaustive resource-status dispatch per CANON.md §4.44.
|
|
@@ -497,4 +418,44 @@ declare function tryCatch<T>(promise: Promise<T>): Promise<[Error, null] | [null
|
|
|
497
418
|
*/
|
|
498
419
|
declare function createLocalSigner(privateKey: `0x${string}`): Account$1;
|
|
499
420
|
|
|
500
|
-
|
|
421
|
+
type SignerProvisionResult = {
|
|
422
|
+
readonly signer: Account$1;
|
|
423
|
+
readonly safeAddress: `0x${string}`;
|
|
424
|
+
};
|
|
425
|
+
/**
|
|
426
|
+
* Headless signer auto-provisioner.
|
|
427
|
+
*
|
|
428
|
+
* Generates a fresh viem private-key account and deterministically derives
|
|
429
|
+
* the corresponding Safe v1.4.1 address.
|
|
430
|
+
*
|
|
431
|
+
* No consumer computes `safeAddress` — it is derived internally and
|
|
432
|
+
* returned alongside the signer so `AuthService.completeBootstrap`
|
|
433
|
+
* can supply it to the backend.
|
|
434
|
+
*
|
|
435
|
+
* **Key persistence note:** Every call to `provision()` mints a fresh
|
|
436
|
+
* private key. The caller MUST persist the returned `signer` (or its
|
|
437
|
+
* private key) if the derived `safeAddress` must be recoverable in
|
|
438
|
+
* future sessions. The bootstrap flow persists the signer via the
|
|
439
|
+
* backend (`signerProvider` row), but direct API consumers are
|
|
440
|
+
* responsible for their own key storage.
|
|
441
|
+
*/
|
|
442
|
+
declare class SignerProvisioner {
|
|
443
|
+
provision(): SignerProvisionResult;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
type PaymentToken = {
|
|
447
|
+
readonly address: `0x${string}`;
|
|
448
|
+
readonly decimals: number;
|
|
449
|
+
readonly symbol: string;
|
|
450
|
+
};
|
|
451
|
+
/**
|
|
452
|
+
* Resolve a currency code to its on-chain payment token metadata.
|
|
453
|
+
*
|
|
454
|
+
* Currently supports USDC only (USD and USDC codes map to the same
|
|
455
|
+
* token). Non-USDC codes return a `NOT_IMPLEMENTED` stub so callers
|
|
456
|
+
* can scaffold multi-currency flows before the registry is fully
|
|
457
|
+
* populated.
|
|
458
|
+
*/
|
|
459
|
+
declare function resolvePaymentToken(currency: string): PaymentToken;
|
|
460
|
+
|
|
461
|
+
export { Account, AccountProvisionPersonalInput, CapxulClient, CapxulError$1 as CapxulError, CapxulErrorCode$1 as CapxulErrorCode, NextAction, type OnboardingFlowContext, type OnboardingFlowError, type OnboardingFlowEvent, type OnboardingProfileInput, type OnboardingSubjectKind, OperationId, type PaymentToken, type ProvisioningFlowContext, type ProvisioningFlowError, type ProvisioningFlowEvent, type ProvisioningFlowInput, type ProvisioningFlowOutput, type SignerProvisionResult, SignerProvisioner, Username, createLocalSigner, createOnboardingFlowMachine, createProvisioningMachine as createProvisioningFlowMachine, matchAction, matchError, matchStatus, resolvePaymentToken, tryCatch };
|