@silmaril-security/sdk 0.10.1 → 0.10.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/index.js CHANGED
@@ -1438,6 +1438,10 @@ var OUTCOME_DESCRIPTIONS = {
1438
1438
  };
1439
1439
  var PRIMARY_OUTCOME_SET = new Set(PRIMARY_OUTCOMES);
1440
1440
  var HARMFUL_OUTCOME_SET = new Set(HARMFUL_OUTCOMES);
1441
+ var PYTHON_NONBLANK = /[^\p{White_Space}\u001c-\u001f]/u;
1442
+ function isNonblankOutcomeLabel(value) {
1443
+ return typeof value === "string" && PYTHON_NONBLANK.test(value);
1444
+ }
1441
1445
  function isPrimaryOutcome(value) {
1442
1446
  return typeof value === "string" && PRIMARY_OUTCOME_SET.has(value);
1443
1447
  }
@@ -1445,13 +1449,13 @@ function isHarmfulOutcome(value) {
1445
1449
  return typeof value === "string" && HARMFUL_OUTCOME_SET.has(value);
1446
1450
  }
1447
1451
  function normalizePrimaryOutcome(value, fieldName = "primary_outcome") {
1448
- if (typeof value !== "string") {
1452
+ if (!isNonblankOutcomeLabel(value)) {
1449
1453
  throw new Error(`Firewall: invalid ${fieldName} ${JSON.stringify(value)}`);
1450
1454
  }
1451
1455
  return isPrimaryOutcome(value) ? value : value;
1452
1456
  }
1453
1457
  function normalizeHarmfulOutcome(value, fieldName = "outcome") {
1454
- if (typeof value !== "string" || value === Outcome.Benign) {
1458
+ if (!isNonblankOutcomeLabel(value) || value === Outcome.Benign) {
1455
1459
  throw new Error(`Firewall: invalid ${fieldName} ${JSON.stringify(value)}`);
1456
1460
  }
1457
1461
  return isHarmfulOutcome(value) ? value : value;
@@ -1469,7 +1473,12 @@ function normalizeNumericOutcomeMap(values, fieldName, accepts) {
1469
1473
  if (typeof value !== "number" || !accepts(value)) {
1470
1474
  throw new Error(`Firewall: invalid ${fieldName} value for ${JSON.stringify(key)}`);
1471
1475
  }
1472
- out[normalizedKey] = value;
1476
+ Object.defineProperty(out, normalizedKey, {
1477
+ value,
1478
+ enumerable: true,
1479
+ configurable: true,
1480
+ writable: true
1481
+ });
1473
1482
  }
1474
1483
  return Object.freeze(out);
1475
1484
  }
@@ -1518,7 +1527,7 @@ function validateThreshold(name, value) {
1518
1527
  }
1519
1528
 
1520
1529
  // src/firewall.ts
1521
- var SDK_VERSION = "0.10.1";
1530
+ var SDK_VERSION = "0.10.2";
1522
1531
  var DEFAULT_TIMEOUT_MS = 1e4;
1523
1532
  var DEFAULT_MAX_RETRIES = 5;
1524
1533
  var MAX_BACKOFF_SECONDS = 30;