@vecteur/cli 0.5.4 → 0.5.5

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/client.js +9 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vecteur/cli",
3
- "version": "0.5.4",
3
+ "version": "0.5.5",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "vecteur": "bin/vecteur.js"
package/src/client.js CHANGED
@@ -278,7 +278,7 @@ export class VecteurClient {
278
278
  this.fetchImpl = fetchImpl;
279
279
  }
280
280
 
281
- async request(method, path, { body, idempotencyKey, accept, signal } = {}) {
281
+ async request(method, path, { body, idempotencyKey, accept, acceptEncoding, signal } = {}) {
282
282
  const controller = new AbortController();
283
283
  const cancel = () => controller.abort();
284
284
  signal?.addEventListener("abort", cancel, { once: true });
@@ -316,6 +316,7 @@ export class VecteurClient {
316
316
  ...(body === undefined ? {} : { "Content-Type": "application/json" }),
317
317
  ...(idempotencyKey ? { "Idempotency-Key": idempotencyKey } : {}),
318
318
  ...(accept ? { Accept: accept } : {}),
319
+ ...(acceptEncoding ? { "Accept-Encoding": acceptEncoding } : {}),
319
320
  },
320
321
  body: body === undefined ? undefined : JSON.stringify(body),
321
322
  });
@@ -488,13 +489,19 @@ export class VecteurClient {
488
489
  }
489
490
  const query = new URLSearchParams({ project_id: projectId });
490
491
  const response = await this.request(
491
- "GET", `/api/artifacts/${encodeURIComponent(casRef)}?${query}`, { signal },
492
+ "GET", `/api/artifacts/${encodeURIComponent(casRef)}?${query}`, {
493
+ acceptEncoding: "identity", signal,
494
+ },
492
495
  );
493
496
  try {
494
497
  const contentType = response.headers.get("content-type");
495
498
  if (!Object.values(ARTIFACT_MEDIA_TYPES).includes(contentType)) {
496
499
  throw new CliError("artifact_invalid", "Server returned an undeclared artifact media type");
497
500
  }
501
+ const contentEncoding = response.headers.get("content-encoding");
502
+ if (contentEncoding && contentEncoding.toLowerCase() !== "identity") {
503
+ throw new CliError("artifact_invalid", "Server returned encoded artifact bytes");
504
+ }
498
505
  const declared = response.headers.get("content-length");
499
506
  if (declared === null || !/^(?:0|[1-9][0-9]*)$/.test(declared)
500
507
  || !Number.isSafeInteger(Number(declared))) {