secure-ls2 2.1.6 → 2.1.8

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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * secure-ls2 - v2.1.6
2
+ * secure-ls2 - v2.1.8
3
3
  * URL - https://github.com/softvar/secure-ls
4
4
  *
5
5
  * The MIT License (MIT)
@@ -46,280 +46,865 @@
46
46
  return /******/ (() => { // webpackBootstrap
47
47
  /******/ var __webpack_modules__ = ({
48
48
 
49
- /***/ "./node_modules/crypto-js/aes.js"
50
- /*!***************************************!*\
51
- !*** ./node_modules/crypto-js/aes.js ***!
52
- \***************************************/
53
- (module, exports, __webpack_require__) {
54
-
55
- ;(function (root, factory, undef) {
56
- if (true) {
57
- // CommonJS
58
- module.exports = exports = factory(__webpack_require__(/*! ./core */ "./node_modules/crypto-js/core.js"), __webpack_require__(/*! ./enc-base64 */ "./node_modules/crypto-js/enc-base64.js"), __webpack_require__(/*! ./md5 */ "./node_modules/crypto-js/md5.js"), __webpack_require__(/*! ./evpkdf */ "./node_modules/crypto-js/evpkdf.js"), __webpack_require__(/*! ./cipher-core */ "./node_modules/crypto-js/cipher-core.js"));
59
- }
60
- else // removed by dead control flow
61
- {}
62
- }(this, function (CryptoJS) {
49
+ /***/ "./src/Base64.js"
50
+ /*!***********************!*\
51
+ !*** ./src/Base64.js ***!
52
+ \***********************/
53
+ (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
63
54
 
64
- (function () {
65
- // Shortcuts
66
- var C = CryptoJS;
67
- var C_lib = C.lib;
68
- var BlockCipher = C_lib.BlockCipher;
69
- var C_algo = C.algo;
55
+ "use strict";
56
+ __webpack_require__.r(__webpack_exports__);
57
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
58
+ /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
59
+ /* harmony export */ });
60
+ const Base64 = {
61
+ _keyStr: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',
62
+ encode: function (e) {
63
+ let t = '';
64
+ let n, r, i, s, o, u, a;
65
+ let f = 0;
66
+ e = Base64._utf8Encode(e);
67
+ while (f < e.length) {
68
+ n = e.charCodeAt(f++);
69
+ r = e.charCodeAt(f++);
70
+ i = e.charCodeAt(f++);
71
+ s = n >> 2;
72
+ o = (n & 3) << 4 | r >> 4;
73
+ u = (r & 15) << 2 | i >> 6;
74
+ a = i & 63;
75
+ if (isNaN(r)) {
76
+ u = a = 64;
77
+ } else if (isNaN(i)) {
78
+ a = 64;
79
+ }
80
+ t = t + this._keyStr.charAt(s) + this._keyStr.charAt(o) + this._keyStr.charAt(u) + this._keyStr.charAt(a);
81
+ }
82
+ return t;
83
+ },
84
+ decode: function (e) {
85
+ let t = '';
86
+ let n, r, i;
87
+ let s, o, u, a;
88
+ let f = 0;
89
+ e = e.replace(/[^A-Za-z0-9+/=]/g, '');
90
+ while (f < e.length) {
91
+ s = this._keyStr.indexOf(e.charAt(f++));
92
+ o = this._keyStr.indexOf(e.charAt(f++));
93
+ u = this._keyStr.indexOf(e.charAt(f++));
94
+ a = this._keyStr.indexOf(e.charAt(f++));
95
+ n = s << 2 | o >> 4;
96
+ r = (o & 15) << 4 | u >> 2;
97
+ i = (u & 3) << 6 | a;
98
+ t = t + String.fromCharCode(n);
99
+ if (u !== 64) {
100
+ t = t + String.fromCharCode(r);
101
+ }
102
+ if (a !== 64) {
103
+ t = t + String.fromCharCode(i);
104
+ }
105
+ }
106
+ t = Base64._utf8Decode(t);
107
+ return t;
108
+ },
109
+ _utf8Encode: function (e) {
110
+ e = e.replace(/\r\n/g, '\n');
111
+ let t = '';
112
+ for (let n = 0; n < e.length; n++) {
113
+ let r = e.charCodeAt(n);
114
+ if (r < 128) {
115
+ t += String.fromCharCode(r);
116
+ } else if (r > 127 && r < 2048) {
117
+ t += String.fromCharCode(r >> 6 | 192);
118
+ t += String.fromCharCode(r & 63 | 128);
119
+ } else {
120
+ t += String.fromCharCode(r >> 12 | 224);
121
+ t += String.fromCharCode(r >> 6 & 63 | 128);
122
+ t += String.fromCharCode(r & 63 | 128);
123
+ }
124
+ }
125
+ return t;
126
+ },
127
+ _utf8Decode: function (e) {
128
+ let t = '';
129
+ let n = 0;
130
+ let r, c2, c3;
70
131
 
71
- // Lookup tables
72
- var SBOX = [];
73
- var INV_SBOX = [];
74
- var SUB_MIX_0 = [];
75
- var SUB_MIX_1 = [];
76
- var SUB_MIX_2 = [];
77
- var SUB_MIX_3 = [];
78
- var INV_SUB_MIX_0 = [];
79
- var INV_SUB_MIX_1 = [];
80
- var INV_SUB_MIX_2 = [];
81
- var INV_SUB_MIX_3 = [];
132
+ // r = c2 = 0;
133
+ while (n < e.length) {
134
+ r = e.charCodeAt(n);
135
+ if (r < 128) {
136
+ t += String.fromCharCode(r);
137
+ n++;
138
+ } else if (r > 191 && r < 224) {
139
+ c2 = e.charCodeAt(n + 1);
140
+ t += String.fromCharCode((r & 31) << 6 | c2 & 63);
141
+ n += 2;
142
+ } else {
143
+ c2 = e.charCodeAt(n + 1);
144
+ c3 = e.charCodeAt(n + 2);
145
+ t += String.fromCharCode((r & 15) << 12 | (c2 & 63) << 6 | c3 & 63);
146
+ n += 3;
147
+ }
148
+ }
149
+ return t;
150
+ }
151
+ };
152
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Base64);
82
153
 
83
- // Compute lookup tables
84
- (function () {
85
- // Compute double table
86
- var d = [];
87
- for (var i = 0; i < 256; i++) {
88
- if (i < 128) {
89
- d[i] = i << 1;
90
- } else {
91
- d[i] = (i << 1) ^ 0x11b;
92
- }
93
- }
154
+ /***/ },
94
155
 
95
- // Walk GF(2^8)
96
- var x = 0;
97
- var xi = 0;
98
- for (var i = 0; i < 256; i++) {
99
- // Compute sbox
100
- var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4);
101
- sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63;
102
- SBOX[x] = sx;
103
- INV_SBOX[sx] = x;
156
+ /***/ "./src/SecureLS.js"
157
+ /*!*************************!*\
158
+ !*** ./src/SecureLS.js ***!
159
+ \*************************/
160
+ (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
104
161
 
105
- // Compute multiplication
106
- var x2 = d[x];
107
- var x4 = d[x2];
108
- var x8 = d[x4];
162
+ "use strict";
163
+ __webpack_require__.r(__webpack_exports__);
164
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
165
+ /* harmony export */ SecureLS: () => (/* binding */ SecureLS)
166
+ /* harmony export */ });
167
+ /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants */ "./src/constants.js");
168
+ /* harmony import */ var _enc_utf8__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./enc-utf8 */ "./src/enc-utf8.js");
169
+ /* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./utils */ "./src/utils.js");
170
+ /* harmony import */ var crypto_js_aes__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! crypto-js/aes */ "./node_modules/crypto-js/aes.js");
171
+ /* harmony import */ var crypto_js_aes__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(crypto_js_aes__WEBPACK_IMPORTED_MODULE_3__);
172
+ /* harmony import */ var crypto_js_rabbit__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! crypto-js/rabbit */ "./node_modules/crypto-js/rabbit.js");
173
+ /* harmony import */ var crypto_js_rabbit__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(crypto_js_rabbit__WEBPACK_IMPORTED_MODULE_4__);
174
+ /* harmony import */ var crypto_js_rc4__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! crypto-js/rc4 */ "./node_modules/crypto-js/rc4.js");
175
+ /* harmony import */ var crypto_js_rc4__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(crypto_js_rc4__WEBPACK_IMPORTED_MODULE_5__);
176
+ /* harmony import */ var crypto_js_tripledes__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! crypto-js/tripledes */ "./node_modules/crypto-js/tripledes.js");
177
+ /* harmony import */ var crypto_js_tripledes__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(crypto_js_tripledes__WEBPACK_IMPORTED_MODULE_6__);
178
+ /* harmony import */ var lz_string_libs_lz_string__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! lz-string/libs/lz-string */ "./node_modules/lz-string/libs/lz-string.js");
179
+ /* harmony import */ var lz_string_libs_lz_string__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(lz_string_libs_lz_string__WEBPACK_IMPORTED_MODULE_7__);
180
+ /* harmony import */ var _Base64__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Base64 */ "./src/Base64.js");
109
181
 
110
- // Compute sub bytes, mix columns tables
111
- var t = (d[sx] * 0x101) ^ (sx * 0x1010100);
112
- SUB_MIX_0[x] = (t << 24) | (t >>> 8);
113
- SUB_MIX_1[x] = (t << 16) | (t >>> 16);
114
- SUB_MIX_2[x] = (t << 8) | (t >>> 24);
115
- SUB_MIX_3[x] = t;
116
182
 
117
- // Compute inv sub bytes, inv mix columns tables
118
- var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100);
119
- INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8);
120
- INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16);
121
- INV_SUB_MIX_2[sx] = (t << 8) | (t >>> 24);
122
- INV_SUB_MIX_3[sx] = t;
123
183
 
124
- // Compute next counter
125
- if (!x) {
126
- x = xi = 1;
127
- } else {
128
- x = x2 ^ d[d[d[x8 ^ x2]]];
129
- xi ^= d[d[xi]];
130
- }
131
- }
132
- }());
133
184
 
134
- // Precomputed Rcon lookup
135
- var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36];
136
185
 
