Skip to main content
Home

Built and signed on GitHub Actions

Works with
This package works with Node.js, Deno, BrowsersIt is unknown whether this package works with Cloudflare Workers, Bun
It is unknown whether this package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
It is unknown whether this package works with Bun
This package works with Browsers
JSR Score88%
Downloads5/wk
Published8 months ago (0.7.0)

A flexible and type-safe permission system for TypeScript/JavaScript applications.

default

Quick Permission Library

f
and

Combines rules with AND logic.

f
merge

Merges multiple rules into a single rule.

f
not

Inverts the result of a rule.

f
or

Combines rules with OR logic.

f
schema

Creates a typed permission schema with validation and default state generation.

core/hierarchy

Hierarchy management for the permission system

f
createDefaultStateSet

Creates a state set with default values for all permissions in a hierarchy

f
flatHierarchy

Creates a flat representation of a permission hierarchy

f
hierarchy

Creates a permission hierarchy object

f
satisfiedBy

Finds all permissions that are satisfied by a given key in the hierarchy

core/permission

Core permission module for creating and configuring permissions

f
permission

Creates a permission object with schemas, rules, optional children and default state

f
rule

Creates a typed permission rule with the specified schemas and validation logic.

core/validation

Validation logic for the permission system

f
convertFlatStatesToObject

Converts a flat array of permission state tuples to a standard permission state set This allows using the tuple format for storage while keeping the internal validation logic unchanged

f
validate

Validates a permission request against a set of permission states

f
validateWithFlatStates

Validates a permission request using a flat array of permission states This is an alternative to the standard validate function that accepts a more database-friendly format

f
allowOwner
No documentation available
f
allowSelf
No documentation available
f
allowTarget

Creates a rule that validates target-based permissions

I
AllowTargetOptions
No documentation available
f
denySelf
No documentation available
f
ensureTime

Creates a rule that validates time constraints

f
owner

Creates an owner schema for permission validation

T
OwnerRequest

Request type for ownership schema Requires both 'from' and 'owner' properties as strings

T
OwnerState

State type for ownership schema No specific state structure is required

f
target

Creates a target schema for permission validation

T
TargetRequest

Request type for target schema Requires both 'from' and 'target' properties as strings

T
TargetState

State type for target schema Requires an array of target strings

f
time

Creates a time schema for permission validation

T
TimeRequest

Request type for time schema Optional date to check instead of using current time

T
TimeState

State type for time schema Optional start and end dates for the permission time window

T
ExtractSchemasFromRules

Utility type to extract all unique schemas from rules

T
FlatHierarchy

Flattens a hierarchy into a structure with paths and values

T
FlatPermissionStateArray

Represents a flat array of permission state entries This is an alternative to PermissionStateSet that uses tuples instead of an object

T
Hierarchy

Defines the structure of a permission hierarchy

T
Permission

Defines a permission node within a hierarchy

T
PermissionElement

Represents a specific permission element within a hierarchy

T
PermissionHierarchy

Represents a processed permission hierarchy with additional metadata

T
PermissionKey

Represents the key of a permission within a hierarchy

T
PermissionRequests

Represents the requests associated with a permission

T
PermissionSchemas

Combines explicit schemas with those extracted from rules

T
PermissionStates

Represents the states associated with a permission

T
PermissionStateSet

Represents a permission state set for a hierarchy

T
PermissionStateTuple

Represents a flat permission state entry using a tuple format This format is easier to store in databases as it avoids nested objects

v
VALIDATION_RESULT

Constants defining the possible outcomes of a validation operation

T
ValidationError

Describes an error that occurred during permission validation

T
ValidationResult

Result of a permission validation operation

T
ValidationResultType

The type of result returned by a rule validation

T
Rule

Represents a permission rule that validates requests against state

T
Schema

Represents a schema that defines and validates state and request structures

T
SchemasRequests

Utility type that merges the Request types from an array of schemas

T
SchemasStates

Utility type that merges the State types from an array of schemas

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.