auth/grant_path_schema.ts

Grant-path registry — the surfaces through which a role can be granted to an actor.

Four builtins:

  • admin — granted by an admin via role_grant_offer_create (subject to the consumer's authorize callback) or admin-side direct grant.
  • self_service — toggled by the holder themselves via self_service_role_set (allowlisted by eligible_roles).
  • system — granted by system code paths (signup, automation, etc.) that don't fit either of the above.
  • bootstrap — granted exactly once during the bootstrap flow (keeper, admin on a fresh install).

Open registry on top so consumers can declare additional paths (e.g. 'invite_only', 'sso_assertion') without an upstream release. RoleSpec.grant_paths references entries from this registry; the default for admin_actions.grantable_roles is grant_paths.includes('admin'), the default for self_service_role_actions eligibility is grant_paths.includes('self_service'). Mirrors the open-registry pattern used for RoleName, ScopeKindName, CredentialTypeName, and AuditEventTypeName.

view source

Declarations
#

11 declarations

builtin_grant_path_meta
#

auth/grant_path_schema.ts view source

ReadonlyMap<string, GrantPathMeta>

type ReadonlyMap<string, GrantPathMeta>

import {builtin_grant_path_meta} from '@fuzdev/fuz_app/auth/grant_path_schema.js';

Builtin grant-path metadata. Not overridable by consumers.

Typed ReadonlyMap for the contract — but JS Maps don't honor Object.freeze for .set / .delete / .clear (they mutate internal slots, not own properties), so freeze adds no runtime guard here. Read once at startup by create_grant_path_registry; runtime mutation has no effect on already-built schemas.

BUILTIN_GRANT_PATHS
#

auth/grant_path_schema.ts view source

readonly ["admin", "self_service", "system", "bootstrap"] import {BUILTIN_GRANT_PATHS} from '@fuzdev/fuz_app/auth/grant_path_schema.js';

The builtin grant-path names as a const tuple.

BuiltinGrantPath
#

auth/grant_path_schema.ts view source

"bootstrap" | "admin" | "self_service" | "system"

type "bootstrap" | "admin" | "self_service" | "system"

import type {BuiltinGrantPath} from '@fuzdev/fuz_app/auth/grant_path_schema.js';

A builtin grant-path name.

create_grant_path_registry
#

auth/grant_path_schema.ts view source

(consumer_paths?: Record<string, GrantPathMeta>): GrantPathRegistry import {create_grant_path_registry} from '@fuzdev/fuz_app/auth/grant_path_schema.js';

Create a grant-path registry from the builtin set plus optional consumer-declared additions.

Builtins (admin, self_service, system, bootstrap) are always present; consumer entries that collide with a builtin name throw at construction. Pass the result into create_role_registry's optional grant_paths parameter so each role's grant_paths entries are validated against this set at construction time.

consumer_paths?

optional consumer-declared grant-path set with optional metadata

type Record<string, GrantPathMeta>
optional default {}

returns

GrantPathRegistry

{grant_paths} — the metadata map

throws

  • Error - if any `consumer_paths` key fails `GrantPathName` (its grammar or its length cap), collides with a builtin name, or appears more than once

examples

// simple — builtins only const {grant_paths} = create_grant_path_registry(); // with consumer extensions const {grant_paths} = create_grant_path_registry({ invite_only: {description: 'Granted by claiming a consumer-issued invite.'}, });

GRANT_PATH_ADMIN
#

auth/grant_path_schema.ts view source

"admin" import {GRANT_PATH_ADMIN} from '@fuzdev/fuz_app/auth/grant_path_schema.js';

Admin-mediated grant — role_grant_offer_create plus admin-direct flows.

GRANT_PATH_BOOTSTRAP
#

auth/grant_path_schema.ts view source

"bootstrap" import {GRANT_PATH_BOOTSTRAP} from '@fuzdev/fuz_app/auth/grant_path_schema.js';

Bootstrap grant — one-shot flow during the keep's first-run bootstrap.

GRANT_PATH_SELF_SERVICE
#

auth/grant_path_schema.ts view source

"self_service" import {GRANT_PATH_SELF_SERVICE} from '@fuzdev/fuz_app/auth/grant_path_schema.js';

Self-service grant — caller toggles their own role_grant via self_service_role_set.

GRANT_PATH_SYSTEM
#

auth/grant_path_schema.ts view source

"system" import {GRANT_PATH_SYSTEM} from '@fuzdev/fuz_app/auth/grant_path_schema.js';

System-mediated grant — signup hooks, automation, internal service flows.

GrantPathMeta
#

auth/grant_path_schema.ts view source

GrantPathMeta import type {GrantPathMeta} from '@fuzdev/fuz_app/auth/grant_path_schema.js';

Per-grant-path metadata. description is admin-UI-facing copy (mirrors RoleSpec.description and ScopeKindMeta.description). Open shape so v2 can extend without a breaking change.

description?

type string

GrantPathName
#

GrantPathRegistry
#

Depends on
#

Imported by
#