@dvmkit/sdk 0.1.2-rc.7 → 0.1.3-rc.7

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 (45) hide show
  1. package/README.md +14 -0
  2. package/dist/chunk-2K7E3N2D.js +1709 -0
  3. package/dist/{chunk-N4VTG3KH.js → chunk-3ZHMQCYP.js} +645 -3027
  4. package/dist/{chunk-TKA6ZP4M.js → chunk-4B56DEEV.js} +50 -426
  5. package/dist/chunk-BIFLRKMO.js +87 -0
  6. package/dist/chunk-BQ2NMWKE.js +160 -0
  7. package/dist/{chunk-LDTWX7JW.js → chunk-BTZY7VPH.js} +13 -1
  8. package/dist/{chunk-FJDCFHW5.js → chunk-C6JHBLMW.js} +3 -81
  9. package/dist/{chunk-EXHBXA4U.js → chunk-DBCLBYHP.js} +13 -1
  10. package/dist/chunk-EPNDZ5DH.js +1010 -0
  11. package/dist/{chunk-P4RUVDU7.js → chunk-H2MEFVH6.js} +12 -141
  12. package/dist/chunk-KXZUCCEY.js +142 -0
  13. package/dist/{chunk-6JZIX5WW.js → chunk-LLXV32HA.js} +82 -5
  14. package/dist/{chunk-LWUR4CGG.js → chunk-MLRCSJYX.js} +11 -3
  15. package/dist/{chunk-2ABMGUDS.js → chunk-NFRM5QYP.js} +83 -10
  16. package/dist/chunk-RW5LP57K.js +44 -0
  17. package/dist/chunk-YDIYXGYL.js +384 -0
  18. package/dist/{chunk-JGGI65I3.js → chunk-Z4BNLUZF.js} +1 -150
  19. package/dist/{credit-ledger-ED6JXKVD.js → credit-ledger-2DFQHNLB.js} +2 -2
  20. package/dist/{credit-menu-BM4qCD5U.d.ts → credit-menu-C7zAJElJ.d.ts} +1632 -1946
  21. package/dist/{fx-C-liI3oY.d.ts → fx-BF_SG2i0.d.ts} +1 -1
  22. package/dist/index.d.ts +7 -6
  23. package/dist/index.js +8 -4
  24. package/dist/internal/caller.d.ts +10429 -0
  25. package/dist/internal/caller.js +9957 -0
  26. package/dist/internal/index.d.ts +2 -10816
  27. package/dist/internal/index.js +2 -10130
  28. package/dist/internal/server.d.ts +404 -0
  29. package/dist/internal/server.js +202 -0
  30. package/dist/job-store-Bn23V3QU.d.ts +576 -0
  31. package/dist/lightning-backend-C04nH94l.d.ts +367 -0
  32. package/dist/{memory-credit-ledger-XJ5VQEVP.js → memory-credit-ledger-OP24Z2KO.js} +3 -3
  33. package/dist/{postgres-job-store-J5F4GUWU.js → postgres-job-store-TAONYLIF.js} +1 -1
  34. package/dist/{revenue-reporter-JIKUPXOK.js → revenue-reporter-XXSU5KVB.js} +1 -1
  35. package/dist/server/index.d.ts +27 -11
  36. package/dist/server/index.js +93 -69
  37. package/dist/{job-store-C53VQ5uu.d.ts → step-cache-3cT4Shk0.d.ts} +31 -585
  38. package/dist/{tempo-session-store-DALMRIWN.js → tempo-session-store-2JNOKJGX.js} +2 -2
  39. package/dist/testing/index.d.ts +16 -4
  40. package/dist/testing/index.js +7 -3
  41. package/dist/{usd-gLcJB1ps.d.ts → usd-BnuXoFl5.d.ts} +1 -1
  42. package/dist/wallet-CJC8lwxx.d.ts +29 -0
  43. package/dist/{x402-FTG2GRAQ.js → x402-T2C5MX3T.js} +6 -3
  44. package/package.json +6 -2
  45. package/dist/{chunk-RU7SXHLO.js → chunk-UP2F5RRT.js} +3 -3
