@open-rlb/ng-app 3.0.2 → 3.0.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.
@@ -148,7 +148,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImpo
148
148
  }]
149
149
  }], ctorParameters: () => [{ type: AppStorageService }] });
150
150
 
151
- const LEVEL_PRIORITIES = {
151
+ const LEVEL_PRIORITIES$1 = {
152
152
  off: 0,
153
153
  error: 1,
154
154
  warn: 2,
@@ -163,7 +163,7 @@ class AppLoggerService extends AbstractLoggerService {
163
163
  this.timestamps = true;
164
164
  }
165
165
  setLogLevel(level) {
166
- if (!(level in LEVEL_PRIORITIES)) {
166
+ if (!(level in LEVEL_PRIORITIES$1)) {
167
167
  throw new Error(`Unknown log level: ${level}`);
168
168
  }
169
169
  this.currentLevel = level;
@@ -202,7 +202,7 @@ class AppLoggerService extends AbstractLoggerService {
202
202
  this.print('log', contextOrMessage, args);
203
203
  }
204
204
  print(level, contextOrMessage, args) {
205
- if (LEVEL_PRIORITIES[level] > LEVEL_PRIORITIES[this.currentLevel]) {
205
+ if (LEVEL_PRIORITIES$1[level] > LEVEL_PRIORITIES$1[this.currentLevel]) {
206
206
  return;
207
207
  }
208
208
  const colors = {
@@ -1275,14 +1275,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImpo
1275
1275
  }] });
1276
1276
 
1277
1277
  class AuthenticationService {
1278
- constructor(oidcSecurityService, cookiesService, router, parseJwtService, store, envConfig, authConfig) {
1278
+ constructor(oidcSecurityService, cookiesService, router, parseJwtService, store, log, envConfig, authConfig) {
1279
1279
  this.oidcSecurityService = oidcSecurityService;
1280
1280
  this.cookiesService = cookiesService;
1281
1281
  this.router = router;
1282
1282
  this.parseJwtService = parseJwtService;
1283
1283
  this.store = store;
1284
+ this.log = log;
1284
1285
  this.envConfig = envConfig;
1285
1286
  this.authConfig = authConfig;
1287
+ this.logger = this.log.for(this.constructor.name);
1288
+ this.logger.log('AuthenticationService initialized');
1286
1289
  }
1287
1290
  get oidc() {
1288
1291
  return this.oidcSecurityService;
@@ -1318,6 +1321,7 @@ class AuthenticationService {
1318
1321
  }
1319
1322
  login() {
1320
1323
  this.cookiesService.setCookie('loginRedirectUrl', this.router.url || '/', 1);
1324
+ this.logger.log(`call login method, loginRedirectUrl: ${this.router.url || '/'}`);
1321
1325
  // electron
1322
1326
  if (typeof (process) !== 'undefined' &&
1323
1327
  typeof (process?.version) !== 'undefined' &&
@@ -1373,7 +1377,7 @@ class AuthenticationService {
1373
1377
  matchRoles(roles) {
1374
1378
  return this.accessToken$.pipe(map(token => this.parseJwtService.parseJwt(token)), map(payload => payload['roles']), map(userRoles => roles.some(role => userRoles.includes(role))));
1375
1379
  }
1376
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AuthenticationService, deps: [{ token: i1$5.OidcSecurityService }, { token: CookiesService }, { token: i2.Router }, { token: ParseJwtService }, { token: i1$1.Store }, { token: RLB_CFG_ENV, optional: true }, { token: RLB_CFG_AUTH, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
1380
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AuthenticationService, deps: [{ token: i1$5.OidcSecurityService }, { token: CookiesService }, { token: i2.Router }, { token: ParseJwtService }, { token: i1$1.Store }, { token: AppLoggerService }, { token: RLB_CFG_ENV, optional: true }, { token: RLB_CFG_AUTH, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
1377
1381
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AuthenticationService, providedIn: 'root' }); }
1378
1382
  }
1379
1383
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AuthenticationService, decorators: [{
@@ -1381,7 +1385,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImpo
1381
1385
  args: [{
1382
1386
  providedIn: 'root'
1383
1387
  }]
1384
- }], ctorParameters: () => [{ type: i1$5.OidcSecurityService }, { type: CookiesService }, { type: i2.Router }, { type: ParseJwtService }, { type: i1$1.Store }, { type: undefined, decorators: [{
1388
+ }], ctorParameters: () => [{ type: i1$5.OidcSecurityService }, { type: CookiesService }, { type: i2.Router }, { type: ParseJwtService }, { type: i1$1.Store }, { type: AppLoggerService }, { type: undefined, decorators: [{
1385
1389
  type: Optional
1386
1390
  }, {
1387
1391
  type: Inject,
@@ -2313,10 +2317,76 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImpo
2313
2317
  type: Input
2314
2318
  }] } });
2315
2319
 
2320
+ const LEVEL_PRIORITIES = {
2321
+ off: 0,
2322
+ error: 1,
2323
+ warn: 2,
2324
+ info: 3,
2325
+ debug: 4,
2326
+ all: 5,
2327
+ };
2328
+ class RlbLoggerService {
2329
+ constructor() {
2330
+ this.currentLevel = 'warn';
2331
+ this.timestamps = true;
2332
+ }
2333
+ setLogLevel(level) {
2334
+ if (!Object.prototype.hasOwnProperty.call(LEVEL_PRIORITIES, level)) {
2335
+ throw new Error(`Unknown log level: ${String(level)}`);
2336
+ }
2337
+ this.currentLevel = level;
2338
+ }
2339
+ getLogLevel() {
2340
+ return this.currentLevel;
2341
+ }
2342
+ enableTimestamps(enabled) {
2343
+ this.timestamps = enabled;
2344
+ }
2345
+ logError(message, ...args) {
2346
+ if (this.shouldLog('error')) {
2347
+ console.error(this.prefix('error'), message, ...args);
2348
+ }
2349
+ }
2350
+ logWarning(message, ...args) {
2351
+ if (this.shouldLog('warn')) {
2352
+ console.warn(this.prefix('warn'), message, ...args);
2353
+ }
2354
+ }
2355
+ logDebug(message, ...args) {
2356
+ if (this.shouldLog('debug')) {
2357
+ console.debug(this.prefix('debug'), message, ...args);
2358
+ }
2359
+ }
2360
+ logInfo(message, ...args) {
2361
+ if (this.shouldLog('info')) {
2362
+ console.info(this.prefix('info'), message, ...args);
2363
+ }
2364
+ }
2365
+ log(message, ...args) {
2366
+ if (this.shouldLog('info')) {
2367
+ console.log(this.prefix('log'), message, ...args);
2368
+ }
2369
+ }
2370
+ prefix(level) {
2371
+ return this.timestamps ? `[${level.toUpperCase()}] ${new Date().toISOString()} -` : `[${level.toUpperCase()}]`;
2372
+ }
2373
+ shouldLog(messageLevel) {
2374
+ return (LEVEL_PRIORITIES[messageLevel] ?? 0) <= (LEVEL_PRIORITIES[this.currentLevel] ?? 0);
2375
+ }
2376
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: RlbLoggerService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
2377
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: RlbLoggerService, providedIn: 'root' }); }
2378
+ }
2379
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: RlbLoggerService, decorators: [{
2380
+ type: Injectable,
2381
+ args: [{ providedIn: 'root' }]
2382
+ }] });
2383
+
2316
2384
  const oauthGuard = (route, state) => {
2317
2385
  const authService = inject(AuthenticationService);
2386
+ const logger = inject(RlbLoggerService);
2318
2387
  return authService.isAuthenticated$.pipe(take(1), map((isAuthenticated) => {
2319
2388
  if (!isAuthenticated) {
2389
+ logger.log('oauthGuard, not authenticated, call authService.login()');
2320
2390
  authService.login();
2321
2391
  return false;
2322
2392
  }
@@ -2328,12 +2398,13 @@ const SESSION_RT = 'RT';
2328
2398
  const SESSION_AT = 'AT';
2329
2399
  const TOKEN_URL = `protocol/openid-connect/token`;
2330
2400
  class OauthPasswordService {
2331
- //private _user: User | null = null
2332
- constructor(httpClient, authenticationService) {
2401
+ constructor(httpClient, authenticationService, log) {
2333
2402
  this.httpClient = httpClient;
2334
2403
  this.authenticationService = authenticationService;
2404
+ this.log = log;
2335
2405
  this.timer = null;
2336
2406
  this._onUpdateToken = null;
2407
+ this.logger = this.log.for(this.constructor.name);
2337
2408
  this.initRefreshToken().catch(e => console.error("Error in refresh token", e));
2338
2409
  }
2339
2410
  intercept(req, next) {
@@ -2430,6 +2501,7 @@ class OauthPasswordService {
2430
2501
  body.set('scope', 'addubby-order');
2431
2502
  body.set('username', username);
2432
2503
  body.set('password', password);
2504
+ this.logger.log(`password service call _login()`);
2433
2505
  return await lastValueFrom(this.httpClient.post(`${this.authenticationService.currentProvider.authority}/${TOKEN_URL}`, body.toString(), {
2434
2506
  headers: { 'content-type': 'application/x-www-form-urlencoded' },
2435
2507
  }));
@@ -2475,7 +2547,7 @@ class OauthPasswordService {
2475
2547
  }, r.expires_in * 1000 - 60000);
2476
2548
  }
2477
2549
  }
2478
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: OauthPasswordService, deps: [{ token: i1$3.HttpClient }, { token: AuthenticationService }], target: i0.ɵɵFactoryTarget.Injectable }); }
2550
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: OauthPasswordService, deps: [{ token: i1$3.HttpClient }, { token: AuthenticationService }, { token: AppLoggerService }], target: i0.ɵɵFactoryTarget.Injectable }); }
2479
2551
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: OauthPasswordService, providedIn: 'root' }); }
2480
2552
  }
