vael:fs/acl
Cross-platform POSIX permission modes, POSIX.1e ACLs, Windows DACLs, and
extended attributes (xattr).
Available in both vjs (vaeljs) and vjs-lite (vaeljs-lite) runtimes.
Exposes capabilities() for feature detection and refuses symbolic links
by default (followSymlinks: false) with "VAEL_FS_ACL_SYMLINK_REFUSED".
Unsupported operations on a host OS or filesystem fail explicitly with
"VAEL_FS_ACL_UNSUPPORTED". Never installed on globalThis — import
explicitly from "vael:fs/acl".
import ... from "vael:fs/acl"
vaeljs-core; vael-fs (default) in vaeljs-lite-coreExample
Section titled “Example”import { capabilities, getAclSync, getModeSync, setModeSync } from "vael:fs/acl";
const caps = capabilities();if (caps.posixMode) { setModeSync("./secret.txt", 0o600); console.log(getModeSync("./secret.txt").permissions.toString(8));}console.log(getAclSync("./secret.txt").scheme);capabilitiesv0.0.0-alpha.2vael:fs/acl.getModeSyncv0.0.0-alpha.2path.setModeSyncv0.0.0-alpha.20o0000..=0o7777) on path.getAclSyncv0.0.0-alpha.2path.setAclSyncv0.0.0-alpha.2path.listXattrsSyncv0.0.0-alpha.2xattr) names on path, sorted lexicographically.getXattrSyncv0.0.0-alpha.2name on path.setXattrSyncv0.0.0-alpha.2name to value on path.removeXattrSyncv0.0.0-alpha.2name from path.AclCapabilitiesv0.0.0-alpha.2capabilities().AclPathOptionsv0.0.0-alpha.2vael:fs/acl operations.SetAclOptionsv0.0.0-alpha.2setAclSync().ModeInfov0.0.0-alpha.2getModeSync().AclEntryv0.0.0-alpha.2AclInfo.entries.AclEntryInputv0.0.0-alpha.2setAclSync().AclInfov0.0.0-alpha.2getAclSync().Functions
Section titled “Functions”capabilities
Section titled “capabilities”export function capabilities(): AclCapabilities;
Return the frozen host capability flags for vael:fs/acl.
AclCapabilities — Frozen AclCapabilities object describing supported host features.TypeError— when any argument is supplied.
getModeSync
Section titled “getModeSync”export function getModeSync(path: string, options?: AclPathOptions): ModeInfo;
Synchronously read file mode and ownership metadata for path.
When options.followSymlinks is false (default), inspects the link
itself without dereferencing.
| Name | Type | Description |
|---|---|---|
path | string | Target filesystem path. |
options optional | AclPathOptions | Optional symlink-handling options. |
ModeInfo — Frozen ModeInfo snapshot.TypeError— on wrong argument types.AclError— on invalid path, missing target, permission error, or I/O failure.
setModeSync
Section titled “setModeSync”export function setModeSync(path: string, mode: number, options?: AclPathOptions): void;
Synchronously set POSIX mode permission bits (0o0000..=0o7777) on path.
Refuses symbolic links with "VAEL_FS_ACL_SYMLINK_REFUSED" when
options.followSymlinks is false (default). On Windows, special bits
(mode & ~0o777) fail with "VAEL_FS_ACL_UNSUPPORTED" and owner write
(0o200) maps to the read-only attribute.
| Name | Type | Description |
|---|---|---|
path | string | Target filesystem path. |
mode | number | Integer permission mask in 0o0000..=0o7777. |
options optional | AclPathOptions | Optional symlink-handling options. |
voidTypeError— on wrong argument types.AclError— on invalid mode/path, symlink refusal, unsupported bits, or I/O error.
getAclSync
Section titled “getAclSync”export function getAclSync(path: string, options?: AclPathOptions): AclInfo;
Synchronously inspect the ACL of path.
Returns "posix" entries on Unix (plus Linux system.posix_acl_access
entries when present) or "windows" DACL entries on Windows.
| Name | Type | Description |
|---|---|---|
path | string | Target filesystem path. |
options optional | AclPathOptions | Optional symlink-handling options. |
AclInfo — Frozen AclInfo snapshot.TypeError— on wrong argument types.AclError— on invalid path, missing target, permission error, or unsupported OS.
setAclSync
Section titled “setAclSync”export function setAclSync(
path: string,
entries: readonly AclEntryInput[],
options?: SetAclOptions,
): void;
Synchronously update the ACL of path.
Refuses symbolic links with "VAEL_FS_ACL_SYMLINK_REFUSED" when
options.followSymlinks is false (default), and rejects unsupported
schemes, POSIX deny ACEs, or unsupported extended entries with
"VAEL_FS_ACL_UNSUPPORTED".
| Name | Type | Description |
|---|---|---|
path | string | Target filesystem path. |
entries | readonly AclEntryInput[] | ACL entries to apply. |
options optional | SetAclOptions | Optional scheme, replace mode, and symlink-handling options. |
voidTypeError— on wrong argument types.AclError— on invalid argument, symlink refusal, unsupported scheme/entry, or I/O error.
listXattrsSync
Section titled “listXattrsSync”export function listXattrsSync(path: string, options?: AclPathOptions): string[];
Synchronously list all extended attribute (xattr) names on path,
sorted lexicographically.
Fails with "VAEL_FS_ACL_UNSUPPORTED" on platforms or filesystems without
extended attribute support.
| Name | Type | Description |
|---|---|---|
path | string | Target filesystem path. |
options optional | AclPathOptions | Optional symlink-handling options. |
string[] — Sorted array of extended attribute names.TypeError— on wrong argument types.AclError— on unsupported OS/filesystem, missing path, limit exceeded, or I/O error.
getXattrSync
Section titled “getXattrSync”export function getXattrSync(
path: string,
name: string,
options?: AclPathOptions,
): Uint8Array | null;
Synchronously read the raw bytes of extended attribute name on path.
Returns null when the attribute is absent.
| Name | Type | Description |
|---|---|---|
path | string | Target filesystem path. |
name | string | Extended attribute name. |
options optional | AclPathOptions | Optional symlink-handling options. |
Uint8Array | null — Raw attribute bytes, or null if absent.TypeError— on wrong argument types.AclError— on unsupported OS/filesystem, invalid name/path, limit exceeded, or I/O error.
setXattrSync
Section titled “setXattrSync”export function setXattrSync(
path: string,
name: string,
value: Uint8Array | string,
options?: AclPathOptions,
): void;
Synchronously set extended attribute name to value on path.
Refuses symbolic links with "VAEL_FS_ACL_SYMLINK_REFUSED" when
options.followSymlinks is false (default).
| Name | Type | Description |
|---|---|---|
path | string | Target filesystem path. |
name | string | Extended attribute name. |
value | Uint8Array | string | Attribute value bytes or UTF-8 string (max 64 KiB). |
options optional | AclPathOptions | Optional symlink-handling options. |
voidTypeError— on wrong argument types.AclError— on unsupported OS/filesystem, symlink refusal, limit exceeded, or I/O error.
removeXattrSync
Section titled “removeXattrSync”export function removeXattrSync(path: string, name: string, options?: AclPathOptions): void;
Synchronously remove extended attribute name from path.
Refuses symbolic links with "VAEL_FS_ACL_SYMLINK_REFUSED" when
options.followSymlinks is false (default), and throws
"VAEL_FS_ACL_NOT_FOUND" when the attribute does not exist.
| Name | Type | Description |
|---|---|---|
path | string | Target filesystem path. |
name | string | Extended attribute name. |
options optional | AclPathOptions | Optional symlink-handling options. |
voidTypeError— on wrong argument types.AclError— on unsupported OS/filesystem, symlink refusal, missing attribute, or I/O error.
Classes
Section titled “Classes”AclError
Section titled “AclError”export class AclError extends Error {
override name: "AclError";
code: AclErrorCode;
constructor(code: AclErrorCode, message: string);
}
Error thrown by vael:fs/acl operations carrying a stable
VAEL_FS_ACL_* error code.
constructor(code: AclErrorCode, message: string);
Construct an AclError.
| Name | Type | Description |
|---|---|---|
code | AclErrorCode | Machine-readable AclErrorCode. |
message | string | Human-readable error message. |
| Property | Type | Description | Since |
|---|---|---|---|
name | "AclError" | Error name ("AclError"). | v0.0.0-alpha.2 |
code | AclErrorCode | Machine-readable VAEL_FS_ACL_* error classification. | v0.0.0-alpha.2 |
Interfaces
Section titled “Interfaces”AclCapabilities
Section titled “AclCapabilities”export interface AclCapabilities {
readonly platform: string;
readonly posixMode: boolean;
readonly posixAcl: boolean;
readonly xattr: boolean;
readonly windowsDacl: boolean;
}
Host ACL and extended-attribute capability flags returned by
capabilities().
| Property | Type | Description | Since |
|---|---|---|---|
platform readonly | string | Host operating system identifier (such as "linux", "macos", or "windows"). | v0.0.0-alpha.2 |
posixMode readonly | boolean | Whether POSIX mode permission bits (0o7777) are natively supported. | v0.0.0-alpha.2 |
posixAcl readonly | boolean | Whether extended POSIX.1e ACLs (system.posix_acl_access) are supported. | v0.0.0-alpha.2 |
xattr readonly | boolean | Whether extended attributes (listXattrsSync / getXattrSync / setXattrSync / removeXattrSync) are supported on the host OS. | v0.0.0-alpha.2 |
windowsDacl readonly | boolean | Whether Windows Discretionary Access Control Lists (DACLs) are supported. | v0.0.0-alpha.2 |
AclPathOptions
Section titled “AclPathOptions”export interface AclPathOptions {
followSymlinks?: boolean;
}
Path-traversal and symlink-handling options shared by vael:fs/acl
operations.
| Property | Type | Description | Since |
|---|---|---|---|
followSymlinks optional | boolean | Follow symbolic links instead of acting on or refusing the link itself (default false). | v0.0.0-alpha.2 |
SetAclOptions
Section titled “SetAclOptions”export interface SetAclOptions extends AclPathOptions {
scheme?: AclScheme;
replace?: boolean;
}
Options controlling setAclSync().
| Property | Type | Description | Since |
|---|---|---|---|
scheme optional | AclScheme | Expected ACL scheme ("posix" or "windows"); fails with "VAEL_FS_ACL_UNSUPPORTED" if unsupported on the host OS. | v0.0.0-alpha.2 |
replace optional | boolean | Replace existing ACL entries rather than merging (default true). | v0.0.0-alpha.2 |
ModeInfo
Section titled “ModeInfo”export interface ModeInfo {
readonly mode: number;
readonly permissions: number;
readonly owner: number | null;
readonly group: number | null;
readonly readonly: boolean;
}
Snapshot file mode and ownership metadata returned by getModeSync().
| Property | Type | Description | Since |
|---|---|---|---|
mode readonly | number | Full raw OS mode word (st_mode on Unix, basic mask on Windows). | v0.0.0-alpha.2 |
permissions readonly | number | Permission and special mode bits masked to 0o7777. | v0.0.0-alpha.2 |
owner readonly | number | null | Numeric owning user ID (uid) on Unix, or null on Windows. | v0.0.0-alpha.2 |
group readonly | number | null | Numeric owning group ID (gid) on Unix, or null on Windows. | v0.0.0-alpha.2 |
readonly readonly | boolean | Whether the filesystem entry is marked read-only. | v0.0.0-alpha.2 |
AclEntry
Section titled “AclEntry”export interface AclEntry {
readonly principal: string;
readonly allow: boolean;
readonly read: boolean;
readonly write: boolean;
readonly execute: boolean;
readonly rawMask: number | null;
}
Frozen cross-platform ACL entry returned inside AclInfo.entries.
| Property | Type | Description | Since |
|---|---|---|---|
principal readonly | string | Principal identifier ("owner", "group", "other", "mask", "user:<uid>", "group:<gid>" on POSIX; SID string on Windows). | v0.0.0-alpha.2 |
allow readonly | boolean | true for allow ACEs, false for deny ACEs (unsupported on POSIX). | v0.0.0-alpha.2 |
read readonly | boolean | Read access granted (or denied when allow is false). | v0.0.0-alpha.2 |
write readonly | boolean | Write access granted (or denied when allow is false). | v0.0.0-alpha.2 |
execute readonly | boolean | Execute/traverse access granted (or denied when allow is false). | v0.0.0-alpha.2 |
rawMask readonly | number | null | Optional platform-native bitmask (0..=7 on POSIX, Win32 ACCESS_MASK on Windows), or null if absent. | v0.0.0-alpha.2 |
AclEntryInput
Section titled “AclEntryInput”export interface AclEntryInput {
principal: string;
allow?: boolean;
read: boolean;
write: boolean;
execute: boolean;
rawMask?: number | null;
}
Input ACL entry accepted by setAclSync().
| Property | Type | Description | Since |
|---|---|---|---|
principal | string | Principal identifier ("owner", "group", "other", "mask", "user:<uid>", "group:<gid>" on POSIX; SID string on Windows). | v0.0.0-alpha.2 |
allow optional | boolean | true for allow ACEs, false for deny ACEs (default true; deny ACEs are unsupported on POSIX). | v0.0.0-alpha.2 |
read | boolean | Read permission bit. | v0.0.0-alpha.2 |
write | boolean | Write permission bit. | v0.0.0-alpha.2 |
execute | boolean | Execute/traverse permission bit. | v0.0.0-alpha.2 |
rawMask optional | number | null | Optional platform-native bitmask (0..=7 on POSIX, Win32 ACCESS_MASK on Windows). | v0.0.0-alpha.2 |
AclInfo
Section titled “AclInfo”export interface AclInfo {
readonly scheme: AclScheme;
readonly mode: number | null;
readonly entries: readonly AclEntry[];
}
Snapshot ACL information returned by getAclSync().
| Property | Type | Description | Since |
|---|---|---|---|
scheme readonly | AclScheme | Platform ACL scheme ("posix" or "windows"). | v0.0.0-alpha.2 |
mode readonly | number | null | POSIX mode bits (0o7777) when available on Unix, or null on Windows. | v0.0.0-alpha.2 |
entries readonly | readonly AclEntry[] | Frozen ordered array of ACL entries. | v0.0.0-alpha.2 |
Type Aliases
Section titled “Type Aliases”AclErrorCode
Section titled “AclErrorCode”export type AclErrorCode =
| "VAEL_FS_ACL_NOT_FOUND"
| "VAEL_FS_ACL_PERMISSION_DENIED"
| "VAEL_FS_ACL_INVALID_ARGUMENT"
| "VAEL_FS_ACL_UNSUPPORTED"
| "VAEL_FS_ACL_SYMLINK_REFUSED"
| "VAEL_FS_ACL_LIMIT_EXCEEDED"
| "VAEL_FS_ACL_IO";
Stable machine-readable VAEL_FS_ACL_* error codes exposed on
AclError.code.
AclScheme
Section titled “AclScheme”export type AclScheme = "posix" | "windows";
Platform ACL scheme identifier ("posix" or "windows").
