IF Commons GitHub

governance/options

Written to: 4 requirements: 4 proved, 0 partly, 0 failing, 0 with no test recorded. 0002-anyfs-serve-governance FR-005, 0002-anyfs-serve-governance FR-006, 0002-anyfs-serve-governance FR-007, 0002-anyfs-serve-governance FR-008

The options of the server, as types: where it may listen (Exposure), who may ask (Authenticator), what it holds (Limits), what it does with the files a desktop makes by itself (Junk), whether an empty collection is kept as an object (Directories) and how a name that is not in the normal form of Unicode is met (Unicode). Each has a default that is the safe one.

import { DEFAULT_LIMITS, LOOPBACK_HOSTS } from "./options.ts";
DEFAULT_LIMITS.maxBody; // 67108864
LOOPBACK_HOSTS; // ["127.0.0.1", "localhost", "[::1]"]

Source: commons/anyfs-serve/src/governance/options.ts

7 of 14 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

Exposuretypeno test imports it
type Exposure = { readonly kind: "loopback" } | { readonly kind: "exposed"; readonly hostname: string; readonly hosts: readonly string[] };

Where the server may listen: on the loopback only, or on an address that the program names and the hosts that may be asked for.

LOOPBACKconst
const LOOPBACK: Exposure

The loopback exposure: the default.

Imported by 8 tests of the run (8 passed, 0 failed): the library's results

LOOPBACK_HOSTSconst
const LOOPBACK_HOSTS: readonly string[]

The host names that reach the loopback.

Imported by 8 tests of the run (8 passed, 0 failed): the library's results

hostsOffunction
function hostsOf(exposure: Exposure): readonly string[]

The hosts an exposure allows in the Host header, without ports. An exposure to a named address needs at least one host.

Imported by 8 tests of the run (8 passed, 0 failed): the library's results

exposefunction
function expose(hostname: string, hosts: readonly string[]): Result<Exposure, string>

An exposure to an address, or why it is not one: a name or an address, and at least one host that may be asked for.

Imported by 12 tests of the run (12 passed, 0 failed): the library's results

Credentialstypeno test imports it
type Credentials = { readonly scheme: "basic"; readonly user: string; readonly secret: string } | { readonly scheme: "bearer"; readonly secret: string };

What a caller sends to show who it is: a password with a user name (a desktop asks for one), or a bearer token.

Authenticatortypeno test imports it
type Authenticator = (credentials: Credentials | undefined) => Promise<boolean>;

Whether a caller may ask: what it sent, or nothing. It does not throw.

Limitstypeno test imports it
type Limits = { /** The most bytes of an object a PUT may carry. */ readonly maxBody: number; /** The most bytes o… (609 characters)
type Limits = {
  /** The most bytes of an object a PUT may carry. */
  readonly maxBody: number;
  /** The most bytes of an XML request. */
  readonly maxXml: number;
  /** The deepest an XML request nests. */
  readonly maxXmlDepth: number;
  /** The most elements, attributes and texts an XML request holds. */
  readonly maxXmlNodes: number;
  /** The longest a lock lasts, in seconds, whatever the caller asks. */
  readonly maxLockSeconds: number;
  /** The most locks at once. */
  readonly maxLocks: number;
  /** The most resources one multistatus answer holds. */
  readonly maxResources: number;
};

What the server holds and for how long, so that a caller cannot make it use all it has.

DEFAULT_LIMITSconst
const DEFAULT_LIMITS: Limits

The limits: 64 MiB of an object, 1 MiB of XML nested 32 deep with 20000 parts, locks of an hour at most, 1000 of them, and 10000 resources of an answer.

Imported by 8 tests of the run (8 passed, 0 failed): the library's results

withLimitsfunction
function withLimits(base: Limits, changes: Partial<Limits>): Result<Limits, string>

The limits with changes, or why they make none: every one a whole number of at least 1.

Imported by 8 tests of the run (8 passed, 0 failed): the library's results

Junktypeno test imports it
type Junk = "allow" | "hide" | "refuse";

What the server does with the files a desktop makes by itself (.DS_Store, ._*, Thumbs.db, desktop.ini): lets them be, keeps them out of listings, or refuses to make them.

isJunkNamefunction
function isJunkName(name: string): boolean

Whether a name is one of those files.

Imported by 8 tests of the run (8 passed, 0 failed): the library's results

Directoriestypeno test imports it
type Directories = "markers" | "virtual";

Whether an empty collection is kept as an object (markers: a marker below it, which the listing hides) or only while an object lies below it (virtual: nothing is written).

Unicodetypeno test imports it
type Unicode = "nfc" | "refuse";

What the server does with a name that is not in the normal form of Unicode (NFC): turns it into that form, or refuses it.

Titles, headings, exports, tables, columns and requirements. Esc closes.