@open-rlb/ng-app 3.1.20 → 3.1.22
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.
|
@@ -15,7 +15,7 @@ import { RLB_TRANSLATION_SERVICE, RlbBootstrapModule, ModalDirective, ToastDirec
|
|
|
15
15
|
import * as i1$5 from 'angular-auth-oidc-client';
|
|
16
16
|
import { AbstractLoggerService, AuthModule, provideAuth, AuthInterceptor, AbstractSecurityStorage } from 'angular-auth-oidc-client';
|
|
17
17
|
import * as i1 from 'ngx-cookie-service-ssr';
|
|
18
|
-
import { filter, switchMap, map, BehaviorSubject,
|
|
18
|
+
import { of, filter, switchMap, map, BehaviorSubject, share, lastValueFrom, from, zip, EMPTY, catchError, Observable, tap, shareReplay, distinctUntilChanged, take } from 'rxjs';
|
|
19
19
|
import { signalStore, withState, withMethods, patchState } from '@ngrx/signals';
|
|
20
20
|
import { tapResponse } from '@ngrx/operators';
|
|
21
21
|
import { takeUntilDestroyed, toObservable } from '@angular/core/rxjs-interop';
|
|
@@ -420,7 +420,8 @@ class AdminApiService {
|
|
|
420
420
|
}
|
|
421
421
|
resourcesByUser$() {
|
|
422
422
|
if (!this.aclConfig) {
|
|
423
|
-
|
|
423
|
+
console.error("ACL configuration is missing. Provide 'acl' in ProjectConfiguration.");
|
|
424
|
+
return of([]);
|
|
424
425
|
}
|
|
425
426
|
const endpoint = this.config.endpoints?.[this.aclConfig.endpointKey];
|
|
426
427
|
if (!endpoint) {
|
|
@@ -501,11 +502,13 @@ const DEFAULT_ROUTES_CONFIG = [
|
|
|
501
502
|
];
|
|
502
503
|
|
|
503
504
|
class AppsService {
|
|
504
|
-
constructor(store, activatedRoute, router, loggerService, confAuth) {
|
|
505
|
+
constructor(store, activatedRoute, router, loggerService, confAuth, confAcl) {
|
|
505
506
|
this.store = store;
|
|
506
507
|
this.activatedRoute = activatedRoute;
|
|
507
508
|
this.router = router;
|
|
508
509
|
this.loggerService = loggerService;
|
|
510
|
+
this.confAuth = confAuth;
|
|
511
|
+
this.confAcl = confAcl;
|
|
509
512
|
this.logger = this.loggerService.for(this.constructor.name);
|
|
510
513
|
this.logger.log('AppsService initialized');
|
|
511
514
|
this.initAuthProviders(store, confAuth);
|
|
@@ -515,8 +518,38 @@ class AppsService {
|
|
|
515
518
|
return window.location.hostname;
|
|
516
519
|
}
|
|
517
520
|
get apps() {
|
|
518
|
-
|
|
519
|
-
|
|
521
|
+
const apps = this.store.selectSignal(state => state[appContextFeatureKey].apps)();
|
|
522
|
+
const resources = this.store.selectSignal(state => state[aclFeatureKey].resources)();
|
|
523
|
+
const confAcl = this.confAcl;
|
|
524
|
+
return apps.filter(app => {
|
|
525
|
+
// Basic domain check
|
|
526
|
+
const isDomainAllowed = !app.domains || app.domains.includes(this.currentDomain);
|
|
527
|
+
if (!isDomainAllowed)
|
|
528
|
+
return false;
|
|
529
|
+
// If acl config doesnt exist return apps filtered by domain
|
|
530
|
+
if (!confAcl)
|
|
531
|
+
return true;
|
|
532
|
+
if (!resources && app.actions?.length)
|
|
533
|
+
return true;
|
|
534
|
+
if (!resources && app.actions && app.actions.length > 0)
|
|
535
|
+
return false;
|
|
536
|
+
return resources?.some(userResource => {
|
|
537
|
+
// Matching by Business ID
|
|
538
|
+
// IMPORTANT: app.data must have key, name of this key is in confAcl
|
|
539
|
+
const appBusId = app.data?.[confAcl.businessIdKey];
|
|
540
|
+
const matchBusId = userResource.resourceBusinessId === appBusId;
|
|
541
|
+
if (!matchBusId)
|
|
542
|
+
return false;
|
|
543
|
+
// Matching by Resource ID
|
|
544
|
+
return userResource.resources.some(res => {
|
|
545
|
+
const appResId = app.data?.[confAcl.resourceIdKey];
|
|
546
|
+
const matchResId = res.resourceId === appResId;
|
|
547
|
+
if (!matchResId)
|
|
548
|
+
return false;
|
|
549
|
+
return res.actions.some(action => app.actions?.includes(action));
|
|
550
|
+
});
|
|
551
|
+
});
|
|
552
|
+
});
|
|
520
553
|
}
|
|
521
554
|
get currentApp() {
|
|
522
555
|
const app = this.store.selectSignal(state => state[appContextFeatureKey].currentApp)();
|
|
@@ -739,7 +772,7 @@ class AppsService {
|
|
|
739
772
|
}
|
|
740
773
|
return segments.join('/');
|
|
741
774
|
}
|
|
742
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.4", ngImport: i0, type: AppsService, deps: [{ token: i1$1.Store }, { token: i2.ActivatedRoute }, { token: i2.Router }, { token: AppLoggerService }, { token: RLB_CFG_AUTH, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
775
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.4", ngImport: i0, type: AppsService, deps: [{ token: i1$1.Store }, { token: i2.ActivatedRoute }, { token: i2.Router }, { token: AppLoggerService }, { token: RLB_CFG_AUTH, optional: true }, { token: RLB_CFG_ACL, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
743
776
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.4", ngImport: i0, type: AppsService, providedIn: 'root' }); }
|
|
744
777
|
}
|
|
745
778
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.4", ngImport: i0, type: AppsService, decorators: [{
|
|
@@ -752,6 +785,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.4", ngImpor
|
|
|
752
785
|
args: [RLB_CFG_AUTH]
|
|
753
786
|
}, {
|
|
754
787
|
type: Optional
|
|
788
|
+
}] }, { type: undefined, decorators: [{
|
|
789
|
+
type: Inject,
|
|
790
|
+
args: [RLB_CFG_ACL]
|
|
791
|
+
}, {
|
|
792
|
+
type: Optional
|
|
755
793
|
}] }] });
|
|
756
794
|
|
|
757
795
|
class LanguageService {
|
|
@@ -885,6 +923,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.4", ngImpor
|
|
|
885
923
|
args: [{ providedIn: 'root' }]
|
|
886
924
|
}], ctorParameters: () => [{ type: i2.Router }, { type: i2.ActivatedRoute }, { type: AppLoggerService }, { type: LanguageService }, { type: i2$1.UniqueIdService }] });
|
|
887
925
|
|
|
926
|
+
const RLB_INIT_PROVIDER = new InjectionToken(`${RLB_CFG}:init.provider`);
|
|
927
|
+
|
|
888
928
|
class LocalCacheService {
|
|
889
929
|
constructor(options) {
|
|
890
930
|
this.options = options;
|
|
@@ -1629,21 +1669,21 @@ class CompanyInterceptor {
|
|
|
1629
1669
|
intercept(req, next) {
|
|
1630
1670
|
const authConfig = this.config.auth;
|
|
1631
1671
|
const isAllowed = authConfig?.allowedUrls?.some(url => req.url.includes(url));
|
|
1632
|
-
console.log('CompanyInterceptor: isAllowed', isAllowed, 'enableCompanyInterceptor', authConfig?.enableCompanyInterceptor);
|
|
1633
1672
|
if (!isAllowed || !authConfig?.enableCompanyInterceptor) {
|
|
1634
1673
|
return next.handle(req);
|
|
1635
1674
|
}
|
|
1636
1675
|
const currentApp = this.store.selectSignal(state => state[appContextFeatureKey].currentApp)();
|
|
1637
1676
|
const data = currentApp?.data;
|
|
1638
1677
|
const mapping = this.config.acl?.interceptorMapping || {};
|
|
1639
|
-
|
|
1640
|
-
Object.keys(mapping)
|
|
1678
|
+
let params = req.params;
|
|
1679
|
+
for (const key of Object.keys(mapping)) {
|
|
1641
1680
|
const storeKey = mapping[key];
|
|
1642
1681
|
const value = data?.[storeKey];
|
|
1643
1682
|
if (!!value) {
|
|
1644
|
-
params.set(key, value);
|
|
1683
|
+
params = params.set(key, value);
|
|
1645
1684
|
}
|
|
1646
|
-
}
|
|
1685
|
+
}
|
|
1686
|
+
;
|
|
1647
1687
|
const clonedReq = req.clone({ params });
|
|
1648
1688
|
return next.handle(clonedReq);
|
|
1649
1689
|
}
|
|
@@ -3053,16 +3093,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.4", ngImpor
|
|
|
3053
3093
|
|
|
3054
3094
|
const appFeature = createFeature({
|
|
3055
3095
|
name: appContextFeatureKey,
|
|
3056
|
-
reducer: createReducer(initialAppContextState, on(AppContextActionsInternal.setCurrentApp, (state, { app, mode, url }) => ({ ...state, currentApp: app ? { ...app, viewMode: mode, navigationUrl: url } : null })), on(AppContextActions.removeApp, (state, { appType }) => ({ ...state, apps: state.apps.filter(a => a.type !== appType) })), on(AppContextActions.finalizeApp, (state, { appType, data, appId }) => {
|
|
3096
|
+
reducer: createReducer(initialAppContextState, on(AppContextActionsInternal.setCurrentApp, (state, { app, mode, url }) => ({ ...state, currentApp: app ? { ...app, viewMode: mode, navigationUrl: url } : null })), on(AppContextActions.removeApp, (state, { appType }) => ({ ...state, apps: state.apps.filter(a => a.type !== appType) })), on(AppContextActions.finalizeApp, (state, { appType, data, appId, actions }) => {
|
|
3057
3097
|
const appsOfType = state.apps.filter(a => a.type === appType);
|
|
3058
3098
|
if (appsOfType.length === 0)
|
|
3059
3099
|
throw new Error(`App type: ${appType} not found. Cannot finalize app.`);
|
|
3060
3100
|
let updatedAppsOfType;
|
|
3061
3101
|
if (appsOfType.length === 1 && !appsOfType[0].id) {
|
|
3062
|
-
updatedAppsOfType = [{ ...appsOfType[0], data, id: appId, }];
|
|
3102
|
+
updatedAppsOfType = [{ ...appsOfType[0], data, id: appId, actions }];
|
|
3063
3103
|
}
|
|
3064
3104
|
else {
|
|
3065
|
-
updatedAppsOfType = [...appsOfType, { ...appsOfType[0], data, id: appId, }];
|
|
3105
|
+
updatedAppsOfType = [...appsOfType, { ...appsOfType[0], data, id: appId, actions }];
|
|
3066
3106
|
}
|
|
3067
3107
|
const remainingApps = state.apps.filter(a => a.type !== appType);
|
|
3068
3108
|
return { ...state, apps: [...remainingApps, ...updatedAppsOfType], };
|
|
@@ -3279,6 +3319,11 @@ function provideRlbConfig(env) {
|
|
|
3279
3319
|
const authService = inject(AuthenticationService);
|
|
3280
3320
|
return authService.checkAuthMultiple();
|
|
3281
3321
|
}),
|
|
3322
|
+
provideAppInitializer(() => {
|
|
3323
|
+
const aclStore = inject(AclStore);
|
|
3324
|
+
// We call the rxMethod, AppInitializer can guarantee that this logic will be executed before routing
|
|
3325
|
+
return aclStore.loadACL();
|
|
3326
|
+
}),
|
|
3282
3327
|
{ provide: RLB_CFG, useValue: env },
|
|
3283
3328
|
{ provide: RLB_CFG_ENV, useValue: env.environment },
|
|
3284
3329
|
{ provide: RLB_CFG_CMS, useValue: env.cms },
|
|
@@ -3332,5 +3377,5 @@ function flattenRoutes(routes, parentPath = '') {
|
|
|
3332
3377
|
* Generated bundle index. Do not edit.
|
|
3333
3378
|
*/
|
|
3334
3379
|
|
|
3335
|
-
export { AbstractMdService, AbstractSupportService, AclActions, AppBreadcrumbService, AppContainerComponent, AppContextActions, AppContextActionsInternal, AppLoggerService, AppStorageService, AppTemplateComponent, AppsService, AsMultiPipe, AsSinglePipe, AuthActions, AuthActionsInternal, AuthFeatureService, AuthenticationService, AutolinkPipe, BaseComponent, CmsComponent, CmsPipe, ContentComponent, CookiesService, ErrorManagementService, ErrorModalComponent, KeycloakProfileService, LanguageService, LeftComponentPipe, LocalCacheService, ModalAppsComponent, NavbarActions, NavbarActionsInternal, OauthPasswordService, ParseJwtService, PwaUpdaterService, RLB_APPS, RLB_APP_NAVCOMP, RLB_CFG, RLB_CFG_ACL, RLB_CFG_AUTH, RLB_CFG_CMS, RLB_CFG_ENV, RLB_CFG_I18N, RLB_CFG_PAGES, RightComponentPipe, RlbAppModule, RlbRole, SidebarActions, SidebarActionsInternal, StrapiService, ToastComponent, TokenOauthInterceptor, TranslateBrowserLoader, TruncatePipe, UtilsService, aclFeatureKey, appContextFeatureKey, authsFeatureKey, getDefaultRoutes, initialAclState, initialAppContextState, initialAuthState, initialNavbarState, initialSidebarState, navbarsFeatureKey, oauthGuard, oauthPasswordGuard, permissionGuard, provideApp, provideRlbCodeBrowserOAuth, provideRlbConfig, provideRlbI18n, sidebarsFeatureKey, translateBrowserLoaderFactory, verifyDeactivate };
|
|
3380
|
+
export { AbstractMdService, AbstractSupportService, AclActions, AppBreadcrumbService, AppContainerComponent, AppContextActions, AppContextActionsInternal, AppLoggerService, AppStorageService, AppTemplateComponent, AppsService, AsMultiPipe, AsSinglePipe, AuthActions, AuthActionsInternal, AuthFeatureService, AuthenticationService, AutolinkPipe, BaseComponent, CmsComponent, CmsPipe, ContentComponent, CookiesService, ErrorManagementService, ErrorModalComponent, KeycloakProfileService, LanguageService, LeftComponentPipe, LocalCacheService, ModalAppsComponent, NavbarActions, NavbarActionsInternal, OauthPasswordService, ParseJwtService, PwaUpdaterService, RLB_APPS, RLB_APP_NAVCOMP, RLB_CFG, RLB_CFG_ACL, RLB_CFG_AUTH, RLB_CFG_CMS, RLB_CFG_ENV, RLB_CFG_I18N, RLB_CFG_PAGES, RLB_INIT_PROVIDER, RightComponentPipe, RlbAppModule, RlbRole, SidebarActions, SidebarActionsInternal, StrapiService, ToastComponent, TokenOauthInterceptor, TranslateBrowserLoader, TruncatePipe, UtilsService, aclFeatureKey, appContextFeatureKey, authsFeatureKey, getDefaultRoutes, initialAclState, initialAppContextState, initialAuthState, initialNavbarState, initialSidebarState, navbarsFeatureKey, oauthGuard, oauthPasswordGuard, permissionGuard, provideApp, provideRlbCodeBrowserOAuth, provideRlbConfig, provideRlbI18n, sidebarsFeatureKey, translateBrowserLoaderFactory, verifyDeactivate };
|
|
3336
3381
|
//# sourceMappingURL=open-rlb-ng-app.mjs.map
|