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.13 to 1.10.14

2

./dist/cjs/index.js

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

"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;
"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.14")?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:case e.Network.MCH_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;case e.Network.MCH_VERSE:case e.Network.MCH_VERSE_TESTNET:return e.Blockchain.MCH_VERSE;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&&t!==e.Network.MCH_VERSE_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){var n;return h(this,void 0,void 0,(function(){var r,i,o;return l(this,(function(s){switch(s.label){case 0:if(this.iframe.throwExceptionUnsupportedBlockchain([e.Blockchain.SOLANA,e.Blockchain.NEAR]),!(a=f(f([],null!==(n=null==t?void 0:t.networks)&&void 0!==n?n:[],!0),[this.network],!1)).every((function(e){return C(e)}))&&!a.every((function(e){return!C(e)})))throw r=C(this.network),i="You initialized the Face SDK with ".concat(r?"Mainnet":"Testnet",". Please open the wallet home in the same environment as the initialized network."),new Error(i);return[4,this.iframe.sendChildMessage({method:e.JsonRpcMethod.face_openHome,params:[t]})];case 1:return o=s.sent(),[2,this.iframe.waitForResponse(o)]}var a}))}))},n.prototype.openBuy=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_openBuy,params:[t]})];case 1:return n=r.sent(),[2,this.iframe.waitForResponse(n)]}}))}))},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){}})),H=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.prototype.onRamp=function(t){return h(this,void 0,void 0,(function(){return l(this,(function(n){return e.assertArgument(t,t.length>0&&t.every((function(t){return e.Blockchain[t]})),"blockchains"),[2,this.internal.openBuy({blockchains:t})]}))}))},t.prototype.onRampToken=function(t,n,r){return h(this,void 0,void 0,(function(){return l(this,(function(i){return e.assertArgument(t,e.Blockchain[t],"blockchain"),e.assertArgument(n,n,"contractAddress"),e.assertArgument(r,r&&r>0,"coinAmount",!1),[2,this.internal.openBuy({blockchains:[t],contractAddress:n,coinAmount:r})]}))}))},t}(),J=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}(),V=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 J(this.internal),this.solana=new R(this.internal),this.near=new S(this.internal),this.wallet=new H(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=V;
//# sourceMappingURL=index.js.map

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

"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;
"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.14")?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:case e.Network.MCH_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;case e.Network.MCH_VERSE:case e.Network.MCH_VERSE_TESTNET:return e.Blockchain.MCH_VERSE;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&&t!==e.Network.MCH_VERSE_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){var n;return h(this,void 0,void 0,(function(){var r,i,o;return l(this,(function(s){switch(s.label){case 0:if(this.iframe.throwExceptionUnsupportedBlockchain([e.Blockchain.SOLANA,e.Blockchain.NEAR]),!(a=f(f([],null!==(n=null==t?void 0:t.networks)&&void 0!==n?n:[],!0),[this.network],!1)).every((function(e){return C(e)}))&&!a.every((function(e){return!C(e)})))throw r=C(this.network),i="You initialized the Face SDK with ".concat(r?"Mainnet":"Testnet",". Please open the wallet home in the same environment as the initialized network."),new Error(i);return[4,this.iframe.sendChildMessage({method:e.JsonRpcMethod.face_openHome,params:[t]})];case 1:return o=s.sent(),[2,this.iframe.waitForResponse(o)]}var a}))}))},n.prototype.openBuy=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_openBuy,params:[t]})];case 1:return n=r.sent(),[2,this.iframe.waitForResponse(n)]}}))}))},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){}})),H=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.prototype.onRamp=function(t){return h(this,void 0,void 0,(function(){return l(this,(function(n){return e.assertArgument(t,t.length>0&&t.every((function(t){return e.Blockchain[t]})),"blockchains"),[2,this.internal.openBuy({blockchains:t})]}))}))},t.prototype.onRampToken=function(t,n,r){return h(this,void 0,void 0,(function(){return l(this,(function(i){return e.assertArgument(t,e.Blockchain[t],"blockchain"),e.assertArgument(n,n,"contractAddress"),e.assertArgument(r,r&&r>0,"coinAmount",!1),[2,this.internal.openBuy({blockchains:[t],contractAddress:n,coinAmount:r})]}))}))},t}(),J=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}(),V=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 J(this.internal),this.solana=new R(this.internal),this.near=new S(this.internal),this.wallet=new H(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=V;
//# sourceMappingURL=index.js.map

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

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

@@ -35,2 +35,3 @@ import { Face, Network, NotificationOptions } from './face';

openHome(options?: HomeOptions): Promise<void>;
openBuy(options?: OnRampOptions): Promise<void>;
sendRpc<T>(rpcPayload: JsonRpcRequestPayload): Promise<JsonRpcResponsePayload<T>['result']>;

@@ -37,0 +38,0 @@ decodeData(serializedTx: string, abi: string[]): Promise<{

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

export declare const getEthlikeChainIdFromNetwork: (network: Network) => string | 0;
export declare function isEveryNetworkOnSameEnv(networks: Network[]): boolean;
//# sourceMappingURL=utils.d.ts.map

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

import { HomeOptions } from '@haechi-labs/face-types';
import { Blockchain, HomeOptions } from '@haechi-labs/face-types';
import { Internal } from './internal';

@@ -11,3 +11,18 @@ /**

home(options?: HomeOptions): Promise<void>;
/**
* Open onRamp(MoonPay) modal for the passed blockchains
*
* @method
* @returns {Promise<void>}
*/
onRamp(blockchains: Blockchain[]): Promise<void>;
/**
* Open onRamp(MoonPay) modal for the token
* Contract address for platform coin like ETH, MATIC is '0x0'
*
* @method
* @returns {Promise<void>}
*/
onRampToken(blockchain: Blockchain, contractAddress: string, coinAmount?: number): Promise<void>;
}
//# sourceMappingURL=wallet.d.ts.map

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

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

@@ -35,2 +35,3 @@ import { Face, Network, NotificationOptions } from './face';

openHome(options?: HomeOptions): Promise<void>;
openBuy(options?: OnRampOptions): Promise<void>;
sendRpc<T>(rpcPayload: JsonRpcRequestPayload): Promise<JsonRpcResponsePayload<T>['result']>;

@@ -37,0 +38,0 @@ decodeData(serializedTx: string, abi: string[]): Promise<{

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

export declare const getEthlikeChainIdFromNetwork: (network: Network) => string | 0;
export declare function isEveryNetworkOnSameEnv(networks: Network[]): boolean;
//# sourceMappingURL=utils.d.ts.map

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

import { HomeOptions } from '@haechi-labs/face-types';
import { Blockchain, HomeOptions } from '@haechi-labs/face-types';
import { Internal } from './internal';

@@ -11,3 +11,18 @@ /**

home(options?: HomeOptions): Promise<void>;
/**
* Open onRamp(MoonPay) modal for the passed blockchains
*
* @method
* @returns {Promise<void>}
*/
onRamp(blockchains: Blockchain[]): Promise<void>;
/**
* Open onRamp(MoonPay) modal for the token
* Contract address for platform coin like ETH, MATIC is '0x0'
*
* @method
* @returns {Promise<void>}
*/
onRampToken(blockchain: Blockchain, contractAddress: string, coinAmount?: number): Promise<void>;
}
//# sourceMappingURL=wallet.d.ts.map

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

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

@@ -90,2 +90,17 @@ import { HexString, TxnBuilderTypes, Types } from 'aptos';

home(options?: HomeOptions): Promise<void>;
/**
* Open onRamp(MoonPay) modal for the passed blockchains
*
* @method
* @returns {Promise<void>}
*/
onRamp(blockchains: Blockchain[]): Promise<void>;
/**
* Open onRamp(MoonPay) modal for the token
* Contract address for platform coin like ETH, MATIC is '0x0'
*
* @method
* @returns {Promise<void>}
*/
onRampToken(blockchain: Blockchain, contractAddress: string, coinAmount?: number): Promise<void>;
}

