@dcl/auth-site 5.1.2-34530473015.commit-5a40912 → 5.1.2-34594550837.commit-e152cbb

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.
Files changed (117) hide show
  1. package/assets/{ConstantsUtil-CwodzP9H.js → ConstantsUtil-9zGObjSD.js} +1 -1
  2. package/assets/{ContentfulRichText-DMyYa8Ub.js → ContentfulRichText-BwTkoAEb.js} +1 -1
  3. package/assets/{ExchangeController-B5eeUyoh.js → ExchangeController-Bc79u1o8.js} +1 -1
  4. package/assets/{HelpersUtil-Bm6jUgWw.js → HelpersUtil-kDlC4Clm.js} +1 -1
  5. package/assets/{LoginPage-BkFIEMAv.js → LoginPage-BeeqS56o.js} +1 -1
  6. package/assets/{NetworkUtil-Dl37cltN.js → NetworkUtil-CcbJUYy6.js} +1 -1
  7. package/assets/{SwapController-BFgiVJqW.js → SwapController-N7B7deGl.js} +1 -1
  8. package/assets/{W3MFrameProviderSingleton-lHGjvMNL.js → W3MFrameProviderSingleton-BukbyIVP.js} +3 -3
  9. package/assets/{biconomy-BnS_Smic.js → biconomy-CyMv8voL.js} +1 -1
  10. package/assets/{browser-C4LJp7Ah.js → browser-aP0rRdtS.js} +1 -1
  11. package/assets/browser-ponyfill-fTToSo9p.js +1 -0
  12. package/assets/{ccip-C0ddu9my.js → ccip-BbpIbX6z.js} +1 -1
  13. package/assets/{ccip-D8rmh0jK.js → ccip-D8OKwVU6.js} +1 -1
  14. package/assets/{chains-DnbBDT2T.js → chains-BNbCov3a.js} +1 -1
  15. package/assets/{common-CDCnIQmp.js → common-DiCb1At8.js} +1 -1
  16. package/assets/{controller-CxBaI-sN.js → controller-iNuS0ia6.js} +2 -2
  17. package/assets/{data-capture-BGkLjB-b.js → data-capture-DvtCBgNl.js} +1 -1
  18. package/assets/{email-vJ4diYnq.js → email-BweKFNhI.js} +1 -1
  19. package/assets/{embedded-wallet-D9K10ARl.js → embedded-wallet-EfqNjGGF.js} +1 -1
  20. package/assets/{engine-CyzDder_.js → engine-Ct_5WbTX.js} +1 -1
  21. package/assets/{estimate-l1-fee-BOs1mFOx.js → estimate-l1-fee-CckrkKwy.js} +1 -1
  22. package/assets/{ethereum-D1zvUd1J.js → ethereum-BEGT5Rbs.js} +1 -1
  23. package/assets/{extractIPFS-Hx6OJfDV.js → extractIPFS-Xl4cN05w.js} +1 -1
  24. package/assets/{features-D73d2Rnv.js → features-BJag8EvI.js} +1 -1
  25. package/assets/{fetchTokenMetadata-BYnOxmb5.js → fetchTokenMetadata-C7WbcKmk.js} +1 -1
  26. package/assets/{fortmatic-Cc4aOwFu.js → fortmatic-DwDzUYQa.js} +1 -1
  27. package/assets/{get-ecosystem-wallet-info-RsfDUsiu.js → get-ecosystem-wallet-info-CWebjm4S.js} +1 -1
  28. package/assets/{getBalance-XMQwJa0J.js → getBalance-BLaorPcT.js} +1 -1
  29. package/assets/{getInstalledModules-BgPOtvVf.js → getInstalledModules-CmPDoG-G.js} +1 -1
  30. package/assets/{getNFT-Bq03USx6.js → getNFT-D5FqZ_Ds.js} +2 -2
  31. package/assets/{getNFT-DDiwCDea.js → getNFT-DND6xA5u.js} +1 -1
  32. package/assets/{if-defined-B4x_6Aly.js → if-defined-DhWqQS7i.js} +1 -1
  33. package/assets/{in-app-C7LY8wEa.js → in-app-CId9fp-b.js} +2 -2
  34. package/assets/{in-app-wallet-calls-Ct3TlKXz.js → in-app-wallet-calls-CE5RiyGW.js} +1 -1
  35. package/assets/{index-DHk1QjgN.js → index-42R7rfLU.js} +1 -1
  36. package/assets/{index-DHikVOA4.js → index-6Tddv9-i.js} +1 -1
  37. package/assets/{index-BHlIdIz9.js → index-8sh7aG3O.js} +1 -1
  38. package/assets/{index-og4b0sve.js → index-BBRIr0-6.js} +1 -1
  39. package/assets/{index-CmiwHZmm.js → index-BCgTR4mk.js} +3 -3
  40. package/assets/{index-BiBcJuC1.js → index-BG6Vo0hs.js} +1 -1
  41. package/assets/{index-BK3BnXJ7.js → index-BItaqbGk.js} +1 -1
  42. package/assets/{index-D6EJnaTh.js → index-BK-Z4Gj8.js} +16 -16
  43. package/assets/{index-bvueQn_A.js → index-BKahtXlD.js} +1 -1
  44. package/assets/{index-DxH12pYW.js → index-BYrBQsfB.js} +1 -1
  45. package/assets/{index-DF5Ye55m.js → index-BdXDsCkJ.js} +1 -1
  46. package/assets/{index-D-D6Rcdj.css → index-Bkz2iMOs.css} +1 -1
  47. package/assets/{index-D03Ad_Fa.js → index-BltRbBJp.js} +3 -3
  48. package/assets/{index-Db3mNGaz.js → index-BnAcWv1n.js} +2 -2
  49. package/assets/{index-DlN5o_FM.js → index-Bp7wYlQZ.js} +1 -1
  50. package/assets/{index-BHD8BqT6.js → index-BppH-bId.js} +1 -1
  51. package/assets/{index-CyNGE13w.js → index-ByCv2tI-.js} +1 -1
  52. package/assets/{index-84uYCktt.js → index-C2vq2z-O.js} +1 -1
  53. package/assets/{index-D2pIWwHH.js → index-C7JelF1h.js} +1 -1
  54. package/assets/{index-CqZrsG8Q.js → index-CAKQ0SNN.js} +1 -1
  55. package/assets/{index-CVcM9I3B.js → index-CAc7JRMZ.js} +1 -1
  56. package/assets/{index-DZ6BAv0U.js → index-CDKDQR5V.js} +1 -1
  57. package/assets/{index-Ba-0wsFH.js → index-CDSdFwwm.js} +1 -1
  58. package/assets/{index-CfHFBK36.js → index-CEzLTC5M.js} +1 -1
  59. package/assets/{index-a_99AQtw.js → index-CMgmsVO-.js} +1 -1
  60. package/assets/{index-CTiWpnpu.js → index-CWpdiJ5c.js} +1 -1
  61. package/assets/{index-ncg9r-8m.js → index-CeKIWpKK.js} +1 -1
  62. package/assets/{index-CzUhXH4V.js → index-ChwDgfd6.js} +1 -1
  63. package/assets/{index-CNcvrFba.js → index-Cq-Utxn0.js} +3 -3
  64. package/assets/{index-Bmt6vNlS.js → index-CvfNZhPI.js} +1 -1
  65. package/assets/{index-BqyAxCCB.js → index-DJIj5nCp.js} +1 -1
  66. package/assets/{index-C-H0mStM.js → index-DU5DKwC0.js} +1 -1
  67. package/assets/{index-CMrTysq0.js → index-DV3uYIsw.js} +1 -1
  68. package/assets/{index-ByIeWAR3.js → index-DWMJTttJ.js} +1 -1
  69. package/assets/{index-K8KsUbQQ.js → index-DjiKjX7f.js} +1 -1
  70. package/assets/{index--9g_I0vb.js → index-DpI7OHJl.js} +1 -1
  71. package/assets/index-Dw30YNSg.js +3 -0
  72. package/assets/{index-DIrmaJma.js → index-Dx-uv9OW.js} +1 -1
  73. package/assets/{index-C0PSUbkf.js → index-DzHBCntz.js} +1 -1
  74. package/assets/{index-D3Mp0xd4.js → index-JrPO_Lwy.js} +2 -2
  75. package/assets/{index-6Owq4Z_2.js → index-OKrJJhyq.js} +1 -1
  76. package/assets/{index-D0RlRRmh.js → index-PwVTQteL.js} +1 -1
  77. package/assets/{index-DwbXguRk.js → index-XGOjwJ4M.js} +1 -1
  78. package/assets/{index-HKfgPnh2.js → index-_E2UO_8o.js} +1 -1
  79. package/assets/{index-Dx48FHWR.js → index-_oMYE9Nr.js} +1 -1
  80. package/assets/{index-CZMR9I3s.js → index-iVrLM3R3.js} +1 -1
  81. package/assets/{index-CqqoV8m-.js → index-kFgCSjY8.js} +1 -1
  82. package/assets/{index-q3cb5UkH.js → index-lr6RODFr.js} +1 -1
  83. package/assets/{index-DXpLnu0M.js → index-pwt3lTiw.js} +1 -1
  84. package/assets/{index.es-CF3Tyupm.js → index.es-COckN1zH.js} +1 -1
  85. package/assets/{index.es-BjrhO8oc.js → index.es-DsK3WASc.js} +1 -1
  86. package/assets/{linkAccount-DJ31GPLv.js → linkAccount-P38eyo-k.js} +1 -1
  87. package/assets/{native-Cmsp_bHn.js → native-WsNezRHP.js} +1 -1
  88. package/assets/{networks-UZOEYOoU.js → networks-CzO5M9Ma.js} +3 -3
  89. package/assets/{onramp-CdhqnunV.js → onramp-BaVNVjFs.js} +1 -1
  90. package/assets/{openzeppelin-BhGrhzFb.js → openzeppelin-BMAZgubg.js} +1 -1
  91. package/assets/{ownerOf-C1jHbTwh.js → ownerOf-CcCLN7-f.js} +1 -1
  92. package/assets/{parseNft-vPEgUOmf.js → parseNft-CCmBRMPQ.js} +2 -2
  93. package/assets/{pay-with-exchange-CalGeXsj.js → pay-with-exchange-DoFn1Vwz.js} +1 -1
  94. package/assets/{qr-overlay-FeC7aKwB.js → qr-overlay-DbCkMnrB.js} +3 -3
  95. package/assets/{receive-_BzlkE98.js → receive-oE4TnL_B.js} +1 -1
  96. package/assets/{ref-B8BLpnGP.js → ref-BWw0B8Hp.js} +1 -1
  97. package/assets/{resolveImplementation-Ch-sVOKB.js → resolveImplementation-Bc7KPglG.js} +1 -1
  98. package/assets/{secp256k1-9NRxC5cB.js → secp256k1-mKcmTatN.js} +1 -1
  99. package/assets/{send-sfR9C5DN.js → send-BiZopm_8.js} +1 -1
  100. package/assets/{send-eip712-transaction-D7Q8Ig4u.js → send-eip712-transaction-D0-LQ7-U.js} +1 -1
  101. package/assets/{send-gasless-transaction-C_5QEYx2.js → send-gasless-transaction-Cs0q3JvE.js} +2 -2
  102. package/assets/{session-proposal-sbvO4Ii3.js → session-proposal-CtmI49vN.js} +1 -1
  103. package/assets/{session-request-CTju1Pzu.js → session-request-Bt5bNIpf.js} +2 -2
  104. package/assets/{socials-DspPNR7g.js → socials-B0Wzcr2j.js} +1 -1
  105. package/assets/{swaps-Drh6fGVc.js → swaps-NSEGlMju.js} +1 -1
  106. package/assets/{thirdweb-C1EiOfxv.js → thirdweb-DdFz669q.js} +5 -5
  107. package/assets/{totalSupply-3UzmtfWn.js → totalSupply-BLOcaNz3.js} +1 -1
  108. package/assets/{transactions-B2bGBDdV.js → transactions-Cw9H3OO6.js} +1 -1
  109. package/assets/{ui-C62pFdCC.js → ui-5SR1m4h7.js} +5 -5
  110. package/assets/{vendor-CDSQy2W7.js → vendor-BgJSXm_k.js} +1 -1
  111. package/assets/{w3m-modal-CF4nY3hg.js → w3m-modal-B0mszKcJ.js} +1 -1
  112. package/assets/{wallets-DVjKXFZM.js → wallets-WSeji0fx.js} +4 -4
  113. package/assets/{web-connector-DYUrBl7Z.js → web-connector-DR6YwYYb.js} +3 -3
  114. package/index.html +5 -5
  115. package/package.json +3 -3
  116. package/assets/browser-ponyfill-C27lDcQ_.js +0 -1
  117. package/assets/index-BPU2rzDM.js +0 -3
