@dvmkit/dvm-cli 0.6.0 → 0.7.0-rc.1

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.
Files changed (51) hide show
  1. package/dist/{_esm-MN4BUYV6.js → _esm-KJAA4KAJ.js} +7 -7
  2. package/dist/{actions-LR65XILR.js → actions-J7VGYDBF.js} +4 -4
  3. package/dist/{ccip-JXYJSXTW.js → ccip-CJFG4PLA.js} +1 -1
  4. package/dist/{chains-LJ7XK6H3.js → chains-J6VIUNUB.js} +4 -4
  5. package/dist/{chunk-QICJRKB7.js → chunk-32AOWN2U.js} +11032 -12469
  6. package/dist/chunk-3E4LW5R5.js +77 -0
  7. package/dist/chunk-5RVUW52C.js +122 -0
  8. package/dist/{chunk-MJ4X4BEW.js → chunk-6LP4EGKA.js} +61 -61
  9. package/dist/chunk-6PVFVHS5.js +5460 -0
  10. package/dist/{chunk-BECPI5H5.js → chunk-B4WHUMZM.js} +36 -36
  11. package/dist/{chunk-CJTE5TS3.js → chunk-ESOJUXVY.js} +5 -5
  12. package/dist/{chunk-F55NNH2F.js → chunk-FOWQ7R7S.js} +16 -16
  13. package/dist/{chunk-ID5G54HJ.js → chunk-FPWP4S5S.js} +5 -3
  14. package/dist/{chunk-EE2MREOM.js → chunk-IQV4KG63.js} +5 -3
  15. package/dist/{chunk-R55XNXAR.js → chunk-IUTVV6N5.js} +3 -3
  16. package/dist/{chunk-Z4CZUMUT.js → chunk-JBU7RKQ3.js} +15 -15
  17. package/dist/{chunk-SHZMNEXE.js → chunk-JTMBSEZO.js} +2770 -926
  18. package/dist/{chunk-ERJFRCJO.js → chunk-KDNFUDOG.js} +5 -5
  19. package/dist/chunk-MWWZX7OQ.js +262 -0
  20. package/dist/chunk-PATIATFK.js +765 -0
  21. package/dist/{chunk-WTM2EICO.js → chunk-PUOXBKY2.js} +3 -3
  22. package/dist/{chunk-GZWKCIYN.js → chunk-QXMKABL7.js} +3 -3
  23. package/dist/chunk-R2DSAZBO.js +87 -0
  24. package/dist/chunk-SNSJAOR3.js +43 -0
  25. package/dist/{chunk-FL2ICZW5.js → chunk-SYFKO6BA.js} +3 -3
  26. package/dist/{chunk-LH3QPVN6.js → chunk-TAZWRWM4.js} +8060 -8058
  27. package/dist/chunk-VIRAAIDU.js +409 -0
  28. package/dist/{chunk-TZWZTS37.js → chunk-WN5R367B.js} +57 -83
  29. package/dist/{chunk-EZHT2RLJ.js → chunk-X7SEGALJ.js} +3 -3
  30. package/dist/{chunk-XHOFQ3OS.js → chunk-Y3SQD37C.js} +9 -9
  31. package/dist/{client-RYDA62DU.js → client-6IHIUB6J.js} +10 -10
  32. package/dist/client-VHGN7ZFZ.js +36 -0
  33. package/dist/{dist-GKCEIY2A.js → dist-23E7OOCA.js} +9 -9
  34. package/dist/dvm.js +2428 -568
  35. package/dist/{internal-INUTGTXQ.js → internal-7RZYJLLG.js} +325 -508
  36. package/dist/lifecycle-Z7YUOTR5.js +36 -0
  37. package/dist/{payout-reporter-3Y2U55ZX-CMKACKA3.js → payout-reporter-WT7XYW42-U2QPDIYC.js} +3 -2
  38. package/dist/{pocket-refill-K5T4LZF6.js → pocket-refill-CCWF3G4N.js} +33 -30
  39. package/dist/{revenue-reporter-MAERPYGK-CCPZXGFA.js → revenue-reporter-7UR3W2SD-C5OMRGK3.js} +3 -2
  40. package/dist/{tempo-AXTE4ZEA.js → tempo-ORFVGUKP.js} +10 -10
  41. package/dist/tempo-lifecycle-OT75TYVA.js +38 -0
  42. package/dist/tempo-wallet-SGYOEWVY.js +43 -0
  43. package/dist/wallet-BRXTQ4BB.js +45 -0
  44. package/dist/{x402-R6HPBY5D-VMSW7Z32.js → x402-ZU4GML7Z-RYEACIIT.js} +4 -19
  45. package/package.json +4 -2
  46. package/dist/chunk-3YE43JJR.js +0 -215
  47. package/dist/chunk-4KINCBHL.js +0 -5153
  48. package/dist/chunk-FSYEZERJ.js +0 -1667
  49. package/dist/chunk-VOO5IAK7.js +0 -2318
  50. package/dist/tempo-lifecycle-ZBBLFBMH-HWI4PLYP.js +0 -32
  51. package/dist/tempo-wallet-B5XXV3YH-SRQBMYFV.js +0 -41
