@privy-io/react-auth 1.12.0-beta.4 → 1.12.0-beta.5

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/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var vi=Object.create;var ct=Object.defineProperty;var bi=Object.getOwnPropertyDescriptor;var xi=Object.getOwnPropertyNames;var Li=Object.getPrototypeOf,Ei=Object.prototype.hasOwnProperty;var Ai=(t,e)=>{for(var o in e)ct(t,o,{get:e[o],enumerable:!0})},So=(t,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of xi(e))!Ei.call(t,i)&&i!==o&&ct(t,i,{get:()=>e[i],enumerable:!(r=bi(e,i))||r.enumerable});return t};var C=(t,e,o)=>(o=t!=null?vi(Li(t)):{},So(e||!t||!t.__esModule?ct(o,"default",{value:t,enumerable:!0}):o,t)),ki=t=>So(ct({},"__esModule",{value:!0}),t);var Yn={};Ai(Yn,{AsExternalProvider:()=>ve,PrivyClient:()=>ze,PrivyConnector:()=>Be,PrivyProvider:()=>yi,PrivyProxyProvider:()=>Ce,VERSION:()=>ht,getAccessToken:()=>wi,usePrivy:()=>O});module.exports=ki(Yn);var z=require("react");var gt=C(require("axios"));var To=C(require("axios")),Q=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}]`:""}`}},pt=class extends Q{constructor(o,r,i,n){super(i,n);this.type=o;this.status=r}},u=class extends Q{constructor(o,r){super(o,r);this.type="client_error"}};var $=class extends Q{constructor(o,r){super(o,r);this.type="connector_error"}},N=t=>{if(t instanceof Q)return t;if(!To.default.isAxiosError(t))return K(t);if(!t.response)return new pt("api_error",null,t.message,t);let{type:e,message:o,error:r}=t.response.data;return new pt(e||"ApiError",t.response.status,o||r,t)},K=t=>t instanceof Q?t:t instanceof Error?new u(t.message,t):new u(`Internal error: ${t}`);var Io="1.12.0-beta.4";var Ro="https://api.privy.io/v0",Mo=process.env.NEXT_PUBLIC_PRIVY_AUTH_URL||"https://auth.privy.io",ut="4df5e2316331463a9130964bd6078dfa",Wo=1e4,De=1400,No=365*24*60*60,ht=Io,Oo="ES256",Uo="privy.io",Fe="privy:token",mt="privy:refresh_token",ne="privy:active_wallet",ft="privy:wallet_type",Do="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 N(r)}}async post(e,o,r){try{return await gt.default.post(e,o,this.buildConfig(r))}catch(i){throw N(i)}}async delete(e,o){try{return await gt.default.delete(e,this.buildConfig(o))}catch(r){throw N(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 Ve=C(require("jose"));var we=class{static parse(e){try{return new we(e)}catch{return null}}constructor(e){this.value=e,this._decoded=Ve.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 Ve.importSPKI(e,Oo);try{return await Ve.jwtVerify(this.value,i,{issuer:Uo,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 Kt=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]}},qt=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 Pi(){return typeof window<"u"&&window.localStorage?new qt:new Kt}var _=Pi();function Se(t){return new Date(t*1e3)}function Si(t){return t.map(e=>{switch(e.type){case"wallet":return{address:e.address,type:e.type,verifiedAt:Se(e.verified_at),chainType:e.chain_type};case"email":return{address:e.address,type:e.type,verifiedAt:Se(e.verified_at)};case"phone":return{number:e.phoneNumber,type:e.type,verifiedAt:Se(e.verified_at)};case"google_oauth":return{subject:e.subject,email:e.email,name:e.name,type:e.type,verifiedAt:Se(e.verified_at)};case"twitter_oauth":return{subject:e.subject,username:e.username,name:e.name,type:e.type,verifiedAt:Se(e.verified_at)};case"discord_oauth":return{subject:e.subject,username:e.username,email:e.email,type:e.type,verifiedAt:Se(e.verified_at)};default:throw new u("Unrecognized account type")}})}function Ti(t,e){return e.find(o=>o.type==="wallet"&&o.address===t)}function Te(t,e){return t.sort((o,r)=>r.verifiedAt.getTime()-o.verifiedAt.getTime()),t.find(o=>o.type===e)}function Je(t){let e=t.linkedAccounts.map(s=>s.type==="wallet"?s.address:null),r=_.get(ne);if(!r||!e.includes(r)){_.del(ne);let s=Te(t.linkedAccounts,"wallet");s&&(r=s.address,_.put(ne,r))}let i=Ti(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 ue(t){if(!t)return null;let e=Si(t.linked_accounts),o=Te(e,"wallet"),r=Te(e,"email"),i=Te(e,"phone"),n=Te(e,"google_oauth"),s=Te(e,"twitter_oauth"),p=Te(e,"discord_oauth"),w={id:t.id,createdAt:Se(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:p&&{subject:p.subject,username:p.username,email:p.email}};return Je(w)}var Fo=()=>"/api/v1/sessions",Vo=()=>"/api/v1/sessions/logout",Go=()=>"/api/v1/sessions/fork",Ho=()=>"/api/v1/siwe/init",Bo=()=>"/api/v1/siwe/authenticate",zo=()=>"/api/v1/siwe/link",Zo=()=>"/api/v1/passwordless/init",jo=()=>"/api/v1/passwordless/authenticate",$o=()=>"/api/v1/passwordless/link",Ko=()=>"/api/v1/passwordless_sms/init",qo=()=>"/api/v1/passwordless_sms/authenticate",Yo=()=>"/api/v1/passwordless_sms/link",Jo=()=>"/api/v1/oauth/init",Qo=()=>"/api/v1/oauth/authenticate",Xo=()=>"/api/v1/oauth/link",er=()=>"/api/v1/siwe/unlink",tr=()=>"/api/v1/passwordless/unlink",or=()=>"/api/v1/passwordless_sms/unlink",rr=()=>"/api/v1/oauth/unlink";var Ii=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(Ii)}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:ue(i),isNewUser:n}}catch(o){throw console.warn("Error authenticating session"),K(o)}}async _link(e){try{let o=await e.link();return ue(o)}catch(o){throw console.warn("Error linking account"),K(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(Fo(),{refresh_token:o});return this.storeToken(r.data.token),this.storeRefreshToken(r.data.refresh_token),ue(r.data.user)}catch(r){throw K(r)}}async _destroy(){var e;try{await((e=this.api)==null?void 0:e.post(Vo(),{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(Go(),{refresh_token:e});return this.storeToken(o.data.token),this.storeRefreshToken(o.data.refresh_token),o.data.new_session_refresh_token}catch(o){throw K(o)}}destroyLocalState(){this.storeToken(null),this.storeRefreshToken(null),_.del(ne)}storeToken(e){typeof e=="string"?_.put(Fe,e):_.del(Fe)}storeRefreshToken(e){typeof e=="string"?_.put(mt,e):_.del(mt)}};var sr=require("@ethersproject/address"),Qt=C(require("@walletconnect/web3-provider"));var ir=require("@ethersproject/logger");var Ge=class extends ${constructor(){super("Wallet timeout");this.type="wallet_error"}},Ct=t=>{if(t instanceof $)return t;if((t==null?void 0:t.code)&&(t==null?void 0:t.reason)){let e=new He(t);return t.code===ir.ErrorCode.ACTION_REJECTED&&(e.details=Ie.E4001_USER_REJECTED_REQUEST),e}return t!=null&&t.code?new He(t):new $("Unknown connector error",t)},Yt=class extends Q{constructor(o,r,i){super(o);this.type="provider_error";this.code=r,this.data=i}},He=class extends Yt{constructor(o){var n,s,p;let r=o;super(r.message,r.code,r.data);let i=Object.values(Ie).find(w=>w.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:(p=r.message)!=null&&p.includes("Already processing")&&r.message.includes("eth_requestAccounts")&&(this.details=Ie.E32002_WALLET_LOCKED))}},Ri={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}},Mi={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}},Wi={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},...Wi,...Mi},Qe={...Ri,...Ie};var Ni=12e4,Jt=(t=new Ge,e=Ni)=>new Promise((o,r)=>setTimeout(()=>{r(t)},e)),Ce=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 $(`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 Ct(o)})}},ve=class extends Ce{constructor(o){super(o)}},vt=class extends Ce{constructor(e){super(e)}sendAsync(e,o){throw new Error("sendAsync is no longer supported by EIP-1193. Use the request method instead.")}};var ar=require("@ethersproject/providers");var nr=["metamask","coinbase_wallet","wallet_connect"];var lr=C(require("@coinbase/wallet-sdk")),Oi=()=>{let t=`https://mainnet.infura.io/v3/${ut}`,e=1;return new lr.default({appName:"Privy",darkMode:!1,headlessMode:!1}).makeWeb3Provider(t,e)},Xt=()=>{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},bt=()=>{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,p)=>`${r} wants you to sign in with your Ethereum account:
1
+ "use strict";var vi=Object.create;var ct=Object.defineProperty;var bi=Object.getOwnPropertyDescriptor;var xi=Object.getOwnPropertyNames;var Li=Object.getPrototypeOf,Ei=Object.prototype.hasOwnProperty;var Ai=(t,e)=>{for(var o in e)ct(t,o,{get:e[o],enumerable:!0})},So=(t,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of xi(e))!Ei.call(t,i)&&i!==o&&ct(t,i,{get:()=>e[i],enumerable:!(r=bi(e,i))||r.enumerable});return t};var C=(t,e,o)=>(o=t!=null?vi(Li(t)):{},So(e||!t||!t.__esModule?ct(o,"default",{value:t,enumerable:!0}):o,t)),ki=t=>So(ct({},"__esModule",{value:!0}),t);var Yn={};Ai(Yn,{AsExternalProvider:()=>ve,PrivyClient:()=>ze,PrivyConnector:()=>Be,PrivyProvider:()=>yi,PrivyProxyProvider:()=>Ce,VERSION:()=>ht,getAccessToken:()=>wi,usePrivy:()=>O});module.exports=ki(Yn);var z=require("react");var gt=C(require("axios"));var To=C(require("axios")),Q=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}]`:""}`}},pt=class extends Q{constructor(o,r,i,n){super(i,n);this.type=o;this.status=r}},u=class extends Q{constructor(o,r){super(o,r);this.type="client_error"}};var $=class extends Q{constructor(o,r){super(o,r);this.type="connector_error"}},N=t=>{if(t instanceof Q)return t;if(!To.default.isAxiosError(t))return K(t);if(!t.response)return new pt("api_error",null,t.message,t);let{type:e,message:o,error:r}=t.response.data;return new pt(e||"ApiError",t.response.status,o||r,t)},K=t=>t instanceof Q?t:t instanceof Error?new u(t.message,t):new u(`Internal error: ${t}`);var Io="1.12.0-beta.5";var Ro="https://api.privy.io/v0",Mo=process.env.NEXT_PUBLIC_PRIVY_AUTH_URL||"https://auth.privy.io",ut="4df5e2316331463a9130964bd6078dfa",Wo=1e4,De=1400,No=365*24*60*60,ht=Io,Oo="ES256",Uo="privy.io",Fe="privy:token",mt="privy:refresh_token",ne="privy:active_wallet",ft="privy:wallet_type",Do="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 N(r)}}async post(e,o,r){try{return await gt.default.post(e,o,this.buildConfig(r))}catch(i){throw N(i)}}async delete(e,o){try{return await gt.default.delete(e,this.buildConfig(o))}catch(r){throw N(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 Ve=C(require("jose"));var we=class{static parse(e){try{return new we(e)}catch{return null}}constructor(e){this.value=e,this._decoded=Ve.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 Ve.importSPKI(e,Oo);try{return await Ve.jwtVerify(this.value,i,{issuer:Uo,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 Kt=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]}},qt=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 Pi(){return typeof window<"u"&&window.localStorage?new qt:new Kt}var _=Pi();function Se(t){return new Date(t*1e3)}function Si(t){return t.map(e=>{switch(e.type){case"wallet":return{address:e.address,type:e.type,verifiedAt:Se(e.verified_at),chainType:e.chain_type};case"email":return{address:e.address,type:e.type,verifiedAt:Se(e.verified_at)};case"phone":return{number:e.phoneNumber,type:e.type,verifiedAt:Se(e.verified_at)};case"google_oauth":return{subject:e.subject,email:e.email,name:e.name,type:e.type,verifiedAt:Se(e.verified_at)};case"twitter_oauth":return{subject:e.subject,username:e.username,name:e.name,type:e.type,verifiedAt:Se(e.verified_at)};case"discord_oauth":return{subject:e.subject,username:e.username,email:e.email,type:e.type,verifiedAt:Se(e.verified_at)};default:throw new u("Unrecognized account type")}})}function Ti(t,e){return e.find(o=>o.type==="wallet"&&o.address===t)}function Te(t,e){return t.sort((o,r)=>r.verifiedAt.getTime()-o.verifiedAt.getTime()),t.find(o=>o.type===e)}function Je(t){let e=t.linkedAccounts.map(s=>s.type==="wallet"?s.address:null),r=_.get(ne);if(!r||!e.includes(r)){_.del(ne);let s=Te(t.linkedAccounts,"wallet");s&&(r=s.address,_.put(ne,r))}let i=Ti(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 ue(t){if(!t)return null;let e=Si(t.linked_accounts),o=Te(e,"wallet"),r=Te(e,"email"),i=Te(e,"phone"),n=Te(e,"google_oauth"),s=Te(e,"twitter_oauth"),p=Te(e,"discord_oauth"),w={id:t.id,createdAt:Se(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:p&&{subject:p.subject,username:p.username,email:p.email}};return Je(w)}var Fo=()=>"/api/v1/sessions",Vo=()=>"/api/v1/sessions/logout",Go=()=>"/api/v1/sessions/fork",Ho=()=>"/api/v1/siwe/init",Bo=()=>"/api/v1/siwe/authenticate",zo=()=>"/api/v1/siwe/link",Zo=()=>"/api/v1/passwordless/init",jo=()=>"/api/v1/passwordless/authenticate",$o=()=>"/api/v1/passwordless/link",Ko=()=>"/api/v1/passwordless_sms/init",qo=()=>"/api/v1/passwordless_sms/authenticate",Yo=()=>"/api/v1/passwordless_sms/link",Jo=()=>"/api/v1/oauth/init",Qo=()=>"/api/v1/oauth/authenticate",Xo=()=>"/api/v1/oauth/link",er=()=>"/api/v1/siwe/unlink",tr=()=>"/api/v1/passwordless/unlink",or=()=>"/api/v1/passwordless_sms/unlink",rr=()=>"/api/v1/oauth/unlink";var Ii=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(Ii)}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:ue(i),isNewUser:n}}catch(o){throw console.warn("Error authenticating session"),K(o)}}async _link(e){try{let o=await e.link();return ue(o)}catch(o){throw console.warn("Error linking account"),K(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(Fo(),{refresh_token:o});return this.storeToken(r.data.token),this.storeRefreshToken(r.data.refresh_token),ue(r.data.user)}catch(r){throw K(r)}}async _destroy(){var e;try{await((e=this.api)==null?void 0:e.post(Vo(),{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(Go(),{refresh_token:e});return this.storeToken(o.data.token),this.storeRefreshToken(o.data.refresh_token),o.data.new_session_refresh_token}catch(o){throw K(o)}}destroyLocalState(){this.storeToken(null),this.storeRefreshToken(null),_.del(ne)}storeToken(e){typeof e=="string"?_.put(Fe,e):_.del(Fe)}storeRefreshToken(e){typeof e=="string"?_.put(mt,e):_.del(mt)}};var sr=require("@ethersproject/address"),Qt=C(require("@walletconnect/web3-provider"));var ir=require("@ethersproject/logger");var Ge=class extends ${constructor(){super("Wallet timeout");this.type="wallet_error"}},Ct=t=>{if(t instanceof $)return t;if((t==null?void 0:t.code)&&(t==null?void 0:t.reason)){let e=new He(t);return t.code===ir.ErrorCode.ACTION_REJECTED&&(e.details=Ie.E4001_USER_REJECTED_REQUEST),e}return t!=null&&t.code?new He(t):new $("Unknown connector error",t)},Yt=class extends Q{constructor(o,r,i){super(o);this.type="provider_error";this.code=r,this.data=i}},He=class extends Yt{constructor(o){var n,s,p;let r=o;super(r.message,r.code,r.data);let i=Object.values(Ie).find(w=>w.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:(p=r.message)!=null&&p.includes("Already processing")&&r.message.includes("eth_requestAccounts")&&(this.details=Ie.E32002_WALLET_LOCKED))}},Ri={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}},Mi={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}},Wi={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},...Wi,...Mi},Qe={...Ri,...Ie};var Ni=12e4,Jt=(t=new Ge,e=Ni)=>new Promise((o,r)=>setTimeout(()=>{r(t)},e)),Ce=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 $(`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 Ct(o)})}},ve=class extends Ce{constructor(o){super(o)}},vt=class extends Ce{constructor(e){super(e)}sendAsync(e,o){throw new Error("sendAsync is no longer supported by EIP-1193. Use the request method instead.")}};var ar=require("@ethersproject/providers");var nr=["metamask","coinbase_wallet","wallet_connect"];var lr=C(require("@coinbase/wallet-sdk")),Oi=()=>{let t=`https://mainnet.infura.io/v3/${ut}`,e=1;return new lr.default({appName:"Privy",darkMode:!1,headlessMode:!1}).makeWeb3Provider(t,e)},Xt=()=>{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},bt=()=>{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,p)=>`${r} wants you to sign in with your Ethereum account:
2
2
  ${o}
