@capxul/sdk 0.1.0-alpha.8 → 0.2.0-alpha.3
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 +122 -0
- package/README.md +45 -0
- package/dist/{client-DDAVWtzJ.d.cts → client-B_Z3ThFO.d.cts} +231 -42
- package/dist/{client-ByzDfG98.d.ts → client-pMBRFcsz.d.ts} +231 -42
- package/dist/client.cjs +1678 -406
- package/dist/client.d.cts +4 -4
- package/dist/client.d.ts +4 -4
- package/dist/client.js +1678 -406
- 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 +1735 -394
- package/dist/index.d.cts +90 -40
- package/dist/index.d.ts +90 -40
- package/dist/index.js +1733 -396
- 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-hfcOE7Oi.d.cts → types-Brucpq0Z.d.cts} +63 -8
- package/dist/{types-PM4AQRLP.d.ts → types-V_D7qjxY.d.ts} +63 -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 +7 -5
package/dist/index.d.cts
CHANGED
|
@@ -1,36 +1,15 @@
|
|
|
1
|
-
import { S as Session, C as CapxulClient, A as AccountProvisionPersonalInput } from './client-
|
|
2
|
-
export {
|
|
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-B_Z3ThFO.cjs';
|
|
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-B_Z3ThFO.cjs';
|
|
3
3
|
import * as xstate from 'xstate';
|
|
4
|
-
import { E as Email, U as Username, O as OperationId, N as NextAction } from './next-action-
|
|
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-
|
|
6
|
-
import { C as CapxulError
|
|
7
|
-
export { b as CapxulErrorDetails, c as CapxulErrorEnvelope, d as CapxulResult } from './errors-
|
|
8
|
-
import { A as Account } from './types-
|
|
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 InvoiceDocument, K as KybProfile,
|
|
4
|
+
import { E as Email, U as Username, O as OperationId, N as NextAction } from './next-action-CTGl8wpy.cjs';
|
|
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.cjs';
|
|
6
|
+
import { C as CapxulError, a as CapxulErrorCode } from './errors-rqxuUhQP.cjs';
|
|
7
|
+
export { b as CapxulErrorDetails, c as CapxulErrorEnvelope, d as CapxulResult } from './errors-rqxuUhQP.cjs';
|
|
8
|
+
import { A as Account } from './types-Brucpq0Z.cjs';
|
|
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-Brucpq0Z.cjs';
|
|
10
10
|
import { Account as Account$1 } from 'viem';
|
|
11
11
|
export { WebhookVerificationOptions, WebhookVerificationResult, verifyWebhook } from './webhooks.cjs';
|
|
12
12
|
|
|
13
|
-
/**
|
|
14
|
-
* Unified error type used across the entire stack: backend, SDK, and frontend.
|
|
15
|
-
* One class, one set of codes, one language.
|
|
16
|
-
*
|
|
17
|
-
* Backend throws CapxulError → withErrorBoundary serializes to ConvexError →
|
|
18
|
-
* SDK deserializes back to CapxulError → frontend routes on err.code.
|
|
19
|
-
*/
|
|
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" | "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
|
-
}
|
|
33
|
-
|
|
34
13
|
/**
|
|
35
14
|
* Auth flow errors may originate from two CapxulError surfaces:
|
|
36
15
|
* - the SDK-local generic `CapxulError<Codes>` returned by
|
|
@@ -42,7 +21,7 @@ declare class CapxulError extends Error {
|
|
|
42
21
|
* union keeps either origin assignable to `context.error` without an
|
|
43
22
|
* `as` cast at the call site.
|
|
44
23
|
*/
|
|
45
|
-
type AuthFlowError = CapxulError
|
|
24
|
+
type AuthFlowError = CapxulError | CapxulError$1;
|
|
46
25
|
type AuthFlowContext = {
|
|
47
26
|
readonly email: Email | null;
|
|
48
27
|
readonly session: Session | null;
|
|
@@ -118,7 +97,7 @@ declare function createAuthFlowMachine(client: CapxulClient): xstate.StateMachin
|
|
|
118
97
|
} | {
|
|
119
98
|
type: "trackSignedOut";
|
|
120
99
|
params: unknown;
|
|
121
|
-
}, never, never, "
|
|
100
|
+
}, never, never, "idle" | "authenticated" | "error" | "sending_otp" | "otp_requested" | "verifying" | "signing_out", string, xstate.NonReducibleUnknown, xstate.NonReducibleUnknown, xstate.EventObject, xstate.MetaObject, {
|
|
122
101
|
id: "auth";
|
|
123
102
|
states: {
|
|
124
103
|
readonly idle: {};
|
|
@@ -141,7 +120,7 @@ declare function createAuthFlowMachine(client: CapxulClient): xstate.StateMachin
|
|
|
141
120
|
*
|
|
142
121
|
* Both share `.code`, `.message`, `.details`, and extend `Error`.
|
|
143
122
|
*/
|
|
144
|
-
type ProvisioningFlowError = CapxulError
|
|
123
|
+
type ProvisioningFlowError = CapxulError | CapxulError$1;
|
|
145
124
|
type ProvisioningFlowContext = {
|
|
146
125
|
readonly input: AccountProvisionPersonalInput | null;
|
|
147
126
|
readonly account: Account | null;
|
|
@@ -218,7 +197,7 @@ declare function createProvisioningMachine(client: CapxulClient): xstate.StateMa
|
|
|
218
197
|
}, {
|
|
219
198
|
type: "hasInput";
|
|
220
199
|
params: unknown;
|
|
221
|
-
}, never, "
|
|
200
|
+
}, never, "idle" | "error" | "done" | "starting" | "running", string, {
|
|
222
201
|
readonly input: AccountProvisionPersonalInput;
|
|
223
202
|
}, {
|
|
224
203
|
readonly account: Account;
|
|
@@ -248,7 +227,7 @@ declare function createProvisioningMachine(client: CapxulClient): xstate.StateMa
|
|
|
248
227
|
*
|
|
249
228
|
* Both share `.code`, `.message`, `.details`, and extend `Error`.
|
|
250
229
|
*/
|
|
251
|
-
type OnboardingFlowError = CapxulError
|
|
230
|
+
type OnboardingFlowError = CapxulError | CapxulError$1;
|
|
252
231
|
/** Subjects supported by the onboarding flow. */
|
|
253
232
|
type OnboardingSubjectKind = "account" | "organization";
|
|
254
233
|
/**
|
|
@@ -326,7 +305,7 @@ declare function createOnboardingFlowMachine(client: CapxulClient): xstate.State
|
|
|
326
305
|
}, {
|
|
327
306
|
type: "hasInput";
|
|
328
307
|
params: unknown;
|
|
329
|
-
}, never, "
|
|
308
|
+
}, never, "idle" | "error" | "done" | "starting" | "running", string, {
|
|
330
309
|
readonly input: AccountProvisionPersonalInput;
|
|
331
310
|
}, {
|
|
332
311
|
readonly account: Account;
|
|
@@ -368,7 +347,7 @@ declare function createOnboardingFlowMachine(client: CapxulClient): xstate.State
|
|
|
368
347
|
}, {
|
|
369
348
|
type: "hasInput";
|
|
370
349
|
params: unknown;
|
|
371
|
-
}, never, "
|
|
350
|
+
}, never, "idle" | "error" | "done" | "starting" | "running", string, {
|
|
372
351
|
readonly input: AccountProvisionPersonalInput;
|
|
373
352
|
}, {
|
|
374
353
|
readonly account: Account;
|
|
@@ -438,7 +417,7 @@ declare function createOnboardingFlowMachine(client: CapxulClient): xstate.State
|
|
|
438
417
|
} | {
|
|
439
418
|
type: "childReportedError";
|
|
440
419
|
params: unknown;
|
|
441
|
-
}, never, "
|
|
420
|
+
}, never, "action_required" | "provisioning" | "error" | "profile" | "complete", string, xstate.NonReducibleUnknown, xstate.NonReducibleUnknown, xstate.EventObject, xstate.MetaObject, {
|
|
442
421
|
id: "onboarding";
|
|
443
422
|
states: {
|
|
444
423
|
readonly profile: {};
|
|
@@ -461,8 +440,8 @@ declare function createOnboardingFlowMachine(client: CapxulClient): xstate.State
|
|
|
461
440
|
* No `default:` arm needed — the compile-time exhaustiveness check is
|
|
462
441
|
* the contract.
|
|
463
442
|
*/
|
|
464
|
-
declare function matchError<Codes extends CapxulErrorCode
|
|
465
|
-
[K in Codes]: (err: CapxulError
|
|
443
|
+
declare function matchError<Codes extends CapxulErrorCode, R>(err: CapxulError<Codes>, handlers: {
|
|
444
|
+
[K in Codes]: (err: CapxulError<K>) => R;
|
|
466
445
|
}): R;
|
|
467
446
|
/**
|
|
468
447
|
* Exhaustive resource-status dispatch per CANON.md §4.44.
|
|
@@ -518,4 +497,75 @@ declare function tryCatch<T>(promise: Promise<T>): Promise<[Error, null] | [null
|
|
|
518
497
|
*/
|
|
519
498
|
declare function createLocalSigner(privateKey: `0x${string}`): Account$1;
|
|
520
499
|
|
|
521
|
-
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,36 +1,15 @@
|
|
|
1
|
-
import { S as Session, C as CapxulClient, A as AccountProvisionPersonalInput } from './client-
|
|
2
|
-
export {
|
|
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
3
|
import * as xstate from 'xstate';
|
|
4
|
-
import { E as Email, U as Username, O as OperationId, N as NextAction } from './next-action-
|
|
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-
|
|
6
|
-
import { C as CapxulError
|
|
7
|
-
export { b as CapxulErrorDetails, c as CapxulErrorEnvelope, d as CapxulResult } from './errors-
|
|
8
|
-
import { A as Account } from './types-
|
|
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 InvoiceDocument, K as KybProfile,
|
|
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
10
|
import { Account as Account$1 } from 'viem';
|
|
11
11
|
export { WebhookVerificationOptions, WebhookVerificationResult, verifyWebhook } from './webhooks.js';
|
|
12
12
|
|
|
13
|
-
/**
|
|
14
|
-
* Unified error type used across the entire stack: backend, SDK, and frontend.
|
|
15
|
-
* One class, one set of codes, one language.
|
|
16
|
-
*
|
|
17
|
-
* Backend throws CapxulError → withErrorBoundary serializes to ConvexError →
|
|
18
|
-
* SDK deserializes back to CapxulError → frontend routes on err.code.
|
|
19
|
-
*/
|
|
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" | "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
|
-
}
|
|
33
|
-
|
|
34
13
|
/**
|
|
35
14
|
* Auth flow errors may originate from two CapxulError surfaces:
|
|
36
15
|
* - the SDK-local generic `CapxulError<Codes>` returned by
|
|
@@ -42,7 +21,7 @@ declare class CapxulError extends Error {
|
|
|
42
21
|
* union keeps either origin assignable to `context.error` without an
|
|
43
22
|
* `as` cast at the call site.
|
|
44
23
|
*/
|
|
45
|
-
type AuthFlowError = CapxulError
|
|
24
|
+
type AuthFlowError = CapxulError | CapxulError$1;
|
|
46
25
|
type AuthFlowContext = {
|
|
47
26
|
readonly email: Email | null;
|
|
48
27
|
readonly session: Session | null;
|
|
@@ -118,7 +97,7 @@ declare function createAuthFlowMachine(client: CapxulClient): xstate.StateMachin
|
|
|
118
97
|
} | {
|
|
119
98
|
type: "trackSignedOut";
|
|
120
99
|
params: unknown;
|
|
121
|
-
}, never, never, "
|
|
100
|
+
}, never, never, "idle" | "authenticated" | "error" | "sending_otp" | "otp_requested" | "verifying" | "signing_out", string, xstate.NonReducibleUnknown, xstate.NonReducibleUnknown, xstate.EventObject, xstate.MetaObject, {
|
|
122
101
|
id: "auth";
|
|
123
102
|
states: {
|
|
124
103
|
readonly idle: {};
|
|
@@ -141,7 +120,7 @@ declare function createAuthFlowMachine(client: CapxulClient): xstate.StateMachin
|
|
|
141
120
|
*
|
|
142
121
|
* Both share `.code`, `.message`, `.details`, and extend `Error`.
|
|
143
122
|
*/
|
|
144
|
-
type ProvisioningFlowError = CapxulError
|
|
123
|
+
type ProvisioningFlowError = CapxulError | CapxulError$1;
|
|
145
124
|
type ProvisioningFlowContext = {
|
|
146
125
|
readonly input: AccountProvisionPersonalInput | null;
|
|
147
126
|
readonly account: Account | null;
|
|
@@ -218,7 +197,7 @@ declare function createProvisioningMachine(client: CapxulClient): xstate.StateMa
|
|
|
218
197
|
}, {
|
|
219
198
|
type: "hasInput";
|
|
220
199
|
params: unknown;
|
|
221
|
-
}, never, "
|
|
200
|
+
}, never, "idle" | "error" | "done" | "starting" | "running", string, {
|
|
222
201
|
readonly input: AccountProvisionPersonalInput;
|
|
223
202
|
}, {
|
|
224
203
|
readonly account: Account;
|
|
@@ -248,7 +227,7 @@ declare function createProvisioningMachine(client: CapxulClient): xstate.StateMa
|
|
|
248
227
|
*
|
|
249
228
|
* Both share `.code`, `.message`, `.details`, and extend `Error`.
|
|
250
229
|
*/
|
|
251
|
-
type OnboardingFlowError = CapxulError
|
|
230
|
+
type OnboardingFlowError = CapxulError | CapxulError$1;
|
|
252
231
|
/** Subjects supported by the onboarding flow. */
|
|
253
232
|
type OnboardingSubjectKind = "account" | "organization";
|
|
254
233
|
/**
|
|
@@ -326,7 +305,7 @@ declare function createOnboardingFlowMachine(client: CapxulClient): xstate.State
|
|
|
326
305
|
}, {
|
|
327
306
|
type: "hasInput";
|
|
328
307
|
params: unknown;
|
|
329
|
-
}, never, "
|
|
308
|
+
}, never, "idle" | "error" | "done" | "starting" | "running", string, {
|
|
330
309
|
readonly input: AccountProvisionPersonalInput;
|
|
331
310
|
}, {
|
|
332
311
|
readonly account: Account;
|
|
@@ -368,7 +347,7 @@ declare function createOnboardingFlowMachine(client: CapxulClient): xstate.State
|
|
|
368
347
|
}, {
|
|
369
348
|
type: "hasInput";
|
|
370
349
|
params: unknown;
|
|
371
|
-
}, never, "
|
|
350
|
+
}, never, "idle" | "error" | "done" | "starting" | "running", string, {
|
|
372
351
|
readonly input: AccountProvisionPersonalInput;
|
|
373
352
|
}, {
|
|
374
353
|
readonly account: Account;
|
|
@@ -438,7 +417,7 @@ declare function createOnboardingFlowMachine(client: CapxulClient): xstate.State
|
|
|
438
417
|
} | {
|
|
439
418
|
type: "childReportedError";
|
|
440
419
|
params: unknown;
|
|
441
|
-
}, never, "
|
|
420
|
+
}, never, "action_required" | "provisioning" | "error" | "profile" | "complete", string, xstate.NonReducibleUnknown, xstate.NonReducibleUnknown, xstate.EventObject, xstate.MetaObject, {
|
|
442
421
|
id: "onboarding";
|
|
443
422
|
states: {
|
|
444
423
|
readonly profile: {};
|
|
@@ -461,8 +440,8 @@ declare function createOnboardingFlowMachine(client: CapxulClient): xstate.State
|
|
|
461
440
|
* No `default:` arm needed — the compile-time exhaustiveness check is
|
|
462
441
|
* the contract.
|
|
463
442
|
*/
|
|
464
|
-
declare function matchError<Codes extends CapxulErrorCode
|
|
465
|
-
[K in Codes]: (err: CapxulError
|
|
443
|
+
declare function matchError<Codes extends CapxulErrorCode, R>(err: CapxulError<Codes>, handlers: {
|
|
444
|
+
[K in Codes]: (err: CapxulError<K>) => R;
|
|
466
445
|
}): R;
|
|
467
446
|
/**
|
|
468
447
|
* Exhaustive resource-status dispatch per CANON.md §4.44.
|
|
@@ -518,4 +497,75 @@ declare function tryCatch<T>(promise: Promise<T>): Promise<[Error, null] | [null
|
|
|
518
497
|
*/
|
|
519
498
|
declare function createLocalSigner(privateKey: `0x${string}`): Account$1;
|
|
520
499
|
|
|
521
|
-
|
|
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 };
|