@capxul/mcp 4.20.0-beta.42 → 4.20.0-beta.43
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 +1 -1
- package/dist/lib-B0WujUb6.mjs +3 -0
- package/dist/{lib-CoGPQsbr.mjs → lib-BF-i2NpS.mjs} +2 -1
- package/dist/{lib-BJgR4mWJ.mjs → lib-BNd97f2M.mjs} +13 -12
- package/dist/lib-C5rDhBj_.mjs +3 -0
- package/dist/lib-CPklA4fw.mjs +3 -0
- package/dist/{lib-CJw8te9L.mjs → lib-CkoBT6RP.mjs} +5 -4
- package/dist/{lib-Buegx0dz.mjs → lib-Cm0Rpsvi.mjs} +9 -8
- package/dist/{lib-5nM6ORJd.mjs → lib-Cugc4DFI.mjs} +17 -16
- package/dist/{lib-BspI667y.mjs → lib-D2rn71RD.mjs} +17 -16
- package/dist/lib-DWEnweWw.mjs +3 -0
- package/dist/{lib-DnmstTkB.mjs → lib-DgGQiVOd.mjs} +2 -36
- package/dist/main.mjs +1061 -734
- package/dist/{organizations-CeOxH4kV.mjs → organizations-Bg6eIN7c.mjs} +49039 -37544
- package/dist/{permission-approvals-C3gzC62m.mjs → permission-approvals-QgcLB6LX.mjs} +16 -44
- package/dist/rolldown-runtime-B000p9w_.mjs +36 -0
- package/dist/secp256k1-BTYHwWe5.mjs +2 -0
- package/dist/{secp256k1-vkvPWdOZ.mjs → secp256k1-DUDiv39Y.mjs} +422 -2
- package/dist/src-Fq2O2dIf.mjs +9409 -0
- package/dist/src-JOPgNauL.mjs +2 -0
- package/package.json +4 -4
- package/dist/lib-BlUleR2B.mjs +0 -3
- package/dist/lib-C_-etuHZ.mjs +0 -3
- package/dist/lib-Dd_fsz7h.mjs +0 -3
- package/dist/lib-IlYdzOHo.mjs +0 -3
- package/dist/secp256k1-CLeVBma1.mjs +0 -2
- package/dist/sha2-D5rBHwg7.mjs +0 -422
package/dist/main.mjs
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import { $ as
|
|
4
|
-
import { t as secp256k1 } from "./secp256k1-
|
|
5
|
-
import { t as require_lib } from "./lib-
|
|
6
|
-
import { serveStdio } from "@modelcontextprotocol/server/stdio";
|
|
2
|
+
import { a as __toESM, i as __require, n as __exportAll, t as __commonJSMin } from "./rolldown-runtime-B000p9w_.mjs";
|
|
3
|
+
import { $ as ConvexCallError, $n as waitlist, $r as isHex, $t as commands, A as makeMeMethods, An as toHandle, Ar as isBytes32, At as checkouts, B as diagnostics, Bn as ActorFailure, Br as isAddress, Bt as makeVerificationMethods, Ci as urlCredentialSource, Cn as signerPathFailure, Cr as redactTelemetryProps, Ct as safes, Di as normalizeCapxulOperation, Dn as toCountryCode, Dr as FAILURE_CLASSES, Dt as makePaymentsMethods, Ei as isCapxulOperation, En as makeClientRequestMethods, Er as CLI_INVOCATION_KINDS, Et as networks, F as ConvexSmartAccountLayer, Fn as noSessionError, Fr as formatGwei$1, Ft as registrations, G as counterparties, Gn as runCapxulEffect, Gr as numberToHex$1, Gt as accounts$1, H as probes, Hn as makeReferralMethods, Hr as keccak256$1, Ht as destinations, I as SmartAccountPortTag, In as publicIdentityFailure, Ir as createCursor, It as HttpBootstrapLayer, J as overlays, Jn as callOperation, Jr as hexToBigInt, Jt as groups, K as documents, Kn as toCapxulResult, Kr as stringToHex, Kt as withheld, L as preferences, Ln as runIdentityFacade, Lr as slice, Lt as BootstrapPortTag, M as makeActivityMethods, Mn as makeAuthMethods, Mr as sha256, Mt as receivables, N as makePaymentDocumentsMethods, Nn as askIdentity, Nr as toRlp, Nt as inboxes, O as executeIdentityProductObservation, On as toKycTier, Or as ORGANIZATION_SETUP_REASONS, Ot as makeDestinationsMethods, P as makeSmartAccountMethods, Pn as readSession, Pr as publicKeyToAddress, Pt as keys, Q as TelemetryPortTag, Qn as sessions, Qr as size, R as makeHoldingsMethods, Rn as runPortEffect, Rr as concat, Rt as decodeConvexError, S as OrgPortTag, Si as redactUrlSecrets, Sn as signerFailure, Sr as BASE_SEPOLIA_CHAIN_ID, St as grants, Ti as CAPXUL_OPERATIONS, Tn as makeCurrentUserMethods, Tr as CLI_CAPABILITIES, Tt as makeAccountMethods, U as receipts, Un as makeFeatureGateMethods, Ur as hexToBytes, Ut as recipients, V as identities, Vn as makeWaitlistMethods, Vr as InvalidAddressError, Vt as contacts, W as annotations, Wn as makeFeatureMethods, Wr as bytesToHex, Wt as verifications, X as ConvexAccountLayer, Xn as features, Xr as trim$1, Xt as terms, Y as makeAccountsMethods, Yn as absurd, Yr as hexToNumber, Yt as runs, Z as AccountReadPortTag, Zn as referrals, Zr as BaseError, Zt as allowances, _ as shareTransfers, _i as isExpectedOutcome, _n as httpStatusOf, _r as AuthCachePortTag, _t as replacements, a as makeBookPriceMethods, ai as isEvmAddress, an as toPublicError, ar as ClockPortTag, at as makePayeeAgreementMethods, bi as FAILURE_MODES, bn as openfortSignerNotReadyCode, br as toAuthUserId, bt as balances, c as exports$1, ci as toPublishableKey, cn as postHogFailureObservation, cr as BetterAuthBrowserLayer, ct as roles, d as reports, di as PROVIDERS, dn as observationContextProps, dr as readInvocationObservation, dt as workspaces, ei as toOrgId, en as executions, er as DEFECTS, et as ConvexCallPortTag, f as makeBankingMethods, fi as PROVIDER_PROBLEMS, fn as withCapturedAttemptContext, fr as sanitizeObservationContext, ft as proposals, g as rounds, gi as CAPXUL_ERROR_CODES, gn as causeChain, gr as globalLocalStorage, gt as configurations, h as directors, hi as isCapxulError, hn as UNOBSERVABLE_SIGNER_STATUS, hr as detectAuthCacheAdapter, ht as commands$1, i as makeOrgMethods, ii as toEpochMs, in as asCapxulError, ir as SystemClockLayer, it as makeApprovalsMethods, j as agents, jn as validateHandle, jr as hashTypedData, jt as offers, k as bootIdentityFlow, kn as toTesterKind, kr as ORGANIZATION_SETUP_STATUSES, kt as makeCheckoutMethods, l as facts, li as Errors, ln as observeFailedResult, lr as attachInvocationObservation, lt as setups, m as deposits, mi as CapxulError, mn as version$2, mr as AuthClientPortTag, mt as authorities, n as makeMeShareMethods, ni as MCP_EXPECTED_OUTCOME_EVENT_NAME, nn as records, nr as getFunctionName, nt as bindProductTelemetryInvocation, o as accounts, oi as toAddress, on as failureDetail$1, or as reuseConvexJwt, ot as invitations, p as bankDetails, pi as httpStatusMode, pn as failureProperties, pr as AuthClientError, pt as agreements, q as items, qn as formatTraceparent, qr as toHex, qt as departments, r as ConvexOrganizationSetupAdapter, ri as stampTelemetryEnvelope, rn as quotes, rr as oauthBearerAuthClient, rt as registerProductTelemetryInvocation, s as assets, si as toAllowedOrigin, sn as failureEvidenceProps, sr as BetterAuthNodeLayer, st as members, t as makeMyVoteMethods, ti as EXCEPTION_EVENT_NAME, tn as lifecycles, tr as Operation, tt as convexCallErrorFromCapxul, u as keepers, ui as providerStatusFailure, un as observeSdkClient, ur as copyInvocationObservation, ut as treasuries, v as equity, vi as isRecord, vn as isEcdsaSignatureHex, vr as maskedMessage, vt as verifications$1, wi as isCredentialField, wn as normalizeSafeSaltEmail, wr as CLI_COMMAND_NAMES, wt as summaries, x as ConvexOrganizationAdapter, xi as redactSecrets, xn as recoverRawDigestSigner, xr as toEmail, xt as claims, y as votes, yi as readField, yn as isSignerNotReadySignal, yr as serializeCapxulError, yt as approvals, z as PonderIndexerAdapter, zn as sessionFromActor, zr as concatHex, zt as makeTargetsMethods } from "./organizations-Bg6eIN7c.mjs";
|
|
4
|
+
import { t as secp256k1 } from "./secp256k1-DUDiv39Y.mjs";
|
|
5
|
+
import { t as require_lib } from "./lib-BF-i2NpS.mjs";
|
|
7
6
|
import { PostHog } from "posthog-node";
|
|
8
7
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
9
8
|
import { createHash, randomUUID } from "node:crypto";
|
|
10
|
-
import { Cause, Clock, Context, Data, Deferred, Duration, Effect, Exit, FiberSet, Layer, LogLevel, Logger, ManagedRuntime, Metric, Option, Predicate, References, Result, Schedule, Schema, SchemaIssue,
|
|
9
|
+
import { Cause, Clock, Context, Data, Deferred, Duration, Effect, Exit, FiberSet, Layer, LogLevel, Logger, ManagedRuntime, Metric, Option, Predicate, References, Result, Schedule, Schema, SchemaIssue, Scope, Stream, Tracer } from "effect";
|
|
11
10
|
import { FetchHttpClient, Headers, HttpBody, HttpClient, HttpClientError, HttpClientResponse } from "effect/http";
|
|
12
11
|
import { OtlpExporter, OtlpLogger, OtlpMetrics, OtlpSerialization, OtlpTracer } from "effect/observability";
|
|
13
12
|
import http from "http";
|
|
@@ -23,299 +22,11 @@ import http2 from "http2";
|
|
|
23
22
|
import { createServer } from "node:http";
|
|
24
23
|
import { localhostHostValidation, localhostOriginValidation, toNodeHandler } from "@modelcontextprotocol/node";
|
|
25
24
|
import { z } from "zod";
|
|
26
|
-
import { McpServer, createMcpHandler } from "@modelcontextprotocol/server";
|
|
25
|
+
import { McpServer, createMcpHandler, isJSONRPCErrorResponse, isJSONRPCNotification, isJSONRPCRequest, isJSONRPCResultResponse } from "@modelcontextprotocol/server";
|
|
27
26
|
import { instrument } from "@posthog/mcp";
|
|
27
|
+
import { StdioServerTransport, serveStdio } from "@modelcontextprotocol/server/stdio";
|
|
28
28
|
//#region package.json
|
|
29
|
-
var version$1 = "4.20.0-beta.
|
|
30
|
-
//#endregion
|
|
31
|
-
//#region ../../node_modules/.pnpm/convex@1.39.1_react@19.2.7/node_modules/convex/dist/esm/values/base64.js
|
|
32
|
-
var lookup = [];
|
|
33
|
-
var revLookup = [];
|
|
34
|
-
var Arr = Uint8Array;
|
|
35
|
-
var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
36
|
-
for (var i = 0, len = code.length; i < len; ++i) {
|
|
37
|
-
lookup[i] = code[i];
|
|
38
|
-
revLookup[code.charCodeAt(i)] = i;
|
|
39
|
-
}
|
|
40
|
-
revLookup["-".charCodeAt(0)] = 62;
|
|
41
|
-
revLookup["_".charCodeAt(0)] = 63;
|
|
42
|
-
function getLens(b64) {
|
|
43
|
-
var len = b64.length;
|
|
44
|
-
if (len % 4 > 0) throw new Error("Invalid string. Length must be a multiple of 4");
|
|
45
|
-
var validLen = b64.indexOf("=");
|
|
46
|
-
if (validLen === -1) validLen = len;
|
|
47
|
-
var placeHoldersLen = validLen === len ? 0 : 4 - validLen % 4;
|
|
48
|
-
return [validLen, placeHoldersLen];
|
|
49
|
-
}
|
|
50
|
-
function _byteLength(_b64, validLen, placeHoldersLen) {
|
|
51
|
-
return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
|
|
52
|
-
}
|
|
53
|
-
function toByteArray(b64) {
|
|
54
|
-
var tmp;
|
|
55
|
-
var lens = getLens(b64);
|
|
56
|
-
var validLen = lens[0];
|
|
57
|
-
var placeHoldersLen = lens[1];
|
|
58
|
-
var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
|
|
59
|
-
var curByte = 0;
|
|
60
|
-
var len = placeHoldersLen > 0 ? validLen - 4 : validLen;
|
|
61
|
-
var i = 0;
|
|
62
|
-
for (; i < len; i += 4) {
|
|
63
|
-
tmp = revLookup[b64.charCodeAt(i)] << 18 | revLookup[b64.charCodeAt(i + 1)] << 12 | revLookup[b64.charCodeAt(i + 2)] << 6 | revLookup[b64.charCodeAt(i + 3)];
|
|
64
|
-
arr[curByte++] = tmp >> 16 & 255;
|
|
65
|
-
arr[curByte++] = tmp >> 8 & 255;
|
|
66
|
-
arr[curByte++] = tmp & 255;
|
|
67
|
-
}
|
|
68
|
-
if (placeHoldersLen === 2) {
|
|
69
|
-
tmp = revLookup[b64.charCodeAt(i)] << 2 | revLookup[b64.charCodeAt(i + 1)] >> 4;
|
|
70
|
-
arr[curByte++] = tmp & 255;
|
|
71
|
-
}
|
|
72
|
-
if (placeHoldersLen === 1) {
|
|
73
|
-
tmp = revLookup[b64.charCodeAt(i)] << 10 | revLookup[b64.charCodeAt(i + 1)] << 4 | revLookup[b64.charCodeAt(i + 2)] >> 2;
|
|
74
|
-
arr[curByte++] = tmp >> 8 & 255;
|
|
75
|
-
arr[curByte++] = tmp & 255;
|
|
76
|
-
}
|
|
77
|
-
return arr;
|
|
78
|
-
}
|
|
79
|
-
function tripletToBase64(num) {
|
|
80
|
-
return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
|
|
81
|
-
}
|
|
82
|
-
function encodeChunk(uint8, start, end) {
|
|
83
|
-
var tmp;
|
|
84
|
-
var output = [];
|
|
85
|
-
for (var i = start; i < end; i += 3) {
|
|
86
|
-
tmp = (uint8[i] << 16 & 16711680) + (uint8[i + 1] << 8 & 65280) + (uint8[i + 2] & 255);
|
|
87
|
-
output.push(tripletToBase64(tmp));
|
|
88
|
-
}
|
|
89
|
-
return output.join("");
|
|
90
|
-
}
|
|
91
|
-
function fromByteArray(uint8) {
|
|
92
|
-
var tmp;
|
|
93
|
-
var len = uint8.length;
|
|
94
|
-
var extraBytes = len % 3;
|
|
95
|
-
var parts = [];
|
|
96
|
-
var maxChunkLength = 16383;
|
|
97
|
-
for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) parts.push(encodeChunk(uint8, i, i + maxChunkLength > len2 ? len2 : i + maxChunkLength));
|
|
98
|
-
if (extraBytes === 1) {
|
|
99
|
-
tmp = uint8[len - 1];
|
|
100
|
-
parts.push(lookup[tmp >> 2] + lookup[tmp << 4 & 63] + "==");
|
|
101
|
-
} else if (extraBytes === 2) {
|
|
102
|
-
tmp = (uint8[len - 2] << 8) + uint8[len - 1];
|
|
103
|
-
parts.push(lookup[tmp >> 10] + lookup[tmp >> 4 & 63] + lookup[tmp << 2 & 63] + "=");
|
|
104
|
-
}
|
|
105
|
-
return parts.join("");
|
|
106
|
-
}
|
|
107
|
-
//#endregion
|
|
108
|
-
//#region ../../node_modules/.pnpm/convex@1.39.1_react@19.2.7/node_modules/convex/dist/esm/common/index.js
|
|
109
|
-
function parseArgs(args) {
|
|
110
|
-
if (args === void 0) return {};
|
|
111
|
-
if (!isSimpleObject(args)) throw new Error(`The arguments to a Convex function must be an object. Received: ${args}`);
|
|
112
|
-
return args;
|
|
113
|
-
}
|
|
114
|
-
function validateDeploymentUrl(deploymentUrl) {
|
|
115
|
-
if (typeof deploymentUrl === "undefined") throw new Error(`Client created with undefined deployment address. If you used an environment variable, check that it's set.`);
|
|
116
|
-
if (typeof deploymentUrl !== "string") throw new Error(`Invalid deployment address: found ${deploymentUrl}".`);
|
|
117
|
-
if (!(deploymentUrl.startsWith("http:") || deploymentUrl.startsWith("https:"))) throw new Error(`Invalid deployment address: Must start with "https://" or "http://". Found "${deploymentUrl}".`);
|
|
118
|
-
try {
|
|
119
|
-
new URL(deploymentUrl);
|
|
120
|
-
} catch {
|
|
121
|
-
throw new Error(`Invalid deployment address: "${deploymentUrl}" is not a valid URL. If you believe this URL is correct, use the \`skipConvexDeploymentUrlCheck\` option to bypass this.`);
|
|
122
|
-
}
|
|
123
|
-
if (deploymentUrl.endsWith(".convex.site")) throw new Error(`Invalid deployment address: "${deploymentUrl}" ends with .convex.site, which is used for HTTP Actions. Convex deployment URLs typically end with .convex.cloud? If you believe this URL is correct, use the \`skipConvexDeploymentUrlCheck\` option to bypass this.`);
|
|
124
|
-
}
|
|
125
|
-
function isSimpleObject(value) {
|
|
126
|
-
const isObject = typeof value === "object";
|
|
127
|
-
const prototype = Object.getPrototypeOf(value);
|
|
128
|
-
const isSimple = prototype === null || prototype === Object.prototype || prototype?.constructor?.name === "Object";
|
|
129
|
-
return isObject && isSimple;
|
|
130
|
-
}
|
|
131
|
-
//#endregion
|
|
132
|
-
//#region ../../node_modules/.pnpm/convex@1.39.1_react@19.2.7/node_modules/convex/dist/esm/values/value.js
|
|
133
|
-
const LITTLE_ENDIAN = true;
|
|
134
|
-
const MIN_INT64 = BigInt("-9223372036854775808");
|
|
135
|
-
const MAX_INT64 = BigInt("9223372036854775807");
|
|
136
|
-
const ZERO = BigInt("0");
|
|
137
|
-
const EIGHT = BigInt("8");
|
|
138
|
-
const TWOFIFTYSIX = BigInt("256");
|
|
139
|
-
function isSpecial(n) {
|
|
140
|
-
return Number.isNaN(n) || !Number.isFinite(n) || Object.is(n, -0);
|
|
141
|
-
}
|
|
142
|
-
function slowBigIntToBase64(value) {
|
|
143
|
-
if (value < ZERO) value -= MIN_INT64 + MIN_INT64;
|
|
144
|
-
let hex = value.toString(16);
|
|
145
|
-
if (hex.length % 2 === 1) hex = "0" + hex;
|
|
146
|
-
const bytes = new Uint8Array(/* @__PURE__ */ new ArrayBuffer(8));
|
|
147
|
-
let i = 0;
|
|
148
|
-
for (const hexByte of hex.match(/.{2}/g).reverse()) {
|
|
149
|
-
bytes.set([parseInt(hexByte, 16)], i++);
|
|
150
|
-
value >>= EIGHT;
|
|
151
|
-
}
|
|
152
|
-
return fromByteArray(bytes);
|
|
153
|
-
}
|
|
154
|
-
function slowBase64ToBigInt(encoded) {
|
|
155
|
-
const integerBytes = toByteArray(encoded);
|
|
156
|
-
if (integerBytes.byteLength !== 8) throw new Error(`Received ${integerBytes.byteLength} bytes, expected 8 for $integer`);
|
|
157
|
-
let value = ZERO;
|
|
158
|
-
let power = ZERO;
|
|
159
|
-
for (const byte of integerBytes) {
|
|
160
|
-
value += BigInt(byte) * TWOFIFTYSIX ** power;
|
|
161
|
-
power++;
|
|
162
|
-
}
|
|
163
|
-
if (value > MAX_INT64) value += MIN_INT64 + MIN_INT64;
|
|
164
|
-
return value;
|
|
165
|
-
}
|
|
166
|
-
function modernBigIntToBase64(value) {
|
|
167
|
-
if (value < MIN_INT64 || MAX_INT64 < value) throw new Error(`BigInt ${value} does not fit into a 64-bit signed integer.`);
|
|
168
|
-
const buffer = /* @__PURE__ */ new ArrayBuffer(8);
|
|
169
|
-
new DataView(buffer).setBigInt64(0, value, true);
|
|
170
|
-
return fromByteArray(new Uint8Array(buffer));
|
|
171
|
-
}
|
|
172
|
-
function modernBase64ToBigInt(encoded) {
|
|
173
|
-
const integerBytes = toByteArray(encoded);
|
|
174
|
-
if (integerBytes.byteLength !== 8) throw new Error(`Received ${integerBytes.byteLength} bytes, expected 8 for $integer`);
|
|
175
|
-
return new DataView(integerBytes.buffer).getBigInt64(0, true);
|
|
176
|
-
}
|
|
177
|
-
const bigIntToBase64 = DataView.prototype.setBigInt64 ? modernBigIntToBase64 : slowBigIntToBase64;
|
|
178
|
-
const base64ToBigInt = DataView.prototype.getBigInt64 ? modernBase64ToBigInt : slowBase64ToBigInt;
|
|
179
|
-
const MAX_IDENTIFIER_LEN = 1024;
|
|
180
|
-
function validateObjectField(k) {
|
|
181
|
-
if (k.length > MAX_IDENTIFIER_LEN) throw new Error(`Field name ${k} exceeds maximum field name length ${MAX_IDENTIFIER_LEN}.`);
|
|
182
|
-
if (k.startsWith("$")) throw new Error(`Field name ${k} starts with a '$', which is reserved.`);
|
|
183
|
-
for (let i = 0; i < k.length; i += 1) {
|
|
184
|
-
const charCode = k.charCodeAt(i);
|
|
185
|
-
if (charCode < 32 || charCode >= 127) throw new Error(`Field name ${k} has invalid character '${k[i]}': Field names can only contain non-control ASCII characters`);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
function jsonToConvex(value) {
|
|
189
|
-
if (value === null) return value;
|
|
190
|
-
if (typeof value === "boolean") return value;
|
|
191
|
-
if (typeof value === "number") return value;
|
|
192
|
-
if (typeof value === "string") return value;
|
|
193
|
-
if (Array.isArray(value)) return value.map((value2) => jsonToConvex(value2));
|
|
194
|
-
if (typeof value !== "object") throw new Error(`Unexpected type of ${value}`);
|
|
195
|
-
const entries = Object.entries(value);
|
|
196
|
-
if (entries.length === 1) {
|
|
197
|
-
const key = entries[0][0];
|
|
198
|
-
if (key === "$bytes") {
|
|
199
|
-
if (typeof value.$bytes !== "string") throw new Error(`Malformed $bytes field on ${value}`);
|
|
200
|
-
return toByteArray(value.$bytes).buffer;
|
|
201
|
-
}
|
|
202
|
-
if (key === "$integer") {
|
|
203
|
-
if (typeof value.$integer !== "string") throw new Error(`Malformed $integer field on ${value}`);
|
|
204
|
-
return base64ToBigInt(value.$integer);
|
|
205
|
-
}
|
|
206
|
-
if (key === "$float") {
|
|
207
|
-
if (typeof value.$float !== "string") throw new Error(`Malformed $float field on ${value}`);
|
|
208
|
-
const floatBytes = toByteArray(value.$float);
|
|
209
|
-
if (floatBytes.byteLength !== 8) throw new Error(`Received ${floatBytes.byteLength} bytes, expected 8 for $float`);
|
|
210
|
-
const float = new DataView(floatBytes.buffer).getFloat64(0, LITTLE_ENDIAN);
|
|
211
|
-
if (!isSpecial(float)) throw new Error(`Float ${float} should be encoded as a number`);
|
|
212
|
-
return float;
|
|
213
|
-
}
|
|
214
|
-
if (key === "$set") throw new Error(`Received a Set which is no longer supported as a Convex type.`);
|
|
215
|
-
if (key === "$map") throw new Error(`Received a Map which is no longer supported as a Convex type.`);
|
|
216
|
-
}
|
|
217
|
-
const out = {};
|
|
218
|
-
for (const [k, v] of Object.entries(value)) {
|
|
219
|
-
validateObjectField(k);
|
|
220
|
-
out[k] = jsonToConvex(v);
|
|
221
|
-
}
|
|
222
|
-
return out;
|
|
223
|
-
}
|
|
224
|
-
const MAX_VALUE_FOR_ERROR_LEN = 16384;
|
|
225
|
-
function stringifyValueForError(value) {
|
|
226
|
-
const str = JSON.stringify(value, (_key, value2) => {
|
|
227
|
-
if (value2 === void 0) return "undefined";
|
|
228
|
-
if (typeof value2 === "bigint") return `${value2.toString()}n`;
|
|
229
|
-
return value2;
|
|
230
|
-
});
|
|
231
|
-
if (str.length > MAX_VALUE_FOR_ERROR_LEN) {
|
|
232
|
-
const rest = "[...truncated]";
|
|
233
|
-
let truncateAt = 16370;
|
|
234
|
-
const codePoint = str.codePointAt(truncateAt - 1);
|
|
235
|
-
if (codePoint !== void 0 && codePoint > 65535) truncateAt -= 1;
|
|
236
|
-
return str.substring(0, truncateAt) + rest;
|
|
237
|
-
}
|
|
238
|
-
return str;
|
|
239
|
-
}
|
|
240
|
-
function convexToJsonInternal(value, originalValue, context, includeTopLevelUndefined) {
|
|
241
|
-
if (value === void 0) {
|
|
242
|
-
const contextText = context && ` (present at path ${context} in original object ${stringifyValueForError(originalValue)})`;
|
|
243
|
-
throw new Error(`undefined is not a valid Convex value${contextText}. To learn about Convex's supported types, see https://docs.convex.dev/using/types.`);
|
|
244
|
-
}
|
|
245
|
-
if (value === null) return value;
|
|
246
|
-
if (typeof value === "bigint") {
|
|
247
|
-
if (value < MIN_INT64 || MAX_INT64 < value) throw new Error(`BigInt ${value} does not fit into a 64-bit signed integer.`);
|
|
248
|
-
return { $integer: bigIntToBase64(value) };
|
|
249
|
-
}
|
|
250
|
-
if (typeof value === "number") {
|
|
251
|
-
if (isSpecial(value)) {
|
|
252
|
-
const buffer = /* @__PURE__ */ new ArrayBuffer(8);
|
|
253
|
-
new DataView(buffer).setFloat64(0, value, LITTLE_ENDIAN);
|
|
254
|
-
return { $float: fromByteArray(new Uint8Array(buffer)) };
|
|
255
|
-
} else return value;
|
|
256
|
-
}
|
|
257
|
-
if (typeof value === "boolean") return value;
|
|
258
|
-
if (typeof value === "string") return value;
|
|
259
|
-
if (value instanceof ArrayBuffer) return { $bytes: fromByteArray(new Uint8Array(value)) };
|
|
260
|
-
if (Array.isArray(value)) return value.map((value2, i) => convexToJsonInternal(value2, originalValue, context + `[${i}]`, false));
|
|
261
|
-
if (value instanceof Set) throw new Error(errorMessageForUnsupportedType(context, "Set", [...value], originalValue));
|
|
262
|
-
if (value instanceof Map) throw new Error(errorMessageForUnsupportedType(context, "Map", [...value], originalValue));
|
|
263
|
-
if (!isSimpleObject(value)) {
|
|
264
|
-
const theType = value?.constructor?.name;
|
|
265
|
-
const typeName = theType ? `${theType} ` : "";
|
|
266
|
-
throw new Error(errorMessageForUnsupportedType(context, typeName, value, originalValue));
|
|
267
|
-
}
|
|
268
|
-
const out = {};
|
|
269
|
-
const entries = Object.entries(value);
|
|
270
|
-
entries.sort(([k1, _v1], [k2, _v2]) => k1 === k2 ? 0 : k1 < k2 ? -1 : 1);
|
|
271
|
-
for (const [k, v] of entries) if (v !== void 0) {
|
|
272
|
-
validateObjectField(k);
|
|
273
|
-
out[k] = convexToJsonInternal(v, originalValue, context + `.${k}`, false);
|
|
274
|
-
} else if (includeTopLevelUndefined) {
|
|
275
|
-
validateObjectField(k);
|
|
276
|
-
out[k] = convexOrUndefinedToJsonInternal(v, originalValue, context + `.${k}`);
|
|
277
|
-
}
|
|
278
|
-
return out;
|
|
279
|
-
}
|
|
280
|
-
function errorMessageForUnsupportedType(context, typeName, value, originalValue) {
|
|
281
|
-
if (context) return `${typeName}${stringifyValueForError(value)} is not a supported Convex type (present at path ${context} in original object ${stringifyValueForError(originalValue)}). To learn about Convex's supported types, see https://docs.convex.dev/using/types.`;
|
|
282
|
-
else return `${typeName}${stringifyValueForError(value)} is not a supported Convex type.`;
|
|
283
|
-
}
|
|
284
|
-
function convexOrUndefinedToJsonInternal(value, originalValue, context) {
|
|
285
|
-
if (value === void 0) return { $undefined: null };
|
|
286
|
-
else {
|
|
287
|
-
if (originalValue === void 0) throw new Error(`Programming error. Current value is ${stringifyValueForError(value)} but original value is undefined`);
|
|
288
|
-
return convexToJsonInternal(value, originalValue, context, false);
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
function convexToJson(value) {
|
|
292
|
-
return convexToJsonInternal(value, value, "", false);
|
|
293
|
-
}
|
|
294
|
-
//#endregion
|
|
295
|
-
//#region ../../node_modules/.pnpm/convex@1.39.1_react@19.2.7/node_modules/convex/dist/esm/values/errors.js
|
|
296
|
-
var __defProp$12 = Object.defineProperty;
|
|
297
|
-
var __defNormalProp$12 = (obj, key, value) => key in obj ? __defProp$12(obj, key, {
|
|
298
|
-
enumerable: true,
|
|
299
|
-
configurable: true,
|
|
300
|
-
writable: true,
|
|
301
|
-
value
|
|
302
|
-
}) : obj[key] = value;
|
|
303
|
-
var __publicField$12 = (obj, key, value) => __defNormalProp$12(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
304
|
-
var _a;
|
|
305
|
-
var _b;
|
|
306
|
-
const IDENTIFYING_FIELD = Symbol.for("ConvexError");
|
|
307
|
-
var ConvexError = class extends (_b = Error, _a = IDENTIFYING_FIELD, _b) {
|
|
308
|
-
constructor(data) {
|
|
309
|
-
super(typeof data === "string" ? data : stringifyValueForError(data));
|
|
310
|
-
__publicField$12(this, "name", "ConvexError");
|
|
311
|
-
__publicField$12(this, "data");
|
|
312
|
-
__publicField$12(this, _a, true);
|
|
313
|
-
this.data = data;
|
|
314
|
-
}
|
|
315
|
-
};
|
|
316
|
-
//#endregion
|
|
317
|
-
//#region ../../node_modules/.pnpm/convex@1.39.1_react@19.2.7/node_modules/convex/dist/esm/index.js
|
|
318
|
-
const version = "1.39.1";
|
|
29
|
+
var version$1 = "4.20.0-beta.43";
|
|
319
30
|
//#endregion
|
|
320
31
|
//#region ../../node_modules/.pnpm/viem@2.55.18_patch_hash=6dka2762lzcggf7at6h6xt4khq_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/utils/unit/formatGwei.js
|
|
321
32
|
/**
|
|
@@ -1398,8 +1109,8 @@ const browserExportClient = (client) => HttpClient.transform(client, (response,
|
|
|
1398
1109
|
const spanUpstream = (span) => {
|
|
1399
1110
|
let current = span;
|
|
1400
1111
|
while (current?._tag === "Span") {
|
|
1401
|
-
const
|
|
1402
|
-
if (
|
|
1112
|
+
const source = urlCredentialSource(current.attributes.get("chain.upstream"));
|
|
1113
|
+
if (source !== void 0) return source;
|
|
1403
1114
|
current = current.parent._tag === "Some" ? current.parent.value : void 0;
|
|
1404
1115
|
}
|
|
1405
1116
|
};
|
|
@@ -1722,13 +1433,18 @@ function cliEngineeringDelivery(budget, ownsMetrics) {
|
|
|
1722
1433
|
}
|
|
1723
1434
|
//#endregion
|
|
1724
1435
|
//#region ../../packages/observability/src/engineering/config.ts
|
|
1725
|
-
/**
|
|
1436
|
+
/**
|
|
1437
|
+
* `devnet` is a DevNet's label (CAP-798); `local` is its retired label, kept for
|
|
1438
|
+
* older callers. `unset` is a CLI with no environment chosen (CAP-931).
|
|
1439
|
+
*/
|
|
1726
1440
|
const ENGINEERING_CAPXUL_ENVS = [
|
|
1727
1441
|
"development",
|
|
1728
1442
|
"staging",
|
|
1443
|
+
"beta",
|
|
1729
1444
|
"production",
|
|
1730
1445
|
"devnet",
|
|
1731
|
-
"local"
|
|
1446
|
+
"local",
|
|
1447
|
+
"unset"
|
|
1732
1448
|
];
|
|
1733
1449
|
const traceHeaderFilter = (_name) => true;
|
|
1734
1450
|
const credentialHeaderPattern = Object.assign(/./u, { exec: (name) => isCredentialField(name, "header") ? Object.assign([name], {
|
|
@@ -1805,12 +1521,20 @@ const MINIMAL_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
|
1805
1521
|
"CLI_CONFIG",
|
|
1806
1522
|
"CLI_STORAGE",
|
|
1807
1523
|
"CLI_DEFECT",
|
|
1808
|
-
"CLI_DEADLINE"
|
|
1524
|
+
"CLI_DEADLINE",
|
|
1525
|
+
"WRONG_ENVIRONMENT",
|
|
1526
|
+
"EXPERIMENTAL_NOT_ACCEPTED",
|
|
1527
|
+
"ENVIRONMENT_NOT_CHOSEN"
|
|
1809
1528
|
]);
|
|
1810
1529
|
const MINIMAL_NUMBERS = /* @__PURE__ */ new Set([
|
|
1811
1530
|
"schema_version",
|
|
1812
1531
|
"duration_ms",
|
|
1813
1532
|
"wait_duration_ms",
|
|
1533
|
+
"wait_scope_ms",
|
|
1534
|
+
"wait_transfers_ms",
|
|
1535
|
+
"wait_payments_ms",
|
|
1536
|
+
"wait_decoration_ms",
|
|
1537
|
+
"wait_facts_ms",
|
|
1814
1538
|
"retry_count",
|
|
1815
1539
|
"http.status_code",
|
|
1816
1540
|
"http.response.status_code",
|
|
@@ -2287,6 +2011,295 @@ const makeEngineeringTelemetryLayer = (config) => {
|
|
|
2287
2011
|
});
|
|
2288
2012
|
};
|
|
2289
2013
|
//#endregion
|
|
2014
|
+
//#region ../../node_modules/.pnpm/convex@1.39.1_react@19.2.7/node_modules/convex/dist/esm/values/base64.js
|
|
2015
|
+
var lookup = [];
|
|
2016
|
+
var revLookup = [];
|
|
2017
|
+
var Arr = Uint8Array;
|
|
2018
|
+
var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
2019
|
+
for (var i = 0, len = code.length; i < len; ++i) {
|
|
2020
|
+
lookup[i] = code[i];
|
|
2021
|
+
revLookup[code.charCodeAt(i)] = i;
|
|
2022
|
+
}
|
|
2023
|
+
revLookup["-".charCodeAt(0)] = 62;
|
|
2024
|
+
revLookup["_".charCodeAt(0)] = 63;
|
|
2025
|
+
function getLens(b64) {
|
|
2026
|
+
var len = b64.length;
|
|
2027
|
+
if (len % 4 > 0) throw new Error("Invalid string. Length must be a multiple of 4");
|
|
2028
|
+
var validLen = b64.indexOf("=");
|
|
2029
|
+
if (validLen === -1) validLen = len;
|
|
2030
|
+
var placeHoldersLen = validLen === len ? 0 : 4 - validLen % 4;
|
|
2031
|
+
return [validLen, placeHoldersLen];
|
|
2032
|
+
}
|
|
2033
|
+
function _byteLength(_b64, validLen, placeHoldersLen) {
|
|
2034
|
+
return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
|
|
2035
|
+
}
|
|
2036
|
+
function toByteArray(b64) {
|
|
2037
|
+
var tmp;
|
|
2038
|
+
var lens = getLens(b64);
|
|
2039
|
+
var validLen = lens[0];
|
|
2040
|
+
var placeHoldersLen = lens[1];
|
|
2041
|
+
var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
|
|
2042
|
+
var curByte = 0;
|
|
2043
|
+
var len = placeHoldersLen > 0 ? validLen - 4 : validLen;
|
|
2044
|
+
var i = 0;
|
|
2045
|
+
for (; i < len; i += 4) {
|
|
2046
|
+
tmp = revLookup[b64.charCodeAt(i)] << 18 | revLookup[b64.charCodeAt(i + 1)] << 12 | revLookup[b64.charCodeAt(i + 2)] << 6 | revLookup[b64.charCodeAt(i + 3)];
|
|
2047
|
+
arr[curByte++] = tmp >> 16 & 255;
|
|
2048
|
+
arr[curByte++] = tmp >> 8 & 255;
|
|
2049
|
+
arr[curByte++] = tmp & 255;
|
|
2050
|
+
}
|
|
2051
|
+
if (placeHoldersLen === 2) {
|
|
2052
|
+
tmp = revLookup[b64.charCodeAt(i)] << 2 | revLookup[b64.charCodeAt(i + 1)] >> 4;
|
|
2053
|
+
arr[curByte++] = tmp & 255;
|
|
2054
|
+
}
|
|
2055
|
+
if (placeHoldersLen === 1) {
|
|
2056
|
+
tmp = revLookup[b64.charCodeAt(i)] << 10 | revLookup[b64.charCodeAt(i + 1)] << 4 | revLookup[b64.charCodeAt(i + 2)] >> 2;
|
|
2057
|
+
arr[curByte++] = tmp >> 8 & 255;
|
|
2058
|
+
arr[curByte++] = tmp & 255;
|
|
2059
|
+
}
|
|
2060
|
+
return arr;
|
|
2061
|
+
}
|
|
2062
|
+
function tripletToBase64(num) {
|
|
2063
|
+
return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
|
|
2064
|
+
}
|
|
2065
|
+
function encodeChunk(uint8, start, end) {
|
|
2066
|
+
var tmp;
|
|
2067
|
+
var output = [];
|
|
2068
|
+
for (var i = start; i < end; i += 3) {
|
|
2069
|
+
tmp = (uint8[i] << 16 & 16711680) + (uint8[i + 1] << 8 & 65280) + (uint8[i + 2] & 255);
|
|
2070
|
+
output.push(tripletToBase64(tmp));
|
|
2071
|
+
}
|
|
2072
|
+
return output.join("");
|
|
2073
|
+
}
|
|
2074
|
+
function fromByteArray(uint8) {
|
|
2075
|
+
var tmp;
|
|
2076
|
+
var len = uint8.length;
|
|
2077
|
+
var extraBytes = len % 3;
|
|
2078
|
+
var parts = [];
|
|
2079
|
+
var maxChunkLength = 16383;
|
|
2080
|
+
for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) parts.push(encodeChunk(uint8, i, i + maxChunkLength > len2 ? len2 : i + maxChunkLength));
|
|
2081
|
+
if (extraBytes === 1) {
|
|
2082
|
+
tmp = uint8[len - 1];
|
|
2083
|
+
parts.push(lookup[tmp >> 2] + lookup[tmp << 4 & 63] + "==");
|
|
2084
|
+
} else if (extraBytes === 2) {
|
|
2085
|
+
tmp = (uint8[len - 2] << 8) + uint8[len - 1];
|
|
2086
|
+
parts.push(lookup[tmp >> 10] + lookup[tmp >> 4 & 63] + lookup[tmp << 2 & 63] + "=");
|
|
2087
|
+
}
|
|
2088
|
+
return parts.join("");
|
|
2089
|
+
}
|
|
2090
|
+
//#endregion
|
|
2091
|
+
//#region ../../node_modules/.pnpm/convex@1.39.1_react@19.2.7/node_modules/convex/dist/esm/common/index.js
|
|
2092
|
+
function parseArgs(args) {
|
|
2093
|
+
if (args === void 0) return {};
|
|
2094
|
+
if (!isSimpleObject(args)) throw new Error(`The arguments to a Convex function must be an object. Received: ${args}`);
|
|
2095
|
+
return args;
|
|
2096
|
+
}
|
|
2097
|
+
function validateDeploymentUrl(deploymentUrl) {
|
|
2098
|
+
if (typeof deploymentUrl === "undefined") throw new Error(`Client created with undefined deployment address. If you used an environment variable, check that it's set.`);
|
|
2099
|
+
if (typeof deploymentUrl !== "string") throw new Error(`Invalid deployment address: found ${deploymentUrl}".`);
|
|
2100
|
+
if (!(deploymentUrl.startsWith("http:") || deploymentUrl.startsWith("https:"))) throw new Error(`Invalid deployment address: Must start with "https://" or "http://". Found "${deploymentUrl}".`);
|
|
2101
|
+
try {
|
|
2102
|
+
new URL(deploymentUrl);
|
|
2103
|
+
} catch {
|
|
2104
|
+
throw new Error(`Invalid deployment address: "${deploymentUrl}" is not a valid URL. If you believe this URL is correct, use the \`skipConvexDeploymentUrlCheck\` option to bypass this.`);
|
|
2105
|
+
}
|
|
2106
|
+
if (deploymentUrl.endsWith(".convex.site")) throw new Error(`Invalid deployment address: "${deploymentUrl}" ends with .convex.site, which is used for HTTP Actions. Convex deployment URLs typically end with .convex.cloud? If you believe this URL is correct, use the \`skipConvexDeploymentUrlCheck\` option to bypass this.`);
|
|
2107
|
+
}
|
|
2108
|
+
function isSimpleObject(value) {
|
|
2109
|
+
const isObject = typeof value === "object";
|
|
2110
|
+
const prototype = Object.getPrototypeOf(value);
|
|
2111
|
+
const isSimple = prototype === null || prototype === Object.prototype || prototype?.constructor?.name === "Object";
|
|
2112
|
+
return isObject && isSimple;
|
|
2113
|
+
}
|
|
2114
|
+
//#endregion
|
|
2115
|
+
//#region ../../node_modules/.pnpm/convex@1.39.1_react@19.2.7/node_modules/convex/dist/esm/values/value.js
|
|
2116
|
+
const LITTLE_ENDIAN = true;
|
|
2117
|
+
const MIN_INT64 = BigInt("-9223372036854775808");
|
|
2118
|
+
const MAX_INT64 = BigInt("9223372036854775807");
|
|
2119
|
+
const ZERO = BigInt("0");
|
|
2120
|
+
const EIGHT = BigInt("8");
|
|
2121
|
+
const TWOFIFTYSIX = BigInt("256");
|
|
2122
|
+
function isSpecial(n) {
|
|
2123
|
+
return Number.isNaN(n) || !Number.isFinite(n) || Object.is(n, -0);
|
|
2124
|
+
}
|
|
2125
|
+
function slowBigIntToBase64(value) {
|
|
2126
|
+
if (value < ZERO) value -= MIN_INT64 + MIN_INT64;
|
|
2127
|
+
let hex = value.toString(16);
|
|
2128
|
+
if (hex.length % 2 === 1) hex = "0" + hex;
|
|
2129
|
+
const bytes = new Uint8Array(/* @__PURE__ */ new ArrayBuffer(8));
|
|
2130
|
+
let i = 0;
|
|
2131
|
+
for (const hexByte of hex.match(/.{2}/g).reverse()) {
|
|
2132
|
+
bytes.set([parseInt(hexByte, 16)], i++);
|
|
2133
|
+
value >>= EIGHT;
|
|
2134
|
+
}
|
|
2135
|
+
return fromByteArray(bytes);
|
|
2136
|
+
}
|
|
2137
|
+
function slowBase64ToBigInt(encoded) {
|
|
2138
|
+
const integerBytes = toByteArray(encoded);
|
|
2139
|
+
if (integerBytes.byteLength !== 8) throw new Error(`Received ${integerBytes.byteLength} bytes, expected 8 for $integer`);
|
|
2140
|
+
let value = ZERO;
|
|
2141
|
+
let power = ZERO;
|
|
2142
|
+
for (const byte of integerBytes) {
|
|
2143
|
+
value += BigInt(byte) * TWOFIFTYSIX ** power;
|
|
2144
|
+
power++;
|
|
2145
|
+
}
|
|
2146
|
+
if (value > MAX_INT64) value += MIN_INT64 + MIN_INT64;
|
|
2147
|
+
return value;
|
|
2148
|
+
}
|
|
2149
|
+
function modernBigIntToBase64(value) {
|
|
2150
|
+
if (value < MIN_INT64 || MAX_INT64 < value) throw new Error(`BigInt ${value} does not fit into a 64-bit signed integer.`);
|
|
2151
|
+
const buffer = /* @__PURE__ */ new ArrayBuffer(8);
|
|
2152
|
+
new DataView(buffer).setBigInt64(0, value, true);
|
|
2153
|
+
return fromByteArray(new Uint8Array(buffer));
|
|
2154
|
+
}
|
|
2155
|
+
function modernBase64ToBigInt(encoded) {
|
|
2156
|
+
const integerBytes = toByteArray(encoded);
|
|
2157
|
+
if (integerBytes.byteLength !== 8) throw new Error(`Received ${integerBytes.byteLength} bytes, expected 8 for $integer`);
|
|
2158
|
+
return new DataView(integerBytes.buffer).getBigInt64(0, true);
|
|
2159
|
+
}
|
|
2160
|
+
const bigIntToBase64 = DataView.prototype.setBigInt64 ? modernBigIntToBase64 : slowBigIntToBase64;
|
|
2161
|
+
const base64ToBigInt = DataView.prototype.getBigInt64 ? modernBase64ToBigInt : slowBase64ToBigInt;
|
|
2162
|
+
const MAX_IDENTIFIER_LEN = 1024;
|
|
2163
|
+
function validateObjectField(k) {
|
|
2164
|
+
if (k.length > MAX_IDENTIFIER_LEN) throw new Error(`Field name ${k} exceeds maximum field name length ${MAX_IDENTIFIER_LEN}.`);
|
|
2165
|
+
if (k.startsWith("$")) throw new Error(`Field name ${k} starts with a '$', which is reserved.`);
|
|
2166
|
+
for (let i = 0; i < k.length; i += 1) {
|
|
2167
|
+
const charCode = k.charCodeAt(i);
|
|
2168
|
+
if (charCode < 32 || charCode >= 127) throw new Error(`Field name ${k} has invalid character '${k[i]}': Field names can only contain non-control ASCII characters`);
|
|
2169
|
+
}
|
|
2170
|
+
}
|
|
2171
|
+
function jsonToConvex(value) {
|
|
2172
|
+
if (value === null) return value;
|
|
2173
|
+
if (typeof value === "boolean") return value;
|
|
2174
|
+
if (typeof value === "number") return value;
|
|
2175
|
+
if (typeof value === "string") return value;
|
|
2176
|
+
if (Array.isArray(value)) return value.map((value2) => jsonToConvex(value2));
|
|
2177
|
+
if (typeof value !== "object") throw new Error(`Unexpected type of ${value}`);
|
|
2178
|
+
const entries = Object.entries(value);
|
|
2179
|
+
if (entries.length === 1) {
|
|
2180
|
+
const key = entries[0][0];
|
|
2181
|
+
if (key === "$bytes") {
|
|
2182
|
+
if (typeof value.$bytes !== "string") throw new Error(`Malformed $bytes field on ${value}`);
|
|
2183
|
+
return toByteArray(value.$bytes).buffer;
|
|
2184
|
+
}
|
|
2185
|
+
if (key === "$integer") {
|
|
2186
|
+
if (typeof value.$integer !== "string") throw new Error(`Malformed $integer field on ${value}`);
|
|
2187
|
+
return base64ToBigInt(value.$integer);
|
|
2188
|
+
}
|
|
2189
|
+
if (key === "$float") {
|
|
2190
|
+
if (typeof value.$float !== "string") throw new Error(`Malformed $float field on ${value}`);
|
|
2191
|
+
const floatBytes = toByteArray(value.$float);
|
|
2192
|
+
if (floatBytes.byteLength !== 8) throw new Error(`Received ${floatBytes.byteLength} bytes, expected 8 for $float`);
|
|
2193
|
+
const float = new DataView(floatBytes.buffer).getFloat64(0, LITTLE_ENDIAN);
|
|
2194
|
+
if (!isSpecial(float)) throw new Error(`Float ${float} should be encoded as a number`);
|
|
2195
|
+
return float;
|
|
2196
|
+
}
|
|
2197
|
+
if (key === "$set") throw new Error(`Received a Set which is no longer supported as a Convex type.`);
|
|
2198
|
+
if (key === "$map") throw new Error(`Received a Map which is no longer supported as a Convex type.`);
|
|
2199
|
+
}
|
|
2200
|
+
const out = {};
|
|
2201
|
+
for (const [k, v] of Object.entries(value)) {
|
|
2202
|
+
validateObjectField(k);
|
|
2203
|
+
out[k] = jsonToConvex(v);
|
|
2204
|
+
}
|
|
2205
|
+
return out;
|
|
2206
|
+
}
|
|
2207
|
+
const MAX_VALUE_FOR_ERROR_LEN = 16384;
|
|
2208
|
+
function stringifyValueForError(value) {
|
|
2209
|
+
const str = JSON.stringify(value, (_key, value2) => {
|
|
2210
|
+
if (value2 === void 0) return "undefined";
|
|
2211
|
+
if (typeof value2 === "bigint") return `${value2.toString()}n`;
|
|
2212
|
+
return value2;
|
|
2213
|
+
});
|
|
2214
|
+
if (str.length > MAX_VALUE_FOR_ERROR_LEN) {
|
|
2215
|
+
const rest = "[...truncated]";
|
|
2216
|
+
let truncateAt = 16370;
|
|
2217
|
+
const codePoint = str.codePointAt(truncateAt - 1);
|
|
2218
|
+
if (codePoint !== void 0 && codePoint > 65535) truncateAt -= 1;
|
|
2219
|
+
return str.substring(0, truncateAt) + rest;
|
|
2220
|
+
}
|
|
2221
|
+
return str;
|
|
2222
|
+
}
|
|
2223
|
+
function convexToJsonInternal(value, originalValue, context, includeTopLevelUndefined) {
|
|
2224
|
+
if (value === void 0) {
|
|
2225
|
+
const contextText = context && ` (present at path ${context} in original object ${stringifyValueForError(originalValue)})`;
|
|
2226
|
+
throw new Error(`undefined is not a valid Convex value${contextText}. To learn about Convex's supported types, see https://docs.convex.dev/using/types.`);
|
|
2227
|
+
}
|
|
2228
|
+
if (value === null) return value;
|
|
2229
|
+
if (typeof value === "bigint") {
|
|
2230
|
+
if (value < MIN_INT64 || MAX_INT64 < value) throw new Error(`BigInt ${value} does not fit into a 64-bit signed integer.`);
|
|
2231
|
+
return { $integer: bigIntToBase64(value) };
|
|
2232
|
+
}
|
|
2233
|
+
if (typeof value === "number") {
|
|
2234
|
+
if (isSpecial(value)) {
|
|
2235
|
+
const buffer = /* @__PURE__ */ new ArrayBuffer(8);
|
|
2236
|
+
new DataView(buffer).setFloat64(0, value, LITTLE_ENDIAN);
|
|
2237
|
+
return { $float: fromByteArray(new Uint8Array(buffer)) };
|
|
2238
|
+
} else return value;
|
|
2239
|
+
}
|
|
2240
|
+
if (typeof value === "boolean") return value;
|
|
2241
|
+
if (typeof value === "string") return value;
|
|
2242
|
+
if (value instanceof ArrayBuffer) return { $bytes: fromByteArray(new Uint8Array(value)) };
|
|
2243
|
+
if (Array.isArray(value)) return value.map((value2, i) => convexToJsonInternal(value2, originalValue, context + `[${i}]`, false));
|
|
2244
|
+
if (value instanceof Set) throw new Error(errorMessageForUnsupportedType(context, "Set", [...value], originalValue));
|
|
2245
|
+
if (value instanceof Map) throw new Error(errorMessageForUnsupportedType(context, "Map", [...value], originalValue));
|
|
2246
|
+
if (!isSimpleObject(value)) {
|
|
2247
|
+
const theType = value?.constructor?.name;
|
|
2248
|
+
const typeName = theType ? `${theType} ` : "";
|
|
2249
|
+
throw new Error(errorMessageForUnsupportedType(context, typeName, value, originalValue));
|
|
2250
|
+
}
|
|
2251
|
+
const out = {};
|
|
2252
|
+
const entries = Object.entries(value);
|
|
2253
|
+
entries.sort(([k1, _v1], [k2, _v2]) => k1 === k2 ? 0 : k1 < k2 ? -1 : 1);
|
|
2254
|
+
for (const [k, v] of entries) if (v !== void 0) {
|
|
2255
|
+
validateObjectField(k);
|
|
2256
|
+
out[k] = convexToJsonInternal(v, originalValue, context + `.${k}`, false);
|
|
2257
|
+
} else if (includeTopLevelUndefined) {
|
|
2258
|
+
validateObjectField(k);
|
|
2259
|
+
out[k] = convexOrUndefinedToJsonInternal(v, originalValue, context + `.${k}`);
|
|
2260
|
+
}
|
|
2261
|
+
return out;
|
|
2262
|
+
}
|
|
2263
|
+
function errorMessageForUnsupportedType(context, typeName, value, originalValue) {
|
|
2264
|
+
if (context) return `${typeName}${stringifyValueForError(value)} is not a supported Convex type (present at path ${context} in original object ${stringifyValueForError(originalValue)}). To learn about Convex's supported types, see https://docs.convex.dev/using/types.`;
|
|
2265
|
+
else return `${typeName}${stringifyValueForError(value)} is not a supported Convex type.`;
|
|
2266
|
+
}
|
|
2267
|
+
function convexOrUndefinedToJsonInternal(value, originalValue, context) {
|
|
2268
|
+
if (value === void 0) return { $undefined: null };
|
|
2269
|
+
else {
|
|
2270
|
+
if (originalValue === void 0) throw new Error(`Programming error. Current value is ${stringifyValueForError(value)} but original value is undefined`);
|
|
2271
|
+
return convexToJsonInternal(value, originalValue, context, false);
|
|
2272
|
+
}
|
|
2273
|
+
}
|
|
2274
|
+
function convexToJson(value) {
|
|
2275
|
+
return convexToJsonInternal(value, value, "", false);
|
|
2276
|
+
}
|
|
2277
|
+
//#endregion
|
|
2278
|
+
//#region ../../node_modules/.pnpm/convex@1.39.1_react@19.2.7/node_modules/convex/dist/esm/values/errors.js
|
|
2279
|
+
var __defProp$12 = Object.defineProperty;
|
|
2280
|
+
var __defNormalProp$12 = (obj, key, value) => key in obj ? __defProp$12(obj, key, {
|
|
2281
|
+
enumerable: true,
|
|
2282
|
+
configurable: true,
|
|
2283
|
+
writable: true,
|
|
2284
|
+
value
|
|
2285
|
+
}) : obj[key] = value;
|
|
2286
|
+
var __publicField$12 = (obj, key, value) => __defNormalProp$12(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2287
|
+
var _a;
|
|
2288
|
+
var _b;
|
|
2289
|
+
const IDENTIFYING_FIELD = Symbol.for("ConvexError");
|
|
2290
|
+
var ConvexError = class extends (_b = Error, _a = IDENTIFYING_FIELD, _b) {
|
|
2291
|
+
constructor(data) {
|
|
2292
|
+
super(typeof data === "string" ? data : stringifyValueForError(data));
|
|
2293
|
+
__publicField$12(this, "name", "ConvexError");
|
|
2294
|
+
__publicField$12(this, "data");
|
|
2295
|
+
__publicField$12(this, _a, true);
|
|
2296
|
+
this.data = data;
|
|
2297
|
+
}
|
|
2298
|
+
};
|
|
2299
|
+
//#endregion
|
|
2300
|
+
//#region ../../node_modules/.pnpm/convex@1.39.1_react@19.2.7/node_modules/convex/dist/esm/index.js
|
|
2301
|
+
const version = "1.39.1";
|
|
2302
|
+
//#endregion
|
|
2290
2303
|
//#region ../../node_modules/.pnpm/viem@2.55.18_patch_hash=6dka2762lzcggf7at6h6xt4khq_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/accounts/toAccount.js
|
|
2291
2304
|
/**
|
|
2292
2305
|
* @description Creates an Account from a custom signing implementation.
|
|
@@ -2468,6 +2481,33 @@ function privateKeyToAccount(privateKey, options = {}) {
|
|
|
2468
2481
|
};
|
|
2469
2482
|
}
|
|
2470
2483
|
//#endregion
|
|
2484
|
+
//#region ../../packages/sdk/src/payroll/department-pay.ts
|
|
2485
|
+
/** The department methods with `pay` bound to this client's approvals. */
|
|
2486
|
+
function withDepartmentPay(methods, orgId, prepare) {
|
|
2487
|
+
return {
|
|
2488
|
+
...methods,
|
|
2489
|
+
pay: async (department, input, options) => {
|
|
2490
|
+
const found = await methods.get(department, options);
|
|
2491
|
+
if (!found.ok) return found;
|
|
2492
|
+
return prepare({
|
|
2493
|
+
...input,
|
|
2494
|
+
organizationId: orgId,
|
|
2495
|
+
permissionId: found.value.departmentId
|
|
2496
|
+
}, options?.signal === void 0 ? void 0 : { signal: options.signal });
|
|
2497
|
+
}
|
|
2498
|
+
};
|
|
2499
|
+
}
|
|
2500
|
+
/** `client.org`, with each Organization's departments paying through `approvals` (CAP-1165). */
|
|
2501
|
+
function departmentPayingOrg(orgMethods, approvals) {
|
|
2502
|
+
return (orgId) => {
|
|
2503
|
+
const organization = orgMethods.org(orgId);
|
|
2504
|
+
return {
|
|
2505
|
+
...organization,
|
|
2506
|
+
departments: withDepartmentPay(organization.departments, String(orgId), (input, options) => approvals.prepare(input, options))
|
|
2507
|
+
};
|
|
2508
|
+
};
|
|
2509
|
+
}
|
|
2510
|
+
//#endregion
|
|
2471
2511
|
//#region ../../packages/sdk/src/platform/transport/convex-read-deadline.ts
|
|
2472
2512
|
/**
|
|
2473
2513
|
* How long a one-shot read waits for its answer: a query, or an action marked
|
|
@@ -2509,63 +2549,6 @@ function readTimedOut(operation, connection) {
|
|
|
2509
2549
|
}));
|
|
2510
2550
|
}
|
|
2511
2551
|
//#endregion
|
|
2512
|
-
//#region ../../packages/protocol/src/errors/convex-decoding.ts
|
|
2513
|
-
const KNOWN_CODES = new Set(CAPXUL_ERROR_CODES);
|
|
2514
|
-
function isCapxulCode(value) {
|
|
2515
|
-
return typeof value === "string" && KNOWN_CODES.has(value);
|
|
2516
|
-
}
|
|
2517
|
-
/**
|
|
2518
|
-
* A serialized failure, rebuilt whole. Nothing that crossed is dropped: a code
|
|
2519
|
-
* this build does not know (a newer backend) becomes an explicit `UNKNOWN` that
|
|
2520
|
-
* names the code it received, and an unrecognized mode or chain shape is kept
|
|
2521
|
-
* raw in `details` instead of being guessed at or discarded.
|
|
2522
|
-
*/
|
|
2523
|
-
function reconstruct(serialized) {
|
|
2524
|
-
if (typeof serialized.code !== "string") return null;
|
|
2525
|
-
const unrecognized = {
|
|
2526
|
-
...isCapxulCode(serialized.code) ? {} : { receivedCode: serialized.code },
|
|
2527
|
-
...serialized.mode === void 0 || isFailureMode(serialized.mode) ? {} : { unrecognizedMode: serialized.mode }
|
|
2528
|
-
};
|
|
2529
|
-
const chain = serialized.chain === void 0 ? null : decodeChainCause(serialized.chain);
|
|
2530
|
-
if (serialized.chain !== void 0 && chain === null) unrecognized.unrecognizedChain = serialized.chain;
|
|
2531
|
-
const hasDetails = isRecord(serialized.details) || Object.keys(unrecognized).length > 0;
|
|
2532
|
-
const cause = causeLinks(serialized.cause);
|
|
2533
|
-
const payload = {
|
|
2534
|
-
code: isCapxulCode(serialized.code) ? serialized.code : "UNKNOWN",
|
|
2535
|
-
message: typeof serialized.message === "string" ? serialized.message : serialized.code,
|
|
2536
|
-
...hasDetails ? { details: {
|
|
2537
|
-
...isRecord(serialized.details) ? serialized.details : {},
|
|
2538
|
-
...unrecognized
|
|
2539
|
-
} } : {},
|
|
2540
|
-
...typeof serialized.correlationId === "string" ? { correlationId: serialized.correlationId } : {},
|
|
2541
|
-
...typeof serialized.layer === "string" ? { layer: serialized.layer } : {},
|
|
2542
|
-
...isFailureMode(serialized.mode) ? { mode: serialized.mode } : {},
|
|
2543
|
-
...chain === null ? {} : { chain },
|
|
2544
|
-
...cause === void 0 ? {} : { cause }
|
|
2545
|
-
};
|
|
2546
|
-
return deserializeCapxulError(payload);
|
|
2547
|
-
}
|
|
2548
|
-
function causeLinks(value) {
|
|
2549
|
-
if (!Array.isArray(value)) return void 0;
|
|
2550
|
-
const links = value.filter((link) => isRecord(link) && typeof link.name === "string" && typeof link.message === "string");
|
|
2551
|
-
return links.length === 0 ? void 0 : links;
|
|
2552
|
-
}
|
|
2553
|
-
function decodeConvexError(err) {
|
|
2554
|
-
if (err === null || err === void 0) return null;
|
|
2555
|
-
if (err instanceof CapxulError) return err;
|
|
2556
|
-
if (typeof err !== "object") return null;
|
|
2557
|
-
if (!("data" in err)) return null;
|
|
2558
|
-
const data = err.data;
|
|
2559
|
-
if (isRecord(data)) return reconstruct(data);
|
|
2560
|
-
if (typeof data === "string") try {
|
|
2561
|
-
const parsed = JSON.parse(data);
|
|
2562
|
-
if (isRecord(parsed)) return reconstruct(parsed);
|
|
2563
|
-
} catch {
|
|
2564
|
-
return null;
|
|
2565
|
-
}
|
|
2566
|
-
return null;
|
|
2567
|
-
}
|
|
2568
|
-
//#endregion
|
|
2569
2552
|
//#region ../../packages/sdk/src/platform/transport/convex-errors.ts
|
|
2570
2553
|
/**
|
|
2571
2554
|
* All a redacting backend says about an error it raised itself: its request
|
|
@@ -2622,7 +2605,7 @@ function mapToCapxulError(operation, err, elapsedMs, transport) {
|
|
|
2622
2605
|
});
|
|
2623
2606
|
}
|
|
2624
2607
|
if (err instanceof Error && isTransportError(err)) return Errors.networkError(operation, err, { provider: "convex" });
|
|
2625
|
-
return backendFailure
|
|
2608
|
+
return backendFailure(operation, err, elapsedMs);
|
|
2626
2609
|
}
|
|
2627
2610
|
/**
|
|
2628
2611
|
* A failure the backend raised outside its own error boundary: Convex
|
|
@@ -2639,7 +2622,7 @@ function mapToCapxulError(operation, err, elapsedMs, transport) {
|
|
|
2639
2622
|
* the reply says where to look instead. The text matches stay for a backend
|
|
2640
2623
|
* that does not redact (development, local).
|
|
2641
2624
|
*/
|
|
2642
|
-
function backendFailure
|
|
2625
|
+
function backendFailure(operation, err, elapsedMs) {
|
|
2643
2626
|
const text = err instanceof Error ? err.message : String(err);
|
|
2644
2627
|
const redacted = REDACTED_ERROR.exec(text.trim())?.[1];
|
|
2645
2628
|
if (redacted !== void 0) return new CapxulError("UNKNOWN", `The backend refused ${operation} and gave no detail. Find Convex request ${redacted} in the backend logs. If the backend can be newer than this client, update the CLI or SDK.`, {
|
|
@@ -14749,7 +14732,7 @@ var require_follow_redirects = /* @__PURE__ */ __commonJSMin(((exports, module)
|
|
|
14749
14732
|
this._performRequest();
|
|
14750
14733
|
};
|
|
14751
14734
|
function wrap(protocols) {
|
|
14752
|
-
var exports$
|
|
14735
|
+
var exports$2 = {
|
|
14753
14736
|
maxRedirects: 21,
|
|
14754
14737
|
maxBodyLength: 10485760
|
|
14755
14738
|
};
|
|
@@ -14757,7 +14740,7 @@ var require_follow_redirects = /* @__PURE__ */ __commonJSMin(((exports, module)
|
|
|
14757
14740
|
Object.keys(protocols).forEach(function(scheme) {
|
|
14758
14741
|
var protocol = scheme + ":";
|
|
14759
14742
|
var nativeProtocol = nativeProtocols[protocol] = protocols[scheme];
|
|
14760
|
-
var wrappedProtocol = exports$
|
|
14743
|
+
var wrappedProtocol = exports$2[scheme] = Object.create(nativeProtocol);
|
|
14761
14744
|
function request(input, options, callback) {
|
|
14762
14745
|
if (isURL(input)) input = spreadUrlObject(input);
|
|
14763
14746
|
else if (isString(input)) input = spreadUrlObject(parseUrl(input));
|
|
@@ -14771,8 +14754,8 @@ var require_follow_redirects = /* @__PURE__ */ __commonJSMin(((exports, module)
|
|
|
14771
14754
|
options = null;
|
|
14772
14755
|
}
|
|
14773
14756
|
options = Object.assign({
|
|
14774
|
-
maxRedirects: exports$
|
|
14775
|
-
maxBodyLength: exports$
|
|
14757
|
+
maxRedirects: exports$2.maxRedirects,
|
|
14758
|
+
maxBodyLength: exports$2.maxBodyLength
|
|
14776
14759
|
}, input, options);
|
|
14777
14760
|
options.nativeProtocols = nativeProtocols;
|
|
14778
14761
|
if (!isString(options.host) && !isString(options.hostname)) options.hostname = "::1";
|
|
@@ -14800,7 +14783,7 @@ var require_follow_redirects = /* @__PURE__ */ __commonJSMin(((exports, module)
|
|
|
14800
14783
|
}
|
|
14801
14784
|
});
|
|
14802
14785
|
});
|
|
14803
|
-
return exports$
|
|
14786
|
+
return exports$2;
|
|
14804
14787
|
}
|
|
14805
14788
|
function noop() {}
|
|
14806
14789
|
function parseUrl(input) {
|
|
@@ -15241,7 +15224,7 @@ const isIPv6Loopback = (host) => {
|
|
|
15241
15224
|
}
|
|
15242
15225
|
return false;
|
|
15243
15226
|
};
|
|
15244
|
-
const isLoopback = (host) => {
|
|
15227
|
+
const isLoopback$1 = (host) => {
|
|
15245
15228
|
if (!host) return false;
|
|
15246
15229
|
if (LOOPBACK_HOSTNAMES.has(host)) return true;
|
|
15247
15230
|
if (isIPv4Loopback(host)) return true;
|
|
@@ -15314,7 +15297,7 @@ function shouldBypassProxy(location) {
|
|
|
15314
15297
|
if (entryPort && entryPort !== port) return false;
|
|
15315
15298
|
if (entryHost.charAt(0) === "*") entryHost = entryHost.slice(1);
|
|
15316
15299
|
if (entryHost.charAt(0) === ".") return hostname.endsWith(entryHost);
|
|
15317
|
-
return hostname === entryHost || isLoopback(hostname) && isLoopback(entryHost);
|
|
15300
|
+
return hostname === entryHost || isLoopback$1(hostname) && isLoopback$1(entryHost);
|
|
15318
15301
|
});
|
|
15319
15302
|
}
|
|
15320
15303
|
//#endregion
|
|
@@ -27725,16 +27708,16 @@ const signMessage = async (parameters) => {
|
|
|
27725
27708
|
type: "bytes32"
|
|
27726
27709
|
}] };
|
|
27727
27710
|
const updatedMessage = { hashedMessage: typedDataHash };
|
|
27728
|
-
const { _TypedDataEncoder } = await import("./lib-
|
|
27711
|
+
const { _TypedDataEncoder } = await import("./lib-DWEnweWw.mjs").then((m) => /* @__PURE__ */ __toESM(m.default, 1));
|
|
27729
27712
|
typedDataHash = _TypedDataEncoder.hash(updatedDomain, updatedTypes, updatedMessage);
|
|
27730
27713
|
}
|
|
27731
27714
|
const signature = await signer.sign(typedDataHash, false, false);
|
|
27732
27715
|
let result = signature;
|
|
27733
27716
|
if (factoryAddress && salt) {
|
|
27734
27717
|
if ([AccountType.UPGRADEABLE_V5, AccountType.UPGRADEABLE_V6].includes(implementationType)) {
|
|
27735
|
-
const { id } = await import("./lib-
|
|
27736
|
-
const { defaultAbiCoder } = await import("./lib-
|
|
27737
|
-
const { hexConcat } = await import("./lib-
|
|
27718
|
+
const { id } = await import("./lib-DWEnweWw.mjs").then((m) => /* @__PURE__ */ __toESM(m.default, 1));
|
|
27719
|
+
const { defaultAbiCoder } = await import("./lib-Cugc4DFI.mjs").then((m) => /* @__PURE__ */ __toESM(m.default, 1));
|
|
27720
|
+
const { hexConcat } = await import("./lib-C5rDhBj_.mjs").then((m) => /* @__PURE__ */ __toESM(m.default, 1));
|
|
27738
27721
|
const factoryCalldata = hexConcat([id("createAccountWithNonce(address,bytes32,bool)").slice(0, 10), defaultAbiCoder.encode([
|
|
27739
27722
|
"address",
|
|
27740
27723
|
"bytes32",
|
|
@@ -27843,8 +27826,8 @@ const personalSign = async ({ params, signer, account, eventEmitter }) => {
|
|
|
27843
27826
|
const fromAddress = params[1];
|
|
27844
27827
|
if (!fromAddress || !message) throw new JsonRpcError(RpcErrorCode.INVALID_PARAMS, "personal_sign requires an address and a message");
|
|
27845
27828
|
if (fromAddress.toLowerCase() !== account.address.toLowerCase()) throw new JsonRpcError(RpcErrorCode.INVALID_PARAMS, "personal_sign requires the signer to be the from address");
|
|
27846
|
-
const { hashMessage } = await import("./lib-
|
|
27847
|
-
const { arrayify, isHexString } = await import("./lib-
|
|
27829
|
+
const { hashMessage } = await import("./lib-DWEnweWw.mjs").then((m) => /* @__PURE__ */ __toESM(m.default, 1));
|
|
27830
|
+
const { arrayify, isHexString } = await import("./lib-C5rDhBj_.mjs").then((m) => /* @__PURE__ */ __toESM(m.default, 1));
|
|
27848
27831
|
const data = isHexString(message) ? arrayify(message) : message;
|
|
27849
27832
|
return await signMessage({
|
|
27850
27833
|
hash: hashMessage(data),
|
|
@@ -28361,7 +28344,7 @@ const signTypedDataV4 = async ({ params, method, signer, implementationType, rpc
|
|
|
28361
28344
|
const typedData = transformTypedData(typedDataParam, chainId);
|
|
28362
28345
|
const types = { ...typedData.types };
|
|
28363
28346
|
delete types.EIP712Domain;
|
|
28364
|
-
const { _TypedDataEncoder } = await import("./lib-
|
|
28347
|
+
const { _TypedDataEncoder } = await import("./lib-DWEnweWw.mjs").then((m) => /* @__PURE__ */ __toESM(m.default, 1));
|
|
28365
28348
|
const typedDataHash = _TypedDataEncoder.hash(typedData.domain, types, typedData.message);
|
|
28366
28349
|
return await signMessage({
|
|
28367
28350
|
hash: typedDataHash,
|
|
@@ -28454,7 +28437,7 @@ var EvmProvider = class {
|
|
|
28454
28437
|
if (!this.#rpcProvider) {
|
|
28455
28438
|
const chainId = (await Account.fromStorage(this.#storage))?.chainId || (this.#customChains ? Number(Object.keys(this.#customChains)[0]) : void 0) || 8453;
|
|
28456
28439
|
const rpcUrl = this.#resolveRpcUrl(chainId);
|
|
28457
|
-
await import("./lib-
|
|
28440
|
+
await import("./lib-CkoBT6RP.mjs").then((m) => /* @__PURE__ */ __toESM(m.default, 1)).then((module) => {
|
|
28458
28441
|
this.#rpcProvider = new module.StaticJsonRpcProvider(rpcUrl);
|
|
28459
28442
|
});
|
|
28460
28443
|
}
|
|
@@ -28486,7 +28469,7 @@ var EvmProvider = class {
|
|
|
28486
28469
|
if (!transaction) throw new JsonRpcError(RpcErrorCode.INVALID_PARAMS, `${request.method} requires a transaction object`);
|
|
28487
28470
|
if (!transaction.chainId) transaction.chainId = chainId.toString();
|
|
28488
28471
|
const parsedTransaction = parseTransactionRequest(transaction);
|
|
28489
|
-
const { serialize } = await import("./lib-
|
|
28472
|
+
const { serialize } = await import("./lib-CPklA4fw.mjs").then((m) => /* @__PURE__ */ __toESM(m.default, 1));
|
|
28490
28473
|
const typeToNumber = (type) => {
|
|
28491
28474
|
return {
|
|
28492
28475
|
legacy: 0,
|
|
@@ -28502,11 +28485,11 @@ var EvmProvider = class {
|
|
|
28502
28485
|
type: typeToNumber(parsedTransaction.type)
|
|
28503
28486
|
};
|
|
28504
28487
|
const unsignedTx = serialize(ethersTransaction);
|
|
28505
|
-
const { keccak256 } = await import("./lib-
|
|
28488
|
+
const { keccak256 } = await import("./lib-B0WujUb6.mjs").then((m) => /* @__PURE__ */ __toESM(m.default, 1));
|
|
28506
28489
|
const digest = keccak256(unsignedTx);
|
|
28507
28490
|
await this.#validateAndRefreshSession();
|
|
28508
28491
|
const signature = await signer.sign(digest, false, false);
|
|
28509
|
-
const { splitSignature } = await import("./lib-
|
|
28492
|
+
const { splitSignature } = await import("./lib-C5rDhBj_.mjs").then((m) => /* @__PURE__ */ __toESM(m.default, 1));
|
|
28510
28493
|
return serialize(ethersTransaction, splitSignature(signature));
|
|
28511
28494
|
}
|
|
28512
28495
|
case "eth_sendTransaction": {
|
|
@@ -28612,7 +28595,7 @@ var EvmProvider = class {
|
|
|
28612
28595
|
const rpcUrl = this.#resolveRpcUrl(chainIdNumber);
|
|
28613
28596
|
try {
|
|
28614
28597
|
await signer.switchChain({ chainId: chainIdNumber });
|
|
28615
|
-
await import("./lib-
|
|
28598
|
+
await import("./lib-CkoBT6RP.mjs").then((m) => /* @__PURE__ */ __toESM(m.default, 1)).then((module) => {
|
|
28616
28599
|
this.#rpcProvider = new module.StaticJsonRpcProvider(rpcUrl);
|
|
28617
28600
|
});
|
|
28618
28601
|
this.#eventEmitter.emit(ProviderEvent.CHAIN_CHANGED, numberToHex(chainIdNumber));
|
|
@@ -30902,7 +30885,7 @@ var EmbeddedWalletApi = class {
|
|
|
30902
30885
|
if (!account) throw new SignerError(OPENFORT_AUTH_ERROR_CODES.MISSING_SIGNER, "No account found");
|
|
30903
30886
|
const typesWithoutDomain = { ...types };
|
|
30904
30887
|
delete typesWithoutDomain.EIP712Domain;
|
|
30905
|
-
const { _TypedDataEncoder } = await import("./lib-
|
|
30888
|
+
const { _TypedDataEncoder } = await import("./lib-DWEnweWw.mjs").then((m) => /* @__PURE__ */ __toESM(m.default, 1));
|
|
30906
30889
|
const typedDataHash = _TypedDataEncoder.hash(domain, typesWithoutDomain, message);
|
|
30907
30890
|
return await signMessage({
|
|
30908
30891
|
hash: typedDataHash,
|
|
@@ -32594,15 +32577,15 @@ function isInsecureBrowserContext() {
|
|
|
32594
32577
|
const OidcTokenBody = Schema.NullOr(Schema.Struct({ token: Schema.NullOr(Schema.String) }));
|
|
32595
32578
|
const BetterAuthSessionBody = Schema.NullOr(Schema.Struct({ session: Schema.NullOr(Schema.Struct({ token: Schema.String })) }));
|
|
32596
32579
|
const EncryptionSessionBody = Schema.Struct({ sessionId: Schema.String });
|
|
32597
|
-
const MISSING
|
|
32598
|
-
const WRONG_TYPE
|
|
32580
|
+
const MISSING = "missing";
|
|
32581
|
+
const WRONG_TYPE = "not the expected type";
|
|
32599
32582
|
/**
|
|
32600
32583
|
* The Schema issues of a reply, each with a fixed reason. The Schema's own
|
|
32601
32584
|
* message can quote the reply, and the reply can hold a credential.
|
|
32602
32585
|
*/
|
|
32603
32586
|
const replyIssues = SchemaIssue.makeFormatterStandardSchemaV1({
|
|
32604
|
-
leafHook: (issue) => issue._tag === "MissingKey" ? MISSING
|
|
32605
|
-
checkHook: () => WRONG_TYPE
|
|
32587
|
+
leafHook: (issue) => issue._tag === "MissingKey" ? MISSING : WRONG_TYPE,
|
|
32588
|
+
checkHook: () => WRONG_TYPE
|
|
32606
32589
|
});
|
|
32607
32590
|
/**
|
|
32608
32591
|
* A reply that fails its Schema, named by the path of the first field that
|
|
@@ -32611,12 +32594,12 @@ const replyIssues = SchemaIssue.makeFormatterStandardSchemaV1({
|
|
|
32611
32594
|
function unusableReply(operation, issue, httpStatus) {
|
|
32612
32595
|
const first = replyIssues(issue).issues[0];
|
|
32613
32596
|
const path = first?.path?.map((segment) => String(typeof segment === "object" ? segment.key : segment)) ?? [];
|
|
32614
|
-
const missing = first?.message === MISSING
|
|
32597
|
+
const missing = first?.message === MISSING;
|
|
32615
32598
|
return openfortAnswerInvalid({
|
|
32616
32599
|
operation,
|
|
32617
32600
|
field: path.length === 0 ? "body" : path.join("."),
|
|
32618
32601
|
problem: missing ? "missing" : "invalid",
|
|
32619
|
-
reason: missing ? MISSING
|
|
32602
|
+
reason: missing ? MISSING : WRONG_TYPE,
|
|
32620
32603
|
httpStatus
|
|
32621
32604
|
});
|
|
32622
32605
|
}
|
|
@@ -33423,300 +33406,120 @@ function withDevTools(layer, url) {
|
|
|
33423
33406
|
}));
|
|
33424
33407
|
}
|
|
33425
33408
|
//#endregion
|
|
33426
|
-
//#region ../../packages/
|
|
33427
|
-
|
|
33428
|
-
|
|
33429
|
-
|
|
33430
|
-
|
|
33431
|
-
|
|
33432
|
-
|
|
33433
|
-
|
|
33434
|
-
|
|
33435
|
-
|
|
33436
|
-
|
|
33437
|
-
|
|
33438
|
-
|
|
33439
|
-
|
|
33440
|
-
|
|
33441
|
-
|
|
33442
|
-
|
|
33443
|
-
|
|
33444
|
-
|
|
33445
|
-
|
|
33446
|
-
|
|
33447
|
-
|
|
33448
|
-
*/
|
|
33449
|
-
|
|
33450
|
-
|
|
33451
|
-
|
|
33452
|
-
|
|
33453
|
-
|
|
33454
|
-
|
|
33455
|
-
|
|
33456
|
-
|
|
33457
|
-
|
|
33458
|
-
|
|
33459
|
-
|
|
33460
|
-
applicationId: decodedState.applicationId,
|
|
33461
|
-
chainId: decodedState.chainId,
|
|
33462
|
-
sessionToken: decodedState.sessionToken,
|
|
33463
|
-
issuedAt: decodedState.issuedAt,
|
|
33464
|
-
expiresIn: decodedState.expiresIn,
|
|
33465
|
-
authBaseUrl: normalizeRuntimeUrl("authBaseUrl", decodedState.authBaseUrl),
|
|
33466
|
-
convexUrl: normalizeRuntimeUrl("convexUrl", decodedState.convexUrl),
|
|
33467
|
-
siteBaseUrl: normalizeRuntimeUrl("siteBaseUrl", decodedState.siteBaseUrl),
|
|
33468
|
-
openfortPublishableKey: decodedState.openfortPublishableKey,
|
|
33469
|
-
shieldPublishableKey: decodedState.shieldPublishableKey,
|
|
33470
|
-
...decodedState.openfortAuthProvider === void 0 ? {} : { openfortAuthProvider: decodedState.openfortAuthProvider },
|
|
33471
|
-
...decodedState.indexerUrl === void 0 ? {} : { indexerUrl: decodedState.indexerUrl },
|
|
33472
|
-
...engineeringTelemetryOf(decodedEngineeringTelemetry)
|
|
33473
|
-
};
|
|
33474
|
-
}
|
|
33475
|
-
const MISSING = "missing";
|
|
33476
|
-
const WRONG_TYPE = "not the expected type";
|
|
33477
|
-
/**
|
|
33478
|
-
* The envelope's Schema issues, each with a fixed reason. The Schema's own
|
|
33479
|
-
* message can quote the body, and the body holds the session token.
|
|
33480
|
-
*/
|
|
33481
|
-
const envelopeIssues = SchemaIssue.makeFormatterStandardSchemaV1({
|
|
33482
|
-
leafHook: (issue) => issue._tag === "MissingKey" ? MISSING : WRONG_TYPE,
|
|
33483
|
-
checkHook: () => WRONG_TYPE
|
|
33409
|
+
//#region ../../packages/protocol/src/profiles/operations.ts
|
|
33410
|
+
/** Every call: no session (or not this person's), or input that does not decode or validate. */
|
|
33411
|
+
const CALL$2 = ["NOT_AUTHENTICATED", "INVALID_INPUT"];
|
|
33412
|
+
/** The person's Profile, as every operation returns it. URLs are resolved per read. */
|
|
33413
|
+
/** A human, or an AI whose own key signs for it (it is sent no approval email). */
|
|
33414
|
+
const MemberKindSchema = Schema.Literals(["human", "ai"]);
|
|
33415
|
+
const ProfileSchema = Schema.Struct({
|
|
33416
|
+
testerKind: Schema.optionalKey(Schema.Literals([
|
|
33417
|
+
"human",
|
|
33418
|
+
"e2e",
|
|
33419
|
+
"agent"
|
|
33420
|
+
])),
|
|
33421
|
+
/** Absent on an older reply: a human. */
|
|
33422
|
+
memberKind: Schema.optionalKey(MemberKindSchema),
|
|
33423
|
+
authUserId: Schema.String,
|
|
33424
|
+
email: Schema.String,
|
|
33425
|
+
displayName: Schema.NullOr(Schema.String),
|
|
33426
|
+
/** ISO 3166-1 alpha-2, uppercase. */
|
|
33427
|
+
country: Schema.NullOr(Schema.String),
|
|
33428
|
+
onboarded: Schema.Boolean,
|
|
33429
|
+
/** The cash-out destination, lowercase `0x` + 40 hex. */
|
|
33430
|
+
withdrawalAddress: Schema.NullOr(Schema.String),
|
|
33431
|
+
/** The handle of the person's claimed Party. */
|
|
33432
|
+
handle: Schema.NullOr(Schema.String),
|
|
33433
|
+
/** A serving URL for the photo; not a stable link to keep. */
|
|
33434
|
+
imageUrl: Schema.NullOr(Schema.String),
|
|
33435
|
+
kycTier: Schema.Literals([
|
|
33436
|
+
0,
|
|
33437
|
+
1,
|
|
33438
|
+
2,
|
|
33439
|
+
3
|
|
33440
|
+
]),
|
|
33441
|
+
createdAt: Schema.Finite,
|
|
33442
|
+
updatedAt: Schema.Finite
|
|
33484
33443
|
});
|
|
33485
|
-
/**
|
|
33486
|
-
|
|
33487
|
-
|
|
33488
|
-
|
|
33489
|
-
|
|
33490
|
-
const first = envelopeIssues(issue).issues[0];
|
|
33491
|
-
const path = first?.path?.map((segment) => String(typeof segment === "object" ? segment.key : segment)) ?? [];
|
|
33492
|
-
const missing = first?.message === MISSING;
|
|
33493
|
-
return unusableAnswer(path.length === 0 ? "body" : path.join("."), missing ? "missing" : "invalid", missing ? MISSING : WRONG_TYPE);
|
|
33494
|
-
}
|
|
33495
|
-
/**
|
|
33496
|
-
* The bootstrap answered, and Capxul cannot use `field` of its answer. `cause`
|
|
33497
|
-
* is what refused the field, when it holds none of the body.
|
|
33498
|
-
*/
|
|
33499
|
-
function unusableAnswer(field, problem, reason, cause) {
|
|
33500
|
-
return Errors.providerResponseInvalid({
|
|
33501
|
-
provider: "convex",
|
|
33502
|
-
operation: "bootstrap",
|
|
33503
|
-
field,
|
|
33504
|
-
problem,
|
|
33505
|
-
reason,
|
|
33506
|
-
...cause === void 0 ? {} : { cause }
|
|
33507
|
-
});
|
|
33508
|
-
}
|
|
33509
|
-
/** The bootstrap state without the policy, which decodes separately. */
|
|
33510
|
-
function withoutPolicy(state) {
|
|
33511
|
-
const { engineeringTelemetry: _policy, ...rest } = state;
|
|
33512
|
-
return rest;
|
|
33513
|
-
}
|
|
33514
|
-
/**
|
|
33515
|
-
* The engineering telemetry policy the backend sent. One it does not admit
|
|
33516
|
-
* leaves SDK telemetry off, and says so once with the decode issue.
|
|
33517
|
-
*/
|
|
33518
|
-
function engineeringTelemetryOf(decoded) {
|
|
33519
|
-
if (decoded === void 0) return {};
|
|
33520
|
-
if (Result.isSuccess(decoded)) return { engineeringTelemetry: decoded.success };
|
|
33521
|
-
console.warn("[capxul-sdk] engineering telemetry policy refused; SDK telemetry is off", { issue: SchemaIssue.makeFormatterDefault()(decoded.failure) });
|
|
33522
|
-
return {};
|
|
33523
|
-
}
|
|
33524
|
-
function normalizeRuntimeUrl(field, raw) {
|
|
33525
|
-
let parsed;
|
|
33526
|
-
try {
|
|
33527
|
-
parsed = new URL(raw);
|
|
33528
|
-
} catch (cause) {
|
|
33529
|
-
throw unusableAnswer(`state.${field}`, "invalid", "must be an http or https URL", cause);
|
|
33530
|
-
}
|
|
33531
|
-
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") throw unusableAnswer(`state.${field}`, "invalid", "must be an http or https URL");
|
|
33532
|
-
return parsed.toString().replace(/\/$/, "");
|
|
33533
|
-
}
|
|
33534
|
-
//#endregion
|
|
33535
|
-
//#region ../../packages/sdk/src/applications/bootstrap-adapter.ts
|
|
33536
|
-
/** A cached envelope this close to its expiry is fetched again, so it cannot lapse mid-command. */
|
|
33537
|
-
const CACHE_EXPIRY_MARGIN_MS = 3e4;
|
|
33538
|
-
/**
|
|
33539
|
-
* The cached envelope, when it is still inside its own lifetime. It is decoded
|
|
33540
|
-
* as a fresh body is; anything that does not decode, or a store that fails,
|
|
33541
|
-
* is a miss.
|
|
33542
|
-
*/
|
|
33543
|
-
async function cachedEnvelope(cache, now) {
|
|
33544
|
-
try {
|
|
33545
|
-
const cached = decodeBootstrapBody(await cache.load());
|
|
33546
|
-
const expiresAt = cached.issuedAt + cached.expiresIn - CACHE_EXPIRY_MARGIN_MS;
|
|
33547
|
-
return cached.issuedAt <= now && now < expiresAt ? cached : null;
|
|
33548
|
-
} catch {
|
|
33549
|
-
return null;
|
|
33550
|
-
}
|
|
33551
|
-
}
|
|
33552
|
-
const DEFAULT_RETRY = {
|
|
33553
|
-
attempts: 2,
|
|
33554
|
-
baseDelayMs: 400
|
|
33555
|
-
};
|
|
33556
|
-
/** Request-side statuses a proxy or backend returns while momentarily unable to serve. */
|
|
33557
|
-
const TRANSIENT_HTTP_STATUSES = /* @__PURE__ */ new Set([
|
|
33558
|
-
408,
|
|
33559
|
-
425,
|
|
33560
|
-
429
|
|
33444
|
+
/** The chain families a payout address may name. The network is the deployment's. */
|
|
33445
|
+
const PayoutChainSchema = Schema.Literals([
|
|
33446
|
+
"evm",
|
|
33447
|
+
"solana",
|
|
33448
|
+
"starknet"
|
|
33561
33449
|
]);
|
|
33562
|
-
|
|
33563
|
-
|
|
33564
|
-
|
|
33565
|
-
}
|
|
33566
|
-
|
|
33567
|
-
|
|
33568
|
-
|
|
33569
|
-
|
|
33570
|
-
|
|
33571
|
-
|
|
33572
|
-
|
|
33573
|
-
|
|
33574
|
-
|
|
33575
|
-
|
|
33576
|
-
|
|
33577
|
-
|
|
33578
|
-
|
|
33579
|
-
|
|
33580
|
-
|
|
33581
|
-
|
|
33582
|
-
|
|
33583
|
-
|
|
33584
|
-
|
|
33585
|
-
}
|
|
33586
|
-
|
|
33587
|
-
|
|
33588
|
-
|
|
33589
|
-
|
|
33590
|
-
|
|
33591
|
-
|
|
33592
|
-
|
|
33593
|
-
|
|
33594
|
-
|
|
33595
|
-
|
|
33596
|
-
|
|
33597
|
-
|
|
33598
|
-
|
|
33599
|
-
|
|
33600
|
-
|
|
33601
|
-
|
|
33602
|
-
|
|
33603
|
-
|
|
33604
|
-
while: isTransientBootstrapFailure,
|
|
33605
|
-
schedule: Schedule.exponential(Duration.millis(this.retry.baseDelayMs))
|
|
33606
|
-
}));
|
|
33607
|
-
const cache = this.cache;
|
|
33608
|
-
if (cache === void 0) return fetched;
|
|
33609
|
-
return Effect.promise(() => cachedEnvelope(cache, Date.now())).pipe(Effect.filterOrElse((cached) => cached !== null, () => fetched));
|
|
33610
|
-
}
|
|
33611
|
-
attempt(input) {
|
|
33612
|
-
return Effect.tryPromise({
|
|
33613
|
-
try: () => {
|
|
33614
|
-
const headers = {
|
|
33615
|
-
"content-type": "application/json",
|
|
33616
|
-
...input.origin === void 0 ? {} : { origin: input.origin },
|
|
33617
|
-
...observationRequestHeaders(this.observation)
|
|
33618
|
-
};
|
|
33619
|
-
return this.fetchImpl(`${this.bootstrapBaseUrl}/v1/client/bootstrap`, {
|
|
33620
|
-
method: "POST",
|
|
33621
|
-
headers,
|
|
33622
|
-
body: JSON.stringify({ publishableKey: input.publishableKey })
|
|
33623
|
-
});
|
|
33624
|
-
},
|
|
33625
|
-
catch: (cause) => bootstrapErrorFromCapxul("network", Errors.networkError("bootstrap", cause, {
|
|
33626
|
-
provider: "bootstrap",
|
|
33627
|
-
failure_mode: "upstream-down",
|
|
33628
|
-
...this.bootstrapHost === void 0 ? {} : { target_host: this.bootstrapHost }
|
|
33629
|
-
}))
|
|
33630
|
-
}).pipe(Effect.flatMap((res) => this.mapResponse(res, input)));
|
|
33631
|
-
}
|
|
33632
|
-
mapResponse(res, input) {
|
|
33633
|
-
if (res.ok) return Effect.tryPromise({
|
|
33634
|
-
try: async () => {
|
|
33635
|
-
const body = await res.json();
|
|
33636
|
-
const resolution = decodeBootstrapBody(body);
|
|
33637
|
-
const cache = this.cache;
|
|
33638
|
-
if (cache !== void 0) await Promise.resolve().then(() => cache.save(body)).catch(() => void 0);
|
|
33639
|
-
return resolution;
|
|
33640
|
-
},
|
|
33641
|
-
catch: (cause) => {
|
|
33642
|
-
if (cause instanceof CapxulError && cause.code === "PROVIDER_RESPONSE_INVALID") return bootstrapErrorFromCapxul("malformedBody", cause);
|
|
33643
|
-
return bootstrapErrorFromCapxul("malformedBody", Errors.providerResponseInvalid({
|
|
33644
|
-
provider: "convex",
|
|
33645
|
-
operation: "bootstrap",
|
|
33646
|
-
field: "body",
|
|
33647
|
-
problem: "invalid",
|
|
33648
|
-
cause
|
|
33649
|
-
}));
|
|
33650
|
-
}
|
|
33651
|
-
});
|
|
33652
|
-
return Effect.promise(() => safeText(res)).pipe(Effect.flatMap((body) => {
|
|
33653
|
-
const refused = backendFailure(body);
|
|
33654
|
-
if (refused !== null) return Effect.fail(bootstrapErrorFromCapxul(bootstrapKind(refused.code), refused));
|
|
33655
|
-
const responseBody = maskedResponseBody(body);
|
|
33656
|
-
const edgeError = res.headers?.get?.("x-vercel-error") ?? void 0;
|
|
33657
|
-
const edgeRequestId = res.headers?.get?.("x-vercel-id") ?? void 0;
|
|
33658
|
-
const evidence = {
|
|
33659
|
-
...responseBody.length === 0 ? {} : { responseBody },
|
|
33660
|
-
...edgeError === void 0 ? {} : { edgeError },
|
|
33661
|
-
...edgeRequestId === void 0 ? {} : { edgeRequestId }
|
|
33662
|
-
};
|
|
33663
|
-
if (res.status === 401) return Effect.fail(bootstrapErrorFromCapxul("notAuthenticated", keyRefused(input, evidence)));
|
|
33664
|
-
return Effect.fail(bootstrapErrorFromCapxul("provider", providerStatusFailure({
|
|
33665
|
-
provider: "convex",
|
|
33666
|
-
operation: "bootstrap",
|
|
33667
|
-
httpStatus: res.status,
|
|
33668
|
-
details: evidence
|
|
33669
|
-
})));
|
|
33670
|
-
}));
|
|
33671
|
-
}
|
|
33450
|
+
const details = {
|
|
33451
|
+
/** The signed-in person's Profile, or null before one exists. */
|
|
33452
|
+
get: Operation.query("profiles.details.get", {
|
|
33453
|
+
input: Schema.Struct({ authUserId: Schema.String }),
|
|
33454
|
+
output: Schema.NullOr(ProfileSchema),
|
|
33455
|
+
errors: [...CALL$2, ...DEFECTS]
|
|
33456
|
+
}),
|
|
33457
|
+
/** Whether a handle is free for the signed-in person, and its canonical form. Their own counts as free. */
|
|
33458
|
+
handleAvailable: Operation.query("profiles.details.handleAvailable", {
|
|
33459
|
+
input: Schema.Struct({ handle: Schema.String }),
|
|
33460
|
+
output: Schema.Struct({
|
|
33461
|
+
available: Schema.Boolean,
|
|
33462
|
+
normalized: Schema.String
|
|
33463
|
+
}),
|
|
33464
|
+
errors: [...CALL$2, ...DEFECTS]
|
|
33465
|
+
}),
|
|
33466
|
+
/** Create the signed-in person's Profile, or return the one that exists. */
|
|
33467
|
+
create: Operation.mutation("profiles.details.create", {
|
|
33468
|
+
input: Schema.Struct({
|
|
33469
|
+
authUserId: Schema.String,
|
|
33470
|
+
email: Schema.String,
|
|
33471
|
+
displayName: Schema.optionalKey(Schema.String),
|
|
33472
|
+
country: Schema.optionalKey(Schema.String)
|
|
33473
|
+
}),
|
|
33474
|
+
output: ProfileSchema,
|
|
33475
|
+
errors: [...CALL$2, ...DEFECTS]
|
|
33476
|
+
}),
|
|
33477
|
+
/** Change the signed-in person's display name, country, or whether they are an AI. */
|
|
33478
|
+
update: Operation.mutation("profiles.details.update", {
|
|
33479
|
+
input: Schema.Struct({
|
|
33480
|
+
authUserId: Schema.String,
|
|
33481
|
+
displayName: Schema.optionalKey(Schema.String),
|
|
33482
|
+
country: Schema.optionalKey(Schema.String),
|
|
33483
|
+
memberKind: Schema.optionalKey(MemberKindSchema)
|
|
33484
|
+
}),
|
|
33485
|
+
output: ProfileSchema,
|
|
33486
|
+
errors: [
|
|
33487
|
+
...CALL$2,
|
|
33488
|
+
...DEFECTS,
|
|
33489
|
+
"PROFILE_NOT_FOUND"
|
|
33490
|
+
]
|
|
33491
|
+
})
|
|
33672
33492
|
};
|
|
33673
|
-
|
|
33674
|
-
|
|
33675
|
-
*
|
|
33676
|
-
*
|
|
33677
|
-
|
|
33678
|
-
|
|
33679
|
-
|
|
33680
|
-
|
|
33681
|
-
|
|
33682
|
-
|
|
33683
|
-
|
|
33684
|
-
|
|
33685
|
-
|
|
33686
|
-
|
|
33687
|
-
|
|
33688
|
-
/**
|
|
33689
|
-
|
|
33690
|
-
|
|
33691
|
-
|
|
33692
|
-
|
|
33693
|
-
|
|
33694
|
-
|
|
33695
|
-
|
|
33696
|
-
|
|
33697
|
-
|
|
33698
|
-
|
|
33699
|
-
|
|
33700
|
-
|
|
33701
|
-
|
|
33702
|
-
|
|
33703
|
-
}
|
|
33704
|
-
function bootstrapKind(code) {
|
|
33705
|
-
if (code === "NOT_AUTHENTICATED") return "notAuthenticated";
|
|
33706
|
-
if (code === "INVALID_INPUT") return "invalidInput";
|
|
33707
|
-
if (code === "RATE_LIMITED") return "rateLimited";
|
|
33708
|
-
return "provider";
|
|
33709
|
-
}
|
|
33710
|
-
function HttpBootstrapLayer(deps) {
|
|
33711
|
-
return Layer.succeed(BootstrapPortTag, new HttpBootstrapAdapter(deps));
|
|
33712
|
-
}
|
|
33713
|
-
function hostOf(url) {
|
|
33714
|
-
try {
|
|
33715
|
-
return new URL(url).hostname;
|
|
33716
|
-
} catch {
|
|
33717
|
-
return;
|
|
33718
|
-
}
|
|
33719
|
-
}
|
|
33493
|
+
const onboardings = {
|
|
33494
|
+
/**
|
|
33495
|
+
* Complete onboarding in one transaction: the Profile, the claimed Party and
|
|
33496
|
+
* its handle, the uploaded photo and the payout addresses. Every input is
|
|
33497
|
+
* checked before the first write; a refusal writes nothing. Repeating it is
|
|
33498
|
+
* safe.
|
|
33499
|
+
*/
|
|
33500
|
+
complete: Operation.mutation("profiles.onboardings.complete", {
|
|
33501
|
+
input: Schema.Struct({
|
|
33502
|
+
authUserId: Schema.String,
|
|
33503
|
+
email: Schema.String,
|
|
33504
|
+
displayName: Schema.String,
|
|
33505
|
+
country: Schema.String,
|
|
33506
|
+
withdrawalAddress: Schema.optionalKey(Schema.String),
|
|
33507
|
+
handle: Schema.String,
|
|
33508
|
+
/** The storage id `media.images.generateUploadUrl`'s upload returned. */
|
|
33509
|
+
imageStorageId: Schema.optionalKey(Schema.String),
|
|
33510
|
+
payoutAddresses: Schema.optionalKey(Schema.Array(Schema.Struct({
|
|
33511
|
+
chain: PayoutChainSchema,
|
|
33512
|
+
address: Schema.String
|
|
33513
|
+
})))
|
|
33514
|
+
}),
|
|
33515
|
+
output: ProfileSchema,
|
|
33516
|
+
errors: [
|
|
33517
|
+
...CALL$2,
|
|
33518
|
+
...DEFECTS,
|
|
33519
|
+
"PROFILE_NOT_FOUND",
|
|
33520
|
+
"WRONG_STATE"
|
|
33521
|
+
]
|
|
33522
|
+
}) };
|
|
33720
33523
|
//#endregion
|
|
33721
33524
|
//#region ../../packages/sdk/src/profiles/port.ts
|
|
33722
33525
|
/** The chain families a payout address may name (#1955). */
|
|
@@ -33760,6 +33563,7 @@ function brandProfile(view) {
|
|
|
33760
33563
|
return {
|
|
33761
33564
|
authUserId: toAuthUserId(view.authUserId),
|
|
33762
33565
|
...view.testerKind === void 0 ? {} : { testerKind: toTesterKind(view.testerKind) },
|
|
33566
|
+
...view.memberKind === void 0 ? {} : { memberKind: view.memberKind },
|
|
33763
33567
|
email: toEmail(view.email),
|
|
33764
33568
|
displayName: view.displayName,
|
|
33765
33569
|
country: view.country === null ? null : toCountryCode(view.country),
|
|
@@ -33897,6 +33701,17 @@ function makeIdentityMethods(deps) {
|
|
|
33897
33701
|
error: Errors.notImplemented("identity", "handleAvailable")
|
|
33898
33702
|
};
|
|
33899
33703
|
return runCapxulEffect(callOperation(convexCall, row, { handle }), options, row.name, deps.runPromise);
|
|
33704
|
+
},
|
|
33705
|
+
async setMemberKind(memberKind, options) {
|
|
33706
|
+
const refuse = (error) => runCapxulEffect(Effect.fail(error), options, details.update.name, deps.runPromise);
|
|
33707
|
+
if (options?.signal?.aborted) return refuse(Errors.cancelled({ operation: details.update.name }));
|
|
33708
|
+
if (memberKind !== "human" && memberKind !== "ai") return refuse(Errors.invalidInput("memberKind", "must be human or ai"));
|
|
33709
|
+
const session = deps.actor?.authSession();
|
|
33710
|
+
if (session === void 0 || session === null) return refuse(noSessionError(deps.actor));
|
|
33711
|
+
return runPortEffect(deps.identityPort.update({
|
|
33712
|
+
authUserId: session.authUserId,
|
|
33713
|
+
memberKind
|
|
33714
|
+
}), options, details.update.name, deps.runPromise);
|
|
33900
33715
|
}
|
|
33901
33716
|
};
|
|
33902
33717
|
}
|
|
@@ -37980,6 +37795,243 @@ function makeConnectionId() {
|
|
|
37980
37795
|
}
|
|
37981
37796
|
}
|
|
37982
37797
|
//#endregion
|
|
37798
|
+
//#region ../../packages/protocol/src/access/rows.ts
|
|
37799
|
+
var rows_exports$15 = /* @__PURE__ */ __exportAll({
|
|
37800
|
+
features: () => features,
|
|
37801
|
+
referrals: () => referrals,
|
|
37802
|
+
sessions: () => sessions,
|
|
37803
|
+
waitlist: () => waitlist
|
|
37804
|
+
});
|
|
37805
|
+
//#endregion
|
|
37806
|
+
//#region ../../packages/protocol/src/accounts/rows.ts
|
|
37807
|
+
var rows_exports$14 = /* @__PURE__ */ __exportAll({
|
|
37808
|
+
agents: () => agents,
|
|
37809
|
+
approvals: () => approvals,
|
|
37810
|
+
balances: () => balances,
|
|
37811
|
+
claims: () => claims,
|
|
37812
|
+
grants: () => grants,
|
|
37813
|
+
networks: () => networks,
|
|
37814
|
+
preferences: () => preferences,
|
|
37815
|
+
safes: () => safes,
|
|
37816
|
+
summaries: () => summaries
|
|
37817
|
+
});
|
|
37818
|
+
//#endregion
|
|
37819
|
+
//#region ../../packages/protocol/src/activity/rows.ts
|
|
37820
|
+
var rows_exports$13 = /* @__PURE__ */ __exportAll({
|
|
37821
|
+
annotations: () => annotations,
|
|
37822
|
+
counterparties: () => counterparties,
|
|
37823
|
+
documents: () => documents,
|
|
37824
|
+
items: () => items,
|
|
37825
|
+
overlays: () => overlays
|
|
37826
|
+
});
|
|
37827
|
+
//#endregion
|
|
37828
|
+
//#region ../../packages/protocol/src/applications/rows.ts
|
|
37829
|
+
var rows_exports$12 = /* @__PURE__ */ __exportAll({
|
|
37830
|
+
keys: () => keys,
|
|
37831
|
+
registrations: () => registrations
|
|
37832
|
+
});
|
|
37833
|
+
//#endregion
|
|
37834
|
+
//#region ../../packages/protocol/src/banking/rows.ts
|
|
37835
|
+
var rows_exports$11 = /* @__PURE__ */ __exportAll({
|
|
37836
|
+
bankDetails: () => bankDetails,
|
|
37837
|
+
deposits: () => deposits
|
|
37838
|
+
});
|
|
37839
|
+
//#endregion
|
|
37840
|
+
//#region ../../packages/protocol/src/books/rows.ts
|
|
37841
|
+
var rows_exports$10 = /* @__PURE__ */ __exportAll({
|
|
37842
|
+
accounts: () => accounts,
|
|
37843
|
+
assets: () => assets,
|
|
37844
|
+
exports: () => exports$1,
|
|
37845
|
+
facts: () => facts,
|
|
37846
|
+
keepers: () => keepers,
|
|
37847
|
+
reports: () => reports
|
|
37848
|
+
});
|
|
37849
|
+
//#endregion
|
|
37850
|
+
//#region ../../packages/protocol/src/documents/operations.ts
|
|
37851
|
+
/** Every call: no session, or input that does not decode. */
|
|
37852
|
+
const CALL$1 = ["NOT_AUTHENTICATED", "INVALID_INPUT"];
|
|
37853
|
+
/** Not a current participant of the Organization, or no such Organization. Indistinguishable. */
|
|
37854
|
+
const PARTICIPANT = ["ROLE_PERMISSION_DENIED"];
|
|
37855
|
+
/** The chain refused, timed out or was unreachable. */
|
|
37856
|
+
const CHAIN = ["PROVIDER_ERROR"];
|
|
37857
|
+
/** Whose Movements: the caller's own Account, or an Organization they take part in. */
|
|
37858
|
+
const MemoActorSchema = Schema.Union([Schema.Struct({ kind: Schema.Literal("account") }), Schema.Struct({
|
|
37859
|
+
kind: Schema.Literal("organization"),
|
|
37860
|
+
orgId: Schema.NonEmptyString
|
|
37861
|
+
})]);
|
|
37862
|
+
/** A Movement's Memo documents, ensured from verified chain evidence. */
|
|
37863
|
+
const memos = {
|
|
37864
|
+
/**
|
|
37865
|
+
* Prove each named Transfer on chain and store its Memo for the actor. At
|
|
37866
|
+
* most 100 unique logical event ids (`chainId:txHash:ordinal`); an id with no
|
|
37867
|
+
* verifiable Transfer counts as unavailable, never as an error.
|
|
37868
|
+
*/
|
|
37869
|
+
ensure: Operation.action("documents.memos.ensure", {
|
|
37870
|
+
input: Schema.Struct({
|
|
37871
|
+
logicalEventIds: Schema.Array(Schema.String),
|
|
37872
|
+
actor: MemoActorSchema
|
|
37873
|
+
}),
|
|
37874
|
+
output: Schema.Struct({
|
|
37875
|
+
requested: Schema.Int,
|
|
37876
|
+
ensured: Schema.Int,
|
|
37877
|
+
unavailable: Schema.Int
|
|
37878
|
+
}),
|
|
37879
|
+
errors: [
|
|
37880
|
+
...CALL$1,
|
|
37881
|
+
...DEFECTS,
|
|
37882
|
+
...PARTICIPANT,
|
|
37883
|
+
...CHAIN
|
|
37884
|
+
]
|
|
37885
|
+
}) };
|
|
37886
|
+
//#endregion
|
|
37887
|
+
//#region ../../packages/protocol/src/documents/rows.ts
|
|
37888
|
+
var rows_exports$9 = /* @__PURE__ */ __exportAll({ memos: () => memos });
|
|
37889
|
+
//#endregion
|
|
37890
|
+
//#region ../../packages/protocol/src/media/operations.ts
|
|
37891
|
+
/** A Convex `_storage` id, as the upload POST returned it. */
|
|
37892
|
+
const StorageId = Schema.NonEmptyString;
|
|
37893
|
+
/** A serving URL, or null when the stored blob is gone. */
|
|
37894
|
+
const ServingUrl = Schema.NullOr(Schema.String);
|
|
37895
|
+
/** Every call: no session, or input that does not decode (a missing or non-image upload included). */
|
|
37896
|
+
const CALL = ["NOT_AUTHENTICATED", "INVALID_INPUT"];
|
|
37897
|
+
/** Acting as an Admin: no authority here, or no Account to hold any. */
|
|
37898
|
+
const ADMIN = [
|
|
37899
|
+
"ROLE_PERMISSION_DENIED",
|
|
37900
|
+
"SMART_ACCOUNT_MISSING",
|
|
37901
|
+
"ACCOUNT_NOT_FOUND"
|
|
37902
|
+
];
|
|
37903
|
+
const images = {
|
|
37904
|
+
/** A one-shot URL the signed-in person POSTs one image to. */
|
|
37905
|
+
generateUploadUrl: Operation.mutation("media.images.generateUploadUrl", {
|
|
37906
|
+
input: Schema.Struct({}),
|
|
37907
|
+
output: Schema.Struct({ uploadUrl: Schema.String }),
|
|
37908
|
+
errors: [...CALL, ...DEFECTS]
|
|
37909
|
+
}),
|
|
37910
|
+
/** Bind an uploaded image as the signed-in person's profile photo; the replaced blob is deleted. */
|
|
37911
|
+
setProfileImage: Operation.mutation("media.images.setProfileImage", {
|
|
37912
|
+
input: Schema.Struct({ storageId: StorageId }),
|
|
37913
|
+
output: Schema.Struct({ imageUrl: ServingUrl }),
|
|
37914
|
+
errors: [
|
|
37915
|
+
...CALL,
|
|
37916
|
+
...DEFECTS,
|
|
37917
|
+
"PROFILE_NOT_FOUND"
|
|
37918
|
+
]
|
|
37919
|
+
}),
|
|
37920
|
+
/** A current Admin binds an uploaded image as the Organization's logo; the replaced blob is deleted. */
|
|
37921
|
+
setOrgLogo: Operation.mutation("media.images.setOrgLogo", {
|
|
37922
|
+
input: Schema.Struct({
|
|
37923
|
+
orgId: Schema.NonEmptyString,
|
|
37924
|
+
storageId: StorageId
|
|
37925
|
+
}),
|
|
37926
|
+
output: Schema.Struct({ logoUrl: ServingUrl }),
|
|
37927
|
+
errors: [
|
|
37928
|
+
...CALL,
|
|
37929
|
+
...DEFECTS,
|
|
37930
|
+
...ADMIN
|
|
37931
|
+
]
|
|
37932
|
+
})
|
|
37933
|
+
};
|
|
37934
|
+
//#endregion
|
|
37935
|
+
//#region ../../packages/protocol/src/media/rows.ts
|
|
37936
|
+
var rows_exports$8 = /* @__PURE__ */ __exportAll({ images: () => images });
|
|
37937
|
+
//#endregion
|
|
37938
|
+
//#region ../../packages/protocol/src/operator/rows.ts
|
|
37939
|
+
var rows_exports$7 = /* @__PURE__ */ __exportAll({
|
|
37940
|
+
diagnostics: () => diagnostics,
|
|
37941
|
+
identities: () => identities,
|
|
37942
|
+
probes: () => probes,
|
|
37943
|
+
receipts: () => receipts
|
|
37944
|
+
});
|
|
37945
|
+
//#endregion
|
|
37946
|
+
//#region ../../packages/protocol/src/organizations/rows.ts
|
|
37947
|
+
var rows_exports$6 = /* @__PURE__ */ __exportAll({
|
|
37948
|
+
directors: () => directors,
|
|
37949
|
+
equity: () => equity,
|
|
37950
|
+
invitations: () => invitations,
|
|
37951
|
+
members: () => members,
|
|
37952
|
+
proposals: () => proposals,
|
|
37953
|
+
roles: () => roles,
|
|
37954
|
+
rounds: () => rounds,
|
|
37955
|
+
setups: () => setups,
|
|
37956
|
+
shareTransfers: () => shareTransfers,
|
|
37957
|
+
treasuries: () => treasuries,
|
|
37958
|
+
votes: () => votes,
|
|
37959
|
+
workspaces: () => workspaces
|
|
37960
|
+
});
|
|
37961
|
+
//#endregion
|
|
37962
|
+
//#region ../../packages/protocol/src/parties/rows.ts
|
|
37963
|
+
var rows_exports$5 = /* @__PURE__ */ __exportAll({
|
|
37964
|
+
accounts: () => accounts$1,
|
|
37965
|
+
contacts: () => contacts,
|
|
37966
|
+
destinations: () => destinations,
|
|
37967
|
+
recipients: () => recipients,
|
|
37968
|
+
verifications: () => verifications
|
|
37969
|
+
});
|
|
37970
|
+
//#endregion
|
|
37971
|
+
//#region ../../packages/protocol/src/payments/rows.ts
|
|
37972
|
+
var rows_exports$4 = /* @__PURE__ */ __exportAll({
|
|
37973
|
+
commands: () => commands,
|
|
37974
|
+
executions: () => executions,
|
|
37975
|
+
lifecycles: () => lifecycles,
|
|
37976
|
+
quotes: () => quotes,
|
|
37977
|
+
records: () => records
|
|
37978
|
+
});
|
|
37979
|
+
//#endregion
|
|
37980
|
+
//#region ../../packages/protocol/src/payroll/rows.ts
|
|
37981
|
+
var rows_exports$3 = /* @__PURE__ */ __exportAll({
|
|
37982
|
+
agreements: () => agreements,
|
|
37983
|
+
departments: () => departments,
|
|
37984
|
+
groups: () => groups,
|
|
37985
|
+
runs: () => runs,
|
|
37986
|
+
terms: () => terms
|
|
37987
|
+
});
|
|
37988
|
+
//#endregion
|
|
37989
|
+
//#region ../../packages/protocol/src/permissions/rows.ts
|
|
37990
|
+
var rows_exports$2 = /* @__PURE__ */ __exportAll({
|
|
37991
|
+
allowances: () => allowances,
|
|
37992
|
+
authorities: () => authorities,
|
|
37993
|
+
commands: () => commands$1,
|
|
37994
|
+
configurations: () => configurations,
|
|
37995
|
+
replacements: () => replacements,
|
|
37996
|
+
verifications: () => verifications$1
|
|
37997
|
+
});
|
|
37998
|
+
//#endregion
|
|
37999
|
+
//#region ../../packages/protocol/src/profiles/rows.ts
|
|
38000
|
+
var rows_exports$1 = /* @__PURE__ */ __exportAll({
|
|
38001
|
+
details: () => details,
|
|
38002
|
+
onboardings: () => onboardings
|
|
38003
|
+
});
|
|
38004
|
+
//#endregion
|
|
38005
|
+
//#region ../../packages/protocol/src/requests/rows.ts
|
|
38006
|
+
var rows_exports = /* @__PURE__ */ __exportAll({
|
|
38007
|
+
checkouts: () => checkouts,
|
|
38008
|
+
inboxes: () => inboxes,
|
|
38009
|
+
offers: () => offers,
|
|
38010
|
+
receivables: () => receivables
|
|
38011
|
+
});
|
|
38012
|
+
//#endregion
|
|
38013
|
+
//#region ../../packages/protocol/src/operations.ts
|
|
38014
|
+
/** A concept's rows, group by group. */
|
|
38015
|
+
const rowsOf = (concept) => Object.values(concept).flatMap((group) => Object.values(group));
|
|
38016
|
+
const OPERATIONS = [
|
|
38017
|
+
...rowsOf(rows_exports$15),
|
|
38018
|
+
...rowsOf(rows_exports$14),
|
|
38019
|
+
...rowsOf(rows_exports$13),
|
|
38020
|
+
...rowsOf(rows_exports$12),
|
|
38021
|
+
...rowsOf(rows_exports$11),
|
|
38022
|
+
...rowsOf(rows_exports$10),
|
|
38023
|
+
...rowsOf(rows_exports$9),
|
|
38024
|
+
...rowsOf(rows_exports$8),
|
|
38025
|
+
...rowsOf(rows_exports$7),
|
|
38026
|
+
...rowsOf(rows_exports$6),
|
|
38027
|
+
...rowsOf(rows_exports$5),
|
|
38028
|
+
...rowsOf(rows_exports$4),
|
|
38029
|
+
...rowsOf(rows_exports$3),
|
|
38030
|
+
...rowsOf(rows_exports$2),
|
|
38031
|
+
...rowsOf(rows_exports$1),
|
|
38032
|
+
...rowsOf(rows_exports)
|
|
38033
|
+
];
|
|
38034
|
+
//#endregion
|
|
37983
38035
|
//#region ../../packages/sdk/src/platform/transport/convex-diagnostics.ts
|
|
37984
38036
|
const writeConvexDiagnostic = (...args) => {
|
|
37985
38037
|
try {
|
|
@@ -38000,7 +38052,6 @@ const silentConvexLogger = {
|
|
|
38000
38052
|
};
|
|
38001
38053
|
/** Exact floor-first allowlist; every additional handler must migrate its validator first. */
|
|
38002
38054
|
const OBSERVED_CONVEX_ACTIONS = new Set(OPERATIONS.filter((row) => row.kind === "action").map((row) => row.path));
|
|
38003
|
-
const OBSERVED_CONVEX_QUERIES = new Set(OPERATIONS.filter((row) => row.kind === "query").map((row) => row.path));
|
|
38004
38055
|
const OBSERVED_CONVEX_MUTATIONS = new Set(OPERATIONS.filter((row) => row.kind === "mutation").map((row) => row.path));
|
|
38005
38056
|
//#endregion
|
|
38006
38057
|
//#region ../../packages/sdk/src/platform/transport/observed-args.ts
|
|
@@ -38180,32 +38231,61 @@ var ConvexSocketAuth = class {
|
|
|
38180
38231
|
//#endregion
|
|
38181
38232
|
//#region ../../packages/sdk/src/platform/transport/convex-fresh-query.ts
|
|
38182
38233
|
/**
|
|
38183
|
-
* One query read past the client's cache, over HTTP with
|
|
38184
|
-
*
|
|
38185
|
-
*
|
|
38234
|
+
* One query read past the client's cache, over HTTP with the session's token.
|
|
38235
|
+
* The token can be a reused one (CAP-603), so when Convex rejects it the read
|
|
38236
|
+
* asks once for a new token and runs again. When the auth provider gave no
|
|
38237
|
+
* token, the read runs signed out, and a refusal for want of a session reports
|
|
38238
|
+
* that token failure instead (CAP-404).
|
|
38186
38239
|
*/
|
|
38187
38240
|
function freshQuery(deps, fn, args, path) {
|
|
38188
38241
|
let tokenFailure;
|
|
38189
38242
|
return Effect.tryPromise({
|
|
38190
38243
|
try: async (signal) => {
|
|
38191
38244
|
const observed = args();
|
|
38192
|
-
const token = await deps.tokenProvider?.({ forceRefreshToken: false });
|
|
38193
|
-
if (signal.aborted) throw Errors.cancelled({ operation: path });
|
|
38194
|
-
const client = new ConvexHttpClient(deps.convexUrl, {
|
|
38195
|
-
logger: deps.logger,
|
|
38196
|
-
fetch: (input, init) => globalThis.fetch(input, {
|
|
38197
|
-
...init,
|
|
38198
|
-
signal
|
|
38199
|
-
})
|
|
38200
|
-
});
|
|
38201
|
-
if (token instanceof CapxulError) tokenFailure = token;
|
|
38202
|
-
else if (typeof token === "string") client.setAuth(token);
|
|
38203
38245
|
const query = fn;
|
|
38204
|
-
|
|
38246
|
+
const run = async (forceRefreshToken) => {
|
|
38247
|
+
const token = await deps.tokenProvider?.({ forceRefreshToken });
|
|
38248
|
+
if (signal.aborted) throw Errors.cancelled({ operation: path });
|
|
38249
|
+
const client = new ConvexHttpClient(deps.convexUrl, {
|
|
38250
|
+
logger: deps.logger,
|
|
38251
|
+
fetch: (input, init) => globalThis.fetch(input, {
|
|
38252
|
+
...init,
|
|
38253
|
+
signal
|
|
38254
|
+
})
|
|
38255
|
+
});
|
|
38256
|
+
tokenFailure = token instanceof CapxulError ? token : void 0;
|
|
38257
|
+
if (typeof token === "string") client.setAuth(token);
|
|
38258
|
+
return {
|
|
38259
|
+
signedIn: typeof token === "string",
|
|
38260
|
+
value: client.query(query, observed)
|
|
38261
|
+
};
|
|
38262
|
+
};
|
|
38263
|
+
const first = await run(false);
|
|
38264
|
+
try {
|
|
38265
|
+
return await first.value;
|
|
38266
|
+
} catch (cause) {
|
|
38267
|
+
if (!first.signedIn || !rejectedToken(cause)) throw cause;
|
|
38268
|
+
return await (await run(true)).value;
|
|
38269
|
+
}
|
|
38205
38270
|
},
|
|
38206
38271
|
catch: withTokenFailure(timedFailure(path), () => tokenFailure)
|
|
38207
38272
|
});
|
|
38208
38273
|
}
|
|
38274
|
+
/**
|
|
38275
|
+
* Convex refused the request's token (HTTP 401), not the read itself.
|
|
38276
|
+
* ConvexHttpClient keeps no status on its error, only the response body as the
|
|
38277
|
+
* message, so the refusal is read from the JSON `code` in that body.
|
|
38278
|
+
*/
|
|
38279
|
+
function rejectedToken(cause) {
|
|
38280
|
+
if (!(cause instanceof Error)) return false;
|
|
38281
|
+
try {
|
|
38282
|
+
const body = JSON.parse(cause.message);
|
|
38283
|
+
const code = typeof body === "object" && body !== null && "code" in body ? body.code : void 0;
|
|
38284
|
+
return code === "Unauthenticated" || code === "InvalidAuthHeader";
|
|
38285
|
+
} catch {
|
|
38286
|
+
return false;
|
|
38287
|
+
}
|
|
38288
|
+
}
|
|
38209
38289
|
//#endregion
|
|
38210
38290
|
//#region ../../packages/sdk/src/platform/transport/convex-adapter.ts
|
|
38211
38291
|
/**
|
|
@@ -38226,10 +38306,12 @@ var ConvexCallAdapter = class {
|
|
|
38226
38306
|
#observation;
|
|
38227
38307
|
#connectionMonitor;
|
|
38228
38308
|
#closeTimeoutMs;
|
|
38309
|
+
#onWrite;
|
|
38229
38310
|
constructor(deps) {
|
|
38230
38311
|
this.#convexUrl = deps.convexUrl;
|
|
38231
38312
|
this.#logger = deps.localDiagnostics === true ? stderrConvexLogger : silentConvexLogger;
|
|
38232
38313
|
this.#closeTimeoutMs = deps.closeTimeoutMs ?? DEFAULT_CLOSE_TIMEOUT_MS;
|
|
38314
|
+
this.#onWrite = deps.onWrite ?? (() => void 0);
|
|
38233
38315
|
this.#connectionMonitor = new ConvexConnectionMonitor();
|
|
38234
38316
|
const webSocketConstructor = this.#connectionMonitor.observedWebSocketConstructor();
|
|
38235
38317
|
this.#client = deps.client ?? new ConvexClient(deps.convexUrl, {
|
|
@@ -38250,17 +38332,16 @@ var ConvexCallAdapter = class {
|
|
|
38250
38332
|
}
|
|
38251
38333
|
query(fn, args, options) {
|
|
38252
38334
|
const path = getFunctionName(fn);
|
|
38253
|
-
|
|
38254
|
-
|
|
38255
|
-
|
|
38256
|
-
|
|
38257
|
-
|
|
38258
|
-
|
|
38259
|
-
|
|
38260
|
-
|
|
38261
|
-
|
|
38262
|
-
|
|
38263
|
-
});
|
|
38335
|
+
const deps = {
|
|
38336
|
+
convexUrl: this.#convexUrl,
|
|
38337
|
+
logger: this.#logger
|
|
38338
|
+
};
|
|
38339
|
+
return withReadDeadline(path, options?.fresh === true ? freshQuery({
|
|
38340
|
+
...deps,
|
|
38341
|
+
tokenProvider: this.#tokenProvider
|
|
38342
|
+
}, fn, () => args, path) : Effect.tryPromise({
|
|
38343
|
+
try: () => this.#client.query(fn, args),
|
|
38344
|
+
catch: withTokenFailure(timedFailure(path), () => this.#socketAuth?.signedOutBecause())
|
|
38264
38345
|
}), () => connectionState(this.#client));
|
|
38265
38346
|
}
|
|
38266
38347
|
mutation(fn, args) {
|
|
@@ -38269,7 +38350,7 @@ var ConvexCallAdapter = class {
|
|
|
38269
38350
|
return Effect.tryPromise({
|
|
38270
38351
|
try: () => this.#client.mutation(fn, this.#observedArgs(OBSERVED_CONVEX_MUTATIONS, path, args, traceparent)),
|
|
38271
38352
|
catch: withTokenFailure(timedFailure(path), () => this.#socketAuth?.signedOutBecause())
|
|
38272
|
-
});
|
|
38353
|
+
}).pipe(Effect.tap(() => Effect.sync(this.#onWrite)));
|
|
38273
38354
|
});
|
|
38274
38355
|
}
|
|
38275
38356
|
action(fn, args, options) {
|
|
@@ -38281,7 +38362,7 @@ var ConvexCallAdapter = class {
|
|
|
38281
38362
|
catch: withTokenFailure(timedFailure(path, () => this.#connectionMonitor.reconnectEvidence(connectionAtStart, connectionState(this.#client))), () => this.#socketAuth?.signedOutBecause())
|
|
38282
38363
|
}).pipe(Effect.tapError((error) => logActionTransportFailure(path, error)));
|
|
38283
38364
|
});
|
|
38284
|
-
return options?.read === true ? withReadDeadline(path, call, () => connectionState(this.#client)) : call;
|
|
38365
|
+
return options?.read === true ? withReadDeadline(path, call, () => connectionState(this.#client)) : call.pipe(Effect.ensuring(Effect.sync(this.#onWrite)));
|
|
38285
38366
|
}
|
|
38286
38367
|
#observedArgs(allowlist, path, args, traceparent) {
|
|
38287
38368
|
return observedConvexArgs({
|
|
@@ -38581,6 +38662,18 @@ function hostEngineeringPolicy(observability) {
|
|
|
38581
38662
|
...policy?.engineeringPrivacy === void 0 ? {} : { privacy: policy.engineeringPrivacy }
|
|
38582
38663
|
};
|
|
38583
38664
|
}
|
|
38665
|
+
//#endregion
|
|
38666
|
+
//#region ../../packages/sdk/src/platform/runtime-urls.ts
|
|
38667
|
+
/**
|
|
38668
|
+
* Interim default Capxul bootstrap host (SDK publish readiness · I3). Node
|
|
38669
|
+
* consumers pass neither `origin` nor `bootstrapBaseUrl`; both default here so
|
|
38670
|
+
* `createCapxulClient({ publishableKey })` reaches the Capxul backend with no
|
|
38671
|
+
* extra wiring. Staging is the only live deployment, so it is the default for
|
|
38672
|
+
* now; a host passes `bootstrapBaseUrl` to reach another. Superseded by the
|
|
38673
|
+
* key-encoded host (`cap_pk_live_…`, out of scope this milestone). See
|
|
38674
|
+
* `packages/sdk/CONTEXT.md`.
|
|
38675
|
+
*/
|
|
38676
|
+
const DEFAULT_CAPXUL_BOOTSTRAP_BASE_URL = "https://api.staging.capxul.com";
|
|
38584
38677
|
function derivedBrowserOrigin(runtime) {
|
|
38585
38678
|
if (runtime !== "browser") throw Errors.invalidInput("origin", "required outside browser runtime");
|
|
38586
38679
|
const origin = readField(readField(globalThis, "location"), "origin");
|
|
@@ -38641,8 +38734,8 @@ function normalizeHttpUrl(field, raw) {
|
|
|
38641
38734
|
function productionBootstrapPortLayer(bootstrap) {
|
|
38642
38735
|
return Layer.succeed(BootstrapPortTag, bootstrap);
|
|
38643
38736
|
}
|
|
38644
|
-
function productionAuthClientLayer(input, refreshConvexAuthRef, resetSignerSessionRef) {
|
|
38645
|
-
|
|
38737
|
+
function productionAuthClientLayer(input, refreshConvexAuthRef, resetSignerSessionRef, dropConvexJwtRef) {
|
|
38738
|
+
const baseLayer = input.authClient !== void 0 ? Layer.succeed(AuthClientPortTag, input.authClient) : input.runtime === "browser" ? BetterAuthBrowserLayer({
|
|
38646
38739
|
authBaseUrl: input.runtimeUrls.authBaseUrl,
|
|
38647
38740
|
...input.fetch === void 0 ? {} : { fetch: input.fetch },
|
|
38648
38741
|
...input.observation === void 0 ? {} : { observation: input.observation }
|
|
@@ -38652,8 +38745,13 @@ function productionAuthClientLayer(input, refreshConvexAuthRef, resetSignerSessi
|
|
|
38652
38745
|
...input.origin === void 0 ? {} : { origin: input.origin },
|
|
38653
38746
|
...input.fetch === void 0 ? {} : { fetch: input.fetch },
|
|
38654
38747
|
...input.observation === void 0 ? {} : { observation: input.observation }
|
|
38655
|
-
})
|
|
38656
|
-
|
|
38748
|
+
});
|
|
38749
|
+
let wrapped;
|
|
38750
|
+
const wrap = (base) => {
|
|
38751
|
+
if (wrapped?.base === base) return wrapped.client;
|
|
38752
|
+
const reuse = reuseConvexJwt(base);
|
|
38753
|
+
dropConvexJwtRef.current = reuse.drop;
|
|
38754
|
+
const refreshed = refreshConvexAuthOnSession(reuse.authClient, () => {
|
|
38657
38755
|
const refresh = refreshConvexAuthRef.current;
|
|
38658
38756
|
if (refresh === null) {
|
|
38659
38757
|
refreshConvexAuthRef.pending = true;
|
|
@@ -38661,19 +38759,26 @@ function productionAuthClientLayer(input, refreshConvexAuthRef, resetSignerSessi
|
|
|
38661
38759
|
}
|
|
38662
38760
|
refresh();
|
|
38663
38761
|
});
|
|
38664
|
-
|
|
38665
|
-
|
|
38762
|
+
const client = resetSignerSessionRef === void 0 ? refreshed : resetSignerSessionOnSignOut(refreshed, resetSignerSessionRef);
|
|
38763
|
+
wrapped = {
|
|
38764
|
+
base,
|
|
38765
|
+
client
|
|
38766
|
+
};
|
|
38767
|
+
return client;
|
|
38768
|
+
};
|
|
38769
|
+
return baseLayer.pipe(Layer.flatMap((context) => Layer.succeedContext(Context.make(AuthClientPortTag, wrap(Context.get(context, AuthClientPortTag))))));
|
|
38666
38770
|
}
|
|
38667
38771
|
function productionAuthCacheLayer(input) {
|
|
38668
38772
|
return Layer.succeed(AuthCachePortTag, input.authCache ?? detectAuthCacheAdapter());
|
|
38669
38773
|
}
|
|
38670
|
-
function productionConvexCallLayer(input, refreshConvexAuthRef) {
|
|
38774
|
+
function productionConvexCallLayer(input, refreshConvexAuthRef, dropConvexJwtRef) {
|
|
38671
38775
|
return Layer.unwrap(Effect.map(AuthClientPortTag, (authClient) => ConvexCallLayer({
|
|
38672
38776
|
convexUrl: input.runtimeUrls.convexUrl,
|
|
38673
38777
|
localDiagnostics: input.localDiagnostics,
|
|
38674
38778
|
...input.applicationId === void 0 ? {} : { applicationId: input.applicationId },
|
|
38675
38779
|
...input.observation === void 0 ? {} : { observation: input.observation },
|
|
38676
38780
|
...input.convexClient === void 0 ? {} : { client: input.convexClient },
|
|
38781
|
+
onWrite: () => dropConvexJwtRef.current?.(),
|
|
38677
38782
|
tokenProvider: async ({ forceRefreshToken }) => {
|
|
38678
38783
|
const tokenResult = await Effect.runPromise(Effect.result(authClient.getConvexJwt({
|
|
38679
38784
|
forceRefresh: forceRefreshToken,
|
|
@@ -38786,8 +38891,9 @@ function makeProductionAdapterLayer(input) {
|
|
|
38786
38891
|
current: null,
|
|
38787
38892
|
pending: false
|
|
38788
38893
|
};
|
|
38789
|
-
const
|
|
38790
|
-
const
|
|
38894
|
+
const dropConvexJwtRef = { current: null };
|
|
38895
|
+
const authClient = productionAuthClientLayer(input, refreshConvexAuthRef, input.resetSignerSession, dropConvexJwtRef);
|
|
38896
|
+
const convexCall = productionConvexCallLayer(input, refreshConvexAuthRef, dropConvexJwtRef).pipe(Layer.provide(authClient));
|
|
38791
38897
|
const telemetry = input.telemetry === void 0 ? PostHogTelemetryLayer({ capture: () => void 0 }) : Layer.succeed(TelemetryPortTag, input.telemetry);
|
|
38792
38898
|
const observedConvexCall = Layer.merge(convexCall, telemetry);
|
|
38793
38899
|
const org = Layer.effect(OrgPortTag, Effect.all([ConvexCallPortTag, TelemetryPortTag]).pipe(Effect.map(([convex, telemetryPort]) => new ConvexOrganizationAdapter({
|
|
@@ -39016,17 +39122,134 @@ function idempotentClose(close) {
|
|
|
39016
39122
|
await close();
|
|
39017
39123
|
};
|
|
39018
39124
|
}
|
|
39125
|
+
const originOf = (url) => URL.canParse(url) ? new URL(url).origin : void 0;
|
|
39126
|
+
const isLoopback = (url) => {
|
|
39127
|
+
if (!URL.canParse(url)) return false;
|
|
39128
|
+
const { hostname } = new URL(url);
|
|
39129
|
+
return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "[::1]";
|
|
39130
|
+
};
|
|
39131
|
+
const nameOf = (bootstrapBaseUrl, betaBaseUrl) => {
|
|
39132
|
+
if (bootstrapBaseUrl === void 0) return "custom";
|
|
39133
|
+
const origin = originOf(bootstrapBaseUrl);
|
|
39134
|
+
if (origin === "https://api.staging.capxul.com") return "staging";
|
|
39135
|
+
if (betaBaseUrl !== void 0 && origin === originOf(betaBaseUrl)) return "beta";
|
|
39136
|
+
return isLoopback(bootstrapBaseUrl) ? "devnet" : "custom";
|
|
39137
|
+
};
|
|
39138
|
+
const mismatch = (name) => ({
|
|
39139
|
+
ok: false,
|
|
39140
|
+
error: Errors.invalidInput("bootstrapBaseUrl", `is not a ${name} origin`)
|
|
39141
|
+
});
|
|
39142
|
+
/**
|
|
39143
|
+
* Choose the environment from `environment`, else from `bootstrapBaseUrl`, else
|
|
39144
|
+
* staging (`defaultBaseUrl` is undefined when a browser bootstraps from its own
|
|
39145
|
+
* origin). A named environment fixes the bootstrap origin: devnet takes only a
|
|
39146
|
+
* loopback origin, staging and beta only their own. Beta refuses as not
|
|
39147
|
+
* provisioned until `BETA_CAPXUL_BOOTSTRAP_BASE_URL` names its host
|
|
39148
|
+
* (`betaBaseUrl` stands in for it in tests). Production refuses without
|
|
39149
|
+
* `experimental: true`, then refuses as not provisioned, so nothing connects.
|
|
39150
|
+
*/
|
|
39151
|
+
function selectEnvironment(input) {
|
|
39152
|
+
const given = input.bootstrapBaseUrl;
|
|
39153
|
+
const beta = input.betaBaseUrl ?? void 0;
|
|
39154
|
+
switch (input.environment) {
|
|
39155
|
+
case void 0: return {
|
|
39156
|
+
ok: true,
|
|
39157
|
+
value: { name: nameOf(given ?? input.defaultBaseUrl, beta) }
|
|
39158
|
+
};
|
|
39159
|
+
case "devnet":
|
|
39160
|
+
if (given !== void 0 && !isLoopback(given)) return mismatch("devnet");
|
|
39161
|
+
return {
|
|
39162
|
+
ok: true,
|
|
39163
|
+
value: {
|
|
39164
|
+
name: "devnet",
|
|
39165
|
+
bootstrapBaseUrl: given ?? "http://127.0.0.1:3211"
|
|
39166
|
+
}
|
|
39167
|
+
};
|
|
39168
|
+
case "staging":
|
|
39169
|
+
if (given !== void 0 && originOf(given) !== "https://api.staging.capxul.com") return mismatch("staging");
|
|
39170
|
+
return {
|
|
39171
|
+
ok: true,
|
|
39172
|
+
value: {
|
|
39173
|
+
name: "staging",
|
|
39174
|
+
bootstrapBaseUrl: given ?? "https://api.staging.capxul.com"
|
|
39175
|
+
}
|
|
39176
|
+
};
|
|
39177
|
+
case "beta":
|
|
39178
|
+
if (beta === void 0) return {
|
|
39179
|
+
ok: false,
|
|
39180
|
+
error: new CapxulError("CAPABILITY_UNAVAILABLE", "beta is not provisioned yet.", { details: {
|
|
39181
|
+
environment: "beta",
|
|
39182
|
+
reason: "not_provisioned"
|
|
39183
|
+
} })
|
|
39184
|
+
};
|
|
39185
|
+
if (given !== void 0 && originOf(given) !== originOf(beta)) return mismatch("beta");
|
|
39186
|
+
return {
|
|
39187
|
+
ok: true,
|
|
39188
|
+
value: {
|
|
39189
|
+
name: "beta",
|
|
39190
|
+
bootstrapBaseUrl: given ?? beta
|
|
39191
|
+
}
|
|
39192
|
+
};
|
|
39193
|
+
case "production": return {
|
|
39194
|
+
ok: false,
|
|
39195
|
+
error: input.experimental === true ? new CapxulError("CAPABILITY_UNAVAILABLE", "production is not provisioned yet.", { details: {
|
|
39196
|
+
environment: "production",
|
|
39197
|
+
reason: "not_provisioned"
|
|
39198
|
+
} }) : Errors.invalidInput("experimental", "production is experimental and moves real money; pass experimental: true to choose it")
|
|
39199
|
+
};
|
|
39200
|
+
default: return {
|
|
39201
|
+
ok: false,
|
|
39202
|
+
error: Errors.invalidInput("environment", "must be devnet, staging, beta or production")
|
|
39203
|
+
};
|
|
39204
|
+
}
|
|
39205
|
+
}
|
|
39206
|
+
/** The client's `environment` once the bootstrap has named its chain. */
|
|
39207
|
+
const clientEnvironment = (name, chainId) => ({
|
|
39208
|
+
name,
|
|
39209
|
+
chainId,
|
|
39210
|
+
experimental: name === "production"
|
|
39211
|
+
});
|
|
39212
|
+
/**
|
|
39213
|
+
* The factory input with the chosen environment's bootstrap origin, and the
|
|
39214
|
+
* environment's name. A named environment fixes the origin; a browser with no
|
|
39215
|
+
* origin bootstraps from its own page.
|
|
39216
|
+
*/
|
|
39217
|
+
function withEnvironment(input) {
|
|
39218
|
+
const selected = selectEnvironment({
|
|
39219
|
+
...input,
|
|
39220
|
+
defaultBaseUrl: (input.runtime ?? detectRuntime()) === "browser" ? void 0 : DEFAULT_CAPXUL_BOOTSTRAP_BASE_URL
|
|
39221
|
+
});
|
|
39222
|
+
if (!selected.ok) return selected;
|
|
39223
|
+
const { name, bootstrapBaseUrl } = selected.value;
|
|
39224
|
+
return {
|
|
39225
|
+
ok: true,
|
|
39226
|
+
value: {
|
|
39227
|
+
name,
|
|
39228
|
+
input: bootstrapBaseUrl === void 0 ? input : {
|
|
39229
|
+
...input,
|
|
39230
|
+
bootstrapBaseUrl
|
|
39231
|
+
}
|
|
39232
|
+
}
|
|
39233
|
+
};
|
|
39234
|
+
}
|
|
39019
39235
|
//#endregion
|
|
39020
39236
|
//#region ../../packages/sdk/src/platform/client/financial-ops.ts
|
|
39021
39237
|
function makeFinancialOpsMethods(deps) {
|
|
39238
|
+
const agreements = makePayeeAgreementMethods(deps);
|
|
39022
39239
|
return {
|
|
39023
|
-
me:
|
|
39240
|
+
me: {
|
|
39241
|
+
...makeMeMethods(deps),
|
|
39242
|
+
agreements,
|
|
39243
|
+
shares: makeMeShareMethods(deps),
|
|
39244
|
+
votes: makeMyVoteMethods(deps)
|
|
39245
|
+
},
|
|
39024
39246
|
targets: makeTargetsMethods(deps),
|
|
39025
39247
|
destinations: makeDestinationsMethods(deps),
|
|
39026
39248
|
payments: makePaymentsMethods(deps),
|
|
39027
39249
|
approvals: makeApprovalsMethods(deps),
|
|
39028
39250
|
activity: makeActivityMethods(deps),
|
|
39029
|
-
paymentDocuments: makePaymentDocumentsMethods(deps)
|
|
39251
|
+
paymentDocuments: makePaymentDocumentsMethods(deps),
|
|
39252
|
+
agreements
|
|
39030
39253
|
};
|
|
39031
39254
|
}
|
|
39032
39255
|
//#endregion
|
|
@@ -39114,10 +39337,16 @@ function makeMediaMethods(deps) {
|
|
|
39114
39337
|
//#endregion
|
|
39115
39338
|
//#region ../../packages/sdk/src/operator/diagnostics.ts
|
|
39116
39339
|
function makeSystemMethods(deps) {
|
|
39117
|
-
return {
|
|
39118
|
-
|
|
39119
|
-
|
|
39120
|
-
|
|
39340
|
+
return {
|
|
39341
|
+
health: (nonce, options) => {
|
|
39342
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
39343
|
+
return runCapxulEffect(callOperation(deps.convexCall, diagnostics.health, copyInvocationObservation(controls, { nonce }), { read: true }), controls, diagnostics.health.name, deps.runPromise);
|
|
39344
|
+
},
|
|
39345
|
+
clock: (options) => {
|
|
39346
|
+
const controls = deps.invocationControls?.(options) ?? options;
|
|
39347
|
+
return runCapxulEffect(callOperation(deps.convexCall, diagnostics.clock, copyInvocationObservation(controls, {}), { read: true }), controls, diagnostics.clock.name, deps.runPromise);
|
|
39348
|
+
}
|
|
39349
|
+
};
|
|
39121
39350
|
}
|
|
39122
39351
|
//#endregion
|
|
39123
39352
|
//#region ../../packages/sdk/src/platform/client/host-observation.ts
|
|
@@ -39374,6 +39603,8 @@ function bootClientActor(input, effectRunner, observation) {
|
|
|
39374
39603
|
const actor = withHostObservation(effectRunner.runSync(Scope.provide(bootIdentityFlow({
|
|
39375
39604
|
ports: input.ports,
|
|
39376
39605
|
chainId: input.bootstrap.chainId,
|
|
39606
|
+
...input.bootstrap.safeSaltNamespace === void 0 ? {} : { safeSaltNamespace: input.bootstrap.safeSaltNamespace },
|
|
39607
|
+
...input.bootstrap.companiesHouse === void 0 ? {} : { companiesHouse: input.bootstrap.companiesHouse },
|
|
39377
39608
|
requirement: input.requirement,
|
|
39378
39609
|
...input.signer === void 0 ? {} : { signer: input.signer },
|
|
39379
39610
|
...input.organizationSetup === void 0 ? {} : { organizationSetup: input.organizationSetup },
|
|
@@ -39447,6 +39678,14 @@ function makeClientInternals(input, shared) {
|
|
|
39447
39678
|
identity: shared.identity,
|
|
39448
39679
|
bootstrap: input.bootstrap,
|
|
39449
39680
|
accounts: { fund: (...args) => shared.accounts.fund(...args) },
|
|
39681
|
+
gates: makeFeatureGateMethods({
|
|
39682
|
+
convexCall: input.ports.convexCall,
|
|
39683
|
+
runPromise: shared.runPromise
|
|
39684
|
+
}),
|
|
39685
|
+
prices: makeBookPriceMethods({
|
|
39686
|
+
convexCall: input.ports.convexCall,
|
|
39687
|
+
runPromise: shared.runPromise
|
|
39688
|
+
}),
|
|
39450
39689
|
...input.ports.indexerRead === void 0 ? {} : { indexer: input.ports.indexerRead },
|
|
39451
39690
|
organizationSetup: { getProofReceipt: (orgId) => runPortEffect(callOperation(input.ports.convexCall, setups.getProofReceipt, { orgId }).pipe(Effect.mapError((publicError) => ({ publicError }))), void 0, CAPXUL_OPERATIONS.runtime.port, shared.runPromise) },
|
|
39452
39691
|
telemetry: input.ports.telemetry,
|
|
@@ -39485,7 +39724,10 @@ const makeClientScopes = (input, runPromise, invocationControls) => {
|
|
|
39485
39724
|
return {
|
|
39486
39725
|
personal: {
|
|
39487
39726
|
banking: makeBankingMethods(shared),
|
|
39488
|
-
verification: makeVerificationMethods(verification)
|
|
39727
|
+
verification: makeVerificationMethods(verification),
|
|
39728
|
+
features: makeFeatureMethods(shared),
|
|
39729
|
+
waitlist: makeWaitlistMethods(shared),
|
|
39730
|
+
referral: makeReferralMethods(shared)
|
|
39489
39731
|
},
|
|
39490
39732
|
organization: {
|
|
39491
39733
|
banking: (orgId) => makeBankingMethods(shared, {
|
|
@@ -39538,9 +39780,8 @@ function assembleCapxulClient(input) {
|
|
|
39538
39780
|
invocationControls,
|
|
39539
39781
|
...input.signer === void 0 ? {} : { signer: input.signer }
|
|
39540
39782
|
};
|
|
39541
|
-
const
|
|
39542
|
-
kickProvisioning =
|
|
39543
|
-
const account = accountBundle.methods;
|
|
39783
|
+
const { methods: account, kickProvisioning: kickAccount } = makeAccountMethods(accountInput);
|
|
39784
|
+
kickProvisioning = kickAccount;
|
|
39544
39785
|
const authMethodsInput = {
|
|
39545
39786
|
actor,
|
|
39546
39787
|
authClient: input.ports.authClient,
|
|
@@ -39560,7 +39801,7 @@ function assembleCapxulClient(input) {
|
|
|
39560
39801
|
const auth = {
|
|
39561
39802
|
...authCore,
|
|
39562
39803
|
clientRequests: makeClientRequestMethods({
|
|
39563
|
-
authBaseUrl: input.bootstrap.authBaseUrl,
|
|
39804
|
+
authBaseUrl: input.authBaseUrl ?? input.bootstrap.authBaseUrl,
|
|
39564
39805
|
signIn: authCore.signIn,
|
|
39565
39806
|
verifyOtp: authCore.verifyOtp
|
|
39566
39807
|
})
|
|
@@ -39584,7 +39825,7 @@ function assembleCapxulClient(input) {
|
|
|
39584
39825
|
authLifetime: actor.authLifetime,
|
|
39585
39826
|
matchesAuthLifetime: actor.matchesAuthLifetime,
|
|
39586
39827
|
restoreSession: (...args) => auth.getSession(...args),
|
|
39587
|
-
refreshIdentity: (options) => runCapxulEffect(
|
|
39828
|
+
refreshIdentity: (options) => runCapxulEffect(readSession(actor, options ?? {}).pipe(Effect.asVoid), options, CAPXUL_OPERATIONS.identity.readSession, effectRunner.runPromise),
|
|
39588
39829
|
handleAvailable: (...args) => identity.handleAvailable(...args),
|
|
39589
39830
|
completeProfile: (...args) => identity.completeProfile(...args),
|
|
39590
39831
|
loadProfile: (...args) => identity.loadCurrent(...args),
|
|
@@ -39641,6 +39882,7 @@ function assembleCapxulClient(input) {
|
|
|
39641
39882
|
});
|
|
39642
39883
|
const identityRuntime = makeIdentityRuntime(actor, input.ports.identity, effectRunner.runPromise);
|
|
39643
39884
|
const client = {
|
|
39885
|
+
environment: input.environment ?? clientEnvironment("custom", input.bootstrap.chainId),
|
|
39644
39886
|
...scopes.personal,
|
|
39645
39887
|
checkouts: makeCheckoutMethods({
|
|
39646
39888
|
convexCall: input.ports.convexCall,
|
|
@@ -39667,7 +39909,7 @@ function assembleCapxulClient(input) {
|
|
|
39667
39909
|
holdings,
|
|
39668
39910
|
media,
|
|
39669
39911
|
orgs: orgMethods.orgs,
|
|
39670
|
-
org: (
|
|
39912
|
+
org: departmentPayingOrg(orgMethods, financialOps.approvals),
|
|
39671
39913
|
signer: input.signer?.statusStore ?? UNOBSERVABLE_SIGNER_STATUS,
|
|
39672
39914
|
_internal: makeClientInternals(input, {
|
|
39673
39915
|
identity: identityRuntime,
|
|
@@ -39768,9 +40010,12 @@ function signerSessionReset(signer) {
|
|
|
39768
40010
|
};
|
|
39769
40011
|
}
|
|
39770
40012
|
/** Shared production composition. The normal factory passes no controls. */
|
|
39771
|
-
async function createCapxulClientWithSignerControls(
|
|
39772
|
-
const invocationObservability = bindHostObservabilityInvocation(
|
|
39773
|
-
const observation = invocationObservability?.failures ??
|
|
40013
|
+
async function createCapxulClientWithSignerControls(requested, controls) {
|
|
40014
|
+
const invocationObservability = bindHostObservabilityInvocation(requested.observability);
|
|
40015
|
+
const observation = invocationObservability?.failures ?? requested.observation;
|
|
40016
|
+
const selected = withEnvironment(requested);
|
|
40017
|
+
if (!selected.ok) return observeFailedResult(selected, observation, "createCapxulClient");
|
|
40018
|
+
const { input } = selected.value;
|
|
39774
40019
|
const validation = validateCreateCapxulClientInput(input);
|
|
39775
40020
|
if (!validation.ok) return observeFailedResult(validation, observation, "createCapxulClient");
|
|
39776
40021
|
const resetSignerSession = { current: null };
|
|
@@ -39810,6 +40055,7 @@ async function createCapxulClientWithSignerControls(input, controls) {
|
|
|
39810
40055
|
runPromise: Effect.runPromiseWith(adapters.value.context)
|
|
39811
40056
|
};
|
|
39812
40057
|
const ownedClient = withAdapterClose(assembleCapxulClient({
|
|
40058
|
+
environment: clientEnvironment(selected.value.name, adapters.value.bootstrap.chainId),
|
|
39813
40059
|
ports: adapters.value.ports,
|
|
39814
40060
|
bootstrap: adapters.value.bootstrap,
|
|
39815
40061
|
authCache: adapters.value.ports.authCache,
|
|
@@ -39826,6 +40072,7 @@ async function createCapxulClientWithSignerControls(input, controls) {
|
|
|
39826
40072
|
...input.signal === void 0 ? {} : { signal: input.signal },
|
|
39827
40073
|
...input.otpTtlMs === void 0 ? {} : { otpTtlMs: input.otpTtlMs },
|
|
39828
40074
|
invokeTimeoutMs: input.invokeTimeoutMs ?? 3e4,
|
|
40075
|
+
authBaseUrl: resolvedAuthBaseUrl,
|
|
39829
40076
|
...input.observability?.failures === void 0 && input.observation === void 0 ? {} : { failureObservation: input.observability?.failures ?? input.observation },
|
|
39830
40077
|
...input.observability === void 0 ? {} : { hostObservationSnapshot: () => snapshotHostObservability(input.observability) },
|
|
39831
40078
|
effectRunner
|
|
@@ -41757,6 +42004,82 @@ async function createSdkClient(input, createClient = createCapxulClient) {
|
|
|
41757
42004
|
};
|
|
41758
42005
|
}
|
|
41759
42006
|
//#endregion
|
|
42007
|
+
//#region src/stdio-session.ts
|
|
42008
|
+
/** The longest the session waits for unanswered requests after stdin closes. */
|
|
42009
|
+
const ANSWER_DEADLINE_MS = 1e4;
|
|
42010
|
+
/**
|
|
42011
|
+
* `@posthog/mcp` captures a tool's row without awaiting it, a few promise turns
|
|
42012
|
+
* after the answer is written (its `beforeSend` is async), and exposes no
|
|
42013
|
+
* completion signal. The capture does no I/O before it queues the row, so a
|
|
42014
|
+
* short wait after the last answer puts that row in PostHog's queue before the
|
|
42015
|
+
* caller drains it.
|
|
42016
|
+
*/
|
|
42017
|
+
const ROW_SETTLE_MS = 50;
|
|
42018
|
+
/**
|
|
42019
|
+
* Serves MCP over stdio, as `serveStdio` does, and reports when the client has
|
|
42020
|
+
* gone. The SDK's transport is wrapped so the session can count the requests
|
|
42021
|
+
* it has read and not answered yet.
|
|
42022
|
+
*/
|
|
42023
|
+
function serveStdioSession(factory, options = {}) {
|
|
42024
|
+
const stdin = options.stdin ?? process.stdin;
|
|
42025
|
+
const wire = new StdioServerTransport(stdin, options.stdout ?? process.stdout);
|
|
42026
|
+
const unanswered = /* @__PURE__ */ new Set();
|
|
42027
|
+
let answered;
|
|
42028
|
+
let transportClosed;
|
|
42029
|
+
const settle = (id) => {
|
|
42030
|
+
unanswered.delete(id);
|
|
42031
|
+
if (unanswered.size === 0) answered?.();
|
|
42032
|
+
};
|
|
42033
|
+
const transport = {
|
|
42034
|
+
start: () => wire.start(),
|
|
42035
|
+
close: () => wire.close(),
|
|
42036
|
+
send: async (message) => {
|
|
42037
|
+
await wire.send(message);
|
|
42038
|
+
if ((isJSONRPCResultResponse(message) || isJSONRPCErrorResponse(message)) && message.id !== void 0) settle(message.id);
|
|
42039
|
+
}
|
|
42040
|
+
};
|
|
42041
|
+
wire.onmessage = (message) => {
|
|
42042
|
+
if (isJSONRPCRequest(message) && message.method !== "subscriptions/listen") unanswered.add(message.id);
|
|
42043
|
+
if (isJSONRPCNotification(message) && message.method === "notifications/cancelled") {
|
|
42044
|
+
const cancelled = message.params?.requestId;
|
|
42045
|
+
if (typeof cancelled === "string" || typeof cancelled === "number") settle(cancelled);
|
|
42046
|
+
}
|
|
42047
|
+
transport.onmessage?.(message);
|
|
42048
|
+
};
|
|
42049
|
+
wire.onerror = (error) => transport.onerror?.(error);
|
|
42050
|
+
wire.onclose = () => {
|
|
42051
|
+
transport.onclose?.();
|
|
42052
|
+
transportClosed?.();
|
|
42053
|
+
};
|
|
42054
|
+
const handle = serveStdio(factory, {
|
|
42055
|
+
legacy: "reject",
|
|
42056
|
+
transport
|
|
42057
|
+
});
|
|
42058
|
+
const deadlineMs = options.answerDeadlineMs ?? ANSWER_DEADLINE_MS;
|
|
42059
|
+
return {
|
|
42060
|
+
ended: new Promise((resolve) => {
|
|
42061
|
+
const onEnd = () => {
|
|
42062
|
+
transportClosed = void 0;
|
|
42063
|
+
stdin.off("end", onEnd);
|
|
42064
|
+
stdin.off("close", onEnd);
|
|
42065
|
+
const allAnswered = new Promise((done) => {
|
|
42066
|
+
if (unanswered.size === 0) done();
|
|
42067
|
+
else answered = done;
|
|
42068
|
+
});
|
|
42069
|
+
let deadline;
|
|
42070
|
+
const late = new Promise((done) => {
|
|
42071
|
+
deadline = setTimeout(done, deadlineMs);
|
|
42072
|
+
});
|
|
42073
|
+
Promise.race([allAnswered, late]).then(() => clearTimeout(deadline)).then(() => new Promise((wait) => setTimeout(wait, ROW_SETTLE_MS))).then(() => resolve());
|
|
42074
|
+
};
|
|
42075
|
+
stdin.once("end", onEnd);
|
|
42076
|
+
stdin.once("close", onEnd);
|
|
42077
|
+
transportClosed = onEnd;
|
|
42078
|
+
}),
|
|
42079
|
+
close: () => handle.close()
|
|
42080
|
+
};
|
|
42081
|
+
}
|
|
42082
|
+
//#endregion
|
|
41760
42083
|
//#region src/main.ts
|
|
41761
42084
|
const cli = parseCliArgs(process.argv.slice(2));
|
|
41762
42085
|
if (cli.kind === "help") {
|
|
@@ -41805,7 +42128,7 @@ const deps = {
|
|
|
41805
42128
|
};
|
|
41806
42129
|
if (cli.stdio) {
|
|
41807
42130
|
const identity = stdioIdentity();
|
|
41808
|
-
const
|
|
42131
|
+
const session = serveStdioSession(() => buildMcpServer(deps, identity));
|
|
41809
42132
|
console.error("capxul-mcp listening on stdio");
|
|
41810
42133
|
console.error(renderStartupBanner({
|
|
41811
42134
|
mode: cli.mode,
|
|
@@ -41813,11 +42136,15 @@ if (cli.stdio) {
|
|
|
41813
42136
|
backend: readBackendForBanner(),
|
|
41814
42137
|
bearer: identity === void 0 ? "none" : "environment"
|
|
41815
42138
|
}));
|
|
42139
|
+
let stopping = false;
|
|
41816
42140
|
const shutdownStdio = () => {
|
|
41817
|
-
|
|
42141
|
+
if (stopping) return;
|
|
42142
|
+
stopping = true;
|
|
42143
|
+
session.close().catch((cause) => console.error("[capxul-mcp] close failed:", cause)).then(() => engineering?.dispose()).then(() => posthog?.shutdown()).catch((cause) => console.error("[capxul-mcp] PostHog shutdown failed:", cause)).finally(() => process.exit(0));
|
|
41818
42144
|
};
|
|
41819
42145
|
process.on("SIGINT", shutdownStdio);
|
|
41820
42146
|
process.on("SIGTERM", shutdownStdio);
|
|
42147
|
+
session.ended.then(shutdownStdio);
|
|
41821
42148
|
} else {
|
|
41822
42149
|
const running = await startHttpServer({
|
|
41823
42150
|
port,
|