@dvmkit/sdk 0.9.0 → 0.10.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.
Files changed (52) hide show
  1. package/dist/{chunk-4VV7WACY.js → chunk-2XQLL6N6.js} +1 -1
  2. package/dist/{chunk-LCCG5HQM.js → chunk-3Q6FTZDB.js} +2 -2
  3. package/dist/{chunk-TRY7BJA4.js → chunk-3R7NQA3Z.js} +1 -1
  4. package/dist/{chunk-KGL3YMZA.js → chunk-AJ6UHXUA.js} +1 -1
  5. package/dist/{chunk-BAQRUYRL.js → chunk-EWZFANHJ.js} +1 -1
  6. package/dist/{chunk-K2MSIKMM.js → chunk-FFXXGCVG.js} +1 -1
  7. package/dist/{chunk-WLPLHXNP.js → chunk-JNECYURT.js} +1 -1
  8. package/dist/{chunk-TFDR2YP2.js → chunk-KFCEXCZM.js} +1 -1
  9. package/dist/{chunk-IYQQXEHV.js → chunk-LDIPVPKI.js} +1 -1
  10. package/dist/{chunk-QSZW2I5Y.js → chunk-M3T5JYDJ.js} +15 -8
  11. package/dist/{chunk-Q3VYRU5R.js → chunk-MB6R4XPZ.js} +1 -1
  12. package/dist/{chunk-IBX2ORBV.js → chunk-MMGSYMIC.js} +1 -1
  13. package/dist/{chunk-LFVIZH2G.js → chunk-MU3IE434.js} +278 -152
  14. package/dist/{chunk-OIP44KBB.js → chunk-QGNXYVBO.js} +47 -12
  15. package/dist/{chunk-73C4JN2E.js → chunk-QNKK7SPY.js} +273 -54
  16. package/dist/{chunk-YYRY32NR.js → chunk-STJBBVNL.js} +2 -2
  17. package/dist/{chunk-WB3E7KE7.js → chunk-VMHYGKWT.js} +1 -1
  18. package/dist/{chunk-GAZBBMAA.js → chunk-VTHYQCDB.js} +1 -1
  19. package/dist/{chunk-LW7KZQHG.js → chunk-VUGEEMLT.js} +1 -1
  20. package/dist/{chunk-HC4I7LAV.js → chunk-W3VGCNG6.js} +1 -1
  21. package/dist/{chunk-GODOH2AF.js → chunk-Y6DO5WSO.js} +1 -1
  22. package/dist/{chunk-ZBQKXAYK.js → chunk-YOSZIWC3.js} +1 -1
  23. package/dist/{content-retention-CVBYehRS.d.ts → content-retention-CrILCNxk.d.ts} +1 -1
  24. package/dist/{credit-ledger-CZQ56DYI.js → credit-ledger-4PZNAMDT.js} +3 -3
  25. package/dist/{credit-menu-QntEhZJS.d.ts → credit-menu-VwX_6KM7.d.ts} +4 -4
  26. package/dist/{fx-CMyNFenZ.d.ts → fx-BM5h4o5S.d.ts} +1 -1
  27. package/dist/index.d.ts +5 -5
  28. package/dist/index.js +4 -4
  29. package/dist/internal/caller.d.ts +7 -7
  30. package/dist/internal/caller.js +7 -7
  31. package/dist/internal/server.d.ts +7 -7
  32. package/dist/internal/server.js +20 -20
  33. package/dist/{job-store-qOD-FrQF.d.ts → job-store-92v8e1LQ.d.ts} +1 -1
  34. package/dist/{lightning-backend-DtdG6UT5.d.ts → lightning-backend-9oky_wJi.d.ts} +1 -1
  35. package/dist/{memory-credit-ledger-EMN7G3MO.js → memory-credit-ledger-RP7DT5IY.js} +4 -4
  36. package/dist/{mpp-setup-VW53KFPO.js → mpp-setup-FURD45LI.js} +3 -3
  37. package/dist/{payout-reporter-TZX2S7KG.js → payout-reporter-HVJ6WUF3.js} +2 -2
  38. package/dist/{postgres-consumed-credential-store-V464OAJB.js → postgres-consumed-credential-store-WO6OCFXZ.js} +1 -1
  39. package/dist/{postgres-job-store-27VOCSPO.js → postgres-job-store-FSRUPYH2.js} +2 -2
  40. package/dist/{postgres-replay-store-7GJFAQXY.js → postgres-replay-store-XXJSA457.js} +2 -2
  41. package/dist/{pricing-NNMBNP7N.js → pricing-X4XU5HXY.js} +3 -3
  42. package/dist/{revenue-reporter-4EAVPWXS.js → revenue-reporter-EV3K5L6B.js} +2 -2
  43. package/dist/server/index.d.ts +74 -11
  44. package/dist/server/index.js +65 -27
  45. package/dist/{step-cache-B7svmPz3.d.ts → step-cache--7yA5Ihr.d.ts} +48 -6
  46. package/dist/{tempo-charge-store-2RPOJBM2.js → tempo-charge-store-5JOIYUIH.js} +2 -2
  47. package/dist/{tempo-session-store-LI3Q3A3U.js → tempo-session-store-S6QMLQUA.js} +3 -3
  48. package/dist/testing/index.d.ts +3 -3
  49. package/dist/testing/index.js +6 -6
  50. package/dist/{usd-D3izFz71.d.ts → usd-C7lvLvLk.d.ts} +1 -1
  51. package/dist/{x402-SL36LSOD.js → x402-EN5LSOVM.js} +3 -3
  52. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  PostgresReplayStore
3
- } from "../chunk-BAQRUYRL.js";
3
+ } from "../chunk-EWZFANHJ.js";
4
4
  import {
5
5
  PostgresKVStore
6
6
  } from "../chunk-V5ZRATJH.js";
@@ -18,7 +18,7 @@ import {
18
18
  parseNwcUri,
19
19
  validateX402Env,
20
20
  withNwcPool
21
- } from "../chunk-KGL3YMZA.js";
21
+ } from "../chunk-AJ6UHXUA.js";
22
22
  import {
23
23
  MemoryKVStore
24
24
  } from "../chunk-SDK6KDJN.js";