3
3
 
4
4
  ${p}
@@ -290,7 +290,7 @@ Resources:
290
290
  border-color: var(--fail-light);
291
291
  border-bottom-color: var(--fail-light);
292
292
  }
293
- `;var Er=require("libphonenumber-js/min");var Ar=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,}))$/),kr=t=>(0,Er.isPossiblePhoneNumber)(String(t),"US"),Wt=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)}},_r=(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,je.useState)(""),[r,i]=(0,je.useState)(!1),[n,s]=(0,je.useState)(null),{authenticated:p}=O(),{loginWithEmail:w,handleLoginError:m}=R(),{navigate:M,options:L}=y(),T=L.wallet;(0,je.useEffect)(()=>{let a=document.querySelector("#email-input");a==null||a.focus()},[]);let A=Ar(e),k=()=>{i(!0),w(e).then(()=>{M("AWAITING_PASSWORDLESS_CODE")}).catch(a=>{let x=(a==null?void 0:a.status)===401&&(a==null?void 0:a.message)==="User is not allowed to login to this app.";(a==null?void 0:a.status)===422?s(a.message):s(x?"You don't have access to this app":"Issue submitting email"),i(!1),m(x)})};return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(Ki,{stacked:t.stacked,children:[(0,F.jsxs)(Ji,{standalone:t.stacked,children:[(0,F.jsx)(Rt,{}),(0,F.jsx)("input",{id:"email-input",type:"email",placeholder:"your@email.com",onChange:a=>o(a.target.value),onKeyUp:a=>{a.key==="Enter"&&k()},value:e,autoComplete:"email"})]}),t.stacked?null:(0,F.jsx)(qi,{disabled:r||!A,onClick:k,children:r?(0,F.jsx)(Ee,{color:"var(--disabled-fg)",style:{height:"1rem",width:"1rem",borderWidth:"2px"}}):"Submit"})]}),n||p||!T?(0,F.jsx)(Xi,{fail:!!n,children:n||""}):null,!n&&!p&&T?(0,F.jsx)(Qi,{children:(0,F.jsx)("span",{children:"Get started without a wallet."})}):null,t.stacked?(0,F.jsx)(Yi,{disabled:r||!A,onClick:k,children:r?(0,F.jsx)(Ee,{color:"var(--disabled-fg)",style:{height:"1rem",width:"1rem",borderWidth:"2px"}}):"Submit"}):null]})},Ki=Ne.default.div`
293
+ `;var Er=require("libphonenumber-js/min");var Ar=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,}))$/),kr=t=>(0,Er.isPossiblePhoneNumber)(String(t),"US"),Wt=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)}},_r=(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,je.useState)(""),[r,i]=(0,je.useState)(!1),[n,s]=(0,je.useState)(null),{authenticated:p}=O(),{loginWithEmail:w,handleLoginError:m}=R(),{navigate:M,options:x}=y(),T=x.wallet;(0,je.useEffect)(()=>{let a=document.querySelector("#email-input");a==null||a.focus()},[]);let A=Ar(e),k=()=>{i(!0),w(e).then(()=>{M("AWAITING_PASSWORDLESS_CODE")}).catch(a=>{let L=(a==null?void 0:a.status)===401&&(a==null?void 0:a.message)==="User is not allowed to login to this app.";(a==null?void 0:a.status)===422?s(a.message):s(L?"You don't have access to this app":"Issue submitting email"),i(!1),m(L)})};return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(Ki,{stacked:t.stacked,children:[(0,F.jsxs)(Ji,{standalone:t.stacked,children:[(0,F.jsx)(Rt,{}),(0,F.jsx)("input",{id:"email-input",type:"email",placeholder:"your@email.com",onChange:a=>o(a.target.value),onKeyUp:a=>{a.key==="Enter"&&k()},value:e,autoComplete:"email"})]}),t.stacked?null:(0,F.jsx)(qi,{disabled:r||!A,onClick:k,children:r?(0,F.jsx)(Ee,{color:"var(--disabled-fg)",style:{height:"1rem",width:"1rem",borderWidth:"2px"}}):"Submit"})]}),n||p||!T?(0,F.jsx)(Xi,{fail:!!n,children:n||""}):null,!n&&!p&&T?(0,F.jsx)(Qi,{children:(0,F.jsx)("span",{children:"Get started without a wallet."})}):null,t.stacked?(0,F.jsx)(Yi,{disabled:r||!A,onClick:k,children:r?(0,F.jsx)(Ee,{color:"var(--disabled-fg)",style:{height:"1rem",width:"1rem",borderWidth:"2px"}}):"Submit"}):null]})},Ki=Ne.default.div`
294
294
  display: flex;
295
295
  border: 1px solid #d1d5db;
296
296
  width: 100%;
@@ -410,7 +410,7 @@ Resources:
410
410
  opacity: ${t=>t.success||t.fail?"1":"0"};
411
411
 
412
412
  transition: ${t=>t.fail?"":"all 150ms ease-in-out"};
413
- `;var $e=require("react"),Ae=C(require("styled-components"));var go=require("react/jsx-runtime"),Ot=({style:t,...e})=>(0,go.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,go.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 V=require("react/jsx-runtime"),Ut=t=>{let[e,o]=(0,$e.useState)(""),[r,i]=(0,$e.useState)(!1),[n,s]=(0,$e.useState)(null),{authenticated:p}=O(),{loginWithSms:w,handleLoginError:m}=R(),{navigate:M,options:L}=y(),T=L.wallet;(0,$e.useEffect)(()=>{let a=document.querySelector("#phone-number-input");a==null||a.focus()},[]);let A=kr(e),k=()=>{i(!0),w(e).then(()=>{M("AWAITING_PASSWORDLESS_CODE")}).catch(a=>{let x=(a==null?void 0:a.status)===401&&(a==null?void 0:a.message)==="User is not allowed to login to this app.";(a==null?void 0:a.status)===422?s(a.message):s(x?"You don't have access to this app":"Issue submitting phone number"),i(!1),m(x)})};return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(en,{stacked:t.stacked,children:[(0,V.jsxs)(rn,{standalone:t.stacked,children:[(0,V.jsx)(Ot,{}),(0,V.jsx)("input",{id:"phone-number-input",type:"tel",placeholder:"555 555 5555",onChange:a=>{o(a.target.value)},onKeyUp:a=>{a.key==="Enter"&&k()},value:e,autoComplete:"tel"})]}),t.stacked?null:(0,V.jsx)(tn,{disabled:r||!A,onClick:k,children:r?(0,V.jsx)(Pr,{color:"var(--disabled-fg)"}):"Submit"})]}),n||p||!T?(0,V.jsx)(sn,{fail:!!n,children:n||""}):null,!n&&!p&&T?(0,V.jsx)(nn,{children:(0,V.jsx)("span",{children:"Don\u2019t have a wallet? Start exploring with your phone or socials."})}):null,t.stacked?(0,V.jsx)(on,{disabled:r||!A,onClick:k,children:r?(0,V.jsx)(Pr,{color:"var(--disabled-fg)"}):"Submit"}):null]})},en=Ae.default.div`
413
+ `;var $e=require("react"),Ae=C(require("styled-components"));var go=require("react/jsx-runtime"),Ot=({style:t,...e})=>(0,go.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,go.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 V=require("react/jsx-runtime"),Ut=t=>{let[e,o]=(0,$e.useState)(""),[r,i]=(0,$e.useState)(!1),[n,s]=(0,$e.useState)(null),{authenticated:p}=O(),{loginWithSms:w,handleLoginError:m}=R(),{navigate:M,options:x}=y(),T=x.wallet;(0,$e.useEffect)(()=>{let a=document.querySelector("#phone-number-input");a==null||a.focus()},[]);let A=kr(e),k=()=>{i(!0),w(e).then(()=>{M("AWAITING_PASSWORDLESS_CODE")}).catch(a=>{let L=(a==null?void 0:a.status)===401&&(a==null?void 0:a.message)==="User is not allowed to login to this app.";(a==null?void 0:a.status)===422?s(a.message):s(L?"You don't have access to this app":"Issue submitting phone number"),i(!1),m(L)})};return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(en,{stacked:t.stacked,children:[(0,V.jsxs)(rn,{standalone:t.stacked,children:[(0,V.jsx)(Ot,{}),(0,V.jsx)("input",{id:"phone-number-input",type:"tel",placeholder:"555 555 5555",onChange:a=>{o(a.target.value)},onKeyUp:a=>{a.key==="Enter"&&k()},value:e,autoComplete:"tel"})]}),t.stacked?null:(0,V.jsx)(tn,{disabled:r||!A,onClick:k,children:r?(0,V.jsx)(Pr,{color:"var(--disabled-fg)"}):"Submit"})]}),n||p||!T?(0,V.jsx)(sn,{fail:!!n,children:n||""}):null,!n&&!p&&T?(0,V.jsx)(nn,{children:(0,V.jsx)("span",{children:"Don\u2019t have a wallet? Start exploring with your phone or socials."})}):null,t.stacked?(0,V.jsx)(on,{disabled:r||!A,onClick:k,children:r?(0,V.jsx)(Pr,{color:"var(--disabled-fg)"}):"Submit"}):null]})},en=Ae.default.div`
414
414
  display: flex;
415
415
  border: 1px solid #d1d5db;
416
416
  width: 100%;
@@ -535,7 +535,7 @@ Resources:
535
535
  width: 1rem;
536
536
  border-width: 2px;
537
537
  }
538
- `;var wo=require("react/jsx-runtime"),Sr=()=>{let{app:t}=y();return t!=null&&t.logoUrl?(0,wo.jsx)("div",{children:(0,wo.jsx)("img",{src:t.logoUrl,alt:`${t==null?void 0:t.name} logo`,style:{objectFit:"contain",width:"200px",height:"80px"}})}):null};var yo=require("react-device-detect"),h=require("react/jsx-runtime");var Ir=()=>{let{ready:t}=O(),{getAuthMeta:e,isLinking:o}=R(),{app:r,navigate:i,options:n}=y(),s=n.email,p=n.sms,w=n.wallet,m=n.google,M=n.twitter,L=n.discord,T=w&&(r==null?void 0:r.showWalletLoginFirst)?0:1,[A,k]=(0,Dt.useState)(T),a=e(),x=(a==null?void 0:a.authorizationCode)&&(a==null?void 0:a.stateCode)&&(a==null?void 0:a.provider);(0,Dt.useEffect)(()=>{x?i("AWAITING_OAUTH_SCREEN"):o&&s?i("LINK_EMAIL_SCREEN"):o&&p?i("LINK_PHONE_SCREEN"):o&&w&&i("LINK_WALLET_SCREEN")},[t]);let j=A==0,G=A==1,pe=()=>(0,h.jsx)(h.Fragment,{children:w&&(0,h.jsx)(an,{active:j,onClick:()=>k(0)})}),v=()=>(0,h.jsx)(h.Fragment,{children:(s||p)&&(0,h.jsx)(ln,{active:G,onClick:()=>k(1),email:s,sms:p,google:m,twitter:M,discord:L})});return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(P,{},"header"),(0,h.jsx)(pn,{walletOnly:!s&&!p&&!m&&!M&&!L,hasTerms:!!((r==null?void 0:r.privacyPolicyUrl)||(r==null?void 0:r.termsAndConditionsUrl)),children:(0,h.jsx)(Sr,{})}),(0,h.jsx)(xe,{children:r!=null&&r.showWalletLoginFirst?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(pe,{}),(0,h.jsx)(v,{})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(v,{}),(0,h.jsx)(pe,{})]})}),r&&(0,h.jsx)(Cr,{app:r}),(0,h.jsx)(ae,{protectedByPrivy:!0})]})};function an(t){return(0,h.jsxs)(Mr,{active:t.active,onClick:t.onClick,children:[(0,h.jsx)(Rr,{active:t.active,children:(0,h.jsx)("h4",{children:"Connect Wallet"})}),t.active&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(_t,{}),(0,h.jsx)(Pt,{})]})]})}function ln(t){let e=t.google||t.discord||t.twitter&&!yo.isMobile,o=t.email?"Email":"Phone";return(0,h.jsxs)(Mr,{active:t.active,onClick:t.onClick,children:[(0,h.jsx)(Rr,{active:t.active,children:(0,h.jsxs)("h4",{children:["Sign In with ",e?`${o} & Social`:o]})}),t.active&&t.email&&(0,h.jsx)(Nt,{}),t.active&&t.sms&&!t.email&&(0,h.jsx)(Ut,{}),t.active&&e&&(0,h.jsx)(dn,{google:t.google,twitter:t.twitter&&!yo.isMobile,discord:t.discord})]})}function dn(t){return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(cn,{children:[(0,h.jsx)(Tr,{}),(0,h.jsx)("p",{children:" Or "}),(0,h.jsx)(Tr,{})]}),(0,h.jsx)(br,{showGoogle:t.google,showDiscord:t.discord,showTwitter:t.twitter})]})}var Rr=Ke.default.div`
538
+ `;var wo=require("react/jsx-runtime"),Sr=()=>{let{app:t}=y();return t!=null&&t.logoUrl?(0,wo.jsx)("div",{children:(0,wo.jsx)("img",{src:t.logoUrl,alt:`${t==null?void 0:t.name} logo`,style:{objectFit:"contain",width:"200px",height:"80px"}})}):null};var yo=require("react-device-detect"),h=require("react/jsx-runtime");var Ir=()=>{let{ready:t}=O(),{getAuthMeta:e,isLinking:o}=R(),{app:r,navigate:i,options:n}=y(),s=n.email,p=n.sms,w=n.wallet,m=n.google,M=n.twitter,x=n.discord,T=w&&(r==null?void 0:r.showWalletLoginFirst)?0:1,[A,k]=(0,Dt.useState)(T),a=e(),L=(a==null?void 0:a.authorizationCode)&&(a==null?void 0:a.stateCode)&&(a==null?void 0:a.provider);(0,Dt.useEffect)(()=>{L?i("AWAITING_OAUTH_SCREEN"):o&&s?i("LINK_EMAIL_SCREEN"):o&&p?i("LINK_PHONE_SCREEN"):o&&w&&i("LINK_WALLET_SCREEN")},[t]);let j=A==0,G=A==1,pe=()=>(0,h.jsx)(h.Fragment,{children:w&&(0,h.jsx)(an,{active:j,onClick:()=>k(0)})}),v=()=>(0,h.jsx)(h.Fragment,{children:(s||p)&&(0,h.jsx)(ln,{active:G,onClick:()=>k(1),email:s,sms:p,google:m,twitter:M,discord:x})});return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(P,{},"header"),(0,h.jsx)(pn,{walletOnly:!s&&!p&&!m&&!M&&!x,hasTerms:!!((r==null?void 0:r.privacyPolicyUrl)||(r==null?void 0:r.termsAndConditionsUrl)),children:(0,h.jsx)(Sr,{})}),(0,h.jsx)(xe,{children:r!=null&&r.showWalletLoginFirst?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(pe,{}),(0,h.jsx)(v,{})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(v,{}),(0,h.jsx)(pe,{})]})}),r&&(0,h.jsx)(Cr,{app:r}),(0,h.jsx)(ae,{protectedByPrivy:!0})]})};function an(t){return(0,h.jsxs)(Mr,{active:t.active,onClick:t.onClick,children:[(0,h.jsx)(Rr,{active:t.active,children:(0,h.jsx)("h4",{children:"Connect Wallet"})}),t.active&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(_t,{}),(0,h.jsx)(Pt,{})]})]})}function ln(t){let e=t.google||t.discord||t.twitter&&!yo.isMobile,o=t.email?"Email":"Phone";return(0,h.jsxs)(Mr,{active:t.active,onClick:t.onClick,children:[(0,h.jsx)(Rr,{active:t.active,children:(0,h.jsxs)("h4",{children:["Sign In with ",e?`${o} & Social`:o]})}),t.active&&t.email&&(0,h.jsx)(Nt,{}),t.active&&t.sms&&!t.email&&(0,h.jsx)(Ut,{}),t.active&&e&&(0,h.jsx)(dn,{google:t.google,twitter:t.twitter&&!yo.isMobile,discord:t.discord})]})}function dn(t){return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(cn,{children:[(0,h.jsx)(Tr,{}),(0,h.jsx)("p",{children:" Or "}),(0,h.jsx)(Tr,{})]}),(0,h.jsx)(br,{showGoogle:t.google,showDiscord:t.discord,showTwitter:t.twitter})]})}var Rr=Ke.default.div`
539
539
  font-weight: ${t=>t.active?600:500};
