fas-admin 0.0.23 → 0.0.25

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.
@@ -0,0 +1,29 @@
1
+ import { IFASAdminConfigInitializer } from '../../shared/models/fas-admin-models';
2
+ import { CanActivate, ActivatedRouteSnapshot, Router } from '@angular/router';
3
+ import * as i0 from "@angular/core";
4
+ /**
5
+ * FasAccessGuard is an Angular route guard that ensures users can only
6
+ * access routes they are authorized to based on their role.
7
+ *
8
+ * Configuration for access rules is provided via FAS_LIB_CONFIG, which
9
+ * must include `accessRules` defining allowed routes per role.
10
+ *
11
+ * Usage:
12
+ * - Ensure that `accessRules` is correctly set in the configuration object.
13
+ * - Token must be stored in `localStorage` under the key `authToken`.
14
+ */
15
+ export declare class FasAccessGuard implements CanActivate {
16
+ private router;
17
+ private config;
18
+ constructor(router: Router, config: IFASAdminConfigInitializer);
19
+ /**
20
+ * Determines whether the current user can activate a route based on
21
+ * their role and the configured access rules.
22
+ *
23
+ * @param route The activated route snapshot
24
+ * @returns `true` if access is allowed, otherwise `false`
25
+ */
26
+ canActivate(route: ActivatedRouteSnapshot): boolean;
27
+ static ɵfac: i0.ɵɵFactoryDeclaration<FasAccessGuard, never>;
28
+ static ɵprov: i0.ɵɵInjectableDeclaration<FasAccessGuard>;
29
+ }
@@ -5,7 +5,9 @@ export declare class FASAdminComponent implements OnInit {
5
5
  private fasAdminService;
6
6
  inputData?: IFASAdminConfigInitializer;
7
7
  visableDefaultButtonList: IFASButtonList[];
8
+ specButtonList: IFASButtonList[];
8
9
  ngOnInit(): void;
10
+ setSidebarButtons(configData: IFASAdminConfigInitializer, buttonList: IFASButtonList[]): IFASButtonList[];
9
11
  static ɵfac: i0.ɵɵFactoryDeclaration<FASAdminComponent, never>;
10
12
  static ɵcmp: i0.ɵɵComponentDeclaration<FASAdminComponent, "lib-fas-admin", never, {}, {}, never, never, false, never>;
11
13
  }
@@ -15,7 +15,7 @@ export declare class FASAdminModule {
15
15
  private configData;
16
16
  private fasAdminService;
17
17
  constructor(configData: IFASAdminConfigInitializer, fasAdminService: FASAdminService);
18
- private setDefaultRoutes;
18
+ private generateRoutes;
19
19
  static ɵfac: i0.ɵɵFactoryDeclaration<FASAdminModule, never>;
20
20
  static ɵmod: i0.ɵɵNgModuleDeclaration<FASAdminModule, [typeof i1.FASAdminComponent, typeof i2.TopBarComponent, typeof i3.SideBarComponent], [typeof i4.CommonModule, typeof i5.RouterModule, typeof i6.SubscriptionsModule, typeof i7.StatisticModule, typeof i8.OperatorsModule, typeof i9.MessagesModule, typeof i10.UsersModule], never>;
21
21
  static ɵinj: i0.ɵɵInjectorDeclaration<FASAdminModule>;
@@ -6,6 +6,7 @@ export interface IFASButtonList {
6
6
  icon: string;
7
7
  }
8
8
  export type IFASDefaultRoutePath = 'dashboard' | 'statistic' | 'subscriptions' | 'messages' | 'operators' | 'users';
9
+ export type IFASUserRole = 'PlatformOperator' | 'OSK';
9
10
  export interface IFASDefaultPath {
10
11
  path: IFASDefaultRoutePath;
11
12
  component: Type<any>;
@@ -17,8 +18,12 @@ export interface IFASDefaultButtonsSettings {
17
18
  }
18
19
  export interface IFASAdminConfigInitializer {
19
20
  companyName: string;
21
+ accessRules: IFASAccessRules[] | null;
20
22
  specButtonList?: IFASButtonList[];
21
23
  customRoutes?: Route[];
22
- hideDefaultRoutePaths?: IFASDefaultRoutePath[];
23
24
  defaultButtonSettings?: IFASDefaultButtonsSettings[];
24
25
  }
26
+ export interface IFASAccessRules {
27
+ role: IFASUserRole;
28
+ access: Array<IFASDefaultPath | string>;
29
+ }
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "fas-admin",
3
- "version": "0.0.23",
3
+ "version": "0.0.25",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^17.2.0",
6
- "@angular/core": "^17.2.0"
6
+ "@angular/core": "^17.2.0",
7
+ "jwt-decode": "^3.1.2"
7
8
  },
8
9
  "dependencies": {
9
10
  "tslib": "^2.3.0"