@dcl/governance-site 1.15.1-20105651460.commit-7620061 → 1.15.1-20473093943.commit-ad8dc42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import{n as g,X as w,Y as y,Z as A,c as k,_ as u,B as m,A as p}from"./core-85d4a2c0.js";import"./index-6c5c6262.js";import"./index-f10062b6.js";class N{constructor(e){this.getNonce=e.getNonce}async createMessage(e){const t={accountAddress:e.accountAddress,chainId:e.chainId,version:"1",domain:typeof document>"u"?"Unknown Domain":document.location.host,uri:typeof document>"u"?"Unknown URI":document.location.href,resources:this.resources,nonce:await this.getNonce(e),issuedAt:this.stringifyDate(new Date),statement:void 0,expirationTime:void 0,notBefore:void 0};return Object.assign(t,{toString:()=>this.stringify(t)})}stringify(e){var n;const t=this.getNetworkName(e.chainId);return[`${e.domain} wants you to sign in with your ${t} account:`,e.accountAddress,e.statement?`
1
+ import{n as g,X as w,Y as y,Z as m,c as k,_ as u,B as p,A}from"./core-0c13d1dd.js";import"./index-726bc846.js";import"./index-37d53923.js";import"./index-c2e969f4.js";class N{constructor(e){this.getNonce=e.getNonce}async createMessage(e){const t={accountAddress:e.accountAddress,chainId:e.chainId,version:"1",domain:typeof document>"u"?"Unknown Domain":document.location.host,uri:typeof document>"u"?"Unknown URI":document.location.href,resources:this.resources,nonce:await this.getNonce(e),issuedAt:this.stringifyDate(new Date),statement:void 0,expirationTime:void 0,notBefore:void 0};return Object.assign(t,{toString:()=>this.stringify(t)})}stringify(e){var n;const t=this.getNetworkName(e.chainId);return[`${e.domain} wants you to sign in with your ${t} account:`,e.accountAddress,e.statement?`
2
2
  ${e.statement}
3
3
  `:"",`URI: ${e.uri}`,`Version: ${e.version}`,`Chain ID: ${e.chainId}`,`Nonce: ${e.nonce}`,e.issuedAt&&`Issued At: ${e.issuedAt}`,e.expirationTime&&`Expiration Time: ${e.expirationTime}`,e.notBefore&&`Not Before: ${e.notBefore}`,e.requestId&&`Request ID: ${e.requestId}`,((n=e.resources)==null?void 0:n.length)&&e.resources.reduce((s,o)=>`${s}
4
4
  - ${o}`,"Resources:")].filter(s=>typeof s=="string").join(`
5
- `).trim()}getNetworkName(e){const t=g.getAllRequestedCaipNetworks();return w.getNetworkNameByCaipNetworkId(t,e)}stringifyDate(e){return e.toISOString()}}class K{constructor(e={}){this.otpUuid=null,this.listeners={sessionChanged:[]},this.localAuthStorageKey=e.localAuthStorageKey||y.SIWX_AUTH_TOKEN,this.localNonceStorageKey=e.localNonceStorageKey||y.SIWX_NONCE_TOKEN,this.required=e.required??!0,this.messenger=new N({getNonce:this.getNonce.bind(this)})}async createMessage(e){return this.messenger.createMessage(e)}async addSession(e){const t=await this.request({method:"POST",key:"authenticate",body:{data:e.data,message:e.message,signature:e.signature,clientId:this.getClientId(),walletInfo:this.getWalletInfo()},headers:["nonce","otp"]});this.setStorageToken(t.token,this.localAuthStorageKey),this.emit("sessionChanged",e),this.setAppKitAccountUser(I(t.token)),this.otpUuid=null}async getSessions(e,t){try{if(!this.getStorageToken(this.localAuthStorageKey))return[];const n=await this.request({method:"GET",key:"me",query:{},headers:["auth"]});if(!n)return[];const s=n.address.toLowerCase()===t.toLowerCase(),o=n.caip2Network===e;if(!s||!o)return[];const r={data:{accountAddress:n.address,chainId:n.caip2Network},message:"",signature:""};return this.emit("sessionChanged",r),this.setAppKitAccountUser(n),[r]}catch{return[]}}async revokeSession(e,t){return Promise.resolve(this.clearStorageTokens())}async setSessions(e){if(e.length===0)this.clearStorageTokens();else{const t=e.find(n=>{var s;return n.data.chainId===((s=A())==null?void 0:s.caipNetworkId)})||e[0];await this.addSession(t)}}getRequired(){return this.required}async getSessionAccount(){if(!this.getStorageToken(this.localAuthStorageKey))throw new Error("Not authenticated");return this.request({method:"GET",key:"me",body:void 0,query:{includeAppKitAccount:!0},headers:["auth"]})}async setSessionAccountMetadata(e=null){if(!this.getStorageToken(this.localAuthStorageKey))throw new Error("Not authenticated");return this.request({method:"PUT",key:"account-metadata",body:{metadata:e},headers:["auth"]})}on(e,t){return this.listeners[e].push(t),()=>{this.listeners[e]=this.listeners[e].filter(n=>n!==t)}}removeAllListeners(){Object.keys(this.listeners).forEach(t=>{this.listeners[t]=[]})}async requestEmailOtp({email:e,account:t}){const n=await this.request({method:"POST",key:"otp",body:{email:e,account:t}});return this.otpUuid=n.uuid,this.messenger.resources=[`email:${e}`],n}confirmEmailOtp({code:e}){return this.request({method:"PUT",key:"otp",body:{code:e},headers:["otp"]})}async request({method:e,key:t,query:n,body:s,headers:o}){var f;const{projectId:r,st:h,sv:S}=this.getSDKProperties(),a=new URL(`${k.W3M_API_URL}/auth/v1/${String(t)}`);a.searchParams.set("projectId",r),a.searchParams.set("st",h),a.searchParams.set("sv",S),n&&Object.entries(n).forEach(([i,l])=>a.searchParams.set(i,String(l)));const c=await fetch(a,{method:e,body:s?JSON.stringify(s):void 0,headers:Array.isArray(o)?o.reduce((i,l)=>{switch(l){case"nonce":i["x-nonce-jwt"]=`Bearer ${this.getStorageToken(this.localNonceStorageKey)}`;break;case"auth":i.Authorization=`Bearer ${this.getStorageToken(this.localAuthStorageKey)}`;break;case"otp":this.otpUuid&&(i["x-otp"]=this.otpUuid);break}return i},{}):void 0});if(!c.ok)throw new Error(await c.text());return(f=c.headers.get("content-type"))!=null&&f.includes("application/json")?c.json():null}getStorageToken(e){return u.getItem(e)}setStorageToken(e,t){u.setItem(t,e)}clearStorageTokens(){this.otpUuid=null,u.removeItem(this.localAuthStorageKey),u.removeItem(this.localNonceStorageKey),this.emit("sessionChanged",void 0)}async getNonce(){const{nonce:e,token:t}=await this.request({method:"GET",key:"nonce"});return this.setStorageToken(t,this.localNonceStorageKey),e}getClientId(){return m.state.clientId}getWalletInfo(){var o;const e=(o=g.getAccountData())==null?void 0:o.connectedWalletInfo;if(!e)return;if("social"in e&&"identifier"in e){const r=e.social,h=e.identifier;return{type:"social",social:r,identifier:h}}const{name:t,icon:n}=e;let s="unknown";switch(e.type){case"EXTERNAL":case"INJECTED":case"ANNOUNCED":s="extension";break;case"WALLET_CONNECT":s="walletconnect";break;default:s="unknown"}return{type:s,name:t,icon:n}}getSDKProperties(){return p._getSdkProperties()}emit(e,t){this.listeners[e].forEach(n=>n(t))}setAppKitAccountUser(e){const{email:t}=e;t&&Object.values(k.CHAIN).forEach(n=>{g.setAccountProp("user",{email:t},n)})}}function I(d){const e=d.split(".");if(e.length!==3)throw new Error("Invalid token");const t=e[1];if(typeof t!="string")throw new Error("Invalid token");const n=t.replace(/-/gu,"+").replace(/_/gu,"/"),s=n.padEnd(n.length+(4-n.length%4)%4,"=");return JSON.parse(atob(s))}export{K as ReownAuthentication,N as ReownAuthenticationMessenger};
5
+ `).trim()}getNetworkName(e){const t=g.getAllRequestedCaipNetworks();return w.getNetworkNameByCaipNetworkId(t,e)}stringifyDate(e){return e.toISOString()}}class U{constructor(e={}){this.otpUuid=null,this.listeners={sessionChanged:[]},this.localAuthStorageKey=e.localAuthStorageKey||y.SIWX_AUTH_TOKEN,this.localNonceStorageKey=e.localNonceStorageKey||y.SIWX_NONCE_TOKEN,this.required=e.required??!0,this.messenger=new N({getNonce:this.getNonce.bind(this)})}async createMessage(e){return this.messenger.createMessage(e)}async addSession(e){const t=await this.request({method:"POST",key:"authenticate",body:{data:e.data,message:e.message,signature:e.signature,clientId:this.getClientId(),walletInfo:this.getWalletInfo()},headers:["nonce","otp"]});this.setStorageToken(t.token,this.localAuthStorageKey),this.emit("sessionChanged",e),this.setAppKitAccountUser(I(t.token)),this.otpUuid=null}async getSessions(e,t){try{if(!this.getStorageToken(this.localAuthStorageKey))return[];const n=await this.request({method:"GET",key:"me",query:{},headers:["auth"]});if(!n)return[];const s=n.address.toLowerCase()===t.toLowerCase(),o=n.caip2Network===e;if(!s||!o)return[];const r={data:{accountAddress:n.address,chainId:n.caip2Network},message:"",signature:""};return this.emit("sessionChanged",r),this.setAppKitAccountUser(n),[r]}catch{return[]}}async revokeSession(e,t){return Promise.resolve(this.clearStorageTokens())}async setSessions(e){if(e.length===0)this.clearStorageTokens();else{const t=e.find(n=>{var s;return n.data.chainId===((s=m())==null?void 0:s.caipNetworkId)})||e[0];await this.addSession(t)}}getRequired(){return this.required}async getSessionAccount(){if(!this.getStorageToken(this.localAuthStorageKey))throw new Error("Not authenticated");return this.request({method:"GET",key:"me",body:void 0,query:{includeAppKitAccount:!0},headers:["auth"]})}async setSessionAccountMetadata(e=null){if(!this.getStorageToken(this.localAuthStorageKey))throw new Error("Not authenticated");return this.request({method:"PUT",key:"account-metadata",body:{metadata:e},headers:["auth"]})}on(e,t){return this.listeners[e].push(t),()=>{this.listeners[e]=this.listeners[e].filter(n=>n!==t)}}removeAllListeners(){Object.keys(this.listeners).forEach(t=>{this.listeners[t]=[]})}async requestEmailOtp({email:e,account:t}){const n=await this.request({method:"POST",key:"otp",body:{email:e,account:t}});return this.otpUuid=n.uuid,this.messenger.resources=[`email:${e}`],n}confirmEmailOtp({code:e}){return this.request({method:"PUT",key:"otp",body:{code:e},headers:["otp"]})}async request({method:e,key:t,query:n,body:s,headers:o}){var f;const{projectId:r,st:h,sv:S}=this.getSDKProperties(),a=new URL(`${k.W3M_API_URL}/auth/v1/${String(t)}`);a.searchParams.set("projectId",r),a.searchParams.set("st",h),a.searchParams.set("sv",S),n&&Object.entries(n).forEach(([i,l])=>a.searchParams.set(i,String(l)));const c=await fetch(a,{method:e,body:s?JSON.stringify(s):void 0,headers:Array.isArray(o)?o.reduce((i,l)=>{switch(l){case"nonce":i["x-nonce-jwt"]=`Bearer ${this.getStorageToken(this.localNonceStorageKey)}`;break;case"auth":i.Authorization=`Bearer ${this.getStorageToken(this.localAuthStorageKey)}`;break;case"otp":this.otpUuid&&(i["x-otp"]=this.otpUuid);break}return i},{}):void 0});if(!c.ok)throw new Error(await c.text());return(f=c.headers.get("content-type"))!=null&&f.includes("application/json")?c.json():null}getStorageToken(e){return u.getItem(e)}setStorageToken(e,t){u.setItem(t,e)}clearStorageTokens(){this.otpUuid=null,u.removeItem(this.localAuthStorageKey),u.removeItem(this.localNonceStorageKey),this.emit("sessionChanged",void 0)}async getNonce(){const{nonce:e,token:t}=await this.request({method:"GET",key:"nonce"});return this.setStorageToken(t,this.localNonceStorageKey),e}getClientId(){return p.state.clientId}getWalletInfo(){var o;const e=(o=g.getAccountData())==null?void 0:o.connectedWalletInfo;if(!e)return;if("social"in e&&"identifier"in e){const r=e.social,h=e.identifier;return{type:"social",social:r,identifier:h}}const{name:t,icon:n}=e;let s="unknown";switch(e.type){case"EXTERNAL":case"INJECTED":case"ANNOUNCED":s="extension";break;case"WALLET_CONNECT":s="walletconnect";break;default:s="unknown"}return{type:s,name:t,icon:n}}getSDKProperties(){return A._getSdkProperties()}emit(e,t){this.listeners[e].forEach(n=>n(t))}setAppKitAccountUser(e){const{email:t}=e;t&&Object.values(k.CHAIN).forEach(n=>{g.setAccountProp("user",{email:t},n)})}}function I(d){const e=d.split(".");if(e.length!==3)throw new Error("Invalid token");const t=e[1];if(typeof t!="string")throw new Error("Invalid token");const n=t.replace(/-/gu,"+").replace(/_/gu,"/"),s=n.padEnd(n.length+(4-n.length%4)%4,"=");return JSON.parse(atob(s))}export{U as ReownAuthentication,N as ReownAuthenticationMessenger};
@@ -0,0 +1,13 @@
1
+ import{bD as Z}from"./index-726bc846.js";function $(h,y){for(var a=0;a<y.length;a++){const r=y[a];if(typeof r!="string"&&!Array.isArray(r)){for(const o in r)if(o!=="default"&&!(o in h)){const u=Object.getOwnPropertyDescriptor(r,o);u&&Object.defineProperty(h,o,u.get?u:{enumerable:!0,get:()=>r[o]})}}}return Object.freeze(Object.defineProperty(h,Symbol.toStringTag,{value:"Module"}))}var z=function(h){var y={};function a(r){if(y[r])return y[r].exports;var o=y[r]={i:r,l:!1,exports:{}};return h[r].call(o.exports,o,o.exports,a),o.l=!0,o.exports}return a.m=h,a.c=y,a.d=function(r,o,u){a.o(r,o)||Object.defineProperty(r,o,{enumerable:!0,get:u})},a.r=function(r){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},a.t=function(r,o){if(1&o&&(r=a(r)),8&o||4&o&&typeof r=="object"&&r&&r.__esModule)return r;var u=Object.create(null);if(a.r(u),Object.defineProperty(u,"default",{enumerable:!0,value:r}),2&o&&typeof r!="string")for(var l in r)a.d(u,l,(function(R){return r[R]}).bind(null,l));return u},a.n=function(r){var o=r&&r.__esModule?function(){return r.default}:function(){return r};return a.d(o,"a",o),o},a.o=function(r,o){return Object.prototype.hasOwnProperty.call(r,o)},a.p="",a(a.s=3)}([function(h,y){h.exports=function(a){return a&&a.__esModule?a:{default:a}}},function(h,y){h.exports=function(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}},function(h,y,a){function r(){return Math.floor(9e4*Math.random())+1e4}Object.defineProperty(y,"__esModule",{value:!0}),y.sendAsyncWrapper=function(o,u){var l=this;return new Promise(function(R,x){l.sendAsync({jsonrpc:"2.0",id:r(),method:o,params:u||[]},function(O,T){O?x(O):R(T.result)})})},y.sendFortmaticAsyncWrapper=function(o){var u=this;return new Promise(function(l,R){u.getProvider().sendFortmaticAsync(o,function(x,O){x?R(x):l(O?O.result:{})})})},y.randomId=r,y.findExistingResponse=function(o,u){for(var l=0;l<o.length;l++)if(o[l].id===u)return o[l];return null}},function(h,y,a){h.exports=a(4)},function(h,y,a){var r=a(0),o=r(a(1)),u=r(a(5)),l=a(2),R="fm_composeSend",x="fm_logout",O="fm_get_balances",T="fm_get_transactions",w="fm_is_logged_in",P="fm_accountSettings",n="fm_deposit",s="fm_get_user",c="fm_configure",f={};h.exports=function b(_,A,I){var v=this;if((0,o.default)(this,b),this.fortmaticClient="https://x2.fortmatic.com",!_)throw new Error("Please provide a Fortmatic API key that you acquired from the developer dashboard.");this.apiKey=_,this.options=I,this.ethNetwork=A,this.queryParams=btoa(JSON.stringify({API_KEY:_,ETH_NETWORK:A})),this.transactions={send:function(m,M){var C=new g(R,{to:m.to,value:m.amount});v.getProvider().sendFortmaticAsync(C,M)}},this.getProvider=function(){return f["fortmatic-".concat(v.queryParams)]||(f["fortmatic-".concat(v.queryParams)]=new u.default(v.fortmaticClient,{API_KEY:_,ETH_NETWORK:A})),f["fortmatic-".concat(v.queryParams)]},this.user={login:function(){return v.getProvider().enable()},logout:function(){v.getProvider().account=null,v.getProvider().network=null;var m=new g(x);return l.sendFortmaticAsyncWrapper.call(v,m)},getUser:function(){var m=new g(s);return l.sendFortmaticAsyncWrapper.call(v,m)},getBalances:function(){var m=new g(O);return l.sendFortmaticAsyncWrapper.call(v,m)},getTransactions:function(){var m=new g(T);return l.sendFortmaticAsyncWrapper.call(v,m)},isLoggedIn:function(){var m=new g(w);return l.sendFortmaticAsyncWrapper.call(v,m)},settings:function(){var m=new g(P);return l.sendFortmaticAsyncWrapper.call(v,m)},deposit:function(m){var M=new g(n,m);return l.sendFortmaticAsyncWrapper.call(v,M)}},this.configure=function(){var m=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},M=new g(c);return M.params=[m],l.sendFortmaticAsyncWrapper.call(v,M)}};var g=function b(_,A){(0,o.default)(this,b),this.id=(0,l.randomId)(),this.method=_,this.params=A?[A]:[{}]}},function(h,y,a){var r=a(0);Object.defineProperty(y,"__esModule",{value:!0}),y.default=void 0;var o=r(a(6)),u=r(a(9)),l=r(a(1)),R=r(a(10)),x=a(11),O=r(a(12)),T=a(2),w=function(){function P(n,s){if((0,l.default)(this,P),this.fortmaticClient=n,this.requests={},this.queue=[],this.account=null,this.network=null,this.isFortmatic=!0,this.overlayReady=!1,this.isLoggedIn=!1,this.postMessages={FORTMATIC_HANDLE_BATCH_REQUEST:"FORTMATIC_HANDLE_BATCH_REQUEST",FORTMATIC_HANDLE_REQUEST:"FORTMATIC_HANDLE_REQUEST",FORTMATIC_HANDLE_FORTMATIC_REQUEST:"FORTMATIC_HANDLE_FORTMATIC_REQUEST",FORTMATIC_HANDLE_RESPONSE:"FORTMATIC_HANDLE_RESPONSE",FORTMATIC_OVERLAY_READY:"FORTMATIC_OVERLAY_READY",FORTMATIC_SHOW_OVERLAY:"FORTMATIC_SHOW_OVERLAY",FORTMATIC_HIDE_OVERLAY:"FORTMATIC_HIDE_OVERLAY",FORTMATIC_USER_DENIED:"FORTMATIC_USER_DENIED",FORTMATIC_USER_LOGOUT:"FORTMATIC_USER_LOGOUT",FORTMATIC_UNAUTHORIZED_API_KEY:"FORTMATIC_UNAUTHORIZED_API_KEY"},!s.API_KEY)throw new Error("Please provide a Fortmatic API key that you acquired from the developer dashboard.");this.options={API_KEY:s.API_KEY,ETH_NETWORK:s.ETH_NETWORK,DOMAIN_ORIGIN:window.location?window.location.origin:"",version:x.version},this.queryParams=btoa(JSON.stringify(this.options)),this.constructPostMessage(),this.overlay=this.createOverlay(),this.listenMessage()}return(0,R.default)(P,[{key:"constructPostMessage",value:function(){var n=this;Object.keys(this.postMessages).map(function(s){n.postMessages[s]+="-".concat(n.queryParams)})}},{key:"createOverlay",value:function(){var n=this;return new Promise(function(s,c){var f=function(){if(function(){var A=!0,I=!1,v=void 0;try{for(var m,M=document.getElementsByClassName("fortmatic-iframe")[Symbol.iterator]();!(A=(m=M.next()).done);A=!0)if(m.value.src.includes(n.queryParams))return!1}catch(C){I=!0,v=C}finally{try{A||M.return==null||M.return()}finally{if(I)throw v}}return!0}()){var g=document.createElement("style");g.innerHTML=O.default.css,g.type="text/css",document.head.appendChild(g);var b=document.createElement("iframe");b.className="fortmatic-iframe",b.src="".concat(n.fortmaticClient,"/send?params=").concat(n.queryParams),document.body.appendChild(b);var _=document.createElement("img");_.src="https://static.fortmatic.com/assets/trans.gif",document.body.appendChild(_),s({iframe:b})}else console.error("Fortmatic: Duplicate instances found.")};["loaded","interactive","complete"].indexOf(document.readyState)>-1?f():window.addEventListener("load",f.bind(n),!1)})}},{key:"showOverlay",value:function(){var n=(0,u.default)(o.default.mark(function s(){return o.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,this.overlay;case 2:c.sent.iframe.style.display="block";case 4:case"end":return c.stop()}},s,this)}));return function(){return n.apply(this,arguments)}}()},{key:"hideOverlay",value:function(){var n=(0,u.default)(o.default.mark(function s(){return o.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,this.overlay;case 2:c.sent.iframe.style.display="none";case 4:case"end":return c.stop()}},s,this)}));return function(){return n.apply(this,arguments)}}()},{key:"sendAsync",value:function(n,s){n.length>0?this.enqueue({payload:{id:(0,T.randomId)(),batch:n.map(function(c){return c.id=(0,T.randomId)(),c}),method:"eth_batchRequest"},cb:s}):this.enqueue({payload:n,cb:s})}},{key:"sendFortmaticAsync",value:function(n,s){this.enqueue({payload:n,cb:s,isNative:!0})}},{key:"send",value:function(n,s){if(typeof n=="string")return T.sendAsyncWrapper.call(this,n,s);if(!s){console.warn("Non-async web3 methods will be deprecated in web3 > 1.0, and are not supported by the Fortmatic provider. An async method to be used instead."),this.sendAsync(n,function(){});var c={};switch(n.method){case"eth_accounts":c=this.account?[this.account]:[];break;case"eth_coinbase":c=this.account;break;case"net_version":c=this.network||(this.options.API_KEY.startsWith("pk_live")?1:4);break;case"eth_uninstallFilter":c=!0;break;default:c={}}return{id:n.id,jsonrpc:n.jsonrpc,result:c}}this.sendAsync(n,s)}},{key:"enqueue",value:function(n){this.queue.push(n),this.overlayReady&&this.dequeue()}},{key:"dequeue",value:function(){var n=(0,u.default)(o.default.mark(function s(){var c,f,g,b=this;return o.default.wrap(function(_){for(;;)switch(_.prev=_.next){case 0:if(this.queue.length!==0){_.next=2;break}return _.abrupt("return");case 2:if(!(c=this.queue.shift())){_.next=11;break}return f=c.payload,g=c.cb,f.id=(0,T.randomId)(),_.next=9,this.postMessage(c.isNative?this.postMessages.FORTMATIC_HANDLE_FORTMATIC_REQUEST:this.postMessages.FORTMATIC_HANDLE_REQUEST,c.payload);case 9:f.batch&&f.batch.length>0?(f.batch.forEach(function(A){b.requests[A.id]={parentId:f.id,payload:A,cb:function(I,v){var m=b.requests[f.id].batchResponse;if(I&&I.response&&!(0,T.findExistingResponse)(m,I.response.id))throw m.push({jsonrpc:"2.0",id:I.response.id,error:{code:I.response.code,message:I.response.message}}),b.requests[f.id].cb(null,m),I.response;if(v&&v.result&&!(0,T.findExistingResponse)(m,v.id))return m.push(v);throw new Error("Fortmatic: unexpected callback behavior")}}}),this.requests[f.id]={payload:f,cb:g,batchResponse:[]}):this.requests[f.id]={payload:f,cb:g},this.dequeue();case 11:case"end":return _.stop()}},s,this)}));return function(){return n.apply(this,arguments)}}()},{key:"postMessage",value:function(){var n=(0,u.default)(o.default.mark(function s(c,f){var g;return o.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this.overlay;case 2:if(!(g=b.sent).iframe.contentWindow){b.next=7;break}g.iframe.contentWindow.postMessage({msgType:c,payload:f},"*"),b.next=8;break;case 7:throw new Error("Fortmatic: Modal is not ready.");case 8:case"end":return b.stop()}},s,this)}));return function(s,c){return n.apply(this,arguments)}}()},{key:"enable",value:function(){return T.sendAsyncWrapper.call(this,"eth_accounts")}},{key:"listenMessage",value:function(){var n=this;window.addEventListener("message",function(s){if(s.origin===n.fortmaticClient){var c=s.data.response?s.data.response.id:null;switch(s.data.msgType){case n.postMessages.FORTMATIC_OVERLAY_READY:n.overlayReady=!0,n.dequeue();break;case n.postMessages.FORTMATIC_HANDLE_RESPONSE:try{n.requests[c].cb(null,s.data.response);var f=n.requests[c].parentId;f&&n.requests[f].payload.batch.length===n.requests[f].batchResponse.length&&n.requests[f].cb(null,n.requests[f].batchResponse),n.requests[c].payload.method==="eth_accounts"?n.account=s.data.response.result[0]:n.requests[c].payload.method==="eth_coinbase"?n.account=s.data.response.result:n.requests[c].payload.method==="net_version"&&(n.network=s.data.response.result)}catch{}n.isLoggedIn=!0,n.dequeue();break;case n.postMessages.FORTMATIC_HIDE_OVERLAY:n.hideOverlay();break;case n.postMessages.FORTMATIC_SHOW_OVERLAY:n.showOverlay();break;case n.postMessages.FORTMATIC_USER_LOGOUT:n.account=null,n.network=null,n.isLoggedIn=!1;break;case n.postMessages.FORTMATIC_UNAUTHORIZED_API_KEY:throw n.overlayReady=!1,new Error("Given API key is not authorized to access the resource.");case n.postMessages.FORTMATIC_USER_DENIED:if(c){var g=s.data.response&&s.data.response.message?s.data.response.message:"Fortmatic: Modal was closed without executing action!",b=s.data.response&&s.data.response.code?s.data.response.code:1;n.requests[c].cb({message:g,code:b,response:s.data.response})}else n.queue.forEach(function(_){return _.cb({message:"Fortmatic: Modal was closed without executing action!",code:1})});n.dequeue()}}})}}]),P}();y.default=w},function(h,y,a){h.exports=a(7)},function(h,y,a){var r=function(){return this||typeof self=="object"&&self}()||Function("return this")(),o=r.regeneratorRuntime&&Object.getOwnPropertyNames(r).indexOf("regeneratorRuntime")>=0,u=o&&r.regeneratorRuntime;if(r.regeneratorRuntime=void 0,h.exports=a(8),o)r.regeneratorRuntime=u;else try{delete r.regeneratorRuntime}catch{r.regeneratorRuntime=void 0}},function(h,y){(function(a){var r,o=Object.prototype,u=o.hasOwnProperty,l=typeof Symbol=="function"?Symbol:{},R=l.iterator||"@@iterator",x=l.asyncIterator||"@@asyncIterator",O=l.toStringTag||"@@toStringTag",T=typeof h=="object",w=a.regeneratorRuntime;if(w)T&&(h.exports=w);else{(w=a.regeneratorRuntime=T?h.exports:{}).wrap=I;var P="suspendedStart",n="suspendedYield",s="executing",c="completed",f={},g={};g[R]=function(){return this};var b=Object.getPrototypeOf,_=b&&b(b(G([])));_&&_!==o&&u.call(_,R)&&(g=_);var A=C.prototype=m.prototype=Object.create(g);M.prototype=A.constructor=C,C.constructor=M,C[O]=M.displayName="GeneratorFunction",w.isGeneratorFunction=function(t){var e=typeof t=="function"&&t.constructor;return!!e&&(e===M||(e.displayName||e.name)==="GeneratorFunction")},w.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,C):(t.__proto__=C,O in t||(t[O]="GeneratorFunction")),t.prototype=Object.create(A),t},w.awrap=function(t){return{__await:t}},V(U.prototype),U.prototype[x]=function(){return this},w.AsyncIterator=U,w.async=function(t,e,d,p){var i=new U(I(t,e,d,p));return w.isGeneratorFunction(e)?i:i.next().then(function(F){return F.done?F.value:i.next()})},V(A),A[O]="Generator",A[R]=function(){return this},A.toString=function(){return"[object Generator]"},w.keys=function(t){var e=[];for(var d in t)e.push(d);return e.reverse(),function p(){for(;e.length;){var i=e.pop();if(i in t)return p.value=i,p.done=!1,p}return p.done=!0,p}},w.values=G,K.prototype={constructor:K,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=r,this.done=!1,this.delegate=null,this.method="next",this.arg=r,this.tryEntries.forEach(Y),!t)for(var e in this)e.charAt(0)==="t"&&u.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=r)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if(t.type==="throw")throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function d(W,E){return F.type="throw",F.arg=t,e.next=W,E&&(e.method="next",e.arg=r),!!E}for(var p=this.tryEntries.length-1;p>=0;--p){var i=this.tryEntries[p],F=i.completion;if(i.tryLoc==="root")return d("end");if(i.tryLoc<=this.prev){var j=u.call(i,"catchLoc"),q=u.call(i,"finallyLoc");if(j&&q){if(this.prev<i.catchLoc)return d(i.catchLoc,!0);if(this.prev<i.finallyLoc)return d(i.finallyLoc)}else if(j){if(this.prev<i.catchLoc)return d(i.catchLoc,!0)}else{if(!q)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return d(i.finallyLoc)}}}},abrupt:function(t,e){for(var d=this.tryEntries.length-1;d>=0;--d){var p=this.tryEntries[d];if(p.tryLoc<=this.prev&&u.call(p,"finallyLoc")&&this.prev<p.finallyLoc){var i=p;break}}i&&(t==="break"||t==="continue")&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var F=i?i.completion:{};return F.type=t,F.arg=e,i?(this.method="next",this.next=i.finallyLoc,f):this.complete(F)},complete:function(t,e){if(t.type==="throw")throw t.arg;return t.type==="break"||t.type==="continue"?this.next=t.arg:t.type==="return"?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):t.type==="normal"&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var d=this.tryEntries[e];if(d.finallyLoc===t)return this.complete(d.completion,d.afterLoc),Y(d),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var d=this.tryEntries[e];if(d.tryLoc===t){var p=d.completion;if(p.type==="throw"){var i=p.arg;Y(d)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,d){return this.delegate={iterator:G(t),resultName:e,nextLoc:d},this.method==="next"&&(this.arg=r),f}}}function I(t,e,d,p){var i=e&&e.prototype instanceof m?e:m,F=Object.create(i.prototype),j=new K(p||[]);return F._invoke=function(q,W,E){var L=P;return function(S,D){if(L===s)throw new Error("Generator is already running");if(L===c){if(S==="throw")throw D;return Q()}for(E.method=S,E.arg=D;;){var H=E.delegate;if(H){var N=B(H,E);if(N){if(N===f)continue;return N}}if(E.method==="next")E.sent=E._sent=E.arg;else if(E.method==="throw"){if(L===P)throw L=c,E.arg;E.dispatchException(E.arg)}else E.method==="return"&&E.abrupt("return",E.arg);L=s;var k=v(q,W,E);if(k.type==="normal"){if(L=E.done?c:n,k.arg===f)continue;return{value:k.arg,done:E.done}}k.type==="throw"&&(L=c,E.method="throw",E.arg=k.arg)}}}(t,d,j),F}function v(t,e,d){try{return{type:"normal",arg:t.call(e,d)}}catch(p){return{type:"throw",arg:p}}}function m(){}function M(){}function C(){}function V(t){["next","throw","return"].forEach(function(e){t[e]=function(d){return this._invoke(e,d)}})}function U(t){var e;this._invoke=function(d,p){function i(){return new Promise(function(F,j){(function q(W,E,L,S){var D=v(t[W],t,E);if(D.type!=="throw"){var H=D.arg,N=H.value;return N&&typeof N=="object"&&u.call(N,"__await")?Promise.resolve(N.__await).then(function(k){q("next",k,L,S)},function(k){q("throw",k,L,S)}):Promise.resolve(N).then(function(k){H.value=k,L(H)},function(k){return q("throw",k,L,S)})}S(D.arg)})(d,p,F,j)})}return e=e?e.then(i,i):i()}}function B(t,e){var d=t.iterator[e.method];if(d===r){if(e.delegate=null,e.method==="throw"){if(t.iterator.return&&(e.method="return",e.arg=r,B(t,e),e.method==="throw"))return f;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var p=v(d,t.iterator,e.arg);if(p.type==="throw")return e.method="throw",e.arg=p.arg,e.delegate=null,f;var i=p.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,e.method!=="return"&&(e.method="next",e.arg=r),e.delegate=null,f):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function J(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function Y(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function K(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(J,this),this.reset(!0)}function G(t){if(t){var e=t[R];if(e)return e.call(t);if(typeof t.next=="function")return t;if(!isNaN(t.length)){var d=-1,p=function i(){for(;++d<t.length;)if(u.call(t,d))return i.value=t[d],i.done=!1,i;return i.value=r,i.done=!0,i};return p.next=p}}return{next:Q}}function Q(){return{value:r,done:!0}}})(function(){return this||typeof self=="object"&&self}()||Function("return this")())},function(h,y){function a(r,o,u,l,R,x,O){try{var T=r[x](O),w=T.value}catch(P){return void u(P)}T.done?o(w):Promise.resolve(w).then(l,R)}h.exports=function(r){return function(){var o=this,u=arguments;return new Promise(function(l,R){var x=r.apply(o,u);function O(w){a(x,l,R,O,T,"next",w)}function T(w){a(x,l,R,O,T,"throw",w)}O(void 0)})}}},function(h,y){function a(r,o){for(var u=0;u<o.length;u++){var l=o[u];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(r,l.key,l)}}h.exports=function(r,o,u){return o&&a(r.prototype,o),u&&a(r,u),r}},function(h){h.exports={name:"fortmatic",version:"1.1.3",description:"Fortmatic Javascript SDK",main:"lib/fortmatic.js",scripts:{build:"WEBPACK_ENV=production webpack","build:dev":"WEBPACK_ENV=development BABEL_ENV=development webpack --progress --colors --watch",test:"nyc --reporter=lcov --reporter=text-summary ava"},author:"Fortmatic <team@fortmatic.com> (https://fortmatic.com/)",license:"MIT",repository:{type:"git",url:"https://github.com/fortmatic/fortmatic-js"},keywords:["Auth","Login","Web3","Crypto","Ethereum","MetaMask","Wallet","Blockchain","Dapp"],homepage:"https://www.fortmatic.com",ava:{require:["@babel/register"],files:["test/**/*.spec.js"],babel:{testOptions:{presets:["@babel/env"],plugins:["@babel/plugin-proposal-function-bind","@babel/plugin-transform-runtime"]}},verbose:!0},nyc:{all:!1,"check-coverage":!0,"per-file":!0,lines:80,statements:80,functions:80,branches:80,include:["src/**/*.js"],exclude:["*/style.js"],require:[],reporter:["html","lcov"]},dependencies:{"@babel/runtime":"7.3.4"},devDependencies:{"@babel/core":"7.3.4","@babel/plugin-proposal-function-bind":"7.2.0","@babel/plugin-transform-modules-commonjs":"7.2.0","@babel/plugin-transform-runtime":"7.3.4","@babel/preset-env":"7.3.4","@babel/register":"7.0.0",ava:"2.2.0","babel-eslint":"10.0.1","babel-loader":"8.0.5",eslint:"5.9.0",lodash:"4.17.11",nyc:"13.1.0",sinon:"7.1.1",webpack:"4.26.1","webpack-cli":"3.1.2"}}},function(h,y,a){y.css=`
2
+ .fortmatic-iframe {
3
+ display: none;
4
+ position: fixed;
5
+ top: 0;
6
+ right: 0;
7
+ width: 100%;
8
+ height: 100%;
9
+ border: none;
10
+ border-radius: 0;
11
+ z-index: 2147483647;
12
+ }
13
+ `}]);const X=Z(z),te=$({__proto__:null,default:X},[z]);export{te as f};