@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.
- package/README.md +14 -0
- package/dist/chunk-2K7E3N2D.js +1709 -0
- package/dist/{chunk-N4VTG3KH.js → chunk-3ZHMQCYP.js} +645 -3027
- package/dist/{chunk-TKA6ZP4M.js → chunk-4B56DEEV.js} +50 -426
- package/dist/chunk-BIFLRKMO.js +87 -0
- package/dist/chunk-BQ2NMWKE.js +160 -0
- package/dist/{chunk-LDTWX7JW.js → chunk-BTZY7VPH.js} +13 -1
- package/dist/{chunk-FJDCFHW5.js → chunk-C6JHBLMW.js} +3 -81
- package/dist/{chunk-EXHBXA4U.js → chunk-DBCLBYHP.js} +13 -1
- package/dist/chunk-EPNDZ5DH.js +1010 -0
- package/dist/{chunk-P4RUVDU7.js → chunk-H2MEFVH6.js} +12 -141
- package/dist/chunk-KXZUCCEY.js +142 -0
- package/dist/{chunk-6JZIX5WW.js → chunk-LLXV32HA.js} +82 -5
- package/dist/{chunk-LWUR4CGG.js → chunk-MLRCSJYX.js} +11 -3
- package/dist/{chunk-2ABMGUDS.js → chunk-NFRM5QYP.js} +83 -10
- package/dist/chunk-RW5LP57K.js +44 -0
- package/dist/chunk-YDIYXGYL.js +384 -0
- package/dist/{chunk-JGGI65I3.js → chunk-Z4BNLUZF.js} +1 -150
- package/dist/{credit-ledger-ED6JXKVD.js → credit-ledger-2DFQHNLB.js} +2 -2
- package/dist/{credit-menu-BM4qCD5U.d.ts → credit-menu-C7zAJElJ.d.ts} +1632 -1946
- package/dist/{fx-C-liI3oY.d.ts → fx-BF_SG2i0.d.ts} +1 -1
- package/dist/index.d.ts +7 -6
- package/dist/index.js +8 -4
- package/dist/internal/caller.d.ts +10429 -0
- package/dist/internal/caller.js +9957 -0
- package/dist/internal/index.d.ts +2 -10816
- package/dist/internal/index.js +2 -10130
- package/dist/internal/server.d.ts +404 -0
- package/dist/internal/server.js +202 -0
- package/dist/job-store-Bn23V3QU.d.ts +576 -0
- package/dist/lightning-backend-C04nH94l.d.ts +367 -0
- package/dist/{memory-credit-ledger-XJ5VQEVP.js → memory-credit-ledger-OP24Z2KO.js} +3 -3
- package/dist/{postgres-job-store-J5F4GUWU.js → postgres-job-store-TAONYLIF.js} +1 -1
- package/dist/{revenue-reporter-JIKUPXOK.js → revenue-reporter-XXSU5KVB.js} +1 -1
- package/dist/server/index.d.ts +27 -11
- package/dist/server/index.js +93 -69
- package/dist/{job-store-C53VQ5uu.d.ts → step-cache-3cT4Shk0.d.ts} +31 -585
- package/dist/{tempo-session-store-DALMRIWN.js → tempo-session-store-2JNOKJGX.js} +2 -2
- package/dist/testing/index.d.ts +16 -4
- package/dist/testing/index.js +7 -3
- package/dist/{usd-gLcJB1ps.d.ts → usd-BnuXoFl5.d.ts} +1 -1
- package/dist/wallet-CJC8lwxx.d.ts +29 -0
- package/dist/{x402-FTG2GRAQ.js → x402-T2C5MX3T.js} +6 -3
- package/package.json +6 -2
- package/dist/{chunk-RU7SXHLO.js → chunk-UP2F5RRT.js} +3 -3
package/dist/server/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "../chunk-L4OYF4DQ.js";
|
|
4
4
|
import {
|
|
5
5
|
PostgresJobStore
|
|
6
|
-
} from "../chunk-
|
|
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
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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-
|
|
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-
|
|
119
|
+
} from "../chunk-KXZUCCEY.js";
|
|
102
120
|
import {
|
|
103
|
-
|
|
104
|
-
|
|
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-
|
|
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
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
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: "
|
|
181
|
-
|
|
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
|
-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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
|
|
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
|
-
|
|
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) {
|