@digitaldefiance/ecies-lib 4.5.15 → 4.5.16
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/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crypto-polyfill.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/lib/crypto-polyfill.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"crypto-polyfill.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/lib/crypto-polyfill.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA0EH,eAAO,MAAM,qBAAqB,SAAkB,CAAC"}
|
|
@@ -7,56 +7,56 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.cryptoPolyfillApplied = void 0;
|
|
10
|
-
//
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
//
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
cryptoTargets
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
10
|
+
// Track if polyfill was applied
|
|
11
|
+
let polyfillApplied = false;
|
|
12
|
+
// Only apply polyfill in non-Node.js environments (browsers, etc.)
|
|
13
|
+
if (typeof process === 'undefined' || !process.versions?.node) {
|
|
14
|
+
// Execute immediately as an IIFE
|
|
15
|
+
(function patchCryptoGetRandomValues() {
|
|
16
|
+
// Save reference to the ORIGINAL Uint8Array constructor
|
|
17
|
+
const OriginalUint8Array = Uint8Array;
|
|
18
|
+
// Get all crypto references
|
|
19
|
+
const cryptoTargets = [];
|
|
20
|
+
if (typeof window !== 'undefined' && window.crypto) {
|
|
21
|
+
cryptoTargets.push({ crypto: window.crypto, name: 'window.crypto' });
|
|
22
|
+
}
|
|
23
|
+
if (typeof globalThis !== 'undefined' && globalThis.crypto) {
|
|
24
|
+
cryptoTargets.push({
|
|
25
|
+
crypto: globalThis.crypto,
|
|
26
|
+
name: 'globalThis.crypto',
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
// Patch all crypto references
|
|
30
|
+
cryptoTargets.forEach(({ crypto, name }) => {
|
|
31
|
+
if (!crypto.getRandomValues)
|
|
32
|
+
return;
|
|
33
|
+
const original = crypto.getRandomValues.bind(crypto);
|
|
34
|
+
crypto.getRandomValues = function (array) {
|
|
35
|
+
if (!array)
|
|
36
|
+
return array;
|
|
37
|
+
// ALWAYS create a pure Uint8Array if input is Uint8Array
|
|
38
|
+
if (array instanceof OriginalUint8Array) {
|
|
39
|
+
const constructor = array.constructor;
|
|
40
|
+
const isPure = constructor === OriginalUint8Array;
|
|
41
|
+
if (!isPure) {
|
|
42
|
+
console.warn(`[crypto-polyfill] Detected non-pure Uint8Array (${constructor.name}), creating pure replacement`);
|
|
43
|
+
}
|
|
44
|
+
// Always use the ORIGINAL Uint8Array for the operation
|
|
45
|
+
const pureArray = new OriginalUint8Array(array.length);
|
|
46
|
+
original(pureArray);
|
|
47
|
+
// Copy back to input array
|
|
48
|
+
for (let i = 0; i < array.length; i++) {
|
|
49
|
+
array[i] = pureArray[i];
|
|
50
|
+
}
|
|
51
|
+
return array;
|
|
48
52
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
module.exports = { cryptoPolyfillApplied };
|
|
59
|
-
}
|
|
60
|
-
})();
|
|
61
|
-
exports.cryptoPolyfillApplied = true;
|
|
53
|
+
// For other types, call original directly
|
|
54
|
+
return original(array);
|
|
55
|
+
};
|
|
56
|
+
console.log(`[crypto-polyfill] Patched ${name}.getRandomValues - all Uint8Array instances will be pure`);
|
|
57
|
+
});
|
|
58
|
+
polyfillApplied = true;
|
|
59
|
+
})();
|
|
60
|
+
}
|
|
61
|
+
exports.cryptoPolyfillApplied = polyfillApplied;
|
|
62
62
|
//# sourceMappingURL=crypto-polyfill.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crypto-polyfill.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/lib/crypto-polyfill.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;
|
|
1
|
+
{"version":3,"file":"crypto-polyfill.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/lib/crypto-polyfill.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAKH,gCAAgC;AAChC,IAAI,eAAe,GAAG,KAAK,CAAC;AAE5B,mEAAmE;AACnE,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC9D,iCAAiC;IACjC,CAAC,SAAS,0BAA0B;QAClC,wDAAwD;QACxD,MAAM,kBAAkB,GAAG,UAAU,CAAC;QAEtC,4BAA4B;QAC5B,MAAM,aAAa,GAA4C,EAAE,CAAC;QAClE,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YACnD,aAAa,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC,CAAC;QACvE,CAAC;QACD,IAAI,OAAO,UAAU,KAAK,WAAW,IAAK,UAAkB,CAAC,MAAM,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