@cdot65/prisma-airs-sdk 0.8.1 → 0.8.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.cjs CHANGED
@@ -481,7 +481,7 @@ var MAX_NUMBER_OF_BATCH_SCAN_OBJECTS = 5;
481
481
  var MAX_CONNECTION_POOL_SIZE = 100;
482
482
  var MAX_NUMBER_OF_RETRIES = 5;
483
483
  var HTTP_FORCE_RETRY_STATUS_CODES = [500, 502, 503, 504];
484
- var SDK_VERSION = "0.8.1";
484
+ var SDK_VERSION = "0.8.3";
485
485
  var USER_AGENT = `PAN-AIRS/${SDK_VERSION}-typescript-sdk`;
486
486
  var DEFAULT_MGMT_ENDPOINT = "https://api.sase.paloaltonetworks.com/aisec";
487
487
  var DEFAULT_TOKEN_ENDPOINT = "https://auth.apps.paloaltonetworks.com/oauth2/access_token";
@@ -800,7 +800,7 @@ async function request(spec) {
800
800
  }
801
801
  let parsed;
802
802
  try {
803
- parsed = text ? JSON.parse(text) : void 0;
803
+ parsed = text ? JSON.parse(text) : {};
804
804
  } catch {
805
805
  throw new AISecSDKException("Response body is not valid JSON", "AISEC_RESPONSE_VALIDATION" /* RESPONSE_VALIDATION */);
806
806
  }
@@ -5495,7 +5495,6 @@ var RedTeamTargetsClient = class {
5495
5495
  };
5496
5496
 
5497
5497
  // src/red-team/custom-attacks-client.ts
5498
- var import_zod33 = require("zod");
5499
5498
  var RedTeamCustomAttacksClient = class {
5500
5499
  baseUrl;
5501
5500
  auth;
@@ -5648,19 +5647,36 @@ var RedTeamCustomAttacksClient = class {
5648
5647
  }
5649
5648
  /**
5650
5649
  * Download CSV template for a prompt set.
5650
+ *
5651
+ * Bypasses `request()` because the response is `text/csv`, not JSON, and
5652
+ * `request()` unconditionally `JSON.parse()`s 2xx bodies.
5653
+ *
5651
5654
  * @param uuid - The prompt set UUID.
5652
- * @returns The CSV template content (untyped raw response from the API).
5655
+ * @returns The CSV template content as a raw string.
5653
5656
  */
5654
5657
  async downloadTemplate(uuid) {
5655
5658
  assertUuid(uuid, "prompt set uuid");
5656
- return request({
5659
+ const url = new URL(
5660
+ `${this.baseUrl.replace(/\/+$/, "")}${RED_TEAM_CUSTOM_ATTACK_PATH}/download-template/${uuid}`
5661
+ );
5662
+ const stub = {
5657
5663
  method: "GET",
5658
- baseUrl: this.baseUrl,
5659
- path: `${RED_TEAM_CUSTOM_ATTACK_PATH}/download-template/${uuid}`,
5660
- responseSchema: import_zod33.z.unknown(),
5661
- auth: this.auth,
5662
- numRetries: this.numRetries
5664
+ url,
5665
+ headers: { "User-Agent": USER_AGENT }
5666
+ };
5667
+ const prepared = await this.auth.prepare(stub);
5668
+ const response = await fetch(prepared.url.toString(), {
5669
+ method: "GET",
5670
+ headers: prepared.headers
5663
5671
  });
5672
+ const text = await response.text();
5673
+ if (!response.ok) {
5674
+ throw new AISecSDKException(
5675
+ `Download template failed (${response.status}): ${text}`,
5676
+ "AISEC_SERVER_SIDE_ERROR" /* SERVER_SIDE_ERROR */
5677
+ );
5678
+ }
5679
+ return text;
5664
5680
  }
5665
5681
  /**
5666
5682
  * Upload a CSV file of custom prompts for a prompt set.