@vltpkg/cli-js 1.0.10 → 1.1.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 (80) hide show
  1. package/{access-4RPC3X5N.js → access-YYMAAPHV.js} +42 -11
  2. package/{bugs-K6QLQLL4.js → bugs-RK5JBPSC.js} +19 -19
  3. package/{build-VD4L5IED.js → build-DVJSYCNF.js} +8 -9
  4. package/{cache-Q6FUUEQF.js → cache-JKQNGZ7L.js} +21 -15
  5. package/{chunk-5JFRXIK2.js → chunk-2PWSMJD7.js} +20 -1
  6. package/{chunk-5HBKYSTX.js → chunk-34TE4HZS.js} +36 -4
  7. package/{chunk-WAYVHANF.js → chunk-3LUM7NX5.js} +30 -5
  8. package/{chunk-NA732FNL.js → chunk-6FT6K5YN.js} +98 -6
  9. package/{chunk-HAYXR3MW.js → chunk-APMYKJI2.js} +1 -1
  10. package/{chunk-ZNCVQQDT.js → chunk-BWEH7DHQ.js} +2 -2
  11. package/{chunk-5HPGL5WS.js → chunk-CBASIDQH.js} +1 -1
  12. package/{chunk-MNK55XSE.js → chunk-CEHPRPGQ.js} +21 -0
  13. package/{chunk-2YJ5MESP.js → chunk-DF5K4CYR.js} +6 -10
  14. package/{chunk-DAS7TVRN.js → chunk-DR4Z63B6.js} +5 -5
  15. package/{chunk-NWLS3VOQ.js → chunk-DS7YMIHP.js} +239 -131
  16. package/{chunk-XUP35M5Q.js → chunk-GDT6KI4I.js} +4 -4
  17. package/{chunk-FUCQ7ARR.js → chunk-JZJWASXL.js} +36 -25
  18. package/{chunk-B5IILBX7.js → chunk-KDF7PEBY.js} +4 -4
  19. package/{chunk-P5S2TFCF.js → chunk-LN2A74PF.js} +14 -10
  20. package/{chunk-VL7RJVNN.js → chunk-LR42WTKN.js} +20 -11
  21. package/chunk-MZA6N2TA.js +190 -0
  22. package/{chunk-3564IL5W.js → chunk-QQYTPGIL.js} +1 -1
  23. package/chunk-SNOBGFNM.js +129 -0
  24. package/{chunk-LPIBYUMT.js → chunk-U7TEQCBN.js} +27 -1
  25. package/{chunk-TYRKIWGF.js → chunk-V4YCZZHY.js} +3 -3
  26. package/chunk-WD74RJXW.js +75 -0
  27. package/{chunk-XFI4THXZ.js → chunk-WE2TQN32.js} +1 -1
  28. package/{chunk-USTJECVS.js → chunk-X2AWQGYG.js} +1 -1
  29. package/{chunk-BSPUKIWY.js → chunk-XIF734VO.js} +12 -2
  30. package/chunk-YBVTY6ZW.js +91 -0
  31. package/{ci-G4PJWJQE.js → ci-WVYVR4XK.js} +10 -11
  32. package/cli-package.json +1 -1
  33. package/{config-WTIWWXRD.js → config-2MFZVP2N.js} +11 -11
  34. package/{config-66ARNESN.js → config-VYOTYBGS.js} +8 -6
  35. package/{create-DF6RQTHC.js → create-OJPLHBRR.js} +18 -18
  36. package/{deprecate-2KTC2HKH.js → deprecate-V4PKGFF7.js} +22 -19
  37. package/{dist-tag-QKJQIOGN.js → dist-tag-DNLV4VDE.js} +24 -26
  38. package/{docs-YSWJTGYX.js → docs-LXHDCGL5.js} +19 -19
  39. package/{exec-5XIMPSBI.js → exec-P32YSP44.js} +18 -18
  40. package/{exec-cache-OGX7WR5P.js → exec-cache-JZ5PDTOY.js} +16 -16
  41. package/{exec-local-SB7EPYED.js → exec-local-HHA464H4.js} +14 -15
  42. package/{help-GMCQHGVN.js → help-GVTTOYUL.js} +4 -5
  43. package/{init-KXIIWHBA.js → init-RENGG74N.js} +8 -9
  44. package/{install-ODTEMAMS.js → install-V6VXOBH2.js} +38 -15
  45. package/{list-QS4FLJSU.js → list-7N7Y5OXB.js} +42 -30
  46. package/{login-6TGYRY43.js → login-D2QSAUJC.js} +12 -12
  47. package/{logout-GOAB7KHJ.js → logout-QPOYBQNF.js} +8 -8
  48. package/{pack-PJDH6PKP.js → pack-4YYGXP3A.js} +12 -13
  49. package/package.json +1 -1
  50. package/{ping-ANBW2IRW.js → ping-QYRIZONU.js} +8 -8
  51. package/{pkg-GZWUXU65.js → pkg-WQTNABKT.js} +11 -12
  52. package/{profile-BLY74CMB.js → profile-PRI7WXK7.js} +21 -8
  53. package/{publish-W2KOTNMB.js → publish-PSBYJQS7.js} +33 -75
  54. package/{query-3PUMU5ON.js → query-UFYLQW4N.js} +36 -24
  55. package/{registry-ONSDWNPV.js → registry-YTJZ3AQD.js} +3 -3
  56. package/registry-client-src-revalidate.js +426 -217
  57. package/{repo-LZ6STH4C.js → repo-4S6ETFXX.js} +19 -19
  58. package/{reporter-SDMDYYMJ.js → reporter-GLWYHI2Y.js} +23 -1
  59. package/{run-JMIBADHE.js → run-OU7NUB7A.js} +14 -15
  60. package/{run-exec-JEKM2O53.js → run-exec-QPBY7ULE.js} +14 -15
  61. package/security-archive-src-update-expired.js +97 -63
  62. package/{setup-BTBU3NAI.js → setup-23QXG473.js} +43 -24
  63. package/{src-J4BAYOBO.js → src-3GN7TDNH.js} +14 -6
  64. package/{src-23VBKASP.js → src-575IYJOL.js} +17 -18
  65. package/{token-PUJ7QN6D.js → token-FCIA3RGD.js} +9 -9
  66. package/{uninstall-OTISP2T7.js → uninstall-BQVZVKB5.js} +12 -12
  67. package/{unpublish-X75EEQAN.js → unpublish-YGJ5HEYF.js} +43 -40
  68. package/{update-CKXX5POE.js → update-WCGV66JK.js} +35 -13
  69. package/{version-24B2X7M7.js → version-7EA3UQG7.js} +10 -11
  70. package/{view-Q7MAQ6R3.js → view-5FWIENVE.js} +10 -10
  71. package/vlr.js +1 -1
  72. package/vlrx.js +1 -1
  73. package/vlt.js +1 -1
  74. package/vlx.js +1 -1
  75. package/vlxl.js +1 -1
  76. package/{whoami-S6CQZFE3.js → whoami-O4ZTBIC4.js} +29 -13
  77. package/chunk-E74WGW5C.js +0 -49
  78. package/chunk-UBLFPJHV.js +0 -40
  79. package/chunk-Y3QEV76Q.js +0 -75
  80. package/registry-client-package.json +0 -75
