Skip to content

Exports

The full public surface of the package, by entry point.

Main entry — @alexify/kerberos

ExportPurpose
KerberosMain authorization engine.
Effect{ Allow: 'EFFECT_ALLOW', Deny: 'EFFECT_DENY' } — a frozen const object, not an enum.
ResourcePolicy, PrincipalPolicy, RolePolicy, DerivedRolesPolicy classes (rarely constructed directly).
Conditions, Variables, Constants, OutputsDSL building blocks.
createSafeExprCodec, serializePolicy, deserializePolicySafe AST codec for dynamic/stored policies.
PlanKind{ AlwaysAllowed, AlwaysDenied, Conditional }query plan filter kinds (const object, not an enum).
expandRelationOperandsMaterializes ReBAC relation operands of a query plan into id filters.
toCerbosQueryPlanConverts a plan to the @cerbos/core SDK shape for the official Cerbos ORM adapters.
KerberosValidationError, KerberosCacheError, KerberosCodecError, KerberosExprError, KerberosRelationsError, KerberosHookErrorTyped error classes.
registerAjvKeywords, createAjvAdapterValidation helpers.
resolveValidationAdapter, toValidationAdapter, parseWithValidationBackend dispatch used by every DSL module — pick an adapter (explicit → Zod → TypeBox+Ajv → JSON Schema+Ajv → passthrough) and parse with it.
createCacheReaderWraps any get(key) store as the engine's read-only policy fallback layer.
JsonSchemas, TypeBoxSchemas, ZodSchemas, KerberosJsonSchemas, ResourcePolicyJsonSchemas, PrincipalPolicyJsonSchemas, RolePolicyJsonSchemas, …Schema builders for the three backends.
ALL_ACTIONS, ALL_ROLES, ALL_RESOURCES, DEFAULT_VERSION, BASE_SCOPEWildcard/default tokens ('*', 'default', '').

Type-only exports for typed authoring (erased at runtime):

TypePurpose
KerberosSchema, AnySchema, KerberosResourceContractShape of an application authorization schema, and the permissive default.
ResourceKindOf<S>, ActionOf<S, K>, ResourceAttrOf<S, K>Projections of the declared resource kinds.
PrincipalRoleOf<S>, PrincipalAttrOf<S>Projections of the declared principal.
RequestPrincipal<S>, RequestResource<S, K>, BaseRequest<S, K>, PolicyEvalRequest<S, K>Request shapes, including the { P, R, V, C } callback envelope.
KerberosPolicy<S>, ResourcePolicySchema<S>, PrincipalPolicySchema<S>, RolePolicySchema<S>, DerivedRolesSchema<S>Policy document shapes.
CheckResourcesArgs<S>, CheckResourcesEntry<S>, CheckResourcesResult<S, E>, CheckResourcesResponse<S, E>checkResources arguments and response.
PlanResourcesArgs<S, K>, PlanResourcesResponse<S>, PlanFilter, PlanExpressionOperandplanResources arguments and response.
KerberosHooks<S>, KerberosHookContext<S>, KerberosRequestSummary, KerberosResourceHookInfo<S>, KerberosResourceHookResult, KerberosEventsHooks & events contracts (the resolver's live in relations.d.ts: RelationResolverHooks, RelationResolverEvents).

@alexify/kerberos/relations

Opt-in ReBAC — kept out of the main entry so non-ReBAC bundles do not grow:

ExportPurpose
RelationResolverThe built-in Zanzibar-lite resolver (check / list / lookupSubjects / lookupResources).
RelationSchemaCompiles the relation-schema DSL standalone (validated schemas reusable across resolvers).
Relations*SchemasSchema builders for the resolver's shapes (three validation backends).
parseRelationSchemaShape, parseObjectRef, parseSubjectRef, parseTupleStandalone parsers/validators for schema documents, type:id refs and tuples.
buildAdmissionKeyBuilds the type + relation + subjectType admission key the compiled schema indexes by.

@alexify/kerberos/cerbos

The Cerbos policy importer — kept out of the main entry so bundles that never import Cerbos policies do not grow:

ExportPurpose
importCerbosPoliciesCerbos YAML/JSON documents → { policies, derivedRoles } serialized Kerberos documents.
celToExprTranslates one CEL expression into a $expr-compatible JavaScript expression string.
parseYamlDocumentsThe zero-dependency YAML-subset parser, standalone.
KerberosImportErrorTyped error for unsupported constructs (carries line for YAML errors).

@alexify/kerberos/loader

Node-only boot-time file/directory loader + versioned bundles (browser bundlers substitute throwing stubs):

ExportPurpose
loadPolicyDirectory, loadPolicyFileRead Kerberos JSON / Cerbos YAML+JSON policy files (+ _schemas/) into constructor inputs.
createPolicyBundle, writePolicyBundle, loadPolicyBundleHash-stamped (SHA-256, content-addressed) policy bundles with load-time integrity verification.
promisesThe asynchronous driver — the same four functions returning promises, reading files concurrently (concurrency, default 64).
KerberosLoaderErrorTyped error for I/O, format and bundle-integrity failures (carries file).

@alexify/kerberos/tests

Dev/test only — not loaded by the main entry:

ExportPurpose
KerberosTest, KerberosTestsCerbos-style declarative test runner.
PrincipalMock, PrincipalsMock, ResourceMock, ResourcesMockNamed fixtures for test suites.
*ZodSchemas, *JsonSchemas, *TypeBoxSchemasSchema builders for the test harness.

Released under the MIT License.