@privy-io/react-auth
Version:
React client for the Privy Auth API
2 lines (1 loc) • 4.8 kB
JavaScript
import{jsxs as e,jsx as o,Fragment as r}from"react/jsx-runtime";import t from"@heroicons/react/24/outline/LockClosedIcon";import i from"@heroicons/react/24/outline/PencilSquareIcon";import s from"@heroicons/react/24/outline/QuestionMarkCircleIcon";import{useState as c}from"react";import{styled as n}from"styled-components";import{a,u as l,g as p}from"./get-is-unified-wallet-DvKS5IUO.mjs";import{P as d}from"./Button-B8mqatRx.mjs";import{M as m,B as u}from"./ModalHeader-BLGC-7ev.mjs";import{C as h}from"./ScreenHeader-Biz1wq02.mjs";import{u as v}from"./context-Bycd1SKV.mjs";import{u as y}from"./internal-context-e-Eni5bG.mjs";import{v as g}from"./index-CCyaupaz.mjs";import{R as f,A as w,G as C,a as j}from"./styles-BxA7nKxI.mjs";import{U as k}from"./useActiveWallet-Bsy5GTCV.mjs";import"viem";import"@heroicons/react/24/outline/ArrowLeftIcon";import"@heroicons/react/24/outline/ArrowRightIcon";import"@heroicons/react/24/outline/XMarkIcon";import"@privy-io/js-sdk-core";import"tinycolor2";import"ofetch";import"uuid";import"jose";import"eventemitter3";import"./useWallets-D0lpBS44.mjs";import"./prepareFundingModalData-CIgFwA7s.mjs";import"@coinbase/wallet-sdk";import"@privy-io/ethereum";import"mipd";import"react-device-detect";import"viem/utils";import"@privy-io/popup";import"./paths-3HW55qZg.mjs";import"./usePrivy-BaiIHGte.mjs";import"./events-context-CI0iqAXA.mjs";import"@scure/base";import"zustand";import"@headlessui/react";import"@walletconnect/ethereum-provider";import"@privy-io/urls";import"./getPublicClient-A9RSftUZ.mjs";import"js-cookie";import"./frame-CwE9r3cT.mjs";import"@privy-io/routes";import"x402/client";import"@privy-io/api-base";import"viem/accounts";import"./use-sign-with-user-signer-eEm9Olt_.mjs";import"./getEmbeddedConnectedWallet-CM6cDQCS.mjs";let S=/*#__PURE__*/n.div.withConfig({displayName:"IconContainer",componentId:"sc-1c4e63fb-0"})(["width:24px;height:24px;display:flex;justify-content:center;align-items:center;"]),b={"google-drive":"Google Drive",icloud:"iCloud","user-passcode":"password",privy:"Privy","privy-v2":"Privy"},A=({onClose:t})=>/*#__PURE__*/e(j,{children:[/*#__PURE__*/o(h,{title:"Why do I need to secure my account?",icon:/*#__PURE__*/o(s,{width:48}),description:/*#__PURE__*/e(r,{children:[/*#__PURE__*/o("p",{children:"Your app uses cryptography to secure your account. App secrets are split and encrypted so only you can access them."}),/*#__PURE__*/o("p",{children:"To use this app on new devices, secure account secrets using a password, your Google or your Apple account. It’s important you don’t lose access to the method you choose."})]})}),/*#__PURE__*/o(d,{onClick:t,children:"Select backup method"})]});const I={component:()=>{let[s,n]=c(!1),{navigate:d,lastScreen:j,navigateBack:I,setModalData:x,data:M,onUserCloseViaDialogOrKeybindRef:P}=a(),{user:O}=l(),{embeddedWallets:W}=v(),{closePrivyModal:R}=y(),F=p(O),B=null===F,{isInAccountCreateFlow:D,isResettingPassword:E,shouldCreateEth:G,shouldCreateSol:U}=M.recoverySelection,H=F&&"privy"!==F.recoveryMethod,L=H?/*#__PURE__*/e("span",{children:["Your account is currently secured using"," ",/*#__PURE__*/o("strong",{children:b[F?.recoveryMethod||"user-passcode"]}),"."]}):"Select a method for logging in on new devices and recovering your account.";function Y(e){x({recoveryOAuthStatus:{provider:e,action:B?"create-wallet":"set-recovery",isInAccountCreateFlow:D,shouldCreateEth:G,shouldCreateSol:U}}),d("RecoveryOAuthScreen")}function q(){M?.setWalletPassword?.onFailure(Error("User exited set recovery flow")),R({shouldCallAuthOnSuccess:M?.setWalletPassword?.callAuthOnSuccessOnClose??!1})}return P.current=q,/*#__PURE__*/e(r,{children:[/*#__PURE__*/o(m,{onClose:q,backFn:s?()=>n(!1):j?I:void 0,infoFn:j||s?void 0:()=>n(!0)},"header"),s?/*#__PURE__*/o(A,{onClose:()=>n(!1)}):/*#__PURE__*/e(r,{children:[/*#__PURE__*/o(h,{title:H?"Update backup method":"Secure your account",icon:/*#__PURE__*/o(t,{width:48}),description:L}),/*#__PURE__*/o(f,{children:W.userOwnedRecoveryOptions.filter((e=>!["icloud","google-drive"].includes(F?.recoveryMethod||"")||e!==F?.recoveryMethod)).sort().map((r=>{switch(r){case"google-drive":/*#__PURE__*/return e(k,{onClick:()=>Y("google-drive"),children:[/*#__PURE__*/o(S,{children:/*#__PURE__*/o(C,{style:{width:18}})}),"Back up to Google Drive"]},r);case"icloud":/*#__PURE__*/return e(k,{onClick:()=>Y("icloud"),children:[/*#__PURE__*/o(S,{children:/*#__PURE__*/o(w,{style:{width:24}})}),"Back up to Apple iCloud"]},r);case"user-passcode":/*#__PURE__*/return e(k,{onClick:()=>{d(g({isCreatingWallet:B,skipSplashScreen:!0}))},children:[/*#__PURE__*/o(S,{children:/*#__PURE__*/o(i,{style:{width:18}})}),E?"Reset your":"Set a"," password"]},r);default:return null}}))})]}),/*#__PURE__*/o(u,{})]})}};export{I as RecoverySelectionScreen,I as default};