@moonpay/cli 1.84.1 → 1.84.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-H3M74Z32.js → chunk-PJACRILH.js} +2 -2
- package/dist/{chunk-QLSNQ4LU.js → chunk-QRMTPUJZ.js} +1 -1
- package/dist/{chunk-YB4YI6XQ.js → chunk-UKDT74TS.js} +1 -1
- package/dist/{chunk-XGFA75FQ.js → chunk-X4JJ5UWK.js} +6 -6
- package/dist/{client-ASHWRSOE.js → client-D4H6JIYN.js} +1 -1
- package/dist/index.js +2 -2
- package/dist/{ledger-3FW7RUN3.js → ledger-4BRGNNSA.js} +2 -2
- package/dist/{mcp-QLRVCHZ2.js → mcp-T7V3FM2O.js} +1 -1
- package/dist/{store-6AGZSQVX.js → store-EVDT4LQ2.js} +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
process.noDeprecation = true; import { createRequire as __createRequire } from "module"; const require = __createRequire(import.meta.url);
|
|
2
|
-
import{a as V,b as T,c as G,d as L,h as D,p as Z}from"./chunk-
|
|
2
|
+
import{a as V,b as T,c as G,d as L,h as D,p as Z}from"./chunk-UKDT74TS.js";import{a as q,f as I}from"./chunk-LMDE72OE.js";import{existsSync as H,readFileSync as N,writeFileSync as he,renameSync as J}from"fs";import{join as S}from"path";import{homedir as ge}from"os";import{randomBytes as we}from"crypto";import*as i from"@open-wallet-standard/core";import Y from"bs58";T();import{z as s}from"zod";var M={"eip155:1":"ethereum","solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp":"solana","bip122:000000000019d6689c085ae165831e93":"bitcoin","tron:mainnet":"tron","ton:mainnet":"ton","fil:mainnet":"filecoin"},E=s.object({solana:s.string().optional(),ethereum:s.string().optional(),bitcoin:s.string().optional(),tron:s.string().optional(),ton:s.string().optional(),filecoin:s.string().optional()}),Q=["base","arbitrum","polygon","optimism","bnb","bnb-testnet","avalanche","tempo","tempo-moderato","ethereum-sepolia","base-sepolia","arbitrum-sepolia","polygon-amoy"];function Ie(e){let t={};if(e.solana&&(t.solana=e.solana,t["solana-devnet"]=e.solana),e.ethereum){t.ethereum=e.ethereum;for(let r of Q)t[r]=e.ethereum}return e.bitcoin&&(t.bitcoin=e.bitcoin),e.tron&&(t.tron=e.tron),e.ton&&(t.ton=e.ton),e.filecoin&&(t.filecoin=e.filecoin),t}var X=s.object({name:s.string(),type:s.literal("hd"),mnemonic:s.string().optional(),addresses:E,createdAt:s.string()}),ee=s.object({name:s.string(),type:s.literal("imported"),chain:s.string().optional(),privateKey:s.string().optional(),addresses:E,createdAt:s.string()}),R=s.enum(["ledger"]),$=s.object({name:s.string(),type:s.literal("hardware"),device:R,addresses:E,createdAt:s.string()}),Te=s.discriminatedUnion("type",[X,ee,$]),De=s.object({name:s.string(),type:s.enum(["hd","imported","hardware"]),device:R.optional(),addresses:s.record(s.string(),s.string()),createdAt:s.string()});import{createHash as U}from"crypto";import{HDKey as x}from"@scure/bip32";import{mnemonicToSeedSync as y}from"@scure/bip39";import{keccak_256 as F}from"@noble/hashes/sha3";import{derivePath as _}from"ed25519-hd-key";import*as j from"bitcoinjs-lib";import te from"ecpair";import*as K from"@bitcoinerlab/secp256k1";import{Keypair as re}from"@solana/web3.js";import ne from"bs58";import{WalletContractV5R1 as oe}from"@ton/ton";import{keyPairFromSeed as ie}from"@ton/crypto";import*as O from"@open-wallet-standard/core";var se=te(K);function z(e,t,r=0){switch(t){case"solana":return ae(e,r);case"ethereum":return le(e,r);case"bitcoin":return fe(e,r);case"tron":return pe(e,r);case"ton":return me(e,r);case"filecoin":return ye(e,r);default:throw new Error(`Unsupported key family for derivation: ${t}`)}}function ae(e,t){let r=y(e),n=`m/44'/501'/${t}'/0'`,{key:o}=_(n,Buffer.from(r).toString("hex")),a=re.fromSeed(Uint8Array.from(o));return{privateKey:a.secretKey,address:a.publicKey.toBase58()}}function le(e,t){let r=y(e),n=x.fromMasterSeed(r),o=`m/44'/60'/${t}'/0/0`,a=n.derive(o);if(!a.privateKey)throw new Error("Failed to derive EVM private key");let l=ce(a.publicKey);return{privateKey:a.privateKey,address:l}}function ce(e){let t=K.pointCompress(e,!1),n=F(t.slice(1)).slice(-20),o="0x"+Buffer.from(n).toString("hex");return de(o)}function de(e){let t=e.toLowerCase().replace("0x",""),r=Buffer.from(F(Buffer.from(t,"utf8"))).toString("hex"),n="0x";for(let o=0;o<t.length;o++)n+=parseInt(r[o],16)>=8?t[o].toUpperCase():t[o];return n}function fe(e,t){let r=y(e),n=x.fromMasterSeed(r),o=`m/84'/0'/${t}'/0/0`,a=n.derive(o);if(!a.privateKey)throw new Error("Failed to derive Bitcoin private key");let l=se.fromPrivateKey(Buffer.from(a.privateKey)),{address:f}=j.payments.p2wpkh({pubkey:Buffer.from(l.publicKey)});if(!f)throw new Error("Failed to derive Bitcoin address");return{privateKey:a.privateKey,address:f}}function pe(e,t){let r=y(e),n=x.fromMasterSeed(r),o=`m/44'/195'/${t}'/0/0`,a=n.derive(o);if(!a.privateKey)throw new Error("Failed to derive Tron private key");let l=ue(a.publicKey);return{privateKey:a.privateKey,address:l}}function ue(e){let t=K.pointCompress(e,!1),n=F(t.slice(1)).slice(-20),o=Buffer.concat([Buffer.from([65]),Buffer.from(n)]),a=U("sha256").update(o).digest(),l=U("sha256").update(a).digest(),f=Buffer.concat([o,l.slice(0,4)]);return ne.encode(f)}function me(e,t){let r=y(e),n=`m/44'/607'/${t}'/0'`,{key:o}=_(n,Buffer.from(r).toString("hex")),a=ie(Buffer.from(o)),l=oe.create({publicKey:Buffer.from(a.publicKey)});return{privateKey:a.secretKey,address:l.address.toString({bounceable:!1})}}function ye(e,t){let r=y(e),n=x.fromMasterSeed(r),o=`m/44'/461'/${t}'/0/0`,a=n.derive(o);if(!a.privateKey)throw new Error("Failed to derive Filecoin private key");let l=O.deriveAddress(e,"filecoin",t);return{privateKey:a.privateKey,address:l}}Z();var b=S(ge(),".config","moonpay"),B=S(b,"hardware-wallets.json");function c(){return b}function ve(e){let t={};for(let r of e){let n=M[r.chainId];n&&(t[n]=r.address)}return t}function h(e){let t=ve(e.accounts);if(!t.filecoin)try{let r=i.exportWallet(e.id,null,c());r&&!r.startsWith("{")&&(t.filecoin=i.deriveAddress(r,"filecoin"))}catch{}return{name:e.name,type:"hd",addresses:t,createdAt:e.createdAt}}function m(){if(!H(B))return[];try{return(JSON.parse(N(B,"utf-8")).wallets??[]).map(t=>$.parse(t))}catch{return[]}}function We(e,t){D();let r=S(b,`.tmp.${we(4).toString("hex")}`);he(r,JSON.stringify(t,null,2),{mode:384}),J(r,e)}function g(e){We(B,{wallets:e})}var w=S(b,"wallets.json");function P(){if(H(w)){process.stderr.write(`Migrating legacy wallets...
|
|
3
3
|
`);let{migrated:e,skipped:t}=xe();process.stderr.write(`Migrated ${e} wallet(s), skipped ${t}.
|
|
4
|
-
`)}}function xe(){if(!H(w))throw new Error("No legacy wallets.json found \u2014 nothing to migrate.");let{getEncryptionKey:e}=(L(),I(G)),{decrypt:t,encryptedFileSchema:r}=(T(),I(V)),n=e();if(!n)throw new Error("Encryption key not found. Set MOONPAY_ENCRYPTION_KEY or ensure OS keychain is accessible.");let o=JSON.parse(N(w,"utf-8")),a=r.parse(o),l=t(a,n),f=JSON.parse(l).wallets??[],p=c(),W=m(),C=0,k=0;for(let d of f){try{i.getWallet(d.name,p),k++;continue}catch{}if(W.some(u=>u.name===d.name)){k++;continue}if(d.type==="hardware")W.push({name:d.name,type:"hardware",device:d.device,addresses:d.addresses,createdAt:d.createdAt});else if(d.type==="hd"&&d.mnemonic)i.importWalletMnemonic(d.name,d.mnemonic,null,null,p);else if(d.type==="imported"&&d.privateKey){let u=d.privateKey;if(!/^[0-9a-fA-F]+$/.test(u)){let A=Y.decode(u);u=Buffer.from(A.length===64?A.slice(0,32):A).toString("hex")}i.importWalletPrivateKey(d.name,u,null,p,null,u,u)}C++}return W.length>0&&g(W),J(w,w+".migrated"),{migrated:C,skipped:k}}function Ke(e){P(),v(e);let t=i.createWallet(e,null,24,c());return h(t)}function Se(e,t){v(e);let r=i.importWalletMnemonic(e,t,null,null,c());return h(r)}function be(e,t){return v(e),h(i.importWalletPrivateKey(e,t,null,c()))}function ke(){P();let e=[];try{e=i.listWallets(c())}catch{}return[...e.map(r=>h(r)),...m()]}function Ae(e){P();let t=c();try{let r=i.getWallet(e,t);return h(r)}catch{}try{for(let r of i.listWallets(t))for(let n of r.accounts)if(n.address===e)return h(r)}catch{}for(let r of m()){if(r.name===e)return r;for(let n of Object.values(r.addresses))if(n===e)return r}return null}function nt(e){let t=Ae(e);if(!t)throw new Error(`Wallet "${e}" not found`);return t}function Ee(e){try{i.deleteWallet(e,c());return}catch{}let t=m(),r=t.findIndex(n=>n.name===e);if(r===-1)throw new Error(`Wallet "${e}" not found`);t.splice(r,1),g(t)}function ot(e,t){if(e===t)return;v(t);try{i.getWallet(e,c()),i.renameWallet(e,t,c());return}catch(o){if(o instanceof Error&&!o.message.includes("not found"))throw o}let r=m(),n=r.find(o=>o.name===e);if(!n)throw new Error(`Wallet "${e}" not found`);n.name=t,g(r)}function it(e){return i.exportWallet(e,null,c())}function $e(e){v(e.name);let t=m();t.push(e),g(t)}function st(e,t){let r=m(),n=r.find(o=>o.name===e);if(!n)throw new Error(`Hardware wallet "${e}" not found`);n.addresses=t,g(r)}function at(e,t,r){return i.signTransaction(e,t,r,null,null,c())}function lt(e,t,r,n){return i.signMessage(e,t,r,null,n??null,null,c())}function ct(e,t,r){return i.signTypedData(e,t,r,null,null,c())}async function dt(e,t){if(e.type==="hardware")throw new Error(`Wallet "${e.name}" is a hardware wallet. Signing must happen on the device.`);let{moonpay:r}=await import("./client-
|
|
4
|
+
`)}}function xe(){if(!H(w))throw new Error("No legacy wallets.json found \u2014 nothing to migrate.");let{getEncryptionKey:e}=(L(),I(G)),{decrypt:t,encryptedFileSchema:r}=(T(),I(V)),n=e();if(!n)throw new Error("Encryption key not found. Set MOONPAY_ENCRYPTION_KEY or ensure OS keychain is accessible.");let o=JSON.parse(N(w,"utf-8")),a=r.parse(o),l=t(a,n),f=JSON.parse(l).wallets??[],p=c(),W=m(),C=0,k=0;for(let d of f){try{i.getWallet(d.name,p),k++;continue}catch{}if(W.some(u=>u.name===d.name)){k++;continue}if(d.type==="hardware")W.push({name:d.name,type:"hardware",device:d.device,addresses:d.addresses,createdAt:d.createdAt});else if(d.type==="hd"&&d.mnemonic)i.importWalletMnemonic(d.name,d.mnemonic,null,null,p);else if(d.type==="imported"&&d.privateKey){let u=d.privateKey;if(!/^[0-9a-fA-F]+$/.test(u)){let A=Y.decode(u);u=Buffer.from(A.length===64?A.slice(0,32):A).toString("hex")}i.importWalletPrivateKey(d.name,u,null,p,null,u,u)}C++}return W.length>0&&g(W),J(w,w+".migrated"),{migrated:C,skipped:k}}function Ke(e){P(),v(e);let t=i.createWallet(e,null,24,c());return h(t)}function Se(e,t){v(e);let r=i.importWalletMnemonic(e,t,null,null,c());return h(r)}function be(e,t,r){return v(e),h(i.importWalletPrivateKey(e,t,null,c(),r))}function ke(){P();let e=[];try{e=i.listWallets(c())}catch{}return[...e.map(r=>h(r)),...m()]}function Ae(e){P();let t=c();try{let r=i.getWallet(e,t);return h(r)}catch{}try{for(let r of i.listWallets(t))for(let n of r.accounts)if(n.address===e)return h(r)}catch{}for(let r of m()){if(r.name===e)return r;for(let n of Object.values(r.addresses))if(n===e)return r}return null}function nt(e){let t=Ae(e);if(!t)throw new Error(`Wallet "${e}" not found`);return t}function Ee(e){try{i.deleteWallet(e,c());return}catch{}let t=m(),r=t.findIndex(n=>n.name===e);if(r===-1)throw new Error(`Wallet "${e}" not found`);t.splice(r,1),g(t)}function ot(e,t){if(e===t)return;v(t);try{i.getWallet(e,c()),i.renameWallet(e,t,c());return}catch(o){if(o instanceof Error&&!o.message.includes("not found"))throw o}let r=m(),n=r.find(o=>o.name===e);if(!n)throw new Error(`Wallet "${e}" not found`);n.name=t,g(r)}function it(e){return i.exportWallet(e,null,c())}function $e(e){v(e.name);let t=m();t.push(e),g(t)}function st(e,t){let r=m(),n=r.find(o=>o.name===e);if(!n)throw new Error(`Hardware wallet "${e}" not found`);n.addresses=t,g(r)}function at(e,t,r){return i.signTransaction(e,t,r,null,null,c())}function lt(e,t,r,n){return i.signMessage(e,t,r,null,n??null,null,c())}function ct(e,t,r){return i.signTypedData(e,t,r,null,null,c())}async function dt(e,t){if(e.type==="hardware")throw new Error(`Wallet "${e.name}" is a hardware wallet. Signing must happen on the device.`);let{moonpay:r}=await import("./client-D4H6JIYN.js"),o=(await r.chain.retrieve({chain:t})).keyFamily,a=i.exportWallet(e.name,null,c());if(a.includes(" "))return z(a,o);let l;if(a.startsWith("{")){let p=JSON.parse(a);l=o==="solana"||o==="ton"?p.ed25519:p.secp256k1}else l=a;let f=Uint8Array.from(Buffer.from(l,"hex"));if(o==="solana"&&f.length===32){let p=q("tweetnacl");f=Uint8Array.from(p.sign.keyPair.fromSeed(f).secretKey)}return{privateKey:f,address:e.addresses[o]??""}}var Fe=ke,ft=Ee;function Be(e){if(e.type==="hardware"){$e(e);return}if(e.type==="hd"&&e.mnemonic){Se(e.name,e.mnemonic);return}if(e.type==="imported"&&e.privateKey){let t=e.privateKey;if(t.startsWith("0x"))t=t.slice(2);else if(!/^[0-9a-fA-F]+$/.test(t)){let r=Y.decode(t);t=Buffer.from(r.length===64?r.slice(0,32):r).toString("hex")}be(e.name,t,"solana");return}Ke(e.name)}function pt(e){for(let t of e)Be(t)}function ut(e){let t=Fe();e(t),g(t.filter(r=>r.type==="hardware"))}function v(e){try{throw i.getWallet(e,c()),new Error(`Wallet "${e}" already exists`)}catch(t){if(t instanceof Error&&t.message.includes("already exists"))throw t}if(m().some(t=>t.name===e))throw new Error(`Wallet "${e}" already exists`)}export{E as a,Ie as b,R as c,De as d,z as e,c as f,P as g,xe as h,Ke as i,Se as j,be as k,ke as l,Ae as m,nt as n,Ee as o,ot as p,it as q,$e as r,st as s,at as t,lt as u,ct as v,dt as w,Fe as x,ft as y,Be as z,pt as A,ut as B};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
process.noDeprecation = true; import { createRequire as __createRequire } from "module"; const require = __createRequire(import.meta.url);
|
|
2
|
-
import{f as Tt,g as Bt,j as xt,m as Vt,n as bt,o as St,p as Ht}from"./chunk-YB4YI6XQ.js";var i=class extends Error{constructor(r,n,u){super(r);this.status=n;this.toolName=u;this.name="MoonPayError"}},c=class extends i{constructor(t="Authentication required"){super(t,401),this.name="AuthError"}},a=class extends i{constructor(t="Rate limit exceeded"){super(t,429),this.name="RateLimitError"}},l=class extends i{constructor(t,r){super(t,400,r),this.name="ValidationError"}},s=class extends i{constructor(t){super(`Tool not found: ${t}`,404,t),this.name="ToolNotFoundError"}},p=class extends i{constructor(t,r){super(`Tool "${t}" has been renamed to "${r}"`,410,t),this.name="ToolRenamedError",this.newName=r}};var Ut="https://agents.moonpay.com",Et=36e4,h=class{constructor(t={}){this.baseUrl=(t.baseUrl??Ut).replace(/\/$/,""),this.auth=t.auth??{type:"none"},this.timeout=t.timeout??Et,this.headers=t.headers??{}}async _call(t,r){let n=`${this.baseUrl}/api/tools/${encodeURIComponent(t)}`,u=await this.buildHeaders(),o=await fetch(n,{method:"POST",headers:u,body:JSON.stringify(r),signal:AbortSignal.timeout(this.timeout)});if(o.status===401&&this.auth.type==="bearer"&&this.auth.refreshToken)try{let qt=await this.auth.refreshToken();u.Authorization=`Bearer ${qt}`,o=await fetch(n,{method:"POST",headers:u,body:JSON.stringify(r),signal:AbortSignal.timeout(this.timeout)})}catch{throw new c("Token refresh failed")}return this.handleResponse(o,t)}async buildHeaders(){let t={"Content-Type":"application/json",...this.headers};if(this.auth.type==="bearer"){let r=await this.auth.getToken();r&&(t.Authorization=`Bearer ${r}`)}return t}async handleResponse(t,r){if(t.ok)return t.json();let n;try{n=await t.json()}catch{n={error:t.statusText}}let u=n?.error??n?.message,o=typeof u=="string"?u:u?JSON.stringify(u):`Request failed with status ${t.status}`;switch(t.status){case 400:throw new l(o,r);case 401:throw new c(o);case 404:throw new s(r);case 410:throw new p(r,n?.newName??"unknown");case 429:throw new a(o);default:throw new i(o,t.status,r)}}};var _=class{constructor(t){this.client=t}create(t){return this.client._call("app_activation_create",t)}},O=class{constructor(t){this.client=t}get activation(){return new _(this.client)}},v=class{constructor(t){this.client=t}build(t){return this.client._call("card_delegation_approve_transaction_build",t)}},P=class{constructor(t){this.client=t}get transaction(){return new v(this.client)}},C=class{constructor(t){this.client=t}build(t){return this.client._call("card_delegation_revoke_transaction_build",t)}},y=class{constructor(t){this.client=t}get transaction(){return new C(this.client)}},I=class{constructor(t){this.client=t}retrieve(t){return this.client._call("card_delegation_token_retrieve",t)}},g=class{constructor(t){this.client=t}get approve(){return new P(this.client)}get revoke(){return new y(this.client)}get token(){return new I(this.client)}},k=class{constructor(t){this.client=t}check(t){return this.client._call("card_onboarding_check",t)}finish(t){return this.client._call("card_onboarding_finish",t)}start(t){return this.client._call("card_onboarding_start",t)}},A=class{constructor(t){this.client=t}list(t){return this.client._call("card_transaction_list",t)}},R=class{constructor(t){this.client=t}retrieve(t){return this.client._call("card_user_retrieve",t)}},f=class{constructor(t){this.client=t}check(t){return this.client._call("card_wallet_check",t)}link(t){return this.client._call("card_wallet_link",t)}list(t){return this.client._call("card_wallet_list",t)}unlink(t){return this.client._call("card_wallet_unlink",t)}},w=class{constructor(t){this.client=t}get delegation(){return new g(this.client)}get onboarding(){return new k(this.client)}get transaction(){return new A(this.client)}get user(){return new R(this.client)}get wallet(){return new f(this.client)}create(t){return this.client._call("card_create",t)}freeze(t){return this.client._call("card_freeze",t)}retrieve(t){return this.client._call("card_retrieve",t)}reveal(t){return this.client._call("card_reveal",t)}unfreeze(t){return this.client._call("card_unfreeze",t)}},L=class{constructor(t){this.client=t}list(t){return this.client._call("chain_list",t)}retrieve(t){return this.client._call("chain_retrieve",t)}},M=class{constructor(t){this.client=t}create(t){return this.client._call("cli_activation_create",t)}update(t){return this.client._call("cli_activation_update",t)}},T=class{constructor(t){this.client=t}get activation(){return new M(this.client)}},x=class{constructor(t){this.client=t}add(t){return this.client._call("commerce_cart_add",t)}remove(t){return this.client._call("commerce_cart_remove",t)}retrieve(t){return this.client._call("commerce_cart_retrieve",t)}update(t){return this.client._call("commerce_cart_update",t)}},V=class{constructor(t){this.client=t}pay(t){return this.client._call("commerce_checkout_pay",t)}start(t){return this.client._call("commerce_checkout_start",t)}},b=class{constructor(t){this.client=t}retrieve(t){return this.client._call("commerce_product_retrieve",t)}search(t){return this.client._call("commerce_product_search",t)}},S=class{constructor(t){this.client=t}list(t){return this.client._call("commerce_store_list",t)}retrieve(t){return this.client._call("commerce_store_retrieve",t)}},q=class{constructor(t){this.client=t}get cart(){return new x(this.client)}get checkout(){return new V(this.client)}get product(){return new b(this.client)}get store(){return new S(this.client)}search(t){return this.client._call("commerce_search",t)}},B=class{constructor(t){this.client=t}list(t){return this.client._call("deposit_transaction_list",t)}},H=class{constructor(t){this.client=t}get transaction(){return new B(this.client)}create(t){return this.client._call("deposit_create",t)}retrieve(t){return this.client._call("deposit_retrieve",t)}},U=class{constructor(t){this.client=t}create(t){return this.client._call("feedback_create",t)}},E=class{constructor(t){this.client=t}buy(t){return this.client._call("gateway_buy",t)}search(t){return this.client._call("gateway_search",t)}},W=class{constructor(t){this.client=t}retrieve(t){return this.client._call("hyperliquid_balance_retrieve",t)}},D=class{constructor(t){this.client=t}list(t){return this.client._call("hyperliquid_candle_list",t)}},F=class{constructor(t){this.client=t}create(t){return this.client._call("hyperliquid_deposit_create",t)}},z=class{constructor(t){this.client=t}submit(t){return this.client._call("hyperliquid_exchange_submit",t)}},$=class{constructor(t){this.client=t}list(t){return this.client._call("hyperliquid_funding_payment_list",t)}},G=class{constructor(t){this.client=t}get payment(){return new $(this.client)}},K=class{constructor(t){this.client=t}list(t){return this.client._call("hyperliquid_market_list",t)}},j=class{constructor(t){this.client=t}create(t){return this.client._call("hyperliquid_order_create",t)}list(t){return this.client._call("hyperliquid_order_list",t)}},J=class{constructor(t){this.client=t}retrieve(t){return this.client._call("hyperliquid_orderbook_retrieve",t)}},Q=class{constructor(t){this.client=t}list(t){return this.client._call("hyperliquid_position_list",t)}},X=class{constructor(t){this.client=t}list(t){return this.client._call("hyperliquid_predicted_funding_list",t)}},Y=class{constructor(t){this.client=t}get funding(){return new X(this.client)}},Z=class{constructor(t){this.client=t}list(t){return this.client._call("hyperliquid_price_list",t)}},N=class{constructor(t){this.client=t}list(t){return this.client._call("hyperliquid_trade_list",t)}},tt=class{constructor(t){this.client=t}get balance(){return new W(this.client)}get candle(){return new D(this.client)}get deposit(){return new F(this.client)}get exchange(){return new z(this.client)}get funding(){return new G(this.client)}get market(){return new K(this.client)}get order(){return new j(this.client)}get orderbook(){return new J(this.client)}get position(){return new Q(this.client)}get predicted(){return new Y(this.client)}get price(){return new Z(this.client)}get trade(){return new N(this.client)}},et=class{constructor(t){this.client=t}redeem(t){return this.client._call("polymarket_position_redeem",t)}sell(t){return this.client._call("polymarket_position_sell",t)}},rt=class{constructor(t){this.client=t}get position(){return new et(this.client)}},it=class{constructor(t){this.client=t}list(t){return this.client._call("prediction-market_event_list",t)}retrieve(t){return this.client._call("prediction-market_event_retrieve",t)}search(t){return this.client._call("prediction-market_event_search",t)}},nt=class{constructor(t){this.client=t}list(t){return this.client._call("prediction-market_market_ohlcv_list",t)}},ut=class{constructor(t){this.client=t}get ohlcv(){return new nt(this.client)}},ot=class{constructor(t){this.client=t}retrieve(t){return this.client._call("prediction-market_order_retrieve",t)}},ct=class{constructor(t){this.client=t}buy(t){return this.client._call("prediction-market_position_buy",t)}list(t){return this.client._call("prediction-market_position_list",t)}redeem(t){return this.client._call("prediction-market_position_redeem",t)}sell(t){return this.client._call("prediction-market_position_sell",t)}},at=class{constructor(t){this.client=t}get event(){return new it(this.client)}get market(){return new ut(this.client)}get order(){return new ot(this.client)}get position(){return new ct(this.client)}},lt=class{constructor(t){this.client=t}build(t){return this.client._call("swaps_transaction_build",t)}},st=class{constructor(t){this.client=t}get transaction(){return new lt(this.client)}},pt=class{constructor(t){this.client=t}list(t){return this.client._call("token_balance_list",t)}},dt=class{constructor(t){this.client=t}list(t){return this.client._call("token_holder_list",t)}},ht=class{constructor(t){this.client=t}list(t){return this.client._call("token_ohlcv_list",t)}},mt=class{constructor(t){this.client=t}list(t){return this.client._call("token_trending_list",t)}},_t=class{constructor(t){this.client=t}get balance(){return new pt(this.client)}get holder(){return new dt(this.client)}get ohlcv(){return new ht(this.client)}get trending(){return new mt(this.client)}check(t){return this.client._call("token_check",t)}list(t){return this.client._call("token_list",t)}retrieve(t){return this.client._call("token_retrieve",t)}search(t){return this.client._call("token_search",t)}},Ot=class{constructor(t){this.client=t}list(t){return this.client._call("transaction_list",t)}prepare(t){return this.client._call("transaction_prepare",t)}register(t){return this.client._call("transaction_register",t)}retrieve(t){return this.client._call("transaction_retrieve",t)}send(t){return this.client._call("transaction_send",t)}},vt=class{constructor(t){this.client=t}retrieve(t){return this.client._call("user_retrieve",t)}},Pt=class{constructor(t){this.client=t}accept(t){return this.client._call("virtual-account_agreement_accept",t)}list(t){return this.client._call("virtual-account_agreement_list",t)}},Ct=class{constructor(t){this.client=t}delete(t){return this.client._call("virtual-account_bank-account_delete",t)}list(t){return this.client._call("virtual-account_bank-account_list",t)}register(t){return this.client._call("virtual-account_bank-account_register",t)}retrieve(t){return this.client._call("virtual-account_bank-account_retrieve",t)}},yt=class{constructor(t){this.client=t}continue(t){return this.client._call("virtual-account_kyc_continue",t)}restart(t){return this.client._call("virtual-account_kyc_restart",t)}},It=class{constructor(t){this.client=t}cancel(t){return this.client._call("virtual-account_offramp_cancel",t)}create(t){return this.client._call("virtual-account_offramp_create",t)}initiate(t){return this.client._call("virtual-account_offramp_initiate",t)}list(t){return this.client._call("virtual-account_offramp_list",t)}retrieve(t){return this.client._call("virtual-account_offramp_retrieve",t)}update(t){return this.client._call("virtual-account_offramp_update",t)}},gt=class{constructor(t){this.client=t}create(t){return this.client._call("virtual-account_onramp_payment_create",t)}retrieve(t){return this.client._call("virtual-account_onramp_payment_retrieve",t)}},kt=class{constructor(t){this.client=t}get payment(){return new gt(this.client)}cancel(t){return this.client._call("virtual-account_onramp_cancel",t)}create(t){return this.client._call("virtual-account_onramp_create",t)}list(t){return this.client._call("virtual-account_onramp_list",t)}retrieve(t){return this.client._call("virtual-account_onramp_retrieve",t)}update(t){return this.client._call("virtual-account_onramp_update",t)}},At=class{constructor(t){this.client=t}list(t){return this.client._call("virtual-account_transaction_list",t)}},Rt=class{constructor(t){this.client=t}list(t){return this.client._call("virtual-account_wallet_list",t)}register(t){return this.client._call("virtual-account_wallet_register",t)}},ft=class{constructor(t){this.client=t}get agreement(){return new Pt(this.client)}get bankAccount(){return new Ct(this.client)}get kyc(){return new yt(this.client)}get offramp(){return new It(this.client)}get onramp(){return new kt(this.client)}get transaction(){return new At(this.client)}get wallet(){return new Rt(this.client)}create(t){return this.client._call("virtual-account_create",t)}retrieve(t){return this.client._call("virtual-account_retrieve",t)}},wt=class{constructor(t){this.client=t}list(t){return this.client._call("wallet_activity_list",t)}},Lt=class{constructor(t){this.client=t}retrieve(t){return this.client._call("wallet_pnl_retrieve",t)}},Mt=class{constructor(t){this.client=t}get activity(){return new wt(this.client)}get pnl(){return new Lt(this.client)}discover(t){return this.client._call("wallet_discover",t)}},d=class extends h{constructor(t={}){super(t)}get app(){return new O(this)}get card(){return new w(this)}get chain(){return new L(this)}get cli(){return new T(this)}get commerce(){return new q(this)}get deposit(){return new H(this)}get feedback(){return new U(this)}get gateway(){return new E(this)}get hyperliquid(){return new tt(this)}get polymarket(){return new rt(this)}get predictionMarket(){return new at(this)}get swaps(){return new st(this)}get token(){return new _t(this)}get transaction(){return new Ot(this)}get user(){return new vt(this)}get virtualAccount(){return new ft(this)}get wallet(){return new Mt(this)}buy(t){return this._call("buy",t)}login(t){return this._call("login",t)}refresh(t){return this._call("refresh",t)}verify(t){return this._call("verify",t)}};Ht();Bt();var m=null;function Wt(){return m||(m=new d({baseUrl:Vt(),auth:{type:"bearer",getToken:St,refreshToken:async()=>{let e=xt();if(!e?.refreshToken)throw new Error("No refresh token available");return(await bt(e)).accessToken}},headers:Tt()})),m}var Nt=new Proxy({},{get(e,t){return Reflect.get(Wt(),t)}});function te(){m=null}export{d as a,Nt as b,te as c};
|
|
2
|
+
import{f as Tt,g as Bt,j as xt,m as Vt,n as bt,o as St,p as Ht}from"./chunk-UKDT74TS.js";var i=class extends Error{constructor(r,n,u){super(r);this.status=n;this.toolName=u;this.name="MoonPayError"}},c=class extends i{constructor(t="Authentication required"){super(t,401),this.name="AuthError"}},a=class extends i{constructor(t="Rate limit exceeded"){super(t,429),this.name="RateLimitError"}},l=class extends i{constructor(t,r){super(t,400,r),this.name="ValidationError"}},s=class extends i{constructor(t){super(`Tool not found: ${t}`,404,t),this.name="ToolNotFoundError"}},p=class extends i{constructor(t,r){super(`Tool "${t}" has been renamed to "${r}"`,410,t),this.name="ToolRenamedError",this.newName=r}};var Ut="https://agents.moonpay.com",Et=36e4,h=class{constructor(t={}){this.baseUrl=(t.baseUrl??Ut).replace(/\/$/,""),this.auth=t.auth??{type:"none"},this.timeout=t.timeout??Et,this.headers=t.headers??{}}async _call(t,r){let n=`${this.baseUrl}/api/tools/${encodeURIComponent(t)}`,u=await this.buildHeaders(),o=await fetch(n,{method:"POST",headers:u,body:JSON.stringify(r),signal:AbortSignal.timeout(this.timeout)});if(o.status===401&&this.auth.type==="bearer"&&this.auth.refreshToken)try{let qt=await this.auth.refreshToken();u.Authorization=`Bearer ${qt}`,o=await fetch(n,{method:"POST",headers:u,body:JSON.stringify(r),signal:AbortSignal.timeout(this.timeout)})}catch{throw new c("Token refresh failed")}return this.handleResponse(o,t)}async buildHeaders(){let t={"Content-Type":"application/json",...this.headers};if(this.auth.type==="bearer"){let r=await this.auth.getToken();r&&(t.Authorization=`Bearer ${r}`)}return t}async handleResponse(t,r){if(t.ok)return t.json();let n;try{n=await t.json()}catch{n={error:t.statusText}}let u=n?.error??n?.message,o=typeof u=="string"?u:u?JSON.stringify(u):`Request failed with status ${t.status}`;switch(t.status){case 400:throw new l(o,r);case 401:throw new c(o);case 404:throw new s(r);case 410:throw new p(r,n?.newName??"unknown");case 429:throw new a(o);default:throw new i(o,t.status,r)}}};var _=class{constructor(t){this.client=t}create(t){return this.client._call("app_activation_create",t)}},O=class{constructor(t){this.client=t}get activation(){return new _(this.client)}},v=class{constructor(t){this.client=t}build(t){return this.client._call("card_delegation_approve_transaction_build",t)}},P=class{constructor(t){this.client=t}get transaction(){return new v(this.client)}},C=class{constructor(t){this.client=t}build(t){return this.client._call("card_delegation_revoke_transaction_build",t)}},y=class{constructor(t){this.client=t}get transaction(){return new C(this.client)}},I=class{constructor(t){this.client=t}retrieve(t){return this.client._call("card_delegation_token_retrieve",t)}},g=class{constructor(t){this.client=t}get approve(){return new P(this.client)}get revoke(){return new y(this.client)}get token(){return new I(this.client)}},k=class{constructor(t){this.client=t}check(t){return this.client._call("card_onboarding_check",t)}finish(t){return this.client._call("card_onboarding_finish",t)}start(t){return this.client._call("card_onboarding_start",t)}},A=class{constructor(t){this.client=t}list(t){return this.client._call("card_transaction_list",t)}},R=class{constructor(t){this.client=t}retrieve(t){return this.client._call("card_user_retrieve",t)}},f=class{constructor(t){this.client=t}check(t){return this.client._call("card_wallet_check",t)}link(t){return this.client._call("card_wallet_link",t)}list(t){return this.client._call("card_wallet_list",t)}unlink(t){return this.client._call("card_wallet_unlink",t)}},w=class{constructor(t){this.client=t}get delegation(){return new g(this.client)}get onboarding(){return new k(this.client)}get transaction(){return new A(this.client)}get user(){return new R(this.client)}get wallet(){return new f(this.client)}create(t){return this.client._call("card_create",t)}freeze(t){return this.client._call("card_freeze",t)}retrieve(t){return this.client._call("card_retrieve",t)}reveal(t){return this.client._call("card_reveal",t)}unfreeze(t){return this.client._call("card_unfreeze",t)}},L=class{constructor(t){this.client=t}list(t){return this.client._call("chain_list",t)}retrieve(t){return this.client._call("chain_retrieve",t)}},M=class{constructor(t){this.client=t}create(t){return this.client._call("cli_activation_create",t)}update(t){return this.client._call("cli_activation_update",t)}},T=class{constructor(t){this.client=t}get activation(){return new M(this.client)}},x=class{constructor(t){this.client=t}add(t){return this.client._call("commerce_cart_add",t)}remove(t){return this.client._call("commerce_cart_remove",t)}retrieve(t){return this.client._call("commerce_cart_retrieve",t)}update(t){return this.client._call("commerce_cart_update",t)}},V=class{constructor(t){this.client=t}pay(t){return this.client._call("commerce_checkout_pay",t)}start(t){return this.client._call("commerce_checkout_start",t)}},b=class{constructor(t){this.client=t}retrieve(t){return this.client._call("commerce_product_retrieve",t)}search(t){return this.client._call("commerce_product_search",t)}},S=class{constructor(t){this.client=t}list(t){return this.client._call("commerce_store_list",t)}retrieve(t){return this.client._call("commerce_store_retrieve",t)}},q=class{constructor(t){this.client=t}get cart(){return new x(this.client)}get checkout(){return new V(this.client)}get product(){return new b(this.client)}get store(){return new S(this.client)}search(t){return this.client._call("commerce_search",t)}},B=class{constructor(t){this.client=t}list(t){return this.client._call("deposit_transaction_list",t)}},H=class{constructor(t){this.client=t}get transaction(){return new B(this.client)}create(t){return this.client._call("deposit_create",t)}retrieve(t){return this.client._call("deposit_retrieve",t)}},U=class{constructor(t){this.client=t}create(t){return this.client._call("feedback_create",t)}},E=class{constructor(t){this.client=t}buy(t){return this.client._call("gateway_buy",t)}search(t){return this.client._call("gateway_search",t)}},W=class{constructor(t){this.client=t}retrieve(t){return this.client._call("hyperliquid_balance_retrieve",t)}},D=class{constructor(t){this.client=t}list(t){return this.client._call("hyperliquid_candle_list",t)}},F=class{constructor(t){this.client=t}create(t){return this.client._call("hyperliquid_deposit_create",t)}},z=class{constructor(t){this.client=t}submit(t){return this.client._call("hyperliquid_exchange_submit",t)}},$=class{constructor(t){this.client=t}list(t){return this.client._call("hyperliquid_funding_payment_list",t)}},G=class{constructor(t){this.client=t}get payment(){return new $(this.client)}},K=class{constructor(t){this.client=t}list(t){return this.client._call("hyperliquid_market_list",t)}},j=class{constructor(t){this.client=t}create(t){return this.client._call("hyperliquid_order_create",t)}list(t){return this.client._call("hyperliquid_order_list",t)}},J=class{constructor(t){this.client=t}retrieve(t){return this.client._call("hyperliquid_orderbook_retrieve",t)}},Q=class{constructor(t){this.client=t}list(t){return this.client._call("hyperliquid_position_list",t)}},X=class{constructor(t){this.client=t}list(t){return this.client._call("hyperliquid_predicted_funding_list",t)}},Y=class{constructor(t){this.client=t}get funding(){return new X(this.client)}},Z=class{constructor(t){this.client=t}list(t){return this.client._call("hyperliquid_price_list",t)}},N=class{constructor(t){this.client=t}list(t){return this.client._call("hyperliquid_trade_list",t)}},tt=class{constructor(t){this.client=t}get balance(){return new W(this.client)}get candle(){return new D(this.client)}get deposit(){return new F(this.client)}get exchange(){return new z(this.client)}get funding(){return new G(this.client)}get market(){return new K(this.client)}get order(){return new j(this.client)}get orderbook(){return new J(this.client)}get position(){return new Q(this.client)}get predicted(){return new Y(this.client)}get price(){return new Z(this.client)}get trade(){return new N(this.client)}},et=class{constructor(t){this.client=t}redeem(t){return this.client._call("polymarket_position_redeem",t)}sell(t){return this.client._call("polymarket_position_sell",t)}},rt=class{constructor(t){this.client=t}get position(){return new et(this.client)}},it=class{constructor(t){this.client=t}list(t){return this.client._call("prediction-market_event_list",t)}retrieve(t){return this.client._call("prediction-market_event_retrieve",t)}search(t){return this.client._call("prediction-market_event_search",t)}},nt=class{constructor(t){this.client=t}list(t){return this.client._call("prediction-market_market_ohlcv_list",t)}},ut=class{constructor(t){this.client=t}get ohlcv(){return new nt(this.client)}},ot=class{constructor(t){this.client=t}retrieve(t){return this.client._call("prediction-market_order_retrieve",t)}},ct=class{constructor(t){this.client=t}buy(t){return this.client._call("prediction-market_position_buy",t)}list(t){return this.client._call("prediction-market_position_list",t)}redeem(t){return this.client._call("prediction-market_position_redeem",t)}sell(t){return this.client._call("prediction-market_position_sell",t)}},at=class{constructor(t){this.client=t}get event(){return new it(this.client)}get market(){return new ut(this.client)}get order(){return new ot(this.client)}get position(){return new ct(this.client)}},lt=class{constructor(t){this.client=t}build(t){return this.client._call("swaps_transaction_build",t)}},st=class{constructor(t){this.client=t}get transaction(){return new lt(this.client)}},pt=class{constructor(t){this.client=t}list(t){return this.client._call("token_balance_list",t)}},dt=class{constructor(t){this.client=t}list(t){return this.client._call("token_holder_list",t)}},ht=class{constructor(t){this.client=t}list(t){return this.client._call("token_ohlcv_list",t)}},mt=class{constructor(t){this.client=t}list(t){return this.client._call("token_trending_list",t)}},_t=class{constructor(t){this.client=t}get balance(){return new pt(this.client)}get holder(){return new dt(this.client)}get ohlcv(){return new ht(this.client)}get trending(){return new mt(this.client)}check(t){return this.client._call("token_check",t)}list(t){return this.client._call("token_list",t)}retrieve(t){return this.client._call("token_retrieve",t)}search(t){return this.client._call("token_search",t)}},Ot=class{constructor(t){this.client=t}list(t){return this.client._call("transaction_list",t)}prepare(t){return this.client._call("transaction_prepare",t)}register(t){return this.client._call("transaction_register",t)}retrieve(t){return this.client._call("transaction_retrieve",t)}send(t){return this.client._call("transaction_send",t)}},vt=class{constructor(t){this.client=t}retrieve(t){return this.client._call("user_retrieve",t)}},Pt=class{constructor(t){this.client=t}accept(t){return this.client._call("virtual-account_agreement_accept",t)}list(t){return this.client._call("virtual-account_agreement_list",t)}},Ct=class{constructor(t){this.client=t}delete(t){return this.client._call("virtual-account_bank-account_delete",t)}list(t){return this.client._call("virtual-account_bank-account_list",t)}register(t){return this.client._call("virtual-account_bank-account_register",t)}retrieve(t){return this.client._call("virtual-account_bank-account_retrieve",t)}},yt=class{constructor(t){this.client=t}continue(t){return this.client._call("virtual-account_kyc_continue",t)}restart(t){return this.client._call("virtual-account_kyc_restart",t)}},It=class{constructor(t){this.client=t}cancel(t){return this.client._call("virtual-account_offramp_cancel",t)}create(t){return this.client._call("virtual-account_offramp_create",t)}initiate(t){return this.client._call("virtual-account_offramp_initiate",t)}list(t){return this.client._call("virtual-account_offramp_list",t)}retrieve(t){return this.client._call("virtual-account_offramp_retrieve",t)}update(t){return this.client._call("virtual-account_offramp_update",t)}},gt=class{constructor(t){this.client=t}create(t){return this.client._call("virtual-account_onramp_payment_create",t)}retrieve(t){return this.client._call("virtual-account_onramp_payment_retrieve",t)}},kt=class{constructor(t){this.client=t}get payment(){return new gt(this.client)}cancel(t){return this.client._call("virtual-account_onramp_cancel",t)}create(t){return this.client._call("virtual-account_onramp_create",t)}list(t){return this.client._call("virtual-account_onramp_list",t)}retrieve(t){return this.client._call("virtual-account_onramp_retrieve",t)}update(t){return this.client._call("virtual-account_onramp_update",t)}},At=class{constructor(t){this.client=t}list(t){return this.client._call("virtual-account_transaction_list",t)}},Rt=class{constructor(t){this.client=t}list(t){return this.client._call("virtual-account_wallet_list",t)}register(t){return this.client._call("virtual-account_wallet_register",t)}},ft=class{constructor(t){this.client=t}get agreement(){return new Pt(this.client)}get bankAccount(){return new Ct(this.client)}get kyc(){return new yt(this.client)}get offramp(){return new It(this.client)}get onramp(){return new kt(this.client)}get transaction(){return new At(this.client)}get wallet(){return new Rt(this.client)}create(t){return this.client._call("virtual-account_create",t)}retrieve(t){return this.client._call("virtual-account_retrieve",t)}},wt=class{constructor(t){this.client=t}list(t){return this.client._call("wallet_activity_list",t)}},Lt=class{constructor(t){this.client=t}retrieve(t){return this.client._call("wallet_pnl_retrieve",t)}},Mt=class{constructor(t){this.client=t}get activity(){return new wt(this.client)}get pnl(){return new Lt(this.client)}discover(t){return this.client._call("wallet_discover",t)}},d=class extends h{constructor(t={}){super(t)}get app(){return new O(this)}get card(){return new w(this)}get chain(){return new L(this)}get cli(){return new T(this)}get commerce(){return new q(this)}get deposit(){return new H(this)}get feedback(){return new U(this)}get gateway(){return new E(this)}get hyperliquid(){return new tt(this)}get polymarket(){return new rt(this)}get predictionMarket(){return new at(this)}get swaps(){return new st(this)}get token(){return new _t(this)}get transaction(){return new Ot(this)}get user(){return new vt(this)}get virtualAccount(){return new ft(this)}get wallet(){return new Mt(this)}buy(t){return this._call("buy",t)}login(t){return this._call("login",t)}refresh(t){return this._call("refresh",t)}verify(t){return this._call("verify",t)}};Ht();Bt();var m=null;function Wt(){return m||(m=new d({baseUrl:Vt(),auth:{type:"bearer",getToken:St,refreshToken:async()=>{let e=xt();if(!e?.refreshToken)throw new Error("No refresh token available");return(await bt(e)).accessToken}},headers:Tt()})),m}var Nt=new Proxy({},{get(e,t){return Reflect.get(Wt(),t)}});function te(){m=null}export{d as a,Nt as b,te as c};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
process.noDeprecation = true; import { createRequire as __createRequire } from "module"; const require = __createRequire(import.meta.url);
|
|
2
|
-
import{b as m,d as b}from"./chunk-LMDE72OE.js";var G={};b(G,{decrypt:()=>k,encrypt:()=>T,encryptedFileSchema:()=>O});import{randomBytes as A,scryptSync as v,createCipheriv as X,createDecipheriv as $}from"crypto";import{z as i}from"zod";function T(n,t){let r=A(32),o=v(t,r,D,{N:R,r:L,p:F,maxmem:K}),s=A(12),c=X("aes-256-gcm",o,s),_=Buffer.concat([c.update(n,"utf8"),c.final()]);return{encryption:{cipher:"aes-256-gcm",kdf:"scrypt",kdfparams:{n:R,r:L,p:F},salt:r.toString("base64"),iv:s.toString("base64"),tag:c.getAuthTag().toString("base64")},data:_.toString("base64")}}function k(n,t){let{salt:r,iv:o,tag:s,kdfparams:c}=n.encryption,_=v(t,Buffer.from(r,"base64"),D,{N:c.n,r:c.r,p:c.p,maxmem:K}),x=$("aes-256-gcm",_,Buffer.from(o,"base64"),{authTagLength:16});return x.setAuthTag(Buffer.from(s,"base64")),Buffer.concat([x.update(Buffer.from(n.data,"base64")),x.final()]).toString("utf8")}var R,L,F,D,K,O,P=m(()=>{"use strict";R=2**18,L=8,F=1,D=32,K=512*1024*1024,O=i.object({encryption:i.object({cipher:i.literal("aes-256-gcm"),kdf:i.literal("scrypt"),kdfparams:i.object({n:i.number(),r:i.number(),p:i.number()}),salt:i.string(),iv:i.string(),tag:i.string()}),data:i.string()})});import{readFileSync as W}from"fs";import{join as z}from"path";import{homedir as q}from"os";function en(){if(f!==void 0)return f;try{f=JSON.parse(W(z(q(),".config","moonpay","consent.json"),"utf-8")).agentId??null}catch{f=null}return f??null}function rn(){return process.env.OPENCLAW_SHELL?"openclaw":process.env.CLAUDECODE?"claude-code":process.env.CODEX_CI?"codex":process.env.GEMINI_CLI?"gemini-cli":"human"}function U(){let n={"Content-Type":"application/json",[Z]:Q,[tn]:rn()},t=en();return t&&(n[nn]=t),n}var Q,Z,nn,f,tn,j=m(()=>{"use strict";Q="1.84.
|
|
2
|
+
import{b as m,d as b}from"./chunk-LMDE72OE.js";var G={};b(G,{decrypt:()=>k,encrypt:()=>T,encryptedFileSchema:()=>O});import{randomBytes as A,scryptSync as v,createCipheriv as X,createDecipheriv as $}from"crypto";import{z as i}from"zod";function T(n,t){let r=A(32),o=v(t,r,D,{N:R,r:L,p:F,maxmem:K}),s=A(12),c=X("aes-256-gcm",o,s),_=Buffer.concat([c.update(n,"utf8"),c.final()]);return{encryption:{cipher:"aes-256-gcm",kdf:"scrypt",kdfparams:{n:R,r:L,p:F},salt:r.toString("base64"),iv:s.toString("base64"),tag:c.getAuthTag().toString("base64")},data:_.toString("base64")}}function k(n,t){let{salt:r,iv:o,tag:s,kdfparams:c}=n.encryption,_=v(t,Buffer.from(r,"base64"),D,{N:c.n,r:c.r,p:c.p,maxmem:K}),x=$("aes-256-gcm",_,Buffer.from(o,"base64"),{authTagLength:16});return x.setAuthTag(Buffer.from(s,"base64")),Buffer.concat([x.update(Buffer.from(n.data,"base64")),x.final()]).toString("utf8")}var R,L,F,D,K,O,P=m(()=>{"use strict";R=2**18,L=8,F=1,D=32,K=512*1024*1024,O=i.object({encryption:i.object({cipher:i.literal("aes-256-gcm"),kdf:i.literal("scrypt"),kdfparams:i.object({n:i.number(),r:i.number(),p:i.number()}),salt:i.string(),iv:i.string(),tag:i.string()}),data:i.string()})});import{readFileSync as W}from"fs";import{join as z}from"path";import{homedir as q}from"os";function en(){if(f!==void 0)return f;try{f=JSON.parse(W(z(q(),".config","moonpay","consent.json"),"utf-8")).agentId??null}catch{f=null}return f??null}function rn(){return process.env.OPENCLAW_SHELL?"openclaw":process.env.CLAUDECODE?"claude-code":process.env.CODEX_CI?"codex":process.env.GEMINI_CLI?"gemini-cli":"human"}function U(){let n={"Content-Type":"application/json",[Z]:Q,[tn]:rn()},t=en();return t&&(n[nn]=t),n}var Q,Z,nn,f,tn,j=m(()=>{"use strict";Q="1.84.3",Z="X-CLI-Version",nn="X-Agent-Id";tn="X-Agent"});import*as e from"fs";import*as Y from"os";import*as g from"path";function d(){e.existsSync(l)||e.mkdirSync(l,{recursive:!0,mode:448})}function H(n,t,r){let o=n+`.tmp.${process.pid}`;e.writeFileSync(o,t,{encoding:"utf-8",mode:r}),e.renameSync(o,n)}function sn(){d();try{let n=e.openSync(u,e.constants.O_CREAT|e.constants.O_EXCL|e.constants.O_WRONLY,384);e.writeSync(n,JSON.stringify({pid:process.pid,ts:Date.now()})),e.closeSync(n)}catch(n){if(n.code!=="EEXIST")throw n;try{let t=JSON.parse(e.readFileSync(u,"utf-8"));if(Date.now()-t.ts<on)return null}catch{}try{e.unlinkSync(u)}catch{}try{let t=e.openSync(u,e.constants.O_CREAT|e.constants.O_EXCL|e.constants.O_WRONLY,384);e.writeSync(t,JSON.stringify({pid:process.pid,ts:Date.now()})),e.closeSync(t)}catch{return null}}return()=>{try{e.unlinkSync(u)}catch{}}}function B(){if(!e.existsSync(w))return null;try{let n=JSON.parse(e.readFileSync(w,"utf-8"));return n.baseUrl?n:null}catch{return null}}function Pn(){let n=B();return n||(an(N),N)}function S(){if(!e.existsSync(p))return null;let n=h();if(!n)return null;try{let t=JSON.parse(e.readFileSync(p,"utf-8")),r=O.parse(t),o=k(r,n),s=JSON.parse(o);return!s.accessToken||!s.baseUrl?null:s}catch{return null}}function cn(n){let t=I(),r=T(JSON.stringify(n),t);d(),H(p,JSON.stringify(r,null,2),384)}function an(n){d(),H(w,JSON.stringify(n,null,2),384)}function Un(){e.existsSync(p)&&e.unlinkSync(p)}function jn(){let n=B(),t=S();return n?.baseUrl??t?.baseUrl??N.baseUrl}async function fn(n,t,r){let o=await fetch(`${n}/api/tools/${encodeURIComponent(t)}`,{method:"POST",signal:AbortSignal.timeout(15e3),headers:U(),body:JSON.stringify(r)}),s=await o.json();if(!o.ok){let c=s;throw new Error(c?.error??`${t} failed (${o.status})`)}return s}async function un(n){if(!n.refreshToken)throw new Error("No refresh token available");let t=sn();if(!t){await new Promise(o=>setTimeout(o,2e3));let r=S();if(r&&r.expiresAt>Date.now())return r;throw new Error("Token refresh failed (concurrent refresh in progress)")}try{let r=S();if(r&&r.expiresAt>Date.now()+6e4)return r;let o=await fn(n.baseUrl,"refresh",{refreshToken:n.refreshToken}),s={accessToken:o.accessToken,refreshToken:o.refreshToken,expiresAt:o.expiresAt*1e3,baseUrl:n.baseUrl};return cn(s),s}finally{t()}}async function Jn(){let n=S();if(!n)return null;if(Date.now()>=n.expiresAt-ln){if(n.refreshToken)try{return(await un(n)).accessToken}catch{return null}return null}return n.accessToken}var l,w,p,u,N,on,ln,V=m(()=>{"use strict";P();J();j();l=g.join(Y.homedir(),".config","moonpay"),w=g.join(l,"config.json"),p=g.join(l,"credentials.json"),u=g.join(l,".credentials.lock"),N={baseUrl:"https://agents.moonpay.com"};on=3e4;ln=300*1e3});var Nn={};b(Nn,{ensureEncryptionKey:()=>I,getEncryptionKey:()=>h});import{execFileSync as C,execSync as pn}from"child_process";import{randomBytes as gn}from"crypto";import{existsSync as dn,readFileSync as yn,writeFileSync as mn}from"fs";import{homedir as Sn,platform as M}from"os";import{join as hn}from"path";function Cn(n){try{C("security",["delete-generic-password","-s",a,"-a",y],{stdio:"ignore"})}catch{}C("security",["add-generic-password","-s",a,"-a",y,"-w",n],{stdio:"ignore"})}function En(){try{return C("security",["find-generic-password","-s",a,"-a",y,"-w"],{encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim()}catch{return null}}function _n(n){pn(`printf '%s' | secret-tool store --label="${a}" service "${a}" account "${y}"`,{input:n,stdio:["pipe","ignore","ignore"]})}function xn(){try{return C("secret-tool",["lookup","service",a,"account",y],{encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim()}catch{return null}}function On(n){d(),mn(E,n,{encoding:"utf-8",mode:384})}function Tn(){try{return dn(E)&&yn(E,"utf-8").trim()||null}catch{return null}}function kn(n){try{let t=M();return t==="darwin"?(Cn(n),!0):t==="linux"?(_n(n),!0):!1}catch{return!1}}function wn(){let n=M();return n==="darwin"?En():n==="linux"?xn():null}function h(){let n=process.env.MOONPAY_ENCRYPTION_KEY;return n||(wn()??Tn())}function I(){let n=h();if(n)return n;let t=gn(32).toString("hex");return kn(t)||(On(t),process.stderr.write("Note: Keychain unavailable. Encryption key stored in "+E+`
|
|
3
3
|
`)),t}var a,y,E,J=m(()=>{"use strict";V();a="moonpay-cli",y="encryption-key",E=hn(Sn(),".config","moonpay",".encryption-key")});export{G as a,P as b,Nn as c,J as d,Q as e,U as f,j as g,d as h,Pn as i,S as j,cn as k,Un as l,jn as m,un as n,Jn as o,V as p};
|