@privy-io/react-auth 1.12.0-beta.7 → 1.12.0

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.
package/dist/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import{useEffect as Ot,useState as re}from"react";import Vt from"axios";import gi from"axios";var z=class extends Error{constructor(o,r){super(o);r instanceof Error&&(this.cause=r)}toString(){return`${this.type}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}},et=class extends z{constructor(o,r,i,n){super(i,n);this.type=o;this.status=r}},u=class extends z{constructor(o,r){super(o,r);this.type="client_error"}};var V=class extends z{constructor(o,r){super(o,r);this.type="connector_error"}},I=t=>{if(t instanceof z)return t;if(!gi.isAxiosError(t))return H(t);if(!t.response)return new et("api_error",null,t.message,t);let{type:e,message:o,error:r}=t.response.data;return new et(e||"ApiError",t.response.status,o||r,t)},H=t=>t instanceof z?t:t instanceof Error?new u(t.message,t):new u(`Internal error: ${t}`);var wo="1.12.0-beta.7";var yo="https://api.privy.io/v0",bo=process.env.NEXT_PUBLIC_PRIVY_AUTH_URL||"https://auth.privy.io",tt="4df5e2316331463a9130964bd6078dfa",Co=1e4,Ee=1400,vo=365*24*60*60,Gt=wo,xo="ES256",Lo="privy.io",ke="privy:token",ot="privy:refresh_token",K="privy:active_wallet",rt="privy:wallet_type",Ao="walletconnect";var it=class{constructor(e,o,r){this.appId=e,this.sdkVersion=Gt,this.session=o,this.defaults=r}async get(e,o){try{return await Vt.get(e,this.buildConfig({headers:{"Cache-Control":"no-cache"},...o}))}catch(r){throw I(r)}}async post(e,o,r){try{return await Vt.post(e,o,this.buildConfig(r))}catch(i){throw I(i)}}async delete(e,o){try{return await Vt.delete(e,this.buildConfig(o))}catch(r){throw I(r)}}buildConfig(e){return e=e||{},e.headers=e.headers||{},e.headers["privy-app-id"]=this.appId,e.headers["privy-client"]=`react-auth:${this.sdkVersion}`,this.session.token!==null&&(e.headers.authorization=`Bearer ${this.session.token}`),{...this.defaults,...e}}};import*as _e from"jose";var ne=class{static parse(e){try{return new ne(e)}catch{return null}}constructor(e){this.value=e,this._decoded=_e.decodeJwt(e)}get subject(){return this._decoded.sub}get expiration(){return this._decoded.exp}get issuer(){return this._decoded.iss}get audience(){return this._decoded.aud}isExpired(e=0){let o=Date.now(),r=(this.expiration-e)*1e3;return o>=r}async isValid(e,o,r=0){let i=await _e.importSPKI(e,xo);try{return await _e.jwtVerify(this.value,i,{issuer:Lo,audience:o,clockTolerance:r}),!0}catch{return!1}}};var se=class{constructor(e){this.promise=null;this.fn=e}execute(e){return this.promise===null&&(this.promise=(async()=>{try{return await this.fn(e)}finally{this.promise=null}})()),this.promise}};var Ht=class{constructor(){this._cache={}}get(e){return this._cache[e]}put(e,o){o!==void 0?this._cache[e]=o:this.del(e)}del(e){delete this._cache[e]}},Bt=class{get(e){let o=localStorage.getItem(e);return o===null?void 0:JSON.parse(o)}put(e,o){o!==void 0?localStorage.setItem(e,JSON.stringify(o)):this.del(e)}del(e){localStorage.removeItem(e)}};function yi(){return typeof window<"u"&&window.localStorage?new Bt:new Ht}var A=yi();function ae(t){return new Date(t*1e3)}function bi(t){return t.map(e=>{switch(e.type){case"wallet":return{address:e.address,type:e.type,verifiedAt:ae(e.verified_at),chainType:e.chain_type};case"email":return{address:e.address,type:e.type,verifiedAt:ae(e.verified_at)};case"phone":return{number:e.phoneNumber,type:e.type,verifiedAt:ae(e.verified_at)};case"google_oauth":return{subject:e.subject,email:e.email,name:e.name,type:e.type,verifiedAt:ae(e.verified_at)};case"twitter_oauth":return{subject:e.subject,username:e.username,name:e.name,type:e.type,verifiedAt:ae(e.verified_at)};case"discord_oauth":return{subject:e.subject,username:e.username,email:e.email,type:e.type,verifiedAt:ae(e.verified_at)};case"github_oauth":return{subject:e.subject,username:e.username,name:e.name,email:e.email,type:e.type,verifiedAt:ae(e.verified_at)};default:throw new u("Unrecognized account type")}})}function Ci(t,e){return e.find(o=>o.type==="wallet"&&o.address===t)}function le(t,e){return t.sort((o,r)=>r.verifiedAt.getTime()-o.verifiedAt.getTime()),t.find(o=>o.type===e)}function Fe(t){let e=t.linkedAccounts.map(s=>s.type==="wallet"?s.address:null),r=A.get(K);if(!r||!e.includes(r)){A.del(K);let s=le(t.linkedAccounts,"wallet");s&&(r=s.address,A.put(K,r))}let i=Ci(r,t.linkedAccounts),n=Object.assign({},t);return n.wallet=i&&{address:i.address,chainType:i.chainType,chainId:i.chainId,walletType:i.walletType},n}function Y(t){if(!t)return null;let e=bi(t.linked_accounts),o=le(e,"wallet"),r=le(e,"email"),i=le(e,"phone"),n=le(e,"google_oauth"),s=le(e,"twitter_oauth"),c=le(e,"discord_oauth"),m=le(e,"github_oauth"),p={id:t.id,createdAt:ae(t.created_at),linkedAccounts:e,email:r&&{address:r==null?void 0:r.address},phone:i&&{number:i==null?void 0:i.number},wallet:o&&{address:o.address,chainType:o.chainType,chainId:o.chainId,walletType:o.walletType},google:n&&{subject:n.subject,email:n.email,name:n.name},twitter:s&&{subject:s.subject,username:s.username,name:s.name},discord:c&&{subject:c.subject,username:c.username,email:c.email},github:m&&{subject:m.subject,username:m.username,name:m.name,email:m.email}};return Fe(p)}var Eo=()=>"/api/v1/sessions",ko=()=>"/api/v1/sessions/logout",_o=()=>"/api/v1/sessions/fork",Po=()=>"/api/v1/siwe/init",So=()=>"/api/v1/siwe/authenticate",To=()=>"/api/v1/siwe/link",Io=()=>"/api/v1/passwordless/init",Mo=()=>"/api/v1/passwordless/authenticate",Ro=()=>"/api/v1/passwordless/link",Wo=()=>"/api/v1/passwordless_sms/init",Oo=()=>"/api/v1/passwordless_sms/authenticate",No=()=>"/api/v1/passwordless_sms/link",Uo=()=>"/api/v1/oauth/init",Do=()=>"/api/v1/oauth/authenticate",Fo=()=>"/api/v1/oauth/link",Go=()=>"/api/v1/siwe/unlink",Vo=()=>"/api/v1/passwordless/unlink",Ho=()=>"/api/v1/passwordless_sms/unlink",Bo=()=>"/api/v1/oauth/unlink";var vi=30,nt=class{constructor(){this.authenticateOnce=new se(async e=>this._authenticate(e)),this.linkOnce=new se(async e=>this._link(e)),this.refreshOnce=new se(this._refresh.bind(this)),this.destroyOnce=new se(this._destroy.bind(this)),this.forkSessionOnce=new se(this._forkSession.bind(this))}get token(){try{let e=A.get(ke);return typeof e=="string"?new ne(e).value:null}catch(e){return console.error(e),this.destroyLocalState(),null}}get refreshToken(){try{let e=A.get(ot);return typeof e=="string"?e:null}catch(e){return console.error(e),this.destroyLocalState(),null}}hasRefreshCredentials(){return typeof this.token=="string"&&typeof this.refreshToken=="string"}hasActiveToken(){let e=ne.parse(this.token);return e!==null&&!e.isExpired(vi)}async hasValidToken(e,o,r=0){let i=ne.parse(this.token);return i!==null&&await i.isValid(e,o,r)}authenticate(e){return this.authenticateOnce.execute(e)}link(e){return this.linkOnce.execute(e)}refresh(){return this.refreshOnce.execute()}forkSession(){return this.forkSessionOnce.execute()}destroy(){return this.destroyOnce.execute()}async _authenticate(e){try{let{token:o,refresh_token:r,user:i,is_new_user:n}=await e.authenticate();return this.storeToken(o),this.storeRefreshToken(r),{user:Y(i),isNewUser:n}}catch(o){throw console.warn("Error authenticating session"),H(o)}}async _link(e){try{let o=await e.link();return Y(o)}catch(o){throw console.warn("Error linking account"),H(o)}}async _refresh(){if(!this.api)throw new u("Session has no API instance");let e=this.token,o=this.refreshToken;if(!e||!o)return null;try{let r=await this.api.post(Eo(),{refresh_token:o});return this.storeToken(r.data.token),this.storeRefreshToken(r.data.refresh_token),Y(r.data.user)}catch(r){throw H(r)}}async _destroy(){var e;try{await((e=this.api)==null?void 0:e.post(ko(),{refresh_token:this.refreshToken}))}catch{console.warn("Error destroying session")}this.destroyLocalState()}async _forkSession(){if(!this.api)throw new u("Session has no API instance");let e=this.refreshToken;try{let o=await this.api.post(_o(),{refresh_token:e});return this.storeToken(o.data.token),this.storeRefreshToken(o.data.refresh_token),o.data.new_session_refresh_token}catch(o){throw H(o)}}destroyLocalState(){this.storeToken(null),this.storeRefreshToken(null),A.del(K)}storeToken(e){typeof e=="string"?A.put(ke,e):A.del(ke)}storeRefreshToken(e){typeof e=="string"?A.put(ot,e):A.del(ot)}};import{getAddress as _i}from"@ethersproject/address";import jo from"@walletconnect/web3-provider";import{ErrorCode as xi}from"@ethersproject/logger";var Pe=class extends V{constructor(){super("Wallet timeout");this.type="wallet_error"}},st=t=>{if(t instanceof V)return t;if((t==null?void 0:t.code)&&(t==null?void 0:t.reason)){let e=new Se(t);return t.code===xi.ACTION_REJECTED&&(e.details=me.E4001_USER_REJECTED_REQUEST),e}return t!=null&&t.code?new Se(t):new V("Unknown connector error",t)},zt=class extends z{constructor(o,r,i){super(o);this.type="provider_error";this.code=r,this.data=i}},Se=class extends zt{constructor(o){var n,s,c;let r=o;super(r.message,r.code,r.data);let i=Object.values(me).find(m=>m.eipCode===r.code);this.details=i||me.UNKNOWN_ERROR,r.code===-32002&&((n=r.message)!=null&&n.includes("already pending for origin")?(s=r.message)!=null&&s.includes("wallet_requestPermissions")?this.details=me.E32002_CONNECTION_ALREADY_PENDING:this.details=me.E32002_REQUEST_ALREADY_PENDING:(c=r.message)!=null&&c.includes("Already processing")&&r.message.includes("eth_requestAccounts")&&(this.details=me.E32002_WALLET_LOCKED))}},Li={ERROR_USER_EXISTS:{message:"User already exists for this address",detail:"Try another address!",retryable:!1},ERROR_TIMED_OUT:{message:"Wallet request timed out",detail:"Please try connecting again.",retryable:!0},ERROR_WALLET_CONNECTION:{message:"Could not log in with wallet",detail:"Please try connecting again.",retryable:!0},ERROR_WALLET_NOT_ALLOWED:{message:"You don\u2019t have access to this app",detail:"Try with a different address?",retryable:!0}},Ai={E32002_CONNECTION_ALREADY_PENDING:{eipCode:-32002,message:"Connection request already pending",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E32002_REQUEST_ALREADY_PENDING:{eipCode:-32002,message:"Resource request already pending",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E32002_WALLET_LOCKED:{eipCode:-32002,message:"Wallet might be locked",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E4001_USER_REJECTED_REQUEST:{eipCode:4001,message:"Signature rejected",detail:"Please try signing again.",retryable:!0}},Ei={E4001_DEFAULT_USER_REJECTED_REQUEST:{eipCode:4001,message:"User Rejected Request",detail:"The user rejected the request.",default:!0,retryable:!0},E4100_DEFAULT_UNAUTHORIZED:{eipCode:4100,message:"Unauthorized",detail:"The requested method and/or account has not been authorized by the user.",default:!0,retryable:!1},E4200_DEFAULT_UNSUPPORTED_METHOD:{eipCode:4200,message:"Unsupported Method",detail:"The Provider does not support the requested method.",default:!0,retryable:!1},E4900_DEFAULT_DISCONNECTED:{eipCode:4900,message:"Disconnected",detail:"The Provider is disconnected from all chains.",default:!0,retryable:!0},E4901_DEFAULT_CHAIN_DISCONNECTED:{eipCode:4901,message:"Chain Disconnected",detail:"The Provider is not connected to the requested chain.",default:!0,retryable:!0},E32700_DEFAULT_PARSE_ERROR:{eipCode:-32700,message:"Parse error",detail:"Invalid JSON",default:!0,retryable:!1},E32600_DEFAULT_INVALID_REQUEST:{eipCode:-32600,message:"Invalid request",detail:"JSON is not a valid request object",default:!0,retryable:!1},E32601_DEFAULT_METHOD_NOT_FOUND:{eipCode:-32601,message:"Method not found",detail:"Method does not exist",default:!0,retryable:!1},E32602_DEFAULT_INVALID_PARAMS:{eipCode:-32602,message:"Invalid params",detail:"Invalid method parameters",default:!0,retryable:!1},E32603_DEFAULT_INTERNAL_ERROR:{eipCode:-32603,message:"Internal error",detail:"Internal JSON-RPC error",default:!0,retryable:!0},E32000_DEFAULT_INVALID_INPUT:{eipCode:-32e3,message:"Invalid input",detail:"Missing or invalid parameters",default:!0,retryable:!1},E32001_DEFAULT_RESOURCE_NOT_FOUND:{eipCode:-32001,message:"Resource not found",detail:"Requested resource not found",default:!0,retryable:!1},E32002_DEFAULT_RESOURCE_UNAVAILABLE:{eipCode:-32002,message:"Resource unavailable",detail:"Requested resource not available",default:!0,retryable:!0},E32003_DEFAULT_TRANSACTION_REJECTED:{eipCode:-32003,message:"Transaction rejected",detail:"Transaction creation failed",default:!0,retryable:!0},E32004_DEFAULT_METHOD_NOT_SUPPORTED:{eipCode:-32004,message:"Method not supported",detail:"Method is not implemented",default:!0,retryable:!1},E32005_DEFAULT_LIMIT_EXCEEDED:{eipCode:-32005,message:"Limit exceeded",detail:"Request exceeds defined limit",default:!0,retryable:!1},E32006_DEFAULT_JSON_RPC_VERSION_NOT_SUPPORTED:{eipCode:-32006,message:"JSON-RPC version not supported",detail:"Version of JSON-RPC protocol is not supported",default:!0,retryable:!1}},me={UNKNOWN_ERROR:{eipCode:0,message:"Unknown error",detail:"Unknown error",retryable:!0},...Ei,...Ai},Ge={...Li,...me};var ki=12e4,jt=(t=new Pe,e=ki)=>new Promise((o,r)=>setTimeout(()=>{r(t)},e)),fe=class{constructor(e){this.removeListener=(e,o)=>{if(this.walletProvider)return this.walletProvider.removeListener(e,o)};this.setProvider=e=>{this.walletProvider=e,this._subscriptions.forEach(o=>{var r;(r=this.walletProvider)==null||r.on(o.eventName,o.listener)})};this.walletProvider=e,this._subscriptions=[]}on(e,o){if(this.walletProvider)return this.walletProvider.on(e,o);this._subscriptions.push({eventName:e,listener:o})}request(e){if(!this.walletProvider)throw new V(`A wallet request of type ${e.method} was made before setting a wallet provider.`);return Promise.race([this.walletProvider.request(e),jt()]).catch(o=>{throw st(o)})}},ge=class extends fe{constructor(o){super(o)}},at=class extends fe{constructor(e){super(e)}sendAsync(e,o){throw new Error("sendAsync is no longer supported by EIP-1193. Use the request method instead.")}};import{Web3Provider as Pi}from"@ethersproject/providers";var zo=["metamask","coinbase_wallet","wallet_connect"];import Si from"@coinbase/wallet-sdk";var Ti=()=>{let t=`https://mainnet.infura.io/v3/${tt}`,e=1;return new Si({appName:"Privy",darkMode:!1,headlessMode:!1}).makeWeb3Provider(t,e)},Zt=()=>{if(!window.ethereum)return!1;if(window.ethereum.isMetaMask)return!0;if(window.ethereum.providers){for(let t of window.ethereum.providers)if(t.isMetaMask)return!0}return!1},lt=()=>{if(!window.ethereum)return!1;if(window.ethereum.isCoinbaseWallet)return!0;if(window.ethereum.providers){for(let t of window.ethereum.providers)if(t.isCoinbaseWallet)return!0}return!1},Ve=class{constructor(){this.walletType=null;this.getEthereumProvider=()=>this.ethProvider;this.createSiweMessage=(e,o,r,i,n,s,c)=>`${r} wants you to sign in with your Ethereum account:
1
+ import{useEffect as Ot,useState as re}from"react";import Vt from"axios";import gi from"axios";var z=class extends Error{constructor(o,r){super(o);r instanceof Error&&(this.cause=r)}toString(){return`${this.type}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}},et=class extends z{constructor(o,r,i,n){super(i,n);this.type=o;this.status=r}},u=class extends z{constructor(o,r){super(o,r);this.type="client_error"}};var V=class extends z{constructor(o,r){super(o,r);this.type="connector_error"}},I=t=>{if(t instanceof z)return t;if(!gi.isAxiosError(t))return H(t);if(!t.response)return new et("api_error",null,t.message,t);let{type:e,message:o,error:r}=t.response.data;return new et(e||"ApiError",t.response.status,o||r,t)},H=t=>t instanceof z?t:t instanceof Error?new u(t.message,t):new u(`Internal error: ${t}`);var wo="1.12.0";var yo="https://api.privy.io/v0",bo=process.env.NEXT_PUBLIC_PRIVY_AUTH_URL||"https://auth.privy.io",tt="4df5e2316331463a9130964bd6078dfa",Co=1e4,Ee=1400,vo=365*24*60*60,Gt=wo,xo="ES256",Lo="privy.io",ke="privy:token",ot="privy:refresh_token",K="privy:active_wallet",rt="privy:wallet_type",Ao="walletconnect";var it=class{constructor(e,o,r){this.appId=e,this.sdkVersion=Gt,this.session=o,this.defaults=r}async get(e,o){try{return await Vt.get(e,this.buildConfig({headers:{"Cache-Control":"no-cache"},...o}))}catch(r){throw I(r)}}async post(e,o,r){try{return await Vt.post(e,o,this.buildConfig(r))}catch(i){throw I(i)}}async delete(e,o){try{return await Vt.delete(e,this.buildConfig(o))}catch(r){throw I(r)}}buildConfig(e){return e=e||{},e.headers=e.headers||{},e.headers["privy-app-id"]=this.appId,e.headers["privy-client"]=`react-auth:${this.sdkVersion}`,this.session.token!==null&&(e.headers.authorization=`Bearer ${this.session.token}`),{...this.defaults,...e}}};import*as _e from"jose";var ne=class{static parse(e){try{return new ne(e)}catch{return null}}constructor(e){this.value=e,this._decoded=_e.decodeJwt(e)}get subject(){return this._decoded.sub}get expiration(){return this._decoded.exp}get issuer(){return this._decoded.iss}get audience(){return this._decoded.aud}isExpired(e=0){let o=Date.now(),r=(this.expiration-e)*1e3;return o>=r}async isValid(e,o,r=0){let i=await _e.importSPKI(e,xo);try{return await _e.jwtVerify(this.value,i,{issuer:Lo,audience:o,clockTolerance:r}),!0}catch{return!1}}};var se=class{constructor(e){this.promise=null;this.fn=e}execute(e){return this.promise===null&&(this.promise=(async()=>{try{return await this.fn(e)}finally{this.promise=null}})()),this.promise}};var Ht=class{constructor(){this._cache={}}get(e){return this._cache[e]}put(e,o){o!==void 0?this._cache[e]=o:this.del(e)}del(e){delete this._cache[e]}},Bt=class{get(e){let o=localStorage.getItem(e);return o===null?void 0:JSON.parse(o)}put(e,o){o!==void 0?localStorage.setItem(e,JSON.stringify(o)):this.del(e)}del(e){localStorage.removeItem(e)}};function yi(){return typeof window<"u"&&window.localStorage?new Bt:new Ht}var E=yi();function ae(t){return new Date(t*1e3)}function bi(t){return t.map(e=>{switch(e.type){case"wallet":return{address:e.address,type:e.type,verifiedAt:ae(e.verified_at),chainType:e.chain_type};case"email":return{address:e.address,type:e.type,verifiedAt:ae(e.verified_at)};case"phone":return{number:e.phoneNumber,type:e.type,verifiedAt:ae(e.verified_at)};case"google_oauth":return{subject:e.subject,email:e.email,name:e.name,type:e.type,verifiedAt:ae(e.verified_at)};case"twitter_oauth":return{subject:e.subject,username:e.username,name:e.name,type:e.type,verifiedAt:ae(e.verified_at)};case"discord_oauth":return{subject:e.subject,username:e.username,email:e.email,type:e.type,verifiedAt:ae(e.verified_at)};case"github_oauth":return{subject:e.subject,username:e.username,name:e.name,email:e.email,type:e.type,verifiedAt:ae(e.verified_at)};default:throw new u("Unrecognized account type")}})}function Ci(t,e){return e.find(o=>o.type==="wallet"&&o.address===t)}function le(t,e){return t.sort((o,r)=>r.verifiedAt.getTime()-o.verifiedAt.getTime()),t.find(o=>o.type===e)}function Fe(t){let e=t.linkedAccounts.map(s=>s.type==="wallet"?s.address:null),r=E.get(K);if(!r||!e.includes(r)){E.del(K);let s=le(t.linkedAccounts,"wallet");s&&(r=s.address,E.put(K,r))}let i=Ci(r,t.linkedAccounts),n=Object.assign({},t);return n.wallet=i&&{address:i.address,chainType:i.chainType,chainId:i.chainId,walletType:i.walletType},n}function Y(t){if(!t)return null;let e=bi(t.linked_accounts),o=le(e,"wallet"),r=le(e,"email"),i=le(e,"phone"),n=le(e,"google_oauth"),s=le(e,"twitter_oauth"),c=le(e,"discord_oauth"),m=le(e,"github_oauth"),p={id:t.id,createdAt:ae(t.created_at),linkedAccounts:e,email:r&&{address:r==null?void 0:r.address},phone:i&&{number:i==null?void 0:i.number},wallet:o&&{address:o.address,chainType:o.chainType,chainId:o.chainId,walletType:o.walletType},google:n&&{subject:n.subject,email:n.email,name:n.name},twitter:s&&{subject:s.subject,username:s.username,name:s.name},discord:c&&{subject:c.subject,username:c.username,email:c.email},github:m&&{subject:m.subject,username:m.username,name:m.name,email:m.email}};return Fe(p)}var Eo=()=>"/api/v1/sessions",ko=()=>"/api/v1/sessions/logout",_o=()=>"/api/v1/sessions/fork",Po=()=>"/api/v1/siwe/init",So=()=>"/api/v1/siwe/authenticate",To=()=>"/api/v1/siwe/link",Io=()=>"/api/v1/passwordless/init",Mo=()=>"/api/v1/passwordless/authenticate",Ro=()=>"/api/v1/passwordless/link",Wo=()=>"/api/v1/passwordless_sms/init",Oo=()=>"/api/v1/passwordless_sms/authenticate",No=()=>"/api/v1/passwordless_sms/link",Uo=()=>"/api/v1/oauth/init",Do=()=>"/api/v1/oauth/authenticate",Fo=()=>"/api/v1/oauth/link",Go=()=>"/api/v1/siwe/unlink",Vo=()=>"/api/v1/passwordless/unlink",Ho=()=>"/api/v1/passwordless_sms/unlink",Bo=()=>"/api/v1/oauth/unlink";var vi=30,nt=class{constructor(){this.authenticateOnce=new se(async e=>this._authenticate(e)),this.linkOnce=new se(async e=>this._link(e)),this.refreshOnce=new se(this._refresh.bind(this)),this.destroyOnce=new se(this._destroy.bind(this)),this.forkSessionOnce=new se(this._forkSession.bind(this))}get token(){try{let e=E.get(ke);return typeof e=="string"?new ne(e).value:null}catch(e){return console.error(e),this.destroyLocalState(),null}}get refreshToken(){try{let e=E.get(ot);return typeof e=="string"?e:null}catch(e){return console.error(e),this.destroyLocalState(),null}}hasRefreshCredentials(){return typeof this.token=="string"&&typeof this.refreshToken=="string"}hasActiveToken(){let e=ne.parse(this.token);return e!==null&&!e.isExpired(vi)}async hasValidToken(e,o,r=0){let i=ne.parse(this.token);return i!==null&&await i.isValid(e,o,r)}authenticate(e){return this.authenticateOnce.execute(e)}link(e){return this.linkOnce.execute(e)}refresh(){return this.refreshOnce.execute()}forkSession(){return this.forkSessionOnce.execute()}destroy(){return this.destroyOnce.execute()}async _authenticate(e){try{let{token:o,refresh_token:r,user:i,is_new_user:n}=await e.authenticate();return this.storeToken(o),this.storeRefreshToken(r),{user:Y(i),isNewUser:n}}catch(o){throw console.warn("Error authenticating session"),H(o)}}async _link(e){try{let o=await e.link();return Y(o)}catch(o){throw console.warn("Error linking account"),H(o)}}async _refresh(){if(!this.api)throw new u("Session has no API instance");let e=this.token,o=this.refreshToken;if(!e||!o)return null;try{let r=await this.api.post(Eo(),{refresh_token:o});return this.storeToken(r.data.token),this.storeRefreshToken(r.data.refresh_token),Y(r.data.user)}catch(r){throw H(r)}}async _destroy(){var e;try{await((e=this.api)==null?void 0:e.post(ko(),{refresh_token:this.refreshToken}))}catch{console.warn("Error destroying session")}this.destroyLocalState()}async _forkSession(){if(!this.api)throw new u("Session has no API instance");let e=this.refreshToken;try{let o=await this.api.post(_o(),{refresh_token:e});return this.storeToken(o.data.token),this.storeRefreshToken(o.data.refresh_token),o.data.new_session_refresh_token}catch(o){throw H(o)}}destroyLocalState(){this.storeToken(null),this.storeRefreshToken(null),E.del(K)}storeToken(e){typeof e=="string"?E.put(ke,e):E.del(ke)}storeRefreshToken(e){typeof e=="string"?E.put(ot,e):E.del(ot)}};import{getAddress as _i}from"@ethersproject/address";import jo from"@walletconnect/web3-provider";import{ErrorCode as xi}from"@ethersproject/logger";var Pe=class extends V{constructor(){super("Wallet timeout");this.type="wallet_error"}},st=t=>{if(t instanceof V)return t;if((t==null?void 0:t.code)&&(t==null?void 0:t.reason)){let e=new Se(t);return t.code===xi.ACTION_REJECTED&&(e.details=me.E4001_USER_REJECTED_REQUEST),e}return t!=null&&t.code?new Se(t):new V("Unknown connector error",t)},zt=class extends z{constructor(o,r,i){super(o);this.type="provider_error";this.code=r,this.data=i}},Se=class extends zt{constructor(o){var n,s,c;let r=o;super(r.message,r.code,r.data);let i=Object.values(me).find(m=>m.eipCode===r.code);this.details=i||me.UNKNOWN_ERROR,r.code===-32002&&((n=r.message)!=null&&n.includes("already pending for origin")?(s=r.message)!=null&&s.includes("wallet_requestPermissions")?this.details=me.E32002_CONNECTION_ALREADY_PENDING:this.details=me.E32002_REQUEST_ALREADY_PENDING:(c=r.message)!=null&&c.includes("Already processing")&&r.message.includes("eth_requestAccounts")&&(this.details=me.E32002_WALLET_LOCKED))}},Li={ERROR_USER_EXISTS:{message:"User already exists for this address",detail:"Try another address!",retryable:!1},ERROR_TIMED_OUT:{message:"Wallet request timed out",detail:"Please try connecting again.",retryable:!0},ERROR_WALLET_CONNECTION:{message:"Could not log in with wallet",detail:"Please try connecting again.",retryable:!0},ERROR_WALLET_NOT_ALLOWED:{message:"You don\u2019t have access to this app",detail:"Try with a different address?",retryable:!0}},Ai={E32002_CONNECTION_ALREADY_PENDING:{eipCode:-32002,message:"Connection request already pending",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E32002_REQUEST_ALREADY_PENDING:{eipCode:-32002,message:"Resource request already pending",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E32002_WALLET_LOCKED:{eipCode:-32002,message:"Wallet might be locked",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E4001_USER_REJECTED_REQUEST:{eipCode:4001,message:"Signature rejected",detail:"Please try signing again.",retryable:!0}},Ei={E4001_DEFAULT_USER_REJECTED_REQUEST:{eipCode:4001,message:"User Rejected Request",detail:"The user rejected the request.",default:!0,retryable:!0},E4100_DEFAULT_UNAUTHORIZED:{eipCode:4100,message:"Unauthorized",detail:"The requested method and/or account has not been authorized by the user.",default:!0,retryable:!1},E4200_DEFAULT_UNSUPPORTED_METHOD:{eipCode:4200,message:"Unsupported Method",detail:"The Provider does not support the requested method.",default:!0,retryable:!1},E4900_DEFAULT_DISCONNECTED:{eipCode:4900,message:"Disconnected",detail:"The Provider is disconnected from all chains.",default:!0,retryable:!0},E4901_DEFAULT_CHAIN_DISCONNECTED:{eipCode:4901,message:"Chain Disconnected",detail:"The Provider is not connected to the requested chain.",default:!0,retryable:!0},E32700_DEFAULT_PARSE_ERROR:{eipCode:-32700,message:"Parse error",detail:"Invalid JSON",default:!0,retryable:!1},E32600_DEFAULT_INVALID_REQUEST:{eipCode:-32600,message:"Invalid request",detail:"JSON is not a valid request object",default:!0,retryable:!1},E32601_DEFAULT_METHOD_NOT_FOUND:{eipCode:-32601,message:"Method not found",detail:"Method does not exist",default:!0,retryable:!1},E32602_DEFAULT_INVALID_PARAMS:{eipCode:-32602,message:"Invalid params",detail:"Invalid method parameters",default:!0,retryable:!1},E32603_DEFAULT_INTERNAL_ERROR:{eipCode:-32603,message:"Internal error",detail:"Internal JSON-RPC error",default:!0,retryable:!0},E32000_DEFAULT_INVALID_INPUT:{eipCode:-32e3,message:"Invalid input",detail:"Missing or invalid parameters",default:!0,retryable:!1},E32001_DEFAULT_RESOURCE_NOT_FOUND:{eipCode:-32001,message:"Resource not found",detail:"Requested resource not found",default:!0,retryable:!1},E32002_DEFAULT_RESOURCE_UNAVAILABLE:{eipCode:-32002,message:"Resource unavailable",detail:"Requested resource not available",default:!0,retryable:!0},E32003_DEFAULT_TRANSACTION_REJECTED:{eipCode:-32003,message:"Transaction rejected",detail:"Transaction creation failed",default:!0,retryable:!0},E32004_DEFAULT_METHOD_NOT_SUPPORTED:{eipCode:-32004,message:"Method not supported",detail:"Method is not implemented",default:!0,retryable:!1},E32005_DEFAULT_LIMIT_EXCEEDED:{eipCode:-32005,message:"Limit exceeded",detail:"Request exceeds defined limit",default:!0,retryable:!1},E32006_DEFAULT_JSON_RPC_VERSION_NOT_SUPPORTED:{eipCode:-32006,message:"JSON-RPC version not supported",detail:"Version of JSON-RPC protocol is not supported",default:!0,retryable:!1}},me={UNKNOWN_ERROR:{eipCode:0,message:"Unknown error",detail:"Unknown error",retryable:!0},...Ei,...Ai},Ge={...Li,...me};var ki=12e4,jt=(t=new Pe,e=ki)=>new Promise((o,r)=>setTimeout(()=>{r(t)},e)),fe=class{constructor(e){this.removeListener=(e,o)=>{if(this.walletProvider)return this.walletProvider.removeListener(e,o)};this.setProvider=e=>{this.walletProvider=e,this._subscriptions.forEach(o=>{var r;(r=this.walletProvider)==null||r.on(o.eventName,o.listener)})};this.walletProvider=e,this._subscriptions=[]}on(e,o){if(this.walletProvider)return this.walletProvider.on(e,o);this._subscriptions.push({eventName:e,listener:o})}request(e){if(!this.walletProvider)throw new V(`A wallet request of type ${e.method} was made before setting a wallet provider.`);return Promise.race([this.walletProvider.request(e),jt()]).catch(o=>{throw st(o)})}},ge=class extends fe{constructor(o){super(o)}},at=class extends fe{constructor(e){super(e)}sendAsync(e,o){throw new Error("sendAsync is no longer supported by EIP-1193. Use the request method instead.")}};import{Web3Provider as Pi}from"@ethersproject/providers";var zo=["metamask","coinbase_wallet","wallet_connect"];import Si from"@coinbase/wallet-sdk";var Ti=()=>{let t=`https://mainnet.infura.io/v3/${tt}`,e=1;return new Si({appName:"Privy",darkMode:!1,headlessMode:!1}).makeWeb3Provider(t,e)},Zt=()=>{if(!window.ethereum)return!1;if(window.ethereum.isMetaMask)return!0;if(window.ethereum.providers){for(let t of window.ethereum.providers)if(t.isMetaMask)return!0}return!1},lt=()=>{if(!window.ethereum)return!1;if(window.ethereum.isCoinbaseWallet)return!0;if(window.ethereum.providers){for(let t of window.ethereum.providers)if(t.isCoinbaseWallet)return!0}return!1},Ve=class{constructor(){this.walletType=null;this.getEthereumProvider=()=>this.ethProvider;this.createSiweMessage=(e,o,r,i,n,s,c)=>`${r} wants you to sign in with your Ethereum account:
2
2
  ${o}
3
3
 
4
4
  ${c}
@@ -9,7 +9,7 @@ Chain ID: ${e}
9
9
  Nonce: ${s}
10
10
  Issued At: ${n}
11
11
  Resources:
12
- - https://privy.io`;this.ethProvider=new fe}initialize(){let e=A.get(rt);zo.includes(e)&&(this.walletType=e,this.connect({showPrompt:!1}))}destroy(){this.walletType=null,A.del(rt),A.del(Ao)}async getConnectedWallet(){let e=this.walletType;if(!e||!await this.isConnected())return null;let o=await this.address(),r=await this.chainId();return{address:o,chainId:r,chainType:"ethereum",walletType:e}}async connect(e){var o;switch(this.walletType){case"metamask":this.ethProvider.setProvider(window.ethereum),(o=window.ethereum.providers)==null||o.forEach(async i=>{i.isMetaMask&&this.ethProvider.setProvider(i)});break;case"coinbase_wallet":this.ethProvider.setProvider(Ti());break;case"wallet_connect":let r=new jo({infuraId:tt});this.ethProvider.setProvider(r);break;default:throw new V(`Unsupported wallet: ${this.walletType}`)}return(!await this.isConnected()||e.showPrompt)&&await this.promptConnection(this.walletType),this.getConnectedWallet()}async isConnected(){switch(this.walletType){case"metamask":return await this.address()!==null;case"coinbase_wallet":return await this.address()!==null;case"wallet_connect":return this.ethProvider.walletProvider.connected;default:throw new V(`Unsupported wallet: ${this.walletType}`)}}async promptConnection(e){try{switch(e){case"metamask":await this.ethProvider.request({method:"wallet_requestPermissions",params:[{eth_accounts:{}}]}),await this.ethProvider.request({method:"eth_requestAccounts"});break;case"coinbase_wallet":await this.ethProvider.request({method:"eth_requestAccounts"});break;case"wallet_connect":let o=new jo({infuraId:tt});this.ethProvider.setProvider(o),await Promise.race([o.enable(),jt()]);break;default:throw new V(`Unsupported wallet: ${this.walletType}`)}A.put(rt,e)}catch(o){throw st(o)}}async sign(e){return new Pi(new ge(this.getEthereumProvider())).getSigner().signMessage(e)}prepareMessage(e,o,r){let i=window.location.host,n=window.location.origin,s="By signing, you are proving you own this wallet and logging in. This does not initiate a transaction or cost any fees.",c=new Date().toISOString();return this.createSiweMessage(e,o,i,n,c,r,s)}async chainId(){let e=await this.getEthereumProvider().request({method:"eth_chainId"}),o=Number(e);return String(o)}async address(){let e=await this.getEthereumProvider().request({method:"eth_accounts"});return Array.isArray(e)&&e.length>0?_i(e[0]):null}};var $t,He=class{constructor(e){let o=e.apiURL||yo,r=e.timeout||Co;this.appId=e.appId,this.connector=new Ve,this.connector.initialize(),$t||($t=new nt),this.session=$t,this.api=new it(e.appId,this.session,{baseURL:o,timeout:r}),this.session.api=this.api}authenticate(){if(!this.authFlow)throw new u("No auth flow in progress.");return this.session.authenticate(this.authFlow)}link(){if(!this.authFlow)throw new u("No auth flow in progress.");return this.session.link(this.authFlow)}async logout(){await this.session.destroy(),this.connector.destroy(),this.authFlow=void 0}startAuthFlow(e){e.api=this.api,this.authFlow=e}async unlinkEmail(e){try{let o=await this.api.post(Vo(),{address:e});return Y(o.data)}catch(o){throw H(o)}}async unlinkPhone(e){try{let o=await this.api.post(Ho(),{phoneNumber:e});return Y(o.data)}catch(o){throw H(o)}}async unlinkWallet(e){try{let o=await this.api.post(Go(),{address:e});return Y(o.data)}catch(o){throw H(o)}}async unlinkOAuth(e,o){try{let r=await this.api.post(Bo(),{provider:e,subject:o});return Y(r.data)}catch(r){throw H(r)}}async getAuthenticatedUser(){return this.session.hasRefreshCredentials()?this.session.refresh():null}async getAccessToken(){if(this.session.hasActiveToken()){let{verificationKey:e,id:o}=await this.getAppSettings();return await this.session.hasValidToken(e,o,vo)?this.session.token:(await this.logout(),null)}else return this.session.hasRefreshCredentials()?(await this.session.refresh(),this.session.token):null}async getAppSettings(){try{let e=await this.api.get(`/api/v1/apps/${this.appId}`);return{id:e.data.id,name:e.data.name,verificationKey:e.data.verification_key,logoUrl:e.data.logo_url||void 0,theme:e.data.theme,accentColor:e.data.accent_color||void 0,showWalletLoginFirst:e.data.show_wallet_login_first,walletAuth:e.data.wallet_auth,emailAuth:e.data.email_auth,smsAuth:e.data.sms_auth,googleOAuth:e.data.google_oauth,twitterOAuth:e.data.twitter_oauth,discordOAuth:e.data.discord_oauth,githubOAuth:e.data.github_oauth,termsAndConditionsUrl:e.data.terms_and_conditions_url,privacyPolicyUrl:e.data.privacy_policy_url,createdAt:new Date(e.data.created_at*1e3),updatedAt:new Date(e.data.updated_at*1e3)}}catch(e){throw H(e)}}setActiveWallet(e,o){if(!o.linkedAccounts.map(i=>i.type==="wallet"?i.address:null).includes(e))throw new u("Cannot set an unlinked address as active.");return A.put(K,e),Fe(o)}async forkSession(){return await this.session.forkSession()}};import{Web3Provider as Ds}from"@ethersproject/providers";import{createContext as Ii,useContext as Mi}from"react";var f=()=>{throw new Error("You need to wrap your application with the <PrivyProvider> initialized with your app id.")};var Kt=Ii({ready:!1,authenticated:!1,user:null,walletConnector:null,login:f,linkEmail:f,linkPhone:f,linkWallet:f,linkGoogle:f,linkTwitter:f,linkDiscord:f,linkGithub:f,logout:f,getAccessToken:f,getEthereumProvider:f,getEthersProvider:f,getWeb3jsProvider:f,unlinkEmail:f,unlinkPhone:f,unlinkWallet:f,unlinkGoogle:f,unlinkTwitter:f,unlinkDiscord:f,unlinkGithub:f,setActiveWallet:f,forkSession:f}),O=()=>Mi(Kt);var Be=class{constructor(e){this.connector=e,this.meta={wallet:this.connector.walletType}}async authenticate(){if(!this.api)throw new u("Auth flow has no API instance");if(!this.connector.walletType)throw new u("Wallet must be specified");try{let{message:e,signature:o}=await this.promptConnectAndSign(this.api),r=await this.api.post(So(),{message:e,signature:o});return{user:r.data.user,token:r.data.token,refresh_token:r.data.refresh_token,is_new_user:r.data.is_new_user}}catch(e){throw I(e)}}async link(){if(!this.api)throw new u("Auth flow has no API instance");if(!this.connector.walletType)throw new u("Wallet must be specified");try{let{message:e,signature:o}=await this.promptConnectAndSign(this.api);return(await this.api.post(To(),{message:e,signature:o})).data}catch(e){throw I(e)}}async promptConnectAndSign(e){let o=await this.connector.connect({showPrompt:!0}),r=o.address,i=o.chainId,n=await e.post(Po(),{address:r}),s=this.connector.prepareMessage(i,r,n.data.nonce),c=await this.connector.sign(s);return{message:s,signature:c}}getEthereumProvider(){return this.connector.getEthereumProvider()}};var ze=class{constructor(e){this.meta={email:e}}async authenticate(){if(!this.api)throw new u("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new u("Email and email code must be set prior to calling authenticate.");try{let e=Mo(),o=await this.api.post(e,{email:this.meta.email,code:this.meta.emailCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(e){throw I(e)}}async link(){if(!this.api)throw new u("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new u("Email and email code must be set prior to calling authenticate.");try{let e=Ro();return(await this.api.post(e,{email:this.meta.email,code:this.meta.emailCode})).data}catch(e){throw I(e)}}async sendCodeEmail(e){if(!this.api)throw new u("Auth flow has no API instance");if(e&&(this.meta.email=e),!this.meta.email)throw new u("Email must be set when initialzing authentication.");try{let o=Io();return(await this.api.post(o,{email:this.meta.email})).data}catch(o){throw I(o)}}};var je=class{constructor(e){this.meta={phoneNumber:e}}async authenticate(){if(!this.api)throw new u("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new u("phone number and sms code must be set prior to calling authenticate.");try{let e=Oo(),o=await this.api.post(e,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(e){throw I(e)}}async link(){if(!this.api)throw new u("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new u("phone number and sms code must be set prior to calling authenticate.");try{let e=No();return(await this.api.post(e,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})).data}catch(e){throw I(e)}}async sendSmsCode(e){if(!this.api)throw new u("Auth flow has no API instance");if(e&&(this.meta.phoneNumber=e),!this.meta.phoneNumber)throw new u("phone nNumber must be set when initialzing authentication.");try{let o=Wo();return(await this.api.post(o,{phoneNumber:this.meta.phoneNumber})).data}catch(o){throw I(o)}}};var Te=class{constructor(e,o,r){this.meta={provider:e},this.meta.authorizationCode=o,this.meta.stateCode=r}isActive(){return!!(this.meta.authorizationCode&&this.meta.stateCode&&this.meta.provider)}async authenticate(){if(!this.api)throw new u("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new u("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if(this.meta.authorizationCode==="undefined")throw new u("User denied confirmation during OAuth flow");try{let e=Do(),o=await this.api.post(e,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(e){throw I(e)}}async link(){if(!this.api)throw new u("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new u("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if(this.meta.authorizationCode==="undefined")throw new u("User denied confirmation during OAuth flow");try{let e=Fo();return(await this.api.post(e,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode})).data}catch(e){throw I(e)}}async getAuthorizationUrl(){if(!this.api)throw new u("Auth flow has no API instance");if(!this.meta.provider)throw new u("Provider must be set when initialzing OAuth authentication.");try{let e=Uo();return(await this.api.post(e,{provider:this.meta.provider,redirect_to:window.location.href})).data}catch(e){throw I(e)}}};import"wicg-inert";import Ms from"react-dom";import mo from"styled-components";import{createContext as Wi,useContext as Oi,useEffect as $o,useState as Ko}from"react";import{jsx as Ri}from"react/jsx-runtime";function Zo(t){return Ri("link",{rel:"prefetch",href:t.src})}import{jsx as Ni,jsxs as Ui}from"react/jsx-runtime";var qo=Wi({ready:!1,app:null,options:{email:!0,sms:!1,wallet:!0,google:!1,twitter:!1,discord:!1,github:!1},currentScreen:"LANDING",lastScreen:"LANDING",navigate:f,navigateBack:f}),Yo=t=>{let e=t.appSettings,o=t.authenticated,r=t.visible,[i,n]=Ko(null),[s,c]=Ko(null);$o(()=>{o||n(null)},[o]),$o(()=>{r||(c("LANDING"),n("LANDING"))},[r]);let m={ready:!!(e!=null&&e.id),app:e,options:t.options,currentScreen:i||"LANDING",lastScreen:s||"LANDING",navigate:p=>{c(i),n(p)},navigateBack:()=>{n(s)}};return Ui(qo.Provider,{value:m,children:[e&&e.logoUrl&&Ni(Zo,{src:e.logoUrl}),t.children]})},w=()=>Oi(qo);import{useEffect as In,useState as Mn}from"react";import qe from"styled-components";import Gi from"styled-components";import{jsx as Jo}from"react/jsx-runtime";var Qo=({style:t,...e})=>Jo("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",style:{height:"1.5rem",width:"1.5rem",...t},...e,children:Jo("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})});import{jsx as Xo}from"react/jsx-runtime";var er=({style:t,...e})=>Xo("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",style:{height:"1.5rem",width:"1.5rem",...t},...e,children:Xo("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10.5 19.5L3 12m0 0l7.5-7.5M3 12h18"})});import{createContext as Di,useContext as Fi}from"react";var qt=Di({isLinking:!1,getAuthMeta:f,getAuthFlow:f,closePrivyModal:f,initLoginWithWallet:f,loginWithWallet:f,loginWithCode:f,loginWithEmail:f,loginWithSms:f,resendEmailCode:f,resendSmsCode:f,initLoginWithOAuth:f,loginWithOAuth:f,handleLoginError:f}),P=()=>Fi(qt);import{jsx as J,jsxs as ji}from"react/jsx-runtime";var Vi=()=>J("div",{}),Hi=({backFn:t})=>J("div",{children:J(er,{onClick:t})}),Bi=()=>{let{closePrivyModal:t}=P();return J("div",{children:J("div",{children:J(Qo,{onClick:t})})})};var E=({backFn:t})=>ji(zi,{children:[t?J(Hi,{backFn:t}):J(Vi,{}),J(Bi,{})]}),zi=Gi.div`
12
+ - https://privy.io`;this.ethProvider=new fe}initialize(){let e=E.get(rt);zo.includes(e)&&(this.walletType=e,this.connect({showPrompt:!1}))}destroy(){this.walletType=null,E.del(rt),E.del(Ao)}async getConnectedWallet(){let e=this.walletType;if(!e||!await this.isConnected())return null;let o=await this.address(),r=await this.chainId();return{address:o,chainId:r,chainType:"ethereum",walletType:e}}async connect(e){var o;switch(this.walletType){case"metamask":this.ethProvider.setProvider(window.ethereum),(o=window.ethereum.providers)==null||o.forEach(async i=>{i.isMetaMask&&this.ethProvider.setProvider(i)});break;case"coinbase_wallet":this.ethProvider.setProvider(Ti());break;case"wallet_connect":let r=new jo({infuraId:tt});this.ethProvider.setProvider(r);break;default:throw new V(`Unsupported wallet: ${this.walletType}`)}return(!await this.isConnected()||e.showPrompt)&&await this.promptConnection(this.walletType),this.getConnectedWallet()}async isConnected(){switch(this.walletType){case"metamask":return await this.address()!==null;case"coinbase_wallet":return await this.address()!==null;case"wallet_connect":return this.ethProvider.walletProvider.connected;default:throw new V(`Unsupported wallet: ${this.walletType}`)}}async promptConnection(e){try{switch(e){case"metamask":await this.ethProvider.request({method:"wallet_requestPermissions",params:[{eth_accounts:{}}]}),await this.ethProvider.request({method:"eth_requestAccounts"});break;case"coinbase_wallet":await this.ethProvider.request({method:"eth_requestAccounts"});break;case"wallet_connect":let o=new jo({infuraId:tt});this.ethProvider.setProvider(o),await Promise.race([o.enable(),jt()]);break;default:throw new V(`Unsupported wallet: ${this.walletType}`)}E.put(rt,e)}catch(o){throw st(o)}}async sign(e){return new Pi(new ge(this.getEthereumProvider())).getSigner().signMessage(e)}prepareMessage(e,o,r){let i=window.location.host,n=window.location.origin,s="By signing, you are proving you own this wallet and logging in. This does not initiate a transaction or cost any fees.",c=new Date().toISOString();return this.createSiweMessage(e,o,i,n,c,r,s)}async chainId(){let e=await this.getEthereumProvider().request({method:"eth_chainId"}),o=Number(e);return String(o)}async address(){let e=await this.getEthereumProvider().request({method:"eth_accounts"});return Array.isArray(e)&&e.length>0?_i(e[0]):null}};var $t,He=class{constructor(e){let o=e.apiURL||yo,r=e.timeout||Co;this.appId=e.appId,this.connector=new Ve,this.connector.initialize(),$t||($t=new nt),this.session=$t,this.api=new it(e.appId,this.session,{baseURL:o,timeout:r}),this.session.api=this.api}authenticate(){if(!this.authFlow)throw new u("No auth flow in progress.");return this.session.authenticate(this.authFlow)}link(){if(!this.authFlow)throw new u("No auth flow in progress.");return this.session.link(this.authFlow)}async logout(){await this.session.destroy(),this.connector.destroy(),this.authFlow=void 0}startAuthFlow(e){e.api=this.api,this.authFlow=e}async unlinkEmail(e){try{let o=await this.api.post(Vo(),{address:e});return Y(o.data)}catch(o){throw H(o)}}async unlinkPhone(e){try{let o=await this.api.post(Ho(),{phoneNumber:e});return Y(o.data)}catch(o){throw H(o)}}async unlinkWallet(e){try{let o=await this.api.post(Go(),{address:e});return Y(o.data)}catch(o){throw H(o)}}async unlinkOAuth(e,o){try{let r=await this.api.post(Bo(),{provider:e,subject:o});return Y(r.data)}catch(r){throw H(r)}}async getAuthenticatedUser(){return this.session.hasRefreshCredentials()?this.session.refresh():null}async getAccessToken(){if(this.session.hasActiveToken()){let{verificationKey:e,id:o}=await this.getAppSettings();return await this.session.hasValidToken(e,o,vo)?this.session.token:(await this.logout(),null)}else return this.session.hasRefreshCredentials()?(await this.session.refresh(),this.session.token):null}async getAppSettings(){try{let e=await this.api.get(`/api/v1/apps/${this.appId}`);return{id:e.data.id,name:e.data.name,verificationKey:e.data.verification_key,logoUrl:e.data.logo_url||void 0,theme:e.data.theme,accentColor:e.data.accent_color||void 0,showWalletLoginFirst:e.data.show_wallet_login_first,walletAuth:e.data.wallet_auth,emailAuth:e.data.email_auth,smsAuth:e.data.sms_auth,googleOAuth:e.data.google_oauth,twitterOAuth:e.data.twitter_oauth,discordOAuth:e.data.discord_oauth,githubOAuth:e.data.github_oauth,termsAndConditionsUrl:e.data.terms_and_conditions_url,privacyPolicyUrl:e.data.privacy_policy_url,createdAt:new Date(e.data.created_at*1e3),updatedAt:new Date(e.data.updated_at*1e3)}}catch(e){throw H(e)}}setActiveWallet(e,o){if(!o.linkedAccounts.map(i=>i.type==="wallet"?i.address:null).includes(e))throw new u("Cannot set an unlinked address as active.");return E.put(K,e),Fe(o)}async forkSession(){return await this.session.forkSession()}};import{Web3Provider as Ds}from"@ethersproject/providers";import{createContext as Ii,useContext as Mi}from"react";var f=()=>{throw new Error("You need to wrap your application with the <PrivyProvider> initialized with your app id.")};var Kt=Ii({ready:!1,authenticated:!1,user:null,walletConnector:null,login:f,linkEmail:f,linkPhone:f,linkWallet:f,linkGoogle:f,linkTwitter:f,linkDiscord:f,linkGithub:f,logout:f,getAccessToken:f,getEthereumProvider:f,getEthersProvider:f,getWeb3jsProvider:f,unlinkEmail:f,unlinkPhone:f,unlinkWallet:f,unlinkGoogle:f,unlinkTwitter:f,unlinkDiscord:f,unlinkGithub:f,setActiveWallet:f,forkSession:f}),O=()=>Mi(Kt);var Be=class{constructor(e){this.connector=e,this.meta={wallet:this.connector.walletType}}async authenticate(){if(!this.api)throw new u("Auth flow has no API instance");if(!this.connector.walletType)throw new u("Wallet must be specified");try{let{message:e,signature:o}=await this.promptConnectAndSign(this.api),r=await this.api.post(So(),{message:e,signature:o});return{user:r.data.user,token:r.data.token,refresh_token:r.data.refresh_token,is_new_user:r.data.is_new_user}}catch(e){throw I(e)}}async link(){if(!this.api)throw new u("Auth flow has no API instance");if(!this.connector.walletType)throw new u("Wallet must be specified");try{let{message:e,signature:o}=await this.promptConnectAndSign(this.api);return(await this.api.post(To(),{message:e,signature:o})).data}catch(e){throw I(e)}}async promptConnectAndSign(e){let o=await this.connector.connect({showPrompt:!0}),r=o.address,i=o.chainId,n=await e.post(Po(),{address:r}),s=this.connector.prepareMessage(i,r,n.data.nonce),c=await this.connector.sign(s);return{message:s,signature:c}}getEthereumProvider(){return this.connector.getEthereumProvider()}};var ze=class{constructor(e){this.meta={email:e}}async authenticate(){if(!this.api)throw new u("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new u("Email and email code must be set prior to calling authenticate.");try{let e=Mo(),o=await this.api.post(e,{email:this.meta.email,code:this.meta.emailCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(e){throw I(e)}}async link(){if(!this.api)throw new u("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new u("Email and email code must be set prior to calling authenticate.");try{let e=Ro();return(await this.api.post(e,{email:this.meta.email,code:this.meta.emailCode})).data}catch(e){throw I(e)}}async sendCodeEmail(e){if(!this.api)throw new u("Auth flow has no API instance");if(e&&(this.meta.email=e),!this.meta.email)throw new u("Email must be set when initialzing authentication.");try{let o=Io();return(await this.api.post(o,{email:this.meta.email})).data}catch(o){throw I(o)}}};var je=class{constructor(e){this.meta={phoneNumber:e}}async authenticate(){if(!this.api)throw new u("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new u("phone number and sms code must be set prior to calling authenticate.");try{let e=Oo(),o=await this.api.post(e,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(e){throw I(e)}}async link(){if(!this.api)throw new u("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new u("phone number and sms code must be set prior to calling authenticate.");try{let e=No();return(await this.api.post(e,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})).data}catch(e){throw I(e)}}async sendSmsCode(e){if(!this.api)throw new u("Auth flow has no API instance");if(e&&(this.meta.phoneNumber=e),!this.meta.phoneNumber)throw new u("phone nNumber must be set when initialzing authentication.");try{let o=Wo();return(await this.api.post(o,{phoneNumber:this.meta.phoneNumber})).data}catch(o){throw I(o)}}};var Te=class{constructor(e,o,r){this.meta={provider:e},this.meta.authorizationCode=o,this.meta.stateCode=r}isActive(){return!!(this.meta.authorizationCode&&this.meta.stateCode&&this.meta.provider)}async authenticate(){if(!this.api)throw new u("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new u("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if(this.meta.authorizationCode==="undefined")throw new u("User denied confirmation during OAuth flow");try{let e=Do(),o=await this.api.post(e,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(e){throw I(e)}}async link(){if(!this.api)throw new u("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new u("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if(this.meta.authorizationCode==="undefined")throw new u("User denied confirmation during OAuth flow");try{let e=Fo();return(await this.api.post(e,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode})).data}catch(e){throw I(e)}}async getAuthorizationUrl(){if(!this.api)throw new u("Auth flow has no API instance");if(!this.meta.provider)throw new u("Provider must be set when initialzing OAuth authentication.");try{let e=Uo();return(await this.api.post(e,{provider:this.meta.provider,redirect_to:window.location.href})).data}catch(e){throw I(e)}}};import"wicg-inert";import Ms from"react-dom";import mo from"styled-components";import{createContext as Wi,useContext as Oi,useEffect as $o,useState as Ko}from"react";import{jsx as Ri}from"react/jsx-runtime";function Zo(t){return Ri("link",{rel:"prefetch",href:t.src})}import{jsx as Ni,jsxs as Ui}from"react/jsx-runtime";var qo=Wi({ready:!1,app:null,options:{email:!0,sms:!1,wallet:!0,google:!1,twitter:!1,discord:!1,github:!1},currentScreen:"LANDING",lastScreen:"LANDING",navigate:f,navigateBack:f}),Yo=t=>{let e=t.appSettings,o=t.authenticated,r=t.visible,[i,n]=Ko(null),[s,c]=Ko(null);$o(()=>{o||n(null)},[o]),$o(()=>{r||(c("LANDING"),n("LANDING"))},[r]);let m={ready:!!(e!=null&&e.id),app:e,options:t.options,currentScreen:i||"LANDING",lastScreen:s||"LANDING",navigate:p=>{c(i),n(p)},navigateBack:()=>{n(s)}};return Ui(qo.Provider,{value:m,children:[e&&e.logoUrl&&Ni(Zo,{src:e.logoUrl}),t.children]})},w=()=>Oi(qo);import{useEffect as In,useState as Mn}from"react";import qe from"styled-components";import Gi from"styled-components";import{jsx as Jo}from"react/jsx-runtime";var Qo=({style:t,...e})=>Jo("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",style:{height:"1.5rem",width:"1.5rem",...t},...e,children:Jo("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})});import{jsx as Xo}from"react/jsx-runtime";var er=({style:t,...e})=>Xo("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",style:{height:"1.5rem",width:"1.5rem",...t},...e,children:Xo("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10.5 19.5L3 12m0 0l7.5-7.5M3 12h18"})});import{createContext as Di,useContext as Fi}from"react";var qt=Di({isLinking:!1,getAuthMeta:f,getAuthFlow:f,closePrivyModal:f,initLoginWithWallet:f,loginWithWallet:f,loginWithCode:f,loginWithEmail:f,loginWithSms:f,resendEmailCode:f,resendSmsCode:f,initLoginWithOAuth:f,loginWithOAuth:f,handleLoginError:f}),P=()=>Fi(qt);import{jsx as J,jsxs as ji}from"react/jsx-runtime";var Vi=()=>J("div",{}),Hi=({backFn:t})=>J("div",{children:J(er,{onClick:t})}),Bi=()=>{let{closePrivyModal:t}=P();return J("div",{children:J("div",{children:J(Qo,{onClick:t})})})};var k=({backFn:t})=>ji(zi,{children:[t?J(Hi,{backFn:t}):J(Vi,{}),J(Bi,{})]}),zi=Gi.div`
13
13
  height: 30px;
14
14
  display: flex;
15
15
  align-items: center;
@@ -302,7 +302,7 @@ Resources:
302
302
  border-color: var(--fail-light);
303
303
  border-bottom-color: var(--fail-light);
304
304
  }
305
- `;import{isPossiblePhoneNumber as mn}from"libphonenumber-js/min";var yr=t=>!!String(t).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,}))$/),br=t=>mn(String(t),"US"),bt=t=>{var e=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;t=t.replace(e,function(r,i,n,s){return i+i+n+n+s+s});var o=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return{r:parseInt((o==null?void 0:o[1])||"00",16),g:parseInt((o==null?void 0:o[2])||"00",16),b:parseInt((o==null?void 0:o[3])||"00",16)}},Cr=(t,e)=>{var o=t.slice(0);let r=[];for(;o.length;)r.push(o.splice(0,e));return r};import{Fragment as xn,jsx as ee,jsxs as Xt}from"react/jsx-runtime";var Ct=t=>{let[e,o]=Qt(""),[r,i]=Qt(!1),[n,s]=Qt(null),{authenticated:c}=O(),{loginWithEmail:m,handleLoginError:p}=P(),{navigate:S,options:v}=w(),k=v.wallet;fn(()=>{let l=document.querySelector("#email-input");l==null||l.focus()},[]);let x=yr(e),L=()=>{i(!0),m(e).then(()=>{S("AWAITING_PASSWORDLESS_CODE")}).catch(l=>{let y=(l==null?void 0:l.status)===401&&(l==null?void 0:l.message)==="User is not allowed to login to this app.";(l==null?void 0:l.status)===422?s(l.message):s(y?"You don't have access to this app":"Issue submitting email"),i(!1),p(y)})};return Xt(xn,{children:[Xt(gn,{stacked:t.stacked,children:[Xt(bn,{standalone:t.stacked,children:[ee(wt,{}),ee("input",{id:"email-input",type:"email",placeholder:"your@email.com",onChange:l=>o(l.target.value),onKeyUp:l=>{l.key==="Enter"&&L()},value:e,autoComplete:"email"})]}),t.stacked?null:ee(wn,{disabled:r||!x,onClick:L,children:r?ee(pe,{color:"var(--disabled-fg)",style:{height:"1rem",width:"1rem",borderWidth:"2px"}}):"Submit"})]}),n||c||!k?ee(vn,{fail:!!n,children:n||""}):null,!n&&!c&&k?ee(Cn,{children:ee("span",{children:"Get started without a wallet."})}):null,t.stacked?ee(yn,{disabled:r||!x,onClick:L,children:r?ee(pe,{color:"var(--disabled-fg)",style:{height:"1rem",width:"1rem",borderWidth:"2px"}}):"Submit"}):null]})},gn=Re.div`
305
+ `;import{isPossiblePhoneNumber as mn}from"libphonenumber-js/min";var yr=t=>!!String(t).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,}))$/),br=t=>mn(String(t),"US"),bt=t=>{var e=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;t=t.replace(e,function(r,i,n,s){return i+i+n+n+s+s});var o=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return{r:parseInt((o==null?void 0:o[1])||"00",16),g:parseInt((o==null?void 0:o[2])||"00",16),b:parseInt((o==null?void 0:o[3])||"00",16)}},Cr=(t,e)=>{var o=t.slice(0);let r=[];for(;o.length;)r.push(o.splice(0,e));return r};import{Fragment as xn,jsx as ee,jsxs as Xt}from"react/jsx-runtime";var Ct=t=>{let[e,o]=Qt(""),[r,i]=Qt(!1),[n,s]=Qt(null),{authenticated:c}=O(),{loginWithEmail:m,handleLoginError:p}=P(),{navigate:S,options:v}=w(),x=v.wallet;fn(()=>{let l=document.querySelector("#email-input");l==null||l.focus()},[]);let L=yr(e),A=()=>{i(!0),m(e).then(()=>{S("AWAITING_PASSWORDLESS_CODE")}).catch(l=>{let y=(l==null?void 0:l.status)===401&&(l==null?void 0:l.message)==="User is not allowed to login to this app.";(l==null?void 0:l.status)===422?s(l.message):s(y?"You don't have access to this app":"Issue submitting email"),i(!1),p(y)})};return Xt(xn,{children:[Xt(gn,{stacked:t.stacked,children:[Xt(bn,{standalone:t.stacked,children:[ee(wt,{}),ee("input",{id:"email-input",type:"email",placeholder:"your@email.com",onChange:l=>o(l.target.value),onKeyUp:l=>{l.key==="Enter"&&A()},value:e,autoComplete:"email"})]}),t.stacked?null:ee(wn,{disabled:r||!L,onClick:A,children:r?ee(pe,{color:"var(--disabled-fg)",style:{height:"1rem",width:"1rem",borderWidth:"2px"}}):"Submit"})]}),n||c||!x?ee(vn,{fail:!!n,children:n||""}):null,!n&&!c&&x?ee(Cn,{children:ee("span",{children:"Get started without a wallet."})}):null,t.stacked?ee(yn,{disabled:r||!L,onClick:A,children:r?ee(pe,{color:"var(--disabled-fg)",style:{height:"1rem",width:"1rem",borderWidth:"2px"}}):"Submit"}):null]})},gn=Re.div`
306
306
  display: flex;
307
307
  border: 1px solid #d1d5db;
308
308
  width: 100%;
@@ -422,7 +422,7 @@ Resources:
422
422
  opacity: ${t=>t.success||t.fail?"1":"0"};
423
423
 
424
424
  transition: ${t=>t.fail?"":"all 150ms ease-in-out"};
425
- `;import{useEffect as Ln,useState as eo}from"react";import be from"styled-components";import{jsx as vr}from"react/jsx-runtime";var vt=({style:t,...e})=>vr("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 20 20",strokeWidth:1.5,stroke:"currentColor",style:{height:"1.5rem",width:"1.5rem",...t},...e,children:vr("path",{d:"M2.5 4.16667C2.5 3.72464 2.67559 3.30072 2.98816 2.98816C3.30072 2.67559 3.72464 2.5 4.16667 2.5H6.9C7.07483 2.50013 7.24519 2.55525 7.38696 2.65754C7.52874 2.75984 7.63475 2.90413 7.69 3.07L8.93833 6.81417C9.00158 7.00445 8.9941 7.21116 8.91726 7.39637C8.84042 7.58158 8.69938 7.73288 8.52 7.8225L6.63917 8.76417C7.5611 10.8046 9.19538 12.4389 11.2358 13.3608L12.1775 11.48C12.2671 11.3006 12.4184 11.1596 12.6036 11.0827C12.7888 11.0059 12.9956 10.9984 13.1858 11.0617L16.93 12.31C17.096 12.3653 17.2404 12.4714 17.3427 12.6134C17.445 12.7553 17.5 12.9259 17.5 13.1008V15.8333C17.5 16.2754 17.3244 16.6993 17.0118 17.0118C16.6993 17.3244 16.2754 17.5 15.8333 17.5H15C8.09667 17.5 2.5 11.9033 2.5 5V4.16667Z",strokeLinecap:"round",strokeLinejoin:"round"})});import{Fragment as Tn,jsx as te,jsxs as to}from"react/jsx-runtime";var xt=t=>{let[e,o]=eo(""),[r,i]=eo(!1),[n,s]=eo(null),{authenticated:c}=O(),{loginWithSms:m,handleLoginError:p}=P(),{navigate:S,options:v}=w(),k=v.wallet;Ln(()=>{let l=document.querySelector("#phone-number-input");l==null||l.focus()},[]);let x=br(e),L=()=>{i(!0),m(e).then(()=>{S("AWAITING_PASSWORDLESS_CODE")}).catch(l=>{let y=(l==null?void 0:l.status)===401&&(l==null?void 0:l.message)==="User is not allowed to login to this app.";(l==null?void 0:l.status)===422?s(l.message):s(y?"You don't have access to this app":"Issue submitting phone number"),i(!1),p(y)})};return to(Tn,{children:[to(An,{stacked:t.stacked,children:[to(_n,{standalone:t.stacked,children:[te(vt,{}),te("input",{id:"phone-number-input",type:"tel",placeholder:"555 555 5555",onChange:l=>{o(l.target.value)},onKeyUp:l=>{l.key==="Enter"&&L()},value:e,autoComplete:"tel"})]}),t.stacked?null:te(En,{disabled:r||!x,onClick:L,children:r?te(xr,{color:"var(--disabled-fg)"}):"Submit"})]}),n||c||!k?te(Sn,{fail:!!n,children:n||""}):null,!n&&!c&&k?te(Pn,{children:te("span",{children:"Don\u2019t have a wallet? Start exploring with your phone or socials."})}):null,t.stacked?te(kn,{disabled:r||!x,onClick:L,children:r?te(xr,{color:"var(--disabled-fg)"}):"Submit"}):null]})},An=be.div`
425
+ `;import{useEffect as Ln,useState as eo}from"react";import be from"styled-components";import{jsx as vr}from"react/jsx-runtime";var vt=({style:t,...e})=>vr("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 20 20",strokeWidth:1.5,stroke:"currentColor",style:{height:"1.5rem",width:"1.5rem",...t},...e,children:vr("path",{d:"M2.5 4.16667C2.5 3.72464 2.67559 3.30072 2.98816 2.98816C3.30072 2.67559 3.72464 2.5 4.16667 2.5H6.9C7.07483 2.50013 7.24519 2.55525 7.38696 2.65754C7.52874 2.75984 7.63475 2.90413 7.69 3.07L8.93833 6.81417C9.00158 7.00445 8.9941 7.21116 8.91726 7.39637C8.84042 7.58158 8.69938 7.73288 8.52 7.8225L6.63917 8.76417C7.5611 10.8046 9.19538 12.4389 11.2358 13.3608L12.1775 11.48C12.2671 11.3006 12.4184 11.1596 12.6036 11.0827C12.7888 11.0059 12.9956 10.9984 13.1858 11.0617L16.93 12.31C17.096 12.3653 17.2404 12.4714 17.3427 12.6134C17.445 12.7553 17.5 12.9259 17.5 13.1008V15.8333C17.5 16.2754 17.3244 16.6993 17.0118 17.0118C16.6993 17.3244 16.2754 17.5 15.8333 17.5H15C8.09667 17.5 2.5 11.9033 2.5 5V4.16667Z",strokeLinecap:"round",strokeLinejoin:"round"})});import{Fragment as Tn,jsx as te,jsxs as to}from"react/jsx-runtime";var xt=t=>{let[e,o]=eo(""),[r,i]=eo(!1),[n,s]=eo(null),{authenticated:c}=O(),{loginWithSms:m,handleLoginError:p}=P(),{navigate:S,options:v}=w(),x=v.wallet;Ln(()=>{let l=document.querySelector("#phone-number-input");l==null||l.focus()},[]);let L=br(e),A=()=>{i(!0),m(e).then(()=>{S("AWAITING_PASSWORDLESS_CODE")}).catch(l=>{let y=(l==null?void 0:l.status)===401&&(l==null?void 0:l.message)==="User is not allowed to login to this app.";(l==null?void 0:l.status)===422?s(l.message):s(y?"You don't have access to this app":"Issue submitting phone number"),i(!1),p(y)})};return to(Tn,{children:[to(An,{stacked:t.stacked,children:[to(_n,{standalone:t.stacked,children:[te(vt,{}),te("input",{id:"phone-number-input",type:"tel",placeholder:"555 555 5555",onChange:l=>{o(l.target.value)},onKeyUp:l=>{l.key==="Enter"&&A()},value:e,autoComplete:"tel"})]}),t.stacked?null:te(En,{disabled:r||!L,onClick:A,children:r?te(xr,{color:"var(--disabled-fg)"}):"Submit"})]}),n||c||!x?te(Sn,{fail:!!n,children:n||""}):null,!n&&!c&&x?te(Pn,{children:te("span",{children:"Don\u2019t have a wallet? Start exploring with your phone or socials."})}):null,t.stacked?te(kn,{disabled:r||!L,onClick:A,children:r?te(xr,{color:"var(--disabled-fg)"}):"Submit"}):null]})},An=be.div`
426
426
  display: flex;
427
427
  border: 1px solid #d1d5db;
428
428
  width: 100%;
@@ -547,7 +547,7 @@ Resources:
547
547
  width: 1rem;
548
548
  border-width: 2px;
549
549
  }
550
- `;import{jsx as Lr}from"react/jsx-runtime";var Ar=()=>{let{app:t}=w();return t!=null&&t.logoUrl?Lr("div",{children:Lr("img",{src:t.logoUrl,alt:`${t==null?void 0:t.name} logo`,style:{objectFit:"contain",width:"200px",height:"80px"}})}):null};import{isMobile as Er}from"react-device-detect";import{Fragment as Ce,jsx as C,jsxs as oe}from"react/jsx-runtime";var _r=()=>{let{ready:t}=O(),{getAuthMeta:e,isLinking:o}=P(),{app:r,navigate:i,options:n}=w(),s=n.email,c=n.sms,m=n.wallet,p=n.google,S=n.twitter,v=n.discord,k=n.github,x=m&&(r==null?void 0:r.showWalletLoginFirst)?0:1,[L,l]=Mn(x),y=e(),G=(y==null?void 0:y.authorizationCode)&&(y==null?void 0:y.stateCode)&&(y==null?void 0:y.provider);In(()=>{G?i("AWAITING_OAUTH_SCREEN"):o&&s?i("LINK_EMAIL_SCREEN"):o&&c?i("LINK_PHONE_SCREEN"):o&&m&&i("LINK_WALLET_SCREEN")},[t]);let W=L==0,ie=L==1,b=()=>C(Ce,{children:m&&C(Rn,{active:W,onClick:()=>l(0)})}),U=()=>C(Ce,{children:(s||c)&&C(Wn,{active:ie,onClick:()=>l(1),email:s,sms:c,google:p,twitter:S,discord:v,github:k})});return oe(Ce,{children:[C(E,{},"header"),C(Un,{walletOnly:!s&&!c&&!p&&!S&&!v,hasTerms:!!((r==null?void 0:r.privacyPolicyUrl)||(r==null?void 0:r.termsAndConditionsUrl)),children:C(Ar,{})}),C(ce,{children:r!=null&&r.showWalletLoginFirst?oe(Ce,{children:[C(b,{}),C(U,{})]}):oe(Ce,{children:[C(U,{}),C(b,{})]})}),r&&C(cr,{app:r}),C(q,{protectedByPrivy:!0})]})};function Rn(t){return oe(Sr,{active:t.active,onClick:t.onClick,children:[C(Pr,{active:t.active,children:C("h4",{children:"Connect Wallet"})}),t.active&&oe(Ce,{children:[C(ct,{}),C(ut,{})]})]})}function Wn(t){let e=t.google||t.discord||t.github||t.twitter&&!Er,o=t.email?"Email":"Phone";return oe(Sr,{active:t.active,onClick:t.onClick,children:[C(Pr,{active:t.active,children:oe("h4",{children:["Sign In with ",e?`${o} & Social`:o]})}),t.active&&t.email&&C(Ct,{}),t.active&&t.sms&&!t.email&&C(xt,{}),t.active&&e&&C(On,{google:t.google,twitter:t.twitter&&!Er,discord:t.discord,github:t.github})]})}function On(t){return oe(Ce,{children:[oe(Nn,{children:[C(kr,{}),C("p",{children:" Or "}),C(kr,{})]}),C(gr,{showGoogle:t.google,showDiscord:t.discord,showGithub:t.github,showTwitter:t.twitter})]})}var Pr=qe.div`
550
+ `;import{jsx as Lr}from"react/jsx-runtime";var Ar=()=>{let{app:t}=w();return t!=null&&t.logoUrl?Lr("div",{children:Lr("img",{src:t.logoUrl,alt:`${t==null?void 0:t.name} logo`,style:{objectFit:"contain",width:"200px",height:"80px"}})}):null};import{isMobile as Er}from"react-device-detect";import{Fragment as Ce,jsx as C,jsxs as oe}from"react/jsx-runtime";var _r=()=>{let{ready:t}=O(),{getAuthMeta:e,isLinking:o}=P(),{app:r,navigate:i,options:n}=w(),s=n.email,c=n.sms,m=n.wallet,p=n.google,S=n.twitter,v=n.discord,x=n.github,L=m&&(r==null?void 0:r.showWalletLoginFirst)?0:1,[A,l]=Mn(L),y=e(),G=(y==null?void 0:y.authorizationCode)&&(y==null?void 0:y.stateCode)&&(y==null?void 0:y.provider);In(()=>{G?i("AWAITING_OAUTH_SCREEN"):o&&s?i("LINK_EMAIL_SCREEN"):o&&c?i("LINK_PHONE_SCREEN"):o&&m&&i("LINK_WALLET_SCREEN")},[t]);let W=A==0,ie=A==1,b=()=>C(Ce,{children:m&&C(Rn,{active:W,onClick:()=>l(0)})}),U=()=>C(Ce,{children:(s||c)&&C(Wn,{active:ie,onClick:()=>l(1),email:s,sms:c,google:p,twitter:S,discord:v,github:x})});return oe(Ce,{children:[C(k,{},"header"),C(Un,{walletOnly:!s&&!c&&!p&&!S&&!v&&!x,hasTerms:!!((r==null?void 0:r.privacyPolicyUrl)||(r==null?void 0:r.termsAndConditionsUrl)),children:C(Ar,{})}),C(ce,{children:r!=null&&r.showWalletLoginFirst?oe(Ce,{children:[C(b,{}),C(U,{})]}):oe(Ce,{children:[C(U,{}),C(b,{})]})}),r&&C(cr,{app:r}),C(q,{protectedByPrivy:!0})]})};function Rn(t){return oe(Sr,{active:t.active,onClick:t.onClick,children:[C(Pr,{active:t.active,children:C("h4",{children:"Connect Wallet"})}),t.active&&oe(Ce,{children:[C(ct,{}),C(ut,{})]})]})}function Wn(t){let e=t.google||t.discord||t.github||t.twitter&&!Er,o=t.email?"Email":"Phone";return oe(Sr,{active:t.active,onClick:t.onClick,children:[C(Pr,{active:t.active,children:oe("h4",{children:["Sign In with ",e?`${o} & Social`:o]})}),t.active&&t.email&&C(Ct,{}),t.active&&t.sms&&!t.email&&C(xt,{}),t.active&&e&&C(On,{google:t.google,twitter:t.twitter&&!Er,discord:t.discord,github:t.github})]})}function On(t){return oe(Ce,{children:[oe(Nn,{children:[C(kr,{}),C("p",{children:" Or "}),C(kr,{})]}),C(gr,{showGoogle:t.google,showDiscord:t.discord,showGithub:t.github,showTwitter:t.twitter})]})}var Pr=qe.div`
551
551
  font-weight: ${t=>t.active?600:500};
552
552
  color: ${t=>t.active?"inherit":"#6b7280"};
553
553
  display: flex;
@@ -641,7 +641,7 @@ Resources:
641
641
  border-color: #e1e7ef;
642
642
  border-width: 1px;
643
643
  }
644
- `;import{Fragment as oo,jsx as B,jsxs as Oe}from"react/jsx-runtime";var ro=6,Wr=new Array(ro).fill(""),Gn=1400;var Or=()=>{var U,a,d;let{app:t}=w(),{closePrivyModal:e,resendEmailCode:o,resendSmsCode:r,getAuthMeta:i,loginWithCode:n}=P(),{authenticated:s,user:c}=O(),[m,p]=At(Wr),[S,v]=At(!1),[k,x]=At(null),[L,l]=At(null),y=(U=i())!=null&&U.email?0:1;Rr(()=>{if(s&&S){let _=setTimeout(e,Ee);return()=>clearTimeout(_)}},[s,S,c]),Rr(()=>{if(k&&L===0){let _=setTimeout(()=>{p(Wr),x(null);let T=document.querySelector("input[name=code-0]");T==null||T.focus()},Gn);return()=>clearTimeout(_)}},[k]);let G=_=>{var go;let T=_.currentTarget.value.replace(" ","");if(T==="")return;if(isNaN(Number(T))){x("Code should be numeric"),l(1);return}x(null),l(null);let Z=Number((go=_.currentTarget.name)==null?void 0:go.charAt(5)),Ut=[...T||[""]].slice(0,ro-Z),Dt=[...m.slice(0,Z),...Ut,...m.slice(Z+Ut.length)];p(Dt);let fi=Ut.length,fo=Math.min(Math.max(Z+fi,0),ro-1);if(!isNaN(Number(_.currentTarget.value))){let $=document.querySelector(`input[name=code-${fo}]`);$==null||$.focus()}if(Dt.every($=>$&&!isNaN(+$))){let $=document.querySelector(`input[name=code-${fo}]`);$==null||$.blur(),n(Dt.join("")).then(()=>v(!0)).catch(Ft=>{(Ft==null?void 0:Ft.status)===422?x("Invalid or expired verification code"):x("Issue verifying code"),l(0)})}_.preventDefault()},W=_=>{L===1&&(x(null),l(null));let T=[...m.slice(0,_),"",...m.slice(_+1)];if(p(T),_>0){let Z=document.querySelector(`input[name=code-${_-1}]`);Z==null||Z.focus()}},ie=`Verify your ${y==0?"email":"phone"}`,b=y==0?`Please check ${(a=i())==null?void 0:a.email} for an email from privy.io and enter your code below.`:`Please check ${(d=i())==null?void 0:d.phoneNumber} for a message from ${(t==null?void 0:t.name)||"privy.io"} and enter your code below.`;return Oe(oo,{children:[B(E,{},"header"),Oe(Vn,{children:[B(ve,{title:ie,description:b}),Oe(hr,{children:[Oe(Hn,{children:[B(Bn,{fail:!!k,success:S,children:B("span",{children:k||(S?"Success!":"")})}),B("div",{children:m.map((_,T)=>B("input",{name:`code-${T}`,type:"text",value:m[T],onChange:G,onKeyUp:Z=>{Z.key==="Backspace"&&W(T)},inputMode:"numeric",autoFocus:T===0,pattern:"[0-9]",className:`${S?"success":""} ${k?"fail":""}`,autoComplete:"one-time-code"},T))})]}),B(zn,{children:y==0?Oe(oo,{children:[B("span",{children:"Didn't get an email?"}),B("button",{onClick:o,children:"Resend Code"})]}):Oe(oo,{children:[B("span",{children:"Didn't get a message?"}),B("button",{onClick:r,children:"Resend Code"})]})})]})]}),B(q,{protectedByPrivy:!0})]})},Vn=Et.div`
644
+ `;import{Fragment as oo,jsx as B,jsxs as Oe}from"react/jsx-runtime";var ro=6,Wr=new Array(ro).fill(""),Gn=1400;var Or=()=>{var U,a,d;let{app:t}=w(),{closePrivyModal:e,resendEmailCode:o,resendSmsCode:r,getAuthMeta:i,loginWithCode:n}=P(),{authenticated:s,user:c}=O(),[m,p]=At(Wr),[S,v]=At(!1),[x,L]=At(null),[A,l]=At(null),y=(U=i())!=null&&U.email?0:1;Rr(()=>{if(s&&S){let _=setTimeout(e,Ee);return()=>clearTimeout(_)}},[s,S,c]),Rr(()=>{if(x&&A===0){let _=setTimeout(()=>{p(Wr),L(null);let T=document.querySelector("input[name=code-0]");T==null||T.focus()},Gn);return()=>clearTimeout(_)}},[x]);let G=_=>{var go;let T=_.currentTarget.value.replace(" ","");if(T==="")return;if(isNaN(Number(T))){L("Code should be numeric"),l(1);return}L(null),l(null);let Z=Number((go=_.currentTarget.name)==null?void 0:go.charAt(5)),Ut=[...T||[""]].slice(0,ro-Z),Dt=[...m.slice(0,Z),...Ut,...m.slice(Z+Ut.length)];p(Dt);let fi=Ut.length,fo=Math.min(Math.max(Z+fi,0),ro-1);if(!isNaN(Number(_.currentTarget.value))){let $=document.querySelector(`input[name=code-${fo}]`);$==null||$.focus()}if(Dt.every($=>$&&!isNaN(+$))){let $=document.querySelector(`input[name=code-${fo}]`);$==null||$.blur(),n(Dt.join("")).then(()=>v(!0)).catch(Ft=>{(Ft==null?void 0:Ft.status)===422?L("Invalid or expired verification code"):L("Issue verifying code"),l(0)})}_.preventDefault()},W=_=>{A===1&&(L(null),l(null));let T=[...m.slice(0,_),"",...m.slice(_+1)];if(p(T),_>0){let Z=document.querySelector(`input[name=code-${_-1}]`);Z==null||Z.focus()}},ie=`Verify your ${y==0?"email":"phone"}`,b=y==0?`Please check ${(a=i())==null?void 0:a.email} for an email from privy.io and enter your code below.`:`Please check ${(d=i())==null?void 0:d.phoneNumber} for a message from ${(t==null?void 0:t.name)||"privy.io"} and enter your code below.`;return Oe(oo,{children:[B(k,{},"header"),Oe(Vn,{children:[B(ve,{title:ie,description:b}),Oe(hr,{children:[Oe(Hn,{children:[B(Bn,{fail:!!x,success:S,children:B("span",{children:x||(S?"Success!":"")})}),B("div",{children:m.map((_,T)=>B("input",{name:`code-${T}`,type:"text",value:m[T],onChange:G,onKeyUp:Z=>{Z.key==="Backspace"&&W(T)},inputMode:"numeric",autoFocus:T===0,pattern:"[0-9]",className:`${S?"success":""} ${x?"fail":""}`,autoComplete:"one-time-code"},T))})]}),B(zn,{children:y==0?Oe(oo,{children:[B("span",{children:"Didn't get an email?"}),B("button",{onClick:o,children:"Resend Code"})]}):Oe(oo,{children:[B("span",{children:"Didn't get a message?"}),B("button",{onClick:r,children:"Resend Code"})]})})]})]}),B(q,{protectedByPrivy:!0})]})},Vn=Et.div`
645
645
  display: flex;
646
646
  flex-direction: column;
647
647
  align-items: flex-start;
@@ -813,7 +813,7 @@ Resources:
813
813
  border: 1px solid #e5e7eb;
814
814
  color: var(--text-dark-blue);
815
815
  }
