@vltpkg/cli-js 1.2.0 → 1.3.1

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 (85) hide show
  1. package/{access-FTHPFPUJ.js → access-ATF2FQHI.js} +10 -10
  2. package/{bugs-QS6HQUO2.js → bugs-P26XZBIE.js} +19 -19
  3. package/{build-H27SXMAS.js → build-UABOHT3O.js} +11 -11
  4. package/{cache-IB4HMFDT.js → cache-R2SEGAZJ.js} +15 -15
  5. package/cache-unzip-src-unzip.js +31 -12
  6. package/{chunk-LD4BQJBG.js → chunk-2QA7DUYM.js} +4 -4
  7. package/{chunk-B2FK2HHL.js → chunk-3WBHQEWL.js} +57 -17
  8. package/{chunk-G5NJ7CYI.js → chunk-64VFL4WI.js} +1 -1
  9. package/{chunk-LKQ5R4VX.js → chunk-73YPXX6C.js} +4 -4
  10. package/{chunk-7KFMQ3BR.js → chunk-7AYULBUY.js} +5 -5
  11. package/{chunk-LEGPLJWK.js → chunk-B7YWFGLB.js} +5 -5
  12. package/{chunk-G5BSQ6DP.js → chunk-BP3PQ67D.js} +30 -0
  13. package/{chunk-6G7MTZGS.js → chunk-BUKZHMMK.js} +110 -21
  14. package/{chunk-YTT3UHUB.js → chunk-CRGWLUGC.js} +1 -1
  15. package/{chunk-UNWQVOLY.js → chunk-CSZTT7QN.js} +6 -6
  16. package/{chunk-GUATFMMU.js → chunk-CU752KW7.js} +1 -1
  17. package/{chunk-6A3XS52F.js → chunk-ENSGPOLR.js} +13 -0
  18. package/chunk-GVQDUMNW.js +75 -0
  19. package/{chunk-55DYW2MP.js → chunk-I6QGYSB4.js} +1 -1
  20. package/{chunk-O44Z6MAV.js → chunk-J4NHRZX6.js} +1 -1
  21. package/{chunk-SYGF27W7.js → chunk-JIQBZ2UT.js} +2 -2
  22. package/{chunk-5PP77V44.js → chunk-KH3ERNCA.js} +4 -3
  23. package/{chunk-FSZF2RSQ.js → chunk-KPMPYRBZ.js} +4 -4
  24. package/{chunk-JTUZP2OD.js → chunk-LCAH3OGR.js} +1 -1
  25. package/{chunk-3CUFJPBK.js → chunk-MC6CESRA.js} +1 -1
  26. package/{chunk-VHHLO5L6.js → chunk-OKJ4U3PP.js} +1 -1
  27. package/{chunk-NJZSCUD4.js → chunk-OOYLF23O.js} +14 -11
  28. package/{chunk-OE6VHHN4.js → chunk-P6LBJWJN.js} +78 -31
  29. package/{chunk-UQUIO7LW.js → chunk-PBBULTAG.js} +4 -3
  30. package/{chunk-BHJT53TP.js → chunk-PDWPFR5T.js} +1 -1
  31. package/{chunk-5YB6UIC3.js → chunk-QXKWSPKX.js} +58 -25
  32. package/{chunk-FOJCK57G.js → chunk-U3WCCLFD.js} +3 -3
  33. package/{chunk-QA6RE2GS.js → chunk-X2WYIUFQ.js} +57 -22
  34. package/{chunk-VE6CCH33.js → chunk-Y5PA7DVK.js} +1 -0
  35. package/{chunk-YFNQ6HZ3.js → chunk-YL5D7SKZ.js} +3 -3
  36. package/{chunk-5BD4QGW2.js → chunk-ZPVVD6CI.js} +6 -6
  37. package/{ci-XJBYXFFJ.js → ci-3R6MFNVV.js} +12 -12
  38. package/cli-package.json +2 -2
  39. package/{config-4Y46SH5K.js → config-4SAA7FD2.js} +9 -9
  40. package/{config-H2Q4ABSS.js → config-WPVXQDM5.js} +11 -11
  41. package/{create-LUYL2QI4.js → create-MS4GFBDA.js} +20 -20
  42. package/{deprecate-5ANCI2L6.js → deprecate-JTTM44ZL.js} +13 -13
  43. package/{devtools-UEMPW5GG.js → devtools-UMJUK42W.js} +2 -2
  44. package/{dist-tag-SD2CRWIL.js → dist-tag-HJEVOOH3.js} +10 -10
  45. package/{docs-B6LVNWTP.js → docs-6OIBQSV6.js} +19 -19
  46. package/{exec-CJ5KQA72.js → exec-LCWL6Z3E.js} +20 -20
  47. package/{exec-cache-EE7DAOW2.js → exec-cache-6UBB7RI2.js} +18 -18
  48. package/{exec-local-HT3VBN6S.js → exec-local-C7MPFSOE.js} +17 -17
  49. package/{help-GZ44WYDS.js → help-DC77D3YW.js} +4 -4
  50. package/{init-HVXRXFVY.js → init-B6G7COKW.js} +12 -12
  51. package/{install-E2C7EE6P.js → install-LJPM2XSF.js} +18 -18
  52. package/{list-V4V6SHJP.js → list-4KT3WIIG.js} +20 -20
  53. package/{login-VRFV7MCE.js → login-CFYSVNFH.js} +14 -14
  54. package/{logout-SU75R7BN.js → logout-5ZUJHYWI.js} +10 -10
  55. package/{pack-IVGKUXTL.js → pack-YP5WBIT6.js} +13 -13
  56. package/package.json +1 -1
  57. package/{ping-WB222SDT.js → ping-LLMQAG3Y.js} +10 -10
  58. package/{pkg-LAAFNONA.js → pkg-QTMOXWRT.js} +13 -13
  59. package/{profile-P3AVHRDI.js → profile-IA3ELAPB.js} +10 -10
  60. package/{publish-IUNB3KH5.js → publish-QSIXKUCZ.js} +36 -21
  61. package/{query-XCN55INS.js → query-KHXMK2ED.js} +20 -20
  62. package/{registry-QQLWJHJI.js → registry-MXAA4HVJ.js} +5 -5
  63. package/registry-client-src-revalidate.js +76 -30
  64. package/{repo-BQDWUCX5.js → repo-XKG2HZ46.js} +19 -19
  65. package/{reporter-5BVUNWQ6.js → reporter-47XFGNJH.js} +75 -75
  66. package/{run-QT7DX243.js → run-3OEGBMSR.js} +17 -17
  67. package/{run-exec-XYUI7GLN.js → run-exec-IH5YQF4G.js} +17 -17
  68. package/security-archive-src-update-expired.js +1 -1
  69. package/{setup-CXDJXRAG.js → setup-LRR3VSGV.js} +17 -17
  70. package/{src-OKMGXMAD.js → src-EJSVFFXB.js} +24 -14
  71. package/{src-UBAERP25.js → src-N3QY4ITW.js} +16 -16
  72. package/{src-2BUT4WYP.js → src-PKFKIVVK.js} +6 -6
  73. package/{token-CBOK6DMT.js → token-UBMP2WBT.js} +10 -10
  74. package/{uninstall-27VP46KJ.js → uninstall-4F4QIOAW.js} +14 -14
  75. package/{unpublish-F4637OQX.js → unpublish-JPDDQZXF.js} +10 -10
  76. package/{update-NGWLJJ22.js → update-CVJFMZOK.js} +17 -17
  77. package/{version-WPD2KNVC.js → version-I7K3J2O2.js} +12 -12
  78. package/{view-YKFTRRPD.js → view-G5O4ZBLM.js} +11 -11
  79. package/vlr.js +1 -1
  80. package/vlrx.js +1 -1
  81. package/vlt.js +1 -1
  82. package/vlx.js +1 -1
  83. package/vlxl.js +1 -1
  84. package/{whoami-I5Q6RTAP.js → whoami-NG7XVRAL.js} +10 -10
  85. package/chunk-SPRVRSEL.js +0 -75
