@dexterai/x402 3.7.6 → 3.7.8

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.
@@ -1,4 +1,4 @@
1
- "use strict";var xt=Object.create;var te=Object.defineProperty;var bt=Object.getOwnPropertyDescriptor;var Pt=Object.getOwnPropertyNames;var Tt=Object.getPrototypeOf,St=Object.prototype.hasOwnProperty;var wt=(e,t)=>{for(var n in t)te(e,n,{get:t[n],enumerable:!0})},ve=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Pt(t))!St.call(e,s)&&s!==n&&te(e,s,{get:()=>t[s],enumerable:!(r=bt(t,s))||r.enumerable});return e};var Te=(e,t,n)=>(n=e!=null?xt(Tt(e)):{},ve(t||!e||!e.__esModule?te(n,"default",{value:e,enumerable:!0}):n,e)),Rt=e=>ve(te({},"__esModule",{value:!0}),e);var Gt={};wt(Gt,{BASE_MAINNET_NETWORK:()=>W,DEXTER_FACILITATOR_URL:()=>U,FacilitatorClient:()=>G,MODEL_PRICING:()=>I,MODEL_PRICING_MAP:()=>he,MODEL_REGISTRY:()=>O,SOLANA_MAINNET_NETWORK:()=>$,SPONSORED_ACCESS_EXTENSION_KEY:()=>ht.SPONSORED_ACCESS_EXTENSION_KEY,USDC_BASE:()=>ue,USDC_MINT:()=>j,countTokens:()=>be,createDynamicPricing:()=>Qe,createTokenPricing:()=>mt,createX402Server:()=>X,escapeHtml:()=>N,estimateCost:()=>pt,findModel:()=>tt,formatModelPricing:()=>lt,formatPricing:()=>Ze,formatTokenPricing:()=>yt,getActiveModels:()=>it,getAvailableModelIds:()=>nt,getAvailableModels:()=>ft,getCheapestModel:()=>ct,getModel:()=>ye,getModelsByFamily:()=>ot,getModelsByTier:()=>st,getTextModels:()=>at,isValidModel:()=>gt,isValidModelId:()=>rt,resolveDefaultAsset:()=>we,stripePayTo:()=>Be,x402AccessPass:()=>Ye,x402BrowserSupport:()=>Xe,x402Middleware:()=>Ge});module.exports=Rt(Gt);var $="solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",Me="solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",_e="solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z";var W="eip155:8453",re="eip155:84532",ne="eip155:42161",se="eip155:137",oe="eip155:10",ie="eip155:43114",ae="eip155:56",ce="eip155:1187947933",pe="eip155:324705682",le="eip155:1";var j="EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";var ue="0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",At="0x55d398326f99059fF775485246999027B3197955",Ce="0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",Ne={[ae]:Ce,[W]:ue,[re]:"0x036CbD53842c5426634e7929541eC2318f3dCF7e",[ne]:"0xaf88d065e77c8cC2239327C5EDb3A432268e5831",[se]:"0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",[oe]:"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",[ie]:"0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",[ce]:"0x85889c8c714505E0c94b30fcfcF64fE3Ac8FCb20",[pe]:"0x2e08028E3C4c2356572E096d8EF835cD5C6030bD",[le]:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},Oe={[At]:{symbol:"USDT",decimals:18},[Ce]:{symbol:"USDC",decimals:18}},V=6;var Jt={[ae]:56,[W]:8453,[re]:84532,[ne]:42161,[se]:137,[oe]:10,[ie]:43114,[ce]:1187947933,[pe]:324705682,[le]:1},Yt={[$]:"https://api.dexter.cash/api/solana/rpc",[Me]:"https://api.devnet.solana.com",[_e]:"https://api.testnet.solana.com"},Qt={[ae]:"https://bsc-dataseed1.binance.org",[W]:"https://api.dexter.cash/api/base/rpc",[re]:"https://sepolia.base.org",[ne]:"https://arb1.arbitrum.io/rpc",[se]:"https://polygon-rpc.com",[oe]:"https://mainnet.optimism.io",[ie]:"https://api.avax.network/ext/bc/C/rpc",[ce]:"https://skale-base.skalenodes.com/v1/base",[pe]:"https://base-sepolia-testnet.skalenodes.com/v1/jubilant-horrible-ancha",[le]:"https://eth.llamarpc.com"},U="https://x402.dexter.cash",de=$;function J(e,t){let n=Math.pow(10,t);return Math.floor(e*n).toString()}function Se(e){return e.startsWith("solana:")||e==="solana"}function Et(e){if(typeof Buffer<"u")return Buffer.from(e,"utf-8").toString("base64");let t=new TextEncoder().encode(e),n="";for(let r=0;r<t.length;r++)n+=String.fromCharCode(t[r]);return btoa(n)}function kt(e){if(typeof Buffer<"u")return Buffer.from(e,"base64").toString("utf-8");let t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return new TextDecoder().decode(n)}function K(e){return Et(JSON.stringify(e))}function Y(e){return JSON.parse(kt(e))}function vt(e){if(e instanceof TypeError)return!0;if(e&&typeof e=="object"&&"status"in e){let t=e.status;return t>=500&&t<600}return!1}var Q=class extends Error{status;body;constructor(t,n){super(`HTTP ${t}`),this.status=t,this.body=n}},G=class{facilitatorUrl;cachedSupported=null;cacheTime=0;CACHE_TTL_MS=6e4;timeoutMs;maxRetries;retryBaseMs;constructor(t=U,n){this.facilitatorUrl=t.replace(/\/$/,""),this.timeoutMs=n?.timeoutMs??1e4,this.maxRetries=n?.maxRetries??3,this.retryBaseMs=n?.retryBaseMs??500}async fetchWithTimeout(t,n){let r=new AbortController,s=setTimeout(()=>r.abort(),this.timeoutMs);try{return await fetch(t,{...n,signal:r.signal})}finally{clearTimeout(s)}}async fetchWithRetry(t,n){let r;for(let s=0;s<this.maxRetries;s++)try{let p=await this.fetchWithTimeout(t,n);if(!p.ok&&p.status>=500)throw new Q(p.status,await p.text());return p}catch(p){if(r=p,s<this.maxRetries-1&&vt(p)){let l=this.retryBaseMs*Math.pow(2,s);await new Promise(y=>setTimeout(y,l));continue}throw p}throw r}async getSupported(){let t=Date.now();if(this.cachedSupported&&t-this.cacheTime<this.CACHE_TTL_MS)return this.cachedSupported;let n=await this.fetchWithTimeout(`${this.facilitatorUrl}/supported`);if(!n.ok)throw new Error(`Facilitator /supported returned ${n.status}`);return this.cachedSupported=await n.json(),this.cacheTime=t,this.cachedSupported}async getFeePayer(t){let r=(await this.getSupported()).kinds.find(s=>s.x402Version===2&&(s.scheme==="exact"||s.scheme==="exact-approval")&&s.network===t);if(!r)throw new Error(`Facilitator does not support network "${t}" with a recognized scheme`);return r.extra?.feePayer}async getNetworkExtra(t){return(await this.getSupported()).kinds.find(s=>s.x402Version===2&&(s.scheme==="exact"||s.scheme==="exact-approval"||s.scheme==="batch-settlement")&&s.network===t)?.extra}async verifyPayment(t,n){try{let r=Y(t),s=await this.fetchWithRetry(`${this.facilitatorUrl}/verify`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({x402Version:2,paymentPayload:r,paymentRequirements:n})});return s.ok?await s.json():{isValid:!1,invalidReason:`facilitator_error_${s.status}`}}catch(r){return{isValid:!1,invalidReason:r instanceof Q?`facilitator_error_${r.status}`:r instanceof Error&&r.name==="AbortError"?"facilitator_timeout":r instanceof Error?r.message:"unexpected_verify_error"}}}async settlePayment(t,n){try{let r=Y(t),s=await this.fetchWithRetry(`${this.facilitatorUrl}/settle`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({x402Version:2,paymentPayload:r,paymentRequirements:n})});return s.ok?{...await s.json(),network:n.network}:{success:!1,network:n.network,errorReason:`facilitator_error_${s.status}`}}catch(r){let s=r instanceof Q?`facilitator_error_${r.status}`:r instanceof Error&&r.name==="AbortError"?"facilitator_timeout":r instanceof Error?r.message:"unexpected_settle_error";return{success:!1,network:n.network,errorReason:s}}}};function we(e){if(Se(e))return{address:j,decimals:6};let t=Ne[e];if(t){let n=Oe[t]?.decimals??6;return{address:t,decimals:n}}return{address:j,decimals:6}}function Ie(e){try{let t=Y(e);return t?.accepted?.amount??t?.accepted?.maxAmountRequired}catch{return}}function X(e){let{payTo:t,facilitatorUrl:n=U,network:r=$,defaultTimeoutSeconds:s=60}=e,p=e.asset??we(r),l=e.scheme??"exact",y=new G(n),g=null,h=new Map,S=3e4,c=Date.now();function o(a){let i=(a.maxTimeoutSeconds||s)*1e3;if(h.set(a.payTo,{accept:a,expiresAt:Date.now()+i}),Date.now()-c>S){let w=Date.now();for(let[_,M]of h)M.expiresAt<w&&h.delete(_);c=w}}function f(a){let i=h.get(a);if(i){if(i.expiresAt<Date.now()){h.delete(a);return}return i.accept}}async function m(a){return typeof t=="string"?t:t(a||{})}async function x(){if(g||(g=await y.getNetworkExtra(r)),Se(r)&&!g?.feePayer)throw new Error(`Facilitator does not provide feePayer for network "${r}"`);return{...g?.feePayer?{feePayer:g.feePayer}:{},decimals:g?.decimals??p.decimals,name:g?.name,version:g?.version,...l==="batch-settlement"&&g?.receiverAuthorizer?{receiverAuthorizer:g.receiverAuthorizer}:{}}}async function T(a,i){let{amountAtomic:w,timeoutSeconds:_=s}=i,M=await x(),A={scheme:l,network:r,amount:w,maxAmountRequired:w,asset:p.address,payTo:a,maxTimeoutSeconds:_,extra:M};return o(A),A}async function E(a){let i=await m({amountAtomic:a.amountAtomic,resourceUrl:a.resourceUrl});return T(i,a)}async function d(a){let{resourceUrl:i,description:w,mimeType:_="application/json"}=a,M={url:i,description:w,mimeType:_},A=await E(a);return{x402Version:2,resource:M,accepts:[A],error:"Payment required"}}function u(a){return K(a)}function b(a){return{status:402,headers:{"PAYMENT-REQUIRED":u(a)},body:{}}}async function P(a,i){if(!i){let w=await m({paymentHeader:a});i=f(w),i||(i=await T(w,{amountAtomic:Ie(a)??"0",resourceUrl:""}))}return y.verifyPayment(a,i)}async function R(a,i){if(!i){let w=await m({paymentHeader:a});i=f(w),i||(i=await T(w,{amountAtomic:Ie(a)??"0",resourceUrl:""}))}return y.settlePayment(a,i)}return{buildRequirements:d,encodeRequirements:u,create402Response:b,verifyPayment:P,settlePayment:R,getPaymentAccept:E,network:r,facilitator:y}}var De=new WeakMap;function Ue(e){return De.get(e)}var Mt={base:"base","base-sepolia":"base_sepolia"},_t={base:"eip155:8453","base-sepolia":"eip155:84532"};function Be(e){let t=typeof e=="string"?{secretKey:e}:e,n=t.network??"base",r=Mt[n]??"base",s=_t[n]??"eip155:8453",p=t.apiVersion??"2026-01-28.clover",l=null;async function y(){if(l)return l;try{let{default:h}=await import("stripe");return l=new h(t.secretKey,{apiVersion:p,appInfo:{name:"@dexterai/x402",url:"https://dexter.cash/sdk"}}),l}catch{throw new Error('The "stripe" package is required for stripePayTo(). Install it with: npm install stripe')}}let g=async h=>{if(h.paymentHeader){try{let E=JSON.parse(Buffer.from(h.paymentHeader,"base64").toString()),d=E.payload?.authorization?.to;if(d&&typeof d=="string")return d;let u=E.accepted?.payTo;if(u&&typeof u=="string")return u}catch{}throw new Error("Could not extract deposit address from payment header. Ensure the client is sending a valid x402 PAYMENT-SIGNATURE.")}let S=await y(),c=h.amountAtomic?parseInt(h.amountAtomic,10):1e4,o=Math.max(1,Math.round(c/Math.pow(10,V-2))),m=(await S.paymentIntents.create({amount:o,currency:"usd",payment_method_types:["crypto"],payment_method_data:{type:"crypto"},payment_method_options:{crypto:{mode:"custom"}},confirm:!0})).next_action;if(!m?.crypto_collect_deposit_details)throw new Error("Stripe PaymentIntent did not return crypto deposit details. Ensure your Stripe account has crypto payins enabled: https://support.stripe.com/questions/get-started-with-pay-with-crypto");let x=m.crypto_collect_deposit_details,T=x.deposit_addresses?.[r]?.address;if(!T)throw new Error(`No deposit address found for network "${r}". Available networks: ${Object.keys(x.deposit_addresses||{}).join(", ")}`);return T};return g._x402Defaults={network:s,facilitatorUrl:U},De.set(g,s),g}var ze=require("os"),je=require("path"),Ve=require("@x402/evm/batch-settlement/server");var me=require("@x402/core/server"),$e=require("@x402/core/http"),Le=require("@x402/evm/batch-settlement/server");function Fe(e){let t=e.verbose?console.log.bind(console,"[batch-settlement:seller]"):()=>{},n=new me.HTTPFacilitatorClient({url:e.facilitatorUrl}),r=new Le.BatchSettlementEvmScheme(e.payTo,{storage:e.channelStore}),s=new me.x402ResourceServer(n).register(e.network,r),p=new $e.x402HTTPResourceServer(s,{[e.route]:{accepts:{scheme:"batch-settlement",payTo:e.payTo,price:e.price,network:e.network},description:"batch-settlement protected route",mimeType:"application/json"}}),l=null;function y(){if(l)return l;let c=p.initialize();return c.catch(o=>{l===c&&(l=null),e.verbose?t("resource server initialize() failed:",o):console.error("[batch-settlement:seller] resource server initialize() failed:",o)}),l=c,c}let g=y();function h(c,o){if(c.headersSent)return;for(let[m,x]of Object.entries(o.headers))c.setHeader(m,x);c.status(o.status);let{body:f}=o;f==null?c.end():typeof f=="string"?c.send(f):c.json(f)}return{scheme:r,facilitator:n,handler:async(c,o,f)=>{try{await y();let m=c.get("host")??"",x=`${c.baseUrl??""}${c.path}`||"/",T={getHeader:R=>c.headers[R.toLowerCase()],getMethod:()=>c.method,getPath:()=>x,getUrl:()=>`${c.protocol}://${m}${c.originalUrl}`,getAcceptHeader:()=>c.headers.accept??"",getUserAgent:()=>c.headers["user-agent"]??"",getBody:()=>c.body??{},getQueryParams:()=>c.query,getQueryParam:R=>{let a=c.query[R];if(typeof a=="string"||Array.isArray(a))return a}},E=c.headers["payment-signature"]??c.headers["x-payment"],d={adapter:T,path:x,method:c.method,paymentHeader:E},u=await p.processHTTPRequest(d);if(t("processHTTPRequest ->",u.type),u.type==="no-payment-required"){f();return}if(u.type==="payment-error"){h(o,u.response);return}let b={request:d,responseBody:Buffer.alloc(0)},P=await p.processSettlement(u.paymentPayload,u.paymentRequirements,u.declaredExtensions,b);if(t("processSettlement ->",P.success?"success":`failure:${P.errorReason}`),!P.success){h(o,P.response);return}for(let[R,a]of Object.entries(P.headers))o.headersSent||o.setHeader(R,a);f()}catch(m){t("handler error:",m),o.headersSent||o.status(500).json({error:"Payment processing error"})}},ready:g}}var Re=require("viem"),qe=6;async function Ae(e){let{manager:t,store:n,channelId:r}=e,s=await n.get(r),p=BigInt(s?.chargedCumulativeAmount??"0"),l=BigInt(s?.balance??"0"),y=l>p?l-p:0n,{claims:g,settle:h}=await t.claimAndSettle(),S=await t.refund([r]),c=S.find(o=>o.channel===r)??S[0];return{claimTx:g[0]?.transaction??"",settleTx:h?.transaction??"",refundTx:c?.transaction??"",settledAmount:(0,Re.formatUnits)(p,qe),refundedAmount:(0,Re.formatUnits)(y,qe)}}async function We(e){let t=await e.store.list(),n=[];for(let r of t)try{let s=await Ae({manager:e.manager,store:e.store,channelId:r.channelId});n.push({channelId:r.channelId,...s})}catch(s){n.push({channelId:r.channelId,error:s instanceof Error?s.message:String(s)})}return n}function Ke(e){let t=!1,n=async()=>{try{await e.claimAndSettle()}catch(s){e.onError?.(s)}},r=setInterval(()=>{t||n()},e.claimIntervalMs);return typeof r.unref=="function"&&r.unref(),{async stop(){t||(t=!0,clearInterval(r),await n())}}}var Ct="https://x402.dexter.cash",Nt="GET /",He=new Set(["eip155:8453","eip155:42161","eip155:137"]);function Ot(e){return e===!1?null:e===void 0||e===!0?3e5:(e.claimIntervalSecs??300)*1e3}function Ee(e){if(!He.has(e.network))throw new Error(`batch-settlement is not supported on network "${e.network}" \u2014 supported: ${[...He].join(", ")}`);let t=e.facilitatorUrl??Ct,n=e.channelStore??new Ve.FileChannelStorage({directory:(0,je.join)((0,ze.homedir)(),".dexter-x402","seller-channels")}),r=Fe({payTo:e.payTo,network:e.network,price:e.price,route:e.route??Nt,facilitatorUrl:t,channelStore:n,verbose:e.verbose}),s=r.scheme.createChannelManager(r.facilitator,e.network),p=async()=>{await s.claimAndSettle()},l=Ot(e.autoSettle),y=null;l!==null&&(y=Ke({claimAndSettle:p,claimIntervalMs:l,onError:c=>console.error("[batch-settlement:seller] auto-loop claim pass failed",c)}));let g=n,h=(c,o,f)=>{r.handler(c,o,f)},S=h;return S.middleware=()=>h,S.closeChannel=c=>Ae({manager:s,store:g,channelId:c}),S.closeAll=()=>We({manager:s,store:g}),S.stop=async()=>{y&&await y.stop()},S}function It(e,t){if(typeof e=="string"||typeof e=="function")return e;if(t in e)return e[t];let r=`${t.split(":")[0]}:*`;if(r in e)return e[r];if("*"in e)return e["*"];throw new Error(`No payTo configured for network "${t}"`)}function Ge(e){if(e.scheme==="batch-settlement"){let d=Array.isArray(e.network)?e.network[0]:e.network;if(!d)throw new Error('x402Middleware: scheme "batch-settlement" requires a network');let u=typeof e.payTo=="string"?e.payTo:void 0;if(!u)throw new Error('x402Middleware: scheme "batch-settlement" requires a string payTo address');return Ee({payTo:u,network:d,price:e.amount,facilitatorUrl:e.facilitatorUrl,route:e.batchSettlement?.route,channelStore:e.batchSettlement?.channelStore,autoSettle:e.batchSettlement?.autoSettle,verbose:e.verbose})}let{payTo:t,amount:n,asset:r,description:s,resourceUrl:p,mimeType:l,timeoutSeconds:y,verbose:g=!1,getResourceUrl:h,getAmount:S,getDescription:c}=e,o=g?console.log.bind(console,"[x402:middleware]"):()=>{},f=typeof t=="function"?t._x402Defaults:void 0,m=e.facilitatorUrl??f?.facilitatorUrl,x=e.network?Array.isArray(e.network)?e.network:[e.network]:f?.network?[f.network]:[de],T=new Map;for(let d of x){let u=It(t,d);if(typeof u=="function"){let b=Ue(u);if(b&&d!==b)throw new Error(`stripePayTo is configured for "${b}" but middleware includes network "${d}". Stripe only supports Base deposit addresses. Use a static payTo for other chains.`)}T.set(d,X({payTo:u,network:d,asset:r,facilitatorUrl:m,defaultTimeoutSeconds:y,scheme:e.scheme}))}let E=T.get(x[0]);return async(d,u,b)=>{try{let P=d.headers["payment-signature"];if(!P){o("No payment signature, returning 402");let M=h?.(d)??p??`${d.protocol}://${d.get("host")}${d.originalUrl}`,A=S?.(d)??n,F=c?.(d)??s,k=r?.decimals??V,D={amountAtomic:J(parseFloat(A),k),resourceUrl:M,description:F,mimeType:l,timeoutSeconds:y},q=[],C=null;for(let[,Pe]of T)try{let ee=await Pe.buildRequirements(D);q.push(...ee.accepts),C||(C=ee)}catch(ee){o("Failed to build requirements for a network:",ee)}if(!C||q.length===0){u.status(500).json({error:"Failed to build payment requirements"});return}C={...C,accepts:q};let Z=E.encodeRequirements(C);u.setHeader("PAYMENT-REQUIRED",Z),u.status(402).json({error:"Payment required",accepts:C.accepts,resource:C.resource});return}o("Payment signature received, verifying...");let R=E;try{let A=JSON.parse(Buffer.from(P,"base64").toString())?.accepted?.network;A&&T.has(A)&&(R=T.get(A))}catch{}let a=await R.verifyPayment(P);if(!a.isValid){if(o("Payment verification failed:",a.invalidReason),e.onVerifyFailed)try{await e.onVerifyFailed({reason:a.invalidReason,resourceUrl:`${d.protocol}://${d.get("host")}${d.originalUrl}`})}catch{}u.status(402).json({error:"Payment verification failed",reason:a.invalidReason});return}o("Payment verified, settling...");let i=await R.settlePayment(P);if(!i.success){o("Payment settlement failed:",i.errorReason),u.status(402).json({error:"Payment settlement failed",reason:i.errorReason});return}o("Payment settled:",i.transaction);let w=i.network||x[0];if(e.onSettlement)try{await e.onSettlement({transaction:i.transaction,network:w,payer:a.payer??"",resourceUrl:`${d.protocol}://${d.get("host")}${d.originalUrl}`})}catch{}d.x402={transaction:i.transaction,payer:a.payer??"",network:w};let _={success:!0,transaction:i.transaction,network:w,payer:a.payer??""};if(i.extensions&&(_.extensions=i.extensions),u.setHeader("PAYMENT-RESPONSE",K(_)),e.sponsoredAccess&&i.extensions?.["sponsored-access"]){let M=i.extensions["sponsored-access"],A=M?.info?.recommendations??M?.recommendations;if(A&&A.length>0){if(o("Injecting sponsored-access recommendations into response"),typeof e.sponsoredAccess=="object"&&e.sponsoredAccess.onMatch)try{e.sponsoredAccess.onMatch(A,{transaction:i.transaction,network:w,payer:a.payer??""})}catch{}let F=u.json.bind(u);u.json=function(v){return typeof e.sponsoredAccess=="object"&&e.sponsoredAccess.inject?F(e.sponsoredAccess.inject(v,A)):v&&typeof v=="object"&&!Array.isArray(v)?F({_x402_sponsored:A,...v}):F(v)}}}b()}catch(P){o("Middleware error:",P),u.status(500).json({error:"Payment processing error"})}}}function N(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}var Dt='<svg width="18" height="18" viewBox="0 0 2000 2000" xmlns="http://www.w3.org/2000/svg"><path d="M1000 2000c554.17 0 1000-445.83 1000-1000S1554.17 0 1000 0 0 445.83 0 1000s445.83 1000 1000 1000z" fill="#2775ca"/><path d="M1275 1158.33c0-145.83-87.5-195.83-262.5-216.66-125-16.67-150-50-150-108.34s41.67-95.83 125-95.83c75 0 116.67 25 137.5 87.5 4.17 12.5 16.67 20.83 29.17 20.83h66.66c16.67 0 29.17-12.5 29.17-29.16v-4.17c-16.67-91.67-91.67-162.5-187.5-170.83v-100c0-16.67-12.5-29.17-33.33-33.34h-62.5c-16.67 0-29.17 12.5-33.34 33.34v95.83c-125 16.67-204.16 100-204.16 204.17 0 137.5 83.33 191.66 258.33 212.5 116.67 20.83 154.17 45.83 154.17 112.5s-58.34 112.5-137.5 112.5c-108.34 0-145.84-45.84-158.34-108.34-4.16-16.66-16.66-25-29.16-25h-70.84c-16.66 0-29.16 12.5-29.16 29.17v4.17c16.66 104.16 83.33 179.16 220.83 200v100c0 16.66 12.5 29.16 33.33 33.33h62.5c16.67 0 29.17-12.5 33.34-33.33v-100c125-20.84 208.33-108.34 208.33-220.84z" fill="#fff"/><path d="M787.5 1595.83c-325-116.66-491.67-479.16-370.83-800 62.5-175 200-308.33 370.83-370.83 16.67-8.33 25-20.83 25-41.67V325c0-16.67-8.33-29.17-25-33.33-4.17 0-12.5 0-16.67 4.16-395.83 125-612.5 545.84-487.5 941.67 75 233.33 254.17 412.5 487.5 487.5 16.67 8.33 33.34 0 37.5-16.67 4.17-4.16 4.17-8.33 4.17-16.66v-58.34c0-12.5-12.5-29.16-25-37.5zM1229.17 295.83c-16.67-8.33-33.34 0-37.5 16.67-4.17 4.17-4.17 8.33-4.17 16.67v58.33c0 16.67 12.5 33.33 25 41.67 325 116.66 491.67 479.16 370.83 800-62.5 175-200 308.33-370.83 370.83-16.67 8.33-25 20.83-25 41.67V1700c0 16.67 8.33 29.17 25 33.33 4.17 0 12.5 0 16.67-4.16 395.83-125 612.5-545.84 487.5-941.67-75-237.5-258.34-416.67-487.5-491.67z" fill="#fff"/></svg>',Ut='<svg width="36" height="36" viewBox="0 0 300 300" xmlns="http://www.w3.org/2000/svg"><g><path fill="#F2681A" d="m324.93,313.11c-115.5,0-231,0-350,0l350,0z"/><path fill="#FDFAF5" d="m230.43,50.62c1.1.85 2.19 1.7 3.32 2.57 6.02 4.8 11.77 9.88 17.46 15.07.92.84.92.84 1.86 1.69 1.82 1.69 3.59 3.42 5.35 5.16.61.56 1.22 1.13 1.84 1.71 5.66 5.76 6.18 10.43 6.13 18.3.02 1.16.04 2.32.06 3.52.06 3.83.06 7.65.07 11.48.02 2.68.05 5.35.08 8.03.05 5.6.09 11.21.1 16.81.02 7.15.09 14.31.17 21.46.06 5.53.1 11.05.13 16.58.02 2.64.04 5.27.07 7.91.18 17.58.12 32.82-11.24 47.32-7.35 7.27-16.54 12.06-25.42 17.22-1.97 1.16-3.94 2.33-5.91 3.49-7.16 4.24-14.34 8.44-21.53 12.62-4.8 2.79-9.59 5.6-14.38 8.42-1.25.73-2.5 1.47-3.79 2.23-2.32 1.36-4.64 2.73-6.96 4.1-27.47 16.09-27.47 16.09-42.16 12.93-8.06-2.28-14.94-5.82-22.16-10.02-1.17-.67-2.34-1.34-3.54-2.04-24.55-14.25-43.58-27.03-51.9-55.58-1.07-4.58-1.54-8.92-1.52-13.61.28-9.5.28-9.5-3.3-17.97-1.81-1.49-3.68-2.92-5.59-4.28-9.19-7.06-12.7-20.03-14.18-31.06-.54-5.77-.55-11.56-.6-17.35-.03-1.32-.07-2.63-.1-3.99-.01-1.26-.02-2.53-.03-3.83-.02-1.15-.03-2.29-.05-3.47.72-4.02 1.94-5.36 5.21-7.74 2.89-.53 2.89-.53 6.07-.46 1.71.02 1.71.02 3.46.05 1.19.04 2.37.08 3.59.12 1.2.02 2.41.04 3.65.06 2.97.05 5.93.13 8.9.23.14-1.35.29-2.7.43-4.08.63-5 1.78-9.74 3.14-14.58.22-.79.43-1.59.66-2.4.53-1.92 1.06-3.84 1.6-5.76-1.55-.45-1.55-.45-3.13-.9-9.52-3.52-17.1-10.95-21.37-20.1-3.81-9.26-3.87-20.34-.29-29.68 6.49-13.99 16.36-23.23 30.66-29.01 49.81-17.69 115.79 8.35 155.13 38.85z"/><path fill="#F2671A" d="m142.93,22.62c.86.19 1.73.39 2.62.59 36.12 8.21 68.79 24.98 95.38 50.75 1.02.98 2.03 1.97 3.08 2.98 10.84 10.66 10.84 10.66 11.05 14.62-2.06 3.55-5.44 4.18-9.17 5.3-.79.25-1.59.49-2.41.75-28.13 8.43-60.95 6.37-87.13-7.16-.86-.49-1.71-.97-2.6-1.48-7.37-4.05-12.59-3.36-20.59-1.54-22.76 4-48.47 1.53-68.69-9.74-4.88-3.88-8.23-8.29-10.21-14.22-.93-10.38-.67-18.44 5.83-26.83 19.57-23.38 55.99-20.36 82.83-14z"/><path fill="#F16619" d="m44.93,129.12c27.36-.03 54.72-.05 82.08-.06 12.7-.01 25.41-.01 38.11-.03 11.07-.01 22.14-.02 33.2-.02 5.86 0 11.73-.01 17.59-.01 5.51-.01 11.03-.01 16.54-.01 2.03 0 4.06 0 6.09-.01 2.76-.01 5.52 0 8.28 0 .81 0 1.63-.01 2.47-.01 5.51.02 5.51.02 6.81 1.32.22 3.43.22 3.43 0 7-2.75 2.75-3.42 2.66-7.15 2.82-1.41.07-1.41.07-2.85.14-1.47.05-1.47.05-2.98.11-1.49.07-1.49.07-3 .14-2.45.11-4.9.21-7.35.3-.2 1.3-.4 2.59-.6 3.93-2.57 16.08-5.93 29.89-18.89 40.86-10.35 7.28-21.87 8.49-34.17 7.71-13.11-2.33-22.52-9.19-30.33-19.83-4.49-7.64-4.8-17.05-5.83-25.67-4.24.39-8.47.77-12.83 1.17-.28 1.84-.28 1.84-.56 3.71-2.32 14.39-5.63 23.35-16.95 33.11-2.32 1.67-2.32 1.67-4.65 1.67 4 4.67 9.06 6.59 14.87 8.24 3.79 1.09 3.79 1.09 6.12 3.43-.65 5.31-.65 5.31-2.33 7-8.42-.27-15.13-2.29-22.17-7-1.09-1.21-2.17-2.43-3.25-3.65-2.72-2.81-4.45-3.84-8.36-4.16-1.67-.02-3.34-.02-5.01.01-1.77-.04-3.54-.09-5.3-.15-1.27-.04-1.27-.04-2.56-.08-9.26-.54-17.6-4.56-24.51-10.64-9.58-11.11-11.03-22.56-10.72-36.82.02-1.4.03-2.8.05-4.24.04-3.42.1-6.85.17-10.27z"/><path fill="#F26117" d="m172.68,203.08c7.27.09 13.23 1.97 18.87 6.65 2.88 3.07 3.86 5.12 4.25 9.32-.12 1.01-.24 2.02-.36 3.06-2.55.95-2.55.95-5.83 1.17-3.28-2.84-3.28-2.84-5.83-5.83-.36.58-.71 1.16-1.08 1.75-7.6 11.29-20.06 17.74-33.05 21.09-20.36 3.1-36.81-1.66-53.37-13.73-2.33-2.11-2.33-2.11-4.67-5.61.42-3.45.99-4.49 3.5-7 4.07.37 5.95 2.13 8.75 4.96 9.81 8.93 22.53 11.87 35.51 11.69 11.74-1.05 22.38-5.85 31.57-13.15 2.06-2.45 2.06-2.45 3.5-4.67-1.66.07-1.66.07-3.35.15-3.65-.15-3.65-.15-5.98-2.48.75-6.18 1.46-7.19 7.58-7.36z"/></g></svg>',Bt=`
1
+ "use strict";var ht=Object.create;var ee=Object.defineProperty;var xt=Object.getOwnPropertyDescriptor;var bt=Object.getOwnPropertyNames;var Pt=Object.getPrototypeOf,Tt=Object.prototype.hasOwnProperty;var St=(e,t)=>{for(var n in t)ee(e,n,{get:t[n],enumerable:!0})},ke=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of bt(t))!Tt.call(e,s)&&s!==n&&ee(e,s,{get:()=>t[s],enumerable:!(r=xt(t,s))||r.enumerable});return e};var Pe=(e,t,n)=>(n=e!=null?ht(Pt(e)):{},ke(t||!e||!e.__esModule?ee(n,"default",{value:e,enumerable:!0}):n,e)),wt=e=>ke(ee({},"__esModule",{value:!0}),e);var Gt={};St(Gt,{BASE_MAINNET_NETWORK:()=>F,DEXTER_FACILITATOR_URL:()=>D,FacilitatorClient:()=>j,MODEL_PRICING:()=>I,MODEL_PRICING_MAP:()=>he,MODEL_REGISTRY:()=>O,SOLANA_MAINNET_NETWORK:()=>B,SPONSORED_ACCESS_EXTENSION_KEY:()=>yt.SPONSORED_ACCESS_EXTENSION_KEY,USDC_BASE:()=>le,USDC_MINT:()=>z,countTokens:()=>be,createDynamicPricing:()=>Ye,createTokenPricing:()=>dt,createX402Server:()=>V,escapeHtml:()=>N,estimateCost:()=>ct,findModel:()=>et,formatModelPricing:()=>pt,formatPricing:()=>Qe,formatTokenPricing:()=>gt,getActiveModels:()=>ot,getAvailableModelIds:()=>rt,getAvailableModels:()=>mt,getCheapestModel:()=>at,getModel:()=>ye,getModelsByFamily:()=>st,getModelsByTier:()=>nt,getTextModels:()=>it,isValidModel:()=>ft,isValidModelId:()=>tt,resolveDefaultAsset:()=>Se,stripePayTo:()=>Ue,x402AccessPass:()=>Je,x402BrowserSupport:()=>Ge,x402Middleware:()=>Ve});module.exports=wt(Gt);var B="solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",ve="solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",Me="solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z";var F="eip155:8453",te="eip155:84532",re="eip155:42161",ne="eip155:137",se="eip155:10",oe="eip155:43114",ie="eip155:56",ae="eip155:1187947933",ce="eip155:324705682",pe="eip155:1";var z="EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";var le="0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",At="0x55d398326f99059fF775485246999027B3197955",_e="0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",Ce={[ie]:_e,[F]:le,[te]:"0x036CbD53842c5426634e7929541eC2318f3dCF7e",[re]:"0xaf88d065e77c8cC2239327C5EDb3A432268e5831",[ne]:"0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",[se]:"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",[oe]:"0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",[ae]:"0x85889c8c714505E0c94b30fcfcF64fE3Ac8FCb20",[ce]:"0x2e08028E3C4c2356572E096d8EF835cD5C6030bD",[pe]:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},Ne={[At]:{symbol:"USDT",decimals:18},[_e]:{symbol:"USDC",decimals:18}},ue=6;var Jt={[ie]:56,[F]:8453,[te]:84532,[re]:42161,[ne]:137,[se]:10,[oe]:43114,[ae]:1187947933,[ce]:324705682,[pe]:1},Yt={[B]:"https://api.dexter.cash/api/solana/rpc",[ve]:"https://api.devnet.solana.com",[Me]:"https://api.testnet.solana.com"},Qt={[ie]:"https://bsc-dataseed1.binance.org",[F]:"https://api.dexter.cash/api/base/rpc",[te]:"https://sepolia.base.org",[re]:"https://arb1.arbitrum.io/rpc",[ne]:"https://polygon-rpc.com",[se]:"https://mainnet.optimism.io",[oe]:"https://api.avax.network/ext/bc/C/rpc",[ae]:"https://skale-base.skalenodes.com/v1/base",[ce]:"https://base-sepolia-testnet.skalenodes.com/v1/jubilant-horrible-ancha",[pe]:"https://eth.llamarpc.com"},D="https://x402.dexter.cash",de=B;function X(e,t){if(!Number.isFinite(e))throw new Error(`toAtomicUnits: amount must be finite, got ${e}`);if(e<0)throw new Error(`toAtomicUnits: amount must be non-negative, got ${e}`);if(!Number.isInteger(t)||t<0)throw new Error(`toAtomicUnits: decimals must be a non-negative integer, got ${t}`);let n=Rt(Math.abs(e)),[r,s=""]=n.split("."),c=s.slice(0,t).padEnd(t,"0");return BigInt(r+c).toString()}function Rt(e){let t=e.toString();if(!/[eE]/.test(t))return t;let[n,r]=t.split(/[eE]/),s=parseInt(r,10),c=n.startsWith("-"),l=c?n.slice(1):n,[g,y=""]=l.split("."),u=g+y,S=g.length+s,a;return S<=0?a="0."+"0".repeat(-S)+u:S>=u.length?a=u+"0".repeat(S-u.length):a=u.slice(0,S)+"."+u.slice(S),(c?"-":"")+a}function Te(e){return e.startsWith("solana:")||e==="solana"}function Et(e){if(typeof Buffer<"u")return Buffer.from(e,"utf-8").toString("base64");let t=new TextEncoder().encode(e),n="";for(let r=0;r<t.length;r++)n+=String.fromCharCode(t[r]);return btoa(n)}function kt(e){if(typeof Buffer<"u")return Buffer.from(e,"base64").toString("utf-8");let t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return new TextDecoder().decode(n)}function q(e){return Et(JSON.stringify(e))}function J(e){return JSON.parse(kt(e))}function vt(e){if(e instanceof TypeError)return!0;if(e&&typeof e=="object"&&"status"in e){let t=e.status;return t>=500&&t<600}return!1}var Y=class extends Error{status;body;constructor(t,n){super(`HTTP ${t}`),this.status=t,this.body=n}},j=class{facilitatorUrl;cachedSupported=null;cacheTime=0;CACHE_TTL_MS=6e4;timeoutMs;maxRetries;retryBaseMs;constructor(t=D,n){this.facilitatorUrl=t.replace(/\/$/,""),this.timeoutMs=n?.timeoutMs??1e4,this.maxRetries=n?.maxRetries??3,this.retryBaseMs=n?.retryBaseMs??500}async fetchWithTimeout(t,n){let r=new AbortController,s=setTimeout(()=>r.abort(),this.timeoutMs);try{return await fetch(t,{...n,signal:r.signal})}finally{clearTimeout(s)}}async fetchWithRetry(t,n){let r;for(let s=0;s<this.maxRetries;s++)try{let c=await this.fetchWithTimeout(t,n);if(!c.ok&&c.status>=500)throw new Y(c.status,await c.text());return c}catch(c){if(r=c,s<this.maxRetries-1&&vt(c)){let l=this.retryBaseMs*Math.pow(2,s);await new Promise(g=>setTimeout(g,l));continue}throw c}throw r}async getSupported(){let t=Date.now();if(this.cachedSupported&&t-this.cacheTime<this.CACHE_TTL_MS)return this.cachedSupported;let n=await this.fetchWithTimeout(`${this.facilitatorUrl}/supported`);if(!n.ok)throw new Error(`Facilitator /supported returned ${n.status}`);return this.cachedSupported=await n.json(),this.cacheTime=t,this.cachedSupported}async getFeePayer(t){let r=(await this.getSupported()).kinds.find(s=>s.x402Version===2&&(s.scheme==="exact"||s.scheme==="exact-approval")&&s.network===t);if(!r)throw new Error(`Facilitator does not support network "${t}" with a recognized scheme`);return r.extra?.feePayer}async getNetworkExtra(t){return(await this.getSupported()).kinds.find(s=>s.x402Version===2&&(s.scheme==="exact"||s.scheme==="exact-approval"||s.scheme==="batch-settlement")&&s.network===t)?.extra}async verifyPayment(t,n){try{let r=J(t),s=await this.fetchWithRetry(`${this.facilitatorUrl}/verify`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({x402Version:2,paymentPayload:r,paymentRequirements:n})});return s.ok?await s.json():{isValid:!1,invalidReason:`facilitator_error_${s.status}`}}catch(r){return{isValid:!1,invalidReason:r instanceof Y?`facilitator_error_${r.status}`:r instanceof Error&&r.name==="AbortError"?"facilitator_timeout":r instanceof Error?r.message:"unexpected_verify_error"}}}async settlePayment(t,n){try{let r=J(t),s=await this.fetchWithRetry(`${this.facilitatorUrl}/settle`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({x402Version:2,paymentPayload:r,paymentRequirements:n})});return s.ok?{...await s.json(),network:n.network}:{success:!1,network:n.network,errorReason:`facilitator_error_${s.status}`}}catch(r){let s=r instanceof Y?`facilitator_error_${r.status}`:r instanceof Error&&r.name==="AbortError"?"facilitator_timeout":r instanceof Error?r.message:"unexpected_settle_error";return{success:!1,network:n.network,errorReason:s}}}};function Se(e){if(Te(e))return{address:z,decimals:6};let t=Ce[e];if(t){let n=Ne[t]?.decimals??6;return{address:t,decimals:n}}return{address:z,decimals:6}}function Oe(e){try{let t=J(e);return t?.accepted?.amount??t?.accepted?.maxAmountRequired}catch{return}}function V(e){let{payTo:t,facilitatorUrl:n=D,network:r=B,defaultTimeoutSeconds:s=60}=e,c=e.asset??Se(r),l=e.scheme??"exact",g=new j(n),y=null,u=new Map,S=3e4,a=Date.now();function o(p){let i=(p.maxTimeoutSeconds||s)*1e3;if(u.set(p.payTo,{accept:p,expiresAt:Date.now()+i}),Date.now()-a>S){let w=Date.now();for(let[C,_]of u)_.expiresAt<w&&u.delete(C);a=w}}function h(p){let i=u.get(p);if(i){if(i.expiresAt<Date.now()){u.delete(p);return}return i.accept}}async function f(p){return typeof t=="string"?t:t(p||{})}async function x(){if(y||(y=await g.getNetworkExtra(r)),Te(r)&&!y?.feePayer)throw new Error(`Facilitator does not provide feePayer for network "${r}"`);return{...y?.feePayer?{feePayer:y.feePayer}:{},decimals:y?.decimals??c.decimals,name:y?.name,version:y?.version,...l==="batch-settlement"&&y?.receiverAuthorizer?{receiverAuthorizer:y.receiverAuthorizer}:{}}}async function T(p,i){let{amountAtomic:w,timeoutSeconds:C=s}=i,_=await x(),R={scheme:l,network:r,amount:w,maxAmountRequired:w,asset:c.address,payTo:p,maxTimeoutSeconds:C,extra:_};return o(R),R}async function E(p){let i=await f({amountAtomic:p.amountAtomic,resourceUrl:p.resourceUrl});return T(i,p)}async function m(p){let{resourceUrl:i,description:w,mimeType:C="application/json"}=p,_={url:i,description:w,mimeType:C},R=await E(p);return{x402Version:2,resource:_,accepts:[R],error:"Payment required"}}function d(p){return q(p)}function b(p){return{status:402,headers:{"PAYMENT-REQUIRED":d(p)},body:{}}}async function P(p,i){if(!i){let w=await f({paymentHeader:p});i=h(w),i||(i=await T(w,{amountAtomic:Oe(p)??"0",resourceUrl:""}))}return g.verifyPayment(p,i)}async function A(p,i){if(!i){let w=await f({paymentHeader:p});i=h(w),i||(i=await T(w,{amountAtomic:Oe(p)??"0",resourceUrl:""}))}return g.settlePayment(p,i)}return{buildRequirements:m,encodeRequirements:d,create402Response:b,verifyPayment:P,settlePayment:A,getPaymentAccept:E,network:r,assetDecimals:c.decimals,facilitator:g}}var Ie=new WeakMap;function De(e){return Ie.get(e)}var Mt={base:"base","base-sepolia":"base_sepolia"},_t={base:"eip155:8453","base-sepolia":"eip155:84532"};function Ue(e){let t=typeof e=="string"?{secretKey:e}:e,n=t.network??"base",r=Mt[n]??"base",s=_t[n]??"eip155:8453",c=t.apiVersion??"2026-01-28.clover",l=null;async function g(){if(l)return l;try{let{default:u}=await import("stripe");return l=new u(t.secretKey,{apiVersion:c,appInfo:{name:"@dexterai/x402",url:"https://dexter.cash/sdk"}}),l}catch{throw new Error('The "stripe" package is required for stripePayTo(). Install it with: npm install stripe')}}let y=async u=>{if(u.paymentHeader){try{let E=JSON.parse(Buffer.from(u.paymentHeader,"base64").toString()),m=E.payload?.authorization?.to;if(m&&typeof m=="string")return m;let d=E.accepted?.payTo;if(d&&typeof d=="string")return d}catch{}throw new Error("Could not extract deposit address from payment header. Ensure the client is sending a valid x402 PAYMENT-SIGNATURE.")}let S=await g(),a=u.amountAtomic?parseInt(u.amountAtomic,10):1e4,o=Math.max(1,Math.round(a/Math.pow(10,ue-2))),f=(await S.paymentIntents.create({amount:o,currency:"usd",payment_method_types:["crypto"],payment_method_data:{type:"crypto"},payment_method_options:{crypto:{mode:"custom"}},confirm:!0})).next_action;if(!f?.crypto_collect_deposit_details)throw new Error("Stripe PaymentIntent did not return crypto deposit details. Ensure your Stripe account has crypto payins enabled: https://support.stripe.com/questions/get-started-with-pay-with-crypto");let x=f.crypto_collect_deposit_details,T=x.deposit_addresses?.[r]?.address;if(!T)throw new Error(`No deposit address found for network "${r}". Available networks: ${Object.keys(x.deposit_addresses||{}).join(", ")}`);return T};return y._x402Defaults={network:s,facilitatorUrl:D},Ie.set(y,s),y}var He=require("os"),ze=require("path"),je=require("@x402/evm/batch-settlement/server");var me=require("@x402/core/server"),Be=require("@x402/core/http"),$e=require("@x402/evm/batch-settlement/server");function Le(e){let t=e.verbose?console.log.bind(console,"[batch-settlement:seller]"):()=>{},n=new me.HTTPFacilitatorClient({url:e.facilitatorUrl}),r=new $e.BatchSettlementEvmScheme(e.payTo,{storage:e.channelStore}),s=new me.x402ResourceServer(n).register(e.network,r),c=new Be.x402HTTPResourceServer(s,{[e.route]:{accepts:{scheme:"batch-settlement",payTo:e.payTo,price:e.price,network:e.network},description:"batch-settlement protected route",mimeType:"application/json"}}),l=null;function g(){if(l)return l;let a=c.initialize();return a.catch(o=>{l===a&&(l=null),e.verbose?t("resource server initialize() failed:",o):console.error("[batch-settlement:seller] resource server initialize() failed:",o)}),l=a,a}let y=g();function u(a,o){if(a.headersSent)return;for(let[f,x]of Object.entries(o.headers))a.setHeader(f,x);a.status(o.status);let{body:h}=o;h==null?a.end():typeof h=="string"?a.send(h):a.json(h)}return{scheme:r,facilitator:n,handler:async(a,o,h)=>{try{await g();let f=a.get("host")??"",x=`${a.baseUrl??""}${a.path}`||"/",T={getHeader:A=>a.headers[A.toLowerCase()],getMethod:()=>a.method,getPath:()=>x,getUrl:()=>`${a.protocol}://${f}${a.originalUrl}`,getAcceptHeader:()=>a.headers.accept??"",getUserAgent:()=>a.headers["user-agent"]??"",getBody:()=>a.body??{},getQueryParams:()=>a.query,getQueryParam:A=>{let p=a.query[A];if(typeof p=="string"||Array.isArray(p))return p}},E=a.headers["payment-signature"]??a.headers["x-payment"],m={adapter:T,path:x,method:a.method,paymentHeader:E},d=await c.processHTTPRequest(m);if(t("processHTTPRequest ->",d.type),d.type==="no-payment-required"){h();return}if(d.type==="payment-error"){u(o,d.response);return}let b={request:m,responseBody:Buffer.alloc(0)},P=await c.processSettlement(d.paymentPayload,d.paymentRequirements,d.declaredExtensions,b);if(t("processSettlement ->",P.success?"success":`failure:${P.errorReason}`),!P.success){u(o,P.response);return}for(let[A,p]of Object.entries(P.headers))o.headersSent||o.setHeader(A,p);h()}catch(f){t("handler error:",f),o.headersSent||o.status(500).json({error:"Payment processing error"})}},ready:y}}var we=require("viem"),Fe=6;async function Ae(e){let{manager:t,store:n,channelId:r}=e,s=await n.get(r),c=BigInt(s?.chargedCumulativeAmount??"0"),l=BigInt(s?.balance??"0"),g=l>c?l-c:0n,{claims:y,settle:u}=await t.claimAndSettle(),S=await t.refund([r]),a=S.find(o=>o.channel===r)??S[0];return{claimTx:y[0]?.transaction??"",settleTx:u?.transaction??"",refundTx:a?.transaction??"",settledAmount:(0,we.formatUnits)(c,Fe),refundedAmount:(0,we.formatUnits)(g,Fe)}}async function qe(e){let t=await e.store.list(),n=[];for(let r of t)try{let s=await Ae({manager:e.manager,store:e.store,channelId:r.channelId});n.push({channelId:r.channelId,...s})}catch(s){n.push({channelId:r.channelId,error:s instanceof Error?s.message:String(s)})}return n}function We(e){let t=!1,n=async()=>{try{await e.claimAndSettle()}catch(s){e.onError?.(s)}},r=setInterval(()=>{t||n()},e.claimIntervalMs);return typeof r.unref=="function"&&r.unref(),{async stop(){t||(t=!0,clearInterval(r),await n())}}}var Ct="https://x402.dexter.cash",Nt="GET /",Ke=new Set(["eip155:8453","eip155:42161","eip155:137"]);function Ot(e){return e===!1?null:e===void 0||e===!0?3e5:(e.claimIntervalSecs??300)*1e3}function Re(e){if(!Ke.has(e.network))throw new Error(`batch-settlement is not supported on network "${e.network}" \u2014 supported: ${[...Ke].join(", ")}`);let t=e.facilitatorUrl??Ct,n=e.channelStore??new je.FileChannelStorage({directory:(0,ze.join)((0,He.homedir)(),".dexter-x402","seller-channels")}),r=Le({payTo:e.payTo,network:e.network,price:e.price,route:e.route??Nt,facilitatorUrl:t,channelStore:n,verbose:e.verbose}),s=r.scheme.createChannelManager(r.facilitator,e.network),c=async()=>{await s.claimAndSettle()},l=Ot(e.autoSettle),g=null;l!==null&&(g=We({claimAndSettle:c,claimIntervalMs:l,onError:a=>console.error("[batch-settlement:seller] auto-loop claim pass failed",a)}));let y=n,u=(a,o,h)=>{r.handler(a,o,h)},S=u;return S.middleware=()=>u,S.closeChannel=a=>Ae({manager:s,store:y,channelId:a}),S.closeAll=()=>qe({manager:s,store:y}),S.stop=async()=>{g&&await g.stop()},S}function It(e,t){if(typeof e=="string"||typeof e=="function")return e;if(t in e)return e[t];let r=`${t.split(":")[0]}:*`;if(r in e)return e[r];if("*"in e)return e["*"];throw new Error(`No payTo configured for network "${t}"`)}function Ve(e){if(e.scheme==="batch-settlement"){let m=Array.isArray(e.network)?e.network[0]:e.network;if(!m)throw new Error('x402Middleware: scheme "batch-settlement" requires a network');let d=typeof e.payTo=="string"?e.payTo:void 0;if(!d)throw new Error('x402Middleware: scheme "batch-settlement" requires a string payTo address');return Re({payTo:d,network:m,price:e.amount,facilitatorUrl:e.facilitatorUrl,route:e.batchSettlement?.route,channelStore:e.batchSettlement?.channelStore,autoSettle:e.batchSettlement?.autoSettle,verbose:e.verbose})}let{payTo:t,amount:n,asset:r,description:s,resourceUrl:c,mimeType:l,timeoutSeconds:g,verbose:y=!1,getResourceUrl:u,getAmount:S,getDescription:a}=e,o=y?console.log.bind(console,"[x402:middleware]"):()=>{},h=typeof t=="function"?t._x402Defaults:void 0,f=e.facilitatorUrl??h?.facilitatorUrl,x=e.network?Array.isArray(e.network)?e.network:[e.network]:h?.network?[h.network]:[de],T=new Map;for(let m of x){let d=It(t,m);if(typeof d=="function"){let b=De(d);if(b&&m!==b)throw new Error(`stripePayTo is configured for "${b}" but middleware includes network "${m}". Stripe only supports Base deposit addresses. Use a static payTo for other chains.`)}T.set(m,V({payTo:d,network:m,asset:r,facilitatorUrl:f,defaultTimeoutSeconds:g,scheme:e.scheme}))}let E=T.get(x[0]);return async(m,d,b)=>{try{let P=m.headers["payment-signature"];if(!P){o("No payment signature, returning 402");let _=u?.(m)??c??`${m.protocol}://${m.get("host")}${m.originalUrl}`,R=S?.(m)??n,L=a?.(m)??s,k=parseFloat(R),v=[],M=null;for(let[,Q]of T)try{let H={amountAtomic:X(k,Q.assetDecimals),resourceUrl:_,description:L,mimeType:l,timeoutSeconds:g},Z=await Q.buildRequirements(H);v.push(...Z.accepts),M||(M=Z)}catch(H){o("Failed to build requirements for a network:",H)}if(!M||v.length===0){d.status(500).json({error:"Failed to build payment requirements"});return}M={...M,accepts:v};let G=E.encodeRequirements(M);d.setHeader("PAYMENT-REQUIRED",G),d.status(402).json({error:"Payment required",accepts:M.accepts,resource:M.resource});return}o("Payment signature received, verifying...");let A=E;try{let R=JSON.parse(Buffer.from(P,"base64").toString())?.accepted?.network;R&&T.has(R)&&(A=T.get(R))}catch{}let p=await A.verifyPayment(P);if(!p.isValid){if(o("Payment verification failed:",p.invalidReason),e.onVerifyFailed)try{await e.onVerifyFailed({reason:p.invalidReason,resourceUrl:`${m.protocol}://${m.get("host")}${m.originalUrl}`})}catch{}d.status(402).json({error:"Payment verification failed",reason:p.invalidReason});return}o("Payment verified, settling...");let i=await A.settlePayment(P);if(!i.success){o("Payment settlement failed:",i.errorReason),d.status(402).json({error:"Payment settlement failed",reason:i.errorReason});return}o("Payment settled:",i.transaction);let w=i.network||x[0];if(e.onSettlement)try{await e.onSettlement({transaction:i.transaction,network:w,payer:p.payer??"",resourceUrl:`${m.protocol}://${m.get("host")}${m.originalUrl}`})}catch{}m.x402={transaction:i.transaction,payer:p.payer??"",network:w};let C={success:!0,transaction:i.transaction,network:w,payer:p.payer??""};if(i.extensions&&(C.extensions=i.extensions),d.setHeader("PAYMENT-RESPONSE",q(C)),e.sponsoredAccess&&i.extensions?.["sponsored-access"]){let _=i.extensions["sponsored-access"],R=_?.info?.recommendations??_?.recommendations;if(R&&R.length>0){if(o("Injecting sponsored-access recommendations into response"),typeof e.sponsoredAccess=="object"&&e.sponsoredAccess.onMatch)try{e.sponsoredAccess.onMatch(R,{transaction:i.transaction,network:w,payer:p.payer??""})}catch{}let L=d.json.bind(d);d.json=function(v){return typeof e.sponsoredAccess=="object"&&e.sponsoredAccess.inject?L(e.sponsoredAccess.inject(v,R)):v&&typeof v=="object"&&!Array.isArray(v)?L({_x402_sponsored:R,...v}):L(v)}}}b()}catch(P){o("Middleware error:",P),d.status(500).json({error:"Payment processing error"})}}}function N(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}var Dt='<svg width="18" height="18" viewBox="0 0 2000 2000" xmlns="http://www.w3.org/2000/svg"><path d="M1000 2000c554.17 0 1000-445.83 1000-1000S1554.17 0 1000 0 0 445.83 0 1000s445.83 1000 1000 1000z" fill="#2775ca"/><path d="M1275 1158.33c0-145.83-87.5-195.83-262.5-216.66-125-16.67-150-50-150-108.34s41.67-95.83 125-95.83c75 0 116.67 25 137.5 87.5 4.17 12.5 16.67 20.83 29.17 20.83h66.66c16.67 0 29.17-12.5 29.17-29.16v-4.17c-16.67-91.67-91.67-162.5-187.5-170.83v-100c0-16.67-12.5-29.17-33.33-33.34h-62.5c-16.67 0-29.17 12.5-33.34 33.34v95.83c-125 16.67-204.16 100-204.16 204.17 0 137.5 83.33 191.66 258.33 212.5 116.67 20.83 154.17 45.83 154.17 112.5s-58.34 112.5-137.5 112.5c-108.34 0-145.84-45.84-158.34-108.34-4.16-16.66-16.66-25-29.16-25h-70.84c-16.66 0-29.16 12.5-29.16 29.17v4.17c16.66 104.16 83.33 179.16 220.83 200v100c0 16.66 12.5 29.16 33.33 33.33h62.5c16.67 0 29.17-12.5 33.34-33.33v-100c125-20.84 208.33-108.34 208.33-220.84z" fill="#fff"/><path d="M787.5 1595.83c-325-116.66-491.67-479.16-370.83-800 62.5-175 200-308.33 370.83-370.83 16.67-8.33 25-20.83 25-41.67V325c0-16.67-8.33-29.17-25-33.33-4.17 0-12.5 0-16.67 4.16-395.83 125-612.5 545.84-487.5 941.67 75 233.33 254.17 412.5 487.5 487.5 16.67 8.33 33.34 0 37.5-16.67 4.17-4.16 4.17-8.33 4.17-16.66v-58.34c0-12.5-12.5-29.16-25-37.5zM1229.17 295.83c-16.67-8.33-33.34 0-37.5 16.67-4.17 4.17-4.17 8.33-4.17 16.67v58.33c0 16.67 12.5 33.33 25 41.67 325 116.66 491.67 479.16 370.83 800-62.5 175-200 308.33-370.83 370.83-16.67 8.33-25 20.83-25 41.67V1700c0 16.67 8.33 29.17 25 33.33 4.17 0 12.5 0 16.67-4.16 395.83-125 612.5-545.84 487.5-941.67-75-237.5-258.34-416.67-487.5-491.67z" fill="#fff"/></svg>',Ut='<svg width="36" height="36" viewBox="0 0 300 300" xmlns="http://www.w3.org/2000/svg"><g><path fill="#F2681A" d="m324.93,313.11c-115.5,0-231,0-350,0l350,0z"/><path fill="#FDFAF5" d="m230.43,50.62c1.1.85 2.19 1.7 3.32 2.57 6.02 4.8 11.77 9.88 17.46 15.07.92.84.92.84 1.86 1.69 1.82 1.69 3.59 3.42 5.35 5.16.61.56 1.22 1.13 1.84 1.71 5.66 5.76 6.18 10.43 6.13 18.3.02 1.16.04 2.32.06 3.52.06 3.83.06 7.65.07 11.48.02 2.68.05 5.35.08 8.03.05 5.6.09 11.21.1 16.81.02 7.15.09 14.31.17 21.46.06 5.53.1 11.05.13 16.58.02 2.64.04 5.27.07 7.91.18 17.58.12 32.82-11.24 47.32-7.35 7.27-16.54 12.06-25.42 17.22-1.97 1.16-3.94 2.33-5.91 3.49-7.16 4.24-14.34 8.44-21.53 12.62-4.8 2.79-9.59 5.6-14.38 8.42-1.25.73-2.5 1.47-3.79 2.23-2.32 1.36-4.64 2.73-6.96 4.1-27.47 16.09-27.47 16.09-42.16 12.93-8.06-2.28-14.94-5.82-22.16-10.02-1.17-.67-2.34-1.34-3.54-2.04-24.55-14.25-43.58-27.03-51.9-55.58-1.07-4.58-1.54-8.92-1.52-13.61.28-9.5.28-9.5-3.3-17.97-1.81-1.49-3.68-2.92-5.59-4.28-9.19-7.06-12.7-20.03-14.18-31.06-.54-5.77-.55-11.56-.6-17.35-.03-1.32-.07-2.63-.1-3.99-.01-1.26-.02-2.53-.03-3.83-.02-1.15-.03-2.29-.05-3.47.72-4.02 1.94-5.36 5.21-7.74 2.89-.53 2.89-.53 6.07-.46 1.71.02 1.71.02 3.46.05 1.19.04 2.37.08 3.59.12 1.2.02 2.41.04 3.65.06 2.97.05 5.93.13 8.9.23.14-1.35.29-2.7.43-4.08.63-5 1.78-9.74 3.14-14.58.22-.79.43-1.59.66-2.4.53-1.92 1.06-3.84 1.6-5.76-1.55-.45-1.55-.45-3.13-.9-9.52-3.52-17.1-10.95-21.37-20.1-3.81-9.26-3.87-20.34-.29-29.68 6.49-13.99 16.36-23.23 30.66-29.01 49.81-17.69 115.79 8.35 155.13 38.85z"/><path fill="#F2671A" d="m142.93,22.62c.86.19 1.73.39 2.62.59 36.12 8.21 68.79 24.98 95.38 50.75 1.02.98 2.03 1.97 3.08 2.98 10.84 10.66 10.84 10.66 11.05 14.62-2.06 3.55-5.44 4.18-9.17 5.3-.79.25-1.59.49-2.41.75-28.13 8.43-60.95 6.37-87.13-7.16-.86-.49-1.71-.97-2.6-1.48-7.37-4.05-12.59-3.36-20.59-1.54-22.76 4-48.47 1.53-68.69-9.74-4.88-3.88-8.23-8.29-10.21-14.22-.93-10.38-.67-18.44 5.83-26.83 19.57-23.38 55.99-20.36 82.83-14z"/><path fill="#F16619" d="m44.93,129.12c27.36-.03 54.72-.05 82.08-.06 12.7-.01 25.41-.01 38.11-.03 11.07-.01 22.14-.02 33.2-.02 5.86 0 11.73-.01 17.59-.01 5.51-.01 11.03-.01 16.54-.01 2.03 0 4.06 0 6.09-.01 2.76-.01 5.52 0 8.28 0 .81 0 1.63-.01 2.47-.01 5.51.02 5.51.02 6.81 1.32.22 3.43.22 3.43 0 7-2.75 2.75-3.42 2.66-7.15 2.82-1.41.07-1.41.07-2.85.14-1.47.05-1.47.05-2.98.11-1.49.07-1.49.07-3 .14-2.45.11-4.9.21-7.35.3-.2 1.3-.4 2.59-.6 3.93-2.57 16.08-5.93 29.89-18.89 40.86-10.35 7.28-21.87 8.49-34.17 7.71-13.11-2.33-22.52-9.19-30.33-19.83-4.49-7.64-4.8-17.05-5.83-25.67-4.24.39-8.47.77-12.83 1.17-.28 1.84-.28 1.84-.56 3.71-2.32 14.39-5.63 23.35-16.95 33.11-2.32 1.67-2.32 1.67-4.65 1.67 4 4.67 9.06 6.59 14.87 8.24 3.79 1.09 3.79 1.09 6.12 3.43-.65 5.31-.65 5.31-2.33 7-8.42-.27-15.13-2.29-22.17-7-1.09-1.21-2.17-2.43-3.25-3.65-2.72-2.81-4.45-3.84-8.36-4.16-1.67-.02-3.34-.02-5.01.01-1.77-.04-3.54-.09-5.3-.15-1.27-.04-1.27-.04-2.56-.08-9.26-.54-17.6-4.56-24.51-10.64-9.58-11.11-11.03-22.56-10.72-36.82.02-1.4.03-2.8.05-4.24.04-3.42.1-6.85.17-10.27z"/><path fill="#F26117" d="m172.68,203.08c7.27.09 13.23 1.97 18.87 6.65 2.88 3.07 3.86 5.12 4.25 9.32-.12 1.01-.24 2.02-.36 3.06-2.55.95-2.55.95-5.83 1.17-3.28-2.84-3.28-2.84-5.83-5.83-.36.58-.71 1.16-1.08 1.75-7.6 11.29-20.06 17.74-33.05 21.09-20.36 3.1-36.81-1.66-53.37-13.73-2.33-2.11-2.33-2.11-4.67-5.61.42-3.45.99-4.49 3.5-7 4.07.37 5.95 2.13 8.75 4.96 9.81 8.93 22.53 11.87 35.51 11.69 11.74-1.05 22.38-5.85 31.57-13.15 2.06-2.45 2.06-2.45 3.5-4.67-1.66.07-1.66.07-3.35.15-3.65-.15-3.65-.15-5.98-2.48.75-6.18 1.46-7.19 7.58-7.36z"/></g></svg>',Bt=`
2
2
  @import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Orbitron:wght@500;700&display=swap');