@@ -3,7 +3,7 @@ import {
3
3
  } from "../chunk-L4OYF4DQ.js";
4
4
  import {
5
5
  PostgresJobStore
6
- } from "../chunk-6JZIX5WW.js";
6
+ } from "../chunk-LLXV32HA.js";
7
7
  import {
8
8
  PostgresKVStore
9
9
  } from "../chunk-FROTD5XQ.js";
@@ -13,6 +13,19 @@ import {
13
13
  createPinnedFetch,
14
14
  envFlag
15
15
  } from "../chunk-TVI4V7GF.js";
16
+ import {
17
+ HttpTransport,
18
+ NwcBackend,
19
+ NwcError,
20
+ SpanWriter,
21
+ isTestMintUrl,
22
+ parseNwcUri,
23
+ validateX402Env,
24
+ withNwcPool
25
+ } from "../chunk-EPNDZ5DH.js";
26
+ import {
27
+ MemoryKVStore
28
+ } from "../chunk-RW5LP57K.js";
16
29
  import {
17
30
  CLIENT_COMPATIBILITY_HEADERS,
18
31
  CREDIT_ENVELOPE_KEYS,
@@ -20,15 +33,11 @@ import {
20
33
  CreditEnvelopeError,
21
34
  DEFAULT_LOCK_PUBKEY_GRACE_SECONDS,
22
35
  DVM_PROTOCOL_VERSION,
23
- HttpTransport,
24
36
  JobManager,
25
37
  MemoryConsumedCredentialStore,
26
38
  MemoryX402ExactSettlementStore,
27
- NwcBackend,
28
- NwcError,
29
39
  PostgresX402ExactSettlementStore,
30
40
  REQUEST_ID_FIELD,
31
- SpanWriter,
32
41
  X402ExactIntentConflictError,
33
42
  X402ExactSettlementEvidenceMissingError,
34
43
  X402ExactSettlementNotReadyError,
@@ -50,19 +59,15 @@ import {
50
59
  drawSettlementRef,
51
60
  extractCreditEnvelope,
52
61
  fundingCommitment,
53
- generateEphemeralReceiptKey,
54
62
  handleCreditRequest,
55
63
  hasInvalidRequestId,
56
64
  initLockPubkeyTable,
57
65
  initWalletAccumulatorTable,
58
- isTestMintUrl,
59
66
  parseClientCapabilities,
60
67
  parseClientCompatibility,
61
68
  parseDvmClient,
62
- parseNwcUri,
63
69
  parseProtocolVersion,
64
70
  protocolEnvelopeIgnoreFields,
65
- receiptPubkeyFromSecret,
66
71
  requestIdFromEnvelope,
67
72
  requireClientCompatibility,
68
73
  revenueReporterBannerState,
@@ -71,39 +76,50 @@ import {
71
76
  stripCreditEnvelope,
72
77
  stripProtocolEnvelope,
73
78
  toCreditView,
74
- unknownRouteNotFound,
75
- validateX402Env,
76
- withNwcPool
77
- } from "../chunk-N4VTG3KH.js";
79
+ unknownRouteNotFound
80
+ } from "../chunk-3ZHMQCYP.js";
81
+ import {
82
+ MemoryProcessedPaymentStore,
83
+ PostgresProcessedPaymentStore,
84
+ ProcessedPaymentReplayError
85
+ } from "../chunk-DMNLFNTW.js";
86
+ import "../chunk-BQ2NMWKE.js";
87
+ import {
88
+ MemoryCreditLedger
89
+ } from "../chunk-DBCLBYHP.js";
90
+ import {
91
+ SignedRequestError,
92
+ createDefaultReplayStore,
93
+ createSignedRequestVerifier,
94
+ signedRequestInput
95
+ } from "../chunk-H2MEFVH6.js";
96
+ import {
97
+ isStreamableJobStore
98
+ } from "../chunk-4B56DEEV.js";
99
+ import {
100
+ generateEphemeralReceiptKey,
101
+ receiptPubkeyFromSecret
102
+ } from "../chunk-2K7E3N2D.js";
78
103
  import {
79
104
  X402_DEFAULT_FACILITATOR,
80
105
  X402_DEFAULT_NETWORK,
81
106
  assertSupportedX402Network,
82
107
  x402NetworkToCaip2
83
- } from "../chunk-JGGI65I3.js";
108
+ } from "../chunk-Z4BNLUZF.js";
84
109
  import {
85
110
  IMPLICIT_CREDIT_TTL_MS
86
111
  } from "../chunk-5URG56JJ.js";
87
112
  import {
88
113
  resolveRpcOverride
89
114
  } from "../chunk-MKI6OVW4.js";
90
- import {
91
- MemoryCreditLedger
92
- } from "../chunk-EXHBXA4U.js";
93
115
  import {
94
116
  SIGNED_REQUEST_AUTH_ID,
95
117
  SIGNED_REQUEST_STATEMENT_VERSION,
96
- SignedRequestError,
97
- createDefaultReplayStore,
98
- createSignedRequestVerifier,
99
- signedRequestInput,
100
118
  signedRequestStatementHeader
101
- } from "../chunk-P4RUVDU7.js";
119
+ } from "../chunk-KXZUCCEY.js";
102
120
  import {
103
- MemoryKVStore,
104
- initLoggers,
105
- isStreamableJobStore
106
- } from "../chunk-TKA6ZP4M.js";
121
+ initLoggers
122
+ } from "../chunk-YDIYXGYL.js";
107
123
  import "../chunk-66HGCPBU.js";
