@capxul/sdk 4.20.0-beta.31 → 4.20.0-beta.33
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/README.md +23 -0
- package/dist/{access-B-2qmxF_.mjs → access-l_ci38yt.mjs} +1671 -337
- package/dist/{index-DidkO1aY.d.mts → index-VeQh7FNW.d.mts} +5615 -839
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +3 -3
- package/dist/node/index.d.mts +1 -1
- package/dist/node/index.mjs +1 -1
- package/dist/{organizations-wucUfgJr.mjs → organizations-UEg_C-_v.mjs} +159 -3
- package/dist/{permission-approvals-BLI_uadD.mjs → permission-approvals-vDZJpy8H.mjs} +2 -2
- package/dist/{production-2L76NWS5.mjs → production-BzEOaP6l.mjs} +249 -110
- package/dist/testing/index.d.mts +1 -1
- package/dist/testing/index.mjs +2 -2
- package/package.json +5 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as deserializeCapxulError, n as makeOrgMethods,
|
|
2
|
-
import {
|
|
1
|
+
import { c as OrgPortTag, l as deserializeCapxulError, n as makeOrgMethods, r as makeBankingMethods, s as ConvexOrganizationAdapter, t as ConvexOrganizationSetupAdapter } from "./organizations-UEg_C-_v.mjs";
|
|
2
|
+
import { A as registerProductTelemetryInvocation, An as onboardings, B as makePaymentsMethods, Bi as FAILURE_MODES, Br as publicIdentityFailure, C as AccountReadPortTag, Ci as AuthClientPortTag, D as convexCallErrorFromCapxul, Dn as normalizeCapxulOperation, E as ConvexCallPortTag, En as isCapxulOperation, Er as ChainIdSchema, Ft as callOperation, Gi as AuthCachePortTag, Gr as runCapxulEffect, Gt as withCapturedAttemptContext, H as makeDestinationsMethods, Hi as isRecord, Hr as runPortEffect, Ht as observeFailedResult, It as asCapxulError, Jn as ORGANIZATION_SETUP_STATUSES, K as makeTargetsMethods, L as makeAccountMethods, Li as Errors, Lt as toPublicError, M as makeApprovalsMethods, Mr as isEvmAddress, Mt as BASE_SEPOLIA_CHAIN_ID, Ni as toAuthUserId, Nr as toAddress, On as OPERATIONS, Ot as normalizeSafeSaltEmail, Pi as toEmail, Qr as CAPXUL_ERROR_CODES, Qt as version, Ri as CapxulError, Rr as makeAuthMethods, Rt as failureDetail, Si as AuthClientError, Sn as CLI_INVOCATION_KINDS, T as TelemetryPortTag, Ti as globalLocalStorage, Tn as CAPXUL_OPERATIONS, Ui as readField, Un as setups, Ur as sessionFromActor, Ut as observeSdkClient, Vi as isFailureMode, Vr as runIdentityFacade, Vt as postHogFailureObservation, W as makeCheckoutMethods, Wt as observationContextProps, Xn as decodeChainCause, Xr as toCapxulResult, Zr as formatTraceparent, _i as isCredentialField, _n as validateHandle, an as openfortSignerNotReadyCode, bi as toPublishableKey, bn as CLI_CAPABILITIES, br as DurationMsSchema, c as makePaymentDocumentsMethods, ci as BetterAuthNodeLayer, cr as images, d as SmartAccountPortTag, di as attachInvocationObservation, dn as toCountryCode, ei as ActorFailure, en as UNOBSERVABLE_SIGNER_STATUS, fi as copyInvocationObservation, fn as toKycTier, g as ConvexAccountLayer, gi as redactUrlSecrets, h as makeAccountsMethods, hi as redactSecrets, hn as toHandle, ii as SystemClockLayer, in as isSignerNotReadySignal, ji as toEpochMs, k as bindProductTelemetryInvocation, kn as details, l as makeSmartAccountMethods, li as BetterAuthBrowserLayer, ln as makeCurrentUserMethods, m as PonderIndexerAdapter, mi as sanitizeObservationContext, n as bootIdentityFlow, oi as ClockPortTag, on as recoverRawDigestSigner, or as diagnostics, p as makeHoldingsMethods, pi as readInvocationObservation, pn as toTesterKind, pr as isBytes32, q as makeVerificationMethods, qn as ORGANIZATION_SETUP_REASONS, r as makeMeMethods, rn as isEcdsaSignatureHex, s as makeActivityMethods, sn as signerFailure, sr as AppIdSchema, t as executeIdentityProductObservation, ti as carryInvocationParentSpan, tn as causeChain, u as ConvexSmartAccountLayer, ui as observationRequestHeaders, un as makeClientRequestMethods, vi as toAllowedOrigin, wi as detectAuthCacheAdapter, wn as stampTelemetryEnvelope, xn as CLI_COMMAND_NAMES, xr as EpochMsSchema, yn as redactTelemetryProps, zi as isCapxulError, zr as askIdentity, zt as failureEvidenceProps } from "./access-l_ci38yt.mjs";
|
|
3
3
|
import { Cause, Clock, Context, Data, Deferred, Duration, Effect, Exit, FiberSet, Layer, Logger, Metric, Option, Predicate, References, Result, Schedule, Schema, SchemaIssue, SchemaParser, Scope, Stream, Tracer } from "effect";
|
|
4
4
|
import { getFunctionName } from "convex/server";
|
|
5
5
|
import { keccak256, stringToHex } from "viem";
|
|
@@ -797,6 +797,76 @@ function devPrivateKeySigner(input) {
|
|
|
797
797
|
};
|
|
798
798
|
}
|
|
799
799
|
//#endregion
|
|
800
|
+
//#region ../observability/src/devtools.ts
|
|
801
|
+
/** Local inspection is an explicit host choice, independent of remote telemetry. */
|
|
802
|
+
function validateDevToolsUrl(value) {
|
|
803
|
+
const url = new URL(value);
|
|
804
|
+
if (!["ws:", "wss:"].includes(url.protocol) || ![
|
|
805
|
+
"localhost",
|
|
806
|
+
"127.0.0.1",
|
|
807
|
+
"[::1]",
|
|
808
|
+
"host.docker.internal"
|
|
809
|
+
].includes(url.hostname) || url.username !== "" || url.password !== "" || url.search !== "" || url.hash !== "") throw new TypeError("devToolsUrl must be a local WebSocket URL without credentials");
|
|
810
|
+
return url.href;
|
|
811
|
+
}
|
|
812
|
+
function localSpan(delegate) {
|
|
813
|
+
const attributes = new Map(delegate.attributes);
|
|
814
|
+
let status = delegate.status;
|
|
815
|
+
return {
|
|
816
|
+
_tag: "Span",
|
|
817
|
+
name: delegate.name,
|
|
818
|
+
spanId: delegate.spanId,
|
|
819
|
+
traceId: delegate.traceId,
|
|
820
|
+
parent: delegate.parent,
|
|
821
|
+
annotations: delegate.annotations,
|
|
822
|
+
sampled: delegate.sampled,
|
|
823
|
+
kind: delegate.kind,
|
|
824
|
+
attributes,
|
|
825
|
+
get status() {
|
|
826
|
+
return status;
|
|
827
|
+
},
|
|
828
|
+
get links() {
|
|
829
|
+
return delegate.links;
|
|
830
|
+
},
|
|
831
|
+
attribute(key, value) {
|
|
832
|
+
attributes.set(key, value);
|
|
833
|
+
delegate.attribute(key, value);
|
|
834
|
+
},
|
|
835
|
+
event(name, time, values) {
|
|
836
|
+
delegate.event(name, time, values);
|
|
837
|
+
},
|
|
838
|
+
addLinks(links) {
|
|
839
|
+
delegate.addLinks(links);
|
|
840
|
+
},
|
|
841
|
+
end(endTime, exit) {
|
|
842
|
+
delegate.end(endTime, exit);
|
|
843
|
+
status = {
|
|
844
|
+
_tag: "Ended",
|
|
845
|
+
startTime: status.startTime,
|
|
846
|
+
endTime,
|
|
847
|
+
exit
|
|
848
|
+
};
|
|
849
|
+
}
|
|
850
|
+
};
|
|
851
|
+
}
|
|
852
|
+
/** Acquire after the host layer so traces and metrics use the same context. */
|
|
853
|
+
function withDevTools(layer, url) {
|
|
854
|
+
if (url === void 0) return layer;
|
|
855
|
+
const endpoint = validateDevToolsUrl(url);
|
|
856
|
+
return Layer.unwrap(Effect.promise(async () => {
|
|
857
|
+
const [{ DevToolsClient }, { Socket }] = await Promise.all([import("effect/devtools"), import("effect/socket")]);
|
|
858
|
+
const client = DevToolsClient.layer.pipe(Layer.provide(Socket.layerWebSocket(endpoint)), Layer.provide(Socket.layerWebSocketConstructorGlobal));
|
|
859
|
+
return Layer.effect(Tracer.Tracer, Effect.gen(function* () {
|
|
860
|
+
const delegate = yield* Effect.tracer;
|
|
861
|
+
const mirror = Tracer.make({
|
|
862
|
+
span: (options) => localSpan(delegate.span(options)),
|
|
863
|
+
...delegate.context === void 0 ? {} : { context: delegate.context.bind(delegate) }
|
|
864
|
+
});
|
|
865
|
+
return yield* DevToolsClient.makeTracer.pipe(Effect.provideService(Tracer.Tracer, mirror));
|
|
866
|
+
})).pipe(Layer.provide(client), Layer.provideMerge(layer));
|
|
867
|
+
}));
|
|
868
|
+
}
|
|
869
|
+
//#endregion
|
|
800
870
|
//#region ../protocol/src/errors/convex-decoding.ts
|
|
801
871
|
const KNOWN_CODES = new Set(CAPXUL_ERROR_CODES);
|
|
802
872
|
function isCapxulCode(value) {
|
|
@@ -2851,6 +2921,123 @@ const attributes = (input, limit = 32) => {
|
|
|
2851
2921
|
};
|
|
2852
2922
|
const terminalName = (name) => name === "cli.command.completed" || name === "cli.wallet.step" || CLI_COMMAND_NAMES.some((command) => name === `cli.command.${command}`);
|
|
2853
2923
|
//#endregion
|
|
2924
|
+
//#region ../observability/src/engineering/tracer.ts
|
|
2925
|
+
const failureText = (failure, key, limit, source) => {
|
|
2926
|
+
if (failure === null || typeof failure !== "object") return void 0;
|
|
2927
|
+
try {
|
|
2928
|
+
let owner = failure;
|
|
2929
|
+
let descriptor;
|
|
2930
|
+
for (let depth = 0; owner !== null && depth < 4; depth += 1) {
|
|
2931
|
+
descriptor = Object.getOwnPropertyDescriptor(owner, key);
|
|
2932
|
+
if (descriptor !== void 0 || key !== "name") break;
|
|
2933
|
+
owner = Object.getPrototypeOf(owner);
|
|
2934
|
+
}
|
|
2935
|
+
const value = descriptor?.value;
|
|
2936
|
+
return typeof value === "string" || key === "code" && typeof value === "number" ? redactSecrets(String(value), source).slice(0, limit) : void 0;
|
|
2937
|
+
} catch {
|
|
2938
|
+
return;
|
|
2939
|
+
}
|
|
2940
|
+
};
|
|
2941
|
+
const exportFailure = (failure, source) => {
|
|
2942
|
+
const message = failureText(failure, "message", 2048, source) ?? (typeof failure === "string" ? redactSecrets(failure, source).slice(0, 2048) : "Engineering operation failed");
|
|
2943
|
+
const code = failureText(failure, "code", 128);
|
|
2944
|
+
const error = new Error((code === void 0 ? message : `${message} [code=${code}]`).slice(0, 2048));
|
|
2945
|
+
error.name = failureText(failure, "_tag", 128) ?? failureText(failure, "name", 128) ?? "Error";
|
|
2946
|
+
error.stack = failureText(failure, "stack", 8192, source) ?? `${error.name}: ${error.message}`;
|
|
2947
|
+
return error;
|
|
2948
|
+
};
|
|
2949
|
+
const exportFailureExit = (cause, source) => Exit.failCause(Cause.fromReasons(cause.reasons.filter((reason) => !Cause.isInterruptReason(reason)).slice(0, 8).map((reason) => Cause.isFailReason(reason) ? Cause.makeFailReason(exportFailure(reason.error, source)) : Cause.makeDieReason(exportFailure(reason.defect, source)))));
|
|
2950
|
+
const BROWSER_KEEPALIVE_BYTES = 65536;
|
|
2951
|
+
let unfinishedBrowserExportBytes = 0;
|
|
2952
|
+
const hasBrowserDocument = () => typeof window !== "undefined" && typeof document !== "undefined";
|
|
2953
|
+
const browserExportClient = (client) => HttpClient.transform(client, (response, request) => Effect.acquireUseRelease(Effect.sync(() => {
|
|
2954
|
+
const bytes = "contentLength" in request.body ? request.body.contentLength : void 0;
|
|
2955
|
+
if (request.body._tag === "Stream" || request.body._tag === "FormData" || bytes === void 0 || !Number.isSafeInteger(bytes) || bytes < 0 || unfinishedBrowserExportBytes + bytes > BROWSER_KEEPALIVE_BYTES) return;
|
|
2956
|
+
unfinishedBrowserExportBytes += bytes;
|
|
2957
|
+
return bytes;
|
|
2958
|
+
}), (bytes) => response.pipe(Effect.provideService(FetchHttpClient.RequestInit, { keepalive: bytes !== void 0 }), Effect.tap((result) => bytes === void 0 ? Effect.void : Stream.runDrain(result.stream).pipe(Effect.catchIf((error) => error.reason._tag === "EmptyBodyError", () => Effect.void)))), (bytes) => Effect.sync(() => {
|
|
2959
|
+
if (bytes !== void 0) unfinishedBrowserExportBytes -= bytes;
|
|
2960
|
+
})));
|
|
2961
|
+
const spanUpstream = (span) => {
|
|
2962
|
+
let current = span;
|
|
2963
|
+
while (current?._tag === "Span") {
|
|
2964
|
+
const upstream = current.attributes.get("chain.upstream");
|
|
2965
|
+
if (upstream === "alchemy" || upstream === "infura" || upstream === "gateway") return upstream;
|
|
2966
|
+
current = current.parent._tag === "Some" ? current.parent.value : void 0;
|
|
2967
|
+
}
|
|
2968
|
+
};
|
|
2969
|
+
function redactHttpPath(path, fullUrl, source) {
|
|
2970
|
+
let origin = "https://redaction.invalid";
|
|
2971
|
+
try {
|
|
2972
|
+
const url = new URL(String(fullUrl));
|
|
2973
|
+
if (url.protocol === "https:" || url.protocol === "http:") origin = url.origin;
|
|
2974
|
+
} catch {}
|
|
2975
|
+
const prefix = path.startsWith("/") ? origin : "";
|
|
2976
|
+
return redactUrlSecrets(`${prefix}${path}`, source).slice(prefix.length, prefix.length + 2048);
|
|
2977
|
+
}
|
|
2978
|
+
/** A span whose prototype is `span`: it answers every Span member until an own property overrides it. */
|
|
2979
|
+
function inheritSpan(span) {
|
|
2980
|
+
const wrapped = Object.create(span);
|
|
2981
|
+
Object.defineProperties(wrapped, {
|
|
2982
|
+
traceId: { get: () => span.traceId },
|
|
2983
|
+
spanId: { get: () => span.spanId },
|
|
2984
|
+
attributes: { get: () => span.attributes },
|
|
2985
|
+
event: {
|
|
2986
|
+
value: span.event.bind(span),
|
|
2987
|
+
configurable: true
|
|
2988
|
+
},
|
|
2989
|
+
addLinks: {
|
|
2990
|
+
value: span.addLinks.bind(span),
|
|
2991
|
+
configurable: true
|
|
2992
|
+
}
|
|
2993
|
+
});
|
|
2994
|
+
return wrapped;
|
|
2995
|
+
}
|
|
2996
|
+
/** Preserve domain exits while preventing the OTLP serializer from seeing raw causes. */
|
|
2997
|
+
const makeLeakSafeEngineeringTracer = (delegate, enabled = () => true) => Tracer.make({
|
|
2998
|
+
span(options) {
|
|
2999
|
+
const span = enabled() ? delegate.span(options) : new Tracer.NativeSpan(options);
|
|
3000
|
+
const wrapped = inheritSpan(span);
|
|
3001
|
+
Object.defineProperty(wrapped, "attribute", { value: (name, value) => {
|
|
3002
|
+
const source = spanUpstream(span);
|
|
3003
|
+
const header = /^http\.(?:request|response)\.header\.(.+)$/u.exec(name)?.[1];
|
|
3004
|
+
if (header !== void 0 && isCredentialField(header, "header")) span.attribute(name, "[REDACTED]");
|
|
3005
|
+
else if (typeof value === "string" && name === "url.query") span.attribute(name, redactUrlSecrets(`?${value}`).slice(1, 2049));
|
|
3006
|
+
else if (typeof value === "string" && (name === "url.path" || name === "http.target")) {
|
|
3007
|
+
const fullUrl = span.attributes.get("url.full") ?? span.attributes.get("http.url");
|
|
3008
|
+
const path = name === "url.path" && typeof fullUrl === "string" ? /^https?:\/\/[^/]+([^?#]*)/u.exec(fullUrl)?.[1] ?? value : value;
|
|
3009
|
+
span.attribute(name, redactHttpPath(path, fullUrl, source));
|
|
3010
|
+
} else if (typeof value === "string" && (name === "url.full" || name === "http.url" || header === "location" || header === "referer" || header === "referrer")) span.attribute(name, redactUrlSecrets(value, source).slice(0, 2048));
|
|
3011
|
+
else if (header !== void 0 && typeof value === "string") span.attribute(name, redactSecrets(value, source).slice(0, 2048));
|
|
3012
|
+
else span.attribute(name, value);
|
|
3013
|
+
} });
|
|
3014
|
+
Object.defineProperty(wrapped, "end", {
|
|
3015
|
+
configurable: false,
|
|
3016
|
+
enumerable: false,
|
|
3017
|
+
value: (endTime, exit) => {
|
|
3018
|
+
if (!enabled()) {
|
|
3019
|
+
Object.defineProperty(wrapped, "status", { value: {
|
|
3020
|
+
_tag: "Ended",
|
|
3021
|
+
startTime: span.status.startTime,
|
|
3022
|
+
endTime,
|
|
3023
|
+
exit
|
|
3024
|
+
} });
|
|
3025
|
+
return;
|
|
3026
|
+
}
|
|
3027
|
+
if (Exit.isFailure(exit) && !Cause.hasInterruptsOnly(exit.cause)) {
|
|
3028
|
+
const first = exit.cause.reasons.find((reason) => !Cause.isInterruptReason(reason));
|
|
3029
|
+
const code = failureText(first === void 0 ? void 0 : Cause.isFailReason(first) ? first.error : first.defect, "code", 128);
|
|
3030
|
+
if (code !== void 0) span.attribute("error.code", code);
|
|
3031
|
+
span.end(endTime, exportFailureExit(exit.cause, spanUpstream(span)));
|
|
3032
|
+
} else span.end(endTime, exit);
|
|
3033
|
+
},
|
|
3034
|
+
writable: false
|
|
3035
|
+
});
|
|
3036
|
+
return wrapped;
|
|
3037
|
+
},
|
|
3038
|
+
...delegate.context === void 0 ? {} : { context: delegate.context.bind(delegate) }
|
|
3039
|
+
});
|
|
3040
|
+
//#endregion
|
|
2854
3041
|
//#region ../observability/src/delivery/records.ts
|
|
2855
3042
|
function admittedLogger(state, delegate) {
|
|
2856
3043
|
return Logger.make((options) => {
|
|
@@ -2906,7 +3093,7 @@ function admittedTracer(state, delegate) {
|
|
|
2906
3093
|
/** The span as a producer sees it: at most 32 fields and 2000 attribute bytes, 2 events, 2 links. */
|
|
2907
3094
|
function boundedSpan(state, span) {
|
|
2908
3095
|
const { budget } = state;
|
|
2909
|
-
const wrapped =
|
|
3096
|
+
const wrapped = inheritSpan(span);
|
|
2910
3097
|
let fields = 0, events = 0, links = 0, attributeBytes = 0;
|
|
2911
3098
|
let ended = false;
|
|
2912
3099
|
Object.defineProperties(wrapped, {
|
|
@@ -3139,109 +3326,6 @@ const validateEngineeringTelemetryConfig = (config) => {
|
|
|
3139
3326
|
};
|
|
3140
3327
|
};
|
|
3141
3328
|
//#endregion
|
|
3142
|
-
//#region ../observability/src/engineering/tracer.ts
|
|
3143
|
-
const failureText = (failure, key, limit, source) => {
|
|
3144
|
-
if (failure === null || typeof failure !== "object") return void 0;
|
|
3145
|
-
try {
|
|
3146
|
-
let owner = failure;
|
|
3147
|
-
let descriptor;
|
|
3148
|
-
for (let depth = 0; owner !== null && depth < 4; depth += 1) {
|
|
3149
|
-
descriptor = Object.getOwnPropertyDescriptor(owner, key);
|
|
3150
|
-
if (descriptor !== void 0 || key !== "name") break;
|
|
3151
|
-
owner = Object.getPrototypeOf(owner);
|
|
3152
|
-
}
|
|
3153
|
-
const value = descriptor?.value;
|
|
3154
|
-
return typeof value === "string" || key === "code" && typeof value === "number" ? redactSecrets(String(value), source).slice(0, limit) : void 0;
|
|
3155
|
-
} catch {
|
|
3156
|
-
return;
|
|
3157
|
-
}
|
|
3158
|
-
};
|
|
3159
|
-
const exportFailure = (failure, source) => {
|
|
3160
|
-
const message = failureText(failure, "message", 2048, source) ?? (typeof failure === "string" ? redactSecrets(failure, source).slice(0, 2048) : "Engineering operation failed");
|
|
3161
|
-
const code = failureText(failure, "code", 128);
|
|
3162
|
-
const error = new Error((code === void 0 ? message : `${message} [code=${code}]`).slice(0, 2048));
|
|
3163
|
-
error.name = failureText(failure, "_tag", 128) ?? failureText(failure, "name", 128) ?? "Error";
|
|
3164
|
-
error.stack = failureText(failure, "stack", 8192, source) ?? `${error.name}: ${error.message}`;
|
|
3165
|
-
return error;
|
|
3166
|
-
};
|
|
3167
|
-
const exportFailureExit = (cause, source) => Exit.failCause(Cause.fromReasons(cause.reasons.filter((reason) => !Cause.isInterruptReason(reason)).slice(0, 8).map((reason) => Cause.isFailReason(reason) ? Cause.makeFailReason(exportFailure(reason.error, source)) : Cause.makeDieReason(exportFailure(reason.defect, source)))));
|
|
3168
|
-
const BROWSER_KEEPALIVE_BYTES = 65536;
|
|
3169
|
-
let unfinishedBrowserExportBytes = 0;
|
|
3170
|
-
const hasBrowserDocument = () => typeof window !== "undefined" && typeof document !== "undefined";
|
|
3171
|
-
const browserExportClient = (client) => HttpClient.transform(client, (response, request) => Effect.acquireUseRelease(Effect.sync(() => {
|
|
3172
|
-
const bytes = "contentLength" in request.body ? request.body.contentLength : void 0;
|
|
3173
|
-
if (request.body._tag === "Stream" || request.body._tag === "FormData" || bytes === void 0 || !Number.isSafeInteger(bytes) || bytes < 0 || unfinishedBrowserExportBytes + bytes > BROWSER_KEEPALIVE_BYTES) return;
|
|
3174
|
-
unfinishedBrowserExportBytes += bytes;
|
|
3175
|
-
return bytes;
|
|
3176
|
-
}), (bytes) => response.pipe(Effect.provideService(FetchHttpClient.RequestInit, { keepalive: bytes !== void 0 }), Effect.tap((result) => bytes === void 0 ? Effect.void : Stream.runDrain(result.stream).pipe(Effect.catchIf((error) => error.reason._tag === "EmptyBodyError", () => Effect.void)))), (bytes) => Effect.sync(() => {
|
|
3177
|
-
if (bytes !== void 0) unfinishedBrowserExportBytes -= bytes;
|
|
3178
|
-
})));
|
|
3179
|
-
const spanUpstream = (span) => {
|
|
3180
|
-
let current = span;
|
|
3181
|
-
while (current?._tag === "Span") {
|
|
3182
|
-
const upstream = current.attributes.get("chain.upstream");
|
|
3183
|
-
if (upstream === "alchemy" || upstream === "infura" || upstream === "gateway") return upstream;
|
|
3184
|
-
current = current.parent._tag === "Some" ? current.parent.value : void 0;
|
|
3185
|
-
}
|
|
3186
|
-
};
|
|
3187
|
-
function redactHttpPath(path, fullUrl, source) {
|
|
3188
|
-
let origin = "https://redaction.invalid";
|
|
3189
|
-
try {
|
|
3190
|
-
const url = new URL(String(fullUrl));
|
|
3191
|
-
if (url.protocol === "https:" || url.protocol === "http:") origin = url.origin;
|
|
3192
|
-
} catch {}
|
|
3193
|
-
const prefix = path.startsWith("/") ? origin : "";
|
|
3194
|
-
return redactUrlSecrets(`${prefix}${path}`, source).slice(prefix.length, prefix.length + 2048);
|
|
3195
|
-
}
|
|
3196
|
-
/** A span whose prototype is `span`: it answers every Span member until an own property overrides it. */
|
|
3197
|
-
function inheritSpan(span) {
|
|
3198
|
-
return Object.create(span);
|
|
3199
|
-
}
|
|
3200
|
-
/** Preserve domain exits while preventing the OTLP serializer from seeing raw causes. */
|
|
3201
|
-
const makeLeakSafeEngineeringTracer = (delegate, enabled = () => true) => Tracer.make({
|
|
3202
|
-
span(options) {
|
|
3203
|
-
const span = enabled() ? delegate.span(options) : new Tracer.NativeSpan(options);
|
|
3204
|
-
const wrapped = inheritSpan(span);
|
|
3205
|
-
Object.defineProperty(wrapped, "attribute", { value: (name, value) => {
|
|
3206
|
-
const source = spanUpstream(span);
|
|
3207
|
-
const header = /^http\.(?:request|response)\.header\.(.+)$/u.exec(name)?.[1];
|
|
3208
|
-
if (header !== void 0 && isCredentialField(header, "header")) span.attribute(name, "[REDACTED]");
|
|
3209
|
-
else if (typeof value === "string" && name === "url.query") span.attribute(name, redactUrlSecrets(`?${value}`).slice(1, 2049));
|
|
3210
|
-
else if (typeof value === "string" && (name === "url.path" || name === "http.target")) {
|
|
3211
|
-
const fullUrl = span.attributes.get("url.full") ?? span.attributes.get("http.url");
|
|
3212
|
-
const path = name === "url.path" && typeof fullUrl === "string" ? /^https?:\/\/[^/]+([^?#]*)/u.exec(fullUrl)?.[1] ?? value : value;
|
|
3213
|
-
span.attribute(name, redactHttpPath(path, fullUrl, source));
|
|
3214
|
-
} else if (typeof value === "string" && (name === "url.full" || name === "http.url" || header === "location" || header === "referer" || header === "referrer")) span.attribute(name, redactUrlSecrets(value, source).slice(0, 2048));
|
|
3215
|
-
else if (header !== void 0 && typeof value === "string") span.attribute(name, redactSecrets(value, source).slice(0, 2048));
|
|
3216
|
-
else span.attribute(name, value);
|
|
3217
|
-
} });
|
|
3218
|
-
Object.defineProperty(wrapped, "end", {
|
|
3219
|
-
configurable: false,
|
|
3220
|
-
enumerable: false,
|
|
3221
|
-
value: (endTime, exit) => {
|
|
3222
|
-
if (!enabled()) {
|
|
3223
|
-
Object.defineProperty(wrapped, "status", { value: {
|
|
3224
|
-
_tag: "Ended",
|
|
3225
|
-
startTime: span.status.startTime,
|
|
3226
|
-
endTime,
|
|
3227
|
-
exit
|
|
3228
|
-
} });
|
|
3229
|
-
return;
|
|
3230
|
-
}
|
|
3231
|
-
if (Exit.isFailure(exit) && !Cause.hasInterruptsOnly(exit.cause)) {
|
|
3232
|
-
const first = exit.cause.reasons.find((reason) => !Cause.isInterruptReason(reason));
|
|
3233
|
-
const code = failureText(first === void 0 ? void 0 : Cause.isFailReason(first) ? first.error : first.defect, "code", 128);
|
|
3234
|
-
if (code !== void 0) span.attribute("error.code", code);
|
|
3235
|
-
span.end(endTime, exportFailureExit(exit.cause, spanUpstream(span)));
|
|
3236
|
-
} else span.end(endTime, exit);
|
|
3237
|
-
},
|
|
3238
|
-
writable: false
|
|
3239
|
-
});
|
|
3240
|
-
return wrapped;
|
|
3241
|
-
},
|
|
3242
|
-
...delegate.context === void 0 ? {} : { context: delegate.context.bind(delegate) }
|
|
3243
|
-
});
|
|
3244
|
-
//#endregion
|
|
3245
3329
|
//#region ../observability/src/engineering/minimal.ts
|
|
3246
3330
|
const MINIMAL_LOG_NAMES = /* @__PURE__ */ new Set([
|
|
3247
3331
|
"capxul_sdk_operation",
|
|
@@ -3901,6 +3985,14 @@ function makeProductionAdapterLayer(input) {
|
|
|
3901
3985
|
//#region src/platform/production-input.ts
|
|
3902
3986
|
function validateCreateCapxulClientInput(input) {
|
|
3903
3987
|
const runtime = input.runtime ?? detectRuntime();
|
|
3988
|
+
if (input.devToolsUrl !== void 0) try {
|
|
3989
|
+
validateDevToolsUrl(input.devToolsUrl);
|
|
3990
|
+
} catch {
|
|
3991
|
+
return {
|
|
3992
|
+
ok: false,
|
|
3993
|
+
error: Errors.invalidInput("devToolsUrl", "must be a local ws or wss URL without credentials")
|
|
3994
|
+
};
|
|
3995
|
+
}
|
|
3904
3996
|
if (input.signer !== void 0 && input.openfortSignerFactory !== void 0) return {
|
|
3905
3997
|
ok: false,
|
|
3906
3998
|
error: Errors.invalidInput("signer", "choose signer or openfortSignerFactory")
|
|
@@ -4065,7 +4157,7 @@ async function createProductionAdapters(input) {
|
|
|
4065
4157
|
...input.resetSignerSession === void 0 ? {} : { resetSignerSession: input.resetSignerSession }
|
|
4066
4158
|
});
|
|
4067
4159
|
const applicationLayer = Layer.merge(portsLayer, optionalEngineeringTelemetryLayer(bootstrapResult.value.engineeringTelemetry, resolvedInput.value.runtime, hostEngineeringPolicy(input.observability))).pipe(Layer.provideMerge(localDiagnosticsLayer(localDiagnostics, resolvedInput.value.runtime)));
|
|
4068
|
-
const context = await Effect.runPromise(Layer.buildWithScope(applicationLayer, scope));
|
|
4160
|
+
const context = await Effect.runPromise(Layer.buildWithScope(withDevTools(applicationLayer, input.devToolsUrl), scope));
|
|
4069
4161
|
const collected = await Effect.runPromise(collectProductionFlowPorts.pipe(Effect.provide(context)));
|
|
4070
4162
|
const indexerUrl = input.indexerUrl ?? bootstrapResult.value.indexerUrl;
|
|
4071
4163
|
const indexerRead = productionIndexerReadPort(indexerUrl === void 0 ? input : {
|
|
@@ -4119,7 +4211,6 @@ function makeFinancialOpsMethods(deps) {
|
|
|
4119
4211
|
payments: makePaymentsMethods(deps),
|
|
4120
4212
|
approvals: makeApprovalsMethods(deps),
|
|
4121
4213
|
activity: makeActivityMethods(deps),
|
|
4122
|
-
offramp: makeOfframpMethods(),
|
|
4123
4214
|
paymentDocuments: makePaymentDocumentsMethods(deps)
|
|
4124
4215
|
};
|
|
4125
4216
|
}
|
|
@@ -4244,6 +4335,21 @@ function withHostObservationControls(snapshot, input, actorId) {
|
|
|
4244
4335
|
});
|
|
4245
4336
|
}
|
|
4246
4337
|
//#endregion
|
|
4338
|
+
//#region src/observability/telemetry/emit-once.ts
|
|
4339
|
+
/**
|
|
4340
|
+
* A product event that could not be built or emitted never reaches the caller
|
|
4341
|
+
* as a failure, and is never lost silently: the drop is logged by event name.
|
|
4342
|
+
*/
|
|
4343
|
+
function logDroppedEvent(eventName) {
|
|
4344
|
+
return (effect) => effect.pipe(Effect.catchCause((cause) => {
|
|
4345
|
+
const reason = Cause.squash(cause);
|
|
4346
|
+
return Effect.logWarning("product.telemetry.emit.dropped").pipe(Effect.annotateLogs({
|
|
4347
|
+
product_event: eventName,
|
|
4348
|
+
reason: reason instanceof Error ? reason.message : String(reason)
|
|
4349
|
+
}), Effect.ignoreCause);
|
|
4350
|
+
}));
|
|
4351
|
+
}
|
|
4352
|
+
//#endregion
|
|
4247
4353
|
//#region src/platform/client/signer-readiness.ts
|
|
4248
4354
|
/**
|
|
4249
4355
|
* Start the signer readiness cycle when the identity becomes claimed (#1667).
|
|
@@ -4527,6 +4633,37 @@ function makeClientInternals(input, shared) {
|
|
|
4527
4633
|
};
|
|
4528
4634
|
}
|
|
4529
4635
|
//#endregion
|
|
4636
|
+
//#region src/platform/client/scopes.ts
|
|
4637
|
+
const makeClientScopes = (input, runPromise, invocationControls) => {
|
|
4638
|
+
const shared = {
|
|
4639
|
+
convexCall: input.ports.convexCall,
|
|
4640
|
+
runPromise,
|
|
4641
|
+
invocationControls
|
|
4642
|
+
};
|
|
4643
|
+
const verification = {
|
|
4644
|
+
...input.ports,
|
|
4645
|
+
siteBaseUrl: input.bootstrap.siteBaseUrl,
|
|
4646
|
+
runPromise,
|
|
4647
|
+
invocationControls
|
|
4648
|
+
};
|
|
4649
|
+
return {
|
|
4650
|
+
personal: {
|
|
4651
|
+
banking: makeBankingMethods(shared),
|
|
4652
|
+
verification: makeVerificationMethods(verification)
|
|
4653
|
+
},
|
|
4654
|
+
organization: {
|
|
4655
|
+
banking: (orgId) => makeBankingMethods(shared, {
|
|
4656
|
+
kind: "org",
|
|
4657
|
+
orgId
|
|
4658
|
+
}),
|
|
4659
|
+
verification: (orgId) => makeVerificationMethods(verification, {
|
|
4660
|
+
kind: "organization",
|
|
4661
|
+
orgId
|
|
4662
|
+
})
|
|
4663
|
+
}
|
|
4664
|
+
};
|
|
4665
|
+
};
|
|
4666
|
+
//#endregion
|
|
4530
4667
|
//#region src/platform/client/assemble.ts
|
|
4531
4668
|
function assembleCapxulClient(input) {
|
|
4532
4669
|
const observation = input;
|
|
@@ -4538,7 +4675,6 @@ function assembleCapxulClient(input) {
|
|
|
4538
4675
|
};
|
|
4539
4676
|
const { actor, stopActor } = bootClientActor(input, effectRunner, observation);
|
|
4540
4677
|
const invocationControls = (controls) => withHostObservationControls(observation.hostObservationSnapshot, controls, actor.authSession()?.authUserId);
|
|
4541
|
-
const selectedOrgPort = input.orgPort;
|
|
4542
4678
|
let kickProvisioning;
|
|
4543
4679
|
const financialOps = makeFinancialOpsMethods({
|
|
4544
4680
|
runPromise: effectRunner.runPromise,
|
|
@@ -4647,6 +4783,7 @@ function assembleCapxulClient(input) {
|
|
|
4647
4783
|
invocationControls
|
|
4648
4784
|
};
|
|
4649
4785
|
const accounts = makeAccountsMethods(accountsInput);
|
|
4786
|
+
const scopes = makeClientScopes(input, effectRunner.runPromise, invocationControls);
|
|
4650
4787
|
const orgMethods = makeOrgMethods({
|
|
4651
4788
|
actor,
|
|
4652
4789
|
chainId: input.bootstrap.chainId,
|
|
@@ -4654,8 +4791,9 @@ function assembleCapxulClient(input) {
|
|
|
4654
4791
|
runPromise: effectRunner.runPromise,
|
|
4655
4792
|
invocationControls,
|
|
4656
4793
|
requestKeyScope: `${input.bootstrap.convexUrl}:${String(input.bootstrap.chainId)}`,
|
|
4657
|
-
...
|
|
4794
|
+
...input.orgPort === void 0 ? {} : { orgPort: input.orgPort },
|
|
4658
4795
|
convexCall: input.ports.convexCall,
|
|
4796
|
+
...scopes.organization,
|
|
4659
4797
|
...input.signer === void 0 ? {} : { signer: input.signer },
|
|
4660
4798
|
...input.organizationSetup === void 0 ? {} : { organizationSetup: input.organizationSetup }
|
|
4661
4799
|
});
|
|
@@ -4667,6 +4805,7 @@ function assembleCapxulClient(input) {
|
|
|
4667
4805
|
});
|
|
4668
4806
|
const identityRuntime = makeIdentityRuntime(actor, input.ports.identity, effectRunner.runPromise);
|
|
4669
4807
|
const client = {
|
|
4808
|
+
...scopes.personal,
|
|
4670
4809
|
checkouts: makeCheckoutMethods({
|
|
4671
4810
|
convexCall: input.ports.convexCall,
|
|
4672
4811
|
runPromise: effectRunner.runPromise,
|
package/dist/testing/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Ao as TelemetryIdentifyInput, Mo as TelemetryPortEvent, R as CapxulClient, T as OpenfortBrowserSignerOptions, Vo as ObservationAdapter, Xo as CapxulResult, at as IdentityTransition, ba as CapxulSigner, c as CapxulClientInput, jo as TelemetryEvent, ko as TelemetryGroupInput, ro as OrganizationSetup } from "../index-VeQh7FNW.mjs";
|
|
2
2
|
import { Effect, Layer } from "effect";
|
|
3
3
|
//#region src/platform/production-client.d.ts
|
|
4
4
|
/** Per-client signing controls; only the testing entry exposes these to consumers. */
|
package/dist/testing/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Ai as
|
|
2
|
-
import { a as cloneTelemetryEvent, c as identityErrorFromCapxul, l as bootstrapErrorFromCapxul, n as createCapxulClientWithSignerControls, o as cloneTelemetryProps, r as assembleCapxulClient, s as IdentityPortTag } from "../production-
|
|
1
|
+
import { Ai as toDurationMs, D as convexCallErrorFromCapxul, Dt as deriveCapxulSafeAddress, Ei as InMemoryAuthCacheAdapter, Fi as toJwtToken, Fr as toWeiAmount, Ii as toSessionToken, Ir as absurd, Li as Errors, Mi as toEpochSeconds, Ni as toAuthUserId, Nr as toAddress, Pi as toEmail, Pr as toChainId, Ri as CapxulError, Tt as CONFIGURED_MONEY_ASSETS, X as assetAmountFromRaw, Zn as toOrgId, _ as accountFromAccountPositions, _n as validateHandle, ai as ClockError, bi as toPublishableKey, dn as toCountryCode, dr as toAccountId, f as smartAccountErrorFromCapxul, fn as toKycTier, hn as toHandle, j as wireChainId, ji as toEpochMs, oi as ClockPortTag, si as readClockNow, tt as toRaw, vi as toAllowedOrigin, vn as redactTelemetryEvent, w as accountReadErrorFromCapxul, xi as authClientPortFromPromiseAdapter, yi as toAppId } from "../access-l_ci38yt.mjs";
|
|
2
|
+
import { a as cloneTelemetryEvent, c as identityErrorFromCapxul, l as bootstrapErrorFromCapxul, n as createCapxulClientWithSignerControls, o as cloneTelemetryProps, r as assembleCapxulClient, s as IdentityPortTag } from "../production-BzEOaP6l.mjs";
|
|
3
3
|
import { Effect, Layer, Result, Semaphore } from "effect";
|
|
4
4
|
import { getFunctionName } from "convex/server";
|
|
5
5
|
//#region src/testing/production-client.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capxul/sdk",
|
|
3
|
-
"version": "4.20.0-beta.
|
|
3
|
+
"version": "4.20.0-beta.33",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/Xelmar-tech/infrastructure.git",
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"#accounts": "./src/accounts/index.ts",
|
|
18
18
|
"#activity": "./src/activity/index.ts",
|
|
19
19
|
"#applications": "./src/applications/index.ts",
|
|
20
|
+
"#banking": "./src/banking/index.ts",
|
|
20
21
|
"#documents": "./src/documents/index.ts",
|
|
21
22
|
"#indexing": "./src/indexing/index.ts",
|
|
22
23
|
"#media": "./src/media/index.ts",
|
|
@@ -83,9 +84,9 @@
|
|
|
83
84
|
"vite-plus": "1.0.0",
|
|
84
85
|
"vitest": "5.0.1",
|
|
85
86
|
"zodiac-roles-sdk": "2.22.2",
|
|
86
|
-
"@capxul/observability": "4.20.0-beta.
|
|
87
|
-
"@capxul/
|
|
88
|
-
"@capxul/
|
|
87
|
+
"@capxul/observability": "4.20.0-beta.33",
|
|
88
|
+
"@capxul/protocol": "0.2.0-beta.5",
|
|
89
|
+
"@capxul/typescript-config": "0.0.0"
|
|
89
90
|
},
|
|
90
91
|
"_permissionlessPinReason": "permissionless.toSafeSmartAccount is pinned to 0.3.4 for live Safe deployment E2E. Counterfactual address fixtures captured 2026-05-17 in packages/backend/convex/_shared/__tests__/counterfactual.test.ts and packages/config/tests/safe.test.ts must be re-verified before upgrading.",
|
|
91
92
|
"scripts": {
|