@dvmkit/sdk 0.5.0-rc.1 → 0.7.0-rc.1
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 +100 -0
- package/dist/{chunk-JH3SX3LY.js → chunk-6XF3RVVX.js} +1 -1
- package/dist/chunk-AFV77S4C.js +258 -0
- package/dist/{chunk-RLTSCKRI.js → chunk-BPYMEMQX.js} +50 -3
- package/dist/chunk-BQJIFRAZ.js +36 -0
- package/dist/{chunk-IWQHUSMO.js → chunk-CXCQLOOK.js} +143 -2
- package/dist/{chunk-PB4FYZET.js → chunk-EQLA4FFY.js} +54 -4
- package/dist/{chunk-LE74UEV7.js → chunk-EZXAJ6EI.js} +64 -53
- package/dist/{chunk-FI4CST2D.js → chunk-FWGWLPXF.js} +4 -6
- package/dist/{chunk-EYTHFFFU.js → chunk-GY66THYI.js} +179 -56
- package/dist/{chunk-TZ2WKCDD.js → chunk-HCLVYZUZ.js} +2 -2
- package/dist/{chunk-O5AT6S5T.js → chunk-IV6Q7NRW.js} +25 -195
- package/dist/{chunk-UOCZXO2Z.js → chunk-JEVLNAO3.js} +10 -5
- package/dist/{chunk-TUA7PYH7.js → chunk-KMED3H3A.js} +134 -130
- package/dist/{chunk-Z4KLECAC.js → chunk-N5RZ5HVB.js} +1 -1
- package/dist/{chunk-PAIM66YA.js → chunk-NFMOPYBA.js} +47 -37
- package/dist/{chunk-B2IROPQF.js → chunk-O2OTZ5GP.js} +40 -15
- package/dist/{chunk-FYRR2UEZ.js → chunk-OML32F6I.js} +1 -1
- package/dist/{chunk-6DOGTAHA.js → chunk-QR2EF2NI.js} +9 -43
- package/dist/{chunk-7ZUKL4IV.js → chunk-RA2WIX7G.js} +5 -5
- package/dist/{chunk-A4YFWZ7R.js → chunk-RCM3P2HE.js} +1 -1
- package/dist/{chunk-PLG4XER6.js → chunk-S3OY533W.js} +1 -1
- package/dist/{chunk-GFY5FRX3.js → chunk-SZVXOQ75.js} +5 -12
- package/dist/{chunk-MZRJR2CW.js → chunk-WBOKPC37.js} +22 -3
- package/dist/content-retention-DHyLdA6b.d.ts +78 -0
- package/dist/{credit-ledger-MI2H7NEC.js → credit-ledger-MCUXYKSJ.js} +2 -3
- package/dist/{credit-menu-CAfqe8IY.d.ts → credit-menu-DjnkeEUU.d.ts} +98 -5
- package/dist/{fx-D9nsN3n4.d.ts → fx-zMWFzfrU.d.ts} +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +3 -3
- package/dist/internal/caller.d.ts +1369 -860
- package/dist/internal/caller.js +1079 -991
- package/dist/internal/index.js +1 -1
- package/dist/internal/server.d.ts +8 -99
- package/dist/internal/server.js +19 -18
- package/dist/{job-store-Bx-VFRjg.d.ts → job-store-DdLXBpol.d.ts} +1 -1
- package/dist/{lightning-backend-BAx2Y8pP.d.ts → lightning-backend-Bw-qtAbt.d.ts} +4 -2
- package/dist/{memory-credit-ledger-W2BAUYJP.js → memory-credit-ledger-SBSMGMDX.js} +3 -4
- package/dist/{postgres-consumed-credential-store-CUQJKRSL.js → postgres-consumed-credential-store-BUVCAPLS.js} +13 -0
- package/dist/{postgres-job-store-VLXLWXUQ.js → postgres-job-store-VHLQBJZC.js} +3 -1
- package/dist/server/index.d.ts +28 -10
- package/dist/server/index.js +34 -24
- package/dist/{step-cache-QG_h5-3G.d.ts → step-cache-2MkvenJn.d.ts} +3 -3
- package/dist/tempo-lifecycle-GJ77YKVY.js +15 -0
- package/dist/{tempo-wallet-B5XXV3YH.js → tempo-wallet-X2GGAZ6X.js} +4 -4
- package/dist/testing/index.d.ts +9 -2
- package/dist/testing/index.js +6 -3
- package/dist/{usd-EwRqCPF-.d.ts → usd-DI3d3gTK.d.ts} +1 -1
- package/dist/{x402-R6HPBY5D.js → x402-FT4S4JS4.js} +8 -10
- package/package.json +5 -3
- package/recipes/postgres/financial-export-v1.sql +137 -0
- package/dist/chunk-CZULM42S.js +0 -143
- package/dist/chunk-LIRAHP7B.js +0 -53
- package/dist/tempo-lifecycle-ZBBLFBMH.js +0 -15
|
@@ -2,16 +2,16 @@ import {
|
|
|
2
2
|
createX402FacilitatorAuthHeaders,
|
|
3
3
|
settleWithFacilitator,
|
|
4
4
|
verifyWithFacilitator
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-S3OY533W.js";
|
|
6
|
+
import {
|
|
7
|
+
usdcToMsats
|
|
8
|
+
} from "./chunk-NFMOPYBA.js";
|
|
6
9
|
import {
|
|
7
10
|
buildPaymentRequirements,
|
|
8
11
|
decodePayment,
|
|
9
12
|
encodeSettleResponseHeader,
|
|
10
13
|
exactEvmAuthorization
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import {
|
|
13
|
-
usdcToMsats
|
|
14
|
-
} from "./chunk-PAIM66YA.js";
|
|
14
|
+
} from "./chunk-CXCQLOOK.js";
|
|
15
15
|
import {
|
|
16
16
|
callerLoggers
|
|
17
17
|
} from "./chunk-66HGCPBU.js";
|
|
@@ -14,7 +14,7 @@ var RAIL_REFUNDABLE = {
|
|
|
14
14
|
var DEFAULT_CREDIT_MIN = "$0.10";
|
|
15
15
|
var DEFAULT_CREDIT_MAX = "$5.00";
|
|
16
16
|
var DEFAULT_CREDIT_TTL_SECONDS = 30 * 24 * 60 * 60;
|
|
17
|
-
var DEFAULT_JOB_RETENTION_DAYS =
|
|
17
|
+
var DEFAULT_JOB_RETENTION_DAYS = 730;
|
|
18
18
|
|
|
19
19
|
// src/lib/signed-request-statement.ts
|
|
20
20
|
var SIGNED_REQUEST_AUTH_ID = "secp256k1-schnorr-v2";
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isValidEvmPrivateKey,
|
|
3
3
|
loadConfig,
|
|
4
|
+
tempoAccountFromConfig,
|
|
4
5
|
updateConfig
|
|
5
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-WBOKPC37.js";
|
|
6
7
|
import {
|
|
7
8
|
resolveRpcHttpTransportOptions,
|
|
8
9
|
resolveRpcOverride
|
|
9
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-CXCQLOOK.js";
|
|
10
11
|
import {
|
|
11
12
|
redactUrl,
|
|
12
13
|
redactUrlsInText
|
|
13
14
|
} from "./chunk-FUJ36YDV.js";
|
|
14
15
|
import {
|
|
15
16
|
DvmError
|
|
16
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-BPYMEMQX.js";
|
|
17
18
|
|
|
18
19
|
// src/lib/payment-rails/tempo-wallet.ts
|
|
19
20
|
var TEMPO_USDC_MAINNET = "0x20C000000000000000000000b9537d11c60E8b50";
|
|
@@ -103,7 +104,7 @@ async function generateTempoKey(opts = {}) {
|
|
|
103
104
|
);
|
|
104
105
|
}
|
|
105
106
|
if (existing && opts.force) {
|
|
106
|
-
const { assertTempoWalletIdle } = await import("./tempo-lifecycle-
|
|
107
|
+
const { assertTempoWalletIdle } = await import("./tempo-lifecycle-GJ77YKVY.js");
|
|
107
108
|
await assertTempoWalletIdle("replace");
|
|
108
109
|
}
|
|
109
110
|
const { privateKeyToAccount, generatePrivateKey } = await import("viem/accounts");
|
|
@@ -182,14 +183,6 @@ async function deriveTempoAddress(privateKey) {
|
|
|
182
183
|
function shortAddress(addr) {
|
|
183
184
|
return `${addr.slice(0, 6)}\u2026${addr.slice(-4)}`;
|
|
184
185
|
}
|
|
185
|
-
async function tempoAccountFromConfig(config) {
|
|
186
|
-
if (config?.tempo?.method !== "tempo") return null;
|
|
187
|
-
const apiKey = config.tempo.apiKey;
|
|
188
|
-
if (!apiKey || !isValidEvmPrivateKey(apiKey)) return null;
|
|
189
|
-
const privateKey = apiKey;
|
|
190
|
-
const address = await deriveTempoAddress(privateKey);
|
|
191
|
-
return { privateKey, address, network: config.tempo.network ?? "mainnet" };
|
|
192
|
-
}
|
|
193
186
|
function invalidTempoPrivateKey() {
|
|
194
187
|
return new DvmError(
|
|
195
188
|
"invalid_api_key",
|
|
@@ -3,11 +3,12 @@ import {
|
|
|
3
3
|
CONFIG_BACKUP_FILE,
|
|
4
4
|
CONFIG_FILE,
|
|
5
5
|
CONFIG_PINNED_FILE,
|
|
6
|
+
X402_DEFAULT_NETWORK,
|
|
6
7
|
ensureConfigDir
|
|
7
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-CXCQLOOK.js";
|
|
8
9
|
import {
|
|
9
10
|
DvmError
|
|
10
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-BPYMEMQX.js";
|
|
11
12
|
|
|
12
13
|
// src/lib/evm-private-key.ts
|
|
13
14
|
import { secp256k1 } from "@noble/curves/secp256k1.js";
|
|
@@ -756,6 +757,22 @@ function retireSlot(reason, slot) {
|
|
|
756
757
|
return true;
|
|
757
758
|
}
|
|
758
759
|
|
|
760
|
+
// src/lib/wallet-credentials.ts
|
|
761
|
+
function x402WalletFromConfig(config) {
|
|
762
|
+
const x402 = config?.x402;
|
|
763
|
+
const privateKey = x402?.privateKey;
|
|
764
|
+
if (!privateKey || !isValidEvmPrivateKey(privateKey)) return null;
|
|
765
|
+
return { privateKey, address: "", network: x402.network ?? X402_DEFAULT_NETWORK };
|
|
766
|
+
}
|
|
767
|
+
async function tempoAccountFromConfig(config) {
|
|
768
|
+
if (config?.tempo?.method !== "tempo") return null;
|
|
769
|
+
const privateKey = config.tempo.apiKey;
|
|
770
|
+
if (!privateKey || !isValidEvmPrivateKey(privateKey)) return null;
|
|
771
|
+
const { privateKeyToAccount } = await import("viem/accounts");
|
|
772
|
+
const address = privateKeyToAccount(privateKey).address.toLowerCase();
|
|
773
|
+
return { privateKey, address, network: config.tempo.network ?? "mainnet" };
|
|
774
|
+
}
|
|
775
|
+
|
|
759
776
|
export {
|
|
760
777
|
isValidEvmPrivateKey,
|
|
761
778
|
authorizeProtectedRemoval,
|
|
@@ -772,5 +789,7 @@ export {
|
|
|
772
789
|
ensureConfig,
|
|
773
790
|
previewConfigRollback,
|
|
774
791
|
rollbackConfig,
|
|
775
|
-
retireConfigBackup
|
|
792
|
+
retireConfigBackup,
|
|
793
|
+
x402WalletFromConfig,
|
|
794
|
+
tempoAccountFromConfig
|
|
776
795
|
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { b as JobStore, J as JobRecord } from './job-store-DdLXBpol.js';
|
|
2
|
+
|
|
3
|
+
/** Authenticated caller metadata; omitted fields on older services mean unknown. */
|
|
4
|
+
interface JobContentMetadata {
|
|
5
|
+
content_expires_at: number | null;
|
|
6
|
+
content_available: boolean;
|
|
7
|
+
}
|
|
8
|
+
/** Admin-only history; reasons and signer identities never appear on caller responses. */
|
|
9
|
+
interface ContentHoldsResponse extends JobContentMetadata {
|
|
10
|
+
job_id: string;
|
|
11
|
+
baseline_content_expires_at: number | null;
|
|
12
|
+
holds: (ContentHold & {
|
|
13
|
+
review_overdue: boolean;
|
|
14
|
+
})[];
|
|
15
|
+
events: ContentHoldEvent[];
|
|
16
|
+
}
|
|
17
|
+
interface ContentHoldEvent {
|
|
18
|
+
id: string;
|
|
19
|
+
hold_id: string;
|
|
20
|
+
job_id: string;
|
|
21
|
+
action: "placed" | "renewed" | "cleared";
|
|
22
|
+
actor: string;
|
|
23
|
+
reason: string;
|
|
24
|
+
at: number;
|
|
25
|
+
review_due_at: number;
|
|
26
|
+
}
|
|
27
|
+
interface ContentHold {
|
|
28
|
+
id: string;
|
|
29
|
+
job_id: string;
|
|
30
|
+
purpose: "support" | "dispute";
|
|
31
|
+
reason: string;
|
|
32
|
+
actor: string;
|
|
33
|
+
created_at: number;
|
|
34
|
+
review_due_at: number;
|
|
35
|
+
cleared_at: number | null;
|
|
36
|
+
}
|
|
37
|
+
interface ContentHoldHistory {
|
|
38
|
+
holds: ContentHold[];
|
|
39
|
+
events: ContentHoldEvent[];
|
|
40
|
+
}
|
|
41
|
+
type ContentHoldMutation = {
|
|
42
|
+
action: "placed";
|
|
43
|
+
purpose: "support" | "dispute";
|
|
44
|
+
reason: string;
|
|
45
|
+
review_due_at: number;
|
|
46
|
+
actor: string;
|
|
47
|
+
at: number;
|
|
48
|
+
} | {
|
|
49
|
+
action: "renewed";
|
|
50
|
+
hold_id: string;
|
|
51
|
+
reason: string;
|
|
52
|
+
review_due_at: number;
|
|
53
|
+
actor: string;
|
|
54
|
+
at: number;
|
|
55
|
+
} | {
|
|
56
|
+
action: "cleared";
|
|
57
|
+
hold_id: string;
|
|
58
|
+
reason: string;
|
|
59
|
+
actor: string;
|
|
60
|
+
at: number;
|
|
61
|
+
};
|
|
62
|
+
/** Mutations and redaction must serialize on the same job, including across processes. */
|
|
63
|
+
interface ContentHoldStore extends JobStore {
|
|
64
|
+
getContentSnapshot(jobId: string, dvmId?: string): Promise<{
|
|
65
|
+
job: JobRecord;
|
|
66
|
+
history: ContentHoldHistory;
|
|
67
|
+
} | undefined>;
|
|
68
|
+
mutateContentHold(jobId: string, mutation: ContentHoldMutation, dvmId?: string): Promise<ContentHoldHistory>;
|
|
69
|
+
}
|
|
70
|
+
declare class ContentHoldError extends Error {
|
|
71
|
+
readonly code: "job_not_found" | "content_unavailable" | "hold_not_active";
|
|
72
|
+
constructor(code: "job_not_found" | "content_unavailable" | "hold_not_active");
|
|
73
|
+
}
|
|
74
|
+
declare function isContentHoldStore(store: JobStore): store is ContentHoldStore;
|
|
75
|
+
declare function contentMetadata(job: Pick<JobRecord, "status" | "lastActivityAt" | "redactedAt">, retentionDays: number, holds?: ContentHold[]): JobContentMetadata;
|
|
76
|
+
declare function baselineContentExpiry(job: Pick<JobRecord, "status" | "lastActivityAt">, retentionDays: number): number | null;
|
|
77
|
+
|
|
78
|
+
export { type ContentHoldHistory as C, type JobContentMetadata as J, type ContentHoldMutation as a, type ContentHold as b, ContentHoldError as c, type ContentHoldEvent as d, type ContentHoldStore as e, type ContentHoldsResponse as f, baselineContentExpiry as g, contentMetadata as h, isContentHoldStore as i };
|
|
@@ -10,11 +10,10 @@ import {
|
|
|
10
10
|
isDrainMethod,
|
|
11
11
|
isFundingRail,
|
|
12
12
|
x402SettlementPending
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-6XF3RVVX.js";
|
|
14
14
|
import "./chunk-COYKJRMM.js";
|
|
15
15
|
import "./chunk-P6QON7ER.js";
|
|
16
|
-
import "./chunk-
|
|
17
|
-
import "./chunk-LIRAHP7B.js";
|
|
16
|
+
import "./chunk-BPYMEMQX.js";
|
|
18
17
|
import "./chunk-ETXDTUJO.js";
|
|
19
18
|
export {
|
|
20
19
|
CreditLedger,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { g as LockPubkey, f as CheckMintHealthOptions, b as LightningBackend, A as AttestationPayload } from './lightning-backend-Bw-qtAbt.js';
|
|
2
|
+
import { cf as HostingCleanupFence, cV as HostedIntent, aj as FundingMethod, o as PaymentMethod, bN as CreditLedgerLike, a3 as Message, _ as FundingReceipt, bP as CreditSnapshot, $ as JobReceipt, S as SDKJobContext, aw as StepCache, u as ResponseContent, P as PaymentContent, a4 as MessageType, bj as X402Receipt, aE as X402Config, bi as X402ExactVersionSupport, cW as X402SettlementIntent, aa as PaymentRequirementsV2, cX as HostedFundingReservation, c2 as CreditLedgerQuerier, cY as X402SettlementCursor, bR as X402SettlementStatus, cZ as X402SettlementWriteOff, bO as X402RefundSettlementGate, c_ as X402FacilitatorAuth, c$ as X402BatchSettlementConfig, cB as PostgresX402ChannelStorage, d0 as X402PayoutObserver, bL as HostedSettlementReportObligations, br as MppxServer, ae as CashuMode, d1 as CreditDepositEnqueue, d2 as X402SettlementReconciliationReason, aq as PaymentRequirements, a2 as MppxCredential, bm as CreditDepositPayload, bQ as DrawResult, cp as CreditLedgerError, a7 as ReceiptCredit, ag as DrainReceiptEvent, a6 as DrainReceipt, K as KVStore, y as SignedRequestAudience, d3 as CreditDrawReleaseEnqueue, cz as JobCostReportPayload, cA as JobTerminalReportPayload, cD as RevenueSkippedNoRailPayload, Z as ZodLike, a as DVMDescriptor, bW as CreditInvoiceRecord, bX as InvoiceSettlement, cj as ClientCompatibilityGate, ch as ClientCompatibility, bv as PostgresTempoSessionStore, bu as PayoutReporter, R as ResolvedCreditConfig, g as CreditView } from './step-cache-2MkvenJn.js';
|
|
2
3
|
import { ProofLike, SerializedDLEQ, Proof } from '@cashu/cashu-ts';
|
|
3
4
|
import { Hono, Context } from 'hono';
|
|
4
5
|
import { Pool } from 'pg';
|
|
5
|
-
import { b as FxRateSnapshot, F as FxFetcher } from './fx-
|
|
6
|
+
import { b as FxRateSnapshot, F as FxFetcher } from './fx-zMWFzfrU.js';
|
|
6
7
|
import { Store, Challenge } from 'mppx';
|
|
7
|
-
import {
|
|
8
|
-
import { T as TopUpCapUnenforcedReason, A as AppendOutgoingOptions, J as JobRecord, b as JobStore } from './job-store-Bx-VFRjg.js';
|
|
8
|
+
import { T as TopUpCapUnenforcedReason, A as AppendOutgoingOptions, J as JobRecord, b as JobStore } from './job-store-DdLXBpol.js';
|
|
9
9
|
import { SettleResponse, SupportedResponse } from '@x402/core/types';
|
|
10
10
|
import { Channel, AutoSettlementConfig } from '@x402/evm/batch-settlement/server';
|
|
11
11
|
import { FacilitatorClient } from '@x402/core/server';
|
|
@@ -195,6 +195,8 @@ declare function hashLockKey(input: string): bigint;
|
|
|
195
195
|
* `pendingMppChallengeIds`.
|
|
196
196
|
*/
|
|
197
197
|
interface ConsumedCredentialStore {
|
|
198
|
+
/** Atomically consume a nonce only if no unexpired mark exists. */
|
|
199
|
+
consume?(realm: string, challengeId: string, ttlSeconds: number): Promise<boolean>;
|
|
198
200
|
/** True iff `(realm, challengeId)` was marked and the entry has not expired. */
|
|
199
201
|
has(realm: string, challengeId: string): Promise<boolean>;
|
|
200
202
|
/** Mark `(realm, challengeId)` as consumed for `ttlSeconds`. */
|
|
@@ -219,9 +221,100 @@ declare class MemoryConsumedCredentialStore implements ConsumedCredentialStore {
|
|
|
219
221
|
private readonly data;
|
|
220
222
|
constructor(opts?: MemoryConsumedCredentialStoreOpts);
|
|
221
223
|
has(realm: string, challengeId: string): Promise<boolean>;
|
|
224
|
+
consume(realm: string, challengeId: string, ttlSeconds: number): Promise<boolean>;
|
|
222
225
|
mark(realm: string, challengeId: string, ttlSeconds: number): Promise<void>;
|
|
223
226
|
}
|
|
224
227
|
|
|
228
|
+
/**
|
|
229
|
+
* Snapshot of a DVM's published lock-pubkey state at a point in time. `current`
|
|
230
|
+
* is what the SDK advertises as `cashu.lock_pubkeys[0]`; `retired` are the
|
|
231
|
+
* pubkeys inside the rotation grace window plus legacy sentinel-0 entries
|
|
232
|
+
* kept until explicitly cleaned up. Both halves are needed by the
|
|
233
|
+
* receive path (accept proofs locked to any entry) and the admin auth verifier
|
|
234
|
+
* (accept signatures from any entry during grace).
|
|
235
|
+
*/
|
|
236
|
+
interface LockPubkeyState {
|
|
237
|
+
current: LockPubkey;
|
|
238
|
+
retired: {
|
|
239
|
+
pubkey: LockPubkey;
|
|
240
|
+
retiredAtMs: number;
|
|
241
|
+
}[];
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Lazy accessor for the DVM's lock-pubkey state. Threaded through the SDK
|
|
245
|
+
* server so call sites (info handler, accept flow, admin auth) read the fresh
|
|
246
|
+
* state on every invocation — rotation propagation has to be visible without
|
|
247
|
+
* a process restart.
|
|
248
|
+
*/
|
|
249
|
+
type LockPubkeyStateLoader = () => Promise<LockPubkeyState>;
|
|
250
|
+
type LockPubkeyPool = AccumulatorPool;
|
|
251
|
+
/**
|
|
252
|
+
* Create the `dvm_lock_pubkeys` table if absent. Each row is one entry in a
|
|
253
|
+
* DVM's lock-pubkey lifecycle: `retired_at_ms IS NULL` is the current pubkey,
|
|
254
|
+
* any non-null value is a retired pubkey that the rotation walker can still
|
|
255
|
+
* derive privkeys for. One current row per `dvm_id` is enforced via a partial
|
|
256
|
+
* unique index — keeps `rotateLockPubkey` honest under concurrent calls.
|
|
257
|
+
*/
|
|
258
|
+
declare function initLockPubkeyTable(db: LockPubkeyPool): Promise<void>;
|
|
259
|
+
/**
|
|
260
|
+
* Idempotent first-boot seed. Inserts `pubkey` as the current row for `dvmId`
|
|
261
|
+
* only when no current row exists. Reseeding with a different pubkey is a
|
|
262
|
+
* no-op — once the DB has state, `rotateLockPubkey` is the only sanctioned
|
|
263
|
+
* mutator, so a stale `DVMKIT_CASHU_LOCK_PUBKEY` env on a redeploy can't
|
|
264
|
+
* silently reset the DVM's view of "what's current".
|
|
265
|
+
*
|
|
266
|
+
* Also backfills any distinct `lock_pubkey` values found in
|
|
267
|
+
* `wallet_accumulator` for this DVM that aren't yet in `dvm_lock_pubkeys`,
|
|
268
|
+
* inserting them as retired rows with `retired_at_ms = 0` — the
|
|
269
|
+
* "long-retired-still-meltable" sentinel. This handles legacy batches
|
|
270
|
+
* that would otherwise trip the monitor's `orphan_lock_pubkey` alarm every
|
|
271
|
+
* tick. Sentinel-0 rows are exempt from grace-window filtering and
|
|
272
|
+
* `pruneRetired` so they stay visible until the operator melts the legacy
|
|
273
|
+
* batches and the receive path keeps accepting in-flight tokens locked to
|
|
274
|
+
* them.
|
|
275
|
+
*
|
|
276
|
+
* `ON CONFLICT DO NOTHING` protects concurrent seeds invoked reentrantly from
|
|
277
|
+
* one guarded callback. Nested calls bypass the queue to avoid deadlock, so
|
|
278
|
+
* both inserts can pass `WHERE NOT EXISTS` before either commits.
|
|
279
|
+
*/
|
|
280
|
+
declare function seedLockPubkeyState(db: LockPubkeyPool, dvmId: string, pubkey: string, now?: number): Promise<void>;
|
|
281
|
+
/**
|
|
282
|
+
* Read the active lock-pubkey state for a DVM. Retired rows older than the
|
|
283
|
+
* grace window are filtered out; aged-out rows linger physically until
|
|
284
|
+
* `pruneRetired` deletes them on a monitor tick. Sentinel-0 rows (the
|
|
285
|
+
* `retired_at_ms = 0` legacy backfill from `seedLockPubkeyState`) are always
|
|
286
|
+
* included regardless of grace. Throws when no current row exists — the SDK's
|
|
287
|
+
* accept/info/admin paths must not run before `seedLockPubkeyState` has been
|
|
288
|
+
* called.
|
|
289
|
+
*/
|
|
290
|
+
declare function loadLockPubkeyState(db: AccumulatorQuerier, dvmId: string, graceMs: number, now?: number): Promise<LockPubkeyState>;
|
|
291
|
+
/**
|
|
292
|
+
* Atomically demote the current pubkey to retired (stamping `retired_at_ms`)
|
|
293
|
+
* and insert `newPubkey` as the new current row. Wrapped in a transaction so
|
|
294
|
+
* the partial unique index never has two current rows visible mid-rotation.
|
|
295
|
+
* Returns the post-rotation state filtered by the supplied grace window.
|
|
296
|
+
*/
|
|
297
|
+
declare function rotateLockPubkey(db: LockPubkeyPool, dvmId: string, newPubkey: string, graceMs: number, now?: number): Promise<LockPubkeyState>;
|
|
298
|
+
/**
|
|
299
|
+
* Delete retired rows whose `retired_at_ms` is older than `now - graceMs`.
|
|
300
|
+
* Called from the monitor tick so aged-out entries don't accumulate.
|
|
301
|
+
* `wallet_accumulator` rows pointing at those pubkeys remain meltable (the
|
|
302
|
+
* builder can still derive the privkey from the mnemonic + rotation_index) —
|
|
303
|
+
* pruning only affects what the DVM advertises and accepts.
|
|
304
|
+
*
|
|
305
|
+
* Sentinel-0 rows (the legacy backfill from `seedLockPubkeyState`) are
|
|
306
|
+
* exempted from pruning — they exist precisely so the monitor keeps treating
|
|
307
|
+
* legacy `wallet_accumulator` batches as retired-still-meltable rather than
|
|
308
|
+
* orphan.
|
|
309
|
+
*/
|
|
310
|
+
declare function pruneRetired(db: AccumulatorQuerier, dvmId: string, graceMs: number, now?: number): Promise<number>;
|
|
311
|
+
/**
|
|
312
|
+
* Default rotation grace window in seconds. Override through
|
|
313
|
+
* `SDKServerOpts.lockPubkeyGraceSeconds`.
|
|
314
|
+
*/
|
|
315
|
+
declare const DEFAULT_LOCK_PUBKEY_GRACE_SECONDS = 86400;
|
|
316
|
+
declare function activePubkeySet(state: LockPubkeyState): LockPubkey[];
|
|
317
|
+
|
|
225
318
|
/** Effective boot-time payment configuration for one mounted DVM. Health may change later. */
|
|
226
319
|
interface PaymentMode {
|
|
227
320
|
mount: string;
|
|
@@ -4539,4 +4632,4 @@ declare function attachCreditMenu(body: Record<string, unknown>, menu: CreditMen
|
|
|
4539
4632
|
*/
|
|
4540
4633
|
declare function toCreditTerms(menu: CreditMenu): CreditTerms;
|
|
4541
4634
|
|
|
4542
|
-
export {
|
|
4635
|
+
export { hashLockKey as $, type AccumulatorPool as A, activePubkeySet as B, type ConsumedCredentialStore as C, DEFAULT_LOCK_PUBKEY_GRACE_SECONDS as D, applyPaymentInfoToJob as E, type FiatDenomination as F, assertRevenueReporterReady as G, buildPaymentErrorResponse as H, type IncomingPaymentOpts as I, JobCancelledError as J, clearAccumulatorForDvm as K, type LockPubkeyStateLoader as L, MintHealthTracker as M, createDVMServer as N, creditDepositPayload as O, PAYMENT_PROOF_KEYS as P, derivedFundCreditId as Q, type ReporterBannerOpts as R, type SDKServerOpts as S, type TempoChannelReport as T, type UpfrontPaymentOpts as U, type VerifiedIncomingPayment as V, devModeSkipsPaymentVerification as W, type X402BatchChannelObservation as X, fromJobRecord as Y, fundedMicroFor as Z, hasPaymentProof as _, type AppEnv as a, type PlatformReporterOpts as a$, implicitCreditId as a0, initLockPubkeyTable as a1, initWalletAccumulatorTable as a2, insertAccumulatorRows as a3, isDerivedCreditId as a4, isTerminal as a5, isYieldMessage as a6, issueUpfrontChallenges as a7, loadLockPubkeyState as a8, msatsToFiatMicro as a9, type BuildCreditMenuArgs as aA, type BuilderIdentity as aB, CREDIT_ENVELOPE_KEYS as aC, type CreateX402BatchSettlementServerOpts as aD, type CreditEnvelope as aE, CreditEnvelopeError as aF, type CreditFundCommitment as aG, type CreditTerms as aH, DEFAULT_INVOICE_TTL_SECONDS as aI, type DVMHost as aJ, type HostingClosureCommand as aK, type HostingClosureEvidence as aL, type HostingControlCommand as aM, type HostingControlConfig as aN, type HostingControlStatus as aO, JobManager as aP, type JobManagerOpts as aQ, type LightningReceiveConfig as aR, MIN_INVOICE_TTL_SECONDS as aS, MemoryConsumedCredentialStore as aT, type MemoryConsumedCredentialStoreOpts as aU, MemoryProcessedPaymentStore as aV, MemoryX402ExactSettlementStore as aW, type MountOpts as aX, type OwnerDisplay as aY, type PaidJobCompletion as aZ, type PaymentMode as a_, paymentErrorBody as aa, pinAskFiat as ab, priceFiatMicro as ac, processIncomingPayment as ad, providerMessage as ae, pruneRetired as af, repairX402ExactSettlementEffect as ag, resolveFxSnapshot as ah, resolvePriceFiat as ai, revenueReporterBannerState as aj, rotateLockPubkey as ak, seedLockPubkeyState as al, toCreditTerms as am, toJobRecord as an, unknownRouteNotFound as ao, verifyIncomingPayment as ap, verifyTempoSessionManagementCredential as aq, verifyUpfrontPayment as ar, x402RequiredUsdcMicro as as, x402SettledShare as at, type CreditMenu as au, ReceiptIssuer as av, LightningReceive as aw, TempoSettlementReadiness as ax, type DVMHostOpts as ay, type DVMServeResult as az, type CreditFundingReport as b, PostgresProcessedPaymentStore as b0, PostgresX402ExactSettlementStore as b1, type PriceFiat as b2, type ProcessedPaymentQuerier as b3, type ProcessedPaymentRail as b4, type ProcessedPaymentRecord as b5, ProcessedPaymentReplayError as b6, type ProcessedPaymentStore as b7, type X402BatchAcceptance as b8, type X402BatchFunding as b9, drawSettlementRef as bA, extractCreditEnvelope as bB, fundingCommitment as bC, selectPrimaryCredit as bD, signHostingClosure as bE, signHostingControl as bF, stripCreditEnvelope as bG, toCreditView as bH, type X402BatchRefusal as ba, type X402BatchSettlementServer as bb, type X402ExactAcceptance as bc, X402ExactIntentConflictError as bd, type X402ExactSettlementAttempt as be, type X402ExactSettlementChainEvidence as bf, type X402ExactSettlementEffect as bg, X402ExactSettlementEvidenceMissingError as bh, type X402ExactSettlementEvidenceReader as bi, type X402ExactSettlementIntent as bj, X402ExactSettlementNotReadyError as bk, X402ExactSettlementServer as bl, type X402ExactSettlementServerOpts as bm, type X402ExactSettlementStatus as bn, type X402ExactSettlementStore as bo, type X402SettlementChainEvidence as bp, type X402SettlementEvidenceReader as bq, X402SettlementSubmissionError as br, X402_BATCH_AUTO_SETTLEMENT as bs, X402_BATCH_MIN_WITHDRAW_DELAY_SECONDS as bt, X402_BATCH_SETTLEMENT_NETWORK as bu, attachCreditMenu as bv, buildCreditMenu as bw, createDVMHost as bx, createX402BatchSettlementServer as by, creditEnvelopeIgnoreFields as bz, type FiatDenominationFailure as c, type FundOnlyRequest as d, type LockPubkeyPool as e, type LockPubkeyState as f, type PaymentErrorCode as g, type PaymentErrorDetail as h, type PaymentInfo as i, PostgresTempoChargeStore as j, type ResolvedFx as k, type RevenueBootCheckOpts as l, type ServerJob as m, type ShortPayForfeit as n, type TempoObserverHealth as o, TempoSessionChannelMismatchError as p, type VerifyIncomingSnapshot as q, X402FacilitatorHealth as r, type X402SettlementEvidenceOutcome as s, type X402SettlementRepair as t, type X402SettlementRepairRefusal as u, type X402SettlementRepaired as v, type X402WedgedSettlement as w, type X402WedgedSettlementPage as x, X402_BATCH_SETTLEMENT_MAINNET_NETWORK as y, abortJob as z };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { C as Currency, Z as ZodLike, D as DVMConfig, a as DVMDescriptor } from './step-cache-
|
|
2
|
-
export { A as ApprovalContent, b as ArtifactContent, c as CancelContent, d as CanonicalEnvelope, e as CreateSignedRequestVerifierOpts, f as CreditConfig, g as CreditView, h as DEFAULT_CREDIT_MAX, i as DEFAULT_CREDIT_MIN, j as DEFAULT_CREDIT_TTL_SECONDS, k as DEFAULT_JOB_RETENTION_DAYS, l as DVMRouteContext, I as IncomingMessage, m as InputType, n as InvalidCurrencyError, J as JobCost, K as KVStore, L as Logger, P as PaymentContent, o as PaymentMethod, p as PriceValue, q as ProgressContent, r as PromptOpts, Q as QuoteConfig, s as QuoteContext, t as QuoteResult, R as ResolvedCreditConfig, u as ResponseContent, S as SDKJobContext, v as SDKPaymentRequestOpts, w as SIGNED_REQUEST_AUTH_ID, x as SIGNED_REQUEST_STATEMENT_VERSION, y as SignedRequestAudience, z as SignedRequestDomain, B as SignedRequestError, E as SignedRequestFailure, F as SignedRequestReplayStore, G as SignedRequestSignOpts, H as SignedRequestStatementHeader, M as SignedRequestVerifier, U as UnsupportedCurrencyError, N as createSignedRequestVerifier, O as isZodSchema, T as signedRequestStatementHeader, V as validateCurrency } from './step-cache-
|
|
3
|
-
export { C as CreateFxFetcherOpts, D as DEFAULT_FX_CURRENCIES, a as DEFAULT_FX_RATE_SOURCE, F as FxFetcher, b as FxRateSnapshot, c as FxRateUnavailableError, P as PlatformFxSource, d as createFxFetcher, f as fxRateFor, r as resolveFxSourceFromEnv } from './fx-
|
|
4
|
-
export { I as InvalidFxRateError, f as fiatToSatsCeil, a as formatFiat, b as formatUsd, r as roundUsd, s as satsToFiat } from './usd-
|
|
5
|
-
export { J as JobRecord, a as JobStatus, b as JobStore } from './job-store-
|
|
1
|
+
import { C as Currency, Z as ZodLike, D as DVMConfig, a as DVMDescriptor } from './step-cache-2MkvenJn.js';
|
|
2
|
+
export { A as ApprovalContent, b as ArtifactContent, c as CancelContent, d as CanonicalEnvelope, e as CreateSignedRequestVerifierOpts, f as CreditConfig, g as CreditView, h as DEFAULT_CREDIT_MAX, i as DEFAULT_CREDIT_MIN, j as DEFAULT_CREDIT_TTL_SECONDS, k as DEFAULT_JOB_RETENTION_DAYS, l as DVMRouteContext, I as IncomingMessage, m as InputType, n as InvalidCurrencyError, J as JobCost, K as KVStore, L as Logger, P as PaymentContent, o as PaymentMethod, p as PriceValue, q as ProgressContent, r as PromptOpts, Q as QuoteConfig, s as QuoteContext, t as QuoteResult, R as ResolvedCreditConfig, u as ResponseContent, S as SDKJobContext, v as SDKPaymentRequestOpts, w as SIGNED_REQUEST_AUTH_ID, x as SIGNED_REQUEST_STATEMENT_VERSION, y as SignedRequestAudience, z as SignedRequestDomain, B as SignedRequestError, E as SignedRequestFailure, F as SignedRequestReplayStore, G as SignedRequestSignOpts, H as SignedRequestStatementHeader, M as SignedRequestVerifier, U as UnsupportedCurrencyError, N as createSignedRequestVerifier, O as isZodSchema, T as signedRequestStatementHeader, V as validateCurrency } from './step-cache-2MkvenJn.js';
|
|
3
|
+
export { C as CreateFxFetcherOpts, D as DEFAULT_FX_CURRENCIES, a as DEFAULT_FX_RATE_SOURCE, F as FxFetcher, b as FxRateSnapshot, c as FxRateUnavailableError, P as PlatformFxSource, d as createFxFetcher, f as fxRateFor, r as resolveFxSourceFromEnv } from './fx-zMWFzfrU.js';
|
|
4
|
+
export { I as InvalidFxRateError, f as fiatToSatsCeil, a as formatFiat, b as formatUsd, r as roundUsd, s as satsToFiat } from './usd-DI3d3gTK.js';
|
|
5
|
+
export { J as JobRecord, a as JobStatus, b as JobStore } from './job-store-DdLXBpol.js';
|
|
6
6
|
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';
|
|
7
7
|
export { z } from 'zod';
|
|
8
8
|
import 'hono';
|
package/dist/index.js
CHANGED
|
@@ -7,11 +7,11 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
configureDVM,
|
|
9
9
|
isConfiguredDVMDescriptor
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-HCLVYZUZ.js";
|
|
11
11
|
import {
|
|
12
12
|
SignedRequestError,
|
|
13
13
|
createSignedRequestVerifier
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-N5RZ5HVB.js";
|
|
15
15
|
import {
|
|
16
16
|
DEFAULT_CREDIT_MAX,
|
|
17
17
|
DEFAULT_CREDIT_MIN,
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
SIGNED_REQUEST_STATEMENT_VERSION,
|
|
22
22
|
isZodSchema,
|
|
23
23
|
signedRequestStatementHeader
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-RCM3P2HE.js";
|
|
25
25
|
import "./chunk-OFVV37XC.js";
|
|
26
26
|
import {
|
|
27
27
|
DEFAULT_FX_CURRENCIES,
|