@aooth/arbac-core 0.2.1 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- //#region src/utils.ts
2
+ // src/utils.ts
3
3
  function arbacPatternToRegex(input) {
4
4
  let pattern = input.replace(/[$()+\-./?[\\\]^{|}]/gu, "\\$&");
5
5
  pattern = pattern.replace(/\*\*/gu, "⁑");
@@ -7,8 +7,7 @@ function arbacPatternToRegex(input) {
7
7
  pattern = pattern.replace(/⁑/gu, ".*");
8
8
  return new RegExp(`^${pattern}$`);
9
9
  }
10
- //#endregion
11
- //#region src/arbac.ts
10
+ // src/arbac.ts
12
11
  /** Most memoized action matches per compiled (role, resource); past it, matched per call. */
13
12
  const MAX_MEMOIZED_ACTIONS = 512;
14
13
  /**
@@ -180,6 +179,5 @@ var Arbac = class {
180
179
  return match;
181
180
  }
182
181
  };
183
- //#endregion
184
182
  exports.Arbac = Arbac;
185
183
  exports.arbacPatternToRegex = arbacPatternToRegex;
package/dist/index.d.cts CHANGED
@@ -1,5 +1,4 @@
1
- //#region src/types.d.ts
2
- interface TArbacEvalResult<TScope> {
1
+ export interface TArbacEvalResult<TScope> {
3
2
  allowed: boolean;
4
3
  scopes?: TScope[];
5
4
  /**
@@ -13,21 +12,21 @@ interface TArbacEvalResult<TScope> {
13
12
  */
14
13
  credScopes?: TScope[];
15
14
  }
