secure-ls2 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc +186 -0
- package/.github/FUNDING.yml +6 -0
- package/.github/workflows/test.yml +65 -0
- package/.husky/commit-msg +1 -0
- package/.husky/pre-commit +1 -0
- package/.husky/pre-push +3 -0
- package/.prettierrc +8 -0
- package/CODE_OF_CONDUCT.md +76 -0
- package/CONTRIBUTING.md +46 -0
- package/LICENSE +21 -0
- package/README.md +350 -0
- package/babel.config.js +3 -0
- package/ci-package.json +47 -0
- package/commitlint.config.js +12 -0
- package/dist/secure-ls.js +5500 -0
- package/dist/secure-ls.js.map +1 -0
- package/dist/secure-ls.min.js +33 -0
- package/dist/secure-ls.min.js.map +1 -0
- package/dist/secure-ls2.js +5500 -0
- package/dist/secure-ls2.js.map +1 -0
- package/dist/secure-ls2.min.js +33 -0
- package/dist/secure-ls2.min.js.map +1 -0
- package/eslint.config.mjs +12 -0
- package/example/aes-compressed-realm.js +28 -0
- package/example/aes-compressed.js +12 -0
- package/example/aes-uncompressed.js +12 -0
- package/example/base64-compressed.js +12 -0
- package/example/custom-storage.js +29 -0
- package/example/des-compressed.js +12 -0
- package/example/des-uncompressed.js +12 -0
- package/example/index.html +42 -0
- package/example/only-base64.js +12 -0
- package/example/only-compressed.js +12 -0
- package/example/rabbit-compressed.js +12 -0
- package/example/rabbit-uncompressed.js +12 -0
- package/example/rc4-compressed.js +12 -0
- package/example/rc4-uncompressed.js +12 -0
- package/example/sessionStorage.js +13 -0
- package/example/standard.js +13 -0
- package/example/vendor/screenlog.min.js +5 -0
- package/jest.config.js +10 -0
- package/package.json +78 -0
- package/screenshot.png +0 -0
- package/types/secure-ls.d.ts +58 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
var data = { data: [{ age: 1 }, { age: '2' }] };
|
|
2
|
+
var aesCRealm1 = new SecureLS({
|
|
3
|
+
encodingType: 'aes',
|
|
4
|
+
encryptionSecret: 'secret1',
|
|
5
|
+
encryptionNamespace: 'realm1',
|
|
6
|
+
metaKey: '__meta__',
|
|
7
|
+
});
|
|
8
|
+
var key1 = 'aes__compressed_1';
|
|
9
|
+
var ae = aesCRealm1.AES.encrypt(JSON.stringify(data), '');
|
|
10
|
+
var bde = aesCRealm1.AES.decrypt(ae.toString(), '');
|
|
11
|
+
var de = bde.toString(aesCRealm1.enc._Utf8);
|
|
12
|
+
var aesCRealm2 = new SecureLS({ encodingType: 'aes', encryptionSecret: 'secret2', encryptionNamespace: 'realm2' });
|
|
13
|
+
var key2 = 'aes__compressed_2';
|
|
14
|
+
var ae2 = aesCRealm2.AES.encrypt(JSON.stringify(data), '');
|
|
15
|
+
var bde2 = aesCRealm2.AES.decrypt(ae2.toString(), '');
|
|
16
|
+
var de2 = bde2.toString(aesCRealm2.enc._Utf8);
|
|
17
|
+
|
|
18
|
+
aesCRealm1.set(key1, data);
|
|
19
|
+
console.log('AES Compressed Realm1');
|
|
20
|
+
console.log(localStorage.getItem(key1));
|
|
21
|
+
console.log(aesCRealm1.get(key1));
|
|
22
|
+
console.log('____________________________________');
|
|
23
|
+
|
|
24
|
+
aesCRealm2.set(key2, data);
|
|
25
|
+
console.log('AES Compressed Realm2');
|
|
26
|
+
console.log(localStorage.getItem(key2));
|
|
27
|
+
console.log(aesCRealm2.get(key2));
|
|
28
|
+
console.log('____________________________________');
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var key = 'aes__compressed';
|
|
2
|
+
var data = { data: [{ age: 1 }, { age: '2' }] };
|
|
3
|
+
var aes_c = new SecureLS({ encodingType: 'aes', encryptionSecret: '' });
|
|
4
|
+
ae = aes_c.AES.encrypt(JSON.stringify(data), '');
|
|
5
|
+
bde = aes_c.AES.decrypt(ae.toString(), '');
|
|
6
|
+
de = bde.toString(aes_c.enc._Utf8);
|
|
7
|
+
|
|
8
|
+
aes_c.set(key, data);
|
|
9
|
+
console.log('AES Compressed');
|
|
10
|
+
console.log(localStorage.getItem(key));
|
|
11
|
+
console.log(aes_c.get(key));
|
|
12
|
+
console.log('____________________________________');
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var key = 'aes__uncompressed';
|
|
2
|
+
var data = { data: [{ age: 1 }, { age: '2' }] };
|
|
3
|
+
var aes_u = new SecureLS({ encodingType: 'aes', isCompression: false });
|
|
4
|
+
ae = aes_u.AES.encrypt(JSON.stringify(data), 's3cr3t@123');
|
|
5
|
+
bde = aes_u.AES.decrypt(ae.toString(), 's3cr3t@123');
|
|
6
|
+
de = bde.toString(aes_u.enc._Utf8);
|
|
7
|
+
|
|
8
|
+
aes_u.set(key, data);
|
|
9
|
+
console.log('AES NOT Compressed');
|
|
10
|
+
console.log(localStorage.getItem(key));
|
|
11
|
+
console.log(aes_u.get(key));
|
|
12
|
+
console.log('____________________________________');
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var key = 'base64__compressed';
|
|
2
|
+
var data = { data: [{ age: 1 }, { age: '2' }] };
|
|
3
|
+
var b_c = new SecureLS();
|
|
4
|
+
ae = b_c.AES.encrypt(JSON.stringify(data), 's3cr3t@123');
|
|
5
|
+
bde = b_c.AES.decrypt(ae.toString(), 's3cr3t@123');
|
|
6
|
+
de = bde.toString(b_c.enc._Utf8);
|
|
7
|
+
|
|
8
|
+
b_c.set(key, data);
|
|
9
|
+
console.log('Base64 Compressed');
|
|
10
|
+
console.log(localStorage.getItem(key));
|
|
11
|
+
console.log(b_c.get(key));
|
|
12
|
+
console.log('____________________________________');
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
window.customSecureLsStore = {};
|
|
2
|
+
const storage = {
|
|
3
|
+
setItem: (key, value) => {
|
|
4
|
+
window.customSecureLsStore[key] = value || '';
|
|
5
|
+
},
|
|
6
|
+
getItem: (key) => {
|
|
7
|
+
return window.customSecureLsStore[key] || null;
|
|
8
|
+
},
|
|
9
|
+
removeItem: (key) => {
|
|
10
|
+
delete window.customSecureLsStore[key];
|
|
11
|
+
},
|
|
12
|
+
clear: () => {
|
|
13
|
+
window.customSecureLsStore = {};
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
var key = 'custom-storage';
|
|
18
|
+
var data = { data: [{ age: 1 }, { age: '2' }] };
|
|
19
|
+
var a = new SecureLS({ encodingType: '', isCompression: false, storage });
|
|
20
|
+
ae = a.AES.encrypt(JSON.stringify(data), 's3cr3t@123');
|
|
21
|
+
bde = a.AES.decrypt(ae.toString(), 's3cr3t@123');
|
|
22
|
+
de = bde.toString(a.enc._Utf8);
|
|
23
|
+
|
|
24
|
+
a.set(key, data);
|
|
25
|
+
console.log('____________________________________');
|
|
26
|
+
console.log('sessionStorage Case: no compression, no encryption / encoding, storage set to sessionStorage');
|
|
27
|
+
console.log(sessionStorage.getItem(key));
|
|
28
|
+
console.log(a.get(key));
|
|
29
|
+
console.log('____________________________________');
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var key = 'des__compressed';
|
|
2
|
+
var data = { data: [{ age: 1 }, { age: '2' }] };
|
|
3
|
+
var des_c = new SecureLS({ encodingType: 'des' });
|
|
4
|
+
ae = des_c.DES.encrypt(JSON.stringify(data), 's3cr3t@123');
|
|
5
|
+
bde = des_c.DES.decrypt(ae.toString(), 's3cr3t@123');
|
|
6
|
+
de = bde.toString(des_c.enc._Utf8);
|
|
7
|
+
|
|
8
|
+
des_c.set(key, data);
|
|
9
|
+
console.log('DES Compressed');
|
|
10
|
+
console.log(localStorage.getItem(key));
|
|
11
|
+
console.log(des_c.get(key));
|
|
12
|
+
console.log('____________________________________');
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var key = 'des__uncompressed';
|
|
2
|
+
var data = { data: [{ age: 1 }, { age: '2' }] };
|
|
3
|
+
var des_u = new SecureLS({ encodingType: 'des', isCompression: false });
|
|
4
|
+
ae = des_u.DES.encrypt(JSON.stringify(data), 's3cr3t@123');
|
|
5
|
+
bde = des_u.DES.decrypt(ae.toString(), 's3cr3t@123');
|
|
6
|
+
de = bde.toString(des_u.enc._Utf8);
|
|
7
|
+
|
|
8
|
+
des_u.set(key, data);
|
|
9
|
+
console.log('DES not Compressed');
|
|
10
|
+
console.log(localStorage.getItem(key));
|
|
11
|
+
console.log(des_u.get(key));
|
|
12
|
+
console.log('____________________________________');
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>Example Page</title>
|
|
5
|
+
<script type="text/javascript" src="../dist/secure-ls.js"></script>
|
|
6
|
+
<script type="text/javascript">
|
|
7
|
+
window.SecureLS = SecureLS.default;
|
|
8
|
+
</script>
|
|
9
|
+
<script type="text/javascript" src="vendor/screenlog.min.js"></script>
|
|
10
|
+
</head>
|
|
11
|
+
<body>
|
|
12
|
+
Open console to check localStorage data.
|
|
13
|
+
<br />
|
|
14
|
+
All of the console output from various examples will be log here. Scroll within it to view all logs.
|
|
15
|
+
<br /><br />
|
|
16
|
+
Input:
|
|
17
|
+
<pre>{"data":[{"age":1},{"age":"2"}]}</pre>
|
|
18
|
+
Output:
|
|
19
|
+
<pre>{"data":[{"age":1},{"age":"2"}]}</pre>
|
|
20
|
+
<script type="text/javascript">
|
|
21
|
+
screenLog.init({
|
|
22
|
+
autoScroll: false,
|
|
23
|
+
});
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<script type="text/javascript" src="standard.js"></script>
|
|
27
|
+
<script type="text/javascript" src="only-base64.js"></script>
|
|
28
|
+
<script type="text/javascript" src="only-compressed.js"></script>
|
|
29
|
+
<script type="text/javascript" src="base64-compressed.js"></script>
|
|
30
|
+
<script type="text/javascript" src="aes-compressed.js"></script>
|
|
31
|
+
<script type="text/javascript" src="aes-compressed-realm.js"></script>
|
|
32
|
+
<script type="text/javascript" src="aes-uncompressed.js"></script>
|
|
33
|
+
<script type="text/javascript" src="des-compressed.js"></script>
|
|
34
|
+
<script type="text/javascript" src="des-uncompressed.js"></script>
|
|
35
|
+
<script type="text/javascript" src="rabbit-compressed.js"></script>
|
|
36
|
+
<script type="text/javascript" src="rabbit-uncompressed.js"></script>
|
|
37
|
+
<script type="text/javascript" src="rc4-compressed.js"></script>
|
|
38
|
+
<script type="text/javascript" src="rc4-uncompressed.js"></script>
|
|
39
|
+
<script type="text/javascript" src="sessionStorage.js"></script>
|
|
40
|
+
<script type="text/javascript" src="custom-storage.js"></script>
|
|
41
|
+
</body>
|
|
42
|
+
</html>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var key = 'only__base64';
|
|
2
|
+
var data = { data: [{ age: 1 }, { age: '2' }] };
|
|
3
|
+
var o_b = new SecureLS({ isCompression: false });
|
|
4
|
+
ae = o_b.AES.encrypt(JSON.stringify(data), 's3cr3t@123');
|
|
5
|
+
bde = o_b.AES.decrypt(ae.toString(), 's3cr3t@123');
|
|
6
|
+
de = bde.toString(o_b.enc._Utf8);
|
|
7
|
+
|
|
8
|
+
o_b.set(key, data);
|
|
9
|
+
console.log('Only Base64, no compression');
|
|
10
|
+
console.log(localStorage.getItem(key));
|
|
11
|
+
console.log(o_b.get(key));
|
|
12
|
+
console.log('____________________________________');
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var key = 'only__compressed';
|
|
2
|
+
var data = { data: [{ age: 1 }, { age: '2' }] };
|
|
3
|
+
var o_c = new SecureLS({ encodingType: '' });
|
|
4
|
+
ae = o_c.AES.encrypt(JSON.stringify(data), 's3cr3t@123');
|
|
5
|
+
bde = o_c.AES.decrypt(ae.toString(), 's3cr3t@123');
|
|
6
|
+
de = bde.toString(o_c.enc._Utf8);
|
|
7
|
+
|
|
8
|
+
o_c.set(key, data);
|
|
9
|
+
console.log('Only Compression, no encoding/encryption');
|
|
10
|
+
console.log(localStorage.getItem(key));
|
|
11
|
+
console.log(o_c.get(key));
|
|
12
|
+
console.log('____________________________________');
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var key = 'rabbit__compressed';
|
|
2
|
+
var data = { data: [{ age: 1 }, { age: '2' }] };
|
|
3
|
+
var rabbit_c = new SecureLS({ encodingType: 'rabbit' });
|
|
4
|
+
ae = rabbit_c.RABBIT.encrypt(JSON.stringify(data), 's3cr3t@123');
|
|
5
|
+
bde = rabbit_c.RABBIT.decrypt(ae.toString(), 's3cr3t@123');
|
|
6
|
+
de = bde.toString(rabbit_c.enc._Utf8);
|
|
7
|
+
|
|
8
|
+
rabbit_c.set(key, data);
|
|
9
|
+
console.log('RABBIT Compressed');
|
|
10
|
+
console.log(localStorage.getItem(key));
|
|
11
|
+
console.log(rabbit_c.get(key));
|
|
12
|
+
console.log('____________________________________');
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var key = 'rabbit__uncompressed';
|
|
2
|
+
var data = { data: [{ age: 1 }, { age: '2' }] };
|
|
3
|
+
var rabbit_u = new SecureLS({ encodingType: 'rabbit', isCompression: false });
|
|
4
|
+
ae = rabbit_u.RABBIT.encrypt(JSON.stringify(data), 's3cr3t@123');
|
|
5
|
+
bde = rabbit_u.RABBIT.decrypt(ae.toString(), 's3cr3t@123');
|
|
6
|
+
de = bde.toString(rabbit_u.enc._Utf8);
|
|
7
|
+
|
|
8
|
+
rabbit_u.set(key, data);
|
|
9
|
+
console.log('RABBIT not Compressed');
|
|
10
|
+
console.log(localStorage.getItem(key));
|
|
11
|
+
console.log(rabbit_u.get(key));
|
|
12
|
+
console.log('____________________________________');
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var key = 'rc4__compressed';
|
|
2
|
+
var data = { data: [{ age: 1 }, { age: '2' }] };
|
|
3
|
+
var rc4_c = new SecureLS({ encodingType: 'rc4' });
|
|
4
|
+
ae = rc4_c.RC4.encrypt(JSON.stringify(data), 's3cr3t@123');
|
|
5
|
+
bde = rc4_c.RC4.decrypt(ae.toString(), 's3cr3t@123');
|
|
6
|
+
de = bde.toString(rc4_c.enc._Utf8);
|
|
7
|
+
|
|
8
|
+
rc4_c.set(key, data);
|
|
9
|
+
console.log('RC4 Compressed');
|
|
10
|
+
console.log(localStorage.getItem(key));
|
|
11
|
+
console.log(rc4_c.get(key));
|
|
12
|
+
console.log('____________________________________');
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var key = 'rc4__uncompressed';
|
|
2
|
+
var data = { data: [{ age: 1 }, { age: '2' }] };
|
|
3
|
+
var rc4_u = new SecureLS({ encodingType: 'rc4', isCompression: false });
|
|
4
|
+
ae = rc4_u.RC4.encrypt(JSON.stringify(data), 's3cr3t@123');
|
|
5
|
+
bde = rc4_u.RC4.decrypt(ae.toString(), 's3cr3t@123');
|
|
6
|
+
de = bde.toString(rc4_u.enc._Utf8);
|
|
7
|
+
|
|
8
|
+
rc4_u.set(key, data);
|
|
9
|
+
console.log('RC4 not Compressed');
|
|
10
|
+
console.log(localStorage.getItem(key));
|
|
11
|
+
console.log(rc4_u.get(key));
|
|
12
|
+
console.log('____________________________________');
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
var key = 'sessionStorage';
|
|
2
|
+
var data = { data: [{ age: 1 }, { age: '2' }] };
|
|
3
|
+
var a = new SecureLS({ encodingType: '', isCompression: false, storage: sessionStorage });
|
|
4
|
+
ae = a.AES.encrypt(JSON.stringify(data), 's3cr3t@123');
|
|
5
|
+
bde = a.AES.decrypt(ae.toString(), 's3cr3t@123');
|
|
6
|
+
de = bde.toString(a.enc._Utf8);
|
|
7
|
+
|
|
8
|
+
a.set(key, data);
|
|
9
|
+
console.log('____________________________________');
|
|
10
|
+
console.log('sessionStorage Case: no compression, no encryption / encoding, storage set to sessionStorage');
|
|
11
|
+
console.log(sessionStorage.getItem(key));
|
|
12
|
+
console.log(a.get(key));
|
|
13
|
+
console.log('____________________________________');
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
var key = 'standard';
|
|
2
|
+
var data = { data: [{ age: 1 }, { age: '2' }] };
|
|
3
|
+
var a = new SecureLS({ encodingType: '', isCompression: false });
|
|
4
|
+
ae = a.AES.encrypt(JSON.stringify(data), 's3cr3t@123');
|
|
5
|
+
bde = a.AES.decrypt(ae.toString(), 's3cr3t@123');
|
|
6
|
+
de = bde.toString(a.enc._Utf8);
|
|
7
|
+
|
|
8
|
+
a.set(key, data);
|
|
9
|
+
console.log('____________________________________');
|
|
10
|
+
console.log('Standard Case: no compression, no encryption / encoding');
|
|
11
|
+
console.log(localStorage.getItem(key));
|
|
12
|
+
console.log(a.get(key));
|
|
13
|
+
console.log('____________________________________');
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*! screenlog - v0.2.2 - 2016-07-11
|
|
2
|
+
* https://github.com/chinchang/screenlog.js
|
|
3
|
+
* Copyright (c) 2016 Kushagra Gour; Licensed */
|
|
4
|
+
|
|
5
|
+
!function(){function a(a,b){var c=document.createElement(a);return c.style.cssText=b,c}function b(){var b=a("div","z-index:2147483647;font-family:Helvetica,Arial,sans-serif;font-size:12px;font-weight:bold;padding:10px;text-align:left;opacity:0.8;position:fixed;min-width:400px;max-height:70vh;overflow:auto;background:"+_options.bgColor+";"+_options.css);return b}function c(b){return function(){var c=a("div","line-height:18px;min-height:18px;background:"+(o.children.length%2?"rgba(255,255,255,0.1)":"")+";color:"+b),d=[].slice.call(arguments).reduce(function(a,b){return a+" "+("object"==typeof b?JSON.stringify(b):b)},"");c.textContent=d,o.appendChild(c),_options.autoScroll&&(o.scrollTop=o.scrollHeight-o.clientHeight)}}function d(){o.innerHTML=""}function e(){return c(_options.logColor).apply(null,arguments)}function f(){return c(_options.infoColor).apply(null,arguments)}function g(){return c(_options.warnColor).apply(null,arguments)}function h(){return c(_options.errorColor).apply(null,arguments)}function i(a){for(var b in a)a.hasOwnProperty(b)&&_options.hasOwnProperty(b)&&(_options[b]=a[b])}function j(a){p||(p=!0,a&&i(a),o=b(),document.body.appendChild(o),_options.freeConsole||(q.log=console.log,q.clear=console.clear,q.info=console.info,q.warn=console.warn,q.error=console.error,console.log=n(e,"log"),console.clear=n(d,"clear"),console.info=n(f,"info"),console.warn=n(g,"warn"),console.error=n(h,"error")))}function k(){p=!1,console.log=q.log,console.clear=q.clear,console.info=q.info,console.warn=q.warn,console.error=q.error,o.remove()}function l(){if(!p)throw"You need to call `screenLog.init()` first."}function m(a){return function(){return l(),a.apply(this,arguments)}}function n(a,b){return function(){a.apply(this,arguments),"function"==typeof q[b]&&q[b].apply(console,arguments)}}var o,p=!1,q={};_options={bgColor:"black",logColor:"lightgreen",infoColor:"blue",warnColor:"orange",errorColor:"red",freeConsole:!1,css:"",autoScroll:!0},window.screenLog={init:j,log:n(m(e),"log"),clear:n(m(d),"clear"),info:n(m(d),"info"),warn:n(m(g),"warn"),error:n(m(h),"error"),destroy:m(k)}}();
|
package/jest.config.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
transform: {
|
|
3
|
+
'^.+\\.jsx?$': 'babel-jest',
|
|
4
|
+
},
|
|
5
|
+
// This is for handling extensions, if needed
|
|
6
|
+
moduleFileExtensions: ['js', 'jsx', 'json', 'node', 'mjs'],
|
|
7
|
+
// This might be required if you want to ignore some files
|
|
8
|
+
transformIgnorePatterns: ['/node_modules/'],
|
|
9
|
+
testEnvironment: 'jest-environment-jsdom',
|
|
10
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "secure-ls2",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Secure localStorage/sessionStorage data with high level of encryption and data compression",
|
|
5
|
+
"main": "./dist/secure-ls.js",
|
|
6
|
+
"browser": "./dist/secure-ls.js",
|
|
7
|
+
"typings": "./types/secure-ls.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "yarn build-dev && yarn build-prod",
|
|
10
|
+
"build-dev": "webpack --mode=development",
|
|
11
|
+
"build-prod": "webpack --mode=production",
|
|
12
|
+
"build:patch": "yarn build-dev --env type=patch npm version patch",
|
|
13
|
+
"build:minor": "yarn build-dev --env type=minor npm version minor",
|
|
14
|
+
"build:major": "yarn build-dev --env type=major npm version major",
|
|
15
|
+
"lint": "eslint src/*.js --fix",
|
|
16
|
+
"prepare": "husky",
|
|
17
|
+
"prettier": "prettier -w **/*.js *.md",
|
|
18
|
+
"test:dev": "jest --watch --runInBand --debug --colors --errorOnDeprecated",
|
|
19
|
+
"test:prod": "jest --runInBand --colors --errorOnDeprecated",
|
|
20
|
+
"test:coverage": "jest --coverage --coverageDirectory=coverage && cat ./coverage/lcov.info",
|
|
21
|
+
"prepublishOnly": "yarn run build",
|
|
22
|
+
"release": "npx bumpp --commit --tag --push && npm publish"
|
|
23
|
+
},
|
|
24
|
+
"lint-staged": {
|
|
25
|
+
"**/*.{js,json,md}": [
|
|
26
|
+
"prettier --write"
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"crypto-js": "^4.2.0",
|
|
31
|
+
"lz-string": "^1.5.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@babel/core": "^7.26.0",
|
|
35
|
+
"@babel/preset-env": "^7.26.0",
|
|
36
|
+
"@commitlint/cli": "^19.6.1",
|
|
37
|
+
"@commitlint/config-conventional": "^19.6.0",
|
|
38
|
+
"@eslint/js": "^9.17.0",
|
|
39
|
+
"@types/crypto-js": "^4.2.2",
|
|
40
|
+
"@types/lz-string": "^1.5.0",
|
|
41
|
+
"babel-jest": "^29.7.0",
|
|
42
|
+
"babel-loader": "^9.2.1",
|
|
43
|
+
"eslint": "^9.17.0",
|
|
44
|
+
"globals": "^15.13.0",
|
|
45
|
+
"husky": "^9.1.7",
|
|
46
|
+
"jest": "^29.7.0",
|
|
47
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
48
|
+
"lint-staged": "^15.2.11",
|
|
49
|
+
"prettier": "^3.4.2",
|
|
50
|
+
"semver": "^7.6.3",
|
|
51
|
+
"webpack": "^5.97.1",
|
|
52
|
+
"webpack-cli": "^5.1.4"
|
|
53
|
+
},
|
|
54
|
+
"repository": {
|
|
55
|
+
"type": "git",
|
|
56
|
+
"url": "https://github.com/wuc656/secure-ls.git"
|
|
57
|
+
},
|
|
58
|
+
"keywords": [
|
|
59
|
+
"secure-ls",
|
|
60
|
+
"localStorage",
|
|
61
|
+
"encryption",
|
|
62
|
+
"compression",
|
|
63
|
+
"webpack",
|
|
64
|
+
"es6",
|
|
65
|
+
"umd",
|
|
66
|
+
"commonjs"
|
|
67
|
+
],
|
|
68
|
+
"author": "wuc656, Varun Malhotra",
|
|
69
|
+
"license": "MIT",
|
|
70
|
+
"bugs": {
|
|
71
|
+
"url": "https://github.com/wuc656/secure-ls/issues"
|
|
72
|
+
},
|
|
73
|
+
"homepage": "https://github.com/wuc656/secure-ls",
|
|
74
|
+
"engines": {
|
|
75
|
+
"node": ">=8.0"
|
|
76
|
+
},
|
|
77
|
+
"engineStrict": true
|
|
78
|
+
}
|
package/screenshot.png
ADDED
|
Binary file
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export = SecureLS;
|
|
2
|
+
|
|
3
|
+
import * as LZString from 'lz-string';
|
|
4
|
+
import { CipherHelper, Encoder } from 'crypto-js';
|
|
5
|
+
|
|
6
|
+
declare class SecureLS {
|
|
7
|
+
constructor(config?: {
|
|
8
|
+
isCompression?: boolean;
|
|
9
|
+
encodingType?: string;
|
|
10
|
+
encryptionSecret?: string;
|
|
11
|
+
encryptionNamespace?: string;
|
|
12
|
+
});
|
|
13
|
+
getEncryptionSecret(): string;
|
|
14
|
+
get(key: string, isAllKeysData?: boolean): any;
|
|
15
|
+
getDataFromLocalStorage(key: string): string | null;
|
|
16
|
+
getAllKeys(): string[];
|
|
17
|
+
set(key: string, data: any): void;
|
|
18
|
+
setDataToLocalStorage(key: string, data: string): void;
|
|
19
|
+
remove(key: string): void;
|
|
20
|
+
removeAll(): void;
|
|
21
|
+
clear(): void;
|
|
22
|
+
resetAllKeys(): string[];
|
|
23
|
+
processData(data: any | string, isAllKeysData: boolean): string;
|
|
24
|
+
setMetaData(): void;
|
|
25
|
+
getMetaData(): { keys: string[] };
|
|
26
|
+
|
|
27
|
+
storage: Storage;
|
|
28
|
+
|
|
29
|
+
_name: string;
|
|
30
|
+
Base64: SecureLS.Base64;
|
|
31
|
+
LZString: LZString.LZStringStatic;
|
|
32
|
+
AES: CipherHelper;
|
|
33
|
+
DES: CipherHelper;
|
|
34
|
+
RABBIT: CipherHelper;
|
|
35
|
+
RC4: CipherHelper;
|
|
36
|
+
enc: {
|
|
37
|
+
Latin1: Encoder;
|
|
38
|
+
_Utf8: Encoder;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
interface Storage {
|
|
43
|
+
readonly length: number;
|
|
44
|
+
clear(): void;
|
|
45
|
+
getItem(key: string): string | null;
|
|
46
|
+
key(index: number): string | null;
|
|
47
|
+
removeItem(key: string): void;
|
|
48
|
+
setItem(key: string, value: string): void;
|
|
49
|
+
[name: string]: any;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
declare namespace SecureLS {
|
|
53
|
+
interface Base64 {
|
|
54
|
+
_keyStr: string;
|
|
55
|
+
encode(e: string): string;
|
|
56
|
+
decode(e: string): string;
|
|
57
|
+
}
|
|
58
|
+
}
|