@@ -177,2 +192,3 @@

openHome(options?: HomeOptions): Promise<void>;
openBuy(options?: OnRampOptions): Promise<void>;
sendRpc<T>(rpcPayload: JsonRpcRequestPayload): Promise<JsonRpcResponsePayload<T>['result']>;

@@ -179,0 +195,0 @@ decodeData(serializedTx: string, abi: string[]): Promise<{

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

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

@@ -35,2 +35,3 @@ import { Face, Network, NotificationOptions } from './face';

openHome(options?: HomeOptions): Promise<void>;
openBuy(options?: OnRampOptions): Promise<void>;
sendRpc<T>(rpcPayload: JsonRpcRequestPayload): Promise<JsonRpcResponsePayload<T>['result']>;

@@ -37,0 +38,0 @@ decodeData(serializedTx: string, abi: string[]): Promise<{

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

export declare const getEthlikeChainIdFromNetwork: (network: Network) => string | 0;
export declare function isEveryNetworkOnSameEnv(networks: Network[]): boolean;
//# sourceMappingURL=utils.d.ts.map

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

import { HomeOptions } from '@haechi-labs/face-types';
import { Blockchain, HomeOptions } from '@haechi-labs/face-types';
import { Internal } from './internal';

@@ -11,3 +11,18 @@ /**

home(options?: HomeOptions): Promise<void>;
/**
* Open onRamp(MoonPay) modal for the passed blockchains
*
* @method
* @returns {Promise<void>}
*/
onRamp(blockchains: Blockchain[]): Promise<void>;
/**
* Open onRamp(MoonPay) modal for the token
* Contract address for platform coin like ETH, MATIC is '0x0'
*
* @method
* @returns {Promise<void>}
*/
onRampToken(blockchain: Blockchain, contractAddress: string, coinAmount?: number): Promise<void>;
}
//# sourceMappingURL=wallet.d.ts.map
{
"name": "@haechi-labs/face-sdk",
"version": "1.10.13",
"version": "1.10.14",
"description": "",

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

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

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

},
"gitHead": "04244316427e8896c43b2c2174ba1f4fdb911c8c",
"gitHead": "a7387e258a1fe11df87b9ffeb2233c2e9c8b14c6",
"publishConfig": {

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

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

LoginWithIdTokenRequest,
OnRampOptions,
ProviderRpcError,

@@ -33,2 +34,3 @@ } from '@haechi-labs/face-types';

getNetwork,
isEveryNetworkOnSameEnv,
isMainnet,

@@ -234,7 +236,4 @@ } from './utils';