3
3
  *{margin:0;padding:0;box-sizing:border-box}
4
4
  body{font-family:'Inter',system-ui,-apple-system,sans-serif;background:#0a0a0a;color:#e2e8f0;min-height:100vh;display:flex;align-items:center;justify-content:center;padding:1rem}
@@ -233,7 +233,7 @@ if (btn) {
233
233
  });
234
234
  }
235
235
  </script>
236
- `;function Ft(e,t,n,r,s,p){let l="?",y="This resource requires payment",g="";try{let c=JSON.parse(Buffer.from(e,"base64").toString()),o=c.accepts?.[0];if(o){let f=o.amount??o.maxAmountRequired??"0",m=o.extra?.decimals||6;l=(Number(f)/Math.pow(10,m)).toFixed(m>4?4:2),g=o.network||""}c.resource?.description&&(y=c.resource.description)}catch{}let h=g.includes("solana")?"Solana":g.includes("eip155")?"Base":"",S=r.showEndpoint?`<div class="endpoint"><code>${N(n)} ${N(t)}</code></div>`:"";return`<!DOCTYPE html>
236
+ `;function Ft(e,t,n,r,s,c){let l="?",g="This resource requires payment",y="";try{let a=JSON.parse(Buffer.from(e,"base64").toString()),o=a.accepts?.[0];if(o){let h=o.amount??o.maxAmountRequired??"0",f=o.extra?.decimals||6;l=(Number(h)/Math.pow(10,f)).toFixed(f>4?4:2),y=o.network||""}a.resource?.description&&(g=a.resource.description)}catch{}let u=y.includes("solana")?"Solana":y.includes("eip155")?"Base":"",S=r.showEndpoint?`<div class="endpoint"><code>${N(n)} ${N(t)}</code></div>`:"";return`<!DOCTYPE html>
237
237
  <html lang="en">