540
540
  color: ${t=>t.active?"inherit":"#6b7280"};
541
541
  display: flex;
@@ -629,7 +629,7 @@ Resources:
629
629
  border-color: #e1e7ef;
630
630
  border-width: 1px;
631
631
  }
632
- `;var E=require("react/jsx-runtime"),Co=6,Or=new Array(Co).fill(""),mn=1400;var Ur=()=>{var oe,d,c;let{app:t}=y(),{closePrivyModal:e,resendEmailCode:o,resendSmsCode:r,getAuthMeta:i,loginWithCode:n}=R(),{authenticated:s,user:p}=O(),[w,m]=(0,ke.useState)(Or),[M,L]=(0,ke.useState)(!1),[T,A]=(0,ke.useState)(null),[k,a]=(0,ke.useState)(null),x=(oe=i())!=null&&oe.email?0:1;(0,ke.useEffect)(()=>{if(s&&M){let I=setTimeout(e,De);return()=>clearTimeout(I)}},[s,M,p]),(0,ke.useEffect)(()=>{if(T&&k===0){let I=setTimeout(()=>{m(Or),A(null);let W=document.querySelector("input[name=code-0]");W==null||W.focus()},mn);return()=>clearTimeout(I)}},[T]);let j=I=>{var Po;let W=I.currentTarget.value.replace(" ","");if(W==="")return;if(isNaN(Number(W))){A("Code should be numeric"),a(1);return}A(null),a(null);let re=Number((Po=I.currentTarget.name)==null?void 0:Po.charAt(5)),Zt=[...W||[""]].slice(0,Co-re),jt=[...w.slice(0,re),...Zt,...w.slice(re+Zt.length)];m(jt);let Ci=Zt.length,_o=Math.min(Math.max(re+Ci,0),Co-1);if(!isNaN(Number(I.currentTarget.value))){let ie=document.querySelector(`input[name=code-${_o}]`);ie==null||ie.focus()}if(jt.every(ie=>ie&&!isNaN(+ie))){let ie=document.querySelector(`input[name=code-${_o}]`);ie==null||ie.blur(),n(jt.join("")).then(()=>L(!0)).catch($t=>{($t==null?void 0:$t.status)===422?A("Invalid or expired verification code"):A("Issue verifying code"),a(0)})}I.preventDefault()},G=I=>{k===1&&(A(null),a(null));let W=[...w.slice(0,I),"",...w.slice(I+1)];if(m(W),I>0){let re=document.querySelector(`input[name=code-${I-1}]`);re==null||re.focus()}},pe=`Verify your ${x==0?"email":"phone"}`,v=x==0?`Please check ${(d=i())==null?void 0:d.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,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(P,{},"header"),(0,E.jsxs)(fn,{children:[(0,E.jsx)(Oe,{title:pe,description:v}),(0,E.jsxs)(vr,{children:[(0,E.jsxs)(gn,{children:[(0,E.jsx)(wn,{fail:!!T,success:M,children:(0,E.jsx)("span",{children:T||(M?"Success!":"")})}),(0,E.jsx)("div",{children:w.map((I,W)=>(0,E.jsx)("input",{name:`code-${W}`,type:"text",value:w[W],onChange:j,onKeyUp:re=>{re.key==="Backspace"&&G(W)},inputMode:"numeric",autoFocus:W===0,pattern:"[0-9]",className:`${M?"success":""} ${T?"fail":""}`,autoComplete:"one-time-code"},W))})]}),(0,E.jsx)(yn,{children:x==0?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)("span",{children:"Didn't get an email?"}),(0,E.jsx)("button",{onClick:o,children:"Resend Code"})]}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)("span",{children:"Didn't get a message?"}),(0,E.jsx)("button",{onClick:r,children:"Resend Code"})]})})]})]}),(0,E.jsx)(ae,{protectedByPrivy:!0})]})},fn=st.default.div`
632
+ `;var E=require("react/jsx-runtime"),Co=6,Or=new Array(Co).fill(""),mn=1400;var Ur=()=>{var oe,d,c;let{app:t}=y(),{closePrivyModal:e,resendEmailCode:o,resendSmsCode:r,getAuthMeta:i,loginWithCode:n}=R(),{authenticated:s,user:p}=O(),[w,m]=(0,ke.useState)(Or),[M,x]=(0,ke.useState)(!1),[T,A]=(0,ke.useState)(null),[k,a]=(0,ke.useState)(null),L=(oe=i())!=null&&oe.email?0:1;(0,ke.useEffect)(()=>{if(s&&M){let I=setTimeout(e,De);return()=>clearTimeout(I)}},[s,M,p]),(0,ke.useEffect)(()=>{if(T&&k===0){let I=setTimeout(()=>{m(Or),A(null);let W=document.querySelector("input[name=code-0]");W==null||W.focus()},mn);return()=>clearTimeout(I)}},[T]);let j=I=>{var Po;let W=I.currentTarget.value.replace(" ","");if(W==="")return;if(isNaN(Number(W))){A("Code should be numeric"),a(1);return}A(null),a(null);let re=Number((Po=I.currentTarget.name)==null?void 0:Po.charAt(5)),Zt=[...W||[""]].slice(0,Co-re),jt=[...w.slice(0,re),...Zt,...w.slice(re+Zt.length)];m(jt);let Ci=Zt.length,_o=Math.min(Math.max(re+Ci,0),Co-1);if(!isNaN(Number(I.currentTarget.value))){let ie=document.querySelector(`input[name=code-${_o}]`);ie==null||ie.focus()}if(jt.every(ie=>ie&&!isNaN(+ie))){let ie=document.querySelector(`input[name=code-${_o}]`);ie==null||ie.blur(),n(jt.join("")).then(()=>x(!0)).catch($t=>{($t==null?void 0:$t.status)===422?A("Invalid or expired verification code"):A("Issue verifying code"),a(0)})}I.preventDefault()},G=I=>{k===1&&(A(null),a(null));let W=[...w.slice(0,I),"",...w.slice(I+1)];if(m(W),I>0){let re=document.querySelector(`input[name=code-${I-1}]`);re==null||re.focus()}},pe=`Verify your ${L==0?"email":"phone"}`,v=L==0?`Please check ${(d=i())==null?void 0:d.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,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(P,{},"header"),(0,E.jsxs)(fn,{children:[(0,E.jsx)(Oe,{title:pe,description:v}),(0,E.jsxs)(vr,{children:[(0,E.jsxs)(gn,{children:[(0,E.jsx)(wn,{fail:!!T,success:M,children:(0,E.jsx)("span",{children:T||(M?"Success!":"")})}),(0,E.jsx)("div",{children:w.map((I,W)=>(0,E.jsx)("input",{name:`code-${W}`,type:"text",value:w[W],onChange:j,onKeyUp:re=>{re.key==="Backspace"&&G(W)},inputMode:"numeric",autoFocus:W===0,pattern:"[0-9]",className:`${M?"success":""} ${T?"fail":""}`,autoComplete:"one-time-code"},W))})]}),(0,E.jsx)(yn,{children:L==0?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)("span",{children:"Didn't get an email?"}),(0,E.jsx)("button",{onClick:o,children:"Resend Code"})]}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)("span",{children:"Didn't get a message?"}),(0,E.jsx)("button",{onClick:r,children:"Resend Code"})]})})]})]}),(0,E.jsx)(ae,{protectedByPrivy:!0})]})},fn=st.default.div`
633
633
  display: flex;
634
634
  flex-direction: column;
635
635
  align-items: flex-start;
@@ -926,7 +926,7 @@ Resources:
926
926
  `,Rn=J.default.div`
927
927
  display: flex;
928
928
  justify-content: center;
929
- `;var Pe=require("react");var lt=C(require("styled-components"));var H=require("react/jsx-runtime"),Ao=2,ti={metamask:{name:"MetaMask",component:Me},coinbase_wallet:{name:"Coinbase Wallet",component:be},wallet_connect:{name:"WalletConnect",component:At}},oi=()=>{var pe;let[t,e]=(0,Pe.useState)(!1),[o,r]=(0,Pe.useState)(void 0),{navigateBack:i}=y(),{getAuthMeta:n,closePrivyModal:s,loginWithWallet:p,handleLoginError:w}=R(),[m,M]=(0,Pe.useState)(0),{user:L}=O(),[T,A]=(0,Pe.useState)((L==null?void 0:L.linkedAccounts.length)||0);(0,Pe.useEffect)(()=>{r(void 0),p().then(()=>e(!0)).catch(v=>{v instanceof Q?console.error(v.cause):console.error(v);let oe=(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(Qe.ERROR_USER_EXISTS):oe?r(Qe.ERROR_WALLET_NOT_ALLOWED):v instanceof He&&!v.details.default?r(v.details):v instanceof Ge?r(Qe.ERROR_TIMED_OUT):r(Qe.ERROR_WALLET_CONNECTION),w(oe)})},[m]),(0,Pe.useEffect)(()=>{if(t){let v=setTimeout(s,De);return()=>clearTimeout(v)}},[L]);let k=((pe=n())==null?void 0:pe.wallet)||"metamask",a=ti[k].name,x=ti[k].component,j=t?`Successfully connected with ${a}`:o?o.message:`Waiting for ${a}`,G="";if(t){let v=(L==null?void 0:L.linkedAccounts.length)||0;T===v?G="Wallet was already linked.":G="You\u2019re good to go!"}else if(m>=Ao&&o)G="Unable to connect wallet";else if(o)G=o.detail;else switch(G="Don\u2019t see your wallet modal? Check your other browser windows.",k){case"wallet_connect":G="Open your mobile wallet app to continue";break;case"coinbase_wallet":bt()||(G="Open the Coinbase app on your phone to continue.");break;default:G="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)(Mn,{children:[(0,H.jsx)(Nn,{children:(0,H.jsxs)("div",{children:[(0,H.jsx)(Mt,{success:t,fail:!!o}),(0,H.jsx)(x,{style:{width:"38px",height:"38px"}})]})}),(0,H.jsxs)(Wn,{children:[(0,H.jsx)("h3",{children:j}),(0,H.jsx)("p",{children:G})]}),(0,H.jsx)(On,{onClick:()=>{M(m+1),r(void 0)},visible:!t&&(o==null?void 0:o.retryable)&&m<Ao,disabled:!t&&(!(o!=null&&o.retryable)||m>=Ao),children:"Retry"})]})]})},Mn=lt.default.div`
929
+ `;var Pe=require("react");var lt=C(require("styled-components"));var H=require("react/jsx-runtime"),Ao=2,ti={metamask:{name:"MetaMask",component:Me},coinbase_wallet:{name:"Coinbase Wallet",component:be},wallet_connect:{name:"WalletConnect",component:At}},oi=()=>{var pe;let[t,e]=(0,Pe.useState)(!1),[o,r]=(0,Pe.useState)(void 0),{navigateBack:i}=y(),{getAuthMeta:n,closePrivyModal:s,loginWithWallet:p,handleLoginError:w}=R(),[m,M]=(0,Pe.useState)(0),{user:x}=O(),[T,A]=(0,Pe.useState)((x==null?void 0:x.linkedAccounts.length)||0);(0,Pe.useEffect)(()=>{r(void 0),p().then(()=>e(!0)).catch(v=>{v instanceof Q?console.error(v.cause):console.error(v);let oe=(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(Qe.ERROR_USER_EXISTS):oe?r(Qe.ERROR_WALLET_NOT_ALLOWED):v instanceof He&&!v.details.default?r(v.details):v instanceof Ge?r(Qe.ERROR_TIMED_OUT):r(Qe.ERROR_WALLET_CONNECTION),w(oe)})},[m]),(0,Pe.useEffect)(()=>{if(t){let v=setTimeout(s,De);return()=>clearTimeout(v)}},[x]);let k=((pe=n())==null?void 0:pe.wallet)||"metamask",a=ti[k].name,L=ti[k].component,j=t?`Successfully connected with ${a}`:o?o.message:`Waiting for ${a}`,G="";if(t){let v=(x==null?void 0:x.linkedAccounts.length)||0;T===v?G="Wallet was already linked.":G="You\u2019re good to go!"}else if(m>=Ao&&o)G="Unable to connect wallet";else if(o)G=o.detail;else switch(G="Don\u2019t see your wallet modal? Check your other browser windows.",k){case"wallet_connect":G="Open your mobile wallet app to continue";break;case"coinbase_wallet":bt()||(G="Open the Coinbase app on your phone to continue.");break;default:G="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)(Mn,{children:[(0,H.jsx)(Nn,{children:(0,H.jsxs)("div",{children:[(0,H.jsx)(Mt,{success:t,fail:!!o}),(0,H.jsx)(L,{style:{width:"38px",height:"38px"}})]})}),(0,H.jsxs)(Wn,{children:[(0,H.jsx)("h3",{children:j}),(0,H.jsx)("p",{children:G})]}),(0,H.jsx)(On,{onClick:()=>{M(m+1),r(void 0)},visible:!t&&(o==null?void 0:o.retryable)&&m<Ao,disabled:!t&&(!(o!=null&&o.retryable)||m>=Ao),children:"Retry"})]})]})},Mn=lt.default.div`
930
930
  display: flex;
931
931
  flex-direction: column;
932
932
  align-items: center;
@@ -1271,7 +1271,7 @@ Resources:
1271
1271
  display: none;
1272
1272
  }
