@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,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitaldefiance/ecies-lib",
3
- "version": "4.5.15",
3
+ "version": "4.5.16",
4
4
  "description": "Digital Defiance ECIES Library",
5
5
  "homepage": "https://github.com/Digital-Defiance/ecies-lib",
6
6
  "repository": {
@@ -4,5 +4,5 @@
4
4
  *
5
5
  * CRITICAL: This must run before ANY @noble/curves code is imported
6
6
  */
7
- export declare const cryptoPolyfillApplied = true;
7
+ export declare const cryptoPolyfillApplied: boolean;
8
8
  //# sourceMappingURL=crypto-polyfill.d.ts.map
@@ -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;AAuEH,eAAO,MAAM,qBAAqB,OAAO,CAAC"}
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
- // Execute immediately as an IIFE to ensure this runs before any other code
11
- (function patchCryptoGetRandomValues() {
12
- // Save reference to the ORIGINAL Uint8Array constructor
13
- const OriginalUint8Array = Uint8Array;
14
- // Mark as having side effects for tree-shaking
15
- const cryptoPolyfillApplied = true;
16
- // Get all crypto references
17
- const cryptoTargets = [];
18
- if (typeof window !== 'undefined' && window.crypto) {
19
- cryptoTargets.push({ crypto: window.crypto, name: 'window.crypto' });
20
- }
21
- if (typeof globalThis !== 'undefined' && globalThis.crypto) {
22
- cryptoTargets.push({
23
- crypto: globalThis.crypto,
24
- name: 'globalThis.crypto',
25
- });
26
- }
27
- // Patch all crypto references
28
- cryptoTargets.forEach(({ crypto, name }) => {
29
- if (!crypto.getRandomValues)
30
- return;
31
- const original = crypto.getRandomValues.bind(crypto);
32
- crypto.getRandomValues = function (array) {
33
- if (!array)
34
- return array;
35
- // ALWAYS create a pure Uint8Array if input is Uint8Array
36
- if (array instanceof OriginalUint8Array) {
37
- const constructor = array.constructor;
38
- const isPure = constructor === OriginalUint8Array;
39
- if (!isPure) {
40
- console.warn(`[crypto-polyfill] Detected non-pure Uint8Array (${constructor.name}), creating pure replacement`);
41
- }
42
- // Always use the ORIGINAL Uint8Array for the operation
43
- const pureArray = new OriginalUint8Array(array.length);
44
- const result = original(pureArray);
45
- // Copy back to input array
46
- for (let i = 0; i < array.length; i++) {
47
- array[i] = pureArray[i];
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
- return array;
50
- }
51
- // For other types, call original directly
52
- return original(array);
53
- };
54
- console.log(`[crypto-polyfill] Patched ${name}.getRandomValues - all Uint8Array instances will be pure`);
55
- });
56
- // Export marker for tree-shaking
57
- if (typeof module !== 'undefined' && module.exports) {
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;;;AAEH,2EAA2E;AAC3E,CAAC,SAAS,0BAA0B;IAClC,wDAAwD;IACxD,MAAM,kBAAkB,GAAG,UAAU,CAAC;IAEtC,+CAA+C;IAC/C,MAAM,qBAAqB,GAAG,IAAI,CAAC;IAEnC,4BAA4B;IAC5B,MAAM,aAAa,GAA4C,EAAE,CAAC;IAClE,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QACnD,aAAa,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM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,CAAC;YAED,0CAA0C;YAC1C,OAAO,QAAQ,CAAC,KAAwB,CAAM,CAAC;QACjD,CAAC,CAAC;QAEF,OAAO,CAAC,GAAG,CACT,6BAA6B,IAAI,0DAA0D,CAC5F,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,iCAAiC;IACjC,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACpD,MAAM,CAAC,OAAO,GAAG,EAAE,qBAAqB,EAAE,CAAC;IAC7C,CAAC;AACH,CAAC,CAAC,EAAE,CAAC;AAEQ,QAAA,qBAAqB,GAAG,IAAI,CAAC"}
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,EAAE,CAAC;YACpE,aAAa,CAAC,IAAI,CAAC;gBACjB,MAAM,EAAG,UAAkB,CAAC,MAAM;gBAClC,IAAI,EAAE,mBAAmB;aAC1B,CAAC,CAAC;QACL,CAAC;QAED,8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