816
- `;import{Fragment as lo,jsx as h,jsxs as R}from"react/jsx-runtime";var co=()=>{let{navigate:t}=w(),e="https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn?hl=en";return he.isFirefox&&(e="https://addons.mozilla.org/en-US/firefox/addon/ether-metamask/"),R(Kr,{children:[h(ve,{title:"Create a Metamask wallet",description:"Follow the instructions below to get started."}),h(qr,{children:h(ye,{style:{width:"152px",height:"152px"}})}),R(so,{children:[h(xe,{children:R("div",{children:[h("span",{children:"Install the "}),h("a",{href:e,target:"_blank",children:"MetaMask browser extension"})]})}),h(Je,{}),h(xe,{children:"Set up your first wallet"}),h(Je,{}),h(xe,{children:"Store your recovery phrase in a safe place!"})]}),h(Yr,{onClick:()=>t("LANDING"),children:"Done! I have my wallet"})]})},uo=()=>{let{navigate:t}=w();return R(Kr,{children:[h(ve,{title:"Create a Coinbase wallet",description:"Follow the instructions below to get started."}),h(qr,{style:{marginTop:"-24px"},children:h(Fr,{size:200})}),R(so,{children:[h(xe,{children:"Scan the QR code with your camera"}),h(Je,{}),h(xe,{children:"Set up your first wallet"}),h(Je,{}),h(xe,{children:"Store your seed phrase in a safe place!"})]}),h(Yr,{onClick:()=>t("LANDING"),children:"Done! I have my wallet"})]})},$r=()=>{let[t,e]=is("WHAT_IS_A_WALLET"),{navigateBack:o}=w();return R(lo,{children:[h(E,{backFn:t==="WHAT_IS_A_WALLET"?o:t==="PICK_A_NEW_WALLET"?()=>e("WHAT_IS_A_WALLET"):()=>e("PICK_A_NEW_WALLET")},"header"),R(ns,{children:[t==="WHAT_IS_A_WALLET"&&R(lo,{children:[h(cs,{children:h(Hr,{style:{width:"240px",height:"auto",borderRadius:"var(--border-radius-sm)",marginBottom:"32px"}})}),R(We,{title:"Get started with a new wallet",children:[h("p",{children:"Wallets help you store, send, and receive digital assets and collectibles. They are also a new\xA0way\xA0to\xA0log\xA0in."}),h("p",{children:"Instead of creating new accounts and passwords for every app, you just connect your wallet and bring your\xA0data\xA0with\xA0you."})]}),h(ls,{children:h(ds,{onClick:()=>{e("PICK_A_NEW_WALLET")},children:"Create a wallet"})})]}),t==="PICK_A_NEW_WALLET"&&h(lo,{children:R(ss,{children:[h(ve,{title:"Create a new wallet",description:"Select one the wallet providers below to get started on your web3 adventure."}),R(as,{children:[R(jr,{onClick:()=>{he.isIOS?window.location.href="https://apps.apple.com/us/app/metamask-blockchain-wallet/id1438144202":he.isAndroid?window.location.href="https://play.google.com/store/apps/details?id=io.metamask":e("CREATE_METAMASK_WALLET")},children:[h(ye,{}),R(Zr,{children:[h("h4",{children:"MetaMask"}),h("p",{children:"Get a browser-based wallet"})]}),h("div",{children:h("span",{children:"Set up"})})]}),R(jr,{onClick:()=>{he.isIOS?window.location.href="https://apps.apple.com/us/app/coinbase-wallet-nfts-crypto/id1278383455":he.isAndroid?window.location.href="https://play.google.com/store/apps/details?id=org.toshi":e("CREATE_COINBASE_WALLET")},children:[h(de,{}),R(Zr,{children:[h("h4",{children:"Coinbase Wallet"}),h("p",{children:"Get a mobile app wallet"})]}),h("div",{children:h("span",{children:"Set up"})})]})]})]})}),t==="CREATE_COINBASE_WALLET"&&h(uo,{}),t==="CREATE_METAMASK_WALLET"&&h(co,{})]}),R(X,{children:[h("span",{children:"Still not sure? "}),h("a",{target:"_blank",href:"https://join.tell.ie/blog/explaining-web3-wallets",children:"Learn more"}),"."]})]})},ns=j.div`
816
+ `;import{Fragment as lo,jsx as h,jsxs as R}from"react/jsx-runtime";var co=()=>{let{navigate:t}=w(),e="https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn?hl=en";return he.isFirefox&&(e="https://addons.mozilla.org/en-US/firefox/addon/ether-metamask/"),R(Kr,{children:[h(ve,{title:"Create a Metamask wallet",description:"Follow the instructions below to get started."}),h(qr,{children:h(ye,{style:{width:"152px",height:"152px"}})}),R(so,{children:[h(xe,{children:R("div",{children:[h("span",{children:"Install the "}),h("a",{href:e,target:"_blank",children:"MetaMask browser extension"})]})}),h(Je,{}),h(xe,{children:"Set up your first wallet"}),h(Je,{}),h(xe,{children:"Store your recovery phrase in a safe place!"})]}),h(Yr,{onClick:()=>t("LANDING"),children:"Done! I have my wallet"})]})},uo=()=>{let{navigate:t}=w();return R(Kr,{children:[h(ve,{title:"Create a Coinbase wallet",description:"Follow the instructions below to get started."}),h(qr,{style:{marginTop:"-24px"},children:h(Fr,{size:200})}),R(so,{children:[h(xe,{children:"Scan the QR code with your camera"}),h(Je,{}),h(xe,{children:"Set up your first wallet"}),h(Je,{}),h(xe,{children:"Store your seed phrase in a safe place!"})]}),h(Yr,{onClick:()=>t("LANDING"),children:"Done! I have my wallet"})]})},$r=()=>{let[t,e]=is("WHAT_IS_A_WALLET"),{navigateBack:o}=w();return R(lo,{children:[h(k,{backFn:t==="WHAT_IS_A_WALLET"?o:t==="PICK_A_NEW_WALLET"?()=>e("WHAT_IS_A_WALLET"):()=>e("PICK_A_NEW_WALLET")},"header"),R(ns,{children:[t==="WHAT_IS_A_WALLET"&&R(lo,{children:[h(cs,{children:h(Hr,{style:{width:"240px",height:"auto",borderRadius:"var(--border-radius-sm)",marginBottom:"32px"}})}),R(We,{title:"Get started with a new wallet",children:[h("p",{children:"Wallets help you store, send, and receive digital assets and collectibles. They are also a new\xA0way\xA0to\xA0log\xA0in."}),h("p",{children:"Instead of creating new accounts and passwords for every app, you just connect your wallet and bring your\xA0data\xA0with\xA0you."})]}),h(ls,{children:h(ds,{onClick:()=>{e("PICK_A_NEW_WALLET")},children:"Create a wallet"})})]}),t==="PICK_A_NEW_WALLET"&&h(lo,{children:R(ss,{children:[h(ve,{title:"Create a new wallet",description:"Select one the wallet providers below to get started on your web3 adventure."}),R(as,{children:[R(jr,{onClick:()=>{he.isIOS?window.location.href="https://apps.apple.com/us/app/metamask-blockchain-wallet/id1438144202":he.isAndroid?window.location.href="https://play.google.com/store/apps/details?id=io.metamask":e("CREATE_METAMASK_WALLET")},children:[h(ye,{}),R(Zr,{children:[h("h4",{children:"MetaMask"}),h("p",{children:"Get a browser-based wallet"})]}),h("div",{children:h("span",{children:"Set up"})})]}),R(jr,{onClick:()=>{he.isIOS?window.location.href="https://apps.apple.com/us/app/coinbase-wallet-nfts-crypto/id1278383455":he.isAndroid?window.location.href="https://play.google.com/store/apps/details?id=org.toshi":e("CREATE_COINBASE_WALLET")},children:[h(de,{}),R(Zr,{children:[h("h4",{children:"Coinbase Wallet"}),h("p",{children:"Get a mobile app wallet"})]}),h("div",{children:h("span",{children:"Set up"})})]})]})]})}),t==="CREATE_COINBASE_WALLET"&&h(uo,{}),t==="CREATE_METAMASK_WALLET"&&h(co,{})]}),R(X,{children:[h("span",{children:"Still not sure? "}),h("a",{target:"_blank",href:"https://join.tell.ie/blog/explaining-web3-wallets",children:"Learn more"}),"."]})]})},ns=j.div`
817
817
  display: flex;