238
238
  <head>
239
239
  <meta charset="utf-8">
@@ -245,9 +245,9 @@ if (btn) {
245
245
  <div class="card">
246
246
  <div class="crest">${Ut}</div>
247
247
  <h1>${N(r.title)}</h1>
248
- <p class="desc">${N(y)}</p>
248
+ <p class="desc">${N(g)}</p>
249
249
  <div class="price">${Dt}<span id="price-value">${N(l)}</span></div>
250
- <div class="chain">${N(h)}${h?" network":""}</div>
250
+ <div class="chain">${N(u)}${u?" network":""}</div>
251
251
  ${S}
252
252
 
253
253
  <div id="pay-section" class="pay-section" style="display:none">
@@ -277,10 +277,10 @@ if (btn) {
277
277
  data-method="${n}"
278
278
  data-url="${t}"
279
279
  data-rpc="${s}"
280
- data-body="${p?Buffer.from(p).toString("base64"):""}"
280
+ data-body="${c?Buffer.from(c).toString("base64"):""}"
281
281
  ></div>
282
282
  ${Lt}
283
283
  </body>
284
- </html>`}function Xe(e={}){let t={title:e.title??"Payment Required",branding:e.branding??'Powered by <a href="https://docs.dexter.cash/docs/sdk/">Dexter x402</a>',sdkUrl:e.sdkUrl??"https://docs.dexter.cash/docs/sdk/",showEndpoint:e.showEndpoint??!0},n=e.rpcUrl??"https://api.dexter.cash/api/solana/rpc";return(r,s,p)=>{let l=s.json.bind(s);s.json=function(y){if(s.statusCode===402&&r.accepts("html")&&!r.headers["payment-signature"]){let g=s.getHeader("PAYMENT-REQUIRED")||s.getHeader("payment-required");if(g&&typeof g=="string"){let h;if(r.body&&typeof r.body=="object"&&Object.keys(r.body).length>0)try{h=JSON.stringify(r.body)}catch{}let S=Ft(g,r.originalUrl,r.method,t,n,h);return s.setHeader("Content-Security-Policy","default-src 'none'; style-src 'unsafe-inline'; script-src 'unsafe-inline'; connect-src *; img-src data:; frame-ancestors 'none'"),s.setHeader("X-Content-Type-Options","nosniff"),s.status(402).type("html").send(S),s}}return l(y)},p()}}var fe=Te(require("crypto"),1),qt=/^(\d+)(m|h|d|w)$/;function Wt(e){let t=e.match(qt);if(!t)return null;let n=parseInt(t[1],10);switch(t[2]){case"m":return n*60;case"h":return n*3600;case"d":return n*86400;case"w":return n*604800;default:return null}}function Je(e){return e>=604800&&e%604800===0?`${e/604800} week${e/604800>1?"s":""}`:e>=86400&&e%86400===0?`${e/86400} day${e/86400>1?"s":""}`:e>=3600&&e%3600===0?`${e/3600} hour${e/3600>1?"s":""}`:e>=60&&e%60===0?`${e/60} minute${e/60>1?"s":""}`:`${e} second${e>1?"s":""}`}function Kt(e,t){let n=Buffer.from(JSON.stringify({alg:"HS256",typ:"JWT"})).toString("base64url"),r=Buffer.from(JSON.stringify(e)).toString("base64url"),s=fe.default.createHmac("sha256",t).update(`${n}.${r}`).digest("base64url");return`${n}.${r}.${s}`}function Ht(e,t){try{let n=e.split(".");if(n.length!==3)return null;let[r,s,p]=n,l=fe.default.createHmac("sha256",t).update(`${r}.${s}`).digest("base64url");if(p!==l)return null;let y=JSON.parse(Buffer.from(s,"base64url").toString());return y.exp&&Date.now()/1e3>y.exp||y.sub!=="x402-access-pass"?null:y}catch{return null}}function Ye(e){let{payTo:t,network:n=de,asset:r,facilitatorUrl:s,tiers:p,ratePerHour:l,secret:y,issuer:g="x402-access-pass",verbose:h=!1,description:S}=e,c=y??fe.default.randomBytes(32);if(y||console.warn("[x402:access-pass] No secret provided \u2014 access passes will be invalidated on server restart. Set `secret` for production use."),!p&&!l)throw new Error("x402AccessPass: at least one of `tiers` or `ratePerHour` is required");let o=h?console.log.bind(console,"[x402:access-pass]"):()=>{},f=r?.decimals??V,m=[];if(p){for(let[b,P]of Object.entries(p)){let R=Wt(b);if(!R){console.warn(`x402AccessPass: skipping tier "${b}" \u2014 unrecognized duration format (use 5m, 1h, 24h, 7d)`);continue}m.push({id:b,label:Je(R),seconds:R,price:P,priceAtomic:J(parseFloat(P),f)})}m.sort((b,P)=>b.seconds-P.seconds)}let x=X({payTo:t,network:n,asset:r,facilitatorUrl:s}),T={tiers:m.length>0?m:void 0,ratePerHour:l||void 0,issuer:g},E=K(T);function d(b){if(!l)throw new Error("Custom durations not supported \u2014 no ratePerHour configured");let P=b/3600,R=(parseFloat(l)*P).toFixed(f>4?4:2);return{price:R,priceAtomic:J(parseFloat(R),f)}}function u(b){let P=b.query.tier,R=b.query.duration;if(P){let i=m.find(w=>w.id===P);if(i)return{tier:i.id,seconds:i.seconds,price:i.price,priceAtomic:i.priceAtomic,label:i.label}}if(R){let i=parseInt(R,10);if(i>0&&l){let w=d(i);return{tier:"custom",seconds:i,...w,label:Je(i)}}}if(m.length>0){let i=m[0];return{tier:i.id,seconds:i.seconds,price:i.price,priceAtomic:i.priceAtomic,label:i.label}}return{tier:"custom",seconds:3600,...d(3600),label:"1 hour"}}return async(b,P,R)=>{try{let a=b.headers.authorization;if(a?.startsWith("Bearer ")){let k=Ht(a.slice(7),c);if(k)return o("Valid access pass:",k.tier,"| expires:",new Date(k.exp*1e3).toISOString()),b.accessPass={tier:k.tier,duration:k.duration,expiresAt:new Date(k.exp*1e3).toISOString(),payer:k.payer,network:k.network},R();o("Invalid or expired access pass token")}let i=b.headers["payment-signature"];if(i){o("Payment signature received, verifying for pass purchase...");let k=await x.verifyPayment(i);if(!k.isValid){o("Payment verification failed:",k.invalidReason),P.status(402).json({error:"Payment verification failed",reason:k.invalidReason});return}let v=await x.settlePayment(i);if(!v.success){o("Payment settlement failed:",v.errorReason),P.status(402).json({error:"Payment settlement failed",reason:v.errorReason});return}o("Payment settled:",v.transaction);let D=u(b),q=Math.floor(Date.now()/1e3),C={sub:"x402-access-pass",tier:D.tier,duration:D.seconds,iat:q,exp:q+D.seconds,payer:k.payer??"",network:n,iss:g},Z=Kt(C,c);b.x402={transaction:v.transaction,payer:k.payer??"",network:n};let Pe={success:!0,transaction:v.transaction,network:n,payer:k.payer??""};P.setHeader("PAYMENT-RESPONSE",K(Pe)),P.setHeader("ACCESS-PASS",Z),P.json({accessPass:{token:Z,tier:D.tier,duration:D.label,durationSeconds:D.seconds,expiresAt:new Date((q+D.seconds)*1e3).toISOString(),usage:"Include on subsequent requests as: Authorization: Bearer <token>"},transaction:v.transaction,payer:k.payer});return}o("No access pass or payment, returning 402");let w=u(b),_=w.priceAtomic,M=`${b.protocol}://${b.get("host")}${b.originalUrl}`,A=await x.buildRequirements({amountAtomic:_,resourceUrl:M,description:S||`Access pass: ${w.label}`,mimeType:"application/json"}),F=x.encodeRequirements(A);P.setHeader("PAYMENT-REQUIRED",F),P.setHeader("X-ACCESS-PASS-TIERS",E),P.status(402).json({error:"Access pass required",message:"Purchase an access pass to unlock unlimited API access for a time window.",accepts:A.accepts,resource:A.resource,accessPass:{tiers:m.length>0?m:void 0,ratePerHour:l||void 0,usage:"Add ?tier=<id> or ?duration=<seconds> to your payment request to choose a pass duration."}})}catch(a){o("Access pass middleware error:",a),P.status(500).json({error:"Payment processing error",message:a instanceof Error?a.message:"Unknown error"})}}}var ge=require("crypto"),zt=300;function Qe(e){let t={unitSize:e.unitSize,ratePerUnit:e.ratePerUnit,minUsd:e.minUsd??.01,maxUsd:e.maxUsd??1/0,roundingMode:e.roundingMode??"ceil",decimals:e.decimals??6},{unitSize:n,ratePerUnit:r,minUsd:s,maxUsd:p,roundingMode:l,decimals:y}=t;if(n<=0)throw new Error("unitSize must be positive");if(r<=0)throw new Error("ratePerUnit must be positive");if(s<0)throw new Error("minUsd cannot be negative");if(p<s)throw new Error("maxUsd must be >= minUsd");let g=(0,ge.randomBytes)(32);function h(o,f){let m=JSON.stringify({unitSize:n,ratePerUnit:r,minUsd:s,maxUsd:p===1/0?"none":p,roundingMode:l}),x=`${o}|${m}|${f}`;return(0,ge.createHmac)("sha256",g).update(x).digest("hex").slice(0,16)}function S(o){let f=o.length,m=f/n,x;switch(l){case"ceil":x=Math.ceil(m);break;case"floor":x=Math.floor(m);break;case"round":x=Math.round(m);break}f>0&&x===0&&(x=1);let T=x*r;T=Math.max(s,T),T=Math.min(p,T);let E=Math.pow(10,y),d=Math.floor(T*E).toString(),u=Math.floor(Date.now()/1e3),b=h(o,u),P=`${u}.${b}`;return{amountAtomic:d,usdAmount:T,quoteHash:P,units:x,inputLength:f}}function c(o,f){if(!f)return!1;let m=f.indexOf(".");if(m===-1)return!1;let x=parseInt(f.slice(0,m),10),T=f.slice(m+1);if(isNaN(x)||!T)return!1;let E=Math.floor(Date.now()/1e3)-x;if(E<0||E>zt)return!1;let d=h(o,x);if(T.length!==d.length)return!1;let u=0;for(let b=0;b<T.length;b++)u|=T.charCodeAt(b)^d.charCodeAt(b);return u===0}return{calculate:S,validateQuote:c,config:t}}function Ze(e){let t=e.ratePerUnit.toFixed(2),n=e.unitSize.toLocaleString();return`from $${t} per ${n} chars`}var dt=require("crypto");var B={usesMaxCompletionTokens:!1,supportsTemperature:!0,supportsTopP:!0,supportsFrequencyPenalty:!0,supportsPresencePenalty:!0,supportsReasoningEffort:!1,supportsStreaming:!0,supportsSystemMessage:!0,supportsTools:!0,supportsStructuredOutput:!0},H={usesMaxCompletionTokens:!0,supportsTemperature:!1,supportsTopP:!1,supportsFrequencyPenalty:!1,supportsPresencePenalty:!1,supportsReasoningEffort:!1,supportsStreaming:!0,supportsSystemMessage:!0,supportsTools:!0,supportsStructuredOutput:!0},L={usesMaxCompletionTokens:!0,supportsTemperature:!1,supportsTopP:!1,supportsFrequencyPenalty:!1,supportsPresencePenalty:!1,supportsReasoningEffort:!0,supportsStreaming:!0,supportsSystemMessage:!0,supportsTools:!0,supportsStructuredOutput:!0},et={...L,supportsStreaming:!1},O=[{id:"gpt-4o-mini",displayName:"GPT-4o Mini",family:"gpt-4o",tier:"fast",capabilityRank:3,modalities:["text","vision"],apiType:"chat",pricing:{input:.15,output:.6,cached:.075},contextWindow:128e3,defaultMaxOutput:4096,maxOutputTokens:16384,parameters:B,deprecated:!1,description:"Fast, affordable small model with vision support"},{id:"gpt-4.1-nano",displayName:"GPT-4.1 Nano",family:"gpt-4.1",tier:"fast",capabilityRank:2,modalities:["text"],apiType:"chat",pricing:{input:.1,output:.4,cached:.025},contextWindow:128e3,defaultMaxOutput:4096,maxOutputTokens:32768,parameters:B,deprecated:!1,description:"Smallest 4.1 model, very fast and cheap"},{id:"gpt-4.1-mini",displayName:"GPT-4.1 Mini",family:"gpt-4.1",tier:"fast",capabilityRank:4,modalities:["text"],apiType:"chat",pricing:{input:.4,output:1.6,cached:.1},contextWindow:128e3,defaultMaxOutput:4096,maxOutputTokens:32768,parameters:B,deprecated:!1,description:"Balanced 4.1 model, good price/performance"},{id:"gpt-5-nano",displayName:"GPT-5 Nano",family:"gpt-5",tier:"fast",capabilityRank:1,modalities:["text"],apiType:"chat",pricing:{input:.05,output:.4,cached:.005},contextWindow:128e3,defaultMaxOutput:4096,maxOutputTokens:16384,parameters:H,deprecated:!1,description:"Cheapest GPT-5 variant, extremely fast"},{id:"gpt-5-mini",displayName:"GPT-5 Mini",family:"gpt-5",tier:"fast",capabilityRank:5,modalities:["text"],apiType:"chat",pricing:{input:.25,output:2,cached:.025},contextWindow:128e3,defaultMaxOutput:8192,maxOutputTokens:32768,parameters:H,deprecated:!1,description:"Small but capable GPT-5, great value"},{id:"gpt-4o",displayName:"GPT-4o",family:"gpt-4o",tier:"standard",capabilityRank:5,modalities:["text","vision"],apiType:"chat",pricing:{input:2.5,output:10,cached:1.25},contextWindow:128e3,defaultMaxOutput:4096,maxOutputTokens:16384,parameters:B,deprecated:!1,description:"Flagship multimodal model with vision"},{id:"gpt-4.1",displayName:"GPT-4.1",family:"gpt-4.1",tier:"standard",capabilityRank:6,modalities:["text"],apiType:"chat",pricing:{input:2,output:8,cached:.5},contextWindow:1e6,defaultMaxOutput:8192,maxOutputTokens:32768,parameters:B,deprecated:!1,description:"Long context specialist, 1M token window"},{id:"gpt-5",displayName:"GPT-5",family:"gpt-5",tier:"standard",capabilityRank:7,modalities:["text"],apiType:"chat",pricing:{input:1.25,output:10,cached:.125},contextWindow:128e3,defaultMaxOutput:8192,maxOutputTokens:32768,parameters:H,deprecated:!1,description:"Base GPT-5, excellent all-around"},{id:"gpt-5.1",displayName:"GPT-5.1",family:"gpt-5",tier:"standard",capabilityRank:8,modalities:["text"],apiType:"chat",pricing:{input:1.25,output:10,cached:.125},contextWindow:128e3,defaultMaxOutput:8192,maxOutputTokens:32768,parameters:H,deprecated:!1,description:"Improved GPT-5 with better instruction following"},{id:"gpt-5.2",displayName:"GPT-5.2",family:"gpt-5",tier:"standard",capabilityRank:9,modalities:["text"],apiType:"chat",pricing:{input:1.75,output:14,cached:.175},contextWindow:128e3,defaultMaxOutput:8192,maxOutputTokens:32768,parameters:H,deprecated:!1,description:"Latest GPT-5, most capable standard model"},{id:"o1-mini",displayName:"o1 Mini",family:"o1",tier:"reasoning",capabilityRank:3,modalities:["text"],apiType:"chat",pricing:{input:1.1,output:4.4,cached:.55},contextWindow:128e3,defaultMaxOutput:16384,maxOutputTokens:65536,parameters:L,deprecated:!1,description:"Fast reasoning model, good for math/code"},{id:"o3-mini",displayName:"o3 Mini",family:"o3",tier:"reasoning",capabilityRank:4,modalities:["text"],apiType:"chat",pricing:{input:1.1,output:4.4,cached:.55},contextWindow:128e3,defaultMaxOutput:16384,maxOutputTokens:65536,parameters:L,deprecated:!1,description:"Improved mini reasoner with better efficiency"},{id:"o4-mini",displayName:"o4 Mini",family:"o4",tier:"reasoning",capabilityRank:5,modalities:["text"],apiType:"chat",pricing:{input:1.1,output:4.4,cached:.275},contextWindow:128e3,defaultMaxOutput:16384,maxOutputTokens:65536,parameters:L,deprecated:!1,description:"Latest mini reasoner, best reasoning per dollar"},{id:"o3",displayName:"o3",family:"o3",tier:"reasoning",capabilityRank:7,modalities:["text"],apiType:"chat",pricing:{input:2,output:8,cached:.5},contextWindow:2e5,defaultMaxOutput:32768,maxOutputTokens:1e5,parameters:L,deprecated:!1,description:"Full o3 reasoning model, excellent for complex problems"},{id:"o1",displayName:"o1",family:"o1",tier:"reasoning",capabilityRank:8,modalities:["text"],apiType:"chat",pricing:{input:15,output:60,cached:7.5},contextWindow:2e5,defaultMaxOutput:32768,maxOutputTokens:1e5,parameters:L,deprecated:!1,description:"Original full reasoning model, very capable"},{id:"gpt-5-pro",displayName:"GPT-5 Pro",family:"gpt-5",tier:"premium",capabilityRank:7,modalities:["text"],apiType:"chat",pricing:{input:15,output:120},contextWindow:128e3,defaultMaxOutput:16384,maxOutputTokens:32768,parameters:H,deprecated:!1,description:"Enhanced GPT-5 for demanding tasks"},{id:"gpt-5.2-pro",displayName:"GPT-5.2 Pro",family:"gpt-5",tier:"premium",capabilityRank:8,modalities:["text"],apiType:"chat",pricing:{input:21,output:168},contextWindow:128e3,defaultMaxOutput:16384,maxOutputTokens:32768,parameters:H,deprecated:!1,description:"Most capable standard model available"},{id:"o3-pro",displayName:"o3 Pro",family:"o3",tier:"premium",capabilityRank:9,modalities:["text"],apiType:"chat",pricing:{input:20,output:80},contextWindow:2e5,defaultMaxOutput:32768,maxOutputTokens:1e5,parameters:et,deprecated:!1,description:"Premium o3 with extended thinking time"},{id:"o1-pro",displayName:"o1 Pro",family:"o1",tier:"premium",capabilityRank:10,modalities:["text"],apiType:"chat",pricing:{input:150,output:600},contextWindow:2e5,defaultMaxOutput:32768,maxOutputTokens:1e5,parameters:et,deprecated:!1,description:"Most capable reasoning model, extended compute"},{id:"o3-deep-research",displayName:"o3 Deep Research",family:"o3",tier:"specialized",capabilityRank:8,modalities:["text"],apiType:"responses",pricing:{input:10,output:40,cached:2.5},contextWindow:2e5,defaultMaxOutput:32768,maxOutputTokens:1e5,parameters:{...L,supportsStreaming:!1},deprecated:!1,description:"Extended research sessions with web access"},{id:"o4-mini-deep-research",displayName:"o4 Mini Deep Research",family:"o4",tier:"specialized",capabilityRank:6,modalities:["text"],apiType:"responses",pricing:{input:2,output:8,cached:.5},contextWindow:128e3,defaultMaxOutput:16384,maxOutputTokens:65536,parameters:{...L,supportsStreaming:!1},deprecated:!1,description:"Affordable deep research with o4 mini"},{id:"computer-use-preview",displayName:"Computer Use Preview",family:"computer-use",tier:"specialized",capabilityRank:5,modalities:["text","vision"],apiType:"responses",pricing:{input:3,output:12},contextWindow:128e3,defaultMaxOutput:4096,maxOutputTokens:16384,parameters:{...B,supportsReasoningEffort:!1},deprecated:!1,description:"Can control computer interfaces via screenshots"},{id:"gpt-realtime",displayName:"GPT Realtime",family:"gpt-realtime",tier:"specialized",capabilityRank:7,modalities:["text","audio","realtime"],apiType:"chat",pricing:{input:4,output:16,cached:.4},contextWindow:128e3,defaultMaxOutput:4096,maxOutputTokens:4096,parameters:{...B,supportsReasoningEffort:!1},deprecated:!1,description:"Real-time audio conversation model"},{id:"gpt-realtime-mini",displayName:"GPT Realtime Mini",family:"gpt-realtime",tier:"specialized",capabilityRank:4,modalities:["text","audio","realtime"],apiType:"chat",pricing:{input:.6,output:2.4,cached:.06},contextWindow:128e3,defaultMaxOutput:4096,maxOutputTokens:4096,parameters:{...B,supportsReasoningEffort:!1},deprecated:!1,description:"Affordable real-time audio model"},{id:"gpt-4o-2024-05-13",displayName:"GPT-4o (May 2024)",family:"gpt-4o",tier:"standard",capabilityRank:4,modalities:["text","vision"],apiType:"chat",pricing:{input:5,output:15},contextWindow:128e3,defaultMaxOutput:4096,maxOutputTokens:4096,parameters:B,deprecated:!0,description:"Original GPT-4o snapshot, use gpt-4o instead"}],ke=new Map(O.map(e=>[e.id,e]));function ye(e){let t=ke.get(e);if(!t)throw new Error(`Unknown model: ${e}. Use getAvailableModelIds() to see valid options.`);return t}function tt(e){return ke.get(e)}function rt(e){return ke.has(e)}function nt(){return O.map(e=>e.id)}function st(e){return O.filter(t=>t.tier===e&&!t.deprecated).sort((t,n)=>t.capabilityRank-n.capabilityRank)}function ot(e){return O.filter(t=>t.family===e).sort((t,n)=>t.capabilityRank-n.capabilityRank)}function it(){let e={fast:1,standard:2,reasoning:3,premium:4,specialized:5};return O.filter(t=>!t.deprecated).sort((t,n)=>{let r=e[t.tier]-e[n.tier];return r!==0?r:t.capabilityRank-n.capabilityRank})}function at(){return O.filter(e=>!e.deprecated&&e.modalities.includes("text")&&!e.modalities.includes("realtime")&&e.apiType!=="responses").sort((e,t)=>{let n={fast:1,standard:2,reasoning:3,premium:4,specialized:5},r=n[e.tier]-n[t.tier];return r!==0?r:e.capabilityRank-t.capabilityRank})}function ct(e="fast"){let t={fast:1,standard:2,reasoning:3,premium:4,specialized:5},n=t[e];return O.filter(s=>!s.deprecated&&t[s.tier]>=n).sort((s,p)=>s.pricing.input-p.pricing.input)[0]}function pt(e,t,n,r=!1){let s=ye(e),p=r&&s.pricing.cached?t/1e6*s.pricing.cached:t/1e6*s.pricing.input,l=n/1e6*s.pricing.output;return p+l}function lt(e){let t=ye(e);return`$${t.pricing.input.toFixed(2)} in / $${t.pricing.output.toFixed(2)} out per 1M tokens`}var he=Object.fromEntries(O.map(e=>[e.id,{input:e.pricing.input,output:e.pricing.output,cached:e.pricing.cached,maxTokens:e.defaultMaxOutput,tier:e.tier}]));var xe=null;async function jt(){if(xe)return xe;try{return xe=await import("tiktoken"),xe}catch{throw new Error('Token pricing requires the "tiktoken" package. Install with: npm install tiktoken')}}var I=he,z="gpt-4o-mini";async function Vt(e){let t=await jt();try{return t.encoding_for_model(e)}catch{return t.get_encoding("cl100k_base")}}async function be(e,t=z){let n=await Vt(t);try{return n.encode(e).length}finally{n.free()}}function ut(e,t,n,r){let s=JSON.stringify({model:t,rate:n,tokens:r});return(0,dt.createHash)("sha256").update(e+s).digest("hex").slice(0,16)}function mt(e={}){let t=e.model??z,n=I[t],r={input:e.inputRate??n?.input??I[z].input,output:e.outputRate??n?.output??I[z].output,maxTokens:e.maxTokens??n?.maxTokens??4096,tier:e.tier??n?.tier??"custom"},s=e.tokenizer,p={model:t,inputRate:r.input,outputRate:r.output,maxTokens:r.maxTokens,tier:r.tier,tokenizer:s??(o=>be(o,t)),minUsd:e.minUsd??.001,maxUsd:e.maxUsd??50,decimals:e.decimals??6},{minUsd:l,maxUsd:y,decimals:g}=p;async function h(o){return s?s(o):be(o,t)}async function S(o,f){let m=f?`${f}
284
+ </html>`}function Ge(e={}){let t={title:e.title??"Payment Required",branding:e.branding??'Powered by <a href="https://docs.dexter.cash/docs/sdk/">Dexter x402</a>',sdkUrl:e.sdkUrl??"https://docs.dexter.cash/docs/sdk/",showEndpoint:e.showEndpoint??!0},n=e.rpcUrl??"https://api.dexter.cash/api/solana/rpc";return(r,s,c)=>{let l=s.json.bind(s);s.json=function(g){if(s.statusCode===402&&r.accepts("html")&&!r.headers["payment-signature"]){let y=s.getHeader("PAYMENT-REQUIRED")||s.getHeader("payment-required");if(y&&typeof y=="string"){let u;if(r.body&&typeof r.body=="object"&&Object.keys(r.body).length>0)try{u=JSON.stringify(r.body)}catch{}let S=Ft(y,r.originalUrl,r.method,t,n,u);return s.setHeader("Content-Security-Policy","default-src 'none'; style-src 'unsafe-inline'; script-src 'unsafe-inline'; connect-src *; img-src data:; frame-ancestors 'none'"),s.setHeader("X-Content-Type-Options","nosniff"),s.status(402).type("html").send(S),s}}return l(g)},c()}}var fe=Pe(require("crypto"),1),qt=/^(\d+)(m|h|d|w)$/;function Wt(e){let t=e.match(qt);if(!t)return null;let n=parseInt(t[1],10);switch(t[2]){case"m":return n*60;case"h":return n*3600;case"d":return n*86400;case"w":return n*604800;default:return null}}function Xe(e){return e>=604800&&e%604800===0?`${e/604800} week${e/604800>1?"s":""}`:e>=86400&&e%86400===0?`${e/86400} day${e/86400>1?"s":""}`:e>=3600&&e%3600===0?`${e/3600} hour${e/3600>1?"s":""}`:e>=60&&e%60===0?`${e/60} minute${e/60>1?"s":""}`:`${e} second${e>1?"s":""}`}function Kt(e,t){let n=Buffer.from(JSON.stringify({alg:"HS256",typ:"JWT"})).toString("base64url"),r=Buffer.from(JSON.stringify(e)).toString("base64url"),s=fe.default.createHmac("sha256",t).update(`${n}.${r}`).digest("base64url");return`${n}.${r}.${s}`}function Ht(e,t){try{let n=e.split(".");if(n.length!==3)return null;let[r,s,c]=n,l=fe.default.createHmac("sha256",t).update(`${r}.${s}`).digest("base64url");if(c!==l)return null;let g=JSON.parse(Buffer.from(s,"base64url").toString());return g.exp&&Date.now()/1e3>g.exp||g.sub!=="x402-access-pass"?null:g}catch{return null}}function Je(e){let{payTo:t,network:n=de,asset:r,facilitatorUrl:s,tiers:c,ratePerHour:l,secret:g,issuer:y="x402-access-pass",verbose:u=!1,description:S}=e,a=g??fe.default.randomBytes(32);if(g||console.warn("[x402:access-pass] No secret provided \u2014 access passes will be invalidated on server restart. Set `secret` for production use."),!c&&!l)throw new Error("x402AccessPass: at least one of `tiers` or `ratePerHour` is required");let o=u?console.log.bind(console,"[x402:access-pass]"):()=>{},h=r?.decimals??ue,f=[];if(c){for(let[b,P]of Object.entries(c)){let A=Wt(b);if(!A){console.warn(`x402AccessPass: skipping tier "${b}" \u2014 unrecognized duration format (use 5m, 1h, 24h, 7d)`);continue}f.push({id:b,label:Xe(A),seconds:A,price:P,priceAtomic:X(parseFloat(P),h)})}f.sort((b,P)=>b.seconds-P.seconds)}let x=V({payTo:t,network:n,asset:r,facilitatorUrl:s}),T={tiers:f.length>0?f:void 0,ratePerHour:l||void 0,issuer:y},E=q(T);function m(b){if(!l)throw new Error("Custom durations not supported \u2014 no ratePerHour configured");let P=b/3600,A=(parseFloat(l)*P).toFixed(h>4?4:2);return{price:A,priceAtomic:X(parseFloat(A),h)}}function d(b){let P=b.query.tier,A=b.query.duration;if(P){let i=f.find(w=>w.id===P);if(i)return{tier:i.id,seconds:i.seconds,price:i.price,priceAtomic:i.priceAtomic,label:i.label}}if(A){let i=parseInt(A,10);if(i>0&&l){let w=m(i);return{tier:"custom",seconds:i,...w,label:Xe(i)}}}if(f.length>0){let i=f[0];return{tier:i.id,seconds:i.seconds,price:i.price,priceAtomic:i.priceAtomic,label:i.label}}return{tier:"custom",seconds:3600,...m(3600),label:"1 hour"}}return async(b,P,A)=>{try{let p=b.headers.authorization;if(p?.startsWith("Bearer ")){let k=Ht(p.slice(7),a);if(k)return o("Valid access pass:",k.tier,"| expires:",new Date(k.exp*1e3).toISOString()),b.accessPass={tier:k.tier,duration:k.duration,expiresAt:new Date(k.exp*1e3).toISOString(),payer:k.payer,network:k.network},A();o("Invalid or expired access pass token")}let i=b.headers["payment-signature"];if(i){o("Payment signature received, verifying for pass purchase...");let k=await x.verifyPayment(i);if(!k.isValid){o("Payment verification failed:",k.invalidReason),P.status(402).json({error:"Payment verification failed",reason:k.invalidReason});return}let v=await x.settlePayment(i);if(!v.success){o("Payment settlement failed:",v.errorReason),P.status(402).json({error:"Payment settlement failed",reason:v.errorReason});return}o("Payment settled:",v.transaction);let M=d(b),G=Math.floor(Date.now()/1e3),Q={sub:"x402-access-pass",tier:M.tier,duration:M.seconds,iat:G,exp:G+M.seconds,payer:k.payer??"",network:n,iss:y},H=Kt(Q,a);b.x402={transaction:v.transaction,payer:k.payer??"",network:n};let Z={success:!0,transaction:v.transaction,network:n,payer:k.payer??""};P.setHeader("PAYMENT-RESPONSE",q(Z)),P.setHeader("ACCESS-PASS",H),P.json({accessPass:{token:H,tier:M.tier,duration:M.label,durationSeconds:M.seconds,expiresAt:new Date((G+M.seconds)*1e3).toISOString(),usage:"Include on subsequent requests as: Authorization: Bearer <token>"},transaction:v.transaction,payer:k.payer});return}o("No access pass or payment, returning 402");let w=d(b),C=w.priceAtomic,_=`${b.protocol}://${b.get("host")}${b.originalUrl}`,R=await x.buildRequirements({amountAtomic:C,resourceUrl:_,description:S||`Access pass: ${w.label}`,mimeType:"application/json"}),L=x.encodeRequirements(R);P.setHeader("PAYMENT-REQUIRED",L),P.setHeader("X-ACCESS-PASS-TIERS",E),P.status(402).json({error:"Access pass required",message:"Purchase an access pass to unlock unlimited API access for a time window.",accepts:R.accepts,resource:R.resource,accessPass:{tiers:f.length>0?f:void 0,ratePerHour:l||void 0,usage:"Add ?tier=<id> or ?duration=<seconds> to your payment request to choose a pass duration."}})}catch(p){o("Access pass middleware error:",p),P.status(500).json({error:"Payment processing error",message:p instanceof Error?p.message:"Unknown error"})}}}var ge=require("crypto"),zt=300;function Ye(e){let t={unitSize:e.unitSize,ratePerUnit:e.ratePerUnit,minUsd:e.minUsd??.01,maxUsd:e.maxUsd??1/0,roundingMode:e.roundingMode??"ceil",decimals:e.decimals??6},{unitSize:n,ratePerUnit:r,minUsd:s,maxUsd:c,roundingMode:l,decimals:g}=t;if(n<=0)throw new Error("unitSize must be positive");if(r<=0)throw new Error("ratePerUnit must be positive");if(s<0)throw new Error("minUsd cannot be negative");if(c<s)throw new Error("maxUsd must be >= minUsd");let y=(0,ge.randomBytes)(32);function u(o,h){let f=JSON.stringify({unitSize:n,ratePerUnit:r,minUsd:s,maxUsd:c===1/0?"none":c,roundingMode:l}),x=`${o}|${f}|${h}`;return(0,ge.createHmac)("sha256",y).update(x).digest("hex").slice(0,16)}function S(o){let h=o.length,f=h/n,x;switch(l){case"ceil":x=Math.ceil(f);break;case"floor":x=Math.floor(f);break;case"round":x=Math.round(f);break}h>0&&x===0&&(x=1);let T=x*r;T=Math.max(s,T),T=Math.min(c,T);let E=Math.pow(10,g),m=Math.floor(T*E).toString(),d=Math.floor(Date.now()/1e3),b=u(o,d),P=`${d}.${b}`;return{amountAtomic:m,usdAmount:T,quoteHash:P,units:x,inputLength:h}}function a(o,h){if(!h)return!1;let f=h.indexOf(".");if(f===-1)return!1;let x=parseInt(h.slice(0,f),10),T=h.slice(f+1);if(isNaN(x)||!T)return!1;let E=Math.floor(Date.now()/1e3)-x;if(E<0||E>zt)return!1;let m=u(o,x);if(T.length!==m.length)return!1;let d=0;for(let b=0;b<T.length;b++)d|=T.charCodeAt(b)^m.charCodeAt(b);return d===0}return{calculate:S,validateQuote:a,config:t}}function Qe(e){let t=e.ratePerUnit.toFixed(2),n=e.unitSize.toLocaleString();return`from $${t} per ${n} chars`}var ut=require("crypto");var U={usesMaxCompletionTokens:!1,supportsTemperature:!0,supportsTopP:!0,supportsFrequencyPenalty:!0,supportsPresencePenalty:!0,supportsReasoningEffort:!1,supportsStreaming:!0,supportsSystemMessage:!0,supportsTools:!0,supportsStructuredOutput:!0},W={usesMaxCompletionTokens:!0,supportsTemperature:!1,supportsTopP:!1,supportsFrequencyPenalty:!1,supportsPresencePenalty:!1,supportsReasoningEffort:!1,supportsStreaming:!0,supportsSystemMessage:!0,supportsTools:!0,supportsStructuredOutput:!0},$={usesMaxCompletionTokens:!0,supportsTemperature:!1,supportsTopP:!1,supportsFrequencyPenalty:!1,supportsPresencePenalty:!1,supportsReasoningEffort:!0,supportsStreaming:!0,supportsSystemMessage:!0,supportsTools:!0,supportsStructuredOutput:!0},Ze={...$,supportsStreaming:!1},O=[{id:"gpt-4o-mini",displayName:"GPT-4o Mini",family:"gpt-4o",tier:"fast",capabilityRank:3,modalities:["text","vision"],apiType:"chat",pricing:{input:.15,output:.6,cached:.075},contextWindow:128e3,defaultMaxOutput:4096,maxOutputTokens:16384,parameters:U,deprecated:!1,description:"Fast, affordable small model with vision support"},{id:"gpt-4.1-nano",displayName:"GPT-4.1 Nano",family:"gpt-4.1",tier:"fast",capabilityRank:2,modalities:["text"],apiType:"chat",pricing:{input:.1,output:.4,cached:.025},contextWindow:128e3,defaultMaxOutput:4096,maxOutputTokens:32768,parameters:U,deprecated:!1,description:"Smallest 4.1 model, very fast and cheap"},{id:"gpt-4.1-mini",displayName:"GPT-4.1 Mini",family:"gpt-4.1",tier:"fast",capabilityRank:4,modalities:["text"],apiType:"chat",pricing:{input:.4,output:1.6,cached:.1},contextWindow:128e3,defaultMaxOutput:4096,maxOutputTokens:32768,parameters:U,deprecated:!1,description:"Balanced 4.1 model, good price/performance"},{id:"gpt-5-nano",displayName:"GPT-5 Nano",family:"gpt-5",tier:"fast",capabilityRank:1,modalities:["text"],apiType:"chat",pricing:{input:.05,output:.4,cached:.005},contextWindow:128e3,defaultMaxOutput:4096,maxOutputTokens:16384,parameters:W,deprecated:!1,description:"Cheapest GPT-5 variant, extremely fast"},{id:"gpt-5-mini",displayName:"GPT-5 Mini",family:"gpt-5",tier:"fast",capabilityRank:5,modalities:["text"],apiType:"chat",pricing:{input:.25,output:2,cached:.025},contextWindow:128e3,defaultMaxOutput:8192,maxOutputTokens:32768,parameters:W,deprecated:!1,description:"Small but capable GPT-5, great value"},{id:"gpt-4o",displayName:"GPT-4o",family:"gpt-4o",tier:"standard",capabilityRank:5,modalities:["text","vision"],apiType:"chat",pricing:{input:2.5,output:10,cached:1.25},contextWindow:128e3,defaultMaxOutput:4096,maxOutputTokens:16384,parameters:U,deprecated:!1,description:"Flagship multimodal model with vision"},{id:"gpt-4.1",displayName:"GPT-4.1",family:"gpt-4.1",tier:"standard",capabilityRank:6,modalities:["text"],apiType:"chat",pricing:{input:2,output:8,cached:.5},contextWindow:1e6,defaultMaxOutput:8192,maxOutputTokens:32768,parameters:U,deprecated:!1,description:"Long context specialist, 1M token window"},{id:"gpt-5",displayName:"GPT-5",family:"gpt-5",tier:"standard",capabilityRank:7,modalities:["text"],apiType:"chat",pricing:{input:1.25,output:10,cached:.125},contextWindow:128e3,defaultMaxOutput:8192,maxOutputTokens:32768,parameters:W,deprecated:!1,description:"Base GPT-5, excellent all-around"},{id:"gpt-5.1",displayName:"GPT-5.1",family:"gpt-5",tier:"standard",capabilityRank:8,modalities:["text"],apiType:"chat",pricing:{input:1.25,output:10,cached:.125},contextWindow:128e3,defaultMaxOutput:8192,maxOutputTokens:32768,parameters:W,deprecated:!1,description:"Improved GPT-5 with better instruction following"},{id:"gpt-5.2",displayName:"GPT-5.2",family:"gpt-5",tier:"standard",capabilityRank:9,modalities:["text"],apiType:"chat",pricing:{input:1.75,output:14,cached:.175},contextWindow:128e3,defaultMaxOutput:8192,maxOutputTokens:32768,parameters:W,deprecated:!1,description:"Latest GPT-5, most capable standard model"},{id:"o1-mini",displayName:"o1 Mini",family:"o1",tier:"reasoning",capabilityRank:3,modalities:["text"],apiType:"chat",pricing:{input:1.1,output:4.4,cached:.55},contextWindow:128e3,defaultMaxOutput:16384,maxOutputTokens:65536,parameters:$,deprecated:!1,description:"Fast reasoning model, good for math/code"},{id:"o3-mini",displayName:"o3 Mini",family:"o3",tier:"reasoning",capabilityRank:4,modalities:["text"],apiType:"chat",pricing:{input:1.1,output:4.4,cached:.55},contextWindow:128e3,defaultMaxOutput:16384,maxOutputTokens:65536,parameters:$,deprecated:!1,description:"Improved mini reasoner with better efficiency"},{id:"o4-mini",displayName:"o4 Mini",family:"o4",tier:"reasoning",capabilityRank:5,modalities:["text"],apiType:"chat",pricing:{input:1.1,output:4.4,cached:.275},contextWindow:128e3,defaultMaxOutput:16384,maxOutputTokens:65536,parameters:$,deprecated:!1,description:"Latest mini reasoner, best reasoning per dollar"},{id:"o3",displayName:"o3",family:"o3",tier:"reasoning",capabilityRank:7,modalities:["text"],apiType:"chat",pricing:{input:2,output:8,cached:.5},contextWindow:2e5,defaultMaxOutput:32768,maxOutputTokens:1e5,parameters:$,deprecated:!1,description:"Full o3 reasoning model, excellent for complex problems"},{id:"o1",displayName:"o1",family:"o1",tier:"reasoning",capabilityRank:8,modalities:["text"],apiType:"chat",pricing:{input:15,output:60,cached:7.5},contextWindow:2e5,defaultMaxOutput:32768,maxOutputTokens:1e5,parameters:$,deprecated:!1,description:"Original full reasoning model, very capable"},{id:"gpt-5-pro",displayName:"GPT-5 Pro",family:"gpt-5",tier:"premium",capabilityRank:7,modalities:["text"],apiType:"chat",pricing:{input:15,output:120},contextWindow:128e3,defaultMaxOutput:16384,maxOutputTokens:32768,parameters:W,deprecated:!1,description:"Enhanced GPT-5 for demanding tasks"},{id:"gpt-5.2-pro",displayName:"GPT-5.2 Pro",family:"gpt-5",tier:"premium",capabilityRank:8,modalities:["text"],apiType:"chat",pricing:{input:21,output:168},contextWindow:128e3,defaultMaxOutput:16384,maxOutputTokens:32768,parameters:W,deprecated:!1,description:"Most capable standard model available"},{id:"o3-pro",displayName:"o3 Pro",family:"o3",tier:"premium",capabilityRank:9,modalities:["text"],apiType:"chat",pricing:{input:20,output:80},contextWindow:2e5,defaultMaxOutput:32768,maxOutputTokens:1e5,parameters:Ze,deprecated:!1,description:"Premium o3 with extended thinking time"},{id:"o1-pro",displayName:"o1 Pro",family:"o1",tier:"premium",capabilityRank:10,modalities:["text"],apiType:"chat",pricing:{input:150,output:600},contextWindow:2e5,defaultMaxOutput:32768,maxOutputTokens:1e5,parameters:Ze,deprecated:!1,description:"Most capable reasoning model, extended compute"},{id:"o3-deep-research",displayName:"o3 Deep Research",family:"o3",tier:"specialized",capabilityRank:8,modalities:["text"],apiType:"responses",pricing:{input:10,output:40,cached:2.5},contextWindow:2e5,defaultMaxOutput:32768,maxOutputTokens:1e5,parameters:{...$,supportsStreaming:!1},deprecated:!1,description:"Extended research sessions with web access"},{id:"o4-mini-deep-research",displayName:"o4 Mini Deep Research",family:"o4",tier:"specialized",capabilityRank:6,modalities:["text"],apiType:"responses",pricing:{input:2,output:8,cached:.5},contextWindow:128e3,defaultMaxOutput:16384,maxOutputTokens:65536,parameters:{...$,supportsStreaming:!1},deprecated:!1,description:"Affordable deep research with o4 mini"},{id:"computer-use-preview",displayName:"Computer Use Preview",family:"computer-use",tier:"specialized",capabilityRank:5,modalities:["text","vision"],apiType:"responses",pricing:{input:3,output:12},contextWindow:128e3,defaultMaxOutput:4096,maxOutputTokens:16384,parameters:{...U,supportsReasoningEffort:!1},deprecated:!1,description:"Can control computer interfaces via screenshots"},{id:"gpt-realtime",displayName:"GPT Realtime",family:"gpt-realtime",tier:"specialized",capabilityRank:7,modalities:["text","audio","realtime"],apiType:"chat",pricing:{input:4,output:16,cached:.4},contextWindow:128e3,defaultMaxOutput:4096,maxOutputTokens:4096,parameters:{...U,supportsReasoningEffort:!1},deprecated:!1,description:"Real-time audio conversation model"},{id:"gpt-realtime-mini",displayName:"GPT Realtime Mini",family:"gpt-realtime",tier:"specialized",capabilityRank:4,modalities:["text","audio","realtime"],apiType:"chat",pricing:{input:.6,output:2.4,cached:.06},contextWindow:128e3,defaultMaxOutput:4096,maxOutputTokens:4096,parameters:{...U,supportsReasoningEffort:!1},deprecated:!1,description:"Affordable real-time audio model"},{id:"gpt-4o-2024-05-13",displayName:"GPT-4o (May 2024)",family:"gpt-4o",tier:"standard",capabilityRank:4,modalities:["text","vision"],apiType:"chat",pricing:{input:5,output:15},contextWindow:128e3,defaultMaxOutput:4096,maxOutputTokens:4096,parameters:U,deprecated:!0,description:"Original GPT-4o snapshot, use gpt-4o instead"}],Ee=new Map(O.map(e=>[e.id,e]));function ye(e){let t=Ee.get(e);if(!t)throw new Error(`Unknown model: ${e}. Use getAvailableModelIds() to see valid options.`);return t}function et(e){return Ee.get(e)}function tt(e){return Ee.has(e)}function rt(){return O.map(e=>e.id)}function nt(e){return O.filter(t=>t.tier===e&&!t.deprecated).sort((t,n)=>t.capabilityRank-n.capabilityRank)}function st(e){return O.filter(t=>t.family===e).sort((t,n)=>t.capabilityRank-n.capabilityRank)}function ot(){let e={fast:1,standard:2,reasoning:3,premium:4,specialized:5};return O.filter(t=>!t.deprecated).sort((t,n)=>{let r=e[t.tier]-e[n.tier];return r!==0?r:t.capabilityRank-n.capabilityRank})}function it(){return O.filter(e=>!e.deprecated&&e.modalities.includes("text")&&!e.modalities.includes("realtime")&&e.apiType!=="responses").sort((e,t)=>{let n={fast:1,standard:2,reasoning:3,premium:4,specialized:5},r=n[e.tier]-n[t.tier];return r!==0?r:e.capabilityRank-t.capabilityRank})}function at(e="fast"){let t={fast:1,standard:2,reasoning:3,premium:4,specialized:5},n=t[e];return O.filter(s=>!s.deprecated&&t[s.tier]>=n).sort((s,c)=>s.pricing.input-c.pricing.input)[0]}function ct(e,t,n,r=!1){let s=ye(e),c=r&&s.pricing.cached?t/1e6*s.pricing.cached:t/1e6*s.pricing.input,l=n/1e6*s.pricing.output;return c+l}function pt(e){let t=ye(e);return`$${t.pricing.input.toFixed(2)} in / $${t.pricing.output.toFixed(2)} out per 1M tokens`}var he=Object.fromEntries(O.map(e=>[e.id,{input:e.pricing.input,output:e.pricing.output,cached:e.pricing.cached,maxTokens:e.defaultMaxOutput,tier:e.tier}]));var xe=null;async function jt(){if(xe)return xe;try{return xe=await import("tiktoken"),xe}catch{throw new Error('Token pricing requires the "tiktoken" package. Install with: npm install tiktoken')}}var I=he,K="gpt-4o-mini";async function Vt(e){let t=await jt();try{return t.encoding_for_model(e)}catch{return t.get_encoding("cl100k_base")}}async function be(e,t=K){let n=await Vt(t);try{return n.encode(e).length}finally{n.free()}}function lt(e,t,n,r){let s=JSON.stringify({model:t,rate:n,tokens:r});return(0,ut.createHash)("sha256").update(e+s).digest("hex").slice(0,16)}function dt(e={}){let t=e.model??K,n=I[t],r={input:e.inputRate??n?.input??I[K].input,output:e.outputRate??n?.output??I[K].output,maxTokens:e.maxTokens??n?.maxTokens??4096,tier:e.tier??n?.tier??"custom"},s=e.tokenizer,c={model:t,inputRate:r.input,outputRate:r.output,maxTokens:r.maxTokens,tier:r.tier,tokenizer:s??(o=>be(o,t)),minUsd:e.minUsd??.001,maxUsd:e.maxUsd??50,decimals:e.decimals??6},{minUsd:l,maxUsd:g,decimals:y}=c;async function u(o){return s?s(o):be(o,t)}async function S(o,h){let f=h?`${h}
285
285
 
286
- ${o}`:o,x=await h(m),T=x/1e6*r.input;T=Math.max(T,l),T=Math.min(T,y);let E=Math.pow(10,g),d=Math.floor(T*E).toString(),u=ut(o,t,r.input,x);return{amountAtomic:d,usdAmount:T,inputTokens:x,model:t,tier:r.tier,inputRatePerMillion:r.input,outputRatePerMillion:r.output,maxOutputTokens:r.maxTokens,quoteHash:u}}async function c(o,f){if(!f)return!1;let m=await h(o);return ut(o,t,r.input,m)===f}return{calculate:S,validateQuote:c,countTokens:h,config:p,modelInfo:r}}function ft(){return Object.entries(I).map(([e,t])=>({model:e,inputRate:t.input,outputRate:t.output,maxTokens:t.maxTokens,tier:t.tier})).sort((e,t)=>{let n={fast:0,standard:1,reasoning:2,premium:3},r=n[e.tier]-n[t.tier];return r!==0?r:e.inputRate-t.inputRate})}function gt(e){return e in I}function yt(e=z){let t=I[e]??I[z],n=I[e]?e:z;return`$${t.input.toFixed(2)} per 1M tokens (${n})`}var ht=require("@dexterai/x402-ads-types");0&&(module.exports={BASE_MAINNET_NETWORK,DEXTER_FACILITATOR_URL,FacilitatorClient,MODEL_PRICING,MODEL_PRICING_MAP,MODEL_REGISTRY,SOLANA_MAINNET_NETWORK,SPONSORED_ACCESS_EXTENSION_KEY,USDC_BASE,USDC_MINT,countTokens,createDynamicPricing,createTokenPricing,createX402Server,escapeHtml,estimateCost,findModel,formatModelPricing,formatPricing,formatTokenPricing,getActiveModels,getAvailableModelIds,getAvailableModels,getCheapestModel,getModel,getModelsByFamily,getModelsByTier,getTextModels,isValidModel,isValidModelId,resolveDefaultAsset,stripePayTo,x402AccessPass,x402BrowserSupport,x402Middleware});
286
+ ${o}`:o,x=await u(f),T=x/1e6*r.input;T=Math.max(T,l),T=Math.min(T,g);let E=Math.pow(10,y),m=Math.floor(T*E).toString(),d=lt(o,t,r.input,x);return{amountAtomic:m,usdAmount:T,inputTokens:x,model:t,tier:r.tier,inputRatePerMillion:r.input,outputRatePerMillion:r.output,maxOutputTokens:r.maxTokens,quoteHash:d}}async function a(o,h){if(!h)return!1;let f=await u(o);return lt(o,t,r.input,f)===h}return{calculate:S,validateQuote:a,countTokens:u,config:c,modelInfo:r}}function mt(){return Object.entries(I).map(([e,t])=>({model:e,inputRate:t.input,outputRate:t.output,maxTokens:t.maxTokens,tier:t.tier})).sort((e,t)=>{let n={fast:0,standard:1,reasoning:2,premium:3},r=n[e.tier]-n[t.tier];return r!==0?r:e.inputRate-t.inputRate})}function ft(e){return e in I}function gt(e=K){let t=I[e]??I[K],n=I[e]?e:K;return`$${t.input.toFixed(2)} per 1M tokens (${n})`}var yt=require("@dexterai/x402-ads-types");0&&(module.exports={BASE_MAINNET_NETWORK,DEXTER_FACILITATOR_URL,FacilitatorClient,MODEL_PRICING,MODEL_PRICING_MAP,MODEL_REGISTRY,SOLANA_MAINNET_NETWORK,SPONSORED_ACCESS_EXTENSION_KEY,USDC_BASE,USDC_MINT,countTokens,createDynamicPricing,createTokenPricing,createX402Server,escapeHtml,estimateCost,findModel,formatModelPricing,formatPricing,formatTokenPricing,getActiveModels,getAvailableModelIds,getAvailableModels,getCheapestModel,getModel,getModelsByFamily,getModelsByTier,getTextModels,isValidModel,isValidModelId,resolveDefaultAsset,stripePayTo,x402AccessPass,x402BrowserSupport,x402Middleware});
@@ -1,12 +1,12 @@
1
- import { P as PaymentAccept, V as VerifyResponse, e as SettleResponse, f as PayToProvider, g as PaymentRequired } from '../types-l-46PFP6.cjs';
2
- export { j as AccessPassClaims, A as AccessPassClientConfig, d as AccessPassInfo, b as AccessPassTier, h as PayToContext, i as PayToProviderDefaults } from '../types-l-46PFP6.cjs';
1
+ import { P as PaymentAccept, V as VerifyResponse, e as SettleResponse, f as PayToProvider, g as PaymentRequired } from '../types-htvWHuW3.cjs';
2
+ export { j as AccessPassClaims, A as AccessPassClientConfig, d as AccessPassInfo, b as AccessPassTier, h as PayToContext, i as PayToProviderDefaults } from '../types-htvWHuW3.cjs';
3
3
  import * as _x402_evm_batch_settlement_server from '@x402/evm/batch-settlement/server';
