Turnkey home page
Search...
⌘K
Ask AI
Demo
Login
Get started
Get started
Search...
Navigation
SDK reference
clearUnusedKeyPairs()
Documentation
SDK reference
API reference
Security
Changelogs
Support
Blog
Contact us
SDK reference
Introduction
React
React Native
Flutter
Swift
TypeScript | Frontend
Overview
Getting Started
Authentication
Advanced backend authentication
Advanced API requests
Legacy (@turnkey/sdk-browser)
SDK reference
addOauthProvider()
addPasskey()
clearAllSessions()
clearSession()
clearUnusedKeyPairs()
completeOauth()
completeOtp()
connectWalletAccount()
constructor()
createApiKeyPair()
createPasskey()
createWallet()
createWalletAccounts()
deleteSubOrganization()
disconnectWalletAccount()
exportPrivateKey()
exportWallet()
exportWalletAccount()
fetchUser()
fetchWalletAccounts()
fetchWallets()
getActiveSessionKey()
getAllSessions()
getProxyAuthConfig()
getSession()
getWalletProviders()
importPrivateKey()
importWallet()
init()
initOtp()
loginOrSignupWithWallet()
loginWithOauth()
loginWithOtp()
loginWithPasskey()
loginWithWallet()
logout()
refreshSession()
removeOauthProviders()
removePasskeys()
removeUserEmail()
removeUserPhoneNumber()
setActiveSession()
signAndSendTransaction()
signMessage()
signTransaction()
signUpWithOauth()
signUpWithOtp()
signUpWithPasskey()
signUpWithWallet()
storeSession()
switchWalletProviderChain()
updateUserEmail()
updateUserName()
updateUserPhoneNumber()
verifyOtp()
switchWalletAccountChain()
fetchPrivateKeys()
TypeScript | Server
Golang
Rust
Ruby
CLI
Python
Web3 libraries
Advanced
Migration Path
SDK reference
clearUnusedKeyPairs()
Copy page
Copy page
Overview
Clears any unused API key pairs from persistent storage.
This function scans all API key pairs stored in indexedDB and removes any key pairs that are not associated with a session in persistent storage.
Ensures that only key pairs referenced by existing sessions are retained, preventing orphaned or stale key pairs from accumulating.
Iterates through all stored session keys and builds a map of in-use public keys, then deletes any key pairs not present in this map.
Intended to be called after session changes (e.g., login, logout, session replacement) to keep key storage clean and secure.
Package:
core
Defined in:
core.ts:3837
Parameters
No parameters.
Response
A successful response returns the following fields:
returns
void
required
A promise that resolves when all unused key pairs are successfully cleared.
Was this page helpful?
Yes
No
clearSession()
completeOauth()
Assistant
Responses are generated using AI and may contain mistakes.