@capxul/sdk 0.1.0-alpha.6 → 0.1.0-alpha.8
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 +1 -8
- package/README.md +86 -4
- package/dist/{client-ChfXWMzO.d.ts → client-ByzDfG98.d.ts} +12 -9
- package/dist/{client-DW_fW9DC.d.cts → client-DDAVWtzJ.d.cts} +12 -9
- package/dist/client.cjs +216 -26
- package/dist/client.d.cts +2 -3
- package/dist/client.d.ts +2 -3
- package/dist/client.js +216 -26
- package/dist/index.cjs +216 -26
- package/dist/index.d.cts +9 -10
- package/dist/index.d.ts +9 -10
- package/dist/index.js +216 -26
- package/dist/types-PM4AQRLP.d.ts +1136 -0
- package/dist/types-hfcOE7Oi.d.cts +1136 -0
- package/dist/webhooks.d.cts +1 -2
- package/dist/webhooks.d.ts +1 -2
- package/package.json +6 -6
- package/dist/types-CYvLP5pP.d.ts +0 -213
- package/dist/types-X02RbQ2u.d.cts +0 -213
package/dist/index.cjs
CHANGED
|
@@ -679,7 +679,12 @@ var Errors = {
|
|
|
679
679
|
"Idempotency key was already used for a different request",
|
|
680
680
|
{ details }
|
|
681
681
|
),
|
|
682
|
-
emailDeliveryFailed: (detail) => new CapxulError2("EMAIL_DELIVERY_FAILED", `Failed to send email: ${detail}
|
|
682
|
+
emailDeliveryFailed: (detail, details) => new CapxulError2("EMAIL_DELIVERY_FAILED", `Failed to send email: ${detail}`, {
|
|
683
|
+
details
|
|
684
|
+
}),
|
|
685
|
+
rateLimited: (details) => new CapxulError2("RATE_LIMITED", "Request was rate limited", {
|
|
686
|
+
details: { ...details }
|
|
687
|
+
}),
|
|
683
688
|
internalError: (reason) => new CapxulError2("INTERNAL_ERROR", `Internal error: ${reason}`),
|
|
684
689
|
/**
|
|
685
690
|
* Verification gate. Surfaced when a request hits a verification
|
|
@@ -752,13 +757,13 @@ function createLifecycle(initial) {
|
|
|
752
757
|
}
|
|
753
758
|
function makeBuildTimeUrlsTransport(config) {
|
|
754
759
|
if (!config.authBaseUrl || config.authBaseUrl.trim().length === 0) {
|
|
755
|
-
throw
|
|
760
|
+
throw invalidConfigError(
|
|
756
761
|
"authBaseUrl",
|
|
757
762
|
"build-time-urls transport requires a non-empty authBaseUrl."
|
|
758
763
|
);
|
|
759
764
|
}
|
|
760
765
|
if (!config.convexUrl || config.convexUrl.trim().length === 0) {
|
|
761
|
-
throw
|
|
766
|
+
throw invalidConfigError(
|
|
762
767
|
"convexUrl",
|
|
763
768
|
"build-time-urls transport requires a non-empty convexUrl."
|
|
764
769
|
);
|
|
@@ -772,6 +777,7 @@ function makeBuildTimeUrlsTransport(config) {
|
|
|
772
777
|
return {
|
|
773
778
|
authBaseUrl,
|
|
774
779
|
convexUrl,
|
|
780
|
+
ensureRuntime: async () => runtime,
|
|
775
781
|
fetch: (path, init) => fetchImpl(resolveUrl(authBaseUrl, path), init),
|
|
776
782
|
getState: lifecycle.getState,
|
|
777
783
|
subscribe: lifecycle.subscribe,
|
|
@@ -787,14 +793,15 @@ function makeBuildTimeUrlsTransport(config) {
|
|
|
787
793
|
};
|
|
788
794
|
}
|
|
789
795
|
function makePublishableKeyTransport(config) {
|
|
790
|
-
|
|
791
|
-
|
|
796
|
+
const publishableKey = config.publishableKey?.trim();
|
|
797
|
+
if (!publishableKey) {
|
|
798
|
+
throw invalidConfigError(
|
|
792
799
|
"publishableKey",
|
|
793
800
|
"publishable-key transport requires a non-empty publishableKey."
|
|
794
801
|
);
|
|
795
802
|
}
|
|
796
803
|
const fetchImpl = config.fetchImpl ?? globalThis.fetch;
|
|
797
|
-
const bootstrapUrl =
|
|
804
|
+
const bootstrapUrl = normalizeBootstrapUrl(
|
|
798
805
|
config.bootstrapUrl ?? `${CAPXUL_API_BASE_URL}/v1/client/bootstrap`
|
|
799
806
|
);
|
|
800
807
|
let authBaseUrl = "";
|
|
@@ -809,23 +816,20 @@ function makePublishableKeyTransport(config) {
|
|
|
809
816
|
const response = await fetchImpl(bootstrapUrl, {
|
|
810
817
|
method: "POST",
|
|
811
818
|
headers: { "content-type": "application/json" },
|
|
812
|
-
body: JSON.stringify({ publishableKey
|
|
819
|
+
body: JSON.stringify({ publishableKey })
|
|
813
820
|
});
|
|
814
821
|
if (!response.ok) {
|
|
815
|
-
throw
|
|
816
|
-
"publishableKey",
|
|
817
|
-
`${bootstrapUrl} failed with HTTP ${response.status}.`
|
|
818
|
-
);
|
|
822
|
+
throw await bootstrapResponseError(response, bootstrapUrl);
|
|
819
823
|
}
|
|
820
|
-
const body = await response
|
|
824
|
+
const body = await readBootstrapSuccessBody(response);
|
|
821
825
|
if (typeof body.authBaseUrl !== "string" || body.authBaseUrl.trim().length === 0) {
|
|
822
|
-
throw
|
|
826
|
+
throw bootstrapContractError(
|
|
823
827
|
"authBaseUrl",
|
|
824
828
|
"/v1/client/bootstrap returned no authBaseUrl."
|
|
825
829
|
);
|
|
826
830
|
}
|
|
827
831
|
if (typeof body.convexUrl !== "string" || body.convexUrl.trim().length === 0) {
|
|
828
|
-
throw
|
|
832
|
+
throw bootstrapContractError(
|
|
829
833
|
"convexUrl",
|
|
830
834
|
"/v1/client/bootstrap returned no convexUrl."
|
|
831
835
|
);
|
|
@@ -837,16 +841,13 @@ function makePublishableKeyTransport(config) {
|
|
|
837
841
|
return runtime;
|
|
838
842
|
})();
|
|
839
843
|
bootstrapPromise = attempt.catch((err) => {
|
|
844
|
+
const error = normalizeBootstrapThrownError(err);
|
|
840
845
|
bootstrapPromise = null;
|
|
841
846
|
lifecycle.setState({
|
|
842
847
|
status: "error",
|
|
843
|
-
error
|
|
844
|
-
code: "UNKNOWN",
|
|
845
|
-
message: "Bootstrap failed without a typed CapxulError.",
|
|
846
|
-
cause: err
|
|
847
|
-
})
|
|
848
|
+
error
|
|
848
849
|
});
|
|
849
|
-
throw
|
|
850
|
+
throw error;
|
|
850
851
|
});
|
|
851
852
|
return await bootstrapPromise;
|
|
852
853
|
}
|
|
@@ -857,6 +858,7 @@ function makePublishableKeyTransport(config) {
|
|
|
857
858
|
get convexUrl() {
|
|
858
859
|
return convexUrl;
|
|
859
860
|
},
|
|
861
|
+
ensureRuntime: ensureBootstrap,
|
|
860
862
|
fetch: async (path, init) => {
|
|
861
863
|
const resolved = await ensureBootstrap();
|
|
862
864
|
return await fetchImpl(resolveUrl(resolved.authBaseUrl, path), init);
|
|
@@ -867,7 +869,7 @@ function makePublishableKeyTransport(config) {
|
|
|
867
869
|
markAuthenticated: ({ dataClient: nextDataClient }) => {
|
|
868
870
|
const current = lifecycle.getState();
|
|
869
871
|
if (current.status !== "ready" && current.status !== "authenticated") {
|
|
870
|
-
throw
|
|
872
|
+
throw internalTransportError(
|
|
871
873
|
`markAuthenticated() called from status="${current.status}". Expected "ready" or "authenticated".`
|
|
872
874
|
);
|
|
873
875
|
}
|
|
@@ -889,6 +891,24 @@ function makePublishableKeyTransport(config) {
|
|
|
889
891
|
function stripTrailingSlash(url) {
|
|
890
892
|
return url.replace(/\/+$/, "");
|
|
891
893
|
}
|
|
894
|
+
function normalizeBootstrapUrl(url) {
|
|
895
|
+
const normalized = stripTrailingSlash(url.trim());
|
|
896
|
+
if (!isAbsoluteHttpUrl(normalized)) {
|
|
897
|
+
throw invalidConfigError(
|
|
898
|
+
"bootstrapUrl",
|
|
899
|
+
"publishable-key transport requires an absolute http(s) bootstrapUrl."
|
|
900
|
+
);
|
|
901
|
+
}
|
|
902
|
+
return normalized;
|
|
903
|
+
}
|
|
904
|
+
function isAbsoluteHttpUrl(url) {
|
|
905
|
+
try {
|
|
906
|
+
const parsed = new URL(url);
|
|
907
|
+
return parsed.protocol === "http:" || parsed.protocol === "https:";
|
|
908
|
+
} catch {
|
|
909
|
+
return false;
|
|
910
|
+
}
|
|
911
|
+
}
|
|
892
912
|
function resolveUrl(authBaseUrl, path) {
|
|
893
913
|
if (path.startsWith("http://") || path.startsWith("https://")) {
|
|
894
914
|
return path;
|
|
@@ -896,10 +916,142 @@ function resolveUrl(authBaseUrl, path) {
|
|
|
896
916
|
return `${authBaseUrl}${path}`;
|
|
897
917
|
}
|
|
898
918
|
function assertNever(value) {
|
|
899
|
-
throw
|
|
919
|
+
throw internalTransportError(
|
|
900
920
|
`Unhandled BrowserCapxulConfig.mode: ${String(value.mode)}.`
|
|
901
921
|
);
|
|
902
922
|
}
|
|
923
|
+
function invalidConfigError(field, reason) {
|
|
924
|
+
return new CapxulError({
|
|
925
|
+
code: "INVALID_INPUT",
|
|
926
|
+
message: `Invalid ${field}: ${reason}`,
|
|
927
|
+
details: { source: "sdk-config", field, reason }
|
|
928
|
+
});
|
|
929
|
+
}
|
|
930
|
+
function bootstrapContractError(field, message) {
|
|
931
|
+
return new CapxulError({
|
|
932
|
+
code: "INVALID_INPUT",
|
|
933
|
+
message,
|
|
934
|
+
details: {
|
|
935
|
+
source: "backend-bootstrap",
|
|
936
|
+
phase: "publishable-key-bootstrap",
|
|
937
|
+
field,
|
|
938
|
+
reason: message
|
|
939
|
+
}
|
|
940
|
+
});
|
|
941
|
+
}
|
|
942
|
+
function internalTransportError(reason) {
|
|
943
|
+
return new CapxulError({
|
|
944
|
+
code: "INTERNAL_ERROR",
|
|
945
|
+
message: `Internal error: ${reason}`,
|
|
946
|
+
details: { source: "sdk-transport", reason }
|
|
947
|
+
});
|
|
948
|
+
}
|
|
949
|
+
async function bootstrapResponseError(response, bootstrapUrl) {
|
|
950
|
+
const envelope = await readBootstrapErrorEnvelope(response);
|
|
951
|
+
const wireCode = readNonEmptyString(envelope?.error?.code);
|
|
952
|
+
const normalized = normalizeBootstrapErrorCode(wireCode);
|
|
953
|
+
const message = readNonEmptyString(envelope?.error?.message) ?? `${bootstrapUrl} failed with HTTP ${response.status}.`;
|
|
954
|
+
const backendDetails = readRecord(envelope?.error?.details);
|
|
955
|
+
return new CapxulError({
|
|
956
|
+
code: normalized.code,
|
|
957
|
+
message,
|
|
958
|
+
details: {
|
|
959
|
+
...backendDetails,
|
|
960
|
+
source: "backend-bootstrap",
|
|
961
|
+
phase: "publishable-key-bootstrap",
|
|
962
|
+
httpStatus: response.status,
|
|
963
|
+
...normalized.wireCode ? { wireCode: normalized.wireCode } : {}
|
|
964
|
+
},
|
|
965
|
+
operationId: readNonEmptyString(envelope?.error?.operationId),
|
|
966
|
+
correlationId: readNonEmptyString(envelope?.error?.correlationId),
|
|
967
|
+
retryable: typeof envelope?.error?.retryable === "boolean" ? envelope.error.retryable : void 0
|
|
968
|
+
});
|
|
969
|
+
}
|
|
970
|
+
async function readBootstrapErrorEnvelope(response) {
|
|
971
|
+
try {
|
|
972
|
+
const parsed = await response.json();
|
|
973
|
+
return typeof parsed === "object" && parsed !== null ? parsed : null;
|
|
974
|
+
} catch {
|
|
975
|
+
return null;
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
async function readBootstrapSuccessBody(response) {
|
|
979
|
+
try {
|
|
980
|
+
const parsed = await response.json();
|
|
981
|
+
return typeof parsed === "object" && parsed !== null ? parsed : {};
|
|
982
|
+
} catch {
|
|
983
|
+
throw bootstrapContractError(
|
|
984
|
+
"body",
|
|
985
|
+
"/v1/client/bootstrap returned invalid JSON."
|
|
986
|
+
);
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
function normalizeBootstrapThrownError(error) {
|
|
990
|
+
if (error instanceof CapxulError) return error;
|
|
991
|
+
return new CapxulError({
|
|
992
|
+
code: "NETWORK_ERROR",
|
|
993
|
+
message: "Publishable-key bootstrap network failure.",
|
|
994
|
+
cause: error,
|
|
995
|
+
details: {
|
|
996
|
+
source: "bootstrap-network",
|
|
997
|
+
phase: "publishable-key-bootstrap"
|
|
998
|
+
}
|
|
999
|
+
});
|
|
1000
|
+
}
|
|
1001
|
+
function normalizeBootstrapErrorCode(wireCode) {
|
|
1002
|
+
if (wireCode === "INTERNAL_SERVER_ERROR") {
|
|
1003
|
+
return { code: "INTERNAL_ERROR", wireCode };
|
|
1004
|
+
}
|
|
1005
|
+
if (wireCode && isCapxulErrorCode(wireCode)) {
|
|
1006
|
+
return { code: wireCode };
|
|
1007
|
+
}
|
|
1008
|
+
return wireCode ? { code: "UNKNOWN", wireCode } : { code: "UNKNOWN" };
|
|
1009
|
+
}
|
|
1010
|
+
var CAPXUL_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
1011
|
+
"NOT_AUTHENTICATED",
|
|
1012
|
+
"EMAIL_DELIVERY_FAILED",
|
|
1013
|
+
"PROFILE_NOT_FOUND",
|
|
1014
|
+
"SMART_ACCOUNT_MISSING",
|
|
1015
|
+
"PLAYER_NOT_FOUND",
|
|
1016
|
+
"ACCOUNT_NOT_FOUND",
|
|
1017
|
+
"PROVIDER_ERROR",
|
|
1018
|
+
"INVALID_INPUT",
|
|
1019
|
+
"ENV_MISSING",
|
|
1020
|
+
"NOT_IMPLEMENTED",
|
|
1021
|
+
"VERIFICATION_REQUIRED",
|
|
1022
|
+
"INSUFFICIENT_BALANCE",
|
|
1023
|
+
"INVALID_RECIPIENT",
|
|
1024
|
+
"TRANSACTION_FAILED",
|
|
1025
|
+
"RATE_LIMITED",
|
|
1026
|
+
"NETWORK_ERROR",
|
|
1027
|
+
"UNKNOWN",
|
|
1028
|
+
"PERMISSION_DENIED",
|
|
1029
|
+
"API_KEY_INVALID",
|
|
1030
|
+
"API_KEY_EXPIRED",
|
|
1031
|
+
"IDEMPOTENCY_CONFLICT",
|
|
1032
|
+
"NOT_FOUND",
|
|
1033
|
+
"OPERATION_CANCELED",
|
|
1034
|
+
"OPERATION_TIMEOUT",
|
|
1035
|
+
"ACTION_REQUIRED",
|
|
1036
|
+
"KYC_REQUIRED",
|
|
1037
|
+
"POLICY_DENIED",
|
|
1038
|
+
"SAFE_NOT_READY",
|
|
1039
|
+
"PROVIDER_UNAVAILABLE",
|
|
1040
|
+
"PROVIDER_REJECTED",
|
|
1041
|
+
"RECONCILIATION_FAILED",
|
|
1042
|
+
"INTERNAL_ERROR",
|
|
1043
|
+
"QUOTE_EXPIRED",
|
|
1044
|
+
"QUOTE_NOT_FOUND"
|
|
1045
|
+
]);
|
|
1046
|
+
function isCapxulErrorCode(value) {
|
|
1047
|
+
return CAPXUL_ERROR_CODES.has(value);
|
|
1048
|
+
}
|
|
1049
|
+
function readRecord(value) {
|
|
1050
|
+
return typeof value === "object" && value !== null ? value : null;
|
|
1051
|
+
}
|
|
1052
|
+
function readNonEmptyString(value) {
|
|
1053
|
+
return typeof value === "string" && value.trim().length > 0 ? value.trim() : null;
|
|
1054
|
+
}
|
|
903
1055
|
|
|
904
1056
|
// src/core/auth.ts
|
|
905
1057
|
function createAuthClient(config = {}) {
|
|
@@ -954,13 +1106,16 @@ function createAuthClient(config = {}) {
|
|
|
954
1106
|
email: signIn.user.email,
|
|
955
1107
|
token: signIn.token,
|
|
956
1108
|
convexJwt,
|
|
957
|
-
expiresAt: new Date(
|
|
1109
|
+
expiresAt: new Date(
|
|
1110
|
+
Date.now() + 30 * 24 * 60 * 60 * 1e3
|
|
1111
|
+
).toISOString()
|
|
958
1112
|
};
|
|
959
1113
|
sessionStore.set(session);
|
|
960
1114
|
if (config.auth?.createDataClient) {
|
|
961
1115
|
try {
|
|
962
1116
|
dataClient = await config.auth.createDataClient(session);
|
|
963
1117
|
mutableConfig(config).data = dataClient;
|
|
1118
|
+
transport.markAuthenticated({ dataClient });
|
|
964
1119
|
} catch (cause) {
|
|
965
1120
|
return [
|
|
966
1121
|
new CapxulError({
|
|
@@ -979,6 +1134,8 @@ function createAuthClient(config = {}) {
|
|
|
979
1134
|
sessionStore.clear();
|
|
980
1135
|
dataClient = null;
|
|
981
1136
|
mutableConfig(config).data = void 0;
|
|
1137
|
+
const transport = getTransport();
|
|
1138
|
+
transport?.clearAuth();
|
|
982
1139
|
return [null, void 0];
|
|
983
1140
|
},
|
|
984
1141
|
serviceTokenMint: async () => stub("auth.serviceTokenMint"),
|
|
@@ -1032,16 +1189,19 @@ async function postBetterAuth(transport, path, body, code, signal) {
|
|
|
1032
1189
|
body: JSON.stringify(body),
|
|
1033
1190
|
signal
|
|
1034
1191
|
});
|
|
1192
|
+
const text = await response.text();
|
|
1035
1193
|
if (!response.ok) {
|
|
1194
|
+
const parsedError = parseBetterAuthError(text);
|
|
1036
1195
|
return [
|
|
1037
1196
|
new CapxulError({
|
|
1038
|
-
code,
|
|
1039
|
-
message: `BetterAuth ${path} failed with HTTP ${response.status}
|
|
1197
|
+
code: parsedError.code ?? code,
|
|
1198
|
+
message: parsedError.message ?? `BetterAuth ${path} failed with HTTP ${response.status}.`,
|
|
1199
|
+
details: parsedError.details,
|
|
1200
|
+
retryable: parsedError.retryable
|
|
1040
1201
|
}),
|
|
1041
1202
|
null
|
|
1042
1203
|
];
|
|
1043
1204
|
}
|
|
1044
|
-
const text = await response.text();
|
|
1045
1205
|
return [null, text ? JSON.parse(text) : void 0];
|
|
1046
1206
|
} catch (cause) {
|
|
1047
1207
|
return [
|
|
@@ -1054,6 +1214,36 @@ async function postBetterAuth(transport, path, body, code, signal) {
|
|
|
1054
1214
|
];
|
|
1055
1215
|
}
|
|
1056
1216
|
}
|
|
1217
|
+
function parseBetterAuthError(text) {
|
|
1218
|
+
if (!text.trim()) {
|
|
1219
|
+
return {};
|
|
1220
|
+
}
|
|
1221
|
+
try {
|
|
1222
|
+
const body = JSON.parse(text);
|
|
1223
|
+
if (!body || typeof body !== "object") {
|
|
1224
|
+
return {};
|
|
1225
|
+
}
|
|
1226
|
+
const record = body;
|
|
1227
|
+
const nested = record.error && typeof record.error === "object" ? record.error : record;
|
|
1228
|
+
const code = typeof nested.code === "string" ? nested.code : void 0;
|
|
1229
|
+
const message = typeof nested.message === "string" ? nested.message : void 0;
|
|
1230
|
+
const details = nested.details && typeof nested.details === "object" ? nested.details : void 0;
|
|
1231
|
+
const correlationId = typeof nested.correlationId === "string" ? nested.correlationId : void 0;
|
|
1232
|
+
const retryable = typeof nested.retryable === "boolean" ? nested.retryable : void 0;
|
|
1233
|
+
return {
|
|
1234
|
+
code: isCapxulErrorCode2(code) ? code : void 0,
|
|
1235
|
+
message,
|
|
1236
|
+
details,
|
|
1237
|
+
correlationId,
|
|
1238
|
+
retryable
|
|
1239
|
+
};
|
|
1240
|
+
} catch {
|
|
1241
|
+
return {};
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
function isCapxulErrorCode2(code) {
|
|
1245
|
+
return code === "NOT_AUTHENTICATED" || code === "EMAIL_DELIVERY_FAILED" || code === "INVALID_INPUT" || code === "RATE_LIMITED" || code === "NETWORK_ERROR" || code === "API_KEY_INVALID" || code === "API_KEY_EXPIRED";
|
|
1246
|
+
}
|
|
1057
1247
|
async function exchangeConvexToken(transport, config, token, signal) {
|
|
1058
1248
|
const path = config.auth?.convexTokenUrl ?? "/convex/token";
|
|
1059
1249
|
try {
|
package/dist/index.d.cts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { S as Session, C as CapxulClient, A as AccountProvisionPersonalInput } from './client-
|
|
2
|
-
export { a as AccountsClient, b as ApiKeyCreateResult, c as ApiKeysClient, d as AuthClient, e as AuthSessionStore, B as BrowserCapxulConfig, f as CapxulAuthConfig, g as CapxulConfig, h as CapxulDataClient, i as CapxulFlowFactories, j as CapxulSigningConfig, D as DocumentsClient, E as ExternalAccountsClient, H as HttpTransport, L as LocalPrivateKeySignerProvider, M as MeClient, O as OperationsClient, k as OrgDocumentsClient, l as OrgPaymentsClient, m as OrgSafesClient, n as OrgTransfersClient, o as OrgTreasuryClient, p as OrgWithdrawalsClient, q as OrganizationsClient, P as PaymentsClient, r as SubAccountsClient, T as TokenTransfer, s as TokenTransferId, t as TokenTransfersClient, u as TokenTransfersListInput, v as TokenTransfersListPage, w as TokenTransfersRetrieveInput, x as TransfersClient, y as TransportRuntime, z as TransportState, V as VirtualAccountsClient, F as VirtualCardsClient, W as WebhookEndpointCreateResult, G as WebhookEndpointsClient, I as WebhookEventsClient, J as WithdrawalsClient, K as createCapxulClient, N as makeHttpTransport, Q as toTokenTransferId } from './client-
|
|
1
|
+
import { S as Session, C as CapxulClient, A as AccountProvisionPersonalInput } from './client-DDAVWtzJ.cjs';
|
|
2
|
+
export { a as AccountsClient, b as ApiKeyCreateResult, c as ApiKeysClient, d as AuthClient, e as AuthSessionStore, B as BrowserCapxulConfig, f as CapxulAuthConfig, g as CapxulConfig, h as CapxulDataClient, i as CapxulFlowFactories, j as CapxulSigningConfig, D as DocumentsClient, E as ExternalAccountsClient, H as HttpTransport, L as LocalPrivateKeySignerProvider, M as MeClient, O as OperationsClient, k as OrgDocumentsClient, l as OrgPaymentsClient, m as OrgSafesClient, n as OrgTransfersClient, o as OrgTreasuryClient, p as OrgWithdrawalsClient, q as OrganizationsClient, P as PaymentsClient, r as SubAccountsClient, T as TokenTransfer, s as TokenTransferId, t as TokenTransfersClient, u as TokenTransfersListInput, v as TokenTransfersListPage, w as TokenTransfersRetrieveInput, x as TransfersClient, y as TransportRuntime, z as TransportState, V as VirtualAccountsClient, F as VirtualCardsClient, W as WebhookEndpointCreateResult, G as WebhookEndpointsClient, I as WebhookEventsClient, J as WithdrawalsClient, K as createCapxulClient, N as makeHttpTransport, Q as toTokenTransferId } from './client-DDAVWtzJ.cjs';
|
|
3
3
|
import * as xstate from 'xstate';
|
|
4
4
|
import { E as Email, U as Username, O as OperationId, N as NextAction } from './next-action-DkrwXYay.cjs';
|
|
5
5
|
export { A as AccountId, a as ApiKeyId, B as BalanceLedgerEntryId, C as CorrelationId, D as DocumentId, b as ExternalAccountId, K as KybProfileId, c as KycProfileId, M as MemberId, d as OrganizationId, P as PaymentId, e as PhoneNumber, S as SafeId, f as SubAccountId, T as TransactionIntentId, g as TransferId, h as TreasuryId, V as VirtualAccountId, i as VirtualCardId, W as WebhookEndpointId, j as WebhookEventId, k as WithdrawalId, t as toAccountId, l as toApiKeyId, m as toBalanceLedgerEntryId, n as toDocumentId, o as toEmail, p as toExternalAccountId, q as toKybProfileId, r as toKycProfileId, s as toMemberId, u as toOperationId, v as toOrganizationId, w as toPaymentId, x as toPhoneNumber, y as toSafeId, z as toSubAccountId, F as toTransferId, G as toTreasuryId, H as toUsername, I as toVirtualAccountId, J as toVirtualCardId, L as toWebhookEndpointId, Q as toWebhookEventId, R as toWithdrawalId } from './next-action-DkrwXYay.cjs';
|
|
6
6
|
import { C as CapxulError$1, a as CapxulErrorCode$1 } from './errors-GgKrSUKp.cjs';
|
|
7
7
|
export { b as CapxulErrorDetails, c as CapxulErrorEnvelope, d as CapxulResult } from './errors-GgKrSUKp.cjs';
|
|
8
|
-
import { A as Account } from './types-
|
|
9
|
-
export { a as AccountLookupResult, b as ApiKey, c as ApiKeyEnvironment, d as ApiKeyType, B as BalanceLedgerEntry, e as BankStatementDocument, C as CreatePaymentResult, f as CreateTransferResult, g as CreateWithdrawalResult, D as Document, E as ExternalAccount, h as ExternalAccountKind, I as InvoiceDocument, K as KybProfile, i as KycProfile, j as KycUploadDocument, L as List, M as Member, k as Money, O as Operation, l as OperationStatus, m as OperationSummary, n as Organization, P as PageInfo, o as Payment, p as PaymentParty, q as PaymentStatus, r as PayrollRunDocument, s as PayrollScheduleDocument, R as ReceiptDocument, S as Safe, t as Scope, u as Settlement, v as SubAccount, w as SubAccountOwnerKind, T as TaxFormDocument, x as TimestampIso, y as Transfer, z as TransferCustody, F as TransferEndpoint, G as TransferFx, H as TransferStatus, J as Treasury, U as UserIdentifier, V as VirtualAccount, N as VirtualAccountOwnerKind, Q as VirtualCard, W as VirtualCardLimits, X as VirtualCardOwnerKind, Y as WebhookEndpoint, Z as WebhookEvent, _ as Withdrawal, $ as WithdrawalStatus } from './types-
|
|
8
|
+
import { A as Account } from './types-hfcOE7Oi.cjs';
|
|
9
|
+
export { a as AccountLookupResult, b as ApiKey, c as ApiKeyEnvironment, d as ApiKeyType, B as BalanceLedgerEntry, e as BankStatementDocument, C as CreatePaymentResult, f as CreateTransferResult, g as CreateWithdrawalResult, D as Document, E as ExternalAccount, h as ExternalAccountKind, I as InvoiceDocument, K as KybProfile, i as KycProfile, j as KycUploadDocument, L as List, M as Member, k as Money, O as Operation, l as OperationStatus, m as OperationSummary, n as Organization, P as PageInfo, o as Payment, p as PaymentParty, q as PaymentStatus, r as PayrollRunDocument, s as PayrollScheduleDocument, R as ReceiptDocument, S as Safe, t as Scope, u as Settlement, v as SubAccount, w as SubAccountOwnerKind, T as TaxFormDocument, x as TimestampIso, y as Transfer, z as TransferCustody, F as TransferEndpoint, G as TransferFx, H as TransferStatus, J as Treasury, U as UserIdentifier, V as VirtualAccount, N as VirtualAccountOwnerKind, Q as VirtualCard, W as VirtualCardLimits, X as VirtualCardOwnerKind, Y as WebhookEndpoint, Z as WebhookEvent, _ as Withdrawal, $ as WithdrawalStatus } from './types-hfcOE7Oi.cjs';
|
|
10
10
|
import { Account as Account$1 } from 'viem';
|
|
11
11
|
export { WebhookVerificationOptions, WebhookVerificationResult, verifyWebhook } from './webhooks.cjs';
|
|
12
|
-
import '@repo/api-contract/gen/types';
|
|
13
12
|
|
|
14
13
|
/**
|
|
15
14
|
* Unified error type used across the entire stack: backend, SDK, and frontend.
|
|
@@ -119,7 +118,7 @@ declare function createAuthFlowMachine(client: CapxulClient): xstate.StateMachin
|
|
|
119
118
|
} | {
|
|
120
119
|
type: "trackSignedOut";
|
|
121
120
|
params: unknown;
|
|
122
|
-
}, never, never, "
|
|
121
|
+
}, never, never, "error" | "idle" | "sending_otp" | "otp_requested" | "verifying" | "authenticated" | "signing_out", string, xstate.NonReducibleUnknown, xstate.NonReducibleUnknown, xstate.EventObject, xstate.MetaObject, {
|
|
123
122
|
id: "auth";
|
|
124
123
|
states: {
|
|
125
124
|
readonly idle: {};
|
|
@@ -219,7 +218,7 @@ declare function createProvisioningMachine(client: CapxulClient): xstate.StateMa
|
|
|
219
218
|
}, {
|
|
220
219
|
type: "hasInput";
|
|
221
220
|
params: unknown;
|
|
222
|
-
}, never, "
|
|
221
|
+
}, never, "done" | "error" | "idle" | "starting" | "running", string, {
|
|
223
222
|
readonly input: AccountProvisionPersonalInput;
|
|
224
223
|
}, {
|
|
225
224
|
readonly account: Account;
|
|
@@ -327,7 +326,7 @@ declare function createOnboardingFlowMachine(client: CapxulClient): xstate.State
|
|
|
327
326
|
}, {
|
|
328
327
|
type: "hasInput";
|
|
329
328
|
params: unknown;
|
|
330
|
-
}, never, "
|
|
329
|
+
}, never, "done" | "error" | "idle" | "starting" | "running", string, {
|
|
331
330
|
readonly input: AccountProvisionPersonalInput;
|
|
332
331
|
}, {
|
|
333
332
|
readonly account: Account;
|
|
@@ -369,7 +368,7 @@ declare function createOnboardingFlowMachine(client: CapxulClient): xstate.State
|
|
|
369
368
|
}, {
|
|
370
369
|
type: "hasInput";
|
|
371
370
|
params: unknown;
|
|
372
|
-
}, never, "
|
|
371
|
+
}, never, "done" | "error" | "idle" | "starting" | "running", string, {
|
|
373
372
|
readonly input: AccountProvisionPersonalInput;
|
|
374
373
|
}, {
|
|
375
374
|
readonly account: Account;
|
|
@@ -439,7 +438,7 @@ declare function createOnboardingFlowMachine(client: CapxulClient): xstate.State
|
|
|
439
438
|
} | {
|
|
440
439
|
type: "childReportedError";
|
|
441
440
|
params: unknown;
|
|
442
|
-
}, never, "
|
|
441
|
+
}, never, "error" | "provisioning" | "profile" | "complete" | "action_required", string, xstate.NonReducibleUnknown, xstate.NonReducibleUnknown, xstate.EventObject, xstate.MetaObject, {
|
|
443
442
|
id: "onboarding";
|
|
444
443
|
states: {
|
|
445
444
|
readonly profile: {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { S as Session, C as CapxulClient, A as AccountProvisionPersonalInput } from './client-
|
|
2
|
-
export { a as AccountsClient, b as ApiKeyCreateResult, c as ApiKeysClient, d as AuthClient, e as AuthSessionStore, B as BrowserCapxulConfig, f as CapxulAuthConfig, g as CapxulConfig, h as CapxulDataClient, i as CapxulFlowFactories, j as CapxulSigningConfig, D as DocumentsClient, E as ExternalAccountsClient, H as HttpTransport, L as LocalPrivateKeySignerProvider, M as MeClient, O as OperationsClient, k as OrgDocumentsClient, l as OrgPaymentsClient, m as OrgSafesClient, n as OrgTransfersClient, o as OrgTreasuryClient, p as OrgWithdrawalsClient, q as OrganizationsClient, P as PaymentsClient, r as SubAccountsClient, T as TokenTransfer, s as TokenTransferId, t as TokenTransfersClient, u as TokenTransfersListInput, v as TokenTransfersListPage, w as TokenTransfersRetrieveInput, x as TransfersClient, y as TransportRuntime, z as TransportState, V as VirtualAccountsClient, F as VirtualCardsClient, W as WebhookEndpointCreateResult, G as WebhookEndpointsClient, I as WebhookEventsClient, J as WithdrawalsClient, K as createCapxulClient, N as makeHttpTransport, Q as toTokenTransferId } from './client-
|
|
1
|
+
import { S as Session, C as CapxulClient, A as AccountProvisionPersonalInput } from './client-ByzDfG98.js';
|
|
2
|
+
export { a as AccountsClient, b as ApiKeyCreateResult, c as ApiKeysClient, d as AuthClient, e as AuthSessionStore, B as BrowserCapxulConfig, f as CapxulAuthConfig, g as CapxulConfig, h as CapxulDataClient, i as CapxulFlowFactories, j as CapxulSigningConfig, D as DocumentsClient, E as ExternalAccountsClient, H as HttpTransport, L as LocalPrivateKeySignerProvider, M as MeClient, O as OperationsClient, k as OrgDocumentsClient, l as OrgPaymentsClient, m as OrgSafesClient, n as OrgTransfersClient, o as OrgTreasuryClient, p as OrgWithdrawalsClient, q as OrganizationsClient, P as PaymentsClient, r as SubAccountsClient, T as TokenTransfer, s as TokenTransferId, t as TokenTransfersClient, u as TokenTransfersListInput, v as TokenTransfersListPage, w as TokenTransfersRetrieveInput, x as TransfersClient, y as TransportRuntime, z as TransportState, V as VirtualAccountsClient, F as VirtualCardsClient, W as WebhookEndpointCreateResult, G as WebhookEndpointsClient, I as WebhookEventsClient, J as WithdrawalsClient, K as createCapxulClient, N as makeHttpTransport, Q as toTokenTransferId } from './client-ByzDfG98.js';
|
|
3
3
|
import * as xstate from 'xstate';
|
|
4
4
|
import { E as Email, U as Username, O as OperationId, N as NextAction } from './next-action-DkrwXYay.js';
|
|
5
5
|
export { A as AccountId, a as ApiKeyId, B as BalanceLedgerEntryId, C as CorrelationId, D as DocumentId, b as ExternalAccountId, K as KybProfileId, c as KycProfileId, M as MemberId, d as OrganizationId, P as PaymentId, e as PhoneNumber, S as SafeId, f as SubAccountId, T as TransactionIntentId, g as TransferId, h as TreasuryId, V as VirtualAccountId, i as VirtualCardId, W as WebhookEndpointId, j as WebhookEventId, k as WithdrawalId, t as toAccountId, l as toApiKeyId, m as toBalanceLedgerEntryId, n as toDocumentId, o as toEmail, p as toExternalAccountId, q as toKybProfileId, r as toKycProfileId, s as toMemberId, u as toOperationId, v as toOrganizationId, w as toPaymentId, x as toPhoneNumber, y as toSafeId, z as toSubAccountId, F as toTransferId, G as toTreasuryId, H as toUsername, I as toVirtualAccountId, J as toVirtualCardId, L as toWebhookEndpointId, Q as toWebhookEventId, R as toWithdrawalId } from './next-action-DkrwXYay.js';
|
|
6
6
|
import { C as CapxulError$1, a as CapxulErrorCode$1 } from './errors-QHD5Tlok.js';
|
|
7
7
|
export { b as CapxulErrorDetails, c as CapxulErrorEnvelope, d as CapxulResult } from './errors-QHD5Tlok.js';
|
|
8
|
-
import { A as Account } from './types-
|
|
9
|
-
export { a as AccountLookupResult, b as ApiKey, c as ApiKeyEnvironment, d as ApiKeyType, B as BalanceLedgerEntry, e as BankStatementDocument, C as CreatePaymentResult, f as CreateTransferResult, g as CreateWithdrawalResult, D as Document, E as ExternalAccount, h as ExternalAccountKind, I as InvoiceDocument, K as KybProfile, i as KycProfile, j as KycUploadDocument, L as List, M as Member, k as Money, O as Operation, l as OperationStatus, m as OperationSummary, n as Organization, P as PageInfo, o as Payment, p as PaymentParty, q as PaymentStatus, r as PayrollRunDocument, s as PayrollScheduleDocument, R as ReceiptDocument, S as Safe, t as Scope, u as Settlement, v as SubAccount, w as SubAccountOwnerKind, T as TaxFormDocument, x as TimestampIso, y as Transfer, z as TransferCustody, F as TransferEndpoint, G as TransferFx, H as TransferStatus, J as Treasury, U as UserIdentifier, V as VirtualAccount, N as VirtualAccountOwnerKind, Q as VirtualCard, W as VirtualCardLimits, X as VirtualCardOwnerKind, Y as WebhookEndpoint, Z as WebhookEvent, _ as Withdrawal, $ as WithdrawalStatus } from './types-
|
|
8
|
+
import { A as Account } from './types-PM4AQRLP.js';
|
|
9
|
+
export { a as AccountLookupResult, b as ApiKey, c as ApiKeyEnvironment, d as ApiKeyType, B as BalanceLedgerEntry, e as BankStatementDocument, C as CreatePaymentResult, f as CreateTransferResult, g as CreateWithdrawalResult, D as Document, E as ExternalAccount, h as ExternalAccountKind, I as InvoiceDocument, K as KybProfile, i as KycProfile, j as KycUploadDocument, L as List, M as Member, k as Money, O as Operation, l as OperationStatus, m as OperationSummary, n as Organization, P as PageInfo, o as Payment, p as PaymentParty, q as PaymentStatus, r as PayrollRunDocument, s as PayrollScheduleDocument, R as ReceiptDocument, S as Safe, t as Scope, u as Settlement, v as SubAccount, w as SubAccountOwnerKind, T as TaxFormDocument, x as TimestampIso, y as Transfer, z as TransferCustody, F as TransferEndpoint, G as TransferFx, H as TransferStatus, J as Treasury, U as UserIdentifier, V as VirtualAccount, N as VirtualAccountOwnerKind, Q as VirtualCard, W as VirtualCardLimits, X as VirtualCardOwnerKind, Y as WebhookEndpoint, Z as WebhookEvent, _ as Withdrawal, $ as WithdrawalStatus } from './types-PM4AQRLP.js';
|
|
10
10
|
import { Account as Account$1 } from 'viem';
|
|
11
11
|
export { WebhookVerificationOptions, WebhookVerificationResult, verifyWebhook } from './webhooks.js';
|
|
12
|
-
import '@repo/api-contract/gen/types';
|
|
13
12
|
|
|
14
13
|
/**
|
|
15
14
|
* Unified error type used across the entire stack: backend, SDK, and frontend.
|
|
@@ -119,7 +118,7 @@ declare function createAuthFlowMachine(client: CapxulClient): xstate.StateMachin
|
|
|
119
118
|
} | {
|
|
120
119
|
type: "trackSignedOut";
|
|
121
120
|
params: unknown;
|
|
122
|
-
}, never, never, "
|
|
121
|
+
}, never, never, "error" | "idle" | "sending_otp" | "otp_requested" | "verifying" | "authenticated" | "signing_out", string, xstate.NonReducibleUnknown, xstate.NonReducibleUnknown, xstate.EventObject, xstate.MetaObject, {
|
|
123
122
|
id: "auth";
|
|
124
123
|
states: {
|
|
125
124
|
readonly idle: {};
|
|
@@ -219,7 +218,7 @@ declare function createProvisioningMachine(client: CapxulClient): xstate.StateMa
|
|
|
219
218
|
}, {
|
|
220
219
|
type: "hasInput";
|
|
221
220
|
params: unknown;
|
|
222
|
-
}, never, "
|
|
221
|
+
}, never, "done" | "error" | "idle" | "starting" | "running", string, {
|
|
223
222
|
readonly input: AccountProvisionPersonalInput;
|
|
224
223
|
}, {
|
|
225
224
|
readonly account: Account;
|
|
@@ -327,7 +326,7 @@ declare function createOnboardingFlowMachine(client: CapxulClient): xstate.State
|
|
|
327
326
|
}, {
|
|
328
327
|
type: "hasInput";
|
|
329
328
|
params: unknown;
|
|
330
|
-
}, never, "
|
|
329
|
+
}, never, "done" | "error" | "idle" | "starting" | "running", string, {
|
|
331
330
|
readonly input: AccountProvisionPersonalInput;
|
|
332
331
|
}, {
|
|
333
332
|
readonly account: Account;
|
|
@@ -369,7 +368,7 @@ declare function createOnboardingFlowMachine(client: CapxulClient): xstate.State
|
|
|
369
368
|
}, {
|
|
370
369
|
type: "hasInput";
|
|
371
370
|
params: unknown;
|
|
372
|
-
}, never, "
|
|
371
|
+
}, never, "done" | "error" | "idle" | "starting" | "running", string, {
|
|
373
372
|
readonly input: AccountProvisionPersonalInput;
|
|
374
373
|
}, {
|
|
375
374
|
readonly account: Account;
|
|
@@ -439,7 +438,7 @@ declare function createOnboardingFlowMachine(client: CapxulClient): xstate.State
|
|
|
439
438
|
} | {
|
|
440
439
|
type: "childReportedError";
|
|
441
440
|
params: unknown;
|
|
442
|
-
}, never, "
|
|
441
|
+
}, never, "error" | "provisioning" | "profile" | "complete" | "action_required", string, xstate.NonReducibleUnknown, xstate.NonReducibleUnknown, xstate.EventObject, xstate.MetaObject, {
|
|
443
442
|
id: "onboarding";
|
|
444
443
|
states: {
|
|
445
444
|
readonly profile: {};
|