818
818
  flex-direction: column;
819
819
  height: 100%;
@@ -938,7 +938,7 @@ Resources:
938
938
  `,cs=j.div`
939
939
  display: flex;
940
940
  justify-content: center;
941
- `;import{useEffect as Jr,useState as Pt}from"react";import Tt from"styled-components";import{Fragment as fs,jsx as Le,jsxs as St}from"react/jsx-runtime";var po=2,Qr={metamask:{name:"MetaMask",component:ye},coinbase_wallet:{name:"Coinbase Wallet",component:de},wallet_connect:{name:"WalletConnect",component:dt}},Xr=()=>{var ie;let[t,e]=Pt(!1),[o,r]=Pt(void 0),{navigateBack:i}=w(),{getAuthMeta:n,closePrivyModal:s,loginWithWallet:c,handleLoginError:m}=P(),[p,S]=Pt(0),{user:v}=O(),[k,x]=Pt((v==null?void 0:v.linkedAccounts.length)||0);Jr(()=>{r(void 0),c().then(()=>e(!0)).catch(b=>{b instanceof z?console.error(b.cause):console.error(b);let U=(b==null?void 0:b.status)===401&&(b==null?void 0:b.message)==="User is not allowed to login to this app.";(b==null?void 0:b.status)===422?r(Ge.ERROR_USER_EXISTS):U?r(Ge.ERROR_WALLET_NOT_ALLOWED):b instanceof Se&&!b.details.default?r(b.details):b instanceof Pe?r(Ge.ERROR_TIMED_OUT):r(Ge.ERROR_WALLET_CONNECTION),m(U)})},[p]),Jr(()=>{if(t){let b=setTimeout(s,Ee);return()=>clearTimeout(b)}},[v]);let L=((ie=n())==null?void 0:ie.wallet)||"metamask",l=Qr[L].name,y=Qr[L].component,G=t?`Successfully connected with ${l}`:o?o.message:`Waiting for ${l}`,W="";if(t){let b=(v==null?void 0:v.linkedAccounts.length)||0;k===b?W="Wallet was already linked.":W="You\u2019re good to go!"}else if(p>=po&&o)W="Unable to connect wallet";else if(o)W=o.detail;else switch(W="Don\u2019t see your wallet modal? Check your other browser windows.",L){case"wallet_connect":W="Open your mobile wallet app to continue";break;case"coinbase_wallet":lt()||(W="Open the Coinbase app on your phone to continue.");break;default:W="Don\u2019t see your wallet modal? Check your other browser windows."}return St(fs,{children:[Le(E,{backFn:i}),St(us,{children:[Le(hs,{children:St("div",{children:[Le(yt,{success:t,fail:!!o}),Le(y,{style:{width:"38px",height:"38px"}})]})}),St(ps,{children:[Le("h3",{children:G}),Le("p",{children:W})]}),Le(ms,{onClick:()=>{S(p+1),r(void 0)},visible:!t&&(o==null?void 0:o.retryable)&&p<po,disabled:!t&&(!(o!=null&&o.retryable)||p>=po),children:"Retry"})]})]})},us=Tt.div`
941
+ `;import{useEffect as Jr,useState as Pt}from"react";import Tt from"styled-components";import{Fragment as fs,jsx as Le,jsxs as St}from"react/jsx-runtime";var po=2,Qr={metamask:{name:"MetaMask",component:ye},coinbase_wallet:{name:"Coinbase Wallet",component:de},wallet_connect:{name:"WalletConnect",component:dt}},Xr=()=>{var ie;let[t,e]=Pt(!1),[o,r]=Pt(void 0),{navigateBack:i}=w(),{getAuthMeta:n,closePrivyModal:s,loginWithWallet:c,handleLoginError:m}=P(),[p,S]=Pt(0),{user:v}=O(),[x,L]=Pt((v==null?void 0:v.linkedAccounts.length)||0);Jr(()=>{r(void 0),c().then(()=>e(!0)).catch(b=>{b instanceof z?console.error(b.cause):console.error(b);let U=(b==null?void 0:b.status)===401&&(b==null?void 0:b.message)==="User is not allowed to login to this app.";(b==null?void 0:b.status)===422?r(Ge.ERROR_USER_EXISTS):U?r(Ge.ERROR_WALLET_NOT_ALLOWED):b instanceof Se&&!b.details.default?r(b.details):b instanceof Pe?r(Ge.ERROR_TIMED_OUT):r(Ge.ERROR_WALLET_CONNECTION),m(U)})},[p]),Jr(()=>{if(t){let b=setTimeout(s,Ee);return()=>clearTimeout(b)}},[v]);let A=((ie=n())==null?void 0:ie.wallet)||"metamask",l=Qr[A].name,y=Qr[A].component,G=t?`Successfully connected with ${l}`:o?o.message:`Waiting for ${l}`,W="";if(t){let b=(v==null?void 0:v.linkedAccounts.length)||0;x===b?W="Wallet was already linked.":W="You\u2019re good to go!"}else if(p>=po&&o)W="Unable to connect wallet";else if(o)W=o.detail;else switch(W="Don\u2019t see your wallet modal? Check your other browser windows.",A){case"wallet_connect":W="Open your mobile wallet app to continue";break;case"coinbase_wallet":lt()||(W="Open the Coinbase app on your phone to continue.");break;default:W="Don\u2019t see your wallet modal? Check your other browser windows."}return St(fs,{children:[Le(k,{backFn:i}),St(us,{children:[Le(hs,{children:St("div",{children:[Le(yt,{success:t,fail:!!o}),Le(y,{style:{width:"38px",height:"38px"}})]})}),St(ps,{children:[Le("h3",{children:G}),Le("p",{children:W})]}),Le(ms,{onClick:()=>{S(p+1),r(void 0)},visible:!t&&(o==null?void 0:o.retryable)&&p<po,disabled:!t&&(!(o!=null&&o.retryable)||p>=po),children:"Retry"})]})]})},us=Tt.div`
942
942
  display: flex;
943
943
  flex-direction: column;
944
944
  align-items: center;
