@silmaril-security/sdk 0.11.3 → 0.11.4

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,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.11.4
4
+
5
+ - Cancel the Node HTTP example on premature response closure.
6
+
3
7
  ## 0.11.3
4
8
 
5
9
  - Reject `protect()` with the caller's abort reason when the operation or output
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.11.3 for reproducible installs:
38
+ Pin version 0.11.4 for reproducible installs:
39
39
 
40
40
  ```sh
41
- npm install @silmaril-security/sdk@0.11.3
41
+ npm install @silmaril-security/sdk@0.11.4
42
42
  ```
43
43
 
44
44
  Requires Node 20 or later.
@@ -203,11 +203,16 @@ Events that belong to one conversation are not independent. Send them with
203
203
  ordered individual `classify()` calls that share `metadata.conversationId`, and
204
204
  wait for each call before sending the next event for that conversation.
205
205
 
206
- Pass a `signal` to cancel one call without touching its siblings:
206
+ Pass a `signal` to cancel one call without touching its siblings. In Node's
207
+ HTTP server, listen for the outgoing response closing before it finishes:
207
208
 
208
209
  ```ts
209
210
  const controller = new AbortController();
210
- request.on("close", () => controller.abort());
211
+ const abortIfDisconnected = () => {
212
+ if (!response.writableFinished) controller.abort();
213
+ };
214
+ response.once("close", abortIfDisconnected);
215
+ if (response.destroyed) abortIfDisconnected();
211
216
 
212
217
  try {
213
218
  const result = await fw.classify(userInput, {
@@ -220,6 +225,8 @@ try {
220
225
  return; // caller went away
221
226
  }
222
227
  throw err;
228
+ } finally {
229
+ response.off("close", abortIfDisconnected);
223
230
  }
224
231
  ```
225
232
 
package/dist/index.cjs CHANGED
@@ -1580,7 +1580,7 @@ function sanitizeText(text) {
1580
1580
  }
1581
1581
 
1582
1582
  // src/firewall.ts
1583
- var SDK_VERSION = "0.11.3";
1583
+ var SDK_VERSION = "0.11.4";
1584
1584
  var DEFAULT_TIMEOUT_MS = 1e4;
1585
1585
  var DEFAULT_MAX_RETRIES = 5;
1586
1586
  var MAX_BACKOFF_SECONDS = 30;