137
- /**
138
- * AES block cipher algorithm.
139
- */
140
- var AES = C_algo.AES = BlockCipher.extend({
141
- _doReset: function () {
142
- var t;
143
186
 
144
- // Skip reset of nRounds has been set before and key did not change
145
- if (this._nRounds && this._keyPriorReset === this._key) {
146
- return;
147
- }
148
187
 
149
- // Shortcuts
150
- var key = this._keyPriorReset = this._key;
151
- var keyWords = key.words;
152
- var keySize = key.sigBytes / 4;
153
188
 
154
- // Compute number of rounds
155
- var nRounds = this._nRounds = keySize + 6;
156
189
 
157
- // Compute number of key schedule rows
158
- var ksRows = (nRounds + 1) * 4;
190
+ const encryptors = {
191
+ [_constants__WEBPACK_IMPORTED_MODULE_0__["default"].EncrytionTypes.AES]: (crypto_js_aes__WEBPACK_IMPORTED_MODULE_3___default()),
192
+ [_constants__WEBPACK_IMPORTED_MODULE_0__["default"].EncrytionTypes.DES]: (crypto_js_tripledes__WEBPACK_IMPORTED_MODULE_6___default()),
193
+ [_constants__WEBPACK_IMPORTED_MODULE_0__["default"].EncrytionTypes.RABBIT]: (crypto_js_rabbit__WEBPACK_IMPORTED_MODULE_4___default()),
194
+ [_constants__WEBPACK_IMPORTED_MODULE_0__["default"].EncrytionTypes.RC4]: (crypto_js_rc4__WEBPACK_IMPORTED_MODULE_5___default())
195
+ };
196
+ class SecureLS {
197
+ constructor({
198
+ encryptionSecret = '',
199
+ encryptionNamespace = '',
200
+ isCompression = true,
201
+ encodingType = _constants__WEBPACK_IMPORTED_MODULE_0__["default"].EncrytionTypes.BASE64,
202
+ storage = localStorage,
203
+ metaKey = _constants__WEBPACK_IMPORTED_MODULE_0__["default"].metaKey
204
+ } = {}) {
205
+ // Assign libraries and utilities
206
+ Object.assign(this, {
207
+ _name: 'secure-ls',
208
+ Base64: _Base64__WEBPACK_IMPORTED_MODULE_8__["default"],
209
+ LZString: {
210
+ compressToUTF16: lz_string_libs_lz_string__WEBPACK_IMPORTED_MODULE_7__.compressToUTF16,
211
+ decompressFromUTF16: lz_string_libs_lz_string__WEBPACK_IMPORTED_MODULE_7__.decompressFromUTF16
212
+ },
213
+ AES: (crypto_js_aes__WEBPACK_IMPORTED_MODULE_3___default()),
214
+ DES: (crypto_js_tripledes__WEBPACK_IMPORTED_MODULE_6___default()),
215
+ RABBIT: (crypto_js_rabbit__WEBPACK_IMPORTED_MODULE_4___default()),
216
+ RC4: (crypto_js_rc4__WEBPACK_IMPORTED_MODULE_5___default()),
217
+ enc: _enc_utf8__WEBPACK_IMPORTED_MODULE_1__["default"]
218
+ });
159
219
 
160
- // Compute key schedule
161
- var keySchedule = this._keySchedule = [];
162
- for (var ksRow = 0; ksRow < ksRows; ksRow++) {
163
- if (ksRow < keySize) {
164
- keySchedule[ksRow] = keyWords[ksRow];
165
- } else {
166
- t = keySchedule[ksRow - 1];
167
-
168
- if (!(ksRow % keySize)) {
169
- // Rot word
170
- t = (t << 8) | (t >>> 24);
220
+ // Configuration and property assignment
221
+ this.config = {
222
+ encryptionSecret,
223
+ encryptionNamespace,
224
+ isCompression,
225
+ encodingType: encodingType.toLowerCase(),
226
+ storage,
227
+ metaKey
228
+ };
229
+ this.encryptionSecret = encryptionSecret;
230
+ this.storage = storage;
231
+ this.metaKey = metaKey;
171
232
 
172
- // Sub word
173
- t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
233
+ // Initialize the class
234
+ this.init();
235
+ }
236
+ init() {
237
+ let metaData = this.getMetaData();
238
+ this._isBase64 = this._isBase64EncryptionType();
239
+ this._isAES = this._isAESEncryptionType();
240
+ this._isDES = this._isDESEncryptionType();
241
+ this._isRabbit = this._isRabbitEncryptionType();
242
+ this._isRC4 = this._isRC4EncryptionType();
243
+ this._isCompression = this._isDataCompressionEnabled();
174
244
 
175
- // Mix Rcon
176
- t ^= RCON[(ksRow / keySize) | 0] << 24;
177
- } else if (keySize > 6 && ksRow % keySize == 4) {
178
- // Sub word
179
- t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
180
- }
245
+ // fill the already present keys to the list of keys being used by secure-ls
246
+ this.allKeys = metaData.keys || this.resetAllKeys();
247
+ }
248
+ _isBase64EncryptionType() {
249
+ return _Base64__WEBPACK_IMPORTED_MODULE_8__["default"] && (typeof this.config.encodingType === 'undefined' || this.config.encodingType === _constants__WEBPACK_IMPORTED_MODULE_0__["default"].EncrytionTypes.BASE64);
250
+ }
251
+ _isAESEncryptionType() {
252
+ return (crypto_js_aes__WEBPACK_IMPORTED_MODULE_3___default()) && this.config.encodingType === _constants__WEBPACK_IMPORTED_MODULE_0__["default"].EncrytionTypes.AES;
253
+ }
254
+ _isDESEncryptionType() {
255
+ return (crypto_js_tripledes__WEBPACK_IMPORTED_MODULE_6___default()) && this.config.encodingType === _constants__WEBPACK_IMPORTED_MODULE_0__["default"].EncrytionTypes.DES;
256
+ }
257
+ _isRabbitEncryptionType() {
258
+ return (crypto_js_rabbit__WEBPACK_IMPORTED_MODULE_4___default()) && this.config.encodingType === _constants__WEBPACK_IMPORTED_MODULE_0__["default"].EncrytionTypes.RABBIT;
259
+ }
260
+ _isRC4EncryptionType() {
261
+ return (crypto_js_rc4__WEBPACK_IMPORTED_MODULE_5___default()) && this.config.encodingType === _constants__WEBPACK_IMPORTED_MODULE_0__["default"].EncrytionTypes.RC4;
262
+ }
263
+ _isDataCompressionEnabled() {
264
+ return this.config.isCompression;
265
+ }
266
+ getEncryptionSecret(key) {
267
+ let metaData = this.getMetaData();
268
+ let obj = _utils__WEBPACK_IMPORTED_MODULE_2__["default"].getObjectFromKey(metaData.keys, key);
269
+ if (!obj) {
270
+ return;
271
+ }
272
+ if (this._isAES || this._isDES || this._isRabbit || this._isRC4) {
273
+ if (typeof this.config.encryptionSecret === 'undefined') {
274
+ this.encryptionSecret = obj.s;
275
+ if (!this.encryptionSecret) {
276
+ this.encryptionSecret = _utils__WEBPACK_IMPORTED_MODULE_2__["default"].generateSecretKey();
277
+ this.setMetaData();
278
+ }
279
+ } else {
280
+ this.encryptionSecret = this.config.encryptionSecret || obj.s || '';
281
+ }
282
+ }
283
+ }
284
+ getEncryptionType() {
285
+ const encodingType = this.config.encodingType;
286
+ return encodingType ? encodingType.toLowerCase() : _constants__WEBPACK_IMPORTED_MODULE_0__["default"].EncrytionTypes.BASE64;
287
+ }
288
+ getDataFromLocalStorage(key) {
289
+ return this.storage.getItem(key, true);
290
+ }
291
+ setDataToLocalStorage(key, data) {
292
+ this.storage.setItem(key, data);
293
+ }
294
+ setMetaData() {
295
+ let dataToStore = this.processData({
296
+ keys: this.allKeys
297
+ }, true);
181
298
 
182
- keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t;
183
- }
184
- }
299
+ // Store the data to localStorage
300
+ this.setDataToLocalStorage(this.getMetaKey(), dataToStore);
301
+ }
302
+ getMetaData() {
303
+ return this.get(this.getMetaKey(), true) || {};
304
+ }
305
+ getMetaKey() {
306
+ return this.metaKey + (this.config.encryptionNamespace ? '__' + this.config.encryptionNamespace : '');
307
+ }
308
+ resetAllKeys() {
309
+ this.allKeys = [];
310
+ return [];
311
+ }
312
+ processData(data, isAllKeysData) {
313
+ if (data === null || data === undefined || data === '') {
314
+ return '';
315
+ }
316
+ let jsonData;
317
+ try {
318
+ jsonData = JSON.stringify(data);
319
+ } catch (err) {
320
+ throw new Error('Could not stringify data', err);
321
+ }
185
322
 
186
- // Compute inv key schedule
187
- var invKeySchedule = this._invKeySchedule = [];
188
- for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) {
189
- var ksRow = ksRows - invKsRow;
323
+ // Encode Based on encoding type
324
+ // If not set, default to Base64 for securing data
325
+ let encodedData = jsonData;
326
+ if (this._isBase64 || isAllKeysData) {
327
+ encodedData = _Base64__WEBPACK_IMPORTED_MODULE_8__["default"].encode(jsonData);
328
+ } else {
329
+ const encryptor = encryptors[this.getEncryptionType()];
330
+ if (encryptor) {
331
+ encodedData = encryptor.encrypt(jsonData, this.encryptionSecret);
332
+ }
333
+ encodedData = encodedData && encodedData.toString();
334
+ }
190
335
 
191
- if (invKsRow % 4) {
192
- var t = keySchedule[ksRow];
193
- } else {
194
- var t = keySchedule[ksRow - 4];
195
- }
336
+ // Compress data if set to true
337
+ let compressedData = encodedData;
338
+ if (this._isCompression || isAllKeysData) {
339
+ compressedData = this.LZString.compressToUTF16(encodedData);
340
+ }
341
+ return compressedData;
342
+ }
196
343
 
197
- if (invKsRow < 4 || ksRow <= 4) {
198
- invKeySchedule[invKsRow] = t;
199
- } else {
200
- invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^
201
- INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]];
202
- }
203
- }
204
- },
344
+ // PUBLIC APIs
345
+ getAllKeys() {
346
+ let data = this.getMetaData();
347
+ return _utils__WEBPACK_IMPORTED_MODULE_2__["default"].extractKeyNames(data) || [];
348
+ }
349
+ get(key, isAllKeysData) {
350
+ let decodedData;
351
+ let jsonData = '';
352
+ if (!_utils__WEBPACK_IMPORTED_MODULE_2__["default"].is(key)) {
353
+ _utils__WEBPACK_IMPORTED_MODULE_2__["default"].warn(_constants__WEBPACK_IMPORTED_MODULE_0__["default"].WarningEnum.KEY_NOT_PROVIDED);
354
+ return jsonData;
355
+ }
356
+ let data = this.getDataFromLocalStorage(key);
357
+ if (!data) {
358
+ return jsonData;
359
+ }
360
+ let deCompressedData = data; // saves else
361
+ if (this._isCompression || isAllKeysData) {
362
+ // meta data always compressed
363
+ deCompressedData = this.LZString.decompressFromUTF16(data);
364
+ }
365
+ decodedData = deCompressedData; // saves else
366
+ if (this._isBase64 || isAllKeysData) {
367
+ // meta data always Base64
368
+ decodedData = _Base64__WEBPACK_IMPORTED_MODULE_8__["default"].decode(deCompressedData);
369
+ } else {
370
+ this.getEncryptionSecret(key);
371
+ const encryptor = encryptors[this.getEncryptionType()];
372
+ if (encryptor) {
373
+ const bytes = encryptor.decrypt(deCompressedData.toString(), this.encryptionSecret);
374
+ if (bytes) {
375
+ decodedData = bytes.toString(_enc_utf8__WEBPACK_IMPORTED_MODULE_1__["default"]._Utf8);
376
+ }
377
+ }
378
+ }
379
+ try {
380
+ jsonData = JSON.parse(decodedData);
381
+ } catch (err) {
382
+ throw new Error('Could not parse JSON', err);
383
+ }
384
+ return jsonData;
385
+ }
386
+ set(key, data) {
387
+ let dataToStore;
388
+ if (!_utils__WEBPACK_IMPORTED_MODULE_2__["default"].is(key)) {
389
+ _utils__WEBPACK_IMPORTED_MODULE_2__["default"].warn(_constants__WEBPACK_IMPORTED_MODULE_0__["default"].WarningEnum.KEY_NOT_PROVIDED);
390
+ return;
391
+ }
392
+ this.getEncryptionSecret(key);
205
393
 
206
- encryptBlock: function (M, offset) {
207
- this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX);
208
- },
394
+ // add key(s) to Array if not already added, only for keys other than meta key
395
+ if (!(String(key) === String(this.metaKey))) {
396
+ if (!_utils__WEBPACK_IMPORTED_MODULE_2__["default"].isKeyPresent(this.allKeys, key)) {
397
+ this.allKeys.push({
398
+ k: key,
399
+ s: this.encryptionSecret
400
+ });
401
+ this.setMetaData();
402
+ }
403
+ }
404
+ dataToStore = this.processData(data);
405
+ // Store the data to localStorage
406
+ this.setDataToLocalStorage(key, dataToStore);
407
+ }
408
+ remove(key) {
409
+ if (!_utils__WEBPACK_IMPORTED_MODULE_2__["default"].is(key)) {
410
+ _utils__WEBPACK_IMPORTED_MODULE_2__["default"].warn(_constants__WEBPACK_IMPORTED_MODULE_0__["default"].WarningEnum.KEY_NOT_PROVIDED);
411
+ return;
412
+ }
413
+ if (key === this.metaKey && this.getAllKeys().length) {
414
+ _utils__WEBPACK_IMPORTED_MODULE_2__["default"].warn(_constants__WEBPACK_IMPORTED_MODULE_0__["default"].WarningEnum.META_KEY_REMOVE);
415
+ return;
416
+ }
417
+ if (_utils__WEBPACK_IMPORTED_MODULE_2__["default"].isKeyPresent(this.allKeys, key)) {
418
+ _utils__WEBPACK_IMPORTED_MODULE_2__["default"].removeFromKeysList(this.allKeys, key);
419
+ this.setMetaData();
420
+ }
421
+ this.storage.removeItem(key);
422
+ }
423
+ removeAll() {
424
+ let keys = this.getAllKeys();
425
+ for (let i = 0; i < keys.length; i++) {
426
+ this.storage.removeItem(keys[i]);
427
+ }
428
+ this.storage.removeItem(this.metaKey);
429
+ this.resetAllKeys();
430
+ }
431
+ clear() {
432
+ this.storage.clear();
433
+ this.resetAllKeys();
434
+ }
435
+ }
209
436
 
