@silmaril-security/sdk 0.10.2 → 0.10.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.js CHANGED
@@ -1380,6 +1380,18 @@ init_exceptions();
1380
1380
  init_hooks();
1381
1381
  init_modes();
1382
1382
 
1383
+ // src/validation.ts
1384
+ var PYTHON_NONBLANK = /[^\p{White_Space}\u001c-\u001f]/u;
1385
+ function isPythonNonblankString(value) {
1386
+ return typeof value === "string" && PYTHON_NONBLANK.test(value);
1387
+ }
1388
+ function validateThreshold(name, value) {
1389
+ if (typeof value !== "number" || !Number.isFinite(value) || value < 0 || value > 1) {
1390
+ throw new Error(`Firewall: ${name} must be a finite number between 0 and 1`);
1391
+ }
1392
+ return value;
1393
+ }
1394
+
1383
1395
  // src/outcomes.ts
1384
1396
  var Outcome = {
1385
1397
  Benign: "benign",
@@ -1438,10 +1450,6 @@ var OUTCOME_DESCRIPTIONS = {
1438
1450
  };
1439
1451
  var PRIMARY_OUTCOME_SET = new Set(PRIMARY_OUTCOMES);
1440
1452
  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
- }
1445
1453
  function isPrimaryOutcome(value) {
1446
1454
  return typeof value === "string" && PRIMARY_OUTCOME_SET.has(value);
1447
1455
  }
@@ -1449,13 +1457,13 @@ function isHarmfulOutcome(value) {
1449
1457
  return typeof value === "string" && HARMFUL_OUTCOME_SET.has(value);
1450
1458
  }
1451
1459
  function normalizePrimaryOutcome(value, fieldName = "primary_outcome") {
1452
- if (!isNonblankOutcomeLabel(value)) {
1460
+ if (!isPythonNonblankString(value)) {
1453
1461
  throw new Error(`Firewall: invalid ${fieldName} ${JSON.stringify(value)}`);
1454
1462
  }
1455
1463
  return isPrimaryOutcome(value) ? value : value;
1456
1464
  }
1457
1465
  function normalizeHarmfulOutcome(value, fieldName = "outcome") {
1458
- if (!isNonblankOutcomeLabel(value) || value === Outcome.Benign) {
1466
+ if (!isPythonNonblankString(value) || value === Outcome.Benign) {
1459
1467
  throw new Error(`Firewall: invalid ${fieldName} ${JSON.stringify(value)}`);
1460
1468
  }
1461
1469
  return isHarmfulOutcome(value) ? value : value;
@@ -1518,16 +1526,8 @@ function sanitizeText(text) {
1518
1526
  return out;
1519
1527
  }
1520
1528
 
1521
- // src/validation.ts
1522
- function validateThreshold(name, value) {
1523
- if (typeof value !== "number" || !Number.isFinite(value) || value < 0 || value > 1) {
1524
- throw new Error(`Firewall: ${name} must be a finite number between 0 and 1`);
1525
- }
1526
- return value;
1527
- }
1528
-
1529
1529
  // src/firewall.ts
1530
- var SDK_VERSION = "0.10.2";
1530
+ var SDK_VERSION = "0.10.3";
1531
1531
  var DEFAULT_TIMEOUT_MS = 1e4;
1532
1532
  var DEFAULT_MAX_RETRIES = 5;
1533
1533
  var MAX_BACKOFF_SECONDS = 30;
@@ -1734,12 +1734,12 @@ function governanceDecisionFromResponse(value) {
1734
1734
  if (value.rule_id !== void 0 && value.rule_id !== null && typeof value.rule_id !== "string") {
1735
1735
  throw new Error("Firewall: response governance rule_id must be a string when provided");
1736
1736
  }
1737
- if (value.identity_revision !== void 0 && value.identity_revision !== null && (typeof value.identity_revision !== "string" || !value.identity_revision.trim())) {
1737
+ if (value.identity_revision !== void 0 && value.identity_revision !== null && !isPythonNonblankString(value.identity_revision)) {
1738
1738
  throw new Error(
1739
1739
  "Firewall: response governance identity_revision must be a non-empty string when provided"
1740
1740
  );
1741
1741
  }
1742
- if (value.reason !== void 0 && value.reason !== null && (typeof value.reason !== "string" || !value.reason.trim())) {
1742
+ if (value.reason !== void 0 && value.reason !== null && !isPythonNonblankString(value.reason)) {
1743
1743
  throw new Error(
1744
1744
  "Firewall: response governance reason must be a non-empty string when provided"
1745
1745
  );