@bravobit/bb-foundation 0.42.0 → 0.42.2
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 +3 -6
- package/auth/lib/auth.service.d.ts +11 -16
- package/dialog/lib/dialog-confirm/dialog-confirm.component.d.ts +2 -5
- package/dialog/lib/dialog-container/dialog-container.component.d.ts +4 -6
- package/dialog/lib/dialog-overlay/dialog-overlay.component.d.ts +5 -7
- package/esm2022/auth/lib/auth.interceptor.mjs +36 -42
- package/esm2022/auth/lib/auth.module.mjs +4 -4
- package/esm2022/auth/lib/auth.service.mjs +25 -41
- package/esm2022/auth/lib/auth.session.mjs +26 -22
- package/esm2022/auth/lib/directives/authenticated.directive.mjs +16 -12
- package/esm2022/auth/lib/helpers/jwt.helper.mjs +29 -31
- package/esm2022/auth/lib/providers/email.provider.mjs +4 -1
- package/esm2022/auth/lib/providers/verify.provider.mjs +4 -1
- package/esm2022/collections/lib/collection.mjs +17 -7
- package/esm2022/collections/lib/collections.module.mjs +6 -6
- package/esm2022/collections/lib/components/collections-actions/collections-actions.component.mjs +7 -9
- package/esm2022/collections/lib/components/collections-grid/collections-grid.component.mjs +11 -11
- package/esm2022/collections/lib/components/collections-pager/collections-pager.component.mjs +10 -10
- package/esm2022/collections/lib/components/collections-table/collections-table.component.mjs +16 -16
- package/esm2022/collections/lib/components/collections-table-label/collections-table-label.component.mjs +9 -11
- package/esm2022/collections/lib/components/collections-table-sorting/collections-table-sorting.component.mjs +12 -9
- package/esm2022/collections/lib/components/collections-viewer/collections-viewer.component.mjs +10 -7
- package/esm2022/collections/lib/directives/collections-data-row.directive.mjs +6 -3
- package/esm2022/collections/lib/directives/collections-data.directive.mjs +6 -3
- package/esm2022/collections/lib/directives/collections-empty.directive.mjs +6 -3
- package/esm2022/collections/lib/directives/collections-error.directive.mjs +6 -3
- package/esm2022/collections/lib/directives/collections-initial.directive.mjs +4 -3
- package/esm2022/collections/lib/directives/collections-item.directive.mjs +6 -3
- package/esm2022/collections/lib/providers/api-collection.provider.mjs +6 -4
- package/esm2022/collections/lib/providers/local-collection.provider.mjs +2 -2
- package/esm2022/combobox/combobox/combobox-container.directive.mjs +12 -7
- package/esm2022/combobox/combobox/combobox.component.mjs +23 -20
- package/esm2022/combobox/combobox-label.directive.mjs +3 -3
- package/esm2022/combobox/combobox-option.directive.mjs +3 -3
- package/esm2022/combobox/combobox-panel/combobox-panel.component.mjs +10 -6
- package/esm2022/dashboard/lib/dashboard/dashboard.component.mjs +13 -13
- package/esm2022/dashboard/lib/dashboard-header/dashboard-header.component.mjs +5 -7
- package/esm2022/dashboard/lib/dashboard-menu/dashboard-menu.component.mjs +8 -10
- package/esm2022/dashboard/lib/dashboard-menu-item/dashboard-menu-item.component.mjs +5 -7
- package/esm2022/dashboard/lib/dashboard-sidebar/dashboard-sidebar.component.mjs +12 -13
- package/esm2022/dashboard/lib/dashboard-sidebar-group/dashboard-sidebar-group.component.mjs +13 -12
- package/esm2022/dashboard/lib/dashboard-sidebar-item/dashboard-sidebar-item.component.mjs +7 -5
- package/esm2022/dashboard/lib/dashboard.module.mjs +5 -5
- package/esm2022/dialog/lib/dialog-actions/dialog-actions.component.mjs +3 -3
- package/esm2022/dialog/lib/dialog-confirm/dialog-confirm.component.mjs +21 -20
- package/esm2022/dialog/lib/dialog-container/dialog-container.component.mjs +19 -24
- package/esm2022/dialog/lib/dialog-header/dialog-header.component.mjs +5 -7
- package/esm2022/dialog/lib/dialog-link/dialog-link.component.mjs +3 -3
- package/esm2022/dialog/lib/dialog-modal/dialog-modal.component.mjs +9 -6
- package/esm2022/dialog/lib/dialog-overlay/dialog-overlay.component.mjs +19 -26
- package/esm2022/dialog/lib/dialog.insertion.mjs +4 -3
- package/esm2022/dialog/lib/dialog.interfaces.mjs +4 -1
- package/esm2022/dialog/lib/dialog.module.mjs +6 -6
- package/esm2022/dialog/lib/dialog.ref.mjs +4 -6
- package/esm2022/dialog/lib/dialog.service.mjs +5 -3
- package/esm2022/dialog/lib/directives/confirm.directive.mjs +12 -14
- package/esm2022/elements/lib/avatar/avatar.component.mjs +75 -77
- package/esm2022/elements/lib/button/button.component.mjs +12 -10
- package/esm2022/elements/lib/checkbox/checkbox.component.mjs +21 -17
- package/esm2022/elements/lib/checkbox-group/checkbox-group.component.mjs +8 -10
- package/esm2022/elements/lib/date-picker/date-picker.component.mjs +82 -76
- package/esm2022/elements/lib/directives/addon.directive.mjs +5 -5
- package/esm2022/elements/lib/directives/extra-error-controls.directive.mjs +7 -9
- package/esm2022/elements/lib/directives/form-submit.directive.mjs +6 -3
- package/esm2022/elements/lib/directives/form-submitter.directive.mjs +5 -7
- package/esm2022/elements/lib/directives/image-upload.directive.mjs +14 -11
- package/esm2022/elements/lib/directives/input.directive.mjs +6 -4
- package/esm2022/elements/lib/elements.module.mjs +6 -6
- package/esm2022/elements/lib/file-picker/file-picker.component.mjs +52 -51
- package/esm2022/elements/lib/form-control/form-control.component.mjs +14 -14
- package/esm2022/elements/lib/form-error/form-error.component.mjs +16 -8
- package/esm2022/elements/lib/form-group/form-group.component.mjs +5 -7
- package/esm2022/elements/lib/icon/icon.component.mjs +14 -13
- package/esm2022/elements/lib/image-picker/image-picker.component.mjs +20 -17
- package/esm2022/elements/lib/multi-file-control/multi-file-control.component.mjs +28 -24
- package/esm2022/elements/lib/pipes/date.pipe.mjs +6 -8
- package/esm2022/elements/lib/pipes/file-image.pipe.mjs +6 -3
- package/esm2022/elements/lib/pipes/file-size.pipe.mjs +13 -15
- package/esm2022/elements/lib/pipes/relative-time.pipe.mjs +37 -35
- package/esm2022/elements/lib/radio-button/radio-button.component.mjs +8 -7
- package/esm2022/elements/lib/radio-group/radio-group.component.mjs +21 -20
- package/esm2022/elements/lib/spinner/spinner.component.mjs +7 -9
- package/esm2022/http/lib/classes/http.config.mjs +19 -15
- package/esm2022/http/lib/http.interfaces.mjs +1 -1
- package/esm2022/http/lib/http.module.mjs +5 -4
- package/esm2022/http/lib/interceptors/base-url.interceptor.mjs +12 -20
- package/esm2022/http/lib/interceptors/error.interceptor.mjs +9 -14
- package/esm2022/lib/core/services/exif.service.mjs +102 -100
- package/esm2022/lib/core/services/file-loader.service.mjs +15 -17
- package/esm2022/lib/core/services/files.service.mjs +9 -17
- package/esm2022/lib/core/services/image-converter.service.mjs +33 -30
- package/esm2022/lib/core/services/languages.service.mjs +25 -24
- package/esm2022/lib/core/services/network.service.mjs +8 -5
- package/esm2022/lib/core/services/patch.service.mjs +9 -6
- package/esm2022/localize/lib/dictionary/dictionary.class.mjs +7 -1
- package/esm2022/localize/lib/dictionary/dictionary.context.mjs +2 -4
- package/esm2022/localize/lib/dictionary/dictionary.data.mjs +2 -1
- package/esm2022/localize/lib/handlers/missing.handler.mjs +2 -4
- package/esm2022/localize/lib/localize.module.mjs +5 -5
- package/esm2022/localize/lib/localize.pipe.mjs +4 -3
- package/esm2022/localize/lib/localize.service.mjs +36 -62
- package/esm2022/localize/lib/transforms/interpolate.transform.mjs +12 -22
- package/esm2022/localize/lib/transforms/plural.transform.mjs +9 -18
- package/esm2022/localize/lib/transforms/reference.transform.mjs +7 -15
- package/esm2022/localize/lib/views/localize-string/localize-string.component.mjs +14 -11
- package/esm2022/localize/lib/views/localize-template.directive.mjs +6 -5
- package/esm2022/masking/lib/directives/currency-mask.directive.mjs +11 -6
- package/esm2022/masking/lib/directives/date-mask.directive.mjs +11 -6
- package/esm2022/masking/lib/directives/input-mask.directive.mjs +21 -14
- package/esm2022/masking/lib/masking.module.mjs +5 -5
- package/esm2022/masking/lib/masking.service.mjs +4 -3
- package/esm2022/notifications/lib/notifications-item/notifications-item.component.mjs +50 -36
- package/esm2022/notifications/lib/notifications-list/notifications-list.component.mjs +8 -7
- package/esm2022/notifications/lib/notifications.interfaces.mjs +10 -1
- package/esm2022/notifications/lib/notifications.module.mjs +4 -4
- package/esm2022/notifications/lib/notifications.service.mjs +24 -10
- package/esm2022/permissions/lib/directives/permission.directive.mjs +20 -14
- package/esm2022/permissions/lib/handlers/local.handler.mjs +3 -1
- package/esm2022/permissions/lib/permissions.interface.mjs +4 -1
- package/esm2022/permissions/lib/permissions.module.mjs +4 -4
- package/esm2022/permissions/lib/permissions.service.mjs +8 -7
- package/esm2022/recaptcha/lib/recaptcha/recaptcha.component.mjs +35 -28
- package/esm2022/recaptcha/lib/recaptcha-loader.service.mjs +15 -15
- package/esm2022/recaptcha/lib/recaptcha.module.mjs +4 -4
- package/esm2022/select/lib/select/select.component.mjs +52 -47
- package/esm2022/select/lib/select-label.directive.mjs +4 -3
- package/esm2022/select/lib/select-multi-label.directive.mjs +4 -3
- package/esm2022/select/lib/select-option-group.directive.mjs +4 -3
- package/esm2022/select/lib/select-option.directive.mjs +4 -3
- package/esm2022/select/lib/select.module.mjs +5 -5
- package/esm2022/storage/lib/storage.service.mjs +25 -21
- package/esm2022/storage/lib/strategies/cookie-storage.strategy.mjs +66 -64
- package/esm2022/storage/lib/strategies/memory-storage.strategy.mjs +16 -18
- package/esm2022/storage/lib/strategies/polyfill-storage.strategy.mjs +31 -30
- package/esm2022/table/lib/components/table/table.component.mjs +30 -20
- package/esm2022/table/lib/components/table-cell/table-cell.component.mjs +3 -3
- package/esm2022/table/lib/components/table-header-cell/table-header-cell.component.mjs +15 -11
- package/esm2022/table/lib/components/table-pager/table-pager.component.mjs +18 -16
- package/esm2022/table/lib/data/datasource.data.mjs +4 -6
- package/esm2022/table/lib/data/generic.data.mjs +38 -36
- package/esm2022/table/lib/table.module.mjs +6 -6
- package/esm2022/tooltip/lib/tooltip-container/tooltip-container.component.mjs +5 -7
- package/esm2022/tooltip/lib/tooltip.directive.mjs +15 -15
- package/esm2022/tooltip/lib/tooltip.module.mjs +4 -4
- package/esm2022/utils/lib/directives/autosize.directive.mjs +9 -7
- package/esm2022/utils/lib/directives/focus-trap.directive.mjs +24 -22
- package/esm2022/utils/lib/directives/focus.directive.mjs +8 -5
- package/esm2022/utils/lib/directives/template.directive.mjs +7 -3
- package/esm2022/utils/lib/utils.module.mjs +5 -5
- package/fesm2022/bravobit-bb-foundation-auth.mjs +134 -144
- package/fesm2022/bravobit-bb-foundation-auth.mjs.map +1 -1
- package/fesm2022/bravobit-bb-foundation-collections.mjs +123 -93
- package/fesm2022/bravobit-bb-foundation-collections.mjs.map +1 -1
- package/fesm2022/bravobit-bb-foundation-combobox.mjs +46 -34
- package/fesm2022/bravobit-bb-foundation-combobox.mjs.map +1 -1
- package/fesm2022/bravobit-bb-foundation-dashboard.mjs +60 -64
- package/fesm2022/bravobit-bb-foundation-dashboard.mjs.map +1 -1
- package/fesm2022/bravobit-bb-foundation-dialog.mjs +97 -103
- package/fesm2022/bravobit-bb-foundation-dialog.mjs.map +1 -1
- package/fesm2022/bravobit-bb-foundation-elements.mjs +468 -440
- package/fesm2022/bravobit-bb-foundation-elements.mjs.map +1 -1
- package/fesm2022/bravobit-bb-foundation-http.mjs +40 -46
- package/fesm2022/bravobit-bb-foundation-http.mjs.map +1 -1
- package/fesm2022/bravobit-bb-foundation-localize.mjs +91 -130
- package/fesm2022/bravobit-bb-foundation-localize.mjs.map +1 -1
- package/fesm2022/bravobit-bb-foundation-masking.mjs +47 -29
- package/fesm2022/bravobit-bb-foundation-masking.mjs.map +1 -1
- package/fesm2022/bravobit-bb-foundation-notifications.mjs +91 -53
- package/fesm2022/bravobit-bb-foundation-notifications.mjs.map +1 -1
- package/fesm2022/bravobit-bb-foundation-permissions.mjs +34 -22
- package/fesm2022/bravobit-bb-foundation-permissions.mjs.map +1 -1
- package/fesm2022/bravobit-bb-foundation-recaptcha.mjs +51 -44
- package/fesm2022/bravobit-bb-foundation-recaptcha.mjs.map +1 -1
- package/fesm2022/bravobit-bb-foundation-select.mjs +67 -58
- package/fesm2022/bravobit-bb-foundation-select.mjs.map +1 -1
- package/fesm2022/bravobit-bb-foundation-storage.mjs +134 -129
- package/fesm2022/bravobit-bb-foundation-storage.mjs.map +1 -1
- package/fesm2022/bravobit-bb-foundation-table.mjs +107 -91
- package/fesm2022/bravobit-bb-foundation-table.mjs.map +1 -1
- package/fesm2022/bravobit-bb-foundation-tooltip.mjs +21 -23
- package/fesm2022/bravobit-bb-foundation-tooltip.mjs.map +1 -1
- package/fesm2022/bravobit-bb-foundation-utils.mjs +48 -37
- package/fesm2022/bravobit-bb-foundation-utils.mjs.map +1 -1
- package/fesm2022/bravobit-bb-foundation.mjs +194 -191
- package/fesm2022/bravobit-bb-foundation.mjs.map +1 -1
- package/http/lib/http.interfaces.d.ts +2 -1
- package/http/lib/interceptors/base-url.interceptor.d.ts +2 -4
- package/http/lib/interceptors/error.interceptor.d.ts +1 -3
- package/lib/core/services/files.service.d.ts +3 -7
- package/localize/lib/localize.service.d.ts +10 -14
- package/localize/lib/transforms/interpolate.transform.d.ts +4 -5
- package/localize/lib/transforms/plural.transform.d.ts +5 -6
- package/localize/lib/transforms/reference.transform.d.ts +2 -3
- package/package.json +39 -39
|
@@ -5,15 +5,15 @@ import { BbFocus } from './directives/focus.directive';
|
|
|
5
5
|
import { NgModule } from '@angular/core';
|
|
6
6
|
import * as i0 from "@angular/core";
|
|
7
7
|
export class UtilsModule {
|
|
8
|
-
static
|
|
9
|
-
static
|
|
8
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: UtilsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
9
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.1.0", ngImport: i0, type: UtilsModule, imports: [BbTemplate,
|
|
10
10
|
BbAutosize,
|
|
11
11
|
BbFocus,
|
|
12
12
|
BbFocusTrap], exports: [BbTemplate,
|
|
13
13
|
BbAutosize,
|
|
14
14
|
BbFocus,
|
|
15
|
-
BbFocusTrap] });
|
|
16
|
-
static
|
|
15
|
+
BbFocusTrap] });
|
|
16
|
+
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: UtilsModule });
|
|
17
17
|
}
|
|
18
18
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: UtilsModule, decorators: [{
|
|
19
19
|
type: NgModule,
|
|
@@ -32,4 +32,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.0", ngImpor
|
|
|
32
32
|
]
|
|
33
33
|
}]
|
|
34
34
|
}] });
|
|
35
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
35
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMubW9kdWxlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vcHJvamVjdHMvYmItZm91bmRhdGlvbi91dGlscy9zcmMvbGliL3V0aWxzLm1vZHVsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUMsV0FBVyxFQUFDLE1BQU0sbUNBQW1DLENBQUM7QUFDOUQsT0FBTyxFQUFDLFVBQVUsRUFBQyxNQUFNLGlDQUFpQyxDQUFDO0FBQzNELE9BQU8sRUFBQyxVQUFVLEVBQUMsTUFBTSxpQ0FBaUMsQ0FBQztBQUMzRCxPQUFPLEVBQUMsT0FBTyxFQUFDLE1BQU0sOEJBQThCLENBQUM7QUFDckQsT0FBTyxFQUFDLFFBQVEsRUFBQyxNQUFNLGVBQWUsQ0FBQzs7QUFnQnZDLE1BQU0sT0FBTyxXQUFXO3VHQUFYLFdBQVc7d0dBQVgsV0FBVyxZQVpoQixVQUFVO1lBQ1YsVUFBVTtZQUNWLE9BQU87WUFDUCxXQUFXLGFBR1gsVUFBVTtZQUNWLFVBQVU7WUFDVixPQUFPO1lBQ1AsV0FBVzt3R0FHTixXQUFXOzsyRkFBWCxXQUFXO2tCQWR2QixRQUFRO21CQUFDO29CQUNOLE9BQU8sRUFBRTt3QkFDTCxVQUFVO3dCQUNWLFVBQVU7d0JBQ1YsT0FBTzt3QkFDUCxXQUFXO3FCQUNkO29CQUNELE9BQU8sRUFBRTt3QkFDTCxVQUFVO3dCQUNWLFVBQVU7d0JBQ1YsT0FBTzt3QkFDUCxXQUFXO3FCQUNkO2lCQUNKIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHtCYkZvY3VzVHJhcH0gZnJvbSAnLi9kaXJlY3RpdmVzL2ZvY3VzLXRyYXAuZGlyZWN0aXZlJztcbmltcG9ydCB7QmJUZW1wbGF0ZX0gZnJvbSAnLi9kaXJlY3RpdmVzL3RlbXBsYXRlLmRpcmVjdGl2ZSc7XG5pbXBvcnQge0JiQXV0b3NpemV9IGZyb20gJy4vZGlyZWN0aXZlcy9hdXRvc2l6ZS5kaXJlY3RpdmUnO1xuaW1wb3J0IHtCYkZvY3VzfSBmcm9tICcuL2RpcmVjdGl2ZXMvZm9jdXMuZGlyZWN0aXZlJztcbmltcG9ydCB7TmdNb2R1bGV9IGZyb20gJ0Bhbmd1bGFyL2NvcmUnO1xuXG5ATmdNb2R1bGUoe1xuICAgIGltcG9ydHM6IFtcbiAgICAgICAgQmJUZW1wbGF0ZSxcbiAgICAgICAgQmJBdXRvc2l6ZSxcbiAgICAgICAgQmJGb2N1cyxcbiAgICAgICAgQmJGb2N1c1RyYXBcbiAgICBdLFxuICAgIGV4cG9ydHM6IFtcbiAgICAgICAgQmJUZW1wbGF0ZSxcbiAgICAgICAgQmJBdXRvc2l6ZSxcbiAgICAgICAgQmJGb2N1cyxcbiAgICAgICAgQmJGb2N1c1RyYXBcbiAgICBdXG59KVxuZXhwb3J0IGNsYXNzIFV0aWxzTW9kdWxlIHtcbn1cbiJdfQ==
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken,
|
|
3
|
-
import
|
|
4
|
-
import { HttpContextToken, HttpContext, HttpErrorResponse, HTTP_INTERCEPTORS } from '@angular/common/http';
|
|
2
|
+
import { InjectionToken, inject, Injector, TransferState, makeStateKey, Injectable, Directive, Input, makeEnvironmentProviders, APP_INITIALIZER, NgModule } from '@angular/core';
|
|
3
|
+
import { HttpContextToken, HttpClient, HttpContext, HttpErrorResponse, HTTP_INTERCEPTORS } from '@angular/common/http';
|
|
5
4
|
import { shareReplay, tap, map, distinctUntilChanged, catchError, filter, take, switchMap, finalize } from 'rxjs/operators';
|
|
6
5
|
import { firstValueFrom, BehaviorSubject, of, Subscription, first, throwError } from 'rxjs';
|
|
7
|
-
import
|
|
6
|
+
import { Storage } from '@bravobit/bb-foundation/storage';
|
|
8
7
|
import { HTTP_CONFIG, HttpError } from '@bravobit/bb-foundation/http';
|
|
8
|
+
import { Platform } from '@angular/cdk/platform';
|
|
9
9
|
import { Router } from '@angular/router';
|
|
10
|
-
import * as i1 from '@bravobit/bb-foundation/storage';
|
|
11
|
-
import * as i2 from '@angular/cdk/platform';
|
|
12
10
|
|
|
13
11
|
const AUTH_CONFIG = new InjectionToken('auth config');
|
|
14
12
|
const AUTH_REDIRECT_HANDLER = new InjectionToken('auth redirect handler');
|
|
@@ -16,36 +14,6 @@ const AUTH_REDIRECT_HANDLER = new InjectionToken('auth redirect handler');
|
|
|
16
14
|
const USE_AUTHORIZATION = new HttpContextToken(() => true);
|
|
17
15
|
|
|
18
16
|
class JwtHelper {
|
|
19
|
-
constructor() {
|
|
20
|
-
this.baseDecodeUnicode = (value) => {
|
|
21
|
-
return decodeURIComponent(atob(value).replace(/(.)/g, (_, p) => {
|
|
22
|
-
let code = p.charCodeAt(0).toString(16).toUpperCase();
|
|
23
|
-
if (code.length < 2) {
|
|
24
|
-
code = '0' + code;
|
|
25
|
-
}
|
|
26
|
-
return '%' + code;
|
|
27
|
-
}));
|
|
28
|
-
};
|
|
29
|
-
this.parse = (data) => {
|
|
30
|
-
return {
|
|
31
|
-
id: data['jti'] ?? null,
|
|
32
|
-
type: data['typ'] ?? null,
|
|
33
|
-
audience: data['aud'] ?? null,
|
|
34
|
-
issuer: data['iss'] ?? null,
|
|
35
|
-
subject: data['sub'] ?? null,
|
|
36
|
-
role: data['role'] ?? null,
|
|
37
|
-
notValidBefore: this.parseDate(data['nbf']),
|
|
38
|
-
expiresAt: this.parseDate(data['exp']),
|
|
39
|
-
issuedAt: this.parseDate(data['iat'])
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
this.parseDate = (epochInSeconds) => {
|
|
43
|
-
if (!epochInSeconds || epochInSeconds <= 0) {
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
return new Date(epochInSeconds * 1000);
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
17
|
decode(token) {
|
|
50
18
|
try {
|
|
51
19
|
if (token === null || token === undefined) {
|
|
@@ -82,9 +50,40 @@ class JwtHelper {
|
|
|
82
50
|
return atob(output);
|
|
83
51
|
}
|
|
84
52
|
}
|
|
53
|
+
baseDecodeUnicode = (value) => {
|
|
54
|
+
return decodeURIComponent(atob(value).replace(/(.)/g, (_, p) => {
|
|
55
|
+
let code = p.charCodeAt(0).toString(16).toUpperCase();
|
|
56
|
+
if (code.length < 2) {
|
|
57
|
+
code = '0' + code;
|
|
58
|
+
}
|
|
59
|
+
return '%' + code;
|
|
60
|
+
}));
|
|
61
|
+
};
|
|
62
|
+
parse = (data) => {
|
|
63
|
+
return {
|
|
64
|
+
id: data['jti'] ?? null,
|
|
65
|
+
type: data['typ'] ?? null,
|
|
66
|
+
audience: data['aud'] ?? null,
|
|
67
|
+
issuer: data['iss'] ?? null,
|
|
68
|
+
subject: data['sub'] ?? null,
|
|
69
|
+
role: data['role'] ?? null,
|
|
70
|
+
notValidBefore: this.parseDate(data['nbf']),
|
|
71
|
+
expiresAt: this.parseDate(data['exp']),
|
|
72
|
+
issuedAt: this.parseDate(data['iat'])
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
parseDate = (epochInSeconds) => {
|
|
76
|
+
if (!epochInSeconds || epochInSeconds <= 0) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
return new Date(epochInSeconds * 1000);
|
|
80
|
+
};
|
|
85
81
|
}
|
|
86
82
|
|
|
87
83
|
class AuthVerifyProvider {
|
|
84
|
+
_code;
|
|
85
|
+
_verifyToken;
|
|
86
|
+
_endpoint;
|
|
88
87
|
constructor(_code, _verifyToken, _endpoint) {
|
|
89
88
|
this._code = _code;
|
|
90
89
|
this._verifyToken = _verifyToken;
|
|
@@ -106,6 +105,9 @@ class AuthVerifyProvider {
|
|
|
106
105
|
}
|
|
107
106
|
|
|
108
107
|
class AuthEmailProvider {
|
|
108
|
+
_email;
|
|
109
|
+
_password;
|
|
110
|
+
_endpoint;
|
|
109
111
|
constructor(_email, _password, _endpoint) {
|
|
110
112
|
this._email = _email;
|
|
111
113
|
this._password = _password;
|
|
@@ -129,28 +131,23 @@ class AuthEmailProvider {
|
|
|
129
131
|
}
|
|
130
132
|
|
|
131
133
|
class AuthSession {
|
|
134
|
+
// Readonly data.
|
|
135
|
+
_jwt = new JwtHelper();
|
|
136
|
+
_storage;
|
|
137
|
+
_accessTokenStorageKey;
|
|
138
|
+
_refreshTokenStorageKey;
|
|
139
|
+
_userStorageKey;
|
|
140
|
+
// Token strings.
|
|
141
|
+
_accessTokenString = null;
|
|
142
|
+
_refreshTokenString = null;
|
|
143
|
+
// Token payloads.
|
|
144
|
+
_accessTokenPayload = null;
|
|
145
|
+
_refreshTokenPayload = null;
|
|
146
|
+
// Private user data.
|
|
147
|
+
_user$ = new BehaviorSubject(null);
|
|
148
|
+
// Public user data.
|
|
149
|
+
user = this._user$.pipe(shareReplay({ refCount: true, bufferSize: 1 }));
|
|
132
150
|
constructor(options) {
|
|
133
|
-
// Readonly data.
|
|
134
|
-
this._jwt = new JwtHelper();
|
|
135
|
-
// Token strings.
|
|
136
|
-
this._accessTokenString = null;
|
|
137
|
-
this._refreshTokenString = null;
|
|
138
|
-
// Token payloads.
|
|
139
|
-
this._accessTokenPayload = null;
|
|
140
|
-
this._refreshTokenPayload = null;
|
|
141
|
-
// Private user data.
|
|
142
|
-
this._user$ = new BehaviorSubject(null);
|
|
143
|
-
// Public user data.
|
|
144
|
-
this.user = this._user$.pipe(shareReplay({ refCount: true, bufferSize: 1 }));
|
|
145
|
-
this.generateKey = (applicationId, key) => {
|
|
146
|
-
return [applicationId, key].join('_');
|
|
147
|
-
};
|
|
148
|
-
this.isTokenValid = (token) => {
|
|
149
|
-
if (!token) {
|
|
150
|
-
return false;
|
|
151
|
-
}
|
|
152
|
-
return token?.expiresAt?.getTime() > Date.now();
|
|
153
|
-
};
|
|
154
151
|
const applicationId = options?.id ?? 'ng';
|
|
155
152
|
// Setting up the readonly storage keys.
|
|
156
153
|
this._accessTokenStorageKey = this.generateKey(applicationId, 'au_act');
|
|
@@ -261,22 +258,34 @@ class AuthSession {
|
|
|
261
258
|
this._refreshTokenString = value ?? null;
|
|
262
259
|
this._refreshTokenPayload = this._jwt.decode(this._refreshTokenString);
|
|
263
260
|
}
|
|
261
|
+
generateKey = (applicationId, key) => {
|
|
262
|
+
return [applicationId, key].join('_');
|
|
263
|
+
};
|
|
264
|
+
isTokenValid = (token) => {
|
|
265
|
+
if (!token) {
|
|
266
|
+
return false;
|
|
267
|
+
}
|
|
268
|
+
return token?.expiresAt?.getTime() > Date.now();
|
|
269
|
+
};
|
|
264
270
|
}
|
|
265
271
|
|
|
266
272
|
class Auth {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
273
|
+
// Dependencies.
|
|
274
|
+
_storage = inject(Storage);
|
|
275
|
+
_injector = inject(Injector);
|
|
276
|
+
_platform = inject(Platform);
|
|
277
|
+
_httpClient = inject(HttpClient);
|
|
278
|
+
_state = inject(TransferState, { optional: true });
|
|
279
|
+
_config = inject(AUTH_CONFIG, { optional: true });
|
|
280
|
+
_httpConfig = inject(HTTP_CONFIG, { optional: true });
|
|
281
|
+
_handler = inject(AUTH_REDIRECT_HANDLER, { optional: true });
|
|
282
|
+
// Readonly data.
|
|
283
|
+
_authStateKey = makeStateKey(`bbAuthStateKey`);
|
|
284
|
+
_httpAlias = this._httpConfig?.defaultAlias ?? null;
|
|
285
|
+
session;
|
|
286
|
+
user;
|
|
287
|
+
_refreshHandler = null;
|
|
288
|
+
constructor() {
|
|
280
289
|
// We select a storage strategy based on the server/browser.
|
|
281
290
|
// Only cookies CAN work on the server.
|
|
282
291
|
const storageStrategy = this._platform.isBrowser
|
|
@@ -427,7 +436,7 @@ class Auth {
|
|
|
427
436
|
this.session.clear();
|
|
428
437
|
if (this._handler) {
|
|
429
438
|
const urlTree = this._handler.onFailedAuthenticated();
|
|
430
|
-
if (
|
|
439
|
+
if (typeof urlTree === 'boolean' || urlTree === null || urlTree === undefined) {
|
|
431
440
|
return;
|
|
432
441
|
}
|
|
433
442
|
this.router.navigateByUrl(urlTree).then(_ => _);
|
|
@@ -497,34 +506,29 @@ class Auth {
|
|
|
497
506
|
.filter(item => !!item)
|
|
498
507
|
.join('/');
|
|
499
508
|
}
|
|
500
|
-
static
|
|
501
|
-
static
|
|
509
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: Auth, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
510
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: Auth, providedIn: 'root' });
|
|
502
511
|
}
|
|
503
512
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: Auth, decorators: [{
|
|
504
513
|
type: Injectable,
|
|
505
514
|
args: [{
|
|
506
515
|
providedIn: 'root'
|
|
507
516
|
}]
|
|
508
|
-
}], ctorParameters: () => [
|
|
509
|
-
type: Optional
|
|
510
|
-
}] }, { type: undefined, decorators: [{
|
|
511
|
-
type: Optional
|
|
512
|
-
}, {
|
|
513
|
-
type: Inject,
|
|
514
|
-
args: [AUTH_CONFIG]
|
|
515
|
-
}] }, { type: i4.HttpConfig, decorators: [{
|
|
516
|
-
type: Optional
|
|
517
|
-
}, {
|
|
518
|
-
type: Inject,
|
|
519
|
-
args: [HTTP_CONFIG]
|
|
520
|
-
}] }, { type: undefined, decorators: [{
|
|
521
|
-
type: Optional
|
|
522
|
-
}, {
|
|
523
|
-
type: Inject,
|
|
524
|
-
args: [AUTH_REDIRECT_HANDLER]
|
|
525
|
-
}] }] });
|
|
517
|
+
}], ctorParameters: () => [] });
|
|
526
518
|
|
|
527
519
|
class BbAuthenticated {
|
|
520
|
+
_auth;
|
|
521
|
+
_templateRef;
|
|
522
|
+
_viewContainerRef;
|
|
523
|
+
// Data.
|
|
524
|
+
_valid = false;
|
|
525
|
+
// Templates.
|
|
526
|
+
_elseTemplateRef = null;
|
|
527
|
+
// View refs.
|
|
528
|
+
_thenViewRef = null;
|
|
529
|
+
_elseViewRef = null;
|
|
530
|
+
// Subscriptions.
|
|
531
|
+
_subscription = new Subscription();
|
|
528
532
|
set bbAuthenticatedElse(templateRef) {
|
|
529
533
|
this.assertTemplate('bbAuthenticatedElse', templateRef);
|
|
530
534
|
this._elseTemplateRef = templateRef;
|
|
@@ -534,15 +538,6 @@ class BbAuthenticated {
|
|
|
534
538
|
this._auth = _auth;
|
|
535
539
|
this._templateRef = _templateRef;
|
|
536
540
|
this._viewContainerRef = _viewContainerRef;
|
|
537
|
-
// Data.
|
|
538
|
-
this._valid = false;
|
|
539
|
-
// Templates.
|
|
540
|
-
this._elseTemplateRef = null;
|
|
541
|
-
// View refs.
|
|
542
|
-
this._thenViewRef = null;
|
|
543
|
-
this._elseViewRef = null;
|
|
544
|
-
// Subscriptions.
|
|
545
|
-
this._subscription = new Subscription();
|
|
546
541
|
}
|
|
547
542
|
ngOnInit() {
|
|
548
543
|
const subscription = this._auth.user.pipe(map(user => !!user), distinctUntilChanged()).subscribe(valid => {
|
|
@@ -580,8 +575,9 @@ class BbAuthenticated {
|
|
|
580
575
|
throw new Error(`${property} must be a TemplateRef.`);
|
|
581
576
|
}
|
|
582
577
|
}
|
|
583
|
-
static
|
|
584
|
-
static
|
|
578
|
+
static ngAcceptInputType_bbAuthenticatedElse;
|
|
579
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: BbAuthenticated, deps: [{ token: Auth }, { token: i0.TemplateRef }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
580
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.1.0", type: BbAuthenticated, isStandalone: true, selector: "[bbAuthenticated]", inputs: { bbAuthenticatedElse: "bbAuthenticatedElse" }, ngImport: i0 });
|
|
585
581
|
}
|
|
586
582
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: BbAuthenticated, decorators: [{
|
|
587
583
|
type: Directive,
|
|
@@ -643,37 +639,15 @@ const bbAuthenticatedGuard = (route, state) => {
|
|
|
643
639
|
};
|
|
644
640
|
|
|
645
641
|
class AuthInterceptor {
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
this.getAccessToken = (request) => {
|
|
656
|
-
// Get the token based on header.
|
|
657
|
-
if (request.headers.has(this._authHeaderString)) {
|
|
658
|
-
return request.headers.get(this._authHeaderString);
|
|
659
|
-
}
|
|
660
|
-
// Return the default access token.
|
|
661
|
-
return this._auth.session.accessToken;
|
|
662
|
-
};
|
|
663
|
-
this.addAuthorizationHeader = (request, accessToken = null) => {
|
|
664
|
-
// Remove auth header when we do not have
|
|
665
|
-
// an access token.
|
|
666
|
-
if (!accessToken) {
|
|
667
|
-
return request.clone({
|
|
668
|
-
headers: request.headers.delete(this._authHeaderString)
|
|
669
|
-
});
|
|
670
|
-
}
|
|
671
|
-
// Add the auth header to the request.
|
|
672
|
-
return request.clone({
|
|
673
|
-
setHeaders: { [this._authHeaderString]: `${this._authScheme} ${accessToken}` }
|
|
674
|
-
});
|
|
675
|
-
};
|
|
676
|
-
}
|
|
642
|
+
// Dependencies.
|
|
643
|
+
_auth = inject(Auth);
|
|
644
|
+
_config = inject(AUTH_CONFIG, { optional: true });
|
|
645
|
+
// Readonly data.
|
|
646
|
+
_authHeaderString = this._config?.http?.header ?? 'Authorization';
|
|
647
|
+
_authScheme = this._config?.http?.scheme ?? 'Bearer';
|
|
648
|
+
// Data.
|
|
649
|
+
isRefreshing = false;
|
|
650
|
+
refreshingAccessToken$ = new BehaviorSubject(null);
|
|
677
651
|
intercept(request, next) {
|
|
678
652
|
// 1. Check if the user wants to use the authorization for this request.
|
|
679
653
|
if (!request.context.get(USE_AUTHORIZATION)) {
|
|
@@ -714,17 +688,33 @@ class AuthInterceptor {
|
|
|
714
688
|
// Return null as data.
|
|
715
689
|
return of(null);
|
|
716
690
|
}
|
|
717
|
-
|
|
718
|
-
|
|
691
|
+
getAccessToken = (request) => {
|
|
692
|
+
// Get the token based on header.
|
|
693
|
+
if (request.headers.has(this._authHeaderString)) {
|
|
694
|
+
return request.headers.get(this._authHeaderString);
|
|
695
|
+
}
|
|
696
|
+
// Return the default access token.
|
|
697
|
+
return this._auth.session.accessToken;
|
|
698
|
+
};
|
|
699
|
+
addAuthorizationHeader = (request, accessToken = null) => {
|
|
700
|
+
// Remove auth header when we do not have
|
|
701
|
+
// an access token.
|
|
702
|
+
if (!accessToken) {
|
|
703
|
+
return request.clone({
|
|
704
|
+
headers: request.headers.delete(this._authHeaderString)
|
|
705
|
+
});
|
|
706
|
+
}
|
|
707
|
+
// Add the auth header to the request.
|
|
708
|
+
return request.clone({
|
|
709
|
+
setHeaders: { [this._authHeaderString]: `${this._authScheme} ${accessToken}` }
|
|
710
|
+
});
|
|
711
|
+
};
|
|
712
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: AuthInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
713
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: AuthInterceptor });
|
|
719
714
|
}
|
|
720
715
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: AuthInterceptor, decorators: [{
|
|
721
716
|
type: Injectable
|
|
722
|
-
}]
|
|
723
|
-
type: Optional
|
|
724
|
-
}, {
|
|
725
|
-
type: Inject,
|
|
726
|
-
args: [AUTH_CONFIG]
|
|
727
|
-
}] }] });
|
|
717
|
+
}] });
|
|
728
718
|
|
|
729
719
|
function provideAuthConfig(config) {
|
|
730
720
|
return makeEnvironmentProviders([
|
|
@@ -746,9 +736,9 @@ class AuthModule {
|
|
|
746
736
|
]
|
|
747
737
|
};
|
|
748
738
|
}
|
|
749
|
-
static
|
|
750
|
-
static
|
|
751
|
-
static
|
|
739
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: AuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
740
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.1.0", ngImport: i0, type: AuthModule, imports: [BbAuthenticated], exports: [BbAuthenticated] });
|
|
741
|
+
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: AuthModule });
|
|
752
742
|
}
|
|
753
743
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: AuthModule, decorators: [{
|
|
754
744
|
type: NgModule,
|