@@ -0,0 +1,409 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __dvmCreateRequire } from "node:module";
3
+ const require = __dvmCreateRequire(import.meta.url);
4
+ import {
5
+ FX_CACHE_TTL_MS,
6
+ X402_EXACT_AUTHORIZATION_TTL_SECONDS,
7
+ fetchBtcUsdRate,
8
+ formatFiat,
9
+ formatStaleness,
10
+ formatUsd,
11
+ getLastKnownBtcRate,
12
+ isSignableExactRequirement,
13
+ maxAdvertisedMicro,
14
+ withinAdvertisedTolerance
15
+ } from "./chunk-32AOWN2U.js";
16
+ import {
17
+ DvmError,
18
+ X402_V1_VERSION,
19
+ X402_VERSION,
20
+ buildPaymentRequirements,
21
+ chainIdFromCaip2,
22
+ encodePayment,
23
+ ensureAddress,
24
+ msatsToUsd,
25
+ msatsToUsdc,
26
+ usdToMsats,
27
+ usdcContractFor,
28
+ usdcDomainNameFor,
29
+ usdcDomainVersionFor,
30
+ usdcToMsats,
31
+ x402NetworkByCaip2,
32
+ x402NetworkToCaip2
33
+ } from "./chunk-JTMBSEZO.js";
34
+
35
+ // src/lib/x402/client.ts
36
+ import { randomBytes } from "crypto";
37
+
38
+ // src/lib/output.ts
39
+ import { writeSync } from "fs";
40
+ var _traceId = null;
41
+ function setOutputTraceId(id) {
42
+ _traceId = id;
43
+ }
44
+ function getOutputTraceId() {
45
+ return _traceId;
46
+ }
47
+ function json(data) {
48
+ const out = _traceId !== null && typeof data === "object" && data !== null && !Array.isArray(data) && !("trace_id" in data) ? { trace_id: _traceId, ...data } : data;
49
+ writeAllSync(1, JSON.stringify(out) + "\n");
50
+ }
51
+ function info(msg) {
52
+ writeAllSync(2, msg + "\n");
53
+ }
54
+ function raw(msg) {
55
+ writeAllSync(1, msg + "\n");
56
+ }
57
+ function progress(event) {
58
+ writeAllSync(2, JSON.stringify(event) + "\n");
59
+ }
60
+ function writeAllSync(fd, text) {
61
+ const buf = Buffer.from(text, "utf8");
62
+ let offset = 0;
63
+ while (offset < buf.length) {
64
+ try {
65
+ offset += writeSync(fd, buf, offset, buf.length - offset);
66
+ } catch (err) {
67
+ const code = err.code;
68
+ if (code === "EAGAIN" || code === "EINTR") continue;
69
+ throw err;
70
+ }
71
+ }
72
+ }
73
+
74
+ // src/lib/btc-rate.ts
75
+ async function resolveBtcUsdRate(purpose) {
76
+ try {
77
+ return { rate: await fetchBtcUsdRate(), stale: false };
78
+ } catch {
79
+ const cached = getLastKnownBtcRate();
80
+ if (cached) {
81
+ warnStaleRate(cached.cachedAt);
82
+ return { rate: cached.rate, stale: true, cachedAt: cached.cachedAt };
83
+ }
84
+ throw rateUnavailable(purpose);
85
+ }
86
+ }
87
+ async function tryResolveBtcUsdRate() {
88
+ try {
89
+ return await resolveBtcUsdRate("conversion");
90
+ } catch {
91
+ return null;
92
+ }
93
+ }
94
+ function staleRateNotice(resolved) {
95
+ if (!resolved?.stale || resolved.cachedAt === void 0) return void 0;
96
+ const age = formatStaleness(resolved.cachedAt);
97
+ return {
98
+ cached_at: new Date(resolved.cachedAt).toISOString(),
99
+ age,
100
+ display: `Priced with a BTC/USD rate cached ${age} \u2014 the rate provider is unreachable, so dollar figures may have drifted.`
101
+ };
102
+ }
103
+ var warnedStale = false;
104
+ function warnStaleRate(cachedAt) {
105
+ if (warnedStale) return;
106
+ warnedStale = true;
107
+ info(
108
+ `Warning: the BTC/USD rate provider is unreachable \u2014 using the last rate this machine saw (cached ${formatStaleness(cachedAt)}). Dollar figures may have drifted.`
109
+ );
110
+ }
111
+ function rateUnavailable(purpose) {
112
+ const outcome = purpose === "payment" ? "nothing was paid" : "no conversion was performed";
113
+ const noun = purpose === "payment" ? "payment" : "conversion";
114
+ const capped = outcome.charAt(0).toUpperCase() + outcome.slice(1);
115
+ return new DvmError(
116
+ "rate_unavailable",
117
+ `Could not price this ${noun}: the BTC/USD rate provider is unreachable and no cached rate is available.`,
118
+ `${capped}. The rate provider (CoinGecko) is rate-limiting or down, and this machine has never cached a rate. Retry in a minute; if it keeps failing, check network access to api.coingecko.com.${purpose === "payment" ? " Budgets are denominated in dollars, so a payment cannot be authorised without a rate." : ""}`,
119
+ {
120
+ display: `BTC/USD rate unavailable \u2014 ${outcome}.`,
121
+ anchor: "rate_unavailable",
122
+ purpose,
123
+ provider: "coingecko",
124
+ retryable: true
125
+ }
126
+ );
127
+ }
128
+
129
+ // src/lib/currency.ts
130
+ function formatSats(msats) {
131
+ if (msats === 0) return "0 sats";
132
+ if (msats < 1e3) return `${msats.toLocaleString("en-US")} msats`;
133
+ if (msats % 1e3 === 0) return `${(msats / 1e3).toLocaleString("en-US")} sats`;
134
+ return `${Math.round(msats / 1e3 * 100) / 100} sats`;
135
+ }
136
+ function formatAmount(msats, rate, opts) {
137
+ const usd = msatsToUsd(msats, rate);
138
+ const base = `~$${formatUsd(usd)} (${formatSats(msats)})`;
139
+ return opts?.anchor === false ? base : `${base} \u2014 ${costAnchor(usd)}`;
140
+ }
141
+ function formatPaymentAmount(msats, fiat, opts) {
142
+ if (!fiat || fiat.amount <= 0) return formatAmountBestEffort(msats, opts);
143
+ const base = `${formatFiat(fiat.amount, fiat.currency)} (${formatSats(msats)})`;
144
+ return opts?.anchor === false ? base : `${base} \u2014 ${costAnchor(fiat.amount, fiat.currency)}`;
145
+ }
146
+ var COST_ANCHOR_BANDS = {
147
+ usd: [0.01, 0.1, 1, 10],
148
+ eur: [0.01, 0.1, 1, 10],
149
+ gbp: [0.01, 0.1, 1, 10],
150
+ jpy: [1, 10, 100, 1500]
151
+ };
152
+ function costAnchor(amount, currency = "usd") {
153
+ const bands = COST_ANCHOR_BANDS[currency] ?? COST_ANCHOR_BANDS.usd;
154
+ if (amount < bands[0]) return "fraction of a cent";
155
+ if (amount <= bands[1]) return "comparable to an API call";
156
+ if (amount <= bands[2]) return "comparable to a ChatGPT query";
157
+ if (amount <= bands[3]) return "comparable to a coffee";
158
+ return "significant purchase \u2014 review carefully";
159
+ }
160
+ function monetaryJson(msats, rate) {
161
+ const usd = msatsToUsd(msats, rate);
162
+ return {
163
+ msats,
164
+ usd: Math.round(usd * 100) / 100,
165
+ anchor: costAnchor(usd),
166
+ display: formatAmount(msats, rate)
167
+ };
168
+ }
169
+ function parseBudget(budget, rate) {
170
+ const value = assertValidBudget(budget);
171
+ return budget.startsWith("$") ? usdToMsats(value, rate) : value;
172
+ }
173
+ function assertValidBudget(budget) {
174
+ const value = budget.startsWith("$") ? parseFloat(budget.slice(1)) : parseInt(budget, 10);
175
+ if (isNaN(value)) throw new Error(`Invalid budget: ${budget}`);
176
+ return value;
177
+ }
178
+ function formatAmountBestEffort(msats, opts) {
179
+ const m = msats ?? 0;
180
+ const cached = getLastKnownBtcRate();
181
+ if (cached === null) return `${Math.round(m / 1e3)} sats`;
182
+ const base = formatAmount(m, cached.rate, opts);
183
+ if (Date.now() - cached.cachedAt < FX_CACHE_TTL_MS) return base;
184
+ return `${base} (rate cached ${formatStaleness(cached.cachedAt)})`;
185
+ }
186
+
187
+ // src/lib/x402/client.ts
188
+ async function tryX402Payment(request, wallet) {
189
+ const selection = selectPaymentRequirement(request);
190
+ let networkSlug;
191
+ let networkCaip2;
192
+ let chainId;
193
+ let usdc;
194
+ try {
195
+ networkCaip2 = x402NetworkToCaip2(selection.network);
196
+ const mapped = x402NetworkByCaip2(networkCaip2);
197
+ networkSlug = mapped?.slug ?? selection.network;
198
+ chainId = chainIdFromCaip2(networkCaip2);
199
+ usdc = usdcContractFor(networkSlug);
200
+ } catch (err) {
201
+ throw new DvmError(
202
+ "x402_build_failed",
203
+ `Could not resolve x402 network from '${selection.network}': ${err instanceof Error ? err.message : String(err)}`,
204
+ "Check that the DVM's advertised x402.network is a CAIP-2 chain id (e.g. 'eip155:8453' for Base)."
205
+ );
206
+ }
207
+ if (!usdc) return null;
208
+ const rate = await priceableRate(request.btcRate);
209
+ if (rate === null) return null;
210
+ const localUsdcMicro = BigInt(msatsToUsdc(request.amountMsats, rate));
211
+ const requiredUsdcMicro = resolveRequiredUsdcMicro(selection.amount, localUsdcMicro);
212
+ const signedAmountMsats = usdcToMsats(Number(requiredUsdcMicro) / 1e6, rate);
213
+ try {
214
+ const w = await ensureAddress(wallet);
215
+ const validAfter = 0n;
216
+ const validBefore = BigInt(
217
+ Math.floor(Date.now() / 1e3) + X402_EXACT_AUTHORIZATION_TTL_SECONDS
218
+ );
219
+ const nonce = request.nonce ?? `0x${randomBytes(32).toString("hex")}`;
220
+ const domainName = selectedDomainField(selection.accepted?.extra?.name, "name") ?? usdcDomainNameFor(networkSlug) ?? "USD Coin";
221
+ const domainVersion = selectedDomainField(selection.accepted?.extra?.version, "version") ?? usdcDomainVersionFor(networkSlug) ?? "2";
222
+ const { signTypedData } = await import("./accounts-2WZE4N5F.js");
223
+ const signature = await signTypedData({
224
+ privateKey: w.privateKey,
225
+ domain: {
226
+ name: domainName,
227
+ version: domainVersion,
228
+ chainId,
229
+ verifyingContract: usdc
230
+ },
231
+ types: {
232
+ TransferWithAuthorization: [
233
+ { name: "from", type: "address" },
234
+ { name: "to", type: "address" },
235
+ { name: "value", type: "uint256" },
236
+ { name: "validAfter", type: "uint256" },
237
+ { name: "validBefore", type: "uint256" },
238
+ { name: "nonce", type: "bytes32" }
239
+ ]
240
+ },
241
+ primaryType: "TransferWithAuthorization",
242
+ message: {
243
+ from: w.address,
244
+ to: selection.payTo,
245
+ value: requiredUsdcMicro,
246
+ validAfter,
247
+ validBefore,
248
+ nonce
249
+ }
250
+ });
251
+ const exactPayload = {
252
+ signature,
253
+ payload: {
254
+ authorization: {
255
+ from: w.address,
256
+ to: selection.payTo,
257
+ value: requiredUsdcMicro.toString(),
258
+ validAfter: validAfter.toString(),
259
+ validBefore: validBefore.toString(),
260
+ nonce
261
+ }
262
+ }
263
+ };
264
+ const payload = selection.version === X402_V1_VERSION ? {
265
+ x402Version: X402_V1_VERSION,
266
+ scheme: "exact",
267
+ network: networkSlug,
268
+ payload: { signature: exactPayload.signature, ...exactPayload.payload }
269
+ } : {
270
+ x402Version: X402_VERSION,
271
+ ...selection.resource ? { resource: selection.resource } : {},
272
+ accepted: selection.accepted ?? buildPaymentRequirements({
273
+ x402Config: {
274
+ payTo: selection.payTo,
275
+ network: networkCaip2,
276
+ ...selection.asset ? { asset: selection.asset } : {}
277
+ },
278
+ requiredUsdcMicro,
279
+ resource: selection.resource?.url ?? "",
280
+ version: X402_VERSION
281
+ }),
282
+ payload: { signature: exactPayload.signature, ...exactPayload.payload },
283
+ extensions: selection.extensions ?? {}
284
+ };
285
+ return {
286
+ paymentHeader: encodePayment(payload),
287
+ x402Version: selection.version,
288
+ amountUsdcMicro: requiredUsdcMicro.toString(),
289
+ amountMsats: signedAmountMsats,
290
+ btcRate: rate
291
+ };
292
+ } catch (err) {
293
+ throw new DvmError(
294
+ "x402_build_failed",
295
+ `Failed to build x402 payment: ${err instanceof Error ? err.message : String(err)}`,
296
+ "Check the configured x402 private key and RPC reachability for the target chain."
297
+ );
298
+ }
299
+ }
300
+ function selectPaymentRequirement(request) {
301
+ const challenge = request.paymentRequired;
302
+ if (challenge?.x402Version === X402_VERSION) {
303
+ const accepted = challenge.accepts.find(isSignableExactRequirement);
304
+ if (!accepted) {
305
+ throw invalidChallenge("The DVM's v2 x402 challenge has no exact EIP-3009 requirement.");
306
+ }
307
+ return {
308
+ version: X402_VERSION,
309
+ network: accepted.network,
310
+ amount: accepted.amount,
311
+ payTo: accepted.payTo,
312
+ asset: accepted.asset,
313
+ accepted,
314
+ resource: challenge.resource,
315
+ extensions: challenge.extensions
316
+ };
317
+ }
318
+ if (challenge?.x402Version === X402_V1_VERSION) {
319
+ const accepted = challenge.accepts.find((candidate) => candidate.scheme === "exact");
320
+ if (!accepted) throw invalidChallenge("The DVM's v1 x402 challenge has no exact requirement.");
321
+ return {
322
+ version: X402_V1_VERSION,
323
+ network: accepted.network,
324
+ amount: accepted.maxAmountRequired,
325
+ payTo: accepted.payTo,
326
+ asset: accepted.asset
327
+ };
328
+ }
329
+ return {
330
+ version: request.x402Version ?? X402_V1_VERSION,
331
+ network: request.network,
332
+ amount: request.requiredUsdcMicro,
333
+ payTo: request.payTo,
334
+ asset: request.asset,
335
+ resource: request.resource
336
+ };
337
+ }
338
+ function invalidChallenge(message) {
339
+ return new DvmError(
340
+ "x402_build_failed",
341
+ message,
342
+ "Ask the DVM operator to advertise an exact x402 payment requirement."
343
+ );
344
+ }
345
+ function selectedDomainField(value, field) {
346
+ if (value === void 0 || value === null) return void 0;
347
+ if (typeof value === "string" && value.length > 0) return value;
348
+ throw invalidChallenge(`The DVM advertised an invalid x402 ${field}.`);
349
+ }
350
+ function resolveRequiredUsdcMicro(advertised, localUsdcMicro) {
351
+ if (advertised === void 0) return localUsdcMicro;
352
+ if (!/^[1-9]\d*$/.test(advertised)) {
353
+ throw new DvmError(
354
+ "x402_amount_invalid",
355
+ `The DVM advertised an invalid x402 maxAmountRequired: '${advertised}'.`,
356
+ "Do not sign this payment. Ask the DVM operator to return a positive integer number of USDC micro-units."
357
+ );
358
+ }
359
+ const required = BigInt(advertised);
360
+ if (withinAdvertisedTolerance(required, localUsdcMicro)) return required;
361
+ const advertisedUsd = Number(required) / 1e6;
362
+ const localUsd = Number(localUsdcMicro) / 1e6;
363
+ throw new DvmError(
364
+ "x402_amount_exceeds_limit",
365
+ `The DVM's x402 charge ($${formatUsd(advertisedUsd)} USDC) is more than 10% above the caller's local price ($${formatUsd(localUsd)} USDC).`,
366
+ "The payment was not signed. Refresh the quote or ask the DVM operator to check its BTC/USD rate.",
367
+ {
368
+ advertised_usdc_microunits: required.toString(),
369
+ local_usdc_microunits: localUsdcMicro.toString(),
370
+ max_usdc_microunits: maxAdvertisedMicro(localUsdcMicro).toString(),
371
+ anchor: costAnchor(advertisedUsd),
372
+ display: `Payment refused: $${formatUsd(advertisedUsd)} USDC exceeds the 10% safety margin over the caller's $${formatUsd(localUsd)} USDC estimate.`
373
+ }
374
+ );
375
+ }
376
+ async function priceableRate(btcRate) {
377
+ if (btcRate && btcRate > 0) return btcRate;
378
+ try {
379
+ return (await resolveBtcUsdRate("payment")).rate;
380
+ } catch (err) {
381
+ if (err instanceof DvmError && err.code === "rate_unavailable") {
382
+ info(
383
+ "Skipping the x402 rail: it prices in USDC and the BTC/USD rate is unavailable (no cached rate on this machine). Trying the remaining rails."
384
+ );
385
+ return null;
386
+ }
387
+ throw err;
388
+ }
389
+ }
390
+
391
+ export {
392
+ setOutputTraceId,
393
+ getOutputTraceId,
394
+ json,
395
+ info,
396
+ raw,
397
+ progress,
398
+ formatAmount,
399
+ formatPaymentAmount,
400
+ costAnchor,
401
+ monetaryJson,
402
+ parseBudget,
403
+ assertValidBudget,
404
+ formatAmountBestEffort,
405
+ resolveBtcUsdRate,
406
+ tryResolveBtcUsdRate,
407
+ staleRateNotice,
408
+ tryX402Payment
409
+ };
@@ -2,7 +2,7 @@
2
2
  import { createRequire as __dvmCreateRequire } from "node:module";