2481
2553
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: OauthPasswordService, decorators: [{
@@ -2483,7 +2555,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImpo
2483
2555
  args: [{
2484
2556
  providedIn: 'root'
2485
2557
  }]
2486
- }], ctorParameters: () => [{ type: i1$3.HttpClient }, { type: AuthenticationService }] });
2558
+ }], ctorParameters: () => [{ type: i1$3.HttpClient }, { type: AuthenticationService }, { type: AppLoggerService }] });
2487
2559
 
2488
2560
  const oauthPasswordGuard = (route, state) => {
2489
2561
  const auth = inject(OauthPasswordService);
@@ -2830,28 +2902,31 @@ const appReducer = appFeature.reducer;
2830
2902
  const { selectAppState, selectApps, selectCurrentApp, selectSupportedLanguages } = appFeature;
2831
2903
 
2832
2904
  class AuthEffects {
2833
- constructor(actions$, auth, authConfig) {
2905
+ constructor(actions$, auth, loggerService, authConfig) {
2834
2906
  this.actions$ = actions$;
2835
2907
  this.auth = auth;
2908
+ this.loggerService = loggerService;
2836
2909
  this.login$ = createEffect(() => {
2837
- return this.actions$.pipe(ofType(AuthActions.login), tap$1(() => this.auth.login()), map$1(() => AuthActionsInternal.setLoading({ loading: true })));
2910
+ return this.actions$.pipe(ofType(AuthActions.login), tap$1(() => this.logger.log('auth effects going to call login()')), tap$1(() => this.auth.login()), map$1(() => AuthActionsInternal.setLoading({ loading: true })));
2838
2911
  });
2839
2912
  this.logout$ = createEffect(() => {
2840
- return this.actions$.pipe(ofType(AuthActions.logout), switchMap$1(() => this.auth.logout$()), map$1(() => AuthActionsInternal.reset()));
2913
+ return this.actions$.pipe(ofType(AuthActions.logout), tap$1(() => this.logger.log('auth effects going to call logout$()')), switchMap$1(() => this.auth.logout$()), map$1(() => AuthActionsInternal.reset()));
2841
2914
  });
2842
2915
  this.setCurrentProvider$ = createEffect(() => {
2843
2916
  return this.actions$.pipe(ofType(AuthActions.setCurrentProvider), map$1(({ currentProvider }) => AuthActionsInternal.setCurrentProvider({ currentProvider })));
2844
2917
  });
2918
+ this.logger = this.loggerService.for(this.constructor.name);
2919
+ this.logger.log('Initialized AuthEffects');
2845
2920
  if (authConfig) {
2846
2921
  auth.checkAuthMultiple().subscribe();
2847
2922
  }
2848
2923
  }
2849
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AuthEffects, deps: [{ token: i1$8.Actions }, { token: AuthenticationService }, { token: RLB_CFG_AUTH, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
2924
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AuthEffects, deps: [{ token: i1$8.Actions }, { token: AuthenticationService }, { token: AppLoggerService }, { token: RLB_CFG_AUTH, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
2850
2925
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AuthEffects }); }
2851
2926
  }
2852
2927
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AuthEffects, decorators: [{
2853
2928
  type: Injectable
2854
- }], ctorParameters: () => [{ type: i1$8.Actions }, { type: AuthenticationService }, { type: undefined, decorators: [{
2929
+ }], ctorParameters: () => [{ type: i1$8.Actions }, { type: AuthenticationService }, { type: AppLoggerService }, { type: undefined, decorators: [{
2855
2930
  type: Inject,
2856
2931
  args: [RLB_CFG_AUTH]
2857
2932
  }, {