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