1
1
import { Access , IAccessInfo , Query , IQueryInfo , Permission } from './core' ;
2
- import type { ValidRoleOrArray , ValidRole } from '.' ;
3
2
/**
4
3
* @classdesc
5
4
* AccessControl class that implements RBAC (Role-Based Access Control) basics
@@ -119,7 +118,7 @@ declare class AccessControl {
119
118
* @name AccessControl#isLocked
120
119
* @type {Boolean }
121
120
*/
122
- get isLocked ( ) : boolean ;
121
+ readonly isLocked : boolean ;
123
122
/**
124
123
* Gets the internal grants object that stores all current grants.
125
124
*
@@ -235,7 +234,7 @@ declare class AccessControl {
235
234
* @throws {AccessControlError } - If a role is extended by itself or a
236
235
* non-existent role. Or if called after `.lock()` is called.
237
236
*/
238
- extendRole ( roles : ValidRoleOrArray , extenderRoles : ValidRoleOrArray ) : AccessControl ;
237
+ extendRole ( roles : string | string [ ] , extenderRoles : string | string [ ] ) : AccessControl ;
239
238
/**
240
239
* Removes all the given role(s) and their granted permissions, at once.
241
240
* @chainable
@@ -247,7 +246,7 @@ declare class AccessControl {
247
246
*
248
247
* @throws {AccessControlError } - If called after `.lock()` is called.
249
248
*/
250
- removeRoles ( roles : ValidRoleOrArray ) : AccessControl ;
249
+ removeRoles ( roles : string | string [ ] ) : AccessControl ;
251
250
/**
252
251
* Removes all the given resources for all roles, at once.
253
252
* Pass the `roles` argument to remove access to resources for those
@@ -264,7 +263,7 @@ declare class AccessControl {
264
263
*
265
264
* @throws {AccessControlError } - If called after `.lock()` is called.
266
265
*/
267
- removeResources ( resources : ValidRoleOrArray , roles ?: ValidRoleOrArray ) : AccessControl ;
266
+ removeResources ( resources : string | string [ ] , roles ?: string | string [ ] ) : AccessControl ;
268
267
/**
269
268
* Gets all the unique roles that have at least one access information.
270
269
*
@@ -285,12 +284,12 @@ declare class AccessControl {
285
284
*
286
285
* @returns {Array<String> }
287
286
*/
288
- getInheritedRolesOf ( role : ValidRole ) : ValidRole [ ] ;
287
+ getInheritedRolesOf ( role : string ) : string [ ] ;
289
288
/**
290
289
* Alias of `getInheritedRolesOf`
291
290
* @private
292
291
*/
293
- getExtendedRolesOf ( role : ValidRole ) : ValidRole [ ] ;
292
+ getExtendedRolesOf ( role : string ) : string [ ] ;
294
293
/**
295
294
* Gets all the unique resources that are granted access for at
296
295
* least one role.
@@ -306,7 +305,7 @@ declare class AccessControl {
306
305
*
307
306
* @returns {Boolean }
308
307
*/
309
- hasRole ( role : ValidRoleOrArray ) : boolean ;
308
+ hasRole ( role : string | string [ ] ) : boolean ;
310
309
/**
311
310
* Checks whether grants include the given resource or resources.
312
311
*
@@ -315,7 +314,7 @@ declare class AccessControl {
315
314
*
316
315
* @returns {Boolean }
317
316
*/
318
- hasResource ( resource : ValidRoleOrArray ) : boolean ;
317
+ hasResource ( resource : string | string [ ] ) : boolean ;
319
318
/**
320
319
* Gets an instance of `Query` object. This is used to check whether the
321
320
* defined access is allowed for the given role(s) and resource. This
@@ -348,12 +347,12 @@ declare class AccessControl {
348
347
* ac.can(['admin', 'user']).createOwn('profile');
349
348
* // Note: when multiple roles checked, acquired attributes are unioned (merged).
350
349
*/
351
- can ( role : ValidRoleOrArray | IQueryInfo ) : Query ;
350
+ can ( role : string | string [ ] | IQueryInfo ) : Query ;
352
351
/**
353
352
* Alias of `can()`.
354
353
* @private
355
354
*/
356
- query ( role : ValidRoleOrArray | IQueryInfo ) : Query ;
355
+ query ( role : string | string [ ] | IQueryInfo ) : Query ;
357
356
/**
358
357
* Gets an instance of `Permission` object that checks and defines the
359
358
* granted access permissions for the target resource and role. Normally
@@ -438,12 +437,12 @@ declare class AccessControl {
438
437
* // Note: when attributes is omitted, it will default to `['*']`
439
438
* // which means all attributes (of the resource) are allowed.
440
439
*/
441
- grant ( role ?: ValidRoleOrArray | IAccessInfo ) : Access ;
440
+ grant ( role ?: string | string [ ] | IAccessInfo ) : Access ;
442
441
/**
443
442
* Alias of `grant()`.
444
443
* @private
445
444
*/
446
- allow ( role ?: ValidRoleOrArray | IAccessInfo ) : Access ;
445
+ allow ( role ?: string | string [ ] | IAccessInfo ) : Access ;
447
446
/**
448
447
* Gets an instance of `Access` object. This is used to deny access to
449
448
* specified resource(s) for the given role(s). Denying will only remove a
@@ -496,31 +495,31 @@ declare class AccessControl {
496
495
* // To deny same resource for multiple roles:
497
496
* ac.deny(['admin', 'user']).createOwn('profile');
498
497
*/
499
- deny ( role ?: ValidRoleOrArray | IAccessInfo ) : Access ;
498
+ deny ( role ?: string | string [ ] | IAccessInfo ) : Access ;
500
499
/**
501
500
* Alias of `deny()`.
502
501
* @private
503
502
*/
504
- reject ( role ?: ValidRoleOrArray | IAccessInfo ) : Access ;
503
+ reject ( role ?: string | string [ ] | IAccessInfo ) : Access ;
505
504
/**
506
505
* @private
507
506
*/
508
- _removePermission ( resources : ValidRoleOrArray , roles ?: ValidRoleOrArray , actionPossession ?: string ) : void ;
507
+ _removePermission ( resources : string | string [ ] , roles ?: string | string [ ] , actionPossession ?: string ) : void ;
509
508
/**
510
509
* Documented separately in enums/Action
511
510
* @private
512
511
*/
513
- static get Action ( ) : any ;
512
+ static readonly Action : any ;
514
513
/**
515
514
* Documented separately in enums/Possession
516
515
* @private
517
516
*/
518
- static get Possession ( ) : any ;
517
+ static readonly Possession : any ;
519
518
/**
520
519
* Documented separately in AccessControlError
521
520
* @private
522
521
*/
523
- static get Error ( ) : any ;
522
+ static readonly Error : any ;
524
523
/**
525
524
* A utility method for deep cloning the given data object(s) while
526
525
* filtering its properties by the given attribute (glob) notations.
0 commit comments