@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.
@@ -1,9 +1,8 @@
1
1
  import { Account as Account$1 } from 'viem';
2
- import * as xstate from 'xstate';
3
2
  import { AnyStateMachine } from 'xstate';
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, K as KybProfileId, V as VirtualAccountId, i as VirtualCardId } from './next-action-DkrwXYay.js';
5
- import { d as CapxulResult, C as CapxulError$1 } from './errors-QHD5Tlok.js';
6
- 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';
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, 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';
4
+ import { d as CapxulResult, C as CapxulError } from './errors-CwhCWGxm.js';
5
+ 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-BD4VAQb5.js';
7
6
 
8
7
  /**
9
8
  * Accounts domain — individual user accounts per sdk-surface.md §1a.
@@ -22,7 +21,6 @@ type AccountUpdateInput = Partial<{
22
21
  type LocalPrivateKeySignerProvider = {
23
22
  readonly kind: "local-private-key";
24
23
  readonly signerAddress: string;
25
- readonly safeAddress: string;
26
24
  };
27
25
  type AccountProvisionPersonalInput = {
28
26
  readonly displayName?: string;
@@ -40,6 +38,7 @@ type AccountListInput = {
40
38
  type AccountCreateSubAccountInput = {
41
39
  readonly accountId: AccountId;
42
40
  readonly name: string;
41
+ readonly purpose?: string;
43
42
  };
44
43
  type AccountCreateExternalAccountInput = {
45
44
  readonly accountId: AccountId;
@@ -59,6 +58,7 @@ type UpdateCodes$1 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "
59
58
  type ListCodes$b = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "INVALID_INPUT";
60
59
  type SafeRetrieveCodes$1 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "SAFE_NOT_READY";
61
60
  type RemoveCodes$5 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND";
61
+ type SubAccountRemoveCodes$1 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "INVALID_INPUT";
62
62
  type AccountSafesClient = {
63
63
  readonly retrieve: (safeId: SafeId) => Promise<CapxulResult<Safe, SafeRetrieveCodes$1>>;
64
64
  };
@@ -75,12 +75,12 @@ type AccountExternalAccountsClient = {
75
75
  readonly remove: (externalAccountId: ExternalAccountId) => Promise<CapxulResult<void, RemoveCodes$5>>;
76
76
  };
77
77
  type AccountSubAccountsClient = {
78
- readonly create: (input: AccountCreateSubAccountInput) => Promise<CapxulResult<SubAccount, UpdateCodes$1>>;
78
+ readonly create: (input: AccountCreateSubAccountInput) => Promise<CapxulResult<SubAccount, UpdateCodes$1 | "PROVIDER_ERROR">>;
79
79
  readonly list: (input: {
80
80
  readonly accountId: AccountId;
81
- } & AccountListInput) => Promise<CapxulResult<List<SubAccount>, ListCodes$b>>;
82
- readonly retrieve: (subAccountId: SubAccountId) => Promise<CapxulResult<SubAccount, RetrieveCodes$e>>;
83
- readonly remove: (subAccountId: SubAccountId) => Promise<CapxulResult<void, RemoveCodes$5>>;
81
+ } & AccountListInput) => Promise<CapxulResult<List<SubAccount>, ListCodes$b | "PROVIDER_ERROR">>;
82
+ readonly retrieve: (subAccountId: SubAccountId) => Promise<CapxulResult<SubAccount, RetrieveCodes$e | "PROVIDER_ERROR">>;
83
+ readonly remove: (subAccountId: SubAccountId) => Promise<CapxulResult<SubAccount, SubAccountRemoveCodes$1 | "PROVIDER_ERROR">>;
84
84
  };
85
85
  type AccountBalanceLedgerClient = {
86
86
  readonly list: (input: {
@@ -183,13 +183,6 @@ type AuthSessionStore = {
183
183
  set(session: Session): void;
184
184
  clear(): void;
185
185
  };
186
- type AuthSendOtpInput = {
187
- readonly email: string;
188
- };
189
- type AuthVerifyOtpInput = {
190
- readonly email: string;
191
- readonly otp: string;
192
- };
193
186
  type AuthBootstrapToken = string & {
194
187
  readonly __capxulAuthBootstrapTokenBrand: "AuthBootstrapToken";
195
188
  };
@@ -211,7 +204,6 @@ type VerifyOtpResult = {
211
204
  type CompleteBootstrapInput = {
212
205
  readonly bootstrapToken: AuthBootstrapToken;
213
206
  readonly username: Username;
214
- readonly signerProvider: LocalPrivateKeySignerProvider;
215
207
  readonly displayName?: string;
216
208
  readonly countryCode?: string;
217
209
  };
@@ -222,10 +214,6 @@ type CompleteBootstrapResult = {
222
214
  readonly username: Username;
223
215
  readonly safe: Safe;
224
216
  };
225
- type AuthServiceTokenMintInput = {
226
- readonly apiKey: string;
227
- readonly audience?: string;
228
- };
229
217
  /**
230
218
  * Options bag for auth methods that perform outbound `fetch` work.
231
219
  *
@@ -239,26 +227,37 @@ type AuthServiceTokenMintInput = {
239
227
  type AuthMethodOptions = {
240
228
  readonly signal?: AbortSignal;
241
229
  };
242
- type ServiceToken = {
243
- readonly token: string;
244
- readonly expiresAt: TimestampIso;
245
- };
246
- type SendOtpCodes = "EMAIL_DELIVERY_FAILED" | "INVALID_INPUT" | "RATE_LIMITED" | "NETWORK_ERROR";
247
- type VerifyOtpCodes = "INVALID_INPUT" | "NOT_AUTHENTICATED" | "RATE_LIMITED" | "OPERATION_TIMEOUT" | "NETWORK_ERROR";
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";
249
- type GetSessionCodes = "NETWORK_ERROR";
250
- type SignOutCodes = "NOT_AUTHENTICATED" | "NETWORK_ERROR";
251
- type ServiceTokenMintCodes = "API_KEY_INVALID" | "API_KEY_EXPIRED" | "INVALID_INPUT" | "RATE_LIMITED" | "NETWORK_ERROR";
252
- type AuthClient = {
253
- readonly sendOtp: (input: AuthSendOtpInput, options?: AuthMethodOptions) => Promise<CapxulResult<void, SendOtpCodes>>;
254
- readonly verifyOtp: (input: AuthVerifyOtpInput, options?: AuthMethodOptions) => Promise<CapxulResult<VerifyOtpResult, VerifyOtpCodes>>;
255
- readonly completeBootstrap: (input: CompleteBootstrapInput) => Promise<CapxulResult<CompleteBootstrapResult, CompleteBootstrapCodes>>;
256
- readonly getSession: () => Promise<CapxulResult<Session | null, GetSessionCodes>>;
257
- readonly signOut: () => Promise<CapxulResult<void, SignOutCodes>>;
258
- readonly serviceTokenMint: (input: AuthServiceTokenMintInput) => Promise<CapxulResult<ServiceToken, ServiceTokenMintCodes>>;
259
- /** Internal bridge for flow hooks that need the authenticated Convex data client. */
260
- readonly getDataClient: () => CapxulDataClient | null;
261
- };
230
+
231
+ /**
232
+ * AuthService — unified promise-based auth surface.
233
+ *
234
+ * Wraps the imperative `AuthClient` tuple API with a class-based,
235
+ * promise-based interface. `signOut` preserves the data-client
236
+ * reference so provider-owned singletons survive sign-in/sign-out
237
+ * cycles.
238
+ */
239
+
240
+ declare class AuthService {
241
+ private authClient;
242
+ private sessionStore;
243
+ private config;
244
+ constructor(config?: CapxulConfig);
245
+ sendOtp(email: string, options?: AuthMethodOptions): Promise<void>;
246
+ verifyOtp(email: string, otp: string, options?: AuthMethodOptions): Promise<VerifyOtpResult>;
247
+ completeBootstrap(params: CompleteBootstrapInput, signer?: Account$1): Promise<CompleteBootstrapResult>;
248
+ /**
249
+ * Clears the persisted session and, when a transport was pre-injected,
250
+ * drops the cached auth header.
251
+ *
252
+ * **Transport safety note:** `clearAuth()` is only invoked when
253
+ * `config._transport` was supplied at construction (e.g. by the React
254
+ * provider). If `AuthService` is instantiated directly in a Node/CLI
255
+ * context without an injected transport, the transport-side auth cache
256
+ * is the caller's responsibility.
257
+ */
258
+ signOut(): Promise<void>;
259
+ getSession(): Promise<Session | null>;
260
+ }
262
261
 
