Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@haechi-labs/face-sdk

Package Overview
Dependencies
Maintainers
3
Versions
99
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@haechi-labs/face-sdk - npm Package Compare versions

Comparing version 1.10.4 to 1.10.5-alpha.0

dist/cdn/index.js.gz

2

./dist/cjs/index.js

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@haechi-labs/face-types"),e=require("@noble/hashes/sha3"),n=require("aptos"),r=require("ethers"),i=require("near-api-js"),o=require("@solana/web3.js");function s(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}})),e.default=t,Object.freeze(e)}var a=s(i),c=function(t,e){return c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},c(t,e)};function u(t,e,n,r){return new(n||(n=Promise))((function(i,o){function s(t){try{c(r.next(t))}catch(t){o(t)}}function a(t){try{c(r.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))}function h(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}var l=function(){function e(t){this.internal=t}return e.prototype.login=function(e){return u(this,void 0,void 0,(function(){return h(this,(function(n){return t.assertArgument(e,Array.isArray(e)&&e.length>0&&function(t,e,n){if(n||2===arguments.length)for(var r,i=0,o=e.length;i<o;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))}([],e,!0).every((function(e){return Object.values(t.LoginProvider).includes(e)})),"providers",!1),[2,this.internal.loginWithCredential(e)]}))}))},e.prototype.directSocialLogin=function(e){return u(this,void 0,void 0,(function(){return h(this,(function(n){return t.assertArgument(e,"string"==typeof e,"provider"),[2,this.internal.directSocialLogin(e)]}))}))},e.prototype.getIdToken=function(e,n){return u(this,void 0,void 0,(function(){return h(this,(function(r){return t.assertArgument(e,"string"==typeof e,"provider"),t.assertArgument(n,"string"==typeof n,"accessToken"),[2,this.internal.getIdToken(e,n)]}))}))},e.prototype.loginWithIdToken=function(e){return u(this,void 0,void 0,(function(){return h(this,(function(n){return t.assertArgument(e,e.idToken&&e.sig,"loginWithIdTokenRequest"),[2,this.internal.loginWithIdToken(e)]}))}))},e.prototype.loginWithAccessToken=function(e){return u(this,void 0,void 0,(function(){return h(this,(function(n){return t.assertArgument(e,e.accessToken&&e.sig,"loginWithIdTokenRequest"),[2,this.internal.loginWithAccessToken(e)]}))}))},e.prototype.logout=function(){return u(this,void 0,void 0,(function(){return h(this,(function(t){switch(t.label){case 0:return[4,this.internal.logout()];case 1:return t.sent(),[2]}}))}))},e.prototype.getCurrentUser=function(){return u(this,void 0,void 0,(function(){return h(this,(function(t){switch(t.label){case 0:return[4,this.internal.getCurrentUser()];case 1:return[2,t.sent()]}}))}))},e.prototype.isLoggedIn=function(){return u(this,void 0,void 0,(function(){return h(this,(function(t){switch(t.label){case 0:return[4,this.internal.isLoggedIn()];case 1:return[2,t.sent()]}}))}))},e}(),d=function(){function r(t){this.internal=t}return r.prototype.getPublicKeys=function(){return u(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this.internal.getAddresses(t.Blockchain.APTOS)];case 1:return[2,e.sent().map((function(t){return n.HexString.ensure(t)}))]}}))}))},r.prototype.getAddresses=function(){return u(this,void 0,void 0,(function(){return h(this,(function(r){switch(r.label){case 0:return[4,this.internal.getAddresses(t.Blockchain.APTOS)];case 1:return[2,r.sent().map((function(t){var r=Uint8Array.from(t.substring(2).match(/.{1,2}/g).map((function(t){return parseInt(t,16)}))),i=new Uint8Array(r.length+1);i.set(r),i.set([0],r.length);var o=e.sha3_256.create();return o.update(i),n.HexString.fromUint8Array(o.digest())}))]}}))}))},r.prototype.signMultiAgentTransaction=function(e){return u(this,void 0,void 0,(function(){return h(this,(function(r){switch(r.label){case 0:return[4,this.internal.sendRpc({method:t.JsonRpcMethod.aptos_signMultiAgentTransaction,params:[e.raw_txn.sender.address,n.BCS.bcsToBytes(e)]})];case 1:return[2,r.sent()]}}))}))},r.prototype.signMessage=function(e){return u(this,void 0,void 0,(function(){var n,r;return h(this,(function(i){switch(i.label){case 0:return n=Buffer.from(JSON.stringify(e)),[4,this.internal.sendRpc({method:t.JsonRpcMethod.aptos_signMessage,params:[n]})];case 1:return r=i.sent(),[2,JSON.parse(r)]}}))}))},r.prototype.signAndSubmitTransaction=function(e,n){return u(this,void 0,void 0,(function(){var r;return h(this,(function(i){switch(i.label){case 0:return[4,this.internal.getAddresses(t.Blockchain.APTOS)];case 1:return r=i.sent()[0],[4,this.internal.sendRpc({method:t.JsonRpcMethod.aptos_signAndSubmitTransaction,params:[Buffer.from(r),Buffer.from(JSON.stringify(e)),n]})];case 2:return[2,{hash:i.sent()}]}}))}))},r.prototype.signTransaction=function(e,n){return u(this,void 0,void 0,(function(){var r,i;return h(this,(function(o){switch(o.label){case 0:return[4,this.internal.getAddresses(t.Blockchain.APTOS)];case 1:return r=o.sent()[0],[4,this.internal.sendRpc({method:t.JsonRpcMethod.aptos_signTransaction,params:[Buffer.from(r),Buffer.from(JSON.stringify(e)),n]})];case 2:return i=o.sent(),[2,JSON.parse(i)]}}))}))},r}(),f=function(){function t(t){this.internal=t}return t.prototype.getProvider=function(){return new d(this.internal)},t}(),p=function(){function e(t){this.internal=t}return e.prototype.connect=function(e){return u(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:return t.assertArgument(e,e.bappUsn&&e.signature,"request"),[4,this.internal.boraConnect(e)];case 1:return[2,n.sent()]}}))}))},e.prototype.isConnected=function(e){return u(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:return t.assertArgument(e,"string"==typeof e,"bappUsn"),[4,this.internal.boraIsConnected(e)];case 1:return[2,n.sent()]}}))}))},e}(),v=function(){function e(t){this.internal=t}return e.prototype.getPublicKeys=function(){return u(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this.internal.getAddresses(t.Blockchain.NEAR)];case 1:return[2,e.sent().map((function(t){return a.utils.PublicKey.fromString(a.utils.serialize.base_encode(Buffer.from(t,"hex")))}))]}}))}))},e.prototype.getBalance=function(e,n){return u(this,void 0,void 0,(function(){var i;return h(this,(function(o){switch(o.label){case 0:return t.assertArgument(e,"string"==typeof e,"address"),t.assertArgument(n,"string"==typeof n,"contractAddress",!1),[4,this.internal.sendRpc({method:t.JsonRpcMethod.near_get_balance,params:[e,n]})];case 1:return i=o.sent(),[2,r.BigNumber.from(i)]}}))}))},e.prototype.signAndSendTransaction=function(t){return u(this,void 0,void 0,(function(){var e;return h(this,(function(n){switch(n.label){case 0:return e={serializedHex:Buffer.from(a.utils.serialize.serialize(a.transactions.SCHEMA,t)).toString("hex")},[4,this.internal.sendRpc({method:"near_broadcast_tx_async",params:[e]})];case 1:return[2,n.sent()]}}))}))},e}(),w=function(){function t(t){this.internal=t}return t.prototype.getProvider=function(){return new v(this.internal)},t}(),m=function(){function e(t){this.internal=t}return e.prototype.getPublicKeys=function(){return u(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this.internal.getAddresses(t.Blockchain.SOLANA)];case 1:return[2,e.sent().map((function(t){return new o.PublicKey(r.ethers.utils.base58.decode(t))}))]}}))}))},e.prototype.signAndSendTransaction=function(t){return u(this,void 0,void 0,(function(){var e;return h(this,(function(n){switch(n.label){case 0:return e={serializedHex:t.serialize({requireAllSignatures:!1,verifySignatures:!1}).toString("hex")},[4,this.internal.sendRpc({method:"solana_sendTransaction",params:[e]})];case 1:return[2,n.sent()]}}))}))},e}(),g=function(){function t(t){this.internal=t}return t.prototype.getProvider=function(){return new m(this.internal)},t}(),y={display:"none",position:"fixed",top:"0",right:"0",width:"100%",height:"100%",borderRadius:"0",border:"none",zIndex:"2147483647"};var k=function(){var t=this;this._isCompleted=!1,this._eventListeners=Array(),this.complete=function(){t._isCompleted=!0,t._eventListeners.forEach((function(t){return t()}))},this.add=function(e){t._eventListeners.push(e)},this.isCompleted=function(){return t._isCompleted}},A=function(){function e(t,e,n,r){var i,o=this;this._ready=new k,this.requestIndex=0,this.activeElement=null,this._blockchain=e,this._env=n,this.iframeUrl=r;var s=Math.random().toString();if(this.randomPrefix=s.substring(s.length-6),document.getElementById("face-iframe"))throw new Error("Face is already initialized, Face can be initialized once.");window.addEventListener("message",(function(t){return u(o,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return t.origin!==r?[2]:[4,this.processMessage(t.data)];case 1:return e.sent(),[2]}}))}))}));var a=null!==(i="1.10.4")?i:"";this._iframe=new Promise((function(i){var o=function(){if(!document.getElementById("face-iframe")){var o=document.createElement("iframe");o.id="face-iframe",o.title="Secure Modal",o.src=new URL("".concat(r,"?api_key=").concat(t,"&blockchain=").concat(e,"&env=").concat(n,"&version=").concat(a,"&type=").concat("web")).href,o.allow="clipboard-read; clipboard-write",function(t){for(var e=0,n=Object.entries(y);e<n.length;e++){var r=n[e],i=r[0],o=r[1];t.style[i]=o}}(o),document.body.appendChild(o),i(o)}};["loaded","interactive","complete"].includes(document.readyState)?o():window.addEventListener("load",o,!1)}))}return e.prototype.sendChildMessage=function(e){var n,r;return u(this,void 0,void 0,(function(){var i;return h(this,(function(o){switch(o.label){case 0:return[4,this.ready()];case 1:return o.sent(),this.requestIndex+=1,i=e.id?"".concat(e.id):"".concat(this.randomPrefix,"-").concat(this.requestIndex),e.id=i,e.from=t.JsonRpcSource.FACE_SDK,[4,this._iframe];case 2:return null===(r=null===(n=o.sent())||void 0===n?void 0:n.contentWindow)||void 0===r||r.postMessage(e,"*"),[2,i]}}))}))},e.prototype.waitForResponse=function(t){return new Promise((function(e,n){var r=function(i){var o=i.data;t&&o.id!==t||(window.removeEventListener("message",r),o.error?n(o.error):e(o.result))};window.addEventListener("message",r)}))},e.prototype.processMessage=function(e){return u(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:switch(e.method){case t.JsonRpcMethod.face_ready:return[3,1];case t.JsonRpcMethod.face_openIframe:return[3,2];case t.JsonRpcMethod.face_closeIframe:return[3,4]}return[3,6];case 1:return this._ready.complete(),[3,6];case 2:return[4,this.showOverlay()];case 3:case 5:return n.sent(),[3,6];case 4:return[4,this.hideOverlay()];case 6:return[2]}}))}))},e.prototype.ready=function(){return u(this,void 0,void 0,(function(){var t=this;return h(this,(function(e){return[2,new Promise((function(e){return u(t,void 0,void 0,(function(){return h(this,(function(t){return this._ready.isCompleted()?(e(),[2]):(this._ready.add((function(){e()})),[2])}))}))}))]}))}))},e.prototype.showOverlay=function(){return u(this,void 0,void 0,(function(){var t;return h(this,(function(e){switch(e.label){case 0:return[4,this.ready()];case 1:return e.sent(),[4,this._iframe];case 2:return(t=e.sent()).style.display="block",this.activeElement=document.activeElement,t.focus(),[2]}}))}))},e.prototype.hideOverlay=function(){var t;return u(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this.ready()];case 1:return e.sent(),[4,this._iframe];case 2:return e.sent().style.display="none",(null===(t=this.activeElement)||void 0===t?void 0:t.focus)&&this.activeElement.focus(),this.activeElement=null,[2]}}))}))},e.prototype.setBlockchain=function(t){this._blockchain=t},e.prototype.throwExceptionUnsupportedBlockchain=function(e){if(e.includes(this._blockchain))throw t.unsupportedChainError()},e.prototype.getBlockchain=function(){return this._blockchain},e}();function b(e){switch(e){case t.Network.ETHEREUM:case t.Network.POLYGON:case t.Network.BNB_SMART_CHAIN:case t.Network.KLAYTN:case t.Network.SOLANA:case t.Network.BORA:case t.Network.NEAR:case t.Network.APTOS:case t.Network.MEVERSE:case t.Network.PSM:return!0;default:return!1}}function N(e){switch(e){case t.Network.ETHEREUM:case t.Network.GOERLI:return t.Blockchain.ETHEREUM;case t.Network.POLYGON:case t.Network.MUMBAI:return t.Blockchain.POLYGON;case t.Network.BNB_SMART_CHAIN:case t.Network.BNB_SMART_CHAIN_TESTNET:return t.Blockchain.BNB_SMART_CHAIN;case t.Network.KLAYTN:case t.Network.BAOBAB:return t.Blockchain.KLAYTN;case t.Network.SOLANA:case t.Network.SOLANA_DEVNET:return t.Blockchain.SOLANA;case t.Network.BORA:case t.Network.BORA_TESTNET:return t.Blockchain.BORA;case t.Network.NEAR:case t.Network.NEAR_TESTNET:return t.Blockchain.NEAR;case t.Network.APTOS:case t.Network.APTOS_TESTNET:return t.Blockchain.APTOS;case t.Network.MEVERSE:case t.Network.MEVERSE_TESTNET:return t.Blockchain.MEVERSE;case t.Network.PSM:case t.Network.PSM_TESTNET:return t.Blockchain.PSM;default:return t.Blockchain.ETHEREUM}}r.BigNumber.from(1e5).toHexString();var E=function(){function e(e){var n=e.apiKey,r=e.network,i=e.env,o=e.iframeUrl,s=e.face;this.network=r||t.Network.ETHEREUM;var a=N(this.network);this.env=null!=i?i:function(e){return!e||e!==t.Network.GOERLI&&e!==t.Network.MUMBAI&&e!==t.Network.BAOBAB&&e!==t.Network.BNB_SMART_CHAIN_TESTNET&&e!==t.Network.BORA_TESTNET&&e!==t.Network.SOLANA_DEVNET&&e!==t.Network.NEAR_TESTNET&&e!==t.Network.APTOS_TESTNET&&e!==t.Network.MEVERSE_TESTNET&&e!==t.Network.PSM_TESTNET?t.Env.ProdMainnet:t.Env.ProdTest}(r),this.iframe=new A(n,a,this.env,function(e,n){if(null!=n)return n;switch(e){case t.Env.Local:return"http://localhost:3333";case t.Env.Dev:return"https://app.dev.facewallet.xyz";case t.Env.StageTest:return"https://app.stage-test.facewallet.xyz";case t.Env.ProdTest:return"https://app.test.facewallet.xyz";case t.Env.StageMainnet:return"https://app.stage.facewallet.xyz";case t.Env.ProdMainnet:default:return"https://app.facewallet.xyz"}}(this.env,o)),this.face=s,this.iframeUrl=o}return e.prototype.getAddresses=function(e){return u(this,void 0,void 0,(function(){var n,r;return h(this,(function(i){switch(i.label){case 0:return[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_accounts,params:[e]})];case 1:return n=i.sent(),[4,this.iframe.waitForResponse(n)];case 2:return(r=i.sent())?[2,r]:[2,Promise.reject(new Error("get address failed"))]}}))}))},e.prototype.estimateGas=function(t){return u(this,void 0,void 0,(function(){return h(this,(function(t){return[2,0]}))}))},e.prototype.getBalance=function(e,n){return u(this,void 0,void 0,(function(){var i,o,s,a;return h(this,(function(c){switch(c.label){case 0:return n?[4,this.encodeData(["function balanceOf(address owner) view returns (uint256)"],"balanceOf",[e])]:[3,3];case 1:return i=c.sent(),[4,this.sendRpc({method:t.JsonRpcMethod.eth_call,params:[{to:n,data:i},"latest"]})];case 2:return o=c.sent(),[2,r.BigNumber.from(o)];case 3:return a=(s=r.BigNumber).from,[4,this.sendRpc({method:t.JsonRpcMethod.eth_getBalance,params:[e,"latest"]})];case 4:return[2,a.apply(s,[c.sent()])]}}))}))},e.prototype.ownerOf=function(e,n){return u(this,void 0,void 0,(function(){var r;return h(this,(function(i){switch(i.label){case 0:return[4,this.encodeData(["function ownerOf(uint256 tokenId) view returns (address)"],"ownerOf",[n])];case 1:return r=i.sent(),[4,this.sendRpc({method:t.JsonRpcMethod.eth_call,params:[{to:e,data:r},"latest"]})];case 2:return[2,("0x"+i.sent().substring(26)).toLowerCase()]}}))}))},e.prototype.logout=function(){return u(this,void 0,void 0,(function(){var e;return h(this,(function(n){switch(n.label){case 0:return[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_logOut})];case 1:return e=n.sent(),[4,this.iframe.waitForResponse(e)];case 2:return n.sent(),[2]}}))}))},e.prototype.getCurrentUser=function(){return u(this,void 0,void 0,(function(){var e;return h(this,(function(n){switch(n.label){case 0:return[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_currentUser})];case 1:return e=n.sent(),[4,this.iframe.waitForResponse(e)];case 2:return[2,n.sent()]}}))}))},e.prototype.isLoggedIn=function(){return u(this,void 0,void 0,(function(){var e;return h(this,(function(n){switch(n.label){case 0:return[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_loggedIn})];case 1:return n.sent(),[4,this.iframe.waitForResponse()];case 2:return(e=n.sent())?[2,e]:[2,!1]}}))}))},e.prototype.ready=function(){return u(this,void 0,void 0,(function(){return h(this,(function(t){return[2,this.iframe.ready()]}))}))},e.prototype.loginWithCredential=function(e){return u(this,void 0,void 0,(function(){var n;return h(this,(function(r){switch(r.label){case 0:return[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_logInSignUp,params:e})];case 1:return n=r.sent(),[4,this.iframe.waitForResponse(n)];case 2:return[2,r.sent()]}}))}))},e.prototype.directSocialLogin=function(e){return u(this,void 0,void 0,(function(){var n;return h(this,(function(r){switch(r.label){case 0:return[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_directSocialLogin,params:[e]})];case 1:return n=r.sent(),[4,this.iframe.waitForResponse(n)];case 2:return[2,r.sent()]}}))}))},e.prototype.getIdToken=function(e,n){return u(this,void 0,void 0,(function(){var r;return h(this,(function(i){switch(i.label){case 0:return[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_getIdToken,params:[e,n]})];case 1:return r=i.sent(),[4,this.iframe.waitForResponse(r)];case 2:return[2,i.sent()]}}))}))},e.prototype.loginWithIdToken=function(e){return u(this,void 0,void 0,(function(){var n;return h(this,(function(r){switch(r.label){case 0:return[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_loginWithIdToken,params:[e]})];case 1:return n=r.sent(),[4,this.iframe.waitForResponse(n)];case 2:return[2,r.sent()]}}))}))},e.prototype.loginWithAccessToken=function(e){return u(this,void 0,void 0,(function(){var n;return h(this,(function(r){switch(r.label){case 0:return[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_loginWithAccessToken,params:[e]})];case 1:return n=r.sent(),[4,this.iframe.waitForResponse(n)];case 2:return[2,r.sent()]}}))}))},e.prototype.openWalletConnect=function(e,n){return u(this,void 0,void 0,(function(){var r;return h(this,(function(i){switch(i.label){case 0:return this.iframe.throwExceptionUnsupportedBlockchain([t.Blockchain.APTOS,t.Blockchain.NEAR,t.Blockchain.SOLANA,t.Blockchain.PSM]),[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_openWalletConnect,params:[e,n]})];case 1:return r=i.sent(),[4,this.iframe.waitForResponse(r)];case 2:return[2,i.sent()]}}))}))},e.prototype.openHome=function(e){return u(this,void 0,void 0,(function(){var n,r,i;return h(this,(function(o){switch(o.label){case 0:if(this.iframe.throwExceptionUnsupportedBlockchain([t.Blockchain.APTOS,t.Blockchain.SOLANA,t.Blockchain.NEAR]),n=b(this.network),(null==e?void 0:e.networks)&&e.networks.some((function(t){return b(t)!==n})))throw r="You initialized the Face SDK with ".concat(n?"Mainnet":"Testnet",". Please open the wallet home in the same environment as the initialized network."),new Error(r);return[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_openHome,params:[e]})];case 1:return i=o.sent(),[2,this.iframe.waitForResponse(i)]}}))}))},e.prototype.sendRpc=function(t){return u(this,void 0,void 0,(function(){var e;return h(this,(function(n){switch(n.label){case 0:return[4,this.iframe.sendChildMessage(t)];case 1:return e=n.sent(),[4,this.iframe.waitForResponse(e)];case 2:return[2,n.sent()]}}))}))},e.prototype.decodeData=function(t,e){return u(this,void 0,void 0,(function(){var n,i,o,s;return h(this,(function(a){return n=new r.ethers.utils.Interface(e),i=n.parseTransaction({data:t}),o=i.name,s=i.args,[2,{name:o,args:s}]}))}))},e.prototype.encodeData=function(t,e,n){return u(this,void 0,void 0,(function(){return h(this,(function(i){return[2,new r.ethers.utils.Interface(t).encodeFunctionData(e,n)]}))}))},e.prototype.switchNetwork=function(e){return u(this,void 0,void 0,(function(){var n,r,i;return h(this,(function(o){switch(o.label){case 0:return n=N(e),r={method:t.JsonRpcMethod.face_switchNetwork,params:[{blockchain:n}]},[4,this.sendRpc(r)];case 1:return i=o.sent(),this.face.setNetwork(e),this.iframe.setBlockchain(n),[2,i]}}))}))},e.prototype.boraIsConnected=function(e){return u(this,void 0,void 0,(function(){var n;return h(this,(function(r){switch(r.label){case 0:return this.iframe.throwExceptionUnsupportedBlockchain([t.Blockchain.APTOS,t.Blockchain.NEAR,t.Blockchain.KLAYTN,t.Blockchain.BNB_SMART_CHAIN,t.Blockchain.ETHEREUM,t.Blockchain.MEVERSE,t.Blockchain.SOLANA,t.Blockchain.POLYGON,t.Blockchain.PSM]),[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.bora_isConnected,params:[e]})];case 1:return n=r.sent(),[4,this.iframe.waitForResponse(n)];case 2:return[2,r.sent()]}}))}))},e.prototype.boraConnect=function(e){return u(this,void 0,void 0,(function(){var n;return h(this,(function(r){switch(r.label){case 0:return this.iframe.throwExceptionUnsupportedBlockchain([t.Blockchain.APTOS,t.Blockchain.NEAR,t.Blockchain.KLAYTN,t.Blockchain.BNB_SMART_CHAIN,t.Blockchain.ETHEREUM,t.Blockchain.MEVERSE,t.Blockchain.SOLANA,t.Blockchain.POLYGON,t.Blockchain.PSM]),[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.bora_connect,params:[e]})];case 1:return n=r.sent(),[4,this.iframe.waitForResponse(n)];case 2:return[2,r.sent()]}}))}))},e}(),T=function(e){function n(t){var n=e.call(this)||this;return n.internal=t,n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}c(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}(n,e),n.prototype.request=function(e){return u(this,void 0,void 0,(function(){var n,r=this;return h(this,(function(i){if(Array.isArray(e))return[2,Promise.all(e.map((function(t){return r.internal.sendRpc(t)})))];switch(e.method){case t.JsonRpcMethod.wallet_switchEthereumChain:return n=t.NetworkChainIdMap[e.params[0].chainId],[2,this.internal.switchNetwork(n)];case t.JsonRpcMethod.eth_estimateGas:return[2,this.internal.estimateGas(e)];case"personal_listAccounts":case"eth_accounts":return[2,this.internal.getAddresses()];default:return[2,this.internal.sendRpc(e)]}return[2]}))}))},n}((function(){this.sendAsync=function(t,e){}})),R=function(){function e(t){this.internal=t}return e.prototype.close=function(){this.internal.iframe.hideOverlay()},e.prototype.home=function(e){var n;return u(this,void 0,void 0,(function(){return h(this,(function(r){return t.assertArgument(null==e?void 0:e.networks,null===(n=null==e?void 0:e.networks)||void 0===n?void 0:n.length,"options.networks",!1),[2,this.internal.openHome(e)]}))}))},e}(),_=function(){function e(t){this.internal=t}return e.prototype.connectOpensea=function(e){return u(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:return t.assertArgument(e,"string"==typeof e,"collectionName",!1),[4,this.connect("OpenSea",e?"https://opensea.io/collection/"+e:"https://opensea.io")];case 1:return n.sent(),[2]}}))}))},e.prototype.connect=function(e,n){return u(this,void 0,void 0,(function(){return h(this,(function(r){switch(r.label){case 0:return t.assertArgument(e,"string"==typeof e,"name"),t.assertArgument(n,"string"==typeof n,"url"),[4,this.internal.openWalletConnect(e,n)];case 1:return r.sent(),[2]}}))}))},e}(),B=function(){function e(e){var n=this,r=e.apiKey,i=e.network,o=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}(e,["apiKey","network"]);this.getAddresses=function(e){return u(n,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:return t.assertArgument(e,e&&t.Blockchain[e],"blockchain",!1),[4,this.internal.getAddresses(e)];case 1:return[2,n.sent()]}}))}))},this.setNetwork=function(e){t.assertArgument(e,t.isSupportedNetwork(e),"network"),n.network=e},this.getNetwork=function(){return n.network},this.getChainId=function(){return u(n,void 0,void 0,(function(){var t;return h(this,(function(e){switch(e.label){case 0:return t=Number,[4,this.internal.sendRpc({method:"eth_chainId",params:[]})];case 1:return[2,t.apply(void 0,[e.sent()])]}}))}))},t.assertArgument(r,"string"==typeof r,"apiKey"),t.assertArgument(i,!0,"network");var s="number"==typeof i?t.NetworkChainIdMap[i]:i;t.assert(t.isSupportedNetwork(s),t.unsupportedChainError),this.network=s,this.internal=new E({apiKey:r,network:s,env:null==o?void 0:o.env,iframeUrl:null==o?void 0:o.iframeUrl,face:this}),this.auth=new l(this.internal),this.wc=new _(this.internal),this.solana=new g(this.internal),this.near=new w(this.internal),this.wallet=new R(this.internal),this.bora=new p(this.internal),this.aptos=new f(this.internal)}return e.prototype.ready=function(){return u(this,void 0,void 0,(function(){return h(this,(function(t){return[2,this.internal.ready()]}))}))},e.prototype.getEthLikeProvider=function(){return t.assert(t.isEthlikeBlockchain(t.networkToBlockchain(this.network)),t.unsupportedChainError),new T(this.internal)},e.prototype.switchNetwork=function(e){return u(this,void 0,void 0,(function(){var n;return h(this,(function(r){return n="number"==typeof e?t.NetworkChainIdMap[e]:e,t.assertArgument(e,t.isSupportedNetwork(n),"network"),[2,this.internal.switchNetwork(n)]}))}))},e}();Object.defineProperty(exports,"Network",{enumerable:!0,get:function(){return t.Network}}),exports.Face=B;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@haechi-labs/face-types"),e=require("@noble/hashes/sha3"),n=require("aptos"),r=require("ethers"),i=require("near-api-js"),o=require("@solana/web3.js");function s(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}})),e.default=t,Object.freeze(e)}var a=s(i),c=function(t,e){return c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},c(t,e)};function u(t,e,n,r){return new(n||(n=Promise))((function(i,o){function s(t){try{c(r.next(t))}catch(t){o(t)}}function a(t){try{c(r.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))}function h(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}var l=function(){function e(t){this.internal=t}return e.prototype.login=function(e){return u(this,void 0,void 0,(function(){return h(this,(function(n){return t.assertArgument(e,Array.isArray(e)&&e.length>0&&function(t,e,n){if(n||2===arguments.length)for(var r,i=0,o=e.length;i<o;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))}([],e,!0).every((function(e){return Object.values(t.LoginProvider).includes(e)})),"providers",!1),[2,this.internal.loginWithCredential(e)]}))}))},e.prototype.directSocialLogin=function(e){return u(this,void 0,void 0,(function(){return h(this,(function(n){return t.assertArgument(e,"string"==typeof e,"provider"),[2,this.internal.directSocialLogin(e)]}))}))},e.prototype.getIdToken=function(e,n){return u(this,void 0,void 0,(function(){return h(this,(function(r){return t.assertArgument(e,"string"==typeof e,"provider"),t.assertArgument(n,"string"==typeof n,"accessToken"),[2,this.internal.getIdToken(e,n)]}))}))},e.prototype.loginWithIdToken=function(e){return u(this,void 0,void 0,(function(){return h(this,(function(n){return t.assertArgument(e,e.idToken&&e.sig,"loginWithIdTokenRequest"),[2,this.internal.loginWithIdToken(e)]}))}))},e.prototype.loginWithAccessToken=function(e){return u(this,void 0,void 0,(function(){return h(this,(function(n){return t.assertArgument(e,e.accessToken&&e.sig,"loginWithIdTokenRequest"),[2,this.internal.loginWithAccessToken(e)]}))}))},e.prototype.logout=function(){return u(this,void 0,void 0,(function(){return h(this,(function(t){switch(t.label){case 0:return[4,this.internal.logout()];case 1:return t.sent(),[2]}}))}))},e.prototype.getCurrentUser=function(){return u(this,void 0,void 0,(function(){return h(this,(function(t){switch(t.label){case 0:return[4,this.internal.getCurrentUser()];case 1:return[2,t.sent()]}}))}))},e.prototype.isLoggedIn=function(){return u(this,void 0,void 0,(function(){return h(this,(function(t){switch(t.label){case 0:return[4,this.internal.isLoggedIn()];case 1:return[2,t.sent()]}}))}))},e}(),d=function(){function r(t){this.internal=t}return r.prototype.getPublicKeys=function(){return u(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this.internal.getAddresses(t.Blockchain.APTOS)];case 1:return[2,e.sent().map((function(t){return n.HexString.ensure(t)}))]}}))}))},r.prototype.getAddresses=function(){return u(this,void 0,void 0,(function(){return h(this,(function(r){switch(r.label){case 0:return[4,this.internal.getAddresses(t.Blockchain.APTOS)];case 1:return[2,r.sent().map((function(t){var r=Uint8Array.from(t.substring(2).match(/.{1,2}/g).map((function(t){return parseInt(t,16)}))),i=new Uint8Array(r.length+1);i.set(r),i.set([0],r.length);var o=e.sha3_256.create();return o.update(i),n.HexString.fromUint8Array(o.digest())}))]}}))}))},r.prototype.signMultiAgentTransaction=function(e){return u(this,void 0,void 0,(function(){return h(this,(function(r){switch(r.label){case 0:return[4,this.internal.sendRpc({method:t.JsonRpcMethod.aptos_signMultiAgentTransaction,params:[e.raw_txn.sender.address,n.BCS.bcsToBytes(e)]})];case 1:return[2,r.sent()]}}))}))},r.prototype.signMessage=function(e){return u(this,void 0,void 0,(function(){var n,r;return h(this,(function(i){switch(i.label){case 0:return n=Buffer.from(JSON.stringify(e)),[4,this.internal.sendRpc({method:t.JsonRpcMethod.aptos_signMessage,params:[n]})];case 1:return r=i.sent(),[2,JSON.parse(r)]}}))}))},r.prototype.signAndSubmitTransaction=function(e,n){return u(this,void 0,void 0,(function(){var r;return h(this,(function(i){switch(i.label){case 0:return[4,this.internal.getAddresses(t.Blockchain.APTOS)];case 1:return r=i.sent()[0],[4,this.internal.sendRpc({method:t.JsonRpcMethod.aptos_signAndSubmitTransaction,params:[Buffer.from(r),Buffer.from(JSON.stringify(e)),n]})];case 2:return[2,{hash:i.sent()}]}}))}))},r.prototype.signTransaction=function(e,n){return u(this,void 0,void 0,(function(){var r,i;return h(this,(function(o){switch(o.label){case 0:return[4,this.internal.getAddresses(t.Blockchain.APTOS)];case 1:return r=o.sent()[0],[4,this.internal.sendRpc({method:t.JsonRpcMethod.aptos_signTransaction,params:[Buffer.from(r),Buffer.from(JSON.stringify(e)),n]})];case 2:return i=o.sent(),[2,JSON.parse(i)]}}))}))},r}(),f=function(){function t(t){this.internal=t}return t.prototype.getProvider=function(){return new d(this.internal)},t}(),p=function(){function e(t){this.internal=t}return e.prototype.connect=function(e){return u(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:return t.assertArgument(e,e.bappUsn&&e.signature,"request"),[4,this.internal.boraConnect(e)];case 1:return[2,n.sent()]}}))}))},e.prototype.isConnected=function(e){return u(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:return t.assertArgument(e,"string"==typeof e,"bappUsn"),[4,this.internal.boraIsConnected(e)];case 1:return[2,n.sent()]}}))}))},e}(),v=function(){function e(t){this.internal=t}return e.prototype.getPublicKeys=function(){return u(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this.internal.getAddresses(t.Blockchain.NEAR)];case 1:return[2,e.sent().map((function(t){return a.utils.PublicKey.fromString(a.utils.serialize.base_encode(Buffer.from(t,"hex")))}))]}}))}))},e.prototype.getBalance=function(e,n){return u(this,void 0,void 0,(function(){var i;return h(this,(function(o){switch(o.label){case 0:return t.assertArgument(e,"string"==typeof e,"address"),t.assertArgument(n,"string"==typeof n,"contractAddress",!1),[4,this.internal.sendRpc({method:t.JsonRpcMethod.near_get_balance,params:[e,n]})];case 1:return i=o.sent(),[2,r.BigNumber.from(i)]}}))}))},e.prototype.signAndSendTransaction=function(t){return u(this,void 0,void 0,(function(){var e;return h(this,(function(n){switch(n.label){case 0:return e={serializedHex:Buffer.from(a.utils.serialize.serialize(a.transactions.SCHEMA,t)).toString("hex")},[4,this.internal.sendRpc({method:"near_broadcast_tx_async",params:[e]})];case 1:return[2,n.sent()]}}))}))},e}(),w=function(){function t(t){this.internal=t}return t.prototype.getProvider=function(){return new v(this.internal)},t}(),m=function(){function e(t){this.internal=t}return e.prototype.getPublicKeys=function(){return u(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this.internal.getAddresses(t.Blockchain.SOLANA)];case 1:return[2,e.sent().map((function(t){return new o.PublicKey(r.ethers.utils.base58.decode(t))}))]}}))}))},e.prototype.signAndSendTransaction=function(t){return u(this,void 0,void 0,(function(){var e;return h(this,(function(n){switch(n.label){case 0:return e={serializedHex:t.serialize({requireAllSignatures:!1,verifySignatures:!1}).toString("hex")},[4,this.internal.sendRpc({method:"solana_sendTransaction",params:[e]})];case 1:return[2,n.sent()]}}))}))},e}(),g=function(){function t(t){this.internal=t}return t.prototype.getProvider=function(){return new m(this.internal)},t}(),y={display:"none",position:"fixed",top:"0",right:"0",width:"100%",height:"100%",borderRadius:"0",border:"none",zIndex:"2147483647"};var k=function(){var t=this;this._isCompleted=!1,this._eventListeners=Array(),this.complete=function(){t._isCompleted=!0,t._eventListeners.forEach((function(t){return t()}))},this.add=function(e){t._eventListeners.push(e)},this.isCompleted=function(){return t._isCompleted}},A=function(){function e(t,e,n,r){var i,o=this;this._ready=new k,this.requestIndex=0,this.activeElement=null,this._blockchain=e,this._env=n,this.iframeUrl=r;var s=Math.random().toString();if(this.randomPrefix=s.substring(s.length-6),document.getElementById("face-iframe"))throw new Error("Face is already initialized, Face can be initialized once.");window.addEventListener("message",(function(t){return u(o,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return t.origin!==r?[2]:[4,this.processMessage(t.data)];case 1:return e.sent(),[2]}}))}))}));var a=null!==(i="1.10.5-alpha.0")?i:"";this._iframe=new Promise((function(i){var o=function(){if(!document.getElementById("face-iframe")){var o=document.createElement("iframe");o.id="face-iframe",o.title="Secure Modal",o.src=new URL("".concat(r,"?api_key=").concat(t,"&blockchain=").concat(e,"&env=").concat(n,"&version=").concat(a,"&type=").concat("web")).href,o.allow="clipboard-read; clipboard-write",function(t){for(var e=0,n=Object.entries(y);e<n.length;e++){var r=n[e],i=r[0],o=r[1];t.style[i]=o}}(o),document.body.appendChild(o),i(o)}};["loaded","interactive","complete"].includes(document.readyState)?o():window.addEventListener("load",o,!1)}))}return e.prototype.sendChildMessage=function(e){var n,r;return u(this,void 0,void 0,(function(){var i;return h(this,(function(o){switch(o.label){case 0:return[4,this.ready()];case 1:return o.sent(),this.requestIndex+=1,i=e.id?"".concat(e.id):"".concat(this.randomPrefix,"-").concat(this.requestIndex),e.id=i,e.from=t.JsonRpcSource.FACE_SDK,[4,this._iframe];case 2:return null===(r=null===(n=o.sent())||void 0===n?void 0:n.contentWindow)||void 0===r||r.postMessage(e,"*"),[2,i]}}))}))},e.prototype.waitForResponse=function(t){return new Promise((function(e,n){var r=function(i){var o=i.data;t&&o.id!==t||(window.removeEventListener("message",r),o.error?n(o.error):e(o.result))};window.addEventListener("message",r)}))},e.prototype.processMessage=function(e){return u(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:switch(e.method){case t.JsonRpcMethod.face_ready:return[3,1];case t.JsonRpcMethod.face_openIframe:return[3,2];case t.JsonRpcMethod.face_closeIframe:return[3,4]}return[3,6];case 1:return this._ready.complete(),[3,6];case 2:return[4,this.showOverlay()];case 3:case 5:return n.sent(),[3,6];case 4:return[4,this.hideOverlay()];case 6:return[2]}}))}))},e.prototype.ready=function(){return u(this,void 0,void 0,(function(){var t=this;return h(this,(function(e){return[2,new Promise((function(e){return u(t,void 0,void 0,(function(){return h(this,(function(t){return this._ready.isCompleted()?(e(),[2]):(this._ready.add((function(){e()})),[2])}))}))}))]}))}))},e.prototype.showOverlay=function(){return u(this,void 0,void 0,(function(){var t;return h(this,(function(e){switch(e.label){case 0:return[4,this.ready()];case 1:return e.sent(),[4,this._iframe];case 2:return(t=e.sent()).style.display="block",this.activeElement=document.activeElement,t.focus(),[2]}}))}))},e.prototype.hideOverlay=function(){var t;return u(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this.ready()];case 1:return e.sent(),[4,this._iframe];case 2:return e.sent().style.display="none",(null===(t=this.activeElement)||void 0===t?void 0:t.focus)&&this.activeElement.focus(),this.activeElement=null,[2]}}))}))},e.prototype.setBlockchain=function(t){this._blockchain=t},e.prototype.throwExceptionUnsupportedBlockchain=function(e){if(e.includes(this._blockchain))throw t.unsupportedChainError()},e.prototype.getBlockchain=function(){return this._blockchain},e}();function b(e){switch(e){case t.Network.ETHEREUM:case t.Network.POLYGON:case t.Network.BNB_SMART_CHAIN:case t.Network.KLAYTN:case t.Network.SOLANA:case t.Network.BORA:case t.Network.NEAR:case t.Network.APTOS:case t.Network.MEVERSE:case t.Network.PSM:return!0;default:return!1}}function N(e){switch(e){case t.Network.ETHEREUM:case t.Network.GOERLI:return t.Blockchain.ETHEREUM;case t.Network.POLYGON:case t.Network.MUMBAI:return t.Blockchain.POLYGON;case t.Network.BNB_SMART_CHAIN:case t.Network.BNB_SMART_CHAIN_TESTNET:return t.Blockchain.BNB_SMART_CHAIN;case t.Network.KLAYTN:case t.Network.BAOBAB:return t.Blockchain.KLAYTN;case t.Network.SOLANA:case t.Network.SOLANA_DEVNET:return t.Blockchain.SOLANA;case t.Network.BORA:case t.Network.BORA_TESTNET:return t.Blockchain.BORA;case t.Network.NEAR:case t.Network.NEAR_TESTNET:return t.Blockchain.NEAR;case t.Network.APTOS:case t.Network.APTOS_TESTNET:return t.Blockchain.APTOS;case t.Network.MEVERSE:case t.Network.MEVERSE_TESTNET:return t.Blockchain.MEVERSE;case t.Network.PSM:case t.Network.PSM_TESTNET:return t.Blockchain.PSM;default:return t.Blockchain.ETHEREUM}}r.BigNumber.from(1e5).toHexString();var E=function(){function e(e){var n=e.apiKey,r=e.network,i=e.env,o=e.iframeUrl,s=e.face;this.network=r||t.Network.ETHEREUM;var a=N(this.network);this.env=null!=i?i:function(e){return!e||e!==t.Network.GOERLI&&e!==t.Network.MUMBAI&&e!==t.Network.BAOBAB&&e!==t.Network.BNB_SMART_CHAIN_TESTNET&&e!==t.Network.BORA_TESTNET&&e!==t.Network.SOLANA_DEVNET&&e!==t.Network.NEAR_TESTNET&&e!==t.Network.APTOS_TESTNET&&e!==t.Network.MEVERSE_TESTNET&&e!==t.Network.PSM_TESTNET?t.Env.ProdMainnet:t.Env.ProdTest}(r),this.iframe=new A(n,a,this.env,function(e,n){if(null!=n)return n;switch(e){case t.Env.Local:return"http://localhost:3333";case t.Env.Dev:return"https://app.dev.facewallet.xyz";case t.Env.StageTest:return"https://app.stage-test.facewallet.xyz";case t.Env.ProdTest:return"https://app.test.facewallet.xyz";case t.Env.StageMainnet:return"https://app.stage.facewallet.xyz";case t.Env.ProdMainnet:default:return"https://app.facewallet.xyz"}}(this.env,o)),this.face=s,this.iframeUrl=o}return e.prototype.getAddresses=function(e){return u(this,void 0,void 0,(function(){var n,r;return h(this,(function(i){switch(i.label){case 0:return[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_accounts,params:[e]})];case 1:return n=i.sent(),[4,this.iframe.waitForResponse(n)];case 2:return(r=i.sent())?[2,r]:[2,Promise.reject(new Error("get address failed"))]}}))}))},e.prototype.estimateGas=function(t){return u(this,void 0,void 0,(function(){return h(this,(function(t){return[2,0]}))}))},e.prototype.getBalance=function(e,n){return u(this,void 0,void 0,(function(){var i,o,s,a;return h(this,(function(c){switch(c.label){case 0:return n?[4,this.encodeData(["function balanceOf(address owner) view returns (uint256)"],"balanceOf",[e])]:[3,3];case 1:return i=c.sent(),[4,this.sendRpc({method:t.JsonRpcMethod.eth_call,params:[{to:n,data:i},"latest"]})];case 2:return o=c.sent(),[2,r.BigNumber.from(o)];case 3:return a=(s=r.BigNumber).from,[4,this.sendRpc({method:t.JsonRpcMethod.eth_getBalance,params:[e,"latest"]})];case 4:return[2,a.apply(s,[c.sent()])]}}))}))},e.prototype.ownerOf=function(e,n){return u(this,void 0,void 0,(function(){var r;return h(this,(function(i){switch(i.label){case 0:return[4,this.encodeData(["function ownerOf(uint256 tokenId) view returns (address)"],"ownerOf",[n])];case 1:return r=i.sent(),[4,this.sendRpc({method:t.JsonRpcMethod.eth_call,params:[{to:e,data:r},"latest"]})];case 2:return[2,("0x"+i.sent().substring(26)).toLowerCase()]}}))}))},e.prototype.logout=function(){return u(this,void 0,void 0,(function(){var e;return h(this,(function(n){switch(n.label){case 0:return[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_logOut})];case 1:return e=n.sent(),[4,this.iframe.waitForResponse(e)];case 2:return n.sent(),[2]}}))}))},e.prototype.getCurrentUser=function(){return u(this,void 0,void 0,(function(){var e;return h(this,(function(n){switch(n.label){case 0:return[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_currentUser})];case 1:return e=n.sent(),[4,this.iframe.waitForResponse(e)];case 2:return[2,n.sent()]}}))}))},e.prototype.isLoggedIn=function(){return u(this,void 0,void 0,(function(){var e;return h(this,(function(n){switch(n.label){case 0:return[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_loggedIn})];case 1:return n.sent(),[4,this.iframe.waitForResponse()];case 2:return(e=n.sent())?[2,e]:[2,!1]}}))}))},e.prototype.ready=function(){return u(this,void 0,void 0,(function(){return h(this,(function(t){return[2,this.iframe.ready()]}))}))},e.prototype.loginWithCredential=function(e){return u(this,void 0,void 0,(function(){var n;return h(this,(function(r){switch(r.label){case 0:return[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_logInSignUp,params:e})];case 1:return n=r.sent(),[4,this.iframe.waitForResponse(n)];case 2:return[2,r.sent()]}}))}))},e.prototype.directSocialLogin=function(e){return u(this,void 0,void 0,(function(){var n;return h(this,(function(r){switch(r.label){case 0:return[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_directSocialLogin,params:[e]})];case 1:return n=r.sent(),[4,this.iframe.waitForResponse(n)];case 2:return[2,r.sent()]}}))}))},e.prototype.getIdToken=function(e,n){return u(this,void 0,void 0,(function(){var r;return h(this,(function(i){switch(i.label){case 0:return[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_getIdToken,params:[e,n]})];case 1:return r=i.sent(),[4,this.iframe.waitForResponse(r)];case 2:return[2,i.sent()]}}))}))},e.prototype.loginWithIdToken=function(e){return u(this,void 0,void 0,(function(){var n;return h(this,(function(r){switch(r.label){case 0:return[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_loginWithIdToken,params:[e]})];case 1:return n=r.sent(),[4,this.iframe.waitForResponse(n)];case 2:return[2,r.sent()]}}))}))},e.prototype.loginWithAccessToken=function(e){return u(this,void 0,void 0,(function(){var n;return h(this,(function(r){switch(r.label){case 0:return[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_loginWithAccessToken,params:[e]})];case 1:return n=r.sent(),[4,this.iframe.waitForResponse(n)];case 2:return[2,r.sent()]}}))}))},e.prototype.openWalletConnect=function(e,n){return u(this,void 0,void 0,(function(){var r;return h(this,(function(i){switch(i.label){case 0:return this.iframe.throwExceptionUnsupportedBlockchain([t.Blockchain.APTOS,t.Blockchain.NEAR,t.Blockchain.SOLANA,t.Blockchain.PSM]),[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_openWalletConnect,params:[e,n]})];case 1:return r=i.sent(),[4,this.iframe.waitForResponse(r)];case 2:return[2,i.sent()]}}))}))},e.prototype.openHome=function(e){return u(this,void 0,void 0,(function(){var n,r,i;return h(this,(function(o){switch(o.label){case 0:if(this.iframe.throwExceptionUnsupportedBlockchain([t.Blockchain.APTOS,t.Blockchain.SOLANA,t.Blockchain.NEAR]),n=b(this.network),(null==e?void 0:e.networks)&&e.networks.some((function(t){return b(t)!==n})))throw r="You initialized the Face SDK with ".concat(n?"Mainnet":"Testnet",". Please open the wallet home in the same environment as the initialized network."),new Error(r);return[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_openHome,params:[e]})];case 1:return i=o.sent(),[2,this.iframe.waitForResponse(i)]}}))}))},e.prototype.sendRpc=function(t){return u(this,void 0,void 0,(function(){var e;return h(this,(function(n){switch(n.label){case 0:return[4,this.iframe.sendChildMessage(t)];case 1:return e=n.sent(),[4,this.iframe.waitForResponse(e)];case 2:return[2,n.sent()]}}))}))},e.prototype.decodeData=function(t,e){return u(this,void 0,void 0,(function(){var n,i,o,s;return h(this,(function(a){return n=new r.ethers.utils.Interface(e),i=n.parseTransaction({data:t}),o=i.name,s=i.args,[2,{name:o,args:s}]}))}))},e.prototype.encodeData=function(t,e,n){return u(this,void 0,void 0,(function(){return h(this,(function(i){return[2,new r.ethers.utils.Interface(t).encodeFunctionData(e,n)]}))}))},e.prototype.switchNetwork=function(e){return u(this,void 0,void 0,(function(){var n,r,i;return h(this,(function(o){switch(o.label){case 0:return n=N(e),r={method:t.JsonRpcMethod.face_switchNetwork,params:[{blockchain:n}]},[4,this.sendRpc(r)];case 1:return i=o.sent(),this.face.setNetwork(e),this.iframe.setBlockchain(n),[2,i]}}))}))},e.prototype.boraIsConnected=function(e){return u(this,void 0,void 0,(function(){var n;return h(this,(function(r){switch(r.label){case 0:return this.iframe.throwExceptionUnsupportedBlockchain([t.Blockchain.APTOS,t.Blockchain.NEAR,t.Blockchain.KLAYTN,t.Blockchain.BNB_SMART_CHAIN,t.Blockchain.ETHEREUM,t.Blockchain.MEVERSE,t.Blockchain.SOLANA,t.Blockchain.POLYGON,t.Blockchain.PSM]),[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.bora_isConnected,params:[e]})];case 1:return n=r.sent(),[4,this.iframe.waitForResponse(n)];case 2:return[2,r.sent()]}}))}))},e.prototype.boraConnect=function(e){return u(this,void 0,void 0,(function(){var n;return h(this,(function(r){switch(r.label){case 0:return this.iframe.throwExceptionUnsupportedBlockchain([t.Blockchain.APTOS,t.Blockchain.NEAR,t.Blockchain.KLAYTN,t.Blockchain.BNB_SMART_CHAIN,t.Blockchain.ETHEREUM,t.Blockchain.MEVERSE,t.Blockchain.SOLANA,t.Blockchain.POLYGON,t.Blockchain.PSM]),[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.bora_connect,params:[e]})];case 1:return n=r.sent(),[4,this.iframe.waitForResponse(n)];case 2:return[2,r.sent()]}}))}))},e}(),T=function(e){function n(t){var n=e.call(this)||this;return n.internal=t,n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}c(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}(n,e),n.prototype.request=function(e){return u(this,void 0,void 0,(function(){var n,r=this;return h(this,(function(i){if(Array.isArray(e))return[2,Promise.all(e.map((function(t){return r.internal.sendRpc(t)})))];switch(e.method){case t.JsonRpcMethod.wallet_switchEthereumChain:return n=t.NetworkChainIdMap[e.params[0].chainId],[2,this.internal.switchNetwork(n)];case t.JsonRpcMethod.eth_estimateGas:return[2,this.internal.estimateGas(e)];case"personal_listAccounts":case"eth_accounts":return[2,this.internal.getAddresses()];default:return[2,this.internal.sendRpc(e)]}return[2]}))}))},n}((function(){this.sendAsync=function(t,e){}})),R=function(){function e(t){this.internal=t}return e.prototype.close=function(){this.internal.iframe.hideOverlay()},e.prototype.home=function(e){var n;return u(this,void 0,void 0,(function(){return h(this,(function(r){return t.assertArgument(null==e?void 0:e.networks,null===(n=null==e?void 0:e.networks)||void 0===n?void 0:n.length,"options.networks",!1),[2,this.internal.openHome(e)]}))}))},e}(),_=function(){function e(t){this.internal=t}return e.prototype.connectOpensea=function(e){return u(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:return t.assertArgument(e,"string"==typeof e,"collectionName",!1),[4,this.connect("OpenSea",e?"https://opensea.io/collection/"+e:"https://opensea.io")];case 1:return n.sent(),[2]}}))}))},e.prototype.connect=function(e,n){return u(this,void 0,void 0,(function(){return h(this,(function(r){switch(r.label){case 0:return t.assertArgument(e,"string"==typeof e,"name"),t.assertArgument(n,"string"==typeof n,"url"),[4,this.internal.openWalletConnect(e,n)];case 1:return r.sent(),[2]}}))}))},e}(),B=function(){function e(e){var n=this,r=e.apiKey,i=e.network,o=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}(e,["apiKey","network"]);this.getAddresses=function(e){return u(n,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:return t.assertArgument(e,e&&t.Blockchain[e],"blockchain",!1),[4,this.internal.getAddresses(e)];case 1:return[2,n.sent()]}}))}))},this.setNetwork=function(e){t.assertArgument(e,t.isSupportedNetwork(e),"network"),n.network=e},this.getNetwork=function(){return n.network},this.getChainId=function(){return u(n,void 0,void 0,(function(){var t;return h(this,(function(e){switch(e.label){case 0:return t=Number,[4,this.internal.sendRpc({method:"eth_chainId",params:[]})];case 1:return[2,t.apply(void 0,[e.sent()])]}}))}))},t.assertArgument(r,"string"==typeof r,"apiKey"),t.assertArgument(i,!0,"network");var s="number"==typeof i?t.NetworkChainIdMap[i]:i;t.assert(t.isSupportedNetwork(s),t.unsupportedChainError),this.network=s,this.internal=new E({apiKey:r,network:s,env:null==o?void 0:o.env,iframeUrl:null==o?void 0:o.iframeUrl,face:this}),this.auth=new l(this.internal),this.wc=new _(this.internal),this.solana=new g(this.internal),this.near=new w(this.internal),this.wallet=new R(this.internal),this.bora=new p(this.internal),this.aptos=new f(this.internal)}return e.prototype.ready=function(){return u(this,void 0,void 0,(function(){return h(this,(function(t){return[2,this.internal.ready()]}))}))},e.prototype.getEthLikeProvider=function(){return t.assert(t.isEthlikeBlockchain(t.networkToBlockchain(this.network)),t.unsupportedChainError),new T(this.internal)},e.prototype.switchNetwork=function(e){return u(this,void 0,void 0,(function(){var n;return h(this,(function(r){return n="number"==typeof e?t.NetworkChainIdMap[e]:e,t.assertArgument(e,t.isSupportedNetwork(n),"network"),[2,this.internal.switchNetwork(n)]}))}))},e}();Object.defineProperty(exports,"Network",{enumerable:!0,get:function(){return t.Network}}),exports.Face=B;
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@haechi-labs/face-types"),e=require("@noble/hashes/sha3"),n=require("aptos"),r=require("ethers"),i=require("near-api-js"),o=require("@solana/web3.js");function s(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}})),e.default=t,Object.freeze(e)}var a=s(i),c=function(t,e){return c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},c(t,e)};function u(t,e,n,r){return new(n||(n=Promise))((function(i,o){function s(t){try{c(r.next(t))}catch(t){o(t)}}function a(t){try{c(r.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))}function h(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}var l=function(){function e(t){this.internal=t}return e.prototype.login=function(e){return u(this,void 0,void 0,(function(){return h(this,(function(n){return t.assertArgument(e,Array.isArray(e)&&e.length>0&&function(t,e,n){if(n||2===arguments.length)for(var r,i=0,o=e.length;i<o;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))}([],e,!0).every((function(e){return Object.values(t.LoginProvider).includes(e)})),"providers",!1),[2,this.internal.loginWithCredential(e)]}))}))},e.prototype.directSocialLogin=function(e){return u(this,void 0,void 0,(function(){return h(this,(function(n){return t.assertArgument(e,"string"==typeof e,"provider"),[2,this.internal.directSocialLogin(e)]}))}))},e.prototype.getIdToken=function(e,n){return u(this,void 0,void 0,(function(){return h(this,(function(r){return t.assertArgument(e,"string"==typeof e,"provider"),t.assertArgument(n,"string"==typeof n,"accessToken"),[2,this.internal.getIdToken(e,n)]}))}))},e.prototype.loginWithIdToken=function(e){return u(this,void 0,void 0,(function(){return h(this,(function(n){return t.assertArgument(e,e.idToken&&e.sig,"loginWithIdTokenRequest"),[2,this.internal.loginWithIdToken(e)]}))}))},e.prototype.loginWithAccessToken=function(e){return u(this,void 0,void 0,(function(){return h(this,(function(n){return t.assertArgument(e,e.accessToken&&e.sig,"loginWithIdTokenRequest"),[2,this.internal.loginWithAccessToken(e)]}))}))},e.prototype.logout=function(){return u(this,void 0,void 0,(function(){return h(this,(function(t){switch(t.label){case 0:return[4,this.internal.logout()];case 1:return t.sent(),[2]}}))}))},e.prototype.getCurrentUser=function(){return u(this,void 0,void 0,(function(){return h(this,(function(t){switch(t.label){case 0:return[4,this.internal.getCurrentUser()];case 1:return[2,t.sent()]}}))}))},e.prototype.isLoggedIn=function(){return u(this,void 0,void 0,(function(){return h(this,(function(t){switch(t.label){case 0:return[4,this.internal.isLoggedIn()];case 1:return[2,t.sent()]}}))}))},e}(),d=function(){function r(t){this.internal=t}return r.prototype.getPublicKeys=function(){return u(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this.internal.getAddresses(t.Blockchain.APTOS)];case 1:return[2,e.sent().map((function(t){return n.HexString.ensure(t)}))]}}))}))},r.prototype.getAddresses=function(){return u(this,void 0,void 0,(function(){return h(this,(function(r){switch(r.label){case 0:return[4,this.internal.getAddresses(t.Blockchain.APTOS)];case 1:return[2,r.sent().map((function(t){var r=Uint8Array.from(t.substring(2).match(/.{1,2}/g).map((function(t){return parseInt(t,16)}))),i=new Uint8Array(r.length+1);i.set(r),i.set([0],r.length);var o=e.sha3_256.create();return o.update(i),n.HexString.fromUint8Array(o.digest())}))]}}))}))},r.prototype.signMultiAgentTransaction=function(e){return u(this,void 0,void 0,(function(){return h(this,(function(r){switch(r.label){case 0:return[4,this.internal.sendRpc({method:t.JsonRpcMethod.aptos_signMultiAgentTransaction,params:[e.raw_txn.sender.address,n.BCS.bcsToBytes(e)]})];case 1:return[2,r.sent()]}}))}))},r.prototype.signMessage=function(e){return u(this,void 0,void 0,(function(){var n,r;return h(this,(function(i){switch(i.label){case 0:return n=Buffer.from(JSON.stringify(e)),[4,this.internal.sendRpc({method:t.JsonRpcMethod.aptos_signMessage,params:[n]})];case 1:return r=i.sent(),[2,JSON.parse(r)]}}))}))},r.prototype.signAndSubmitTransaction=function(e,n){return u(this,void 0,void 0,(function(){var r;return h(this,(function(i){switch(i.label){case 0:return[4,this.internal.getAddresses(t.Blockchain.APTOS)];case 1:return r=i.sent()[0],[4,this.internal.sendRpc({method:t.JsonRpcMethod.aptos_signAndSubmitTransaction,params:[Buffer.from(r),Buffer.from(JSON.stringify(e)),n]})];case 2:return[2,{hash:i.sent()}]}}))}))},r.prototype.signTransaction=function(e,n){return u(this,void 0,void 0,(function(){var r,i;return h(this,(function(o){switch(o.label){case 0:return[4,this.internal.getAddresses(t.Blockchain.APTOS)];case 1:return r=o.sent()[0],[4,this.internal.sendRpc({method:t.JsonRpcMethod.aptos_signTransaction,params:[Buffer.from(r),Buffer.from(JSON.stringify(e)),n]})];case 2:return i=o.sent(),[2,JSON.parse(i)]}}))}))},r}(),f=function(){function t(t){this.internal=t}return t.prototype.getProvider=function(){return new d(this.internal)},t}(),p=function(){function e(t){this.internal=t}return e.prototype.connect=function(e){return u(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:return t.assertArgument(e,e.bappUsn&&e.signature,"request"),[4,this.internal.boraConnect(e)];case 1:return[2,n.sent()]}}))}))},e.prototype.isConnected=function(e){return u(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:return t.assertArgument(e,"string"==typeof e,"bappUsn"),[4,this.internal.boraIsConnected(e)];case 1:return[2,n.sent()]}}))}))},e}(),v=function(){function e(t){this.internal=t}return e.prototype.getPublicKeys=function(){return u(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this.internal.getAddresses(t.Blockchain.NEAR)];case 1:return[2,e.sent().map((function(t){return a.utils.PublicKey.fromString(a.utils.serialize.base_encode(Buffer.from(t,"hex")))}))]}}))}))},e.prototype.getBalance=function(e,n){return u(this,void 0,void 0,(function(){var i;return h(this,(function(o){switch(o.label){case 0:return t.assertArgument(e,"string"==typeof e,"address"),t.assertArgument(n,"string"==typeof n,"contractAddress",!1),[4,this.internal.sendRpc({method:t.JsonRpcMethod.near_get_balance,params:[e,n]})];case 1:return i=o.sent(),[2,r.BigNumber.from(i)]}}))}))},e.prototype.signAndSendTransaction=function(t){return u(this,void 0,void 0,(function(){var e;return h(this,(function(n){switch(n.label){case 0:return e={serializedHex:Buffer.from(a.utils.serialize.serialize(a.transactions.SCHEMA,t)).toString("hex")},[4,this.internal.sendRpc({method:"near_broadcast_tx_async",params:[e]})];case 1:return[2,n.sent()]}}))}))},e}(),w=function(){function t(t){this.internal=t}return t.prototype.getProvider=function(){return new v(this.internal)},t}(),m=function(){function e(t){this.internal=t}return e.prototype.getPublicKeys=function(){return u(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this.internal.getAddresses(t.Blockchain.SOLANA)];case 1:return[2,e.sent().map((function(t){return new o.PublicKey(r.ethers.utils.base58.decode(t))}))]}}))}))},e.prototype.signAndSendTransaction=function(t){return u(this,void 0,void 0,(function(){var e;return h(this,(function(n){switch(n.label){case 0:return e={serializedHex:t.serialize({requireAllSignatures:!1,verifySignatures:!1}).toString("hex")},[4,this.internal.sendRpc({method:"solana_sendTransaction",params:[e]})];case 1:return[2,n.sent()]}}))}))},e}(),g=function(){function t(t){this.internal=t}return t.prototype.getProvider=function(){return new m(this.internal)},t}(),y={display:"none",position:"fixed",top:"0",right:"0",width:"100%",height:"100%",borderRadius:"0",border:"none",zIndex:"2147483647"};var k=function(){var t=this;this._isCompleted=!1,this._eventListeners=Array(),this.complete=function(){t._isCompleted=!0,t._eventListeners.forEach((function(t){return t()}))},this.add=function(e){t._eventListeners.push(e)},this.isCompleted=function(){return t._isCompleted}},A=function(){function e(t,e,n,r){var i,o=this;this._ready=new k,this.requestIndex=0,this.activeElement=null,this._blockchain=e,this._env=n,this.iframeUrl=r;var s=Math.random().toString();if(this.randomPrefix=s.substring(s.length-6),document.getElementById("face-iframe"))throw new Error("Face is already initialized, Face can be initialized once.");window.addEventListener("message",(function(t){return u(o,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return t.origin!==r?[2]:[4,this.processMessage(t.data)];case 1:return e.sent(),[2]}}))}))}));var a=null!==(i="1.10.4")?i:"";this._iframe=new Promise((function(i){var o=function(){if(!document.getElementById("face-iframe")){var o=document.createElement("iframe");o.id="face-iframe",o.title="Secure Modal",o.src=new URL("".concat(r,"?api_key=").concat(t,"&blockchain=").concat(e,"&env=").concat(n,"&version=").concat(a,"&type=").concat("web")).href,o.allow="clipboard-read; clipboard-write",function(t){for(var e=0,n=Object.entries(y);e<n.length;e++){var r=n[e],i=r[0],o=r[1];t.style[i]=o}}(o),document.body.appendChild(o),i(o)}};["loaded","interactive","complete"].includes(document.readyState)?o():window.addEventListener("load",o,!1)}))}return e.prototype.sendChildMessage=function(e){var n,r;return u(this,void 0,void 0,(function(){var i;return h(this,(function(o){switch(o.label){case 0:return[4,this.ready()];case 1:return o.sent(),this.requestIndex+=1,i=e.id?"".concat(e.id):"".concat(this.randomPrefix,"-").concat(this.requestIndex),e.id=i,e.from=t.JsonRpcSource.FACE_SDK,[4,this._iframe];case 2:return null===(r=null===(n=o.sent())||void 0===n?void 0:n.contentWindow)||void 0===r||r.postMessage(e,"*"),[2,i]}}))}))},e.prototype.waitForResponse=function(t){return new Promise((function(e,n){var r=function(i){var o=i.data;t&&o.id!==t||(window.removeEventListener("message",r),o.error?n(o.error):e(o.result))};window.addEventListener("message",r)}))},e.prototype.processMessage=function(e){return u(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:switch(e.method){case t.JsonRpcMethod.face_ready:return[3,1];case t.JsonRpcMethod.face_openIframe:return[3,2];case t.JsonRpcMethod.face_closeIframe:return[3,4]}return[3,6];case 1:return this._ready.complete(),[3,6];case 2:return[4,this.showOverlay()];case 3:case 5:return n.sent(),[3,6];case 4:return[4,this.hideOverlay()];case 6:return[2]}}))}))},e.prototype.ready=function(){return u(this,void 0,void 0,(function(){var t=this;return h(this,(function(e){return[2,new Promise((function(e){return u(t,void 0,void 0,(function(){return h(this,(function(t){return this._ready.isCompleted()?(e(),[2]):(this._ready.add((function(){e()})),[2])}))}))}))]}))}))},e.prototype.showOverlay=function(){return u(this,void 0,void 0,(function(){var t;return h(this,(function(e){switch(e.label){case 0:return[4,this.ready()];case 1:return e.sent(),[4,this._iframe];case 2:return(t=e.sent()).style.display="block",this.activeElement=document.activeElement,t.focus(),[2]}}))}))},e.prototype.hideOverlay=function(){var t;return u(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this.ready()];case 1:return e.sent(),[4,this._iframe];case 2:return e.sent().style.display="none",(null===(t=this.activeElement)||void 0===t?void 0:t.focus)&&this.activeElement.focus(),this.activeElement=null,[2]}}))}))},e.prototype.setBlockchain=function(t){this._blockchain=t},e.prototype.throwExceptionUnsupportedBlockchain=function(e){if(e.includes(this._blockchain))throw t.unsupportedChainError()},e.prototype.getBlockchain=function(){return this._blockchain},e}();function b(e){switch(e){case t.Network.ETHEREUM:case t.Network.POLYGON:case t.Network.BNB_SMART_CHAIN:case t.Network.KLAYTN:case t.Network.SOLANA:case t.Network.BORA:case t.Network.NEAR:case t.Network.APTOS:case t.Network.MEVERSE:case t.Network.PSM:return!0;default:return!1}}function N(e){switch(e){case t.Network.ETHEREUM:case t.Network.GOERLI:return t.Blockchain.ETHEREUM;case t.Network.POLYGON:case t.Network.MUMBAI:return t.Blockchain.POLYGON;case t.Network.BNB_SMART_CHAIN:case t.Network.BNB_SMART_CHAIN_TESTNET:return t.Blockchain.BNB_SMART_CHAIN;case t.Network.KLAYTN:case t.Network.BAOBAB:return t.Blockchain.KLAYTN;case t.Network.SOLANA:case t.Network.SOLANA_DEVNET:return t.Blockchain.SOLANA;case t.Network.BORA:case t.Network.BORA_TESTNET:return t.Blockchain.BORA;case t.Network.NEAR:case t.Network.NEAR_TESTNET:return t.Blockchain.NEAR;case t.Network.APTOS:case t.Network.APTOS_TESTNET:return t.Blockchain.APTOS;case t.Network.MEVERSE:case t.Network.MEVERSE_TESTNET:return t.Blockchain.MEVERSE;case t.Network.PSM:case t.Network.PSM_TESTNET:return t.Blockchain.PSM;default:return t.Blockchain.ETHEREUM}}r.BigNumber.from(1e5).toHexString();var E=function(){function e(e){var n=e.apiKey,r=e.network,i=e.env,o=e.iframeUrl,s=e.face;this.network=r||t.Network.ETHEREUM;var a=N(this.network);this.env=null!=i?i:function(e){return!e||e!==t.Network.GOERLI&&e!==t.Network.MUMBAI&&e!==t.Network.BAOBAB&&e!==t.Network.BNB_SMART_CHAIN_TESTNET&&e!==t.Network.BORA_TESTNET&&e!==t.Network.SOLANA_DEVNET&&e!==t.Network.NEAR_TESTNET&&e!==t.Network.APTOS_TESTNET&&e!==t.Network.MEVERSE_TESTNET&&e!==t.Network.PSM_TESTNET?t.Env.ProdMainnet:t.Env.ProdTest}(r),this.iframe=new A(n,a,this.env,function(e,n){if(null!=n)return n;switch(e){case t.Env.Local:return"http://localhost:3333";case t.Env.Dev:return"https://app.dev.facewallet.xyz";case t.Env.StageTest:return"https://app.stage-test.facewallet.xyz";case t.Env.ProdTest:return"https://app.test.facewallet.xyz";case t.Env.StageMainnet:return"https://app.stage.facewallet.xyz";case t.Env.ProdMainnet:default:return"https://app.facewallet.xyz"}}(this.env,o)),this.face=s,this.iframeUrl=o}return e.prototype.getAddresses=function(e){return u(this,void 0,void 0,(function(){var n,r;return h(this,(function(i){switch(i.label){case 0:return[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_accounts,params:[e]})];case 1:return n=i.sent(),[4,this.iframe.waitForResponse(n)];case 2:return(r=i.sent())?[2,r]:[2,Promise.reject(new Error("get address failed"))]}}))}))},e.prototype.estimateGas=function(t){return u(this,void 0,void 0,(function(){return h(this,(function(t){return[2,0]}))}))},e.prototype.getBalance=function(e,n){return u(this,void 0,void 0,(function(){var i,o,s,a;return h(this,(function(c){switch(c.label){case 0:return n?[4,this.encodeData(["function balanceOf(address owner) view returns (uint256)"],"balanceOf",[e])]:[3,3];case 1:return i=c.sent(),[4,this.sendRpc({method:t.JsonRpcMethod.eth_call,params:[{to:n,data:i},"latest"]})];case 2:return o=c.sent(),[2,r.BigNumber.from(o)];case 3:return a=(s=r.BigNumber).from,[4,this.sendRpc({method:t.JsonRpcMethod.eth_getBalance,params:[e,"latest"]})];case 4:return[2,a.apply(s,[c.sent()])]}}))}))},e.prototype.ownerOf=function(e,n){return u(this,void 0,void 0,(function(){var r;return h(this,(function(i){switch(i.label){case 0:return[4,this.encodeData(["function ownerOf(uint256 tokenId) view returns (address)"],"ownerOf",[n])];case 1:return r=i.sent(),[4,this.sendRpc({method:t.JsonRpcMethod.eth_call,params:[{to:e,data:r},"latest"]})];case 2:return[2,("0x"+i.sent().substring(26)).toLowerCase()]}}))}))},e.prototype.logout=function(){return u(this,void 0,void 0,(function(){var e;return h(this,(function(n){switch(n.label){case 0:return[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_logOut})];case 1:return e=n.sent(),[4,this.iframe.waitForResponse(e)];case 2:return n.sent(),[2]}}))}))},e.prototype.getCurrentUser=function(){return u(this,void 0,void 0,(function(){var e;return h(this,(function(n){switch(n.label){case 0:return[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_currentUser})];case 1:return e=n.sent(),[4,this.iframe.waitForResponse(e)];case 2:return[2,n.sent()]}}))}))},e.prototype.isLoggedIn=function(){return u(this,void 0,void 0,(function(){var e;return h(this,(function(n){switch(n.label){case 0:return[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_loggedIn})];case 1:return n.sent(),[4,this.iframe.waitForResponse()];case 2:return(e=n.sent())?[2,e]:[2,!1]}}))}))},e.prototype.ready=function(){return u(this,void 0,void 0,(function(){return h(this,(function(t){return[2,this.iframe.ready()]}))}))},e.prototype.loginWithCredential=function(e){return u(this,void 0,void 0,(function(){var n;return h(this,(function(r){switch(r.label){case 0:return[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_logInSignUp,params:e})];case 1:return n=r.sent(),[4,this.iframe.waitForResponse(n)];case 2:return[2,r.sent()]}}))}))},e.prototype.directSocialLogin=function(e){return u(this,void 0,void 0,(function(){var n;return h(this,(function(r){switch(r.label){case 0:return[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_directSocialLogin,params:[e]})];case 1:return n=r.sent(),[4,this.iframe.waitForResponse(n)];case 2:return[2,r.sent()]}}))}))},e.prototype.getIdToken=function(e,n){return u(this,void 0,void 0,(function(){var r;return h(this,(function(i){switch(i.label){case 0:return[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_getIdToken,params:[e,n]})];case 1:return r=i.sent(),[4,this.iframe.waitForResponse(r)];case 2:return[2,i.sent()]}}))}))},e.prototype.loginWithIdToken=function(e){return u(this,void 0,void 0,(function(){var n;return h(this,(function(r){switch(r.label){case 0:return[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_loginWithIdToken,params:[e]})];case 1:return n=r.sent(),[4,this.iframe.waitForResponse(n)];case 2:return[2,r.sent()]}}))}))},e.prototype.loginWithAccessToken=function(e){return u(this,void 0,void 0,(function(){var n;return h(this,(function(r){switch(r.label){case 0:return[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_loginWithAccessToken,params:[e]})];case 1:return n=r.sent(),[4,this.iframe.waitForResponse(n)];case 2:return[2,r.sent()]}}))}))},e.prototype.openWalletConnect=function(e,n){return u(this,void 0,void 0,(function(){var r;return h(this,(function(i){switch(i.label){case 0:return this.iframe.throwExceptionUnsupportedBlockchain([t.Blockchain.APTOS,t.Blockchain.NEAR,t.Blockchain.SOLANA,t.Blockchain.PSM]),[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_openWalletConnect,params:[e,n]})];case 1:return r=i.sent(),[4,this.iframe.waitForResponse(r)];case 2:return[2,i.sent()]}}))}))},e.prototype.openHome=function(e){return u(this,void 0,void 0,(function(){var n,r,i;return h(this,(function(o){switch(o.label){case 0:if(this.iframe.throwExceptionUnsupportedBlockchain([t.Blockchain.APTOS,t.Blockchain.SOLANA,t.Blockchain.NEAR]),n=b(this.network),(null==e?void 0:e.networks)&&e.networks.some((function(t){return b(t)!==n})))throw r="You initialized the Face SDK with ".concat(n?"Mainnet":"Testnet",". Please open the wallet home in the same environment as the initialized network."),new Error(r);return[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_openHome,params:[e]})];case 1:return i=o.sent(),[2,this.iframe.waitForResponse(i)]}}))}))},e.prototype.sendRpc=function(t){return u(this,void 0,void 0,(function(){var e;return h(this,(function(n){switch(n.label){case 0:return[4,this.iframe.sendChildMessage(t)];case 1:return e=n.sent(),[4,this.iframe.waitForResponse(e)];case 2:return[2,n.sent()]}}))}))},e.prototype.decodeData=function(t,e){return u(this,void 0,void 0,(function(){var n,i,o,s;return h(this,(function(a){return n=new r.ethers.utils.Interface(e),i=n.parseTransaction({data:t}),o=i.name,s=i.args,[2,{name:o,args:s}]}))}))},e.prototype.encodeData=function(t,e,n){return u(this,void 0,void 0,(function(){return h(this,(function(i){return[2,new r.ethers.utils.Interface(t).encodeFunctionData(e,n)]}))}))},e.prototype.switchNetwork=function(e){return u(this,void 0,void 0,(function(){var n,r,i;return h(this,(function(o){switch(o.label){case 0:return n=N(e),r={method:t.JsonRpcMethod.face_switchNetwork,params:[{blockchain:n}]},[4,this.sendRpc(r)];case 1:return i=o.sent(),this.face.setNetwork(e),this.iframe.setBlockchain(n),[2,i]}}))}))},e.prototype.boraIsConnected=function(e){return u(this,void 0,void 0,(function(){var n;return h(this,(function(r){switch(r.label){case 0:return this.iframe.throwExceptionUnsupportedBlockchain([t.Blockchain.APTOS,t.Blockchain.NEAR,t.Blockchain.KLAYTN,t.Blockchain.BNB_SMART_CHAIN,t.Blockchain.ETHEREUM,t.Blockchain.MEVERSE,t.Blockchain.SOLANA,t.Blockchain.POLYGON,t.Blockchain.PSM]),[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.bora_isConnected,params:[e]})];case 1:return n=r.sent(),[4,this.iframe.waitForResponse(n)];case 2:return[2,r.sent()]}}))}))},e.prototype.boraConnect=function(e){return u(this,void 0,void 0,(function(){var n;return h(this,(function(r){switch(r.label){case 0:return this.iframe.throwExceptionUnsupportedBlockchain([t.Blockchain.APTOS,t.Blockchain.NEAR,t.Blockchain.KLAYTN,t.Blockchain.BNB_SMART_CHAIN,t.Blockchain.ETHEREUM,t.Blockchain.MEVERSE,t.Blockchain.SOLANA,t.Blockchain.POLYGON,t.Blockchain.PSM]),[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.bora_connect,params:[e]})];case 1:return n=r.sent(),[4,this.iframe.waitForResponse(n)];case 2:return[2,r.sent()]}}))}))},e}(),T=function(e){function n(t){var n=e.call(this)||this;return n.internal=t,n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}c(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}(n,e),n.prototype.request=function(e){return u(this,void 0,void 0,(function(){var n,r=this;return h(this,(function(i){if(Array.isArray(e))return[2,Promise.all(e.map((function(t){return r.internal.sendRpc(t)})))];switch(e.method){case t.JsonRpcMethod.wallet_switchEthereumChain:return n=t.NetworkChainIdMap[e.params[0].chainId],[2,this.internal.switchNetwork(n)];case t.JsonRpcMethod.eth_estimateGas:return[2,this.internal.estimateGas(e)];case"personal_listAccounts":case"eth_accounts":return[2,this.internal.getAddresses()];default:return[2,this.internal.sendRpc(e)]}return[2]}))}))},n}((function(){this.sendAsync=function(t,e){}})),R=function(){function e(t){this.internal=t}return e.prototype.close=function(){this.internal.iframe.hideOverlay()},e.prototype.home=function(e){var n;return u(this,void 0,void 0,(function(){return h(this,(function(r){return t.assertArgument(null==e?void 0:e.networks,null===(n=null==e?void 0:e.networks)||void 0===n?void 0:n.length,"options.networks",!1),[2,this.internal.openHome(e)]}))}))},e}(),_=function(){function e(t){this.internal=t}return e.prototype.connectOpensea=function(e){return u(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:return t.assertArgument(e,"string"==typeof e,"collectionName",!1),[4,this.connect("OpenSea",e?"https://opensea.io/collection/"+e:"https://opensea.io")];case 1:return n.sent(),[2]}}))}))},e.prototype.connect=function(e,n){return u(this,void 0,void 0,(function(){return h(this,(function(r){switch(r.label){case 0:return t.assertArgument(e,"string"==typeof e,"name"),t.assertArgument(n,"string"==typeof n,"url"),[4,this.internal.openWalletConnect(e,n)];case 1:return r.sent(),[2]}}))}))},e}(),B=function(){function e(e){var n=this,r=e.apiKey,i=e.network,o=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}(e,["apiKey","network"]);this.getAddresses=function(e){return u(n,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:return t.assertArgument(e,e&&t.Blockchain[e],"blockchain",!1),[4,this.internal.getAddresses(e)];case 1:return[2,n.sent()]}}))}))},this.setNetwork=function(e){t.assertArgument(e,t.isSupportedNetwork(e),"network"),n.network=e},this.getNetwork=function(){return n.network},this.getChainId=function(){return u(n,void 0,void 0,(function(){var t;return h(this,(function(e){switch(e.label){case 0:return t=Number,[4,this.internal.sendRpc({method:"eth_chainId",params:[]})];case 1:return[2,t.apply(void 0,[e.sent()])]}}))}))},t.assertArgument(r,"string"==typeof r,"apiKey"),t.assertArgument(i,!0,"network");var s="number"==typeof i?t.NetworkChainIdMap[i]:i;t.assert(t.isSupportedNetwork(s),t.unsupportedChainError),this.network=s,this.internal=new E({apiKey:r,network:s,env:null==o?void 0:o.env,iframeUrl:null==o?void 0:o.iframeUrl,face:this}),this.auth=new l(this.internal),this.wc=new _(this.internal),this.solana=new g(this.internal),this.near=new w(this.internal),this.wallet=new R(this.internal),this.bora=new p(this.internal),this.aptos=new f(this.internal)}return e.prototype.ready=function(){return u(this,void 0,void 0,(function(){return h(this,(function(t){return[2,this.internal.ready()]}))}))},e.prototype.getEthLikeProvider=function(){return t.assert(t.isEthlikeBlockchain(t.networkToBlockchain(this.network)),t.unsupportedChainError),new T(this.internal)},e.prototype.switchNetwork=function(e){return u(this,void 0,void 0,(function(){var n;return h(this,(function(r){return n="number"==typeof e?t.NetworkChainIdMap[e]:e,t.assertArgument(e,t.isSupportedNetwork(n),"network"),[2,this.internal.switchNetwork(n)]}))}))},e}();Object.defineProperty(exports,"Network",{enumerable:!0,get:function(){return t.Network}}),exports.Face=B;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@haechi-labs/face-types"),e=require("@noble/hashes/sha3"),n=require("aptos"),r=require("ethers"),i=require("near-api-js"),o=require("@solana/web3.js");function s(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}})),e.default=t,Object.freeze(e)}var a=s(i),c=function(t,e){return c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},c(t,e)};function u(t,e,n,r){return new(n||(n=Promise))((function(i,o){function s(t){try{c(r.next(t))}catch(t){o(t)}}function a(t){try{c(r.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))}function h(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}var l=function(){function e(t){this.internal=t}return e.prototype.login=function(e){return u(this,void 0,void 0,(function(){return h(this,(function(n){return t.assertArgument(e,Array.isArray(e)&&e.length>0&&function(t,e,n){if(n||2===arguments.length)for(var r,i=0,o=e.length;i<o;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))}([],e,!0).every((function(e){return Object.values(t.LoginProvider).includes(e)})),"providers",!1),[2,this.internal.loginWithCredential(e)]}))}))},e.prototype.directSocialLogin=function(e){return u(this,void 0,void 0,(function(){return h(this,(function(n){return t.assertArgument(e,"string"==typeof e,"provider"),[2,this.internal.directSocialLogin(e)]}))}))},e.prototype.getIdToken=function(e,n){return u(this,void 0,void 0,(function(){return h(this,(function(r){return t.assertArgument(e,"string"==typeof e,"provider"),t.assertArgument(n,"string"==typeof n,"accessToken"),[2,this.internal.getIdToken(e,n)]}))}))},e.prototype.loginWithIdToken=function(e){return u(this,void 0,void 0,(function(){return h(this,(function(n){return t.assertArgument(e,e.idToken&&e.sig,"loginWithIdTokenRequest"),[2,this.internal.loginWithIdToken(e)]}))}))},e.prototype.loginWithAccessToken=function(e){return u(this,void 0,void 0,(function(){return h(this,(function(n){return t.assertArgument(e,e.accessToken&&e.sig,"loginWithIdTokenRequest"),[2,this.internal.loginWithAccessToken(e)]}))}))},e.prototype.logout=function(){return u(this,void 0,void 0,(function(){return h(this,(function(t){switch(t.label){case 0:return[4,this.internal.logout()];case 1:return t.sent(),[2]}}))}))},e.prototype.getCurrentUser=function(){return u(this,void 0,void 0,(function(){return h(this,(function(t){switch(t.label){case 0:return[4,this.internal.getCurrentUser()];case 1:return[2,t.sent()]}}))}))},e.prototype.isLoggedIn=function(){return u(this,void 0,void 0,(function(){return h(this,(function(t){switch(t.label){case 0:return[4,this.internal.isLoggedIn()];case 1:return[2,t.sent()]}}))}))},e}(),d=function(){function r(t){this.internal=t}return r.prototype.getPublicKeys=function(){return u(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this.internal.getAddresses(t.Blockchain.APTOS)];case 1:return[2,e.sent().map((function(t){return n.HexString.ensure(t)}))]}}))}))},r.prototype.getAddresses=function(){return u(this,void 0,void 0,(function(){return h(this,(function(r){switch(r.label){case 0:return[4,this.internal.getAddresses(t.Blockchain.APTOS)];case 1:return[2,r.sent().map((function(t){var r=Uint8Array.from(t.substring(2).match(/.{1,2}/g).map((function(t){return parseInt(t,16)}))),i=new Uint8Array(r.length+1);i.set(r),i.set([0],r.length);var o=e.sha3_256.create();return o.update(i),n.HexString.fromUint8Array(o.digest())}))]}}))}))},r.prototype.signMultiAgentTransaction=function(e){return u(this,void 0,void 0,(function(){return h(this,(function(r){switch(r.label){case 0:return[4,this.internal.sendRpc({method:t.JsonRpcMethod.aptos_signMultiAgentTransaction,params:[e.raw_txn.sender.address,n.BCS.bcsToBytes(e)]})];case 1:return[2,r.sent()]}}))}))},r.prototype.signMessage=function(e){return u(this,void 0,void 0,(function(){var n,r;return h(this,(function(i){switch(i.label){case 0:return n=Buffer.from(JSON.stringify(e)),[4,this.internal.sendRpc({method:t.JsonRpcMethod.aptos_signMessage,params:[n]})];case 1:return r=i.sent(),[2,JSON.parse(r)]}}))}))},r.prototype.signAndSubmitTransaction=function(e,n){return u(this,void 0,void 0,(function(){var r;return h(this,(function(i){switch(i.label){case 0:return[4,this.internal.getAddresses(t.Blockchain.APTOS)];case 1:return r=i.sent()[0],[4,this.internal.sendRpc({method:t.JsonRpcMethod.aptos_signAndSubmitTransaction,params:[Buffer.from(r),Buffer.from(JSON.stringify(e)),n]})];case 2:return[2,{hash:i.sent()}]}}))}))},r.prototype.signTransaction=function(e,n){return u(this,void 0,void 0,(function(){var r,i;return h(this,(function(o){switch(o.label){case 0:return[4,this.internal.getAddresses(t.Blockchain.APTOS)];case 1:return r=o.sent()[0],[4,this.internal.sendRpc({method:t.JsonRpcMethod.aptos_signTransaction,params:[Buffer.from(r),Buffer.from(JSON.stringify(e)),n]})];case 2:return i=o.sent(),[2,JSON.parse(i)]}}))}))},r}(),f=function(){function t(t){this.internal=t}return t.prototype.getProvider=function(){return new d(this.internal)},t}(),p=function(){function e(t){this.internal=t}return e.prototype.connect=function(e){return u(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:return t.assertArgument(e,e.bappUsn&&e.signature,"request"),[4,this.internal.boraConnect(e)];case 1:return[2,n.sent()]}}))}))},e.prototype.isConnected=function(e){return u(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:return t.assertArgument(e,"string"==typeof e,"bappUsn"),[4,this.internal.boraIsConnected(e)];case 1:return[2,n.sent()]}}))}))},e}(),v=function(){function e(t){this.internal=t}return e.prototype.getPublicKeys=function(){return u(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this.internal.getAddresses(t.Blockchain.NEAR)];case 1:return[2,e.sent().map((function(t){return a.utils.PublicKey.fromString(a.utils.serialize.base_encode(Buffer.from(t,"hex")))}))]}}))}))},e.prototype.getBalance=function(e,n){return u(this,void 0,void 0,(function(){var i;return h(this,(function(o){switch(o.label){case 0:return t.assertArgument(e,"string"==typeof e,"address"),t.assertArgument(n,"string"==typeof n,"contractAddress",!1),[4,this.internal.sendRpc({method:t.JsonRpcMethod.near_get_balance,params:[e,n]})];case 1:return i=o.sent(),[2,r.BigNumber.from(i)]}}))}))},e.prototype.signAndSendTransaction=function(t){return u(this,void 0,void 0,(function(){var e;return h(this,(function(n){switch(n.label){case 0:return e={serializedHex:Buffer.from(a.utils.serialize.serialize(a.transactions.SCHEMA,t)).toString("hex")},[4,this.internal.sendRpc({method:"near_broadcast_tx_async",params:[e]})];case 1:return[2,n.sent()]}}))}))},e}(),w=function(){function t(t){this.internal=t}return t.prototype.getProvider=function(){return new v(this.internal)},t}(),m=function(){function e(t){this.internal=t}return e.prototype.getPublicKeys=function(){return u(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this.internal.getAddresses(t.Blockchain.SOLANA)];case 1:return[2,e.sent().map((function(t){return new o.PublicKey(r.ethers.utils.base58.decode(t))}))]}}))}))},e.prototype.signAndSendTransaction=function(t){return u(this,void 0,void 0,(function(){var e;return h(this,(function(n){switch(n.label){case 0:return e={serializedHex:t.serialize({requireAllSignatures:!1,verifySignatures:!1}).toString("hex")},[4,this.internal.sendRpc({method:"solana_sendTransaction",params:[e]})];case 1:return[2,n.sent()]}}))}))},e}(),g=function(){function t(t){this.internal=t}return t.prototype.getProvider=function(){return new m(this.internal)},t}(),y={display:"none",position:"fixed",top:"0",right:"0",width:"100%",height:"100%",borderRadius:"0",border:"none",zIndex:"2147483647"};var k=function(){var t=this;this._isCompleted=!1,this._eventListeners=Array(),this.complete=function(){t._isCompleted=!0,t._eventListeners.forEach((function(t){return t()}))},this.add=function(e){t._eventListeners.push(e)},this.isCompleted=function(){return t._isCompleted}},A=function(){function e(t,e,n,r){var i,o=this;this._ready=new k,this.requestIndex=0,this.activeElement=null,this._blockchain=e,this._env=n,this.iframeUrl=r;var s=Math.random().toString();if(this.randomPrefix=s.substring(s.length-6),document.getElementById("face-iframe"))throw new Error("Face is already initialized, Face can be initialized once.");window.addEventListener("message",(function(t){return u(o,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return t.origin!==r?[2]:[4,this.processMessage(t.data)];case 1:return e.sent(),[2]}}))}))}));var a=null!==(i="1.10.5-alpha.0")?i:"";this._iframe=new Promise((function(i){var o=function(){if(!document.getElementById("face-iframe")){var o=document.createElement("iframe");o.id="face-iframe",o.title="Secure Modal",o.src=new URL("".concat(r,"?api_key=").concat(t,"&blockchain=").concat(e,"&env=").concat(n,"&version=").concat(a,"&type=").concat("web")).href,o.allow="clipboard-read; clipboard-write",function(t){for(var e=0,n=Object.entries(y);e<n.length;e++){var r=n[e],i=r[0],o=r[1];t.style[i]=o}}(o),document.body.appendChild(o),i(o)}};["loaded","interactive","complete"].includes(document.readyState)?o():window.addEventListener("load",o,!1)}))}return e.prototype.sendChildMessage=function(e){var n,r;return u(this,void 0,void 0,(function(){var i;return h(this,(function(o){switch(o.label){case 0:return[4,this.ready()];case 1:return o.sent(),this.requestIndex+=1,i=e.id?"".concat(e.id):"".concat(this.randomPrefix,"-").concat(this.requestIndex),e.id=i,e.from=t.JsonRpcSource.FACE_SDK,[4,this._iframe];case 2:return null===(r=null===(n=o.sent())||void 0===n?void 0:n.contentWindow)||void 0===r||r.postMessage(e,"*"),[2,i]}}))}))},e.prototype.waitForResponse=function(t){return new Promise((function(e,n){var r=function(i){var o=i.data;t&&o.id!==t||(window.removeEventListener("message",r),o.error?n(o.error):e(o.result))};window.addEventListener("message",r)}))},e.prototype.processMessage=function(e){return u(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:switch(e.method){case t.JsonRpcMethod.face_ready:return[3,1];case t.JsonRpcMethod.face_openIframe:return[3,2];case t.JsonRpcMethod.face_closeIframe:return[3,4]}return[3,6];case 1:return this._ready.complete(),[3,6];case 2:return[4,this.showOverlay()];case 3:case 5:return n.sent(),[3,6];case 4:return[4,this.hideOverlay()];case 6:return[2]}}))}))},e.prototype.ready=function(){return u(this,void 0,void 0,(function(){var t=this;return h(this,(function(e){return[2,new Promise((function(e){return u(t,void 0,void 0,(function(){return h(this,(function(t){return this._ready.isCompleted()?(e(),[2]):(this._ready.add((function(){e()})),[2])}))}))}))]}))}))},e.prototype.showOverlay=function(){return u(this,void 0,void 0,(function(){var t;return h(this,(function(e){switch(e.label){case 0:return[4,this.ready()];case 1:return e.sent(),[4,this._iframe];case 2:return(t=e.sent()).style.display="block",this.activeElement=document.activeElement,t.focus(),[2]}}))}))},e.prototype.hideOverlay=function(){var t;return u(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this.ready()];case 1:return e.sent(),[4,this._iframe];case 2:return e.sent().style.display="none",(null===(t=this.activeElement)||void 0===t?void 0:t.focus)&&this.activeElement.focus(),this.activeElement=null,[2]}}))}))},e.prototype.setBlockchain=function(t){this._blockchain=t},e.prototype.throwExceptionUnsupportedBlockchain=function(e){if(e.includes(this._blockchain))throw t.unsupportedChainError()},e.prototype.getBlockchain=function(){return this._blockchain},e}();function b(e){switch(e){case t.Network.ETHEREUM:case t.Network.POLYGON:case t.Network.BNB_SMART_CHAIN:case t.Network.KLAYTN:case t.Network.SOLANA:case t.Network.BORA:case t.Network.NEAR:case t.Network.APTOS:case t.Network.MEVERSE:case t.Network.PSM:return!0;default:return!1}}function N(e){switch(e){case t.Network.ETHEREUM:case t.Network.GOERLI:return t.Blockchain.ETHEREUM;case t.Network.POLYGON:case t.Network.MUMBAI:return t.Blockchain.POLYGON;case t.Network.BNB_SMART_CHAIN:case t.Network.BNB_SMART_CHAIN_TESTNET:return t.Blockchain.BNB_SMART_CHAIN;case t.Network.KLAYTN:case t.Network.BAOBAB:return t.Blockchain.KLAYTN;case t.Network.SOLANA:case t.Network.SOLANA_DEVNET:return t.Blockchain.SOLANA;case t.Network.BORA:case t.Network.BORA_TESTNET:return t.Blockchain.BORA;case t.Network.NEAR:case t.Network.NEAR_TESTNET:return t.Blockchain.NEAR;case t.Network.APTOS:case t.Network.APTOS_TESTNET:return t.Blockchain.APTOS;case t.Network.MEVERSE:case t.Network.MEVERSE_TESTNET:return t.Blockchain.MEVERSE;case t.Network.PSM:case t.Network.PSM_TESTNET:return t.Blockchain.PSM;default:return t.Blockchain.ETHEREUM}}r.BigNumber.from(1e5).toHexString();var E=function(){function e(e){var n=e.apiKey,r=e.network,i=e.env,o=e.iframeUrl,s=e.face;this.network=r||t.Network.ETHEREUM;var a=N(this.network);this.env=null!=i?i:function(e){return!e||e!==t.Network.GOERLI&&e!==t.Network.MUMBAI&&e!==t.Network.BAOBAB&&e!==t.Network.BNB_SMART_CHAIN_TESTNET&&e!==t.Network.BORA_TESTNET&&e!==t.Network.SOLANA_DEVNET&&e!==t.Network.NEAR_TESTNET&&e!==t.Network.APTOS_TESTNET&&e!==t.Network.MEVERSE_TESTNET&&e!==t.Network.PSM_TESTNET?t.Env.ProdMainnet:t.Env.ProdTest}(r),this.iframe=new A(n,a,this.env,function(e,n){if(null!=n)return n;switch(e){case t.Env.Local:return"http://localhost:3333";case t.Env.Dev:return"https://app.dev.facewallet.xyz";case t.Env.StageTest:return"https://app.stage-test.facewallet.xyz";case t.Env.ProdTest:return"https://app.test.facewallet.xyz";case t.Env.StageMainnet:return"https://app.stage.facewallet.xyz";case t.Env.ProdMainnet:default:return"https://app.facewallet.xyz"}}(this.env,o)),this.face=s,this.iframeUrl=o}return e.prototype.getAddresses=function(e){return u(this,void 0,void 0,(function(){var n,r;return h(this,(function(i){switch(i.label){case 0:return[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_accounts,params:[e]})];case 1:return n=i.sent(),[4,this.iframe.waitForResponse(n)];case 2:return(r=i.sent())?[2,r]:[2,Promise.reject(new Error("get address failed"))]}}))}))},e.prototype.estimateGas=function(t){return u(this,void 0,void 0,(function(){return h(this,(function(t){return[2,0]}))}))},e.prototype.getBalance=function(e,n){return u(this,void 0,void 0,(function(){var i,o,s,a;return h(this,(function(c){switch(c.label){case 0:return n?[4,this.encodeData(["function balanceOf(address owner) view returns (uint256)"],"balanceOf",[e])]:[3,3];case 1:return i=c.sent(),[4,this.sendRpc({method:t.JsonRpcMethod.eth_call,params:[{to:n,data:i},"latest"]})];case 2:return o=c.sent(),[2,r.BigNumber.from(o)];case 3:return a=(s=r.BigNumber).from,[4,this.sendRpc({method:t.JsonRpcMethod.eth_getBalance,params:[e,"latest"]})];case 4:return[2,a.apply(s,[c.sent()])]}}))}))},e.prototype.ownerOf=function(e,n){return u(this,void 0,void 0,(function(){var r;return h(this,(function(i){switch(i.label){case 0:return[4,this.encodeData(["function ownerOf(uint256 tokenId) view returns (address)"],"ownerOf",[n])];case 1:return r=i.sent(),[4,this.sendRpc({method:t.JsonRpcMethod.eth_call,params:[{to:e,data:r},"latest"]})];case 2:return[2,("0x"+i.sent().substring(26)).toLowerCase()]}}))}))},e.prototype.logout=function(){return u(this,void 0,void 0,(function(){var e;return h(this,(function(n){switch(n.label){case 0:return[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_logOut})];case 1:return e=n.sent(),[4,this.iframe.waitForResponse(e)];case 2:return n.sent(),[2]}}))}))},e.prototype.getCurrentUser=function(){return u(this,void 0,void 0,(function(){var e;return h(this,(function(n){switch(n.label){case 0:return[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_currentUser})];case 1:return e=n.sent(),[4,this.iframe.waitForResponse(e)];case 2:return[2,n.sent()]}}))}))},e.prototype.isLoggedIn=function(){return u(this,void 0,void 0,(function(){var e;return h(this,(function(n){switch(n.label){case 0:return[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_loggedIn})];case 1:return n.sent(),[4,this.iframe.waitForResponse()];case 2:return(e=n.sent())?[2,e]:[2,!1]}}))}))},e.prototype.ready=function(){return u(this,void 0,void 0,(function(){return h(this,(function(t){return[2,this.iframe.ready()]}))}))},e.prototype.loginWithCredential=function(e){return u(this,void 0,void 0,(function(){var n;return h(this,(function(r){switch(r.label){case 0:return[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_logInSignUp,params:e})];case 1:return n=r.sent(),[4,this.iframe.waitForResponse(n)];case 2:return[2,r.sent()]}}))}))},e.prototype.directSocialLogin=function(e){return u(this,void 0,void 0,(function(){var n;return h(this,(function(r){switch(r.label){case 0:return[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_directSocialLogin,params:[e]})];case 1:return n=r.sent(),[4,this.iframe.waitForResponse(n)];case 2:return[2,r.sent()]}}))}))},e.prototype.getIdToken=function(e,n){return u(this,void 0,void 0,(function(){var r;return h(this,(function(i){switch(i.label){case 0:return[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_getIdToken,params:[e,n]})];case 1:return r=i.sent(),[4,this.iframe.waitForResponse(r)];case 2:return[2,i.sent()]}}))}))},e.prototype.loginWithIdToken=function(e){return u(this,void 0,void 0,(function(){var n;return h(this,(function(r){switch(r.label){case 0:return[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_loginWithIdToken,params:[e]})];case 1:return n=r.sent(),[4,this.iframe.waitForResponse(n)];case 2:return[2,r.sent()]}}))}))},e.prototype.loginWithAccessToken=function(e){return u(this,void 0,void 0,(function(){var n;return h(this,(function(r){switch(r.label){case 0:return[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_loginWithAccessToken,params:[e]})];case 1:return n=r.sent(),[4,this.iframe.waitForResponse(n)];case 2:return[2,r.sent()]}}))}))},e.prototype.openWalletConnect=function(e,n){return u(this,void 0,void 0,(function(){var r;return h(this,(function(i){switch(i.label){case 0:return this.iframe.throwExceptionUnsupportedBlockchain([t.Blockchain.APTOS,t.Blockchain.NEAR,t.Blockchain.SOLANA,t.Blockchain.PSM]),[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_openWalletConnect,params:[e,n]})];case 1:return r=i.sent(),[4,this.iframe.waitForResponse(r)];case 2:return[2,i.sent()]}}))}))},e.prototype.openHome=function(e){return u(this,void 0,void 0,(function(){var n,r,i;return h(this,(function(o){switch(o.label){case 0:if(this.iframe.throwExceptionUnsupportedBlockchain([t.Blockchain.APTOS,t.Blockchain.SOLANA,t.Blockchain.NEAR]),n=b(this.network),(null==e?void 0:e.networks)&&e.networks.some((function(t){return b(t)!==n})))throw r="You initialized the Face SDK with ".concat(n?"Mainnet":"Testnet",". Please open the wallet home in the same environment as the initialized network."),new Error(r);return[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_openHome,params:[e]})];case 1:return i=o.sent(),[2,this.iframe.waitForResponse(i)]}}))}))},e.prototype.sendRpc=function(t){return u(this,void 0,void 0,(function(){var e;return h(this,(function(n){switch(n.label){case 0:return[4,this.iframe.sendChildMessage(t)];case 1:return e=n.sent(),[4,this.iframe.waitForResponse(e)];case 2:return[2,n.sent()]}}))}))},e.prototype.decodeData=function(t,e){return u(this,void 0,void 0,(function(){var n,i,o,s;return h(this,(function(a){return n=new r.ethers.utils.Interface(e),i=n.parseTransaction({data:t}),o=i.name,s=i.args,[2,{name:o,args:s}]}))}))},e.prototype.encodeData=function(t,e,n){return u(this,void 0,void 0,(function(){return h(this,(function(i){return[2,new r.ethers.utils.Interface(t).encodeFunctionData(e,n)]}))}))},e.prototype.switchNetwork=function(e){return u(this,void 0,void 0,(function(){var n,r,i;return h(this,(function(o){switch(o.label){case 0:return n=N(e),r={method:t.JsonRpcMethod.face_switchNetwork,params:[{blockchain:n}]},[4,this.sendRpc(r)];case 1:return i=o.sent(),this.face.setNetwork(e),this.iframe.setBlockchain(n),[2,i]}}))}))},e.prototype.boraIsConnected=function(e){return u(this,void 0,void 0,(function(){var n;return h(this,(function(r){switch(r.label){case 0:return this.iframe.throwExceptionUnsupportedBlockchain([t.Blockchain.APTOS,t.Blockchain.NEAR,t.Blockchain.KLAYTN,t.Blockchain.BNB_SMART_CHAIN,t.Blockchain.ETHEREUM,t.Blockchain.MEVERSE,t.Blockchain.SOLANA,t.Blockchain.POLYGON,t.Blockchain.PSM]),[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.bora_isConnected,params:[e]})];case 1:return n=r.sent(),[4,this.iframe.waitForResponse(n)];case 2:return[2,r.sent()]}}))}))},e.prototype.boraConnect=function(e){return u(this,void 0,void 0,(function(){var n;return h(this,(function(r){switch(r.label){case 0:return this.iframe.throwExceptionUnsupportedBlockchain([t.Blockchain.APTOS,t.Blockchain.NEAR,t.Blockchain.KLAYTN,t.Blockchain.BNB_SMART_CHAIN,t.Blockchain.ETHEREUM,t.Blockchain.MEVERSE,t.Blockchain.SOLANA,t.Blockchain.POLYGON,t.Blockchain.PSM]),[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.bora_connect,params:[e]})];case 1:return n=r.sent(),[4,this.iframe.waitForResponse(n)];case 2:return[2,r.sent()]}}))}))},e}(),T=function(e){function n(t){var n=e.call(this)||this;return n.internal=t,n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}c(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}(n,e),n.prototype.request=function(e){return u(this,void 0,void 0,(function(){var n,r=this;return h(this,(function(i){if(Array.isArray(e))return[2,Promise.all(e.map((function(t){return r.internal.sendRpc(t)})))];switch(e.method){case t.JsonRpcMethod.wallet_switchEthereumChain:return n=t.NetworkChainIdMap[e.params[0].chainId],[2,this.internal.switchNetwork(n)];case t.JsonRpcMethod.eth_estimateGas:return[2,this.internal.estimateGas(e)];case"personal_listAccounts":case"eth_accounts":return[2,this.internal.getAddresses()];default:return[2,this.internal.sendRpc(e)]}return[2]}))}))},n}((function(){this.sendAsync=function(t,e){}})),R=function(){function e(t){this.internal=t}return e.prototype.close=function(){this.internal.iframe.hideOverlay()},e.prototype.home=function(e){var n;return u(this,void 0,void 0,(function(){return h(this,(function(r){return t.assertArgument(null==e?void 0:e.networks,null===(n=null==e?void 0:e.networks)||void 0===n?void 0:n.length,"options.networks",!1),[2,this.internal.openHome(e)]}))}))},e}(),_=function(){function e(t){this.internal=t}return e.prototype.connectOpensea=function(e){return u(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:return t.assertArgument(e,"string"==typeof e,"collectionName",!1),[4,this.connect("OpenSea",e?"https://opensea.io/collection/"+e:"https://opensea.io")];case 1:return n.sent(),[2]}}))}))},e.prototype.connect=function(e,n){return u(this,void 0,void 0,(function(){return h(this,(function(r){switch(r.label){case 0:return t.assertArgument(e,"string"==typeof e,"name"),t.assertArgument(n,"string"==typeof n,"url"),[4,this.internal.openWalletConnect(e,n)];case 1:return r.sent(),[2]}}))}))},e}(),B=function(){function e(e){var n=this,r=e.apiKey,i=e.network,o=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}(e,["apiKey","network"]);this.getAddresses=function(e){return u(n,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:return t.assertArgument(e,e&&t.Blockchain[e],"blockchain",!1),[4,this.internal.getAddresses(e)];case 1:return[2,n.sent()]}}))}))},this.setNetwork=function(e){t.assertArgument(e,t.isSupportedNetwork(e),"network"),n.network=e},this.getNetwork=function(){return n.network},this.getChainId=function(){return u(n,void 0,void 0,(function(){var t;return h(this,(function(e){switch(e.label){case 0:return t=Number,[4,this.internal.sendRpc({method:"eth_chainId",params:[]})];case 1:return[2,t.apply(void 0,[e.sent()])]}}))}))},t.assertArgument(r,"string"==typeof r,"apiKey"),t.assertArgument(i,!0,"network");var s="number"==typeof i?t.NetworkChainIdMap[i]:i;t.assert(t.isSupportedNetwork(s),t.unsupportedChainError),this.network=s,this.internal=new E({apiKey:r,network:s,env:null==o?void 0:o.env,iframeUrl:null==o?void 0:o.iframeUrl,face:this}),this.auth=new l(this.internal),this.wc=new _(this.internal),this.solana=new g(this.internal),this.near=new w(this.internal),this.wallet=new R(this.internal),this.bora=new p(this.internal),this.aptos=new f(this.internal)}return e.prototype.ready=function(){return u(this,void 0,void 0,(function(){return h(this,(function(t){return[2,this.internal.ready()]}))}))},e.prototype.getEthLikeProvider=function(){return t.assert(t.isEthlikeBlockchain(t.networkToBlockchain(this.network)),t.unsupportedChainError),new T(this.internal)},e.prototype.switchNetwork=function(e){return u(this,void 0,void 0,(function(){var n;return h(this,(function(r){return n="number"==typeof e?t.NetworkChainIdMap[e]:e,t.assertArgument(e,t.isSupportedNetwork(n),"network"),[2,this.internal.switchNetwork(n)]}))}))},e}();Object.defineProperty(exports,"Network",{enumerable:!0,get:function(){return t.Network}}),exports.Face=B;
//# sourceMappingURL=index.js.map
{
"name": "@haechi-labs/face-sdk",
"version": "1.10.4",
"version": "1.10.5-alpha.0",
"description": "",

@@ -34,5 +34,6 @@ "license": "ISC",

"devDependencies": {
"@haechi-labs/face-types": "^1.10.4",
"@haechi-labs/face-types": "^1.10.5-alpha.0",
"@rollup/plugin-commonjs": "^24.0.1",
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^13.3.0",
"@rollup/plugin-terser": "^0.4.0",

@@ -50,2 +51,3 @@ "@tsconfig/node16": "^1.0.2",

"rollup-plugin-node-polyfills": "^0.2.1",
"rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-replace": "^2.2.0",

@@ -61,3 +63,3 @@ "rollup-plugin-typescript2": "^0.34.1",

},
"gitHead": "51f79b3fe28c9233178f69209f487dcc54f1711f",
"gitHead": "489d0ba08486945d3862f5377e00a0ff9652ed47",
"publishConfig": {

@@ -64,0 +66,0 @@ "access": "public"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc