Line

packages/core/dir-browser

Allowlisted, directories-only filesystem browser.

Core engine, v0.9. Source: packages/core/dir-browser.mjs.

Classes#

DirBrowseError#

Defined in: packages/core/dir-browser.mjs:24

A directory-browse failure that carries the HTTP status the Cockpit server should answer with (403 for outside the allowed roots or unreadable, 404 for missing).

Extends#

  • Error

Constructors#

Constructor

new DirBrowseError(status, message): DirBrowseError

Defined in: packages/core/dir-browser.mjs:25

Parameters
status

any

message

any

Returns

DirBrowseError

Overrides

Error.constructor

Properties#

name

name: string

Defined in: packages/core/dir-browser.mjs:27

Inherited from

Error.name

status

status: any

Defined in: packages/core/dir-browser.mjs:28

Variables#

DEFAULT_LIMIT#

const DEFAULT_LIMIT: 200 = 200

Defined in: packages/core/dir-browser.mjs:17


MAX_LIMIT#

const MAX_LIMIT: 500 = 500

Defined in: packages/core/dir-browser.mjs:18

Functions#

detectProject()#

detectProject(dir): object

Defined in: packages/core/dir-browser.mjs:86

Marker flags for one directory: which well-known project files it holds. Booleans only.

Parameters#

dir

any

Returns#

object

hasArchitectureYml

hasArchitectureYml: any

hasPackageJson

hasPackageJson: any

isConstructProject

isConstructProject: any = hasArchitectureYml

isReact

isReact: boolean


isInside()#

isInside(root, target): boolean

Defined in: packages/core/dir-browser.mjs:49

True if target equals root or is nested under it (both must already be real paths).

Parameters#

root

any

target

any

Returns#

boolean


listDirectories()#

listDirectories(options?): object

Defined in: packages/core/dir-browser.mjs:136

List the sub-directories of requested (default: first root).

Parameters#

options?
limit?

number

Page size (clamped to the module maximum).

offset?

number

Entries to skip.

path?

string

Directory to list; defaults to the first allowed root.

roots?

string[]

Allowed roots; nothing outside them can be listed.

showHidden?

boolean = false

Include dot-directories.

Returns#

object

parent is null when path is itself a root (cannot navigate above the allowlist).

entries

entries: any

limit

limit: any

offset

offset: any

parent

parent: any

path

path: any

roots

roots: any

total

total: any

truncated

truncated: any

Throws#

When the path is outside the roots or not readable.


normalizeRoots()#

normalizeRoots(roots): any[]

Defined in: packages/core/dir-browser.mjs:55

Realpath + dedupe the configured roots; roots that do not exist / are not directories are dropped.

Parameters#

roots

any

Returns#

any[]


resolveAllowedPath()#

resolveAllowedPath(requested, roots): any

Defined in: packages/core/dir-browser.mjs:100

Resolve a requested path to a real path inside the allowlist, or throw 400/403/404.

Parameters#

requested

any

roots

any

Returns#

any