@openclaw/openshell-sandbox 2026.9.2 → 2026.9.3
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/index.js +87 -47
- package/node_modules/@openclaw/fs-safe/CHANGELOG.md +700 -0
- package/node_modules/@openclaw/fs-safe/LICENSE +21 -0
- package/node_modules/@openclaw/fs-safe/README.md +564 -0
- package/node_modules/@openclaw/fs-safe/SECURITY.md +45 -0
- package/node_modules/@openclaw/fs-safe/dist/absolute-path.d.ts +33 -0
- package/node_modules/@openclaw/fs-safe/dist/absolute-path.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/absolute-path.js +307 -0
- package/node_modules/@openclaw/fs-safe/dist/advanced.d.ts +26 -0
- package/node_modules/@openclaw/fs-safe/dist/advanced.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/advanced.js +28 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-crc32.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-crc32.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-crc32.js +14 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-deadline.d.ts +12 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-deadline.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-deadline.js +103 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-entry.d.ts +14 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-entry.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-entry.js +85 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-errors.d.ts +13 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-errors.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-errors.js +23 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-gzip-tail.d.ts +18 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-gzip-tail.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-gzip-tail.js +74 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-input.d.ts +19 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-input.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-input.js +92 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-kind.d.ts +9 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-kind.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-kind.js +82 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-limits.d.ts +57 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-limits.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-limits.js +131 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-merge.d.ts +18 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-merge.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-merge.js +157 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-native.d.ts +20 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-native.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-native.js +107 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-options.d.ts +21 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-options.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-options.js +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-parser-errors.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-parser-errors.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-parser-errors.js +12 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-parser.wasm +0 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-plan.d.ts +20 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-plan.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-plan.js +55 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-policy.d.ts +22 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-policy.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-policy.js +38 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-read.d.ts +6 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-read.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-read.js +225 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-staging.d.ts +31 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-staging.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-staging.js +250 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-tar-inspect.d.ts +7 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-tar-inspect.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-tar-inspect.js +59 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-tar-stream.d.ts +18 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-tar-stream.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-tar-stream.js +95 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-tar-wasm.d.ts +18 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-tar-wasm.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-tar-wasm.js +99 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-tar.d.ts +19 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-tar.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-tar.js +21 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-zip-admission.d.ts +8 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-zip-admission.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-zip-admission.js +60 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-zip-count.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-zip-count.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-zip-count.js +140 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-zip-directory.d.ts +15 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-zip-directory.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-zip-directory.js +228 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-zip-entry.d.ts +21 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-zip-entry.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-zip-entry.js +27 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-zip-integrity.d.ts +5 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-zip-integrity.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-zip-integrity.js +41 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-zip-names.d.ts +12 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-zip-names.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-zip-names.js +100 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-zip-preflight.d.ts +7 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-zip-preflight.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-zip-preflight.js +44 -0
- package/node_modules/@openclaw/fs-safe/dist/archive.d.ts +15 -0
- package/node_modules/@openclaw/fs-safe/dist/archive.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive.js +275 -0
- package/node_modules/@openclaw/fs-safe/dist/async-lock.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/async-lock.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/async-lock.js +17 -0
- package/node_modules/@openclaw/fs-safe/dist/atomic.d.ts +5 -0
- package/node_modules/@openclaw/fs-safe/dist/atomic.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/atomic.js +4 -0
- package/node_modules/@openclaw/fs-safe/dist/bounded-read-stream.d.ts +4 -0
- package/node_modules/@openclaw/fs-safe/dist/bounded-read-stream.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/bounded-read-stream.js +21 -0
- package/node_modules/@openclaw/fs-safe/dist/bounded-read.d.ts +14 -0
- package/node_modules/@openclaw/fs-safe/dist/bounded-read.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/bounded-read.js +106 -0
- package/node_modules/@openclaw/fs-safe/dist/byte-budget.d.ts +4 -0
- package/node_modules/@openclaw/fs-safe/dist/byte-budget.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/byte-budget.js +9 -0
- package/node_modules/@openclaw/fs-safe/dist/config.d.ts +3 -0
- package/node_modules/@openclaw/fs-safe/dist/config.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/config.js +2 -0
- package/node_modules/@openclaw/fs-safe/dist/containment.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/containment.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/containment.js +1 -0
- package/node_modules/@openclaw/fs-safe/dist/deny-mutations.d.ts +12 -0
- package/node_modules/@openclaw/fs-safe/dist/deny-mutations.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/deny-mutations.js +69 -0
- package/node_modules/@openclaw/fs-safe/dist/device-path.d.ts +15 -0
- package/node_modules/@openclaw/fs-safe/dist/device-path.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/device-path.js +137 -0
- package/node_modules/@openclaw/fs-safe/dist/directory-durability.d.ts +44 -0
- package/node_modules/@openclaw/fs-safe/dist/directory-durability.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/directory-durability.js +299 -0
- package/node_modules/@openclaw/fs-safe/dist/directory-guard.d.ts +31 -0
- package/node_modules/@openclaw/fs-safe/dist/directory-guard.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/directory-guard.js +82 -0
- package/node_modules/@openclaw/fs-safe/dist/directory-mode-node.d.ts +8 -0
- package/node_modules/@openclaw/fs-safe/dist/directory-mode-node.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/directory-mode-node.js +93 -0
- package/node_modules/@openclaw/fs-safe/dist/directory-mode-owner.d.ts +21 -0
- package/node_modules/@openclaw/fs-safe/dist/directory-mode-owner.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/directory-mode-owner.js +78 -0
- package/node_modules/@openclaw/fs-safe/dist/durability.d.ts +4 -0
- package/node_modules/@openclaw/fs-safe/dist/durability.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/durability.js +3 -0
- package/node_modules/@openclaw/fs-safe/dist/error-detail.d.ts +3 -0
- package/node_modules/@openclaw/fs-safe/dist/error-detail.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/error-detail.js +10 -0
- package/node_modules/@openclaw/fs-safe/dist/errors.d.ts +14 -0
- package/node_modules/@openclaw/fs-safe/dist/errors.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/errors.js +26 -0
- package/node_modules/@openclaw/fs-safe/dist/file-hash.d.ts +10 -0
- package/node_modules/@openclaw/fs-safe/dist/file-hash.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/file-hash.js +73 -0
- package/node_modules/@openclaw/fs-safe/dist/file-identity.d.ts +8 -0
- package/node_modules/@openclaw/fs-safe/dist/file-identity.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/file-identity.js +34 -0
- package/node_modules/@openclaw/fs-safe/dist/file-lock-sync.d.ts +35 -0
- package/node_modules/@openclaw/fs-safe/dist/file-lock-sync.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/file-lock-sync.js +349 -0
- package/node_modules/@openclaw/fs-safe/dist/file-lock.d.ts +24 -0
- package/node_modules/@openclaw/fs-safe/dist/file-lock.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/file-lock.js +46 -0
- package/node_modules/@openclaw/fs-safe/dist/file-observation.d.ts +9 -0
- package/node_modules/@openclaw/fs-safe/dist/file-observation.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/file-observation.js +22 -0
- package/node_modules/@openclaw/fs-safe/dist/file-store-boundary.d.ts +33 -0
- package/node_modules/@openclaw/fs-safe/dist/file-store-boundary.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/file-store-boundary.js +189 -0
- package/node_modules/@openclaw/fs-safe/dist/file-store-limit.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/file-store-limit.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/file-store-limit.js +8 -0
- package/node_modules/@openclaw/fs-safe/dist/file-store-prune.d.ts +12 -0
- package/node_modules/@openclaw/fs-safe/dist/file-store-prune.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/file-store-prune.js +95 -0
- package/node_modules/@openclaw/fs-safe/dist/file-store-sync-write.d.ts +9 -0
- package/node_modules/@openclaw/fs-safe/dist/file-store-sync-write.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/file-store-sync-write.js +127 -0
- package/node_modules/@openclaw/fs-safe/dist/file-store.d.ts +62 -0
- package/node_modules/@openclaw/fs-safe/dist/file-store.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/file-store.js +357 -0
- package/node_modules/@openclaw/fs-safe/dist/file-sync.d.ts +5 -0
- package/node_modules/@openclaw/fs-safe/dist/file-sync.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/file-sync.js +19 -0
- package/node_modules/@openclaw/fs-safe/dist/filename.d.ts +8 -0
- package/node_modules/@openclaw/fs-safe/dist/filename.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/filename.js +91 -0
- package/node_modules/@openclaw/fs-safe/dist/fs.d.ts +13 -0
- package/node_modules/@openclaw/fs-safe/dist/fs.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/fs.js +30 -0
- package/node_modules/@openclaw/fs-safe/dist/guarded-mkdir.d.ts +14 -0
- package/node_modules/@openclaw/fs-safe/dist/guarded-mkdir.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/guarded-mkdir.js +87 -0
- package/node_modules/@openclaw/fs-safe/dist/guarded-mutation.d.ts +37 -0
- package/node_modules/@openclaw/fs-safe/dist/guarded-mutation.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/guarded-mutation.js +82 -0
- package/node_modules/@openclaw/fs-safe/dist/home-dir.d.ts +12 -0
- package/node_modules/@openclaw/fs-safe/dist/home-dir.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/home-dir.js +84 -0
- package/node_modules/@openclaw/fs-safe/dist/index.d.ts +7 -0
- package/node_modules/@openclaw/fs-safe/dist/index.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/index.js +5 -0
- package/node_modules/@openclaw/fs-safe/dist/install-path.d.ts +20 -0
- package/node_modules/@openclaw/fs-safe/dist/install-path.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/install-path.js +94 -0
- package/node_modules/@openclaw/fs-safe/dist/json-document-store.d.ts +35 -0
- package/node_modules/@openclaw/fs-safe/dist/json-document-store.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/json-document-store.js +97 -0
- package/node_modules/@openclaw/fs-safe/dist/json-durable-queue-directory.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/json-durable-queue-directory.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/json-durable-queue-directory.js +20 -0
- package/node_modules/@openclaw/fs-safe/dist/json-durable-queue-ownership.d.ts +17 -0
- package/node_modules/@openclaw/fs-safe/dist/json-durable-queue-ownership.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/json-durable-queue-ownership.js +292 -0
- package/node_modules/@openclaw/fs-safe/dist/json-durable-queue.d.ts +46 -0
- package/node_modules/@openclaw/fs-safe/dist/json-durable-queue.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/json-durable-queue.js +383 -0
- package/node_modules/@openclaw/fs-safe/dist/json-store.d.ts +9 -0
- package/node_modules/@openclaw/fs-safe/dist/json-store.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/json-store.js +12 -0
- package/node_modules/@openclaw/fs-safe/dist/json-stringify.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/json-stringify.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/json-stringify.js +7 -0
- package/node_modules/@openclaw/fs-safe/dist/json.d.ts +50 -0
- package/node_modules/@openclaw/fs-safe/dist/json.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/json.js +343 -0
- package/node_modules/@openclaw/fs-safe/dist/local-file-access.d.ts +9 -0
- package/node_modules/@openclaw/fs-safe/dist/local-file-access.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/local-file-access.js +87 -0
- package/node_modules/@openclaw/fs-safe/dist/local-roots.d.ts +26 -0
- package/node_modules/@openclaw/fs-safe/dist/local-roots.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/local-roots.js +135 -0
- package/node_modules/@openclaw/fs-safe/dist/lock-config.d.ts +10 -0
- package/node_modules/@openclaw/fs-safe/dist/lock-config.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/lock-config.js +12 -0
- package/node_modules/@openclaw/fs-safe/dist/move-path-cleanup.d.ts +43 -0
- package/node_modules/@openclaw/fs-safe/dist/move-path-cleanup.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/move-path-cleanup.js +161 -0
- package/node_modules/@openclaw/fs-safe/dist/move-path.d.ts +21 -0
- package/node_modules/@openclaw/fs-safe/dist/move-path.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/move-path.js +334 -0
- package/node_modules/@openclaw/fs-safe/dist/native-binding.d.ts +93 -0
- package/node_modules/@openclaw/fs-safe/dist/native-binding.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/native-binding.js +1 -0
- package/node_modules/@openclaw/fs-safe/dist/native-config.d.ts +17 -0
- package/node_modules/@openclaw/fs-safe/dist/native-config.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/native-config.js +71 -0
- package/node_modules/@openclaw/fs-safe/dist/native-operations.d.ts +21 -0
- package/node_modules/@openclaw/fs-safe/dist/native-operations.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/native-operations.js +132 -0
- package/node_modules/@openclaw/fs-safe/dist/native-pinned-write-windows.d.ts +8 -0
- package/node_modules/@openclaw/fs-safe/dist/native-pinned-write-windows.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/native-pinned-write-windows.js +96 -0
- package/node_modules/@openclaw/fs-safe/dist/native-pinned-write.d.ts +5 -0
- package/node_modules/@openclaw/fs-safe/dist/native-pinned-write.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/native-pinned-write.js +161 -0
- package/node_modules/@openclaw/fs-safe/dist/native-staged-file.d.ts +31 -0
- package/node_modules/@openclaw/fs-safe/dist/native-staged-file.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/native-staged-file.js +362 -0
- package/node_modules/@openclaw/fs-safe/dist/native.d.ts +14 -0
- package/node_modules/@openclaw/fs-safe/dist/native.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/native.js +204 -0
- package/node_modules/@openclaw/fs-safe/dist/opened-file-failure.d.ts +8 -0
- package/node_modules/@openclaw/fs-safe/dist/opened-file-failure.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/opened-file-failure.js +45 -0
- package/node_modules/@openclaw/fs-safe/dist/opened-realpath.d.ts +16 -0
- package/node_modules/@openclaw/fs-safe/dist/opened-realpath.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/opened-realpath.js +92 -0
- package/node_modules/@openclaw/fs-safe/dist/output.d.ts +15 -0
- package/node_modules/@openclaw/fs-safe/dist/output.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/output.js +123 -0
- package/node_modules/@openclaw/fs-safe/dist/owner-dacl.d.ts +31 -0
- package/node_modules/@openclaw/fs-safe/dist/owner-dacl.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/owner-dacl.js +28 -0
- package/node_modules/@openclaw/fs-safe/dist/path-policy.d.ts +25 -0
- package/node_modules/@openclaw/fs-safe/dist/path-policy.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/path-policy.js +44 -0
- package/node_modules/@openclaw/fs-safe/dist/path.d.ts +21 -0
- package/node_modules/@openclaw/fs-safe/dist/path.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/path.js +136 -0
- package/node_modules/@openclaw/fs-safe/dist/permission-exec.d.ts +25 -0
- package/node_modules/@openclaw/fs-safe/dist/permission-exec.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/permission-exec.js +74 -0
- package/node_modules/@openclaw/fs-safe/dist/permissions-public.d.ts +4 -0
- package/node_modules/@openclaw/fs-safe/dist/permissions-public.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/permissions-public.js +3 -0
- package/node_modules/@openclaw/fs-safe/dist/permissions-windows.d.ts +59 -0
- package/node_modules/@openclaw/fs-safe/dist/permissions-windows.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/permissions-windows.js +296 -0
- package/node_modules/@openclaw/fs-safe/dist/permissions.d.ts +60 -0
- package/node_modules/@openclaw/fs-safe/dist/permissions.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/permissions.js +125 -0
- package/node_modules/@openclaw/fs-safe/dist/pinned-open.d.ts +24 -0
- package/node_modules/@openclaw/fs-safe/dist/pinned-open.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/pinned-open.js +74 -0
- package/node_modules/@openclaw/fs-safe/dist/pinned-operation.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/pinned-operation.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/pinned-operation.js +35 -0
- package/node_modules/@openclaw/fs-safe/dist/pinned-write.d.ts +36 -0
- package/node_modules/@openclaw/fs-safe/dist/pinned-write.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/pinned-write.js +252 -0
- package/node_modules/@openclaw/fs-safe/dist/private-directory.d.ts +5 -0
- package/node_modules/@openclaw/fs-safe/dist/private-directory.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/private-directory.js +14 -0
- package/node_modules/@openclaw/fs-safe/dist/private-temp-workspace.d.ts +45 -0
- package/node_modules/@openclaw/fs-safe/dist/private-temp-workspace.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/private-temp-workspace.js +299 -0
- package/node_modules/@openclaw/fs-safe/dist/publish-file-failure.d.ts +28 -0
- package/node_modules/@openclaw/fs-safe/dist/publish-file-failure.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/publish-file-failure.js +22 -0
- package/node_modules/@openclaw/fs-safe/dist/publish-file.d.ts +21 -0
- package/node_modules/@openclaw/fs-safe/dist/publish-file.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/publish-file.js +366 -0
- package/node_modules/@openclaw/fs-safe/dist/read-open-flags.d.ts +8 -0
- package/node_modules/@openclaw/fs-safe/dist/read-open-flags.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/read-open-flags.js +13 -0
- package/node_modules/@openclaw/fs-safe/dist/read-opened-file.d.ts +21 -0
- package/node_modules/@openclaw/fs-safe/dist/read-opened-file.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/read-opened-file.js +18 -0
- package/node_modules/@openclaw/fs-safe/dist/regular-file.d.ts +38 -0
- package/node_modules/@openclaw/fs-safe/dist/regular-file.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/regular-file.js +391 -0
- package/node_modules/@openclaw/fs-safe/dist/replace-directory.d.ts +7 -0
- package/node_modules/@openclaw/fs-safe/dist/replace-directory.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/replace-directory.js +42 -0
- package/node_modules/@openclaw/fs-safe/dist/replace-file-copy-fallback.d.ts +39 -0
- package/node_modules/@openclaw/fs-safe/dist/replace-file-copy-fallback.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/replace-file-copy-fallback.js +331 -0
- package/node_modules/@openclaw/fs-safe/dist/replace-file-copy-source.d.ts +21 -0
- package/node_modules/@openclaw/fs-safe/dist/replace-file-copy-source.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/replace-file-copy-source.js +107 -0
- package/node_modules/@openclaw/fs-safe/dist/replace-file-descriptor.d.ts +51 -0
- package/node_modules/@openclaw/fs-safe/dist/replace-file-descriptor.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/replace-file-descriptor.js +161 -0
- package/node_modules/@openclaw/fs-safe/dist/replace-file-rename-policy.d.ts +7 -0
- package/node_modules/@openclaw/fs-safe/dist/replace-file-rename-policy.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/replace-file-rename-policy.js +30 -0
- package/node_modules/@openclaw/fs-safe/dist/replace-file-temp-owner.d.ts +53 -0
- package/node_modules/@openclaw/fs-safe/dist/replace-file-temp-owner.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/replace-file-temp-owner.js +376 -0
- package/node_modules/@openclaw/fs-safe/dist/replace-file.d.ts +58 -0
- package/node_modules/@openclaw/fs-safe/dist/replace-file.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/replace-file.js +329 -0
- package/node_modules/@openclaw/fs-safe/dist/root-context.d.ts +38 -0
- package/node_modules/@openclaw/fs-safe/dist/root-context.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/root-context.js +141 -0
- package/node_modules/@openclaw/fs-safe/dist/root-errors.d.ts +12 -0
- package/node_modules/@openclaw/fs-safe/dist/root-errors.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/root-errors.js +75 -0
- package/node_modules/@openclaw/fs-safe/dist/root-file.d.ts +45 -0
- package/node_modules/@openclaw/fs-safe/dist/root-file.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/root-file.js +120 -0
- package/node_modules/@openclaw/fs-safe/dist/root-impl.d.ts +163 -0
- package/node_modules/@openclaw/fs-safe/dist/root-impl.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/root-impl.js +1230 -0
- package/node_modules/@openclaw/fs-safe/dist/root-path-existing.d.ts +3 -0
- package/node_modules/@openclaw/fs-safe/dist/root-path-existing.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/root-path-existing.js +68 -0
- package/node_modules/@openclaw/fs-safe/dist/root-path-symlink.d.ts +7 -0
- package/node_modules/@openclaw/fs-safe/dist/root-path-symlink.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/root-path-symlink.js +35 -0
- package/node_modules/@openclaw/fs-safe/dist/root-path.d.ts +40 -0
- package/node_modules/@openclaw/fs-safe/dist/root-path.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/root-path.js +481 -0
- package/node_modules/@openclaw/fs-safe/dist/root-paths.d.ts +89 -0
- package/node_modules/@openclaw/fs-safe/dist/root-paths.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/root-paths.js +381 -0
- package/node_modules/@openclaw/fs-safe/dist/root-walk.d.ts +41 -0
- package/node_modules/@openclaw/fs-safe/dist/root-walk.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/root-walk.js +133 -0
- package/node_modules/@openclaw/fs-safe/dist/root-write-mode.d.ts +6 -0
- package/node_modules/@openclaw/fs-safe/dist/root-write-mode.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/root-write-mode.js +61 -0
- package/node_modules/@openclaw/fs-safe/dist/root-write-verification.d.ts +12 -0
- package/node_modules/@openclaw/fs-safe/dist/root-write-verification.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/root-write-verification.js +97 -0
- package/node_modules/@openclaw/fs-safe/dist/root.d.ts +4 -0
- package/node_modules/@openclaw/fs-safe/dist/root.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/root.js +1 -0
- package/node_modules/@openclaw/fs-safe/dist/safe-path-segment.d.ts +12 -0
- package/node_modules/@openclaw/fs-safe/dist/safe-path-segment.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/safe-path-segment.js +75 -0
- package/node_modules/@openclaw/fs-safe/dist/secret-file.d.ts +25 -0
- package/node_modules/@openclaw/fs-safe/dist/secret-file.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/secret-file.js +329 -0
- package/node_modules/@openclaw/fs-safe/dist/secret-read-async.d.ts +4 -0
- package/node_modules/@openclaw/fs-safe/dist/secret-read-async.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/secret-read-async.js +73 -0
- package/node_modules/@openclaw/fs-safe/dist/secret-read-policy.d.ts +17 -0
- package/node_modules/@openclaw/fs-safe/dist/secret-read-policy.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/secret-read-policy.js +40 -0
- package/node_modules/@openclaw/fs-safe/dist/secret.d.ts +4 -0
- package/node_modules/@openclaw/fs-safe/dist/secret.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/secret.js +3 -0
- package/node_modules/@openclaw/fs-safe/dist/secure-file.d.ts +32 -0
- package/node_modules/@openclaw/fs-safe/dist/secure-file.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/secure-file.js +182 -0
- package/node_modules/@openclaw/fs-safe/dist/secure-temp-dir.d.ts +27 -0
- package/node_modules/@openclaw/fs-safe/dist/secure-temp-dir.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/secure-temp-dir.js +160 -0
- package/node_modules/@openclaw/fs-safe/dist/sibling-staged-file.d.ts +15 -0
- package/node_modules/@openclaw/fs-safe/dist/sibling-staged-file.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/sibling-staged-file.js +143 -0
- package/node_modules/@openclaw/fs-safe/dist/sibling-temp.d.ts +27 -0
- package/node_modules/@openclaw/fs-safe/dist/sibling-temp.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/sibling-temp.js +95 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-acquire.d.ts +31 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-acquire.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-acquire.js +336 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-handle.d.ts +24 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-handle.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-handle.js +42 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-policy.d.ts +14 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-policy.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-policy.js +71 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-reclaim.d.ts +63 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-reclaim.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-reclaim.js +305 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-root.d.ts +3 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-root.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-root.js +76 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-types.d.ts +63 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-types.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-types.js +1 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock.d.ts +14 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock.js +265 -0
- package/node_modules/@openclaw/fs-safe/dist/staged-directory.d.ts +16 -0
- package/node_modules/@openclaw/fs-safe/dist/staged-directory.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/staged-directory.js +60 -0
- package/node_modules/@openclaw/fs-safe/dist/staged-file-types.d.ts +56 -0
- package/node_modules/@openclaw/fs-safe/dist/staged-file-types.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/staged-file-types.js +1 -0
- package/node_modules/@openclaw/fs-safe/dist/store.d.ts +4 -0
- package/node_modules/@openclaw/fs-safe/dist/store.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/store.js +3 -0
- package/node_modules/@openclaw/fs-safe/dist/strict-file-identity.d.ts +6 -0
- package/node_modules/@openclaw/fs-safe/dist/strict-file-identity.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/strict-file-identity.js +51 -0
- package/node_modules/@openclaw/fs-safe/dist/string-coerce.d.ts +5 -0
- package/node_modules/@openclaw/fs-safe/dist/string-coerce.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/string-coerce.js +16 -0
- package/node_modules/@openclaw/fs-safe/dist/suppressed-error.d.ts +6 -0
- package/node_modules/@openclaw/fs-safe/dist/suppressed-error.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/suppressed-error.js +15 -0
- package/node_modules/@openclaw/fs-safe/dist/symlink-parents.d.ts +12 -0
- package/node_modules/@openclaw/fs-safe/dist/symlink-parents.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/symlink-parents.js +78 -0
- package/node_modules/@openclaw/fs-safe/dist/temp-cleanup.d.ts +14 -0
- package/node_modules/@openclaw/fs-safe/dist/temp-cleanup.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/temp-cleanup.js +87 -0
- package/node_modules/@openclaw/fs-safe/dist/temp-target.d.ts +28 -0
- package/node_modules/@openclaw/fs-safe/dist/temp-target.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/temp-target.js +137 -0
- package/node_modules/@openclaw/fs-safe/dist/temp-workspace-owner.d.ts +23 -0
- package/node_modules/@openclaw/fs-safe/dist/temp-workspace-owner.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/temp-workspace-owner.js +320 -0
- package/node_modules/@openclaw/fs-safe/dist/temp.d.ts +4 -0
- package/node_modules/@openclaw/fs-safe/dist/temp.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/temp.js +2 -0
- package/node_modules/@openclaw/fs-safe/dist/test-hooks.d.ts +25 -0
- package/node_modules/@openclaw/fs-safe/dist/test-hooks.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/test-hooks.js +13 -0
- package/node_modules/@openclaw/fs-safe/dist/text-atomic.d.ts +14 -0
- package/node_modules/@openclaw/fs-safe/dist/text-atomic.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/text-atomic.js +14 -0
- package/node_modules/@openclaw/fs-safe/dist/timing.d.ts +8 -0
- package/node_modules/@openclaw/fs-safe/dist/timing.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/timing.js +40 -0
- package/node_modules/@openclaw/fs-safe/dist/trash.d.ts +5 -0
- package/node_modules/@openclaw/fs-safe/dist/trash.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/trash.js +171 -0
- package/node_modules/@openclaw/fs-safe/dist/types.d.ts +23 -0
- package/node_modules/@openclaw/fs-safe/dist/types.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/types.js +1 -0
- package/node_modules/@openclaw/fs-safe/dist/walk.d.ts +37 -0
- package/node_modules/@openclaw/fs-safe/dist/walk.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/walk.js +207 -0
- package/node_modules/@openclaw/fs-safe/dist/windows-command.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/windows-command.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/windows-command.js +34 -0
- package/node_modules/@openclaw/fs-safe/dist/windows-owner.d.ts +32 -0
- package/node_modules/@openclaw/fs-safe/dist/windows-owner.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/windows-owner.js +126 -0
- package/node_modules/@openclaw/fs-safe/dist/write-open-flags.d.ts +5 -0
- package/node_modules/@openclaw/fs-safe/dist/write-open-flags.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/write-open-flags.js +35 -0
- package/node_modules/@openclaw/fs-safe/dist/write-queue.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/write-queue.d.ts.map +1 -0
- package/node_modules/@openclaw/fs-safe/dist/write-queue.js +18 -0
- package/node_modules/@openclaw/fs-safe/docs/advanced.md +153 -0
- package/node_modules/@openclaw/fs-safe/docs/archive.md +658 -0
- package/node_modules/@openclaw/fs-safe/docs/assets/readme-banner.jpg +0 -0
- package/node_modules/@openclaw/fs-safe/docs/atomic.md +334 -0
- package/node_modules/@openclaw/fs-safe/docs/config.md +131 -0
- package/node_modules/@openclaw/fs-safe/docs/contributing.md +180 -0
- package/node_modules/@openclaw/fs-safe/docs/durability.md +313 -0
- package/node_modules/@openclaw/fs-safe/docs/errors.md +232 -0
- package/node_modules/@openclaw/fs-safe/docs/file-store.md +258 -0
- package/node_modules/@openclaw/fs-safe/docs/filename.md +96 -0
- package/node_modules/@openclaw/fs-safe/docs/index.md +84 -0
- package/node_modules/@openclaw/fs-safe/docs/install-path.md +170 -0
- package/node_modules/@openclaw/fs-safe/docs/install.md +163 -0
- package/node_modules/@openclaw/fs-safe/docs/json-store.md +221 -0
- package/node_modules/@openclaw/fs-safe/docs/json.md +213 -0
- package/node_modules/@openclaw/fs-safe/docs/local-roots.md +141 -0
- package/node_modules/@openclaw/fs-safe/docs/migrating-to-0.5.md +196 -0
- package/node_modules/@openclaw/fs-safe/docs/migrating-to-0.6.md +43 -0
- package/node_modules/@openclaw/fs-safe/docs/native-helper.md +118 -0
- package/node_modules/@openclaw/fs-safe/docs/native.md +196 -0
- package/node_modules/@openclaw/fs-safe/docs/output.md +139 -0
- package/node_modules/@openclaw/fs-safe/docs/path-scope.md +159 -0
- package/node_modules/@openclaw/fs-safe/docs/path.md +208 -0
- package/node_modules/@openclaw/fs-safe/docs/permissions.md +200 -0
- package/node_modules/@openclaw/fs-safe/docs/private-file-store.md +54 -0
- package/node_modules/@openclaw/fs-safe/docs/public-api.md +112 -0
- package/node_modules/@openclaw/fs-safe/docs/quickstart.md +154 -0
- package/node_modules/@openclaw/fs-safe/docs/reading.md +183 -0
- package/node_modules/@openclaw/fs-safe/docs/regular-file.md +190 -0
- package/node_modules/@openclaw/fs-safe/docs/root.md +266 -0
- package/node_modules/@openclaw/fs-safe/docs/secret-file.md +273 -0
- package/node_modules/@openclaw/fs-safe/docs/secure-file.md +100 -0
- package/node_modules/@openclaw/fs-safe/docs/security-model.md +188 -0
- package/node_modules/@openclaw/fs-safe/docs/sidecar-lock.md +439 -0
- package/node_modules/@openclaw/fs-safe/docs/staged-file.md +182 -0
- package/node_modules/@openclaw/fs-safe/docs/store.md +94 -0
- package/node_modules/@openclaw/fs-safe/docs/temp.md +476 -0
- package/node_modules/@openclaw/fs-safe/docs/test-hooks.md +96 -0
- package/node_modules/@openclaw/fs-safe/docs/testing.md +189 -0
- package/node_modules/@openclaw/fs-safe/docs/timing.md +121 -0
- package/node_modules/@openclaw/fs-safe/docs/types.md +188 -0
- package/node_modules/@openclaw/fs-safe/docs/walk.md +128 -0
- package/node_modules/@openclaw/fs-safe/docs/writing.md +347 -0
- package/node_modules/@openclaw/fs-safe/package.json +187 -0
- package/node_modules/@openclaw/fs-safe-darwin-arm64/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-darwin-arm64/package.json +29 -0
- package/node_modules/@openclaw/fs-safe-darwin-x64/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-darwin-x64/package.json +29 -0
- package/node_modules/@openclaw/fs-safe-linux-arm64-gnu/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-linux-arm64-gnu/package.json +32 -0
- package/node_modules/@openclaw/fs-safe-linux-arm64-musl/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-linux-arm64-musl/package.json +32 -0
- package/node_modules/@openclaw/fs-safe-linux-x64-gnu/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-linux-x64-gnu/package.json +32 -0
- package/node_modules/@openclaw/fs-safe-linux-x64-musl/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-linux-x64-musl/package.json +32 -0
- package/node_modules/@openclaw/fs-safe-win32-x64-msvc/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-win32-x64-msvc/package.json +29 -0
- package/node_modules/core-util-is/LICENSE +19 -0
- package/node_modules/core-util-is/README.md +3 -0
- package/node_modules/core-util-is/lib/util.js +107 -0
- package/node_modules/core-util-is/package.json +38 -0
- package/node_modules/immediate/LICENSE.txt +20 -0
- package/node_modules/immediate/README.md +93 -0
- package/node_modules/immediate/dist/immediate.js +75 -0
- package/node_modules/immediate/dist/immediate.min.js +1 -0
- package/node_modules/immediate/lib/browser.js +69 -0
- package/node_modules/immediate/lib/index.js +73 -0
- package/node_modules/immediate/package.json +42 -0
- package/node_modules/inherits/LICENSE +16 -0
- package/node_modules/inherits/README.md +42 -0
- package/node_modules/inherits/inherits.js +9 -0
- package/node_modules/inherits/inherits_browser.js +27 -0
- package/node_modules/inherits/package.json +29 -0
- package/node_modules/isarray/.npmignore +1 -0
- package/node_modules/isarray/.travis.yml +4 -0
- package/node_modules/isarray/Makefile +6 -0
- package/node_modules/isarray/README.md +60 -0
- package/node_modules/isarray/component.json +19 -0
- package/node_modules/isarray/index.js +5 -0
- package/node_modules/isarray/package.json +45 -0
- package/node_modules/isarray/test.js +20 -0
- package/node_modules/jszip/.codeclimate.yml +16 -0
- package/node_modules/jszip/.editorconfig +8 -0
- package/node_modules/jszip/.eslintrc.js +43 -0
- package/node_modules/jszip/.github/workflows/pr.yaml +58 -0
- package/node_modules/jszip/.jekyll-metadata +0 -0
- package/node_modules/jszip/.travis.yml +17 -0
- package/node_modules/jszip/CHANGES.md +204 -0
- package/node_modules/jszip/LICENSE.markdown +651 -0
- package/node_modules/jszip/README.markdown +33 -0
- package/node_modules/jszip/deps.js +37 -0
- package/node_modules/jszip/dist/jszip.js +11577 -0
- package/node_modules/jszip/dist/jszip.min.js +13 -0
- package/node_modules/jszip/graph.svg +601 -0
- package/node_modules/jszip/index.d.ts +330 -0
- package/node_modules/jszip/lib/base64.js +106 -0
- package/node_modules/jszip/lib/compressedObject.js +74 -0
- package/node_modules/jszip/lib/compressions.js +14 -0
- package/node_modules/jszip/lib/crc32.js +77 -0
- package/node_modules/jszip/lib/defaults.js +11 -0
- package/node_modules/jszip/lib/external.js +18 -0
- package/node_modules/jszip/lib/flate.js +85 -0
- package/node_modules/jszip/lib/generate/ZipFileWorker.js +539 -0
- package/node_modules/jszip/lib/generate/index.js +57 -0
- package/node_modules/jszip/lib/index.js +55 -0
- package/node_modules/jszip/lib/license_header.js +11 -0
- package/node_modules/jszip/lib/load.js +88 -0
- package/node_modules/jszip/lib/nodejs/NodejsStreamInputAdapter.js +74 -0
- package/node_modules/jszip/lib/nodejs/NodejsStreamOutputAdapter.js +42 -0
- package/node_modules/jszip/lib/nodejsUtils.js +57 -0
- package/node_modules/jszip/lib/object.js +384 -0
- package/node_modules/jszip/lib/readable-stream-browser.js +10 -0
- package/node_modules/jszip/lib/reader/ArrayReader.js +57 -0
- package/node_modules/jszip/lib/reader/DataReader.js +116 -0
- package/node_modules/jszip/lib/reader/NodeBufferReader.js +19 -0
- package/node_modules/jszip/lib/reader/StringReader.js +38 -0
- package/node_modules/jszip/lib/reader/Uint8ArrayReader.js +22 -0
- package/node_modules/jszip/lib/reader/readerFor.js +28 -0
- package/node_modules/jszip/lib/signature.js +7 -0
- package/node_modules/jszip/lib/stream/ConvertWorker.js +26 -0
- package/node_modules/jszip/lib/stream/Crc32Probe.js +24 -0
- package/node_modules/jszip/lib/stream/DataLengthProbe.js +29 -0
- package/node_modules/jszip/lib/stream/DataWorker.js +116 -0
- package/node_modules/jszip/lib/stream/GenericWorker.js +263 -0
- package/node_modules/jszip/lib/stream/StreamHelper.js +214 -0
- package/node_modules/jszip/lib/support.js +38 -0
- package/node_modules/jszip/lib/utf8.js +275 -0
- package/node_modules/jszip/lib/utils.js +501 -0
- package/node_modules/jszip/lib/zipEntries.js +261 -0
- package/node_modules/jszip/lib/zipEntry.js +293 -0
- package/node_modules/jszip/lib/zipObject.js +133 -0
- package/node_modules/jszip/package.json +67 -0
- package/node_modules/jszip/sponsors.md +21 -0
- package/node_modules/jszip/tsconfig.json +101 -0
- package/node_modules/jszip/vendor/FileSaver.js +247 -0
- package/node_modules/lie/README.md +62 -0
- package/node_modules/lie/dist/lie.js +350 -0
- package/node_modules/lie/dist/lie.min.js +1 -0
- package/node_modules/lie/dist/lie.polyfill.js +358 -0
- package/node_modules/lie/dist/lie.polyfill.min.js +1 -0
- package/node_modules/lie/lib/browser.js +273 -0
- package/node_modules/lie/lib/index.js +298 -0
- package/node_modules/lie/license.md +7 -0
- package/node_modules/lie/lie.d.ts +244 -0
- package/node_modules/lie/package.json +69 -0
- package/node_modules/lie/polyfill.js +4 -0
- package/node_modules/pako/CHANGELOG.md +164 -0
- package/node_modules/pako/LICENSE +21 -0
- package/node_modules/pako/README.md +191 -0
- package/node_modules/pako/dist/pako.js +6818 -0
- package/node_modules/pako/dist/pako.min.js +1 -0
- package/node_modules/pako/dist/pako_deflate.js +3997 -0
- package/node_modules/pako/dist/pako_deflate.min.js +1 -0
- package/node_modules/pako/dist/pako_inflate.js +3300 -0
- package/node_modules/pako/dist/pako_inflate.min.js +1 -0
- package/node_modules/pako/index.js +14 -0
- package/node_modules/pako/lib/deflate.js +400 -0
- package/node_modules/pako/lib/inflate.js +423 -0
- package/node_modules/pako/lib/utils/common.js +105 -0
- package/node_modules/pako/lib/utils/strings.js +187 -0
- package/node_modules/pako/lib/zlib/README +59 -0
- package/node_modules/pako/lib/zlib/adler32.js +51 -0
- package/node_modules/pako/lib/zlib/constants.js +68 -0
- package/node_modules/pako/lib/zlib/crc32.js +59 -0
- package/node_modules/pako/lib/zlib/deflate.js +1874 -0
- package/node_modules/pako/lib/zlib/gzheader.js +58 -0
- package/node_modules/pako/lib/zlib/inffast.js +345 -0
- package/node_modules/pako/lib/zlib/inflate.js +1556 -0
- package/node_modules/pako/lib/zlib/inftrees.js +343 -0
- package/node_modules/pako/lib/zlib/messages.js +32 -0
- package/node_modules/pako/lib/zlib/trees.js +1222 -0
- package/node_modules/pako/lib/zlib/zstream.js +47 -0
- package/node_modules/pako/package.json +44 -0
- package/node_modules/process-nextick-args/index.js +45 -0
- package/node_modules/process-nextick-args/license.md +19 -0
- package/node_modules/process-nextick-args/package.json +25 -0
- package/node_modules/process-nextick-args/readme.md +18 -0
- package/node_modules/readable-stream/.travis.yml +34 -0
- package/node_modules/readable-stream/CONTRIBUTING.md +38 -0
- package/node_modules/readable-stream/GOVERNANCE.md +136 -0
- package/node_modules/readable-stream/LICENSE +47 -0
- package/node_modules/readable-stream/README.md +58 -0
- package/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md +60 -0
- package/node_modules/readable-stream/duplex-browser.js +1 -0
- package/node_modules/readable-stream/duplex.js +1 -0
- package/node_modules/readable-stream/lib/_stream_duplex.js +131 -0
- package/node_modules/readable-stream/lib/_stream_passthrough.js +47 -0
- package/node_modules/readable-stream/lib/_stream_readable.js +1019 -0
- package/node_modules/readable-stream/lib/_stream_transform.js +214 -0
- package/node_modules/readable-stream/lib/_stream_writable.js +685 -0
- package/node_modules/readable-stream/lib/internal/streams/BufferList.js +78 -0
- package/node_modules/readable-stream/lib/internal/streams/destroy.js +84 -0
- package/node_modules/readable-stream/lib/internal/streams/stream-browser.js +1 -0
- package/node_modules/readable-stream/lib/internal/streams/stream.js +1 -0
- package/node_modules/readable-stream/package.json +52 -0
- package/node_modules/readable-stream/passthrough.js +1 -0
- package/node_modules/readable-stream/readable-browser.js +7 -0
- package/node_modules/readable-stream/readable.js +19 -0
- package/node_modules/readable-stream/transform.js +1 -0
- package/node_modules/readable-stream/writable-browser.js +1 -0
- package/node_modules/readable-stream/writable.js +8 -0
- package/node_modules/safe-buffer/LICENSE +21 -0
- package/node_modules/safe-buffer/README.md +584 -0
- package/node_modules/safe-buffer/index.d.ts +187 -0
- package/node_modules/safe-buffer/index.js +62 -0
- package/node_modules/safe-buffer/package.json +37 -0
- package/node_modules/setimmediate/LICENSE.txt +20 -0
- package/node_modules/setimmediate/package.json +30 -0
- package/node_modules/setimmediate/setImmediate.js +186 -0
- package/node_modules/string_decoder/.travis.yml +50 -0
- package/node_modules/string_decoder/LICENSE +48 -0
- package/node_modules/string_decoder/README.md +47 -0
- package/node_modules/string_decoder/lib/string_decoder.js +296 -0
- package/node_modules/string_decoder/package.json +31 -0
- package/node_modules/util-deprecate/History.md +16 -0
- package/node_modules/util-deprecate/LICENSE +24 -0
- package/node_modules/util-deprecate/README.md +53 -0
- package/node_modules/util-deprecate/browser.js +67 -0
- package/node_modules/util-deprecate/node.js +6 -0
- package/node_modules/util-deprecate/package.json +27 -0
- package/package.json +6 -4
- /package/node_modules/{p-limit/node_modules/yocto-queue → yocto-queue}/index.d.ts +0 -0
- /package/node_modules/{p-limit/node_modules/yocto-queue → yocto-queue}/index.js +0 -0
- /package/node_modules/{p-limit/node_modules/yocto-queue → yocto-queue}/license +0 -0
- /package/node_modules/{p-limit/node_modules/yocto-queue → yocto-queue}/package.json +0 -0
- /package/node_modules/{p-limit/node_modules/yocto-queue → yocto-queue}/readme.md +0 -0
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
import syncFs from "node:fs";
|
|
2
|
+
import fs from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { normalizeMaxBytes } from "./byte-budget.js";
|
|
5
|
+
import { readFileDescriptorBoundedSync } from "./bounded-read.js";
|
|
6
|
+
import { FsSafeError } from "./errors.js";
|
|
7
|
+
import { assertFileStoreMaxBytes } from "./file-store-limit.js";
|
|
8
|
+
import { pruneExpiredStoreEntries } from "./file-store-prune.js";
|
|
9
|
+
import { ensureParentInRoot, openPrivateStoreLockRoot, openWritableStoreRoot, writeStreamToTempSource, } from "./file-store-boundary.js";
|
|
10
|
+
import { writeFileSyncAtomic } from "./file-store-sync-write.js";
|
|
11
|
+
import { createJsonStore } from "./json-document-store.js";
|
|
12
|
+
import { stringifyJsonDocument } from "./json-stringify.js";
|
|
13
|
+
import { isNotFoundPathError, resolveSafeRelativePath, splitSafeRelativePath } from "./path.js";
|
|
14
|
+
import { throwFsSafeReadError } from "./root-errors.js";
|
|
15
|
+
import { root } from "./root.js";
|
|
16
|
+
import { DEFAULT_ROOT_MAX_BYTES } from "./root-impl.js";
|
|
17
|
+
import { readRegularFile } from "./regular-file.js";
|
|
18
|
+
import { matchRootFileOpenFailure, openRootFileSync } from "./root-file.js";
|
|
19
|
+
import { writeSecretFileAtomic } from "./secret-file.js";
|
|
20
|
+
function assertRelativePath(relativePath) {
|
|
21
|
+
const raw = relativePath.trim();
|
|
22
|
+
if (!raw || raw !== relativePath) {
|
|
23
|
+
throw new FsSafeError("invalid-path", "store key must be non-empty and unpadded");
|
|
24
|
+
}
|
|
25
|
+
const segments = splitSafeRelativePath(raw);
|
|
26
|
+
if (segments.length === 0 ||
|
|
27
|
+
segments.join("/") !== raw ||
|
|
28
|
+
raw.normalize("NFC") !== raw ||
|
|
29
|
+
segments.some((segment) => /[ .]$/u.test(segment))) {
|
|
30
|
+
throw new FsSafeError("invalid-path", "store key must use one canonical relative spelling");
|
|
31
|
+
}
|
|
32
|
+
return raw;
|
|
33
|
+
}
|
|
34
|
+
function resolveStorePath(rootDir, relativePath) {
|
|
35
|
+
return resolveSafeRelativePath(rootDir, assertRelativePath(relativePath));
|
|
36
|
+
}
|
|
37
|
+
function isNotFound(error) {
|
|
38
|
+
return error instanceof FsSafeError ? error.code === "not-found" : isNotFoundPathError(error);
|
|
39
|
+
}
|
|
40
|
+
function handleSyncStoreReadOpenFailure(opened) {
|
|
41
|
+
return matchRootFileOpenFailure(opened, {
|
|
42
|
+
path: (failure) => {
|
|
43
|
+
if (isNotFound(failure.error)) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
throw new FsSafeError("path-mismatch", "store target changed during read", {
|
|
47
|
+
cause: failure.error instanceof Error ? failure.error : undefined,
|
|
48
|
+
});
|
|
49
|
+
},
|
|
50
|
+
validation: (failure) => {
|
|
51
|
+
if (failure.error instanceof FsSafeError) {
|
|
52
|
+
throw failure.error;
|
|
53
|
+
}
|
|
54
|
+
// Validation failures mean the path existed but violated store policy
|
|
55
|
+
// (directory, hardlink, symlink race). Do not report them as missing.
|
|
56
|
+
throw new FsSafeError("path-mismatch", "store target failed read validation", {
|
|
57
|
+
cause: failure.error instanceof Error ? failure.error : undefined,
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
io: (failure) => throwFsSafeReadError(failure.error, "store"),
|
|
61
|
+
fallback: (failure) => {
|
|
62
|
+
throw new FsSafeError("path-mismatch", "store target changed during read", {
|
|
63
|
+
cause: failure.error instanceof Error ? failure.error : undefined,
|
|
64
|
+
});
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
async function readFileStoreCopySource(params) {
|
|
69
|
+
const sourceStat = syncFs.lstatSync(params.sourcePath);
|
|
70
|
+
if (sourceStat.isSymbolicLink() || !sourceStat.isFile()) {
|
|
71
|
+
throw new FsSafeError("not-file", "source path is not a file");
|
|
72
|
+
}
|
|
73
|
+
assertFileStoreMaxBytes(sourceStat.size, params.maxBytes);
|
|
74
|
+
try {
|
|
75
|
+
return (await readRegularFile({ filePath: params.sourcePath, maxBytes: params.maxBytes }))
|
|
76
|
+
.buffer;
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
80
|
+
if (message.includes("regular file") || message.includes("not a regular file")) {
|
|
81
|
+
throw new FsSafeError("not-file", "source path is not a file", {
|
|
82
|
+
cause: error instanceof Error ? error : undefined,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
if (params.maxBytes !== undefined && message.includes(`exceeds ${params.maxBytes} bytes`)) {
|
|
86
|
+
throw new FsSafeError("too-large", `file exceeds maximum size of ${params.maxBytes} bytes`, {
|
|
87
|
+
cause: error instanceof Error ? error : undefined,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
throw error;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
async function copyIntoRoot(params) {
|
|
94
|
+
const relativePath = assertRelativePath(params.relativePath);
|
|
95
|
+
const destination = resolveStorePath(params.rootDir, relativePath);
|
|
96
|
+
const sourceStat = syncFs.lstatSync(params.sourcePath);
|
|
97
|
+
if (sourceStat.isSymbolicLink() || !sourceStat.isFile()) {
|
|
98
|
+
throw new FsSafeError("not-file", "source path is not a file");
|
|
99
|
+
}
|
|
100
|
+
assertFileStoreMaxBytes(sourceStat.size, params.maxBytes);
|
|
101
|
+
const dirMode = params.dirMode ?? 0o700;
|
|
102
|
+
const scopedRoot = await openWritableStoreRoot({
|
|
103
|
+
rootDir: params.rootDir,
|
|
104
|
+
dirMode,
|
|
105
|
+
maxBytes: params.maxBytes,
|
|
106
|
+
});
|
|
107
|
+
await ensureParentInRoot(scopedRoot, relativePath, dirMode);
|
|
108
|
+
await scopedRoot.copyIn(relativePath, params.sourcePath, {
|
|
109
|
+
maxBytes: params.maxBytes,
|
|
110
|
+
mkdir: false,
|
|
111
|
+
mode: params.mode ?? 0o600,
|
|
112
|
+
});
|
|
113
|
+
return destination;
|
|
114
|
+
}
|
|
115
|
+
export function fileStore(options) {
|
|
116
|
+
const rootDir = path.resolve(options.rootDir);
|
|
117
|
+
const privateMode = options.private ?? false;
|
|
118
|
+
const dirMode = options.dirMode ?? 0o700;
|
|
119
|
+
const mode = options.mode ?? 0o600;
|
|
120
|
+
const maxBytes = normalizeMaxBytes(options.maxBytes);
|
|
121
|
+
async function openRoot() {
|
|
122
|
+
return await root(rootDir, { hardlinks: "reject", maxBytes });
|
|
123
|
+
}
|
|
124
|
+
async function write(relativePath, data, writeOptions) {
|
|
125
|
+
const safeRelativePath = assertRelativePath(relativePath);
|
|
126
|
+
const destination = resolveStorePath(rootDir, safeRelativePath);
|
|
127
|
+
const content = Buffer.isBuffer(data) ? data : Buffer.from(data);
|
|
128
|
+
const writeMaxBytes = normalizeMaxBytes(writeOptions?.maxBytes, { defaultValue: maxBytes });
|
|
129
|
+
assertFileStoreMaxBytes(content.byteLength, writeMaxBytes);
|
|
130
|
+
if (privateMode) {
|
|
131
|
+
await writeSecretFileAtomic({
|
|
132
|
+
rootDir,
|
|
133
|
+
filePath: destination,
|
|
134
|
+
content,
|
|
135
|
+
dirMode: writeOptions?.dirMode ?? dirMode,
|
|
136
|
+
mode: writeOptions?.mode ?? mode,
|
|
137
|
+
});
|
|
138
|
+
return destination;
|
|
139
|
+
}
|
|
140
|
+
const writeDirMode = writeOptions?.dirMode ?? dirMode;
|
|
141
|
+
const scopedRoot = await openWritableStoreRoot({
|
|
142
|
+
rootDir,
|
|
143
|
+
dirMode: writeDirMode,
|
|
144
|
+
maxBytes: writeMaxBytes,
|
|
145
|
+
});
|
|
146
|
+
await ensureParentInRoot(scopedRoot, safeRelativePath, writeDirMode);
|
|
147
|
+
await scopedRoot.write(safeRelativePath, content, {
|
|
148
|
+
mkdir: false,
|
|
149
|
+
mode: writeOptions?.mode ?? mode,
|
|
150
|
+
});
|
|
151
|
+
return destination;
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
rootDir,
|
|
155
|
+
path: (relativePath) => resolveStorePath(rootDir, relativePath),
|
|
156
|
+
root: openRoot,
|
|
157
|
+
write,
|
|
158
|
+
writeStream: async (relativePath, stream, writeOptions) => {
|
|
159
|
+
const safeRelativePath = assertRelativePath(relativePath);
|
|
160
|
+
const destination = resolveStorePath(rootDir, safeRelativePath);
|
|
161
|
+
const configuredLimit = normalizeMaxBytes(writeOptions?.maxBytes, { defaultValue: maxBytes });
|
|
162
|
+
const limit = configuredLimit ?? (privateMode ? DEFAULT_ROOT_MAX_BYTES : undefined);
|
|
163
|
+
if (privateMode) {
|
|
164
|
+
const chunks = [];
|
|
165
|
+
let total = 0;
|
|
166
|
+
for await (const chunk of stream) {
|
|
167
|
+
const buffer = typeof chunk === "string" ? Buffer.from(chunk) : Buffer.from(chunk);
|
|
168
|
+
total += buffer.byteLength;
|
|
169
|
+
assertFileStoreMaxBytes(total, limit);
|
|
170
|
+
chunks.push(buffer);
|
|
171
|
+
}
|
|
172
|
+
await writeSecretFileAtomic({
|
|
173
|
+
rootDir,
|
|
174
|
+
filePath: destination,
|
|
175
|
+
content: Buffer.concat(chunks),
|
|
176
|
+
dirMode: writeOptions?.dirMode ?? dirMode,
|
|
177
|
+
mode: writeOptions?.mode ?? mode,
|
|
178
|
+
});
|
|
179
|
+
return destination;
|
|
180
|
+
}
|
|
181
|
+
const staged = await writeStreamToTempSource({
|
|
182
|
+
stream,
|
|
183
|
+
maxBytes: limit,
|
|
184
|
+
mode: writeOptions?.mode ?? mode,
|
|
185
|
+
});
|
|
186
|
+
try {
|
|
187
|
+
await copyIntoRoot({
|
|
188
|
+
rootDir,
|
|
189
|
+
relativePath: safeRelativePath,
|
|
190
|
+
sourcePath: staged.path,
|
|
191
|
+
maxBytes: limit,
|
|
192
|
+
mode: writeOptions?.mode ?? mode,
|
|
193
|
+
tempPrefix: writeOptions?.tempPrefix,
|
|
194
|
+
dirMode: writeOptions?.dirMode ?? dirMode,
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
finally {
|
|
198
|
+
await staged.cleanup();
|
|
199
|
+
}
|
|
200
|
+
return destination;
|
|
201
|
+
},
|
|
202
|
+
copyIn: async (relativePath, sourcePath, writeOptions) => {
|
|
203
|
+
const configuredLimit = normalizeMaxBytes(writeOptions?.maxBytes, { defaultValue: maxBytes });
|
|
204
|
+
if (privateMode) {
|
|
205
|
+
const buffer = await readFileStoreCopySource({
|
|
206
|
+
sourcePath,
|
|
207
|
+
maxBytes: configuredLimit ?? DEFAULT_ROOT_MAX_BYTES,
|
|
208
|
+
});
|
|
209
|
+
return await write(relativePath, buffer, writeOptions);
|
|
210
|
+
}
|
|
211
|
+
return await copyIntoRoot({
|
|
212
|
+
rootDir,
|
|
213
|
+
relativePath,
|
|
214
|
+
sourcePath,
|
|
215
|
+
dirMode: writeOptions?.dirMode ?? dirMode,
|
|
216
|
+
maxBytes: configuredLimit,
|
|
217
|
+
mode: writeOptions?.mode ?? mode,
|
|
218
|
+
tempPrefix: writeOptions?.tempPrefix,
|
|
219
|
+
});
|
|
220
|
+
},
|
|
221
|
+
open: async (relativePath, readOptions) => await (await openRoot()).open(assertRelativePath(relativePath), readOptions),
|
|
222
|
+
read: async (relativePath, readOptions) => await (await openRoot()).read(assertRelativePath(relativePath), readOptions),
|
|
223
|
+
readBytes: async (relativePath, readOptions) => await (await openRoot()).readBytes(assertRelativePath(relativePath), readOptions),
|
|
224
|
+
readText: async (relativePath, readOptions) => {
|
|
225
|
+
const { encoding = "utf8", ...options } = readOptions ?? {};
|
|
226
|
+
return (await (await openRoot()).read(assertRelativePath(relativePath), options)).buffer
|
|
227
|
+
.toString(encoding);
|
|
228
|
+
},
|
|
229
|
+
readTextIfExists: async (relativePath, readOptions) => {
|
|
230
|
+
try {
|
|
231
|
+
return await (await openRoot()).readText(assertRelativePath(relativePath), readOptions);
|
|
232
|
+
}
|
|
233
|
+
catch (error) {
|
|
234
|
+
if (isNotFound(error)) {
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
throwFsSafeReadError(error, "store");
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
readJson: async (relativePath, readOptions) => {
|
|
241
|
+
const { encoding = "utf8", ...options } = readOptions ?? {};
|
|
242
|
+
return JSON.parse((await (await openRoot()).read(assertRelativePath(relativePath), options)).buffer
|
|
243
|
+
.toString(encoding));
|
|
244
|
+
},
|
|
245
|
+
readJsonIfExists: async (relativePath, readOptions) => {
|
|
246
|
+
try {
|
|
247
|
+
return await (await openRoot()).readJson(assertRelativePath(relativePath), readOptions);
|
|
248
|
+
}
|
|
249
|
+
catch (error) {
|
|
250
|
+
if (isNotFound(error)) {
|
|
251
|
+
return null;
|
|
252
|
+
}
|
|
253
|
+
throwFsSafeReadError(error, "store");
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
remove: async (relativePath) => {
|
|
257
|
+
await (await openRoot()).remove(assertRelativePath(relativePath));
|
|
258
|
+
},
|
|
259
|
+
exists: async (relativePath) => await (await openRoot()).exists(assertRelativePath(relativePath)),
|
|
260
|
+
writeText: async (relativePath, data, writeOptions) => await write(relativePath, data, writeOptions),
|
|
261
|
+
writeJson: async (relativePath, data, writeOptions) => {
|
|
262
|
+
const json = stringifyJsonDocument(data, null, 2);
|
|
263
|
+
return await write(relativePath, writeOptions?.trailingNewline === false ? json : `${json}\n`, writeOptions);
|
|
264
|
+
},
|
|
265
|
+
json: (relativePath, jsonOptions) => {
|
|
266
|
+
const filePath = resolveStorePath(rootDir, relativePath);
|
|
267
|
+
return createJsonStore({
|
|
268
|
+
filePath,
|
|
269
|
+
...(privateMode ? {
|
|
270
|
+
prepareLock: () => openPrivateStoreLockRoot({ rootDir, filePath, mode, dirMode }),
|
|
271
|
+
} : {}),
|
|
272
|
+
readIfExists: async () => {
|
|
273
|
+
try {
|
|
274
|
+
return await (await openRoot()).readJson(assertRelativePath(relativePath));
|
|
275
|
+
}
|
|
276
|
+
catch (error) {
|
|
277
|
+
if (isNotFound(error)) {
|
|
278
|
+
return undefined;
|
|
279
|
+
}
|
|
280
|
+
throw error;
|
|
281
|
+
}
|
|
282
|
+
},
|
|
283
|
+
readRequired: async () => await (await openRoot()).readJson(assertRelativePath(relativePath)),
|
|
284
|
+
write: async (value, options) => {
|
|
285
|
+
const json = stringifyJsonDocument(value, null, 2);
|
|
286
|
+
await write(relativePath, options?.trailingNewline === false ? json : `${json}\n`);
|
|
287
|
+
},
|
|
288
|
+
}, jsonOptions);
|
|
289
|
+
},
|
|
290
|
+
pruneExpired: async (pruneOptions) => {
|
|
291
|
+
await pruneExpiredStoreEntries({ rootDir, dirMode, options: pruneOptions });
|
|
292
|
+
},
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
export function fileStoreSync(options) {
|
|
296
|
+
const rootDir = path.resolve(options.rootDir);
|
|
297
|
+
const privateMode = options.private ?? false;
|
|
298
|
+
const dirMode = options.dirMode ?? 0o700;
|
|
299
|
+
const mode = options.mode ?? 0o600;
|
|
300
|
+
const maxBytes = normalizeMaxBytes(options.maxBytes);
|
|
301
|
+
function write(relativePath, data, writeOptions) {
|
|
302
|
+
const destination = resolveStorePath(rootDir, relativePath);
|
|
303
|
+
const content = Buffer.isBuffer(data) ? data : Buffer.from(data);
|
|
304
|
+
const writeMaxBytes = normalizeMaxBytes(writeOptions?.maxBytes, { defaultValue: maxBytes });
|
|
305
|
+
assertFileStoreMaxBytes(content.byteLength, writeMaxBytes);
|
|
306
|
+
return writeFileSyncAtomic({
|
|
307
|
+
rootDir,
|
|
308
|
+
filePath: destination,
|
|
309
|
+
content,
|
|
310
|
+
privateMode,
|
|
311
|
+
dirMode: writeOptions?.dirMode ?? dirMode,
|
|
312
|
+
mode: writeOptions?.mode ?? mode,
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
return {
|
|
316
|
+
rootDir,
|
|
317
|
+
path: (relativePath) => resolveStorePath(rootDir, relativePath),
|
|
318
|
+
readTextIfExists: (relativePath, readOptions) => {
|
|
319
|
+
const limit = normalizeMaxBytes(readOptions?.maxBytes, { defaultValue: maxBytes });
|
|
320
|
+
const targetPath = resolveStorePath(rootDir, relativePath);
|
|
321
|
+
const opened = openRootFileSync({
|
|
322
|
+
absolutePath: targetPath,
|
|
323
|
+
rootPath: rootDir,
|
|
324
|
+
boundaryLabel: "store root",
|
|
325
|
+
rejectHardlinks: true,
|
|
326
|
+
});
|
|
327
|
+
if (!opened.ok) {
|
|
328
|
+
return handleSyncStoreReadOpenFailure(opened);
|
|
329
|
+
}
|
|
330
|
+
try {
|
|
331
|
+
assertFileStoreMaxBytes(opened.stat.size, limit);
|
|
332
|
+
try {
|
|
333
|
+
return limit === undefined
|
|
334
|
+
? syncFs.readFileSync(opened.fd, "utf8")
|
|
335
|
+
: readFileDescriptorBoundedSync(opened.fd, limit).toString("utf8");
|
|
336
|
+
}
|
|
337
|
+
catch (error) {
|
|
338
|
+
throwFsSafeReadError(error, "store");
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
finally {
|
|
342
|
+
syncFs.closeSync(opened.fd);
|
|
343
|
+
}
|
|
344
|
+
},
|
|
345
|
+
readJsonIfExists: (relativePath, readOptions) => {
|
|
346
|
+
const raw = fileStoreSync({ rootDir, private: privateMode, dirMode, mode, maxBytes })
|
|
347
|
+
.readTextIfExists(relativePath, readOptions);
|
|
348
|
+
return raw === null ? null : JSON.parse(raw);
|
|
349
|
+
},
|
|
350
|
+
write,
|
|
351
|
+
writeText: (relativePath, data, writeOptions) => write(relativePath, data, writeOptions),
|
|
352
|
+
writeJson: (relativePath, data, writeOptions) => {
|
|
353
|
+
const json = stringifyJsonDocument(data, null, 2);
|
|
354
|
+
return write(relativePath, writeOptions?.trailingNewline === false ? json : `${json}\n`, writeOptions);
|
|
355
|
+
},
|
|
356
|
+
};
|
|
357
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import type { FileHandle } from "node:fs/promises";
|
|
3
|
+
export declare function syncFileBestEffort(handle: Pick<FileHandle, "sync">): Promise<void>;
|
|
4
|
+
export declare function syncFileBestEffortSync(fd: number, fsModule?: Pick<typeof fs, "fsyncSync">): void;
|
|
5
|
+
//# sourceMappingURL=file-sync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-sync.d.ts","sourceRoot":"","sources":["../src/file-sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAMxF;AAED,wBAAgB,sBAAsB,CACpC,EAAE,EAAE,MAAM,EACV,QAAQ,GAAE,IAAI,CAAC,OAAO,EAAE,EAAE,WAAW,CAAM,GAC1C,IAAI,CAMN"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
export async function syncFileBestEffort(handle) {
|
|
3
|
+
try {
|
|
4
|
+
await handle.sync();
|
|
5
|
+
}
|
|
6
|
+
catch (error) {
|
|
7
|
+
if (error?.code !== "EPERM")
|
|
8
|
+
throw error;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export function syncFileBestEffortSync(fd, fsModule = fs) {
|
|
12
|
+
try {
|
|
13
|
+
fsModule.fsyncSync(fd);
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
if (error?.code !== "EPERM")
|
|
17
|
+
throw error;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Keeps short names exact and trims only the filename tail of a composite temp name. */
|
|
2
|
+
export declare function fitFileNameToPortableComponent(params: {
|
|
3
|
+
prefix: string;
|
|
4
|
+
fileName: string;
|
|
5
|
+
suffix: string;
|
|
6
|
+
}): string;
|
|
7
|
+
export declare function sanitizeUntrustedFileName(fileName: string, fallbackName: string): string;
|
|
8
|
+
//# sourceMappingURL=filename.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filename.d.ts","sourceRoot":"","sources":["../src/filename.ts"],"names":[],"mappings":"AAqCA,yFAAyF;AACzF,wBAAgB,8BAA8B,CAAC,MAAM,EAAE;IACrD,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,MAAM,CA8BT;AAED,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAgCxF"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { WINDOWS_RESERVED_DEVICE_NAMES } from "./device-path.js";
|
|
3
|
+
const WINDOWS_INVALID_FILE_NAME_CHARACTERS = new Set('<>:"/\\|?*');
|
|
4
|
+
function trimWindowsIgnoredSuffix(value) {
|
|
5
|
+
let end = value.length;
|
|
6
|
+
while (end > 0) {
|
|
7
|
+
const character = value.charCodeAt(end - 1);
|
|
8
|
+
if (character !== 0x20 && character !== 0x2e) {
|
|
9
|
+
break;
|
|
10
|
+
}
|
|
11
|
+
end -= 1;
|
|
12
|
+
}
|
|
13
|
+
return end === value.length ? value : value.slice(0, end);
|
|
14
|
+
}
|
|
15
|
+
function suffixWindowsReservedDeviceName(fileName) {
|
|
16
|
+
const extensionIndex = fileName.indexOf(".");
|
|
17
|
+
const baseNameEnd = extensionIndex < 0 ? fileName.length : extensionIndex;
|
|
18
|
+
const baseName = fileName.slice(0, baseNameEnd);
|
|
19
|
+
const deviceBaseName = trimWindowsIgnoredSuffix(baseName);
|
|
20
|
+
if (!WINDOWS_RESERVED_DEVICE_NAMES.has(deviceBaseName.toUpperCase())) {
|
|
21
|
+
return fileName;
|
|
22
|
+
}
|
|
23
|
+
return `${baseName}_${fileName.slice(baseNameEnd)}`;
|
|
24
|
+
}
|
|
25
|
+
const PORTABLE_FILE_NAME_BYTES = 255;
|
|
26
|
+
function normalizedFileNameBytes(value) {
|
|
27
|
+
return Math.max(Buffer.byteLength(value.normalize("NFC"), "utf8"), Buffer.byteLength(value.normalize("NFD"), "utf8"));
|
|
28
|
+
}
|
|
29
|
+
/** Keeps short names exact and trims only the filename tail of a composite temp name. */
|
|
30
|
+
export function fitFileNameToPortableComponent(params) {
|
|
31
|
+
const complete = `${params.prefix}${params.fileName}${params.suffix}`;
|
|
32
|
+
if (normalizedFileNameBytes(complete) <= PORTABLE_FILE_NAME_BYTES) {
|
|
33
|
+
return params.fileName;
|
|
34
|
+
}
|
|
35
|
+
if (normalizedFileNameBytes(`${params.prefix}${params.suffix}`) > PORTABLE_FILE_NAME_BYTES) {
|
|
36
|
+
// Preserve the existing OS error for a caller-supplied prefix that cannot fit.
|
|
37
|
+
return params.fileName;
|
|
38
|
+
}
|
|
39
|
+
const extension = path.extname(params.fileName);
|
|
40
|
+
const preserveExtension = normalizedFileNameBytes(`${params.prefix}${extension}${params.suffix}`) <=
|
|
41
|
+
PORTABLE_FILE_NAME_BYTES;
|
|
42
|
+
const tailSuffix = preserveExtension ? extension : "";
|
|
43
|
+
const stem = preserveExtension
|
|
44
|
+
? params.fileName.slice(0, params.fileName.length - extension.length)
|
|
45
|
+
: params.fileName;
|
|
46
|
+
const codePoints = Array.from(stem);
|
|
47
|
+
let low = 0;
|
|
48
|
+
let high = codePoints.length;
|
|
49
|
+
while (low < high) {
|
|
50
|
+
const length = Math.ceil((low + high) / 2);
|
|
51
|
+
const candidate = `${params.prefix}${codePoints.slice(0, length).join("")}${tailSuffix}${params.suffix}`;
|
|
52
|
+
if (normalizedFileNameBytes(candidate) <= PORTABLE_FILE_NAME_BYTES) {
|
|
53
|
+
low = length;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
high = length - 1;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return `${codePoints.slice(0, low).join("")}${tailSuffix}`;
|
|
60
|
+
}
|
|
61
|
+
export function sanitizeUntrustedFileName(fileName, fallbackName) {
|
|
62
|
+
const trimmed = typeof fileName === "string" ? fileName.trim() : "";
|
|
63
|
+
if (!trimmed) {
|
|
64
|
+
return fallbackName;
|
|
65
|
+
}
|
|
66
|
+
let base = path.posix.basename(trimmed);
|
|
67
|
+
base = path.win32.basename(base);
|
|
68
|
+
let cleaned = "";
|
|
69
|
+
for (let i = 0; i < base.length; i++) {
|
|
70
|
+
const code = base.charCodeAt(i);
|
|
71
|
+
if (code < 0x20 ||
|
|
72
|
+
(code >= 0x7f && code <= 0x9f) ||
|
|
73
|
+
WINDOWS_INVALID_FILE_NAME_CHARACTERS.has(base[i])) {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
cleaned += base[i];
|
|
77
|
+
}
|
|
78
|
+
base = cleaned.trim();
|
|
79
|
+
if (!base || base === "." || base === "..") {
|
|
80
|
+
return fallbackName;
|
|
81
|
+
}
|
|
82
|
+
base = suffixWindowsReservedDeviceName(base);
|
|
83
|
+
if (base.length > 200) {
|
|
84
|
+
base = base.slice(0, 200);
|
|
85
|
+
const trailingCodeUnit = base.charCodeAt(base.length - 1);
|
|
86
|
+
if (trailingCodeUnit >= 0xd800 && trailingCodeUnit <= 0xdbff) {
|
|
87
|
+
base = base.slice(0, -1);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return base;
|
|
91
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns true when `fs.stat()` can stat the path.
|
|
3
|
+
*
|
|
4
|
+
* This follows stat semantics: broken symlinks return false, while symlinks to
|
|
5
|
+
* existing targets return true.
|
|
6
|
+
*/
|
|
7
|
+
export declare function pathExists(filePath: string): Promise<boolean>;
|
|
8
|
+
/**
|
|
9
|
+
* Synchronous counterpart to `pathExists()`, with the same `fs.statSync()`
|
|
10
|
+
* semantics.
|
|
11
|
+
*/
|
|
12
|
+
export declare function pathExistsSync(filePath: string): boolean;
|
|
13
|
+
//# sourceMappingURL=fs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../src/fs.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAOnE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAOxD"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import fsp from "node:fs/promises";
|
|
3
|
+
/**
|
|
4
|
+
* Returns true when `fs.stat()` can stat the path.
|
|
5
|
+
*
|
|
6
|
+
* This follows stat semantics: broken symlinks return false, while symlinks to
|
|
7
|
+
* existing targets return true.
|
|
8
|
+
*/
|
|
9
|
+
export async function pathExists(filePath) {
|
|
10
|
+
try {
|
|
11
|
+
await fsp.stat(filePath);
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Synchronous counterpart to `pathExists()`, with the same `fs.statSync()`
|
|
20
|
+
* semantics.
|
|
21
|
+
*/
|
|
22
|
+
export function pathExistsSync(filePath) {
|
|
23
|
+
try {
|
|
24
|
+
fs.statSync(filePath);
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates each missing path component from `rootReal` down to `targetPath`,
|
|
3
|
+
* guarding every step. Returns the real (symlink-resolved) path of the final
|
|
4
|
+
* component so callers can guard/use that path directly instead of
|
|
5
|
+
* re-deriving it from the original, possibly-symlinked, lexical path.
|
|
6
|
+
*/
|
|
7
|
+
export declare function mkdirPathComponentsWithGuards(params: {
|
|
8
|
+
rootReal: string;
|
|
9
|
+
targetPath: string;
|
|
10
|
+
beforeComponent?: (componentPath: string) => Promise<void> | void;
|
|
11
|
+
mode?: number;
|
|
12
|
+
rejectSymlinks?: boolean;
|
|
13
|
+
}): Promise<string>;
|
|
14
|
+
//# sourceMappingURL=guarded-mkdir.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guarded-mkdir.d.ts","sourceRoot":"","sources":["../src/guarded-mkdir.ts"],"names":[],"mappings":"AA0BA;;;;;GAKG;AACH,wBAAsB,6BAA6B,CAAC,MAAM,EAAE;IAC1D,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAClE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,GAAG,OAAO,CAAC,MAAM,CAAC,CAuDlB"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import fsSync from "node:fs";
|
|
2
|
+
import fs from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { assertAsyncDirectoryGuard, createAsyncDirectoryGuard } from "./directory-guard.js";
|
|
5
|
+
import { FsSafeError } from "./errors.js";
|
|
6
|
+
import { isNotFoundPathError, isPathRelativeEscape } from "./path.js";
|
|
7
|
+
import { directoryComponentNotDirectoryError } from "./root-errors.js";
|
|
8
|
+
function isSameOrChildPath(candidate, parent) {
|
|
9
|
+
const parentPrefix = parent.endsWith(path.sep) ? parent : `${parent}${path.sep}`;
|
|
10
|
+
return candidate === parent || candidate.startsWith(parentPrefix);
|
|
11
|
+
}
|
|
12
|
+
async function realpathOrThrowNotFile(target) {
|
|
13
|
+
try {
|
|
14
|
+
return path.resolve(fsSync.realpathSync.native(target));
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
if (isNotFoundPathError(error)) {
|
|
18
|
+
// A dangling symlink (or a component removed between lstat and
|
|
19
|
+
// realpath) is not a usable directory component.
|
|
20
|
+
throw directoryComponentNotDirectoryError(error instanceof Error ? error : undefined);
|
|
21
|
+
}
|
|
22
|
+
throw error;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Creates each missing path component from `rootReal` down to `targetPath`,
|
|
27
|
+
* guarding every step. Returns the real (symlink-resolved) path of the final
|
|
28
|
+
* component so callers can guard/use that path directly instead of
|
|
29
|
+
* re-deriving it from the original, possibly-symlinked, lexical path.
|
|
30
|
+
*/
|
|
31
|
+
export async function mkdirPathComponentsWithGuards(params) {
|
|
32
|
+
const root = path.resolve(params.rootReal);
|
|
33
|
+
const rootCanonical = path.resolve(fsSync.realpathSync.native(root));
|
|
34
|
+
const target = path.resolve(params.targetPath);
|
|
35
|
+
const relative = path.relative(root, target);
|
|
36
|
+
if (isPathRelativeEscape(relative)) {
|
|
37
|
+
throw new FsSafeError("outside-workspace", "directory is outside workspace root");
|
|
38
|
+
}
|
|
39
|
+
let current = root;
|
|
40
|
+
for (const part of relative.split(path.sep).filter(Boolean)) {
|
|
41
|
+
const next = path.join(current, part);
|
|
42
|
+
const parentGuard = await createAsyncDirectoryGuard(current);
|
|
43
|
+
await assertAsyncDirectoryGuard(parentGuard);
|
|
44
|
+
await params.beforeComponent?.(next);
|
|
45
|
+
try {
|
|
46
|
+
await fs.mkdir(next, { mode: params.mode });
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
if (!error || typeof error !== "object" || !("code" in error) || error.code !== "EEXIST") {
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const stat = fsSync.lstatSync(next);
|
|
54
|
+
if ((params.rejectSymlinks && stat.isSymbolicLink()) || (!stat.isSymbolicLink() && !stat.isDirectory())) {
|
|
55
|
+
throw directoryComponentNotDirectoryError();
|
|
56
|
+
}
|
|
57
|
+
// Node's recursive mkdir follows symlinks in missing components. Build one
|
|
58
|
+
// segment at a time and realpath-check each segment before descending.
|
|
59
|
+
const nextReal = await realpathOrThrowNotFile(next);
|
|
60
|
+
if (!isSameOrChildPath(nextReal, rootCanonical)) {
|
|
61
|
+
throw new FsSafeError("outside-workspace", "directory escaped workspace root");
|
|
62
|
+
}
|
|
63
|
+
if (stat.isSymbolicLink()) {
|
|
64
|
+
// An existing path component may legitimately be a symlink to a real
|
|
65
|
+
// directory inside the root (e.g. a skill-bank layout). We already
|
|
66
|
+
// verified above that it resolves inside the root, so treat the
|
|
67
|
+
// resolved real path as the directory for the rest of this walk
|
|
68
|
+
// instead of rejecting it outright. Guard checks from here on operate
|
|
69
|
+
// on the real (non-symlink) path, preserving TOCTOU protection for
|
|
70
|
+
// every subsequent segment. Callers that need the final directory
|
|
71
|
+
// (e.g. to guard it themselves after this function returns) must use
|
|
72
|
+
// the returned resolved path, not their own lexical parent path.
|
|
73
|
+
const targetStat = fsSync.statSync(nextReal);
|
|
74
|
+
if (!targetStat.isDirectory()) {
|
|
75
|
+
throw directoryComponentNotDirectoryError();
|
|
76
|
+
}
|
|
77
|
+
await createAsyncDirectoryGuard(nextReal);
|
|
78
|
+
await assertAsyncDirectoryGuard(parentGuard);
|
|
79
|
+
current = nextReal;
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
await createAsyncDirectoryGuard(next);
|
|
83
|
+
await assertAsyncDirectoryGuard(parentGuard);
|
|
84
|
+
current = next;
|
|
85
|
+
}
|
|
86
|
+
return current;
|
|
87
|
+
}
|