@openclaw/fs-safe 0.18.0 → 0.18.2
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 +18 -0
- package/dist/advanced.d.ts +4 -2
- package/dist/advanced.js +1 -1
- package/dist/archive-durability.d.ts +1 -1
- package/dist/archive-merge.js +0 -1
- package/dist/archive-parser.wasm +0 -0
- package/dist/archive-plan.d.ts +64 -3
- package/dist/archive-plan.js +55 -1
- package/dist/archive-staging.d.ts +1 -2
- package/dist/archive-staging.js +0 -2
- package/dist/archive-tar-wasm.d.ts +1 -1
- package/dist/archive-zip-directory.d.ts +1 -1
- package/dist/archive-zip-entry.d.ts +1 -1
- package/dist/archive-zip-entry.js +1 -1
- package/dist/archive-zip-preflight.d.ts +0 -2
- package/dist/archive-zip-preflight.js +0 -1
- package/dist/archive.d.ts +14 -8
- package/dist/archive.js +127 -12
- package/dist/atomic.d.ts +3 -1
- package/dist/copy-publication.d.ts +1 -1
- package/dist/create.d.ts +16 -2
- package/dist/create.js +388 -2
- package/dist/creation-boundary.d.ts +60 -0
- package/dist/creation-boundary.js +371 -0
- package/dist/directory-guard.d.ts +0 -1
- package/dist/directory-guard.js +0 -3
- package/dist/directory-mode-node.d.ts +20 -2
- package/dist/directory-mode-node.js +89 -3
- package/dist/durability.d.ts +2 -1
- package/dist/file-lock-sync-acquisition.js +3 -3
- package/dist/file-lock-sync-root-acquire.js +2 -6
- package/dist/file-lock-sync-root-options.d.ts +2 -10
- package/dist/file-lock-sync-root.d.ts +2 -1
- package/dist/file-lock-sync-stale-admission.js +3 -10
- package/dist/file-lock-sync.d.ts +4 -21
- package/dist/file-store-boundary.d.ts +7 -0
- package/dist/file-store-boundary.js +58 -1
- package/dist/file-store-sync-write.js +2 -3
- package/dist/file-store.js +1 -6
- package/dist/guarded-mkdir.d.ts +1 -1
- package/dist/index.d.ts +9 -6
- package/dist/json-durable-queue-ownership.d.ts +1 -5
- package/dist/json-durable-queue-read.js +7 -3
- package/dist/json-durable-queue.d.ts +0 -1
- package/dist/json-durable-queue.js +1 -3
- package/dist/json-store.js +1 -2
- package/dist/json.js +1 -2
- package/dist/move-path.js +1 -2
- package/dist/native-operations.js +0 -1
- package/dist/native-pinned-write-windows.d.ts +1 -1
- package/dist/native-pinned-write-windows.js +1 -1
- package/dist/native-pinned-write.d.ts +1 -1
- package/dist/native-pinned-write.js +3 -6
- package/dist/native-policy-parent-windows.d.ts +1 -1
- package/dist/native-staged-file.d.ts +2 -2
- package/dist/native-staged-file.js +1 -2
- package/dist/permission-exec.d.ts +6 -0
- package/dist/permissions-public.d.ts +2 -1
- package/dist/permissions-windows.d.ts +3 -6
- package/dist/permissions.d.ts +3 -10
- package/dist/permissions.js +0 -1
- package/dist/pinned-mutation-admission.d.ts +1 -1
- package/dist/pinned-open.d.ts +1 -0
- package/dist/pinned-open.js +7 -2
- package/dist/pinned-operation.d.ts +1 -1
- package/dist/pinned-operation.js +3 -16
- package/dist/pinned-write-mode.js +1 -1
- package/dist/pinned-write-staged.js +1 -2
- package/dist/pinned-write.d.ts +0 -1
- package/dist/pinned-write.js +3 -5
- package/dist/private-producer-handoff-sync.d.ts +2 -12
- package/dist/private-producer-handoff-sync.js +1 -1
- package/dist/private-producer-handoff.d.ts +3 -3
- package/dist/private-temp-workspace.js +1 -2
- package/dist/publish-copy-stage.d.ts +1 -1
- package/dist/publish-file.d.ts +0 -1
- package/dist/publish-file.js +1 -2
- package/dist/replace-directory.js +6 -19
- package/dist/replace-file-copy-fallback.d.ts +1 -8
- package/dist/replace-file-descriptor.d.ts +3 -11
- package/dist/replace-file-descriptor.js +1 -1
- package/dist/replace-file-rename-policy.d.ts +1 -2
- package/dist/replace-file.d.ts +3 -3
- package/dist/replace-file.js +1 -1
- package/dist/retained-directory-replacement.d.ts +1 -0
- package/dist/retained-directory-replacement.js +1 -1
- package/dist/root-context.js +3 -7
- package/dist/root-create-input.d.ts +1 -1
- package/dist/root-directory-creation.d.ts +1 -1
- package/dist/root-directory-creation.js +1 -1
- package/dist/root-directory-list.js +3 -7
- package/dist/root-entries.js +2 -2
- package/dist/root-errors.d.ts +4 -0
- package/dist/root-errors.js +5 -3
- package/dist/root-file-final-admission.d.ts +1 -1
- package/dist/root-file-final-admission.js +1 -6
- package/dist/root-file.js +2 -5
- package/dist/root-impl.d.ts +0 -5
- package/dist/root-impl.js +22 -21
- package/dist/root-move-noreplace.js +4 -10
- package/dist/root-observed-path.js +2 -4
- package/dist/root-options.d.ts +1 -1
- package/dist/root-path-existing.js +2 -3
- package/dist/root-path-stat.js +2 -4
- package/dist/root-public-types.d.ts +11 -0
- package/dist/root-remove-identity.js +2 -4
- package/dist/root-remove.js +2 -4
- package/dist/root-write-admission.d.ts +1 -1
- package/dist/root-write-admission.js +3 -7
- package/dist/root-write-complete-parent.js +2 -3
- package/dist/root-write-verification.d.ts +1 -1
- package/dist/root.d.ts +2 -6
- package/dist/secret-file.js +11 -17
- package/dist/secret-read-policy.js +1 -1
- package/dist/secure-file-windows.js +4 -9
- package/dist/secure-temp-dir.js +2 -7
- package/dist/secure-temp-repair.js +5 -1
- package/dist/sidecar-lock-acquire.js +8 -11
- package/dist/sidecar-lock-policy.d.ts +1 -0
- package/dist/sidecar-lock-policy.js +7 -0
- package/dist/sidecar-lock-reclaim.js +5 -6
- package/dist/sidecar-lock-stale-admission.js +2 -6
- package/dist/sidecar-lock-types.d.ts +22 -16
- package/dist/stat-observation.js +3 -10
- package/dist/strict-file-identity.d.ts +2 -0
- package/dist/strict-file-identity.js +6 -6
- package/dist/temp-target.js +3 -8
- package/dist/temp-workspace-admission.js +7 -15
- package/dist/temp-workspace-child-admission.d.ts +16 -2
- package/dist/temp-workspace-child-admission.js +65 -3
- package/dist/temp-workspace-descriptor.d.ts +1 -1
- package/dist/temp-workspace-descriptor.js +2 -4
- package/dist/text-atomic.js +1 -1
- package/dist/windows-owner.d.ts +3 -6
- package/dist/windows-owner.js +1 -1
- package/dist/windows-path-alias.d.ts +1 -0
- package/dist/windows-path-alias.js +5 -0
- package/dist/windows-security-bridge.cs +0 -2
- package/docs/advanced.md +3 -1
- package/docs/secret-file.md +13 -0
- package/docs/sidecar-lock.md +6 -0
- package/docs/store.md +6 -0
- package/docs/temp.md +8 -1
- package/docs/writing.md +5 -0
- package/package.json +8 -8
- package/dist/archive-native.d.ts +0 -10
- package/dist/archive-native.js +0 -73
- package/dist/archive-options.d.ts +0 -30
- package/dist/archive-policy.d.ts +0 -21
- package/dist/archive-policy.js +0 -38
- package/dist/archive-tar-inspect.d.ts +0 -6
- package/dist/archive-tar-inspect.js +0 -62
- package/dist/archive-tar.d.ts +0 -18
- package/dist/archive-tar.js +0 -21
- package/dist/create-directory.d.ts +0 -18
- package/dist/create-directory.js +0 -111
- package/dist/create-file-async.d.ts +0 -6
- package/dist/create-file-async.js +0 -121
- package/dist/create-file.d.ts +0 -7
- package/dist/create-file.js +0 -179
- package/dist/creation-darwin.d.ts +0 -5
- package/dist/creation-darwin.js +0 -70
- package/dist/creation-file-state.d.ts +0 -18
- package/dist/creation-file-state.js +0 -118
- package/dist/creation-path.d.ts +0 -22
- package/dist/creation-path.js +0 -83
- package/dist/creation-permissions.d.ts +0 -18
- package/dist/creation-permissions.js +0 -115
- package/dist/directory-mode-owner.d.ts +0 -20
- package/dist/directory-mode-owner.js +0 -78
- package/dist/file-store-copy-source.d.ts +0 -4
- package/dist/file-store-copy-source.js +0 -31
- package/dist/file-store-limit.d.ts +0 -1
- package/dist/file-store-limit.js +0 -7
- package/dist/file-store-path.d.ts +0 -2
- package/dist/file-store-path.js +0 -30
- package/dist/standalone-publication-path.d.ts +0 -1
- package/dist/standalone-publication-path.js +0 -6
- package/dist/temp-workspace-identity.d.ts +0 -14
- package/dist/temp-workspace-identity.js +0 -41
- package/dist/temp-workspace-permissions.d.ts +0 -3
- package/dist/temp-workspace-permissions.js +0 -32
- /package/dist/{archive-options.js → root-public-types.js} +0 -0
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { type BigIntStats, type Stats } from "node:fs";
|
|
2
|
-
export type TempWorkspaceIdentity = Readonly<{
|
|
3
|
-
dev: bigint;
|
|
4
|
-
ino: bigint;
|
|
5
|
-
}>;
|
|
6
|
-
export type TempWorkspaceNumericIdentity = Readonly<{
|
|
7
|
-
dev: number;
|
|
8
|
-
ino: number;
|
|
9
|
-
}>;
|
|
10
|
-
export type TempWorkspaceIdentityStat = BigIntStats | Stats;
|
|
11
|
-
export declare const TEMP_WORKSPACE_NUMERIC_IDENTITY_REPLAY: boolean;
|
|
12
|
-
export declare function projectTempWorkspaceNumericIdentity(identity: TempWorkspaceIdentity): TempWorkspaceNumericIdentity | undefined;
|
|
13
|
-
export declare function inspectTempWorkspaceDescriptorIdentitySync(fd: number, expected: TempWorkspaceIdentity, numeric: TempWorkspaceNumericIdentity | undefined): TempWorkspaceIdentityStat;
|
|
14
|
-
export declare function inspectTempWorkspaceDirectoryIdentitySync(dir: string, expected: TempWorkspaceIdentity, numeric: TempWorkspaceNumericIdentity | undefined): TempWorkspaceIdentityStat;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import fsSync, {} from "node:fs";
|
|
2
|
-
import { observeDirectoryIdentitySync } from "./directory-guard.js";
|
|
3
|
-
import { FsSafeError } from "./errors.js";
|
|
4
|
-
import { recordFileObservationFailure } from "./file-observation.js";
|
|
5
|
-
import { inspectFileIdentitySync } from "./strict-file-identity.js";
|
|
6
|
-
export const TEMP_WORKSPACE_NUMERIC_IDENTITY_REPLAY = process.platform === "linux" || process.platform === "darwin";
|
|
7
|
-
export function projectTempWorkspaceNumericIdentity(identity) {
|
|
8
|
-
const dev = Number(identity.dev);
|
|
9
|
-
const ino = Number(identity.ino);
|
|
10
|
-
if (!Number.isSafeInteger(dev) || dev < 0 || BigInt(dev) !== identity.dev ||
|
|
11
|
-
!Number.isSafeInteger(ino) || ino < 0 || BigInt(ino) !== identity.ino) {
|
|
12
|
-
return undefined;
|
|
13
|
-
}
|
|
14
|
-
return Object.freeze({ dev, ino });
|
|
15
|
-
}
|
|
16
|
-
function identityMismatch() {
|
|
17
|
-
const error = new FsSafeError("path-mismatch", "file identity changed or could not be verified");
|
|
18
|
-
recordFileObservationFailure(error, "identity");
|
|
19
|
-
throw error;
|
|
20
|
-
}
|
|
21
|
-
function inspectNumericIdentity(current, expected) {
|
|
22
|
-
if (!Number.isSafeInteger(current.dev) || current.dev < 0 || current.dev !== expected.dev ||
|
|
23
|
-
!Number.isSafeInteger(current.ino) || current.ino < 0 || current.ino !== expected.ino) {
|
|
24
|
-
identityMismatch();
|
|
25
|
-
}
|
|
26
|
-
return current;
|
|
27
|
-
}
|
|
28
|
-
export function inspectTempWorkspaceDescriptorIdentitySync(fd, expected, numeric) {
|
|
29
|
-
// A malformed or mismatched numeric observation is definite and never
|
|
30
|
-
// retried. Unsafe receipts and other platforms retain exact replay.
|
|
31
|
-
if (TEMP_WORKSPACE_NUMERIC_IDENTITY_REPLAY && numeric) {
|
|
32
|
-
return inspectNumericIdentity(fsSync.fstatSync(fd), numeric);
|
|
33
|
-
}
|
|
34
|
-
return inspectFileIdentitySync(() => fsSync.fstatSync(fd, { bigint: true }), expected);
|
|
35
|
-
}
|
|
36
|
-
export function inspectTempWorkspaceDirectoryIdentitySync(dir, expected, numeric) {
|
|
37
|
-
if (TEMP_WORKSPACE_NUMERIC_IDENTITY_REPLAY && numeric) {
|
|
38
|
-
return inspectNumericIdentity(observeDirectoryIdentitySync(dir), numeric);
|
|
39
|
-
}
|
|
40
|
-
return inspectFileIdentitySync(() => observeDirectoryIdentitySync(dir, { bigint: true }), expected);
|
|
41
|
-
}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { BigIntStats, Stats } from "node:fs";
|
|
2
|
-
export declare function validateTempWorkspaceDirMode(mode: number): void;
|
|
3
|
-
export declare function assertTrustedTempWorkspaceDirectory(stat: Pick<BigIntStats, "uid" | "mode"> | Pick<Stats, "uid" | "mode">, uid: number | undefined, child?: boolean): void;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { FsSafeError } from "./errors.js";
|
|
2
|
-
export function validateTempWorkspaceDirMode(mode) {
|
|
3
|
-
if (!Number.isInteger(mode) || mode < 0 || mode > 0o7777) {
|
|
4
|
-
throw new FsSafeError("insecure-permissions", "temp workspace dirMode must be permission bits");
|
|
5
|
-
}
|
|
6
|
-
if (process.platform !== "win32" && (mode & 0o022) !== 0) {
|
|
7
|
-
throw new FsSafeError("insecure-permissions", "temp workspace must not be group/world writable");
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
export function assertTrustedTempWorkspaceDirectory(stat, uid, child = false) {
|
|
11
|
-
if (uid === undefined)
|
|
12
|
-
return;
|
|
13
|
-
const ownedByUser = typeof stat.uid === "bigint" ? stat.uid === BigInt(uid) : stat.uid === uid;
|
|
14
|
-
const ownedByRoot = typeof stat.uid === "bigint" ? stat.uid === 0n : stat.uid === 0;
|
|
15
|
-
if (!ownedByUser && (child || !ownedByRoot)) {
|
|
16
|
-
throw new FsSafeError("not-owned", "temp workspace directory has an untrusted owner");
|
|
17
|
-
}
|
|
18
|
-
// A root/current-user-owned sticky directory protects children owned by us,
|
|
19
|
-
// including the usual shared system temp directory. Never chmod that parent.
|
|
20
|
-
const writable = typeof stat.mode === "bigint"
|
|
21
|
-
? (stat.mode & 18n) !== 0n
|
|
22
|
-
: Number.isSafeInteger(stat.mode) && stat.mode >= 0 && (stat.mode & 0o022) !== 0;
|
|
23
|
-
const sticky = typeof stat.mode === "bigint"
|
|
24
|
-
? (stat.mode & 512n) !== 0n
|
|
25
|
-
: Number.isSafeInteger(stat.mode) && stat.mode >= 0 && (stat.mode & 0o1000) !== 0;
|
|
26
|
-
if (typeof stat.mode !== "bigint" && (!Number.isSafeInteger(stat.mode) || stat.mode < 0)) {
|
|
27
|
-
throw new FsSafeError("insecure-permissions", "temp workspace directory permissions are invalid");
|
|
28
|
-
}
|
|
29
|
-
if (writable && (child || !sticky)) {
|
|
30
|
-
throw new FsSafeError("insecure-permissions", "temp workspace directory is group/world writable without sticky protection");
|
|
31
|
-
}
|
|
32
|
-
}
|
|
File without changes
|