UNPKG

@privy-io/js-sdk-core

Version:

Vanilla JS client for the Privy Auth API

2 lines (1 loc) 1.13 kB
import{PrivyClientError as e}from"../../Error.mjs";import{isUnifiedWallet as t}from"../../wallet-api/unified-wallet.mjs";import{getUserValidDelegateWallets as r}from"./utils.mjs";import"../../utils/getAllUserEmbeddedEthereumWallets.mjs";import"../../utils/getAllUserEmbeddedSolanaWallets.mjs";import"../../utils/getUserEmbeddedEthereumWallet.mjs";import"../../utils/getUserEmbeddedSolanaWallet.mjs";const o=o=>async()=>{let{user:s}=await o.user.get();if(!s)throw new e({code:"delegated_actions_before_logged_in",error:"Must be logged in to revoke delegated wallets"});let l=r(s);if(l.some(t))throw new e({code:"unsupported_wallet_type",error:"revokeWallets is only supported for on-device execution and this app uses TEE execution. Use the useSessionSigners hook to manage server side access on behalf of your users. Learn more https://docs.privy.io/recipes/tee-wallet-migration-guide"});if(l.every((e=>!e.delegated)))throw new e({code:"delegated_actions_no_wallet_to_revoke",error:"User has no delegated wallets to revoke."});await o.delegated.revoke();let{user:a}=await o.user.get();return{user:a}};export{o as revokeWallets};