PageSourceSearch

https://columbusjack.com/chunk-OIQKMNDN.js

js columbusjack.com collected 2026-10-04 13:24:47 UTC 6,254 bytes, 5 lines download raw bytes

1import{C as S,L as w,U as d,a as y,b as k,h as m,i as c,w as p}from"./chunk-HU7RPYJZ.js";import"./chunk-3RPMVPPX.js";import"./chunk-4S22LEGP.js";import"./chunk-SQLCXRSN.js";import"./chunk-UGZMQAEK.js";import{l as s}from"./chunk-E77BULOG.js";var l=class{constructor(e){this.getNonce=e.getNonce}createMessage(e){return s(this,null,function*(){let 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:yield 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((o,n)=>`${o}
4- ${n}`,"Resources:")].filter(o=>typeof o=="string").join(`
5`).trim()}getNetworkName(e){let t=d.getAllRequestedCaipNetworks();return k.getNetworkNameByCaipNetworkId(t,e)}stringifyDate(e){return e.toISOString()}};var N=class{constructor(e={}){this.otpUuid=null,this.listeners={sessionChanged:[]},this.localAuthStorageKey=e.localAuthStorageKey||m.SIWX_AUTH_TOKEN,this.localNonceStorageKey=e.localNonceStorageKey||m.SIWX_NONCE_TOKEN,this.required=e.required??!0,this.messenger=new l({getNonce:this.getNonce.bind(this)})}createMessage(e){return s(this,null,function*(){return this.messenger.createMessage(e)})}addSession(e){return s(this,null,function*(){let t=yield 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(E(t.token)),this.otpUuid=null})}getSessions(e,t){return s(this,null,function*(){try{if(!this.getStorageToken(this.localAuthStorageKey))return[];let o=yield this.request({method:"GET",key:"me",query:{},headers:["auth"]});if(!o)return[];let n=o.address.toLowerCase()===t.toLowerCase(),r=o.caip2Network===e;if(!n||!r)return[];let u={data:{accountAddress:o.address,chainId:o.caip2Network},message:"",signature:""};return this.emit("sessionChanged",u),this.setAppKitAccountUser(o),[u]}catch{return[]}})}revokeSession(e,t){return s(this,null,function*(){return Promise.resolve(this.clearStorageTokens())})}setSessions(e){return s(this,null,function*(){if(e.length===0)this.clearStorageTokens();else{let t=e.find(o=>o.data.chainId===w()?.caipNetworkId)||e[0];yield this.addSession(t)}})}getRequired(){return this.required}getSessionAccount(){return s(this,null,function*(){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"]})})}setSessionAccountMetadata(e=null){return s(this,null,function*(){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(o=>o!==t)}}removeAllListeners(){Object.keys(this.listeners).forEach(t=>{this.listeners[t]=[]})}requestEmailOtp(o){return s(this,arguments,function*({email:e,account:t}){let n=yield 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"]})}request(u){return s(this,arguments,function*({method:e,key:t,query:o,body:n,headers:r}){let{projectId:A,st:I,sv:T}=this.getSDKProperties(),a=new URL(`${y.W3M_API_URL}/auth/v1/${String(t)}`);a.searchParams.set("projectId",A),a.searchParams.set("st",I),a.searchParams.set("sv",T),o&&Object.entries(o).forEac
5h(([i,f])=>a.searchParams.set(i,String(f)));let h=yield fetch(a,{method:e,body:n?JSON.stringify(n):void 0,headers:Array.isArray(r)?r.reduce((i,f)=>{switch(f){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;default:break}return i},{}):void 0});if(!h.ok)throw new Error(yield h.text());return h.headers.get("content-type")?.includes("application/json")?h.json():null})}getStorageToken(e){return c.getItem(e)}setStorageToken(e,t){c.setItem(t,e)}clearStorageTokens(){this.otpUuid=null,c.removeItem(this.localAuthStorageKey),c.removeItem(this.localNonceStorageKey),this.emit("sessionChanged",void 0)}getNonce(){return s(this,null,function*(){let{nonce:e,token:t}=yield this.request({method:"GET",key:"nonce"});return this.setStorageToken(t,this.localNonceStorageKey),e})}getClientId(){return p.state.clientId}getWalletInfo(){let e=d.getAccountData()?.connectedWalletInfo;if(!e)return;if("social"in e&&"identifier"in e){let r=e.social,u=e.identifier;return{type:"social",social:r,identifier:u}}let{name:t,icon:o}=e,n="unknown";switch(e.type){case"EXTERNAL":case"INJECTED":case"ANNOUNCED":n="extension";break;case"WALLET_CONNECT":n="walletconnect";break;default:n="unknown"}return{type:n,name:t,icon:o}}getSDKProperties(){return S._getSdkProperties()}emit(e,t){this.listeners[e].forEach(o=>o(t))}setAppKitAccountUser(e){let{email:t}=e;
5t&&Object.values(y.CHAIN).forEach(o=>{d.setAccountProp("user",{email:t},o)})}};function E(g){let e=g.split(".");if(e.length!==3)throw new Error("Invalid token");let t=e[1];if(typeof t!="string")throw new Error("Invalid token");let o=t.replace(/-/gu,"+").replace(/_/gu,"/"),n=o.padEnd(o.length+(4-o.length%4)%4,"=");return JSON.parse(atob(n))}export{N as ReownAuthentication,l as ReownAuthenticationMessenger};

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.