@privy-io/react-auth
Version:
React client for the Privy Auth API
2 lines (1 loc) • 5.62 kB
JavaScript
;var e=require("react/jsx-runtime"),r=require("lucide-react"),t=require("styled-components"),i=require("./context-DFq1obBO.js"),a=require("./index-NJrQkxJ7.js"),n=require("./internal-context-NWsAL807.js"),o=require("./get-is-unified-wallet-D4ouXJpi.js"),l=require("./reservoir-CQGyEBb7.js"),s=require("./ScreenLayout-BeH-Q6N2.js");require("react"),require("@privy-io/js-sdk-core"),require("tinycolor2"),require("uuid"),require("jose"),require("eventemitter3"),require("./useActiveWallet-BOX8xCn9.js"),require("zustand"),require("react-device-detect"),require("./prepareFundingModalData-Cnd6rhhJ.js"),require("./events-context-Di6--rDg.js"),require("viem"),require("viem/utils"),require("./getPublicClient-CGlodIp_.js"),require("./useWallets-BLFNjTwC.js"),require("@coinbase/wallet-sdk"),require("@privy-io/ethereum"),require("mipd"),require("@privy-io/popup"),require("./paths-DizMb-lU.js"),require("./usePrivy-CcfSRv1R.js"),require("@scure/base"),require("@headlessui/react"),require("@walletconnect/ethereum-provider"),require("@privy-io/urls"),require("ofetch"),require("js-cookie"),require("./frame-B14fp9oC.js"),require("@privy-io/routes"),require("x402/client"),require("@privy-io/api-base"),require("viem/accounts"),require("./use-sign-with-user-signer-BcAsQTGF.js"),require("./getEmbeddedConnectedWallet-6TsVZJkD.js"),require("./Button-Bm_Ft0Dw.js"),require("./Screen-D9Tvi297.js"),require("./ModalHeader-DB7Tbjwz.js"),require("@heroicons/react/24/outline/ArrowLeftIcon"),require("@heroicons/react/24/outline/ArrowRightIcon"),require("@heroicons/react/24/outline/QuestionMarkCircleIcon"),require("@heroicons/react/24/outline/XMarkIcon"),require("./index-CRFXS9pP.js");const c=({error:t,allowlistConfig:i,onRetry:o,onCaptchaReset:c,onBack:u})=>{let T=((t,i)=>{if(t instanceof l.RelayRequestError)return{title:"Transaction failed",detail:/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx("span",{children:t.message}),/*#__PURE__*/e.jsxs("span",{children:[" ","Check the"," ",/*#__PURE__*/e.jsx(d,{href:t.relayLink,target:"_blank",children:"refund status"}),"."]})]}),ctaText:"Try again",icon:r.AlertTriangle};if(t instanceof n.PrivyClientError)switch(t.privyErrorCode){case n.PrivyErrorCode.CLIENT_REQUEST_TIMEOUT:return{title:"Timed out",detail:t.message,ctaText:"Try again",icon:r.AlertTriangle};case n.PrivyErrorCode.INSUFFICIENT_BALANCE:return{title:"Insufficient balance",detail:t.message,ctaText:"Try again",icon:r.AlertTriangle};case n.PrivyErrorCode.TRANSACTION_FAILURE:return{title:"Transaction failure",detail:t.message,ctaText:"Try again",icon:r.AlertTriangle};default:return{title:"Something went wrong",detail:"Try again later",ctaText:"Try again",icon:r.AlertTriangle}}else{if(t instanceof a.PrivyIframeError&&"twilio_verification_failed"===t.type)return{title:"Something went wrong",detail:t.message,ctaText:"Try again",icon:r.Phone};if(!(t instanceof n.PrivyError))return t instanceof n.PrivyApiError&&t.status&&[400,422].includes(t.status)?{title:"Something went wrong",detail:t.message,ctaText:"Try again",icon:r.AlertTriangle}:{title:"Something went wrong",detail:"Try again later",ctaText:"Try again",icon:r.AlertTriangle};switch(t.privyErrorCode){case n.PrivyErrorCode.INVALID_CAPTCHA:return{title:"Something went wrong",detail:"Please try again.",ctaText:"Try again",icon:r.AlertTriangle};case n.PrivyErrorCode.DISALLOWED_LOGIN_METHOD:return{title:"Not allowed",detail:t.message,ctaText:"Try another method",icon:r.AlertTriangle};case n.PrivyErrorCode.ALLOWLIST_REJECTED:return{title:i.errorTitle||"You don't have access to this app",detail:i.errorDetail||"Have you been invited?",ctaText:i.errorCtaText||"Try another account",icon:r.Lock};case n.PrivyErrorCode.CAPTCHA_FAILURE:return{title:"Something went wrong",detail:"You did not pass CAPTCHA. Please try again.",ctaText:"Try again",icon:null};case n.PrivyErrorCode.CAPTCHA_TIMEOUT:return{title:"Something went wrong",detail:"Something went wrong! Please try again later.",ctaText:"Try again",icon:null};case n.PrivyErrorCode.LINKED_TO_ANOTHER_USER:return{title:"Authentication failed",detail:"This account has already been linked to another user.",ctaText:"Try again",icon:r.AlertTriangle};case n.PrivyErrorCode.NOT_SUPPORTED:return{title:"This region is not supported",detail:"SMS authentication from this region is not available",ctaText:"Try another method",icon:r.AlertTriangle};case n.PrivyErrorCode.TOO_MANY_REQUESTS:return{title:"Request failed",detail:"Too many attempts.",ctaText:"Try again later",icon:r.AlertTriangle};default:return{title:"Something went wrong",detail:"Try again later",ctaText:"Try again",icon:r.AlertTriangle}}}})(t,i);/*#__PURE__*/return e.jsx(s.ScreenLayout,{title:T.title,subtitle:T.detail,icon:T.icon,onBack:u,iconVariant:"error",primaryCta:{label:T.ctaText,onClick:()=>{t instanceof n.PrivyError&&(t.privyErrorCode===n.PrivyErrorCode.INVALID_CAPTCHA&&c?.(),t.privyErrorCode===n.PrivyErrorCode.ALLOWLIST_REJECTED&&i.errorCtaLink)?window.location.href=i.errorCtaLink:o?.()},variant:"error"},watermark:!0})},u={component:()=>{let{navigate:r,data:t,lastScreen:n,currentScreen:l}=o.usePrivyModal(),s=i.useAppConfig(),{reset:u}=a.useCaptcha(),d=t?.errorModalData?.previousScreen||(n===l?void 0:n);/*#__PURE__*/return e.jsx(c,{error:t?.errorModalData?.error||Error(),allowlistConfig:s.allowlistConfig,onRetry:()=>{r(d||"LandingScreen",!1)},onCaptchaReset:u})}};let d=/*#__PURE__*/t.styled.a.withConfig({displayName:"Link",componentId:"sc-506514cb-0"})(["color:var(--privy-color-accent) !important;font-weight:600;"]);exports.ErrorScreen=u,exports.ErrorScreenView=c,exports.default=u;