@vltpkg/cli-js 1.3.3 → 1.3.4

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 (76) hide show
  1. package/{access-KMBBQIIT.js → access-AY2CIGVN.js} +4 -4
  2. package/{bugs-CABZX76X.js → bugs-6PTC6V7S.js} +12 -12
  3. package/{build-WNHKYA4E.js → build-R6OJNJDU.js} +6 -6
  4. package/{cache-KKT4GIYD.js → cache-NVLCCVWQ.js} +6 -6
  5. package/{chunk-3IDIPSH7.js → chunk-4XTUCYBW.js} +1 -1
  6. package/{chunk-MC6CESRA.js → chunk-AFUXQ3P4.js} +1 -1
  7. package/{chunk-GZWJAGBL.js → chunk-B5AKQ5TS.js} +3 -3
  8. package/{chunk-CU752KW7.js → chunk-BCANUHR3.js} +1 -1
  9. package/{chunk-LY5FNWRY.js → chunk-BFR3XHEM.js} +3 -3
  10. package/{chunk-ROCFQPP2.js → chunk-CYN4ADWK.js} +2 -2
  11. package/{chunk-QBXGMTDE.js → chunk-D4KNFORN.js} +1 -1
  12. package/{chunk-GA4LA6B2.js → chunk-DK6HGJCF.js} +4 -4
  13. package/chunk-DM2XRLCS.js +75 -0
  14. package/{chunk-SH24EMXO.js → chunk-GCLZEI3R.js} +150 -40
  15. package/{chunk-BUKZHMMK.js → chunk-INEKXXUQ.js} +1 -0
  16. package/{chunk-I6QGYSB4.js → chunk-LHIDMYN2.js} +1 -1
  17. package/{chunk-DCFLXO2M.js → chunk-MVD5AUNS.js} +1 -1
  18. package/{chunk-HCMAX6Q5.js → chunk-MWAWPY3P.js} +3 -3
  19. package/chunk-OFHNSAQ5.js +2155 -0
  20. package/{chunk-TJBBYDUN.js → chunk-QEWKCTQY.js} +4 -4
  21. package/{chunk-ZRRNOLEG.js → chunk-QGFDMXDH.js} +196 -96
  22. package/{chunk-ZBJRZXSU.js → chunk-QZIC3WVP.js} +3 -3
  23. package/{chunk-ZWKI5OSF.js → chunk-SRWDPPLX.js} +0 -1377
  24. package/{chunk-MOL2DUEQ.js → chunk-TL5SYXSC.js} +279 -35
  25. package/{chunk-CSZTT7QN.js → chunk-TOKUDCSW.js} +2 -2
  26. package/{chunk-YU2W5UPG.js → chunk-WXRS5PRL.js} +1 -1
  27. package/{chunk-ENSGPOLR.js → chunk-XU5WNX4S.js} +3 -1
  28. package/{ci-BGVGC5RF.js → ci-FEZ6B33S.js} +7 -7
  29. package/cli-package.json +1 -1
  30. package/{config-AWX2VEKL.js → config-EV5S74AA.js} +5 -5
  31. package/{config-FIKZ4VWG.js → config-VVPVV36W.js} +6 -6
  32. package/{create-CHTG7KO3.js → create-VGCARZLU.js} +13 -13
  33. package/{deprecate-W7KQ62HF.js → deprecate-3E27QREJ.js} +7 -7
  34. package/{dist-tag-66CC6HT7.js → dist-tag-ZIDIGEIM.js} +4 -4
  35. package/{docs-HW4U5TGD.js → docs-GESU73FF.js} +12 -12
  36. package/{exec-BVVNAGFI.js → exec-3SE4PRXY.js} +13 -13
  37. package/{exec-cache-L3ONPM5C.js → exec-cache-7QOIKCYP.js} +11 -11
  38. package/{exec-local-NR3RYQDQ.js → exec-local-EVAI6IYM.js} +10 -10
  39. package/{help-5YL6SUAN.js → help-H54DUW2F.js} +4 -4
  40. package/{init-RI2WVCGL.js → init-JOAMKEKV.js} +7 -7
  41. package/{install-OWAI4EOW.js → install-WHOVSLKH.js} +12 -12
  42. package/{list-4ZFX7ANG.js → list-7X2RIDA4.js} +12 -12
  43. package/{login-6TL3EE6Q.js → login-P5NRTQDS.js} +8 -8
  44. package/{logout-VQWHVHBE.js → logout-5PCTGCJZ.js} +4 -4
  45. package/{pack-Q5IRRAMU.js → pack-MLOVKXJZ.js} +9 -9
  46. package/package.json +1 -1
  47. package/{ping-2WV3V7GB.js → ping-6D6EEICV.js} +4 -4
  48. package/{pkg-RXB6BRS5.js → pkg-HC6N3DDH.js} +8 -8
  49. package/{profile-GNGWS5H2.js → profile-C3MNVMAE.js} +4 -4
  50. package/{publish-PI74W4GH.js → publish-3KUMQXKT.js} +12 -12
  51. package/{query-NESDWXGE.js → query-HNBW2ZGX.js} +12 -12
  52. package/{registry-MXAA4HVJ.js → registry-PY2L5ZWC.js} +2 -2
  53. package/registry-client-src-revalidate.js +150 -40
  54. package/{repo-PPBN3SKP.js → repo-VWEPCUXK.js} +12 -12
  55. package/{reporter-XBHCUW7W.js → reporter-UUDMEN4E.js} +6 -6
  56. package/{run-7GTWIFMV.js → run-OFW4MPAV.js} +10 -10
  57. package/{run-exec-VLSH5SOB.js → run-exec-ACGX23HX.js} +10 -10
  58. package/security-archive-src-update-expired.js +1 -1
  59. package/{setup-6O7RFGU2.js → setup-5C56O3S3.js} +10 -10
  60. package/{src-EJSVFFXB.js → src-3MEJQYBG.js} +21 -7
  61. package/{src-U4MCZFJT.js → src-LH2HZ6FT.js} +2 -2
  62. package/{src-6E7KCC7J.js → src-SI5YMOJI.js} +9 -9
  63. package/{token-NZ4HODXE.js → token-RPQP6BV5.js} +4 -4
  64. package/{uninstall-KBZ6PJBG.js → uninstall-HDUNLNAD.js} +8 -8
  65. package/{unpublish-JBWSIBRX.js → unpublish-SB647KPY.js} +4 -4
  66. package/{update-X4EC6MPP.js → update-PAIZPQPH.js} +11 -11
  67. package/{version-QEHPAFAE.js → version-5O2P2ROI.js} +7 -7
  68. package/{view-WGGZTYAT.js → view-3YVL4M7Z.js} +7 -7
  69. package/vlr.js +1 -1
  70. package/vlrx.js +1 -1
  71. package/vlt.js +1 -1
  72. package/vlx.js +1 -1
  73. package/vlxl.js +1 -1
  74. package/{whoami-RYNXOULV.js → whoami-KFXNKZOX.js} +4 -4
  75. package/chunk-7JK53T6G.js +0 -75
  76. package/chunk-KH3ERNCA.js +0 -783
@@ -9,1382 +9,6 @@ globalThis.setInterval = _vlt_setInterval;
9
9
  globalThis.clearInterval = _vlt_clearInterval;
10
10
  import {createRequire as _vlt_createRequire} from "node:module";
11
11
  var require = _vlt_createRequire(import.meta.filename);