@@ -985,7 +985,7 @@ Resources:
985
985
  opacity: ${t=>t.visible?"1":"0"};
986
986
  transition: opacity 200ms;
987
987
  }
988
- `;import{Fragment as gs,jsx as It,jsxs as ei}from"react/jsx-runtime";var ti=()=>{let{navigateBack:t}=w();return ei(gs,{children:[It(E,{backFn:t},"header"),It(co,{}),ei(X,{children:[It("span",{children:"Still not sure? "}),It("a",{target:"_blank",href:"https://join.tell.ie/blog/explaining-web3-wallets",children:"Learn more"})]})]})};import{Fragment as ws,jsx as Mt,jsxs as oi}from"react/jsx-runtime";var ri=()=>{let{navigateBack:t}=w();return oi(ws,{children:[Mt(E,{backFn:t},"header"),Mt(uo,{}),oi(X,{children:[Mt("span",{children:"Still not sure? "}),Mt("a",{target:"_blank",href:"https://join.tell.ie/blog/explaining-web3-wallets",children:"Learn more"})]})]})};import ys from"styled-components";import{jsx as Cs}from"react/jsx-runtime";var ii=t=>{let e=t.accentColor||"#696ffd";return Cs(bs,{accentColor:e,children:t.children})},bs=ys.div`
988
+ `;import{Fragment as gs,jsx as It,jsxs as ei}from"react/jsx-runtime";var ti=()=>{let{navigateBack:t}=w();return ei(gs,{children:[It(k,{backFn:t},"header"),It(co,{}),ei(X,{children:[It("span",{children:"Still not sure? "}),It("a",{target:"_blank",href:"https://join.tell.ie/blog/explaining-web3-wallets",children:"Learn more"})]})]})};import{Fragment as ws,jsx as Mt,jsxs as oi}from"react/jsx-runtime";var ri=()=>{let{navigateBack:t}=w();return oi(ws,{children:[Mt(k,{backFn:t},"header"),Mt(uo,{}),oi(X,{children:[Mt("span",{children:"Still not sure? "}),Mt("a",{target:"_blank",href:"https://join.tell.ie/blog/explaining-web3-wallets",children:"Learn more"})]})]})};import ys from"styled-components";import{jsx as Cs}from"react/jsx-runtime";var ii=t=>{let e=t.accentColor||"#696ffd";return Cs(bs,{accentColor:e,children:t.children})},bs=ys.div`
989
989
  /*! Modified from https://unpkg.com/tailwindcss@3.2.3/src/css/preflight.css */
990
990
 
991
991
  *,
@@ -1283,7 +1283,7 @@ Resources:
1283
1283
  display: none;
1284
1284
  }
1285
1285
  }
1286
- `;import{useEffect as Rs}from"react";import{useEffect as ni,useState as si}from"react";import Wt from"styled-components";import{Fragment as ks,jsx as Ae,jsxs as Rt}from"react/jsx-runtime";var ai={google:{name:"Google",component:gt},discord:{name:"Discord",component:ht},github:{name:"Github",component:mt},twitter:{name:"Twitter",component:pt}},vs=t=>t.charAt(0).toUpperCase()+t.slice(1),ho=()=>{let t=new URL(window.location.href);t.searchParams.delete("privy_oauth_code"),t.searchParams.delete("privy_oauth_provider"),t.searchParams.delete("privy_oauth_state"),window.history.pushState({},"",t)},li=()=>{var L;let[t,e]=si(!1),[o,r]=si(void 0),{getAuthMeta:i,initLoginWithOAuth:n,loginWithOAuth:s,closePrivyModal:c}=P(),{ready:m}=O(),p=((L=i())==null?void 0:L.provider)||"google",S=ai[p].name,v=ai[p].component;ni(()=>{!m||s().then(()=>{ho(),e(!0)}).catch(l=>{let y={retryable:!1,message:"Authentication failed."};l.message.includes("Another user has already linked this")?y.detail="This account has already been linked to another user.":l.message==="Invalid code during oauth flow."?(y.retryable=!0,y.detail="Something went wrong. Try again."):l.message==="User denied confirmation during OAuth flow"&&(y.detail=`Retry and check ${vs(p)} to finish connecting your account.`,y.retryable=!0),ho(),r(y)})},[m]),ni(()=>{if(!t)return;let l=setTimeout(c,Ee);return()=>clearTimeout(l)},[t]);let k=t?`Successfully connected with ${S}`:o?o.message:`Verifying connection to ${S}`,x="";return t?x="You\u2019re good to go!":o?x=o.detail:x="Just a few moments more",Rt(ks,{children:[Ae(E,{}),Rt(xs,{children:[Ae(As,{children:Rt("div",{children:[Ae(yt,{success:t,fail:!!o}),Ae(v,{style:{width:"38px",height:"38px"},logoFill:"primary"})]})}),Rt(Ls,{children:[Ae("h3",{children:k}),Ae("p",{children:x})]}),Ae(Es,{onClick:()=>{ho(),n(p),r(void 0)},visible:!t&&(o==null?void 0:o.retryable),disabled:!t&&!(o!=null&&o.retryable),children:"Retry"})]})]})},xs=Wt.div`
1286
+ `;import{useEffect as Rs}from"react";import{useEffect as ni,useState as si}from"react";import Wt from"styled-components";import{Fragment as ks,jsx as Ae,jsxs as Rt}from"react/jsx-runtime";var ai={google:{name:"Google",component:gt},discord:{name:"Discord",component:ht},github:{name:"Github",component:mt},twitter:{name:"Twitter",component:pt}},vs=t=>t.charAt(0).toUpperCase()+t.slice(1),ho=()=>{let t=new URL(window.location.href);t.searchParams.delete("privy_oauth_code"),t.searchParams.delete("privy_oauth_provider"),t.searchParams.delete("privy_oauth_state"),window.history.pushState({},"",t)},li=()=>{var A;let[t,e]=si(!1),[o,r]=si(void 0),{getAuthMeta:i,initLoginWithOAuth:n,loginWithOAuth:s,closePrivyModal:c}=P(),{ready:m}=O(),p=((A=i())==null?void 0:A.provider)||"google",S=ai[p].name,v=ai[p].component;ni(()=>{!m||s().then(()=>{ho(),e(!0)}).catch(l=>{let y={retryable:!1,message:"Authentication failed."};l.message.includes("Another user has already linked this")?y.detail="This account has already been linked to another user.":l.message==="Invalid code during oauth flow."?(y.retryable=!0,y.detail="Something went wrong. Try again."):l.message==="User denied confirmation during OAuth flow"&&(y.detail=`Retry and check ${vs(p)} to finish connecting your account.`,y.retryable=!0),ho(),r(y)})},[m]),ni(()=>{if(!t)return;let l=setTimeout(c,Ee);return()=>clearTimeout(l)},[t]);let x=t?`Successfully connected with ${S}`:o?o.message:`Verifying connection to ${S}`,L="";return t?L="You\u2019re good to go!":o?L=o.detail:L="Just a few moments more",Rt(ks,{children:[Ae(k,{}),Rt(xs,{children:[Ae(As,{children:Rt("div",{children:[Ae(yt,{success:t,fail:!!o}),Ae(v,{style:{width:"38px",height:"38px"},logoFill:"primary"})]})}),Rt(Ls,{children:[Ae("h3",{children:x}),Ae("p",{children:L})]}),Ae(Es,{onClick:()=>{ho(),n(p),r(void 0)},visible:!t&&(o==null?void 0:o.retryable),disabled:!t&&!(o!=null&&o.retryable),children:"Retry"})]})]})},xs=Wt.div`
1287
1287
  display: flex;
1288
1288
  flex-direction: column;
1289
1289
  align-items: center;
@@ -1330,7 +1330,7 @@ Resources:
1330
1330
  opacity: ${t=>t.visible?"1":"0"};
1331
1331
  transition: opacity 200ms;
1332
1332
  }
1333
- `;import{Fragment as _s,jsx as Ue,jsxs as Ps}from"react/jsx-runtime";var di=()=>{let{app:t}=w();return Ps(_s,{children:[Ue(E,{},"header"),Ue(We,{title:"Connect your email",description:`Add your email to your ${t==null?void 0:t.name} account`,icon:Ue(wt,{})}),Ue(ce,{children:Ue(Ct,{stacked:!0})}),Ue(q,{protectedByPrivy:!0})]})};import{Fragment as Ss,jsx as De,jsxs as Ts}from"react/jsx-runtime";var ci=()=>{let{app:t}=w();return Ts(Ss,{children:[De(E,{},"header"),De(We,{title:"Connect your phone",description:`Add your number to your ${t==null?void 0:t.name} account`,icon:De(vt,{})}),De(ce,{children:De(xt,{stacked:!0})}),De(q,{protectedByPrivy:!0})]})};import{Fragment as Is,jsx as Qe,jsxs as ui}from"react/jsx-runtime";var pi=()=>{let{app:t}=w();return ui(Is,{children:[Qe(E,{},"header"),Qe(Tr,{title:"Connect your wallet",description:`Link a wallet to your ${t==null?void 0:t.name} account`}),ui(ce,{children:[Qe(ct,{}),Qe(ut,{})]}),Qe(q,{protectedByPrivy:!0})]})};import{jsx as M,jsxs as hi}from"react/jsx-runtime";var Ws=()=>{let{ready:t}=O(),{isLinking:e}=P(),{ready:o,currentScreen:r}=w(),i;return["AWAITING_CONNECTION","AWAITING_OAUTH_SCREEN"].includes(r)?i="compact":"WALLET_EDUCATION"===r?i="full":e?i="medium":i="full",!t||!o?hi(kt,{"data-height":i,children:[M(E,{}),M(Us,{children:M(pe,{})}),M(X,{})]}):hi(kt,{"data-height":i,children:[r==="LANDING"&&M(_r,{}),r==="AWAITING_PASSWORDLESS_CODE"&&M(Or,{}),r==="WALLET_EDUCATION"&&M($r,{}),r==="AWAITING_CONNECTION"&&M(Xr,{}),r==="AWAITING_OAUTH_SCREEN"&&M(li,{}),r==="INSTALL_METAMASK_SCREEN"&&M(ti,{}),r==="INSTALL_COINBASE_WALLET_SCREEN"&&M(ri,{}),r==="LINK_EMAIL_SCREEN"&&M(di,{}),r==="LINK_PHONE_SCREEN"&&M(ci,{}),r==="LINK_WALLET_SCREEN"&&M(pi,{})]})},mi=()=>{let{app:t}=w();return Ms.createPortal(M(Ns,{id:"privy-dialog",children:M(ii,{accentColor:t==null?void 0:t.accentColor,children:M(Ws,{})})}),document.body)},Os=({children:t,...e})=>(Rs(()=>{var r;(r=document==null?void 0:document.activeElement)==null||r.blur();let o=(document==null?void 0:document.getElementById("root"))||(document==null?void 0:document.getElementById("__next"));if(!!o)return o.setAttribute("inert","true"),()=>{let i=(document==null?void 0:document.getElementById("root"))||(document==null?void 0:document.getElementById("__next"));!i||i.removeAttribute("inert")}},[e.open,e.onClose]),M("dialog",{open:!0,role:"dialog",...e,children:t})),Ns=mo(Os)`
1333
+ `;import{Fragment as _s,jsx as Ue,jsxs as Ps}from"react/jsx-runtime";var di=()=>{let{app:t}=w();return Ps(_s,{children:[Ue(k,{},"header"),Ue(We,{title:"Connect your email",description:`Add your email to your ${t==null?void 0:t.name} account`,icon:Ue(wt,{})}),Ue(ce,{children:Ue(Ct,{stacked:!0})}),Ue(q,{protectedByPrivy:!0})]})};import{Fragment as Ss,jsx as De,jsxs as Ts}from"react/jsx-runtime";var ci=()=>{let{app:t}=w();return Ts(Ss,{children:[De(k,{},"header"),De(We,{title:"Connect your phone",description:`Add your number to your ${t==null?void 0:t.name} account`,icon:De(vt,{})}),De(ce,{children:De(xt,{stacked:!0})}),De(q,{protectedByPrivy:!0})]})};import{Fragment as Is,jsx as Qe,jsxs as ui}from"react/jsx-runtime";var pi=()=>{let{app:t}=w();return ui(Is,{children:[Qe(k,{},"header"),Qe(Tr,{title:"Connect your wallet",description:`Link a wallet to your ${t==null?void 0:t.name} account`}),ui(ce,{children:[Qe(ct,{}),Qe(ut,{})]}),Qe(q,{protectedByPrivy:!0})]})};import{jsx as M,jsxs as hi}from"react/jsx-runtime";var Ws=()=>{let{ready:t}=O(),{isLinking:e}=P(),{ready:o,currentScreen:r}=w(),i;return["AWAITING_CONNECTION","AWAITING_OAUTH_SCREEN"].includes(r)?i="compact":"WALLET_EDUCATION"===r?i="full":e?i="medium":i="full",!t||!o?hi(kt,{"data-height":i,children:[M(k,{}),M(Us,{children:M(pe,{})}),M(X,{})]}):hi(kt,{"data-height":i,children:[r==="LANDING"&&M(_r,{}),r==="AWAITING_PASSWORDLESS_CODE"&&M(Or,{}),r==="WALLET_EDUCATION"&&M($r,{}),r==="AWAITING_CONNECTION"&&M(Xr,{}),r==="AWAITING_OAUTH_SCREEN"&&M(li,{}),r==="INSTALL_METAMASK_SCREEN"&&M(ti,{}),r==="INSTALL_COINBASE_WALLET_SCREEN"&&M(ri,{}),r==="LINK_EMAIL_SCREEN"&&M(di,{}),r==="LINK_PHONE_SCREEN"&&M(ci,{}),r==="LINK_WALLET_SCREEN"&&M(pi,{})]})},mi=()=>{let{app:t}=w();return Ms.createPortal(M(Ns,{id:"privy-dialog",children:M(ii,{accentColor:t==null?void 0:t.accentColor,children:M(Ws,{})})}),document.body)},Os=({children:t,...e})=>(Rs(()=>{var r;(r=document==null?void 0:document.activeElement)==null||r.blur();let o=(document==null?void 0:document.getElementById("root"))||(document==null?void 0:document.getElementById("__next"));if(!!o)return o.setAttribute("inert","true"),()=>{let i=(document==null?void 0:document.getElementById("root"))||(document==null?void 0:document.getElementById("__next"));!i||i.removeAttribute("inert")}},[e.open,e.onClose]),M("dialog",{open:!0,role:"dialog",...e,children:t})),Ns=mo(Os)`
1334
1334
  position: fixed;
1335
1335
  top: 0;
1336
1336
  left: 0;
@@ -1389,4 +1389,4 @@ Resources:
1389
1389
  align-items: center;
1390
1390
  justify-content: center;
1391
1391
  height: 100%;