263
262
  /**
264
263
  * Documents domain — unified artifact primitive per sdk-surface.md §1a
@@ -294,9 +293,9 @@ type OrgDocumentsCancelInput = {
294
293
  readonly documentId: DocumentId;
295
294
  };
296
295
  type CreateCodes$7 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "INVALID_INPUT" | "IDEMPOTENCY_CONFLICT" | "RATE_LIMITED" | "NETWORK_ERROR";
297
- type RetrieveCodes$c = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND";
296
+ type RetrieveCodes$c = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "INVALID_INPUT";
298
297
  type ListCodes$9 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "INVALID_INPUT";
299
- type CancelCodes$1 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "OPERATION_CANCELED";
298
+ type CancelCodes$1 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "INVALID_INPUT" | "OPERATION_CANCELED";
300
299
  type DocumentsClient = {
301
300
  readonly create: (input: DocumentsCreateInput) => Promise<CapxulResult<Document, CreateCodes$7>>;
302
301
  readonly retrieve: (documentId: DocumentId) => Promise<CapxulResult<Document, RetrieveCodes$c>>;
@@ -691,7 +690,7 @@ type WebhookEventsClient = {
691
690
 
692
691
  type OrganizationsCreateInput = {
693
692
  readonly name: string;
694
- readonly country: string;
693
+ readonly country?: string;
695
694
  };
696
695
  type OrganizationsListInput = {
697
696
  readonly limit?: number;
@@ -710,6 +709,9 @@ type OrgMemberInviteInput = {
710
709
  readonly email: string;
711
710
  readonly role: Member["role"];
712
711
  };
712
+ type OrgMemberAcceptInput = {
713
+ readonly token: string;
714
+ };
713
715
  type OrgMemberUpdateRoleInput = {
714
716
  readonly organizationId: OrganizationId;
715
717
  readonly memberId: MemberId;
@@ -720,21 +722,23 @@ type OrgMemberRemoveInput = {
720
722
  readonly memberId: MemberId;
721
723
  };
722
724
  type OrgMemberRetrieveInput = OrgMemberRemoveInput;
725
+ type OrgMemberRevokeInput = OrgMemberRemoveInput;
726
+ type OrgMemberResendInput = OrgMemberRemoveInput;
723
727
  type OrgListInput = {
724
728
  readonly organizationId: OrganizationId;
725
729
  readonly limit?: number;
726
730
  readonly cursor?: string;
727
731
  };
728
- type OrgKybProfileStartInput = {
729
- readonly organizationId: OrganizationId;
730
- };
731
- type OrgKybProfileRetrieveInput = {
732
+ type OrgMemberListInput = {
732
733
  readonly organizationId: OrganizationId;
733
- readonly kybProfileId: KybProfileId;
734
+ readonly status?: MembershipStatus | "all";
735
+ readonly limit?: number;
736
+ readonly cursor?: string;
734
737
  };
735
738
  type OrgCreateSubAccountInput = {
736
739
  readonly organizationId: OrganizationId;
737
740
  readonly name: string;
741
+ readonly purpose?: string;
738
742
  };
739
743
  type OrgCreateExternalAccountInput = {
740
744
  readonly organizationId: OrganizationId;
@@ -766,6 +770,7 @@ type UpdateCodes = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "IN
766
770
  type SafeRetrieveCodes = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND";
767
771
  type TreasuryRetrieveCodes = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "SAFE_NOT_READY";
768
772
  type RemoveCodes$2 = RetrieveCodes$4;
773
+ type SubAccountRemoveCodes = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "INVALID_INPUT";
769
774
  type OrgSafesClient = {
770
775
  readonly retrieve: (input: OrgSafeRetrieveInput) => Promise<CapxulResult<Safe, SafeRetrieveCodes>>;
771
776
  };
@@ -773,27 +778,26 @@ type OrgTreasuryClient = {
773
778
  readonly retrieve: (organizationId: OrganizationId) => Promise<CapxulResult<Treasury, TreasuryRetrieveCodes>>;
774
779
  };
775
780
  type OrgMembersClient = {
776
- readonly list: (input: OrgListInput) => Promise<CapxulResult<List<Member>, ListCodes$3>>;
781
+ readonly list: (input: OrgMemberListInput) => Promise<CapxulResult<List<Member>, ListCodes$3>>;
777
782
  readonly retrieve: (input: OrgMemberRetrieveInput) => Promise<CapxulResult<Member, RetrieveCodes$4>>;
778
- readonly invite: (input: OrgMemberInviteInput) => Promise<CapxulResult<Member, UpdateCodes>>;
783
+ readonly invite: (input: OrgMemberInviteInput) => Promise<CapxulResult<MemberInviteResponse, UpdateCodes>>;
784
+ readonly accept: (input: OrgMemberAcceptInput) => Promise<CapxulResult<Member, UpdateCodes>>;
779
785
  readonly updateRole: (input: OrgMemberUpdateRoleInput) => Promise<CapxulResult<Member, UpdateCodes>>;
786
+ readonly revoke: (input: OrgMemberRevokeInput) => Promise<CapxulResult<Member, UpdateCodes>>;
780
787
  readonly remove: (input: OrgMemberRemoveInput) => Promise<CapxulResult<void, RemoveCodes$2>>;
781
- };
782
- type OrgKybProfileClient = {
783
- readonly start: (input: OrgKybProfileStartInput) => Promise<CapxulResult<KybProfile, CreateCodes$2>>;
784
- readonly retrieve: (input: OrgKybProfileRetrieveInput) => Promise<CapxulResult<KybProfile, RetrieveCodes$4>>;
788
+ readonly resend: (input: OrgMemberResendInput) => Promise<CapxulResult<MemberInviteResponse, UpdateCodes>>;
785
789
  };
786
790
  type OrgSubAccountsClient = {
787
- readonly create: (input: OrgCreateSubAccountInput) => Promise<CapxulResult<SubAccount, UpdateCodes>>;
788
- readonly list: (input: OrgListInput) => Promise<CapxulResult<List<SubAccount>, ListCodes$3>>;
791
+ readonly create: (input: OrgCreateSubAccountInput) => Promise<CapxulResult<SubAccount, UpdateCodes | "PROVIDER_ERROR">>;
792
+ readonly list: (input: OrgListInput) => Promise<CapxulResult<List<SubAccount>, ListCodes$3 | "PROVIDER_ERROR">>;
789
793
  readonly retrieve: (input: {
790
794
  readonly organizationId: OrganizationId;
791
795
  readonly subAccountId: SubAccountId;
792
- }) => Promise<CapxulResult<SubAccount, RetrieveCodes$4>>;
796
+ }) => Promise<CapxulResult<SubAccount, RetrieveCodes$4 | "PROVIDER_ERROR">>;
793
797
  readonly remove: (input: {
794
798
  readonly organizationId: OrganizationId;
795
799
  readonly subAccountId: SubAccountId;
796
- }) => Promise<CapxulResult<void, RemoveCodes$2>>;
800
+ }) => Promise<CapxulResult<SubAccount, SubAccountRemoveCodes | "PROVIDER_ERROR">>;
797
801
  };
798
802
  type OrgExternalAccountsClient = {
799
803
  readonly create: (input: OrgCreateExternalAccountInput) => Promise<CapxulResult<ExternalAccount, UpdateCodes>>;
@@ -824,7 +828,6 @@ type OrganizationsClient = {
824
828
  readonly treasury: OrgTreasuryClient;
825
829
  readonly members: OrgMembersClient;
826
830
  readonly apiKeys: OrgApiKeysClient;
827
- readonly kybProfile: OrgKybProfileClient;
828
831
  readonly subAccounts: OrgSubAccountsClient;
829
832
  readonly externalAccounts: OrgExternalAccountsClient;
830
833
  readonly balanceLedger: OrgBalanceLedgerClient;
@@ -918,7 +921,7 @@ type TransportState = {
918
921
  readonly runtime: TransportRuntime;
919
922
  } | {
920
923
  readonly status: "error";
921
- readonly error: CapxulError$1;
924
+ readonly error: CapxulError;
922
925
  };
923
926
  type TransportRuntime = {
924
927
  readonly authBaseUrl: string;
@@ -977,13 +980,20 @@ declare function makeHttpTransport(config: BrowserCapxulConfig): HttpTransport;
977
980
  * `accounts.subAccounts.create(...)` or
978
981
  * `organizations.subAccounts.create(...)`), so only `retrieve` and
979
982
  * `remove` live at the top level.
983
+ *
984
+ * Wired in PR-2a of the funds-v1 balance-closure stack: the backend
985
+ * always returns truthful `balance: Money` per canon §sub_account
986
+ * (PR-1 made `toCanonShape` populate it from `computeSubAccountBalance`).
987
+ * The SDK brands the wire shape and passes the balance through as-is.
988
+ * NO zero-balance fallback exists at the SDK layer — if the backend
989
+ * ever omits `balance`, that is a bug to surface, not paper over.
980
990
  */
