uvd-x402-sdk 2.99.0 → 2.100.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/README.md +10 -0
- package/dist/adapters/index.d.mts +1 -1
- package/dist/adapters/index.d.ts +1 -1
- package/dist/adapters/index.js +2 -2
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/index.mjs +2 -2
- package/dist/adapters/index.mjs.map +1 -1
- package/dist/backend/index.d.mts +3 -3
- package/dist/backend/index.d.ts +3 -3
- package/dist/backend/index.js +199 -45
- package/dist/backend/index.js.map +1 -1
- package/dist/backend/index.mjs +198 -46
- package/dist/backend/index.mjs.map +1 -1
- package/dist/erc8128/index.js.map +1 -1
- package/dist/erc8128/index.mjs.map +1 -1
- package/dist/{index-B2i1mGpW.d.mts → index-CS4qStqy.d.mts} +2 -2
- package/dist/{index-BiL4seGs.d.ts → index-CYMXb5eC.d.ts} +27 -10
- package/dist/{index-BsKsZzP3.d.ts → index-DagQ74ZQ.d.mts} +2 -2
- package/dist/{index-BsKsZzP3.d.mts → index-DagQ74ZQ.d.ts} +2 -2
- package/dist/{index--bevvYU9.d.ts → index-QswKm6BF.d.ts} +2 -2
- package/dist/{index-SaqboHsK.d.mts → index-prkNXpLX.d.mts} +27 -10
- package/dist/index.d.mts +24 -10
- package/dist/index.d.ts +24 -10
- package/dist/index.js +188 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +187 -27
- package/dist/index.mjs.map +1 -1
- package/dist/providers/algorand/index.d.mts +1 -1
- package/dist/providers/algorand/index.d.ts +1 -1
- package/dist/providers/algorand/index.js +23 -2
- package/dist/providers/algorand/index.js.map +1 -1
- package/dist/providers/algorand/index.mjs +23 -2
- package/dist/providers/algorand/index.mjs.map +1 -1
- package/dist/providers/evm/index.d.mts +1 -1
- package/dist/providers/evm/index.d.ts +1 -1
- package/dist/providers/evm/index.js.map +1 -1
- package/dist/providers/evm/index.mjs.map +1 -1
- package/dist/providers/hedera/index.d.mts +1 -1
- package/dist/providers/hedera/index.d.ts +1 -1
- package/dist/providers/near/index.d.mts +1 -1
- package/dist/providers/near/index.d.ts +1 -1
- package/dist/providers/near/index.js +23 -2
- package/dist/providers/near/index.js.map +1 -1
- package/dist/providers/near/index.mjs +23 -2
- package/dist/providers/near/index.mjs.map +1 -1
- package/dist/providers/solana/index.d.mts +1 -1
- package/dist/providers/solana/index.d.ts +1 -1
- package/dist/providers/solana/index.js +23 -2
- package/dist/providers/solana/index.js.map +1 -1
- package/dist/providers/solana/index.mjs +23 -2
- package/dist/providers/solana/index.mjs.map +1 -1
- package/dist/providers/stellar/index.d.mts +1 -1
- package/dist/providers/stellar/index.d.ts +1 -1
- package/dist/providers/stellar/index.js +23 -2
- package/dist/providers/stellar/index.js.map +1 -1
- package/dist/providers/stellar/index.mjs +23 -2
- package/dist/providers/stellar/index.mjs.map +1 -1
- package/dist/providers/sui/index.d.mts +1 -1
- package/dist/providers/sui/index.d.ts +1 -1
- package/dist/providers/sui/index.js +23 -2
- package/dist/providers/sui/index.js.map +1 -1
- package/dist/providers/sui/index.mjs +23 -2
- package/dist/providers/sui/index.mjs.map +1 -1
- package/dist/providers/xrpl/index.d.mts +1 -1
- package/dist/providers/xrpl/index.d.ts +1 -1
- package/dist/providers/xrpl/index.js +24 -8
- package/dist/providers/xrpl/index.js.map +1 -1
- package/dist/providers/xrpl/index.mjs +24 -8
- package/dist/providers/xrpl/index.mjs.map +1 -1
- package/dist/react/index.d.mts +4 -4
- package/dist/react/index.d.ts +4 -4
- package/dist/react/index.js +30 -1
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +31 -2
- package/dist/react/index.mjs.map +1 -1
- package/dist/react/picker/index.d.mts +1 -1
- package/dist/react/picker/index.d.ts +1 -1
- package/dist/receipts-8XsMeo1y.d.ts +191 -0
- package/dist/receipts-COPJ_BY9.d.mts +191 -0
- package/dist/utils/index.d.mts +2 -2
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.js +22 -3
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +23 -4
- package/dist/utils/index.mjs.map +1 -1
- package/dist/{validity-CoCrj9pZ.d.ts → validity-BpwXbfdj.d.ts} +1 -1
- package/dist/{validity-BcPTzuK8.d.mts → validity-eGGXxzpi.d.mts} +1 -1
- package/package.json +1 -1
- package/src/backend/index.ts +81 -50
- package/src/backend/stack-key.ts +263 -0
- package/src/dx402.ts +26 -9
- package/src/events.ts +12 -2
- package/src/index.ts +4 -0
- package/src/providers/algorand/index.ts +3 -2
- package/src/providers/near/index.ts +3 -2
- package/src/providers/solana/index.ts +3 -2
- package/src/providers/stellar/index.ts +3 -2
- package/src/providers/sui/index.ts +3 -2
- package/src/providers/xrpl/index.ts +7 -12
- package/src/receipts.ts +12 -2
- package/src/types/index.ts +1 -1
- package/src/utils/amount.ts +64 -0
- package/src/utils/x402.ts +4 -3
- package/dist/receipts-Co6C9FPO.d.ts +0 -111
- package/dist/receipts-D0zg-8uK.d.mts +0 -111
package/README.md
CHANGED
|
@@ -861,6 +861,16 @@ app.post('/api/premium', async (req, res) => {
|
|
|
861
861
|
|
|
862
862
|
`createPaymentMiddleware()` and `createHonoMiddleware()` verify and settle automatically by default (`before-handler`). Use `settlementStrategy: 'manual'` if you need to control when settlement happens (e.g., settle only after confirming you can fulfill the request).
|
|
863
863
|
|
|
864
|
+
### Stack key (services run by Ultravioleta DAO)
|
|
865
|
+
|
|
866
|
+
Services run by Ultravioleta DAO carry a per-service credential, the stack key, so that the facilitator's rate-limit policy does not answer them `429`. Everything in this SDK that calls the facilitator sends it as `X-UVD-Stack-Key`: the clients `FacilitatorClient` (and the two middlewares), `Erc8004Client`, `BazaarClient`, `EscrowClient` and `AdvancedEscrowClient`, and the functions `anchorEvidence`, `availableBackends`, `streamTrafficEvents` and `getFacilitatorReceipt`, which take the same `stackKey` / `stackKeyHosts` options. It changes nothing else about a payment, and a facilitator that does not know the header ignores it.
|
|
867
|
+
|
|
868
|
+
- **Where it comes from:** the facilitator's operator issues one per service: `uvdsk_` followed by 43-128 base64url characters. The process receives it as `UVD_STACK_KEY` (read by default) or as the `stackKey` option, from a secret store, never from code.
|
|
869
|
+
- **Not for third parties:** if you integrate this SDK in your own product you have no key and need none. Leave both unset and no header is sent.
|
|
870
|
+
- **Only to a house facilitator:** the key goes over `https://` to `facilitator.ultravioletadao.xyz` and nowhere else, checked on the URL of every request. A request to any other host, or over plain `http://`, carries no header, whether the key came from the option or from `UVD_STACK_KEY`, and warns once, naming the host and never the key. `stackKeyHosts: ['facilitator-staging.example']` ADDS hosts (hostnames only, matched exactly); `facilitator.ultravioletadao.xyz` stays in. Plain `http://` is accepted only for `127.0.0.1` or `localhost`, and only when listed there. `EscrowClient`'s default base URL, `escrow.ultravioletadao.xyz`, is not the facilitator and gets the key only if listed.
|
|
871
|
+
- **The key does not follow redirects:** a redirect answered to a request that carries it fails with `StackKeyRedirectError` (exported), and the key is not sent again. Point the client at the facilitator's final URL.
|
|
872
|
+
- **A bad key never breaks a payment:** one leading BOM (U+FEFF), then spaces, tabs, CR and LF at both ends, are removed, and nothing else. A value that still does not match is not sent: the client warns once, without the value, and pays like any other client. The key never appears in a result, an error, a log line or a printed client.
|
|
873
|
+
|
|
864
874
|
## React
|
|
865
875
|
|
|
866
876
|
```tsx
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { X as X402Version, a as PaymentResult } from '../index-
|
|
1
|
+
import { X as X402Version, a as PaymentResult } from '../index-DagQ74ZQ.mjs';
|
|
2
2
|
export { E as EnvKeyAdapter, O as OWSWallet, a as OWSWalletAdapter } from '../ows-Z9v4GxOZ.mjs';
|
|
3
3
|
import '../wallet-w7BnImDG.mjs';
|
|
4
4
|
|
package/dist/adapters/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { X as X402Version, a as PaymentResult } from '../index-
|
|
1
|
+
import { X as X402Version, a as PaymentResult } from '../index-DagQ74ZQ.js';
|
|
2
2
|
export { E as EnvKeyAdapter, O as OWSWallet, a as OWSWalletAdapter } from '../ows-C-KmORG9.js';
|
|
3
3
|
import '../wallet-w7BnImDG.js';
|
|
4
4
|
|
package/dist/adapters/index.js
CHANGED
|
@@ -1325,7 +1325,7 @@ function generateNonce() {
|
|
|
1325
1325
|
}
|
|
1326
1326
|
return "0x" + Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
1327
1327
|
}
|
|
1328
|
-
function
|
|
1328
|
+
function parseUnits2(amount, decimals) {
|
|
1329
1329
|
const [integer, fraction = ""] = amount.split(".");
|
|
1330
1330
|
const paddedFraction = fraction.padEnd(decimals, "0").slice(0, decimals);
|
|
1331
1331
|
return BigInt(integer + paddedFraction);
|
|
@@ -1357,7 +1357,7 @@ async function createPaymentFromWalletClient(walletClient, options) {
|
|
|
1357
1357
|
const nonce = generateNonce();
|
|
1358
1358
|
const validAfter = 0;
|
|
1359
1359
|
const validBefore = Math.floor(Date.now() / 1e3) + validitySeconds;
|
|
1360
|
-
const value =
|
|
1360
|
+
const value = parseUnits2(amount, chain.usdc.decimals);
|
|
1361
1361
|
const domain = {
|
|
1362
1362
|
name: chain.usdc.name,
|
|
1363
1363
|
version: chain.usdc.version,
|