xypriss 9.15.1 → 9.15.2

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/cjs/index.js CHANGED
@@ -18451,10 +18451,12 @@ class ProtoShield {
18451
18451
  throw new Error(`[XyPriss Validation Error] Invalid '$protoShield.mode': ${JSON.stringify(raw.mode)}. Accepted values are: 'block', 'warn', 'freeze'.`);
18452
18452
  }
18453
18453
  }
18454
- if (raw.neutralizeProto !== undefined && typeof raw.neutralizeProto !== "boolean") {
18454
+ if (raw.neutralizeProto !== undefined &&
18455
+ typeof raw.neutralizeProto !== "boolean") {
18455
18456
  throw new Error(`[XyPriss Validation Error] '$protoShield.neutralizeProto' must be a boolean. Received: ${typeof raw.neutralizeProto}`);
18456
18457
  }
18457
- if (raw.freezePrototypes !== undefined && typeof raw.freezePrototypes !== "boolean") {
18458
+ if (raw.freezePrototypes !== undefined &&
18459
+ typeof raw.freezePrototypes !== "boolean") {
18458
18460
  throw new Error(`[XyPriss Validation Error] '$protoShield.freezePrototypes' must be a boolean. Received: ${typeof raw.freezePrototypes}`);
18459
18461
  }
18460
18462
  if (raw.allowedProperties !== undefined) {
@@ -18472,8 +18474,12 @@ class ProtoShield {
18472
18474
  enabled: raw.enabled !== undefined ? raw.enabled : true,
18473
18475
  mode: raw.mode || "block",
18474
18476
  neutralizeProto: raw.neutralizeProto !== undefined ? raw.neutralizeProto : true,
18475
- freezePrototypes: raw.freezePrototypes !== undefined ? raw.freezePrototypes : false,
18476
- allowedProperties: Array.isArray(raw.allowedProperties) ? [...raw.allowedProperties] : [],
18477
+ freezePrototypes: raw.freezePrototypes !== undefined
18478
+ ? raw.freezePrototypes
18479
+ : false,
18480
+ allowedProperties: Array.isArray(raw.allowedProperties)
18481
+ ? [...raw.allowedProperties]
18482
+ : [],
18477
18483
  };
18478
18484
  }
18479
18485
  /**
@@ -18517,14 +18523,19 @@ class ProtoShield {
18517
18523
  */
18518
18524
  static applyPropertyInterception(allowed, mode) {
18519
18525
  const origDefineProperty = Object.defineProperty;
18520
- const targetPrototypes = [Object.prototype, Array.prototype, Function.prototype];
18526
+ const targetPrototypes = [
18527
+ Object.prototype,
18528
+ Array.prototype,
18529
+ Function.prototype,
18530
+ ];
18521
18531
  Object.defineProperty = function (target, propertyKey, attributes) {
18522
18532
  if (targetPrototypes.includes(target)) {
18523
18533
  const propStr = String(propertyKey);
18524
18534
  if (!allowed.has(propStr)) {
18525
18535
  const message = `[XyPriss ProtoShield] Blocked Prototype Pollution attempt! Unauthorized property '${propStr}' on ${target?.constructor?.name || "Object"}.prototype`;
18526
18536
  if (mode === "warn") {
18527
- console.warn(`\x1b[33m${message}\x1b[0m\n` + (new Error().stack || ""));
18537
+ console.warn(`\x1b[33m${message}\x1b[0m\n` +
18538
+ (new Error().stack || ""));
18528
18539
  }
18529
18540
  else {
18530
18541
  const err = new TypeError(message);
@@ -18550,11 +18561,13 @@ class ProtoShield {
18550
18561
  set(_newProto) {
18551
18562
  const message = `[XyPriss ProtoShield] Blocked Prototype Mutation attempt via '__proto__'!`;
18552
18563
  if (mode === "warn") {
18553
- console.warn(`\x1b[33m${message}\x1b[0m\n` + (new Error().stack || ""));
18564
+ console.warn(`\x1b[33m${message}\x1b[0m\n` +
18565
+ (new Error().stack || ""));
18554
18566
  }
18555
18567
  else {
18556
18568
  const err = new TypeError(message);
18557
- console.error(`\x1b[31m${message}\x1b[0m\n` + (err.stack || ""));
18569
+ console.error(`\x1b[31m${message}\x1b[0m\n` +
18570
+ (err.stack || ""));
18558
18571
  throw err;
18559
18572
  }
18560
18573
  },