@ac-kit/node 0.2.0 → 0.3.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/CHANGELOG.md +39 -0
- package/README.md +5 -2
- package/dist/error/process-exit-error.d.ts +16 -3
- package/dist/error/process-exit-error.d.ts.map +1 -1
- package/dist/error/process-exit-error.js +51 -7
- package/dist/error/process-exit-error.js.map +1 -1
- package/dist/fs/path-escape-error.d.ts +20 -0
- package/dist/fs/path-escape-error.d.ts.map +1 -0
- package/dist/fs/path-escape-error.js +23 -0
- package/dist/fs/path-escape-error.js.map +1 -0
- package/dist/fs/path-within.d.ts +121 -0
- package/dist/fs/path-within.d.ts.map +1 -0
- package/dist/fs/path-within.js +196 -0
- package/dist/fs/path-within.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/net/dgram-socket.d.ts +2 -1
- package/dist/net/dgram-socket.d.ts.map +1 -1
- package/dist/net/dgram-socket.js +3 -3
- package/dist/net/dgram-socket.js.map +1 -1
- package/dist/net/inet-address.d.ts +20 -0
- package/dist/net/inet-address.d.ts.map +1 -0
- package/dist/net/inet-address.js +42 -0
- package/dist/net/inet-address.js.map +1 -0
- package/dist/net/inet-endpoint.d.ts +7 -0
- package/dist/net/inet-endpoint.d.ts.map +1 -0
- package/dist/net/inet-endpoint.js +2 -0
- package/dist/net/inet-endpoint.js.map +1 -0
- package/dist/net/inet-socket.d.ts +2 -1
- package/dist/net/inet-socket.d.ts.map +1 -1
- package/dist/net/inet-socket.js +7 -11
- package/dist/net/inet-socket.js.map +1 -1
- package/dist/net/tcp-server.d.ts +1 -1
- package/dist/net/tcp-server.d.ts.map +1 -1
- package/dist/net/tcp-server.js +5 -4
- package/dist/net/tcp-server.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
# @ac-kit/node
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- a5c4d66: - New `InetAddress`, `InetEndpoint` and `toInetAddress`, moved here from
|
|
8
|
+
`@ac-kit/core` — an `InetAddress` answers what the OS told us, a family and an
|
|
9
|
+
opaque address string, rather than being an address you can compute with, so
|
|
10
|
+
it belongs beside the Node APIs that report it rather than in
|
|
11
|
+
`@ac-kit/net-address`. `composeInetAddress` is renamed `toInetAddress`: it
|
|
12
|
+
exists solely to normalise the inconsistent `family` field Node reports, which
|
|
13
|
+
arrives as `"IPv4"`, as `4` or as `null` depending on which API answered, and
|
|
14
|
+
"compose" named none of that. Its behaviour, including the `UnsupportedError`
|
|
15
|
+
it throws on any other family, is unchanged.
|
|
16
|
+
- New `isPathWithin` / `assertPathWithin` and their symlink-resolving `…Async`
|
|
17
|
+
counterparts, plus the `PathEscapeError` they throw. Proving that a resolved
|
|
18
|
+
path stayed inside a root directory is the check that stands between a
|
|
19
|
+
user-supplied name and `../../../etc/passwd`, and it is routinely written as
|
|
20
|
+
`resolved.startsWith(root)` — which accepts `/var/data-evil` for a root of
|
|
21
|
+
`/var/data`. Comparing resolved path segments makes the separator implicit
|
|
22
|
+
instead of something the caller has to remember to append, and settles the
|
|
23
|
+
trailing-separator, `.`/`..` and relative-input cases on the way. The
|
|
24
|
+
asynchronous variants resolve both sides through `realpath`, falling back to
|
|
25
|
+
the longest existing prefix so a path can be checked before it is created, and
|
|
26
|
+
rethrow any error other than a missing path — a check that could not look must
|
|
27
|
+
not answer "within". They narrow the check-to-use window rather than closing
|
|
28
|
+
it, which the documentation says plainly; the asserting forms return the
|
|
29
|
+
resolved path so a caller uses the value that was checked instead of resolving
|
|
30
|
+
a second time. Case folding defaults to the platform's convention —
|
|
31
|
+
insensitive on Windows, sensitive elsewhere — and is an option, because Node
|
|
32
|
+
cannot report what the volume actually does and a case-insensitive mount under
|
|
33
|
+
a case-sensitive platform would otherwise read as a different root.
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- Updated dependencies [a5c4d66]
|
|
38
|
+
- Updated dependencies [a5c4d66]
|
|
39
|
+
- @ac-kit/core@0.3.0
|
|
40
|
+
- @ac-kit/async@0.1.2
|
|
41
|
+
|
|
3
42
|
## 0.2.0
|
|
4
43
|
|
|
5
44
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -22,12 +22,15 @@ await writeFileAtomic("config.json", JSON.stringify(config));
|
|
|
22
22
|
|
|
23
23
|
## What it covers
|
|
24
24
|
|
|
25
|
-
- **Sockets** — promise-based TCP, TLS, IPC and UDP classes
|
|
25
|
+
- **Sockets** — promise-based TCP, TLS, IPC and UDP classes, addressed with
|
|
26
|
+
`InetAddress` / `InetEndpoint` and `toInetAddress`, which normalizes the
|
|
27
|
+
inconsistent `family` field Node reports.
|
|
26
28
|
- **Servers** — promise-based TCP, TLS and IPC listeners, dispatching typed
|
|
27
29
|
connection events.
|
|
28
30
|
- **Filesystem** — `walkPaths`, `writeFileAtomic`, `existsAsync`,
|
|
29
31
|
`isDirectoryAsync`, `fileContentEqual`, `compressFile`, `createTempDir`,
|
|
30
|
-
`escapePath
|
|
32
|
+
`escapePath`, and `isPathWithin` / `assertPathWithinAsync` for proving a path
|
|
33
|
+
stays inside a root directory, symbolic links included.
|
|
31
34
|
- **Processes** — `execAsync`, forking, and typed `NodeError` /
|
|
32
35
|
`NodeSystemError` / `NodeExecError` / `ProcessExitError`.
|
|
33
36
|
- **Modules** — `importModule`, `optionalImport`, `resolveModule`.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { INodeExecError } from "./node-exec-error.js";
|
|
1
|
+
import type { INodeExecError } from "./node-exec-error.js";
|
|
2
2
|
/**
|
|
3
3
|
* Error thrown when a shell command exits with a non-zero code or is terminated
|
|
4
4
|
* by a signal.
|
|
@@ -9,14 +9,27 @@ export declare class ProcessExitError extends Error {
|
|
|
9
9
|
readonly killed: boolean;
|
|
10
10
|
constructor(code: string | number | null, signal: NodeJS.Signals | null, killed: boolean, options?: ErrorOptions);
|
|
11
11
|
}
|
|
12
|
+
export type ProcessExitWithOutputErrorOptions = ErrorOptions & {
|
|
13
|
+
/**
|
|
14
|
+
* How much of the failing stream the message keeps, counted in characters for
|
|
15
|
+
* string output and in bytes for `Buffer` output. Default `32768`.
|
|
16
|
+
*/
|
|
17
|
+
readonly maxOutputLength?: number | null;
|
|
18
|
+
};
|
|
12
19
|
/**
|
|
13
20
|
* Error thrown when a shell command exits with a non-zero code or is terminated
|
|
14
21
|
* by a signal, including its stdout and stderr output.
|
|
22
|
+
*
|
|
23
|
+
* The message appends the failing stream — `stderr` when it holds anything but
|
|
24
|
+
* whitespace, `stdout` otherwise — keeping its tail up to
|
|
25
|
+
* {@link ProcessExitWithOutputErrorOptions.maxOutputLength} and stating how much
|
|
26
|
+
* it dropped. {@link stdout} and {@link stderr} always carry the untruncated
|
|
27
|
+
* output.
|
|
15
28
|
*/
|
|
16
29
|
export declare class ProcessExitWithOutputError extends ProcessExitError {
|
|
17
30
|
readonly stdout: string | Buffer;
|
|
18
31
|
readonly stderr: string | Buffer;
|
|
19
|
-
static fromNodeExecError(error: INodeExecError): ProcessExitWithOutputError;
|
|
20
|
-
constructor(code: string | number | null, signal: NodeJS.Signals | null, killed: boolean, stdout: string | Buffer, stderr: string | Buffer, options?:
|
|
32
|
+
static fromNodeExecError(error: INodeExecError, options?: Exclude<ProcessExitWithOutputErrorOptions, "cause">): ProcessExitWithOutputError;
|
|
33
|
+
constructor(code: string | number | null, signal: NodeJS.Signals | null, killed: boolean, stdout: string | Buffer, stderr: string | Buffer, options?: ProcessExitWithOutputErrorOptions);
|
|
21
34
|
}
|
|
22
35
|
//# sourceMappingURL=process-exit-error.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-exit-error.d.ts","sourceRoot":"","sources":["../../src/error/process-exit-error.ts"],"names":[],"mappings":"
|
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
|
-
import { joinNonEmpty } from "@ac-kit/core";
|
|
1
|
+
import { isAsciiWhitespace, joinNonEmpty, nextUtf8Boundary, } from "@ac-kit/core";
|
|
2
|
+
const DEFAULT_MAX_OUTPUT_LENGTH_ = 32 * 1024;
|
|
3
|
+
function hasContent_(output) {
|
|
4
|
+
return typeof output === "string"
|
|
5
|
+
? /\S/.test(output)
|
|
6
|
+
: output.some((byte) => !isAsciiWhitespace(byte));
|
|
7
|
+
}
|
|
8
|
+
function getOutputTail_(output, maxLength) {
|
|
9
|
+
const start = Math.max(0, output.length - maxLength);
|
|
10
|
+
if (typeof output === "string") {
|
|
11
|
+
return {
|
|
12
|
+
text: output.slice(start),
|
|
13
|
+
omittedLength: start,
|
|
14
|
+
unit: "characters",
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
const byteStart = nextUtf8Boundary(output, start);
|
|
18
|
+
return {
|
|
19
|
+
text: output.toString("utf8", byteStart),
|
|
20
|
+
omittedLength: byteStart,
|
|
21
|
+
unit: "bytes",
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function getOutputMessage_(stdout, stderr, maxOutputLength) {
|
|
25
|
+
const [name, output] = hasContent_(stderr)
|
|
26
|
+
? ["stderr", stderr]
|
|
27
|
+
: ["stdout", stdout];
|
|
28
|
+
if (!hasContent_(output)) {
|
|
29
|
+
return "";
|
|
30
|
+
}
|
|
31
|
+
const { text, omittedLength, unit } = getOutputTail_(output, maxOutputLength);
|
|
32
|
+
const truncation = omittedLength > 0
|
|
33
|
+
? ` (last ${output.length - omittedLength} of ${output.length} ${unit})`
|
|
34
|
+
: "";
|
|
35
|
+
return `${name}${truncation}:\n${text}`;
|
|
36
|
+
}
|
|
2
37
|
/**
|
|
3
38
|
* Error thrown when a shell command exits with a non-zero code or is terminated
|
|
4
39
|
* by a signal.
|
|
@@ -23,16 +58,21 @@ export class ProcessExitError extends Error {
|
|
|
23
58
|
/**
|
|
24
59
|
* Error thrown when a shell command exits with a non-zero code or is terminated
|
|
25
60
|
* by a signal, including its stdout and stderr output.
|
|
61
|
+
*
|
|
62
|
+
* The message appends the failing stream — `stderr` when it holds anything but
|
|
63
|
+
* whitespace, `stdout` otherwise — keeping its tail up to
|
|
64
|
+
* {@link ProcessExitWithOutputErrorOptions.maxOutputLength} and stating how much
|
|
65
|
+
* it dropped. {@link stdout} and {@link stderr} always carry the untruncated
|
|
66
|
+
* output.
|
|
26
67
|
*/
|
|
27
68
|
export class ProcessExitWithOutputError extends ProcessExitError {
|
|
28
69
|
stdout;
|
|
29
70
|
stderr;
|
|
30
|
-
static fromNodeExecError(error) {
|
|
31
|
-
const result = new ProcessExitWithOutputError(error.code, error.signal, error.killed, error.stdout, error.stderr,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
: undefined);
|
|
71
|
+
static fromNodeExecError(error, options) {
|
|
72
|
+
const result = new ProcessExitWithOutputError(error.code, error.signal, error.killed, error.stdout, error.stderr, {
|
|
73
|
+
...options,
|
|
74
|
+
cause: error.cause,
|
|
75
|
+
});
|
|
36
76
|
Error.captureStackTrace(result, ProcessExitWithOutputError.fromNodeExecError);
|
|
37
77
|
return result;
|
|
38
78
|
}
|
|
@@ -41,6 +81,10 @@ export class ProcessExitWithOutputError extends ProcessExitError {
|
|
|
41
81
|
this.stdout = stdout;
|
|
42
82
|
this.stderr = stderr;
|
|
43
83
|
this.name = "ProcessExitWithOutputError";
|
|
84
|
+
this.message = joinNonEmpty([
|
|
85
|
+
this.message,
|
|
86
|
+
getOutputMessage_(stdout, stderr, options?.maxOutputLength ?? DEFAULT_MAX_OUTPUT_LENGTH_),
|
|
87
|
+
], "\n\n");
|
|
44
88
|
}
|
|
45
89
|
}
|
|
46
90
|
//# sourceMappingURL=process-exit-error.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-exit-error.js","sourceRoot":"","sources":["../../src/error/process-exit-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM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CAAC,iBAAiB,CACvB,KAAqB,EACrB,OAA6D;QAE7D,MAAM,MAAM,GAAG,IAAI,0BAA0B,CAC5C,KAAK,CAAC,IAAI,EACV,KAAK,CAAC,MAAM,EACZ,KAAK,CAAC,MAAM,EACZ,KAAK,CAAC,MAAM,EACZ,KAAK,CAAC,MAAM,EACZ;YACC,GAAG,OAAO;YACV,KAAK,EAAE,KAAK,CAAC,KAAK;SAClB,CACD,CAAC;QAEF,KAAK,CAAC,iBAAiB,CACtB,MAAM,EACN,0BAA0B,CAAC,iBAAiB,CAC5C,CAAC;QACF,OAAO,MAAM,CAAC;IACf,CAAC;IAED,YACC,IAA4B,EAC5B,MAA6B,EAC7B,MAAe,EACN,MAAuB,EACvB,MAAuB,EAChC,OAA2C;QAE3C,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;sBAJ5B,MAAM;sBACN,MAAM;QAKf,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAC;QACzC,IAAI,CAAC,OAAO,GAAG,YAAY,CAC1B;YACC,IAAI,CAAC,OAAO;YACZ,iBAAiB,CAChB,MAAM,EACN,MAAM,EACN,OAAO,EAAE,eAAe,IAAI,0BAA0B,CACtD;SACD,EACD,MAAM,CACN,CAAC;IACH,CAAC;CACD"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error thrown when a path resolves outside the root directory it was required
|
|
3
|
+
* to stay inside.
|
|
4
|
+
*
|
|
5
|
+
* Carries the two resolved absolute paths rather than the caller's originals,
|
|
6
|
+
* because the originals are what looked innocent — `../../../etc/passwd` says
|
|
7
|
+
* nothing about where it landed.
|
|
8
|
+
*/
|
|
9
|
+
export declare class PathEscapeError extends Error {
|
|
10
|
+
/** The resolved root the path was required to stay inside. */
|
|
11
|
+
readonly root: string;
|
|
12
|
+
/** The resolved path that fell outside it. */
|
|
13
|
+
readonly path: string;
|
|
14
|
+
constructor(
|
|
15
|
+
/** The resolved root the path was required to stay inside. */
|
|
16
|
+
root: string,
|
|
17
|
+
/** The resolved path that fell outside it. */
|
|
18
|
+
path: string, options?: ErrorOptions);
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=path-escape-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-escape-error.d.ts","sourceRoot":"","sources":["../../src/fs/path-escape-error.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IAExC,8DAA8D;IAC9D,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,8CAA8C;IAC9C,QAAQ,CAAC,IAAI,EAAE,MAAM;IAJtB;IACC,8DAA8D;IACrD,IAAI,EAAE,MAAM;IACrB,8CAA8C;IACrC,IAAI,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE,YAAY,EAKtB;CACD"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error thrown when a path resolves outside the root directory it was required
|
|
3
|
+
* to stay inside.
|
|
4
|
+
*
|
|
5
|
+
* Carries the two resolved absolute paths rather than the caller's originals,
|
|
6
|
+
* because the originals are what looked innocent — `../../../etc/passwd` says
|
|
7
|
+
* nothing about where it landed.
|
|
8
|
+
*/
|
|
9
|
+
export class PathEscapeError extends Error {
|
|
10
|
+
root;
|
|
11
|
+
path;
|
|
12
|
+
constructor(
|
|
13
|
+
/** The resolved root the path was required to stay inside. */
|
|
14
|
+
root,
|
|
15
|
+
/** The resolved path that fell outside it. */
|
|
16
|
+
path, options) {
|
|
17
|
+
super(`Path "${path}" is outside "${root}"`, options);
|
|
18
|
+
this.root = root;
|
|
19
|
+
this.path = path;
|
|
20
|
+
this.name = "PathEscapeError";
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=path-escape-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-escape-error.js","sourceRoot":"","sources":["../../src/fs/path-escape-error.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAG/B,IAAI;IAEJ,IAAI;IAJd;IACC,8DAA8D;IACrD,IAAY;IACrB,8CAA8C;IACrC,IAAY,EACrB,OAAsB;QAEtB,KAAK,CAAC,SAAS,IAAI,iBAAiB,IAAI,GAAG,EAAE,OAAO,CAAC,CAAC;oBAL7C,IAAI;oBAEJ,IAAI;QAKb,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAC/B,CAAC;CACD"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
export type PathWithinOptions = {
|
|
2
|
+
/**
|
|
3
|
+
* Directory a relative `root` or `path` resolves against. Default
|
|
4
|
+
* `process.cwd()`.
|
|
5
|
+
*/
|
|
6
|
+
readonly from?: string | null;
|
|
7
|
+
/**
|
|
8
|
+
* Whether the path resolving to the root itself counts as within. Default
|
|
9
|
+
* `true`.
|
|
10
|
+
*
|
|
11
|
+
* Set it to `false` where the root is a container the path must be an entry
|
|
12
|
+
* of — a destination directory that must not be overwritten by the write it
|
|
13
|
+
* is receiving.
|
|
14
|
+
*/
|
|
15
|
+
readonly allowRoot?: boolean | null;
|
|
16
|
+
/**
|
|
17
|
+
* Compares segments case-insensitively. Defaults to `true` on Windows and
|
|
18
|
+
* `false` everywhere else.
|
|
19
|
+
*
|
|
20
|
+
* That default follows the platform's _convention_, not the filesystem's
|
|
21
|
+
* actual behaviour, which Node cannot report: a macOS volume is usually
|
|
22
|
+
* case-insensitive, a case-sensitive one can be mounted anywhere, and NTFS
|
|
23
|
+
* can be made case-sensitive per directory. Where the answer is a security
|
|
24
|
+
* decision and the volume may be case-insensitive, pass `true` explicitly —
|
|
25
|
+
* comparing case-sensitively there lets `/Root/../etc` reached as
|
|
26
|
+
* `/ROOT/../etc` read as a different root.
|
|
27
|
+
*/
|
|
28
|
+
readonly caseInsensitive?: boolean | null;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Whether `path` stays inside `root`, comparing the two as resolved sequences
|
|
32
|
+
* of path segments.
|
|
33
|
+
*
|
|
34
|
+
* Both are resolved first, so `..`, `.`, a trailing separator and a relative
|
|
35
|
+
* input all behave as the filesystem would read them. Containment is then
|
|
36
|
+
* decided segment by segment, which is why `/var/data-evil` is not inside
|
|
37
|
+
* `/var/data` — a `startsWith` test on the joined strings says it is. The path
|
|
38
|
+
* being the root itself counts as within unless
|
|
39
|
+
* {@link PathWithinOptions.allowRoot} says otherwise.
|
|
40
|
+
*
|
|
41
|
+
* **This answers a question about strings, not about the filesystem.** A
|
|
42
|
+
* symbolic link inside the root pointing out of it resolves within textually
|
|
43
|
+
* and reads outside it in practice; {@link isPathWithinAsync} is the variant
|
|
44
|
+
* that follows links.
|
|
45
|
+
*
|
|
46
|
+
* Time and memory are linear in the length of the two paths.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* isPathWithin("/var/data", "/var/data/a/b"); // true
|
|
51
|
+
* isPathWithin("/var/data", "/var/data-evil/x"); // false
|
|
52
|
+
* isPathWithin("/var/data", "/var/data/a/../../etc/passwd"); // false
|
|
53
|
+
* isPathWithin("/var/data", "/var/data", { allowRoot: false }); // false
|
|
54
|
+
* ```;
|
|
55
|
+
*
|
|
56
|
+
* @param root The directory the path must stay inside.
|
|
57
|
+
* @param path The path to check.
|
|
58
|
+
* @param options Resolution base, root-equality and case-folding policy.
|
|
59
|
+
* @returns True if the resolved path is inside the resolved root.
|
|
60
|
+
*/
|
|
61
|
+
export declare function isPathWithin(root: string, path: string, options?: PathWithinOptions): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Whether `path` stays inside `root` once both are resolved through symbolic
|
|
64
|
+
* links.
|
|
65
|
+
*
|
|
66
|
+
* Resolves each with `realpath`, falling back to the longest existing prefix
|
|
67
|
+
* when the path does not exist yet, then applies the segment comparison
|
|
68
|
+
* {@link isPathWithin} describes. A link inside the root pointing out of it is
|
|
69
|
+
* therefore reported as outside.
|
|
70
|
+
*
|
|
71
|
+
* **Resolving is not opening, and the gap between them is exploitable.** A path
|
|
72
|
+
* that answers `true` here can be replaced by a symbolic link before the caller
|
|
73
|
+
* opens it — the check and the use are two syscalls, and nothing holds the
|
|
74
|
+
* filesystem still between them. Where that matters, open the file first and
|
|
75
|
+
* validate the handle (`fd`-relative operations, `O_NOFOLLOW`), or make the
|
|
76
|
+
* root a directory an attacker cannot write to. This function narrows the
|
|
77
|
+
* window; it does not close it.
|
|
78
|
+
*
|
|
79
|
+
* Costs one `realpath` per path, plus one per missing ancestor when the path
|
|
80
|
+
* does not exist.
|
|
81
|
+
*
|
|
82
|
+
* @param root The directory the path must stay inside.
|
|
83
|
+
* @param path The path to check.
|
|
84
|
+
* @param options Resolution base, root-equality and case-folding policy.
|
|
85
|
+
* @returns A promise for whether the real path is inside the real root.
|
|
86
|
+
* @throws Error Any filesystem error other than a missing path — a check that
|
|
87
|
+
* could not look never answers "within".
|
|
88
|
+
*/
|
|
89
|
+
export declare function isPathWithinAsync(root: string, path: string, options?: PathWithinOptions): Promise<boolean>;
|
|
90
|
+
/**
|
|
91
|
+
* Require that `path` stays inside `root`, and hand back the resolved path.
|
|
92
|
+
*
|
|
93
|
+
* Returning the resolved path is the point: a caller that resolves again to use
|
|
94
|
+
* it opens a second window in which the answer could change, and a caller that
|
|
95
|
+
* uses its original relative input has not used the thing that was checked.
|
|
96
|
+
*
|
|
97
|
+
* Same textual semantics as {@link isPathWithin}, symbolic links included.
|
|
98
|
+
*
|
|
99
|
+
* @param root The directory the path must stay inside.
|
|
100
|
+
* @param path The path to check.
|
|
101
|
+
* @param options Resolution base, root-equality and case-folding policy.
|
|
102
|
+
* @returns The resolved absolute path.
|
|
103
|
+
* @throws PathEscapeError If the resolved path is outside the resolved root.
|
|
104
|
+
*/
|
|
105
|
+
export declare function assertPathWithin(root: string, path: string, options?: PathWithinOptions): string;
|
|
106
|
+
/**
|
|
107
|
+
* Require that `path` stays inside `root` once both are resolved through
|
|
108
|
+
* symbolic links, and hand back the real path.
|
|
109
|
+
*
|
|
110
|
+
* Same semantics and the same TOCTOU caveat as {@link isPathWithinAsync}; use
|
|
111
|
+
* the returned path rather than the argument, so the value opened is the value
|
|
112
|
+
* that was checked.
|
|
113
|
+
*
|
|
114
|
+
* @param root The directory the path must stay inside.
|
|
115
|
+
* @param path The path to check.
|
|
116
|
+
* @param options Resolution base, root-equality and case-folding policy.
|
|
117
|
+
* @returns A promise for the real absolute path.
|
|
118
|
+
* @throws PathEscapeError If the real path is outside the real root.
|
|
119
|
+
*/
|
|
120
|
+
export declare function assertPathWithinAsync(root: string, path: string, options?: PathWithinOptions): Promise<string>;
|
|
121
|
+
//# sourceMappingURL=path-within.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-within.d.ts","sourceRoot":"","sources":["../../src/fs/path-within.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,iBAAiB,GAAG;IAC/B;;;OAGG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAE9B;;;;;;;OAOG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAEpC;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;CAC1C,CAAC;AA6HF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,YAAY,CAC3B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,iBAAiB,GACzB,OAAO,CAET;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAsB,iBAAiB,CACtC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,iBAAiB,GACzB,OAAO,CAAC,OAAO,CAAC,CAElB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAC/B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,iBAAiB,GACzB,MAAM,CAQR;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,qBAAqB,CAC1C,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,iBAAiB,GACzB,OAAO,CAAC,MAAM,CAAC,CAQjB"}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { realpath } from "node:fs/promises";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import { basename, dirname, join, parse, resolve, sep } from "node:path";
|
|
4
|
+
import { PathEscapeError } from "./path-escape-error.js";
|
|
5
|
+
/** Absolute path to `[filesystemRoot, ...segments]`, with no empty segment. */
|
|
6
|
+
function toSegments_(absolutePath) {
|
|
7
|
+
const { root } = parse(absolutePath);
|
|
8
|
+
const rest = absolutePath.slice(root.length);
|
|
9
|
+
return rest.length === 0 ? [root] : [root, ...rest.split(sep)];
|
|
10
|
+
}
|
|
11
|
+
function isSegmentEqual_(left, right, caseInsensitive) {
|
|
12
|
+
return caseInsensitive
|
|
13
|
+
? // Not `toLocaleLowerCase`: a Turkish locale would fold the dotless i and
|
|
14
|
+
// make containment depend on the machine's language.
|
|
15
|
+
left.toLowerCase() === right.toLowerCase()
|
|
16
|
+
: left === right;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Segment-wise containment.
|
|
20
|
+
*
|
|
21
|
+
* A prefix test on the joined strings is the classic bug: `/var/data-evil`
|
|
22
|
+
* starts with `/var/data`. Comparing segments makes the separator implicit
|
|
23
|
+
* instead of something the caller has to remember to append.
|
|
24
|
+
*/
|
|
25
|
+
function isWithin_(resolved) {
|
|
26
|
+
const rootSegments = toSegments_(resolved.root);
|
|
27
|
+
const pathSegments = toSegments_(resolved.path);
|
|
28
|
+
if (pathSegments.length < rootSegments.length) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
for (let index = 0; index < rootSegments.length; index++) {
|
|
32
|
+
if (!isSegmentEqual_(rootSegments[index], pathSegments[index], resolved.caseInsensitive)) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return pathSegments.length > rootSegments.length || resolved.allowRoot;
|
|
37
|
+
}
|
|
38
|
+
function resolveTextually_(root, path, options) {
|
|
39
|
+
const from = options?.from ?? ".";
|
|
40
|
+
return {
|
|
41
|
+
// `resolve` normalizes `.` and `..`, drops a trailing separator, and
|
|
42
|
+
// ignores `from` for an input that is already absolute.
|
|
43
|
+
root: resolve(from, root),
|
|
44
|
+
path: resolve(from, path),
|
|
45
|
+
allowRoot: options?.allowRoot ?? true,
|
|
46
|
+
caseInsensitive: options?.caseInsensitive ?? os.platform() === "win32",
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* `realpath` of the longest existing prefix, with the missing tail appended.
|
|
51
|
+
*
|
|
52
|
+
* A path being checked before it is created has nothing to resolve, and
|
|
53
|
+
* `realpath` reports that as `ENOENT` for the whole path rather than for the
|
|
54
|
+
* part that is missing. Anything else — a permission error, a symlink loop — is
|
|
55
|
+
* rethrown, so a check never answers "within" because it could not look.
|
|
56
|
+
*/
|
|
57
|
+
async function realpathPartial_(target) {
|
|
58
|
+
const missing = [];
|
|
59
|
+
let current = target;
|
|
60
|
+
for (;;) {
|
|
61
|
+
try {
|
|
62
|
+
const existing = await realpath(current);
|
|
63
|
+
return missing.length === 0
|
|
64
|
+
? existing
|
|
65
|
+
: join(existing, ...missing.reverse());
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
const code = error.code;
|
|
69
|
+
if (code !== "ENOENT" && code !== "ENOTDIR") {
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
const parent = dirname(current);
|
|
73
|
+
if (parent === current) {
|
|
74
|
+
return target;
|
|
75
|
+
}
|
|
76
|
+
missing.push(basename(current));
|
|
77
|
+
current = parent;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
async function resolveReally_(root, path, options) {
|
|
82
|
+
const textual = resolveTextually_(root, path, options);
|
|
83
|
+
const [realRoot, realPath] = await Promise.all([
|
|
84
|
+
realpathPartial_(textual.root),
|
|
85
|
+
realpathPartial_(textual.path),
|
|
86
|
+
]);
|
|
87
|
+
return { ...textual, root: realRoot, path: realPath };
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Whether `path` stays inside `root`, comparing the two as resolved sequences
|
|
91
|
+
* of path segments.
|
|
92
|
+
*
|
|
93
|
+
* Both are resolved first, so `..`, `.`, a trailing separator and a relative
|
|
94
|
+
* input all behave as the filesystem would read them. Containment is then
|
|
95
|
+
* decided segment by segment, which is why `/var/data-evil` is not inside
|
|
96
|
+
* `/var/data` — a `startsWith` test on the joined strings says it is. The path
|
|
97
|
+
* being the root itself counts as within unless
|
|
98
|
+
* {@link PathWithinOptions.allowRoot} says otherwise.
|
|
99
|
+
*
|
|
100
|
+
* **This answers a question about strings, not about the filesystem.** A
|
|
101
|
+
* symbolic link inside the root pointing out of it resolves within textually
|
|
102
|
+
* and reads outside it in practice; {@link isPathWithinAsync} is the variant
|
|
103
|
+
* that follows links.
|
|
104
|
+
*
|
|
105
|
+
* Time and memory are linear in the length of the two paths.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```ts
|
|
109
|
+
* isPathWithin("/var/data", "/var/data/a/b"); // true
|
|
110
|
+
* isPathWithin("/var/data", "/var/data-evil/x"); // false
|
|
111
|
+
* isPathWithin("/var/data", "/var/data/a/../../etc/passwd"); // false
|
|
112
|
+
* isPathWithin("/var/data", "/var/data", { allowRoot: false }); // false
|
|
113
|
+
* ```;
|
|
114
|
+
*
|
|
115
|
+
* @param root The directory the path must stay inside.
|
|
116
|
+
* @param path The path to check.
|
|
117
|
+
* @param options Resolution base, root-equality and case-folding policy.
|
|
118
|
+
* @returns True if the resolved path is inside the resolved root.
|
|
119
|
+
*/
|
|
120
|
+
export function isPathWithin(root, path, options) {
|
|
121
|
+
return isWithin_(resolveTextually_(root, path, options));
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Whether `path` stays inside `root` once both are resolved through symbolic
|
|
125
|
+
* links.
|
|
126
|
+
*
|
|
127
|
+
* Resolves each with `realpath`, falling back to the longest existing prefix
|
|
128
|
+
* when the path does not exist yet, then applies the segment comparison
|
|
129
|
+
* {@link isPathWithin} describes. A link inside the root pointing out of it is
|
|
130
|
+
* therefore reported as outside.
|
|
131
|
+
*
|
|
132
|
+
* **Resolving is not opening, and the gap between them is exploitable.** A path
|
|
133
|
+
* that answers `true` here can be replaced by a symbolic link before the caller
|
|
134
|
+
* opens it — the check and the use are two syscalls, and nothing holds the
|
|
135
|
+
* filesystem still between them. Where that matters, open the file first and
|
|
136
|
+
* validate the handle (`fd`-relative operations, `O_NOFOLLOW`), or make the
|
|
137
|
+
* root a directory an attacker cannot write to. This function narrows the
|
|
138
|
+
* window; it does not close it.
|
|
139
|
+
*
|
|
140
|
+
* Costs one `realpath` per path, plus one per missing ancestor when the path
|
|
141
|
+
* does not exist.
|
|
142
|
+
*
|
|
143
|
+
* @param root The directory the path must stay inside.
|
|
144
|
+
* @param path The path to check.
|
|
145
|
+
* @param options Resolution base, root-equality and case-folding policy.
|
|
146
|
+
* @returns A promise for whether the real path is inside the real root.
|
|
147
|
+
* @throws Error Any filesystem error other than a missing path — a check that
|
|
148
|
+
* could not look never answers "within".
|
|
149
|
+
*/
|
|
150
|
+
export async function isPathWithinAsync(root, path, options) {
|
|
151
|
+
return isWithin_(await resolveReally_(root, path, options));
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Require that `path` stays inside `root`, and hand back the resolved path.
|
|
155
|
+
*
|
|
156
|
+
* Returning the resolved path is the point: a caller that resolves again to use
|
|
157
|
+
* it opens a second window in which the answer could change, and a caller that
|
|
158
|
+
* uses its original relative input has not used the thing that was checked.
|
|
159
|
+
*
|
|
160
|
+
* Same textual semantics as {@link isPathWithin}, symbolic links included.
|
|
161
|
+
*
|
|
162
|
+
* @param root The directory the path must stay inside.
|
|
163
|
+
* @param path The path to check.
|
|
164
|
+
* @param options Resolution base, root-equality and case-folding policy.
|
|
165
|
+
* @returns The resolved absolute path.
|
|
166
|
+
* @throws PathEscapeError If the resolved path is outside the resolved root.
|
|
167
|
+
*/
|
|
168
|
+
export function assertPathWithin(root, path, options) {
|
|
169
|
+
const resolved = resolveTextually_(root, path, options);
|
|
170
|
+
if (!isWithin_(resolved)) {
|
|
171
|
+
throw new PathEscapeError(resolved.root, resolved.path);
|
|
172
|
+
}
|
|
173
|
+
return resolved.path;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Require that `path` stays inside `root` once both are resolved through
|
|
177
|
+
* symbolic links, and hand back the real path.
|
|
178
|
+
*
|
|
179
|
+
* Same semantics and the same TOCTOU caveat as {@link isPathWithinAsync}; use
|
|
180
|
+
* the returned path rather than the argument, so the value opened is the value
|
|
181
|
+
* that was checked.
|
|
182
|
+
*
|
|
183
|
+
* @param root The directory the path must stay inside.
|
|
184
|
+
* @param path The path to check.
|
|
185
|
+
* @param options Resolution base, root-equality and case-folding policy.
|
|
186
|
+
* @returns A promise for the real absolute path.
|
|
187
|
+
* @throws PathEscapeError If the real path is outside the real root.
|
|
188
|
+
*/
|
|
189
|
+
export async function assertPathWithinAsync(root, path, options) {
|
|
190
|
+
const resolved = await resolveReally_(root, path, options);
|
|
191
|
+
if (!isWithin_(resolved)) {
|
|
192
|
+
throw new PathEscapeError(resolved.root, resolved.path);
|
|
193
|
+
}
|
|
194
|
+
return resolved.path;
|
|
195
|
+
}
|
|
196
|
+
//# sourceMappingURL=path-within.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-within.js","sourceRoot":"","sources":["../../src/fs/path-within.ts"],"names":[],"mappings":"AAAA,OAA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IAAY,EACZ,OAA2B;IAE3B,MAAM,QAAQ,GAAG,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAExD,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,eAAe,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IACzD,CAAC;IAED,OAAO,QAAQ,CAAC,IAAI,CAAC;AACtB,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAC1C,IAAY,EACZ,IAAY,EACZ,OAA2B;IAE3B,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAE3D,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,eAAe,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IACzD,CAAC;IAED,OAAO,QAAQ,CAAC,IAAI,CAAC;AACtB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ export * from "./fs/escape-path.js";
|
|
|
10
10
|
export * from "./fs/exists-async.js";
|
|
11
11
|
export * from "./fs/file-content-equal.js";
|
|
12
12
|
export * from "./fs/is-directory-async.js";
|
|
13
|
+
export * from "./fs/path-escape-error.js";
|
|
14
|
+
export * from "./fs/path-within.js";
|
|
13
15
|
export * from "./fs/types.js";
|
|
14
16
|
export * from "./fs/walk-paths.js";
|
|
15
17
|
export * from "./fs/write-file-atomic.js";
|
|
@@ -18,6 +20,8 @@ export * from "./module/optional-import.js";
|
|
|
18
20
|
export * from "./module/resolve-module.js";
|
|
19
21
|
export * from "./net/connection-closed-error.js";
|
|
20
22
|
export * from "./net/dgram-socket.js";
|
|
23
|
+
export * from "./net/inet-address.js";
|
|
24
|
+
export * from "./net/inet-endpoint.js";
|
|
21
25
|
export * from "./net/inet-socket.js";
|
|
22
26
|
export * from "./net/ipc-server.js";
|
|
23
27
|
export * from "./net/ipc-socket.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iCAAiC,CAAC;AAChD,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kCAAkC,CAAC;AACjD,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yCAAyC,CAAC;AACxD,cAAc,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iCAAiC,CAAC;AAChD,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kCAAkC,CAAC;AACjD,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yCAAyC,CAAC;AACxD,cAAc,yBAAyB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,8 @@ export * from "./fs/escape-path.js";
|
|
|
10
10
|
export * from "./fs/exists-async.js";
|
|
11
11
|
export * from "./fs/file-content-equal.js";
|
|
12
12
|
export * from "./fs/is-directory-async.js";
|
|
13
|
+
export * from "./fs/path-escape-error.js";
|
|
14
|
+
export * from "./fs/path-within.js";
|
|
13
15
|
export * from "./fs/types.js";
|
|
14
16
|
export * from "./fs/walk-paths.js";
|
|
15
17
|
export * from "./fs/write-file-atomic.js";
|
|
@@ -18,6 +20,8 @@ export * from "./module/optional-import.js";
|
|
|
18
20
|
export * from "./module/resolve-module.js";
|
|
19
21
|
export * from "./net/connection-closed-error.js";
|
|
20
22
|
export * from "./net/dgram-socket.js";
|
|
23
|
+
export * from "./net/inet-address.js";
|
|
24
|
+
export * from "./net/inet-endpoint.js";
|
|
21
25
|
export * from "./net/inet-socket.js";
|
|
22
26
|
export * from "./net/ipc-server.js";
|
|
23
27
|
export * from "./net/ipc-socket.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iCAAiC,CAAC;AAChD,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kCAAkC,CAAC;AACjD,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc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qB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yCAAyC,CAAC;AACxD,cAAc,yBAAyB,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as dgram from "node:dgram";
|
|
2
2
|
import { EventDispatcherMapBase, IEventDispatcherMap } from "@ac-kit/async";
|
|
3
|
-
import {
|
|
3
|
+
import type { IError } from "@ac-kit/core";
|
|
4
4
|
import type { Except, TypedArray } from "type-fest";
|
|
5
|
+
import type { InetEndpoint } from "./inet-endpoint.js";
|
|
5
6
|
/** Event map for DgramSocket socket-specific events. */
|
|
6
7
|
export type DgramSocketEvents = {
|
|
7
8
|
/** Emitted when the socket is closed. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dgram-socket.d.ts","sourceRoot":"","sources":["../../src/net/dgram-socket.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AAGpC,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,
|
|
1
|
+
{"version":3,"file":"dgram-socket.d.ts","sourceRoot":"","sources":["../../src/net/dgram-socket.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AAGpC,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAIpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,wDAAwD;AACxD,MAAM,MA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,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,QAAQ,EACnC,MAAM,CAAC,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,MAAM,CAAC,CAiBjB;IAED,OAAO,CAAC,oBAAoB;CA6B5B"}
|
package/dist/net/dgram-socket.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as dgram from "node:dgram";
|
|
2
2
|
import { EventDispatcherMapBase } from "@ac-kit/async";
|
|
3
|
-
import { composeInetAddress } from "@ac-kit/core";
|
|
4
3
|
import { isNodeErrorWithCode } from "../error/node-error.js";
|
|
4
|
+
import { toInetAddress } from "./inet-address.js";
|
|
5
5
|
/**
|
|
6
6
|
* High-level wrapper around Node.js
|
|
7
7
|
* {@link dgram.Socket | UDP datagram sockets}.
|
|
@@ -206,7 +206,7 @@ export class DgramSocket extends EventDispatcherMapBase {
|
|
|
206
206
|
throw error;
|
|
207
207
|
}
|
|
208
208
|
return {
|
|
209
|
-
...
|
|
209
|
+
...toInetAddress(addr.family, addr.address),
|
|
210
210
|
port: addr.port,
|
|
211
211
|
};
|
|
212
212
|
}
|
|
@@ -331,7 +331,7 @@ export class DgramSocket extends EventDispatcherMapBase {
|
|
|
331
331
|
});
|
|
332
332
|
this.socket.on("message", (msg, rinfo) => {
|
|
333
333
|
const from = {
|
|
334
|
-
...
|
|
334
|
+
...toInetAddress(rinfo.family, rinfo.address),
|
|
335
335
|
port: rinfo.port,
|
|
336
336
|
};
|
|
337
337
|
this.dispatch("message", [msg, rinfo.size, from]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dgram-socket.js","sourceRoot":"","sources":["../../src/net/dgram-socket.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AAGpC,OAAO,EAAE,sBAAsB,EAAuB,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"dgram-socket.js","sourceR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CAAC,SAAS,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;YACxC,MAAM,IAAI,GAAiB;gBAC1B,GAAG,aAAa,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC;gBAC7C,IAAI,EAAE,KAAK,CAAC,IAAI;aAChB,CAAC;YACF,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;QACnD,CAAC,CAAC,CAAC;IACJ,CAAC;CACD"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Represents an Internet address with IP family and address. */
|
|
2
|
+
export type InetAddress = {
|
|
3
|
+
/** IP family: 4 for IPv4, 6 for IPv6, or null for unknown family. */
|
|
4
|
+
family: 4 | 6 | null;
|
|
5
|
+
/** IP address string. */
|
|
6
|
+
address: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Normalizes a family and address into an InetAddress. Validates and converts
|
|
10
|
+
* the family to ensure it is 4, 6, or null.
|
|
11
|
+
*
|
|
12
|
+
* @param family The IP family, either as a string ('IPv4', 'IPv6'), number (4,
|
|
13
|
+
* 6), or null for unknown.
|
|
14
|
+
* @param address The IP address string.
|
|
15
|
+
* @returns An InetAddress object.
|
|
16
|
+
* @throws {UnsupportedError} If the family is not valid (not 'IPv4'/'IPv6' or
|
|
17
|
+
* 4/6 or null).
|
|
18
|
+
*/
|
|
19
|
+
export declare function toInetAddress(family: string | number | null, address: string): InetAddress;
|
|
20
|
+
//# sourceMappingURL=inet-address.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inet-address.d.ts","sourceRoot":"","sources":["../../src/net/inet-address.ts"],"names":[],"mappings":"AAEA,iEAAiE;AACjE,MAAM,MAAM,WAAW,GAAG;IACzB,qEAAqE;IACrE,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;IACrB,yBAAyB;IACzB,OAAO,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAC5B,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,EAC9B,OAAO,EAAE,MAAM,GACb,WAAW,CA6Bb"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { UnsupportedError } from "@ac-kit/core";
|
|
2
|
+
/**
|
|
3
|
+
* Normalizes a family and address into an InetAddress. Validates and converts
|
|
4
|
+
* the family to ensure it is 4, 6, or null.
|
|
5
|
+
*
|
|
6
|
+
* @param family The IP family, either as a string ('IPv4', 'IPv6'), number (4,
|
|
7
|
+
* 6), or null for unknown.
|
|
8
|
+
* @param address The IP address string.
|
|
9
|
+
* @returns An InetAddress object.
|
|
10
|
+
* @throws {UnsupportedError} If the family is not valid (not 'IPv4'/'IPv6' or
|
|
11
|
+
* 4/6 or null).
|
|
12
|
+
*/
|
|
13
|
+
export function toInetAddress(family, address) {
|
|
14
|
+
let validatedFamily;
|
|
15
|
+
if (typeof family === "string") {
|
|
16
|
+
if (family === "IPv4") {
|
|
17
|
+
validatedFamily = 4;
|
|
18
|
+
}
|
|
19
|
+
else if (family === "IPv6") {
|
|
20
|
+
validatedFamily = 6;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
throw new UnsupportedError(`Unsupported IP family: ${family}. Expected 'IPv4' or 'IPv6'.`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
else if (typeof family === "number") {
|
|
27
|
+
if (family === 4 || family === 6) {
|
|
28
|
+
validatedFamily = family;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
throw new UnsupportedError(`Unsupported IP family: ${family}. Expected 4 (IPv4) or 6 (IPv6).`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
validatedFamily = null;
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
family: validatedFamily,
|
|
39
|
+
address,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=inet-address.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inet-address.js","sourceRoot":"","sources":["../../src/net/inet-address.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAUhD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,aAAa,CAC5B,MAA8B,EAC9B,OAAe;IAEf,IAAI,eAA6B,CAAC;IAElC,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAChC,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;YACvB,eAAe,GAAG,CAAC,CAAC;QACrB,CAAC;aAAM,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;YAC9B,eAAe,GAAG,CAAC,CAAC;QACrB,CAAC;aAAM,CAAC;YACP,MAAM,IAAI,gBAAgB,CACzB,0BAA0B,MAAM,8BAA8B,CAC9D,CAAC;QACH,CAAC;IACF,CAAC;SAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QACvC,IAAI,MAAM,KAAK,CAAC,IAAI,MAAM,KAAK,CAAC,EAAE,CAAC;YAClC,eAAe,GAAG,MAAM,CAAC;QAC1B,CAAC;aAAM,CAAC;YACP,MAAM,IAAI,gBAAgB,CACzB,0BAA0B,MAAM,kCAAkC,CAClE,CAAC;QACH,CAAC;IACF,CAAC;SAAM,CAAC;QACP,eAAe,GAAG,IAAI,CAAC;IACxB,CAAC;IAED,OAAO;QACN,MAAM,EAAE,eAAe;QACvB,OAAO;KACP,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inet-endpoint.d.ts","sourceRoot":"","sources":["../../src/net/inet-endpoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,yEAAyE;AACzE,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG;IACxC,mBAAmB;IACnB,IAAI,EAAE,MAAM,CAAC;CACb,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inet-endpoint.js","sourceRoot":"","sources":["../../src/net/inet-endpoint.ts"],"names":[],"mappings":""}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as net from "node:net";
|
|
2
|
-
import { type InetAddress
|
|
2
|
+
import { type InetAddress } from "./inet-address.js";
|
|
3
|
+
import type { InetEndpoint } from "./inet-endpoint.js";
|
|
3
4
|
import { StreamSocket, type StreamSocketEvents } from "./stream-socket.js";
|
|
4
5
|
/** Event map for sockets running over an IP transport. */
|
|
5
6
|
export type InetSocketEvents = StreamSocketEvents & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inet-socket.d.ts","sourceRoot":"","sources":["../../src/net/inet-socket.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAEhC,OAAO,
|
|
1
|
+
{"version":3,"file":"inet-socket.d.ts","sourceRoot":"","sources":["../../src/net/inet-socket.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,KAAK,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE3E,0DAA0D;AAC1D,MAAM,MAAM,gBAAgB,GAAG,kBAAkB,GAAG;IACnD;;;OAGG;IACH,iBAAiB,EAAE,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;IAE5C;;;OAGG;IACH,uBAAuB,EAAE,CAAC,QAAQ,EAAE,YAAY,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IAEhE;;;OAGG;IACH,wBAAwB,EAAE,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;IAEnD,mEAAmE;IACnE,MAAM,EAAE,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;CAClE,CAAC;AAEF;;;;;;;;;;GAUG;AACH,qBAAa,UAAU,CACtB,OAAO,SAAS,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,EACvC,OAAO,SAAS,gBAAgB,GAAG,gBAAgB,CAClD,SAAQ,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC;IACvC;;;;OAIG;IACH,IAAI,cAAc,IAAI,YAAY,GAAG,IAAI,CAaxC;IAED;;;;OAIG;IACH,IAAI,aAAa,IAAI,YAAY,GAAG,IAAI,CAavC;IAED;;;;;;OAMG;IACH,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAEzD;IAED;;;;OAIG;IACH,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAEjC;IAED,UAAmB,oBAAoB,IAAI,IAAI,CAkC9C;CACD"}
|
package/dist/net/inet-socket.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { toInetAddress } from "./inet-address.js";
|
|
2
2
|
import { StreamSocket } from "./stream-socket.js";
|
|
3
3
|
/**
|
|
4
4
|
* Base class for sockets whose transport is an IP connection.
|
|
@@ -25,7 +25,7 @@ export class InetSocket extends StreamSocket {
|
|
|
25
25
|
return null;
|
|
26
26
|
}
|
|
27
27
|
return {
|
|
28
|
-
...
|
|
28
|
+
...toInetAddress(family, address),
|
|
29
29
|
port,
|
|
30
30
|
};
|
|
31
31
|
}
|
|
@@ -42,7 +42,7 @@ export class InetSocket extends StreamSocket {
|
|
|
42
42
|
return null;
|
|
43
43
|
}
|
|
44
44
|
return {
|
|
45
|
-
...
|
|
45
|
+
...toInetAddress(family, address),
|
|
46
46
|
port,
|
|
47
47
|
};
|
|
48
48
|
}
|
|
@@ -69,7 +69,7 @@ export class InetSocket extends StreamSocket {
|
|
|
69
69
|
this.socket.on("connectionAttempt", (ip, port, family) => {
|
|
70
70
|
this.dispatch("connectionAttempt", [
|
|
71
71
|
{
|
|
72
|
-
...
|
|
72
|
+
...toInetAddress(family, ip),
|
|
73
73
|
port,
|
|
74
74
|
},
|
|
75
75
|
]);
|
|
@@ -77,7 +77,7 @@ export class InetSocket extends StreamSocket {
|
|
|
77
77
|
this.socket.on("connectionAttemptFailed", (ip, port, family, error) => {
|
|
78
78
|
this.dispatch("connectionAttemptFailed", [
|
|
79
79
|
{
|
|
80
|
-
...
|
|
80
|
+
...toInetAddress(family, ip),
|
|
81
81
|
port,
|
|
82
82
|
},
|
|
83
83
|
error,
|
|
@@ -86,17 +86,13 @@ export class InetSocket extends StreamSocket {
|
|
|
86
86
|
this.socket.on("connectionAttemptTimeout", (ip, port, family) => {
|
|
87
87
|
this.dispatch("connectionAttemptTimeout", [
|
|
88
88
|
{
|
|
89
|
-
...
|
|
89
|
+
...toInetAddress(family, ip),
|
|
90
90
|
port,
|
|
91
91
|
},
|
|
92
92
|
]);
|
|
93
93
|
});
|
|
94
94
|
this.socket.on("lookup", (error, address, family, host) => {
|
|
95
|
-
this.dispatch("lookup", [
|
|
96
|
-
error,
|
|
97
|
-
composeInetAddress(family, address),
|
|
98
|
-
host,
|
|
99
|
-
]);
|
|
95
|
+
this.dispatch("lookup", [error, toInetAddress(family, address), host]);
|
|
100
96
|
});
|
|
101
97
|
}
|
|
102
98
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inet-socket.js","sourceRoot":"","sources":["../../src/net/inet-socket.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"inet-socket.js","sourceRoot":"","sources":["../../src/net/inet-socket.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAoB,MAAM,mBAAmB,CAAC;AAEpE,OAAO,EAAE,YAAY,EA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
import { InetEndpoint } from "@ac-kit/core";
|
|
3
2
|
import type { Except } from "type-fest";
|
|
3
|
+
import type { InetEndpoint } from "./inet-endpoint.js";
|
|
4
4
|
import { StreamServer, type StreamServerEvents } from "./stream-server.js";
|
|
5
5
|
import { TcpSocket } from "./tcp-socket.js";
|
|
6
6
|
/** Event map for {@link TcpServer}. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tcp-server.d.ts","sourceRoot":"","sources":["../../src/net/tcp-server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"tcp-server.d.ts","sourceRoot":"","sources":["../../src/net/tcp-server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAGhC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGxC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,KAAK,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,uCAAuC;AACvC,MAAM,MAAM,eAAe,GAAG,kBAAkB,GAAG;IAClD,iDAAiD;IACjD,UAAU,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAEhC;;;;OAIG;IACH,IAAI,EAAE;QACL,aAAa,EAAE,YAAY,GAAG,IAAI;QAClC,cAAc,EAAE,YAAY,GAAG,IAAI;KACnC,CAAC;CACF,CAAC;AAEF,kDAAkD;AAClD,MAAM,MAAM,gBAAgB,GAAG,GAAG,CAAC,UAAU,CAAC;AAE9C,oDAAoD;AACpD,MAAM,MAAM,sBAAsB,GAAG,MAAM,CAC1C,GAAG,CAAC,aAAa,EACjB,MAAM,GAAG,MAAM,GAAG,QAAQ,CAC1B,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,SAAS,CACrB,OAAO,SAAS,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,EACvC,OAAO,SAAS,eAAe,GAAG,eAAe,CAChD,SAAQ,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC;IACvC;;;;;OAKG;IACH,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,gBAAgB,GAAG,SAAS,CAEjD;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAKpE;IAED;;;;;;OAMG;IACH,OAAO,IAAI,YAAY,GAAG,IAAI,CAiB7B;IAED,UAAmB,oBAAoB,IAAI,IAAI,CA8B9C;CACD"}
|
package/dist/net/tcp-server.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as net from "node:net";
|
|
2
|
-
import {
|
|
2
|
+
import { UnsupportedError } from "@ac-kit/core";
|
|
3
|
+
import { toInetAddress } from "./inet-address.js";
|
|
3
4
|
import { StreamServer } from "./stream-server.js";
|
|
4
5
|
import { TcpSocket } from "./tcp-socket.js";
|
|
5
6
|
/**
|
|
@@ -59,7 +60,7 @@ export class TcpServer extends StreamServer {
|
|
|
59
60
|
throw new UnsupportedError(`Unsupported address type: string. Expected AddressInfo object.`);
|
|
60
61
|
}
|
|
61
62
|
return {
|
|
62
|
-
...
|
|
63
|
+
...toInetAddress(address.family, address.address),
|
|
63
64
|
port: address.port,
|
|
64
65
|
};
|
|
65
66
|
}
|
|
@@ -73,7 +74,7 @@ export class TcpServer extends StreamServer {
|
|
|
73
74
|
data.localPort !== undefined &&
|
|
74
75
|
data.localFamily !== undefined
|
|
75
76
|
? {
|
|
76
|
-
...
|
|
77
|
+
...toInetAddress(data.localFamily, data.localAddress),
|
|
77
78
|
port: data.localPort,
|
|
78
79
|
}
|
|
79
80
|
: null;
|
|
@@ -81,7 +82,7 @@ export class TcpServer extends StreamServer {
|
|
|
81
82
|
data.remotePort !== undefined &&
|
|
82
83
|
data.remoteFamily !== undefined
|
|
83
84
|
? {
|
|
84
|
-
...
|
|
85
|
+
...toInetAddress(data.remoteFamily, data.remoteAddress),
|
|
85
86
|
port: data.remotePort,
|
|
86
87
|
}
|
|
87
88
|
: null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tcp-server.js","sourceRoot":"","sources":["../../src/net/tcp-server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAEhC,OAAO,
|
|
1
|
+
{"version":3,"file":"tcp-server.js","sourceRoot":"","sources":["../../src/net/tcp-server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGhD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,EAAE,YAAY,EAA2B,MAAM,oBAAoB,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AA2B5C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,SAGX,SAAQ,YAA8B;IACvC;;;;;OAKG;IACH,MAAM,CAAC,IAAI,CAAC,OAA0B;QACrC,OAAO,IAAI,SAAS,CAAC,GAAG,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;IACjD,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,IAAY,EAAE,OAAgC;QACpD,OAAO,IAAI,CAAC,QAAQ,CAAC;YACpB,GAAG,OAAO;YACV,IAAI;SACJ,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACH,OAAO;QACN,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QAEtC,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;YACtB,OAAO,IAAI,CAAC;QACb,CAAC;QAED,IAAI,OAAO,OAAO,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AC,CAAC;QACxD,CAAC,CAAC,CAAC;IACJ,CAAC;CACD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ac-kit/node",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Node.js extensions and zero-dependency wrappers over node: built-ins — promise-based TCP, TLS, IPC and UDP sockets, file I/O helpers and process utilities.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fs",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"prepack": "yarn build"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@ac-kit/async": "^0.1.
|
|
43
|
-
"@ac-kit/core": "^0.
|
|
42
|
+
"@ac-kit/async": "^0.1.2",
|
|
43
|
+
"@ac-kit/core": "^0.3.0",
|
|
44
44
|
"@types/node": "^26.5.1",
|
|
45
45
|
"type-fest": "^5.8.0"
|
|
46
46
|
},
|