210
- decryptBlock: function (M, offset) {
211
- // Swap 2nd and 4th rows
212
- var t = M[offset + 1];
213
- M[offset + 1] = M[offset + 3];
214
- M[offset + 3] = t;
437
+ /***/ },
215
438
 
216
- this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX);
439
+ /***/ "./src/WordArray.js"
440
+ /*!**************************!*\
441
+ !*** ./src/WordArray.js ***!
442
+ \**************************/
443
+ (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
217
444
 
218
- // Inv swap 2nd and 4th rows
219
- var t = M[offset + 1];
220
- M[offset + 1] = M[offset + 3];
221
- M[offset + 3] = t;
222
- },
445
+ "use strict";
446
+ __webpack_require__.r(__webpack_exports__);
447
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
448
+ /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
449
+ /* harmony export */ });
450
+ /*
451
+ ES6 compatible port of CryptoJS - WordArray for PBKDF2 password key generation
223
452
 
224
- _doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) {
225
- // Shortcut
226
- var nRounds = this._nRounds;
453
+ Source: https://github.com/brix/crypto-js
454
+ LICENSE: MIT
455
+ */
227
456
 
228
- // Get input, add round key
229
- var s0 = M[offset] ^ keySchedule[0];
230
- var s1 = M[offset + 1] ^ keySchedule[1];
231
- var s2 = M[offset + 2] ^ keySchedule[2];
232
- var s3 = M[offset + 3] ^ keySchedule[3];
457
+ let CryptoJSWordArray = {
458
+ random: function (nBytes) {
459
+ let words = [];
460
+ let r = function (mw) {
461
+ let mz = 0x3ade68b1;
462
+ let mask = 0xffffffff;
463
+ return function () {
464
+ mz = 0x9069 * (mz & 0xffff) + (mz >> 0x10) & mask;
465
+ mw = 0x4650 * (mw & 0xffff) + (mw >> 0x10) & mask;
466
+ let result = (mz << 0x10) + mw & mask;
467
+ result /= 0x100000000;
468
+ result += 0.5;
469
+ return result * (Math.random() > 0.5 ? 1 : -1);
470
+ };
471
+ };
472
+ for (let i = 0, rcache; i < nBytes; i += 4) {
473
+ let _r = r((rcache || Math.random()) * 0x100000000);
474
+ rcache = _r() * 0x3ade67b7;
475
+ words.push(_r() * 0x100000000 | 0);
476
+ }
477
+ return new CryptoJSWordArray.Set(words, nBytes);
478
+ },
479
+ Set: function (words, sigBytes) {
480
+ words = this.words = words || [];
481
+ if (sigBytes !== undefined) {
482
+ this.sigBytes = sigBytes;
483
+ } else {
484
+ this.sigBytes = words.length * 8;
485
+ }
486
+ }
487
+ };
488
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (CryptoJSWordArray);
233
489
 
234
- // Key schedule row counter
235
- var ksRow = 4;
490
+ /***/ },
236
491
 
237
- // Rounds
238
- for (var round = 1; round < nRounds; round++) {
239
- // Shift rows, sub bytes, mix columns, add round key
240
- var t0 = SUB_MIX_0[s0 >>> 24] ^ SUB_MIX_1[(s1 >>> 16) & 0xff] ^ SUB_MIX_2[(s2 >>> 8) & 0xff] ^ SUB_MIX_3[s3 & 0xff] ^ keySchedule[ksRow++];
241
- var t1 = SUB_MIX_0[s1 >>> 24] ^ SUB_MIX_1[(s2 >>> 16) & 0xff] ^ SUB_MIX_2[(s3 >>> 8) & 0xff] ^ SUB_MIX_3[s0 & 0xff] ^ keySchedule[ksRow++];
242
- var t2 = SUB_MIX_0[s2 >>> 24] ^ SUB_MIX_1[(s3 >>> 16) & 0xff] ^ SUB_MIX_2[(s0 >>> 8) & 0xff] ^ SUB_MIX_3[s1 & 0xff] ^ keySchedule[ksRow++];
243
- var t3 = SUB_MIX_0[s3 >>> 24] ^ SUB_MIX_1[(s0 >>> 16) & 0xff] ^ SUB_MIX_2[(s1 >>> 8) & 0xff] ^ SUB_MIX_3[s2 & 0xff] ^ keySchedule[ksRow++];
492
+ /***/ "./src/constants.js"
493
+ /*!**************************!*\
494
+ !*** ./src/constants.js ***!
495
+ \**************************/
496
+ (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
244
497
 
245
- // Update state
246
- s0 = t0;
247
- s1 = t1;
248
- s2 = t2;
249
- s3 = t3;
250
- }
498
+ "use strict";
499
+ __webpack_require__.r(__webpack_exports__);
500
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
501
+ /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
502
+ /* harmony export */ });
503
+ const WarningEnum = {
504
+ KEY_NOT_PROVIDED: 'keyNotProvided',
505
+ META_KEY_REMOVE: 'metaKeyRemove',
506
+ DEFAULT_TEXT: 'defaultText'
507
+ };
508
+ const WarningTypes = {};
509
+ WarningTypes[WarningEnum.KEY_NOT_PROVIDED] = 'Secure LS: Key not provided. Aborting operation!';
510
+ WarningTypes[WarningEnum.META_KEY_REMOVE] = `Secure LS: Meta key can not be removed
511
+ unless all keys created by Secure LS are removed!`;
512
+ WarningTypes[WarningEnum.DEFAULT_TEXT] = `Unexpected output`;
513
+ const constants = {
514
+ WarningEnum: WarningEnum,
515
+ WarningTypes: WarningTypes,
516
+ EncrytionTypes: {
517
+ BASE64: 'base64',
518
+ AES: 'aes',
519
+ DES: 'des',
520
+ RABBIT: 'rabbit',
521
+ RC4: 'rc4'
522
+ },
523
+ metaKey: '_secure__ls__metadata',
524
+ secretPhrase: 's3cr3t$#@135^&*246'
525
+ };
526
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (constants);
251
527
 
252
- // Shift rows, sub bytes, add round key
253
- var t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++];
254
- var t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++];
255
- var t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++];
256
- var t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++];
528
+ /***/ },
257
529
 
258
- // Set output
259
- M[offset] = t0;
260
- M[offset + 1] = t1;
261
- M[offset + 2] = t2;
262
- M[offset + 3] = t3;
263
- },
530
+ /***/ "./src/enc-utf8.js"
531
+ /*!*************************!*\
532
+ !*** ./src/enc-utf8.js ***!
533
+ \*************************/
534
+ (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
264
535
 
265
- keySize: 256/32
266
- });
536
+ "use strict";
537
+ __webpack_require__.r(__webpack_exports__);
538
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
539
+ /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
540
+ /* harmony export */ });
541
+ /*
542
+ ES6 compatible port of CryptoJS - encoding
267
543
 
268
- /**
269
- * Shortcut functions to the cipher's object interface.
270
- *
271
- * @example
272
- *
273
- * var ciphertext = CryptoJS.AES.encrypt(message, key, cfg);
274
- * var plaintext = CryptoJS.AES.decrypt(ciphertext, key, cfg);
275
- */
276
- C.AES = BlockCipher._createHelper(AES);
277
- }());
544
+ Source: https://github.com/brix/crypto-js
545
+ LICENSE: MIT
546
+ */
547
+ const enc = {
548
+ Latin1: {
549
+ stringify: wordArray => {
550
+ // Shortcuts
551
+ let words = wordArray.words;
552
+ let sigBytes = wordArray.sigBytes;
553
+ let latin1Chars = [],
554
+ i,
555
+ bite;
556
+
557
+ // Convert
558
+ for (i = 0; i < sigBytes; i++) {
559
+ bite = words[i >>> 2] >>> 24 - i % 4 * 8 & 0xff;
560
+ latin1Chars.push(String.fromCharCode(bite));
561
+ }
562
+ return latin1Chars.join('');
563
+ }
564
+ },
565
+ _Utf8: {
566
+ stringify: wordArray => {
567
+ try {
568
+ return decodeURIComponent(escape(enc.Latin1.stringify(wordArray)));
569
+ } catch (err) {
570
+ throw new Error('Malformed UTF-8 data', err);
571
+ }
572
+ }
573
+ }
574
+ };
575
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (enc);
278
576
 
577
+ /***/ },
578
+
579
+ /***/ "./src/utils.js"
580
+ /*!**********************!*\
581
+ !*** ./src/utils.js ***!
582
+ \**********************/
583
+ (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
584
+
585
+ "use strict";
586
+ __webpack_require__.r(__webpack_exports__);
587
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
588
+ /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
589
+ /* harmony export */ });
590
+ /* harmony import */ var crypto_js_pbkdf2__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! crypto-js/pbkdf2 */ "./node_modules/crypto-js/pbkdf2.js");
591
+ /* harmony import */ var crypto_js_pbkdf2__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(crypto_js_pbkdf2__WEBPACK_IMPORTED_MODULE_0__);
592
+ /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./constants */ "./src/constants.js");
593
+ /* harmony import */ var _WordArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./WordArray */ "./src/WordArray.js");
279
594
 
280
- return CryptoJS.AES;
281
595
 
