@bravobit/bb-foundation 0.23.7 → 0.24.1
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/auth/lib/auth.module.d.ts +2 -3
- package/auth/lib/interfaces/config.interface.d.ts +0 -4
- package/auth/public_api.d.ts +0 -5
- package/esm2020/auth/lib/auth.interceptor.mjs +4 -4
- package/esm2020/auth/lib/auth.module.mjs +7 -16
- package/esm2020/auth/lib/auth.service.mjs +5 -5
- package/esm2020/auth/lib/directives/authenticated.directive.mjs +4 -4
- package/esm2020/auth/lib/guards/anonymous.guard.mjs +4 -4
- package/esm2020/auth/lib/guards/authenticated.guard.mjs +4 -4
- package/esm2020/auth/lib/interfaces/config.interface.mjs +1 -1
- package/esm2020/auth/public_api.mjs +1 -6
- package/esm2020/collections/lib/collections.module.mjs +5 -5
- package/esm2020/collections/lib/components/collections-pager/collections-pager.component.mjs +4 -4
- package/esm2020/collections/lib/components/collections-viewer/collections-viewer.component.mjs +4 -4
- package/esm2020/collections/lib/components/collections.directive.mjs +13 -13
- package/esm2020/controls/lib/checkbox/checkbox/checkbox.component.mjs +4 -4
- package/esm2020/controls/lib/checkbox/checkbox-group/checkbox-group.component.mjs +4 -4
- package/esm2020/controls/lib/checkbox/checkbox.module.mjs +5 -5
- package/esm2020/controls/lib/control-error/control-error/control-error.component.mjs +4 -4
- package/esm2020/controls/lib/control-error/control-error-submit.directive.mjs +4 -4
- package/esm2020/controls/lib/control-error/control-error.module.mjs +5 -5
- package/esm2020/controls/lib/controls.module.mjs +5 -5
- package/esm2020/controls/lib/form-control/form-control/form-control.component.mjs +4 -4
- package/esm2020/controls/lib/form-control/form-control-addon/form-control-addon.component.mjs +4 -4
- package/esm2020/controls/lib/form-control/form-control-input.directive.mjs +4 -4
- package/esm2020/controls/lib/form-control/form-control.module.mjs +5 -5
- package/esm2020/controls/lib/radio/radio-button/radio-button.component.mjs +4 -4
- package/esm2020/controls/lib/radio/radio-group/radio-group.component.mjs +4 -4
- package/esm2020/controls/lib/radio/radio.module.mjs +5 -5
- package/esm2020/controls/lib/toggle/toggle/toggle.component.mjs +4 -4
- package/esm2020/controls/lib/toggle/toggle-group/toggle-group.component.mjs +4 -4
- package/esm2020/controls/lib/toggle/toggle.module.mjs +5 -5
- package/esm2020/dashboard/lib/dashboard/dashboard.component.mjs +4 -4
- package/esm2020/dashboard/lib/dashboard-header/dashboard-header.component.mjs +4 -4
- package/esm2020/dashboard/lib/dashboard-menu/dashboard-menu.component.mjs +4 -4
- package/esm2020/dashboard/lib/dashboard-menu-item/dashboard-menu-item.component.mjs +4 -4
- package/esm2020/dashboard/lib/dashboard-sidebar/dashboard-sidebar.component.mjs +4 -4
- package/esm2020/dashboard/lib/dashboard-sidebar-group/dashboard-sidebar-group.component.mjs +4 -4
- package/esm2020/dashboard/lib/dashboard-sidebar-item/dashboard-sidebar-item.component.mjs +4 -4
- package/esm2020/dashboard/lib/dashboard.module.mjs +5 -5
- package/esm2020/dialog/lib/dialog-actions/dialog-actions.component.mjs +4 -4
- package/esm2020/dialog/lib/dialog-confirm/dialog-confirm.component.mjs +4 -4
- package/esm2020/dialog/lib/dialog-container/dialog-container.component.mjs +4 -4
- package/esm2020/dialog/lib/dialog-header/dialog-header.component.mjs +4 -4
- package/esm2020/dialog/lib/dialog-link/dialog-link.component.mjs +4 -4
- package/esm2020/dialog/lib/dialog-modal/dialog-modal.component.mjs +4 -4
- package/esm2020/dialog/lib/dialog-overlay/dialog-overlay.component.mjs +4 -4
- package/esm2020/dialog/lib/dialog.insertion.mjs +4 -4
- package/esm2020/dialog/lib/dialog.module.mjs +5 -5
- package/esm2020/dialog/lib/dialog.service.mjs +4 -4
- package/esm2020/elements/lib/avatar/avatar.component.mjs +4 -4
- package/esm2020/elements/lib/button/button.component.mjs +7 -7
- package/esm2020/elements/lib/checkbox/checkbox.component.mjs +4 -4
- package/esm2020/elements/lib/date-picker/date-picker.component.mjs +4 -4
- package/esm2020/elements/lib/directives/addon.directive.mjs +7 -7
- package/esm2020/elements/lib/directives/form-submit.directive.mjs +4 -4
- package/esm2020/elements/lib/directives/form-submitter.directive.mjs +4 -4
- package/esm2020/elements/lib/directives/input.directive.mjs +7 -7
- package/esm2020/elements/lib/dropdown/dropdown.component.mjs +7 -7
- package/esm2020/elements/lib/elements.module.mjs +5 -5
- package/esm2020/elements/lib/file-picker/file-picker.component.mjs +4 -4
- package/esm2020/elements/lib/form-control/form-control.component.mjs +4 -4
- package/esm2020/elements/lib/form-error/form-error.component.mjs +4 -4
- package/esm2020/elements/lib/form-group/form-group.component.mjs +4 -4
- package/esm2020/elements/lib/icon/icon.component.mjs +4 -4
- package/esm2020/elements/lib/image-picker/image-picker.component.mjs +4 -4
- package/esm2020/elements/lib/pipes/file-image.pipe.mjs +4 -4
- package/esm2020/elements/lib/pipes/file-size.pipe.mjs +4 -4
- package/esm2020/elements/lib/pipes/relative-time.pipe.mjs +4 -4
- package/esm2020/elements/lib/spinner/spinner.component.mjs +4 -4
- package/esm2020/elements/lib/tag/tag.component.mjs +4 -4
- package/esm2020/http/lib/http.module.mjs +5 -5
- package/esm2020/http/lib/interceptors/base-url.interceptor.mjs +4 -4
- package/esm2020/http/lib/interceptors/error.interceptor.mjs +4 -4
- package/esm2020/lib/core/services/clipboard.service.mjs +4 -4
- package/esm2020/lib/core/services/exif.service.mjs +4 -4
- package/esm2020/lib/core/services/file-loader.service.mjs +4 -4
- package/esm2020/lib/core/services/image-converter.service.mjs +4 -4
- package/esm2020/lib/core/services/languages.service.mjs +4 -4
- package/esm2020/lib/core/services/network.service.mjs +4 -4
- package/esm2020/lib/core/services/patch.service.mjs +4 -4
- package/esm2020/localize/lib/localize.module.mjs +5 -5
- package/esm2020/localize/lib/localize.pipe.mjs +4 -4
- package/esm2020/localize/lib/localize.service.mjs +4 -4
- package/esm2020/localize/lib/views/localize-string/localize-string.component.mjs +4 -4
- package/esm2020/localize/lib/views/localize-template.directive.mjs +4 -4
- package/esm2020/masking/lib/directives/currency-mask.directive.mjs +4 -4
- package/esm2020/masking/lib/directives/date-mask.directive.mjs +4 -4
- package/esm2020/masking/lib/directives/input-mask.directive.mjs +4 -4
- package/esm2020/masking/lib/masking.module.mjs +5 -5
- package/esm2020/masking/lib/masking.service.mjs +4 -4
- package/esm2020/notifications/lib/notifications-item/notifications-item.component.mjs +4 -4
- package/esm2020/notifications/lib/notifications-list/notifications-list.component.mjs +4 -4
- package/esm2020/notifications/lib/notifications.module.mjs +5 -5
- package/esm2020/notifications/lib/notifications.service.mjs +4 -4
- package/esm2020/permissions/bravobit-bb-foundation-permissions.mjs +5 -0
- package/esm2020/permissions/lib/directives/permission.directive.mjs +88 -0
- package/esm2020/permissions/lib/guards/permission.guard.mjs +56 -0
- package/esm2020/permissions/lib/handlers/abstract.handler.mjs +3 -0
- package/esm2020/permissions/lib/handlers/local.handler.mjs +27 -0
- package/esm2020/permissions/lib/permissions.interface.mjs +3 -0
- package/esm2020/permissions/lib/permissions.module.mjs +39 -0
- package/esm2020/permissions/lib/permissions.service.mjs +96 -0
- package/esm2020/permissions/public_api.mjs +8 -0
- package/esm2020/recaptcha/lib/recaptcha/recaptcha.component.mjs +4 -4
- package/esm2020/recaptcha/lib/recaptcha-loader.service.mjs +4 -4
- package/esm2020/recaptcha/lib/recaptcha.module.mjs +5 -5
- package/esm2020/storage/lib/storage.service.mjs +4 -4
- package/esm2020/table/lib/components/table/table.component.mjs +10 -10
- package/esm2020/table/lib/components/table-cell/table-cell.component.mjs +4 -4
- package/esm2020/table/lib/components/table-header-cell/table-header-cell.component.mjs +4 -4
- package/esm2020/table/lib/components/table-pager/table-pager.component.mjs +4 -4
- package/esm2020/table/lib/table.module.mjs +5 -5
- package/esm2020/theming/lib/theming.directive.mjs +4 -4
- package/esm2020/theming/lib/theming.module.mjs +5 -5
- package/esm2020/utils/lib/directives/autosize.directive.mjs +4 -4
- package/esm2020/utils/lib/directives/focus-trap.directive.mjs +4 -4
- package/esm2020/utils/lib/directives/focus.directive.mjs +4 -4
- package/esm2020/utils/lib/directives/template.directive.mjs +4 -4
- package/esm2020/utils/lib/utils.module.mjs +5 -5
- package/fesm2015/bravobit-bb-foundation-auth.mjs +30 -261
- package/fesm2015/bravobit-bb-foundation-auth.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-collections.mjs +22 -22
- package/fesm2015/bravobit-bb-foundation-collections.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-controls.mjs +57 -57
- package/fesm2015/bravobit-bb-foundation-controls.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-dashboard.mjs +25 -25
- package/fesm2015/bravobit-bb-foundation-dashboard.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-dialog.mjs +31 -31
- package/fesm2015/bravobit-bb-foundation-dialog.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-elements.mjs +76 -76
- package/fesm2015/bravobit-bb-foundation-elements.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-http.mjs +10 -10
- package/fesm2015/bravobit-bb-foundation-http.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-localize.mjs +16 -16
- package/fesm2015/bravobit-bb-foundation-localize.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-masking.mjs +16 -16
- package/fesm2015/bravobit-bb-foundation-masking.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-notifications.mjs +13 -13
- package/fesm2015/bravobit-bb-foundation-notifications.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-permissions.mjs +310 -0
- package/fesm2015/bravobit-bb-foundation-permissions.mjs.map +1 -0
- package/fesm2015/bravobit-bb-foundation-recaptcha.mjs +10 -10
- package/fesm2015/bravobit-bb-foundation-recaptcha.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-storage.mjs +3 -3
- package/fesm2015/bravobit-bb-foundation-storage.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-table.mjs +22 -22
- package/fesm2015/bravobit-bb-foundation-table.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-theming.mjs +7 -7
- package/fesm2015/bravobit-bb-foundation-theming.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-utils.mjs +16 -16
- package/fesm2015/bravobit-bb-foundation-utils.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation.mjs +21 -21
- package/fesm2015/bravobit-bb-foundation.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-auth.mjs +25 -239
- package/fesm2020/bravobit-bb-foundation-auth.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-collections.mjs +22 -22
- package/fesm2020/bravobit-bb-foundation-collections.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-controls.mjs +57 -57
- package/fesm2020/bravobit-bb-foundation-controls.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-dashboard.mjs +25 -25
- package/fesm2020/bravobit-bb-foundation-dashboard.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-dialog.mjs +31 -31
- package/fesm2020/bravobit-bb-foundation-dialog.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-elements.mjs +76 -76
- package/fesm2020/bravobit-bb-foundation-elements.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-http.mjs +10 -10
- package/fesm2020/bravobit-bb-foundation-http.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-localize.mjs +16 -16
- package/fesm2020/bravobit-bb-foundation-localize.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-masking.mjs +16 -16
- package/fesm2020/bravobit-bb-foundation-masking.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-notifications.mjs +13 -13
- package/fesm2020/bravobit-bb-foundation-notifications.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-permissions.mjs +298 -0
- package/fesm2020/bravobit-bb-foundation-permissions.mjs.map +1 -0
- package/fesm2020/bravobit-bb-foundation-recaptcha.mjs +10 -10
- package/fesm2020/bravobit-bb-foundation-recaptcha.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-storage.mjs +3 -3
- package/fesm2020/bravobit-bb-foundation-storage.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-table.mjs +22 -22
- package/fesm2020/bravobit-bb-foundation-table.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-theming.mjs +7 -7
- package/fesm2020/bravobit-bb-foundation-theming.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-utils.mjs +16 -16
- package/fesm2020/bravobit-bb-foundation-utils.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation.mjs +21 -21
- package/fesm2020/bravobit-bb-foundation.mjs.map +1 -1
- package/package.json +13 -5
- package/permissions/index.d.ts +5 -0
- package/{auth → permissions}/lib/directives/permission.directive.d.ts +11 -6
- package/{auth → permissions}/lib/guards/permission.guard.d.ts +4 -5
- package/permissions/lib/handlers/abstract.handler.d.ts +4 -0
- package/permissions/lib/handlers/local.handler.d.ts +10 -0
- package/permissions/lib/permissions.interface.d.ts +12 -0
- package/permissions/lib/permissions.module.d.ts +10 -0
- package/permissions/lib/permissions.service.d.ts +23 -0
- package/permissions/public_api.d.ts +7 -0
- package/README.md +0 -47
- package/auth/lib/interfaces/permission.interface.d.ts +0 -6
- package/auth/lib/permissions/permissions.handler.d.ts +0 -9
- package/auth/lib/permissions/permissions.service.d.ts +0 -18
- package/esm2020/auth/lib/directives/permission.directive.mjs +0 -58
- package/esm2020/auth/lib/guards/permission.guard.mjs +0 -63
- package/esm2020/auth/lib/interfaces/permission.interface.mjs +0 -2
- package/esm2020/auth/lib/permissions/permissions.handler.mjs +0 -33
- package/esm2020/auth/lib/permissions/permissions.service.mjs +0 -73
|
@@ -2,8 +2,8 @@ import * as i0 from '@angular/core';
|
|
|
2
2
|
import { InjectionToken, Injectable, Optional, Inject, Directive, Input, APP_INITIALIZER, NgModule } from '@angular/core';
|
|
3
3
|
import * as i3 from '@angular/common/http';
|
|
4
4
|
import { HttpContextToken, HttpContext, HttpErrorResponse, HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http';
|
|
5
|
-
import { shareReplay, tap, map, distinctUntilChanged,
|
|
6
|
-
import { firstValueFrom, BehaviorSubject, of, Subscription,
|
|
5
|
+
import { shareReplay, tap, map, distinctUntilChanged, catchError, filter, take, switchMap, finalize } from 'rxjs/operators';
|
|
6
|
+
import { firstValueFrom, BehaviorSubject, of, Subscription, first, throwError } from 'rxjs';
|
|
7
7
|
import * as i5 from '@angular/platform-browser';
|
|
8
8
|
import { makeStateKey } from '@angular/platform-browser';
|
|
9
9
|
import * as i2$1 from '@angular/router';
|
|
@@ -368,7 +368,7 @@ class Auth {
|
|
|
368
368
|
async signIn(provider, as) {
|
|
369
369
|
const { accessToken, refreshToken, user, ...result } = await provider.authenticate(this._httpClient);
|
|
370
370
|
// Check if the role matches.
|
|
371
|
-
const role =
|
|
371
|
+
const role = user?.role ?? null;
|
|
372
372
|
if (as && !as.includes(role)) {
|
|
373
373
|
throw new Error('Invalid role.');
|
|
374
374
|
}
|
|
@@ -542,9 +542,9 @@ class Auth {
|
|
|
542
542
|
.join('/');
|
|
543
543
|
}
|
|
544
544
|
}
|
|
545
|
-
Auth.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.
|
|
546
|
-
Auth.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.
|
|
547
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.
|
|
545
|
+
Auth.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.10", ngImport: i0, type: Auth, deps: [{ token: i1.Storage }, { token: i0.Injector }, { token: i2.Platform }, { token: i3.HttpClient }, { token: AuthConfig, optional: true }, { token: i5.TransferState, optional: true }, { token: i6.HttpConfig, optional: true }, { token: AUTH_REDIRECT_HANDLER, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
546
|
+
Auth.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.10", ngImport: i0, type: Auth });
|
|
547
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.10", ngImport: i0, type: Auth, decorators: [{
|
|
548
548
|
type: Injectable
|
|
549
549
|
}], ctorParameters: function () { return [{ type: i1.Storage }, { type: i0.Injector }, { type: i2.Platform }, { type: i3.HttpClient }, { type: AuthConfig, decorators: [{
|
|
550
550
|
type: Optional
|
|
@@ -584,9 +584,9 @@ class BbAuthenticated extends AbstractAuthDirective {
|
|
|
584
584
|
this._subscription?.unsubscribe();
|
|
585
585
|
}
|
|
586
586
|
}
|
|
587
|
-
BbAuthenticated.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.
|
|
588
|
-
BbAuthenticated.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.
|
|
589
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.
|
|
587
|
+
BbAuthenticated.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.10", ngImport: i0, type: BbAuthenticated, deps: [{ token: Auth }, { token: i0.TemplateRef }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
588
|
+
BbAuthenticated.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.10", type: BbAuthenticated, selector: "[bbAuthenticated]", inputs: { bbAuthenticatedElse: "bbAuthenticatedElse" }, usesInheritance: true, ngImport: i0 });
|
|
589
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.10", ngImport: i0, type: BbAuthenticated, decorators: [{
|
|
590
590
|
type: Directive,
|
|
591
591
|
args: [{
|
|
592
592
|
selector: '[bbAuthenticated]'
|
|
@@ -595,158 +595,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.5", ngImpor
|
|
|
595
595
|
type: Input
|
|
596
596
|
}] } });
|
|
597
597
|
|
|
598
|
-
class Permissions {
|
|
599
|
-
constructor(_auth, _config) {
|
|
600
|
-
this._auth = _auth;
|
|
601
|
-
this._config = _config;
|
|
602
|
-
// Data.
|
|
603
|
-
this._permissionHandler = this._config?.permissions ?? null;
|
|
604
|
-
}
|
|
605
|
-
has(value, options) {
|
|
606
|
-
const requiredPermissions = this.getRequiredPermissions(value);
|
|
607
|
-
if (requiredPermissions?.length <= 0) {
|
|
608
|
-
return of(false);
|
|
609
|
-
}
|
|
610
|
-
return this._auth.user.pipe(map(user => this.hasPermission(requiredPermissions, user, options)), distinctUntilChanged());
|
|
611
|
-
}
|
|
612
|
-
hasSync(value, options) {
|
|
613
|
-
const requiredPermissions = this.getRequiredPermissions(value);
|
|
614
|
-
if (requiredPermissions?.length <= 0) {
|
|
615
|
-
return false;
|
|
616
|
-
}
|
|
617
|
-
const user = this._auth?.session?.snapshot?.user ?? null;
|
|
618
|
-
return this.hasPermission(requiredPermissions, user, options);
|
|
619
|
-
}
|
|
620
|
-
hasPermission(requiredPermissions, user, options) {
|
|
621
|
-
if (user === null || user === undefined || !this._permissionHandler) {
|
|
622
|
-
return false;
|
|
623
|
-
}
|
|
624
|
-
const mode = options?.mode ?? 'and';
|
|
625
|
-
switch (mode) {
|
|
626
|
-
case 'or':
|
|
627
|
-
return this.verifyModeOr(requiredPermissions, user);
|
|
628
|
-
case 'and':
|
|
629
|
-
default:
|
|
630
|
-
return this.verifyModeAnd(requiredPermissions, user);
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
verifyModeAnd(permissions, user) {
|
|
634
|
-
for (const permission of permissions) {
|
|
635
|
-
const verified = this._permissionHandler.verifyForUser(permission, user);
|
|
636
|
-
if (!verified) {
|
|
637
|
-
return false;
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
return true;
|
|
641
|
-
}
|
|
642
|
-
verifyModeOr(permissions, user) {
|
|
643
|
-
for (const permission of permissions) {
|
|
644
|
-
const verified = this._permissionHandler.verifyForUser(permission, user);
|
|
645
|
-
if (verified) {
|
|
646
|
-
return true;
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
|
-
return false;
|
|
650
|
-
}
|
|
651
|
-
getRequiredPermissions(value) {
|
|
652
|
-
return Array.isArray(value)
|
|
653
|
-
? value
|
|
654
|
-
: [value];
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
Permissions.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.5", ngImport: i0, type: Permissions, deps: [{ token: Auth }, { token: AuthConfig, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
658
|
-
Permissions.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.5", ngImport: i0, type: Permissions });
|
|
659
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.5", ngImport: i0, type: Permissions, decorators: [{
|
|
660
|
-
type: Injectable
|
|
661
|
-
}], ctorParameters: function () { return [{ type: Auth }, { type: AuthConfig, decorators: [{
|
|
662
|
-
type: Optional
|
|
663
|
-
}] }]; } });
|
|
664
|
-
|
|
665
|
-
class BbPermission extends AbstractAuthDirective {
|
|
666
|
-
constructor(_permissions, _templateRef, _viewContainerRef) {
|
|
667
|
-
super(_templateRef, _viewContainerRef);
|
|
668
|
-
this._permissions = _permissions;
|
|
669
|
-
this._templateRef = _templateRef;
|
|
670
|
-
this._viewContainerRef = _viewContainerRef;
|
|
671
|
-
// Data.
|
|
672
|
-
this._permission$ = new BehaviorSubject([]);
|
|
673
|
-
this._mode$ = new BehaviorSubject('and');
|
|
674
|
-
// Subscriptions.
|
|
675
|
-
this._subscription = new Subscription();
|
|
676
|
-
}
|
|
677
|
-
set bbPermission(value) {
|
|
678
|
-
const permissions = Array.isArray(value) ? value : [value];
|
|
679
|
-
this._permission$.next(permissions);
|
|
680
|
-
this.updateView();
|
|
681
|
-
}
|
|
682
|
-
set bbPermissionElse(templateRef) {
|
|
683
|
-
this.assertTemplate('bbPermissionElse', templateRef);
|
|
684
|
-
this.elseTemplateRef = templateRef;
|
|
685
|
-
this.updateView();
|
|
686
|
-
}
|
|
687
|
-
set bbPermissionMode(mode) {
|
|
688
|
-
this._mode$.next(mode);
|
|
689
|
-
}
|
|
690
|
-
ngOnInit() {
|
|
691
|
-
const check$ = combineLatest([this._permission$, this._mode$]).pipe(switchMap(([permissions, mode]) => this._permissions.has(permissions, { mode })), distinctUntilChanged());
|
|
692
|
-
const subscription = check$.subscribe(valid => {
|
|
693
|
-
this.valid = valid;
|
|
694
|
-
this.updateView();
|
|
695
|
-
});
|
|
696
|
-
this._subscription.add(subscription);
|
|
697
|
-
}
|
|
698
|
-
ngOnDestroy() {
|
|
699
|
-
this._subscription?.unsubscribe();
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
BbPermission.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.5", ngImport: i0, type: BbPermission, deps: [{ token: Permissions }, { token: i0.TemplateRef }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
703
|
-
BbPermission.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.5", type: BbPermission, selector: "[bbPermission]", inputs: { bbPermission: "bbPermission", bbPermissionElse: "bbPermissionElse", bbPermissionMode: "bbPermissionMode" }, usesInheritance: true, ngImport: i0 });
|
|
704
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.5", ngImport: i0, type: BbPermission, decorators: [{
|
|
705
|
-
type: Directive,
|
|
706
|
-
args: [{
|
|
707
|
-
selector: '[bbPermission]'
|
|
708
|
-
}]
|
|
709
|
-
}], ctorParameters: function () { return [{ type: Permissions }, { type: i0.TemplateRef }, { type: i0.ViewContainerRef }]; }, propDecorators: { bbPermission: [{
|
|
710
|
-
type: Input
|
|
711
|
-
}], bbPermissionElse: [{
|
|
712
|
-
type: Input
|
|
713
|
-
}], bbPermissionMode: [{
|
|
714
|
-
type: Input
|
|
715
|
-
}] } });
|
|
716
|
-
|
|
717
|
-
class AppPermissions {
|
|
718
|
-
constructor(_data) {
|
|
719
|
-
this._data = _data;
|
|
720
|
-
}
|
|
721
|
-
verify(permission, role) {
|
|
722
|
-
if ((typeof ngDevMode === 'undefined' || ngDevMode) && !this._data?.[role]) {
|
|
723
|
-
console?.warn?.(`Current permissions do not include role: "${role}".`);
|
|
724
|
-
}
|
|
725
|
-
const availablePermissions = this._data?.[role] ?? [];
|
|
726
|
-
return availablePermissions.includes(permission);
|
|
727
|
-
}
|
|
728
|
-
verifyForUser(permission, data) {
|
|
729
|
-
const role = this.getRole(data);
|
|
730
|
-
return this.verify(permission, role);
|
|
731
|
-
}
|
|
732
|
-
getRole(data) {
|
|
733
|
-
return data?.['role'] ?? null;
|
|
734
|
-
}
|
|
735
|
-
static forRoles(data) {
|
|
736
|
-
const permissions = Object.keys(data) ?? [];
|
|
737
|
-
const roles = permissions.reduce((previous, current) => ([
|
|
738
|
-
...previous,
|
|
739
|
-
...(data?.[current] ?? [])
|
|
740
|
-
]), []);
|
|
741
|
-
const uniqueRoles = [...new Set(roles)];
|
|
742
|
-
const formattedData = uniqueRoles.reduce((previous, current) => {
|
|
743
|
-
const rolePermissions = permissions.filter(permission => data?.[permission]?.includes(current));
|
|
744
|
-
return { ...previous, [current]: rolePermissions };
|
|
745
|
-
}, {});
|
|
746
|
-
return new AppPermissions(formattedData);
|
|
747
|
-
}
|
|
748
|
-
}
|
|
749
|
-
|
|
750
598
|
class BbAnonymousGuard {
|
|
751
599
|
constructor(_auth, _router, _config, _handler) {
|
|
752
600
|
this._auth = _auth;
|
|
@@ -776,9 +624,9 @@ class BbAnonymousGuard {
|
|
|
776
624
|
return this.canActivate(childRoute, state);
|
|
777
625
|
}
|
|
778
626
|
}
|
|
779
|
-
BbAnonymousGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.
|
|
780
|
-
BbAnonymousGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.
|
|
781
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.
|
|
627
|
+
BbAnonymousGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.10", ngImport: i0, type: BbAnonymousGuard, deps: [{ token: Auth }, { token: i2$1.Router }, { token: AuthConfig, optional: true }, { token: AUTH_REDIRECT_HANDLER, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
628
|
+
BbAnonymousGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.10", ngImport: i0, type: BbAnonymousGuard, providedIn: 'root' });
|
|
629
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.10", ngImport: i0, type: BbAnonymousGuard, decorators: [{
|
|
782
630
|
type: Injectable,
|
|
783
631
|
args: [{
|
|
784
632
|
providedIn: 'root'
|
|
@@ -824,9 +672,9 @@ class BbAuthenticatedGuard {
|
|
|
824
672
|
return this.canActivate(childRoute, state);
|
|
825
673
|
}
|
|
826
674
|
}
|
|
827
|
-
BbAuthenticatedGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.
|
|
828
|
-
BbAuthenticatedGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.
|
|
829
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.
|
|
675
|
+
BbAuthenticatedGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.10", ngImport: i0, type: BbAuthenticatedGuard, deps: [{ token: Auth }, { token: i2$1.Router }, { token: AuthConfig, optional: true }, { token: AUTH_REDIRECT_HANDLER, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
676
|
+
BbAuthenticatedGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.10", ngImport: i0, type: BbAuthenticatedGuard, providedIn: 'root' });
|
|
677
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.10", ngImport: i0, type: BbAuthenticatedGuard, decorators: [{
|
|
830
678
|
type: Injectable,
|
|
831
679
|
args: [{
|
|
832
680
|
providedIn: 'root'
|
|
@@ -840,61 +688,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.5", ngImpor
|
|
|
840
688
|
args: [AUTH_REDIRECT_HANDLER]
|
|
841
689
|
}] }]; } });
|
|
842
690
|
|
|
843
|
-
class BbPermissionGuard {
|
|
844
|
-
constructor(_router, _permissions, _config, _handler) {
|
|
845
|
-
this._router = _router;
|
|
846
|
-
this._permissions = _permissions;
|
|
847
|
-
this._config = _config;
|
|
848
|
-
this._handler = _handler;
|
|
849
|
-
}
|
|
850
|
-
canActivate(snapshot, state) {
|
|
851
|
-
const permission = snapshot?.data?.['permission'] ?? null;
|
|
852
|
-
const permission$ = this.parsePermission(permission);
|
|
853
|
-
return permission$.pipe(map(valid => {
|
|
854
|
-
if (valid) {
|
|
855
|
-
return true;
|
|
856
|
-
}
|
|
857
|
-
if (this._handler) {
|
|
858
|
-
return this._handler.onPermissionDenied(snapshot, state);
|
|
859
|
-
}
|
|
860
|
-
const nextUrl = this._config?.redirects?.permissionDenied ?? null;
|
|
861
|
-
if (!nextUrl) {
|
|
862
|
-
return false;
|
|
863
|
-
}
|
|
864
|
-
const commands = Array.isArray(nextUrl) ? nextUrl : [nextUrl];
|
|
865
|
-
return valid ? true : this._router.createUrlTree(commands);
|
|
866
|
-
}));
|
|
867
|
-
}
|
|
868
|
-
canActivateChild(childRoute, state) {
|
|
869
|
-
return this.canActivate(childRoute, state);
|
|
870
|
-
}
|
|
871
|
-
parsePermission(data) {
|
|
872
|
-
if ((typeof ngDevMode === 'undefined' || ngDevMode) && (data === undefined || data === null)) {
|
|
873
|
-
console?.warn?.(`No "data.permission" property was passed.`);
|
|
874
|
-
return of(false);
|
|
875
|
-
}
|
|
876
|
-
if (Array.isArray(data) || typeof data === 'string') {
|
|
877
|
-
return this._permissions.has(data);
|
|
878
|
-
}
|
|
879
|
-
return this._permissions.has(data?.value, data?.options);
|
|
880
|
-
}
|
|
881
|
-
}
|
|
882
|
-
BbPermissionGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.5", ngImport: i0, type: BbPermissionGuard, deps: [{ token: i2$1.Router }, { token: Permissions }, { token: AuthConfig, optional: true }, { token: AUTH_REDIRECT_HANDLER, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
883
|
-
BbPermissionGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.5", ngImport: i0, type: BbPermissionGuard, providedIn: 'root' });
|
|
884
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.5", ngImport: i0, type: BbPermissionGuard, decorators: [{
|
|
885
|
-
type: Injectable,
|
|
886
|
-
args: [{
|
|
887
|
-
providedIn: 'root'
|
|
888
|
-
}]
|
|
889
|
-
}], ctorParameters: function () { return [{ type: i2$1.Router }, { type: Permissions }, { type: AuthConfig, decorators: [{
|
|
890
|
-
type: Optional
|
|
891
|
-
}] }, { type: undefined, decorators: [{
|
|
892
|
-
type: Optional
|
|
893
|
-
}, {
|
|
894
|
-
type: Inject,
|
|
895
|
-
args: [AUTH_REDIRECT_HANDLER]
|
|
896
|
-
}] }]; } });
|
|
897
|
-
|
|
898
691
|
class AuthInterceptor {
|
|
899
692
|
constructor(_auth, _config) {
|
|
900
693
|
this._auth = _auth;
|
|
@@ -968,25 +761,20 @@ class AuthInterceptor {
|
|
|
968
761
|
return of(null);
|
|
969
762
|
}
|
|
970
763
|
}
|
|
971
|
-
AuthInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.
|
|
972
|
-
AuthInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.
|
|
973
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.
|
|
764
|
+
AuthInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.10", ngImport: i0, type: AuthInterceptor, deps: [{ token: Auth }, { token: AuthConfig, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
765
|
+
AuthInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.10", ngImport: i0, type: AuthInterceptor });
|
|
766
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.10", ngImport: i0, type: AuthInterceptor, decorators: [{
|
|
974
767
|
type: Injectable
|
|
975
768
|
}], ctorParameters: function () { return [{ type: Auth }, { type: AuthConfig, decorators: [{
|
|
976
769
|
type: Optional
|
|
977
770
|
}] }]; } });
|
|
978
771
|
|
|
979
|
-
const DECLARATIONS_EXPORTS = [
|
|
980
|
-
BbAuthenticated,
|
|
981
|
-
BbPermission
|
|
982
|
-
];
|
|
983
772
|
class AuthModule {
|
|
984
773
|
static forRoot(config) {
|
|
985
774
|
return {
|
|
986
775
|
ngModule: AuthModule,
|
|
987
776
|
providers: [
|
|
988
777
|
Auth,
|
|
989
|
-
Permissions,
|
|
990
778
|
{ provide: AuthConfig, useValue: config },
|
|
991
779
|
{ provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true },
|
|
992
780
|
{ useFactory: initializeAuth, provide: APP_INITIALIZER, deps: [Auth], multi: true }
|
|
@@ -994,17 +782,15 @@ class AuthModule {
|
|
|
994
782
|
};
|
|
995
783
|
}
|
|
996
784
|
}
|
|
997
|
-
AuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.
|
|
998
|
-
AuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
AuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.5", ngImport: i0, type: AuthModule, imports: [HttpClientModule] });
|
|
1002
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.5", ngImport: i0, type: AuthModule, decorators: [{
|
|
785
|
+
AuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.10", ngImport: i0, type: AuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
786
|
+
AuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.10", ngImport: i0, type: AuthModule, declarations: [BbAuthenticated], imports: [HttpClientModule], exports: [BbAuthenticated] });
|
|
787
|
+
AuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.10", ngImport: i0, type: AuthModule, imports: [HttpClientModule] });
|
|
788
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.10", ngImport: i0, type: AuthModule, decorators: [{
|
|
1003
789
|
type: NgModule,
|
|
1004
790
|
args: [{
|
|
1005
791
|
imports: [HttpClientModule],
|
|
1006
|
-
declarations: [
|
|
1007
|
-
exports: [
|
|
792
|
+
declarations: [BbAuthenticated],
|
|
793
|
+
exports: [BbAuthenticated]
|
|
1008
794
|
}]
|
|
1009
795
|
}] });
|
|
1010
796
|
function initializeAuth(auth) {
|
|
@@ -1015,5 +801,5 @@ function initializeAuth(auth) {
|
|
|
1015
801
|
* Generated bundle index. Do not edit.
|
|
1016
802
|
*/
|
|
1017
803
|
|
|
1018
|
-
export { AUTH_REDIRECT_HANDLER,
|
|
804
|
+
export { AUTH_REDIRECT_HANDLER, Auth, AuthConfig, AuthEmailProvider, AuthModule, AuthSession, AuthVerifyProvider, BbAnonymousGuard, BbAuthenticated, BbAuthenticatedGuard, JwtHelper, USE_AUTHORIZATION, initializeAuth };
|
|
1019
805
|
//# sourceMappingURL=bravobit-bb-foundation-auth.mjs.map
|