@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.
@@ -1,8 +1,9 @@
1
1
  import { Account as Account$1 } from 'viem';
2
+ import * as xstate from 'xstate';
2
3
  import { AnyStateMachine } from 'xstate';
3
- import { A as AccountId, S as SafeId, c as KycProfileId, b as ExternalAccountId, f as SubAccountId, d as OrganizationId, a as ApiKeyId, X as TimestampIso, D as DocumentId, O as OperationId, P as PaymentId, g as TransferId, k as WithdrawalId, W as WebhookEndpointId, j as WebhookEventId, M as MemberId, K as KybProfileId, V as VirtualAccountId, i as VirtualCardId } from './next-action-DkrwXYay.js';
4
- import { d as CapxulResult, C as CapxulError } from './errors-QHD5Tlok.js';
5
- import { A as Account, U as UserIdentifier, a as AccountLookupResult, S as Safe, i as KycProfile, E as ExternalAccount, L as List, v as SubAccount, B as BalanceLedgerEntry, b as ApiKey, a0 as CreateApiKeyRequest, a1 as CreateDocumentRequest, D as Document, O as Operation, l as OperationStatus, k as Money, C as CreatePaymentResult, o as Payment, F as TransferEndpoint, f as CreateTransferResult, y as Transfer, g as CreateWithdrawalResult, _ as Withdrawal, a2 as CreateWebhookEndpointRequest, Y as WebhookEndpoint, Z as WebhookEvent, n as Organization, J as Treasury, M as Member, K as KybProfile, a3 as CreateVirtualAccountRequest, V as VirtualAccount, a4 as CreateVirtualCardRequest, Q as VirtualCard } from './types-PM4AQRLP.js';
4
+ import { A as AccountId, S as SafeId, c as KycProfileId, b as ExternalAccountId, f as SubAccountId, d as OrganizationId, a as ApiKeyId, X as TimestampIso, U as Username, E as Email, D as DocumentId, O as OperationId, P as PaymentId, g as TransferId, k as WithdrawalId, W as WebhookEndpointId, j as WebhookEventId, M as MemberId, V as VirtualAccountId, i as VirtualCardId } from './next-action-CTGl8wpy.js';
5
+ import { d as CapxulResult, C as CapxulError$1 } from './errors-CwhCWGxm.js';
6
+ import { A as Account, X as UserIdentifier, a as AccountLookupResult, S as Safe, k as KycProfile, E as ExternalAccount, L as List, F as SubAccount, B as BalanceLedgerEntry, b as ApiKey, a5 as CreateApiKeyRequest, a6 as CreateDocumentRequest, D as Document, O as Operation, q as OperationStatus, p as Money, C as CreatePaymentResult, t as Payment, Q as TransferEndpoint, f as CreateTransferResult, J as Transfer, g as CreateWithdrawalResult, a3 as Withdrawal, a7 as CreateWebhookEndpointRequest, a1 as WebhookEndpoint, a2 as WebhookEvent, s as Organization, W as Treasury, o as MembershipStatus, M as Member, n as MemberInviteResponse, a8 as CreateVirtualAccountRequest, Y as VirtualAccount, a9 as CreateVirtualCardRequest, _ as VirtualCard } from './types-V_D7qjxY.js';
6
7
 