1273
1273
  }
1274
- `;var mi=require("react");var Ye=require("react");var dt=C(require("styled-components"));var B=require("react/jsx-runtime"),li={google:{name:"Google",component:It},discord:{name:"Discord",component:Tt},twitter:{name:"Twitter",component:St}},Dn=t=>t.charAt(0).toUpperCase()+t.slice(1),ko=()=>{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)},di=()=>{var k;let[t,e]=(0,Ye.useState)(!1),[o,r]=(0,Ye.useState)(void 0),{getAuthMeta:i,initLoginWithOAuth:n,loginWithOAuth:s,closePrivyModal:p}=R(),{ready:w}=O(),m=((k=i())==null?void 0:k.provider)||"google",M=li[m].name,L=li[m].component;(0,Ye.useEffect)(()=>{!w||s().then(()=>{ko(),e(!0)}).catch(a=>{let x={retryable:!1,message:"Authentication failed."};a.message.includes("Another user has already linked this")?x.detail="This account has already been linked to another user.":a.message==="Invalid code during oauth flow."?(x.retryable=!0,x.detail="Something went wrong. Try again."):a.message==="User denied confirmation during OAuth flow"&&(x.detail=`Retry and check ${Dn(m)} to finish connecting your account.`,x.retryable=!0),ko(),r(x)})},[w]),(0,Ye.useEffect)(()=>{if(!t)return;let a=setTimeout(p,De);return()=>clearTimeout(a)},[t]);let T=t?`Successfully connected with ${M}`:o?o.message:`Verifying connection to ${M}`,A="";return t?A="You\u2019re good to go!":o?A=o.detail:A="Just a few moments more",(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(P,{}),(0,B.jsxs)(Fn,{children:[(0,B.jsx)(Gn,{children:(0,B.jsxs)("div",{children:[(0,B.jsx)(Mt,{success:t,fail:!!o}),(0,B.jsx)(L,{style:{width:"38px",height:"38px"},logoFill:"primary"})]})}),(0,B.jsxs)(Vn,{children:[(0,B.jsx)("h3",{children:T}),(0,B.jsx)("p",{children:A})]}),(0,B.jsx)(Hn,{onClick:()=>{ko(),n(m),r(void 0)},visible:!t&&(o==null?void 0:o.retryable),disabled:!t&&!(o!=null&&o.retryable),children:"Retry"})]})]})},Fn=dt.default.div`
1274
+ `;var mi=require("react");var Ye=require("react");var dt=C(require("styled-components"));var B=require("react/jsx-runtime"),li={google:{name:"Google",component:It},discord:{name:"Discord",component:Tt},twitter:{name:"Twitter",component:St}},Dn=t=>t.charAt(0).toUpperCase()+t.slice(1),ko=()=>{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)},di=()=>{var k;let[t,e]=(0,Ye.useState)(!1),[o,r]=(0,Ye.useState)(void 0),{getAuthMeta:i,initLoginWithOAuth:n,loginWithOAuth:s,closePrivyModal:p}=R(),{ready:w}=O(),m=((k=i())==null?void 0:k.provider)||"google",M=li[m].name,x=li[m].component;(0,Ye.useEffect)(()=>{!w||s().then(()=>{ko(),e(!0)}).catch(a=>{let L={retryable:!1,message:"Authentication failed."};a.message.includes("Another user has already linked this")?L.detail="This account has already been linked to another user.":a.message==="Invalid code during oauth flow."?(L.retryable=!0,L.detail="Something went wrong. Try again."):a.message==="User denied confirmation during OAuth flow"&&(L.detail=`Retry and check ${Dn(m)} to finish connecting your account.`,L.retryable=!0),ko(),r(L)})},[w]),(0,Ye.useEffect)(()=>{if(!t)return;let a=setTimeout(p,De);return()=>clearTimeout(a)},[t]);let T=t?`Successfully connected with ${M}`:o?o.message:`Verifying connection to ${M}`,A="";return t?A="You\u2019re good to go!":o?A=o.detail:A="Just a few moments more",(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(P,{}),(0,B.jsxs)(Fn,{children:[(0,B.jsx)(Gn,{children:(0,B.jsxs)("div",{children:[(0,B.jsx)(Mt,{success:t,fail:!!o}),(0,B.jsx)(x,{style:{width:"38px",height:"38px"},logoFill:"primary"})]})}),(0,B.jsxs)(Vn,{children:[(0,B.jsx)("h3",{children:T}),(0,B.jsx)("p",{children:A})]}),(0,B.jsx)(Hn,{onClick:()=>{ko(),n(m),r(void 0)},visible:!t&&(o==null?void 0:o.retryable),disabled:!t&&!(o!=null&&o.retryable),children:"Retry"})]})]})},Fn=dt.default.div`
1275
1275
  display: flex;
1276
1276
  flex-direction: column;
1277
1277
  align-items: center;
@@ -1377,4 +1377,4 @@ Resources:
1377
1377
  align-items: center;
1378
1378
  justify-content: center;
1379
1379
  height: 100%;
