@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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.10.2
4
+
5
+ - Reject blank and Python-whitespace-only primary outcome labels and harmful
6
+ score/count map keys while preserving nonblank open-ended labels verbatim.
7
+ This includes Python's separator controls, NEL, and non-ASCII spaces while
8
+ retaining U+FEFF as nonblank.
9
+
3
10
  ## 0.10.1
4
11
 
5
12
  - Reject missing, null, string, non-finite, or out-of-range response `score`
package/README.md CHANGED
@@ -35,10 +35,10 @@ This SDK is distributed as an npm package.
35
35
  npm install @silmaril-security/sdk
36
36
  ```
37
37
 
38
- Pin version 0.10.1 for reproducible installs:
38
+ Pin version 0.10.2 for reproducible installs:
39
39
 
40
40
  ```sh
41
- npm install @silmaril-security/sdk@0.10.1
41
+ npm install @silmaril-security/sdk@0.10.2
42
42
  ```
43
43
 
44
44
  Requires Node 20 or later.
package/dist/index.cjs CHANGED
@@ -1491,6 +1491,10 @@ var OUTCOME_DESCRIPTIONS = {
1491
1491
  };
1492
1492
  var PRIMARY_OUTCOME_SET = new Set(PRIMARY_OUTCOMES);
1493
1493
  var HARMFUL_OUTCOME_SET = new Set(HARMFUL_OUTCOMES);
1494
+ var PYTHON_NONBLANK = /[^\p{White_Space}\u001c-\u001f]/u;
1495
+ function isNonblankOutcomeLabel(value) {
1496
+ return typeof value === "string" && PYTHON_NONBLANK.test(value);
1497
+ }
1494
1498
  function isPrimaryOutcome(value) {
1495
1499
  return typeof value === "string" && PRIMARY_OUTCOME_SET.has(value);
1496
1500
  }
@@ -1498,13 +1502,13 @@ function isHarmfulOutcome(value) {
1498
1502
  return typeof value === "string" && HARMFUL_OUTCOME_SET.has(value);
1499
1503
  }
1500
1504
  function normalizePrimaryOutcome(value, fieldName = "primary_outcome") {
1501
- if (typeof value !== "string") {
1505
+ if (!isNonblankOutcomeLabel(value)) {
1502
1506
  throw new Error(`Firewall: invalid ${fieldName} ${JSON.stringify(value)}`);
1503
1507
  }
1504
1508
  return isPrimaryOutcome(value) ? value : value;
1505
1509
  }
1506
1510
  function normalizeHarmfulOutcome(value, fieldName = "outcome") {
1507
- if (typeof value !== "string" || value === Outcome.Benign) {
1511
+ if (!isNonblankOutcomeLabel(value) || value === Outcome.Benign) {
1508
1512
  throw new Error(`Firewall: invalid ${fieldName} ${JSON.stringify(value)}`);
1509
1513
  }
1510
1514
  return isHarmfulOutcome(value) ? value : value;
@@ -1522,7 +1526,12 @@ function normalizeNumericOutcomeMap(values, fieldName, accepts) {
1522
1526
  if (typeof value !== "number" || !accepts(value)) {
1523
1527
  throw new Error(`Firewall: invalid ${fieldName} value for ${JSON.stringify(key)}`);
1524
1528
  }
1525
- out[normalizedKey] = value;
1529
+ Object.defineProperty(out, normalizedKey, {
1530
+ value,
1531
+ enumerable: true,
1532
+ configurable: true,
1533
+ writable: true
1534
+ });
1526
1535
  }
1527
1536
  return Object.freeze(out);
1528
1537
  }
@@ -1571,7 +1580,7 @@ function validateThreshold(name, value) {
1571
1580
  }
1572
1581
 
1573
1582
  // src/firewall.ts
1574
- var SDK_VERSION = "0.10.1";
1583
+ var SDK_VERSION = "0.10.2";
1575
1584
  var DEFAULT_TIMEOUT_MS = 1e4;
1576
1585
  var DEFAULT_MAX_RETRIES = 5;
1577
1586
  var MAX_BACKOFF_SECONDS = 30;