282
- }));
596
+
597
+ const utils = {
598
+ is: key => !!key,
599
+ warn: (reason = _constants__WEBPACK_IMPORTED_MODULE_1__["default"].WarningEnum.DEFAULT_TEXT) => {
600
+ console.warn(_constants__WEBPACK_IMPORTED_MODULE_1__["default"].WarningTypes[reason]);
601
+ },
602
+ generateSecretKey: () => {
603
+ const salt = _WordArray__WEBPACK_IMPORTED_MODULE_2__["default"].random(128 / 8);
604
+ const key128Bits = crypto_js_pbkdf2__WEBPACK_IMPORTED_MODULE_0___default()(_constants__WEBPACK_IMPORTED_MODULE_1__["default"].secretPhrase, salt, {
605
+ keySize: 128 / 32
606
+ });
607
+ return key128Bits.toString();
608
+ },
609
+ getObjectFromKey: (data = [], key) => {
610
+ return data.find(item => item.k === key) || {};
611
+ },
612
+ extractKeyNames: ({
613
+ keys = []
614
+ } = {}) => {
615
+ return keys.map(({
616
+ k
617
+ }) => k);
618
+ },
619
+ isKeyPresent: (allKeys = [], key) => {
620
+ return allKeys.some(item => String(item.k) === String(key));
621
+ },
622
+ removeFromKeysList: (allKeys = [], key) => {
623
+ const index = allKeys.findIndex(item => item.k === key);
624
+ if (index !== -1) {
625
+ allKeys.splice(index, 1);
626
+ }
627
+ return index;
628
+ }
629
+ };
630
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (utils);
283
631
 
284
632
  /***/ },
285
633
 