108
124
  import "../chunk-FUJ36YDV.js";
109
125
  import "../chunk-27V2ILSR.js";
@@ -115,7 +131,11 @@ import {
115
131
  PostgresX402ChannelStorage,
116
132
  X402RelaySubmissionLockError,
117
133
  allocateDrawValue
118
- } from "../chunk-LWUR4CGG.js";
134
+ } from "../chunk-MLRCSJYX.js";
135
+ import {
136
+ SDK_INIT_ADVISORY_LOCK,
137
+ withSdkInitLock
138
+ } from "../chunk-S3XAHZQY.js";
119
139
  import {
120
140
  applyRetryToPool
121
141
  } from "../chunk-C3MTFLC6.js";
@@ -124,15 +144,6 @@ import {
124
144
  TEMPO_USDC_MAINNET,
125
145
  TempoSettlementReadiness
126
146
  } from "../chunk-5GFED3GJ.js";
127
- import {
128
- MemoryProcessedPaymentStore,
129
- PostgresProcessedPaymentStore,
130
- ProcessedPaymentReplayError
131
- } from "../chunk-DMNLFNTW.js";
132
- import {
133
- SDK_INIT_ADVISORY_LOCK,
134
- withSdkInitLock
135
- } from "../chunk-S3XAHZQY.js";
136
147
 
137
148
  // src/sdk/server/cashu-env.ts
138
149
  async function resolveCashuOptsFromEnv(env, pool, cashuModeHint) {
@@ -167,36 +178,46 @@ async function resolveCashuOptsFromEnv(env, pool, cashuModeHint) {
167
178
  );
168
179
  }
169
180
  }
181
+ const missingAdminConfig = [
182
+ ...!lockPubkey ? ["DVMKIT_CASHU_LOCK_PUBKEY"] : [],
183
+ ...!dvmId ? ["DVMKIT_DVM_ID"] : [],
184
+ ...!pool ? ["DATABASE_URL"] : []
185
+ ];
186
+ if (envMaybe.DVMKIT_NWC_RECEIVE_URI && cashuMode !== "p2pk-accumulator" && missingAdminConfig.length > 0) {
187
+ console.warn(
188
+ JSON.stringify({
189
+ level: "admin_surface_missing_config",
190
+ message: "Lightning credit recovery requires the builder admin surface, but its lock identity is incomplete.",
191
+ missing: missingAdminConfig
192
+ })
193
+ );
194
+ }
170
195
  let db;
