feat: add delete all local data option in settings with keypair destruction
This commit is contained in:
@@ -149,6 +149,30 @@ class AuthService {
|
||||
this.notifyListeners()
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all local data (tokens, keys, caches, preferences)
|
||||
*/
|
||||
async clearAllData() {
|
||||
await this.logout()
|
||||
cryptoService.destroyKeyPair()
|
||||
|
||||
const keysToRemove = []
|
||||
for (let i = 0; i < localStorage.length; i++) {
|
||||
const key = localStorage.key(i)
|
||||
if (key && key.startsWith('dgray_')) keysToRemove.push(key)
|
||||
}
|
||||
keysToRemove.forEach(k => localStorage.removeItem(k))
|
||||
|
||||
localStorage.removeItem('searchFilters')
|
||||
localStorage.removeItem('locale')
|
||||
localStorage.removeItem('theme')
|
||||
|
||||
for (let i = sessionStorage.length - 1; i >= 0; i--) {
|
||||
const key = sessionStorage.key(i)
|
||||
if (key && key.startsWith('dgray_')) sessionStorage.removeItem(key)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset preferences to defaults on logout
|
||||
*/
|
||||
|
||||
@@ -140,6 +140,12 @@ class CryptoService {
|
||||
this.keyPair = null
|
||||
}
|
||||
|
||||
destroyKeyPair() {
|
||||
this.keyPair = null
|
||||
localStorage.removeItem(STORAGE_KEY)
|
||||
localStorage.removeItem(SALT_KEY)
|
||||
}
|
||||
|
||||
getPublicKey() {
|
||||
if (!this.keyPair) return null
|
||||
return this.naclUtil.encodeBase64(this.keyPair.publicKey)
|
||||
|
||||
Reference in New Issue
Block a user