modern-tar 0.3.4 → 0.4.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 +4 -2
- package/dist/fs/index.d.ts +15 -16
- package/dist/fs/index.js +340 -268
- package/dist/types-D-xPQp4Z.d.ts +108 -0
- package/dist/unpacker-C9aO0rJR.js +695 -0
- package/dist/web/index.d.ts +284 -2
- package/dist/web/index.js +186 -2
- package/package.json +7 -16
- package/dist/index-1Ec89lu7.d.ts +0 -404
- package/dist/web-BceRXirJ.js +0 -678
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ Zero-dependency, cross-platform, streaming tar archive library for every JavaScr
|
|
|
10
10
|
- 📝 **TypeScript First** - Full type safety with detailed TypeDoc documentation.
|
|
11
11
|
- ⚡ **Zero Dependencies** - No external dependencies, minimal bundle size.
|
|
12
12
|
- 🌐 **Cross-Platform** - Works in browsers, Node.js, Cloudflare Workers, and other JavaScript runtimes.
|
|
13
|
-
- 📁 **Node.js Integration** - Additional high-level APIs for directory packing and extraction
|
|
13
|
+
- 📁 **Node.js Integration** - Additional high-level APIs for directory packing and extraction.
|
|
14
14
|
|
|
15
15
|
## Installation
|
|
16
16
|
|
|
@@ -186,7 +186,9 @@ const extractStream = unpackTar('./output', {
|
|
|
186
186
|
// Filesystem-specific options
|
|
187
187
|
fmode: 0o644, // Override file permissions
|
|
188
188
|
dmode: 0o755, // Override directory permissions
|
|
189
|
-
maxDepth: 50 // Limit extraction depth for security (default: 1024)
|
|
189
|
+
maxDepth: 50, // Limit extraction depth for security (default: 1024)
|
|
190
|
+
concurrency: 8, // Limit concurrent filesystem operations (default: CPU cores)
|
|
191
|
+
streamTimeout: 10000 // Timeout after 10 seconds of inactivity (default: 5000ms)
|
|
190
192
|
});
|
|
191
193
|
|
|
192
194
|
await pipeline(sourceStream, extractStream);
|
package/dist/fs/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TarEntryData, TarHeader, UnpackOptions } from "../
|
|
1
|
+
import { TarEntryData, TarHeader, UnpackOptions } from "../types-D-xPQp4Z.js";
|
|
2
2
|
import { Stats } from "node:fs";
|
|
3
3
|
import { Readable, Writable } from "node:stream";
|
|
4
4
|
|
|
@@ -17,6 +17,8 @@ interface PackOptionsFS {
|
|
|
17
17
|
filter?: (path: string, stat: Stats) => boolean;
|
|
18
18
|
/** Transform function to modify tar headers before packing */
|
|
19
19
|
map?: (header: TarHeader) => TarHeader;
|
|
20
|
+
/** Base directory for symlink security validation, when `dereference` is set to true. */
|
|
21
|
+
baseDir?: string;
|
|
20
22
|
}
|
|
21
23
|
/**
|
|
22
24
|
* Filesystem-specific configuration options for extracting tar archives to the filesystem.
|
|
@@ -29,11 +31,6 @@ interface UnpackOptionsFS extends UnpackOptions {
|
|
|
29
31
|
dmode?: number;
|
|
30
32
|
/** Default mode for created files (e.g., 0o644). If not specified, uses mode from tar header or system default */
|
|
31
33
|
fmode?: number;
|
|
32
|
-
/**
|
|
33
|
-
* Prevent symlinks from pointing outside the extraction directory.
|
|
34
|
-
* @default true
|
|
35
|
-
*/
|
|
36
|
-
validateSymlinks?: boolean;
|
|
37
34
|
/**
|
|
38
35
|
* The maximum depth of paths to extract. Prevents Denial of Service (DoS) attacks
|
|
39
36
|
* from malicious archives with deeply nested directories.
|
|
@@ -42,6 +39,11 @@ interface UnpackOptionsFS extends UnpackOptions {
|
|
|
42
39
|
* @default 1024
|
|
43
40
|
*/
|
|
44
41
|
maxDepth?: number;
|
|
42
|
+
/**
|
|
43
|
+
* Maximum number of concurrent filesystem operations during extraction.
|
|
44
|
+
* @default os.cpus().length || 8
|
|
45
|
+
*/
|
|
46
|
+
concurrency?: number;
|
|
45
47
|
}
|
|
46
48
|
/** Describes a file on the local filesystem to be added to the archive. */
|
|
47
49
|
interface FileSource {
|
|
@@ -72,12 +74,13 @@ interface ContentSource {
|
|
|
72
74
|
/** A union of all possible source types for creating a tar archive. */
|
|
73
75
|
type TarSource = FileSource | DirectorySource | ContentSource;
|
|
74
76
|
//#endregion
|
|
75
|
-
//#region src/fs/
|
|
77
|
+
//#region src/fs/pack.d.ts
|
|
76
78
|
/**
|
|
77
79
|
* Packs multiple sources into a tar archive as a Node.js Readable stream from an
|
|
78
80
|
* array of sources (files, directories, or raw content).
|
|
79
81
|
*
|
|
80
82
|
* @param sources - An array of {@link TarSource} objects describing what to include.
|
|
83
|
+
* @param options - Optional packing configuration using {@link PackOptionsFS}.
|
|
81
84
|
* @returns A Node.js [`Readable`](https://nodejs.org/api/stream.html#class-streamreadable)
|
|
82
85
|
* stream that outputs the tar archive bytes.
|
|
83
86
|
*
|
|
@@ -95,17 +98,13 @@ type TarSource = FileSource | DirectorySource | ContentSource;
|
|
|
95
98
|
* await pipeline(archiveStream, createWriteStream('project.tar'));
|
|
96
99
|
* ```
|
|
97
100
|
*/
|
|
98
|
-
declare function packTarSources(sources: TarSource[]): Readable;
|
|
99
|
-
//#endregion
|
|
100
|
-
//#region src/fs/pack.d.ts
|
|
101
|
+
declare function packTarSources(sources: TarSource[], options?: PackOptionsFS): Readable;
|
|
101
102
|
/**
|
|
102
|
-
* Pack a directory into a Node.js
|
|
103
|
-
*
|
|
104
|
-
* Recursively walks the directory structure and creates tar entries for files, directories,
|
|
105
|
-
* symlinks, and hardlinks.
|
|
103
|
+
* Pack a directory into a Node.js `Readable` stream. This is a convenience
|
|
104
|
+
* wrapper around `packTarSources` that reads the contents of the specified directory.
|
|
106
105
|
*
|
|
107
|
-
* @param directoryPath - Path to directory to pack
|
|
108
|
-
* @param options - Optional packing configuration
|
|
106
|
+
* @param directoryPath - Path to directory to pack.
|
|
107
|
+
* @param options - Optional packing configuration using {@link PackOptionsFS}.
|
|
109
108
|
* @returns Node.js [`Readable`](https://nodejs.org/api/stream.html#class-streamreadable) stream of tar archive bytes
|
|
110
109
|
*
|
|
111
110
|
* @example
|