@dexterai/x402 1.8.2 → 1.9.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/adapters/index.cjs +15 -3
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.d.cts +5 -5
- package/dist/adapters/index.d.ts +5 -5
- package/dist/adapters/index.js +5 -3
- package/dist/adapters/index.js.map +1 -1
- package/dist/client/index.cjs +22 -9
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +6 -6
- package/dist/client/index.d.ts +6 -6
- package/dist/client/index.js +12 -9
- package/dist/client/index.js.map +1 -1
- package/dist/react/index.cjs +24 -11
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +4 -4
- package/dist/react/index.d.ts +4 -4
- package/dist/react/index.js +14 -11
- package/dist/react/index.js.map +1 -1
- package/dist/server/index.cjs +27 -17
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +2 -2
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.js +25 -15
- package/dist/server/index.js.map +1 -1
- package/dist/{solana-BeGAqPta.d.cts → solana-CfHuiW2H.d.cts} +2 -2
- package/dist/{solana-CQD9yMju.d.ts → solana-kZcwbUK9.d.ts} +2 -2
- package/dist/{types-DYLi7SuF.d.cts → types-BQvaF8lB.d.cts} +7 -5
- package/dist/{types-DYLi7SuF.d.ts → types-BQvaF8lB.d.ts} +7 -5
- package/dist/{types-B477nBpg.d.cts → types-DmqH9yD8.d.cts} +1 -1
- package/dist/{types-BWnUAPvD.d.ts → types-ENcnkof8.d.ts} +1 -1
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/{x402-client-Dk9q2QQF.d.cts → x402-client-BDaOwfgE.d.cts} +2 -2
- package/dist/{x402-client-D9b3PHai.d.ts → x402-client-DIcp-PvX.d.ts} +2 -2
- package/package.json +1 -1
package/dist/react/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as X402Client } from '../x402-client-
|
|
2
|
-
import { W as WalletSet, B as BalanceInfo } from '../types-
|
|
3
|
-
import { a as AccessPassTier } from '../types-
|
|
4
|
-
export { A as AccessPassClientConfig, b as AccessPassInfo, X as X402Error } from '../types-
|
|
1
|
+
import { a as X402Client } from '../x402-client-BDaOwfgE.cjs';
|
|
2
|
+
import { W as WalletSet, B as BalanceInfo } from '../types-DmqH9yD8.cjs';
|
|
3
|
+
import { a as AccessPassTier } from '../types-BQvaF8lB.cjs';
|
|
4
|
+
export { A as AccessPassClientConfig, b as AccessPassInfo, X as X402Error } from '../types-BQvaF8lB.cjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* React Hook for x402 v2 Payments
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as X402Client } from '../x402-client-
|
|
2
|
-
import { W as WalletSet, B as BalanceInfo } from '../types-
|
|
3
|
-
import { a as AccessPassTier } from '../types-
|
|
4
|
-
export { A as AccessPassClientConfig, b as AccessPassInfo, X as X402Error } from '../types-
|
|
1
|
+
import { a as X402Client } from '../x402-client-DIcp-PvX.js';
|
|
2
|
+
import { W as WalletSet, B as BalanceInfo } from '../types-ENcnkof8.js';
|
|
3
|
+
import { a as AccessPassTier } from '../types-BQvaF8lB.js';
|
|
4
|
+
export { A as AccessPassClientConfig, b as AccessPassInfo, X as X402Error } from '../types-BQvaF8lB.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* React Hook for x402 v2 Payments
|
package/dist/react/index.js
CHANGED
|
@@ -124,7 +124,7 @@ var SolanaAdapter = class {
|
|
|
124
124
|
const connection = new Connection(url, "confirmed");
|
|
125
125
|
const userPubkey = new PublicKey(wallet.publicKey.toBase58());
|
|
126
126
|
const { payTo, asset, extra } = accept;
|
|
127
|
-
const amount = accept.amount
|
|
127
|
+
const amount = accept.amount ?? accept.maxAmountRequired;
|
|
128
128
|
if (!amount) {
|
|
129
129
|
throw new Error("Missing amount in payment requirements");
|
|
130
130
|
}
|
|
@@ -362,7 +362,7 @@ var EvmAdapter = class {
|
|
|
362
362
|
throw new Error("Wallet not connected");
|
|
363
363
|
}
|
|
364
364
|
const { payTo, asset, extra } = accept;
|
|
365
|
-
const amount = accept.amount
|
|
365
|
+
const amount = accept.amount ?? accept.maxAmountRequired;
|
|
366
366
|
if (!amount) {
|
|
367
367
|
throw new Error("Missing amount in payment requirements");
|
|
368
368
|
}
|
|
@@ -390,7 +390,9 @@ var EvmAdapter = class {
|
|
|
390
390
|
{ name: "nonce", type: "bytes32" }
|
|
391
391
|
]
|
|
392
392
|
};
|
|
393
|
-
const
|
|
393
|
+
const nonceBytes = new Uint8Array(32);
|
|
394
|
+
(globalThis.crypto ?? (await import("crypto")).webcrypto).getRandomValues(nonceBytes);
|
|
395
|
+
const nonce = "0x" + [...nonceBytes].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
394
396
|
const now = Math.floor(Date.now() / 1e3);
|
|
395
397
|
const authorization = {
|
|
396
398
|
from: wallet.address,
|
|
@@ -482,10 +484,11 @@ function createX402Client(config) {
|
|
|
482
484
|
const parts = jwt.split(".");
|
|
483
485
|
if (parts.length === 3) {
|
|
484
486
|
const payload = JSON.parse(atob(parts[1].replace(/-/g, "+").replace(/_/g, "/")));
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
}
|
|
487
|
+
const now = Math.floor(Date.now() / 1e3);
|
|
488
|
+
const maxExp = now + 86400;
|
|
489
|
+
const expiresAt = Math.min(typeof payload.exp === "number" ? payload.exp : now, maxExp);
|
|
490
|
+
passCache.set(host, { jwt, expiresAt });
|
|
491
|
+
log("Access pass cached for", host, "| expires:", new Date(expiresAt * 1e3).toISOString());
|
|
489
492
|
}
|
|
490
493
|
} catch {
|
|
491
494
|
log("Failed to cache access pass");
|
|
@@ -566,7 +569,7 @@ function createX402Client(config) {
|
|
|
566
569
|
if (adapter.name === "Solana" && !accept.extra?.feePayer) return null;
|
|
567
570
|
const decimals = accept.extra?.decimals ?? (isKnownUSDC(accept.asset) ? 6 : void 0);
|
|
568
571
|
if (typeof decimals !== "number") return null;
|
|
569
|
-
const paymentAmount = accept.amount
|
|
572
|
+
const paymentAmount = accept.amount ?? accept.maxAmountRequired;
|
|
570
573
|
if (!paymentAmount) return null;
|
|
571
574
|
const rpcUrl = getRpcUrl(accept.network, adapter);
|
|
572
575
|
const balance = await adapter.getBalance(accept, wallet, rpcUrl);
|
|
@@ -710,7 +713,7 @@ function createX402Client(config) {
|
|
|
710
713
|
"Payment option missing decimals - provide in extra or use a known stablecoin"
|
|
711
714
|
);
|
|
712
715
|
}
|
|
713
|
-
const paymentAmount = accept.amount
|
|
716
|
+
const paymentAmount = accept.amount ?? accept.maxAmountRequired;
|
|
714
717
|
if (!paymentAmount) {
|
|
715
718
|
throw new X402Error("missing_amount", "Payment option missing amount");
|
|
716
719
|
}
|
|
@@ -921,7 +924,7 @@ function useX402Payment(config) {
|
|
|
921
924
|
const accept = {
|
|
922
925
|
scheme: "exact",
|
|
923
926
|
network: SOLANA_MAINNET_NETWORK,
|
|
924
|
-
|
|
927
|
+
amount: "0",
|
|
925
928
|
asset: USDC_MINT,
|
|
926
929
|
payTo: "",
|
|
927
930
|
maxTimeoutSeconds: 60,
|
|
@@ -946,7 +949,7 @@ function useX402Payment(config) {
|
|
|
946
949
|
const accept = {
|
|
947
950
|
scheme: "exact",
|
|
948
951
|
network: BASE_MAINNET_NETWORK,
|
|
949
|
-
|
|
952
|
+
amount: "0",
|
|
950
953
|
asset: USDC_BASE,
|
|
951
954
|
payTo: "",
|
|
952
955
|
maxTimeoutSeconds: 60,
|