-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
479 additions
and
463 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1 @@ | ||
[fast-rbac](README.md) | ||
|
||
# fast-rbac | ||
|
||
## Index | ||
|
||
### Classes | ||
|
||
* [RBAC](classes/rbac.md) | ||
|
||
### Variables | ||
|
||
* [SEPARATOR](README.md#const-separator) | ||
|
||
### Functions | ||
|
||
* [flatten](README.md#private-flatten) | ||
* [mergeRoles](README.md#private-mergeroles) | ||
|
||
## Variables | ||
|
||
### `Const` SEPARATOR | ||
|
||
• **SEPARATOR**: *":"* = ":" | ||
|
||
Defined in index.ts:3 | ||
|
||
## Functions | ||
|
||
### `Private` flatten | ||
|
||
▸ **flatten**(`object`: object, `separator`: string): *object* | ||
|
||
Defined in utils.ts:4 | ||
|
||
**Parameters:** | ||
|
||
Name | Type | Default | | ||
------ | ------ | ------ | | ||
`object` | object | - | | ||
`separator` | string | "." | | ||
|
||
**Returns:** *object* | ||
|
||
* \[ **key**: *string*\]: any | ||
|
||
___ | ||
|
||
### `Private` mergeRoles | ||
|
||
▸ **mergeRoles**(`dst`: object, ...`srcs`: Array‹object›): *object* | ||
|
||
Defined in utils.ts:42 | ||
|
||
**Parameters:** | ||
|
||
Name | Type | | ||
------ | ------ | | ||
`dst` | object | | ||
`...srcs` | Array‹object› | | ||
|
||
**Returns:** *object* | ||
|
||
* \[ **key**: *string*\]: any | ||
Fast RBAC - v1.3.0 / [Modules](modules.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
[Fast RBAC - v1.3.0](../README.md) / [Modules](../modules.md) / [index](../modules/index.md) / RBAC | ||
|
||
# Class: RBAC | ||
|
||
[index](../modules/index.md).RBAC | ||
|
||
RBAC classref | ||
|
||
## Table of contents | ||
|
||
### Constructors | ||
|
||
- [constructor](index.rbac-1.md#constructor) | ||
|
||
### Methods | ||
|
||
- [add](index.rbac-1.md#add) | ||
- [can](index.rbac-1.md#can) | ||
- [remove](index.rbac-1.md#remove) | ||
|
||
## Constructors | ||
|
||
### constructor | ||
|
||
• **new RBAC**(`options?`) | ||
|
||
RBAC constructor | ||
|
||
#### Parameters | ||
|
||
| Name | Type | Description | | ||
| :-------- | :--------------------------------------------- | :----------- | | ||
| `options` | [Options](../interfaces/index.rbac.options.md) | RBAC options | | ||
|
||
#### Defined in | ||
|
||
[index.ts:44](https://github.com/SkeLLLa/fast-rbac/blob/e543d2b/src/index.ts#L44) | ||
|
||
## Methods | ||
|
||
### add | ||
|
||
▸ **add**(`role`, `resource`, `operation`, `when?`): `void` | ||
|
||
Adds new role to rules. | ||
|
||
**`version`** 1.1.X | ||
|
||
#### Parameters | ||
|
||
| Name | Type | Description | | ||
| :---------- | :---------------------------------------------- | :----------------------------- | | ||
| `role` | `string` | user role | | ||
| `resource` | `string` | resource to access | | ||
| `operation` | `string` | allowed operation | | ||
| `when?` | [WhenFn](../modules/index.rbac.md#whenfn)<any\> | function for additional checks | | ||
|
||
#### Returns | ||
|
||
`void` | ||
|
||
#### Defined in | ||
|
||
[index.ts:95](https://github.com/SkeLLLa/fast-rbac/blob/e543d2b/src/index.ts#L95) | ||
|
||
--- | ||
|
||
### can | ||
|
||
▸ **can**(`role`, `resource`, `operation?`): `boolean` | ||
|
||
Checks if user can perform operation without checking when condition. | ||
|
||
**`version`** 1.X.X | ||
|
||
#### Parameters | ||
|
||
| Name | Type | Description | | ||
| :----------- | :------- | :-------------------- | | ||
| `role` | `string` | user role | | ||
| `resource` | `string` | resource to access | | ||
| `operation?` | `string` | operation on resource | | ||
|
||
#### Returns | ||
|
||
`boolean` | ||
|
||
true if role has access to resources | ||
|
||
#### Defined in | ||
|
||
[index.ts:153](https://github.com/SkeLLLa/fast-rbac/blob/e543d2b/src/index.ts#L153) | ||
|
||
▸ **can**<TContext\>(`role`, `resource`, `operation`, `context`): `Promise`<boolean\> | ||
|
||
Checks if user can perform operation with checking when condition if it's provided. | ||
|
||
**`version`** 1.X.X | ||
|
||
#### Type parameters | ||
|
||
| Name | Type | | ||
| :--------- | :----------------- | | ||
| `TContext` | `TContext` = `any` | | ||
|
||
#### Parameters | ||
|
||
| Name | Type | Description | | ||
| :---------- | :--------- | :---------------------------------------------- | | ||
| `role` | `string` | user role | | ||
| `resource` | `string` | resource to access | | ||
| `operation` | `string` | operation on resource | | ||
| `context` | `TContext` | context passed to when function, set it to null | | ||
|
||
#### Returns | ||
|
||
`Promise`<boolean\> | ||
|
||
true if role has access to resources. | ||
|
||
#### Defined in | ||
|
||
[index.ts:165](https://github.com/SkeLLLa/fast-rbac/blob/e543d2b/src/index.ts#L165) | ||
|
||
--- | ||
|
||
### remove | ||
|
||
▸ **remove**(`role`, `resource?`, `operation?`): `void` | ||
|
||
Remove rule(s). | ||
|
||
**`version`** 1.1.X | ||
|
||
#### Parameters | ||
|
||
| Name | Type | Default value | Description | | ||
| :---------- | :------- | :------------ | :----------------- | | ||
| `role` | `string` | `undefined` | user role | | ||
| `resource` | `string` | '\*' | resource to access | | ||
| `operation` | `string` | '\*' | operation | | ||
|
||
#### Returns | ||
|
||
`void` | ||
|
||
#### Defined in | ||
|
||
[index.ts:116](https://github.com/SkeLLLa/fast-rbac/blob/e543d2b/src/index.ts#L116) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[Fast RBAC - v1.3.0](../README.md) / [Modules](../modules.md) / [index](../modules/index.md) / [RBAC](../modules/index.rbac.md) / OperationRules | ||
|
||
# Interface: OperationRules | ||
|
||
[index](../modules/index.md).[RBAC](../modules/index.rbac.md).OperationRules | ||
|
||
Operation permission list. | ||
|
||
## Indexable | ||
|
||
▪ [operationName: `string`]: `boolean` \| [WhenFn](../modules/index.rbac.md#whenfn) | ||
|
||
Operation permission. | ||
|
||
**`description`** `true` if allowed or `function` if need additional dynamic checks | ||
|
||
**`see`** [RBAC.WhenFn](../modules/index.rbac.md#whenfn) |
Oops, something went wrong.