4
4
  import { Request, RequestHandler } from 'express';
5
5
  import { SponsoredRecommendation } from '@dexterai/x402-ads-types';
6
6
  export { SPONSORED_ACCESS_EXTENSION_KEY, SponsoredAccessClientConsent, SponsoredAccessPaymentRequiredInfo, SponsoredAccessSettlementInfo, SponsoredRecommendation } from '@dexterai/x402-ads-types';
7
- import { B as BatchSettlementSeller } from '../types-DE4puQ4m.cjs';
7
+ import { B as BatchSettlementSeller } from '../types-pOwQlGEV.cjs';
8
8
  export { b as BASE_MAINNET_NETWORK, D as DEXTER_FACILITATOR_URL, a as SOLANA_MAINNET_NETWORK, c as USDC_BASE, U as USDC_MINT } from '../constants-qU-4U3L-.cjs';
9
- import '../types-Ck3GsR9K.cjs';
9
+ import '../types-XG8QvfyL.cjs';
10
10
  import '@x402/evm/batch-settlement/client';
11
11
 
12
12
  /**
@@ -225,6 +225,13 @@ interface X402Server {
225
225
  getPaymentAccept(options: BuildRequirementsOptions): Promise<PaymentAccept>;
226
226
  /** Get network this server is configured for */
