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.12 to 1.10.13

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("ethers"),n=require("@noble/hashes/sha3"),r=require("aptos"),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){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)}function h(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 l(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])}}}function f(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))}function d(){}function p(){p.init.call(this)}function v(t){return void 0===t._maxListeners?p.defaultMaxListeners:t._maxListeners}function w(t,e,n,r){var i,o,s,a;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((o=t._events)?(o.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),o=t._events),s=o[e]):(o=t._events=new d,t._eventsCount=0),s){if("function"==typeof s?s=o[e]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),!s.warned&&(i=v(t))&&i>0&&s.length>i){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+e+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=s.length,a=c,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[e]=n,++t._eventsCount;return t}function m(t,e,n){var r=!1;function i(){t.removeListener(e,i),r||(r=!0,n.apply(t,arguments))}return i.listener=n,i}function y(t){var e=this._events;if(e){var n=e[t];if("function"==typeof n)return 1;if(n)return n.length}return 0}function g(t,e){for(var n=new Array(e);e--;)n[e]=t[e];return n}function k(t,e,n){try{Reflect.apply(t,e,n)}catch(t){setTimeout((function(){throw t}))}}d.prototype=Object.create(null),p.EventEmitter=p,p.usingDomains=!1,p.prototype.domain=void 0,p.prototype._events=void 0,p.prototype._maxListeners=void 0,p.defaultMaxListeners=10,p.init=function(){this.domain=null,p.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new d,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},p.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||isNaN(t))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=t,this},p.prototype.getMaxListeners=function(){return v(this)},p.prototype.emit=function(t){var e,n,r,i,o,s,a,c="error"===t;if(s=this._events)c=c&&null==s.error;else if(!c)return!1;if(a=this.domain,c){if(e=arguments[1],!a){if(e instanceof Error)throw e;var u=new Error('Uncaught, unspecified "error" event. ('+e+")");throw u.context=e,u}return e||(e=new Error('Uncaught, unspecified "error" event')),e.domainEmitter=this,e.domain=a,e.domainThrown=!1,a.emit("error",e),!1}if(!(n=s[t]))return!1;var h="function"==typeof n;switch(r=arguments.length){case 1:!function(t,e,n){if(e)t.call(n);else for(var r=t.length,i=g(t,r),o=0;o<r;++o)i[o].call(n)}(n,h,this);break;case 2:!function(t,e,n,r){if(e)t.call(n,r);else for(var i=t.length,o=g(t,i),s=0;s<i;++s)o[s].call(n,r)}(n,h,this,arguments[1]);break;case 3:!function(t,e,n,r,i){if(e)t.call(n,r,i);else for(var o=t.length,s=g(t,o),a=0;a<o;++a)s[a].call(n,r,i)}(n,h,this,arguments[1],arguments[2]);break;case 4:!function(t,e,n,r,i,o){if(e)t.call(n,r,i,o);else for(var s=t.length,a=g(t,s),c=0;c<s;++c)a[c].call(n,r,i,o)}(n,h,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(r-1),o=1;o<r;o++)i[o-1]=arguments[o];!function(t,e,n,r){if(e)t.apply(n,r);else for(var i=t.length,o=g(t,i),s=0;s<i;++s)o[s].apply(n,r)}(n,h,this,i)}return!0},p.prototype.addListener=function(t,e){return w(this,t,e,!1)},p.prototype.on=p.prototype.addListener,p.prototype.prependListener=function(t,e){return w(this,t,e,!0)},p.prototype.once=function(t,e){if("function"!=typeof e)throw new TypeError('"listener" argument must be a function');return this.on(t,m(this,t,e)),this},p.prototype.prependOnceListener=function(t,e){if("function"!=typeof e)throw new TypeError('"listener" argument must be a function');return this.prependListener(t,m(this,t,e)),this},p.prototype.removeListener=function(t,e){var n,r,i,o,s;if("function"!=typeof e)throw new TypeError('"listener" argument must be a function');if(!(r=this._events))return this;if(!(n=r[t]))return this;if(n===e||n.listener&&n.listener===e)0==--this._eventsCount?this._events=new d:(delete r[t],r.removeListener&&this.emit("removeListener",t,n.listener||e));else if("function"!=typeof n){for(i=-1,o=n.length;o-- >0;)if(n[o]===e||n[o].listener&&n[o].listener===e){s=n[o].listener,i=o;break}if(i<0)return this;if(1===n.length){if(n[0]=void 0,0==--this._eventsCount)return this._events=new d,this;delete r[t]}else!function(t,e){for(var n=e,r=n+1,i=t.length;r<i;n+=1,r+=1)t[n]=t[r];t.pop()}(n,i);r.removeListener&&this.emit("removeListener",t,s||e)}return this},p.prototype.removeAllListeners=function(t){var e,n;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=new d,this._eventsCount=0):n[t]&&(0==--this._eventsCount?this._events=new d:delete n[t]),this;if(0===arguments.length){for(var r,i=Object.keys(n),o=0;o<i.length;++o)"removeListener"!==(r=i[o])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=new d,this._eventsCount=0,this}if("function"==typeof(e=n[t]))this.removeListener(t,e);else if(e)do{this.removeListener(t,e[e.length-1])}while(e[0]);return this},p.prototype.listeners=function(t){var e,n=this._events;return n&&(e=n[t])?"function"==typeof e?[e.listener||e]:function(t){for(var e=new Array(t.length),n=0;n<e.length;++n)e[n]=t[n].listener||t[n];return e}(e):[]},p.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):y.call(t,e)},p.prototype.listenerCount=y,p.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var E=new(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return u(e,t),e.prototype.emit=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var r="error"===t,i=this._events;if(void 0!==i)r=r&&void 0===i.error;else if(!r)return!1;if(r){var o=void 0;if(e.length>0&&(o=e[0]),o instanceof Error)throw o;var s=new Error("Unhandled error.".concat(o?" (".concat(o.message,")"):""));throw s.context=o,s}var a=i[t];if(void 0===a)return!1;if("function"==typeof a)k(a,this,e);else for(var c=a.length,u=function(t){for(var e=t.length,n=new Array(e),r=0;r<e;r+=1)n[r]=t[r];return n}(a),h=0;h<c;h+=1)k(u[h],this,e);return!0},e}(p)),N=function(){function n(t){this.internal=t}return n.prototype.emitLoginEventsOnlyEthlike=function(){if(t.isEthlikeNetwork(this.internal.getNetwork())){var n=e.ethers.utils.hexlify(t.NetworkChainIdMap[this.internal.getNetwork()]);E.emit("connect",{chainId:n})}},n.prototype.emitLogoutEventsOnlyEthlike=function(){t.isEthlikeNetwork(this.internal.getNetwork())&&E.emit("disconnect")},n.prototype.login=function(e){return h(this,void 0,void 0,(function(){var n;return l(this,(function(r){switch(r.label){case 0:return t.assertArgument(e,Array.isArray(e)&&e.length>0&&f([],e,!0).every((function(e){return Object.values(t.LoginProvider).includes(e)})),"providers",!1),[4,this.internal.loginWithCredential(e)];case 1:return n=r.sent(),this.emitLoginEventsOnlyEthlike(),[2,n]}}))}))},n.prototype.directSocialLogin=function(e){return h(this,void 0,void 0,(function(){var n;return l(this,(function(r){switch(r.label){case 0:return t.assertArgument(e,"string"==typeof e,"provider"),[4,this.internal.directSocialLogin(e)];case 1:return n=r.sent(),this.emitLoginEventsOnlyEthlike(),[2,n]}}))}))},n.prototype.getIdToken=function(e,n){return h(this,void 0,void 0,(function(){return l(this,(function(r){return t.assertArgument(e,"string"==typeof e,"provider"),t.assertArgument(n,"string"==typeof n,"accessToken"),[2,this.internal.getIdToken(e,n)]}))}))},n.prototype.loginWithIdToken=function(e){return h(this,void 0,void 0,(function(){var n;return l(this,(function(r){switch(r.label){case 0:return t.assertArgument(e,e.idToken&&e.sig,"loginWithIdTokenRequest"),[4,this.internal.loginWithIdToken(e)];case 1:return n=r.sent(),this.emitLoginEventsOnlyEthlike(),[2,n]}}))}))},n.prototype.loginWithAccessToken=function(e){return h(this,void 0,void 0,(function(){var n;return l(this,(function(r){switch(r.label){case 0:return t.assertArgument(e,e.accessToken&&e.sig,"loginWithIdTokenRequest"),[4,this.internal.loginWithAccessToken(e)];case 1:return n=r.sent(),this.emitLoginEventsOnlyEthlike(),[2,n]}}))}))},n.prototype.logout=function(){return h(this,void 0,void 0,(function(){return l(this,(function(t){switch(t.label){case 0:return[4,this.internal.logout()];case 1:return t.sent(),this.emitLogoutEventsOnlyEthlike(),[2]}}))}))},n.prototype.getCurrentUser=function(){return h(this,void 0,void 0,(function(){return l(this,(function(t){switch(t.label){case 0:return[4,this.internal.getCurrentUser()];case 1:return[2,t.sent()]}}))}))},n.prototype.isLoggedIn=function(){return h(this,void 0,void 0,(function(){return l(this,(function(t){switch(t.label){case 0:return[4,this.internal.isLoggedIn()];case 1:return[2,t.sent()]}}))}))},n.prototype.getUserVerificationToken=function(){return h(this,void 0,void 0,(function(){return l(this,(function(t){switch(t.label){case 0:return[4,this.internal.getUserVerificationToken()];case 1:return[2,t.sent()]}}))}))},n}(),_=function(){function e(t){this.internal=t}return e.prototype.getPublicKeys=function(){return h(this,void 0,void 0,(function(){return l(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 r.HexString.ensure(t)}))]}}))}))},e.prototype.getAddresses=function(){return h(this,void 0,void 0,(function(){return l(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){var e=Uint8Array.from(t.substring(2).match(/.{1,2}/g).map((function(t){return parseInt(t,16)}))),i=new Uint8Array(e.length+1);i.set(e),i.set([0],e.length);var o=n.sha3_256.create();return o.update(i),r.HexString.fromUint8Array(o.digest())}))]}}))}))},e.prototype.signMultiAgentTransaction=function(e){return h(this,void 0,void 0,(function(){return l(this,(function(n){switch(n.label){case 0:return[4,this.internal.sendRpc({method:t.JsonRpcMethod.aptos_signMultiAgentTransaction,params:[e.raw_txn.sender.address,r.BCS.bcsToBytes(e)]})];case 1:return[2,n.sent()]}}))}))},e.prototype.signMessage=function(e){return h(this,void 0,void 0,(function(){var n,r;return l(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)]}}))}))},e.prototype.signAndSubmitTransaction=function(e,n){return h(this,void 0,void 0,(function(){var r;return l(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()}]}}))}))},e.prototype.signTransaction=function(e,n){return h(this,void 0,void 0,(function(){var r,i;return l(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)]}}))}))},e}(),b=function(){function t(t){this.internal=t}return t.prototype.getProvider=function(){return new _(this.internal)},t}(),T=function(){function e(t){this.internal=t}return e.prototype.connect=function(e){return h(this,void 0,void 0,(function(){return l(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 h(this,void 0,void 0,(function(){return l(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}(),A=function(){function n(t){this.internal=t}return n.prototype.getPublicKeys=function(){return h(this,void 0,void 0,(function(){return l(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")))}))]}}))}))},n.prototype.getBalance=function(n,r){return h(this,void 0,void 0,(function(){var i;return l(this,(function(o){switch(o.label){case 0:return t.assertArgument(n,"string"==typeof n,"address"),t.assertArgument(r,"string"==typeof r,"contractAddress",!1),[4,this.internal.sendRpc({method:t.JsonRpcMethod.near_get_balance,params:[n,r]})];case 1:return i=o.sent(),[2,e.BigNumber.from(i)]}}))}))},n.prototype.signAndSendTransaction=function(t){return h(this,void 0,void 0,(function(){var e;return l(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()]}}))}))},n}(),S=function(){function t(t){this.internal=t}return t.prototype.getProvider=function(){return new A(this.internal)},t}(),O=function(){function n(t){this.internal=t}return n.prototype.getPublicKeys=function(){return h(this,void 0,void 0,(function(){return l(this,(function(n){switch(n.label){case 0:return[4,this.internal.getAddresses(t.Blockchain.SOLANA)];case 1:return[2,n.sent().map((function(t){return new o.PublicKey(e.ethers.utils.base58.decode(t))}))]}}))}))},n.prototype.signAndSendTransaction=function(t){return h(this,void 0,void 0,(function(){var e;return l(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()]}}))}))},n}(),M=function(){function t(t){this.internal=t}return t.prototype.getProvider=function(){return new O(this.internal)},t}(),R={display:"none",position:"fixed",top:"0",right:"0",width:"100%",height:"100%",borderRadius:"0",border:"none",zIndex:"2147483647"};var B=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}},L=function(){function e(t,e,n,r,i){void 0===i&&(i={type:"toast"});var o,s=this;this._ready=new B,this.requestIndex=0,this.activeElement=null,this._blockchain=e,this._env=n,this.iframeUrl=r;var a=Math.random().toString();if(this.randomPrefix=a.substring(a.length-6),document.getElementById("face-iframe"))throw new Error("Face is already initialized, Face can be initialized once.");window.addEventListener("message",(function(t){return h(s,void 0,void 0,(function(){return l(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 c=null!==(o="1.10.12")?o:"";this._iframe=new Promise((function(o){var s=function(){if(!document.getElementById("face-iframe")){var s=document.createElement("iframe");s.id="face-iframe",s.title="Secure Modal",s.src=new URL("".concat(r,"?api_key=").concat(t,"&blockchain=").concat(e,"&env=").concat(n,"&version=").concat(c,"&type=").concat("web","&notification=").concat(null==i?void 0:i.type)).href,s.allow="clipboard-read; clipboard-write",function(t){for(var e=0,n=Object.entries(R);e<n.length;e++){var r=n[e],i=r[0],o=r[1];t.style[i]=o}}(s),document.body.appendChild(s),o(s)}};["loaded","interactive","complete"].includes(document.readyState)?s():window.addEventListener("load",s,!1)}))}return e.prototype.sendChildMessage=function(e){var n,r;return h(this,void 0,void 0,(function(){var i;return l(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 h(this,void 0,void 0,(function(){var n;return l(this,(function(r){switch(r.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];case t.JsonRpcMethod.face_showToast:return[3,6]}return[3,7];case 1:return this._ready.complete(),[3,7];case 2:return[4,this.showOverlay()];case 3:case 5:return r.sent(),[3,7];case 4:return[4,this.hideOverlay()];case 6:return n=new CustomEvent("face-toast",{detail:null==e?void 0:e.result}),window.dispatchEvent(n),[3,7];case 7:return[2]}}))}))},e.prototype.ready=function(){return h(this,void 0,void 0,(function(){var t=this;return l(this,(function(e){return[2,new Promise((function(e){return h(t,void 0,void 0,(function(){return l(this,(function(t){return this._ready.isCompleted()?(e(),[2]):(this._ready.add((function(){e()})),[2])}))}))}))]}))}))},e.prototype.showOverlay=function(){return h(this,void 0,void 0,(function(){var t;return l(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 h(this,void 0,void 0,(function(){return l(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 C(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:case t.Network.YOOLDO_VERSE:return!0;default:return!1}}function P(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;case t.Network.PSM_TESTNET_DEV:return t.Blockchain.PSM_DEV;case t.Network.PSM_TESTNET_TEST:return t.Blockchain.PSM_TEST;case t.Network.HOME_VERSE:case t.Network.HOME_VERSE_TESTNET:return t.Blockchain.HOME_VERSE;case t.Network.YOOLDO_VERSE:case t.Network.SAND_VERSE:return t.Blockchain.YOOLDO_VERSE;case t.Network.OASYS:case t.Network.OASYS_TESTNET:return t.Blockchain.OASYS;default:return t.Blockchain.ETHEREUM}}function I(e){if("string"==typeof e&&/^0x[0-9A-Fa-f]*$/.test(e)){var n=parseInt(e,16);if(t.NetworkChainIdMap.hasOwnProperty(n))return t.NetworkChainIdMap[n];throw new Error("Invalid chainId: ".concat(n))}if("number"==typeof e){if(t.NetworkChainIdMap.hasOwnProperty(e))return t.NetworkChainIdMap[e];throw new Error("Invalid chainId: ".concat(e))}if(Object.values(t.Network).includes(e))return e;throw new Error("Invalid network parameter")}e.BigNumber.from(1e5).toHexString();var x=function(){function n(e){var n=e.apiKey,r=e.network,i=e.env,o=e.iframeUrl,s=e.face,a=e.notificationOptions;this.network=r||t.Network.ETHEREUM;var c=P(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&&e!==t.Network.PSM_TESTNET_DEV&&e!==t.Network.PSM_TESTNET_TEST&&e!==t.Network.HOME_VERSE_TESTNET&&e!==t.Network.SAND_VERSE&&e!==t.Network.OASYS_TESTNET?t.Env.ProdMainnet:t.Env.ProdTest}(r),this.iframe=new L(n,c,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),a),this.face=s,this.iframeUrl=o}return n.prototype.getAddresses=function(e){return h(this,void 0,void 0,(function(){var n,r;return l(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"))]}}))}))},n.prototype.estimateGas=function(t){return h(this,void 0,void 0,(function(){return l(this,(function(t){return[2,0]}))}))},n.prototype.getBalance=function(n,r){return h(this,void 0,void 0,(function(){var i,o,s,a;return l(this,(function(c){switch(c.label){case 0:return r?[4,this.encodeData(["function balanceOf(address owner) view returns (uint256)"],"balanceOf",[n])]:[3,3];case 1:return i=c.sent(),[4,this.sendRpc({method:t.JsonRpcMethod.eth_call,params:[{to:r,data:i},"latest"]})];case 2:return o=c.sent(),[2,e.BigNumber.from(o)];case 3:return a=(s=e.BigNumber).from,[4,this.sendRpc({method:t.JsonRpcMethod.eth_getBalance,params:[n,"latest"]})];case 4:return[2,a.apply(s,[c.sent()])]}}))}))},n.prototype.ownerOf=function(e,n){return h(this,void 0,void 0,(function(){var r;return l(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()]}}))}))},n.prototype.logout=function(){return h(this,void 0,void 0,(function(){var e;return l(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]}}))}))},n.prototype.getCurrentUser=function(){return h(this,void 0,void 0,(function(){var e;return l(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()]}}))}))},n.prototype.isLoggedIn=function(){return h(this,void 0,void 0,(function(){var e;return l(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]}}))}))},n.prototype.ready=function(){return h(this,void 0,void 0,(function(){return l(this,(function(t){return[2,this.iframe.ready()]}))}))},n.prototype.loginWithCredential=function(e){return h(this,void 0,void 0,(function(){var n;return l(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()]}}))}))},n.prototype.directSocialLogin=function(e){return h(this,void 0,void 0,(function(){var n;return l(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()]}}))}))},n.prototype.getIdToken=function(e,n){return h(this,void 0,void 0,(function(){var r;return l(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()]}}))}))},n.prototype.loginWithIdToken=function(e){return h(this,void 0,void 0,(function(){var n;return l(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()]}}))}))},n.prototype.loginWithAccessToken=function(e){return h(this,void 0,void 0,(function(){var n;return l(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()]}}))}))},n.prototype.openWalletConnect=function(e,n){return h(this,void 0,void 0,(function(){var r;return l(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()]}}))}))},n.prototype.openHome=function(e){return h(this,void 0,void 0,(function(){var n,r,i;return l(this,(function(o){switch(o.label){case 0:if(this.iframe.throwExceptionUnsupportedBlockchain([t.Blockchain.SOLANA,t.Blockchain.NEAR]),n=C(this.network),(null==e?void 0:e.networks)&&e.networks.some((function(t){return C(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)]}}))}))},n.prototype.sendRpc=function(t){return h(this,void 0,void 0,(function(){var e;return l(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()]}}))}))},n.prototype.decodeData=function(t,n){return h(this,void 0,void 0,(function(){var r,i,o,s;return l(this,(function(a){return r=new e.ethers.utils.Interface(n),i=r.parseTransaction({data:t}),o=i.name,s=i.args,[2,{name:o,args:s}]}))}))},n.prototype.encodeData=function(t,n,r){return h(this,void 0,void 0,(function(){return l(this,(function(i){return[2,new e.ethers.utils.Interface(t).encodeFunctionData(n,r)]}))}))},n.prototype.switchNetwork=function(e){return h(this,void 0,void 0,(function(){var n,r,i;return l(this,(function(o){switch(o.label){case 0:return n=P(e),r={method:t.JsonRpcMethod.face_switchNetwork,params:[{blockchain:n}]},[4,this.sendRpc(r)];case 1:return i=o.sent(),this.network=e,this.face.setNetwork(e),this.iframe.setBlockchain(n),[2,i]}}))}))},n.prototype.boraIsConnected=function(e){return h(this,void 0,void 0,(function(){var n;return l(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,t.Blockchain.HOME_VERSE,t.Blockchain.YOOLDO_VERSE]),[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()]}}))}))},n.prototype.boraConnect=function(e){return h(this,void 0,void 0,(function(){var n;return l(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,t.Blockchain.HOME_VERSE,t.Blockchain.YOOLDO_VERSE]),[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()]}}))}))},n.prototype.getUserVerificationToken=function(){return h(this,void 0,void 0,(function(){var e,n;return l(this,(function(r){switch(r.label){case 0:return[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_getUserVerificationToken,params:[]})];case 1:return e=r.sent(),[4,this.iframe.waitForResponse(e)];case 2:return(n=r.sent())?[2,n]:[2,Promise.reject(new Error("get user verification token failed"))]}}))}))},n.prototype.getNetwork=function(){return this.network},n}(),U=function(e){function n(t){var n=e.call(this)||this;return n.internal=t,n}return u(n,e),n.prototype.request=function(e){return h(this,void 0,void 0,(function(){var n,r=this;return l(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.prototype.on=function(t,e){return E.on(t,e),this},n.prototype.emit=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return E.emit.apply(E,f([t],e,!1))},n.prototype.removeListener=function(t,e){return E.removeListener(t,e),this},n.prototype.off=function(t,e){return E.off(t,e),this},n}((function(){this.sendAsync=function(t,e){}})),J=function(){function e(t){this.internal=t}return e.prototype.close=function(){this.internal.iframe.hideOverlay()},e.prototype.home=function(e){var n;return h(this,void 0,void 0,(function(){return l(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}(),H=function(){function e(t){this.internal=t}return e.prototype.connectOpensea=function(e){return h(this,void 0,void 0,(function(){return l(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 h(this,void 0,void 0,(function(){return l(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}(),V=function(){function n(e){var n=this,r=e.apiKey,i=e.network,o=e.notificationOptions,s=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","notificationOptions"]);this.getAddresses=function(e){return h(n,void 0,void 0,(function(){return l(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 h(n,void 0,void 0,(function(){var t;return l(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 a=I(i);t.assert(t.isSupportedNetwork(a),t.unsupportedChainError),this.network=a,this.internal=new x({apiKey:r,network:a,env:null==s?void 0:s.env,iframeUrl:null==s?void 0:s.iframeUrl,notificationOptions:o,face:this}),this.auth=new N(this.internal),this.wc=new H(this.internal),this.solana=new M(this.internal),this.near=new S(this.internal),this.wallet=new J(this.internal),this.bora=new T(this.internal),this.aptos=new b(this.internal)}return n.prototype.ready=function(){return h(this,void 0,void 0,(function(){return l(this,(function(t){return[2,this.internal.ready()]}))}))},n.prototype.getEthLikeProvider=function(){return t.assert(t.isEthlikeBlockchain(t.networkToBlockchain(this.network)),t.unsupportedChainError),new U(this.internal)},n.prototype.switchNetwork=function(n){return h(this,void 0,void 0,(function(){var r,i,o;return l(this,(function(s){switch(s.label){case 0:return r=I(n),t.assertArgument(n,t.isSupportedNetwork(r),"network"),[4,this.internal.switchNetwork(r)];case 1:return i=s.sent(),t.isEthlikeNetwork(this.network)&&(o=function(n){return t.isEthlikeNetwork(n)?e.ethers.utils.hexlify(t.NetworkChainIdMap[n]):0}(r),E.emit("chainChanged",o)),[2,i]}}))}))},n}();Object.defineProperty(exports,"Network",{enumerable:!0,get:function(){return t.Network}}),exports.Face=V;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@haechi-labs/face-types"),t=require("ethers"),n=require("@noble/hashes/sha3"),r=require("aptos"),i=require("near-api-js"),o=require("@solana/web3.js");function s(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var a=s(i),c=function(e,t){return c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},c(e,t)};function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}c(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function h(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))}function l(e,t){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=t.call(e,s)}catch(e){a=[6,e],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])}}}function f(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}function d(){}function p(){p.init.call(this)}function v(e){return void 0===e._maxListeners?p.defaultMaxListeners:e._maxListeners}function w(e,t,n,r){var i,o,s,a;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((o=e._events)?(o.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),o=e._events),s=o[t]):(o=e._events=new d,e._eventsCount=0),s){if("function"==typeof s?s=o[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),!s.warned&&(i=v(e))&&i>0&&s.length>i){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=s.length,a=c,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=n,++e._eventsCount;return e}function m(e,t,n){var r=!1;function i(){e.removeListener(t,i),r||(r=!0,n.apply(e,arguments))}return i.listener=n,i}function y(e){var t=this._events;if(t){var n=t[e];if("function"==typeof n)return 1;if(n)return n.length}return 0}function g(e,t){for(var n=new Array(t);t--;)n[t]=e[t];return n}function E(e,t,n){try{Reflect.apply(e,t,n)}catch(e){setTimeout((function(){throw e}))}}d.prototype=Object.create(null),p.EventEmitter=p,p.usingDomains=!1,p.prototype.domain=void 0,p.prototype._events=void 0,p.prototype._maxListeners=void 0,p.defaultMaxListeners=10,p.init=function(){this.domain=null,p.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new d,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},p.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},p.prototype.getMaxListeners=function(){return v(this)},p.prototype.emit=function(e){var t,n,r,i,o,s,a,c="error"===e;if(s=this._events)c=c&&null==s.error;else if(!c)return!1;if(a=this.domain,c){if(t=arguments[1],!a){if(t instanceof Error)throw t;var u=new Error('Uncaught, unspecified "error" event. ('+t+")");throw u.context=t,u}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(n=s[e]))return!1;var h="function"==typeof n;switch(r=arguments.length){case 1:!function(e,t,n){if(t)e.call(n);else for(var r=e.length,i=g(e,r),o=0;o<r;++o)i[o].call(n)}(n,h,this);break;case 2:!function(e,t,n,r){if(t)e.call(n,r);else for(var i=e.length,o=g(e,i),s=0;s<i;++s)o[s].call(n,r)}(n,h,this,arguments[1]);break;case 3:!function(e,t,n,r,i){if(t)e.call(n,r,i);else for(var o=e.length,s=g(e,o),a=0;a<o;++a)s[a].call(n,r,i)}(n,h,this,arguments[1],arguments[2]);break;case 4:!function(e,t,n,r,i,o){if(t)e.call(n,r,i,o);else for(var s=e.length,a=g(e,s),c=0;c<s;++c)a[c].call(n,r,i,o)}(n,h,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(r-1),o=1;o<r;o++)i[o-1]=arguments[o];!function(e,t,n,r){if(t)e.apply(n,r);else for(var i=e.length,o=g(e,i),s=0;s<i;++s)o[s].apply(n,r)}(n,h,this,i)}return!0},p.prototype.addListener=function(e,t){return w(this,e,t,!1)},p.prototype.on=p.prototype.addListener,p.prototype.prependListener=function(e,t){return w(this,e,t,!0)},p.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,m(this,e,t)),this},p.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,m(this,e,t)),this},p.prototype.removeListener=function(e,t){var n,r,i,o,s;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(r=this._events))return this;if(!(n=r[e]))return this;if(n===t||n.listener&&n.listener===t)0==--this._eventsCount?this._events=new d:(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,o=n.length;o-- >0;)if(n[o]===t||n[o].listener&&n[o].listener===t){s=n[o].listener,i=o;break}if(i<0)return this;if(1===n.length){if(n[0]=void 0,0==--this._eventsCount)return this._events=new d,this;delete r[e]}else!function(e,t){for(var n=t,r=n+1,i=e.length;r<i;n+=1,r+=1)e[n]=e[r];e.pop()}(n,i);r.removeListener&&this.emit("removeListener",e,s||t)}return this},p.prototype.removeAllListeners=function(e){var t,n;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=new d,this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=new d:delete n[e]),this;if(0===arguments.length){for(var r,i=Object.keys(n),o=0;o<i.length;++o)"removeListener"!==(r=i[o])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=new d,this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},p.prototype.listeners=function(e){var t,n=this._events;return n&&(t=n[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(t):[]},p.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):y.call(e,t)},p.prototype.listenerCount=y,p.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var k=new(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return u(t,e),t.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var r="error"===e,i=this._events;if(void 0!==i)r=r&&void 0===i.error;else if(!r)return!1;if(r){var o=void 0;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var s=new Error("Unhandled error.".concat(o?" (".concat(o.message,")"):""));throw s.context=o,s}var a=i[e];if(void 0===a)return!1;if("function"==typeof a)E(a,this,t);else for(var c=a.length,u=function(e){for(var t=e.length,n=new Array(t),r=0;r<t;r+=1)n[r]=e[r];return n}(a),h=0;h<c;h+=1)E(u[h],this,t);return!0},t}(p)),N=function(){function n(e){this.internal=e}return n.prototype.emitLoginEventsOnlyEthlike=function(){if(e.isEthlikeNetwork(this.internal.getNetwork())){var n=t.ethers.utils.hexlify(e.NetworkChainIdMap[this.internal.getNetwork()]);k.emit("connect",{chainId:n})}},n.prototype.emitLogoutEventsOnlyEthlike=function(){if(e.isEthlikeNetwork(this.internal.getNetwork())){k.emit("disconnect",{name:"disconnect",code:4900,message:"face wallet logout"})}},n.prototype.login=function(t){return h(this,void 0,void 0,(function(){var n;return l(this,(function(r){switch(r.label){case 0:return e.assertArgument(t,Array.isArray(t)&&t.length>0&&f([],t,!0).every((function(t){return Object.values(e.LoginProvider).includes(t)})),"providers",!1),[4,this.internal.loginWithCredential(t)];case 1:return n=r.sent(),this.emitLoginEventsOnlyEthlike(),[2,n]}}))}))},n.prototype.directSocialLogin=function(t){return h(this,void 0,void 0,(function(){var n;return l(this,(function(r){switch(r.label){case 0:return e.assertArgument(t,"string"==typeof t,"provider"),[4,this.internal.directSocialLogin(t)];case 1:return n=r.sent(),this.emitLoginEventsOnlyEthlike(),[2,n]}}))}))},n.prototype.getIdToken=function(t,n){return h(this,void 0,void 0,(function(){return l(this,(function(r){return e.assertArgument(t,"string"==typeof t,"provider"),e.assertArgument(n,"string"==typeof n,"accessToken"),[2,this.internal.getIdToken(t,n)]}))}))},n.prototype.loginWithIdToken=function(t){return h(this,void 0,void 0,(function(){var n;return l(this,(function(r){switch(r.label){case 0:return e.assertArgument(t,t.idToken&&t.sig,"loginWithIdTokenRequest"),[4,this.internal.loginWithIdToken(t)];case 1:return n=r.sent(),this.emitLoginEventsOnlyEthlike(),[2,n]}}))}))},n.prototype.loginWithAccessToken=function(t){return h(this,void 0,void 0,(function(){var n;return l(this,(function(r){switch(r.label){case 0:return e.assertArgument(t,t.accessToken&&t.sig,"loginWithIdTokenRequest"),[4,this.internal.loginWithAccessToken(t)];case 1:return n=r.sent(),this.emitLoginEventsOnlyEthlike(),[2,n]}}))}))},n.prototype.logout=function(){return h(this,void 0,void 0,(function(){return l(this,(function(e){switch(e.label){case 0:return[4,this.internal.logout()];case 1:return e.sent(),this.emitLogoutEventsOnlyEthlike(),[2]}}))}))},n.prototype.getCurrentUser=function(){return h(this,void 0,void 0,(function(){return l(this,(function(e){switch(e.label){case 0:return[4,this.internal.getCurrentUser()];case 1:return[2,e.sent()]}}))}))},n.prototype.isLoggedIn=function(){return h(this,void 0,void 0,(function(){return l(this,(function(e){switch(e.label){case 0:return[4,this.internal.isLoggedIn()];case 1:return[2,e.sent()]}}))}))},n.prototype.getUserVerificationToken=function(){return h(this,void 0,void 0,(function(){return l(this,(function(e){switch(e.label){case 0:return[4,this.internal.getUserVerificationToken()];case 1:return[2,e.sent()]}}))}))},n}(),_=function(){function t(e){this.internal=e}return t.prototype.getPublicKeys=function(){return h(this,void 0,void 0,(function(){return l(this,(function(t){switch(t.label){case 0:return[4,this.internal.getAddresses(e.Blockchain.APTOS)];case 1:return[2,t.sent().map((function(e){return r.HexString.ensure(e)}))]}}))}))},t.prototype.getAddresses=function(){return h(this,void 0,void 0,(function(){return l(this,(function(t){switch(t.label){case 0:return[4,this.internal.getAddresses(e.Blockchain.APTOS)];case 1:return[2,t.sent().map((function(e){var t=Uint8Array.from(e.substring(2).match(/.{1,2}/g).map((function(e){return parseInt(e,16)}))),i=new Uint8Array(t.length+1);i.set(t),i.set([0],t.length);var o=n.sha3_256.create();return o.update(i),r.HexString.fromUint8Array(o.digest())}))]}}))}))},t.prototype.signMultiAgentTransaction=function(t){return h(this,void 0,void 0,(function(){return l(this,(function(n){switch(n.label){case 0:return[4,this.internal.sendRpc({method:e.JsonRpcMethod.aptos_signMultiAgentTransaction,params:[t.raw_txn.sender.address,r.BCS.bcsToBytes(t)]})];case 1:return[2,n.sent()]}}))}))},t.prototype.signMessage=function(t){return h(this,void 0,void 0,(function(){var n,r;return l(this,(function(i){switch(i.label){case 0:return n=Buffer.from(JSON.stringify(t)),[4,this.internal.sendRpc({method:e.JsonRpcMethod.aptos_signMessage,params:[n]})];case 1:return r=i.sent(),[2,JSON.parse(r)]}}))}))},t.prototype.signAndSubmitTransaction=function(t,n){return h(this,void 0,void 0,(function(){var r;return l(this,(function(i){switch(i.label){case 0:return[4,this.internal.getAddresses(e.Blockchain.APTOS)];case 1:return r=i.sent()[0],[4,this.internal.sendRpc({method:e.JsonRpcMethod.aptos_signAndSubmitTransaction,params:[Buffer.from(r),Buffer.from(JSON.stringify(t)),n]})];case 2:return[2,{hash:i.sent()}]}}))}))},t.prototype.signTransaction=function(t,n){return h(this,void 0,void 0,(function(){var r,i;return l(this,(function(o){switch(o.label){case 0:return[4,this.internal.getAddresses(e.Blockchain.APTOS)];case 1:return r=o.sent()[0],[4,this.internal.sendRpc({method:e.JsonRpcMethod.aptos_signTransaction,params:[Buffer.from(r),Buffer.from(JSON.stringify(t)),n]})];case 2:return i=o.sent(),[2,JSON.parse(i)]}}))}))},t}(),b=function(){function e(e){this.internal=e}return e.prototype.getProvider=function(){return new _(this.internal)},e}(),T=function(){function t(e){this.internal=e}return t.prototype.connect=function(t){return h(this,void 0,void 0,(function(){return l(this,(function(n){switch(n.label){case 0:return e.assertArgument(t,t.bappUsn&&t.signature,"request"),[4,this.internal.boraConnect(t)];case 1:return[2,n.sent()]}}))}))},t.prototype.isConnected=function(t){return h(this,void 0,void 0,(function(){return l(this,(function(n){switch(n.label){case 0:return e.assertArgument(t,"string"==typeof t,"bappUsn"),[4,this.internal.boraIsConnected(t)];case 1:return[2,n.sent()]}}))}))},t}(),A=function(){function n(e){this.internal=e}return n.prototype.getPublicKeys=function(){return h(this,void 0,void 0,(function(){return l(this,(function(t){switch(t.label){case 0:return[4,this.internal.getAddresses(e.Blockchain.NEAR)];case 1:return[2,t.sent().map((function(e){return a.utils.PublicKey.fromString(a.utils.serialize.base_encode(Buffer.from(e,"hex")))}))]}}))}))},n.prototype.getBalance=function(n,r){return h(this,void 0,void 0,(function(){var i;return l(this,(function(o){switch(o.label){case 0:return e.assertArgument(n,"string"==typeof n,"address"),e.assertArgument(r,"string"==typeof r,"contractAddress",!1),[4,this.internal.sendRpc({method:e.JsonRpcMethod.near_get_balance,params:[n,r]})];case 1:return i=o.sent(),[2,t.BigNumber.from(i)]}}))}))},n.prototype.signAndSendTransaction=function(e){return h(this,void 0,void 0,(function(){var t;return l(this,(function(n){switch(n.label){case 0:return t={serializedHex:Buffer.from(a.utils.serialize.serialize(a.transactions.SCHEMA,e)).toString("hex")},[4,this.internal.sendRpc({method:"near_broadcast_tx_async",params:[t]})];case 1:return[2,n.sent()]}}))}))},n}(),S=function(){function e(e){this.internal=e}return e.prototype.getProvider=function(){return new A(this.internal)},e}(),O=function(){function n(e){this.internal=e}return n.prototype.getPublicKeys=function(){return h(this,void 0,void 0,(function(){return l(this,(function(n){switch(n.label){case 0:return[4,this.internal.getAddresses(e.Blockchain.SOLANA)];case 1:return[2,n.sent().map((function(e){return new o.PublicKey(t.ethers.utils.base58.decode(e))}))]}}))}))},n.prototype.signAndSendTransaction=function(e){return h(this,void 0,void 0,(function(){var t;return l(this,(function(n){switch(n.label){case 0:return t={serializedHex:e.serialize({requireAllSignatures:!1,verifySignatures:!1}).toString("hex")},[4,this.internal.sendRpc({method:"solana_sendTransaction",params:[t]})];case 1:return[2,n.sent()]}}))}))},n}(),R=function(){function e(e){this.internal=e}return e.prototype.getProvider=function(){return new O(this.internal)},e}(),M={display:"none",position:"fixed",top:"0",right:"0",width:"100%",height:"100%",borderRadius:"0",border:"none",zIndex:"2147483647"};var B=function(){var e=this;this._isCompleted=!1,this._eventListeners=Array(),this.complete=function(){e._isCompleted=!0,e._eventListeners.forEach((function(e){return e()}))},this.add=function(t){e._eventListeners.push(t)},this.isCompleted=function(){return e._isCompleted}},L=function(){function t(e,t,n,r,i){void 0===i&&(i={type:"toast"});var o,s=this;this._ready=new B,this.requestIndex=0,this.activeElement=null,this._blockchain=t,this._env=n,this.iframeUrl=r;var a=Math.random().toString();if(this.randomPrefix=a.substring(a.length-6),document.getElementById("face-iframe"))throw new Error("Face is already initialized, Face can be initialized once.");window.addEventListener("message",(function(e){return h(s,void 0,void 0,(function(){return l(this,(function(t){switch(t.label){case 0:return e.origin!==r?[2]:[4,this.processMessage(e.data)];case 1:return t.sent(),[2]}}))}))}));var c=null!==(o="1.10.13")?o:"";this._iframe=new Promise((function(o){var s=function(){if(!document.getElementById("face-iframe")){var s=document.createElement("iframe");s.id="face-iframe",s.title="Secure Modal",s.src=new URL("".concat(r,"?api_key=").concat(e,"&blockchain=").concat(t,"&env=").concat(n,"&version=").concat(c,"&type=").concat("web","&notification=").concat(null==i?void 0:i.type)).href,s.allow="clipboard-read; clipboard-write",function(e){for(var t=0,n=Object.entries(M);t<n.length;t++){var r=n[t],i=r[0],o=r[1];e.style[i]=o}}(s),document.body.appendChild(s),o(s)}};["loaded","interactive","complete"].includes(document.readyState)?s():window.addEventListener("load",s,!1)}))}return t.prototype.sendChildMessage=function(t){var n,r;return h(this,void 0,void 0,(function(){var i;return l(this,(function(o){switch(o.label){case 0:return[4,this.ready()];case 1:return o.sent(),this.requestIndex+=1,i=t.id?"".concat(t.id):"".concat(this.randomPrefix,"-").concat(this.requestIndex),t.id=i,t.from=e.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(t,"*"),[2,i]}}))}))},t.prototype.waitForResponse=function(e){return new Promise((function(t,n){var r=function(i){var o=i.data;e&&o.id!==e||(window.removeEventListener("message",r),o.error?n(o.error):t(o.result))};window.addEventListener("message",r)}))},t.prototype.processMessage=function(t){return h(this,void 0,void 0,(function(){var n;return l(this,(function(r){switch(r.label){case 0:switch(t.method){case e.JsonRpcMethod.face_ready:return[3,1];case e.JsonRpcMethod.face_openIframe:return[3,2];case e.JsonRpcMethod.face_closeIframe:return[3,4];case e.JsonRpcMethod.face_showToast:return[3,6]}return[3,7];case 1:return this._ready.complete(),[3,7];case 2:return[4,this.showOverlay()];case 3:case 5:return r.sent(),[3,7];case 4:return[4,this.hideOverlay()];case 6:return n=new CustomEvent("face-toast",{detail:null==t?void 0:t.result}),window.dispatchEvent(n),[3,7];case 7:return[2]}}))}))},t.prototype.ready=function(){return h(this,void 0,void 0,(function(){var e=this;return l(this,(function(t){return[2,new Promise((function(t){return h(e,void 0,void 0,(function(){return l(this,(function(e){return this._ready.isCompleted()?(t(),[2]):(this._ready.add((function(){t()})),[2])}))}))}))]}))}))},t.prototype.showOverlay=function(){return h(this,void 0,void 0,(function(){var e;return l(this,(function(t){switch(t.label){case 0:return[4,this.ready()];case 1:return t.sent(),[4,this._iframe];case 2:return(e=t.sent()).style.display="block",this.activeElement=document.activeElement,e.focus(),[2]}}))}))},t.prototype.hideOverlay=function(){var e;return h(this,void 0,void 0,(function(){return l(this,(function(t){switch(t.label){case 0:return[4,this.ready()];case 1:return t.sent(),[4,this._iframe];case 2:return t.sent().style.display="none",(null===(e=this.activeElement)||void 0===e?void 0:e.focus)&&this.activeElement.focus(),this.activeElement=null,[2]}}))}))},t.prototype.setBlockchain=function(e){this._blockchain=e},t.prototype.throwExceptionUnsupportedBlockchain=function(t){if(t.includes(this._blockchain))throw e.unsupportedChainError()},t.prototype.getBlockchain=function(){return this._blockchain},t}();function C(t){switch(t){case e.Network.ETHEREUM:case e.Network.POLYGON:case e.Network.BNB_SMART_CHAIN:case e.Network.KLAYTN:case e.Network.SOLANA:case e.Network.BORA:case e.Network.NEAR:case e.Network.APTOS:case e.Network.MEVERSE:case e.Network.PSM:case e.Network.YOOLDO_VERSE:return!0;default:return!1}}function P(t){switch(t){case e.Network.ETHEREUM:case e.Network.GOERLI:return e.Blockchain.ETHEREUM;case e.Network.POLYGON:case e.Network.MUMBAI:return e.Blockchain.POLYGON;case e.Network.BNB_SMART_CHAIN:case e.Network.BNB_SMART_CHAIN_TESTNET:return e.Blockchain.BNB_SMART_CHAIN;case e.Network.KLAYTN:case e.Network.BAOBAB:return e.Blockchain.KLAYTN;case e.Network.SOLANA:case e.Network.SOLANA_DEVNET:return e.Blockchain.SOLANA;case e.Network.BORA:case e.Network.BORA_TESTNET:return e.Blockchain.BORA;case e.Network.NEAR:case e.Network.NEAR_TESTNET:return e.Blockchain.NEAR;case e.Network.APTOS:case e.Network.APTOS_TESTNET:return e.Blockchain.APTOS;case e.Network.MEVERSE:case e.Network.MEVERSE_TESTNET:return e.Blockchain.MEVERSE;case e.Network.PSM:case e.Network.PSM_TESTNET:return e.Blockchain.PSM;case e.Network.PSM_TESTNET_DEV:return e.Blockchain.PSM_DEV;case e.Network.PSM_TESTNET_TEST:return e.Blockchain.PSM_TEST;case e.Network.HOME_VERSE:case e.Network.HOME_VERSE_TESTNET:return e.Blockchain.HOME_VERSE;case e.Network.YOOLDO_VERSE:case e.Network.SAND_VERSE:return e.Blockchain.YOOLDO_VERSE;case e.Network.OASYS:case e.Network.OASYS_TESTNET:return e.Blockchain.OASYS;default:return e.Blockchain.ETHEREUM}}function I(t){if("string"==typeof t&&/^0x[0-9A-Fa-f]*$/.test(t)){var n=parseInt(t,16);if(e.NetworkChainIdMap.hasOwnProperty(n))return e.NetworkChainIdMap[n];throw new e.FaceError({message:"Invalid chainId: ".concat(n),code:e.FaceErrorCode.UNSUPPORTED_CHAIN})}if("number"==typeof t){if(e.NetworkChainIdMap.hasOwnProperty(t))return e.NetworkChainIdMap[t];throw new e.FaceError({message:"Invalid chainId: ".concat(t),code:e.FaceErrorCode.UNSUPPORTED_CHAIN})}if(Object.values(e.Network).includes(t))return t;throw new e.FaceError({message:"Invalid network parameter: ".concat(t),code:e.FaceErrorCode.UNSUPPORTED_CHAIN})}t.BigNumber.from(1e5).toHexString();var x=function(){function n(t){var n=t.apiKey,r=t.network,i=t.env,o=t.iframeUrl,s=t.face,a=t.notificationOptions;this.network=r||e.Network.ETHEREUM;var c=P(this.network);this.env=null!=i?i:function(t){return!t||t!==e.Network.GOERLI&&t!==e.Network.MUMBAI&&t!==e.Network.BAOBAB&&t!==e.Network.BNB_SMART_CHAIN_TESTNET&&t!==e.Network.BORA_TESTNET&&t!==e.Network.SOLANA_DEVNET&&t!==e.Network.NEAR_TESTNET&&t!==e.Network.APTOS_TESTNET&&t!==e.Network.MEVERSE_TESTNET&&t!==e.Network.PSM_TESTNET&&t!==e.Network.PSM_TESTNET_DEV&&t!==e.Network.PSM_TESTNET_TEST&&t!==e.Network.HOME_VERSE_TESTNET&&t!==e.Network.SAND_VERSE&&t!==e.Network.OASYS_TESTNET?e.Env.ProdMainnet:e.Env.ProdTest}(r),this.iframe=new L(n,c,this.env,function(t,n){if(null!=n)return n;switch(t){case e.Env.Local:return"http://localhost:3333";case e.Env.Dev:return"https://app.dev.facewallet.xyz";case e.Env.StageTest:return"https://app.stage-test.facewallet.xyz";case e.Env.ProdTest:return"https://app.test.facewallet.xyz";case e.Env.StageMainnet:return"https://app.stage.facewallet.xyz";case e.Env.ProdMainnet:default:return"https://app.facewallet.xyz"}}(this.env,o),a),this.face=s,this.iframeUrl=o}return n.prototype.getAddresses=function(t){return h(this,void 0,void 0,(function(){var n,r;return l(this,(function(i){switch(i.label){case 0:return[4,this.iframe.sendChildMessage({method:e.JsonRpcMethod.face_accounts,params:[t]})];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"))]}}))}))},n.prototype.estimateGas=function(e){return h(this,void 0,void 0,(function(){return l(this,(function(e){return[2,0]}))}))},n.prototype.getBalance=function(n,r){return h(this,void 0,void 0,(function(){var i,o,s,a;return l(this,(function(c){switch(c.label){case 0:return r?[4,this.encodeData(["function balanceOf(address owner) view returns (uint256)"],"balanceOf",[n])]:[3,3];case 1:return i=c.sent(),[4,this.sendRpc({method:e.JsonRpcMethod.eth_call,params:[{to:r,data:i},"latest"]})];case 2:return o=c.sent(),[2,t.BigNumber.from(o)];case 3:return a=(s=t.BigNumber).from,[4,this.sendRpc({method:e.JsonRpcMethod.eth_getBalance,params:[n,"latest"]})];case 4:return[2,a.apply(s,[c.sent()])]}}))}))},n.prototype.ownerOf=function(t,n){return h(this,void 0,void 0,(function(){var r;return l(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:e.JsonRpcMethod.eth_call,params:[{to:t,data:r},"latest"]})];case 2:return[2,("0x"+i.sent().substring(26)).toLowerCase()]}}))}))},n.prototype.logout=function(){return h(this,void 0,void 0,(function(){var t;return l(this,(function(n){switch(n.label){case 0:return[4,this.iframe.sendChildMessage({method:e.JsonRpcMethod.face_logOut})];case 1:return t=n.sent(),[4,this.iframe.waitForResponse(t)];case 2:return n.sent(),[2]}}))}))},n.prototype.getCurrentUser=function(){return h(this,void 0,void 0,(function(){var t;return l(this,(function(n){switch(n.label){case 0:return[4,this.iframe.sendChildMessage({method:e.JsonRpcMethod.face_currentUser})];case 1:return t=n.sent(),[4,this.iframe.waitForResponse(t)];case 2:return[2,n.sent()]}}))}))},n.prototype.isLoggedIn=function(){return h(this,void 0,void 0,(function(){var t;return l(this,(function(n){switch(n.label){case 0:return[4,this.iframe.sendChildMessage({method:e.JsonRpcMethod.face_loggedIn})];case 1:return n.sent(),[4,this.iframe.waitForResponse()];case 2:return(t=n.sent())?[2,t]:[2,!1]}}))}))},n.prototype.ready=function(){return h(this,void 0,void 0,(function(){return l(this,(function(e){return[2,this.iframe.ready()]}))}))},n.prototype.loginWithCredential=function(t){return h(this,void 0,void 0,(function(){var n;return l(this,(function(r){switch(r.label){case 0:return[4,this.iframe.sendChildMessage({method:e.JsonRpcMethod.face_logInSignUp,params:t})];case 1:return n=r.sent(),[4,this.iframe.waitForResponse(n)];case 2:return[2,r.sent()]}}))}))},n.prototype.directSocialLogin=function(t){return h(this,void 0,void 0,(function(){var n;return l(this,(function(r){switch(r.label){case 0:return[4,this.iframe.sendChildMessage({method:e.JsonRpcMethod.face_directSocialLogin,params:[t]})];case 1:return n=r.sent(),[4,this.iframe.waitForResponse(n)];case 2:return[2,r.sent()]}}))}))},n.prototype.getIdToken=function(t,n){return h(this,void 0,void 0,(function(){var r;return l(this,(function(i){switch(i.label){case 0:return[4,this.iframe.sendChildMessage({method:e.JsonRpcMethod.face_getIdToken,params:[t,n]})];case 1:return r=i.sent(),[4,this.iframe.waitForResponse(r)];case 2:return[2,i.sent()]}}))}))},n.prototype.loginWithIdToken=function(t){return h(this,void 0,void 0,(function(){var n;return l(this,(function(r){switch(r.label){case 0:return[4,this.iframe.sendChildMessage({method:e.JsonRpcMethod.face_loginWithIdToken,params:[t]})];case 1:return n=r.sent(),[4,this.iframe.waitForResponse(n)];case 2:return[2,r.sent()]}}))}))},n.prototype.loginWithAccessToken=function(t){return h(this,void 0,void 0,(function(){var n;return l(this,(function(r){switch(r.label){case 0:return[4,this.iframe.sendChildMessage({method:e.JsonRpcMethod.face_loginWithAccessToken,params:[t]})];case 1:return n=r.sent(),[4,this.iframe.waitForResponse(n)];case 2:return[2,r.sent()]}}))}))},n.prototype.openWalletConnect=function(t,n){return h(this,void 0,void 0,(function(){var r;return l(this,(function(i){switch(i.label){case 0:return this.iframe.throwExceptionUnsupportedBlockchain([e.Blockchain.APTOS,e.Blockchain.NEAR,e.Blockchain.SOLANA,e.Blockchain.PSM]),[4,this.iframe.sendChildMessage({method:e.JsonRpcMethod.face_openWalletConnect,params:[t,n]})];case 1:return r=i.sent(),[4,this.iframe.waitForResponse(r)];case 2:return[2,i.sent()]}}))}))},n.prototype.openHome=function(t){return h(this,void 0,void 0,(function(){var n,r,i;return l(this,(function(o){switch(o.label){case 0:if(this.iframe.throwExceptionUnsupportedBlockchain([e.Blockchain.SOLANA,e.Blockchain.NEAR]),n=C(this.network),(null==t?void 0:t.networks)&&t.networks.some((function(e){return C(e)!==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:e.JsonRpcMethod.face_openHome,params:[t]})];case 1:return i=o.sent(),[2,this.iframe.waitForResponse(i)]}}))}))},n.prototype.sendRpc=function(e){return h(this,void 0,void 0,(function(){var t;return l(this,(function(n){switch(n.label){case 0:return[4,this.iframe.sendChildMessage(e)];case 1:return t=n.sent(),[4,this.iframe.waitForResponse(t)];case 2:return[2,n.sent()]}}))}))},n.prototype.decodeData=function(e,n){return h(this,void 0,void 0,(function(){var r,i,o,s;return l(this,(function(a){return r=new t.ethers.utils.Interface(n),i=r.parseTransaction({data:e}),o=i.name,s=i.args,[2,{name:o,args:s}]}))}))},n.prototype.encodeData=function(e,n,r){return h(this,void 0,void 0,(function(){return l(this,(function(i){return[2,new t.ethers.utils.Interface(e).encodeFunctionData(n,r)]}))}))},n.prototype.switchNetwork=function(n){return h(this,void 0,void 0,(function(){var r,i,o,s,a,c,u;return l(this,(function(h){switch(h.label){case 0:return h.trys.push([0,2,,3]),r=I(n),e.assertArgument(n,e.isSupportedNetwork(r),"network"),i=P(r),o={method:e.JsonRpcMethod.face_switchNetwork,params:[{blockchain:i}]},[4,this.sendRpc(o)];case 1:return s=h.sent(),this.network=r,this.iframe.setBlockchain(i),e.isEthlikeNetwork(this.network)&&(a=function(n){return e.isEthlikeNetwork(n)?t.ethers.utils.hexlify(e.NetworkChainIdMap[n]):0}(r),k.emit("chainChanged",a)),[2,s];case 2:throw c=h.sent(),e.isEthlikeNetwork(this.network)&&(u={name:c.name,message:c.message,code:4901},k.emit("disconnect",u)),c;case 3:return[2]}}))}))},n.prototype.boraIsConnected=function(t){return h(this,void 0,void 0,(function(){var n;return l(this,(function(r){switch(r.label){case 0:return this.iframe.throwExceptionUnsupportedBlockchain([e.Blockchain.APTOS,e.Blockchain.NEAR,e.Blockchain.KLAYTN,e.Blockchain.BNB_SMART_CHAIN,e.Blockchain.ETHEREUM,e.Blockchain.MEVERSE,e.Blockchain.SOLANA,e.Blockchain.POLYGON,e.Blockchain.PSM,e.Blockchain.HOME_VERSE,e.Blockchain.YOOLDO_VERSE]),[4,this.iframe.sendChildMessage({method:e.JsonRpcMethod.bora_isConnected,params:[t]})];case 1:return n=r.sent(),[4,this.iframe.waitForResponse(n)];case 2:return[2,r.sent()]}}))}))},n.prototype.boraConnect=function(t){return h(this,void 0,void 0,(function(){var n;return l(this,(function(r){switch(r.label){case 0:return this.iframe.throwExceptionUnsupportedBlockchain([e.Blockchain.APTOS,e.Blockchain.NEAR,e.Blockchain.KLAYTN,e.Blockchain.BNB_SMART_CHAIN,e.Blockchain.ETHEREUM,e.Blockchain.MEVERSE,e.Blockchain.SOLANA,e.Blockchain.POLYGON,e.Blockchain.PSM,e.Blockchain.HOME_VERSE,e.Blockchain.YOOLDO_VERSE]),[4,this.iframe.sendChildMessage({method:e.JsonRpcMethod.bora_connect,params:[t]})];case 1:return n=r.sent(),[4,this.iframe.waitForResponse(n)];case 2:return[2,r.sent()]}}))}))},n.prototype.getUserVerificationToken=function(){return h(this,void 0,void 0,(function(){var t,n;return l(this,(function(r){switch(r.label){case 0:return[4,this.iframe.sendChildMessage({method:e.JsonRpcMethod.face_getUserVerificationToken,params:[]})];case 1:return t=r.sent(),[4,this.iframe.waitForResponse(t)];case 2:return(n=r.sent())?[2,n]:[2,Promise.reject(new Error("get user verification token failed"))]}}))}))},n.prototype.getNetwork=function(){return this.network},n}(),U=function(t){function n(e){var n=t.call(this)||this;return n.internal=e,n}return u(n,t),n.prototype.request=function(t){return h(this,void 0,void 0,(function(){var n=this;return l(this,(function(r){if(Array.isArray(t))return[2,Promise.all(t.map((function(e){return n.internal.sendRpc(e)})))];switch(t.method){case e.JsonRpcMethod.wallet_switchEthereumChain:return[2,this.internal.switchNetwork(t.params[0].chainId)];case e.JsonRpcMethod.eth_estimateGas:return[2,this.internal.estimateGas(t)];case"personal_listAccounts":case"eth_accounts":return[2,this.internal.getAddresses()];default:return[2,this.internal.sendRpc(t)]}return[2]}))}))},n.prototype.on=function(e,t){return k.on(e,t),this},n.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return k.emit.apply(k,f([e],t,!1))},n.prototype.removeListener=function(e,t){return k.removeListener(e,t),this},n.prototype.off=function(e,t){return k.off(e,t),this},n}((function(){this.sendAsync=function(e,t){}})),J=function(){function t(e){this.internal=e}return t.prototype.close=function(){this.internal.iframe.hideOverlay()},t.prototype.home=function(t){var n;return h(this,void 0,void 0,(function(){return l(this,(function(r){return e.assertArgument(null==t?void 0:t.networks,null===(n=null==t?void 0:t.networks)||void 0===n?void 0:n.length,"options.networks",!1),[2,this.internal.openHome(t)]}))}))},t}(),H=function(){function t(e){this.internal=e}return t.prototype.connectOpensea=function(t){return h(this,void 0,void 0,(function(){return l(this,(function(n){switch(n.label){case 0:return e.assertArgument(t,"string"==typeof t,"collectionName",!1),[4,this.connect("OpenSea",t?"https://opensea.io/collection/"+t:"https://opensea.io")];case 1:return n.sent(),[2]}}))}))},t.prototype.connect=function(t,n){return h(this,void 0,void 0,(function(){return l(this,(function(r){switch(r.label){case 0:return e.assertArgument(t,"string"==typeof t,"name"),e.assertArgument(n,"string"==typeof n,"url"),[4,this.internal.openWalletConnect(t,n)];case 1:return r.sent(),[2]}}))}))},t}(),F=function(){function t(t){var n=this,r=t.apiKey,i=t.network,o=t.notificationOptions,s=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}(t,["apiKey","network","notificationOptions"]);this.getAddresses=function(t){return h(n,void 0,void 0,(function(){return l(this,(function(n){switch(n.label){case 0:return e.assertArgument(t,t&&e.Blockchain[t],"blockchain",!1),[4,this.internal.getAddresses(t)];case 1:return[2,n.sent()]}}))}))},this.getNetwork=function(){return n.internal.getNetwork()},this.getChainId=function(){return h(n,void 0,void 0,(function(){var e;return l(this,(function(t){switch(t.label){case 0:return e=Number,[4,this.internal.sendRpc({method:"eth_chainId",params:[]})];case 1:return[2,e.apply(void 0,[t.sent()])]}}))}))},e.assertArgument(r,"string"==typeof r,"apiKey"),e.assertArgument(i,!0,"network");var a=I(i);e.assert(e.isSupportedNetwork(a),e.unsupportedChainError),this.internal=new x({apiKey:r,network:a,env:null==s?void 0:s.env,iframeUrl:null==s?void 0:s.iframeUrl,notificationOptions:o,face:this}),this.auth=new N(this.internal),this.wc=new H(this.internal),this.solana=new R(this.internal),this.near=new S(this.internal),this.wallet=new J(this.internal),this.bora=new T(this.internal),this.aptos=new b(this.internal)}return t.prototype.ready=function(){return h(this,void 0,void 0,(function(){return l(this,(function(e){return[2,this.internal.ready()]}))}))},t.prototype.getEthLikeProvider=function(){return e.assert(e.isEthlikeBlockchain(e.networkToBlockchain(this.internal.getNetwork())),e.unsupportedChainError),new U(this.internal)},t.prototype.switchNetwork=function(e){return h(this,void 0,void 0,(function(){return l(this,(function(t){switch(t.label){case 0:return[4,this.internal.switchNetwork(e)];case 1:return[2,t.sent()]}}))}))},t}();Object.defineProperty(exports,"Network",{enumerable:!0,get:function(){return e.Network}}),exports.Face=F;
//# 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("ethers"),n=require("@noble/hashes/sha3"),r=require("aptos"),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){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)}function h(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 l(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])}}}function f(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))}function d(){}function p(){p.init.call(this)}function v(t){return void 0===t._maxListeners?p.defaultMaxListeners:t._maxListeners}function w(t,e,n,r){var i,o,s,a;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((o=t._events)?(o.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),o=t._events),s=o[e]):(o=t._events=new d,t._eventsCount=0),s){if("function"==typeof s?s=o[e]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),!s.warned&&(i=v(t))&&i>0&&s.length>i){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+e+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=s.length,a=c,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[e]=n,++t._eventsCount;return t}function m(t,e,n){var r=!1;function i(){t.removeListener(e,i),r||(r=!0,n.apply(t,arguments))}return i.listener=n,i}function y(t){var e=this._events;if(e){var n=e[t];if("function"==typeof n)return 1;if(n)return n.length}return 0}function g(t,e){for(var n=new Array(e);e--;)n[e]=t[e];return n}function k(t,e,n){try{Reflect.apply(t,e,n)}catch(t){setTimeout((function(){throw t}))}}d.prototype=Object.create(null),p.EventEmitter=p,p.usingDomains=!1,p.prototype.domain=void 0,p.prototype._events=void 0,p.prototype._maxListeners=void 0,p.defaultMaxListeners=10,p.init=function(){this.domain=null,p.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new d,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},p.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||isNaN(t))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=t,this},p.prototype.getMaxListeners=function(){return v(this)},p.prototype.emit=function(t){var e,n,r,i,o,s,a,c="error"===t;if(s=this._events)c=c&&null==s.error;else if(!c)return!1;if(a=this.domain,c){if(e=arguments[1],!a){if(e instanceof Error)throw e;var u=new Error('Uncaught, unspecified "error" event. ('+e+")");throw u.context=e,u}return e||(e=new Error('Uncaught, unspecified "error" event')),e.domainEmitter=this,e.domain=a,e.domainThrown=!1,a.emit("error",e),!1}if(!(n=s[t]))return!1;var h="function"==typeof n;switch(r=arguments.length){case 1:!function(t,e,n){if(e)t.call(n);else for(var r=t.length,i=g(t,r),o=0;o<r;++o)i[o].call(n)}(n,h,this);break;case 2:!function(t,e,n,r){if(e)t.call(n,r);else for(var i=t.length,o=g(t,i),s=0;s<i;++s)o[s].call(n,r)}(n,h,this,arguments[1]);break;case 3:!function(t,e,n,r,i){if(e)t.call(n,r,i);else for(var o=t.length,s=g(t,o),a=0;a<o;++a)s[a].call(n,r,i)}(n,h,this,arguments[1],arguments[2]);break;case 4:!function(t,e,n,r,i,o){if(e)t.call(n,r,i,o);else for(var s=t.length,a=g(t,s),c=0;c<s;++c)a[c].call(n,r,i,o)}(n,h,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(r-1),o=1;o<r;o++)i[o-1]=arguments[o];!function(t,e,n,r){if(e)t.apply(n,r);else for(var i=t.length,o=g(t,i),s=0;s<i;++s)o[s].apply(n,r)}(n,h,this,i)}return!0},p.prototype.addListener=function(t,e){return w(this,t,e,!1)},p.prototype.on=p.prototype.addListener,p.prototype.prependListener=function(t,e){return w(this,t,e,!0)},p.prototype.once=function(t,e){if("function"!=typeof e)throw new TypeError('"listener" argument must be a function');return this.on(t,m(this,t,e)),this},p.prototype.prependOnceListener=function(t,e){if("function"!=typeof e)throw new TypeError('"listener" argument must be a function');return this.prependListener(t,m(this,t,e)),this},p.prototype.removeListener=function(t,e){var n,r,i,o,s;if("function"!=typeof e)throw new TypeError('"listener" argument must be a function');if(!(r=this._events))return this;if(!(n=r[t]))return this;if(n===e||n.listener&&n.listener===e)0==--this._eventsCount?this._events=new d:(delete r[t],r.removeListener&&this.emit("removeListener",t,n.listener||e));else if("function"!=typeof n){for(i=-1,o=n.length;o-- >0;)if(n[o]===e||n[o].listener&&n[o].listener===e){s=n[o].listener,i=o;break}if(i<0)return this;if(1===n.length){if(n[0]=void 0,0==--this._eventsCount)return this._events=new d,this;delete r[t]}else!function(t,e){for(var n=e,r=n+1,i=t.length;r<i;n+=1,r+=1)t[n]=t[r];t.pop()}(n,i);r.removeListener&&this.emit("removeListener",t,s||e)}return this},p.prototype.removeAllListeners=function(t){var e,n;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=new d,this._eventsCount=0):n[t]&&(0==--this._eventsCount?this._events=new d:delete n[t]),this;if(0===arguments.length){for(var r,i=Object.keys(n),o=0;o<i.length;++o)"removeListener"!==(r=i[o])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=new d,this._eventsCount=0,this}if("function"==typeof(e=n[t]))this.removeListener(t,e);else if(e)do{this.removeListener(t,e[e.length-1])}while(e[0]);return this},p.prototype.listeners=function(t){var e,n=this._events;return n&&(e=n[t])?"function"==typeof e?[e.listener||e]:function(t){for(var e=new Array(t.length),n=0;n<e.length;++n)e[n]=t[n].listener||t[n];return e}(e):[]},p.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):y.call(t,e)},p.prototype.listenerCount=y,p.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var E=new(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return u(e,t),e.prototype.emit=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var r="error"===t,i=this._events;if(void 0!==i)r=r&&void 0===i.error;else if(!r)return!1;if(r){var o=void 0;if(e.length>0&&(o=e[0]),o instanceof Error)throw o;var s=new Error("Unhandled error.".concat(o?" (".concat(o.message,")"):""));throw s.context=o,s}var a=i[t];if(void 0===a)return!1;if("function"==typeof a)k(a,this,e);else for(var c=a.length,u=function(t){for(var e=t.length,n=new Array(e),r=0;r<e;r+=1)n[r]=t[r];return n}(a),h=0;h<c;h+=1)k(u[h],this,e);return!0},e}(p)),N=function(){function n(t){this.internal=t}return n.prototype.emitLoginEventsOnlyEthlike=function(){if(t.isEthlikeNetwork(this.internal.getNetwork())){var n=e.ethers.utils.hexlify(t.NetworkChainIdMap[this.internal.getNetwork()]);E.emit("connect",{chainId:n})}},n.prototype.emitLogoutEventsOnlyEthlike=function(){t.isEthlikeNetwork(this.internal.getNetwork())&&E.emit("disconnect")},n.prototype.login=function(e){return h(this,void 0,void 0,(function(){var n;return l(this,(function(r){switch(r.label){case 0:return t.assertArgument(e,Array.isArray(e)&&e.length>0&&f([],e,!0).every((function(e){return Object.values(t.LoginProvider).includes(e)})),"providers",!1),[4,this.internal.loginWithCredential(e)];case 1:return n=r.sent(),this.emitLoginEventsOnlyEthlike(),[2,n]}}))}))},n.prototype.directSocialLogin=function(e){return h(this,void 0,void 0,(function(){var n;return l(this,(function(r){switch(r.label){case 0:return t.assertArgument(e,"string"==typeof e,"provider"),[4,this.internal.directSocialLogin(e)];case 1:return n=r.sent(),this.emitLoginEventsOnlyEthlike(),[2,n]}}))}))},n.prototype.getIdToken=function(e,n){return h(this,void 0,void 0,(function(){return l(this,(function(r){return t.assertArgument(e,"string"==typeof e,"provider"),t.assertArgument(n,"string"==typeof n,"accessToken"),[2,this.internal.getIdToken(e,n)]}))}))},n.prototype.loginWithIdToken=function(e){return h(this,void 0,void 0,(function(){var n;return l(this,(function(r){switch(r.label){case 0:return t.assertArgument(e,e.idToken&&e.sig,"loginWithIdTokenRequest"),[4,this.internal.loginWithIdToken(e)];case 1:return n=r.sent(),this.emitLoginEventsOnlyEthlike(),[2,n]}}))}))},n.prototype.loginWithAccessToken=function(e){return h(this,void 0,void 0,(function(){var n;return l(this,(function(r){switch(r.label){case 0:return t.assertArgument(e,e.accessToken&&e.sig,"loginWithIdTokenRequest"),[4,this.internal.loginWithAccessToken(e)];case 1:return n=r.sent(),this.emitLoginEventsOnlyEthlike(),[2,n]}}))}))},n.prototype.logout=function(){return h(this,void 0,void 0,(function(){return l(this,(function(t){switch(t.label){case 0:return[4,this.internal.logout()];case 1:return t.sent(),this.emitLogoutEventsOnlyEthlike(),[2]}}))}))},n.prototype.getCurrentUser=function(){return h(this,void 0,void 0,(function(){return l(this,(function(t){switch(t.label){case 0:return[4,this.internal.getCurrentUser()];case 1:return[2,t.sent()]}}))}))},n.prototype.isLoggedIn=function(){return h(this,void 0,void 0,(function(){return l(this,(function(t){switch(t.label){case 0:return[4,this.internal.isLoggedIn()];case 1:return[2,t.sent()]}}))}))},n.prototype.getUserVerificationToken=function(){return h(this,void 0,void 0,(function(){return l(this,(function(t){switch(t.label){case 0:return[4,this.internal.getUserVerificationToken()];case 1:return[2,t.sent()]}}))}))},n}(),_=function(){function e(t){this.internal=t}return e.prototype.getPublicKeys=function(){return h(this,void 0,void 0,(function(){return l(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 r.HexString.ensure(t)}))]}}))}))},e.prototype.getAddresses=function(){return h(this,void 0,void 0,(function(){return l(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){var e=Uint8Array.from(t.substring(2).match(/.{1,2}/g).map((function(t){return parseInt(t,16)}))),i=new Uint8Array(e.length+1);i.set(e),i.set([0],e.length);var o=n.sha3_256.create();return o.update(i),r.HexString.fromUint8Array(o.digest())}))]}}))}))},e.prototype.signMultiAgentTransaction=function(e){return h(this,void 0,void 0,(function(){return l(this,(function(n){switch(n.label){case 0:return[4,this.internal.sendRpc({method:t.JsonRpcMethod.aptos_signMultiAgentTransaction,params:[e.raw_txn.sender.address,r.BCS.bcsToBytes(e)]})];case 1:return[2,n.sent()]}}))}))},e.prototype.signMessage=function(e){return h(this,void 0,void 0,(function(){var n,r;return l(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)]}}))}))},e.prototype.signAndSubmitTransaction=function(e,n){return h(this,void 0,void 0,(function(){var r;return l(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()}]}}))}))},e.prototype.signTransaction=function(e,n){return h(this,void 0,void 0,(function(){var r,i;return l(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)]}}))}))},e}(),b=function(){function t(t){this.internal=t}return t.prototype.getProvider=function(){return new _(this.internal)},t}(),T=function(){function e(t){this.internal=t}return e.prototype.connect=function(e){return h(this,void 0,void 0,(function(){return l(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 h(this,void 0,void 0,(function(){return l(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}(),A=function(){function n(t){this.internal=t}return n.prototype.getPublicKeys=function(){return h(this,void 0,void 0,(function(){return l(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")))}))]}}))}))},n.prototype.getBalance=function(n,r){return h(this,void 0,void 0,(function(){var i;return l(this,(function(o){switch(o.label){case 0:return t.assertArgument(n,"string"==typeof n,"address"),t.assertArgument(r,"string"==typeof r,"contractAddress",!1),[4,this.internal.sendRpc({method:t.JsonRpcMethod.near_get_balance,params:[n,r]})];case 1:return i=o.sent(),[2,e.BigNumber.from(i)]}}))}))},n.prototype.signAndSendTransaction=function(t){return h(this,void 0,void 0,(function(){var e;return l(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()]}}))}))},n}(),S=function(){function t(t){this.internal=t}return t.prototype.getProvider=function(){return new A(this.internal)},t}(),O=function(){function n(t){this.internal=t}return n.prototype.getPublicKeys=function(){return h(this,void 0,void 0,(function(){return l(this,(function(n){switch(n.label){case 0:return[4,this.internal.getAddresses(t.Blockchain.SOLANA)];case 1:return[2,n.sent().map((function(t){return new o.PublicKey(e.ethers.utils.base58.decode(t))}))]}}))}))},n.prototype.signAndSendTransaction=function(t){return h(this,void 0,void 0,(function(){var e;return l(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()]}}))}))},n}(),M=function(){function t(t){this.internal=t}return t.prototype.getProvider=function(){return new O(this.internal)},t}(),R={display:"none",position:"fixed",top:"0",right:"0",width:"100%",height:"100%",borderRadius:"0",border:"none",zIndex:"2147483647"};var B=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}},L=function(){function e(t,e,n,r,i){void 0===i&&(i={type:"toast"});var o,s=this;this._ready=new B,this.requestIndex=0,this.activeElement=null,this._blockchain=e,this._env=n,this.iframeUrl=r;var a=Math.random().toString();if(this.randomPrefix=a.substring(a.length-6),document.getElementById("face-iframe"))throw new Error("Face is already initialized, Face can be initialized once.");window.addEventListener("message",(function(t){return h(s,void 0,void 0,(function(){return l(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 c=null!==(o="1.10.12")?o:"";this._iframe=new Promise((function(o){var s=function(){if(!document.getElementById("face-iframe")){var s=document.createElement("iframe");s.id="face-iframe",s.title="Secure Modal",s.src=new URL("".concat(r,"?api_key=").concat(t,"&blockchain=").concat(e,"&env=").concat(n,"&version=").concat(c,"&type=").concat("web","&notification=").concat(null==i?void 0:i.type)).href,s.allow="clipboard-read; clipboard-write",function(t){for(var e=0,n=Object.entries(R);e<n.length;e++){var r=n[e],i=r[0],o=r[1];t.style[i]=o}}(s),document.body.appendChild(s),o(s)}};["loaded","interactive","complete"].includes(document.readyState)?s():window.addEventListener("load",s,!1)}))}return e.prototype.sendChildMessage=function(e){var n,r;return h(this,void 0,void 0,(function(){var i;return l(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 h(this,void 0,void 0,(function(){var n;return l(this,(function(r){switch(r.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];case t.JsonRpcMethod.face_showToast:return[3,6]}return[3,7];case 1:return this._ready.complete(),[3,7];case 2:return[4,this.showOverlay()];case 3:case 5:return r.sent(),[3,7];case 4:return[4,this.hideOverlay()];case 6:return n=new CustomEvent("face-toast",{detail:null==e?void 0:e.result}),window.dispatchEvent(n),[3,7];case 7:return[2]}}))}))},e.prototype.ready=function(){return h(this,void 0,void 0,(function(){var t=this;return l(this,(function(e){return[2,new Promise((function(e){return h(t,void 0,void 0,(function(){return l(this,(function(t){return this._ready.isCompleted()?(e(),[2]):(this._ready.add((function(){e()})),[2])}))}))}))]}))}))},e.prototype.showOverlay=function(){return h(this,void 0,void 0,(function(){var t;return l(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 h(this,void 0,void 0,(function(){return l(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 C(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:case t.Network.YOOLDO_VERSE:return!0;default:return!1}}function P(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;case t.Network.PSM_TESTNET_DEV:return t.Blockchain.PSM_DEV;case t.Network.PSM_TESTNET_TEST:return t.Blockchain.PSM_TEST;case t.Network.HOME_VERSE:case t.Network.HOME_VERSE_TESTNET:return t.Blockchain.HOME_VERSE;case t.Network.YOOLDO_VERSE:case t.Network.SAND_VERSE:return t.Blockchain.YOOLDO_VERSE;case t.Network.OASYS:case t.Network.OASYS_TESTNET:return t.Blockchain.OASYS;default:return t.Blockchain.ETHEREUM}}function I(e){if("string"==typeof e&&/^0x[0-9A-Fa-f]*$/.test(e)){var n=parseInt(e,16);if(t.NetworkChainIdMap.hasOwnProperty(n))return t.NetworkChainIdMap[n];throw new Error("Invalid chainId: ".concat(n))}if("number"==typeof e){if(t.NetworkChainIdMap.hasOwnProperty(e))return t.NetworkChainIdMap[e];throw new Error("Invalid chainId: ".concat(e))}if(Object.values(t.Network).includes(e))return e;throw new Error("Invalid network parameter")}e.BigNumber.from(1e5).toHexString();var x=function(){function n(e){var n=e.apiKey,r=e.network,i=e.env,o=e.iframeUrl,s=e.face,a=e.notificationOptions;this.network=r||t.Network.ETHEREUM;var c=P(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&&e!==t.Network.PSM_TESTNET_DEV&&e!==t.Network.PSM_TESTNET_TEST&&e!==t.Network.HOME_VERSE_TESTNET&&e!==t.Network.SAND_VERSE&&e!==t.Network.OASYS_TESTNET?t.Env.ProdMainnet:t.Env.ProdTest}(r),this.iframe=new L(n,c,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),a),this.face=s,this.iframeUrl=o}return n.prototype.getAddresses=function(e){return h(this,void 0,void 0,(function(){var n,r;return l(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"))]}}))}))},n.prototype.estimateGas=function(t){return h(this,void 0,void 0,(function(){return l(this,(function(t){return[2,0]}))}))},n.prototype.getBalance=function(n,r){return h(this,void 0,void 0,(function(){var i,o,s,a;return l(this,(function(c){switch(c.label){case 0:return r?[4,this.encodeData(["function balanceOf(address owner) view returns (uint256)"],"balanceOf",[n])]:[3,3];case 1:return i=c.sent(),[4,this.sendRpc({method:t.JsonRpcMethod.eth_call,params:[{to:r,data:i},"latest"]})];case 2:return o=c.sent(),[2,e.BigNumber.from(o)];case 3:return a=(s=e.BigNumber).from,[4,this.sendRpc({method:t.JsonRpcMethod.eth_getBalance,params:[n,"latest"]})];case 4:return[2,a.apply(s,[c.sent()])]}}))}))},n.prototype.ownerOf=function(e,n){return h(this,void 0,void 0,(function(){var r;return l(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()]}}))}))},n.prototype.logout=function(){return h(this,void 0,void 0,(function(){var e;return l(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]}}))}))},n.prototype.getCurrentUser=function(){return h(this,void 0,void 0,(function(){var e;return l(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()]}}))}))},n.prototype.isLoggedIn=function(){return h(this,void 0,void 0,(function(){var e;return l(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]}}))}))},n.prototype.ready=function(){return h(this,void 0,void 0,(function(){return l(this,(function(t){return[2,this.iframe.ready()]}))}))},n.prototype.loginWithCredential=function(e){return h(this,void 0,void 0,(function(){var n;return l(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()]}}))}))},n.prototype.directSocialLogin=function(e){return h(this,void 0,void 0,(function(){var n;return l(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()]}}))}))},n.prototype.getIdToken=function(e,n){return h(this,void 0,void 0,(function(){var r;return l(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()]}}))}))},n.prototype.loginWithIdToken=function(e){return h(this,void 0,void 0,(function(){var n;return l(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()]}}))}))},n.prototype.loginWithAccessToken=function(e){return h(this,void 0,void 0,(function(){var n;return l(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()]}}))}))},n.prototype.openWalletConnect=function(e,n){return h(this,void 0,void 0,(function(){var r;return l(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()]}}))}))},n.prototype.openHome=function(e){return h(this,void 0,void 0,(function(){var n,r,i;return l(this,(function(o){switch(o.label){case 0:if(this.iframe.throwExceptionUnsupportedBlockchain([t.Blockchain.SOLANA,t.Blockchain.NEAR]),n=C(this.network),(null==e?void 0:e.networks)&&e.networks.some((function(t){return C(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)]}}))}))},n.prototype.sendRpc=function(t){return h(this,void 0,void 0,(function(){var e;return l(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()]}}))}))},n.prototype.decodeData=function(t,n){return h(this,void 0,void 0,(function(){var r,i,o,s;return l(this,(function(a){return r=new e.ethers.utils.Interface(n),i=r.parseTransaction({data:t}),o=i.name,s=i.args,[2,{name:o,args:s}]}))}))},n.prototype.encodeData=function(t,n,r){return h(this,void 0,void 0,(function(){return l(this,(function(i){return[2,new e.ethers.utils.Interface(t).encodeFunctionData(n,r)]}))}))},n.prototype.switchNetwork=function(e){return h(this,void 0,void 0,(function(){var n,r,i;return l(this,(function(o){switch(o.label){case 0:return n=P(e),r={method:t.JsonRpcMethod.face_switchNetwork,params:[{blockchain:n}]},[4,this.sendRpc(r)];case 1:return i=o.sent(),this.network=e,this.face.setNetwork(e),this.iframe.setBlockchain(n),[2,i]}}))}))},n.prototype.boraIsConnected=function(e){return h(this,void 0,void 0,(function(){var n;return l(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,t.Blockchain.HOME_VERSE,t.Blockchain.YOOLDO_VERSE]),[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()]}}))}))},n.prototype.boraConnect=function(e){return h(this,void 0,void 0,(function(){var n;return l(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,t.Blockchain.HOME_VERSE,t.Blockchain.YOOLDO_VERSE]),[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()]}}))}))},n.prototype.getUserVerificationToken=function(){return h(this,void 0,void 0,(function(){var e,n;return l(this,(function(r){switch(r.label){case 0:return[4,this.iframe.sendChildMessage({method:t.JsonRpcMethod.face_getUserVerificationToken,params:[]})];case 1:return e=r.sent(),[4,this.iframe.waitForResponse(e)];case 2:return(n=r.sent())?[2,n]:[2,Promise.reject(new Error("get user verification token failed"))]}}))}))},n.prototype.getNetwork=function(){return this.network},n}(),U=function(e){function n(t){var n=e.call(this)||this;return n.internal=t,n}return u(n,e),n.prototype.request=function(e){return h(this,void 0,void 0,(function(){var n,r=this;return l(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.prototype.on=function(t,e){return E.on(t,e),this},n.prototype.emit=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return E.emit.apply(E,f([t],e,!1))},n.prototype.removeListener=function(t,e){return E.removeListener(t,e),this},n.prototype.off=function(t,e){return E.off(t,e),this},n}((function(){this.sendAsync=function(t,e){}})),J=function(){function e(t){this.internal=t}return e.prototype.close=function(){this.internal.iframe.hideOverlay()},e.prototype.home=function(e){var n;return h(this,void 0,void 0,(function(){return l(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}(),H=function(){function e(t){this.internal=t}return e.prototype.connectOpensea=function(e){return h(this,void 0,void 0,(function(){return l(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 h(this,void 0,void 0,(function(){return l(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}(),V=function(){function n(e){var n=this,r=e.apiKey,i=e.network,o=e.notificationOptions,s=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","notificationOptions"]);this.getAddresses=function(e){return h(n,void 0,void 0,(function(){return l(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 h(n,void 0,void 0,(function(){var t;return l(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 a=I(i);t.assert(t.isSupportedNetwork(a),t.unsupportedChainError),this.network=a,this.internal=new x({apiKey:r,network:a,env:null==s?void 0:s.env,iframeUrl:null==s?void 0:s.iframeUrl,notificationOptions:o,face:this}),this.auth=new N(this.internal),this.wc=new H(this.internal),this.solana=new M(this.internal),this.near=new S(this.internal),this.wallet=new J(this.internal),this.bora=new T(this.internal),this.aptos=new b(this.internal)}return n.prototype.ready=function(){return h(this,void 0,void 0,(function(){return l(this,(function(t){return[2,this.internal.ready()]}))}))},n.prototype.getEthLikeProvider=function(){return t.assert(t.isEthlikeBlockchain(t.networkToBlockchain(this.network)),t.unsupportedChainError),new U(this.internal)},n.prototype.switchNetwork=function(n){return h(this,void 0,void 0,(function(){var r,i,o;return l(this,(function(s){switch(s.label){case 0:return r=I(n),t.assertArgument(n,t.isSupportedNetwork(r),"network"),[4,this.internal.switchNetwork(r)];case 1:return i=s.sent(),t.isEthlikeNetwork(this.network)&&(o=function(n){return t.isEthlikeNetwork(n)?e.ethers.utils.hexlify(t.NetworkChainIdMap[n]):0}(r),E.emit("chainChanged",o)),[2,i]}}))}))},n}();Object.defineProperty(exports,"Network",{enumerable:!0,get:function(){return t.Network}}),exports.Face=V;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@haechi-labs/face-types"),t=require("ethers"),n=require("@noble/hashes/sha3"),r=require("aptos"),i=require("near-api-js"),o=require("@solana/web3.js");function s(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var a=s(i),c=function(e,t){return c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},c(e,t)};function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}c(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function h(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))}function l(e,t){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=t.call(e,s)}catch(e){a=[6,e],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])}}}function f(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}function d(){}function p(){p.init.call(this)}function v(e){return void 0===e._maxListeners?p.defaultMaxListeners:e._maxListeners}function w(e,t,n,r){var i,o,s,a;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((o=e._events)?(o.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),o=e._events),s=o[t]):(o=e._events=new d,e._eventsCount=0),s){if("function"==typeof s?s=o[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),!s.warned&&(i=v(e))&&i>0&&s.length>i){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=s.length,a=c,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=n,++e._eventsCount;return e}function m(e,t,n){var r=!1;function i(){e.removeListener(t,i),r||(r=!0,n.apply(e,arguments))}return i.listener=n,i}function y(e){var t=this._events;if(t){var n=t[e];if("function"==typeof n)return 1;if(n)return n.length}return 0}function g(e,t){for(var n=new Array(t);t--;)n[t]=e[t];return n}function E(e,t,n){try{Reflect.apply(e,t,n)}catch(e){setTimeout((function(){throw e}))}}d.prototype=Object.create(null),p.EventEmitter=p,p.usingDomains=!1,p.prototype.domain=void 0,p.prototype._events=void 0,p.prototype._maxListeners=void 0,p.defaultMaxListeners=10,p.init=function(){this.domain=null,p.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new d,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},p.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},p.prototype.getMaxListeners=function(){return v(this)},p.prototype.emit=function(e){var t,n,r,i,o,s,a,c="error"===e;if(s=this._events)c=c&&null==s.error;else if(!c)return!1;if(a=this.domain,c){if(t=arguments[1],!a){if(t instanceof Error)throw t;var u=new Error('Uncaught, unspecified "error" event. ('+t+")");throw u.context=t,u}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(n=s[e]))return!1;var h="function"==typeof n;switch(r=arguments.length){case 1:!function(e,t,n){if(t)e.call(n);else for(var r=e.length,i=g(e,r),o=0;o<r;++o)i[o].call(n)}(n,h,this);break;case 2:!function(e,t,n,r){if(t)e.call(n,r);else for(var i=e.length,o=g(e,i),s=0;s<i;++s)o[s].call(n,r)}(n,h,this,arguments[1]);break;case 3:!function(e,t,n,r,i){if(t)e.call(n,r,i);else for(var o=e.length,s=g(e,o),a=0;a<o;++a)s[a].call(n,r,i)}(n,h,this,arguments[1],arguments[2]);break;case 4:!function(e,t,n,r,i,o){if(t)e.call(n,r,i,o);else for(var s=e.length,a=g(e,s),c=0;c<s;++c)a[c].call(n,r,i,o)}(n,h,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(r-1),o=1;o<r;o++)i[o-1]=arguments[o];!function(e,t,n,r){if(t)e.apply(n,r);else for(var i=e.length,o=g(e,i),s=0;s<i;++s)o[s].apply(n,r)}(n,h,this,i)}return!0},p.prototype.addListener=function(e,t){return w(this,e,t,!1)},p.prototype.on=p.prototype.addListener,p.prototype.prependListener=function(e,t){return w(this,e,t,!0)},p.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,m(this,e,t)),this},p.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,m(this,e,t)),this},p.prototype.removeListener=function(e,t){var n,r,i,o,s;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(r=this._events))return this;if(!(n=r[e]))return this;if(n===t||n.listener&&n.listener===t)0==--this._eventsCount?this._events=new d:(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,o=n.length;o-- >0;)if(n[o]===t||n[o].listener&&n[o].listener===t){s=n[o].listener,i=o;break}if(i<0)return this;if(1===n.length){if(n[0]=void 0,0==--this._eventsCount)return this._events=new d,this;delete r[e]}else!function(e,t){for(var n=t,r=n+1,i=e.length;r<i;n+=1,r+=1)e[n]=e[r];e.pop()}(n,i);r.removeListener&&this.emit("removeListener",e,s||t)}return this},p.prototype.removeAllListeners=function(e){var t,n;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=new d,this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=new d:delete n[e]),this;if(0===arguments.length){for(var r,i=Object.keys(n),o=0;o<i.length;++o)"removeListener"!==(r=i[o])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=new d,this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},p.prototype.listeners=function(e){var t,n=this._events;return n&&(t=n[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(t):[]},p.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):y.call(e,t)},p.prototype.listenerCount=y,p.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var k=new(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return u(t,e),t.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var r="error"===e,i=this._events;if(void 0!==i)r=r&&void 0===i.error;else if(!r)return!1;if(r){var o=void 0;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var s=new Error("Unhandled error.".concat(o?" (".concat(o.message,")"):""));throw s.context=o,s}var a=i[e];if(void 0===a)return!1;if("function"==typeof a)E(a,this,t);else for(var c=a.length,u=function(e){for(var t=e.length,n=new Array(t),r=0;r<t;r+=1)n[r]=e[r];return n}(a),h=0;h<c;h+=1)E(u[h],this,t);return!0},t}(p)),N=function(){function n(e){this.internal=e}return n.prototype.emitLoginEventsOnlyEthlike=function(){if(e.isEthlikeNetwork(this.internal.getNetwork())){var n=t.ethers.utils.hexlify(e.NetworkChainIdMap[this.internal.getNetwork()]);k.emit("connect",{chainId:n})}},n.prototype.emitLogoutEventsOnlyEthlike=function(){if(e.isEthlikeNetwork(this.internal.getNetwork())){k.emit("disconnect",{name:"disconnect",code:4900,message:"face wallet logout"})}},n.prototype.login=function(t){return h(this,void 0,void 0,(function(){var n;return l(this,(function(r){switch(r.label){case 0:return e.assertArgument(t,Array.isArray(t)&&t.length>0&&f([],t,!0).every((function(t){return Object.values(e.LoginProvider).includes(t)})),"providers",!1),[4,this.internal.loginWithCredential(t)];case 1:return n=r.sent(),this.emitLoginEventsOnlyEthlike(),[2,n]}}))}))},n.prototype.directSocialLogin=function(t){return h(this,void 0,void 0,(function(){var n;return l(this,(function(r){switch(r.label){case 0:return e.assertArgument(t,"string"==typeof t,"provider"),[4,this.internal.directSocialLogin(t)];case 1:return n=r.sent(),this.emitLoginEventsOnlyEthlike(),[2,n]}}))}))},n.prototype.getIdToken=function(t,n){return h(this,void 0,void 0,(function(){return l(this,(function(r){return e.assertArgument(t,"string"==typeof t,"provider"),e.assertArgument(n,"string"==typeof n,"accessToken"),[2,this.internal.getIdToken(t,n)]}))}))},n.prototype.loginWithIdToken=function(t){return h(this,void 0,void 0,(function(){var n;return l(this,(function(r){switch(r.label){case 0:return e.assertArgument(t,t.idToken&&t.sig,"loginWithIdTokenRequest"),[4,this.internal.loginWithIdToken(t)];case 1:return n=r.sent(),this.emitLoginEventsOnlyEthlike(),[2,n]}}))}))},n.prototype.loginWithAccessToken=function(t){return h(this,void 0,void 0,(function(){var n;return l(this,(function(r){switch(r.label){case 0:return e.assertArgument(t,t.accessToken&&t.sig,"loginWithIdTokenRequest"),[4,this.internal.loginWithAccessToken(t)];case 1:return n=r.sent(),this.emitLoginEventsOnlyEthlike(),[2,n]}}))}))},n.prototype.logout=function(){return h(this,void 0,void 0,(function(){return l(this,(function(e){switch(e.label){case 0:return[4,this.internal.logout()];case 1:return e.sent(),this.emitLogoutEventsOnlyEthlike(),[2]}}))}))},n.prototype.getCurrentUser=function(){return h(this,void 0,void 0,(function(){return l(this,(function(e){switch(e.label){case 0:return[4,this.internal.getCurrentUser()];case 1:return[2,e.sent()]}}))}))},n.prototype.isLoggedIn=function(){return h(this,void 0,void 0,(function(){return l(this,(function(e){switch(e.label){case 0:return[4,this.internal.isLoggedIn()];case 1:return[2,e.sent()]}}))}))},n.prototype.getUserVerificationToken=function(){return h(this,void 0,void 0,(function(){return l(this,(function(e){switch(e.label){case 0:return[4,this.internal.getUserVerificationToken()];case 1:return[2,e.sent()]}}))}))},n}(),_=function(){function t(e){this.internal=e}return t.prototype.getPublicKeys=function(){return h(this,void 0,void 0,(function(){return l(this,(function(t){switch(t.label){case 0:return[4,this.internal.getAddresses(e.Blockchain.APTOS)];case 1:return[2,t.sent().map((function(e){return r.HexString.ensure(e)}))]}}))}))},t.prototype.getAddresses=function(){return h(this,void 0,void 0,(function(){return l(this,(function(t){switch(t.label){case 0:return[4,this.internal.getAddresses(e.Blockchain.APTOS)];case 1:return[2,t.sent().map((function(e){var t=Uint8Array.from(e.substring(2).match(/.{1,2}/g).map((function(e){return parseInt(e,16)}))),i=new Uint8Array(t.length+1);i.set(t),i.set([0],t.length);var o=n.sha3_256.create();return o.update(i),r.HexString.fromUint8Array(o.digest())}))]}}))}))},t.prototype.signMultiAgentTransaction=function(t){return h(this,void 0,void 0,(function(){return l(this,(function(n){switch(n.label){case 0:return[4,this.internal.sendRpc({method:e.JsonRpcMethod.aptos_signMultiAgentTransaction,params:[t.raw_txn.sender.address,r.BCS.bcsToBytes(t)]})];case 1:return[2,n.sent()]}}))}))},t.prototype.signMessage=function(t){return h(this,void 0,void 0,(function(){var n,r;return l(this,(function(i){switch(i.label){case 0:return n=Buffer.from(JSON.stringify(t)),[4,this.internal.sendRpc({method:e.JsonRpcMethod.aptos_signMessage,params:[n]})];case 1:return r=i.sent(),[2,JSON.parse(r)]}}))}))},t.prototype.signAndSubmitTransaction=function(t,n){return h(this,void 0,void 0,(function(){var r;return l(this,(function(i){switch(i.label){case 0:return[4,this.internal.getAddresses(e.Blockchain.APTOS)];case 1:return r=i.sent()[0],[4,this.internal.sendRpc({method:e.JsonRpcMethod.aptos_signAndSubmitTransaction,params:[Buffer.from(r),Buffer.from(JSON.stringify(t)),n]})];case 2:return[2,{hash:i.sent()}]}}))}))},t.prototype.signTransaction=function(t,n){return h(this,void 0,void 0,(function(){var r,i;return l(this,(function(o){switch(o.label){case 0:return[4,this.internal.getAddresses(e.Blockchain.APTOS)];case 1:return r=o.sent()[0],[4,this.internal.sendRpc({method:e.JsonRpcMethod.aptos_signTransaction,params:[Buffer.from(r),Buffer.from(JSON.stringify(t)),n]})];case 2:return i=o.sent(),[2,JSON.parse(i)]}}))}))},t}(),b=function(){function e(e){this.internal=e}return e.prototype.getProvider=function(){return new _(this.internal)},e}(),T=function(){function t(e){this.internal=e}return t.prototype.connect=function(t){return h(this,void 0,void 0,(function(){return l(this,(function(n){switch(n.label){case 0:return e.assertArgument(t,t.bappUsn&&t.signature,"request"),[4,this.internal.boraConnect(t)];case 1:return[2,n.sent()]}}))}))},t.prototype.isConnected=function(t){return h(this,void 0,void 0,(function(){return l(this,(function(n){switch(n.label){case 0:return e.assertArgument(t,"string"==typeof t,"bappUsn"),[4,this.internal.boraIsConnected(t)];case 1:return[2,n.sent()]}}))}))},t}(),A=function(){function n(e){this.internal=e}return n.prototype.getPublicKeys=function(){return h(this,void 0,void 0,(function(){return l(this,(function(t){switch(t.label){case 0:return[4,this.internal.getAddresses(e.Blockchain.NEAR)];case 1:return[2,t.sent().map((function(e){return a.utils.PublicKey.fromString(a.utils.serialize.base_encode(Buffer.from(e,"hex")))}))]}}))}))},n.prototype.getBalance=function(n,r){return h(this,void 0,void 0,(function(){var i;return l(this,(function(o){switch(o.label){case 0:return e.assertArgument(n,"string"==typeof n,"address"),e.assertArgument(r,"string"==typeof r,"contractAddress",!1),[4,this.internal.sendRpc({method:e.JsonRpcMethod.near_get_balance,params:[n,r]})];case 1:return i=o.sent(),[2,t.BigNumber.from(i)]}}))}))},n.prototype.signAndSendTransaction=function(e){return h(this,void 0,void 0,(function(){var t;return l(this,(function(n){switch(n.label){case 0:return t={serializedHex:Buffer.from(a.utils.serialize.serialize(a.transactions.SCHEMA,e)).toString("hex")},[4,this.internal.sendRpc({method:"near_broadcast_tx_async",params:[t]})];case 1:return[2,n.sent()]}}))}))},n}(),S=function(){function e(e){this.internal=e}return e.prototype.getProvider=function(){return new A(this.internal)},e}(),O=function(){function n(e){this.internal=e}return n.prototype.getPublicKeys=function(){return h(this,void 0,void 0,(function(){return l(this,(function(n){switch(n.label){case 0:return[4,this.internal.getAddresses(e.Blockchain.SOLANA)];case 1:return[2,n.sent().map((function(e){return new o.PublicKey(t.ethers.utils.base58.decode(e))}))]}}))}))},n.prototype.signAndSendTransaction=function(e){return h(this,void 0,void 0,(function(){var t;return l(this,(function(n){switch(n.label){case 0:return t={serializedHex:e.serialize({requireAllSignatures:!1,verifySignatures:!1}).toString("hex")},[4,this.internal.sendRpc({method:"solana_sendTransaction",params:[t]})];case 1:return[2,n.sent()]}}))}))},n}(),R=function(){function e(e){this.internal=e}return e.prototype.getProvider=function(){return new O(this.internal)},e}(),M={display:"none",position:"fixed",top:"0",right:"0",width:"100%",height:"100%",borderRadius:"0",border:"none",zIndex:"2147483647"};var B=function(){var e=this;this._isCompleted=!1,this._eventListeners=Array(),this.complete=function(){e._isCompleted=!0,e._eventListeners.forEach((function(e){return e()}))},this.add=function(t){e._eventListeners.push(t)},this.isCompleted=function(){return e._isCompleted}},L=function(){function t(e,t,n,r,i){void 0===i&&(i={type:"toast"});var o,s=this;this._ready=new B,this.requestIndex=0,this.activeElement=null,this._blockchain=t,this._env=n,this.iframeUrl=r;var a=Math.random().toString();if(this.randomPrefix=a.substring(a.length-6),document.getElementById("face-iframe"))throw new Error("Face is already initialized, Face can be initialized once.");window.addEventListener("message",(function(e){return h(s,void 0,void 0,(function(){return l(this,(function(t){switch(t.label){case 0:return e.origin!==r?[2]:[4,this.processMessage(e.data)];case 1:return t.sent(),[2]}}))}))}));var c=null!==(o="1.10.13")?o:"";this._iframe=new Promise((function(o){var s=function(){if(!document.getElementById("face-iframe")){var s=document.createElement("iframe");s.id="face-iframe",s.title="Secure Modal",s.src=new URL("".concat(r,"?api_key=").concat(e,"&blockchain=").concat(t,"&env=").concat(n,"&version=").concat(c,"&type=").concat("web","&notification=").concat(null==i?void 0:i.type)).href,s.allow="clipboard-read; clipboard-write",function(e){for(var t=0,n=Object.entries(M);t<n.length;t++){var r=n[t],i=r[0],o=r[1];e.style[i]=o}}(s),document.body.appendChild(s),o(s)}};["loaded","interactive","complete"].includes(document.readyState)?s():window.addEventListener("load",s,!1)}))}return t.prototype.sendChildMessage=function(t){var n,r;return h(this,void 0,void 0,(function(){var i;return l(this,(function(o){switch(o.label){case 0:return[4,this.ready()];case 1:return o.sent(),this.requestIndex+=1,i=t.id?"".concat(t.id):"".concat(this.randomPrefix,"-").concat(this.requestIndex),t.id=i,t.from=e.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(t,"*"),[2,i]}}))}))},t.prototype.waitForResponse=function(e){return new Promise((function(t,n){var r=function(i){var o=i.data;e&&o.id!==e||(window.removeEventListener("message",r),o.error?n(o.error):t(o.result))};window.addEventListener("message",r)}))},t.prototype.processMessage=function(t){return h(this,void 0,void 0,(function(){var n;return l(this,(function(r){switch(r.label){case 0:switch(t.method){case e.JsonRpcMethod.face_ready:return[3,1];case e.JsonRpcMethod.face_openIframe:return[3,2];case e.JsonRpcMethod.face_closeIframe:return[3,4];case e.JsonRpcMethod.face_showToast:return[3,6]}return[3,7];case 1:return this._ready.complete(),[3,7];case 2:return[4,this.showOverlay()];case 3:case 5:return r.sent(),[3,7];case 4:return[4,this.hideOverlay()];case 6:return n=new CustomEvent("face-toast",{detail:null==t?void 0:t.result}),window.dispatchEvent(n),[3,7];case 7:return[2]}}))}))},t.prototype.ready=function(){return h(this,void 0,void 0,(function(){var e=this;return l(this,(function(t){return[2,new Promise((function(t){return h(e,void 0,void 0,(function(){return l(this,(function(e){return this._ready.isCompleted()?(t(),[2]):(this._ready.add((function(){t()})),[2])}))}))}))]}))}))},t.prototype.showOverlay=function(){return h(this,void 0,void 0,(function(){var e;return l(this,(function(t){switch(t.label){case 0:return[4,this.ready()];case 1:return t.sent(),[4,this._iframe];case 2:return(e=t.sent()).style.display="block",this.activeElement=document.activeElement,e.focus(),[2]}}))}))},t.prototype.hideOverlay=function(){var e;return h(this,void 0,void 0,(function(){return l(this,(function(t){switch(t.label){case 0:return[4,this.ready()];case 1:return t.sent(),[4,this._iframe];case 2:return t.sent().style.display="none",(null===(e=this.activeElement)||void 0===e?void 0:e.focus)&&this.activeElement.focus(),this.activeElement=null,[2]}}))}))},t.prototype.setBlockchain=function(e){this._blockchain=e},t.prototype.throwExceptionUnsupportedBlockchain=function(t){if(t.includes(this._blockchain))throw e.unsupportedChainError()},t.prototype.getBlockchain=function(){return this._blockchain},t}();function C(t){switch(t){case e.Network.ETHEREUM:case e.Network.POLYGON:case e.Network.BNB_SMART_CHAIN:case e.Network.KLAYTN:case e.Network.SOLANA:case e.Network.BORA:case e.Network.NEAR:case e.Network.APTOS:case e.Network.MEVERSE:case e.Network.PSM:case e.Network.YOOLDO_VERSE:return!0;default:return!1}}function P(t){switch(t){case e.Network.ETHEREUM:case e.Network.GOERLI:return e.Blockchain.ETHEREUM;case e.Network.POLYGON:case e.Network.MUMBAI:return e.Blockchain.POLYGON;case e.Network.BNB_SMART_CHAIN:case e.Network.BNB_SMART_CHAIN_TESTNET:return e.Blockchain.BNB_SMART_CHAIN;case e.Network.KLAYTN:case e.Network.BAOBAB:return e.Blockchain.KLAYTN;case e.Network.SOLANA:case e.Network.SOLANA_DEVNET:return e.Blockchain.SOLANA;case e.Network.BORA:case e.Network.BORA_TESTNET:return e.Blockchain.BORA;case e.Network.NEAR:case e.Network.NEAR_TESTNET:return e.Blockchain.NEAR;case e.Network.APTOS:case e.Network.APTOS_TESTNET:return e.Blockchain.APTOS;case e.Network.MEVERSE:case e.Network.MEVERSE_TESTNET:return e.Blockchain.MEVERSE;case e.Network.PSM:case e.Network.PSM_TESTNET:return e.Blockchain.PSM;case e.Network.PSM_TESTNET_DEV:return e.Blockchain.PSM_DEV;case e.Network.PSM_TESTNET_TEST:return e.Blockchain.PSM_TEST;case e.Network.HOME_VERSE:case e.Network.HOME_VERSE_TESTNET:return e.Blockchain.HOME_VERSE;case e.Network.YOOLDO_VERSE:case e.Network.SAND_VERSE:return e.Blockchain.YOOLDO_VERSE;case e.Network.OASYS:case e.Network.OASYS_TESTNET:return e.Blockchain.OASYS;default:return e.Blockchain.ETHEREUM}}function I(t){if("string"==typeof t&&/^0x[0-9A-Fa-f]*$/.test(t)){var n=parseInt(t,16);if(e.NetworkChainIdMap.hasOwnProperty(n))return e.NetworkChainIdMap[n];throw new e.FaceError({message:"Invalid chainId: ".concat(n),code:e.FaceErrorCode.UNSUPPORTED_CHAIN})}if("number"==typeof t){if(e.NetworkChainIdMap.hasOwnProperty(t))return e.NetworkChainIdMap[t];throw new e.FaceError({message:"Invalid chainId: ".concat(t),code:e.FaceErrorCode.UNSUPPORTED_CHAIN})}if(Object.values(e.Network).includes(t))return t;throw new e.FaceError({message:"Invalid network parameter: ".concat(t),code:e.FaceErrorCode.UNSUPPORTED_CHAIN})}t.BigNumber.from(1e5).toHexString();var x=function(){function n(t){var n=t.apiKey,r=t.network,i=t.env,o=t.iframeUrl,s=t.face,a=t.notificationOptions;this.network=r||e.Network.ETHEREUM;var c=P(this.network);this.env=null!=i?i:function(t){return!t||t!==e.Network.GOERLI&&t!==e.Network.MUMBAI&&t!==e.Network.BAOBAB&&t!==e.Network.BNB_SMART_CHAIN_TESTNET&&t!==e.Network.BORA_TESTNET&&t!==e.Network.SOLANA_DEVNET&&t!==e.Network.NEAR_TESTNET&&t!==e.Network.APTOS_TESTNET&&t!==e.Network.MEVERSE_TESTNET&&t!==e.Network.PSM_TESTNET&&t!==e.Network.PSM_TESTNET_DEV&&t!==e.Network.PSM_TESTNET_TEST&&t!==e.Network.HOME_VERSE_TESTNET&&t!==e.Network.SAND_VERSE&&t!==e.Network.OASYS_TESTNET?e.Env.ProdMainnet:e.Env.ProdTest}(r),this.iframe=new L(n,c,this.env,function(t,n){if(null!=n)return n;switch(t){case e.Env.Local:return"http://localhost:3333";case e.Env.Dev:return"https://app.dev.facewallet.xyz";case e.Env.StageTest:return"https://app.stage-test.facewallet.xyz";case e.Env.ProdTest:return"https://app.test.facewallet.xyz";case e.Env.StageMainnet:return"https://app.stage.facewallet.xyz";case e.Env.ProdMainnet:default:return"https://app.facewallet.xyz"}}(this.env,o),a),this.face=s,this.iframeUrl=o}return n.prototype.getAddresses=function(t){return h(this,void 0,void 0,(function(){var n,r;return l(this,(function(i){switch(i.label){case 0:return[4,this.iframe.sendChildMessage({method:e.JsonRpcMethod.face_accounts,params:[t]})];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"))]}}))}))},n.prototype.estimateGas=function(e){return h(this,void 0,void 0,(function(){return l(this,(function(e){return[2,0]}))}))},n.prototype.getBalance=function(n,r){return h(this,void 0,void 0,(function(){var i,o,s,a;return l(this,(function(c){switch(c.label){case 0:return r?[4,this.encodeData(["function balanceOf(address owner) view returns (uint256)"],"balanceOf",[n])]:[3,3];case 1:return i=c.sent(),[4,this.sendRpc({method:e.JsonRpcMethod.eth_call,params:[{to:r,data:i},"latest"]})];case 2:return o=c.sent(),[2,t.BigNumber.from(o)];case 3:return a=(s=t.BigNumber).from,[4,this.sendRpc({method:e.JsonRpcMethod.eth_getBalance,params:[n,"latest"]})];case 4:return[2,a.apply(s,[c.sent()])]}}))}))},n.prototype.ownerOf=function(t,n){return h(this,void 0,void 0,(function(){var r;return l(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:e.JsonRpcMethod.eth_call,params:[{to:t,data:r},"latest"]})];case 2:return[2,("0x"+i.sent().substring(26)).toLowerCase()]}}))}))},n.prototype.logout=function(){return h(this,void 0,void 0,(function(){var t;return l(this,(function(n){switch(n.label){case 0:return[4,this.iframe.sendChildMessage({method:e.JsonRpcMethod.face_logOut})];case 1:return t=n.sent(),[4,this.iframe.waitForResponse(t)];case 2:return n.sent(),[2]}}))}))},n.prototype.getCurrentUser=function(){return h(this,void 0,void 0,(function(){var t;return l(this,(function(n){switch(n.label){case 0:return[4,this.iframe.sendChildMessage({method:e.JsonRpcMethod.face_currentUser})];case 1:return t=n.sent(),[4,this.iframe.waitForResponse(t)];case 2:return[2,n.sent()]}}))}))},n.prototype.isLoggedIn=function(){return h(this,void 0,void 0,(function(){var t;return l(this,(function(n){switch(n.label){case 0:return[4,this.iframe.sendChildMessage({method:e.JsonRpcMethod.face_loggedIn})];case 1:return n.sent(),[4,this.iframe.waitForResponse()];case 2:return(t=n.sent())?[2,t]:[2,!1]}}))}))},n.prototype.ready=function(){return h(this,void 0,void 0,(function(){return l(this,(function(e){return[2,this.iframe.ready()]}))}))},n.prototype.loginWithCredential=function(t){return h(this,void 0,void 0,(function(){var n;return l(this,(function(r){switch(r.label){case 0:return[4,this.iframe.sendChildMessage({method:e.JsonRpcMethod.face_logInSignUp,params:t})];case 1:return n=r.sent(),[4,this.iframe.waitForResponse(n)];case 2:return[2,r.sent()]}}))}))},n.prototype.directSocialLogin=function(t){return h(this,void 0,void 0,(function(){var n;return l(this,(function(r){switch(r.label){case 0:return[4,this.iframe.sendChildMessage({method:e.JsonRpcMethod.face_directSocialLogin,params:[t]})];case 1:return n=r.sent(),[4,this.iframe.waitForResponse(n)];case 2:return[2,r.sent()]}}))}))},n.prototype.getIdToken=function(t,n){return h(this,void 0,void 0,(function(){var r;return l(this,(function(i){switch(i.label){case 0:return[4,this.iframe.sendChildMessage({method:e.JsonRpcMethod.face_getIdToken,params:[t,n]})];case 1:return r=i.sent(),[4,this.iframe.waitForResponse(r)];case 2:return[2,i.sent()]}}))}))},n.prototype.loginWithIdToken=function(t){return h(this,void 0,void 0,(function(){var n;return l(this,(function(r){switch(r.label){case 0:return[4,this.iframe.sendChildMessage({method:e.JsonRpcMethod.face_loginWithIdToken,params:[t]})];case 1:return n=r.sent(),[4,this.iframe.waitForResponse(n)];case 2:return[2,r.sent()]}}))}))},n.prototype.loginWithAccessToken=function(t){return h(this,void 0,void 0,(function(){var n;return l(this,(function(r){switch(r.label){case 0:return[4,this.iframe.sendChildMessage({method:e.JsonRpcMethod.face_loginWithAccessToken,params:[t]})];case 1:return n=r.sent(),[4,this.iframe.waitForResponse(n)];case 2:return[2,r.sent()]}}))}))},n.prototype.openWalletConnect=function(t,n){return h(this,void 0,void 0,(function(){var r;return l(this,(function(i){switch(i.label){case 0:return this.iframe.throwExceptionUnsupportedBlockchain([e.Blockchain.APTOS,e.Blockchain.NEAR,e.Blockchain.SOLANA,e.Blockchain.PSM]),[4,this.iframe.sendChildMessage({method:e.JsonRpcMethod.face_openWalletConnect,params:[t,n]})];case 1:return r=i.sent(),[4,this.iframe.waitForResponse(r)];case 2:return[2,i.sent()]}}))}))},n.prototype.openHome=function(t){return h(this,void 0,void 0,(function(){var n,r,i;return l(this,(function(o){switch(o.label){case 0:if(this.iframe.throwExceptionUnsupportedBlockchain([e.Blockchain.SOLANA,e.Blockchain.NEAR]),n=C(this.network),(null==t?void 0:t.networks)&&t.networks.some((function(e){return C(e)!==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:e.JsonRpcMethod.face_openHome,params:[t]})];case 1:return i=o.sent(),[2,this.iframe.waitForResponse(i)]}}))}))},n.prototype.sendRpc=function(e){return h(this,void 0,void 0,(function(){var t;return l(this,(function(n){switch(n.label){case 0:return[4,this.iframe.sendChildMessage(e)];case 1:return t=n.sent(),[4,this.iframe.waitForResponse(t)];case 2:return[2,n.sent()]}}))}))},n.prototype.decodeData=function(e,n){return h(this,void 0,void 0,(function(){var r,i,o,s;return l(this,(function(a){return r=new t.ethers.utils.Interface(n),i=r.parseTransaction({data:e}),o=i.name,s=i.args,[2,{name:o,args:s}]}))}))},n.prototype.encodeData=function(e,n,r){return h(this,void 0,void 0,(function(){return l(this,(function(i){return[2,new t.ethers.utils.Interface(e).encodeFunctionData(n,r)]}))}))},n.prototype.switchNetwork=function(n){return h(this,void 0,void 0,(function(){var r,i,o,s,a,c,u;return l(this,(function(h){switch(h.label){case 0:return h.trys.push([0,2,,3]),r=I(n),e.assertArgument(n,e.isSupportedNetwork(r),"network"),i=P(r),o={method:e.JsonRpcMethod.face_switchNetwork,params:[{blockchain:i}]},[4,this.sendRpc(o)];case 1:return s=h.sent(),this.network=r,this.iframe.setBlockchain(i),e.isEthlikeNetwork(this.network)&&(a=function(n){return e.isEthlikeNetwork(n)?t.ethers.utils.hexlify(e.NetworkChainIdMap[n]):0}(r),k.emit("chainChanged",a)),[2,s];case 2:throw c=h.sent(),e.isEthlikeNetwork(this.network)&&(u={name:c.name,message:c.message,code:4901},k.emit("disconnect",u)),c;case 3:return[2]}}))}))},n.prototype.boraIsConnected=function(t){return h(this,void 0,void 0,(function(){var n;return l(this,(function(r){switch(r.label){case 0:return this.iframe.throwExceptionUnsupportedBlockchain([e.Blockchain.APTOS,e.Blockchain.NEAR,e.Blockchain.KLAYTN,e.Blockchain.BNB_SMART_CHAIN,e.Blockchain.ETHEREUM,e.Blockchain.MEVERSE,e.Blockchain.SOLANA,e.Blockchain.POLYGON,e.Blockchain.PSM,e.Blockchain.HOME_VERSE,e.Blockchain.YOOLDO_VERSE]),[4,this.iframe.sendChildMessage({method:e.JsonRpcMethod.bora_isConnected,params:[t]})];case 1:return n=r.sent(),[4,this.iframe.waitForResponse(n)];case 2:return[2,r.sent()]}}))}))},n.prototype.boraConnect=function(t){return h(this,void 0,void 0,(function(){var n;return l(this,(function(r){switch(r.label){case 0:return this.iframe.throwExceptionUnsupportedBlockchain([e.Blockchain.APTOS,e.Blockchain.NEAR,e.Blockchain.KLAYTN,e.Blockchain.BNB_SMART_CHAIN,e.Blockchain.ETHEREUM,e.Blockchain.MEVERSE,e.Blockchain.SOLANA,e.Blockchain.POLYGON,e.Blockchain.PSM,e.Blockchain.HOME_VERSE,e.Blockchain.YOOLDO_VERSE]),[4,this.iframe.sendChildMessage({method:e.JsonRpcMethod.bora_connect,params:[t]})];case 1:return n=r.sent(),[4,this.iframe.waitForResponse(n)];case 2:return[2,r.sent()]}}))}))},n.prototype.getUserVerificationToken=function(){return h(this,void 0,void 0,(function(){var t,n;return l(this,(function(r){switch(r.label){case 0:return[4,this.iframe.sendChildMessage({method:e.JsonRpcMethod.face_getUserVerificationToken,params:[]})];case 1:return t=r.sent(),[4,this.iframe.waitForResponse(t)];case 2:return(n=r.sent())?[2,n]:[2,Promise.reject(new Error("get user verification token failed"))]}}))}))},n.prototype.getNetwork=function(){return this.network},n}(),U=function(t){function n(e){var n=t.call(this)||this;return n.internal=e,n}return u(n,t),n.prototype.request=function(t){return h(this,void 0,void 0,(function(){var n=this;return l(this,(function(r){if(Array.isArray(t))return[2,Promise.all(t.map((function(e){return n.internal.sendRpc(e)})))];switch(t.method){case e.JsonRpcMethod.wallet_switchEthereumChain:return[2,this.internal.switchNetwork(t.params[0].chainId)];case e.JsonRpcMethod.eth_estimateGas:return[2,this.internal.estimateGas(t)];case"personal_listAccounts":case"eth_accounts":return[2,this.internal.getAddresses()];default:return[2,this.internal.sendRpc(t)]}return[2]}))}))},n.prototype.on=function(e,t){return k.on(e,t),this},n.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return k.emit.apply(k,f([e],t,!1))},n.prototype.removeListener=function(e,t){return k.removeListener(e,t),this},n.prototype.off=function(e,t){return k.off(e,t),this},n}((function(){this.sendAsync=function(e,t){}})),J=function(){function t(e){this.internal=e}return t.prototype.close=function(){this.internal.iframe.hideOverlay()},t.prototype.home=function(t){var n;return h(this,void 0,void 0,(function(){return l(this,(function(r){return e.assertArgument(null==t?void 0:t.networks,null===(n=null==t?void 0:t.networks)||void 0===n?void 0:n.length,"options.networks",!1),[2,this.internal.openHome(t)]}))}))},t}(),H=function(){function t(e){this.internal=e}return t.prototype.connectOpensea=function(t){return h(this,void 0,void 0,(function(){return l(this,(function(n){switch(n.label){case 0:return e.assertArgument(t,"string"==typeof t,"collectionName",!1),[4,this.connect("OpenSea",t?"https://opensea.io/collection/"+t:"https://opensea.io")];case 1:return n.sent(),[2]}}))}))},t.prototype.connect=function(t,n){return h(this,void 0,void 0,(function(){return l(this,(function(r){switch(r.label){case 0:return e.assertArgument(t,"string"==typeof t,"name"),e.assertArgument(n,"string"==typeof n,"url"),[4,this.internal.openWalletConnect(t,n)];case 1:return r.sent(),[2]}}))}))},t}(),F=function(){function t(t){var n=this,r=t.apiKey,i=t.network,o=t.notificationOptions,s=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}(t,["apiKey","network","notificationOptions"]);this.getAddresses=function(t){return h(n,void 0,void 0,(function(){return l(this,(function(n){switch(n.label){case 0:return e.assertArgument(t,t&&e.Blockchain[t],"blockchain",!1),[4,this.internal.getAddresses(t)];case 1:return[2,n.sent()]}}))}))},this.getNetwork=function(){return n.internal.getNetwork()},this.getChainId=function(){return h(n,void 0,void 0,(function(){var e;return l(this,(function(t){switch(t.label){case 0:return e=Number,[4,this.internal.sendRpc({method:"eth_chainId",params:[]})];case 1:return[2,e.apply(void 0,[t.sent()])]}}))}))},e.assertArgument(r,"string"==typeof r,"apiKey"),e.assertArgument(i,!0,"network");var a=I(i);e.assert(e.isSupportedNetwork(a),e.unsupportedChainError),this.internal=new x({apiKey:r,network:a,env:null==s?void 0:s.env,iframeUrl:null==s?void 0:s.iframeUrl,notificationOptions:o,face:this}),this.auth=new N(this.internal),this.wc=new H(this.internal),this.solana=new R(this.internal),this.near=new S(this.internal),this.wallet=new J(this.internal),this.bora=new T(this.internal),this.aptos=new b(this.internal)}return t.prototype.ready=function(){return h(this,void 0,void 0,(function(){return l(this,(function(e){return[2,this.internal.ready()]}))}))},t.prototype.getEthLikeProvider=function(){return e.assert(e.isEthlikeBlockchain(e.networkToBlockchain(this.internal.getNetwork())),e.unsupportedChainError),new U(this.internal)},t.prototype.switchNetwork=function(e){return h(this,void 0,void 0,(function(){return l(this,(function(t){switch(t.label){case 0:return[4,this.internal.switchNetwork(e)];case 1:return[2,t.sent()]}}))}))},t}();Object.defineProperty(exports,"Network",{enumerable:!0,get:function(){return e.Network}}),exports.Face=F;
//# sourceMappingURL=index.js.map

@@ -22,3 +22,2 @@ import { Blockchain, Network } from '@haechi-labs/face-types';

readonly internal: Internal;
network: Network;
wc: WalletConnect;

@@ -35,3 +34,2 @@ auth: Auth;

getAddresses: (blockchain?: Blockchain) => Promise<string[]>;
setNetwork: (network: Network) => void;
getNetwork: () => Network;

@@ -38,0 +36,0 @@ getChainId: () => Promise<number>;

@@ -41,3 +41,3 @@ import { Blockchain, BoraPortalConnectRequest, BoraPortalConnectStatusResponse, Env, FaceIdTokenResponse, FaceLoginResponse, HomeOptions, JsonRpcRequestPayload, JsonRpcResponsePayload, LoginProviderType, LoginWithAccessTokenRequest, LoginWithIdTokenRequest } from '@haechi-labs/face-types';

encodeData(abi: string[], functionFragment: string, args?: any[]): Promise<string>;
switchNetwork(network: Network): Promise<unknown>;
switchNetwork(network: Network | number | string): Promise<unknown>;
boraIsConnected(bappUsn: string): Promise<BoraPortalConnectStatusResponse | null>;

@@ -44,0 +44,0 @@ boraConnect(request: BoraPortalConnectRequest): Promise<BoraPortalConnectStatusResponse | null>;

@@ -22,3 +22,2 @@ import { Blockchain, Network } from '@haechi-labs/face-types';

readonly internal: Internal;
network: Network;
wc: WalletConnect;

@@ -35,3 +34,2 @@ auth: Auth;

getAddresses: (blockchain?: Blockchain) => Promise<string[]>;
setNetwork: (network: Network) => void;
getNetwork: () => Network;

@@ -38,0 +36,0 @@ getChainId: () => Promise<number>;

@@ -41,3 +41,3 @@ import { Blockchain, BoraPortalConnectRequest, BoraPortalConnectStatusResponse, Env, FaceIdTokenResponse, FaceLoginResponse, HomeOptions, JsonRpcRequestPayload, JsonRpcResponsePayload, LoginProviderType, LoginWithAccessTokenRequest, LoginWithIdTokenRequest } from '@haechi-labs/face-types';

encodeData(abi: string[], functionFragment: string, args?: any[]): Promise<string>;
switchNetwork(network: Network): Promise<unknown>;
switchNetwork(network: Network | number | string): Promise<unknown>;
boraIsConnected(bappUsn: string): Promise<BoraPortalConnectStatusResponse | null>;

@@ -44,0 +44,0 @@ boraConnect(request: BoraPortalConnectRequest): Promise<BoraPortalConnectStatusResponse | null>;

@@ -109,3 +109,2 @@ import { LoginProviderType, FaceLoginResponse, FaceIdTokenResponse, LoginWithIdTokenRequest, LoginWithAccessTokenRequest, BoraPortalConnectRequest, BoraPortalConnectStatusResponse, JsonRpcResponsePayload, HomeOptions, Network, Blockchain, Env, JsonRpcRequestPayload, AptosSignMessagePayload, AptosSignMessageResponse, AptosTxOptions } from '@haechi-labs/face-types';

readonly internal: Internal;
network: Network;
wc: WalletConnect;

@@ -122,3 +121,2 @@ auth: Auth;

getAddresses: (blockchain?: Blockchain) => Promise<string[]>;
setNetwork: (network: Network) => void;
getNetwork: () => Network;

@@ -186,3 +184,3 @@ getChainId: () => Promise<number>;

encodeData(abi: string[], functionFragment: string, args?: any[]): Promise<string>;
switchNetwork(network: Network): Promise<unknown>;
switchNetwork(network: Network | number | string): Promise<unknown>;
boraIsConnected(bappUsn: string): Promise<BoraPortalConnectStatusResponse | null>;

@@ -189,0 +187,0 @@ boraConnect(request: BoraPortalConnectRequest): Promise<BoraPortalConnectStatusResponse | null>;

@@ -22,3 +22,2 @@ import { Blockchain, Network } from '@haechi-labs/face-types';

readonly internal: Internal;
network: Network;
wc: WalletConnect;

@@ -35,3 +34,2 @@ auth: Auth;

getAddresses: (blockchain?: Blockchain) => Promise<string[]>;
setNetwork: (network: Network) => void;
getNetwork: () => Network;

@@ -38,0 +36,0 @@ getChainId: () => Promise<number>;

@@ -41,3 +41,3 @@ import { Blockchain, BoraPortalConnectRequest, BoraPortalConnectStatusResponse, Env, FaceIdTokenResponse, FaceLoginResponse, HomeOptions, JsonRpcRequestPayload, JsonRpcResponsePayload, LoginProviderType, LoginWithAccessTokenRequest, LoginWithIdTokenRequest } from '@haechi-labs/face-types';

encodeData(abi: string[], functionFragment: string, args?: any[]): Promise<string>;
switchNetwork(network: Network): Promise<unknown>;
switchNetwork(network: Network | number | string): Promise<unknown>;
boraIsConnected(bappUsn: string): Promise<BoraPortalConnectStatusResponse | null>;

@@ -44,0 +44,0 @@ boraConnect(request: BoraPortalConnectRequest): Promise<BoraPortalConnectStatusResponse | null>;

{
"name": "@haechi-labs/face-sdk",
"version": "1.10.12",
"version": "1.10.13",
"description": "",

@@ -35,3 +35,3 @@ "license": "ISC",

"devDependencies": {
"@haechi-labs/face-types": "^1.10.12",
"@haechi-labs/face-types": "^1.10.13",
"@rollup/plugin-commonjs": "^24.0.1",

@@ -63,3 +63,3 @@ "@rollup/plugin-json": "^6.0.0",

},
"gitHead": "6da2744b9e0077cf6ed7aa384b19de66f28c6f32",
"gitHead": "04244316427e8896c43b2c2174ba1f4fdb911c8c",
"publishConfig": {

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

@@ -11,2 +11,3 @@ import {

NetworkChainIdMap,
ProviderRpcError,
} from '@haechi-labs/face-types';

@@ -34,3 +35,8 @@ import { ethers } from 'ethers';

if (isEthlikeNetwork(this.internal.getNetwork())) {
eventEmitter.emit('disconnect');
const error: ProviderRpcError = {
name: 'disconnect',
code: 4900,
message: 'face wallet logout',
};
eventEmitter.emit('disconnect', error);
}

@@ -37,0 +43,0 @@ }

@@ -6,2 +6,3 @@ import {

Env,
FaceError,
isEthlikeBlockchain,

@@ -12,2 +13,3 @@ isEthlikeNetwork,

networkToBlockchain,
ProviderRpcError,
unsupportedChainError,

@@ -42,3 +44,3 @@ } from '@haechi-labs/face-types';

public readonly internal: Internal;
public network: Network;
// public network: Network;
public wc: WalletConnect;

@@ -59,3 +61,2 @@ public auth: Auth;

this.network = _network!;
this.internal = new Internal({

@@ -83,3 +84,6 @@ apiKey,

getEthLikeProvider(): Provider {
assert(isEthlikeBlockchain(networkToBlockchain(this.network)), unsupportedChainError);
assert(
isEthlikeBlockchain(networkToBlockchain(this.internal.getNetwork())),
unsupportedChainError
);

@@ -95,10 +99,4 @@ return new Provider(this.internal);

setNetwork = (network: Network) => {
assertArgument(network, isSupportedNetwork(network), 'network');
this.network = network;
};
getNetwork = (): Network => {
return this.network;
return this.internal.getNetwork();
};

@@ -111,13 +109,4 @@

async switchNetwork(network: Network | number | string) {
const _network = getNetwork(network);
assertArgument(network, isSupportedNetwork(_network), 'network');
const res = await this.internal.switchNetwork(_network);
if (isEthlikeNetwork(this.network)) {
const chainId = getEthlikeChainIdFromNetwork(_network);
eventEmitter.emit('chainChanged', chainId);
}
return res;
return await this.internal.switchNetwork(network);
}
}
import {
assertArgument,
Blockchain,

@@ -6,5 +7,8 @@ BoraPortalConnectRequest,

Env,
FaceError,
FaceIdTokenResponse,
FaceLoginResponse,
HomeOptions,
isEthlikeNetwork,
isSupportedNetwork,
JsonRpcMethod,

@@ -16,8 +20,17 @@ JsonRpcRequestPayload,

LoginWithIdTokenRequest,
ProviderRpcError,
} from '@haechi-labs/face-types';
import { BigNumber, ethers } from 'ethers';
import eventEmitter from './events';
import { Face, Network, NotificationOptions } from './face';
import { Iframe } from './iframe';
import { getBlockchainFromNetwork, getDefaultEnv, getIframeUrl, isMainnet } from './utils';
import {
getBlockchainFromNetwork,
getDefaultEnv,
getEthlikeChainIdFromNetwork,
getIframeUrl,
getNetwork,
isMainnet,
} from './utils';

@@ -258,16 +271,32 @@ const DEFAULT_ETH_GAS_PRICE = BigNumber.from(100000).toHexString();

async switchNetwork(network: Network) {
const blockchain = getBlockchainFromNetwork(network);
const request = {
method: JsonRpcMethod.face_switchNetwork,
params: [{ blockchain }],
};
const res = await this.sendRpc(request);
async switchNetwork(network: Network | number | string) {
try {
const _network = getNetwork(network);
assertArgument(network, isSupportedNetwork(_network), 'network');
const blockchain = getBlockchainFromNetwork(_network);
const request = {
method: JsonRpcMethod.face_switchNetwork,
params: [{ blockchain }],
};
const res = await this.sendRpc(request);
this.network = _network;
this.iframe.setBlockchain(blockchain);
this.network = network;
this.face.setNetwork(network);
if (isEthlikeNetwork(this.network)) {
const chainId = getEthlikeChainIdFromNetwork(_network);
eventEmitter.emit('chainChanged', chainId);
}
this.iframe.setBlockchain(blockchain);
return res;
return res;
} catch (e) {
if (isEthlikeNetwork(this.network)) {
const error: ProviderRpcError = {
name: (e as FaceError).name,
message: (e as FaceError).message,
code: 4901,
};
eventEmitter.emit('disconnect', error);
}
throw e;
}
}

@@ -274,0 +303,0 @@

@@ -39,4 +39,3 @@ import {

case JsonRpcMethod.wallet_switchEthereumChain:
const network = NetworkChainIdMap[request.params[0].chainId] as Network;
return this.internal.switchNetwork(network);
return this.internal.switchNetwork(request.params[0].chainId);
case JsonRpcMethod.eth_estimateGas:

@@ -43,0 +42,0 @@ return this.internal.estimateGas(request);

import {
Blockchain,
Env,
FaceError,
FaceErrorCode,
isEthlikeNetwork,

@@ -135,3 +137,6 @@ Network,

} else {
throw new Error(`Invalid chainId: ${chainId}`);
throw new FaceError({
message: `Invalid chainId: ${chainId}`,
code: FaceErrorCode.UNSUPPORTED_CHAIN,
});
}

@@ -144,3 +149,6 @@ }

} else {
throw new Error(`Invalid chainId: ${network}`);
throw new FaceError({
message: `Invalid chainId: ${network}`,
code: FaceErrorCode.UNSUPPORTED_CHAIN,
});
}

@@ -153,3 +161,6 @@ }

throw new Error('Invalid network parameter');
throw new FaceError({
message: `Invalid network parameter: ${network}`,
code: FaceErrorCode.UNSUPPORTED_CHAIN,
});
}

@@ -156,0 +167,0 @@

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

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

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

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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

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