@dvmkit/sdk 0.2.0-rc.9 → 0.2.1-rc.9

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 (58) hide show
  1. package/README.md +2 -0
  2. package/dist/{chunk-V7EVFLAK.js → chunk-2D75MNNG.js} +154 -523
  3. package/dist/{chunk-BIFLRKMO.js → chunk-2KGG5ORW.js} +1 -1
  4. package/dist/{chunk-5URG56JJ.js → chunk-A4CM2BD3.js} +18 -2
  5. package/dist/{chunk-FT6HTUM4.js → chunk-AJNFXR7J.js} +1 -1
  6. package/dist/{chunk-S3XAHZQY.js → chunk-COYKJRMM.js} +24 -3
  7. package/dist/{chunk-UP2F5RRT.js → chunk-D7YQYLLM.js} +1 -4
  8. package/dist/{chunk-OMIQMMME.js → chunk-FPOLJRBF.js} +3 -3
  9. package/dist/{chunk-QP53RWAD.js → chunk-JAHRF5X3.js} +1 -1
  10. package/dist/{chunk-PCUQZDZA.js → chunk-JNKQZVZX.js} +95 -321
  11. package/dist/{chunk-JDT5LCJC.js → chunk-MD3H3BF7.js} +1 -1
  12. package/dist/{chunk-KSQEFVFJ.js → chunk-MMCE7XSR.js} +1 -1
  13. package/dist/{chunk-MRAGS5VP.js → chunk-N5B66UOS.js} +4 -16
  14. package/dist/{chunk-2ATUAUAO.js → chunk-O6D72KYA.js} +2 -2
  15. package/dist/{chunk-KXCKFIJI.js → chunk-QX52F6IB.js} +1 -1
  16. package/dist/{chunk-PHHAYRQV.js → chunk-U5VNEALI.js} +23 -10
  17. package/dist/{chunk-JLXYOV4Y.js → chunk-V5ZRATJH.js} +1 -1
  18. package/dist/{chunk-6GRIKOFB.js → chunk-VA7GT6C6.js} +5 -16
  19. package/dist/{chunk-O2X2CCKH.js → chunk-VIVXB4CD.js} +1 -1
  20. package/dist/{chunk-L67WTZX2.js → chunk-XMDQOXHO.js} +10 -33
  21. package/dist/{chunk-QT4ONTST.js → chunk-XRLKGCAW.js} +1 -1
  22. package/dist/{chunk-KMZXTBLA.js → chunk-XZ7LW4S5.js} +0 -1
  23. package/dist/{chunk-XQXJKJ3P.js → chunk-YO56VCTQ.js} +0 -4
  24. package/dist/{credit-ledger-5ZEJRI46.js → credit-ledger-MHA652TV.js} +2 -2
  25. package/dist/{credit-menu-D4Gcdgc4.d.ts → credit-menu-kDA9RVzD.d.ts} +135 -532
  26. package/dist/{fx-B0SLBe5x.d.ts → fx-DhyT1Cjh.d.ts} +1 -1
  27. package/dist/index.d.ts +5 -17
  28. package/dist/internal/caller.d.ts +109 -698
  29. package/dist/internal/caller.js +10 -12
  30. package/dist/internal/server.d.ts +17 -42
  31. package/dist/internal/server.js +15 -15
  32. package/dist/{job-store-B2uZvga4.d.ts → job-store-D3CcZp_g.d.ts} +6 -10
  33. package/dist/{lightning-backend-CQBnQgsT.d.ts → lightning-backend-BhsyrBLa.d.ts} +1 -15
  34. package/dist/{memory-credit-ledger-ZOH6C3N4.js → memory-credit-ledger-BYBATRN3.js} +3 -3
  35. package/dist/{mpp-secret-state-WNAQQ6K4.js → mpp-secret-state-B5GCILVH.js} +1 -1
  36. package/dist/{mpp-setup-IOJBF7DB.js → mpp-setup-MPP3ST5X.js} +1 -1
  37. package/dist/{payout-reporter-5PIRYFVQ.js → payout-reporter-KEMUXEUO.js} +2 -2
  38. package/dist/{postgres-consumed-credential-store-ISRHBMOU.js → postgres-consumed-credential-store-6N2V5MJN.js} +1 -1
  39. package/dist/postgres-job-store-MZZZMS2B.js +7 -0
  40. package/dist/postgres-kv-store-DXGTKXLU.js +7 -0
  41. package/dist/{postgres-replay-store-IZFLTTAC.js → postgres-replay-store-ZF4JNZOW.js} +2 -2
  42. package/dist/{processed-payment-store-FIDI3RNH.js → processed-payment-store-GKMAWOM3.js} +2 -2
  43. package/dist/revenue-reporter-O75BGYFK.js +7 -0
  44. package/dist/server/index.d.ts +34 -140
  45. package/dist/server/index.js +52 -124
  46. package/dist/{step-cache-CXg7ziML.d.ts → step-cache-v2yhyhSZ.d.ts} +359 -1112
  47. package/dist/{tempo-charge-store-76TDAF34.js → tempo-charge-store-SDTUNTKA.js} +2 -2
  48. package/dist/{tempo-lifecycle-DXM7QXJQ.js → tempo-lifecycle-G5SB4HFC.js} +4 -4
  49. package/dist/{tempo-session-store-2JNOKJGX.js → tempo-session-store-WF3VZXNF.js} +2 -2
  50. package/dist/{tempo-wallet-O67H5M4N.js → tempo-wallet-ZFNUDFVO.js} +1 -1
  51. package/dist/testing/index.d.ts +2 -2
  52. package/dist/testing/index.js +2 -2
  53. package/dist/{usd-BNDg1715.d.ts → usd-Cu9G6xv2.d.ts} +1 -1
  54. package/dist/{x402-7S2EFINY.js → x402-CI6PSHNO.js} +4 -4
  55. package/package.json +2 -2
  56. package/dist/postgres-job-store-OGQ6IT4U.js +0 -7
  57. package/dist/postgres-kv-store-D5E2EZ24.js +0 -7
  58. package/dist/revenue-reporter-NNCNRY4C.js +0 -7
