uvd-x402-sdk 2.53.0 → 2.55.0
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/dist/index.d.mts +169 -1
- package/dist/index.d.ts +169 -1
- package/dist/index.js +273 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +258 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -1
- package/src/dx402.ts +484 -0
- package/src/dx402.vectors.json +15 -0
- package/src/index.ts +22 -0
package/dist/index.d.mts
CHANGED
|
@@ -6,6 +6,174 @@ export { a as EIP3009Authorization, E as EIP3009Params } from './wallet-w7BnImDG
|
|
|
6
6
|
export { E as EnvKeyAdapter, O as OWSWallet, a as OWSWalletAdapter } from './ows-Z9v4GxOZ.mjs';
|
|
7
7
|
export { FacilitatorClient, FacilitatorClientOptions, HonoMiddlewareOptions, PaymentAcceptance, PaymentMiddlewareOptions, PaymentPayloadV2, PaymentRequirementsV2, ResourceInfoV2, SettleRequestV2, VerifiedPaymentState, VerifyRequestV2, X402_CORS_HEADERS, X402_HEADER_NAMES, buildPaymentRequirements, buildSettleRequest, buildSettleRequestV2, buildVerifyRequest, buildVerifyRequestV2, create402Response, createHonoMiddleware, createPaymentMiddleware, extractPaymentFromHeaders, getCorsHeaders } from './backend/index.mjs';
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* DX402 `durable-evidence`: recover a paid response after the fact.
|
|
11
|
+
*
|
|
12
|
+
* x402 settles payment on-chain permanently but delivers the purchased resource
|
|
13
|
+
* **exactly once**, in the body of a `200 OK`, and keeps nothing. A buyer who did
|
|
14
|
+
* not capture it at that instant cannot recover it, and neither party can later
|
|
15
|
+
* prove *what* was delivered — only *that* payment happened.
|
|
16
|
+
*
|
|
17
|
+
* DX402 closes that gap. The seller seals a copy of the response to the payer's
|
|
18
|
+
* own public key — recovered from the payment signature itself — and anchors it.
|
|
19
|
+
* The buyer gets an `X-Durable-Evidence` header pointing at it.
|
|
20
|
+
*
|
|
21
|
+
* **Paying is publishing your encryption key.** No registration, no key
|
|
22
|
+
* exchange, no extra round trip.
|
|
23
|
+
*
|
|
24
|
+
* ```ts
|
|
25
|
+
* const evidence = evidenceFromHeaders(response.headers);
|
|
26
|
+
* const body = await recoverEvidence(evidence, myPrivateKey);
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* Specification: `docs/plans/dx402/02-SPEC-v0.1.md` in x402-rs.
|
|
30
|
+
*/
|
|
31
|
+
declare const EVIDENCE_HEADER = "X-Durable-Evidence";
|
|
32
|
+
declare class DX402Error extends Error {
|
|
33
|
+
constructor(message: string);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* No evidence was anchored for this payment.
|
|
37
|
+
*
|
|
38
|
+
* A normal outcome, not a fault: the body may have exceeded the seller's size
|
|
39
|
+
* cap, the store may have been unreachable, or the payer may be a
|
|
40
|
+
* smart-contract wallet with no recoverable key.
|
|
41
|
+
*/
|
|
42
|
+
declare class EvidenceSkipped extends DX402Error {
|
|
43
|
+
readonly reason: string;
|
|
44
|
+
constructor(reason: string);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The anchored bytes are not the bytes that were delivered.
|
|
48
|
+
*
|
|
49
|
+
* This is the interesting failure: the seller anchored something other than
|
|
50
|
+
* what it served, which is precisely the fraud `contentHash` exists to expose.
|
|
51
|
+
* Treat it as evidence of misbehaviour, not a transport glitch.
|
|
52
|
+
*/
|
|
53
|
+
declare class ContentHashMismatch extends DX402Error {
|
|
54
|
+
readonly anchored: string;
|
|
55
|
+
readonly actual: string;
|
|
56
|
+
constructor(anchored: string, actual: string);
|
|
57
|
+
}
|
|
58
|
+
type EvidenceMode = 'direct' | 'escrowed';
|
|
59
|
+
interface AnchoredEvidence {
|
|
60
|
+
v: number;
|
|
61
|
+
paymentId: string;
|
|
62
|
+
pointer: string;
|
|
63
|
+
backend: string;
|
|
64
|
+
contentHash: string;
|
|
65
|
+
cipher: string;
|
|
66
|
+
keyAlg: 'ECIES-secp256k1' | 'ECIES-X25519';
|
|
67
|
+
mode: EvidenceMode;
|
|
68
|
+
retention: string;
|
|
69
|
+
receipt?: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Whether the facilitator is cryptographically unable to read this payload.
|
|
73
|
+
*
|
|
74
|
+
* `direct` and `escrowed` make materially different claims about who can open
|
|
75
|
+
* the payload, so a caller that cares about confidentiality must check rather
|
|
76
|
+
* than assume.
|
|
77
|
+
*/
|
|
78
|
+
declare function isEndToEnd(evidence: AnchoredEvidence): boolean;
|
|
79
|
+
/** keccak256 of a body, `0x`-prefixed — matching the facilitator's `contentHash`. */
|
|
80
|
+
declare function contentHash(body: Uint8Array): string;
|
|
81
|
+
/**
|
|
82
|
+
* Derive the canonical payment identifier: `keccak256(caip2Network || txHash)`.
|
|
83
|
+
*
|
|
84
|
+
* This value is the AEAD associated data binding a ciphertext to its payment.
|
|
85
|
+
* Buyer and seller must derive it identically or decryption fails with no
|
|
86
|
+
* obvious cause, which is why it lives in the SDK rather than in each caller.
|
|
87
|
+
*/
|
|
88
|
+
declare function paymentId(caip2Network: string, txHash: string): string;
|
|
89
|
+
/** Parse an `X-Durable-Evidence` header value. */
|
|
90
|
+
declare function parseEvidenceHeader(value: string): AnchoredEvidence;
|
|
91
|
+
/**
|
|
92
|
+
* Pull the anchored evidence out of a response's headers.
|
|
93
|
+
*
|
|
94
|
+
* Accepts a `Headers` object or a plain record. Lookup is case-insensitive,
|
|
95
|
+
* because HTTP does not care and different clients disagree about casing.
|
|
96
|
+
*/
|
|
97
|
+
declare function evidenceFromHeaders(headers: Headers | Record<string, string>): AnchoredEvidence;
|
|
98
|
+
/**
|
|
99
|
+
* Turn a DX402 pointer into a fetchable URL.
|
|
100
|
+
*
|
|
101
|
+
* `s3+https://...` is a scheme tag over an ordinary HTTPS URL; `ipfs://` and
|
|
102
|
+
* `ar://` go through public gateways. Anything else passes through untouched, so
|
|
103
|
+
* a caller with their own resolver is not blocked by this function.
|
|
104
|
+
*/
|
|
105
|
+
declare function dereferencePointer(pointer: string): string;
|
|
106
|
+
interface SealedEnvelope {
|
|
107
|
+
alg: 'secp256k1' | 'x25519';
|
|
108
|
+
ephemeral: Uint8Array;
|
|
109
|
+
cekNonce: Uint8Array;
|
|
110
|
+
wrappedCek: Uint8Array;
|
|
111
|
+
bodyNonce: Uint8Array;
|
|
112
|
+
ciphertext: Uint8Array;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Parse the sealed-blob layout.
|
|
116
|
+
*
|
|
117
|
+
* `MAGIC | version | alg | ephLen | eph | cekNonce | wrappedLen | wrapped |
|
|
118
|
+
* bodyNonce | ciphertext`
|
|
119
|
+
*
|
|
120
|
+
* Every read is bounds-checked, so a truncated blob is a clear parse failure
|
|
121
|
+
* rather than an out-of-range surprise later.
|
|
122
|
+
*/
|
|
123
|
+
declare function parseSealed(raw: Uint8Array): SealedEnvelope;
|
|
124
|
+
/** Decrypt a sealed envelope with the payer's private key. */
|
|
125
|
+
declare function unseal(sealed: SealedEnvelope, privateKey: Uint8Array, aad: Uint8Array): Uint8Array;
|
|
126
|
+
/**
|
|
127
|
+
* Fetch, decrypt and verify the body behind `evidence`.
|
|
128
|
+
*
|
|
129
|
+
* `privateKey` is the raw key of the wallet that paid: 32 bytes for both an EVM
|
|
130
|
+
* secp256k1 key and an ed25519 seed. Hex accepted with or without `0x`.
|
|
131
|
+
*
|
|
132
|
+
* In `direct` mode this needs no permission from anyone — the ciphertext was
|
|
133
|
+
* sealed to the public key of the wallet that paid, so retrieval is arithmetic
|
|
134
|
+
* rather than an access-control decision that could be refused or misconfigured.
|
|
135
|
+
*
|
|
136
|
+
* The `contentHash` check is **not optional**: it is what catches a seller that
|
|
137
|
+
* anchored something other than what it served.
|
|
138
|
+
*/
|
|
139
|
+
declare function recoverEvidence(evidence: AnchoredEvidence, privateKey: Uint8Array | string, options?: {
|
|
140
|
+
fetch?: typeof fetch;
|
|
141
|
+
}): Promise<Uint8Array>;
|
|
142
|
+
/**
|
|
143
|
+
* Map an ed25519 public key to its X25519 form.
|
|
144
|
+
*
|
|
145
|
+
* On ed25519 chains (Solana, NEAR, Stellar, Algorand) the address **is** the
|
|
146
|
+
* public key, so this is all that stands between an address and an encryption
|
|
147
|
+
* target — no signature, no lookup.
|
|
148
|
+
*/
|
|
149
|
+
declare function ed25519ToX25519(pubkey: Uint8Array): Uint8Array;
|
|
150
|
+
/**
|
|
151
|
+
* Recover an EVM payer's secp256k1 public key from their payment signature.
|
|
152
|
+
*
|
|
153
|
+
* `digest` is the EIP-712 digest the payer actually signed. Getting it wrong
|
|
154
|
+
* does not throw: it recovers a *different, perfectly valid* key, and the body
|
|
155
|
+
* would be sealed to a stranger while every log line said success. The token's
|
|
156
|
+
* EIP-712 domain name varies per chain and even flips between a chain's mainnet
|
|
157
|
+
* and testnet, so derive it from the same table the facilitator uses.
|
|
158
|
+
*
|
|
159
|
+
* Returns the SEC1-compressed key (33 bytes).
|
|
160
|
+
*/
|
|
161
|
+
declare function payerKeyFromEvmSignature(signature: Uint8Array | string, digest: Uint8Array): Uint8Array;
|
|
162
|
+
/**
|
|
163
|
+
* Seal `body` so that only the holder of the payer's private key can read it.
|
|
164
|
+
*
|
|
165
|
+
* `payerKey` is a 33-byte SEC1-compressed secp256k1 key (EVM, XRPL) or a 32-byte
|
|
166
|
+
* X25519 key from {@link ed25519ToX25519}.
|
|
167
|
+
*
|
|
168
|
+
* `paymentIdValue` is bound in as AEAD associated data, which is what stops a
|
|
169
|
+
* ciphertext from being replayed as the evidence for a different payment.
|
|
170
|
+
* Derive it with {@link paymentId} on both sides — deriving it differently makes
|
|
171
|
+
* decryption fail with no obvious cause.
|
|
172
|
+
*
|
|
173
|
+
* Returns the bytes to upload. Nothing here touches the network.
|
|
174
|
+
*/
|
|
175
|
+
declare function sealEvidence(body: Uint8Array, payerKey: Uint8Array, paymentIdValue: string): Uint8Array;
|
|
176
|
+
|
|
9
177
|
/**
|
|
10
178
|
* Facilitator wallet addresses by chain type
|
|
11
179
|
*
|
|
@@ -653,4 +821,4 @@ interface EscrowPreAuthParams {
|
|
|
653
821
|
*/
|
|
654
822
|
declare function buildEscrowPreAuth(wallet: EscrowPreAuthSigner, params: EscrowPreAuthParams): Promise<string>;
|
|
655
823
|
|
|
656
|
-
export { type CreateSignedFetchConfig, type ERC8128RequestOptions, ESCROW_DEPOSIT_LIMIT_USD, ESCROW_TIER_WINDOWS, EVENT_KINDS, type EscrowNetworkConfig, type EscrowPaymentInfo, type EscrowPreAuthParams, type EscrowPreAuthSigner, type EscrowTierWindows, FACILITATOR_ADDRESSES, type FacilitatorAddresses, KEEPALIVE_INTERVAL_MS, OPERATOR_FEE_BPS, type SSEFrame, SSEParser, type SignRequestOptions, type SignRequestWithSignerOptions, type SignatureBaseParams, type SignatureHeaders, type SignatureParamsInput, SigningWalletAdapter, type StreamTrafficEventsOptions, type TrafficEvent, type TrafficEventKind, TrafficStreamError, buildEscrowPreAuth, buildSignatureBase, buildSignatureParams, computeEscrowNonce, createSignedFetch, fetchNonce, getFacilitatorAddress, matchesFilters, parseTrafficEvent, signRequest, signRequestWithSigner, signRequestWithWallet, streamTrafficEvents };
|
|
824
|
+
export { type AnchoredEvidence, ContentHashMismatch, type CreateSignedFetchConfig, DX402Error, type ERC8128RequestOptions, ESCROW_DEPOSIT_LIMIT_USD, ESCROW_TIER_WINDOWS, EVENT_KINDS, EVIDENCE_HEADER, type EscrowNetworkConfig, type EscrowPaymentInfo, type EscrowPreAuthParams, type EscrowPreAuthSigner, type EscrowTierWindows, type EvidenceMode, EvidenceSkipped, FACILITATOR_ADDRESSES, type FacilitatorAddresses, KEEPALIVE_INTERVAL_MS, OPERATOR_FEE_BPS, type SSEFrame, SSEParser, type SignRequestOptions, type SignRequestWithSignerOptions, type SignatureBaseParams, type SignatureHeaders, type SignatureParamsInput, SigningWalletAdapter, type StreamTrafficEventsOptions, type TrafficEvent, type TrafficEventKind, TrafficStreamError, buildEscrowPreAuth, buildSignatureBase, buildSignatureParams, computeEscrowNonce, contentHash, createSignedFetch, dereferencePointer, paymentId as dx402PaymentId, ed25519ToX25519, evidenceFromHeaders, fetchNonce, getFacilitatorAddress, isEndToEnd, matchesFilters, parseEvidenceHeader, parseSealed, parseTrafficEvent, payerKeyFromEvmSignature, recoverEvidence, sealEvidence, signRequest, signRequestWithSigner, signRequestWithWallet, streamTrafficEvents, unseal };
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,174 @@ export { a as EIP3009Authorization, E as EIP3009Params } from './wallet-w7BnImDG
|
|
|
6
6
|
export { E as EnvKeyAdapter, O as OWSWallet, a as OWSWalletAdapter } from './ows-C-KmORG9.js';
|
|
7
7
|
export { FacilitatorClient, FacilitatorClientOptions, HonoMiddlewareOptions, PaymentAcceptance, PaymentMiddlewareOptions, PaymentPayloadV2, PaymentRequirementsV2, ResourceInfoV2, SettleRequestV2, VerifiedPaymentState, VerifyRequestV2, X402_CORS_HEADERS, X402_HEADER_NAMES, buildPaymentRequirements, buildSettleRequest, buildSettleRequestV2, buildVerifyRequest, buildVerifyRequestV2, create402Response, createHonoMiddleware, createPaymentMiddleware, extractPaymentFromHeaders, getCorsHeaders } from './backend/index.js';
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* DX402 `durable-evidence`: recover a paid response after the fact.
|
|
11
|
+
*
|
|
12
|
+
* x402 settles payment on-chain permanently but delivers the purchased resource
|
|
13
|
+
* **exactly once**, in the body of a `200 OK`, and keeps nothing. A buyer who did
|
|
14
|
+
* not capture it at that instant cannot recover it, and neither party can later
|
|
15
|
+
* prove *what* was delivered — only *that* payment happened.
|
|
16
|
+
*
|
|
17
|
+
* DX402 closes that gap. The seller seals a copy of the response to the payer's
|
|
18
|
+
* own public key — recovered from the payment signature itself — and anchors it.
|
|
19
|
+
* The buyer gets an `X-Durable-Evidence` header pointing at it.
|
|
20
|
+
*
|
|
21
|
+
* **Paying is publishing your encryption key.** No registration, no key
|
|
22
|
+
* exchange, no extra round trip.
|
|
23
|
+
*
|
|
24
|
+
* ```ts
|
|
25
|
+
* const evidence = evidenceFromHeaders(response.headers);
|
|
26
|
+
* const body = await recoverEvidence(evidence, myPrivateKey);
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* Specification: `docs/plans/dx402/02-SPEC-v0.1.md` in x402-rs.
|
|
30
|
+
*/
|
|
31
|
+
declare const EVIDENCE_HEADER = "X-Durable-Evidence";
|
|
32
|
+
declare class DX402Error extends Error {
|
|
33
|
+
constructor(message: string);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* No evidence was anchored for this payment.
|
|
37
|
+
*
|
|
38
|
+
* A normal outcome, not a fault: the body may have exceeded the seller's size
|
|
39
|
+
* cap, the store may have been unreachable, or the payer may be a
|
|
40
|
+
* smart-contract wallet with no recoverable key.
|
|
41
|
+
*/
|
|
42
|
+
declare class EvidenceSkipped extends DX402Error {
|
|
43
|
+
readonly reason: string;
|
|
44
|
+
constructor(reason: string);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The anchored bytes are not the bytes that were delivered.
|
|
48
|
+
*
|
|
49
|
+
* This is the interesting failure: the seller anchored something other than
|
|
50
|
+
* what it served, which is precisely the fraud `contentHash` exists to expose.
|
|
51
|
+
* Treat it as evidence of misbehaviour, not a transport glitch.
|
|
52
|
+
*/
|
|
53
|
+
declare class ContentHashMismatch extends DX402Error {
|
|
54
|
+
readonly anchored: string;
|
|
55
|
+
readonly actual: string;
|
|
56
|
+
constructor(anchored: string, actual: string);
|
|
57
|
+
}
|
|
58
|
+
type EvidenceMode = 'direct' | 'escrowed';
|
|
59
|
+
interface AnchoredEvidence {
|
|
60
|
+
v: number;
|
|
61
|
+
paymentId: string;
|
|
62
|
+
pointer: string;
|
|
63
|
+
backend: string;
|
|
64
|
+
contentHash: string;
|
|
65
|
+
cipher: string;
|
|
66
|
+
keyAlg: 'ECIES-secp256k1' | 'ECIES-X25519';
|
|
67
|
+
mode: EvidenceMode;
|
|
68
|
+
retention: string;
|
|
69
|
+
receipt?: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Whether the facilitator is cryptographically unable to read this payload.
|
|
73
|
+
*
|
|
74
|
+
* `direct` and `escrowed` make materially different claims about who can open
|
|
75
|
+
* the payload, so a caller that cares about confidentiality must check rather
|
|
76
|
+
* than assume.
|
|
77
|
+
*/
|
|
78
|
+
declare function isEndToEnd(evidence: AnchoredEvidence): boolean;
|
|
79
|
+
/** keccak256 of a body, `0x`-prefixed — matching the facilitator's `contentHash`. */
|
|
80
|
+
declare function contentHash(body: Uint8Array): string;
|
|
81
|
+
/**
|
|
82
|
+
* Derive the canonical payment identifier: `keccak256(caip2Network || txHash)`.
|
|
83
|
+
*
|
|
84
|
+
* This value is the AEAD associated data binding a ciphertext to its payment.
|
|
85
|
+
* Buyer and seller must derive it identically or decryption fails with no
|
|
86
|
+
* obvious cause, which is why it lives in the SDK rather than in each caller.
|
|
87
|
+
*/
|
|
88
|
+
declare function paymentId(caip2Network: string, txHash: string): string;
|
|
89
|
+
/** Parse an `X-Durable-Evidence` header value. */
|
|
90
|
+
declare function parseEvidenceHeader(value: string): AnchoredEvidence;
|
|
91
|
+
/**
|
|
92
|
+
* Pull the anchored evidence out of a response's headers.
|
|
93
|
+
*
|
|
94
|
+
* Accepts a `Headers` object or a plain record. Lookup is case-insensitive,
|
|
95
|
+
* because HTTP does not care and different clients disagree about casing.
|
|
96
|
+
*/
|
|
97
|
+
declare function evidenceFromHeaders(headers: Headers | Record<string, string>): AnchoredEvidence;
|
|
98
|
+
/**
|
|
99
|
+
* Turn a DX402 pointer into a fetchable URL.
|
|
100
|
+
*
|
|
101
|
+
* `s3+https://...` is a scheme tag over an ordinary HTTPS URL; `ipfs://` and
|
|
102
|
+
* `ar://` go through public gateways. Anything else passes through untouched, so
|
|
103
|
+
* a caller with their own resolver is not blocked by this function.
|
|
104
|
+
*/
|
|
105
|
+
declare function dereferencePointer(pointer: string): string;
|
|
106
|
+
interface SealedEnvelope {
|
|
107
|
+
alg: 'secp256k1' | 'x25519';
|
|
108
|
+
ephemeral: Uint8Array;
|
|
109
|
+
cekNonce: Uint8Array;
|
|
110
|
+
wrappedCek: Uint8Array;
|
|
111
|
+
bodyNonce: Uint8Array;
|
|
112
|
+
ciphertext: Uint8Array;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Parse the sealed-blob layout.
|
|
116
|
+
*
|
|
117
|
+
* `MAGIC | version | alg | ephLen | eph | cekNonce | wrappedLen | wrapped |
|
|
118
|
+
* bodyNonce | ciphertext`
|
|
119
|
+
*
|
|
120
|
+
* Every read is bounds-checked, so a truncated blob is a clear parse failure
|
|
121
|
+
* rather than an out-of-range surprise later.
|
|
122
|
+
*/
|
|
123
|
+
declare function parseSealed(raw: Uint8Array): SealedEnvelope;
|
|
124
|
+
/** Decrypt a sealed envelope with the payer's private key. */
|
|
125
|
+
declare function unseal(sealed: SealedEnvelope, privateKey: Uint8Array, aad: Uint8Array): Uint8Array;
|
|
126
|
+
/**
|
|
127
|
+
* Fetch, decrypt and verify the body behind `evidence`.
|
|
128
|
+
*
|
|
129
|
+
* `privateKey` is the raw key of the wallet that paid: 32 bytes for both an EVM
|
|
130
|
+
* secp256k1 key and an ed25519 seed. Hex accepted with or without `0x`.
|
|
131
|
+
*
|
|
132
|
+
* In `direct` mode this needs no permission from anyone — the ciphertext was
|
|
133
|
+
* sealed to the public key of the wallet that paid, so retrieval is arithmetic
|
|
134
|
+
* rather than an access-control decision that could be refused or misconfigured.
|
|
135
|
+
*
|
|
136
|
+
* The `contentHash` check is **not optional**: it is what catches a seller that
|
|
137
|
+
* anchored something other than what it served.
|
|
138
|
+
*/
|
|
139
|
+
declare function recoverEvidence(evidence: AnchoredEvidence, privateKey: Uint8Array | string, options?: {
|
|
140
|
+
fetch?: typeof fetch;
|
|
141
|
+
}): Promise<Uint8Array>;
|
|
142
|
+
/**
|
|
143
|
+
* Map an ed25519 public key to its X25519 form.
|
|
144
|
+
*
|
|
145
|
+
* On ed25519 chains (Solana, NEAR, Stellar, Algorand) the address **is** the
|
|
146
|
+
* public key, so this is all that stands between an address and an encryption
|
|
147
|
+
* target — no signature, no lookup.
|
|
148
|
+
*/
|
|
149
|
+
declare function ed25519ToX25519(pubkey: Uint8Array): Uint8Array;
|
|
150
|
+
/**
|
|
151
|
+
* Recover an EVM payer's secp256k1 public key from their payment signature.
|
|
152
|
+
*
|
|
153
|
+
* `digest` is the EIP-712 digest the payer actually signed. Getting it wrong
|
|
154
|
+
* does not throw: it recovers a *different, perfectly valid* key, and the body
|
|
155
|
+
* would be sealed to a stranger while every log line said success. The token's
|
|
156
|
+
* EIP-712 domain name varies per chain and even flips between a chain's mainnet
|
|
157
|
+
* and testnet, so derive it from the same table the facilitator uses.
|
|
158
|
+
*
|
|
159
|
+
* Returns the SEC1-compressed key (33 bytes).
|
|
160
|
+
*/
|
|
161
|
+
declare function payerKeyFromEvmSignature(signature: Uint8Array | string, digest: Uint8Array): Uint8Array;
|
|
162
|
+
/**
|
|
163
|
+
* Seal `body` so that only the holder of the payer's private key can read it.
|
|
164
|
+
*
|
|
165
|
+
* `payerKey` is a 33-byte SEC1-compressed secp256k1 key (EVM, XRPL) or a 32-byte
|
|
166
|
+
* X25519 key from {@link ed25519ToX25519}.
|
|
167
|
+
*
|
|
168
|
+
* `paymentIdValue` is bound in as AEAD associated data, which is what stops a
|
|
169
|
+
* ciphertext from being replayed as the evidence for a different payment.
|
|
170
|
+
* Derive it with {@link paymentId} on both sides — deriving it differently makes
|
|
171
|
+
* decryption fail with no obvious cause.
|
|
172
|
+
*
|
|
173
|
+
* Returns the bytes to upload. Nothing here touches the network.
|
|
174
|
+
*/
|
|
175
|
+
declare function sealEvidence(body: Uint8Array, payerKey: Uint8Array, paymentIdValue: string): Uint8Array;
|
|
176
|
+
|
|
9
177
|
/**
|
|
10
178
|
* Facilitator wallet addresses by chain type
|
|
11
179
|
*
|
|
@@ -653,4 +821,4 @@ interface EscrowPreAuthParams {
|
|
|
653
821
|
*/
|
|
654
822
|
declare function buildEscrowPreAuth(wallet: EscrowPreAuthSigner, params: EscrowPreAuthParams): Promise<string>;
|
|
655
823
|
|
|
656
|
-
export { type CreateSignedFetchConfig, type ERC8128RequestOptions, ESCROW_DEPOSIT_LIMIT_USD, ESCROW_TIER_WINDOWS, EVENT_KINDS, type EscrowNetworkConfig, type EscrowPaymentInfo, type EscrowPreAuthParams, type EscrowPreAuthSigner, type EscrowTierWindows, FACILITATOR_ADDRESSES, type FacilitatorAddresses, KEEPALIVE_INTERVAL_MS, OPERATOR_FEE_BPS, type SSEFrame, SSEParser, type SignRequestOptions, type SignRequestWithSignerOptions, type SignatureBaseParams, type SignatureHeaders, type SignatureParamsInput, SigningWalletAdapter, type StreamTrafficEventsOptions, type TrafficEvent, type TrafficEventKind, TrafficStreamError, buildEscrowPreAuth, buildSignatureBase, buildSignatureParams, computeEscrowNonce, createSignedFetch, fetchNonce, getFacilitatorAddress, matchesFilters, parseTrafficEvent, signRequest, signRequestWithSigner, signRequestWithWallet, streamTrafficEvents };
|
|
824
|
+
export { type AnchoredEvidence, ContentHashMismatch, type CreateSignedFetchConfig, DX402Error, type ERC8128RequestOptions, ESCROW_DEPOSIT_LIMIT_USD, ESCROW_TIER_WINDOWS, EVENT_KINDS, EVIDENCE_HEADER, type EscrowNetworkConfig, type EscrowPaymentInfo, type EscrowPreAuthParams, type EscrowPreAuthSigner, type EscrowTierWindows, type EvidenceMode, EvidenceSkipped, FACILITATOR_ADDRESSES, type FacilitatorAddresses, KEEPALIVE_INTERVAL_MS, OPERATOR_FEE_BPS, type SSEFrame, SSEParser, type SignRequestOptions, type SignRequestWithSignerOptions, type SignatureBaseParams, type SignatureHeaders, type SignatureParamsInput, SigningWalletAdapter, type StreamTrafficEventsOptions, type TrafficEvent, type TrafficEventKind, TrafficStreamError, buildEscrowPreAuth, buildSignatureBase, buildSignatureParams, computeEscrowNonce, contentHash, createSignedFetch, dereferencePointer, paymentId as dx402PaymentId, ed25519ToX25519, evidenceFromHeaders, fetchNonce, getFacilitatorAddress, isEndToEnd, matchesFilters, parseEvidenceHeader, parseSealed, parseTrafficEvent, payerKeyFromEvmSignature, recoverEvidence, sealEvidence, signRequest, signRequestWithSigner, signRequestWithWallet, streamTrafficEvents, unseal };
|