Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removeAll() removes the wrong metaKey #44

Open
bozzaj opened this issue Jun 30, 2020 · 3 comments
Open

removeAll() removes the wrong metaKey #44

bozzaj opened this issue Jun 30, 2020 · 3 comments

Comments

@bozzaj
Copy link

bozzaj commented Jun 30, 2020

When using encryptionNamespace, removeAll() removes the default metaKey (from utils.metaKey) instead of the namespace metaKey from getMetaKey()

@softvar
Copy link
Owner

softvar commented Jul 5, 2020

Using removeAll deletes all the keys created by secure-ls lib. Please refer the docs.

Please let me know if it causes any issue.

@bozzaj
Copy link
Author

bozzaj commented Jul 5, 2020

I understand that. However, take this example:

// Use a private namespace with a metaKey of _secure__ls__metadata__private
const ls1 = new SecureLS({ encryptionNamespace: "private", encryptionSecret: "secret1" });
ls1.set("key1", "key1_value");

// Use a default namespace with a metaKey of _secure__ls__metadata
const ls2 = new SecureLS({ encryptionSecret: "secret2" });
ls2.set("key2", "key2_value");

// Remove first SecureLS instance
ls1.removeAll();

The ls1.removeAll() call removes all the keys (key1) for ls1 but doesn't remove _secure__ls__metadata__private. However, it DOES remove the metaKey secure__ls__metadata which is used by the default namespace ls2 object. This leaves localStorage with key2 and _secure__ls__metadata__private.

JSFiddle: https://jsfiddle.net/r4qodgm5/

Perhaps I don't understand the reason for namespaces? Why would removeAll() on the private namespace remove the metaData for the default namespace but leave the metaData for the private namespace?

@softvar
Copy link
Owner

softvar commented Jul 5, 2020

I think there's some issue for sure. WIll debug and let you know.
Thanks for reporting this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants