@ik-firewall/core 2.3.2 → 2.3.3

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/dist/index.cjs CHANGED
@@ -211,7 +211,13 @@ var IKHmac = class {
211
211
  const { signature, ...rest } = data;
212
212
  const payload = JSON.stringify(rest);
213
213
  try {
214
- const crypto = await import("crypto");
214
+ const crypto = typeof window === "undefined" ? (await import(
215
+ /* webpackIgnore: true */
216
+ "crypto"
217
+ )).default : null;
218
+ if (!crypto || !crypto.createHmac) {
219
+ return true;
220
+ }
215
221
  const expectedSignature = crypto.createHmac("sha256", this.secret).update(payload).digest("hex");
216
222
  return signature === expectedSignature;
217
223
  } catch (e) {
@@ -1559,8 +1565,16 @@ var UsageTracker = class {
1559
1565
  };
1560
1566
  if (hmacSecret) {
1561
1567
  const jsonStr = JSON.stringify(payload);
1562
- const crypto = await import("crypto");
1563
- payload.signature = crypto.createHmac("sha256", hmacSecret).update(jsonStr).digest("hex");
1568
+ try {
1569
+ const crypto = typeof window === "undefined" ? (await import(
1570
+ /* webpackIgnore: true */
1571
+ "crypto"
1572
+ )).default : null;
1573
+ if (crypto && crypto.createHmac) {
1574
+ payload.signature = crypto.createHmac("sha256", hmacSecret).update(jsonStr).digest("hex");
1575
+ }
1576
+ } catch (e) {
1577
+ }
1564
1578
  }
1565
1579
  const response = await fetch(endpoint, {
1566
1580
  method: "POST",
package/dist/index.js CHANGED
@@ -169,7 +169,13 @@ var IKHmac = class {
169
169
  const { signature, ...rest } = data;
170
170
  const payload = JSON.stringify(rest);
171
171
  try {
172
- const crypto = await import("crypto");
172
+ const crypto = typeof window === "undefined" ? (await import(
173
+ /* webpackIgnore: true */
174
+ "crypto"
175
+ )).default : null;
176
+ if (!crypto || !crypto.createHmac) {
177
+ return true;
178
+ }
173
179
  const expectedSignature = crypto.createHmac("sha256", this.secret).update(payload).digest("hex");
174
180
  return signature === expectedSignature;
175
181
  } catch (e) {
@@ -1517,8 +1523,16 @@ var UsageTracker = class {
1517
1523
  };
1518
1524
  if (hmacSecret) {
1519
1525
  const jsonStr = JSON.stringify(payload);
1520
- const crypto = await import("crypto");
1521
- payload.signature = crypto.createHmac("sha256", hmacSecret).update(jsonStr).digest("hex");
1526
+ try {
1527
+ const crypto = typeof window === "undefined" ? (await import(
1528
+ /* webpackIgnore: true */
1529
+ "crypto"
1530
+ )).default : null;
1531
+ if (crypto && crypto.createHmac) {
1532
+ payload.signature = crypto.createHmac("sha256", hmacSecret).update(jsonStr).digest("hex");
1533
+ }
1534
+ } catch (e) {
1535
+ }
1522
1536
  }
1523
1537
  const response = await fetch(endpoint, {
1524
1538
  method: "POST",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ik-firewall/core",
3
- "version": "2.3.2",
3
+ "version": "2.3.3",
4
4
  "type": "module",
5
5
  "description": "The core IK Firewall engine for semantic-driven AI optimization.",
6
6
  "main": "./dist/index.js",