@openclaw/fs-safe 0.11.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +119 -0
- package/README.md +15 -8
- package/dist/absolute-path.d.ts.map +1 -1
- package/dist/absolute-path.js +32 -11
- package/dist/advanced.d.ts +3 -1
- package/dist/advanced.d.ts.map +1 -1
- package/dist/advanced.js +3 -1
- package/dist/archive-entry.d.ts.map +1 -1
- package/dist/archive-entry.js +4 -3
- package/dist/archive-gzip-tail.d.ts.map +1 -1
- package/dist/archive-gzip-tail.js +13 -9
- package/dist/archive-input.d.ts.map +1 -1
- package/dist/archive-input.js +6 -2
- package/dist/archive-merge.d.ts.map +1 -1
- package/dist/archive-merge.js +15 -2
- package/dist/archive-native.d.ts.map +1 -1
- package/dist/archive-native.js +7 -19
- package/dist/archive-plan.js +1 -1
- package/dist/archive-read.d.ts.map +1 -1
- package/dist/archive-read.js +55 -46
- package/dist/archive-staging.d.ts.map +1 -1
- package/dist/archive-staging.js +43 -10
- package/dist/archive-tar-inspect.d.ts.map +1 -1
- package/dist/archive-tar-inspect.js +4 -1
- package/dist/archive-zip-admission.d.ts +1 -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 +3 -0
- package/dist/archive-zip-directory.d.ts.map +1 -1
- package/dist/archive-zip-directory.js +13 -2
- package/dist/archive-zip-loader.d.ts +3 -2
- package/dist/archive-zip-loader.d.ts.map +1 -1
- package/dist/archive-zip-loader.js +30 -4
- package/dist/archive-zip-manifest.d.ts +5 -0
- package/dist/archive-zip-manifest.d.ts.map +1 -0
- package/dist/archive-zip-manifest.js +22 -0
- package/dist/archive-zip-names.d.ts +6 -1
- package/dist/archive-zip-names.d.ts.map +1 -1
- package/dist/archive-zip-names.js +50 -17
- package/dist/archive-zip-preflight.d.ts.map +1 -1
- package/dist/archive-zip-preflight.js +3 -2
- package/dist/archive.d.ts.map +1 -1
- package/dist/archive.js +9 -4
- package/dist/bounded-read.js +2 -2
- package/dist/darwin-acl.d.ts +4 -0
- package/dist/darwin-acl.d.ts.map +1 -0
- package/dist/darwin-acl.js +24 -0
- package/dist/deny-mutations.d.ts.map +1 -1
- package/dist/deny-mutations.js +8 -2
- package/dist/device-path.d.ts.map +1 -1
- package/dist/device-path.js +5 -3
- package/dist/directory-durability.d.ts.map +1 -1
- package/dist/directory-durability.js +67 -23
- package/dist/directory-entry-path.d.ts +3 -0
- package/dist/directory-entry-path.d.ts.map +1 -0
- package/dist/directory-entry-path.js +21 -0
- package/dist/directory-guard.d.ts +17 -1
- package/dist/directory-guard.d.ts.map +1 -1
- package/dist/directory-guard.js +134 -48
- package/dist/directory-mode-node.d.ts +12 -0
- package/dist/directory-mode-node.d.ts.map +1 -1
- package/dist/directory-mode-node.js +102 -4
- package/dist/effective-uid.d.ts +2 -0
- package/dist/effective-uid.d.ts.map +1 -0
- package/dist/effective-uid.js +25 -0
- package/dist/file-handle-transfer.d.ts.map +1 -1
- package/dist/file-handle-transfer.js +98 -27
- package/dist/file-hash.d.ts.map +1 -1
- package/dist/file-hash.js +12 -2
- package/dist/file-lock-sync.d.ts.map +1 -1
- package/dist/file-lock-sync.js +36 -6
- package/dist/file-lock.d.ts.map +1 -1
- package/dist/file-lock.js +29 -9
- package/dist/file-observation.d.ts +1 -1
- package/dist/file-observation.d.ts.map +1 -1
- package/dist/file-store-boundary.d.ts +6 -2
- package/dist/file-store-boundary.d.ts.map +1 -1
- package/dist/file-store-boundary.js +20 -65
- package/dist/file-store-copy-source.d.ts +5 -0
- package/dist/file-store-copy-source.d.ts.map +1 -0
- package/dist/file-store-copy-source.js +31 -0
- package/dist/file-store-path.d.ts.map +1 -1
- package/dist/file-store-path.js +4 -1
- package/dist/file-store-prune.d.ts.map +1 -1
- package/dist/file-store-prune.js +9 -1
- package/dist/file-store-sync-directory.d.ts +16 -0
- package/dist/file-store-sync-directory.d.ts.map +1 -0
- package/dist/file-store-sync-directory.js +349 -0
- package/dist/file-store.d.ts.map +1 -1
- package/dist/file-store.js +11 -28
- package/dist/filename.d.ts +1 -0
- package/dist/filename.d.ts.map +1 -1
- package/dist/filename.js +85 -23
- package/dist/fs.d.ts.map +1 -1
- package/dist/fs.js +3 -2
- package/dist/guarded-mkdir.d.ts +10 -0
- package/dist/guarded-mkdir.d.ts.map +1 -1
- package/dist/guarded-mkdir.js +217 -33
- package/dist/guest.d.ts.map +1 -1
- package/dist/guest.js +16 -5
- package/dist/home-dir.d.ts.map +1 -1
- package/dist/home-dir.js +73 -10
- package/dist/install-path.d.ts +6 -0
- package/dist/install-path.d.ts.map +1 -1
- package/dist/install-path.js +67 -19
- package/dist/json-durable-queue-ownership.d.ts +8 -0
- package/dist/json-durable-queue-ownership.d.ts.map +1 -1
- package/dist/json-durable-queue-ownership.js +134 -43
- package/dist/json-durable-queue-paths.d.ts +11 -0
- package/dist/json-durable-queue-paths.d.ts.map +1 -0
- package/dist/json-durable-queue-paths.js +42 -0
- package/dist/json-durable-queue-read.d.ts +6 -0
- package/dist/json-durable-queue-read.d.ts.map +1 -0
- package/dist/json-durable-queue-read.js +61 -0
- package/dist/json-durable-queue.d.ts +1 -1
- package/dist/json-durable-queue.d.ts.map +1 -1
- package/dist/json-durable-queue.js +83 -134
- package/dist/json-store.d.ts.map +1 -1
- package/dist/json-store.js +5 -1
- package/dist/json.d.ts.map +1 -1
- package/dist/json.js +54 -22
- package/dist/local-file-access.d.ts.map +1 -1
- package/dist/local-file-access.js +4 -0
- package/dist/local-file-descriptor.d.ts +17 -0
- package/dist/local-file-descriptor.d.ts.map +1 -0
- package/dist/local-file-descriptor.js +84 -0
- package/dist/local-roots.d.ts.map +1 -1
- package/dist/local-roots.js +35 -7
- package/dist/move-path-cleanup.d.ts +2 -0
- package/dist/move-path-cleanup.d.ts.map +1 -1
- package/dist/move-path-cleanup.js +44 -18
- package/dist/move-path.d.ts.map +1 -1
- package/dist/move-path.js +31 -6
- package/dist/native-binding.d.ts +21 -0
- package/dist/native-binding.d.ts.map +1 -1
- package/dist/native-directory-observation.d.ts +17 -0
- package/dist/native-directory-observation.d.ts.map +1 -0
- package/dist/native-directory-observation.js +37 -0
- package/dist/native-parent-admission.d.ts +31 -0
- package/dist/native-parent-admission.d.ts.map +1 -0
- package/dist/native-parent-admission.js +124 -0
- package/dist/native-pinned-write-windows.d.ts +0 -1
- package/dist/native-pinned-write-windows.d.ts.map +1 -1
- package/dist/native-pinned-write-windows.js +0 -3
- package/dist/native-pinned-write.d.ts.map +1 -1
- package/dist/native-pinned-write.js +309 -40
- package/dist/output.d.ts.map +1 -1
- package/dist/output.js +15 -5
- package/dist/overwrite-file-handle.d.ts.map +1 -1
- package/dist/overwrite-file-handle.js +5 -1
- package/dist/owner-dacl.d.ts.map +1 -1
- package/dist/owner-dacl.js +2 -0
- package/dist/path-policy.d.ts.map +1 -1
- package/dist/path-policy.js +7 -2
- package/dist/path-prefix.d.ts +7 -0
- package/dist/path-prefix.d.ts.map +1 -0
- package/dist/path-prefix.js +82 -0
- package/dist/path-scope-lexical.d.ts +14 -0
- package/dist/path-scope-lexical.d.ts.map +1 -0
- package/dist/path-scope-lexical.js +37 -0
- package/dist/path-segment-route.d.ts +7 -0
- package/dist/path-segment-route.d.ts.map +1 -0
- package/dist/path-segment-route.js +24 -0
- package/dist/path-suffix-aliases.d.ts +10 -0
- package/dist/path-suffix-aliases.d.ts.map +1 -0
- package/dist/path-suffix-aliases.js +386 -0
- package/dist/path.d.ts.map +1 -1
- package/dist/path.js +35 -6
- package/dist/permissions-windows.d.ts.map +1 -1
- package/dist/permissions-windows.js +14 -3
- package/dist/permissions.d.ts.map +1 -1
- package/dist/permissions.js +37 -8
- package/dist/pinned-mutation-admission.d.ts +25 -0
- package/dist/pinned-mutation-admission.d.ts.map +1 -0
- package/dist/pinned-mutation-admission.js +425 -0
- package/dist/pinned-mutation-observation.d.ts +34 -0
- package/dist/pinned-mutation-observation.d.ts.map +1 -0
- package/dist/pinned-mutation-observation.js +142 -0
- package/dist/pinned-mutation-shared-route.d.ts +24 -0
- package/dist/pinned-mutation-shared-route.d.ts.map +1 -0
- package/dist/pinned-mutation-shared-route.js +70 -0
- package/dist/pinned-open.d.ts +6 -0
- package/dist/pinned-open.d.ts.map +1 -1
- package/dist/pinned-open.js +28 -10
- package/dist/pinned-write-types.d.ts +75 -0
- package/dist/pinned-write-types.d.ts.map +1 -0
- package/dist/pinned-write-types.js +1 -0
- package/dist/pinned-write.d.ts +7 -33
- package/dist/pinned-write.d.ts.map +1 -1
- package/dist/pinned-write.js +152 -17
- package/dist/private-directory.d.ts.map +1 -1
- package/dist/private-directory.js +2 -0
- package/dist/private-producer-handoff.d.ts +16 -0
- package/dist/private-producer-handoff.d.ts.map +1 -0
- package/dist/private-producer-handoff.js +272 -0
- package/dist/private-temp-workspace.d.ts +2 -39
- package/dist/private-temp-workspace.d.ts.map +1 -1
- package/dist/private-temp-workspace.js +183 -77
- package/dist/publish-file.d.ts.map +1 -1
- package/dist/publish-file.js +33 -29
- package/dist/regular-file.d.ts.map +1 -1
- package/dist/regular-file.js +56 -45
- package/dist/replace-directory.d.ts.map +1 -1
- package/dist/replace-directory.js +12 -5
- package/dist/replace-file-temp-owner.d.ts +1 -0
- package/dist/replace-file-temp-owner.d.ts.map +1 -1
- package/dist/replace-file-temp-owner.js +12 -1
- package/dist/replace-file.d.ts.map +1 -1
- package/dist/replace-file.js +24 -24
- package/dist/root-boundary.d.ts +29 -0
- package/dist/root-boundary.d.ts.map +1 -0
- package/dist/root-boundary.js +182 -0
- package/dist/root-context.d.ts +12 -1
- package/dist/root-context.d.ts.map +1 -1
- package/dist/root-context.js +89 -16
- package/dist/root-directory-creation.d.ts +13 -0
- package/dist/root-directory-creation.d.ts.map +1 -0
- package/dist/root-directory-creation.js +212 -0
- package/dist/root-directory-list.d.ts +16 -4
- package/dist/root-directory-list.d.ts.map +1 -1
- package/dist/root-directory-list.js +182 -33
- package/dist/root-directory.d.ts +23 -0
- package/dist/root-directory.d.ts.map +1 -0
- package/dist/root-directory.js +141 -0
- package/dist/root-errors.d.ts.map +1 -1
- package/dist/root-errors.js +12 -1
- package/dist/root-file-final-admission.d.ts +21 -0
- package/dist/root-file-final-admission.d.ts.map +1 -0
- package/dist/root-file-final-admission.js +83 -0
- package/dist/root-file.d.ts.map +1 -1
- package/dist/root-file.js +103 -24
- package/dist/root-impl.d.ts +1 -0
- package/dist/root-impl.d.ts.map +1 -1
- package/dist/root-impl.js +316 -325
- package/dist/root-move-noreplace.d.ts +14 -0
- package/dist/root-move-noreplace.d.ts.map +1 -0
- package/dist/root-move-noreplace.js +202 -0
- package/dist/root-move-preflight.d.ts +8 -0
- package/dist/root-move-preflight.d.ts.map +1 -0
- package/dist/root-move-preflight.js +16 -0
- package/dist/root-observed-path.d.ts +9 -0
- package/dist/root-observed-path.d.ts.map +1 -0
- package/dist/root-observed-path.js +95 -0
- package/dist/root-path-errors.d.ts +12 -0
- package/dist/root-path-errors.d.ts.map +1 -0
- package/dist/root-path-errors.js +13 -0
- package/dist/root-path-existing.d.ts +2 -0
- package/dist/root-path-existing.d.ts.map +1 -1
- package/dist/root-path-existing.js +63 -22
- package/dist/root-path-observation.d.ts +63 -0
- package/dist/root-path-observation.d.ts.map +1 -0
- package/dist/root-path-observation.js +180 -0
- package/dist/root-path-stat.d.ts +5 -0
- package/dist/root-path-stat.d.ts.map +1 -0
- package/dist/root-path-stat.js +101 -0
- package/dist/root-path-symlink.d.ts.map +1 -1
- package/dist/root-path-symlink.js +23 -4
- package/dist/root-path.d.ts +13 -0
- package/dist/root-path.d.ts.map +1 -1
- package/dist/root-path.js +263 -73
- package/dist/root-paths-lexical.d.ts +9 -0
- package/dist/root-paths-lexical.d.ts.map +1 -0
- package/dist/root-paths-lexical.js +22 -0
- package/dist/root-paths.d.ts +3 -29
- package/dist/root-paths.d.ts.map +1 -1
- package/dist/root-paths.js +89 -178
- package/dist/root-read-admission.d.ts +26 -0
- package/dist/root-read-admission.d.ts.map +1 -0
- package/dist/root-read-admission.js +94 -0
- package/dist/root-remove-identity.d.ts +15 -0
- package/dist/root-remove-identity.d.ts.map +1 -0
- package/dist/root-remove-identity.js +89 -0
- package/dist/root-remove-receipt.d.ts +17 -0
- package/dist/root-remove-receipt.d.ts.map +1 -0
- package/dist/root-remove-receipt.js +37 -0
- package/dist/root-remove.d.ts +2 -1
- package/dist/root-remove.d.ts.map +1 -1
- package/dist/root-remove.js +172 -10
- package/dist/root-walk.d.ts.map +1 -1
- package/dist/root-walk.js +2 -1
- package/dist/root-write-admission.d.ts +68 -0
- package/dist/root-write-admission.d.ts.map +1 -0
- package/dist/root-write-admission.js +322 -0
- package/dist/root-write-compatibility.d.ts +13 -0
- package/dist/root-write-compatibility.d.ts.map +1 -0
- package/dist/root-write-compatibility.js +74 -0
- package/dist/root-write-complete-parent.d.ts +42 -0
- package/dist/root-write-complete-parent.d.ts.map +1 -0
- package/dist/root-write-complete-parent.js +195 -0
- package/dist/root-write-mode.d.ts +2 -0
- package/dist/root-write-mode.d.ts.map +1 -1
- package/dist/root-write-mode.js +20 -7
- package/dist/root-write-publication.d.ts +24 -0
- package/dist/root-write-publication.d.ts.map +1 -0
- package/dist/root-write-publication.js +85 -0
- package/dist/root-write-verification.d.ts.map +1 -1
- package/dist/root-write-verification.js +18 -7
- package/dist/safe-path-segment.d.ts.map +1 -1
- package/dist/safe-path-segment.js +3 -1
- package/dist/secret-file.d.ts.map +1 -1
- package/dist/secret-file.js +62 -24
- package/dist/secret-read-async.d.ts.map +1 -1
- package/dist/secret-read-async.js +18 -13
- package/dist/secret-read-policy.d.ts.map +1 -1
- package/dist/secret-read-policy.js +5 -1
- package/dist/secure-file-windows.d.ts +10 -0
- package/dist/secure-file-windows.d.ts.map +1 -0
- package/dist/secure-file-windows.js +186 -0
- package/dist/secure-file.d.ts.map +1 -1
- package/dist/secure-file.js +98 -10
- package/dist/secure-temp-dir.d.ts +6 -3
- package/dist/secure-temp-dir.d.ts.map +1 -1
- package/dist/secure-temp-dir.js +121 -101
- package/dist/secure-temp-repair.d.ts +35 -0
- package/dist/secure-temp-repair.d.ts.map +1 -0
- package/dist/secure-temp-repair.js +106 -0
- package/dist/sibling-staged-file.d.ts +3 -1
- package/dist/sibling-staged-file.d.ts.map +1 -1
- package/dist/sibling-staged-file.js +181 -50
- package/dist/sibling-temp.d.ts.map +1 -1
- package/dist/sibling-temp.js +27 -12
- package/dist/sidecar-lock-acquire.d.ts.map +1 -1
- package/dist/sidecar-lock-acquire.js +45 -15
- package/dist/sidecar-lock-root.d.ts.map +1 -1
- package/dist/sidecar-lock-root.js +4 -2
- package/dist/sidecar-lock.d.ts.map +1 -1
- package/dist/sidecar-lock.js +2 -3
- package/dist/staged-directory.d.ts +14 -5
- package/dist/staged-directory.d.ts.map +1 -1
- package/dist/staged-directory.js +54 -3
- package/dist/standalone-publication-path.d.ts +2 -0
- package/dist/standalone-publication-path.d.ts.map +1 -0
- package/dist/standalone-publication-path.js +6 -0
- package/dist/stat-observation.d.ts +11 -0
- package/dist/stat-observation.d.ts.map +1 -0
- package/dist/stat-observation.js +64 -0
- package/dist/strict-file-identity.d.ts.map +1 -1
- package/dist/strict-file-identity.js +39 -2
- package/dist/symlink-parents.d.ts.map +1 -1
- package/dist/symlink-parents.js +7 -2
- package/dist/temp-target.d.ts +2 -0
- package/dist/temp-target.d.ts.map +1 -1
- package/dist/temp-target.js +133 -4
- package/dist/temp-workspace-admission.d.ts +22 -0
- package/dist/temp-workspace-admission.d.ts.map +1 -0
- package/dist/temp-workspace-admission.js +374 -0
- package/dist/temp-workspace-child-admission.d.ts +13 -0
- package/dist/temp-workspace-child-admission.d.ts.map +1 -0
- package/dist/temp-workspace-child-admission.js +95 -0
- package/dist/temp-workspace-descriptor.d.ts +48 -0
- package/dist/temp-workspace-descriptor.d.ts.map +1 -0
- package/dist/temp-workspace-descriptor.js +363 -0
- package/dist/temp-workspace-identity.d.ts +15 -0
- package/dist/temp-workspace-identity.d.ts.map +1 -0
- package/dist/temp-workspace-identity.js +41 -0
- package/dist/temp-workspace-owner.d.ts +7 -6
- package/dist/temp-workspace-owner.d.ts.map +1 -1
- package/dist/temp-workspace-owner.js +121 -61
- package/dist/temp-workspace-permissions.d.ts +4 -0
- package/dist/temp-workspace-permissions.d.ts.map +1 -0
- package/dist/temp-workspace-permissions.js +32 -0
- package/dist/temp-workspace-types.d.ts +40 -0
- package/dist/temp-workspace-types.d.ts.map +1 -0
- package/dist/temp-workspace-types.js +1 -0
- package/dist/temp.d.ts +1 -1
- package/dist/temp.d.ts.map +1 -1
- package/dist/temp.js +1 -1
- package/dist/test-hooks.d.ts +7 -0
- package/dist/test-hooks.d.ts.map +1 -1
- package/dist/text-atomic.d.ts.map +1 -1
- package/dist/text-atomic.js +3 -1
- package/dist/trash.d.ts.map +1 -1
- package/dist/trash.js +54 -8
- package/dist/walk.d.ts.map +1 -1
- package/dist/walk.js +20 -16
- package/dist/windows-owner.d.ts.map +1 -1
- package/dist/windows-owner.js +5 -0
- package/dist/windows-path-alias.d.ts +39 -0
- package/dist/windows-path-alias.d.ts.map +1 -0
- package/dist/windows-path-alias.js +153 -0
- package/docs/advanced.md +28 -1
- package/docs/archive.md +29 -2
- package/docs/atomic.md +27 -3
- package/docs/contributing.md +4 -1
- package/docs/copy.md +4 -1
- package/docs/durability.md +18 -2
- package/docs/errors.md +14 -6
- package/docs/file-store.md +30 -3
- package/docs/filename.md +21 -7
- package/docs/guest.md +5 -0
- package/docs/install-path.md +61 -15
- package/docs/install.md +12 -8
- package/docs/json-store.md +5 -1
- package/docs/json.md +11 -0
- package/docs/mutation-policy-proof.md +65 -0
- package/docs/native-helper.md +28 -9
- package/docs/native.md +46 -10
- package/docs/output.md +33 -11
- package/docs/path-prefix.md +64 -0
- package/docs/path-suffix-aliases.md +159 -0
- package/docs/path.md +12 -1
- package/docs/permissions.md +26 -1
- package/docs/private-file-store.md +14 -0
- package/docs/public-api.md +14 -0
- package/docs/quickstart.md +1 -1
- package/docs/reading.md +8 -1
- package/docs/root.md +21 -4
- package/docs/secret-file.md +3 -0
- package/docs/secure-file.md +21 -16
- package/docs/security-model.md +76 -9
- package/docs/sidecar-lock.md +28 -1
- package/docs/store.md +27 -2
- package/docs/temp.md +262 -34
- package/docs/test-hooks.md +14 -0
- package/docs/writing.md +38 -8
- package/package.json +10 -10
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { FsSafeError } from "./errors.js";
|
|
2
|
+
import { recordFileObservationFailure } from "./file-observation.js";
|
|
3
|
+
import { getNativeBinding } from "./native.js";
|
|
4
|
+
const IDENTITY_RE = /^([0-9a-f]{8}):([0-9a-f]{16})$/;
|
|
5
|
+
const SID_RE = /^s-\d+-\d+(?:-\d+)+$/;
|
|
6
|
+
const OWNER_CLASSES = new Set(["current-user", "system", "administrators", "foreign"]);
|
|
7
|
+
const TRUSTED_OWNER_CLASSES = new Set(["current-user", "system", "administrators"]);
|
|
8
|
+
const SYSTEM_SID = "s-1-5-18";
|
|
9
|
+
const ADMINISTRATORS_SID = "s-1-5-32-544";
|
|
10
|
+
const WORLD_SIDS = new Set([
|
|
11
|
+
"s-1-1-0", "s-1-5-11", "s-1-5-32-545", "s-1-5-7",
|
|
12
|
+
"s-1-5-32-546", "s-1-5-4", "s-1-5-2",
|
|
13
|
+
]);
|
|
14
|
+
const GENERIC_READ = 0x8000_0000;
|
|
15
|
+
const GENERIC_WRITE = 0x4000_0000;
|
|
16
|
+
const GENERIC_ALL = 0x1000_0000;
|
|
17
|
+
const DELETE_ACCESS = 0x0001_0000;
|
|
18
|
+
const WRITE_DAC = 0x0004_0000;
|
|
19
|
+
const WRITE_OWNER = 0x0008_0000;
|
|
20
|
+
const FILE_READ_DATA = 0x0000_0001;
|
|
21
|
+
const FILE_WRITE_DATA = 0x0000_0002;
|
|
22
|
+
const FILE_APPEND_DATA = 0x0000_0004;
|
|
23
|
+
const FILE_READ_EA = 0x0000_0008;
|
|
24
|
+
const FILE_WRITE_EA = 0x0000_0010;
|
|
25
|
+
const FILE_DELETE_CHILD = 0x0000_0040;
|
|
26
|
+
const FILE_READ_ATTRIBUTES = 0x0000_0080;
|
|
27
|
+
const FILE_WRITE_ATTRIBUTES = 0x0000_0100;
|
|
28
|
+
function permissionUnverified(message, cause) {
|
|
29
|
+
throw new FsSafeError("permission-unverified", message, cause === undefined ? {} : { cause });
|
|
30
|
+
}
|
|
31
|
+
function identityMismatch() {
|
|
32
|
+
const error = new FsSafeError("path-mismatch", "file identity changed or could not be verified");
|
|
33
|
+
recordFileObservationFailure(error, "identity");
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
function isRecord(value) {
|
|
37
|
+
return typeof value === "object" && value !== null;
|
|
38
|
+
}
|
|
39
|
+
function isUint32(value) {
|
|
40
|
+
return typeof value === "number" && Number.isInteger(value) && value >= 0 && value <= 0xffff_ffff;
|
|
41
|
+
}
|
|
42
|
+
function parseIdentity(value) {
|
|
43
|
+
if (typeof value !== "string")
|
|
44
|
+
identityMismatch();
|
|
45
|
+
const match = IDENTITY_RE.exec(value);
|
|
46
|
+
if (!match)
|
|
47
|
+
identityMismatch();
|
|
48
|
+
return {
|
|
49
|
+
dev: BigInt(`0x${match[1]}`),
|
|
50
|
+
ino: BigInt(`0x${match[2]}`),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function validateFlags(value) {
|
|
54
|
+
if (!isRecord(value))
|
|
55
|
+
return false;
|
|
56
|
+
const raw = value.raw;
|
|
57
|
+
if (!isUint32(raw) || (raw & ~0xdf) !== 0)
|
|
58
|
+
return false;
|
|
59
|
+
const fields = [
|
|
60
|
+
["objectInherit", 0x01], ["containerInherit", 0x02],
|
|
61
|
+
["noPropagateInherit", 0x04], ["inheritOnly", 0x08], ["inherited", 0x10],
|
|
62
|
+
["successfulAccess", 0x40], ["failedAccess", 0x80],
|
|
63
|
+
];
|
|
64
|
+
return fields.every(([field, bit]) => typeof value[field] === "boolean" && value[field] === ((raw & bit) !== 0));
|
|
65
|
+
}
|
|
66
|
+
function validateAce(value) {
|
|
67
|
+
return isRecord(value) && typeof value.sid === "string" && SID_RE.test(value.sid) &&
|
|
68
|
+
isUint32(value.mask) && (value.aceType === "allow" || value.aceType === "deny") &&
|
|
69
|
+
validateFlags(value.flags);
|
|
70
|
+
}
|
|
71
|
+
function canRead(mask) {
|
|
72
|
+
return (mask & (GENERIC_ALL | GENERIC_READ | FILE_READ_DATA | FILE_READ_EA |
|
|
73
|
+
FILE_READ_ATTRIBUTES)) !== 0;
|
|
74
|
+
}
|
|
75
|
+
function canWrite(mask) {
|
|
76
|
+
return (mask & (GENERIC_ALL | GENERIC_WRITE | FILE_WRITE_DATA | FILE_APPEND_DATA |
|
|
77
|
+
FILE_WRITE_EA | FILE_WRITE_ATTRIBUTES | FILE_DELETE_CHILD | DELETE_ACCESS |
|
|
78
|
+
WRITE_DAC | WRITE_OWNER)) !== 0;
|
|
79
|
+
}
|
|
80
|
+
function expectedOwnerClass(facts) {
|
|
81
|
+
if (facts.ownerSid === facts.currentUserSid)
|
|
82
|
+
return "current-user";
|
|
83
|
+
if (facts.ownerSid === SYSTEM_SID)
|
|
84
|
+
return "system";
|
|
85
|
+
if (facts.ownerSid === ADMINISTRATORS_SID)
|
|
86
|
+
return "administrators";
|
|
87
|
+
return "foreign";
|
|
88
|
+
}
|
|
89
|
+
function validateSecurity(value) {
|
|
90
|
+
if (!isRecord(value))
|
|
91
|
+
permissionUnverified("Windows descriptor ACL facts were malformed");
|
|
92
|
+
const facts = value;
|
|
93
|
+
const booleans = [
|
|
94
|
+
"worldWritable", "groupWritable", "worldReadable", "groupReadable",
|
|
95
|
+
"fallbackRequired", "daclPresent", "isLocal", "aceListComplete",
|
|
96
|
+
];
|
|
97
|
+
if (!booleans.every((field) => typeof facts[field] === "boolean") ||
|
|
98
|
+
typeof facts.ownerSid !== "string" || !SID_RE.test(facts.ownerSid) ||
|
|
99
|
+
typeof facts.currentUserSid !== "string" || !SID_RE.test(facts.currentUserSid) ||
|
|
100
|
+
typeof facts.ownerClass !== "string" || !OWNER_CLASSES.has(facts.ownerClass) ||
|
|
101
|
+
!Array.isArray(facts.unsupportedAceTypes) ||
|
|
102
|
+
!facts.unsupportedAceTypes.every(isUint32) ||
|
|
103
|
+
!Array.isArray(facts.aces) || !facts.aces.every(validateAce)) {
|
|
104
|
+
permissionUnverified("Windows descriptor ACL facts were malformed");
|
|
105
|
+
}
|
|
106
|
+
if (facts.ownerClass !== expectedOwnerClass(facts)) {
|
|
107
|
+
permissionUnverified("Windows descriptor owner facts were inconsistent");
|
|
108
|
+
}
|
|
109
|
+
if (facts.fallbackRequired || !facts.isLocal || !facts.aceListComplete ||
|
|
110
|
+
facts.unsupportedAceTypes.length !== 0) {
|
|
111
|
+
permissionUnverified("Windows descriptor ACL facts were incomplete or unsupported");
|
|
112
|
+
}
|
|
113
|
+
if (!facts.daclPresent && facts.aces.length !== 0) {
|
|
114
|
+
permissionUnverified("Windows descriptor DACL facts were inconsistent");
|
|
115
|
+
}
|
|
116
|
+
return facts;
|
|
117
|
+
}
|
|
118
|
+
function validatePermissionSummary(facts) {
|
|
119
|
+
let worldReadable = !facts.daclPresent;
|
|
120
|
+
let worldWritable = !facts.daclPresent;
|
|
121
|
+
let groupReadable = false;
|
|
122
|
+
let groupWritable = false;
|
|
123
|
+
const trustedSids = new Set([facts.currentUserSid, SYSTEM_SID, ADMINISTRATORS_SID]);
|
|
124
|
+
for (const ace of facts.aces) {
|
|
125
|
+
if (ace.aceType !== "allow" || ace.flags.inheritOnly || trustedSids.has(ace.sid))
|
|
126
|
+
continue;
|
|
127
|
+
const world = WORLD_SIDS.has(ace.sid);
|
|
128
|
+
if (world) {
|
|
129
|
+
worldReadable ||= canRead(ace.mask);
|
|
130
|
+
worldWritable ||= canWrite(ace.mask);
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
groupReadable ||= canRead(ace.mask);
|
|
134
|
+
groupWritable ||= canWrite(ace.mask);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (facts.worldReadable !== worldReadable || facts.worldWritable !== worldWritable ||
|
|
138
|
+
facts.groupReadable !== groupReadable || facts.groupWritable !== groupWritable) {
|
|
139
|
+
permissionUnverified("Windows descriptor ACL summary was inconsistent");
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
export function inspectSecureWindowsDescriptor(params) {
|
|
143
|
+
let native;
|
|
144
|
+
try {
|
|
145
|
+
native = getNativeBinding();
|
|
146
|
+
}
|
|
147
|
+
catch (cause) {
|
|
148
|
+
permissionUnverified("Windows descriptor ACL verification requires the matching native helper", cause);
|
|
149
|
+
}
|
|
150
|
+
const inspect = native?.inspectWindowsSecureFileHandle;
|
|
151
|
+
if (typeof inspect !== "function") {
|
|
152
|
+
permissionUnverified("Windows descriptor ACL verification requires an up-to-date native helper");
|
|
153
|
+
}
|
|
154
|
+
let result;
|
|
155
|
+
try {
|
|
156
|
+
result = inspect.call(native, params.fd);
|
|
157
|
+
}
|
|
158
|
+
catch (cause) {
|
|
159
|
+
permissionUnverified("Windows descriptor ACL verification failed", cause);
|
|
160
|
+
}
|
|
161
|
+
if (!isRecord(result))
|
|
162
|
+
permissionUnverified("Windows descriptor ACL facts were malformed");
|
|
163
|
+
const observed = parseIdentity(result.identity);
|
|
164
|
+
if (observed.dev !== params.identity.dev || observed.ino !== params.identity.ino) {
|
|
165
|
+
identityMismatch();
|
|
166
|
+
}
|
|
167
|
+
const facts = validateSecurity(result.security);
|
|
168
|
+
validatePermissionSummary(facts);
|
|
169
|
+
return {
|
|
170
|
+
ok: true,
|
|
171
|
+
isSymlink: false,
|
|
172
|
+
isDir: params.stat.isDirectory(),
|
|
173
|
+
mode: typeof params.stat.mode === "number" ? params.stat.mode : null,
|
|
174
|
+
bits: null,
|
|
175
|
+
source: "windows-acl",
|
|
176
|
+
worldWritable: facts.worldWritable,
|
|
177
|
+
groupWritable: facts.groupWritable,
|
|
178
|
+
worldReadable: facts.worldReadable,
|
|
179
|
+
groupReadable: facts.groupReadable,
|
|
180
|
+
ownerSid: facts.ownerSid,
|
|
181
|
+
ownerTrusted: TRUSTED_OWNER_CLASSES.has(facts.ownerClass),
|
|
182
|
+
aclSummary: `native descriptor owner=${facts.ownerClass} world=` +
|
|
183
|
+
`${facts.worldReadable ? "r" : "-"}${facts.worldWritable ? "w" : "-"} ` +
|
|
184
|
+
`group=${facts.groupReadable ? "r" : "-"}${facts.groupWritable ? "w" : "-"}`,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secure-file.d.ts","sourceRoot":"","sources":["../src/secure-file.ts"],"names":[],"mappings":"AAAA,OAAe,EAAoB,KAAK,KAAK,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"secure-file.d.ts","sourceRoot":"","sources":["../src/secure-file.ts"],"names":[],"mappings":"AAAA,OAAe,EAAoB,KAAK,KAAK,EAAE,MAAM,SAAS,CAAC;AAe/D,OAAO,EAOL,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC5B,MAAM,kBAAkB,CAAC;AAU1B,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,sBAAsB,CAAC;IAC/B,WAAW,CAAC,EAAE,2BAA2B,CAAC;IAC1C,MAAM,CAAC,EAAE,uBAAuB,CAAC;IACjC,EAAE,CAAC,EAAE,mBAAmB,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACxC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,sBAAsB,CAAC;AAE7D,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,KAAK,CAAC;IACZ,WAAW,CAAC,EAAE,eAAe,CAAC;CAC/B,CAAC;AAgTF,wBAAsB,cAAc,CAClC,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,oBAAoB,CAAC,CAgC/B"}
|
package/dist/secure-file.js
CHANGED
|
@@ -4,6 +4,7 @@ import path from "node:path";
|
|
|
4
4
|
import { readFileHandleBounded } from "./bounded-read.js";
|
|
5
5
|
import { normalizeMaxBytes } from "./byte-budget.js";
|
|
6
6
|
import { assertNoUnsafeDeviceReadPath } from "./device-path.js";
|
|
7
|
+
import { resolveEffectiveUid } from "./effective-uid.js";
|
|
7
8
|
import { FsSafeError } from "./errors.js";
|
|
8
9
|
import { isWindowsDriveLetterPath, isWindowsNetworkPath } from "./local-file-access.js";
|
|
9
10
|
import { isPathInside, isSymlinkOpenError } from "./path.js";
|
|
@@ -12,7 +13,77 @@ import { resolveReadOpenFlags } from "./read-open-flags.js";
|
|
|
12
13
|
import { realpathSync } from "./realpath.js";
|
|
13
14
|
import { inspectPathPermissions, isGroupReadable, isGroupWritable, isWorldReadable, isWorldWritable, modeBits, } from "./permissions.js";
|
|
14
15
|
import { inspectFileIdentity } from "./strict-file-identity.js";
|
|
16
|
+
import { inspectSecureWindowsDescriptor } from "./secure-file-windows.js";
|
|
15
17
|
import { scheduleTimeout } from "./timing.js";
|
|
18
|
+
import { anchorWindowsDriveRelativePath, assertNoWindowsPathAlias, resolvePathPreservingWindowsRoot, } from "./windows-path-alias.js";
|
|
19
|
+
function snapshotTrustedDirs(dirs) {
|
|
20
|
+
if (dirs === undefined)
|
|
21
|
+
return undefined;
|
|
22
|
+
if (!Array.isArray(dirs)) {
|
|
23
|
+
throw new FsSafeError("invalid-path", "trustedDirs must be an array of path strings.");
|
|
24
|
+
}
|
|
25
|
+
const trustedDirs = [];
|
|
26
|
+
const length = dirs.length;
|
|
27
|
+
if (!Number.isSafeInteger(length) || length < 0 || length > 0xffff_ffff) {
|
|
28
|
+
throw new FsSafeError("invalid-path", "trustedDirs must have a valid array length.");
|
|
29
|
+
}
|
|
30
|
+
for (let index = 0; index < length; index += 1) {
|
|
31
|
+
if (!Object.hasOwn(dirs, index)) {
|
|
32
|
+
throw new FsSafeError("invalid-path", "trustedDirs must not contain sparse entries.");
|
|
33
|
+
}
|
|
34
|
+
const dir = dirs[index];
|
|
35
|
+
if (typeof dir !== "string" || dir.includes("\0")) {
|
|
36
|
+
throw new FsSafeError("invalid-path", "trustedDirs must contain only path strings without null bytes.");
|
|
37
|
+
}
|
|
38
|
+
// Admit the raw suffix before normalization can erase an alternate stream,
|
|
39
|
+
// while retaining Node's per-drive cwd semantics for D:credentials.
|
|
40
|
+
const anchored = anchorWindowsDriveRelativePath(dir);
|
|
41
|
+
assertNoWindowsPathAlias(anchored, "filesystem", "trusted directory uses a Windows filesystem namespace alias");
|
|
42
|
+
const resolved = resolvePathPreservingWindowsRoot(anchored);
|
|
43
|
+
assertNoWindowsPathAlias(resolved, "filesystem", "trusted directory uses a Windows filesystem namespace alias");
|
|
44
|
+
trustedDirs.push(resolved);
|
|
45
|
+
}
|
|
46
|
+
return trustedDirs;
|
|
47
|
+
}
|
|
48
|
+
function snapshotPermissionEnv(env) {
|
|
49
|
+
if (env === undefined)
|
|
50
|
+
return undefined;
|
|
51
|
+
const snapshot = { ...env };
|
|
52
|
+
// Windows command lookup first reads these exact names, even when inherited
|
|
53
|
+
// or non-enumerable, then considers only enumerable own case variants.
|
|
54
|
+
// Reuse copied values so enumerable getters are not invoked a second time.
|
|
55
|
+
if (!Object.hasOwn(snapshot, "SystemRoot"))
|
|
56
|
+
snapshot.SystemRoot = env.SystemRoot;
|
|
57
|
+
if (!Object.hasOwn(snapshot, "WINDIR"))
|
|
58
|
+
snapshot.WINDIR = env.WINDIR;
|
|
59
|
+
return snapshot;
|
|
60
|
+
}
|
|
61
|
+
function snapshotSecureFileOptions(options, io, maxBytes) {
|
|
62
|
+
const { filePath, label, trust, permissions, inject } = options;
|
|
63
|
+
const env = inject?.env;
|
|
64
|
+
return {
|
|
65
|
+
filePath,
|
|
66
|
+
label,
|
|
67
|
+
trust: {
|
|
68
|
+
trustedDirs: snapshotTrustedDirs(trust?.trustedDirs),
|
|
69
|
+
allowSymlink: trust?.allowSymlink,
|
|
70
|
+
allowNetworkPath: trust?.allowNetworkPath,
|
|
71
|
+
},
|
|
72
|
+
permissions: {
|
|
73
|
+
allowInsecure: permissions?.allowInsecure,
|
|
74
|
+
allowReadableByOthers: permissions?.allowReadableByOthers,
|
|
75
|
+
},
|
|
76
|
+
inject: {
|
|
77
|
+
platform: inject?.platform,
|
|
78
|
+
env: snapshotPermissionEnv(env),
|
|
79
|
+
exec: inject?.exec,
|
|
80
|
+
},
|
|
81
|
+
io: {
|
|
82
|
+
maxBytes,
|
|
83
|
+
timeoutMs: io?.timeoutMs,
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
}
|
|
16
87
|
function isAbsolutePathname(value) {
|
|
17
88
|
return (path.isAbsolute(value) ||
|
|
18
89
|
(process.platform === "win32" &&
|
|
@@ -81,6 +152,7 @@ async function openSecureHandle(options, maxBytes) {
|
|
|
81
152
|
return pathStat;
|
|
82
153
|
}, openedIdentity);
|
|
83
154
|
const realPath = realpathSync.native(options.filePath);
|
|
155
|
+
assertNoWindowsPathAlias(realPath, "filesystem", `${label(options)} resolved path uses a Windows filesystem namespace alias`);
|
|
84
156
|
await inspectFileIdentity(() => {
|
|
85
157
|
const realPathStat = fsSync.statSync(realPath, { bigint: true });
|
|
86
158
|
assertNotHardlinked(options, realPathStat);
|
|
@@ -101,13 +173,15 @@ async function assertTrustedDirs(options, realPath) {
|
|
|
101
173
|
return;
|
|
102
174
|
}
|
|
103
175
|
const trusted = await Promise.all(options.trust.trustedDirs.map(async (dir) => {
|
|
104
|
-
|
|
176
|
+
let realPath;
|
|
105
177
|
try {
|
|
106
|
-
|
|
178
|
+
realPath = realpathSync.native(dir);
|
|
107
179
|
}
|
|
108
180
|
catch {
|
|
109
|
-
return
|
|
181
|
+
return dir;
|
|
110
182
|
}
|
|
183
|
+
assertNoWindowsPathAlias(realPath, "filesystem", "trusted directory uses a Windows filesystem namespace alias");
|
|
184
|
+
return realPath;
|
|
111
185
|
}));
|
|
112
186
|
if (!trusted.some((dir) => isPathInside(dir, realPath))) {
|
|
113
187
|
throw new FsSafeError("outside-workspace", `${label(options)} is outside trustedDirs: ${realPath}`);
|
|
@@ -128,13 +202,15 @@ function inspectOpenedPermissions(stat, platform) {
|
|
|
128
202
|
groupReadable: isGroupReadable(bits),
|
|
129
203
|
};
|
|
130
204
|
}
|
|
131
|
-
async function assertSecurePermissions(options, stat, realPath) {
|
|
205
|
+
async function assertSecurePermissions(options, stat, realPath, identity, fd) {
|
|
132
206
|
if (options.permissions?.allowInsecure) {
|
|
133
207
|
return undefined;
|
|
134
208
|
}
|
|
135
209
|
const platform = options.inject?.platform ?? process.platform;
|
|
136
210
|
const permissions = platform === "win32"
|
|
137
|
-
?
|
|
211
|
+
? process.platform === "win32"
|
|
212
|
+
? inspectSecureWindowsDescriptor({ fd, identity, stat })
|
|
213
|
+
: await inspectPathPermissions(realPath, options.inject)
|
|
138
214
|
: inspectOpenedPermissions(stat, platform);
|
|
139
215
|
const reason = permissions.error ? `: ${formatPermissionErrorDetail(permissions.error)}` : "";
|
|
140
216
|
const diagnostics = {
|
|
@@ -160,10 +236,19 @@ async function assertSecurePermissions(options, stat, realPath) {
|
|
|
160
236
|
if (writableByOthers || (!options.permissions?.allowReadableByOthers && readableByOthers)) {
|
|
161
237
|
throw new FsSafeError("insecure-permissions", `${label(options)} permissions are too open: ${realPath}`);
|
|
162
238
|
}
|
|
163
|
-
if (platform !== "win32"
|
|
164
|
-
|
|
239
|
+
if (platform !== "win32") {
|
|
240
|
+
let uid;
|
|
241
|
+
try {
|
|
242
|
+
uid = resolveEffectiveUid();
|
|
243
|
+
}
|
|
244
|
+
catch (cause) {
|
|
245
|
+
throw new FsSafeError("permission-unverified", `${label(options)} owner identity could not be verified for the effective user: ${realPath}`, { cause });
|
|
246
|
+
}
|
|
247
|
+
if (uid === undefined || !Number.isSafeInteger(stat.uid) || stat.uid < 0) {
|
|
248
|
+
throw new FsSafeError("permission-unverified", `${label(options)} owner identity could not be verified for the effective user: ${realPath}`);
|
|
249
|
+
}
|
|
165
250
|
if (stat.uid !== uid) {
|
|
166
|
-
throw new FsSafeError("not-owned", `${label(options)} must be owned by the
|
|
251
|
+
throw new FsSafeError("not-owned", `${label(options)} must be owned by the effective user (uid=${uid}): ${realPath}`);
|
|
167
252
|
}
|
|
168
253
|
}
|
|
169
254
|
return permissions;
|
|
@@ -190,11 +275,14 @@ async function readHandleWithTimeout(handle, timeoutMs, maxBytes) {
|
|
|
190
275
|
}
|
|
191
276
|
}
|
|
192
277
|
export async function readSecureFile(options) {
|
|
193
|
-
const
|
|
278
|
+
const io = options.io;
|
|
279
|
+
const maxBytes = normalizeMaxBytes(io?.maxBytes);
|
|
280
|
+
options = snapshotSecureFileOptions(options, io, maxBytes);
|
|
281
|
+
assertNoWindowsPathAlias(options.filePath, "filesystem", `${label(options)} path uses a Windows filesystem namespace alias`);
|
|
194
282
|
const opened = await openSecureHandle(options, maxBytes);
|
|
195
283
|
try {
|
|
196
284
|
await assertTrustedDirs(options, opened.realPath);
|
|
197
|
-
const permissions = await assertSecurePermissions(options, opened.pathStat, opened.realPath);
|
|
285
|
+
const permissions = await assertSecurePermissions(options, opened.pathStat, opened.realPath, opened.identity, opened.handle.fd);
|
|
198
286
|
const buffer = await readHandleWithTimeout(opened.handle, options.io?.timeoutMs, maxBytes);
|
|
199
287
|
const finalIdentity = await inspectFileIdentity(() => fsSync.fstatSync(opened.handle.fd, { bigint: true }), opened.identity);
|
|
200
288
|
if (!finalIdentity.isFile()) {
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
+
import { type SecureTempRootDescriptorAdapter } from "./secure-temp-repair.js";
|
|
2
|
+
export type { SecureTempRootDescriptorAdapter } from "./secure-temp-repair.js";
|
|
1
3
|
type SecureDirStat = {
|
|
2
4
|
isDirectory(): boolean;
|
|
3
5
|
isSymbolicLink(): boolean;
|
|
4
|
-
mode?: number;
|
|
5
|
-
uid?: number;
|
|
6
|
+
mode?: number | bigint;
|
|
7
|
+
uid?: number | bigint;
|
|
6
8
|
};
|
|
7
9
|
export type ResolveSecureTempRootOptions = {
|
|
8
10
|
accessSync?: (path: string, mode?: number) => void;
|
|
11
|
+
/** @deprecated Unused. Repairs require descriptor-bound chmod. */
|
|
9
12
|
chmodSync?: (path: string, mode: number) => void;
|
|
13
|
+
descriptor?: SecureTempRootDescriptorAdapter;
|
|
10
14
|
fallbackPrefix: string;
|
|
11
15
|
getuid?: () => number | undefined;
|
|
12
16
|
lstatSync?: (path: string) => SecureDirStat;
|
|
@@ -23,5 +27,4 @@ export type ResolveSecureTempRootOptions = {
|
|
|
23
27
|
warningPrefix?: string;
|
|
24
28
|
};
|
|
25
29
|
export declare function resolveSecureTempRoot(options: ResolveSecureTempRootOptions): string;
|
|
26
|
-
export {};
|
|
27
30
|
//# sourceMappingURL=secure-temp-dir.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secure-temp-dir.d.ts","sourceRoot":"","sources":["../src/secure-temp-dir.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"secure-temp-dir.d.ts","sourceRoot":"","sources":["../src/secure-temp-dir.ts"],"names":[],"mappings":"AAOA,OAAO,EAKL,KAAK,+BAA+B,EACrC,MAAM,yBAAyB,CAAC;AACjC,YAAY,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAC;AAI/E,KAAK,aAAa,GAAG;IACnB,WAAW,IAAI,OAAO,CAAC;IACvB,cAAc,IAAI,OAAO,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG;IACzC,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,kEAAkE;IAClE,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACjD,UAAU,CAAC,EAAE,+BAA+B,CAAC;IAC7C,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;IAClC,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,aAAa,CAAC;IAC5C,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;QAAE,SAAS,EAAE,OAAO,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAChF,QAAQ,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,MAAM,CAAC,EAAE,MAAM,MAAM,CAAC;IACtB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAWF,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,4BAA4B,GAAG,MAAM,CA6LnF"}
|