1392
- `;import{Fragment as zs,jsx as Xe,jsxs as js}from"react/jsx-runtime";function Fs(t){return typeof t=="string"&&t.length===25}var Nt;function Gs(){if(!Nt){let t=A.get(ke);return Promise.resolve(t||null)}return Nt.getAccessToken()}var Vs=t=>{if(!Fs(t.appId))throw new u("Cannot initialize the Privy provider with an invalid Privy app ID");let[e,o]=re(null);return Ot(()=>{Nt=new He({appId:t.appId,apiURL:bo}),o(Nt)},[]),e===null?Xe(zs,{}):Xe(Bs,{...t,client:e})},Hs=(t,e)=>{if(e)return{email:!1,sms:!1,wallet:!1,google:!1,twitter:!1,discord:!1,github:!1,[e]:!0};let o=!!(t!=null&&t.emailAuth),r=!!(t!=null&&t.smsAuth);return o&&r&&(console.warn("Enabling both email and SMS passwordless is not currently supported. Disabling SMS."),r=!1),{email:o,sms:r,wallet:!!(t!=null&&t.walletAuth),google:!!(t!=null&&t.googleOAuth),twitter:!!(t!=null&&t.twitterOAuth),discord:!!(t!=null&&t.discordOAuth),github:!!(t!=null&&t.githubOAuth)}},Bs=t=>{let e=t.client,[o,r]=re(!1),[i,n]=re(!1),[s,c]=re(!1),[m,p]=re(null),[S,v]=re(!1),[k,x]=re({accentColor:"#696ffd",theme:"System",showWalletLoginFirst:!0,emailAuth:!0,smsAuth:!1,walletAuth:!0,googleOAuth:!1,twitterOAuth:!1,discordOAuth:!1,githubOAuth:!1,termsAndConditionsUrl:null,privacyPolicyUrl:null}),[L,l]=re(null),[y,G]=re(!1);Ot(()=>{async function a(){let d=await e.getAppSettings();x(d)}a()},[]);let W=Hs(k,L),ie=()=>{let a=new URLSearchParams(window.location.search),d=a.get("privy_oauth_code"),_=a.get("privy_oauth_state"),T=a.get("privy_oauth_provider");d&&_&&T&&(e.startAuthFlow(new Te(T,d,_)),l(T),r(!0))};Ot(()=>{async function a(){ie();let d=await e.getAuthenticatedUser();c(!!d),p(d),n(!0)}a()},[]),Ot(()=>{i&&s&&m===null&&e.getAuthenticatedUser().then(p)},[i,s,m]);let b={ready:i,authenticated:s,user:m,walletConnector:e.connector,linkWallet:()=>{l("wallet"),G(!0),r(!0)},linkEmail:()=>{l("email"),G(!0),r(!0)},linkPhone:()=>{l("sms"),G(!0),r(!0)},linkGoogle:async()=>{await U.initLoginWithOAuth("google")},linkTwitter:async()=>{await U.initLoginWithOAuth("twitter")},linkDiscord:async()=>{await U.initLoginWithOAuth("discord")},linkGithub:async()=>{await U.initLoginWithOAuth("github")},login:()=>{if(i&&s){console.warn("Attempted to log in, but user is already logged in. Use a `link` helper instead.");return}r(!0)},logout:async()=>{await e.logout(),p(null),c(!1),l(null),G(!1),r(!1)},getAccessToken:()=>e.getAccessToken(),getEthereumProvider:()=>e.connector.getEthereumProvider(),getEthersProvider:()=>new Ds(new ge(e.connector.getEthereumProvider())),getWeb3jsProvider:()=>new at(e.connector.getEthereumProvider()),unlinkWallet:async a=>{let d=await e.unlinkWallet(a);return p(d),d},unlinkEmail:async a=>{let d=await e.unlinkEmail(a);return p(d),d},unlinkPhone:async a=>{let d=await e.unlinkPhone(a);return p(d),d},unlinkGoogle:async a=>{let d=await e.unlinkOAuth("google",a);return p(d),d},unlinkTwitter:async a=>{let d=await e.unlinkOAuth("twitter",a);return p(d),d},unlinkDiscord:async a=>{let d=await e.unlinkOAuth("discord",a);return p(d),d},unlinkGithub:async a=>{let d=await e.unlinkOAuth("github",a);return p(d),d},setActiveWallet:a=>{if(!m)return;let d=e.setActiveWallet(a,m);p(d)},forkSession:()=>e.forkSession()},U={isLinking:y,getAuthFlow:()=>e.authFlow,getAuthMeta:()=>{var a;return(a=e.authFlow)==null?void 0:a.meta},closePrivyModal:()=>{var a;i&&s&&m&&((a=t.onSuccess)==null||a.call(t,m,S)),e.authFlow=void 0,l(null),G(!1),v(!1),r(!1)},initLoginWithWallet:a=>{a||(a="metamask"),e.connector.walletType=a,e.startAuthFlow(new Be(e.connector))},initLoginWithOAuth:async a=>{e.startAuthFlow(new Te(a));let d=await e.authFlow.getAuthorizationUrl();d&&d.url&&window.location.assign(d.url)},loginWithOAuth:async()=>{if(!(e.authFlow instanceof Te))throw new u("Must initialize OAuth flow before calling loginWithOAuth");let a,d;i&&s?a=await e.link():{user:a,isNewUser:d}=await e.authenticate(),p(a),v(d||!1),c(!0)},loginWithWallet:async()=>{if(!(e.authFlow instanceof Be))throw new u("Must initialize SIWE flow first.");let a,d;y?(a=await e.link(),a&&(A.del(K),a=Fe(a))):{user:a,isNewUser:d}=await e.authenticate(),p(a||m||null),v(d||!1),c(!0)},loginWithEmail:async a=>{let d=new ze(a);e.startAuthFlow(d),await d.sendCodeEmail()},loginWithSms:async a=>{let d=new je(a);e.startAuthFlow(d),await d.sendSmsCode()},resendEmailCode:async()=>{var a;await((a=e.authFlow)==null?void 0:a.sendCodeEmail())},resendSmsCode:async()=>{var a;await((a=e.authFlow)==null?void 0:a.sendSmsCode())},loginWithCode:async a=>{if(e.authFlow instanceof ze)e.authFlow.meta.emailCode=a.trim();else if(e.authFlow instanceof je)e.authFlow.meta.smsCode=a.trim();else throw new u("Must initialize a passwordless code flow first");let d,_;y?d=await e.link():{user:d,isNewUser:_}=await e.authenticate(),p(d||m||null),v(_||!1),c(!0)},handleLoginError:async a=>{var d;e.authFlow=void 0,l(null),G(!1),v(!1),(d=t.onError)==null||d.call(t,a)}};return js(Kt.Provider,{value:b,children:[t.children,Xe(qt.Provider,{value:U,children:Xe(Yo,{appSettings:k,options:W,visible:o,authenticated:s,children:o&&Xe(mi,{})})})]})};export{ge as AsExternalProvider,He as PrivyClient,Ve as PrivyConnector,Vs as PrivyProvider,fe as PrivyProxyProvider,Gt as VERSION,Gs as getAccessToken,O as usePrivy};
1392
+ `;import{Fragment as zs,jsx as Xe,jsxs as js}from"react/jsx-runtime";function Fs(t){return typeof t=="string"&&t.length===25}var Nt;function Gs(){if(!Nt){let t=E.get(ke);return Promise.resolve(t||null)}return Nt.getAccessToken()}var Vs=t=>{if(!Fs(t.appId))throw new u("Cannot initialize the Privy provider with an invalid Privy app ID");let[e,o]=re(null);return Ot(()=>{Nt=new He({appId:t.appId,apiURL:bo}),o(Nt)},[]),e===null?Xe(zs,{}):Xe(Bs,{...t,client:e})},Hs=(t,e)=>{if(e)return{email:!1,sms:!1,wallet:!1,google:!1,twitter:!1,discord:!1,github:!1,[e]:!0};let o=!!(t!=null&&t.emailAuth),r=!!(t!=null&&t.smsAuth);return o&&r&&(console.warn("Enabling both email and SMS passwordless is not currently supported. Disabling SMS."),r=!1),{email:o,sms:r,wallet:!!(t!=null&&t.walletAuth),google:!!(t!=null&&t.googleOAuth),twitter:!!(t!=null&&t.twitterOAuth),discord:!!(t!=null&&t.discordOAuth),github:!!(t!=null&&t.githubOAuth)}},Bs=t=>{let e=t.client,[o,r]=re(!1),[i,n]=re(!1),[s,c]=re(!1),[m,p]=re(null),[S,v]=re(!1),[x,L]=re({accentColor:"#696ffd",theme:"System",showWalletLoginFirst:!0,emailAuth:!0,smsAuth:!1,walletAuth:!0,googleOAuth:!1,twitterOAuth:!1,discordOAuth:!1,githubOAuth:!1,termsAndConditionsUrl:null,privacyPolicyUrl:null}),[A,l]=re(null),[y,G]=re(!1);Ot(()=>{async function a(){let d=await e.getAppSettings();L(d)}a()},[]);let W=Hs(x,A),ie=()=>{let a=new URLSearchParams(window.location.search),d=a.get("privy_oauth_code"),_=a.get("privy_oauth_state"),T=a.get("privy_oauth_provider");d&&_&&T&&(e.startAuthFlow(new Te(T,d,_)),l(T),r(!0))};Ot(()=>{async function a(){ie();let d=await e.getAuthenticatedUser();c(!!d),p(d),n(!0)}a()},[]),Ot(()=>{i&&s&&m===null&&e.getAuthenticatedUser().then(p)},[i,s,m]);let b={ready:i,authenticated:s,user:m,walletConnector:e.connector,linkWallet:()=>{l("wallet"),G(!0),r(!0)},linkEmail:()=>{l("email"),G(!0),r(!0)},linkPhone:()=>{l("sms"),G(!0),r(!0)},linkGoogle:async()=>{await U.initLoginWithOAuth("google")},linkTwitter:async()=>{await U.initLoginWithOAuth("twitter")},linkDiscord:async()=>{await U.initLoginWithOAuth("discord")},linkGithub:async()=>{await U.initLoginWithOAuth("github")},login:()=>{if(i&&s){console.warn("Attempted to log in, but user is already logged in. Use a `link` helper instead.");return}r(!0)},logout:async()=>{await e.logout(),p(null),c(!1),l(null),G(!1),r(!1)},getAccessToken:()=>e.getAccessToken(),getEthereumProvider:()=>e.connector.getEthereumProvider(),getEthersProvider:()=>new Ds(new ge(e.connector.getEthereumProvider())),getWeb3jsProvider:()=>new at(e.connector.getEthereumProvider()),unlinkWallet:async a=>{let d=await e.unlinkWallet(a);return p(d),d},unlinkEmail:async a=>{let d=await e.unlinkEmail(a);return p(d),d},unlinkPhone:async a=>{let d=await e.unlinkPhone(a);return p(d),d},unlinkGoogle:async a=>{let d=await e.unlinkOAuth("google",a);return p(d),d},unlinkTwitter:async a=>{let d=await e.unlinkOAuth("twitter",a);return p(d),d},unlinkDiscord:async a=>{let d=await e.unlinkOAuth("discord",a);return p(d),d},unlinkGithub:async a=>{let d=await e.unlinkOAuth("github",a);return p(d),d},setActiveWallet:a=>{if(!m)return;let d=e.setActiveWallet(a,m);p(d)},forkSession:()=>e.forkSession()},U={isLinking:y,getAuthFlow:()=>e.authFlow,getAuthMeta:()=>{var a;return(a=e.authFlow)==null?void 0:a.meta},closePrivyModal:()=>{var a;i&&s&&m&&((a=t.onSuccess)==null||a.call(t,m,S)),e.authFlow=void 0,l(null),G(!1),v(!1),r(!1)},initLoginWithWallet:a=>{a||(a="metamask"),e.connector.walletType=a,e.startAuthFlow(new Be(e.connector))},initLoginWithOAuth:async a=>{e.startAuthFlow(new Te(a));let d=await e.authFlow.getAuthorizationUrl();d&&d.url&&window.location.assign(d.url)},loginWithOAuth:async()=>{if(!(e.authFlow instanceof Te))throw new u("Must initialize OAuth flow before calling loginWithOAuth");let a,d;i&&s?a=await e.link():{user:a,isNewUser:d}=await e.authenticate(),p(a),v(d||!1),c(!0)},loginWithWallet:async()=>{if(!(e.authFlow instanceof Be))throw new u("Must initialize SIWE flow first.");let a,d;y?(a=await e.link(),a&&(E.del(K),a=Fe(a))):{user:a,isNewUser:d}=await e.authenticate(),p(a||m||null),v(d||!1),c(!0)},loginWithEmail:async a=>{let d=new ze(a);e.startAuthFlow(d),await d.sendCodeEmail()},loginWithSms:async a=>{let d=new je(a);e.startAuthFlow(d),await d.sendSmsCode()},resendEmailCode:async()=>{var a;await((a=e.authFlow)==null?void 0:a.sendCodeEmail())},resendSmsCode:async()=>{var a;await((a=e.authFlow)==null?void 0:a.sendSmsCode())},loginWithCode:async a=>{if(e.authFlow instanceof ze)e.authFlow.meta.emailCode=a.trim();else if(e.authFlow instanceof je)e.authFlow.meta.smsCode=a.trim();else throw new u("Must initialize a passwordless code flow first");let d,_;y?d=await e.link():{user:d,isNewUser:_}=await e.authenticate(),p(d||m||null),v(_||!1),c(!0)},handleLoginError:async a=>{var d;e.authFlow=void 0,l(null),G(!1),v(!1),(d=t.onError)==null||d.call(t,a)}};return js(Kt.Provider,{value:b,children:[t.children,Xe(qt.Provider,{value:U,children:Xe(Yo,{appSettings:x,options:W,visible:o,authenticated:s,children:o&&Xe(mi,{})})})]})};export{ge as AsExternalProvider,He as PrivyClient,Ve as PrivyConnector,Vs as PrivyProvider,fe as PrivyProxyProvider,Gt as VERSION,Gs as getAccessToken,O as usePrivy};
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var xi=Object.create;var ct=Object.defineProperty;var Li=Object.getOwnPropertyDescriptor;var Ai=Object.getOwnPropertyNames;var Ei=Object.getPrototypeOf,ki=Object.prototype.hasOwnProperty;var _i=(t,e)=>{for(var o in e)ct(t,o,{get:e[o],enumerable:!0})},Io=(t,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Ai(e))!ki.call(t,i)&&i!==o&&ct(t,i,{get:()=>e[i],enumerable:!(r=Li(e,i))||r.enumerable});return t};var C=(t,e,o)=>(o=t!=null?xi(Ei(t)):{},Io(e||!t||!t.__esModule?ct(o,"default",{value:t,enumerable:!0}):o,t)),Pi=t=>Io(ct({},"__esModule",{value:!0}),t);var Xn={};_i(Xn,{AsExternalProvider:()=>xe,PrivyClient:()=>ze,PrivyConnector:()=>Be,PrivyProvider:()=>Ci,PrivyProxyProvider:()=>ve,VERSION:()=>ht,getAccessToken:()=>bi,usePrivy:()=>N});module.exports=Pi(Xn);var z=require("react");var gt=C(require("axios"));var Mo=C(require("axios")),X=class extends Error{constructor(o,r){super(o);r instanceof Error&&(this.cause=r)}toString(){return`${this.type}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}},ut=class extends X{constructor(o,r,i,n){super(i,n);this.type=o;this.status=r}},p=class extends X{constructor(o,r){super(o,r);this.type="client_error"}};var K=class extends X{constructor(o,r){super(o,r);this.type="connector_error"}},O=t=>{if(t instanceof X)return t;if(!Mo.default.isAxiosError(t))return q(t);if(!t.response)return new ut("api_error",null,t.message,t);let{type:e,message:o,error:r}=t.response.data;return new ut(e||"ApiError",t.response.status,o||r,t)},q=t=>t instanceof X?t:t instanceof Error?new p(t.message,t):new p(`Internal error: ${t}`);var Ro="1.12.0-beta.7";var Wo="https://api.privy.io/v0",Oo=process.env.NEXT_PUBLIC_PRIVY_AUTH_URL||"https://auth.privy.io",pt="4df5e2316331463a9130964bd6078dfa",No=1e4,De=1400,Uo=365*24*60*60,ht=Ro,Do="ES256",Fo="privy.io",Fe="privy:token",mt="privy:refresh_token",se="privy:active_wallet",ft="privy:wallet_type",Go="walletconnect";var wt=class{constructor(e,o,r){this.appId=e,this.sdkVersion=ht,this.session=o,this.defaults=r}async get(e,o){try{return await gt.default.get(e,this.buildConfig({headers:{"Cache-Control":"no-cache"},...o}))}catch(r){throw O(r)}}async post(e,o,r){try{return await gt.default.post(e,o,this.buildConfig(r))}catch(i){throw O(i)}}async delete(e,o){try{return await gt.default.delete(e,this.buildConfig(o))}catch(r){throw O(r)}}buildConfig(e){return e=e||{},e.headers=e.headers||{},e.headers["privy-app-id"]=this.appId,e.headers["privy-client"]=`react-auth:${this.sdkVersion}`,this.session.token!==null&&(e.headers.authorization=`Bearer ${this.session.token}`),{...this.defaults,...e}}};var Ge=C(require("jose"));var we=class{static parse(e){try{return new we(e)}catch{return null}}constructor(e){this.value=e,this._decoded=Ge.decodeJwt(e)}get subject(){return this._decoded.sub}get expiration(){return this._decoded.exp}get issuer(){return this._decoded.iss}get audience(){return this._decoded.aud}isExpired(e=0){let o=Date.now(),r=(this.expiration-e)*1e3;return o>=r}async isValid(e,o,r=0){let i=await Ge.importSPKI(e,Do);try{return await Ge.jwtVerify(this.value,i,{issuer:Fo,audience:o,clockTolerance:r}),!0}catch{return!1}}};var ye=class{constructor(e){this.promise=null;this.fn=e}execute(e){return this.promise===null&&(this.promise=(async()=>{try{return await this.fn(e)}finally{this.promise=null}})()),this.promise}};var qt=class{constructor(){this._cache={}}get(e){return this._cache[e]}put(e,o){o!==void 0?this._cache[e]=o:this.del(e)}del(e){delete this._cache[e]}},Yt=class{get(e){let o=localStorage.getItem(e);return o===null?void 0:JSON.parse(o)}put(e,o){o!==void 0?localStorage.setItem(e,JSON.stringify(o)):this.del(e)}del(e){localStorage.removeItem(e)}};function Ti(){return typeof window<"u"&&window.localStorage?new Yt:new qt}var _=Ti();function be(t){return new Date(t*1e3)}function Ii(t){return t.map(e=>{switch(e.type){case"wallet":return{address:e.address,type:e.type,verifiedAt:be(e.verified_at),chainType:e.chain_type};case"email":return{address:e.address,type:e.type,verifiedAt:be(e.verified_at)};case"phone":return{number:e.phoneNumber,type:e.type,verifiedAt:be(e.verified_at)};case"google_oauth":return{subject:e.subject,email:e.email,name:e.name,type:e.type,verifiedAt:be(e.verified_at)};case"twitter_oauth":return{subject:e.subject,username:e.username,name:e.name,type:e.type,verifiedAt:be(e.verified_at)};case"discord_oauth":return{subject:e.subject,username:e.username,email:e.email,type:e.type,verifiedAt:be(e.verified_at)};case"github_oauth":return{subject:e.subject,username:e.username,name:e.name,email:e.email,type:e.type,verifiedAt:be(e.verified_at)};default:throw new p("Unrecognized account type")}})}function Mi(t,e){return e.find(o=>o.type==="wallet"&&o.address===t)}function Ce(t,e){return t.sort((o,r)=>r.verifiedAt.getTime()-o.verifiedAt.getTime()),t.find(o=>o.type===e)}function Qe(t){let e=t.linkedAccounts.map(s=>s.type==="wallet"?s.address:null),r=_.get(se);if(!r||!e.includes(r)){_.del(se);let s=Ce(t.linkedAccounts,"wallet");s&&(r=s.address,_.put(se,r))}let i=Mi(r,t.linkedAccounts),n=Object.assign({},t);return n.wallet=i&&{address:i.address,chainType:i.chainType,chainId:i.chainId,walletType:i.walletType},n}function pe(t){if(!t)return null;let e=Ii(t.linked_accounts),o=Ce(e,"wallet"),r=Ce(e,"email"),i=Ce(e,"phone"),n=Ce(e,"google_oauth"),s=Ce(e,"twitter_oauth"),u=Ce(e,"discord_oauth"),f=Ce(e,"github_oauth"),h={id:t.id,createdAt:be(t.created_at),linkedAccounts:e,email:r&&{address:r==null?void 0:r.address},phone:i&&{number:i==null?void 0:i.number},wallet:o&&{address:o.address,chainType:o.chainType,chainId:o.chainId,walletType:o.walletType},google:n&&{subject:n.subject,email:n.email,name:n.name},twitter:s&&{subject:s.subject,username:s.username,name:s.name},discord:u&&{subject:u.subject,username:u.username,email:u.email},github:f&&{subject:f.subject,username:f.username,name:f.name,email:f.email}};return Qe(h)}var Vo=()=>"/api/v1/sessions",Ho=()=>"/api/v1/sessions/logout",Bo=()=>"/api/v1/sessions/fork",zo=()=>"/api/v1/siwe/init",jo=()=>"/api/v1/siwe/authenticate",Zo=()=>"/api/v1/siwe/link",$o=()=>"/api/v1/passwordless/init",Ko=()=>"/api/v1/passwordless/authenticate",qo=()=>"/api/v1/passwordless/link",Yo=()=>"/api/v1/passwordless_sms/init",Jo=()=>"/api/v1/passwordless_sms/authenticate",Qo=()=>"/api/v1/passwordless_sms/link",Xo=()=>"/api/v1/oauth/init",er=()=>"/api/v1/oauth/authenticate",tr=()=>"/api/v1/oauth/link",or=()=>"/api/v1/siwe/unlink",rr=()=>"/api/v1/passwordless/unlink",ir=()=>"/api/v1/passwordless_sms/unlink",nr=()=>"/api/v1/oauth/unlink";var Ri=30,yt=class{constructor(){this.authenticateOnce=new ye(async e=>this._authenticate(e)),this.linkOnce=new ye(async e=>this._link(e)),this.refreshOnce=new ye(this._refresh.bind(this)),this.destroyOnce=new ye(this._destroy.bind(this)),this.forkSessionOnce=new ye(this._forkSession.bind(this))}get token(){try{let e=_.get(Fe);return typeof e=="string"?new we(e).value:null}catch(e){return console.error(e),this.destroyLocalState(),null}}get refreshToken(){try{let e=_.get(mt);return typeof e=="string"?e:null}catch(e){return console.error(e),this.destroyLocalState(),null}}hasRefreshCredentials(){return typeof this.token=="string"&&typeof this.refreshToken=="string"}hasActiveToken(){let e=we.parse(this.token);return e!==null&&!e.isExpired(Ri)}async hasValidToken(e,o,r=0){let i=we.parse(this.token);return i!==null&&await i.isValid(e,o,r)}authenticate(e){return this.authenticateOnce.execute(e)}link(e){return this.linkOnce.execute(e)}refresh(){return this.refreshOnce.execute()}forkSession(){return this.forkSessionOnce.execute()}destroy(){return this.destroyOnce.execute()}async _authenticate(e){try{let{token:o,refresh_token:r,user:i,is_new_user:n}=await e.authenticate();return this.storeToken(o),this.storeRefreshToken(r),{user:pe(i),isNewUser:n}}catch(o){throw console.warn("Error authenticating session"),q(o)}}async _link(e){try{let o=await e.link();return pe(o)}catch(o){throw console.warn("Error linking account"),q(o)}}async _refresh(){if(!this.api)throw new p("Session has no API instance");let e=this.token,o=this.refreshToken;if(!e||!o)return null;try{let r=await this.api.post(Vo(),{refresh_token:o});return this.storeToken(r.data.token),this.storeRefreshToken(r.data.refresh_token),pe(r.data.user)}catch(r){throw q(r)}}async _destroy(){var e;try{await((e=this.api)==null?void 0:e.post(Ho(),{refresh_token:this.refreshToken}))}catch{console.warn("Error destroying session")}this.destroyLocalState()}async _forkSession(){if(!this.api)throw new p("Session has no API instance");let e=this.refreshToken;try{let o=await this.api.post(Bo(),{refresh_token:e});return this.storeToken(o.data.token),this.storeRefreshToken(o.data.refresh_token),o.data.new_session_refresh_token}catch(o){throw q(o)}}destroyLocalState(){this.storeToken(null),this.storeRefreshToken(null),_.del(se)}storeToken(e){typeof e=="string"?_.put(Fe,e):_.del(Fe)}storeRefreshToken(e){typeof e=="string"?_.put(mt,e):_.del(mt)}};var lr=require("@ethersproject/address"),Xt=C(require("@walletconnect/web3-provider"));var sr=require("@ethersproject/logger");var Ve=class extends K{constructor(){super("Wallet timeout");this.type="wallet_error"}},bt=t=>{if(t instanceof K)return t;if((t==null?void 0:t.code)&&(t==null?void 0:t.reason)){let e=new He(t);return t.code===sr.ErrorCode.ACTION_REJECTED&&(e.details=Ie.E4001_USER_REJECTED_REQUEST),e}return t!=null&&t.code?new He(t):new K("Unknown connector error",t)},Jt=class extends X{constructor(o,r,i){super(o);this.type="provider_error";this.code=r,this.data=i}},He=class extends Jt{constructor(o){var n,s,u;let r=o;super(r.message,r.code,r.data);let i=Object.values(Ie).find(f=>f.eipCode===r.code);this.details=i||Ie.UNKNOWN_ERROR,r.code===-32002&&((n=r.message)!=null&&n.includes("already pending for origin")?(s=r.message)!=null&&s.includes("wallet_requestPermissions")?this.details=Ie.E32002_CONNECTION_ALREADY_PENDING:this.details=Ie.E32002_REQUEST_ALREADY_PENDING:(u=r.message)!=null&&u.includes("Already processing")&&r.message.includes("eth_requestAccounts")&&(this.details=Ie.E32002_WALLET_LOCKED))}},Wi={ERROR_USER_EXISTS:{message:"User already exists for this address",detail:"Try another address!",retryable:!1},ERROR_TIMED_OUT:{message:"Wallet request timed out",detail:"Please try connecting again.",retryable:!0},ERROR_WALLET_CONNECTION:{message:"Could not log in with wallet",detail:"Please try connecting again.",retryable:!0},ERROR_WALLET_NOT_ALLOWED:{message:"You don\u2019t have access to this app",detail:"Try with a different address?",retryable:!0}},Oi={E32002_CONNECTION_ALREADY_PENDING:{eipCode:-32002,message:"Connection request already pending",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E32002_REQUEST_ALREADY_PENDING:{eipCode:-32002,message:"Resource request already pending",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E32002_WALLET_LOCKED:{eipCode:-32002,message:"Wallet might be locked",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E4001_USER_REJECTED_REQUEST:{eipCode:4001,message:"Signature rejected",detail:"Please try signing again.",retryable:!0}},Ni={E4001_DEFAULT_USER_REJECTED_REQUEST:{eipCode:4001,message:"User Rejected Request",detail:"The user rejected the request.",default:!0,retryable:!0},E4100_DEFAULT_UNAUTHORIZED:{eipCode:4100,message:"Unauthorized",detail:"The requested method and/or account has not been authorized by the user.",default:!0,retryable:!1},E4200_DEFAULT_UNSUPPORTED_METHOD:{eipCode:4200,message:"Unsupported Method",detail:"The Provider does not support the requested method.",default:!0,retryable:!1},E4900_DEFAULT_DISCONNECTED:{eipCode:4900,message:"Disconnected",detail:"The Provider is disconnected from all chains.",default:!0,retryable:!0},E4901_DEFAULT_CHAIN_DISCONNECTED:{eipCode:4901,message:"Chain Disconnected",detail:"The Provider is not connected to the requested chain.",default:!0,retryable:!0},E32700_DEFAULT_PARSE_ERROR:{eipCode:-32700,message:"Parse error",detail:"Invalid JSON",default:!0,retryable:!1},E32600_DEFAULT_INVALID_REQUEST:{eipCode:-32600,message:"Invalid request",detail:"JSON is not a valid request object",default:!0,retryable:!1},E32601_DEFAULT_METHOD_NOT_FOUND:{eipCode:-32601,message:"Method not found",detail:"Method does not exist",default:!0,retryable:!1},E32602_DEFAULT_INVALID_PARAMS:{eipCode:-32602,message:"Invalid params",detail:"Invalid method parameters",default:!0,retryable:!1},E32603_DEFAULT_INTERNAL_ERROR:{eipCode:-32603,message:"Internal error",detail:"Internal JSON-RPC error",default:!0,retryable:!0},E32000_DEFAULT_INVALID_INPUT:{eipCode:-32e3,message:"Invalid input",detail:"Missing or invalid parameters",default:!0,retryable:!1},E32001_DEFAULT_RESOURCE_NOT_FOUND:{eipCode:-32001,message:"Resource not found",detail:"Requested resource not found",default:!0,retryable:!1},E32002_DEFAULT_RESOURCE_UNAVAILABLE:{eipCode:-32002,message:"Resource unavailable",detail:"Requested resource not available",default:!0,retryable:!0},E32003_DEFAULT_TRANSACTION_REJECTED:{eipCode:-32003,message:"Transaction rejected",detail:"Transaction creation failed",default:!0,retryable:!0},E32004_DEFAULT_METHOD_NOT_SUPPORTED:{eipCode:-32004,message:"Method not supported",detail:"Method is not implemented",default:!0,retryable:!1},E32005_DEFAULT_LIMIT_EXCEEDED:{eipCode:-32005,message:"Limit exceeded",detail:"Request exceeds defined limit",default:!0,retryable:!1},E32006_DEFAULT_JSON_RPC_VERSION_NOT_SUPPORTED:{eipCode:-32006,message:"JSON-RPC version not supported",detail:"Version of JSON-RPC protocol is not supported",default:!0,retryable:!1}},Ie={UNKNOWN_ERROR:{eipCode:0,message:"Unknown error",detail:"Unknown error",retryable:!0},...Ni,...Oi},Xe={...Wi,...Ie};var Ui=12e4,Qt=(t=new Ve,e=Ui)=>new Promise((o,r)=>setTimeout(()=>{r(t)},e)),ve=class{constructor(e){this.removeListener=(e,o)=>{if(this.walletProvider)return this.walletProvider.removeListener(e,o)};this.setProvider=e=>{this.walletProvider=e,this._subscriptions.forEach(o=>{var r;(r=this.walletProvider)==null||r.on(o.eventName,o.listener)})};this.walletProvider=e,this._subscriptions=[]}on(e,o){if(this.walletProvider)return this.walletProvider.on(e,o);this._subscriptions.push({eventName:e,listener:o})}request(e){if(!this.walletProvider)throw new K(`A wallet request of type ${e.method} was made before setting a wallet provider.`);return Promise.race([this.walletProvider.request(e),Qt()]).catch(o=>{throw bt(o)})}},xe=class extends ve{constructor(o){super(o)}},Ct=class extends ve{constructor(e){super(e)}sendAsync(e,o){throw new Error("sendAsync is no longer supported by EIP-1193. Use the request method instead.")}};var dr=require("@ethersproject/providers");var ar=["metamask","coinbase_wallet","wallet_connect"];var cr=C(require("@coinbase/wallet-sdk")),Di=()=>{let t=`https://mainnet.infura.io/v3/${pt}`,e=1;return new cr.default({appName:"Privy",darkMode:!1,headlessMode:!1}).makeWeb3Provider(t,e)},eo=()=>{if(!window.ethereum)return!1;if(window.ethereum.isMetaMask)return!0;if(window.ethereum.providers){for(let t of window.ethereum.providers)if(t.isMetaMask)return!0}return!1},vt=()=>{if(!window.ethereum)return!1;if(window.ethereum.isCoinbaseWallet)return!0;if(window.ethereum.providers){for(let t of window.ethereum.providers)if(t.isCoinbaseWallet)return!0}return!1},Be=class{constructor(){this.walletType=null;this.getEthereumProvider=()=>this.ethProvider;this.createSiweMessage=(e,o,r,i,n,s,u)=>`${r} wants you to sign in with your Ethereum account:
1
+ "use strict";var xi=Object.create;var ct=Object.defineProperty;var Li=Object.getOwnPropertyDescriptor;var Ai=Object.getOwnPropertyNames;var Ei=Object.getPrototypeOf,ki=Object.prototype.hasOwnProperty;var _i=(t,e)=>{for(var o in e)ct(t,o,{get:e[o],enumerable:!0})},Io=(t,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Ai(e))!ki.call(t,i)&&i!==o&&ct(t,i,{get:()=>e[i],enumerable:!(r=Li(e,i))||r.enumerable});return t};var C=(t,e,o)=>(o=t!=null?xi(Ei(t)):{},Io(e||!t||!t.__esModule?ct(o,"default",{value:t,enumerable:!0}):o,t)),Pi=t=>Io(ct({},"__esModule",{value:!0}),t);var Xn={};_i(Xn,{AsExternalProvider:()=>xe,PrivyClient:()=>ze,PrivyConnector:()=>Be,PrivyProvider:()=>Ci,PrivyProxyProvider:()=>ve,VERSION:()=>ht,getAccessToken:()=>bi,usePrivy:()=>N});module.exports=Pi(Xn);var z=require("react");var gt=C(require("axios"));var Mo=C(require("axios")),X=class extends Error{constructor(o,r){super(o);r instanceof Error&&(this.cause=r)}toString(){return`${this.type}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}},ut=class extends X{constructor(o,r,i,n){super(i,n);this.type=o;this.status=r}},p=class extends X{constructor(o,r){super(o,r);this.type="client_error"}};var K=class extends X{constructor(o,r){super(o,r);this.type="connector_error"}},O=t=>{if(t instanceof X)return t;if(!Mo.default.isAxiosError(t))return q(t);if(!t.response)return new ut("api_error",null,t.message,t);let{type:e,message:o,error:r}=t.response.data;return new ut(e||"ApiError",t.response.status,o||r,t)},q=t=>t instanceof X?t:t instanceof Error?new p(t.message,t):new p(`Internal error: ${t}`);var Ro="1.12.0";var Wo="https://api.privy.io/v0",Oo=process.env.NEXT_PUBLIC_PRIVY_AUTH_URL||"https://auth.privy.io",pt="4df5e2316331463a9130964bd6078dfa",No=1e4,De=1400,Uo=365*24*60*60,ht=Ro,Do="ES256",Fo="privy.io",Fe="privy:token",mt="privy:refresh_token",se="privy:active_wallet",ft="privy:wallet_type",Go="walletconnect";var wt=class{constructor(e,o,r){this.appId=e,this.sdkVersion=ht,this.session=o,this.defaults=r}async get(e,o){try{return await gt.default.get(e,this.buildConfig({headers:{"Cache-Control":"no-cache"},...o}))}catch(r){throw O(r)}}async post(e,o,r){try{return await gt.default.post(e,o,this.buildConfig(r))}catch(i){throw O(i)}}async delete(e,o){try{return await gt.default.delete(e,this.buildConfig(o))}catch(r){throw O(r)}}buildConfig(e){return e=e||{},e.headers=e.headers||{},e.headers["privy-app-id"]=this.appId,e.headers["privy-client"]=`react-auth:${this.sdkVersion}`,this.session.token!==null&&(e.headers.authorization=`Bearer ${this.session.token}`),{...this.defaults,...e}}};var Ge=C(require("jose"));var we=class{static parse(e){try{return new we(e)}catch{return null}}constructor(e){this.value=e,this._decoded=Ge.decodeJwt(e)}get subject(){return this._decoded.sub}get expiration(){return this._decoded.exp}get issuer(){return this._decoded.iss}get audience(){return this._decoded.aud}isExpired(e=0){let o=Date.now(),r=(this.expiration-e)*1e3;return o>=r}async isValid(e,o,r=0){let i=await Ge.importSPKI(e,Do);try{return await Ge.jwtVerify(this.value,i,{issuer:Fo,audience:o,clockTolerance:r}),!0}catch{return!1}}};var ye=class{constructor(e){this.promise=null;this.fn=e}execute(e){return this.promise===null&&(this.promise=(async()=>{try{return await this.fn(e)}finally{this.promise=null}})()),this.promise}};var qt=class{constructor(){this._cache={}}get(e){return this._cache[e]}put(e,o){o!==void 0?this._cache[e]=o:this.del(e)}del(e){delete this._cache[e]}},Yt=class{get(e){let o=localStorage.getItem(e);return o===null?void 0:JSON.parse(o)}put(e,o){o!==void 0?localStorage.setItem(e,JSON.stringify(o)):this.del(e)}del(e){localStorage.removeItem(e)}};function Ti(){return typeof window<"u"&&window.localStorage?new Yt:new qt}var P=Ti();function be(t){return new Date(t*1e3)}function Ii(t){return t.map(e=>{switch(e.type){case"wallet":return{address:e.address,type:e.type,verifiedAt:be(e.verified_at),chainType:e.chain_type};case"email":return{address:e.address,type:e.type,verifiedAt:be(e.verified_at)};case"phone":return{number:e.phoneNumber,type:e.type,verifiedAt:be(e.verified_at)};case"google_oauth":return{subject:e.subject,email:e.email,name:e.name,type:e.type,verifiedAt:be(e.verified_at)};case"twitter_oauth":return{subject:e.subject,username:e.username,name:e.name,type:e.type,verifiedAt:be(e.verified_at)};case"discord_oauth":return{subject:e.subject,username:e.username,email:e.email,type:e.type,verifiedAt:be(e.verified_at)};case"github_oauth":return{subject:e.subject,username:e.username,name:e.name,email:e.email,type:e.type,verifiedAt:be(e.verified_at)};default:throw new p("Unrecognized account type")}})}function Mi(t,e){return e.find(o=>o.type==="wallet"&&o.address===t)}function Ce(t,e){return t.sort((o,r)=>r.verifiedAt.getTime()-o.verifiedAt.getTime()),t.find(o=>o.type===e)}function Qe(t){let e=t.linkedAccounts.map(s=>s.type==="wallet"?s.address:null),r=P.get(se);if(!r||!e.includes(r)){P.del(se);let s=Ce(t.linkedAccounts,"wallet");s&&(r=s.address,P.put(se,r))}let i=Mi(r,t.linkedAccounts),n=Object.assign({},t);return n.wallet=i&&{address:i.address,chainType:i.chainType,chainId:i.chainId,walletType:i.walletType},n}function pe(t){if(!t)return null;let e=Ii(t.linked_accounts),o=Ce(e,"wallet"),r=Ce(e,"email"),i=Ce(e,"phone"),n=Ce(e,"google_oauth"),s=Ce(e,"twitter_oauth"),u=Ce(e,"discord_oauth"),f=Ce(e,"github_oauth"),h={id:t.id,createdAt:be(t.created_at),linkedAccounts:e,email:r&&{address:r==null?void 0:r.address},phone:i&&{number:i==null?void 0:i.number},wallet:o&&{address:o.address,chainType:o.chainType,chainId:o.chainId,walletType:o.walletType},google:n&&{subject:n.subject,email:n.email,name:n.name},twitter:s&&{subject:s.subject,username:s.username,name:s.name},discord:u&&{subject:u.subject,username:u.username,email:u.email},github:f&&{subject:f.subject,username:f.username,name:f.name,email:f.email}};return Qe(h)}var Vo=()=>"/api/v1/sessions",Ho=()=>"/api/v1/sessions/logout",Bo=()=>"/api/v1/sessions/fork",zo=()=>"/api/v1/siwe/init",jo=()=>"/api/v1/siwe/authenticate",Zo=()=>"/api/v1/siwe/link",$o=()=>"/api/v1/passwordless/init",Ko=()=>"/api/v1/passwordless/authenticate",qo=()=>"/api/v1/passwordless/link",Yo=()=>"/api/v1/passwordless_sms/init",Jo=()=>"/api/v1/passwordless_sms/authenticate",Qo=()=>"/api/v1/passwordless_sms/link",Xo=()=>"/api/v1/oauth/init",er=()=>"/api/v1/oauth/authenticate",tr=()=>"/api/v1/oauth/link",or=()=>"/api/v1/siwe/unlink",rr=()=>"/api/v1/passwordless/unlink",ir=()=>"/api/v1/passwordless_sms/unlink",nr=()=>"/api/v1/oauth/unlink";var Ri=30,yt=class{constructor(){this.authenticateOnce=new ye(async e=>this._authenticate(e)),this.linkOnce=new ye(async e=>this._link(e)),this.refreshOnce=new ye(this._refresh.bind(this)),this.destroyOnce=new ye(this._destroy.bind(this)),this.forkSessionOnce=new ye(this._forkSession.bind(this))}get token(){try{let e=P.get(Fe);return typeof e=="string"?new we(e).value:null}catch(e){return console.error(e),this.destroyLocalState(),null}}get refreshToken(){try{let e=P.get(mt);return typeof e=="string"?e:null}catch(e){return console.error(e),this.destroyLocalState(),null}}hasRefreshCredentials(){return typeof this.token=="string"&&typeof this.refreshToken=="string"}hasActiveToken(){let e=we.parse(this.token);return e!==null&&!e.isExpired(Ri)}async hasValidToken(e,o,r=0){let i=we.parse(this.token);return i!==null&&await i.isValid(e,o,r)}authenticate(e){return this.authenticateOnce.execute(e)}link(e){return this.linkOnce.execute(e)}refresh(){return this.refreshOnce.execute()}forkSession(){return this.forkSessionOnce.execute()}destroy(){return this.destroyOnce.execute()}async _authenticate(e){try{let{token:o,refresh_token:r,user:i,is_new_user:n}=await e.authenticate();return this.storeToken(o),this.storeRefreshToken(r),{user:pe(i),isNewUser:n}}catch(o){throw console.warn("Error authenticating session"),q(o)}}async _link(e){try{let o=await e.link();return pe(o)}catch(o){throw console.warn("Error linking account"),q(o)}}async _refresh(){if(!this.api)throw new p("Session has no API instance");let e=this.token,o=this.refreshToken;if(!e||!o)return null;try{let r=await this.api.post(Vo(),{refresh_token:o});return this.storeToken(r.data.token),this.storeRefreshToken(r.data.refresh_token),pe(r.data.user)}catch(r){throw q(r)}}async _destroy(){var e;try{await((e=this.api)==null?void 0:e.post(Ho(),{refresh_token:this.refreshToken}))}catch{console.warn("Error destroying session")}this.destroyLocalState()}async _forkSession(){if(!this.api)throw new p("Session has no API instance");let e=this.refreshToken;try{let o=await this.api.post(Bo(),{refresh_token:e});return this.storeToken(o.data.token),this.storeRefreshToken(o.data.refresh_token),o.data.new_session_refresh_token}catch(o){throw q(o)}}destroyLocalState(){this.storeToken(null),this.storeRefreshToken(null),P.del(se)}storeToken(e){typeof e=="string"?P.put(Fe,e):P.del(Fe)}storeRefreshToken(e){typeof e=="string"?P.put(mt,e):P.del(mt)}};var lr=require("@ethersproject/address"),Xt=C(require("@walletconnect/web3-provider"));var sr=require("@ethersproject/logger");var Ve=class extends K{constructor(){super("Wallet timeout");this.type="wallet_error"}},bt=t=>{if(t instanceof K)return t;if((t==null?void 0:t.code)&&(t==null?void 0:t.reason)){let e=new He(t);return t.code===sr.ErrorCode.ACTION_REJECTED&&(e.details=Ie.E4001_USER_REJECTED_REQUEST),e}return t!=null&&t.code?new He(t):new K("Unknown connector error",t)},Jt=class extends X{constructor(o,r,i){super(o);this.type="provider_error";this.code=r,this.data=i}},He=class extends Jt{constructor(o){var n,s,u;let r=o;super(r.message,r.code,r.data);let i=Object.values(Ie).find(f=>f.eipCode===r.code);this.details=i||Ie.UNKNOWN_ERROR,r.code===-32002&&((n=r.message)!=null&&n.includes("already pending for origin")?(s=r.message)!=null&&s.includes("wallet_requestPermissions")?this.details=Ie.E32002_CONNECTION_ALREADY_PENDING:this.details=Ie.E32002_REQUEST_ALREADY_PENDING:(u=r.message)!=null&&u.includes("Already processing")&&r.message.includes("eth_requestAccounts")&&(this.details=Ie.E32002_WALLET_LOCKED))}},Wi={ERROR_USER_EXISTS:{message:"User already exists for this address",detail:"Try another address!",retryable:!1},ERROR_TIMED_OUT:{message:"Wallet request timed out",detail:"Please try connecting again.",retryable:!0},ERROR_WALLET_CONNECTION:{message:"Could not log in with wallet",detail:"Please try connecting again.",retryable:!0},ERROR_WALLET_NOT_ALLOWED:{message:"You don\u2019t have access to this app",detail:"Try with a different address?",retryable:!0}},Oi={E32002_CONNECTION_ALREADY_PENDING:{eipCode:-32002,message:"Connection request already pending",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E32002_REQUEST_ALREADY_PENDING:{eipCode:-32002,message:"Resource request already pending",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E32002_WALLET_LOCKED:{eipCode:-32002,message:"Wallet might be locked",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E4001_USER_REJECTED_REQUEST:{eipCode:4001,message:"Signature rejected",detail:"Please try signing again.",retryable:!0}},Ni={E4001_DEFAULT_USER_REJECTED_REQUEST:{eipCode:4001,message:"User Rejected Request",detail:"The user rejected the request.",default:!0,retryable:!0},E4100_DEFAULT_UNAUTHORIZED:{eipCode:4100,message:"Unauthorized",detail:"The requested method and/or account has not been authorized by the user.",default:!0,retryable:!1},E4200_DEFAULT_UNSUPPORTED_METHOD:{eipCode:4200,message:"Unsupported Method",detail:"The Provider does not support the requested method.",default:!0,retryable:!1},E4900_DEFAULT_DISCONNECTED:{eipCode:4900,message:"Disconnected",detail:"The Provider is disconnected from all chains.",default:!0,retryable:!0},E4901_DEFAULT_CHAIN_DISCONNECTED:{eipCode:4901,message:"Chain Disconnected",detail:"The Provider is not connected to the requested chain.",default:!0,retryable:!0},E32700_DEFAULT_PARSE_ERROR:{eipCode:-32700,message:"Parse error",detail:"Invalid JSON",default:!0,retryable:!1},E32600_DEFAULT_INVALID_REQUEST:{eipCode:-32600,message:"Invalid request",detail:"JSON is not a valid request object",default:!0,retryable:!1},E32601_DEFAULT_METHOD_NOT_FOUND:{eipCode:-32601,message:"Method not found",detail:"Method does not exist",default:!0,retryable:!1},E32602_DEFAULT_INVALID_PARAMS:{eipCode:-32602,message:"Invalid params",detail:"Invalid method parameters",default:!0,retryable:!1},E32603_DEFAULT_INTERNAL_ERROR:{eipCode:-32603,message:"Internal error",detail:"Internal JSON-RPC error",default:!0,retryable:!0},E32000_DEFAULT_INVALID_INPUT:{eipCode:-32e3,message:"Invalid input",detail:"Missing or invalid parameters",default:!0,retryable:!1},E32001_DEFAULT_RESOURCE_NOT_FOUND:{eipCode:-32001,message:"Resource not found",detail:"Requested resource not found",default:!0,retryable:!1},E32002_DEFAULT_RESOURCE_UNAVAILABLE:{eipCode:-32002,message:"Resource unavailable",detail:"Requested resource not available",default:!0,retryable:!0},E32003_DEFAULT_TRANSACTION_REJECTED:{eipCode:-32003,message:"Transaction rejected",detail:"Transaction creation failed",default:!0,retryable:!0},E32004_DEFAULT_METHOD_NOT_SUPPORTED:{eipCode:-32004,message:"Method not supported",detail:"Method is not implemented",default:!0,retryable:!1},E32005_DEFAULT_LIMIT_EXCEEDED:{eipCode:-32005,message:"Limit exceeded",detail:"Request exceeds defined limit",default:!0,retryable:!1},E32006_DEFAULT_JSON_RPC_VERSION_NOT_SUPPORTED:{eipCode:-32006,message:"JSON-RPC version not supported",detail:"Version of JSON-RPC protocol is not supported",default:!0,retryable:!1}},Ie={UNKNOWN_ERROR:{eipCode:0,message:"Unknown error",detail:"Unknown error",retryable:!0},...Ni,...Oi},Xe={...Wi,...Ie};var Ui=12e4,Qt=(t=new Ve,e=Ui)=>new Promise((o,r)=>setTimeout(()=>{r(t)},e)),ve=class{constructor(e){this.removeListener=(e,o)=>{if(this.walletProvider)return this.walletProvider.removeListener(e,o)};this.setProvider=e=>{this.walletProvider=e,this._subscriptions.forEach(o=>{var r;(r=this.walletProvider)==null||r.on(o.eventName,o.listener)})};this.walletProvider=e,this._subscriptions=[]}on(e,o){if(this.walletProvider)return this.walletProvider.on(e,o);this._subscriptions.push({eventName:e,listener:o})}request(e){if(!this.walletProvider)throw new K(`A wallet request of type ${e.method} was made before setting a wallet provider.`);return Promise.race([this.walletProvider.request(e),Qt()]).catch(o=>{throw bt(o)})}},xe=class extends ve{constructor(o){super(o)}},Ct=class extends ve{constructor(e){super(e)}sendAsync(e,o){throw new Error("sendAsync is no longer supported by EIP-1193. Use the request method instead.")}};var dr=require("@ethersproject/providers");var ar=["metamask","coinbase_wallet","wallet_connect"];var cr=C(require("@coinbase/wallet-sdk")),Di=()=>{let t=`https://mainnet.infura.io/v3/${pt}`,e=1;return new cr.default({appName:"Privy",darkMode:!1,headlessMode:!1}).makeWeb3Provider(t,e)},eo=()=>{if(!window.ethereum)return!1;if(window.ethereum.isMetaMask)return!0;if(window.ethereum.providers){for(let t of window.ethereum.providers)if(t.isMetaMask)return!0}return!1},vt=()=>{if(!window.ethereum)return!1;if(window.ethereum.isCoinbaseWallet)return!0;if(window.ethereum.providers){for(let t of window.ethereum.providers)if(t.isCoinbaseWallet)return!0}return!1},Be=class{constructor(){this.walletType=null;this.getEthereumProvider=()=>this.ethProvider;this.createSiweMessage=(e,o,r,i,n,s,u)=>`${r} wants you to sign in with your Ethereum account:
2
2
  ${o}
3
3
 
4
4
  ${u}
@@ -9,7 +9,7 @@ Chain ID: ${e}
9
9
  Nonce: ${s}
10
10
  Issued At: ${n}
11
11
  Resources:
12
- - https://privy.io`;this.ethProvider=new ve}initialize(){let e=_.get(ft);ar.includes(e)&&(this.walletType=e,this.connect({showPrompt:!1}))}destroy(){this.walletType=null,_.del(ft),_.del(Go)}async getConnectedWallet(){let e=this.walletType;if(!e||!await this.isConnected())return null;let o=await this.address(),r=await this.chainId();return{address:o,chainId:r,chainType:"ethereum",walletType:e}}async connect(e){var o;switch(this.walletType){case"metamask":this.ethProvider.setProvider(window.ethereum),(o=window.ethereum.providers)==null||o.forEach(async i=>{i.isMetaMask&&this.ethProvider.setProvider(i)});break;case"coinbase_wallet":this.ethProvider.setProvider(Di());break;case"wallet_connect":let r=new Xt.default({infuraId:pt});this.ethProvider.setProvider(r);break;default:throw new K(`Unsupported wallet: ${this.walletType}`)}return(!await this.isConnected()||e.showPrompt)&&await this.promptConnection(this.walletType),this.getConnectedWallet()}async isConnected(){switch(this.walletType){case"metamask":return await this.address()!==null;case"coinbase_wallet":return await this.address()!==null;case"wallet_connect":return this.ethProvider.walletProvider.connected;default:throw new K(`Unsupported wallet: ${this.walletType}`)}}async promptConnection(e){try{switch(e){case"metamask":await this.ethProvider.request({method:"wallet_requestPermissions",params:[{eth_accounts:{}}]}),await this.ethProvider.request({method:"eth_requestAccounts"});break;case"coinbase_wallet":await this.ethProvider.request({method:"eth_requestAccounts"});break;case"wallet_connect":let o=new Xt.default({infuraId:pt});this.ethProvider.setProvider(o),await Promise.race([o.enable(),Qt()]);break;default:throw new K(`Unsupported wallet: ${this.walletType}`)}_.put(ft,e)}catch(o){throw bt(o)}}async sign(e){return new dr.Web3Provider(new xe(this.getEthereumProvider())).getSigner().signMessage(e)}prepareMessage(e,o,r){let i=window.location.host,n=window.location.origin,s="By signing, you are proving you own this wallet and logging in. This does not initiate a transaction or cost any fees.",u=new Date().toISOString();return this.createSiweMessage(e,o,i,n,u,r,s)}async chainId(){let e=await this.getEthereumProvider().request({method:"eth_chainId"}),o=Number(e);return String(o)}async address(){let e=await this.getEthereumProvider().request({method:"eth_accounts"});return Array.isArray(e)&&e.length>0?(0,lr.getAddress)(e[0]):null}};var to,ze=class{constructor(e){let o=e.apiURL||Wo,r=e.timeout||No;this.appId=e.appId,this.connector=new Be,this.connector.initialize(),to||(to=new yt),this.session=to,this.api=new wt(e.appId,this.session,{baseURL:o,timeout:r}),this.session.api=this.api}authenticate(){if(!this.authFlow)throw new p("No auth flow in progress.");return this.session.authenticate(this.authFlow)}link(){if(!this.authFlow)throw new p("No auth flow in progress.");return this.session.link(this.authFlow)}async logout(){await this.session.destroy(),this.connector.destroy(),this.authFlow=void 0}startAuthFlow(e){e.api=this.api,this.authFlow=e}async unlinkEmail(e){try{let o=await this.api.post(rr(),{address:e});return pe(o.data)}catch(o){throw q(o)}}async unlinkPhone(e){try{let o=await this.api.post(ir(),{phoneNumber:e});return pe(o.data)}catch(o){throw q(o)}}async unlinkWallet(e){try{let o=await this.api.post(or(),{address:e});return pe(o.data)}catch(o){throw q(o)}}async unlinkOAuth(e,o){try{let r=await this.api.post(nr(),{provider:e,subject:o});return pe(r.data)}catch(r){throw q(r)}}async getAuthenticatedUser(){return this.session.hasRefreshCredentials()?this.session.refresh():null}async getAccessToken(){if(this.session.hasActiveToken()){let{verificationKey:e,id:o}=await this.getAppSettings();return await this.session.hasValidToken(e,o,Uo)?this.session.token:(await this.logout(),null)}else return this.session.hasRefreshCredentials()?(await this.session.refresh(),this.session.token):null}async getAppSettings(){try{let e=await this.api.get(`/api/v1/apps/${this.appId}`);return{id:e.data.id,name:e.data.name,verificationKey:e.data.verification_key,logoUrl:e.data.logo_url||void 0,theme:e.data.theme,accentColor:e.data.accent_color||void 0,showWalletLoginFirst:e.data.show_wallet_login_first,walletAuth:e.data.wallet_auth,emailAuth:e.data.email_auth,smsAuth:e.data.sms_auth,googleOAuth:e.data.google_oauth,twitterOAuth:e.data.twitter_oauth,discordOAuth:e.data.discord_oauth,githubOAuth:e.data.github_oauth,termsAndConditionsUrl:e.data.terms_and_conditions_url,privacyPolicyUrl:e.data.privacy_policy_url,createdAt:new Date(e.data.created_at*1e3),updatedAt:new Date(e.data.updated_at*1e3)}}catch(e){throw q(e)}}setActiveWallet(e,o){if(!o.linkedAccounts.map(i=>i.type==="wallet"?i.address:null).includes(e))throw new p("Cannot set an unlinked address as active.");return _.put(se,e),Qe(o)}async forkSession(){return await this.session.forkSession()}};var yi=require("@ethersproject/providers");var xt=require("react");var w=()=>{throw new Error("You need to wrap your application with the <PrivyProvider> initialized with your app id.")};var oo=(0,xt.createContext)({ready:!1,authenticated:!1,user:null,walletConnector:null,login:w,linkEmail:w,linkPhone:w,linkWallet:w,linkGoogle:w,linkTwitter:w,linkDiscord:w,linkGithub:w,logout:w,getAccessToken:w,getEthereumProvider:w,getEthersProvider:w,getWeb3jsProvider:w,unlinkEmail:w,unlinkPhone:w,unlinkWallet:w,unlinkGoogle:w,unlinkTwitter:w,unlinkDiscord:w,unlinkGithub:w,setActiveWallet:w,forkSession:w}),N=()=>(0,xt.useContext)(oo);var et=class{constructor(e){this.connector=e,this.meta={wallet:this.connector.walletType}}async authenticate(){if(!this.api)throw new p("Auth flow has no API instance");if(!this.connector.walletType)throw new p("Wallet must be specified");try{let{message:e,signature:o}=await this.promptConnectAndSign(this.api),r=await this.api.post(jo(),{message:e,signature:o});return{user:r.data.user,token:r.data.token,refresh_token:r.data.refresh_token,is_new_user:r.data.is_new_user}}catch(e){throw O(e)}}async link(){if(!this.api)throw new p("Auth flow has no API instance");if(!this.connector.walletType)throw new p("Wallet must be specified");try{let{message:e,signature:o}=await this.promptConnectAndSign(this.api);return(await this.api.post(Zo(),{message:e,signature:o})).data}catch(e){throw O(e)}}async promptConnectAndSign(e){let o=await this.connector.connect({showPrompt:!0}),r=o.address,i=o.chainId,n=await e.post(zo(),{address:r}),s=this.connector.prepareMessage(i,r,n.data.nonce),u=await this.connector.sign(s);return{message:s,signature:u}}getEthereumProvider(){return this.connector.getEthereumProvider()}};var tt=class{constructor(e){this.meta={email:e}}async authenticate(){if(!this.api)throw new p("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new p("Email and email code must be set prior to calling authenticate.");try{let e=Ko(),o=await this.api.post(e,{email:this.meta.email,code:this.meta.emailCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(e){throw O(e)}}async link(){if(!this.api)throw new p("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new p("Email and email code must be set prior to calling authenticate.");try{let e=qo();return(await this.api.post(e,{email:this.meta.email,code:this.meta.emailCode})).data}catch(e){throw O(e)}}async sendCodeEmail(e){if(!this.api)throw new p("Auth flow has no API instance");if(e&&(this.meta.email=e),!this.meta.email)throw new p("Email must be set when initialzing authentication.");try{let o=$o();return(await this.api.post(o,{email:this.meta.email})).data}catch(o){throw O(o)}}};var ot=class{constructor(e){this.meta={phoneNumber:e}}async authenticate(){if(!this.api)throw new p("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new p("phone number and sms code must be set prior to calling authenticate.");try{let e=Jo(),o=await this.api.post(e,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(e){throw O(e)}}async link(){if(!this.api)throw new p("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new p("phone number and sms code must be set prior to calling authenticate.");try{let e=Qo();return(await this.api.post(e,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})).data}catch(e){throw O(e)}}async sendSmsCode(e){if(!this.api)throw new p("Auth flow has no API instance");if(e&&(this.meta.phoneNumber=e),!this.meta.phoneNumber)throw new p("phone nNumber must be set when initialzing authentication.");try{let o=Yo();return(await this.api.post(o,{phoneNumber:this.meta.phoneNumber})).data}catch(o){throw O(o)}}};var je=class{constructor(e,o,r){this.meta={provider:e},this.meta.authorizationCode=o,this.meta.stateCode=r}isActive(){return!!(this.meta.authorizationCode&&this.meta.stateCode&&this.meta.provider)}async authenticate(){if(!this.api)throw new p("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new p("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if(this.meta.authorizationCode==="undefined")throw new p("User denied confirmation during OAuth flow");try{let e=er(),o=await this.api.post(e,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(e){throw O(e)}}async link(){if(!this.api)throw new p("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new p("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if(this.meta.authorizationCode==="undefined")throw new p("User denied confirmation during OAuth flow");try{let e=tr();return(await this.api.post(e,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode})).data}catch(e){throw O(e)}}async getAuthorizationUrl(){if(!this.api)throw new p("Auth flow has no API instance");if(!this.meta.provider)throw new p("Provider must be set when initialzing OAuth authentication.");try{let e=Xo();return(await this.api.post(e,{provider:this.meta.provider,redirect_to:window.location.href})).data}catch(e){throw O(e)}}};var Td=require("wicg-inert"),fi=C(require("react-dom")),zt=C(require("styled-components"));var ae=require("react");var pr=require("react/jsx-runtime");function ur(t){return(0,pr.jsx)("link",{rel:"prefetch",href:t.src})}var Lt=require("react/jsx-runtime"),hr=(0,ae.createContext)({ready:!1,app:null,options:{email:!0,sms:!1,wallet:!0,google:!1,twitter:!1,discord:!1,github:!1},currentScreen:"LANDING",lastScreen:"LANDING",navigate:w,navigateBack:w}),mr=t=>{let e=t.appSettings,o=t.authenticated,r=t.visible,[i,n]=(0,ae.useState)(null),[s,u]=(0,ae.useState)(null);(0,ae.useEffect)(()=>{o||n(null)},[o]),(0,ae.useEffect)(()=>{r||(u("LANDING"),n("LANDING"))},[r]);let f={ready:!!(e!=null&&e.id),app:e,options:t.options,currentScreen:i||"LANDING",lastScreen:s||"LANDING",navigate:h=>{u(i),n(h)},navigateBack:()=>{n(s)}};return(0,Lt.jsxs)(hr.Provider,{value:f,children:[e&&e.logoUrl&&(0,Lt.jsx)(ur,{src:e.logoUrl}),t.children]})},y=()=>(0,ae.useContext)(hr);var Ft=require("react"),qe=C(require("styled-components"));var wr=C(require("styled-components"));var ro=require("react/jsx-runtime"),fr=({style:t,...e})=>(0,ro.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",style:{height:"1.5rem",width:"1.5rem",...t},...e,children:(0,ro.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})});var io=require("react/jsx-runtime"),gr=({style:t,...e})=>(0,io.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",style:{height:"1.5rem",width:"1.5rem",...t},...e,children:(0,io.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10.5 19.5L3 12m0 0l7.5-7.5M3 12h18"})});var At=require("react");var no=(0,At.createContext)({isLinking:!1,getAuthMeta:w,getAuthFlow:w,closePrivyModal:w,initLoginWithWallet:w,loginWithWallet:w,loginWithCode:w,loginWithEmail:w,loginWithSms:w,resendEmailCode:w,resendSmsCode:w,initLoginWithOAuth:w,loginWithOAuth:w,handleLoginError:w}),M=()=>(0,At.useContext)(no);var Y=require("react/jsx-runtime"),Fi=()=>(0,Y.jsx)("div",{}),Gi=({backFn:t})=>(0,Y.jsx)("div",{children:(0,Y.jsx)(gr,{onClick:t})}),Vi=()=>{let{closePrivyModal:t}=M();return(0,Y.jsx)("div",{children:(0,Y.jsx)("div",{children:(0,Y.jsx)(fr,{onClick:t})})})};var P=({backFn:t})=>(0,Y.jsxs)(Hi,{children:[t?(0,Y.jsx)(Gi,{backFn:t}):(0,Y.jsx)(Fi,{}),(0,Y.jsx)(Vi,{})]}),Hi=wr.default.div`
12
+ - https://privy.io`;this.ethProvider=new ve}initialize(){let e=P.get(ft);ar.includes(e)&&(this.walletType=e,this.connect({showPrompt:!1}))}destroy(){this.walletType=null,P.del(ft),P.del(Go)}async getConnectedWallet(){let e=this.walletType;if(!e||!await this.isConnected())return null;let o=await this.address(),r=await this.chainId();return{address:o,chainId:r,chainType:"ethereum",walletType:e}}async connect(e){var o;switch(this.walletType){case"metamask":this.ethProvider.setProvider(window.ethereum),(o=window.ethereum.providers)==null||o.forEach(async i=>{i.isMetaMask&&this.ethProvider.setProvider(i)});break;case"coinbase_wallet":this.ethProvider.setProvider(Di());break;case"wallet_connect":let r=new Xt.default({infuraId:pt});this.ethProvider.setProvider(r);break;default:throw new K(`Unsupported wallet: ${this.walletType}`)}return(!await this.isConnected()||e.showPrompt)&&await this.promptConnection(this.walletType),this.getConnectedWallet()}async isConnected(){switch(this.walletType){case"metamask":return await this.address()!==null;case"coinbase_wallet":return await this.address()!==null;case"wallet_connect":return this.ethProvider.walletProvider.connected;default:throw new K(`Unsupported wallet: ${this.walletType}`)}}async promptConnection(e){try{switch(e){case"metamask":await this.ethProvider.request({method:"wallet_requestPermissions",params:[{eth_accounts:{}}]}),await this.ethProvider.request({method:"eth_requestAccounts"});break;case"coinbase_wallet":await this.ethProvider.request({method:"eth_requestAccounts"});break;case"wallet_connect":let o=new Xt.default({infuraId:pt});this.ethProvider.setProvider(o),await Promise.race([o.enable(),Qt()]);break;default:throw new K(`Unsupported wallet: ${this.walletType}`)}P.put(ft,e)}catch(o){throw bt(o)}}async sign(e){return new dr.Web3Provider(new xe(this.getEthereumProvider())).getSigner().signMessage(e)}prepareMessage(e,o,r){let i=window.location.host,n=window.location.origin,s="By signing, you are proving you own this wallet and logging in. This does not initiate a transaction or cost any fees.",u=new Date().toISOString();return this.createSiweMessage(e,o,i,n,u,r,s)}async chainId(){let e=await this.getEthereumProvider().request({method:"eth_chainId"}),o=Number(e);return String(o)}async address(){let e=await this.getEthereumProvider().request({method:"eth_accounts"});return Array.isArray(e)&&e.length>0?(0,lr.getAddress)(e[0]):null}};var to,ze=class{constructor(e){let o=e.apiURL||Wo,r=e.timeout||No;this.appId=e.appId,this.connector=new Be,this.connector.initialize(),to||(to=new yt),this.session=to,this.api=new wt(e.appId,this.session,{baseURL:o,timeout:r}),this.session.api=this.api}authenticate(){if(!this.authFlow)throw new p("No auth flow in progress.");return this.session.authenticate(this.authFlow)}link(){if(!this.authFlow)throw new p("No auth flow in progress.");return this.session.link(this.authFlow)}async logout(){await this.session.destroy(),this.connector.destroy(),this.authFlow=void 0}startAuthFlow(e){e.api=this.api,this.authFlow=e}async unlinkEmail(e){try{let o=await this.api.post(rr(),{address:e});return pe(o.data)}catch(o){throw q(o)}}async unlinkPhone(e){try{let o=await this.api.post(ir(),{phoneNumber:e});return pe(o.data)}catch(o){throw q(o)}}async unlinkWallet(e){try{let o=await this.api.post(or(),{address:e});return pe(o.data)}catch(o){throw q(o)}}async unlinkOAuth(e,o){try{let r=await this.api.post(nr(),{provider:e,subject:o});return pe(r.data)}catch(r){throw q(r)}}async getAuthenticatedUser(){return this.session.hasRefreshCredentials()?this.session.refresh():null}async getAccessToken(){if(this.session.hasActiveToken()){let{verificationKey:e,id:o}=await this.getAppSettings();return await this.session.hasValidToken(e,o,Uo)?this.session.token:(await this.logout(),null)}else return this.session.hasRefreshCredentials()?(await this.session.refresh(),this.session.token):null}async getAppSettings(){try{let e=await this.api.get(`/api/v1/apps/${this.appId}`);return{id:e.data.id,name:e.data.name,verificationKey:e.data.verification_key,logoUrl:e.data.logo_url||void 0,theme:e.data.theme,accentColor:e.data.accent_color||void 0,showWalletLoginFirst:e.data.show_wallet_login_first,walletAuth:e.data.wallet_auth,emailAuth:e.data.email_auth,smsAuth:e.data.sms_auth,googleOAuth:e.data.google_oauth,twitterOAuth:e.data.twitter_oauth,discordOAuth:e.data.discord_oauth,githubOAuth:e.data.github_oauth,termsAndConditionsUrl:e.data.terms_and_conditions_url,privacyPolicyUrl:e.data.privacy_policy_url,createdAt:new Date(e.data.created_at*1e3),updatedAt:new Date(e.data.updated_at*1e3)}}catch(e){throw q(e)}}setActiveWallet(e,o){if(!o.linkedAccounts.map(i=>i.type==="wallet"?i.address:null).includes(e))throw new p("Cannot set an unlinked address as active.");return P.put(se,e),Qe(o)}async forkSession(){return await this.session.forkSession()}};var yi=require("@ethersproject/providers");var xt=require("react");var w=()=>{throw new Error("You need to wrap your application with the <PrivyProvider> initialized with your app id.")};var oo=(0,xt.createContext)({ready:!1,authenticated:!1,user:null,walletConnector:null,login:w,linkEmail:w,linkPhone:w,linkWallet:w,linkGoogle:w,linkTwitter:w,linkDiscord:w,linkGithub:w,logout:w,getAccessToken:w,getEthereumProvider:w,getEthersProvider:w,getWeb3jsProvider:w,unlinkEmail:w,unlinkPhone:w,unlinkWallet:w,unlinkGoogle:w,unlinkTwitter:w,unlinkDiscord:w,unlinkGithub:w,setActiveWallet:w,forkSession:w}),N=()=>(0,xt.useContext)(oo);var et=class{constructor(e){this.connector=e,this.meta={wallet:this.connector.walletType}}async authenticate(){if(!this.api)throw new p("Auth flow has no API instance");if(!this.connector.walletType)throw new p("Wallet must be specified");try{let{message:e,signature:o}=await this.promptConnectAndSign(this.api),r=await this.api.post(jo(),{message:e,signature:o});return{user:r.data.user,token:r.data.token,refresh_token:r.data.refresh_token,is_new_user:r.data.is_new_user}}catch(e){throw O(e)}}async link(){if(!this.api)throw new p("Auth flow has no API instance");if(!this.connector.walletType)throw new p("Wallet must be specified");try{let{message:e,signature:o}=await this.promptConnectAndSign(this.api);return(await this.api.post(Zo(),{message:e,signature:o})).data}catch(e){throw O(e)}}async promptConnectAndSign(e){let o=await this.connector.connect({showPrompt:!0}),r=o.address,i=o.chainId,n=await e.post(zo(),{address:r}),s=this.connector.prepareMessage(i,r,n.data.nonce),u=await this.connector.sign(s);return{message:s,signature:u}}getEthereumProvider(){return this.connector.getEthereumProvider()}};var tt=class{constructor(e){this.meta={email:e}}async authenticate(){if(!this.api)throw new p("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new p("Email and email code must be set prior to calling authenticate.");try{let e=Ko(),o=await this.api.post(e,{email:this.meta.email,code:this.meta.emailCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(e){throw O(e)}}async link(){if(!this.api)throw new p("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new p("Email and email code must be set prior to calling authenticate.");try{let e=qo();return(await this.api.post(e,{email:this.meta.email,code:this.meta.emailCode})).data}catch(e){throw O(e)}}async sendCodeEmail(e){if(!this.api)throw new p("Auth flow has no API instance");if(e&&(this.meta.email=e),!this.meta.email)throw new p("Email must be set when initialzing authentication.");try{let o=$o();return(await this.api.post(o,{email:this.meta.email})).data}catch(o){throw O(o)}}};var ot=class{constructor(e){this.meta={phoneNumber:e}}async authenticate(){if(!this.api)throw new p("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new p("phone number and sms code must be set prior to calling authenticate.");try{let e=Jo(),o=await this.api.post(e,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(e){throw O(e)}}async link(){if(!this.api)throw new p("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new p("phone number and sms code must be set prior to calling authenticate.");try{let e=Qo();return(await this.api.post(e,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})).data}catch(e){throw O(e)}}async sendSmsCode(e){if(!this.api)throw new p("Auth flow has no API instance");if(e&&(this.meta.phoneNumber=e),!this.meta.phoneNumber)throw new p("phone nNumber must be set when initialzing authentication.");try{let o=Yo();return(await this.api.post(o,{phoneNumber:this.meta.phoneNumber})).data}catch(o){throw O(o)}}};var je=class{constructor(e,o,r){this.meta={provider:e},this.meta.authorizationCode=o,this.meta.stateCode=r}isActive(){return!!(this.meta.authorizationCode&&this.meta.stateCode&&this.meta.provider)}async authenticate(){if(!this.api)throw new p("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new p("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if(this.meta.authorizationCode==="undefined")throw new p("User denied confirmation during OAuth flow");try{let e=er(),o=await this.api.post(e,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(e){throw O(e)}}async link(){if(!this.api)throw new p("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new p("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if(this.meta.authorizationCode==="undefined")throw new p("User denied confirmation during OAuth flow");try{let e=tr();return(await this.api.post(e,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode})).data}catch(e){throw O(e)}}async getAuthorizationUrl(){if(!this.api)throw new p("Auth flow has no API instance");if(!this.meta.provider)throw new p("Provider must be set when initialzing OAuth authentication.");try{let e=Xo();return(await this.api.post(e,{provider:this.meta.provider,redirect_to:window.location.href})).data}catch(e){throw O(e)}}};var Td=require("wicg-inert"),fi=C(require("react-dom")),zt=C(require("styled-components"));var ae=require("react");var pr=require("react/jsx-runtime");function ur(t){return(0,pr.jsx)("link",{rel:"prefetch",href:t.src})}var Lt=require("react/jsx-runtime"),hr=(0,ae.createContext)({ready:!1,app:null,options:{email:!0,sms:!1,wallet:!0,google:!1,twitter:!1,discord:!1,github:!1},currentScreen:"LANDING",lastScreen:"LANDING",navigate:w,navigateBack:w}),mr=t=>{let e=t.appSettings,o=t.authenticated,r=t.visible,[i,n]=(0,ae.useState)(null),[s,u]=(0,ae.useState)(null);(0,ae.useEffect)(()=>{o||n(null)},[o]),(0,ae.useEffect)(()=>{r||(u("LANDING"),n("LANDING"))},[r]);let f={ready:!!(e!=null&&e.id),app:e,options:t.options,currentScreen:i||"LANDING",lastScreen:s||"LANDING",navigate:h=>{u(i),n(h)},navigateBack:()=>{n(s)}};return(0,Lt.jsxs)(hr.Provider,{value:f,children:[e&&e.logoUrl&&(0,Lt.jsx)(ur,{src:e.logoUrl}),t.children]})},y=()=>(0,ae.useContext)(hr);var Ft=require("react"),qe=C(require("styled-components"));var wr=C(require("styled-components"));var ro=require("react/jsx-runtime"),fr=({style:t,...e})=>(0,ro.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",style:{height:"1.5rem",width:"1.5rem",...t},...e,children:(0,ro.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})});var io=require("react/jsx-runtime"),gr=({style:t,...e})=>(0,io.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",style:{height:"1.5rem",width:"1.5rem",...t},...e,children:(0,io.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10.5 19.5L3 12m0 0l7.5-7.5M3 12h18"})});var At=require("react");var no=(0,At.createContext)({isLinking:!1,getAuthMeta:w,getAuthFlow:w,closePrivyModal:w,initLoginWithWallet:w,loginWithWallet:w,loginWithCode:w,loginWithEmail:w,loginWithSms:w,resendEmailCode:w,resendSmsCode:w,initLoginWithOAuth:w,loginWithOAuth:w,handleLoginError:w}),M=()=>(0,At.useContext)(no);var Y=require("react/jsx-runtime"),Fi=()=>(0,Y.jsx)("div",{}),Gi=({backFn:t})=>(0,Y.jsx)("div",{children:(0,Y.jsx)(gr,{onClick:t})}),Vi=()=>{let{closePrivyModal:t}=M();return(0,Y.jsx)("div",{children:(0,Y.jsx)("div",{children:(0,Y.jsx)(fr,{onClick:t})})})};var S=({backFn:t})=>(0,Y.jsxs)(Hi,{children:[t?(0,Y.jsx)(Gi,{backFn:t}):(0,Y.jsx)(Fi,{}),(0,Y.jsx)(Vi,{})]}),Hi=wr.default.div`
13
13
  height: 30px;
14
14
  display: flex;
15
15
  align-items: center;
@@ -302,7 +302,7 @@ Resources:
302
302
  border-color: var(--fail-light);
303
303
  border-bottom-color: var(--fail-light);
304
304
  }
305
- `;var kr=require("libphonenumber-js/min");var _r=t=>!!String(t).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=t=>(0,kr.isPossiblePhoneNumber)(String(t),"US"),Ot=t=>{var e=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;t=t.replace(e,function(r,i,n,s){return i+i+n+n+s+s});var o=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return{r:parseInt((o==null?void 0:o[1])||"00",16),g:parseInt((o==null?void 0:o[2])||"00",16),b:parseInt((o==null?void 0:o[3])||"00",16)}},Sr=(t,e)=>{var o=t.slice(0);let r=[];for(;o.length;)r.push(o.splice(0,e));return r};var F=require("react/jsx-runtime"),Nt=t=>{let[e,o]=(0,$e.useState)(""),[r,i]=(0,$e.useState)(!1),[n,s]=(0,$e.useState)(null),{authenticated:u}=N(),{loginWithEmail:f,handleLoginError:h}=M(),{navigate:R,options:L}=y(),T=L.wallet;(0,$e.useEffect)(()=>{let d=document.querySelector("#email-input");d==null||d.focus()},[]);let E=_r(e),k=()=>{i(!0),f(e).then(()=>{R("AWAITING_PASSWORDLESS_CODE")}).catch(d=>{let b=(d==null?void 0:d.status)===401&&(d==null?void 0:d.message)==="User is not allowed to login to this app.";(d==null?void 0:d.status)===422?s(d.message):s(b?"You don't have access to this app":"Issue submitting email"),i(!1),h(b)})};return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(Ji,{stacked:t.stacked,children:[(0,F.jsxs)(en,{standalone:t.stacked,children:[(0,F.jsx)(Rt,{}),(0,F.jsx)("input",{id:"email-input",type:"email",placeholder:"your@email.com",onChange:d=>o(d.target.value),onKeyUp:d=>{d.key==="Enter"&&k()},value:e,autoComplete:"email"})]}),t.stacked?null:(0,F.jsx)(Qi,{disabled:r||!E,onClick:k,children:r?(0,F.jsx)(ke,{color:"var(--disabled-fg)",style:{height:"1rem",width:"1rem",borderWidth:"2px"}}):"Submit"})]}),n||u||!T?(0,F.jsx)(on,{fail:!!n,children:n||""}):null,!n&&!u&&T?(0,F.jsx)(tn,{children:(0,F.jsx)("span",{children:"Get started without a wallet."})}):null,t.stacked?(0,F.jsx)(Xi,{disabled:r||!E,onClick:k,children:r?(0,F.jsx)(ke,{color:"var(--disabled-fg)",style:{height:"1rem",width:"1rem",borderWidth:"2px"}}):"Submit"}):null]})},Ji=Oe.default.div`
305
+ `;var kr=require("libphonenumber-js/min");var _r=t=>!!String(t).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=t=>(0,kr.isPossiblePhoneNumber)(String(t),"US"),Ot=t=>{var e=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;t=t.replace(e,function(r,i,n,s){return i+i+n+n+s+s});var o=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return{r:parseInt((o==null?void 0:o[1])||"00",16),g:parseInt((o==null?void 0:o[2])||"00",16),b:parseInt((o==null?void 0:o[3])||"00",16)}},Sr=(t,e)=>{var o=t.slice(0);let r=[];for(;o.length;)r.push(o.splice(0,e));return r};var F=require("react/jsx-runtime"),Nt=t=>{let[e,o]=(0,$e.useState)(""),[r,i]=(0,$e.useState)(!1),[n,s]=(0,$e.useState)(null),{authenticated:u}=N(),{loginWithEmail:f,handleLoginError:h}=M(),{navigate:R,options:L}=y(),E=L.wallet;(0,$e.useEffect)(()=>{let d=document.querySelector("#email-input");d==null||d.focus()},[]);let k=_r(e),_=()=>{i(!0),f(e).then(()=>{R("AWAITING_PASSWORDLESS_CODE")}).catch(d=>{let b=(d==null?void 0:d.status)===401&&(d==null?void 0:d.message)==="User is not allowed to login to this app.";(d==null?void 0:d.status)===422?s(d.message):s(b?"You don't have access to this app":"Issue submitting email"),i(!1),h(b)})};return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(Ji,{stacked:t.stacked,children:[(0,F.jsxs)(en,{standalone:t.stacked,children:[(0,F.jsx)(Rt,{}),(0,F.jsx)("input",{id:"email-input",type:"email",placeholder:"your@email.com",onChange:d=>o(d.target.value),onKeyUp:d=>{d.key==="Enter"&&_()},value:e,autoComplete:"email"})]}),t.stacked?null:(0,F.jsx)(Qi,{disabled:r||!k,onClick:_,children:r?(0,F.jsx)(ke,{color:"var(--disabled-fg)",style:{height:"1rem",width:"1rem",borderWidth:"2px"}}):"Submit"})]}),n||u||!E?(0,F.jsx)(on,{fail:!!n,children:n||""}):null,!n&&!u&&E?(0,F.jsx)(tn,{children:(0,F.jsx)("span",{children:"Get started without a wallet."})}):null,t.stacked?(0,F.jsx)(Xi,{disabled:r||!k,onClick:_,children:r?(0,F.jsx)(ke,{color:"var(--disabled-fg)",style:{height:"1rem",width:"1rem",borderWidth:"2px"}}):"Submit"}):null]})},Ji=Oe.default.div`
306
306
  display: flex;
307
307
  border: 1px solid #d1d5db;
308
308
  width: 100%;
@@ -422,7 +422,7 @@ Resources:
422
422
  opacity: ${t=>t.success||t.fail?"1":"0"};
423
423
 
424
424
  transition: ${t=>t.fail?"":"all 150ms ease-in-out"};
425
- `;var Ke=require("react"),_e=C(require("styled-components"));var yo=require("react/jsx-runtime"),Ut=({style:t,...e})=>(0,yo.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 20 20",strokeWidth:1.5,stroke:"currentColor",style:{height:"1.5rem",width:"1.5rem",...t},...e,children:(0,yo.jsx)("path",{d:"M2.5 4.16667C2.5 3.72464 2.67559 3.30072 2.98816 2.98816C3.30072 2.67559 3.72464 2.5 4.16667 2.5H6.9C7.07483 2.50013 7.24519 2.55525 7.38696 2.65754C7.52874 2.75984 7.63475 2.90413 7.69 3.07L8.93833 6.81417C9.00158 7.00445 8.9941 7.21116 8.91726 7.39637C8.84042 7.58158 8.69938 7.73288 8.52 7.8225L6.63917 8.76417C7.5611 10.8046 9.19538 12.4389 11.2358 13.3608L12.1775 11.48C12.2671 11.3006 12.4184 11.1596 12.6036 11.0827C12.7888 11.0059 12.9956 10.9984 13.1858 11.0617L16.93 12.31C17.096 12.3653 17.2404 12.4714 17.3427 12.6134C17.445 12.7553 17.5 12.9259 17.5 13.1008V15.8333C17.5 16.2754 17.3244 16.6993 17.0118 17.0118C16.6993 17.3244 16.2754 17.5 15.8333 17.5H15C8.09667 17.5 2.5 11.9033 2.5 5V4.16667Z",strokeLinecap:"round",strokeLinejoin:"round"})});var G=require("react/jsx-runtime"),Dt=t=>{let[e,o]=(0,Ke.useState)(""),[r,i]=(0,Ke.useState)(!1),[n,s]=(0,Ke.useState)(null),{authenticated:u}=N(),{loginWithSms:f,handleLoginError:h}=M(),{navigate:R,options:L}=y(),T=L.wallet;(0,Ke.useEffect)(()=>{let d=document.querySelector("#phone-number-input");d==null||d.focus()},[]);let E=Pr(e),k=()=>{i(!0),f(e).then(()=>{R("AWAITING_PASSWORDLESS_CODE")}).catch(d=>{let b=(d==null?void 0:d.status)===401&&(d==null?void 0:d.message)==="User is not allowed to login to this app.";(d==null?void 0:d.status)===422?s(d.message):s(b?"You don't have access to this app":"Issue submitting phone number"),i(!1),h(b)})};return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(rn,{stacked:t.stacked,children:[(0,G.jsxs)(an,{standalone:t.stacked,children:[(0,G.jsx)(Ut,{}),(0,G.jsx)("input",{id:"phone-number-input",type:"tel",placeholder:"555 555 5555",onChange:d=>{o(d.target.value)},onKeyUp:d=>{d.key==="Enter"&&k()},value:e,autoComplete:"tel"})]}),t.stacked?null:(0,G.jsx)(nn,{disabled:r||!E,onClick:k,children:r?(0,G.jsx)(Tr,{color:"var(--disabled-fg)"}):"Submit"})]}),n||u||!T?(0,G.jsx)(dn,{fail:!!n,children:n||""}):null,!n&&!u&&T?(0,G.jsx)(ln,{children:(0,G.jsx)("span",{children:"Don\u2019t have a wallet? Start exploring with your phone or socials."})}):null,t.stacked?(0,G.jsx)(sn,{disabled:r||!E,onClick:k,children:r?(0,G.jsx)(Tr,{color:"var(--disabled-fg)"}):"Submit"}):null]})},rn=_e.default.div`
425
+ `;var Ke=require("react"),_e=C(require("styled-components"));var yo=require("react/jsx-runtime"),Ut=({style:t,...e})=>(0,yo.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 20 20",strokeWidth:1.5,stroke:"currentColor",style:{height:"1.5rem",width:"1.5rem",...t},...e,children:(0,yo.jsx)("path",{d:"M2.5 4.16667C2.5 3.72464 2.67559 3.30072 2.98816 2.98816C3.30072 2.67559 3.72464 2.5 4.16667 2.5H6.9C7.07483 2.50013 7.24519 2.55525 7.38696 2.65754C7.52874 2.75984 7.63475 2.90413 7.69 3.07L8.93833 6.81417C9.00158 7.00445 8.9941 7.21116 8.91726 7.39637C8.84042 7.58158 8.69938 7.73288 8.52 7.8225L6.63917 8.76417C7.5611 10.8046 9.19538 12.4389 11.2358 13.3608L12.1775 11.48C12.2671 11.3006 12.4184 11.1596 12.6036 11.0827C12.7888 11.0059 12.9956 10.9984 13.1858 11.0617L16.93 12.31C17.096 12.3653 17.2404 12.4714 17.3427 12.6134C17.445 12.7553 17.5 12.9259 17.5 13.1008V15.8333C17.5 16.2754 17.3244 16.6993 17.0118 17.0118C16.6993 17.3244 16.2754 17.5 15.8333 17.5H15C8.09667 17.5 2.5 11.9033 2.5 5V4.16667Z",strokeLinecap:"round",strokeLinejoin:"round"})});var G=require("react/jsx-runtime"),Dt=t=>{let[e,o]=(0,Ke.useState)(""),[r,i]=(0,Ke.useState)(!1),[n,s]=(0,Ke.useState)(null),{authenticated:u}=N(),{loginWithSms:f,handleLoginError:h}=M(),{navigate:R,options:L}=y(),E=L.wallet;(0,Ke.useEffect)(()=>{let d=document.querySelector("#phone-number-input");d==null||d.focus()},[]);let k=Pr(e),_=()=>{i(!0),f(e).then(()=>{R("AWAITING_PASSWORDLESS_CODE")}).catch(d=>{let b=(d==null?void 0:d.status)===401&&(d==null?void 0:d.message)==="User is not allowed to login to this app.";(d==null?void 0:d.status)===422?s(d.message):s(b?"You don't have access to this app":"Issue submitting phone number"),i(!1),h(b)})};return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(rn,{stacked:t.stacked,children:[(0,G.jsxs)(an,{standalone:t.stacked,children:[(0,G.jsx)(Ut,{}),(0,G.jsx)("input",{id:"phone-number-input",type:"tel",placeholder:"555 555 5555",onChange:d=>{o(d.target.value)},onKeyUp:d=>{d.key==="Enter"&&_()},value:e,autoComplete:"tel"})]}),t.stacked?null:(0,G.jsx)(nn,{disabled:r||!k,onClick:_,children:r?(0,G.jsx)(Tr,{color:"var(--disabled-fg)"}):"Submit"})]}),n||u||!E?(0,G.jsx)(dn,{fail:!!n,children:n||""}):null,!n&&!u&&E?(0,G.jsx)(ln,{children:(0,G.jsx)("span",{children:"Don\u2019t have a wallet? Start exploring with your phone or socials."})}):null,t.stacked?(0,G.jsx)(sn,{disabled:r||!k,onClick:_,children:r?(0,G.jsx)(Tr,{color:"var(--disabled-fg)"}):"Submit"}):null]})},rn=_e.default.div`
426
426
  display: flex;
427
427
  border: 1px solid #d1d5db;
428
428
  width: 100%;
@@ -547,7 +547,7 @@ Resources:
547
547
  width: 1rem;
548
548
  border-width: 2px;
549
549
  }
550
- `;var bo=require("react/jsx-runtime"),Ir=()=>{let{app:t}=y();return t!=null&&t.logoUrl?(0,bo.jsx)("div",{children:(0,bo.jsx)("img",{src:t.logoUrl,alt:`${t==null?void 0:t.name} logo`,style:{objectFit:"contain",width:"200px",height:"80px"}})}):null};var Co=require("react-device-detect"),m=require("react/jsx-runtime");var Rr=()=>{let{ready:t}=N(),{getAuthMeta:e,isLinking:o}=M(),{app:r,navigate:i,options:n}=y(),s=n.email,u=n.sms,f=n.wallet,h=n.google,R=n.twitter,L=n.discord,T=n.github,E=f&&(r==null?void 0:r.showWalletLoginFirst)?0:1,[k,d]=(0,Ft.useState)(E),b=e(),$=(b==null?void 0:b.authorizationCode)&&(b==null?void 0:b.stateCode)&&(b==null?void 0:b.provider);(0,Ft.useEffect)(()=>{$?i("AWAITING_OAUTH_SCREEN"):o&&s?i("LINK_EMAIL_SCREEN"):o&&u?i("LINK_PHONE_SCREEN"):o&&f&&i("LINK_WALLET_SCREEN")},[t]);let V=k==0,ge=k==1,v=()=>(0,m.jsx)(m.Fragment,{children:f&&(0,m.jsx)(cn,{active:V,onClick:()=>d(0)})}),j=()=>(0,m.jsx)(m.Fragment,{children:(s||u)&&(0,m.jsx)(un,{active:ge,onClick:()=>d(1),email:s,sms:u,google:h,twitter:R,discord:L,github:T})});return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(P,{},"header"),(0,m.jsx)(mn,{walletOnly:!s&&!u&&!h&&!R&&!L,hasTerms:!!((r==null?void 0:r.privacyPolicyUrl)||(r==null?void 0:r.termsAndConditionsUrl)),children:(0,m.jsx)(Ir,{})}),(0,m.jsx)(Ae,{children:r!=null&&r.showWalletLoginFirst?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(v,{}),(0,m.jsx)(j,{})]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(j,{}),(0,m.jsx)(v,{})]})}),r&&(0,m.jsx)(vr,{app:r}),(0,m.jsx)(le,{protectedByPrivy:!0})]})};function cn(t){return(0,m.jsxs)(Or,{active:t.active,onClick:t.onClick,children:[(0,m.jsx)(Wr,{active:t.active,children:(0,m.jsx)("h4",{children:"Connect Wallet"})}),t.active&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(_t,{}),(0,m.jsx)(Pt,{})]})]})}function un(t){let e=t.google||t.discord||t.github||t.twitter&&!Co.isMobile,o=t.email?"Email":"Phone";return(0,m.jsxs)(Or,{active:t.active,onClick:t.onClick,children:[(0,m.jsx)(Wr,{active:t.active,children:(0,m.jsxs)("h4",{children:["Sign In with ",e?`${o} & Social`:o]})}),t.active&&t.email&&(0,m.jsx)(Nt,{}),t.active&&t.sms&&!t.email&&(0,m.jsx)(Dt,{}),t.active&&e&&(0,m.jsx)(pn,{google:t.google,twitter:t.twitter&&!Co.isMobile,discord:t.discord,github:t.github})]})}function pn(t){return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(hn,{children:[(0,m.jsx)(Mr,{}),(0,m.jsx)("p",{children:" Or "}),(0,m.jsx)(Mr,{})]}),(0,m.jsx)(Lr,{showGoogle:t.google,showDiscord:t.discord,showGithub:t.github,showTwitter:t.twitter})]})}var Wr=qe.default.div`
550
+ `;var bo=require("react/jsx-runtime"),Ir=()=>{let{app:t}=y();return t!=null&&t.logoUrl?(0,bo.jsx)("div",{children:(0,bo.jsx)("img",{src:t.logoUrl,alt:`${t==null?void 0:t.name} logo`,style:{objectFit:"contain",width:"200px",height:"80px"}})}):null};var Co=require("react-device-detect"),m=require("react/jsx-runtime");var Rr=()=>{let{ready:t}=N(),{getAuthMeta:e,isLinking:o}=M(),{app:r,navigate:i,options:n}=y(),s=n.email,u=n.sms,f=n.wallet,h=n.google,R=n.twitter,L=n.discord,E=n.github,k=f&&(r==null?void 0:r.showWalletLoginFirst)?0:1,[_,d]=(0,Ft.useState)(k),b=e(),$=(b==null?void 0:b.authorizationCode)&&(b==null?void 0:b.stateCode)&&(b==null?void 0:b.provider);(0,Ft.useEffect)(()=>{$?i("AWAITING_OAUTH_SCREEN"):o&&s?i("LINK_EMAIL_SCREEN"):o&&u?i("LINK_PHONE_SCREEN"):o&&f&&i("LINK_WALLET_SCREEN")},[t]);let V=_==0,ge=_==1,v=()=>(0,m.jsx)(m.Fragment,{children:f&&(0,m.jsx)(cn,{active:V,onClick:()=>d(0)})}),j=()=>(0,m.jsx)(m.Fragment,{children:(s||u)&&(0,m.jsx)(un,{active:ge,onClick:()=>d(1),email:s,sms:u,google:h,twitter:R,discord:L,github:E})});return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(S,{},"header"),(0,m.jsx)(mn,{walletOnly:!s&&!u&&!h&&!R&&!L&&!E,hasTerms:!!((r==null?void 0:r.privacyPolicyUrl)||(r==null?void 0:r.termsAndConditionsUrl)),children:(0,m.jsx)(Ir,{})}),(0,m.jsx)(Ae,{children:r!=null&&r.showWalletLoginFirst?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(v,{}),(0,m.jsx)(j,{})]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(j,{}),(0,m.jsx)(v,{})]})}),r&&(0,m.jsx)(vr,{app:r}),(0,m.jsx)(le,{protectedByPrivy:!0})]})};function cn(t){return(0,m.jsxs)(Or,{active:t.active,onClick:t.onClick,children:[(0,m.jsx)(Wr,{active:t.active,children:(0,m.jsx)("h4",{children:"Connect Wallet"})}),t.active&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(_t,{}),(0,m.jsx)(Pt,{})]})]})}function un(t){let e=t.google||t.discord||t.github||t.twitter&&!Co.isMobile,o=t.email?"Email":"Phone";return(0,m.jsxs)(Or,{active:t.active,onClick:t.onClick,children:[(0,m.jsx)(Wr,{active:t.active,children:(0,m.jsxs)("h4",{children:["Sign In with ",e?`${o} & Social`:o]})}),t.active&&t.email&&(0,m.jsx)(Nt,{}),t.active&&t.sms&&!t.email&&(0,m.jsx)(Dt,{}),t.active&&e&&(0,m.jsx)(pn,{google:t.google,twitter:t.twitter&&!Co.isMobile,discord:t.discord,github:t.github})]})}function pn(t){return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(hn,{children:[(0,m.jsx)(Mr,{}),(0,m.jsx)("p",{children:" Or "}),(0,m.jsx)(Mr,{})]}),(0,m.jsx)(Lr,{showGoogle:t.google,showDiscord:t.discord,showGithub:t.github,showTwitter:t.twitter})]})}var Wr=qe.default.div`
551
551
  font-weight: ${t=>t.active?600:500};
552
552
  color: ${t=>t.active?"inherit":"#6b7280"};
553
553
  display: flex;
@@ -641,7 +641,7 @@ Resources:
641
641
  border-color: #e1e7ef;
642
642
  border-width: 1px;
643
643
  }
