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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { X as X402Version, a as PaymentResult } from '../index-DARXHuQl.mjs';
|
|
2
|
-
export { E as EnvKeyAdapter, O as OWSAccountInfo, a as OWSCore, b as OWSSignResult, c as OWSWallet, d as OWSWalletAdapter, e as OWSWalletAdapterOptions } from '../ows-
|
|
2
|
+
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';
|
|
3
3
|
import '../wallet-T0NFUUkT.mjs';
|
|
4
4
|
import 'ethers';
|
|
5
5
|
|
package/dist/adapters/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { X as X402Version, a as PaymentResult } from '../index-DARXHuQl.js';
|
|
2
|
-
export { E as EnvKeyAdapter, O as OWSAccountInfo, a as OWSCore, b as OWSSignResult, c as OWSWallet, d as OWSWalletAdapter, e as OWSWalletAdapterOptions } from '../ows-
|
|
2
|
+
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';
|
|
3
3
|
import '../wallet-T0NFUUkT.js';
|
|
4
4
|
import 'ethers';
|
|
5
5
|
|
package/dist/adapters/index.js
CHANGED
|
@@ -1545,8 +1545,124 @@ function assertTypedDataIntegersExact(doc, where = "typed data", code = "INVALID
|
|
|
1545
1545
|
}
|
|
1546
1546
|
assertNoInexactNumber(message, `${where} message`, code);
|
|
1547
1547
|
}
|
|
1548
|
+
var MIN_EXACT_DIGITS = 22;
|
|
1549
|
+
var MAX_EXACT_DIGITS = 78;
|
|
1550
|
+
var MAX_DOUBLE_DIGITS = 17;
|
|
1551
|
+
function doubleShaped(literal) {
|
|
1552
|
+
const significant = literal.replace(/^-/, "").replace(/0+$/, "");
|
|
1553
|
+
return significant.length <= MAX_DOUBLE_DIGITS || BigInt(literal) === BigInt(Number(literal));
|
|
1554
|
+
}
|
|
1555
|
+
var JSON_NUMBER = /-?(?:0|[1-9][0-9]*)(\.[0-9]+)?([eE][+-]?[0-9]+)?/y;
|
|
1556
|
+
var JSON_SPACE = /[ \t\n\r]*/y;
|
|
1557
|
+
function dataDescriptor(value) {
|
|
1558
|
+
const descriptor = /* @__PURE__ */ Object.create(null);
|
|
1559
|
+
descriptor.value = value;
|
|
1560
|
+
descriptor.writable = true;
|
|
1561
|
+
descriptor.enumerable = true;
|
|
1562
|
+
descriptor.configurable = true;
|
|
1563
|
+
return descriptor;
|
|
1564
|
+
}
|
|
1565
|
+
function parseJsonExact(input) {
|
|
1566
|
+
const text = String(input);
|
|
1567
|
+
let pos = 0;
|
|
1568
|
+
let wide = false;
|
|
1569
|
+
const fail = (what) => {
|
|
1570
|
+
throw new SyntaxError(`${what} in JSON at position ${pos}`);
|
|
1571
|
+
};
|
|
1572
|
+
const space = () => {
|
|
1573
|
+
JSON_SPACE.lastIndex = pos;
|
|
1574
|
+
if (JSON_SPACE.exec(text)) pos = JSON_SPACE.lastIndex;
|
|
1575
|
+
};
|
|
1576
|
+
const string = () => {
|
|
1577
|
+
if (text[pos] !== '"') fail("Expected a string");
|
|
1578
|
+
let end = pos + 1;
|
|
1579
|
+
while (end < text.length && text[end] !== '"') end += text[end] === "\\" ? 2 : 1;
|
|
1580
|
+
if (end >= text.length) fail("Unterminated string");
|
|
1581
|
+
const value = JSON.parse(text.slice(pos, end + 1));
|
|
1582
|
+
pos = end + 1;
|
|
1583
|
+
return value;
|
|
1584
|
+
};
|
|
1585
|
+
const key = () => {
|
|
1586
|
+
const name = string();
|
|
1587
|
+
space();
|
|
1588
|
+
if (text[pos] !== ":") fail("Expected ':'");
|
|
1589
|
+
pos += 1;
|
|
1590
|
+
space();
|
|
1591
|
+
return name;
|
|
1592
|
+
};
|
|
1593
|
+
const scalar = () => {
|
|
1594
|
+
if (text[pos] === '"') return string();
|
|
1595
|
+
for (const [word, value] of [["true", true], ["false", false], ["null", null]]) {
|
|
1596
|
+
if (text.startsWith(word, pos)) {
|
|
1597
|
+
pos += word.length;
|
|
1598
|
+
return value;
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1601
|
+
JSON_NUMBER.lastIndex = pos;
|
|
1602
|
+
const match = JSON_NUMBER.exec(text);
|
|
1603
|
+
if (!match) return fail("Unexpected token");
|
|
1604
|
+
pos = JSON_NUMBER.lastIndex;
|
|
1605
|
+
const literal = match[0];
|
|
1606
|
+
const digits = literal.length - (literal.startsWith("-") ? 1 : 0);
|
|
1607
|
+
if (match[1] === void 0 && match[2] === void 0 && digits >= MIN_EXACT_DIGITS && digits <= MAX_EXACT_DIGITS && !doubleShaped(literal)) {
|
|
1608
|
+
wide = true;
|
|
1609
|
+
return BigInt(literal);
|
|
1610
|
+
}
|
|
1611
|
+
return Number(literal);
|
|
1612
|
+
};
|
|
1613
|
+
const stack = [];
|
|
1614
|
+
space();
|
|
1615
|
+
for (; ; ) {
|
|
1616
|
+
let value;
|
|
1617
|
+
if (text[pos] === "[") {
|
|
1618
|
+
pos += 1;
|
|
1619
|
+
space();
|
|
1620
|
+
if (text[pos] !== "]") {
|
|
1621
|
+
stack.push({ kind: "array", items: [] });
|
|
1622
|
+
continue;
|
|
1623
|
+
}
|
|
1624
|
+
pos += 1;
|
|
1625
|
+
value = [];
|
|
1626
|
+
} else if (text[pos] === "{") {
|
|
1627
|
+
pos += 1;
|
|
1628
|
+
space();
|
|
1629
|
+
if (text[pos] !== "}") {
|
|
1630
|
+
stack.push({ kind: "object", object: {}, key: key() });
|
|
1631
|
+
continue;
|
|
1632
|
+
}
|
|
1633
|
+
pos += 1;
|
|
1634
|
+
value = {};
|
|
1635
|
+
} else {
|
|
1636
|
+
value = scalar();
|
|
1637
|
+
}
|
|
1638
|
+
for (; ; ) {
|
|
1639
|
+
space();
|
|
1640
|
+
const top = stack[stack.length - 1];
|
|
1641
|
+
if (top === void 0) {
|
|
1642
|
+
if (pos !== text.length) fail("Unexpected non-whitespace character after JSON");
|
|
1643
|
+
return wide ? value : JSON.parse(text);
|
|
1644
|
+
}
|
|
1645
|
+
const close = top.kind === "array" ? "]" : "}";
|
|
1646
|
+
if (top.kind === "array") {
|
|
1647
|
+
top.items.push(value);
|
|
1648
|
+
} else {
|
|
1649
|
+
Object.defineProperty(top.object, top.key, dataDescriptor(value));
|
|
1650
|
+
}
|
|
1651
|
+
if (text[pos] === ",") {
|
|
1652
|
+
pos += 1;
|
|
1653
|
+
space();
|
|
1654
|
+
if (top.kind === "object") top.key = key();
|
|
1655
|
+
break;
|
|
1656
|
+
}
|
|
1657
|
+
if (text[pos] !== close) fail(`Expected ',' or '${close}'`);
|
|
1658
|
+
pos += 1;
|
|
1659
|
+
stack.pop();
|
|
1660
|
+
value = top.kind === "array" ? top.items : top.object;
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1548
1664
|
function parseTypedDataJson(text, where = "typed data", code = "INVALID_CONFIG") {
|
|
1549
|
-
const doc =
|
|
1665
|
+
const doc = parseJsonExact(text);
|
|
1550
1666
|
assertTypedDataIntegersExact(doc, where, code);
|
|
1551
1667
|
return doc;
|
|
1552
1668
|
}
|
|
@@ -1589,11 +1705,18 @@ var EnvKeyAdapter = class {
|
|
|
1589
1705
|
/**
|
|
1590
1706
|
* Sign EIP-712 typed structured data.
|
|
1591
1707
|
*
|
|
1708
|
+
* An integer of 22 to 78 digits written as a JSON number (a 32-byte salt)
|
|
1709
|
+
* is read with every digit, as Python's `json` reads it, not rounded the
|
|
1710
|
+
* way `JSON.parse` rounds it.
|
|
1711
|
+
*
|
|
1592
1712
|
* @param typedData - JSON string with `domain`, `types`, `primaryType`, and `message` fields
|
|
1593
1713
|
* @returns Object with signature and v/r/s components
|
|
1594
1714
|
* @throws {X402Error} `INVALID_CONFIG` when an integer field of `message`
|
|
1595
|
-
* (or `domain.chainId`) is a JSON number above 2**53 - 1
|
|
1596
|
-
*
|
|
1715
|
+
* (or `domain.chainId`) is a JSON number above 2**53 - 1 of up to 21
|
|
1716
|
+
* digits (a JavaScript hop may have rounded it and written it back in
|
|
1717
|
+
* digits) or written with an exponent or a fraction (`7.76e+76`): it is
|
|
1718
|
+
* refused instead of signed. Write uints as strings. An integer out of
|
|
1719
|
+
* its field's range is refused by ethers (`value out-of-bounds`).
|
|
1597
1720
|
*/
|
|
1598
1721
|
async signTypedData(typedData) {
|
|
1599
1722
|
const parsed = parseTypedDataJson(typedData);
|
|
@@ -1856,7 +1979,14 @@ function prepareTypedData(input) {
|
|
|
1856
1979
|
EIP712Domain: EIP712_DOMAIN_FIELDS.filter(([name]) => domain[name] != null).map(
|
|
1857
1980
|
([name, type]) => ({ name, type })
|
|
1858
1981
|
),
|
|
1859
|
-
|
|
1982
|
+
// Each field as ethers hashes it, name and type: any other key (a wide
|
|
1983
|
+
// number in it is a bigint) never reaches OWS or JSON.stringify.
|
|
1984
|
+
...Object.fromEntries(
|
|
1985
|
+
Object.entries(structs).map(([struct, fields]) => [
|
|
1986
|
+
struct,
|
|
1987
|
+
fields.map(({ name, type }) => ({ name, type }))
|
|
1988
|
+
])
|
|
1989
|
+
)
|
|
1860
1990
|
};
|
|
1861
1991
|
const owsDomain = owsValue("EIP712Domain", domain, all, "domain");
|
|
1862
1992
|
const owsMessage = owsValue(root, message, all, "message");
|
|
@@ -1988,7 +2118,7 @@ var OWSWalletAdapter = class {
|
|
|
1988
2118
|
async signTypedData(typedData) {
|
|
1989
2119
|
let parsed;
|
|
1990
2120
|
try {
|
|
1991
|
-
parsed =
|
|
2121
|
+
parsed = parseJsonExact(typedData);
|
|
1992
2122
|
} catch {
|
|
1993
2123
|
throw refuse("typedData is not a JSON string");
|
|
1994
2124
|
}
|