1380
- `;var ce=require("react/jsx-runtime");function $n(t){return typeof t=="string"&&t.length===25}var zt;function wi(){if(!zt){let t=_.get(Fe);return Promise.resolve(t||null)}return zt.getAccessToken()}var yi=t=>{if(!$n(t.appId))throw new u("Cannot initialize the Privy provider with an invalid Privy app ID");let[e,o]=(0,z.useState)(null);return(0,z.useEffect)(()=>{zt=new ze({appId:t.appId,apiURL:Mo}),o(zt)},[]),e===null?(0,ce.jsx)(ce.Fragment,{}):(0,ce.jsx)(qn,{...t,client:e})},Kn=(t,e)=>{if(e)return{email:!1,sms:!1,wallet:!1,google:!1,twitter:!1,discord:!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)}},qn=t=>{let e=t.client,[o,r]=(0,z.useState)(!1),[i,n]=(0,z.useState)(!1),[s,p]=(0,z.useState)(!1),[w,m]=(0,z.useState)(null),[M,L]=(0,z.useState)(!1),[T,A]=(0,z.useState)({accentColor:"#696ffd",theme:"System",showWalletLoginFirst:!0,emailAuth:!0,smsAuth:!1,walletAuth:!0,googleOAuth:!1,twitterOAuth:!1,discordOAuth:!1,termsAndConditionsUrl:null,privacyPolicyUrl:null}),[k,a]=(0,z.useState)(null),[x,j]=(0,z.useState)(!1);(0,z.useEffect)(()=>{async function d(){let c=await e.getAppSettings();A(c)}d()},[]);let G=Kn(T,k),pe=()=>{let d=new URLSearchParams(window.location.search),c=d.get("privy_oauth_code"),I=d.get("privy_oauth_state"),W=d.get("privy_oauth_provider");c&&I&&W&&(e.startAuthFlow(new Ze(W,c,I)),a(W),r(!0))};(0,z.useEffect)(()=>{async function d(){pe();let c=await e.getAuthenticatedUser();p(!!c),m(c),n(!0)}d()},[]),(0,z.useEffect)(()=>{i&&s&&w===null&&e.getAuthenticatedUser().then(m)},[i,s,w]);let v={ready:i,authenticated:s,user:w,walletConnector:e.connector,linkWallet:()=>{a("wallet"),j(!0),r(!0)},linkEmail:()=>{a("email"),j(!0),r(!0)},linkPhone:()=>{a("sms"),j(!0),r(!0)},linkGoogle:async()=>{await oe.initLoginWithOAuth("google")},linkTwitter:async()=>{await oe.initLoginWithOAuth("twitter")},linkDiscord:async()=>{await oe.initLoginWithOAuth("discord")},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(),m(null),p(!1),a(null),j(!1),r(!1)},getAccessToken:()=>e.getAccessToken(),getEthereumProvider:()=>e.connector.getEthereumProvider(),getEthersProvider:()=>new gi.Web3Provider(new ve(e.connector.getEthereumProvider())),getWeb3jsProvider:()=>new vt(e.connector.getEthereumProvider()),unlinkWallet:async d=>{let c=await e.unlinkWallet(d);return m(c),c},unlinkEmail:async d=>{let c=await e.unlinkEmail(d);return m(c),c},unlinkPhone:async d=>{let c=await e.unlinkPhone(d);return m(c),c},unlinkGoogle:async d=>{let c=await e.unlinkOAuth("google",d);return m(c),c},unlinkTwitter:async d=>{let c=await e.unlinkOAuth("twitter",d);return m(c),c},unlinkDiscord:async d=>{let c=await e.unlinkOAuth("discord",d);return m(c),c},setActiveWallet:d=>{if(!w)return;let c=e.setActiveWallet(d,w);m(c)},forkSession:()=>e.forkSession()},oe={isLinking:x,getAuthFlow:()=>e.authFlow,getAuthMeta:()=>{var d;return(d=e.authFlow)==null?void 0:d.meta},closePrivyModal:()=>{var d;i&&s&&w&&((d=t.onSuccess)==null||d.call(t,w,M)),e.authFlow=void 0,a(null),j(!1),L(!1),r(!1)},initLoginWithWallet:d=>{d||(d="metamask"),e.connector.walletType=d,e.startAuthFlow(new Xe(e.connector))},initLoginWithOAuth:async d=>{e.startAuthFlow(new Ze(d));let c=await e.authFlow.getAuthorizationUrl();c&&c.url&&window.location.assign(c.url)},loginWithOAuth:async()=>{if(!(e.authFlow instanceof Ze))throw new u("Must initialize OAuth flow before calling loginWithOAuth");let d,c;x?d=await e.link():{user:d,isNewUser:c}=await e.authenticate(),m(d),L(c||!1),p(!0)},loginWithWallet:async()=>{if(!(e.authFlow instanceof Xe))throw new u("Must initialize SIWE flow first.");let d,c;x?(d=await e.link(),d&&(_.del(ne),d=Je(d))):{user:d,isNewUser:c}=await e.authenticate(),m(d||w||null),L(c||!1),p(!0)},loginWithEmail:async d=>{let c=new et(d);e.startAuthFlow(c),await c.sendCodeEmail()},loginWithSms:async d=>{let c=new tt(d);e.startAuthFlow(c),await c.sendSmsCode()},resendEmailCode:async()=>{var d;await((d=e.authFlow)==null?void 0:d.sendCodeEmail())},resendSmsCode:async()=>{var d;await((d=e.authFlow)==null?void 0:d.sendSmsCode())},loginWithCode:async d=>{if(e.authFlow instanceof et)e.authFlow.meta.emailCode=d.trim();else if(e.authFlow instanceof tt)e.authFlow.meta.smsCode=d.trim();else throw new u("Must initialize a passwordless code flow first");let c,I;x?c=await e.link():{user:c,isNewUser:I}=await e.authenticate(),m(c||w||null),L(I||!1),p(!0)},handleLoginError:async d=>{var c;e.authFlow=void 0,a(null),j(!1),L(!1),(c=t.onError)==null||c.call(t,d)}};return(0,ce.jsxs)(to.Provider,{value:v,children:[t.children,(0,ce.jsx)(io.Provider,{value:oe,children:(0,ce.jsx)(ur,{appSettings:T,options:G,visible:o,authenticated:s,children:o&&(0,ce.jsx)(fi,{})})})]})};0&&(module.exports={AsExternalProvider,PrivyClient,PrivyConnector,PrivyProvider,PrivyProxyProvider,VERSION,getAccessToken,usePrivy});
1380
+ `;var ce=require("react/jsx-runtime");function $n(t){return typeof t=="string"&&t.length===25}var zt;function wi(){if(!zt){let t=_.get(Fe);return Promise.resolve(t||null)}return zt.getAccessToken()}var yi=t=>{if(!$n(t.appId))throw new u("Cannot initialize the Privy provider with an invalid Privy app ID");let[e,o]=(0,z.useState)(null);return(0,z.useEffect)(()=>{zt=new ze({appId:t.appId,apiURL:Mo}),o(zt)},[]),e===null?(0,ce.jsx)(ce.Fragment,{}):(0,ce.jsx)(qn,{...t,client:e})},Kn=(t,e)=>{if(e)return{email:!1,sms:!1,wallet:!1,google:!1,twitter:!1,discord:!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)}},qn=t=>{let e=t.client,[o,r]=(0,z.useState)(!1),[i,n]=(0,z.useState)(!1),[s,p]=(0,z.useState)(!1),[w,m]=(0,z.useState)(null),[M,x]=(0,z.useState)(!1),[T,A]=(0,z.useState)({accentColor:"#696ffd",theme:"System",showWalletLoginFirst:!0,emailAuth:!0,smsAuth:!1,walletAuth:!0,googleOAuth:!1,twitterOAuth:!1,discordOAuth:!1,termsAndConditionsUrl:null,privacyPolicyUrl:null}),[k,a]=(0,z.useState)(null),[L,j]=(0,z.useState)(!1);(0,z.useEffect)(()=>{async function d(){let c=await e.getAppSettings();A(c)}d()},[]);let G=Kn(T,k),pe=()=>{let d=new URLSearchParams(window.location.search),c=d.get("privy_oauth_code"),I=d.get("privy_oauth_state"),W=d.get("privy_oauth_provider");c&&I&&W&&(e.startAuthFlow(new Ze(W,c,I)),a(W),r(!0))};(0,z.useEffect)(()=>{async function d(){pe();let c=await e.getAuthenticatedUser();p(!!c),m(c),n(!0)}d()},[]),(0,z.useEffect)(()=>{i&&s&&w===null&&e.getAuthenticatedUser().then(m)},[i,s,w]);let v={ready:i,authenticated:s,user:w,walletConnector:e.connector,linkWallet:()=>{a("wallet"),j(!0),r(!0)},linkEmail:()=>{a("email"),j(!0),r(!0)},linkPhone:()=>{a("sms"),j(!0),r(!0)},linkGoogle:async()=>{await oe.initLoginWithOAuth("google")},linkTwitter:async()=>{await oe.initLoginWithOAuth("twitter")},linkDiscord:async()=>{await oe.initLoginWithOAuth("discord")},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(),m(null),p(!1),a(null),j(!1),r(!1)},getAccessToken:()=>e.getAccessToken(),getEthereumProvider:()=>e.connector.getEthereumProvider(),getEthersProvider:()=>new gi.Web3Provider(new ve(e.connector.getEthereumProvider())),getWeb3jsProvider:()=>new vt(e.connector.getEthereumProvider()),unlinkWallet:async d=>{let c=await e.unlinkWallet(d);return m(c),c},unlinkEmail:async d=>{let c=await e.unlinkEmail(d);return m(c),c},unlinkPhone:async d=>{let c=await e.unlinkPhone(d);return m(c),c},unlinkGoogle:async d=>{let c=await e.unlinkOAuth("google",d);return m(c),c},unlinkTwitter:async d=>{let c=await e.unlinkOAuth("twitter",d);return m(c),c},unlinkDiscord:async d=>{let c=await e.unlinkOAuth("discord",d);return m(c),c},setActiveWallet:d=>{if(!w)return;let c=e.setActiveWallet(d,w);m(c)},forkSession:()=>e.forkSession()},oe={isLinking:L,getAuthFlow:()=>e.authFlow,getAuthMeta:()=>{var d;return(d=e.authFlow)==null?void 0:d.meta},closePrivyModal:()=>{var d;i&&s&&w&&((d=t.onSuccess)==null||d.call(t,w,M)),e.authFlow=void 0,a(null),j(!1),x(!1),r(!1)},initLoginWithWallet:d=>{d||(d="metamask"),e.connector.walletType=d,e.startAuthFlow(new Xe(e.connector))},initLoginWithOAuth:async d=>{e.startAuthFlow(new Ze(d));let c=await e.authFlow.getAuthorizationUrl();c&&c.url&&window.location.assign(c.url)},loginWithOAuth:async()=>{if(!(e.authFlow instanceof Ze))throw new u("Must initialize OAuth flow before calling loginWithOAuth");let d,c;i&&s?d=await e.link():{user:d,isNewUser:c}=await e.authenticate(),m(d),x(c||!1),p(!0)},loginWithWallet:async()=>{if(!(e.authFlow instanceof Xe))throw new u("Must initialize SIWE flow first.");let d,c;L?(d=await e.link(),d&&(_.del(ne),d=Je(d))):{user:d,isNewUser:c}=await e.authenticate(),m(d||w||null),x(c||!1),p(!0)},loginWithEmail:async d=>{let c=new et(d);e.startAuthFlow(c),await c.sendCodeEmail()},loginWithSms:async d=>{let c=new tt(d);e.startAuthFlow(c),await c.sendSmsCode()},resendEmailCode:async()=>{var d;await((d=e.authFlow)==null?void 0:d.sendCodeEmail())},resendSmsCode:async()=>{var d;await((d=e.authFlow)==null?void 0:d.sendSmsCode())},loginWithCode:async d=>{if(e.authFlow instanceof et)e.authFlow.meta.emailCode=d.trim();else if(e.authFlow instanceof tt)e.authFlow.meta.smsCode=d.trim();else throw new u("Must initialize a passwordless code flow first");let c,I;L?c=await e.link():{user:c,isNewUser:I}=await e.authenticate(),m(c||w||null),x(I||!1),p(!0)},handleLoginError:async d=>{var c;e.authFlow=void 0,a(null),j(!1),x(!1),(c=t.onError)==null||c.call(t,d)}};return(0,ce.jsxs)(to.Provider,{value:v,children:[t.children,(0,ce.jsx)(io.Provider,{value:oe,children:(0,ce.jsx)(ur,{appSettings:T,options:G,visible:o,authenticated:s,children:o&&(0,ce.jsx)(fi,{})})})]})};0&&(module.exports={AsExternalProvider,PrivyClient,PrivyConnector,PrivyProvider,PrivyProxyProvider,VERSION,getAccessToken,usePrivy});
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import{useEffect as Wt,useState as ie}from"react";import Vt from"axios";import mi from"axios";var B=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}]`:""}`}},Xe=class extends B{constructor(o,r,i,n){super(i,n);this.type=o;this.status=r}},p=class extends B{constructor(o,r){super(o,r);this.type="client_error"}};var V=class extends B{constructor(o,r){super(o,r);this.type="connector_error"}},I=t=>{if(t instanceof B)return t;if(!mi.isAxiosError(t))return G(t);if(!t.response)return new Xe("api_error",null,t.message,t);let{type:e,message:o,error:r}=t.response.data;return new Xe(e||"ApiError",t.response.status,o||r,t)},G=t=>t instanceof B?t:t instanceof Error?new p(t.message,t):new p(`Internal error: ${t}`);var go="1.12.0-beta.4";var wo="https://api.privy.io/v0",yo=process.env.NEXT_PUBLIC_PRIVY_AUTH_URL||"https://auth.privy.io",et="4df5e2316331463a9130964bd6078dfa",Co=1e4,Ee=1400,vo=365*24*60*60,Ft=go,bo="ES256",xo="privy.io",Ae="privy:token",tt="privy:refresh_token",K="privy:active_wallet",ot="privy:wallet_type",Lo="walletconnect";var rt=class{constructor(e,o,r){this.appId=e,this.sdkVersion=Ft,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 ke from"jose";var ne=class{static parse(e){try{return new ne(e)}catch{return null}}constructor(e){this.value=e,this._decoded=ke.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 ke.importSPKI(e,bo);try{return await ke.jwtVerify(this.value,i,{issuer:xo,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 Gt=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]}},Ht=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 gi(){return typeof window<"u"&&window.localStorage?new Ht:new Gt}var E=gi();function pe(t){return new Date(t*1e3)}function wi(t){return t.map(e=>{switch(e.type){case"wallet":return{address:e.address,type:e.type,verifiedAt:pe(e.verified_at),chainType:e.chain_type};case"email":return{address:e.address,type:e.type,verifiedAt:pe(e.verified_at)};case"phone":return{number:e.phoneNumber,type:e.type,verifiedAt:pe(e.verified_at)};case"google_oauth":return{subject:e.subject,email:e.email,name:e.name,type:e.type,verifiedAt:pe(e.verified_at)};case"twitter_oauth":return{subject:e.subject,username:e.username,name:e.name,type:e.type,verifiedAt:pe(e.verified_at)};case"discord_oauth":return{subject:e.subject,username:e.username,email:e.email,type:e.type,verifiedAt:pe(e.verified_at)};default:throw new p("Unrecognized account type")}})}function yi(t,e){return e.find(o=>o.type==="wallet"&&o.address===t)}function ue(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=ue(t.linkedAccounts,"wallet");s&&(r=s.address,E.put(K,r))}let i=yi(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 J(t){if(!t)return null;let e=wi(t.linked_accounts),o=ue(e,"wallet"),r=ue(e,"email"),i=ue(e,"phone"),n=ue(e,"google_oauth"),s=ue(e,"twitter_oauth"),c=ue(e,"discord_oauth"),f={id:t.id,createdAt:pe(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}};return Fe(f)}var Eo=()=>"/api/v1/sessions",Ao=()=>"/api/v1/sessions/logout",ko=()=>"/api/v1/sessions/fork",_o=()=>"/api/v1/siwe/init",Po=()=>"/api/v1/siwe/authenticate",So=()=>"/api/v1/siwe/link",To=()=>"/api/v1/passwordless/init",Io=()=>"/api/v1/passwordless/authenticate",Ro=()=>"/api/v1/passwordless/link",Mo=()=>"/api/v1/passwordless_sms/init",Wo=()=>"/api/v1/passwordless_sms/authenticate",No=()=>"/api/v1/passwordless_sms/link",Oo=()=>"/api/v1/oauth/init",Uo=()=>"/api/v1/oauth/authenticate",Do=()=>"/api/v1/oauth/link",Fo=()=>"/api/v1/siwe/unlink",Vo=()=>"/api/v1/passwordless/unlink",Go=()=>"/api/v1/passwordless_sms/unlink",Ho=()=>"/api/v1/oauth/unlink";var Ci=30,it=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(Ae);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(tt);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(Ci)}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:J(i),isNewUser:n}}catch(o){throw console.warn("Error authenticating session"),G(o)}}async _link(e){try{let o=await e.link();return J(o)}catch(o){throw console.warn("Error linking account"),G(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(Eo(),{refresh_token:o});return this.storeToken(r.data.token),this.storeRefreshToken(r.data.refresh_token),J(r.data.user)}catch(r){throw G(r)}}async _destroy(){var e;try{await((e=this.api)==null?void 0:e.post(Ao(),{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(ko(),{refresh_token:e});return this.storeToken(o.data.token),this.storeRefreshToken(o.data.refresh_token),o.data.new_session_refresh_token}catch(o){throw G(o)}}destroyLocalState(){this.storeToken(null),this.storeRefreshToken(null),E.del(K)}storeToken(e){typeof e=="string"?E.put(Ae,e):E.del(Ae)}storeRefreshToken(e){typeof e=="string"?E.put(tt,e):E.del(tt)}};import{getAddress as Ai}from"@ethersproject/address";import zo from"@walletconnect/web3-provider";import{ErrorCode as vi}from"@ethersproject/logger";var _e=class extends V{constructor(){super("Wallet timeout");this.type="wallet_error"}},nt=t=>{if(t instanceof V)return t;if((t==null?void 0:t.code)&&(t==null?void 0:t.reason)){let e=new Pe(t);return t.code===vi.ACTION_REJECTED&&(e.details=he.E4001_USER_REJECTED_REQUEST),e}return t!=null&&t.code?new Pe(t):new V("Unknown connector error",t)},Bt=class extends B{constructor(o,r,i){super(o);this.type="provider_error";this.code=r,this.data=i}},Pe=class extends Bt{constructor(o){var n,s,c;let r=o;super(r.message,r.code,r.data);let i=Object.values(he).find(f=>f.eipCode===r.code);this.details=i||he.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=he.E32002_CONNECTION_ALREADY_PENDING:this.details=he.E32002_REQUEST_ALREADY_PENDING:(c=r.message)!=null&&c.includes("Already processing")&&r.message.includes("eth_requestAccounts")&&(this.details=he.E32002_WALLET_LOCKED))}},bi={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}},xi={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}},Li={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}},he={UNKNOWN_ERROR:{eipCode:0,message:"Unknown error",detail:"Unknown error",retryable:!0},...Li,...xi},Ve={...bi,...he};var Ei=12e4,zt=(t=new _e,e=Ei)=>new Promise((o,r)=>setTimeout(()=>{r(t)},e)),me=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),zt()]).catch(o=>{throw nt(o)})}},fe=class extends me{constructor(o){super(o)}},st=class extends me{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 ki}from"@ethersproject/providers";var Bo=["metamask","coinbase_wallet","wallet_connect"];import _i from"@coinbase/wallet-sdk";var Pi=()=>{let t=`https://mainnet.infura.io/v3/${et}`,e=1;return new _i({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},at=()=>{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},Ge=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 Wt,useState as ie}from"react";import Vt from"axios";import mi from"axios";var B=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}]`:""}`}},Xe=class extends B{constructor(o,r,i,n){super(i,n);this.type=o;this.status=r}},p=class extends B{constructor(o,r){super(o,r);this.type="client_error"}};var V=class extends B{constructor(o,r){super(o,r);this.type="connector_error"}},I=t=>{if(t instanceof B)return t;if(!mi.isAxiosError(t))return G(t);if(!t.response)return new Xe("api_error",null,t.message,t);let{type:e,message:o,error:r}=t.response.data;return new Xe(e||"ApiError",t.response.status,o||r,t)},G=t=>t instanceof B?t:t instanceof Error?new p(t.message,t):new p(`Internal error: ${t}`);var go="1.12.0-beta.5";var wo="https://api.privy.io/v0",yo=process.env.NEXT_PUBLIC_PRIVY_AUTH_URL||"https://auth.privy.io",et="4df5e2316331463a9130964bd6078dfa",Co=1e4,Ee=1400,vo=365*24*60*60,Ft=go,bo="ES256",xo="privy.io",Ae="privy:token",tt="privy:refresh_token",K="privy:active_wallet",ot="privy:wallet_type",Lo="walletconnect";var rt=class{constructor(e,o,r){this.appId=e,this.sdkVersion=Ft,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 ke from"jose";var ne=class{static parse(e){try{return new ne(e)}catch{return null}}constructor(e){this.value=e,this._decoded=ke.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 ke.importSPKI(e,bo);try{return await ke.jwtVerify(this.value,i,{issuer:xo,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 Gt=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]}},Ht=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 gi(){return typeof window<"u"&&window.localStorage?new Ht:new Gt}var E=gi();function pe(t){return new Date(t*1e3)}function wi(t){return t.map(e=>{switch(e.type){case"wallet":return{address:e.address,type:e.type,verifiedAt:pe(e.verified_at),chainType:e.chain_type};case"email":return{address:e.address,type:e.type,verifiedAt:pe(e.verified_at)};case"phone":return{number:e.phoneNumber,type:e.type,verifiedAt:pe(e.verified_at)};case"google_oauth":return{subject:e.subject,email:e.email,name:e.name,type:e.type,verifiedAt:pe(e.verified_at)};case"twitter_oauth":return{subject:e.subject,username:e.username,name:e.name,type:e.type,verifiedAt:pe(e.verified_at)};case"discord_oauth":return{subject:e.subject,username:e.username,email:e.email,type:e.type,verifiedAt:pe(e.verified_at)};default:throw new p("Unrecognized account type")}})}function yi(t,e){return e.find(o=>o.type==="wallet"&&o.address===t)}function ue(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=ue(t.linkedAccounts,"wallet");s&&(r=s.address,E.put(K,r))}let i=yi(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 J(t){if(!t)return null;let e=wi(t.linked_accounts),o=ue(e,"wallet"),r=ue(e,"email"),i=ue(e,"phone"),n=ue(e,"google_oauth"),s=ue(e,"twitter_oauth"),c=ue(e,"discord_oauth"),f={id:t.id,createdAt:pe(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}};return Fe(f)}var Eo=()=>"/api/v1/sessions",Ao=()=>"/api/v1/sessions/logout",ko=()=>"/api/v1/sessions/fork",_o=()=>"/api/v1/siwe/init",Po=()=>"/api/v1/siwe/authenticate",So=()=>"/api/v1/siwe/link",To=()=>"/api/v1/passwordless/init",Io=()=>"/api/v1/passwordless/authenticate",Ro=()=>"/api/v1/passwordless/link",Mo=()=>"/api/v1/passwordless_sms/init",Wo=()=>"/api/v1/passwordless_sms/authenticate",No=()=>"/api/v1/passwordless_sms/link",Oo=()=>"/api/v1/oauth/init",Uo=()=>"/api/v1/oauth/authenticate",Do=()=>"/api/v1/oauth/link",Fo=()=>"/api/v1/siwe/unlink",Vo=()=>"/api/v1/passwordless/unlink",Go=()=>"/api/v1/passwordless_sms/unlink",Ho=()=>"/api/v1/oauth/unlink";var Ci=30,it=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(Ae);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(tt);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(Ci)}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:J(i),isNewUser:n}}catch(o){throw console.warn("Error authenticating session"),G(o)}}async _link(e){try{let o=await e.link();return J(o)}catch(o){throw console.warn("Error linking account"),G(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(Eo(),{refresh_token:o});return this.storeToken(r.data.token),this.storeRefreshToken(r.data.refresh_token),J(r.data.user)}catch(r){throw G(r)}}async _destroy(){var e;try{await((e=this.api)==null?void 0:e.post(Ao(),{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(ko(),{refresh_token:e});return this.storeToken(o.data.token),this.storeRefreshToken(o.data.refresh_token),o.data.new_session_refresh_token}catch(o){throw G(o)}}destroyLocalState(){this.storeToken(null),this.storeRefreshToken(null),E.del(K)}storeToken(e){typeof e=="string"?E.put(Ae,e):E.del(Ae)}storeRefreshToken(e){typeof e=="string"?E.put(tt,e):E.del(tt)}};import{getAddress as Ai}from"@ethersproject/address";import zo from"@walletconnect/web3-provider";import{ErrorCode as vi}from"@ethersproject/logger";var _e=class extends V{constructor(){super("Wallet timeout");this.type="wallet_error"}},nt=t=>{if(t instanceof V)return t;if((t==null?void 0:t.code)&&(t==null?void 0:t.reason)){let e=new Pe(t);return t.code===vi.ACTION_REJECTED&&(e.details=he.E4001_USER_REJECTED_REQUEST),e}return t!=null&&t.code?new Pe(t):new V("Unknown connector error",t)},Bt=class extends B{constructor(o,r,i){super(o);this.type="provider_error";this.code=r,this.data=i}},Pe=class extends Bt{constructor(o){var n,s,c;let r=o;super(r.message,r.code,r.data);let i=Object.values(he).find(f=>f.eipCode===r.code);this.details=i||he.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=he.E32002_CONNECTION_ALREADY_PENDING:this.details=he.E32002_REQUEST_ALREADY_PENDING:(c=r.message)!=null&&c.includes("Already processing")&&r.message.includes("eth_requestAccounts")&&(this.details=he.E32002_WALLET_LOCKED))}},bi={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}},xi={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}},Li={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}},he={UNKNOWN_ERROR:{eipCode:0,message:"Unknown error",detail:"Unknown error",retryable:!0},...Li,...xi},Ve={...bi,...he};var Ei=12e4,zt=(t=new _e,e=Ei)=>new Promise((o,r)=>setTimeout(()=>{r(t)},e)),me=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),zt()]).catch(o=>{throw nt(o)})}},fe=class extends me{constructor(o){super(o)}},st=class extends me{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 ki}from"@ethersproject/providers";var Bo=["metamask","coinbase_wallet","wallet_connect"];import _i from"@coinbase/wallet-sdk";var Pi=()=>{let t=`https://mainnet.infura.io/v3/${et}`,e=1;return new _i({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},at=()=>{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},Ge=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}
@@ -290,7 +290,7 @@ Resources:
290
290
  border-color: var(--fail-light);
291
291
  border-bottom-color: var(--fail-light);
292
292
  }
