@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
|
@@ -5427,7 +5427,7 @@ declare const DEFAULT_CREDIT_MAX: PriceValue;
|
|
|
5427
5427
|
/** Platform default for {@link CreditConfig.ttl}: 30 days. */
|
|
5428
5428
|
declare const DEFAULT_CREDIT_TTL_SECONDS: number;
|
|
5429
5429
|
/** Default lifetime of caller-controlled job content before it is redacted. */
|
|
5430
|
-
declare const DEFAULT_JOB_RETENTION_DAYS =
|
|
5430
|
+
declare const DEFAULT_JOB_RETENTION_DAYS = 730;
|
|
5431
5431
|
/**
|
|
5432
5432
|
* Per-capability configuration for the multi-capability shape.
|
|
5433
5433
|
* Each capability is an independent unit a caller pays for: its own input
|
|
@@ -5591,7 +5591,7 @@ interface DVMConfig<State = Record<string, unknown>, InputSchema extends ZodLike
|
|
|
5591
5591
|
/**
|
|
5592
5592
|
* Days terminal job content remains available before the SDK redacts it.
|
|
5593
5593
|
* The durable row, payment linkage, and signed receipt remain for accounting
|
|
5594
|
-
* and request-id safety. Default:
|
|
5594
|
+
* and request-id safety. Default: 730. Set to `0` to disable automatic
|
|
5595
5595
|
* redaction.
|
|
5596
5596
|
*/
|
|
5597
5597
|
jobRetentionDays?: number;
|
|
@@ -5761,4 +5761,4 @@ declare class StepCache {
|
|
|
5761
5761
|
static deserialize(records: StepRecord[]): StepCache;
|
|
5762
5762
|
}
|
|
5763
5763
|
|
|
5764
|
-
export { type
|
|
5764
|
+
export { type JobReceipt as $, type ApprovalContent as A, SignedRequestError as B, type Currency as C, type DVMConfig as D, type SignedRequestFailure as E, type SignedRequestReplayStore as F, type SignedRequestSignOpts as G, type SignedRequestStatementHeader as H, type IncomingMessage as I, type JobCost as J, type KVStore as K, type Logger as L, type SignedRequestVerifier as M, createSignedRequestVerifier as N, isZodSchema as O, type PaymentContent as P, type QuoteConfig as Q, type ResolvedCreditConfig as R, type SDKJobContext as S, signedRequestStatementHeader as T, UnsupportedCurrencyError as U, validateCurrency as V, type JsonValue as W, X402_BATCH_SETTLEMENT_SCHEME as X, X402_EXACT_SCHEME as Y, type ZodLike as Z, type FundingReceipt as _, type DVMDescriptor as a, isDrainReceipt as a$, type PaymentRequired as a0, type X402Version as a1, type MppxCredential as a2, type Message as a3, type MessageType as a4, type MppxChallenge as a5, type DrainReceipt as a6, type ReceiptCredit as a7, type X402Wallet as a8, type PaymentRequirementsV1 as a9, type UnsignedFundingReceipt as aA, type UnsignedJobReceipt as aB, type VerifyResponse as aC, type WorkingContent as aD, type X402Config$1 as aE, type X402ResponseBody as aF, type X402SelfRelayRpcFailureReason as aG, X402_DEFAULT_NETWORK as aH, X402_V1_VERSION as aI, X402_VERSION as aJ, buildPaymentRequiredV2 as aK, buildPaymentRequirements as aL, caip2ToX402Network as aM, canonicalRequestPath as aN, canonicaliseForSigning as aO, canonicalize as aP, chainIdFromCaip2 as aQ, computeResultHash as aR, decodePayment as aS, decodePaymentRequiredHeader as aT, encodePayment as aU, encodePaymentRequiredHeader as aV, encodeSettleResponseHeader as aW, exactEvmAuthorization as aX, isArtifactMessage as aY, isCancelMessage as aZ, isCompleteMessage as a_, type PaymentRequirementsV2 as aa, type ResourceInfo as ab, type BuildPaymentRequirementsOpts as ac, type CapabilityDescriptor as ad, type CashuMode as ae, type CompleteContent as af, type DrainReceiptEvent as ag, type ExactEvmPayload as ah, type ExactEvmPayloadAuthorization as ai, type FundingMethod as aj, type MessageFrom as ak, type PaymentPayload as al, type PaymentPayloadV1 as am, type PaymentPayloadV2 as an, type PaymentRequestContent as ao, type PaymentRequiredV2 as ap, type PaymentRequirements as aq, type PromptContent as ar, RAIL_REFUNDABLE as as, type ReceiptOutcome as at, type ReceiptPayment as au, type SettleResponse as av, StepCache as aw, type StepRecord as ax, type TextContent as ay, type UnsignedDrainReceipt as az, type ArtifactContent as b, type DrawRecord as b$, isFundingReceipt as b0, isPaymentRequestMessage as b1, isPromptMessage as b2, isSignedJobReceipt as b3, isTextMessage as b4, isWorkingMessage as b5, paymentRequiredV2FromV1 as b6, signDrainReceipt as b7, signFundingReceipt as b8, signReceipt as b9, _testing as bA, createDefaultReplayStore as bB, depleteLots as bC, fifoOrder as bD, inKindDrawMsats as bE, isInKindDepletion as bF, isNonChannelBitcoinRail as bG, lotOwedSats as bH, netOwedSats as bI, wrapMppx as bJ, type CreditDrainEnqueue as bK, HostedSettlementReportObligations as bL, type DVMAuthScheme as bM, type CreditLedgerLike as bN, type X402RefundSettlementGate as bO, type CreditSnapshot as bP, type DrawResult as bQ, type X402SettlementStatus as bR, type X402UnresolvedRefund as bS, type GrownDrawResult as bT, type DrawResolution as bU, type FundingRecord as bV, type CreditInvoiceRecord as bW, type InvoiceSettlement as bX, type BlockedInvoiceCursor as bY, type InvoiceReconciliation as bZ, type InvoiceWriteOff as b_, usdcContractByCaip2 as ba, usdcContractFor as bb, usdcDomainNameFor as bc, usdcDomainVersionFor as bd, verifyDrainReceipt as be, verifyFundingReceipt as bf, verifyReceipt as bg, x402NetworkToCaip2 as bh, type X402ExactVersionSupport as bi, type X402Receipt as bj, type TransactionalPayoutHook as bk, type CashuMeltCompleted as bl, type CreditDepositPayload as bm, type CreditDrainPayload as bn, type FundingLot as bo, type LotDebit as bp, type LotDepletion as bq, type MppxServer as br, NON_CHANNEL_BITCOIN_RAILS as bs, type NonChannelBitcoinRail as bt, PayoutReporter as bu, PostgresTempoSessionStore as bv, RevenueReporter as bw, SIGNED_ENVELOPE_FIELDS as bx, SIGNED_ENVELOPE_TYPES as by, type X402TrackedChannel as bz, type CancelContent as c, type X402BatchSettlementConfig as c$, type StalePendingDrawCursor as c0, type TempoCreditLossEvidence as c1, type CreditLedgerQuerier as c2, type TempoCreditLoss as c3, type X402CreditLossEvidence as c4, type X402CreditLoss as c5, type DrainMethod as c6, type DrainRequestResult as c7, type BitcoinDepositLiability as c8, type CreditDrainRecord as c9, type JobTerminalReportPayload as cA, PostgresX402ChannelStorage as cB, type ReplayStoreBackend as cC, type RevenueSkippedNoRailPayload as cD, type RevenueSkippedNoRailReason as cE, type Secp256k1AuthOpts as cF, type X402ChannelStorageOpts as cG, type X402RelayLockHolder as cH, type X402RelaySubmissionLock as cI, X402RelaySubmissionLockError as cJ, allocateDrawValue as cK, clientCompatibilityAttributes as cL, clientCompatibilityMiddleware as cM, clientUpgradeRequired as cN, parseClientCapabilities as cO, parseClientCompatibility as cP, parseDvmClient as cQ, parseProtocolVersion as cR, requireClientCompatibility as cS, secp256k1Auth as cT, signedRequestInput as cU, type HostedIntent as cV, type X402SettlementIntent as cW, type HostedFundingReservation as cX, type X402SettlementCursor as cY, type X402SettlementWriteOff as cZ, type X402FacilitatorAuth as c_, type ChannelDrainCursor as ca, type DrainWriteOff as cb, type DrainReleaseResult as cc, type DrainFulfilment as cd, type DrainTransitionResult as ce, HostingCleanupFence as cf, CLIENT_COMPATIBILITY_HEADERS as cg, type ClientCompatibility as ch, type ClientCompatibilityEnv as ci, type ClientCompatibilityGate as cj, type ClientCompatibilityRequirement as ck, type ClientSemVer as cl, type CreditFundingBasis as cm, type CreditInvoiceStatus as cn, CreditLedger as co, CreditLedgerError as cp, type CreditLedgerErrorCode as cq, type CreditLedgerErrorDetails as cr, type CreditLedgerPool as cs, type CreditStatus as ct, DRAIN_DELIVERY_RESERVE_SATS as cu, DVM_PROTOCOL_VERSION as cv, type DrainConflictReason as cw, type DrawRailValue as cx, type DrawStatus as cy, type JobCostReportPayload as cz, type CanonicalEnvelope as d, type X402PayoutObserver as d0, type CreditDepositEnqueue as d1, type X402SettlementReconciliationReason as d2, type CreditDrawReleaseEnqueue as d3, type CreateSignedRequestVerifierOpts as e, type CreditConfig as f, type CreditView as g, DEFAULT_CREDIT_MAX as h, DEFAULT_CREDIT_MIN as i, DEFAULT_CREDIT_TTL_SECONDS as j, DEFAULT_JOB_RETENTION_DAYS as k, type DVMRouteContext as l, type InputType as m, InvalidCurrencyError as n, type PaymentMethod as o, type PriceValue as p, type ProgressContent as q, type PromptOpts as r, type QuoteContext as s, type QuoteResult as t, type ResponseContent as u, type SDKPaymentRequestOpts as v, SIGNED_REQUEST_AUTH_ID as w, SIGNED_REQUEST_STATEMENT_VERSION as x, type SignedRequestAudience as y, type SignedRequestDomain as z };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
assertTempoWalletIdle
|
|
3
|
+
} from "./chunk-JEVLNAO3.js";
|
|
4
|
+
import "./chunk-SZVXOQ75.js";
|
|
5
|
+
import "./chunk-O2OTZ5GP.js";
|
|
6
|
+
import "./chunk-WBOKPC37.js";
|
|
7
|
+
import "./chunk-NFMOPYBA.js";
|
|
8
|
+
import "./chunk-CXCQLOOK.js";
|
|
9
|
+
import "./chunk-OFVV37XC.js";
|
|
10
|
+
import "./chunk-FUJ36YDV.js";
|
|
11
|
+
import "./chunk-AT6V3SY7.js";
|
|
12
|
+
import "./chunk-BPYMEMQX.js";
|
|
13
|
+
export {
|
|
14
|
+
assertTempoWalletIdle
|
|
15
|
+
};
|
|
@@ -15,11 +15,11 @@ import {
|
|
|
15
15
|
tempoTokenReference,
|
|
16
16
|
tempoWrongAssetHint,
|
|
17
17
|
tryResolveTempoAsset
|
|
18
|
-
} from "./chunk-
|
|
19
|
-
import "./chunk-
|
|
20
|
-
import "./chunk-
|
|
18
|
+
} from "./chunk-SZVXOQ75.js";
|
|
19
|
+
import "./chunk-WBOKPC37.js";
|
|
20
|
+
import "./chunk-CXCQLOOK.js";
|
|
21
21
|
import "./chunk-FUJ36YDV.js";
|
|
22
|
-
import "./chunk-
|
|
22
|
+
import "./chunk-BPYMEMQX.js";
|
|
23
23
|
export {
|
|
24
24
|
TEMPO_CHAIN_ID,
|
|
25
25
|
TEMPO_MODERATO_CHAIN_ID,
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { C as ContentHoldHistory, a as ContentHoldMutation } from '../content-retention-DHyLdA6b.js';
|
|
2
|
+
import { $ as JobReceipt, a3 as Message, a4 as MessageType, K as KVStore, L as Logger, u as ResponseContent, P as PaymentContent, S as SDKJobContext } from '../step-cache-2MkvenJn.js';
|
|
3
|
+
import { c as StreamableJobStore, R as ReceiptIssuingStore, J as JobRecord, d as RequestIdClaim, e as RequestIdClaimResult, f as JobRetentionCursor, O as OutgoingMessage, A as AppendOutgoingOptions, P as PaymentCreditDelta, V as VerifyAndCreditResult, g as JobCounters } from '../job-store-DdLXBpol.js';
|
|
3
4
|
import 'hono';
|
|
4
5
|
import 'mppx';
|
|
5
6
|
import '@x402/core/server';
|
|
@@ -16,6 +17,7 @@ import '@cashu/cashu-ts';
|
|
|
16
17
|
* concurrency control beyond JS's single-threaded execution.
|
|
17
18
|
*/
|
|
18
19
|
declare class MemoryJobStore implements StreamableJobStore, ReceiptIssuingStore {
|
|
20
|
+
private contentHolds;
|
|
19
21
|
private data;
|
|
20
22
|
private messages;
|
|
21
23
|
private nextSeq;
|
|
@@ -44,6 +46,11 @@ declare class MemoryJobStore implements StreamableJobStore, ReceiptIssuingStore
|
|
|
44
46
|
expectedLastActivityAt: number;
|
|
45
47
|
redactedAt: number;
|
|
46
48
|
}): Promise<boolean>;
|
|
49
|
+
getContentSnapshot(jobId: string): Promise<{
|
|
50
|
+
job: JobRecord;
|
|
51
|
+
history: ContentHoldHistory;
|
|
52
|
+
} | undefined>;
|
|
53
|
+
mutateContentHold(jobId: string, mutation: ContentHoldMutation): Promise<ContentHoldHistory>;
|
|
47
54
|
claimReceiptSeq(jobId: string): Promise<number>;
|
|
48
55
|
saveReceipt(jobId: string, receipt: JobReceipt): Promise<JobReceipt | undefined>;
|
|
49
56
|
appendOutgoing(jobId: string, message: OutgoingMessage, opts?: AppendOutgoingOptions): Promise<number>;
|
package/dist/testing/index.js
CHANGED
|
@@ -2,15 +2,18 @@ import {
|
|
|
2
2
|
MemoryKVStore
|
|
3
3
|
} from "../chunk-SDK6KDJN.js";
|
|
4
4
|
import {
|
|
5
|
-
JobCancelledError,
|
|
6
5
|
MemoryJobStore,
|
|
7
6
|
createInstrumentedFetch
|
|
8
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-IV6Q7NRW.js";
|
|
8
|
+
import {
|
|
9
|
+
JobCancelledError
|
|
10
|
+
} from "../chunk-AFV77S4C.js";
|
|
9
11
|
import {
|
|
10
12
|
createNoopLogger
|
|
11
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-QR2EF2NI.js";
|
|
12
14
|
import "../chunk-66HGCPBU.js";
|
|
13
15
|
import "../chunk-FUJ36YDV.js";
|
|
16
|
+
import "../chunk-BQJIFRAZ.js";
|
|
14
17
|
import {
|
|
15
18
|
validateCurrency
|
|
16
19
|
} from "../chunk-BYCEKO65.js";
|
|
@@ -10,13 +10,14 @@ import {
|
|
|
10
10
|
saveX402Wallet,
|
|
11
11
|
tryX402Payment,
|
|
12
12
|
x402WrongAssetHint
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
13
|
+
} from "./chunk-EZXAJ6EI.js";
|
|
14
|
+
import "./chunk-O2OTZ5GP.js";
|
|
15
|
+
import "./chunk-WBOKPC37.js";
|
|
16
16
|
import {
|
|
17
17
|
verifyX402Payment
|
|
18
|
-
} from "./chunk-
|
|
19
|
-
import "./chunk-
|
|
18
|
+
} from "./chunk-RA2WIX7G.js";
|
|
19
|
+
import "./chunk-S3OY533W.js";
|
|
20
|
+
import "./chunk-NFMOPYBA.js";
|
|
20
21
|
import {
|
|
21
22
|
X402_DEFAULT_FACILITATOR,
|
|
22
23
|
X402_DEFAULT_NETWORK,
|
|
@@ -35,9 +36,7 @@ import {
|
|
|
35
36
|
paymentRequiredV2FromV1,
|
|
36
37
|
usdcContractByCaip2,
|
|
37
38
|
x402NetworkToCaip2
|
|
38
|
-
} from "./chunk-
|
|
39
|
-
import "./chunk-PAIM66YA.js";
|
|
40
|
-
import "./chunk-CZULM42S.js";
|
|
39
|
+
} from "./chunk-CXCQLOOK.js";
|
|
41
40
|
import "./chunk-OFVV37XC.js";
|
|
42
41
|
import "./chunk-66HGCPBU.js";
|
|
43
42
|
import "./chunk-FUJ36YDV.js";
|
|
@@ -49,8 +48,7 @@ import {
|
|
|
49
48
|
x402NetworkLabel,
|
|
50
49
|
x402NetworkListForCopy,
|
|
51
50
|
x402SupportedNetworksHint
|
|
52
|
-
} from "./chunk-
|
|
53
|
-
import "./chunk-LIRAHP7B.js";
|
|
51
|
+
} from "./chunk-BPYMEMQX.js";
|
|
54
52
|
export {
|
|
55
53
|
X402_DEFAULT_FACILITATOR,
|
|
56
54
|
X402_DEFAULT_NETWORK,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dvmkit/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0-rc.1",
|
|
4
4
|
"description": "SDK for building accountless, pay-per-use Digital Vending Machines",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -36,7 +36,8 @@
|
|
|
36
36
|
},
|
|
37
37
|
"files": [
|
|
38
38
|
"dist",
|
|
39
|
-
"NOTICE"
|
|
39
|
+
"NOTICE",
|
|
40
|
+
"recipes"
|
|
40
41
|
],
|
|
41
42
|
"engines": {
|
|
42
43
|
"node": ">=22"
|
|
@@ -60,7 +61,8 @@
|
|
|
60
61
|
"test:db": "vitest run --config vitest.db.config.ts",
|
|
61
62
|
"typecheck": "tsc --noEmit",
|
|
62
63
|
"typecheck:scripts": "tsc --noEmit --project tsconfig.scripts.json",
|
|
63
|
-
"verify": "node scripts/verify.mjs"
|
|
64
|
+
"verify": "node scripts/verify.mjs",
|
|
65
|
+
"check:ownership": "node scripts/check-caller-ownership.mjs"
|
|
64
66
|
},
|
|
65
67
|
"dependencies": {
|
|
66
68
|
"@cashu/cashu-ts": "4.10.2",
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
-- Run with psql -X -q -t -A -v ON_ERROR_STOP=1 -f financial-export-v1.sql > financial-evidence.json
|
|
2
|
+
-- The transaction gives every table one consistent snapshot. Optional rail tables
|
|
3
|
+
-- absent from this service are empty arrays. Keep this file with the export.
|
|
4
|
+
-- Receipts are signed over every field. Reject unsupported shapes instead of
|
|
5
|
+
-- removing signed extensions and silently producing unverifiable evidence.
|
|
6
|
+
CREATE OR REPLACE FUNCTION pg_temp.receipt_v1(value jsonb) RETURNS jsonb LANGUAGE plpgsql IMMUTABLE AS $$
|
|
7
|
+
DECLARE allowed text[]; nested_allowed text[]; item record; nested_item record;
|
|
8
|
+
BEGIN
|
|
9
|
+
IF value IS NULL OR value = 'null'::jsonb THEN RETURN value; END IF;
|
|
10
|
+
IF jsonb_typeof(value) <> 'object' OR value->'v' IS DISTINCT FROM '1'::jsonb THEN
|
|
11
|
+
RAISE EXCEPTION 'financial export v1: unsupported receipt version or shape';
|
|
12
|
+
END IF;
|
|
13
|
+
CASE value->>'kind'
|
|
14
|
+
WHEN 'credit_funding' THEN allowed := ARRAY['v','kind','credit_id','fund_id','funded_micro','balance_after_micro','ledger_seq','issued_at','caller_pubkey','dvm_id','dvm','receipt_pubkey','signature'];
|
|
15
|
+
WHEN 'credit_drain' THEN allowed := ARRAY['v','kind','credit_id','drain_id','event','method','amount_micro','balance_after_micro','ledger_seq','issued_at','caller_pubkey','dvm_id','dvm','receipt_pubkey','signature'];
|
|
16
|
+
ELSE
|
|
17
|
+
IF value ? 'kind' THEN RAISE EXCEPTION 'financial export v1: unsupported receipt kind'; END IF;
|
|
18
|
+
allowed := ARRAY['v','job_id','dvm_id','dvm','capability','outcome','reason','ended_by','seq','issued_at','requester_pubkey','result_hash','receipt_pubkey','signature','paid','timing','credit'];
|
|
19
|
+
END CASE;
|
|
20
|
+
FOR item IN SELECT key,val FROM jsonb_each(value) AS e(key,val) LOOP
|
|
21
|
+
IF NOT item.key = ANY(allowed) THEN
|
|
22
|
+
RAISE EXCEPTION 'financial export v1: unsupported signed receipt extension';
|
|
23
|
+
END IF;
|
|
24
|
+
IF item.key = ANY(ARRAY['paid','timing','credit']) THEN
|
|
25
|
+
IF jsonb_typeof(item.val) <> 'object' THEN
|
|
26
|
+
RAISE EXCEPTION 'financial export v1: unsupported receipt block';
|
|
27
|
+
END IF;
|
|
28
|
+
nested_allowed := CASE item.key
|
|
29
|
+
WHEN 'paid' THEN ARRAY['msats','rail','native_amount','native_asset','tx_hash','mint']
|
|
30
|
+
WHEN 'timing' THEN ARRAY['accepted_at_ms','terminal_at_ms','caller_wait_ms']
|
|
31
|
+
WHEN 'credit' THEN ARRAY['credit_id','draw_id','amount','balance_after','ledger_seq'] END;
|
|
32
|
+
FOR nested_item IN SELECT key,val FROM jsonb_each(item.val) AS n(key,val) LOOP
|
|
33
|
+
IF NOT nested_item.key = ANY(nested_allowed) OR jsonb_typeof(nested_item.val) = ANY(ARRAY['object','array']) THEN
|
|
34
|
+
RAISE EXCEPTION 'financial export v1: unsupported signed receipt block extension';
|
|
35
|
+
END IF;
|
|
36
|
+
END LOOP;
|
|
37
|
+
ELSIF jsonb_typeof(item.val) = ANY(ARRAY['object','array']) THEN
|
|
38
|
+
RAISE EXCEPTION 'financial export v1: unsupported receipt field shape';
|
|
39
|
+
END IF;
|
|
40
|
+
END LOOP;
|
|
41
|
+
RETURN value;
|
|
42
|
+
END
|
|
43
|
+
$$;
|
|
44
|
+
-- Unsigned evidence uses explicit scalar projections. Objects/arrays in scalar
|
|
45
|
+
-- positions are excluded, including inside the supported nested financial blocks.
|
|
46
|
+
CREATE OR REPLACE FUNCTION pg_temp.scalars_v1(value jsonb, strings text[], numbers text[], booleans text[] DEFAULT ARRAY[]::text[]) RETURNS jsonb LANGUAGE sql IMMUTABLE AS $$
|
|
47
|
+
SELECT CASE WHEN jsonb_typeof(value) <> 'object' THEN NULL ELSE
|
|
48
|
+
(SELECT COALESCE(jsonb_object_agg(key,val), '{}'::jsonb) FROM jsonb_each(value) AS e(key,val)
|
|
49
|
+
WHERE (key=ANY(strings) AND jsonb_typeof(val) IN ('string','null'))
|
|
50
|
+
OR (key=ANY(numbers) AND (jsonb_typeof(val) IN ('number','null') OR (jsonb_typeof(val)='string' AND val #>> '{}' ~ '^-?[0-9]+$')))
|
|
51
|
+
OR (key=ANY(booleans) AND jsonb_typeof(val) IN ('boolean','null'))) END
|
|
52
|
+
$$;
|
|
53
|
+
CREATE OR REPLACE FUNCTION pg_temp.settlement_v1(value jsonb) RETURNS jsonb LANGUAGE sql IMMUTABLE AS $$
|
|
54
|
+
SELECT pg_temp.scalars_v1(value,
|
|
55
|
+
ARRAY['tx_hash','transaction','channel_id','network','repair_kind','payer'],
|
|
56
|
+
ARRAY['settledAmount','settled_amount','amount','refunded_native','debited_native','surplus_native'], ARRAY['success','repaired'])
|
|
57
|
+
$$;
|
|
58
|
+
CREATE OR REPLACE FUNCTION pg_temp.fulfilment_v1(value jsonb) RETURNS jsonb LANGUAGE sql IMMUTABLE AS $$
|
|
59
|
+
SELECT pg_temp.scalars_v1(value, ARRAY['source','mintUrl','quoteId'], ARRAY['faceSats','reserveSats','invoiceMsats','routingFeeMsats'])
|
|
60
|
+
$$;
|
|
61
|
+
CREATE OR REPLACE FUNCTION pg_temp.lot_debits_v1(value jsonb) RETURNS jsonb LANGUAGE sql IMMUTABLE AS $$
|
|
62
|
+
SELECT CASE WHEN jsonb_typeof(value) <> 'array' THEN NULL ELSE
|
|
63
|
+
(SELECT COALESCE(jsonb_agg(pg_temp.scalars_v1(item, ARRAY['lotId'], ARRAY['micro','sats'])), '[]'::jsonb)
|
|
64
|
+
FROM jsonb_array_elements(value) item WHERE jsonb_typeof(item)='object') END
|
|
65
|
+
$$;
|
|
66
|
+
CREATE OR REPLACE FUNCTION pg_temp.effect_v1(value jsonb) RETURNS jsonb LANGUAGE sql IMMUTABLE AS $$
|
|
67
|
+
SELECT pg_temp.scalars_v1(value, ARRAY['callerId','dvmId','jobId'],
|
|
68
|
+
ARRAY['requiredMsats','paidMsats','fundedMicro','nativeAmount','topUpCapMicro'], ARRAY['drawBasis','askSatisfied','midJob'])
|
|
69
|
+
|| jsonb_strip_nulls(jsonb_build_object(
|
|
70
|
+
'priceFiat', pg_temp.scalars_v1(value->'priceFiat', ARRAY['currency'], ARRAY['amountMicro']),
|
|
71
|
+
'fundOnly', pg_temp.scalars_v1(value->'fundOnly', ARRAY['creditId','fundId'], ARRAY[]::text[]),
|
|
72
|
+
'topUp', pg_temp.scalars_v1(value->'topUp', ARRAY['creditId','drawId'], ARRAY[]::text[]),
|
|
73
|
+
'creditEnvelope', pg_temp.scalars_v1(value->'creditEnvelope', ARRAY['creditId','drawId'], ARRAY[]::text[])))
|
|
74
|
+
$$;
|
|
75
|
+
CREATE OR REPLACE FUNCTION pg_temp.channel_config_v1(value jsonb) RETURNS jsonb LANGUAGE sql IMMUTABLE AS $$
|
|
76
|
+
SELECT pg_temp.scalars_v1(value, ARRAY['payer','payerAuthorizer','receiver','receiverAuthorizer'], ARRAY['withdrawDelay'])
|
|
77
|
+
|| CASE WHEN value->>'token' ~ '^0x[0-9a-fA-F]{40}$' THEN jsonb_build_object('token',value->'token') ELSE '{}'::jsonb END
|
|
78
|
+
$$;
|
|
79
|
+
CREATE OR REPLACE FUNCTION pg_temp.tempo_state_v1(value jsonb) RETURNS jsonb LANGUAGE plpgsql IMMUTABLE AS $$
|
|
80
|
+
DECLARE state jsonb; amounts jsonb;
|
|
81
|
+
BEGIN
|
|
82
|
+
IF value IS NULL OR value='null'::jsonb THEN RETURN NULL; END IF;
|
|
83
|
+
IF jsonb_typeof(value)<>'string' THEN RETURN NULL; END IF;
|
|
84
|
+
BEGIN state := (value #>> '{}')::jsonb;
|
|
85
|
+
EXCEPTION WHEN OTHERS THEN RAISE EXCEPTION 'financial export v1: unsupported Tempo state'; END;
|
|
86
|
+
IF jsonb_typeof(state)<>'object' THEN RETURN NULL; END IF;
|
|
87
|
+
-- Normalize the store's tagged bigints without retaining vouchers or signatures.
|
|
88
|
+
SELECT COALESCE(jsonb_object_agg(key, regexp_replace(val #>> '{}', '#__bigint$', '')), '{}'::jsonb) INTO amounts
|
|
89
|
+
FROM jsonb_each(state) AS e(key,val)
|
|
90
|
+
WHERE key=ANY(ARRAY['deposit','spent','settledOnChain','highestVoucherAmount','closeRequestedAt'])
|
|
91
|
+
AND jsonb_typeof(val) IN ('number','string') AND val #>> '{}' ~ '^[0-9]+(#__bigint)?$';
|
|
92
|
+
RETURN pg_temp.scalars_v1(state, ARRAY['channelId','escrowContract','payee','payer'], ARRAY['chainId','units'], ARRAY['finalized']) || amounts
|
|
93
|
+
|| CASE WHEN state->>'token' ~ '^0x[0-9a-fA-F]{40}$' THEN jsonb_build_object('token',state->'token') ELSE '{}'::jsonb END;
|
|
94
|
+
END
|
|
95
|
+
$$;
|
|
96
|
+
CREATE OR REPLACE FUNCTION pg_temp.financial_rows_v1(table_name text, columns text[]) RETURNS jsonb LANGUAGE plpgsql AS $$
|
|
97
|
+
DECLARE result jsonb;
|
|
98
|
+
BEGIN
|
|
99
|
+
IF to_regclass(table_name) IS NULL THEN RETURN '[]'::jsonb; END IF;
|
|
100
|
+
EXECUTE format('SELECT COALESCE(jsonb_agg(projected ORDER BY projected::text), ''[]''::jsonb) FROM (
|
|
101
|
+
SELECT (SELECT COALESCE(jsonb_object_agg(key,
|
|
102
|
+
CASE WHEN key=ANY(ARRAY[''sent_ref'',''settle_response'']) THEN pg_temp.settlement_v1(value)
|
|
103
|
+
WHEN key=''fulfilment'' THEN pg_temp.fulfilment_v1(value)
|
|
104
|
+
WHEN key=''lot_debits'' THEN pg_temp.lot_debits_v1(value)
|
|
105
|
+
WHEN key=''state_json'' THEN pg_temp.tempo_state_v1(value)
|
|
106
|
+
WHEN key=''channel_config'' THEN pg_temp.channel_config_v1(value)
|
|
107
|
+
WHEN key=''effect'' THEN pg_temp.effect_v1(value)
|
|
108
|
+
WHEN key=''receipt'' THEN pg_temp.receipt_v1(value)
|
|
109
|
+
WHEN key=''receipts'' THEN (SELECT COALESCE(jsonb_agg(pg_temp.receipt_v1(r)), ''[]''::jsonb) FROM jsonb_array_elements(value) r)
|
|
110
|
+
ELSE CASE WHEN jsonb_typeof(value) NOT IN (''object'',''array'') THEN value ELSE NULL END END), ''{}''::jsonb)
|
|
111
|
+
FROM jsonb_each(to_jsonb(t)) WHERE key=ANY($1)) projected FROM %I t) rows', table_name)
|
|
112
|
+
INTO result USING columns;
|
|
113
|
+
RETURN result;
|
|
114
|
+
END
|
|
115
|
+
$$;
|
|
116
|
+
BEGIN TRANSACTION ISOLATION LEVEL REPEATABLE READ READ ONLY;
|
|
117
|
+
SELECT jsonb_build_object(
|
|
118
|
+
'format', 'dvmkit-financial-evidence', 'version', 1,
|
|
119
|
+
'jobs', pg_temp.financial_rows_v1('jobs', ARRAY['id','dvm_id','request_id','requester_pubkey','capability','status','created_at','last_activity_at','terminal_at_ms','ended_by','receipt','receipt_seq','paid_msats','payment_rail','payment_tx_hash','payment_transaction_hash','native_amount','native_asset','credit_id','draw_id','cost_amount_micro','cost_currency']),
|
|
120
|
+
'credits', pg_temp.financial_rows_v1('credits', ARRAY['credit_id','caller_pubkey','currency','balance_micro','expiry_ms','status','last_ledger_seq','created_at','rail','native_asset','funding_ref','tempo_channel_id','x402_channel_id','msats_remaining','native_remaining']),
|
|
121
|
+
'fundings', pg_temp.financial_rows_v1('credit_fundings', ARRAY['credit_id','fund_id','caller_pubkey','amount_micro','rail','created_at','balance_after_micro','ledger_seq','receipt']),
|
|
122
|
+
'funding_lots', pg_temp.financial_rows_v1('credit_funding_lots', ARRAY['lot_id','credit_id','rail','sats_funded','credited_micro','remaining_micro','funding_ref','created_at']),
|
|
123
|
+
'draws', pg_temp.financial_rows_v1('credit_draws', ARRAY['credit_id','draw_id','job_id','amount_micro','ledger_seq','status','balance_after_micro','created_at','resolved_at','draw_msats','allocated_msats','draw_native','grown_micro']),
|
|
124
|
+
'drains', pg_temp.financial_rows_v1('credit_drains', ARRAY['credit_id','drain_id','method','amount_micro','balance_after_micro','drained_msats','drained_native','owed_sats','ledger_seq','status','receipts','sent_ref','fulfilment','lot_debits','created_at','parked_at','picked_up_at','sent_at','released_at','written_off_at']),
|
|
125
|
+
'invoices', pg_temp.financial_rows_v1('credit_invoices', ARRAY['credit_id','fund_id','caller_pubkey','currency','amount_micro','amount_msats','payment_hash','status','expires_at','created_at','settled_at','reconciled_credit_id','reconciled_fund_id','resolved_at']),
|
|
126
|
+
'expiry_releases', pg_temp.financial_rows_v1('credit_expiry_releases', ARRAY['credit_id','release_id','caller_pubkey','currency','rail','amount_micro','expiry_ms','released_at','reversed_at']),
|
|
127
|
+
'tempo_channels', pg_temp.financial_rows_v1('mpp_tempo_channels', ARRAY['channel_key','state_json','updated_at']),
|
|
128
|
+
'tempo_channel_tombstones', pg_temp.financial_rows_v1('mpp_tempo_channel_tombstones', ARRAY['channel_key','state_json','deleted_at_ms']),
|
|
129
|
+
'tempo_close_intents', pg_temp.financial_rows_v1('mpp_tempo_close_intents', ARRAY['channel_id','drain_id','reference','forecast_pending','updated_at']),
|
|
130
|
+
'x402_channels', pg_temp.financial_rows_v1('x402_batch_channels', ARRAY['channel_id','channel_config','charged_cumulative_amount','signed_max_claimable','balance','total_claimed','withdraw_requested_at','refund_nonce','onchain_synced_at','last_request_timestamp']),
|
|
131
|
+
'x402_channel_tombstones', pg_temp.financial_rows_v1('x402_batch_channel_tombstones', ARRAY['channel_id','charged_cumulative_amount','signed_max_claimable','refund_nonce','deleted_at_ms']),
|
|
132
|
+
'x402_batch_settlements', pg_temp.financial_rows_v1('x402_batch_settlements', ARRAY['settlement_id','channel_id','operation','effect_id','payment_id','status','submission_block','settle_response','created_at','updated_at','resolved_at']),
|
|
133
|
+
'x402_exact_settlements', pg_temp.financial_rows_v1('x402_exact_settlement_intents', ARRAY['dvm_id','intent_id','network','asset','authorizer','recipient','value','status','effect','submission_block','transaction','settle_response','last_outcome','created_at','updated_at','resolved_at']),
|
|
134
|
+
'tempo_losses', pg_temp.financial_rows_v1('tempo_credit_losses', ARRAY['credit_id','channel_id','caller_pubkey','currency','former_balance_micro','settled_on_chain_native','highest_voucher_native','consumed_service_micro','consumed_native','observed_at']),
|
|
135
|
+
'x402_losses', pg_temp.financial_rows_v1('x402_credit_losses', ARRAY['credit_id','channel_id','caller_pubkey','currency','former_balance_micro','channel_balance_native','total_claimed_native','consumed_service_micro','observed_at'])
|
|
136
|
+
);
|
|
137
|
+
ROLLBACK;
|
package/dist/chunk-CZULM42S.js
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
// src/defaults.ts
|
|
2
|
-
import { homedir } from "os";
|
|
3
|
-
import { join } from "path";
|
|
4
|
-
var CONFIG_DIR = process.env.DVM_CONFIG_DIR ?? join(homedir(), ".dvm");
|
|
5
|
-
var CONFIG_FILE = join(CONFIG_DIR, "config.json");
|
|
6
|
-
var CONFIG_BACKUP_FILE = join(CONFIG_DIR, "config.json.bak");
|
|
7
|
-
var CONFIG_AUDIT_FILE = join(CONFIG_DIR, "config-audit.jsonl");
|
|
8
|
-
var CONFIG_PINNED_FILE = join(CONFIG_DIR, "config.json.pinned");
|
|
9
|
-
var JOBS_FILE = join(CONFIG_DIR, "jobs.json");
|
|
10
|
-
var REQUEST_INTENTS_DIR = join(CONFIG_DIR, "request-intents");
|
|
11
|
-
var FAVORITES_FILE = join(CONFIG_DIR, "favorites.json");
|
|
12
|
-
var MESSAGES_DIR = join(CONFIG_DIR, "messages");
|
|
13
|
-
var RECEIPTS_FILE = join(CONFIG_DIR, "receipts.jsonl");
|
|
14
|
-
var CREDITS_FILE = join(CONFIG_DIR, "credits.json");
|
|
15
|
-
var X402_CHANNELS_FILE = join(CONFIG_DIR, "x402-channels.json");
|
|
16
|
-
var TEMPO_CHANNELS_FILE = join(CONFIG_DIR, "tempo-channels.json");
|
|
17
|
-
var FEEDBACK_NUDGES_FILE = join(CONFIG_DIR, "feedback-nudges.json");
|
|
18
|
-
var RECOVERY_MNEMONIC_FILE = join(CONFIG_DIR, "recovery.mnemonic");
|
|
19
|
-
var WALLET_FILE = join(CONFIG_DIR, "wallet.json");
|
|
20
|
-
var AGENT_MNEMONIC_FILE = join(CONFIG_DIR, "wallet.mnemonic");
|
|
21
|
-
var IDENTITIES_FILE = join(CONFIG_DIR, "identities.json");
|
|
22
|
-
var PAIRINGS_DIR = join(CONFIG_DIR, "pairings");
|
|
23
|
-
var BUDGET_FILE = join(CONFIG_DIR, "budget.json");
|
|
24
|
-
var BTC_RATE_FILE = join(CONFIG_DIR, "btc-rate.json");
|
|
25
|
-
var ADMIN_DIR = join(CONFIG_DIR, "admin");
|
|
26
|
-
var PROXY_STATE_FILE = join(ADMIN_DIR, "proxy.json");
|
|
27
|
-
var BUILDER_CONFIG_DIR = process.env.DVMKIT_CONFIG_DIR ?? join(homedir(), ".dvmkit");
|
|
28
|
-
var BUILDER_FILE = join(BUILDER_CONFIG_DIR, "builder.json");
|
|
29
|
-
var BUILDER_MNEMONIC_FILE = join(BUILDER_CONFIG_DIR, "recovery.mnemonic");
|
|
30
|
-
var BUILDER_KEY_FILE = join(BUILDER_CONFIG_DIR, "builder.key");
|
|
31
|
-
var MELT_PENDING_LOG_FILE = join(BUILDER_CONFIG_DIR, "melt-pending.log");
|
|
32
|
-
var DRAIN_PARK_LOG_FILE = join(BUILDER_CONFIG_DIR, "drain-park.log");
|
|
33
|
-
var DRAIN_HOLD_STATE_FILE = join(BUILDER_CONFIG_DIR, "drain-hold.json");
|
|
34
|
-
var MELT_SUCCESS_FILE = join(BUILDER_CONFIG_DIR, "melt-success.json");
|
|
35
|
-
|
|
36
|
-
// src/lib/config-dir.ts
|
|
37
|
-
import { chmodSync, mkdirSync, statSync } from "fs";
|
|
38
|
-
var CONFIG_DIR_MODE = 448;
|
|
39
|
-
function ensureConfigDir() {
|
|
40
|
-
ensureConfigSubdir(CONFIG_DIR);
|
|
41
|
-
}
|
|
42
|
-
function ensureConfigSubdir(path) {
|
|
43
|
-
mkdirSync(path, { recursive: true, mode: CONFIG_DIR_MODE });
|
|
44
|
-
}
|
|
45
|
-
function repairConfigDirMode() {
|
|
46
|
-
const base = {
|
|
47
|
-
path: CONFIG_DIR,
|
|
48
|
-
exists: false,
|
|
49
|
-
modeOctal: null,
|
|
50
|
-
repaired: false,
|
|
51
|
-
skippedNonPosix: process.platform === "win32"
|
|
52
|
-
};
|
|
53
|
-
if (base.skippedNonPosix) return base;
|
|
54
|
-
let mode;
|
|
55
|
-
try {
|
|
56
|
-
mode = statSync(CONFIG_DIR).mode & 511;
|
|
57
|
-
} catch (err) {
|
|
58
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
59
|
-
const missing = err.code === "ENOENT";
|
|
60
|
-
return missing ? base : { ...base, error: message };
|
|
61
|
-
}
|
|
62
|
-
if ((mode & 63) === 0) {
|
|
63
|
-
return { ...base, exists: true, modeOctal: toOctal(mode) };
|
|
64
|
-
}
|
|
65
|
-
try {
|
|
66
|
-
chmodSync(CONFIG_DIR, CONFIG_DIR_MODE);
|
|
67
|
-
} catch (err) {
|
|
68
|
-
return {
|
|
69
|
-
...base,
|
|
70
|
-
exists: true,
|
|
71
|
-
modeOctal: toOctal(mode),
|
|
72
|
-
error: err instanceof Error ? err.message : String(err)
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
return {
|
|
76
|
-
...base,
|
|
77
|
-
exists: true,
|
|
78
|
-
modeOctal: toOctal(CONFIG_DIR_MODE),
|
|
79
|
-
previousModeOctal: toOctal(mode),
|
|
80
|
-
repaired: true
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
function toOctal(mode) {
|
|
84
|
-
return "0" + mode.toString(8).padStart(3, "0");
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// src/lib/payment-rails/rpc.ts
|
|
88
|
-
function resolveRpcOverride(envValue, bundled) {
|
|
89
|
-
const override = envValue?.trim() ?? "";
|
|
90
|
-
return override.length > 0 ? { url: override, source: "override" } : { url: bundled, source: "bundled" };
|
|
91
|
-
}
|
|
92
|
-
function resolveRpcHttpTransportOptions(source, envValue) {
|
|
93
|
-
if (source !== "override" || !envValue?.trim()) return void 0;
|
|
94
|
-
let parsed;
|
|
95
|
-
try {
|
|
96
|
-
parsed = JSON.parse(envValue);
|
|
97
|
-
} catch {
|
|
98
|
-
throw new Error("RPC headers must be a JSON object of non-empty string values.");
|
|
99
|
-
}
|
|
100
|
-
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
|
|
101
|
-
throw new Error("RPC headers must be a JSON object of non-empty string values.");
|
|
102
|
-
const headers = {};
|
|
103
|
-
for (const [name, value] of Object.entries(parsed)) {
|
|
104
|
-
if (!/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/.test(name) || typeof value !== "string" || value.length === 0 || /[\r\n]/.test(value))
|
|
105
|
-
throw new Error("RPC headers must be a JSON object of non-empty string values.");
|
|
106
|
-
headers[name] = value;
|
|
107
|
-
}
|
|
108
|
-
if (Object.keys(headers).length === 0)
|
|
109
|
-
throw new Error("RPC headers must be a JSON object of non-empty string values.");
|
|
110
|
-
return { fetchOptions: { headers } };
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export {
|
|
114
|
-
CONFIG_DIR,
|
|
115
|
-
CONFIG_FILE,
|
|
116
|
-
CONFIG_BACKUP_FILE,
|
|
117
|
-
CONFIG_AUDIT_FILE,
|
|
118
|
-
CONFIG_PINNED_FILE,
|
|
119
|
-
JOBS_FILE,
|
|
120
|
-
REQUEST_INTENTS_DIR,
|
|
121
|
-
FAVORITES_FILE,
|
|
122
|
-
MESSAGES_DIR,
|
|
123
|
-
RECEIPTS_FILE,
|
|
124
|
-
CREDITS_FILE,
|
|
125
|
-
X402_CHANNELS_FILE,
|
|
126
|
-
TEMPO_CHANNELS_FILE,
|
|
127
|
-
FEEDBACK_NUDGES_FILE,
|
|
128
|
-
RECOVERY_MNEMONIC_FILE,
|
|
129
|
-
WALLET_FILE,
|
|
130
|
-
AGENT_MNEMONIC_FILE,
|
|
131
|
-
IDENTITIES_FILE,
|
|
132
|
-
PAIRINGS_DIR,
|
|
133
|
-
BUDGET_FILE,
|
|
134
|
-
BTC_RATE_FILE,
|
|
135
|
-
BUILDER_CONFIG_DIR,
|
|
136
|
-
BUILDER_FILE,
|
|
137
|
-
BUILDER_KEY_FILE,
|
|
138
|
-
ensureConfigDir,
|
|
139
|
-
ensureConfigSubdir,
|
|
140
|
-
repairConfigDirMode,
|
|
141
|
-
resolveRpcOverride,
|
|
142
|
-
resolveRpcHttpTransportOptions
|
|
143
|
-
};
|
package/dist/chunk-LIRAHP7B.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
// src/lib/errors.ts
|
|
2
|
-
var DvmError = class extends Error {
|
|
3
|
-
constructor(code, message, hint, data, display, proseSources) {
|
|
4
|
-
super(message);
|
|
5
|
-
this.code = code;
|
|
6
|
-
this.hint = hint;
|
|
7
|
-
this.data = data;
|
|
8
|
-
this.display = display;
|
|
9
|
-
this.proseSources = proseSources;
|
|
10
|
-
this.name = "DvmError";
|
|
11
|
-
}
|
|
12
|
-
code;
|
|
13
|
-
hint;
|
|
14
|
-
data;
|
|
15
|
-
display;
|
|
16
|
-
proseSources;
|
|
17
|
-
};
|
|
18
|
-
function providerProseSources(...sources) {
|
|
19
|
-
const provenance = {};
|
|
20
|
-
for (const source of sources) {
|
|
21
|
-
if (!source) continue;
|
|
22
|
-
for (const field of ["message", "hint", "display"]) {
|
|
23
|
-
if (typeof source[field] === "string") provenance[field] = "provider";
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return Object.keys(provenance).length > 0 ? provenance : void 0;
|
|
27
|
-
}
|
|
28
|
-
function isAbortError(err) {
|
|
29
|
-
return err instanceof Error && (err.name === "AbortError" || err.name === "TimeoutError");
|
|
30
|
-
}
|
|
31
|
-
function transportErrorCode(err) {
|
|
32
|
-
let current = err;
|
|
33
|
-
const seen = /* @__PURE__ */ new Set();
|
|
34
|
-
for (let depth = 0; depth < 5 && isErrorLike(current) && !seen.has(current); depth++) {
|
|
35
|
-
seen.add(current);
|
|
36
|
-
const code = current.code;
|
|
37
|
-
if (typeof code === "string" && /^(?:E[A-Z0-9_]{1,63}|UND_ERR_[A-Z0-9_]{1,63})$/.test(code)) {
|
|
38
|
-
return code;
|
|
39
|
-
}
|
|
40
|
-
current = current.cause;
|
|
41
|
-
}
|
|
42
|
-
return void 0;
|
|
43
|
-
}
|
|
44
|
-
function isErrorLike(value) {
|
|
45
|
-
return (typeof value === "object" || typeof value === "function") && value !== null;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export {
|
|
49
|
-
DvmError,
|
|
50
|
-
providerProseSources,
|
|
51
|
-
isAbortError,
|
|
52
|
-
transportErrorCode
|
|
53
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
assertTempoWalletIdle
|
|
3
|
-
} from "./chunk-UOCZXO2Z.js";
|
|
4
|
-
import "./chunk-GFY5FRX3.js";
|
|
5
|
-
import "./chunk-B2IROPQF.js";
|
|
6
|
-
import "./chunk-MZRJR2CW.js";
|
|
7
|
-
import "./chunk-PAIM66YA.js";
|
|
8
|
-
import "./chunk-CZULM42S.js";
|
|
9
|
-
import "./chunk-OFVV37XC.js";
|
|
10
|
-
import "./chunk-FUJ36YDV.js";
|
|
11
|
-
import "./chunk-AT6V3SY7.js";
|
|
12
|
-
import "./chunk-LIRAHP7B.js";
|
|
13
|
-
export {
|
|
14
|
-
assertTempoWalletIdle
|
|
15
|
-
};
|