@dcl/auth-site 4.20.1-29287535500.commit-21e2097 → 4.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/assets/{ConstantsUtil-DkgBhC-3.js → ConstantsUtil-SfeDQRNO.js} +1 -1
  2. package/assets/{ContentfulRichText-CpTGRqW5.js → ContentfulRichText-B493-l1G.js} +1 -1
  3. package/assets/{ExchangeController-DAuyR32a.js → ExchangeController-Cl7LpW_9.js} +1 -1
  4. package/assets/{HelpersUtil-BmBOHU8y.js → HelpersUtil-BqxjBOsb.js} +1 -1
  5. package/assets/LoginPage-3mBiytHd.js +1 -0
  6. package/assets/{NetworkUtil-hPciM8MB.js → NetworkUtil-WtQP9K5L.js} +1 -1
  7. package/assets/{SwapController-BuTlR-rE.js → SwapController-C3sOw1fb.js} +1 -1
  8. package/assets/{W3MFrameProviderSingleton-C1QswdNU.js → W3MFrameProviderSingleton-GariHyC1.js} +3 -3
  9. package/assets/{biconomy-Fnzq2AaG.js → biconomy-ok_Fev4O.js} +1 -1
  10. package/assets/{browser-yuJ3wGx6.js → browser-CL7pc_C2.js} +1 -1
  11. package/assets/browser-ponyfill-B9OjpPGs.js +1 -0
  12. package/assets/{ccip-CAaY56-g.js → ccip-BlbxM0LQ.js} +1 -1
  13. package/assets/{ccip-DLLDQWdG.js → ccip-CFiU7kCg.js} +1 -1
  14. package/assets/{chains-BWttGtkR.js → chains-CGXwPY-w.js} +1 -1
  15. package/assets/{common-7lNGOStV.js → common-CvKtb4n1.js} +1 -1
  16. package/assets/{controller-Bi4psLHv.js → controller-BFbz0Wfy.js} +2 -2
  17. package/assets/{data-capture-D-C94jSy.js → data-capture-Bjp5qmbu.js} +1 -1
  18. package/assets/{email-B62o62VS.js → email-dOZOTXLM.js} +1 -1
  19. package/assets/{embedded-wallet-Bufr94SG.js → embedded-wallet-4C0zCBzD.js} +1 -1
  20. package/assets/{engine-Ds35bLsp.js → engine-BF4fgHph.js} +1 -1
  21. package/assets/{estimate-l1-fee-BJHE4ePY.js → estimate-l1-fee-DFM9SNlY.js} +1 -1
  22. package/assets/{ethereum-B7A4SHAX.js → ethereum-D1IvEqvR.js} +1 -1
  23. package/assets/{extractIPFS-DgWXFyTF.js → extractIPFS-DJ38044A.js} +1 -1
  24. package/assets/{features-yOzv-e_q.js → features-Dq7eLLHj.js} +1 -1
  25. package/assets/{fetchTokenMetadata-CdsDJI22.js → fetchTokenMetadata-DFbXfV36.js} +1 -1
  26. package/assets/{fortmatic-DSTwSTGw.js → fortmatic-VXwlmn3x.js} +1 -1
  27. package/assets/{get-ecosystem-wallet-info-r53Q9L1F.js → get-ecosystem-wallet-info-7Lw-sZ_z.js} +1 -1
  28. package/assets/{getBalance-DYKZS6Hn.js → getBalance-lwqG5BkA.js} +1 -1
  29. package/assets/{getInstalledModules-BsaRLOBo.js → getInstalledModules-BqEUrGDu.js} +1 -1
  30. package/assets/{getNFT-BT0va_ps.js → getNFT-CdoOvyuq.js} +2 -2
  31. package/assets/{getNFT-DyXFPTtJ.js → getNFT-qEDnShr-.js} +1 -1
  32. package/assets/{if-defined-BGHXcjlf.js → if-defined-CqpJarBn.js} +1 -1
  33. package/assets/{in-app-wallet-calls-D-jHkY3c.js → in-app-wallet-calls-DnbOJdqi.js} +1 -1
  34. package/assets/{index-CkD9exTg.js → index-48_zL_8V.js} +3 -3
  35. package/assets/{index-ClytS1EG.js → index-4Rm21Jcs.js} +1 -1
  36. package/assets/{index-BXRMK8j1.js → index-B4nv3uRr.js} +1 -1
  37. package/assets/{index-2jBQ38d_.js → index-B90inivw.js} +1 -1
  38. package/assets/{index-CmNc8trc.js → index-BGzx8xC8.js} +1 -1
  39. package/assets/{index-CYuFlPOC.js → index-BNctYT5W.js} +1 -1
  40. package/assets/{index-DAvzQoJc.js → index-BZnk5nGE.js} +1 -1
  41. package/assets/{index-bLgqUt1C.js → index-BehUnmBQ.js} +1 -1
  42. package/assets/{index-zorQVT5C.js → index-BgA11815.js} +1 -1
  43. package/assets/{index-Ds1ydXx9.js → index-BgjSH5C0.js} +2 -2
  44. package/assets/{index-DPoBMxER.js → index-Bmtxr8ck.js} +1 -1
  45. package/assets/{index-BHfrnWbK.js → index-BnEh4tgY.js} +1 -1
  46. package/assets/{index-C6oKjgTD.js → index-BnMK4rtE.js} +1 -1
  47. package/assets/{index-Ynxfq_j7.js → index-BxDS7YgF.js} +1 -1
  48. package/assets/{index-JXnAd7HU.js → index-C0a8a3_a.js} +1 -1
  49. package/assets/{index-BORKfZ0w.js → index-C2wXt8bX.js} +1 -1
  50. package/assets/{index-CUTvqvnd.js → index-C9zadnoP.js} +1 -1
  51. package/assets/{index-Xt3c8bVw.js → index-CA_7NqLN.js} +2 -2
  52. package/assets/{index-DAn6fi4B.js → index-CJQ7XUF1.js} +1 -1
  53. package/assets/{index-Co20Wufm.js → index-CMVgYvcj.js} +1 -1
  54. package/assets/{index-CbNgsots.js → index-CNiv2JYH.js} +1 -1
  55. package/assets/{index-D0kxJqlX.js → index-COjWxfCR.js} +1 -1
  56. package/assets/{index-SvnadGeW.js → index-CSkZf6TU.js} +1 -1
  57. package/assets/{index-DfmwgrQl.js → index-CVYOFAvL.js} +1 -1
  58. package/assets/{index-BU93e28H.js → index-CVqr-7Pt.js} +1 -1
  59. package/assets/{index-mkKLfL50.js → index-CZRVN2vE.js} +1 -1
  60. package/assets/{index-h7zgn9mx.js → index-C_o5O_iU.js} +9 -9
  61. package/assets/{index-xfbV3wiz.js → index-CgTPsSZC.js} +1 -1
  62. package/assets/{index-ClM-sGXu.js → index-CmYKoHtM.js} +1 -1
  63. package/assets/{index-BWW9faHX.js → index-CpyBHHGL.js} +1 -1
  64. package/assets/{index-D3A-KZkC.js → index-CusnlpEv.js} +1 -1
  65. package/assets/{index-BuAaz9-i.js → index-Czf8Yu5V.js} +1 -1
  66. package/assets/{index-j12pitQF.js → index-D28HIM1b.js} +1 -1
  67. package/assets/{index-Db4WTF-F.js → index-D3-eBZaP.js} +1 -1
  68. package/assets/{index-DrOlu4Tm.js → index-DJKVllQq.js} +1 -1
  69. package/assets/{index-B5GQLMSc.js → index-DLztodpx.js} +3 -3
  70. package/assets/{index-BAbd-m37.js → index-DO37X-UR.js} +1 -1
  71. package/assets/{index-DqM7glUM.js → index-DWhePAr8.js} +1 -1
  72. package/assets/index-DdAb4cgP.css +1 -0
  73. package/assets/{index-DrBxmxAk.js → index-DhrbQM9o.js} +1 -1
  74. package/assets/{index-DXlOrQan.js → index-DkoCaWFP.js} +1 -1
  75. package/assets/{index-Dd6WSWIJ.js → index-DpgCenmo.js} +1 -1
  76. package/assets/{index-C2UZfzQ-.js → index-Dqf3E5Am.js} +1 -1
  77. package/assets/{index-Cjq04DXG.js → index-DxTxoCQ5.js} +1 -1
  78. package/assets/{index-H1RtENWs.js → index-MOkgM3CG.js} +1 -1
  79. package/assets/{index-BpVXwPYi.js → index-aGypPCn4.js} +1 -1
  80. package/assets/{index-DiMYCz_K.js → index-lExqs17M.js} +1 -1
  81. package/assets/{index-BXwt6qMC.js → index-ltBsvN7l.js} +1 -1
  82. package/assets/{index.es-BGCdZ8iz.js → index.es-DnpWJXa6.js} +1 -1
  83. package/assets/{index.es-q-O--bde.js → index.es-obcdOSPN.js} +1 -1
  84. package/assets/{native-JpImfY6X.js → native-B7Tb9XD0.js} +1 -1
  85. package/assets/{networks-B-X638Cy.js → networks-xZgfuUkI.js} +3 -3
  86. package/assets/{onramp-OnMvtDz0.js → onramp-DRY-VmEl.js} +1 -1
  87. package/assets/{openzeppelin-BU8bW370.js → openzeppelin-BZfSJIk4.js} +1 -1
  88. package/assets/{ownerOf-TveQWfL6.js → ownerOf-Chv3cItD.js} +1 -1
  89. package/assets/{parseNft-CfxuqOgy.js → parseNft-d6d6Hp6d.js} +2 -2
  90. package/assets/{pay-with-exchange-Ck0Cj6VC.js → pay-with-exchange-Fws3sgDP.js} +1 -1
  91. package/assets/{qr-overlay-EnFVg6ne.js → qr-overlay-CRwPPsut.js} +3 -3
  92. package/assets/{receive-ucd1iMgu.js → receive-ENeHUThj.js} +1 -1
  93. package/assets/{ref-BIDK04Qt.js → ref-BJXu_ix1.js} +1 -1
  94. package/assets/{resolveImplementation-CRGcSdv-.js → resolveImplementation-BDMCDrvF.js} +1 -1
  95. package/assets/{secp256k1-GERMcQ1g.js → secp256k1-CAuxtucr.js} +1 -1
  96. package/assets/{send-NLAJsBux.js → send-BVveMXEO.js} +1 -1
  97. package/assets/{send-eip712-transaction-haPD8e0J.js → send-eip712-transaction-BLYLbaE2.js} +1 -1
  98. package/assets/{send-gasless-transaction-BZ-k8SPZ.js → send-gasless-transaction-H5yovUSA.js} +2 -2
  99. package/assets/{session-proposal-CvW06ECh.js → session-proposal-BOVuEqZb.js} +1 -1
  100. package/assets/{session-request-hdyj4KFj.js → session-request-u0q6IDVU.js} +2 -2
  101. package/assets/{socials-C0OswFfG.js → socials-CT51nzyt.js} +1 -1
  102. package/assets/{swaps-Ylmuyai3.js → swaps-DcnyL-aF.js} +1 -1
  103. package/assets/{thirdweb-DwEJXXOk.js → thirdweb-RfTGDewD.js} +5 -5
  104. package/assets/{totalSupply-DIe1jFWb.js → totalSupply-D1tOGyvE.js} +1 -1
  105. package/assets/{transactions-D2TvDz1u.js → transactions-LbE_YtGz.js} +1 -1
  106. package/assets/{ui-CCQzH9lw.js → ui-CUXWd4jk.js} +5 -5
  107. package/assets/{vendor-DNqBwP4B.js → vendor-DlkLYSlV.js} +1 -1
  108. package/assets/{w3m-modal-NV3fM5nf.js → w3m-modal-BSFcMGCh.js} +1 -1
  109. package/assets/{wallets-BbpGg0Ps.js → wallets-OS7LlF3P.js} +5 -5
  110. package/assets/{web-connector-v65JqJ1n.js → web-connector-3zdQreYv.js} +3 -3
  111. package/index.html +5 -5
  112. package/package.json +2 -2
  113. package/assets/LoginPage-CyMLzwvv.js +0 -1
  114. package/assets/browser-ponyfill-RildGPMW.js +0 -1
  115. package/assets/index-DXHA7qZa.css +0 -1
