Skip to main content

Module permissions

Module permissions 

Source
Expand description

The realm’s permission container, and the checks every module makes.

The policy itself is ferrijs_permissions; this module is where it meets QuickJS: the Container is stored as context userdata, each fs / os / network entry point calls one of the check_* helpers, and a refusal is thrown into JS as a PermissionDeniedError carrying Node’s ERR_ACCESS_DENIED code plus the permission and resource Node attaches.

A realm with no container installed is unrestricted. The ferrijs runtime always installs one (deny-all unless the host grants more); a host embedding this crate without the runtime calls install itself, or gets a standard library with no sandbox.

The container is the realm’s for its whole life and only narrows. Nothing here carries a policy across a callback: a timer fires under the same container it was armed under, because there is only one.

Functions§

check_env
Errors
check_net
Errors
check_read
Errors
check_sys
Errors
check_write
Errors
container
The realm’s container, if a host installed one.
drop
Give up resource under kind (or the whole kind) for good: Node’s process.permission.drop. Nothing when no container is installed.
has
Whether kind covers resource right now, for a has()-style query. Unrestricted when no container is installed.
install
Install the realm’s container. A second call replaces the first.
throw_denied
Throw denied into JS as a PermissionDeniedError.