@@ -1,13 +1,13 @@
1
- import { ab as CashuMode, bK as CreditDrainEnqueue, R as ResolvedCreditConfig, bL as DVMAuthScheme, z as SignedRequestDomain, bM as CreditLedgerLike, bN as X402RefundSettlementGate, bO as CreditSnapshot, bP as DrawResult, bQ as X402SettlementStatus, bR as X402UnresolvedRefund, bS as GrownDrawResult, bT as DrawResolution, bU as FundingRecord, X as FundingReceipt, bV as CreditInvoiceRecord, bW as InvoiceSettlement, bX as BlockedInvoiceCursor, bY as InvoiceReconciliation, bZ as InvoiceWriteOff, b_ as DrawRecord, b$ as StalePendingDrawCursor, c0 as TempoCreditLossEvidence, c1 as CreditLedgerQuerier, c2 as TempoCreditLoss, c3 as X402CreditLossEvidence, c4 as X402CreditLoss, c5 as DrainMethod, c6 as DrainRequestResult, c7 as BitcoinDepositLiability, bo as FundingLot, c8 as CreditDrainRecord, c9 as ChannelDrainCursor, ca as DrainWriteOff, cb as DrainReleaseResult, cc as DrainFulfilment, cd as DrainTransitionResult, Y as JobReceipt, a1 as Message, K as KVStore, F as SignedRequestReplayStore, Z as ZodLike, a as DVMDescriptor } from '../step-cache-CXg7ziML.js';
2
- export { ce as CLIENT_COMPATIBILITY_HEADERS, d as CanonicalEnvelope, cf as ClientCompatibility, cg as ClientCompatibilityEnv, ch as ClientCompatibilityGate, ci as ClientCompatibilityRequirement, cj as ClientSemVer, e as CreateSignedRequestVerifierOpts, ck as CreditFundingBasis, cl as CreditInvoiceStatus, cm as CreditLedger, cn as CreditLedgerError, co as CreditLedgerErrorCode, cp as CreditLedgerErrorDetails, cq as CreditLedgerPool, cr as CreditStatus, cs as DRAIN_DELIVERY_RESERVE_SATS, ct as DVM_PROTOCOL_VERSION, cu as DrainConflictReason, cv as DrawRailValue, cw as DrawStatus, cx as JobCostReportPayload, cy as JobTerminalReportPayload, cz as PostgresX402ChannelStorage, cA as ReplayStoreBackend, cB as RevenueSkippedNoRailPayload, cC as RevenueSkippedNoRailReason, w as SIGNED_REQUEST_AUTH_ID, x as SIGNED_REQUEST_STATEMENT_VERSION, cD as Secp256k1AuthOpts, y as SignedRequestAudience, B as SignedRequestError, E as SignedRequestFailure, G as SignedRequestSignOpts, H as SignedRequestStatementHeader, M as SignedRequestVerifier, cE as X402ChannelStorageOpts, cF as X402RelayLockHolder, cG as X402RelaySubmissionLock, cH as X402RelaySubmissionLockError, cI as allocateDrawValue, cJ as clientCompatibilityAttributes, cK as clientCompatibilityMiddleware, cL as clientUpgradeRequired, N as createSignedRequestVerifier, cM as parseClientCapabilities, cN as parseClientCompatibility, cO as parseDvmClient, cP as parseProtocolVersion, cQ as requireClientCompatibility, cR as secp256k1Auth, cS as signedRequestInput, T as signedRequestStatementHeader } from '../step-cache-CXg7ziML.js';
1
+ import { ab as CashuMode, bK as CreditDrainEnqueue, R as ResolvedCreditConfig, bL as DVMAuthScheme, z as SignedRequestDomain, bM as CreditLedgerLike, bN as X402RefundSettlementGate, bO as CreditSnapshot, bP as DrawResult, bQ as X402SettlementStatus, bR as X402UnresolvedRefund, bS as GrownDrawResult, bT as DrawResolution, bU as FundingRecord, X as FundingReceipt, bV as CreditInvoiceRecord, bW as InvoiceSettlement, bX as BlockedInvoiceCursor, bY as InvoiceReconciliation, bZ as InvoiceWriteOff, b_ as DrawRecord, b$ as StalePendingDrawCursor, c0 as TempoCreditLossEvidence, c1 as CreditLedgerQuerier, c2 as TempoCreditLoss, c3 as X402CreditLossEvidence, c4 as X402CreditLoss, c5 as DrainMethod, c6 as DrainRequestResult, c7 as BitcoinDepositLiability, bo as FundingLot, c8 as CreditDrainRecord, c9 as ChannelDrainCursor, ca as DrainWriteOff, cb as DrainReleaseResult, cc as DrainFulfilment, cd as DrainTransitionResult, Y as JobReceipt, a1 as Message, K as KVStore, F as SignedRequestReplayStore, Z as ZodLike, a as DVMDescriptor } from '../step-cache-v2yhyhSZ.js';
2
+ export { ce as CLIENT_COMPATIBILITY_HEADERS, d as CanonicalEnvelope, cf as ClientCompatibility, cg as ClientCompatibilityEnv, ch as ClientCompatibilityGate, ci as ClientCompatibilityRequirement, cj as ClientSemVer, e as CreateSignedRequestVerifierOpts, ck as CreditFundingBasis, cl as CreditInvoiceStatus, cm as CreditLedger, cn as CreditLedgerError, co as CreditLedgerErrorCode, cp as CreditLedgerErrorDetails, cq as CreditLedgerPool, cr as CreditStatus, cs as DRAIN_DELIVERY_RESERVE_SATS, ct as DVM_PROTOCOL_VERSION, cu as DrainConflictReason, cv as DrawRailValue, cw as DrawStatus, cx as JobCostReportPayload, cy as JobTerminalReportPayload, cz as PostgresX402ChannelStorage, cA as ReplayStoreBackend, cB as RevenueSkippedNoRailPayload, cC as RevenueSkippedNoRailReason, w as SIGNED_REQUEST_AUTH_ID, x as SIGNED_REQUEST_STATEMENT_VERSION, cD as Secp256k1AuthOpts, y as SignedRequestAudience, B as SignedRequestError, E as SignedRequestFailure, G as SignedRequestSignOpts, H as SignedRequestStatementHeader, M as SignedRequestVerifier, cE as X402ChannelStorageOpts, cF as X402RelayLockHolder, cG as X402RelaySubmissionLock, cH as X402RelaySubmissionLockError, cI as allocateDrawValue, cJ as clientCompatibilityAttributes, cK as clientCompatibilityMiddleware, cL as clientUpgradeRequired, N as createSignedRequestVerifier, cM as parseClientCapabilities, cN as parseClientCompatibility, cO as parseDvmClient, cP as parseProtocolVersion, cQ as requireClientCompatibility, cR as secp256k1Auth, cS as signedRequestInput, T as signedRequestStatementHeader } from '../step-cache-v2yhyhSZ.js';
3
3
  import { Pool } from 'pg';
