wire-mesh-core 4.2.7 → 4.2.9
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/dist/adapters/node-fs-layout.cjs +2 -1
- package/dist/adapters/node-fs-layout.d.cts +3 -3
- package/dist/adapters/node-fs-layout.d.mts +3 -3
- package/dist/adapters/node-fs-layout.mjs +2 -1
- package/dist/adapters/node-fs-storage.cjs +1 -1
- package/dist/adapters/node-fs-storage.mjs +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
//#region src/adapters/node-fs-layout.ts
|
|
3
3
|
/**
|
|
4
|
-
* Checks `key` against the layout. The first rule it breaks is the refusal, taken in this order: empty, NUL, backslash, a leading slash, then each segment from the left (empty, `.`,
|
|
4
|
+
* Checks `key` against the layout. The first rule it breaks is the refusal, taken in this order: empty, NUL, backslash, a leading slash, then each segment from the left (empty, `.`, `..`, a drive prefix: an ASCII letter followed by a colon). Undefined when the key is a key of the layout.
|
|
5
5
|
*/
|
|
6
6
|
function refusalOfKey(key) {
|
|
7
7
|
if (key === "") return "empty";
|
|
@@ -12,6 +12,7 @@ function refusalOfKey(key) {
|
|
|
12
12
|
if (segment === "") return "empty_segment";
|
|
13
13
|
if (segment === ".") return "dot_segment";
|
|
14
14
|
if (segment === "..") return "parent_segment";
|
|
15
|
+
if (/^[A-Za-z]:/u.test(segment)) return "drive_prefix";
|
|
15
16
|
}
|
|
16
17
|
}
|
|
17
18
|
/** Thrown by a storage operation given a key the layout refuses, rather than storing it under another name. */
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
/**
|
|
3
3
|
The layout of a file-backed key-value store, as pure functions: which keys the layout accepts, and the file a key names. The TypeScript implementation of the layout lives here, and a directory written by any implementation that follows it is read by another. A key is a relative path of `/`-separated segments under the store's directory, and its file holds the value's bytes and nothing else.
|
|
4
4
|
|
|
5
|
-
A key that `path.join` would rewrite (empty, `.` and `..` segments, a doubled or trailing separator) or that leaves the directory would be stored under a name other than its own and listed back as another key, so it is refused.
|
|
5
|
+
A key that `path.join` would rewrite (empty, `.` and `..` segments, a doubled or trailing separator) or that leaves the directory would be stored under a name other than its own and listed back as another key, so it is refused. So is a segment that starts with an ASCII letter and a colon, which Windows reads as a drive prefix that replaces the directory when joined onto it (`C:/x`) or names the drive's current directory (`C:x`). The refusals are the same on every host: `/` is the only separator, and a backslash is refused so that the layout does not depend on the operating system. Names that only some filesystems rewrite (Windows alternate data streams, trailing dots or spaces, reserved device names, case folding, Unicode normalisation) are not covered.
|
|
6
6
|
|
|
7
7
|
Containment is lexical: the rule decides from the key's text alone that the file lies inside the directory, so a symlink placed inside the directory by someone who can already write there is still followed.
|
|
8
8
|
|
|
9
9
|
`KeyRefusal` is a closed union, so a rule added later is a type-level change for a consumer that switches on it exhaustively.
|
|
10
10
|
*/
|
|
11
11
|
/** Why a key is not a key of the layout, by the name the conformance vectors use. */
|
|
12
|
-
export type KeyRefusal = "empty" | "nul" | "backslash" | "absolute" | "empty_segment" | "dot_segment" | "parent_segment";
|
|
12
|
+
export type KeyRefusal = "empty" | "nul" | "backslash" | "absolute" | "empty_segment" | "dot_segment" | "parent_segment" | "drive_prefix";
|
|
13
13
|
/**
|
|
14
|
-
* Checks `key` against the layout. The first rule it breaks is the refusal, taken in this order: empty, NUL, backslash, a leading slash, then each segment from the left (empty, `.`,
|
|
14
|
+
* Checks `key` against the layout. The first rule it breaks is the refusal, taken in this order: empty, NUL, backslash, a leading slash, then each segment from the left (empty, `.`, `..`, a drive prefix: an ASCII letter followed by a colon). Undefined when the key is a key of the layout.
|
|
15
15
|
*/
|
|
16
16
|
export declare function refusalOfKey(key: string): KeyRefusal | undefined;
|
|
17
17
|
/** Thrown by a storage operation given a key the layout refuses, rather than storing it under another name. */
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
/**
|
|
3
3
|
The layout of a file-backed key-value store, as pure functions: which keys the layout accepts, and the file a key names. The TypeScript implementation of the layout lives here, and a directory written by any implementation that follows it is read by another. A key is a relative path of `/`-separated segments under the store's directory, and its file holds the value's bytes and nothing else.
|
|
4
4
|
|
|
5
|
-
A key that `path.join` would rewrite (empty, `.` and `..` segments, a doubled or trailing separator) or that leaves the directory would be stored under a name other than its own and listed back as another key, so it is refused.
|
|
5
|
+
A key that `path.join` would rewrite (empty, `.` and `..` segments, a doubled or trailing separator) or that leaves the directory would be stored under a name other than its own and listed back as another key, so it is refused. So is a segment that starts with an ASCII letter and a colon, which Windows reads as a drive prefix that replaces the directory when joined onto it (`C:/x`) or names the drive's current directory (`C:x`). The refusals are the same on every host: `/` is the only separator, and a backslash is refused so that the layout does not depend on the operating system. Names that only some filesystems rewrite (Windows alternate data streams, trailing dots or spaces, reserved device names, case folding, Unicode normalisation) are not covered.
|
|
6
6
|
|
|
7
7
|
Containment is lexical: the rule decides from the key's text alone that the file lies inside the directory, so a symlink placed inside the directory by someone who can already write there is still followed.
|
|
8
8
|
|
|
9
9
|
`KeyRefusal` is a closed union, so a rule added later is a type-level change for a consumer that switches on it exhaustively.
|
|
10
10
|
*/
|
|
11
11
|
/** Why a key is not a key of the layout, by the name the conformance vectors use. */
|
|
12
|
-
export type KeyRefusal = "empty" | "nul" | "backslash" | "absolute" | "empty_segment" | "dot_segment" | "parent_segment";
|
|
12
|
+
export type KeyRefusal = "empty" | "nul" | "backslash" | "absolute" | "empty_segment" | "dot_segment" | "parent_segment" | "drive_prefix";
|
|
13
13
|
/**
|
|
14
|
-
* Checks `key` against the layout. The first rule it breaks is the refusal, taken in this order: empty, NUL, backslash, a leading slash, then each segment from the left (empty, `.`,
|
|
14
|
+
* Checks `key` against the layout. The first rule it breaks is the refusal, taken in this order: empty, NUL, backslash, a leading slash, then each segment from the left (empty, `.`, `..`, a drive prefix: an ASCII letter followed by a colon). Undefined when the key is a key of the layout.
|
|
15
15
|
*/
|
|
16
16
|
export declare function refusalOfKey(key: string): KeyRefusal | undefined;
|
|
17
17
|
/** Thrown by a storage operation given a key the layout refuses, rather than storing it under another name. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//#region src/adapters/node-fs-layout.ts
|
|
2
2
|
/**
|
|
3
|
-
* Checks `key` against the layout. The first rule it breaks is the refusal, taken in this order: empty, NUL, backslash, a leading slash, then each segment from the left (empty, `.`,
|
|
3
|
+
* Checks `key` against the layout. The first rule it breaks is the refusal, taken in this order: empty, NUL, backslash, a leading slash, then each segment from the left (empty, `.`, `..`, a drive prefix: an ASCII letter followed by a colon). Undefined when the key is a key of the layout.
|
|
4
4
|
*/
|
|
5
5
|
function refusalOfKey(key) {
|
|
6
6
|
if (key === "") return "empty";
|
|
@@ -11,6 +11,7 @@ function refusalOfKey(key) {
|
|
|
11
11
|
if (segment === "") return "empty_segment";
|
|
12
12
|
if (segment === ".") return "dot_segment";
|
|
13
13
|
if (segment === "..") return "parent_segment";
|
|
14
|
+
if (/^[A-Za-z]:/u.test(segment)) return "drive_prefix";
|
|
14
15
|
}
|
|
15
16
|
}
|
|
16
17
|
/** Thrown by a storage operation given a key the layout refuses, rather than storing it under another name. */
|
|
@@ -6,7 +6,7 @@ node_fs_promises = require_rolldown_runtime.__toESM(node_fs_promises, 1);
|
|
|
6
6
|
let node_path = require("node:path");
|
|
7
7
|
node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
|
8
8
|
//#region src/adapters/node-fs-storage.ts
|
|
9
|
-
/** A Node filesystem-backed KeyValueStorage, the durable Node-side counterpart to indexeddb-storage.ts's browser one, and memory-storage.ts's in-process one, satisfying the identical contract. Every key is a relative path under the given directory (creating nested directories as needed), in the layout node-fs-layout.ts defines, so a directory written by one implementation is read by another. A key the layout refuses (empty, `.` and `..` segments, a leading, doubled or trailing separator, a backslash, a NUL) throws InvalidStorageKeyError, since a key that left the directory or that `path.join` rewrites would be stored under a name other than its own. keys() lists only names the layout accepts: a file already in the directory under a refused name (one containing a backslash, or written outside the layout by other means) is skipped, so every listed key can be passed to get, set and delete. A store written before the layout was enforced keeps its files: a key `path.join` rewrote is read under its normalised spelling, and the old spelling now throws. */
|
|
9
|
+
/** A Node filesystem-backed KeyValueStorage, the durable Node-side counterpart to indexeddb-storage.ts's browser one, and memory-storage.ts's in-process one, satisfying the identical contract. Every key is a relative path under the given directory (creating nested directories as needed), in the layout node-fs-layout.ts defines, so a directory written by one implementation is read by another. A key the layout refuses (empty, `.` and `..` segments, a segment starting like a drive such as `C:`, a leading, doubled or trailing separator, a backslash, a NUL) throws InvalidStorageKeyError, since a key that left the directory or that `path.join` rewrites would be stored under a name other than its own. keys() lists only names the layout accepts: a file already in the directory under a refused name (one containing a backslash, or written outside the layout by other means) is skipped, so every listed key can be passed to get, set and delete. A store written before the layout was enforced keeps its files: a key `path.join` rewrote is read under its normalised spelling, and the old spelling now throws. */
|
|
10
10
|
function isEnoent(error) {
|
|
11
11
|
if (!(error instanceof Error)) return false;
|
|
12
12
|
if (!("code" in error)) return false;
|
|
@@ -2,7 +2,7 @@ import { refusalOfKey, segmentsOfKey } from "./node-fs-layout.mjs";
|
|
|
2
2
|
import * as fs from "node:fs/promises";
|
|
3
3
|
import * as path from "node:path";
|
|
4
4
|
//#region src/adapters/node-fs-storage.ts
|
|
5
|
-
/** A Node filesystem-backed KeyValueStorage, the durable Node-side counterpart to indexeddb-storage.ts's browser one, and memory-storage.ts's in-process one, satisfying the identical contract. Every key is a relative path under the given directory (creating nested directories as needed), in the layout node-fs-layout.ts defines, so a directory written by one implementation is read by another. A key the layout refuses (empty, `.` and `..` segments, a leading, doubled or trailing separator, a backslash, a NUL) throws InvalidStorageKeyError, since a key that left the directory or that `path.join` rewrites would be stored under a name other than its own. keys() lists only names the layout accepts: a file already in the directory under a refused name (one containing a backslash, or written outside the layout by other means) is skipped, so every listed key can be passed to get, set and delete. A store written before the layout was enforced keeps its files: a key `path.join` rewrote is read under its normalised spelling, and the old spelling now throws. */
|
|
5
|
+
/** A Node filesystem-backed KeyValueStorage, the durable Node-side counterpart to indexeddb-storage.ts's browser one, and memory-storage.ts's in-process one, satisfying the identical contract. Every key is a relative path under the given directory (creating nested directories as needed), in the layout node-fs-layout.ts defines, so a directory written by one implementation is read by another. A key the layout refuses (empty, `.` and `..` segments, a segment starting like a drive such as `C:`, a leading, doubled or trailing separator, a backslash, a NUL) throws InvalidStorageKeyError, since a key that left the directory or that `path.join` rewrites would be stored under a name other than its own. keys() lists only names the layout accepts: a file already in the directory under a refused name (one containing a backslash, or written outside the layout by other means) is skipped, so every listed key can be passed to get, set and delete. A store written before the layout was enforced keeps its files: a key `path.join` rewrote is read under its normalised spelling, and the old spelling now throws. */
|
|
6
6
|
function isEnoent(error) {
|
|
7
7
|
if (!(error instanceof Error)) return false;
|
|
8
8
|
if (!("code" in error)) return false;
|