shield-llm 0.6.2 → 0.6.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.
@@ -1,7 +1,7 @@
1
1
  import { createRequire as __cjs_createRequire } from "module"; import { fileURLToPath as __cjs_fileURLToPath } from "url"; import { dirname as __cjs_dirname } from "path"; const __filename = __cjs_fileURLToPath(import.meta.url); const __dirname = __cjs_dirname(__filename); const require = __cjs_createRequire(import.meta.url);
2
2
 
3
3
  // package.json
4
- var version = "0.6.2";
4
+ var version = "0.6.3";
5
5
 
6
6
  // src/config/schema.ts
7
7
  import { z as z2 } from "zod";
@@ -5611,6 +5611,11 @@ async function fetchWithTimeout(url, init, timeoutMs, responseField, allowPrivat
5611
5611
  const field = responseField ?? "response";
5612
5612
  return { [field]: text };
5613
5613
  }
5614
+ if (contentType.includes("ndjson")) {
5615
+ const text = await collectNDJSON(response);
5616
+ const field = responseField ?? "response";
5617
+ return { [field]: text };
5618
+ }
5614
5619
  if (!contentType.includes("json")) {
5615
5620
  const text = await readBodyWithLimit(response);
5616
5621
  throw new HttpTargetError(
@@ -5760,6 +5765,59 @@ async function collectSSE(response) {
5760
5765
  }
5761
5766
  return result;
5762
5767
  }
5768
+ async function collectNDJSON(response) {
5769
+ if (!response.body) {
5770
+ throw new HttpTargetError("NDJSON response has no body", 0);
5771
+ }
5772
+ const reader = response.body.getReader();
5773
+ const decoder = new TextDecoder();
5774
+ let buffer = "";
5775
+ let result = "";
5776
+ let totalBytes = 0;
5777
+ const consume = (raw) => {
5778
+ const trimmed = raw.trim();
5779
+ if (!trimmed) return false;
5780
+ let parsed;
5781
+ try {
5782
+ parsed = JSON.parse(trimmed);
5783
+ } catch {
5784
+ return false;
5785
+ }
5786
+ if (!parsed || typeof parsed !== "object") return false;
5787
+ const chunk = extractSseChunk(parsed);
5788
+ if (typeof chunk === "string") result += chunk;
5789
+ return parsed.done === true;
5790
+ };
5791
+ try {
5792
+ while (true) {
5793
+ const { done, value } = await reader.read();
5794
+ if (done) break;
5795
+ totalBytes += value.byteLength;
5796
+ if (totalBytes > MAX_RESPONSE_BYTES) {
5797
+ await reader.cancel().catch(() => {
5798
+ });
5799
+ throw new HttpTargetError(
5800
+ `NDJSON stream exceeded ${MAX_RESPONSE_BYTES} bytes`,
5801
+ response.status
5802
+ );
5803
+ }
5804
+ buffer += decoder.decode(value, { stream: true });
5805
+ const lines = buffer.split("\n");
5806
+ buffer = lines.pop();
5807
+ for (const line of lines) {
5808
+ if (consume(line)) {
5809
+ await reader.cancel().catch(() => {
5810
+ });
5811
+ return result;
5812
+ }
5813
+ }
5814
+ }
5815
+ } finally {
5816
+ reader.releaseLock();
5817
+ }
5818
+ consume(buffer);
5819
+ return result;
5820
+ }
5763
5821
  var HttpTargetError = class extends Error {
5764
5822
  constructor(message, statusCode) {
5765
5823
  super(message);
package/dist/cli.js CHANGED
@@ -29,7 +29,7 @@ import {
29
29
  resolveOfflinePosition,
30
30
  summarizeAttackErrors,
31
31
  version
32
- } from "./chunk-3ZVL7ZFC.js";
32
+ } from "./chunk-LNYPVVYM.js";
33
33
 
34
34
  // src/load-env.ts
35
35
  try {
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  generatePdf,
10
10
  loadConfig,
11
11
  loadSystemPrompt
12
- } from "./chunk-3ZVL7ZFC.js";
12
+ } from "./chunk-LNYPVVYM.js";
13
13
  export {
14
14
  ConfigError,
15
15
  ConfigSchema,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shield-llm",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "description": "AI chatbot security scanner — automated red teaming for LLMs",
5
5
  "type": "module",
6
6
  "publishConfig": {