@@ -82,30 +82,30 @@ import {
82
82
  toCreditView,
83
83
  unknownRouteNotFound,
84
84
  writeOffHostedTempoCloseReport
85
- } from "../chunk-73C4JN2E.js";
85
+ } from "../chunk-QNKK7SPY.js";
86
86
  import {
87
87
  MemoryProcessedPaymentStore,
88
88
  PostgresProcessedPaymentStore,
89
89
  ProcessedPaymentReplayError
90
90
  } from "../chunk-XRLKGCAW.js";
91
- import "../chunk-K2MSIKMM.js";
92
- import "../chunk-GAZBBMAA.js";
91
+ import "../chunk-FFXXGCVG.js";
92
+ import "../chunk-VTHYQCDB.js";
93
93
  import {
94
94
  MemoryCreditLedger
95
- } from "../chunk-ZBQKXAYK.js";
95
+ } from "../chunk-YOSZIWC3.js";
96
96
  import {
97
97
  PostgresJobStore
98
- } from "../chunk-GODOH2AF.js";
98
+ } from "../chunk-Y6DO5WSO.js";
99
99
  import "../chunk-YG7G4DPZ.js";
100
100
  import {
101
101
  SignedRequestError,
102
102
  createDefaultReplayStore,
103
103
  createSignedRequestVerifier,
104
104
  signedRequestInput
105
- } from "../chunk-4VV7WACY.js";
105
+ } from "../chunk-2XQLL6N6.js";
106
106
  import {
107
107
  isStreamableJobStore
108
- } from "../chunk-TFDR2YP2.js";
108
+ } from "../chunk-KFCEXCZM.js";
109
109
  import {
110
110
  ContentHoldError,
111
111
  baselineContentExpiry,
@@ -116,7 +116,7 @@ import {
116
116
  IMPLICIT_CREDIT_TTL_MS,
117
117
  generateEphemeralReceiptKey,
118
118
  receiptPubkeyFromSecret
119
- } from "../chunk-LW7KZQHG.js";
119
+ } from "../chunk-VUGEEMLT.js";
120
120
  import {
121
121
  X402_DEFAULT_FACILITATOR,
122
122
  X402_DEFAULT_NETWORK,
@@ -128,11 +128,11 @@ import {
128
128
  SIGNED_REQUEST_STATEMENT_VERSION,
129
129
  signedRequestStatementHeader
130
130
  } from "../chunk-UKD3R2KU.js";
131
- import "../chunk-TRY7BJA4.js";
131
+ import "../chunk-3R7NQA3Z.js";
132
132
  import "../chunk-FUJ36YDV.js";
133
133
  import "../chunk-BQJIFRAZ.js";
134
- import "../chunk-WLPLHXNP.js";
135
- import "../chunk-HC4I7LAV.js";
134
+ import "../chunk-JNECYURT.js";
135
+ import "../chunk-W3VGCNG6.js";
136
136
  import {
137
137
  CreditLedger,
138
138
  CreditLedgerError,
@@ -140,14 +140,14 @@ import {
140
140
  PostgresX402ChannelStorage,
141
141
  X402RelaySubmissionLockError,
142
142
  allocateDrawValue
143
- } from "../chunk-YYRY32NR.js";
143
+ } from "../chunk-STJBBVNL.js";
144
144
  import {
145
145
  SDK_INIT_ADVISORY_LOCK,
146
146
  withSdkInitLock
147
147
  } from "../chunk-COYKJRMM.js";
148
148
  import {
149
149
  applyRetryToPool
150
- } from "../chunk-IBX2ORBV.js";
150
+ } from "../chunk-MMGSYMIC.js";
151
151
  import {
152
152
  assertSupportedX402Network
153
153
  } from "../chunk-BPYMEMQX.js";
@@ -157,14 +157,14 @@ import {
157
157
  TEMPO_SETTLEMENT_DEFAULT_LOW_BALANCE_MICRO,
158
158
  TempoSettlementReadiness,
159
159
  resolveTempoNetwork
160
- } from "../chunk-LFVIZH2G.js";
160
+ } from "../chunk-MU3IE434.js";
161
161
  import {
162
162
  initLoggers
163
- } from "../chunk-QSZW2I5Y.js";
163
+ } from "../chunk-M3T5JYDJ.js";
164
164
  import "../chunk-66HGCPBU.js";
165
165
  import {
166
166
  diagnosticConsole
167
- } from "../chunk-OIP44KBB.js";
167
+ } from "../chunk-QGNXYVBO.js";
168
168
 
169
169
  // src/sdk/server/cashu-env.ts