7
8
  /**
8
9
  * Accounts domain — individual user accounts per sdk-surface.md §1a.
@@ -21,7 +22,6 @@ type AccountUpdateInput = Partial<{
21
22
  type LocalPrivateKeySignerProvider = {
22
23
  readonly kind: "local-private-key";
23
24
  readonly signerAddress: string;
24
- readonly safeAddress: string;
25
25
  };
26
26
  type AccountProvisionPersonalInput = {
27
27
  readonly displayName?: string;
@@ -39,6 +39,7 @@ type AccountListInput = {
39
39
  type AccountCreateSubAccountInput = {
40
40
  readonly accountId: AccountId;
41
41
  readonly name: string;
42
+ readonly purpose?: string;
42
43
  };
43
44
  type AccountCreateExternalAccountInput = {
44
45
  readonly accountId: AccountId;
@@ -58,6 +59,7 @@ type UpdateCodes$1 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "
58
59
  type ListCodes$b = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "INVALID_INPUT";
59
60
  type SafeRetrieveCodes$1 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "SAFE_NOT_READY";
60
61
  type RemoveCodes$5 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND";
62
+ type SubAccountRemoveCodes$1 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "INVALID_INPUT";
61
63
  type AccountSafesClient = {
62
64
  readonly retrieve: (safeId: SafeId) => Promise<CapxulResult<Safe, SafeRetrieveCodes$1>>;
63
65
  };
@@ -74,12 +76,12 @@ type AccountExternalAccountsClient = {
74
76
  readonly remove: (externalAccountId: ExternalAccountId) => Promise<CapxulResult<void, RemoveCodes$5>>;
75
77
  };
76
78
  type AccountSubAccountsClient = {
77
- readonly create: (input: AccountCreateSubAccountInput) => Promise<CapxulResult<SubAccount, UpdateCodes$1>>;
79
+ readonly create: (input: AccountCreateSubAccountInput) => Promise<CapxulResult<SubAccount, UpdateCodes$1 | "PROVIDER_ERROR">>;
78
80
  readonly list: (input: {
79
81
  readonly accountId: AccountId;
80
- } & AccountListInput) => Promise<CapxulResult<List<SubAccount>, ListCodes$b>>;
81
- readonly retrieve: (subAccountId: SubAccountId) => Promise<CapxulResult<SubAccount, RetrieveCodes$e>>;
82
- readonly remove: (subAccountId: SubAccountId) => Promise<CapxulResult<void, RemoveCodes$5>>;
82
+ } & AccountListInput) => Promise<CapxulResult<List<SubAccount>, ListCodes$b | "PROVIDER_ERROR">>;
83
+ readonly retrieve: (subAccountId: SubAccountId) => Promise<CapxulResult<SubAccount, RetrieveCodes$e | "PROVIDER_ERROR">>;
84
+ readonly remove: (subAccountId: SubAccountId) => Promise<CapxulResult<SubAccount, SubAccountRemoveCodes$1 | "PROVIDER_ERROR">>;
83
85
  };
84
86
  type AccountBalanceLedgerClient = {
85
87
  readonly list: (input: {
@@ -189,6 +191,37 @@ type AuthVerifyOtpInput = {
189
191
  readonly email: string;
190
192
  readonly otp: string;
191
193
  };
194
+ type AuthBootstrapToken = string & {
195
+ readonly __capxulAuthBootstrapTokenBrand: "AuthBootstrapToken";
196
+ };
197
+ type AuthBootstrapReason = "new_member" | "missing_profile" | "missing_account" | "missing_safe" | "missing_signer_grant";
198
+ type VerifyOtpResult = {
199
+ readonly kind: "existing_member";
200
+ readonly session: Session;
201
+ readonly account: Account;
202
+ readonly username: Username;
203
+ readonly safe: Safe;
204
+ } | {
205
+ readonly kind: "bootstrap_required";
206
+ readonly session: Session;
207
+ readonly bootstrapToken: AuthBootstrapToken;
208
+ readonly email: Email;
209
+ readonly reason: AuthBootstrapReason;
210
+ readonly username?: Username;
211
+ };
212
+ type CompleteBootstrapInput = {
213
+ readonly bootstrapToken: AuthBootstrapToken;
214
+ readonly username: Username;
215
+ readonly displayName?: string;
216
+ readonly countryCode?: string;
217
+ };
218
+ type CompleteBootstrapResult = {
219
+ readonly kind: "authenticated";
220
+ readonly session: Session;
221
+ readonly account: Account;
222
+ readonly username: Username;
223
+ readonly safe: Safe;
224
+ };
192
225
  type AuthServiceTokenMintInput = {
193
226
  readonly apiKey: string;
194
227
  readonly audience?: string;
@@ -210,14 +243,16 @@ type ServiceToken = {
210
243
  readonly token: string;
211
244
  readonly expiresAt: TimestampIso;
212
245
  };
213
- type SendOtpCodes = "EMAIL_DELIVERY_FAILED" | "INVALID_INPUT" | "RATE_LIMITED" | "NETWORK_ERROR";
214
- type VerifyOtpCodes = "INVALID_INPUT" | "NOT_AUTHENTICATED" | "RATE_LIMITED" | "NETWORK_ERROR";
246
+ type SendOtpCodes = "EMAIL_DELIVERY_FAILED" | "INVALID_INPUT" | "RATE_LIMITED" | "NETWORK_ERROR" | "PROVIDER_ERROR" | "INTERNAL_ERROR" | "ENV_MISSING" | "UNKNOWN" | "NOT_AUTHENTICATED" | "PERMISSION_DENIED";
247
+ type VerifyOtpCodes = "INVALID_INPUT" | "NOT_AUTHENTICATED" | "RATE_LIMITED" | "OPERATION_TIMEOUT" | "NETWORK_ERROR" | "PROVIDER_ERROR" | "INTERNAL_ERROR" | "ENV_MISSING" | "UNKNOWN" | "PERMISSION_DENIED";
248
+ type CompleteBootstrapCodes = "INVALID_INPUT" | "IDEMPOTENCY_CONFLICT" | "RATE_LIMITED" | "PROFILE_NOT_FOUND" | "SMART_ACCOUNT_MISSING" | "PROVIDER_UNAVAILABLE" | "PROVIDER_REJECTED" | "OPERATION_TIMEOUT" | "NETWORK_ERROR" | "INTERNAL_ERROR";
215
249
  type GetSessionCodes = "NETWORK_ERROR";
216
250
  type SignOutCodes = "NOT_AUTHENTICATED" | "NETWORK_ERROR";
217
251
  type ServiceTokenMintCodes = "API_KEY_INVALID" | "API_KEY_EXPIRED" | "INVALID_INPUT" | "RATE_LIMITED" | "NETWORK_ERROR";
218
252
  type AuthClient = {
219
253
  readonly sendOtp: (input: AuthSendOtpInput, options?: AuthMethodOptions) => Promise<CapxulResult<void, SendOtpCodes>>;
220
- readonly verifyOtp: (input: AuthVerifyOtpInput, options?: AuthMethodOptions) => Promise<CapxulResult<Session, VerifyOtpCodes>>;
254
+ readonly verifyOtp: (input: AuthVerifyOtpInput, options?: AuthMethodOptions) => Promise<CapxulResult<VerifyOtpResult, VerifyOtpCodes>>;
255
+ readonly completeBootstrap: (input: CompleteBootstrapInput) => Promise<CapxulResult<CompleteBootstrapResult, CompleteBootstrapCodes>>;
221
256
  readonly getSession: () => Promise<CapxulResult<Session | null, GetSessionCodes>>;
222
257
  readonly signOut: () => Promise<CapxulResult<void, SignOutCodes>>;
223
258
  readonly serviceTokenMint: (input: AuthServiceTokenMintInput) => Promise<CapxulResult<ServiceToken, ServiceTokenMintCodes>>;
@@ -656,7 +691,7 @@ type WebhookEventsClient = {
656
691
 
657
692
  type OrganizationsCreateInput = {
658
693
  readonly name: string;
659
- readonly country: string;
694
+ readonly country?: string;
660
695
  };
661
696
  type OrganizationsListInput = {
662
697
  readonly limit?: number;
@@ -675,6 +710,9 @@ type OrgMemberInviteInput = {
675
710
  readonly email: string;
676
711
  readonly role: Member["role"];
677
712
  };
713
+ type OrgMemberAcceptInput = {
714
+ readonly token: string;
715
+ };
678
716
  type OrgMemberUpdateRoleInput = {
679
717
  readonly organizationId: OrganizationId;
680
718
  readonly memberId: MemberId;
@@ -685,21 +723,23 @@ type OrgMemberRemoveInput = {
685
723
  readonly memberId: MemberId;
686
724
  };
687
725
  type OrgMemberRetrieveInput = OrgMemberRemoveInput;
726
+ type OrgMemberRevokeInput = OrgMemberRemoveInput;
727
+ type OrgMemberResendInput = OrgMemberRemoveInput;
688
728
  type OrgListInput = {
689
729
  readonly organizationId: OrganizationId;
690
730
  readonly limit?: number;
691
731
  readonly cursor?: string;
692
732
  };
693
- type OrgKybProfileStartInput = {
694
- readonly organizationId: OrganizationId;
695
- };
696
- type OrgKybProfileRetrieveInput = {
733
+ type OrgMemberListInput = {
697
734
  readonly organizationId: OrganizationId;
698
- readonly kybProfileId: KybProfileId;
735
+ readonly status?: MembershipStatus | "all";
736
+ readonly limit?: number;
737
+ readonly cursor?: string;
699
738
  };
700
739
  type OrgCreateSubAccountInput = {
701
740
  readonly organizationId: OrganizationId;
702
741
  readonly name: string;
742
+ readonly purpose?: string;
703
743
  };
704
744
  type OrgCreateExternalAccountInput = {
705
745
  readonly organizationId: OrganizationId;
@@ -731,6 +771,7 @@ type UpdateCodes = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "IN
731
771
  type SafeRetrieveCodes = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND";
732
772
  type TreasuryRetrieveCodes = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "SAFE_NOT_READY";
733
773
  type RemoveCodes$2 = RetrieveCodes$4;
774
+ type SubAccountRemoveCodes = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "INVALID_INPUT";
734
775
  type OrgSafesClient = {
735
776
  readonly retrieve: (input: OrgSafeRetrieveInput) => Promise<CapxulResult<Safe, SafeRetrieveCodes>>;
736
777
  };
@@ -738,27 +779,26 @@ type OrgTreasuryClient = {
738
779
  readonly retrieve: (organizationId: OrganizationId) => Promise<CapxulResult<Treasury, TreasuryRetrieveCodes>>;
739
780
  };
740
781
  type OrgMembersClient = {
741
- readonly list: (input: OrgListInput) => Promise<CapxulResult<List<Member>, ListCodes$3>>;
782
+ readonly list: (input: OrgMemberListInput) => Promise<CapxulResult<List<Member>, ListCodes$3>>;
742
783
  readonly retrieve: (input: OrgMemberRetrieveInput) => Promise<CapxulResult<Member, RetrieveCodes$4>>;
743
- readonly invite: (input: OrgMemberInviteInput) => Promise<CapxulResult<Member, UpdateCodes>>;
784
+ readonly invite: (input: OrgMemberInviteInput) => Promise<CapxulResult<MemberInviteResponse, UpdateCodes>>;
785
+ readonly accept: (input: OrgMemberAcceptInput) => Promise<CapxulResult<Member, UpdateCodes>>;
744
786
  readonly updateRole: (input: OrgMemberUpdateRoleInput) => Promise<CapxulResult<Member, UpdateCodes>>;
787
+ readonly revoke: (input: OrgMemberRevokeInput) => Promise<CapxulResult<Member, UpdateCodes>>;
745
788
  readonly remove: (input: OrgMemberRemoveInput) => Promise<CapxulResult<void, RemoveCodes$2>>;
746
- };
747
- type OrgKybProfileClient = {
748
- readonly start: (input: OrgKybProfileStartInput) => Promise<CapxulResult<KybProfile, CreateCodes$2>>;
749
- readonly retrieve: (input: OrgKybProfileRetrieveInput) => Promise<CapxulResult<KybProfile, RetrieveCodes$4>>;
789
+ readonly resend: (input: OrgMemberResendInput) => Promise<CapxulResult<MemberInviteResponse, UpdateCodes>>;
750
790
  };
751
791
  type OrgSubAccountsClient = {
752
- readonly create: (input: OrgCreateSubAccountInput) => Promise<CapxulResult<SubAccount, UpdateCodes>>;
753
- readonly list: (input: OrgListInput) => Promise<CapxulResult<List<SubAccount>, ListCodes$3>>;
792
+ readonly create: (input: OrgCreateSubAccountInput) => Promise<CapxulResult<SubAccount, UpdateCodes | "PROVIDER_ERROR">>;
793
+ readonly list: (input: OrgListInput) => Promise<CapxulResult<List<SubAccount>, ListCodes$3 | "PROVIDER_ERROR">>;
754
794
  readonly retrieve: (input: {
755
795
  readonly organizationId: OrganizationId;
756
796
  readonly subAccountId: SubAccountId;
757
- }) => Promise<CapxulResult<SubAccount, RetrieveCodes$4>>;
797
+ }) => Promise<CapxulResult<SubAccount, RetrieveCodes$4 | "PROVIDER_ERROR">>;
758
798
  readonly remove: (input: {
759
799
  readonly organizationId: OrganizationId;
760
800
  readonly subAccountId: SubAccountId;
761
- }) => Promise<CapxulResult<void, RemoveCodes$2>>;
801
+ }) => Promise<CapxulResult<SubAccount, SubAccountRemoveCodes | "PROVIDER_ERROR">>;
762
802
  };
763
803
  type OrgExternalAccountsClient = {
764
804
  readonly create: (input: OrgCreateExternalAccountInput) => Promise<CapxulResult<ExternalAccount, UpdateCodes>>;
@@ -789,7 +829,6 @@ type OrganizationsClient = {
789
829
  readonly treasury: OrgTreasuryClient;
790
830
  readonly members: OrgMembersClient;
791
831
  readonly apiKeys: OrgApiKeysClient;
792
- readonly kybProfile: OrgKybProfileClient;
793
832
  readonly subAccounts: OrgSubAccountsClient;
794
833
  readonly externalAccounts: OrgExternalAccountsClient;
795
834
  readonly balanceLedger: OrgBalanceLedgerClient;
@@ -883,7 +922,7 @@ type TransportState = {
883
922
  readonly runtime: TransportRuntime;
884
923
  } | {
885
924
  readonly status: "error";
886
- readonly error: CapxulError;
925
+ readonly error: CapxulError$1;
887
926
  };
888
927
  type TransportRuntime = {
889
928
  readonly authBaseUrl: string;
@@ -942,13 +981,20 @@ declare function makeHttpTransport(config: BrowserCapxulConfig): HttpTransport;
942
981
  * `accounts.subAccounts.create(...)` or
943
982
  * `organizations.subAccounts.create(...)`), so only `retrieve` and
944
983
  * `remove` live at the top level.
984
+ *
985
+ * Wired in PR-2a of the funds-v1 balance-closure stack: the backend
986
+ * always returns truthful `balance: Money` per canon §sub_account
987
+ * (PR-1 made `toCanonShape` populate it from `computeSubAccountBalance`).
988
+ * The SDK brands the wire shape and passes the balance through as-is.
989
+ * NO zero-balance fallback exists at the SDK layer — if the backend
990
+ * ever omits `balance`, that is a bug to surface, not paper over.
945
991
  */
