secure-ls2 2.0.0 → 2.0.1

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/README.md CHANGED
@@ -1,350 +1,352 @@
1
- # secure-ls
2
- wuc656 自用
3
- Secure localStorage/sessionStorage data with high level of encryption and data compression.
4
-
5
- [![npm version](https://img.shields.io/npm/v/secure-ls2?style=for-the-badge&color=grey&logo=npm)](https://www.npmjs.com/package/secure-ls2) [![npm](https://img.shields.io/npm/dt/secure-ls2.svg?style=for-the-badge&color=blue)](https://www.npmjs.com/package/secure-ls2)
6
-
7
- [![CI](https://img.shields.io/github/actions/workflow/status/softvar/secure-ls/test.yml?style=for-the-badge&logo=github)](https://github.com/softvar/secure-ls/actions?query=workflow%3ACI)
8
- [![codecov](https://img.shields.io/codecov/c/github/softvar/secure-ls?token=HxMmlpGn3k&style=for-the-badge&logo=codecov)](https://codecov.io/gh/softvar/secure-ls)
9
-
10
- **[LIVE DEMO](http://softvar.github.io/secure-ls#live-demo)**
11
-
12
- ## Features
13
-
14
- - Secure data with various types of encryption including `AES`, `DES`, `Rabbit` and `RC4`. (defaults to `Base64` encoding).
15
- - Compress data before storing it to `localStorage` to save extra bytes (defaults to `true`).
16
- - Advanced API wrapper over `localStorage` API, providing other basic utilities.
17
- - Save data in multiple keys inside `localStorage` and `secure-ls` will always remember it's creation.
18
-
19
- ## Installation
20
-
21
- Via NPM
22
-
23
- ```bash
24
- npm install secure-ls2
25
- ```
26
-
27
- Via yarn
28
-
29
- ```bash
30
- yarn add secure-ls
31
- ```
32
-
33
- ## Libraries used
34
-
35
- - **Encryption / Decryption** using [The Cipher Algorithms](https://code.google.com/archive/p/crypto-js)
36
-
37
- It requires secret-key for encrypting and decrypting data securely. If custom secret-key is provided as mentioned below in APIs, then the library will pick that otherwise it will generate yet another very `secure` unique password key using [PBKDF2](https://code.google.com/archive/p/crypto-js/#PBKDF2), which will be further used for future API requests.
38
-
39
- `PBKDF2` is a password-based key derivation function. In many applications of cryptography, user security is ultimately dependent on a password, and because a password usually can't be used directly as a cryptographic key, some processing is required.
40
-
41
- A salt provides a large set of keys for any given password, and an iteration count increases the cost of producing keys from a password, thereby also increasing the difficulty of attack.
42
-
43
- Eg: `55e8f5585789191d350329b9ebcf2b11` and `db51d35aad96610683d5a40a70b20c39`.
44
-
45
- For the generation of such strings, `secretPhrase` is being used and can be found in code easily but that won't make it unsecure, `PBKDF2`'s layer on top of that will handle security.
46
-
47
- - **Compresion / Decompression** using [lz-string](https://github.com/pieroxy/lz-string)
48
-
49
- ## Usage
50
-
51
- - Example 1: With `default` settings i.e. `Base64` Encoding and Data Compression
52
-
53
- ```javascript
54
- const ls = new SecureLS();
55
-
56
- ls.set('key1', { data: 'test' }); // set key1
57
- ls.get('key1'); // print data
58
- // {data: 'test'}
59
- ```
60
-
61
- - Example 2: With `AES` Encryption and Data Compression
62
-
63
- ```javascript
64
- const ls = new SecureLS({ encodingType: 'aes' });
65
-
66
- ls.set('key1', { data: 'test' }); // set key1
67
- ls.get('key1'); // print data
68
- // {data: 'test'}
69
-
70
- ls.set('key2', [1, 2, 3]); // set another key
71
- ls.getAllKeys(); // get all keys
72
- // ["key1", "key2"]
73
- ls.removeAll(); // remove all keys
74
- ```
75
-
76
- - Example 3: With `RC4` Encryption but no Data Compression
77
-
78
- ```javascript
79
- const ls = new SecureLS({ encodingType: 'rc4', isCompression: false });
80
-
81
- ls.set('key1', { data: 'test' }); // set key1
82
- ls.get('key1'); // print data
83
- // {data: 'test'}
84
-
85
- ls.set('key2', [1, 2, 3]); // set another key
86
- ls.getAllKeys(); // get all keys
87
- // ["key1", "key2"]
88
- ls.removeAll(); // remove all keys
89
- ```
90
-
91
- - Example 3: With `DES` Encryption, no Data Compression and custom secret key
92
-
93
- ```javascript
94
- const ls = new SecureLS({ encodingType: 'des', isCompression: false, encryptionSecret: 'my-secret-key' });
95
-
96
- ls.set('key1', { data: 'test' }); // set key1
97
- ls.get('key1'); // print data
98
- // {data: 'test'}
99
-
100
- ls.set('key2', [1, 2, 3]); // set another key
101
- ls.getAllKeys(); // get all keys
102
- // ["key1", "key2"]
103
- ls.removeAll(); // remove all keys
104
- ```
105
-
106
- ## API Documentation
107
-
108
- #### Create an instance / reference before using.
109
-
110
- ```javascript
111
- const ls = new SecureLS();
112
- ```
113
-
114
- `Contructor` accepts a configurable `Object` with all three keys being optional.
115
-
116
- | Config Keys | default | accepts |
117
- | ----------------------- | ----------------------- | ------------------------------------------------------------------------------ |
118
- | **encodingType** | Base64 | `base64`/`aes`/`des`/`rabbit`/`rc4`/`''` |
119
- | **isCompression** | `true` | `true`/`false` |
120
- | **encryptionSecret** | PBKDF2 value | String |
121
- | **encryptionNamespace** | null | String |
122
- | **storage** | localStorage | sessionStorage/localStorage or any storage object having same methods as ls/ss |
123
- | **metaKey** | `_secure__ls__metadata` | String |
124
-
125
- **Note:** `encryptionSecret` will only be used for the Encryption and Decryption of data
126
- with `AES`, `DES`, `RC4`, `RABBIT`, and the library will discard it if no encoding / Base64
127
- encoding method is choosen.
128
-
129
- `encryptionNamespace` is used to make multiple instances with different `encryptionSecret`
130
- and/or different `encryptionSecret` possible.
131
-
132
- ```javascript
133
- const ls1 = new SecureLS({ encodingType: 'des', encryptionSecret: 'my-secret-key-1' });
134
-
135
- const ls2 = new SecureLS({ encodingType: 'aes', encryptionSecret: 'my-secret-key-2' });
136
- ```
137
-
138
- **Examples:**
139
-
140
- - No config or empty Object i.e. Default **`Base64 Encoding`** and **`Data compression`**
141
-
142
- ```javascript
143
- const ls = new SecureLS();
144
- // or
145
- const ls = new SecureLS({});
146
- ```
147
-
148
- - No encoding No data compression i.e. **`Normal`** way of storing data
149
-
150
- ```javascript
151
- const ls = new SecureLS({ encodingType: '', isCompression: false });
152
- ```
153
-
154
- - **`Base64`** encoding but **`no`** data compression
155
-
156
- ```javascript
157
- const ls = new SecureLS({ isCompression: false });
158
- ```
159
-
160
- - **`AES`** encryption and **`data compression`**
161
-
162
- ```javascript
163
- const ls = new SecureLS({ encodingType: 'aes' });
164
- ```
165
-
166
- - **`RC4`** encryption and **`no`** data compression
167
-
168
- ```javascript
169
- const ls = new SecureLS({ encodingType: 'rc4', isCompression: false });
170
- ```
171
-
172
- - **`RABBIT`** encryption, **`no`** data compression and `custom` encryptionSecret
173
-
174
- ```javascript
175
- const ls = new SecureLS({ encodingType: 'rc4', isCompression: false, encryptionSecret: 's3cr3tPa$$w0rd@123' });
176
- ```
177
-
178
- - Any other **storage** apart from localStorage
179
-
180
- - Using `sessionStorage`
181
-
182
- ```javascript
183
- const ls = new SecureLS({ encodingType: 'aes', isCompression: true, storage: sessionStorage });
184
- ```
185
-
186
- - Using any storage having same methods as `localStorage/sessionStorage`
187
-
188
- ```javascript
189
- window.customSecureLsStore = {};
190
- const storage = {
191
- setItem: (key, value) => {
192
- window.customSecureLsStore[key] = value || '';
193
- },
194
- getItem: (key) => {
195
- return window.customSecureLsStore[key] || null;
196
- },
197
- removeItem: (key) => {
198
- delete window.customSecureLsStore[key];
199
- },
200
- clear: () => {
201
- window.customSecureLsStore = {};
202
- },
203
- };
204
-
205
- const ls = new SecureLS({ encodingType: 'aes', isCompression: true, storage: storage });
206
- ```
207
-
208
- #### Methods
209
-
210
- - **`set`**
211
-
212
- Saves `data` in specifed `key` in localStorage. If the key is not provided, the library will warn. Following types of JavaScript objects are supported:
213
-
214
- - Array
215
- - ArrayBuffer
216
- - Blob
217
- - Float32Array
218
- - Float64Array
219
- - Int8Array
220
- - Int16Array
221
- - Int32Array
222
- - Number
223
- - Object
224
- - Uint8Array
225
- - Uint8ClampedArray
226
- - Uint16Array
227
- - Uint32Array
228
- - String
229
-
230
- | Parameter | Description |
231
- | --------- | -------------------- |
232
- | key | key to store data in |
233
- | data | data to be stored |
234
-
235
- ```javascript
236
- ls.set('key-name', { test: 'secure-ls' });
237
- ```
238
-
239
- - **`get`**
240
-
241
- Gets `data` back from specified `key` from the localStorage library. If the key is not provided, the library will warn.
242
-
243
- | Parameter | Description |
244
- | --------- | --------------------------- |
245
- | key | key in which data is stored |
246
-
247
- ```javascript
248
- ls.get('key-name');
249
- ```
250
-
251
- - **`remove`**
252
-
253
- Removes the value of a key from the localStorage. If the `meta key`, which stores the list of keys, is tried to be removed even if there are other keys which were created by `secure-ls` library, the library will warn for the action.
254
-
255
- | Parameter | Description |
256
- | --------- | ---------------------------------- |
257
- | key | remove key in which data is stored |
258
-
259
- ```javascript
260
- ls.remove('key-name');
261
- ```
262
-
263
- - **`removeAll`**
264
-
265
- Removes all the keys that were created by the `secure-ls` library, even the `meta key`.
266
-
267
- ```javascript
268
- ls.removeAll();
269
- ```
270
-
271
- - **`clear`**
272
-
273
- Removes all the keys ever created for that particular domain. Remember localStorage works differently for `http` and `https` protocol;
274
-
275
- ```javascript
276
- ls.clear();
277
- ```
278
-
279
- - **`getAllKeys`**
280
-
281
- Gets the list of keys that were created using the `secure-ls` library. Helpful when data needs to be retrieved for all the keys or when keys name are not known(dynamically created keys).
282
-
283
- `getAllKeys()`
284
-
285
- ```javascript
286
- ls.getAllKeys();
287
- ```
288
-
289
- ## Screenshot
290
-
291
- <img src="screenshot.png" height="800">
292
-
293
- ## Scripts
294
-
295
- - `npm run build` - produces production version of the library under the `dist` folder
296
- - `npm run build-dev` - produces development version of the library and runs a watcher
297
- - `npm run test` - well ... it runs the tests :)
298
-
299
- ## Contributing
300
-
301
- 1. Fork the repo on GitHub.
302
- 2. Clone the repo on machine.
303
- 3. Execute `npm install` and `npm run dev`.
304
- 4. Create a new branch `<fix-typo>` and do your work.
305
- 5. Run `npm run build` to build dist files and `npm run test` to ensure all test cases are passing.
306
- 6. Commit your changes to the branch.
307
- 7. Submit a Pull request.
308
-
309
- ## Development Stack
310
-
311
- - Webpack based `src` compilation & bundling and `dist` generation.
312
- - ES6 as a source of writing code.
313
- - Exports in a [umd](https://github.com/umdjs/umd) format so the library works everywhere.
314
- - ES6 test setup with [Jest](https://jestjs.io/)
315
- - Linting with [ESLint](http://eslint.org/).
316
-
317
- ## Process
318
-
319
- ```
320
- ES6 source files
321
- |
322
- |
323
- webpack
324
- |
325
- +--- babel, eslint
326
- |
327
- ready to use
328
- library
329
- in umd format
330
- ```
331
-
332
- ## Credits
333
-
334
- Many thanks to:
335
-
336
- - [@brix](https://github.com/brix) for the awesome **[crypto-js](https://github.com/brix/crypto-js)** library for encrypting and decrypting data securely.
337
-
338
- - [@pieroxy](https://github.com/pieroxy) for the **[lz-string](https://github.com/pieroxy/lz-string)** js library for data compression / decompression.
339
-
340
- ## Copyright and license
341
-
342
- > The [MIT license](https://opensource.org/licenses/MIT) (MIT)
343
- >
344
- > Copyright (c) 2015-2024 Varun Malhotra
345
- >
346
- > Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
347
- >
348
- > The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
349
- >
350
- > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ # secure-ls
2
+
3
+ wuc656 自用
4
+
5
+ Secure localStorage/sessionStorage data with high level of encryption and data compression.
6
+
7
+ [![npm version](https://img.shields.io/npm/v/secure-ls2?style=for-the-badge&color=grey&logo=npm)](https://www.npmjs.com/package/secure-ls2) [![npm](https://img.shields.io/npm/dt/secure-ls2.svg?style=for-the-badge&color=blue)](https://www.npmjs.com/package/secure-ls2)
8
+
9
+ [![CI](https://img.shields.io/github/actions/workflow/status/softvar/secure-ls/test.yml?style=for-the-badge&logo=github)](https://github.com/softvar/secure-ls/actions?query=workflow%3ACI)
10
+ [![codecov](https://img.shields.io/codecov/c/github/softvar/secure-ls?token=HxMmlpGn3k&style=for-the-badge&logo=codecov)](https://codecov.io/gh/softvar/secure-ls)
11
+
12
+ **[LIVE DEMO](http://softvar.github.io/secure-ls#live-demo)**
13
+
14
+ ## Features
15
+
16
+ - Secure data with various types of encryption including `AES`, `DES`, `Rabbit` and `RC4`. (defaults to `Base64` encoding).
17
+ - Compress data before storing it to `localStorage` to save extra bytes (defaults to `true`).
18
+ - Advanced API wrapper over `localStorage` API, providing other basic utilities.
19
+ - Save data in multiple keys inside `localStorage` and `secure-ls` will always remember it's creation.
20
+
21
+ ## Installation
22
+
23
+ Via NPM
24
+
25
+ ```bash
26
+ npm install secure-ls2
27
+ ```
28
+
29
+ Via yarn
30
+
31
+ ```bash
32
+ yarn add secure-ls
33
+ ```
34
+
35
+ ## Libraries used
36
+
37
+ - **Encryption / Decryption** using [The Cipher Algorithms](https://code.google.com/archive/p/crypto-js)
38
+
39
+ It requires secret-key for encrypting and decrypting data securely. If custom secret-key is provided as mentioned below in APIs, then the library will pick that otherwise it will generate yet another very `secure` unique password key using [PBKDF2](https://code.google.com/archive/p/crypto-js/#PBKDF2), which will be further used for future API requests.
40
+
41
+ `PBKDF2` is a password-based key derivation function. In many applications of cryptography, user security is ultimately dependent on a password, and because a password usually can't be used directly as a cryptographic key, some processing is required.
42
+
43
+ A salt provides a large set of keys for any given password, and an iteration count increases the cost of producing keys from a password, thereby also increasing the difficulty of attack.
44
+
45
+ Eg: `55e8f5585789191d350329b9ebcf2b11` and `db51d35aad96610683d5a40a70b20c39`.
46
+
47
+ For the generation of such strings, `secretPhrase` is being used and can be found in code easily but that won't make it unsecure, `PBKDF2`'s layer on top of that will handle security.
48
+
49
+ - **Compresion / Decompression** using [lz-string](https://github.com/pieroxy/lz-string)
50
+
51
+ ## Usage
52
+
53
+ - Example 1: With `default` settings i.e. `Base64` Encoding and Data Compression
54
+
55
+ ```javascript
56
+ const ls = new SecureLS();
57
+
58
+ ls.set('key1', { data: 'test' }); // set key1
59
+ ls.get('key1'); // print data
60
+ // {data: 'test'}
61
+ ```
62
+
63
+ - Example 2: With `AES` Encryption and Data Compression
64
+
65
+ ```javascript
66
+ const ls = new SecureLS({ encodingType: 'aes' });
67
+
68
+ ls.set('key1', { data: 'test' }); // set key1
69
+ ls.get('key1'); // print data
70
+ // {data: 'test'}
71
+
72
+ ls.set('key2', [1, 2, 3]); // set another key
73
+ ls.getAllKeys(); // get all keys
74
+ // ["key1", "key2"]
75
+ ls.removeAll(); // remove all keys
76
+ ```
77
+
78
+ - Example 3: With `RC4` Encryption but no Data Compression
79
+
80
+ ```javascript
81
+ const ls = new SecureLS({ encodingType: 'rc4', isCompression: false });
82
+
83
+ ls.set('key1', { data: 'test' }); // set key1
84
+ ls.get('key1'); // print data
85
+ // {data: 'test'}
86
+
87
+ ls.set('key2', [1, 2, 3]); // set another key
88
+ ls.getAllKeys(); // get all keys
89
+ // ["key1", "key2"]
90
+ ls.removeAll(); // remove all keys
91
+ ```
92
+
93
+ - Example 3: With `DES` Encryption, no Data Compression and custom secret key
94
+
95
+ ```javascript
96
+ const ls = new SecureLS({ encodingType: 'des', isCompression: false, encryptionSecret: 'my-secret-key' });
97
+
98
+ ls.set('key1', { data: 'test' }); // set key1
99
+ ls.get('key1'); // print data
100
+ // {data: 'test'}
101
+
102
+ ls.set('key2', [1, 2, 3]); // set another key
103
+ ls.getAllKeys(); // get all keys
104
+ // ["key1", "key2"]
105
+ ls.removeAll(); // remove all keys
106
+ ```
107
+
108
+ ## API Documentation
109
+
110
+ #### Create an instance / reference before using.
111
+
112
+ ```javascript
113
+ const ls = new SecureLS();
114
+ ```
115
+
116
+ `Contructor` accepts a configurable `Object` with all three keys being optional.
117
+
118
+ | Config Keys | default | accepts |
119
+ | ----------------------- | ----------------------- | ------------------------------------------------------------------------------ |
120
+ | **encodingType** | Base64 | `base64`/`aes`/`des`/`rabbit`/`rc4`/`''` |
121
+ | **isCompression** | `true` | `true`/`false` |
122
+ | **encryptionSecret** | PBKDF2 value | String |
123
+ | **encryptionNamespace** | null | String |
124
+ | **storage** | localStorage | sessionStorage/localStorage or any storage object having same methods as ls/ss |
125
+ | **metaKey** | `_secure__ls__metadata` | String |
126
+
127
+ **Note:** `encryptionSecret` will only be used for the Encryption and Decryption of data
128
+ with `AES`, `DES`, `RC4`, `RABBIT`, and the library will discard it if no encoding / Base64
129
+ encoding method is choosen.
130
+
131
+ `encryptionNamespace` is used to make multiple instances with different `encryptionSecret`
132
+ and/or different `encryptionSecret` possible.
133
+
134
+ ```javascript
135
+ const ls1 = new SecureLS({ encodingType: 'des', encryptionSecret: 'my-secret-key-1' });
136
+
137
+ const ls2 = new SecureLS({ encodingType: 'aes', encryptionSecret: 'my-secret-key-2' });
138
+ ```
139
+
140
+ **Examples:**
141
+
142
+ - No config or empty Object i.e. Default **`Base64 Encoding`** and **`Data compression`**
143
+
144
+ ```javascript
145
+ const ls = new SecureLS();
146
+ // or
147
+ const ls = new SecureLS({});
148
+ ```
149
+
150
+ - No encoding No data compression i.e. **`Normal`** way of storing data
151
+
152
+ ```javascript
153
+ const ls = new SecureLS({ encodingType: '', isCompression: false });
154
+ ```
155
+
156
+ - **`Base64`** encoding but **`no`** data compression
157
+
158
+ ```javascript
159
+ const ls = new SecureLS({ isCompression: false });
160
+ ```
161
+
162
+ - **`AES`** encryption and **`data compression`**
163
+
164
+ ```javascript
165
+ const ls = new SecureLS({ encodingType: 'aes' });
166
+ ```
167
+
168
+ - **`RC4`** encryption and **`no`** data compression
169
+
170
+ ```javascript
171
+ const ls = new SecureLS({ encodingType: 'rc4', isCompression: false });
172
+ ```
173
+
174
+ - **`RABBIT`** encryption, **`no`** data compression and `custom` encryptionSecret
175
+
176
+ ```javascript
177
+ const ls = new SecureLS({ encodingType: 'rc4', isCompression: false, encryptionSecret: 's3cr3tPa$$w0rd@123' });
178
+ ```
179
+
180
+ - Any other **storage** apart from localStorage
181
+
182
+ - Using `sessionStorage`
183
+
184
+ ```javascript
185
+ const ls = new SecureLS({ encodingType: 'aes', isCompression: true, storage: sessionStorage });
186
+ ```
187
+
188
+ - Using any storage having same methods as `localStorage/sessionStorage`
189
+
190
+ ```javascript
191
+ window.customSecureLsStore = {};
192
+ const storage = {
193
+ setItem: (key, value) => {
194
+ window.customSecureLsStore[key] = value || '';
195
+ },
196
+ getItem: (key) => {
197
+ return window.customSecureLsStore[key] || null;
198
+ },
199
+ removeItem: (key) => {
200
+ delete window.customSecureLsStore[key];
201
+ },
202
+ clear: () => {
203
+ window.customSecureLsStore = {};
204
+ },
205
+ };
206
+
207
+ const ls = new SecureLS({ encodingType: 'aes', isCompression: true, storage: storage });
208
+ ```
209
+
210
+ #### Methods
211
+
212
+ - **`set`**
213
+
214
+ Saves `data` in specifed `key` in localStorage. If the key is not provided, the library will warn. Following types of JavaScript objects are supported:
215
+
216
+ - Array
217
+ - ArrayBuffer
218
+ - Blob
219
+ - Float32Array
220
+ - Float64Array
221
+ - Int8Array
222
+ - Int16Array
223
+ - Int32Array
224
+ - Number
225
+ - Object
226
+ - Uint8Array
227
+ - Uint8ClampedArray
228
+ - Uint16Array
229
+ - Uint32Array
230
+ - String
231
+
232
+ | Parameter | Description |
233
+ | --------- | -------------------- |
234
+ | key | key to store data in |
235
+ | data | data to be stored |
236
+
237
+ ```javascript
238
+ ls.set('key-name', { test: 'secure-ls' });
239
+ ```
240
+
241
+ - **`get`**
242
+
243
+ Gets `data` back from specified `key` from the localStorage library. If the key is not provided, the library will warn.
244
+
245
+ | Parameter | Description |
246
+ | --------- | --------------------------- |
247
+ | key | key in which data is stored |
248
+
249
+ ```javascript
250
+ ls.get('key-name');
251
+ ```
252
+
253
+ - **`remove`**
254
+
255
+ Removes the value of a key from the localStorage. If the `meta key`, which stores the list of keys, is tried to be removed even if there are other keys which were created by `secure-ls` library, the library will warn for the action.
256
+
257
+ | Parameter | Description |
258
+ | --------- | ---------------------------------- |
259
+ | key | remove key in which data is stored |
260
+
261
+ ```javascript
262
+ ls.remove('key-name');
263
+ ```
264
+
265
+ - **`removeAll`**
266
+
267
+ Removes all the keys that were created by the `secure-ls` library, even the `meta key`.
268
+
269
+ ```javascript
270
+ ls.removeAll();
271
+ ```
272
+
273
+ - **`clear`**
274
+
275
+ Removes all the keys ever created for that particular domain. Remember localStorage works differently for `http` and `https` protocol;
276
+
277
+ ```javascript
278
+ ls.clear();
279
+ ```
280
+
281
+ - **`getAllKeys`**
282
+
283
+ Gets the list of keys that were created using the `secure-ls` library. Helpful when data needs to be retrieved for all the keys or when keys name are not known(dynamically created keys).
284
+
285
+ `getAllKeys()`
286
+
287
+ ```javascript
288
+ ls.getAllKeys();
289
+ ```
290
+
291
+ ## Screenshot
292
+
293
+ <img src="screenshot.png" height="800">
294
+
295
+ ## Scripts
296
+
297
+ - `npm run build` - produces production version of the library under the `dist` folder
298
+ - `npm run build-dev` - produces development version of the library and runs a watcher
299
+ - `npm run test` - well ... it runs the tests :)
300
+
301
+ ## Contributing
302
+
303
+ 1. Fork the repo on GitHub.
304
+ 2. Clone the repo on machine.
305
+ 3. Execute `npm install` and `npm run dev`.
306
+ 4. Create a new branch `<fix-typo>` and do your work.
307
+ 5. Run `npm run build` to build dist files and `npm run test` to ensure all test cases are passing.
308
+ 6. Commit your changes to the branch.
309
+ 7. Submit a Pull request.
310
+
311
+ ## Development Stack
312
+
313
+ - Webpack based `src` compilation & bundling and `dist` generation.
314
+ - ES6 as a source of writing code.
315
+ - Exports in a [umd](https://github.com/umdjs/umd) format so the library works everywhere.
316
+ - ES6 test setup with [Jest](https://jestjs.io/)
317
+ - Linting with [ESLint](http://eslint.org/).
318
+
319
+ ## Process
320
+
321
+ ```
322
+ ES6 source files
323
+ |
324
+ |
325
+ webpack
326
+ |
327
+ +--- babel, eslint
328
+ |
329
+ ready to use
330
+ library
331
+ in umd format
332
+ ```
333
+
334
+ ## Credits
335
+
336
+ Many thanks to:
337
+
338
+ - [@brix](https://github.com/brix) for the awesome **[crypto-js](https://github.com/brix/crypto-js)** library for encrypting and decrypting data securely.
339
+
340
+ - [@pieroxy](https://github.com/pieroxy) for the **[lz-string](https://github.com/pieroxy/lz-string)** js library for data compression / decompression.
341
+
342
+ ## Copyright and license
343
+
344
+ > The [MIT license](https://opensource.org/licenses/MIT) (MIT)
345
+ >
346
+ > Copyright (c) 2015-2024 Varun Malhotra
347
+ >
348
+ > Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
349
+ >
350
+ > The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
351
+ >
352
+ > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.