@capxul/sdk 0.1.0-alpha.8 → 0.1.0-alpha.9
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 +14 -0
- package/dist/{client-ByzDfG98.d.ts → client-ChZrdf3R.d.ts} +197 -6
- package/dist/{client-DDAVWtzJ.d.cts → client-DG6ODWu6.d.cts} +197 -6
- package/dist/client.cjs +418 -10
- package/dist/client.d.cts +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.js +418 -10
- package/dist/index.cjs +419 -10
- package/dist/index.d.cts +14 -35
- package/dist/index.d.ts +14 -35
- package/dist/index.js +419 -11
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @capxul/sdk
|
|
2
2
|
|
|
3
|
+
## 0.1.0-alpha.9
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Add the canonical auth bootstrap flow.
|
|
8
|
+
|
|
9
|
+
`verifyOtp()` now resolves a verified email session into either an
|
|
10
|
+
`existing_member` identity or a `bootstrap_required` continuation. New and
|
|
11
|
+
incomplete members continue through `completeBootstrap()`, which validates a
|
|
12
|
+
server-issued bootstrap token, claims the username, provisions the account/Safe
|
|
13
|
+
through the backend bootstrap path, and returns the authenticated product
|
|
14
|
+
identity. The React SDK adds `useAuthBootstrapFlow()` as the typed first-run
|
|
15
|
+
flow wrapper.
|
|
16
|
+
|
|
3
17
|
## 0.1.0-alpha.8
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
|
@@ -1,7 +1,8 @@
|
|
|
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';
|
|
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';
|
|
5
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';
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -189,6 +190,38 @@ type AuthVerifyOtpInput = {
|
|
|
189
190
|
readonly email: string;
|
|
190
191
|
readonly otp: string;
|
|
191
192
|
};
|
|
193
|
+
type AuthBootstrapToken = string & {
|
|
194
|
+
readonly __capxulAuthBootstrapTokenBrand: "AuthBootstrapToken";
|
|
195
|
+
};
|
|
196
|
+
type AuthBootstrapReason = "new_member" | "missing_profile" | "missing_account" | "missing_safe" | "missing_signer_grant";
|
|
197
|
+
type VerifyOtpResult = {
|
|
198
|
+
readonly kind: "existing_member";
|
|
199
|
+
readonly session: Session;
|
|
200
|
+
readonly account: Account;
|
|
201
|
+
readonly username: Username;
|
|
202
|
+
readonly safe: Safe;
|
|
203
|
+
} | {
|
|
204
|
+
readonly kind: "bootstrap_required";
|
|
205
|
+
readonly session: Session;
|
|
206
|
+
readonly bootstrapToken: AuthBootstrapToken;
|
|
207
|
+
readonly email: Email;
|
|
208
|
+
readonly reason: AuthBootstrapReason;
|
|
209
|
+
readonly username?: Username;
|
|
210
|
+
};
|
|
211
|
+
type CompleteBootstrapInput = {
|
|
212
|
+
readonly bootstrapToken: AuthBootstrapToken;
|
|
213
|
+
readonly username: Username;
|
|
214
|
+
readonly signerProvider: LocalPrivateKeySignerProvider;
|
|
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;
|
|
@@ -211,13 +244,15 @@ type ServiceToken = {
|
|
|
211
244
|
readonly expiresAt: TimestampIso;
|
|
212
245
|
};
|
|
213
246
|
type SendOtpCodes = "EMAIL_DELIVERY_FAILED" | "INVALID_INPUT" | "RATE_LIMITED" | "NETWORK_ERROR";
|
|
214
|
-
type VerifyOtpCodes = "INVALID_INPUT" | "NOT_AUTHENTICATED" | "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";
|
|
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<
|
|
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>>;
|
|
@@ -883,7 +918,7 @@ type TransportState = {
|
|
|
883
918
|
readonly runtime: TransportRuntime;
|
|
884
919
|
} | {
|
|
885
920
|
readonly status: "error";
|
|
886
|
-
readonly error: CapxulError;
|
|
921
|
+
readonly error: CapxulError$1;
|
|
887
922
|
};
|
|
888
923
|
type TransportRuntime = {
|
|
889
924
|
readonly authBaseUrl: string;
|
|
@@ -1103,6 +1138,161 @@ type VirtualCardsClient = {
|
|
|
1103
1138
|
readonly cancel: (virtualCardId: VirtualCardId) => Promise<CapxulResult<VirtualCard, MutateCodes>>;
|
|
1104
1139
|
};
|
|
1105
1140
|
|
|
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
|
+
|
|
1106
1296
|
/**
|
|
1107
1297
|
* Root `@capxul/sdk` client factory.
|
|
1108
1298
|
*
|
|
@@ -1230,6 +1420,7 @@ type CapxulConfig = {
|
|
|
1230
1420
|
*/
|
|
1231
1421
|
type CapxulFlowFactories = {
|
|
1232
1422
|
readonly auth: () => AnyStateMachine;
|
|
1423
|
+
readonly authBootstrap: () => ReturnType<typeof createAuthBootstrapFlowMachine>;
|
|
1233
1424
|
readonly onboarding: () => AnyStateMachine;
|
|
1234
1425
|
readonly provisioning: () => AnyStateMachine;
|
|
1235
1426
|
};
|
|
@@ -1292,4 +1483,4 @@ type CapxulClient = {
|
|
|
1292
1483
|
*/
|
|
1293
1484
|
declare function createCapxulClient(config?: CapxulConfig): CapxulClient;
|
|
1294
1485
|
|
|
1295
|
-
export { type AccountProvisionPersonalInput as A, type BrowserCapxulConfig as B,
|
|
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 };
|
|
@@ -1,7 +1,8 @@
|
|
|
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.cjs';
|
|
4
|
-
import { d as CapxulResult, C as CapxulError } from './errors-GgKrSUKp.cjs';
|
|
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.cjs';
|
|
5
|
+
import { d as CapxulResult, C as CapxulError$1 } from './errors-GgKrSUKp.cjs';
|
|
5
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-hfcOE7Oi.cjs';
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -189,6 +190,38 @@ type AuthVerifyOtpInput = {
|
|
|
189
190
|
readonly email: string;
|
|
190
191
|
readonly otp: string;
|
|
191
192
|
};
|
|
193
|
+
type AuthBootstrapToken = string & {
|
|
194
|
+
readonly __capxulAuthBootstrapTokenBrand: "AuthBootstrapToken";
|
|
195
|
+
};
|
|
196
|
+
type AuthBootstrapReason = "new_member" | "missing_profile" | "missing_account" | "missing_safe" | "missing_signer_grant";
|
|
197
|
+
type VerifyOtpResult = {
|
|
198
|
+
readonly kind: "existing_member";
|
|
199
|
+
readonly session: Session;
|
|
200
|
+
readonly account: Account;
|
|
201
|
+
readonly username: Username;
|
|
202
|
+
readonly safe: Safe;
|
|
203
|
+
} | {
|
|
204
|
+
readonly kind: "bootstrap_required";
|
|
205
|
+
readonly session: Session;
|
|
206
|
+
readonly bootstrapToken: AuthBootstrapToken;
|
|
207
|
+
readonly email: Email;
|
|
208
|
+
readonly reason: AuthBootstrapReason;
|
|
209
|
+
readonly username?: Username;
|
|
210
|
+
};
|
|
211
|
+
type CompleteBootstrapInput = {
|
|
212
|
+
readonly bootstrapToken: AuthBootstrapToken;
|
|
213
|
+
readonly username: Username;
|
|
214
|
+
readonly signerProvider: LocalPrivateKeySignerProvider;
|
|
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;
|
|
@@ -211,13 +244,15 @@ type ServiceToken = {
|
|
|
211
244
|
readonly expiresAt: TimestampIso;
|
|
212
245
|
};
|
|
213
246
|
type SendOtpCodes = "EMAIL_DELIVERY_FAILED" | "INVALID_INPUT" | "RATE_LIMITED" | "NETWORK_ERROR";
|
|
214
|
-
type VerifyOtpCodes = "INVALID_INPUT" | "NOT_AUTHENTICATED" | "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";
|
|
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<
|
|
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>>;
|
|
@@ -883,7 +918,7 @@ type TransportState = {
|
|
|
883
918
|
readonly runtime: TransportRuntime;
|
|
884
919
|
} | {
|
|
885
920
|
readonly status: "error";
|
|
886
|
-
readonly error: CapxulError;
|
|
921
|
+
readonly error: CapxulError$1;
|
|
887
922
|
};
|
|
888
923
|
type TransportRuntime = {
|
|
889
924
|
readonly authBaseUrl: string;
|
|
@@ -1103,6 +1138,161 @@ type VirtualCardsClient = {
|
|
|
1103
1138
|
readonly cancel: (virtualCardId: VirtualCardId) => Promise<CapxulResult<VirtualCard, MutateCodes>>;
|
|
1104
1139
|
};
|
|
1105
1140
|
|
|
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
|
+
|
|
1106
1296
|
/**
|
|
1107
1297
|
* Root `@capxul/sdk` client factory.
|
|
1108
1298
|
*
|
|
@@ -1230,6 +1420,7 @@ type CapxulConfig = {
|
|
|
1230
1420
|
*/
|
|
1231
1421
|
type CapxulFlowFactories = {
|
|
1232
1422
|
readonly auth: () => AnyStateMachine;
|
|
1423
|
+
readonly authBootstrap: () => ReturnType<typeof createAuthBootstrapFlowMachine>;
|
|
1233
1424
|
readonly onboarding: () => AnyStateMachine;
|
|
1234
1425
|
readonly provisioning: () => AnyStateMachine;
|
|
1235
1426
|
};
|
|
@@ -1292,4 +1483,4 @@ type CapxulClient = {
|
|
|
1292
1483
|
*/
|
|
1293
1484
|
declare function createCapxulClient(config?: CapxulConfig): CapxulClient;
|
|
1294
1485
|
|
|
1295
|
-
export { type AccountProvisionPersonalInput as A, type BrowserCapxulConfig as B,
|
|
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 };
|