@capxul/mcp 4.20.0-beta.41 → 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 +1090 -740
- package/dist/{organizations-D3Z6n79m.mjs → organizations-Bg6eIN7c.mjs} +48844 -37437
- package/dist/{permission-approvals-DJ08uQHm.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 +5 -5
- 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
|
/**
|
|
@@ -1278,7 +989,8 @@ const CLI_ENGINEERING_LIMITS = Object.freeze({
|
|
|
1278
989
|
ordinaryRequests: 2,
|
|
1279
990
|
requestBytes: 1572864,
|
|
1280
991
|
metricSeries: 16,
|
|
1281
|
-
requestTimeoutMs: 1e3
|
|
992
|
+
requestTimeoutMs: 1e3,
|
|
993
|
+
responseBytes: 65536
|
|
1282
994
|
});
|
|
1283
995
|
//#endregion
|
|
1284
996
|
//#region ../../packages/observability/src/delivery/admission.ts
|
|
@@ -1292,6 +1004,7 @@ function newDeliveryState(budget, ownsMetrics) {
|
|
|
1292
1004
|
logs: [],
|
|
1293
1005
|
spans: /* @__PURE__ */ new Map(),
|
|
1294
1006
|
terminalBodies: /* @__PURE__ */ new WeakSet(),
|
|
1007
|
+
packets: /* @__PURE__ */ new WeakMap(),
|
|
1295
1008
|
bodyLeases: /* @__PURE__ */ new WeakMap(),
|
|
1296
1009
|
pendingBodies: /* @__PURE__ */ new Set()
|
|
1297
1010
|
};
|
|
@@ -1396,8 +1109,8 @@ const browserExportClient = (client) => HttpClient.transform(client, (response,
|
|
|
1396
1109
|
const spanUpstream = (span) => {
|
|
1397
1110
|
let current = span;
|
|
1398
1111
|
while (current?._tag === "Span") {
|
|
1399
|
-
const
|
|
1400
|
-
if (
|
|
1112
|
+
const source = urlCredentialSource(current.attributes.get("chain.upstream"));
|
|
1113
|
+
if (source !== void 0) return source;
|
|
1401
1114
|
current = current.parent._tag === "Some" ? current.parent.value : void 0;
|
|
1402
1115
|
}
|
|
1403
1116
|
};
|
|
@@ -1586,6 +1299,14 @@ function boundedSpan(state, span) {
|
|
|
1586
1299
|
}
|
|
1587
1300
|
//#endregion
|
|
1588
1301
|
//#region ../../packages/observability/src/delivery/requests.ts
|
|
1302
|
+
const rememberPacket = (state, body, lane) => {
|
|
1303
|
+
if (state.budget.journal === void 0 || body._tag !== "Uint8Array" || body.body.byteLength > CLI_ENGINEERING_LIMITS.requestBytes) return;
|
|
1304
|
+
state.packets.set(body, {
|
|
1305
|
+
lane,
|
|
1306
|
+
body: new TextDecoder().decode(body.body),
|
|
1307
|
+
terminal: state.terminalBodies.has(body)
|
|
1308
|
+
});
|
|
1309
|
+
};
|
|
1589
1310
|
function admittedSerialization(state, delegate) {
|
|
1590
1311
|
return {
|
|
1591
1312
|
logs(data) {
|
|
@@ -1594,6 +1315,7 @@ function admittedSerialization(state, delegate) {
|
|
|
1594
1315
|
const body = delegate.logs(data);
|
|
1595
1316
|
if (data.resourceLogs.some((r) => r.scopeLogs.some((s) => s.logRecords?.some((l) => terminalName(l.body?.stringValue ?? ""))))) state.terminalBodies.add(body);
|
|
1596
1317
|
holdBody(state, body, releases);
|
|
1318
|
+
rememberPacket(state, body, "logs");
|
|
1597
1319
|
return body;
|
|
1598
1320
|
} catch (error) {
|
|
1599
1321
|
for (const release of releases) release();
|
|
@@ -1611,6 +1333,7 @@ function admittedSerialization(state, delegate) {
|
|
|
1611
1333
|
const body = delegate.traces(data);
|
|
1612
1334
|
if (data.resourceSpans.some((r) => r.scopeSpans.some((s) => s.spans.some((span) => terminalName(span.name))))) state.terminalBodies.add(body);
|
|
1613
1335
|
holdBody(state, body, releases);
|
|
1336
|
+
rememberPacket(state, body, "traces");
|
|
1614
1337
|
return body;
|
|
1615
1338
|
} catch (error) {
|
|
1616
1339
|
for (const release of releases) release();
|
|
@@ -1620,6 +1343,7 @@ function admittedSerialization(state, delegate) {
|
|
|
1620
1343
|
metrics(data) {
|
|
1621
1344
|
const body = delegate.metrics(data);
|
|
1622
1345
|
state.terminalBodies.add(body);
|
|
1346
|
+
rememberPacket(state, body, "metrics");
|
|
1623
1347
|
return body;
|
|
1624
1348
|
}
|
|
1625
1349
|
};
|
|
@@ -1642,7 +1366,7 @@ function admittedTransport(state, client, enabled = () => true) {
|
|
|
1642
1366
|
let received = 0;
|
|
1643
1367
|
return Stream.runForEach(result.stream, (chunk) => Effect.sync(() => {
|
|
1644
1368
|
received += chunk.byteLength;
|
|
1645
|
-
if (received >
|
|
1369
|
+
if (received > CLI_ENGINEERING_LIMITS.responseBytes) throw new Error("Engineering response limit exceeded");
|
|
1646
1370
|
})).pipe(Effect.catchReason("HttpClientError", "EmptyBodyError", () => Effect.void));
|
|
1647
1371
|
}))).pipe(HttpClient.filterStatusOk, HttpClient.retryTransient({
|
|
1648
1372
|
times: 1,
|
|
@@ -1666,7 +1390,15 @@ function admittedTransport(state, client, enabled = () => true) {
|
|
|
1666
1390
|
}
|
|
1667
1391
|
const lease = state.bodyLeases.get(request.body);
|
|
1668
1392
|
if (lease !== void 0) lease.started = true;
|
|
1669
|
-
return
|
|
1393
|
+
return (budget.journal === void 0 ? response : Effect.suspend(() => {
|
|
1394
|
+
const packet = state.packets.get(request.body);
|
|
1395
|
+
state.packets.delete(request.body);
|
|
1396
|
+
if (packet === void 0 || !enabled()) {
|
|
1397
|
+
budget.drop();
|
|
1398
|
+
return Effect.void;
|
|
1399
|
+
}
|
|
1400
|
+
return budget.journal?.(packet) ?? Effect.void;
|
|
1401
|
+
})).pipe(Effect.asVoid, Effect.timeoutOption(CLI_ENGINEERING_LIMITS.requestTimeoutMs), Effect.raceFirst(Deferred.await(state.closed).pipe(Effect.andThen(Effect.interrupt))), Effect.tap((result) => Effect.sync(() => {
|
|
1670
1402
|
if (Option.isNone(result)) budget.drop();
|
|
1671
1403
|
})), Effect.catchCause(() => Effect.sync(() => {
|
|
1672
1404
|
budget.drop();
|
|
@@ -1701,13 +1433,18 @@ function cliEngineeringDelivery(budget, ownsMetrics) {
|
|
|
1701
1433
|
}
|
|
1702
1434
|
//#endregion
|
|
1703
1435
|
//#region ../../packages/observability/src/engineering/config.ts
|
|
1704
|
-
/**
|
|
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
|
+
*/
|
|
1705
1440
|
const ENGINEERING_CAPXUL_ENVS = [
|
|
1706
1441
|
"development",
|
|
1707
1442
|
"staging",
|
|
1443
|
+
"beta",
|
|
1708
1444
|
"production",
|
|
1709
1445
|
"devnet",
|
|
1710
|
-
"local"
|
|
1446
|
+
"local",
|
|
1447
|
+
"unset"
|
|
1711
1448
|
];
|
|
1712
1449
|
const traceHeaderFilter = (_name) => true;
|
|
1713
1450
|
const credentialHeaderPattern = Object.assign(/./u, { exec: (name) => isCredentialField(name, "header") ? Object.assign([name], {
|
|
@@ -1784,12 +1521,20 @@ const MINIMAL_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
|
1784
1521
|
"CLI_CONFIG",
|
|
1785
1522
|
"CLI_STORAGE",
|
|
1786
1523
|
"CLI_DEFECT",
|
|
1787
|
-
"CLI_DEADLINE"
|
|
1524
|
+
"CLI_DEADLINE",
|
|
1525
|
+
"WRONG_ENVIRONMENT",
|
|
1526
|
+
"EXPERIMENTAL_NOT_ACCEPTED",
|
|
1527
|
+
"ENVIRONMENT_NOT_CHOSEN"
|
|
1788
1528
|
]);
|
|
1789
1529
|
const MINIMAL_NUMBERS = /* @__PURE__ */ new Set([
|
|
1790
1530
|
"schema_version",
|
|
1791
1531
|
"duration_ms",
|
|
1792
1532
|
"wait_duration_ms",
|
|
1533
|
+
"wait_scope_ms",
|
|
1534
|
+
"wait_transfers_ms",
|
|
1535
|
+
"wait_payments_ms",
|
|
1536
|
+
"wait_decoration_ms",
|
|
1537
|
+
"wait_facts_ms",
|
|
1793
1538
|
"retry_count",
|
|
1794
1539
|
"http.status_code",
|
|
1795
1540
|
"http.response.status_code",
|
|
@@ -2152,9 +1897,11 @@ const logEngineeringInfo = (message, attributes) => {
|
|
|
2152
1897
|
/** Shared browser/server OTLP layer. OtlpLogger merges with incumbent loggers once. */
|
|
2153
1898
|
const makeEngineeringTelemetryLayer = (config) => {
|
|
2154
1899
|
const validated = validateEngineeringTelemetryConfig(config);
|
|
1900
|
+
if (validated.deliveryBudget?.journal !== void 0 && validated.privacy !== "minimal") throw new TypeError("CLI journal delivery requires minimal engineering privacy");
|
|
2155
1901
|
return Layer.suspend(() => {
|
|
2156
1902
|
const bounded = validated.deliveryBudget === void 0 ? void 0 : cliEngineeringDelivery(validated.deliveryBudget, validated.serviceName === "capxul-cli");
|
|
2157
1903
|
const endpoints = postHogOtlpEndpoints(validated.host);
|
|
1904
|
+
const headers = validated.deliveryBudget?.journal === void 0 ? validated.headers : void 0;
|
|
2158
1905
|
let disabled = false;
|
|
2159
1906
|
const enabled = () => {
|
|
2160
1907
|
if (disabled) return false;
|
|
@@ -2185,13 +1932,13 @@ const makeEngineeringTelemetryLayer = (config) => {
|
|
|
2185
1932
|
};
|
|
2186
1933
|
const tracing = Layer.effect(Tracer.Tracer, OtlpTracer.make({
|
|
2187
1934
|
url: endpoints.traces,
|
|
2188
|
-
headers
|
|
1935
|
+
headers,
|
|
2189
1936
|
resource,
|
|
2190
1937
|
...delivery
|
|
2191
1938
|
}).pipe(Effect.map((tracer) => makeLeakSafeEngineeringTracer(bounded?.tracer(tracer) ?? tracer, enabled)))).pipe(Layer.provideMerge(OtlpExporter.layerFlusher));
|
|
2192
1939
|
const ownedLogging = Layer.effect(EngineeringLog, OtlpLogger.make({
|
|
2193
1940
|
url: endpoints.logs,
|
|
2194
|
-
headers
|
|
1941
|
+
headers,
|
|
2195
1942
|
resource,
|
|
2196
1943
|
...delivery,
|
|
2197
1944
|
...bounded === void 0 ? {} : { excludeLogSpans: true }
|
|
@@ -2204,7 +1951,7 @@ const makeEngineeringTelemetryLayer = (config) => {
|
|
|
2204
1951
|
const logging = Logger.layer([EngineeringLog], { mergeWithExisting: true }).pipe(Layer.provideMerge(ownedLogging));
|
|
2205
1952
|
const metricConfig = {
|
|
2206
1953
|
url: endpoints.metrics,
|
|
2207
|
-
headers
|
|
1954
|
+
headers,
|
|
2208
1955
|
resource,
|
|
2209
1956
|
temporality: "delta",
|
|
2210
1957
|
...delivery
|
|
@@ -2264,6 +2011,295 @@ const makeEngineeringTelemetryLayer = (config) => {
|
|
|
2264
2011
|
});
|
|
2265
2012
|
};
|
|
2266
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
|
|
2267
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
|
|
2268
2304
|
/**
|
|
2269
2305
|
* @description Creates an Account from a custom signing implementation.
|
|
@@ -2445,6 +2481,33 @@ function privateKeyToAccount(privateKey, options = {}) {
|
|
|
2445
2481
|
};
|
|
2446
2482
|
}
|
|
2447
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
|
|
2448
2511
|
//#region ../../packages/sdk/src/platform/transport/convex-read-deadline.ts
|
|
2449
2512
|
/**
|
|
2450
2513
|
* How long a one-shot read waits for its answer: a query, or an action marked
|
|
@@ -2486,63 +2549,6 @@ function readTimedOut(operation, connection) {
|
|
|
2486
2549
|
}));
|
|
2487
2550
|
}
|
|
2488
2551
|
//#endregion
|
|
2489
|
-
//#region ../../packages/protocol/src/errors/convex-decoding.ts
|
|
2490
|
-
const KNOWN_CODES = new Set(CAPXUL_ERROR_CODES);
|
|
2491
|
-
function isCapxulCode(value) {
|
|
2492
|
-
return typeof value === "string" && KNOWN_CODES.has(value);
|
|
2493
|
-
}
|
|
2494
|
-
/**
|
|
2495
|
-
* A serialized failure, rebuilt whole. Nothing that crossed is dropped: a code
|
|
2496
|
-
* this build does not know (a newer backend) becomes an explicit `UNKNOWN` that
|
|
2497
|
-
* names the code it received, and an unrecognized mode or chain shape is kept
|
|
2498
|
-
* raw in `details` instead of being guessed at or discarded.
|
|
2499
|
-
*/
|
|
2500
|
-
function reconstruct(serialized) {
|
|
2501
|
-
if (typeof serialized.code !== "string") return null;
|
|
2502
|
-
const unrecognized = {
|
|
2503
|
-
...isCapxulCode(serialized.code) ? {} : { receivedCode: serialized.code },
|
|
2504
|
-
...serialized.mode === void 0 || isFailureMode(serialized.mode) ? {} : { unrecognizedMode: serialized.mode }
|
|
2505
|
-
};
|
|
2506
|
-
const chain = serialized.chain === void 0 ? null : decodeChainCause(serialized.chain);
|
|
2507
|
-
if (serialized.chain !== void 0 && chain === null) unrecognized.unrecognizedChain = serialized.chain;
|
|
2508
|
-
const hasDetails = isRecord(serialized.details) || Object.keys(unrecognized).length > 0;
|
|
2509
|
-
const cause = causeLinks(serialized.cause);
|
|
2510
|
-
const payload = {
|
|
2511
|
-
code: isCapxulCode(serialized.code) ? serialized.code : "UNKNOWN",
|
|
2512
|
-
message: typeof serialized.message === "string" ? serialized.message : serialized.code,
|
|
2513
|
-
...hasDetails ? { details: {
|
|
2514
|
-
...isRecord(serialized.details) ? serialized.details : {},
|
|
2515
|
-
...unrecognized
|
|
2516
|
-
} } : {},
|
|
2517
|
-
...typeof serialized.correlationId === "string" ? { correlationId: serialized.correlationId } : {},
|
|
2518
|
-
...typeof serialized.layer === "string" ? { layer: serialized.layer } : {},
|
|
2519
|
-
...isFailureMode(serialized.mode) ? { mode: serialized.mode } : {},
|
|
2520
|
-
...chain === null ? {} : { chain },
|
|
2521
|
-
...cause === void 0 ? {} : { cause }
|
|
2522
|
-
};
|
|
2523
|
-
return deserializeCapxulError(payload);
|
|
2524
|
-
}
|
|
2525
|
-
function causeLinks(value) {
|
|
2526
|
-
if (!Array.isArray(value)) return void 0;
|
|
2527
|
-
const links = value.filter((link) => isRecord(link) && typeof link.name === "string" && typeof link.message === "string");
|
|
2528
|
-
return links.length === 0 ? void 0 : links;
|
|
2529
|
-
}
|
|
2530
|
-
function decodeConvexError(err) {
|
|
2531
|
-
if (err === null || err === void 0) return null;
|
|
2532
|
-
if (err instanceof CapxulError) return err;
|
|
2533
|
-
if (typeof err !== "object") return null;
|
|
2534
|
-
if (!("data" in err)) return null;
|
|
2535
|
-
const data = err.data;
|
|
2536
|
-
if (isRecord(data)) return reconstruct(data);
|
|
2537
|
-
if (typeof data === "string") try {
|
|
2538
|
-
const parsed = JSON.parse(data);
|
|
2539
|
-
if (isRecord(parsed)) return reconstruct(parsed);
|
|
2540
|
-
} catch {
|
|
2541
|
-
return null;
|
|
2542
|
-
}
|
|
2543
|
-
return null;
|
|
2544
|
-
}
|
|
2545
|
-
//#endregion
|
|
2546
2552
|
//#region ../../packages/sdk/src/platform/transport/convex-errors.ts
|
|
2547
2553
|
/**
|
|
2548
2554
|
* All a redacting backend says about an error it raised itself: its request
|
|
@@ -2599,7 +2605,7 @@ function mapToCapxulError(operation, err, elapsedMs, transport) {
|
|
|
2599
2605
|
});
|
|
2600
2606
|
}
|
|
2601
2607
|
if (err instanceof Error && isTransportError(err)) return Errors.networkError(operation, err, { provider: "convex" });
|
|
2602
|
-
return backendFailure
|
|
2608
|
+
return backendFailure(operation, err, elapsedMs);
|
|
2603
2609
|
}
|
|
2604
2610
|
/**
|
|
2605
2611
|
* A failure the backend raised outside its own error boundary: Convex
|
|
@@ -2616,7 +2622,7 @@ function mapToCapxulError(operation, err, elapsedMs, transport) {
|
|
|
2616
2622
|
* the reply says where to look instead. The text matches stay for a backend
|
|
2617
2623
|
* that does not redact (development, local).
|
|
2618
2624
|
*/
|
|
2619
|
-
function backendFailure
|
|
2625
|
+
function backendFailure(operation, err, elapsedMs) {
|
|
2620
2626
|
const text = err instanceof Error ? err.message : String(err);
|
|
2621
2627
|
const redacted = REDACTED_ERROR.exec(text.trim())?.[1];
|
|
2622
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.`, {
|
|
@@ -14726,7 +14732,7 @@ var require_follow_redirects = /* @__PURE__ */ __commonJSMin(((exports, module)
|
|
|
14726
14732
|
this._performRequest();
|
|
14727
14733
|
};
|
|
14728
14734
|
function wrap(protocols) {
|
|
14729
|
-
var exports$
|
|
14735
|
+
var exports$2 = {
|
|
14730
14736
|
maxRedirects: 21,
|
|
14731
14737
|
maxBodyLength: 10485760
|
|
14732
14738
|
};
|
|
@@ -14734,7 +14740,7 @@ var require_follow_redirects = /* @__PURE__ */ __commonJSMin(((exports, module)
|
|
|
14734
14740
|
Object.keys(protocols).forEach(function(scheme) {
|
|
14735
14741
|
var protocol = scheme + ":";
|
|
14736
14742
|
var nativeProtocol = nativeProtocols[protocol] = protocols[scheme];
|
|
14737
|
-
var wrappedProtocol = exports$
|
|
14743
|
+
var wrappedProtocol = exports$2[scheme] = Object.create(nativeProtocol);
|
|
14738
14744
|
function request(input, options, callback) {
|
|
14739
14745
|
if (isURL(input)) input = spreadUrlObject(input);
|
|
14740
14746
|
else if (isString(input)) input = spreadUrlObject(parseUrl(input));
|
|
@@ -14748,8 +14754,8 @@ var require_follow_redirects = /* @__PURE__ */ __commonJSMin(((exports, module)
|
|
|
14748
14754
|
options = null;
|
|
14749
14755
|
}
|
|
14750
14756
|
options = Object.assign({
|
|
14751
|
-
maxRedirects: exports$
|
|
14752
|
-
maxBodyLength: exports$
|
|
14757
|
+
maxRedirects: exports$2.maxRedirects,
|
|
14758
|
+
maxBodyLength: exports$2.maxBodyLength
|
|
14753
14759
|
}, input, options);
|
|
14754
14760
|
options.nativeProtocols = nativeProtocols;
|
|
14755
14761
|
if (!isString(options.host) && !isString(options.hostname)) options.hostname = "::1";
|
|
@@ -14777,7 +14783,7 @@ var require_follow_redirects = /* @__PURE__ */ __commonJSMin(((exports, module)
|
|
|
14777
14783
|
}
|
|
14778
14784
|
});
|
|
14779
14785
|
});
|
|
14780
|
-
return exports$
|
|
14786
|
+
return exports$2;
|
|
14781
14787
|
}
|
|
14782
14788
|
function noop() {}
|
|
14783
14789
|
function parseUrl(input) {
|
|
@@ -15218,7 +15224,7 @@ const isIPv6Loopback = (host) => {
|
|
|
15218
15224
|
}
|
|
15219
15225
|
return false;
|
|
15220
15226
|
};
|
|
15221
|
-
const isLoopback = (host) => {
|
|
15227
|
+
const isLoopback$1 = (host) => {
|
|
15222
15228
|
if (!host) return false;
|
|
15223
15229
|
if (LOOPBACK_HOSTNAMES.has(host)) return true;
|
|
15224
15230
|
if (isIPv4Loopback(host)) return true;
|
|
@@ -15291,7 +15297,7 @@ function shouldBypassProxy(location) {
|
|
|
15291
15297
|
if (entryPort && entryPort !== port) return false;
|
|
15292
15298
|
if (entryHost.charAt(0) === "*") entryHost = entryHost.slice(1);
|
|
15293
15299
|
if (entryHost.charAt(0) === ".") return hostname.endsWith(entryHost);
|
|
15294
|
-
return hostname === entryHost || isLoopback(hostname) && isLoopback(entryHost);
|
|
15300
|
+
return hostname === entryHost || isLoopback$1(hostname) && isLoopback$1(entryHost);
|
|
15295
15301
|
});
|
|
15296
15302
|
}
|
|
15297
15303
|
//#endregion
|
|
@@ -27702,16 +27708,16 @@ const signMessage = async (parameters) => {
|
|
|
27702
27708
|
type: "bytes32"
|
|
27703
27709
|
}] };
|
|
27704
27710
|
const updatedMessage = { hashedMessage: typedDataHash };
|
|
27705
|
-
const { _TypedDataEncoder } = await import("./lib-
|
|
27711
|
+
const { _TypedDataEncoder } = await import("./lib-DWEnweWw.mjs").then((m) => /* @__PURE__ */ __toESM(m.default, 1));
|
|
27706
27712
|
typedDataHash = _TypedDataEncoder.hash(updatedDomain, updatedTypes, updatedMessage);
|
|
27707
27713
|
}
|
|
27708
27714
|
const signature = await signer.sign(typedDataHash, false, false);
|
|
27709
27715
|
let result = signature;
|
|
27710
27716
|
if (factoryAddress && salt) {
|
|
27711
27717
|
if ([AccountType.UPGRADEABLE_V5, AccountType.UPGRADEABLE_V6].includes(implementationType)) {
|
|
27712
|
-
const { id } = await import("./lib-
|
|
27713
|
-
const { defaultAbiCoder } = await import("./lib-
|
|
27714
|
-
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));
|
|
27715
27721
|
const factoryCalldata = hexConcat([id("createAccountWithNonce(address,bytes32,bool)").slice(0, 10), defaultAbiCoder.encode([
|
|
27716
27722
|
"address",
|
|
27717
27723
|
"bytes32",
|
|
@@ -27820,8 +27826,8 @@ const personalSign = async ({ params, signer, account, eventEmitter }) => {
|
|
|
27820
27826
|
const fromAddress = params[1];
|
|
27821
27827
|
if (!fromAddress || !message) throw new JsonRpcError(RpcErrorCode.INVALID_PARAMS, "personal_sign requires an address and a message");
|
|
27822
27828
|
if (fromAddress.toLowerCase() !== account.address.toLowerCase()) throw new JsonRpcError(RpcErrorCode.INVALID_PARAMS, "personal_sign requires the signer to be the from address");
|
|
27823
|
-
const { hashMessage } = await import("./lib-
|
|
27824
|
-
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));
|
|
27825
27831
|
const data = isHexString(message) ? arrayify(message) : message;
|
|
27826
27832
|
return await signMessage({
|
|
27827
27833
|
hash: hashMessage(data),
|
|
@@ -28338,7 +28344,7 @@ const signTypedDataV4 = async ({ params, method, signer, implementationType, rpc
|
|
|
28338
28344
|
const typedData = transformTypedData(typedDataParam, chainId);
|
|
28339
28345
|
const types = { ...typedData.types };
|
|
28340
28346
|
delete types.EIP712Domain;
|
|
28341
|
-
const { _TypedDataEncoder } = await import("./lib-
|
|
28347
|
+
const { _TypedDataEncoder } = await import("./lib-DWEnweWw.mjs").then((m) => /* @__PURE__ */ __toESM(m.default, 1));
|
|
28342
28348
|
const typedDataHash = _TypedDataEncoder.hash(typedData.domain, types, typedData.message);
|
|
28343
28349
|
return await signMessage({
|
|
28344
28350
|
hash: typedDataHash,
|
|
@@ -28431,7 +28437,7 @@ var EvmProvider = class {
|
|
|
28431
28437
|
if (!this.#rpcProvider) {
|
|
28432
28438
|
const chainId = (await Account.fromStorage(this.#storage))?.chainId || (this.#customChains ? Number(Object.keys(this.#customChains)[0]) : void 0) || 8453;
|
|
28433
28439
|
const rpcUrl = this.#resolveRpcUrl(chainId);
|
|
28434
|
-
await import("./lib-
|
|
28440
|
+
await import("./lib-CkoBT6RP.mjs").then((m) => /* @__PURE__ */ __toESM(m.default, 1)).then((module) => {
|
|
28435
28441
|
this.#rpcProvider = new module.StaticJsonRpcProvider(rpcUrl);
|
|
28436
28442
|
});
|
|
28437
28443
|
}
|
|
@@ -28463,7 +28469,7 @@ var EvmProvider = class {
|
|
|
28463
28469
|
if (!transaction) throw new JsonRpcError(RpcErrorCode.INVALID_PARAMS, `${request.method} requires a transaction object`);
|
|
28464
28470
|
if (!transaction.chainId) transaction.chainId = chainId.toString();
|
|
28465
28471
|
const parsedTransaction = parseTransactionRequest(transaction);
|
|
28466
|
-
const { serialize } = await import("./lib-
|
|
28472
|
+
const { serialize } = await import("./lib-CPklA4fw.mjs").then((m) => /* @__PURE__ */ __toESM(m.default, 1));
|
|
28467
28473
|
const typeToNumber = (type) => {
|
|
28468
28474
|
return {
|
|
28469
28475
|
legacy: 0,
|
|
@@ -28479,11 +28485,11 @@ var EvmProvider = class {
|
|
|
28479
28485
|
type: typeToNumber(parsedTransaction.type)
|
|
28480
28486
|
};
|
|
28481
28487
|
const unsignedTx = serialize(ethersTransaction);
|
|
28482
|
-
const { keccak256 } = await import("./lib-
|
|
28488
|
+
const { keccak256 } = await import("./lib-B0WujUb6.mjs").then((m) => /* @__PURE__ */ __toESM(m.default, 1));
|
|
28483
28489
|
const digest = keccak256(unsignedTx);
|
|
28484
28490
|
await this.#validateAndRefreshSession();
|
|
28485
28491
|
const signature = await signer.sign(digest, false, false);
|
|
28486
|
-
const { splitSignature } = await import("./lib-
|
|
28492
|
+
const { splitSignature } = await import("./lib-C5rDhBj_.mjs").then((m) => /* @__PURE__ */ __toESM(m.default, 1));
|
|
28487
28493
|
return serialize(ethersTransaction, splitSignature(signature));
|
|
28488
28494
|
}
|
|
28489
28495
|
case "eth_sendTransaction": {
|
|
@@ -28589,7 +28595,7 @@ var EvmProvider = class {
|
|
|
28589
28595
|
const rpcUrl = this.#resolveRpcUrl(chainIdNumber);
|
|
28590
28596
|
try {
|
|
28591
28597
|
await signer.switchChain({ chainId: chainIdNumber });
|
|
28592
|
-
await import("./lib-
|
|
28598
|
+
await import("./lib-CkoBT6RP.mjs").then((m) => /* @__PURE__ */ __toESM(m.default, 1)).then((module) => {
|
|
28593
28599
|
this.#rpcProvider = new module.StaticJsonRpcProvider(rpcUrl);
|
|
28594
28600
|
});
|
|
28595
28601
|
this.#eventEmitter.emit(ProviderEvent.CHAIN_CHANGED, numberToHex(chainIdNumber));
|
|
@@ -30879,7 +30885,7 @@ var EmbeddedWalletApi = class {
|
|
|
30879
30885
|
if (!account) throw new SignerError(OPENFORT_AUTH_ERROR_CODES.MISSING_SIGNER, "No account found");
|
|
30880
30886
|
const typesWithoutDomain = { ...types };
|
|
30881
30887
|
delete typesWithoutDomain.EIP712Domain;
|
|
30882
|
-
const { _TypedDataEncoder } = await import("./lib-
|
|
30888
|
+
const { _TypedDataEncoder } = await import("./lib-DWEnweWw.mjs").then((m) => /* @__PURE__ */ __toESM(m.default, 1));
|
|
30883
30889
|
const typedDataHash = _TypedDataEncoder.hash(domain, typesWithoutDomain, message);
|
|
30884
30890
|
return await signMessage({
|
|
30885
30891
|
hash: typedDataHash,
|
|
@@ -32571,15 +32577,15 @@ function isInsecureBrowserContext() {
|
|
|
32571
32577
|
const OidcTokenBody = Schema.NullOr(Schema.Struct({ token: Schema.NullOr(Schema.String) }));
|
|
32572
32578
|
const BetterAuthSessionBody = Schema.NullOr(Schema.Struct({ session: Schema.NullOr(Schema.Struct({ token: Schema.String })) }));
|
|
32573
32579
|
const EncryptionSessionBody = Schema.Struct({ sessionId: Schema.String });
|
|
32574
|
-
const MISSING
|
|
32575
|
-
const WRONG_TYPE
|
|
32580
|
+
const MISSING = "missing";
|
|
32581
|
+
const WRONG_TYPE = "not the expected type";
|
|
32576
32582
|
/**
|
|
32577
32583
|
* The Schema issues of a reply, each with a fixed reason. The Schema's own
|
|
32578
32584
|
* message can quote the reply, and the reply can hold a credential.
|
|
32579
32585
|
*/
|
|
32580
32586
|
const replyIssues = SchemaIssue.makeFormatterStandardSchemaV1({
|
|
32581
|
-
leafHook: (issue) => issue._tag === "MissingKey" ? MISSING
|
|
32582
|
-
checkHook: () => WRONG_TYPE
|
|
32587
|
+
leafHook: (issue) => issue._tag === "MissingKey" ? MISSING : WRONG_TYPE,
|
|
32588
|
+
checkHook: () => WRONG_TYPE
|
|
32583
32589
|
});
|
|
32584
32590
|
/**
|
|
32585
32591
|
* A reply that fails its Schema, named by the path of the first field that
|
|
@@ -32588,12 +32594,12 @@ const replyIssues = SchemaIssue.makeFormatterStandardSchemaV1({
|
|
|
32588
32594
|
function unusableReply(operation, issue, httpStatus) {
|
|
32589
32595
|
const first = replyIssues(issue).issues[0];
|
|
32590
32596
|
const path = first?.path?.map((segment) => String(typeof segment === "object" ? segment.key : segment)) ?? [];
|
|
32591
|
-
const missing = first?.message === MISSING
|
|
32597
|
+
const missing = first?.message === MISSING;
|
|
32592
32598
|
return openfortAnswerInvalid({
|
|
32593
32599
|
operation,
|
|
32594
32600
|
field: path.length === 0 ? "body" : path.join("."),
|
|
32595
32601
|
problem: missing ? "missing" : "invalid",
|
|
32596
|
-
reason: missing ? MISSING
|
|
32602
|
+
reason: missing ? MISSING : WRONG_TYPE,
|
|
32597
32603
|
httpStatus
|
|
32598
32604
|
});
|
|
32599
32605
|
}
|
|
@@ -33400,300 +33406,120 @@ function withDevTools(layer, url) {
|
|
|
33400
33406
|
}));
|
|
33401
33407
|
}
|
|
33402
33408
|
//#endregion
|
|
33403
|
-
//#region ../../packages/
|
|
33404
|
-
|
|
33405
|
-
|
|
33406
|
-
|
|
33407
|
-
|
|
33408
|
-
|
|
33409
|
-
|
|
33410
|
-
|
|
33411
|
-
|
|
33412
|
-
|
|
33413
|
-
|
|
33414
|
-
|
|
33415
|
-
|
|
33416
|
-
|
|
33417
|
-
|
|
33418
|
-
|
|
33419
|
-
|
|
33420
|
-
|
|
33421
|
-
|
|
33422
|
-
|
|
33423
|
-
|
|
33424
|
-
|
|
33425
|
-
*/
|
|
33426
|
-
|
|
33427
|
-
|
|
33428
|
-
|
|
33429
|
-
|
|
33430
|
-
|
|
33431
|
-
|
|
33432
|
-
|
|
33433
|
-
|
|
33434
|
-
|
|
33435
|
-
|
|
33436
|
-
|
|
33437
|
-
applicationId: decodedState.applicationId,
|
|
33438
|
-
chainId: decodedState.chainId,
|
|
33439
|
-
sessionToken: decodedState.sessionToken,
|
|
33440
|
-
issuedAt: decodedState.issuedAt,
|
|
33441
|
-
expiresIn: decodedState.expiresIn,
|
|
33442
|
-
authBaseUrl: normalizeRuntimeUrl("authBaseUrl", decodedState.authBaseUrl),
|
|
33443
|
-
convexUrl: normalizeRuntimeUrl("convexUrl", decodedState.convexUrl),
|
|
33444
|
-
siteBaseUrl: normalizeRuntimeUrl("siteBaseUrl", decodedState.siteBaseUrl),
|
|
33445
|
-
openfortPublishableKey: decodedState.openfortPublishableKey,
|
|
33446
|
-
shieldPublishableKey: decodedState.shieldPublishableKey,
|
|
33447
|
-
...decodedState.openfortAuthProvider === void 0 ? {} : { openfortAuthProvider: decodedState.openfortAuthProvider },
|
|
33448
|
-
...decodedState.indexerUrl === void 0 ? {} : { indexerUrl: decodedState.indexerUrl },
|
|
33449
|
-
...engineeringTelemetryOf(decodedEngineeringTelemetry)
|
|
33450
|
-
};
|
|
33451
|
-
}
|
|
33452
|
-
const MISSING = "missing";
|
|
33453
|
-
const WRONG_TYPE = "not the expected type";
|
|
33454
|
-
/**
|
|
33455
|
-
* The envelope's Schema issues, each with a fixed reason. The Schema's own
|
|
33456
|
-
* message can quote the body, and the body holds the session token.
|
|
33457
|
-
*/
|
|
33458
|
-
const envelopeIssues = SchemaIssue.makeFormatterStandardSchemaV1({
|
|
33459
|
-
leafHook: (issue) => issue._tag === "MissingKey" ? MISSING : WRONG_TYPE,
|
|
33460
|
-
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
|
|
33461
33443
|
});
|
|
33462
|
-
/**
|
|
33463
|
-
|
|
33464
|
-
|
|
33465
|
-
|
|
33466
|
-
|
|
33467
|
-
const first = envelopeIssues(issue).issues[0];
|
|
33468
|
-
const path = first?.path?.map((segment) => String(typeof segment === "object" ? segment.key : segment)) ?? [];
|
|
33469
|
-
const missing = first?.message === MISSING;
|
|
33470
|
-
return unusableAnswer(path.length === 0 ? "body" : path.join("."), missing ? "missing" : "invalid", missing ? MISSING : WRONG_TYPE);
|
|
33471
|
-
}
|
|
33472
|
-
/**
|
|
33473
|
-
* The bootstrap answered, and Capxul cannot use `field` of its answer. `cause`
|
|
33474
|
-
* is what refused the field, when it holds none of the body.
|
|
33475
|
-
*/
|
|
33476
|
-
function unusableAnswer(field, problem, reason, cause) {
|
|
33477
|
-
return Errors.providerResponseInvalid({
|
|
33478
|
-
provider: "convex",
|
|
33479
|
-
operation: "bootstrap",
|
|
33480
|
-
field,
|
|
33481
|
-
problem,
|
|
33482
|
-
reason,
|
|
33483
|
-
...cause === void 0 ? {} : { cause }
|
|
33484
|
-
});
|
|
33485
|
-
}
|
|
33486
|
-
/** The bootstrap state without the policy, which decodes separately. */
|
|
33487
|
-
function withoutPolicy(state) {
|
|
33488
|
-
const { engineeringTelemetry: _policy, ...rest } = state;
|
|
33489
|
-
return rest;
|
|
33490
|
-
}
|
|
33491
|
-
/**
|
|
33492
|
-
* The engineering telemetry policy the backend sent. One it does not admit
|
|
33493
|
-
* leaves SDK telemetry off, and says so once with the decode issue.
|
|
33494
|
-
*/
|
|
33495
|
-
function engineeringTelemetryOf(decoded) {
|
|
33496
|
-
if (decoded === void 0) return {};
|
|
33497
|
-
if (Result.isSuccess(decoded)) return { engineeringTelemetry: decoded.success };
|
|
33498
|
-
console.warn("[capxul-sdk] engineering telemetry policy refused; SDK telemetry is off", { issue: SchemaIssue.makeFormatterDefault()(decoded.failure) });
|
|
33499
|
-
return {};
|
|
33500
|
-
}
|
|
33501
|
-
function normalizeRuntimeUrl(field, raw) {
|
|
33502
|
-
let parsed;
|
|
33503
|
-
try {
|
|
33504
|
-
parsed = new URL(raw);
|
|
33505
|
-
} catch (cause) {
|
|
33506
|
-
throw unusableAnswer(`state.${field}`, "invalid", "must be an http or https URL", cause);
|
|
33507
|
-
}
|
|
33508
|
-
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") throw unusableAnswer(`state.${field}`, "invalid", "must be an http or https URL");
|
|
33509
|
-
return parsed.toString().replace(/\/$/, "");
|
|
33510
|
-
}
|
|
33511
|
-
//#endregion
|
|
33512
|
-
//#region ../../packages/sdk/src/applications/bootstrap-adapter.ts
|
|
33513
|
-
/** A cached envelope this close to its expiry is fetched again, so it cannot lapse mid-command. */
|
|
33514
|
-
const CACHE_EXPIRY_MARGIN_MS = 3e4;
|
|
33515
|
-
/**
|
|
33516
|
-
* The cached envelope, when it is still inside its own lifetime. It is decoded
|
|
33517
|
-
* as a fresh body is; anything that does not decode, or a store that fails,
|
|
33518
|
-
* is a miss.
|
|
33519
|
-
*/
|
|
33520
|
-
async function cachedEnvelope(cache, now) {
|
|
33521
|
-
try {
|
|
33522
|
-
const cached = decodeBootstrapBody(await cache.load());
|
|
33523
|
-
const expiresAt = cached.issuedAt + cached.expiresIn - CACHE_EXPIRY_MARGIN_MS;
|
|
33524
|
-
return cached.issuedAt <= now && now < expiresAt ? cached : null;
|
|
33525
|
-
} catch {
|
|
33526
|
-
return null;
|
|
33527
|
-
}
|
|
33528
|
-
}
|
|
33529
|
-
const DEFAULT_RETRY = {
|
|
33530
|
-
attempts: 2,
|
|
33531
|
-
baseDelayMs: 400
|
|
33532
|
-
};
|
|
33533
|
-
/** Request-side statuses a proxy or backend returns while momentarily unable to serve. */
|
|
33534
|
-
const TRANSIENT_HTTP_STATUSES = /* @__PURE__ */ new Set([
|
|
33535
|
-
408,
|
|
33536
|
-
425,
|
|
33537
|
-
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"
|
|
33538
33449
|
]);
|
|
33539
|
-
|
|
33540
|
-
|
|
33541
|
-
|
|
33542
|
-
}
|
|
33543
|
-
|
|
33544
|
-
|
|
33545
|
-
|
|
33546
|
-
|
|
33547
|
-
|
|
33548
|
-
|
|
33549
|
-
|
|
33550
|
-
|
|
33551
|
-
|
|
33552
|
-
|
|
33553
|
-
|
|
33554
|
-
|
|
33555
|
-
|
|
33556
|
-
|
|
33557
|
-
|
|
33558
|
-
|
|
33559
|
-
|
|
33560
|
-
|
|
33561
|
-
|
|
33562
|
-
}
|
|
33563
|
-
|
|
33564
|
-
|
|
33565
|
-
|
|
33566
|
-
|
|
33567
|
-
|
|
33568
|
-
|
|
33569
|
-
|
|
33570
|
-
|
|
33571
|
-
|
|
33572
|
-
|
|
33573
|
-
|
|
33574
|
-
|
|
33575
|
-
|
|
33576
|
-
|
|
33577
|
-
|
|
33578
|
-
|
|
33579
|
-
|
|
33580
|
-
|
|
33581
|
-
while: isTransientBootstrapFailure,
|
|
33582
|
-
schedule: Schedule.exponential(Duration.millis(this.retry.baseDelayMs))
|
|
33583
|
-
}));
|
|
33584
|
-
const cache = this.cache;
|
|
33585
|
-
if (cache === void 0) return fetched;
|
|
33586
|
-
return Effect.promise(() => cachedEnvelope(cache, Date.now())).pipe(Effect.filterOrElse((cached) => cached !== null, () => fetched));
|
|
33587
|
-
}
|
|
33588
|
-
attempt(input) {
|
|
33589
|
-
return Effect.tryPromise({
|
|
33590
|
-
try: () => {
|
|
33591
|
-
const headers = {
|
|
33592
|
-
"content-type": "application/json",
|
|
33593
|
-
...input.origin === void 0 ? {} : { origin: input.origin },
|
|
33594
|
-
...observationRequestHeaders(this.observation)
|
|
33595
|
-
};
|
|
33596
|
-
return this.fetchImpl(`${this.bootstrapBaseUrl}/v1/client/bootstrap`, {
|
|
33597
|
-
method: "POST",
|
|
33598
|
-
headers,
|
|
33599
|
-
body: JSON.stringify({ publishableKey: input.publishableKey })
|
|
33600
|
-
});
|
|
33601
|
-
},
|
|
33602
|
-
catch: (cause) => bootstrapErrorFromCapxul("network", Errors.networkError("bootstrap", cause, {
|
|
33603
|
-
provider: "bootstrap",
|
|
33604
|
-
failure_mode: "upstream-down",
|
|
33605
|
-
...this.bootstrapHost === void 0 ? {} : { target_host: this.bootstrapHost }
|
|
33606
|
-
}))
|
|
33607
|
-
}).pipe(Effect.flatMap((res) => this.mapResponse(res, input)));
|
|
33608
|
-
}
|
|
33609
|
-
mapResponse(res, input) {
|
|
33610
|
-
if (res.ok) return Effect.tryPromise({
|
|
33611
|
-
try: async () => {
|
|
33612
|
-
const body = await res.json();
|
|
33613
|
-
const resolution = decodeBootstrapBody(body);
|
|
33614
|
-
const cache = this.cache;
|
|
33615
|
-
if (cache !== void 0) await Promise.resolve().then(() => cache.save(body)).catch(() => void 0);
|
|
33616
|
-
return resolution;
|
|
33617
|
-
},
|
|
33618
|
-
catch: (cause) => {
|
|
33619
|
-
if (cause instanceof CapxulError && cause.code === "PROVIDER_RESPONSE_INVALID") return bootstrapErrorFromCapxul("malformedBody", cause);
|
|
33620
|
-
return bootstrapErrorFromCapxul("malformedBody", Errors.providerResponseInvalid({
|
|
33621
|
-
provider: "convex",
|
|
33622
|
-
operation: "bootstrap",
|
|
33623
|
-
field: "body",
|
|
33624
|
-
problem: "invalid",
|
|
33625
|
-
cause
|
|
33626
|
-
}));
|
|
33627
|
-
}
|
|
33628
|
-
});
|
|
33629
|
-
return Effect.promise(() => safeText(res)).pipe(Effect.flatMap((body) => {
|
|
33630
|
-
const refused = backendFailure(body);
|
|
33631
|
-
if (refused !== null) return Effect.fail(bootstrapErrorFromCapxul(bootstrapKind(refused.code), refused));
|
|
33632
|
-
const responseBody = maskedResponseBody(body);
|
|
33633
|
-
const edgeError = res.headers?.get?.("x-vercel-error") ?? void 0;
|
|
33634
|
-
const edgeRequestId = res.headers?.get?.("x-vercel-id") ?? void 0;
|
|
33635
|
-
const evidence = {
|
|
33636
|
-
...responseBody.length === 0 ? {} : { responseBody },
|
|
33637
|
-
...edgeError === void 0 ? {} : { edgeError },
|
|
33638
|
-
...edgeRequestId === void 0 ? {} : { edgeRequestId }
|
|
33639
|
-
};
|
|
33640
|
-
if (res.status === 401) return Effect.fail(bootstrapErrorFromCapxul("notAuthenticated", keyRefused(input, evidence)));
|
|
33641
|
-
return Effect.fail(bootstrapErrorFromCapxul("provider", providerStatusFailure({
|
|
33642
|
-
provider: "convex",
|
|
33643
|
-
operation: "bootstrap",
|
|
33644
|
-
httpStatus: res.status,
|
|
33645
|
-
details: evidence
|
|
33646
|
-
})));
|
|
33647
|
-
}));
|
|
33648
|
-
}
|
|
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
|
+
})
|
|
33649
33492
|
};
|
|
33650
|
-
|
|
33651
|
-
|
|
33652
|
-
*
|
|
33653
|
-
*
|
|
33654
|
-
|
|
33655
|
-
|
|
33656
|
-
|
|
33657
|
-
|
|
33658
|
-
|
|
33659
|
-
|
|
33660
|
-
|
|
33661
|
-
|
|
33662
|
-
|
|
33663
|
-
|
|
33664
|
-
|
|
33665
|
-
/**
|
|
33666
|
-
|
|
33667
|
-
|
|
33668
|
-
|
|
33669
|
-
|
|
33670
|
-
|
|
33671
|
-
|
|
33672
|
-
|
|
33673
|
-
|
|
33674
|
-
|
|
33675
|
-
|
|
33676
|
-
|
|
33677
|
-
|
|
33678
|
-
|
|
33679
|
-
|
|
33680
|
-
}
|
|
33681
|
-
function bootstrapKind(code) {
|
|
33682
|
-
if (code === "NOT_AUTHENTICATED") return "notAuthenticated";
|
|
33683
|
-
if (code === "INVALID_INPUT") return "invalidInput";
|
|
33684
|
-
if (code === "RATE_LIMITED") return "rateLimited";
|
|
33685
|
-
return "provider";
|
|
33686
|
-
}
|
|
33687
|
-
function HttpBootstrapLayer(deps) {
|
|
33688
|
-
return Layer.succeed(BootstrapPortTag, new HttpBootstrapAdapter(deps));
|
|
33689
|
-
}
|
|
33690
|
-
function hostOf(url) {
|
|
33691
|
-
try {
|
|
33692
|
-
return new URL(url).hostname;
|
|
33693
|
-
} catch {
|
|
33694
|
-
return;
|
|
33695
|
-
}
|
|
33696
|
-
}
|
|
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
|
+
}) };
|
|
33697
33523
|
//#endregion
|
|
33698
33524
|
//#region ../../packages/sdk/src/profiles/port.ts
|
|
33699
33525
|
/** The chain families a payout address may name (#1955). */
|
|
@@ -33737,6 +33563,7 @@ function brandProfile(view) {
|
|
|
33737
33563
|
return {
|
|
33738
33564
|
authUserId: toAuthUserId(view.authUserId),
|
|
33739
33565
|
...view.testerKind === void 0 ? {} : { testerKind: toTesterKind(view.testerKind) },
|
|
33566
|
+
...view.memberKind === void 0 ? {} : { memberKind: view.memberKind },
|
|
33740
33567
|
email: toEmail(view.email),
|
|
33741
33568
|
displayName: view.displayName,
|
|
33742
33569
|
country: view.country === null ? null : toCountryCode(view.country),
|
|
@@ -33874,6 +33701,17 @@ function makeIdentityMethods(deps) {
|
|
|
33874
33701
|
error: Errors.notImplemented("identity", "handleAvailable")
|
|
33875
33702
|
};
|
|
33876
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);
|
|
33877
33715
|
}
|
|
33878
33716
|
};
|
|
33879
33717
|
}
|
|
@@ -37957,6 +37795,243 @@ function makeConnectionId() {
|
|
|
37957
37795
|
}
|
|
37958
37796
|
}
|
|
37959
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
|
|
37960
38035
|
//#region ../../packages/sdk/src/platform/transport/convex-diagnostics.ts
|
|
37961
38036
|
const writeConvexDiagnostic = (...args) => {
|
|
37962
38037
|
try {
|
|
@@ -37977,7 +38052,6 @@ const silentConvexLogger = {
|
|
|
37977
38052
|
};
|
|
37978
38053
|
/** Exact floor-first allowlist; every additional handler must migrate its validator first. */
|
|
37979
38054
|
const OBSERVED_CONVEX_ACTIONS = new Set(OPERATIONS.filter((row) => row.kind === "action").map((row) => row.path));
|
|
37980
|
-
const OBSERVED_CONVEX_QUERIES = new Set(OPERATIONS.filter((row) => row.kind === "query").map((row) => row.path));
|
|
37981
38055
|
const OBSERVED_CONVEX_MUTATIONS = new Set(OPERATIONS.filter((row) => row.kind === "mutation").map((row) => row.path));
|
|
37982
38056
|
//#endregion
|
|
37983
38057
|
//#region ../../packages/sdk/src/platform/transport/observed-args.ts
|
|
@@ -38157,32 +38231,61 @@ var ConvexSocketAuth = class {
|
|
|
38157
38231
|
//#endregion
|
|
38158
38232
|
//#region ../../packages/sdk/src/platform/transport/convex-fresh-query.ts
|
|
38159
38233
|
/**
|
|
38160
|
-
* One query read past the client's cache, over HTTP with
|
|
38161
|
-
*
|
|
38162
|
-
*
|
|
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).
|
|
38163
38239
|
*/
|
|
38164
38240
|
function freshQuery(deps, fn, args, path) {
|
|
38165
38241
|
let tokenFailure;
|
|
38166
38242
|
return Effect.tryPromise({
|
|
38167
38243
|
try: async (signal) => {
|
|
38168
38244
|
const observed = args();
|
|
38169
|
-
const token = await deps.tokenProvider?.({ forceRefreshToken: false });
|
|
38170
|
-
if (signal.aborted) throw Errors.cancelled({ operation: path });
|
|
38171
|
-
const client = new ConvexHttpClient(deps.convexUrl, {
|
|
38172
|
-
logger: deps.logger,
|
|
38173
|
-
fetch: (input, init) => globalThis.fetch(input, {
|
|
38174
|
-
...init,
|
|
38175
|
-
signal
|
|
38176
|
-
})
|
|
38177
|
-
});
|
|
38178
|
-
if (token instanceof CapxulError) tokenFailure = token;
|
|
38179
|
-
else if (typeof token === "string") client.setAuth(token);
|
|
38180
38245
|
const query = fn;
|
|
38181
|
-
|
|
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
|
+
}
|
|
38182
38270
|
},
|
|
38183
38271
|
catch: withTokenFailure(timedFailure(path), () => tokenFailure)
|
|
38184
38272
|
});
|
|
38185
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
|
+
}
|
|
38186
38289
|
//#endregion
|
|
38187
38290
|
//#region ../../packages/sdk/src/platform/transport/convex-adapter.ts
|
|
38188
38291
|
/**
|
|
@@ -38203,10 +38306,12 @@ var ConvexCallAdapter = class {
|
|
|
38203
38306
|
#observation;
|
|
38204
38307
|
#connectionMonitor;
|
|
38205
38308
|
#closeTimeoutMs;
|
|
38309
|
+
#onWrite;
|
|
38206
38310
|
constructor(deps) {
|
|
38207
38311
|
this.#convexUrl = deps.convexUrl;
|
|
38208
38312
|
this.#logger = deps.localDiagnostics === true ? stderrConvexLogger : silentConvexLogger;
|
|
38209
38313
|
this.#closeTimeoutMs = deps.closeTimeoutMs ?? DEFAULT_CLOSE_TIMEOUT_MS;
|
|
38314
|
+
this.#onWrite = deps.onWrite ?? (() => void 0);
|
|
38210
38315
|
this.#connectionMonitor = new ConvexConnectionMonitor();
|
|
38211
38316
|
const webSocketConstructor = this.#connectionMonitor.observedWebSocketConstructor();
|
|
38212
38317
|
this.#client = deps.client ?? new ConvexClient(deps.convexUrl, {
|
|
@@ -38227,17 +38332,16 @@ var ConvexCallAdapter = class {
|
|
|
38227
38332
|
}
|
|
38228
38333
|
query(fn, args, options) {
|
|
38229
38334
|
const path = getFunctionName(fn);
|
|
38230
|
-
|
|
38231
|
-
|
|
38232
|
-
|
|
38233
|
-
|
|
38234
|
-
|
|
38235
|
-
|
|
38236
|
-
|
|
38237
|
-
|
|
38238
|
-
|
|
38239
|
-
|
|
38240
|
-
});
|
|
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())
|
|
38241
38345
|
}), () => connectionState(this.#client));
|
|
38242
38346
|
}
|
|
38243
38347
|
mutation(fn, args) {
|
|
@@ -38246,7 +38350,7 @@ var ConvexCallAdapter = class {
|
|
|
38246
38350
|
return Effect.tryPromise({
|
|
38247
38351
|
try: () => this.#client.mutation(fn, this.#observedArgs(OBSERVED_CONVEX_MUTATIONS, path, args, traceparent)),
|
|
38248
38352
|
catch: withTokenFailure(timedFailure(path), () => this.#socketAuth?.signedOutBecause())
|
|
38249
|
-
});
|
|
38353
|
+
}).pipe(Effect.tap(() => Effect.sync(this.#onWrite)));
|
|
38250
38354
|
});
|
|
38251
38355
|
}
|
|
38252
38356
|
action(fn, args, options) {
|
|
@@ -38258,7 +38362,7 @@ var ConvexCallAdapter = class {
|
|
|
38258
38362
|
catch: withTokenFailure(timedFailure(path, () => this.#connectionMonitor.reconnectEvidence(connectionAtStart, connectionState(this.#client))), () => this.#socketAuth?.signedOutBecause())
|
|
38259
38363
|
}).pipe(Effect.tapError((error) => logActionTransportFailure(path, error)));
|
|
38260
38364
|
});
|
|
38261
|
-
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)));
|
|
38262
38366
|
}
|
|
38263
38367
|
#observedArgs(allowlist, path, args, traceparent) {
|
|
38264
38368
|
return observedConvexArgs({
|
|
@@ -38558,6 +38662,18 @@ function hostEngineeringPolicy(observability) {
|
|
|
38558
38662
|
...policy?.engineeringPrivacy === void 0 ? {} : { privacy: policy.engineeringPrivacy }
|
|
38559
38663
|
};
|
|
38560
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";
|
|
38561
38677
|
function derivedBrowserOrigin(runtime) {
|
|
38562
38678
|
if (runtime !== "browser") throw Errors.invalidInput("origin", "required outside browser runtime");
|
|
38563
38679
|
const origin = readField(readField(globalThis, "location"), "origin");
|
|
@@ -38618,8 +38734,8 @@ function normalizeHttpUrl(field, raw) {
|
|
|
38618
38734
|
function productionBootstrapPortLayer(bootstrap) {
|
|
38619
38735
|
return Layer.succeed(BootstrapPortTag, bootstrap);
|
|
38620
38736
|
}
|
|
38621
|
-
function productionAuthClientLayer(input, refreshConvexAuthRef, resetSignerSessionRef) {
|
|
38622
|
-
|
|
38737
|
+
function productionAuthClientLayer(input, refreshConvexAuthRef, resetSignerSessionRef, dropConvexJwtRef) {
|
|
38738
|
+
const baseLayer = input.authClient !== void 0 ? Layer.succeed(AuthClientPortTag, input.authClient) : input.runtime === "browser" ? BetterAuthBrowserLayer({
|
|
38623
38739
|
authBaseUrl: input.runtimeUrls.authBaseUrl,
|
|
38624
38740
|
...input.fetch === void 0 ? {} : { fetch: input.fetch },
|
|
38625
38741
|
...input.observation === void 0 ? {} : { observation: input.observation }
|
|
@@ -38629,8 +38745,13 @@ function productionAuthClientLayer(input, refreshConvexAuthRef, resetSignerSessi
|
|
|
38629
38745
|
...input.origin === void 0 ? {} : { origin: input.origin },
|
|
38630
38746
|
...input.fetch === void 0 ? {} : { fetch: input.fetch },
|
|
38631
38747
|
...input.observation === void 0 ? {} : { observation: input.observation }
|
|
38632
|
-
})
|
|
38633
|
-
|
|
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, () => {
|
|
38634
38755
|
const refresh = refreshConvexAuthRef.current;
|
|
38635
38756
|
if (refresh === null) {
|
|
38636
38757
|
refreshConvexAuthRef.pending = true;
|
|
@@ -38638,19 +38759,26 @@ function productionAuthClientLayer(input, refreshConvexAuthRef, resetSignerSessi
|
|
|
38638
38759
|
}
|
|
38639
38760
|
refresh();
|
|
38640
38761
|
});
|
|
38641
|
-
|
|
38642
|
-
|
|
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))))));
|
|
38643
38770
|
}
|
|
38644
38771
|
function productionAuthCacheLayer(input) {
|
|
38645
38772
|
return Layer.succeed(AuthCachePortTag, input.authCache ?? detectAuthCacheAdapter());
|
|
38646
38773
|
}
|
|
38647
|
-
function productionConvexCallLayer(input, refreshConvexAuthRef) {
|
|
38774
|
+
function productionConvexCallLayer(input, refreshConvexAuthRef, dropConvexJwtRef) {
|
|
38648
38775
|
return Layer.unwrap(Effect.map(AuthClientPortTag, (authClient) => ConvexCallLayer({
|
|
38649
38776
|
convexUrl: input.runtimeUrls.convexUrl,
|
|
38650
38777
|
localDiagnostics: input.localDiagnostics,
|
|
38651
38778
|
...input.applicationId === void 0 ? {} : { applicationId: input.applicationId },
|
|
38652
38779
|
...input.observation === void 0 ? {} : { observation: input.observation },
|
|
38653
38780
|
...input.convexClient === void 0 ? {} : { client: input.convexClient },
|
|
38781
|
+
onWrite: () => dropConvexJwtRef.current?.(),
|
|
38654
38782
|
tokenProvider: async ({ forceRefreshToken }) => {
|
|
38655
38783
|
const tokenResult = await Effect.runPromise(Effect.result(authClient.getConvexJwt({
|
|
38656
38784
|
forceRefresh: forceRefreshToken,
|
|
@@ -38763,8 +38891,9 @@ function makeProductionAdapterLayer(input) {
|
|
|
38763
38891
|
current: null,
|
|
38764
38892
|
pending: false
|
|
38765
38893
|
};
|
|
38766
|
-
const
|
|
38767
|
-
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));
|
|
38768
38897
|
const telemetry = input.telemetry === void 0 ? PostHogTelemetryLayer({ capture: () => void 0 }) : Layer.succeed(TelemetryPortTag, input.telemetry);
|
|
38769
38898
|
const observedConvexCall = Layer.merge(convexCall, telemetry);
|
|
38770
38899
|
const org = Layer.effect(OrgPortTag, Effect.all([ConvexCallPortTag, TelemetryPortTag]).pipe(Effect.map(([convex, telemetryPort]) => new ConvexOrganizationAdapter({
|
|
@@ -38993,17 +39122,134 @@ function idempotentClose(close) {
|
|
|
38993
39122
|
await close();
|
|
38994
39123
|
};
|
|
38995
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
|
+
}
|
|
38996
39235
|
//#endregion
|
|
38997
39236
|
//#region ../../packages/sdk/src/platform/client/financial-ops.ts
|
|
38998
39237
|
function makeFinancialOpsMethods(deps) {
|
|
39238
|
+
const agreements = makePayeeAgreementMethods(deps);
|
|
38999
39239
|
return {
|
|
39000
|
-
me:
|
|
39240
|
+
me: {
|
|
39241
|
+
...makeMeMethods(deps),
|
|
39242
|
+
agreements,
|
|
39243
|
+
shares: makeMeShareMethods(deps),
|
|
39244
|
+
votes: makeMyVoteMethods(deps)
|
|
39245
|
+
},
|
|
39001
39246
|
targets: makeTargetsMethods(deps),
|
|
39002
39247
|
destinations: makeDestinationsMethods(deps),
|
|
39003
39248
|
payments: makePaymentsMethods(deps),
|
|
39004
39249
|
approvals: makeApprovalsMethods(deps),
|
|
39005
39250
|
activity: makeActivityMethods(deps),
|
|
39006
|
-
paymentDocuments: makePaymentDocumentsMethods(deps)
|
|
39251
|
+
paymentDocuments: makePaymentDocumentsMethods(deps),
|
|
39252
|
+
agreements
|
|
39007
39253
|
};
|
|
39008
39254
|
}
|
|
39009
39255
|
//#endregion
|
|
@@ -39091,10 +39337,16 @@ function makeMediaMethods(deps) {
|
|
|
39091
39337
|
//#endregion
|
|
39092
39338
|
//#region ../../packages/sdk/src/operator/diagnostics.ts
|
|
39093
39339
|
function makeSystemMethods(deps) {
|
|
39094
|
-
return {
|
|
39095
|
-
|
|
39096
|
-
|
|
39097
|
-
|
|
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
|
+
};
|
|
39098
39350
|
}
|
|
39099
39351
|
//#endregion
|
|
39100
39352
|
//#region ../../packages/sdk/src/platform/client/host-observation.ts
|
|
@@ -39351,6 +39603,8 @@ function bootClientActor(input, effectRunner, observation) {
|
|
|
39351
39603
|
const actor = withHostObservation(effectRunner.runSync(Scope.provide(bootIdentityFlow({
|
|
39352
39604
|
ports: input.ports,
|
|
39353
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 },
|
|
39354
39608
|
requirement: input.requirement,
|
|
39355
39609
|
...input.signer === void 0 ? {} : { signer: input.signer },
|
|
39356
39610
|
...input.organizationSetup === void 0 ? {} : { organizationSetup: input.organizationSetup },
|
|
@@ -39424,6 +39678,14 @@ function makeClientInternals(input, shared) {
|
|
|
39424
39678
|
identity: shared.identity,
|
|
39425
39679
|
bootstrap: input.bootstrap,
|
|
39426
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
|
+
}),
|
|
39427
39689
|
...input.ports.indexerRead === void 0 ? {} : { indexer: input.ports.indexerRead },
|
|
39428
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) },
|
|
39429
39691
|
telemetry: input.ports.telemetry,
|
|
@@ -39462,7 +39724,10 @@ const makeClientScopes = (input, runPromise, invocationControls) => {
|
|
|
39462
39724
|
return {
|
|
39463
39725
|
personal: {
|
|
39464
39726
|
banking: makeBankingMethods(shared),
|
|
39465
|
-
verification: makeVerificationMethods(verification)
|
|
39727
|
+
verification: makeVerificationMethods(verification),
|
|
39728
|
+
features: makeFeatureMethods(shared),
|
|
39729
|
+
waitlist: makeWaitlistMethods(shared),
|
|
39730
|
+
referral: makeReferralMethods(shared)
|
|
39466
39731
|
},
|
|
39467
39732
|
organization: {
|
|
39468
39733
|
banking: (orgId) => makeBankingMethods(shared, {
|
|
@@ -39515,9 +39780,8 @@ function assembleCapxulClient(input) {
|
|
|
39515
39780
|
invocationControls,
|
|
39516
39781
|
...input.signer === void 0 ? {} : { signer: input.signer }
|
|
39517
39782
|
};
|
|
39518
|
-
const
|
|
39519
|
-
kickProvisioning =
|
|
39520
|
-
const account = accountBundle.methods;
|
|
39783
|
+
const { methods: account, kickProvisioning: kickAccount } = makeAccountMethods(accountInput);
|
|
39784
|
+
kickProvisioning = kickAccount;
|
|
39521
39785
|
const authMethodsInput = {
|
|
39522
39786
|
actor,
|
|
39523
39787
|
authClient: input.ports.authClient,
|
|
@@ -39537,7 +39801,7 @@ function assembleCapxulClient(input) {
|
|
|
39537
39801
|
const auth = {
|
|
39538
39802
|
...authCore,
|
|
39539
39803
|
clientRequests: makeClientRequestMethods({
|
|
39540
|
-
authBaseUrl: input.bootstrap.authBaseUrl,
|
|
39804
|
+
authBaseUrl: input.authBaseUrl ?? input.bootstrap.authBaseUrl,
|
|
39541
39805
|
signIn: authCore.signIn,
|
|
39542
39806
|
verifyOtp: authCore.verifyOtp
|
|
39543
39807
|
})
|
|
@@ -39561,7 +39825,7 @@ function assembleCapxulClient(input) {
|
|
|
39561
39825
|
authLifetime: actor.authLifetime,
|
|
39562
39826
|
matchesAuthLifetime: actor.matchesAuthLifetime,
|
|
39563
39827
|
restoreSession: (...args) => auth.getSession(...args),
|
|
39564
|
-
refreshIdentity: (options) => runCapxulEffect(
|
|
39828
|
+
refreshIdentity: (options) => runCapxulEffect(readSession(actor, options ?? {}).pipe(Effect.asVoid), options, CAPXUL_OPERATIONS.identity.readSession, effectRunner.runPromise),
|
|
39565
39829
|
handleAvailable: (...args) => identity.handleAvailable(...args),
|
|
39566
39830
|
completeProfile: (...args) => identity.completeProfile(...args),
|
|
39567
39831
|
loadProfile: (...args) => identity.loadCurrent(...args),
|
|
@@ -39618,6 +39882,7 @@ function assembleCapxulClient(input) {
|
|
|
39618
39882
|
});
|
|
39619
39883
|
const identityRuntime = makeIdentityRuntime(actor, input.ports.identity, effectRunner.runPromise);
|
|
39620
39884
|
const client = {
|
|
39885
|
+
environment: input.environment ?? clientEnvironment("custom", input.bootstrap.chainId),
|
|
39621
39886
|
...scopes.personal,
|
|
39622
39887
|
checkouts: makeCheckoutMethods({
|
|
39623
39888
|
convexCall: input.ports.convexCall,
|
|
@@ -39644,7 +39909,7 @@ function assembleCapxulClient(input) {
|
|
|
39644
39909
|
holdings,
|
|
39645
39910
|
media,
|
|
39646
39911
|
orgs: orgMethods.orgs,
|
|
39647
|
-
org: (
|
|
39912
|
+
org: departmentPayingOrg(orgMethods, financialOps.approvals),
|
|
39648
39913
|
signer: input.signer?.statusStore ?? UNOBSERVABLE_SIGNER_STATUS,
|
|
39649
39914
|
_internal: makeClientInternals(input, {
|
|
39650
39915
|
identity: identityRuntime,
|
|
@@ -39745,9 +40010,12 @@ function signerSessionReset(signer) {
|
|
|
39745
40010
|
};
|
|
39746
40011
|
}
|
|
39747
40012
|
/** Shared production composition. The normal factory passes no controls. */
|
|
39748
|
-
async function createCapxulClientWithSignerControls(
|
|
39749
|
-
const invocationObservability = bindHostObservabilityInvocation(
|
|
39750
|
-
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;
|
|
39751
40019
|
const validation = validateCreateCapxulClientInput(input);
|
|
39752
40020
|
if (!validation.ok) return observeFailedResult(validation, observation, "createCapxulClient");
|
|
39753
40021
|
const resetSignerSession = { current: null };
|
|
@@ -39787,6 +40055,7 @@ async function createCapxulClientWithSignerControls(input, controls) {
|
|
|
39787
40055
|
runPromise: Effect.runPromiseWith(adapters.value.context)
|
|
39788
40056
|
};
|
|
39789
40057
|
const ownedClient = withAdapterClose(assembleCapxulClient({
|
|
40058
|
+
environment: clientEnvironment(selected.value.name, adapters.value.bootstrap.chainId),
|
|
39790
40059
|
ports: adapters.value.ports,
|
|
39791
40060
|
bootstrap: adapters.value.bootstrap,
|
|
39792
40061
|
authCache: adapters.value.ports.authCache,
|
|
@@ -39803,6 +40072,7 @@ async function createCapxulClientWithSignerControls(input, controls) {
|
|
|
39803
40072
|
...input.signal === void 0 ? {} : { signal: input.signal },
|
|
39804
40073
|
...input.otpTtlMs === void 0 ? {} : { otpTtlMs: input.otpTtlMs },
|
|
39805
40074
|
invokeTimeoutMs: input.invokeTimeoutMs ?? 3e4,
|
|
40075
|
+
authBaseUrl: resolvedAuthBaseUrl,
|
|
39806
40076
|
...input.observability?.failures === void 0 && input.observation === void 0 ? {} : { failureObservation: input.observability?.failures ?? input.observation },
|
|
39807
40077
|
...input.observability === void 0 ? {} : { hostObservationSnapshot: () => snapshotHostObservability(input.observability) },
|
|
39808
40078
|
effectRunner
|
|
@@ -41734,6 +42004,82 @@ async function createSdkClient(input, createClient = createCapxulClient) {
|
|
|
41734
42004
|
};
|
|
41735
42005
|
}
|
|
41736
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
|
|
41737
42083
|
//#region src/main.ts
|
|
41738
42084
|
const cli = parseCliArgs(process.argv.slice(2));
|
|
41739
42085
|
if (cli.kind === "help") {
|
|
@@ -41782,7 +42128,7 @@ const deps = {
|
|
|
41782
42128
|
};
|
|
41783
42129
|
if (cli.stdio) {
|
|
41784
42130
|
const identity = stdioIdentity();
|
|
41785
|
-
const
|
|
42131
|
+
const session = serveStdioSession(() => buildMcpServer(deps, identity));
|
|
41786
42132
|
console.error("capxul-mcp listening on stdio");
|
|
41787
42133
|
console.error(renderStartupBanner({
|
|
41788
42134
|
mode: cli.mode,
|
|
@@ -41790,11 +42136,15 @@ if (cli.stdio) {
|
|
|
41790
42136
|
backend: readBackendForBanner(),
|
|
41791
42137
|
bearer: identity === void 0 ? "none" : "environment"
|
|
41792
42138
|
}));
|
|
42139
|
+
let stopping = false;
|
|
41793
42140
|
const shutdownStdio = () => {
|
|
41794
|
-
|
|
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));
|
|
41795
42144
|
};
|
|
41796
42145
|
process.on("SIGINT", shutdownStdio);
|
|
41797
42146
|
process.on("SIGTERM", shutdownStdio);
|
|
42147
|
+
session.ended.then(shutdownStdio);
|
|
41798
42148
|
} else {
|
|
41799
42149
|
const running = await startHttpServer({
|
|
41800
42150
|
port,
|