tar 6.2.0 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -16
- package/dist/commonjs/create.d.ts +8 -0
- package/dist/commonjs/create.d.ts.map +1 -0
- package/dist/commonjs/create.js +106 -0
- package/dist/commonjs/create.js.map +1 -0
- package/dist/commonjs/cwd-error.d.ts +8 -0
- package/dist/commonjs/cwd-error.d.ts.map +1 -0
- package/dist/commonjs/cwd-error.js +18 -0
- package/dist/commonjs/cwd-error.js.map +1 -0
- package/dist/commonjs/extract.d.ts +8 -0
- package/dist/commonjs/extract.d.ts.map +1 -0
- package/dist/commonjs/extract.js +141 -0
- package/dist/commonjs/extract.js.map +1 -0
- package/dist/commonjs/get-write-flag.d.ts +2 -0
- package/dist/commonjs/get-write-flag.d.ts.map +1 -0
- package/dist/commonjs/get-write-flag.js +29 -0
- package/dist/commonjs/get-write-flag.js.map +1 -0
- package/dist/commonjs/header.d.ts +54 -0
- package/dist/commonjs/header.d.ts.map +1 -0
- package/dist/commonjs/header.js +308 -0
- package/dist/commonjs/header.js.map +1 -0
- package/dist/commonjs/index.d.ts +19 -0
- package/dist/commonjs/index.d.ts.map +1 -0
- package/dist/commonjs/index.js +54 -0
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/large-numbers.d.ts +4 -0
- package/dist/commonjs/large-numbers.d.ts.map +1 -0
- package/dist/commonjs/large-numbers.js +99 -0
- package/dist/commonjs/large-numbers.js.map +1 -0
- package/dist/commonjs/list.d.ts +8 -0
- package/dist/commonjs/list.d.ts.map +1 -0
- package/dist/commonjs/list.js +167 -0
- package/dist/commonjs/list.js.map +1 -0
- package/dist/commonjs/mkdir.d.ts +27 -0
- package/dist/commonjs/mkdir.d.ts.map +1 -0
- package/dist/commonjs/mkdir.js +209 -0
- package/dist/commonjs/mkdir.js.map +1 -0
- package/dist/commonjs/mode-fix.d.ts +2 -0
- package/dist/commonjs/mode-fix.d.ts.map +1 -0
- package/dist/commonjs/mode-fix.js +29 -0
- package/dist/commonjs/mode-fix.js.map +1 -0
- package/dist/commonjs/normalize-unicode.d.ts +2 -0
- package/dist/commonjs/normalize-unicode.d.ts.map +1 -0
- package/dist/commonjs/normalize-unicode.js +17 -0
- package/dist/commonjs/normalize-unicode.js.map +1 -0
- package/dist/commonjs/normalize-windows-path.d.ts +2 -0
- package/dist/commonjs/normalize-windows-path.d.ts.map +1 -0
- package/dist/commonjs/normalize-windows-path.js +12 -0
- package/dist/commonjs/normalize-windows-path.js.map +1 -0
- package/dist/commonjs/options.d.ts +545 -0
- package/dist/commonjs/options.d.ts.map +1 -0
- package/dist/commonjs/options.js +55 -0
- package/dist/commonjs/options.js.map +1 -0
- package/dist/commonjs/pack.d.ts +98 -0
- package/dist/commonjs/pack.d.ts.map +1 -0
- package/dist/commonjs/pack.js +461 -0
- package/dist/commonjs/pack.js.map +1 -0
- package/dist/commonjs/package.json +3 -0
- package/dist/commonjs/parse.d.ts +84 -0
- package/dist/commonjs/parse.d.ts.map +1 -0
- package/dist/commonjs/parse.js +571 -0
- package/dist/commonjs/parse.js.map +1 -0
- package/dist/commonjs/path-reservations.d.ts +11 -0
- package/dist/commonjs/path-reservations.d.ts.map +1 -0
- package/dist/commonjs/path-reservations.js +169 -0
- package/dist/commonjs/path-reservations.js.map +1 -0
- package/dist/commonjs/pax.d.ts +27 -0
- package/dist/commonjs/pax.d.ts.map +1 -0
- package/dist/commonjs/pax.js +158 -0
- package/dist/commonjs/pax.js.map +1 -0
- package/dist/commonjs/read-entry.d.ts +37 -0
- package/dist/commonjs/read-entry.d.ts.map +1 -0
- package/dist/commonjs/read-entry.js +139 -0
- package/dist/commonjs/read-entry.js.map +1 -0
- package/dist/commonjs/replace.d.ts +5 -0
- package/dist/commonjs/replace.d.ts.map +1 -0
- package/dist/commonjs/replace.js +223 -0
- package/dist/commonjs/replace.js.map +1 -0
- package/dist/commonjs/strip-absolute-path.d.ts +2 -0
- package/dist/commonjs/strip-absolute-path.d.ts.map +1 -0
- package/dist/commonjs/strip-absolute-path.js +29 -0
- package/dist/commonjs/strip-absolute-path.js.map +1 -0
- package/dist/commonjs/strip-trailing-slashes.d.ts +2 -0
- package/dist/commonjs/strip-trailing-slashes.d.ts.map +1 -0
- package/dist/commonjs/strip-trailing-slashes.js +18 -0
- package/dist/commonjs/strip-trailing-slashes.js.map +1 -0
- package/dist/commonjs/symlink-error.d.ts +9 -0
- package/dist/commonjs/symlink-error.d.ts.map +1 -0
- package/dist/commonjs/symlink-error.js +19 -0
- package/dist/commonjs/symlink-error.js.map +1 -0
- package/dist/commonjs/types.d.ts +7 -0
- package/dist/commonjs/types.d.ts.map +1 -0
- package/dist/commonjs/types.js +50 -0
- package/dist/commonjs/types.js.map +1 -0
- package/dist/commonjs/unpack.d.ts +98 -0
- package/dist/commonjs/unpack.d.ts.map +1 -0
- package/dist/commonjs/unpack.js +921 -0
- package/dist/commonjs/unpack.js.map +1 -0
- package/dist/commonjs/update.d.ts +3 -0
- package/dist/commonjs/update.d.ts.map +1 -0
- package/dist/commonjs/update.js +47 -0
- package/dist/commonjs/update.js.map +1 -0
- package/dist/commonjs/warn-method.d.ts +20 -0
- package/dist/commonjs/warn-method.d.ts.map +1 -0
- package/dist/commonjs/warn-method.js +31 -0
- package/dist/commonjs/warn-method.js.map +1 -0
- package/dist/commonjs/winchars.d.ts +3 -0
- package/dist/commonjs/winchars.d.ts.map +1 -0
- package/dist/commonjs/winchars.js +14 -0
- package/dist/commonjs/winchars.js.map +1 -0
- package/dist/commonjs/write-entry.d.ts +125 -0
- package/dist/commonjs/write-entry.d.ts.map +1 -0
- package/dist/commonjs/write-entry.js +657 -0
- package/dist/commonjs/write-entry.js.map +1 -0
- package/dist/esm/create.d.ts +8 -0
- package/dist/esm/create.d.ts.map +1 -0
- package/dist/esm/create.js +99 -0
- package/dist/esm/create.js.map +1 -0
- package/dist/esm/cwd-error.d.ts +8 -0
- package/dist/esm/cwd-error.d.ts.map +1 -0
- package/dist/esm/cwd-error.js +14 -0
- package/dist/esm/cwd-error.js.map +1 -0
- package/dist/esm/extract.d.ts +8 -0
- package/dist/esm/extract.d.ts.map +1 -0
- package/dist/esm/extract.js +111 -0
- package/dist/esm/extract.js.map +1 -0
- package/dist/esm/get-write-flag.d.ts +2 -0
- package/dist/esm/get-write-flag.d.ts.map +1 -0
- package/dist/esm/get-write-flag.js +23 -0
- package/dist/esm/get-write-flag.js.map +1 -0
- package/dist/esm/header.d.ts +54 -0
- package/dist/esm/header.d.ts.map +1 -0
- package/dist/esm/header.js +281 -0
- package/dist/esm/header.js.map +1 -0
- package/dist/esm/index.d.ts +19 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +20 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/large-numbers.d.ts +4 -0
- package/dist/esm/large-numbers.d.ts.map +1 -0
- package/dist/esm/large-numbers.js +94 -0
- package/dist/esm/large-numbers.js.map +1 -0
- package/dist/esm/list.d.ts +8 -0
- package/dist/esm/list.d.ts.map +1 -0
- package/dist/esm/list.js +137 -0
- package/dist/esm/list.js.map +1 -0
- package/dist/esm/mkdir.d.ts +27 -0
- package/dist/esm/mkdir.d.ts.map +1 -0
- package/dist/esm/mkdir.js +201 -0
- package/dist/esm/mkdir.js.map +1 -0
- package/dist/esm/mode-fix.d.ts +2 -0
- package/dist/esm/mode-fix.d.ts.map +1 -0
- package/dist/esm/mode-fix.js +25 -0
- package/dist/esm/mode-fix.js.map +1 -0
- package/dist/esm/normalize-unicode.d.ts +2 -0
- package/dist/esm/normalize-unicode.d.ts.map +1 -0
- package/dist/esm/normalize-unicode.js +13 -0
- package/dist/esm/normalize-unicode.js.map +1 -0
- package/dist/esm/normalize-windows-path.d.ts +2 -0
- package/dist/esm/normalize-windows-path.d.ts.map +1 -0
- package/{lib → dist/esm}/normalize-windows-path.js +5 -4
- package/dist/esm/normalize-windows-path.js.map +1 -0
- package/dist/esm/options.d.ts +545 -0
- package/dist/esm/options.d.ts.map +1 -0
- package/dist/esm/options.js +48 -0
- package/dist/esm/options.js.map +1 -0
- package/dist/esm/pack.d.ts +98 -0
- package/dist/esm/pack.d.ts.map +1 -0
- package/dist/esm/pack.js +429 -0
- package/dist/esm/pack.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/parse.d.ts +84 -0
- package/dist/esm/parse.d.ts.map +1 -0
- package/dist/esm/parse.js +567 -0
- package/dist/esm/parse.js.map +1 -0
- package/dist/esm/path-reservations.d.ts +11 -0
- package/dist/esm/path-reservations.d.ts.map +1 -0
- package/dist/esm/path-reservations.js +165 -0
- package/dist/esm/path-reservations.js.map +1 -0
- package/dist/esm/pax.d.ts +27 -0
- package/dist/esm/pax.d.ts.map +1 -0
- package/dist/esm/pax.js +154 -0
- package/dist/esm/pax.js.map +1 -0
- package/dist/esm/read-entry.d.ts +37 -0
- package/dist/esm/read-entry.d.ts.map +1 -0
- package/dist/esm/read-entry.js +135 -0
- package/dist/esm/read-entry.js.map +1 -0
- package/dist/esm/replace.d.ts +5 -0
- package/dist/esm/replace.d.ts.map +1 -0
- package/dist/esm/replace.js +216 -0
- package/dist/esm/replace.js.map +1 -0
- package/dist/esm/strip-absolute-path.d.ts +2 -0
- package/dist/esm/strip-absolute-path.d.ts.map +1 -0
- package/dist/esm/strip-absolute-path.js +25 -0
- package/dist/esm/strip-absolute-path.js.map +1 -0
- package/dist/esm/strip-trailing-slashes.d.ts +2 -0
- package/dist/esm/strip-trailing-slashes.d.ts.map +1 -0
- package/dist/esm/strip-trailing-slashes.js +14 -0
- package/dist/esm/strip-trailing-slashes.js.map +1 -0
- package/dist/esm/symlink-error.d.ts +9 -0
- package/dist/esm/symlink-error.d.ts.map +1 -0
- package/dist/esm/symlink-error.js +15 -0
- package/dist/esm/symlink-error.js.map +1 -0
- package/dist/esm/types.d.ts +7 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +45 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/unpack.d.ts +98 -0
- package/dist/esm/unpack.d.ts.map +1 -0
- package/dist/esm/unpack.js +890 -0
- package/dist/esm/unpack.js.map +1 -0
- package/dist/esm/update.d.ts +3 -0
- package/dist/esm/update.d.ts.map +1 -0
- package/dist/esm/update.js +43 -0
- package/dist/esm/update.js.map +1 -0
- package/dist/esm/warn-method.d.ts +20 -0
- package/dist/esm/warn-method.d.ts.map +1 -0
- package/dist/esm/warn-method.js +27 -0
- package/dist/esm/warn-method.js.map +1 -0
- package/dist/esm/winchars.d.ts +3 -0
- package/dist/esm/winchars.d.ts.map +1 -0
- package/dist/esm/winchars.js +9 -0
- package/dist/esm/winchars.js.map +1 -0
- package/dist/esm/write-entry.d.ts +125 -0
- package/dist/esm/write-entry.d.ts.map +1 -0
- package/dist/esm/write-entry.js +625 -0
- package/dist/esm/write-entry.js.map +1 -0
- package/package.json +255 -40
- package/index.js +0 -18
- package/lib/create.js +0 -111
- package/lib/extract.js +0 -113
- package/lib/get-write-flag.js +0 -20
- package/lib/header.js +0 -304
- package/lib/high-level-opt.js +0 -29
- package/lib/large-numbers.js +0 -104
- package/lib/list.js +0 -139
- package/lib/mkdir.js +0 -229
- package/lib/mode-fix.js +0 -27
- package/lib/normalize-unicode.js +0 -12
- package/lib/pack.js +0 -432
- package/lib/parse.js +0 -552
- package/lib/path-reservations.js +0 -156
- package/lib/pax.js +0 -150
- package/lib/read-entry.js +0 -107
- package/lib/replace.js +0 -246
- package/lib/strip-absolute-path.js +0 -24
- package/lib/strip-trailing-slashes.js +0 -13
- package/lib/types.js +0 -44
- package/lib/unpack.js +0 -906
- package/lib/update.js +0 -40
- package/lib/warn-mixin.js +0 -24
- package/lib/winchars.js +0 -23
- package/lib/write-entry.js +0 -546
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/parse.ts"],"names":[],"mappings":";;AAoBA,OAAO,EAAE,YAAY,IAAI,EAAE,EAAE,MAAM,QAAQ,CAAA;AA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IA6C/B,GAAG,CAAC,KAAK,CAAC,EAAE,MAAM;CAgBnB"}
|
|
@@ -0,0 +1,567 @@
|
|
|
1
|
+
// this[BUFFER] is the remainder of a chunk if we're waiting for
|
|
2
|
+
// the full 512 bytes of a header to come in. We will Buffer.concat()
|
|
3
|
+
// it to the next write(), which is a mem copy, but a small one.
|
|
4
|
+
//
|
|
5
|
+
// this[QUEUE] is a Yallist of entries that haven't been emitted
|
|
6
|
+
// yet this can only get filled up if the user keeps write()ing after
|
|
7
|
+
// a write() returns false, or does a write() with more than one entry
|
|
8
|
+
//
|
|
9
|
+
// We don't buffer chunks, we always parse them and either create an
|
|
10
|
+
// entry, or push it into the active entry. The ReadEntry class knows
|
|
11
|
+
// to throw data away if .ignore=true
|
|
12
|
+
//
|
|
13
|
+
// Shift entry off the buffer when it emits 'end', and emit 'entry' for
|
|
14
|
+
// the next one in the list.
|
|
15
|
+
//
|
|
16
|
+
// At any time, we're pushing body chunks into the entry at WRITEENTRY,
|
|
17
|
+
// and waiting for 'end' on the entry at READENTRY
|
|
18
|
+
//
|
|
19
|
+
// ignored entries get .resume() called on them straight away
|
|
20
|
+
import { EventEmitter as EE } from 'events';
|
|
21
|
+
import { BrotliDecompress, Unzip } from 'minizlib';
|
|
22
|
+
import { Yallist } from 'yallist';
|
|
23
|
+
import { Header } from './header.js';
|
|
24
|
+
import { Pax } from './pax.js';
|
|
25
|
+
import { ReadEntry } from './read-entry.js';
|
|
26
|
+
import { warnMethod, } from './warn-method.js';
|
|
27
|
+
const maxMetaEntrySize = 1024 * 1024;
|
|
28
|
+
const gzipHeader = Buffer.from([0x1f, 0x8b]);
|
|
29
|
+
const STATE = Symbol('state');
|
|
30
|
+
const WRITEENTRY = Symbol('writeEntry');
|
|
31
|
+
const READENTRY = Symbol('readEntry');
|
|
32
|
+
const NEXTENTRY = Symbol('nextEntry');
|
|
33
|
+
const PROCESSENTRY = Symbol('processEntry');
|
|
34
|
+
const EX = Symbol('extendedHeader');
|
|
35
|
+
const GEX = Symbol('globalExtendedHeader');
|
|
36
|
+
const META = Symbol('meta');
|
|
37
|
+
const EMITMETA = Symbol('emitMeta');
|
|
38
|
+
const BUFFER = Symbol('buffer');
|
|
39
|
+
const QUEUE = Symbol('queue');
|
|
40
|
+
const ENDED = Symbol('ended');
|
|
41
|
+
const EMITTEDEND = Symbol('emittedEnd');
|
|
42
|
+
const EMIT = Symbol('emit');
|
|
43
|
+
const UNZIP = Symbol('unzip');
|
|
44
|
+
const CONSUMECHUNK = Symbol('consumeChunk');
|
|
45
|
+
const CONSUMECHUNKSUB = Symbol('consumeChunkSub');
|
|
46
|
+
const CONSUMEBODY = Symbol('consumeBody');
|
|
47
|
+
const CONSUMEMETA = Symbol('consumeMeta');
|
|
48
|
+
const CONSUMEHEADER = Symbol('consumeHeader');
|
|
49
|
+
const CONSUMING = Symbol('consuming');
|
|
50
|
+
const BUFFERCONCAT = Symbol('bufferConcat');
|
|
51
|
+
const MAYBEEND = Symbol('maybeEnd');
|
|
52
|
+
const WRITING = Symbol('writing');
|
|
53
|
+
const ABORTED = Symbol('aborted');
|
|
54
|
+
const DONE = Symbol('onDone');
|
|
55
|
+
const SAW_VALID_ENTRY = Symbol('sawValidEntry');
|
|
56
|
+
const SAW_NULL_BLOCK = Symbol('sawNullBlock');
|
|
57
|
+
const SAW_EOF = Symbol('sawEOF');
|
|
58
|
+
const CLOSESTREAM = Symbol('closeStream');
|
|
59
|
+
const noop = () => true;
|
|
60
|
+
export class Parser extends EE {
|
|
61
|
+
file;
|
|
62
|
+
strict;
|
|
63
|
+
maxMetaEntrySize;
|
|
64
|
+
filter;
|
|
65
|
+
brotli;
|
|
66
|
+
writable = true;
|
|
67
|
+
readable = false;
|
|
68
|
+
[QUEUE] = new Yallist();
|
|
69
|
+
[BUFFER];
|
|
70
|
+
[READENTRY];
|
|
71
|
+
[WRITEENTRY];
|
|
72
|
+
[STATE] = 'begin';
|
|
73
|
+
[META] = '';
|
|
74
|
+
[EX];
|
|
75
|
+
[GEX];
|
|
76
|
+
[ENDED] = false;
|
|
77
|
+
[UNZIP];
|
|
78
|
+
[ABORTED] = false;
|
|
79
|
+
[SAW_VALID_ENTRY];
|
|
80
|
+
[SAW_NULL_BLOCK] = false;
|
|
81
|
+
[SAW_EOF] = false;
|
|
82
|
+
[WRITING] = false;
|
|
83
|
+
[CONSUMING] = false;
|
|
84
|
+
[EMITTEDEND] = false;
|
|
85
|
+
constructor(opt = {}) {
|
|
86
|
+
super();
|
|
87
|
+
this.file = opt.file || '';
|
|
88
|
+
// these BADARCHIVE errors can't be detected early. listen on DONE.
|
|
89
|
+
this.on(DONE, () => {
|
|
90
|
+
if (this[STATE] === 'begin' ||
|
|
91
|
+
this[SAW_VALID_ENTRY] === false) {
|
|
92
|
+
// either less than 1 block of data, or all entries were invalid.
|
|
93
|
+
// Either way, probably not even a tarball.
|
|
94
|
+
this.warn('TAR_BAD_ARCHIVE', 'Unrecognized archive format');
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
if (opt.ondone) {
|
|
98
|
+
this.on(DONE, opt.ondone);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
this.on(DONE, () => {
|
|
102
|
+
this.emit('prefinish');
|
|
103
|
+
this.emit('finish');
|
|
104
|
+
this.emit('end');
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
this.strict = !!opt.strict;
|
|
108
|
+
this.maxMetaEntrySize = opt.maxMetaEntrySize || maxMetaEntrySize;
|
|
109
|
+
this.filter = typeof opt.filter === 'function' ? opt.filter : noop;
|
|
110
|
+
// Unlike gzip, brotli doesn't have any magic bytes to identify it
|
|
111
|
+
// Users need to explicitly tell us they're extracting a brotli file
|
|
112
|
+
// Or we infer from the file extension
|
|
113
|
+
const isTBR = opt.file &&
|
|
114
|
+
(opt.file.endsWith('.tar.br') || opt.file.endsWith('.tbr'));
|
|
115
|
+
// if it's a tbr file it MIGHT be brotli, but we don't know until
|
|
116
|
+
// we look at it and verify it's not a valid tar file.
|
|
117
|
+
this.brotli =
|
|
118
|
+
!opt.gzip && opt.brotli !== undefined
|
|
119
|
+
? opt.brotli
|
|
120
|
+
: isTBR
|
|
121
|
+
? undefined
|
|
122
|
+
: false;
|
|
123
|
+
// have to set this so that streams are ok piping into it
|
|
124
|
+
this.on('end', () => this[CLOSESTREAM]());
|
|
125
|
+
if (typeof opt.onwarn === 'function') {
|
|
126
|
+
this.on('warn', opt.onwarn);
|
|
127
|
+
}
|
|
128
|
+
if (typeof opt.onentry === 'function') {
|
|
129
|
+
this.on('entry', opt.onentry);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
warn(code, message, data = {}) {
|
|
133
|
+
warnMethod(this, code, message, data);
|
|
134
|
+
}
|
|
135
|
+
[CONSUMEHEADER](chunk, position) {
|
|
136
|
+
if (this[SAW_VALID_ENTRY] === undefined) {
|
|
137
|
+
this[SAW_VALID_ENTRY] = false;
|
|
138
|
+
}
|
|
139
|
+
let header;
|
|
140
|
+
try {
|
|
141
|
+
header = new Header(chunk, position, this[EX], this[GEX]);
|
|
142
|
+
}
|
|
143
|
+
catch (er) {
|
|
144
|
+
return this.warn('TAR_ENTRY_INVALID', er);
|
|
145
|
+
}
|
|
146
|
+
if (header.nullBlock) {
|
|
147
|
+
if (this[SAW_NULL_BLOCK]) {
|
|
148
|
+
this[SAW_EOF] = true;
|
|
149
|
+
// ending an archive with no entries. pointless, but legal.
|
|
150
|
+
if (this[STATE] === 'begin') {
|
|
151
|
+
this[STATE] = 'header';
|
|
152
|
+
}
|
|
153
|
+
this[EMIT]('eof');
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
this[SAW_NULL_BLOCK] = true;
|
|
157
|
+
this[EMIT]('nullBlock');
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
this[SAW_NULL_BLOCK] = false;
|
|
162
|
+
if (!header.cksumValid) {
|
|
163
|
+
this.warn('TAR_ENTRY_INVALID', 'checksum failure', { header });
|
|
164
|
+
}
|
|
165
|
+
else if (!header.path) {
|
|
166
|
+
this.warn('TAR_ENTRY_INVALID', 'path is required', { header });
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
const type = header.type;
|
|
170
|
+
if (/^(Symbolic)?Link$/.test(type) && !header.linkpath) {
|
|
171
|
+
this.warn('TAR_ENTRY_INVALID', 'linkpath required', {
|
|
172
|
+
header,
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
else if (!/^(Symbolic)?Link$/.test(type) &&
|
|
176
|
+
!/^(Global)?ExtendedHeader$/.test(type) &&
|
|
177
|
+
header.linkpath) {
|
|
178
|
+
this.warn('TAR_ENTRY_INVALID', 'linkpath forbidden', {
|
|
179
|
+
header,
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
const entry = (this[WRITEENTRY] = new ReadEntry(header, this[EX], this[GEX]));
|
|
184
|
+
// we do this for meta & ignored entries as well, because they
|
|
185
|
+
// are still valid tar, or else we wouldn't know to ignore them
|
|
186
|
+
if (!this[SAW_VALID_ENTRY]) {
|
|
187
|
+
if (entry.remain) {
|
|
188
|
+
// this might be the one!
|
|
189
|
+
const onend = () => {
|
|
190
|
+
if (!entry.invalid) {
|
|
191
|
+
this[SAW_VALID_ENTRY] = true;
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
entry.on('end', onend);
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
this[SAW_VALID_ENTRY] = true;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (entry.meta) {
|
|
201
|
+
if (entry.size > this.maxMetaEntrySize) {
|
|
202
|
+
entry.ignore = true;
|
|
203
|
+
this[EMIT]('ignoredEntry', entry);
|
|
204
|
+
this[STATE] = 'ignore';
|
|
205
|
+
entry.resume();
|
|
206
|
+
}
|
|
207
|
+
else if (entry.size > 0) {
|
|
208
|
+
this[META] = '';
|
|
209
|
+
entry.on('data', c => (this[META] += c));
|
|
210
|
+
this[STATE] = 'meta';
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
this[EX] = undefined;
|
|
215
|
+
entry.ignore =
|
|
216
|
+
entry.ignore || !this.filter(entry.path, entry);
|
|
217
|
+
if (entry.ignore) {
|
|
218
|
+
// probably valid, just not something we care about
|
|
219
|
+
this[EMIT]('ignoredEntry', entry);
|
|
220
|
+
this[STATE] = entry.remain ? 'ignore' : 'header';
|
|
221
|
+
entry.resume();
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
if (entry.remain) {
|
|
225
|
+
this[STATE] = 'body';
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
this[STATE] = 'header';
|
|
229
|
+
entry.end();
|
|
230
|
+
}
|
|
231
|
+
if (!this[READENTRY]) {
|
|
232
|
+
this[QUEUE].push(entry);
|
|
233
|
+
this[NEXTENTRY]();
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
this[QUEUE].push(entry);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
[CLOSESTREAM]() {
|
|
245
|
+
queueMicrotask(() => this.emit('close'));
|
|
246
|
+
}
|
|
247
|
+
[PROCESSENTRY](entry) {
|
|
248
|
+
let go = true;
|
|
249
|
+
if (!entry) {
|
|
250
|
+
this[READENTRY] = undefined;
|
|
251
|
+
go = false;
|
|
252
|
+
}
|
|
253
|
+
else if (Array.isArray(entry)) {
|
|
254
|
+
const [ev, ...args] = entry;
|
|
255
|
+
this.emit(ev, ...args);
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
this[READENTRY] = entry;
|
|
259
|
+
this.emit('entry', entry);
|
|
260
|
+
if (!entry.emittedEnd) {
|
|
261
|
+
entry.on('end', () => this[NEXTENTRY]());
|
|
262
|
+
go = false;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
return go;
|
|
266
|
+
}
|
|
267
|
+
[NEXTENTRY]() {
|
|
268
|
+
do { } while (this[PROCESSENTRY](this[QUEUE].shift()));
|
|
269
|
+
if (!this[QUEUE].length) {
|
|
270
|
+
// At this point, there's nothing in the queue, but we may have an
|
|
271
|
+
// entry which is being consumed (readEntry).
|
|
272
|
+
// If we don't, then we definitely can handle more data.
|
|
273
|
+
// If we do, and either it's flowing, or it has never had any data
|
|
274
|
+
// written to it, then it needs more.
|
|
275
|
+
// The only other possibility is that it has returned false from a
|
|
276
|
+
// write() call, so we wait for the next drain to continue.
|
|
277
|
+
const re = this[READENTRY];
|
|
278
|
+
const drainNow = !re || re.flowing || re.size === re.remain;
|
|
279
|
+
if (drainNow) {
|
|
280
|
+
if (!this[WRITING]) {
|
|
281
|
+
this.emit('drain');
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
re.once('drain', () => this.emit('drain'));
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
[CONSUMEBODY](chunk, position) {
|
|
290
|
+
// write up to but no more than writeEntry.blockRemain
|
|
291
|
+
const entry = this[WRITEENTRY];
|
|
292
|
+
/* c8 ignore start */
|
|
293
|
+
if (!entry) {
|
|
294
|
+
throw new Error('attempt to consume body without entry??');
|
|
295
|
+
}
|
|
296
|
+
const br = entry.blockRemain ?? 0;
|
|
297
|
+
/* c8 ignore stop */
|
|
298
|
+
const c = br >= chunk.length && position === 0
|
|
299
|
+
? chunk
|
|
300
|
+
: chunk.subarray(position, position + br);
|
|
301
|
+
entry.write(c);
|
|
302
|
+
if (!entry.blockRemain) {
|
|
303
|
+
this[STATE] = 'header';
|
|
304
|
+
this[WRITEENTRY] = undefined;
|
|
305
|
+
entry.end();
|
|
306
|
+
}
|
|
307
|
+
return c.length;
|
|
308
|
+
}
|
|
309
|
+
[CONSUMEMETA](chunk, position) {
|
|
310
|
+
const entry = this[WRITEENTRY];
|
|
311
|
+
const ret = this[CONSUMEBODY](chunk, position);
|
|
312
|
+
// if we finished, then the entry is reset
|
|
313
|
+
if (!this[WRITEENTRY] && entry) {
|
|
314
|
+
this[EMITMETA](entry);
|
|
315
|
+
}
|
|
316
|
+
return ret;
|
|
317
|
+
}
|
|
318
|
+
[EMIT](ev, data, extra) {
|
|
319
|
+
if (!this[QUEUE].length && !this[READENTRY]) {
|
|
320
|
+
this.emit(ev, data, extra);
|
|
321
|
+
}
|
|
322
|
+
else {
|
|
323
|
+
this[QUEUE].push([ev, data, extra]);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
[EMITMETA](entry) {
|
|
327
|
+
this[EMIT]('meta', this[META]);
|
|
328
|
+
switch (entry.type) {
|
|
329
|
+
case 'ExtendedHeader':
|
|
330
|
+
case 'OldExtendedHeader':
|
|
331
|
+
this[EX] = Pax.parse(this[META], this[EX], false);
|
|
332
|
+
break;
|
|
333
|
+
case 'GlobalExtendedHeader':
|
|
334
|
+
this[GEX] = Pax.parse(this[META], this[GEX], true);
|
|
335
|
+
break;
|
|
336
|
+
case 'NextFileHasLongPath':
|
|
337
|
+
case 'OldGnuLongPath': {
|
|
338
|
+
const ex = this[EX] ?? Object.create(null);
|
|
339
|
+
this[EX] = ex;
|
|
340
|
+
ex.path = this[META].replace(/\0.*/, '');
|
|
341
|
+
break;
|
|
342
|
+
}
|
|
343
|
+
case 'NextFileHasLongLinkpath': {
|
|
344
|
+
const ex = this[EX] || Object.create(null);
|
|
345
|
+
this[EX] = ex;
|
|
346
|
+
ex.linkpath = this[META].replace(/\0.*/, '');
|
|
347
|
+
break;
|
|
348
|
+
}
|
|
349
|
+
/* c8 ignore start */
|
|
350
|
+
default:
|
|
351
|
+
throw new Error('unknown meta: ' + entry.type);
|
|
352
|
+
/* c8 ignore stop */
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
abort(error) {
|
|
356
|
+
this[ABORTED] = true;
|
|
357
|
+
this.emit('abort', error);
|
|
358
|
+
// always throws, even in non-strict mode
|
|
359
|
+
this.warn('TAR_ABORT', error, { recoverable: false });
|
|
360
|
+
}
|
|
361
|
+
write(chunk) {
|
|
362
|
+
if (this[ABORTED]) {
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
// first write, might be gzipped
|
|
366
|
+
const needSniff = this[UNZIP] === undefined ||
|
|
367
|
+
(this.brotli === undefined && this[UNZIP] === false);
|
|
368
|
+
if (needSniff && chunk) {
|
|
369
|
+
if (this[BUFFER]) {
|
|
370
|
+
chunk = Buffer.concat([this[BUFFER], chunk]);
|
|
371
|
+
this[BUFFER] = undefined;
|
|
372
|
+
}
|
|
373
|
+
if (chunk.length < gzipHeader.length) {
|
|
374
|
+
this[BUFFER] = chunk;
|
|
375
|
+
return true;
|
|
376
|
+
}
|
|
377
|
+
// look for gzip header
|
|
378
|
+
for (let i = 0; this[UNZIP] === undefined && i < gzipHeader.length; i++) {
|
|
379
|
+
if (chunk[i] !== gzipHeader[i]) {
|
|
380
|
+
this[UNZIP] = false;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
const maybeBrotli = this.brotli === undefined;
|
|
384
|
+
if (this[UNZIP] === false && maybeBrotli) {
|
|
385
|
+
// read the first header to see if it's a valid tar file. If so,
|
|
386
|
+
// we can safely assume that it's not actually brotli, despite the
|
|
387
|
+
// .tbr or .tar.br file extension.
|
|
388
|
+
// if we ended before getting a full chunk, yes, def brotli
|
|
389
|
+
if (chunk.length < 512) {
|
|
390
|
+
if (this[ENDED]) {
|
|
391
|
+
this.brotli = true;
|
|
392
|
+
}
|
|
393
|
+
else {
|
|
394
|
+
this[BUFFER] = chunk;
|
|
395
|
+
return true;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
else {
|
|
399
|
+
// if it's tar, it's pretty reliably not brotli, chances of
|
|
400
|
+
// that happening are astronomical.
|
|
401
|
+
try {
|
|
402
|
+
new Header(chunk.subarray(0, 512));
|
|
403
|
+
this.brotli = false;
|
|
404
|
+
}
|
|
405
|
+
catch (_) {
|
|
406
|
+
this.brotli = true;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
if (this[UNZIP] === undefined ||
|
|
411
|
+
(this[UNZIP] === false && this.brotli)) {
|
|
412
|
+
const ended = this[ENDED];
|
|
413
|
+
this[ENDED] = false;
|
|
414
|
+
this[UNZIP] =
|
|
415
|
+
this[UNZIP] === undefined
|
|
416
|
+
? new Unzip({})
|
|
417
|
+
: new BrotliDecompress({});
|
|
418
|
+
this[UNZIP].on('data', chunk => this[CONSUMECHUNK](chunk));
|
|
419
|
+
this[UNZIP].on('error', er => this.abort(er));
|
|
420
|
+
this[UNZIP].on('end', () => {
|
|
421
|
+
this[ENDED] = true;
|
|
422
|
+
this[CONSUMECHUNK]();
|
|
423
|
+
});
|
|
424
|
+
this[WRITING] = true;
|
|
425
|
+
const ret = this[UNZIP][ended ? 'end' : 'write'](chunk);
|
|
426
|
+
this[WRITING] = false;
|
|
427
|
+
return ret;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
this[WRITING] = true;
|
|
431
|
+
if (this[UNZIP]) {
|
|
432
|
+
this[UNZIP].write(chunk);
|
|
433
|
+
}
|
|
434
|
+
else {
|
|
435
|
+
this[CONSUMECHUNK](chunk);
|
|
436
|
+
}
|
|
437
|
+
this[WRITING] = false;
|
|
438
|
+
// return false if there's a queue, or if the current entry isn't flowing
|
|
439
|
+
const ret = this[QUEUE].length
|
|
440
|
+
? false
|
|
441
|
+
: this[READENTRY]
|
|
442
|
+
? this[READENTRY].flowing
|
|
443
|
+
: true;
|
|
444
|
+
// if we have no queue, then that means a clogged READENTRY
|
|
445
|
+
if (!ret && !this[QUEUE].length) {
|
|
446
|
+
this[READENTRY]?.once('drain', () => this.emit('drain'));
|
|
447
|
+
}
|
|
448
|
+
return ret;
|
|
449
|
+
}
|
|
450
|
+
[BUFFERCONCAT](c) {
|
|
451
|
+
if (c && !this[ABORTED]) {
|
|
452
|
+
this[BUFFER] = this[BUFFER]
|
|
453
|
+
? Buffer.concat([this[BUFFER], c])
|
|
454
|
+
: c;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
[MAYBEEND]() {
|
|
458
|
+
if (this[ENDED] &&
|
|
459
|
+
!this[EMITTEDEND] &&
|
|
460
|
+
!this[ABORTED] &&
|
|
461
|
+
!this[CONSUMING]) {
|
|
462
|
+
this[EMITTEDEND] = true;
|
|
463
|
+
const entry = this[WRITEENTRY];
|
|
464
|
+
if (entry && entry.blockRemain) {
|
|
465
|
+
// truncated, likely a damaged file
|
|
466
|
+
const have = this[BUFFER] ? this[BUFFER].length : 0;
|
|
467
|
+
this.warn('TAR_BAD_ARCHIVE', `Truncated input (needed ${entry.blockRemain} more bytes, only ${have} available)`, { entry });
|
|
468
|
+
if (this[BUFFER]) {
|
|
469
|
+
entry.write(this[BUFFER]);
|
|
470
|
+
}
|
|
471
|
+
entry.end();
|
|
472
|
+
}
|
|
473
|
+
this[EMIT](DONE);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
[CONSUMECHUNK](chunk) {
|
|
477
|
+
if (this[CONSUMING] && chunk) {
|
|
478
|
+
this[BUFFERCONCAT](chunk);
|
|
479
|
+
}
|
|
480
|
+
else if (!chunk && !this[BUFFER]) {
|
|
481
|
+
this[MAYBEEND]();
|
|
482
|
+
}
|
|
483
|
+
else if (chunk) {
|
|
484
|
+
this[CONSUMING] = true;
|
|
485
|
+
if (this[BUFFER]) {
|
|
486
|
+
this[BUFFERCONCAT](chunk);
|
|
487
|
+
const c = this[BUFFER];
|
|
488
|
+
this[BUFFER] = undefined;
|
|
489
|
+
this[CONSUMECHUNKSUB](c);
|
|
490
|
+
}
|
|
491
|
+
else {
|
|
492
|
+
this[CONSUMECHUNKSUB](chunk);
|
|
493
|
+
}
|
|
494
|
+
while (this[BUFFER] &&
|
|
495
|
+
this[BUFFER]?.length >= 512 &&
|
|
496
|
+
!this[ABORTED] &&
|
|
497
|
+
!this[SAW_EOF]) {
|
|
498
|
+
const c = this[BUFFER];
|
|
499
|
+
this[BUFFER] = undefined;
|
|
500
|
+
this[CONSUMECHUNKSUB](c);
|
|
501
|
+
}
|
|
502
|
+
this[CONSUMING] = false;
|
|
503
|
+
}
|
|
504
|
+
if (!this[BUFFER] || this[ENDED]) {
|
|
505
|
+
this[MAYBEEND]();
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
[CONSUMECHUNKSUB](chunk) {
|
|
509
|
+
// we know that we are in CONSUMING mode, so anything written goes into
|
|
510
|
+
// the buffer. Advance the position and put any remainder in the buffer.
|
|
511
|
+
let position = 0;
|
|
512
|
+
const length = chunk.length;
|
|
513
|
+
while (position + 512 <= length &&
|
|
514
|
+
!this[ABORTED] &&
|
|
515
|
+
!this[SAW_EOF]) {
|
|
516
|
+
switch (this[STATE]) {
|
|
517
|
+
case 'begin':
|
|
518
|
+
case 'header':
|
|
519
|
+
this[CONSUMEHEADER](chunk, position);
|
|
520
|
+
position += 512;
|
|
521
|
+
break;
|
|
522
|
+
case 'ignore':
|
|
523
|
+
case 'body':
|
|
524
|
+
position += this[CONSUMEBODY](chunk, position);
|
|
525
|
+
break;
|
|
526
|
+
case 'meta':
|
|
527
|
+
position += this[CONSUMEMETA](chunk, position);
|
|
528
|
+
break;
|
|
529
|
+
/* c8 ignore start */
|
|
530
|
+
default:
|
|
531
|
+
throw new Error('invalid state: ' + this[STATE]);
|
|
532
|
+
/* c8 ignore stop */
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
if (position < length) {
|
|
536
|
+
if (this[BUFFER]) {
|
|
537
|
+
this[BUFFER] = Buffer.concat([
|
|
538
|
+
chunk.subarray(position),
|
|
539
|
+
this[BUFFER],
|
|
540
|
+
]);
|
|
541
|
+
}
|
|
542
|
+
else {
|
|
543
|
+
this[BUFFER] = chunk.subarray(position);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
end(chunk) {
|
|
548
|
+
if (!this[ABORTED]) {
|
|
549
|
+
if (this[UNZIP]) {
|
|
550
|
+
/* c8 ignore start */
|
|
551
|
+
if (chunk)
|
|
552
|
+
this[UNZIP].write(chunk);
|
|
553
|
+
/* c8 ignore stop */
|
|
554
|
+
this[UNZIP].end();
|
|
555
|
+
}
|
|
556
|
+
else {
|
|
557
|
+
this[ENDED] = true;
|
|
558
|
+
if (this.brotli === undefined)
|
|
559
|
+
chunk = chunk || Buffer.alloc(0);
|
|
560
|
+
if (chunk)
|
|
561
|
+
this.write(chunk);
|
|
562
|
+
this[MAYBEEND]();
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
//# sourceMappingURL=parse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../../src/parse.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,sEAAsE;AACtE,gEAAgE;AAChE,EAAE;AACF,gEAAgE;AAChE,qEAAqE;AACrE,sEAAsE;AACtE,EAAE;AACF,oEAAoE;AACpE,sEAAsE;AACtE,qCAAqC;AACrC,EAAE;AACF,uEAAuE;AACvE,4BAA4B;AAC5B,EAAE;AACF,uEAAuE;AACvE,kDAAkD;AAClD,EAAE;AACF,6DAA6D;AAE7D,OAAO,EAAE,YAAY,IAAI,EAAE,EAAE,MAAM,QAAQ,CAAA;AAC3C,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EACL,UAAU,GAGX,MAAM,kBAAkB,CAAA;AAEzB,MAAM,gBAAgB,GAAG,IAAI,GAAG,IAAI,CAAA;AACpC,MAAM,UAAU,GAAG,MAAM,CAAC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AC;iBACb,CAAC,CAAA;YACJ,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;YACzC,CAAC;QACH,CAAC;IACH,CAAC;IAED,GAAG,CAAC,KAAc;QAChB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;YACnB,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;gBAChB,qBAAqB;gBACrB,IAAI,KAAK;oBAAE,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;gBACnC,oBAAoB;gBACpB,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,CAAA;YACnB,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,CAAA;gBAClB,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS;oBAC3B,KAAK,GAAG,KAAK,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;gBAClC,IAAI,KAAK;oBAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;gBAC5B,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAA;YAClB,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["// this[BUFFER] is the remainder of a chunk if we're waiting for\n// the full 512 bytes of a header to come in. We will Buffer.concat()\n// it to the next write(), which is a mem copy, but a small one.\n//\n// this[QUEUE] is a Yallist of entries that haven't been emitted\n// yet this can only get filled up if the user keeps write()ing after\n// a write() returns false, or does a write() with more than one entry\n//\n// We don't buffer chunks, we always parse them and either create an\n// entry, or push it into the active entry. The ReadEntry class knows\n// to throw data away if .ignore=true\n//\n// Shift entry off the buffer when it emits 'end', and emit 'entry' for\n// the next one in the list.\n//\n// At any time, we're pushing body chunks into the entry at WRITEENTRY,\n// and waiting for 'end' on the entry at READENTRY\n//\n// ignored entries get .resume() called on them straight away\n\nimport { EventEmitter as EE } from 'events'\nimport { BrotliDecompress, Unzip } from 'minizlib'\nimport { Yallist } from 'yallist'\nimport { Header } from './header.js'\nimport { TarOptions } from './options.js'\nimport { Pax } from './pax.js'\nimport { ReadEntry } from './read-entry.js'\nimport {\n warnMethod,\n type WarnData,\n type Warner,\n} from './warn-method.js'\n\nconst maxMetaEntrySize = 1024 * 1024\nconst gzipHeader = Buffer.from([0x1f, 0x8b])\n\nconst STATE = Symbol('state')\nconst WRITEENTRY = Symbol('writeEntry')\nconst READENTRY = Symbol('readEntry')\nconst NEXTENTRY = Symbol('nextEntry')\nconst PROCESSENTRY = Symbol('processEntry')\nconst EX = Symbol('extendedHeader')\nconst GEX = Symbol('globalExtendedHeader')\nconst META = Symbol('meta')\nconst EMITMETA = Symbol('emitMeta')\nconst BUFFER = Symbol('buffer')\nconst QUEUE = Symbol('queue')\nconst ENDED = Symbol('ended')\nconst EMITTEDEND = Symbol('emittedEnd')\nconst EMIT = Symbol('emit')\nconst UNZIP = Symbol('unzip')\nconst CONSUMECHUNK = Symbol('consumeChunk')\nconst CONSUMECHUNKSUB = Symbol('consumeChunkSub')\nconst CONSUMEBODY = Symbol('consumeBody')\nconst CONSUMEMETA = Symbol('consumeMeta')\nconst CONSUMEHEADER = Symbol('consumeHeader')\nconst CONSUMING = Symbol('consuming')\nconst BUFFERCONCAT = Symbol('bufferConcat')\nconst MAYBEEND = Symbol('maybeEnd')\nconst WRITING = Symbol('writing')\nconst ABORTED = Symbol('aborted')\nconst DONE = Symbol('onDone')\nconst SAW_VALID_ENTRY = Symbol('sawValidEntry')\nconst SAW_NULL_BLOCK = Symbol('sawNullBlock')\nconst SAW_EOF = Symbol('sawEOF')\nconst CLOSESTREAM = Symbol('closeStream')\n\nconst noop = () => true\n\nexport type State = 'begin' | 'header' | 'ignore' | 'meta' | 'body'\n\nexport class Parser extends EE implements Warner {\n file: string\n strict: boolean\n maxMetaEntrySize: number\n filter: Exclude<TarOptions['filter'], undefined>\n brotli?: TarOptions['brotli']\n\n writable: true = true\n readable: false = false;\n\n [QUEUE]: Yallist<ReadEntry | [string | symbol, any, any]> =\n new Yallist();\n [BUFFER]?: Buffer;\n [READENTRY]?: ReadEntry;\n [WRITEENTRY]?: ReadEntry;\n [STATE]: State = 'begin';\n [META]: string = '';\n [EX]?: Pax;\n [GEX]?: Pax;\n [ENDED]: boolean = false;\n [UNZIP]?: false | Unzip | BrotliDecompress;\n [ABORTED]: boolean = false;\n [SAW_VALID_ENTRY]?: boolean;\n [SAW_NULL_BLOCK]: boolean = false;\n [SAW_EOF]: boolean = false;\n [WRITING]: boolean = false;\n [CONSUMING]: boolean = false;\n [EMITTEDEND]: boolean = false\n\n constructor(opt: TarOptions = {}) {\n super()\n\n this.file = opt.file || ''\n\n // these BADARCHIVE errors can't be detected early. listen on DONE.\n this.on(DONE, () => {\n if (\n this[STATE] === 'begin' ||\n this[SAW_VALID_ENTRY] === false\n ) {\n // either less than 1 block of data, or all entries were invalid.\n // Either way, probably not even a tarball.\n this.warn('TAR_BAD_ARCHIVE', 'Unrecognized archive format')\n }\n })\n\n if (opt.ondone) {\n this.on(DONE, opt.ondone)\n } else {\n this.on(DONE, () => {\n this.emit('prefinish')\n this.emit('finish')\n this.emit('end')\n })\n }\n\n this.strict = !!opt.strict\n this.maxMetaEntrySize = opt.maxMetaEntrySize || maxMetaEntrySize\n this.filter = typeof opt.filter === 'function' ? opt.filter : noop\n // Unlike gzip, brotli doesn't have any magic bytes to identify it\n // Users need to explicitly tell us they're extracting a brotli file\n // Or we infer from the file extension\n const isTBR =\n opt.file &&\n (opt.file.endsWith('.tar.br') || opt.file.endsWith('.tbr'))\n // if it's a tbr file it MIGHT be brotli, but we don't know until\n // we look at it and verify it's not a valid tar file.\n this.brotli =\n !opt.gzip && opt.brotli !== undefined\n ? opt.brotli\n : isTBR\n ? undefined\n : false\n\n // have to set this so that streams are ok piping into it\n this.on('end', () => this[CLOSESTREAM]())\n\n if (typeof opt.onwarn === 'function') {\n this.on('warn', opt.onwarn)\n }\n if (typeof opt.onentry === 'function') {\n this.on('entry', opt.onentry)\n }\n }\n\n warn(\n code: string,\n message: string | Error,\n data: WarnData = {},\n ): void {\n warnMethod(this, code, message, data)\n }\n\n [CONSUMEHEADER](chunk: Buffer, position: number) {\n if (this[SAW_VALID_ENTRY] === undefined) {\n this[SAW_VALID_ENTRY] = false\n }\n let header\n try {\n header = new Header(chunk, position, this[EX], this[GEX])\n } catch (er) {\n return this.warn('TAR_ENTRY_INVALID', er as Error)\n }\n\n if (header.nullBlock) {\n if (this[SAW_NULL_BLOCK]) {\n this[SAW_EOF] = true\n // ending an archive with no entries. pointless, but legal.\n if (this[STATE] === 'begin') {\n this[STATE] = 'header'\n }\n this[EMIT]('eof')\n } else {\n this[SAW_NULL_BLOCK] = true\n this[EMIT]('nullBlock')\n }\n } else {\n this[SAW_NULL_BLOCK] = false\n if (!header.cksumValid) {\n this.warn('TAR_ENTRY_INVALID', 'checksum failure', { header })\n } else if (!header.path) {\n this.warn('TAR_ENTRY_INVALID', 'path is required', { header })\n } else {\n const type = header.type\n if (/^(Symbolic)?Link$/.test(type) && !header.linkpath) {\n this.warn('TAR_ENTRY_INVALID', 'linkpath required', {\n header,\n })\n } else if (\n !/^(Symbolic)?Link$/.test(type) &&\n !/^(Global)?ExtendedHeader$/.test(type) &&\n header.linkpath\n ) {\n this.warn('TAR_ENTRY_INVALID', 'linkpath forbidden', {\n header,\n })\n } else {\n const entry = (this[WRITEENTRY] = new ReadEntry(\n header,\n this[EX],\n this[GEX],\n ))\n\n // we do this for meta & ignored entries as well, because they\n // are still valid tar, or else we wouldn't know to ignore them\n if (!this[SAW_VALID_ENTRY]) {\n if (entry.remain) {\n // this might be the one!\n const onend = () => {\n if (!entry.invalid) {\n this[SAW_VALID_ENTRY] = true\n }\n }\n entry.on('end', onend)\n } else {\n this[SAW_VALID_ENTRY] = true\n }\n }\n\n if (entry.meta) {\n if (entry.size > this.maxMetaEntrySize) {\n entry.ignore = true\n this[EMIT]('ignoredEntry', entry)\n this[STATE] = 'ignore'\n entry.resume()\n } else if (entry.size > 0) {\n this[META] = ''\n entry.on('data', c => (this[META] += c))\n this[STATE] = 'meta'\n }\n } else {\n this[EX] = undefined\n entry.ignore =\n entry.ignore || !this.filter(entry.path, entry)\n\n if (entry.ignore) {\n // probably valid, just not something we care about\n this[EMIT]('ignoredEntry', entry)\n this[STATE] = entry.remain ? 'ignore' : 'header'\n entry.resume()\n } else {\n if (entry.remain) {\n this[STATE] = 'body'\n } else {\n this[STATE] = 'header'\n entry.end()\n }\n\n if (!this[READENTRY]) {\n this[QUEUE].push(entry)\n this[NEXTENTRY]()\n } else {\n this[QUEUE].push(entry)\n }\n }\n }\n }\n }\n }\n }\n\n [CLOSESTREAM]() {\n queueMicrotask(() => this.emit('close'))\n }\n\n [PROCESSENTRY](entry?: ReadEntry | [string | symbol, any, any]) {\n let go = true\n\n if (!entry) {\n this[READENTRY] = undefined\n go = false\n } else if (Array.isArray(entry)) {\n const [ev, ...args]: [string | symbol, any, any] = entry\n this.emit(ev, ...args)\n } else {\n this[READENTRY] = entry\n this.emit('entry', entry)\n if (!entry.emittedEnd) {\n entry.on('end', () => this[NEXTENTRY]())\n go = false\n }\n }\n\n return go\n }\n\n [NEXTENTRY]() {\n do {} while (this[PROCESSENTRY](this[QUEUE].shift()))\n\n if (!this[QUEUE].length) {\n // At this point, there's nothing in the queue, but we may have an\n // entry which is being consumed (readEntry).\n // If we don't, then we definitely can handle more data.\n // If we do, and either it's flowing, or it has never had any data\n // written to it, then it needs more.\n // The only other possibility is that it has returned false from a\n // write() call, so we wait for the next drain to continue.\n const re = this[READENTRY]\n const drainNow = !re || re.flowing || re.size === re.remain\n if (drainNow) {\n if (!this[WRITING]) {\n this.emit('drain')\n }\n } else {\n re.once('drain', () => this.emit('drain'))\n }\n }\n }\n\n [CONSUMEBODY](chunk: Buffer, position: number) {\n // write up to but no more than writeEntry.blockRemain\n const entry = this[WRITEENTRY]\n /* c8 ignore start */\n if (!entry) {\n throw new Error('attempt to consume body without entry??')\n }\n const br = entry.blockRemain ?? 0\n /* c8 ignore stop */\n const c =\n br >= chunk.length && position === 0\n ? chunk\n : chunk.subarray(position, position + br)\n\n entry.write(c)\n\n if (!entry.blockRemain) {\n this[STATE] = 'header'\n this[WRITEENTRY] = undefined\n entry.end()\n }\n\n return c.length\n }\n\n [CONSUMEMETA](chunk: Buffer, position: number) {\n const entry = this[WRITEENTRY]\n const ret = this[CONSUMEBODY](chunk, position)\n\n // if we finished, then the entry is reset\n if (!this[WRITEENTRY] && entry) {\n this[EMITMETA](entry)\n }\n\n return ret\n }\n\n [EMIT](ev: string | symbol, data?: any, extra?: any) {\n if (!this[QUEUE].length && !this[READENTRY]) {\n this.emit(ev, data, extra)\n } else {\n this[QUEUE].push([ev, data, extra])\n }\n }\n\n [EMITMETA](entry: ReadEntry) {\n this[EMIT]('meta', this[META])\n switch (entry.type) {\n case 'ExtendedHeader':\n case 'OldExtendedHeader':\n this[EX] = Pax.parse(this[META], this[EX], false)\n break\n\n case 'GlobalExtendedHeader':\n this[GEX] = Pax.parse(this[META], this[GEX], true)\n break\n\n case 'NextFileHasLongPath':\n case 'OldGnuLongPath': {\n const ex = this[EX] ?? Object.create(null)\n this[EX] = ex\n ex.path = this[META].replace(/\\0.*/, '')\n break\n }\n\n case 'NextFileHasLongLinkpath': {\n const ex = this[EX] || Object.create(null)\n this[EX] = ex\n ex.linkpath = this[META].replace(/\\0.*/, '')\n break\n }\n\n /* c8 ignore start */\n default:\n throw new Error('unknown meta: ' + entry.type)\n /* c8 ignore stop */\n }\n }\n\n abort(error: Error) {\n this[ABORTED] = true\n this.emit('abort', error)\n // always throws, even in non-strict mode\n this.warn('TAR_ABORT', error, { recoverable: false })\n }\n\n write(chunk: Buffer) {\n if (this[ABORTED]) {\n return\n }\n\n // first write, might be gzipped\n const needSniff =\n this[UNZIP] === undefined ||\n (this.brotli === undefined && this[UNZIP] === false)\n if (needSniff && chunk) {\n if (this[BUFFER]) {\n chunk = Buffer.concat([this[BUFFER], chunk])\n this[BUFFER] = undefined\n }\n if (chunk.length < gzipHeader.length) {\n this[BUFFER] = chunk\n return true\n }\n\n // look for gzip header\n for (\n let i = 0;\n this[UNZIP] === undefined && i < gzipHeader.length;\n i++\n ) {\n if (chunk[i] !== gzipHeader[i]) {\n this[UNZIP] = false\n }\n }\n\n const maybeBrotli = this.brotli === undefined\n if (this[UNZIP] === false && maybeBrotli) {\n // read the first header to see if it's a valid tar file. If so,\n // we can safely assume that it's not actually brotli, despite the\n // .tbr or .tar.br file extension.\n // if we ended before getting a full chunk, yes, def brotli\n if (chunk.length < 512) {\n if (this[ENDED]) {\n this.brotli = true\n } else {\n this[BUFFER] = chunk\n return true\n }\n } else {\n // if it's tar, it's pretty reliably not brotli, chances of\n // that happening are astronomical.\n try {\n new Header(chunk.subarray(0, 512))\n this.brotli = false\n } catch (_) {\n this.brotli = true\n }\n }\n }\n\n if (\n this[UNZIP] === undefined ||\n (this[UNZIP] === false && this.brotli)\n ) {\n const ended = this[ENDED]\n this[ENDED] = false\n this[UNZIP] =\n this[UNZIP] === undefined\n ? new Unzip({})\n : new BrotliDecompress({})\n this[UNZIP].on('data', chunk => this[CONSUMECHUNK](chunk))\n this[UNZIP].on('error', er => this.abort(er as Error))\n this[UNZIP].on('end', () => {\n this[ENDED] = true\n this[CONSUMECHUNK]()\n })\n this[WRITING] = true\n const ret = this[UNZIP][ended ? 'end' : 'write'](chunk)\n this[WRITING] = false\n return ret\n }\n }\n\n this[WRITING] = true\n if (this[UNZIP]) {\n this[UNZIP].write(chunk)\n } else {\n this[CONSUMECHUNK](chunk)\n }\n this[WRITING] = false\n\n // return false if there's a queue, or if the current entry isn't flowing\n const ret = this[QUEUE].length\n ? false\n : this[READENTRY]\n ? this[READENTRY].flowing\n : true\n\n // if we have no queue, then that means a clogged READENTRY\n if (!ret && !this[QUEUE].length) {\n this[READENTRY]?.once('drain', () => this.emit('drain'))\n }\n\n return ret\n }\n\n [BUFFERCONCAT](c: Buffer) {\n if (c && !this[ABORTED]) {\n this[BUFFER] = this[BUFFER]\n ? Buffer.concat([this[BUFFER], c])\n : c\n }\n }\n\n [MAYBEEND]() {\n if (\n this[ENDED] &&\n !this[EMITTEDEND] &&\n !this[ABORTED] &&\n !this[CONSUMING]\n ) {\n this[EMITTEDEND] = true\n const entry = this[WRITEENTRY]\n if (entry && entry.blockRemain) {\n // truncated, likely a damaged file\n const have = this[BUFFER] ? this[BUFFER].length : 0\n this.warn(\n 'TAR_BAD_ARCHIVE',\n `Truncated input (needed ${entry.blockRemain} more bytes, only ${have} available)`,\n { entry },\n )\n if (this[BUFFER]) {\n entry.write(this[BUFFER])\n }\n entry.end()\n }\n this[EMIT](DONE)\n }\n }\n\n [CONSUMECHUNK](chunk?: Buffer) {\n if (this[CONSUMING] && chunk) {\n this[BUFFERCONCAT](chunk)\n } else if (!chunk && !this[BUFFER]) {\n this[MAYBEEND]()\n } else if (chunk) {\n this[CONSUMING] = true\n if (this[BUFFER]) {\n this[BUFFERCONCAT](chunk)\n const c = this[BUFFER]\n this[BUFFER] = undefined\n this[CONSUMECHUNKSUB](c)\n } else {\n this[CONSUMECHUNKSUB](chunk)\n }\n\n while (\n this[BUFFER] &&\n (this[BUFFER] as Buffer)?.length >= 512 &&\n !this[ABORTED] &&\n !this[SAW_EOF]\n ) {\n const c = this[BUFFER]\n this[BUFFER] = undefined\n this[CONSUMECHUNKSUB](c)\n }\n this[CONSUMING] = false\n }\n\n if (!this[BUFFER] || this[ENDED]) {\n this[MAYBEEND]()\n }\n }\n\n [CONSUMECHUNKSUB](chunk: Buffer) {\n // we know that we are in CONSUMING mode, so anything written goes into\n // the buffer. Advance the position and put any remainder in the buffer.\n let position = 0\n const length = chunk.length\n while (\n position + 512 <= length &&\n !this[ABORTED] &&\n !this[SAW_EOF]\n ) {\n switch (this[STATE]) {\n case 'begin':\n case 'header':\n this[CONSUMEHEADER](chunk, position)\n position += 512\n break\n\n case 'ignore':\n case 'body':\n position += this[CONSUMEBODY](chunk, position)\n break\n\n case 'meta':\n position += this[CONSUMEMETA](chunk, position)\n break\n\n /* c8 ignore start */\n default:\n throw new Error('invalid state: ' + this[STATE])\n /* c8 ignore stop */\n }\n }\n\n if (position < length) {\n if (this[BUFFER]) {\n this[BUFFER] = Buffer.concat([\n chunk.subarray(position),\n this[BUFFER],\n ])\n } else {\n this[BUFFER] = chunk.subarray(position)\n }\n }\n }\n\n end(chunk?: Buffer) {\n if (!this[ABORTED]) {\n if (this[UNZIP]) {\n /* c8 ignore start */\n if (chunk) this[UNZIP].write(chunk)\n /* c8 ignore stop */\n this[UNZIP].end()\n } else {\n this[ENDED] = true\n if (this.brotli === undefined)\n chunk = chunk || Buffer.alloc(0)\n if (chunk) this.write(chunk)\n this[MAYBEEND]()\n }\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type Reservation = {
|
|
2
|
+
paths: string[];
|
|
3
|
+
dirs: Set<string>;
|
|
4
|
+
};
|
|
5
|
+
export type Handler = (clear: () => void) => void;
|
|
6
|
+
export declare class PathReservations {
|
|
7
|
+
#private;
|
|
8
|
+
reserve(paths: string[], fn: Handler): boolean;
|
|
9
|
+
check(fn: Handler): boolean;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=path-reservations.d.ts.map
|