UNPKG

@privy-io/react-auth

Version:

React client for the Privy Auth API

2 lines (1 loc) 2.17 kB
import{jsx as e}from"react/jsx-runtime";import{AlertCircle as o,CheckCircle as t,Ban as r}from"lucide-react";import{useState as i,useEffect as n}from"react";import{u as s,r as a}from"./context-DLtU3JQy.mjs";import{u as c,a as m}from"./internal-context-Z-fyxadS.mjs";import{a as l}from"./privy-context-DrMxzgOR.mjs";import{S as p}from"./ScreenLayout-D1p_ntex.mjs";import"@privy-io/js-sdk-core";import"tinycolor2";import"ofetch";import"@privy-io/are-addresses-equal";import"./ModalHeader-BnVmXtvG.mjs";import"styled-components";import"./useActiveWallet-CvP7iYvj.mjs";import"zustand";import"react-device-detect";import"./use-export-wallet-_wu5ex5t.mjs";import"./useWallets-BzNCTucF.mjs";import"viem";import"eventemitter3";import"viem/utils";import"./events-context-CI0iqAXA.mjs";import"@heroicons/react/24/outline/ArrowLeftIcon";import"@heroicons/react/24/outline/ArrowRightIcon";import"@heroicons/react/24/outline/QuestionMarkCircleIcon";import"@heroicons/react/24/outline/XMarkIcon";import"./Screen-Cycy3IzT.mjs";import"./index-Dq_xe9dz.mjs";const u=({appName:i,success:n,error:s,onRevoke:a,onDeny:c,onClose:m})=>/*#__PURE__*/e(p,n||s?{title:s?"Something went wrong":"Success!",subtitle:s?"Please try again.":"You've successfully revoked permissions.",icon:s?o:t,iconVariant:s?"error":"success",onBack:m,watermark:!0}:{title:"Revoke offline access to wallet",subtitle:`By confirming, ${i} will no longer be able to use this wallet on your behalf when you are not online.`,icon:r,primaryCta:{label:"Confirm",onClick:a},secondaryCta:{label:"Deny",onClick:c},onBack:m,watermark:!0}),d={component:()=>{let{data:o}=l(),t=s(),{closePrivyModal:r}=c(),[p,d]=i(!1),[y,v]=i(),{onRevoke:f,onSuccess:k,onError:h}=o.delegatedActions.revoke,j=async()=>{p?k():h(y??new m("User declined revoking access to their delegated wallet.")),r({shouldCallAuthOnSuccess:!1})};return n((()=>{if(!p&&!y)return;let e=setTimeout(j,a);return()=>clearTimeout(e)}),[p,y]),/*#__PURE__*/e(u,{appName:t.name,success:p,error:y,onRevoke:async()=>{try{await f(),d(!0)}catch(e){v(e)}},onDeny:()=>{j()},onClose:j})}};export{d as DelegatedActionsRevokeScreen,u as DelegatedActionsRevokeScreenView,d as default};