@silmaril-security/sdk 0.10.1 → 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 +13 -0
- package/README.md +2 -2
- package/dist/index.cjs +23 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +23 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
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
|
+
|
|
9
|
+
## 0.10.2
|
|
10
|
+
|
|
11
|
+
- Reject blank and Python-whitespace-only primary outcome labels and harmful
|
|
12
|
+
score/count map keys while preserving nonblank open-ended labels verbatim.
|
|
13
|
+
This includes Python's separator controls, NEL, and non-ASCII spaces while
|
|
14
|
+
retaining U+FEFF as nonblank.
|
|
15
|
+
|
|
3
16
|
## 0.10.1
|
|
4
17
|
|
|
5
18
|
- 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.
|
|
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",
|
|
@@ -1498,13 +1510,13 @@ function isHarmfulOutcome(value) {
|
|
|
1498
1510
|
return typeof value === "string" && HARMFUL_OUTCOME_SET.has(value);
|
|
1499
1511
|
}
|
|
1500
1512
|
function normalizePrimaryOutcome(value, fieldName = "primary_outcome") {
|
|
1501
|
-
if (
|
|
1513
|
+
if (!isPythonNonblankString(value)) {
|
|
1502
1514
|
throw new Error(`Firewall: invalid ${fieldName} ${JSON.stringify(value)}`);
|
|
1503
1515
|
}
|
|
1504
1516
|
return isPrimaryOutcome(value) ? value : value;
|
|
1505
1517
|
}
|
|
1506
1518
|
function normalizeHarmfulOutcome(value, fieldName = "outcome") {
|
|
1507
|
-
if (
|
|
1519
|
+
if (!isPythonNonblankString(value) || value === Outcome.Benign) {
|
|
1508
1520
|
throw new Error(`Firewall: invalid ${fieldName} ${JSON.stringify(value)}`);
|
|
1509
1521
|
}
|
|
1510
1522
|
return isHarmfulOutcome(value) ? value : value;
|
|
@@ -1522,7 +1534,12 @@ function normalizeNumericOutcomeMap(values, fieldName, accepts) {
|
|
|
1522
1534
|
if (typeof value !== "number" || !accepts(value)) {
|
|
1523
1535
|
throw new Error(`Firewall: invalid ${fieldName} value for ${JSON.stringify(key)}`);
|
|
1524
1536
|
}
|
|
1525
|
-
out
|
|
1537
|
+
Object.defineProperty(out, normalizedKey, {
|
|
1538
|
+
value,
|
|
1539
|
+
enumerable: true,
|
|
1540
|
+
configurable: true,
|
|
1541
|
+
writable: true
|
|
1542
|
+
});
|
|
1526
1543
|
}
|
|
1527
1544
|
return Object.freeze(out);
|
|
1528
1545
|
}
|
|
@@ -1562,16 +1579,8 @@ function sanitizeText(text) {
|
|
|
1562
1579
|
return out;
|
|
1563
1580
|
}
|
|
1564
1581
|
|
|
1565
|
-
// src/validation.ts
|
|
1566
|
-
function validateThreshold(name, value) {
|
|
1567
|
-
if (typeof value !== "number" || !Number.isFinite(value) || value < 0 || value > 1) {
|
|
1568
|
-
throw new Error(`Firewall: ${name} must be a finite number between 0 and 1`);
|
|
1569
|
-
}
|
|
1570
|
-
return value;
|
|
1571
|
-
}
|
|
1572
|
-
|
|
1573
1582
|
// src/firewall.ts
|
|
1574
|
-
var SDK_VERSION = "0.10.
|
|
1583
|
+
var SDK_VERSION = "0.10.3";
|
|
1575
1584
|
var DEFAULT_TIMEOUT_MS = 1e4;
|
|
1576
1585
|
var DEFAULT_MAX_RETRIES = 5;
|
|
1577
1586
|
var MAX_BACKOFF_SECONDS = 30;
|
|
@@ -1778,12 +1787,12 @@ function governanceDecisionFromResponse(value) {
|
|
|
1778
1787
|
if (value.rule_id !== void 0 && value.rule_id !== null && typeof value.rule_id !== "string") {
|
|
1779
1788
|
throw new Error("Firewall: response governance rule_id must be a string when provided");
|
|
1780
1789
|
}
|
|
1781
|
-
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)) {
|
|
1782
1791
|
throw new Error(
|
|
1783
1792
|
"Firewall: response governance identity_revision must be a non-empty string when provided"
|
|
1784
1793
|
);
|
|
1785
1794
|
}
|
|
1786
|
-
if (value.reason !== void 0 && value.reason !== null && (
|
|
1795
|
+
if (value.reason !== void 0 && value.reason !== null && !isPythonNonblankString(value.reason)) {
|
|
1787
1796
|
throw new Error(
|
|
1788
1797
|
"Firewall: response governance reason must be a non-empty string when provided"
|
|
1789
1798
|
);
|