293
- `;import{isPossiblePhoneNumber as pn}from"libphonenumber-js/min";var gr=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,}))$/),wr=t=>pn(String(t),"US"),yt=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)}},yr=(t,e)=>{var o=t.slice(0);let r=[];for(;o.length;)r.push(o.splice(0,e));return r};import{Fragment as Cn,jsx as te,jsxs as Qt}from"react/jsx-runtime";var Ct=t=>{let[e,o]=Jt(""),[r,i]=Jt(!1),[n,s]=Jt(null),{authenticated:c}=N(),{loginWithEmail:f,handleLoginError:h}=P(),{navigate:S,options:b}=w(),k=b.wallet;un(()=>{let a=document.querySelector("#email-input");a==null||a.focus()},[]);let x=gr(e),L=()=>{i(!0),f(e).then(()=>{S("AWAITING_PASSWORDLESS_CODE")}).catch(a=>{let v=(a==null?void 0:a.status)===401&&(a==null?void 0:a.message)==="User is not allowed to login to this app.";(a==null?void 0:a.status)===422?s(a.message):s(v?"You don't have access to this app":"Issue submitting email"),i(!1),h(v)})};return Qt(Cn,{children:[Qt(hn,{stacked:t.stacked,children:[Qt(gn,{standalone:t.stacked,children:[te(gt,{}),te("input",{id:"email-input",type:"email",placeholder:"your@email.com",onChange:a=>o(a.target.value),onKeyUp:a=>{a.key==="Enter"&&L()},value:e,autoComplete:"email"})]}),t.stacked?null:te(mn,{disabled:r||!x,onClick:L,children:r?te(de,{color:"var(--disabled-fg)",style:{height:"1rem",width:"1rem",borderWidth:"2px"}}):"Submit"})]}),n||c||!k?te(yn,{fail:!!n,children:n||""}):null,!n&&!c&&k?te(wn,{children:te("span",{children:"Get started without a wallet."})}):null,t.stacked?te(fn,{disabled:r||!x,onClick:L,children:r?te(de,{color:"var(--disabled-fg)",style:{height:"1rem",width:"1rem",borderWidth:"2px"}}):"Submit"}):null]})},hn=Me.div`
293
+ `;import{isPossiblePhoneNumber as pn}from"libphonenumber-js/min";var gr=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,}))$/),wr=t=>pn(String(t),"US"),yt=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)}},yr=(t,e)=>{var o=t.slice(0);let r=[];for(;o.length;)r.push(o.splice(0,e));return r};import{Fragment as Cn,jsx as te,jsxs as Qt}from"react/jsx-runtime";var Ct=t=>{let[e,o]=Jt(""),[r,i]=Jt(!1),[n,s]=Jt(null),{authenticated:c}=N(),{loginWithEmail:f,handleLoginError:h}=P(),{navigate:S,options:v}=w(),k=v.wallet;un(()=>{let a=document.querySelector("#email-input");a==null||a.focus()},[]);let x=gr(e),L=()=>{i(!0),f(e).then(()=>{S("AWAITING_PASSWORDLESS_CODE")}).catch(a=>{let b=(a==null?void 0:a.status)===401&&(a==null?void 0:a.message)==="User is not allowed to login to this app.";(a==null?void 0:a.status)===422?s(a.message):s(b?"You don't have access to this app":"Issue submitting email"),i(!1),h(b)})};return Qt(Cn,{children:[Qt(hn,{stacked:t.stacked,children:[Qt(gn,{standalone:t.stacked,children:[te(gt,{}),te("input",{id:"email-input",type:"email",placeholder:"your@email.com",onChange:a=>o(a.target.value),onKeyUp:a=>{a.key==="Enter"&&L()},value:e,autoComplete:"email"})]}),t.stacked?null:te(mn,{disabled:r||!x,onClick:L,children:r?te(de,{color:"var(--disabled-fg)",style:{height:"1rem",width:"1rem",borderWidth:"2px"}}):"Submit"})]}),n||c||!k?te(yn,{fail:!!n,children:n||""}):null,!n&&!c&&k?te(wn,{children:te("span",{children:"Get started without a wallet."})}):null,t.stacked?te(fn,{disabled:r||!x,onClick:L,children:r?te(de,{color:"var(--disabled-fg)",style:{height:"1rem",width:"1rem",borderWidth:"2px"}}):"Submit"}):null]})},hn=Me.div`
294
294
  display: flex;
295
295
  border: 1px solid #d1d5db;
296
296
  width: 100%;
@@ -410,7 +410,7 @@ Resources:
410
410
  opacity: ${t=>t.success||t.fail?"1":"0"};
411
411
 
412
412
  transition: ${t=>t.fail?"":"all 150ms ease-in-out"};
413
- `;import{useEffect as vn,useState as Xt}from"react";import ye from"styled-components";import{jsx as Cr}from"react/jsx-runtime";var vt=({style:t,...e})=>Cr("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:Cr("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 _n,jsx as oe,jsxs as eo}from"react/jsx-runtime";var bt=t=>{let[e,o]=Xt(""),[r,i]=Xt(!1),[n,s]=Xt(null),{authenticated:c}=N(),{loginWithSms:f,handleLoginError:h}=P(),{navigate:S,options:b}=w(),k=b.wallet;vn(()=>{let a=document.querySelector("#phone-number-input");a==null||a.focus()},[]);let x=wr(e),L=()=>{i(!0),f(e).then(()=>{S("AWAITING_PASSWORDLESS_CODE")}).catch(a=>{let v=(a==null?void 0:a.status)===401&&(a==null?void 0:a.message)==="User is not allowed to login to this app.";(a==null?void 0:a.status)===422?s(a.message):s(v?"You don't have access to this app":"Issue submitting phone number"),i(!1),h(v)})};return eo(_n,{children:[eo(bn,{stacked:t.stacked,children:[eo(En,{standalone:t.stacked,children:[oe(vt,{}),oe("input",{id:"phone-number-input",type:"tel",placeholder:"555 555 5555",onChange:a=>{o(a.target.value)},onKeyUp:a=>{a.key==="Enter"&&L()},value:e,autoComplete:"tel"})]}),t.stacked?null:oe(xn,{disabled:r||!x,onClick:L,children:r?oe(vr,{color:"var(--disabled-fg)"}):"Submit"})]}),n||c||!k?oe(kn,{fail:!!n,children:n||""}):null,!n&&!c&&k?oe(An,{children:oe("span",{children:"Don\u2019t have a wallet? Start exploring with your phone or socials."})}):null,t.stacked?oe(Ln,{disabled:r||!x,onClick:L,children:r?oe(vr,{color:"var(--disabled-fg)"}):"Submit"}):null]})},bn=ye.div`
413
+ `;import{useEffect as vn,useState as Xt}from"react";import ye from"styled-components";import{jsx as Cr}from"react/jsx-runtime";var vt=({style:t,...e})=>Cr("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:Cr("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 _n,jsx as oe,jsxs as eo}from"react/jsx-runtime";var bt=t=>{let[e,o]=Xt(""),[r,i]=Xt(!1),[n,s]=Xt(null),{authenticated:c}=N(),{loginWithSms:f,handleLoginError:h}=P(),{navigate:S,options:v}=w(),k=v.wallet;vn(()=>{let a=document.querySelector("#phone-number-input");a==null||a.focus()},[]);let x=wr(e),L=()=>{i(!0),f(e).then(()=>{S("AWAITING_PASSWORDLESS_CODE")}).catch(a=>{let b=(a==null?void 0:a.status)===401&&(a==null?void 0:a.message)==="User is not allowed to login to this app.";(a==null?void 0:a.status)===422?s(a.message):s(b?"You don't have access to this app":"Issue submitting phone number"),i(!1),h(b)})};return eo(_n,{children:[eo(bn,{stacked:t.stacked,children:[eo(En,{standalone:t.stacked,children:[oe(vt,{}),oe("input",{id:"phone-number-input",type:"tel",placeholder:"555 555 5555",onChange:a=>{o(a.target.value)},onKeyUp:a=>{a.key==="Enter"&&L()},value:e,autoComplete:"tel"})]}),t.stacked?null:oe(xn,{disabled:r||!x,onClick:L,children:r?oe(vr,{color:"var(--disabled-fg)"}):"Submit"})]}),n||c||!k?oe(kn,{fail:!!n,children:n||""}):null,!n&&!c&&k?oe(An,{children:oe("span",{children:"Don\u2019t have a wallet? Start exploring with your phone or socials."})}):null,t.stacked?oe(Ln,{disabled:r||!x,onClick:L,children:r?oe(vr,{color:"var(--disabled-fg)"}):"Submit"}):null]})},bn=ye.div`
414
414
  display: flex;
415
415
  border: 1px solid #d1d5db;
416
416
  width: 100%;
@@ -535,7 +535,7 @@ Resources:
535
535
  width: 1rem;
536
536
  border-width: 2px;
537
537
  }
538
- `;import{jsx as br}from"react/jsx-runtime";var xr=()=>{let{app:t}=w();return t!=null&&t.logoUrl?br("div",{children:br("img",{src:t.logoUrl,alt:`${t==null?void 0:t.name} logo`,style:{objectFit:"contain",width:"200px",height:"80px"}})}):null};import{isMobile as Lr}from"react-device-detect";import{Fragment as Ce,jsx as C,jsxs as re}from"react/jsx-runtime";var Ar=()=>{let{ready:t}=N(),{getAuthMeta:e,isLinking:o}=P(),{app:r,navigate:i,options:n}=w(),s=n.email,c=n.sms,f=n.wallet,h=n.google,S=n.twitter,b=n.discord,k=f&&(r==null?void 0:r.showWalletLoginFirst)?0:1,[x,L]=Sn(k),a=e(),v=(a==null?void 0:a.authorizationCode)&&(a==null?void 0:a.stateCode)&&(a==null?void 0:a.provider);Pn(()=>{v?i("AWAITING_OAUTH_SCREEN"):o&&s?i("LINK_EMAIL_SCREEN"):o&&c?i("LINK_PHONE_SCREEN"):o&&f&&i("LINK_WALLET_SCREEN")},[t]);let F=x==0,W=x==1,Y=()=>C(Ce,{children:f&&C(Tn,{active:F,onClick:()=>L(0)})}),y=()=>C(Ce,{children:(s||c)&&C(In,{active:W,onClick:()=>L(1),email:s,sms:c,google:h,twitter:S,discord:b})});return re(Ce,{children:[C(A,{},"header"),C(Wn,{walletOnly:!s&&!c&&!h&&!S&&!b,hasTerms:!!((r==null?void 0:r.privacyPolicyUrl)||(r==null?void 0:r.termsAndConditionsUrl)),children:C(xr,{})}),C(le,{children:r!=null&&r.showWalletLoginFirst?re(Ce,{children:[C(Y,{}),C(y,{})]}):re(Ce,{children:[C(y,{}),C(Y,{})]})}),r&&C(dr,{app:r}),C(q,{protectedByPrivy:!0})]})};function Tn(t){return re(_r,{active:t.active,onClick:t.onClick,children:[C(kr,{active:t.active,children:C("h4",{children:"Connect Wallet"})}),t.active&&re(Ce,{children:[C(dt,{}),C(ct,{})]})]})}function In(t){let e=t.google||t.discord||t.twitter&&!Lr,o=t.email?"Email":"Phone";return re(_r,{active:t.active,onClick:t.onClick,children:[C(kr,{active:t.active,children:re("h4",{children:["Sign In with ",e?`${o} & Social`:o]})}),t.active&&t.email&&C(Ct,{}),t.active&&t.sms&&!t.email&&C(bt,{}),t.active&&e&&C(Rn,{google:t.google,twitter:t.twitter&&!Lr,discord:t.discord})]})}function Rn(t){return re(Ce,{children:[re(Mn,{children:[C(Er,{}),C("p",{children:" Or "}),C(Er,{})]}),C(mr,{showGoogle:t.google,showDiscord:t.discord,showTwitter:t.twitter})]})}var kr=Ke.div`
538
+ `;import{jsx as br}from"react/jsx-runtime";var xr=()=>{let{app:t}=w();return t!=null&&t.logoUrl?br("div",{children:br("img",{src:t.logoUrl,alt:`${t==null?void 0:t.name} logo`,style:{objectFit:"contain",width:"200px",height:"80px"}})}):null};import{isMobile as Lr}from"react-device-detect";import{Fragment as Ce,jsx as C,jsxs as re}from"react/jsx-runtime";var Ar=()=>{let{ready:t}=N(),{getAuthMeta:e,isLinking:o}=P(),{app:r,navigate:i,options:n}=w(),s=n.email,c=n.sms,f=n.wallet,h=n.google,S=n.twitter,v=n.discord,k=f&&(r==null?void 0:r.showWalletLoginFirst)?0:1,[x,L]=Sn(k),a=e(),b=(a==null?void 0:a.authorizationCode)&&(a==null?void 0:a.stateCode)&&(a==null?void 0:a.provider);Pn(()=>{b?i("AWAITING_OAUTH_SCREEN"):o&&s?i("LINK_EMAIL_SCREEN"):o&&c?i("LINK_PHONE_SCREEN"):o&&f&&i("LINK_WALLET_SCREEN")},[t]);let F=x==0,W=x==1,Y=()=>C(Ce,{children:f&&C(Tn,{active:F,onClick:()=>L(0)})}),y=()=>C(Ce,{children:(s||c)&&C(In,{active:W,onClick:()=>L(1),email:s,sms:c,google:h,twitter:S,discord:v})});return re(Ce,{children:[C(A,{},"header"),C(Wn,{walletOnly:!s&&!c&&!h&&!S&&!v,hasTerms:!!((r==null?void 0:r.privacyPolicyUrl)||(r==null?void 0:r.termsAndConditionsUrl)),children:C(xr,{})}),C(le,{children:r!=null&&r.showWalletLoginFirst?re(Ce,{children:[C(Y,{}),C(y,{})]}):re(Ce,{children:[C(y,{}),C(Y,{})]})}),r&&C(dr,{app:r}),C(q,{protectedByPrivy:!0})]})};function Tn(t){return re(_r,{active:t.active,onClick:t.onClick,children:[C(kr,{active:t.active,children:C("h4",{children:"Connect Wallet"})}),t.active&&re(Ce,{children:[C(dt,{}),C(ct,{})]})]})}function In(t){let e=t.google||t.discord||t.twitter&&!Lr,o=t.email?"Email":"Phone";return re(_r,{active:t.active,onClick:t.onClick,children:[C(kr,{active:t.active,children:re("h4",{children:["Sign In with ",e?`${o} & Social`:o]})}),t.active&&t.email&&C(Ct,{}),t.active&&t.sms&&!t.email&&C(bt,{}),t.active&&e&&C(Rn,{google:t.google,twitter:t.twitter&&!Lr,discord:t.discord})]})}function Rn(t){return re(Ce,{children:[re(Mn,{children:[C(Er,{}),C("p",{children:" Or "}),C(Er,{})]}),C(mr,{showGoogle:t.google,showDiscord:t.discord,showTwitter:t.twitter})]})}var kr=Ke.div`
539
539
  font-weight: ${t=>t.active?600:500};