644
- `;var A=require("react/jsx-runtime"),vo=6,Dr=new Array(vo).fill(""),wn=1400;var Fr=()=>{var j,a,c;let{app:t}=y(),{closePrivyModal:e,resendEmailCode:o,resendSmsCode:r,getAuthMeta:i,loginWithCode:n}=M(),{authenticated:s,user:u}=N(),[f,h]=(0,Pe.useState)(Dr),[R,L]=(0,Pe.useState)(!1),[T,E]=(0,Pe.useState)(null),[k,d]=(0,Pe.useState)(null),b=(j=i())!=null&&j.email?0:1;(0,Pe.useEffect)(()=>{if(s&&R){let I=setTimeout(e,De);return()=>clearTimeout(I)}},[s,R,u]),(0,Pe.useEffect)(()=>{if(T&&k===0){let I=setTimeout(()=>{h(Dr),E(null);let W=document.querySelector("input[name=code-0]");W==null||W.focus()},wn);return()=>clearTimeout(I)}},[T]);let $=I=>{var To;let W=I.currentTarget.value.replace(" ","");if(W==="")return;if(isNaN(Number(W))){E("Code should be numeric"),d(1);return}E(null),d(null);let ie=Number((To=I.currentTarget.name)==null?void 0:To.charAt(5)),Zt=[...W||[""]].slice(0,vo-ie),$t=[...f.slice(0,ie),...Zt,...f.slice(ie+Zt.length)];h($t);let vi=Zt.length,So=Math.min(Math.max(ie+vi,0),vo-1);if(!isNaN(Number(I.currentTarget.value))){let ne=document.querySelector(`input[name=code-${So}]`);ne==null||ne.focus()}if($t.every(ne=>ne&&!isNaN(+ne))){let ne=document.querySelector(`input[name=code-${So}]`);ne==null||ne.blur(),n($t.join("")).then(()=>L(!0)).catch(Kt=>{(Kt==null?void 0:Kt.status)===422?E("Invalid or expired verification code"):E("Issue verifying code"),d(0)})}I.preventDefault()},V=I=>{k===1&&(E(null),d(null));let W=[...f.slice(0,I),"",...f.slice(I+1)];if(h(W),I>0){let ie=document.querySelector(`input[name=code-${I-1}]`);ie==null||ie.focus()}},ge=`Verify your ${b==0?"email":"phone"}`,v=b==0?`Please check ${(a=i())==null?void 0:a.email} for an email from privy.io and enter your code below.`:`Please check ${(c=i())==null?void 0:c.phoneNumber} for a message from ${(t==null?void 0:t.name)||"privy.io"} and enter your code below.`;return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(P,{},"header"),(0,A.jsxs)(yn,{children:[(0,A.jsx)(Ne,{title:ge,description:v}),(0,A.jsxs)(xr,{children:[(0,A.jsxs)(bn,{children:[(0,A.jsx)(Cn,{fail:!!T,success:R,children:(0,A.jsx)("span",{children:T||(R?"Success!":"")})}),(0,A.jsx)("div",{children:f.map((I,W)=>(0,A.jsx)("input",{name:`code-${W}`,type:"text",value:f[W],onChange:$,onKeyUp:ie=>{ie.key==="Backspace"&&V(W)},inputMode:"numeric",autoFocus:W===0,pattern:"[0-9]",className:`${R?"success":""} ${T?"fail":""}`,autoComplete:"one-time-code"},W))})]}),(0,A.jsx)(vn,{children:b==0?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("span",{children:"Didn't get an email?"}),(0,A.jsx)("button",{onClick:o,children:"Resend Code"})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("span",{children:"Didn't get a message?"}),(0,A.jsx)("button",{onClick:r,children:"Resend Code"})]})})]})]}),(0,A.jsx)(le,{protectedByPrivy:!0})]})},yn=st.default.div`
644
+ `;var A=require("react/jsx-runtime"),vo=6,Dr=new Array(vo).fill(""),wn=1400;var Fr=()=>{var j,a,c;let{app:t}=y(),{closePrivyModal:e,resendEmailCode:o,resendSmsCode:r,getAuthMeta:i,loginWithCode:n}=M(),{authenticated:s,user:u}=N(),[f,h]=(0,Pe.useState)(Dr),[R,L]=(0,Pe.useState)(!1),[E,k]=(0,Pe.useState)(null),[_,d]=(0,Pe.useState)(null),b=(j=i())!=null&&j.email?0:1;(0,Pe.useEffect)(()=>{if(s&&R){let I=setTimeout(e,De);return()=>clearTimeout(I)}},[s,R,u]),(0,Pe.useEffect)(()=>{if(E&&_===0){let I=setTimeout(()=>{h(Dr),k(null);let W=document.querySelector("input[name=code-0]");W==null||W.focus()},wn);return()=>clearTimeout(I)}},[E]);let $=I=>{var To;let W=I.currentTarget.value.replace(" ","");if(W==="")return;if(isNaN(Number(W))){k("Code should be numeric"),d(1);return}k(null),d(null);let ie=Number((To=I.currentTarget.name)==null?void 0:To.charAt(5)),Zt=[...W||[""]].slice(0,vo-ie),$t=[...f.slice(0,ie),...Zt,...f.slice(ie+Zt.length)];h($t);let vi=Zt.length,So=Math.min(Math.max(ie+vi,0),vo-1);if(!isNaN(Number(I.currentTarget.value))){let ne=document.querySelector(`input[name=code-${So}]`);ne==null||ne.focus()}if($t.every(ne=>ne&&!isNaN(+ne))){let ne=document.querySelector(`input[name=code-${So}]`);ne==null||ne.blur(),n($t.join("")).then(()=>L(!0)).catch(Kt=>{(Kt==null?void 0:Kt.status)===422?k("Invalid or expired verification code"):k("Issue verifying code"),d(0)})}I.preventDefault()},V=I=>{_===1&&(k(null),d(null));let W=[...f.slice(0,I),"",...f.slice(I+1)];if(h(W),I>0){let ie=document.querySelector(`input[name=code-${I-1}]`);ie==null||ie.focus()}},ge=`Verify your ${b==0?"email":"phone"}`,v=b==0?`Please check ${(a=i())==null?void 0:a.email} for an email from privy.io and enter your code below.`:`Please check ${(c=i())==null?void 0:c.phoneNumber} for a message from ${(t==null?void 0:t.name)||"privy.io"} and enter your code below.`;return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(S,{},"header"),(0,A.jsxs)(yn,{children:[(0,A.jsx)(Ne,{title:ge,description:v}),(0,A.jsxs)(xr,{children:[(0,A.jsxs)(bn,{children:[(0,A.jsx)(Cn,{fail:!!E,success:R,children:(0,A.jsx)("span",{children:E||(R?"Success!":"")})}),(0,A.jsx)("div",{children:f.map((I,W)=>(0,A.jsx)("input",{name:`code-${W}`,type:"text",value:f[W],onChange:$,onKeyUp:ie=>{ie.key==="Backspace"&&V(W)},inputMode:"numeric",autoFocus:W===0,pattern:"[0-9]",className:`${R?"success":""} ${E?"fail":""}`,autoComplete:"one-time-code"},W))})]}),(0,A.jsx)(vn,{children:b==0?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("span",{children:"Didn't get an email?"}),(0,A.jsx)("button",{onClick:o,children:"Resend Code"})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("span",{children:"Didn't get a message?"}),(0,A.jsx)("button",{onClick:r,children:"Resend Code"})]})})]})]}),(0,A.jsx)(le,{protectedByPrivy:!0})]})},yn=st.default.div`
645
645
  display: flex;