981
991
 
982
- type RetrieveCodes$3 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND";
983
- type RemoveCodes$1 = RetrieveCodes$3;
992
+ type RetrieveCodes$3 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "PROVIDER_ERROR";
993
+ type RemoveCodes$1 = "NOT_AUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "INVALID_INPUT" | "PROVIDER_ERROR";
984
994
  type SubAccountsClient = {
985
995
  readonly retrieve: (subAccountId: SubAccountId) => Promise<CapxulResult<SubAccount, RetrieveCodes$3>>;
986
- readonly remove: (subAccountId: SubAccountId) => Promise<CapxulResult<void, RemoveCodes$1>>;
996
+ readonly remove: (subAccountId: SubAccountId) => Promise<CapxulResult<SubAccount, RemoveCodes$1>>;
987
997
  };
988
998
 
989
999
  /**
@@ -1138,161 +1148,6 @@ type VirtualCardsClient = {
1138
1148
  readonly cancel: (virtualCardId: VirtualCardId) => Promise<CapxulResult<VirtualCard, MutateCodes>>;
1139
1149
  };
1140
1150
 
1141
- /**
1142
- * Unified error type used across the entire stack: backend, SDK, and frontend.
1143
- * One class, one set of codes, one language.
1144
- *
1145
- * Backend throws CapxulError → withErrorBoundary serializes to ConvexError →
1146
- * SDK deserializes back to CapxulError → frontend routes on err.code.
1147
- */
1148
- 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";
1149
- declare class CapxulError extends Error {
1150
- readonly code: CapxulErrorCode;
1151
- readonly details?: Record<string, unknown>;
1152
- readonly correlationId?: string;
1153
- readonly layer?: string;
1154
- constructor(code: CapxulErrorCode, message: string, options?: {
1155
- cause?: unknown;
1156
- details?: Record<string, unknown>;
1157
- correlationId?: string;
1158
- layer?: string;
1159
- });
1160
- }
1161
-
1162
- type AuthBootstrapFlowError = CapxulError$1 | CapxulError;
1163
- type AuthBootstrapFlowContext = {
1164
- readonly email: Email | null;
1165
- readonly code: string | null;
1166
- readonly username: Username | null;
1167
- readonly signerProvider: LocalPrivateKeySignerProvider | null;
1168
- readonly bootstrapToken: AuthBootstrapToken | null;
1169
- readonly bootstrapReason: AuthBootstrapReason | null;
1170
- readonly session: Session | null;
1171
- readonly account: Account | null;
1172
- readonly safe: Safe | null;
1173
- readonly error: AuthBootstrapFlowError | null;
1174
- };
1175
- type AuthBootstrapFlowEvent = {
1176
- readonly type: "ENTER_EMAIL";
1177
- readonly email: Email;
1178
- } | {
1179
- readonly type: "REQUEST_OTP";
1180
- } | {
1181
- readonly type: "ENTER_OTP";
1182
- readonly code: string;
1183
- } | {
1184
- readonly type: "VERIFY_OTP";
1185
- } | {
1186
- readonly type: "ENTER_USERNAME";
1187
- readonly username: Username;
1188
- } | {
1189
- readonly type: "ENTER_SIGNER_PROVIDER";
1190
- readonly signerProvider: LocalPrivateKeySignerProvider;
1191
- } | {
1192
- readonly type: "COMPLETE_BOOTSTRAP";
1193
- } | {
1194
- readonly type: "BACK";
1195
- } | {
1196
- readonly type: "RESET";
1197
- } | {
1198
- readonly type: "SIGN_OUT";
1199
- };
1200
- declare function createAuthBootstrapFlowMachine(client: CapxulClient): xstate.StateMachine<AuthBootstrapFlowContext, {
1201
- readonly type: "ENTER_EMAIL";
1202
- readonly email: Email;
1203
- } | {
1204
- readonly type: "REQUEST_OTP";
1205
- } | {
1206
- readonly type: "ENTER_OTP";
1207
- readonly code: string;
1208
- } | {
1209
- readonly type: "VERIFY_OTP";
1210
- } | {
1211
- readonly type: "ENTER_USERNAME";
1212
- readonly username: Username;
1213
- } | {
1214
- readonly type: "ENTER_SIGNER_PROVIDER";
1215
- readonly signerProvider: LocalPrivateKeySignerProvider;
1216
- } | {
1217
- readonly type: "COMPLETE_BOOTSTRAP";
1218
- } | {
1219
- readonly type: "BACK";
1220
- } | {
1221
- readonly type: "RESET";
1222
- } | {
1223
- readonly type: "SIGN_OUT";
1224
- }, {
1225
- [x: string]: xstate.ActorRefFromLogic<xstate.PromiseActorLogic<void, void, xstate.EventObject>> | xstate.ActorRefFromLogic<xstate.PromiseActorLogic<void, {
1226
- email: Email;
1227
- }, xstate.EventObject>> | xstate.ActorRefFromLogic<xstate.PromiseActorLogic<VerifyOtpResult, {
1228
- email: Email;
1229
- code: string;
1230
- }, xstate.EventObject>> | xstate.ActorRefFromLogic<xstate.PromiseActorLogic<CompleteBootstrapResult, {
1231
- bootstrapToken: AuthBootstrapToken;
1232
- username: Username;
1233
- signerProvider: LocalPrivateKeySignerProvider;
1234
- }, xstate.EventObject>> | undefined;
1235
- }, {
1236
- src: "sendOtp";
1237
- logic: xstate.PromiseActorLogic<void, {
1238
- email: Email;
1239
- }, xstate.EventObject>;
1240
- id: string | undefined;
1241
- } | {
1242
- src: "verifyOtp";
1243
- logic: xstate.PromiseActorLogic<VerifyOtpResult, {
1244
- email: Email;
1245
- code: string;
1246
- }, xstate.EventObject>;
1247
- id: string | undefined;
1248
- } | {
1249
- src: "signOut";
1250
- logic: xstate.PromiseActorLogic<void, void, xstate.EventObject>;
1251
- id: string | undefined;
1252
- } | {
1253
- src: "completeBootstrap";
1254
- logic: xstate.PromiseActorLogic<CompleteBootstrapResult, {
1255
- bootstrapToken: AuthBootstrapToken;
1256
- username: Username;
1257
- signerProvider: LocalPrivateKeySignerProvider;
1258
- }, xstate.EventObject>;
1259
- id: string | undefined;
1260
- }, {
1261
- type: "trackOtpRequested";
1262
- params: unknown;
1263
- } | {
1264
- type: "trackTimeoutFailed";
1265
- params: unknown;
1266
- } | {
1267
- type: "trackVerified";
1268
- params: unknown;
1269
- } | {
1270
- type: "identifyAndTrack";
1271
- params: unknown;
1272
- } | {
1273
- type: "trackSignedOut";
1274
- params: unknown;
1275
- } | {
1276
- type: "trackFailed";
1277
- params: unknown;
1278
- } | {
1279
- type: "trackBootstrapRequired";
1280
- params: unknown;
1281
- }, 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, {
1282
- id: "authBootstrap";
1283
- states: {
1284
- readonly email: {};
1285
- readonly sending_otp: {};
1286
- readonly otp_requested: {};
1287
- readonly verifying_otp: {};
1288
- readonly bootstrap_required: {};
1289
- readonly completing_bootstrap: {};
1290
- readonly authenticated: {};
1291
- readonly signing_out: {};
1292
- readonly error: {};
1293
- };
1294
- }>;
1295
-
1296
1151
  /**
1297
1152
  * Root `@capxul/sdk` client factory.
1298
1153
  *
@@ -1340,11 +1195,6 @@ type CapxulAuthConfig = {
1340
1195
  readonly convexTokenUrl?: string;
1341
1196
  /** Scenario/browser-local session store shared by auth + onboarding hooks. */