540
540
  color: ${t=>t.active?"inherit":"#6b7280"};
541
541
  display: flex;
@@ -629,7 +629,7 @@ Resources:
629
629
  border-color: #e1e7ef;
630
630
  border-width: 1px;
631
631
  }
632
- `;import{Fragment as to,jsx as H,jsxs as Ne}from"react/jsx-runtime";var oo=6,Rr=new Array(oo).fill(""),Un=1400;var Mr=()=>{var Z,l,d;let{app:t}=w(),{closePrivyModal:e,resendEmailCode:o,resendSmsCode:r,getAuthMeta:i,loginWithCode:n}=P(),{authenticated:s,user:c}=N(),[f,h]=Lt(Rr),[S,b]=Lt(!1),[k,x]=Lt(null),[L,a]=Lt(null),v=(Z=i())!=null&&Z.email?0:1;Ir(()=>{if(s&&S){let _=setTimeout(e,Ee);return()=>clearTimeout(_)}},[s,S,c]),Ir(()=>{if(k&&L===0){let _=setTimeout(()=>{h(Rr),x(null);let T=document.querySelector("input[name=code-0]");T==null||T.focus()},Un);return()=>clearTimeout(_)}},[k]);let F=_=>{var fo;let T=_.currentTarget.value.replace(" ","");if(T==="")return;if(isNaN(Number(T))){x("Code should be numeric"),a(1);return}x(null),a(null);let j=Number((fo=_.currentTarget.name)==null?void 0:fo.charAt(5)),Ot=[...T||[""]].slice(0,oo-j),Ut=[...f.slice(0,j),...Ot,...f.slice(j+Ot.length)];h(Ut);let hi=Ot.length,mo=Math.min(Math.max(j+hi,0),oo-1);if(!isNaN(Number(_.currentTarget.value))){let $=document.querySelector(`input[name=code-${mo}]`);$==null||$.focus()}if(Ut.every($=>$&&!isNaN(+$))){let $=document.querySelector(`input[name=code-${mo}]`);$==null||$.blur(),n(Ut.join("")).then(()=>b(!0)).catch(Dt=>{(Dt==null?void 0:Dt.status)===422?x("Invalid or expired verification code"):x("Issue verifying code"),a(0)})}_.preventDefault()},W=_=>{L===1&&(x(null),a(null));let T=[...f.slice(0,_),"",...f.slice(_+1)];if(h(T),_>0){let j=document.querySelector(`input[name=code-${_-1}]`);j==null||j.focus()}},Y=`Verify your ${v==0?"email":"phone"}`,y=v==0?`Please check ${(l=i())==null?void 0:l.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 Ne(to,{children:[H(A,{},"header"),Ne(Dn,{children:[H(ve,{title:Y,description:y}),Ne(ur,{children:[Ne(Fn,{children:[H(Vn,{fail:!!k,success:S,children:H("span",{children:k||(S?"Success!":"")})}),H("div",{children:f.map((_,T)=>H("input",{name:`code-${T}`,type:"text",value:f[T],onChange:F,onKeyUp:j=>{j.key==="Backspace"&&W(T)},inputMode:"numeric",autoFocus:T===0,pattern:"[0-9]",className:`${S?"success":""} ${k?"fail":""}`,autoComplete:"one-time-code"},T))})]}),H(Gn,{children:v==0?Ne(to,{children:[H("span",{children:"Didn't get an email?"}),H("button",{onClick:o,children:"Resend Code"})]}):Ne(to,{children:[H("span",{children:"Didn't get a message?"}),H("button",{onClick:r,children:"Resend Code"})]})})]})]}),H(q,{protectedByPrivy:!0})]})},Dn=Et.div`
632
+ `;import{Fragment as to,jsx as H,jsxs as Ne}from"react/jsx-runtime";var oo=6,Rr=new Array(oo).fill(""),Un=1400;var Mr=()=>{var Z,l,d;let{app:t}=w(),{closePrivyModal:e,resendEmailCode:o,resendSmsCode:r,getAuthMeta:i,loginWithCode:n}=P(),{authenticated:s,user:c}=N(),[f,h]=Lt(Rr),[S,v]=Lt(!1),[k,x]=Lt(null),[L,a]=Lt(null),b=(Z=i())!=null&&Z.email?0:1;Ir(()=>{if(s&&S){let _=setTimeout(e,Ee);return()=>clearTimeout(_)}},[s,S,c]),Ir(()=>{if(k&&L===0){let _=setTimeout(()=>{h(Rr),x(null);let T=document.querySelector("input[name=code-0]");T==null||T.focus()},Un);return()=>clearTimeout(_)}},[k]);let F=_=>{var fo;let T=_.currentTarget.value.replace(" ","");if(T==="")return;if(isNaN(Number(T))){x("Code should be numeric"),a(1);return}x(null),a(null);let j=Number((fo=_.currentTarget.name)==null?void 0:fo.charAt(5)),Ot=[...T||[""]].slice(0,oo-j),Ut=[...f.slice(0,j),...Ot,...f.slice(j+Ot.length)];h(Ut);let hi=Ot.length,mo=Math.min(Math.max(j+hi,0),oo-1);if(!isNaN(Number(_.currentTarget.value))){let $=document.querySelector(`input[name=code-${mo}]`);$==null||$.focus()}if(Ut.every($=>$&&!isNaN(+$))){let $=document.querySelector(`input[name=code-${mo}]`);$==null||$.blur(),n(Ut.join("")).then(()=>v(!0)).catch(Dt=>{(Dt==null?void 0:Dt.status)===422?x("Invalid or expired verification code"):x("Issue verifying code"),a(0)})}_.preventDefault()},W=_=>{L===1&&(x(null),a(null));let T=[...f.slice(0,_),"",...f.slice(_+1)];if(h(T),_>0){let j=document.querySelector(`input[name=code-${_-1}]`);j==null||j.focus()}},Y=`Verify your ${b==0?"email":"phone"}`,y=b==0?`Please check ${(l=i())==null?void 0:l.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 Ne(to,{children:[H(A,{},"header"),Ne(Dn,{children:[H(ve,{title:Y,description:y}),Ne(ur,{children:[Ne(Fn,{children:[H(Vn,{fail:!!k,success:S,children:H("span",{children:k||(S?"Success!":"")})}),H("div",{children:f.map((_,T)=>H("input",{name:`code-${T}`,type:"text",value:f[T],onChange:F,onKeyUp:j=>{j.key==="Backspace"&&W(T)},inputMode:"numeric",autoFocus:T===0,pattern:"[0-9]",className:`${S?"success":""} ${k?"fail":""}`,autoComplete:"one-time-code"},T))})]}),H(Gn,{children:b==0?Ne(to,{children:[H("span",{children:"Didn't get an email?"}),H("button",{onClick:o,children:"Resend Code"})]}):Ne(to,{children:[H("span",{children:"Didn't get a message?"}),H("button",{onClick:r,children:"Resend Code"})]})})]})]}),H(q,{protectedByPrivy:!0})]})},Dn=Et.div`
633
633
  display: flex;
634
634
  flex-direction: column;
635
635
  align-items: flex-start;
@@ -926,7 +926,7 @@ Resources:
926
926
  `,as=z.div`
927
927
  display: flex;
928
928
  justify-content: center;
929
- `;import{useEffect as qr,useState as _t}from"react";import St from"styled-components";import{Fragment as us,jsx as xe,jsxs as Pt}from"react/jsx-runtime";var po=2,Yr={metamask:{name:"MetaMask",component:we},coinbase_wallet:{name:"Coinbase Wallet",component:ae},wallet_connect:{name:"WalletConnect",component:lt}},Jr=()=>{var Y;let[t,e]=_t(!1),[o,r]=_t(void 0),{navigateBack:i}=w(),{getAuthMeta:n,closePrivyModal:s,loginWithWallet:c,handleLoginError:f}=P(),[h,S]=_t(0),{user:b}=N(),[k,x]=_t((b==null?void 0:b.linkedAccounts.length)||0);qr(()=>{r(void 0),c().then(()=>e(!0)).catch(y=>{y instanceof B?console.error(y.cause):console.error(y);let Z=(y==null?void 0:y.status)===401&&(y==null?void 0:y.message)==="User is not allowed to login to this app.";(y==null?void 0:y.status)===422?r(Ve.ERROR_USER_EXISTS):Z?r(Ve.ERROR_WALLET_NOT_ALLOWED):y instanceof Pe&&!y.details.default?r(y.details):y instanceof _e?r(Ve.ERROR_TIMED_OUT):r(Ve.ERROR_WALLET_CONNECTION),f(Z)})},[h]),qr(()=>{if(t){let y=setTimeout(s,Ee);return()=>clearTimeout(y)}},[b]);let L=((Y=n())==null?void 0:Y.wallet)||"metamask",a=Yr[L].name,v=Yr[L].component,F=t?`Successfully connected with ${a}`:o?o.message:`Waiting for ${a}`,W="";if(t){let y=(b==null?void 0:b.linkedAccounts.length)||0;k===y?W="Wallet was already linked.":W="You\u2019re good to go!"}else if(h>=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":at()||(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 Pt(us,{children:[xe(A,{backFn:i}),Pt(ls,{children:[xe(cs,{children:Pt("div",{children:[xe(wt,{success:t,fail:!!o}),xe(v,{style:{width:"38px",height:"38px"}})]})}),Pt(ds,{children:[xe("h3",{children:F}),xe("p",{children:W})]}),xe(ps,{onClick:()=>{S(h+1),r(void 0)},visible:!t&&(o==null?void 0:o.retryable)&&h<po,disabled:!t&&(!(o!=null&&o.retryable)||h>=po),children:"Retry"})]})]})},ls=St.div`
929
+ `;import{useEffect as qr,useState as _t}from"react";import St from"styled-components";import{Fragment as us,jsx as xe,jsxs as Pt}from"react/jsx-runtime";var po=2,Yr={metamask:{name:"MetaMask",component:we},coinbase_wallet:{name:"Coinbase Wallet",component:ae},wallet_connect:{name:"WalletConnect",component:lt}},Jr=()=>{var Y;let[t,e]=_t(!1),[o,r]=_t(void 0),{navigateBack:i}=w(),{getAuthMeta:n,closePrivyModal:s,loginWithWallet:c,handleLoginError:f}=P(),[h,S]=_t(0),{user:v}=N(),[k,x]=_t((v==null?void 0:v.linkedAccounts.length)||0);qr(()=>{r(void 0),c().then(()=>e(!0)).catch(y=>{y instanceof B?console.error(y.cause):console.error(y);let Z=(y==null?void 0:y.status)===401&&(y==null?void 0:y.message)==="User is not allowed to login to this app.";(y==null?void 0:y.status)===422?r(Ve.ERROR_USER_EXISTS):Z?r(Ve.ERROR_WALLET_NOT_ALLOWED):y instanceof Pe&&!y.details.default?r(y.details):y instanceof _e?r(Ve.ERROR_TIMED_OUT):r(Ve.ERROR_WALLET_CONNECTION),f(Z)})},[h]),qr(()=>{if(t){let y=setTimeout(s,Ee);return()=>clearTimeout(y)}},[v]);let L=((Y=n())==null?void 0:Y.wallet)||"metamask",a=Yr[L].name,b=Yr[L].component,F=t?`Successfully connected with ${a}`:o?o.message:`Waiting for ${a}`,W="";if(t){let y=(v==null?void 0:v.linkedAccounts.length)||0;k===y?W="Wallet was already linked.":W="You\u2019re good to go!"}else if(h>=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":at()||(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 Pt(us,{children:[xe(A,{backFn:i}),Pt(ls,{children:[xe(cs,{children:Pt("div",{children:[xe(wt,{success:t,fail:!!o}),xe(b,{style:{width:"38px",height:"38px"}})]})}),Pt(ds,{children:[xe("h3",{children:F}),xe("p",{children:W})]}),xe(ps,{onClick:()=>{S(h+1),r(void 0)},visible:!t&&(o==null?void 0:o.retryable)&&h<po,disabled:!t&&(!(o!=null&&o.retryable)||h>=po),children:"Retry"})]})]})},ls=St.div`
930
930
  display: flex;
931
931
  flex-direction: column;
932
932
  align-items: center;
@@ -1271,7 +1271,7 @@ Resources:
1271
1271
  display: none;
1272
1272
  }
1273
1273
  }