const isCurrentNetworkMainnet = isMainnet(this.network);
if (
options?.networks &&
options.networks.some((network) => isMainnet(network) !== isCurrentNetworkMainnet)
) {
if (!isEveryNetworkOnSameEnv([...(options?.networks ?? []), this.network])) {
const isCurrentNetworkMainnet = isMainnet(this.network);
const message = `You initialized the Face SDK with ${

@@ -253,2 +252,10 @@ isCurrentNetworkMainnet ? 'Mainnet' : 'Testnet'

async openBuy(options?: OnRampOptions): Promise<void> {
const requestId = await this.iframe.sendChildMessage({
method: JsonRpcMethod.face_openBuy,
params: [options],
});
return this.iframe.waitForResponse(requestId);
}
async sendRpc<T>(

@@ -255,0 +262,0 @@ rpcPayload: JsonRpcRequestPayload

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

case Network.YOOLDO_VERSE:
case Network.MCH_VERSE:
return true;

@@ -77,2 +78,5 @@ default:

return Blockchain.OASYS;
case Network.MCH_VERSE:
case Network.MCH_VERSE_TESTNET:
return Blockchain.MCH_VERSE;
default:

@@ -124,3 +128,4 @@ return Blockchain.ETHEREUM;

network === Network.SAND_VERSE ||
network === Network.OASYS_TESTNET
network === Network.OASYS_TESTNET ||
network === Network.MCH_VERSE_TESTNET
) {

@@ -171,1 +176,8 @@ return Env.ProdTest;

};
export function isEveryNetworkOnSameEnv(networks: Network[]) {
return (
networks.every((network) => isMainnet(network)) ||
networks.every((network) => !isMainnet(network))
);
}

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

import { assertArgument, HomeOptions } from '@haechi-labs/face-types';
import { assertArgument, Blockchain, HomeOptions } from '@haechi-labs/face-types';

@@ -24,2 +24,33 @@ import { Internal } from './internal';

}
/**
* Open onRamp(MoonPay) modal for the passed blockchains
*
* @method
* @returns {Promise<void>}
*/
async onRamp(blockchains: Blockchain[]) {
assertArgument(
blockchains,
blockchains.length > 0 && blockchains.every((b) => Blockchain[b]),
'blockchains'
);
return this.internal.openBuy({ blockchains });
}
/**
* Open onRamp(MoonPay) modal for the token
* Contract address for platform coin like ETH, MATIC is '0x0'
*
* @method
* @returns {Promise<void>}
*/
async onRampToken(blockchain: Blockchain, contractAddress: string, coinAmount?: number) {
assertArgument(blockchain, Blockchain[blockchain], 'blockchain');
assertArgument(contractAddress, contractAddress, 'contractAddress');
assertArgument(coinAmount, coinAmount && coinAmount > 0, 'coinAmount', false);
return this.internal.openBuy({ blockchains: [blockchain], contractAddress, coinAmount });
}
}

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

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