4
- import { ak as CreditMenu, b as AppEnv, U as UpfrontPaymentOpts, h as PaymentInfo, al as ReceiptIssuer, am as LightningReceive, an as TempoSettlementReadiness, ao as DVMHostOpts, ap as DVMServeResult } from '../credit-menu-D4Gcdgc4.js';
5
- export { aq as BuildCreditMenuArgs, ar as BuilderIdentity, as as CREDIT_ENVELOPE_KEYS, C as ConsumedCredentialStore, at as CreateX402BatchSettlementServerOpts, au as CreditEnvelope, av as CreditEnvelopeError, aw as CreditFundCommitment, ax as CreditTerms, ay as DEFAULT_INVOICE_TTL_SECONDS, az as DVMHost, aA as JobManager, aB as JobManagerOpts, aC as LightningReceiveConfig, aD as MIN_INVOICE_TTL_SECONDS, aE as MemoryConsumedCredentialStore, aF as MemoryConsumedCredentialStoreOpts, aG as MemoryProcessedPaymentStore, aH as MemoryX402ExactSettlementStore, aI as MountOpts, aJ as OwnerDisplay, aK as PaidJobCompletion, aL as PaymentMode, aM as PlatformReporterOpts, aN as PostgresProcessedPaymentStore, aO as PostgresX402ExactSettlementStore, aP as PriceFiat, aQ as ProcessedPaymentQuerier, aR as ProcessedPaymentRail, aS as ProcessedPaymentRecord, aT as ProcessedPaymentReplayError, aU as ProcessedPaymentStore, aV as X402BatchAcceptance, aW as X402BatchFunding, aX as X402BatchRefusal, aY as X402BatchSettlementServer, aZ as X402ExactAcceptance, a_ as X402ExactIntentConflictError, a$ as X402ExactSettlementAttempt, b0 as X402ExactSettlementChainEvidence, b1 as X402ExactSettlementEffect, b2 as X402ExactSettlementEvidenceMissingError, b3 as X402ExactSettlementEvidenceReader, b4 as X402ExactSettlementIntent, b5 as X402ExactSettlementNotReadyError, b6 as X402ExactSettlementServer, b7 as X402ExactSettlementServerOpts, b8 as X402ExactSettlementStatus, b9 as X402ExactSettlementStore, ba as X402SettlementChainEvidence, bb as X402SettlementEvidenceReader, bc as X402SettlementSubmissionError, bd as X402_BATCH_AUTO_SETTLEMENT, be as X402_BATCH_MIN_WITHDRAW_DELAY_SECONDS, bf as X402_BATCH_SETTLEMENT_NETWORK, bg as attachCreditMenu, bh as buildCreditMenu, bi as createDVMHost, bj as createX402BatchSettlementServer, bk as creditEnvelopeIgnoreFields, bl as drawSettlementRef, bm as extractCreditEnvelope, bn as fundingCommitment, bo as selectPrimaryCredit, bp as stripCreditEnvelope, bq as toCreditView } from '../credit-menu-D4Gcdgc4.js';
4
+ import { ak as CreditMenu, b as AppEnv, U as UpfrontPaymentOpts, h as PaymentInfo, al as ReceiptIssuer, am as LightningReceive, an as TempoSettlementReadiness, ao as DVMHostOpts, ap as DVMServeResult } from '../credit-menu-kDA9RVzD.js';
5
+ export { aq as BuildCreditMenuArgs, ar as BuilderIdentity, as as CREDIT_ENVELOPE_KEYS, C as ConsumedCredentialStore, at as CreateX402BatchSettlementServerOpts, au as CreditEnvelope, av as CreditEnvelopeError, aw as CreditFundCommitment, ax as CreditTerms, ay as DEFAULT_INVOICE_TTL_SECONDS, az as DVMHost, aA as JobManager, aB as JobManagerOpts, aC as LightningReceiveConfig, aD as MIN_INVOICE_TTL_SECONDS, aE as MemoryConsumedCredentialStore, aF as MemoryConsumedCredentialStoreOpts, aG as MemoryProcessedPaymentStore, aH as MemoryX402ExactSettlementStore, aI as MountOpts, aJ as OwnerDisplay, aK as PaidJobCompletion, aL as PaymentMode, aM as PlatformReporterOpts, aN as PostgresProcessedPaymentStore, aO as PostgresX402ExactSettlementStore, aP as PriceFiat, aQ as ProcessedPaymentQuerier, aR as ProcessedPaymentRail, aS as ProcessedPaymentRecord, aT as ProcessedPaymentReplayError, aU as ProcessedPaymentStore, aV as X402BatchAcceptance, aW as X402BatchFunding, aX as X402BatchRefusal, aY as X402BatchSettlementServer, aZ as X402ExactAcceptance, a_ as X402ExactIntentConflictError, a$ as X402ExactSettlementAttempt, b0 as X402ExactSettlementChainEvidence, b1 as X402ExactSettlementEffect, b2 as X402ExactSettlementEvidenceMissingError, b3 as X402ExactSettlementEvidenceReader, b4 as X402ExactSettlementIntent, b5 as X402ExactSettlementNotReadyError, b6 as X402ExactSettlementServer, b7 as X402ExactSettlementServerOpts, b8 as X402ExactSettlementStatus, b9 as X402ExactSettlementStore, ba as X402SettlementChainEvidence, bb as X402SettlementEvidenceReader, bc as X402SettlementSubmissionError, bd as X402_BATCH_AUTO_SETTLEMENT, be as X402_BATCH_MIN_WITHDRAW_DELAY_SECONDS, bf as X402_BATCH_SETTLEMENT_NETWORK, bg as attachCreditMenu, bh as buildCreditMenu, bi as createDVMHost, bj as createX402BatchSettlementServer, bk as creditEnvelopeIgnoreFields, bl as drawSettlementRef, bm as extractCreditEnvelope, bn as fundingCommitment, bo as selectPrimaryCredit, bp as stripCreditEnvelope, bq as toCreditView } from '../credit-menu-kDA9RVzD.js';
6
6
  import { Context } from 'hono';
