@bravobit/bb-foundation 0.23.6 → 0.24.0
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/auth.session.d.ts +5 -0
- 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 +6 -6
- package/esm2020/auth/lib/auth.session.mjs +8 -1
- 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 +57 -0
- package/esm2020/permissions/lib/handlers/abstract.handler.mjs +3 -0
- package/esm2020/permissions/lib/handlers/role.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 +86 -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 +40 -254
- 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 +301 -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 +33 -231
- 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 +289 -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 +9 -4
- 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/role.handler.d.ts +9 -0
- package/permissions/lib/permissions.interface.d.ts +11 -0
- package/permissions/lib/permissions.module.d.ts +10 -0
- package/permissions/lib/permissions.service.d.ts +22 -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 -16
- 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 -64
|
@@ -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';
|
|
@@ -205,6 +205,13 @@ class AuthSession {
|
|
|
205
205
|
// Init methods.
|
|
206
206
|
this.restoreFromStorage();
|
|
207
207
|
}
|
|
208
|
+
get snapshot() {
|
|
209
|
+
return {
|
|
210
|
+
user: this._user$.getValue(),
|
|
211
|
+
accessToken: this.accessToken,
|
|
212
|
+
refreshToken: this.refreshToken
|
|
213
|
+
};
|
|
214
|
+
}
|
|
208
215
|
get accessToken() {
|
|
209
216
|
return this.isTokenValid(this._accessTokenPayload)
|
|
210
217
|
? this._accessTokenString
|
|
@@ -361,7 +368,7 @@ class Auth {
|
|
|
361
368
|
async signIn(provider, as) {
|
|
362
369
|
const { accessToken, refreshToken, user, ...result } = await provider.authenticate(this._httpClient);
|
|
363
370
|
// Check if the role matches.
|
|
364
|
-
const role =
|
|
371
|
+
const role = user?.role ?? null;
|
|
365
372
|
if (as && !as.includes(role)) {
|
|
366
373
|
throw new Error('Invalid role.');
|
|
367
374
|
}
|
|
@@ -509,7 +516,7 @@ class Auth {
|
|
|
509
516
|
clearTimeout?.(this._refreshHandler);
|
|
510
517
|
this._refreshHandler = null;
|
|
511
518
|
}
|
|
512
|
-
this._refreshHandler = setTimeout?.(() => this.autoRefresh(), cappedTiming);
|
|
519
|
+
this._refreshHandler = window?.setTimeout?.(() => this.autoRefresh(), cappedTiming);
|
|
513
520
|
}
|
|
514
521
|
catch {
|
|
515
522
|
// Just ignore it.
|
|
@@ -535,9 +542,9 @@ class Auth {
|
|
|
535
542
|
.join('/');
|
|
536
543
|
}
|
|
537
544
|
}
|
|
538
|
-
Auth.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.
|
|
539
|
-
Auth.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.
|
|
540
|
-
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: [{
|
|
541
548
|
type: Injectable
|
|
542
549
|
}], ctorParameters: function () { return [{ type: i1.Storage }, { type: i0.Injector }, { type: i2.Platform }, { type: i3.HttpClient }, { type: AuthConfig, decorators: [{
|
|
543
550
|
type: Optional
|
|
@@ -577,9 +584,9 @@ class BbAuthenticated extends AbstractAuthDirective {
|
|
|
577
584
|
this._subscription?.unsubscribe();
|
|
578
585
|
}
|
|
579
586
|
}
|
|
580
|
-
BbAuthenticated.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.
|
|
581
|
-
BbAuthenticated.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.
|
|
582
|
-
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: [{
|
|
583
590
|
type: Directive,
|
|
584
591
|
args: [{
|
|
585
592
|
selector: '[bbAuthenticated]'
|
|
@@ -588,149 +595,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImpor
|
|
|
588
595
|
type: Input
|
|
589
596
|
}] } });
|
|
590
597
|
|
|
591
|
-
class Permissions {
|
|
592
|
-
constructor(_auth, _config) {
|
|
593
|
-
this._auth = _auth;
|
|
594
|
-
this._config = _config;
|
|
595
|
-
// Data.
|
|
596
|
-
this._permissionHandler = this._config?.permissions ?? null;
|
|
597
|
-
}
|
|
598
|
-
has(value, options) {
|
|
599
|
-
const requiredPermissions = this.getRequiredPermissions(value);
|
|
600
|
-
if (requiredPermissions?.length <= 0) {
|
|
601
|
-
return of(false);
|
|
602
|
-
}
|
|
603
|
-
return this._auth.user.pipe(map(user => {
|
|
604
|
-
if (user === null || user === undefined || !this._permissionHandler) {
|
|
605
|
-
return false;
|
|
606
|
-
}
|
|
607
|
-
const mode = options?.mode ?? 'and';
|
|
608
|
-
switch (mode) {
|
|
609
|
-
case 'or':
|
|
610
|
-
return this.verifyModeOr(requiredPermissions, user);
|
|
611
|
-
case 'and':
|
|
612
|
-
default:
|
|
613
|
-
return this.verifyModeAnd(requiredPermissions, user);
|
|
614
|
-
}
|
|
615
|
-
}), distinctUntilChanged());
|
|
616
|
-
}
|
|
617
|
-
verifyModeAnd(permissions, user) {
|
|
618
|
-
for (const permission of permissions) {
|
|
619
|
-
const verified = this._permissionHandler.verifyForUser(permission, user);
|
|
620
|
-
if (!verified) {
|
|
621
|
-
return false;
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
return true;
|
|
625
|
-
}
|
|
626
|
-
verifyModeOr(permissions, user) {
|
|
627
|
-
for (const permission of permissions) {
|
|
628
|
-
const verified = this._permissionHandler.verifyForUser(permission, user);
|
|
629
|
-
if (verified) {
|
|
630
|
-
return true;
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
return false;
|
|
634
|
-
}
|
|
635
|
-
getRequiredPermissions(value) {
|
|
636
|
-
return Array.isArray(value)
|
|
637
|
-
? value
|
|
638
|
-
: [value];
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
Permissions.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: Permissions, deps: [{ token: Auth }, { token: AuthConfig, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
642
|
-
Permissions.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: Permissions });
|
|
643
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: Permissions, decorators: [{
|
|
644
|
-
type: Injectable
|
|
645
|
-
}], ctorParameters: function () { return [{ type: Auth }, { type: AuthConfig, decorators: [{
|
|
646
|
-
type: Optional
|
|
647
|
-
}] }]; } });
|
|
648
|
-
|
|
649
|
-
class BbPermission extends AbstractAuthDirective {
|
|
650
|
-
constructor(_permissions, _templateRef, _viewContainerRef) {
|
|
651
|
-
super(_templateRef, _viewContainerRef);
|
|
652
|
-
this._permissions = _permissions;
|
|
653
|
-
this._templateRef = _templateRef;
|
|
654
|
-
this._viewContainerRef = _viewContainerRef;
|
|
655
|
-
// Data.
|
|
656
|
-
this._permission$ = new BehaviorSubject([]);
|
|
657
|
-
this._mode$ = new BehaviorSubject('and');
|
|
658
|
-
// Subscriptions.
|
|
659
|
-
this._subscription = new Subscription();
|
|
660
|
-
}
|
|
661
|
-
set bbPermission(value) {
|
|
662
|
-
const permissions = Array.isArray(value) ? value : [value];
|
|
663
|
-
this._permission$.next(permissions);
|
|
664
|
-
this.updateView();
|
|
665
|
-
}
|
|
666
|
-
set bbPermissionElse(templateRef) {
|
|
667
|
-
this.assertTemplate('bbPermissionElse', templateRef);
|
|
668
|
-
this.elseTemplateRef = templateRef;
|
|
669
|
-
this.updateView();
|
|
670
|
-
}
|
|
671
|
-
set bbPermissionMode(mode) {
|
|
672
|
-
this._mode$.next(mode);
|
|
673
|
-
}
|
|
674
|
-
ngOnInit() {
|
|
675
|
-
const check$ = combineLatest([this._permission$, this._mode$]).pipe(switchMap(([permissions, mode]) => this._permissions.has(permissions, { mode })), distinctUntilChanged());
|
|
676
|
-
const subscription = check$.subscribe(valid => {
|
|
677
|
-
this.valid = valid;
|
|
678
|
-
this.updateView();
|
|
679
|
-
});
|
|
680
|
-
this._subscription.add(subscription);
|
|
681
|
-
}
|
|
682
|
-
ngOnDestroy() {
|
|
683
|
-
this._subscription?.unsubscribe();
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
BbPermission.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: BbPermission, deps: [{ token: Permissions }, { token: i0.TemplateRef }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
687
|
-
BbPermission.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.2", type: BbPermission, selector: "[bbPermission]", inputs: { bbPermission: "bbPermission", bbPermissionElse: "bbPermissionElse", bbPermissionMode: "bbPermissionMode" }, usesInheritance: true, ngImport: i0 });
|
|
688
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: BbPermission, decorators: [{
|
|
689
|
-
type: Directive,
|
|
690
|
-
args: [{
|
|
691
|
-
selector: '[bbPermission]'
|
|
692
|
-
}]
|
|
693
|
-
}], ctorParameters: function () { return [{ type: Permissions }, { type: i0.TemplateRef }, { type: i0.ViewContainerRef }]; }, propDecorators: { bbPermission: [{
|
|
694
|
-
type: Input
|
|
695
|
-
}], bbPermissionElse: [{
|
|
696
|
-
type: Input
|
|
697
|
-
}], bbPermissionMode: [{
|
|
698
|
-
type: Input
|
|
699
|
-
}] } });
|
|
700
|
-
|
|
701
|
-
class AppPermissions {
|
|
702
|
-
constructor(_data) {
|
|
703
|
-
this._data = _data;
|
|
704
|
-
}
|
|
705
|
-
verify(permission, role) {
|
|
706
|
-
if ((typeof ngDevMode === 'undefined' || ngDevMode) && !this._data?.[role]) {
|
|
707
|
-
console?.warn?.(`Current permissions do not include role: "${role}".`);
|
|
708
|
-
}
|
|
709
|
-
const availablePermissions = this._data?.[role] ?? [];
|
|
710
|
-
return availablePermissions.includes(permission);
|
|
711
|
-
}
|
|
712
|
-
verifyForUser(permission, data) {
|
|
713
|
-
const role = this.getRole(data);
|
|
714
|
-
return this.verify(permission, role);
|
|
715
|
-
}
|
|
716
|
-
getRole(data) {
|
|
717
|
-
return data?.['role'] ?? null;
|
|
718
|
-
}
|
|
719
|
-
static forRoles(data) {
|
|
720
|
-
const permissions = Object.keys(data) ?? [];
|
|
721
|
-
const roles = permissions.reduce((previous, current) => ([
|
|
722
|
-
...previous,
|
|
723
|
-
...(data?.[current] ?? [])
|
|
724
|
-
]), []);
|
|
725
|
-
const uniqueRoles = [...new Set(roles)];
|
|
726
|
-
const formattedData = uniqueRoles.reduce((previous, current) => {
|
|
727
|
-
const rolePermissions = permissions.filter(permission => data?.[permission]?.includes(current));
|
|
728
|
-
return { ...previous, [current]: rolePermissions };
|
|
729
|
-
}, {});
|
|
730
|
-
return new AppPermissions(formattedData);
|
|
731
|
-
}
|
|
732
|
-
}
|
|
733
|
-
|
|
734
598
|
class BbAnonymousGuard {
|
|
735
599
|
constructor(_auth, _router, _config, _handler) {
|
|
736
600
|
this._auth = _auth;
|
|
@@ -760,9 +624,9 @@ class BbAnonymousGuard {
|
|
|
760
624
|
return this.canActivate(childRoute, state);
|
|
761
625
|
}
|
|
762
626
|
}
|
|
763
|
-
BbAnonymousGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.
|
|
764
|
-
BbAnonymousGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.
|
|
765
|
-
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: [{
|
|
766
630
|
type: Injectable,
|
|
767
631
|
args: [{
|
|
768
632
|
providedIn: 'root'
|
|
@@ -808,9 +672,9 @@ class BbAuthenticatedGuard {
|
|
|
808
672
|
return this.canActivate(childRoute, state);
|
|
809
673
|
}
|
|
810
674
|
}
|
|
811
|
-
BbAuthenticatedGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.
|
|
812
|
-
BbAuthenticatedGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.
|
|
813
|
-
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: [{
|
|
814
678
|
type: Injectable,
|
|
815
679
|
args: [{
|
|
816
680
|
providedIn: 'root'
|
|
@@ -824,61 +688,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImpor
|
|
|
824
688
|
args: [AUTH_REDIRECT_HANDLER]
|
|
825
689
|
}] }]; } });
|
|
826
690
|
|
|
827
|
-
class BbPermissionGuard {
|
|
828
|
-
constructor(_router, _permissions, _config, _handler) {
|
|
829
|
-
this._router = _router;
|
|
830
|
-
this._permissions = _permissions;
|
|
831
|
-
this._config = _config;
|
|
832
|
-
this._handler = _handler;
|
|
833
|
-
}
|
|
834
|
-
canActivate(snapshot, state) {
|
|
835
|
-
const permission = snapshot?.data?.['permission'] ?? null;
|
|
836
|
-
const permission$ = this.parsePermission(permission);
|
|
837
|
-
return permission$.pipe(map(valid => {
|
|
838
|
-
if (valid) {
|
|
839
|
-
return true;
|
|
840
|
-
}
|
|
841
|
-
if (this._handler) {
|
|
842
|
-
return this._handler.onPermissionDenied(snapshot, state);
|
|
843
|
-
}
|
|
844
|
-
const nextUrl = this._config?.redirects?.permissionDenied ?? null;
|
|
845
|
-
if (!nextUrl) {
|
|
846
|
-
return false;
|
|
847
|
-
}
|
|
848
|
-
const commands = Array.isArray(nextUrl) ? nextUrl : [nextUrl];
|
|
849
|
-
return valid ? true : this._router.createUrlTree(commands);
|
|
850
|
-
}));
|
|
851
|
-
}
|
|
852
|
-
canActivateChild(childRoute, state) {
|
|
853
|
-
return this.canActivate(childRoute, state);
|
|
854
|
-
}
|
|
855
|
-
parsePermission(data) {
|
|
856
|
-
if ((typeof ngDevMode === 'undefined' || ngDevMode) && (data === undefined || data === null)) {
|
|
857
|
-
console?.warn?.(`No "data.permission" property was passed.`);
|
|
858
|
-
return of(false);
|
|
859
|
-
}
|
|
860
|
-
if (Array.isArray(data) || typeof data === 'string') {
|
|
861
|
-
return this._permissions.has(data);
|
|
862
|
-
}
|
|
863
|
-
return this._permissions.has(data?.value, data?.options);
|
|
864
|
-
}
|
|
865
|
-
}
|
|
866
|
-
BbPermissionGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", 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 });
|
|
867
|
-
BbPermissionGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: BbPermissionGuard, providedIn: 'root' });
|
|
868
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: BbPermissionGuard, decorators: [{
|
|
869
|
-
type: Injectable,
|
|
870
|
-
args: [{
|
|
871
|
-
providedIn: 'root'
|
|
872
|
-
}]
|
|
873
|
-
}], ctorParameters: function () { return [{ type: i2$1.Router }, { type: Permissions }, { type: AuthConfig, decorators: [{
|
|
874
|
-
type: Optional
|
|
875
|
-
}] }, { type: undefined, decorators: [{
|
|
876
|
-
type: Optional
|
|
877
|
-
}, {
|
|
878
|
-
type: Inject,
|
|
879
|
-
args: [AUTH_REDIRECT_HANDLER]
|
|
880
|
-
}] }]; } });
|
|
881
|
-
|
|
882
691
|
class AuthInterceptor {
|
|
883
692
|
constructor(_auth, _config) {
|
|
884
693
|
this._auth = _auth;
|
|
@@ -952,25 +761,20 @@ class AuthInterceptor {
|
|
|
952
761
|
return of(null);
|
|
953
762
|
}
|
|
954
763
|
}
|
|
955
|
-
AuthInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.
|
|
956
|
-
AuthInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.
|
|
957
|
-
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: [{
|
|
958
767
|
type: Injectable
|
|
959
768
|
}], ctorParameters: function () { return [{ type: Auth }, { type: AuthConfig, decorators: [{
|
|
960
769
|
type: Optional
|
|
961
770
|
}] }]; } });
|
|
962
771
|
|
|
963
|
-
const DECLARATIONS_EXPORTS = [
|
|
964
|
-
BbAuthenticated,
|
|
965
|
-
BbPermission
|
|
966
|
-
];
|
|
967
772
|
class AuthModule {
|
|
968
773
|
static forRoot(config) {
|
|
969
774
|
return {
|
|
970
775
|
ngModule: AuthModule,
|
|
971
776
|
providers: [
|
|
972
777
|
Auth,
|
|
973
|
-
Permissions,
|
|
974
778
|
{ provide: AuthConfig, useValue: config },
|
|
975
779
|
{ provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true },
|
|
976
780
|
{ useFactory: initializeAuth, provide: APP_INITIALIZER, deps: [Auth], multi: true }
|
|
@@ -978,17 +782,15 @@ class AuthModule {
|
|
|
978
782
|
};
|
|
979
783
|
}
|
|
980
784
|
}
|
|
981
|
-
AuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.
|
|
982
|
-
AuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
AuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: AuthModule, imports: [HttpClientModule] });
|
|
986
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", 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: [{
|
|
987
789
|
type: NgModule,
|
|
988
790
|
args: [{
|
|
989
791
|
imports: [HttpClientModule],
|
|
990
|
-
declarations: [
|
|
991
|
-
exports: [
|
|
792
|
+
declarations: [BbAuthenticated],
|
|
793
|
+
exports: [BbAuthenticated]
|
|
992
794
|
}]
|
|
993
795
|
}] });
|
|
994
796
|
function initializeAuth(auth) {
|
|
@@ -999,5 +801,5 @@ function initializeAuth(auth) {
|
|
|
999
801
|
* Generated bundle index. Do not edit.
|
|
1000
802
|
*/
|
|
1001
803
|
|
|
1002
|
-
export { AUTH_REDIRECT_HANDLER,
|
|
804
|
+
export { AUTH_REDIRECT_HANDLER, Auth, AuthConfig, AuthEmailProvider, AuthModule, AuthSession, AuthVerifyProvider, BbAnonymousGuard, BbAuthenticated, BbAuthenticatedGuard, JwtHelper, USE_AUTHORIZATION, initializeAuth };
|
|
1003
805
|
//# sourceMappingURL=bravobit-bb-foundation-auth.mjs.map
|