@dvmkit/sdk 0.7.0-rc.1 → 0.7.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/{chunk-S3OY533W.js → chunk-26W6GPCD.js} +48 -6
- package/dist/{chunk-FWGWLPXF.js → chunk-2OM2QPBE.js} +2 -2
- package/dist/{chunk-GY66THYI.js → chunk-3UK3CDOT.js} +186 -90
- package/dist/{chunk-CXCQLOOK.js → chunk-62FI3NJF.js} +42 -107
- package/dist/{chunk-VHNPVGSA.js → chunk-6STC5TCP.js} +3 -3
- package/dist/{chunk-N5RZ5HVB.js → chunk-72V5DTEC.js} +2 -2
- package/dist/chunk-A262WVYX.js +6 -0
- package/dist/{chunk-QR2EF2NI.js → chunk-AQ7OX5NX.js} +2 -2
- package/dist/{chunk-BYCEKO65.js → chunk-CLIAFTUR.js} +102 -13
- package/dist/{chunk-GAOAYHZA.js → chunk-DNG4KGSC.js} +3 -3
- package/dist/{chunk-Z4ZT5LNT.js → chunk-GSLS4464.js} +3 -3
- package/dist/{chunk-RA2WIX7G.js → chunk-H5FVVEEN.js} +18 -7
- package/dist/{chunk-IXR5RFK7.js → chunk-HCE4MPZ5.js} +1 -1
- package/dist/{chunk-OML32F6I.js → chunk-I555L2WK.js} +1 -1
- package/dist/{chunk-EQLA4FFY.js → chunk-IIZQNDQU.js} +3 -3
- package/dist/{chunk-FUJ36YDV.js → chunk-KXWROQGK.js} +24 -1
- package/dist/{chunk-ETXDTUJO.js → chunk-LAKP6FUI.js} +55 -0
- package/dist/{chunk-X7EZ5CLI.js → chunk-MON76YBJ.js} +3 -3
- package/dist/chunk-OFSOLHRX.js +120 -0
- package/dist/{chunk-IV6Q7NRW.js → chunk-RAGX6VG7.js} +2 -2
- package/dist/{chunk-KA6VN5FK.js → chunk-RXPHMS4C.js} +3 -3
- package/dist/{chunk-6XF3RVVX.js → chunk-SPYEJXI7.js} +5 -5
- package/dist/{chunk-P6QON7ER.js → chunk-TRNMTTPX.js} +1 -1
- package/dist/{chunk-RCM3P2HE.js → chunk-UKD3R2KU.js} +55 -4
- package/dist/chunk-USL7ZEXN.js +17 -0
- package/dist/{chunk-KMED3H3A.js → chunk-VB5OLOZH.js} +395 -231
- package/dist/{content-retention-DHyLdA6b.d.ts → content-retention-ChFSSVO0.d.ts} +1 -1
- package/dist/{credit-ledger-MCUXYKSJ.js → credit-ledger-7Z7LOCTN.js} +4 -4
- package/dist/{credit-menu-DjnkeEUU.d.ts → credit-menu-fy0DDigm.d.ts} +6 -6
- package/dist/{fx-zMWFzfrU.d.ts → fx-DM0_NYiE.d.ts} +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +236 -16
- package/dist/internal/caller.d.ts +4968 -8286
- package/dist/internal/caller.js +4291 -8084
- package/dist/internal/index.js +1 -1
- package/dist/internal/server.d.ts +7 -7
- package/dist/internal/server.js +27 -30
- package/dist/{job-store-DdLXBpol.d.ts → job-store-DkfNE9sv.d.ts} +1 -1
- package/dist/{lightning-backend-Bw-qtAbt.d.ts → lightning-backend-C3Gf1XpP.d.ts} +2 -2
- package/dist/{memory-credit-ledger-SBSMGMDX.js → memory-credit-ledger-3WOS74UH.js} +5 -5
- package/dist/{mpp-setup-RF5FXGGV.js → mpp-setup-XB4KATMU.js} +2 -2
- package/dist/{payout-reporter-3Y2U55ZX.js → payout-reporter-WT7XYW42.js} +2 -2
- package/dist/{postgres-consumed-credential-store-BUVCAPLS.js → postgres-consumed-credential-store-W7UP33AH.js} +3 -3
- package/dist/{postgres-job-store-VHLQBJZC.js → postgres-job-store-3KGUGFRD.js} +2 -2
- package/dist/{postgres-replay-store-ARZSQ45X.js → postgres-replay-store-CVNJJOQG.js} +2 -2
- package/dist/{pricing-XT2IAPNE.js → pricing-QAVZUTZR.js} +12 -12
- package/dist/{revenue-reporter-MAERPYGK.js → revenue-reporter-7UR3W2SD.js} +2 -2
- package/dist/server/index.d.ts +10 -10
- package/dist/server/index.js +44 -48
- package/dist/{step-cache-2MkvenJn.d.ts → step-cache-DDTwd4SK.d.ts} +6 -2
- package/dist/{tempo-charge-store-Q3D7KYMH.js → tempo-charge-store-GA6CED6O.js} +2 -2
- package/dist/{tempo-session-store-ZRNCOX7P.js → tempo-session-store-WZWQRITB.js} +3 -3
- package/dist/testing/index.d.ts +3 -3
- package/dist/testing/index.js +6 -7
- package/dist/{usd-DI3d3gTK.d.ts → usd-DkRy9nfU.d.ts} +1 -1
- package/dist/{x402-FT4S4JS4.js → x402-ZU4GML7Z.js} +8 -27
- package/package.json +1 -1
- package/dist/chunk-66HGCPBU.js +0 -25
- package/dist/chunk-AT6V3SY7.js +0 -102
- package/dist/chunk-EZXAJ6EI.js +0 -1082
- package/dist/chunk-HCLVYZUZ.js +0 -244
- package/dist/chunk-JEVLNAO3.js +0 -1668
- package/dist/chunk-NFMOPYBA.js +0 -357
- package/dist/chunk-O2OTZ5GP.js +0 -1869
- package/dist/chunk-OFVV37XC.js +0 -57
- package/dist/chunk-SZVXOQ75.js +0 -211
- package/dist/chunk-WBOKPC37.js +0 -795
- package/dist/tempo-lifecycle-GJ77YKVY.js +0 -15
- package/dist/tempo-wallet-X2GGAZ6X.js +0 -40
package/README.md
CHANGED
|
@@ -92,12 +92,16 @@ Builders can pass `onPaidJobCompleted` to observe settled customer charges after
|
|
|
92
92
|
- A `credit` block opts into reusable prepaid balances and their reclaim obligations. Reusable channels return undrawn collateral through their channel lifecycle; one-payment stablecoin funding is disabled unless `allowOneShotStablecoin: true` because it creates manual refunds. Run and monitor the documented reclaim/payout worker.
|
|
93
93
|
- Honour `ctx.signal`, use `ctx.fetch` for abortable provider calls, and declare provider cost with `ctx.cost` only after the durable step that incurred it.
|
|
94
94
|
|
|
95
|
+
Reusable x402 channels default to a 24-hour payer withdrawal grace (86400 seconds) on every network. For Base Sepolia (`eip155:84532`) acceptance tests, set `x402.batchSettlement.withdrawDelay: 900` or `DVMKIT_X402_WITHDRAW_DELAY_SECONDS=900` with `DVMKIT_X402_BATCH_SETTLEMENT=true`. Explicit delays must be integer seconds and at least 900 on Base Sepolia; Base mainnet retains the 86400 minimum even in development mode and still requires self-relay. The grace is bound into each channel's immutable configuration: changing the server setting affects new channels, not existing deposits. A shorter testnet run exercises early-withdrawal refusal and post-deadline recovery; retain a separate 24-hour run to cover next-day recovery.
|
|
96
|
+
|
|
95
97
|
For Bitcoin credit monitoring, `GET /admin/credit/bitcoin-liability` reports exact in-kind obligations in satoshis. Uncovered and basisless credits need live-rate pricing on reclaim, so their whole balances appear in `uncovered_by_currency` and `unbacked_by_currency` as `{ currency, micro, credits }` entries. Sum the credit counts if useful, but display or price each currency separately. Older consumers must replace the former `uncovered_micro` and `unbacked_micro` scalar reads; the [portable response fixture](./protocol-fixtures/bitcoin-liability.json) shows the full shape.
|
|
96
98
|
|
|
97
99
|
The public [SDK guide](https://dvmkit.com/docs/sdk) covers signed requests, custom routes, rail configuration, credit reclaim, persistence, and deployment in depth. The [protocol guide](https://dvmkit.com/docs/protocol) specifies the HTTP contract.
|
|
98
100
|
|
|
99
101
|
## Diagnostic retention
|
|
100
102
|
|
|
103
|
+
[Payment diagnostics](./docs/DIAGNOSTICS.md) documents the closed failure categories, stages, and top-up causes retained by safe logging sinks.
|
|
104
|
+
|
|
101
105
|
The SDK advertises 730 days of retention for sanitized diagnostics in every existing span dataset: `platform`, `cashu`, `lightning`, `stripe`, `x402`, `tempo`, `isolate`, `audit`, and `cron`. Dataset names, producer permissions, and query semantics remain unchanged; only operator services may write to `audit`.
|
|
102
106
|
|
|
103
107
|
This metadata describes the retention schedule. The SDK does not automatically delete diagnostics or override platform destruction or case controls. The platform must enforce the schedule and those controls.
|
|
@@ -1,9 +1,34 @@
|
|
|
1
1
|
import {
|
|
2
2
|
X402_DEFAULT_FACILITATOR
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-62FI3NJF.js";
|
|
4
4
|
import {
|
|
5
5
|
callerLoggers
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-KXWROQGK.js";
|
|
7
|
+
import {
|
|
8
|
+
diagnosticConsole
|
|
9
|
+
} from "./chunk-LAKP6FUI.js";
|
|
10
|
+
|
|
11
|
+
// src/observability/payment-diagnostics.ts
|
|
12
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
13
|
+
var scopes = new AsyncLocalStorage();
|
|
14
|
+
function withPaymentDiagnostics(fn) {
|
|
15
|
+
return scopes.run({}, fn);
|
|
16
|
+
}
|
|
17
|
+
async function withPaymentStage(stage, fn) {
|
|
18
|
+
try {
|
|
19
|
+
return await fn();
|
|
20
|
+
} catch (error) {
|
|
21
|
+
const scope = scopes.getStore();
|
|
22
|
+
if (scope && (!scope.failure || !Object.is(scope.failure.error, error))) {
|
|
23
|
+
scope.failure = { error, stage };
|
|
24
|
+
}
|
|
25
|
+
throw error;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function paymentFailureStage(error) {
|
|
29
|
+
const failure = scopes.getStore()?.failure;
|
|
30
|
+
return failure && Object.is(failure.error, error) ? failure.stage : "unknown";
|
|
31
|
+
}
|
|
7
32
|
|
|
8
33
|
// src/lib/x402/facilitator.ts
|
|
9
34
|
import { createPrivateKey, randomBytes } from "crypto";
|
|
@@ -82,7 +107,7 @@ async function verifyWithFacilitator(payload, requirements, config = {}, createA
|
|
|
82
107
|
return callerLoggers.x402.span(
|
|
83
108
|
"x402.verify_with_facilitator",
|
|
84
109
|
{ facilitator_url: url },
|
|
85
|
-
async () => {
|
|
110
|
+
() => withPaymentStage("verifier", async () => {
|
|
86
111
|
const authHeaders = (await createAuthHeaders?.())?.verify ?? {};
|
|
87
112
|
const res = await fetch(url, {
|
|
88
113
|
method: "POST",
|
|
@@ -96,14 +121,17 @@ async function verifyWithFacilitator(payload, requirements, config = {}, createA
|
|
|
96
121
|
if (!res.ok) {
|
|
97
122
|
const rejection = await readFacilitatorRejection(res);
|
|
98
123
|
if (rejection?.isValid === false && typeof rejection.invalidReason === "string" && rejection.invalidReason.length > 0) {
|
|
124
|
+
logRejected("verifier");
|
|
99
125
|
return rejection;
|
|
100
126
|
}
|
|
127
|
+
logRejected("verifier");
|
|
101
128
|
return { isValid: false, invalidReason: `facilitator_status_${res.status}` };
|
|
102
129
|
}
|
|
103
130
|
const data = await res.json();
|
|
131
|
+
if (!data.isValid) logRejected("verifier");
|
|
104
132
|
callerLoggers.x402.info("x402.verify_with_facilitator.result", { is_valid: data.isValid });
|
|
105
133
|
return data;
|
|
106
|
-
}
|
|
134
|
+
})
|
|
107
135
|
);
|
|
108
136
|
}
|
|
109
137
|
async function settleWithFacilitator(payload, requirements, config = {}, createAuthHeaders = createX402FacilitatorAuthHeaders(config)) {
|
|
@@ -112,7 +140,7 @@ async function settleWithFacilitator(payload, requirements, config = {}, createA
|
|
|
112
140
|
return callerLoggers.x402.span(
|
|
113
141
|
"x402.settle_with_facilitator",
|
|
114
142
|
{ facilitator_url: url },
|
|
115
|
-
async () => {
|
|
143
|
+
() => withPaymentStage("broadcast", async () => {
|
|
116
144
|
const authHeaders = (await createAuthHeaders?.())?.settle ?? {};
|
|
117
145
|
const res = await fetch(url, {
|
|
118
146
|
method: "POST",
|
|
@@ -126,17 +154,20 @@ async function settleWithFacilitator(payload, requirements, config = {}, createA
|
|
|
126
154
|
if (!res.ok) {
|
|
127
155
|
const rejection = await readFacilitatorRejection(res);
|
|
128
156
|
if (rejection?.success === false && typeof rejection.errorReason === "string" && rejection.errorReason.length > 0) {
|
|
157
|
+
logRejected("broadcast");
|
|
129
158
|
return rejection;
|
|
130
159
|
}
|
|
160
|
+
logRejected("broadcast");
|
|
131
161
|
return { success: false, errorReason: `facilitator_status_${res.status}` };
|
|
132
162
|
}
|
|
133
163
|
const data = await res.json();
|
|
164
|
+
if (!data.success) logRejected("broadcast");
|
|
134
165
|
callerLoggers.x402.info("x402.settle_with_facilitator.result", {
|
|
135
166
|
success: data.success,
|
|
136
167
|
tx_hash: data.transaction
|
|
137
168
|
});
|
|
138
169
|
return data;
|
|
139
|
-
}
|
|
170
|
+
})
|
|
140
171
|
);
|
|
141
172
|
}
|
|
142
173
|
async function readFacilitatorRejection(res) {
|
|
@@ -151,8 +182,19 @@ async function readFacilitatorRejection(res) {
|
|
|
151
182
|
function isRecord(value) {
|
|
152
183
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
153
184
|
}
|
|
185
|
+
function logRejected(stage) {
|
|
186
|
+
diagnosticConsole.warn({
|
|
187
|
+
event: "x402_credential_rejected",
|
|
188
|
+
rail: "x402",
|
|
189
|
+
failure_category: stage === "verifier" ? "verification_failed" : "settlement_failed",
|
|
190
|
+
failure_stage: stage
|
|
191
|
+
});
|
|
192
|
+
}
|
|
154
193
|
|
|
155
194
|
export {
|
|
195
|
+
withPaymentDiagnostics,
|
|
196
|
+
withPaymentStage,
|
|
197
|
+
paymentFailureStage,
|
|
156
198
|
createX402FacilitatorAuthHeaders,
|
|
157
199
|
createX402FacilitatorClient,
|
|
158
200
|
verifyWithFacilitator,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
callerLoggers
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-KXWROQGK.js";
|
|
4
4
|
import {
|
|
5
5
|
diagnosticConsole,
|
|
6
6
|
projectSpanRow
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-LAKP6FUI.js";
|
|
8
8
|
|
|
9
9
|
// src/lib/x402/env.ts
|
|
10
10
|
import { isAddress } from "viem";
|