UNPKG

permix

Version:

Permix is a lightweight, framework-agnostic, type-safe permissions management library for JavaScript applications on the client and server sides.

25 lines (22 loc) 1.08 kB
import { P as PermixDefinition, C as CheckContext, e as PermixRules, a as Permix, h as CheckFunctionParams } from '../shared/permix.CuefdCK4.js'; import { TRPCError } from '@trpc/server'; interface PermixOptions<T extends PermixDefinition> { /** * Custom error to throw when permission is denied */ forbiddenError?: <C = unknown>(params: CheckContext<T> & { ctx: C; }) => TRPCError; } /** * Create a middleware function that checks permissions for TRPC routes. * * @link https://permix.letstri.dev/docs/integrations/trpc */ declare function createPermix<Definition extends PermixDefinition>({ forbiddenError, }?: PermixOptions<Definition>): { setup: (rules: PermixRules<Definition>) => Pick<Permix<Definition>, "check" | "dehydrate">; checkMiddleware: <K extends keyof Definition>(...params: CheckFunctionParams<Definition, K>) => any; template: <T = void>(rules: PermixRules<Definition> | ((param: T) => PermixRules<Definition>)) => (param: T) => PermixRules<Definition>; }; export { createPermix }; export type { PermixOptions };