UNPKG

@privy-io/react-auth

Version:

React client for the Privy Auth API

2 lines (1 loc) 5.38 kB
"use strict";var e=require("react/jsx-runtime"),r=require("@heroicons/react/24/outline/LockClosedIcon"),o=require("@heroicons/react/24/outline/PencilSquareIcon"),t=require("@heroicons/react/24/outline/QuestionMarkCircleIcon"),i=require("react"),s=require("styled-components"),n=require("./get-is-unified-wallet-D4ouXJpi.js"),c=require("./Button-Bm_Ft0Dw.js"),u=require("./ModalHeader-DB7Tbjwz.js"),l=require("./ScreenHeader-CyURV6Ti.js"),a=require("./context-DFq1obBO.js"),d=require("./internal-context-NWsAL807.js"),h=require("./index-NJrQkxJ7.js"),p=require("./styles-Ca_DS00a.js"),y=require("./useActiveWallet-BOX8xCn9.js");function v(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("viem"),require("@heroicons/react/24/outline/ArrowLeftIcon"),require("@heroicons/react/24/outline/ArrowRightIcon"),require("@heroicons/react/24/outline/XMarkIcon"),require("@privy-io/js-sdk-core"),require("tinycolor2"),require("ofetch"),require("uuid"),require("jose"),require("eventemitter3"),require("./useWallets-BLFNjTwC.js"),require("./prepareFundingModalData-Cnd6rhhJ.js"),require("@coinbase/wallet-sdk"),require("@privy-io/ethereum"),require("mipd"),require("react-device-detect"),require("viem/utils"),require("@privy-io/popup"),require("./paths-DizMb-lU.js"),require("./usePrivy-CcfSRv1R.js"),require("./events-context-Di6--rDg.js"),require("@scure/base"),require("zustand"),require("@headlessui/react"),require("@walletconnect/ethereum-provider"),require("@privy-io/urls"),require("./getPublicClient-CGlodIp_.js"),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");var q=/*#__PURE__*/v(r),j=/*#__PURE__*/v(o),g=/*#__PURE__*/v(t);let x=/*#__PURE__*/s.styled.div.withConfig({displayName:"IconContainer",componentId:"sc-1c4e63fb-0"})(["width:24px;height:24px;display:flex;justify-content:center;align-items:center;"]),C={"google-drive":"Google Drive",icloud:"iCloud","user-passcode":"password",privy:"Privy","privy-v2":"Privy"},m=({onClose:r})=>/*#__PURE__*/e.jsxs(p.RecoveryExplainerContainer,{children:[/*#__PURE__*/e.jsx(l.CenteredScreenHeader,{title:"Why do I need to secure my account?",icon:/*#__PURE__*/e.jsx(g.default,{width:48}),description:/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx("p",{children:"Your app uses cryptography to secure your account. App secrets are split and encrypted so only you can access them."}),/*#__PURE__*/e.jsx("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__*/e.jsx(c.PrimaryButton,{onClick:r,children:"Select backup method"})]});const w={component:()=>{let[r,o]=i.useState(!1),{navigate:t,lastScreen:s,navigateBack:c,setModalData:v,data:g,onUserCloseViaDialogOrKeybindRef:w}=n.usePrivyModal(),{user:f}=n.usePrivyContext(),{embeddedWallets:S}=a.useAppConfig(),{closePrivyModal:b}=d.usePrivyInternal(),k=n.getPrivyPrimaryWallet(f),P=null===k,{isInAccountCreateFlow:M,isResettingPassword:A,shouldCreateEth:I,shouldCreateSol:F}=g.recoverySelection,W=k&&"privy"!==k.recoveryMethod,B=W?/*#__PURE__*/e.jsxs("span",{children:["Your account is currently secured using"," ",/*#__PURE__*/e.jsx("strong",{children:C[k?.recoveryMethod||"user-passcode"]}),"."]}):"Select a method for logging in on new devices and recovering your account.";function R(e){v({recoveryOAuthStatus:{provider:e,action:P?"create-wallet":"set-recovery",isInAccountCreateFlow:M,shouldCreateEth:I,shouldCreateSol:F}}),t("RecoveryOAuthScreen")}function O(){g?.setWalletPassword?.onFailure(Error("User exited set recovery flow")),b({shouldCallAuthOnSuccess:g?.setWalletPassword?.callAuthOnSuccessOnClose??!1})}return w.current=O,/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(u.ModalHeader,{onClose:O,backFn:r?()=>o(!1):s?c:void 0,infoFn:s||r?void 0:()=>o(!0)},"header"),r?/*#__PURE__*/e.jsx(m,{onClose:()=>o(!1)}):/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(l.CenteredScreenHeader,{title:W?"Update backup method":"Secure your account",icon:/*#__PURE__*/e.jsx(q.default,{width:48}),description:B}),/*#__PURE__*/e.jsx(p.RecoveryContainer,{children:S.userOwnedRecoveryOptions.filter((e=>!["icloud","google-drive"].includes(k?.recoveryMethod||"")||e!==k?.recoveryMethod)).sort().map((r=>{switch(r){case"google-drive":/*#__PURE__*/return e.jsxs(y.LoginMethodButton,{onClick:()=>R("google-drive"),children:[/*#__PURE__*/e.jsx(x,{children:/*#__PURE__*/e.jsx(p.GoogleDrive,{style:{width:18}})}),"Back up to Google Drive"]},r);case"icloud":/*#__PURE__*/return e.jsxs(y.LoginMethodButton,{onClick:()=>R("icloud"),children:[/*#__PURE__*/e.jsx(x,{children:/*#__PURE__*/e.jsx(p.AppleICloud,{style:{width:24}})}),"Back up to Apple iCloud"]},r);case"user-passcode":/*#__PURE__*/return e.jsxs(y.LoginMethodButton,{onClick:()=>{t(h.embeddedWalletSetPasswordScreen({isCreatingWallet:P,skipSplashScreen:!0}))},children:[/*#__PURE__*/e.jsx(x,{children:/*#__PURE__*/e.jsx(j.default,{style:{width:18}})}),A?"Reset your":"Set a"," password"]},r);default:return null}}))})]}),/*#__PURE__*/e.jsx(u.BlobbyFooter,{})]})}};exports.RecoverySelectionScreen=w,exports.default=w;