@capxul/sdk 0.2.0-alpha.3 → 0.2.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/README.md +64 -22
- package/dist/{client-pMBRFcsz.d.ts → client-CbUeJoM9.d.ts} +41 -190
- package/dist/{client-B_Z3ThFO.d.cts → client-UEm2oZbZ.d.cts} +41 -190
- package/dist/client.cjs +362 -644
- package/dist/client.d.cts +2 -2
- package/dist/client.d.ts +2 -2
- package/dist/client.js +363 -645
- package/dist/index.cjs +363 -716
- package/dist/index.d.cts +32 -142
- package/dist/index.d.ts +32 -142
- package/dist/index.js +365 -716
- package/dist/{types-V_D7qjxY.d.ts → types-BD4VAQb5.d.ts} +14 -0
- package/dist/{types-Brucpq0Z.d.cts → types-HlwCIjgQ.d.cts} +14 -0
- package/dist/webhooks.d.cts +1 -1
- package/dist/webhooks.d.ts +1 -1
- package/package.json +2 -3
|
@@ -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
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.cjs';
|
|
5
|
-
import { d as CapxulResult, C as CapxulError
|
|
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-
|
|
4
|
+
import { d as CapxulResult, C as CapxulError } from './errors-rqxuUhQP.cjs';
|
|
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-HlwCIjgQ.cjs';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* Accounts domain — individual user accounts per sdk-surface.md §1a.
|
|
@@ -184,13 +183,6 @@ type AuthSessionStore = {
|
|
|
184
183
|
set(session: Session): void;
|
|
185
184
|
clear(): void;
|
|
186
185
|
};
|
|
187
|
-
type AuthSendOtpInput = {
|
|
188
|
-
readonly email: string;
|
|
189
|
-
};
|
|
190
|
-
type AuthVerifyOtpInput = {
|
|
191
|
-
readonly email: string;
|
|
192
|
-
readonly otp: string;
|
|
193
|
-
};
|
|
194
186
|
type AuthBootstrapToken = string & {
|
|
195
187
|
readonly __capxulAuthBootstrapTokenBrand: "AuthBootstrapToken";
|
|
196
188
|
};
|
|
@@ -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
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
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>>;
|
|
@@ -922,7 +921,7 @@ type TransportState = {
|
|
|
922
921
|
readonly runtime: TransportRuntime;
|
|
923
922
|
} | {
|
|
924
923
|
readonly status: "error";
|
|
925
|
-
readonly error: CapxulError
|
|
924
|
+
readonly error: CapxulError;
|
|
926
925
|
};
|
|
927
926
|
type TransportRuntime = {
|
|
928
927
|
readonly authBaseUrl: string;
|
|
@@ -1149,152 +1148,6 @@ type VirtualCardsClient = {
|
|
|
1149
1148
|
readonly cancel: (virtualCardId: VirtualCardId) => Promise<CapxulResult<VirtualCard, MutateCodes>>;
|
|
1150
1149
|
};
|
|
1151
1150
|
|
|
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
|
-
|
|
1298
1151
|
/**
|
|
1299
1152
|
* Root `@capxul/sdk` client factory.
|
|
1300
1153
|
*
|
|
@@ -1401,7 +1254,7 @@ type CapxulConfig = {
|
|
|
1401
1254
|
readonly _transport?: HttpTransport;
|
|
1402
1255
|
};
|
|
1403
1256
|
/**
|
|
1404
|
-
* Per-call factories for
|
|
1257
|
+
* Per-call factories for XState v5 flow machines.
|
|
1405
1258
|
*
|
|
1406
1259
|
* Each factory returns a fresh machine instance bound to this
|
|
1407
1260
|
* `CapxulClient`. The consumer is responsible for creating a single
|
|
@@ -1417,8 +1270,6 @@ type CapxulConfig = {
|
|
|
1417
1270
|
* `./flows/*` when they need them.
|
|
1418
1271
|
*/
|
|
1419
1272
|
type CapxulFlowFactories = {
|
|
1420
|
-
readonly auth: () => AnyStateMachine;
|
|
1421
|
-
readonly authBootstrap: () => ReturnType<typeof createAuthBootstrapFlowMachine>;
|
|
1422
1273
|
readonly onboarding: () => AnyStateMachine;
|
|
1423
1274
|
readonly provisioning: () => AnyStateMachine;
|
|
1424
1275
|
};
|
|
@@ -1439,7 +1290,7 @@ type CapxulClient = {
|
|
|
1439
1290
|
* `createCapxulClient()` call. See Codex P1 finding on PR #406.
|
|
1440
1291
|
*/
|
|
1441
1292
|
readonly id: string;
|
|
1442
|
-
readonly auth:
|
|
1293
|
+
readonly auth: AuthService;
|
|
1443
1294
|
readonly me: MeClient;
|
|
1444
1295
|
readonly accounts: AccountsClient;
|
|
1445
1296
|
readonly organizations: OrganizationsClient;
|
|
@@ -1474,11 +1325,11 @@ type CapxulClient = {
|
|
|
1474
1325
|
* Two-pass construction: the per-domain clients (`auth`, `me`, …) are
|
|
1475
1326
|
* built first, then `flows` is assigned with factories that close over
|
|
1476
1327
|
* the fully-built `client` so the spawned XState machines can call
|
|
1477
|
-
* back into `client.
|
|
1478
|
-
*
|
|
1328
|
+
* back into `client.accounts.provisionPersonal`, etc. The intermediate
|
|
1329
|
+
* `clientWithoutFlows` value is typed without
|
|
1479
1330
|
* `flows`; `Object.assign` mutates a single `flows` field on it before
|
|
1480
1331
|
* the returned `CapxulClient` cast — minimal and contained.
|
|
1481
1332
|
*/
|
|
1482
1333
|
declare function createCapxulClient(config?: CapxulConfig): CapxulClient;
|
|
1483
1334
|
|
|
1484
|
-
export { type
|
|
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 };
|