@@ -15,12 +15,13 @@ import {
15
15
  import {
16
16
  assertOk,
17
17
  registryErrorMessage,
18
+ statusText,
18
19
  storeRoot,
19
20
  tokenRefusal
20
- } from "./chunk-UQUIO7LW.js";
21
+ } from "./chunk-PBBULTAG.js";
21
22
  import {
22
23
  userAgent
23
- } from "./chunk-JTUZP2OD.js";
24
+ } from "./chunk-LCAH3OGR.js";
24
25
  import {
25
26
  I,
26
27
  logRequest
@@ -30,12 +31,12 @@ import {
30
31
  } from "./chunk-XNLSTHDK.js";
31
32
  import {
32
33
  rimraf
33
- } from "./chunk-BHJT53TP.js";
34
+ } from "./chunk-PDWPFR5T.js";
34
35
  import {
35
36
  asError,
36
37
  integrityHex,
37
38
  integrityRE
38
- } from "./chunk-G5BSQ6DP.js";
39
+ } from "./chunk-BP3PQ67D.js";
39
40
  import {
40
41
  error
41
42
  } from "./chunk-WZWDS3W4.js";
@@ -2323,14 +2324,14 @@ var require_request = __commonJS({
2323
2324
  onResponseStarted() {
2324
2325
  return this[kHandler].onResponseStarted?.();
2325
2326
  }
2326
- onHeaders(statusCode, headers, resume, statusText) {
2327
+ onHeaders(statusCode, headers, resume, statusText2) {
2327
2328
  assert(!this.aborted);
2328
2329
  assert(!this.completed);
2329
2330
  if (channels.headers.hasSubscribers) {
2330
- channels.headers.publish({ request: this, response: { statusCode, headers, statusText } });
2331
+ channels.headers.publish({ request: this, response: { statusCode, headers, statusText: statusText2 } });
2331
2332
  }
2332
2333
  try {
2333
- return this[kHandler].onHeaders(statusCode, headers, resume, statusText);
2334
+ return this[kHandler].onHeaders(statusCode, headers, resume, statusText2);
2334
2335
  } catch (err) {
2335
2336
  this.abort(err);
2336
2337
  }
@@ -5083,9 +5084,9 @@ var require_util2 = __commonJS({
5083
5084
  function isErrorLike(object) {
5084
5085
  return object instanceof Error || (object?.constructor?.name === "Error" || object?.constructor?.name === "DOMException");
5085
5086
  }
5086
- function isValidReasonPhrase(statusText) {
5087
- for (let i = 0; i < statusText.length; ++i) {
5088
- const c = statusText.charCodeAt(i);
5087
+ function isValidReasonPhrase(statusText2) {
5088
+ for (let i = 0; i < statusText2.length; ++i) {
5089
+ const c = statusText2.charCodeAt(i);
5089
5090
  if (!(c === 9 || // HTAB
5090
5091
  c >= 32 && c <= 126 || // SP / VCHAR
5091
5092
  c >= 128 && c <= 255)) {
@@ -7040,7 +7041,7 @@ var require_client_h1 = __commonJS({
7040
7041
  * @returns {number}
7041
7042
  */
7042
7043
  onHeadersComplete(statusCode, upgrade, shouldKeepAlive) {
7043
- const { client, socket, headers, statusText } = this;
7044
+ const { client, socket, headers, statusText: statusText2 } = this;
7044
7045
  if (socket.destroyed) {
7045
7046
  return -1;
7046
7047
  }
@@ -7105,7 +7106,7 @@ var require_client_h1 = __commonJS({
7105
7106
  } else {
7106
7107
  socket[kReset] = true;
7107
7108
  }
7108
- const pause = request2.onHeaders(statusCode, headers, this.resume, statusText) === false;
7109
+ const pause = request2.onHeaders(statusCode, headers, this.resume, statusText2) === false;
7109
7110
  if (request2.aborted) {
7110
7111
  return -1;
7111
7112
  }
@@ -12603,7 +12604,7 @@ var require_mock_utils = __commonJS({
12603
12604
  kTotalDispatchCount
12604
12605
  } = require_mock_symbols();
12605
12606
  var { serializePathWithQuery } = require_util();
12606
- var { STATUS_CODES: STATUS_CODES2 } = __require("node:http");
12607
+ var { STATUS_CODES } = __require("node:http");
12607
12608
  var {
12608
12609
  types: {
12609
12610
  isPromise
@@ -12811,7 +12812,7 @@ var require_mock_utils = __commonJS({
12811
12812
  return result;
12812
12813
  }
12813
12814
  function getStatusText(statusCode) {
12814
- return STATUS_CODES2[statusCode] || "unknown";
12815
+ return STATUS_CODES[statusCode] || "unknown";
12815
12816
  }
12816
12817
  async function getResponse(body) {
12817
12818
  const buffers = [];
@@ -20417,7 +20418,7 @@ var require_fetch = __commonJS({
20417
20418
  var { dataURLProcessor, serializeAMimeType, minimizeSupportedMimeType } = require_data_url();
20418
20419
  var { getGlobalDispatcher } = require_global2();
20419
20420
  var { webidl } = require_webidl();
20420
- var { STATUS_CODES: STATUS_CODES2 } = __require("node:http");
20421
+ var { STATUS_CODES } = __require("node:http");
20421
20422
  var { bytesMatch } = require_subresource_integrity();
20422
20423
  var { createDeferredPromise } = require_promise();
20423
20424
  var { isomorphicEncode } = require_infra();
@@ -21210,13 +21211,13 @@ var require_fetch = __commonJS({
21210
21211
  })();
21211
21212
  }
21212
21213
  try {
21213
- const { body, status, statusText, headersList, socket } = await dispatch({ body: requestBody });
21214
+ const { body, status, statusText: statusText2, headersList, socket } = await dispatch({ body: requestBody });
21214
21215
  if (socket) {
21215
- response = makeResponse({ status, statusText, headersList, socket });
21216
+ response = makeResponse({ status, statusText: statusText2, headersList, socket });
21216
21217
  } else {
21217
21218
  const iterator = body[Symbol.asyncIterator]();
21218
21219
  fetchParams.controller.next = () => iterator.next();
21219
- response = makeResponse({ status, statusText, headersList });
21220
+ response = makeResponse({ status, statusText: statusText2, headersList });
21220
21221
  }
21221
21222
  } catch (err) {
21222
21223
  if (err.name === "AbortError") {
@@ -21338,7 +21339,7 @@ var require_fetch = __commonJS({
21338
21339
  onResponseStarted() {
21339
21340
  timingInfo.finalNetworkResponseStartTime = coarsenedSharedCurrentTime(fetchParams.crossOriginIsolatedCapability);
21340
21341
  },
21341
- onHeaders(status, rawHeaders, resume, statusText) {
21342
+ onHeaders(status, rawHeaders, resume, statusText2) {
21342
21343
  if (status < 200) {
21343
21344
  return false;
21344
21345
  }
@@ -21401,7 +21402,7 @@ var require_fetch = __commonJS({
21401
21402
  const onError = this.onError.bind(this);
21402
21403
  resolve5({
21403
21404
  status,
21404
- statusText,
21405
+ statusText: statusText2,
21405
21406
  headersList,
21406
21407
  body: decoders.length ? pipeline(this.body, ...decoders, (err) => {
21407
21408
  if (err) {
@@ -21454,7 +21455,7 @@ var require_fetch = __commonJS({
21454
21455
  }
21455
21456
  resolve5({
21456
21457
  status,
21457
- statusText: STATUS_CODES2[status],
21458
+ statusText: STATUS_CODES[status],
21458
21459
  headersList,
21459
21460
  socket
21460
21461
  });
@@ -21478,7 +21479,7 @@ var require_fetch = __commonJS({
21478
21479
  }
21479
21480
  resolve5({
21480
21481
  status,
21481
- statusText: STATUS_CODES2[status],
21482
+ statusText: STATUS_CODES[status],
21482
21483
  headersList,
21483
21484
  socket
21484
21485
  });
@@ -26149,8 +26150,7 @@ var handleBeforeExit = () => {
26149
26150
  // ../../src/registry-client/src/index.ts
26150
26151
  var import_undici3 = __toESM(require_undici(), 1);
26151
26152
  import { randomUUID } from "node:crypto";
26152
- import { readFileSync as readFileSync2 } from "node:fs";
26153
- import { STATUS_CODES } from "node:http";
26153
+ import { closeSync, openSync, readFileSync as readFileSync2, readSync } from "node:fs";
26154
26154
  import { availableParallelism } from "node:os";
26155
26155
  import { dirname as dirname3, resolve as resolve4 } from "node:path";
26156
26156
  import { setTimeout as setTimeout2 } from "node:timers/promises";
@@ -26937,10 +26937,19 @@ var CacheEntry = class _CacheEntry {
26937
26937
  * i.e. a tarball the global store can be built from.
26938
26938
  */
26939
26939
  static isTarballEntry(buffer) {
26940
+ return !!_CacheEntry.tarballIntegrity(buffer);
26941
+ }
26942
+ /**
26943
+ * The hash recorded on such an entry, or undefined if this is not one.
26944
+ * {@link isTarballEntry} is built on this, and both only need the head.
26945
+ */
26946
+ static tarballIntegrity(buffer) {
26940
26947
  const parsed = _CacheEntry.#parseHead(buffer);
26941
- if (parsed?.statusCode !== 200 || !parsed.integrity) return false;
26948
+ if (parsed?.statusCode !== 200 || !parsed.integrity) {
26949
+ return void 0;
26950
+ }
26942
26951
  const ct = getRawHeader(parsed.headers, "content-type");
26943
- return !ct || !/\bjson\b/.test(getDecodedValue(ct));
26952
+ return !ct || !/\bjson\b/.test(getDecodedValue(ct)) ? parsed.integrity : void 0;
26944
26953
  }
26945
26954
  /**
26946
26955
  * Encode status + headers (no body) as they appear at the start of
@@ -27480,13 +27489,13 @@ var exchangeToken = async (idToken, packageName, registry) => {
27480
27489
  // ../../src/registry-client/src/index.ts
27481
27490
  var log3 = (msg) => console.error(msg);
27482
27491
  var isCacheableMethod = (m) => m === "GET" || m === "HEAD";
27492
+ var maxHeadSize = 1024 * 1024;
27483
27493
  var cacheKey = (method, url) => `${method !== "GET" ? method + " " : ""}${url}`;
27484
27494
  var agentOptions = {
27485
27495
  bodyTimeout: 6e5,
27486
27496
  headersTimeout: 6e5,
27487
27497
  keepAliveMaxTimeout: 12e5,
27488
27498
  keepAliveTimeout: 6e5,
27489
- keepAliveTimeoutThreshold: 3e4,
27490
27499
  connect: {
27491
27500
  timeout: 6e5,
27492
27501
  keepAlive: true,
@@ -27571,7 +27580,7 @@ var RegistryClient = class {
27571
27580
  }
27572
27581
  } catch {
27573
27582
  }
27574
- const status = STATUS_CODES[statusCode];
27583
+ const status = statusText(statusCode);
27575
27584
  throw error(
27576
27585
  `Failed to fetch paginated results: ${statusCode}${status ? ` ${status}` : ""}${typeof detail === "string" && detail ? `: ${detail}` : ""}`,
27577
27586
  { code: "EREQUEST", status: statusCode, url: String(url) }
@@ -27688,7 +27697,7 @@ var RegistryClient = class {
27688
27697
  }
27689
27698
  }
27690
27699
  const { statusCode } = response;
27691
- const status = STATUS_CODES[statusCode];
27700
+ const status = statusText(statusCode);
27692
27701
  throw error(
27693
27702
  `Failed to perform web login: ${statusCode}${status ? ` ${status}` : ""}`,
27694
27703
  {
@@ -27767,6 +27776,44 @@ var RegistryClient = class {
27767
27776
  response
27768
27777
  });
27769
27778
  }
27779
+ /**
27780
+ * The hash the cache recorded for `url`. This reads only the entry's
27781
+ * head, which is about a kilobyte, rather than the body, which can be a
27782
+ * megabyte. A caller that is about to look the package up in the global
27783
+ * store needs nothing else, and if the store misses it can still read
27784
+ * the body afterwards.
27785
+ *
27786
+ * Returns undefined if there is no entry, or if the entry is not a
27787
+ * tarball. This never reads the body, so if `cache-unzip` rewrote the
27788
+ * entry underneath us the worst case is a stale hash. That misses in the
27789
+ * store; it cannot return the wrong bytes.
27790
+ */
27791
+ cachedIntegrity(url, options = {}) {
27792
+ const { method = "GET" } = options;
27793
+ try {
27794
+ const key = cacheKey(
27795
+ method,
27796
+ typeof url === "string" ? new URL(url) : url
27797
+ );
27798
+ if (this.cache.peek(key)) return void 0;
27799
+ const fd = openSync(this.cache.path(key), "r");
27800
+ try {
27801
+ const size = Buffer.allocUnsafe(4);
27802
+ if (readSync(fd, size, 0, 4, 0) < 4) return void 0;
27803
+ const headSize = size.readUInt32BE(0);
27804
+ if (headSize < 7 || headSize > maxHeadSize) return void 0;
27805
+ const head = Buffer.allocUnsafe(headSize);
27806
+ if (readSync(fd, head, 0, headSize, 0) < headSize) {
27807
+ return void 0;
27808
+ }
27809
+ return CacheEntry.tarballIntegrity(head);
27810
+ } finally {
27811
+ closeSync(fd);
27812
+ }
27813
+ } catch {
27814
+ }
27815
+ return void 0;
27816
+ }
27770
27817
  /**
27771
27818
  * Read a valid cached non-JSON body straight off disk, bypassing the
27772
27819
  * in-memory cache LRU so that a tarball is never held in it.
@@ -27795,7 +27842,7 @@ var RegistryClient = class {
27795
27842
  if (i) paths.add(i);
27796
27843
  } catch {
27797
27844
  }
27798
- paths.add(this.cache.path(key));
27845
+ if (!integrity) paths.add(this.cache.path(key));
27799
27846
  for (const path of paths) {
27800
27847
  let buf;
27801
27848
  try {
@@ -27938,7 +27985,7 @@ var RegistryClient = class {
27938
27985
  );
27939
27986
  if (!trustIntegrity && !result.fromCache) {
27940
27987
  result.deleteHeader("integrity");
27941
- if (result.isGzip) result.checkIntegrity({ url });
27988
+ if (result.statusCode === 200) result.checkIntegrity({ url });
27942
27989
  }
27943
27990
  if (verifyDigest && !integrity && !result.fromCache && result.statusCode === 200) {
27944
27991
  result.checkDigest(verifyDigest === "required", { url });
@@ -12,13 +12,13 @@ var require = _vlt_createRequire(import.meta.filename);
12
12
  import {
13
13
  asError,
14
14
  isObject
15
- } from "./chunk-G5BSQ6DP.js";
15
+ } from "./chunk-BP3PQ67D.js";
16
16
  import {
17
17
  error
18
18
  } from "./chunk-WZWDS3W4.js";
19
19
 
20
20
  // ../../src/registry-client/src/registry-error.ts
21
- import { STATUS_CODES } from "node:http";
21
+ var statusText = (code) => process.getBuiltinModule("node:http").STATUS_CODES[code];
22
22
  var MAX_DETAIL_LENGTH = 512;
23
23
  var truncate = (s) => s.length <= MAX_DETAIL_LENGTH ? s : `${s.slice(0, MAX_DETAIL_LENGTH - 1)}\u2026`;
24
24
  var isHTML = (s) => /^\s*(<!doctype\s+html|<html\b)/i.test(s);
@@ -42,7 +42,7 @@ var detailFromJSON = (text) => {
42
42
  return void 0;
43
43
  };
44
44
  var registryErrorMessage = (response) => {
45
- const statusMessage = STATUS_CODES[response.statusCode];
45
+ const statusMessage = statusText(response.statusCode);
46
46
  const status = `${response.statusCode}${statusMessage ? ` ${statusMessage}` : ""}`;
47
47
  let text;
48
48
  try {
@@ -161,6 +161,7 @@ import { resolve } from "node:path";
161
161
  var storeRoot = (cache) => resolve(cache, "store", "v1");
162
162
 
163
163
  export {
164
+ statusText,
164
165
  registryErrorMessage,
165
166
  tokenRefusal,
166
167
  tokenRefusalAdvice,
@@ -12,7 +12,7 @@ var require = _vlt_createRequire(import.meta.filename);
12
12
  import {
13
13
  Ze,
14
14
  ts
15
- } from "./chunk-VE6CCH33.js";
15
+ } from "./chunk-Y5PA7DVK.js";
16
16
 
17
17
  // ../../node_modules/.vlt/~npm~rimraf@6.1.3/node_modules/rimraf/dist/esm/opt-arg.js
18
18
  var typeOrUndef = (val, t) => typeof val === "undefined" || typeof val === t;
@@ -20,15 +20,15 @@ import {
20
20
  pickManifest,
21
21
  resolve,
22
22
  revs
23
- } from "./chunk-6G7MTZGS.js";
23
+ } from "./chunk-BUKZHMMK.js";
24
24
  import {
25
25
  Spec
26
- } from "./chunk-G5NJ7CYI.js";
26
+ } from "./chunk-64VFL4WI.js";
27
27
  import {
28
28
  registryErrorMessage,
29
29
  storeRoot,
30
30
  tokenRefusalAdvice
31
- } from "./chunk-UQUIO7LW.js";
31
+ } from "./chunk-PBBULTAG.js";
32
32
  import {
33
33
  logRequest
34
34
  } from "./chunk-U7TEQCBN.js";
@@ -37,8 +37,10 @@ import {
37
37
  } from "./chunk-XNLSTHDK.js";
38
38
  import {
39
39
  asPackument,
40
- integrityHex
41
- } from "./chunk-G5BSQ6DP.js";
40
+ brotliTarballUrl,
41
+ integrityHex,
42
+ tarballFormat
43
+ } from "./chunk-BP3PQ67D.js";
42
44
  import {
43
45
  error
44
46
  } from "./chunk-WZWDS3W4.js";
@@ -204,7 +206,7 @@ var PackageInfoClient = class {
204
206
  #tarPoolPromise;
205
207
  async getRegistryClient() {
206
208
  if (this.#registryClient) return this.#registryClient;
207
- this.#registryClientPromise ??= import("./src-2BUT4WYP.js").then(({ RegistryClient }) => {
209
+ this.#registryClientPromise ??= import("./src-PKFKIVVK.js").then(({ RegistryClient }) => {
208
210
  this.#registryClient = new RegistryClient(this.options);
209
211
  return this.#registryClient;
210
212
  });
@@ -244,7 +246,7 @@ var PackageInfoClient = class {
244
246
  }
245
247
  async getTarPool() {
246
248
  if (this.#tarPool) return this.#tarPool;
247
- this.#tarPoolPromise ??= import("./src-OKMGXMAD.js").then(
249
+ this.#tarPoolPromise ??= import("./src-EJSVFFXB.js").then(
248
250
  ({ Pool }) => {
249
251
  this.#tarPool = new Pool();
250
252
  return this.#tarPool;
@@ -252,6 +254,18 @@ var PackageInfoClient = class {
252
254
  );
253
255
  return this.#tarPoolPromise;
254
256
  }
257
+ /**
258
+ * A version's Brotli (`.tar.br`) alternate: its absolute URL, plus its
259
+ * hash if the registry sent one. Returns undefined if the version has no
260
+ * alternate, if it has one this client does not use (see
261
+ * {@link brotliTarballUrl}), or if `--no-brotli-tarballs` is set.
262
+ * `dist.tarball` is already absolute by this point; see
263
+ * `absolutizeTarballs`.
264
+ */
265
+ #brotliTarball(tarball, alternates) {
266
+ if (this.options["brotli-tarballs"] === false) return void 0;
267
+ return brotliTarballUrl(tarball, alternates);
268
+ }
255
269
  constructor(options = {}) {
256
270
  this.options = options;
257
271
  this.#projectRoot = options.projectRoot || process.cwd();
@@ -286,8 +300,13 @@ var PackageInfoClient = class {
286
300
  installScripts = false
287
301
  } = options;
288
302
  const f = spec.final;
289
- const alreadyResolved = !!(integrity && resolved);
290
- const r = alreadyResolved ? { resolved, integrity, spec } : await this.resolve(spec, options);
303
+ const brotli = !!resolved && tarballFormat(resolved) === "brotli";
304
+ const r = resolved && (integrity || brotli) ? {
305
+ resolved,
306
+ integrity,
307
+ spec,
308
+ ...brotli && !integrity ? { digestRequired: true } : {}
309
+ } : await this.resolve(spec, options);
291
310
  switch (f.type) {
292
311
  case "git": {
293
312
  const {
@@ -322,8 +341,14 @@ var PackageInfoClient = class {
322
341
  }
323
342
  case "registry": {
324
343
  const pool = await this.getTarPool();
325
- const hex = f.type === "registry" && this.#storeLinker !== "unpack" ? integrityHex(r.integrity) : void 0;
344
+ const format = tarballFormat(r.resolved);
345
+ const storeOn = f.type === "registry" && this.#storeLinker !== "unpack";
326
346
  const copy = this.#storeLinker === "copy" || installScripts;
347
+ const hex = !storeOn ? void 0 : r.integrity ? integrityHex(r.integrity) : integrityHex(
348
+ (await this.getRegistryClient()).cachedIntegrity(
349
+ r.resolved
350
+ )
351
+ );
327
352
  if (hex) {
328
353
  if (debug.enabled && !this.#storeHitRateLogged) {
329
354
  this.#storeHitRateLogged = true;
@@ -353,10 +378,10 @@ var PackageInfoClient = class {
353
378
  });
354
379
  if (cached) {
355
380
  try {
356
- await pool.unpack(cached.body, target);
381
+ await pool.unpack(cached.body, target, format);
357
382
  logRequest(r.resolved, "cache");
358
383
  r.integrity ??= cached.integrity;
359
- if (hex || cached.gzip) {
384
+ if (storeOn || cached.gzip) {
360
385
  rc.queueForStore(cached.key, r.integrity);
361
386
  }
362
387
  return r;
@@ -387,7 +412,8 @@ var PackageInfoClient = class {
387
412
  }
388
413
  );
389
414
  }
390
- if (!trustIntegrity && response.checkIntegrity({ spec, url: resolved })) {
415
+ const verified = !trustIntegrity && response.checkIntegrity({ spec, url: resolved });
416
+ if (verified) {
391
417
  this.#trustedIntegrities.set(
392
418
  r.resolved,
393
419
  response.integrity
@@ -395,7 +421,7 @@ var PackageInfoClient = class {
395
421
  }
396
422
  const buf2 = response.buffer();
397
423
  if (r.integrity) {
398
- if (!fromLockfile && !response.fromCache) {
424
+ if (!verified && !fromLockfile && !response.fromCache) {
399
425
  const hash = createHash("sha512");
400
426
  hash.update(buf2);
401
427
  const computed = `sha512-${hash.digest("base64")}`;
@@ -427,7 +453,7 @@ var PackageInfoClient = class {
427
453
  }
428
454
  }
429
455
  try {
430
- await (await this.getTarPool()).unpack(buf, target);
456
+ await pool.unpack(buf, target, format);
431
457
  } catch (er) {
432
458
  throw this.#resolveError(
433
459
  spec,
@@ -627,11 +653,12 @@ var PackageInfoClient = class {
627
653
  { response, url: tarball }
628
654
  );
629
655
  }
630
- if (!trustIntegrity && response.checkIntegrity({ spec, url: tarball })) {
656
+ const verified = !trustIntegrity && response.checkIntegrity({ spec, url: tarball });
657
+ if (verified) {
631
658
  this.#trustedIntegrities.set(tarball, response.integrity);
632
659
  }
633
660
  const buf = response.buffer();
634
- if (integrity && !response.fromCache) {
661
+ if (integrity && !verified && !response.fromCache) {
635
662
  const hash = createHash("sha512");
636
663
  hash.update(buf);
637
664
  const computed = `sha512-${hash.digest("base64")}`;
@@ -1027,15 +1054,21 @@ var PackageInfoClient = class {
1027
1054
  case "registry": {
1028
1055
  const mani = await this.manifest(spec, options);
1029
1056
  if (mani.dist) {
1030
- const { integrity, tarball, signatures } = mani.dist;
1057
+ const { integrity, tarball, signatures, alternates } = mani.dist;
1031
1058
  if (tarball) {
1032
- const r = {
1033
- resolved: tarball,
1034
- integrity,
1035
- signatures,
1036
- spec
1037
- };
1038
- if (!integrity && this.#vltPackuments.has(`${f.registry}${f.name}`)) {
1059
+ const brotli = this.#brotliTarball(tarball, alternates);
1060
+ const r = brotli ? {
1061
+ resolved: brotli.tarball,
1062
+ spec,
1063
+ // Pin the alternate's own hash if the registry sent
1064
+ // one. That also means we can look the package up in
1065
+ // the global store before downloading it. If there is
1066
+ // no hash, the Repr-Digest header is the only check we
1067
+ // get, so require it instead of treating it as
1068
+ // optional.
1069
+ ...brotli.integrity ? { integrity: brotli.integrity } : { digestRequired: true }
1070
+ } : { resolved: tarball, integrity, signatures, spec };
1071
+ if (!brotli && !integrity && this.#vltPackuments.has(`${f.registry}${f.name}`)) {
1039
1072
  r.digestRequired = true;
1040
1073
  }
1041
1074
  this.#resolutions.set(memoKey, r);
@@ -13,10 +13,10 @@ import {
13
13
  asDepID,
14
14
  baseDepID,
15
15
  splitDepID
16
- } from "./chunk-SYGF27W7.js";
16
+ } from "./chunk-JIQBZ2UT.js";
17
17
  import {
18
18
  userAgent
19
- } from "./chunk-JTUZP2OD.js";
19
+ } from "./chunk-LCAH3OGR.js";
20
20
  import {
21
21
  I
22
22
  } from "./chunk-U7TEQCBN.js";
@@ -25,7 +25,7 @@ import {
25
25
  } from "./chunk-XNLSTHDK.js";
26
26
  import {
27
27
  defaultRegistryName
28
- } from "./chunk-G5BSQ6DP.js";
28
+ } from "./chunk-BP3PQ67D.js";
29
29
  import {
30
30
  error
31
31
  } from "./chunk-WZWDS3W4.js";
@@ -12,11 +12,11 @@ var require = _vlt_createRequire(import.meta.filename);
12
12
  import {
13
13
  rimraf,
14
14
  rimrafSync
15
- } from "./chunk-BHJT53TP.js";
15
+ } from "./chunk-PDWPFR5T.js";
16
16
  import {
17
17
  isManifest,
18
18
  normalizeBinPaths
19
- } from "./chunk-G5BSQ6DP.js";
19
+ } from "./chunk-BP3PQ67D.js";
20
20
  import {
21
21
  error
22
22
  } from "./chunk-WZWDS3W4.js";
@@ -87,7 +87,13 @@ import {
87
87
  statSync,
88
88
  writeFileSync
89
89
  } from "node:fs";
90
- import { lstat, mkdir, rename, writeFile } from "node:fs/promises";
90
+ import {
91
+ lstat,
92
+ mkdir,
93
+ readFile,
94
+ rename,
95
+ writeFile
96
+ } from "node:fs/promises";
91
97
  import {
92
98
  basename as basename2,
93
99
  dirname,
@@ -590,7 +596,12 @@ var parseKVLine = (set, line) => {
590
596
  };
591
597
 
592
598
  // ../../src/tar/src/unpack.ts
593
- import { unzip as unzipCB, unzipSync as unzipSyncCB } from "node:zlib";
599
+ import {
600
+ brotliDecompress as brotliCB,
601
+ brotliDecompressSync as brotliSyncCB,
602
+ unzip as unzipCB,
603
+ unzipSync as unzipSyncCB
604
+ } from "node:zlib";
594
605
 
595
606
  // ../../src/tar/src/find-tar-dir.ts
596
607
  var findTarDir = (path, tarDir) => {
@@ -639,6 +650,27 @@ var unzipSync = (input) => {
639
650
  throw unzipError(er, input.length, max);
640
651
  }
641
652
  };
653
+ var isGzip = (b) => b[0] === 31 && b[1] === 139;
654
+ var brotli = async (input) => {
655
+ const max = unzipMax(input.length);
656
+ return new Promise(
657
+ (res, rej) => brotliCB(
658
+ input,
659
+ { maxOutputLength: max },
660
+ (er, result) => er ? rej(unzipError(er, input.length, max)) : res(result)
661
+ )
662
+ );
663
+ };
664
+ var brotliSync = (input) => {
665
+ const max = unzipMax(input.length);
666
+ try {
667
+ return brotliSyncCB(input, { maxOutputLength: max });
668
+ } catch (er) {
669
+ throw unzipError(er, input.length, max);
670
+ }
671
+ };
672
+ var decompress = async (input, format) => format === "brotli" ? brotli(input) : isGzip(input) ? unzip(input) : input;
673
+ var decompressSync = (input, format) => format === "brotli" ? brotliSync(input) : isGzip(input) ? unzipSync(input) : input;
642
674
  var exists = async (path) => {
643
675
  try {
644
676
  await lstat(path);
@@ -737,24 +769,26 @@ var write = async (path, body, executable = false) => {
737
769
  mode: executable ? 511 : 438
738
770
  });
739
771
  };
740
- var unpack = async (tarData, target) => {
741
- const isGzip = tarData[0] === 31 && tarData[1] === 139;
742
- await unpackUnzipped(
743
- isGzip ? await unzip(tarData) : tarData,
744
- target
745
- );
772
+ var unpack = async (tarData, target, format) => {
773
+ await unpackUnzipped(await decompress(tarData, format), target);
746
774
  };
747
- var unpackSync = (tarData, target) => {
748
- const isGzip = tarData[0] === 31 && tarData[1] === 139;
749
- unpackUnzippedSync(isGzip ? unzipSync(tarData) : tarData, target);
775
+ var unpackSync = (tarData, target, format) => {
776
+ unpackUnzippedSync(decompressSync(tarData, format), target);
750
777
  };
751
- var unpackFileSync = (file, target, offset = 0) => unpackSync(readFileSync2(file).subarray(offset), target);
778
+ var unpackParallel = async (tarData, target, format) => {
779
+ unpackUnzippedSync(await decompress(tarData, format), target);
780
+ };
781
+ var unpackFileParallel = async (file, target, offset = 0, format) => unpackParallel(
782
+ (await readFile(file)).subarray(offset),
783
+ target,
784
+ format
785
+ );
786
+ var unpackFileSync = (file, target, offset = 0, format) => unpackSync(readFileSync2(file).subarray(offset), target, format);
752
787
  var tmpName = (target) => dirname(target) + sep + "." + basename2(target) + "." + tmpSuffix();
753
788
  var parseTarball = (buffer, tmp2) => {
754
- const isGzip = buffer[0] === 31 && buffer[1] === 139;
755
- if (isGzip) {
789
+ if (isGzip(buffer)) {
756
790
  throw error("still gzipped after unzipping", {
757
- found: isGzip,
791
+ found: true,
758
792
  wanted: false
759
793
  });
760
794
  }
@@ -923,10 +957,9 @@ var unpackUnzippedSync = (buffer, target) => {
923
957
  }
924
958
  }
925
959
  };
926
- var storeLayout = (tarData, dir) => {
927
- const isGzip = tarData[0] === 31 && tarData[1] === 139;
960
+ var storeLayout = (tarData, dir, format) => {
928
961
  const { dirs, files } = parseTarball(
929
- isGzip ? unzipSync(tarData) : tarData,
962
+ decompressSync(tarData, format),
930
963
  dir
931
964
  );
932
965
  const rel = (p) => relative(dir, p).replace(/\\/g, "/");
@@ -968,8 +1001,8 @@ var storeLayout = (tarData, dir) => {
968
1001
  binFiles
969
1002
  };
970
1003
  };
971
- var unpackToStoreSync = (tarData, dir) => {
972
- const { index, files, binFiles } = storeLayout(tarData, dir);
1004
+ var unpackToStoreSync = (tarData, dir, format) => {
1005
+ const { index, files, binFiles } = storeLayout(tarData, dir, format);
973
1006
  mkdirSync(dirname(dir), { recursive: true });
974
1007
  mkdirSync(dir, { mode: 511 });
975
1008
  let succeeded = false;
@@ -1101,6 +1134,8 @@ export {
1101
1134
  readStoreIndex,
1102
1135
  unpack,
1103
1136
  unpackSync,
1137
+ unpackParallel,
1138
+ unpackFileParallel,
1104
1139
  unpackFileSync,
1105
1140
  tmpName,
1106
1141
  unpackToStoreSync,
@@ -2995,6 +2995,7 @@ var Ze = Object.assign(Je, { glob: Je, globSync: ts, sync: Ui, globStream: Qe, s
2995
2995
  Ze.glob = Ze;
2996
2996
 
2997
2997
  export {
2998
+ ot,
2998
2999
  ts,
2999
3000
  Ze
3000
3001
  };