@@ -1 +1 @@
1
- import{r as T}from"./index-CpWZ5dtQ.js";import{b4 as y,b5 as k,b6 as I}from"./index-h7zgn9mx.js";import"./thirdweb-DwEJXXOk.js";import"./ui-CCQzH9lw.js";import"./vendor-DNqBwP4B.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{b4 as y,b5 as k,b6 as I}from"./index-C_o5O_iU.js";import"./thirdweb-RfTGDewD.js";import"./ui-CUXWd4jk.js";import"./vendor-DlkLYSlV.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,4 +1,4 @@
1
- import{j as m,r as c,i as f,h as d}from"./index-CkD9exTg.js";import{n as u,c as h}from"./index-zorQVT5C.js";import{o as b}from"./if-defined-BGHXcjlf.js";import"./index-mkKLfL50.js";const v=m`
1
+ import{j as m,r as c,i as f,h as d}from"./index-48_zL_8V.js";import{n as u,c as h}from"./index-BgA11815.js";import{o as b}from"./if-defined-CqpJarBn.js";import"./index-CZRVN2vE.js";const v=m`
2
2
  :host {
3
3
  position: relative;
4
4
  display: inline-block;
@@ -1,4 +1,4 @@
1
- import{d as b,r as p,e as f,i as m,h as l}from"./index-CkD9exTg.js";import{n as s,c as v}from"./index-zorQVT5C.js";const h=b`
1
+ import{d as b,r as p,e as f,i as m,h as l}from"./index-48_zL_8V.js";import{n as s,c as v}from"./index-BgA11815.js";const h=b`
2
2
  button {
3
3
  border: none;
4
4
  background: transparent;
@@ -1,4 +1,4 @@
1
- import{d as c,r as h,e as m,i as b,h as a}from"./index-CkD9exTg.js";import{n as o,c as x}from"./index-zorQVT5C.js";import{o as f}from"./if-defined-BGHXcjlf.js";import{e as $,n as g}from"./ref-BIDK04Qt.js";const w=c`
1
+ import{d as c,r as h,e as m,i as b,h as a}from"./index-48_zL_8V.js";import{n as o,c as x}from"./index-BgA11815.js";import{o as f}from"./if-defined-CqpJarBn.js";import{e as $,n as g}from"./ref-BJXu_ix1.js";const w=c`
2
2
  :host {
3
3
  position: relative;
4
4
  width: 100%;