3
3
  const require = __dvmCreateRequire(import.meta.url);
4
4
 
5
- // node_modules/@dvmkit/sdk/dist/chunk-ETXDTUJO.js
5
+ // node_modules/@dvmkit/sdk/dist/chunk-LAKP6FUI.js
6
6
  import { isIP } from "net";
7
7
  var diagnostic_catalogue_v1_default = {
8
8
  version: 1,
@@ -1000,9 +1000,61 @@ var diagnostic_catalogue_v1_default = {
1000
1000
  ],
1001
1001
  clientVersionFields: [
1002
1002
  "client.version"
1003
+ ],
1004
+ paymentSkipReasons: [
1005
+ "credit_or_draw_missing",
1006
+ "draw_not_pending",
1007
+ "draw_job_mismatch",
1008
+ "rail_mismatch",
1009
+ "channel_binding_mismatch",
1010
+ "denomination_unavailable",
1011
+ "topup_cap_unavailable",
1012
+ "topup_cap_currency_mismatch",
1013
+ "unknown"
1014
+ ],
1015
+ denominationCauses: [
1016
+ "no_msats",
1017
+ "sub_micro",
1018
+ "unsupported_currency",
1019
+ "rate_unavailable",
1020
+ "rate_stale_refused",
1021
+ "unknown"
1022
+ ],
1023
+ paymentFailureCategories: [
1024
+ "invalid_challenge",
1025
+ "malformed_credential",
1026
+ "payment_expired",
1027
+ "verification_failed",
1028
+ "insufficient_funds",
1029
+ "invalid_signature",
1030
+ "unsupported_method",
1031
+ "replay_detected",
1032
+ "ledger_refused",
1033
+ "settlement_failed",
1034
+ "unsupported_version",
1035
+ "unknown"
1036
+ ],
1037
+ paymentFailureStages: [
1038
+ "verifier",
1039
+ "broadcast",
1040
+ "verifier_broadcast",
1041
+ "replay_store",
1042
+ "funding_ledger",
1043
+ "unknown"
1044
+ ],
1045
+ paymentPhases: [
1046
+ "upfront",
1047
+ "mid-job"
1003
1048
  ]
1004
1049
  };