646
646
  flex-direction: column;
647
647
  align-items: flex-start;
@@ -813,7 +813,7 @@ Resources:
813
813
  border: 1px solid #e5e7eb;
814
814
  color: var(--text-dark-blue);
815
815
  }
816
- `;var l=require("react/jsx-runtime");var Eo=()=>{let{navigate:t}=y(),e="https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn?hl=en";return Se.isFirefox&&(e="https://addons.mozilla.org/en-US/firefox/addon/ether-metamask/"),(0,l.jsxs)(ei,{children:[(0,l.jsx)(Ne,{title:"Create a Metamask wallet",description:"Follow the instructions below to get started."}),(0,l.jsx)(ti,{children:(0,l.jsx)(Re,{style:{width:"152px",height:"152px"}})}),(0,l.jsxs)(Ao,{children:[(0,l.jsx)(Ue,{children:(0,l.jsxs)("div",{children:[(0,l.jsx)("span",{children:"Install the "}),(0,l.jsx)("a",{href:e,target:"_blank",children:"MetaMask browser extension"})]})}),(0,l.jsx)(at,{}),(0,l.jsx)(Ue,{children:"Set up your first wallet"}),(0,l.jsx)(at,{}),(0,l.jsx)(Ue,{children:"Store your recovery phrase in a safe place!"})]}),(0,l.jsx)(oi,{onClick:()=>t("LANDING"),children:"Done! I have my wallet"})]})},ko=()=>{let{navigate:t}=y();return(0,l.jsxs)(ei,{children:[(0,l.jsx)(Ne,{title:"Create a Coinbase wallet",description:"Follow the instructions below to get started."}),(0,l.jsx)(ti,{style:{marginTop:"-24px"},children:(0,l.jsx)(zr,{size:200})}),(0,l.jsxs)(Ao,{children:[(0,l.jsx)(Ue,{children:"Scan the QR code with your camera"}),(0,l.jsx)(at,{}),(0,l.jsx)(Ue,{children:"Set up your first wallet"}),(0,l.jsx)(at,{}),(0,l.jsx)(Ue,{children:"Store your seed phrase in a safe place!"})]}),(0,l.jsx)(oi,{onClick:()=>t("LANDING"),children:"Done! I have my wallet"})]})},Xr=()=>{let[t,e]=(0,Qr.useState)("WHAT_IS_A_WALLET"),{navigateBack:o}=y();return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(P,{backFn:t==="WHAT_IS_A_WALLET"?o:t==="PICK_A_NEW_WALLET"?()=>e("WHAT_IS_A_WALLET"):()=>e("PICK_A_NEW_WALLET")},"header"),(0,l.jsxs)(Tn,{children:[t==="WHAT_IS_A_WALLET"&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(On,{children:(0,l.jsx)($r,{style:{width:"240px",height:"auto",borderRadius:"var(--border-radius-sm)",marginBottom:"32px"}})}),(0,l.jsxs)(Ye,{title:"Get started with a new wallet",children:[(0,l.jsx)("p",{children:"Wallets help you store, send, and receive digital assets and collectibles. They are also a new\xA0way\xA0to\xA0log\xA0in."}),(0,l.jsx)("p",{children:"Instead of creating new accounts and passwords for every app, you just connect your wallet and bring your\xA0data\xA0with\xA0you."})]}),(0,l.jsx)(Rn,{children:(0,l.jsx)(Wn,{onClick:()=>{e("PICK_A_NEW_WALLET")},children:"Create a wallet"})})]}),t==="PICK_A_NEW_WALLET"&&(0,l.jsx)(l.Fragment,{children:(0,l.jsxs)(In,{children:[(0,l.jsx)(Ne,{title:"Create a new wallet",description:"Select one the wallet providers below to get started on your web3 adventure."}),(0,l.jsxs)(Mn,{children:[(0,l.jsxs)(Yr,{onClick:()=>{Se.isIOS?window.location.href="https://apps.apple.com/us/app/metamask-blockchain-wallet/id1438144202":Se.isAndroid?window.location.href="https://play.google.com/store/apps/details?id=io.metamask":e("CREATE_METAMASK_WALLET")},children:[(0,l.jsx)(Re,{}),(0,l.jsxs)(Jr,{children:[(0,l.jsx)("h4",{children:"MetaMask"}),(0,l.jsx)("p",{children:"Get a browser-based wallet"})]}),(0,l.jsx)("div",{children:(0,l.jsx)("span",{children:"Set up"})})]}),(0,l.jsxs)(Yr,{onClick:()=>{Se.isIOS?window.location.href="https://apps.apple.com/us/app/coinbase-wallet-nfts-crypto/id1278383455":Se.isAndroid?window.location.href="https://play.google.com/store/apps/details?id=org.toshi":e("CREATE_COINBASE_WALLET")},children:[(0,l.jsx)(Le,{}),(0,l.jsxs)(Jr,{children:[(0,l.jsx)("h4",{children:"Coinbase Wallet"}),(0,l.jsx)("p",{children:"Get a mobile app wallet"})]}),(0,l.jsx)("div",{children:(0,l.jsx)("span",{children:"Set up"})})]})]})]})}),t==="CREATE_COINBASE_WALLET"&&(0,l.jsx)(ko,{}),t==="CREATE_METAMASK_WALLET"&&(0,l.jsx)(Eo,{})]}),(0,l.jsxs)(me,{children:[(0,l.jsx)("span",{children:"Still not sure? "}),(0,l.jsx)("a",{target:"_blank",href:"https://join.tell.ie/blog/explaining-web3-wallets",children:"Learn more"}),"."]})]})},Tn=Q.default.div`
816
+ `;var l=require("react/jsx-runtime");var Eo=()=>{let{navigate:t}=y(),e="https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn?hl=en";return Se.isFirefox&&(e="https://addons.mozilla.org/en-US/firefox/addon/ether-metamask/"),(0,l.jsxs)(ei,{children:[(0,l.jsx)(Ne,{title:"Create a Metamask wallet",description:"Follow the instructions below to get started."}),(0,l.jsx)(ti,{children:(0,l.jsx)(Re,{style:{width:"152px",height:"152px"}})}),(0,l.jsxs)(Ao,{children:[(0,l.jsx)(Ue,{children:(0,l.jsxs)("div",{children:[(0,l.jsx)("span",{children:"Install the "}),(0,l.jsx)("a",{href:e,target:"_blank",children:"MetaMask browser extension"})]})}),(0,l.jsx)(at,{}),(0,l.jsx)(Ue,{children:"Set up your first wallet"}),(0,l.jsx)(at,{}),(0,l.jsx)(Ue,{children:"Store your recovery phrase in a safe place!"})]}),(0,l.jsx)(oi,{onClick:()=>t("LANDING"),children:"Done! I have my wallet"})]})},ko=()=>{let{navigate:t}=y();return(0,l.jsxs)(ei,{children:[(0,l.jsx)(Ne,{title:"Create a Coinbase wallet",description:"Follow the instructions below to get started."}),(0,l.jsx)(ti,{style:{marginTop:"-24px"},children:(0,l.jsx)(zr,{size:200})}),(0,l.jsxs)(Ao,{children:[(0,l.jsx)(Ue,{children:"Scan the QR code with your camera"}),(0,l.jsx)(at,{}),(0,l.jsx)(Ue,{children:"Set up your first wallet"}),(0,l.jsx)(at,{}),(0,l.jsx)(Ue,{children:"Store your seed phrase in a safe place!"})]}),(0,l.jsx)(oi,{onClick:()=>t("LANDING"),children:"Done! I have my wallet"})]})},Xr=()=>{let[t,e]=(0,Qr.useState)("WHAT_IS_A_WALLET"),{navigateBack:o}=y();return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(S,{backFn:t==="WHAT_IS_A_WALLET"?o:t==="PICK_A_NEW_WALLET"?()=>e("WHAT_IS_A_WALLET"):()=>e("PICK_A_NEW_WALLET")},"header"),(0,l.jsxs)(Tn,{children:[t==="WHAT_IS_A_WALLET"&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(On,{children:(0,l.jsx)($r,{style:{width:"240px",height:"auto",borderRadius:"var(--border-radius-sm)",marginBottom:"32px"}})}),(0,l.jsxs)(Ye,{title:"Get started with a new wallet",children:[(0,l.jsx)("p",{children:"Wallets help you store, send, and receive digital assets and collectibles. They are also a new\xA0way\xA0to\xA0log\xA0in."}),(0,l.jsx)("p",{children:"Instead of creating new accounts and passwords for every app, you just connect your wallet and bring your\xA0data\xA0with\xA0you."})]}),(0,l.jsx)(Rn,{children:(0,l.jsx)(Wn,{onClick:()=>{e("PICK_A_NEW_WALLET")},children:"Create a wallet"})})]}),t==="PICK_A_NEW_WALLET"&&(0,l.jsx)(l.Fragment,{children:(0,l.jsxs)(In,{children:[(0,l.jsx)(Ne,{title:"Create a new wallet",description:"Select one the wallet providers below to get started on your web3 adventure."}),(0,l.jsxs)(Mn,{children:[(0,l.jsxs)(Yr,{onClick:()=>{Se.isIOS?window.location.href="https://apps.apple.com/us/app/metamask-blockchain-wallet/id1438144202":Se.isAndroid?window.location.href="https://play.google.com/store/apps/details?id=io.metamask":e("CREATE_METAMASK_WALLET")},children:[(0,l.jsx)(Re,{}),(0,l.jsxs)(Jr,{children:[(0,l.jsx)("h4",{children:"MetaMask"}),(0,l.jsx)("p",{children:"Get a browser-based wallet"})]}),(0,l.jsx)("div",{children:(0,l.jsx)("span",{children:"Set up"})})]}),(0,l.jsxs)(Yr,{onClick:()=>{Se.isIOS?window.location.href="https://apps.apple.com/us/app/coinbase-wallet-nfts-crypto/id1278383455":Se.isAndroid?window.location.href="https://play.google.com/store/apps/details?id=org.toshi":e("CREATE_COINBASE_WALLET")},children:[(0,l.jsx)(Le,{}),(0,l.jsxs)(Jr,{children:[(0,l.jsx)("h4",{children:"Coinbase Wallet"}),(0,l.jsx)("p",{children:"Get a mobile app wallet"})]}),(0,l.jsx)("div",{children:(0,l.jsx)("span",{children:"Set up"})})]})]})]})}),t==="CREATE_COINBASE_WALLET"&&(0,l.jsx)(ko,{}),t==="CREATE_METAMASK_WALLET"&&(0,l.jsx)(Eo,{})]}),(0,l.jsxs)(me,{children:[(0,l.jsx)("span",{children:"Still not sure? "}),(0,l.jsx)("a",{target:"_blank",href:"https://join.tell.ie/blog/explaining-web3-wallets",children:"Learn more"}),"."]})]})},Tn=Q.default.div`
817
817
  display: flex;
818
818
  flex-direction: column;
819
819
  height: 100%;
@@ -938,7 +938,7 @@ Resources:
938
938
  `,On=Q.default.div`
939
939
  display: flex;
940
940
  justify-content: center;
941
- `;var Te=require("react");var lt=C(require("styled-components"));var H=require("react/jsx-runtime"),_o=2,ri={metamask:{name:"MetaMask",component:Re},coinbase_wallet:{name:"Coinbase Wallet",component:Le},wallet_connect:{name:"WalletConnect",component:Et}},ii=()=>{var ge;let[t,e]=(0,Te.useState)(!1),[o,r]=(0,Te.useState)(void 0),{navigateBack:i}=y(),{getAuthMeta:n,closePrivyModal:s,loginWithWallet:u,handleLoginError:f}=M(),[h,R]=(0,Te.useState)(0),{user:L}=N(),[T,E]=(0,Te.useState)((L==null?void 0:L.linkedAccounts.length)||0);(0,Te.useEffect)(()=>{r(void 0),u().then(()=>e(!0)).catch(v=>{v instanceof X?console.error(v.cause):console.error(v);let j=(v==null?void 0:v.status)===401&&(v==null?void 0:v.message)==="User is not allowed to login to this app.";(v==null?void 0:v.status)===422?r(Xe.ERROR_USER_EXISTS):j?r(Xe.ERROR_WALLET_NOT_ALLOWED):v instanceof He&&!v.details.default?r(v.details):v instanceof Ve?r(Xe.ERROR_TIMED_OUT):r(Xe.ERROR_WALLET_CONNECTION),f(j)})},[h]),(0,Te.useEffect)(()=>{if(t){let v=setTimeout(s,De);return()=>clearTimeout(v)}},[L]);let k=((ge=n())==null?void 0:ge.wallet)||"metamask",d=ri[k].name,b=ri[k].component,$=t?`Successfully connected with ${d}`:o?o.message:`Waiting for ${d}`,V="";if(t){let v=(L==null?void 0:L.linkedAccounts.length)||0;T===v?V="Wallet was already linked.":V="You\u2019re good to go!"}else if(h>=_o&&o)V="Unable to connect wallet";else if(o)V=o.detail;else switch(V="Don\u2019t see your wallet modal? Check your other browser windows.",k){case"wallet_connect":V="Open your mobile wallet app to continue";break;case"coinbase_wallet":vt()||(V="Open the Coinbase app on your phone to continue.");break;default:V="Don\u2019t see your wallet modal? Check your other browser windows."}return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(P,{backFn:i}),(0,H.jsxs)(Nn,{children:[(0,H.jsx)(Dn,{children:(0,H.jsxs)("div",{children:[(0,H.jsx)(Wt,{success:t,fail:!!o}),(0,H.jsx)(b,{style:{width:"38px",height:"38px"}})]})}),(0,H.jsxs)(Un,{children:[(0,H.jsx)("h3",{children:$}),(0,H.jsx)("p",{children:V})]}),(0,H.jsx)(Fn,{onClick:()=>{R(h+1),r(void 0)},visible:!t&&(o==null?void 0:o.retryable)&&h<_o,disabled:!t&&(!(o!=null&&o.retryable)||h>=_o),children:"Retry"})]})]})},Nn=lt.default.div`
941
+ `;var Te=require("react");var lt=C(require("styled-components"));var H=require("react/jsx-runtime"),_o=2,ri={metamask:{name:"MetaMask",component:Re},coinbase_wallet:{name:"Coinbase Wallet",component:Le},wallet_connect:{name:"WalletConnect",component:Et}},ii=()=>{var ge;let[t,e]=(0,Te.useState)(!1),[o,r]=(0,Te.useState)(void 0),{navigateBack:i}=y(),{getAuthMeta:n,closePrivyModal:s,loginWithWallet:u,handleLoginError:f}=M(),[h,R]=(0,Te.useState)(0),{user:L}=N(),[E,k]=(0,Te.useState)((L==null?void 0:L.linkedAccounts.length)||0);(0,Te.useEffect)(()=>{r(void 0),u().then(()=>e(!0)).catch(v=>{v instanceof X?console.error(v.cause):console.error(v);let j=(v==null?void 0:v.status)===401&&(v==null?void 0:v.message)==="User is not allowed to login to this app.";(v==null?void 0:v.status)===422?r(Xe.ERROR_USER_EXISTS):j?r(Xe.ERROR_WALLET_NOT_ALLOWED):v instanceof He&&!v.details.default?r(v.details):v instanceof Ve?r(Xe.ERROR_TIMED_OUT):r(Xe.ERROR_WALLET_CONNECTION),f(j)})},[h]),(0,Te.useEffect)(()=>{if(t){let v=setTimeout(s,De);return()=>clearTimeout(v)}},[L]);let _=((ge=n())==null?void 0:ge.wallet)||"metamask",d=ri[_].name,b=ri[_].component,$=t?`Successfully connected with ${d}`:o?o.message:`Waiting for ${d}`,V="";if(t){let v=(L==null?void 0:L.linkedAccounts.length)||0;E===v?V="Wallet was already linked.":V="You\u2019re good to go!"}else if(h>=_o&&o)V="Unable to connect wallet";else if(o)V=o.detail;else switch(V="Don\u2019t see your wallet modal? Check your other browser windows.",_){case"wallet_connect":V="Open your mobile wallet app to continue";break;case"coinbase_wallet":vt()||(V="Open the Coinbase app on your phone to continue.");break;default:V="Don\u2019t see your wallet modal? Check your other browser windows."}return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(S,{backFn:i}),(0,H.jsxs)(Nn,{children:[(0,H.jsx)(Dn,{children:(0,H.jsxs)("div",{children:[(0,H.jsx)(Wt,{success:t,fail:!!o}),(0,H.jsx)(b,{style:{width:"38px",height:"38px"}})]})}),(0,H.jsxs)(Un,{children:[(0,H.jsx)("h3",{children:$}),(0,H.jsx)("p",{children:V})]}),(0,H.jsx)(Fn,{onClick:()=>{R(h+1),r(void 0)},visible:!t&&(o==null?void 0:o.retryable)&&h<_o,disabled:!t&&(!(o!=null&&o.retryable)||h>=_o),children:"Retry"})]})]})},Nn=lt.default.div`
942
942
  display: flex;