1274
- `;import{useEffect as Ts}from"react";import{useEffect as ri,useState as ii}from"react";import Mt from"styled-components";import{Fragment as Ls,jsx as Le,jsxs as Rt}from"react/jsx-runtime";var ni={google:{name:"Google",component:mt},discord:{name:"Discord",component:ut},twitter:{name:"Twitter",component:pt}},ys=t=>t.charAt(0).toUpperCase()+t.slice(1),uo=()=>{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)},si=()=>{var L;let[t,e]=ii(!1),[o,r]=ii(void 0),{getAuthMeta:i,initLoginWithOAuth:n,loginWithOAuth:s,closePrivyModal:c}=P(),{ready:f}=N(),h=((L=i())==null?void 0:L.provider)||"google",S=ni[h].name,b=ni[h].component;ri(()=>{!f||s().then(()=>{uo(),e(!0)}).catch(a=>{let v={retryable:!1,message:"Authentication failed."};a.message.includes("Another user has already linked this")?v.detail="This account has already been linked to another user.":a.message==="Invalid code during oauth flow."?(v.retryable=!0,v.detail="Something went wrong. Try again."):a.message==="User denied confirmation during OAuth flow"&&(v.detail=`Retry and check ${ys(h)} to finish connecting your account.`,v.retryable=!0),uo(),r(v)})},[f]),ri(()=>{if(!t)return;let a=setTimeout(c,Ee);return()=>clearTimeout(a)},[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(Ls,{children:[Le(A,{}),Rt(Cs,{children:[Le(bs,{children:Rt("div",{children:[Le(wt,{success:t,fail:!!o}),Le(b,{style:{width:"38px",height:"38px"},logoFill:"primary"})]})}),Rt(vs,{children:[Le("h3",{children:k}),Le("p",{children:x})]}),Le(xs,{onClick:()=>{uo(),n(h),r(void 0)},visible:!t&&(o==null?void 0:o.retryable),disabled:!t&&!(o!=null&&o.retryable),children:"Retry"})]})]})},Cs=Mt.div`
1274
+ `;import{useEffect as Ts}from"react";import{useEffect as ri,useState as ii}from"react";import Mt from"styled-components";import{Fragment as Ls,jsx as Le,jsxs as Rt}from"react/jsx-runtime";var ni={google:{name:"Google",component:mt},discord:{name:"Discord",component:ut},twitter:{name:"Twitter",component:pt}},ys=t=>t.charAt(0).toUpperCase()+t.slice(1),uo=()=>{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)},si=()=>{var L;let[t,e]=ii(!1),[o,r]=ii(void 0),{getAuthMeta:i,initLoginWithOAuth:n,loginWithOAuth:s,closePrivyModal:c}=P(),{ready:f}=N(),h=((L=i())==null?void 0:L.provider)||"google",S=ni[h].name,v=ni[h].component;ri(()=>{!f||s().then(()=>{uo(),e(!0)}).catch(a=>{let b={retryable:!1,message:"Authentication failed."};a.message.includes("Another user has already linked this")?b.detail="This account has already been linked to another user.":a.message==="Invalid code during oauth flow."?(b.retryable=!0,b.detail="Something went wrong. Try again."):a.message==="User denied confirmation during OAuth flow"&&(b.detail=`Retry and check ${ys(h)} to finish connecting your account.`,b.retryable=!0),uo(),r(b)})},[f]),ri(()=>{if(!t)return;let a=setTimeout(c,Ee);return()=>clearTimeout(a)},[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(Ls,{children:[Le(A,{}),Rt(Cs,{children:[Le(bs,{children:Rt("div",{children:[Le(wt,{success:t,fail:!!o}),Le(v,{style:{width:"38px",height:"38px"},logoFill:"primary"})]})}),Rt(vs,{children:[Le("h3",{children:k}),Le("p",{children:x})]}),Le(xs,{onClick:()=>{uo(),n(h),r(void 0)},visible:!t&&(o==null?void 0:o.retryable),disabled:!t&&!(o!=null&&o.retryable),children:"Retry"})]})]})},Cs=Mt.div`
1275
1275
  display: flex;
1276
1276
  flex-direction: column;
1277
1277
  align-items: center;
@@ -1377,4 +1377,4 @@ Resources:
1377
1377
  align-items: center;
1378
1378
  justify-content: center;
1379
1379
  height: 100%;
1380
- `;import{Fragment as Gs,jsx as Qe,jsxs as Hs}from"react/jsx-runtime";function Os(t){return typeof t=="string"&&t.length===25}var Nt;function Us(){if(!Nt){let t=E.get(Ae);return Promise.resolve(t||null)}return Nt.getAccessToken()}var Ds=t=>{if(!Os(t.appId))throw new p("Cannot initialize the Privy provider with an invalid Privy app ID");let[e,o]=ie(null);return Wt(()=>{Nt=new He({appId:t.appId,apiURL:yo}),o(Nt)},[]),e===null?Qe(Gs,{}):Qe(Vs,{...t,client:e})},Fs=(t,e)=>{if(e)return{email:!1,sms:!1,wallet:!1,google:!1,twitter:!1,discord:!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)}},Vs=t=>{let e=t.client,[o,r]=ie(!1),[i,n]=ie(!1),[s,c]=ie(!1),[f,h]=ie(null),[S,b]=ie(!1),[k,x]=ie({accentColor:"#696ffd",theme:"System",showWalletLoginFirst:!0,emailAuth:!0,smsAuth:!1,walletAuth:!0,googleOAuth:!1,twitterOAuth:!1,discordOAuth:!1,termsAndConditionsUrl:null,privacyPolicyUrl:null}),[L,a]=ie(null),[v,F]=ie(!1);Wt(()=>{async function l(){let d=await e.getAppSettings();x(d)}l()},[]);let W=Fs(k,L),Y=()=>{let l=new URLSearchParams(window.location.search),d=l.get("privy_oauth_code"),_=l.get("privy_oauth_state"),T=l.get("privy_oauth_provider");d&&_&&T&&(e.startAuthFlow(new Se(T,d,_)),a(T),r(!0))};Wt(()=>{async function l(){Y();let d=await e.getAuthenticatedUser();c(!!d),h(d),n(!0)}l()},[]),Wt(()=>{i&&s&&f===null&&e.getAuthenticatedUser().then(h)},[i,s,f]);let y={ready:i,authenticated:s,user:f,walletConnector:e.connector,linkWallet:()=>{a("wallet"),F(!0),r(!0)},linkEmail:()=>{a("email"),F(!0),r(!0)},linkPhone:()=>{a("sms"),F(!0),r(!0)},linkGoogle:async()=>{await Z.initLoginWithOAuth("google")},linkTwitter:async()=>{await Z.initLoginWithOAuth("twitter")},linkDiscord:async()=>{await Z.initLoginWithOAuth("discord")},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),c(!1),a(null),F(!1),r(!1)},getAccessToken:()=>e.getAccessToken(),getEthereumProvider:()=>e.connector.getEthereumProvider(),getEthersProvider:()=>new Ns(new fe(e.connector.getEthereumProvider())),getWeb3jsProvider:()=>new st(e.connector.getEthereumProvider()),unlinkWallet:async l=>{let d=await e.unlinkWallet(l);return h(d),d},unlinkEmail:async l=>{let d=await e.unlinkEmail(l);return h(d),d},unlinkPhone:async l=>{let d=await e.unlinkPhone(l);return h(d),d},unlinkGoogle:async l=>{let d=await e.unlinkOAuth("google",l);return h(d),d},unlinkTwitter:async l=>{let d=await e.unlinkOAuth("twitter",l);return h(d),d},unlinkDiscord:async l=>{let d=await e.unlinkOAuth("discord",l);return h(d),d},setActiveWallet:l=>{if(!f)return;let d=e.setActiveWallet(l,f);h(d)},forkSession:()=>e.forkSession()},Z={isLinking:v,getAuthFlow:()=>e.authFlow,getAuthMeta:()=>{var l;return(l=e.authFlow)==null?void 0:l.meta},closePrivyModal:()=>{var l;i&&s&&f&&((l=t.onSuccess)==null||l.call(t,f,S)),e.authFlow=void 0,a(null),F(!1),b(!1),r(!1)},initLoginWithWallet:l=>{l||(l="metamask"),e.connector.walletType=l,e.startAuthFlow(new Be(e.connector))},initLoginWithOAuth:async l=>{e.startAuthFlow(new Se(l));let d=await e.authFlow.getAuthorizationUrl();d&&d.url&&window.location.assign(d.url)},loginWithOAuth:async()=>{if(!(e.authFlow instanceof Se))throw new p("Must initialize OAuth flow before calling loginWithOAuth");let l,d;v?l=await e.link():{user:l,isNewUser:d}=await e.authenticate(),h(l),b(d||!1),c(!0)},loginWithWallet:async()=>{if(!(e.authFlow instanceof Be))throw new p("Must initialize SIWE flow first.");let l,d;v?(l=await e.link(),l&&(E.del(K),l=Fe(l))):{user:l,isNewUser:d}=await e.authenticate(),h(l||f||null),b(d||!1),c(!0)},loginWithEmail:async l=>{let d=new ze(l);e.startAuthFlow(d),await d.sendCodeEmail()},loginWithSms:async l=>{let d=new Ze(l);e.startAuthFlow(d),await d.sendSmsCode()},resendEmailCode:async()=>{var l;await((l=e.authFlow)==null?void 0:l.sendCodeEmail())},resendSmsCode:async()=>{var l;await((l=e.authFlow)==null?void 0:l.sendSmsCode())},loginWithCode:async l=>{if(e.authFlow instanceof ze)e.authFlow.meta.emailCode=l.trim();else if(e.authFlow instanceof Ze)e.authFlow.meta.smsCode=l.trim();else throw new p("Must initialize a passwordless code flow first");let d,_;v?d=await e.link():{user:d,isNewUser:_}=await e.authenticate(),h(d||f||null),b(_||!1),c(!0)},handleLoginError:async l=>{var d;e.authFlow=void 0,a(null),F(!1),b(!1),(d=t.onError)==null||d.call(t,l)}};return Hs($t.Provider,{value:y,children:[t.children,Qe(Kt.Provider,{value:Z,children:Qe(qo,{appSettings:k,options:W,visible:o,authenticated:s,children:o&&Qe(ui,{})})})]})};export{fe as AsExternalProvider,He as PrivyClient,Ge as PrivyConnector,Ds as PrivyProvider,me as PrivyProxyProvider,Ft as VERSION,Us as getAccessToken,N as usePrivy};
1380
+ `;import{Fragment as Gs,jsx as Qe,jsxs as Hs}from"react/jsx-runtime";function Os(t){return typeof t=="string"&&t.length===25}var Nt;function Us(){if(!Nt){let t=E.get(Ae);return Promise.resolve(t||null)}return Nt.getAccessToken()}var Ds=t=>{if(!Os(t.appId))throw new p("Cannot initialize the Privy provider with an invalid Privy app ID");let[e,o]=ie(null);return Wt(()=>{Nt=new He({appId:t.appId,apiURL:yo}),o(Nt)},[]),e===null?Qe(Gs,{}):Qe(Vs,{...t,client:e})},Fs=(t,e)=>{if(e)return{email:!1,sms:!1,wallet:!1,google:!1,twitter:!1,discord:!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)}},Vs=t=>{let e=t.client,[o,r]=ie(!1),[i,n]=ie(!1),[s,c]=ie(!1),[f,h]=ie(null),[S,v]=ie(!1),[k,x]=ie({accentColor:"#696ffd",theme:"System",showWalletLoginFirst:!0,emailAuth:!0,smsAuth:!1,walletAuth:!0,googleOAuth:!1,twitterOAuth:!1,discordOAuth:!1,termsAndConditionsUrl:null,privacyPolicyUrl:null}),[L,a]=ie(null),[b,F]=ie(!1);Wt(()=>{async function l(){let d=await e.getAppSettings();x(d)}l()},[]);let W=Fs(k,L),Y=()=>{let l=new URLSearchParams(window.location.search),d=l.get("privy_oauth_code"),_=l.get("privy_oauth_state"),T=l.get("privy_oauth_provider");d&&_&&T&&(e.startAuthFlow(new Se(T,d,_)),a(T),r(!0))};Wt(()=>{async function l(){Y();let d=await e.getAuthenticatedUser();c(!!d),h(d),n(!0)}l()},[]),Wt(()=>{i&&s&&f===null&&e.getAuthenticatedUser().then(h)},[i,s,f]);let y={ready:i,authenticated:s,user:f,walletConnector:e.connector,linkWallet:()=>{a("wallet"),F(!0),r(!0)},linkEmail:()=>{a("email"),F(!0),r(!0)},linkPhone:()=>{a("sms"),F(!0),r(!0)},linkGoogle:async()=>{await Z.initLoginWithOAuth("google")},linkTwitter:async()=>{await Z.initLoginWithOAuth("twitter")},linkDiscord:async()=>{await Z.initLoginWithOAuth("discord")},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),c(!1),a(null),F(!1),r(!1)},getAccessToken:()=>e.getAccessToken(),getEthereumProvider:()=>e.connector.getEthereumProvider(),getEthersProvider:()=>new Ns(new fe(e.connector.getEthereumProvider())),getWeb3jsProvider:()=>new st(e.connector.getEthereumProvider()),unlinkWallet:async l=>{let d=await e.unlinkWallet(l);return h(d),d},unlinkEmail:async l=>{let d=await e.unlinkEmail(l);return h(d),d},unlinkPhone:async l=>{let d=await e.unlinkPhone(l);return h(d),d},unlinkGoogle:async l=>{let d=await e.unlinkOAuth("google",l);return h(d),d},unlinkTwitter:async l=>{let d=await e.unlinkOAuth("twitter",l);return h(d),d},unlinkDiscord:async l=>{let d=await e.unlinkOAuth("discord",l);return h(d),d},setActiveWallet:l=>{if(!f)return;let d=e.setActiveWallet(l,f);h(d)},forkSession:()=>e.forkSession()},Z={isLinking:b,getAuthFlow:()=>e.authFlow,getAuthMeta:()=>{var l;return(l=e.authFlow)==null?void 0:l.meta},closePrivyModal:()=>{var l;i&&s&&f&&((l=t.onSuccess)==null||l.call(t,f,S)),e.authFlow=void 0,a(null),F(!1),v(!1),r(!1)},initLoginWithWallet:l=>{l||(l="metamask"),e.connector.walletType=l,e.startAuthFlow(new Be(e.connector))},initLoginWithOAuth:async l=>{e.startAuthFlow(new Se(l));let d=await e.authFlow.getAuthorizationUrl();d&&d.url&&window.location.assign(d.url)},loginWithOAuth:async()=>{if(!(e.authFlow instanceof Se))throw new p("Must initialize OAuth flow before calling loginWithOAuth");let l,d;i&&s?l=await e.link():{user:l,isNewUser:d}=await e.authenticate(),h(l),v(d||!1),c(!0)},loginWithWallet:async()=>{if(!(e.authFlow instanceof Be))throw new p("Must initialize SIWE flow first.");let l,d;b?(l=await e.link(),l&&(E.del(K),l=Fe(l))):{user:l,isNewUser:d}=await e.authenticate(),h(l||f||null),v(d||!1),c(!0)},loginWithEmail:async l=>{let d=new ze(l);e.startAuthFlow(d),await d.sendCodeEmail()},loginWithSms:async l=>{let d=new Ze(l);e.startAuthFlow(d),await d.sendSmsCode()},resendEmailCode:async()=>{var l;await((l=e.authFlow)==null?void 0:l.sendCodeEmail())},resendSmsCode:async()=>{var l;await((l=e.authFlow)==null?void 0:l.sendSmsCode())},loginWithCode:async l=>{if(e.authFlow instanceof ze)e.authFlow.meta.emailCode=l.trim();else if(e.authFlow instanceof Ze)e.authFlow.meta.smsCode=l.trim();else throw new p("Must initialize a passwordless code flow first");let d,_;b?d=await e.link():{user:d,isNewUser:_}=await e.authenticate(),h(d||f||null),v(_||!1),c(!0)},handleLoginError:async l=>{var d;e.authFlow=void 0,a(null),F(!1),v(!1),(d=t.onError)==null||d.call(t,l)}};return Hs($t.Provider,{value:y,children:[t.children,Qe(Kt.Provider,{value:Z,children:Qe(qo,{appSettings:k,options:W,visible:o,authenticated:s,children:o&&Qe(ui,{})})})]})};export{fe as AsExternalProvider,He as PrivyClient,Ge as PrivyConnector,Ds as PrivyProvider,me as PrivyProxyProvider,Ft as VERSION,Us as getAccessToken,N as usePrivy};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@privy-io/react-auth",
3
- "version": "1.12.0-beta.4",
3
+ "version": "1.12.0-beta.5",
4
4
  "description": "React client for the Privy Auth API",
5
5
  "keywords": [
6
6
  "authentication",