uvd-x402-sdk 2.104.2 → 2.104.3
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/adapters/index.d.mts +1 -1
- package/dist/adapters/index.d.ts +1 -1
- package/dist/adapters/index.js +135 -5
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/index.mjs +135 -5
- package/dist/adapters/index.mjs.map +1 -1
- package/dist/backend/index.js.map +1 -1
- 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 +135 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +135 -5
- package/dist/index.mjs.map +1 -1
- package/dist/{ows-BB6Sgj0W.d.ts → ows-CW-g7qGw.d.ts} +9 -2
- package/dist/{ows-DazT4KQH.d.mts → ows-DJu424iz.d.mts} +9 -2
- package/dist/providers/evm/index.js.map +1 -1
- package/dist/providers/evm/index.mjs.map +1 -1
- package/dist/providers/stellar/index.js.map +1 -1
- package/dist/providers/stellar/index.mjs.map +1 -1
- package/dist/providers/sui/index.js.map +1 -1
- package/dist/providers/sui/index.mjs.map +1 -1
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/adapters/env-key.ts +9 -2
- package/src/adapters/ows.ts +12 -3
- package/src/utils/uint.ts +211 -3
package/dist/index.d.mts
CHANGED
|
@@ -4,7 +4,7 @@ export { A as AdvertisedQuote, j as AlgorandPaymentPayload, k as CAIP2_IDENTIFIE
|
|
|
4
4
|
export { D as DEFAULT_PAYMENT_HEADER, a as DEFAULT_VALIDITY_SECONDS, M as MAX_VALIDITY_SECONDS, P as PAYMENT_HEADER_NAMES, b as buildTokenMetadata, c as caip2ToChain, d as chainToCAIP2, e as clampValiditySeconds, f as convertX402Header, g as createPaymentHeaders, h as createX402Header, i as createX402V1Header, j as createX402V2Header, k as decodeBase64Utf8, l as decodeX402Header, m as detectX402Version, n as encodeBase64Json, o as encodeBase64Utf8, p as encodeX402Header, q as generatePaymentOptions, r as getPaymentHeader, s as isCAIP2Format, t as parseNetworkIdentifier, u as paymentChallengeFrom, v as resolveValiditySeconds, w as validateAmount, x as validateRecipient } from './validity-y_M1oNCt.mjs';
|
|
5
5
|
import { S as SigningWalletAdapter } from './wallet-T0NFUUkT.mjs';
|
|
6
6
|
export { a as EIP3009Authorization, E as EIP3009Params } from './wallet-T0NFUUkT.mjs';
|
|
7
|
-
export { E as EnvKeyAdapter, O as OWSAccountInfo, a as OWSCore, b as OWSSignResult, c as OWSWallet, d as OWSWalletAdapter, e as OWSWalletAdapterOptions } from './ows-
|
|
7
|
+
export { E as EnvKeyAdapter, O as OWSAccountInfo, a as OWSCore, b as OWSSignResult, c as OWSWallet, d as OWSWalletAdapter, e as OWSWalletAdapterOptions } from './ows-DJu424iz.mjs';
|
|
8
8
|
import { S as StackKeyOptions } from './receipts-DsOSK0yB.mjs';
|
|
9
9
|
export { a as FacilitatorReceipt, F as FetchReceiptResult, P as PaymentState, b as PurchaseContext, c as RECEIPT_ISSUER, R as ReceiptFetchOptions, d as ReceiptKeys, e as STACK_KEY_HEADER, f as StackKeyRedirectError, g as canonicalReceiptJson, h as createPurchaseContext, i as fetchWithReceipt, j as getFacilitatorReceipt, m as mergeHeaderList, k as mergePaymentResponseHeaders, p as parseFacilitatorReceipt, l as paymentResponseHeaders, n as purchaseContextHeader, r as receiptCommitment, o as receiptFromErrorBody, q as receiptFromResponse, v as validatePurchaseContext, s as verifyFacilitatorReceipt } from './receipts-DsOSK0yB.mjs';
|
|
10
10
|
export { HEDERA_NETWORKS, HederaNetwork, HederaPaymentPayload, HederaProvider, HederaRequirements, buildHederaRequest, buildHederaRequirements, validateHederaRequirements } from './providers/hedera/index.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { A as AdvertisedQuote, j as AlgorandPaymentPayload, k as CAIP2_IDENTIFIE
|
|
|
4
4
|
export { D as DEFAULT_PAYMENT_HEADER, a as DEFAULT_VALIDITY_SECONDS, M as MAX_VALIDITY_SECONDS, P as PAYMENT_HEADER_NAMES, b as buildTokenMetadata, c as caip2ToChain, d as chainToCAIP2, e as clampValiditySeconds, f as convertX402Header, g as createPaymentHeaders, h as createX402Header, i as createX402V1Header, j as createX402V2Header, k as decodeBase64Utf8, l as decodeX402Header, m as detectX402Version, n as encodeBase64Json, o as encodeBase64Utf8, p as encodeX402Header, q as generatePaymentOptions, r as getPaymentHeader, s as isCAIP2Format, t as parseNetworkIdentifier, u as paymentChallengeFrom, v as resolveValiditySeconds, w as validateAmount, x as validateRecipient } from './validity-BshzF_Ga.js';
|
|
5
5
|
import { S as SigningWalletAdapter } from './wallet-T0NFUUkT.js';
|
|
6
6
|
export { a as EIP3009Authorization, E as EIP3009Params } from './wallet-T0NFUUkT.js';
|
|
7
|
-
export { E as EnvKeyAdapter, O as OWSAccountInfo, a as OWSCore, b as OWSSignResult, c as OWSWallet, d as OWSWalletAdapter, e as OWSWalletAdapterOptions } from './ows-
|
|
7
|
+
export { E as EnvKeyAdapter, O as OWSAccountInfo, a as OWSCore, b as OWSSignResult, c as OWSWallet, d as OWSWalletAdapter, e as OWSWalletAdapterOptions } from './ows-CW-g7qGw.js';
|
|
8
8
|
import { S as StackKeyOptions } from './receipts-CMuWVtO0.js';
|
|
9
9
|
export { a as FacilitatorReceipt, F as FetchReceiptResult, P as PaymentState, b as PurchaseContext, c as RECEIPT_ISSUER, R as ReceiptFetchOptions, d as ReceiptKeys, e as STACK_KEY_HEADER, f as StackKeyRedirectError, g as canonicalReceiptJson, h as createPurchaseContext, i as fetchWithReceipt, j as getFacilitatorReceipt, m as mergeHeaderList, k as mergePaymentResponseHeaders, p as parseFacilitatorReceipt, l as paymentResponseHeaders, n as purchaseContextHeader, r as receiptCommitment, o as receiptFromErrorBody, q as receiptFromResponse, v as validatePurchaseContext, s as verifyFacilitatorReceipt } from './receipts-CMuWVtO0.js';
|
|
10
10
|
export { HEDERA_NETWORKS, HederaNetwork, HederaPaymentPayload, HederaProvider, HederaRequirements, buildHederaRequest, buildHederaRequirements, validateHederaRequirements } from './providers/hedera/index.js';
|
package/dist/index.js
CHANGED
|
@@ -3553,8 +3553,124 @@ function assertTypedDataIntegersExact(doc, where = "typed data", code = "INVALID
|
|
|
3553
3553
|
}
|
|
3554
3554
|
assertNoInexactNumber(message, `${where} message`, code);
|
|
3555
3555
|
}
|
|
3556
|
+
var MIN_EXACT_DIGITS = 22;
|
|
3557
|
+
var MAX_EXACT_DIGITS = 78;
|
|
3558
|
+
var MAX_DOUBLE_DIGITS = 17;
|
|
3559
|
+
function doubleShaped(literal) {
|
|
3560
|
+
const significant = literal.replace(/^-/, "").replace(/0+$/, "");
|
|
3561
|
+
return significant.length <= MAX_DOUBLE_DIGITS || BigInt(literal) === BigInt(Number(literal));
|
|
3562
|
+
}
|
|
3563
|
+
var JSON_NUMBER = /-?(?:0|[1-9][0-9]*)(\.[0-9]+)?([eE][+-]?[0-9]+)?/y;
|
|
3564
|
+
var JSON_SPACE = /[ \t\n\r]*/y;
|
|
3565
|
+
function dataDescriptor(value) {
|
|
3566
|
+
const descriptor = /* @__PURE__ */ Object.create(null);
|
|
3567
|
+
descriptor.value = value;
|
|
3568
|
+
descriptor.writable = true;
|
|
3569
|
+
descriptor.enumerable = true;
|
|
3570
|
+
descriptor.configurable = true;
|
|
3571
|
+
return descriptor;
|
|
3572
|
+
}
|
|
3573
|
+
function parseJsonExact(input) {
|
|
3574
|
+
const text = String(input);
|
|
3575
|
+
let pos = 0;
|
|
3576
|
+
let wide = false;
|
|
3577
|
+
const fail = (what) => {
|
|
3578
|
+
throw new SyntaxError(`${what} in JSON at position ${pos}`);
|
|
3579
|
+
};
|
|
3580
|
+
const space = () => {
|
|
3581
|
+
JSON_SPACE.lastIndex = pos;
|
|
3582
|
+
if (JSON_SPACE.exec(text)) pos = JSON_SPACE.lastIndex;
|
|
3583
|
+
};
|
|
3584
|
+
const string = () => {
|
|
3585
|
+
if (text[pos] !== '"') fail("Expected a string");
|
|
3586
|
+
let end = pos + 1;
|
|
3587
|
+
while (end < text.length && text[end] !== '"') end += text[end] === "\\" ? 2 : 1;
|
|
3588
|
+
if (end >= text.length) fail("Unterminated string");
|
|
3589
|
+
const value = JSON.parse(text.slice(pos, end + 1));
|
|
3590
|
+
pos = end + 1;
|
|
3591
|
+
return value;
|
|
3592
|
+
};
|
|
3593
|
+
const key = () => {
|
|
3594
|
+
const name = string();
|
|
3595
|
+
space();
|
|
3596
|
+
if (text[pos] !== ":") fail("Expected ':'");
|
|
3597
|
+
pos += 1;
|
|
3598
|
+
space();
|
|
3599
|
+
return name;
|
|
3600
|
+
};
|
|
3601
|
+
const scalar = () => {
|
|
3602
|
+
if (text[pos] === '"') return string();
|
|
3603
|
+
for (const [word, value] of [["true", true], ["false", false], ["null", null]]) {
|
|
3604
|
+
if (text.startsWith(word, pos)) {
|
|
3605
|
+
pos += word.length;
|
|
3606
|
+
return value;
|
|
3607
|
+
}
|
|
3608
|
+
}
|
|
3609
|
+
JSON_NUMBER.lastIndex = pos;
|
|
3610
|
+
const match = JSON_NUMBER.exec(text);
|
|
3611
|
+
if (!match) return fail("Unexpected token");
|
|
3612
|
+
pos = JSON_NUMBER.lastIndex;
|
|
3613
|
+
const literal = match[0];
|
|
3614
|
+
const digits = literal.length - (literal.startsWith("-") ? 1 : 0);
|
|
3615
|
+
if (match[1] === void 0 && match[2] === void 0 && digits >= MIN_EXACT_DIGITS && digits <= MAX_EXACT_DIGITS && !doubleShaped(literal)) {
|
|
3616
|
+
wide = true;
|
|
3617
|
+
return BigInt(literal);
|
|
3618
|
+
}
|
|
3619
|
+
return Number(literal);
|
|
3620
|
+
};
|
|
3621
|
+
const stack = [];
|
|
3622
|
+
space();
|
|
3623
|
+
for (; ; ) {
|
|
3624
|
+
let value;
|
|
3625
|
+
if (text[pos] === "[") {
|
|
3626
|
+
pos += 1;
|
|
3627
|
+
space();
|
|
3628
|
+
if (text[pos] !== "]") {
|
|
3629
|
+
stack.push({ kind: "array", items: [] });
|
|
3630
|
+
continue;
|
|
3631
|
+
}
|
|
3632
|
+
pos += 1;
|
|
3633
|
+
value = [];
|
|
3634
|
+
} else if (text[pos] === "{") {
|
|
3635
|
+
pos += 1;
|
|
3636
|
+
space();
|
|
3637
|
+
if (text[pos] !== "}") {
|
|
3638
|
+
stack.push({ kind: "object", object: {}, key: key() });
|
|
3639
|
+
continue;
|
|
3640
|
+
}
|
|
3641
|
+
pos += 1;
|
|
3642
|
+
value = {};
|
|
3643
|
+
} else {
|
|
3644
|
+
value = scalar();
|
|
3645
|
+
}
|
|
3646
|
+
for (; ; ) {
|
|
3647
|
+
space();
|
|
3648
|
+
const top = stack[stack.length - 1];
|
|
3649
|
+
if (top === void 0) {
|
|
3650
|
+
if (pos !== text.length) fail("Unexpected non-whitespace character after JSON");
|
|
3651
|
+
return wide ? value : JSON.parse(text);
|
|
3652
|
+
}
|
|
3653
|
+
const close = top.kind === "array" ? "]" : "}";
|
|
3654
|
+
if (top.kind === "array") {
|
|
3655
|
+
top.items.push(value);
|
|
3656
|
+
} else {
|
|
3657
|
+
Object.defineProperty(top.object, top.key, dataDescriptor(value));
|
|
3658
|
+
}
|
|
3659
|
+
if (text[pos] === ",") {
|
|
3660
|
+
pos += 1;
|
|
3661
|
+
space();
|
|
3662
|
+
if (top.kind === "object") top.key = key();
|
|
3663
|
+
break;
|
|
3664
|
+
}
|
|
3665
|
+
if (text[pos] !== close) fail(`Expected ',' or '${close}'`);
|
|
3666
|
+
pos += 1;
|
|
3667
|
+
stack.pop();
|
|
3668
|
+
value = top.kind === "array" ? top.items : top.object;
|
|
3669
|
+
}
|
|
3670
|
+
}
|
|
3671
|
+
}
|
|
3556
3672
|
function parseTypedDataJson(text, where = "typed data", code = "INVALID_CONFIG") {
|
|
3557
|
-
const doc =
|
|
3673
|
+
const doc = parseJsonExact(text);
|
|
3558
3674
|
assertTypedDataIntegersExact(doc, where, code);
|
|
3559
3675
|
return doc;
|
|
3560
3676
|
}
|
|
@@ -4589,11 +4705,18 @@ var EnvKeyAdapter = class {
|
|
|
4589
4705
|
/**
|
|
4590
4706
|
* Sign EIP-712 typed structured data.
|
|
4591
4707
|
*
|
|
4708
|
+
* An integer of 22 to 78 digits written as a JSON number (a 32-byte salt)
|
|
4709
|
+
* is read with every digit, as Python's `json` reads it, not rounded the
|
|
4710
|
+
* way `JSON.parse` rounds it.
|
|
4711
|
+
*
|
|
4592
4712
|
* @param typedData - JSON string with `domain`, `types`, `primaryType`, and `message` fields
|
|
4593
4713
|
* @returns Object with signature and v/r/s components
|
|
4594
4714
|
* @throws {X402Error} `INVALID_CONFIG` when an integer field of `message`
|
|
4595
|
-
* (or `domain.chainId`) is a JSON number above 2**53 - 1
|
|
4596
|
-
*
|
|
4715
|
+
* (or `domain.chainId`) is a JSON number above 2**53 - 1 of up to 21
|
|
4716
|
+
* digits (a JavaScript hop may have rounded it and written it back in
|
|
4717
|
+
* digits) or written with an exponent or a fraction (`7.76e+76`): it is
|
|
4718
|
+
* refused instead of signed. Write uints as strings. An integer out of
|
|
4719
|
+
* its field's range is refused by ethers (`value out-of-bounds`).
|
|
4597
4720
|
*/
|
|
4598
4721
|
async signTypedData(typedData) {
|
|
4599
4722
|
const parsed = parseTypedDataJson(typedData);
|
|
@@ -4860,7 +4983,14 @@ function prepareTypedData(input) {
|
|
|
4860
4983
|
EIP712Domain: EIP712_DOMAIN_FIELDS.filter(([name]) => domain[name] != null).map(
|
|
4861
4984
|
([name, type]) => ({ name, type })
|
|
4862
4985
|
),
|
|
4863
|
-
|
|
4986
|
+
// Each field as ethers hashes it, name and type: any other key (a wide
|
|
4987
|
+
// number in it is a bigint) never reaches OWS or JSON.stringify.
|
|
4988
|
+
...Object.fromEntries(
|
|
4989
|
+
Object.entries(structs).map(([struct, fields]) => [
|
|
4990
|
+
struct,
|
|
4991
|
+
fields.map(({ name, type }) => ({ name, type }))
|
|
4992
|
+
])
|
|
4993
|
+
)
|
|
4864
4994
|
};
|
|
4865
4995
|
const owsDomain = owsValue("EIP712Domain", domain, all, "domain");
|
|
4866
4996
|
const owsMessage = owsValue(root, message, all, "message");
|
|
@@ -4992,7 +5122,7 @@ var OWSWalletAdapter = class {
|
|
|
4992
5122
|
async signTypedData(typedData) {
|
|
4993
5123
|
let parsed;
|
|
4994
5124
|
try {
|
|
4995
|
-
parsed =
|
|
5125
|
+
parsed = parseJsonExact(typedData);
|
|
4996
5126
|
} catch {
|
|
4997
5127
|
throw refuse("typedData is not a JSON string");
|
|
4998
5128
|
}
|