@privy-io/react-auth 1.17.0 → 1.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.js +11 -11
- package/dist/index.js +11 -11
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Web3Provider as u1}from"@ethersproject/providers";import{useEffect as Nn,useState as te}from"react";import Un from"axios";var ne=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}]`:""}`}},je=class extends ne{constructor(o,r,i,n){super(i,n);this.type=o;this.status=r}},y=class extends ne{constructor(o,r){super(o,r);this.type="client_error"}};var B=class extends ne{constructor(o,r){super(o,r);this.type="connector_error"}},U=t=>{if(t instanceof ne)return t;if(!Un.isAxiosError(t))return oe(t);if(!t.response)return new je("api_error",null,t.message,t);let{type:e,message:o,error:r}=t.response.data;return new je(e||"ApiError",t.response.status,o||r,t)},oe=t=>t instanceof ne?t:t instanceof Error?new y(t.message,t):new y(`Internal error: ${t}`);var vr=()=>"/api/v1/sessions",Cr=()=>"/api/v1/sessions/logout",br=()=>"/api/v1/sessions/fork",xr=()=>"/api/v1/siwe/init",Er=()=>"/api/v1/siwe/authenticate",Lr=()=>"/api/v1/siwe/link",Ar=()=>"/api/v1/passwordless/init",_r=()=>"/api/v1/passwordless/authenticate",Pr=()=>"/api/v1/passwordless/link",Sr=()=>"/api/v1/passwordless_sms/init",kr=()=>"/api/v1/passwordless_sms/authenticate",Tr=()=>"/api/v1/passwordless_sms/link",Wr=()=>"/api/v1/oauth/init",Ir=()=>"/api/v1/oauth/authenticate",Rr=()=>"/api/v1/oauth/link",Mr=()=>"/api/v1/siwe/unlink",Nr=()=>"/api/v1/passwordless/unlink",Or=()=>"/api/v1/passwordless_sms/unlink",Ur=()=>"/api/v1/oauth/unlink";var ft=class{constructor(e){this.meta={email:e}}async authenticate(){if(!this.api)throw new y("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new y("Email and email code must be set prior to calling authenticate.");try{let e=_r(),o=await this.api.post(e,{email:this.meta.email,code:this.meta.emailCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(e){throw U(e)}}async link(){if(!this.api)throw new y("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new y("Email and email code must be set prior to calling authenticate.");try{let e=Pr();return(await this.api.post(e,{email:this.meta.email,code:this.meta.emailCode})).data}catch(e){throw U(e)}}async sendCodeEmail(e){if(!this.api)throw new y("Auth flow has no API instance");if(e&&(this.meta.email=e),!this.meta.email)throw new y("Email must be set when initialzing authentication.");try{let o=Ar();return(await this.api.post(o,{email:this.meta.email})).data}catch(o){throw U(o)}}};var Ze=class{constructor(e,o,r){this.meta={provider:e},this.meta.authorizationCode=o,this.meta.stateCode=r}isActive(){return!!(this.meta.authorizationCode&&this.meta.stateCode&&this.meta.provider)}async authenticate(){if(!this.api)throw new y("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new y("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if(this.meta.authorizationCode==="undefined")throw new y("User denied confirmation during OAuth flow");try{let e=Ir(),o=await this.api.post(e,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(e){throw U(e)}}async link(){if(!this.api)throw new y("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new y("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if(this.meta.authorizationCode==="undefined")throw new y("User denied confirmation during OAuth flow");try{let e=Rr();return(await this.api.post(e,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode})).data}catch(e){throw U(e)}}async getAuthorizationUrl(){if(!this.api)throw new y("Auth flow has no API instance");if(!this.meta.provider)throw new y("Provider must be set when initialzing OAuth authentication.");try{let e=Wr();return(await this.api.post(e,{provider:this.meta.provider,redirect_to:window.location.href})).data}catch(e){throw U(e)}}};var gt=class{constructor(e,o){this.meta={walletType:o},this.connectors=e,this.walletConnector=this.connectors.createWalletConnector(o,null)}async authenticate(){if(!this.api)throw new y("Auth flow has no API instance");try{let{message:e,signature:o}=await this.promptConnectAndSign(this.api),r=await this.api.post(Er(),{message:e,signature:o});return this.connectors.addWalletConnector(this.walletConnector),await this.connectors.setActiveWallet(this.walletConnector.address)||console.warn("Failed to set active wallet"),{user:r.data.user,token:r.data.token,refresh_token:r.data.refresh_token,is_new_user:r.data.is_new_user}}catch(e){throw U(e)}}async link(){if(!this.api)throw new y("Auth flow has no API instance");try{let{message:e,signature:o}=await this.promptConnectAndSign(this.api),r=await this.api.post(Lr(),{message:e,signature:o});return this.connectors.addWalletConnector(this.walletConnector),await this.connectors.setActiveWallet(this.walletConnector.address)||console.warn("Failed to set active wallet"),r.data}catch(e){throw U(e)}}async promptConnectAndSign(e){let o=await this.walletConnector.connect({showPrompt:!0}),r=o.address,i=o.chainId,n=await e.post(xr(),{address:r}),s=this.walletConnector.prepareMessage(i,r,n.data.nonce),a=await this.walletConnector.sign(s);return{message:s,signature:a}}};var yt=class{constructor(e){this.meta={phoneNumber:e}}async authenticate(){if(!this.api)throw new y("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new y("phone number and sms code must be set prior to calling authenticate.");try{let e=kr(),o=await this.api.post(e,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(e){throw U(e)}}async link(){if(!this.api)throw new y("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new y("phone number and sms code must be set prior to calling authenticate.");try{let e=Tr();return(await this.api.post(e,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})).data}catch(e){throw U(e)}}async sendSmsCode(e){if(!this.api)throw new y("Auth flow has no API instance");if(e&&(this.meta.phoneNumber=e),!this.meta.phoneNumber)throw new y("phone nNumber must be set when initialzing authentication.");try{let o=Sr();return(await this.api.post(o,{phoneNumber:this.meta.phoneNumber})).data}catch(o){throw U(o)}}};import{getAddress as es}from"@ethersproject/address";var Dr="1.17.0";var Fr="https://api.privy.io/v0",Po=process.env.NEXT_PUBLIC_PRIVY_AUTH_URL||"https://auth.privy.io",wt="4df5e2316331463a9130964bd6078dfa",Gr=1e4,re=1400,So=Dr;var qe="privy:token",Ut="privy:refresh_token",Dt="privy:connectors",Br="walletconnect",ko=3e4;var To=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]}getKeys(){return Object.keys(this._cache)}},Wo=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)}getKeys(){return Object.entries(localStorage).map(([e])=>e)}};function Fn(){return typeof window<"u"&&window.localStorage?new Wo:new To}var Z=Fn();import Zn from"@coinbase/wallet-sdk";import{getAddress as qn}from"@ethersproject/address";import{getAddress as $n}from"@ethersproject/address";import{Web3Provider as jn}from"@ethersproject/providers";import{ErrorCode as Gn}from"@ethersproject/logger";var Ke=class extends B{constructor(){super("Wallet timeout");this.type="wallet_error"}},Pe=t=>{if(t instanceof B)return t;if((t==null?void 0:t.code)&&(t==null?void 0:t.reason)){let e=new Je(t);return t.code===Gn.ACTION_REJECTED&&(e.details=Ue.E4001_USER_REJECTED_REQUEST),e}return t!=null&&t.code?new Je(t):new B("Unknown connector error",t)},Io=class extends ne{constructor(o,r,i){super(o);this.type="provider_error";this.code=r,this.data=i}},Je=class extends Io{constructor(o){var n,s,a;let r=o;super(r.message,r.code,r.data);let i=Object.values(Ue).find(p=>p.eipCode===r.code);this.details=i||Ue.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=Ue.E32002_CONNECTION_ALREADY_PENDING:this.details=Ue.E32002_REQUEST_ALREADY_PENDING:(a=r.message)!=null&&a.includes("Already processing")&&r.message.includes("eth_requestAccounts")&&(this.details=Ue.E32002_WALLET_LOCKED))}},Bn={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}},Vn={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}},Hn={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}},Ue={UNKNOWN_ERROR:{eipCode:0,message:"Unknown error",detail:"Unknown error",retryable:!0},...Hn,...Vn},Ye={...Bn,...Ue};var zn=12e4,Ro=(t=new Ke,e=zn)=>new Promise((o,r)=>setTimeout(()=>{r(t)},e)),de=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})}async request(e){if(!this.walletProvider)throw new B(`A wallet request of type ${e.method} was made before setting a wallet provider.`);return Promise.race([this.walletProvider.request(e),Ro()]).catch(o=>{throw Pe(o)})}},fe=class extends de{constructor(o){super(o)}},Ft=class extends de{constructor(e){super(e)}sendAsync(e,o){throw new Error("sendAsync is no longer supported by EIP-1193. Use the request method instead.")}};var ge=class{constructor(e,o,r){this.createSiweMessage=(e,o,r,i,n,s,a)=>`${r} wants you to sign in with your Ethereum account:
|
|
1
|
+
import{Web3Provider as u1}from"@ethersproject/providers";import{useEffect as Nn,useState as te}from"react";import Un from"axios";var ne=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}]`:""}`}},je=class extends ne{constructor(o,r,i,n){super(i,n);this.type=o;this.status=r}},y=class extends ne{constructor(o,r){super(o,r);this.type="client_error"}};var B=class extends ne{constructor(o,r){super(o,r);this.type="connector_error"}},U=t=>{if(t instanceof ne)return t;if(!Un.isAxiosError(t))return oe(t);if(!t.response)return new je("api_error",null,t.message,t);let{type:e,message:o,error:r}=t.response.data;return new je(e||"ApiError",t.response.status,o||r,t)},oe=t=>t instanceof ne?t:t instanceof Error?new y(t.message,t):new y(`Internal error: ${t}`);var vr=()=>"/api/v1/sessions",Cr=()=>"/api/v1/sessions/logout",br=()=>"/api/v1/sessions/fork",xr=()=>"/api/v1/siwe/init",Er=()=>"/api/v1/siwe/authenticate",Lr=()=>"/api/v1/siwe/link",Ar=()=>"/api/v1/passwordless/init",_r=()=>"/api/v1/passwordless/authenticate",Pr=()=>"/api/v1/passwordless/link",Sr=()=>"/api/v1/passwordless_sms/init",kr=()=>"/api/v1/passwordless_sms/authenticate",Tr=()=>"/api/v1/passwordless_sms/link",Wr=()=>"/api/v1/oauth/init",Ir=()=>"/api/v1/oauth/authenticate",Rr=()=>"/api/v1/oauth/link",Mr=()=>"/api/v1/siwe/unlink",Nr=()=>"/api/v1/passwordless/unlink",Or=()=>"/api/v1/passwordless_sms/unlink",Ur=()=>"/api/v1/oauth/unlink";var ft=class{constructor(e){this.meta={email:e}}async authenticate(){if(!this.api)throw new y("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new y("Email and email code must be set prior to calling authenticate.");try{let e=_r(),o=await this.api.post(e,{email:this.meta.email,code:this.meta.emailCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(e){throw U(e)}}async link(){if(!this.api)throw new y("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new y("Email and email code must be set prior to calling authenticate.");try{let e=Pr();return(await this.api.post(e,{email:this.meta.email,code:this.meta.emailCode})).data}catch(e){throw U(e)}}async sendCodeEmail(e){if(!this.api)throw new y("Auth flow has no API instance");if(e&&(this.meta.email=e),!this.meta.email)throw new y("Email must be set when initialzing authentication.");try{let o=Ar();return(await this.api.post(o,{email:this.meta.email})).data}catch(o){throw U(o)}}};var Ze=class{constructor(e,o,r){this.meta={provider:e},this.meta.authorizationCode=o,this.meta.stateCode=r}isActive(){return!!(this.meta.authorizationCode&&this.meta.stateCode&&this.meta.provider)}async authenticate(){if(!this.api)throw new y("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new y("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if(this.meta.authorizationCode==="undefined")throw new y("User denied confirmation during OAuth flow");try{let e=Ir(),o=await this.api.post(e,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(e){throw U(e)}}async link(){if(!this.api)throw new y("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new y("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if(this.meta.authorizationCode==="undefined")throw new y("User denied confirmation during OAuth flow");try{let e=Rr();return(await this.api.post(e,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode})).data}catch(e){throw U(e)}}async getAuthorizationUrl(){if(!this.api)throw new y("Auth flow has no API instance");if(!this.meta.provider)throw new y("Provider must be set when initialzing OAuth authentication.");try{let e=Wr();return(await this.api.post(e,{provider:this.meta.provider,redirect_to:window.location.href})).data}catch(e){throw U(e)}}};var gt=class{constructor(e,o){this.meta={walletType:o},this.connectors=e,this.walletConnector=this.connectors.createWalletConnector(o,null)}async authenticate(){if(!this.api)throw new y("Auth flow has no API instance");try{let{message:e,signature:o}=await this.promptConnectAndSign(this.api),r=await this.api.post(Er(),{message:e,signature:o});return this.connectors.addWalletConnector(this.walletConnector),await this.connectors.setActiveWallet(this.walletConnector.address)||console.warn("Failed to set active wallet"),{user:r.data.user,token:r.data.token,refresh_token:r.data.refresh_token,is_new_user:r.data.is_new_user}}catch(e){throw U(e)}}async link(){if(!this.api)throw new y("Auth flow has no API instance");try{let{message:e,signature:o}=await this.promptConnectAndSign(this.api),r=await this.api.post(Lr(),{message:e,signature:o});return this.connectors.addWalletConnector(this.walletConnector),await this.connectors.setActiveWallet(this.walletConnector.address)||console.warn("Failed to set active wallet"),r.data}catch(e){throw U(e)}}async promptConnectAndSign(e){let o=await this.walletConnector.connect({showPrompt:!0}),r=o.address,i=o.chainId,n=await e.post(xr(),{address:r}),s=this.walletConnector.prepareMessage(i,r,n.data.nonce),a=await this.walletConnector.sign(s);return{message:s,signature:a}}};var yt=class{constructor(e){this.meta={phoneNumber:e}}async authenticate(){if(!this.api)throw new y("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new y("phone number and sms code must be set prior to calling authenticate.");try{let e=kr(),o=await this.api.post(e,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(e){throw U(e)}}async link(){if(!this.api)throw new y("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new y("phone number and sms code must be set prior to calling authenticate.");try{let e=Tr();return(await this.api.post(e,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})).data}catch(e){throw U(e)}}async sendSmsCode(e){if(!this.api)throw new y("Auth flow has no API instance");if(e&&(this.meta.phoneNumber=e),!this.meta.phoneNumber)throw new y("phone nNumber must be set when initialzing authentication.");try{let o=Sr();return(await this.api.post(o,{phoneNumber:this.meta.phoneNumber})).data}catch(o){throw U(o)}}};import{getAddress as es}from"@ethersproject/address";var Dr="1.17.1";var Fr="https://api.privy.io/v0",Po=process.env.NEXT_PUBLIC_PRIVY_AUTH_URL||"https://auth.privy.io",wt="4df5e2316331463a9130964bd6078dfa",Gr=1e4,re=1400,So=Dr;var qe="privy:token",Ut="privy:refresh_token",Dt="privy:connectors",Br="walletconnect",ko=3e4;var To=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]}getKeys(){return Object.keys(this._cache)}},Wo=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)}getKeys(){return Object.entries(localStorage).map(([e])=>e)}};function Fn(){return typeof window<"u"&&window.localStorage?new Wo:new To}var Z=Fn();import Zn from"@coinbase/wallet-sdk";import{getAddress as qn}from"@ethersproject/address";import{getAddress as $n}from"@ethersproject/address";import{Web3Provider as jn}from"@ethersproject/providers";import{ErrorCode as Gn}from"@ethersproject/logger";var Ke=class extends B{constructor(){super("Wallet timeout");this.type="wallet_error"}},Pe=t=>{if(t instanceof B)return t;if((t==null?void 0:t.code)&&(t==null?void 0:t.reason)){let e=new Je(t);return t.code===Gn.ACTION_REJECTED&&(e.details=Ue.E4001_USER_REJECTED_REQUEST),e}return t!=null&&t.code?new Je(t):new B("Unknown connector error",t)},Io=class extends ne{constructor(o,r,i){super(o);this.type="provider_error";this.code=r,this.data=i}},Je=class extends Io{constructor(o){var n,s,a;let r=o;super(r.message,r.code,r.data);let i=Object.values(Ue).find(p=>p.eipCode===r.code);this.details=i||Ue.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=Ue.E32002_CONNECTION_ALREADY_PENDING:this.details=Ue.E32002_REQUEST_ALREADY_PENDING:(a=r.message)!=null&&a.includes("Already processing")&&r.message.includes("eth_requestAccounts")&&(this.details=Ue.E32002_WALLET_LOCKED))}},Bn={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}},Vn={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}},Hn={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}},Ue={UNKNOWN_ERROR:{eipCode:0,message:"Unknown error",detail:"Unknown error",retryable:!0},...Hn,...Vn},Ye={...Bn,...Ue};var zn=12e4,Ro=(t=new Ke,e=zn)=>new Promise((o,r)=>setTimeout(()=>{r(t)},e)),de=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})}async request(e){if(!this.walletProvider)throw new B(`A wallet request of type ${e.method} was made before setting a wallet provider.`);return Promise.race([this.walletProvider.request(e),Ro()]).catch(o=>{throw Pe(o)})}},fe=class extends de{constructor(o){super(o)}},Ft=class extends de{constructor(e){super(e)}sendAsync(e,o){throw new Error("sendAsync is no longer supported by EIP-1193. Use the request method instead.")}};var ge=class{constructor(e,o,r){this.createSiweMessage=(e,o,r,i,n,s,a)=>`${r} wants you to sign in with your Ethereum account:
|
|
2
2
|
${o}
|
|
3
3
|
|
|
4
4
|
${a}
|
|
@@ -215,7 +215,7 @@ Resources:
|
|
|
215
215
|
border-color: var(--light-theme-bg-3);
|
|
216
216
|
border-width: 1px;
|
|
217
217
|
}
|
|
218
|
-
`;import{Fragment as zo,jsx as X,jsxs as Ge}from"react/jsx-runtime";var $o=6,Ci=new Array($o).fill(""),Ss=1400;var bi=()=>{var P,ie,Ae;let{app:t,data:e,navigate:o,setModalData:r}=v(),{closePrivyModal:i,resendEmailCode:n,resendSmsCode:s,getAuthMeta:a,loginWithCode:p}=_(),{authenticated:u,user:x}=z(),[L,
|
|
218
|
+
`;import{Fragment as zo,jsx as X,jsxs as Ge}from"react/jsx-runtime";var $o=6,Ci=new Array($o).fill(""),Ss=1400;var bi=()=>{var P,ie,Ae;let{app:t,data:e,navigate:o,setModalData:r}=v(),{closePrivyModal:i,resendEmailCode:n,resendSmsCode:s,getAuthMeta:a,loginWithCode:p}=_(),{authenticated:u,user:x}=z(),[L,f]=Xt(Ci),[g,m]=Xt(!1),[c,S]=Xt(null),[M,k]=Xt(null),b=(P=a())!=null&&P.email?0:1;vi(()=>{var R;if(!(u&&g&&x))return;if(((R=e==null?void 0:e.login)==null?void 0:R.promptCreatePrivyWalletFlow)&&!x.wallet){let ce=setTimeout(()=>{r({createWallet:{onSuccess:()=>i({shouldCallAuthOnSuccess:!0}),onFailure:Oe=>console.error(Oe)}}),o("EMBEDDED_WALLET_SCREEN")},re-500);return()=>clearTimeout(ce)}else{let ce=setTimeout(i,re);return()=>clearTimeout(ce)}},[u,g,x]),vi(()=>{if(c&&M===0){let D=setTimeout(()=>{f(Ci),S(null);let F=document.querySelector("input[name=code-0]");F==null||F.focus()},Ss);return()=>clearTimeout(D)}},[c]);let W=D=>{var _o;let F=D.currentTarget.value.replace(" ","");if(F==="")return;if(isNaN(Number(F))){S("Code should be numeric"),k(1);return}S(null),k(null);let R=Number((_o=D.currentTarget.name)==null?void 0:_o.charAt(5)),ce=[...F||[""]].slice(0,$o-R),Oe=[...L.slice(0,R),...ce,...L.slice(R+ce.length)];f(Oe);let mt=ce.length,Ot=Math.min(Math.max(R+mt,0),$o-1);if(!isNaN(Number(D.currentTarget.value))){let H=document.querySelector(`input[name=code-${Ot}]`);H==null||H.focus()}if(Oe.every(H=>H&&!isNaN(+H))){let H=document.querySelector(`input[name=code-${Ot}]`);H==null||H.blur(),p(Oe.join("")).then(()=>m(!0)).catch(l=>{(l==null?void 0:l.status)===422?S("Invalid or expired verification code"):S("Issue verifying code"),k(0)})}D.preventDefault()},G=D=>{M===1&&(S(null),k(null));let F=[...L.slice(0,D),"",...L.slice(D+1)];if(f(F),D>0){let R=document.querySelector(`input[name=code-${D-1}]`);R==null||R.focus()}},K=`Verify your ${b==0?"email":"phone"}`,I=b==0?Ge("p",{children:["Please check ",X(Rs,{children:(ie=a())==null?void 0:ie.email})," for an email from privy.io and enter your code below."]}):`Please check ${(Ae=a())==null?void 0:Ae.phoneNumber} for a message from ${(t==null?void 0:t.name)||"privy.io"} and enter your code below.`;return Ge(zo,{children:[X(A,{},"header"),Ge(ks,{children:[X(Y,{title:K,description:I}),Ge(pi,{children:[Ge(Ts,{children:[X(Ws,{fail:!!c,success:g,children:X("span",{children:c||(g?"Success!":"")})}),X("div",{children:L.map((D,F)=>X("input",{name:`code-${F}`,type:"text",value:L[F],onChange:W,onKeyUp:R=>{R.key==="Backspace"&&G(F)},inputMode:"numeric",autoFocus:F===0,pattern:"[0-9]",className:`${g?"success":""} ${c?"fail":""}`,autoComplete:Ps?"one-time-code":"off"},F))})]}),X(Is,{children:b==0?Ge(zo,{children:[X("span",{children:"Didn't get an email?"}),X("button",{onClick:n,children:"Resend Code"})]}):Ge(zo,{children:[X("span",{children:"Didn't get a message?"}),X("button",{onClick:s,children:"Resend Code"})]})})]})]}),X($,{protectedByPrivy:!0})]})},ks=xt.div`
|
|
219
219
|
display: flex;
|
|
220
220
|
flex-direction: column;
|
|
221
221
|
align-items: flex-start;
|
|
@@ -361,7 +361,7 @@ Resources:
|
|
|
361
361
|
|
|
362
362
|
transition: border-color 350ms ease;
|
|
363
363
|
}
|
|
364
|
-
`;import{jsx as xi,jsxs as Ds}from"react/jsx-runtime";var ue=({style:t,...e})=>Ds("svg",{width:"1024",height:"1024",viewBox:"0 0 1024 1024",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...t},...e,children:[xi("rect",{width:"1024",height:"1024",fill:"#0052FF",rx:100,ry:100}),xi("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z",fill:"white"})]});import{jsx as Q,jsxs as Fs}from"react/jsx-runtime";var he=({style:t,...e})=>Fs("svg",{width:"28",height:"28",viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...t},...e,children:[Q("rect",{width:"28",height:"28",rx:"6",fill:"white"}),Q("path",{d:"M23.0126 5L15.1958 10.7823L16.6533 7.37359L23.0126 5Z",fill:"#E17726",stroke:"#E17726",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"}),Q("path",{d:"M4.98753 5L12.7329 10.8299L11.3468 7.37954L4.98753 5ZM20.1987 18.4027L18.1166 21.5794L22.5723 22.8049L23.8454 18.4741L20.1987 18.4027ZM4.16064 18.4741L5.42775 22.8049L9.87153 21.5794L7.80133 18.4027L4.16064 18.4741Z",fill:"#E27625",stroke:"#E27625",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"}),Q("path",{d:"M9.6336 13.0369L8.39624 14.9049L12.7984 15.1071L12.6556 10.3659L9.6336 13.0429V13.0369ZM18.3665 13.0429L15.2969 10.3064L15.1958 15.1071L19.5979 14.9049L18.3665 13.0429ZM9.87155 21.5794L12.5426 20.2945L10.2463 18.5098L9.87155 21.5794ZM15.4635 20.2886L18.1166 21.5794L17.7597 18.5039L15.4635 20.2886Z",fill:"#E27625",stroke:"#E27625",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"}),Q("path",{d:"M18.1167 21.5794L15.4635 20.2944L15.6776 22.0196L15.6539 22.7513L18.1167 21.5794ZM9.87158 21.5794L12.3463 22.7513L12.3285 22.0196L12.5426 20.2944L9.87158 21.5794Z",fill:"#D5BFB2",stroke:"#D5BFB2",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"}),Q("path",{d:"M12.3878 17.3616L10.1868 16.7191L11.7454 16.0052L12.3938 17.3616H12.3878ZM15.6062 17.3616L16.2605 15.9993L17.8251 16.7131L15.6062 17.3675V17.3616Z",fill:"#233447",stroke:"#233447",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"}),Q("path",{d:"M9.87147 21.5794L10.2581 18.4027L7.80127 18.4741L9.87147 21.5794ZM17.7418 18.4027L18.1166 21.5794L20.1987 18.4741L17.7418 18.4027ZM19.6038 14.9048L15.2016 15.107L15.6061 17.3676L16.2605 15.9994L17.8251 16.7132L19.6038 14.9048ZM10.1868 16.7192L11.7454 16.0053L12.3938 17.3617L12.8042 15.1011L8.4021 14.9048L10.1868 16.7192Z",fill:"#CC6228",stroke:"#CC6228",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"}),Q("path",{d:"M8.4021 14.9048L10.2462 18.5038L10.1868 16.7192L8.4021 14.9048ZM17.8251 16.7192L17.7537 18.5038L19.5978 14.9048L17.8251 16.7192ZM12.8042 15.107L12.3878 17.3676L12.9113 20.0327L13.0303 16.5169L12.8042 15.107ZM15.1957 15.107L14.9815 16.511L15.0886 20.0327L15.6061 17.3617L15.1957 15.1011V15.107Z",fill:"#E27525",stroke:"#E27525",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"}),Q("path",{d:"M15.6062 17.3617L15.0887 20.0327L15.4635 20.2945L17.7538 18.5098L17.8252 16.7192L15.6062 17.3617ZM10.1869 16.7192L10.2463 18.5039L12.5426 20.2885L12.9114 20.0327L12.3939 17.3617L10.1809 16.7192H10.1869Z",fill:"#F5841F",stroke:"#F5841F",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"}),Q("path",{d:"M15.6598 22.7513L15.6776 22.0196L15.4754 21.853H12.5248L12.3285 22.0196L12.3463 22.7513L9.87158 21.5793L10.7401 22.2932L12.495 23.5008H15.4992L17.26 22.2873L18.1167 21.5793L15.6539 22.7513H15.6598Z",fill:"#C0AC9D",stroke:"#C0AC9D",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"}),Q("path",{d:"M15.4634 20.2885L15.0886 20.0327H12.9114L12.5425 20.2945L12.3284 22.0196L12.5247 21.8531H15.4753L15.6776 22.0196L15.4634 20.2945V20.2885Z",fill:"#161616",stroke:"#161616",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"}),Q("path",{d:"M23.3456 11.1571L24 7.97442L23.0125 5L15.4575 10.5919L18.3664 13.0369L22.4711 14.2326L23.3754 13.1797L22.9827 12.8941L23.6074 12.323L23.1315 11.9542L23.7561 11.4783L23.3397 11.1571H23.3456ZM4 7.96847L4.66627 11.1571L4.23795 11.4723L4.87448 11.9482L4.39857 12.323L5.01725 12.8941L4.62463 13.1797L5.52885 14.2326L9.63355 13.0428L12.5425 10.586L4.98751 5L4 7.96847Z",fill:"#763E1A",stroke:"#763E1A",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"}),Q("path",{d:"M22.4712 14.2325L18.3665 13.0428L19.6038 14.9048L17.7597 18.5038L20.1987 18.4741H23.8454L22.4712 14.2325ZM9.63358 13.0368L5.52888 14.2325L4.16064 18.4741H7.80728L10.2463 18.5038L8.40217 14.9048L9.63953 13.0368H9.63358ZM15.1957 15.107L15.4634 10.5859L16.6532 7.37354H11.3468L12.5366 10.5859L12.8043 15.107L12.9054 16.5229V20.0327H15.0887L15.1006 16.5229L15.1957 15.107Z",fill:"#F5841F",stroke:"#F5841F",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as rt,jsxs as Gs}from"react/jsx-runtime";var it=({style:t,...e})=>Gs("svg",{width:"28",height:"28",viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...t},...e,children:[rt("rect",{width:"28",height:"28",rx:"6",fill:"#141414"}),rt("g",{clipPath:"url(#clip0_1765_9946)",children:rt("path",{d:"M8.09448 10.3941C11.3558 7.20196 16.6442 7.20196 19.9055 10.3941L20.2982 10.7782C20.3369 10.8157 20.3677 10.8606 20.3887 10.9102C20.4097 10.9599 20.4206 11.0132 20.4206 11.0671C20.4206 11.121 20.4097 11.1744 20.3887 11.224C20.3677 11.2737 20.3369 11.3186 20.2982 11.3561L18.9554 12.6702C18.9158 12.7086 18.8628 12.7301 18.8077 12.7301C18.7526 12.7301 18.6996 12.7086 18.66 12.6702L18.1198 12.1415C15.8448 9.91503 12.1557 9.91503 9.88015 12.1415L9.30167 12.7075C9.26207 12.7459 9.20909 12.7673 9.15395 12.7673C9.0988 12.7673 9.04582 12.7459 9.00622 12.7075L7.66346 11.3934C7.62475 11.3559 7.59397 11.3109 7.57295 11.2613C7.55193 11.2117 7.5411 11.1583 7.5411 11.1044C7.5411 11.0505 7.55193 10.9971 7.57295 10.9475C7.59397 10.8979 7.62475 10.8529 7.66346 10.8154L8.09448 10.3941ZM22.6829 13.1115L23.8776 14.2814C23.9163 14.319 23.9471 14.3639 23.9681 14.4135C23.9892 14.4632 24 14.5165 24 14.5704C24 14.6243 23.9892 14.6777 23.9681 14.7273C23.9471 14.777 23.9163 14.8219 23.8776 14.8594L18.4893 20.1332C18.4102 20.2101 18.3042 20.2531 18.1938 20.2531C18.0835 20.2531 17.9775 20.2101 17.8984 20.1332L14.0743 16.3901C14.0545 16.3708 14.0279 16.36 14.0003 16.36C13.9726 16.36 13.9461 16.3708 13.9263 16.3901L10.1021 20.1332C10.023 20.2101 9.91703 20.2531 9.8067 20.2531C9.69636 20.2531 9.59038 20.2101 9.51124 20.1332L4.12236 14.8594C4.08365 14.8219 4.05287 14.777 4.03185 14.7273C4.01083 14.6777 4 14.6243 4 14.5704C4 14.5165 4.01083 14.4632 4.03185 14.4135C4.05287 14.3639 4.08365 14.319 4.12236 14.2814L5.31767 13.1115C5.39678 13.0348 5.50265 12.9919 5.61285 12.9919C5.72305 12.9919 5.82892 13.0348 5.90803 13.1115L9.73216 16.8546C9.75194 16.874 9.7785 16.8848 9.80616 16.8848C9.83381 16.8848 9.86037 16.874 9.88015 16.8546L13.7043 13.1115C13.7834 13.0346 13.8894 12.9916 13.9997 12.9916C14.1101 12.9916 14.216 13.0346 14.2952 13.1115L18.1198 16.8546C18.1396 16.874 18.1662 16.8848 18.1938 16.8848C18.2215 16.8848 18.2481 16.874 18.2678 16.8546L22.092 13.1115C22.1711 13.0346 22.2771 12.9916 22.3874 12.9916C22.4977 12.9916 22.6037 13.0346 22.6829 13.1115Z",fill:"white"})}),rt("defs",{children:rt("clipPath",{id:"clip0_1765_9946",children:rt("rect",{width:"20",height:"12.2531",fill:"white",transform:"translate(4 8)"})})})]});import{Fragment as zs,jsx as xe,jsxs as Qt}from"react/jsx-runtime";var qo=2,Li={metamask:{name:"MetaMask",component:he},coinbase_wallet:{name:"Coinbase Wallet",component:ue},wallet_connect:{name:"WalletConnect",component:it}},Ai=()=>{var K;let[t,e]=Lt(!1),[o,r]=Lt("metamask"),[i,n]=Lt(void 0),{navigate:s,navigateBack:a}=v(),{getAuthMeta:p,closePrivyModal:u,loginWithWallet:x}=_(),{walletConnectors:L}=z(),[m,g]=Lt(0),{user:f}=z(),[c]=Lt((f==null?void 0:f.linkedAccounts.length)||0);Ei(()=>{var I;r(((I=p())==null?void 0:I.walletType)||"metamask"),n(void 0),x().then(()=>e(!0)).catch(P=>{P instanceof ne?console.error(P.cause):console.error(P);let ie=(P==null?void 0:P.status)===401&&(P==null?void 0:P.message)==="User is not allowed to login to this app.";(P==null?void 0:P.status)===422?n(Ye.ERROR_USER_EXISTS):ie?s("ALLOWLIST_REJECTION_SCREEN"):P instanceof Je&&!P.details.default?n(P.details):P instanceof Ke?n(Ye.ERROR_TIMED_OUT):n(Ye.ERROR_WALLET_CONNECTION)})},[m]),Ei(()=>{if(t){let I=setTimeout(u,re);return()=>clearTimeout(I)}},[f]);let S=Li[o].name,M=Li[o].component,k=t?`Successfully connected with ${S}`:i?i.message:`Waiting for ${S}`,b="";if(t){let I=(f==null?void 0:f.linkedAccounts.length)||0;c===I?b="Wallet was already linked.":b="You\u2019re good to go!"}else if(m>=qo&&i)b="Unable to connect wallet";else if(i)b=i.detail;else switch(b="Don\u2019t see your wallet modal? Check your other browser windows.",o){case"metamask":b="For the best experience, connect only one wallet at a time.";break;case"wallet_connect":b="Open your mobile wallet app to continue";break;case"coinbase_wallet":$t()||(Uo(f)?b="Continue with the Coinbase app. Not the right wallet? Reset your connection below.":b="Open the Coinbase app on your phone to continue.");break}let W=(K=L==null?void 0:L.walletConnectors)==null?void 0:K.find(I=>I.walletType==="coinbase_wallet"),G=o==="coinbase_wallet"&&(Uo(f)||i===Ye.ERROR_USER_EXISTS);return Qt(zs,{children:[xe(A,{backFn:a}),Qt(Bs,{children:[xe(Hs,{children:Qt("div",{children:[xe(ot,{success:t,fail:!!i}),xe(M,{style:{width:"38px",height:"38px"}})]})}),Qt(Vs,{children:[xe("h3",{children:k}),xe("p",{children:b})]}),G?xe(Ko,{onClick:()=>W&&(W==null?void 0:W.disconnect()),visible:!t,disabled:t,children:"Use a different wallet"}):i==Ye.ERROR_USER_EXISTS?xe(Ko,{onClick:a,visible:!0,children:"Use a different wallet"}):xe(Ko,{onClick:()=>{g(m+1),n(void 0)},visible:!t&&(i==null?void 0:i.retryable)&&m<qo,disabled:!t&&(!(i!=null&&i.retryable)||m>=qo),children:"Retry"})]})]})},Bs=eo.div`
|
|
364
|
+
`;import{jsx as xi,jsxs as Ds}from"react/jsx-runtime";var ue=({style:t,...e})=>Ds("svg",{width:"1024",height:"1024",viewBox:"0 0 1024 1024",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...t},...e,children:[xi("rect",{width:"1024",height:"1024",fill:"#0052FF",rx:100,ry:100}),xi("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z",fill:"white"})]});import{jsx as Q,jsxs as Fs}from"react/jsx-runtime";var he=({style:t,...e})=>Fs("svg",{width:"28",height:"28",viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...t},...e,children:[Q("rect",{width:"28",height:"28",rx:"6",fill:"white"}),Q("path",{d:"M23.0126 5L15.1958 10.7823L16.6533 7.37359L23.0126 5Z",fill:"#E17726",stroke:"#E17726",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"}),Q("path",{d:"M4.98753 5L12.7329 10.8299L11.3468 7.37954L4.98753 5ZM20.1987 18.4027L18.1166 21.5794L22.5723 22.8049L23.8454 18.4741L20.1987 18.4027ZM4.16064 18.4741L5.42775 22.8049L9.87153 21.5794L7.80133 18.4027L4.16064 18.4741Z",fill:"#E27625",stroke:"#E27625",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"}),Q("path",{d:"M9.6336 13.0369L8.39624 14.9049L12.7984 15.1071L12.6556 10.3659L9.6336 13.0429V13.0369ZM18.3665 13.0429L15.2969 10.3064L15.1958 15.1071L19.5979 14.9049L18.3665 13.0429ZM9.87155 21.5794L12.5426 20.2945L10.2463 18.5098L9.87155 21.5794ZM15.4635 20.2886L18.1166 21.5794L17.7597 18.5039L15.4635 20.2886Z",fill:"#E27625",stroke:"#E27625",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"}),Q("path",{d:"M18.1167 21.5794L15.4635 20.2944L15.6776 22.0196L15.6539 22.7513L18.1167 21.5794ZM9.87158 21.5794L12.3463 22.7513L12.3285 22.0196L12.5426 20.2944L9.87158 21.5794Z",fill:"#D5BFB2",stroke:"#D5BFB2",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"}),Q("path",{d:"M12.3878 17.3616L10.1868 16.7191L11.7454 16.0052L12.3938 17.3616H12.3878ZM15.6062 17.3616L16.2605 15.9993L17.8251 16.7131L15.6062 17.3675V17.3616Z",fill:"#233447",stroke:"#233447",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"}),Q("path",{d:"M9.87147 21.5794L10.2581 18.4027L7.80127 18.4741L9.87147 21.5794ZM17.7418 18.4027L18.1166 21.5794L20.1987 18.4741L17.7418 18.4027ZM19.6038 14.9048L15.2016 15.107L15.6061 17.3676L16.2605 15.9994L17.8251 16.7132L19.6038 14.9048ZM10.1868 16.7192L11.7454 16.0053L12.3938 17.3617L12.8042 15.1011L8.4021 14.9048L10.1868 16.7192Z",fill:"#CC6228",stroke:"#CC6228",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"}),Q("path",{d:"M8.4021 14.9048L10.2462 18.5038L10.1868 16.7192L8.4021 14.9048ZM17.8251 16.7192L17.7537 18.5038L19.5978 14.9048L17.8251 16.7192ZM12.8042 15.107L12.3878 17.3676L12.9113 20.0327L13.0303 16.5169L12.8042 15.107ZM15.1957 15.107L14.9815 16.511L15.0886 20.0327L15.6061 17.3617L15.1957 15.1011V15.107Z",fill:"#E27525",stroke:"#E27525",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"}),Q("path",{d:"M15.6062 17.3617L15.0887 20.0327L15.4635 20.2945L17.7538 18.5098L17.8252 16.7192L15.6062 17.3617ZM10.1869 16.7192L10.2463 18.5039L12.5426 20.2885L12.9114 20.0327L12.3939 17.3617L10.1809 16.7192H10.1869Z",fill:"#F5841F",stroke:"#F5841F",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"}),Q("path",{d:"M15.6598 22.7513L15.6776 22.0196L15.4754 21.853H12.5248L12.3285 22.0196L12.3463 22.7513L9.87158 21.5793L10.7401 22.2932L12.495 23.5008H15.4992L17.26 22.2873L18.1167 21.5793L15.6539 22.7513H15.6598Z",fill:"#C0AC9D",stroke:"#C0AC9D",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"}),Q("path",{d:"M15.4634 20.2885L15.0886 20.0327H12.9114L12.5425 20.2945L12.3284 22.0196L12.5247 21.8531H15.4753L15.6776 22.0196L15.4634 20.2945V20.2885Z",fill:"#161616",stroke:"#161616",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"}),Q("path",{d:"M23.3456 11.1571L24 7.97442L23.0125 5L15.4575 10.5919L18.3664 13.0369L22.4711 14.2326L23.3754 13.1797L22.9827 12.8941L23.6074 12.323L23.1315 11.9542L23.7561 11.4783L23.3397 11.1571H23.3456ZM4 7.96847L4.66627 11.1571L4.23795 11.4723L4.87448 11.9482L4.39857 12.323L5.01725 12.8941L4.62463 13.1797L5.52885 14.2326L9.63355 13.0428L12.5425 10.586L4.98751 5L4 7.96847Z",fill:"#763E1A",stroke:"#763E1A",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"}),Q("path",{d:"M22.4712 14.2325L18.3665 13.0428L19.6038 14.9048L17.7597 18.5038L20.1987 18.4741H23.8454L22.4712 14.2325ZM9.63358 13.0368L5.52888 14.2325L4.16064 18.4741H7.80728L10.2463 18.5038L8.40217 14.9048L9.63953 13.0368H9.63358ZM15.1957 15.107L15.4634 10.5859L16.6532 7.37354H11.3468L12.5366 10.5859L12.8043 15.107L12.9054 16.5229V20.0327H15.0887L15.1006 16.5229L15.1957 15.107Z",fill:"#F5841F",stroke:"#F5841F",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as rt,jsxs as Gs}from"react/jsx-runtime";var it=({style:t,...e})=>Gs("svg",{width:"28",height:"28",viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...t},...e,children:[rt("rect",{width:"28",height:"28",rx:"6",fill:"#141414"}),rt("g",{clipPath:"url(#clip0_1765_9946)",children:rt("path",{d:"M8.09448 10.3941C11.3558 7.20196 16.6442 7.20196 19.9055 10.3941L20.2982 10.7782C20.3369 10.8157 20.3677 10.8606 20.3887 10.9102C20.4097 10.9599 20.4206 11.0132 20.4206 11.0671C20.4206 11.121 20.4097 11.1744 20.3887 11.224C20.3677 11.2737 20.3369 11.3186 20.2982 11.3561L18.9554 12.6702C18.9158 12.7086 18.8628 12.7301 18.8077 12.7301C18.7526 12.7301 18.6996 12.7086 18.66 12.6702L18.1198 12.1415C15.8448 9.91503 12.1557 9.91503 9.88015 12.1415L9.30167 12.7075C9.26207 12.7459 9.20909 12.7673 9.15395 12.7673C9.0988 12.7673 9.04582 12.7459 9.00622 12.7075L7.66346 11.3934C7.62475 11.3559 7.59397 11.3109 7.57295 11.2613C7.55193 11.2117 7.5411 11.1583 7.5411 11.1044C7.5411 11.0505 7.55193 10.9971 7.57295 10.9475C7.59397 10.8979 7.62475 10.8529 7.66346 10.8154L8.09448 10.3941ZM22.6829 13.1115L23.8776 14.2814C23.9163 14.319 23.9471 14.3639 23.9681 14.4135C23.9892 14.4632 24 14.5165 24 14.5704C24 14.6243 23.9892 14.6777 23.9681 14.7273C23.9471 14.777 23.9163 14.8219 23.8776 14.8594L18.4893 20.1332C18.4102 20.2101 18.3042 20.2531 18.1938 20.2531C18.0835 20.2531 17.9775 20.2101 17.8984 20.1332L14.0743 16.3901C14.0545 16.3708 14.0279 16.36 14.0003 16.36C13.9726 16.36 13.9461 16.3708 13.9263 16.3901L10.1021 20.1332C10.023 20.2101 9.91703 20.2531 9.8067 20.2531C9.69636 20.2531 9.59038 20.2101 9.51124 20.1332L4.12236 14.8594C4.08365 14.8219 4.05287 14.777 4.03185 14.7273C4.01083 14.6777 4 14.6243 4 14.5704C4 14.5165 4.01083 14.4632 4.03185 14.4135C4.05287 14.3639 4.08365 14.319 4.12236 14.2814L5.31767 13.1115C5.39678 13.0348 5.50265 12.9919 5.61285 12.9919C5.72305 12.9919 5.82892 13.0348 5.90803 13.1115L9.73216 16.8546C9.75194 16.874 9.7785 16.8848 9.80616 16.8848C9.83381 16.8848 9.86037 16.874 9.88015 16.8546L13.7043 13.1115C13.7834 13.0346 13.8894 12.9916 13.9997 12.9916C14.1101 12.9916 14.216 13.0346 14.2952 13.1115L18.1198 16.8546C18.1396 16.874 18.1662 16.8848 18.1938 16.8848C18.2215 16.8848 18.2481 16.874 18.2678 16.8546L22.092 13.1115C22.1711 13.0346 22.2771 12.9916 22.3874 12.9916C22.4977 12.9916 22.6037 13.0346 22.6829 13.1115Z",fill:"white"})}),rt("defs",{children:rt("clipPath",{id:"clip0_1765_9946",children:rt("rect",{width:"20",height:"12.2531",fill:"white",transform:"translate(4 8)"})})})]});import{Fragment as zs,jsx as xe,jsxs as Qt}from"react/jsx-runtime";var qo=2,Li={metamask:{name:"MetaMask",component:he},coinbase_wallet:{name:"Coinbase Wallet",component:ue},wallet_connect:{name:"WalletConnect",component:it}},Ai=()=>{var K;let[t,e]=Lt(!1),[o,r]=Lt("metamask"),[i,n]=Lt(void 0),{navigate:s,navigateBack:a}=v(),{getAuthMeta:p,closePrivyModal:u,loginWithWallet:x}=_(),{walletConnectors:L}=z(),[f,g]=Lt(0),{user:m}=z(),[c]=Lt((m==null?void 0:m.linkedAccounts.length)||0);Ei(()=>{var I;r(((I=p())==null?void 0:I.walletType)||"metamask"),n(void 0),x().then(()=>e(!0)).catch(P=>{P instanceof ne?console.error(P.cause):console.error(P);let ie=(P==null?void 0:P.status)===401&&(P==null?void 0:P.message)==="User is not allowed to login to this app.";(P==null?void 0:P.status)===422?n(Ye.ERROR_USER_EXISTS):ie?s("ALLOWLIST_REJECTION_SCREEN"):P instanceof Je&&!P.details.default?n(P.details):P instanceof Ke?n(Ye.ERROR_TIMED_OUT):n(Ye.ERROR_WALLET_CONNECTION)})},[f]),Ei(()=>{if(m&&t){let I=setTimeout(u,re);return()=>clearTimeout(I)}},[m,t]);let S=Li[o].name,M=Li[o].component,k=t?`Successfully connected with ${S}`:i?i.message:`Waiting for ${S}`,b="";if(t){let I=(m==null?void 0:m.linkedAccounts.length)||0;c===I?b="Wallet was already linked.":b="You\u2019re good to go!"}else if(f>=qo&&i)b="Unable to connect wallet";else if(i)b=i.detail;else switch(b="Don\u2019t see your wallet modal? Check your other browser windows.",o){case"metamask":b="For the best experience, connect only one wallet at a time.";break;case"wallet_connect":b="Open your mobile wallet app to continue";break;case"coinbase_wallet":$t()||(Uo(m)?b="Continue with the Coinbase app. Not the right wallet? Reset your connection below.":b="Open the Coinbase app on your phone to continue.");break}let W=(K=L==null?void 0:L.walletConnectors)==null?void 0:K.find(I=>I.walletType==="coinbase_wallet"),G=o==="coinbase_wallet"&&(Uo(m)||i===Ye.ERROR_USER_EXISTS);return Qt(zs,{children:[xe(A,{backFn:a}),Qt(Bs,{children:[xe(Hs,{children:Qt("div",{children:[xe(ot,{success:t,fail:!!i}),xe(M,{style:{width:"38px",height:"38px"}})]})}),Qt(Vs,{children:[xe("h3",{children:k}),xe("p",{children:b})]}),G?xe(Ko,{onClick:()=>W&&(W==null?void 0:W.disconnect()),visible:!t,disabled:t,children:"Use a different wallet"}):i==Ye.ERROR_USER_EXISTS?xe(Ko,{onClick:a,visible:!0,children:"Use a different wallet"}):xe(Ko,{onClick:()=>{g(f+1),n(void 0)},visible:!t&&(i==null?void 0:i.retryable)&&f<qo,disabled:!t&&(!(i!=null&&i.retryable)||f>=qo),children:"Retry"})]})]})},Bs=eo.div`
|
|
365
365
|
display: flex;
|
|
366
366
|
flex-direction: column;
|
|
367
367
|
align-items: center;
|
|
@@ -526,7 +526,7 @@ Resources:
|
|
|
526
526
|
`,oa=at.div`
|
|
527
527
|
display: flex;
|
|
528
528
|
justify-content: center;
|
|
529
|
-
`;import{useEffect as ya,useState as or}from"react";import Oi from"styled-components";import{useEffect as ia,useState as At}from"react";import tr from"styled-components";import{jsx as Ii}from"react/jsx-runtime";var Ri=({style:t,...e})=>Ii("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",style:{height:"1.5rem",width:"1.5rem",...t},...e,children:Ii("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0l3.181 3.183a8.25 8.25 0 0013.803-3.7M4.031 9.865a8.25 8.25 0 0113.803-3.7l3.181 3.182m0-4.991v4.99"})});import{Fragment as ga,jsx as lt,jsxs as er}from"react/jsx-runtime";var ct=6,na=new Array(ct).fill("");function sa(t){return t.replace(/\s+/g,"")}function Qo(t){return/^[a-zA-Z0-9]{1}$/.test(t)}function aa(t){return/^[a-zA-Z]{1}$/.test(t)}function la(t){return/^[a-z]{1}$/.test(t)}function Mi(t){return t.length===ct&&t.every(Qo)}function ca(t,e){return t.reduce((o,r)=>o+Number(e(r)),0)}function da(){return crypto.getRandomValues(new Uint8Array(1))[0]}function pa(){let t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",e=[];for(;e.length<ct;){let o=da();o>247||e.push(t.charAt(o%62))}return e.join("")}var Ni=({onChange:t,disabled:e,readOnly:o,errorReasonOverride:r})=>{let[i,n]=At(na),[s,a]=At(null),[p,u]=At(null),x=
|
|
529
|
+
`;import{useEffect as ya,useState as or}from"react";import Oi from"styled-components";import{useEffect as ia,useState as At}from"react";import tr from"styled-components";import{jsx as Ii}from"react/jsx-runtime";var Ri=({style:t,...e})=>Ii("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",style:{height:"1.5rem",width:"1.5rem",...t},...e,children:Ii("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0l3.181 3.183a8.25 8.25 0 0013.803-3.7M4.031 9.865a8.25 8.25 0 0113.803-3.7l3.181 3.182m0-4.991v4.99"})});import{Fragment as ga,jsx as lt,jsxs as er}from"react/jsx-runtime";var ct=6,na=new Array(ct).fill("");function sa(t){return t.replace(/\s+/g,"")}function Qo(t){return/^[a-zA-Z0-9]{1}$/.test(t)}function aa(t){return/^[a-zA-Z]{1}$/.test(t)}function la(t){return/^[a-z]{1}$/.test(t)}function Mi(t){return t.length===ct&&t.every(Qo)}function ca(t,e){return t.reduce((o,r)=>o+Number(e(r)),0)}function da(){return crypto.getRandomValues(new Uint8Array(1))[0]}function pa(){let t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",e=[];for(;e.length<ct;){let o=da();o>247||e.push(t.charAt(o%62))}return e.join("")}var Ni=({onChange:t,disabled:e,readOnly:o,errorReasonOverride:r})=>{let[i,n]=At(na),[s,a]=At(null),[p,u]=At(null),x=f=>{var ie;let g=sa(f.currentTarget.value);if(g==="")return;let m=ca(i,Qo),c=g.split(""),S=!c.every(Qo),M=c.length+m>ct;if(S){a("PIN can only be letters and numbers"),u(1);return}if(M){a("PIN must be exactly 6 letters and numbers"),u(1);return}a(null),u(null);let k=Number((ie=f.currentTarget.name)==null?void 0:ie.charAt(4)),b=[...g||[""]].slice(0,ct-k),W=[...i.slice(0,k),...b,...i.slice(k+b.length)];n(W);let G=b.length,K=Math.min(Math.max(k+G,0),ct-1),I=document.querySelector(`input[name=pin-${K}]`),P=b[b.length-1]||"";if(aa(P)&&(la(P)?I.autocapitalize="none":I.autocapitalize="on"),I==null||I.focus(),Mi(W)){let Ae=document.querySelector(`input[name=pin-${K}]`);Ae==null||Ae.blur(),t(W.join(""))}else t(null);f.preventDefault()},L=f=>{p===1&&(a(null),u(null));let g=[...i.slice(0,f),"",...i.slice(f+1)];if(n(g),f>0){let m=document.querySelector(`input[name=pin-${f-1}]`);m==null||m.focus()}Mi(g)?t(g.join("")):t(null)};return er(ga,{children:[er(ua,{children:[lt(ha,{fail:!!r||!!s,children:r||s||"PIN can be letters and numbers"}),lt("div",{children:i.map((f,g)=>lt("input",{name:`pin-${g}`,type:"text",value:i[g],onChange:x,onKeyUp:m=>{m.key==="Backspace"&&L(g)},inputMode:"text",autoFocus:g===0,pattern:"[a-zA-Z0-9]",className:s?"fail":"",autoComplete:"off",disabled:e||o,autoCapitalize:"none"},g))})]}),!o&<(ma,{disabled:e,onClick:()=>{let f=pa();n([...f]),t(f)}})]})},ua=tr.div`
|
|
530
530
|
display: flex;
|
|
531
531
|
flex-direction: column;
|
|
532
532
|
width: 100%;
|
|
@@ -639,7 +639,7 @@ Resources:
|
|
|
639
639
|
width: 14px;
|
|
640
640
|
height: 14px;
|
|
641
641
|
}
|
|
642
|
-
`;import{Fragment as Ca,jsx as Ee,jsxs as oo}from"react/jsx-runtime";var Ui=()=>{let{authenticated:t,getAccessToken:e,user:o}=z(),{walletProxy:r,refreshUser:i,closePrivyModal:n}=_(),{navigate:s,data:a}=v(),[p,u]=or(null),[x,L]=or(""),[
|
|
642
|
+
`;import{Fragment as Ca,jsx as Ee,jsxs as oo}from"react/jsx-runtime";var Ui=()=>{let{authenticated:t,getAccessToken:e,user:o}=z(),{walletProxy:r,refreshUser:i,closePrivyModal:n}=_(),{navigate:s,data:a}=v(),[p,u]=or(null),[x,L]=or(""),[f,g]=or(!1),{onFailure:m}=a.createWallet;ya(()=>{t||(s("LANDING"),m(new Error("User must be authenticated before creating a Privy wallet")))},[t]);let c=()=>{m(new Error("User exited before creating a wallet")),n({shouldCallAuthOnSuccess:!1})},S=W=>{u(W)},M=ye(o),k=M?()=>{g(!0),setTimeout(()=>{g(!1),s("EMBEDDED_WALLET_CREATED_SCREEN")},350)}:async()=>{g(!0);let W=await e();if(W&&p!==null)try{await(r==null?void 0:r.create({accessToken:W,recoveryPin:p})),L(""),await i()}catch(G){L("An error has occurred, please try again."),console.error(G)}finally{g(!1)}},b=!!M;return oo(Ca,{children:[Ee(A,{onClose:c}),oo(wa,{children:[oo("div",{children:[Ee(Y,{title:b?"Secure your PIN":"Set your PIN",description:b?"Don\u2019t lose this PIN. You\u2019ll need it to access your wallet across devices.":"To finish setting up your account, please set up a PIN."}),Ee(Ni,{onChange:S,disabled:f,readOnly:b,errorReasonOverride:x}),b?Ee(to,{text:p||""}):null]}),oo(va,{children:[Ee("h4",{children:"Why am I doing this?"}),b?Ee("p",{children:"This PIN allows you to access your wallet across devices. If you lose it, there is no way to recover your wallet."}):Ee("p",{children:"A digital wallet is being created on this device for your account. This PIN allows you to access it across devices."})]}),Ee(Ie,{loading:f||!r,disabled:!p,onClick:k,warn:b,children:b?"I have saved my PIN":"Create your wallet"})]}),Ee($,{protectedByPrivy:!0})]})},wa=Oi.div`
|
|
643
643
|
display: flex;
|
|
644
644
|
height: 100%;
|
|
645
645
|
flex-direction: column;
|
|
@@ -838,7 +838,7 @@ Resources:
|
|
|
838
838
|
`,Ga=ae.div`
|
|
839
839
|
display: flex;
|
|
840
840
|
justify-content: center;
|
|
841
|
-
`;import{Fragment as Ba,jsx as io,jsxs as Yi}from"react/jsx-runtime";var Xi=()=>{let{navigateBack:t}=v();return Yi(Ba,{children:[io(A,{backFn:t},"header"),io(lr,{}),Yi(se,{children:[io("span",{children:"Still not sure? "}),io("a",{target:"_blank",href:"https://join.tell.ie/blog/explaining-web3-wallets",children:"Learn more"})]})]})};import{Fragment as Va,jsx as no,jsxs as Qi}from"react/jsx-runtime";var en=()=>{let{navigateBack:t}=v();return Qi(Va,{children:[no(A,{backFn:t},"header"),no(ar,{}),Qi(se,{children:[no("span",{children:"Still not sure? "}),no("a",{target:"_blank",href:"https://join.tell.ie/blog/explaining-web3-wallets",children:"Learn more"})]})]})};import{useState as wl}from"react";import{isMobile as hn}from"react-device-detect";import pt from"styled-components";import{jsx as tn}from"react/jsx-runtime";var on=()=>{let{app:t}=v();return t!=null&&t.logoUrl?tn("div",{children:tn("img",{src:t.logoUrl,alt:`${t==null?void 0:t.name} logo`,style:{objectFit:"contain",width:"200px",height:"80px"}})}):null};import{useEffect as Ha,useState as cr}from"react";import Pt from"styled-components";import{jsx as rn}from"react/jsx-runtime";var so=({style:t,...e})=>rn("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",style:{height:"1.5rem",width:"1.5rem",...t},...e,children:rn("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21.75 6.75v10.5a2.25 2.25 0 01-2.25 2.25h-15a2.25 2.25 0 01-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0019.5 4.5h-15a2.25 2.25 0 00-2.25 2.25m19.5 0v.243a2.25 2.25 0 01-1.07 1.916l-7.5 4.615a2.25 2.25 0 01-2.36 0L3.32 8.91a2.25 2.25 0 01-1.07-1.916V6.75"})});import{Fragment as Ka,jsx as Ve,jsxs as dr}from"react/jsx-runtime";var ao=t=>{let[e,o]=cr(""),[r,i]=cr(!1),[n,s]=cr(null),{isLinking:a,initLoginWithEmail:p}=_(),{navigate:u,options:x}=v(),L=x.wallet;Ha(()=>{let c=document.querySelector("#email-input");c==null||c.focus()},[]);let
|
|
841
|
+
`;import{Fragment as Ba,jsx as io,jsxs as Yi}from"react/jsx-runtime";var Xi=()=>{let{navigateBack:t}=v();return Yi(Ba,{children:[io(A,{backFn:t},"header"),io(lr,{}),Yi(se,{children:[io("span",{children:"Still not sure? "}),io("a",{target:"_blank",href:"https://join.tell.ie/blog/explaining-web3-wallets",children:"Learn more"})]})]})};import{Fragment as Va,jsx as no,jsxs as Qi}from"react/jsx-runtime";var en=()=>{let{navigateBack:t}=v();return Qi(Va,{children:[no(A,{backFn:t},"header"),no(ar,{}),Qi(se,{children:[no("span",{children:"Still not sure? "}),no("a",{target:"_blank",href:"https://join.tell.ie/blog/explaining-web3-wallets",children:"Learn more"})]})]})};import{useState as wl}from"react";import{isMobile as hn}from"react-device-detect";import pt from"styled-components";import{jsx as tn}from"react/jsx-runtime";var on=()=>{let{app:t}=v();return t!=null&&t.logoUrl?tn("div",{children:tn("img",{src:t.logoUrl,alt:`${t==null?void 0:t.name} logo`,style:{objectFit:"contain",width:"200px",height:"80px"}})}):null};import{useEffect as Ha,useState as cr}from"react";import Pt from"styled-components";import{jsx as rn}from"react/jsx-runtime";var so=({style:t,...e})=>rn("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",style:{height:"1.5rem",width:"1.5rem",...t},...e,children:rn("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21.75 6.75v10.5a2.25 2.25 0 01-2.25 2.25h-15a2.25 2.25 0 01-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0019.5 4.5h-15a2.25 2.25 0 00-2.25 2.25m19.5 0v.243a2.25 2.25 0 01-1.07 1.916l-7.5 4.615a2.25 2.25 0 01-2.36 0L3.32 8.91a2.25 2.25 0 01-1.07-1.916V6.75"})});import{Fragment as Ka,jsx as Ve,jsxs as dr}from"react/jsx-runtime";var ao=t=>{let[e,o]=cr(""),[r,i]=cr(!1),[n,s]=cr(null),{isLinking:a,initLoginWithEmail:p}=_(),{navigate:u,options:x}=v(),L=x.wallet;Ha(()=>{let c=document.querySelector("#email-input");c==null||c.focus()},[]);let f=Vr(e),g=()=>{i(!0),p(e).then(()=>{u("AWAITING_PASSWORDLESS_CODE")}).catch(c=>{let S=(c==null?void 0:c.status)===401&&(c==null?void 0:c.message)==="User is not allowed to login to this app.";(c==null?void 0:c.status)===422?s(c.message):S?u("ALLOWLIST_REJECTION_SCREEN"):s("Issue submitting email"),i(!1)})},m="Get started without a wallet.";return n?m=n:a?m="Easily connect an email":L||(m="Get started quickly with email"),dr(Ka,{children:[dr(za,{stacked:t.stacked,children:[dr(Za,{standalone:t.stacked,children:[Ve(so,{}),Ve("input",{id:"email-input",type:"email",placeholder:"your@email.com",onChange:c=>o(c.target.value),onKeyUp:c=>{c.key==="Enter"&&g()},value:e,autoComplete:"email"})]}),t.stacked?null:Ve($a,{disabled:r||!f,onClick:g,children:r?Ve(We,{}):"Submit"})]}),Ve(qa,{fail:!!n,children:m}),t.stacked?Ve(ja,{disabled:r||!f,onClick:g,children:r?Ve(We,{}):"Submit"}):null]})},za=Pt.div`
|
|
842
842
|
border: 1px solid var(--border-color-1);
|
|
843
843
|
width: 100%;
|
|
844
844
|
height: ${t=>t.stacked?"100%":"auto"};
|
|
@@ -950,7 +950,7 @@ Resources:
|
|
|
950
950
|
> a {
|
|
951
951
|
text-decoration: underline;
|
|
952
952
|
}
|
|
953
|
-
`;import{useEffect as Ja,useState as pr}from"react";import St from"styled-components";import{jsx as nn}from"react/jsx-runtime";var lo=({style:t,...e})=>nn("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:nn("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 ol,jsx as He,jsxs as ur}from"react/jsx-runtime";var co=t=>{let[e,o]=pr(""),[r,i]=pr(!1),[n,s]=pr(null),{isLinking:a,initLoginWithSms:p}=_(),{navigate:u,options:x}=v(),L=x.wallet;Ja(()=>{let c=document.querySelector("#phone-number-input");c==null||c.focus()},[]);let
|
|
953
|
+
`;import{useEffect as Ja,useState as pr}from"react";import St from"styled-components";import{jsx as nn}from"react/jsx-runtime";var lo=({style:t,...e})=>nn("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:nn("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 ol,jsx as He,jsxs as ur}from"react/jsx-runtime";var co=t=>{let[e,o]=pr(""),[r,i]=pr(!1),[n,s]=pr(null),{isLinking:a,initLoginWithSms:p}=_(),{navigate:u,options:x}=v(),L=x.wallet;Ja(()=>{let c=document.querySelector("#phone-number-input");c==null||c.focus()},[]);let f=Hr(e),g=()=>{i(!0),p(e).then(()=>{u("AWAITING_PASSWORDLESS_CODE")}).catch(c=>{let S=(c==null?void 0:c.status)===401&&(c==null?void 0:c.message)==="User is not allowed to login to this app.";(c==null?void 0:c.status)===422?s(c.message):S?u("ALLOWLIST_REJECTION_SCREEN"):s("Issue submitting phone number"),i(!1)})},m="Get started without a wallet.";return n?m=n:a?m="Easily connect a phone number":L||(m="Get started quickly with your phone"),ur(ol,{children:[ur(Ya,{stacked:t.stacked,children:[ur(el,{standalone:t.stacked,children:[He(lo,{}),He("input",{id:"phone-number-input",type:"tel",placeholder:"555 555 5555",onChange:c=>{o(c.target.value)},onKeyUp:c=>{c.key==="Enter"&&g()},value:e,autoComplete:"tel"})]}),t.stacked?null:He(Xa,{disabled:r||!f,onClick:g,children:r?He(We,{}):"Submit"})]}),He(tl,{fail:!!n,children:m}),t.stacked?He(Qa,{disabled:r||!f,onClick:g,children:r?He(We,{}):"Submit"}):null]})},Ya=St.div`
|
|
954
954
|
display: flex;
|
|
955
955
|
border: 1px solid var(--border-color-1);
|
|
956
956
|
width: 100%;
|
|
@@ -1210,7 +1210,7 @@ Resources:
|
|
|
1210
1210
|
@media (max-width: 440px) {
|
|
1211
1211
|
margin-top: 4px;
|
|
1212
1212
|
}
|
|
1213
|
-
`;import{Fragment as fr,jsx as O,jsxs as ze}from"react/jsx-runtime";var fn=()=>{let{app:t,options:e}=v(),o=e.email,r=e.sms,i=e.wallet,n=e.google,s=e.twitter,a=e.discord,p=e.github,u=i&&(t==null?void 0:t.showWalletLoginFirst)?0:1,[x,L]=wl(u),
|
|
1213
|
+
`;import{Fragment as fr,jsx as O,jsxs as ze}from"react/jsx-runtime";var fn=()=>{let{app:t,options:e}=v(),o=e.email,r=e.sms,i=e.wallet,n=e.google,s=e.twitter,a=e.discord,p=e.github,u=i&&(t==null?void 0:t.showWalletLoginFirst)?0:1,[x,L]=wl(u),f=x==0,g=x==1,m=i,c=o||r;return ze(fr,{children:[O(A,{},"header"),O(El,{hasOnlyOneSection:m!==c,hasTerms:!!((t==null?void 0:t.privacyPolicyUrl)||(t==null?void 0:t.termsAndConditionsUrl)),children:O(on,{})}),ze(Ll,{reverse:!(t!=null&&t.showWalletLoginFirst),children:[m&&O(vl,{active:f,onClick:()=>L(0),isOnlySection:!c}),c&&O(Cl,{active:g,onClick:()=>L(1),email:o,sms:r,google:n,twitter:s,discord:a,github:p,isOnlySection:!m})]}),t&&O(mi,{app:t}),O($,{protectedByPrivy:!0})]})};function vl(t){return ze(yn,{active:t.active,onClick:t.onClick,isOnlySection:t.isOnlySection,children:[O(gn,{active:t.active,children:O("h4",{children:"Connect Wallet"})}),t.active&&ze(fr,{children:[O(go,{}),O(yo,{})]})]})}function Cl(t){let e=t.google||t.discord||t.github||t.twitter&&!hn,o=t.email?"Email":"Phone";return ze(yn,{active:t.active,onClick:t.onClick,isOnlySection:t.isOnlySection,children:[t.isOnlySection?null:O(gn,{active:t.active,children:O("h4",{children:e?`${o} & Social`:o})}),t.active&&t.email&&O(ao,{}),t.active&&t.sms&&!t.email&&O(co,{}),t.active&&e&&O(bl,{google:t.google,twitter:t.twitter&&!hn,discord:t.discord,github:t.github})]})}function bl(t){return ze(fr,{children:[ze(xl,{children:[O(mn,{}),O("p",{children:" Or "}),O(mn,{})]}),O(ln,{showGoogle:t.google,showDiscord:t.discord,showGithub:t.github,showTwitter:t.twitter})]})}var gn=pt.div`
|
|
1214
1214
|
font-weight: ${t=>t.active?600:500};
|
|
1215
1215
|
color: ${t=>t.active?"inherit":"var(--light-theme-fg-3)"};
|
|
1216
1216
|
display: flex;
|
|
@@ -1273,7 +1273,7 @@ Resources:
|
|
|
1273
1273
|
margin-bottom: ${t=>`${60+(t.hasOnlyOneSection?31:0)-(t.hasTerms?18:0)}px`};
|
|
1274
1274
|
`,Ll=pt(Te)`
|
|
1275
1275
|
flex-direction: ${t=>t.reverse?"column-reverse":"column"};
|
|
1276
|
-
`;import{Fragment as Al,jsx as ut,jsxs as _l}from"react/jsx-runtime";var wn=()=>{let{app:t}=v();return _l(Al,{children:[ut(A,{},"header"),ut(et,{title:"Connect your email",description:`Add your email to your ${t==null?void 0:t.name} account`,icon:ut(so,{})}),ut(Te,{children:ut(ao,{stacked:!0})}),ut($,{protectedByPrivy:!0})]})};import{Fragment as Pl,jsx as ht,jsxs as Sl}from"react/jsx-runtime";var vn=()=>{let{app:t}=v();return Sl(Pl,{children:[ht(A,{},"header"),ht(et,{title:"Connect your phone",description:`Add your number to your ${t==null?void 0:t.name} account`,icon:ht(lo,{})}),ht(Te,{children:ht(co,{stacked:!0})}),ht($,{protectedByPrivy:!0})]})};import{Fragment as kl,jsx as It,jsxs as Cn}from"react/jsx-runtime";var bn=()=>{let{linkingHint:t}=_(),{app:e}=v(),o=t?`Select the wallet with ${De(t)} and follow the instructions to reconnect your wallet${e!=null&&e.name?` to ${e.name}.`:"."}`:`Link a wallet to your ${e==null?void 0:e.name} account`;return Cn(kl,{children:[It(A,{},"header"),It(gi,{title:`${t?"Reconnect":"Connect"} your wallet`,description:o}),Cn(Te,{children:[It(go,{}),It(yo,{})]}),It($,{protectedByPrivy:!0})]})};import{useEffect as xn,useState as En}from"react";import vo from"styled-components";import{Fragment as Nl,jsx as $e,jsxs as wo}from"react/jsx-runtime";var Ln={google:{name:"Google",component:mo},discord:{name:"Discord",component:po},github:{name:"Github",component:uo},twitter:{name:"Twitter",component:fo}},Tl=t=>t.charAt(0).toUpperCase()+t.slice(1),gr=()=>{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)},An=()=>{var b;let{ready:t,user:e,authenticated:o}=z(),{data:r,setModalData:i,navigate:n}=v(),{getAuthMeta:s,initLoginWithOAuth:a,loginWithOAuth:p,closePrivyModal:u}=_(),[x,L]=En(!1),[
|
|
1276
|
+
`;import{Fragment as Al,jsx as ut,jsxs as _l}from"react/jsx-runtime";var wn=()=>{let{app:t}=v();return _l(Al,{children:[ut(A,{},"header"),ut(et,{title:"Connect your email",description:`Add your email to your ${t==null?void 0:t.name} account`,icon:ut(so,{})}),ut(Te,{children:ut(ao,{stacked:!0})}),ut($,{protectedByPrivy:!0})]})};import{Fragment as Pl,jsx as ht,jsxs as Sl}from"react/jsx-runtime";var vn=()=>{let{app:t}=v();return Sl(Pl,{children:[ht(A,{},"header"),ht(et,{title:"Connect your phone",description:`Add your number to your ${t==null?void 0:t.name} account`,icon:ht(lo,{})}),ht(Te,{children:ht(co,{stacked:!0})}),ht($,{protectedByPrivy:!0})]})};import{Fragment as kl,jsx as It,jsxs as Cn}from"react/jsx-runtime";var bn=()=>{let{linkingHint:t}=_(),{app:e}=v(),o=t?`Select the wallet with ${De(t)} and follow the instructions to reconnect your wallet${e!=null&&e.name?` to ${e.name}.`:"."}`:`Link a wallet to your ${e==null?void 0:e.name} account`;return Cn(kl,{children:[It(A,{},"header"),It(gi,{title:`${t?"Reconnect":"Connect"} your wallet`,description:o}),Cn(Te,{children:[It(go,{}),It(yo,{})]}),It($,{protectedByPrivy:!0})]})};import{useEffect as xn,useState as En}from"react";import vo from"styled-components";import{Fragment as Nl,jsx as $e,jsxs as wo}from"react/jsx-runtime";var Ln={google:{name:"Google",component:mo},discord:{name:"Discord",component:po},github:{name:"Github",component:uo},twitter:{name:"Twitter",component:fo}},Tl=t=>t.charAt(0).toUpperCase()+t.slice(1),gr=()=>{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)},An=()=>{var b;let{ready:t,user:e,authenticated:o}=z(),{data:r,setModalData:i,navigate:n}=v(),{getAuthMeta:s,initLoginWithOAuth:a,loginWithOAuth:p,closePrivyModal:u}=_(),[x,L]=En(!1),[f,g]=En(void 0),m=((b=s())==null?void 0:b.provider)||"google",c=Ln[m].name,S=Ln[m].component;xn(()=>{!t||p().then(()=>{gr(),L(!0)}).catch(W=>{let G={retryable:!1,message:"Authentication failed."};W.message.includes("Another user has already linked this")?G.detail="This account has already been linked to another user.":W.message==="Invalid code during oauth flow."?(G.retryable=!0,G.detail="Something went wrong. Try again."):W.message==="User denied confirmation during OAuth flow"&&(G.detail=`Retry and check ${Tl(m)} to finish connecting your account.`,G.retryable=!0),gr(),g(G)})},[t]),xn(()=>{var K;if(!(o&&x&&e))return;if(((K=r==null?void 0:r.login)==null?void 0:K.promptCreatePrivyWalletFlow)&&!e.wallet){let I=setTimeout(()=>{i({createWallet:{onSuccess:()=>u({shouldCallAuthOnSuccess:!0}),onFailure:P=>console.error(P)}}),n("EMBEDDED_WALLET_SCREEN")},re-500);return()=>clearTimeout(I)}else{let I=setTimeout(u,re);return()=>clearTimeout(I)}},[x]);let M=x?`Successfully connected with ${c}`:f?f.message:`Verifying connection to ${c}`,k="";return x?k="You\u2019re good to go!":f?k=f.detail:k="Just a few moments more",wo(Nl,{children:[$e(A,{}),wo(Wl,{children:[$e(Rl,{children:wo("div",{children:[$e(ot,{success:x,fail:!!f}),$e(S,{style:{width:"38px",height:"38px"},logoFill:"primary"})]})}),wo(Il,{children:[$e("h3",{children:M}),$e("p",{children:k})]}),$e(Ml,{onClick:()=>{gr(),a(m),g(void 0)},visible:!x&&(f==null?void 0:f.retryable),disabled:!x&&!(f!=null&&f.retryable),children:"Retry"})]})]})},Wl=vo.div`
|
|
1277
1277
|
display: flex;
|
|
1278
1278
|
flex-direction: column;
|
|
1279
1279
|
align-items: center;
|
|
@@ -1355,7 +1355,7 @@ Resources:
|
|
|
1355
1355
|
left: -19px;
|
|
1356
1356
|
top: -19px;
|
|
1357
1357
|
}
|
|
1358
|
-
`;import{useEffect as Gl,useState as kn}from"react";import Rt,{css as Bl}from"styled-components";import{Fragment as Zl,jsx as Ne,jsxs as bo}from"react/jsx-runtime";var Tn=()=>{let{authenticated:t,getAccessToken:e,user:o}=z(),{walletProxy:r,closePrivyModal:i}=_(),{navigate:n,data:s}=v(),[a,p]=kn(!1),[u,x]=kn("");Gl(()=>{t||(n("LANDING"),g(new Error("User must be authenticated before signing with a Privy wallet")))},[t]);let{message:L,onSuccess:
|
|
1358
|
+
`;import{useEffect as Gl,useState as kn}from"react";import Rt,{css as Bl}from"styled-components";import{Fragment as Zl,jsx as Ne,jsxs as bo}from"react/jsx-runtime";var Tn=()=>{let{authenticated:t,getAccessToken:e,user:o}=z(),{walletProxy:r,closePrivyModal:i}=_(),{navigate:n,data:s}=v(),[a,p]=kn(!1),[u,x]=kn("");Gl(()=>{t||(n("LANDING"),g(new Error("User must be authenticated before signing with a Privy wallet")))},[t]);let{message:L,onSuccess:f,onFailure:g,uiOptions:m}=s.signMessage,c=ye(o),S=!r,M={title:m.title||"Sign message",description:m.description||"Signing this message will not cost you any fees.",buttonText:m.buttonText||"Sign and continue"};return bo(Zl,{children:[Ne(A,{onClose:()=>i({shouldCallAuthOnSuccess:!1})}),bo(Vl,{children:[bo("div",{children:[Ne(Y,{title:M.title,description:M.description}),Ne(Hl,{children:L}),Ne(zl,{fail:!0,children:u})]}),Ne(jl,{success:a,loading:S,disabled:a,onClick:async()=>{let k=await e();if(k&&!S&&c)try{let{signature:b}=await r.sign({accessToken:k,address:c==null?void 0:c.address,message:L});x(""),f(b),p(!0),setTimeout(()=>{i({shouldCallAuthOnSuccess:!1})},re)}catch(b){x("An error has occurred, please try again."),g(b)}},children:a?bo($l,{children:[Ne(nt,{style:{height:"0.9rem",width:"0.9rem"},strokeWidth:2})," ",Ne("span",{children:"Success"})]}):M.buttonText})]}),Ne($,{protectedByPrivy:!0})]})},Vl=Rt.div`
|
|
1359
1359
|
display: flex;
|
|
1360
1360
|
height: 100%;
|
|
1361
1361
|
flex-direction: column;
|
|
@@ -1759,4 +1759,4 @@ Resources:
|
|
|
1759
1759
|
align-items: center;
|
|
1760
1760
|
justify-content: center;
|
|
1761
1761
|
height: 100%;
|
|
1762
|
-
`;import{useRef as s1,useEffect as a1}from"react";var xo=class{constructor(){this.callbacks={}}enqueue(e,o){this.callbacks[e]=o}dequeue(e,o){let r=this.callbacks[o];if(!r)throw new Error(`cannot dequeue ${e} event: no event found for id ${o}`);switch(delete this.callbacks[o],e){case"privy:iframe:ready":return r;case"privy:wallet:create":return r;case"privy:wallet:sign":return r;case"privy:wallet:recover":return r;default:throw new Error(`invalid wallet event type ${e}`)}}};import{jsx as p1}from"react/jsx-runtime";var l1=function(t){return()=>`id-${t++}`}(0);function c1(t){return typeof t.event=="string"&&/^privy:.+/.test(t.event)}function Eo(t){return t.error!==void 0}var Mt=new xo;function Lo(t,e,o){let r=o.contentWindow;if(!r)throw new Error("iframe not initialized");return new Promise((i,n)=>{let s=l1();Mt.enqueue(s,{resolve:i,reject:n}),r.postMessage({id:s,event:t,data:e},"*")})}function d1(t){switch(t.event){case"privy:iframe:ready":let e=Mt.dequeue(t.event,t.id);return Eo(t)?e.reject(new Error(t.error.message)):e.resolve(t.data);case"privy:wallet:create":let o=Mt.dequeue(t.event,t.id);return Eo(t)?o.reject(new Error(t.error.message)):o.resolve(t.data);case"privy:wallet:sign":let r=Mt.dequeue(t.event,t.id);return Eo(t)?r.reject(new Error(t.error.message)):r.resolve(t.data);case"privy:wallet:recover":let i=Mt.dequeue(t.event,t.id);return Eo(t)?i.reject(new Error(t.error.message)):i.resolve(t.data)}}function Mn(t){let e=s1(null);return a1(()=>{let o=e.current;if(!o)return;function r(a){a&&a.origin===t.origin&&c1(a.data)&&d1(a.data)}let i={create(a){return Lo("privy:wallet:create",a,o)},sign(a){return Lo("privy:wallet:sign",a,o)},recover(a){return Lo("privy:wallet:recover",a,o)}};window.addEventListener("message",r);let n=()=>t.onLoad(i),s=(...a)=>{console.error("privy iframe failed to load: ",...a),t.onLoadFailed()};return $r(()=>Lo("privy:iframe:ready",{},o)).then(n,s),()=>window.removeEventListener("message",r)},[e.current]),p1("iframe",{ref:e,width:"0",height:"0",style:{visibility:"hidden"},src:jr(t.origin,`/apps/${t.appId}/embedded-wallets`)})}import{jsx as Ao,jsxs as On}from"react/jsx-runtime";function h1(t){return typeof t=="string"&&t.length===25}var Nt;function m1(){if(!Nt){let t=Z.get(qe);return Promise.resolve(t||null)}return Nt.getAccessToken()}var f1=t=>{if(!h1(t.appId))throw new y("Cannot initialize the Privy provider with an invalid Privy app ID");return Nt||(Nt=new bt({appId:t.appId,apiURL:Po})),Ao(y1,{...t,client:Nt})},g1=t=>{let e=!!(t!=null&&t.emailAuth),o=!!(t!=null&&t.smsAuth);return e&&o&&(console.warn("Enabling both email and SMS passwordless is not currently supported. Disabling SMS."),o=!1),{email:e,sms:o,wallet:!!(t!=null&&t.walletAuth),google:!!(t!=null&&t.googleOAuth),twitter:!!(t!=null&&t.twitterOAuth),discord:!!(t!=null&&t.discordOAuth),github:!!(t!=null&&t.githubOAuth)}},y1=t=>{let e=t.client,[o,r]=te(!1),[i,n]=te(!1),[s,a]=te(!1),[p,u]=te(null),[x,L]=te(!1),[
|
|
1762
|
+
`;import{useRef as s1,useEffect as a1}from"react";var xo=class{constructor(){this.callbacks={}}enqueue(e,o){this.callbacks[e]=o}dequeue(e,o){let r=this.callbacks[o];if(!r)throw new Error(`cannot dequeue ${e} event: no event found for id ${o}`);switch(delete this.callbacks[o],e){case"privy:iframe:ready":return r;case"privy:wallet:create":return r;case"privy:wallet:sign":return r;case"privy:wallet:recover":return r;default:throw new Error(`invalid wallet event type ${e}`)}}};import{jsx as p1}from"react/jsx-runtime";var l1=function(t){return()=>`id-${t++}`}(0);function c1(t){return typeof t.event=="string"&&/^privy:.+/.test(t.event)}function Eo(t){return t.error!==void 0}var Mt=new xo;function Lo(t,e,o){let r=o.contentWindow;if(!r)throw new Error("iframe not initialized");return new Promise((i,n)=>{let s=l1();Mt.enqueue(s,{resolve:i,reject:n}),r.postMessage({id:s,event:t,data:e},"*")})}function d1(t){switch(t.event){case"privy:iframe:ready":let e=Mt.dequeue(t.event,t.id);return Eo(t)?e.reject(new Error(t.error.message)):e.resolve(t.data);case"privy:wallet:create":let o=Mt.dequeue(t.event,t.id);return Eo(t)?o.reject(new Error(t.error.message)):o.resolve(t.data);case"privy:wallet:sign":let r=Mt.dequeue(t.event,t.id);return Eo(t)?r.reject(new Error(t.error.message)):r.resolve(t.data);case"privy:wallet:recover":let i=Mt.dequeue(t.event,t.id);return Eo(t)?i.reject(new Error(t.error.message)):i.resolve(t.data)}}function Mn(t){let e=s1(null);return a1(()=>{let o=e.current;if(!o)return;function r(a){a&&a.origin===t.origin&&c1(a.data)&&d1(a.data)}let i={create(a){return Lo("privy:wallet:create",a,o)},sign(a){return Lo("privy:wallet:sign",a,o)},recover(a){return Lo("privy:wallet:recover",a,o)}};window.addEventListener("message",r);let n=()=>t.onLoad(i),s=(...a)=>{console.error("privy iframe failed to load: ",...a),t.onLoadFailed()};return $r(()=>Lo("privy:iframe:ready",{},o)).then(n,s),()=>window.removeEventListener("message",r)},[e.current]),p1("iframe",{ref:e,width:"0",height:"0",style:{visibility:"hidden"},src:jr(t.origin,`/apps/${t.appId}/embedded-wallets`)})}import{jsx as Ao,jsxs as On}from"react/jsx-runtime";function h1(t){return typeof t=="string"&&t.length===25}var Nt;function m1(){if(!Nt){let t=Z.get(qe);return Promise.resolve(t||null)}return Nt.getAccessToken()}var f1=t=>{if(!h1(t.appId))throw new y("Cannot initialize the Privy provider with an invalid Privy app ID");return Nt||(Nt=new bt({appId:t.appId,apiURL:Po})),Ao(y1,{...t,client:Nt})},g1=t=>{let e=!!(t!=null&&t.emailAuth),o=!!(t!=null&&t.smsAuth);return e&&o&&(console.warn("Enabling both email and SMS passwordless is not currently supported. Disabling SMS."),o=!1),{email:e,sms:o,wallet:!!(t!=null&&t.walletAuth),google:!!(t!=null&&t.googleOAuth),twitter:!!(t!=null&&t.twitterOAuth),discord:!!(t!=null&&t.discordOAuth),github:!!(t!=null&&t.githubOAuth)}},y1=t=>{let e=t.client,[o,r]=te(!1),[i,n]=te(!1),[s,a]=te(!1),[p,u]=te(null),[x,L]=te(!1),[f,g]=te(null),[m,c]=te(!1),[S,M]=te(null),[k,b]=te(null),[W,G]=te(null),[K,I]=te({accentColor:"#696ffd",theme:"System",showWalletLoginFirst:!0,allowlistConfig:{errorTitle:null,errorDetail:null,errorCtaText:null,errorCtaLink:null},walletAuth:!0,emailAuth:!0,smsAuth:!1,googleOAuth:!1,twitterOAuth:!1,discordOAuth:!1,githubOAuth:!1,termsAndConditionsUrl:null,privacyPolicyUrl:null}),[P,ie]=te(!1),[Ae,D]=te({}),F=g1(K),R=l=>{l&&g(l),r(!0)},ce=l=>{let d=t.createPrivyWalletOnLogin===!0;D({login:{promptCreatePrivyWalletFlow:d}}),d&&ie(!0),R(l)};Nn(()=>{async function l(){let d=await e.getAppSettings();I(d),e.connectors.initialize(),Oe();let N=await e.getAuthenticatedUser();a(!!N),u(N),n(!0)}l()},[e]);let Oe=()=>{let l=new URLSearchParams(window.location.search),d=l.get("privy_oauth_code"),N=l.get("privy_oauth_state"),_e=l.get("privy_oauth_provider");d&&N&&_e&&(e.startAuthFlow(new Ze(_e,d,N)),ce("AWAITING_OAUTH_SCREEN"))};Nn(()=>{i&&s&&p===null&&e.getAuthenticatedUser().then(u)},[i,s,p,e]);let mt=()=>{c(!0),R("LINK_WALLET_SCREEN")},Ot={ready:i,authenticated:s,user:p,walletConnectors:e.connectors,linkWallet:mt,linkEmail:()=>{c(!0),R("LINK_EMAIL_SCREEN")},linkPhone:()=>{c(!0),R("LINK_PHONE_SCREEN")},linkGoogle:async()=>{await H.initLoginWithOAuth("google")},linkTwitter:async()=>{await H.initLoginWithOAuth("twitter")},linkDiscord:async()=>{await H.initLoginWithOAuth("discord")},linkGithub:async()=>{await H.initLoginWithOAuth("github")},login:()=>{if(i&&s){console.warn("Attempted to log in, but user is already logged in. Use a `link` helper instead.");return}ce()},logout:async()=>{await e.logout(),u(null),a(!1),g(null),c(!1),r(!1)},getAccessToken:()=>e.getAccessToken(),getEthereumProvider:()=>e.connectors.getEthereumProvider(),getEthersProvider:()=>new u1(new fe(e.connectors.getEthereumProvider())),getWeb3jsProvider:()=>new Ft(e.connectors.getEthereumProvider()),unlinkWallet:async l=>{let d=await e.unlinkWallet(l);return u(d),d},unlinkEmail:async l=>{let d=await e.unlinkEmail(l);return u(d),d},unlinkPhone:async l=>{let d=await e.unlinkPhone(l);return u(d),d},unlinkGoogle:async l=>{let d=await e.unlinkOAuth("google",l);return u(d),d},unlinkTwitter:async l=>{let d=await e.unlinkOAuth("twitter",l);return u(d),d},unlinkDiscord:async l=>{let d=await e.unlinkOAuth("discord",l);return u(d),d},unlinkGithub:async l=>{let d=await e.unlinkOAuth("github",l);return u(d),d},setActiveWallet:async l=>{if(!p)return;let d=e.connectors.getConnectorByAddress(l);if(!d){b(l),mt();return}M({address:l,walletType:d.walletType,success:!1}),R("SETTING_ACTIVE_WALLET"),e.setActiveWallet(l,p).then(N=>{u(N),M({address:l,walletType:d.walletType,success:!0})}).catch(N=>{N instanceof y&&N.message==="Error setting the active wallet."&&(b(l),mt()),M({address:l,walletType:d.walletType,success:!1,error:N.message})})},forkSession:()=>e.forkSession(),createWallet:()=>new Promise((l,d)=>{if(!s||!p){d(new Error("User must be authenticated before creating a Privy wallet"));return}if(ye(p)){d(new Error("Only one Privy wallet per user is currently allowed"));return}ie(!0),D({createWallet:{onSuccess:l,onFailure:d}}),R("EMBEDDED_WALLET_SCREEN")}),signMessage:(l,d)=>new Promise((N,_e)=>{if(!s||!p){_e(new Error("User must be authenticated before signing with a Privy wallet"));return}if(!ye(p)){_e(new Error("Must have a Privy wallet before signing"));return}if(typeof l!="string"||l.length<1){_e(new Error("Message must be a non-empty string"));return}ie(!0),D({signMessage:{message:l,onSuccess:N,onFailure:_e,uiOptions:d||{}}}),R("SIGN_REQUEST_SCREEN")})},H=(()=>({isLinking:m,linkingHint:k,activeStatus:S,getAuthFlow:()=>e.authFlow,getAuthMeta:()=>{var l;return(l=e.authFlow)==null?void 0:l.meta},closePrivyModal:(l={shouldCallAuthOnSuccess:!0})=>{var N;let d=i&&s&&p;l.shouldCallAuthOnSuccess&&d&&((N=t.onSuccess)==null||N.call(t,p,x)),e.authFlow=void 0,b(null),g(null),c(!1),M(null),L(!1),r(!1)},initLoginWithWallet:l=>{if(!e.connectors)throw new y("Connector not initialized");l||(l="metamask"),e.startAuthFlow(new gt(e.connectors,l))},loginWithWallet:async()=>{if(!(e.authFlow instanceof gt))throw new y("Must initialize SIWE flow first.");let l,d;m?(l=await e.link(),l&&(l=Ct(l))):{user:l,isNewUser:d}=await e.authenticate(),u(l||p||null),L(d||!1),a(!0)},initLoginWithOAuth:async l=>{e.startAuthFlow(new Ze(l));let d=await e.authFlow.getAuthorizationUrl();d&&d.url&&window.location.assign(d.url)},loginWithOAuth:async()=>{if(!(e.authFlow instanceof Ze))throw new y("Must initialize OAuth flow before calling loginWithOAuth");let l,d;i&&s?l=await e.link():{user:l,isNewUser:d}=await e.authenticate(),u(l),L(d||!1),a(!0)},initLoginWithEmail:async l=>{let d=new ft(l);e.startAuthFlow(d),await d.sendCodeEmail()},initLoginWithSms:async l=>{let d=new yt(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 ft)e.authFlow.meta.emailCode=l.trim();else if(e.authFlow instanceof yt)e.authFlow.meta.smsCode=l.trim();else throw new y("Must initialize a passwordless code flow first");let d,N;m?d=await e.link():{user:d,isNewUser:N}=await e.authenticate(),u(d||p||null),L(N||!1),a(!0)},refreshUser:async()=>{let l=await e.getAuthenticatedUser();return u(l),l},walletProxy:W}))();return On(Vo.Provider,{value:Ot,children:[t.children,On(Go.Provider,{value:H,children:[Ao(ei,{appSettings:K,options:F,data:Ae,setModalData:D,initialScreen:f,visible:o,authenticated:s,children:o&&Ao(Rn,{})}),P&&Ao(Mn,{appId:t.appId,origin:Po,onLoad:G,onLoadFailed:()=>null})]})]})};export{fe as AsExternalProvider,vt as ConnectorManager,bt as PrivyClient,f1 as PrivyProvider,de as PrivyProxyProvider,So as VERSION,ge as WalletConnector,m1 as getAccessToken,z as usePrivy};
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var $n=Object.create;var Xt=Object.defineProperty;var jn=Object.getOwnPropertyDescriptor;var Zn=Object.getOwnPropertyNames;var qn=Object.getPrototypeOf,Kn=Object.prototype.hasOwnProperty;var Jn=(t,e)=>{for(var o in e)Xt(t,o,{get:e[o],enumerable:!0})},Rr=(t,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Zn(e))!Kn.call(t,i)&&i!==o&&Xt(t,i,{get:()=>e[i],enumerable:!(r=jn(e,i))||r.enumerable});return t};var E=(t,e,o)=>(o=t!=null?$n(qn(t)):{},Rr(e||!t||!t.__esModule?Xt(o,"default",{value:t,enumerable:!0}):o,t)),Yn=t=>Rr(Xt({},"__esModule",{value:!0}),t);var ol={};Jn(ol,{AsExternalProvider:()=>Se,ConnectorManager:()=>ft,PrivyClient:()=>gt,PrivyProvider:()=>zn,PrivyProxyProvider:()=>Ce,VERSION:()=>Qt,WalletConnector:()=>ke,getAccessToken:()=>Hn,usePrivy:()=>q});module.exports=Yn(ol);var Vn=require("@ethersproject/providers"),Y=require("react");var Mr=E(require("axios")),ve=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}]`:""}`}},ct=class extends ve{constructor(o,r,i,n){super(i,n);this.type=o;this.status=r}},w=class extends ve{constructor(o,r){super(o,r);this.type="client_error"}};var Z=class extends ve{constructor(o,r){super(o,r);this.type="connector_error"}},V=t=>{if(t instanceof ve)return t;if(!Mr.default.isAxiosError(t))return ue(t);if(!t.response)return new ct("api_error",null,t.message,t);let{type:e,message:o,error:r}=t.response.data;return new ct(e||"ApiError",t.response.status,o||r,t)},ue=t=>t instanceof ve?t:t instanceof Error?new w(t.message,t):new w(`Internal error: ${t}`);var Nr=()=>"/api/v1/sessions",Or=()=>"/api/v1/sessions/logout",Ur=()=>"/api/v1/sessions/fork",Dr=()=>"/api/v1/siwe/init",Fr=()=>"/api/v1/siwe/authenticate",Gr=()=>"/api/v1/siwe/link",Br=()=>"/api/v1/passwordless/init",Vr=()=>"/api/v1/passwordless/authenticate",Hr=()=>"/api/v1/passwordless/link",zr=()=>"/api/v1/passwordless_sms/init",$r=()=>"/api/v1/passwordless_sms/authenticate",jr=()=>"/api/v1/passwordless_sms/link",Zr=()=>"/api/v1/oauth/init",qr=()=>"/api/v1/oauth/authenticate",Kr=()=>"/api/v1/oauth/link",Jr=()=>"/api/v1/siwe/unlink",Yr=()=>"/api/v1/passwordless/unlink",Xr=()=>"/api/v1/passwordless_sms/unlink",Qr=()=>"/api/v1/oauth/unlink";var Mt=class{constructor(e){this.meta={email:e}}async authenticate(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new w("Email and email code must be set prior to calling authenticate.");try{let e=Vr(),o=await this.api.post(e,{email:this.meta.email,code:this.meta.emailCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(e){throw V(e)}}async link(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new w("Email and email code must be set prior to calling authenticate.");try{let e=Hr();return(await this.api.post(e,{email:this.meta.email,code:this.meta.emailCode})).data}catch(e){throw V(e)}}async sendCodeEmail(e){if(!this.api)throw new w("Auth flow has no API instance");if(e&&(this.meta.email=e),!this.meta.email)throw new w("Email must be set when initialzing authentication.");try{let o=Br();return(await this.api.post(o,{email:this.meta.email})).data}catch(o){throw V(o)}}};var dt=class{constructor(e,o,r){this.meta={provider:e},this.meta.authorizationCode=o,this.meta.stateCode=r}isActive(){return!!(this.meta.authorizationCode&&this.meta.stateCode&&this.meta.provider)}async authenticate(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new w("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if(this.meta.authorizationCode==="undefined")throw new w("User denied confirmation during OAuth flow");try{let e=qr(),o=await this.api.post(e,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(e){throw V(e)}}async link(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new w("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if(this.meta.authorizationCode==="undefined")throw new w("User denied confirmation during OAuth flow");try{let e=Kr();return(await this.api.post(e,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode})).data}catch(e){throw V(e)}}async getAuthorizationUrl(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.provider)throw new w("Provider must be set when initialzing OAuth authentication.");try{let e=Zr();return(await this.api.post(e,{provider:this.meta.provider,redirect_to:window.location.href})).data}catch(e){throw V(e)}}};var Nt=class{constructor(e,o){this.meta={walletType:o},this.connectors=e,this.walletConnector=this.connectors.createWalletConnector(o,null)}async authenticate(){if(!this.api)throw new w("Auth flow has no API instance");try{let{message:e,signature:o}=await this.promptConnectAndSign(this.api),r=await this.api.post(Fr(),{message:e,signature:o});return this.connectors.addWalletConnector(this.walletConnector),await this.connectors.setActiveWallet(this.walletConnector.address)||console.warn("Failed to set active wallet"),{user:r.data.user,token:r.data.token,refresh_token:r.data.refresh_token,is_new_user:r.data.is_new_user}}catch(e){throw V(e)}}async link(){if(!this.api)throw new w("Auth flow has no API instance");try{let{message:e,signature:o}=await this.promptConnectAndSign(this.api),r=await this.api.post(Gr(),{message:e,signature:o});return this.connectors.addWalletConnector(this.walletConnector),await this.connectors.setActiveWallet(this.walletConnector.address)||console.warn("Failed to set active wallet"),r.data}catch(e){throw V(e)}}async promptConnectAndSign(e){let o=await this.walletConnector.connect({showPrompt:!0}),r=o.address,i=o.chainId,n=await e.post(Dr(),{address:r}),s=this.walletConnector.prepareMessage(i,r,n.data.nonce),a=await this.walletConnector.sign(s);return{message:s,signature:a}}};var Ot=class{constructor(e){this.meta={phoneNumber:e}}async authenticate(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new w("phone number and sms code must be set prior to calling authenticate.");try{let e=$r(),o=await this.api.post(e,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(e){throw V(e)}}async link(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new w("phone number and sms code must be set prior to calling authenticate.");try{let e=jr();return(await this.api.post(e,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})).data}catch(e){throw V(e)}}async sendSmsCode(e){if(!this.api)throw new w("Auth flow has no API instance");if(e&&(this.meta.phoneNumber=e),!this.meta.phoneNumber)throw new w("phone nNumber must be set when initialzing authentication.");try{let o=zr();return(await this.api.post(o,{phoneNumber:this.meta.phoneNumber})).data}catch(o){throw V(o)}}};var wi=require("@ethersproject/address");var ei="1.17.0";var ti="https://api.privy.io/v0",Ho=process.env.NEXT_PUBLIC_PRIVY_AUTH_URL||"https://auth.privy.io",Ut="4df5e2316331463a9130964bd6078dfa",oi=1e4,he=1400,Qt=ei;var pt="privy:token",eo="privy:refresh_token",to="privy:connectors",ri="walletconnect",zo=3e4;var $o=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]}getKeys(){return Object.keys(this._cache)}},jo=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)}getKeys(){return Object.entries(localStorage).map(([e])=>e)}};function Qn(){return typeof window<"u"&&window.localStorage?new jo:new $o}var re=Qn();var ai=E(require("@coinbase/wallet-sdk")),li=require("@ethersproject/address");var ni=require("@ethersproject/address"),si=require("@ethersproject/providers");var ii=require("@ethersproject/logger");var ut=class extends Z{constructor(){super("Wallet timeout");this.type="wallet_error"}},Ve=t=>{if(t instanceof Z)return t;if((t==null?void 0:t.code)&&(t==null?void 0:t.reason)){let e=new ht(t);return t.code===ii.ErrorCode.ACTION_REJECTED&&(e.details=ot.E4001_USER_REJECTED_REQUEST),e}return t!=null&&t.code?new ht(t):new Z("Unknown connector error",t)},Zo=class extends ve{constructor(o,r,i){super(o);this.type="provider_error";this.code=r,this.data=i}},ht=class extends Zo{constructor(o){var n,s,a;let r=o;super(r.message,r.code,r.data);let i=Object.values(ot).find(h=>h.eipCode===r.code);this.details=i||ot.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=ot.E32002_CONNECTION_ALREADY_PENDING:this.details=ot.E32002_REQUEST_ALREADY_PENDING:(a=r.message)!=null&&a.includes("Already processing")&&r.message.includes("eth_requestAccounts")&&(this.details=ot.E32002_WALLET_LOCKED))}},es={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}},ts={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}},os={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}},ot={UNKNOWN_ERROR:{eipCode:0,message:"Unknown error",detail:"Unknown error",retryable:!0},...os,...ts},mt={...es,...ot};var rs=12e4,qo=(t=new ut,e=rs)=>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})}async request(e){if(!this.walletProvider)throw new Z(`A wallet request of type ${e.method} was made before setting a wallet provider.`);return Promise.race([this.walletProvider.request(e),qo()]).catch(o=>{throw Ve(o)})}},Se=class extends Ce{constructor(o){super(o)}},oo=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 ke=class{constructor(e,o,r){this.createSiweMessage=(e,o,r,i,n,s,a)=>`${r} wants you to sign in with your Ethereum account:
|
|
1
|
+
"use strict";var $n=Object.create;var Xt=Object.defineProperty;var jn=Object.getOwnPropertyDescriptor;var Zn=Object.getOwnPropertyNames;var qn=Object.getPrototypeOf,Kn=Object.prototype.hasOwnProperty;var Jn=(t,e)=>{for(var o in e)Xt(t,o,{get:e[o],enumerable:!0})},Rr=(t,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Zn(e))!Kn.call(t,i)&&i!==o&&Xt(t,i,{get:()=>e[i],enumerable:!(r=jn(e,i))||r.enumerable});return t};var E=(t,e,o)=>(o=t!=null?$n(qn(t)):{},Rr(e||!t||!t.__esModule?Xt(o,"default",{value:t,enumerable:!0}):o,t)),Yn=t=>Rr(Xt({},"__esModule",{value:!0}),t);var ol={};Jn(ol,{AsExternalProvider:()=>Se,ConnectorManager:()=>ft,PrivyClient:()=>gt,PrivyProvider:()=>zn,PrivyProxyProvider:()=>Ce,VERSION:()=>Qt,WalletConnector:()=>ke,getAccessToken:()=>Hn,usePrivy:()=>q});module.exports=Yn(ol);var Vn=require("@ethersproject/providers"),Y=require("react");var Mr=E(require("axios")),ve=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}]`:""}`}},ct=class extends ve{constructor(o,r,i,n){super(i,n);this.type=o;this.status=r}},w=class extends ve{constructor(o,r){super(o,r);this.type="client_error"}};var Z=class extends ve{constructor(o,r){super(o,r);this.type="connector_error"}},V=t=>{if(t instanceof ve)return t;if(!Mr.default.isAxiosError(t))return ue(t);if(!t.response)return new ct("api_error",null,t.message,t);let{type:e,message:o,error:r}=t.response.data;return new ct(e||"ApiError",t.response.status,o||r,t)},ue=t=>t instanceof ve?t:t instanceof Error?new w(t.message,t):new w(`Internal error: ${t}`);var Nr=()=>"/api/v1/sessions",Or=()=>"/api/v1/sessions/logout",Ur=()=>"/api/v1/sessions/fork",Dr=()=>"/api/v1/siwe/init",Fr=()=>"/api/v1/siwe/authenticate",Gr=()=>"/api/v1/siwe/link",Br=()=>"/api/v1/passwordless/init",Vr=()=>"/api/v1/passwordless/authenticate",Hr=()=>"/api/v1/passwordless/link",zr=()=>"/api/v1/passwordless_sms/init",$r=()=>"/api/v1/passwordless_sms/authenticate",jr=()=>"/api/v1/passwordless_sms/link",Zr=()=>"/api/v1/oauth/init",qr=()=>"/api/v1/oauth/authenticate",Kr=()=>"/api/v1/oauth/link",Jr=()=>"/api/v1/siwe/unlink",Yr=()=>"/api/v1/passwordless/unlink",Xr=()=>"/api/v1/passwordless_sms/unlink",Qr=()=>"/api/v1/oauth/unlink";var Mt=class{constructor(e){this.meta={email:e}}async authenticate(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new w("Email and email code must be set prior to calling authenticate.");try{let e=Vr(),o=await this.api.post(e,{email:this.meta.email,code:this.meta.emailCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(e){throw V(e)}}async link(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new w("Email and email code must be set prior to calling authenticate.");try{let e=Hr();return(await this.api.post(e,{email:this.meta.email,code:this.meta.emailCode})).data}catch(e){throw V(e)}}async sendCodeEmail(e){if(!this.api)throw new w("Auth flow has no API instance");if(e&&(this.meta.email=e),!this.meta.email)throw new w("Email must be set when initialzing authentication.");try{let o=Br();return(await this.api.post(o,{email:this.meta.email})).data}catch(o){throw V(o)}}};var dt=class{constructor(e,o,r){this.meta={provider:e},this.meta.authorizationCode=o,this.meta.stateCode=r}isActive(){return!!(this.meta.authorizationCode&&this.meta.stateCode&&this.meta.provider)}async authenticate(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new w("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if(this.meta.authorizationCode==="undefined")throw new w("User denied confirmation during OAuth flow");try{let e=qr(),o=await this.api.post(e,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(e){throw V(e)}}async link(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new w("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if(this.meta.authorizationCode==="undefined")throw new w("User denied confirmation during OAuth flow");try{let e=Kr();return(await this.api.post(e,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode})).data}catch(e){throw V(e)}}async getAuthorizationUrl(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.provider)throw new w("Provider must be set when initialzing OAuth authentication.");try{let e=Zr();return(await this.api.post(e,{provider:this.meta.provider,redirect_to:window.location.href})).data}catch(e){throw V(e)}}};var Nt=class{constructor(e,o){this.meta={walletType:o},this.connectors=e,this.walletConnector=this.connectors.createWalletConnector(o,null)}async authenticate(){if(!this.api)throw new w("Auth flow has no API instance");try{let{message:e,signature:o}=await this.promptConnectAndSign(this.api),r=await this.api.post(Fr(),{message:e,signature:o});return this.connectors.addWalletConnector(this.walletConnector),await this.connectors.setActiveWallet(this.walletConnector.address)||console.warn("Failed to set active wallet"),{user:r.data.user,token:r.data.token,refresh_token:r.data.refresh_token,is_new_user:r.data.is_new_user}}catch(e){throw V(e)}}async link(){if(!this.api)throw new w("Auth flow has no API instance");try{let{message:e,signature:o}=await this.promptConnectAndSign(this.api),r=await this.api.post(Gr(),{message:e,signature:o});return this.connectors.addWalletConnector(this.walletConnector),await this.connectors.setActiveWallet(this.walletConnector.address)||console.warn("Failed to set active wallet"),r.data}catch(e){throw V(e)}}async promptConnectAndSign(e){let o=await this.walletConnector.connect({showPrompt:!0}),r=o.address,i=o.chainId,n=await e.post(Dr(),{address:r}),s=this.walletConnector.prepareMessage(i,r,n.data.nonce),a=await this.walletConnector.sign(s);return{message:s,signature:a}}};var Ot=class{constructor(e){this.meta={phoneNumber:e}}async authenticate(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new w("phone number and sms code must be set prior to calling authenticate.");try{let e=$r(),o=await this.api.post(e,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(e){throw V(e)}}async link(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new w("phone number and sms code must be set prior to calling authenticate.");try{let e=jr();return(await this.api.post(e,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})).data}catch(e){throw V(e)}}async sendSmsCode(e){if(!this.api)throw new w("Auth flow has no API instance");if(e&&(this.meta.phoneNumber=e),!this.meta.phoneNumber)throw new w("phone nNumber must be set when initialzing authentication.");try{let o=zr();return(await this.api.post(o,{phoneNumber:this.meta.phoneNumber})).data}catch(o){throw V(o)}}};var wi=require("@ethersproject/address");var ei="1.17.1";var ti="https://api.privy.io/v0",Ho=process.env.NEXT_PUBLIC_PRIVY_AUTH_URL||"https://auth.privy.io",Ut="4df5e2316331463a9130964bd6078dfa",oi=1e4,he=1400,Qt=ei;var pt="privy:token",eo="privy:refresh_token",to="privy:connectors",ri="walletconnect",zo=3e4;var $o=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]}getKeys(){return Object.keys(this._cache)}},jo=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)}getKeys(){return Object.entries(localStorage).map(([e])=>e)}};function Qn(){return typeof window<"u"&&window.localStorage?new jo:new $o}var re=Qn();var ai=E(require("@coinbase/wallet-sdk")),li=require("@ethersproject/address");var ni=require("@ethersproject/address"),si=require("@ethersproject/providers");var ii=require("@ethersproject/logger");var ut=class extends Z{constructor(){super("Wallet timeout");this.type="wallet_error"}},Ve=t=>{if(t instanceof Z)return t;if((t==null?void 0:t.code)&&(t==null?void 0:t.reason)){let e=new ht(t);return t.code===ii.ErrorCode.ACTION_REJECTED&&(e.details=ot.E4001_USER_REJECTED_REQUEST),e}return t!=null&&t.code?new ht(t):new Z("Unknown connector error",t)},Zo=class extends ve{constructor(o,r,i){super(o);this.type="provider_error";this.code=r,this.data=i}},ht=class extends Zo{constructor(o){var n,s,a;let r=o;super(r.message,r.code,r.data);let i=Object.values(ot).find(h=>h.eipCode===r.code);this.details=i||ot.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=ot.E32002_CONNECTION_ALREADY_PENDING:this.details=ot.E32002_REQUEST_ALREADY_PENDING:(a=r.message)!=null&&a.includes("Already processing")&&r.message.includes("eth_requestAccounts")&&(this.details=ot.E32002_WALLET_LOCKED))}},es={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}},ts={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}},os={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}},ot={UNKNOWN_ERROR:{eipCode:0,message:"Unknown error",detail:"Unknown error",retryable:!0},...os,...ts},mt={...es,...ot};var rs=12e4,qo=(t=new ut,e=rs)=>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})}async request(e){if(!this.walletProvider)throw new Z(`A wallet request of type ${e.method} was made before setting a wallet provider.`);return Promise.race([this.walletProvider.request(e),qo()]).catch(o=>{throw Ve(o)})}},Se=class extends Ce{constructor(o){super(o)}},oo=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 ke=class{constructor(e,o,r){this.createSiweMessage=(e,o,r,i,n,s,a)=>`${r} wants you to sign in with your Ethereum account:
|
|
2
2
|
${o}
|
|
3
3
|
|
|
4
4
|
${a}
|
|
@@ -215,7 +215,7 @@ Resources:
|
|
|
215
215
|
border-color: var(--light-theme-bg-3);
|
|
216
216
|
border-width: 1px;
|
|
217
217
|
}
|
|
218
|
-
`;var W=require("react/jsx-runtime"),dr=6,Ui=new Array(dr).fill(""),ys=1400;var Fi=()=>{var T,we,Ge;let{app:t,data:e,navigate:o,setModalData:r}=C(),{closePrivyModal:i,resendEmailCode:n,resendSmsCode:s,getAuthMeta:a,loginWithCode:h}=S(),{authenticated:m,user:L}=q(),[_,
|
|
218
|
+
`;var W=require("react/jsx-runtime"),dr=6,Ui=new Array(dr).fill(""),ys=1400;var Fi=()=>{var T,we,Ge;let{app:t,data:e,navigate:o,setModalData:r}=C(),{closePrivyModal:i,resendEmailCode:n,resendSmsCode:s,getAuthMeta:a,loginWithCode:h}=S(),{authenticated:m,user:L}=q(),[_,g]=(0,je.useState)(Ui),[y,f]=(0,je.useState)(!1),[d,R]=(0,je.useState)(null),[D,M]=(0,je.useState)(null),x=(T=a())!=null&&T.email?0:1;(0,je.useEffect)(()=>{var U;if(!(m&&y&&L))return;if(((U=e==null?void 0:e.login)==null?void 0:U.promptCreatePrivyWalletFlow)&&!L.wallet){let Pe=setTimeout(()=>{r({createWallet:{onSuccess:()=>i({shouldCallAuthOnSuccess:!0}),onFailure:tt=>console.error(tt)}}),o("EMBEDDED_WALLET_SCREEN")},he-500);return()=>clearTimeout(Pe)}else{let Pe=setTimeout(i,he);return()=>clearTimeout(Pe)}},[m,y,L]),(0,je.useEffect)(()=>{if(d&&D===0){let z=setTimeout(()=>{g(Ui),R(null);let $=document.querySelector("input[name=code-0]");$==null||$.focus()},ys);return()=>clearTimeout(z)}},[d]);let N=z=>{var Vo;let $=z.currentTarget.value.replace(" ","");if($==="")return;if(isNaN(Number($))){R("Code should be numeric"),M(1);return}R(null),M(null);let U=Number((Vo=z.currentTarget.name)==null?void 0:Vo.charAt(5)),Pe=[...$||[""]].slice(0,dr-U),tt=[..._.slice(0,U),...Pe,..._.slice(U+Pe.length)];g(tt);let Rt=Pe.length,Yt=Math.min(Math.max(U+Rt,0),dr-1);if(!isNaN(Number(z.currentTarget.value))){let X=document.querySelector(`input[name=code-${Yt}]`);X==null||X.focus()}if(tt.every(X=>X&&!isNaN(+X))){let X=document.querySelector(`input[name=code-${Yt}]`);X==null||X.blur(),h(tt.join("")).then(()=>f(!0)).catch(l=>{(l==null?void 0:l.status)===422?R("Invalid or expired verification code"):R("Issue verifying code"),M(0)})}z.preventDefault()},j=z=>{D===1&&(R(null),M(null));let $=[..._.slice(0,z),"",..._.slice(z+1)];if(g($),z>0){let U=document.querySelector(`input[name=code-${z-1}]`);U==null||U.focus()}},ae=`Verify your ${x==0?"email":"phone"}`,O=x==0?(0,W.jsxs)("p",{children:["Please check ",(0,W.jsx)(xs,{children:(we=a())==null?void 0:we.email})," for an email from privy.io and enter your code below."]}):`Please check ${(Ge=a())==null?void 0:Ge.phoneNumber} for a message from ${(t==null?void 0:t.name)||"privy.io"} and enter your code below.`;return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(P,{},"header"),(0,W.jsxs)(ws,{children:[(0,W.jsx)(ce,{title:ae,description:O}),(0,W.jsxs)(Ri,{children:[(0,W.jsxs)(vs,{children:[(0,W.jsx)(Cs,{fail:!!d,success:y,children:(0,W.jsx)("span",{children:d||(y?"Success!":"")})}),(0,W.jsx)("div",{children:_.map((z,$)=>(0,W.jsx)("input",{name:`code-${$}`,type:"text",value:_[$],onChange:N,onKeyUp:U=>{U.key==="Backspace"&&j($)},inputMode:"numeric",autoFocus:$===0,pattern:"[0-9]",className:`${y?"success":""} ${d?"fail":""}`,autoComplete:Di.isMobile?"one-time-code":"off"},$))})]}),(0,W.jsx)(bs,{children:x==0?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)("span",{children:"Didn't get an email?"}),(0,W.jsx)("button",{onClick:n,children:"Resend Code"})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)("span",{children:"Didn't get a message?"}),(0,W.jsx)("button",{onClick:s,children:"Resend Code"})]})})]})]}),(0,W.jsx)(Q,{protectedByPrivy:!0})]})},ws=wt.default.div`
|
|
219
219
|
display: flex;
|
|
220
220
|
flex-direction: column;
|
|
221
221
|
align-items: flex-start;
|
|
@@ -361,7 +361,7 @@ Resources:
|
|
|
361
361
|
|
|
362
362
|
transition: border-color 350ms ease;
|
|
363
363
|
}
|
|
364
|
-
`;var Vt=require("react/jsx-runtime"),Te=({style:t,...e})=>(0,Vt.jsxs)("svg",{width:"1024",height:"1024",viewBox:"0 0 1024 1024",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...t},...e,children:[(0,Vt.jsx)("rect",{width:"1024",height:"1024",fill:"#0052FF",rx:100,ry:100}),(0,Vt.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z",fill:"white"})]});var ee=require("react/jsx-runtime"),We=({style:t,...e})=>(0,ee.jsxs)("svg",{width:"28",height:"28",viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...t},...e,children:[(0,ee.jsx)("rect",{width:"28",height:"28",rx:"6",fill:"white"}),(0,ee.jsx)("path",{d:"M23.0126 5L15.1958 10.7823L16.6533 7.37359L23.0126 5Z",fill:"#E17726",stroke:"#E17726",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ee.jsx)("path",{d:"M4.98753 5L12.7329 10.8299L11.3468 7.37954L4.98753 5ZM20.1987 18.4027L18.1166 21.5794L22.5723 22.8049L23.8454 18.4741L20.1987 18.4027ZM4.16064 18.4741L5.42775 22.8049L9.87153 21.5794L7.80133 18.4027L4.16064 18.4741Z",fill:"#E27625",stroke:"#E27625",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ee.jsx)("path",{d:"M9.6336 13.0369L8.39624 14.9049L12.7984 15.1071L12.6556 10.3659L9.6336 13.0429V13.0369ZM18.3665 13.0429L15.2969 10.3064L15.1958 15.1071L19.5979 14.9049L18.3665 13.0429ZM9.87155 21.5794L12.5426 20.2945L10.2463 18.5098L9.87155 21.5794ZM15.4635 20.2886L18.1166 21.5794L17.7597 18.5039L15.4635 20.2886Z",fill:"#E27625",stroke:"#E27625",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ee.jsx)("path",{d:"M18.1167 21.5794L15.4635 20.2944L15.6776 22.0196L15.6539 22.7513L18.1167 21.5794ZM9.87158 21.5794L12.3463 22.7513L12.3285 22.0196L12.5426 20.2944L9.87158 21.5794Z",fill:"#D5BFB2",stroke:"#D5BFB2",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ee.jsx)("path",{d:"M12.3878 17.3616L10.1868 16.7191L11.7454 16.0052L12.3938 17.3616H12.3878ZM15.6062 17.3616L16.2605 15.9993L17.8251 16.7131L15.6062 17.3675V17.3616Z",fill:"#233447",stroke:"#233447",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ee.jsx)("path",{d:"M9.87147 21.5794L10.2581 18.4027L7.80127 18.4741L9.87147 21.5794ZM17.7418 18.4027L18.1166 21.5794L20.1987 18.4741L17.7418 18.4027ZM19.6038 14.9048L15.2016 15.107L15.6061 17.3676L16.2605 15.9994L17.8251 16.7132L19.6038 14.9048ZM10.1868 16.7192L11.7454 16.0053L12.3938 17.3617L12.8042 15.1011L8.4021 14.9048L10.1868 16.7192Z",fill:"#CC6228",stroke:"#CC6228",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ee.jsx)("path",{d:"M8.4021 14.9048L10.2462 18.5038L10.1868 16.7192L8.4021 14.9048ZM17.8251 16.7192L17.7537 18.5038L19.5978 14.9048L17.8251 16.7192ZM12.8042 15.107L12.3878 17.3676L12.9113 20.0327L13.0303 16.5169L12.8042 15.107ZM15.1957 15.107L14.9815 16.511L15.0886 20.0327L15.6061 17.3617L15.1957 15.1011V15.107Z",fill:"#E27525",stroke:"#E27525",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ee.jsx)("path",{d:"M15.6062 17.3617L15.0887 20.0327L15.4635 20.2945L17.7538 18.5098L17.8252 16.7192L15.6062 17.3617ZM10.1869 16.7192L10.2463 18.5039L12.5426 20.2885L12.9114 20.0327L12.3939 17.3617L10.1809 16.7192H10.1869Z",fill:"#F5841F",stroke:"#F5841F",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ee.jsx)("path",{d:"M15.6598 22.7513L15.6776 22.0196L15.4754 21.853H12.5248L12.3285 22.0196L12.3463 22.7513L9.87158 21.5793L10.7401 22.2932L12.495 23.5008H15.4992L17.26 22.2873L18.1167 21.5793L15.6539 22.7513H15.6598Z",fill:"#C0AC9D",stroke:"#C0AC9D",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ee.jsx)("path",{d:"M15.4634 20.2885L15.0886 20.0327H12.9114L12.5425 20.2945L12.3284 22.0196L12.5247 21.8531H15.4753L15.6776 22.0196L15.4634 20.2945V20.2885Z",fill:"#161616",stroke:"#161616",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ee.jsx)("path",{d:"M23.3456 11.1571L24 7.97442L23.0125 5L15.4575 10.5919L18.3664 13.0369L22.4711 14.2326L23.3754 13.1797L22.9827 12.8941L23.6074 12.323L23.1315 11.9542L23.7561 11.4783L23.3397 11.1571H23.3456ZM4 7.96847L4.66627 11.1571L4.23795 11.4723L4.87448 11.9482L4.39857 12.323L5.01725 12.8941L4.62463 13.1797L5.52885 14.2326L9.63355 13.0428L12.5425 10.586L4.98751 5L4 7.96847Z",fill:"#763E1A",stroke:"#763E1A",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ee.jsx)("path",{d:"M22.4712 14.2325L18.3665 13.0428L19.6038 14.9048L17.7597 18.5038L20.1987 18.4741H23.8454L22.4712 14.2325ZM9.63358 13.0368L5.52888 14.2325L4.16064 18.4741H7.80728L10.2463 18.5038L8.40217 14.9048L9.63953 13.0368H9.63358ZM15.1957 15.107L15.4634 10.5859L16.6532 7.37354H11.3468L12.5366 10.5859L12.8043 15.107L12.9054 16.5229V20.0327H15.0887L15.1006 16.5229L15.1957 15.107Z",fill:"#F5841F",stroke:"#F5841F",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"})]});var De=require("react/jsx-runtime"),bt=({style:t,...e})=>(0,De.jsxs)("svg",{width:"28",height:"28",viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...t},...e,children:[(0,De.jsx)("rect",{width:"28",height:"28",rx:"6",fill:"#141414"}),(0,De.jsx)("g",{clipPath:"url(#clip0_1765_9946)",children:(0,De.jsx)("path",{d:"M8.09448 10.3941C11.3558 7.20196 16.6442 7.20196 19.9055 10.3941L20.2982 10.7782C20.3369 10.8157 20.3677 10.8606 20.3887 10.9102C20.4097 10.9599 20.4206 11.0132 20.4206 11.0671C20.4206 11.121 20.4097 11.1744 20.3887 11.224C20.3677 11.2737 20.3369 11.3186 20.2982 11.3561L18.9554 12.6702C18.9158 12.7086 18.8628 12.7301 18.8077 12.7301C18.7526 12.7301 18.6996 12.7086 18.66 12.6702L18.1198 12.1415C15.8448 9.91503 12.1557 9.91503 9.88015 12.1415L9.30167 12.7075C9.26207 12.7459 9.20909 12.7673 9.15395 12.7673C9.0988 12.7673 9.04582 12.7459 9.00622 12.7075L7.66346 11.3934C7.62475 11.3559 7.59397 11.3109 7.57295 11.2613C7.55193 11.2117 7.5411 11.1583 7.5411 11.1044C7.5411 11.0505 7.55193 10.9971 7.57295 10.9475C7.59397 10.8979 7.62475 10.8529 7.66346 10.8154L8.09448 10.3941ZM22.6829 13.1115L23.8776 14.2814C23.9163 14.319 23.9471 14.3639 23.9681 14.4135C23.9892 14.4632 24 14.5165 24 14.5704C24 14.6243 23.9892 14.6777 23.9681 14.7273C23.9471 14.777 23.9163 14.8219 23.8776 14.8594L18.4893 20.1332C18.4102 20.2101 18.3042 20.2531 18.1938 20.2531C18.0835 20.2531 17.9775 20.2101 17.8984 20.1332L14.0743 16.3901C14.0545 16.3708 14.0279 16.36 14.0003 16.36C13.9726 16.36 13.9461 16.3708 13.9263 16.3901L10.1021 20.1332C10.023 20.2101 9.91703 20.2531 9.8067 20.2531C9.69636 20.2531 9.59038 20.2101 9.51124 20.1332L4.12236 14.8594C4.08365 14.8219 4.05287 14.777 4.03185 14.7273C4.01083 14.6777 4 14.6243 4 14.5704C4 14.5165 4.01083 14.4632 4.03185 14.4135C4.05287 14.3639 4.08365 14.319 4.12236 14.2814L5.31767 13.1115C5.39678 13.0348 5.50265 12.9919 5.61285 12.9919C5.72305 12.9919 5.82892 13.0348 5.90803 13.1115L9.73216 16.8546C9.75194 16.874 9.7785 16.8848 9.80616 16.8848C9.83381 16.8848 9.86037 16.874 9.88015 16.8546L13.7043 13.1115C13.7834 13.0346 13.8894 12.9916 13.9997 12.9916C14.1101 12.9916 14.216 13.0346 14.2952 13.1115L18.1198 16.8546C18.1396 16.874 18.1662 16.8848 18.1938 16.8848C18.2215 16.8848 18.2481 16.874 18.2678 16.8546L22.092 13.1115C22.1711 13.0346 22.2771 12.9916 22.3874 12.9916C22.4977 12.9916 22.6037 13.0346 22.6829 13.1115Z",fill:"white"})}),(0,De.jsx)("defs",{children:(0,De.jsx)("clipPath",{id:"clip0_1765_9946",children:(0,De.jsx)("rect",{width:"20",height:"12.2531",fill:"white",transform:"translate(4 8)"})})})]});var K=require("react/jsx-runtime"),pr=2,Gi={metamask:{name:"MetaMask",component:We},coinbase_wallet:{name:"Coinbase Wallet",component:Te},wallet_connect:{name:"WalletConnect",component:bt}},Bi=()=>{var ae;let[t,e]=(0,Fe.useState)(!1),[o,r]=(0,Fe.useState)("metamask"),[i,n]=(0,Fe.useState)(void 0),{navigate:s,navigateBack:a}=C(),{getAuthMeta:h,closePrivyModal:m,loginWithWallet:L}=S(),{walletConnectors:_}=q(),[f,y]=(0,Fe.useState)(0),{user:g}=q(),[d]=(0,Fe.useState)((g==null?void 0:g.linkedAccounts.length)||0);(0,Fe.useEffect)(()=>{var O;r(((O=h())==null?void 0:O.walletType)||"metamask"),n(void 0),L().then(()=>e(!0)).catch(T=>{T instanceof ve?console.error(T.cause):console.error(T);let we=(T==null?void 0:T.status)===401&&(T==null?void 0:T.message)==="User is not allowed to login to this app.";(T==null?void 0:T.status)===422?n(mt.ERROR_USER_EXISTS):we?s("ALLOWLIST_REJECTION_SCREEN"):T instanceof ht&&!T.details.default?n(T.details):T instanceof ut?n(mt.ERROR_TIMED_OUT):n(mt.ERROR_WALLET_CONNECTION)})},[f]),(0,Fe.useEffect)(()=>{if(t){let O=setTimeout(m,he);return()=>clearTimeout(O)}},[g]);let R=Gi[o].name,D=Gi[o].component,M=t?`Successfully connected with ${R}`:i?i.message:`Waiting for ${R}`,x="";if(t){let O=(g==null?void 0:g.linkedAccounts.length)||0;d===O?x="Wallet was already linked.":x="You\u2019re good to go!"}else if(f>=pr&&i)x="Unable to connect wallet";else if(i)x=i.detail;else switch(x="Don\u2019t see your wallet modal? Check your other browser windows.",o){case"metamask":x="For the best experience, connect only one wallet at a time.";break;case"wallet_connect":x="Open your mobile wallet app to continue";break;case"coinbase_wallet":lo()||(er(g)?x="Continue with the Coinbase app. Not the right wallet? Reset your connection below.":x="Open the Coinbase app on your phone to continue.");break}let N=(ae=_==null?void 0:_.walletConnectors)==null?void 0:ae.find(O=>O.walletType==="coinbase_wallet"),j=o==="coinbase_wallet"&&(er(g)||i===mt.ERROR_USER_EXISTS);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(P,{backFn:a}),(0,K.jsxs)(As,{children:[(0,K.jsx)(Ps,{children:(0,K.jsxs)("div",{children:[(0,K.jsx)(Ct,{success:t,fail:!!i}),(0,K.jsx)(D,{style:{width:"38px",height:"38px"}})]})}),(0,K.jsxs)(_s,{children:[(0,K.jsx)("h3",{children:M}),(0,K.jsx)("p",{children:x})]}),j?(0,K.jsx)(ur,{onClick:()=>N&&(N==null?void 0:N.disconnect()),visible:!t,disabled:t,children:"Use a different wallet"}):i==mt.ERROR_USER_EXISTS?(0,K.jsx)(ur,{onClick:a,visible:!0,children:"Use a different wallet"}):(0,K.jsx)(ur,{onClick:()=>{y(f+1),n(void 0)},visible:!t&&(i==null?void 0:i.retryable)&&f<pr,disabled:!t&&(!(i!=null&&i.retryable)||f>=pr),children:"Retry"})]})]})},As=Ht.default.div`
|
|
364
|
+
`;var Vt=require("react/jsx-runtime"),Te=({style:t,...e})=>(0,Vt.jsxs)("svg",{width:"1024",height:"1024",viewBox:"0 0 1024 1024",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...t},...e,children:[(0,Vt.jsx)("rect",{width:"1024",height:"1024",fill:"#0052FF",rx:100,ry:100}),(0,Vt.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z",fill:"white"})]});var ee=require("react/jsx-runtime"),We=({style:t,...e})=>(0,ee.jsxs)("svg",{width:"28",height:"28",viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...t},...e,children:[(0,ee.jsx)("rect",{width:"28",height:"28",rx:"6",fill:"white"}),(0,ee.jsx)("path",{d:"M23.0126 5L15.1958 10.7823L16.6533 7.37359L23.0126 5Z",fill:"#E17726",stroke:"#E17726",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ee.jsx)("path",{d:"M4.98753 5L12.7329 10.8299L11.3468 7.37954L4.98753 5ZM20.1987 18.4027L18.1166 21.5794L22.5723 22.8049L23.8454 18.4741L20.1987 18.4027ZM4.16064 18.4741L5.42775 22.8049L9.87153 21.5794L7.80133 18.4027L4.16064 18.4741Z",fill:"#E27625",stroke:"#E27625",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ee.jsx)("path",{d:"M9.6336 13.0369L8.39624 14.9049L12.7984 15.1071L12.6556 10.3659L9.6336 13.0429V13.0369ZM18.3665 13.0429L15.2969 10.3064L15.1958 15.1071L19.5979 14.9049L18.3665 13.0429ZM9.87155 21.5794L12.5426 20.2945L10.2463 18.5098L9.87155 21.5794ZM15.4635 20.2886L18.1166 21.5794L17.7597 18.5039L15.4635 20.2886Z",fill:"#E27625",stroke:"#E27625",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ee.jsx)("path",{d:"M18.1167 21.5794L15.4635 20.2944L15.6776 22.0196L15.6539 22.7513L18.1167 21.5794ZM9.87158 21.5794L12.3463 22.7513L12.3285 22.0196L12.5426 20.2944L9.87158 21.5794Z",fill:"#D5BFB2",stroke:"#D5BFB2",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ee.jsx)("path",{d:"M12.3878 17.3616L10.1868 16.7191L11.7454 16.0052L12.3938 17.3616H12.3878ZM15.6062 17.3616L16.2605 15.9993L17.8251 16.7131L15.6062 17.3675V17.3616Z",fill:"#233447",stroke:"#233447",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ee.jsx)("path",{d:"M9.87147 21.5794L10.2581 18.4027L7.80127 18.4741L9.87147 21.5794ZM17.7418 18.4027L18.1166 21.5794L20.1987 18.4741L17.7418 18.4027ZM19.6038 14.9048L15.2016 15.107L15.6061 17.3676L16.2605 15.9994L17.8251 16.7132L19.6038 14.9048ZM10.1868 16.7192L11.7454 16.0053L12.3938 17.3617L12.8042 15.1011L8.4021 14.9048L10.1868 16.7192Z",fill:"#CC6228",stroke:"#CC6228",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ee.jsx)("path",{d:"M8.4021 14.9048L10.2462 18.5038L10.1868 16.7192L8.4021 14.9048ZM17.8251 16.7192L17.7537 18.5038L19.5978 14.9048L17.8251 16.7192ZM12.8042 15.107L12.3878 17.3676L12.9113 20.0327L13.0303 16.5169L12.8042 15.107ZM15.1957 15.107L14.9815 16.511L15.0886 20.0327L15.6061 17.3617L15.1957 15.1011V15.107Z",fill:"#E27525",stroke:"#E27525",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ee.jsx)("path",{d:"M15.6062 17.3617L15.0887 20.0327L15.4635 20.2945L17.7538 18.5098L17.8252 16.7192L15.6062 17.3617ZM10.1869 16.7192L10.2463 18.5039L12.5426 20.2885L12.9114 20.0327L12.3939 17.3617L10.1809 16.7192H10.1869Z",fill:"#F5841F",stroke:"#F5841F",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ee.jsx)("path",{d:"M15.6598 22.7513L15.6776 22.0196L15.4754 21.853H12.5248L12.3285 22.0196L12.3463 22.7513L9.87158 21.5793L10.7401 22.2932L12.495 23.5008H15.4992L17.26 22.2873L18.1167 21.5793L15.6539 22.7513H15.6598Z",fill:"#C0AC9D",stroke:"#C0AC9D",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ee.jsx)("path",{d:"M15.4634 20.2885L15.0886 20.0327H12.9114L12.5425 20.2945L12.3284 22.0196L12.5247 21.8531H15.4753L15.6776 22.0196L15.4634 20.2945V20.2885Z",fill:"#161616",stroke:"#161616",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ee.jsx)("path",{d:"M23.3456 11.1571L24 7.97442L23.0125 5L15.4575 10.5919L18.3664 13.0369L22.4711 14.2326L23.3754 13.1797L22.9827 12.8941L23.6074 12.323L23.1315 11.9542L23.7561 11.4783L23.3397 11.1571H23.3456ZM4 7.96847L4.66627 11.1571L4.23795 11.4723L4.87448 11.9482L4.39857 12.323L5.01725 12.8941L4.62463 13.1797L5.52885 14.2326L9.63355 13.0428L12.5425 10.586L4.98751 5L4 7.96847Z",fill:"#763E1A",stroke:"#763E1A",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ee.jsx)("path",{d:"M22.4712 14.2325L18.3665 13.0428L19.6038 14.9048L17.7597 18.5038L20.1987 18.4741H23.8454L22.4712 14.2325ZM9.63358 13.0368L5.52888 14.2325L4.16064 18.4741H7.80728L10.2463 18.5038L8.40217 14.9048L9.63953 13.0368H9.63358ZM15.1957 15.107L15.4634 10.5859L16.6532 7.37354H11.3468L12.5366 10.5859L12.8043 15.107L12.9054 16.5229V20.0327H15.0887L15.1006 16.5229L15.1957 15.107Z",fill:"#F5841F",stroke:"#F5841F",strokeWidth:"0.25",strokeLinecap:"round",strokeLinejoin:"round"})]});var De=require("react/jsx-runtime"),bt=({style:t,...e})=>(0,De.jsxs)("svg",{width:"28",height:"28",viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...t},...e,children:[(0,De.jsx)("rect",{width:"28",height:"28",rx:"6",fill:"#141414"}),(0,De.jsx)("g",{clipPath:"url(#clip0_1765_9946)",children:(0,De.jsx)("path",{d:"M8.09448 10.3941C11.3558 7.20196 16.6442 7.20196 19.9055 10.3941L20.2982 10.7782C20.3369 10.8157 20.3677 10.8606 20.3887 10.9102C20.4097 10.9599 20.4206 11.0132 20.4206 11.0671C20.4206 11.121 20.4097 11.1744 20.3887 11.224C20.3677 11.2737 20.3369 11.3186 20.2982 11.3561L18.9554 12.6702C18.9158 12.7086 18.8628 12.7301 18.8077 12.7301C18.7526 12.7301 18.6996 12.7086 18.66 12.6702L18.1198 12.1415C15.8448 9.91503 12.1557 9.91503 9.88015 12.1415L9.30167 12.7075C9.26207 12.7459 9.20909 12.7673 9.15395 12.7673C9.0988 12.7673 9.04582 12.7459 9.00622 12.7075L7.66346 11.3934C7.62475 11.3559 7.59397 11.3109 7.57295 11.2613C7.55193 11.2117 7.5411 11.1583 7.5411 11.1044C7.5411 11.0505 7.55193 10.9971 7.57295 10.9475C7.59397 10.8979 7.62475 10.8529 7.66346 10.8154L8.09448 10.3941ZM22.6829 13.1115L23.8776 14.2814C23.9163 14.319 23.9471 14.3639 23.9681 14.4135C23.9892 14.4632 24 14.5165 24 14.5704C24 14.6243 23.9892 14.6777 23.9681 14.7273C23.9471 14.777 23.9163 14.8219 23.8776 14.8594L18.4893 20.1332C18.4102 20.2101 18.3042 20.2531 18.1938 20.2531C18.0835 20.2531 17.9775 20.2101 17.8984 20.1332L14.0743 16.3901C14.0545 16.3708 14.0279 16.36 14.0003 16.36C13.9726 16.36 13.9461 16.3708 13.9263 16.3901L10.1021 20.1332C10.023 20.2101 9.91703 20.2531 9.8067 20.2531C9.69636 20.2531 9.59038 20.2101 9.51124 20.1332L4.12236 14.8594C4.08365 14.8219 4.05287 14.777 4.03185 14.7273C4.01083 14.6777 4 14.6243 4 14.5704C4 14.5165 4.01083 14.4632 4.03185 14.4135C4.05287 14.3639 4.08365 14.319 4.12236 14.2814L5.31767 13.1115C5.39678 13.0348 5.50265 12.9919 5.61285 12.9919C5.72305 12.9919 5.82892 13.0348 5.90803 13.1115L9.73216 16.8546C9.75194 16.874 9.7785 16.8848 9.80616 16.8848C9.83381 16.8848 9.86037 16.874 9.88015 16.8546L13.7043 13.1115C13.7834 13.0346 13.8894 12.9916 13.9997 12.9916C14.1101 12.9916 14.216 13.0346 14.2952 13.1115L18.1198 16.8546C18.1396 16.874 18.1662 16.8848 18.1938 16.8848C18.2215 16.8848 18.2481 16.874 18.2678 16.8546L22.092 13.1115C22.1711 13.0346 22.2771 12.9916 22.3874 12.9916C22.4977 12.9916 22.6037 13.0346 22.6829 13.1115Z",fill:"white"})}),(0,De.jsx)("defs",{children:(0,De.jsx)("clipPath",{id:"clip0_1765_9946",children:(0,De.jsx)("rect",{width:"20",height:"12.2531",fill:"white",transform:"translate(4 8)"})})})]});var K=require("react/jsx-runtime"),pr=2,Gi={metamask:{name:"MetaMask",component:We},coinbase_wallet:{name:"Coinbase Wallet",component:Te},wallet_connect:{name:"WalletConnect",component:bt}},Bi=()=>{var ae;let[t,e]=(0,Fe.useState)(!1),[o,r]=(0,Fe.useState)("metamask"),[i,n]=(0,Fe.useState)(void 0),{navigate:s,navigateBack:a}=C(),{getAuthMeta:h,closePrivyModal:m,loginWithWallet:L}=S(),{walletConnectors:_}=q(),[g,y]=(0,Fe.useState)(0),{user:f}=q(),[d]=(0,Fe.useState)((f==null?void 0:f.linkedAccounts.length)||0);(0,Fe.useEffect)(()=>{var O;r(((O=h())==null?void 0:O.walletType)||"metamask"),n(void 0),L().then(()=>e(!0)).catch(T=>{T instanceof ve?console.error(T.cause):console.error(T);let we=(T==null?void 0:T.status)===401&&(T==null?void 0:T.message)==="User is not allowed to login to this app.";(T==null?void 0:T.status)===422?n(mt.ERROR_USER_EXISTS):we?s("ALLOWLIST_REJECTION_SCREEN"):T instanceof ht&&!T.details.default?n(T.details):T instanceof ut?n(mt.ERROR_TIMED_OUT):n(mt.ERROR_WALLET_CONNECTION)})},[g]),(0,Fe.useEffect)(()=>{if(f&&t){let O=setTimeout(m,he);return()=>clearTimeout(O)}},[f,t]);let R=Gi[o].name,D=Gi[o].component,M=t?`Successfully connected with ${R}`:i?i.message:`Waiting for ${R}`,x="";if(t){let O=(f==null?void 0:f.linkedAccounts.length)||0;d===O?x="Wallet was already linked.":x="You\u2019re good to go!"}else if(g>=pr&&i)x="Unable to connect wallet";else if(i)x=i.detail;else switch(x="Don\u2019t see your wallet modal? Check your other browser windows.",o){case"metamask":x="For the best experience, connect only one wallet at a time.";break;case"wallet_connect":x="Open your mobile wallet app to continue";break;case"coinbase_wallet":lo()||(er(f)?x="Continue with the Coinbase app. Not the right wallet? Reset your connection below.":x="Open the Coinbase app on your phone to continue.");break}let N=(ae=_==null?void 0:_.walletConnectors)==null?void 0:ae.find(O=>O.walletType==="coinbase_wallet"),j=o==="coinbase_wallet"&&(er(f)||i===mt.ERROR_USER_EXISTS);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(P,{backFn:a}),(0,K.jsxs)(As,{children:[(0,K.jsx)(Ps,{children:(0,K.jsxs)("div",{children:[(0,K.jsx)(Ct,{success:t,fail:!!i}),(0,K.jsx)(D,{style:{width:"38px",height:"38px"}})]})}),(0,K.jsxs)(_s,{children:[(0,K.jsx)("h3",{children:M}),(0,K.jsx)("p",{children:x})]}),j?(0,K.jsx)(ur,{onClick:()=>N&&(N==null?void 0:N.disconnect()),visible:!t,disabled:t,children:"Use a different wallet"}):i==mt.ERROR_USER_EXISTS?(0,K.jsx)(ur,{onClick:a,visible:!0,children:"Use a different wallet"}):(0,K.jsx)(ur,{onClick:()=>{y(g+1),n(void 0)},visible:!t&&(i==null?void 0:i.retryable)&&g<pr,disabled:!t&&(!(i!=null&&i.retryable)||g>=pr),children:"Retry"})]})]})},As=Ht.default.div`
|
|
365
365
|
display: flex;
|
|
366
366
|
flex-direction: column;
|
|
367
367
|
align-items: center;
|
|
@@ -526,7 +526,7 @@ Resources:
|
|
|
526
526
|
`,Ns=nt.default.div`
|
|
527
527
|
display: flex;
|
|
528
528
|
justify-content: center;
|
|
529
|
-
`;var At=require("react"),gr=E(require("styled-components"));var Je=require("react"),bo=E(require("styled-components"));var mr=require("react/jsx-runtime"),qi=({style:t,...e})=>(0,mr.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",style:{height:"1.5rem",width:"1.5rem",...t},...e,children:(0,mr.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0l3.181 3.183a8.25 8.25 0 0013.803-3.7M4.031 9.865a8.25 8.25 0 0113.803-3.7l3.181 3.182m0-4.991v4.99"})});var de=require("react/jsx-runtime"),Lt=6,Os=new Array(Lt).fill("");function Us(t){return t.replace(/\s+/g,"")}function fr(t){return/^[a-zA-Z0-9]{1}$/.test(t)}function Ds(t){return/^[a-zA-Z]{1}$/.test(t)}function Fs(t){return/^[a-z]{1}$/.test(t)}function Ki(t){return t.length===Lt&&t.every(fr)}function Gs(t,e){return t.reduce((o,r)=>o+Number(e(r)),0)}function Bs(){return crypto.getRandomValues(new Uint8Array(1))[0]}function Vs(){let t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",e=[];for(;e.length<Lt;){let o=Bs();o>247||e.push(t.charAt(o%62))}return e.join("")}var Ji=({onChange:t,disabled:e,readOnly:o,errorReasonOverride:r})=>{let[i,n]=(0,Je.useState)(Os),[s,a]=(0,Je.useState)(null),[h,m]=(0,Je.useState)(null),L=
|
|
529
|
+
`;var At=require("react"),gr=E(require("styled-components"));var Je=require("react"),bo=E(require("styled-components"));var mr=require("react/jsx-runtime"),qi=({style:t,...e})=>(0,mr.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",style:{height:"1.5rem",width:"1.5rem",...t},...e,children:(0,mr.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0l3.181 3.183a8.25 8.25 0 0013.803-3.7M4.031 9.865a8.25 8.25 0 0113.803-3.7l3.181 3.182m0-4.991v4.99"})});var de=require("react/jsx-runtime"),Lt=6,Os=new Array(Lt).fill("");function Us(t){return t.replace(/\s+/g,"")}function fr(t){return/^[a-zA-Z0-9]{1}$/.test(t)}function Ds(t){return/^[a-zA-Z]{1}$/.test(t)}function Fs(t){return/^[a-z]{1}$/.test(t)}function Ki(t){return t.length===Lt&&t.every(fr)}function Gs(t,e){return t.reduce((o,r)=>o+Number(e(r)),0)}function Bs(){return crypto.getRandomValues(new Uint8Array(1))[0]}function Vs(){let t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",e=[];for(;e.length<Lt;){let o=Bs();o>247||e.push(t.charAt(o%62))}return e.join("")}var Ji=({onChange:t,disabled:e,readOnly:o,errorReasonOverride:r})=>{let[i,n]=(0,Je.useState)(Os),[s,a]=(0,Je.useState)(null),[h,m]=(0,Je.useState)(null),L=g=>{var we;let y=Us(g.currentTarget.value);if(y==="")return;let f=Gs(i,fr),d=y.split(""),R=!d.every(fr),D=d.length+f>Lt;if(R){a("PIN can only be letters and numbers"),m(1);return}if(D){a("PIN must be exactly 6 letters and numbers"),m(1);return}a(null),m(null);let M=Number((we=g.currentTarget.name)==null?void 0:we.charAt(4)),x=[...y||[""]].slice(0,Lt-M),N=[...i.slice(0,M),...x,...i.slice(M+x.length)];n(N);let j=x.length,ae=Math.min(Math.max(M+j,0),Lt-1),O=document.querySelector(`input[name=pin-${ae}]`),T=x[x.length-1]||"";if(Ds(T)&&(Fs(T)?O.autocapitalize="none":O.autocapitalize="on"),O==null||O.focus(),Ki(N)){let Ge=document.querySelector(`input[name=pin-${ae}]`);Ge==null||Ge.blur(),t(N.join(""))}else t(null);g.preventDefault()},_=g=>{h===1&&(a(null),m(null));let y=[...i.slice(0,g),"",...i.slice(g+1)];if(n(y),g>0){let f=document.querySelector(`input[name=pin-${g-1}]`);f==null||f.focus()}Ki(y)?t(y.join("")):t(null)};return(0,de.jsxs)(de.Fragment,{children:[(0,de.jsxs)(Hs,{children:[(0,de.jsx)(zs,{fail:!!r||!!s,children:r||s||"PIN can be letters and numbers"}),(0,de.jsx)("div",{children:i.map((g,y)=>(0,de.jsx)("input",{name:`pin-${y}`,type:"text",value:i[y],onChange:L,onKeyUp:f=>{f.key==="Backspace"&&_(y)},inputMode:"text",autoFocus:y===0,pattern:"[a-zA-Z0-9]",className:s?"fail":"",autoComplete:"off",disabled:e||o,autoCapitalize:"none"},y))})]}),!o&&(0,de.jsx)($s,{disabled:e,onClick:()=>{let g=Vs();n([...g]),t(g)}})]})},Hs=bo.default.div`
|
|
530
530
|
display: flex;
|
|
531
531
|
flex-direction: column;
|
|
532
532
|
width: 100%;
|
|
@@ -639,7 +639,7 @@ Resources:
|
|
|
639
639
|
width: 14px;
|
|
640
640
|
height: 14px;
|
|
641
641
|
}
|
|
642
|
-
`;var J=require("react/jsx-runtime"),Yi=()=>{let{authenticated:t,getAccessToken:e,user:o}=q(),{walletProxy:r,refreshUser:i,closePrivyModal:n}=S(),{navigate:s,data:a}=C(),[h,m]=(0,At.useState)(null),[L,_]=(0,At.useState)(""),[
|
|
642
|
+
`;var J=require("react/jsx-runtime"),Yi=()=>{let{authenticated:t,getAccessToken:e,user:o}=q(),{walletProxy:r,refreshUser:i,closePrivyModal:n}=S(),{navigate:s,data:a}=C(),[h,m]=(0,At.useState)(null),[L,_]=(0,At.useState)(""),[g,y]=(0,At.useState)(!1),{onFailure:f}=a.createWallet;(0,At.useEffect)(()=>{t||(s("LANDING"),f(new Error("User must be authenticated before creating a Privy wallet")))},[t]);let d=()=>{f(new Error("User exited before creating a wallet")),n({shouldCallAuthOnSuccess:!1})},R=N=>{m(N)},D=Me(o),M=D?()=>{y(!0),setTimeout(()=>{y(!1),s("EMBEDDED_WALLET_CREATED_SCREEN")},350)}:async()=>{y(!0);let N=await e();if(N&&h!==null)try{await(r==null?void 0:r.create({accessToken:N,recoveryPin:h})),_(""),await i()}catch(j){_("An error has occurred, please try again."),console.error(j)}finally{y(!1)}},x=!!D;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(P,{onClose:d}),(0,J.jsxs)(Zs,{children:[(0,J.jsxs)("div",{children:[(0,J.jsx)(ce,{title:x?"Secure your PIN":"Set your PIN",description:x?"Don\u2019t lose this PIN. You\u2019ll need it to access your wallet across devices.":"To finish setting up your account, please set up a PIN."}),(0,J.jsx)(Ji,{onChange:R,disabled:g,readOnly:x,errorReasonOverride:L}),x?(0,J.jsx)(Co,{text:h||""}):null]}),(0,J.jsxs)(qs,{children:[(0,J.jsx)("h4",{children:"Why am I doing this?"}),x?(0,J.jsx)("p",{children:"This PIN allows you to access your wallet across devices. If you lose it, there is no way to recover your wallet."}):(0,J.jsx)("p",{children:"A digital wallet is being created on this device for your account. This PIN allows you to access it across devices."})]}),(0,J.jsx)(Ke,{loading:g||!r,disabled:!h,onClick:M,warn:x,children:x?"I have saved my PIN":"Create your wallet"})]}),(0,J.jsx)(Q,{protectedByPrivy:!0})]})},Zs=gr.default.div`
|
|
643
643
|
display: flex;
|
|
644
644
|
height: 100%;
|
|
645
645
|
flex-direction: column;
|
|
@@ -838,7 +838,7 @@ Resources:
|
|
|
838
838
|
`,la=ye.default.div`
|
|
839
839
|
display: flex;
|
|
840
840
|
justify-content: center;
|
|
841
|
-
`;var Ie=require("react/jsx-runtime"),mn=()=>{let{navigateBack:t}=C();return(0,Ie.jsxs)(Ie.Fragment,{children:[(0,Ie.jsx)(P,{backFn:t},"header"),(0,Ie.jsx)(br,{}),(0,Ie.jsxs)(xe,{children:[(0,Ie.jsx)("span",{children:"Still not sure? "}),(0,Ie.jsx)("a",{target:"_blank",href:"https://join.tell.ie/blog/explaining-web3-wallets",children:"Learn more"})]})]})};var Re=require("react/jsx-runtime"),fn=()=>{let{navigateBack:t}=C();return(0,Re.jsxs)(Re.Fragment,{children:[(0,Re.jsx)(P,{backFn:t},"header"),(0,Re.jsx)(Cr,{}),(0,Re.jsxs)(xe,{children:[(0,Re.jsx)("span",{children:"Still not sure? "}),(0,Re.jsx)("a",{target:"_blank",href:"https://join.tell.ie/blog/explaining-web3-wallets",children:"Learn more"})]})]})};var xn=require("react"),Wr=require("react-device-detect"),lt=E(require("styled-components"));var xr=require("react/jsx-runtime"),gn=()=>{let{app:t}=C();return t!=null&&t.logoUrl?(0,xr.jsx)("div",{children:(0,xr.jsx)("img",{src:t.logoUrl,alt:`${t==null?void 0:t.name} logo`,style:{objectFit:"contain",width:"200px",height:"80px"}})}):null};var _t=require("react"),Pt=E(require("styled-components"));var Er=require("react/jsx-runtime"),Lo=({style:t,...e})=>(0,Er.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",style:{height:"1.5rem",width:"1.5rem",...t},...e,children:(0,Er.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21.75 6.75v10.5a2.25 2.25 0 01-2.25 2.25h-15a2.25 2.25 0 01-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0019.5 4.5h-15a2.25 2.25 0 00-2.25 2.25m19.5 0v.243a2.25 2.25 0 01-1.07 1.916l-7.5 4.615a2.25 2.25 0 01-2.36 0L3.32 8.91a2.25 2.25 0 01-1.07-1.916V6.75"})});var ne=require("react/jsx-runtime"),Ao=t=>{let[e,o]=(0,_t.useState)(""),[r,i]=(0,_t.useState)(!1),[n,s]=(0,_t.useState)(null),{isLinking:a,initLoginWithEmail:h}=S(),{navigate:m,options:L}=C(),_=L.wallet;(0,_t.useEffect)(()=>{let d=document.querySelector("#email-input");d==null||d.focus()},[]);let
|
|
841
|
+
`;var Ie=require("react/jsx-runtime"),mn=()=>{let{navigateBack:t}=C();return(0,Ie.jsxs)(Ie.Fragment,{children:[(0,Ie.jsx)(P,{backFn:t},"header"),(0,Ie.jsx)(br,{}),(0,Ie.jsxs)(xe,{children:[(0,Ie.jsx)("span",{children:"Still not sure? "}),(0,Ie.jsx)("a",{target:"_blank",href:"https://join.tell.ie/blog/explaining-web3-wallets",children:"Learn more"})]})]})};var Re=require("react/jsx-runtime"),fn=()=>{let{navigateBack:t}=C();return(0,Re.jsxs)(Re.Fragment,{children:[(0,Re.jsx)(P,{backFn:t},"header"),(0,Re.jsx)(Cr,{}),(0,Re.jsxs)(xe,{children:[(0,Re.jsx)("span",{children:"Still not sure? "}),(0,Re.jsx)("a",{target:"_blank",href:"https://join.tell.ie/blog/explaining-web3-wallets",children:"Learn more"})]})]})};var xn=require("react"),Wr=require("react-device-detect"),lt=E(require("styled-components"));var xr=require("react/jsx-runtime"),gn=()=>{let{app:t}=C();return t!=null&&t.logoUrl?(0,xr.jsx)("div",{children:(0,xr.jsx)("img",{src:t.logoUrl,alt:`${t==null?void 0:t.name} logo`,style:{objectFit:"contain",width:"200px",height:"80px"}})}):null};var _t=require("react"),Pt=E(require("styled-components"));var Er=require("react/jsx-runtime"),Lo=({style:t,...e})=>(0,Er.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",style:{height:"1.5rem",width:"1.5rem",...t},...e,children:(0,Er.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21.75 6.75v10.5a2.25 2.25 0 01-2.25 2.25h-15a2.25 2.25 0 01-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0019.5 4.5h-15a2.25 2.25 0 00-2.25 2.25m19.5 0v.243a2.25 2.25 0 01-1.07 1.916l-7.5 4.615a2.25 2.25 0 01-2.36 0L3.32 8.91a2.25 2.25 0 01-1.07-1.916V6.75"})});var ne=require("react/jsx-runtime"),Ao=t=>{let[e,o]=(0,_t.useState)(""),[r,i]=(0,_t.useState)(!1),[n,s]=(0,_t.useState)(null),{isLinking:a,initLoginWithEmail:h}=S(),{navigate:m,options:L}=C(),_=L.wallet;(0,_t.useEffect)(()=>{let d=document.querySelector("#email-input");d==null||d.focus()},[]);let g=di(e),y=()=>{i(!0),h(e).then(()=>{m("AWAITING_PASSWORDLESS_CODE")}).catch(d=>{let R=(d==null?void 0:d.status)===401&&(d==null?void 0:d.message)==="User is not allowed to login to this app.";(d==null?void 0:d.status)===422?s(d.message):R?m("ALLOWLIST_REJECTION_SCREEN"):s("Issue submitting email"),i(!1)})},f="Get started without a wallet.";return n?f=n:a?f="Easily connect an email":_||(f="Get started quickly with email"),(0,ne.jsxs)(ne.Fragment,{children:[(0,ne.jsxs)(ca,{stacked:t.stacked,children:[(0,ne.jsxs)(ua,{standalone:t.stacked,children:[(0,ne.jsx)(Lo,{}),(0,ne.jsx)("input",{id:"email-input",type:"email",placeholder:"your@email.com",onChange:d=>o(d.target.value),onKeyUp:d=>{d.key==="Enter"&&y()},value:e,autoComplete:"email"})]}),t.stacked?null:(0,ne.jsx)(da,{disabled:r||!g,onClick:y,children:r?(0,ne.jsx)(qe,{}):"Submit"})]}),(0,ne.jsx)(ha,{fail:!!n,children:f}),t.stacked?(0,ne.jsx)(pa,{disabled:r||!g,onClick:y,children:r?(0,ne.jsx)(qe,{}):"Submit"}):null]})},ca=Pt.default.div`
|
|
842
842
|
border: 1px solid var(--border-color-1);
|
|
843
843
|
width: 100%;
|
|
844
844
|
height: ${t=>t.stacked?"100%":"auto"};
|
|
@@ -950,7 +950,7 @@ Resources:
|
|
|
950
950
|
> a {
|
|
951
951
|
text-decoration: underline;
|
|
952
952
|
}
|
|
953
|
-
`;var St=require("react"),kt=E(require("styled-components"));var Lr=require("react/jsx-runtime"),_o=({style:t,...e})=>(0,Lr.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,Lr.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 se=require("react/jsx-runtime"),Po=t=>{let[e,o]=(0,St.useState)(""),[r,i]=(0,St.useState)(!1),[n,s]=(0,St.useState)(null),{isLinking:a,initLoginWithSms:h}=S(),{navigate:m,options:L}=C(),_=L.wallet;(0,St.useEffect)(()=>{let d=document.querySelector("#phone-number-input");d==null||d.focus()},[]);let
|
|
953
|
+
`;var St=require("react"),kt=E(require("styled-components"));var Lr=require("react/jsx-runtime"),_o=({style:t,...e})=>(0,Lr.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,Lr.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 se=require("react/jsx-runtime"),Po=t=>{let[e,o]=(0,St.useState)(""),[r,i]=(0,St.useState)(!1),[n,s]=(0,St.useState)(null),{isLinking:a,initLoginWithSms:h}=S(),{navigate:m,options:L}=C(),_=L.wallet;(0,St.useEffect)(()=>{let d=document.querySelector("#phone-number-input");d==null||d.focus()},[]);let g=pi(e),y=()=>{i(!0),h(e).then(()=>{m("AWAITING_PASSWORDLESS_CODE")}).catch(d=>{let R=(d==null?void 0:d.status)===401&&(d==null?void 0:d.message)==="User is not allowed to login to this app.";(d==null?void 0:d.status)===422?s(d.message):R?m("ALLOWLIST_REJECTION_SCREEN"):s("Issue submitting phone number"),i(!1)})},f="Get started without a wallet.";return n?f=n:a?f="Easily connect a phone number":_||(f="Get started quickly with your phone"),(0,se.jsxs)(se.Fragment,{children:[(0,se.jsxs)(ma,{stacked:t.stacked,children:[(0,se.jsxs)(ya,{standalone:t.stacked,children:[(0,se.jsx)(_o,{}),(0,se.jsx)("input",{id:"phone-number-input",type:"tel",placeholder:"555 555 5555",onChange:d=>{o(d.target.value)},onKeyUp:d=>{d.key==="Enter"&&y()},value:e,autoComplete:"tel"})]}),t.stacked?null:(0,se.jsx)(fa,{disabled:r||!g,onClick:y,children:r?(0,se.jsx)(qe,{}):"Submit"})]}),(0,se.jsx)(wa,{fail:!!n,children:f}),t.stacked?(0,se.jsx)(ga,{disabled:r||!g,onClick:y,children:r?(0,se.jsx)(qe,{}):"Submit"}):null]})},ma=kt.default.div`
|
|
954
954
|
display: flex;
|
|
955
955
|
border: 1px solid var(--border-color-1);
|
|
956
956
|
width: 100%;
|
|
@@ -1210,7 +1210,7 @@ Resources:
|
|
|
1210
1210
|
@media (max-width: 440px) {
|
|
1211
1211
|
margin-top: 4px;
|
|
1212
1212
|
}
|
|
1213
|
-
`;var A=require("react/jsx-runtime");var En=()=>{let{app:t,options:e}=C(),o=e.email,r=e.sms,i=e.wallet,n=e.google,s=e.twitter,a=e.discord,h=e.github,m=i&&(t==null?void 0:t.showWalletLoginFirst)?0:1,[L,_]=(0,xn.useState)(m),
|
|
1213
|
+
`;var A=require("react/jsx-runtime");var En=()=>{let{app:t,options:e}=C(),o=e.email,r=e.sms,i=e.wallet,n=e.google,s=e.twitter,a=e.discord,h=e.github,m=i&&(t==null?void 0:t.showWalletLoginFirst)?0:1,[L,_]=(0,xn.useState)(m),g=L==0,y=L==1,f=i,d=o||r;return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(P,{},"header"),(0,A.jsx)(Ta,{hasOnlyOneSection:f!==d,hasTerms:!!((t==null?void 0:t.privacyPolicyUrl)||(t==null?void 0:t.termsAndConditionsUrl)),children:(0,A.jsx)(gn,{})}),(0,A.jsxs)(Wa,{reverse:!(t!=null&&t.showWalletLoginFirst),children:[f&&(0,A.jsx)(_a,{active:g,onClick:()=>_(0),isOnlySection:!d}),d&&(0,A.jsx)(Pa,{active:y,onClick:()=>_(1),email:o,sms:r,google:n,twitter:s,discord:a,github:h,isOnlySection:!f})]}),t&&(0,A.jsx)(Mi,{app:t}),(0,A.jsx)(Q,{protectedByPrivy:!0})]})};function _a(t){return(0,A.jsxs)(An,{active:t.active,onClick:t.onClick,isOnlySection:t.isOnlySection,children:[(0,A.jsx)(Ln,{active:t.active,children:(0,A.jsx)("h4",{children:"Connect Wallet"})}),t.active&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(Ro,{}),(0,A.jsx)(Mo,{})]})]})}function Pa(t){let e=t.google||t.discord||t.github||t.twitter&&!Wr.isMobile,o=t.email?"Email":"Phone";return(0,A.jsxs)(An,{active:t.active,onClick:t.onClick,isOnlySection:t.isOnlySection,children:[t.isOnlySection?null:(0,A.jsx)(Ln,{active:t.active,children:(0,A.jsx)("h4",{children:e?`${o} & Social`:o})}),t.active&&t.email&&(0,A.jsx)(Ao,{}),t.active&&t.sms&&!t.email&&(0,A.jsx)(Po,{}),t.active&&e&&(0,A.jsx)(Sa,{google:t.google,twitter:t.twitter&&!Wr.isMobile,discord:t.discord,github:t.github})]})}function Sa(t){return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(ka,{children:[(0,A.jsx)(bn,{}),(0,A.jsx)("p",{children:" Or "}),(0,A.jsx)(bn,{})]}),(0,A.jsx)(yn,{showGoogle:t.google,showDiscord:t.discord,showGithub:t.github,showTwitter:t.twitter})]})}var Ln=lt.default.div`
|
|
1214
1214
|
font-weight: ${t=>t.active?600:500};
|
|
1215
1215
|
color: ${t=>t.active?"inherit":"var(--light-theme-fg-3)"};
|
|
1216
1216
|
display: flex;
|
|
@@ -1273,7 +1273,7 @@ Resources:
|
|
|
1273
1273
|
margin-bottom: ${t=>`${60+(t.hasOnlyOneSection?31:0)-(t.hasTerms?18:0)}px`};
|
|
1274
1274
|
`,Wa=(0,lt.default)($e)`
|
|
1275
1275
|
flex-direction: ${t=>t.reverse?"column-reverse":"column"};
|
|
1276
|
-
`;var Le=require("react/jsx-runtime"),_n=()=>{let{app:t}=C();return(0,Le.jsxs)(Le.Fragment,{children:[(0,Le.jsx)(P,{},"header"),(0,Le.jsx)(yt,{title:"Connect your email",description:`Add your email to your ${t==null?void 0:t.name} account`,icon:(0,Le.jsx)(Lo,{})}),(0,Le.jsx)($e,{children:(0,Le.jsx)(Ao,{stacked:!0})}),(0,Le.jsx)(Q,{protectedByPrivy:!0})]})};var Ae=require("react/jsx-runtime"),Pn=()=>{let{app:t}=C();return(0,Ae.jsxs)(Ae.Fragment,{children:[(0,Ae.jsx)(P,{},"header"),(0,Ae.jsx)(yt,{title:"Connect your phone",description:`Add your number to your ${t==null?void 0:t.name} account`,icon:(0,Ae.jsx)(_o,{})}),(0,Ae.jsx)($e,{children:(0,Ae.jsx)(Po,{stacked:!0})}),(0,Ae.jsx)(Q,{protectedByPrivy:!0})]})};var _e=require("react/jsx-runtime"),Sn=()=>{let{linkingHint:t}=S(),{app:e}=C(),o=t?`Select the wallet with ${rt(t)} and follow the instructions to reconnect your wallet${e!=null&&e.name?` to ${e.name}.`:"."}`:`Link a wallet to your ${e==null?void 0:e.name} account`;return(0,_e.jsxs)(_e.Fragment,{children:[(0,_e.jsx)(P,{},"header"),(0,_e.jsx)(Ni,{title:`${t?"Reconnect":"Connect"} your wallet`,description:o}),(0,_e.jsxs)($e,{children:[(0,_e.jsx)(Ro,{}),(0,_e.jsx)(Mo,{})]}),(0,_e.jsx)(Q,{protectedByPrivy:!0})]})};var Wt=require("react"),Zt=E(require("styled-components"));var ie=require("react/jsx-runtime"),kn={google:{name:"Google",component:To},discord:{name:"Discord",component:So},github:{name:"Github",component:ko},twitter:{name:"Twitter",component:Wo}},Ia=t=>t.charAt(0).toUpperCase()+t.slice(1),Ir=()=>{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)},Tn=()=>{var x;let{ready:t,user:e,authenticated:o}=q(),{data:r,setModalData:i,navigate:n}=C(),{getAuthMeta:s,initLoginWithOAuth:a,loginWithOAuth:h,closePrivyModal:m}=S(),[L,_]=(0,Wt.useState)(!1),[
|
|
1276
|
+
`;var Le=require("react/jsx-runtime"),_n=()=>{let{app:t}=C();return(0,Le.jsxs)(Le.Fragment,{children:[(0,Le.jsx)(P,{},"header"),(0,Le.jsx)(yt,{title:"Connect your email",description:`Add your email to your ${t==null?void 0:t.name} account`,icon:(0,Le.jsx)(Lo,{})}),(0,Le.jsx)($e,{children:(0,Le.jsx)(Ao,{stacked:!0})}),(0,Le.jsx)(Q,{protectedByPrivy:!0})]})};var Ae=require("react/jsx-runtime"),Pn=()=>{let{app:t}=C();return(0,Ae.jsxs)(Ae.Fragment,{children:[(0,Ae.jsx)(P,{},"header"),(0,Ae.jsx)(yt,{title:"Connect your phone",description:`Add your number to your ${t==null?void 0:t.name} account`,icon:(0,Ae.jsx)(_o,{})}),(0,Ae.jsx)($e,{children:(0,Ae.jsx)(Po,{stacked:!0})}),(0,Ae.jsx)(Q,{protectedByPrivy:!0})]})};var _e=require("react/jsx-runtime"),Sn=()=>{let{linkingHint:t}=S(),{app:e}=C(),o=t?`Select the wallet with ${rt(t)} and follow the instructions to reconnect your wallet${e!=null&&e.name?` to ${e.name}.`:"."}`:`Link a wallet to your ${e==null?void 0:e.name} account`;return(0,_e.jsxs)(_e.Fragment,{children:[(0,_e.jsx)(P,{},"header"),(0,_e.jsx)(Ni,{title:`${t?"Reconnect":"Connect"} your wallet`,description:o}),(0,_e.jsxs)($e,{children:[(0,_e.jsx)(Ro,{}),(0,_e.jsx)(Mo,{})]}),(0,_e.jsx)(Q,{protectedByPrivy:!0})]})};var Wt=require("react"),Zt=E(require("styled-components"));var ie=require("react/jsx-runtime"),kn={google:{name:"Google",component:To},discord:{name:"Discord",component:So},github:{name:"Github",component:ko},twitter:{name:"Twitter",component:Wo}},Ia=t=>t.charAt(0).toUpperCase()+t.slice(1),Ir=()=>{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)},Tn=()=>{var x;let{ready:t,user:e,authenticated:o}=q(),{data:r,setModalData:i,navigate:n}=C(),{getAuthMeta:s,initLoginWithOAuth:a,loginWithOAuth:h,closePrivyModal:m}=S(),[L,_]=(0,Wt.useState)(!1),[g,y]=(0,Wt.useState)(void 0),f=((x=s())==null?void 0:x.provider)||"google",d=kn[f].name,R=kn[f].component;(0,Wt.useEffect)(()=>{!t||h().then(()=>{Ir(),_(!0)}).catch(N=>{let j={retryable:!1,message:"Authentication failed."};N.message.includes("Another user has already linked this")?j.detail="This account has already been linked to another user.":N.message==="Invalid code during oauth flow."?(j.retryable=!0,j.detail="Something went wrong. Try again."):N.message==="User denied confirmation during OAuth flow"&&(j.detail=`Retry and check ${Ia(f)} to finish connecting your account.`,j.retryable=!0),Ir(),y(j)})},[t]),(0,Wt.useEffect)(()=>{var ae;if(!(o&&L&&e))return;if(((ae=r==null?void 0:r.login)==null?void 0:ae.promptCreatePrivyWalletFlow)&&!e.wallet){let O=setTimeout(()=>{i({createWallet:{onSuccess:()=>m({shouldCallAuthOnSuccess:!0}),onFailure:T=>console.error(T)}}),n("EMBEDDED_WALLET_SCREEN")},he-500);return()=>clearTimeout(O)}else{let O=setTimeout(m,he);return()=>clearTimeout(O)}},[L]);let D=L?`Successfully connected with ${d}`:g?g.message:`Verifying connection to ${d}`,M="";return L?M="You\u2019re good to go!":g?M=g.detail:M="Just a few moments more",(0,ie.jsxs)(ie.Fragment,{children:[(0,ie.jsx)(P,{}),(0,ie.jsxs)(Ra,{children:[(0,ie.jsx)(Na,{children:(0,ie.jsxs)("div",{children:[(0,ie.jsx)(Ct,{success:L,fail:!!g}),(0,ie.jsx)(R,{style:{width:"38px",height:"38px"},logoFill:"primary"})]})}),(0,ie.jsxs)(Ma,{children:[(0,ie.jsx)("h3",{children:D}),(0,ie.jsx)("p",{children:M})]}),(0,ie.jsx)(Oa,{onClick:()=>{Ir(),a(f),y(void 0)},visible:!L&&(g==null?void 0:g.retryable),disabled:!L&&!(g!=null&&g.retryable),children:"Retry"})]})]})},Ra=Zt.default.div`
|
|
1277
1277
|
display: flex;
|
|
1278
1278
|
flex-direction: column;
|
|
1279
1279
|
align-items: center;
|
|
@@ -1355,7 +1355,7 @@ Resources:
|
|
|
1355
1355
|
left: -19px;
|
|
1356
1356
|
top: -19px;
|
|
1357
1357
|
}
|
|
1358
|
-
`;var qt=require("react"),Qe=E(require("styled-components"));var oe=require("react/jsx-runtime"),In=()=>{let{authenticated:t,getAccessToken:e,user:o}=q(),{walletProxy:r,closePrivyModal:i}=S(),{navigate:n,data:s}=C(),[a,h]=(0,qt.useState)(!1),[m,L]=(0,qt.useState)("");(0,qt.useEffect)(()=>{t||(n("LANDING"),y(new Error("User must be authenticated before signing with a Privy wallet")))},[t]);let{message:_,onSuccess:
|
|
1358
|
+
`;var qt=require("react"),Qe=E(require("styled-components"));var oe=require("react/jsx-runtime"),In=()=>{let{authenticated:t,getAccessToken:e,user:o}=q(),{walletProxy:r,closePrivyModal:i}=S(),{navigate:n,data:s}=C(),[a,h]=(0,qt.useState)(!1),[m,L]=(0,qt.useState)("");(0,qt.useEffect)(()=>{t||(n("LANDING"),y(new Error("User must be authenticated before signing with a Privy wallet")))},[t]);let{message:_,onSuccess:g,onFailure:y,uiOptions:f}=s.signMessage,d=Me(o),R=!r,D={title:f.title||"Sign message",description:f.description||"Signing this message will not cost you any fees.",buttonText:f.buttonText||"Sign and continue"};return(0,oe.jsxs)(oe.Fragment,{children:[(0,oe.jsx)(P,{onClose:()=>i({shouldCallAuthOnSuccess:!1})}),(0,oe.jsxs)(Ga,{children:[(0,oe.jsxs)("div",{children:[(0,oe.jsx)(ce,{title:D.title,description:D.description}),(0,oe.jsx)(Ba,{children:_}),(0,oe.jsx)(Va,{fail:!0,children:m})]}),(0,oe.jsx)(za,{success:a,loading:R,disabled:a,onClick:async()=>{let M=await e();if(M&&!R&&d)try{let{signature:x}=await r.sign({accessToken:M,address:d==null?void 0:d.address,message:_});L(""),g(x),h(!0),setTimeout(()=>{i({shouldCallAuthOnSuccess:!1})},he)}catch(x){L("An error has occurred, please try again."),y(x)}},children:a?(0,oe.jsxs)(Ha,{children:[(0,oe.jsx)(Et,{style:{height:"0.9rem",width:"0.9rem"},strokeWidth:2})," ",(0,oe.jsx)("span",{children:"Success"})]}):D.buttonText})]}),(0,oe.jsx)(Q,{protectedByPrivy:!0})]})},Ga=Qe.default.div`
|
|
1359
1359
|
display: flex;
|
|
1360
1360
|
height: 100%;
|
|
1361
1361
|
flex-direction: column;
|
|
@@ -1759,4 +1759,4 @@ Resources:
|
|
|
1759
1759
|
align-items: center;
|
|
1760
1760
|
justify-content: center;
|
|
1761
1761
|
height: 100%;
|
|
1762
|
-
`;var Bo=require("react");var Do=class{constructor(){this.callbacks={}}enqueue(e,o){this.callbacks[e]=o}dequeue(e,o){let r=this.callbacks[o];if(!r)throw new Error(`cannot dequeue ${e} event: no event found for id ${o}`);switch(delete this.callbacks[o],e){case"privy:iframe:ready":return r;case"privy:wallet:create":return r;case"privy:wallet:sign":return r;case"privy:wallet:recover":return r;default:throw new Error(`invalid wallet event type ${e}`)}}};var Bn=require("react/jsx-runtime"),Ja=function(t){return()=>`id-${t++}`}(0);function Ya(t){return typeof t.event=="string"&&/^privy:.+/.test(t.event)}function Fo(t){return t.error!==void 0}var Kt=new Do;function Go(t,e,o){let r=o.contentWindow;if(!r)throw new Error("iframe not initialized");return new Promise((i,n)=>{let s=Ja();Kt.enqueue(s,{resolve:i,reject:n}),r.postMessage({id:s,event:t,data:e},"*")})}function Xa(t){switch(t.event){case"privy:iframe:ready":let e=Kt.dequeue(t.event,t.id);return Fo(t)?e.reject(new Error(t.error.message)):e.resolve(t.data);case"privy:wallet:create":let o=Kt.dequeue(t.event,t.id);return Fo(t)?o.reject(new Error(t.error.message)):o.resolve(t.data);case"privy:wallet:sign":let r=Kt.dequeue(t.event,t.id);return Fo(t)?r.reject(new Error(t.error.message)):r.resolve(t.data);case"privy:wallet:recover":let i=Kt.dequeue(t.event,t.id);return Fo(t)?i.reject(new Error(t.error.message)):i.resolve(t.data)}}function Gn(t){let e=(0,Bo.useRef)(null);return(0,Bo.useEffect)(()=>{let o=e.current;if(!o)return;function r(a){a&&a.origin===t.origin&&Ya(a.data)&&Xa(a.data)}let i={create(a){return Go("privy:wallet:create",a,o)},sign(a){return Go("privy:wallet:sign",a,o)},recover(a){return Go("privy:wallet:recover",a,o)}};window.addEventListener("message",r);let n=()=>t.onLoad(i),s=(...a)=>{console.error("privy iframe failed to load: ",...a),t.onLoadFailed()};return hi(()=>Go("privy:iframe:ready",{},o)).then(n,s),()=>window.removeEventListener("message",r)},[e.current]),(0,Bn.jsx)("iframe",{ref:e,width:"0",height:"0",style:{visibility:"hidden"},src:mi(t.origin,`/apps/${t.appId}/embedded-wallets`)})}var et=require("react/jsx-runtime");function Qa(t){return typeof t=="string"&&t.length===25}var Jt;function Hn(){if(!Jt){let t=re.get(pt);return Promise.resolve(t||null)}return Jt.getAccessToken()}var zn=t=>{if(!Qa(t.appId))throw new w("Cannot initialize the Privy provider with an invalid Privy app ID");return Jt||(Jt=new gt({appId:t.appId,apiURL:Ho})),(0,et.jsx)(tl,{...t,client:Jt})},el=t=>{let e=!!(t!=null&&t.emailAuth),o=!!(t!=null&&t.smsAuth);return e&&o&&(console.warn("Enabling both email and SMS passwordless is not currently supported. Disabling SMS."),o=!1),{email:e,sms:o,wallet:!!(t!=null&&t.walletAuth),google:!!(t!=null&&t.googleOAuth),twitter:!!(t!=null&&t.twitterOAuth),discord:!!(t!=null&&t.discordOAuth),github:!!(t!=null&&t.githubOAuth)}},tl=t=>{let e=t.client,[o,r]=(0,Y.useState)(!1),[i,n]=(0,Y.useState)(!1),[s,a]=(0,Y.useState)(!1),[h,m]=(0,Y.useState)(null),[L,_]=(0,Y.useState)(!1),[
|
|
1762
|
+
`;var Bo=require("react");var Do=class{constructor(){this.callbacks={}}enqueue(e,o){this.callbacks[e]=o}dequeue(e,o){let r=this.callbacks[o];if(!r)throw new Error(`cannot dequeue ${e} event: no event found for id ${o}`);switch(delete this.callbacks[o],e){case"privy:iframe:ready":return r;case"privy:wallet:create":return r;case"privy:wallet:sign":return r;case"privy:wallet:recover":return r;default:throw new Error(`invalid wallet event type ${e}`)}}};var Bn=require("react/jsx-runtime"),Ja=function(t){return()=>`id-${t++}`}(0);function Ya(t){return typeof t.event=="string"&&/^privy:.+/.test(t.event)}function Fo(t){return t.error!==void 0}var Kt=new Do;function Go(t,e,o){let r=o.contentWindow;if(!r)throw new Error("iframe not initialized");return new Promise((i,n)=>{let s=Ja();Kt.enqueue(s,{resolve:i,reject:n}),r.postMessage({id:s,event:t,data:e},"*")})}function Xa(t){switch(t.event){case"privy:iframe:ready":let e=Kt.dequeue(t.event,t.id);return Fo(t)?e.reject(new Error(t.error.message)):e.resolve(t.data);case"privy:wallet:create":let o=Kt.dequeue(t.event,t.id);return Fo(t)?o.reject(new Error(t.error.message)):o.resolve(t.data);case"privy:wallet:sign":let r=Kt.dequeue(t.event,t.id);return Fo(t)?r.reject(new Error(t.error.message)):r.resolve(t.data);case"privy:wallet:recover":let i=Kt.dequeue(t.event,t.id);return Fo(t)?i.reject(new Error(t.error.message)):i.resolve(t.data)}}function Gn(t){let e=(0,Bo.useRef)(null);return(0,Bo.useEffect)(()=>{let o=e.current;if(!o)return;function r(a){a&&a.origin===t.origin&&Ya(a.data)&&Xa(a.data)}let i={create(a){return Go("privy:wallet:create",a,o)},sign(a){return Go("privy:wallet:sign",a,o)},recover(a){return Go("privy:wallet:recover",a,o)}};window.addEventListener("message",r);let n=()=>t.onLoad(i),s=(...a)=>{console.error("privy iframe failed to load: ",...a),t.onLoadFailed()};return hi(()=>Go("privy:iframe:ready",{},o)).then(n,s),()=>window.removeEventListener("message",r)},[e.current]),(0,Bn.jsx)("iframe",{ref:e,width:"0",height:"0",style:{visibility:"hidden"},src:mi(t.origin,`/apps/${t.appId}/embedded-wallets`)})}var et=require("react/jsx-runtime");function Qa(t){return typeof t=="string"&&t.length===25}var Jt;function Hn(){if(!Jt){let t=re.get(pt);return Promise.resolve(t||null)}return Jt.getAccessToken()}var zn=t=>{if(!Qa(t.appId))throw new w("Cannot initialize the Privy provider with an invalid Privy app ID");return Jt||(Jt=new gt({appId:t.appId,apiURL:Ho})),(0,et.jsx)(tl,{...t,client:Jt})},el=t=>{let e=!!(t!=null&&t.emailAuth),o=!!(t!=null&&t.smsAuth);return e&&o&&(console.warn("Enabling both email and SMS passwordless is not currently supported. Disabling SMS."),o=!1),{email:e,sms:o,wallet:!!(t!=null&&t.walletAuth),google:!!(t!=null&&t.googleOAuth),twitter:!!(t!=null&&t.twitterOAuth),discord:!!(t!=null&&t.discordOAuth),github:!!(t!=null&&t.githubOAuth)}},tl=t=>{let e=t.client,[o,r]=(0,Y.useState)(!1),[i,n]=(0,Y.useState)(!1),[s,a]=(0,Y.useState)(!1),[h,m]=(0,Y.useState)(null),[L,_]=(0,Y.useState)(!1),[g,y]=(0,Y.useState)(null),[f,d]=(0,Y.useState)(!1),[R,D]=(0,Y.useState)(null),[M,x]=(0,Y.useState)(null),[N,j]=(0,Y.useState)(null),[ae,O]=(0,Y.useState)({accentColor:"#696ffd",theme:"System",showWalletLoginFirst:!0,allowlistConfig:{errorTitle:null,errorDetail:null,errorCtaText:null,errorCtaLink:null},walletAuth:!0,emailAuth:!0,smsAuth:!1,googleOAuth:!1,twitterOAuth:!1,discordOAuth:!1,githubOAuth:!1,termsAndConditionsUrl:null,privacyPolicyUrl:null}),[T,we]=(0,Y.useState)(!1),[Ge,z]=(0,Y.useState)({}),$=el(ae),U=l=>{l&&y(l),r(!0)},Pe=l=>{let u=t.createPrivyWalletOnLogin===!0;z({login:{promptCreatePrivyWalletFlow:u}}),u&&we(!0),U(l)};(0,Y.useEffect)(()=>{async function l(){let u=await e.getAppSettings();O(u),e.connectors.initialize(),tt();let F=await e.getAuthenticatedUser();a(!!F),m(F),n(!0)}l()},[e]);let tt=()=>{let l=new URLSearchParams(window.location.search),u=l.get("privy_oauth_code"),F=l.get("privy_oauth_state"),Be=l.get("privy_oauth_provider");u&&F&&Be&&(e.startAuthFlow(new dt(Be,u,F)),Pe("AWAITING_OAUTH_SCREEN"))};(0,Y.useEffect)(()=>{i&&s&&h===null&&e.getAuthenticatedUser().then(m)},[i,s,h,e]);let Rt=()=>{d(!0),U("LINK_WALLET_SCREEN")},Yt={ready:i,authenticated:s,user:h,walletConnectors:e.connectors,linkWallet:Rt,linkEmail:()=>{d(!0),U("LINK_EMAIL_SCREEN")},linkPhone:()=>{d(!0),U("LINK_PHONE_SCREEN")},linkGoogle:async()=>{await X.initLoginWithOAuth("google")},linkTwitter:async()=>{await X.initLoginWithOAuth("twitter")},linkDiscord:async()=>{await X.initLoginWithOAuth("discord")},linkGithub:async()=>{await X.initLoginWithOAuth("github")},login:()=>{if(i&&s){console.warn("Attempted to log in, but user is already logged in. Use a `link` helper instead.");return}Pe()},logout:async()=>{await e.logout(),m(null),a(!1),y(null),d(!1),r(!1)},getAccessToken:()=>e.getAccessToken(),getEthereumProvider:()=>e.connectors.getEthereumProvider(),getEthersProvider:()=>new Vn.Web3Provider(new Se(e.connectors.getEthereumProvider())),getWeb3jsProvider:()=>new oo(e.connectors.getEthereumProvider()),unlinkWallet:async l=>{let u=await e.unlinkWallet(l);return m(u),u},unlinkEmail:async l=>{let u=await e.unlinkEmail(l);return m(u),u},unlinkPhone:async l=>{let u=await e.unlinkPhone(l);return m(u),u},unlinkGoogle:async l=>{let u=await e.unlinkOAuth("google",l);return m(u),u},unlinkTwitter:async l=>{let u=await e.unlinkOAuth("twitter",l);return m(u),u},unlinkDiscord:async l=>{let u=await e.unlinkOAuth("discord",l);return m(u),u},unlinkGithub:async l=>{let u=await e.unlinkOAuth("github",l);return m(u),u},setActiveWallet:async l=>{if(!h)return;let u=e.connectors.getConnectorByAddress(l);if(!u){x(l),Rt();return}D({address:l,walletType:u.walletType,success:!1}),U("SETTING_ACTIVE_WALLET"),e.setActiveWallet(l,h).then(F=>{m(F),D({address:l,walletType:u.walletType,success:!0})}).catch(F=>{F instanceof w&&F.message==="Error setting the active wallet."&&(x(l),Rt()),D({address:l,walletType:u.walletType,success:!1,error:F.message})})},forkSession:()=>e.forkSession(),createWallet:()=>new Promise((l,u)=>{if(!s||!h){u(new Error("User must be authenticated before creating a Privy wallet"));return}if(Me(h)){u(new Error("Only one Privy wallet per user is currently allowed"));return}we(!0),z({createWallet:{onSuccess:l,onFailure:u}}),U("EMBEDDED_WALLET_SCREEN")}),signMessage:(l,u)=>new Promise((F,Be)=>{if(!s||!h){Be(new Error("User must be authenticated before signing with a Privy wallet"));return}if(!Me(h)){Be(new Error("Must have a Privy wallet before signing"));return}if(typeof l!="string"||l.length<1){Be(new Error("Message must be a non-empty string"));return}we(!0),z({signMessage:{message:l,onSuccess:F,onFailure:Be,uiOptions:u||{}}}),U("SIGN_REQUEST_SCREEN")})},X=(()=>({isLinking:f,linkingHint:M,activeStatus:R,getAuthFlow:()=>e.authFlow,getAuthMeta:()=>{var l;return(l=e.authFlow)==null?void 0:l.meta},closePrivyModal:(l={shouldCallAuthOnSuccess:!0})=>{var F;let u=i&&s&&h;l.shouldCallAuthOnSuccess&&u&&((F=t.onSuccess)==null||F.call(t,h,L)),e.authFlow=void 0,x(null),y(null),d(!1),D(null),_(!1),r(!1)},initLoginWithWallet:l=>{if(!e.connectors)throw new w("Connector not initialized");l||(l="metamask"),e.startAuthFlow(new Nt(e.connectors,l))},loginWithWallet:async()=>{if(!(e.authFlow instanceof Nt))throw new w("Must initialize SIWE flow first.");let l,u;f?(l=await e.link(),l&&(l=Dt(l))):{user:l,isNewUser:u}=await e.authenticate(),m(l||h||null),_(u||!1),a(!0)},initLoginWithOAuth:async l=>{e.startAuthFlow(new dt(l));let u=await e.authFlow.getAuthorizationUrl();u&&u.url&&window.location.assign(u.url)},loginWithOAuth:async()=>{if(!(e.authFlow instanceof dt))throw new w("Must initialize OAuth flow before calling loginWithOAuth");let l,u;i&&s?l=await e.link():{user:l,isNewUser:u}=await e.authenticate(),m(l),_(u||!1),a(!0)},initLoginWithEmail:async l=>{let u=new Mt(l);e.startAuthFlow(u),await u.sendCodeEmail()},initLoginWithSms:async l=>{let u=new Ot(l);e.startAuthFlow(u),await u.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 Mt)e.authFlow.meta.emailCode=l.trim();else if(e.authFlow instanceof Ot)e.authFlow.meta.smsCode=l.trim();else throw new w("Must initialize a passwordless code flow first");let u,F;f?u=await e.link():{user:u,isNewUser:F}=await e.authenticate(),m(u||h||null),_(F||!1),a(!0)},refreshUser:async()=>{let l=await e.getAuthenticatedUser();return m(l),l},walletProxy:N}))();return(0,et.jsxs)(rr.Provider,{value:Yt,children:[t.children,(0,et.jsxs)(or.Provider,{value:X,children:[(0,et.jsx)(Li,{appSettings:ae,options:$,data:Ge,setModalData:z,initialScreen:g,visible:o,authenticated:s,children:o&&(0,et.jsx)(Fn,{})}),T&&(0,et.jsx)(Gn,{appId:t.appId,origin:Ho,onLoad:j,onLoadFailed:()=>null})]})]})};0&&(module.exports={AsExternalProvider,ConnectorManager,PrivyClient,PrivyProvider,PrivyProxyProvider,VERSION,WalletConnector,getAccessToken,usePrivy});
|