Once a user’s wallet has session signers, they may also revoke consent to prevent your app from taking any further wallet actions on their behalf.
To remove all the session signers on the wallet, use the removeSessionSigners
method from the useSessionSigners
hook:
removeSessionSigners: async ({address: string}) => Promise<{user: User}>
Usage
import {useSessionSigners} from '@privy-io/react-auth';
...
const {removeSessionSigners} = useSessionSigners();
When invoked, the removeSessionSigners
method will remove all the session signers, so only the user can transact on the wallet.
After this action, your app will no longer be able to take actions on behalf of the user with
their wallet unless the user adds more session
signers.
Check out the starter repo
for an end to end example of how to use session signers.
Parameters
The removeSessionSigners
method accepts a params
object with the following fields:
Address of the embedded wallet to delegate.
As an example, you might have a button within your app to allow users to remove all session signers like so:
Example remove session signers button
import {usePrivy, useSessionSigners, type WalletWithMetadata} from '@privy-io/react-auth';
function RemoveSessionSignersButton() {
const {user} = usePrivy();
const {removeSessionSigners} = useSessionSigners();
// Check if the user's wallets already has session signers by searching the linkedAccounts array for wallets
// with `delegated: true` set
const delegatedWallet = user.linkedAccounts.filter(
(account): account is WalletWithMetadata => account.type === 'wallet' && account.delegated
);
const onRevoke = async () => {
if (!hasDelegatedWallets) return; // Button is disabled to prevent this case
await removeSessionSigners({address: delegatedWallet.address});
};
return (
<button disabled={!hasDelegatedWallets} onClick={onRevoke}>
Revoke permission for this app to transact on my behalf
</button>
);
}
To remove all the session signers on the wallet, use the removeSessionSigners
method from the useSessionSigners
hook:
removeSessionSigners: async ({address: string}) => Promise<{user: User}>
Usage
import {useSessionSigners} from '@privy-io/react-auth';
...
const {removeSessionSigners} = useSessionSigners();
When invoked, the removeSessionSigners
method will remove all the session signers, so only the user can transact on the wallet.
After this action, your app will no longer be able to take actions on behalf of the user with
their wallet unless the user adds more session
signers.
Check out the starter repo
for an end to end example of how to use session signers.
Parameters
The removeSessionSigners
method accepts a params
object with the following fields:
Address of the embedded wallet to delegate.
As an example, you might have a button within your app to allow users to remove all session signers like so:
Example remove session signers button
import {usePrivy, useSessionSigners, type WalletWithMetadata} from '@privy-io/react-auth';
function RemoveSessionSignersButton() {
const {user} = usePrivy();
const {removeSessionSigners} = useSessionSigners();
// Check if the user's wallets already has session signers by searching the linkedAccounts array for wallets
// with `delegated: true` set
const delegatedWallet = user.linkedAccounts.filter(
(account): account is WalletWithMetadata => account.type === 'wallet' && account.delegated
);
const onRevoke = async () => {
if (!hasDelegatedWallets) return; // Button is disabled to prevent this case
await removeSessionSigners({address: delegatedWallet.address});
};
return (
<button disabled={!hasDelegatedWallets} onClick={onRevoke}>
Revoke permission for this app to transact on my behalf
</button>
);
}
To remove all the session signers on the wallet, use the removeSessionSigners
method from the useSessionSigners
hook:
removeSessionSigners: async ({address: string}) => Promise<{user: PrivyUser}>;
Usage
import {useSessionSigners} from '@privy-io/expo';
...
const {removeSessionSigners} = useSessionSigners();
When invoked, the removeSessionSigners
method will remove all the session signers, so only the user can transact on the wallet.
After this action, your app will no longer be able to take actions on behalf of the user with
their wallet unless the user adds more session
signers.
Parameters
The removeSessionSigners
method accepts a params
object with the following fields:
Address of the embedded wallet to delegate.
As an example, you might have a button within your app to allow users to remove all session signers like so:
Example remove session signers button
import {usePrivy, useSessionSigners, type PrivyEmbeddedWalletAccount} from '@privy-io/expo';
function RemoveSessionSignersButton() {
const {user} = usePrivy();
const {removeSessionSigners} = useSessionSigners();
// Check if the user's wallets already has session signers by searching the linked_accounts array for wallets
// with `delegated: true` set
const delegatedWallet = user.linked_accounts.find(
(account): account is PrivyEmbeddedWalletAccount =>
account.type === 'wallet' && account.delegated
);
const onRevoke = async () => {
if (!delegatedWallet) return; // Button is disabled to prevent this case
await removeSessionSigners({address: delegatedWallet.address});
};
return (
<Button disabled={!delegatedWallet} onPress={onRevoke}>
Revoke permission for this app to transact on my behalf
</Button>
);
}