@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/CHANGELOG.md +6 -0
- package/README.md +2 -2
- package/dist/index.cjs +17 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +17 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.10.3
|
|
4
|
+
|
|
5
|
+
- Match Python `str.strip()` when validating optional governance
|
|
6
|
+
`identity_revision` and `reason` evidence. Omitted and null values remain
|
|
7
|
+
compatible, and accepted nonblank strings remain unmodified.
|
|
8
|
+
|
|
3
9
|
## 0.10.2
|
|
4
10
|
|
|
5
11
|
- Reject blank and Python-whitespace-only primary outcome labels and harmful
|
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.
|
|
38
|
+
Pin version 0.10.3 for reproducible installs:
|
|
39
39
|
|
|
40
40
|
```sh
|
|
41
|
-
npm install @silmaril-security/sdk@0.10.
|
|
41
|
+
npm install @silmaril-security/sdk@0.10.3
|
|
42
42
|
```
|
|
43
43
|
|
|
44
44
|
Requires Node 20 or later.
|
package/dist/index.cjs
CHANGED
|
@@ -1433,6 +1433,18 @@ init_exceptions();
|
|
|
1433
1433
|
init_hooks();
|
|
1434
1434
|
init_modes();
|
|
1435
1435
|
|
|
1436
|
+
// src/validation.ts
|
|
1437
|
+
var PYTHON_NONBLANK = /[^\p{White_Space}\u001c-\u001f]/u;
|
|
1438
|
+
function isPythonNonblankString(value) {
|
|
1439
|
+
return typeof value === "string" && PYTHON_NONBLANK.test(value);
|
|
1440
|
+
}
|
|
1441
|
+
function validateThreshold(name, value) {
|
|
1442
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value < 0 || value > 1) {
|
|
1443
|
+
throw new Error(`Firewall: ${name} must be a finite number between 0 and 1`);
|
|
1444
|
+
}
|
|
1445
|
+
return value;
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1436
1448
|
// src/outcomes.ts
|
|
1437
1449
|
var Outcome = {
|
|
1438
1450
|
Benign: "benign",
|
|
@@ -1491,10 +1503,6 @@ var OUTCOME_DESCRIPTIONS = {
|
|
|
1491
1503
|
};
|
|
1492
1504
|
var PRIMARY_OUTCOME_SET = new Set(PRIMARY_OUTCOMES);
|
|
1493
1505
|
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
|
-
}
|
|
1498
1506
|
function isPrimaryOutcome(value) {
|
|
1499
1507
|
return typeof value === "string" && PRIMARY_OUTCOME_SET.has(value);
|
|
1500
1508
|
}
|
|
@@ -1502,13 +1510,13 @@ function isHarmfulOutcome(value) {
|
|
|
1502
1510
|
return typeof value === "string" && HARMFUL_OUTCOME_SET.has(value);
|
|
1503
1511
|
}
|
|
1504
1512
|
function normalizePrimaryOutcome(value, fieldName = "primary_outcome") {
|
|
1505
|
-
if (!
|
|
1513
|
+
if (!isPythonNonblankString(value)) {
|
|
1506
1514
|
throw new Error(`Firewall: invalid ${fieldName} ${JSON.stringify(value)}`);
|
|
1507
1515
|
}
|
|
1508
1516
|
return isPrimaryOutcome(value) ? value : value;
|
|
1509
1517
|
}
|
|
1510
1518
|
function normalizeHarmfulOutcome(value, fieldName = "outcome") {
|
|
1511
|
-
if (!
|
|
1519
|
+
if (!isPythonNonblankString(value) || value === Outcome.Benign) {
|
|
1512
1520
|
throw new Error(`Firewall: invalid ${fieldName} ${JSON.stringify(value)}`);
|
|
1513
1521
|
}
|
|
1514
1522
|
return isHarmfulOutcome(value) ? value : value;
|
|
@@ -1571,16 +1579,8 @@ function sanitizeText(text) {
|
|
|
1571
1579
|
return out;
|
|
1572
1580
|
}
|
|
1573
1581
|
|
|
1574
|
-
// src/validation.ts
|
|
1575
|
-
function validateThreshold(name, value) {
|
|
1576
|
-
if (typeof value !== "number" || !Number.isFinite(value) || value < 0 || value > 1) {
|
|
1577
|
-
throw new Error(`Firewall: ${name} must be a finite number between 0 and 1`);
|
|
1578
|
-
}
|
|
1579
|
-
return value;
|
|
1580
|
-
}
|
|
1581
|
-
|
|
1582
1582
|
// src/firewall.ts
|
|
1583
|
-
var SDK_VERSION = "0.10.
|
|
1583
|
+
var SDK_VERSION = "0.10.3";
|
|
1584
1584
|
var DEFAULT_TIMEOUT_MS = 1e4;
|
|
1585
1585
|
var DEFAULT_MAX_RETRIES = 5;
|
|
1586
1586
|
var MAX_BACKOFF_SECONDS = 30;
|
|
@@ -1787,12 +1787,12 @@ function governanceDecisionFromResponse(value) {
|
|
|
1787
1787
|
if (value.rule_id !== void 0 && value.rule_id !== null && typeof value.rule_id !== "string") {
|
|
1788
1788
|
throw new Error("Firewall: response governance rule_id must be a string when provided");
|
|
1789
1789
|
}
|
|
1790
|
-
if (value.identity_revision !== void 0 && value.identity_revision !== null && (
|
|
1790
|
+
if (value.identity_revision !== void 0 && value.identity_revision !== null && !isPythonNonblankString(value.identity_revision)) {
|
|
1791
1791
|
throw new Error(
|
|
1792
1792
|
"Firewall: response governance identity_revision must be a non-empty string when provided"
|
|
1793
1793
|
);
|
|
1794
1794
|
}
|
|
1795
|
-
if (value.reason !== void 0 && value.reason !== null && (
|
|
1795
|
+
if (value.reason !== void 0 && value.reason !== null && !isPythonNonblankString(value.reason)) {
|
|
1796
1796
|
throw new Error(
|
|
1797
1797
|
"Firewall: response governance reason must be a non-empty string when provided"
|
|
1798
1798
|
);
|