286
- /***/ "./node_modules/crypto-js/cipher-core.js"
287
- /*!***********************************************!*\
288
- !*** ./node_modules/crypto-js/cipher-core.js ***!
289
- \***********************************************/
634
+ /***/ "./node_modules/crypto-js/aes.js"
635
+ /*!***************************************!*\
636
+ !*** ./node_modules/crypto-js/aes.js ***!
637
+ \***************************************/
290
638
  (module, exports, __webpack_require__) {
291
639
 
292
640
  ;(function (root, factory, undef) {
293
641
  if (true) {
294
642
  // CommonJS
295
- module.exports = exports = factory(__webpack_require__(/*! ./core */ "./node_modules/crypto-js/core.js"), __webpack_require__(/*! ./evpkdf */ "./node_modules/crypto-js/evpkdf.js"));
643
+ module.exports = exports = factory(__webpack_require__(/*! ./core */ "./node_modules/crypto-js/core.js"), __webpack_require__(/*! ./enc-base64 */ "./node_modules/crypto-js/enc-base64.js"), __webpack_require__(/*! ./md5 */ "./node_modules/crypto-js/md5.js"), __webpack_require__(/*! ./evpkdf */ "./node_modules/crypto-js/evpkdf.js"), __webpack_require__(/*! ./cipher-core */ "./node_modules/crypto-js/cipher-core.js"));
296
644
  }
297
645
  else // removed by dead control flow
298
646
  {}
299
647
  }(this, function (CryptoJS) {
300
648
 
301
- /**
302
- * Cipher core components.
303
- */
304
- CryptoJS.lib.Cipher || (function (undefined) {
649
+ (function () {
305
650
  // Shortcuts
306
651
  var C = CryptoJS;
307
652
  var C_lib = C.lib;
308
- var Base = C_lib.Base;
309
- var WordArray = C_lib.WordArray;
310
- var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm;
311
- var C_enc = C.enc;
312
- var Utf8 = C_enc.Utf8;
313
- var Base64 = C_enc.Base64;
653
+ var BlockCipher = C_lib.BlockCipher;
314
654
  var C_algo = C.algo;
315
- var EvpKDF = C_algo.EvpKDF;
316
655
 
317
- /**
318
- * Abstract base cipher template.
319
- *
320
- * @property {number} keySize This cipher's key size. Default: 4 (128 bits)
321
- * @property {number} ivSize This cipher's IV size. Default: 4 (128 bits)
322
- * @property {number} _ENC_XFORM_MODE A constant representing encryption mode.
656
+ // Lookup tables
657
+ var SBOX = [];
658
+ var INV_SBOX = [];
659
+ var SUB_MIX_0 = [];
660
+ var SUB_MIX_1 = [];
661
+ var SUB_MIX_2 = [];
662
+ var SUB_MIX_3 = [];
663
+ var INV_SUB_MIX_0 = [];
664
+ var INV_SUB_MIX_1 = [];
665
+ var INV_SUB_MIX_2 = [];
666
+ var INV_SUB_MIX_3 = [];
667
+
668
+ // Compute lookup tables
669
+ (function () {
670
+ // Compute double table
671
+ var d = [];
672
+ for (var i = 0; i < 256; i++) {
673
+ if (i < 128) {
674
+ d[i] = i << 1;
675
+ } else {
676
+ d[i] = (i << 1) ^ 0x11b;
677
+ }
678
+ }
679
+
680
+ // Walk GF(2^8)
681
+ var x = 0;
682
+ var xi = 0;
683
+ for (var i = 0; i < 256; i++) {
684
+ // Compute sbox
685
+ var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4);
686
+ sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63;
687
+ SBOX[x] = sx;
688
+ INV_SBOX[sx] = x;
689
+
690
+ // Compute multiplication
691
+ var x2 = d[x];
692
+ var x4 = d[x2];
693
+ var x8 = d[x4];
694
+
695
+ // Compute sub bytes, mix columns tables
696
+ var t = (d[sx] * 0x101) ^ (sx * 0x1010100);
697
+ SUB_MIX_0[x] = (t << 24) | (t >>> 8);
698
+ SUB_MIX_1[x] = (t << 16) | (t >>> 16);
699
+ SUB_MIX_2[x] = (t << 8) | (t >>> 24);
700
+ SUB_MIX_3[x] = t;
701
+
702
+ // Compute inv sub bytes, inv mix columns tables
703
+ var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100);
704
+ INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8);
705
+ INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16);
706
+ INV_SUB_MIX_2[sx] = (t << 8) | (t >>> 24);
707
+ INV_SUB_MIX_3[sx] = t;
708
+
709
+ // Compute next counter
710
+ if (!x) {
711
+ x = xi = 1;
712
+ } else {
713
+ x = x2 ^ d[d[d[x8 ^ x2]]];
714
+ xi ^= d[d[xi]];
715
+ }
716
+ }
717
+ }());
718
+
719
+ // Precomputed Rcon lookup
720
+ var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36];
721
+
722
+ /**
723
+ * AES block cipher algorithm.
724
+ */
725
+ var AES = C_algo.AES = BlockCipher.extend({
726
+ _doReset: function () {
727
+ var t;
728
+
729
+ // Skip reset of nRounds has been set before and key did not change
730
+ if (this._nRounds && this._keyPriorReset === this._key) {
731
+ return;
732
+ }
733
+
734
+ // Shortcuts
735
+ var key = this._keyPriorReset = this._key;
736
+ var keyWords = key.words;
737
+ var keySize = key.sigBytes / 4;
738
+
739
+ // Compute number of rounds
740
+ var nRounds = this._nRounds = keySize + 6;
741
+
742
+ // Compute number of key schedule rows
743
+ var ksRows = (nRounds + 1) * 4;
744
+
745
+ // Compute key schedule
746
+ var keySchedule = this._keySchedule = [];
747
+ for (var ksRow = 0; ksRow < ksRows; ksRow++) {
748
+ if (ksRow < keySize) {
749
+ keySchedule[ksRow] = keyWords[ksRow];
750
+ } else {
751
+ t = keySchedule[ksRow - 1];
752
+
753
+ if (!(ksRow % keySize)) {
754
+ // Rot word
755
+ t = (t << 8) | (t >>> 24);
756
+
757
+ // Sub word
758
+ t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
759
+
760
+ // Mix Rcon
761
+ t ^= RCON[(ksRow / keySize) | 0] << 24;
762
+ } else if (keySize > 6 && ksRow % keySize == 4) {
763
+ // Sub word
764
+ t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
765
+ }
766
+
767
+ keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t;
768
+ }
769
+ }
770
+
771
+ // Compute inv key schedule
772
+ var invKeySchedule = this._invKeySchedule = [];
773
+ for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) {
774
+ var ksRow = ksRows - invKsRow;
775
+
776
+ if (invKsRow % 4) {
777
+ var t = keySchedule[ksRow];
778
+ } else {
779
+ var t = keySchedule[ksRow - 4];
780
+ }
781
+
782
+ if (invKsRow < 4 || ksRow <= 4) {
783
+ invKeySchedule[invKsRow] = t;
784
+ } else {
785
+ invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^
786
+ INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]];
787
+ }
788
+ }
789
+ },
790
+
791
+ encryptBlock: function (M, offset) {
792
+ this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX);
793
+ },
794
+
795
+ decryptBlock: function (M, offset) {
796
+ // Swap 2nd and 4th rows
797
+ var t = M[offset + 1];
798
+ M[offset + 1] = M[offset + 3];
799
+ M[offset + 3] = t;
800
+
801
+ this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX);
802
+
803
+ // Inv swap 2nd and 4th rows
804
+ var t = M[offset + 1];
805
+ M[offset + 1] = M[offset + 3];
806
+ M[offset + 3] = t;
807
+ },
808
+
809
+ _doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) {
810
+ // Shortcut
811
+ var nRounds = this._nRounds;
812
+
813
+ // Get input, add round key
814
+ var s0 = M[offset] ^ keySchedule[0];
815
+ var s1 = M[offset + 1] ^ keySchedule[1];
816
+ var s2 = M[offset + 2] ^ keySchedule[2];
817
+ var s3 = M[offset + 3] ^ keySchedule[3];
818
+
819
+ // Key schedule row counter
820
+ var ksRow = 4;
821
+
822
+ // Rounds
823
+ for (var round = 1; round < nRounds; round++) {
824
+ // Shift rows, sub bytes, mix columns, add round key
825
+ var t0 = SUB_MIX_0[s0 >>> 24] ^ SUB_MIX_1[(s1 >>> 16) & 0xff] ^ SUB_MIX_2[(s2 >>> 8) & 0xff] ^ SUB_MIX_3[s3 & 0xff] ^ keySchedule[ksRow++];
826
+ var t1 = SUB_MIX_0[s1 >>> 24] ^ SUB_MIX_1[(s2 >>> 16) & 0xff] ^ SUB_MIX_2[(s3 >>> 8) & 0xff] ^ SUB_MIX_3[s0 & 0xff] ^ keySchedule[ksRow++];
827
+ var t2 = SUB_MIX_0[s2 >>> 24] ^ SUB_MIX_1[(s3 >>> 16) & 0xff] ^ SUB_MIX_2[(s0 >>> 8) & 0xff] ^ SUB_MIX_3[s1 & 0xff] ^ keySchedule[ksRow++];
828
+ var t3 = SUB_MIX_0[s3 >>> 24] ^ SUB_MIX_1[(s0 >>> 16) & 0xff] ^ SUB_MIX_2[(s1 >>> 8) & 0xff] ^ SUB_MIX_3[s2 & 0xff] ^ keySchedule[ksRow++];
829
+
830
+ // Update state
831
+ s0 = t0;
832
+ s1 = t1;
833
+ s2 = t2;
834
+ s3 = t3;
835
+ }
836
+
837
+ // Shift rows, sub bytes, add round key
838
+ var t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++];
839
+ var t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++];
840
+ var t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++];
841
+ var t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++];
842
+
843
+ // Set output
844
+ M[offset] = t0;
845
+ M[offset + 1] = t1;
846
+ M[offset + 2] = t2;
847
+ M[offset + 3] = t3;
848
+ },
849
+
850
+ keySize: 256/32
851
+ });
852
+
853
+ /**
854
+ * Shortcut functions to the cipher's object interface.
855
+ *
856
+ * @example
857
+ *
858
+ * var ciphertext = CryptoJS.AES.encrypt(message, key, cfg);
859
+ * var plaintext = CryptoJS.AES.decrypt(ciphertext, key, cfg);
860
+ */
861
+ C.AES = BlockCipher._createHelper(AES);
862
+ }());
863
+
864
+
865
+ return CryptoJS.AES;
866
+
867
+ }));
868
+
869
+ /***/ },
870
+
871
+ /***/ "./node_modules/crypto-js/cipher-core.js"
872
+ /*!***********************************************!*\
873
+ !*** ./node_modules/crypto-js/cipher-core.js ***!
874
+ \***********************************************/
875
+ (module, exports, __webpack_require__) {
876
+
877
+ ;(function (root, factory, undef) {
878
+ if (true) {
879
+ // CommonJS
880
+ module.exports = exports = factory(__webpack_require__(/*! ./core */ "./node_modules/crypto-js/core.js"), __webpack_require__(/*! ./evpkdf */ "./node_modules/crypto-js/evpkdf.js"));
881
+ }
882
+ else // removed by dead control flow
883
+ {}
884
+ }(this, function (CryptoJS) {
885
+
886
+ /**
887
+ * Cipher core components.
888
+ */
889
+ CryptoJS.lib.Cipher || (function (undefined) {
890
+ // Shortcuts
891
+ var C = CryptoJS;
892
+ var C_lib = C.lib;
893
+ var Base = C_lib.Base;
894
+ var WordArray = C_lib.WordArray;
895
+ var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm;
896
+ var C_enc = C.enc;
897
+ var Utf8 = C_enc.Utf8;
898
+ var Base64 = C_enc.Base64;
899
+ var C_algo = C.algo;
900
+ var EvpKDF = C_algo.EvpKDF;
901
+
902
+ /**
903
+ * Abstract base cipher template.
904
+ *
905
+ * @property {number} keySize This cipher's key size. Default: 4 (128 bits)
906
+ * @property {number} ivSize This cipher's IV size. Default: 4 (128 bits)
907
+ * @property {number} _ENC_XFORM_MODE A constant representing encryption mode.
323
908
  * @property {number} _DEC_XFORM_MODE A constant representing decryption mode.
324
909
  */
325
910
  var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({
@@ -4583,821 +5168,237 @@ var LZString = {
4583
5168
  }
4584
5169
  }
4585
5170
  context_enlargeIn--;
4586
- if (context_enlargeIn == 0) {
4587
- context_enlargeIn = Math.pow(2, context_numBits);
4588
- context_numBits++;
4589
- }
4590
- delete context_dictionaryToCreate[context_w];
4591
- } else {
4592
- value = context_dictionary[context_w];
4593
- for (i=0 ; i<context_numBits ; i++) {
4594
- context_data_val = (context_data_val << 1) | (value&1);
4595
- if (context_data_position == bitsPerChar-1) {
4596
- context_data_position = 0;
4597
- context_data.push(getCharFromInt(context_data_val));
4598
- context_data_val = 0;
4599
- } else {
4600
- context_data_position++;
4601
- }
4602
- value = value >> 1;
4603
- }
4604
-
4605
-
4606
- }
4607
- context_enlargeIn--;
4608
- if (context_enlargeIn == 0) {
4609
- context_enlargeIn = Math.pow(2, context_numBits);
4610
- context_numBits++;
4611
- }
4612
- }
4613
-
4614
- // Mark the end of the stream
4615
- value = 2;
4616
- for (i=0 ; i<context_numBits ; i++) {
4617
- context_data_val = (context_data_val << 1) | (value&1);
4618
- if (context_data_position == bitsPerChar-1) {
4619
- context_data_position = 0;
4620
- context_data.push(getCharFromInt(context_data_val));
4621
- context_data_val = 0;
4622
- } else {
4623
- context_data_position++;
4624
- }
4625
- value = value >> 1;
4626
- }
4627
-
4628
- // Flush the last char
4629
- while (true) {
4630
- context_data_val = (context_data_val << 1);
4631
- if (context_data_position == bitsPerChar-1) {
4632
- context_data.push(getCharFromInt(context_data_val));
4633
- break;
4634
- }
4635
- else context_data_position++;
4636
- }
4637
- return context_data.join('');
4638
- },
4639
-
4640
- decompress: function (compressed) {
4641
- if (compressed == null) return "";
4642
- if (compressed == "") return null;
4643
- return LZString._decompress(compressed.length, 32768, function(index) { return compressed.charCodeAt(index); });
4644
- },
4645
-
4646
- _decompress: function (length, resetValue, getNextValue) {
4647
- var dictionary = [],
4648
- next,
4649
- enlargeIn = 4,
4650
- dictSize = 4,
4651
- numBits = 3,
4652
- entry = "",
4653
- result = [],
4654
- i,
4655
- w,
4656
- bits, resb, maxpower, power,
4657
- c,
4658
- data = {val:getNextValue(0), position:resetValue, index:1};
4659
-
4660
- for (i = 0; i < 3; i += 1) {
4661
- dictionary[i] = i;
4662
- }
4663
-
4664
- bits = 0;
4665
- maxpower = Math.pow(2,2);
4666
- power=1;
4667
- while (power!=maxpower) {
4668
- resb = data.val & data.position;
4669
- data.position >>= 1;
4670
- if (data.position == 0) {
4671
- data.position = resetValue;
4672
- data.val = getNextValue(data.index++);
4673
- }
4674
- bits |= (resb>0 ? 1 : 0) * power;
4675
- power <<= 1;
4676
- }
4677
-
4678
- switch (next = bits) {
4679
- case 0:
4680
- bits = 0;
4681
- maxpower = Math.pow(2,8);
4682
- power=1;
4683
- while (power!=maxpower) {
4684
- resb = data.val & data.position;
4685
- data.position >>= 1;
4686
- if (data.position == 0) {
4687
- data.position = resetValue;
4688
- data.val = getNextValue(data.index++);
4689
- }
4690
- bits |= (resb>0 ? 1 : 0) * power;
4691
- power <<= 1;
4692
- }
4693
- c = f(bits);
4694
- break;
4695
- case 1:
4696
- bits = 0;
4697
- maxpower = Math.pow(2,16);
4698
- power=1;
4699
- while (power!=maxpower) {
4700
- resb = data.val & data.position;
4701
- data.position >>= 1;
4702
- if (data.position == 0) {
4703
- data.position = resetValue;
4704
- data.val = getNextValue(data.index++);
4705
- }
4706
- bits |= (resb>0 ? 1 : 0) * power;
4707
- power <<= 1;
4708
- }
4709
- c = f(bits);
4710
- break;
4711
- case 2:
4712
- return "";
4713
- }
4714
- dictionary[3] = c;
4715
- w = c;
4716
- result.push(c);
4717
- while (true) {
4718
- if (data.index > length) {
4719
- return "";
4720
- }
4721
-
4722
- bits = 0;
4723
- maxpower = Math.pow(2,numBits);
4724
- power=1;
4725
- while (power!=maxpower) {
4726
- resb = data.val & data.position;
4727
- data.position >>= 1;
4728
- if (data.position == 0) {
4729
- data.position = resetValue;
4730
- data.val = getNextValue(data.index++);
4731
- }
4732
- bits |= (resb>0 ? 1 : 0) * power;
4733
- power <<= 1;
4734
- }
4735
-
4736
- switch (c = bits) {
4737
- case 0:
4738
- bits = 0;
4739
- maxpower = Math.pow(2,8);
4740
- power=1;
4741
- while (power!=maxpower) {
4742
- resb = data.val & data.position;
4743
- data.position >>= 1;
4744
- if (data.position == 0) {
4745
- data.position = resetValue;
4746
- data.val = getNextValue(data.index++);
4747
- }
4748
- bits |= (resb>0 ? 1 : 0) * power;
4749
- power <<= 1;
4750
- }
4751
-
4752
- dictionary[dictSize++] = f(bits);
4753
- c = dictSize-1;
4754
- enlargeIn--;
4755
- break;
4756
- case 1:
4757
- bits = 0;
4758
- maxpower = Math.pow(2,16);
4759
- power=1;
4760
- while (power!=maxpower) {
4761
- resb = data.val & data.position;
4762
- data.position >>= 1;
4763
- if (data.position == 0) {
4764
- data.position = resetValue;
4765
- data.val = getNextValue(data.index++);
4766
- }
4767
- bits |= (resb>0 ? 1 : 0) * power;
4768
- power <<= 1;
4769
- }
4770
- dictionary[dictSize++] = f(bits);
4771
- c = dictSize-1;
4772
- enlargeIn--;
4773
- break;
4774
- case 2:
4775
- return result.join('');
4776
- }
4777
-
4778
- if (enlargeIn == 0) {
4779
- enlargeIn = Math.pow(2, numBits);
4780
- numBits++;
4781
- }
4782
-
4783
- if (dictionary[c]) {
4784
- entry = dictionary[c];
4785
- } else {
4786
- if (c === dictSize) {
4787
- entry = w + w.charAt(0);
4788
- } else {
4789
- return null;
4790
- }
4791
- }
4792
- result.push(entry);
4793
-
4794
- // Add w+entry[0] to the dictionary.
4795
- dictionary[dictSize++] = w + entry.charAt(0);
4796
- enlargeIn--;
4797
-
4798
- w = entry;
4799
-
4800
- if (enlargeIn == 0) {
4801
- enlargeIn = Math.pow(2, numBits);
4802
- numBits++;
4803
- }
4804
-
4805
- }
4806
- }
4807
- };
4808
- return LZString;
4809
- })();
4810
-
4811
- if (true) {
4812
- !(__WEBPACK_AMD_DEFINE_RESULT__ = (function () { return LZString; }).call(exports, __webpack_require__, exports, module),
4813
- __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
4814
- } else // removed by dead control flow
4815
- {}
4816
-
4817
-
4818
- /***/ },
4819
-
4820
- /***/ "./src/Base64.js"
4821
- /*!***********************!*\
4822
- !*** ./src/Base64.js ***!
4823
- \***********************/
4824
- (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
4825
-
4826
- "use strict";
4827
- __webpack_require__.r(__webpack_exports__);
4828
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4829
- /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
4830
- /* harmony export */ });
4831
- const Base64 = {
4832
- _keyStr: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',
4833
- encode: function (e) {
4834
- let t = '';
4835
- let n, r, i, s, o, u, a;
4836
- let f = 0;
4837
- e = Base64._utf8Encode(e);
4838
- while (f < e.length) {
4839
- n = e.charCodeAt(f++);
4840
- r = e.charCodeAt(f++);
4841
- i = e.charCodeAt(f++);
4842
- s = n >> 2;
4843
- o = (n & 3) << 4 | r >> 4;
4844
- u = (r & 15) << 2 | i >> 6;
4845
- a = i & 63;
4846
- if (isNaN(r)) {
4847
- u = a = 64;
4848
- } else if (isNaN(i)) {
4849
- a = 64;
4850
- }
4851
- t = t + this._keyStr.charAt(s) + this._keyStr.charAt(o) + this._keyStr.charAt(u) + this._keyStr.charAt(a);
4852
- }
4853
- return t;
4854
- },
4855
- decode: function (e) {
4856
- let t = '';
4857
- let n, r, i;
4858
- let s, o, u, a;
4859
- let f = 0;
4860
- e = e.replace(/[^A-Za-z0-9+/=]/g, '');
4861
- while (f < e.length) {
4862
- s = this._keyStr.indexOf(e.charAt(f++));
4863
- o = this._keyStr.indexOf(e.charAt(f++));
4864
- u = this._keyStr.indexOf(e.charAt(f++));
4865
- a = this._keyStr.indexOf(e.charAt(f++));
4866
- n = s << 2 | o >> 4;
4867
- r = (o & 15) << 4 | u >> 2;
4868
- i = (u & 3) << 6 | a;
4869
- t = t + String.fromCharCode(n);
4870
- if (u !== 64) {
4871
- t = t + String.fromCharCode(r);
4872
- }
4873
- if (a !== 64) {
4874
- t = t + String.fromCharCode(i);
4875
- }
4876
- }
4877
- t = Base64._utf8Decode(t);
4878
- return t;
4879
- },
4880
- _utf8Encode: function (e) {
4881
- e = e.replace(/\r\n/g, '\n');
4882
- let t = '';
4883
- for (let n = 0; n < e.length; n++) {
4884
- let r = e.charCodeAt(n);
4885
- if (r < 128) {
4886
- t += String.fromCharCode(r);
4887
- } else if (r > 127 && r < 2048) {
4888
- t += String.fromCharCode(r >> 6 | 192);
4889
- t += String.fromCharCode(r & 63 | 128);
4890
- } else {
4891
- t += String.fromCharCode(r >> 12 | 224);
4892
- t += String.fromCharCode(r >> 6 & 63 | 128);
4893
- t += String.fromCharCode(r & 63 | 128);
4894
- }
4895
- }
4896
- return t;
4897
- },
4898
- _utf8Decode: function (e) {
4899
- let t = '';
4900
- let n = 0;
4901
- let r, c2, c3;
4902
- r = c2 = 0;
4903
- while (n < e.length) {
4904
- r = e.charCodeAt(n);
4905
- if (r < 128) {
4906
- t += String.fromCharCode(r);
4907
- n++;
4908
- } else if (r > 191 && r < 224) {
4909
- c2 = e.charCodeAt(n + 1);
4910
- t += String.fromCharCode((r & 31) << 6 | c2 & 63);
4911
- n += 2;
4912
- } else {
4913
- c2 = e.charCodeAt(n + 1);
4914
- c3 = e.charCodeAt(n + 2);
4915
- t += String.fromCharCode((r & 15) << 12 | (c2 & 63) << 6 | c3 & 63);
4916
- n += 3;
4917
- }
4918
- }
4919
- return t;
4920
- }
4921
- };
4922
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Base64);
4923
-
4924
- /***/ },
4925
-
4926
- /***/ "./src/SecureLS.js"
4927
- /*!*************************!*\
4928
- !*** ./src/SecureLS.js ***!
4929
- \*************************/
4930
- (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
4931
-
4932
- "use strict";
4933
- __webpack_require__.r(__webpack_exports__);
4934
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4935
- /* harmony export */ SecureLS: () => (/* binding */ SecureLS)
4936
- /* harmony export */ });
4937
- /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants */ "./src/constants.js");
4938
- /* harmony import */ var _enc_utf8__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./enc-utf8 */ "./src/enc-utf8.js");
4939
- /* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./utils */ "./src/utils.js");
4940
- /* harmony import */ var crypto_js_aes__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! crypto-js/aes */ "./node_modules/crypto-js/aes.js");
4941
- /* harmony import */ var crypto_js_aes__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(crypto_js_aes__WEBPACK_IMPORTED_MODULE_3__);
4942
- /* harmony import */ var crypto_js_rabbit__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! crypto-js/rabbit */ "./node_modules/crypto-js/rabbit.js");
4943
- /* harmony import */ var crypto_js_rabbit__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(crypto_js_rabbit__WEBPACK_IMPORTED_MODULE_4__);
4944
- /* harmony import */ var crypto_js_rc4__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! crypto-js/rc4 */ "./node_modules/crypto-js/rc4.js");
4945
- /* harmony import */ var crypto_js_rc4__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(crypto_js_rc4__WEBPACK_IMPORTED_MODULE_5__);
4946
- /* harmony import */ var crypto_js_tripledes__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! crypto-js/tripledes */ "./node_modules/crypto-js/tripledes.js");
4947
- /* harmony import */ var crypto_js_tripledes__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(crypto_js_tripledes__WEBPACK_IMPORTED_MODULE_6__);
4948
- /* harmony import */ var lz_string_libs_lz_string__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! lz-string/libs/lz-string */ "./node_modules/lz-string/libs/lz-string.js");
4949
- /* harmony import */ var lz_string_libs_lz_string__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(lz_string_libs_lz_string__WEBPACK_IMPORTED_MODULE_7__);
4950
- /* harmony import */ var _Base64__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Base64 */ "./src/Base64.js");
4951
-
4952
-
4953
-
4954
-
4955
-
4956
-
4957
-
4958
-
4959
-
4960
- const encryptors = {
4961
- [_constants__WEBPACK_IMPORTED_MODULE_0__["default"].EncrytionTypes.AES]: (crypto_js_aes__WEBPACK_IMPORTED_MODULE_3___default()),
4962
- [_constants__WEBPACK_IMPORTED_MODULE_0__["default"].EncrytionTypes.DES]: (crypto_js_tripledes__WEBPACK_IMPORTED_MODULE_6___default()),
4963
- [_constants__WEBPACK_IMPORTED_MODULE_0__["default"].EncrytionTypes.RABBIT]: (crypto_js_rabbit__WEBPACK_IMPORTED_MODULE_4___default()),
4964
- [_constants__WEBPACK_IMPORTED_MODULE_0__["default"].EncrytionTypes.RC4]: (crypto_js_rc4__WEBPACK_IMPORTED_MODULE_5___default())
4965
- };
4966
- class SecureLS {
4967
- constructor({
4968
- encryptionSecret = '',
4969
- encryptionNamespace = '',
4970
- isCompression = true,
4971
- encodingType = _constants__WEBPACK_IMPORTED_MODULE_0__["default"].EncrytionTypes.BASE64,
4972
- storage = localStorage,
4973
- metaKey = _constants__WEBPACK_IMPORTED_MODULE_0__["default"].metaKey
4974
- } = {}) {
4975
- // Assign libraries and utilities
4976
- Object.assign(this, {
4977
- _name: 'secure-ls',
4978
- Base64: _Base64__WEBPACK_IMPORTED_MODULE_8__["default"],
4979
- LZString: {
4980
- compressToUTF16: lz_string_libs_lz_string__WEBPACK_IMPORTED_MODULE_7__.compressToUTF16,
4981
- decompressFromUTF16: lz_string_libs_lz_string__WEBPACK_IMPORTED_MODULE_7__.decompressFromUTF16
4982
- },
4983
- AES: (crypto_js_aes__WEBPACK_IMPORTED_MODULE_3___default()),
4984
- DES: (crypto_js_tripledes__WEBPACK_IMPORTED_MODULE_6___default()),
4985
- RABBIT: (crypto_js_rabbit__WEBPACK_IMPORTED_MODULE_4___default()),
4986
- RC4: (crypto_js_rc4__WEBPACK_IMPORTED_MODULE_5___default()),
4987
- enc: _enc_utf8__WEBPACK_IMPORTED_MODULE_1__["default"]
4988
- });
4989
-
4990
- // Configuration and property assignment
4991
- this.config = {
4992
- encryptionSecret,
4993
- encryptionNamespace,
4994
- isCompression,
4995
- encodingType: encodingType.toLowerCase(),
4996
- storage,
4997
- metaKey
4998
- };
4999
- this.encryptionSecret = encryptionSecret;
5000
- this.storage = storage;
5001
- this.metaKey = metaKey;
5002
-
5003
- // Initialize the class
5004
- this.init();
5005
- }
5006
- init() {
5007
- let metaData = this.getMetaData();
5008
- this._isBase64 = this._isBase64EncryptionType();
5009
- this._isAES = this._isAESEncryptionType();
5010
- this._isDES = this._isDESEncryptionType();
5011
- this._isRabbit = this._isRabbitEncryptionType();
5012
- this._isRC4 = this._isRC4EncryptionType();
5013
- this._isCompression = this._isDataCompressionEnabled();
5014
-
5015
- // fill the already present keys to the list of keys being used by secure-ls
5016
- this.allKeys = metaData.keys || this.resetAllKeys();
5017
- }
5018
- _isBase64EncryptionType() {
5019
- return _Base64__WEBPACK_IMPORTED_MODULE_8__["default"] && (typeof this.config.encodingType === 'undefined' || this.config.encodingType === _constants__WEBPACK_IMPORTED_MODULE_0__["default"].EncrytionTypes.BASE64);
5020
- }
5021
- _isAESEncryptionType() {
5022
- return (crypto_js_aes__WEBPACK_IMPORTED_MODULE_3___default()) && this.config.encodingType === _constants__WEBPACK_IMPORTED_MODULE_0__["default"].EncrytionTypes.AES;
5023
- }
5024
- _isDESEncryptionType() {
5025
- return (crypto_js_tripledes__WEBPACK_IMPORTED_MODULE_6___default()) && this.config.encodingType === _constants__WEBPACK_IMPORTED_MODULE_0__["default"].EncrytionTypes.DES;
5026
- }
5027
- _isRabbitEncryptionType() {
5028
- return (crypto_js_rabbit__WEBPACK_IMPORTED_MODULE_4___default()) && this.config.encodingType === _constants__WEBPACK_IMPORTED_MODULE_0__["default"].EncrytionTypes.RABBIT;
5029
- }
5030
- _isRC4EncryptionType() {
5031
- return (crypto_js_rc4__WEBPACK_IMPORTED_MODULE_5___default()) && this.config.encodingType === _constants__WEBPACK_IMPORTED_MODULE_0__["default"].EncrytionTypes.RC4;
5032
- }
5033
- _isDataCompressionEnabled() {
5034
- return this.config.isCompression;
5035
- }
5036
- getEncryptionSecret(key) {
5037
- let metaData = this.getMetaData();
5038
- let obj = _utils__WEBPACK_IMPORTED_MODULE_2__["default"].getObjectFromKey(metaData.keys, key);
5039
- if (!obj) {
5040
- return;
5041
- }
5042
- if (this._isAES || this._isDES || this._isRabbit || this._isRC4) {
5043
- if (typeof this.config.encryptionSecret === 'undefined') {
5044
- this.encryptionSecret = obj.s;
5045
- if (!this.encryptionSecret) {
5046
- this.encryptionSecret = _utils__WEBPACK_IMPORTED_MODULE_2__["default"].generateSecretKey();
5047
- this.setMetaData();
5048
- }
5049
- } else {
5050
- this.encryptionSecret = this.config.encryptionSecret || obj.s || '';
5051
- }
5052
- }
5053
- }
5054
- getEncryptionType() {
5055
- const encodingType = this.config.encodingType;
5056
- return encodingType ? encodingType.toLowerCase() : _constants__WEBPACK_IMPORTED_MODULE_0__["default"].EncrytionTypes.BASE64;
5057
- }
5058
- getDataFromLocalStorage(key) {
5059
- return this.storage.getItem(key, true);
5060
- }
5061
- setDataToLocalStorage(key, data) {
5062
- this.storage.setItem(key, data);
5063
- }
5064
- setMetaData() {
5065
- let dataToStore = this.processData({
5066
- keys: this.allKeys
5067
- }, true);
5171
+ if (context_enlargeIn == 0) {
5172
+ context_enlargeIn = Math.pow(2, context_numBits);
5173
+ context_numBits++;
5174
+ }
5175
+ delete context_dictionaryToCreate[context_w];
5176
+ } else {
5177
+ value = context_dictionary[context_w];
5178
+ for (i=0 ; i<context_numBits ; i++) {
5179
+ context_data_val = (context_data_val << 1) | (value&1);
5180
+ if (context_data_position == bitsPerChar-1) {
5181
+ context_data_position = 0;
5182
+ context_data.push(getCharFromInt(context_data_val));
5183
+ context_data_val = 0;
5184
+ } else {
5185
+ context_data_position++;
5186
+ }
5187
+ value = value >> 1;
5188
+ }
5068
5189
 
5069
- // Store the data to localStorage
5070
- this.setDataToLocalStorage(this.getMetaKey(), dataToStore);
5071
- }
5072
- getMetaData() {
5073
- return this.get(this.getMetaKey(), true) || {};
5074
- }
5075
- getMetaKey() {
5076
- return this.metaKey + (this.config.encryptionNamespace ? '__' + this.config.encryptionNamespace : '');
5077
- }
5078
- resetAllKeys() {
5079
- this.allKeys = [];
5080
- return [];
5081
- }
5082
- processData(data, isAllKeysData) {
5083
- if (data === null || data === undefined || data === '') {
5084
- return '';
5085
- }
5086
- let jsonData;
5087
- try {
5088
- jsonData = JSON.stringify(data);
5089
- } catch (err) {
5090
- throw new Error('Could not stringify data', err);
5091
- }
5092
5190
 
5093
- // Encode Based on encoding type
5094
- // If not set, default to Base64 for securing data
5095
- let encodedData = jsonData;
5096
- if (this._isBase64 || isAllKeysData) {
5097
- encodedData = _Base64__WEBPACK_IMPORTED_MODULE_8__["default"].encode(jsonData);
5098
- } else {
5099
- const encryptor = encryptors[this.getEncryptionType()];
5100
- if (encryptor) {
5101
- encodedData = encryptor.encrypt(jsonData, this.encryptionSecret);
5102
5191
  }
5103
- encodedData = encodedData && encodedData.toString();
5104
- }
5105
-
5106
- // Compress data if set to true
5107
- let compressedData = encodedData;
5108
- if (this._isCompression || isAllKeysData) {
5109
- compressedData = this.LZString.compressToUTF16(encodedData);
5110
- }
5111
- return compressedData;
5112
- }
5113
-
5114
- // PUBLIC APIs
5115
- getAllKeys() {
5116
- let data = this.getMetaData();
5117
- return _utils__WEBPACK_IMPORTED_MODULE_2__["default"].extractKeyNames(data) || [];
5118
- }
5119
- get(key, isAllKeysData) {
5120
- let decodedData = '';
5121
- let jsonData = '';
5122
- if (!_utils__WEBPACK_IMPORTED_MODULE_2__["default"].is(key)) {
5123
- _utils__WEBPACK_IMPORTED_MODULE_2__["default"].warn(_constants__WEBPACK_IMPORTED_MODULE_0__["default"].WarningEnum.KEY_NOT_PROVIDED);
5124
- return jsonData;
5125
- }
5126
- let data = this.getDataFromLocalStorage(key);
5127
- if (!data) {
5128
- return jsonData;
5129
- }
5130
- let deCompressedData = data; // saves else
5131
- if (this._isCompression || isAllKeysData) {
5132
- // meta data always compressed
5133
- deCompressedData = this.LZString.decompressFromUTF16(data);
5134
- }
5135
- decodedData = deCompressedData; // saves else
5136
- if (this._isBase64 || isAllKeysData) {
5137
- // meta data always Base64
5138
- decodedData = _Base64__WEBPACK_IMPORTED_MODULE_8__["default"].decode(deCompressedData);
5139
- } else {
5140
- this.getEncryptionSecret(key);
5141
- const encryptor = encryptors[this.getEncryptionType()];
5142
- if (encryptor) {
5143
- const bytes = encryptor.decrypt(deCompressedData.toString(), this.encryptionSecret);
5144
- if (bytes) {
5145
- decodedData = bytes.toString(_enc_utf8__WEBPACK_IMPORTED_MODULE_1__["default"]._Utf8);
5146
- }
5192
+ context_enlargeIn--;
5193
+ if (context_enlargeIn == 0) {
5194
+ context_enlargeIn = Math.pow(2, context_numBits);
5195
+ context_numBits++;
5147
5196
  }
5148
5197
  }
5149
- try {
5150
- jsonData = JSON.parse(decodedData);
5151
- } catch (err) {
5152
- throw new Error('Could not parse JSON', err);
5153
- }
5154
- return jsonData;
5155
- }
5156
- set(key, data) {
5157
- let dataToStore = '';
5158
- if (!_utils__WEBPACK_IMPORTED_MODULE_2__["default"].is(key)) {
5159
- _utils__WEBPACK_IMPORTED_MODULE_2__["default"].warn(_constants__WEBPACK_IMPORTED_MODULE_0__["default"].WarningEnum.KEY_NOT_PROVIDED);
5160
- return;
5161
- }
5162
- this.getEncryptionSecret(key);
5163
5198
 
5164
- // add key(s) to Array if not already added, only for keys other than meta key
5165
- if (!(String(key) === String(this.metaKey))) {
5166
- if (!_utils__WEBPACK_IMPORTED_MODULE_2__["default"].isKeyPresent(this.allKeys, key)) {
5167
- this.allKeys.push({
5168
- k: key,
5169
- s: this.encryptionSecret
5170
- });
5171
- this.setMetaData();
5199
+ // Mark the end of the stream
5200
+ value = 2;
5201
+ for (i=0 ; i<context_numBits ; i++) {
5202
+ context_data_val = (context_data_val << 1) | (value&1);
5203
+ if (context_data_position == bitsPerChar-1) {
5204
+ context_data_position = 0;
5205
+ context_data.push(getCharFromInt(context_data_val));
5206
+ context_data_val = 0;
5207
+ } else {
5208
+ context_data_position++;
5172
5209
  }
5210
+ value = value >> 1;
5173
5211
  }
5174
- dataToStore = this.processData(data);
5175
- // Store the data to localStorage
5176
- this.setDataToLocalStorage(key, dataToStore);
5177
- }
5178
- remove(key) {
5179
- if (!_utils__WEBPACK_IMPORTED_MODULE_2__["default"].is(key)) {
5180
- _utils__WEBPACK_IMPORTED_MODULE_2__["default"].warn(_constants__WEBPACK_IMPORTED_MODULE_0__["default"].WarningEnum.KEY_NOT_PROVIDED);
5181
- return;
5182
- }
5183
- if (key === this.metaKey && this.getAllKeys().length) {
5184
- _utils__WEBPACK_IMPORTED_MODULE_2__["default"].warn(_constants__WEBPACK_IMPORTED_MODULE_0__["default"].WarningEnum.META_KEY_REMOVE);
5185
- return;
5186
- }
5187
- if (_utils__WEBPACK_IMPORTED_MODULE_2__["default"].isKeyPresent(this.allKeys, key)) {
5188
- _utils__WEBPACK_IMPORTED_MODULE_2__["default"].removeFromKeysList(this.allKeys, key);
5189
- this.setMetaData();
5190
- }
5191
- this.storage.removeItem(key);
5192
- }
5193
- removeAll() {
5194
- let keys = this.getAllKeys();
5195
- for (let i = 0; i < keys.length; i++) {
5196
- this.storage.removeItem(keys[i]);
5197
- }
5198
- this.storage.removeItem(this.metaKey);
5199
- this.resetAllKeys();
5200
- }
5201
- clear() {
5202
- this.storage.clear();
5203
- this.resetAllKeys();
5204
- }
5205
- }
5206
-
5207
- /***/ },
5208
-
5209
- /***/ "./src/WordArray.js"
5210
- /*!**************************!*\
5211
- !*** ./src/WordArray.js ***!
5212
- \**************************/
5213
- (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
5214
-
5215
- "use strict";
5216
- __webpack_require__.r(__webpack_exports__);
5217
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5218
- /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
5219
- /* harmony export */ });
5220
- /*
5221
- ES6 compatible port of CryptoJS - WordArray for PBKDF2 password key generation
5222
-
5223
- Source: https://github.com/brix/crypto-js
5224
- LICENSE: MIT
5225
- */
5226
5212
 
5227
- let CryptoJSWordArray = {
5228
- random: function (nBytes) {
5229
- let words = [];
5230
- let r = function (mw) {
5231
- let mz = 0x3ade68b1;
5232
- let mask = 0xffffffff;
5233
- return function () {
5234
- mz = 0x9069 * (mz & 0xffff) + (mz >> 0x10) & mask;
5235
- mw = 0x4650 * (mw & 0xffff) + (mw >> 0x10) & mask;
5236
- let result = (mz << 0x10) + mw & mask;
5237
- result /= 0x100000000;
5238
- result += 0.5;
5239
- return result * (Math.random() > 0.5 ? 1 : -1);
5240
- };
5241
- };
5242
- for (let i = 0, rcache; i < nBytes; i += 4) {
5243
- let _r = r((rcache || Math.random()) * 0x100000000);
5244
- rcache = _r() * 0x3ade67b7;
5245
- words.push(_r() * 0x100000000 | 0);
5213
+ // Flush the last char
5214
+ while (true) {
5215
+ context_data_val = (context_data_val << 1);
5216
+ if (context_data_position == bitsPerChar-1) {
5217
+ context_data.push(getCharFromInt(context_data_val));
5218
+ break;
5219
+ }
5220
+ else context_data_position++;
5246
5221
  }
5247
- return new CryptoJSWordArray.Set(words, nBytes);
5222
+ return context_data.join('');
5248
5223
  },
5249
- Set: function (words, sigBytes) {
5250
- words = this.words = words || [];
5251
- if (sigBytes !== undefined) {
5252
- this.sigBytes = sigBytes;
5253
- } else {
5254
- this.sigBytes = words.length * 8;
5255
- }
5256
- }
5257
- };
5258
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (CryptoJSWordArray);
5259
-
5260
- /***/ },
5261
-
5262
- /***/ "./src/constants.js"
5263
- /*!**************************!*\
5264
- !*** ./src/constants.js ***!
5265
- \**************************/
5266
- (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
5267
5224
 
5268
- "use strict";
5269
- __webpack_require__.r(__webpack_exports__);
5270
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5271
- /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
5272
- /* harmony export */ });
5273
- const WarningEnum = {
5274
- KEY_NOT_PROVIDED: 'keyNotProvided',
5275
- META_KEY_REMOVE: 'metaKeyRemove',
5276
- DEFAULT_TEXT: 'defaultText'
5277
- };
5278
- const WarningTypes = {};
5279
- WarningTypes[WarningEnum.KEY_NOT_PROVIDED] = 'Secure LS: Key not provided. Aborting operation!';
5280
- WarningTypes[WarningEnum.META_KEY_REMOVE] = `Secure LS: Meta key can not be removed
5281
- unless all keys created by Secure LS are removed!`;
5282
- WarningTypes[WarningEnum.DEFAULT_TEXT] = `Unexpected output`;
5283
- const constants = {
5284
- WarningEnum: WarningEnum,
5285
- WarningTypes: WarningTypes,
5286
- EncrytionTypes: {
5287
- BASE64: 'base64',
5288
- AES: 'aes',
5289
- DES: 'des',
5290
- RABBIT: 'rabbit',
5291
- RC4: 'rc4'
5225
+ decompress: function (compressed) {
5226
+ if (compressed == null) return "";
5227
+ if (compressed == "") return null;
5228
+ return LZString._decompress(compressed.length, 32768, function(index) { return compressed.charCodeAt(index); });
5292
5229
  },
5293
- metaKey: '_secure__ls__metadata',
5294
- secretPhrase: 's3cr3t$#@135^&*246'
5295
- };
5296
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (constants);
5297
5230
 
5298
- /***/ },
5231
+ _decompress: function (length, resetValue, getNextValue) {
5232
+ var dictionary = [],
5233
+ next,
5234
+ enlargeIn = 4,
5235
+ dictSize = 4,
5236
+ numBits = 3,
5237
+ entry = "",
5238
+ result = [],
5239
+ i,
5240
+ w,
5241
+ bits, resb, maxpower, power,
5242
+ c,
5243
+ data = {val:getNextValue(0), position:resetValue, index:1};
5299
5244
 
5300
- /***/ "./src/enc-utf8.js"
5301
- /*!*************************!*\
5302
- !*** ./src/enc-utf8.js ***!
5303
- \*************************/
5304
- (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
5245
+ for (i = 0; i < 3; i += 1) {
5246
+ dictionary[i] = i;
5247
+ }
5305
5248
 
5306
- "use strict";
5307
- __webpack_require__.r(__webpack_exports__);
5308
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5309
- /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
5310
- /* harmony export */ });
5311
- /*
5312
- ES6 compatible port of CryptoJS - encoding
5249
+ bits = 0;
5250
+ maxpower = Math.pow(2,2);
5251
+ power=1;
5252
+ while (power!=maxpower) {
5253
+ resb = data.val & data.position;
5254
+ data.position >>= 1;
5255
+ if (data.position == 0) {
5256
+ data.position = resetValue;
5257
+ data.val = getNextValue(data.index++);
5258
+ }
5259
+ bits |= (resb>0 ? 1 : 0) * power;
5260
+ power <<= 1;
5261
+ }
5313
5262
 
5314
- Source: https://github.com/brix/crypto-js
5315
- LICENSE: MIT
5316
- */
5317
- const enc = {
5318
- Latin1: {
5319
- stringify: wordArray => {
5320
- // Shortcuts
5321
- let words = wordArray.words;
5322
- let sigBytes = wordArray.sigBytes;
5323
- let latin1Chars = [],
5324
- i,
5325
- bite;
5263
+ switch (next = bits) {
5264
+ case 0:
5265
+ bits = 0;
5266
+ maxpower = Math.pow(2,8);
5267
+ power=1;
5268
+ while (power!=maxpower) {
5269
+ resb = data.val & data.position;
5270
+ data.position >>= 1;
5271
+ if (data.position == 0) {
5272
+ data.position = resetValue;
5273
+ data.val = getNextValue(data.index++);
5274
+ }
5275
+ bits |= (resb>0 ? 1 : 0) * power;
5276
+ power <<= 1;
5277
+ }
5278
+ c = f(bits);
5279
+ break;
5280
+ case 1:
5281
+ bits = 0;
5282
+ maxpower = Math.pow(2,16);
5283
+ power=1;
5284
+ while (power!=maxpower) {
5285
+ resb = data.val & data.position;
5286
+ data.position >>= 1;
5287
+ if (data.position == 0) {
5288
+ data.position = resetValue;
5289
+ data.val = getNextValue(data.index++);
5290
+ }
5291
+ bits |= (resb>0 ? 1 : 0) * power;
5292
+ power <<= 1;
5293
+ }
5294
+ c = f(bits);
5295
+ break;
5296
+ case 2:
5297
+ return "";
5298
+ }
5299
+ dictionary[3] = c;
5300
+ w = c;
5301
+ result.push(c);
5302
+ while (true) {
5303
+ if (data.index > length) {
5304
+ return "";
5305
+ }
5326
5306
 
5327
- // Convert
5328
- for (i = 0; i < sigBytes; i++) {
5329
- bite = words[i >>> 2] >>> 24 - i % 4 * 8 & 0xff;
5330
- latin1Chars.push(String.fromCharCode(bite));
5307
+ bits = 0;
5308
+ maxpower = Math.pow(2,numBits);
5309
+ power=1;
5310
+ while (power!=maxpower) {
5311
+ resb = data.val & data.position;
5312
+ data.position >>= 1;
5313
+ if (data.position == 0) {
5314
+ data.position = resetValue;
5315
+ data.val = getNextValue(data.index++);
5316
+ }
5317
+ bits |= (resb>0 ? 1 : 0) * power;
5318
+ power <<= 1;
5331
5319
  }
5332
- return latin1Chars.join('');
5333
- }
5334
- },
5335
- _Utf8: {
5336
- stringify: wordArray => {
5337
- try {
5338
- return decodeURIComponent(escape(enc.Latin1.stringify(wordArray)));
5339
- } catch (err) {
5340
- throw new Error('Malformed UTF-8 data', err);
5320
+
5321
+ switch (c = bits) {
5322
+ case 0:
5323
+ bits = 0;
5324
+ maxpower = Math.pow(2,8);
5325
+ power=1;
5326
+ while (power!=maxpower) {
5327
+ resb = data.val & data.position;
5328
+ data.position >>= 1;
5329
+ if (data.position == 0) {
5330
+ data.position = resetValue;
5331
+ data.val = getNextValue(data.index++);
5332
+ }
5333
+ bits |= (resb>0 ? 1 : 0) * power;
5334
+ power <<= 1;
5335
+ }
5336
+
5337
+ dictionary[dictSize++] = f(bits);
5338
+ c = dictSize-1;
5339
+ enlargeIn--;
5340
+ break;
5341
+ case 1:
5342
+ bits = 0;
5343
+ maxpower = Math.pow(2,16);
5344
+ power=1;
5345
+ while (power!=maxpower) {
5346
+ resb = data.val & data.position;
5347
+ data.position >>= 1;
5348
+ if (data.position == 0) {
5349
+ data.position = resetValue;
5350
+ data.val = getNextValue(data.index++);
5351
+ }
5352
+ bits |= (resb>0 ? 1 : 0) * power;
5353
+ power <<= 1;
5354
+ }
5355
+ dictionary[dictSize++] = f(bits);
5356
+ c = dictSize-1;
5357
+ enlargeIn--;
5358
+ break;
5359
+ case 2:
5360
+ return result.join('');
5341
5361
  }
5342
- }
5343
- }
5344
- };
5345
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (enc);
5346
5362
 
5347
- /***/ },
5363
+ if (enlargeIn == 0) {
5364
+ enlargeIn = Math.pow(2, numBits);
5365
+ numBits++;
5366
+ }
5348
5367
 
5349
- /***/ "./src/utils.js"
5350
- /*!**********************!*\
5351
- !*** ./src/utils.js ***!
5352
- \**********************/
5353
- (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
5368
+ if (dictionary[c]) {
5369
+ entry = dictionary[c];
5370
+ } else {
5371
+ if (c === dictSize) {
5372
+ entry = w + w.charAt(0);
5373
+ } else {
5374
+ return null;
5375
+ }
5376
+ }
5377
+ result.push(entry);
5354
5378
 
5355
- "use strict";
5356
- __webpack_require__.r(__webpack_exports__);
5357
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5358
- /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
5359
- /* harmony export */ });
5360
- /* harmony import */ var crypto_js_pbkdf2__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! crypto-js/pbkdf2 */ "./node_modules/crypto-js/pbkdf2.js");
5361
- /* harmony import */ var crypto_js_pbkdf2__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(crypto_js_pbkdf2__WEBPACK_IMPORTED_MODULE_0__);
5362
- /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./constants */ "./src/constants.js");
5363
- /* harmony import */ var _WordArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./WordArray */ "./src/WordArray.js");
5379
+ // Add w+entry[0] to the dictionary.
5380
+ dictionary[dictSize++] = w + entry.charAt(0);
5381
+ enlargeIn--;
5364
5382
 