946
992
 
947
- type RetrieveCodes$3 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND";
948
- type RemoveCodes$1 = RetrieveCodes$3;
993
+ type RetrieveCodes$3 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "PROVIDER_ERROR";
994
+ type RemoveCodes$1 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "INVALID_INPUT" | "PROVIDER_ERROR";
949
995
  type SubAccountsClient = {
950
996
  readonly retrieve: (subAccountId: SubAccountId) => Promise<CapxulResult<SubAccount, RetrieveCodes$3>>;
951
- readonly remove: (subAccountId: SubAccountId) => Promise<CapxulResult<void, RemoveCodes$1>>;
997
+ readonly remove: (subAccountId: SubAccountId) => Promise<CapxulResult<SubAccount, RemoveCodes$1>>;
952
998
  };
953
999
 
954
1000
  /**
@@ -1103,6 +1149,152 @@ type VirtualCardsClient = {
1103
1149
  readonly cancel: (virtualCardId: VirtualCardId) => Promise<CapxulResult<VirtualCard, MutateCodes>>;
1104
1150
  };
1105
1151
 
1152
+ /**
1153
+ * Unified error type used across the entire stack: backend, SDK, and frontend.
1154
+ * One class, one set of codes, one language.
1155
+ *
1156
+ * Backend throws CapxulError → withErrorBoundary serializes to ConvexError →
1157
+ * SDK deserializes back to CapxulError → frontend routes on err.code.
1158
+ */
1159
+ 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";
1160
+ declare class CapxulError extends Error {
1161
+ readonly code: CapxulErrorCode;
1162
+ readonly details?: Record<string, unknown>;
1163
+ readonly correlationId?: string;
1164
+ readonly layer?: string;
1165
+ constructor(code: CapxulErrorCode, message: string, options?: {
1166
+ cause?: unknown;
1167
+ details?: Record<string, unknown>;
1168
+ correlationId?: string;
1169
+ layer?: string;
1170
+ });
1171
+ }
1172
+
1173
+ type AuthBootstrapFlowError = CapxulError$1 | CapxulError;
1174
+ type AuthBootstrapFlowContext = {
1175
+ readonly email: Email | null;
1176
+ readonly code: string | null;
1177
+ readonly username: Username | null;
1178
+ readonly bootstrapToken: AuthBootstrapToken | null;
1179
+ readonly bootstrapReason: AuthBootstrapReason | null;
1180
+ readonly session: Session | null;
1181
+ readonly account: Account | null;
1182
+ readonly safe: Safe | null;
1183
+ readonly error: AuthBootstrapFlowError | null;
1184
+ };
1185
+ type AuthBootstrapFlowEvent = {
1186
+ readonly type: "ENTER_EMAIL";
1187
+ readonly email: Email;
1188
+ } | {
1189
+ readonly type: "REQUEST_OTP";
1190
+ } | {
1191
+ readonly type: "ENTER_OTP";
1192
+ readonly code: string;
1193
+ } | {
1194
+ readonly type: "VERIFY_OTP";
1195
+ } | {
1196
+ readonly type: "ENTER_USERNAME";
1197
+ readonly username: Username;
1198
+ } | {
1199
+ readonly type: "COMPLETE_BOOTSTRAP";
1200
+ } | {
1201
+ readonly type: "BACK";
1202
+ } | {
1203
+ readonly type: "RESET";
1204
+ } | {
1205
+ readonly type: "SIGN_OUT";
1206
+ };
1207
+ declare function createAuthBootstrapFlowMachine(client: CapxulClient): xstate.StateMachine<AuthBootstrapFlowContext, {
1208
+ readonly type: "ENTER_EMAIL";
1209
+ readonly email: Email;
1210
+ } | {
1211
+ readonly type: "REQUEST_OTP";
1212
+ } | {
1213
+ readonly type: "ENTER_OTP";
1214
+ readonly code: string;
1215
+ } | {
1216
+ readonly type: "VERIFY_OTP";
1217
+ } | {
1218
+ readonly type: "ENTER_USERNAME";
1219
+ readonly username: Username;
1220
+ } | {
1221
+ readonly type: "COMPLETE_BOOTSTRAP";
1222
+ } | {
1223
+ readonly type: "BACK";
1224
+ } | {
1225
+ readonly type: "RESET";
1226
+ } | {
1227
+ readonly type: "SIGN_OUT";
1228
+ }, {
1229
+ [x: string]: xstate.ActorRefFromLogic<xstate.PromiseActorLogic<void, void, xstate.EventObject>> | xstate.ActorRefFromLogic<xstate.PromiseActorLogic<void, {
1230
+ email: Email;
1231
+ }, xstate.EventObject>> | xstate.ActorRefFromLogic<xstate.PromiseActorLogic<VerifyOtpResult, {
1232
+ email: Email;
1233
+ code: string;
1234
+ }, xstate.EventObject>> | xstate.ActorRefFromLogic<xstate.PromiseActorLogic<CompleteBootstrapResult, {
1235
+ bootstrapToken: AuthBootstrapToken;
1236
+ username: Username;
1237
+ }, xstate.EventObject>> | undefined;
1238
+ }, {
1239
+ src: "sendOtp";
1240
+ logic: xstate.PromiseActorLogic<void, {
1241
+ email: Email;
1242
+ }, xstate.EventObject>;
1243
+ id: string | undefined;
1244
+ } | {
1245
+ src: "verifyOtp";
1246
+ logic: xstate.PromiseActorLogic<VerifyOtpResult, {
1247
+ email: Email;
1248
+ code: string;
1249
+ }, xstate.EventObject>;
1250
+ id: string | undefined;
1251
+ } | {
1252
+ src: "signOut";
1253
+ logic: xstate.PromiseActorLogic<void, void, xstate.EventObject>;
1254
+ id: string | undefined;
1255
+ } | {
1256
+ src: "completeBootstrap";
1257
+ logic: xstate.PromiseActorLogic<CompleteBootstrapResult, {
1258
+ bootstrapToken: AuthBootstrapToken;
1259
+ username: Username;
1260
+ }, xstate.EventObject>;
1261
+ id: string | undefined;
1262
+ }, {
1263
+ type: "trackOtpRequested";
1264
+ params: unknown;
1265
+ } | {
1266
+ type: "trackTimeoutFailed";
1267
+ params: unknown;
1268
+ } | {
1269
+ type: "trackVerified";
1270
+ params: unknown;
1271
+ } | {
1272
+ type: "identifyAndTrack";
1273
+ params: unknown;
1274
+ } | {
1275
+ type: "trackSignedOut";
1276
+ params: unknown;
1277
+ } | {
1278
+ type: "trackFailed";
1279
+ params: unknown;
1280
+ } | {
1281
+ type: "trackBootstrapRequired";
1282
+ params: unknown;
1283
+ }, never, never, "email" | "authenticated" | "error" | "bootstrap_required" | "sending_otp" | "otp_requested" | "signing_out" | "verifying_otp" | "completing_bootstrap", string, xstate.NonReducibleUnknown, xstate.NonReducibleUnknown, xstate.EventObject, xstate.MetaObject, {
1284
+ id: "authBootstrap";
1285
+ states: {
1286
+ readonly email: {};
1287
+ readonly sending_otp: {};
1288
+ readonly otp_requested: {};
1289
+ readonly verifying_otp: {};
1290
+ readonly bootstrap_required: {};
1291
+ readonly completing_bootstrap: {};
1292
+ readonly authenticated: {};
1293
+ readonly signing_out: {};
1294
+ readonly error: {};
1295
+ };
1296
+ }>;
1297
+
1106
1298
  /**
1107
1299
  * Root `@capxul/sdk` client factory.
1108
1300
  *
@@ -1150,11 +1342,6 @@ type CapxulAuthConfig = {
1150
1342
  readonly convexTokenUrl?: string;
1151
1343
  /** Scenario/browser-local session store shared by auth + onboarding hooks. */
