@privy-io/react-auth
Version:
React client for the Privy Auth API
8 lines (7 loc) • 5.36 kB
JavaScript
"use strict";var e=require("react/jsx-runtime"),r=require("@heroicons/react/24/outline/LockClosedIcon"),o=require("@heroicons/react/24/outline/PencilSquareIcon"),i=require("@heroicons/react/24/outline/QuestionMarkCircleIcon"),t=require("react"),s=require("styled-components"),n=require("./get-is-unified-wallet-UpdjHxOV.js"),u=require("./ModalHeader-BCPQgekO.js"),c=require("./ScreenHeader-CgYJ5Fmg.js"),l=require("./context-D-ZJYjUg.js"),a=require("./internal-context-BJv4f_bO.js"),d=require("./index-C8lpxYDX.js"),h=require("./styles-CQnB5gHS.js"),p=require("./useActiveWallet-Cn6zOXx5.js");function y(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("@privy-io/are-addresses-equal"),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-CKAypPZB.js"),require("./use-export-wallet-B5ujV5Nk.js"),require("viem/utils"),require("@coinbase/wallet-sdk"),require("@privy-io/ethereum"),require("mipd"),require("react-device-detect"),require("@privy-io/popup"),require("./paths-DizMb-lU.js"),require("./usePrivy-cfS6o4tX.js"),require("./events-context-Di6--rDg.js"),require("@scure/base"),require("zustand"),require("@headlessui/react"),require("@walletconnect/ethereum-provider"),require("@privy-io/urls"),require("viem"),require("./PrivyPluginContext-DsgaS6n9.js"),require("./getEmbeddedConnectedWallet-pJd-l936.js"),require("./getPublicClient-BsmZyCGX.js"),require("js-cookie"),require("./frame-Oz7volks.js"),require("@privy-io/routes"),require("x402/client"),require("@privy-io/api-base"),require("viem/accounts"),require("./use-sign-with-user-signer-Cu_6Bx7m.js");var v=/*#__PURE__*/y(r),q=/*#__PURE__*/y(o),j=/*#__PURE__*/y(i);let g=s.styled.div`
width: 24px;
height: 24px;
display: flex;
justify-content: center;
align-items: center;
`,x={"google-drive":"Google Drive",icloud:"iCloud","user-passcode":"password",privy:"Privy","privy-v2":"Privy"},C=({onClose:r})=>/*#__PURE__*/e.jsxs(h.RecoveryExplainerContainer,{children:[/*#__PURE__*/e.jsx(c.CenteredScreenHeader,{title:"Why do I need to secure my account?",icon:/*#__PURE__*/e.jsx(j.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(u.PrimaryButton,{onClick:r,children:"Select backup method"})]});const m={component:()=>{let[r,o]=t.useState(!1),{navigate:i,lastScreen:s,navigateBack:y,setModalData:j,data:m,onUserCloseViaDialogOrKeybindRef:w}=n.usePrivyModal(),{user:f}=n.usePrivyContext(),{embeddedWallets:S}=l.useAppConfig(),{closePrivyModal:P}=a.usePrivyInternal(),k=n.getPrivyPrimaryWallet(f),b=null===k,{isInAccountCreateFlow:A,isResettingPassword:M,shouldCreateEth:I,shouldCreateSol:W}=m.recoverySelection,F=k&&"privy"!==k.recoveryMethod,R=F?/*#__PURE__*/e.jsxs("span",{children:["Your account is currently secured using"," ",/*#__PURE__*/e.jsx("strong",{children:x[k?.recoveryMethod||"user-passcode"]}),"."]}):"Select a method for logging in on new devices and recovering your account.";function B(e){j({recoveryOAuthStatus:{provider:e,action:b?"create-wallet":"set-recovery",isInAccountCreateFlow:A,shouldCreateEth:I,shouldCreateSol:W}}),i("RecoveryOAuthScreen")}function O(){m?.setWalletPassword?.onFailure(Error("User exited set recovery flow")),P({shouldCallAuthOnSuccess:m?.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?y:void 0,infoFn:s||r?void 0:()=>o(!0)},"header"),r?/*#__PURE__*/e.jsx(C,{onClose:()=>o(!1)}):/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(c.CenteredScreenHeader,{title:F?"Update backup method":"Secure your account",icon:/*#__PURE__*/e.jsx(v.default,{width:48}),description:R}),/*#__PURE__*/e.jsx(h.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(p.LoginMethodButton,{onClick:()=>B("google-drive"),children:[/*#__PURE__*/e.jsx(g,{children:/*#__PURE__*/e.jsx(h.GoogleDrive,{style:{width:18}})}),"Back up to Google Drive"]},r);case"icloud":/*#__PURE__*/return e.jsxs(p.LoginMethodButton,{onClick:()=>B("icloud"),children:[/*#__PURE__*/e.jsx(g,{children:/*#__PURE__*/e.jsx(h.AppleICloud,{style:{width:24}})}),"Back up to Apple iCloud"]},r);case"user-passcode":/*#__PURE__*/return e.jsxs(p.LoginMethodButton,{onClick:()=>{i(d.embeddedWalletSetPasswordScreen({isCreatingWallet:b,skipSplashScreen:!0}))},children:[/*#__PURE__*/e.jsx(g,{children:/*#__PURE__*/e.jsx(q.default,{style:{width:18}})}),M?"Reset your":"Set a"," password"]},r);default:return null}}))})]}),/*#__PURE__*/e.jsx(u.BlobbyFooter,{})]})}};exports.RecoverySelectionScreen=m,exports.default=m;