5383
+ w = entry;
5365
5384
 
5385
+ if (enlargeIn == 0) {
5386
+ enlargeIn = Math.pow(2, numBits);
5387
+ numBits++;
5388
+ }
5366
5389
 
5367
- const utils = {
5368
- is: key => !!key,
5369
- warn: (reason = _constants__WEBPACK_IMPORTED_MODULE_1__["default"].WarningEnum.DEFAULT_TEXT) => {
5370
- console.warn(_constants__WEBPACK_IMPORTED_MODULE_1__["default"].WarningTypes[reason]);
5371
- },
5372
- generateSecretKey: () => {
5373
- const salt = _WordArray__WEBPACK_IMPORTED_MODULE_2__["default"].random(128 / 8);
5374
- const key128Bits = crypto_js_pbkdf2__WEBPACK_IMPORTED_MODULE_0___default()(_constants__WEBPACK_IMPORTED_MODULE_1__["default"].secretPhrase, salt, {
5375
- keySize: 128 / 32
5376
- });
5377
- return key128Bits.toString();
5378
- },
5379
- getObjectFromKey: (data = [], key) => {
5380
- return data.find(item => item.k === key) || {};
5381
- },
5382
- extractKeyNames: ({
5383
- keys = []
5384
- } = {}) => {
5385
- return keys.map(({
5386
- k
5387
- }) => k);
5388
- },
5389
- isKeyPresent: (allKeys = [], key) => {
5390
- return allKeys.some(item => String(item.k) === String(key));
5391
- },
5392
- removeFromKeysList: (allKeys = [], key) => {
5393
- const index = allKeys.findIndex(item => item.k === key);
5394
- if (index !== -1) {
5395
- allKeys.splice(index, 1);
5396
5390
  }
5397
- return index;
5398
5391
  }
5399
5392
  };