1005
1050
  var DIAGNOSTIC_CATALOGUE_VERSION = diagnostic_catalogue_v1_default.version;
1051
+ var PAYMENT_ENUMS = {
1052
+ reason: new Set(diagnostic_catalogue_v1_default.paymentSkipReasons),
1053
+ cause: new Set(diagnostic_catalogue_v1_default.denominationCauses),
1054
+ failure_category: new Set(diagnostic_catalogue_v1_default.paymentFailureCategories),
1055
+ failure_stage: new Set(diagnostic_catalogue_v1_default.paymentFailureStages),
1056
+ phase: new Set(diagnostic_catalogue_v1_default.paymentPhases)
1057
+ };
1006
1058
  var EVENTS = new Set(diagnostic_catalogue_v1_default.events);
1007
1059
  var ROUTE_TEMPLATES = [...diagnostic_catalogue_v1_default.routeTemplates].sort(
1008
1060
  compareRouteTemplates
@@ -1202,6 +1254,9 @@ function projectFields(input, dataset, authority, identityAuthority) {
1202
1254
  return output;
1203
1255
  }
1204
1256
  function projectField(key, value, dataset, authority, identityAuthority) {
1257
+ const paymentEnum = Object.hasOwn(PAYMENT_ENUMS, key) ? PAYMENT_ENUMS[key] : void 0;
1258
+ if (paymentEnum)
1259
+ return typeof value === "string" && paymentEnum.has(value) ? value : void 0;
1205
1260
  if (BOOLEAN_FIELDS.has(key))
1206
1261
  return typeof value === "boolean" ? value : void 0;
1207
1262
  if (INTEGER_FIELDS.has(key))
@@ -1422,86 +1477,6 @@ function ownValue2(input, key) {
1422
1477
  }
1423
1478
  }
1424
1479
 
1425
- // node_modules/@dvmkit/sdk/dist/chunk-COYKJRMM.js
1426
- import { AsyncLocalStorage } from "async_hooks";
1427
- var SDK_INIT_ADVISORY_LOCK = 17320927;
1428
- async function withSdkInitLock(db, fn) {
1429
- const context = activeInits.getStore();
1430
- if (context?.get(db)?.active) return fn();
1431
- assertPoolFitsLock(db);
1432
- let holder = holders.get(db);
1433
- if (holder) {
1434
- holder.refs += 1;
1435
- } else {
1436
- holder = { refs: 1, acquired: acquire(db), tail: Promise.resolve() };
1437
- holders.set(db, holder);
1438
- }
1439
- const predecessor = holder.tail;
1440
- let finishTurn;
1441
- holder.tail = new Promise((resolve) => {
1442
- finishTurn = resolve;
1443
- });
1444
- let guardedFailed = false;
1445
- try {
1446
- await holder.acquired;
1447
- await predecessor;
1448
- const token = { active: true };
1449
- const nextContext = new Map(context);
1450
- nextContext.set(db, token);
1451
- try {
1452
- return await activeInits.run(nextContext, fn);
1453
- } finally {
1454
- token.active = false;
1455
- }
1456
- } catch (err) {
1457
- guardedFailed = true;
1458
- throw err;
1459
- } finally {
1460
- try {
1461
- await releaseHolder(db, holder, guardedFailed);
1462
- } finally {
1463
- finishTurn();
1464
- }
1465
- }
1466
- }
1467
- var holders = /* @__PURE__ */ new WeakMap();
1468
- var activeInits = new AsyncLocalStorage();
1469
- function assertPoolFitsLock(db) {
1470
- const max = db.options?.max;
1471
- if (max === void 0 || max >= 2) return;
1472
- throw new Error(
1473
- `withSdkInitLock: the SDK boot lock needs a pool that allows at least 2 connections (got max=${max}). The lock is held on one pinned client while the guarded DDL runs on another, so boot would hang forever.`
1474
- );
1475
- }
1476
- async function acquire(db) {
1477
- const client = await db.connect();
1478
- try {
1479
- await client.query(`SELECT pg_advisory_lock(${SDK_INIT_ADVISORY_LOCK})`);
1480
- } catch (err) {
1481
- client.release();
1482
- throw err;
1483
- }
1484
- return client;
1485
- }
1486
- async function releaseHolder(db, holder, guardedFailed) {
1487
- holder.refs -= 1;
1488
- if (holder.refs > 0) return;
1489
- holders.delete(db);
1490
- let client;
1491
- try {
1492
- client = await holder.acquired;
1493
- } catch {
1494
- return;
1495
- }
1496
- try {
1497
- await client.query(`SELECT pg_advisory_unlock(${SDK_INIT_ADVISORY_LOCK})`);
1498
- client.release();
1499
- } catch (err) {
1500
- client.release(err instanceof Error ? err : new Error(String(err)));
1501
- if (!guardedFailed) throw err;
1502
- }
1503
- }
1504
-
1505
1480
  export {
1506
1481
  DIAGNOSTIC_CATALOGUE_VERSION,
1507
1482
  createDiagnosticCapabilityAuthority,
@@ -1512,6 +1487,5 @@ export {
1512
1487
  projectDiagnosticFields,
1513
1488
  projectEventName,
1514
1489
  diagnosticConsole,
1515
- emitDiagnostic,
1516
- withSdkInitLock
1490
+ emitDiagnostic
1517
1491
  };
@@ -15,11 +15,11 @@ import {
15
15
  sha384,
16
16
  sha512,
17
17
  toBytes,
18
- toHex,
18
+ toHex2 as toHex,
19
19
  toRpcList,
20
20
  validate,
21
21
  yParityToV
22
- } from "./chunk-LH3QPVN6.js";
22
+ } from "./chunk-TAZWRWM4.js";
23
23
  import {
24
24
  BaseError,
25
25
  concat,
@@ -40,7 +40,7 @@ import {
40
40
  toNumber2 as toNumber,
41
41
  toString,
42
42
  trimLeft2 as trimLeft
43
- } from "./chunk-F55NNH2F.js";
43
+ } from "./chunk-FOWQ7R7S.js";
44
44
  import {
45
45
  __export
46
46
  } from "./chunk-IYHTITNZ.js";
@@ -28,11 +28,7 @@ import {
28
28
  toSubscriptionPeriodSeconds,
29
29
  validateCredentialHeaderValue,
30
30
  verifySubscriptionKeyAuthorization
31
- } from "./chunk-MJ4X4BEW.js";
32
- import {
33
- KeyAuthorization_exports,
34
- tempo
35
- } from "./chunk-BECPI5H5.js";
31
+ } from "./chunk-6LP4EGKA.js";
36
32
  import {
37
33
  Assets_exports2 as Assets_exports,
38
34
  Chains_exports,
@@ -46,7 +42,7 @@ import {
46
42
  networkOf,
47
43
  resolve as resolve2,
48
44
  toSource
49
- } from "./chunk-FL2ICZW5.js";
45
+ } from "./chunk-SYFKO6BA.js";
50
46
  import {
51
47
  _minLength,
52
48
  amount,
@@ -68,16 +64,20 @@ import {
68
64
  toClient,
69
65
  toPaymentRequirements,
70
66
  transform
71
- } from "./chunk-WTM2EICO.js";
67
+ } from "./chunk-PUOXBKY2.js";
68
+ import {
69
+ KeyAuthorization_exports,
70
+ tempo
71
+ } from "./chunk-B4WHUMZM.js";
72
72
  import {
73
73
  Hash_exports,
74
74
  parseUnits
75
- } from "./chunk-LH3QPVN6.js";
75
+ } from "./chunk-TAZWRWM4.js";
76
76
  import {
77
77
  Bytes_exports,
78
78
  Hex_exports,
79
79
  isAddressEqual
80
- } from "./chunk-F55NNH2F.js";
80
+ } from "./chunk-FOWQ7R7S.js";
81
81
  import {
82
82
  getAddress
83
83
  } from "./chunk-MLDUKBU3.js";