171
- if (cashuMode === "p2pk-accumulator") {
172
- if (!lockPubkey || !dvmId || !pool) {
173
- const missing = [
174
- ...!lockPubkey ? ["DVMKIT_CASHU_LOCK_PUBKEY"] : [],
175
- ...!dvmId ? ["DVMKIT_DVM_ID"] : [],
176
- ...!pool ? ["DATABASE_URL"] : []
177
- ];
178
- console.warn(
196
+ if (cashuMode === "p2pk-accumulator" && missingAdminConfig.length > 0) {
197
+ console.warn(
198
+ JSON.stringify({
199
+ level: "accumulator_mode_missing_config",
200
+ message: "Cashu accumulator mode requires extra config \u2014 dropping cashu from advertised payment methods.",
201
+ missing: missingAdminConfig
202
+ })
203
+ );
204
+ }
205
+ if (lockPubkey && dvmId && pool) {
206
+ db = pool;
207
+ try {
208
+ if (cashuMode === "p2pk-accumulator") {
209
+ await initWalletAccumulatorTable(db);
210
+ }
211
+ await initLockPubkeyTable(db);
212
+ await seedLockPubkeyState(db, dvmId, lockPubkey);
213
+ } catch (err) {
214
+ console.error(
179
215
  JSON.stringify({
180
- level: "accumulator_mode_missing_config",
181
- message: "Cashu accumulator mode requires extra config \u2014 dropping cashu from advertised payment methods.",
182
- missing
216
+ level: cashuMode === "p2pk-accumulator" ? "accumulator_table_init_failed" : "admin_lock_table_init_failed",
217
+ error: err instanceof Error ? err.message : String(err)
183
218
  })
184
219
  );
185
- } else {
186
- db = pool;
187
- try {
188
- await initWalletAccumulatorTable(db);
189
- await initLockPubkeyTable(db);
190
- await seedLockPubkeyState(db, dvmId, lockPubkey);
191
- } catch (err) {
192
- console.error(
193
- JSON.stringify({
194
- level: "accumulator_table_init_failed",
195
- error: err instanceof Error ? err.message : String(err)
196
- })
197
- );
198
- db = void 0;
199
- }
220
+ db = void 0;
200
221
  }
201
222
  }
202
223
  return { cashuMode, lockPubkey, lockPubkeyGraceSeconds, db, dvmId, canonicalDvmId };
@@ -632,6 +653,7 @@ var LightningReceive = class _LightningReceive {
632
653
  payload: {
633
654
  dvmId: opts.dvmId,
634
655
  creditId: invoice.creditId,
656
+ callerPubkey: invoice.callerPubkey,
635
657
  fundingId: invoice.paymentHash,
636
658
  rail: "lightning",
637
659
  paidMsats: invoice.amountMsats,
@@ -1108,7 +1130,7 @@ function createDVMHost(opts = {}) {
1108
1130
  });
1109
1131
  applyRetryToPool(pool, "dvm-host");
1110
1132
  pgPool = pool;
1111
- const { PostgresJobStore: PostgresJobStore2 } = await import("../postgres-job-store-J5F4GUWU.js");
1133
+ const { PostgresJobStore: PostgresJobStore2 } = await import("../postgres-job-store-TAONYLIF.js");
1112
1134
  const pgJobStore = new PostgresJobStore2(pool);
1113
1135
  pendingInits.push(pgJobStore.init(), pgJobStore.initStreaming());
1114
1136
  jobStore = pgJobStore;
@@ -1208,7 +1230,7 @@ ${config.facilitatorAuth?.keyId ?? ""}`;
1208
1230
  { createPublicClient, createWalletClient, erc20Abi, http },
1209
1231
  { tempo: tempoMainnet, tempoModerato }
1210
1232
  ] = await Promise.all([
1211
- import("../tempo-session-store-DALMRIWN.js"),
1233
+ import("../tempo-session-store-2JNOKJGX.js"),
1212
1234
  import("viem/accounts"),
1213
1235
  import("viem"),
1214
1236
  import("viem/chains")
@@ -1375,7 +1397,7 @@ ${config.facilitatorAuth?.keyId ?? ""}`;
1375
1397
  sharedPgConsumedStore = consumedStore;
1376
1398
  }
1377
1399
  if (pgPool) {
1378
- const { CreditLedger: CreditLedger2 } = await import("../credit-ledger-ED6JXKVD.js");
1400
+ const { CreditLedger: CreditLedger2 } = await import("../credit-ledger-2DFQHNLB.js");
1379
1401
  const pgLedger = new CreditLedger2(pgPool, tempoSessionStore);
1380
1402
  pendingInits.push(pgLedger.init());
1381
1403
  creditLedger = pgLedger;
@@ -1384,7 +1406,7 @@ ${config.facilitatorAuth?.keyId ?? ""}`;
1384
1406
  pendingInits.push(pgProcessed.init());
1385
1407
  processedPayments = pgProcessed;
1386
1408
  } else {
1387
- const { MemoryCreditLedger: MemoryCreditLedger2 } = await import("../memory-credit-ledger-XJ5VQEVP.js");
1409
+ const { MemoryCreditLedger: MemoryCreditLedger2 } = await import("../memory-credit-ledger-OP24Z2KO.js");
1388
1410
  creditLedger = new MemoryCreditLedger2();
1389
1411
  const { MemoryProcessedPaymentStore: MemoryProcessedPaymentStore2 } = await import("../processed-payment-store-HAA4SFNK.js");
1390
1412
  processedPayments = new MemoryProcessedPaymentStore2();
@@ -1403,7 +1425,7 @@ ${config.facilitatorAuth?.keyId ?? ""}`;
1403
1425
  }
1404
1426
  };
1405
1427
  const mppActive = mounts.some((e) => (e.descriptor.mpp ?? mpp) !== void 0);
1406
- const adminCashuActive = cashuOpts.cashuMode === "p2pk-accumulator" && !!cashuOpts.db && !!cashuOpts.dvmId && !!cashuOpts.lockPubkey;
1428
+ const adminActive = !!cashuOpts.db && !!cashuOpts.dvmId && !!cashuOpts.lockPubkey;
1407
1429
  const consumedBackend = opts.consumedCredentialStore ? "user-supplied" : pgPool ? "postgres" : "memory";
1408
1430
  const adminCashuBackend = pgPool ? "postgres" : "memory";
1409
1431
  checkStoreFallback(
@@ -1423,7 +1445,7 @@ ${config.facilitatorAuth?.keyId ?? ""}`;
1423
1445
  checkStoreFallback(
1424
1446
  "admin-cashu-nonce",
1425
1447
  "admin_cashu_nonce_store_in_memory",
1426
- adminCashuActive,
1448
+ adminActive,
1427
1449
  adminCashuBackend,
1428
1450
  "replay a signed P2PK admin challenge"
1429
1451
  );
@@ -1491,7 +1513,9 @@ ${config.facilitatorAuth?.keyId ?? ""}`;
1491
1513
  processedPayments,
1492
1514
  lightningReceive,
1493
1515
  tempoObserverHealth,
1494
- tempoSettlementReadiness
1516
+ tempoSettlementReadiness,
1517
+ onJobRetentionSweepFailed: opts.onJobRetentionSweepFailed,
1518
+ onJobRetentionSweepRecovered: opts.onJobRetentionSweepRecovered
1495
1519
  });
1496
1520
  entry.shutdown = shutdown;
1497
1521
  if (payoutReporter && !tempoPayoutOwner) {