@capxul/sdk 2.8.0 → 2.8.2
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/dist/{InMemoryAuthCacheAdapter-FptQ2p7C.mjs → InMemoryAuthCacheAdapter-BrEN-men.mjs} +56 -5
- package/dist/{create-capxul-client-YSN2yN8m.mjs → create-capxul-client-BKJHefmA.mjs} +361 -434
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +641 -27
- package/dist/node/index.d.mts +1 -1
- package/dist/node/index.mjs +1 -1
- package/dist/{observation-YhuU8yQX.d.mts → observation-D-oCDlMS.d.mts} +32 -3
- package/dist/{signer-xGhV5Q7i.d.mts → signer-BdDgF200.d.mts} +24 -1
- package/dist/testing/index.d.mts +1 -1
- package/dist/testing/index.mjs +2 -2
- package/package.json +5 -5
package/dist/{InMemoryAuthCacheAdapter-FptQ2p7C.mjs → InMemoryAuthCacheAdapter-BrEN-men.mjs}
RENAMED
|
@@ -12,6 +12,7 @@ const FAILURE_MODES = [
|
|
|
12
12
|
"stale-openfort-cache",
|
|
13
13
|
"app-env-allowlist",
|
|
14
14
|
"no-secure-context",
|
|
15
|
+
"signer-not-ready",
|
|
15
16
|
"rate-limited",
|
|
16
17
|
"timeout",
|
|
17
18
|
"upstream-down",
|
|
@@ -225,6 +226,7 @@ const EXPECTED_OPERATION_OUTCOMES = /* @__PURE__ */ new Set([
|
|
|
225
226
|
"INVALID_INPUT",
|
|
226
227
|
"NOT_AUTHENTICATED",
|
|
227
228
|
"SMART_ACCOUNT_MISSING",
|
|
229
|
+
"ACCOUNT_CLAIMED_BY_OTHER_SIGNER",
|
|
228
230
|
"CANCELLED",
|
|
229
231
|
"SIGNER_REJECTED",
|
|
230
232
|
"VERIFICATION_REQUIRED",
|
|
@@ -283,6 +285,46 @@ function compactErrorOptions(options) {
|
|
|
283
285
|
if (options.chain !== void 0) result.chain = options.chain;
|
|
284
286
|
return result;
|
|
285
287
|
}
|
|
288
|
+
const NETWORK_DETAIL_LABEL_RE = /^[A-Za-z][A-Za-z0-9_.-]{0,63}$/u;
|
|
289
|
+
const NETWORK_TARGET_HOST_RE = /^[A-Za-z0-9.[\]:-]{1,253}$/u;
|
|
290
|
+
const DOCUMENT_VISIBILITY = /* @__PURE__ */ new Set(["hidden", "visible"]);
|
|
291
|
+
const BROWSER_LIFECYCLE_EVENTS = /* @__PURE__ */ new Set([
|
|
292
|
+
"visibility-visible",
|
|
293
|
+
"visibility-hidden",
|
|
294
|
+
"pagehide",
|
|
295
|
+
"pageshow",
|
|
296
|
+
"online",
|
|
297
|
+
"offline"
|
|
298
|
+
]);
|
|
299
|
+
function networkErrorDetails(operation, options) {
|
|
300
|
+
const details = { operation };
|
|
301
|
+
if (options === void 0) return details;
|
|
302
|
+
if (typeof options.provider === "string" && NETWORK_DETAIL_LABEL_RE.test(options.provider)) details.provider = options.provider;
|
|
303
|
+
if (typeof options.target_host === "string" && NETWORK_TARGET_HOST_RE.test(options.target_host)) details.target_host = options.target_host;
|
|
304
|
+
if (isFailureMode(options.failure_mode)) details.failure_mode = options.failure_mode;
|
|
305
|
+
if (options.reason === "connection-lost-in-flight") details.reason = options.reason;
|
|
306
|
+
if (typeof options.connection_id === "string" && NETWORK_DETAIL_LABEL_RE.test(options.connection_id)) details.connection_id = options.connection_id;
|
|
307
|
+
for (const key of [
|
|
308
|
+
"connection_count",
|
|
309
|
+
"connection_retries",
|
|
310
|
+
"close_code",
|
|
311
|
+
"ms_since_browser_event"
|
|
312
|
+
]) {
|
|
313
|
+
const value = options[key];
|
|
314
|
+
if (typeof value === "number" && Number.isSafeInteger(value) && value >= 0 && (key !== "close_code" || value <= 4999)) details[key] = value;
|
|
315
|
+
}
|
|
316
|
+
for (const key of [
|
|
317
|
+
"close_was_clean",
|
|
318
|
+
"close_reason_present",
|
|
319
|
+
"navigator_online"
|
|
320
|
+
]) {
|
|
321
|
+
const value = options[key];
|
|
322
|
+
if (typeof value === "boolean") details[key] = value;
|
|
323
|
+
}
|
|
324
|
+
if (DOCUMENT_VISIBILITY.has(options.document_visibility ?? "")) details.document_visibility = options.document_visibility;
|
|
325
|
+
if (BROWSER_LIFECYCLE_EVENTS.has(options.last_browser_event ?? "")) details.last_browser_event = options.last_browser_event;
|
|
326
|
+
return details;
|
|
327
|
+
}
|
|
286
328
|
const Errors = {
|
|
287
329
|
notAuthenticated: (message, opts) => new CapxulError("NOT_AUTHENTICATED", message ?? "Not authenticated", opts?.failure_mode ? { details: { failure_mode: opts.failure_mode } } : void 0),
|
|
288
330
|
emailDeliveryFailed: (detail) => new CapxulError("EMAIL_DELIVERY_FAILED", "Failed to send email", { details: { detail } }),
|
|
@@ -381,10 +423,14 @@ const Errors = {
|
|
|
381
423
|
}
|
|
382
424
|
}),
|
|
383
425
|
rateLimited: (details) => new CapxulError("RATE_LIMITED", "Rate limit exceeded", details === void 0 ? void 0 : { details: { ...details } }),
|
|
384
|
-
networkError: (operation, cause) =>
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
426
|
+
networkError: (operation, cause, opts) => {
|
|
427
|
+
const mode = isFailureMode(opts?.failure_mode) ? opts.failure_mode : void 0;
|
|
428
|
+
return new CapxulError("NETWORK_ERROR", `Network error during ${operation}`, {
|
|
429
|
+
cause,
|
|
430
|
+
details: networkErrorDetails(operation, opts),
|
|
431
|
+
...mode === void 0 ? {} : { mode }
|
|
432
|
+
});
|
|
433
|
+
},
|
|
388
434
|
unknown: (cause) => new CapxulError("UNKNOWN", "Unknown error", { cause }),
|
|
389
435
|
otpExpired: (details) => new CapxulError("OTP_EXPIRED", "Verification code has expired. Request a new one.", details === void 0 ? void 0 : { details: { ...details } }),
|
|
390
436
|
signerRejected: (details) => new CapxulError("SIGNER_REJECTED", "Signer rejected the request.", {
|
|
@@ -394,6 +440,11 @@ const Errors = {
|
|
|
394
440
|
reason: details.reason
|
|
395
441
|
}
|
|
396
442
|
}),
|
|
443
|
+
superseded: (details) => new CapxulError("SUPERSEDED", "Operation was superseded.", { details: {
|
|
444
|
+
operation: details.operation,
|
|
445
|
+
reason: details.reason,
|
|
446
|
+
...details.executionId === void 0 ? {} : { executionId: details.executionId }
|
|
447
|
+
} }),
|
|
397
448
|
cancelled: (details) => new CapxulError("CANCELLED", "Operation was cancelled.", details === void 0 ? void 0 : { details: { ...details } }),
|
|
398
449
|
/**
|
|
399
450
|
* Method called from a flow state where its precondition fails (TA16). The
|
|
@@ -709,4 +760,4 @@ Layer.effect(AuthCachePortTag, Effect.sync(() => new InMemoryAuthCacheAdapter())
|
|
|
709
760
|
cause
|
|
710
761
|
}))));
|
|
711
762
|
//#endregion
|
|
712
|
-
export { toPartyId as A, Errors as B, toDurationMs as C, toJwtToken as D, toEpochSeconds as E, toSessionToken as F,
|
|
763
|
+
export { toPartyId as A, Errors as B, toDurationMs as C, toJwtToken as D, toEpochSeconds as E, toSessionToken as F, decodeChainCause as G, CHAIN_UPSTREAMS as H, decodeConvexError as I, revertSummaryText as J, failureFingerprint as K, CAPXUL_ERROR_CODES as L, toPayrollRunId as M, toPublishableKey as N, toKycTier as O, toRoleKey as P, CapxulError as R, toCurrencyCode as S, toEpochMs as T, FAILURE_MODES as U, isCapxulError as V, chainCauseProperties as W, toAppId as _, AuthCacheError as a, toChainId as b, BYTES32_RE as c, WEI_RE as d, ZERO_BYTES32 as f, toAllowedOrigin as g, toAddress as h, parseCachedJwt as i, toPayrollGroupId as j, toOrgId as k, EVM_ADDRESS_RE as l, toAccountId as m, BrowserAuthCacheAdapter as n, AuthCachePortTag as o, currencySymbolFor as p, isFailureMode as q, parseAuthSession as r, APP_ID_RE as s, InMemoryAuthCacheAdapter as t, SUPPORTED_CURRENCY_CODES as u, toAuthUserId as v, toEmail as w, toCountryCode as x, toBudgetId as y, EXPECTED_OPERATION_OUTCOMES as z };
|