943
943
  flex-direction: column;
944
944
  align-items: center;
@@ -985,7 +985,7 @@ Resources:
985
985
  opacity: ${t=>t.visible?"1":"0"};
986
986
  transition: opacity 200ms;
987
987
  }
988
- `;var de=require("react/jsx-runtime"),ni=()=>{let{navigateBack:t}=y();return(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)(P,{backFn:t},"header"),(0,de.jsx)(Eo,{}),(0,de.jsxs)(me,{children:[(0,de.jsx)("span",{children:"Still not sure? "}),(0,de.jsx)("a",{target:"_blank",href:"https://join.tell.ie/blog/explaining-web3-wallets",children:"Learn more"})]})]})};var ce=require("react/jsx-runtime"),si=()=>{let{navigateBack:t}=y();return(0,ce.jsxs)(ce.Fragment,{children:[(0,ce.jsx)(P,{backFn:t},"header"),(0,ce.jsx)(ko,{}),(0,ce.jsxs)(me,{children:[(0,ce.jsx)("span",{children:"Still not sure? "}),(0,ce.jsx)("a",{target:"_blank",href:"https://join.tell.ie/blog/explaining-web3-wallets",children:"Learn more"})]})]})};var ai=C(require("styled-components"));var di=require("react/jsx-runtime"),li=t=>{let e=t.accentColor||"#696ffd";return(0,di.jsx)(Gn,{accentColor:e,children:t.children})},Gn=ai.default.div`
988
+ `;var de=require("react/jsx-runtime"),ni=()=>{let{navigateBack:t}=y();return(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)(S,{backFn:t},"header"),(0,de.jsx)(Eo,{}),(0,de.jsxs)(me,{children:[(0,de.jsx)("span",{children:"Still not sure? "}),(0,de.jsx)("a",{target:"_blank",href:"https://join.tell.ie/blog/explaining-web3-wallets",children:"Learn more"})]})]})};var ce=require("react/jsx-runtime"),si=()=>{let{navigateBack:t}=y();return(0,ce.jsxs)(ce.Fragment,{children:[(0,ce.jsx)(S,{backFn:t},"header"),(0,ce.jsx)(ko,{}),(0,ce.jsxs)(me,{children:[(0,ce.jsx)("span",{children:"Still not sure? "}),(0,ce.jsx)("a",{target:"_blank",href:"https://join.tell.ie/blog/explaining-web3-wallets",children:"Learn more"})]})]})};var ai=C(require("styled-components"));var di=require("react/jsx-runtime"),li=t=>{let e=t.accentColor||"#696ffd";return(0,di.jsx)(Gn,{accentColor:e,children:t.children})},Gn=ai.default.div`
989
989
  /*! Modified from https://unpkg.com/tailwindcss@3.2.3/src/css/preflight.css */
990
990
 
991
991
  *,
@@ -1283,7 +1283,7 @@ Resources:
1283
1283
  display: none;
1284
1284
  }
1285
1285
  }
1286
- `;var gi=require("react");var Je=require("react");var dt=C(require("styled-components"));var B=require("react/jsx-runtime"),ci={google:{name:"Google",component:Mt},discord:{name:"Discord",component:Tt},github:{name:"Github",component:It},twitter:{name:"Twitter",component:St}},Vn=t=>t.charAt(0).toUpperCase()+t.slice(1),Po=()=>{let t=new URL(window.location.href);t.searchParams.delete("privy_oauth_code"),t.searchParams.delete("privy_oauth_provider"),t.searchParams.delete("privy_oauth_state"),window.history.pushState({},"",t)},ui=()=>{var k;let[t,e]=(0,Je.useState)(!1),[o,r]=(0,Je.useState)(void 0),{getAuthMeta:i,initLoginWithOAuth:n,loginWithOAuth:s,closePrivyModal:u}=M(),{ready:f}=N(),h=((k=i())==null?void 0:k.provider)||"google",R=ci[h].name,L=ci[h].component;(0,Je.useEffect)(()=>{!f||s().then(()=>{Po(),e(!0)}).catch(d=>{let b={retryable:!1,message:"Authentication failed."};d.message.includes("Another user has already linked this")?b.detail="This account has already been linked to another user.":d.message==="Invalid code during oauth flow."?(b.retryable=!0,b.detail="Something went wrong. Try again."):d.message==="User denied confirmation during OAuth flow"&&(b.detail=`Retry and check ${Vn(h)} to finish connecting your account.`,b.retryable=!0),Po(),r(b)})},[f]),(0,Je.useEffect)(()=>{if(!t)return;let d=setTimeout(u,De);return()=>clearTimeout(d)},[t]);let T=t?`Successfully connected with ${R}`:o?o.message:`Verifying connection to ${R}`,E="";return t?E="You\u2019re good to go!":o?E=o.detail:E="Just a few moments more",(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(P,{}),(0,B.jsxs)(Hn,{children:[(0,B.jsx)(zn,{children:(0,B.jsxs)("div",{children:[(0,B.jsx)(Wt,{success:t,fail:!!o}),(0,B.jsx)(L,{style:{width:"38px",height:"38px"},logoFill:"primary"})]})}),(0,B.jsxs)(Bn,{children:[(0,B.jsx)("h3",{children:T}),(0,B.jsx)("p",{children:E})]}),(0,B.jsx)(jn,{onClick:()=>{Po(),n(h),r(void 0)},visible:!t&&(o==null?void 0:o.retryable),disabled:!t&&!(o!=null&&o.retryable),children:"Retry"})]})]})},Hn=dt.default.div`
1286
+ `;var gi=require("react");var Je=require("react");var dt=C(require("styled-components"));var B=require("react/jsx-runtime"),ci={google:{name:"Google",component:Mt},discord:{name:"Discord",component:Tt},github:{name:"Github",component:It},twitter:{name:"Twitter",component:St}},Vn=t=>t.charAt(0).toUpperCase()+t.slice(1),Po=()=>{let t=new URL(window.location.href);t.searchParams.delete("privy_oauth_code"),t.searchParams.delete("privy_oauth_provider"),t.searchParams.delete("privy_oauth_state"),window.history.pushState({},"",t)},ui=()=>{var _;let[t,e]=(0,Je.useState)(!1),[o,r]=(0,Je.useState)(void 0),{getAuthMeta:i,initLoginWithOAuth:n,loginWithOAuth:s,closePrivyModal:u}=M(),{ready:f}=N(),h=((_=i())==null?void 0:_.provider)||"google",R=ci[h].name,L=ci[h].component;(0,Je.useEffect)(()=>{!f||s().then(()=>{Po(),e(!0)}).catch(d=>{let b={retryable:!1,message:"Authentication failed."};d.message.includes("Another user has already linked this")?b.detail="This account has already been linked to another user.":d.message==="Invalid code during oauth flow."?(b.retryable=!0,b.detail="Something went wrong. Try again."):d.message==="User denied confirmation during OAuth flow"&&(b.detail=`Retry and check ${Vn(h)} to finish connecting your account.`,b.retryable=!0),Po(),r(b)})},[f]),(0,Je.useEffect)(()=>{if(!t)return;let d=setTimeout(u,De);return()=>clearTimeout(d)},[t]);let E=t?`Successfully connected with ${R}`:o?o.message:`Verifying connection to ${R}`,k="";return t?k="You\u2019re good to go!":o?k=o.detail:k="Just a few moments more",(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(S,{}),(0,B.jsxs)(Hn,{children:[(0,B.jsx)(zn,{children:(0,B.jsxs)("div",{children:[(0,B.jsx)(Wt,{success:t,fail:!!o}),(0,B.jsx)(L,{style:{width:"38px",height:"38px"},logoFill:"primary"})]})}),(0,B.jsxs)(Bn,{children:[(0,B.jsx)("h3",{children:E}),(0,B.jsx)("p",{children:k})]}),(0,B.jsx)(jn,{onClick:()=>{Po(),n(h),r(void 0)},visible:!t&&(o==null?void 0:o.retryable),disabled:!t&&!(o!=null&&o.retryable),children:"Retry"})]})]})},Hn=dt.default.div`
1287
1287
  display: flex;
1288
1288
  flex-direction: column;
1289
1289
  align-items: center;
@@ -1330,7 +1330,7 @@ Resources:
1330
1330
  opacity: ${t=>t.visible?"1":"0"};
1331
1331
  transition: opacity 200ms;
1332
1332
  }
1333
- `;var te=require("react/jsx-runtime"),pi=()=>{let{app:t}=y();return(0,te.jsxs)(te.Fragment,{children:[(0,te.jsx)(P,{},"header"),(0,te.jsx)(Ye,{title:"Connect your email",description:`Add your email to your ${t==null?void 0:t.name} account`,icon:(0,te.jsx)(Rt,{})}),(0,te.jsx)(Ae,{children:(0,te.jsx)(Nt,{stacked:!0})}),(0,te.jsx)(le,{protectedByPrivy:!0})]})};var oe=require("react/jsx-runtime"),hi=()=>{let{app:t}=y();return(0,oe.jsxs)(oe.Fragment,{children:[(0,oe.jsx)(P,{},"header"),(0,oe.jsx)(Ye,{title:"Connect your phone",description:`Add your number to your ${t==null?void 0:t.name} account`,icon:(0,oe.jsx)(Ut,{})}),(0,oe.jsx)(Ae,{children:(0,oe.jsx)(Dt,{stacked:!0})}),(0,oe.jsx)(le,{protectedByPrivy:!0})]})};var re=require("react/jsx-runtime"),mi=()=>{let{app:t}=y();return(0,re.jsxs)(re.Fragment,{children:[(0,re.jsx)(P,{},"header"),(0,re.jsx)(Nr,{title:"Connect your wallet",description:`Link a wallet to your ${t==null?void 0:t.name} account`}),(0,re.jsxs)(Ae,{children:[(0,re.jsx)(_t,{}),(0,re.jsx)(Pt,{})]}),(0,re.jsx)(le,{protectedByPrivy:!0})]})};var S=require("react/jsx-runtime"),Zn=()=>{let{ready:t}=N(),{isLinking:e}=M(),{ready:o,currentScreen:r}=y(),i;return["AWAITING_CONNECTION","AWAITING_OAUTH_SCREEN"].includes(r)?i="compact":"WALLET_EDUCATION"===r?i="full":e?i="medium":i="full",!t||!o?(0,S.jsxs)(Gt,{"data-height":i,children:[(0,S.jsx)(P,{}),(0,S.jsx)(qn,{children:(0,S.jsx)(ke,{})}),(0,S.jsx)(me,{})]}):(0,S.jsxs)(Gt,{"data-height":i,children:[r==="LANDING"&&(0,S.jsx)(Rr,{}),r==="AWAITING_PASSWORDLESS_CODE"&&(0,S.jsx)(Fr,{}),r==="WALLET_EDUCATION"&&(0,S.jsx)(Xr,{}),r==="AWAITING_CONNECTION"&&(0,S.jsx)(ii,{}),r==="AWAITING_OAUTH_SCREEN"&&(0,S.jsx)(ui,{}),r==="INSTALL_METAMASK_SCREEN"&&(0,S.jsx)(ni,{}),r==="INSTALL_COINBASE_WALLET_SCREEN"&&(0,S.jsx)(si,{}),r==="LINK_EMAIL_SCREEN"&&(0,S.jsx)(pi,{}),r==="LINK_PHONE_SCREEN"&&(0,S.jsx)(hi,{}),r==="LINK_WALLET_SCREEN"&&(0,S.jsx)(mi,{})]})},wi=()=>{let{app:t}=y();return fi.default.createPortal((0,S.jsx)(Kn,{id:"privy-dialog",children:(0,S.jsx)(li,{accentColor:t==null?void 0:t.accentColor,children:(0,S.jsx)(Zn,{})})}),document.body)},$n=({children:t,...e})=>((0,gi.useEffect)(()=>{var r;(r=document==null?void 0:document.activeElement)==null||r.blur();let o=(document==null?void 0:document.getElementById("root"))||(document==null?void 0:document.getElementById("__next"));if(!!o)return o.setAttribute("inert","true"),()=>{let i=(document==null?void 0:document.getElementById("root"))||(document==null?void 0:document.getElementById("__next"));!i||i.removeAttribute("inert")}},[e.open,e.onClose]),(0,S.jsx)("dialog",{open:!0,role:"dialog",...e,children:t})),Kn=(0,zt.default)($n)`
1333
+ `;var te=require("react/jsx-runtime"),pi=()=>{let{app:t}=y();return(0,te.jsxs)(te.Fragment,{children:[(0,te.jsx)(S,{},"header"),(0,te.jsx)(Ye,{title:"Connect your email",description:`Add your email to your ${t==null?void 0:t.name} account`,icon:(0,te.jsx)(Rt,{})}),(0,te.jsx)(Ae,{children:(0,te.jsx)(Nt,{stacked:!0})}),(0,te.jsx)(le,{protectedByPrivy:!0})]})};var oe=require("react/jsx-runtime"),hi=()=>{let{app:t}=y();return(0,oe.jsxs)(oe.Fragment,{children:[(0,oe.jsx)(S,{},"header"),(0,oe.jsx)(Ye,{title:"Connect your phone",description:`Add your number to your ${t==null?void 0:t.name} account`,icon:(0,oe.jsx)(Ut,{})}),(0,oe.jsx)(Ae,{children:(0,oe.jsx)(Dt,{stacked:!0})}),(0,oe.jsx)(le,{protectedByPrivy:!0})]})};var re=require("react/jsx-runtime"),mi=()=>{let{app:t}=y();return(0,re.jsxs)(re.Fragment,{children:[(0,re.jsx)(S,{},"header"),(0,re.jsx)(Nr,{title:"Connect your wallet",description:`Link a wallet to your ${t==null?void 0:t.name} account`}),(0,re.jsxs)(Ae,{children:[(0,re.jsx)(_t,{}),(0,re.jsx)(Pt,{})]}),(0,re.jsx)(le,{protectedByPrivy:!0})]})};var T=require("react/jsx-runtime"),Zn=()=>{let{ready:t}=N(),{isLinking:e}=M(),{ready:o,currentScreen:r}=y(),i;return["AWAITING_CONNECTION","AWAITING_OAUTH_SCREEN"].includes(r)?i="compact":"WALLET_EDUCATION"===r?i="full":e?i="medium":i="full",!t||!o?(0,T.jsxs)(Gt,{"data-height":i,children:[(0,T.jsx)(S,{}),(0,T.jsx)(qn,{children:(0,T.jsx)(ke,{})}),(0,T.jsx)(me,{})]}):(0,T.jsxs)(Gt,{"data-height":i,children:[r==="LANDING"&&(0,T.jsx)(Rr,{}),r==="AWAITING_PASSWORDLESS_CODE"&&(0,T.jsx)(Fr,{}),r==="WALLET_EDUCATION"&&(0,T.jsx)(Xr,{}),r==="AWAITING_CONNECTION"&&(0,T.jsx)(ii,{}),r==="AWAITING_OAUTH_SCREEN"&&(0,T.jsx)(ui,{}),r==="INSTALL_METAMASK_SCREEN"&&(0,T.jsx)(ni,{}),r==="INSTALL_COINBASE_WALLET_SCREEN"&&(0,T.jsx)(si,{}),r==="LINK_EMAIL_SCREEN"&&(0,T.jsx)(pi,{}),r==="LINK_PHONE_SCREEN"&&(0,T.jsx)(hi,{}),r==="LINK_WALLET_SCREEN"&&(0,T.jsx)(mi,{})]})},wi=()=>{let{app:t}=y();return fi.default.createPortal((0,T.jsx)(Kn,{id:"privy-dialog",children:(0,T.jsx)(li,{accentColor:t==null?void 0:t.accentColor,children:(0,T.jsx)(Zn,{})})}),document.body)},$n=({children:t,...e})=>((0,gi.useEffect)(()=>{var r;(r=document==null?void 0:document.activeElement)==null||r.blur();let o=(document==null?void 0:document.getElementById("root"))||(document==null?void 0:document.getElementById("__next"));if(!!o)return o.setAttribute("inert","true"),()=>{let i=(document==null?void 0:document.getElementById("root"))||(document==null?void 0:document.getElementById("__next"));!i||i.removeAttribute("inert")}},[e.open,e.onClose]),(0,T.jsx)("dialog",{open:!0,role:"dialog",...e,children:t})),Kn=(0,zt.default)($n)`
1334
1334
  position: fixed;
1335
1335
  top: 0;
1336
1336
  left: 0;
@@ -1389,4 +1389,4 @@ Resources:
1389
1389
  align-items: center;
1390
1390
  justify-content: center;
1391
1391
  height: 100%;
1392
- `;var ue=require("react/jsx-runtime");function Yn(t){return typeof t=="string"&&t.length===25}var jt;function bi(){if(!jt){let t=_.get(Fe);return Promise.resolve(t||null)}return jt.getAccessToken()}var Ci=t=>{if(!Yn(t.appId))throw new p("Cannot initialize the Privy provider with an invalid Privy app ID");let[e,o]=(0,z.useState)(null);return(0,z.useEffect)(()=>{jt=new ze({appId:t.appId,apiURL:Oo}),o(jt)},[]),e===null?(0,ue.jsx)(ue.Fragment,{}):(0,ue.jsx)(Qn,{...t,client:e})},Jn=(t,e)=>{if(e)return{email:!1,sms:!1,wallet:!1,google:!1,twitter:!1,discord:!1,github:!1,[e]:!0};let o=!!(t!=null&&t.emailAuth),r=!!(t!=null&&t.smsAuth);return o&&r&&(console.warn("Enabling both email and SMS passwordless is not currently supported. Disabling SMS."),r=!1),{email:o,sms:r,wallet:!!(t!=null&&t.walletAuth),google:!!(t!=null&&t.googleOAuth),twitter:!!(t!=null&&t.twitterOAuth),discord:!!(t!=null&&t.discordOAuth),github:!!(t!=null&&t.githubOAuth)}},Qn=t=>{let e=t.client,[o,r]=(0,z.useState)(!1),[i,n]=(0,z.useState)(!1),[s,u]=(0,z.useState)(!1),[f,h]=(0,z.useState)(null),[R,L]=(0,z.useState)(!1),[T,E]=(0,z.useState)({accentColor:"#696ffd",theme:"System",showWalletLoginFirst:!0,emailAuth:!0,smsAuth:!1,walletAuth:!0,googleOAuth:!1,twitterOAuth:!1,discordOAuth:!1,githubOAuth:!1,termsAndConditionsUrl:null,privacyPolicyUrl:null}),[k,d]=(0,z.useState)(null),[b,$]=(0,z.useState)(!1);(0,z.useEffect)(()=>{async function a(){let c=await e.getAppSettings();E(c)}a()},[]);let V=Jn(T,k),ge=()=>{let a=new URLSearchParams(window.location.search),c=a.get("privy_oauth_code"),I=a.get("privy_oauth_state"),W=a.get("privy_oauth_provider");c&&I&&W&&(e.startAuthFlow(new je(W,c,I)),d(W),r(!0))};(0,z.useEffect)(()=>{async function a(){ge();let c=await e.getAuthenticatedUser();u(!!c),h(c),n(!0)}a()},[]),(0,z.useEffect)(()=>{i&&s&&f===null&&e.getAuthenticatedUser().then(h)},[i,s,f]);let v={ready:i,authenticated:s,user:f,walletConnector:e.connector,linkWallet:()=>{d("wallet"),$(!0),r(!0)},linkEmail:()=>{d("email"),$(!0),r(!0)},linkPhone:()=>{d("sms"),$(!0),r(!0)},linkGoogle:async()=>{await j.initLoginWithOAuth("google")},linkTwitter:async()=>{await j.initLoginWithOAuth("twitter")},linkDiscord:async()=>{await j.initLoginWithOAuth("discord")},linkGithub:async()=>{await j.initLoginWithOAuth("github")},login:()=>{if(i&&s){console.warn("Attempted to log in, but user is already logged in. Use a `link` helper instead.");return}r(!0)},logout:async()=>{await e.logout(),h(null),u(!1),d(null),$(!1),r(!1)},getAccessToken:()=>e.getAccessToken(),getEthereumProvider:()=>e.connector.getEthereumProvider(),getEthersProvider:()=>new yi.Web3Provider(new xe(e.connector.getEthereumProvider())),getWeb3jsProvider:()=>new Ct(e.connector.getEthereumProvider()),unlinkWallet:async a=>{let c=await e.unlinkWallet(a);return h(c),c},unlinkEmail:async a=>{let c=await e.unlinkEmail(a);return h(c),c},unlinkPhone:async a=>{let c=await e.unlinkPhone(a);return h(c),c},unlinkGoogle:async a=>{let c=await e.unlinkOAuth("google",a);return h(c),c},unlinkTwitter:async a=>{let c=await e.unlinkOAuth("twitter",a);return h(c),c},unlinkDiscord:async a=>{let c=await e.unlinkOAuth("discord",a);return h(c),c},unlinkGithub:async a=>{let c=await e.unlinkOAuth("github",a);return h(c),c},setActiveWallet:a=>{if(!f)return;let c=e.setActiveWallet(a,f);h(c)},forkSession:()=>e.forkSession()},j={isLinking:b,getAuthFlow:()=>e.authFlow,getAuthMeta:()=>{var a;return(a=e.authFlow)==null?void 0:a.meta},closePrivyModal:()=>{var a;i&&s&&f&&((a=t.onSuccess)==null||a.call(t,f,R)),e.authFlow=void 0,d(null),$(!1),L(!1),r(!1)},initLoginWithWallet:a=>{a||(a="metamask"),e.connector.walletType=a,e.startAuthFlow(new et(e.connector))},initLoginWithOAuth:async a=>{e.startAuthFlow(new je(a));let c=await e.authFlow.getAuthorizationUrl();c&&c.url&&window.location.assign(c.url)},loginWithOAuth:async()=>{if(!(e.authFlow instanceof je))throw new p("Must initialize OAuth flow before calling loginWithOAuth");let a,c;i&&s?a=await e.link():{user:a,isNewUser:c}=await e.authenticate(),h(a),L(c||!1),u(!0)},loginWithWallet:async()=>{if(!(e.authFlow instanceof et))throw new p("Must initialize SIWE flow first.");let a,c;b?(a=await e.link(),a&&(_.del(se),a=Qe(a))):{user:a,isNewUser:c}=await e.authenticate(),h(a||f||null),L(c||!1),u(!0)},loginWithEmail:async a=>{let c=new tt(a);e.startAuthFlow(c),await c.sendCodeEmail()},loginWithSms:async a=>{let c=new ot(a);e.startAuthFlow(c),await c.sendSmsCode()},resendEmailCode:async()=>{var a;await((a=e.authFlow)==null?void 0:a.sendCodeEmail())},resendSmsCode:async()=>{var a;await((a=e.authFlow)==null?void 0:a.sendSmsCode())},loginWithCode:async a=>{if(e.authFlow instanceof tt)e.authFlow.meta.emailCode=a.trim();else if(e.authFlow instanceof ot)e.authFlow.meta.smsCode=a.trim();else throw new p("Must initialize a passwordless code flow first");let c,I;b?c=await e.link():{user:c,isNewUser:I}=await e.authenticate(),h(c||f||null),L(I||!1),u(!0)},handleLoginError:async a=>{var c;e.authFlow=void 0,d(null),$(!1),L(!1),(c=t.onError)==null||c.call(t,a)}};return(0,ue.jsxs)(oo.Provider,{value:v,children:[t.children,(0,ue.jsx)(no.Provider,{value:j,children:(0,ue.jsx)(mr,{appSettings:T,options:V,visible:o,authenticated:s,children:o&&(0,ue.jsx)(wi,{})})})]})};0&&(module.exports={AsExternalProvider,PrivyClient,PrivyConnector,PrivyProvider,PrivyProxyProvider,VERSION,getAccessToken,usePrivy});
1392
+ `;var ue=require("react/jsx-runtime");function Yn(t){return typeof t=="string"&&t.length===25}var jt;function bi(){if(!jt){let t=P.get(Fe);return Promise.resolve(t||null)}return jt.getAccessToken()}var Ci=t=>{if(!Yn(t.appId))throw new p("Cannot initialize the Privy provider with an invalid Privy app ID");let[e,o]=(0,z.useState)(null);return(0,z.useEffect)(()=>{jt=new ze({appId:t.appId,apiURL:Oo}),o(jt)},[]),e===null?(0,ue.jsx)(ue.Fragment,{}):(0,ue.jsx)(Qn,{...t,client:e})},Jn=(t,e)=>{if(e)return{email:!1,sms:!1,wallet:!1,google:!1,twitter:!1,discord:!1,github:!1,[e]:!0};let o=!!(t!=null&&t.emailAuth),r=!!(t!=null&&t.smsAuth);return o&&r&&(console.warn("Enabling both email and SMS passwordless is not currently supported. Disabling SMS."),r=!1),{email:o,sms:r,wallet:!!(t!=null&&t.walletAuth),google:!!(t!=null&&t.googleOAuth),twitter:!!(t!=null&&t.twitterOAuth),discord:!!(t!=null&&t.discordOAuth),github:!!(t!=null&&t.githubOAuth)}},Qn=t=>{let e=t.client,[o,r]=(0,z.useState)(!1),[i,n]=(0,z.useState)(!1),[s,u]=(0,z.useState)(!1),[f,h]=(0,z.useState)(null),[R,L]=(0,z.useState)(!1),[E,k]=(0,z.useState)({accentColor:"#696ffd",theme:"System",showWalletLoginFirst:!0,emailAuth:!0,smsAuth:!1,walletAuth:!0,googleOAuth:!1,twitterOAuth:!1,discordOAuth:!1,githubOAuth:!1,termsAndConditionsUrl:null,privacyPolicyUrl:null}),[_,d]=(0,z.useState)(null),[b,$]=(0,z.useState)(!1);(0,z.useEffect)(()=>{async function a(){let c=await e.getAppSettings();k(c)}a()},[]);let V=Jn(E,_),ge=()=>{let a=new URLSearchParams(window.location.search),c=a.get("privy_oauth_code"),I=a.get("privy_oauth_state"),W=a.get("privy_oauth_provider");c&&I&&W&&(e.startAuthFlow(new je(W,c,I)),d(W),r(!0))};(0,z.useEffect)(()=>{async function a(){ge();let c=await e.getAuthenticatedUser();u(!!c),h(c),n(!0)}a()},[]),(0,z.useEffect)(()=>{i&&s&&f===null&&e.getAuthenticatedUser().then(h)},[i,s,f]);let v={ready:i,authenticated:s,user:f,walletConnector:e.connector,linkWallet:()=>{d("wallet"),$(!0),r(!0)},linkEmail:()=>{d("email"),$(!0),r(!0)},linkPhone:()=>{d("sms"),$(!0),r(!0)},linkGoogle:async()=>{await j.initLoginWithOAuth("google")},linkTwitter:async()=>{await j.initLoginWithOAuth("twitter")},linkDiscord:async()=>{await j.initLoginWithOAuth("discord")},linkGithub:async()=>{await j.initLoginWithOAuth("github")},login:()=>{if(i&&s){console.warn("Attempted to log in, but user is already logged in. Use a `link` helper instead.");return}r(!0)},logout:async()=>{await e.logout(),h(null),u(!1),d(null),$(!1),r(!1)},getAccessToken:()=>e.getAccessToken(),getEthereumProvider:()=>e.connector.getEthereumProvider(),getEthersProvider:()=>new yi.Web3Provider(new xe(e.connector.getEthereumProvider())),getWeb3jsProvider:()=>new Ct(e.connector.getEthereumProvider()),unlinkWallet:async a=>{let c=await e.unlinkWallet(a);return h(c),c},unlinkEmail:async a=>{let c=await e.unlinkEmail(a);return h(c),c},unlinkPhone:async a=>{let c=await e.unlinkPhone(a);return h(c),c},unlinkGoogle:async a=>{let c=await e.unlinkOAuth("google",a);return h(c),c},unlinkTwitter:async a=>{let c=await e.unlinkOAuth("twitter",a);return h(c),c},unlinkDiscord:async a=>{let c=await e.unlinkOAuth("discord",a);return h(c),c},unlinkGithub:async a=>{let c=await e.unlinkOAuth("github",a);return h(c),c},setActiveWallet:a=>{if(!f)return;let c=e.setActiveWallet(a,f);h(c)},forkSession:()=>e.forkSession()},j={isLinking:b,getAuthFlow:()=>e.authFlow,getAuthMeta:()=>{var a;return(a=e.authFlow)==null?void 0:a.meta},closePrivyModal:()=>{var a;i&&s&&f&&((a=t.onSuccess)==null||a.call(t,f,R)),e.authFlow=void 0,d(null),$(!1),L(!1),r(!1)},initLoginWithWallet:a=>{a||(a="metamask"),e.connector.walletType=a,e.startAuthFlow(new et(e.connector))},initLoginWithOAuth:async a=>{e.startAuthFlow(new je(a));let c=await e.authFlow.getAuthorizationUrl();c&&c.url&&window.location.assign(c.url)},loginWithOAuth:async()=>{if(!(e.authFlow instanceof je))throw new p("Must initialize OAuth flow before calling loginWithOAuth");let a,c;i&&s?a=await e.link():{user:a,isNewUser:c}=await e.authenticate(),h(a),L(c||!1),u(!0)},loginWithWallet:async()=>{if(!(e.authFlow instanceof et))throw new p("Must initialize SIWE flow first.");let a,c;b?(a=await e.link(),a&&(P.del(se),a=Qe(a))):{user:a,isNewUser:c}=await e.authenticate(),h(a||f||null),L(c||!1),u(!0)},loginWithEmail:async a=>{let c=new tt(a);e.startAuthFlow(c),await c.sendCodeEmail()},loginWithSms:async a=>{let c=new ot(a);e.startAuthFlow(c),await c.sendSmsCode()},resendEmailCode:async()=>{var a;await((a=e.authFlow)==null?void 0:a.sendCodeEmail())},resendSmsCode:async()=>{var a;await((a=e.authFlow)==null?void 0:a.sendSmsCode())},loginWithCode:async a=>{if(e.authFlow instanceof tt)e.authFlow.meta.emailCode=a.trim();else if(e.authFlow instanceof ot)e.authFlow.meta.smsCode=a.trim();else throw new p("Must initialize a passwordless code flow first");let c,I;b?c=await e.link():{user:c,isNewUser:I}=await e.authenticate(),h(c||f||null),L(I||!1),u(!0)},handleLoginError:async a=>{var c;e.authFlow=void 0,d(null),$(!1),L(!1),(c=t.onError)==null||c.call(t,a)}};return(0,ue.jsxs)(oo.Provider,{value:v,children:[t.children,(0,ue.jsx)(no.Provider,{value:j,children:(0,ue.jsx)(mr,{appSettings:E,options:V,visible:o,authenticated:s,children:o&&(0,ue.jsx)(wi,{})})})]})};0&&(module.exports={AsExternalProvider,PrivyClient,PrivyConnector,PrivyProvider,PrivyProxyProvider,VERSION,getAccessToken,usePrivy});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@privy-io/react-auth",
3
- "version": "1.12.0-beta.7",
3
+ "version": "1.12.0",
4
4
  "description": "React client for the Privy Auth API",
5
5
  "keywords": [
6
6
  "authentication",