@@ -7,7 +7,7 @@ import {
7
7
  sessionClient,
8
8
  stripe,
9
9
  tempo
10
- } from "./chunk-XHOFQ3OS.js";
10
+ } from "./chunk-Y3SQD37C.js";
11
11
  import {
12
12
  Fetch_exports,
13
13
  Transport_exports,
@@ -18,22 +18,22 @@ import {
18
18
  session3 as session2,
19
19
  sessionManager,
20
20
  sessionManager2
21
- } from "./chunk-MJ4X4BEW.js";
22
- import "./chunk-BECPI5H5.js";
21
+ } from "./chunk-6LP4EGKA.js";
23
22
  import "./chunk-N3UJT2NJ.js";
24
- import "./chunk-FL2ICZW5.js";
23
+ import "./chunk-SYFKO6BA.js";
25
24
  import {
26
25
  Constants_exports,
27
26
  Expires_exports
28
- } from "./chunk-WTM2EICO.js";
29
- import "./chunk-EZHT2RLJ.js";
27
+ } from "./chunk-PUOXBKY2.js";
30
28
  import "./chunk-EVQERRCP.js";
31
- import "./chunk-CJTE5TS3.js";
32
- import "./chunk-GZWKCIYN.js";
33
- import "./chunk-LH3QPVN6.js";
29
+ import "./chunk-B4WHUMZM.js";
30
+ import "./chunk-X7SEGALJ.js";
31
+ import "./chunk-ESOJUXVY.js";
32
+ import "./chunk-QXMKABL7.js";
33
+ import "./chunk-TAZWRWM4.js";
34
34
  import "./chunk-6O27TEXD.js";
35
35
  import "./chunk-65EY7CT4.js";
36
- import "./chunk-F55NNH2F.js";
36
+ import "./chunk-FOWQ7R7S.js";
37
37
  import "./chunk-MLDUKBU3.js";
38
38
  import "./chunk-7OK7MBT6.js";
39
39
  import "./chunk-IYHTITNZ.js";