227
227
  readonly network: string;
228
+ /**
229
+ * Decimals of the payment asset on THIS server's network. USDC is 6
230
+ * decimals on every supported chain except BSC, where it is 18. The
231
+ * multi-chain middleware reads this to convert the USD price into the
232
+ * correct atomic amount per network.
233
+ */
234
+ readonly assetDecimals: number;
228
235
  /** Get facilitator client for advanced usage */
229
236
  readonly facilitator: FacilitatorClient;
230
237
  }
@@ -1,12 +1,12 @@
1
- import { P as PaymentAccept, V as VerifyResponse, e as SettleResponse, f as PayToProvider, g as PaymentRequired } from '../types-l-46PFP6.js';
2
- export { j as AccessPassClaims, A as AccessPassClientConfig, d as AccessPassInfo, b as AccessPassTier, h as PayToContext, i as PayToProviderDefaults } from '../types-l-46PFP6.js';
1
+ import { P as PaymentAccept, V as VerifyResponse, e as SettleResponse, f as PayToProvider, g as PaymentRequired } from '../types-htvWHuW3.js';
2
+ export { j as AccessPassClaims, A as AccessPassClientConfig, d as AccessPassInfo, b as AccessPassTier, h as PayToContext, i as PayToProviderDefaults } from '../types-htvWHuW3.js';
3
3
  import * as _x402_evm_batch_settlement_server from '@x402/evm/batch-settlement/server';
