Closed ayun2001 closed 3 months ago
From other fork, someone already tried it: https://github.com/hansanwok/secure-ls/pull/2 It may need to pull request here too.
i need it too. will you merge it? if not, would you mind explaining me how i can install the version with the PR integrated via npm? i've never done this before
any news about this?
A hacky TS solution
export class SecureStorage extends SecureLS {
constructor(config: { isCompression?: boolean, encodingType?: string, encryptionSecret?: string, encryptionNamespace?: string, useSessionStore?: boolean }) {
super(config);
// tslint:disable-next-line:ban-ts-ignore
// @ts-ignore
super.ls = config.useSessionStore ? sessionStorage : localStorage;
}
}
Hey @ayun2001 , @YanDevDe , @GsHeri , @gilbertg ,
I refactored the code & tests have published a new version 2.0.0 The latest version has support for sessionStorage as well as any kind of custom storage.
You can refer this - https://github.com/softvar/secure-ls?tab=readme-ov-file#api-documentation
Any other storage apart from localStorage
Using sessionStorage
const ls = new SecureLS({ encodingType: 'aes', isCompression: true, storage: sessionStorage });
Using any storage having the same methods as localStorage/sessionStorage
window.customSecureLsStore = {};
const storage = {
setItem: (key, value) => {
window.customSecureLsStore[key] = value || '';
},
getItem: (key) => {
return window.customSecureLsStore[key] || null;
},
removeItem: (key) => {
delete window.customSecureLsStore[key];
},
clear: () => {
window.customSecureLsStore = {};
},
};
const ls = new SecureLS({ encodingType: 'aes', isCompression: true, storage: storage });
I hope you will be glad to know this 🙌
Hi Varun Malhotra, do you have any planning to let secure-ls support sessionStorage?