7
7
  import { z } from 'zod';
8
- import { F as FxFetcher } from '../fx-B0SLBe5x.js';
9
- 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-B2uZvga4.js';
10
- export { a as JobStatus, b as JobStore, h as isStreamableJobStore } from '../job-store-B2uZvga4.js';
8
+ import { F as FxFetcher } from '../fx-DhyT1Cjh.js';
9
+ 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-D3CcZp_g.js';
10
+ export { a as JobStatus, b as JobStore, h as isStreamableJobStore } from '../job-store-D3CcZp_g.js';
11
11
  export { P as PinnedFetch, S as SSRFError, a as SSRFGuardOpts, b as SSRFReason, c as SSRFResolver, d as assertSafeUrl, e as createPinnedFetch } from '../ssrf-dMooihtY.js';
12
12
  import 'mppx';
13
13
  import '@x402/core/server';
@@ -15,12 +15,11 @@ import '@x402/evm/batch-settlement/server';
15
15
  import 'viem';
16
16
  import '@x402/core/types';
17
17
  import '@cashu/cashu-ts';
18
- import '../lightning-backend-CQBnQgsT.js';
18
+ import '../lightning-backend-BhsyrBLa.js';
19
19
 
20
20
  /** Lifetime of a per-call implicit credit before the ledger refuses new draws. */
