secure-ls2 2.2.0 → 2.2.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 +2 -2
- package/dist/secure-ls2.esm.min.mjs +3 -3
- package/dist/secure-ls2.esm.min.mjs.map +1 -1
- package/dist/secure-ls2.esm.mjs +22 -2
- package/dist/secure-ls2.esm.mjs.map +1 -1
- package/dist/secure-ls2.js +22 -2
- package/dist/secure-ls2.js.map +1 -1
- package/dist/secure-ls2.min.js +3 -3
- package/dist/secure-ls2.min.js.map +1 -1
- package/package.json +4 -5
package/dist/secure-ls2.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* secure-ls2 - v2.2.
|
|
3
|
-
* URL - https://github.com/
|
|
2
|
+
* secure-ls2 - v2.2.1
|
|
3
|
+
* URL - https://github.com/wuc656/secure-ls
|
|
4
4
|
*
|
|
5
5
|
* The MIT License (MIT)
|
|
6
6
|
*
|
|
@@ -488,6 +488,14 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
488
488
|
|
|
489
489
|
let CryptoJSWordArray = {
|
|
490
490
|
random: function (nBytes) {
|
|
491
|
+
const cryptoObj = typeof globalThis !== 'undefined' ? globalThis.crypto : undefined;
|
|
492
|
+
if (cryptoObj && typeof cryptoObj.getRandomValues === 'function') {
|
|
493
|
+
const wordsCount = Math.ceil(nBytes / 4);
|
|
494
|
+
const uint32Arr = new Uint32Array(wordsCount);
|
|
495
|
+
cryptoObj.getRandomValues(uint32Arr);
|
|
496
|
+
const words = Array.from(uint32Arr);
|
|
497
|
+
return new CryptoJSWordArray.Set(words, nBytes);
|
|
498
|
+
}
|
|
491
499
|
let words = [];
|
|
492
500
|
let r = function (mw) {
|
|
493
501
|
let mz = 0x3ade68b1;
|
|
@@ -597,6 +605,18 @@ const enc = {
|
|
|
597
605
|
_Utf8: {
|
|
598
606
|
stringify: wordArray => {
|
|
599
607
|
try {
|
|
608
|
+
const Decoder = typeof TextDecoder !== 'undefined' ? TextDecoder : typeof globalThis !== 'undefined' && globalThis.TextDecoder ? globalThis.TextDecoder : undefined;
|
|
609
|
+
if (Decoder) {
|
|
610
|
+
const sigBytes = wordArray.sigBytes;
|
|
611
|
+
const words = wordArray.words;
|
|
612
|
+
const bytes = new Uint8Array(sigBytes);
|
|
613
|
+
for (let i = 0; i < sigBytes; i++) {
|
|
614
|
+
bytes[i] = words[i >>> 2] >>> 24 - i % 4 * 8 & 0xff;
|
|
615
|
+
}
|
|
616
|
+
return new Decoder('utf-8', {
|
|
617
|
+
fatal: true
|
|
618
|
+
}).decode(bytes);
|
|
619
|
+
}
|
|
600
620
|
return decodeURIComponent(escape(enc.Latin1.stringify(wordArray)));
|
|
601
621
|
} catch (err) {
|
|
602
622
|
throw new Error('Malformed UTF-8 data', err);
|