@@ -11,16 +11,18 @@ import {createRequire as _vlt_createRequire} from "node:module";
11
11
  var require = _vlt_createRequire(import.meta.filename);
12
12
  import {
13
13
  urlOpen
14
- } from "./chunk-HAYXR3MW.js";
14
+ } from "./chunk-APMYKJI2.js";
15
15
  import {
16
- loadPackageJson
17
- } from "./chunk-E74WGW5C.js";
16
+ assertOk,
17
+ registryErrorMessage
18
+ } from "./chunk-SNOBGFNM.js";
18
19
  import {
19
- I
20
- } from "./chunk-LPIBYUMT.js";
20
+ userAgent
21
+ } from "./chunk-YBVTY6ZW.js";
21
22
  import {
23
+ I,
22
24
  logRequest
23
- } from "./chunk-UBLFPJHV.js";
25
+ } from "./chunk-U7TEQCBN.js";
24
26
  import {
25
27
  asError
26
28
  } from "./chunk-VFBCWAOC.js";
@@ -934,33 +936,33 @@ var require_tree = __commonJS({
934
936
  throw new TypeError("Unreachable");
935
937
  }
936
938
  let index = 0;
937
- let node2 = this;
939
+ let node = this;
938
940
  while (true) {
939
941
  const code = key.charCodeAt(index);
940
942
  if (code > 127) {
941
943
  throw new TypeError("key must be ascii string");
942
944
  }
943
- if (node2.code === code) {
945
+ if (node.code === code) {
944
946
  if (length === ++index) {
945
- node2.value = value;
947
+ node.value = value;
946
948
  break;
947
- } else if (node2.middle !== null) {
948
- node2 = node2.middle;
949
+ } else if (node.middle !== null) {
950
+ node = node.middle;
949
951
  } else {
950
- node2.middle = new _TstNode(key, value, index);
952
+ node.middle = new _TstNode(key, value, index);
951
953
  break;
952
954
  }
953
- } else if (node2.code < code) {
954
- if (node2.left !== null) {
955
- node2 = node2.left;
955
+ } else if (node.code < code) {
956
+ if (node.left !== null) {
957
+ node = node.left;
956
958
  } else {
957
- node2.left = new _TstNode(key, value, index);
959
+ node.left = new _TstNode(key, value, index);
958
960
  break;
959
961
  }
960
- } else if (node2.right !== null) {
961
- node2 = node2.right;
962
+ } else if (node.right !== null) {
963
+ node = node.right;
962
964
  } else {
963
- node2.right = new _TstNode(key, value, index);
965
+ node.right = new _TstNode(key, value, index);
964
966
  break;
965
967
  }
966
968
  }
@@ -972,21 +974,21 @@ var require_tree = __commonJS({
972
974
  search(key) {
973
975
  const keylength = key.length;
974
976
  let index = 0;
975
- let node2 = this;
976
- while (node2 !== null && index < keylength) {
977
+ let node = this;
978
+ while (node !== null && index < keylength) {
977
979
  let code = key[index];
978
980
  if (code <= 90 && code >= 65) {
979
981
  code |= 32;
980
982
  }
981
- while (node2 !== null) {
982
- if (code === node2.code) {
983
+ while (node !== null) {
984
+ if (code === node.code) {
983
985
  if (keylength === ++index) {
984
- return node2;
986
+ return node;
985
987
  }
986
- node2 = node2.middle;
988
+ node = node.middle;
987
989
  break;
988
990
  }
989
- node2 = node2.code < code ? node2.left : node2.right;
991
+ node = node.code < code ? node.left : node.right;
990
992
  }
991
993
  }
992
994
  return null;
@@ -1074,7 +1076,7 @@ var require_util = __commonJS({
1074
1076
  return new BodyAsyncIterable(body);
1075
1077
  } else if (body && isFormDataLike(body)) {
1076
1078
  return body;
1077
- } else if (body && typeof body !== "string" && !ArrayBuffer.isView(body) && isIterable2(body)) {
1079
+ } else if (body && typeof body !== "string" && !ArrayBuffer.isView(body) && isIterable3(body)) {
1078
1080
  return new BodyAsyncIterable(body);
1079
1081
  } else {
1080
1082
  return body;
@@ -1195,7 +1197,7 @@ var require_util = __commonJS({
1195
1197
  function isAsyncIterable(obj) {
1196
1198
  return !!(obj != null && typeof obj[Symbol.asyncIterator] === "function");
1197
1199
  }
1198
- function isIterable2(obj) {
1200
+ function isIterable3(obj) {
1199
1201
  return !!(obj != null && (typeof obj[Symbol.iterator] === "function" || typeof obj[Symbol.asyncIterator] === "function"));
1200
1202
  }
1201
1203
  function hasSafeIterator(obj) {
@@ -1806,7 +1808,7 @@ var require_util = __commonJS({
1806
1808
  parseURL,
1807
1809
  getServerName,
1808
1810
  isStream,
1809
- isIterable: isIterable2,
1811
+ isIterable: isIterable3,
1810
1812
  hasSafeIterator,
1811
1813
  isAsyncIterable,
1812
1814
  isDestroyed,
@@ -1928,14 +1930,14 @@ var require_diagnostics = __commonJS({
1928
1930
  "undici:client:beforeConnect",
1929
1931
  (evt) => {
1930
1932
  const {
1931
- connectParams: { version: version2, protocol, port, host }
1933
+ connectParams: { version, protocol, port, host }
1932
1934
  } = evt;
1933
1935
  debugLog(
1934
1936
  "connecting to %s%s using %s%s",
1935
1937
  host,
1936
1938
  port ? `:${port}` : "",
1937
1939
  protocol,
1938
- version2
1940
+ version
1939
1941
  );
1940
1942
  }
1941
1943
  );
@@ -1943,14 +1945,14 @@ var require_diagnostics = __commonJS({
1943
1945
  "undici:client:connected",
1944
1946
  (evt) => {
1945
1947
  const {
1946
- connectParams: { version: version2, protocol, port, host }
1948
+ connectParams: { version, protocol, port, host }
1947
1949
  } = evt;
1948
1950
  debugLog(
1949
1951
  "connected to %s%s using %s%s",
1950
1952
  host,
1951
1953
  port ? `:${port}` : "",
1952
1954
  protocol,
1953
- version2
1955
+ version
1954
1956
  );
1955
1957
  }
1956
1958
  );
@@ -1958,7 +1960,7 @@ var require_diagnostics = __commonJS({
1958
1960
  "undici:client:connectError",
1959
1961
  (evt) => {
1960
1962
  const {
1961
- connectParams: { version: version2, protocol, port, host },
1963
+ connectParams: { version, protocol, port, host },
1962
1964
  error: error2
1963
1965
  } = evt;
1964
1966
  debugLog(
@@ -1966,7 +1968,7 @@ var require_diagnostics = __commonJS({
1966
1968
  host,
1967
1969
  port ? `:${port}` : "",
1968
1970
  protocol,
1969
- version2,
1971
+ version,
1970
1972
  error2.message
1971
1973
  );
1972
1974
  }
@@ -2115,7 +2117,7 @@ var require_request = __commonJS({
2115
2117
  destroy,
2116
2118
  isBuffer,
2117
2119
  isFormDataLike,
2118
- isIterable: isIterable2,
2120
+ isIterable: isIterable3,
2119
2121
  hasSafeIterator,
2120
2122
  isBlobLike,
2121
2123
  serializePathWithQuery,
@@ -2230,7 +2232,7 @@ var require_request = __commonJS({
2230
2232
  this.body = body.byteLength ? Buffer.from(body) : null;
2231
2233
  } else if (typeof body === "string") {
2232
2234
  this.body = body.length ? Buffer.from(body) : null;
2233
- } else if (isFormDataLike(body) || isIterable2(body) || isBlobLike(body)) {
2235
+ } else if (isFormDataLike(body) || isIterable3(body) || isBlobLike(body)) {
2234
2236
  this.body = body;
2235
2237
  } else {
2236
2238
  throw new InvalidArgumentError("body must be a string, a Buffer, a Readable stream, an iterable, or an async iterable");
@@ -10153,10 +10155,10 @@ var require_socks5_client = __commonJS({
10153
10155
  if (this.buffer.length < 2) {
10154
10156
  return;
10155
10157
  }
10156
- const version2 = this.buffer[0];
10158
+ const version = this.buffer[0];
10157
10159
  const method = this.buffer[1];
10158
- if (version2 !== SOCKS_VERSION) {
10159
- throw new Socks5ProxyError(`Invalid SOCKS version: ${version2}`, "UND_ERR_SOCKS5_VERSION");
10160
+ if (version !== SOCKS_VERSION) {
10161
+ throw new Socks5ProxyError(`Invalid SOCKS version: ${version}`, "UND_ERR_SOCKS5_VERSION");
10160
10162
  }
10161
10163
  if (method === AUTH_METHODS.NO_ACCEPTABLE) {
10162
10164
  throw new Socks5ProxyError("No acceptable authentication method", "UND_ERR_SOCKS5_AUTH_REJECTED");
@@ -10201,10 +10203,10 @@ var require_socks5_client = __commonJS({
10201
10203
  if (this.buffer.length < 2) {
10202
10204
  return;
10203
10205
  }
10204
- const version2 = this.buffer[0];
10206
+ const version = this.buffer[0];
10205
10207
  const status = this.buffer[1];
10206
- if (version2 !== 1) {
10207
- throw new Socks5ProxyError(`Invalid auth sub-negotiation version: ${version2}`, "UND_ERR_SOCKS5_AUTH_VERSION");
10208
+ if (version !== 1) {
10209
+ throw new Socks5ProxyError(`Invalid auth sub-negotiation version: ${version}`, "UND_ERR_SOCKS5_AUTH_VERSION");
10208
10210
  }
10209
10211
  if (status !== 0) {
10210
10212
  throw new Socks5ProxyError("Authentication failed", "UND_ERR_SOCKS5_AUTH_FAILED");
@@ -10251,11 +10253,11 @@ var require_socks5_client = __commonJS({
10251
10253
  if (this.buffer.length < 4) {
10252
10254
  return;
10253
10255
  }
10254
- const version2 = this.buffer[0];
10256
+ const version = this.buffer[0];
10255
10257
  const reply = this.buffer[1];
10256
10258
  const addressType = this.buffer[3];
10257
- if (version2 !== SOCKS_VERSION) {
10258
- throw new Socks5ProxyError(`Invalid SOCKS version in reply: ${version2}`, "UND_ERR_SOCKS5_REPLY_VERSION");
10259
+ if (version !== SOCKS_VERSION) {
10260
+ throw new Socks5ProxyError(`Invalid SOCKS version in reply: ${version}`, "UND_ERR_SOCKS5_REPLY_VERSION");
10259
10261
  }
10260
10262
  let responseLength = 4;
10261
10263
  if (addressType === ADDRESS_TYPES.IPV4) {
@@ -23908,24 +23910,24 @@ var require_sender = __commonJS({
23908
23910
  this.#socket.write(createFrame(item, hint), cb);
23909
23911
  }
23910
23912
  } else {
23911
- const node3 = {
23913
+ const node2 = {
23912
23914
  promise: null,
23913
23915
  callback: cb,
23914
23916
  frame: createFrame(item, hint)
23915
23917
  };
23916
- this.#queue.push(node3);
23918
+ this.#queue.push(node2);
23917
23919
  }
23918
23920
  return;
23919
23921
  }
23920
- const node2 = {
23922
+ const node = {
23921
23923
  promise: item.arrayBuffer().then((ab) => {
23922
- node2.promise = null;
23923
- node2.frame = createFrame(ab, hint);
23924
+ node.promise = null;
23925
+ node.frame = createFrame(ab, hint);
23924
23926
  }),
23925
23927
  callback: cb,
23926
23928
  frame: null
23927
23929
  };
23928
- this.#queue.push(node2);
23930
+ this.#queue.push(node);
23929
23931
  if (!this.#running) {
23930
23932
  this.#run();
23931
23933
  }
@@ -23934,12 +23936,12 @@ var require_sender = __commonJS({
23934
23936
  this.#running = true;
23935
23937
  const queue = this.#queue;
23936
23938
  while (!queue.isEmpty()) {
23937
- const node2 = queue.shift();
23938
- if (node2.promise !== null) {
23939
- await node2.promise;
23939
+ const node = queue.shift();
23940
+ if (node.promise !== null) {
23941
+ await node.promise;
23940
23942
  }
23941
- this.#socket.write(node2.frame, node2.callback);
23942
- node2.callback = node2.frame = null;
23943
+ this.#socket.write(node.frame, node.callback);
23944
+ node.callback = node.frame = null;
23943
23945
  }
23944
23946
  this.#running = false;
23945
23947
  }
@@ -26113,29 +26115,29 @@ var handleBeforeExit = () => {
26113
26115
  }
26114
26116
  args.push(__CODE_SPLIT_SCRIPT_NAME, path);
26115
26117
  registered.delete(path);
26116
- const proc3 = spawn(process.execPath, args, {
26118
+ const proc2 = spawn(process.execPath, args, {
26117
26119
  detached,
26118
26120
  stdio: ["pipe", "ignore", "ignore"],
26119
26121
  env
26120
26122
  });
26121
26123
  for (const key of r) {
26122
- proc3.stdin.write(`${key}\0`);
26124
+ proc2.stdin.write(`${key}\0`);
26123
26125
  }
26124
- proc3.stdin.end();
26126
+ proc2.stdin.end();
26125
26127
  if (detached) {
26126
- proc3.unref();
26128
+ proc2.unref();
26127
26129
  }
26128
26130
  }
26129
26131
  };
26130
26132
 
26131
26133
  // ../../src/registry-client/src/index.ts
26134
+ var import_undici3 = __toESM(require_undici(), 1);
26132
26135
  import { randomUUID } from "node:crypto";
26133
26136
  import { readFileSync as readFileSync2 } from "node:fs";
26134
26137
  import { STATUS_CODES } from "node:http";
26135
26138
  import { availableParallelism } from "node:os";
26136
26139
  import { dirname as dirname3, resolve as resolve4 } from "node:path";
26137
26140
  import { setTimeout as setTimeout2 } from "node:timers/promises";
26138
- var import_undici3 = __toESM(require_undici(), 1);
26139
26141
 
26140
26142
  // ../../src/registry-client/src/is-iterable.ts
26141
26143
  var isIterable = (o) => !!o && typeof o === "object" && Symbol.iterator in o;
@@ -26143,27 +26145,23 @@ var isIterable = (o) => !!o && typeof o === "object" && Symbol.iterator in o;
26143
26145
  // ../../src/registry-client/src/delete-header.ts
26144
26146
  var deleteHeader = (headers, key) => {
26145
26147
  if (!headers) return {};
26148
+ const lk = key.toLowerCase();
26146
26149
  if (Array.isArray(headers)) {
26147
26150
  if (!headers.length) return headers;
26148
- if (Array.isArray(headers[0])) {
26149
- const index = headers.findIndex(
26150
- ([k]) => k.toLowerCase() === key.toLowerCase()
26151
- );
26152
- if (index !== -1) headers.splice(index, 1);
26153
- } else {
26154
- const h = headers;
26155
- for (let i = 0; i < h.length; i += 2) {
26156
- if (h[i]?.toLowerCase() === key.toLowerCase()) {
26157
- headers.splice(i, 2);
26158
- break;
26159
- }
26160
- }
26151
+ const step = Array.isArray(headers[0]) ? 1 : 2;
26152
+ for (let i = 0; i < headers.length; ) {
26153
+ const h = headers[i];
26154
+ const k = Array.isArray(h) ? h[0] : h;
26155
+ if (k.toLowerCase() === lk) headers.splice(i, step);
26156
+ else i += step;
26161
26157
  }
26162
26158
  return headers;
26163
26159
  } else if (isIterable(headers)) {
26164
26160
  return deleteHeader([...headers], key);
26165
26161
  } else {
26166
- delete headers[key];
26162
+ for (const k of Object.keys(headers)) {
26163
+ if (k.toLowerCase() === lk) delete headers[k];
26164
+ }
26167
26165
  return headers;
26168
26166
  }
26169
26167
  };
@@ -26341,18 +26339,11 @@ var getTokenByURL = async (requestUrl, identity) => {
26341
26339
  for (const k of await kc.keys()) {
26342
26340
  candidates.push(k);
26343
26341
  }
26344
- let bestKey;
26345
- let bestLen = 0;
26346
- for (const candidate of candidates) {
26347
- if (candidate.length > bestLen && (normalized === candidate || normalized.startsWith(candidate + "/"))) {
26348
- bestKey = candidate;
26349
- bestLen = candidate.length;
26350
- }
26351
- }
26352
- if (bestKey) {
26353
- return getToken(bestKey, identity);
26342
+ const matches = candidates.filter((c) => normalized === c || normalized.startsWith(c + "/")).sort((a, b) => b.length - a.length);
26343
+ for (const key of matches) {
26344
+ const tok = await getToken(key, identity);
26345
+ if (tok) return tok;
26354
26346
  }
26355
- return getToken(requestUrl, identity);
26356
26347
  };
26357
26348
 
26358
26349
  // ../../src/registry-client/src/cache-entry.ts
@@ -26601,6 +26592,19 @@ var CacheEntry = class _CacheEntry {
26601
26592
  get statusCode() {
26602
26593
  return this.#statusCode;
26603
26594
  }
26595
+ /**
26596
+ * True when the registry answered with a 2xx.
26597
+ *
26598
+ * `RegistryClient.request()` resolves for every status, so this is how
26599
+ * code holding a real CacheEntry asks "did it work?".
26600
+ *
26601
+ * Note this is the strict form. Use it only where a genuine CacheEntry
26602
+ * is guaranteed; `assertOk` uses the loose range check because it is
26603
+ * also handed duck-typed responses.
26604
+ */
26605
+ get ok() {
26606
+ return this.#statusCode >= 200 && this.#statusCode < 300;
26607
+ }
26604
26608
  get headers() {
26605
26609
  return this.#headers;
26606
26610
  }
@@ -26953,9 +26957,9 @@ var __CODE_SPLIT_SCRIPT_NAME2 = resolve3(import.meta.dirname, "registry-client-s
26953
26957
  var isDeno2 = globalThis.Deno != void 0;
26954
26958
  var didProcessBeforeExitHook2 = false;
26955
26959
  var registered2 = /* @__PURE__ */ new Map();
26956
- var register2 = (path, method, url) => {
26960
+ var register2 = (path, method, url, accept) => {
26957
26961
  const r = registered2.get(path) ?? /* @__PURE__ */ new Set();
26958
- const key = `${method} ${url}`;
26962
+ const key = `${method} ${url}${accept ? ` ${String(accept)}` : ""}`;
26959
26963
  r.add(key);
26960
26964
  registered2.set(path, r);
26961
26965
  if (!didProcessBeforeExitHook2) {
@@ -26979,31 +26983,47 @@ var handleBeforeExit2 = () => {
26979
26983
  args.push(__CODE_SPLIT_SCRIPT_NAME2, path);
26980
26984
  registered2.delete(path);
26981
26985
  const detached = !(isDeno2 && process.platform === "win32");
26982
- const proc3 = spawn2(process.execPath, args, {
26986
+ const proc2 = spawn2(process.execPath, args, {
26983
26987
  detached,
26984
26988
  stdio: ["pipe", "ignore", "ignore"],
26985
26989
  env
26986
26990
  });
26987
26991
  for (const key of r) {
26988
- proc3.stdin.write(`${key}\0`);
26992
+ proc2.stdin.write(`${key}\0`);
26989
26993
  }
26990
- proc3.stdin.end();
26994
+ proc2.stdin.end();
26991
26995
  if (detached) {
26992
- proc3.unref();
26996
+ proc2.unref();
26993
26997
  }
26994
26998
  }
26995
26999
  };
26996
27000
 
26997
- // ../../src/registry-client/src/env.ts
26998
- import proc from "node:process";
26999
- var { Deno, Bun } = globalThis;
27000
- var isObj = (v) => typeof v === "object" && !!v;
27001
- var isDeno3 = isObj(Deno);
27002
- var isBun = !isDeno3 && isObj(Bun);
27003
- var isNode = !isDeno3 && !isBun && "node" in proc.versions;
27004
- var bun = isBun ? proc.versions.bun : void 0;
27005
- var deno = isDeno3 ? proc.versions.deno : void 0;
27006
- var node = isNode ? proc.versions.node : void 0;
27001
+ // ../../src/registry-client/src/get-header.ts
27002
+ var isIterable2 = (o) => !!o && typeof o === "object" && Symbol.iterator in o;
27003
+ var getHeader = (headers, key) => {
27004
+ if (!headers) return void 0;
27005
+ key = key.toLowerCase();
27006
+ if (Array.isArray(headers)) {
27007
+ if (!headers.length) return void 0;
27008
+ if (Array.isArray(headers[0])) {
27009
+ for (const [k, v] of headers) {
27010
+ if (k.toLowerCase() === key) return v;
27011
+ }
27012
+ } else if (headers.length % 2 === 0) {
27013
+ for (let i = 0; i < headers.length; i += 2) {
27014
+ if (headers[i]?.toLowerCase() === key) return headers[i + 1];
27015
+ }
27016
+ }
27017
+ } else if (isIterable2(headers)) {
27018
+ for (const [k, v] of headers) {
27019
+ if (k.toLowerCase() === key) return v;
27020
+ }
27021
+ } else {
27022
+ for (const [k, v] of Object.entries(headers)) {
27023
+ if (k.toLowerCase() === key) return v;
27024
+ }
27025
+ }
27026
+ };
27007
27027
 
27008
27028
  // ../../src/registry-client/src/handle-304-response.ts
27009
27029
  var handleCacheHitResponse = (resp, entry) => {
@@ -27053,6 +27073,9 @@ var otplease = async (client, options, response) => {
27053
27073
  );
27054
27074
  if (wwwAuth.has("ipaddress")) {
27055
27075
  throw error("Authorization is not allowed from your ip address", {
27076
+ code: "ENEEDAUTH",
27077
+ status: response.statusCode,
27078
+ method: options.method,
27056
27079
  response
27057
27080
  });
27058
27081
  }
@@ -27085,17 +27108,30 @@ var otplease = async (client, options, response) => {
27085
27108
  }
27086
27109
  }
27087
27110
  throw error("Unrecognized OTP authentication challenge", {
27111
+ code: "ENEEDAUTH",
27112
+ status: response.statusCode,
27113
+ method: options.method,
27088
27114
  response
27089
27115
  });
27090
27116
  }
27091
27117
  if (wwwAuth.has("bearer")) {
27092
27118
  throw error(
27093
27119
  "Missing or invalid authentication token. Run `vlt login` or `vlt token add` to authenticate.",
27094
- { response }
27120
+ {
27121
+ code: "ENEEDAUTH",
27122
+ status: response.statusCode,
27123
+ method: options.method,
27124
+ response
27125
+ }
27095
27126
  );
27096
27127
  }
27097
27128
  if (wwwAuth.size) {
27098
- throw error("Unknown authentication challenge", { response });
27129
+ throw error("Unknown authentication challenge", {
27130
+ code: "ENEEDAUTH",
27131
+ status: response.statusCode,
27132
+ method: options.method,
27133
+ response
27134
+ });
27099
27135
  }
27100
27136
  const text = await responseBodyText(response).catch(() => "");
27101
27137
  if (text.toLowerCase().includes("one-time pass")) {
@@ -27111,8 +27147,8 @@ var otplease = async (client, options, response) => {
27111
27147
 
27112
27148
  // ../../src/registry-client/src/proxy.ts
27113
27149
  var import_undici = __toESM(require_undici(), 1);
27114
- import proc2 from "node:process";
27115
- var hasProxyEnv = () => !!(proc2.env.http_proxy ?? proc2.env.HTTP_PROXY) || !!(proc2.env.https_proxy ?? proc2.env.HTTPS_PROXY);
27150
+ import proc from "node:process";
27151
+ var hasProxyEnv = () => !!(proc.env.http_proxy ?? proc.env.HTTP_PROXY) || !!(proc.env.https_proxy ?? proc.env.HTTPS_PROXY);
27116
27152
  var getDispatcher = (options) => hasProxyEnv() ? new import_undici.EnvHttpProxyAgent(options) : new import_undici.Agent(options);
27117
27153
 
27118
27154
  // ../../src/registry-client/src/redirect.ts
@@ -27145,6 +27181,12 @@ var redirect = (options, response, from) => {
27145
27181
  };
27146
27182
  delete nextOptions.path;
27147
27183
  redirections.add(String(nextURL));
27184
+ if (nextURL.origin !== from.origin) {
27185
+ nextOptions.headers = deleteHeader(
27186
+ nextOptions.headers,
27187
+ "authorization"
27188
+ );
27189
+ }
27148
27190
  switch (response.statusCode) {
27149
27191
  case 303: {
27150
27192
  nextOptions.method = "GET";
@@ -27362,12 +27404,6 @@ var exchangeToken = async (idToken, packageName, registry) => {
27362
27404
  var log3 = (msg) => console.error(msg);
27363
27405
  var isCacheableMethod = (m) => m === "GET" || m === "HEAD";
27364
27406
  var cacheKey = (method, url) => `${method !== "GET" ? method + " " : ""}${url}`;
27365
- var { version } = loadPackageJson(
27366
- import.meta.filename,
27367
- "registry-client-package.json"
27368
- );
27369
- var nua = globalThis.navigator?.userAgent ?? (bun ? `Bun/${bun}` : deno ? `Deno/${deno}` : node ? `Node.js/${node}` : "(unknown platform)");
27370
- var userAgent = `@vltpkg/registry-client/${version} ${nua}`;
27371
27407
  var agentOptions = {
27372
27408
  bodyTimeout: 6e5,
27373
27409
  headersTimeout: 6e5,
@@ -27446,7 +27482,40 @@ var RegistryClient = class {
27446
27482
  */
27447
27483
  async scroll(url, options = {}, seek) {
27448
27484
  const resp = await this.request(url, options);
27449
- const { objects, urls } = resp.json();
27485
+ const { statusCode } = resp;
27486
+ if (statusCode < 200 || statusCode >= 300) {
27487
+ let detail;
27488
+ try {
27489
+ const body2 = resp.json();
27490
+ if (body2 && typeof body2 === "object" && "error" in body2) {
27491
+ detail = body2.error;
27492
+ }
27493
+ } catch {
27494
+ }
27495
+ const status = STATUS_CODES[statusCode];
27496
+ throw error(
27497
+ `Failed to fetch paginated results: ${statusCode}${status ? ` ${status}` : ""}${typeof detail === "string" && detail ? `: ${detail}` : ""}`,
27498
+ { code: "EREQUEST", status: statusCode, url: String(url) }
27499
+ );
27500
+ }
27501
+ let body;
27502
+ try {
27503
+ body = resp.json();
27504
+ } catch (cause) {
27505
+ throw error("Invalid JSON in paginated registry response", {
27506
+ code: "EREQUEST",
27507
+ url: String(url),
27508
+ cause
27509
+ });
27510
+ }
27511
+ if (!body || typeof body !== "object" || !("objects" in body) || !Array.isArray(body.objects) || !("urls" in body) || !body.urls || typeof body.urls !== "object" || Array.isArray(body.urls) || "next" in body.urls && body.urls.next !== null && body.urls.next !== void 0 && typeof body.urls.next !== "string") {
27512
+ throw error("Invalid pagination in registry response", {
27513
+ code: "EREQUEST",
27514
+ url: String(url)
27515
+ });
27516
+ }
27517
+ const objects = body.objects;
27518
+ const urls = body.urls;
27450
27519
  return urls.next && !(seek && objects.some(seek)) ? objects.concat(await this.scroll(urls.next, options, seek)) : objects;
27451
27520
  }
27452
27521
  /**
@@ -27465,17 +27534,41 @@ var RegistryClient = class {
27465
27534
  const s = tok.replace(/^(Bearer|Basic) /i, "");
27466
27535
  const base = registryBase(registry);
27467
27536
  const tokensUrl = new URL("-/npm/v1/tokens", base);
27468
- const record = await this.seek(tokensUrl, ({ token }) => s.startsWith(token), {
27469
- useCache: false
27470
- }).catch(() => void 0);
27471
- if (record) {
27472
- const { key } = record;
27473
- await this.request(
27474
- new URL(`-/npm/v1/tokens/token/${key}`, base),
27475
- { useCache: false, method: "DELETE" }
27476
- );
27537
+ const stillLive = `Removing the local credential anyway; revoke the token in the registry UI if it is still live.`;
27538
+ try {
27539
+ let record;
27540
+ try {
27541
+ record = await this.seek(tokensUrl, ({ token }) => s.startsWith(token), {
27542
+ useCache: false
27543
+ });
27544
+ } catch (er) {
27545
+ log3(
27546
+ `Could not list tokens at ${tokensUrl}: ${asError(er).message}
27547
+ ` + stillLive
27548
+ );
27549
+ }
27550
+ if (record) {
27551
+ const deleteUrl = new URL(
27552
+ `-/npm/v1/tokens/token/${record.key}`,
27553
+ base
27554
+ );
27555
+ const failed = (detail) => log3(
27556
+ `Failed to revoke the token on the registry: ${detail}
27557
+ ` + stillLive
27558
+ );
27559
+ try {
27560
+ const response = await this.request(deleteUrl, {
27561
+ useCache: false,
27562
+ method: "DELETE"
27563
+ });
27564
+ if (!response.ok) failed(registryErrorMessage(response));
27565
+ } catch (er) {
27566
+ failed(asError(er).message);
27567
+ }
27568
+ }
27569
+ } finally {
27570
+ await deleteToken(registry, this.identity);
27477
27571
  }
27478
- await deleteToken(registry, this.identity);
27479
27572
  }
27480
27573
  /**
27481
27574
  * Log into the registry specified.
@@ -27579,11 +27672,19 @@ var RegistryClient = class {
27579
27672
  }
27580
27673
  return await this.#checkLogin(url, options);
27581
27674
  }
27675
+ assertOk(response, {
27676
+ message: "Web login failed",
27677
+ url,
27678
+ advice: (statusCode) => statusCode === 404 ? "This registry does not implement the web login endpoint." : void 0
27679
+ });
27582
27680
  if (response.statusCode === 200) {
27583
27681
  const token = getTokenResponse(response.json());
27584
27682
  if (token) return token;
27585
27683
  }
27586
27684
  throw error("Invalid response from web login endpoint", {
27685
+ code: "EREQUEST",
27686
+ url,
27687
+ status: response.statusCode,
27587
27688
  response
27588
27689
  });
27589
27690
  }
@@ -27657,13 +27758,19 @@ var RegistryClient = class {
27657
27758
  }
27658
27759
  const forcedFallback = forceRevalidate && entry?.staleWhileRevalidate ? entry : void 0;
27659
27760
  if (!forceRevalidate && staleWhileRevalidate && entry?.staleWhileRevalidate && m) {
27660
- register2(dirname3(this.cache.path()), m, url);
27761
+ register2(
27762
+ dirname3(this.cache.path()),
27763
+ m,
27764
+ url,
27765
+ getHeader(options.headers, "accept")
27766
+ );
27661
27767
  logRequest(url, "stale", { method });
27662
27768
  return entry;
27663
27769
  }
27664
27770
  logRequest(url, "start", { method });
27665
27771
  const requestStart = Date.now();
27666
27772
  setCacheHeaders(options, entry);
27773
+ const redirected = redirections.size > 0;
27667
27774
  redirections.add(String(url));
27668
27775
  options.path = u.pathname.replace(/\/+$/, "") + u.search;
27669
27776
  options.origin = u.origin;
@@ -27691,11 +27798,13 @@ var RegistryClient = class {
27691
27798
  );
27692
27799
  }
27693
27800
  options.method = options.method ?? "GET";
27694
- options.headers = addHeader(
27695
- options.headers,
27696
- "authorization",
27697
- await getTokenByURL(String(u), this.identity)
27698
- );
27801
+ if (!redirected || !getHeader(options.headers, "authorization")) {
27802
+ options.headers = addHeader(
27803
+ options.headers,
27804
+ "authorization",
27805
+ await getTokenByURL(String(u), this.identity)
27806
+ );
27807
+ }
27699
27808
  let response = null;
27700
27809
  try {
27701
27810
  response = await this.agent.request(
@@ -27815,7 +27924,6 @@ export {
27815
27924
  oidc,
27816
27925
  isCacheableMethod,
27817
27926
  cacheKey,
27818
- userAgent,
27819
27927
  RegistryClient
27820
27928
  };
27821
27929
  /*! Bundled license information: