Skip to content
VaelJS Blog

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"
Since v0.0.0-alpha.2 vjs (V8) vjs-lite (QuickJS)
Cargo feature: Always enabled in vaeljs-core; vael-fs (default) in vaeljs-lite-core
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);
API Symbols
functionSince v0.0.0-alpha.2vjs & vjs-lite
export function capabilities(): AclCapabilities;

Return the frozen host capability flags for vael:fs/acl.

Returns
AclCapabilities — Frozen AclCapabilities object describing supported host features.
Exceptions
  • TypeError — when any argument is supplied.
functionSince v0.0.0-alpha.2vjs & vjs-lite
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.

Parameters
NameTypeDescription
pathstringTarget filesystem path.
options optionalAclPathOptionsOptional symlink-handling options.
Returns
ModeInfo — Frozen ModeInfo snapshot.
Exceptions
  • TypeError — on wrong argument types.
  • AclError — on invalid path, missing target, permission error, or I/O failure.
functionSince v0.0.0-alpha.2vjs & vjs-lite
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.

Parameters
NameTypeDescription
pathstringTarget filesystem path.
modenumberInteger permission mask in 0o0000..=0o7777.
options optionalAclPathOptionsOptional symlink-handling options.
Returns
void
Exceptions
  • TypeError — on wrong argument types.
  • AclError — on invalid mode/path, symlink refusal, unsupported bits, or I/O error.
functionSince v0.0.0-alpha.2vjs & vjs-lite
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.

Parameters
NameTypeDescription
pathstringTarget filesystem path.
options optionalAclPathOptionsOptional symlink-handling options.
Returns
AclInfo — Frozen AclInfo snapshot.
Exceptions
  • TypeError — on wrong argument types.
  • AclError — on invalid path, missing target, permission error, or unsupported OS.
functionSince v0.0.0-alpha.2vjs & vjs-lite
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".

Parameters
NameTypeDescription
pathstringTarget filesystem path.
entriesreadonly AclEntryInput[]ACL entries to apply.
options optionalSetAclOptionsOptional scheme, replace mode, and symlink-handling options.
Returns
void
Exceptions
  • TypeError — on wrong argument types.
  • AclError — on invalid argument, symlink refusal, unsupported scheme/entry, or I/O error.
functionSince v0.0.0-alpha.2vjs & vjs-lite
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.

Parameters
NameTypeDescription
pathstringTarget filesystem path.
options optionalAclPathOptionsOptional symlink-handling options.
Returns
string[] — Sorted array of extended attribute names.
Exceptions
  • TypeError — on wrong argument types.
  • AclError — on unsupported OS/filesystem, missing path, limit exceeded, or I/O error.
functionSince v0.0.0-alpha.2vjs & vjs-lite
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.

Parameters
NameTypeDescription
pathstringTarget filesystem path.
namestringExtended attribute name.
options optionalAclPathOptionsOptional symlink-handling options.
Returns
Uint8Array | null — Raw attribute bytes, or null if absent.
Exceptions
  • TypeError — on wrong argument types.
  • AclError — on unsupported OS/filesystem, invalid name/path, limit exceeded, or I/O error.
functionSince v0.0.0-alpha.2vjs & vjs-lite
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).

Parameters
NameTypeDescription
pathstringTarget filesystem path.
namestringExtended attribute name.
valueUint8Array | stringAttribute value bytes or UTF-8 string (max 64 KiB).
options optionalAclPathOptionsOptional symlink-handling options.
Returns
void
Exceptions
  • TypeError — on wrong argument types.
  • AclError — on unsupported OS/filesystem, symlink refusal, limit exceeded, or I/O error.
functionSince v0.0.0-alpha.2vjs & vjs-lite
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.

Parameters
NameTypeDescription
pathstringTarget filesystem path.
namestringExtended attribute name.
options optionalAclPathOptionsOptional symlink-handling options.
Returns
void
Exceptions
  • TypeError — on wrong argument types.
  • AclError — on unsupported OS/filesystem, symlink refusal, missing attribute, or I/O error.
classSince v0.0.0-alpha.2vjs & vjs-lite
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
constructor(code: AclErrorCode, message: string);

Construct an AclError.

Parameters
NameTypeDescription
codeAclErrorCodeMachine-readable AclErrorCode.
messagestringHuman-readable error message.
Properties
PropertyTypeDescriptionSince
name "AclError"Error name ("AclError").v0.0.0-alpha.2
code AclErrorCodeMachine-readable VAEL_FS_ACL_* error classification.v0.0.0-alpha.2
interfaceSince v0.0.0-alpha.2vjs & vjs-lite
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().

Properties
PropertyTypeDescriptionSince
platform readonlystringHost operating system identifier (such as "linux", "macos", or "windows").v0.0.0-alpha.2
posixMode readonlybooleanWhether POSIX mode permission bits (0o7777) are natively supported.v0.0.0-alpha.2
posixAcl readonlybooleanWhether extended POSIX.1e ACLs (system.posix_acl_access) are supported.v0.0.0-alpha.2
xattr readonlybooleanWhether extended attributes (listXattrsSync / getXattrSync / setXattrSync / removeXattrSync) are supported on the host OS.v0.0.0-alpha.2
windowsDacl readonlybooleanWhether Windows Discretionary Access Control Lists (DACLs) are supported.v0.0.0-alpha.2
interfaceSince v0.0.0-alpha.2vjs & vjs-lite
export interface AclPathOptions {
  followSymlinks?: boolean;
}

Path-traversal and symlink-handling options shared by vael:fs/acl operations.

Properties
PropertyTypeDescriptionSince
followSymlinks optionalbooleanFollow symbolic links instead of acting on or refusing the link itself (default false).v0.0.0-alpha.2
interfaceSince v0.0.0-alpha.2vjs & vjs-lite
export interface SetAclOptions extends AclPathOptions {
  scheme?: AclScheme;
  replace?: boolean;
}

Options controlling setAclSync().

Properties
PropertyTypeDescriptionSince
scheme optionalAclSchemeExpected ACL scheme ("posix" or "windows"); fails with "VAEL_FS_ACL_UNSUPPORTED" if unsupported on the host OS.v0.0.0-alpha.2
replace optionalbooleanReplace existing ACL entries rather than merging (default true).v0.0.0-alpha.2
interfaceSince v0.0.0-alpha.2vjs & vjs-lite
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().

Properties
PropertyTypeDescriptionSince
mode readonlynumberFull raw OS mode word (st_mode on Unix, basic mask on Windows).v0.0.0-alpha.2
permissions readonlynumberPermission and special mode bits masked to 0o7777.v0.0.0-alpha.2
owner readonlynumber | nullNumeric owning user ID (uid) on Unix, or null on Windows.v0.0.0-alpha.2
group readonlynumber | nullNumeric owning group ID (gid) on Unix, or null on Windows.v0.0.0-alpha.2
readonly readonlybooleanWhether the filesystem entry is marked read-only.v0.0.0-alpha.2
interfaceSince v0.0.0-alpha.2vjs & vjs-lite
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.

Properties
PropertyTypeDescriptionSince
principal readonlystringPrincipal identifier ("owner", "group", "other", "mask", "user:<uid>", "group:<gid>" on POSIX; SID string on Windows).v0.0.0-alpha.2
allow readonlybooleantrue for allow ACEs, false for deny ACEs (unsupported on POSIX).v0.0.0-alpha.2
read readonlybooleanRead access granted (or denied when allow is false).v0.0.0-alpha.2
write readonlybooleanWrite access granted (or denied when allow is false).v0.0.0-alpha.2
execute readonlybooleanExecute/traverse access granted (or denied when allow is false).v0.0.0-alpha.2
rawMask readonlynumber | nullOptional platform-native bitmask (0..=7 on POSIX, Win32 ACCESS_MASK on Windows), or null if absent.v0.0.0-alpha.2
interfaceSince v0.0.0-alpha.2vjs & vjs-lite
export interface AclEntryInput {
  principal: string;
  allow?: boolean;
  read: boolean;
  write: boolean;
  execute: boolean;
  rawMask?: number | null;
}

Input ACL entry accepted by setAclSync().

Properties
PropertyTypeDescriptionSince
principal stringPrincipal identifier ("owner", "group", "other", "mask", "user:<uid>", "group:<gid>" on POSIX; SID string on Windows).v0.0.0-alpha.2
allow optionalbooleantrue for allow ACEs, false for deny ACEs (default true; deny ACEs are unsupported on POSIX).v0.0.0-alpha.2
read booleanRead permission bit.v0.0.0-alpha.2
write booleanWrite permission bit.v0.0.0-alpha.2
execute booleanExecute/traverse permission bit.v0.0.0-alpha.2
rawMask optionalnumber | nullOptional platform-native bitmask (0..=7 on POSIX, Win32 ACCESS_MASK on Windows).v0.0.0-alpha.2
interfaceSince v0.0.0-alpha.2vjs & vjs-lite
export interface AclInfo {
  readonly scheme: AclScheme;
  readonly mode: number | null;
  readonly entries: readonly AclEntry[];
}

Snapshot ACL information returned by getAclSync().

Properties
PropertyTypeDescriptionSince
scheme readonlyAclSchemePlatform ACL scheme ("posix" or "windows").v0.0.0-alpha.2
mode readonlynumber | nullPOSIX mode bits (0o7777) when available on Unix, or null on Windows.v0.0.0-alpha.2
entries readonlyreadonly AclEntry[]Frozen ordered array of ACL entries.v0.0.0-alpha.2
typeSince v0.0.0-alpha.2vjs & vjs-lite
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.

typeSince v0.0.0-alpha.2vjs & vjs-lite
export type AclScheme = "posix" | "windows";

Platform ACL scheme identifier ("posix" or "windows").