@openclaw/fs-safe 0.7.2 → 0.8.1
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 +71 -0
- package/README.md +5 -1
- package/dist/absolute-path.d.ts.map +1 -1
- package/dist/absolute-path.js +9 -10
- package/dist/archive-merge.d.ts +18 -0
- package/dist/archive-merge.d.ts.map +1 -0
- package/dist/archive-merge.js +157 -0
- package/dist/archive-native.d.ts.map +1 -1
- package/dist/archive-native.js +25 -5
- package/dist/archive-policy.d.ts +1 -1
- package/dist/archive-policy.d.ts.map +1 -1
- package/dist/archive-policy.js +1 -1
- package/dist/archive-read.d.ts.map +1 -1
- package/dist/archive-read.js +3 -2
- package/dist/archive-staging.d.ts +13 -8
- package/dist/archive-staging.d.ts.map +1 -1
- package/dist/archive-staging.js +44 -192
- package/dist/archive-tar-meta.d.ts.map +1 -1
- package/dist/archive-tar-meta.js +9 -5
- package/dist/archive-tar-runtime.d.ts +1 -0
- package/dist/archive-tar-runtime.d.ts.map +1 -1
- package/dist/archive-zip-admission.d.ts +2 -1
- package/dist/archive-zip-admission.d.ts.map +1 -1
- package/dist/archive-zip-admission.js +2 -2
- package/dist/archive-zip-directory.d.ts +8 -1
- package/dist/archive-zip-directory.d.ts.map +1 -1
- package/dist/archive-zip-directory.js +6 -2
- package/dist/archive-zip-entry.d.ts +1 -1
- package/dist/archive-zip-entry.d.ts.map +1 -1
- package/dist/archive-zip-names.d.ts +1 -1
- package/dist/archive-zip-names.d.ts.map +1 -1
- package/dist/archive-zip-names.js +1 -0
- package/dist/archive.d.ts.map +1 -1
- package/dist/archive.js +17 -25
- package/dist/directory-guard.d.ts +17 -5
- package/dist/directory-guard.d.ts.map +1 -1
- package/dist/directory-guard.js +8 -6
- package/dist/directory-mode-node.d.ts +8 -0
- package/dist/directory-mode-node.d.ts.map +1 -0
- package/dist/directory-mode-node.js +93 -0
- package/dist/directory-mode-owner.d.ts +21 -0
- package/dist/directory-mode-owner.d.ts.map +1 -0
- package/dist/directory-mode-owner.js +73 -0
- package/dist/file-observation.d.ts +1 -1
- package/dist/file-observation.d.ts.map +1 -1
- package/dist/file-store-boundary.d.ts +2 -0
- package/dist/file-store-boundary.d.ts.map +1 -1
- package/dist/file-store-boundary.js +13 -0
- package/dist/file-store.d.ts.map +1 -1
- package/dist/file-store.js +8 -11
- package/dist/filename.d.ts +6 -0
- package/dist/filename.d.ts.map +1 -1
- package/dist/filename.js +36 -0
- package/dist/guarded-mkdir.d.ts +2 -0
- package/dist/guarded-mkdir.d.ts.map +1 -1
- package/dist/guarded-mkdir.js +2 -2
- package/dist/guarded-mutation.d.ts +2 -2
- package/dist/guarded-mutation.d.ts.map +1 -1
- package/dist/json-document-store.d.ts +3 -0
- package/dist/json-document-store.d.ts.map +1 -1
- package/dist/json-document-store.js +2 -0
- package/dist/json-durable-queue-ownership.d.ts +3 -1
- package/dist/json-durable-queue-ownership.d.ts.map +1 -1
- package/dist/json-durable-queue-ownership.js +7 -4
- package/dist/json-durable-queue.d.ts.map +1 -1
- package/dist/json-durable-queue.js +25 -28
- package/dist/local-roots.d.ts.map +1 -1
- package/dist/local-roots.js +18 -56
- package/dist/move-path-cleanup.d.ts +43 -0
- package/dist/move-path-cleanup.d.ts.map +1 -0
- package/dist/move-path-cleanup.js +159 -0
- package/dist/move-path.d.ts.map +1 -1
- package/dist/move-path.js +30 -84
- package/dist/native-operations.d.ts +2 -4
- package/dist/native-operations.d.ts.map +1 -1
- package/dist/native-operations.js +7 -9
- package/dist/native-pinned-write-windows.d.ts +2 -2
- package/dist/native-pinned-write-windows.d.ts.map +1 -1
- package/dist/native-pinned-write-windows.js +5 -5
- package/dist/native-pinned-write.d.ts.map +1 -1
- package/dist/native-pinned-write.js +14 -4
- package/dist/native-staged-file.d.ts +2 -2
- package/dist/native-staged-file.d.ts.map +1 -1
- package/dist/opened-file-failure.d.ts +1 -0
- package/dist/opened-file-failure.d.ts.map +1 -1
- package/dist/opened-file-failure.js +4 -0
- package/dist/output-sibling.d.ts.map +1 -1
- package/dist/output-sibling.js +9 -3
- package/dist/pinned-write.d.ts +2 -2
- package/dist/pinned-write.d.ts.map +1 -1
- package/dist/pinned-write.js +32 -13
- package/dist/publish-file.d.ts.map +1 -1
- package/dist/publish-file.js +7 -3
- package/dist/regular-file.d.ts +1 -1
- package/dist/regular-file.d.ts.map +1 -1
- package/dist/regular-file.js +35 -6
- package/dist/replace-file-descriptor.d.ts +9 -1
- package/dist/replace-file-descriptor.d.ts.map +1 -1
- package/dist/replace-file-descriptor.js +58 -10
- package/dist/replace-file-temp-owner.d.ts +7 -0
- package/dist/replace-file-temp-owner.d.ts.map +1 -1
- package/dist/replace-file-temp-owner.js +29 -0
- package/dist/replace-file.d.ts +1 -0
- package/dist/replace-file.d.ts.map +1 -1
- package/dist/replace-file.js +12 -38
- package/dist/root-context.d.ts +4 -0
- package/dist/root-context.d.ts.map +1 -1
- package/dist/root-context.js +19 -0
- package/dist/root-impl.d.ts +43 -0
- package/dist/root-impl.d.ts.map +1 -1
- package/dist/root-impl.js +13 -11
- package/dist/root-path-symlink.d.ts +6 -2
- package/dist/root-path-symlink.d.ts.map +1 -1
- package/dist/root-path-symlink.js +7 -6
- package/dist/root-path.d.ts +1 -0
- package/dist/root-path.d.ts.map +1 -1
- package/dist/root-path.js +6 -2
- package/dist/root-walk.d.ts.map +1 -1
- package/dist/root-walk.js +4 -0
- package/dist/root-write-verification.d.ts +3 -2
- package/dist/root-write-verification.d.ts.map +1 -1
- package/dist/root-write-verification.js +6 -0
- package/dist/secret-file.d.ts +9 -0
- package/dist/secret-file.d.ts.map +1 -1
- package/dist/secret-file.js +136 -74
- package/dist/sibling-temp.d.ts.map +1 -1
- package/dist/sibling-temp.js +9 -3
- package/dist/sidecar-lock-acquire.d.ts +1 -0
- package/dist/sidecar-lock-acquire.d.ts.map +1 -1
- package/dist/sidecar-lock-acquire.js +24 -5
- package/dist/sidecar-lock-reclaim.d.ts.map +1 -1
- package/dist/sidecar-lock-reclaim.js +6 -4
- package/dist/sidecar-lock-types.d.ts +7 -0
- package/dist/sidecar-lock-types.d.ts.map +1 -1
- package/dist/sidecar-lock.d.ts +2 -0
- package/dist/sidecar-lock.d.ts.map +1 -1
- package/dist/sidecar-lock.js +44 -3
- package/dist/write-open-flags.d.ts +5 -0
- package/dist/write-open-flags.d.ts.map +1 -0
- package/dist/write-open-flags.js +35 -0
- package/docs/advanced.md +1 -1
- package/docs/archive.md +56 -7
- package/docs/atomic.md +8 -2
- package/docs/contributing.md +13 -0
- package/docs/durability.md +3 -2
- package/docs/errors.md +3 -1
- package/docs/file-store.md +38 -8
- package/docs/local-roots.md +4 -3
- package/docs/output.md +4 -1
- package/docs/private-file-store.md +11 -2
- package/docs/reading.md +3 -1
- package/docs/regular-file.md +16 -2
- package/docs/root.md +4 -2
- package/docs/secret-file.md +37 -2
- package/docs/sidecar-lock.md +33 -5
- package/docs/store.md +5 -1
- package/docs/temp.md +19 -1
- package/docs/writing.md +24 -3
- package/package.json +14 -10
package/docs/writing.md
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
# Writing
|
|
2
2
|
|
|
3
3
|
The `Root` handle exposes a tight set of mutation verbs. Replacement writes
|
|
4
|
-
(`write`, `
|
|
5
|
-
|
|
4
|
+
(`write`, `writeJson`, and `copyIn`) publish with a sibling-temp commit so no
|
|
5
|
+
half-written replacement appears at the destination. Create-only writes
|
|
6
|
+
(`create`, `createJson`, and `write` with `overwrite: false`) use sibling-temp
|
|
7
|
+
staging with an atomic no-replace rename only on backends that provide one —
|
|
8
|
+
the native binding, which `require` mode guarantees and `auto` mode uses when
|
|
9
|
+
the binding loads. The pure-JavaScript fallback has no atomic no-clobber
|
|
10
|
+
rename and does not stage: it claims the final name exclusively with `O_EXCL`
|
|
11
|
+
and writes content in place, so a concurrent observer can see the new file
|
|
12
|
+
before its content is complete. Use `require` mode when that visibility window
|
|
13
|
+
matters.
|
|
6
14
|
`append` and `openWritable` intentionally modify an opened file in place;
|
|
7
15
|
`move`, `remove`, and `mkdir` mutate directory entries rather than file bytes.
|
|
8
16
|
Each verb applies the boundary checks appropriate to its operation.
|
|
@@ -91,7 +99,13 @@ alone is never proof that the name still refers to the expected file.
|
|
|
91
99
|
Don't-clobber variant of `write()`. Throws `already-exists` if the target is there.
|
|
92
100
|
Create-only preflight preserves boundary, alias, hardlink, and type checks without
|
|
93
101
|
opening an existing target to inherit its mode; a fresh file uses the requested
|
|
94
|
-
mode or the normal new-file default.
|
|
102
|
+
mode or the normal new-file default. When the native binding is in use
|
|
103
|
+
(`require` mode, or `auto` mode with a successfully loaded binding), content is
|
|
104
|
+
staged privately and published with an atomic no-replace rename, so the name
|
|
105
|
+
never appears before its bytes. In the pure-JavaScript fallback the name is
|
|
106
|
+
claimed exclusively first and content is written afterward, so observers can
|
|
107
|
+
briefly see an empty file; failure cleanup removes a claimed file only when its
|
|
108
|
+
identity is unchanged.
|
|
95
109
|
|
|
96
110
|
```ts
|
|
97
111
|
try {
|
|
@@ -207,6 +221,13 @@ destination — there is no atomic-rename step. If you need both streaming and
|
|
|
207
221
|
atomicity, write to a sibling temp yourself and rename when done; the
|
|
208
222
|
[`atomic`](atomic.md) helpers can do this for you.
|
|
209
223
|
|
|
224
|
+
On POSIX, existing-target opens use `O_NONBLOCK` as an admission safeguard so
|
|
225
|
+
a no-reader FIFO cannot stall regular-file validation. This does not change
|
|
226
|
+
ordinary regular-file write semantics. `replace` and `update` remain write-only
|
|
227
|
+
opens, including for mode `0o200` files; replacement truncation happens only
|
|
228
|
+
after type, identity, and boundary checks pass. Rejected existing paths are
|
|
229
|
+
never cleanup-owned or unlinked.
|
|
230
|
+
|
|
210
231
|
## Write defaults vs per-call options
|
|
211
232
|
|
|
212
233
|
Set `mkdir: true` once on `root()`; pass text encodings per call when needed:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/fs-safe",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "Capability-style filesystem roots for Node.js apps that handle untrusted relative paths.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"filesystem",
|
|
@@ -93,6 +93,10 @@
|
|
|
93
93
|
"types": "./dist/temp.d.ts",
|
|
94
94
|
"default": "./dist/temp.js"
|
|
95
95
|
},
|
|
96
|
+
"./secure-temp-root": {
|
|
97
|
+
"types": "./dist/secure-temp-dir.d.ts",
|
|
98
|
+
"default": "./dist/secure-temp-dir.js"
|
|
99
|
+
},
|
|
96
100
|
"./atomic": {
|
|
97
101
|
"types": "./dist/atomic.d.ts",
|
|
98
102
|
"default": "./dist/atomic.js"
|
|
@@ -149,20 +153,20 @@
|
|
|
149
153
|
"crabbox:warmup": "crabbox warmup"
|
|
150
154
|
},
|
|
151
155
|
"optionalDependencies": {
|
|
152
|
-
"@openclaw/fs-safe-darwin-arm64": "0.
|
|
153
|
-
"@openclaw/fs-safe-darwin-x64": "0.
|
|
154
|
-
"@openclaw/fs-safe-linux-arm64-gnu": "0.
|
|
155
|
-
"@openclaw/fs-safe-linux-arm64-musl": "0.
|
|
156
|
-
"@openclaw/fs-safe-linux-x64-gnu": "0.
|
|
157
|
-
"@openclaw/fs-safe-linux-x64-musl": "0.
|
|
158
|
-
"@openclaw/fs-safe-win32-x64-msvc": "0.
|
|
156
|
+
"@openclaw/fs-safe-darwin-arm64": "0.8.1",
|
|
157
|
+
"@openclaw/fs-safe-darwin-x64": "0.8.1",
|
|
158
|
+
"@openclaw/fs-safe-linux-arm64-gnu": "0.8.1",
|
|
159
|
+
"@openclaw/fs-safe-linux-arm64-musl": "0.8.1",
|
|
160
|
+
"@openclaw/fs-safe-linux-x64-gnu": "0.8.1",
|
|
161
|
+
"@openclaw/fs-safe-linux-x64-musl": "0.8.1",
|
|
162
|
+
"@openclaw/fs-safe-win32-x64-msvc": "0.8.1",
|
|
159
163
|
"jszip": "^3.10.1",
|
|
160
164
|
"tar": "7.5.22"
|
|
161
165
|
},
|
|
162
166
|
"devDependencies": {
|
|
163
167
|
"@emnapi/runtime": "2.0.0-alpha.4",
|
|
164
168
|
"@napi-rs/cli": "3.8.6",
|
|
165
|
-
"@types/node": "^26.4.
|
|
169
|
+
"@types/node": "^26.4.1",
|
|
166
170
|
"@vitest/coverage-v8": "4.1.11",
|
|
167
171
|
"fast-check": "^4.9.0",
|
|
168
172
|
"istanbul-lib-coverage": "3.2.2",
|
|
@@ -176,5 +180,5 @@
|
|
|
176
180
|
"engines": {
|
|
177
181
|
"node": ">=22"
|
|
178
182
|
},
|
|
179
|
-
"packageManager": "pnpm@11.
|
|
183
|
+
"packageManager": "pnpm@11.25.0"
|
|
180
184
|
}
|