@privy-io/react-auth
Version:
React client for the Privy Auth API
1 lines • 649 kB
JavaScript
import{jsxs as e,jsx as t,Fragment as n}from"react/jsx-runtime";import{createStore as r}from"mipd";import a,{useRef as i,useState as o,useMemo as s,useContext as l,createContext as c,useEffect as d,useCallback as h,useReducer as p,forwardRef as u}from"react";import*as m from"react-device-detect";import{isMobile as g,isIOS as y,isSafari as f,isAndroid as w}from"react-device-detect";import{getAddress as v,toHex as C,isAddress as b,isHex as k}from"viem/utils";import T,{ProviderErrors as x,DEFAULT_SUPPORTED_CHAIN_IDS as A,dedupeSupportedChains as I,DEFAULT_SUPPORTED_CHAINS as _,mainnet as E,addToDefaultChains as S,create as N,countryCodesAndNumbers as M,validatePhoneNumber as P,phoneNumberTypingFormatter as W,getPlaceholderPhoneNumber as U,getCountryCallingCode as O,getPhoneCountryCodeAndNumber as L,formatPhoneNumber as R,toObjectKeys as F,arbitrum as D,avalanche as z,base as B,celo as $,linea as j,optimism as V,polygon as H,zora as q,formatWalletAddress as K,getCoinbaseOnRampUrl as Z,chainToMoonpayCurrency as G,isSupportedChainIdForMoonpay as Y,isSupportedChainIdForCoinbaseOnramp as J,sepolia as Q,optimismSepolia as X,polygonAmoy as ee,baseSepolia as te,avalancheFuji as ne,arbitrumSepolia as re,SolanaClient as ae,rpc as ie,formatTokenAmount as oe,formatWeiAmount as se,lastFourDigits as le}from"@privy-io/js-sdk-core";import{P as ce,p as de,f as he,b as pe,c as ue,d as me,e as ge,g as ye,h as fe,i as we,j as ve,o as Ce,a as be,k as ke,l as Te,m as xe,q as Ae,r as Ie,s as _e,t as Ee,v as Se,w as Ne,x as Me,y as Pe,z as We,A as Ue,n as Oe,B as Le,C as Re,D as Fe,E as De,F as ze,G as Be,H as $e,J as je,K as Ve,L as He,M as qe,N as Ke,O as Ze,Q as Ge,R as Ye,S as Je,T as Qe,U as Xe,V as et,W as tt,X as nt,Y as rt,Z as at,_ as it,$ as ot,a0 as st,a1 as lt,a2 as ct,a3 as dt,a4 as ht,a5 as pt,a6 as ut,a7 as mt,a8 as gt,a9 as yt,aa as ft,ab as wt,ac as vt,ad as Ct,ae as bt,u as kt,af as Tt,ag as xt,ah as At,ai as It,aj as _t,ak as Et,al as St,I as Nt}from"./internal-context-D5bEplez.mjs";import{createPublicClient as Mt,http as Pt,getAddress as Wt,isHex as Ut,toHex as Ot,formatEther as Lt,formatUnits as Rt,parseEther as Ft,createWalletClient as Dt,custom as zt,publicActions as Bt,encodeFunctionData as $t,isAddress as jt,hexToString as Vt,decodeFunctionData as Ht,decodeAbiParameters as qt}from"viem";import{v4 as Kt}from"uuid";import*as Zt from"jose";import{base64url as Gt}from"jose";import Yt from"eventemitter3";import{CoinbaseWalletSDK as Jt}from"@coinbase/wallet-sdk";import{Turnstile as Qt}from"@marsidev/react-turnstile";import{styled as Xt,css as en,createGlobalStyle as tn,keyframes as nn}from"styled-components";import rn from"tinycolor2";import an from"@heroicons/react/24/outline/DevicePhoneMobileIcon";import on from"@heroicons/react/24/outline/FingerPrintIcon";import sn from"@heroicons/react/24/outline/PhoneIcon";import ln from"@heroicons/react/24/outline/ShieldCheckIcon";import cn from"@heroicons/react/24/outline/ArrowLeftIcon";import dn from"@heroicons/react/24/outline/ArrowRightIcon";import hn from"@heroicons/react/24/outline/QuestionMarkCircleIcon";import pn from"@heroicons/react/24/outline/XMarkIcon";import un from"@heroicons/react/24/outline/ChevronDownIcon";import mn from"@heroicons/react/24/outline/CalendarIcon";import gn from"@heroicons/react/24/outline/ExclamationTriangleIcon";import{Transition as yn,Dialog as fn,TransitionChild as wn,DialogPanel as vn,Menu as Cn,MenuButton as bn,MenuItems as kn,MenuItem as Tn}from"@headlessui/react";import{EthereumProvider as xn,OPTIONAL_EVENTS as An,OPTIONAL_METHODS as In}from"@walletconnect/ethereum-provider";import{create as _n}from"zustand";import En from"fast-password-entropy";import*as Sn from"secure-password-utilities";import{DEFAULT_WORDLIST as Nn}from"secure-password-utilities/wordlists";import Mn from"@heroicons/react/24/outline/UserCircleIcon";import Pn from"@heroicons/react/24/outline/EnvelopeIcon";import Wn from"@heroicons/react/20/solid/CheckIcon";import Un from"@heroicons/react/24/outline/WalletIcon";import On from"@heroicons/react/24/outline/CheckIcon";import Ln from"@heroicons/react/24/outline/Square2StackIcon";import Rn from"@heroicons/react/24/outline/ExclamationCircleIcon";import Fn from"@heroicons/react/24/outline/ArrowTopRightOnSquareIcon";import Dn from"@heroicons/react/24/solid/DocumentCheckIcon";import zn from"@heroicons/react/24/solid/XCircleIcon";import Bn from"@heroicons/react/24/solid/CheckCircleIcon";import $n from"qrcode";import jn from"@heroicons/react/24/outline/ChevronRightIcon";import Vn from"@heroicons/react/24/outline/LockClosedIcon";import Hn from"@heroicons/react/24/outline/PencilSquareIcon";import qn from"@heroicons/react/24/outline/ArrowPathIcon";import Kn from"@heroicons/react/24/outline/EyeIcon";import Zn from"@heroicons/react/24/outline/EyeSlashIcon";import Gn from"@heroicons/react/24/outline/KeyIcon";import Yn from"@heroicons/react/24/outline/ArrowDownTrayIcon";import Jn from"@heroicons/react/24/outline/ClipboardDocumentCheckIcon";import Qn from"@heroicons/react/24/outline/DocumentDuplicateIcon";import Xn from"@heroicons/react/24/solid/LockClosedIcon";import er from"@heroicons/react/24/outline/CheckCircleIcon";import tr from"@heroicons/react/24/outline/InformationCircleIcon";import nr from"@heroicons/react/24/outline/CreditCardIcon";import rr from"@heroicons/react/24/outline/QrCodeIcon";import ar from"@heroicons/react/24/solid/ArrowsRightLeftIcon";import ir from"@heroicons/react/24/outline/GlobeAltIcon";import{ofetch as or}from"ofetch";import{ChevronDownIcon as sr,ArrowRightIcon as lr}from"@heroicons/react/24/outline";import cr from"@heroicons/react/24/outline/ClipboardDocumentIcon";import dr from"@heroicons/react/24/outline/CloudArrowUpIcon";import hr from"@heroicons/react/24/outline/NoSymbolIcon";import pr from"@heroicons/react/24/outline/ClockIcon";import ur from"@heroicons/react/24/outline/TrashIcon";import mr from"@heroicons/react/24/solid/CheckBadgeIcon";import gr from"@heroicons/react/24/solid/IdentificationIcon";import yr from"@heroicons/react/24/outline/MinusCircleIcon";import fr from"@heroicons/react/24/outline/ArrowRightEndOnRectangleIcon";import wr from"@heroicons/react/24/solid/ShieldCheckIcon";import vr from"js-cookie";function Cr(e){return e?{"privy-ui":"t"}:void 0}class br{async authenticate(){if(!this.api)throw new ce("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new ce("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(de,{email:this.meta.email,code:this.meta.emailCode,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw he(e)}}async link(){if(!this.api)throw new ce("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new ce("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(pe,{email:this.meta.email,code:this.meta.emailCode})}catch(e){throw he(e)}}async sendCodeEmail({email:e,captchaToken:t,withPrivyUi:n}){if(!this.api)throw new ce("Auth flow has no API instance");if(e&&(this.meta.email=e),t&&(this.meta.captchaToken=t),!this.meta.email)throw new ce("Email must be set when initialzing authentication.");let r=Cr(n);try{return await this.api.post(ue,{email:this.meta.email,token:this.meta.captchaToken},{headers:{...r}})}catch(e){throw he(e)}}constructor({email:e,captchaToken:t,disableSignup:n}){this.meta={email:e,captchaToken:t,disableSignup:n??!1}}}class kr extends br{async link(){if(!this.api)throw new ce("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode||!this.meta.oldAddress)throw new ce("Email, email code, and an old email address must be set prior to calling update.");try{return await this.api.post(me,{oldAddress:this.meta.oldAddress,newAddress:this.meta.email,code:this.meta.emailCode})}catch(e){throw he(e)}}constructor(e,t,n){super({email:t,captchaToken:n}),this.meta={email:t,captchaToken:n,oldAddress:e,disableSignup:!1}}}class Tr{get(e){let t=localStorage.getItem(e);return null===t?void 0:JSON.parse(t)}put(e,t){void 0!==t?localStorage.setItem(e,JSON.stringify(t)):this.del(e)}del(e){localStorage.removeItem(e)}getKeys(){return Object.entries(localStorage).map((([e])=>e))}}function xr(){try{let e="privy:__session_storage__test",t=new Tr;return t.put(e,"blobby"),t.del(e),!0}catch(e){return!1}}var Ar="undefined"!=typeof window&&window.localStorage?new Tr:new class{get(e){return this._cache[e]}put(e,t){void 0!==t?this._cache[e]=t:this.del(e)}del(e){delete this._cache[e]}getKeys(){return Object.keys(this._cache)}constructor(){this._cache={}}};const Ir=e=>e.isApexWallet?"Apex Wallet":e.isAvalanche?"Core Wallet":e.isBackpack?"Backpack":e.isBifrost?"Bifrost Wallet":e.isBitKeep?"BitKeep":e.isBitski?"Bitski":e.isBlockWallet?"BlockWallet":e.isBraveWallet?"Brave Wallet":e.isClover?"Clover":e.isCoin98?"Coin98 Wallet":e.isCoinbaseWallet?"Coinbase Wallet":e.isDawn?"Dawn Wallet":e.isDefiant?"Defiant":e.isDesig?"Desig Wallet":e.isEnkrypt?"Enkrypt":e.isExodus?"Exodus":e.isFordefi?"Fordefi":e.isFrame?"Frame":e.isFrontier?"Frontier Wallet":e.isGamestop?"GameStop Wallet":e.isHaqqWallet?"HAQQ Wallet":e.isHyperPay?"HyperPay Wallet":e.isImToken?"ImToken":e.isHaloWallet?"Halo Wallet":e.isKuCoinWallet?"KuCoin Wallet":e.isMathWallet?"MathWallet":e.isNovaWallet?"Nova Wallet":e.isOkxWallet||e.isOKExWallet?"OKX Wallet":e.isOneInchIOSWallet||e.isOneInchAndroidWallet?"1inch Wallet":e.isOneKey?"OneKey Wallet":e.isOpera?"Opera":e.isPhantom||"isPhantom"in e?"Phantom":e.isPortal?"Ripio Portal":e.isRabby?"Rabby Wallet":e.isRainbow?"Rainbow":e.isSafePal?"SafePal Wallet":e.isStatus?"Status":e.isSubWallet?"SubWallet":e.isTalisman?"Talisman":e.isTally||e.isTaho?"Taho":e.isTokenPocket?"TokenPocket":e.isTokenary?"Tokenary":e.isTrust||e.isTrustWallet?"Trust Wallet":e.isTTWallet?"TTWallet":e.isXDEFI?"XDEFI Wallet":e.isZeal?"Zeal":e.isZerion?"Zerion":e.isMetaMask?"MetaMask":void 0,_r=(e,t)=>{if(!e.isMetaMask)return!1;if(e.isMetaMask&&!t)return!0;if(e.isBraveWallet&&!e._events&&!e._state||"MetaMask"!==Ir(e))return!1;if(e.providers)for(let t of e.providers)if(!_r(t))return!1;return!0},Er=()=>{let e=window;if(!e.ethereum)return!1;if(e.ethereum.isCoinbaseWallet)return!0;if(e.ethereum.providers)for(let t of e.ethereum.providers)if(t&&t.isCoinbaseWallet)return!0;return!1},Sr=(e,t,n,r)=>{let a=Number(e),i=t.find((e=>e.id===a));if(!i)throw new ge(`Unsupported chainId ${e}`,4901);return Mt({transport:Pt(Nr(i,n,r.appId)),chain:i})},Nr=(e,t,n)=>{let r,a=e.id,i=Number(e.id);if(e.rpcUrls.privyWalletOverride&&e.rpcUrls.privyWalletOverride.http[0])r=e.rpcUrls.privyWalletOverride.http[0];else if(t.rpcUrls&&t.rpcUrls[i])r=t.rpcUrls[i];else if(e.rpcUrls.privy?.http[0]){let t=new URL(e.rpcUrls.privy.http[0]);t.searchParams.append("privyAppId",n),r=t.toString()}else r=e.rpcUrls.public?.http[0]?e.rpcUrls.public.http[0]:e.rpcUrls.default?.http[0];if(!r)throw new ge(`No RPC url found for ${a}`);return r},Mr=e=>!!String(e).toLowerCase().match(/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/),Pr=(e,t=3,n=4,r="ethereum")=>{if(!e)return"";let a="ethereum"===r?2:0;return t+n+a+3>=e.length?e:`${e.slice(0,a+t)}...${e.slice(e.length-n,e.length)}`},Wr=(e,t=3,n=4)=>Pr(e,t,n,"solana"),Ur=e=>new Promise((t=>setTimeout(t,e)));const Or=(e,t={})=>{let n=t.delayMs||150,r=t.maxAttempts||270;return new Promise((async(a,i)=>{let o=!1,s=0;for(;!o&&s<r;){if(t.abortSignal?.aborted)return;e().then((e=>{o=!0,a(e)}),((...e)=>{o=!0,i(...e)})),s+=1,await Ur(n)}o||i(Error("Exceeded max attempts before resolving function"))}))},Lr=(e,t,n={},r={})=>{let a=new URL(t,e);for(let[e,t]of Object.entries(n))void 0!==t&&a.searchParams.set(e,t);let i=Object.entries(r);if(i.length>0){let e=new URLSearchParams;for(let[t,n]of i)e.append(t,n);a.hash=e.toString()}return a.href},Rr=e=>e.replace(/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g,""),Fr=e=>"string"==typeof e?e:"0x"+e.toString(16);async function Dr({store:e,walletList:t,externalWalletConfig:n,walletChainType:r,timeout:a=3e3}){let i=!1,o=window;return new Promise((s=>{function l(){if(i)return;i=!0,window.removeEventListener("ethereum#initialized",l);let a=e.getProviders();console.debug("Detected injected providers:",a.map((e=>e.info)));let o=[];for(let e of a)t.includes("coinbase_wallet")&&"com.coinbase.wallet"===e.info.rdns||"solana-only"===r&&"app.phantom"===e.info.rdns||o.push({type:e.info.name.toLowerCase().replace(/\s/g,"_"),eip6963InjectedProvider:e});if("solana-only"!==r)for(let e of function(){let e=window,t=e.ethereum;if(!t)return[];let n=[];if(t.providers?.length)for(let e of t.providers)e&&n.push(e);return n.push(e.ethereum),n}()){let t=Ir(e);if(!a.some((e=>e.info.name===t))){if(_r(e,!0)&&!o.find((e=>"metamask"===e.type))){o.push({type:"metamask",legacyInjectedProvider:e});continue}if("Phantom"===t&&!o.find((e=>"phantom"===e.type))){o.push({type:"phantom",legacyInjectedProvider:e});continue}if("Coinbase Wallet"===t&&!o.find((e=>"coinbase_wallet"===e.type&&"smartWalletOnly"!==n.coinbaseWallet?.connectionOptions))){o.push({type:"coinbase_wallet",legacyInjectedProvider:e});continue}o.find((e=>"unknown_browser_extension"===e.type))||o.push({type:"unknown_browser_extension",legacyInjectedProvider:e})}}s(o)}o.ethereum?l():(window.addEventListener("ethereum#initialized",l,{once:!0}),setTimeout((()=>{l()}),a))}))}function zr(e){return`eip155:${String(Number(e))}`}const Br=(e,t,n,r)=>{let a=Number(e),i=t.find((e=>e.id===a));if(!i)throw new ge(`Unsupported chainId ${e}`,4901);return Nr(i,n,r)},$r=e=>{let t={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},n=e.types.EIP712Domain??Object.entries(e.domain).map((([e,n])=>{if(null!=n&&"string"==typeof e&&e in t)return{name:e,type:t[e]}})).filter((e=>void 0!==e));return{...e,types:{...e.types,EIP712Domain:n}}};const jr=["c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96","4622a2b2d6af1c9844944291e5e7351a6aa24cd7b23099efac1b2fd875da31a0","225affb176778569276e484e1b92637ad061b01e13a048b35a9d280c3b58970f","1ae92b26df02f0abca6304df07debccd18262fdf5fe82daa81593582dac9a369","c03dfee351b6fcc421b4494ea33b9d4b92a984f87aa76d1663bb28705e95034a","ecc4036f814562b41a5268adc86270fba1365471402006302e70169465b7ac18","bc949c5d968ae81310268bf9193f9c9fb7bb4e1283e1284af8f2bd4992535fd6","74f8092562bd79675e276d8b2062a83601a4106d30202f2d509195e30e19673d","afbd95522f4041c71dd4f1a065f971fd32372865b416f95a0b1db759ae33f2a7","f2436c67184f158d1beda5df53298ee84abfc367581e4505134b5bcf5f46697d","84b43e8ddfcd18e5fcb5d21e7277733f9cccef76f7d92c836d0e481db0c70c04","0b415a746fb9ee99cce155c2ceca0c6f6061b1dbca2d722b3ba16381d0562150","38f5d18bd8522c244bdd70cb4a68e0e718865155811c043f052fb9f1c51de662","9414d5a85c8f4eabc1b5b15ebe0cd399e1a2a9d35643ab0ad22a6e4a32f596f0","c286eebc742a537cd1d6818363e9dc53b21759a1e8e5d9b263d0c03ec7703576","8a0ee50d1f22f6651afcae7eb4253e52a3310b90af5daef78a8c4929a9bb99d4","e9ff15be73584489ca4a66f64d32c4537711797e30b6660dbcb71ea72a42b1f4","f5b4eeb6015d66be3f5940a895cbaa49ef3439e518cd771270e6b553b48f31d2","138f51c8d00ac7b9ac9d8dc75344d096a7dfe370a568aa167eabc0a21830ed98","47bb07617af518642f3413a201ec5859faa63acb1dd175ca95085d35d38afb83","7674bb4e353bf52886768a3ddc2a4562ce2f4191c80831291218ebd90f5f5e26","8308656f4548bb81b3508afe355cfbb7f0cb6253d1cc7f998080601f838ecee3","031f0187049b7f96c6f039d1c9c8138ff7a17fd75d38b34350c7182232cc29aa","2c81da3add65899baeac53758a07e652eea46dbb5195b8074772c62a77bbf568","dd43441a6368ec9046540c46c5fdc58f79926d17ce61a176444568ca7c970dcd","2a3c89040ac3b723a1972a33a125b1db11e258a6975d3a61252cd64e6ea5ea01","b956da9052132e3dabdcd78feb596d5194c99b7345d8c4bd7a47cabdcb69a25f","0e4915107da5b3408b38e248f7a710f4529d54cd30e9d12ff0eb886d45c18e92","719bd888109f5e8dd23419b20e749900ce4d2fc6858cf588395f19c82fd036b3","942d0e22a7e6b520b0a03abcafc4dbe156a1fc151876e3c4a842f914277278ef","8ff6eccefefa7506339201bc33346f92a43118d6ff7d6e71d499d8187a1c56a2","07f99a5d9849bb049d74830012b286f8b238e72b0337933ef22b84947409db80","8821748c25de9dbc4f72a691b25a6ddad9d7df12fa23333fd9c8b5fdc14cc819","bdc9433ffdaee55d31737d83b931caa1f17e30666f5b8e03eea794bac960eb4a","cbe13eb482c76f1fa401ff4c84d9acd0b8bc9af311ca0620a0b192fb28359b4e","94f785c0c8fb8c4f38cd9cd704416430bcaa2137f27e1468782d624bcd155a43","2cca8c1b0bea04ba37dee4017991d348cdb7b826804ab2bd31073254f345b715","14e5d957c6eb62d3ee8fc6239703ac2d537d7e3552154836ca0beef775f630bc","576c90ceaea34f29ff0104837cf2b2e23d201be43be1433feeb18d375430e1fd","49bb9d698dbdf2c3d4627d66f99dd9fe90bba1eec84b143f56c64a51473c60bd","19418ecfd44963883e4d6abca1adeb2036f3b5ffb9bee0ec61f267a9641f878b","5b8e33346dfb2a532748c247876db8d596734da8977905a27b947ba1e2cf465b","d23de318f0f56038c5edb730a083216ff0cce00c1514e619ab32231cc9ec484b","50df7da345f84e5a79aaf617df5167335a4b6751626df2e8a38f07029b3dde7b","9751385960bca290c13b443155288f892f62ee920337eda8c5a8874135daaea8","6464873279d46030c0b6b005b33da6be5ed57a752be3ef1f857dc10eaf8028aa","41f20106359ff63cf732adf1f7dc1a157176c9b02fd266b50da6dcc1e9b86071","14e7176536cb3706e221daaa3cfd7b88b7da8c7dfb64d1d241044164802c6bdd","a0e04f1086aac204d4ebdd5f985c12ed226cd0006323fd8143715f9324da58d1","971e689d0a5be527bac79629b4ee9b925e82208e5168b733496a09c0faed0709","18388be9ac2d02726dbac9777c96efaac06d744b2f6d580fccdd4127a6d01fd1","15c8b91ade1a4e58f3ce4e7a0dd7f42b47db0c8df7e0d84f63eb39bcb96c4e0f","541d5dcd4ede02f3afaf75bf8e3e4c4f1fb09edb5fa6c4377ebf31c2785d9adf"];function Vr(e){return{name:e.metadata?.shortName||e.name||"",universalLink:e.mobile.universal,deepLink:e.mobile.native}}let Hr="WALLETCONNECT_DEEPLINK_CHOICE";function qr(e){return e.startsWith("http://")||e.startsWith("https://")}function Kr(e,t){if(qr(e))return Zr(e,t);let n=e;return n.includes("://")||(n=e.replaceAll("/","").replaceAll(":",""),n=`${n}://`),n.endsWith("/")||(n=`${n}/`),{redirect:`${n}wc?uri=${encodeURIComponent(t)}`,href:n}}function Zr(e,t){if(!qr(e))return Kr(e,t);let n=e;return n.endsWith("/")||(n=`${n}/`),{redirect:`${n}wc?uri=${encodeURIComponent(t)}`,href:n}}function Gr(e,t){window.open(e,t,"noreferrer noopener")}class Yr{execute(e){return null===this.promise&&(this.promise=(async()=>{try{return await this.fn(e)}finally{this.promise=null}})()),this.promise}constructor(e){this.promise=null,this.fn=e}}class Jr{get meta(){return this._meta}async authenticate(){if(!this.api)throw new ce("Auth flow has no API instance");if(!this.meta.channelToken)throw new ce("Auth flow must be initialized first");try{let e=await this.api.post(ye,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"});if(!e)throw new ce("No response from authentication");return e}catch(e){throw he(e)}}async link(){if(!this.api)throw new ce("Auth flow has no API instance");try{return await this.api.post(fe,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid})}catch(e){throw he(e)}}async _startChannelOnce(){if(!this.api)throw new ce("Auth flow has no API instance");let e=await this.api.post(we,{token:this.captchaToken});g&&!y&&e.connect_uri&&Gr(e.connect_uri,"_blank"),this._meta={...this._meta,connectUri:e.connect_uri,channelToken:e.channel_token}}async initializeFarcasterConnect(){if(!this.api)throw new ce("Auth flow has no API instance");await this.startChannelOnce.execute()}async _pollForReady(){if(!this.api)throw new ce("Auth flow has no API instance");if(!this.meta.channelToken)throw new ce("Auth flow must be initialized first");let e=await this.api.get(ve,{headers:{"farcaster-channel-token":this.meta.channelToken}});return"completed"===e.state&&(this.message=e.message,this.signature=e.signature,this.fid=e.fid,!0)}constructor(e,t=!1){this._meta={disableSignup:!1},this.captchaToken=e,this.startChannelOnce=new Yr(this._startChannelOnce.bind(this)),this.pollForReady=new Yr(this._pollForReady.bind(this)),this._meta.disableSignup=t}}const Qr="https://auth.privy.io",Xr=1400,ea=2500,ta=4e3,na="2.8.3",ra="privy:token",aa="privy-token",ia="privy:refresh_token",oa="privy:pat",sa="privy:id_token",la="privy-id-token",ca="privy-session",da="privy:caid",ha=e=>`privy:guest:${e}`,pa=e=>`privy:cross-app:${e}`,ua="privy:state_code",ma="privy:code_verifier",ga="privy:headless_oauth",ya="privy:oauth_disable_signup",fa=e=>`privy:wallet:${e}`,wa="privy:connectors",va="privy:connections",Ca=12e4,ba=3e4,ka="https://api.moonpay.com/v1",Ta="https://api.moonpay.com/v1",xa="pk_live_hirbpu0cVcLHrjktC9l7fbc9ctjv0SL",Aa="pk_test_fqWjXZMSFwloh7orvJsRfjiUHXJqFzI";function Ia(e){return crypto.getRandomValues(new Uint8Array(e))}function _a(){return Gt.encode(Ia(36))}function Ea(){return _a()}async function Sa(e,t="S256"){if("S256"!=t)return e;{let t=await async function(e){let t=(new TextEncoder).encode(e);return new Uint8Array(await crypto.subtle.digest("SHA-256",t))}(e);return Gt.encode(t)}}class Na{addCaptchaToken(e){this.meta.captchaToken=e}isActive(){return!!(this.meta.authorizationCode&&this.meta.stateCode&&this.meta.provider)}async authenticate(){if(!this.api)throw new ce("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new ce("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if("undefined"===this.meta.authorizationCode)throw new ce("User denied confirmation during OAuth flow");let e=function(){let e=Ar.get(ma);if(!e)throw new ce("Authentication error.");return e}();try{let t=await this.api.post(Ce,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:e,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"});return Ar.del(ma),Ar.del(ga),Ar.del(ya),t}catch(e){let t=he(e);if(t.privyErrorCode)throw new ce(t.message||"Invalid code during OAuth flow.",void 0,t.privyErrorCode);if("User denied confirmation during OAuth flow"===t.message)throw new ce("Invalid code during oauth flow.",void 0,be.OAUTH_USER_DENIED);throw new ce("Invalid code during OAuth flow.",void 0,be.UNKNOWN_AUTH_ERROR)}}async link(){if(!this.api)throw new ce("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new ce("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if("undefined"===this.meta.authorizationCode)throw new ce("User denied confirmation during OAuth flow");let e=Ar.get(ma);if(!e)throw new ce("Authentication error.");try{let t=await this.api.post(ke,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:e});return Ar.del(ma),t}catch(e){throw he(e)}}async getAuthorizationUrl(){if(!this.api)throw new ce("Auth flow has no API instance");if(!this.meta.provider)throw new ce("Provider must be set when initializing OAuth authentication.");let e=_a();Ar.put(ma,e);let t=Ea();Ar.put(ua,t);let n=await Sa(e);this.meta.withPrivyUi||Ar.put(ga,!0),this.meta.disableSignup&&Ar.put(ya,!0);let r=Cr(this.meta.withPrivyUi);try{return await this.api.post(Te,{provider:this.meta.provider,redirect_to:window.location.href,token:this.meta.captchaToken,code_challenge:n,state_code:t},{headers:{...r}})}catch(e){throw he(e)}}constructor(e){this.meta=e}}function Ma(e){return e.charAt(0).toUpperCase()+e.slice(1)}const Pa=({style:n,...r})=>/*#__PURE__*/e("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:"0 0 24 24",style:{height:"24px",...n},...r,children:[/*#__PURE__*/t("path",{d:"M17.0722 11.6888C17.0471 8.90571 19.3263 7.56847 19.429 7.50274C18.1466 5.60938 16.153 5.35154 15.4417 5.3212C13.7461 5.14678 12.1306 6.32982 11.269 6.32982C10.4074 6.32982 9.08004 5.34648 7.67246 5.37429C5.82158 5.40209 4.11595 6.45874 3.16171 8.13218C1.24068 11.4942 2.6708 16.4817 4.54423 19.2143C5.46091 20.549 6.55041 22.0531 7.98554 21.9975C9.36803 21.9419 9.88905 21.095 11.5571 21.095C13.2251 21.095 13.696 21.9975 15.1537 21.9697C16.6389 21.9393 17.5806 20.6046 18.4897 19.2648C19.5392 17.7153 19.9725 16.2137 19.9975 16.1354C19.965 16.1228 17.1022 15.0155 17.0722 11.6888Z",fill:"currentColor"}),/*#__PURE__*/t("path",{d:"M14.3295 3.51373C15.0909 2.58347 15.6043 1.28921 15.4641 0C14.3671 0.0455014 13.0396 0.738135 12.2532 1.66838C11.5494 2.48994 10.9307 3.80695 11.0986 5.07089C12.3183 5.16694 13.5681 4.44145 14.3295 3.51373Z",fill:"currentColor"})]}),Wa=({style:n,...r})=>/*#__PURE__*/e("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:"0 0 71 55",style:{height:"24px",...n},...r,children:[/*#__PURE__*/t("g",{clipPath:"url(#clip0)",children:/*#__PURE__*/t("path",{d:"M60.1045 4.8978C55.5792 2.8214 50.7265 1.2916 45.6527 0.41542C45.5603 0.39851 45.468 0.440769 45.4204 0.525289C44.7963 1.6353 44.105 3.0834 43.6209 4.2216C38.1637 3.4046 32.7345 3.4046 27.3892 4.2216C26.905 3.0581 26.1886 1.6353 25.5617 0.525289C25.5141 0.443589 25.4218 0.40133 25.3294 0.41542C20.2584 1.2888 15.4057 2.8186 10.8776 4.8978C10.8384 4.9147 10.8048 4.9429 10.7825 4.9795C1.57795 18.7309 -0.943561 32.1443 0.293408 45.3914C0.299005 45.4562 0.335386 45.5182 0.385761 45.5576C6.45866 50.0174 12.3413 52.7249 18.1147 54.5195C18.2071 54.5477 18.305 54.5139 18.3638 54.4378C19.7295 52.5728 20.9469 50.6063 21.9907 48.5383C22.0523 48.4172 21.9935 48.2735 21.8676 48.2256C19.9366 47.4931 18.0979 46.6 16.3292 45.5858C16.1893 45.5041 16.1781 45.304 16.3068 45.2082C16.679 44.9293 17.0513 44.6391 17.4067 44.3461C17.471 44.2926 17.5606 44.2813 17.6362 44.3151C29.2558 49.6202 41.8354 49.6202 53.3179 44.3151C53.3935 44.2785 53.4831 44.2898 53.5502 44.3433C53.9057 44.6363 54.2779 44.9293 54.6529 45.2082C54.7816 45.304 54.7732 45.5041 54.6333 45.5858C52.8646 46.6197 51.0259 47.4931 49.0921 48.2228C48.9662 48.2707 48.9102 48.4172 48.9718 48.5383C50.038 50.6034 51.2554 52.5699 52.5959 54.435C52.6519 54.5139 52.7526 54.5477 52.845 54.5195C58.6464 52.7249 64.529 50.0174 70.6019 45.5576C70.6551 45.5182 70.6887 45.459 70.6943 45.3942C72.1747 30.0791 68.2147 16.7757 60.1968 4.9823C60.1772 4.9429 60.1437 4.9147 60.1045 4.8978ZM23.7259 37.3253C20.2276 37.3253 17.3451 34.1136 17.3451 30.1693C17.3451 26.225 20.1717 23.0133 23.7259 23.0133C27.308 23.0133 30.1626 26.2532 30.1066 30.1693C30.1066 34.1136 27.28 37.3253 23.7259 37.3253ZM47.3178 37.3253C43.8196 37.3253 40.9371 34.1136 40.9371 30.1693C40.9371 26.225 43.7636 23.0133 47.3178 23.0133C50.9 23.0133 53.7545 26.2532 53.6986 30.1693C53.6986 34.1136 50.9 37.3253 47.3178 37.3253Z",fill:"#5865F2"})}),/*#__PURE__*/t("defs",{children:/*#__PURE__*/t("clipPath",{id:"clip0",children:/*#__PURE__*/t("rect",{width:"71",height:"55",fill:"white"})})})]}),Ua=({style:e,...n})=>/*#__PURE__*/t("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"24",y:"24",viewBox:"0 0 98 96",style:{height:"24px",...e},...n,children:/*#__PURE__*/t("path",{d:"M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z",fill:"currentColor"})}),Oa=({style:e})=>/*#__PURE__*/t(ir,{style:{color:"var(--privy-color-error)",...e}}),La=({style:n,...r})=>/*#__PURE__*/e("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"26px",width:"26px",...n},...r,children:[/*#__PURE__*/t("path",{d:"M22.56 12.25C22.56 11.47 22.49 10.72 22.36 10H12V14.255H17.92C17.665 15.63 16.89 16.795 15.725 17.575V20.335H19.28C21.36 18.42 22.56 15.6 22.56 12.25Z",fill:"#4285F4"}),/*#__PURE__*/t("path",{d:"M12 23C14.97 23 17.46 22.015 19.28 20.335L15.725 17.575C14.74 18.235 13.48 18.625 12 18.625C9.13504 18.625 6.71004 16.69 5.84504 14.09H2.17004V16.94C3.98004 20.535 7.70004 23 12 23Z",fill:"#34A853"}),/*#__PURE__*/t("path",{d:"M5.845 14.09C5.625 13.43 5.5 12.725 5.5 12C5.5 11.275 5.625 10.57 5.845 9.91V7.06H2.17C1.4 8.59286 0.999321 10.2846 1 12C1 13.775 1.425 15.455 2.17 16.94L5.845 14.09Z",fill:"#FBBC05"}),/*#__PURE__*/t("path",{d:"M12 5.375C13.615 5.375 15.065 5.93 16.205 7.02L19.36 3.865C17.455 2.09 14.965 1 12 1C7.70004 1 3.98004 3.465 2.17004 7.06L5.84504 9.91C6.71004 7.31 9.13504 5.375 12 5.375Z",fill:"#EA4335"})]});function Ra(n){/*#__PURE__*/return e("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:26,height:26,viewBox:"0 0 140 140",x:"0px",y:"0px",fill:"none",...n,children:[/*#__PURE__*/e("defs",{children:[/*#__PURE__*/e("linearGradient",{id:"b",children:[/*#__PURE__*/t("stop",{offset:"0",stopColor:"#3771c8"}),/*#__PURE__*/t("stop",{stopColor:"#3771c8",offset:".128"}),/*#__PURE__*/t("stop",{offset:"1",stopColor:"#60f",stopOpacity:"0"})]}),/*#__PURE__*/e("linearGradient",{id:"a",children:[/*#__PURE__*/t("stop",{offset:"0",stopColor:"#fd5"}),/*#__PURE__*/t("stop",{offset:".1",stopColor:"#fd5"}),/*#__PURE__*/t("stop",{offset:".5",stopColor:"#ff543e"}),/*#__PURE__*/t("stop",{offset:"1",stopColor:"#c837ab"})]}),/*#__PURE__*/t("radialGradient",{id:"c",cx:"158.429",cy:"578.088",r:"65",xlinkHref:"#a",gradientUnits:"userSpaceOnUse",gradientTransform:"matrix(0 -1.98198 1.8439 0 -1031.402 454.004)",fx:"158.429",fy:"578.088"}),/*#__PURE__*/t("radialGradient",{id:"d",cx:"147.694",cy:"473.455",r:"65",xlinkHref:"#b",gradientUnits:"userSpaceOnUse",gradientTransform:"matrix(.17394 .86872 -3.5818 .71718 1648.348 -458.493)",fx:"147.694",fy:"473.455"})]}),/*#__PURE__*/t("path",{fill:"url(#c)",d:"M65.03 0C37.888 0 29.95.028 28.407.156c-5.57.463-9.036 1.34-12.812 3.22-2.91 1.445-5.205 3.12-7.47 5.468C4 13.126 1.5 18.394.595 24.656c-.44 3.04-.568 3.66-.594 19.188-.01 5.176 0 11.988 0 21.125 0 27.12.03 35.05.16 36.59.45 5.42 1.3 8.83 3.1 12.56 3.44 7.14 10.01 12.5 17.75 14.5 2.68.69 5.64 1.07 9.44 1.25 1.61.07 18.02.12 34.44.12 16.42 0 32.84-.02 34.41-.1 4.4-.207 6.955-.55 9.78-1.28 7.79-2.01 14.24-7.29 17.75-14.53 1.765-3.64 2.66-7.18 3.065-12.317.088-1.12.125-18.977.125-36.81 0-17.836-.04-35.66-.128-36.78-.41-5.22-1.305-8.73-3.127-12.44-1.495-3.037-3.155-5.305-5.565-7.624C116.9 4 111.64 1.5 105.372.596 102.335.157 101.73.027 86.19 0H65.03z",transform:"translate(1.004 1)"}),/*#__PURE__*/t("path",{fill:"url(#d)",d:"M65.03 0C37.888 0 29.95.028 28.407.156c-5.57.463-9.036 1.34-12.812 3.22-2.91 1.445-5.205 3.12-7.47 5.468C4 13.126 1.5 18.394.595 24.656c-.44 3.04-.568 3.66-.594 19.188-.01 5.176 0 11.988 0 21.125 0 27.12.03 35.05.16 36.59.45 5.42 1.3 8.83 3.1 12.56 3.44 7.14 10.01 12.5 17.75 14.5 2.68.69 5.64 1.07 9.44 1.25 1.61.07 18.02.12 34.44.12 16.42 0 32.84-.02 34.41-.1 4.4-.207 6.955-.55 9.78-1.28 7.79-2.01 14.24-7.29 17.75-14.53 1.765-3.64 2.66-7.18 3.065-12.317.088-1.12.125-18.977.125-36.81 0-17.836-.04-35.66-.128-36.78-.41-5.22-1.305-8.73-3.127-12.44-1.495-3.037-3.155-5.305-5.565-7.624C116.9 4 111.64 1.5 105.372.596 102.335.157 101.73.027 86.19 0H65.03z",transform:"translate(1.004 1)"}),/*#__PURE__*/t("path",{fill:"#fff",d:"M66.004 18c-13.036 0-14.672.057-19.792.29-5.11.234-8.598 1.043-11.65 2.23-3.157 1.226-5.835 2.866-8.503 5.535-2.67 2.668-4.31 5.346-5.54 8.502-1.19 3.053-2 6.542-2.23 11.65C18.06 51.327 18 52.964 18 66s.058 14.667.29 19.787c.235 5.11 1.044 8.598 2.23 11.65 1.227 3.157 2.867 5.835 5.536 8.503 2.667 2.67 5.345 4.314 8.5 5.54 3.054 1.187 6.543 1.996 11.652 2.23 5.12.233 6.755.29 19.79.29 13.037 0 14.668-.057 19.788-.29 5.11-.234 8.602-1.043 11.656-2.23 3.156-1.226 5.83-2.87 8.497-5.54 2.67-2.668 4.31-5.346 5.54-8.502 1.18-3.053 1.99-6.542 2.23-11.65.23-5.12.29-6.752.29-19.788 0-13.036-.06-14.672-.29-19.792-.24-5.11-1.05-8.598-2.23-11.65-1.23-3.157-2.87-5.835-5.54-8.503-2.67-2.67-5.34-4.31-8.5-5.535-3.06-1.187-6.55-1.996-11.66-2.23-5.12-.233-6.75-.29-19.79-.29zm-4.306 8.65c1.278-.002 2.704 0 4.306 0 12.816 0 14.335.046 19.396.276 4.68.214 7.22.996 8.912 1.653 2.24.87 3.837 1.91 5.516 3.59 1.68 1.68 2.72 3.28 3.592 5.52.657 1.69 1.44 4.23 1.653 8.91.23 5.06.28 6.58.28 19.39s-.05 14.33-.28 19.39c-.214 4.68-.996 7.22-1.653 8.91-.87 2.24-1.912 3.835-3.592 5.514-1.68 1.68-3.275 2.72-5.516 3.59-1.69.66-4.232 1.44-8.912 1.654-5.06.23-6.58.28-19.396.28-12.817 0-14.336-.05-19.396-.28-4.68-.216-7.22-.998-8.913-1.655-2.24-.87-3.84-1.91-5.52-3.59-1.68-1.68-2.72-3.276-3.592-5.517-.657-1.69-1.44-4.23-1.653-8.91-.23-5.06-.276-6.58-.276-19.398s.046-14.33.276-19.39c.214-4.68.996-7.22 1.653-8.912.87-2.24 1.912-3.84 3.592-5.52 1.68-1.68 3.28-2.72 5.52-3.592 1.692-.66 4.233-1.44 8.913-1.655 4.428-.2 6.144-.26 15.09-.27zm29.928 7.97c-3.18 0-5.76 2.577-5.76 5.758 0 3.18 2.58 5.76 5.76 5.76 3.18 0 5.76-2.58 5.76-5.76 0-3.18-2.58-5.76-5.76-5.76zm-25.622 6.73c-13.613 0-24.65 11.037-24.65 24.65 0 13.613 11.037 24.645 24.65 24.645C79.617 90.645 90.65 79.613 90.65 66S79.616 41.35 66.003 41.35zm0 8.65c8.836 0 16 7.163 16 16 0 8.836-7.164 16-16 16-8.837 0-16-7.164-16-16 0-8.837 7.163-16 16-16z"})]})}function Fa({style:e,...n}){/*#__PURE__*/return t("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",viewBox:"0,0,256,256",style:{height:"26px",width:"26px",...e},...n,children:/*#__PURE__*/t("g",{fill:"#0077b5",strokeWidth:"1",strokeLinecap:"butt",strokeLinejoin:"miter",strokeMiterlimit:"10",style:{mixBlendMode:"normal"},children:/*#__PURE__*/t("g",{transform:"scale(5.12,5.12)",children:/*#__PURE__*/t("path",{d:"M41,4h-32c-2.76,0 -5,2.24 -5,5v32c0,2.76 2.24,5 5,5h32c2.76,0 5,-2.24 5,-5v-32c0,-2.76 -2.24,-5 -5,-5zM17,20v19h-6v-19zM11,14.47c0,-1.4 1.2,-2.47 3,-2.47c1.8,0 2.93,1.07 3,2.47c0,1.4 -1.12,2.53 -3,2.53c-1.8,0 -3,-1.13 -3,-2.53zM39,39h-6c0,0 0,-9.26 0,-10c0,-2 -1,-4 -3.5,-4.04h-0.08c-2.42,0 -3.42,2.06 -3.42,4.04c0,0.91 0,10 0,10h-6v-19h6v2.56c0,0 1.93,-2.56 5.81,-2.56c3.97,0 7.19,2.73 7.19,8.26z"})})})})}function Da(n){/*#__PURE__*/return e("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 496 512",...n,children:[/*#__PURE__*/t("path",{fill:"#1ed760",d:"M248 8C111.1 8 0 119.1 0 256s111.1 248 248 248 248-111.1 248-248S384.9 8 248 8Z"}),/*#__PURE__*/t("path",{d:"M406.6 231.1c-5.2 0-8.4-1.3-12.9-3.9-71.2-42.5-198.5-52.7-280.9-29.7-3.6 1-8.1 2.6-12.9 2.6-13.2 0-23.3-10.3-23.3-23.6 0-13.6 8.4-21.3 17.4-23.9 35.2-10.3 74.6-15.2 117.5-15.2 73 0 149.5 15.2 205.4 47.8 7.8 4.5 12.9 10.7 12.9 22.6 0 13.6-11 23.3-23.2 23.3zm-31 76.2c-5.2 0-8.7-2.3-12.3-4.2-62.5-37-155.7-51.9-238.6-29.4-4.8 1.3-7.4 2.6-11.9 2.6-10.7 0-19.4-8.7-19.4-19.4s5.2-17.8 15.5-20.7c27.8-7.8 56.2-13.6 97.8-13.6 64.9 0 127.6 16.1 177 45.5 8.1 4.8 11.3 11 11.3 19.7-.1 10.8-8.5 19.5-19.4 19.5zm-26.9 65.6c-4.2 0-6.8-1.3-10.7-3.6-62.4-37.6-135-39.2-206.7-24.5-3.9 1-9 2.6-11.9 2.6-9.7 0-15.8-7.7-15.8-15.8 0-10.3 6.1-15.2 13.6-16.8 81.9-18.1 165.6-16.5 237 26.2 6.1 3.9 9.7 7.4 9.7 16.5s-7.1 15.4-15.2 15.4z"})]})}function za(n){/*#__PURE__*/return e("svg",{xmlns:"http://www.w3.org/2000/svg",fillRule:"evenodd",clipRule:"evenodd",imageRendering:"optimizeQuality",shapeRendering:"geometricPrecision",textRendering:"geometricPrecision",viewBox:"0 0 293768 333327",width:24,height:24,...n,children:[/*#__PURE__*/t("path",{fill:"#26f4ee",d:"M204958 0c5369 45832 32829 78170 77253 81022v43471l-287 27V87593c-44424-2850-69965-30183-75333-76015l-47060-1v192819c6791 86790-60835 89368-86703 56462 30342 18977 79608 6642 73766-68039V0h58365zM78515 319644c-26591-5471-50770-21358-64969-44588-34496-56437-3401-148418 96651-157884v54345l-164 27v-40773C17274 145544 7961 245185 33650 286633c9906 15984 26169 27227 44864 33011z"}),/*#__PURE__*/t("path",{fill:"#fb2c53",d:"M218434 11587c3505 29920 15609 55386 35948 70259-27522-10602-43651-34934-47791-70262l11843 3zm63489 82463c3786 804 7734 1348 11844 1611v51530c-25770 2537-48321-5946-74600-21749l4034 88251c0 28460 106 41467-15166 67648-34260 58734-95927 63376-137628 35401 54529 22502 137077-4810 136916-103049v-96320c26279 15803 48830 24286 74600 21748V94050zm-171890 37247c5390-1122 11048-1985 16998-2548v54345c-21666 3569-35427 10222-41862 22528-20267 38754 5827 69491 35017 74111-33931 5638-73721-28750-49999-74111 6434-12304 18180-18959 39846-22528v-51797zm64479-119719h1808-1808z"}),/*#__PURE__*/t("path",{d:"M206590 11578c5369 45832 30910 73164 75333 76015v51528c-25770 2539-48321-5945-74600-21748v96320c206 125717-135035 135283-173673 72939-25688-41449-16376-141089 76383-155862v52323c-21666 3569-33412 10224-39846 22528-39762 76035 98926 121273 89342-1225V11577l47060 1z",fill:"#000000"})]})}const Ba=({style:e,...n})=>/*#__PURE__*/t("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"24px",width:"24px",...e},...n,children:/*#__PURE__*/t("path",{d:"M 14.285156 10.171875 L 23.222656 0 L 21.105469 0 L 13.34375 8.832031 L 7.148438 0 L 0 0 L 9.371094 13.355469 L 0 24.019531 L 2.117188 24.019531 L 10.308594 14.691406 L 16.851562 24.019531 L 24 24.019531 M 2.878906 1.5625 L 6.132812 1.5625 L 21.101562 22.535156 L 17.851562 22.535156",fill:"currentColor"})});let $a={google:{name:"Google",component:La},discord:{name:"Discord",component:Wa},github:{name:"Github",component:Ua},linkedin:{name:"LinkedIn",component:Fa},twitter:{name:"Twitter",component:Ba},spotify:{name:"Spotify",component:Da},instagram:{name:"Instagram",component:Ra},tiktok:{name:"Tiktok",component:za},apple:{name:"Apple",component:Pa}};const ja=e=>e in $a?$a[e]:{name:"Unknown",component:Oa};function Va(){let e=new URLSearchParams(window.location.search),t=e.get("privy_oauth_code"),n=e.get("privy_oauth_state"),r=e.get("privy_oauth_provider");if(!t||!n||!r)return{inProgress:!1};let a=!1;try{a=!!window.opener.location.origin}catch{}return{inProgress:!0,authorizationCode:t,stateCode:n,provider:r,withPrivyUi:!Ar.get(ga),popupFlow:null!==window.opener&&a,disableSignup:!!Ar.get(ya)}}function Ha(){let e=new URL(window.location.href);e.searchParams.delete("privy_oauth_code"),e.searchParams.delete("privy_oauth_provider"),e.searchParams.delete("privy_oauth_state"),Ar.del(ua),window.history.replaceState({},"",e)}class qa{async initRegisterFlow(e){if(!this.api)throw new ce("Auth flow has no API instance");this.authenticateForRegistration=!0,this.meta.initRegisterResponse=await this.initRegisterOnce.execute(e)}async initAuthenticationFlow(e){if(!this.api)throw new ce("Auth flow has no API instance");this.authenticateForRegistration=!1,this.meta.initAuthenticateResponse=await this.initAuthenticateOnce.execute(e)}async initLinkFlow(){if(!this.api)throw new ce("Auth flow has no API instance");this.meta.initLinkResponse=await this.initLinkOnce.execute()}async register(){let e=await import("@simplewebauthn/browser");if(!this.api)throw new ce("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new ce("WebAuthn is not supported in this browser");this.meta.initRegisterResponse||(this.meta.initRegisterResponse=await this.initRegisterOnce.execute());try{let t=this.meta.initRegisterResponse.options,n=await e.startRegistration(this._transformInitLinkOptionsToCamelCase(t));return this.meta.setPasskeyAuthState?.({status:"submitting-response"}),await this.api.post(xe,{relying_party:this.meta.initRegisterResponse.relying_party,authenticator_response:this._transformRegistrationResponseToSnakeCase(n)})}catch(e){if("NotAllowedError"===e.name)throw new ce("Passkey request timed out or rejected by user.",void 0,be.PASSKEY_NOT_ALLOWED);throw he(e)}}async authenticate(){if(this.authenticateForRegistration)return this.register();let e=await import("@simplewebauthn/browser");if(!this.api)throw new ce("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new ce("WebAuthn is not supported in this browser");this.meta.initAuthenticateResponse||(this.meta.initAuthenticateResponse=await this.initAuthenticateOnce.execute());let t=this.meta.allowedCredentialsIds?.map((e=>({type:"public-key",id:e})))??this.meta.initAuthenticateResponse.options.allow_credentials;try{let n=await e.startAuthentication(this._transformInitAuthenticateOptionsToCamelCase({...this.meta.initAuthenticateResponse.options,allow_credentials:t}));return this.meta.setPasskeyAuthState?.({status:"submitting-response"}),await this.api.post(Ae,{relying_party:this.meta.initAuthenticateResponse.relying_party,challenge:this.meta.initAuthenticateResponse.options.challenge,authenticator_response:this._transformAuthenticationResponseToSnakeCase(n)})}catch(e){if("NotAllowedError"===e.name)throw new ce("Passkey request timed out or rejected by user.",void 0,be.PASSKEY_NOT_ALLOWED);throw he(e)}}async link(){let e=await import("@simplewebauthn/browser");if(!this.api)throw new ce("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new ce("WebAuthn is not supported in this browser");this.meta.initLinkResponse||(this.meta.initLinkResponse=await this.initLinkOnce.execute());try{let t=this.meta.initLinkResponse.options,n=await e.startRegistration(this._transformInitLinkOptionsToCamelCase(t));return this.meta.setPasskeyAuthState?.({status:"submitting-response"}),await this.api.post(Ie,{relying_party:this.meta.initLinkResponse.relying_party,authenticator_response:this._transformRegistrationResponseToSnakeCase(n)})}catch(e){if("NotAllowedError"===e.name)throw new ce("Passkey request timed out or rejected by user.",void 0,be.PASSKEY_NOT_ALLOWED);throw he(e)}}async _initRegisterOnce(e){if(!this.api)throw new ce("Auth flow has no API instance");let t=Cr(e);return await this.api.post(_e,{token:this.meta.captchaToken},{headers:{...t}})}async _initAuthenticateOnce(e){if(!this.api)throw new ce("Auth flow has no API instance");let t=Cr(e);return await this.api.post(Ee,{token:this.meta.captchaToken},{headers:{...t}})}async _initLinkOnce(){if(!this.api)throw new ce("Auth flow has no API instance");return await this.api.post(Se,{})}_transformInitLinkOptionsToCamelCase(e){return{rp:e.rp,user:{id:e.user.id,name:e.user.name,displayName:e.user.display_name},challenge:e.challenge,pubKeyCredParams:e.pub_key_cred_params.map((e=>({type:e.type,alg:e.alg}))),timeout:e.timeout,excludeCredentials:e.exclude_credentials?.map((e=>({id:e.id,type:e.type,transports:e.transports}))),authenticatorSelection:{authenticatorAttachment:e.authenticator_selection?.authenticator_attachment,requireResidentKey:e.authenticator_selection?.require_resident_key,residentKey:e.authenticator_selection?.resident_key,userVerification:e.authenticator_selection?.user_verification},attestation:e.attestation,extensions:{appid:e.extensions?.app_id,credProps:e.extensions?.cred_props?.rk,hmacCreateSecret:e.extensions?.hmac_create_secret}}}_transformRegistrationResponseToSnakeCase(e){return{id:e.id,raw_id:e.rawId,response:{client_data_json:e.response.clientDataJSON,attestation_object:e.response.attestationObject,authenticator_data:e.response.authenticatorData},authenticator_attachment:e.authenticatorAttachment,client_extension_results:{app_id:e.clientExtensionResults.appid,cred_props:e.clientExtensionResults.credProps,hmac_create_secret:e.clientExtensionResults.hmacCreateSecret},type:e.type}}_transformInitAuthenticateOptionsToCamelCase(e){return{rpId:e.rp_id,challenge:e.challenge,allowCredentials:e.allow_credentials?.map((e=>({id:e.id,type:e.type,transports:e.transports})))||[],timeout:e.timeout,extensions:{appid:e.extensions?.app_id,credProps:e.extensions?.cred_props,hmacCreateSecret:e.extensions?.hmac_create_secret},userVerification:e.user_verification}}_transformAuthenticationResponseToSnakeCase(e){return{id:e.id,raw_id:e.rawId,response:{client_data_json:e.response.clientDataJSON,authenticator_data:e.response.authenticatorData,signature:e.response.signature,user_handle:e.response.userHandle},authenticator_attachment:e.authenticatorAttachment,client_extension_results:{app_id:e.clientExtensionResults.appid,cred_props:e.clientExtensionResults.credProps,hmac_create_secret:e.clientExtensionResults.hmacCreateSecret},type:e.type}}constructor({captchaToken:e,setPasskeyAuthState:t}){this.authenticateForRegistration=!1,this.initRegisterOnce=new Yr(this._initRegisterOnce.bind(this)),this.initAuthenticateOnce=new Yr(this._initAuthenticateOnce.bind(this)),this.initLinkOnce=new Yr(this._initLinkOnce.bind(this)),this.meta={captchaToken:e,setPasskeyAuthState:t}}}const Ka=({address:e,chainId:t,nonce:n})=>`${window.location.host} wants you to sign in with your Ethereum account:\n${e}\n\nBy signing, you are proving you own this wallet and logging in. This does not initiate a transaction or cost any fees.\n\nURI: ${window.location.origin}\nVersion: 1\nChain ID: ${t}\nNonce: ${n}\nIssued At: ${(new Date).toISOString()}\nResources:\n- https://privy.io`;class Za{get meta(){return{connectorType:this.wallet.connectorType,walletClientType:this.wallet.walletClientType,chainId:this.wallet.chainId,address:this.wallet.address,disableSignup:this._meta.disableSignup}}async authenticate(){if(!this.client)throw new ce("SiweFlow has no client instance");try{let{message:e,signature:t}=await this.sign();return await this.client.authenticateWithSiweInternal({message:e,signature:t,chainId:this.wallet.chainId,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw he(e)}}async link(){if(!this.client)throw new ce("SiweFlow has no client instance");try{let{message:e,signature:t}=await this.sign();return await this.client.linkWithSiweInternal({message:e,signature:t,chainId:this.wallet.chainId,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType})}catch(e){throw he(e)}}async sign(){if(!this.client)throw new ce("SiweFlow has no client instance");if(await this.buildMessage(),!this.preparedMessage)throw new ce("Could not prepare SIWE message");let e=await this.wallet.sign(this.preparedMessage);return{message:this.preparedMessage,signature:e}}async _getNonceOnce(){if(!this.client)throw new ce("SiweFlow has no client instance");return await this.client.generateSiweNonce({address:this.wallet.address,captchaToken:this.captchaToken})}async buildMessage(){if(!this.client)throw new ce("SiweFlow has no client instance");let e=this.wallet.address,t=this.wallet.chainId.replace("eip155:","");return this.nonce||(this.nonce=await this.getNonceOnce.execute()),this.preparedMessage=Ka({address:e,chainId:t,nonce:this.nonce}),this.preparedMessage}constructor(e,t,n,r=!1){this._meta={disableSignup:!1},this.getNonceOnce=new Yr(this._getNonceOnce.bind(this)),this.wallet=e,this.captchaToken=n,this.client=t,this._meta.disableSignup=r}}const Ga=(...e)=>{if("undefined"==typeof Buffer)throw new ce("Buffer is not defined.",void 0,be.BUFFER_NOT_DEFINED);return Buffer.from(...e)};class Ya{get meta(){return{connectorType:this.wallet.connectorType,walletClientType:this.wallet.walletClientType,disableSignup:this._meta.disableSignup}}async authenticate(){if(!this.client)throw new ce("SiwsFlow has no client instance");try{let{message:e,signature:t}=await this.sign();return await this.client.authenticateWithSiwsInternal({message:e,signature:t,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw he(e)}}async link(){if(!this.client)throw new ce("SiwsFlow has no client instance");try{let{message:e,signature:t}=await this.sign();return await this.client.linkWithSiwsInternal({message:e,signature:t,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType})}catch(e){throw he(e)}}async sign(){if(!this.client)throw new ce("SiwsFlow has no client instance");if(await this.buildMessage(),!this.preparedMessage)throw new ce("Could not prepare SIWS message");if(!this.wallet.signMessage)throw new ce("Wallet does not support signMessage");let e=await this.wallet.signMessage(Ga(this.preparedMessage));return{message:this.preparedMessage,signature:Ga(e).toString("base64")}}async _getNonceOnce(){if(!this.client)throw new ce("SiwsFlow has no client instance");return await this.client.generateSiwsNonce({address:this.wallet.address,captchaToken:this.captchaToken})}async buildMessage(){if(!this.client)throw new ce("SiwsFlow has no client instance");let e=this.wallet.address;return this.nonce||(this.nonce=await this.getNonceOnce.execute()),this.preparedMessage=(({address:e,nonce:t})=>`${window.location.host} wants you to sign in with your Solana account:\n${e}\n\nYou are proving you own ${e}.\n\nURI: ${window.location.origin}\nVersion: 1\nChain ID: mainnet\nNonce: ${t}\nIssued At: ${(new Date).toISOString()}\nResources:\n- https://privy.io`)({address:e,nonce:this.nonce}),this.preparedMessage}constructor(e,t,n,r=!1){this._meta={disableSignup:!1},this.getNonceOnce=new Yr(this._getNonceOnce.bind(this)),this.wallet=e,this.captchaToken=n,this.client=t,this._meta.disableSignup=r}}class Ja{async authenticate(){if(!this.api)throw new ce("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new ce("phone number and sms code must be set prior to calling authenticate.");try{return await this.api.post(Ne,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw he(e)}}async link(){if(!this.api)throw new ce("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new ce("phone number and sms code must be set prior to calling authenticate.");try{return await this.api.post(Me,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})}catch(e){throw he(e)}}async sendSmsCode({phoneNumber:e,captchaToken:t,withPrivyUi:n}){if(!this.