oip-common 0.0.13 → 0.0.15

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/index.d.ts CHANGED
@@ -5,7 +5,7 @@ import { ActivatedRoute, QueryParamsHandling, IsActiveMatchOptions, Params, Rout
5
5
  import { TranslateService } from '@ngx-translate/core';
6
6
  import * as rxjs from 'rxjs';
7
7
  import { Subject, Observable, Subscription } from 'rxjs';
8
- import { LoginResponse, AuthOptions, AbstractSecurityStorage, StsConfigHttpLoader } from 'angular-auth-oidc-client';
8
+ import { LoginResponse, AuthOptions, OidcSecurityService, LogoutAuthOptions, AbstractSecurityStorage, StsConfigHttpLoader } from 'angular-auth-oidc-client';
9
9
  import { ContextMenu } from 'primeng/contextmenu';
10
10
  import { PrimeNG } from 'primeng/config';
11
11
  import { HttpInterceptorFn, HttpClient as HttpClient$1 } from '@angular/common/http';
@@ -326,6 +326,72 @@ declare abstract class SecurityService {
326
326
  abstract isAdmin(): boolean;
327
327
  abstract authorize(configId?: string, authOptions?: AuthOptions): void;
328
328
  }
329
+ /**
330
+ * SecurityService extends OidcSecurityService to manage authentication,
331
+ * token handling, and user role access in an Angular application.
332
+ *
333
+ * It provides helper methods for checking authentication, managing tokens,
334
+ * determining user roles, and performing logout and refresh operations.
335
+ */
336
+ declare class KeycloakSecurityService extends OidcSecurityService implements OnDestroy, SecurityService {
337
+ /**
338
+ * Handles angular OIDC events.
339
+ */
340
+ private readonly publicEventsService;
341
+ /**
342
+ * Stores the latest login response from checkAuth().
343
+ */
344
+ private loginResponse;
345
+ /**
346
+ * Stores the decoded access token payload.
347
+ */
348
+ private payload;
349
+ /**
350
+ * Stores user-specific data from the login response.
351
+ */
352
+ userData: any;
353
+ /**
354
+ * Initializes service and subscribes to authentication events.
355
+ * When a 'NewAuthenticationResult' event is received, the `auth` method is called.
356
+ */
357
+ constructor();
358
+ getCurrentUser(): any;
359
+ /**
360
+ * Returns the ID token for the sign-in.
361
+ * @returns A string with the id token.
362
+ */
363
+ getAccessToken(): Observable<string>;
364
+ /**
365
+ * Indicates whether the current user has the 'admin' role.
366
+ *
367
+ * @returns {boolean} True if the user is an admin, false otherwise.
368
+ */
369
+ isAdmin(): boolean;
370
+ /**
371
+ * Initiates authentication check and updates login response, user data,
372
+ * and decoded token payload if authenticated.
373
+ */
374
+ auth(): void;
375
+ /**
376
+ * Performs logout and clears the local token payload.
377
+ *
378
+ * @param {string} [configId] Optional configuration ID for logout.
379
+ * @param {LogoutAuthOptions} [logoutAuthOptions] Optional logout options.
380
+ */
381
+ logout(configId?: string, logoutAuthOptions?: LogoutAuthOptions): void;
382
+ /**
383
+ * Completes the BehaviorSubjects when the service is destroyed to avoid memory leaks.
384
+ */
385
+ ngOnDestroy(): void;
386
+ /**
387
+ * Checks whether the current access token is expired based on the 'exp' claim.
388
+ *
389
+ * @returns {Observable<boolean>} Observable that emits true if the token is expired.
390
+ */
391
+ isTokenExpired(): Observable<boolean>;
392
+ static ɵfac: i0.ɵɵFactoryDeclaration<KeycloakSecurityService, never>;
393
+ static ɵprov: i0.ɵɵInjectableDeclaration<KeycloakSecurityService>;
394
+ }
329
395
 
330
396
  /**
331
397
  * UserService is responsible for retrieving and handling user-related data,
@@ -747,7 +813,42 @@ declare class LogoComponent {
747
813
  static ɵcmp: i0.ɵɵComponentDeclaration<LogoComponent, "logo", never, { "width": { "alias": "width"; "required": false; }; "height": { "alias": "height"; "required": false; }; }, {}, never, never, true, never>;
748
814
  }
749
815
 
816
+ /**
817
+ * Service for managing translation loading in the application
818
+ */
819
+ declare class L10nService {
820
+ private loadedTranslations;
821
+ private httpClient;
822
+ private translateService;
823
+ private readonly primeNg;
824
+ private readonly layoutService;
825
+ /**
826
+ * Loads translations for a specific component
827
+ * @param component - Name of the component to load translations for
828
+ */
829
+ loadComponentTranslations(component: string): void;
830
+ /**
831
+ * Gets the translated value of a key (or an array of keys)
832
+ * @returns the translated key, or an object of translated keys
833
+ */
834
+ get(key: string): rxjs.Observable<any>;
835
+ /**
836
+ * Internal method to load translations from JSON files
837
+ * @param component - Component or translation namespace
838
+ * @param lang - Language code to load translations for
839
+ */
840
+ private loadTranslations;
841
+ /**
842
+ * Changes the lang currently used
843
+ */
844
+ use(selectedLanguage: string, key?: string): void;
845
+ init(langs: string[]): void;
846
+ static ɵfac: i0.ɵɵFactoryDeclaration<L10nService, never>;
847
+ static ɵprov: i0.ɵɵInjectableDeclaration<L10nService>;
848
+ }
849
+
750
850
  declare class NotfoundComponent {
851
+ constructor(l10nService: L10nService);
751
852
  static ɵfac: i0.ɵɵFactoryDeclaration<NotfoundComponent, never>;
752
853
  static ɵcmp: i0.ɵɵComponentDeclaration<NotfoundComponent, "app-notfound", never, {}, {}, never, never, true, never>;
753
854
  }
@@ -826,37 +927,6 @@ declare class DbMigrationComponent extends BaseModuleComponent<NoSettingsDto, No
826
927
  static ɵcmp: i0.ɵɵComponentDeclaration<DbMigrationComponent, "db-migration", never, {}, {}, never, never, true, never>;
827
928
  }