1342
1197
  readonly sessionStore?: AuthSessionStore;
1343
- /**
1344
- * Optional bridge for environments that can build an authenticated data
1345
- * client after BetterAuth returns a session.
1346
- */
1347
- readonly createDataClient?: (session: Session) => Promise<CapxulDataClient>;
1348
1198
  };
1349
1199
  type CapxulConfig = {
1350
1200
  /** Server-to-server partner key. Mutually exclusive with `publishableKey`. */
@@ -1360,12 +1210,13 @@ type CapxulConfig = {
1360
1210
  */
1361
1211
  readonly signer?: Account$1;
1362
1212
  /**
1363
- * Inject an authenticated Convex data client.
1213
+ * @internal
1364
1214
  *
1365
- * Slice F.2 uses this for the restart payment + operation runtime
1366
- * path while the `/v1/*` service-token bridge remains unfinished.
1215
+ * Test-only override seam for injecting an authenticated Convex data client.
1216
+ * The SDK now owns runtime construction of the data client; this field is
1217
+ * reserved for tests and the React provider's singleton lifecycle.
1367
1218
  */
1368
- readonly data?: CapxulDataClient;
1219
+ readonly _data?: CapxulDataClient;
1369
1220
  /**
1370
1221
  * Chain + bundler configuration for on-chain submission.
1371
1222
  *
@@ -1403,7 +1254,7 @@ type CapxulConfig = {
1403
1254
  readonly _transport?: HttpTransport;
1404
1255
  };
1405
1256
  /**
1406
- * Per-call factories for the three Stack-1 XState v5 flow machines.
1257
+ * Per-call factories for XState v5 flow machines.
1407
1258
  *
1408
1259
  * Each factory returns a fresh machine instance bound to this
1409
1260
  * `CapxulClient`. The consumer is responsible for creating a single
@@ -1419,8 +1270,6 @@ type CapxulConfig = {
1419
1270
  * `./flows/*` when they need them.
1420
1271
  */
1421
1272
  type CapxulFlowFactories = {
1422
- readonly auth: () => AnyStateMachine;
1423
- readonly authBootstrap: () => ReturnType<typeof createAuthBootstrapFlowMachine>;
1424
1273
  readonly onboarding: () => AnyStateMachine;
1425
1274
  readonly provisioning: () => AnyStateMachine;
1426
1275
  };
@@ -1441,7 +1290,7 @@ type CapxulClient = {
1441
1290
  * `createCapxulClient()` call. See Codex P1 finding on PR #406.
1442
1291
  */
1443
1292
  readonly id: string;
1444
- readonly auth: AuthClient;
1293
+ readonly auth: AuthService;
1445
1294
  readonly me: MeClient;
1446
1295
  readonly accounts: AccountsClient;
1447
1296
  readonly organizations: OrganizationsClient;
@@ -1476,11 +1325,11 @@ type CapxulClient = {
1476
1325
  * Two-pass construction: the per-domain clients (`auth`, `me`, …) are
1477
1326
  * built first, then `flows` is assigned with factories that close over
1478
1327
  * the fully-built `client` so the spawned XState machines can call
1479
- * back into `client.auth.sendOtp`, `client.accounts.provisionPersonal`,
1480
- * etc. The intermediate `clientWithoutFlows` value is typed without
1328
+ * back into `client.accounts.provisionPersonal`, etc. The intermediate
1329
+ * `clientWithoutFlows` value is typed without
1481
1330
  * `flows`; `Object.assign` mutates a single `flows` field on it before
1482
1331
  * the returned `CapxulClient` cast — minimal and contained.
1483
1332
  */
1484
1333
  declare function createCapxulClient(config?: CapxulConfig): CapxulClient;
1485
1334
 
1486
- export { createAuthBootstrapFlowMachine as $, type AccountProvisionPersonalInput as A, type BrowserCapxulConfig as B, CapxulError as C, type DocumentsClient as D, type ExternalAccountsClient as E, type TokenTransferId as F, type TokenTransfersClient as G, type HttpTransport as H, type TokenTransfersListInput as I, type TokenTransfersListPage as J, type TokenTransfersRetrieveInput as K, type LocalPrivateKeySignerProvider as L, type MeClient as M, type TransfersClient as N, type OperationsClient as O, type PaymentsClient as P, type TransportRuntime as Q, type TransportState as R, type Session as S, type TokenTransfer as T, type VirtualAccountsClient as U, type VerifyOtpResult as V, type VirtualCardsClient as W, type WebhookEndpointCreateResult as X, type WebhookEndpointsClient as Y, type WebhookEventsClient as Z, type WithdrawalsClient as _, type CapxulClient as a, createCapxulClient as a0, makeHttpTransport as a1, toTokenTransferId as a2, type AccountsClient as b, type ApiKeyCreateResult as c, type ApiKeysClient as d, type AuthBootstrapFlowContext as e, type AuthBootstrapFlowError as f, type AuthBootstrapFlowEvent as g, type AuthBootstrapReason as h, type AuthBootstrapToken as i, type AuthClient as j, type AuthSessionStore as k, type CapxulAuthConfig as l, type CapxulConfig as m, type CapxulDataClient as n, type CapxulFlowFactories as o, type CapxulSigningConfig as p, type CompleteBootstrapInput as q, type CompleteBootstrapResult as r, type OrgDocumentsClient as s, type OrgPaymentsClient as t, type OrgSafesClient as u, type OrgTransfersClient as v, type OrgTreasuryClient as w, type OrgWithdrawalsClient as x, type OrganizationsClient as y, type SubAccountsClient as z };
1335
+ export { type AccountProvisionPersonalInput as A, type BrowserCapxulConfig as B, type CapxulClient as C, type DocumentsClient as D, type ExternalAccountsClient as E, type TokenTransfersListPage as F, type TokenTransfersRetrieveInput as G, type HttpTransport as H, type TransfersClient as I, type TransportRuntime as J, type TransportState as K, type LocalPrivateKeySignerProvider as L, type MeClient as M, type VirtualAccountsClient as N, type OperationsClient as O, type PaymentsClient as P, type VirtualCardsClient as Q, type WebhookEndpointsClient as R, type Session as S, type TokenTransfer as T, type WebhookEventsClient as U, type VerifyOtpResult as V, type WebhookEndpointCreateResult as W, type WithdrawalsClient as X, createCapxulClient as Y, makeHttpTransport as Z, toTokenTransferId as _, type AccountsClient as a, type ApiKeyCreateResult as b, type ApiKeysClient as c, type AuthBootstrapReason as d, type AuthBootstrapToken as e, AuthService as f, type AuthSessionStore as g, type CapxulAuthConfig as h, type CapxulConfig as i, type CapxulDataClient as j, type CapxulFlowFactories as k, type CapxulSigningConfig as l, type CompleteBootstrapInput as m, type CompleteBootstrapResult as n, type OrgDocumentsClient as o, type OrgMembersClient as p, type OrgPaymentsClient as q, type OrgSafesClient as r, type OrgTransfersClient as s, type OrgTreasuryClient as t, type OrgWithdrawalsClient as u, type OrganizationsClient as v, type SubAccountsClient as w, type TokenTransferId as x, type TokenTransfersClient as y, type TokenTransfersListInput as z };