16
- interface TArbacRole<TUserAttrs, TScope> {
15
+ export interface TArbacRole<TUserAttrs, TScope> {
17
16
  id: string;
18
17
  name?: string;
19
18
  description?: string;
20
19
  rules: Array<TArbacRule<TUserAttrs, TScope>>;
21
20
  }
22
- type TArbacCompiledRule<TUserAttrs, TScope> = Omit<TArbacRule<TUserAttrs, TScope>, "resource" | "effect" | "_resourceRegex"> & {
21
+ export type TArbacCompiledRule<TUserAttrs, TScope> = Omit<TArbacRule<TUserAttrs, TScope>, "resource" | "effect" | "_resourceRegex"> & {
23
22
  _actionRegex: RegExp;
24
23
  };
25
- interface TArbacRoleForResource<TUserAttrs, TScope> {
24
+ export interface TArbacRoleForResource<TUserAttrs, TScope> {
26
25
  id: string;
27
26
  allow: Array<TArbacCompiledRule<TUserAttrs, TScope>>;
28
27
  deny: Array<TArbacCompiledRule<TUserAttrs, TScope>>;
29
28
  }
30
- type TArbacRule<TUserAttrs, TScope> = {
29
+ export type TArbacRule<TUserAttrs, TScope> = {
31
30
  resource: string;
32
31
  action: string;
33
32
  /**
@@ -43,8 +42,6 @@ type TArbacRule<TUserAttrs, TScope> = {
43
42
  effect: "deny";
44
43
  scope?: never;
45
44
  };
46
- //#endregion
47
- //#region src/arbac.d.ts
48
45
  /**
49
46
  * Implements Advanced Role-Based Access Control (ARBAC) system.
50
47
  * This class allows registering roles and resources, and evaluating access permissions based on user attributes and roles.
@@ -52,7 +49,7 @@ type TArbacRule<TUserAttrs, TScope> = {
52
49
  * @template TUserAttrs The type of user attributes.
53
50
  * @template TScope The type of scope that access rules can define.
54
51
  */
55
- declare class Arbac<TUserAttrs extends object, TScope extends object> {
52
+ export declare class Arbac<TUserAttrs extends object, TScope extends object> {
56
53
  protected roles: Record<string, TArbacRole<TUserAttrs, TScope> | undefined>;
57
54
  protected resources: Record<string, Record<string, TArbacRoleForResource<TUserAttrs, TScope> | undefined> | undefined>;
58
55
  private warnedRoles;
@@ -137,8 +134,4 @@ declare class Arbac<TUserAttrs extends object, TScope extends object> {
137
134
  */
138
135
  private matchAction;
139
136
  }
140
- //#endregion
141
- //#region src/utils.d.ts
142
- declare function arbacPatternToRegex(input: string): RegExp;
143
- //#endregion
144
- export { Arbac, TArbacCompiledRule, TArbacEvalResult, TArbacRole, TArbacRoleForResource, TArbacRule, arbacPatternToRegex };
137
+ export declare function arbacPatternToRegex(input: string): RegExp;
package/dist/index.d.mts CHANGED
@@ -1,5 +1,4 @@
1
- //#region src/types.d.ts
2
- interface TArbacEvalResult<TScope> {
1
+ export interface TArbacEvalResult<TScope> {
3
2
  allowed: boolean;
4
3
  scopes?: TScope[];
5
4
  /**
@@ -13,21 +12,21 @@ interface TArbacEvalResult<TScope> {
13
12
  */
14
13
  credScopes?: TScope[];
15
14
  }
16
- interface TArbacRole<TUserAttrs, TScope> {
15
+ export interface TArbacRole<TUserAttrs, TScope> {
17
16
  id: string;
18
17
  name?: string;
19
18
  description?: string;
20
19
  rules: Array<TArbacRule<TUserAttrs, TScope>>;
21
20
  }
22
- type TArbacCompiledRule<TUserAttrs, TScope> = Omit<TArbacRule<TUserAttrs, TScope>, "resource" | "effect" | "_resourceRegex"> & {
21
+ export type TArbacCompiledRule<TUserAttrs, TScope> = Omit<TArbacRule<TUserAttrs, TScope>, "resource" | "effect" | "_resourceRegex"> & {
23
22
  _actionRegex: RegExp;
24
23
  };
25
- interface TArbacRoleForResource<TUserAttrs, TScope> {
24
+ export interface TArbacRoleForResource<TUserAttrs, TScope> {
26
25
  id: string;
27
26
  allow: Array<TArbacCompiledRule<TUserAttrs, TScope>>;
28
27
  deny: Array<TArbacCompiledRule<TUserAttrs, TScope>>;
29
28
  }
30
- type TArbacRule<TUserAttrs, TScope> = {
29
+ export type TArbacRule<TUserAttrs, TScope> = {
31
30
  resource: string;
32
31
  action: string;
33
32
  /**
@@ -43,8 +42,6 @@ type TArbacRule<TUserAttrs, TScope> = {
43
42
  effect: "deny";
44
43
  scope?: never;
45
44
  };
46
- //#endregion
47
- //#region src/arbac.d.ts
48
45
  /**
49
46
  * Implements Advanced Role-Based Access Control (ARBAC) system.
50
47
  * This class allows registering roles and resources, and evaluating access permissions based on user attributes and roles.
@@ -52,7 +49,7 @@ type TArbacRule<TUserAttrs, TScope> = {
52
49
  * @template TUserAttrs The type of user attributes.
53
50
  * @template TScope The type of scope that access rules can define.
54
51
  */
55
- declare class Arbac<TUserAttrs extends object, TScope extends object> {
52
+ export declare class Arbac<TUserAttrs extends object, TScope extends object> {
56
53
  protected roles: Record<string, TArbacRole<TUserAttrs, TScope> | undefined>;
57
54
  protected resources: Record<string, Record<string, TArbacRoleForResource<TUserAttrs, TScope> | undefined> | undefined>;
58
55
  private warnedRoles;
@@ -137,8 +134,4 @@ declare class Arbac<TUserAttrs extends object, TScope extends object> {
137
134
  */
138
135
  private matchAction;
139
136
  }
140
- //#endregion
141
- //#region src/utils.d.ts
142
- declare function arbacPatternToRegex(input: string): RegExp;
143
- //#endregion
144
- export { Arbac, TArbacCompiledRule, TArbacEvalResult, TArbacRole, TArbacRoleForResource, TArbacRule, arbacPatternToRegex };
137
+ export declare function arbacPatternToRegex(input: string): RegExp;
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- //#region src/utils.ts
1
+ // src/utils.ts
2
2
  function arbacPatternToRegex(input) {
3
3
  let pattern = input.replace(/[$()+\-./?[\\\]^{|}]/gu, "\\$&");
4
4
  pattern = pattern.replace(/\*\*/gu, "⁑");
@@ -6,8 +6,7 @@ function arbacPatternToRegex(input) {
6
6
  pattern = pattern.replace(/⁑/gu, ".*");
7
7
  return new RegExp(`^${pattern}$`);
8
8
  }
9
- //#endregion
10
- //#region src/arbac.ts
9
+ // src/arbac.ts
11
10
  /** Most memoized action matches per compiled (role, resource); past it, matched per call. */
12
11
  const MAX_MEMOIZED_ACTIONS = 512;
13
12
  /**
@@ -179,5 +178,4 @@ var Arbac = class {
179
178
  return match;
180
179
  }
181
180
  };
182
- //#endregion
183
181
  export { Arbac, arbacPatternToRegex };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aooth/arbac-core",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Advanced Role-Based Access Control (ARBAC) engine",
5
5
  "keywords": [
6
6
  "access-control",