21
21
  declare const IMPLICIT_CREDIT_TTL_MS: number;
22
22
 
23
- /** Builder-lock and Cashu accumulator opts resolved from environment variables. */
24
23
  interface ResolvedCashuOpts {
25
24
  cashuMode: CashuMode | undefined;
26
25
  lockPubkey: string | undefined;
@@ -42,10 +41,7 @@ interface ResolvedCashuOpts {
42
41
  declare function resolveCashuOptsFromEnv(env: Record<string, string>, pool?: Pool, cashuModeHint?: CashuMode): Promise<ResolvedCashuOpts>;
43
42
 
44
43
  /**
45
- * What a terminal drain transition needs in order to book its platform drain
46
- * report. Every field is optional because a DVM can legitimately
47
- * run without platform reporting — a `dvmctl dev` server, a self-hosted
48
- * builder, a test host — and a drain must still be fulfillable there.
44
+ * Reporting is optional; an unwired host still runs the money transition.
49
45
  */
50
46
  interface DrainReportWiring {
51
47
  /** The SDK's own Postgres, which holds both the ledger and the reporter's outbox. */
@@ -57,14 +53,8 @@ interface DrainReportWiring {
57
53
  }
58
54
 
59
55
  /**
60
- * Signed body of a `POST /v1/credit` request. The op discriminator
61
- * lives **inside** the signed bytes, so a network attacker can't rewrite a
62
- * `balance` read into a `drain`.
63
- *
64
- * Deliberately independent of `credit-envelope.ts`, which parses the credit
65
- * fields riding a `/v1/job` body: that shape pairs `credit_id` with a
66
- * mandatory `draw_id`, and a fund-only top-up has no draw. Two routes, two
67
- * schemas — sharing one would force a top-up to invent a draw id.
56
+ * Authenticate the raw body, including op. Its schema is independent of job-input credit/draw
57
+ * envelopes; normal job schema projection must not define this wire contract.
68
58
  */
69
59
  declare const CREDIT_REQUEST_SCHEMA: z.ZodObject<{
70
60
  op: z.ZodEnum<{
@@ -99,49 +89,34 @@ declare const CREDIT_REQUEST_SCHEMA: z.ZodObject<{
99
89
  timestamp: z.ZodNumber;
100
90
  nonce: z.ZodString;
101
91
  }, z.core.$strip>;
102
- /** Parsed `/v1/credit` body. */
103
92
  type CreditRequest = z.infer<typeof CREDIT_REQUEST_SCHEMA>;
104
- /** Everything the `/v1/credit` handler needs from the server that mounts it. */
105
93
  interface CreditRouteDeps {
106
- /** Resolved credit sizing, or `undefined` when this DVM didn't opt in. */
107
94
  menu: () => Promise<CreditMenu | undefined>;
108
- /** Resolved builder policy; absent and older config fail closed. */
109
95
  creditConfig: ResolvedCreditConfig | undefined;
110
96
  auth: DVMAuthScheme | undefined;
111
97
  /** Exact `/v1/credit` audience and operation expected by the auth gate. */
112
98
  authDomain?: SignedRequestDomain;
113
99
  ledger: CreditLedgerLike;
114
100
  fxFetcher: FxFetcher;
115
- /** Per-DVM + per-request rail wiring, shared with `/v1/job` (see `railVerifyOpts`). */
116
101
  railOpts: (c: Context<AppEnv>) => Promise<UpfrontPaymentOpts>;
117
102
  /**
118
- * Book a committed top-up as a platform deposit. A fund-only
119
- * top-up moves real money onto a credit whose draws will each book revenue
120
- * later, so skipping this would report the spending without the money that
121
- * backed it — the DVM's outstanding liability would go negative.
103
+ * Report committed fund-only top-ups as deposits. They have no job terminal to book the
104
+ * liability; replay must not report it twice.
122
105
  */
123
106
  onDeposit: (funding: NonNullable<PaymentInfo["funding"]>) => void;
124
107
  /**
125
- * Platform drain-report wiring, used by the cashu pickup — the
126
- * one terminal drain transition that lands on this caller-facing route.
127
- * Empty on a DVM with no platform reporting, which changes nothing about
128
- * the reclaim itself.
108
+ * Optional terminal drain report wiring: Cashu pickup and channel completion commit their
109
+ * ledger transition with its report.
129
110
  */
130
111
  drainReport: DrainReportWiring;
131
112
  /**
132
- * Receipt signer, when this DVM has a receipt key. Drain ops
133
- * countersign every reclaim event with it; absent, drains still
134
- * work — the ledger stays authoritative, the caller just gets no portable
135
- * evidence artifact.
113
+ * Optional signer for reclaim observations. The ledger transition remains authoritative;
114
+ * signature issuance happens after commit and may fail separately.
136
115
  */
137
116
  receiptIssuer: ReceiptIssuer | undefined;
138
117
  /**
139
- * The Lightning receive leg, when this DVM configured one.
140
- * Absent ⇒ `method: "lightning"` is refused with `lightning_unavailable`
141
- * and the funding menu never advertised it in the first place.
142
- *
143
- * Only the *issue* path reaches through this. Settling goes via
144
- * {@link settleLightning}, which is where a settlement books its deposit.
118
+ * Optional receive-only Lightning funding leg. Issuance uses the wallet; polling uses the
119
+ * shared settlement hook. An absent leg refuses method:lightning.
145
120
  */
146
121
  lightning: {
147
122
  receive: LightningReceive;
@@ -154,28 +129,8 @@ interface CreditRouteDeps {
154
129
  * invoice on the same credit is swept with it.
155
130
  */
156
131
  settleLightning: (callerPubkey: string, creditId?: string) => Promise<void>;
157
- /** Hosted operator fee-token gate; absent on self-hosted DVMs. */
158
132
  tempoSettlementReadiness?: TempoSettlementReadiness;
159
133
  }
160
- /**
161
- * `POST /v1/credit` — the caller-facing surface of the credits settlement
162
- * layer (the funding-menu and signed-operation contract). Three ops on one signed, replay-protected
163
- * envelope, mirroring `/v1/job`'s auth discipline exactly:
164
- *
165
- * - **fund** — a top-up with no job attached. The rail artifact rides the same
166
- * headers as `/v1/job` (`X-Cashu` + `X-Cashu-Request-Id`, `X-PAYMENT`,
167
- * `Authorization: Payment …`) and a missing or bad one comes back as the
168
- * same 402 envelope, which is what lets a caller's existing resumable-submit
169
- * machinery drive a top-up with no new client code.
170
- * - **balance** — what do I hold here, including expired credits (their value
171
- * is still the caller's), plus the funding menu, so the same read
172
- * also answers what may be added.
173
- * - **drain** — reclaim the unspent balance (the reclaim contract). One
174
- * op is both the request and the poll/pickup: the first call debits the
175
- * available balance into a `pending` liability; re-polling the same
176
- * `drain_id` returns the current state, delivers the parked Cashu token
177
- * when the builder's batch job has parked it, and is idempotent throughout.
178
- */
179
134
  declare function handleCreditRequest(c: Context<AppEnv>, deps: CreditRouteDeps): Promise<Response>;
180
135
 
181
136
  /**
@@ -192,61 +147,24 @@ type InitLockPool = Pick<Pool, "connect"> & {
192
147
  };
193
148
  };
194
149
  /**
195
- * The single session advisory-lock key serializing **all** SDK boot-time
196
- * schema work against concurrent creators — two machines cold-booting one DVM
197
- * against a fresh database, or parallel test files sharing one DB.
198
- *
199
- * Postgres' `IF NOT EXISTS` existence check is not atomic against a concurrent
200
- * creator: two sessions running the same `CREATE TABLE IF NOT EXISTS` at once
201
- * can raise `duplicate key value violates unique constraint
202
- * "pg_type_typname_nsp_index"` (23505) in the loser, which at SDK boot is an
203
- * unhandled throw that kills the machine.
204
- *
205
- * Deliberately distinct from `PLATFORM_INIT_ADVISORY_LOCK` (17320917) — a
206
- * DVM's own database is not the platform database — and from the first-party
207
- * DVMs' own keys (cast 17320918, scrape 17320926, scribe 24700919). **A new
208
- * SDK store reuses this key rather than inventing a second one**: one key means
209
- * there is only ever one lock order, so the per-store lock-order inversion that
210
- * deadlocked can't recur.
150
+ * All SDK boot DDL shares one advisory-lock key. CREATE TABLE IF NOT EXISTS
151
+ * can still race in Postgres system catalogs across machines. Reusing one key
152
+ * also prevents inconsistent lock acquisition order between SDK stores.
211
153
  */
212
154
  declare const SDK_INIT_ADVISORY_LOCK = 17320927;
213
155
  /**
214
- * Run `fn` holding {@link SDK_INIT_ADVISORY_LOCK} on `db`. Every SDK
215
- * boot-path `CREATE TABLE IF NOT EXISTS` goes through here.
216
- *
217
- * Overlapping callers on the same pool share **one** acquisition: the first
218
- * connects and locks, concurrent and nested callers join the held lock, and
219
- * the last one out unlocks and releases the client. That keeps * deliberately-parallel store-init batch parallel — six `init()`s racing each
220
- * other would otherwise queue behind one another — and keeps the uncontended
221
- * cost at one extra round trip per boot phase rather than one per store.
222
- * Sharing is safe for the DDL, which is what this lock is for: it excludes
223
- * *other machines*, and within one process no two inits create the same table.
224
- * It is not by itself a mutex between same-pool callers — two of them
225
- * concurrently running one non-idempotent statement still race, so anything
226
- * riding this lock that isn't `CREATE … IF NOT EXISTS` must carry its own
227
- * conflict handling (`seedLockPubkeyState`'s `ON CONFLICT DO NOTHING`).
228
- *
229
- * Session-level (not `pg_advisory_xact_lock`) because the DDL runs in
230
- * autocommit with no enclosing transaction, so the lock and the unlock ride a
231
- * dedicated pinned client — advisory locks are session-scoped and the unlock
232
- * must land on the backend that holds it. Released in `finally` on every path
233
- * including throws: an SDK boot that died holding this lock would block every
234
- * sibling until its connection closed.
235
- *
236
- * Guarded DDL needs a second connection while the advisory-lock client stays
237
- * pinned. Pools with `max < 2` would starve boot and are rejected.
156
+ * Overlapping callers on one pool share a pinned session lock and run their
157
+ * guarded work in order. A nested call from the active callback is reentrant.
158
+ * The last caller unlocks, preserving protection against other pools/processes.
159
+ * DDL runs on another connection; pools smaller than two are rejected.
160
+ * The pinned client is released in finally, including guarded failures.
238
161
  */
239
162
  declare function withSdkInitLock<T>(db: InitLockPool, fn: () => Promise<T>): Promise<T>;
240
163
 
241
164
  /**
242
- * In-memory {@link CreditLedgerLike} for pool-less setups — devMode, direct
243
- * `createDVMServer` tests, and the in-process x402 money loop — mirroring the
244
- * `MemoryJobStore` precedent. Same semantics as the Postgres `CreditLedger`
245
- * (two-phase draws, replay-before-expiry, `draw_conflict`, gap-free
246
- * `ledger_seq`), minus durability and cross-machine safety: per-process only,
247
- * so production DVMs must use the Postgres ledger (the durable-ledger requirement).
248
- * Every mutating verb is synchronous between awaits, so operations are
249
- * atomic in-process; the `tx` handles are accepted and ignored.
165
+ * Per-process development/test ledger without durability or cross-machine safety. Mutations
166
+ * run synchronously between awaits; accepted tx handles are ignored. Production funding
167
+ * requires a durable ledger.
250
168
  */
251
169
  declare class MemoryCreditLedger implements CreditLedgerLike {
252
170
  /**
@@ -263,13 +181,10 @@ declare class MemoryCreditLedger implements CreditLedgerLike {
263
181
  private x402Settlements?;
264
182
  /** Internal disposable transaction snapshot. The caller must serialize every ledger access. */
265
183
  forkForTransaction(): MemoryCreditLedger;
266
- /** See {@link CreditLedger.useX402SettlementGate} — same contract. */
267
184
  useX402SettlementGate(gate: X402RefundSettlementGate): void;
268
185
  fund(args: Parameters<CreditLedgerLike["fund"]>[0]): Promise<CreditSnapshot>;
269
186
  draw(args: Parameters<CreditLedgerLike["draw"]>[0]): Promise<DrawResult>;
270
- /** See {@link CreditLedger.blockingX402Refund} — same contract. */
271
187
  blockingX402Refund(channelId: string | null | undefined, statuses: X402SettlementStatus[]): Promise<X402UnresolvedRefund | undefined>;
272
- /** The unresolved x402 refund that must stop an effect on `creditId`. */
273
188
  private blockingRefundForCredit;
274
189
  growDraw(args: Parameters<CreditLedgerLike["growDraw"]>[0]): Promise<GrownDrawResult>;
275
190
  settle(args: Parameters<CreditLedgerLike["settle"]>[0]): Promise<DrawResolution>;
@@ -316,7 +231,6 @@ declare class MemoryCreditLedger implements CreditLedgerLike {
316
231
  private findByPaymentHash;
317
232
  private fundSync;
318
233
  private drawSync;
319
- /** Mid-job top-up growth — see `CreditLedger.growDraw` for the semantics. */
320
234
  private growDrawSync;
321
235
  get(creditId: string, opts?: {
322
236
  nowMs?: number;
@@ -336,7 +250,6 @@ declare class MemoryCreditLedger implements CreditLedgerLike {
336
250
  limit: number;
337
251
  after?: StalePendingDrawCursor;
338
252
  }): Promise<DrawRecord[]>;
339
- /** Settled draws' native value for the credit an x402 channel funded. */
340
253
  earnedNativeForX402Channel(channelId: string): Promise<number | undefined>;
341
254
  getCreditByX402Channel(channelId: string): Promise<CreditSnapshot | undefined>;
342
255
  terminalizeTempoCredits(evidence: TempoCreditLossEvidence, _tx?: CreditLedgerQuerier): Promise<TempoCreditLoss[]>;
@@ -563,16 +476,8 @@ interface PostgresReplayStoreOpts {
563
476
  gcSampleRate?: number;
564
477
  }
565
478
  /**
566
- * Postgres-backed replay store implementing {@link SignedRequestReplayStore}.
567
- *
568
- * Cross-machine safe: relies on the PK on `(pubkey, timestamp, nonce)` with
569
- * `INSERT ... ON CONFLICT DO NOTHING` to detect duplicates atomically across
570
- * concurrent inserts from multiple machines. The consumer hands in a `Pool`
571
- * (matching `PostgresJobStore` / `PostgresKVStore`) and manages its lifecycle.
572
- *
573
- * Multi-machine deploys of secp256k1-auth'd DVMs SHOULD use this store to
574
- * close the per-process replay window — see {@link SignedRequestReplayStore}
575
- * for the threat model.
479
+ * The (pubkey, timestamp, nonce) primary key detects concurrent duplicates
480
+ * atomically across machines. The caller owns the pool lifecycle.
576
481
  */
577
482
  declare class PostgresReplayStore implements SignedRequestReplayStore {
578
483
  private pool;
@@ -598,18 +503,7 @@ declare function stripProtocolEnvelope(schema: unknown, data: unknown): unknown;
598
503
  declare function requestIdFromEnvelope(data: unknown): string | undefined;
599
504
  declare function hasInvalidRequestId(data: unknown): boolean;
600
505
 
601
- /**
602
- * Convenience one-liner over {@link createDVMHost}. For
603
- * single-DVM hosts, `serve(dvm, opts)` is equivalent to
604
- * `createDVMHost(opts).mount(dvm).serve()`. Multi-DVM hosts go through
605
- * `createDVMHost` directly so each mount can carry its own prefix.
606
- *
607
- * This is **shorthand-over-host**, not a parallel code path — every wiring
608
- * step (Cashu/MPP/x402 envelope resolution, platform reporter, db, fx) flows
609
- * through `createDVMHost`. First-party DVMs that use `serve(...)` are NOT
610
- * exposed to the wiring-drift bug class fixed in 485/511, which was
611
- * about bypassing the host entirely. There is no migration to do.
612
- */
506
+ /** Single-DVM host. Use createDVMHost for multiple mounts with distinct prefixes. */
613
507
  declare function serve<State, InputSchema extends ZodLike | undefined = undefined>(descriptor: DVMDescriptor<State, InputSchema>, opts?: DVMHostOpts): Promise<DVMServeResult>;
614
508
 
615
- export { BlockedInvoiceCursor, CREDIT_REQUEST_SCHEMA, CreditInvoiceRecord, CreditLedgerLike, CreditLedgerQuerier, CreditMenu, type CreditRequest, type CreditRouteDeps, CreditSnapshot, DVMAuthScheme, DVMHostOpts, DVMServeResult, DrawRecord, DrawResolution, DrawResult, FundingRecord, GrownDrawResult, IMPLICIT_CREDIT_TTL_MS, type InitLockPool, InvoiceReconciliation, InvoiceSettlement, InvoiceWriteOff, JobRecord, LightningReceive, MemoryCreditLedger, PostgresJobStore, PostgresKVStore, PostgresReplayStore, type PostgresReplayStoreOpts, REQUEST_ID_FIELD, type ResolvedCashuOpts, SDK_INIT_ADVISORY_LOCK, SignedRequestDomain, SignedRequestReplayStore, StalePendingDrawCursor, StreamableJobStore, handleCreditRequest, hasInvalidRequestId, protocolEnvelopeIgnoreFields, requestIdFromEnvelope, resolveCashuOptsFromEnv, serve, stripProtocolEnvelope, withSdkInitLock };
509
+ export { BitcoinDepositLiability, BlockedInvoiceCursor, CREDIT_REQUEST_SCHEMA, CreditInvoiceRecord, CreditLedgerLike, CreditLedgerQuerier, CreditMenu, type CreditRequest, type CreditRouteDeps, CreditSnapshot, DVMAuthScheme, DVMHostOpts, DVMServeResult, DrawRecord, DrawResolution, DrawResult, FundingRecord, GrownDrawResult, IMPLICIT_CREDIT_TTL_MS, type InitLockPool, InvoiceReconciliation, InvoiceSettlement, InvoiceWriteOff, JobRecord, LightningReceive, MemoryCreditLedger, PostgresJobStore, PostgresKVStore, PostgresReplayStore, type PostgresReplayStoreOpts, REQUEST_ID_FIELD, type ResolvedCashuOpts, SDK_INIT_ADVISORY_LOCK, SignedRequestDomain, SignedRequestReplayStore, StalePendingDrawCursor, StreamableJobStore, handleCreditRequest, hasInvalidRequestId, protocolEnvelopeIgnoreFields, requestIdFromEnvelope, resolveCashuOptsFromEnv, serve, stripProtocolEnvelope, withSdkInitLock };