1152
1344
  readonly sessionStore?: AuthSessionStore;
1153
- /**
1154
- * Optional bridge for environments that can build an authenticated data
1155
- * client after BetterAuth returns a session.
1156
- */
1157
- readonly createDataClient?: (session: Session) => Promise<CapxulDataClient>;
1158
1345
  };
1159
1346
  type CapxulConfig = {
1160
1347
  /** Server-to-server partner key. Mutually exclusive with `publishableKey`. */
@@ -1170,12 +1357,13 @@ type CapxulConfig = {
1170
1357
  */
1171
1358
  readonly signer?: Account$1;
1172
1359
  /**
1173
- * Inject an authenticated Convex data client.
1360
+ * @internal
1174
1361
  *
1175
- * Slice F.2 uses this for the restart payment + operation runtime
1176
- * path while the `/v1/*` service-token bridge remains unfinished.
1362
+ * Test-only override seam for injecting an authenticated Convex data client.
1363
+ * The SDK now owns runtime construction of the data client; this field is
1364
+ * reserved for tests and the React provider's singleton lifecycle.
1177
1365
  */
1178
- readonly data?: CapxulDataClient;
1366
+ readonly _data?: CapxulDataClient;
1179
1367
  /**
1180
1368
  * Chain + bundler configuration for on-chain submission.
1181
1369
  *
@@ -1230,6 +1418,7 @@ type CapxulConfig = {
1230
1418
  */
1231
1419
  type CapxulFlowFactories = {
1232
1420
  readonly auth: () => AnyStateMachine;
1421
+ readonly authBootstrap: () => ReturnType<typeof createAuthBootstrapFlowMachine>;
1233
1422
  readonly onboarding: () => AnyStateMachine;
1234
1423
  readonly provisioning: () => AnyStateMachine;
1235
1424
  };
@@ -1292,4 +1481,4 @@ type CapxulClient = {
1292
1481
  */
1293
1482
  declare function createCapxulClient(config?: CapxulConfig): CapxulClient;
1294
1483
 
1295
- export { type AccountProvisionPersonalInput as A, type BrowserCapxulConfig as B, type CapxulClient as C, type DocumentsClient as D, type ExternalAccountsClient as E, type VirtualCardsClient as F, type WebhookEndpointsClient as G, type HttpTransport as H, type WebhookEventsClient as I, type WithdrawalsClient as J, createCapxulClient as K, type LocalPrivateKeySignerProvider as L, type MeClient as M, makeHttpTransport as N, type OperationsClient as O, type PaymentsClient as P, toTokenTransferId as Q, type Session as S, type TokenTransfer as T, type VirtualAccountsClient as V, type WebhookEndpointCreateResult as W, type AccountsClient as a, type ApiKeyCreateResult as b, type ApiKeysClient as c, type AuthClient as d, type AuthSessionStore as e, type CapxulAuthConfig as f, type CapxulConfig as g, type CapxulDataClient as h, type CapxulFlowFactories as i, type CapxulSigningConfig as j, type OrgDocumentsClient as k, type OrgPaymentsClient as l, type OrgSafesClient as m, type OrgTransfersClient as n, type OrgTreasuryClient as o, type OrgWithdrawalsClient as p, type OrganizationsClient as q, type SubAccountsClient as r, type TokenTransferId as s, type TokenTransfersClient as t, type TokenTransfersListInput as u, type TokenTransfersListPage as v, type TokenTransfersRetrieveInput as w, type TransfersClient as x, type TransportRuntime as y, type TransportState as z };
1484
+ export { type WithdrawalsClient as $, type AccountProvisionPersonalInput as A, type BrowserCapxulConfig as B, CapxulError as C, type DocumentsClient as D, type ExternalAccountsClient as E, type SubAccountsClient as F, type TokenTransferId as G, type HttpTransport as H, type TokenTransfersClient as I, type TokenTransfersListInput as J, type TokenTransfersListPage as K, type LocalPrivateKeySignerProvider as L, type MeClient as M, type TokenTransfersRetrieveInput as N, type OperationsClient as O, type PaymentsClient as P, type TransfersClient as Q, type TransportRuntime as R, type Session as S, type TokenTransfer as T, type TransportState as U, type VerifyOtpResult as V, type VirtualAccountsClient as W, type VirtualCardsClient as X, type WebhookEndpointCreateResult as Y, type WebhookEndpointsClient as Z, type WebhookEventsClient as _, type CapxulClient as a, createAuthBootstrapFlowMachine as a0, createCapxulClient as a1, makeHttpTransport as a2, toTokenTransferId as a3, type CapxulConfig as b, type CompleteBootstrapInput as c, type CompleteBootstrapResult as d, type AccountsClient as e, type ApiKeyCreateResult as f, type ApiKeysClient as g, type AuthBootstrapFlowContext as h, type AuthBootstrapFlowError as i, type AuthBootstrapFlowEvent as j, type AuthBootstrapReason as k, type AuthBootstrapToken as l, type AuthClient as m, type AuthSessionStore as n, type CapxulAuthConfig as o, type CapxulDataClient as p, type CapxulFlowFactories as q, type CapxulSigningConfig as r, type OrgDocumentsClient as s, type OrgMembersClient as t, type OrgPaymentsClient as u, type OrgSafesClient as v, type OrgTransfersClient as w, type OrgTreasuryClient as x, type OrgWithdrawalsClient as y, type OrganizationsClient as z };