@bravobit/bb-foundation 0.16.3 → 0.20.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/README.md +47 -47
- package/auth/bravobit-bb-foundation-auth.d.ts +5 -5
- package/auth/lib/auth.interceptor.d.ts +21 -21
- package/auth/lib/auth.module.d.ts +15 -15
- package/auth/lib/auth.service.d.ts +59 -59
- package/auth/lib/auth.session.d.ts +34 -34
- package/auth/lib/directives/authenticated.directive.d.ts +14 -14
- package/auth/lib/directives/permission.directive.d.ts +24 -24
- package/auth/lib/directives/role.directive.d.ts +16 -16
- package/auth/lib/guards/anonymous.guard.d.ts +11 -11
- package/auth/lib/guards/authenticated.guard.d.ts +11 -11
- package/auth/lib/helpers/jwt.helper.d.ts +8 -8
- package/auth/lib/helpers/mapper.helper.d.ts +23 -23
- package/auth/lib/interfaces/config.interface.d.ts +12 -12
- package/auth/lib/interfaces/mapper.interface.d.ts +19 -19
- package/auth/lib/interfaces/provider.interface.d.ts +16 -16
- package/auth/lib/interfaces/token.interface.d.ts +11 -11
- package/auth/lib/permissions.service.d.ts +14 -14
- package/auth/lib/providers/email.provider.d.ts +15 -15
- package/auth/lib/providers/verify.provider.d.ts +13 -13
- package/auth/lib/tokens/use-authorization.token.d.ts +2 -2
- package/auth/public_api.d.ts +18 -18
- package/bravobit-bb-foundation.d.ts +5 -5
- package/collections/bravobit-bb-foundation-collections.d.ts +5 -5
- package/collections/lib/collection.d.ts +43 -43
- package/collections/lib/collections.module.d.ts +10 -10
- package/collections/lib/components/collections-pager/collections-pager.component.d.ts +34 -34
- package/collections/lib/components/collections-viewer/collections-viewer.component.d.ts +12 -12
- package/collections/lib/components/collections.directive.d.ts +17 -17
- package/collections/lib/interfaces/collection.interface.d.ts +26 -26
- package/collections/lib/providers/api-collection.provider.d.ts +17 -15
- package/collections/lib/providers/collection.provider.d.ts +6 -6
- package/collections/lib/providers/local-collection.provider.d.ts +8 -8
- package/collections/public_api.d.ts +9 -9
- package/controls/bravobit-bb-foundation-controls.d.ts +5 -5
- package/controls/lib/checkbox/checkbox/checkbox.component.d.ts +47 -47
- package/controls/lib/checkbox/checkbox-group/checkbox-group.component.d.ts +18 -18
- package/controls/lib/checkbox/checkbox.module.d.ts +9 -9
- package/controls/lib/controls.module.d.ts +7 -7
- package/controls/public_api.d.ts +4 -4
- package/dashboard/bravobit-bb-foundation-dashboard.d.ts +5 -5
- package/dashboard/lib/dashboard/dashboard.component.d.ts +19 -19
- package/dashboard/lib/dashboard-header/dashboard-header.component.d.ts +11 -11
- package/dashboard/lib/dashboard-menu/dashboard-menu.component.d.ts +9 -9
- package/dashboard/lib/dashboard-menu-item/dashboard-menu-item.component.d.ts +11 -11
- package/dashboard/lib/dashboard-sidebar/dashboard-sidebar.component.d.ts +21 -21
- package/dashboard/lib/dashboard-sidebar-group/dashboard-sidebar-group.component.d.ts +27 -27
- package/dashboard/lib/dashboard-sidebar-item/dashboard-sidebar-item.component.d.ts +16 -16
- package/dashboard/lib/dashboard.module.d.ts +16 -16
- package/dashboard/public_api.d.ts +8 -8
- package/dialog/bravobit-bb-foundation-dialog.d.ts +5 -5
- package/dialog/lib/dialog-actions/dialog-actions.component.d.ts +5 -5
- package/dialog/lib/dialog-confirm/dialog-confirm.component.d.ts +16 -16
- package/dialog/lib/dialog-container/dialog-container.component.d.ts +24 -24
- package/dialog/lib/dialog-header/dialog-header.component.d.ts +9 -9
- package/dialog/lib/dialog-link/dialog-link.component.d.ts +5 -5
- package/dialog/lib/dialog-modal/dialog-modal.component.d.ts +12 -12
- package/dialog/lib/dialog-overlay/dialog-overlay.component.d.ts +22 -22
- package/dialog/lib/dialog.injector.d.ts +8 -8
- package/dialog/lib/dialog.insertion.d.ts +8 -8
- package/dialog/lib/dialog.interfaces.d.ts +3 -3
- package/dialog/lib/dialog.module.d.ts +19 -19
- package/dialog/lib/dialog.ref.d.ts +8 -8
- package/dialog/lib/dialog.service.d.ts +19 -19
- package/dialog/public_api.d.ts +9 -9
- package/elements/bravobit-bb-foundation-elements.d.ts +5 -5
- package/elements/lib/avatar/avatar.component.d.ts +25 -25
- package/elements/lib/button/button.component.d.ts +23 -23
- package/elements/lib/checkbox/checkbox.component.d.ts +27 -27
- package/elements/lib/date-picker/date-picker.component.d.ts +69 -69
- package/elements/lib/directives/addon.directive.d.ts +9 -9
- package/elements/lib/directives/autosize.directive.d.ts +18 -18
- package/elements/lib/directives/focus-trap.directive.d.ts +17 -17
- package/elements/lib/directives/focus.directive.d.ts +14 -14
- package/elements/lib/directives/form-submit.directive.d.ts +17 -17
- package/elements/lib/directives/input.directive.d.ts +38 -38
- package/elements/lib/directives/template.directive.d.ts +10 -10
- package/elements/lib/dropdown/dropdown.component.d.ts +21 -21
- package/elements/lib/elements.interfaces.d.ts +25 -25
- package/elements/lib/elements.module.d.ts +116 -116
- package/elements/lib/file-picker/file-picker.component.d.ts +49 -49
- package/elements/lib/form-control/form-control.component.d.ts +21 -21
- package/elements/lib/form-error/form-error.component.d.ts +29 -29
- package/elements/lib/form-group/form-group.component.d.ts +10 -10
- package/elements/lib/icon/icon.component.d.ts +22 -22
- package/elements/lib/image-picker/image-picker.component.d.ts +38 -38
- package/elements/lib/pipes/file-image.pipe.d.ts +13 -13
- package/elements/lib/pipes/file-size.pipe.d.ts +8 -8
- package/elements/lib/pipes/relative-time.pipe.d.ts +19 -19
- package/elements/lib/spinner/spinner.component.d.ts +12 -12
- package/elements/lib/tag/tag.component.d.ts +7 -7
- package/elements/public_api.d.ts +25 -25
- package/esm2020/auth/bravobit-bb-foundation-auth.mjs +4 -4
- package/esm2020/auth/lib/auth.interceptor.mjs +93 -94
- package/esm2020/auth/lib/auth.module.mjs +54 -54
- package/esm2020/auth/lib/auth.service.mjs +281 -276
- package/esm2020/auth/lib/auth.session.mjs +131 -131
- package/esm2020/auth/lib/directives/authenticated.directive.mjs +31 -31
- package/esm2020/auth/lib/directives/permission.directive.mjs +80 -80
- package/esm2020/auth/lib/directives/role.directive.mjs +37 -37
- package/esm2020/auth/lib/guards/anonymous.guard.mjs +34 -34
- package/esm2020/auth/lib/guards/authenticated.guard.mjs +35 -35
- package/esm2020/auth/lib/helpers/jwt.helper.mjs +69 -69
- package/esm2020/auth/lib/helpers/mapper.helper.mjs +35 -35
- package/esm2020/auth/lib/interfaces/config.interface.mjs +3 -3
- package/esm2020/auth/lib/interfaces/mapper.interface.mjs +2 -2
- package/esm2020/auth/lib/interfaces/provider.interface.mjs +2 -2
- package/esm2020/auth/lib/interfaces/token.interface.mjs +2 -2
- package/esm2020/auth/lib/permissions.service.mjs +56 -56
- package/esm2020/auth/lib/providers/email.provider.mjs +25 -25
- package/esm2020/auth/lib/providers/verify.provider.mjs +19 -19
- package/esm2020/auth/lib/tokens/use-authorization.token.mjs +3 -3
- package/esm2020/auth/public_api.mjs +19 -19
- package/esm2020/bravobit-bb-foundation.mjs +4 -4
- package/esm2020/collections/bravobit-bb-foundation-collections.mjs +4 -4
- package/esm2020/collections/lib/collection.mjs +102 -102
- package/esm2020/collections/lib/collections.module.mjs +54 -54
- package/esm2020/collections/lib/components/collections-pager/collections-pager.component.mjs +123 -123
- package/esm2020/collections/lib/components/collections-viewer/collections-viewer.component.mjs +31 -31
- package/esm2020/collections/lib/components/collections.directive.mjs +43 -43
- package/esm2020/collections/lib/interfaces/collection.interface.mjs +2 -2
- package/esm2020/collections/lib/providers/api-collection.provider.mjs +71 -71
- package/esm2020/collections/lib/providers/collection.provider.mjs +13 -13
- package/esm2020/collections/lib/providers/local-collection.provider.mjs +16 -16
- package/esm2020/collections/public_api.mjs +10 -10
- package/esm2020/controls/bravobit-bb-foundation-controls.mjs +4 -4
- package/esm2020/controls/lib/checkbox/checkbox/checkbox.component.mjs +153 -153
- package/esm2020/controls/lib/checkbox/checkbox-group/checkbox-group.component.mjs +48 -48
- package/esm2020/controls/lib/checkbox/checkbox.module.mjs +19 -19
- package/esm2020/controls/lib/controls.module.mjs +16 -16
- package/esm2020/controls/public_api.mjs +5 -5
- package/esm2020/dashboard/bravobit-bb-foundation-dashboard.mjs +4 -4
- package/esm2020/dashboard/lib/dashboard/dashboard.component.mjs +56 -56
- package/esm2020/dashboard/lib/dashboard-header/dashboard-header.component.mjs +30 -30
- package/esm2020/dashboard/lib/dashboard-menu/dashboard-menu.component.mjs +31 -31
- package/esm2020/dashboard/lib/dashboard-menu-item/dashboard-menu-item.component.mjs +29 -29
- package/esm2020/dashboard/lib/dashboard-sidebar/dashboard-sidebar.component.mjs +75 -75
- package/esm2020/dashboard/lib/dashboard-sidebar-group/dashboard-sidebar-group.component.mjs +99 -99
- package/esm2020/dashboard/lib/dashboard-sidebar-item/dashboard-sidebar-item.component.mjs +62 -62
- package/esm2020/dashboard/lib/dashboard.module.mjs +47 -47
- package/esm2020/dashboard/public_api.mjs +9 -9
- package/esm2020/dialog/bravobit-bb-foundation-dialog.mjs +4 -4
- package/esm2020/dialog/lib/dialog-actions/dialog-actions.component.mjs +12 -12
- package/esm2020/dialog/lib/dialog-confirm/dialog-confirm.component.mjs +37 -37
- package/esm2020/dialog/lib/dialog-container/dialog-container.component.mjs +153 -153
- package/esm2020/dialog/lib/dialog-header/dialog-header.component.mjs +25 -25
- package/esm2020/dialog/lib/dialog-link/dialog-link.component.mjs +11 -11
- package/esm2020/dialog/lib/dialog-modal/dialog-modal.component.mjs +46 -46
- package/esm2020/dialog/lib/dialog-overlay/dialog-overlay.component.mjs +134 -134
- package/esm2020/dialog/lib/dialog.injector.mjs +18 -18
- package/esm2020/dialog/lib/dialog.insertion.mjs +16 -16
- package/esm2020/dialog/lib/dialog.interfaces.mjs +3 -3
- package/esm2020/dialog/lib/dialog.module.mjs +70 -70
- package/esm2020/dialog/lib/dialog.ref.mjs +22 -22
- package/esm2020/dialog/lib/dialog.service.mjs +77 -77
- package/esm2020/dialog/public_api.mjs +10 -10
- package/esm2020/elements/bravobit-bb-foundation-elements.mjs +4 -4
- package/esm2020/elements/lib/avatar/avatar.component.mjs +145 -142
- package/esm2020/elements/lib/button/button.component.mjs +61 -61
- package/esm2020/elements/lib/checkbox/checkbox.component.mjs +73 -73
- package/esm2020/elements/lib/date-picker/date-picker.component.mjs +304 -304
- package/esm2020/elements/lib/directives/addon.directive.mjs +29 -29
- package/esm2020/elements/lib/directives/autosize.directive.mjs +72 -72
- package/esm2020/elements/lib/directives/focus-trap.directive.mjs +77 -77
- package/esm2020/elements/lib/directives/focus.directive.mjs +39 -39
- package/esm2020/elements/lib/directives/form-submit.directive.mjs +50 -50
- package/esm2020/elements/lib/directives/input.directive.mjs +136 -136
- package/esm2020/elements/lib/directives/template.directive.mjs +28 -28
- package/esm2020/elements/lib/dropdown/dropdown.component.mjs +100 -100
- package/esm2020/elements/lib/elements.interfaces.mjs +4 -4
- package/esm2020/elements/lib/elements.module.mjs +177 -177
- package/esm2020/elements/lib/file-picker/file-picker.component.mjs +236 -236
- package/esm2020/elements/lib/form-control/form-control.component.mjs +49 -49
- package/esm2020/elements/lib/form-error/form-error.component.mjs +108 -108
- package/esm2020/elements/lib/form-group/form-group.component.mjs +18 -18
- package/esm2020/elements/lib/icon/icon.component.mjs +102 -102
- package/esm2020/elements/lib/image-picker/image-picker.component.mjs +106 -106
- package/esm2020/elements/lib/pipes/file-image.pipe.mjs +42 -42
- package/esm2020/elements/lib/pipes/file-size.pipe.mjs +28 -28
- package/esm2020/elements/lib/pipes/relative-time.pipe.mjs +94 -94
- package/esm2020/elements/lib/spinner/spinner.component.mjs +25 -25
- package/esm2020/elements/lib/tag/tag.component.mjs +18 -18
- package/esm2020/elements/public_api.mjs +26 -26
- package/esm2020/http/bravobit-bb-foundation-http.mjs +4 -4
- package/esm2020/http/lib/classes/http.config.mjs +29 -29
- package/esm2020/http/lib/classes/http.error.mjs +20 -20
- package/esm2020/http/lib/http.interfaces.mjs +2 -2
- package/esm2020/http/lib/http.module.mjs +43 -43
- package/esm2020/http/lib/interceptors/base-url.interceptor.mjs +50 -50
- package/esm2020/http/lib/interceptors/error.interceptor.mjs +32 -32
- package/esm2020/http/public_api.mjs +7 -7
- package/esm2020/lib/core/miscellaneous/regex.mjs +5 -5
- package/esm2020/lib/core/miscellaneous/validator.mjs +85 -85
- package/esm2020/lib/core/mixins/can-disable.mjs +16 -16
- package/esm2020/lib/core/mixins/can-hide-errors.mjs +16 -16
- package/esm2020/lib/core/mixins/can-load.mjs +16 -16
- package/esm2020/lib/core/mixins/constructor.mjs +2 -2
- package/esm2020/lib/core/mixins/has-error.mjs +16 -16
- package/esm2020/lib/core/mixins/is-focused.mjs +16 -16
- package/esm2020/lib/core/mixins/is-grouped.mjs +16 -16
- package/esm2020/lib/core/mixins/is-readonly.mjs +16 -16
- package/esm2020/lib/core/mixins/is-required.mjs +16 -16
- package/esm2020/lib/core/services/clipboard.service.mjs +70 -70
- package/esm2020/lib/core/services/exif.service.mjs +163 -163
- package/esm2020/lib/core/services/file-loader.service.mjs +87 -87
- package/esm2020/lib/core/services/image-converter.service.mjs +123 -123
- package/esm2020/lib/core/services/languages.service.mjs +74 -74
- package/esm2020/lib/core/services/network.service.mjs +55 -55
- package/esm2020/lib/core/services/patch.service.mjs +63 -63
- package/esm2020/lib/core/services/platform.service.mjs +42 -42
- package/esm2020/lib/core/tokens/accept-language.token.mjs +3 -3
- package/esm2020/lib/core/tokens/base-url.token.mjs +3 -3
- package/esm2020/lib/core/tokens/cookie.token.mjs +3 -3
- package/esm2020/lib/core/tokens/location.token.mjs +6 -6
- package/esm2020/lib/core/tokens/navigator.token.mjs +6 -6
- package/esm2020/lib/core/tokens/window.token.mjs +12 -12
- package/esm2020/localize/bravobit-bb-foundation-localize.mjs +4 -4
- package/esm2020/localize/lib/functions/date.function.mjs +18 -18
- package/esm2020/localize/lib/functions/lowercase.function.mjs +13 -13
- package/esm2020/localize/lib/functions/uppercase.function.mjs +13 -13
- package/esm2020/localize/lib/handlers/missing.handler.mjs +15 -17
- package/esm2020/localize/lib/interfaces/config.interfaces.mjs +7 -10
- package/esm2020/localize/lib/interfaces/functions.interfaces.mjs +8 -8
- package/esm2020/localize/lib/interfaces/handlers.interfaces.mjs +2 -2
- package/esm2020/localize/lib/interfaces/options.interfaces.mjs +6 -6
- package/esm2020/localize/lib/localizations/dutch.localization.mjs +45 -53
- package/esm2020/localize/lib/localizations/english.localization.mjs +45 -53
- package/esm2020/localize/lib/localize.dictionary.mjs +26 -135
- package/esm2020/localize/lib/localize.module.mjs +71 -69
- package/esm2020/localize/lib/localize.pipe.mjs +49 -49
- package/esm2020/localize/lib/localize.service.mjs +205 -277
- package/esm2020/localize/lib/views/localize-string/localize-string.component.mjs +88 -88
- package/esm2020/localize/lib/views/localize-template-or-string.directive.mjs +28 -28
- package/esm2020/localize/lib/views/localize-template.directive.mjs +21 -21
- package/esm2020/localize/public_api.mjs +17 -18
- package/esm2020/notifications/bravobit-bb-foundation-notifications.mjs +4 -4
- package/esm2020/notifications/lib/notifications-item/notifications-item.component.mjs +100 -100
- package/esm2020/notifications/lib/notifications-list/notifications-list.component.mjs +47 -47
- package/esm2020/notifications/lib/notifications.animations.mjs +28 -28
- package/esm2020/notifications/lib/notifications.injector.mjs +18 -18
- package/esm2020/notifications/lib/notifications.interfaces.mjs +20 -20
- package/esm2020/notifications/lib/notifications.module.mjs +30 -30
- package/esm2020/notifications/lib/notifications.service.mjs +145 -145
- package/esm2020/notifications/public_api.mjs +4 -4
- package/esm2020/public_api.mjs +29 -29
- package/esm2020/recaptcha/bravobit-bb-foundation-recaptcha.mjs +4 -4
- package/esm2020/recaptcha/lib/recaptcha/recaptcha.component.mjs +185 -185
- package/esm2020/recaptcha/lib/recaptcha-loader.service.mjs +90 -90
- package/esm2020/recaptcha/lib/recaptcha.interface.mjs +3 -3
- package/esm2020/recaptcha/lib/recaptcha.module.mjs +27 -27
- package/esm2020/recaptcha/public_api.mjs +5 -5
- package/esm2020/rxjs/bravobit-bb-foundation-rxjs.mjs +4 -4
- package/esm2020/rxjs/lib/operators/combine-latest-map.operator.mjs +10 -10
- package/esm2020/rxjs/lib/operators/filter-nil.operator.mjs +5 -5
- package/esm2020/rxjs/public_api.mjs +3 -3
- package/esm2020/storage/bravobit-bb-foundation-storage.mjs +4 -4
- package/esm2020/storage/lib/interfaces/attributes.interface.mjs +2 -2
- package/esm2020/storage/lib/interfaces/memory.interface.mjs +2 -2
- package/esm2020/storage/lib/interfaces/strategy.interface.mjs +2 -2
- package/esm2020/storage/lib/storage.service.mjs +109 -109
- package/esm2020/storage/lib/strategies/cookie-storage.strategy.mjs +142 -142
- package/esm2020/storage/lib/strategies/memory-storage.strategy.mjs +56 -56
- package/esm2020/storage/lib/strategies/polyfill-storage.strategy.mjs +102 -102
- package/esm2020/storage/public_api.mjs +8 -8
- package/esm2020/table/bravobit-bb-foundation-table.mjs +4 -4
- package/esm2020/table/lib/components/table/table.component.mjs +191 -191
- package/esm2020/table/lib/components/table-cell/table-cell.component.mjs +11 -11
- package/esm2020/table/lib/components/table-header-cell/table-header-cell.component.mjs +131 -131
- package/esm2020/table/lib/components/table-pager/table-pager.component.mjs +136 -136
- package/esm2020/table/lib/data/datasource.data.mjs +32 -32
- package/esm2020/table/lib/data/generic.data.mjs +72 -72
- package/esm2020/table/lib/interfaces/datasource.interface.mjs +2 -2
- package/esm2020/table/lib/interfaces/table.interfaces.mjs +2 -2
- package/esm2020/table/lib/table.module.mjs +42 -42
- package/esm2020/table/public_api.mjs +10 -10
- package/fesm2015/bravobit-bb-foundation-auth.mjs +930 -926
- package/fesm2015/bravobit-bb-foundation-auth.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-collections.mjs +423 -423
- package/fesm2015/bravobit-bb-foundation-collections.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-controls.mjs +216 -216
- package/fesm2015/bravobit-bb-foundation-controls.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-dashboard.mjs +382 -382
- package/fesm2015/bravobit-bb-foundation-dashboard.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-dialog.mjs +542 -542
- package/fesm2015/bravobit-bb-foundation-dialog.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-elements.mjs +1971 -1968
- package/fesm2015/bravobit-bb-foundation-elements.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-http.mjs +156 -156
- package/fesm2015/bravobit-bb-foundation-http.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-localize.mjs +611 -805
- package/fesm2015/bravobit-bb-foundation-localize.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-notifications.mjs +348 -348
- package/fesm2015/bravobit-bb-foundation-notifications.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-recaptcha.mjs +290 -290
- package/fesm2015/bravobit-bb-foundation-recaptcha.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-rxjs.mjs +7 -7
- package/fesm2015/bravobit-bb-foundation-rxjs.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-storage.mjs +401 -401
- package/fesm2015/bravobit-bb-foundation-storage.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-table.mjs +571 -571
- package/fesm2015/bravobit-bb-foundation-table.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation.mjs +860 -860
- package/fesm2015/bravobit-bb-foundation.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-auth.mjs +882 -878
- package/fesm2020/bravobit-bb-foundation-auth.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-collections.mjs +413 -413
- package/fesm2020/bravobit-bb-foundation-collections.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-controls.mjs +214 -214
- package/fesm2020/bravobit-bb-foundation-controls.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-dashboard.mjs +370 -370
- package/fesm2020/bravobit-bb-foundation-dashboard.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-dialog.mjs +541 -541
- package/fesm2020/bravobit-bb-foundation-dialog.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-elements.mjs +1928 -1925
- package/fesm2020/bravobit-bb-foundation-elements.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-http.mjs +148 -148
- package/fesm2020/bravobit-bb-foundation-http.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-localize.mjs +590 -792
- package/fesm2020/bravobit-bb-foundation-localize.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-notifications.mjs +346 -346
- package/fesm2020/bravobit-bb-foundation-notifications.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-recaptcha.mjs +280 -280
- package/fesm2020/bravobit-bb-foundation-recaptcha.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-rxjs.mjs +10 -10
- package/fesm2020/bravobit-bb-foundation-rxjs.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-storage.mjs +396 -396
- package/fesm2020/bravobit-bb-foundation-storage.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-table.mjs +560 -560
- package/fesm2020/bravobit-bb-foundation-table.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation.mjs +832 -832
- package/fesm2020/bravobit-bb-foundation.mjs.map +1 -1
- package/http/bravobit-bb-foundation-http.d.ts +5 -5
- package/http/lib/classes/http.config.d.ts +9 -9
- package/http/lib/classes/http.error.d.ts +7 -7
- package/http/lib/http.interfaces.d.ts +12 -12
- package/http/lib/http.module.d.ts +15 -15
- package/http/lib/interceptors/base-url.interceptor.d.ts +15 -15
- package/http/lib/interceptors/error.interceptor.d.ts +11 -11
- package/http/public_api.d.ts +6 -6
- package/lib/core/miscellaneous/regex.d.ts +4 -4
- package/lib/core/miscellaneous/validator.d.ts +13 -13
- package/lib/core/mixins/can-disable.d.ts +6 -6
- package/lib/core/mixins/can-hide-errors.d.ts +6 -6
- package/lib/core/mixins/can-load.d.ts +6 -6
- package/lib/core/mixins/constructor.d.ts +1 -1
- package/lib/core/mixins/has-error.d.ts +6 -6
- package/lib/core/mixins/is-focused.d.ts +6 -6
- package/lib/core/mixins/is-grouped.d.ts +6 -6
- package/lib/core/mixins/is-readonly.d.ts +6 -6
- package/lib/core/mixins/is-required.d.ts +6 -6
- package/lib/core/services/clipboard.service.d.ts +18 -18
- package/lib/core/services/exif.service.d.ts +15 -15
- package/lib/core/services/file-loader.service.d.ts +13 -13
- package/lib/core/services/image-converter.service.d.ts +21 -21
- package/lib/core/services/languages.service.d.ts +16 -16
- package/lib/core/services/network.service.d.ts +14 -14
- package/lib/core/services/patch.service.d.ts +16 -16
- package/lib/core/services/platform.service.d.ts +18 -18
- package/lib/core/tokens/accept-language.token.d.ts +2 -2
- package/lib/core/tokens/base-url.token.d.ts +2 -2
- package/lib/core/tokens/cookie.token.d.ts +2 -2
- package/lib/core/tokens/location.token.d.ts +2 -2
- package/lib/core/tokens/navigator.token.d.ts +2 -2
- package/lib/core/tokens/window.token.d.ts +2 -2
- package/localize/bravobit-bb-foundation-localize.d.ts +5 -5
- package/localize/lib/functions/date.function.d.ts +5 -5
- package/localize/lib/functions/lowercase.function.d.ts +5 -5
- package/localize/lib/functions/uppercase.function.d.ts +5 -5
- package/localize/lib/handlers/missing.handler.d.ts +6 -6
- package/localize/lib/interfaces/config.interfaces.d.ts +18 -8
- package/localize/lib/interfaces/functions.interfaces.d.ts +9 -9
- package/localize/lib/interfaces/handlers.interfaces.d.ts +6 -6
- package/localize/lib/interfaces/options.interfaces.d.ts +10 -10
- package/localize/lib/localizations/dutch.localization.d.ts +44 -51
- package/localize/lib/localizations/english.localization.d.ts +44 -51
- package/localize/lib/localize.dictionary.d.ts +7 -24
- package/localize/lib/localize.module.d.ts +17 -18
- package/localize/lib/localize.pipe.d.ts +12 -12
- package/localize/lib/localize.service.d.ts +40 -51
- package/localize/lib/views/localize-string/localize-string.component.d.ts +23 -23
- package/localize/lib/views/localize-template-or-string.directive.d.ts +10 -10
- package/localize/lib/views/localize-template.directive.d.ts +9 -9
- package/localize/public_api.d.ts +16 -17
- package/notifications/bravobit-bb-foundation-notifications.d.ts +5 -5
- package/notifications/lib/notifications-item/notifications-item.component.d.ts +34 -34
- package/notifications/lib/notifications-list/notifications-list.component.d.ts +16 -16
- package/notifications/lib/notifications.animations.d.ts +1 -1
- package/notifications/lib/notifications.injector.d.ts +8 -8
- package/notifications/lib/notifications.interfaces.d.ts +49 -49
- package/notifications/lib/notifications.module.d.ts +13 -13
- package/notifications/lib/notifications.service.d.ts +34 -34
- package/notifications/public_api.d.ts +3 -3
- package/package.json +6 -6
- package/public_api.d.ts +25 -25
- package/recaptcha/bravobit-bb-foundation-recaptcha.d.ts +5 -5
- package/recaptcha/lib/recaptcha/recaptcha.component.d.ts +47 -47
- package/recaptcha/lib/recaptcha-loader.service.d.ts +22 -22
- package/recaptcha/lib/recaptcha.interface.d.ts +14 -14
- package/recaptcha/lib/recaptcha.module.d.ts +10 -10
- package/recaptcha/public_api.d.ts +4 -4
- package/rxjs/bravobit-bb-foundation-rxjs.d.ts +5 -5
- package/rxjs/lib/operators/combine-latest-map.operator.d.ts +8 -8
- package/rxjs/lib/operators/filter-nil.operator.d.ts +1 -1
- package/rxjs/public_api.d.ts +2 -2
- package/storage/bravobit-bb-foundation-storage.d.ts +5 -5
- package/storage/lib/interfaces/attributes.interface.d.ts +13 -13
- package/storage/lib/interfaces/memory.interface.d.ts +7 -7
- package/storage/lib/interfaces/strategy.interface.d.ts +17 -17
- package/storage/lib/storage.service.d.ts +26 -26
- package/storage/lib/strategies/cookie-storage.strategy.d.ts +20 -20
- package/storage/lib/strategies/memory-storage.strategy.d.ts +11 -11
- package/storage/lib/strategies/polyfill-storage.strategy.d.ts +15 -15
- package/storage/public_api.d.ts +7 -7
- package/table/bravobit-bb-foundation-table.d.ts +5 -5
- package/table/lib/components/table/table.component.d.ts +56 -56
- package/table/lib/components/table-cell/table-cell.component.d.ts +5 -5
- package/table/lib/components/table-header-cell/table-header-cell.component.d.ts +29 -29
- package/table/lib/components/table-pager/table-pager.component.d.ts +41 -41
- package/table/lib/data/datasource.data.d.ts +14 -14
- package/table/lib/data/generic.data.d.ts +23 -23
- package/table/lib/interfaces/datasource.interface.d.ts +17 -17
- package/table/lib/interfaces/table.interfaces.d.ts +1 -1
- package/table/lib/table.module.d.ts +14 -14
- package/table/public_api.d.ts +9 -9
- package/esm2020/localize/lib/interfaces/dictionary.interfaces.mjs +0 -8
- package/localize/lib/interfaces/dictionary.interfaces.d.ts +0 -12
|
@@ -12,916 +12,920 @@ import * as i3 from '@bravobit/bb-foundation';
|
|
|
12
12
|
import * as i7 from '@bravobit/bb-foundation/http';
|
|
13
13
|
import { HttpError } from '@bravobit/bb-foundation/http';
|
|
14
14
|
|
|
15
|
-
class AuthConfig {
|
|
15
|
+
class AuthConfig {
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
const USE_AUTHORIZATION = new HttpContextToken(() => true);
|
|
19
19
|
|
|
20
|
-
class JwtHelper {
|
|
21
|
-
constructor() {
|
|
22
|
-
this.baseDecodeUnicode = (value) => {
|
|
23
|
-
return decodeURIComponent(atob(value).replace(/(.)/g, (_, p) => {
|
|
24
|
-
let code = p.charCodeAt(0).toString(16).toUpperCase();
|
|
25
|
-
if (code.length < 2) {
|
|
26
|
-
code = '0' + code;
|
|
27
|
-
}
|
|
28
|
-
return '%' + code;
|
|
29
|
-
}));
|
|
30
|
-
};
|
|
31
|
-
this.parse = (data) => {
|
|
32
|
-
return {
|
|
33
|
-
id: data['iss'] || null,
|
|
34
|
-
type: data['typ'] || null,
|
|
35
|
-
audience: data['aud'] || null,
|
|
36
|
-
issuer: data['iss'] || null,
|
|
37
|
-
subject: data['sub'] || null,
|
|
38
|
-
role: data['role'] || null,
|
|
39
|
-
notValidBefore: this.parseDate(data['nbf']),
|
|
40
|
-
expiresAt: this.parseDate(data['exp']),
|
|
41
|
-
issuedAt: this.parseDate(data['iat'])
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
this.parseDate = (epochInSeconds) => {
|
|
45
|
-
if (!epochInSeconds || epochInSeconds <= 0) {
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
return new Date(epochInSeconds * 1000);
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
decode(token) {
|
|
52
|
-
try {
|
|
53
|
-
if (token === null || token === undefined) {
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
const json = JSON.parse(this.urlDecode(token.split('.')[1]));
|
|
57
|
-
return this.parse(json);
|
|
58
|
-
}
|
|
59
|
-
catch {
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
urlDecode(token) {
|
|
64
|
-
const value = token || '';
|
|
65
|
-
let output = value
|
|
66
|
-
.replace(/-/g, '+')
|
|
67
|
-
.replace(/_/g, '/');
|
|
68
|
-
switch (output.length % 4) {
|
|
69
|
-
case 0:
|
|
70
|
-
break;
|
|
71
|
-
case 2:
|
|
72
|
-
output += '==';
|
|
73
|
-
break;
|
|
74
|
-
case 3:
|
|
75
|
-
output += '=';
|
|
76
|
-
break;
|
|
77
|
-
default:
|
|
78
|
-
throw 'Illegal base64url string!';
|
|
79
|
-
}
|
|
80
|
-
try {
|
|
81
|
-
return this.baseDecodeUnicode(output);
|
|
82
|
-
}
|
|
83
|
-
catch {
|
|
84
|
-
return atob(output);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
20
|
+
class JwtHelper {
|
|
21
|
+
constructor() {
|
|
22
|
+
this.baseDecodeUnicode = (value) => {
|
|
23
|
+
return decodeURIComponent(atob(value).replace(/(.)/g, (_, p) => {
|
|
24
|
+
let code = p.charCodeAt(0).toString(16).toUpperCase();
|
|
25
|
+
if (code.length < 2) {
|
|
26
|
+
code = '0' + code;
|
|
27
|
+
}
|
|
28
|
+
return '%' + code;
|
|
29
|
+
}));
|
|
30
|
+
};
|
|
31
|
+
this.parse = (data) => {
|
|
32
|
+
return {
|
|
33
|
+
id: data['iss'] || null,
|
|
34
|
+
type: data['typ'] || null,
|
|
35
|
+
audience: data['aud'] || null,
|
|
36
|
+
issuer: data['iss'] || null,
|
|
37
|
+
subject: data['sub'] || null,
|
|
38
|
+
role: data['role'] || null,
|
|
39
|
+
notValidBefore: this.parseDate(data['nbf']),
|
|
40
|
+
expiresAt: this.parseDate(data['exp']),
|
|
41
|
+
issuedAt: this.parseDate(data['iat'])
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
this.parseDate = (epochInSeconds) => {
|
|
45
|
+
if (!epochInSeconds || epochInSeconds <= 0) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
return new Date(epochInSeconds * 1000);
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
decode(token) {
|
|
52
|
+
try {
|
|
53
|
+
if (token === null || token === undefined) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
const json = JSON.parse(this.urlDecode(token.split('.')[1]));
|
|
57
|
+
return this.parse(json);
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
urlDecode(token) {
|
|
64
|
+
const value = token || '';
|
|
65
|
+
let output = value
|
|
66
|
+
.replace(/-/g, '+')
|
|
67
|
+
.replace(/_/g, '/');
|
|
68
|
+
switch (output.length % 4) {
|
|
69
|
+
case 0:
|
|
70
|
+
break;
|
|
71
|
+
case 2:
|
|
72
|
+
output += '==';
|
|
73
|
+
break;
|
|
74
|
+
case 3:
|
|
75
|
+
output += '=';
|
|
76
|
+
break;
|
|
77
|
+
default:
|
|
78
|
+
throw 'Illegal base64url string!';
|
|
79
|
+
}
|
|
80
|
+
try {
|
|
81
|
+
return this.baseDecodeUnicode(output);
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
return atob(output);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
class AuthMapper {
|
|
90
|
-
constructor() {
|
|
91
|
-
// Routes.
|
|
92
|
-
this.me = 'auth/me';
|
|
93
|
-
this.register = 'auth/register';
|
|
94
|
-
this.resendCode = 'auth/resend';
|
|
95
|
-
this.logout = 'auth/logout';
|
|
96
|
-
this.refresh = 'auth/refresh';
|
|
97
|
-
this.requestPassword = 'auth/reset';
|
|
98
|
-
this.resetPassword = 'auth/reset-password';
|
|
99
|
-
}
|
|
100
|
-
role(data) {
|
|
101
|
-
return (data && data.role) || null;
|
|
102
|
-
}
|
|
103
|
-
toRegister(data) {
|
|
104
|
-
// Retrieve the params.
|
|
105
|
-
const { token, refresh_token, user } = data;
|
|
106
|
-
// Map the data to the correct format.
|
|
107
|
-
return { accessToken: token, refreshToken: refresh_token, user: user };
|
|
108
|
-
}
|
|
109
|
-
toRefresh(data) {
|
|
110
|
-
// Retrieve the params.
|
|
111
|
-
const { token, refresh_token } = data;
|
|
112
|
-
// Map the data to the correct format.
|
|
113
|
-
return { accessToken: token, refreshToken: refresh_token };
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
AuthMapper.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.
|
|
117
|
-
AuthMapper.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.
|
|
118
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.
|
|
119
|
-
type: Injectable
|
|
89
|
+
class AuthMapper {
|
|
90
|
+
constructor() {
|
|
91
|
+
// Routes.
|
|
92
|
+
this.me = 'auth/me';
|
|
93
|
+
this.register = 'auth/register';
|
|
94
|
+
this.resendCode = 'auth/resend';
|
|
95
|
+
this.logout = 'auth/logout';
|
|
96
|
+
this.refresh = 'auth/refresh';
|
|
97
|
+
this.requestPassword = 'auth/reset';
|
|
98
|
+
this.resetPassword = 'auth/reset-password';
|
|
99
|
+
}
|
|
100
|
+
role(data) {
|
|
101
|
+
return (data && data.role) || null;
|
|
102
|
+
}
|
|
103
|
+
toRegister(data) {
|
|
104
|
+
// Retrieve the params.
|
|
105
|
+
const { token, refresh_token, user } = data;
|
|
106
|
+
// Map the data to the correct format.
|
|
107
|
+
return { accessToken: token, refreshToken: refresh_token, user: user };
|
|
108
|
+
}
|
|
109
|
+
toRefresh(data) {
|
|
110
|
+
// Retrieve the params.
|
|
111
|
+
const { token, refresh_token } = data;
|
|
112
|
+
// Map the data to the correct format.
|
|
113
|
+
return { accessToken: token, refreshToken: refresh_token };
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
AuthMapper.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: AuthMapper, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
117
|
+
AuthMapper.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: AuthMapper });
|
|
118
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: AuthMapper, decorators: [{
|
|
119
|
+
type: Injectable
|
|
120
120
|
}] });
|
|
121
121
|
|
|
122
|
-
class AuthVerifyProvider {
|
|
123
|
-
constructor(_code, _verifyToken, _endpoint) {
|
|
124
|
-
this._code = _code;
|
|
125
|
-
this._verifyToken = _verifyToken;
|
|
126
|
-
this._endpoint = _endpoint;
|
|
127
|
-
}
|
|
128
|
-
async authenticate(httpClient) {
|
|
129
|
-
// Execute API call.
|
|
130
|
-
const data$ = await httpClient.post(this._endpoint, {
|
|
131
|
-
token: this._code,
|
|
132
|
-
verify_token: this._verifyToken
|
|
133
|
-
});
|
|
134
|
-
const { token, refresh_token, user } = await firstValueFrom(data$);
|
|
135
|
-
// Map the data to the correct format.
|
|
136
|
-
return { accessToken: token, refreshToken: refresh_token, user: user };
|
|
137
|
-
}
|
|
122
|
+
class AuthVerifyProvider {
|
|
123
|
+
constructor(_code, _verifyToken, _endpoint) {
|
|
124
|
+
this._code = _code;
|
|
125
|
+
this._verifyToken = _verifyToken;
|
|
126
|
+
this._endpoint = _endpoint;
|
|
127
|
+
}
|
|
128
|
+
async authenticate(httpClient) {
|
|
129
|
+
// Execute API call.
|
|
130
|
+
const data$ = await httpClient.post(this._endpoint, {
|
|
131
|
+
token: this._code,
|
|
132
|
+
verify_token: this._verifyToken
|
|
133
|
+
});
|
|
134
|
+
const { token, refresh_token, user } = await firstValueFrom(data$);
|
|
135
|
+
// Map the data to the correct format.
|
|
136
|
+
return { accessToken: token, refreshToken: refresh_token, user: user };
|
|
137
|
+
}
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
class AuthEmailProvider {
|
|
141
|
-
constructor(_email, _password, _endpoint) {
|
|
142
|
-
this._email = _email;
|
|
143
|
-
this._password = _password;
|
|
144
|
-
this._endpoint = _endpoint;
|
|
145
|
-
}
|
|
146
|
-
async authenticate(httpClient) {
|
|
147
|
-
// Execute API call.
|
|
148
|
-
const data$ = await httpClient.post(this._endpoint, {
|
|
149
|
-
email: this._email,
|
|
150
|
-
password: this._password
|
|
151
|
-
});
|
|
152
|
-
const { token, refresh_token, user, provider, verify_token } = await firstValueFrom(data$);
|
|
153
|
-
// Map the data to the correct format.
|
|
154
|
-
return {
|
|
155
|
-
accessToken: token,
|
|
156
|
-
refreshToken: refresh_token,
|
|
157
|
-
user: user,
|
|
158
|
-
provider: provider,
|
|
159
|
-
verifyToken: verify_token
|
|
160
|
-
};
|
|
161
|
-
}
|
|
140
|
+
class AuthEmailProvider {
|
|
141
|
+
constructor(_email, _password, _endpoint) {
|
|
142
|
+
this._email = _email;
|
|
143
|
+
this._password = _password;
|
|
144
|
+
this._endpoint = _endpoint;
|
|
145
|
+
}
|
|
146
|
+
async authenticate(httpClient) {
|
|
147
|
+
// Execute API call.
|
|
148
|
+
const data$ = await httpClient.post(this._endpoint, {
|
|
149
|
+
email: this._email,
|
|
150
|
+
password: this._password
|
|
151
|
+
});
|
|
152
|
+
const { token, refresh_token, user, provider, verify_token } = await firstValueFrom(data$);
|
|
153
|
+
// Map the data to the correct format.
|
|
154
|
+
return {
|
|
155
|
+
accessToken: token,
|
|
156
|
+
refreshToken: refresh_token,
|
|
157
|
+
user: user,
|
|
158
|
+
provider: provider,
|
|
159
|
+
verifyToken: verify_token
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
-
class AuthSession {
|
|
165
|
-
constructor(options) {
|
|
166
|
-
// Readonly data.
|
|
167
|
-
this._jwt = new JwtHelper();
|
|
168
|
-
// Token strings.
|
|
169
|
-
this._accessTokenString = null;
|
|
170
|
-
this._refreshTokenString = null;
|
|
171
|
-
// Token payloads.
|
|
172
|
-
this._accessTokenPayload = null;
|
|
173
|
-
this._refreshTokenPayload = null;
|
|
174
|
-
// Private user data.
|
|
175
|
-
this._user$ = new BehaviorSubject(null);
|
|
176
|
-
// Public user data.
|
|
177
|
-
this.user = this._user$.pipe(shareReplay(1));
|
|
178
|
-
this.generateKey = (applicationId, key) => {
|
|
179
|
-
return [applicationId, key].join('_');
|
|
180
|
-
};
|
|
181
|
-
this.isTokenValid = (token) => {
|
|
182
|
-
if (!token) {
|
|
183
|
-
return false;
|
|
184
|
-
}
|
|
185
|
-
return token?.expiresAt?.getTime() > Date.now();
|
|
186
|
-
};
|
|
187
|
-
const applicationId = options?.id ?? 'ng';
|
|
188
|
-
// Setting up the readonly storage keys.
|
|
189
|
-
this._accessTokenStorageKey = this.generateKey(applicationId, 'au_act');
|
|
190
|
-
this._refreshTokenStorageKey = this.generateKey(applicationId, 'au_rft');
|
|
191
|
-
this._userStorageKey = this.generateKey(applicationId, 'au_usr');
|
|
192
|
-
// Setting up the storage.
|
|
193
|
-
this._storage = options?.storage ?? null;
|
|
194
|
-
// Init methods.
|
|
195
|
-
this.restoreFromStorage();
|
|
196
|
-
}
|
|
197
|
-
get accessToken() {
|
|
198
|
-
return this.isTokenValid(this._accessTokenPayload)
|
|
199
|
-
? this._accessTokenString
|
|
200
|
-
: null;
|
|
201
|
-
}
|
|
202
|
-
get refreshToken() {
|
|
203
|
-
return this.isTokenValid(this.refreshTokenPayload)
|
|
204
|
-
? this._refreshTokenString
|
|
205
|
-
: null;
|
|
206
|
-
}
|
|
207
|
-
get accessTokenPayload() {
|
|
208
|
-
return this._accessTokenPayload ?? null;
|
|
209
|
-
}
|
|
210
|
-
get refreshTokenPayload() {
|
|
211
|
-
return this._refreshTokenPayload ?? null;
|
|
212
|
-
}
|
|
213
|
-
authenticated() {
|
|
214
|
-
return this.isTokenValid(this._accessTokenPayload) || this.isTokenValid(this._refreshTokenPayload);
|
|
215
|
-
}
|
|
216
|
-
setTokens(accessToken, refreshToken) {
|
|
217
|
-
this.setAccessToken(accessToken);
|
|
218
|
-
this.setRefreshToken(refreshToken);
|
|
219
|
-
this.syncTokensInStorage();
|
|
220
|
-
}
|
|
221
|
-
setUser(user) {
|
|
222
|
-
this._user$.next(user ?? null);
|
|
223
|
-
this.syncUserInStorage();
|
|
224
|
-
}
|
|
225
|
-
clear() {
|
|
226
|
-
this.setTokens(null, null);
|
|
227
|
-
this.setUser(null);
|
|
228
|
-
}
|
|
229
|
-
restoreFromStorage() {
|
|
230
|
-
if (!this._storage) {
|
|
231
|
-
return;
|
|
232
|
-
}
|
|
233
|
-
// Set the access token.
|
|
234
|
-
const accessToken = this._storage.get(this._accessTokenStorageKey);
|
|
235
|
-
this.setAccessToken(accessToken);
|
|
236
|
-
// Set the refresh token.
|
|
237
|
-
const refreshToken = this._storage.get(this._refreshTokenStorageKey);
|
|
238
|
-
this.setRefreshToken(refreshToken);
|
|
239
|
-
// Set the user if we have any correct token payloads.
|
|
240
|
-
if (this._accessTokenPayload || this._refreshTokenPayload) {
|
|
241
|
-
const user = this._storage.get(this._userStorageKey);
|
|
242
|
-
this._user$.next(user ?? null); // Note: just settings here instead of setUser() because of syncing to the storage.
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
syncTokensInStorage() {
|
|
246
|
-
if (!this._storage) {
|
|
247
|
-
return;
|
|
248
|
-
}
|
|
249
|
-
// Set the access token if completely valid.
|
|
250
|
-
if (!!this.accessToken) {
|
|
251
|
-
this._storage.set(this._accessTokenStorageKey, this._accessTokenString, {
|
|
252
|
-
expires: this._accessTokenPayload?.expiresAt
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
else {
|
|
256
|
-
this._storage.remove(this._accessTokenStorageKey);
|
|
257
|
-
}
|
|
258
|
-
// Set the refresh token if completely valid.
|
|
259
|
-
if (!!this.refreshToken) {
|
|
260
|
-
this._storage.set(this._refreshTokenStorageKey, this._refreshTokenString, {
|
|
261
|
-
expires: this._refreshTokenPayload?.expiresAt
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
else {
|
|
265
|
-
this._storage.remove(this._refreshTokenStorageKey);
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
syncUserInStorage() {
|
|
269
|
-
if (!this._storage) {
|
|
270
|
-
return;
|
|
271
|
-
}
|
|
272
|
-
const user = this._user$.getValue();
|
|
273
|
-
if (!user) {
|
|
274
|
-
return this._storage.remove(this._userStorageKey);
|
|
275
|
-
}
|
|
276
|
-
const date = new Date();
|
|
277
|
-
date.setFullYear(date.getFullYear() + 1);
|
|
278
|
-
this._storage.set(this._userStorageKey, user, {
|
|
279
|
-
expires: new Date(date.getTime())
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
setAccessToken(value) {
|
|
283
|
-
this._accessTokenString = value ?? null;
|
|
284
|
-
this._accessTokenPayload = this._jwt.decode(this._accessTokenString);
|
|
285
|
-
}
|
|
286
|
-
setRefreshToken(value) {
|
|
287
|
-
this._refreshTokenString = value ?? null;
|
|
288
|
-
this._refreshTokenPayload = this._jwt.decode(this._refreshTokenString);
|
|
289
|
-
}
|
|
164
|
+
class AuthSession {
|
|
165
|
+
constructor(options) {
|
|
166
|
+
// Readonly data.
|
|
167
|
+
this._jwt = new JwtHelper();
|
|
168
|
+
// Token strings.
|
|
169
|
+
this._accessTokenString = null;
|
|
170
|
+
this._refreshTokenString = null;
|
|
171
|
+
// Token payloads.
|
|
172
|
+
this._accessTokenPayload = null;
|
|
173
|
+
this._refreshTokenPayload = null;
|
|
174
|
+
// Private user data.
|
|
175
|
+
this._user$ = new BehaviorSubject(null);
|
|
176
|
+
// Public user data.
|
|
177
|
+
this.user = this._user$.pipe(shareReplay(1));
|
|
178
|
+
this.generateKey = (applicationId, key) => {
|
|
179
|
+
return [applicationId, key].join('_');
|
|
180
|
+
};
|
|
181
|
+
this.isTokenValid = (token) => {
|
|
182
|
+
if (!token) {
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
return token?.expiresAt?.getTime() > Date.now();
|
|
186
|
+
};
|
|
187
|
+
const applicationId = options?.id ?? 'ng';
|
|
188
|
+
// Setting up the readonly storage keys.
|
|
189
|
+
this._accessTokenStorageKey = this.generateKey(applicationId, 'au_act');
|
|
190
|
+
this._refreshTokenStorageKey = this.generateKey(applicationId, 'au_rft');
|
|
191
|
+
this._userStorageKey = this.generateKey(applicationId, 'au_usr');
|
|
192
|
+
// Setting up the storage.
|
|
193
|
+
this._storage = options?.storage ?? null;
|
|
194
|
+
// Init methods.
|
|
195
|
+
this.restoreFromStorage();
|
|
196
|
+
}
|
|
197
|
+
get accessToken() {
|
|
198
|
+
return this.isTokenValid(this._accessTokenPayload)
|
|
199
|
+
? this._accessTokenString
|
|
200
|
+
: null;
|
|
201
|
+
}
|
|
202
|
+
get refreshToken() {
|
|
203
|
+
return this.isTokenValid(this.refreshTokenPayload)
|
|
204
|
+
? this._refreshTokenString
|
|
205
|
+
: null;
|
|
206
|
+
}
|
|
207
|
+
get accessTokenPayload() {
|
|
208
|
+
return this._accessTokenPayload ?? null;
|
|
209
|
+
}
|
|
210
|
+
get refreshTokenPayload() {
|
|
211
|
+
return this._refreshTokenPayload ?? null;
|
|
212
|
+
}
|
|
213
|
+
authenticated() {
|
|
214
|
+
return this.isTokenValid(this._accessTokenPayload) || this.isTokenValid(this._refreshTokenPayload);
|
|
215
|
+
}
|
|
216
|
+
setTokens(accessToken, refreshToken) {
|
|
217
|
+
this.setAccessToken(accessToken);
|
|
218
|
+
this.setRefreshToken(refreshToken);
|
|
219
|
+
this.syncTokensInStorage();
|
|
220
|
+
}
|
|
221
|
+
setUser(user) {
|
|
222
|
+
this._user$.next(user ?? null);
|
|
223
|
+
this.syncUserInStorage();
|
|
224
|
+
}
|
|
225
|
+
clear() {
|
|
226
|
+
this.setTokens(null, null);
|
|
227
|
+
this.setUser(null);
|
|
228
|
+
}
|
|
229
|
+
restoreFromStorage() {
|
|
230
|
+
if (!this._storage) {
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
// Set the access token.
|
|
234
|
+
const accessToken = this._storage.get(this._accessTokenStorageKey);
|
|
235
|
+
this.setAccessToken(accessToken);
|
|
236
|
+
// Set the refresh token.
|
|
237
|
+
const refreshToken = this._storage.get(this._refreshTokenStorageKey);
|
|
238
|
+
this.setRefreshToken(refreshToken);
|
|
239
|
+
// Set the user if we have any correct token payloads.
|
|
240
|
+
if (this._accessTokenPayload || this._refreshTokenPayload) {
|
|
241
|
+
const user = this._storage.get(this._userStorageKey);
|
|
242
|
+
this._user$.next(user ?? null); // Note: just settings here instead of setUser() because of syncing to the storage.
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
syncTokensInStorage() {
|
|
246
|
+
if (!this._storage) {
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
// Set the access token if completely valid.
|
|
250
|
+
if (!!this.accessToken) {
|
|
251
|
+
this._storage.set(this._accessTokenStorageKey, this._accessTokenString, {
|
|
252
|
+
expires: this._accessTokenPayload?.expiresAt
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
this._storage.remove(this._accessTokenStorageKey);
|
|
257
|
+
}
|
|
258
|
+
// Set the refresh token if completely valid.
|
|
259
|
+
if (!!this.refreshToken) {
|
|
260
|
+
this._storage.set(this._refreshTokenStorageKey, this._refreshTokenString, {
|
|
261
|
+
expires: this._refreshTokenPayload?.expiresAt
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
this._storage.remove(this._refreshTokenStorageKey);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
syncUserInStorage() {
|
|
269
|
+
if (!this._storage) {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
const user = this._user$.getValue();
|
|
273
|
+
if (!user) {
|
|
274
|
+
return this._storage.remove(this._userStorageKey);
|
|
275
|
+
}
|
|
276
|
+
const date = new Date();
|
|
277
|
+
date.setFullYear(date.getFullYear() + 1);
|
|
278
|
+
this._storage.set(this._userStorageKey, user, {
|
|
279
|
+
expires: new Date(date.getTime())
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
setAccessToken(value) {
|
|
283
|
+
this._accessTokenString = value ?? null;
|
|
284
|
+
this._accessTokenPayload = this._jwt.decode(this._accessTokenString);
|
|
285
|
+
}
|
|
286
|
+
setRefreshToken(value) {
|
|
287
|
+
this._refreshTokenString = value ?? null;
|
|
288
|
+
this._refreshTokenPayload = this._jwt.decode(this._refreshTokenString);
|
|
289
|
+
}
|
|
290
290
|
}
|
|
291
291
|
|
|
292
|
-
class Auth {
|
|
293
|
-
constructor(_storage, _mapper, _injector, _platform, _httpClient, _config, _state, _httpConfig) {
|
|
294
|
-
this._storage = _storage;
|
|
295
|
-
this._mapper = _mapper;
|
|
296
|
-
this._injector = _injector;
|
|
297
|
-
this._platform = _platform;
|
|
298
|
-
this._httpClient = _httpClient;
|
|
299
|
-
this._config = _config;
|
|
300
|
-
this._state = _state;
|
|
301
|
-
this._httpConfig = _httpConfig;
|
|
302
|
-
// Readonly data.
|
|
303
|
-
this._authStateKey = makeStateKey(`bbAuthStateKey`);
|
|
304
|
-
this._httpAlias = this._httpConfig?.defaultAlias ?? null;
|
|
305
|
-
this._refreshHandler = null;
|
|
306
|
-
//
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
//
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
return
|
|
328
|
-
}
|
|
329
|
-
//
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
this.
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
//
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
if
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
const
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
this.
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
//
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
//
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
//
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
//
|
|
426
|
-
const
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
}
|
|
440
|
-
async
|
|
441
|
-
const url = this.getUrl('auth/reset
|
|
442
|
-
const observable$ = this._httpClient.post(url, { ...extraParams,
|
|
443
|
-
return firstValueFrom(observable$);
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
const
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
// We
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
//
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
//
|
|
526
|
-
this.
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
292
|
+
class Auth {
|
|
293
|
+
constructor(_storage, _mapper, _injector, _platform, _httpClient, _config, _state, _httpConfig) {
|
|
294
|
+
this._storage = _storage;
|
|
295
|
+
this._mapper = _mapper;
|
|
296
|
+
this._injector = _injector;
|
|
297
|
+
this._platform = _platform;
|
|
298
|
+
this._httpClient = _httpClient;
|
|
299
|
+
this._config = _config;
|
|
300
|
+
this._state = _state;
|
|
301
|
+
this._httpConfig = _httpConfig;
|
|
302
|
+
// Readonly data.
|
|
303
|
+
this._authStateKey = makeStateKey(`bbAuthStateKey`);
|
|
304
|
+
this._httpAlias = this._httpConfig?.defaultAlias ?? null;
|
|
305
|
+
this._refreshHandler = null;
|
|
306
|
+
// We select a storage strategy based on the server/browser.
|
|
307
|
+
// Only cookies CAN work on the server.
|
|
308
|
+
const storageStrategy = this._platform.isBrowser
|
|
309
|
+
? this._storage.select(["cookie" /* Cookie */, "local" /* Local */])
|
|
310
|
+
: this._storage.cookie;
|
|
311
|
+
// Starting the new session.
|
|
312
|
+
this.session = new AuthSession({
|
|
313
|
+
id: this._config?.applicationId,
|
|
314
|
+
storage: storageStrategy
|
|
315
|
+
});
|
|
316
|
+
this.user = this.session.user;
|
|
317
|
+
}
|
|
318
|
+
initialize() {
|
|
319
|
+
return async () => {
|
|
320
|
+
// Check if the app should bootstrap the authentication.
|
|
321
|
+
const shouldBootstrap = this._config?.bootstrap ?? true;
|
|
322
|
+
if (!shouldBootstrap) {
|
|
323
|
+
return this.handleAutoRefreshing();
|
|
324
|
+
}
|
|
325
|
+
// Only retrieve from the server when we are actually authenticated.
|
|
326
|
+
if (!this.session.authenticated()) {
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
// Get the key from the server state.
|
|
330
|
+
if (this._state && this._state?.hasKey(this._authStateKey)) {
|
|
331
|
+
const user = this._state?.get(this._authStateKey, null) ?? null;
|
|
332
|
+
return this.session.setUser(user);
|
|
333
|
+
}
|
|
334
|
+
// Try to fetch the user from the server.
|
|
335
|
+
const user$ = this.me();
|
|
336
|
+
const user = await firstValueFrom(user$, { defaultValue: null });
|
|
337
|
+
// Set the state if exists.
|
|
338
|
+
if (this._state) {
|
|
339
|
+
this._state?.set(this._authStateKey, user ?? null);
|
|
340
|
+
}
|
|
341
|
+
// Save the user in the storage and handle auto refreshing.
|
|
342
|
+
this.session.setUser(user);
|
|
343
|
+
this.handleAutoRefreshing();
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
me() {
|
|
347
|
+
const url = this.getUrl('auth/me');
|
|
348
|
+
return this._httpClient.get(url);
|
|
349
|
+
}
|
|
350
|
+
async signIn(provider, as) {
|
|
351
|
+
const { accessToken, refreshToken, user, ...result } = await provider.authenticate(this._httpClient);
|
|
352
|
+
// Check if the role matches.
|
|
353
|
+
if (as && !as.includes(this._mapper.role(user))) {
|
|
354
|
+
throw new Error('Invalid role.');
|
|
355
|
+
}
|
|
356
|
+
// Validate if the provider is one of the available
|
|
357
|
+
// providers then return the user object and the provider.
|
|
358
|
+
const apiProvider = result?.provider ?? null;
|
|
359
|
+
const apiVerifyToken = result?.verifyToken ?? null;
|
|
360
|
+
const availableProviders = ['email', 'sms', 'totp'];
|
|
361
|
+
if (availableProviders.includes(apiProvider)) {
|
|
362
|
+
return { user, provider: apiProvider, verifyToken: apiVerifyToken };
|
|
363
|
+
}
|
|
364
|
+
// Set the tokens in storage.
|
|
365
|
+
this.setTokens(accessToken, refreshToken);
|
|
366
|
+
// Set the user in storage.
|
|
367
|
+
this.session.setUser(user);
|
|
368
|
+
// Return the user.
|
|
369
|
+
return { user };
|
|
370
|
+
}
|
|
371
|
+
async signInWithEmail(email, password, as) {
|
|
372
|
+
const url = this.getUrl('auth/login');
|
|
373
|
+
return this.signIn(new AuthEmailProvider(email, password, url), as);
|
|
374
|
+
}
|
|
375
|
+
async signInWithVerifyCode(code, verifyToken) {
|
|
376
|
+
const url = this.getUrl('auth/verify');
|
|
377
|
+
return this.signIn(new AuthVerifyProvider(code, verifyToken, url));
|
|
378
|
+
}
|
|
379
|
+
async resendVerifyCode(verifyToken) {
|
|
380
|
+
const url = this.getUrl('auth/resend');
|
|
381
|
+
const result$ = this._httpClient.post(url, {
|
|
382
|
+
verify_token: verifyToken
|
|
383
|
+
});
|
|
384
|
+
return firstValueFrom(result$);
|
|
385
|
+
}
|
|
386
|
+
async register(data, options) {
|
|
387
|
+
// Execute API call.
|
|
388
|
+
const url = this.getUrl('auth/register');
|
|
389
|
+
const result$ = this._httpClient.post(url, data, options);
|
|
390
|
+
const result = await firstValueFrom(result$);
|
|
391
|
+
// Map to the correct response.
|
|
392
|
+
const { accessToken, refreshToken, user } = this._mapper.toRegister(result);
|
|
393
|
+
// Set the tokens in storage.
|
|
394
|
+
this.setTokens(accessToken, refreshToken);
|
|
395
|
+
// Set the user in storage.
|
|
396
|
+
this.session.setUser(user);
|
|
397
|
+
// Return the user.
|
|
398
|
+
return user;
|
|
399
|
+
}
|
|
400
|
+
logout() {
|
|
401
|
+
// If we don't have a refresh token just clear the session.
|
|
402
|
+
// Note: We do this because else we try to invalidate
|
|
403
|
+
// an "undefined" refresh token.
|
|
404
|
+
const refreshToken = this.session.refreshToken;
|
|
405
|
+
if (!refreshToken) {
|
|
406
|
+
return this.session.clear();
|
|
407
|
+
}
|
|
408
|
+
// We do have a refresh token, so try to
|
|
409
|
+
// invalidate it in the backend.
|
|
410
|
+
try {
|
|
411
|
+
const url = this.getUrl('auth/logout');
|
|
412
|
+
const observable$ = this._httpClient.get(url, {
|
|
413
|
+
headers: { Authorization: refreshToken }
|
|
414
|
+
});
|
|
415
|
+
firstValueFrom(observable$).then(_ => _);
|
|
416
|
+
}
|
|
417
|
+
catch {
|
|
418
|
+
// Do nothing because the tokens will be deleted anyways from the session.
|
|
419
|
+
}
|
|
420
|
+
// Delete the tokens from the session.
|
|
421
|
+
return this.session.clear();
|
|
422
|
+
}
|
|
423
|
+
refresh() {
|
|
424
|
+
// If the refresh token does
|
|
425
|
+
// not exist just return an observable of null.
|
|
426
|
+
const refreshToken = this.session.refreshToken;
|
|
427
|
+
if (!refreshToken) {
|
|
428
|
+
return of(null);
|
|
429
|
+
}
|
|
430
|
+
// Perform the refresh call.
|
|
431
|
+
const scheme = this._config?.scheme ?? 'Bearer';
|
|
432
|
+
const url = this.getUrl('auth/refresh');
|
|
433
|
+
const context = new HttpContext()
|
|
434
|
+
.set(USE_AUTHORIZATION, false);
|
|
435
|
+
return this._httpClient.get(url, {
|
|
436
|
+
headers: { Authorization: `${scheme} ${refreshToken}` },
|
|
437
|
+
context: context
|
|
438
|
+
}).pipe(map(data => this._mapper.toRefresh(data)), tap(({ accessToken, refreshToken }) => this.setTokens(accessToken, refreshToken)), map(({ accessToken }) => accessToken));
|
|
439
|
+
}
|
|
440
|
+
async requestPassword(email, extraParams = {}) {
|
|
441
|
+
const url = this.getUrl('auth/reset');
|
|
442
|
+
const observable$ = this._httpClient.post(url, { ...extraParams, email });
|
|
443
|
+
return firstValueFrom(observable$);
|
|
444
|
+
}
|
|
445
|
+
async resetPassword(token, newPassword, extraParams = {}) {
|
|
446
|
+
const url = this.getUrl('auth/reset-password');
|
|
447
|
+
const observable$ = this._httpClient.post(url, { ...extraParams, token, password: newPassword });
|
|
448
|
+
return firstValueFrom(observable$);
|
|
449
|
+
}
|
|
450
|
+
guard(type, redirectUrl) {
|
|
451
|
+
let newUrl = null;
|
|
452
|
+
// Get the correct new url.
|
|
453
|
+
switch (type) {
|
|
454
|
+
case 'authenticated':
|
|
455
|
+
newUrl = this._config?.loggedInUrl ?? null;
|
|
456
|
+
break;
|
|
457
|
+
case 'unauthenticated':
|
|
458
|
+
newUrl = this._config?.redirectUrl ?? null;
|
|
459
|
+
break;
|
|
460
|
+
}
|
|
461
|
+
// Append a redirect url if the user is deemed
|
|
462
|
+
// unauthenticated.
|
|
463
|
+
if (type === 'unauthenticated') {
|
|
464
|
+
const setRedirectOnFailedAuth = this._config?.setRedirectOnFailedAuth ?? true;
|
|
465
|
+
if (setRedirectOnFailedAuth && redirectUrl && newUrl) {
|
|
466
|
+
newUrl += `?redirectUrl=${redirectUrl}`;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
// Parse the url if it exists.
|
|
470
|
+
if (this.router && newUrl) {
|
|
471
|
+
return this.router.parseUrl(newUrl);
|
|
472
|
+
}
|
|
473
|
+
// Return false if the user is not allowed.
|
|
474
|
+
return false;
|
|
475
|
+
}
|
|
476
|
+
clearAndRedirect() {
|
|
477
|
+
// 1. Delete the tokens from the session.
|
|
478
|
+
this.session.clear();
|
|
479
|
+
// 2. Compose the route url.
|
|
480
|
+
const redirectUrl = this._config?.redirectUrl ?? null;
|
|
481
|
+
// 3. Route back if the user provided a redirect url.
|
|
482
|
+
if (this.router && redirectUrl) {
|
|
483
|
+
this.router.navigate([redirectUrl]).then(_ => _);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
setTokens(accessToken, refreshToken) {
|
|
487
|
+
// Set the tokens in our session.
|
|
488
|
+
this.session.setTokens(accessToken, refreshToken);
|
|
489
|
+
// We need to update the auto refresh of the refresh token.
|
|
490
|
+
this.handleAutoRefreshing();
|
|
491
|
+
}
|
|
492
|
+
handleAutoRefreshing() {
|
|
493
|
+
const shouldAutoRefresh = this._config?.autoRefresh ?? false;
|
|
494
|
+
if (!shouldAutoRefresh) {
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
const expiresAt = this.session.refreshTokenPayload?.expiresAt ?? null;
|
|
498
|
+
if (expiresAt === null || !this._platform.isBrowser) {
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
501
|
+
const differenceInMilliseconds = expiresAt.getTime() - Date.now();
|
|
502
|
+
const offsetInMilliseconds = 10000; // 10 seconds.
|
|
503
|
+
// We want to start the refresh 10 seconds before it expires.
|
|
504
|
+
const actualTiming = differenceInMilliseconds - offsetInMilliseconds;
|
|
505
|
+
if (actualTiming <= 0) {
|
|
506
|
+
return;
|
|
507
|
+
}
|
|
508
|
+
// We need to cap the timings because if
|
|
509
|
+
// we get large numbers it might cause unwanted results.
|
|
510
|
+
const maxTiming = 1000 * 60 * 60 * 24; // 24 hours.
|
|
511
|
+
const cappedTiming = Math.max(1, Math.min(actualTiming, maxTiming));
|
|
512
|
+
try {
|
|
513
|
+
if (this._refreshHandler !== null) {
|
|
514
|
+
clearTimeout?.(this._refreshHandler);
|
|
515
|
+
this._refreshHandler = null;
|
|
516
|
+
}
|
|
517
|
+
this._refreshHandler = setTimeout?.(() => this.autoRefresh(), cappedTiming);
|
|
518
|
+
}
|
|
519
|
+
catch {
|
|
520
|
+
// Just ignore it.
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
async autoRefresh() {
|
|
524
|
+
try {
|
|
525
|
+
// We just need to wait for it to refresh.
|
|
526
|
+
const refresh$ = this.refresh();
|
|
527
|
+
await firstValueFrom(refresh$);
|
|
528
|
+
}
|
|
529
|
+
catch {
|
|
530
|
+
// Something went wrong refreshing, we need to clear.
|
|
531
|
+
this.clearAndRedirect();
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
get router() {
|
|
535
|
+
return this._injector.get(Router);
|
|
536
|
+
}
|
|
537
|
+
getUrl(endpoint) {
|
|
538
|
+
return [this._httpAlias, endpoint]
|
|
539
|
+
.filter(item => !!item)
|
|
540
|
+
.join('/');
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
Auth.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: Auth, deps: [{ token: i1.Storage }, { token: AuthMapper }, { token: i0.Injector }, { token: i3.Platform }, { token: i4.HttpClient }, { token: AuthConfig, optional: true }, { token: i6.TransferState, optional: true }, { token: i7.HttpConfig, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
544
|
+
Auth.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: Auth });
|
|
545
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: Auth, decorators: [{
|
|
546
|
+
type: Injectable
|
|
547
|
+
}], ctorParameters: function () { return [{ type: i1.Storage }, { type: AuthMapper }, { type: i0.Injector }, { type: i3.Platform }, { type: i4.HttpClient }, { type: AuthConfig, decorators: [{
|
|
548
|
+
type: Optional
|
|
549
|
+
}] }, { type: i6.TransferState, decorators: [{
|
|
550
|
+
type: Optional
|
|
551
|
+
}] }, { type: i7.HttpConfig, decorators: [{
|
|
552
|
+
type: Optional
|
|
548
553
|
}] }]; } });
|
|
549
554
|
|
|
550
|
-
class BbAuthenticated {
|
|
551
|
-
constructor(_auth, _template, _viewContainerRef) {
|
|
552
|
-
this._auth = _auth;
|
|
553
|
-
this._template = _template;
|
|
554
|
-
this._viewContainerRef = _viewContainerRef;
|
|
555
|
-
}
|
|
556
|
-
ngOnInit() {
|
|
557
|
-
this._subscription = this._auth.user.pipe(map(user => !!user), distinctUntilChanged()).subscribe(isAuthenticated => {
|
|
558
|
-
if (!isAuthenticated) {
|
|
559
|
-
return this._viewContainerRef.clear();
|
|
560
|
-
}
|
|
561
|
-
this._viewContainerRef.createEmbeddedView(this._template);
|
|
562
|
-
});
|
|
563
|
-
}
|
|
564
|
-
ngOnDestroy() {
|
|
565
|
-
this._subscription?.unsubscribe();
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
BbAuthenticated.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.
|
|
569
|
-
BbAuthenticated.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.
|
|
570
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.
|
|
571
|
-
type: Directive,
|
|
572
|
-
args: [{
|
|
573
|
-
selector: '[bbAuthenticated]'
|
|
574
|
-
}]
|
|
555
|
+
class BbAuthenticated {
|
|
556
|
+
constructor(_auth, _template, _viewContainerRef) {
|
|
557
|
+
this._auth = _auth;
|
|
558
|
+
this._template = _template;
|
|
559
|
+
this._viewContainerRef = _viewContainerRef;
|
|
560
|
+
}
|
|
561
|
+
ngOnInit() {
|
|
562
|
+
this._subscription = this._auth.user.pipe(map(user => !!user), distinctUntilChanged()).subscribe(isAuthenticated => {
|
|
563
|
+
if (!isAuthenticated) {
|
|
564
|
+
return this._viewContainerRef.clear();
|
|
565
|
+
}
|
|
566
|
+
this._viewContainerRef.createEmbeddedView(this._template);
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
ngOnDestroy() {
|
|
570
|
+
this._subscription?.unsubscribe();
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
BbAuthenticated.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: BbAuthenticated, deps: [{ token: Auth }, { token: i0.TemplateRef }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
574
|
+
BbAuthenticated.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.6", type: BbAuthenticated, selector: "[bbAuthenticated]", ngImport: i0 });
|
|
575
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: BbAuthenticated, decorators: [{
|
|
576
|
+
type: Directive,
|
|
577
|
+
args: [{
|
|
578
|
+
selector: '[bbAuthenticated]'
|
|
579
|
+
}]
|
|
575
580
|
}], ctorParameters: function () { return [{ type: Auth }, { type: i0.TemplateRef }, { type: i0.ViewContainerRef }]; } });
|
|
576
581
|
|
|
577
|
-
class BbRole {
|
|
578
|
-
constructor(_auth, _template, _viewContainerRef) {
|
|
579
|
-
this._auth = _auth;
|
|
580
|
-
this._template = _template;
|
|
581
|
-
this._viewContainerRef = _viewContainerRef;
|
|
582
|
-
this.getAllowedRoles = (value) => {
|
|
583
|
-
return Array.isArray(value) ? value : [value];
|
|
584
|
-
};
|
|
585
|
-
}
|
|
586
|
-
ngOnInit() {
|
|
587
|
-
this._subscription = this._auth.user.pipe(map(user => user?.role ?? null), distinctUntilChanged()).subscribe(role => {
|
|
588
|
-
const allowedRoles = this.getAllowedRoles(this.bbRole);
|
|
589
|
-
if (!allowedRoles.includes(role)) {
|
|
590
|
-
return this._viewContainerRef.clear();
|
|
591
|
-
}
|
|
592
|
-
this._viewContainerRef.createEmbeddedView(this._template);
|
|
593
|
-
});
|
|
594
|
-
}
|
|
595
|
-
ngOnDestroy() {
|
|
596
|
-
this._subscription?.unsubscribe();
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
BbRole.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.
|
|
600
|
-
BbRole.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.
|
|
601
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.
|
|
602
|
-
type: Directive,
|
|
603
|
-
args: [{
|
|
604
|
-
selector: '[bbRole]'
|
|
605
|
-
}]
|
|
606
|
-
}], ctorParameters: function () { return [{ type: Auth }, { type: i0.TemplateRef }, { type: i0.ViewContainerRef }]; }, propDecorators: { bbRole: [{
|
|
607
|
-
type: Input
|
|
582
|
+
class BbRole {
|
|
583
|
+
constructor(_auth, _template, _viewContainerRef) {
|
|
584
|
+
this._auth = _auth;
|
|
585
|
+
this._template = _template;
|
|
586
|
+
this._viewContainerRef = _viewContainerRef;
|
|
587
|
+
this.getAllowedRoles = (value) => {
|
|
588
|
+
return Array.isArray(value) ? value : [value];
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
ngOnInit() {
|
|
592
|
+
this._subscription = this._auth.user.pipe(map(user => user?.role ?? null), distinctUntilChanged()).subscribe(role => {
|
|
593
|
+
const allowedRoles = this.getAllowedRoles(this.bbRole);
|
|
594
|
+
if (!allowedRoles.includes(role)) {
|
|
595
|
+
return this._viewContainerRef.clear();
|
|
596
|
+
}
|
|
597
|
+
this._viewContainerRef.createEmbeddedView(this._template);
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
ngOnDestroy() {
|
|
601
|
+
this._subscription?.unsubscribe();
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
BbRole.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: BbRole, deps: [{ token: Auth }, { token: i0.TemplateRef }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
605
|
+
BbRole.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.6", type: BbRole, selector: "[bbRole]", inputs: { bbRole: "bbRole" }, ngImport: i0 });
|
|
606
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: BbRole, decorators: [{
|
|
607
|
+
type: Directive,
|
|
608
|
+
args: [{
|
|
609
|
+
selector: '[bbRole]'
|
|
610
|
+
}]
|
|
611
|
+
}], ctorParameters: function () { return [{ type: Auth }, { type: i0.TemplateRef }, { type: i0.ViewContainerRef }]; }, propDecorators: { bbRole: [{
|
|
612
|
+
type: Input
|
|
608
613
|
}] } });
|
|
609
614
|
|
|
610
|
-
class Permissions {
|
|
611
|
-
constructor(_auth, _config) {
|
|
612
|
-
this._auth = _auth;
|
|
613
|
-
this._config = _config;
|
|
614
|
-
// Data.
|
|
615
|
-
this._permissions = this._config?.permissions ?? {};
|
|
616
|
-
this._role$ = this._auth.user.pipe(map(user => user?.role ?? null), distinctUntilChanged());
|
|
617
|
-
}
|
|
618
|
-
has(value) {
|
|
619
|
-
const requiredPermissions = Array.isArray(value)
|
|
620
|
-
? value
|
|
621
|
-
: [value];
|
|
622
|
-
return this._role$.pipe(map(role => {
|
|
623
|
-
if (role === null || role === undefined) {
|
|
624
|
-
return false;
|
|
625
|
-
}
|
|
626
|
-
for (const requiredPermission of requiredPermissions) {
|
|
627
|
-
const result = this.validatePermission(requiredPermission, role);
|
|
628
|
-
if (!result) {
|
|
629
|
-
return false;
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
|
-
return true;
|
|
633
|
-
}));
|
|
634
|
-
}
|
|
635
|
-
validatePermission(type, role) {
|
|
636
|
-
const permission = this._permissions?.[type] ?? null;
|
|
637
|
-
if (!permission) {
|
|
638
|
-
console?.warn?.(`Permissions: Invalid permission requested "${type}".`);
|
|
639
|
-
return false;
|
|
640
|
-
}
|
|
641
|
-
if (permission?.length <= 0) {
|
|
642
|
-
console?.warn?.(`Permissions: No roles were set, please add some roles to this permission.`);
|
|
643
|
-
return false;
|
|
644
|
-
}
|
|
645
|
-
// If the permission includes a "*" we allow everyone.
|
|
646
|
-
if (permission.includes('*')) {
|
|
647
|
-
return true;
|
|
648
|
-
}
|
|
649
|
-
// Validate the role against the permissions.
|
|
650
|
-
return permission?.includes(role) ?? false;
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
Permissions.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.
|
|
654
|
-
Permissions.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.
|
|
655
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.
|
|
656
|
-
type: Injectable
|
|
657
|
-
}], ctorParameters: function () { return [{ type: Auth }, { type: AuthConfig, decorators: [{
|
|
658
|
-
type: Optional
|
|
615
|
+
class Permissions {
|
|
616
|
+
constructor(_auth, _config) {
|
|
617
|
+
this._auth = _auth;
|
|
618
|
+
this._config = _config;
|
|
619
|
+
// Data.
|
|
620
|
+
this._permissions = this._config?.permissions ?? {};
|
|
621
|
+
this._role$ = this._auth.user.pipe(map(user => user?.role ?? null), distinctUntilChanged());
|
|
622
|
+
}
|
|
623
|
+
has(value) {
|
|
624
|
+
const requiredPermissions = Array.isArray(value)
|
|
625
|
+
? value
|
|
626
|
+
: [value];
|
|
627
|
+
return this._role$.pipe(map(role => {
|
|
628
|
+
if (role === null || role === undefined) {
|
|
629
|
+
return false;
|
|
630
|
+
}
|
|
631
|
+
for (const requiredPermission of requiredPermissions) {
|
|
632
|
+
const result = this.validatePermission(requiredPermission, role);
|
|
633
|
+
if (!result) {
|
|
634
|
+
return false;
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
return true;
|
|
638
|
+
}));
|
|
639
|
+
}
|
|
640
|
+
validatePermission(type, role) {
|
|
641
|
+
const permission = this._permissions?.[type] ?? null;
|
|
642
|
+
if (!permission) {
|
|
643
|
+
console?.warn?.(`Permissions: Invalid permission requested "${type}".`);
|
|
644
|
+
return false;
|
|
645
|
+
}
|
|
646
|
+
if (permission?.length <= 0) {
|
|
647
|
+
console?.warn?.(`Permissions: No roles were set, please add some roles to this permission.`);
|
|
648
|
+
return false;
|
|
649
|
+
}
|
|
650
|
+
// If the permission includes a "*" we allow everyone.
|
|
651
|
+
if (permission.includes('*')) {
|
|
652
|
+
return true;
|
|
653
|
+
}
|
|
654
|
+
// Validate the role against the permissions.
|
|
655
|
+
return permission?.includes(role) ?? false;
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
Permissions.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: Permissions, deps: [{ token: Auth }, { token: AuthConfig, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
659
|
+
Permissions.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: Permissions });
|
|
660
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: Permissions, decorators: [{
|
|
661
|
+
type: Injectable
|
|
662
|
+
}], ctorParameters: function () { return [{ type: Auth }, { type: AuthConfig, decorators: [{
|
|
663
|
+
type: Optional
|
|
659
664
|
}] }]; } });
|
|
660
665
|
|
|
661
|
-
class BbPermission {
|
|
662
|
-
constructor(_permissions, _templateRef, _viewContainerRef) {
|
|
663
|
-
this._permissions = _permissions;
|
|
664
|
-
this._templateRef = _templateRef;
|
|
665
|
-
this._viewContainerRef = _viewContainerRef;
|
|
666
|
-
// Data.
|
|
667
|
-
this._permission$ = new BehaviorSubject([]);
|
|
668
|
-
this._valid = false;
|
|
669
|
-
this._elseTemplateRef = null;
|
|
670
|
-
this._thenViewRef = null;
|
|
671
|
-
this._elseViewRef = null;
|
|
672
|
-
this.getAllowedPermissions = (value) => {
|
|
673
|
-
return Array.isArray(value) ? value : [value];
|
|
674
|
-
};
|
|
675
|
-
this.assertTemplate = (property, templateRef) => {
|
|
676
|
-
const isTemplateRefOrNull = !!(!templateRef || templateRef.createEmbeddedView);
|
|
677
|
-
if (!isTemplateRefOrNull) {
|
|
678
|
-
throw new Error(`${property} must be a TemplateRef.`);
|
|
679
|
-
}
|
|
680
|
-
};
|
|
681
|
-
}
|
|
682
|
-
set bbPermission(value) {
|
|
683
|
-
const permissions = this.getAllowedPermissions(value);
|
|
684
|
-
this._permission$.next(permissions);
|
|
685
|
-
this.updateView();
|
|
686
|
-
}
|
|
687
|
-
set bbPermissionElse(templateRef) {
|
|
688
|
-
this.assertTemplate('bbPermissionElse', templateRef);
|
|
689
|
-
this._elseTemplateRef = templateRef;
|
|
690
|
-
this.updateView();
|
|
691
|
-
}
|
|
692
|
-
ngOnInit() {
|
|
693
|
-
const check$ = this._permission$.pipe(switchMap(permissions => this._permissions.has(permissions)));
|
|
694
|
-
this._subscription = check$.subscribe(valid => {
|
|
695
|
-
this._valid = valid;
|
|
696
|
-
this.updateView();
|
|
697
|
-
});
|
|
698
|
-
}
|
|
699
|
-
ngOnDestroy() {
|
|
700
|
-
this._subscription?.unsubscribe();
|
|
701
|
-
}
|
|
702
|
-
updateView() {
|
|
703
|
-
if (this._valid) {
|
|
704
|
-
if (!this._thenViewRef) {
|
|
705
|
-
this._viewContainerRef.clear();
|
|
706
|
-
this._elseViewRef = null;
|
|
707
|
-
if (this._templateRef) {
|
|
708
|
-
this._thenViewRef = this._viewContainerRef.createEmbeddedView(this._templateRef);
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
}
|
|
712
|
-
else {
|
|
713
|
-
if (!this._elseViewRef) {
|
|
714
|
-
this._viewContainerRef.clear();
|
|
715
|
-
this._thenViewRef = null;
|
|
716
|
-
if (this._elseTemplateRef) {
|
|
717
|
-
this._elseViewRef = this._viewContainerRef.createEmbeddedView(this._elseTemplateRef);
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
}
|
|
722
|
-
}
|
|
723
|
-
BbPermission.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.
|
|
724
|
-
BbPermission.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.
|
|
725
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.
|
|
726
|
-
type: Directive,
|
|
727
|
-
args: [{
|
|
728
|
-
selector: '[bbPermission]'
|
|
729
|
-
}]
|
|
730
|
-
}], ctorParameters: function () { return [{ type: Permissions }, { type: i0.TemplateRef }, { type: i0.ViewContainerRef }]; }, propDecorators: { bbPermission: [{
|
|
731
|
-
type: Input
|
|
732
|
-
}], bbPermissionElse: [{
|
|
733
|
-
type: Input
|
|
666
|
+
class BbPermission {
|
|
667
|
+
constructor(_permissions, _templateRef, _viewContainerRef) {
|
|
668
|
+
this._permissions = _permissions;
|
|
669
|
+
this._templateRef = _templateRef;
|
|
670
|
+
this._viewContainerRef = _viewContainerRef;
|
|
671
|
+
// Data.
|
|
672
|
+
this._permission$ = new BehaviorSubject([]);
|
|
673
|
+
this._valid = false;
|
|
674
|
+
this._elseTemplateRef = null;
|
|
675
|
+
this._thenViewRef = null;
|
|
676
|
+
this._elseViewRef = null;
|
|
677
|
+
this.getAllowedPermissions = (value) => {
|
|
678
|
+
return Array.isArray(value) ? value : [value];
|
|
679
|
+
};
|
|
680
|
+
this.assertTemplate = (property, templateRef) => {
|
|
681
|
+
const isTemplateRefOrNull = !!(!templateRef || templateRef.createEmbeddedView);
|
|
682
|
+
if (!isTemplateRefOrNull) {
|
|
683
|
+
throw new Error(`${property} must be a TemplateRef.`);
|
|
684
|
+
}
|
|
685
|
+
};
|
|
686
|
+
}
|
|
687
|
+
set bbPermission(value) {
|
|
688
|
+
const permissions = this.getAllowedPermissions(value);
|
|
689
|
+
this._permission$.next(permissions);
|
|
690
|
+
this.updateView();
|
|
691
|
+
}
|
|
692
|
+
set bbPermissionElse(templateRef) {
|
|
693
|
+
this.assertTemplate('bbPermissionElse', templateRef);
|
|
694
|
+
this._elseTemplateRef = templateRef;
|
|
695
|
+
this.updateView();
|
|
696
|
+
}
|
|
697
|
+
ngOnInit() {
|
|
698
|
+
const check$ = this._permission$.pipe(switchMap(permissions => this._permissions.has(permissions)));
|
|
699
|
+
this._subscription = check$.subscribe(valid => {
|
|
700
|
+
this._valid = valid;
|
|
701
|
+
this.updateView();
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
ngOnDestroy() {
|
|
705
|
+
this._subscription?.unsubscribe();
|
|
706
|
+
}
|
|
707
|
+
updateView() {
|
|
708
|
+
if (this._valid) {
|
|
709
|
+
if (!this._thenViewRef) {
|
|
710
|
+
this._viewContainerRef.clear();
|
|
711
|
+
this._elseViewRef = null;
|
|
712
|
+
if (this._templateRef) {
|
|
713
|
+
this._thenViewRef = this._viewContainerRef.createEmbeddedView(this._templateRef);
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
else {
|
|
718
|
+
if (!this._elseViewRef) {
|
|
719
|
+
this._viewContainerRef.clear();
|
|
720
|
+
this._thenViewRef = null;
|
|
721
|
+
if (this._elseTemplateRef) {
|
|
722
|
+
this._elseViewRef = this._viewContainerRef.createEmbeddedView(this._elseTemplateRef);
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
BbPermission.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: BbPermission, deps: [{ token: Permissions }, { token: i0.TemplateRef }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
729
|
+
BbPermission.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.6", type: BbPermission, selector: "[bbPermission]", inputs: { bbPermission: "bbPermission", bbPermissionElse: "bbPermissionElse" }, ngImport: i0 });
|
|
730
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: BbPermission, decorators: [{
|
|
731
|
+
type: Directive,
|
|
732
|
+
args: [{
|
|
733
|
+
selector: '[bbPermission]'
|
|
734
|
+
}]
|
|
735
|
+
}], ctorParameters: function () { return [{ type: Permissions }, { type: i0.TemplateRef }, { type: i0.ViewContainerRef }]; }, propDecorators: { bbPermission: [{
|
|
736
|
+
type: Input
|
|
737
|
+
}], bbPermissionElse: [{
|
|
738
|
+
type: Input
|
|
734
739
|
}] } });
|
|
735
740
|
|
|
736
|
-
class BbAnonymousGuard {
|
|
737
|
-
constructor(_auth) {
|
|
738
|
-
this._auth = _auth;
|
|
739
|
-
}
|
|
740
|
-
async canActivate(_, state) {
|
|
741
|
-
// Check if the user is authenticated.
|
|
742
|
-
const isAuthenticated$ = await this._auth.user.pipe(map(user => !!user));
|
|
743
|
-
// If the user is not authenticated it can
|
|
744
|
-
// access the anonymous page.
|
|
745
|
-
const isAuthenticated = await firstValueFrom(isAuthenticated$, { defaultValue: null });
|
|
746
|
-
if (!isAuthenticated) {
|
|
747
|
-
return true;
|
|
748
|
-
}
|
|
749
|
-
// Return the user back to the authenticated page.
|
|
750
|
-
return this._auth.guard('authenticated', state.url);
|
|
751
|
-
}
|
|
752
|
-
canActivateChild(childRoute, state) {
|
|
753
|
-
return this.canActivate(childRoute, state);
|
|
754
|
-
}
|
|
755
|
-
}
|
|
756
|
-
BbAnonymousGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.
|
|
757
|
-
BbAnonymousGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.
|
|
758
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.
|
|
759
|
-
type: Injectable,
|
|
760
|
-
args: [{
|
|
761
|
-
providedIn: 'root'
|
|
762
|
-
}]
|
|
741
|
+
class BbAnonymousGuard {
|
|
742
|
+
constructor(_auth) {
|
|
743
|
+
this._auth = _auth;
|
|
744
|
+
}
|
|
745
|
+
async canActivate(_, state) {
|
|
746
|
+
// Check if the user is authenticated.
|
|
747
|
+
const isAuthenticated$ = await this._auth.user.pipe(map(user => !!user));
|
|
748
|
+
// If the user is not authenticated it can
|
|
749
|
+
// access the anonymous page.
|
|
750
|
+
const isAuthenticated = await firstValueFrom(isAuthenticated$, { defaultValue: null });
|
|
751
|
+
if (!isAuthenticated) {
|
|
752
|
+
return true;
|
|
753
|
+
}
|
|
754
|
+
// Return the user back to the authenticated page.
|
|
755
|
+
return this._auth.guard('authenticated', state.url);
|
|
756
|
+
}
|
|
757
|
+
canActivateChild(childRoute, state) {
|
|
758
|
+
return this.canActivate(childRoute, state);
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
BbAnonymousGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: BbAnonymousGuard, deps: [{ token: Auth }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
762
|
+
BbAnonymousGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: BbAnonymousGuard, providedIn: 'root' });
|
|
763
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: BbAnonymousGuard, decorators: [{
|
|
764
|
+
type: Injectable,
|
|
765
|
+
args: [{
|
|
766
|
+
providedIn: 'root'
|
|
767
|
+
}]
|
|
763
768
|
}], ctorParameters: function () { return [{ type: Auth }]; } });
|
|
764
769
|
|
|
765
|
-
class BbAuthenticatedGuard {
|
|
766
|
-
constructor(_auth) {
|
|
767
|
-
this._auth = _auth;
|
|
768
|
-
}
|
|
769
|
-
async canActivate(_, state) {
|
|
770
|
-
// Check if the user is authenticated.
|
|
771
|
-
const isAuthenticated$ = await this._auth.user.pipe(map(user => !!user));
|
|
772
|
-
// If the user is authenticated it can
|
|
773
|
-
// access the authenticated page.
|
|
774
|
-
const isAuthenticated = await firstValueFrom(isAuthenticated$, { defaultValue: null });
|
|
775
|
-
if (isAuthenticated) {
|
|
776
|
-
return true;
|
|
777
|
-
}
|
|
778
|
-
// The user is not authorized to see that
|
|
779
|
-
// page so un-authorize him.
|
|
780
|
-
return this._auth.guard('unauthenticated', state.url);
|
|
781
|
-
}
|
|
782
|
-
canActivateChild(childRoute, state) {
|
|
783
|
-
return this.canActivate(childRoute, state);
|
|
784
|
-
}
|
|
785
|
-
}
|
|
786
|
-
BbAuthenticatedGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.
|
|
787
|
-
BbAuthenticatedGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.
|
|
788
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.
|
|
789
|
-
type: Injectable,
|
|
790
|
-
args: [{
|
|
791
|
-
providedIn: 'root'
|
|
792
|
-
}]
|
|
770
|
+
class BbAuthenticatedGuard {
|
|
771
|
+
constructor(_auth) {
|
|
772
|
+
this._auth = _auth;
|
|
773
|
+
}
|
|
774
|
+
async canActivate(_, state) {
|
|
775
|
+
// Check if the user is authenticated.
|
|
776
|
+
const isAuthenticated$ = await this._auth.user.pipe(map(user => !!user));
|
|
777
|
+
// If the user is authenticated it can
|
|
778
|
+
// access the authenticated page.
|
|
779
|
+
const isAuthenticated = await firstValueFrom(isAuthenticated$, { defaultValue: null });
|
|
780
|
+
if (isAuthenticated) {
|
|
781
|
+
return true;
|
|
782
|
+
}
|
|
783
|
+
// The user is not authorized to see that
|
|
784
|
+
// page so un-authorize him.
|
|
785
|
+
return this._auth.guard('unauthenticated', state.url);
|
|
786
|
+
}
|
|
787
|
+
canActivateChild(childRoute, state) {
|
|
788
|
+
return this.canActivate(childRoute, state);
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
BbAuthenticatedGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: BbAuthenticatedGuard, deps: [{ token: Auth }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
792
|
+
BbAuthenticatedGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: BbAuthenticatedGuard, providedIn: 'root' });
|
|
793
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: BbAuthenticatedGuard, decorators: [{
|
|
794
|
+
type: Injectable,
|
|
795
|
+
args: [{
|
|
796
|
+
providedIn: 'root'
|
|
797
|
+
}]
|
|
793
798
|
}], ctorParameters: function () { return [{ type: Auth }]; } });
|
|
794
799
|
|
|
795
|
-
class AuthInterceptor {
|
|
796
|
-
constructor(_auth, _config) {
|
|
797
|
-
this._auth = _auth;
|
|
798
|
-
this._config = _config;
|
|
799
|
-
// Readonly data.
|
|
800
|
-
this._authHeaderString = 'Authorization';
|
|
801
|
-
// Data.
|
|
802
|
-
this.isRefreshing = false;
|
|
803
|
-
this.refreshingAccessToken$ = new BehaviorSubject(null);
|
|
804
|
-
this.getAccessToken = (request) => {
|
|
805
|
-
// Get the token based on header.
|
|
806
|
-
if (request.headers.has('Authorization')) {
|
|
807
|
-
return request.headers.get('Authorization');
|
|
808
|
-
}
|
|
809
|
-
// Return the default access token.
|
|
810
|
-
return this._auth.session.accessToken;
|
|
811
|
-
};
|
|
812
|
-
this.addAuthorizationHeader = (request, accessToken = null) => {
|
|
813
|
-
// Remove auth header when we do not have
|
|
814
|
-
// an access token.
|
|
815
|
-
if (!accessToken) {
|
|
816
|
-
return request.clone({
|
|
817
|
-
headers: request.headers.delete(this._authHeaderString)
|
|
818
|
-
});
|
|
819
|
-
}
|
|
820
|
-
// Add the auth header to the request.
|
|
821
|
-
return request.clone({
|
|
822
|
-
setHeaders: { [this._authHeaderString]: this.getFullAuthorizationHeader(accessToken) }
|
|
823
|
-
});
|
|
824
|
-
};
|
|
825
|
-
this.getFullAuthorizationHeader = (token) => {
|
|
826
|
-
const authScheme = this._config?.scheme ?? 'Bearer';
|
|
827
|
-
return [authScheme, token].join(' ');
|
|
828
|
-
};
|
|
829
|
-
}
|
|
830
|
-
intercept(request, next) {
|
|
831
|
-
// 1. Check if the user wants to use the authorization for this request.
|
|
832
|
-
if (!request.context.get(USE_AUTHORIZATION)) {
|
|
833
|
-
return next.handle(request);
|
|
834
|
-
}
|
|
835
|
-
// 2. Compose the new request.
|
|
836
|
-
const accessToken = this.getAccessToken(request);
|
|
837
|
-
const newRequest = this.addAuthorizationHeader(request, accessToken);
|
|
838
|
-
// 3. Handle all errors.
|
|
839
|
-
return next.handle(newRequest).pipe(catchError(error => {
|
|
840
|
-
// Handle the HTTP401 error.
|
|
841
|
-
if ((error instanceof HttpErrorResponse || error instanceof HttpError) && error?.status === 401) {
|
|
842
|
-
return this.handle401Error(request, next);
|
|
843
|
-
}
|
|
844
|
-
// Just re-throw the parsed error.
|
|
845
|
-
return throwError(error);
|
|
846
|
-
}));
|
|
847
|
-
}
|
|
848
|
-
handle401Error(request, next) {
|
|
849
|
-
// If already refreshing wait for the refresh token to complete.
|
|
850
|
-
if (this.isRefreshing) {
|
|
851
|
-
return this.refreshingAccessToken$.pipe(filter(accessToken => accessToken !== null), take(1), switchMap(accessToken => next.handle(this.addAuthorizationHeader(request, accessToken))));
|
|
852
|
-
}
|
|
853
|
-
// Set the refreshing to true.
|
|
854
|
-
this.isRefreshing = true;
|
|
855
|
-
this.refreshingAccessToken$.next(null);
|
|
856
|
-
return this._auth.refresh().pipe(switchMap(newAccessToken => {
|
|
857
|
-
if (!newAccessToken) {
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
this.
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
}
|
|
872
|
-
AuthInterceptor.ɵ
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
type: Optional
|
|
800
|
+
class AuthInterceptor {
|
|
801
|
+
constructor(_auth, _config) {
|
|
802
|
+
this._auth = _auth;
|
|
803
|
+
this._config = _config;
|
|
804
|
+
// Readonly data.
|
|
805
|
+
this._authHeaderString = 'Authorization';
|
|
806
|
+
// Data.
|
|
807
|
+
this.isRefreshing = false;
|
|
808
|
+
this.refreshingAccessToken$ = new BehaviorSubject(null);
|
|
809
|
+
this.getAccessToken = (request) => {
|
|
810
|
+
// Get the token based on header.
|
|
811
|
+
if (request.headers.has('Authorization')) {
|
|
812
|
+
return request.headers.get('Authorization');
|
|
813
|
+
}
|
|
814
|
+
// Return the default access token.
|
|
815
|
+
return this._auth.session.accessToken;
|
|
816
|
+
};
|
|
817
|
+
this.addAuthorizationHeader = (request, accessToken = null) => {
|
|
818
|
+
// Remove auth header when we do not have
|
|
819
|
+
// an access token.
|
|
820
|
+
if (!accessToken) {
|
|
821
|
+
return request.clone({
|
|
822
|
+
headers: request.headers.delete(this._authHeaderString)
|
|
823
|
+
});
|
|
824
|
+
}
|
|
825
|
+
// Add the auth header to the request.
|
|
826
|
+
return request.clone({
|
|
827
|
+
setHeaders: { [this._authHeaderString]: this.getFullAuthorizationHeader(accessToken) }
|
|
828
|
+
});
|
|
829
|
+
};
|
|
830
|
+
this.getFullAuthorizationHeader = (token) => {
|
|
831
|
+
const authScheme = this._config?.scheme ?? 'Bearer';
|
|
832
|
+
return [authScheme, token].join(' ');
|
|
833
|
+
};
|
|
834
|
+
}
|
|
835
|
+
intercept(request, next) {
|
|
836
|
+
// 1. Check if the user wants to use the authorization for this request.
|
|
837
|
+
if (!request.context.get(USE_AUTHORIZATION)) {
|
|
838
|
+
return next.handle(request);
|
|
839
|
+
}
|
|
840
|
+
// 2. Compose the new request.
|
|
841
|
+
const accessToken = this.getAccessToken(request);
|
|
842
|
+
const newRequest = this.addAuthorizationHeader(request, accessToken);
|
|
843
|
+
// 3. Handle all errors.
|
|
844
|
+
return next.handle(newRequest).pipe(catchError(error => {
|
|
845
|
+
// Handle the HTTP401 error.
|
|
846
|
+
if ((error instanceof HttpErrorResponse || error instanceof HttpError) && error?.status === 401) {
|
|
847
|
+
return this.handle401Error(request, next);
|
|
848
|
+
}
|
|
849
|
+
// Just re-throw the parsed error.
|
|
850
|
+
return throwError(() => error);
|
|
851
|
+
}));
|
|
852
|
+
}
|
|
853
|
+
handle401Error(request, next) {
|
|
854
|
+
// If already refreshing wait for the refresh token to complete.
|
|
855
|
+
if (this.isRefreshing) {
|
|
856
|
+
return this.refreshingAccessToken$.pipe(filter(accessToken => accessToken !== null), take(1), switchMap(accessToken => next.handle(this.addAuthorizationHeader(request, accessToken))));
|
|
857
|
+
}
|
|
858
|
+
// Set the refreshing to true.
|
|
859
|
+
this.isRefreshing = true;
|
|
860
|
+
this.refreshingAccessToken$.next(null);
|
|
861
|
+
return this._auth.refresh().pipe(switchMap(newAccessToken => {
|
|
862
|
+
if (!newAccessToken) {
|
|
863
|
+
return throwError(() => new Error('No refresh token was available.'));
|
|
864
|
+
}
|
|
865
|
+
this.refreshingAccessToken$.next(newAccessToken);
|
|
866
|
+
return next.handle(this.addAuthorizationHeader(request, newAccessToken));
|
|
867
|
+
}), catchError(() => this.logoutUser()), finalize(() => this.isRefreshing = false));
|
|
868
|
+
}
|
|
869
|
+
logoutUser() {
|
|
870
|
+
// Handle the refresh error.
|
|
871
|
+
this._auth.clearAndRedirect();
|
|
872
|
+
// Return null as data.
|
|
873
|
+
return of(null);
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
AuthInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: AuthInterceptor, deps: [{ token: Auth }, { token: AuthConfig, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
877
|
+
AuthInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: AuthInterceptor });
|
|
878
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: AuthInterceptor, decorators: [{
|
|
879
|
+
type: Injectable
|
|
880
|
+
}], ctorParameters: function () { return [{ type: Auth }, { type: AuthConfig, decorators: [{
|
|
881
|
+
type: Optional
|
|
878
882
|
}] }]; } });
|
|
879
883
|
|
|
880
|
-
const DECLARATIONS_EXPORTS = [
|
|
881
|
-
BbAuthenticated,
|
|
882
|
-
BbRole,
|
|
883
|
-
BbPermission
|
|
884
|
-
];
|
|
885
|
-
class AuthModule {
|
|
886
|
-
static forRoot(config) {
|
|
887
|
-
return {
|
|
888
|
-
ngModule: AuthModule,
|
|
889
|
-
providers: [
|
|
890
|
-
Auth,
|
|
891
|
-
Permissions,
|
|
892
|
-
{ provide: AuthConfig, useValue: config },
|
|
893
|
-
{ provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true },
|
|
894
|
-
{ useFactory: initializeAuth, provide: APP_INITIALIZER, deps: [Auth], multi: true }
|
|
895
|
-
]
|
|
896
|
-
};
|
|
897
|
-
}
|
|
898
|
-
}
|
|
899
|
-
AuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.
|
|
900
|
-
AuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.
|
|
901
|
-
BbRole,
|
|
902
|
-
BbPermission], imports: [HttpClientModule], exports: [BbAuthenticated,
|
|
903
|
-
BbRole,
|
|
904
|
-
BbPermission] });
|
|
905
|
-
AuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.
|
|
906
|
-
{ provide: AuthMapper, useClass: AuthMapper }
|
|
907
|
-
], imports: [[HttpClientModule]] });
|
|
908
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.
|
|
909
|
-
type: NgModule,
|
|
910
|
-
args: [{
|
|
911
|
-
imports: [HttpClientModule],
|
|
912
|
-
declarations: [...DECLARATIONS_EXPORTS],
|
|
913
|
-
exports: [...DECLARATIONS_EXPORTS],
|
|
914
|
-
providers: [
|
|
915
|
-
{ provide: AuthMapper, useClass: AuthMapper }
|
|
916
|
-
]
|
|
917
|
-
}]
|
|
918
|
-
}] });
|
|
919
|
-
function initializeAuth(auth) {
|
|
920
|
-
return auth.initialize();
|
|
884
|
+
const DECLARATIONS_EXPORTS = [
|
|
885
|
+
BbAuthenticated,
|
|
886
|
+
BbRole,
|
|
887
|
+
BbPermission
|
|
888
|
+
];
|
|
889
|
+
class AuthModule {
|
|
890
|
+
static forRoot(config) {
|
|
891
|
+
return {
|
|
892
|
+
ngModule: AuthModule,
|
|
893
|
+
providers: [
|
|
894
|
+
Auth,
|
|
895
|
+
Permissions,
|
|
896
|
+
{ provide: AuthConfig, useValue: config },
|
|
897
|
+
{ provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true },
|
|
898
|
+
{ useFactory: initializeAuth, provide: APP_INITIALIZER, deps: [Auth], multi: true }
|
|
899
|
+
]
|
|
900
|
+
};
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
AuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: AuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
904
|
+
AuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: AuthModule, declarations: [BbAuthenticated,
|
|
905
|
+
BbRole,
|
|
906
|
+
BbPermission], imports: [HttpClientModule], exports: [BbAuthenticated,
|
|
907
|
+
BbRole,
|
|
908
|
+
BbPermission] });
|
|
909
|
+
AuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: AuthModule, providers: [
|
|
910
|
+
{ provide: AuthMapper, useClass: AuthMapper }
|
|
911
|
+
], imports: [[HttpClientModule]] });
|
|
912
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: AuthModule, decorators: [{
|
|
913
|
+
type: NgModule,
|
|
914
|
+
args: [{
|
|
915
|
+
imports: [HttpClientModule],
|
|
916
|
+
declarations: [...DECLARATIONS_EXPORTS],
|
|
917
|
+
exports: [...DECLARATIONS_EXPORTS],
|
|
918
|
+
providers: [
|
|
919
|
+
{ provide: AuthMapper, useClass: AuthMapper }
|
|
920
|
+
]
|
|
921
|
+
}]
|
|
922
|
+
}] });
|
|
923
|
+
function initializeAuth(auth) {
|
|
924
|
+
return auth.initialize();
|
|
921
925
|
}
|
|
922
926
|
|
|
923
|
-
/**
|
|
924
|
-
* Generated bundle index. Do not edit.
|
|
927
|
+
/**
|
|
928
|
+
* Generated bundle index. Do not edit.
|
|
925
929
|
*/
|
|
926
930
|
|
|
927
931
|
export { Auth, AuthConfig, AuthEmailProvider, AuthMapper, AuthModule, AuthSession, AuthVerifyProvider, BbAnonymousGuard, BbAuthenticated, BbAuthenticatedGuard, BbPermission, BbRole, JwtHelper, Permissions, USE_AUTHORIZATION, initializeAuth };
|