From 575ac9dc63850afb5bb71da4b72f435f42640763 Mon Sep 17 00:00:00 2001
From: Jono Wenger <jono@elixxir.io>
Date: Wed, 7 Jun 2023 16:33:51 +0000
Subject: [PATCH] Fix purge for wasm-utils localstorage

---
 storage/purge.go | 30 ++++--------------------------
 1 file changed, 4 insertions(+), 26 deletions(-)

diff --git a/storage/purge.go b/storage/purge.go
index df75cebf..a7b7f64f 100644
--- a/storage/purge.go
+++ b/storage/purge.go
@@ -16,7 +16,6 @@ import (
 	"github.com/hack-pad/go-indexeddb/idb"
 	jww "github.com/spf13/jwalterweatherman"
 
-	"gitlab.com/elixxir/client/v4/storage/utility"
 	"gitlab.com/elixxir/wasm-utils/exception"
 	"gitlab.com/elixxir/wasm-utils/storage"
 )
@@ -45,17 +44,14 @@ func DecrementNumClientsRunning() {
 // password is required.
 //
 // Parameters:
-//   - args[0] - Storage directory path (string). This is the same directory
-//     path passed into [wasm.NewCmix].
-//   - args[1] - The user-supplied password (string). This is the same password
+//   - args[0] - The user-supplied password (string). This is the same password
 //     passed into [wasm.NewCmix].
 //
 // Returns:
-//   - Throws an error if the password is incorrect or if not all cMix
-//     followers have been stopped.
+//   - Throws an error if the password is incorrect or if not all cMix followers
+//     have been stopped.
 func Purge(_ js.Value, args []js.Value) any {
-	storageDirectory := args[0].String()
-	userPassword := args[1].String()
+	userPassword := args[0].String()
 
 	// Check the password
 	if !verifyPassword(userPassword) {
@@ -96,23 +92,5 @@ func Purge(_ js.Value, args []js.Value) any {
 	n := ls.Clear()
 	jww.DEBUG.Printf("[PURGE] Cleared %d WASM keys in local storage", n)
 
-	// Clear all EKV from local storage
-	keys := ls.LocalStorageUNSAFE().KeysPrefix(storageDirectory)
-	n = len(keys)
-	for _, keyName := range keys {
-		ls.LocalStorageUNSAFE().RemoveItem(keyName)
-	}
-	jww.DEBUG.Printf("[PURGE] Cleared %d keys with the prefix %q (for EKV)",
-		n, storageDirectory)
-
-	// Clear all NDFs saved to local storage
-	keys = ls.LocalStorageUNSAFE().KeysPrefix(utility.NdfStorageKeyNamePrefix)
-	n = len(keys)
-	for _, keyName := range keys {
-		ls.LocalStorageUNSAFE().RemoveItem(keyName)
-	}
-	jww.DEBUG.Printf("[PURGE] Cleared %d keys with the prefix %q (for NDF)",
-		n, utility.NdfStorageKeyNamePrefix)
-
 	return nil
 }
-- 
GitLab