@@ -1,4 +1,4 @@
1
- import{j as d,r as p,i as m,v as r,h as x}from"./index-CNcvrFba.js";import{n as h,c as f}from"./index-CVcM9I3B.js";const g=d`
1
+ import{j as d,r as p,i as m,v as r,h as x}from"./index-Cq-Utxn0.js";import{n as h,c as f}from"./index-CAc7JRMZ.js";const g=d`
2
2
  :host {
3
3
  display: flex;
4
4
  }
@@ -1 +1 @@
1
- import{r as T}from"./index-CpWZ5dtQ.js";import{b3 as y,b4 as k,b5 as I}from"./index-D6EJnaTh.js";import"./thirdweb-C1EiOfxv.js";import"./ui-C62pFdCC.js";import"./vendor-CDSQy2W7.js";const q=()=>"9.1.0",v=t=>t.toString(16).padStart(2,"0"),C=t=>{const e=new Uint8Array(t/2);return window.crypto.getRandomValues(e),Array.from(e,v).join("")},R=()=>typeof window<"u"?C(10):new Date().getTime().toString(36);class g{}g.makeRequest=(t,e)=>({id:R(),method:t,params:e,env:{sdkVersion:q()}});g.makeResponse=(t,e,s)=>({id:t,success:!0,version:s,data:e});g.makeErrorResponse=(t,e,s)=>({id:t,success:!1,error:e,version:s});var r;(function(t){t.sendTransactions="sendTransactions",t.rpcCall="rpcCall",t.getChainInfo="getChainInfo",t.getSafeInfo="getSafeInfo",t.getTxBySafeTxHash="getTxBySafeTxHash",t.getSafeBalances="getSafeBalances",t.signMessage="signMessage",t.signTypedMessage="signTypedMessage",t.getEnvironmentInfo="getEnvironmentInfo",t.getOffChainSignature="getOffChainSignature",t.requestAddressBook="requestAddressBook",t.wallet_getPermissions="wallet_getPermissions",t.wallet_requestPermissions="wallet_requestPermissions"})(r||(r={}));var m;(function(t){t.requestAddressBook="requestAddressBook"})(m||(m={}));class H{constructor(e=null,s=!1){this.allowedOrigins=null,this.callbacks=new Map,this.debugMode=!1,this.isServer=typeof window>"u",this.isValidMessage=({origin:a,data:n,source:i})=>{const o=!n,l=!this.isServer&&i===window.parent,u=typeof n.version<"u"&&parseInt(n.version.split(".")[0]),B=typeof u=="number"&&u>=1;let p=!0;return Array.isArray(this.allowedOrigins)&&(p=this.allowedOrigins.find(P=>P.test(a))!==void 0),!o&&l&&B&&p},this.logIncomingMessage=a=>{console.info(`Safe Apps SDK v1: A message was received from origin ${a.origin}. `,a.data)},this.onParentMessage=a=>{this.isValidMessage(a)&&(this.debugMode&&this.logIncomingMessage(a),this.handleIncomingMessage(a.data))},this.handleIncomingMessage=a=>{const{id:n}=a,i=this.callbacks.get(n);i&&(i(a),this.callbacks.delete(n))},this.send=(a,n)=>{const i=g.makeRequest(a,n);if(this.isServer)throw new Error("Window doesn't exist");return window.parent.postMessage(i,"*"),new Promise((o,l)=>{this.callbacks.set(i.id,u=>{if(!u.success){l(new Error(u.error));return}o(u)})})},this.allowedOrigins=e,this.debugMode=s,this.isServer||window.addEventListener("message",this.onParentMessage)}}const b=t=>typeof t=="object"&&t!=null&&"domain"in t&&"types"in t&&"message"in t;T();class E{constructor(e){this.communicator=e}async getBySafeTxHash(e){if(!e)throw new Error("Invalid safeTxHash");return(await this.communicator.send(r.getTxBySafeTxHash,{safeTxHash:e})).data}async signMessage(e){const s={message:e};return(await this.communicator.send(r.signMessage,s)).data}async signTypedMessage(e){if(!b(e))throw new Error("Invalid typed data");return(await this.communicator.send(r.signTypedMessage,{typedData:e})).data}async send({txs:e,params:s}){if(!e||!e.length)throw new Error("No transactions were passed");const a={txs:e,params:s};return(await this.communicator.send(r.sendTransactions,a)).data}}const c={eth_call:"eth_call",eth_gasPrice:"eth_gasPrice",eth_getLogs:"eth_getLogs",eth_getBalance:"eth_getBalance",eth_getCode:"eth_getCode",eth_getBlockByHash:"eth_getBlockByHash",eth_getBlockByNumber:"eth_getBlockByNumber",eth_getStorageAt:"eth_getStorageAt",eth_getTransactionByHash:"eth_getTransactionByHash",eth_getTransactionReceipt:"eth_getTransactionReceipt",eth_getTransactionCount:"eth_getTransactionCount",eth_estimateGas:"eth_estimateGas",safe_setSettings:"safe_setSettings"},h={defaultBlockParam:(t="latest")=>t,returnFullTxObjectParam:(t=!1)=>t,blockNumberToHex:t=>Number.isInteger(t)?`0x${t.toString(16)}`:t};class A{constructor(e){this.communicator=e,this.call=this.buildRequest({call:c.eth_call,formatters:[null,h.defaultBlockParam]}),this.getBalance=this.buildRequest({call:c.eth_getBalance,formatters:[null,h.defaultBlockParam]}),this.getCode=this.buildRequest({call:c.eth_getCode,formatters:[null,h.defaultBlockParam]}),this.getStorageAt=this.buildRequest({call:c.eth_getStorageAt,formatters:[null,h.blockNumberToHex,h.defaultBlockParam]}),this.getPastLogs=this.buildRequest({call:c.eth_getLogs}),this.getBlockByHash=this.buildRequest({call:c.eth_getBlockByHash,formatters:[null,h.returnFullTxObjectParam]}),this.getBlockByNumber=this.buildRequest({call:c.eth_getBlockByNumber,formatters:[h.blockNumberToHex,h.returnFullTxObjectParam]}),this.getTransactionByHash=this.buildRequest({call:c.eth_getTransactionByHash}),this.getTransactionReceipt=this.buildRequest({call:c.eth_getTransactionReceipt}),this.getTransactionCount=this.buildRequest({call:c.eth_getTransactionCount,formatters:[null,h.defaultBlockParam]}),this.getGasPrice=this.buildRequest({call:c.eth_gasPrice}),this.getEstimateGas=s=>this.buildRequest({call:c.eth_estimateGas})([s]),this.setSafeSettings=this.buildRequest({call:c.safe_setSettings})}buildRequest(e){const{call:s,formatters:a}=e;return async n=>{a&&Array.isArray(n)&&a.forEach((l,u)=>{l&&(n[u]=l(n[u]))});const i={call:s,params:n||[]};return(await this.communicator.send(r.rpcCall,i)).data}}}const x="0x1626ba7e",O="0x20c13b0b",f=4001;class d extends Error{constructor(e,s,a){super(e),this.code=s,this.data=a,Object.setPrototypeOf(this,d.prototype)}}class S{constructor(e){this.communicator=e}async getPermissions(){return(await this.communicator.send(r.wallet_getPermissions,void 0)).data}async requestPermissions(e){if(!this.isPermissionRequestValid(e))throw new d("Permissions request is invalid",f);try{return(await this.communicator.send(r.wallet_requestPermissions,e)).data}catch{throw new d("Permissions rejected",f)}}isPermissionRequestValid(e){return e.every(s=>typeof s=="object"?Object.keys(s).every(a=>!!Object.values(m).includes(a)):!1)}}const w=(t,e)=>e.some(s=>s.parentCapability===t),V=()=>(t,e,s)=>{const a=s.value;return s.value=async function(){const n=new S(this.communicator);let i=await n.getPermissions();if(w(e,i)||(i=await n.requestPermissions([{[e]:{}}])),!w(e,i))throw new d("Permissions rejected",f);return a.apply(this)},s};var M=function(t,e,s,a){var n=arguments.length,i=n<3?e:a===null?a=Object.getOwnPropertyDescriptor(e,s):a,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(t,e,s,a);else for(var l=t.length-1;l>=0;l--)(o=t[l])&&(i=(n<3?o(i):n>3?o(e,s,i):o(e,s))||i);return n>3&&i&&Object.defineProperty(e,s,i),i};class _{constructor(e){this.communicator=e}async getChainInfo(){return(await this.communicator.send(r.getChainInfo,void 0)).data}async getInfo(){return(await this.communicator.send(r.getSafeInfo,void 0)).data}async experimental_getBalances({currency:e="usd"}={}){return(await this.communicator.send(r.getSafeBalances,{currency:e})).data}async check1271Signature(e,s="0x"){const a=await this.getInfo(),n=y({abi:[{constant:!1,inputs:[{name:"_dataHash",type:"bytes32"},{name:"_signature",type:"bytes"}],name:"isValidSignature",outputs:[{name:"",type:"bytes4"}],payable:!1,stateMutability:"nonpayable",type:"function"}],functionName:"isValidSignature",args:[e,s]}),i={call:c.eth_call,params:[{to:a.safeAddress,data:n},"latest"]};try{return(await this.communicator.send(r.rpcCall,i)).data.slice(0,10).toLowerCase()===x}catch{return!1}}async check1271SignatureBytes(e,s="0x"){const a=await this.getInfo(),n=y({abi:[{constant:!1,inputs:[{name:"_data",type:"bytes"},{name:"_signature",type:"bytes"}],name:"isValidSignature",outputs:[{name:"",type:"bytes4"}],payable:!1,stateMutability:"nonpayable",type:"function"}],functionName:"isValidSignature",args:[e,s]}),i={call:c.eth_call,params:[{to:a.safeAddress,data:n},"latest"]};try{return(await this.communicator.send(r.rpcCall,i)).data.slice(0,10).toLowerCase()===O}catch{return!1}}calculateMessageHash(e){return k(e)}calculateTypedMessageHash(e){const s=typeof e.domain.chainId=="object"?e.domain.chainId.toNumber():Number(e.domain.chainId);let a=e.primaryType;if(!a){const n=Object.values(e.types),i=Object.keys(e.types).filter(o=>n.every(l=>l.every(({type:u})=>u.replace("[","").replace("]","")!==o)));if(i.length===0||i.length>1)throw new Error("Please specify primaryType");a=i[0]}return I({message:e.message,domain:{...e.domain,chainId:s,verifyingContract:e.domain.verifyingContract,salt:e.domain.salt},types:e.types,primaryType:a})}async getOffChainSignature(e){return(await this.communicator.send(r.getOffChainSignature,e)).data}async isMessageSigned(e,s="0x"){let a;if(typeof e=="string"&&(a=async()=>{const n=this.calculateMessageHash(e);return await this.isMessageHashSigned(n,s)}),b(e)&&(a=async()=>{const n=this.calculateTypedMessageHash(e);return await this.isMessageHashSigned(n,s)}),a)return await a();throw new Error("Invalid message type")}async isMessageHashSigned(e,s="0x"){const a=[this.check1271Signature.bind(this),this.check1271SignatureBytes.bind(this)];for(const n of a)if(await n(e,s))return!0;return!1}async getEnvironmentInfo(){return(await this.communicator.send(r.getEnvironmentInfo,void 0)).data}async requestAddressBook(){return(await this.communicator.send(r.requestAddressBook,void 0)).data}}M([V()],_.prototype,"requestAddressBook",null);class G{constructor(e={}){const{allowedDomains:s=null,debug:a=!1}=e;this.communicator=new H(s,a),this.eth=new A(this.communicator),this.txs=new E(this.communicator),this.safe=new _(this.communicator),this.wallet=new S(this.communicator)}}export{g as MessageFormatter,r as Methods,c as RPC_CALLS,m as RestrictedMethods,G as default,q as getSDKVersion,b as isObjectEIP712TypedData};
1
+ import{r as T}from"./index-CpWZ5dtQ.js";import{b3 as y,b4 as k,b5 as I}from"./index-BK-Z4Gj8.js";import"./thirdweb-DdFz669q.js";import"./ui-5SR1m4h7.js";import"./vendor-BgJSXm_k.js";const q=()=>"9.1.0",v=t=>t.toString(16).padStart(2,"0"),C=t=>{const e=new Uint8Array(t/2);return window.crypto.getRandomValues(e),Array.from(e,v).join("")},R=()=>typeof window<"u"?C(10):new Date().getTime().toString(36);class g{}g.makeRequest=(t,e)=>({id:R(),method:t,params:e,env:{sdkVersion:q()}});g.makeResponse=(t,e,s)=>({id:t,success:!0,version:s,data:e});g.makeErrorResponse=(t,e,s)=>({id:t,success:!1,error:e,version:s});var r;(function(t){t.sendTransactions="sendTransactions",t.rpcCall="rpcCall",t.getChainInfo="getChainInfo",t.getSafeInfo="getSafeInfo",t.getTxBySafeTxHash="getTxBySafeTxHash",t.getSafeBalances="getSafeBalances",t.signMessage="signMessage",t.signTypedMessage="signTypedMessage",t.getEnvironmentInfo="getEnvironmentInfo",t.getOffChainSignature="getOffChainSignature",t.requestAddressBook="requestAddressBook",t.wallet_getPermissions="wallet_getPermissions",t.wallet_requestPermissions="wallet_requestPermissions"})(r||(r={}));var m;(function(t){t.requestAddressBook="requestAddressBook"})(m||(m={}));class H{constructor(e=null,s=!1){this.allowedOrigins=null,this.callbacks=new Map,this.debugMode=!1,this.isServer=typeof window>"u",this.isValidMessage=({origin:a,data:n,source:i})=>{const o=!n,l=!this.isServer&&i===window.parent,u=typeof n.version<"u"&&parseInt(n.version.split(".")[0]),B=typeof u=="number"&&u>=1;let p=!0;return Array.isArray(this.allowedOrigins)&&(p=this.allowedOrigins.find(P=>P.test(a))!==void 0),!o&&l&&B&&p},this.logIncomingMessage=a=>{console.info(`Safe Apps SDK v1: A message was received from origin ${a.origin}. `,a.data)},this.onParentMessage=a=>{this.isValidMessage(a)&&(this.debugMode&&this.logIncomingMessage(a),this.handleIncomingMessage(a.data))},this.handleIncomingMessage=a=>{const{id:n}=a,i=this.callbacks.get(n);i&&(i(a),this.callbacks.delete(n))},this.send=(a,n)=>{const i=g.makeRequest(a,n);if(this.isServer)throw new Error("Window doesn't exist");return window.parent.postMessage(i,"*"),new Promise((o,l)=>{this.callbacks.set(i.id,u=>{if(!u.success){l(new Error(u.error));return}o(u)})})},this.allowedOrigins=e,this.debugMode=s,this.isServer||window.addEventListener("message",this.onParentMessage)}}const b=t=>typeof t=="object"&&t!=null&&"domain"in t&&"types"in t&&"message"in t;T();class E{constructor(e){this.communicator=e}async getBySafeTxHash(e){if(!e)throw new Error("Invalid safeTxHash");return(await this.communicator.send(r.getTxBySafeTxHash,{safeTxHash:e})).data}async signMessage(e){const s={message:e};return(await this.communicator.send(r.signMessage,s)).data}async signTypedMessage(e){if(!b(e))throw new Error("Invalid typed data");return(await this.communicator.send(r.signTypedMessage,{typedData:e})).data}async send({txs:e,params:s}){if(!e||!e.length)throw new Error("No transactions were passed");const a={txs:e,params:s};return(await this.communicator.send(r.sendTransactions,a)).data}}const c={eth_call:"eth_call",eth_gasPrice:"eth_gasPrice",eth_getLogs:"eth_getLogs",eth_getBalance:"eth_getBalance",eth_getCode:"eth_getCode",eth_getBlockByHash:"eth_getBlockByHash",eth_getBlockByNumber:"eth_getBlockByNumber",eth_getStorageAt:"eth_getStorageAt",eth_getTransactionByHash:"eth_getTransactionByHash",eth_getTransactionReceipt:"eth_getTransactionReceipt",eth_getTransactionCount:"eth_getTransactionCount",eth_estimateGas:"eth_estimateGas",safe_setSettings:"safe_setSettings"},h={defaultBlockParam:(t="latest")=>t,returnFullTxObjectParam:(t=!1)=>t,blockNumberToHex:t=>Number.isInteger(t)?`0x${t.toString(16)}`:t};class A{constructor(e){this.communicator=e,this.call=this.buildRequest({call:c.eth_call,formatters:[null,h.defaultBlockParam]}),this.getBalance=this.buildRequest({call:c.eth_getBalance,formatters:[null,h.defaultBlockParam]}),this.getCode=this.buildRequest({call:c.eth_getCode,formatters:[null,h.defaultBlockParam]}),this.getStorageAt=this.buildRequest({call:c.eth_getStorageAt,formatters:[null,h.blockNumberToHex,h.defaultBlockParam]}),this.getPastLogs=this.buildRequest({call:c.eth_getLogs}),this.getBlockByHash=this.buildRequest({call:c.eth_getBlockByHash,formatters:[null,h.returnFullTxObjectParam]}),this.getBlockByNumber=this.buildRequest({call:c.eth_getBlockByNumber,formatters:[h.blockNumberToHex,h.returnFullTxObjectParam]}),this.getTransactionByHash=this.buildRequest({call:c.eth_getTransactionByHash}),this.getTransactionReceipt=this.buildRequest({call:c.eth_getTransactionReceipt}),this.getTransactionCount=this.buildRequest({call:c.eth_getTransactionCount,formatters:[null,h.defaultBlockParam]}),this.getGasPrice=this.buildRequest({call:c.eth_gasPrice}),this.getEstimateGas=s=>this.buildRequest({call:c.eth_estimateGas})([s]),this.setSafeSettings=this.buildRequest({call:c.safe_setSettings})}buildRequest(e){const{call:s,formatters:a}=e;return async n=>{a&&Array.isArray(n)&&a.forEach((l,u)=>{l&&(n[u]=l(n[u]))});const i={call:s,params:n||[]};return(await this.communicator.send(r.rpcCall,i)).data}}}const x="0x1626ba7e",O="0x20c13b0b",f=4001;class d extends Error{constructor(e,s,a){super(e),this.code=s,this.data=a,Object.setPrototypeOf(this,d.prototype)}}class S{constructor(e){this.communicator=e}async getPermissions(){return(await this.communicator.send(r.wallet_getPermissions,void 0)).data}async requestPermissions(e){if(!this.isPermissionRequestValid(e))throw new d("Permissions request is invalid",f);try{return(await this.communicator.send(r.wallet_requestPermissions,e)).data}catch{throw new d("Permissions rejected",f)}}isPermissionRequestValid(e){return e.every(s=>typeof s=="object"?Object.keys(s).every(a=>!!Object.values(m).includes(a)):!1)}}const w=(t,e)=>e.some(s=>s.parentCapability===t),V=()=>(t,e,s)=>{const a=s.value;return s.value=async function(){const n=new S(this.communicator);let i=await n.getPermissions();if(w(e,i)||(i=await n.requestPermissions([{[e]:{}}])),!w(e,i))throw new d("Permissions rejected",f);return a.apply(this)},s};var M=function(t,e,s,a){var n=arguments.length,i=n<3?e:a===null?a=Object.getOwnPropertyDescriptor(e,s):a,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(t,e,s,a);else for(var l=t.length-1;l>=0;l--)(o=t[l])&&(i=(n<3?o(i):n>3?o(e,s,i):o(e,s))||i);return n>3&&i&&Object.defineProperty(e,s,i),i};class _{constructor(e){this.communicator=e}async getChainInfo(){return(await this.communicator.send(r.getChainInfo,void 0)).data}async getInfo(){return(await this.communicator.send(r.getSafeInfo,void 0)).data}async experimental_getBalances({currency:e="usd"}={}){return(await this.communicator.send(r.getSafeBalances,{currency:e})).data}async check1271Signature(e,s="0x"){const a=await this.getInfo(),n=y({abi:[{constant:!1,inputs:[{name:"_dataHash",type:"bytes32"},{name:"_signature",type:"bytes"}],name:"isValidSignature",outputs:[{name:"",type:"bytes4"}],payable:!1,stateMutability:"nonpayable",type:"function"}],functionName:"isValidSignature",args:[e,s]}),i={call:c.eth_call,params:[{to:a.safeAddress,data:n},"latest"]};try{return(await this.communicator.send(r.rpcCall,i)).data.slice(0,10).toLowerCase()===x}catch{return!1}}async check1271SignatureBytes(e,s="0x"){const a=await this.getInfo(),n=y({abi:[{constant:!1,inputs:[{name:"_data",type:"bytes"},{name:"_signature",type:"bytes"}],name:"isValidSignature",outputs:[{name:"",type:"bytes4"}],payable:!1,stateMutability:"nonpayable",type:"function"}],functionName:"isValidSignature",args:[e,s]}),i={call:c.eth_call,params:[{to:a.safeAddress,data:n},"latest"]};try{return(await this.communicator.send(r.rpcCall,i)).data.slice(0,10).toLowerCase()===O}catch{return!1}}calculateMessageHash(e){return k(e)}calculateTypedMessageHash(e){const s=typeof e.domain.chainId=="object"?e.domain.chainId.toNumber():Number(e.domain.chainId);let a=e.primaryType;if(!a){const n=Object.values(e.types),i=Object.keys(e.types).filter(o=>n.every(l=>l.every(({type:u})=>u.replace("[","").replace("]","")!==o)));if(i.length===0||i.length>1)throw new Error("Please specify primaryType");a=i[0]}return I({message:e.message,domain:{...e.domain,chainId:s,verifyingContract:e.domain.verifyingContract,salt:e.domain.salt},types:e.types,primaryType:a})}async getOffChainSignature(e){return(await this.communicator.send(r.getOffChainSignature,e)).data}async isMessageSigned(e,s="0x"){let a;if(typeof e=="string"&&(a=async()=>{const n=this.calculateMessageHash(e);return await this.isMessageHashSigned(n,s)}),b(e)&&(a=async()=>{const n=this.calculateTypedMessageHash(e);return await this.isMessageHashSigned(n,s)}),a)return await a();throw new Error("Invalid message type")}async isMessageHashSigned(e,s="0x"){const a=[this.check1271Signature.bind(this),this.check1271SignatureBytes.bind(this)];for(const n of a)if(await n(e,s))return!0;return!1}async getEnvironmentInfo(){return(await this.communicator.send(r.getEnvironmentInfo,void 0)).data}async requestAddressBook(){return(await this.communicator.send(r.requestAddressBook,void 0)).data}}M([V()],_.prototype,"requestAddressBook",null);class G{constructor(e={}){const{allowedDomains:s=null,debug:a=!1}=e;this.communicator=new H(s,a),this.eth=new A(this.communicator),this.txs=new E(this.communicator),this.safe=new _(this.communicator),this.wallet=new S(this.communicator)}}export{g as MessageFormatter,r as Methods,c as RPC_CALLS,m as RestrictedMethods,G as default,q as getSDKVersion,b as isObjectEIP712TypedData};