softvar / secure-ls

:lock: Secure localStorage data with high level of encryption and data compression
http://softvar.github.io/secure-ls
MIT License
646 stars 82 forks source link

secure-ls ( v.^1.2.6") can't find variable localStorage #47

Closed mohamedbelhassen closed 4 months ago

mohamedbelhassen commented 4 years ago

I am trying to use secure-ls to encrypt local data of my Parse Server Application in a react-native project. when typing the following two lines, I get the error "secure-ls can't find variable localStorage":

import SecureLS from 'secure-ls';
const ls = new SecureLS({ isCompression: false });

Could you tell me how to fix this error?

zheNeng commented 4 years ago

https://github.com/softvar/secure-ls/blob/b2d92feeeb0de93f8aebed83750dd5a30fd02d0e/src/index.js#L39

试试自己改一下这里?我想使用 sesstionStorage ,而不是 localStorage.

只要覆盖以下 api clear setItem getItem remove 应该就可以直接用了

softvar commented 4 months ago

Update the library to use 2.0.0. It works! Let me know if it fails.