828
929
 
829
- /**
830
- * Service for managing translation loading in the application
831
- */
832
- declare class L10nService {
833
- private loadedTranslations;
834
- private httpClient;
835
- private translateService;
836
- /**
837
- * Loads translations for a specific component
838
- * @param component - Name of the component to load translations for
839
- */
840
- loadComponentTranslations(component: string): Promise<void>;
841
- /**
842
- * Gets the translated value of a key (or an array of keys)
843
- * @returns the translated key, or an object of translated keys
844
- */
845
- get(key: string): Promise<rxjs.Observable<any>>;
846
- /**
847
- * Internal method to load translations from JSON files
848
- * @param component - Component or translation namespace
849
- * @param lang - Language code to load translations for
850
- */
851
- private loadTranslations;
852
- /**
853
- * Changes the lang currently used
854
- */
855
- use(selectedLanguage: string): void;
856
- static ɵfac: i0.ɵɵFactoryDeclaration<L10nService, never>;
857
- static ɵprov: i0.ɵɵInjectableDeclaration<L10nService>;
858
- }
859
-
860
930
  interface L10n {
861
931
  confirm: {
862
932
  header: string;
@@ -1068,5 +1138,5 @@ declare class SecurePipe implements PipeTransform {
1068
1138
  */
1069
1139
  declare const httpLoaderAuthFactory: (httpClient: HttpClient$1) => StsConfigHttpLoader;
1070
1140
 
1071
- export { AppConfiguratorComponent, AppFloatingConfiguratorComponent, AppLayoutComponent, AppModulesComponent, AppTopbar, AuthGuardService, BaseDataService, BaseModuleComponent, ConfigComponent, DbMigrationComponent, ErrorComponent, FooterComponent, LayoutService, LogoComponent, MenuComponent, MenuService, MsgService, NotfoundComponent, ProfileComponent, SecurePipe, SecurityComponent, SecurityDataService, SecurityService, SecurityStorageService, SidebarComponent, TopBarService, UnauthorizedComponent, UserService, httpLoaderAuthFactory, langIntercept };
1141
+ export { AppConfiguratorComponent, AppFloatingConfiguratorComponent, AppLayoutComponent, AppModulesComponent, AppTopbar, AuthGuardService, BaseDataService, BaseModuleComponent, ConfigComponent, DbMigrationComponent, ErrorComponent, FooterComponent, KeycloakSecurityService, LayoutService, LogoComponent, MenuComponent, MenuService, MsgService, NotfoundComponent, ProfileComponent, SecurePipe, SecurityComponent, SecurityDataService, SecurityService, SecurityStorageService, SidebarComponent, TopBarService, UnauthorizedComponent, UserService, httpLoaderAuthFactory, langIntercept };
1072
1142
  export type { AppConfig, MenuChangeEvent, NoSettingsDto, PutSecurityDto, SecurityDto, TopBarDto };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oip-common",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
4
4
  "description": "A template for cross-platform web applications based on sakai-ng and primeNG",
5
5
  "main": "index.js",
6
6
  "keywords": [