auth/name_schema.ts

The name grammar the auth vocabularies share: runs of lowercase letters joined by single underscores, at most NAME_LENGTH_MAX characters.

Role names (RoleName), scope kinds (ScopeKindName), grant paths (GrantPathName), credential types (CredentialTypeName) and a token's surface: name (is_route_scope_capability) all hold it, and the audit event type (AuditEventTypeName) takes its length cap over a grammar of its own. Each domain keeps its own label in its messages, so the rule is shared and the wording is not: create_name_schema('Role') says Role names must …. The Rust spine's is_valid_name and NAME_LENGTH_MAX are its twin.

view source

Declarations
#

6 declarations

create_name_schema
#

auth/name_schema.ts view source

(label: string): PipeSchema<string, PipeSchema<string, StringSchema>> import {create_name_schema} from '@fuzdev/fuz_app/auth/name_schema.js';

A @fuzdev/fuz_schema schema for a name of one domain: bounded_string at NAME_LENGTH_MAX, then NAME_REGEX, each with the domain's message. A string both too long and off the grammar gets the one length issue, as the pipe stops at its first failing step; a value that is no string gets fuz_schema's message. Its JSON Schema is maxLength and pattern.

label

the domain's label, capitalized, e.g. 'Role' or 'Scope-kind'

type string

returns

PipeSchema

the name schema

format_name_length_message
#

auth/name_schema.ts view source

(label: string): string import {format_name_length_message} from '@fuzdev/fuz_app/auth/name_schema.js';

The message of a name longer than NAME_LENGTH_MAX.

label

the domain's label, capitalized, e.g. 'Role' or 'Scope-kind'

type string

returns

string

<label> names must be at most 64 characters

format_name_pattern_message
#

auth/name_schema.ts view source

(label: string): string import {format_name_pattern_message} from '@fuzdev/fuz_app/auth/name_schema.js';

The message of a name off NAME_REGEX.

label

the domain's label, capitalized, e.g. 'Role' or 'Scope-kind'

type string

returns

string

<label> names must be lowercase letters and underscores (a-z_), no leading, trailing or consecutive underscores

is_valid_name
#

NAME_LENGTH_MAX
#

auth/name_schema.ts view source

64 import {NAME_LENGTH_MAX} from '@fuzdev/fuz_app/auth/name_schema.js';

The longest name the grammar admits, in UTF-16 code units (what String.length measures; for a name on NAME_REGEX they are its characters). A name is caller-chosen text until it passes the grammar, and some are copied into a row or an audit row where they enter, so the grammar bounds the length too. Same value as the Rust spine's NAME_LENGTH_MAX.

NAME_REGEX
#

auth/name_schema.ts view source

RegExp import {NAME_REGEX} from '@fuzdev/fuz_app/auth/name_schema.js';

The grammar of a name: runs of lowercase letters (a-z) joined by single underscores. Rejects empty strings, leading, trailing or consecutive underscores, uppercase, digits, and the partial unique indexes' 'GLOBAL' token.

Depends on
#

Imported by
#