12
- import {
13
- __commonJS,
14
- __require
15
- } from "./chunk-PZLD7RTK.js";
16
-
17
- // ../../node_modules/.vlt/~npm~minipass@7.1.3/node_modules/minipass/dist/commonjs/index.js
18
- var require_commonjs = __commonJS({
19
- "../../node_modules/.vlt/~npm~minipass@7.1.3/node_modules/minipass/dist/commonjs/index.js"(exports) {
20
- "use strict";
21
- var __importDefault = exports && exports.__importDefault || function(mod) {
22
- return mod && mod.__esModule ? mod : { "default": mod };
23
- };
24
- Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.Minipass = exports.isWritable = exports.isReadable = exports.isStream = void 0;
26
- var proc = typeof process === "object" && process ? process : {
27
- stdout: null,
28
- stderr: null
29
- };
30
- var node_events_1 = __require("node:events");
31
- var node_stream_1 = __importDefault(__require("node:stream"));
32
- var node_string_decoder_1 = __require("node:string_decoder");
33
- var isStream = (s3) => !!s3 && typeof s3 === "object" && (s3 instanceof Minipass || s3 instanceof node_stream_1.default || (0, exports.isReadable)(s3) || (0, exports.isWritable)(s3));
34
- exports.isStream = isStream;
35
- var isReadable = (s3) => !!s3 && typeof s3 === "object" && s3 instanceof node_events_1.EventEmitter && typeof s3.pipe === "function" && // node core Writable streams have a pipe() method, but it throws
36
- s3.pipe !== node_stream_1.default.Writable.prototype.pipe;
37
- exports.isReadable = isReadable;
38
- var isWritable = (s3) => !!s3 && typeof s3 === "object" && s3 instanceof node_events_1.EventEmitter && typeof s3.write === "function" && typeof s3.end === "function";
39
- exports.isWritable = isWritable;
40
- var EOF = /* @__PURE__ */ Symbol("EOF");
41
- var MAYBE_EMIT_END = /* @__PURE__ */ Symbol("maybeEmitEnd");
42
- var EMITTED_END = /* @__PURE__ */ Symbol("emittedEnd");
43
- var EMITTING_END = /* @__PURE__ */ Symbol("emittingEnd");
44
- var EMITTED_ERROR = /* @__PURE__ */ Symbol("emittedError");
45
- var CLOSED = /* @__PURE__ */ Symbol("closed");
46
- var READ = /* @__PURE__ */ Symbol("read");
47
- var FLUSH = /* @__PURE__ */ Symbol("flush");
48
- var FLUSHCHUNK = /* @__PURE__ */ Symbol("flushChunk");
49
- var ENCODING = /* @__PURE__ */ Symbol("encoding");
50
- var DECODER = /* @__PURE__ */ Symbol("decoder");
51
- var FLOWING = /* @__PURE__ */ Symbol("flowing");
52
- var PAUSED = /* @__PURE__ */ Symbol("paused");
53
- var RESUME = /* @__PURE__ */ Symbol("resume");
54
- var BUFFER = /* @__PURE__ */ Symbol("buffer");
55
- var PIPES = /* @__PURE__ */ Symbol("pipes");
56
- var BUFFERLENGTH = /* @__PURE__ */ Symbol("bufferLength");
57
- var BUFFERPUSH = /* @__PURE__ */ Symbol("bufferPush");
58
- var BUFFERSHIFT = /* @__PURE__ */ Symbol("bufferShift");
59
- var OBJECTMODE = /* @__PURE__ */ Symbol("objectMode");
60
- var DESTROYED = /* @__PURE__ */ Symbol("destroyed");
61
- var ERROR = /* @__PURE__ */ Symbol("error");
62
- var EMITDATA = /* @__PURE__ */ Symbol("emitData");
63
- var EMITEND = /* @__PURE__ */ Symbol("emitEnd");
64
- var EMITEND2 = /* @__PURE__ */ Symbol("emitEnd2");
65
- var ASYNC = /* @__PURE__ */ Symbol("async");
66
- var ABORT = /* @__PURE__ */ Symbol("abort");
67
- var ABORTED = /* @__PURE__ */ Symbol("aborted");
68
- var SIGNAL = /* @__PURE__ */ Symbol("signal");
69
- var DATALISTENERS = /* @__PURE__ */ Symbol("dataListeners");
70
- var DISCARDED = /* @__PURE__ */ Symbol("discarded");
71
- var defer = (fn) => Promise.resolve().then(fn);
72
- var nodefer = (fn) => fn();
73
- var isEndish = (ev) => ev === "end" || ev === "finish" || ev === "prefinish";
74
- var isArrayBufferLike = (b2) => b2 instanceof ArrayBuffer || !!b2 && typeof b2 === "object" && b2.constructor && b2.constructor.name === "ArrayBuffer" && b2.byteLength >= 0;
75
- var isArrayBufferView = (b2) => !Buffer.isBuffer(b2) && ArrayBuffer.isView(b2);
76
- var Pipe = class {
77
- src;
78
- dest;
79
- opts;
80
- ondrain;
81
- constructor(src, dest, opts) {
82
- this.src = src;
83
- this.dest = dest;
84
- this.opts = opts;
85
- this.ondrain = () => src[RESUME]();
86
- this.dest.on("drain", this.ondrain);
87
- }
88
- unpipe() {
89
- this.dest.removeListener("drain", this.ondrain);
90
- }
91
- // only here for the prototype
92
- /* c8 ignore start */
93
- proxyErrors(_er) {
94
- }
95
- /* c8 ignore stop */
96
- end() {
97
- this.unpipe();
98
- if (this.opts.end)
99
- this.dest.end();
100
- }
101
- };
102
- var PipeProxyErrors = class extends Pipe {
103
- unpipe() {
104
- this.src.removeListener("error", this.proxyErrors);
105
- super.unpipe();
106
- }
107
- constructor(src, dest, opts) {
108
- super(src, dest, opts);
109
- this.proxyErrors = (er2) => this.dest.emit("error", er2);
110
- src.on("error", this.proxyErrors);
111
- }
112
- };
113
- var isObjectModeOptions = (o) => !!o.objectMode;
114
- var isEncodingOptions = (o) => !o.objectMode && !!o.encoding && o.encoding !== "buffer";
115
- var Minipass = class extends node_events_1.EventEmitter {
116
- [FLOWING] = false;
117
- [PAUSED] = false;
118
- [PIPES] = [];
119
- [BUFFER] = [];
120
- [OBJECTMODE];
121
- [ENCODING];
122
- [ASYNC];
123
- [DECODER];
124
- [EOF] = false;
125
- [EMITTED_END] = false;
126
- [EMITTING_END] = false;
127
- [CLOSED] = false;
128
- [EMITTED_ERROR] = null;
129
- [BUFFERLENGTH] = 0;
130
- [DESTROYED] = false;
131
- [SIGNAL];
132
- [ABORTED] = false;
133
- [DATALISTENERS] = 0;
134
- [DISCARDED] = false;
135
- /**
136
- * true if the stream can be written
137
- */
138
- writable = true;
139
- /**
140
- * true if the stream can be read
141
- */
142
- readable = true;
143
- /**
144
- * If `RType` is Buffer, then options do not need to be provided.
145
- * Otherwise, an options object must be provided to specify either
146
- * {@link Minipass.SharedOptions.objectMode} or
147
- * {@link Minipass.SharedOptions.encoding}, as appropriate.
148
- */
149
- constructor(...args) {
150
- const options = args[0] || {};
151
- super();
152
- if (options.objectMode && typeof options.encoding === "string") {
153
- throw new TypeError("Encoding and objectMode may not be used together");
154
- }
155
- if (isObjectModeOptions(options)) {
156
- this[OBJECTMODE] = true;
157
- this[ENCODING] = null;
158
- } else if (isEncodingOptions(options)) {
159
- this[ENCODING] = options.encoding;
160
- this[OBJECTMODE] = false;
161
- } else {
162
- this[OBJECTMODE] = false;
163
- this[ENCODING] = null;
164
- }
165
- this[ASYNC] = !!options.async;
166
- this[DECODER] = this[ENCODING] ? new node_string_decoder_1.StringDecoder(this[ENCODING]) : null;
167
- if (options && options.debugExposeBuffer === true) {
168
- Object.defineProperty(this, "buffer", { get: () => this[BUFFER] });
169
- }
170
- if (options && options.debugExposePipes === true) {
171
- Object.defineProperty(this, "pipes", { get: () => this[PIPES] });
172
- }
173
- const { signal } = options;
174
- if (signal) {
175
- this[SIGNAL] = signal;
176
- if (signal.aborted) {
177
- this[ABORT]();
178
- } else {
179
- signal.addEventListener("abort", () => this[ABORT]());
180
- }
181
- }
182
- }
183
- /**
184
- * The amount of data stored in the buffer waiting to be read.
185
- *
186
- * For Buffer strings, this will be the total byte length.
187
- * For string encoding streams, this will be the string character length,
188
- * according to JavaScript's `string.length` logic.
189
- * For objectMode streams, this is a count of the items waiting to be
190
- * emitted.
191
- */
192
- get bufferLength() {
193
- return this[BUFFERLENGTH];
194
- }
195
- /**
196
- * The `BufferEncoding` currently in use, or `null`
197
- */
198
- get encoding() {
199
- return this[ENCODING];
200
- }
201
- /**
202
- * @deprecated - This is a read only property
203
- */
204
- set encoding(_enc) {
205
- throw new Error("Encoding must be set at instantiation time");
206
- }
207
- /**
208
- * @deprecated - Encoding may only be set at instantiation time
209
- */
210
- setEncoding(_enc) {
211
- throw new Error("Encoding must be set at instantiation time");
212
- }
213
- /**
214
- * True if this is an objectMode stream
215
- */
216
- get objectMode() {
217
- return this[OBJECTMODE];
218
- }
219
- /**
220
- * @deprecated - This is a read-only property
221
- */
222
- set objectMode(_om) {
223
- throw new Error("objectMode must be set at instantiation time");
224
- }
225
- /**
226
- * true if this is an async stream
227
- */
228
- get ["async"]() {
229
- return this[ASYNC];
230
- }
231
- /**
232
- * Set to true to make this stream async.
233
- *
234
- * Once set, it cannot be unset, as this would potentially cause incorrect
235
- * behavior. Ie, a sync stream can be made async, but an async stream
236
- * cannot be safely made sync.
237
- */
238
- set ["async"](a) {
239
- this[ASYNC] = this[ASYNC] || !!a;
240
- }
241
- // drop everything and get out of the flow completely
242
- [ABORT]() {
243
- this[ABORTED] = true;
244
- this.emit("abort", this[SIGNAL]?.reason);
245
- this.destroy(this[SIGNAL]?.reason);
246
- }
247
- /**
248
- * True if the stream has been aborted.
249
- */
250
- get aborted() {
251
- return this[ABORTED];
252
- }
253
- /**
254
- * No-op setter. Stream aborted status is set via the AbortSignal provided
255
- * in the constructor options.
256
- */
257
- set aborted(_2) {
258
- }
259
- write(chunk, encoding, cb) {
260
- if (this[ABORTED])
261
- return false;
262
- if (this[EOF])
263
- throw new Error("write after end");
264
- if (this[DESTROYED]) {
265
- this.emit("error", Object.assign(new Error("Cannot call write after a stream was destroyed"), { code: "ERR_STREAM_DESTROYED" }));
266
- return true;
267
- }
268
- if (typeof encoding === "function") {
269
- cb = encoding;
270
- encoding = "utf8";
271
- }
272
- if (!encoding)
273
- encoding = "utf8";
274
- const fn = this[ASYNC] ? defer : nodefer;
275
- if (!this[OBJECTMODE] && !Buffer.isBuffer(chunk)) {
276
- if (isArrayBufferView(chunk)) {
277
- chunk = Buffer.from(chunk.buffer, chunk.byteOffset, chunk.byteLength);
278
- } else if (isArrayBufferLike(chunk)) {
279
- chunk = Buffer.from(chunk);
280
- } else if (typeof chunk !== "string") {
281
- throw new Error("Non-contiguous data written to non-objectMode stream");
282
- }
283
- }
284
- if (this[OBJECTMODE]) {
285
- if (this[FLOWING] && this[BUFFERLENGTH] !== 0)
286
- this[FLUSH](true);
287
- if (this[FLOWING])
288
- this.emit("data", chunk);
289
- else
290
- this[BUFFERPUSH](chunk);
291
- if (this[BUFFERLENGTH] !== 0)
292
- this.emit("readable");
293
- if (cb)
294
- fn(cb);
295
- return this[FLOWING];
296
- }
297
- if (!chunk.length) {
298
- if (this[BUFFERLENGTH] !== 0)
299
- this.emit("readable");
300
- if (cb)
301
- fn(cb);
302
- return this[FLOWING];
303
- }
304
- if (typeof chunk === "string" && // unless it is a string already ready for us to use
305
- !(encoding === this[ENCODING] && !this[DECODER]?.lastNeed)) {
306
- chunk = Buffer.from(chunk, encoding);
307
- }
308
- if (Buffer.isBuffer(chunk) && this[ENCODING]) {
309
- chunk = this[DECODER].write(chunk);
310
- }
311
- if (this[FLOWING] && this[BUFFERLENGTH] !== 0)
312
- this[FLUSH](true);
313
- if (this[FLOWING])
314
- this.emit("data", chunk);
315
- else
316
- this[BUFFERPUSH](chunk);
317
- if (this[BUFFERLENGTH] !== 0)
318
- this.emit("readable");
319
- if (cb)
320
- fn(cb);
321
- return this[FLOWING];
322
- }
323
- /**
324
- * Low-level explicit read method.
325
- *
326
- * In objectMode, the argument is ignored, and one item is returned if
327
- * available.
328
- *
329
- * `n` is the number of bytes (or in the case of encoding streams,
330
- * characters) to consume. If `n` is not provided, then the entire buffer
331
- * is returned, or `null` is returned if no data is available.
332
- *
333
- * If `n` is greater that the amount of data in the internal buffer,
334
- * then `null` is returned.
335
- */
336
- read(n) {
337
- if (this[DESTROYED])
338
- return null;
339
- this[DISCARDED] = false;
340
- if (this[BUFFERLENGTH] === 0 || n === 0 || n && n > this[BUFFERLENGTH]) {
341
- this[MAYBE_EMIT_END]();
342
- return null;
343
- }
344
- if (this[OBJECTMODE])
345
- n = null;
346
- if (this[BUFFER].length > 1 && !this[OBJECTMODE]) {
347
- this[BUFFER] = [
348
- this[ENCODING] ? this[BUFFER].join("") : Buffer.concat(this[BUFFER], this[BUFFERLENGTH])
349
- ];
350
- }
351
- const ret = this[READ](n || null, this[BUFFER][0]);
352
- this[MAYBE_EMIT_END]();
353
- return ret;
354
- }
355
- [READ](n, chunk) {
356
- if (this[OBJECTMODE])
357
- this[BUFFERSHIFT]();
358
- else {
359
- const c = chunk;
360
- if (n === c.length || n === null)
361
- this[BUFFERSHIFT]();
362
- else if (typeof c === "string") {
363
- this[BUFFER][0] = c.slice(n);
364
- chunk = c.slice(0, n);
365
- this[BUFFERLENGTH] -= n;
366
- } else {
367
- this[BUFFER][0] = c.subarray(n);
368
- chunk = c.subarray(0, n);
369
- this[BUFFERLENGTH] -= n;
370
- }
371
- }
372
- this.emit("data", chunk);
373
- if (!this[BUFFER].length && !this[EOF])
374
- this.emit("drain");
375
- return chunk;
376
- }
377
- end(chunk, encoding, cb) {
378
- if (typeof chunk === "function") {
379
- cb = chunk;
380
- chunk = void 0;
381
- }
382
- if (typeof encoding === "function") {
383
- cb = encoding;
384
- encoding = "utf8";
385
- }
386
- if (chunk !== void 0)
387
- this.write(chunk, encoding);
388
- if (cb)
389
- this.once("end", cb);
390
- this[EOF] = true;
391
- this.writable = false;
392
- if (this[FLOWING] || !this[PAUSED])
393
- this[MAYBE_EMIT_END]();
394
- return this;
395
- }
396
- // don't let the internal resume be overwritten
397
- [RESUME]() {
398
- if (this[DESTROYED])
399
- return;
400
- if (!this[DATALISTENERS] && !this[PIPES].length) {
401
- this[DISCARDED] = true;
402
- }
403
- this[PAUSED] = false;
404
- this[FLOWING] = true;
405
- this.emit("resume");
406
- if (this[BUFFER].length)
407
- this[FLUSH]();
408
- else if (this[EOF])
409
- this[MAYBE_EMIT_END]();
410
- else
411
- this.emit("drain");
412
- }
413
- /**
414
- * Resume the stream if it is currently in a paused state
415
- *
416
- * If called when there are no pipe destinations or `data` event listeners,
417
- * this will place the stream in a "discarded" state, where all data will
418
- * be thrown away. The discarded state is removed if a pipe destination or
419
- * data handler is added, if pause() is called, or if any synchronous or
420
- * asynchronous iteration is started.
421
- */
422
- resume() {
423
- return this[RESUME]();
424
- }
425
- /**
426
- * Pause the stream
427
- */
428
- pause() {
429
- this[FLOWING] = false;
430
- this[PAUSED] = true;
431
- this[DISCARDED] = false;
432
- }
433
- /**
434
- * true if the stream has been forcibly destroyed
435
- */
436
- get destroyed() {
437
- return this[DESTROYED];
438
- }
439
- /**
440
- * true if the stream is currently in a flowing state, meaning that
441
- * any writes will be immediately emitted.
442
- */
443
- get flowing() {
444
- return this[FLOWING];
445
- }
446
- /**
447
- * true if the stream is currently in a paused state
448
- */
449
- get paused() {
450
- return this[PAUSED];
451
- }
452
- [BUFFERPUSH](chunk) {
453
- if (this[OBJECTMODE])
454
- this[BUFFERLENGTH] += 1;
455
- else
456
- this[BUFFERLENGTH] += chunk.length;
457
- this[BUFFER].push(chunk);
458
- }
459
- [BUFFERSHIFT]() {
460
- if (this[OBJECTMODE])
461
- this[BUFFERLENGTH] -= 1;
462
- else
463
- this[BUFFERLENGTH] -= this[BUFFER][0].length;
464
- return this[BUFFER].shift();
465
- }
466
- [FLUSH](noDrain = false) {
467
- do {
468
- } while (this[FLUSHCHUNK](this[BUFFERSHIFT]()) && this[BUFFER].length);
469
- if (!noDrain && !this[BUFFER].length && !this[EOF])
470
- this.emit("drain");
471
- }
472
- [FLUSHCHUNK](chunk) {
473
- this.emit("data", chunk);
474
- return this[FLOWING];
475
- }
476
- /**
477
- * Pipe all data emitted by this stream into the destination provided.
478
- *
479
- * Triggers the flow of data.
480
- */
481
- pipe(dest, opts) {
482
- if (this[DESTROYED])
483
- return dest;
484
- this[DISCARDED] = false;
485
- const ended = this[EMITTED_END];
486
- opts = opts || {};
487
- if (dest === proc.stdout || dest === proc.stderr)
488
- opts.end = false;
489
- else
490
- opts.end = opts.end !== false;
491
- opts.proxyErrors = !!opts.proxyErrors;
492
- if (ended) {
493
- if (opts.end)
494
- dest.end();
495
- } else {
496
- this[PIPES].push(!opts.proxyErrors ? new Pipe(this, dest, opts) : new PipeProxyErrors(this, dest, opts));
497
- if (this[ASYNC])
498
- defer(() => this[RESUME]());
499
- else
500
- this[RESUME]();
501
- }
502
- return dest;
503
- }
504
- /**
505
- * Fully unhook a piped destination stream.
506
- *
507
- * If the destination stream was the only consumer of this stream (ie,
508
- * there are no other piped destinations or `'data'` event listeners)
509
- * then the flow of data will stop until there is another consumer or
510
- * {@link Minipass#resume} is explicitly called.
511
- */
512
- unpipe(dest) {
513
- const p2 = this[PIPES].find((p3) => p3.dest === dest);
514
- if (p2) {
515
- if (this[PIPES].length === 1) {
516
- if (this[FLOWING] && this[DATALISTENERS] === 0) {
517
- this[FLOWING] = false;
518
- }
519
- this[PIPES] = [];
520
- } else
521
- this[PIPES].splice(this[PIPES].indexOf(p2), 1);
522
- p2.unpipe();
523
- }
524
- }
525
- /**
526
- * Alias for {@link Minipass#on}
527
- */
528
- addListener(ev, handler) {
529
- return this.on(ev, handler);
530
- }
531
- /**
532
- * Mostly identical to `EventEmitter.on`, with the following
533
- * behavior differences to prevent data loss and unnecessary hangs:
534
- *
535
- * - Adding a 'data' event handler will trigger the flow of data
536
- *
537
- * - Adding a 'readable' event handler when there is data waiting to be read
538
- * will cause 'readable' to be emitted immediately.
539
- *
540
- * - Adding an 'endish' event handler ('end', 'finish', etc.) which has
541
- * already passed will cause the event to be emitted immediately and all
542
- * handlers removed.
543
- *
544
- * - Adding an 'error' event handler after an error has been emitted will
545
- * cause the event to be re-emitted immediately with the error previously
546
- * raised.
547
- */
548
- on(ev, handler) {
549
- const ret = super.on(ev, handler);
550
- if (ev === "data") {
551
- this[DISCARDED] = false;
552
- this[DATALISTENERS]++;
553
- if (!this[PIPES].length && !this[FLOWING]) {
554
- this[RESUME]();
555
- }
556
- } else if (ev === "readable" && this[BUFFERLENGTH] !== 0) {
557
- super.emit("readable");
558
- } else if (isEndish(ev) && this[EMITTED_END]) {
559
- super.emit(ev);
560
- this.removeAllListeners(ev);
561
- } else if (ev === "error" && this[EMITTED_ERROR]) {
562
- const h = handler;
563
- if (this[ASYNC])
564
- defer(() => h.call(this, this[EMITTED_ERROR]));
565
- else
566
- h.call(this, this[EMITTED_ERROR]);
567
- }
568
- return ret;
569
- }
570
- /**
571
- * Alias for {@link Minipass#off}
572
- */
573
- removeListener(ev, handler) {
574
- return this.off(ev, handler);
575
- }
576
- /**
577
- * Mostly identical to `EventEmitter.off`
578
- *
579
- * If a 'data' event handler is removed, and it was the last consumer
580
- * (ie, there are no pipe destinations or other 'data' event listeners),
581
- * then the flow of data will stop until there is another consumer or
582
- * {@link Minipass#resume} is explicitly called.
583
- */
584
- off(ev, handler) {
585
- const ret = super.off(ev, handler);
586
- if (ev === "data") {
587
- this[DATALISTENERS] = this.listeners("data").length;
588
- if (this[DATALISTENERS] === 0 && !this[DISCARDED] && !this[PIPES].length) {
589
- this[FLOWING] = false;
590
- }
591
- }
592
- return ret;
593
- }
594
- /**
595
- * Mostly identical to `EventEmitter.removeAllListeners`
596
- *
597
- * If all 'data' event handlers are removed, and they were the last consumer
598
- * (ie, there are no pipe destinations), then the flow of data will stop
599
- * until there is another consumer or {@link Minipass#resume} is explicitly
600
- * called.
601
- */
602
- removeAllListeners(ev) {
603
- const ret = super.removeAllListeners(ev);
604
- if (ev === "data" || ev === void 0) {
605
- this[DATALISTENERS] = 0;
606
- if (!this[DISCARDED] && !this[PIPES].length) {
607
- this[FLOWING] = false;
608
- }
609
- }
610
- return ret;
611
- }
612
- /**
613
- * true if the 'end' event has been emitted
614
- */
615
- get emittedEnd() {
616
- return this[EMITTED_END];
617
- }
618
- [MAYBE_EMIT_END]() {
619
- if (!this[EMITTING_END] && !this[EMITTED_END] && !this[DESTROYED] && this[BUFFER].length === 0 && this[EOF]) {
620
- this[EMITTING_END] = true;
621
- this.emit("end");
622
- this.emit("prefinish");
623
- this.emit("finish");
624
- if (this[CLOSED])
625
- this.emit("close");
626
- this[EMITTING_END] = false;
627
- }
628
- }
629
- /**
630
- * Mostly identical to `EventEmitter.emit`, with the following
631
- * behavior differences to prevent data loss and unnecessary hangs:
632
- *
633
- * If the stream has been destroyed, and the event is something other
634
- * than 'close' or 'error', then `false` is returned and no handlers
635
- * are called.
636
- *
637
- * If the event is 'end', and has already been emitted, then the event
638
- * is ignored. If the stream is in a paused or non-flowing state, then
639
- * the event will be deferred until data flow resumes. If the stream is
640
- * async, then handlers will be called on the next tick rather than
641
- * immediately.
642
- *
643
- * If the event is 'close', and 'end' has not yet been emitted, then
644
- * the event will be deferred until after 'end' is emitted.
645
- *
646
- * If the event is 'error', and an AbortSignal was provided for the stream,
647
- * and there are no listeners, then the event is ignored, matching the
648
- * behavior of node core streams in the presense of an AbortSignal.
649
- *
650
- * If the event is 'finish' or 'prefinish', then all listeners will be
651
- * removed after emitting the event, to prevent double-firing.
652
- */
653
- emit(ev, ...args) {
654
- const data = args[0];
655
- if (ev !== "error" && ev !== "close" && ev !== DESTROYED && this[DESTROYED]) {
656
- return false;
657
- } else if (ev === "data") {
658
- return !this[OBJECTMODE] && !data ? false : this[ASYNC] ? (defer(() => this[EMITDATA](data)), true) : this[EMITDATA](data);
659
- } else if (ev === "end") {
660
- return this[EMITEND]();
661
- } else if (ev === "close") {
662
- this[CLOSED] = true;
663
- if (!this[EMITTED_END] && !this[DESTROYED])
664
- return false;
665
- const ret2 = super.emit("close");
666
- this.removeAllListeners("close");
667
- return ret2;
668
- } else if (ev === "error") {
669
- this[EMITTED_ERROR] = data;
670
- super.emit(ERROR, data);
671
- const ret2 = !this[SIGNAL] || this.listeners("error").length ? super.emit("error", data) : false;
672
- this[MAYBE_EMIT_END]();
673
- return ret2;
674
- } else if (ev === "resume") {
675
- const ret2 = super.emit("resume");
676
- this[MAYBE_EMIT_END]();
677
- return ret2;
678
- } else if (ev === "finish" || ev === "prefinish") {
679
- const ret2 = super.emit(ev);
680
- this.removeAllListeners(ev);
681
- return ret2;
682
- }
683
- const ret = super.emit(ev, ...args);
684
- this[MAYBE_EMIT_END]();
685
- return ret;
686
- }
687
- [EMITDATA](data) {
688
- for (const p2 of this[PIPES]) {
689
- if (p2.dest.write(data) === false)
690
- this.pause();
691
- }
692
- const ret = this[DISCARDED] ? false : super.emit("data", data);
693
- this[MAYBE_EMIT_END]();
694
- return ret;
695
- }
696
- [EMITEND]() {
697
- if (this[EMITTED_END])
698
- return false;
699
- this[EMITTED_END] = true;
700
- this.readable = false;
701
- return this[ASYNC] ? (defer(() => this[EMITEND2]()), true) : this[EMITEND2]();
702
- }
703
- [EMITEND2]() {
704
- if (this[DECODER]) {
705
- const data = this[DECODER].end();
706
- if (data) {
707
- for (const p2 of this[PIPES]) {
708
- p2.dest.write(data);
709
- }
710
- if (!this[DISCARDED])
711
- super.emit("data", data);
712
- }
713
- }
714
- for (const p2 of this[PIPES]) {
715
- p2.end();
716
- }
717
- const ret = super.emit("end");
718
- this.removeAllListeners("end");
719
- return ret;
720
- }
721
- /**
722
- * Return a Promise that resolves to an array of all emitted data once
723
- * the stream ends.
724
- */
725
- async collect() {
726
- const buf = Object.assign([], {
727
- dataLength: 0
728
- });
729
- if (!this[OBJECTMODE])
730
- buf.dataLength = 0;
731
- const p2 = this.promise();
732
- this.on("data", (c) => {
733
- buf.push(c);
734
- if (!this[OBJECTMODE])
735
- buf.dataLength += c.length;
736
- });
737
- await p2;
738
- return buf;
739
- }
740
- /**
741
- * Return a Promise that resolves to the concatenation of all emitted data
742
- * once the stream ends.
743
- *
744
- * Not allowed on objectMode streams.
745
- */
746
- async concat() {
747
- if (this[OBJECTMODE]) {
748
- throw new Error("cannot concat in objectMode");
749
- }
750
- const buf = await this.collect();
751
- return this[ENCODING] ? buf.join("") : Buffer.concat(buf, buf.dataLength);
752
- }
753
- /**
754
- * Return a void Promise that resolves once the stream ends.
755
- */
756
- async promise() {
757
- return new Promise((resolve, reject) => {
758
- this.on(DESTROYED, () => reject(new Error("stream destroyed")));
759
- this.on("error", (er2) => reject(er2));
760
- this.on("end", () => resolve());
761
- });
762
- }
763
- /**
764
- * Asynchronous `for await of` iteration.
765
- *
766
- * This will continue emitting all chunks until the stream terminates.
767
- */
768
- [Symbol.asyncIterator]() {
769
- this[DISCARDED] = false;
770
- let stopped = false;
771
- const stop = async () => {
772
- this.pause();
773
- stopped = true;
774
- return { value: void 0, done: true };
775
- };
776
- const next = () => {
777
- if (stopped)
778
- return stop();
779
- const res = this.read();
780
- if (res !== null)
781
- return Promise.resolve({ done: false, value: res });
782
- if (this[EOF])
783
- return stop();
784
- let resolve;
785
- let reject;
786
- const onerr = (er2) => {
787
- this.off("data", ondata);
788
- this.off("end", onend);
789
- this.off(DESTROYED, ondestroy);
790
- stop();
791
- reject(er2);
792
- };
793
- const ondata = (value) => {
794
- this.off("error", onerr);
795
- this.off("end", onend);
796
- this.off(DESTROYED, ondestroy);
797
- this.pause();
798
- resolve({ value, done: !!this[EOF] });
799
- };
800
- const onend = () => {
801
- this.off("error", onerr);
802
- this.off("data", ondata);
803
- this.off(DESTROYED, ondestroy);
804
- stop();
805
- resolve({ done: true, value: void 0 });
806
- };
807
- const ondestroy = () => onerr(new Error("stream destroyed"));
808
- return new Promise((res2, rej) => {
809
- reject = rej;
810
- resolve = res2;
811
- this.once(DESTROYED, ondestroy);
812
- this.once("error", onerr);
813
- this.once("end", onend);
814
- this.once("data", ondata);
815
- });
816
- };
817
- return {
818
- next,
819
- throw: stop,
820
- return: stop,
821
- [Symbol.asyncIterator]() {
822
- return this;
823
- },
824
- [Symbol.asyncDispose]: async () => {
825
- }
826
- };
827
- }
828
- /**
829
- * Synchronous `for of` iteration.
830
- *
831
- * The iteration will terminate when the internal buffer runs out, even
832
- * if the stream has not yet terminated.
833
- */
834
- [Symbol.iterator]() {
835
- this[DISCARDED] = false;
836
- let stopped = false;
837
- const stop = () => {
838
- this.pause();
839
- this.off(ERROR, stop);
840
- this.off(DESTROYED, stop);
841
- this.off("end", stop);
842
- stopped = true;
843
- return { done: true, value: void 0 };
844
- };
845
- const next = () => {
846
- if (stopped)
847
- return stop();
848
- const value = this.read();
849
- return value === null ? stop() : { done: false, value };
850
- };
851
- this.once("end", stop);
852
- this.once(ERROR, stop);
853
- this.once(DESTROYED, stop);
854
- return {
855
- next,
856
- throw: stop,
857
- return: stop,
858
- [Symbol.iterator]() {
859
- return this;
860
- },
861
- [Symbol.dispose]: () => {
862
- }
863
- };
864
- }
865
- /**
866
- * Destroy a stream, preventing it from being used for any further purpose.
867
- *
868
- * If the stream has a `close()` method, then it will be called on
869
- * destruction.
870
- *
871
- * After destruction, any attempt to write data, read data, or emit most
872
- * events will be ignored.
873
- *
874
- * If an error argument is provided, then it will be emitted in an
875
- * 'error' event.
876
- */
877
- destroy(er2) {
878
- if (this[DESTROYED]) {
879
- if (er2)
880
- this.emit("error", er2);
881
- else
882
- this.emit(DESTROYED);
883
- return this;
884
- }
885
- this[DESTROYED] = true;
886
- this[DISCARDED] = true;
887
- this[BUFFER].length = 0;
888
- this[BUFFERLENGTH] = 0;
889
- const wc = this;
890
- if (typeof wc.close === "function" && !this[CLOSED])
891
- wc.close();
892
- if (er2)
893
- this.emit("error", er2);
894
- else
895
- this.emit(DESTROYED);
896
- return this;
897
- }
898
- /**
899
- * Alias for {@link isStream}
900
- *
901
- * Former export location, maintained for backwards compatibility.
902
- *
903
- * @deprecated
904
- */
905
- static get isStream() {
906
- return exports.isStream;
907
- }
908
- };
909
- exports.Minipass = Minipass;
910
- }
911
- });
912
-
913
- // ../../node_modules/.vlt/~npm~ssri@13.0.1/node_modules/ssri/lib/index.js
914
- var require_lib = __commonJS({
915
- "../../node_modules/.vlt/~npm~ssri@13.0.1/node_modules/ssri/lib/index.js"(exports, module) {
916
- "use strict";
917
- var crypto = __require("node:crypto");
918
- var { Minipass } = require_commonjs();
919
- var SPEC_ALGORITHMS = ["sha512", "sha384", "sha256"];
920
- var DEFAULT_ALGORITHMS = ["sha512"];
921
- var NODE_HASHES = crypto.getHashes();
922
- var BASE64_REGEX = /^[a-z0-9+/]+(?:=?=?)$/i;
923
- var SRI_REGEX = /^([a-z0-9]+)-([^?]+)(\?[?\S*]*)?$/;
924
- var STRICT_SRI_REGEX = /^([a-z0-9]+)-([A-Za-z0-9+/=]{44,88})(\?[\x21-\x7E]*)?$/;
925
- var VCHAR_REGEX = /^[\x21-\x7E]+$/;
926
- var DEFAULT_PRIORITY = [
927
- "md5",
928
- "whirlpool",
929
- "sha1",
930
- "sha224",
931
- "sha256",
932
- "sha384",
933
- "sha512",
934
- // TODO - it's unclear _which_ of these Node will actually use as its name for the algorithm, so we guesswork it based on the OpenSSL names.
935
- "sha3",
936
- "sha3-256",
937
- "sha3-384",
938
- "sha3-512",
939
- "sha3_256",
940
- "sha3_384",
941
- "sha3_512"
942
- ].filter((algo) => NODE_HASHES.includes(algo));
943
- var getOptString = (options) => options?.length ? `?${options.join("?")}` : "";
944
- var IntegrityStream = class extends Minipass {
945
- #emittedIntegrity;
946
- #emittedSize;
947
- #emittedVerified;
948
- constructor(opts) {
949
- super();
950
- this.size = 0;
951
- this.opts = opts;
952
- this.#getOptions();
953
- if (opts?.algorithms) {
954
- this.algorithms = [...opts.algorithms];
955
- } else {
956
- this.algorithms = [...DEFAULT_ALGORITHMS];
957
- }
958
- if (this.algorithm !== null && !this.algorithms.includes(this.algorithm)) {
959
- this.algorithms.push(this.algorithm);
960
- }
961
- this.hashes = this.algorithms.map(crypto.createHash);
962
- }
963
- #getOptions() {
964
- this.sri = this.opts?.integrity ? parse(this.opts?.integrity, this.opts) : null;
965
- this.expectedSize = this.opts?.size;
966
- if (!this.sri) {
967
- this.algorithm = null;
968
- } else if (this.sri.isHash) {
969
- this.goodSri = true;
970
- this.algorithm = this.sri.algorithm;
971
- } else {
972
- this.goodSri = !this.sri.isEmpty();
973
- this.algorithm = this.sri.pickAlgorithm(this.opts);
974
- }
975
- this.digests = this.goodSri ? this.sri[this.algorithm] : null;
976
- this.optString = getOptString(this.opts?.options);
977
- }
978
- on(ev, handler) {
979
- if (ev === "size" && this.#emittedSize) {
980
- return handler(this.#emittedSize);
981
- }
982
- if (ev === "integrity" && this.#emittedIntegrity) {
983
- return handler(this.#emittedIntegrity);
984
- }
985
- if (ev === "verified" && this.#emittedVerified) {
986
- return handler(this.#emittedVerified);
987
- }
988
- return super.on(ev, handler);
989
- }
990
- emit(ev, data) {
991
- if (ev === "end") {
992
- this.#onEnd();
993
- }
994
- return super.emit(ev, data);
995
- }
996
- write(data) {
997
- this.size += data.length;
998
- this.hashes.forEach((h) => h.update(data));
999
- return super.write(data);
1000
- }
1001
- #onEnd() {
1002
- if (!this.goodSri) {
1003
- this.#getOptions();
1004
- }
1005
- const newSri = parse(this.hashes.map((h, i) => {
1006
- return `${this.algorithms[i]}-${h.digest("base64")}${this.optString}`;
1007
- }).join(" "), this.opts);
1008
- const match = this.goodSri && newSri.match(this.sri, this.opts);
1009
- if (typeof this.expectedSize === "number" && this.size !== this.expectedSize) {
1010
- const err = new Error(`stream size mismatch when checking ${this.sri}.
1011
- Wanted: ${this.expectedSize}
1012
- Found: ${this.size}`);
1013
- err.code = "EBADSIZE";
1014
- err.found = this.size;
1015
- err.expected = this.expectedSize;
1016
- err.sri = this.sri;
1017
- this.emit("error", err);
1018
- } else if (this.sri && !match) {
1019
- const err = new Error(`${this.sri} integrity checksum failed when using ${this.algorithm}: wanted ${this.digests} but got ${newSri}. (${this.size} bytes)`);
1020
- err.code = "EINTEGRITY";
1021
- err.found = newSri;
1022
- err.expected = this.digests;
1023
- err.algorithm = this.algorithm;
1024
- err.sri = this.sri;
1025
- this.emit("error", err);
1026
- } else {
1027
- this.#emittedSize = this.size;
1028
- this.emit("size", this.size);
1029
- this.#emittedIntegrity = newSri;
1030
- this.emit("integrity", newSri);
1031
- if (match) {
1032
- this.#emittedVerified = match;
1033
- this.emit("verified", match);
1034
- }
1035
- }
1036
- }
1037
- };
1038
- var Hash = class {
1039
- get isHash() {
1040
- return true;
1041
- }
1042
- constructor(hash, opts) {
1043
- const strict = opts?.strict;
1044
- this.source = hash.trim();
1045
- this.digest = "";
1046
- this.algorithm = "";
1047
- this.options = [];
1048
- const match = this.source.match(
1049
- strict ? STRICT_SRI_REGEX : SRI_REGEX
1050
- );
1051
- if (!match) {
1052
- return;
1053
- }
1054
- if (strict && !SPEC_ALGORITHMS.includes(match[1])) {
1055
- return;
1056
- }
1057
- if (!NODE_HASHES.includes(match[1])) {
1058
- return;
1059
- }
1060
- this.algorithm = match[1];
1061
- this.digest = match[2];
1062
- const rawOpts = match[3];
1063
- if (rawOpts) {
1064
- this.options = rawOpts.slice(1).split("?");
1065
- }
1066
- }
1067
- hexDigest() {
1068
- return this.digest && Buffer.from(this.digest, "base64").toString("hex");
1069
- }
1070
- toJSON() {
1071
- return this.toString();
1072
- }
1073
- match(integrity, opts) {
1074
- const other = parse(integrity, opts);
1075
- if (!other) {
1076
- return false;
1077
- }
1078
- if (other.isIntegrity) {
1079
- const algo = other.pickAlgorithm(opts, [this.algorithm]);
1080
- if (!algo) {
1081
- return false;
1082
- }
1083
- const foundHash = other[algo].find((hash) => hash.digest === this.digest);
1084
- if (foundHash) {
1085
- return foundHash;
1086
- }
1087
- return false;
1088
- }
1089
- return other.digest === this.digest ? other : false;
1090
- }
1091
- toString(opts) {
1092
- if (opts?.strict) {
1093
- if (!// The spec has very restricted productions for algorithms.
1094
- // https://www.w3.org/TR/CSP2/#source-list-syntax
1095
- (SPEC_ALGORITHMS.includes(this.algorithm) && // Usually, if someone insists on using a "different" base64, we leave it as-is, since there are multiple standards, and the specified is not a URL-safe variant.
1096
- // https://www.w3.org/TR/CSP2/#base64_value
1097
- this.digest.match(BASE64_REGEX) && // Option syntax is strictly visual chars.
1098
- // https://w3c.github.io/webappsec-subresource-integrity/#grammardef-option-expression
1099
- // https://tools.ietf.org/html/rfc5234#appendix-B.1
1100
- this.options.every((opt) => opt.match(VCHAR_REGEX)))) {
1101
- return "";
1102
- }
1103
- }
1104
- return `${this.algorithm}-${this.digest}${getOptString(this.options)}`;
1105
- }
1106
- };
1107
- function integrityHashToString(toString, sep, opts, hashes) {
1108
- const toStringIsNotEmpty = toString !== "";
1109
- let shouldAddFirstSep = false;
1110
- let complement = "";
1111
- const lastIndex = hashes.length - 1;
1112
- for (let i = 0; i < lastIndex; i++) {
1113
- const hashString = Hash.prototype.toString.call(hashes[i], opts);
1114
- if (hashString) {
1115
- shouldAddFirstSep = true;
1116
- complement += hashString;
1117
- complement += sep;
1118
- }
1119
- }
1120
- const finalHashString = Hash.prototype.toString.call(hashes[lastIndex], opts);
1121
- if (finalHashString) {
1122
- shouldAddFirstSep = true;
1123
- complement += finalHashString;
1124
- }
1125
- if (toStringIsNotEmpty && shouldAddFirstSep) {
1126
- return toString + sep + complement;
1127
- }
1128
- return toString + complement;
1129
- }
1130
- var Integrity = class {
1131
- get isIntegrity() {
1132
- return true;
1133
- }
1134
- toJSON() {
1135
- return this.toString();
1136
- }
1137
- isEmpty() {
1138
- return Object.keys(this).length === 0;
1139
- }
1140
- toString(opts) {
1141
- let sep = opts?.sep || " ";
1142
- let toString = "";
1143
- if (opts?.strict) {
1144
- sep = sep.replace(/\S+/g, " ");
1145
- for (const hash of SPEC_ALGORITHMS) {
1146
- if (this[hash]) {
1147
- toString = integrityHashToString(toString, sep, opts, this[hash]);
1148
- }
1149
- }
1150
- } else {
1151
- for (const hash of Object.keys(this)) {
1152
- toString = integrityHashToString(toString, sep, opts, this[hash]);
1153
- }
1154
- }
1155
- return toString;
1156
- }
1157
- concat(integrity, opts) {
1158
- const other = typeof integrity === "string" ? integrity : stringify(integrity, opts);
1159
- return parse(`${this.toString(opts)} ${other}`, opts);
1160
- }
1161
- hexDigest() {
1162
- return parse(this, { single: true }).hexDigest();
1163
- }
1164
- // add additional hashes to an integrity value, but prevent *changing* an existing integrity hash.
1165
- merge(integrity, opts) {
1166
- const other = parse(integrity, opts);
1167
- for (const algo in other) {
1168
- if (this[algo]) {
1169
- if (!this[algo].find((hash) => other[algo].find((otherhash) => hash.digest === otherhash.digest))) {
1170
- throw new Error("hashes do not match, cannot update integrity");
1171
- }
1172
- } else {
1173
- this[algo] = other[algo];
1174
- }
1175
- }
1176
- }
1177
- match(integrity, opts) {
1178
- const other = parse(integrity, opts);
1179
- if (!other) {
1180
- return false;
1181
- }
1182
- const algo = other.pickAlgorithm(opts, Object.keys(this));
1183
- return !!algo && this[algo].find(
1184
- (hash) => other[algo].find(
1185
- (otherhash) => hash.digest === otherhash.digest
1186
- )
1187
- ) || false;
1188
- }
1189
- // Pick the highest priority algorithm present, optionally also limited to a set of hashes found in another integrity.
1190
- // When limiting it may return nothing.
1191
- pickAlgorithm(opts, hashes) {
1192
- const pickAlgorithm = opts?.pickAlgorithm || getPrioritizedHash;
1193
- let keys = Object.keys(this);
1194
- if (hashes?.length) {
1195
- keys = keys.filter((k2) => hashes.includes(k2));
1196
- }
1197
- if (keys.length) {
1198
- return keys.reduce((acc, algo) => pickAlgorithm(acc, algo) || acc);
1199
- }
1200
- return null;
1201
- }
1202
- };
1203
- module.exports.parse = parse;
1204
- function parse(sri, opts) {
1205
- if (!sri) {
1206
- return null;
1207
- }
1208
- if (typeof sri === "string") {
1209
- return _parse(sri, opts);
1210
- } else if (sri.algorithm && sri.digest) {
1211
- const fullSri = new Integrity();
1212
- fullSri[sri.algorithm] = [sri];
1213
- return _parse(stringify(fullSri, opts), opts);
1214
- } else {
1215
- return _parse(stringify(sri, opts), opts);
1216
- }
1217
- }
1218
- function _parse(integrity, opts) {
1219
- if (opts?.single) {
1220
- return new Hash(integrity, opts);
1221
- }
1222
- const hashes = integrity.trim().split(/\s+/).reduce((acc, string) => {
1223
- const hash = new Hash(string, opts);
1224
- if (hash.algorithm && hash.digest) {
1225
- const algo = hash.algorithm;
1226
- if (!Object.keys(acc).includes(algo)) {
1227
- acc[algo] = [];
1228
- }
1229
- acc[algo].push(hash);
1230
- }
1231
- return acc;
1232
- }, new Integrity());
1233
- return hashes.isEmpty() ? null : hashes;
1234
- }
1235
- module.exports.stringify = stringify;
1236
- function stringify(obj, opts) {
1237
- if (obj.algorithm && obj.digest) {
1238
- return Hash.prototype.toString.call(obj, opts);
1239
- } else if (typeof obj === "string") {
1240
- return stringify(parse(obj, opts), opts);
1241
- } else {
1242
- return Integrity.prototype.toString.call(obj, opts);
1243
- }
1244
- }
1245
- module.exports.fromHex = fromHex;
1246
- function fromHex(hexDigest, algorithm, opts) {
1247
- const optString = getOptString(opts?.options);
1248
- return parse(
1249
- `${algorithm}-${Buffer.from(hexDigest, "hex").toString("base64")}${optString}`,
1250
- opts
1251
- );
1252
- }
1253
- module.exports.fromData = fromData;
1254
- function fromData(data, opts) {
1255
- const algorithms = opts?.algorithms || [...DEFAULT_ALGORITHMS];
1256
- const optString = getOptString(opts?.options);
1257
- return algorithms.reduce((acc, algo) => {
1258
- const digest = crypto.createHash(algo).update(data).digest("base64");
1259
- const hash = new Hash(
1260
- `${algo}-${digest}${optString}`,
1261
- opts
1262
- );
1263
- if (hash.algorithm && hash.digest) {
1264
- const hashAlgo = hash.algorithm;
1265
- if (!acc[hashAlgo]) {
1266
- acc[hashAlgo] = [];
1267
- }
1268
- acc[hashAlgo].push(hash);
1269
- }
1270
- return acc;
1271
- }, new Integrity());
1272
- }
1273
- module.exports.fromStream = fromStream;
1274
- function fromStream(stream, opts) {
1275
- const istream = integrityStream(opts);
1276
- return new Promise((resolve, reject) => {
1277
- stream.pipe(istream);
1278
- stream.on("error", reject);
1279
- istream.on("error", reject);
1280
- let sri;
1281
- istream.on("integrity", (s3) => {
1282
- sri = s3;
1283
- });
1284
- istream.on("end", () => resolve(sri));
1285
- istream.resume();
1286
- });
1287
- }
1288
- module.exports.checkData = checkData;
1289
- function checkData(data, sri, opts) {
1290
- sri = parse(sri, opts);
1291
- if (!sri || !Object.keys(sri).length) {
1292
- if (opts?.error) {
1293
- throw Object.assign(
1294
- new Error("No valid integrity hashes to check against"),
1295
- {
1296
- code: "EINTEGRITY"
1297
- }
1298
- );
1299
- } else {
1300
- return false;
1301
- }
1302
- }
1303
- const algorithm = sri.pickAlgorithm(opts);
1304
- const digest = crypto.createHash(algorithm).update(data).digest("base64");
1305
- const newSri = parse({ algorithm, digest });
1306
- const match = newSri.match(sri, opts);
1307
- opts = opts || {};
1308
- if (match || !opts.error) {
1309
- return match;
1310
- } else if (typeof opts.size === "number" && data.length !== opts.size) {
1311
- const err = new Error(`data size mismatch when checking ${sri}.
1312
- Wanted: ${opts.size}
1313
- Found: ${data.length}`);
1314
- err.code = "EBADSIZE";
1315
- err.found = data.length;
1316
- err.expected = opts.size;
1317
- err.sri = sri;
1318
- throw err;
1319
- } else {
1320
- const err = new Error(`Integrity checksum failed when using ${algorithm}: Wanted ${sri}, but got ${newSri}. (${data.length} bytes)`);
1321
- err.code = "EINTEGRITY";
1322
- err.found = newSri;
1323
- err.expected = sri;
1324
- err.algorithm = algorithm;
1325
- err.sri = sri;
1326
- throw err;
1327
- }
1328
- }
1329
- module.exports.checkStream = checkStream;
1330
- function checkStream(stream, sri, opts) {
1331
- opts = opts || /* @__PURE__ */ Object.create(null);
1332
- opts.integrity = sri;
1333
- sri = parse(sri, opts);
1334
- if (!sri || !Object.keys(sri).length) {
1335
- return Promise.reject(Object.assign(
1336
- new Error("No valid integrity hashes to check against"),
1337
- {
1338
- code: "EINTEGRITY"
1339
- }
1340
- ));
1341
- }
1342
- const checker = integrityStream(opts);
1343
- return new Promise((resolve, reject) => {
1344
- stream.pipe(checker);
1345
- stream.on("error", reject);
1346
- checker.on("error", reject);
1347
- let verified;
1348
- checker.on("verified", (s3) => {
1349
- verified = s3;
1350
- });
1351
- checker.on("end", () => resolve(verified));
1352
- checker.resume();
1353
- });
1354
- }
1355
- module.exports.integrityStream = integrityStream;
1356
- function integrityStream(opts = /* @__PURE__ */ Object.create(null)) {
1357
- return new IntegrityStream(opts);
1358
- }
1359
- module.exports.create = createIntegrity;
1360
- function createIntegrity(opts) {
1361
- const algorithms = opts?.algorithms || [...DEFAULT_ALGORITHMS];
1362
- const optString = getOptString(opts?.options);
1363
- const hashes = algorithms.map(crypto.createHash);
1364
- return {
1365
- update: function(chunk, enc) {
1366
- hashes.forEach((h) => h.update(chunk, enc));
1367
- return this;
1368
- },
1369
- digest: function() {
1370
- const integrity = algorithms.reduce((acc, algo) => {
1371
- const digest = hashes.shift().digest("base64");
1372
- const hash = new Hash(`${algo}-${digest}${optString}`, opts);
1373
- if (!acc[hash.algorithm]) {
1374
- acc[hash.algorithm] = [];
1375
- }
1376
- acc[hash.algorithm].push(hash);
1377
- return acc;
1378
- }, new Integrity());
1379
- return integrity;
1380
- }
1381
- };
1382
- }
1383
- function getPrioritizedHash(algo1, algo2) {
1384
- return DEFAULT_PRIORITY.indexOf(algo1.toLowerCase()) >= DEFAULT_PRIORITY.indexOf(algo2.toLowerCase()) ? algo1 : algo2;
1385
- }
1386
- }
1387
- });
1388
12
 
1389
13
  // ../../node_modules/.vlt/~npm~tar@7.5.22/node_modules/tar/dist/esm/index.min.js
1390
14
  import Qr from "node:events";
@@ -4356,7 +2980,6 @@ var To = (s3) => {
4356
2980
  };
4357
2981
 
4358
2982
  export {
4359
- require_lib,
4360
2983
  Ct,
4361
2984
  Qn
4362
2985
  };