4
4
  import { Request, RequestHandler } from 'express';
5
5
  import { SponsoredRecommendation } from '@dexterai/x402-ads-types';
6
6
  export { SPONSORED_ACCESS_EXTENSION_KEY, SponsoredAccessClientConsent, SponsoredAccessPaymentRequiredInfo, SponsoredAccessSettlementInfo, SponsoredRecommendation } from '@dexterai/x402-ads-types';
7
- import { B as BatchSettlementSeller } from '../types-DoSm_OkR.js';
7
+ import { B as BatchSettlementSeller } from '../types-DDBPREEu.js';
8
8
  export { b as BASE_MAINNET_NETWORK, D as DEXTER_FACILITATOR_URL, a as SOLANA_MAINNET_NETWORK, c as USDC_BASE, U as USDC_MINT } from '../constants-qU-4U3L-.js';
9
- import '../types-CSFsiCHc.js';
9
+ import '../types-DllrEG_Z.js';
10
10
  import '@x402/evm/batch-settlement/client';
11
11
 
12
12
  /**
@@ -225,6 +225,13 @@ interface X402Server {
225
225
  getPaymentAccept(options: BuildRequirementsOptions): Promise<PaymentAccept>;
226
226
  /** Get network this server is configured for */
227
227
  readonly network: string;
228
+ /**
229
+ * Decimals of the payment asset on THIS server's network. USDC is 6
230
+ * decimals on every supported chain except BSC, where it is 18. The
231
+ * multi-chain middleware reads this to convert the USD price into the
232
+ * correct atomic amount per network.
233
+ */
234
+ readonly assetDecimals: number;
228
235
  /** Get facilitator client for advanced usage */
229
236
  readonly facilitator: FacilitatorClient;
230
237
  }