@capxul/sdk 4.1.4 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{OAuthBearerAuthClient-BHvDR8_0.mjs → OAuthBearerAuthClient-ByPzJZr8.mjs} +1 -1
- package/dist/{clock-C2AUlq1V.mjs → clock-DIfTX44d.mjs} +265 -29
- package/dist/{create-capxul-client-B3ET402J.mjs → create-capxul-client-B6PUjdld.mjs} +69 -9
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +92 -28
- package/dist/node/index.mjs +2 -2
- package/dist/{observation-Bhdq9-l6.d.mts → observation-vegBPfXj.d.mts} +42 -2
- package/dist/testing/index.d.mts +1 -1
- package/dist/testing/index.mjs +2 -2
- package/package.json +5 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as toAuthUserId, B as toJwtToken, I as toEmail, J as toSessionToken, L as toEpochMs, R as toEpochSeconds, c as ClockError, l as ClockPortTag, t as readClockNow, tt as Errors, u as authClientPortFromPromiseAdapter } from "./clock-
|
|
1
|
+
import { A as toAuthUserId, B as toJwtToken, I as toEmail, J as toSessionToken, L as toEpochMs, R as toEpochSeconds, c as ClockError, l as ClockPortTag, t as readClockNow, tt as Errors, u as authClientPortFromPromiseAdapter } from "./clock-DIfTX44d.mjs";
|
|
2
2
|
import { Effect, Layer } from "effect";
|
|
3
3
|
//#region src/adapters/clock/SystemClockAdapter.ts
|
|
4
4
|
var SystemClockAdapter = class {
|
|
@@ -1,39 +1,275 @@
|
|
|
1
1
|
import { Context, Data, Effect, Layer, Result } from "effect";
|
|
2
2
|
import { concat, encodeAbiParameters, encodeFunctionData, encodePacked, getContractAddress, keccak256, padHex, stringToHex, toBytes, toEventSelector, toFunctionSelector, toFunctionSignature } from "viem";
|
|
3
3
|
//#region ../errors/src/secret-material.ts
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
const CREDENTIAL_FIELDS = /* @__PURE__ */ new Set([
|
|
5
|
+
"password",
|
|
6
|
+
"passwd",
|
|
7
|
+
"pwd",
|
|
8
|
+
"pass",
|
|
9
|
+
"passphrase",
|
|
10
|
+
"currentpassword",
|
|
11
|
+
"newpassword",
|
|
12
|
+
"confirmpassword",
|
|
13
|
+
"passwordconfirmation",
|
|
14
|
+
"passwordhash",
|
|
15
|
+
"hashedpassword",
|
|
16
|
+
"pin",
|
|
17
|
+
"privatekey",
|
|
18
|
+
"walletprivatekey",
|
|
19
|
+
"secretkey",
|
|
20
|
+
"signingkey",
|
|
21
|
+
"signingsecret",
|
|
22
|
+
"seed",
|
|
23
|
+
"seedphrase",
|
|
24
|
+
"mnemonic",
|
|
25
|
+
"recoveryphrase",
|
|
26
|
+
"recovery",
|
|
27
|
+
"recoverycode",
|
|
28
|
+
"recoverycodes",
|
|
29
|
+
"keyshare",
|
|
30
|
+
"signingmaterial",
|
|
31
|
+
"recoverymaterial",
|
|
32
|
+
"privatekeybytes",
|
|
33
|
+
"signingprivatekey",
|
|
34
|
+
"encryptionkey",
|
|
35
|
+
"decryptionkey",
|
|
36
|
+
"authtoken",
|
|
37
|
+
"apitoken",
|
|
38
|
+
"bearertoken",
|
|
39
|
+
"oauthtoken",
|
|
40
|
+
"csrftoken",
|
|
41
|
+
"clientassertion",
|
|
42
|
+
"token",
|
|
43
|
+
"accesstoken",
|
|
44
|
+
"refreshtoken",
|
|
45
|
+
"idtoken",
|
|
46
|
+
"sessiontoken",
|
|
47
|
+
"session",
|
|
48
|
+
"sessionkey",
|
|
49
|
+
"sessionsecret",
|
|
50
|
+
"authsessionid",
|
|
51
|
+
"sessioncredential",
|
|
52
|
+
"sessioncredentials",
|
|
53
|
+
"sessioncookie",
|
|
54
|
+
"auth",
|
|
55
|
+
"authentication",
|
|
56
|
+
"authorization",
|
|
57
|
+
"proxyauthorization",
|
|
58
|
+
"cookie",
|
|
59
|
+
"cookies",
|
|
60
|
+
"setcookie",
|
|
61
|
+
"apikey",
|
|
62
|
+
"xapikey",
|
|
63
|
+
"xauthtoken",
|
|
64
|
+
"clientsecret",
|
|
65
|
+
"secret",
|
|
66
|
+
"secrets",
|
|
67
|
+
"credential",
|
|
68
|
+
"credentials",
|
|
69
|
+
"signature",
|
|
70
|
+
"otp",
|
|
71
|
+
"otpcode",
|
|
72
|
+
"totpsecret",
|
|
73
|
+
"onetimecode",
|
|
74
|
+
"onetimepassword",
|
|
75
|
+
"verificationcode",
|
|
76
|
+
"authcode",
|
|
77
|
+
"authorizationcode",
|
|
78
|
+
"oauthcode",
|
|
79
|
+
"codeverifier"
|
|
80
|
+
]);
|
|
81
|
+
/** Match credential fields by meaning, without hiding token addresses or replay IDs. */
|
|
82
|
+
function isCredentialField(name, context) {
|
|
83
|
+
const normalized = name.toLowerCase().replace(/[^a-z0-9]/gu, "");
|
|
84
|
+
return CREDENTIAL_FIELDS.has(normalized) || /(?:password(?:hash)?|passwd|passphrase|privatekey|signingkey|apikey|clientsecret|accesstoken|refreshtoken|sessiontoken)$/u.test(normalized) || context === "authentication" && (normalized === "code" || normalized === "sessionid") || context === "header" && /(?:token|secret|apikey|privatekey|signingkey|password|authorization|cookie|session)$/u.test(normalized);
|
|
85
|
+
}
|
|
86
|
+
function decodeUrlComponent(text) {
|
|
87
|
+
try {
|
|
88
|
+
return decodeURIComponent(text);
|
|
89
|
+
} catch {
|
|
90
|
+
return text;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/** Preserve URL diagnostics while removing credentials from their declared components. */
|
|
94
|
+
function redactUrlSecrets(value, source) {
|
|
95
|
+
try {
|
|
96
|
+
const absolute = /^[a-z][a-z0-9+.-]*:/iu.test(value);
|
|
97
|
+
const protocolRelative = value.startsWith("//");
|
|
98
|
+
const url = new URL(value, "https://redaction.invalid");
|
|
99
|
+
if (url.protocol !== "https:" && url.protocol !== "http:") return maskText(value);
|
|
100
|
+
let changed = url.username.length > 0 || url.password.length > 0;
|
|
101
|
+
const maskParams = (params) => new URLSearchParams(Array.from(params, ([name, entry]) => {
|
|
102
|
+
const safeName = maskText(name);
|
|
103
|
+
const safeEntry = isCredentialField(name) || /^(?:code|draft|__posthog)$/iu.test(name) ? "[REDACTED]" : maskText(entry);
|
|
104
|
+
changed ||= safeName !== name || safeEntry !== entry;
|
|
105
|
+
return [safeName, safeEntry];
|
|
106
|
+
})).toString();
|
|
107
|
+
const provider = source !== void 0 || /(?:^|\.)(?:alchemy\.com|alchemyapi\.io|infura\.io)$/iu.test(url.hostname);
|
|
108
|
+
const segments = (absolute || protocolRelative ? url.pathname : value.split(/[?#]/u)[0] ?? "").split("/");
|
|
109
|
+
const path = segments.map((segment, index) => {
|
|
110
|
+
const decoded = decodeUrlComponent(segment);
|
|
111
|
+
const masked = provider && /^v[23]$/u.test(decodeUrlComponent(segments[index - 1] ?? "")) && decoded.length > 0 ? "[REDACTED]" : maskText(decoded);
|
|
112
|
+
changed ||= masked !== decoded;
|
|
113
|
+
return masked === decoded ? segment : encodeURIComponent(masked);
|
|
114
|
+
}).join("/");
|
|
115
|
+
const query = maskParams(url.searchParams);
|
|
116
|
+
const fragment = url.hash.slice(1);
|
|
117
|
+
const decodedFragment = decodeUrlComponent(fragment);
|
|
118
|
+
const maskedFragment = maskText(decodedFragment);
|
|
119
|
+
changed ||= maskedFragment !== decodedFragment;
|
|
120
|
+
const fragmentQuery = fragment.indexOf("?");
|
|
121
|
+
const fragmentPath = fragment.slice(0, fragmentQuery);
|
|
122
|
+
const maskedFragmentPath = maskText(decodeUrlComponent(fragmentPath));
|
|
123
|
+
changed ||= maskedFragmentPath !== decodeUrlComponent(fragmentPath);
|
|
124
|
+
const hash = fragmentQuery >= 0 ? `${maskedFragmentPath === decodeUrlComponent(fragmentPath) ? fragmentPath : encodeURIComponent(maskedFragmentPath)}?${maskParams(new URLSearchParams(fragment.slice(fragmentQuery + 1)))}` : fragment.includes("=") ? maskParams(new URLSearchParams(fragment)) : maskedFragment === decodedFragment ? fragment : encodeURIComponent(maskedFragment);
|
|
125
|
+
const origin = absolute ? url.origin : protocolRelative ? `//${url.host}` : "";
|
|
126
|
+
if (!changed) return value;
|
|
127
|
+
return `${origin}${path}${query ? `?${query}` : ""}${hash ? `#${hash}` : ""}`;
|
|
128
|
+
} catch {
|
|
129
|
+
return maskText(value.replace(/(https?:\/\/)[^/\s@]+@/giu, "$1[REDACTED]@").replace(/([?&#])([^=&#]+)=([^&#]*)/gu, (whole, separator, name) => isCredentialField(decodeUrlComponent(name)) || /^(?:code|draft|__posthog)$/iu.test(decodeUrlComponent(name)) ? `${separator}${name}=[REDACTED]` : whole));
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
const JSON_FIELD = /("(?:[^"\\]|\\.)*")(\s*:\s*)("(?:[^"\\]|\\.)*"|-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?|true|false|null)/gu;
|
|
133
|
+
const PROSE_FIELD = /(?=(\b([A-Za-z][A-Za-z0-9_-]*(?:[ \t]+[A-Za-z][A-Za-z0-9_-]*){0,3})\s*[:=]\s*((?:Bearer|Basic)[ \t]+[^\s,;"']+|"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|[^\s,;&"']+)))/gu;
|
|
134
|
+
const EMBEDDED_URL = /(https?:\/\/[^\s"<>]*)/giu;
|
|
135
|
+
function isSecretLabel(name) {
|
|
136
|
+
return isCredentialField(name) || /^request[ _-]?body$/iu.test(name);
|
|
137
|
+
}
|
|
138
|
+
const JSON_ENCODING_MAX = 8;
|
|
139
|
+
const JSON_NESTING_MAX = 64;
|
|
140
|
+
const JSON_KEY = /("(?:[^"\\]|\\.)*")\s*:/gu;
|
|
141
|
+
const JSON_CONTAINER_START = /(?:\{\s*["}]|\[\s*[[\]{}"0-9tfn-])/uy;
|
|
142
|
+
function hasSecretJsonKey(value) {
|
|
143
|
+
for (const match of value.matchAll(JSON_KEY)) try {
|
|
144
|
+
if (match[1] !== void 0 && isSecretLabel(JSON.parse(match[1]))) return true;
|
|
145
|
+
} catch {}
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
/** Project a complete fragment once. Never retry all of its nested substrings. */
|
|
149
|
+
function projectJsonFragment(value, encodingDepth, overDepth) {
|
|
150
|
+
if (overDepth || encodingDepth >= JSON_ENCODING_MAX) return "[REDACTED]";
|
|
151
|
+
let parsed;
|
|
152
|
+
try {
|
|
153
|
+
parsed = JSON.parse(value);
|
|
154
|
+
} catch {
|
|
155
|
+
return hasSecretJsonKey(value) ? "[REDACTED]" : value;
|
|
156
|
+
}
|
|
157
|
+
try {
|
|
158
|
+
let changed = false;
|
|
159
|
+
const masked = JSON.stringify(parsed, (name, nested) => {
|
|
160
|
+
if (isSecretLabel(name)) {
|
|
161
|
+
changed ||= nested !== "[REDACTED]";
|
|
162
|
+
return "[REDACTED]";
|
|
163
|
+
}
|
|
164
|
+
if (typeof nested === "string") {
|
|
165
|
+
const projected = maskJsonFragments(nested, encodingDepth + 1);
|
|
166
|
+
changed ||= projected !== nested;
|
|
167
|
+
return projected;
|
|
168
|
+
}
|
|
169
|
+
return nested;
|
|
170
|
+
});
|
|
171
|
+
return changed ? masked : value;
|
|
172
|
+
} catch {
|
|
173
|
+
return "[REDACTED]";
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
/** Scan balanced object/array fragments once, respecting JSON quotes and escapes. */
|
|
177
|
+
function maskJsonFragments(value, encodingDepth = 0) {
|
|
178
|
+
if (value.trimStart().startsWith("\"")) try {
|
|
179
|
+
const decoded = JSON.parse(value);
|
|
180
|
+
if (typeof decoded === "string") {
|
|
181
|
+
if (encodingDepth >= JSON_ENCODING_MAX) return "\"[REDACTED]\"";
|
|
182
|
+
const masked = maskJsonFragments(decoded, encodingDepth + 1);
|
|
183
|
+
return masked === decoded ? value : JSON.stringify(masked);
|
|
184
|
+
}
|
|
185
|
+
} catch {}
|
|
186
|
+
let output = "";
|
|
187
|
+
let cursor = 0;
|
|
188
|
+
let start = -1;
|
|
189
|
+
let depth = 0;
|
|
190
|
+
let overDepth = false;
|
|
191
|
+
let quoted = false;
|
|
192
|
+
let escaped = false;
|
|
193
|
+
for (let index = 0; index < value.length; index++) {
|
|
194
|
+
const character = value[index];
|
|
195
|
+
if (start < 0) {
|
|
196
|
+
JSON_CONTAINER_START.lastIndex = index;
|
|
197
|
+
if (!JSON_CONTAINER_START.test(value)) continue;
|
|
198
|
+
start = index;
|
|
199
|
+
depth = 1;
|
|
200
|
+
overDepth = false;
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
if (quoted) {
|
|
204
|
+
if (escaped) escaped = false;
|
|
205
|
+
else if (character === "\\") escaped = true;
|
|
206
|
+
else if (character === "\"") quoted = false;
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
if (character === "\"") quoted = true;
|
|
210
|
+
else if (character === "{" || character === "[") {
|
|
211
|
+
depth++;
|
|
212
|
+
overDepth ||= depth > JSON_NESTING_MAX;
|
|
213
|
+
} else if (character === "}" || character === "]") {
|
|
214
|
+
depth--;
|
|
215
|
+
if (depth !== 0) continue;
|
|
216
|
+
output += value.slice(cursor, start) + projectJsonFragment(value.slice(start, index + 1), encodingDepth, overDepth);
|
|
217
|
+
cursor = index + 1;
|
|
218
|
+
start = -1;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
if (start >= 0) {
|
|
222
|
+
const fragment = value.slice(start);
|
|
223
|
+
output += value.slice(cursor, start) + (overDepth || hasSecretJsonKey(fragment) ? "[REDACTED]" : fragment);
|
|
224
|
+
cursor = value.length;
|
|
225
|
+
}
|
|
226
|
+
return output + value.slice(cursor);
|
|
227
|
+
}
|
|
228
|
+
function maskLabelledText(value) {
|
|
229
|
+
const jsonMasked = maskJsonFragments(value).replace(JSON_FIELD, (whole, quotedName, separator) => {
|
|
230
|
+
try {
|
|
231
|
+
return isSecretLabel(JSON.parse(quotedName)) ? `${quotedName}${separator}"[REDACTED]"` : whole;
|
|
232
|
+
} catch {
|
|
233
|
+
return whole;
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
let output = "";
|
|
237
|
+
let cursor = 0;
|
|
238
|
+
for (const match of jsonMasked.matchAll(PROSE_FIELD)) {
|
|
239
|
+
const [, whole, label, entry] = match;
|
|
240
|
+
if (whole === void 0 || label === void 0 || entry === void 0 || match.index < cursor || /^Bearer[ \t]+/iu.test(entry)) continue;
|
|
241
|
+
const words = label.split(/[ \t]+/u);
|
|
242
|
+
for (let index = 0; index < words.length; index++) {
|
|
243
|
+
const name = words.slice(index).join(" ");
|
|
244
|
+
if (isSecretLabel(name)) {
|
|
245
|
+
const prefix = words.slice(0, index).join(" ");
|
|
246
|
+
output += jsonMasked.slice(cursor, match.index) + `${prefix ? `${prefix} ` : ""}${name}=[REDACTED]`;
|
|
247
|
+
cursor = match.index + whole.length;
|
|
248
|
+
break;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return output + jsonMasked.slice(cursor);
|
|
253
|
+
}
|
|
254
|
+
const TOKEN_MASKS = [
|
|
255
|
+
[/\bBearer\s+(?!(?:realm|error|error_description|scope|authorization_uri|resource|claims)\s*=)[^\s,;"']+/giu, "Bearer [REDACTED]"],
|
|
14
256
|
[/\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\b/gu, "[REDACTED]"],
|
|
15
257
|
[/(^|[^a-fA-F0-9])(?<!0[xX])[a-fA-F0-9]{64}(?=$|[^a-fA-F0-9])/gu, "$1[REDACTED]"],
|
|
16
|
-
[/(?:(?:sk|pk|rk)_(?:live|test)|(?:phc|phx|ghp|gho|ghu|ghs|ghr|whsec)_|github_pat_|xox[baprs]-|AKIA[0-9A-Z]{16}|AIza)[A-Za-z0-9_-]*/giu, "[REDACTED]"]
|
|
17
|
-
[/(https?:\/\/[^\s"']+?\/v[0-9]\/)[A-Za-z0-9_-]{16,}/giu, "$1[REDACTED]"],
|
|
18
|
-
[/\b(api[ _-]?key|access[ _-]?token|token|secret|password|passphrase|private[ _-]?key|authorization|cookie|signature|request[ _-]?body|credential|otp|one[ _-]?time[ _-]?(?:password|code)|verification[ _-]?code)\b\s*[:=]\s*(?:"[^"]*"|'[^']*'|[^\s,;&]+)/giu, "$1=[REDACTED]"]
|
|
258
|
+
[/(?:(?:sk|pk|rk)_(?:live|test)|(?:phc|phx|ghp|gho|ghu|ghs|ghr|whsec)_|github_pat_|xox[baprs]-|AKIA[0-9A-Z]{16}|AIza)[A-Za-z0-9_-]*/giu, "[REDACTED]"]
|
|
19
259
|
];
|
|
20
|
-
/**
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
260
|
+
/** URL components and malformed URLs use this non-recursive masking layer. */
|
|
261
|
+
function maskText(value) {
|
|
262
|
+
let text = maskLabelledText(value);
|
|
263
|
+
for (const [pattern, replacement] of TOKEN_MASKS) text = text.replace(pattern, replacement);
|
|
264
|
+
return text;
|
|
265
|
+
}
|
|
266
|
+
/** Reject only when the same semantic sanitizer removes credential material. */
|
|
25
267
|
function containsSensitiveMaterial(value) {
|
|
26
|
-
return
|
|
268
|
+
return redactSecrets(value) !== value;
|
|
27
269
|
}
|
|
28
|
-
/**
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
* lines, provider messages, PostHog rows) but must not carry live credentials.
|
|
32
|
-
*/
|
|
33
|
-
function redactSecrets(value) {
|
|
34
|
-
let text = value;
|
|
35
|
-
for (const [pattern, replacement] of MASKS) text = text.replace(pattern, replacement);
|
|
36
|
-
return text;
|
|
270
|
+
/** Mask credential fields and embedded URLs while preserving surrounding evidence. */
|
|
271
|
+
function redactSecrets(value, source) {
|
|
272
|
+
return maskLabelledText(value).split(EMBEDDED_URL).map((part, index) => index % 2 === 1 ? redactUrlSecrets(part, source).replaceAll("%5BREDACTED%5D", "[REDACTED]") : maskText(part)).join("");
|
|
37
273
|
}
|
|
38
274
|
//#endregion
|
|
39
275
|
//#region ../errors/src/chain-cause.ts
|
|
@@ -1890,4 +2126,4 @@ async function readClockNow(clock) {
|
|
|
1890
2126
|
}
|
|
1891
2127
|
}
|
|
1892
2128
|
//#endregion
|
|
1893
|
-
export { CapxulError as $, toAuthUserId as A, toJwtToken as B, WEI_RE as C, toAddress as D, toAccountId as E, toDurationMs as F, toPayrollRunId as G, toOrgId as H, toEmail as I, toSessionToken as J, toPublishableKey as K, toEpochMs as L, toChainId as M, toCountryCode as N, toAllowedOrigin as O, toCurrencyCode as P, CAPXUL_ERROR_CODES as Q, toEpochSeconds as R, SUPPORTED_CURRENCY_CODES as S, currencySymbolFor as T, toPartyId as U, toKycTier as V, toPayrollGroupId as W, HANDLE_RE as X, toTesterKind as Y, decodeConvexError as Z, deriveCapxulSafeAddress as _, parseCachedJwt as a, boundedResponseHeaders as at, BYTES32_RE as b, ClockError as c, decodeChainCause as ct, AuthClientError as d, isFailureMode as dt, EXPECTED_OPERATION_OUTCOMES as et, AuthClientPortTag as f, revertSummaryText as ft, BASE_SEPOLIA_CHAIN_ID as g, normalizeBindingEmail as h, parseAuthSession as i, FAILURE_MODES as it, toBudgetId as j, toAppId as k, ClockPortTag as l, failureFingerprint as lt, CAPXUL_PAYMENTS_V2_ADDRESS as m,
|
|
2129
|
+
export { CapxulError as $, toAuthUserId as A, toJwtToken as B, WEI_RE as C, toAddress as D, toAccountId as E, toDurationMs as F, toPayrollRunId as G, toOrgId as H, toEmail as I, toSessionToken as J, toPublishableKey as K, toEpochMs as L, toChainId as M, toCountryCode as N, toAllowedOrigin as O, toCurrencyCode as P, CAPXUL_ERROR_CODES as Q, toEpochSeconds as R, SUPPORTED_CURRENCY_CODES as S, currencySymbolFor as T, toPartyId as U, toKycTier as V, toPayrollGroupId as W, HANDLE_RE as X, toTesterKind as Y, decodeConvexError as Z, deriveCapxulSafeAddress as _, parseCachedJwt as a, boundedResponseHeaders as at, BYTES32_RE as b, ClockError as c, decodeChainCause as ct, AuthClientError as d, isFailureMode as dt, EXPECTED_OPERATION_OUTCOMES as et, AuthClientPortTag as f, revertSummaryText as ft, BASE_SEPOLIA_CHAIN_ID as g, redactUrlSecrets as gt, normalizeBindingEmail as h, redactSecrets as ht, parseAuthSession as i, FAILURE_MODES as it, toBudgetId as j, toAppId as k, ClockPortTag as l, failureFingerprint as lt, CAPXUL_PAYMENTS_V2_ADDRESS as m, isCredentialField as mt, InMemoryAuthCacheAdapter as n, isCapxulError as nt, AuthCacheError as o, chainCauseProperties as ot, orgRoleKeyForLabel as p, containsSensitiveMaterial as pt, toRoleKey as q, BrowserAuthCacheAdapter as r, CHAIN_UPSTREAMS as rt, AuthCachePortTag as s, chainEvidenceLabel as st, readClockNow as t, Errors as tt, authClientPortFromPromiseAdapter as u, isChainUpstream as ut, validateHandle as v, ZERO_BYTES32 as w, EVM_ADDRESS_RE as x, APP_ID_RE as y, toHandle as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as CapxulError, A as toAuthUserId, C as WEI_RE, D as toAddress, E as toAccountId, G as toPayrollRunId, H as toOrgId, I as toEmail, M as toChainId, N as toCountryCode, P as toCurrencyCode, Q as CAPXUL_ERROR_CODES, S as SUPPORTED_CURRENCY_CODES, U as toPartyId, W as toPayrollGroupId, _ as deriveCapxulSafeAddress, at as boundedResponseHeaders, b as BYTES32_RE, ct as decodeChainCause, dt as isFailureMode, et as EXPECTED_OPERATION_OUTCOMES, ft as revertSummaryText, it as FAILURE_MODES$1, j as toBudgetId, lt as failureFingerprint, mt as
|
|
1
|
+
import { $ as CapxulError, A as toAuthUserId, C as WEI_RE, D as toAddress, E as toAccountId, G as toPayrollRunId, H as toOrgId, I as toEmail, M as toChainId, N as toCountryCode, P as toCurrencyCode, Q as CAPXUL_ERROR_CODES, S as SUPPORTED_CURRENCY_CODES, U as toPartyId, W as toPayrollGroupId, _ as deriveCapxulSafeAddress, at as boundedResponseHeaders, b as BYTES32_RE, ct as decodeChainCause, dt as isFailureMode, et as EXPECTED_OPERATION_OUTCOMES, ft as revertSummaryText, ht as redactSecrets, it as FAILURE_MODES$1, j as toBudgetId, lt as failureFingerprint, mt as isCredentialField, n as InMemoryAuthCacheAdapter, nt as isCapxulError, ot as chainCauseProperties, p as orgRoleKeyForLabel, pt as containsSensitiveMaterial, q as toRoleKey, r as BrowserAuthCacheAdapter, rt as CHAIN_UPSTREAMS, st as chainEvidenceLabel, tt as Errors, ut as isChainUpstream, v as validateHandle, w as ZERO_BYTES32, x as EVM_ADDRESS_RE$1, y as APP_ID_RE } from "./clock-DIfTX44d.mjs";
|
|
2
2
|
import { Cause, Clock, Context, Data, Deferred, Duration, Effect, Exit, Fiber, Layer, Queue, Ref, Result, Schema, SchemaGetter, SchemaParser, Scope } from "effect";
|
|
3
3
|
import { formatUnits, keccak256, parseUnits, recoverAddress, toBytes } from "viem";
|
|
4
4
|
import { makeFunctionReference } from "convex/server";
|
|
@@ -5228,7 +5228,7 @@ const moneyExecutionContract = {
|
|
|
5228
5228
|
};
|
|
5229
5229
|
//#endregion
|
|
5230
5230
|
//#region package.json
|
|
5231
|
-
var version = "4.
|
|
5231
|
+
var version = "4.2.0";
|
|
5232
5232
|
//#endregion
|
|
5233
5233
|
//#region src/telemetry/exception-projection.ts
|
|
5234
5234
|
/** Fixed fallback for failures that have no safe message. */
|
|
@@ -5591,8 +5591,6 @@ function evidenceText(value) {
|
|
|
5591
5591
|
if (typeof value !== "string" || value.length === 0) return void 0;
|
|
5592
5592
|
return redactSecrets(value).slice(0, MAX_EVIDENCE_TEXT);
|
|
5593
5593
|
}
|
|
5594
|
-
/** A field whose NAME says credential is masked whatever its value looks like. */
|
|
5595
|
-
const CREDENTIAL_FIELD_NAME = /(?:otp|pass(?:word|wd|phrase)?|token|secret|credential|api[_-]?key|private[_-]?key|authorization|cookie|session)/iu;
|
|
5596
5594
|
/** Copy a details object into a JSON-safe shape with every string masked. */
|
|
5597
5595
|
function evidenceValue(value, depth = 0) {
|
|
5598
5596
|
if (typeof value === "string") return evidenceText(value);
|
|
@@ -5603,7 +5601,7 @@ function evidenceValue(value, depth = 0) {
|
|
|
5603
5601
|
if (Array.isArray(value)) return value.slice(0, 50).map((item) => evidenceValue(item, depth + 1));
|
|
5604
5602
|
const copy = {};
|
|
5605
5603
|
for (const [key, nested] of Object.entries(value)) {
|
|
5606
|
-
if (
|
|
5604
|
+
if (isCredentialField(key)) {
|
|
5607
5605
|
copy[key] = "[REDACTED]";
|
|
5608
5606
|
continue;
|
|
5609
5607
|
}
|
|
@@ -7073,6 +7071,12 @@ function convexCallErrorFromCapxul(operation, error, transport) {
|
|
|
7073
7071
|
var ConvexCallPortTag = class extends Context.Service()("@capxul/sdk/ports/ConvexCallPort") {};
|
|
7074
7072
|
//#endregion
|
|
7075
7073
|
//#region src/ports/identity.ts
|
|
7074
|
+
/** The chain families a payout address may name (#1955). */
|
|
7075
|
+
const PAYOUT_CHAINS = [
|
|
7076
|
+
"evm",
|
|
7077
|
+
"solana",
|
|
7078
|
+
"starknet"
|
|
7079
|
+
];
|
|
7076
7080
|
var IdentityError = class extends Data.TaggedError("IdentityError") {};
|
|
7077
7081
|
function identityErrorFromCapxul(operation, error, cause = error) {
|
|
7078
7082
|
return new IdentityError({
|
|
@@ -8075,8 +8079,52 @@ const loadIdentityProgram = Effect.gen(function* () {
|
|
|
8075
8079
|
if (authUserId === void 0) return null;
|
|
8076
8080
|
return yield* deps.identityPort.loadByAuthUserId(authUserId).pipe(Effect.catchDefect((cause) => Effect.fail(identityErrorFromCapxul("loadByAuthUserId", cause instanceof CapxulError ? cause : Errors.unknown(cause), cause))), Effect.mapError((failure) => failure.publicError));
|
|
8077
8081
|
});
|
|
8078
|
-
|
|
8079
|
-
|
|
8082
|
+
/**
|
|
8083
|
+
* THE ONE boundary grammar for those optional fields. Both `completeProfile`
|
|
8084
|
+
* entry points — the method bundle here and the identity runtime in
|
|
8085
|
+
* `create-capxul-client.ts` — run it, so a malformed value is refused the same
|
|
8086
|
+
* way at each and never reaches the port.
|
|
8087
|
+
*/
|
|
8088
|
+
function checkProfileCarriage(profile) {
|
|
8089
|
+
const carriage = {};
|
|
8090
|
+
if (profile.imageStorageId !== void 0) {
|
|
8091
|
+
if (typeof profile.imageStorageId !== "string" || profile.imageStorageId.trim().length === 0) return {
|
|
8092
|
+
ok: false,
|
|
8093
|
+
field: "imageStorageId",
|
|
8094
|
+
message: "must be a non-empty storage id"
|
|
8095
|
+
};
|
|
8096
|
+
carriage.imageStorageId = profile.imageStorageId.trim();
|
|
8097
|
+
}
|
|
8098
|
+
if (profile.payoutAddresses !== void 0) {
|
|
8099
|
+
if (!Array.isArray(profile.payoutAddresses)) return {
|
|
8100
|
+
ok: false,
|
|
8101
|
+
field: "payoutAddresses",
|
|
8102
|
+
message: "must be an array"
|
|
8103
|
+
};
|
|
8104
|
+
if (profile.payoutAddresses.length > 10) return {
|
|
8105
|
+
ok: false,
|
|
8106
|
+
field: "payoutAddresses",
|
|
8107
|
+
message: `must carry at most 10 addresses`
|
|
8108
|
+
};
|
|
8109
|
+
const entries = [];
|
|
8110
|
+
for (const entry of profile.payoutAddresses) {
|
|
8111
|
+
if (typeof entry !== "object" || entry === null || !PAYOUT_CHAINS.some((chain) => chain === entry.chain) || typeof entry.address !== "string" || entry.address.trim().length === 0) return {
|
|
8112
|
+
ok: false,
|
|
8113
|
+
field: "payoutAddresses",
|
|
8114
|
+
message: `each entry needs a chain of ${PAYOUT_CHAINS.join(", ")} and an address`
|
|
8115
|
+
};
|
|
8116
|
+
entries.push({
|
|
8117
|
+
chain: entry.chain,
|
|
8118
|
+
address: entry.address.trim()
|
|
8119
|
+
});
|
|
8120
|
+
}
|
|
8121
|
+
carriage.payoutAddresses = entries;
|
|
8122
|
+
}
|
|
8123
|
+
return {
|
|
8124
|
+
ok: true,
|
|
8125
|
+
carriage
|
|
8126
|
+
};
|
|
8127
|
+
}
|
|
8080
8128
|
function makeIdentityMethods(deps) {
|
|
8081
8129
|
const convexCall = deps.convexCall;
|
|
8082
8130
|
return {
|
|
@@ -8115,6 +8163,11 @@ function makeIdentityMethods(deps) {
|
|
|
8115
8163
|
error: Errors.invalidInput("country", "unsupported country")
|
|
8116
8164
|
};
|
|
8117
8165
|
}
|
|
8166
|
+
const carried = checkProfileCarriage(profile);
|
|
8167
|
+
if (!carried.ok) return {
|
|
8168
|
+
ok: false,
|
|
8169
|
+
error: Errors.invalidInput(carried.field, carried.message)
|
|
8170
|
+
};
|
|
8118
8171
|
const session = deps.actor?.authSession();
|
|
8119
8172
|
if (session === void 0 || session === null) return {
|
|
8120
8173
|
ok: false,
|
|
@@ -8125,7 +8178,8 @@ function makeIdentityMethods(deps) {
|
|
|
8125
8178
|
email: session.email,
|
|
8126
8179
|
displayName,
|
|
8127
8180
|
country,
|
|
8128
|
-
handle
|
|
8181
|
+
handle,
|
|
8182
|
+
...carried.carriage
|
|
8129
8183
|
}), options, CAPXUL_OPERATIONS.identity.completeProfile);
|
|
8130
8184
|
},
|
|
8131
8185
|
async handleAvailable(handle, options) {
|
|
@@ -10111,6 +10165,11 @@ function assembleCapxulClient(input) {
|
|
|
10111
10165
|
ok: false,
|
|
10112
10166
|
reason: "INVALID_INPUT"
|
|
10113
10167
|
};
|
|
10168
|
+
const carried = checkProfileCarriage(profile);
|
|
10169
|
+
if (!carried.ok) return {
|
|
10170
|
+
ok: false,
|
|
10171
|
+
reason: "INVALID_INPUT"
|
|
10172
|
+
};
|
|
10114
10173
|
const session = actor.authSession();
|
|
10115
10174
|
if (session === null) return {
|
|
10116
10175
|
ok: false,
|
|
@@ -10121,7 +10180,8 @@ function assembleCapxulClient(input) {
|
|
|
10121
10180
|
email: session.email,
|
|
10122
10181
|
displayName,
|
|
10123
10182
|
country,
|
|
10124
|
-
handle
|
|
10183
|
+
handle,
|
|
10184
|
+
...carried.carriage
|
|
10125
10185
|
}), controls, CAPXUL_OPERATIONS.identity.completeProfile, effectRunner.runPromise);
|
|
10126
10186
|
return result.ok ? { ok: true } : {
|
|
10127
10187
|
ok: false,
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { B as EVM_ADDRESS_RE, Ct as RevertSummary, E as Address, G as OrgId, I as CountryCode, J as PayrollGroupId, K as PartyId, M as AuthUserId, P as BudgetId, St as FailureMode, T as AccountId, U as Handle, W as Money, Y as PayrollRunId, _t as isCapxulError, a as SignerStatusStore, bt as ChainUpstream, c as AccountProviderSource, ct as toHandle, d as eip1193AccountProvider, dt as CAPXUL_ERROR_CODES, et as RoleKey, f as localPrivateKeyAccountProvider, ft as CapxulError, g as SmartAccount, h as Session, ht as Errors, i as SignerStatus, j as AuthSession, l as AccountRequirement, lt as toPartyId, m as Profile, mt as CapxulErrorDetails, n as CapxulSigner, o as injectedWalletSigner, ot as toAddress, p as CapxulResult, pt as CapxulErrorCode, r as Eip1193RequestProvider, rt as TesterKind, s as AccountProvider, st as toCountryCode, t as CapxulDigestSigner, u as Eip1193Provider, ut as CAPXUL_PAYMENTS_V2_ADDRESS, vt as CHAIN_UPSTREAMS, w as Account, xt as FAILURE_MODES, yt as ChainCause } from "./signer-C0hZ6Kiy.mjs";
|
|
2
|
-
import { $ as OrganizationPaymentItemInput, $t as DestinationKind, A as OrgView, An as TargetReference, At as AddressBookLabelInput, B as PayrollGroup, Bn as OrgLifecycle, Bt as ActivityKind, C as DetectPendingOrgInvitationsResult, Cn as PaymentTiming, Ct as ActorProfileMethods, D as OrgMethods, Dn as RecipientResolution, Dt as ActorRequestsMethods, E as MemberView, En as PaymentsPayInput, Et as ActorRequestIssueInput, F as RoleSpendCap, Fn as isSettingUpLifecycle, Ft as ActivityAnnotation, G as PayrollOptions, Gn as
|
|
2
|
+
import { $ as OrganizationPaymentItemInput, $t as DestinationKind, A as OrgView, An as TargetReference, At as AddressBookLabelInput, B as PayrollGroup, Bn as OrgLifecycle, Bt as ActivityKind, C as DetectPendingOrgInvitationsResult, Cn as PaymentTiming, Ct as ActorProfileMethods, D as OrgMethods, Dn as RecipientResolution, Dt as ActorRequestsMethods, E as MemberView, En as PaymentsPayInput, Et as ActorRequestIssueInput, F as RoleSpendCap, Fn as isSettingUpLifecycle, Ft as ActivityAnnotation, G as PayrollOptions, Gn as Permission, Gt as ActivityReference, H as PayrollGroupMember, Hn as PayoutAddress, Ht as ActivityMethods, I as RoleView, In as CompleteProfileInput, It as ActivityAnnotationInput, J as PayrollRunStatus, Jn as PAYMENT_DIRECTIONS, Jt as ActivitySummaryTotal, K as PayrollRun, Kn as SubmittedPermissionExecution, Kt as ActivitySummary, L as AuthorizeRunInput, Ln as IdentityMethods, Lt as ActivityDetail, M as OrganizationAuditLogItem, Mn as fingerprintPaymentIntent, Mt as InboxApproveInput, N as ResendInviteTokenInput, Nn as AccountLifecycle, Nt as InboxItem, O as OrgScopedMethods, On as Ref, Ot as AddressBookAddInput, P as RoleDefinition, Pn as AccountSetupStep, Pt as InboxMethods, Q as OrganizationPaymentInput, Qt as DestinationAddInput, R as AuthorizeRunOptions, Rn as SmartAccountMethods, Rt as ActivityFilter, S as CreateOrgInput, Sn as PaymentStatus, St as ActorProfile, T as MemberStatus, Tn as PaymentsMethods, Tt as ActorRequest, U as PayrollGroupsMethods, Un as ActorRef, Ut as ActivityPage, V as PayrollGroupInput, Vn as OrgSetupStep, Vt as ActivityListParams, W as PayrollMethods, Wn as CurrentHoldings, Wt as ActivityRange, X as PayrollTermsUnit, Xn as PaymentStatus$1, Xt as DepositInstructions, Y as PayrollRuns, Yn as PAYMENT_STATUSES, Yt as ActorReference, Z as OrganizationPaymentBatchInput, Zn as RequestStatus, Zt as Destination, _ as SystemMethods, _n as PaymentDocumentRef, _t as OrganizationOnboardingInput, a as SdkFailureObservation, an as FinancialOpsMethods, ar as OrgLane, at as PermissionOptions, b as CurrentUserContext, bn as PaymentDocumentsMethods, bt as ReadyAccountLifecycle, c as PostHogObservabilityOptions, cn as MovementActivityEvidence, cr as destination, ct as PermissionReadResult, d as CreateCapxulClientInput, dn as OfframpQuoteInput, dr as IdentityTransition, dt as OrgMeMethod, en as DestinationListInput, et as OrganizationPaymentsMethods, f as IdentityProfileDetails, fn as OfframpStatus, fr as InvocationControls, ft as OrgMeOptions, g as Holding, gn as PaymentDocumentKind, gt as OrganizationOnboarding, h as HoldingsMethods, hn as PaymentDirection, ht as OnboardingMethods, i as ObservationDelivery, in as DestinationsMethods, ir as IdentityState, it as PermissionMethods, j as OrganizationAccount, jn as TargetsMethods, jt as AddressBookMethods, k as OrgTemplate, kn as ResolvedTarget, kt as AddressBookEntry, l as postHogObservability, ln as OfframpMethods, lr as isClaimed, lt as Budget, m as IdentityRuntimeSendResult, mn as PaymentActivityEvidence, mt as CompletedPersonProfile, n as ObservationAdapter, nn as DestinationRail, nr as Destination$1, nt as PermissionChangeInput, o as HostObservability, on as MeMethods, or as Readiness, ot as PermissionReplaceInput, p as IdentityRuntime, pn as Payment, pt as AccountsMethods, q as PayrollRunItemInput, qn as InboxStatus, qt as ActivitySummaryParams, r as ObservationContext, rn as DestinationRemoveInput, rr as IdentityEvent, rt as PermissionCreateInput, s as PostHogObservabilityClient, sn as MeProfile, sr as StateLabel, st as PermissionRevokeInput, t as CAPXUL_SDK_EXPECTED_OUTCOME_EVENT, tn as DestinationPayload, tr as TelemetryPort, tt as PermissionAssignInput, u as CapxulClient, un as OfframpQuote, ur as isRestoring, ut as OrgMe, v as SystemHealth, vn as PaymentDocumentRender, vt as PersonOnboarding, w as InviteMemberInput, wn as PaymentType, wt as ActorRelationshipMethods, x as CurrentUserMethods, xn as PaymentMoney, xt as AccountMethods, y as MediaMethods, yn as PaymentDocumentVerification, yt as PersonOnboardingInput, z as PayrollEngagementTerms, zn as AuthMethods, zt as ActivityItem } from "./observation-vegBPfXj.mjs";
|
|
3
3
|
import "./OAuthBearerAuthClient-D-DLYlKj.mjs";
|
|
4
4
|
import { Context, Effect, Layer } from "effect";
|
|
5
5
|
import { Hex } from "viem";
|
|
@@ -626,4 +626,4 @@ declare function captureException(telemetry: TelemetryPort, error: unknown, cont
|
|
|
626
626
|
*/
|
|
627
627
|
declare function captureExceptionSync(telemetry: TelemetryPort, error: unknown, context?: HandledErrorReportContext): void;
|
|
628
628
|
//#endregion
|
|
629
|
-
export { type Account, type AccountId, type AccountLifecycle, type AccountMethods, type AccountProvider, type AccountProviderSource, type AccountRequirement, type AccountSetupStep, type AccountsMethods, type ActivityAnnotation, type ActivityAnnotationInput, type ActivityDetail, type ActivityFilter, type ActivityItem, type ActivityKind, type ActivityListParams, type ActivityMethods, type ActivityPage, type ActivityPhase, type ActivityRange, type ActivityReference, type ActivitySummary, type ActivitySummaryParams, type ActivitySummaryTotal, type ActorProfile, type ActorProfileMethods, type ActorRef, type ActorReference, type ActorRelationshipMethods, type ActorRequest, type ActorRequestIssueInput, type ActorRequestsMethods, type Address, type AddressBookAddInput, type AddressBookEntry, type AddressBookLabelInput, type AddressBookMethods, type AuthMethods, type AuthSession, type AuthUserId, type AuthorizeRunInput, type AuthorizeRunOptions, type Budget, type BudgetId, CAPXUL_ERROR_CODES, CAPXUL_OPERATIONS, CAPXUL_PAYMENTS_V2_ADDRESS, CAPXUL_SDK_EXPECTED_OUTCOME_EVENT, CHAIN_UPSTREAMS, type CapxulClient, type CapxulClientInput, type CapxulDigestSigner, CapxulError, type CapxulErrorCode, type CapxulErrorDetails, type CapxulOperation, type CapxulResult, type CapxulSigner, type ChainCause, type ChainUpstream, type CompleteProfileInput, type CompletedPersonProfile, type CountryCode, type CreateCapxulClientInput, type CreateOrgInput, type CurrentHoldings, type CurrentUserContext, type CurrentUserMethods, type DepositInstructions, type Destination, type DestinationAddInput, type DestinationKind, type DestinationListInput, type DestinationPayload, type DestinationRail, type DestinationRemoveInput, type DestinationsMethods, type DetectPendingOrgInvitationsResult, type DevPrivateKeySignerInput, EVM_ADDRESS_RE, type Eip1193Provider, type Eip1193RequestProvider, Errors, FAILURE_MODES, type FailureMode, type FinancialOpsMethods, HANDLE_RE, type Handle, type HandledErrorReportContext, type Holding, type HoldingsMethods, type HostObservability, type Destination$1 as IdentityDestination, type IdentityEvent, type IdentityMethods, type IdentityProfileDetails, type IdentityRuntime, type IdentityRuntimeSendResult, type IdentityState, type IdentityTransition, type InboxApproveInput, type InboxItem, type InboxMethods, type InviteMemberInput, type InvocationControls, type MeMethods, type MeProfile, type MediaMethods, type MemberStatus, type MemberView, type Money, type MoneyParseError, type MoneyParseErrorReason, type MovementActivityEvidence, type NormalizedCapxulOperation, type ObservationAdapter, type ObservationContext, type ObservationDelivery, type OfframpMethods, type OfframpQuote, type OfframpQuoteInput, type OfframpStatus, type OnboardingMethods, type OpenfortEmbeddedSignerInput, type OpenfortEmbeddedWalletApi, type OpenfortEmbeddedWalletPort, type OrgId, type OrgLane, type OrgLifecycle, type OrgMe, type OrgMeMethod, type OrgMeOptions, type OrgMethods, type OrgScopedMethods, type OrgSetupStep, type OrgTemplate, type OrgView, type OrganizationAccount, type OrganizationAuditLogItem, type OrganizationOnboarding, type OrganizationOnboardingInput, type OrganizationPaymentBatchInput, type OrganizationPaymentInput, type OrganizationPaymentItemInput, type OrganizationPaymentsMethods, PAYMENT_DIRECTIONS, PAYMENT_STATUSES, type PartyId, type Payment, type PaymentActivityEvidence, type PaymentDirection, type PaymentDocumentKind, type PaymentDocumentRef, type PaymentDocumentRender, type PaymentDocumentVerification, type PaymentDocumentsMethods, type PaymentMoney, type PaymentStatus, type PaymentTiming, type PaymentType, type PaymentsMethods, type PaymentsPayInput, type PayrollEngagementTerms, type PayrollGroup, type PayrollGroupId, type PayrollGroupInput, type PayrollGroupMember, type PayrollGroupsMethods, type PayrollMethods, type PayrollOptions, type PayrollRun, type PayrollRunId, type PayrollRunItemInput, type PayrollRunStatus, type PayrollRuns, type PayrollTermsUnit, type Permission, type PermissionAssignInput, type PermissionChangeInput, type PermissionCreateInput, type PermissionMethods, type PermissionOptions, type PermissionReadResult, type PermissionReplaceInput, type PermissionRevokeInput, type PersonOnboarding, type PersonOnboardingInput, type PostHogObservabilityClient, type PostHogObservabilityOptions, type Profile, type Readiness, type ReadyAccountLifecycle, type RecipientResolution, type Ref, type ResendInviteTokenInput, type ResolvedTarget, type RevertSummary, type RoleDefinition, type RoleKey, type RoleSpendCap, type RoleView, type SdkFailureObservation, type Session, type SignerStatus, type SignerStatusStore, type SmartAccount, type SmartAccountMethods, type StateLabel, type SubmittedPermissionExecution, type SystemHealth, type SystemMethods, type TargetReference, type TargetsMethods, type TelemetryPort, type TesterKind, captureException, captureExceptionSync, createCapxulClient, deriveDevPrivateKey, devPrivateKeySigner, eip1193AccountProvider, embeddedSigner, fingerprintPaymentIntent, formatMoney, inboxPhase, injectedWalletSigner, isCapxulError, isCapxulOperation, isClaimed, isMoneyParseError, isRestoring, isSettingUpLifecycle, localPrivateKeyAccountProvider, normalizeCapxulOperation, openfortEmbeddedSigner, openfortEmbeddedSignerFromWallet, openfortEmbeddedWalletPort, parseMoney, paymentPhase, postHogObservability, requestPhase, destination as resolveIdentityDestination, toCountryCode, toAddress as toEvmAddress, toHandle, toPartyId };
|
|
629
|
+
export { type Account, type AccountId, type AccountLifecycle, type AccountMethods, type AccountProvider, type AccountProviderSource, type AccountRequirement, type AccountSetupStep, type AccountsMethods, type ActivityAnnotation, type ActivityAnnotationInput, type ActivityDetail, type ActivityFilter, type ActivityItem, type ActivityKind, type ActivityListParams, type ActivityMethods, type ActivityPage, type ActivityPhase, type ActivityRange, type ActivityReference, type ActivitySummary, type ActivitySummaryParams, type ActivitySummaryTotal, type ActorProfile, type ActorProfileMethods, type ActorRef, type ActorReference, type ActorRelationshipMethods, type ActorRequest, type ActorRequestIssueInput, type ActorRequestsMethods, type Address, type AddressBookAddInput, type AddressBookEntry, type AddressBookLabelInput, type AddressBookMethods, type AuthMethods, type AuthSession, type AuthUserId, type AuthorizeRunInput, type AuthorizeRunOptions, type Budget, type BudgetId, CAPXUL_ERROR_CODES, CAPXUL_OPERATIONS, CAPXUL_PAYMENTS_V2_ADDRESS, CAPXUL_SDK_EXPECTED_OUTCOME_EVENT, CHAIN_UPSTREAMS, type CapxulClient, type CapxulClientInput, type CapxulDigestSigner, CapxulError, type CapxulErrorCode, type CapxulErrorDetails, type CapxulOperation, type CapxulResult, type CapxulSigner, type ChainCause, type ChainUpstream, type CompleteProfileInput, type CompletedPersonProfile, type CountryCode, type CreateCapxulClientInput, type CreateOrgInput, type CurrentHoldings, type CurrentUserContext, type CurrentUserMethods, type DepositInstructions, type Destination, type DestinationAddInput, type DestinationKind, type DestinationListInput, type DestinationPayload, type DestinationRail, type DestinationRemoveInput, type DestinationsMethods, type DetectPendingOrgInvitationsResult, type DevPrivateKeySignerInput, EVM_ADDRESS_RE, type Eip1193Provider, type Eip1193RequestProvider, Errors, FAILURE_MODES, type FailureMode, type FinancialOpsMethods, HANDLE_RE, type Handle, type HandledErrorReportContext, type Holding, type HoldingsMethods, type HostObservability, type Destination$1 as IdentityDestination, type IdentityEvent, type IdentityMethods, type IdentityProfileDetails, type IdentityRuntime, type IdentityRuntimeSendResult, type IdentityState, type IdentityTransition, type InboxApproveInput, type InboxItem, type InboxMethods, type InviteMemberInput, type InvocationControls, type MeMethods, type MeProfile, type MediaMethods, type MemberStatus, type MemberView, type Money, type MoneyParseError, type MoneyParseErrorReason, type MovementActivityEvidence, type NormalizedCapxulOperation, type ObservationAdapter, type ObservationContext, type ObservationDelivery, type OfframpMethods, type OfframpQuote, type OfframpQuoteInput, type OfframpStatus, type OnboardingMethods, type OpenfortEmbeddedSignerInput, type OpenfortEmbeddedWalletApi, type OpenfortEmbeddedWalletPort, type OrgId, type OrgLane, type OrgLifecycle, type OrgMe, type OrgMeMethod, type OrgMeOptions, type OrgMethods, type OrgScopedMethods, type OrgSetupStep, type OrgTemplate, type OrgView, type OrganizationAccount, type OrganizationAuditLogItem, type OrganizationOnboarding, type OrganizationOnboardingInput, type OrganizationPaymentBatchInput, type OrganizationPaymentInput, type OrganizationPaymentItemInput, type OrganizationPaymentsMethods, PAYMENT_DIRECTIONS, PAYMENT_STATUSES, type PartyId, type Payment, type PaymentActivityEvidence, type PaymentDirection, type PaymentDocumentKind, type PaymentDocumentRef, type PaymentDocumentRender, type PaymentDocumentVerification, type PaymentDocumentsMethods, type PaymentMoney, type PaymentStatus, type PaymentTiming, type PaymentType, type PaymentsMethods, type PaymentsPayInput, type PayoutAddress, type PayrollEngagementTerms, type PayrollGroup, type PayrollGroupId, type PayrollGroupInput, type PayrollGroupMember, type PayrollGroupsMethods, type PayrollMethods, type PayrollOptions, type PayrollRun, type PayrollRunId, type PayrollRunItemInput, type PayrollRunStatus, type PayrollRuns, type PayrollTermsUnit, type Permission, type PermissionAssignInput, type PermissionChangeInput, type PermissionCreateInput, type PermissionMethods, type PermissionOptions, type PermissionReadResult, type PermissionReplaceInput, type PermissionRevokeInput, type PersonOnboarding, type PersonOnboardingInput, type PostHogObservabilityClient, type PostHogObservabilityOptions, type Profile, type Readiness, type ReadyAccountLifecycle, type RecipientResolution, type Ref, type ResendInviteTokenInput, type ResolvedTarget, type RevertSummary, type RoleDefinition, type RoleKey, type RoleSpendCap, type RoleView, type SdkFailureObservation, type Session, type SignerStatus, type SignerStatusStore, type SmartAccount, type SmartAccountMethods, type StateLabel, type SubmittedPermissionExecution, type SystemHealth, type SystemMethods, type TargetReference, type TargetsMethods, type TelemetryPort, type TesterKind, captureException, captureExceptionSync, createCapxulClient, deriveDevPrivateKey, devPrivateKeySigner, eip1193AccountProvider, embeddedSigner, fingerprintPaymentIntent, formatMoney, inboxPhase, injectedWalletSigner, isCapxulError, isCapxulOperation, isClaimed, isMoneyParseError, isRestoring, isSettingUpLifecycle, localPrivateKeyAccountProvider, normalizeCapxulOperation, openfortEmbeddedSigner, openfortEmbeddedSignerFromWallet, openfortEmbeddedWalletPort, parseMoney, paymentPhase, postHogObservability, requestPhase, destination as resolveIdentityDestination, toCountryCode, toAddress as toEvmAddress, toHandle, toPartyId };
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { $ as stampTelemetryEnvelope, A as safeExceptionLabel, B as resolveFailureMode, C as observeFailedResult, D as normalizeExceptionErrorKind, E as SDK_VERSION$1, F as causeChain, G as sanitizeObservationContext, H as readInvocationObservation, I as injectedWalletSigner, J as CAPXUL_FUNCTIONS, K as PAYMENT_DIRECTIONS, L as isSignerNotReadySignal, M as fromWei, N as isSettingUpLifecycle, O as normalizeExceptionOperation, P as formatTraceparent, Q as redactTelemetryProps, R as openfortSignerNotReadyCode, S as observationContextProps, T as EXCEPTION_MESSAGE, U as OBSERVATION_CONTEXT_HEADER, V as copyInvocationObservation, W as encodeObservationContextHeader, X as EngineeringTelemetryBootstrapPolicy, Y as BootstrapEnvelope, _ as fingerprintPaymentIntent, a as AccountReadPortTag, at as isRestoring, b as failureDetail, c as retryIdempotentRead, d as IdentityPortTag, et as CAPXUL_OPERATIONS, f as identityErrorFromCapxul, g as bootstrapErrorFromCapxul, h as BootstrapPortTag, i as smartAccountErrorFromCapxul, it as isClaimed, j as version, k as projectSdkException, l as PRODUCT_INVOCATION, m as convexCallErrorFromCapxul, n as detectAuthCacheAdapter, nt as normalizeCapxulOperation, o as accountReadErrorFromCapxul, p as ConvexCallPortTag, q as PAYMENT_STATUSES, r as SmartAccountPortTag, rt as destination, s as TelemetryPortTag, t as assembleCapxulClient, tt as isCapxulOperation, u as wireChainId, v as toWei, w as postHogFailureObservation, x as failureEvidenceProps, y as CAPXUL_SDK_EXPECTED_OUTCOME_EVENT, z as signerFailure } from "./create-capxul-client-
|
|
2
|
-
import { $ as CapxulError, A as toAuthUserId, B as toJwtToken, D as toAddress, E as toAccountId, F as toDurationMs, H as toOrgId, I as toEmail, J as toSessionToken, K as toPublishableKey, L as toEpochMs, M as toChainId, N as toCountryCode, O as toAllowedOrigin, P as toCurrencyCode, Q as CAPXUL_ERROR_CODES, R as toEpochSeconds, T as currencySymbolFor, U as toPartyId, V as toKycTier, X as HANDLE_RE, Y as toTesterKind, Z as decodeConvexError, d as AuthClientError, f as AuthClientPortTag, g as BASE_SEPOLIA_CHAIN_ID, h as normalizeBindingEmail, it as FAILURE_MODES, l as ClockPortTag, m as CAPXUL_PAYMENTS_V2_ADDRESS, nt as isCapxulError, q as toRoleKey, rt as CHAIN_UPSTREAMS, s as AuthCachePortTag, tt as Errors, u as authClientPortFromPromiseAdapter, x as EVM_ADDRESS_RE, z as toHandle } from "./clock-
|
|
3
|
-
import { n as SystemClockLayer } from "./OAuthBearerAuthClient-
|
|
4
|
-
import { Cause, Context, Data, Duration, Effect, Exit, Layer, Result, Schedule, SchemaIssue, SchemaParser, Scope, Tracer } from "effect";
|
|
1
|
+
import { $ as stampTelemetryEnvelope, A as safeExceptionLabel, B as resolveFailureMode, C as observeFailedResult, D as normalizeExceptionErrorKind, E as SDK_VERSION$1, F as causeChain, G as sanitizeObservationContext, H as readInvocationObservation, I as injectedWalletSigner, J as CAPXUL_FUNCTIONS, K as PAYMENT_DIRECTIONS, L as isSignerNotReadySignal, M as fromWei, N as isSettingUpLifecycle, O as normalizeExceptionOperation, P as formatTraceparent, Q as redactTelemetryProps, R as openfortSignerNotReadyCode, S as observationContextProps, T as EXCEPTION_MESSAGE, U as OBSERVATION_CONTEXT_HEADER, V as copyInvocationObservation, W as encodeObservationContextHeader, X as EngineeringTelemetryBootstrapPolicy, Y as BootstrapEnvelope, _ as fingerprintPaymentIntent, a as AccountReadPortTag, at as isRestoring, b as failureDetail, c as retryIdempotentRead, d as IdentityPortTag, et as CAPXUL_OPERATIONS, f as identityErrorFromCapxul, g as bootstrapErrorFromCapxul, h as BootstrapPortTag, i as smartAccountErrorFromCapxul, it as isClaimed, j as version, k as projectSdkException, l as PRODUCT_INVOCATION, m as convexCallErrorFromCapxul, n as detectAuthCacheAdapter, nt as normalizeCapxulOperation, o as accountReadErrorFromCapxul, p as ConvexCallPortTag, q as PAYMENT_STATUSES, r as SmartAccountPortTag, rt as destination, s as TelemetryPortTag, t as assembleCapxulClient, tt as isCapxulOperation, u as wireChainId, v as toWei, w as postHogFailureObservation, x as failureEvidenceProps, y as CAPXUL_SDK_EXPECTED_OUTCOME_EVENT, z as signerFailure } from "./create-capxul-client-B6PUjdld.mjs";
|
|
2
|
+
import { $ as CapxulError, A as toAuthUserId, B as toJwtToken, D as toAddress, E as toAccountId, F as toDurationMs, H as toOrgId, I as toEmail, J as toSessionToken, K as toPublishableKey, L as toEpochMs, M as toChainId, N as toCountryCode, O as toAllowedOrigin, P as toCurrencyCode, Q as CAPXUL_ERROR_CODES, R as toEpochSeconds, T as currencySymbolFor, U as toPartyId, V as toKycTier, X as HANDLE_RE, Y as toTesterKind, Z as decodeConvexError, d as AuthClientError, f as AuthClientPortTag, g as BASE_SEPOLIA_CHAIN_ID, gt as redactUrlSecrets, h as normalizeBindingEmail, ht as redactSecrets, it as FAILURE_MODES, l as ClockPortTag, m as CAPXUL_PAYMENTS_V2_ADDRESS, mt as isCredentialField, nt as isCapxulError, q as toRoleKey, rt as CHAIN_UPSTREAMS, s as AuthCachePortTag, tt as Errors, u as authClientPortFromPromiseAdapter, x as EVM_ADDRESS_RE, z as toHandle } from "./clock-DIfTX44d.mjs";
|
|
3
|
+
import { n as SystemClockLayer } from "./OAuthBearerAuthClient-ByPzJZr8.mjs";
|
|
4
|
+
import { Cause, Context, Data, Duration, Effect, Exit, FiberSet, Layer, Result, Schedule, SchemaIssue, SchemaParser, Scope, Stream, Tracer } from "effect";
|
|
5
5
|
import { keccak256, recoverAddress, stringToHex } from "viem";
|
|
6
6
|
import { getFunctionName, makeFunctionReference } from "convex/server";
|
|
7
7
|
import { privateKeyToAccount } from "viem/accounts";
|
|
@@ -424,21 +424,8 @@ const ENGINEERING_CAPXUL_ENVS = [
|
|
|
424
424
|
"production",
|
|
425
425
|
"local"
|
|
426
426
|
];
|
|
427
|
-
const
|
|
428
|
-
|
|
429
|
-
"content-type",
|
|
430
|
-
"traceparent",
|
|
431
|
-
"tracestate",
|
|
432
|
-
"x-request-id"
|
|
433
|
-
];
|
|
434
|
-
const ENGINEERING_REDACTED_HEADER_NAMES = Object.freeze([
|
|
435
|
-
"authorization",
|
|
436
|
-
"cookie",
|
|
437
|
-
"set-cookie",
|
|
438
|
-
"x-api-key",
|
|
439
|
-
/auth|email|key|otp|secret|session|token|wallet/i
|
|
440
|
-
]);
|
|
441
|
-
const traceHeaderFilter = (name) => SAFE_TRACED_HEADER_NAMES.includes(name.toLowerCase());
|
|
427
|
+
const traceHeaderFilter = (_name) => true;
|
|
428
|
+
const credentialHeaderPattern = Object.assign(/./u, { test: (name) => isCredentialField(name, "header") });
|
|
442
429
|
const postHogOtlpEndpoints = (host) => {
|
|
443
430
|
const base = host.replace(/\/+$/, "");
|
|
444
431
|
return {
|
|
@@ -470,23 +457,79 @@ const validateEngineeringTelemetryConfig = (config) => {
|
|
|
470
457
|
headers: Object.freeze({ authorization: headerEntries[0][1] })
|
|
471
458
|
};
|
|
472
459
|
};
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
460
|
+
const failureText = (failure, key, limit, source) => {
|
|
461
|
+
if (failure === null || typeof failure !== "object") return void 0;
|
|
462
|
+
try {
|
|
463
|
+
let owner = failure;
|
|
464
|
+
let descriptor;
|
|
465
|
+
for (let depth = 0; owner !== null && depth < 4; depth += 1) {
|
|
466
|
+
descriptor = Object.getOwnPropertyDescriptor(owner, key);
|
|
467
|
+
if (descriptor !== void 0 || key !== "name") break;
|
|
468
|
+
owner = Object.getPrototypeOf(owner);
|
|
469
|
+
}
|
|
470
|
+
const value = descriptor?.value;
|
|
471
|
+
return typeof value === "string" || key === "code" && typeof value === "number" ? redactSecrets(String(value), source).slice(0, limit) : void 0;
|
|
472
|
+
} catch {
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
const exportFailure = (failure, source) => {
|
|
477
|
+
const message = failureText(failure, "message", 2048, source) ?? (typeof failure === "string" ? redactSecrets(failure, source).slice(0, 2048) : "Engineering operation failed");
|
|
478
|
+
const code = failureText(failure, "code", 128);
|
|
479
|
+
const error = new Error((code === void 0 ? message : `${message} [code=${code}]`).slice(0, 2048));
|
|
480
|
+
error.name = failureText(failure, "_tag", 128) ?? failureText(failure, "name", 128) ?? "Error";
|
|
481
|
+
error.stack = failureText(failure, "stack", 8192, source) ?? `${error.name}: ${error.message}`;
|
|
482
|
+
return error;
|
|
483
|
+
};
|
|
484
|
+
const exportFailureExit = (cause, source) => Exit.failCause(Cause.fromReasons(cause.reasons.filter((reason) => !Cause.isInterruptReason(reason)).slice(0, 8).map((reason) => Cause.isFailReason(reason) ? Cause.makeFailReason(exportFailure(reason.error, source)) : Cause.makeDieReason(exportFailure(reason.defect, source)))));
|
|
485
|
+
const BROWSER_KEEPALIVE_BYTES = 65536;
|
|
486
|
+
let unfinishedBrowserExportBytes = 0;
|
|
487
|
+
const hasBrowserDocument = () => typeof window !== "undefined" && typeof document !== "undefined";
|
|
488
|
+
const browserExportClient = (client) => HttpClient.transform(client, (response, request) => Effect.acquireUseRelease(Effect.sync(() => {
|
|
489
|
+
const bytes = "contentLength" in request.body ? request.body.contentLength : void 0;
|
|
490
|
+
if (request.body._tag === "Stream" || request.body._tag === "FormData" || bytes === void 0 || !Number.isSafeInteger(bytes) || bytes < 0 || unfinishedBrowserExportBytes + bytes > BROWSER_KEEPALIVE_BYTES) return;
|
|
491
|
+
unfinishedBrowserExportBytes += bytes;
|
|
492
|
+
return bytes;
|
|
493
|
+
}), (bytes) => response.pipe(Effect.provideService(FetchHttpClient.RequestInit, { keepalive: bytes !== void 0 }), Effect.tap((result) => bytes === void 0 ? Effect.void : Stream.runDrain(result.stream).pipe(Effect.catch((error) => error.reason._tag === "EmptyBodyError" ? Effect.void : Effect.fail(error))))), (bytes) => Effect.sync(() => {
|
|
494
|
+
if (bytes !== void 0) unfinishedBrowserExportBytes -= bytes;
|
|
495
|
+
})));
|
|
496
|
+
const spanUpstream = (span) => {
|
|
497
|
+
let current = span;
|
|
498
|
+
while (current?._tag === "Span") {
|
|
499
|
+
const upstream = current.attributes.get("chain.upstream");
|
|
500
|
+
if (upstream === "alchemy" || upstream === "infura") return upstream;
|
|
501
|
+
current = current.parent._tag === "Some" ? current.parent.value : void 0;
|
|
478
502
|
}
|
|
479
503
|
};
|
|
480
|
-
const REDACTED_SPAN_FAILURE = Exit.fail(new RedactedEngineeringSpanFailure());
|
|
481
504
|
/** Preserve domain exits while preventing the OTLP serializer from seeing raw causes. */
|
|
482
505
|
const makeLeakSafeEngineeringTracer = (delegate) => Tracer.make({
|
|
483
506
|
span(options) {
|
|
484
507
|
const span = delegate.span(options);
|
|
485
508
|
const wrapped = Object.create(span);
|
|
509
|
+
Object.defineProperty(wrapped, "attribute", { value: (name, value) => {
|
|
510
|
+
const source = spanUpstream(span);
|
|
511
|
+
const header = /^http\.(?:request|response)\.header\.(.+)$/u.exec(name)?.[1];
|
|
512
|
+
if (header !== void 0 && isCredentialField(header, "header")) span.attribute(name, "[REDACTED]");
|
|
513
|
+
else if (typeof value === "string" && name === "url.query") span.attribute(name, redactUrlSecrets(`?${value}`).slice(1, 2049));
|
|
514
|
+
else if (typeof value === "string" && name === "url.path") {
|
|
515
|
+
const fullUrl = span.attributes.get("url.full");
|
|
516
|
+
const path = typeof fullUrl === "string" ? /^https?:\/\/[^/]+([^?#]*)/u.exec(fullUrl)?.[1] ?? value : value;
|
|
517
|
+
span.attribute(name, redactUrlSecrets(path, source).slice(0, 2048));
|
|
518
|
+
} else if (typeof value === "string" && (name === "url.full" || header === "location" || header === "referer" || header === "referrer")) span.attribute(name, redactUrlSecrets(value, source).slice(0, 2048));
|
|
519
|
+
else if (header !== void 0 && typeof value === "string") span.attribute(name, redactSecrets(value, source).slice(0, 2048));
|
|
520
|
+
else span.attribute(name, value);
|
|
521
|
+
} });
|
|
486
522
|
Object.defineProperty(wrapped, "end", {
|
|
487
523
|
configurable: false,
|
|
488
524
|
enumerable: false,
|
|
489
|
-
value: (endTime, exit) =>
|
|
525
|
+
value: (endTime, exit) => {
|
|
526
|
+
if (Exit.isFailure(exit) && !Cause.hasInterruptsOnly(exit.cause)) {
|
|
527
|
+
const first = exit.cause.reasons.find((reason) => !Cause.isInterruptReason(reason));
|
|
528
|
+
const code = failureText(first === void 0 ? void 0 : Cause.isFailReason(first) ? first.error : first.defect, "code", 128);
|
|
529
|
+
if (code !== void 0) span.attribute("error.code", code);
|
|
530
|
+
span.end(endTime, exportFailureExit(exit.cause, spanUpstream(span)));
|
|
531
|
+
} else span.end(endTime, exit);
|
|
532
|
+
},
|
|
490
533
|
writable: false
|
|
491
534
|
});
|
|
492
535
|
return wrapped;
|
|
@@ -517,8 +560,29 @@ const makeEngineeringTelemetryLayer = (config) => {
|
|
|
517
560
|
resource,
|
|
518
561
|
mergeWithExisting: true
|
|
519
562
|
});
|
|
520
|
-
const headerPolicy = Layer.merge(Layer.succeed(HttpClient.TracerHeaderFilter, traceHeaderFilter), Layer.succeed(Headers.CurrentRedactedNames,
|
|
521
|
-
|
|
563
|
+
const headerPolicy = Layer.merge(Layer.succeed(HttpClient.TracerHeaderFilter, traceHeaderFilter), Layer.succeed(Headers.CurrentRedactedNames, [credentialHeaderPattern]));
|
|
564
|
+
const browserLifecycle = Layer.effectDiscard(Effect.gen(function* () {
|
|
565
|
+
if (validated.producer !== "browser" || !hasBrowserDocument()) return;
|
|
566
|
+
const browserWindow = window;
|
|
567
|
+
const browserDocument = document;
|
|
568
|
+
const flusher = yield* OtlpExporter.Flusher;
|
|
569
|
+
const run = yield* FiberSet.makeRuntime();
|
|
570
|
+
const flush = () => {
|
|
571
|
+
run(flusher.flush);
|
|
572
|
+
};
|
|
573
|
+
const visibilityChanged = () => {
|
|
574
|
+
if (browserDocument.visibilityState === "hidden") flush();
|
|
575
|
+
};
|
|
576
|
+
yield* Effect.acquireRelease(Effect.sync(() => {
|
|
577
|
+
browserDocument.addEventListener("visibilitychange", visibilityChanged);
|
|
578
|
+
browserWindow.addEventListener("pagehide", flush);
|
|
579
|
+
}), () => Effect.sync(() => {
|
|
580
|
+
browserDocument.removeEventListener("visibilitychange", visibilityChanged);
|
|
581
|
+
browserWindow.removeEventListener("pagehide", flush);
|
|
582
|
+
}));
|
|
583
|
+
}));
|
|
584
|
+
const transport = Layer.effect(HttpClient.HttpClient, Effect.map(HttpClient.HttpClient, (client) => validated.producer === "browser" && hasBrowserDocument() ? browserExportClient(client) : client)).pipe(Layer.provide(FetchHttpClient.layer));
|
|
585
|
+
return browserLifecycle.pipe(Layer.provideMerge(Layer.mergeAll(tracing, logging, headerPolicy)), Layer.provide(OtlpSerialization.layerJson), Layer.provide(transport));
|
|
522
586
|
};
|
|
523
587
|
//#endregion
|
|
524
588
|
//#region src/adapters/auth-client/resolve-auth-url.ts
|
package/dist/node/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as toAddress, a as parseCachedJwt, i as parseAuthSession, n as InMemoryAuthCacheAdapter, o as AuthCacheError, r as BrowserAuthCacheAdapter, s as AuthCachePortTag } from "../clock-
|
|
2
|
-
import { t as oauthBearerAuthClient } from "../OAuthBearerAuthClient-
|
|
1
|
+
import { D as toAddress, a as parseCachedJwt, i as parseAuthSession, n as InMemoryAuthCacheAdapter, o as AuthCacheError, r as BrowserAuthCacheAdapter, s as AuthCachePortTag } from "../clock-DIfTX44d.mjs";
|
|
2
|
+
import { t as oauthBearerAuthClient } from "../OAuthBearerAuthClient-ByPzJZr8.mjs";
|
|
3
3
|
import { Effect, FileSystem, Layer, Path } from "effect";
|
|
4
4
|
import { privateKeyToAccount } from "viem/accounts";
|
|
5
5
|
import * as os from "node:os";
|
|
@@ -78,6 +78,11 @@ interface OrgDraft {
|
|
|
78
78
|
interface OrgSubmissionDraft extends OrgDraft {
|
|
79
79
|
readonly bio?: string;
|
|
80
80
|
readonly size?: string;
|
|
81
|
+
/**
|
|
82
|
+
* #1955: the logo uploaded on file pick. The org lane spreads this draft
|
|
83
|
+
* straight into `startOrResume`, which records it on the `orgs` insert.
|
|
84
|
+
*/
|
|
85
|
+
readonly logoStorageId?: string;
|
|
81
86
|
}
|
|
82
87
|
/** The org lane, keyed by the active orgId — which does not exist yet while the
|
|
83
88
|
* FIRST DURABLE ORG WRITE is in flight, hence `creating` carrying only a draft. */
|
|
@@ -710,6 +715,16 @@ type UpdateIdentityInput = {
|
|
|
710
715
|
readonly displayName?: string;
|
|
711
716
|
readonly country?: CountryCode;
|
|
712
717
|
};
|
|
718
|
+
/** The chain families a payout address may name (#1955). */
|
|
719
|
+
declare const PAYOUT_CHAINS: readonly ["evm", "solana", "starknet"];
|
|
720
|
+
/**
|
|
721
|
+
* One payout address, named BY CHAIN FAMILY. The network is the deployment's
|
|
722
|
+
* and the backend derives it (#1955) — a caller never sends one.
|
|
723
|
+
*/
|
|
724
|
+
type PayoutAddress = {
|
|
725
|
+
readonly chain: (typeof PAYOUT_CHAINS)[number];
|
|
726
|
+
readonly address: string;
|
|
727
|
+
};
|
|
713
728
|
/**
|
|
714
729
|
* D-ONBOARD (#669) — the onboarding-complete identity write. Composes the
|
|
715
730
|
* existing create/update write into one idempotent upsert that ALSO sets the
|
|
@@ -717,6 +732,10 @@ type UpdateIdentityInput = {
|
|
|
717
732
|
* allowed raw-0x class). `displayName` + `country` are required at onboarding
|
|
718
733
|
* time. The returned `Profile` is the existing branded shape — the onboarding
|
|
719
734
|
* flags live on the wire row and are not projected onto the read surface.
|
|
735
|
+
*
|
|
736
|
+
* #1955: it also carries the photo the signup form uploaded and the payout
|
|
737
|
+
* addresses it collected, so the backend writes all three in one transaction
|
|
738
|
+
* instead of the app binding them with two more calls afterwards.
|
|
720
739
|
*/
|
|
721
740
|
type CompleteOnboardingIdentityInput = {
|
|
722
741
|
readonly authUserId: AuthUserId;
|
|
@@ -726,6 +745,9 @@ type CompleteOnboardingIdentityInput = {
|
|
|
726
745
|
readonly withdrawalAddress?: Address$1;
|
|
727
746
|
/** One globally unique Party handle. */
|
|
728
747
|
readonly handle: string;
|
|
748
|
+
/** Storage id from `media.uploadImage`; bound on the identity write itself. */
|
|
749
|
+
readonly imageStorageId?: string;
|
|
750
|
+
readonly payoutAddresses?: readonly PayoutAddress[];
|
|
729
751
|
};
|
|
730
752
|
declare const IdentityError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
731
753
|
readonly _tag: "IdentityError";
|
|
@@ -929,6 +951,8 @@ type StartOrResumeOrganizationInput = {
|
|
|
929
951
|
/** #1064: optional onboarding-collected description + size bucket. */
|
|
930
952
|
readonly bio?: string;
|
|
931
953
|
readonly size?: string;
|
|
954
|
+
/** #1955: storage id from `media.uploadImage`, recorded on the org insert. */
|
|
955
|
+
readonly logoStorageId?: string;
|
|
932
956
|
/** @internal Safe trace/correlation carriage owned by the identity flow. */
|
|
933
957
|
readonly observationContext?: WireObservationContext;
|
|
934
958
|
};
|
|
@@ -1019,7 +1043,16 @@ interface SmartAccountMethods {
|
|
|
1019
1043
|
}
|
|
1020
1044
|
//#endregion
|
|
1021
1045
|
//#region src/surface/identity.d.ts
|
|
1022
|
-
|
|
1046
|
+
/**
|
|
1047
|
+
* #1955: what a create call may carry besides the three required fields — the
|
|
1048
|
+
* photo already uploaded and the payout addresses the form collected.
|
|
1049
|
+
*/
|
|
1050
|
+
interface ProfileCarriage {
|
|
1051
|
+
/** Storage id from `media.uploadImage`. */
|
|
1052
|
+
readonly imageStorageId?: string;
|
|
1053
|
+
readonly payoutAddresses?: readonly PayoutAddress[];
|
|
1054
|
+
}
|
|
1055
|
+
interface CompleteProfileInput extends ProfileCarriage {
|
|
1023
1056
|
readonly displayName: string;
|
|
1024
1057
|
readonly country: string;
|
|
1025
1058
|
readonly handle: string;
|
|
@@ -2545,6 +2578,13 @@ type IdentityProfileDetails = {
|
|
|
2545
2578
|
readonly displayName: string;
|
|
2546
2579
|
readonly country: string;
|
|
2547
2580
|
readonly handle: string;
|
|
2581
|
+
/**
|
|
2582
|
+
* #1955: the storage id `useCapxulUploadImage` handed back on file pick, and
|
|
2583
|
+
* the payout addresses the form collected. The create call carries them, so
|
|
2584
|
+
* the backend binds the photo and writes the rails in the same durable step.
|
|
2585
|
+
*/
|
|
2586
|
+
readonly imageStorageId?: string;
|
|
2587
|
+
readonly payoutAddresses?: readonly PayoutAddress[];
|
|
2548
2588
|
};
|
|
2549
2589
|
interface IdentityRuntime {
|
|
2550
2590
|
readonly snapshot: () => IdentityState;
|
|
@@ -2835,4 +2875,4 @@ interface ObservationAdapter {
|
|
|
2835
2875
|
/** Stable PostHog event used for typed failures that are expected product outcomes. */
|
|
2836
2876
|
declare const CAPXUL_SDK_EXPECTED_OUTCOME_EVENT = "capxul_sdk_expected_outcome";
|
|
2837
2877
|
//#endregion
|
|
2838
|
-
export { OrganizationPaymentItemInput as $,
|
|
2878
|
+
export { OrganizationPaymentItemInput as $, TelemetryGroupInput as $n, DestinationKind as $t, OrgView as A, TargetReference as An, AddressBookLabelInput as At, PayrollGroup as B, OrgLifecycle as Bn, ActivityKind as Bt, DetectPendingOrgInvitationsResult as C, PaymentTiming as Cn, ActorProfileMethods as Ct, OrgMethods as D, RecipientResolution as Dn, ActorRequestsMethods as Dt, MemberView as E, PaymentsPayInput as En, ActorRequestIssueInput as Et, RoleSpendCap as F, isSettingUpLifecycle as Fn, ActivityAnnotation as Ft, PayrollOptions as G, Permission as Gn, ActivityReference as Gt, PayrollGroupMember as H, PayoutAddress as Hn, ActivityMethods as Ht, RoleView as I, CompleteProfileInput as In, ActivityAnnotationInput as It, PayrollRunStatus as J, PAYMENT_DIRECTIONS as Jn, ActivitySummaryTotal as Jt, PayrollRun as K, SubmittedPermissionExecution as Kn, ActivitySummary as Kt, AuthorizeRunInput as L, IdentityMethods as Ln, ActivityDetail as Lt, OrganizationAuditLogItem as M, fingerprintPaymentIntent as Mn, InboxApproveInput as Mt, ResendInviteTokenInput as N, AccountLifecycle as Nn, InboxItem as Nt, OrgScopedMethods as O, Ref$1 as On, AddressBookAddInput as Ot, RoleDefinition as P, AccountSetupStep as Pn, InboxMethods as Pt, OrganizationPaymentInput as Q, TelemetryEvent as Qn, DestinationAddInput as Qt, AuthorizeRunOptions as R, SmartAccountMethods as Rn, ActivityFilter as Rt, CreateOrgInput as S, PaymentStatus as Sn, ActorProfile as St, MemberStatus as T, PaymentsMethods as Tn, ActorRequest as Tt, PayrollGroupsMethods as U, ActorRef as Un, ActivityPage as Ut, PayrollGroupInput as V, OrgSetupStep as Vn, ActivityListParams as Vt, PayrollMethods as W, CurrentHoldings as Wn, ActivityRange as Wt, PayrollTermsUnit as X, PaymentStatus$1 as Xn, DepositInstructions as Xt, PayrollRuns as Y, PAYMENT_STATUSES as Yn, ActorReference as Yt, OrganizationPaymentBatchInput as Z, RequestStatus as Zn, Destination as Zt, SystemMethods as _, PaymentDocumentRef as _n, OrganizationOnboardingInput as _t, SdkFailureObservation as a, FinancialOpsMethods as an, OrgLane as ar, PermissionOptions as at, CurrentUserContext as b, PaymentDocumentsMethods as bn, ReadyAccountLifecycle as bt, PostHogObservabilityOptions as c, MovementActivityEvidence as cn, destination as cr, PermissionReadResult as ct, CreateCapxulClientInput as d, OfframpQuoteInput as dn, IdentityTransition as dr, OrgMeMethod as dt, DestinationListInput as en, TelemetryIdentifyInput as er, OrganizationPaymentsMethods as et, IdentityProfileDetails as f, OfframpStatus as fn, InvocationControls as fr, OrgMeOptions as ft, Holding as g, PaymentDocumentKind as gn, OrganizationOnboarding as gt, HoldingsMethods as h, PaymentDirection as hn, OnboardingMethods as ht, ObservationDelivery as i, DestinationsMethods as in, IdentityState as ir, PermissionMethods as it, OrganizationAccount as j, TargetsMethods as jn, AddressBookMethods as jt, OrgTemplate as k, ResolvedTarget as kn, AddressBookEntry as kt, postHogObservability as l, OfframpMethods as ln, isClaimed as lr, Budget as lt, IdentityRuntimeSendResult as m, PaymentActivityEvidence as mn, CompletedPersonProfile as mt, ObservationAdapter as n, DestinationRail as nn, Destination$1 as nr, PermissionChangeInput as nt, HostObservability as o, MeMethods as on, Readiness as or, PermissionReplaceInput as ot, IdentityRuntime as p, Payment as pn, AccountsMethods as pt, PayrollRunItemInput as q, InboxStatus as qn, ActivitySummaryParams as qt, ObservationContext as r, DestinationRemoveInput as rn, IdentityEvent as rr, PermissionCreateInput as rt, PostHogObservabilityClient as s, MeProfile as sn, StateLabel as sr, PermissionRevokeInput as st, CAPXUL_SDK_EXPECTED_OUTCOME_EVENT as t, DestinationPayload as tn, TelemetryPort as tr, PermissionAssignInput as tt, CapxulClient as u, OfframpQuote as un, isRestoring as ur, OrgMe as ut, SystemHealth as v, PaymentDocumentRender as vn, PersonOnboarding as vt, InviteMemberInput as w, PaymentType as wn, ActorRelationshipMethods as wt, CurrentUserMethods as x, PaymentMoney as xn, AccountMethods as xt, MediaMethods as y, PaymentDocumentVerification as yn, PersonOnboardingInput as yt, PayrollEngagementTerms as z, AuthMethods as zn, ActivityItem as zt };
|
package/dist/testing/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $n as
|
|
1
|
+
import { $n as TelemetryGroupInput, Qn as TelemetryEvent, dr as IdentityTransition, er as TelemetryIdentifyInput, n as ObservationAdapter, u as CapxulClient } from "../observation-vegBPfXj.mjs";
|
|
2
2
|
import { Effect, Layer } from "effect";
|
|
3
3
|
//#region src/testing/telemetry/RecordingTelemetryAdapter.d.ts
|
|
4
4
|
type RecordingTelemetryOperation = {
|
package/dist/testing/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as fromWei, Z as redactTelemetryEvent, f as identityErrorFromCapxul, g as bootstrapErrorFromCapxul, i as smartAccountErrorFromCapxul, m as convexCallErrorFromCapxul, o as accountReadErrorFromCapxul, t as assembleCapxulClient, u as wireChainId, v as toWei } from "../create-capxul-client-
|
|
2
|
-
import { $ as CapxulError, A as toAuthUserId, B as toJwtToken, D as toAddress, E as toAccountId, F as toDurationMs, I as toEmail, J as toSessionToken, K as toPublishableKey, L as toEpochMs, M as toChainId, N as toCountryCode, O as toAllowedOrigin, R as toEpochSeconds, V as toKycTier, _ as deriveCapxulSafeAddress, k as toAppId, n as InMemoryAuthCacheAdapter, t as readClockNow, tt as Errors, u as authClientPortFromPromiseAdapter, v as validateHandle, z as toHandle } from "../clock-
|
|
1
|
+
import { M as fromWei, Z as redactTelemetryEvent, f as identityErrorFromCapxul, g as bootstrapErrorFromCapxul, i as smartAccountErrorFromCapxul, m as convexCallErrorFromCapxul, o as accountReadErrorFromCapxul, t as assembleCapxulClient, u as wireChainId, v as toWei } from "../create-capxul-client-B6PUjdld.mjs";
|
|
2
|
+
import { $ as CapxulError, A as toAuthUserId, B as toJwtToken, D as toAddress, E as toAccountId, F as toDurationMs, I as toEmail, J as toSessionToken, K as toPublishableKey, L as toEpochMs, M as toChainId, N as toCountryCode, O as toAllowedOrigin, R as toEpochSeconds, V as toKycTier, _ as deriveCapxulSafeAddress, k as toAppId, n as InMemoryAuthCacheAdapter, t as readClockNow, tt as Errors, u as authClientPortFromPromiseAdapter, v as validateHandle, z as toHandle } from "../clock-DIfTX44d.mjs";
|
|
3
3
|
import { Effect, Result, Semaphore } from "effect";
|
|
4
4
|
import { keccak256 } from "viem";
|
|
5
5
|
import { getFunctionName } from "convex/server";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capxul/sdk",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/Xelmar-tech/infrastructure.git",
|
|
@@ -47,12 +47,12 @@
|
|
|
47
47
|
"vite": "npm:@voidzero-dev/vite-plus-core@0.3.0",
|
|
48
48
|
"vite-plus": "0.3.0",
|
|
49
49
|
"vitest": "4.1.11",
|
|
50
|
-
"@capxul/errors": "0.3.0",
|
|
51
|
-
"@capxul/observability": "4.1.4",
|
|
52
|
-
"@capxul/types": "0.3.0",
|
|
53
50
|
"@capxul/config": "0.3.0",
|
|
51
|
+
"@capxul/errors": "0.3.0",
|
|
54
52
|
"@capxul/typescript-config": "0.0.0",
|
|
55
|
-
"@capxul/
|
|
53
|
+
"@capxul/types": "0.3.0",
|
|
54
|
+
"@capxul/wire": "0.7.0",
|
|
55
|
+
"@capxul/observability": "4.2.0"
|
|
56
56
|
},
|
|
57
57
|
"_permissionlessPinReason": "permissionless.toSafeSmartAccount is pinned to 0.3.4 for live Safe deployment E2E. Counterfactual address fixtures captured 2026-05-17 in packages/backend/convex/_shared/__tests__/counterfactual.test.ts and packages/config/tests/safe.test.ts must be re-verified before upgrading.",
|
|
58
58
|
"scripts": {
|