DefinitelyTyped/types/easy-rbac/index.d.ts
Adam Zerella 76168b497f
Typing for "easy-rbac" (#43149)
Co-authored-by: Adam Zerella <adamzerella@users.noreply.github.com>
2020-03-26 22:23:08 -07:00

27 lines
704 B
TypeScript

// Type definitions for easy-rbac 3.1
// Project: https://github.com/DeadAlready/easy-rbac
// Definitions by: Adam Zerella <https://github.com/adamzerella>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface RoleObject {
name: string;
when: (params: object) => Promise<boolean>;
}
interface Roles {
[key: string]: {
can: Array<string|RoleObject>;
inherits?: string[];
};
}
type Options = Roles | (() => Promise<Roles>) | Promise<Roles>;
declare class RBAC {
constructor(opts: Options);
can(role: string|string[]|Roles[], operation: string, params?: object): Promise<boolean>;
static create(opts: Options): RBAC;
}
export = RBAC;