UNPKG

@privy-io/js-sdk-core

Version:

Vanilla JS client for the Privy Auth API

2 lines (1 loc) 1.16 kB
"use strict";var e=require("../../Error.js"),r=require("../../wallet-api/unified-wallet.js"),t=require("./utils.js");require("../../utils/getAllUserEmbeddedEthereumWallets.js"),require("../../utils/getAllUserEmbeddedSolanaWallets.js"),require("../../utils/getUserEmbeddedEthereumWallet.js"),require("../../utils/getUserEmbeddedSolanaWallet.js");exports.revokeWallets=s=>async()=>{let{user:l}=await s.user.get();if(!l)throw new e.PrivyClientError({code:"delegated_actions_before_logged_in",error:"Must be logged in to revoke delegated wallets"});let o=t.getUserValidDelegateWallets(l);if(o.some(r.isUnifiedWallet))throw new e.PrivyClientError({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(o.every((e=>!e.delegated)))throw new e.PrivyClientError({code:"delegated_actions_no_wallet_to_revoke",error:"User has no delegated wallets to revoke."});await s.delegated.revoke();let{user:i}=await s.user.get();return{user:i}};