170
170
  async function resolveCashuOptsFromEnv(env, pool, cashuModeHint) {
@@ -245,6 +245,43 @@ async function resolveCashuOptsFromEnv(env, pool, cashuModeHint) {
245
245
  return { cashuMode, lockPubkey, lockPubkeyGraceSeconds, db, dvmId, canonicalDvmId };
246
246
  }
247
247
 
248
+ // src/sdk/server/pending-implicit-draws.ts
249
+ async function readPendingImplicitDraws({
250
+ db
251
+ }) {
252
+ const { rows } = await db.query(`
253
+ SELECT c.rail, c.currency, COUNT(*)::text AS draw_count,
254
+ SUM(d.amount_micro)::text AS amount_micro,
255
+ MIN(d.created_at)::text AS oldest_draw_at
256
+ FROM credit_draws d
257
+ JOIN credits c ON c.credit_id = d.credit_id
258
+ WHERE d.status = 'pending' AND d.credit_id LIKE 'imp:%'
259
+ GROUP BY c.rail, c.currency
260
+ ORDER BY c.rail NULLS LAST, c.currency
261
+ `);
262
+ const byRailCurrency = rows.map((row) => ({
263
+ rail: row.rail,
264
+ currency: row.currency,
265
+ drawCount: safeInteger(row.draw_count),
266
+ amountMicro: safeInteger(row.amount_micro),
267
+ oldestDrawAt: safeInteger(row.oldest_draw_at)
268
+ }));
269
+ let count = 0n;
270
+ let oldestDrawAt = null;
271
+ for (const group of byRailCurrency) {
272
+ count += BigInt(group.drawCount);
273
+ oldestDrawAt = oldestDrawAt === null ? group.oldestDrawAt : Math.min(oldestDrawAt, group.oldestDrawAt);
274
+ }
275
+ return { drawCount: safeInteger(count.toString()), oldestDrawAt, byRailCurrency };
276
+ }
277
+ function safeInteger(value) {
278
+ const number = Number(value);
279
+ if (!/^\d+$/.test(value) || !Number.isSafeInteger(number)) {
280
+ throw new RangeError("pending implicit draws: aggregate outside nonnegative safe integer range");
281
+ }
282
+ return number;
283
+ }
284
+
248
285
  // src/sdk/server/payment-mode.ts
249
286
  function resolvePaymentMode(opts) {
250
287
  const active = (rail, configured, ready) => ({
@@ -1151,7 +1188,7 @@ function createDVMHost(opts = {}) {
1151
1188
  });
1152
1189
  applyRetryToPool(pool, "dvm-host");
1153
1190
  pgPool = pool;
1154
- const { PostgresJobStore: PostgresJobStore2 } = await import("../postgres-job-store-27VOCSPO.js");
1191
+ const { PostgresJobStore: PostgresJobStore2 } = await import("../postgres-job-store-FSRUPYH2.js");
1155
1192
  const pgJobStore = new PostgresJobStore2(pool);
1156
1193
  pendingInits.push(pgJobStore.init(), pgJobStore.initStreaming());
1157
1194
  jobStore = pgJobStore;
@@ -1244,11 +1281,11 @@ ${config.facilitatorAuth?.keyId ?? ""}`;
1244
1281
  let tempoChargeBackend = "user-supplied";
1245
1282
  const mppTempoRecipient = envMaybe.DVMKIT_TEMPO_RECIPIENT;
1246
1283
  if (!mpp && mppTempoRecipient) {
1247
- const { createMppFromOpts, createDualKeyMppxFromOpts, parseMppMethodsAllowlist } = await import("../mpp-setup-VW53KFPO.js");
1284
+ const { createMppFromOpts, createDualKeyMppxFromOpts, parseMppMethodsAllowlist } = await import("../mpp-setup-FURD45LI.js");
1248
1285
  tempoChargeBackend = pgPool ? "postgres" : "memory";
1249
1286
  let tempoCharge;
1250
1287
  if (pgPool) {
1251
- const { PostgresTempoChargeStore } = await import("../tempo-charge-store-2RPOJBM2.js");
1288
+ const { PostgresTempoChargeStore } = await import("../tempo-charge-store-5JOIYUIH.js");
1252
1289
  const chargeStore = new PostgresTempoChargeStore(pgPool);
1253
1290
  tempoChargeStore = chargeStore;
1254
1291
  pendingInits.push(chargeStore.init());
@@ -1268,7 +1305,7 @@ ${config.facilitatorAuth?.keyId ?? ""}`;
1268
1305
  { createPublicClient, createWalletClient, erc20Abi, http },
1269
1306
  { tempo: tempoMainnet, tempoModerato }
1270
1307
  ] = await Promise.all([
1271
- import("../tempo-session-store-LI3Q3A3U.js"),
1308
+ import("../tempo-session-store-S6QMLQUA.js"),
1272
1309
  import("viem/accounts"),
1273
1310
  import("viem"),
1274
1311
  import("viem/chains")
@@ -1421,7 +1458,7 @@ ${config.facilitatorAuth?.keyId ?? ""}`;
1421
1458
  }
1422
1459
  }
1423
1460
  const fxSource = envMaybe.DVMKIT_FX_SOURCE;
1424
- const { createFxFetcher, resolveFxSourceFromEnv, warmFxSnapshot } = await import("../pricing-NNMBNP7N.js");
1461
+ const { createFxFetcher, resolveFxSourceFromEnv, warmFxSnapshot } = await import("../pricing-X4XU5HXY.js");
1425
1462
  const fxFetcher = opts.fx ?? createFxFetcher({ source: resolveFxSourceFromEnv(envMaybe) });
1426
1463
  const hostRailConfigured = (opts.paymentMethods?.length ?? 0) > 0 || (effectiveMints?.length ?? 0) > 0 || !!x402WithDualServe || !!mpp;
1427
1464
  if (mounts.some((entry) => mountNeedsFx(entry, hostRailConfigured))) warmFxSnapshot(fxFetcher);
@@ -1431,7 +1468,7 @@ ${config.facilitatorAuth?.keyId ?? ""}`;
1431
1468
  assertReceiptIdentity(envMaybe, opts.builder, receiptKey, cashuOpts.dvmId, opts.devMode);
1432
1469
  let sharedPgReplayStore;
1433
1470
  if (pgPool) {
1434
- const { PostgresReplayStore: PostgresReplayStore2 } = await import("../postgres-replay-store-7GJFAQXY.js");
1471
+ const { PostgresReplayStore: PostgresReplayStore2 } = await import("../postgres-replay-store-XXJSA457.js");
1435
1472
  const store2 = new PostgresReplayStore2(pgPool);
1436
1473
  pendingInits.push(store2.init());
1437
1474
  sharedPgReplayStore = store2;
@@ -1459,13 +1496,13 @@ ${config.facilitatorAuth?.keyId ?? ""}`;
1459
1496
  }
1460
1497
  let sharedPgConsumedStore;
1461
1498
  if (pgPool) {
1462
- const { PostgresConsumedCredentialStore } = await import("../postgres-consumed-credential-store-V464OAJB.js");
1499
+ const { PostgresConsumedCredentialStore } = await import("../postgres-consumed-credential-store-WO6OCFXZ.js");
1463
1500
  const consumedStore = new PostgresConsumedCredentialStore(pgPool);
1464
1501
  pendingInits.push(consumedStore.init());
1465
1502
  sharedPgConsumedStore = consumedStore;
1466
1503
  }
1467
1504
  if (pgPool) {
1468
- const { CreditLedger: CreditLedger2 } = await import("../credit-ledger-CZQ56DYI.js");
1505
+ const { CreditLedger: CreditLedger2 } = await import("../credit-ledger-4PZNAMDT.js");
1469
1506
  const pgLedger = new CreditLedger2(pgPool, tempoSessionStore);
1470
1507
  pendingInits.push(pgLedger.init());
1471
1508
  creditLedger = pgLedger;
@@ -1474,7 +1511,7 @@ ${config.facilitatorAuth?.keyId ?? ""}`;
1474
1511
  pendingInits.push(pgProcessed.init());
1475
1512
  processedPayments = pgProcessed;
1476
1513
  } else {
1477
- const { MemoryCreditLedger: MemoryCreditLedger2 } = await import("../memory-credit-ledger-EMN7G3MO.js");
1514
+ const { MemoryCreditLedger: MemoryCreditLedger2 } = await import("../memory-credit-ledger-RP7DT5IY.js");
1478
1515
  creditLedger = disposableCashu?.ledger ?? new MemoryCreditLedger2();
1479
1516
  const { MemoryProcessedPaymentStore: MemoryProcessedPaymentStore2 } = await import("../processed-payment-store-GKMAWOM3.js");
1480
1517
  processedPayments = new MemoryProcessedPaymentStore2();
@@ -2166,6 +2203,7 @@ export {
2166
2203
  parseDvmClient,
2167
2204
  parseProtocolVersion,
2168
2205
  protocolEnvelopeIgnoreFields,
2206
+ readPendingImplicitDraws,
2169
2207
  requestIdFromEnvelope,
2170
2208
  requireClientCompatibility,
2171
2209
  resolveCashuOptsFromEnv,
@@ -1261,6 +1261,28 @@ declare class HostedSettlementReportObligations {
1261
1261
  tempoCloseAmountAtStake(id: string): Promise<string>;
1262
1262
  /** Stop automatic searches without declaring a possibly missing payout discharged. */
1263
1263
  markTempoCloseUnmatched(id: string): Promise<boolean>;
1264
+ listTempoCloseReports(args: {
1265
+ limit: number;
1266
+ after?: {
1267
+ createdAtMs: number;
1268
+ obligationId: string;
1269
+ };
1270
+ all?: boolean;
1271
+ }): Promise<{
1272
+ id: string;
1273
+ channelId: string;
1274
+ amountNative: string;
1275
+ status: "unmatched" | "no_report";
1276
+ createdAtMs: number;
1277
+ updatedAtMs: number;
1278
+ deliveredAtMs: number | null;
1279
+ retryable: boolean;
1280
+ writeOffAllowed: boolean;
1281
+ writtenOff: boolean;
1282
+ writeOffNote: string | null;
1283
+ writtenOffAtMs: number | null;
1284
+ }[]>;
1285
+ hasTempoCloseReport(id: string): Promise<boolean>;
1264
1286
  writeOffTempoClose(id: string, note: string): Promise<{
1265
1287
  channelId: string;
1266
1288
  amount: string;
@@ -1276,6 +1298,8 @@ declare class HostedSettlementReportObligations {
1276
1298
  reservedAtMs: number;
1277
1299
  searchBefore: bigint | null;
1278
1300
  } | undefined>;
1301
+ /** A recorded close transaction remains refund evidence after its report is delivered. */
1302
+ tempoCloseTransaction(channelId: string, drainId: string): Promise<string | undefined>;
1279
1303
  /**
1280
1304
  * Where the next search for this close obligation's transaction resumes. It
1281
1305
  * lives on the obligation, not the drain's close intent, because releasing
@@ -1337,13 +1361,24 @@ declare function retryHostedTempoCloseReport(args: {
1337
1361
  scope: string;
1338
1362
  obligationId: string;
1339
1363
  }): Promise<boolean>;
1340
- /** Forgo an unmatched builder payout report after the operator declares its history irrecoverable. */
1341
- declare function writeOffHostedTempoCloseReport(args: {
1364
+ interface HostedTempoCloseReportWriteOff {
1365
+ channelId: string;
1366
+ /** Builder payout abandoned, as a decimal string in native token units. */
1367
+ amountForgoneNative: string;
1368
+ }
1369
+ interface WriteOffHostedTempoCloseReportArgs {
1342
1370
  db: Pool;
1343
1371
  dvmId: string;
1344
1372
  scope: string;
1345
1373
  obligationId: string;
1346
1374
  note: string;
1375
+ }
1376
+ /** Forgo an unmatched builder payout report; includeDetails returns the amount without another read. */
1377
+ declare function writeOffHostedTempoCloseReport(args: WriteOffHostedTempoCloseReportArgs & {
1378
+ includeDetails: true;
1379
+ }): Promise<HostedTempoCloseReportWriteOff | false>;
1380
+ declare function writeOffHostedTempoCloseReport(args: WriteOffHostedTempoCloseReportArgs & {
1381
+ includeDetails?: false;
1347
1382
  }): Promise<boolean>;
1348
1383
 
1349
1384
  type JsonValue = string | number | boolean | null | JsonValue[] | {
@@ -4544,6 +4579,9 @@ interface TempoDrainFinalization {
4544
4579
  outcome: "payer_exit" | "cooperative_close";
4545
4580
  creditUnbacked: boolean;
4546
4581
  }
4582
+ type TempoCloseRecovery = string | null | {
4583
+ outcome: "refund_unproven";
4584
+ };
4547
4585
  type TempoDrainFinalizer = (drain: CreditDrainRecord, evidence: TempoDrainFinalization) => Promise<boolean>;
4548
4586
  /**
4549
4587
  * Options for assembling an Mppx server handle from explicit recipient strings
@@ -4720,8 +4758,12 @@ interface MppxServer {
4720
4758
  releaseTempoSessionCloseIntent?<value>(channelId: string, drainId: string, operation: (tx: CreditLedgerQuerier) => Promise<value>): Promise<value>;
4721
4759
  /** Persist a confirmed cooperative-close transaction before draining the ledger. */
4722
4760
  confirmTempoSessionClose?: (channelId: string, drainId: string, reference: string) => Promise<string>;
4723
- /** Recover a close result after a process failure between chain and ledger commits. */
4724
- recoverTempoSessionClose?: (channelId: string, drainId: string) => Promise<string | null>;
4761
+ /**
4762
+ * Recover a close result after a process failure between chain and ledger commits.
4763
+ * Supplying the credit ID checks the durable drain status and requires a
4764
+ * proven refund before completing a finalized channel through the ledger.
4765
+ */
4766
+ recoverTempoSessionClose?: (channelId: string, drainId: string, creditId?: string) => Promise<TempoCloseRecovery>;
4725
4767
  /**
4726
4768
  * Read a channel's close intent without touching it.
4727
4769
  *
@@ -4887,7 +4929,7 @@ interface TempoSessionChainOps {
4887
4929
  * chain head when omitted) down to blocks older than `notBeforeMs`. One call searches a bounded number of
4888
4930
  * windows; `paused` names the block the next call resumes from.
4889
4931
  */
4890
- findChannelClose(client: Client, channelId: Hex, escrowContract: `0x${string}`, notBeforeMs: number, startBlock?: bigint): Promise<TempoChannelCloseSearch>;
4932
+ findChannelClose(client: Client, channelId: Hex, escrowContract: `0x${string}`, notBeforeMs: number, startBlock?: bigint, deadlineMs?: number | (() => number)): Promise<TempoChannelCloseSearch>;
4891
4933
  }
4892
4934
  type TempoChannelCloseSearch =
4893
4935
  /** A `ChannelClosed` log, with the address that sent its transaction. */
@@ -5987,4 +6029,4 @@ declare class StepCache {
5987
6029
  static deserialize(records: StepRecord[]): StepCache;
5988
6030
  }
5989
6031
 
5990
- export { type FundingReceipt as $, type ApprovalContent as A, type SignedRequestDomain as B, type Currency as C, type DVMConfig as D, SignedRequestError as E, type SignedRequestFailure as F, type SignedRequestReplayStore as G, type SignedRequestSignOpts as H, type IncomingMessage as I, type JobCost as J, type KVStore as K, type Logger as L, type SignedRequestStatementHeader as M, type SignedRequestVerifier as N, createSignedRequestVerifier as O, type PaymentContent as P, type QuoteConfig as Q, type ResolvedCreditConfig as R, type SDKJobContext as S, isZodSchema as T, UnsupportedCurrencyError as U, signedRequestStatementHeader as V, validateCurrency as W, type JsonValue as X, X402_BATCH_SETTLEMENT_SCHEME as Y, type ZodLike as Z, X402_EXACT_SCHEME as _, type DVMDescriptor as a, isCompleteMessage as a$, type JobReceipt as a0, type MessageType as a1, type X402Version as a2, type MppxCredential as a3, type PaymentRequired as a4, type Message as a5, type MppxChallenge as a6, type ReceiptCredit as a7, type DrainReceipt as a8, type X402Wallet as a9, type UnsignedDrainReceipt as aA, type UnsignedFundingReceipt as aB, type UnsignedJobReceipt as aC, type VerifyResponse as aD, type WorkingContent as aE, type X402Config$1 as aF, type X402ResponseBody as aG, type X402SelfRelayRpcFailureReason as aH, X402_DEFAULT_NETWORK as aI, X402_V1_VERSION as aJ, X402_VERSION as aK, buildPaymentRequiredV2 as aL, buildPaymentRequirements as aM, caip2ToX402Network as aN, canonicalRequestPath as aO, canonicaliseForSigning as aP, canonicalize as aQ, chainIdFromCaip2 as aR, computeResultHash as aS, decodePayment as aT, decodePaymentRequiredHeader as aU, encodePayment as aV, encodePaymentRequiredHeader as aW, encodeSettleResponseHeader as aX, exactEvmAuthorization as aY, isArtifactMessage as aZ, isCancelMessage as a_, type PaymentRequirementsV1 as aa, type PaymentRequirementsV2 as ab, type BuildPaymentRequirementsOpts as ac, type CapabilityDescriptor as ad, type CashuMode as ae, type CompleteContent as af, type DrainReceiptEvent as ag, type ExactEvmPayload as ah, type ExactEvmPayloadAuthorization as ai, type FundingMethod as aj, type MessageFrom as ak, type PaymentPayload as al, type PaymentPayloadV1 as am, type PaymentPayloadV2 as an, type PaymentRequestContent as ao, type PaymentRequiredV2 as ap, type PaymentRequirements as aq, type PromptContent as ar, RAIL_REFUNDABLE as as, type ReceiptOutcome as at, type ReceiptPayment as au, type ResourceInfo as av, type SettleResponse as aw, StepCache as ax, type StepRecord as ay, type TextContent as az, type ArtifactContent as b, type InvoiceWriteOff as b$, isDrainReceipt as b0, isFundingReceipt as b1, isPaymentRequestMessage as b2, isPromptMessage as b3, isSignedJobReceipt as b4, isTextMessage as b5, isWorkingMessage as b6, paymentRequiredV2FromV1 as b7, signDrainReceipt as b8, signFundingReceipt as b9, type X402TrackedChannel as bA, _testing as bB, createDefaultReplayStore as bC, depleteLots as bD, fifoOrder as bE, inKindDrawMsats as bF, isInKindDepletion as bG, isNonChannelBitcoinRail as bH, lotOwedSats as bI, netOwedSats as bJ, wrapMppx as bK, type CreditDrainEnqueue as bL, HostedSettlementReportObligations as bM, type DVMAuthScheme as bN, type CreditLedgerLike as bO, type X402RefundSettlementGate as bP, type CreditSnapshot as bQ, type DrawResult as bR, type X402SettlementStatus as bS, type X402UnresolvedRefund as bT, type GrownDrawResult as bU, type DrawResolution as bV, type FundingRecord as bW, type CreditInvoiceRecord as bX, type InvoiceSettlement as bY, type BlockedInvoiceCursor as bZ, type InvoiceReconciliation as b_, signReceipt as ba, usdcContractByCaip2 as bb, usdcContractFor as bc, usdcDomainNameFor as bd, usdcDomainVersionFor as be, verifyDrainReceipt as bf, verifyFundingReceipt as bg, verifyReceipt as bh, x402NetworkToCaip2 as bi, type X402ExactVersionSupport as bj, type X402Receipt as bk, type TransactionalPayoutHook as bl, type CashuMeltCompleted as bm, type CreditDepositPayload as bn, type CreditDrainPayload as bo, type FundingLot as bp, type LotDebit as bq, type LotDepletion as br, type MppxServer as bs, NON_CHANNEL_BITCOIN_RAILS as bt, type NonChannelBitcoinRail as bu, PayoutReporter as bv, PostgresTempoSessionStore as bw, RevenueReporter as bx, SIGNED_ENVELOPE_FIELDS as by, SIGNED_ENVELOPE_TYPES as bz, type CancelContent as c, type X402SettlementCursor as c$, type DrawRecord as c0, type StalePendingDrawCursor as c1, type TempoCreditLossEvidence as c2, type CreditLedgerQuerier as c3, type TempoCreditLoss as c4, type X402CreditLossEvidence as c5, type X402CreditLoss as c6, type DrainMethod as c7, type DrainRequestResult as c8, type BitcoinDepositLiability as c9, type JobCostReportPayload as cA, type JobTerminalReportPayload as cB, PostgresX402ChannelStorage as cC, type ReplayStoreBackend as cD, type RevenueSkippedNoRailPayload as cE, type RevenueSkippedNoRailReason as cF, type Secp256k1AuthOpts as cG, type X402ChannelStorageOpts as cH, type X402RelayLockHolder as cI, type X402RelaySubmissionLock as cJ, X402RelaySubmissionLockError as cK, allocateDrawValue as cL, clientCompatibilityAttributes as cM, clientCompatibilityMiddleware as cN, clientUpgradeRequired as cO, parseClientCapabilities as cP, parseClientCompatibility as cQ, parseDvmClient as cR, parseProtocolVersion as cS, requireClientCompatibility as cT, retryHostedTempoCloseReport as cU, secp256k1Auth as cV, signedRequestInput as cW, writeOffHostedTempoCloseReport as cX, type HostedIntent as cY, type X402SettlementIntent as cZ, type HostedFundingReservation as c_, type CreditDrainRecord as ca, type ChannelDrainCursor as cb, type DrainWriteOff as cc, type DrainTransitionResult as cd, type DrainReleaseResult as ce, type DrainFulfilment as cf, HostingCleanupFence as cg, CLIENT_COMPATIBILITY_HEADERS as ch, type ClientCompatibility as ci, type ClientCompatibilityEnv as cj, type ClientCompatibilityGate as ck, type ClientCompatibilityRequirement as cl, type ClientSemVer as cm, type CreditFundingBasis as cn, type CreditInvoiceStatus as co, CreditLedger as cp, CreditLedgerError as cq, type CreditLedgerErrorCode as cr, type CreditLedgerErrorDetails as cs, type CreditLedgerPool as ct, type CreditStatus as cu, DRAIN_DELIVERY_RESERVE_SATS as cv, DVM_PROTOCOL_VERSION as cw, type DrainConflictReason as cx, type DrawRailValue as cy, type DrawStatus as cz, type CanonicalEnvelope as d, type X402SettlementWriteOff as d0, type X402FacilitatorAuth as d1, type X402BatchSettlementConfig as d2, type X402PayoutObserver as d3, type CreditDepositEnqueue as d4, type X402SettlementReconciliationReason as d5, type CreditDrawReleaseEnqueue as d6, type CapabilityRate as e, type CreateSignedRequestVerifierOpts as f, type CreditConfig as g, type CreditView as h, DEFAULT_CREDIT_MAX as i, DEFAULT_CREDIT_MIN as j, DEFAULT_CREDIT_TTL_SECONDS as k, DEFAULT_JOB_RETENTION_DAYS as l, type DVMRouteContext as m, type InputType as n, InvalidCurrencyError as o, type PaymentMethod as p, type PriceValue as q, type ProgressContent as r, type PromptOpts as s, type QuoteContext as t, type QuoteResult as u, type ResponseContent as v, type SDKPaymentRequestOpts as w, SIGNED_REQUEST_AUTH_ID as x, SIGNED_REQUEST_STATEMENT_VERSION as y, type SignedRequestAudience as z };
6032
+ export { type FundingReceipt as $, type ApprovalContent as A, type SignedRequestDomain as B, type Currency as C, type DVMConfig as D, SignedRequestError as E, type SignedRequestFailure as F, type SignedRequestReplayStore as G, type SignedRequestSignOpts as H, type IncomingMessage as I, type JobCost as J, type KVStore as K, type Logger as L, type SignedRequestStatementHeader as M, type SignedRequestVerifier as N, createSignedRequestVerifier as O, type PaymentContent as P, type QuoteConfig as Q, type ResolvedCreditConfig as R, type SDKJobContext as S, isZodSchema as T, UnsupportedCurrencyError as U, signedRequestStatementHeader as V, validateCurrency as W, type JsonValue as X, X402_BATCH_SETTLEMENT_SCHEME as Y, type ZodLike as Z, X402_EXACT_SCHEME as _, type DVMDescriptor as a, isCompleteMessage as a$, type JobReceipt as a0, type MessageType as a1, type X402Version as a2, type MppxCredential as a3, type PaymentRequired as a4, type Message as a5, type MppxChallenge as a6, type ReceiptCredit as a7, type DrainReceipt as a8, type X402Wallet as a9, type UnsignedDrainReceipt as aA, type UnsignedFundingReceipt as aB, type UnsignedJobReceipt as aC, type VerifyResponse as aD, type WorkingContent as aE, type X402Config$1 as aF, type X402ResponseBody as aG, type X402SelfRelayRpcFailureReason as aH, X402_DEFAULT_NETWORK as aI, X402_V1_VERSION as aJ, X402_VERSION as aK, buildPaymentRequiredV2 as aL, buildPaymentRequirements as aM, caip2ToX402Network as aN, canonicalRequestPath as aO, canonicaliseForSigning as aP, canonicalize as aQ, chainIdFromCaip2 as aR, computeResultHash as aS, decodePayment as aT, decodePaymentRequiredHeader as aU, encodePayment as aV, encodePaymentRequiredHeader as aW, encodeSettleResponseHeader as aX, exactEvmAuthorization as aY, isArtifactMessage as aZ, isCancelMessage as a_, type PaymentRequirementsV1 as aa, type PaymentRequirementsV2 as ab, type BuildPaymentRequirementsOpts as ac, type CapabilityDescriptor as ad, type CashuMode as ae, type CompleteContent as af, type DrainReceiptEvent as ag, type ExactEvmPayload as ah, type ExactEvmPayloadAuthorization as ai, type FundingMethod as aj, type MessageFrom as ak, type PaymentPayload as al, type PaymentPayloadV1 as am, type PaymentPayloadV2 as an, type PaymentRequestContent as ao, type PaymentRequiredV2 as ap, type PaymentRequirements as aq, type PromptContent as ar, RAIL_REFUNDABLE as as, type ReceiptOutcome as at, type ReceiptPayment as au, type ResourceInfo as av, type SettleResponse as aw, StepCache as ax, type StepRecord as ay, type TextContent as az, type ArtifactContent as b, type InvoiceReconciliation as b$, isDrainReceipt as b0, isFundingReceipt as b1, isPaymentRequestMessage as b2, isPromptMessage as b3, isSignedJobReceipt as b4, isTextMessage as b5, isWorkingMessage as b6, paymentRequiredV2FromV1 as b7, signDrainReceipt as b8, signFundingReceipt as b9, type X402TrackedChannel as bA, _testing as bB, createDefaultReplayStore as bC, depleteLots as bD, fifoOrder as bE, inKindDrawMsats as bF, isInKindDepletion as bG, isNonChannelBitcoinRail as bH, lotOwedSats as bI, netOwedSats as bJ, wrapMppx as bK, type CreditLedgerQuerier as bL, type CreditDrainEnqueue as bM, HostedSettlementReportObligations as bN, type DVMAuthScheme as bO, type CreditLedgerLike as bP, type X402RefundSettlementGate as bQ, type CreditSnapshot as bR, type DrawResult as bS, type X402SettlementStatus as bT, type X402UnresolvedRefund as bU, type GrownDrawResult as bV, type DrawResolution as bW, type FundingRecord as bX, type CreditInvoiceRecord as bY, type InvoiceSettlement as bZ, type BlockedInvoiceCursor as b_, signReceipt as ba, usdcContractByCaip2 as bb, usdcContractFor as bc, usdcDomainNameFor as bd, usdcDomainVersionFor as be, verifyDrainReceipt as bf, verifyFundingReceipt as bg, verifyReceipt as bh, x402NetworkToCaip2 as bi, type X402ExactVersionSupport as bj, type X402Receipt as bk, type TransactionalPayoutHook as bl, type CashuMeltCompleted as bm, type CreditDepositPayload as bn, type CreditDrainPayload as bo, type FundingLot as bp, type LotDebit as bq, type LotDepletion as br, type MppxServer as bs, NON_CHANNEL_BITCOIN_RAILS as bt, type NonChannelBitcoinRail as bu, PayoutReporter as bv, PostgresTempoSessionStore as bw, RevenueReporter as bx, SIGNED_ENVELOPE_FIELDS as by, SIGNED_ENVELOPE_TYPES as bz, type CancelContent as c, type HostedFundingReservation as c$, type InvoiceWriteOff as c0, type DrawRecord as c1, type StalePendingDrawCursor as c2, type TempoCreditLossEvidence as c3, type TempoCreditLoss as c4, type X402CreditLossEvidence as c5, type X402CreditLoss as c6, type DrainMethod as c7, type DrainRequestResult as c8, type BitcoinDepositLiability as c9, type HostedTempoCloseReportWriteOff as cA, type JobCostReportPayload as cB, type JobTerminalReportPayload as cC, PostgresX402ChannelStorage as cD, type ReplayStoreBackend as cE, type RevenueSkippedNoRailPayload as cF, type RevenueSkippedNoRailReason as cG, type Secp256k1AuthOpts as cH, type X402ChannelStorageOpts as cI, type X402RelayLockHolder as cJ, type X402RelaySubmissionLock as cK, X402RelaySubmissionLockError as cL, allocateDrawValue as cM, clientCompatibilityAttributes as cN, clientCompatibilityMiddleware as cO, clientUpgradeRequired as cP, parseClientCapabilities as cQ, parseClientCompatibility as cR, parseDvmClient as cS, parseProtocolVersion as cT, requireClientCompatibility as cU, retryHostedTempoCloseReport as cV, secp256k1Auth as cW, signedRequestInput as cX, writeOffHostedTempoCloseReport as cY, type HostedIntent as cZ, type X402SettlementIntent as c_, type CreditDrainRecord as ca, type ChannelDrainCursor as cb, type DrainWriteOff as cc, type DrainTransitionResult as cd, type DrainReleaseResult as ce, type DrainFulfilment as cf, HostingCleanupFence as cg, CLIENT_COMPATIBILITY_HEADERS as ch, type ClientCompatibility as ci, type ClientCompatibilityEnv as cj, type ClientCompatibilityGate as ck, type ClientCompatibilityRequirement as cl, type ClientSemVer as cm, type CreditFundingBasis as cn, type CreditInvoiceStatus as co, CreditLedger as cp, CreditLedgerError as cq, type CreditLedgerErrorCode as cr, type CreditLedgerErrorDetails as cs, type CreditLedgerPool as ct, type CreditStatus as cu, DRAIN_DELIVERY_RESERVE_SATS as cv, DVM_PROTOCOL_VERSION as cw, type DrainConflictReason as cx, type DrawRailValue as cy, type DrawStatus as cz, type CanonicalEnvelope as d, type X402SettlementCursor as d0, type X402SettlementWriteOff as d1, type X402FacilitatorAuth as d2, type X402BatchSettlementConfig as d3, type X402PayoutObserver as d4, type CreditDepositEnqueue as d5, type X402SettlementReconciliationReason as d6, type CreditDrawReleaseEnqueue as d7, type CapabilityRate as e, type CreateSignedRequestVerifierOpts as f, type CreditConfig as g, type CreditView as h, DEFAULT_CREDIT_MAX as i, DEFAULT_CREDIT_MIN as j, DEFAULT_CREDIT_TTL_SECONDS as k, DEFAULT_JOB_RETENTION_DAYS as l, type DVMRouteContext as m, type InputType as n, InvalidCurrencyError as o, type PaymentMethod as p, type PriceValue as q, type ProgressContent as r, type PromptOpts as s, type QuoteContext as t, type QuoteResult as u, type ResponseContent as v, type SDKPaymentRequestOpts as w, SIGNED_REQUEST_AUTH_ID as x, SIGNED_REQUEST_STATEMENT_VERSION as y, type SignedRequestAudience as z };
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  PostgresTempoChargeStore
3
- } from "./chunk-IYQQXEHV.js";
3
+ } from "./chunk-LDIPVPKI.js";
4
4
  import "./chunk-YG7G4DPZ.js";
5
5
  import "./chunk-COYKJRMM.js";
6
- import "./chunk-OIP44KBB.js";
6
+ import "./chunk-QGNXYVBO.js";
7
7
  export {
8
8
  PostgresTempoChargeStore
9
9
  };
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  PostgresTempoSessionStore,
3
3
  assertMonotonicTransition
4
- } from "./chunk-Q3VYRU5R.js";
4
+ } from "./chunk-MB6R4XPZ.js";
5
5
  import "./chunk-YG7G4DPZ.js";
6
6
  import "./chunk-COYKJRMM.js";
7
- import "./chunk-IBX2ORBV.js";
8
- import "./chunk-OIP44KBB.js";
7
+ import "./chunk-MMGSYMIC.js";
8
+ import "./chunk-QGNXYVBO.js";
9
9
  export {
10
10
  PostgresTempoSessionStore,
11
11
  assertMonotonicTransition
@@ -1,6 +1,6 @@
1
- import { C as ContentHoldHistory, a as ContentHoldMutation } from '../content-retention-CVBYehRS.js';
2
- import { a0 as JobReceipt, a5 as Message, a1 as MessageType, K as KVStore, L as Logger, v as ResponseContent, P as PaymentContent, S as SDKJobContext } from '../step-cache-B7svmPz3.js';
3
- import { c as StreamableJobStore, R as ReceiptIssuingStore, J as JobRecord, d as RequestIdClaim, e as RequestIdClaimResult, f as JobRetentionCursor, O as OutgoingMessage, A as AppendOutgoingOptions, P as PaymentCreditDelta, V as VerifyAndCreditResult, g as JobCounters } from '../job-store-qOD-FrQF.js';
1
+ import { C as ContentHoldHistory, a as ContentHoldMutation } from '../content-retention-CrILCNxk.js';
2
+ import { a0 as JobReceipt, a5 as Message, a1 as MessageType, K as KVStore, L as Logger, v as ResponseContent, P as PaymentContent, S as SDKJobContext } from '../step-cache--7yA5Ihr.js';
3
+ import { c as StreamableJobStore, R as ReceiptIssuingStore, J as JobRecord, d as RequestIdClaim, e as RequestIdClaimResult, f as JobRetentionCursor, O as OutgoingMessage, A as AppendOutgoingOptions, P as PaymentCreditDelta, V as VerifyAndCreditResult, g as JobCounters } from '../job-store-92v8e1LQ.js';
4
4
  import 'hono';
5
5
  import 'mppx';
6
6
  import '@x402/core/server';
@@ -4,22 +4,22 @@ import {
4
4
  import {
5
5
  MemoryJobStore,
6
6
  createInstrumentedFetch
7
- } from "../chunk-TFDR2YP2.js";
7
+ } from "../chunk-KFCEXCZM.js";
8
8
  import {
9
9
  JobCancelledError
10
10
  } from "../chunk-AFV77S4C.js";
11
11
  import {
12
12
  createNoopLogger
13
- } from "../chunk-TRY7BJA4.js";
13
+ } from "../chunk-3R7NQA3Z.js";
14
14
  import "../chunk-FUJ36YDV.js";
15
15
  import "../chunk-BQJIFRAZ.js";
16
- import "../chunk-WLPLHXNP.js";
16
+ import "../chunk-JNECYURT.js";
17
17
  import {
18
18
  validateCurrency
19
- } from "../chunk-HC4I7LAV.js";
20
- import "../chunk-QSZW2I5Y.js";
19
+ } from "../chunk-W3VGCNG6.js";
20
+ import "../chunk-M3T5JYDJ.js";
21
21
  import "../chunk-66HGCPBU.js";
22
- import "../chunk-OIP44KBB.js";
22
+ import "../chunk-QGNXYVBO.js";
23
23
 
24
24
  // src/sdk/testing/test-context.ts
25
25
  function createTestContext(opts) {
@@ -1,4 +1,4 @@
1
- import { C as Currency } from './step-cache-B7svmPz3.js';
1
+ import { C as Currency } from './step-cache--7yA5Ihr.js';
2
2
 
3
3
  /**
4
4
  * Thrown by `fiatToSatsCeil` / `satsToFiat` when the supplied `ratePerBtc` is
@@ -6,8 +6,8 @@ import {
6
6
  } from "./chunk-WMGXJQI3.js";
7
7
  import {
8
8
  verifyX402Payment
9
- } from "./chunk-LCCG5HQM.js";
10
- import "./chunk-GAZBBMAA.js";
9
+ } from "./chunk-3Q6FTZDB.js";
10
+ import "./chunk-VTHYQCDB.js";
11
11
  import {
12
12
  X402_DEFAULT_FACILITATOR,
13
13
  X402_DEFAULT_NETWORK,
@@ -37,7 +37,7 @@ import {
37
37
  x402SupportedNetworksHint
38
38
  } from "./chunk-BPYMEMQX.js";
39
39
  import "./chunk-66HGCPBU.js";
40
- import "./chunk-OIP44KBB.js";
40
+ import "./chunk-QGNXYVBO.js";
41
41
  export {
42
42
  X402_DEFAULT_FACILITATOR,
43
43
  X402_DEFAULT_NETWORK,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dvmkit/sdk",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "SDK for building Digital Vending Machines: pay-per-use HTTPS services AI agents can find, pay, and call with no account or API key",
5
5
  "author": "DVM Technologies Ltd",
6
6
  "keywords": [