From 8ee45a38f0bc9891cc704bf36917f6294945c62d Mon Sep 17 00:00:00 2001 From: Samuel Crypto Date: Thu, 1 Nov 2018 10:57:42 -0400 Subject: [PATCH] proxifiedContainers.delete routine added and loosely tested --- src/js/proxified-containers.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/js/proxified-containers.js b/src/js/proxified-containers.js index 85a1ed4..1cd0b01 100644 --- a/src/js/proxified-containers.js +++ b/src/js/proxified-containers.js @@ -146,5 +146,31 @@ proxifiedContainers = { return result; } + }, + + //Deletes the proxy information object for a specified cookieStoreId [useful for cleaning] + delete(cookieStoreId) { + return new Promise((resolve, reject) => { + // Assumes proxy is a properly formatted object + proxifiedContainers.retrieve().then((proxifiedContainersStore) => { + let index = proxifiedContainersStore.findIndex(i => i.cookieStoreId === cookieStoreId); + + if (index === -1) { + reject({error: "not-found", message: `Container '${cookieStoreId}' not found.`}); + } else { + delete proxifiedContainersStore[index]; + } + + browser.storage.local.set({ + proxifiedContainersKey: proxifiedContainersStore + }); + + resolve(); + }, (errorObj) => { + reject(errorObj); + }).catch((error) => { + throw error; + }); + }); } };