5400
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (utils);
5393
+ return LZString;
5394
+ })();
5395
+
5396
+ if (true) {
5397
+ !(__WEBPACK_AMD_DEFINE_RESULT__ = (function () { return LZString; }).call(exports, __webpack_require__, exports, module),
5398
+ __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
5399
+ } else // removed by dead control flow
5400
+ {}
5401
+
5401
5402
 
5402
5403
  /***/ },
5403
5404
 
@@ -5423,12 +5424,6 @@ const utils = {
5423
5424
  /******/ if (cachedModule !== undefined) {
5424
5425
  /******/ return cachedModule.exports;
5425
5426
  /******/ }
5426
- /******/ // Check if module exists (development only)
5427
- /******/ if (__webpack_modules__[moduleId] === undefined) {
5428
- /******/ var e = new Error("Cannot find module '" + moduleId + "'");
5429
- /******/ e.code = 'MODULE_NOT_FOUND';
5430
- /******/ throw e;
5431
- /******/ }
5432
5427
  /******/ // Create a new module (and put it into the cache)
5433
5428
  /******/ var module = __webpack_module_cache__[moduleId] = {
5434
5429
  /******/ // no module.id needed
@@ -5437,6 +5432,12 @@ const utils = {
5437
5432
  /******/ };
5438
5433
  /******/
5439
5434
  /******/ // Execute the module function
5435
+ /******/ if (!(moduleId in __webpack_modules__)) {
5436
+ /******/ delete __webpack_module_cache__[moduleId];
5437
+ /******/ var e = new Error("Cannot find module '" + moduleId + "'");
5438
+ /******/ e.code = 'MODULE_NOT_FOUND';
5439
+ /******/ throw e;
5440
+ /******/ }
5440
5441
  /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
5441
5442
  /******/
5442
5443
  /******/ // Return the exports of the module