@bravobit/bb-foundation 0.21.6 → 0.22.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.interceptor.d.ts +1 -1
- package/auth/lib/auth.module.d.ts +4 -5
- package/auth/lib/auth.service.d.ts +4 -7
- package/auth/lib/directives/abstract.directive.d.ts +12 -0
- package/auth/lib/directives/authenticated.directive.d.ts +7 -4
- package/auth/lib/directives/permission.directive.d.ts +11 -11
- package/auth/lib/guards/anonymous.guard.d.ts +8 -5
- package/auth/lib/guards/authenticated.guard.d.ts +8 -5
- package/auth/lib/guards/permission.guard.d.ts +15 -0
- package/auth/lib/interfaces/config.interface.d.ts +14 -8
- package/auth/lib/interfaces/permission.interface.d.ts +6 -0
- package/auth/lib/interfaces/provider.interface.d.ts +10 -3
- package/auth/lib/permissions/permissions.handler.d.ts +9 -0
- package/auth/lib/permissions/permissions.service.d.ts +16 -0
- package/auth/lib/providers/email.provider.d.ts +2 -8
- package/auth/lib/providers/verify.provider.d.ts +2 -6
- package/auth/public_api.d.ts +4 -4
- package/controls/lib/checkbox/checkbox/checkbox.component.d.ts +5 -1
- package/controls/lib/control-error/control-error/control-error.animation.d.ts +1 -0
- package/controls/lib/control-error/control-error/control-error.component.d.ts +17 -0
- package/controls/lib/control-error/control-error-submit.directive.d.ts +15 -0
- package/controls/lib/control-error/control-error.defaults.d.ts +2 -0
- package/controls/lib/control-error/control-error.interface.d.ts +12 -0
- package/controls/lib/control-error/control-error.module.d.ts +9 -0
- package/controls/lib/controls.interfaces.d.ts +4 -0
- package/controls/lib/controls.module.d.ts +7 -2
- package/controls/lib/form-control/form-control/form-control.component.d.ts +31 -0
- package/controls/lib/form-control/form-control-addon/form-control-addon.component.d.ts +6 -0
- package/controls/lib/form-control/form-control-input.directive.d.ts +35 -0
- package/controls/lib/form-control/form-control.module.d.ts +11 -0
- package/controls/public_api.d.ts +9 -0
- package/dashboard/lib/dashboard/dashboard.component.d.ts +2 -1
- package/dialog/lib/dialog-confirm/dialog-confirm.component.d.ts +10 -5
- package/dialog/lib/dialog-container/dialog-container.animations.d.ts +1 -0
- package/dialog/lib/dialog-container/dialog-container.component.d.ts +5 -7
- package/dialog/lib/dialog-header/dialog-header.component.d.ts +1 -3
- package/dialog/lib/dialog-modal/dialog-modal.component.d.ts +7 -3
- package/dialog/lib/dialog-overlay/dialog-overlay.animations.d.ts +1 -0
- package/dialog/lib/dialog-overlay/dialog-overlay.component.d.ts +5 -7
- package/dialog/lib/dialog.service.d.ts +4 -3
- package/elements/lib/directives/focus-trap.directive.d.ts +1 -1
- package/elements/lib/directives/focus.directive.d.ts +1 -3
- package/elements/lib/pipes/file-image.pipe.d.ts +2 -1
- package/esm2020/auth/lib/auth.interceptor.mjs +9 -12
- package/esm2020/auth/lib/auth.module.mjs +7 -17
- package/esm2020/auth/lib/auth.service.mjs +29 -55
- package/esm2020/auth/lib/directives/abstract.directive.mjs +40 -0
- package/esm2020/auth/lib/directives/authenticated.directive.mjs +25 -14
- package/esm2020/auth/lib/directives/permission.directive.mjs +24 -46
- package/esm2020/auth/lib/guards/anonymous.guard.mjs +28 -19
- package/esm2020/auth/lib/guards/authenticated.guard.mjs +31 -20
- package/esm2020/auth/lib/guards/permission.guard.mjs +53 -0
- package/esm2020/auth/lib/helpers/jwt.helper.mjs +7 -7
- package/esm2020/auth/lib/interfaces/config.interface.mjs +1 -1
- package/esm2020/auth/lib/interfaces/permission.interface.mjs +2 -0
- package/esm2020/auth/lib/interfaces/provider.interface.mjs +1 -1
- package/esm2020/auth/lib/permissions/permissions.handler.mjs +33 -0
- package/esm2020/auth/lib/permissions/permissions.service.mjs +64 -0
- package/esm2020/auth/lib/providers/email.provider.mjs +8 -9
- package/esm2020/auth/lib/providers/verify.provider.mjs +8 -5
- package/esm2020/auth/public_api.mjs +5 -5
- package/esm2020/collections/lib/collections.module.mjs +4 -4
- package/esm2020/collections/lib/components/collections-pager/collections-pager.component.mjs +3 -3
- package/esm2020/collections/lib/components/collections-viewer/collections-viewer.component.mjs +3 -3
- package/esm2020/collections/lib/components/collections.directive.mjs +12 -12
- package/esm2020/controls/lib/checkbox/checkbox/checkbox.component.mjs +19 -6
- package/esm2020/controls/lib/checkbox/checkbox-group/checkbox-group.component.mjs +4 -4
- package/esm2020/controls/lib/checkbox/checkbox.module.mjs +4 -4
- package/esm2020/controls/lib/control-error/control-error/control-error.animation.mjs +14 -0
- package/esm2020/controls/lib/control-error/control-error/control-error.component.mjs +63 -0
- package/esm2020/controls/lib/control-error/control-error-submit.directive.mjs +47 -0
- package/esm2020/controls/lib/control-error/control-error.defaults.mjs +26 -0
- package/esm2020/controls/lib/control-error/control-error.interface.mjs +3 -0
- package/esm2020/controls/lib/control-error/control-error.module.mjs +19 -0
- package/esm2020/controls/lib/controls.interfaces.mjs +2 -0
- package/esm2020/controls/lib/controls.module.mjs +45 -8
- package/esm2020/controls/lib/form-control/form-control/form-control.component.mjs +94 -0
- package/esm2020/controls/lib/form-control/form-control-addon/form-control-addon.component.mjs +22 -0
- package/esm2020/controls/lib/form-control/form-control-input.directive.mjs +124 -0
- package/esm2020/controls/lib/form-control/form-control.module.mjs +33 -0
- package/esm2020/controls/public_api.mjs +10 -1
- package/esm2020/dashboard/lib/dashboard/dashboard.component.mjs +7 -6
- package/esm2020/dashboard/lib/dashboard-header/dashboard-header.component.mjs +3 -3
- package/esm2020/dashboard/lib/dashboard-menu/dashboard-menu.component.mjs +3 -3
- package/esm2020/dashboard/lib/dashboard-menu-item/dashboard-menu-item.component.mjs +3 -3
- package/esm2020/dashboard/lib/dashboard-sidebar/dashboard-sidebar.component.mjs +3 -3
- package/esm2020/dashboard/lib/dashboard-sidebar-group/dashboard-sidebar-group.component.mjs +3 -3
- package/esm2020/dashboard/lib/dashboard-sidebar-item/dashboard-sidebar-item.component.mjs +3 -3
- package/esm2020/dashboard/lib/dashboard.module.mjs +4 -4
- package/esm2020/dialog/lib/dialog-actions/dialog-actions.component.mjs +3 -3
- package/esm2020/dialog/lib/dialog-confirm/dialog-confirm.component.mjs +17 -11
- package/esm2020/dialog/lib/dialog-container/dialog-container.animations.mjs +29 -0
- package/esm2020/dialog/lib/dialog-container/dialog-container.component.mjs +28 -104
- package/esm2020/dialog/lib/dialog-header/dialog-header.component.mjs +7 -14
- package/esm2020/dialog/lib/dialog-link/dialog-link.component.mjs +4 -4
- package/esm2020/dialog/lib/dialog-modal/dialog-modal.component.mjs +29 -8
- package/esm2020/dialog/lib/dialog-overlay/dialog-overlay.animations.mjs +26 -0
- package/esm2020/dialog/lib/dialog-overlay/dialog-overlay.component.mjs +29 -84
- package/esm2020/dialog/lib/dialog.insertion.mjs +3 -3
- package/esm2020/dialog/lib/dialog.module.mjs +4 -4
- package/esm2020/dialog/lib/dialog.service.mjs +8 -7
- package/esm2020/elements/lib/avatar/avatar.component.mjs +8 -6
- package/esm2020/elements/lib/button/button.component.mjs +6 -6
- package/esm2020/elements/lib/checkbox/checkbox.component.mjs +3 -3
- package/esm2020/elements/lib/date-picker/date-picker.component.mjs +3 -3
- package/esm2020/elements/lib/directives/addon.directive.mjs +6 -6
- package/esm2020/elements/lib/directives/autosize.directive.mjs +3 -3
- package/esm2020/elements/lib/directives/focus-trap.directive.mjs +5 -5
- package/esm2020/elements/lib/directives/focus.directive.mjs +7 -9
- package/esm2020/elements/lib/directives/form-submit.directive.mjs +3 -3
- package/esm2020/elements/lib/directives/form-submitter.directive.mjs +3 -3
- package/esm2020/elements/lib/directives/input.directive.mjs +6 -6
- package/esm2020/elements/lib/directives/template.directive.mjs +3 -3
- package/esm2020/elements/lib/dropdown/dropdown.component.mjs +6 -6
- package/esm2020/elements/lib/elements.module.mjs +4 -4
- package/esm2020/elements/lib/file-picker/file-picker.component.mjs +3 -3
- package/esm2020/elements/lib/form-control/form-control.component.mjs +3 -3
- package/esm2020/elements/lib/form-error/form-error.component.mjs +3 -3
- package/esm2020/elements/lib/form-group/form-group.component.mjs +3 -3
- package/esm2020/elements/lib/icon/icon.component.mjs +3 -3
- package/esm2020/elements/lib/image-picker/image-picker.component.mjs +3 -3
- package/esm2020/elements/lib/pipes/file-image.pipe.mjs +8 -7
- package/esm2020/elements/lib/pipes/file-size.pipe.mjs +3 -3
- package/esm2020/elements/lib/pipes/relative-time.pipe.mjs +3 -3
- package/esm2020/elements/lib/spinner/spinner.component.mjs +3 -3
- package/esm2020/elements/lib/tag/tag.component.mjs +3 -3
- package/esm2020/http/lib/http.module.mjs +4 -4
- package/esm2020/http/lib/interceptors/base-url.interceptor.mjs +3 -3
- package/esm2020/http/lib/interceptors/error.interceptor.mjs +3 -3
- package/esm2020/lib/core/services/clipboard.service.mjs +5 -5
- package/esm2020/lib/core/services/exif.service.mjs +5 -5
- package/esm2020/lib/core/services/file-loader.service.mjs +3 -3
- package/esm2020/lib/core/services/image-converter.service.mjs +5 -5
- package/esm2020/lib/core/services/languages.service.mjs +3 -3
- package/esm2020/lib/core/services/network.service.mjs +7 -7
- package/esm2020/lib/core/services/patch.service.mjs +7 -7
- package/esm2020/localize/lib/localize.module.mjs +4 -4
- package/esm2020/localize/lib/localize.pipe.mjs +3 -3
- package/esm2020/localize/lib/localize.service.mjs +5 -5
- package/esm2020/localize/lib/views/localize-string/localize-string.component.mjs +3 -3
- package/esm2020/localize/lib/views/localize-template-or-string.directive.mjs +3 -3
- package/esm2020/localize/lib/views/localize-template.directive.mjs +3 -3
- package/esm2020/masking/lib/directives/currency-mask.directive.mjs +3 -3
- package/esm2020/masking/lib/directives/date-mask.directive.mjs +3 -3
- package/esm2020/masking/lib/directives/input-mask.directive.mjs +3 -3
- package/esm2020/masking/lib/masking.module.mjs +4 -4
- package/esm2020/masking/lib/masking.service.mjs +3 -3
- package/esm2020/notifications/lib/notifications-item/notifications-item.component.mjs +5 -5
- package/esm2020/notifications/lib/notifications-list/notifications-list.component.mjs +7 -7
- package/esm2020/notifications/lib/notifications.module.mjs +4 -4
- package/esm2020/notifications/lib/notifications.service.mjs +5 -5
- package/esm2020/public_api.mjs +1 -2
- package/esm2020/recaptcha/lib/recaptcha/recaptcha.component.mjs +3 -3
- package/esm2020/recaptcha/lib/recaptcha-loader.service.mjs +10 -10
- package/esm2020/recaptcha/lib/recaptcha.module.mjs +4 -4
- package/esm2020/storage/lib/storage.service.mjs +5 -5
- package/esm2020/table/lib/components/table/table.component.mjs +9 -9
- package/esm2020/table/lib/components/table-cell/table-cell.component.mjs +3 -3
- package/esm2020/table/lib/components/table-header-cell/table-header-cell.component.mjs +3 -3
- package/esm2020/table/lib/components/table-pager/table-pager.component.mjs +3 -3
- package/esm2020/table/lib/table.module.mjs +4 -4
- package/esm2020/theming/lib/themes/checkbox-group.theme.mjs +17 -2
- package/esm2020/theming/lib/themes/checkbox.theme.mjs +35 -2
- package/esm2020/theming/lib/themes/control-error.theme.mjs +11 -0
- package/esm2020/theming/lib/themes/form-control-addon.theme.mjs +6 -0
- package/esm2020/theming/lib/themes/form-control.theme.mjs +45 -0
- package/esm2020/theming/lib/theming.data.mjs +82 -0
- package/esm2020/theming/lib/theming.directive.mjs +38 -0
- package/esm2020/theming/lib/theming.interface.mjs +2 -3
- package/esm2020/theming/lib/theming.module.mjs +12 -34
- package/esm2020/theming/lib/utils/theming.variable.mjs +41 -0
- package/esm2020/theming/public_api.mjs +6 -3
- package/fesm2015/bravobit-bb-foundation-auth.mjs +326 -284
- package/fesm2015/bravobit-bb-foundation-auth.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-collections.mjs +22 -22
- package/fesm2015/bravobit-bb-foundation-controls.mjs +493 -24
- package/fesm2015/bravobit-bb-foundation-controls.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-dashboard.mjs +29 -28
- package/fesm2015/bravobit-bb-foundation-dashboard.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-dialog.mjs +185 -233
- package/fesm2015/bravobit-bb-foundation-dialog.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-elements.mjs +99 -97
- package/fesm2015/bravobit-bb-foundation-elements.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-http.mjs +10 -10
- package/fesm2015/bravobit-bb-foundation-localize.mjs +20 -20
- package/fesm2015/bravobit-bb-foundation-localize.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-masking.mjs +16 -16
- package/fesm2015/bravobit-bb-foundation-notifications.mjs +18 -17
- package/fesm2015/bravobit-bb-foundation-notifications.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-recaptcha.mjs +16 -16
- package/fesm2015/bravobit-bb-foundation-recaptcha.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-storage.mjs +4 -4
- package/fesm2015/bravobit-bb-foundation-storage.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-table.mjs +22 -22
- package/fesm2015/bravobit-bb-foundation-theming.mjs +251 -128
- package/fesm2015/bravobit-bb-foundation-theming.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation.mjs +33 -73
- package/fesm2015/bravobit-bb-foundation.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-auth.mjs +306 -277
- package/fesm2020/bravobit-bb-foundation-auth.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-collections.mjs +22 -22
- package/fesm2020/bravobit-bb-foundation-controls.mjs +477 -24
- package/fesm2020/bravobit-bb-foundation-controls.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-dashboard.mjs +29 -28
- package/fesm2020/bravobit-bb-foundation-dashboard.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-dialog.mjs +175 -233
- package/fesm2020/bravobit-bb-foundation-dialog.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-elements.mjs +99 -97
- package/fesm2020/bravobit-bb-foundation-elements.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-http.mjs +10 -10
- package/fesm2020/bravobit-bb-foundation-localize.mjs +20 -20
- package/fesm2020/bravobit-bb-foundation-localize.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-masking.mjs +16 -16
- package/fesm2020/bravobit-bb-foundation-notifications.mjs +17 -17
- package/fesm2020/bravobit-bb-foundation-notifications.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-recaptcha.mjs +16 -16
- package/fesm2020/bravobit-bb-foundation-recaptcha.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-storage.mjs +4 -4
- package/fesm2020/bravobit-bb-foundation-storage.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-table.mjs +22 -22
- package/fesm2020/bravobit-bb-foundation-theming.mjs +252 -120
- package/fesm2020/bravobit-bb-foundation-theming.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation.mjs +32 -70
- package/fesm2020/bravobit-bb-foundation.mjs.map +1 -1
- package/lib/core/services/clipboard.service.d.ts +2 -2
- package/lib/core/services/exif.service.d.ts +1 -1
- package/lib/core/services/image-converter.service.d.ts +1 -1
- package/lib/core/services/network.service.d.ts +4 -4
- package/lib/core/services/patch.service.d.ts +4 -4
- package/localize/lib/localize.service.d.ts +1 -1
- package/notifications/lib/notifications-item/notifications-item.component.d.ts +1 -1
- package/notifications/lib/notifications.service.d.ts +1 -1
- package/package.json +4 -4
- package/public_api.d.ts +0 -1
- package/recaptcha/lib/recaptcha-loader.service.d.ts +3 -3
- package/storage/lib/storage.service.d.ts +1 -1
- package/theming/lib/themes/checkbox-group.theme.d.ts +14 -3
- package/theming/lib/themes/checkbox.theme.d.ts +30 -17
- package/theming/lib/themes/control-error.theme.d.ts +9 -0
- package/theming/lib/themes/form-control-addon.theme.d.ts +5 -0
- package/theming/lib/themes/form-control.theme.d.ts +32 -0
- package/theming/lib/theming.data.d.ts +17 -0
- package/theming/lib/theming.directive.d.ts +13 -0
- package/theming/lib/theming.interface.d.ts +19 -8
- package/theming/lib/theming.module.d.ts +3 -9
- package/theming/lib/utils/theming.variable.d.ts +16 -0
- package/theming/public_api.d.ts +5 -2
- package/auth/lib/directives/role.directive.d.ts +0 -16
- package/auth/lib/helpers/mapper.helper.d.ts +0 -23
- package/auth/lib/interfaces/mapper.interface.d.ts +0 -19
- package/auth/lib/permissions.service.d.ts +0 -14
- package/esm2020/auth/lib/directives/role.directive.mjs +0 -37
- package/esm2020/auth/lib/helpers/mapper.helper.mjs +0 -35
- package/esm2020/auth/lib/interfaces/mapper.interface.mjs +0 -2
- package/esm2020/auth/lib/permissions.service.mjs +0 -56
- package/esm2020/lib/core/services/platform.service.mjs +0 -42
- package/esm2020/theming/lib/themes/theme.mjs +0 -34
- package/esm2020/theming/lib/theming.service.mjs +0 -77
- package/lib/core/services/platform.service.d.ts +0 -18
- package/theming/lib/themes/theme.d.ts +0 -12
- package/theming/lib/theming.service.d.ts +0 -22
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as i3 from '@angular/common/http';
|
|
2
2
|
import { HttpContextToken, HttpContext, HttpErrorResponse, HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http';
|
|
3
3
|
import * as i0 from '@angular/core';
|
|
4
4
|
import { Injectable, Optional, Directive, Input, APP_INITIALIZER, NgModule } from '@angular/core';
|
|
5
|
-
import { shareReplay,
|
|
5
|
+
import { shareReplay, tap, map, distinctUntilChanged, switchMap, catchError, filter, take, finalize } from 'rxjs/operators';
|
|
6
|
+
import { firstValueFrom, BehaviorSubject, of, Subscription, combineLatest, first, throwError } from 'rxjs';
|
|
6
7
|
import { __awaiter, __rest } from 'tslib';
|
|
7
|
-
import * as
|
|
8
|
+
import * as i5 from '@angular/platform-browser';
|
|
8
9
|
import { makeStateKey } from '@angular/platform-browser';
|
|
9
|
-
import
|
|
10
|
+
import * as i2$1 from '@angular/router';
|
|
10
11
|
import { Router } from '@angular/router';
|
|
11
12
|
import * as i1 from '@bravobit/bb-foundation/storage';
|
|
12
|
-
import * as
|
|
13
|
-
import * as
|
|
13
|
+
import * as i2 from '@angular/cdk/platform';
|
|
14
|
+
import * as i6 from '@bravobit/bb-foundation/http';
|
|
14
15
|
import { HttpError } from '@bravobit/bb-foundation/http';
|
|
15
16
|
|
|
16
17
|
class AuthConfig {
|
|
@@ -30,13 +31,14 @@ class JwtHelper {
|
|
|
30
31
|
}));
|
|
31
32
|
};
|
|
32
33
|
this.parse = (data) => {
|
|
34
|
+
var _a, _b, _c, _d, _e, _f;
|
|
33
35
|
return {
|
|
34
|
-
id: data['iss']
|
|
35
|
-
type: data['typ']
|
|
36
|
-
audience: data['aud']
|
|
37
|
-
issuer: data['iss']
|
|
38
|
-
subject: data['sub']
|
|
39
|
-
role: data['role']
|
|
36
|
+
id: (_a = data['iss']) !== null && _a !== void 0 ? _a : null,
|
|
37
|
+
type: (_b = data['typ']) !== null && _b !== void 0 ? _b : null,
|
|
38
|
+
audience: (_c = data['aud']) !== null && _c !== void 0 ? _c : null,
|
|
39
|
+
issuer: (_d = data['iss']) !== null && _d !== void 0 ? _d : null,
|
|
40
|
+
subject: (_e = data['sub']) !== null && _e !== void 0 ? _e : null,
|
|
41
|
+
role: (_f = data['role']) !== null && _f !== void 0 ? _f : null,
|
|
40
42
|
notValidBefore: this.parseDate(data['nbf']),
|
|
41
43
|
expiresAt: this.parseDate(data['exp']),
|
|
42
44
|
issuedAt: this.parseDate(data['iat'])
|
|
@@ -87,38 +89,45 @@ class JwtHelper {
|
|
|
87
89
|
}
|
|
88
90
|
}
|
|
89
91
|
|
|
90
|
-
class
|
|
91
|
-
constructor() {
|
|
92
|
-
|
|
93
|
-
this.
|
|
94
|
-
|
|
95
|
-
this.
|
|
96
|
-
|
|
97
|
-
this.
|
|
98
|
-
|
|
99
|
-
this.
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
92
|
+
class AbstractAuthDirective {
|
|
93
|
+
constructor(templateRef, viewContainerRef) {
|
|
94
|
+
this.templateRef = templateRef;
|
|
95
|
+
this.viewContainerRef = viewContainerRef;
|
|
96
|
+
// Data.
|
|
97
|
+
this.valid = false;
|
|
98
|
+
// Templates.
|
|
99
|
+
this.elseTemplateRef = null;
|
|
100
|
+
// View refs.
|
|
101
|
+
this.thenViewRef = null;
|
|
102
|
+
this.elseViewRef = null;
|
|
103
|
+
}
|
|
104
|
+
updateView() {
|
|
105
|
+
if (this.valid) {
|
|
106
|
+
if (!this.thenViewRef) {
|
|
107
|
+
this.viewContainerRef.clear();
|
|
108
|
+
this.elseViewRef = null;
|
|
109
|
+
if (this.templateRef) {
|
|
110
|
+
this.thenViewRef = this.viewContainerRef.createEmbeddedView(this.templateRef);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
if (!this.elseViewRef) {
|
|
116
|
+
this.viewContainerRef.clear();
|
|
117
|
+
this.thenViewRef = null;
|
|
118
|
+
if (this.elseTemplateRef) {
|
|
119
|
+
this.elseViewRef = this.viewContainerRef.createEmbeddedView(this.elseTemplateRef);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
assertTemplate(property, templateRef) {
|
|
125
|
+
const isTemplateRefOrNull = !!(!templateRef || templateRef.createEmbeddedView);
|
|
126
|
+
if (!isTemplateRefOrNull) {
|
|
127
|
+
throw new Error(`${property} must be a TemplateRef.`);
|
|
128
|
+
}
|
|
115
129
|
}
|
|
116
130
|
}
|
|
117
|
-
AuthMapper.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.5", ngImport: i0, type: AuthMapper, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
118
|
-
AuthMapper.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.5", ngImport: i0, type: AuthMapper });
|
|
119
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.5", ngImport: i0, type: AuthMapper, decorators: [{
|
|
120
|
-
type: Injectable
|
|
121
|
-
}] });
|
|
122
131
|
|
|
123
132
|
class AuthVerifyProvider {
|
|
124
133
|
constructor(_code, _verifyToken, _endpoint) {
|
|
@@ -129,13 +138,16 @@ class AuthVerifyProvider {
|
|
|
129
138
|
authenticate(httpClient) {
|
|
130
139
|
return __awaiter(this, void 0, void 0, function* () {
|
|
131
140
|
// Execute API call.
|
|
132
|
-
const data$ =
|
|
141
|
+
const data$ = httpClient.post(this._endpoint, {
|
|
133
142
|
token: this._code,
|
|
134
143
|
verify_token: this._verifyToken
|
|
135
144
|
});
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
145
|
+
const data = yield firstValueFrom(data$);
|
|
146
|
+
return {
|
|
147
|
+
accessToken: data === null || data === void 0 ? void 0 : data.token,
|
|
148
|
+
refreshToken: data === null || data === void 0 ? void 0 : data.refresh_token,
|
|
149
|
+
user: data === null || data === void 0 ? void 0 : data.user
|
|
150
|
+
};
|
|
139
151
|
});
|
|
140
152
|
}
|
|
141
153
|
}
|
|
@@ -149,18 +161,17 @@ class AuthEmailProvider {
|
|
|
149
161
|
authenticate(httpClient) {
|
|
150
162
|
return __awaiter(this, void 0, void 0, function* () {
|
|
151
163
|
// Execute API call.
|
|
152
|
-
const data$ =
|
|
164
|
+
const data$ = httpClient.post(this._endpoint, {
|
|
153
165
|
email: this._email,
|
|
154
166
|
password: this._password
|
|
155
167
|
});
|
|
156
|
-
const
|
|
157
|
-
// Map the data to the correct format.
|
|
168
|
+
const data = yield firstValueFrom(data$);
|
|
158
169
|
return {
|
|
159
|
-
accessToken: token,
|
|
160
|
-
refreshToken: refresh_token,
|
|
161
|
-
user: user,
|
|
162
|
-
provider: provider,
|
|
163
|
-
verifyToken: verify_token
|
|
170
|
+
accessToken: data === null || data === void 0 ? void 0 : data.token,
|
|
171
|
+
refreshToken: data === null || data === void 0 ? void 0 : data.refresh_token,
|
|
172
|
+
user: data === null || data === void 0 ? void 0 : data.user,
|
|
173
|
+
provider: data === null || data === void 0 ? void 0 : data.provider,
|
|
174
|
+
verifyToken: data === null || data === void 0 ? void 0 : data.verify_token
|
|
164
175
|
};
|
|
165
176
|
});
|
|
166
177
|
}
|
|
@@ -300,10 +311,9 @@ class AuthSession {
|
|
|
300
311
|
}
|
|
301
312
|
|
|
302
313
|
class Auth {
|
|
303
|
-
constructor(_storage,
|
|
314
|
+
constructor(_storage, _injector, _platform, _httpClient, _config, _state, _httpConfig) {
|
|
304
315
|
var _a, _b, _c;
|
|
305
316
|
this._storage = _storage;
|
|
306
|
-
this._mapper = _mapper;
|
|
307
317
|
this._injector = _injector;
|
|
308
318
|
this._platform = _platform;
|
|
309
319
|
this._httpClient = _httpClient;
|
|
@@ -360,18 +370,19 @@ class Auth {
|
|
|
360
370
|
return this._httpClient.get(url);
|
|
361
371
|
}
|
|
362
372
|
signIn(provider, as) {
|
|
363
|
-
var _a, _b;
|
|
373
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
364
374
|
return __awaiter(this, void 0, void 0, function* () {
|
|
365
|
-
const
|
|
375
|
+
const _k = yield provider.authenticate(this._httpClient), { accessToken, refreshToken, user } = _k, result = __rest(_k, ["accessToken", "refreshToken", "user"]);
|
|
366
376
|
// Check if the role matches.
|
|
367
|
-
|
|
377
|
+
const role = (_e = (_d = (_c = (_b = (_a = this._config) === null || _a === void 0 ? void 0 : _a.permissions) === null || _b === void 0 ? void 0 : _b.getRole) === null || _c === void 0 ? void 0 : _c.call(_b, user)) !== null && _d !== void 0 ? _d : user === null || user === void 0 ? void 0 : user.role) !== null && _e !== void 0 ? _e : null;
|
|
378
|
+
if (as && !as.includes(role)) {
|
|
368
379
|
throw new Error('Invalid role.');
|
|
369
380
|
}
|
|
370
381
|
// Validate if the provider is one of the available
|
|
371
382
|
// providers then return the user object and the provider.
|
|
372
|
-
const apiProvider = (
|
|
373
|
-
const apiVerifyToken = (
|
|
374
|
-
const availableProviders = ['email', 'sms', 'totp'];
|
|
383
|
+
const apiProvider = (_f = result === null || result === void 0 ? void 0 : result.provider) !== null && _f !== void 0 ? _f : null;
|
|
384
|
+
const apiVerifyToken = (_g = result === null || result === void 0 ? void 0 : result.verifyToken) !== null && _g !== void 0 ? _g : null;
|
|
385
|
+
const availableProviders = (_j = (_h = this._config) === null || _h === void 0 ? void 0 : _h.providers) !== null && _j !== void 0 ? _j : ['email', 'sms', 'totp'];
|
|
375
386
|
if (availableProviders.includes(apiProvider)) {
|
|
376
387
|
return { user, provider: apiProvider, verifyToken: apiVerifyToken };
|
|
377
388
|
}
|
|
@@ -410,17 +421,17 @@ class Auth {
|
|
|
410
421
|
const url = this.getUrl('auth/register');
|
|
411
422
|
const result$ = this._httpClient.post(url, data, options);
|
|
412
423
|
const result = yield firstValueFrom(result$);
|
|
413
|
-
// Map to the correct response.
|
|
414
|
-
const { accessToken, refreshToken, user } = this._mapper.toRegister(result);
|
|
415
424
|
// Set the tokens in storage.
|
|
416
|
-
this.setTokens(
|
|
425
|
+
this.setTokens(result === null || result === void 0 ? void 0 : result.token, result === null || result === void 0 ? void 0 : result.refresh_token);
|
|
417
426
|
// Set the user in storage.
|
|
427
|
+
const user = result === null || result === void 0 ? void 0 : result.user;
|
|
418
428
|
this.session.setUser(user);
|
|
419
429
|
// Return the user.
|
|
420
430
|
return user;
|
|
421
431
|
});
|
|
422
432
|
}
|
|
423
433
|
logout() {
|
|
434
|
+
var _a, _b, _c;
|
|
424
435
|
// If we don't have a refresh token just clear the session.
|
|
425
436
|
// Note: We do this because else we try to invalidate
|
|
426
437
|
// an "undefined" refresh token.
|
|
@@ -432,19 +443,20 @@ class Auth {
|
|
|
432
443
|
// invalidate it in the backend.
|
|
433
444
|
try {
|
|
434
445
|
const url = this.getUrl('auth/logout');
|
|
446
|
+
const headerName = (_c = (_b = (_a = this._config) === null || _a === void 0 ? void 0 : _a.http) === null || _b === void 0 ? void 0 : _b.header) !== null && _c !== void 0 ? _c : 'Authorization';
|
|
435
447
|
const observable$ = this._httpClient.get(url, {
|
|
436
|
-
headers: {
|
|
448
|
+
headers: { [headerName]: refreshToken }
|
|
437
449
|
});
|
|
438
|
-
firstValueFrom(observable$).then(_ => _);
|
|
450
|
+
firstValueFrom(observable$).then(_ => _).catch(_ => _);
|
|
439
451
|
}
|
|
440
|
-
catch (
|
|
452
|
+
catch (_d) {
|
|
441
453
|
// Do nothing because the tokens will be deleted anyways from the session.
|
|
442
454
|
}
|
|
443
455
|
// Delete the tokens from the session.
|
|
444
456
|
return this.session.clear();
|
|
445
457
|
}
|
|
446
458
|
refresh() {
|
|
447
|
-
var _a, _b;
|
|
459
|
+
var _a, _b, _c, _d, _e, _f;
|
|
448
460
|
// If the refresh token does
|
|
449
461
|
// not exist just return an observable of null.
|
|
450
462
|
const refreshToken = this.session.refreshToken;
|
|
@@ -452,14 +464,14 @@ class Auth {
|
|
|
452
464
|
return of(null);
|
|
453
465
|
}
|
|
454
466
|
// Perform the refresh call.
|
|
455
|
-
const
|
|
467
|
+
const headerName = (_c = (_b = (_a = this._config) === null || _a === void 0 ? void 0 : _a.http) === null || _b === void 0 ? void 0 : _b.header) !== null && _c !== void 0 ? _c : 'Authorization';
|
|
468
|
+
const scheme = (_f = (_e = (_d = this._config) === null || _d === void 0 ? void 0 : _d.http) === null || _e === void 0 ? void 0 : _e.scheme) !== null && _f !== void 0 ? _f : 'Bearer';
|
|
456
469
|
const url = this.getUrl('auth/refresh');
|
|
457
|
-
const context = new HttpContext()
|
|
458
|
-
.set(USE_AUTHORIZATION, false);
|
|
470
|
+
const context = new HttpContext().set(USE_AUTHORIZATION, false);
|
|
459
471
|
return this._httpClient.get(url, {
|
|
460
|
-
headers: {
|
|
472
|
+
headers: { [headerName]: `${scheme} ${refreshToken}` },
|
|
461
473
|
context: context
|
|
462
|
-
}).pipe(
|
|
474
|
+
}).pipe(tap(({ token, refresh_token }) => this.setTokens(token, refresh_token)), map(({ token }) => token));
|
|
463
475
|
}
|
|
464
476
|
requestPassword(email, extraParams = {}) {
|
|
465
477
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -475,42 +487,16 @@ class Auth {
|
|
|
475
487
|
return firstValueFrom(observable$);
|
|
476
488
|
});
|
|
477
489
|
}
|
|
478
|
-
guard(type, redirectUrl) {
|
|
479
|
-
var _a, _b, _c, _d, _e, _f;
|
|
480
|
-
let newUrl = null;
|
|
481
|
-
// Get the correct new url.
|
|
482
|
-
switch (type) {
|
|
483
|
-
case 'authenticated':
|
|
484
|
-
newUrl = (_b = (_a = this._config) === null || _a === void 0 ? void 0 : _a.loggedInUrl) !== null && _b !== void 0 ? _b : null;
|
|
485
|
-
break;
|
|
486
|
-
case 'unauthenticated':
|
|
487
|
-
newUrl = (_d = (_c = this._config) === null || _c === void 0 ? void 0 : _c.redirectUrl) !== null && _d !== void 0 ? _d : null;
|
|
488
|
-
break;
|
|
489
|
-
}
|
|
490
|
-
// Append a redirect url if the user is deemed
|
|
491
|
-
// unauthenticated.
|
|
492
|
-
if (type === 'unauthenticated') {
|
|
493
|
-
const setRedirectOnFailedAuth = (_f = (_e = this._config) === null || _e === void 0 ? void 0 : _e.setRedirectOnFailedAuth) !== null && _f !== void 0 ? _f : true;
|
|
494
|
-
if (setRedirectOnFailedAuth && redirectUrl && newUrl) {
|
|
495
|
-
newUrl += `?redirectUrl=${redirectUrl}`;
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
// Parse the url if it exists.
|
|
499
|
-
if (this.router && newUrl) {
|
|
500
|
-
return this.router.parseUrl(newUrl);
|
|
501
|
-
}
|
|
502
|
-
// Return false if the user is not allowed.
|
|
503
|
-
return false;
|
|
504
|
-
}
|
|
505
490
|
clearAndRedirect() {
|
|
506
491
|
var _a, _b;
|
|
507
492
|
// 1. Delete the tokens from the session.
|
|
508
493
|
this.session.clear();
|
|
509
494
|
// 2. Compose the route url.
|
|
510
|
-
const redirectUrl = (_b = (_a = this._config) === null || _a === void 0 ? void 0 : _a.
|
|
495
|
+
const redirectUrl = (_b = (_a = this._config) === null || _a === void 0 ? void 0 : _a.redirects.unauthenticated) !== null && _b !== void 0 ? _b : null;
|
|
511
496
|
// 3. Route back if the user provided a redirect url.
|
|
512
497
|
if (this.router && redirectUrl) {
|
|
513
|
-
|
|
498
|
+
const commands = Array.isArray(redirectUrl) ? redirectUrl : [redirectUrl];
|
|
499
|
+
this.router.navigate(commands).then(_ => _);
|
|
514
500
|
}
|
|
515
501
|
}
|
|
516
502
|
setTokens(accessToken, refreshToken) {
|
|
@@ -573,79 +559,54 @@ class Auth {
|
|
|
573
559
|
.join('/');
|
|
574
560
|
}
|
|
575
561
|
}
|
|
576
|
-
Auth.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.
|
|
577
|
-
Auth.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.
|
|
578
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.
|
|
562
|
+
Auth.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.1", 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 }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
563
|
+
Auth.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: Auth });
|
|
564
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: Auth, decorators: [{
|
|
579
565
|
type: Injectable
|
|
580
566
|
}], ctorParameters: function () {
|
|
581
|
-
return [{ type: i1.Storage }, { type:
|
|
567
|
+
return [{ type: i1.Storage }, { type: i0.Injector }, { type: i2.Platform }, { type: i3.HttpClient }, { type: AuthConfig, decorators: [{
|
|
582
568
|
type: Optional
|
|
583
|
-
}] }, { type:
|
|
569
|
+
}] }, { type: i5.TransferState, decorators: [{
|
|
584
570
|
type: Optional
|
|
585
|
-
}] }, { type:
|
|
571
|
+
}] }, { type: i6.HttpConfig, decorators: [{
|
|
586
572
|
type: Optional
|
|
587
573
|
}] }];
|
|
588
574
|
} });
|
|
589
575
|
|
|
590
|
-
class BbAuthenticated {
|
|
591
|
-
constructor(_auth,
|
|
576
|
+
class BbAuthenticated extends AbstractAuthDirective {
|
|
577
|
+
constructor(_auth, _templateRef, _viewContainerRef) {
|
|
578
|
+
super(_templateRef, _viewContainerRef);
|
|
592
579
|
this._auth = _auth;
|
|
593
|
-
this.
|
|
580
|
+
this._templateRef = _templateRef;
|
|
594
581
|
this._viewContainerRef = _viewContainerRef;
|
|
582
|
+
// Subscriptions.
|
|
583
|
+
this._subscription = new Subscription();
|
|
595
584
|
}
|
|
596
|
-
|
|
597
|
-
this.
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
}
|
|
601
|
-
this._viewContainerRef.createEmbeddedView(this._template);
|
|
602
|
-
});
|
|
603
|
-
}
|
|
604
|
-
ngOnDestroy() {
|
|
605
|
-
var _a;
|
|
606
|
-
(_a = this._subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
BbAuthenticated.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.5", ngImport: i0, type: BbAuthenticated, deps: [{ token: Auth }, { token: i0.TemplateRef }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
610
|
-
BbAuthenticated.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.0.5", type: BbAuthenticated, selector: "[bbAuthenticated]", ngImport: i0 });
|
|
611
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.5", ngImport: i0, type: BbAuthenticated, decorators: [{
|
|
612
|
-
type: Directive,
|
|
613
|
-
args: [{
|
|
614
|
-
selector: '[bbAuthenticated]'
|
|
615
|
-
}]
|
|
616
|
-
}], ctorParameters: function () { return [{ type: Auth }, { type: i0.TemplateRef }, { type: i0.ViewContainerRef }]; } });
|
|
617
|
-
|
|
618
|
-
class BbRole {
|
|
619
|
-
constructor(_auth, _template, _viewContainerRef) {
|
|
620
|
-
this._auth = _auth;
|
|
621
|
-
this._template = _template;
|
|
622
|
-
this._viewContainerRef = _viewContainerRef;
|
|
623
|
-
this.getAllowedRoles = (value) => {
|
|
624
|
-
return Array.isArray(value) ? value : [value];
|
|
625
|
-
};
|
|
585
|
+
set bbAuthenticatedElse(templateRef) {
|
|
586
|
+
this.assertTemplate('bbAuthenticatedElse', templateRef);
|
|
587
|
+
this.elseTemplateRef = templateRef;
|
|
588
|
+
this.updateView();
|
|
626
589
|
}
|
|
627
590
|
ngOnInit() {
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
return this._viewContainerRef.clear();
|
|
632
|
-
}
|
|
633
|
-
this._viewContainerRef.createEmbeddedView(this._template);
|
|
591
|
+
const subscription = this._auth.user.pipe(map(user => !!user), distinctUntilChanged()).subscribe(valid => {
|
|
592
|
+
this.valid = valid;
|
|
593
|
+
this.updateView();
|
|
634
594
|
});
|
|
595
|
+
this._subscription.add(subscription);
|
|
635
596
|
}
|
|
636
597
|
ngOnDestroy() {
|
|
637
598
|
var _a;
|
|
638
599
|
(_a = this._subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
639
600
|
}
|
|
640
601
|
}
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.
|
|
602
|
+
BbAuthenticated.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: BbAuthenticated, deps: [{ token: Auth }, { token: i0.TemplateRef }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
603
|
+
BbAuthenticated.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.1.1", type: BbAuthenticated, selector: "[bbAuthenticated]", inputs: { bbAuthenticatedElse: "bbAuthenticatedElse" }, usesInheritance: true, ngImport: i0 });
|
|
604
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: BbAuthenticated, decorators: [{
|
|
644
605
|
type: Directive,
|
|
645
606
|
args: [{
|
|
646
|
-
selector: '[
|
|
607
|
+
selector: '[bbAuthenticated]'
|
|
647
608
|
}]
|
|
648
|
-
}], ctorParameters: function () { return [{ type: Auth }, { type: i0.TemplateRef }, { type: i0.ViewContainerRef }]; }, propDecorators: {
|
|
609
|
+
}], ctorParameters: function () { return [{ type: Auth }, { type: i0.TemplateRef }, { type: i0.ViewContainerRef }]; }, propDecorators: { bbAuthenticatedElse: [{
|
|
649
610
|
type: Input
|
|
650
611
|
}] } });
|
|
651
612
|
|
|
@@ -655,48 +616,55 @@ class Permissions {
|
|
|
655
616
|
this._auth = _auth;
|
|
656
617
|
this._config = _config;
|
|
657
618
|
// Data.
|
|
658
|
-
this.
|
|
659
|
-
this._role$ = this._auth.user.pipe(map(user => { var _a; return (_a = user === null || user === void 0 ? void 0 : user.role) !== null && _a !== void 0 ? _a : null; }), distinctUntilChanged());
|
|
619
|
+
this._permissionHandler = (_b = (_a = this._config) === null || _a === void 0 ? void 0 : _a.permissions) !== null && _b !== void 0 ? _b : null;
|
|
660
620
|
}
|
|
661
|
-
has(value) {
|
|
662
|
-
const requiredPermissions =
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
621
|
+
has(value, options) {
|
|
622
|
+
const requiredPermissions = this.getRequiredPermissions(value);
|
|
623
|
+
if ((requiredPermissions === null || requiredPermissions === void 0 ? void 0 : requiredPermissions.length) <= 0) {
|
|
624
|
+
return of(false);
|
|
625
|
+
}
|
|
626
|
+
return this._auth.user.pipe(map(user => {
|
|
627
|
+
var _a;
|
|
628
|
+
if (user === null || user === undefined || !this._permissionHandler) {
|
|
667
629
|
return false;
|
|
668
630
|
}
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
return
|
|
673
|
-
|
|
631
|
+
const mode = (_a = options === null || options === void 0 ? void 0 : options.mode) !== null && _a !== void 0 ? _a : 'and';
|
|
632
|
+
switch (mode) {
|
|
633
|
+
case 'or':
|
|
634
|
+
return this.verifyModeOr(requiredPermissions, user);
|
|
635
|
+
case 'and':
|
|
636
|
+
default:
|
|
637
|
+
return this.verifyModeAnd(requiredPermissions, user);
|
|
674
638
|
}
|
|
675
|
-
|
|
676
|
-
}));
|
|
639
|
+
}), distinctUntilChanged());
|
|
677
640
|
}
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
}
|
|
685
|
-
if ((permission === null || permission === void 0 ? void 0 : permission.length) <= 0) {
|
|
686
|
-
(_d = console === null || console === void 0 ? void 0 : console.warn) === null || _d === void 0 ? void 0 : _d.call(console, `Permissions: No roles were set, please add some roles to this permission.`);
|
|
687
|
-
return false;
|
|
641
|
+
verifyModeAnd(permissions, user) {
|
|
642
|
+
for (const permission of permissions) {
|
|
643
|
+
const verified = this._permissionHandler.verifyForUser(permission, user);
|
|
644
|
+
if (!verified) {
|
|
645
|
+
return false;
|
|
646
|
+
}
|
|
688
647
|
}
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
648
|
+
return true;
|
|
649
|
+
}
|
|
650
|
+
verifyModeOr(permissions, user) {
|
|
651
|
+
for (const permission of permissions) {
|
|
652
|
+
const verified = this._permissionHandler.verifyForUser(permission, user);
|
|
653
|
+
if (verified) {
|
|
654
|
+
return true;
|
|
655
|
+
}
|
|
692
656
|
}
|
|
693
|
-
|
|
694
|
-
|
|
657
|
+
return false;
|
|
658
|
+
}
|
|
659
|
+
getRequiredPermissions(value) {
|
|
660
|
+
return Array.isArray(value)
|
|
661
|
+
? value
|
|
662
|
+
: [value];
|
|
695
663
|
}
|
|
696
664
|
}
|
|
697
|
-
Permissions.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.
|
|
698
|
-
Permissions.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.
|
|
699
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.
|
|
665
|
+
Permissions.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: Permissions, deps: [{ token: Auth }, { token: AuthConfig, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
666
|
+
Permissions.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: Permissions });
|
|
667
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: Permissions, decorators: [{
|
|
700
668
|
type: Injectable
|
|
701
669
|
}], ctorParameters: function () {
|
|
702
670
|
return [{ type: Auth }, { type: AuthConfig, decorators: [{
|
|
@@ -704,72 +672,47 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.5", ngImpor
|
|
|
704
672
|
}] }];
|
|
705
673
|
} });
|
|
706
674
|
|
|
707
|
-
class BbPermission {
|
|
675
|
+
class BbPermission extends AbstractAuthDirective {
|
|
708
676
|
constructor(_permissions, _templateRef, _viewContainerRef) {
|
|
677
|
+
super(_templateRef, _viewContainerRef);
|
|
709
678
|
this._permissions = _permissions;
|
|
710
679
|
this._templateRef = _templateRef;
|
|
711
680
|
this._viewContainerRef = _viewContainerRef;
|
|
712
681
|
// Data.
|
|
713
682
|
this._permission$ = new BehaviorSubject([]);
|
|
714
|
-
this.
|
|
715
|
-
|
|
716
|
-
this.
|
|
717
|
-
this._elseViewRef = null;
|
|
718
|
-
this.getAllowedPermissions = (value) => {
|
|
719
|
-
return Array.isArray(value) ? value : [value];
|
|
720
|
-
};
|
|
721
|
-
this.assertTemplate = (property, templateRef) => {
|
|
722
|
-
const isTemplateRefOrNull = !!(!templateRef || templateRef.createEmbeddedView);
|
|
723
|
-
if (!isTemplateRefOrNull) {
|
|
724
|
-
throw new Error(`${property} must be a TemplateRef.`);
|
|
725
|
-
}
|
|
726
|
-
};
|
|
683
|
+
this._mode$ = new BehaviorSubject('and');
|
|
684
|
+
// Subscriptions.
|
|
685
|
+
this._subscription = new Subscription();
|
|
727
686
|
}
|
|
728
687
|
set bbPermission(value) {
|
|
729
|
-
const permissions =
|
|
688
|
+
const permissions = Array.isArray(value) ? value : [value];
|
|
730
689
|
this._permission$.next(permissions);
|
|
731
690
|
this.updateView();
|
|
732
691
|
}
|
|
733
692
|
set bbPermissionElse(templateRef) {
|
|
734
693
|
this.assertTemplate('bbPermissionElse', templateRef);
|
|
735
|
-
this.
|
|
694
|
+
this.elseTemplateRef = templateRef;
|
|
736
695
|
this.updateView();
|
|
737
696
|
}
|
|
697
|
+
set bbPermissionMode(mode) {
|
|
698
|
+
this._mode$.next(mode);
|
|
699
|
+
}
|
|
738
700
|
ngOnInit() {
|
|
739
|
-
const check$ = this._permission
|
|
740
|
-
|
|
741
|
-
this.
|
|
701
|
+
const check$ = combineLatest([this._permission$, this._mode$]).pipe(switchMap(([permissions, mode]) => this._permissions.has(permissions, { mode })), distinctUntilChanged());
|
|
702
|
+
const subscription = check$.subscribe(valid => {
|
|
703
|
+
this.valid = valid;
|
|
742
704
|
this.updateView();
|
|
743
705
|
});
|
|
706
|
+
this._subscription.add(subscription);
|
|
744
707
|
}
|
|
745
708
|
ngOnDestroy() {
|
|
746
709
|
var _a;
|
|
747
710
|
(_a = this._subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
748
711
|
}
|
|
749
|
-
updateView() {
|
|
750
|
-
if (this._valid) {
|
|
751
|
-
if (!this._thenViewRef) {
|
|
752
|
-
this._viewContainerRef.clear();
|
|
753
|
-
this._elseViewRef = null;
|
|
754
|
-
if (this._templateRef) {
|
|
755
|
-
this._thenViewRef = this._viewContainerRef.createEmbeddedView(this._templateRef);
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
}
|
|
759
|
-
else {
|
|
760
|
-
if (!this._elseViewRef) {
|
|
761
|
-
this._viewContainerRef.clear();
|
|
762
|
-
this._thenViewRef = null;
|
|
763
|
-
if (this._elseTemplateRef) {
|
|
764
|
-
this._elseViewRef = this._viewContainerRef.createEmbeddedView(this._elseTemplateRef);
|
|
765
|
-
}
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
712
|
}
|
|
770
|
-
BbPermission.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.
|
|
771
|
-
BbPermission.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.
|
|
772
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.
|
|
713
|
+
BbPermission.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: BbPermission, deps: [{ token: Permissions }, { token: i0.TemplateRef }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
714
|
+
BbPermission.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.1.1", type: BbPermission, selector: "[bbPermission]", inputs: { bbPermission: "bbPermission", bbPermissionElse: "bbPermissionElse", bbPermissionMode: "bbPermissionMode" }, usesInheritance: true, ngImport: i0 });
|
|
715
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: BbPermission, decorators: [{
|
|
773
716
|
type: Directive,
|
|
774
717
|
args: [{
|
|
775
718
|
selector: '[bbPermission]'
|
|
@@ -778,84 +721,196 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.5", ngImpor
|
|
|
778
721
|
type: Input
|
|
779
722
|
}], bbPermissionElse: [{
|
|
780
723
|
type: Input
|
|
724
|
+
}], bbPermissionMode: [{
|
|
725
|
+
type: Input
|
|
781
726
|
}] } });
|
|
782
727
|
|
|
728
|
+
class AppPermissions {
|
|
729
|
+
constructor(_data) {
|
|
730
|
+
this._data = _data;
|
|
731
|
+
}
|
|
732
|
+
verify(permission, role) {
|
|
733
|
+
var _a, _b, _c, _d;
|
|
734
|
+
if ((typeof ngDevMode === 'undefined' || ngDevMode) && !((_a = this._data) === null || _a === void 0 ? void 0 : _a[role])) {
|
|
735
|
+
(_b = console === null || console === void 0 ? void 0 : console.warn) === null || _b === void 0 ? void 0 : _b.call(console, `Current permissions do not include role: "${role}".`);
|
|
736
|
+
}
|
|
737
|
+
const availablePermissions = (_d = (_c = this._data) === null || _c === void 0 ? void 0 : _c[role]) !== null && _d !== void 0 ? _d : [];
|
|
738
|
+
return availablePermissions.includes(permission);
|
|
739
|
+
}
|
|
740
|
+
verifyForUser(permission, data) {
|
|
741
|
+
const role = this.getRole(data);
|
|
742
|
+
return this.verify(permission, role);
|
|
743
|
+
}
|
|
744
|
+
getRole(data) {
|
|
745
|
+
var _a;
|
|
746
|
+
return (_a = data === null || data === void 0 ? void 0 : data['role']) !== null && _a !== void 0 ? _a : null;
|
|
747
|
+
}
|
|
748
|
+
static forRoles(data) {
|
|
749
|
+
var _a;
|
|
750
|
+
const permissions = (_a = Object.keys(data)) !== null && _a !== void 0 ? _a : [];
|
|
751
|
+
const roles = permissions.reduce((previous, current) => {
|
|
752
|
+
var _a;
|
|
753
|
+
return ([
|
|
754
|
+
...previous,
|
|
755
|
+
...((_a = data === null || data === void 0 ? void 0 : data[current]) !== null && _a !== void 0 ? _a : [])
|
|
756
|
+
]);
|
|
757
|
+
}, []);
|
|
758
|
+
const uniqueRoles = [...new Set(roles)];
|
|
759
|
+
const formattedData = uniqueRoles.reduce((previous, current) => {
|
|
760
|
+
const rolePermissions = permissions.filter(permission => { var _a; return (_a = data === null || data === void 0 ? void 0 : data[permission]) === null || _a === void 0 ? void 0 : _a.includes(current); });
|
|
761
|
+
return Object.assign(Object.assign({}, previous), { [current]: rolePermissions });
|
|
762
|
+
}, {});
|
|
763
|
+
return new AppPermissions(formattedData);
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
|
|
783
767
|
class BbAnonymousGuard {
|
|
784
|
-
constructor(_auth) {
|
|
768
|
+
constructor(_auth, _router, _config) {
|
|
785
769
|
this._auth = _auth;
|
|
770
|
+
this._router = _router;
|
|
771
|
+
this._config = _config;
|
|
786
772
|
}
|
|
787
|
-
canActivate(_,
|
|
788
|
-
return
|
|
789
|
-
|
|
790
|
-
const isAuthenticated$ = yield this._auth.user.pipe(map(user => !!user));
|
|
791
|
-
// If the user is not authenticated it can
|
|
792
|
-
// access the anonymous page.
|
|
793
|
-
const isAuthenticated = yield firstValueFrom(isAuthenticated$, { defaultValue: null });
|
|
773
|
+
canActivate(_, __) {
|
|
774
|
+
return this._auth.user.pipe(map(user => !!user), map(isAuthenticated => {
|
|
775
|
+
var _a, _b, _c;
|
|
794
776
|
if (!isAuthenticated) {
|
|
795
777
|
return true;
|
|
796
778
|
}
|
|
797
|
-
//
|
|
798
|
-
|
|
799
|
-
|
|
779
|
+
// If we don't have a URL to go to we can just say
|
|
780
|
+
// the user is not allowed in this route by returning false.
|
|
781
|
+
const nextUrl = (_c = (_b = (_a = this._config) === null || _a === void 0 ? void 0 : _a.redirects) === null || _b === void 0 ? void 0 : _b.authenticated) !== null && _c !== void 0 ? _c : null;
|
|
782
|
+
if (!nextUrl) {
|
|
783
|
+
return false;
|
|
784
|
+
}
|
|
785
|
+
const commands = Array.isArray(nextUrl) ? nextUrl : [nextUrl];
|
|
786
|
+
return this._router.createUrlTree(commands);
|
|
787
|
+
}), first());
|
|
800
788
|
}
|
|
801
789
|
canActivateChild(childRoute, state) {
|
|
802
790
|
return this.canActivate(childRoute, state);
|
|
803
791
|
}
|
|
804
792
|
}
|
|
805
|
-
BbAnonymousGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.
|
|
806
|
-
BbAnonymousGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.
|
|
807
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.
|
|
793
|
+
BbAnonymousGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: BbAnonymousGuard, deps: [{ token: Auth }, { token: i2$1.Router }, { token: AuthConfig, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
794
|
+
BbAnonymousGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: BbAnonymousGuard, providedIn: 'root' });
|
|
795
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: BbAnonymousGuard, decorators: [{
|
|
808
796
|
type: Injectable,
|
|
809
797
|
args: [{
|
|
810
798
|
providedIn: 'root'
|
|
811
799
|
}]
|
|
812
|
-
}], ctorParameters: function () {
|
|
800
|
+
}], ctorParameters: function () {
|
|
801
|
+
return [{ type: Auth }, { type: i2$1.Router }, { type: AuthConfig, decorators: [{
|
|
802
|
+
type: Optional
|
|
803
|
+
}] }];
|
|
804
|
+
} });
|
|
813
805
|
|
|
814
806
|
class BbAuthenticatedGuard {
|
|
815
|
-
constructor(_auth) {
|
|
807
|
+
constructor(_auth, _router, _config) {
|
|
816
808
|
this._auth = _auth;
|
|
809
|
+
this._router = _router;
|
|
810
|
+
this._config = _config;
|
|
817
811
|
}
|
|
818
812
|
canActivate(_, state) {
|
|
819
|
-
return
|
|
820
|
-
|
|
821
|
-
const isAuthenticated$ = yield this._auth.user.pipe(map(user => !!user));
|
|
822
|
-
// If the user is authenticated it can
|
|
823
|
-
// access the authenticated page.
|
|
824
|
-
const isAuthenticated = yield firstValueFrom(isAuthenticated$, { defaultValue: null });
|
|
813
|
+
return this._auth.user.pipe(map(user => !!user), map(isAuthenticated => {
|
|
814
|
+
var _a, _b, _c, _d, _e, _f;
|
|
825
815
|
if (isAuthenticated) {
|
|
826
816
|
return true;
|
|
827
817
|
}
|
|
828
|
-
//
|
|
829
|
-
//
|
|
830
|
-
|
|
831
|
-
|
|
818
|
+
// If we don't have a URL to go to we can just say
|
|
819
|
+
// the user is not allowed in this route by returning false.
|
|
820
|
+
const nextUrl = (_c = (_b = (_a = this._config) === null || _a === void 0 ? void 0 : _a.redirects) === null || _b === void 0 ? void 0 : _b.unauthenticated) !== null && _c !== void 0 ? _c : null;
|
|
821
|
+
if (!nextUrl) {
|
|
822
|
+
return false;
|
|
823
|
+
}
|
|
824
|
+
const setRedirectOnFailedAuth = (_e = (_d = this._config) === null || _d === void 0 ? void 0 : _d.setRedirectOnFailedAuth) !== null && _e !== void 0 ? _e : true;
|
|
825
|
+
const redirectUrl = (_f = state === null || state === void 0 ? void 0 : state.url) !== null && _f !== void 0 ? _f : null;
|
|
826
|
+
const queryParams = setRedirectOnFailedAuth && redirectUrl ? { redirectUrl } : {};
|
|
827
|
+
const commands = Array.isArray(nextUrl) ? nextUrl : [nextUrl];
|
|
828
|
+
return this._router.createUrlTree(commands, { queryParams });
|
|
829
|
+
}), first());
|
|
830
|
+
}
|
|
831
|
+
canActivateChild(childRoute, state) {
|
|
832
|
+
return this.canActivate(childRoute, state);
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
BbAuthenticatedGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: BbAuthenticatedGuard, deps: [{ token: Auth }, { token: i2$1.Router }, { token: AuthConfig, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
836
|
+
BbAuthenticatedGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: BbAuthenticatedGuard, providedIn: 'root' });
|
|
837
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: BbAuthenticatedGuard, decorators: [{
|
|
838
|
+
type: Injectable,
|
|
839
|
+
args: [{
|
|
840
|
+
providedIn: 'root'
|
|
841
|
+
}]
|
|
842
|
+
}], ctorParameters: function () {
|
|
843
|
+
return [{ type: Auth }, { type: i2$1.Router }, { type: AuthConfig, decorators: [{
|
|
844
|
+
type: Optional
|
|
845
|
+
}] }];
|
|
846
|
+
} });
|
|
847
|
+
|
|
848
|
+
class BbPermissionGuard {
|
|
849
|
+
constructor(_router, _permissions, _config) {
|
|
850
|
+
this._router = _router;
|
|
851
|
+
this._permissions = _permissions;
|
|
852
|
+
this._config = _config;
|
|
853
|
+
}
|
|
854
|
+
canActivate(snapshot, _) {
|
|
855
|
+
var _a, _b;
|
|
856
|
+
const permission = (_b = (_a = snapshot === null || snapshot === void 0 ? void 0 : snapshot.data) === null || _a === void 0 ? void 0 : _a['permission']) !== null && _b !== void 0 ? _b : null;
|
|
857
|
+
const permission$ = this.parsePermission(permission);
|
|
858
|
+
return permission$.pipe(map(valid => {
|
|
859
|
+
var _a, _b, _c;
|
|
860
|
+
if (valid) {
|
|
861
|
+
return true;
|
|
862
|
+
}
|
|
863
|
+
const nextUrl = (_c = (_b = (_a = this._config) === null || _a === void 0 ? void 0 : _a.redirects) === null || _b === void 0 ? void 0 : _b.permissionDenied) !== null && _c !== void 0 ? _c : null;
|
|
864
|
+
if (!nextUrl) {
|
|
865
|
+
return false;
|
|
866
|
+
}
|
|
867
|
+
const commands = Array.isArray(nextUrl) ? nextUrl : [nextUrl];
|
|
868
|
+
return valid ? true : this._router.createUrlTree(commands);
|
|
869
|
+
}));
|
|
832
870
|
}
|
|
833
871
|
canActivateChild(childRoute, state) {
|
|
834
872
|
return this.canActivate(childRoute, state);
|
|
835
873
|
}
|
|
874
|
+
parsePermission(data) {
|
|
875
|
+
var _a;
|
|
876
|
+
if ((typeof ngDevMode === 'undefined' || ngDevMode) && (data === undefined || data === null)) {
|
|
877
|
+
(_a = console === null || console === void 0 ? void 0 : console.warn) === null || _a === void 0 ? void 0 : _a.call(console, `No "data.permission" property was passed.`);
|
|
878
|
+
return of(false);
|
|
879
|
+
}
|
|
880
|
+
if (Array.isArray(data) || typeof data === 'string') {
|
|
881
|
+
return this._permissions.has(data);
|
|
882
|
+
}
|
|
883
|
+
return this._permissions.has(data === null || data === void 0 ? void 0 : data.value, data === null || data === void 0 ? void 0 : data.options);
|
|
884
|
+
}
|
|
836
885
|
}
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.
|
|
886
|
+
BbPermissionGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: BbPermissionGuard, deps: [{ token: i2$1.Router }, { token: Permissions }, { token: AuthConfig, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
887
|
+
BbPermissionGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: BbPermissionGuard, providedIn: 'root' });
|
|
888
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: BbPermissionGuard, decorators: [{
|
|
840
889
|
type: Injectable,
|
|
841
890
|
args: [{
|
|
842
891
|
providedIn: 'root'
|
|
843
892
|
}]
|
|
844
|
-
}], ctorParameters: function () {
|
|
893
|
+
}], ctorParameters: function () {
|
|
894
|
+
return [{ type: i2$1.Router }, { type: Permissions }, { type: AuthConfig, decorators: [{
|
|
895
|
+
type: Optional
|
|
896
|
+
}] }];
|
|
897
|
+
} });
|
|
845
898
|
|
|
846
899
|
class AuthInterceptor {
|
|
847
900
|
constructor(_auth, _config) {
|
|
901
|
+
var _a, _b, _c, _d, _e, _f;
|
|
848
902
|
this._auth = _auth;
|
|
849
903
|
this._config = _config;
|
|
850
904
|
// Readonly data.
|
|
851
|
-
this._authHeaderString = 'Authorization';
|
|
905
|
+
this._authHeaderString = (_c = (_b = (_a = this._config) === null || _a === void 0 ? void 0 : _a.http) === null || _b === void 0 ? void 0 : _b.header) !== null && _c !== void 0 ? _c : 'Authorization';
|
|
906
|
+
this._authScheme = (_f = (_e = (_d = this._config) === null || _d === void 0 ? void 0 : _d.http) === null || _e === void 0 ? void 0 : _e.scheme) !== null && _f !== void 0 ? _f : 'Bearer';
|
|
852
907
|
// Data.
|
|
853
908
|
this.isRefreshing = false;
|
|
854
909
|
this.refreshingAccessToken$ = new BehaviorSubject(null);
|
|
855
910
|
this.getAccessToken = (request) => {
|
|
856
911
|
// Get the token based on header.
|
|
857
|
-
if (request.headers.has(
|
|
858
|
-
return request.headers.get(
|
|
912
|
+
if (request.headers.has(this._authHeaderString)) {
|
|
913
|
+
return request.headers.get(this._authHeaderString);
|
|
859
914
|
}
|
|
860
915
|
// Return the default access token.
|
|
861
916
|
return this._auth.session.accessToken;
|
|
@@ -870,14 +925,9 @@ class AuthInterceptor {
|
|
|
870
925
|
}
|
|
871
926
|
// Add the auth header to the request.
|
|
872
927
|
return request.clone({
|
|
873
|
-
setHeaders: { [this._authHeaderString]: this.
|
|
928
|
+
setHeaders: { [this._authHeaderString]: `${this._authScheme} ${accessToken}` }
|
|
874
929
|
});
|
|
875
930
|
};
|
|
876
|
-
this.getFullAuthorizationHeader = (token) => {
|
|
877
|
-
var _a, _b;
|
|
878
|
-
const authScheme = (_b = (_a = this._config) === null || _a === void 0 ? void 0 : _a.scheme) !== null && _b !== void 0 ? _b : 'Bearer';
|
|
879
|
-
return [authScheme, token].join(' ');
|
|
880
|
-
};
|
|
881
931
|
}
|
|
882
932
|
intercept(request, next) {
|
|
883
933
|
// 1. Check if the user wants to use the authorization for this request.
|
|
@@ -920,9 +970,9 @@ class AuthInterceptor {
|
|
|
920
970
|
return of(null);
|
|
921
971
|
}
|
|
922
972
|
}
|
|
923
|
-
AuthInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.
|
|
924
|
-
AuthInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.
|
|
925
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.
|
|
973
|
+
AuthInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: AuthInterceptor, deps: [{ token: Auth }, { token: AuthConfig, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
974
|
+
AuthInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: AuthInterceptor });
|
|
975
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: AuthInterceptor, decorators: [{
|
|
926
976
|
type: Injectable
|
|
927
977
|
}], ctorParameters: function () {
|
|
928
978
|
return [{ type: Auth }, { type: AuthConfig, decorators: [{
|
|
@@ -932,7 +982,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.5", ngImpor
|
|
|
932
982
|
|
|
933
983
|
const DECLARATIONS_EXPORTS = [
|
|
934
984
|
BbAuthenticated,
|
|
935
|
-
BbRole,
|
|
936
985
|
BbPermission
|
|
937
986
|
];
|
|
938
987
|
class AuthModule {
|
|
@@ -949,24 +998,17 @@ class AuthModule {
|
|
|
949
998
|
};
|
|
950
999
|
}
|
|
951
1000
|
}
|
|
952
|
-
AuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.
|
|
953
|
-
AuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.
|
|
954
|
-
BbRole,
|
|
1001
|
+
AuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: AuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1002
|
+
AuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.1.1", ngImport: i0, type: AuthModule, declarations: [BbAuthenticated,
|
|
955
1003
|
BbPermission], imports: [HttpClientModule], exports: [BbAuthenticated,
|
|
956
|
-
BbRole,
|
|
957
1004
|
BbPermission] });
|
|
958
|
-
AuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.
|
|
959
|
-
|
|
960
|
-
], imports: [HttpClientModule] });
|
|
961
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.5", ngImport: i0, type: AuthModule, decorators: [{
|
|
1005
|
+
AuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: AuthModule, imports: [HttpClientModule] });
|
|
1006
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: AuthModule, decorators: [{
|
|
962
1007
|
type: NgModule,
|
|
963
1008
|
args: [{
|
|
964
1009
|
imports: [HttpClientModule],
|
|
965
1010
|
declarations: [...DECLARATIONS_EXPORTS],
|
|
966
|
-
exports: [...DECLARATIONS_EXPORTS]
|
|
967
|
-
providers: [
|
|
968
|
-
{ provide: AuthMapper, useClass: AuthMapper }
|
|
969
|
-
]
|
|
1011
|
+
exports: [...DECLARATIONS_EXPORTS]
|
|
970
1012
|
}]
|
|
971
1013
|
}] });
|
|
972
1014
|
function initializeAuth(auth) {
|
|
@@ -977,5 +1019,5 @@ function initializeAuth(auth) {
|
|
|
977
1019
|
* Generated bundle index. Do not edit.
|
|
978
1020
|
*/
|
|
979
1021
|
|
|
980
|
-
export { Auth, AuthConfig, AuthEmailProvider,
|
|
1022
|
+
export { AppPermissions, Auth, AuthConfig, AuthEmailProvider, AuthModule, AuthSession, AuthVerifyProvider, BbAnonymousGuard, BbAuthenticated, BbAuthenticatedGuard, BbPermission, BbPermissionGuard, JwtHelper, Permissions, USE_AUTHORIZATION, initializeAuth };
|
|
981
1023
|
//# sourceMappingURL=bravobit-bb-foundation-auth.mjs.map
|