1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6284],{52674:function(e,t,i){i.d(t,{z:function(){return ReownAuthentication}});var a=i(11191),r=i(45206),o=i(93922),n=i(43655),s=i(55532),l=i(1325),c=i(85047);let ReownAuthenticationMessenger=class ReownAuthenticationMessenger{constructor(e){this.getNonce=e.getNonce}async createMessage(e){let 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};return Object.assign(t,{toString:()=>this.stringify(t)})}stringify(e){let t=this.getNetworkName(e.chainId);return[`${e.domain} wants you to sign in with your ${t} account:`,e.accountAddress,e.statement?` 2${e.statement} 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}`,e.resources?.length&&e.resources.reduce((e,t)=>`${e} 4- ${t}`,"Resources:")].filter(e=>"string"==typeof e).join("\n").trim()}getNetworkName(e){let t=s.R.getAllRequestedCaipNetworks();return c.p.getNetworkNameByCaipNetworkId(t,e)}stringifyDate(e){return e.toISOString()}};let ReownAuthentication=class ReownAuthentication{constructor(e={}){this.otpUuid=null,this.listeners={sessionChanged:[]},this.localAuthStorageKey=e.localAuthStorageKey||a.uJ.SIWX_AUTH_TOKEN,this.localNonceStorageKey=e.localNonceStorageKey||a.uJ.SIWX_NONCE_TOKEN,this.required=e.required??!0,this.messenger=new ReownAuthenticationMessenger({getNonce:this.getNonce.bind(this)})}async createMessage(e){return this.messenger.createMessage(e)}async addSession(e){let 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){let t=e.split(".");if(3!==t.length)throw Error("Invalid token");let i=t[1];if("string"!=typeof i)throw Error("Invalid token");let a=i.replace(/-/gu,"+").replace(/_/gu,"/"),r=a.padEnd(a.length+(4-a.length%4)%4,"="),o=JSON.parse(atob(r));return o}(t.token)),this.otpUuid=null}async getSessions(e,t){try{if(!this.getStorageToken(this.localAuthStorageKey))return[];let i=await this.request({method:"GET",key:"me",query:{},headers:["auth"]});if(!i)return[];let a=i.address.toLowerCase()===t.toLowerCase(),r=i.caip2Network===e;if(!a||!r)return[];let o={data:{accountAddress:i.address,chainId:i.caip2Network},message:"",signature:""};return this.emit("sessionChanged",o),this.setAppKitAccountUser(i),[o]}catch{return[]}}async revokeSession(e,t){return Promise.resolve(this.clearStorageTokens())}async setSessions(e){if(0===e.length)this.clearStorageTokens();else{let t=e.find(e=>e.data.chainId===l.eq()?.caipNetworkId)||e[0];await this.addSession(t)}}getRequired(){return this.required}async getSessionAccount(){if(!this.getStorageToken(this.localAuthStorageKey))throw 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 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(){let e=Object.keys(this.listeners);e.forEach(e=>{this.listeners[e]=[]})}async requestEmailOtp({email:e,account:t}){let i=await this.request({method:"POST",key:"otp",body:{email:e,account:t}});return this.otpUuid=i.uuid,this.messenger.resources=[`email:${e}`],i}confirmEmailOtp({code:e}){return this.request({method:"PUT",key:"otp",body:{code:e},headers:["otp"]})}async request({method:e,key:t,query:i,body:a,headers:o}){let{projectId:n,st:s,sv:l}=this.getSDKProperties(),c=new URL(`${r.b.W3M_API_URL}/auth/v1/${String(t)}`);c.searchParams.set("projectId",n),c.searchParams.set("st",s),c.searchParams.set("sv",l),i&&Object.entries(i).forEac
4h(([e,t])=>c.searchParams.set(e,String(t)));let u=await fetch(c,{method:e,body:a?JSON.stringify(a):void 0,headers:Array.isArray(o)?o.reduce((e,t)=>{switch(t){case"nonce":e["x-nonce-jwt"]=`Bearer ${this.getStorageToken(this.localNonceStorageKey)}`;break;case"auth":e.Authorization=`Bearer ${this.getStorageToken(this.localAuthStorageKey)}`;break;case"otp":this.otpUuid&&(e["x-otp"]=this.otpUuid)}return e},{}):void 0});if(!u.ok)throw Error(await u.text());return u.headers.get("content-type")?.includes("application/json")?u.json():null}getStorageToken(e){return a.mr.getItem(e)}setStorageToken(e,t){a.mr.setItem(t,e)}clearStorageTokens(){this.otpUuid=null,a.mr.removeItem(this.localAuthStorageKey),a.mr.removeItem(this.localNonceStorageKey),this.emit("sessionChanged",void 0)}async getNonce(){let{nonce:e,token:t}=await this.request({method:"GET",key:"nonce"});return this.setStorageToken(t,this.localNonceStorageKey),e}getClientId(){return n.L.state.clientId}getWalletInfo(){let e=s.R.getAccountData()?.connectedWalletInfo;if(!e)return;if("social"in e&&"identifier"in e){let t=e.social,i=e.identifier;return{type:"social",social:t,identifier:i}}let{name:t,icon:i}=e,a="unknown";switch(e.type){case"EXTERNAL":case"INJECTED":case"ANNOUNCED":a="extension";break;case"WALLET_CONNECT":a="walletconnect";break;default:a="unknown"}return{type:a,name:t,icon:i}}getSDKProperties(){return o.ApiController._getSdkProperties()}emit(e,t){this.listeners[e].forEach(e=>e(t))}setAppKitAccountUser(e){let{email:t}=e;
4t&&Object.values(r.b.CHAIN).forEach(e=>{s.R.setAccountProp("user",{email:t},e)})}}},36284:function(e,t,i){i.r(t),i.d(t,{W3mDataCaptureOtpConfirmView:function(){return f},W3mDataCaptureView:function(){return x},W3mEmailSuffixesWidget:function(){return l},W3mRecentEmailsWidget:function(){return u}});var a=i(72267),r=i(94836),o=i(32527),n=a.iv` 5 .email-sufixes { 6 display: flex; 7 flex-direction: row; 8 gap: var(--wui-spacing-3xs); 9 overflow-x: auto; 10 max-width: 100%; 11 margin-top: var(--wui-spacing-s); 12 margin-bottom: calc(-1 * var(--wui-spacing-m)); 13 padding-bottom: var(--wui-spacing-m); 14 margin-left: calc(-1 * var(--wui-spacing-m)); 15 margin-right: calc(-1 * var(--wui-spacing-m)); 16 padding-left: var(--wui-spacing-m); 17 padding-right: var(--wui-spacing-m); 18 19 &::-webkit-scrollbar { 20 display: none; 21 } 22 } 23`,__decorate=function(e,t,i,a){var r,o=arguments.length,n=o<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(n=(o<3?r(n):o>3?r(t,i,n):r(t,i))||n);return o>3&&n&&Object.defineProperty(t,i,n),n};let s=["@gmail.com","@outlook.com","@yahoo.com","@hotmail.com","@aol.com","@icloud.com","@zoho.com"],l=class extends a.oi{constructor(){super(...arguments),this.email=""}render(){let e=s.filter(this.filter.bind(this)).map(this.item.bind(this));return 0===e.length?null:a.dy`<div class="email-sufixes">${e}</div>`}filter(e){if(!this.email)return!1;let t=this.email.split("@");if(t.length<2)return!0;let i=t.pop();return e.includes(i)&&e!==`@${i}`}item(e){return a.dy`<wui-button variant="neutral" size="sm" @click=${()=>{let t=this.email.split("@");t.length>1&&t.pop();let i=t[0]+e;this.dispatchEvent(new CustomEvent("change",{detail:i,bubbles:!0,composed:!0}))}} 24 >${e}</wui-button 25 >`}};l.styles=[n],__decorate([(0,r.Cb)()],l.prototype,"email",void 0),l=__decorate([(0,o.Mo)("w3m-email-suffixes-widget")],l);var c=a.iv` 26 .recent-emails { 27 display: flex; 28 flex-direction: column; 29 padding: var(--wui-spacing-s) 0; 30 border-top: 1px solid var(--wui-color-gray-glass-005); 31 border-bottom: 1px solid var(--wui-color-gray-glass-005); 32 } 33 34 .recent-emails-heading { 35 margin-bottom: var(--wui-spacing-s); 36 } 37 38 .recent-emails-list-item { 39 --wui-color-gray-glass-002: transparent; 40 } 41`,w3m_recent_emails_widget_decorate=function(e,t,i,a){var r,o=arguments.length,n=o<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(n=(o<3?r(n):o>3?r(t,i,n):r(t,i))||n);return o>3&&n&&Object.defineProperty(t,i,n),n};let u=class extends a.oi{constructor(){super(...arguments),this.emails=[]}render(){return 0===this.emails.length?null:a.dy`<div class="recent-emails"> 42 <wui-text variant="micro-600" color="fg-200" class="recent-emails-heading" 43 >Recently used emails</wui-text 44 > 45 ${this.emails.map(this.item.bind(this))} 46 </div>`}item(e){return a.dy`<wui-list-item 47 @click=${()=>{this.dispatchEvent(new CustomEvent("select",{detail:e,bubbles:!0,composed:!0}))}} 48 ?chevron=${!0} 49 icon="mail" 50 iconVariant="overlay" 51 class="recent-emails-list-item" 52 > 53 <wui-text variant="paragraph-500" color="fg-100">${e}</wui-text> 54 </wui-list-item>`}};u.styles=[c],w3m_recent_emails_widget_decorate([(0,r.Cb)()],u.prototype,"emails",void 0),u=w3m_recent_emails_widget_decorate([(0,o.Mo)("w3m-recent-emails-widget")],u);var d=i(17582),h=i(12056),p=i(55532),m=i(87655),g=i(52674),w=i(99404),w3m_data_capture_otp_confirm_view_decorate=function(e,t,i,a){var r,o=arguments.length,n=o<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(n=(o<3?r(n):o>3?r(t,i,n):r(t,i))||n);return o>3&&n&&Object.defineProperty(t,i,n),n};let f=class extends w.m{constructor(){super(...arguments),this.siwx=d.OptionsController.state.siwx,this.onOtpSubmit=async e=>{await this.siwx.confirmEmailOtp({code:e}),h.RouterController.replace("SIWXSignMessage")},this.onOtpResend=async e=>{let t=p.R.getAccountData();if(!t?.caipAddress)throw Error("No account data found");await this.siwx.requestEmailOtp({email:e,account:t.caipAddress})}}connectedCallback(){this.siwx&&this.siwx instanceof g.z||m.SnackController.showError("ReownAuthentication is not initialized."),super.connectedCallback()}shouldSubmitOnOtpChange(){return this.otp.length===w.m.OTP_LENGTH}};w3m_data_capture_otp_confirm_view_decorate([(0,r.SB)()],f.prototype,"siwx",void 0),f=w3m_data_capture_otp_confirm_view_decorate([(0,o.Mo)("w3m-data-capture-otp-confirm-view")],f);var y=i(11191),v=a.iv` 55 .hero { 56 display: flex; 57 flex-direction: column; 58 align-items: center; 59 justify-content: center; 60 gap: var(--wui-spacing-3xs); 61 62 transition-property: margin, height; 63 transition-duration: var(--wui-duration-md); 64 transition-timing-function: var(--wui-ease-out-power-1); 65 margin-top: -100px; 66 67 &[data-state='loading'] { 68 margin-top: 0px; 69 } 70 71 position: relative; 72 &:after { 73 content: ''; 74 position: absolute; 75 bottom: 0; 76 height: 252px; 77 width: 360px; 78 background: radial-gradient( 79 96.11% 53.95% at 50% 51.28%, 80 transparent 0%, 81 color-mix(in srgb, var(--wui-color-bg-100) 5%, transparent) 49%, 82 color-mix(in srgb, var(--wui-color-bg-100) 65%, transparent) 99.43% 83 ); 84 } 85 } 86 87 .hero-main-icon { 88 width: 176px; 89 transition-property: background-color; 90 transition-duration: var(--wui-duration-lg); 91 transition-timing-function: var(--wui-ease-out-power-1); 92 93 &[data-state='loading'] { 94 width: 56px; 95 } 96 } 97 98 .hero-row { 99 display: flex; 100 flex-direction: row; 101 align-items: center; 102 justify-content: center; 103 gap: var(--wui-spacing-3xs); 104 flex-wrap: nowrap; 105 min-width: fit-content; 106 107 &:nth-child(1) { 108 transform: translateX(-30px); 109 } 110 111 &:nth-child(2) { 112 transform: translateX(30px); 113 } 114 115 &:nth-child(4) { 116 transform: translateX(40px); 117 } 118 119 transition-property: height; 120 transition-duration: var(--wui-duration-md); 121 transition-timing-function: var(--wui-ease-out-power-1); 122 height: 68px; 123 124 &[data-state='loading'] { 125 height: 0px; 126 } 127 } 128 129 .hero-row-icon { 130 opacity: 0.1; 131 transition-property: opacity; 132 transition-duration: var(--wui-duration-md); 133 transition-timing-function: var(--wui-ease-out-power-1); 134 135 &[data-state='loading'] { 136 opacity: 0; 137 } 138 } 139`,w3m_data_capture_view_decorate=function(e,t,i,a){var r,o=arguments.length,n=o<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(n=(o<3?r(n):o>3?r(t,i,n):r(t,i))||n);return o>3&&n&&Object.defineProperty(t,i,n),n};let x=class extends a.oi{constructor(){super(...arguments),this.email=h.RouterController.state.data?.email??p.R.getAccountData()?.user?.email??"",this.address=p.R.getAccountData()?.address??"",this.loading=!1,this.appName=d.OptionsController.state.metadata?.name??"AppKit",this.siwx=d.OptionsController.state.siwx,this.isRequired=Array.isArray(d.OptionsController.state.remoteFeatures?.emailCapture)&&d.OptionsController.state.remoteFeatures?.emailCapture.includes("required"),this.recentEmails=this.getRecentEmails()}connectedCallback(){this.siwx&&this.siwx instanceof g.z||m.SnackController.showError("ReownAuthentication is not initialized. Please contact support."),super.connectedCallback()}firstUpdated(){this.loading=!1,this.recentEmails=this.getRecentEmails(),this.email&&this.onSubmit()}render(){return a.dy` 140 <wui-flex flexDirection="column" .padding=${["3xs","m","m","m"]} gap="l"> 141 ${this.hero()} ${this.paragraph()} ${this.emailInput()} ${this.recentEmailsWidget()} 142 ${this.footerActions()} 143 </wui-flex> 144 `}hero(){return a.dy` 145 <div class="hero" data-state=${this.loading?"loading":"default"}> 146 ${this.heroRow(["id","mail","wallet","x","solana","qrCode"])} 147 ${this.heroRow(["mail","farcaster","wallet","discord","mobile","qrCode"])} 148 <div class="hero-row"> 149 ${this.heroIcon("github")} ${this.heroIcon("bank")} 150 <wui-icon-box 151 size="xl" 152 iconSize="xxl" 153 iconColor=${this.loading?"fg-100":"accent-100"} 154 backgroundColor=${this.loading?"fg-100":"accent-100"} 155 icon=${this.loading?"id":"user"} 156 isOpaque 157 class="hero-main-icon" 158 data-state=${this.loading?"loading":"default"} 159 > 160 </wui-icon-box> 161 ${this.heroIcon("id")} ${this.heroIcon("card")} 162 </div> 163 ${this.heroRow(["google","id","github","verify","apple","mobile"])} 164 </div> 165 `}heroRow(e){return a.dy` 166 <div class="hero-row" data-state=${this.loading?"loading":"default"}> 167 ${e.map(this.heroIcon.bind(this))} 168 </div> 169 `}heroIcon(e){return a.dy` 170 <wui-icon-box 171 size="xl" 172 iconSize="xxl" 173 iconColor="fg-100" 174 backgroundColor="fg-100" 175 icon=${e} 176 data-state=${this.loading?"loading":"default"} 177 isOpaque 178 class="hero-row-icon" 179 > 180 </wui-icon-box> 181 `}paragraph(){return this.loading?a.dy` 182 <wui-text variant="paragraph-400" color="fg-200" align="center" 183 >We are verifying your account with email 184 <wui-text variant="paragraph-600" color="accent-100">${this.email}</wui-text> and address 185 <wui-text variant="paragraph-600" color="fg-100"> 186 ${o.Hg.getTruncateString({string:this.address,charsEnd:4,charsStart:4,truncate:"middle"})} </wui-text 187 >, please wait a moment.</wui-text 188 > 189 `:this.isRequired?a.dy` 190 <wui-text variant="paragraph-600" color="fg-100" align="center"> 191 ${this.appName} requires your email for authentication. 192 </wui-text> 193 `:a.dy` 194 <wui-flex flexDirection="column" gap="xs" alignItems="center"> 195 <wui-text variant="paragraph-600" color="fg-100" align="center" size> 196 ${this.appName} would like to collect your email. 197 </wui-text> 198 199 <wui-text variant="small-400" color="fg-200" align="center"> 200 Don't worry, it's optional—
200you can skip this step. 201 </wui-text> 202 </wui-flex> 203 `}emailInput(){if(this.loading)return null;let changeHandler=e=>{this.email=e.detail};return a.dy` 204 <wui-flex flexDirection="column"> 205 <wui-email-input 206 .value=${this.email} 207 .disabled=${this.loading} 208 @inputChange=${changeHandler} 209 @keydown=${e=>{"Enter"===e.key&&this.onSubmit()}} 210 ></wui-email-input> 211 212 <w3m-email-suffixes-widget 213 .email=${this.email} 214 @change=${changeHandler} 215 ></w3m-email-suffixes-widget> 216 </wui-flex> 217 `}recentEmailsWidget(){return 0===this.recentEmails.length||this.loading?null:a.dy` 218 <w3m-recent-emails-widget 219 .emails=${this.recentEmails} 220 @select=${e=>{this.email=e.detail,this.onSubmit()}} 221 ></w3m-recent-emails-widget> 222 `}footerActions(){return a.dy` 223 <wui-flex flexDirection="row" fullWidth gap="s"> 224 ${this.isRequired?null:a.dy`<wui-button 225 size="lg" 226 variant="neutral" 227 fullWidth 228 .disabled=${this.loading} 229 @click=${this.onSkip.bind(this)} 230 >Skip this step</wui-button 231 >`} 232 233 <wui-button 234 size="lg" 235 variant="main" 236 type="submit" 237 fullWidth 238 .disabled=${!this.email||!this.isValidEmail(this.email)} 239 .loading=${this.loading} 240 @click=${this.onSubmit.bind(this)} 241 > 242 Continue 243 </wui-button> 244 </wui-flex> 245 `}async onSubmit(){if(!(this.siwx instanceof g.z)){m.SnackController.showError("ReownAuthentication is not initialized. Please contact support.");return}let e=p.R.getActiveCaipAddress();if(!e)throw Error("Account is not connected.");if(!this.isValidEmail(this.email)){m.SnackController.showError("Please provide a valid email.");return}try{this.loading=!0;let t=await this.siwx.requestEmailOtp({email:this.email,account:e});this.pushRecentEmail(this.email),null===t.uuid?h.RouterController.replace("SIWXSignMessage"):h.RouterController.replace("DataCaptureOtpConfirm",{email:this.email})}catch(e){m.SnackController.showError("Failed to send email OTP"),this.loading=!1}}onSkip(){h.RouterController.replace("SIWXSignMessage")}getRecentEmails(){let e=y.mr.getItem(y.uJ.RECENT_EMAILS),t=e?e.split(","):[];return t.filter(this.isValidEmail.bind(this)).slice(0,3)}pushRecentEmail(e){let t=this.getRecentEmails(),i=Array.from(new Set([e,...t])).slice(0,3);y.mr.setItem(y.uJ.RECENT_EMAILS,i.join(","))}isValidEmail(e){return/^\S+@\S+\.\S+$/u.test(e)}};x.styles=[v],w3m_data_capture_view_decorate([(0,r.SB)()],x.prototype,"email",void 0),w3m_data_capture_view_decorate([(0,r.SB)()],x.prototype,"address",void 0),w3m_data_capture_view_decorate([(0,r.SB)()],x.prototype,"loading",void 0),w3m_data_capture_view_decorate([(0,r.SB)()],x.prototype,"appName",void 0),w3m_data_capture_view_decorate([(0,r.SB)()],x.prototype,"siwx",void 0),w3m_data_capture_view_decorate([(0,r.SB)()],x.prototype,"isRequired",void 0),w3m_data_capture_view_decorate([(0,r.SB)()],x.prototype,"recentEmails",void 0),x=w3m_data_capture_view_decorate([(0,o.Mo)("w3m-data-capture-view")],x)}}]);
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.