@dvmkit/sdk 0.1.0-rc.3 → 0.1.0-rc.4
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/{chunk-FT7IM66W.js → chunk-2K6UXDAN.js} +1 -1
- package/dist/{chunk-C2DC4FKR.js → chunk-4UVRXDNY.js} +330 -9
- package/dist/{chunk-XY5Y5REG.js → chunk-AAJNGQMC.js} +1 -1
- package/dist/{chunk-YD3TZNXV.js → chunk-EDU6COY2.js} +17 -2
- package/dist/{chunk-5SO7ZVOH.js → chunk-F2L6KIMD.js} +5 -0
- package/dist/{chunk-RHP3BRTH.js → chunk-GJD7PVWY.js} +3 -3
- package/dist/{credit-menu-DONAtGVf.d.ts → credit-menu-ClA1JyYW.d.ts} +2 -2
- package/dist/{fx-Bq4cvn16.d.ts → fx-ptKVFOwq.d.ts} +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/internal/index.d.ts +158 -7
- package/dist/internal/index.js +34 -6
- package/dist/{job-store-m2pYmvbr.d.ts → job-store-DxFqDPYq.d.ts} +6 -1
- package/dist/server/index.d.ts +5 -5
- package/dist/server/index.js +5 -213
- package/dist/testing/index.d.ts +1 -1
- package/dist/{usd-DjVAPMlf.d.ts → usd-Cha_j80I.d.ts} +1 -1
- package/dist/{x402-5EVIUSEP.js → x402-XXFQQAAD.js} +4 -4
- package/package.json +1 -1
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
verifyWithFacilitator,
|
|
18
18
|
x402NetworkByCaip2,
|
|
19
19
|
x402NetworkToCaip2
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-AAJNGQMC.js";
|
|
21
21
|
import {
|
|
22
22
|
AGENT_MNEMONIC_FILE,
|
|
23
23
|
BUILDER_CONFIG_DIR,
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
msatsToUsdc,
|
|
35
35
|
resolveRpcOverride,
|
|
36
36
|
usdcToMsats
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-F2L6KIMD.js";
|
|
38
38
|
import {
|
|
39
39
|
MemoryCreditLedger
|
|
40
40
|
} from "./chunk-EXHBXA4U.js";
|
|
@@ -4365,7 +4365,7 @@ async function verifyUpfrontPayment(opts) {
|
|
|
4365
4365
|
x402Requirements
|
|
4366
4366
|
});
|
|
4367
4367
|
}
|
|
4368
|
-
const { verifyX402Payment } = await import("./x402-
|
|
4368
|
+
const { verifyX402Payment } = await import("./x402-XXFQQAAD.js");
|
|
4369
4369
|
const receipt = await verifyX402Payment(
|
|
4370
4370
|
x402Payment,
|
|
4371
4371
|
x402Config,
|
|
@@ -5285,7 +5285,7 @@ async function verifyIncomingPayment(body, opts, snapshot) {
|
|
|
5285
5285
|
snapshot
|
|
5286
5286
|
});
|
|
5287
5287
|
}
|
|
5288
|
-
const { verifyX402Payment } = await import("./x402-
|
|
5288
|
+
const { verifyX402Payment } = await import("./x402-XXFQQAAD.js");
|
|
5289
5289
|
const receipt = await verifyX402Payment(
|
|
5290
5290
|
body.content.x402_payment,
|
|
5291
5291
|
opts.x402Config,
|
|
@@ -5695,7 +5695,7 @@ async function processIncomingPayment(job, body, opts) {
|
|
|
5695
5695
|
try {
|
|
5696
5696
|
const requiredMsats = job.pendingPaymentMsats ?? 0;
|
|
5697
5697
|
const requiredUsdcMicro = job.pendingX402AmountUsdcMicro !== void 0 ? BigInt(job.pendingX402AmountUsdcMicro) : BigInt(msatsToUsdc(requiredMsats, rate));
|
|
5698
|
-
const { verifyX402Payment } = await import("./x402-
|
|
5698
|
+
const { verifyX402Payment } = await import("./x402-XXFQQAAD.js");
|
|
5699
5699
|
const receipt = await verifyX402Payment(
|
|
5700
5700
|
body.content.x402_payment,
|
|
5701
5701
|
opts.x402Config,
|
|
@@ -9237,6 +9237,280 @@ function fail(code, variable, message, expectedAddress) {
|
|
|
9237
9237
|
throw new X402EnvValidationError(code, variable, message, expectedAddress);
|
|
9238
9238
|
}
|
|
9239
9239
|
|
|
9240
|
+
// src/observability/span-writer.ts
|
|
9241
|
+
var noop = () => {
|
|
9242
|
+
};
|
|
9243
|
+
var SPANS_INSERTED_CHANNEL = "spans_inserted";
|
|
9244
|
+
var MAX_BUFFERED_SPANS = 1e4;
|
|
9245
|
+
var MAX_ROW_JSONB_BYTES = 64 * 1024;
|
|
9246
|
+
var MAX_STRING_VALUE_BYTES = 4 * 1024;
|
|
9247
|
+
var FLUSH_THRESHOLD = 1e3;
|
|
9248
|
+
var MAX_BACKOFF_EXPONENT = 6;
|
|
9249
|
+
var SpanWriter = class {
|
|
9250
|
+
constructor(transport, flushIntervalMs = 1e4) {
|
|
9251
|
+
this.transport = transport;
|
|
9252
|
+
this.flushIntervalMs = flushIntervalMs;
|
|
9253
|
+
}
|
|
9254
|
+
transport;
|
|
9255
|
+
flushIntervalMs;
|
|
9256
|
+
buffer = [];
|
|
9257
|
+
flushTimer = null;
|
|
9258
|
+
flushing = false;
|
|
9259
|
+
dropCount = 0;
|
|
9260
|
+
truncatedSpanCount = 0;
|
|
9261
|
+
consecutiveFailures = 0;
|
|
9262
|
+
backoffTimer = null;
|
|
9263
|
+
/** Enqueue a span row. Non-blocking — truncates oversize JSONB and appends to buffer. */
|
|
9264
|
+
enqueue(row) {
|
|
9265
|
+
const originalBytes = JSON.stringify({
|
|
9266
|
+
attributes: row.attributes,
|
|
9267
|
+
dimensions: row.dimensions
|
|
9268
|
+
}).length;
|
|
9269
|
+
if (originalBytes > MAX_ROW_JSONB_BYTES) {
|
|
9270
|
+
row = this.truncateForSize(row, originalBytes);
|
|
9271
|
+
}
|
|
9272
|
+
if (this.buffer.length >= MAX_BUFFERED_SPANS) {
|
|
9273
|
+
this.dropCount++;
|
|
9274
|
+
if (this.dropCount === 1 || this.dropCount % 1e3 === 0) {
|
|
9275
|
+
console.error(
|
|
9276
|
+
JSON.stringify({
|
|
9277
|
+
event: "span_buffer_drop",
|
|
9278
|
+
reason: "buffer_full",
|
|
9279
|
+
total_dropped: this.dropCount,
|
|
9280
|
+
buffer_size: this.buffer.length
|
|
9281
|
+
})
|
|
9282
|
+
);
|
|
9283
|
+
}
|
|
9284
|
+
return;
|
|
9285
|
+
}
|
|
9286
|
+
this.buffer.push(row);
|
|
9287
|
+
if (this.buffer.length >= FLUSH_THRESHOLD && !this.flushing) {
|
|
9288
|
+
void this.flush().catch(noop);
|
|
9289
|
+
}
|
|
9290
|
+
}
|
|
9291
|
+
/** Start periodic flush to the transport. */
|
|
9292
|
+
startFlush() {
|
|
9293
|
+
this.flushTimer = setInterval(() => {
|
|
9294
|
+
void this.flush().catch(noop);
|
|
9295
|
+
}, this.flushIntervalMs);
|
|
9296
|
+
}
|
|
9297
|
+
/** Stop periodic flush. */
|
|
9298
|
+
stopFlush() {
|
|
9299
|
+
if (this.flushTimer) {
|
|
9300
|
+
clearInterval(this.flushTimer);
|
|
9301
|
+
this.flushTimer = null;
|
|
9302
|
+
}
|
|
9303
|
+
if (this.backoffTimer) {
|
|
9304
|
+
clearTimeout(this.backoffTimer);
|
|
9305
|
+
this.backoffTimer = null;
|
|
9306
|
+
}
|
|
9307
|
+
}
|
|
9308
|
+
/** Flush buffered spans. Single-flight: concurrent calls exit early. */
|
|
9309
|
+
async flush() {
|
|
9310
|
+
if (this.flushing) return;
|
|
9311
|
+
if (this.buffer.length === 0) return;
|
|
9312
|
+
this.flushing = true;
|
|
9313
|
+
const batch = this.buffer;
|
|
9314
|
+
this.buffer = [];
|
|
9315
|
+
try {
|
|
9316
|
+
await this.transport.send(batch);
|
|
9317
|
+
this.consecutiveFailures = 0;
|
|
9318
|
+
} catch (err) {
|
|
9319
|
+
this.consecutiveFailures++;
|
|
9320
|
+
console.error(
|
|
9321
|
+
JSON.stringify({
|
|
9322
|
+
event: "span_flush_failed",
|
|
9323
|
+
error: err instanceof Error ? err.message : String(err),
|
|
9324
|
+
batch_size: batch.length,
|
|
9325
|
+
consecutive_failures: this.consecutiveFailures
|
|
9326
|
+
})
|
|
9327
|
+
);
|
|
9328
|
+
const room = MAX_BUFFERED_SPANS - this.buffer.length;
|
|
9329
|
+
if (room > 0) {
|
|
9330
|
+
this.buffer.unshift(...batch.slice(0, room));
|
|
9331
|
+
}
|
|
9332
|
+
if (this.consecutiveFailures > 1) {
|
|
9333
|
+
const exponent = Math.min(this.consecutiveFailures - 1, MAX_BACKOFF_EXPONENT);
|
|
9334
|
+
const backoffMs = this.flushIntervalMs * Math.pow(2, exponent);
|
|
9335
|
+
this.stopFlush();
|
|
9336
|
+
this.backoffTimer = setTimeout(() => {
|
|
9337
|
+
this.backoffTimer = null;
|
|
9338
|
+
this.startFlush();
|
|
9339
|
+
}, backoffMs);
|
|
9340
|
+
}
|
|
9341
|
+
} finally {
|
|
9342
|
+
this.flushing = false;
|
|
9343
|
+
}
|
|
9344
|
+
}
|
|
9345
|
+
/** Flush remaining spans on shutdown. */
|
|
9346
|
+
async shutdown() {
|
|
9347
|
+
this.stopFlush();
|
|
9348
|
+
await this.flush();
|
|
9349
|
+
}
|
|
9350
|
+
/** Number of spans dropped due to buffer overflow. */
|
|
9351
|
+
getDropCount() {
|
|
9352
|
+
return this.dropCount;
|
|
9353
|
+
}
|
|
9354
|
+
/** Number of spans truncated due to oversized JSONB payload. */
|
|
9355
|
+
getTruncatedSpanCount() {
|
|
9356
|
+
return this.truncatedSpanCount;
|
|
9357
|
+
}
|
|
9358
|
+
/** Current buffer size. */
|
|
9359
|
+
getBufferSize() {
|
|
9360
|
+
return this.buffer.length;
|
|
9361
|
+
}
|
|
9362
|
+
/** Consecutive flush failures; resets to 0 on the next successful flush. */
|
|
9363
|
+
getConsecutiveFailures() {
|
|
9364
|
+
return this.consecutiveFailures;
|
|
9365
|
+
}
|
|
9366
|
+
/**
|
|
9367
|
+
* Two-pass truncation: cap individual string values, then fall back to
|
|
9368
|
+
* wholesale attribute replacement if the blob is still over the limit.
|
|
9369
|
+
*/
|
|
9370
|
+
truncateForSize(row, originalBytes) {
|
|
9371
|
+
const truncatedAttrs = {};
|
|
9372
|
+
for (const [key, value] of Object.entries(row.attributes)) {
|
|
9373
|
+
if (typeof value === "string" && value.length > MAX_STRING_VALUE_BYTES) {
|
|
9374
|
+
const omitted = value.length - MAX_STRING_VALUE_BYTES;
|
|
9375
|
+
truncatedAttrs[key] = `${value.slice(0, MAX_STRING_VALUE_BYTES)}\u2026 [truncated, ${omitted} chars omitted]`;
|
|
9376
|
+
} else {
|
|
9377
|
+
truncatedAttrs[key] = value;
|
|
9378
|
+
}
|
|
9379
|
+
}
|
|
9380
|
+
const afterStringPass = JSON.stringify({
|
|
9381
|
+
attributes: truncatedAttrs,
|
|
9382
|
+
dimensions: row.dimensions
|
|
9383
|
+
}).length;
|
|
9384
|
+
let mode;
|
|
9385
|
+
if (afterStringPass <= MAX_ROW_JSONB_BYTES) {
|
|
9386
|
+
row = { ...row, attributes: truncatedAttrs };
|
|
9387
|
+
mode = "string_pass";
|
|
9388
|
+
} else {
|
|
9389
|
+
const dimSize = JSON.stringify(row.dimensions).length;
|
|
9390
|
+
if (dimSize > MAX_ROW_JSONB_BYTES) {
|
|
9391
|
+
console.error(
|
|
9392
|
+
JSON.stringify({
|
|
9393
|
+
event: "span_dimension_oversized",
|
|
9394
|
+
name: row.name,
|
|
9395
|
+
dataset: row.dataset,
|
|
9396
|
+
dimension_bytes: dimSize
|
|
9397
|
+
})
|
|
9398
|
+
);
|
|
9399
|
+
}
|
|
9400
|
+
row = {
|
|
9401
|
+
...row,
|
|
9402
|
+
attributes: {
|
|
9403
|
+
_truncated: true,
|
|
9404
|
+
original_bytes: originalBytes,
|
|
9405
|
+
original_keys: Object.keys(row.attributes).sort()
|
|
9406
|
+
}
|
|
9407
|
+
};
|
|
9408
|
+
mode = "wholesale_fallback";
|
|
9409
|
+
}
|
|
9410
|
+
this.truncatedSpanCount++;
|
|
9411
|
+
if (this.truncatedSpanCount === 1 || this.truncatedSpanCount % 100 === 0) {
|
|
9412
|
+
console.error(
|
|
9413
|
+
JSON.stringify({
|
|
9414
|
+
event: "span_truncated",
|
|
9415
|
+
name: row.name,
|
|
9416
|
+
dataset: row.dataset,
|
|
9417
|
+
original_bytes: originalBytes,
|
|
9418
|
+
after_string_pass_bytes: afterStringPass,
|
|
9419
|
+
mode,
|
|
9420
|
+
total_truncated: this.truncatedSpanCount
|
|
9421
|
+
})
|
|
9422
|
+
);
|
|
9423
|
+
}
|
|
9424
|
+
return row;
|
|
9425
|
+
}
|
|
9426
|
+
};
|
|
9427
|
+
var SPAN_COLUMNS = [
|
|
9428
|
+
"span_id",
|
|
9429
|
+
"trace_id",
|
|
9430
|
+
"parent_span_id",
|
|
9431
|
+
"dataset",
|
|
9432
|
+
"name",
|
|
9433
|
+
"level",
|
|
9434
|
+
"status",
|
|
9435
|
+
"started_at_ms",
|
|
9436
|
+
"ended_at_ms",
|
|
9437
|
+
"service",
|
|
9438
|
+
"service_version",
|
|
9439
|
+
"host",
|
|
9440
|
+
"pid",
|
|
9441
|
+
"dimensions",
|
|
9442
|
+
"attributes",
|
|
9443
|
+
"error_message",
|
|
9444
|
+
"error_stack",
|
|
9445
|
+
"sample_rate"
|
|
9446
|
+
];
|
|
9447
|
+
async function insertSpanBatch(pool, rows) {
|
|
9448
|
+
if (rows.length === 0) return;
|
|
9449
|
+
const values = [];
|
|
9450
|
+
const placeholders = [];
|
|
9451
|
+
let idx = 1;
|
|
9452
|
+
for (const row of rows) {
|
|
9453
|
+
const rowPlaceholders = [];
|
|
9454
|
+
for (const col of SPAN_COLUMNS) {
|
|
9455
|
+
let val = row[col] ?? null;
|
|
9456
|
+
if (col === "sample_rate" && val == null) {
|
|
9457
|
+
val = 1;
|
|
9458
|
+
}
|
|
9459
|
+
if (col === "dimensions" || col === "attributes") {
|
|
9460
|
+
rowPlaceholders.push(`$${idx}::jsonb`);
|
|
9461
|
+
values.push(typeof val === "string" ? val : JSON.stringify(val ?? {}));
|
|
9462
|
+
} else {
|
|
9463
|
+
rowPlaceholders.push(`$${idx}`);
|
|
9464
|
+
values.push(val);
|
|
9465
|
+
}
|
|
9466
|
+
idx++;
|
|
9467
|
+
}
|
|
9468
|
+
placeholders.push(`(${rowPlaceholders.join(", ")})`);
|
|
9469
|
+
}
|
|
9470
|
+
await pool.query(
|
|
9471
|
+
`INSERT INTO observability.spans (${SPAN_COLUMNS.join(", ")})
|
|
9472
|
+
VALUES ${placeholders.join(",\n")}
|
|
9473
|
+
ON CONFLICT (dataset, span_id) DO NOTHING`,
|
|
9474
|
+
values
|
|
9475
|
+
);
|
|
9476
|
+
try {
|
|
9477
|
+
await pool.query(`SELECT pg_notify('${SPANS_INSERTED_CHANNEL}', '')`);
|
|
9478
|
+
} catch {
|
|
9479
|
+
}
|
|
9480
|
+
}
|
|
9481
|
+
var DbTransport = class {
|
|
9482
|
+
constructor(pool) {
|
|
9483
|
+
this.pool = pool;
|
|
9484
|
+
}
|
|
9485
|
+
pool;
|
|
9486
|
+
async send(rows) {
|
|
9487
|
+
await insertSpanBatch(this.pool, rows);
|
|
9488
|
+
}
|
|
9489
|
+
};
|
|
9490
|
+
var HttpTransport = class {
|
|
9491
|
+
constructor(platformUrl, serviceToken) {
|
|
9492
|
+
this.platformUrl = platformUrl;
|
|
9493
|
+
this.serviceToken = serviceToken;
|
|
9494
|
+
}
|
|
9495
|
+
platformUrl;
|
|
9496
|
+
serviceToken;
|
|
9497
|
+
async send(rows) {
|
|
9498
|
+
if (rows.length === 0) return;
|
|
9499
|
+
const resp = await fetch(`${this.platformUrl.replace(/\/$/, "")}/_internal/spans`, {
|
|
9500
|
+
method: "POST",
|
|
9501
|
+
headers: {
|
|
9502
|
+
"Content-Type": "application/json",
|
|
9503
|
+
Authorization: `Bearer ${this.serviceToken}`
|
|
9504
|
+
},
|
|
9505
|
+
body: JSON.stringify({ spans: rows })
|
|
9506
|
+
});
|
|
9507
|
+
if (!resp.ok) {
|
|
9508
|
+
const text = await resp.text().catch(() => "");
|
|
9509
|
+
throw new Error(`Span ingestion failed: ${resp.status} ${text}`);
|
|
9510
|
+
}
|
|
9511
|
+
}
|
|
9512
|
+
};
|
|
9513
|
+
|
|
9240
9514
|
// src/lib/builder-identity.ts
|
|
9241
9515
|
import {
|
|
9242
9516
|
chmodSync as chmodSync3,
|
|
@@ -9802,20 +10076,35 @@ function formatPaid(msats, rate) {
|
|
|
9802
10076
|
return `~$${formatUsd(usd)} (${satsLabel}, ${costAnchor(usd)})`;
|
|
9803
10077
|
}
|
|
9804
10078
|
|
|
9805
|
-
// src/lib/cashu/admin-auth.ts
|
|
9806
|
-
import { randomBytes as randomBytes3 } from "crypto";
|
|
9807
|
-
import { sha256 as sha2564 } from "@noble/hashes/sha2.js";
|
|
9808
|
-
|
|
9809
10079
|
// src/lib/wallet-agent/sign.ts
|
|
9810
10080
|
import { schnorr as schnorr4 } from "@noble/curves/secp256k1.js";
|
|
9811
10081
|
|
|
9812
10082
|
// src/lib/wallet-agent/keypair.ts
|
|
9813
10083
|
import { secp256k1 as secp256k12 } from "@noble/curves/secp256k1.js";
|
|
10084
|
+
var PRIVKEY_HEX_RE = /^[0-9a-f]{64}$/i;
|
|
9814
10085
|
|
|
9815
10086
|
// src/lib/wallet-agent/sign.ts
|
|
9816
10087
|
var PUBKEY_COMPRESSED_HEX_RE = /^0[23][0-9a-f]{64}$/i;
|
|
9817
10088
|
var PUBKEY_XONLY_HEX_RE = /^[0-9a-f]{64}$/i;
|
|
9818
10089
|
var SIG_HEX_RE = /^[0-9a-f]{128}$/i;
|
|
10090
|
+
function signChallenge(privkeyHex, challenge) {
|
|
10091
|
+
if (!PRIVKEY_HEX_RE.test(privkeyHex)) {
|
|
10092
|
+
throw new DvmError(
|
|
10093
|
+
"invalid_privkey",
|
|
10094
|
+
"Privkey must be 64 hex characters (32 bytes).",
|
|
10095
|
+
"Provide a valid secp256k1 private key as a 64-char hex string."
|
|
10096
|
+
);
|
|
10097
|
+
}
|
|
10098
|
+
if (challenge.length !== 32) {
|
|
10099
|
+
throw new DvmError(
|
|
10100
|
+
"invalid_challenge",
|
|
10101
|
+
`Challenge must be exactly 32 bytes; got ${challenge.length}.`,
|
|
10102
|
+
"Pass the SHA-256 digest output (32 bytes)."
|
|
10103
|
+
);
|
|
10104
|
+
}
|
|
10105
|
+
const sig = schnorr4.sign(challenge, hexToBytes4(privkeyHex));
|
|
10106
|
+
return bytesToHex4(sig);
|
|
10107
|
+
}
|
|
9819
10108
|
function verifyChallenge(pubkeyHex, challenge, sigHex) {
|
|
9820
10109
|
if (!SIG_HEX_RE.test(sigHex)) return false;
|
|
9821
10110
|
if (challenge.length !== 32) return false;
|
|
@@ -9836,8 +10125,13 @@ function verifyChallenge(pubkeyHex, challenge, sigHex) {
|
|
|
9836
10125
|
function hexToBytes4(hex) {
|
|
9837
10126
|
return Uint8Array.from(Buffer.from(hex, "hex"));
|
|
9838
10127
|
}
|
|
10128
|
+
function bytesToHex4(bytes) {
|
|
10129
|
+
return Buffer.from(bytes).toString("hex");
|
|
10130
|
+
}
|
|
9839
10131
|
|
|
9840
10132
|
// src/lib/cashu/admin-auth.ts
|
|
10133
|
+
import { randomBytes as randomBytes3 } from "crypto";
|
|
10134
|
+
import { sha256 as sha2564 } from "@noble/hashes/sha2.js";
|
|
9841
10135
|
var ADMIN_AUTH_NONCE_TTL_SECONDS = 300;
|
|
9842
10136
|
var ADMIN_AUTH_CLOCK_SKEW_SECONDS = 30;
|
|
9843
10137
|
var ADMIN_STATE_UNAVAILABLE = "admin_state_unavailable";
|
|
@@ -9845,6 +10139,25 @@ function buildAdminChallenge(args) {
|
|
|
9845
10139
|
const msg = `dvmkit-admin:${args.method}:${args.path}:${args.dvmId}:${args.nonceHex}:${args.unixSeconds}`;
|
|
9846
10140
|
return sha2564(new TextEncoder().encode(msg));
|
|
9847
10141
|
}
|
|
10142
|
+
function buildAdminAuthHeader(args) {
|
|
10143
|
+
const nowMs = args.now ? args.now() : Date.now();
|
|
10144
|
+
const unixSeconds = Math.floor(nowMs / 1e3);
|
|
10145
|
+
const nonceBytes = args.randomNonce ? args.randomNonce() : Uint8Array.from(randomBytes3(16));
|
|
10146
|
+
const nonceHex = Buffer.from(nonceBytes).toString("hex");
|
|
10147
|
+
const challenge = buildAdminChallenge({
|
|
10148
|
+
method: args.method,
|
|
10149
|
+
path: args.path,
|
|
10150
|
+
dvmId: args.dvmId,
|
|
10151
|
+
nonceHex,
|
|
10152
|
+
unixSeconds
|
|
10153
|
+
});
|
|
10154
|
+
const sigHex = signChallenge(args.privkeyHex, challenge);
|
|
10155
|
+
return {
|
|
10156
|
+
header: `P2PK ${nonceHex}.${unixSeconds}.${sigHex}`,
|
|
10157
|
+
nonceHex,
|
|
10158
|
+
unixSeconds
|
|
10159
|
+
};
|
|
10160
|
+
}
|
|
9848
10161
|
|
|
9849
10162
|
// src/sdk/server/admin-cashu.ts
|
|
9850
10163
|
import { CheckStateEnum as CheckStateEnum2 } from "@cashu/cashu-ts";
|
|
@@ -21353,6 +21666,11 @@ export {
|
|
|
21353
21666
|
X402_RPC_URL_KEY,
|
|
21354
21667
|
X402EnvValidationError,
|
|
21355
21668
|
validateX402Env,
|
|
21669
|
+
SPANS_INSERTED_CHANNEL,
|
|
21670
|
+
SpanWriter,
|
|
21671
|
+
insertSpanBatch,
|
|
21672
|
+
DbTransport,
|
|
21673
|
+
HttpTransport,
|
|
21356
21674
|
generateIdentity,
|
|
21357
21675
|
loadIdentitySecret,
|
|
21358
21676
|
writeIdentity,
|
|
@@ -21384,7 +21702,10 @@ export {
|
|
|
21384
21702
|
epochMsToIso,
|
|
21385
21703
|
receiptHint,
|
|
21386
21704
|
receiptFailureDetail,
|
|
21705
|
+
verifyChallenge,
|
|
21706
|
+
ADMIN_STATE_UNAVAILABLE,
|
|
21387
21707
|
buildAdminChallenge,
|
|
21708
|
+
buildAdminAuthHeader,
|
|
21388
21709
|
installAdminCashuRoutes,
|
|
21389
21710
|
createAdminCashuNonceStore,
|
|
21390
21711
|
X402ExactSettlementServer,
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
maxAdvertisedMicro,
|
|
7
7
|
normalizeCreditEndpoint,
|
|
8
8
|
withinAdvertisedTolerance
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-2K6UXDAN.js";
|
|
10
10
|
import {
|
|
11
11
|
DvmError,
|
|
12
12
|
IDENTITIES_FILE,
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
formatUsd,
|
|
17
17
|
resolveRpcHttpTransportOptions,
|
|
18
18
|
resolveRpcOverride
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-F2L6KIMD.js";
|
|
20
20
|
import {
|
|
21
21
|
redactUrl,
|
|
22
22
|
redactUrlsInText
|
|
@@ -405,6 +405,20 @@ function shellQuoteArg(value) {
|
|
|
405
405
|
}
|
|
406
406
|
var SAFE_VALUE_RE = /^[a-zA-Z0-9_\-./@:=,+%]+$/;
|
|
407
407
|
|
|
408
|
+
// src/lib/rail-labels.ts
|
|
409
|
+
function fundingRailLabel(rail) {
|
|
410
|
+
switch (rail) {
|
|
411
|
+
case "cashu":
|
|
412
|
+
return "ecash";
|
|
413
|
+
case "lightning":
|
|
414
|
+
return "Lightning";
|
|
415
|
+
case "x402":
|
|
416
|
+
return "x402 stablecoin";
|
|
417
|
+
case "tempo":
|
|
418
|
+
return "Tempo stablecoin";
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
408
422
|
// src/lib/cli-identity-store.ts
|
|
409
423
|
import { schnorr } from "@noble/curves/secp256k1.js";
|
|
410
424
|
import { existsSync as existsSync2, readFileSync as readFileSync2, renameSync as renameSync2, unlinkSync, writeFileSync as writeFileSync2 } from "fs";
|
|
@@ -1018,6 +1032,7 @@ export {
|
|
|
1018
1032
|
listResumableTempoChargeFundings,
|
|
1019
1033
|
clearPendingTempoChargeFunding,
|
|
1020
1034
|
shellQuoteArg,
|
|
1035
|
+
fundingRailLabel,
|
|
1021
1036
|
findSigningIdentityByPubkey,
|
|
1022
1037
|
TEMPO_CHAIN_ID,
|
|
1023
1038
|
connectedTempoAccount,
|
|
@@ -29,6 +29,9 @@ function providerProseSources(...sources) {
|
|
|
29
29
|
}
|
|
30
30
|
return Object.keys(provenance).length > 0 ? provenance : void 0;
|
|
31
31
|
}
|
|
32
|
+
function isAbortError(err) {
|
|
33
|
+
return err instanceof Error && (err.name === "AbortError" || err.name === "TimeoutError");
|
|
34
|
+
}
|
|
32
35
|
function transportErrorCode(err) {
|
|
33
36
|
let current = err;
|
|
34
37
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -332,6 +335,7 @@ function resolveRpcHttpTransportOptions(source, envValue) {
|
|
|
332
335
|
export {
|
|
333
336
|
DvmError,
|
|
334
337
|
providerProseSources,
|
|
338
|
+
isAbortError,
|
|
335
339
|
transportErrorCode,
|
|
336
340
|
IMPLICIT_CREDIT_TTL_MS,
|
|
337
341
|
CONFIG_FILE,
|
|
@@ -352,6 +356,7 @@ export {
|
|
|
352
356
|
ensureConfigDir,
|
|
353
357
|
COINGECKO_SIMPLE_PRICE_URL,
|
|
354
358
|
fetchCoinGeckoSpot,
|
|
359
|
+
fetchCoinGeckoBtcUsd,
|
|
355
360
|
msatsToUsd,
|
|
356
361
|
usdToMsats,
|
|
357
362
|
msatsToUsdCents,
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
maxAdvertisedMicro,
|
|
9
9
|
updateConfig,
|
|
10
10
|
withinAdvertisedTolerance
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-2K6UXDAN.js";
|
|
12
12
|
import {
|
|
13
13
|
X402_DEFAULT_NETWORK,
|
|
14
14
|
X402_V1_VERSION,
|
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
x402NetworkByCaip2,
|
|
30
30
|
x402NetworkToCaip2,
|
|
31
31
|
x402SupportedNetworksHint
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-AAJNGQMC.js";
|
|
33
33
|
import {
|
|
34
34
|
DvmError,
|
|
35
35
|
X402_CHANNELS_FILE,
|
|
@@ -43,7 +43,7 @@ import {
|
|
|
43
43
|
resolveRpcHttpTransportOptions,
|
|
44
44
|
resolveRpcOverride,
|
|
45
45
|
usdcToMsats
|
|
46
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-F2L6KIMD.js";
|
|
47
47
|
import {
|
|
48
48
|
callerLoggers
|
|
49
49
|
} from "./chunk-66HGCPBU.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Hono, Context } from 'hono';
|
|
2
2
|
import { Pool } from 'pg';
|
|
3
|
-
import { X as JsonValue,
|
|
4
|
-
import { F as FxFetcher, b as FxRateSnapshot } from './fx-
|
|
3
|
+
import { X as JsonValue, bG as CreditLedgerLike, bP as CreditInvoiceRecord, cU as CreditDepositEnqueue, bQ as InvoiceSettlement, Z as ZodLike, a as DVMDescriptor, K as KVStore, o as JobStore, af as CashuMode, ap as MppxServer, a8 as X402Config, p as PaymentMethod, cj as ClientCompatibilityGate, a2 as Message, am as FundingMethod, Y as FundingReceipt, bI as CreditSnapshot, cV as TopUpCapUnenforcedReason, _ as JobReceipt, cc as AppendOutgoingOptions, S as SDKJobContext, aM as StepCache, v as ResponseContent, P as PaymentContent, J as JobRecord, a3 as MessageType, aa as X402Receipt, a9 as X402ExactVersionSupport, cW as X402SettlementIntent, az as PaymentRequirementsV2, bX as CreditLedgerQuerier, cX as X402SettlementCursor, bK as X402SettlementStatus, cY as X402SettlementWriteOff, bH as X402RefundSettlementGate, cZ as X402FacilitatorAuth, c_ as X402BatchSettlementConfig, cz as PostgresX402ChannelStorage, c$ as X402PayoutObserver, d0 as X402SettlementReconciliationReason, ax as PaymentRequirements, a1 as MppxCredential, ag as CreditDepositPayload, bJ as DrawResult, cp as CreditLedgerError, aD as ReceiptCredit, ai as DrainReceiptEvent, ah as DrainReceipt, z as SignedRequestAudience, d1 as CreditDrawReleaseEnqueue, cB as RevenueSkippedNoRailPayload, ch as ClientCompatibility, aA as PayoutReporter, R as ResolvedCreditConfig, g as CreditView } from './job-store-DxFqDPYq.js';
|
|
4
|
+
import { F as FxFetcher, b as FxRateSnapshot } from './fx-ptKVFOwq.js';
|
|
5
5
|
import { ProofLike, SerializedDLEQ } from '@cashu/cashu-ts';
|
|
6
6
|
import { Challenge } from 'mppx';
|
|
7
7
|
import { SettleResponse, SupportedResponse } from '@x402/core/types';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { C as Currency, Z as ZodLike, D as DVMConfig, a as DVMDescriptor } from './job-store-
|
|
2
|
-
export { A as ApprovalContent, b as ArtifactContent, c as CancelContent, d as CanonicalEnvelope, e as CreateSignedRequestVerifierOpts, f as CreditConfig, g as CreditView, h as DEFAULT_CREDIT_MAX, i as DEFAULT_CREDIT_MIN, j as DEFAULT_CREDIT_TTL_SECONDS, k as DVMRouteContext, I as IncomingMessage, l as InputType, m as InvalidCurrencyError, J as JobRecord, n as JobStatus, o as JobStore, K as KVStore, L as Logger, P as PaymentContent, p as PaymentMethod, q as PriceValue, r as ProgressContent, s as PromptOpts, Q as QuoteConfig, t as QuoteContext, u as QuoteResult, R as ResolvedCreditConfig, v as ResponseContent, S as SDKJobContext, w as SDKPaymentRequestOpts, x as SIGNED_REQUEST_AUTH_ID, y as SIGNED_REQUEST_STATEMENT_VERSION, z as SignedRequestAudience, B as SignedRequestDomain, E as SignedRequestError, F as SignedRequestFailure, G as SignedRequestReplayStore, H as SignedRequestSignOpts, M as SignedRequestStatementHeader, N as SignedRequestVerifier, U as UnsupportedCurrencyError, O as createSignedRequestVerifier, T as isZodSchema, V as signedRequestStatementHeader, W as validateCurrency } from './job-store-
|
|
3
|
-
export { C as CreateFxFetcherOpts, D as DEFAULT_FX_CURRENCIES, a as DEFAULT_FX_RATE_SOURCE, F as FxFetcher, b as FxRateSnapshot, c as FxRateUnavailableError, P as PlatformFxSource, d as createFxFetcher, f as fxRateFor, r as resolveFxSourceFromEnv } from './fx-
|
|
4
|
-
export { I as InvalidFxRateError, f as fiatToSatsCeil, a as formatFiat, b as formatUsd, r as roundUsd, s as satsToFiat } from './usd-
|
|
1
|
+
import { C as Currency, Z as ZodLike, D as DVMConfig, a as DVMDescriptor } from './job-store-DxFqDPYq.js';
|
|
2
|
+
export { A as ApprovalContent, b as ArtifactContent, c as CancelContent, d as CanonicalEnvelope, e as CreateSignedRequestVerifierOpts, f as CreditConfig, g as CreditView, h as DEFAULT_CREDIT_MAX, i as DEFAULT_CREDIT_MIN, j as DEFAULT_CREDIT_TTL_SECONDS, k as DVMRouteContext, I as IncomingMessage, l as InputType, m as InvalidCurrencyError, J as JobRecord, n as JobStatus, o as JobStore, K as KVStore, L as Logger, P as PaymentContent, p as PaymentMethod, q as PriceValue, r as ProgressContent, s as PromptOpts, Q as QuoteConfig, t as QuoteContext, u as QuoteResult, R as ResolvedCreditConfig, v as ResponseContent, S as SDKJobContext, w as SDKPaymentRequestOpts, x as SIGNED_REQUEST_AUTH_ID, y as SIGNED_REQUEST_STATEMENT_VERSION, z as SignedRequestAudience, B as SignedRequestDomain, E as SignedRequestError, F as SignedRequestFailure, G as SignedRequestReplayStore, H as SignedRequestSignOpts, M as SignedRequestStatementHeader, N as SignedRequestVerifier, U as UnsupportedCurrencyError, O as createSignedRequestVerifier, T as isZodSchema, V as signedRequestStatementHeader, W as validateCurrency } from './job-store-DxFqDPYq.js';
|
|
3
|
+
export { C as CreateFxFetcherOpts, D as DEFAULT_FX_CURRENCIES, a as DEFAULT_FX_RATE_SOURCE, F as FxFetcher, b as FxRateSnapshot, c as FxRateUnavailableError, P as PlatformFxSource, d as createFxFetcher, f as fxRateFor, r as resolveFxSourceFromEnv } from './fx-ptKVFOwq.js';
|
|
4
|
+
export { I as InvalidFxRateError, f as fiatToSatsCeil, a as formatFiat, b as formatUsd, r as roundUsd, s as satsToFiat } from './usd-Cha_j80I.js';
|
|
5
5
|
export { P as PinnedFetch, S as SSRFError, a as SSRFGuardOpts, b as SSRFReason, c as SSRFResolver, d as assertSafeUrl, e as createPinnedFetch } from './ssrf-DbFkpDv0.js';
|
|
6
6
|
export { z } from 'zod';
|
|
7
7
|
import '@cashu/cashu-ts';
|