uvd-x402-sdk 2.77.0 → 2.78.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/backend/index.d.mts +85 -2
- package/dist/backend/index.d.ts +85 -2
- package/dist/backend/index.js +65 -2
- package/dist/backend/index.js.map +1 -1
- package/dist/backend/index.mjs +61 -3
- package/dist/backend/index.mjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +65 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +61 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/backend/index.ts +187 -2
- package/src/index.ts +7 -0
package/dist/index.d.mts
CHANGED
|
@@ -4,7 +4,7 @@ export { A as AlgorandPaymentPayload, C as CAIP2_IDENTIFIERS, a as CAIP2_TO_CHAI
|
|
|
4
4
|
import { S as SigningWalletAdapter } from './wallet-0cX9Pw2F.mjs';
|
|
5
5
|
export { E as EIP3009Authorization, a as EIP3009Params } from './wallet-0cX9Pw2F.mjs';
|
|
6
6
|
export { E as EnvKeyAdapter, O as OWSWallet, a as OWSWalletAdapter } from './ows-CYIVd4xO.mjs';
|
|
7
|
-
export { AMBIGUOUS_LEASE_REASONS, DEFAULT_FACILITATOR_RETRIES, DEFAULT_RETRY_AFTER_SECONDS, FacilitatorClient, FacilitatorClientOptions, FacilitatorErrorInfo, FacilitatorFailureFields, FacilitatorFetchOptions, HonoMiddlewareOptions, MAX_RETRY_AFTER_SECONDS, PaymentAcceptance, PaymentMiddlewareOptions, PaymentPayloadV2, PaymentRequirementsV2, REPLAYABLE_LEASE_REASONS, ResourceInfoV2, SettleRequestV2, VerifiedPaymentState, VerifyRequestV2, WRITER_LEASE_REASONS, WriterLeaseReason, X402_CORS_HEADERS, X402_HEADER_NAMES, buildPaymentRequirements, buildSettleRequest, buildSettleRequestV2, buildVerifyRequest, buildVerifyRequestV2, create402Response, createHonoMiddleware, createPaymentMiddleware, extractPaymentFromHeaders, facilitatorFetch, getCorsHeaders, isAmbiguousLeaseReason, isReplayableLeaseReason, parseRetryAfterSeconds, readFacilitatorError } from './backend/index.mjs';
|
|
7
|
+
export { AMBIGUOUS_LEASE_REASONS, DEFAULT_FACILITATOR_RETRIES, DEFAULT_RETRY_AFTER_SECONDS, FacilitatorClient, FacilitatorClientOptions, FacilitatorErrorInfo, FacilitatorFailureFields, FacilitatorFetchOptions, HonoMiddlewareOptions, MAX_RETRY_AFTER_SECONDS, PaymentAcceptance, PaymentMiddlewareOptions, PaymentPayloadV2, PaymentRequirementsV2, REPLAYABLE_LEASE_REASONS, ResourceInfoV2, SettleRequestV2, VerifiedPaymentState, VerifyRequestV2, WRITER_LEASE_REASONS, WriterLeaseReason, X402_CORS_HEADERS, X402_HEADER_NAMES, buildPaymentRequirements, buildSettleRequest, buildSettleRequestForVersion, buildSettleRequestV2, buildVerifyRequest, buildVerifyRequestForVersion, buildVerifyRequestV2, create402Response, createHonoMiddleware, createPaymentMiddleware, extractPaymentFromHeaders, facilitatorFetch, getCorsHeaders, isAmbiguousLeaseReason, isReplayableLeaseReason, parseRetryAfterSeconds, readFacilitatorError, resolveEnvelopeVersion, toPaymentRequirementsV2, toResourceInfoV2 } from './backend/index.mjs';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* DX402 `durable-evidence`: recover a paid response after the fact.
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { A as AlgorandPaymentPayload, C as CAIP2_IDENTIFIERS, a as CAIP2_TO_CHAI
|
|
|
4
4
|
import { S as SigningWalletAdapter } from './wallet-0cX9Pw2F.js';
|
|
5
5
|
export { E as EIP3009Authorization, a as EIP3009Params } from './wallet-0cX9Pw2F.js';
|
|
6
6
|
export { E as EnvKeyAdapter, O as OWSWallet, a as OWSWalletAdapter } from './ows-DTDixPzO.js';
|
|
7
|
-
export { AMBIGUOUS_LEASE_REASONS, DEFAULT_FACILITATOR_RETRIES, DEFAULT_RETRY_AFTER_SECONDS, FacilitatorClient, FacilitatorClientOptions, FacilitatorErrorInfo, FacilitatorFailureFields, FacilitatorFetchOptions, HonoMiddlewareOptions, MAX_RETRY_AFTER_SECONDS, PaymentAcceptance, PaymentMiddlewareOptions, PaymentPayloadV2, PaymentRequirementsV2, REPLAYABLE_LEASE_REASONS, ResourceInfoV2, SettleRequestV2, VerifiedPaymentState, VerifyRequestV2, WRITER_LEASE_REASONS, WriterLeaseReason, X402_CORS_HEADERS, X402_HEADER_NAMES, buildPaymentRequirements, buildSettleRequest, buildSettleRequestV2, buildVerifyRequest, buildVerifyRequestV2, create402Response, createHonoMiddleware, createPaymentMiddleware, extractPaymentFromHeaders, facilitatorFetch, getCorsHeaders, isAmbiguousLeaseReason, isReplayableLeaseReason, parseRetryAfterSeconds, readFacilitatorError } from './backend/index.js';
|
|
7
|
+
export { AMBIGUOUS_LEASE_REASONS, DEFAULT_FACILITATOR_RETRIES, DEFAULT_RETRY_AFTER_SECONDS, FacilitatorClient, FacilitatorClientOptions, FacilitatorErrorInfo, FacilitatorFailureFields, FacilitatorFetchOptions, HonoMiddlewareOptions, MAX_RETRY_AFTER_SECONDS, PaymentAcceptance, PaymentMiddlewareOptions, PaymentPayloadV2, PaymentRequirementsV2, REPLAYABLE_LEASE_REASONS, ResourceInfoV2, SettleRequestV2, VerifiedPaymentState, VerifyRequestV2, WRITER_LEASE_REASONS, WriterLeaseReason, X402_CORS_HEADERS, X402_HEADER_NAMES, buildPaymentRequirements, buildSettleRequest, buildSettleRequestForVersion, buildSettleRequestV2, buildVerifyRequest, buildVerifyRequestForVersion, buildVerifyRequestV2, create402Response, createHonoMiddleware, createPaymentMiddleware, extractPaymentFromHeaders, facilitatorFetch, getCorsHeaders, isAmbiguousLeaseReason, isReplayableLeaseReason, parseRetryAfterSeconds, readFacilitatorError, resolveEnvelopeVersion, toPaymentRequirementsV2, toResourceInfoV2 } from './backend/index.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* DX402 `durable-evidence`: recover a paid response after the fact.
|
package/dist/index.js
CHANGED
|
@@ -3945,6 +3945,54 @@ function buildSettleRequest(paymentHeader, requirements) {
|
|
|
3945
3945
|
paymentRequirements: requirements
|
|
3946
3946
|
};
|
|
3947
3947
|
}
|
|
3948
|
+
function isCaip2Network(network) {
|
|
3949
|
+
return network.includes(":");
|
|
3950
|
+
}
|
|
3951
|
+
function toResourceInfoV2(requirements) {
|
|
3952
|
+
return {
|
|
3953
|
+
url: requirements.resource,
|
|
3954
|
+
description: requirements.description ?? DEFAULT_PAYMENT_DESCRIPTION,
|
|
3955
|
+
mimeType: requirements.mimeType ?? DEFAULT_PAYMENT_MIME_TYPE
|
|
3956
|
+
};
|
|
3957
|
+
}
|
|
3958
|
+
function toPaymentRequirementsV2(requirements) {
|
|
3959
|
+
return {
|
|
3960
|
+
scheme: requirements.scheme,
|
|
3961
|
+
network: isCaip2Network(requirements.network) ? requirements.network : chainToCAIP2(requirements.network),
|
|
3962
|
+
asset: requirements.asset,
|
|
3963
|
+
amount: requirements.maxAmountRequired,
|
|
3964
|
+
payTo: requirements.payTo,
|
|
3965
|
+
// Required by the facilitator: omitting it is a 400, measured the same day.
|
|
3966
|
+
maxTimeoutSeconds: requirements.maxTimeoutSeconds ?? DEFAULT_PAYMENT_TIMEOUT_SECONDS,
|
|
3967
|
+
...requirements.extra !== void 0 ? { extra: requirements.extra } : {}
|
|
3968
|
+
};
|
|
3969
|
+
}
|
|
3970
|
+
function resolveEnvelopeVersion(paymentHeader, requirements, requested = "auto") {
|
|
3971
|
+
if (requested !== "auto") {
|
|
3972
|
+
return requested;
|
|
3973
|
+
}
|
|
3974
|
+
return isCaip2Network(paymentHeader.network) || isCaip2Network(requirements.network) ? 2 : 1;
|
|
3975
|
+
}
|
|
3976
|
+
function buildVerifyRequestForVersion(paymentHeader, requirements, version) {
|
|
3977
|
+
if (version === 2) {
|
|
3978
|
+
return buildVerifyRequestV2(
|
|
3979
|
+
paymentHeader.payload,
|
|
3980
|
+
toResourceInfoV2(requirements),
|
|
3981
|
+
toPaymentRequirementsV2(requirements)
|
|
3982
|
+
);
|
|
3983
|
+
}
|
|
3984
|
+
return buildVerifyRequest(paymentHeader, requirements);
|
|
3985
|
+
}
|
|
3986
|
+
function buildSettleRequestForVersion(paymentHeader, requirements, version) {
|
|
3987
|
+
if (version === 2) {
|
|
3988
|
+
return buildSettleRequestV2(
|
|
3989
|
+
paymentHeader.payload,
|
|
3990
|
+
toResourceInfoV2(requirements),
|
|
3991
|
+
toPaymentRequirementsV2(requirements)
|
|
3992
|
+
);
|
|
3993
|
+
}
|
|
3994
|
+
return buildSettleRequest(paymentHeader, requirements);
|
|
3995
|
+
}
|
|
3948
3996
|
var X402_CORS_HEADERS = {
|
|
3949
3997
|
"Access-Control-Allow-Headers": "Content-Type, X-PAYMENT, PAYMENT-SIGNATURE, Authorization",
|
|
3950
3998
|
"Access-Control-Expose-Headers": "X-PAYMENT-RESPONSE, PAYMENT-RESPONSE, PAYMENT-REQUIRED",
|
|
@@ -3968,11 +4016,13 @@ var FacilitatorClient = class {
|
|
|
3968
4016
|
timeout;
|
|
3969
4017
|
explicitTimeout;
|
|
3970
4018
|
retries;
|
|
4019
|
+
x402Version;
|
|
3971
4020
|
constructor(options = {}) {
|
|
3972
4021
|
this.baseUrl = options.baseUrl || "https://facilitator.ultravioletadao.xyz";
|
|
3973
4022
|
this.explicitTimeout = options.timeout !== void 0;
|
|
3974
4023
|
this.timeout = options.timeout || 3e4;
|
|
3975
4024
|
this.retries = options.retries;
|
|
4025
|
+
this.x402Version = options.x402Version ?? "auto";
|
|
3976
4026
|
}
|
|
3977
4027
|
/**
|
|
3978
4028
|
* Get timeout for a specific network, using per-chain defaults when no explicit timeout was set.
|
|
@@ -3998,7 +4048,11 @@ var FacilitatorClient = class {
|
|
|
3998
4048
|
* @returns Verification result
|
|
3999
4049
|
*/
|
|
4000
4050
|
async verify(paymentHeader, requirements) {
|
|
4001
|
-
const body =
|
|
4051
|
+
const body = buildVerifyRequestForVersion(
|
|
4052
|
+
paymentHeader,
|
|
4053
|
+
requirements,
|
|
4054
|
+
resolveEnvelopeVersion(paymentHeader, requirements, this.x402Version)
|
|
4055
|
+
);
|
|
4002
4056
|
try {
|
|
4003
4057
|
const { response, error } = await facilitatorFetch(
|
|
4004
4058
|
`${this.baseUrl}/verify`,
|
|
@@ -4037,7 +4091,11 @@ var FacilitatorClient = class {
|
|
|
4037
4091
|
* @returns Settlement result with transaction hash
|
|
4038
4092
|
*/
|
|
4039
4093
|
async settle(paymentHeader, requirements) {
|
|
4040
|
-
const body =
|
|
4094
|
+
const body = buildSettleRequestForVersion(
|
|
4095
|
+
paymentHeader,
|
|
4096
|
+
requirements,
|
|
4097
|
+
resolveEnvelopeVersion(paymentHeader, requirements, this.x402Version)
|
|
4098
|
+
);
|
|
4041
4099
|
const settleTimeout = this.getTimeout(requirements.network);
|
|
4042
4100
|
try {
|
|
4043
4101
|
const { response, error } = await facilitatorFetch(
|
|
@@ -4745,11 +4803,13 @@ exports.availableBackends = availableBackends;
|
|
|
4745
4803
|
exports.buildEscrowPreAuth = buildEscrowPreAuth;
|
|
4746
4804
|
exports.buildPaymentRequirements = buildPaymentRequirements;
|
|
4747
4805
|
exports.buildSettleRequest = buildSettleRequest;
|
|
4806
|
+
exports.buildSettleRequestForVersion = buildSettleRequestForVersion;
|
|
4748
4807
|
exports.buildSettleRequestV2 = buildSettleRequestV2;
|
|
4749
4808
|
exports.buildSignatureBase = buildSignatureBase;
|
|
4750
4809
|
exports.buildSignatureParams = buildSignatureParams;
|
|
4751
4810
|
exports.buildTokenMetadata = buildTokenMetadata;
|
|
4752
4811
|
exports.buildVerifyRequest = buildVerifyRequest;
|
|
4812
|
+
exports.buildVerifyRequestForVersion = buildVerifyRequestForVersion;
|
|
4753
4813
|
exports.buildVerifyRequestV2 = buildVerifyRequestV2;
|
|
4754
4814
|
exports.caip2ToChain = caip2ToChain;
|
|
4755
4815
|
exports.chainToCAIP2 = chainToCAIP2;
|
|
@@ -4824,6 +4884,7 @@ exports.readFacilitatorError = readFacilitatorError;
|
|
|
4824
4884
|
exports.recoverEvidence = recoverEvidence;
|
|
4825
4885
|
exports.replaySafeTypedData = replaySafeTypedData;
|
|
4826
4886
|
exports.resolveDelegation = resolveDelegation;
|
|
4887
|
+
exports.resolveEnvelopeVersion = resolveEnvelopeVersion;
|
|
4827
4888
|
exports.rpcDelegationResolver = rpcDelegationResolver;
|
|
4828
4889
|
exports.sealEvidence = sealEvidence;
|
|
4829
4890
|
exports.sealEvidenceTo = sealEvidenceTo;
|
|
@@ -4835,6 +4896,8 @@ exports.signRequest = signRequest;
|
|
|
4835
4896
|
exports.signRequestWithSigner = signRequestWithSigner;
|
|
4836
4897
|
exports.signRequestWithWallet = signRequestWithWallet;
|
|
4837
4898
|
exports.streamTrafficEvents = streamTrafficEvents;
|
|
4899
|
+
exports.toPaymentRequirementsV2 = toPaymentRequirementsV2;
|
|
4900
|
+
exports.toResourceInfoV2 = toResourceInfoV2;
|
|
4838
4901
|
exports.unseal = unseal;
|
|
4839
4902
|
exports.validateAmount = validateAmount;
|
|
4840
4903
|
exports.validateRecipient = validateRecipient;
|