1"use strict";(self.webpackChunkmaxelpay_frontend=self.webpackChunkmaxelpay_frontend||[]).push([[3411],{46123(e,t,n){n.d(t,{u:()=>d});var s=n(25476),o=n(22856),r=n(15049),a=n(5211),i=n(49176),c=n(48656),u=n(24135);class h{constructor(e){this.getNonce=e.getNonce}async createMessage(e){const t={accountAddress:e.accountAddress,chainId:e.chainId,version:"1",domain:"undefined"===typeof document?"Unknown Domain":document.location.host,uri:"undefined"===typeof document?"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},n={toString:()=>this.stringify(t)};return Object.assign(t,n)}stringify(e){var t;const n=this.getNetworkName(e.chainId);return["".concat(e.domain," wants you to sign in with your ").concat(n," account:"),e.accountAddress,e.statement?"\n".concat(e.statement,"\n"):"","URI: ".concat(e.uri),"Version: ".concat(e.version),"Chain ID: ".concat(e.chainId),"Nonce: ".concat(e.nonce),e.issuedAt&&"Issued At: ".concat(e.issuedAt),e.expirationTime&&"Expiration Time: ".concat(e.expirationTime),e.notBefore&&"Not Before: ".concat(e.notBefore),e.requestId&&"Request ID: ".concat(e.requestId),(null===(t=e.resources)||void 0===t?void 0:t.length)&&e.resources.reduce((e,t)=>"".concat(e,"\n- ").concat(t),"Resources:")].filter(e=>"string"===typeof e).join("\n").trim()}getNetworkName(e){const t=i.W.getAllRequestedCaipNetworks();return u.L.getNetworkNameByCaipNetworkId(t,e)}stringifyDate(e){return e.toISOString()}}class d{constructor(){var e;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.otpUuid=null,this.listeners={sessionChanged:[]},this.localAuthStorageKey=t.localAuthStorageKey||s.Ws.SIWX_AUTH_TOKEN,this.localNonceStorageKey=t.localNonceStorageKey||s.Ws.SIWX_NONCE_TOKEN,this.required=null===(e=t.required)||void 0===e||e,this.messenger=new h({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(function(e){const t=e.split(".");if(3!==t.length)throw new Error("Invalid token");const n=t[1];if("string"!==typeof n)throw new Error("Invalid token");const s=n.replace(/-/g,"+").replace(/_/g,"/"),o=s.padEnd(s.length+(4-s.length%4)%4,"=");return JSON.parse(atob(o))}(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(n){return[]}}async revokeSession(e,t){return Promise.resolve(this.clearStorageTokens())}async setSessions(e){if(0===e.length)this.clearStorageTokens();else{const t=e.find(e=>{var t;return e.data.chainId===(null===(t=(0,c.kg)())||void 0===t?void 0:t.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(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]: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(e=>e!==t)}}removeAllListeners(){Object.keys(this.listeners).forEach(e=>{this.listeners[e]=[]})}async requestEmailOtp(e){let{email:t,account:n}=e;const s=await this.request({method:"POST",key:"otp",body:{email:t,account:n}});return this.otpUuid=s.uuid,this.messenger.resources=["email:".concat(t)],s}
1confirmEmailOtp(e){let{code:t}=e;return this.request({method:"PUT",key:"otp",body:{code:t},headers:["otp"]})}async request(e){var t;let{method:n,key:s,query:r,body:a,headers:i}=e;const{projectId:c,st:u,sv:h}=this.getSDKProperties(),d=new URL("".concat(o.o.W3M_API_URL,"/auth/v1/").concat(String(s)));d.searchParams.set("projectId",c),d.searchParams.set("st",u),d.searchParams.set("sv",h),r&&Object.entries(r).forEach(e=>{let[t,n]=e;return d.searchParams.set(t,String(n))});const l=await fetch(d,{method:n,body:a?JSON.stringify(a):void 0,headers:Array.isArray(i)?i.reduce((e,t)=>{switch(t){case"nonce":e["x-nonce-jwt"]="Bearer ".concat(this.getStorageToken(this.localNonceStorageKey));break;case"auth":e.Authorization="Bearer ".concat(this.getStorageToken(this.localAuthStorageKey));break;case"otp":this.otpUuid&&(e["x-otp"]=this.otpUuid)}return e},{}):void 0});if(!l.ok)throw new Error(await l.text());return null!==(t=l.headers.get("content-type"))&&void 0!==t&&t.includes("application/json")?l.json():null}getStorageToken(e){return s.Ud.getItem(e)}setStorageToken(e,t){s.Ud.setItem(t,e)}clearStorageTokens(){this.otpUuid=null,s.Ud.removeItem(this.localAuthStorageKey),s.Ud.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 a.T.state.clientId}getWalletInfo(){var e;const t=null===(e=i.W.getAccountData())||void 0===e?void 0:e.connectedWalletInfo;if(!t)return;if("social"in t&&"identifier"in t){return{type:"social",social:t.social,identifier:t.identifier}}const{name:n,icon:s}=t;let o="unknown";switch(t.type){case"EXTERNAL":case"INJECTED":case"ANNOUNCED":o="extension";break;case"WALLET_CONNECT":o="walletconnect";break;default:o="unknown"}return{type:o,name:n,icon:s}}getSDKProperties(){return r.N._getSdkProperties()}emit(e,t){this.listeners[e].forEach(e=>e(t))}setAppKitAccountUser(e){const{email:t}=e;
1t&&Object.values(o.o.CHAIN).forEach(e=>{i.W.setAccountProp("user",{email:t},e)})}}},93411(e,t,n){n.d(t,{ReownAuthentication:()=>s.u});var s=n(46123)}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.