@bravobit/bb-foundation 0.15.6 → 0.16.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/auth/lib/auth.interceptor.d.ts +1 -1
- package/auth/lib/auth.service.d.ts +1 -1
- package/auth/package.json +5 -5
- package/collections/lib/collection.d.ts +1 -1
- package/collections/package.json +5 -5
- package/controls/bravobit-bb-foundation-controls.d.ts +5 -0
- package/controls/lib/checkbox/checkbox/checkbox.component.d.ts +47 -0
- package/controls/lib/checkbox/checkbox-group/checkbox-group.component.d.ts +18 -0
- package/controls/lib/checkbox/checkbox.module.d.ts +9 -0
- package/controls/lib/controls.module.d.ts +7 -0
- package/controls/package.json +10 -0
- package/controls/public_api.d.ts +4 -0
- package/dashboard/package.json +5 -5
- package/dialog/package.json +5 -5
- package/elements/package.json +5 -5
- package/{esm2015/auth/bravobit-bb-foundation-auth.js → esm2020/auth/bravobit-bb-foundation-auth.mjs} +0 -0
- package/esm2020/auth/lib/auth.interceptor.mjs +94 -0
- package/{esm2015/auth/lib/auth.module.js → esm2020/auth/lib/auth.module.mjs} +5 -5
- package/esm2020/auth/lib/auth.service.mjs +276 -0
- package/esm2020/auth/lib/auth.session.mjs +131 -0
- package/{esm2015/auth/lib/directives/authenticated.directive.js → esm2020/auth/lib/directives/authenticated.directive.mjs} +5 -6
- package/esm2020/auth/lib/directives/permission.directive.mjs +80 -0
- package/esm2020/auth/lib/directives/role.directive.mjs +37 -0
- package/esm2020/auth/lib/guards/anonymous.guard.mjs +34 -0
- package/esm2020/auth/lib/guards/authenticated.guard.mjs +35 -0
- package/{esm2015/auth/lib/helpers/jwt.helper.js → esm2020/auth/lib/helpers/jwt.helper.mjs} +3 -3
- package/{esm2015/auth/lib/helpers/mapper.helper.js → esm2020/auth/lib/helpers/mapper.helper.mjs} +4 -4
- package/{esm2015/auth/lib/interfaces/config.interface.js → esm2020/auth/lib/interfaces/config.interface.mjs} +0 -0
- package/{esm2015/auth/lib/interfaces/mapper.interface.js → esm2020/auth/lib/interfaces/mapper.interface.mjs} +0 -0
- package/{esm2015/auth/lib/interfaces/provider.interface.js → esm2020/auth/lib/interfaces/provider.interface.mjs} +0 -0
- package/{esm2015/auth/lib/interfaces/token.interface.js → esm2020/auth/lib/interfaces/token.interface.mjs} +0 -0
- package/esm2020/auth/lib/permissions.service.mjs +56 -0
- package/esm2020/auth/lib/providers/email.provider.mjs +25 -0
- package/esm2020/auth/lib/providers/verify.provider.mjs +19 -0
- package/{esm2015/auth/lib/tokens/use-authorization.token.js → esm2020/auth/lib/tokens/use-authorization.token.mjs} +0 -0
- package/{esm2015/auth/public_api.js → esm2020/auth/public_api.mjs} +0 -0
- package/{esm2015/bravobit-bb-foundation.js → esm2020/bravobit-bb-foundation.mjs} +0 -0
- package/{esm2015/collections/bravobit-bb-foundation-collections.js → esm2020/collections/bravobit-bb-foundation-collections.mjs} +0 -0
- package/esm2020/collections/lib/collection.mjs +102 -0
- package/{esm2015/collections/lib/collections.module.js → esm2020/collections/lib/collections.module.mjs} +5 -5
- package/esm2020/collections/lib/components/collections-pager/collections-pager.component.mjs +123 -0
- package/esm2020/collections/lib/components/collections-viewer/collections-viewer.component.mjs +31 -0
- package/{esm2015/collections/lib/components/collections.directive.js → esm2020/collections/lib/components/collections.directive.mjs} +13 -13
- package/{esm2015/collections/lib/interfaces/collection.interface.js → esm2020/collections/lib/interfaces/collection.interface.mjs} +0 -0
- package/esm2020/collections/lib/providers/api-collection.provider.mjs +71 -0
- package/esm2020/collections/lib/providers/collection.provider.mjs +13 -0
- package/{esm2015/collections/lib/providers/local-collection.provider.js → esm2020/collections/lib/providers/local-collection.provider.mjs} +0 -0
- package/{esm2015/collections/public_api.js → esm2020/collections/public_api.mjs} +0 -0
- package/esm2020/controls/bravobit-bb-foundation-controls.mjs +5 -0
- package/esm2020/controls/lib/checkbox/checkbox/checkbox.component.mjs +153 -0
- package/esm2020/controls/lib/checkbox/checkbox-group/checkbox-group.component.mjs +48 -0
- package/esm2020/controls/lib/checkbox/checkbox.module.mjs +19 -0
- package/esm2020/controls/lib/controls.module.mjs +16 -0
- package/esm2020/controls/public_api.mjs +5 -0
- package/{esm2015/dashboard/bravobit-bb-foundation-dashboard.js → esm2020/dashboard/bravobit-bb-foundation-dashboard.mjs} +0 -0
- package/esm2020/dashboard/lib/dashboard/dashboard.component.mjs +56 -0
- package/esm2020/dashboard/lib/dashboard-header/dashboard-header.component.mjs +30 -0
- package/esm2020/dashboard/lib/dashboard-menu/dashboard-menu.component.mjs +31 -0
- package/esm2020/dashboard/lib/dashboard-menu-item/dashboard-menu-item.component.mjs +29 -0
- package/esm2020/dashboard/lib/dashboard-sidebar/dashboard-sidebar.component.mjs +75 -0
- package/esm2020/dashboard/lib/dashboard-sidebar-group/dashboard-sidebar-group.component.mjs +99 -0
- package/esm2020/dashboard/lib/dashboard-sidebar-item/dashboard-sidebar-item.component.mjs +62 -0
- package/{esm2015/dashboard/lib/dashboard.module.js → esm2020/dashboard/lib/dashboard.module.mjs} +5 -5
- package/{esm2015/dashboard/public_api.js → esm2020/dashboard/public_api.mjs} +0 -0
- package/{esm2015/dialog/bravobit-bb-foundation-dialog.js → esm2020/dialog/bravobit-bb-foundation-dialog.mjs} +0 -0
- package/esm2020/dialog/lib/dialog-actions/dialog-actions.component.mjs +12 -0
- package/esm2020/dialog/lib/dialog-confirm/dialog-confirm.component.mjs +37 -0
- package/{esm2015/dialog/lib/dialog-container/dialog-container.component.js → esm2020/dialog/lib/dialog-container/dialog-container.component.mjs} +6 -15
- package/esm2020/dialog/lib/dialog-header/dialog-header.component.mjs +25 -0
- package/esm2020/dialog/lib/dialog-link/dialog-link.component.mjs +11 -0
- package/esm2020/dialog/lib/dialog-modal/dialog-modal.component.mjs +46 -0
- package/esm2020/dialog/lib/dialog-overlay/dialog-overlay.component.mjs +134 -0
- package/{esm2015/dialog/lib/dialog.injector.js → esm2020/dialog/lib/dialog.injector.mjs} +0 -0
- package/{esm2015/dialog/lib/dialog.insertion.js → esm2020/dialog/lib/dialog.insertion.mjs} +4 -4
- package/{esm2015/dialog/lib/dialog.interfaces.js → esm2020/dialog/lib/dialog.interfaces.mjs} +0 -0
- package/{esm2015/dialog/lib/dialog.module.js → esm2020/dialog/lib/dialog.module.mjs} +5 -9
- package/{esm2015/dialog/lib/dialog.ref.js → esm2020/dialog/lib/dialog.ref.mjs} +0 -0
- package/{esm2015/dialog/lib/dialog.service.js → esm2020/dialog/lib/dialog.service.mjs} +5 -5
- package/{esm2015/dialog/public_api.js → esm2020/dialog/public_api.mjs} +0 -0
- package/{esm2015/elements/bravobit-bb-foundation-elements.js → esm2020/elements/bravobit-bb-foundation-elements.mjs} +0 -0
- package/esm2020/elements/lib/avatar/avatar.component.mjs +142 -0
- package/esm2020/elements/lib/button/button.component.mjs +61 -0
- package/esm2020/elements/lib/checkbox/checkbox.component.mjs +73 -0
- package/esm2020/elements/lib/date-picker/date-picker.component.mjs +304 -0
- package/{esm2015/elements/lib/directives/addon.directive.js → esm2020/elements/lib/directives/addon.directive.mjs} +7 -7
- package/esm2020/elements/lib/directives/autosize.directive.mjs +72 -0
- package/{esm2015/elements/lib/directives/focus-trap.directive.js → esm2020/elements/lib/directives/focus-trap.directive.mjs} +4 -4
- package/{esm2015/elements/lib/directives/focus.directive.js → esm2020/elements/lib/directives/focus.directive.mjs} +4 -4
- package/esm2020/elements/lib/directives/form-submit.directive.mjs +50 -0
- package/esm2020/elements/lib/directives/input.directive.mjs +136 -0
- package/{esm2015/elements/lib/directives/template.directive.js → esm2020/elements/lib/directives/template.directive.mjs} +4 -4
- package/esm2020/elements/lib/dropdown/dropdown.component.mjs +100 -0
- package/{esm2015/elements/lib/elements.interfaces.js → esm2020/elements/lib/elements.interfaces.mjs} +0 -0
- package/{esm2015/elements/lib/elements.module.js → esm2020/elements/lib/elements.module.mjs} +5 -5
- package/esm2020/elements/lib/file-picker/file-picker.component.mjs +236 -0
- package/esm2020/elements/lib/form-control/form-control.component.mjs +49 -0
- package/esm2020/elements/lib/form-error/form-error.component.mjs +108 -0
- package/esm2020/elements/lib/form-group/form-group.component.mjs +18 -0
- package/esm2020/elements/lib/icon/icon.component.mjs +102 -0
- package/esm2020/elements/lib/image-picker/image-picker.component.mjs +106 -0
- package/esm2020/elements/lib/pipes/file-image.pipe.mjs +42 -0
- package/{esm2015/elements/lib/pipes/file-size.pipe.js → esm2020/elements/lib/pipes/file-size.pipe.mjs} +4 -4
- package/esm2020/elements/lib/pipes/relative-time.pipe.mjs +94 -0
- package/esm2020/elements/lib/spinner/spinner.component.mjs +25 -0
- package/esm2020/elements/lib/tag/tag.component.mjs +18 -0
- package/{esm2015/elements/public_api.js → esm2020/elements/public_api.mjs} +0 -0
- package/{esm2015/http/bravobit-bb-foundation-http.js → esm2020/http/bravobit-bb-foundation-http.mjs} +0 -0
- package/esm2020/http/lib/classes/http.config.mjs +29 -0
- package/esm2020/http/lib/classes/http.error.mjs +20 -0
- package/{esm2015/http/lib/http.interfaces.js → esm2020/http/lib/http.interfaces.mjs} +0 -0
- package/{esm2015/http/lib/http.module.js → esm2020/http/lib/http.module.mjs} +5 -5
- package/esm2020/http/lib/interceptors/base-url.interceptor.mjs +50 -0
- package/esm2020/http/lib/interceptors/error.interceptor.mjs +32 -0
- package/{esm2015/http/public_api.js → esm2020/http/public_api.mjs} +0 -0
- package/{esm2015/lib/core/miscellaneous/regex.js → esm2020/lib/core/miscellaneous/regex.mjs} +0 -0
- package/esm2020/lib/core/miscellaneous/validator.mjs +85 -0
- package/esm2020/lib/core/mixins/can-disable.mjs +16 -0
- package/{esm2015/lib/core/mixins/can-hide-errors.js → esm2020/lib/core/mixins/can-hide-errors.mjs} +2 -2
- package/esm2020/lib/core/mixins/can-load.mjs +16 -0
- package/{esm2015/lib/core/mixins/constructor.js → esm2020/lib/core/mixins/constructor.mjs} +0 -0
- package/esm2020/lib/core/mixins/has-error.mjs +16 -0
- package/esm2020/lib/core/mixins/is-focused.mjs +16 -0
- package/esm2020/lib/core/mixins/is-grouped.mjs +16 -0
- package/esm2020/lib/core/mixins/is-readonly.mjs +16 -0
- package/esm2020/lib/core/mixins/is-required.mjs +16 -0
- package/esm2020/lib/core/services/clipboard.service.mjs +70 -0
- package/esm2020/lib/core/services/exif.service.mjs +163 -0
- package/esm2020/lib/core/services/file-loader.service.mjs +87 -0
- package/esm2020/lib/core/services/image-converter.service.mjs +123 -0
- package/{esm2015/lib/core/services/languages.service.js → esm2020/lib/core/services/languages.service.mjs} +4 -4
- package/{esm2015/lib/core/services/network.service.js → esm2020/lib/core/services/network.service.mjs} +5 -6
- package/esm2020/lib/core/services/patch.service.mjs +63 -0
- package/{esm2015/lib/core/services/platform.service.js → esm2020/lib/core/services/platform.service.mjs} +5 -5
- package/{esm2015/lib/core/tokens/accept-language.token.js → esm2020/lib/core/tokens/accept-language.token.mjs} +0 -0
- package/{esm2015/lib/core/tokens/base-url.token.js → esm2020/lib/core/tokens/base-url.token.mjs} +0 -0
- package/{esm2015/lib/core/tokens/cookie.token.js → esm2020/lib/core/tokens/cookie.token.mjs} +0 -0
- package/{esm2015/lib/core/tokens/location.token.js → esm2020/lib/core/tokens/location.token.mjs} +0 -0
- package/{esm2015/lib/core/tokens/navigator.token.js → esm2020/lib/core/tokens/navigator.token.mjs} +0 -0
- package/{esm2015/lib/core/tokens/window.token.js → esm2020/lib/core/tokens/window.token.mjs} +0 -0
- package/{esm2015/localize/bravobit-bb-foundation-localize.js → esm2020/localize/bravobit-bb-foundation-localize.mjs} +0 -0
- package/{esm2015/localize/lib/functions/date.function.js → esm2020/localize/lib/functions/date.function.mjs} +0 -0
- package/{esm2015/localize/lib/functions/lowercase.function.js → esm2020/localize/lib/functions/lowercase.function.mjs} +0 -0
- package/{esm2015/localize/lib/functions/uppercase.function.js → esm2020/localize/lib/functions/uppercase.function.mjs} +0 -0
- package/{esm2015/localize/lib/handlers/missing.handler.js → esm2020/localize/lib/handlers/missing.handler.mjs} +0 -0
- package/{esm2015/localize/lib/interfaces/config.interfaces.js → esm2020/localize/lib/interfaces/config.interfaces.mjs} +0 -0
- package/{esm2015/localize/lib/interfaces/dictionary.interfaces.js → esm2020/localize/lib/interfaces/dictionary.interfaces.mjs} +0 -0
- package/{esm2015/localize/lib/interfaces/functions.interfaces.js → esm2020/localize/lib/interfaces/functions.interfaces.mjs} +0 -0
- package/{esm2015/localize/lib/interfaces/handlers.interfaces.js → esm2020/localize/lib/interfaces/handlers.interfaces.mjs} +0 -0
- package/{esm2015/localize/lib/interfaces/options.interfaces.js → esm2020/localize/lib/interfaces/options.interfaces.mjs} +0 -0
- package/{esm2015/localize/lib/localizations/dutch.localization.js → esm2020/localize/lib/localizations/dutch.localization.mjs} +0 -0
- package/{esm2015/localize/lib/localizations/english.localization.js → esm2020/localize/lib/localizations/english.localization.mjs} +0 -0
- package/esm2020/localize/lib/localize.dictionary.mjs +135 -0
- package/{esm2015/localize/lib/localize.module.js → esm2020/localize/lib/localize.module.mjs} +5 -5
- package/{esm2015/localize/lib/localize.pipe.js → esm2020/localize/lib/localize.pipe.mjs} +5 -5
- package/esm2020/localize/lib/localize.service.mjs +277 -0
- package/esm2020/localize/lib/views/localize-string/localize-string.component.mjs +88 -0
- package/{esm2015/localize/lib/views/localize-template-or-string.directive.js → esm2020/localize/lib/views/localize-template-or-string.directive.mjs} +4 -4
- package/{esm2015/localize/lib/views/localize-template.directive.js → esm2020/localize/lib/views/localize-template.directive.mjs} +4 -4
- package/{esm2015/localize/public_api.js → esm2020/localize/public_api.mjs} +0 -0
- package/{esm2015/notifications/bravobit-bb-foundation-notifications.js → esm2020/notifications/bravobit-bb-foundation-notifications.mjs} +0 -0
- package/esm2020/notifications/lib/notifications-item/notifications-item.component.mjs +100 -0
- package/esm2020/notifications/lib/notifications-list/notifications-list.component.mjs +47 -0
- package/{esm2015/notifications/lib/notifications.animations.js → esm2020/notifications/lib/notifications.animations.mjs} +0 -0
- package/{esm2015/notifications/lib/notifications.injector.js → esm2020/notifications/lib/notifications.injector.mjs} +0 -0
- package/{esm2015/notifications/lib/notifications.interfaces.js → esm2020/notifications/lib/notifications.interfaces.mjs} +0 -0
- package/{esm2015/notifications/lib/notifications.module.js → esm2020/notifications/lib/notifications.module.mjs} +6 -7
- package/{esm2015/notifications/lib/notifications.service.js → esm2020/notifications/lib/notifications.service.mjs} +5 -5
- package/{esm2015/notifications/public_api.js → esm2020/notifications/public_api.mjs} +0 -0
- package/{esm2015/public_api.js → esm2020/public_api.mjs} +1 -2
- package/{esm2015/recaptcha/bravobit-bb-foundation-recaptcha.js → esm2020/recaptcha/bravobit-bb-foundation-recaptcha.mjs} +0 -0
- package/esm2020/recaptcha/lib/recaptcha/recaptcha.component.mjs +185 -0
- package/esm2020/recaptcha/lib/recaptcha-loader.service.mjs +90 -0
- package/{esm2015/recaptcha/lib/recaptcha.interface.js → esm2020/recaptcha/lib/recaptcha.interface.mjs} +0 -0
- package/{esm2015/recaptcha/lib/recaptcha.module.js → esm2020/recaptcha/lib/recaptcha.module.mjs} +5 -5
- package/{esm2015/recaptcha/public_api.js → esm2020/recaptcha/public_api.mjs} +0 -0
- package/{esm2015/rxjs/bravobit-bb-foundation-rxjs.js → esm2020/rxjs/bravobit-bb-foundation-rxjs.mjs} +0 -0
- package/esm2020/rxjs/lib/operators/combine-latest-map.operator.mjs +10 -0
- package/{esm2015/rxjs/lib/operators/filter-nil.operator.js → esm2020/rxjs/lib/operators/filter-nil.operator.mjs} +0 -0
- package/{esm2015/rxjs/public_api.js → esm2020/rxjs/public_api.mjs} +0 -0
- package/{esm2015/storage/bravobit-bb-foundation-storage.js → esm2020/storage/bravobit-bb-foundation-storage.mjs} +0 -0
- package/{esm2015/storage/lib/interfaces/attributes.interface.js → esm2020/storage/lib/interfaces/attributes.interface.mjs} +0 -0
- package/{esm2015/storage/lib/interfaces/memory.interface.js → esm2020/storage/lib/interfaces/memory.interface.mjs} +0 -0
- package/{esm2015/storage/lib/interfaces/strategy.interface.js → esm2020/storage/lib/interfaces/strategy.interface.mjs} +0 -0
- package/esm2020/storage/lib/storage.service.mjs +109 -0
- package/esm2020/storage/lib/strategies/cookie-storage.strategy.mjs +142 -0
- package/{esm2015/storage/lib/strategies/memory-storage.strategy.js → esm2020/storage/lib/strategies/memory-storage.strategy.mjs} +2 -2
- package/esm2020/storage/lib/strategies/polyfill-storage.strategy.mjs +102 -0
- package/{esm2015/storage/public_api.js → esm2020/storage/public_api.mjs} +0 -0
- package/{esm2015/table/bravobit-bb-foundation-table.js → esm2020/table/bravobit-bb-foundation-table.mjs} +0 -0
- package/esm2020/table/lib/components/table/table.component.mjs +191 -0
- package/esm2020/table/lib/components/table-cell/table-cell.component.mjs +11 -0
- package/esm2020/table/lib/components/table-header-cell/table-header-cell.component.mjs +131 -0
- package/esm2020/table/lib/components/table-pager/table-pager.component.mjs +136 -0
- package/esm2020/table/lib/data/datasource.data.mjs +32 -0
- package/esm2020/table/lib/data/generic.data.mjs +72 -0
- package/{esm2015/table/lib/interfaces/datasource.interface.js → esm2020/table/lib/interfaces/datasource.interface.mjs} +0 -0
- package/{esm2015/table/lib/interfaces/table.interfaces.js → esm2020/table/lib/interfaces/table.interfaces.mjs} +0 -0
- package/{esm2015/table/lib/table.module.js → esm2020/table/lib/table.module.mjs} +5 -5
- package/{esm2015/table/public_api.js → esm2020/table/public_api.mjs} +0 -0
- package/fesm2015/{bravobit-bb-foundation-auth.js → bravobit-bb-foundation-auth.mjs} +79 -68
- package/fesm2015/bravobit-bb-foundation-auth.mjs.map +1 -0
- package/fesm2015/{bravobit-bb-foundation-collections.js → bravobit-bb-foundation-collections.mjs} +45 -57
- package/fesm2015/bravobit-bb-foundation-collections.mjs.map +1 -0
- package/fesm2015/bravobit-bb-foundation-controls.mjs +235 -0
- package/fesm2015/bravobit-bb-foundation-controls.mjs.map +1 -0
- package/fesm2015/bravobit-bb-foundation-dashboard.mjs +416 -0
- package/fesm2015/bravobit-bb-foundation-dashboard.mjs.map +1 -0
- package/fesm2015/{bravobit-bb-foundation-dialog.js → bravobit-bb-foundation-dialog.mjs} +45 -106
- package/fesm2015/bravobit-bb-foundation-dialog.mjs.map +1 -0
- package/fesm2015/{bravobit-bb-foundation-elements.js → bravobit-bb-foundation-elements.mjs} +195 -303
- package/fesm2015/bravobit-bb-foundation-elements.mjs.map +1 -0
- package/fesm2015/{bravobit-bb-foundation-http.js → bravobit-bb-foundation-http.mjs} +18 -16
- package/fesm2015/bravobit-bb-foundation-http.mjs.map +1 -0
- package/fesm2015/{bravobit-bb-foundation-localize.js → bravobit-bb-foundation-localize.mjs} +63 -69
- package/fesm2015/bravobit-bb-foundation-localize.mjs.map +1 -0
- package/fesm2015/bravobit-bb-foundation-notifications.mjs +377 -0
- package/fesm2015/bravobit-bb-foundation-notifications.mjs.map +1 -0
- package/fesm2015/{bravobit-bb-foundation-recaptcha.js → bravobit-bb-foundation-recaptcha.mjs} +40 -47
- package/fesm2015/bravobit-bb-foundation-recaptcha.mjs.map +1 -0
- package/fesm2015/{bravobit-bb-foundation-rxjs.js → bravobit-bb-foundation-rxjs.mjs} +1 -1
- package/fesm2015/bravobit-bb-foundation-rxjs.mjs.map +1 -0
- package/fesm2015/{bravobit-bb-foundation-storage.js → bravobit-bb-foundation-storage.mjs} +12 -10
- package/fesm2015/bravobit-bb-foundation-storage.mjs.map +1 -0
- package/fesm2015/bravobit-bb-foundation-table.mjs +603 -0
- package/fesm2015/bravobit-bb-foundation-table.mjs.map +1 -0
- package/fesm2015/{bravobit-bb-foundation.js → bravobit-bb-foundation.mjs} +76 -69
- package/fesm2015/bravobit-bb-foundation.mjs.map +1 -0
- package/fesm2020/bravobit-bb-foundation-auth.mjs +928 -0
- package/fesm2020/bravobit-bb-foundation-auth.mjs.map +1 -0
- package/fesm2020/bravobit-bb-foundation-collections.mjs +441 -0
- package/fesm2020/bravobit-bb-foundation-collections.mjs.map +1 -0
- package/fesm2020/bravobit-bb-foundation-controls.mjs +233 -0
- package/fesm2020/bravobit-bb-foundation-controls.mjs.map +1 -0
- package/fesm2020/bravobit-bb-foundation-dashboard.mjs +404 -0
- package/fesm2020/bravobit-bb-foundation-dashboard.mjs.map +1 -0
- package/fesm2020/bravobit-bb-foundation-dialog.mjs +584 -0
- package/fesm2020/bravobit-bb-foundation-dialog.mjs.map +1 -0
- package/fesm2020/bravobit-bb-foundation-elements.mjs +1994 -0
- package/fesm2020/bravobit-bb-foundation-elements.mjs.map +1 -0
- package/fesm2020/bravobit-bb-foundation-http.mjs +168 -0
- package/fesm2020/bravobit-bb-foundation-http.mjs.map +1 -0
- package/fesm2020/bravobit-bb-foundation-localize.mjs +832 -0
- package/fesm2020/bravobit-bb-foundation-localize.mjs.map +1 -0
- package/fesm2020/bravobit-bb-foundation-notifications.mjs +375 -0
- package/fesm2020/bravobit-bb-foundation-notifications.mjs.map +1 -0
- package/fesm2020/bravobit-bb-foundation-recaptcha.mjs +300 -0
- package/fesm2020/bravobit-bb-foundation-recaptcha.mjs.map +1 -0
- package/fesm2020/bravobit-bb-foundation-rxjs.mjs +21 -0
- package/fesm2020/bravobit-bb-foundation-rxjs.mjs.map +1 -0
- package/fesm2020/bravobit-bb-foundation-storage.mjs +413 -0
- package/fesm2020/bravobit-bb-foundation-storage.mjs.map +1 -0
- package/fesm2020/bravobit-bb-foundation-table.mjs +592 -0
- package/fesm2020/bravobit-bb-foundation-table.mjs.map +1 -0
- package/fesm2020/bravobit-bb-foundation.mjs +892 -0
- package/fesm2020/bravobit-bb-foundation.mjs.map +1 -0
- package/http/package.json +5 -5
- package/localize/package.json +5 -5
- package/notifications/package.json +5 -5
- package/package.json +126 -8
- package/public_api.d.ts +0 -1
- package/recaptcha/package.json +5 -5
- package/rxjs/package.json +5 -5
- package/storage/package.json +5 -5
- package/table/package.json +5 -5
- package/bundles/bravobit-bb-foundation-auth.umd.js +0 -1483
- package/bundles/bravobit-bb-foundation-auth.umd.js.map +0 -1
- package/bundles/bravobit-bb-foundation-collections.umd.js +0 -868
- package/bundles/bravobit-bb-foundation-collections.umd.js.map +0 -1
- package/bundles/bravobit-bb-foundation-dashboard.umd.js +0 -876
- package/bundles/bravobit-bb-foundation-dashboard.umd.js.map +0 -1
- package/bundles/bravobit-bb-foundation-dialog.umd.js +0 -716
- package/bundles/bravobit-bb-foundation-dialog.umd.js.map +0 -1
- package/bundles/bravobit-bb-foundation-elements.umd.js +0 -2768
- package/bundles/bravobit-bb-foundation-elements.umd.js.map +0 -1
- package/bundles/bravobit-bb-foundation-http.umd.js +0 -535
- package/bundles/bravobit-bb-foundation-http.umd.js.map +0 -1
- package/bundles/bravobit-bb-foundation-localize.umd.js +0 -1292
- package/bundles/bravobit-bb-foundation-localize.umd.js.map +0 -1
- package/bundles/bravobit-bb-foundation-notifications.umd.js +0 -794
- package/bundles/bravobit-bb-foundation-notifications.umd.js.map +0 -1
- package/bundles/bravobit-bb-foundation-recaptcha.umd.js +0 -683
- package/bundles/bravobit-bb-foundation-recaptcha.umd.js.map +0 -1
- package/bundles/bravobit-bb-foundation-rxjs.umd.js +0 -29
- package/bundles/bravobit-bb-foundation-rxjs.umd.js.map +0 -1
- package/bundles/bravobit-bb-foundation-storage.umd.js +0 -799
- package/bundles/bravobit-bb-foundation-storage.umd.js.map +0 -1
- package/bundles/bravobit-bb-foundation-table.umd.js +0 -1084
- package/bundles/bravobit-bb-foundation-table.umd.js.map +0 -1
- package/bundles/bravobit-bb-foundation.umd.js +0 -1440
- package/bundles/bravobit-bb-foundation.umd.js.map +0 -1
- package/esm2015/auth/lib/auth.interceptor.js +0 -95
- package/esm2015/auth/lib/auth.service.js +0 -299
- package/esm2015/auth/lib/auth.session.js +0 -136
- package/esm2015/auth/lib/directives/permission.directive.js +0 -81
- package/esm2015/auth/lib/directives/role.directive.js +0 -38
- package/esm2015/auth/lib/guards/anonymous.guard.js +0 -35
- package/esm2015/auth/lib/guards/authenticated.guard.js +0 -36
- package/esm2015/auth/lib/permissions.service.js +0 -58
- package/esm2015/auth/lib/providers/email.provider.js +0 -26
- package/esm2015/auth/lib/providers/verify.provider.js +0 -20
- package/esm2015/collections/lib/collection.js +0 -104
- package/esm2015/collections/lib/components/collections-pager/collections-pager.component.js +0 -136
- package/esm2015/collections/lib/components/collections-viewer/collections-viewer.component.js +0 -39
- package/esm2015/collections/lib/providers/api-collection.provider.js +0 -69
- package/esm2015/collections/lib/providers/collection.provider.js +0 -14
- package/esm2015/dashboard/lib/dashboard/dashboard.component.js +0 -64
- package/esm2015/dashboard/lib/dashboard-header/dashboard-header.component.js +0 -41
- package/esm2015/dashboard/lib/dashboard-menu/dashboard-menu.component.js +0 -39
- package/esm2015/dashboard/lib/dashboard-menu-item/dashboard-menu-item.component.js +0 -38
- package/esm2015/dashboard/lib/dashboard-sidebar/dashboard-sidebar.component.js +0 -83
- package/esm2015/dashboard/lib/dashboard-sidebar-group/dashboard-sidebar-group.component.js +0 -110
- package/esm2015/dashboard/lib/dashboard-sidebar-item/dashboard-sidebar-item.component.js +0 -71
- package/esm2015/dialog/lib/dialog-actions/dialog-actions.component.js +0 -20
- package/esm2015/dialog/lib/dialog-confirm/dialog-confirm.component.js +0 -45
- package/esm2015/dialog/lib/dialog-header/dialog-header.component.js +0 -33
- package/esm2015/dialog/lib/dialog-link/dialog-link.component.js +0 -19
- package/esm2015/dialog/lib/dialog-modal/dialog-modal.component.js +0 -54
- package/esm2015/dialog/lib/dialog-overlay/dialog-overlay.component.js +0 -143
- package/esm2015/elements/lib/avatar/avatar.component.js +0 -151
- package/esm2015/elements/lib/button/button.component.js +0 -79
- package/esm2015/elements/lib/checkbox/checkbox.component.js +0 -83
- package/esm2015/elements/lib/date-picker/date-picker.component.js +0 -322
- package/esm2015/elements/lib/directives/autosize.directive.js +0 -74
- package/esm2015/elements/lib/directives/form-submit.directive.js +0 -53
- package/esm2015/elements/lib/directives/input.directive.js +0 -139
- package/esm2015/elements/lib/dropdown/dropdown.component.js +0 -111
- package/esm2015/elements/lib/file-picker/file-picker.component.js +0 -247
- package/esm2015/elements/lib/form-control/form-control.component.js +0 -58
- package/esm2015/elements/lib/form-error/form-error.component.js +0 -116
- package/esm2015/elements/lib/form-group/form-group.component.js +0 -27
- package/esm2015/elements/lib/icon/icon.component.js +0 -110
- package/esm2015/elements/lib/image-picker/image-picker.component.js +0 -119
- package/esm2015/elements/lib/pipes/file-image.pipe.js +0 -45
- package/esm2015/elements/lib/pipes/relative-time.pipe.js +0 -96
- package/esm2015/elements/lib/spinner/spinner.component.js +0 -34
- package/esm2015/elements/lib/tag/tag.component.js +0 -26
- package/esm2015/http/lib/classes/http.config.js +0 -31
- package/esm2015/http/lib/classes/http.error.js +0 -21
- package/esm2015/http/lib/interceptors/base-url.interceptor.js +0 -52
- package/esm2015/http/lib/interceptors/error.interceptor.js +0 -33
- package/esm2015/lib/core/coercions/boolean-coercion.js +0 -4
- package/esm2015/lib/core/miscellaneous/validator.js +0 -86
- package/esm2015/lib/core/mixins/can-disable.js +0 -16
- package/esm2015/lib/core/mixins/can-load.js +0 -16
- package/esm2015/lib/core/mixins/has-error.js +0 -16
- package/esm2015/lib/core/mixins/is-focused.js +0 -16
- package/esm2015/lib/core/mixins/is-grouped.js +0 -16
- package/esm2015/lib/core/mixins/is-readonly.js +0 -16
- package/esm2015/lib/core/mixins/is-required.js +0 -16
- package/esm2015/lib/core/services/clipboard.service.js +0 -72
- package/esm2015/lib/core/services/exif.service.js +0 -168
- package/esm2015/lib/core/services/file-loader.service.js +0 -90
- package/esm2015/lib/core/services/image-converter.service.js +0 -130
- package/esm2015/lib/core/services/patch.service.js +0 -65
- package/esm2015/localize/lib/localize.dictionary.js +0 -137
- package/esm2015/localize/lib/localize.service.js +0 -282
- package/esm2015/localize/lib/views/localize-string/localize-string.component.js +0 -99
- package/esm2015/notifications/lib/notifications-item/notifications-item.component.js +0 -108
- package/esm2015/notifications/lib/notifications-list/notifications-list.component.js +0 -56
- package/esm2015/recaptcha/lib/recaptcha/recaptcha.component.js +0 -199
- package/esm2015/recaptcha/lib/recaptcha-loader.service.js +0 -93
- package/esm2015/rxjs/lib/operators/combine-latest-map.operator.js +0 -7
- package/esm2015/storage/lib/storage.service.js +0 -111
- package/esm2015/storage/lib/strategies/cookie-storage.strategy.js +0 -143
- package/esm2015/storage/lib/strategies/polyfill-storage.strategy.js +0 -102
- package/esm2015/table/lib/components/table/table.component.js +0 -204
- package/esm2015/table/lib/components/table-cell/table-cell.component.js +0 -19
- package/esm2015/table/lib/components/table-header-cell/table-header-cell.component.js +0 -143
- package/esm2015/table/lib/components/table-pager/table-pager.component.js +0 -146
- package/esm2015/table/lib/data/datasource.data.js +0 -32
- package/esm2015/table/lib/data/generic.data.js +0 -73
- package/fesm2015/bravobit-bb-foundation-auth.js.map +0 -1
- package/fesm2015/bravobit-bb-foundation-collections.js.map +0 -1
- package/fesm2015/bravobit-bb-foundation-dashboard.js +0 -468
- package/fesm2015/bravobit-bb-foundation-dashboard.js.map +0 -1
- package/fesm2015/bravobit-bb-foundation-dialog.js.map +0 -1
- package/fesm2015/bravobit-bb-foundation-elements.js.map +0 -1
- package/fesm2015/bravobit-bb-foundation-http.js.map +0 -1
- package/fesm2015/bravobit-bb-foundation-localize.js.map +0 -1
- package/fesm2015/bravobit-bb-foundation-notifications.js +0 -393
- package/fesm2015/bravobit-bb-foundation-notifications.js.map +0 -1
- package/fesm2015/bravobit-bb-foundation-recaptcha.js.map +0 -1
- package/fesm2015/bravobit-bb-foundation-rxjs.js.map +0 -1
- package/fesm2015/bravobit-bb-foundation-storage.js.map +0 -1
- package/fesm2015/bravobit-bb-foundation-table.js +0 -636
- package/fesm2015/bravobit-bb-foundation-table.js.map +0 -1
- package/fesm2015/bravobit-bb-foundation.js.map +0 -1
- package/lib/core/coercions/boolean-coercion.d.ts +0 -1
|
@@ -1,1483 +0,0 @@
|
|
|
1
|
-
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common/http'), require('@angular/core'), require('rxjs/operators'), require('@angular/platform-browser'), require('rxjs'), require('@angular/router'), require('@bravobit/bb-foundation/storage'), require('@bravobit/bb-foundation'), require('@bravobit/bb-foundation/http')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define('@bravobit/bb-foundation/auth', ['exports', '@angular/common/http', '@angular/core', 'rxjs/operators', '@angular/platform-browser', 'rxjs', '@angular/router', '@bravobit/bb-foundation/storage', '@bravobit/bb-foundation', '@bravobit/bb-foundation/http'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.bravobit = global.bravobit || {}, global.bravobit["bb-foundation"] = global.bravobit["bb-foundation"] || {}, global.bravobit["bb-foundation"].auth = {}), global.ng.common.http, global.ng.core, global.rxjs.operators, global.ng.platformBrowser, global.rxjs, global.ng.router, global.bravobit["bb-foundation"].storage, global.bravobit["bb-foundation"], global.bravobit["bb-foundation"].http));
|
|
5
|
-
})(this, (function (exports, i4, i0, operators, i6, rxjs, router, i1, i3, i7) { 'use strict';
|
|
6
|
-
|
|
7
|
-
function _interopNamespace(e) {
|
|
8
|
-
if (e && e.__esModule) return e;
|
|
9
|
-
var n = Object.create(null);
|
|
10
|
-
if (e) {
|
|
11
|
-
Object.keys(e).forEach(function (k) {
|
|
12
|
-
if (k !== 'default') {
|
|
13
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: function () { return e[k]; }
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
n["default"] = e;
|
|
22
|
-
return Object.freeze(n);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
var i4__namespace = /*#__PURE__*/_interopNamespace(i4);
|
|
26
|
-
var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
|
|
27
|
-
var i6__namespace = /*#__PURE__*/_interopNamespace(i6);
|
|
28
|
-
var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
|
|
29
|
-
var i3__namespace = /*#__PURE__*/_interopNamespace(i3);
|
|
30
|
-
var i7__namespace = /*#__PURE__*/_interopNamespace(i7);
|
|
31
|
-
|
|
32
|
-
var AuthConfig = /** @class */ (function () {
|
|
33
|
-
function AuthConfig() {
|
|
34
|
-
}
|
|
35
|
-
return AuthConfig;
|
|
36
|
-
}());
|
|
37
|
-
|
|
38
|
-
var USE_AUTHORIZATION = new i4.HttpContextToken(function () { return true; });
|
|
39
|
-
|
|
40
|
-
var JwtHelper = /** @class */ (function () {
|
|
41
|
-
function JwtHelper() {
|
|
42
|
-
var _this = this;
|
|
43
|
-
this.baseDecodeUnicode = function (value) {
|
|
44
|
-
return decodeURIComponent(atob(value).replace(/(.)/g, function (_, p) {
|
|
45
|
-
var code = p.charCodeAt(0).toString(16).toUpperCase();
|
|
46
|
-
if (code.length < 2) {
|
|
47
|
-
code = '0' + code;
|
|
48
|
-
}
|
|
49
|
-
return '%' + code;
|
|
50
|
-
}));
|
|
51
|
-
};
|
|
52
|
-
this.parse = function (data) {
|
|
53
|
-
return {
|
|
54
|
-
id: data['iss'] || null,
|
|
55
|
-
type: data['typ'] || null,
|
|
56
|
-
audience: data['aud'] || null,
|
|
57
|
-
issuer: data['iss'] || null,
|
|
58
|
-
subject: data['sub'] || null,
|
|
59
|
-
role: data['role'] || null,
|
|
60
|
-
notValidBefore: _this.parseDate(data['nbf']),
|
|
61
|
-
expiresAt: _this.parseDate(data['exp']),
|
|
62
|
-
issuedAt: _this.parseDate(data['iat'])
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
this.parseDate = function (epochInSeconds) {
|
|
66
|
-
if (!epochInSeconds || epochInSeconds <= 0) {
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
return new Date(epochInSeconds * 1000);
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
JwtHelper.prototype.decode = function (token) {
|
|
73
|
-
try {
|
|
74
|
-
if (token === null || token === undefined) {
|
|
75
|
-
return null;
|
|
76
|
-
}
|
|
77
|
-
var json = JSON.parse(this.urlDecode(token.split('.')[1]));
|
|
78
|
-
return this.parse(json);
|
|
79
|
-
}
|
|
80
|
-
catch (_a) {
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
JwtHelper.prototype.urlDecode = function (token) {
|
|
85
|
-
var value = token || '';
|
|
86
|
-
var output = value
|
|
87
|
-
.replace(/-/g, '+')
|
|
88
|
-
.replace(/_/g, '/');
|
|
89
|
-
switch (output.length % 4) {
|
|
90
|
-
case 0:
|
|
91
|
-
break;
|
|
92
|
-
case 2:
|
|
93
|
-
output += '==';
|
|
94
|
-
break;
|
|
95
|
-
case 3:
|
|
96
|
-
output += '=';
|
|
97
|
-
break;
|
|
98
|
-
default:
|
|
99
|
-
throw 'Illegal base64url string!';
|
|
100
|
-
}
|
|
101
|
-
try {
|
|
102
|
-
return this.baseDecodeUnicode(output);
|
|
103
|
-
}
|
|
104
|
-
catch (_a) {
|
|
105
|
-
return atob(output);
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
return JwtHelper;
|
|
109
|
-
}());
|
|
110
|
-
|
|
111
|
-
var AuthMapper = /** @class */ (function () {
|
|
112
|
-
function AuthMapper() {
|
|
113
|
-
// Routes.
|
|
114
|
-
this.me = 'auth/me';
|
|
115
|
-
this.register = 'auth/register';
|
|
116
|
-
this.resendCode = 'auth/resend';
|
|
117
|
-
this.logout = 'auth/logout';
|
|
118
|
-
this.refresh = 'auth/refresh';
|
|
119
|
-
this.requestPassword = 'auth/reset';
|
|
120
|
-
this.resetPassword = 'auth/reset-password';
|
|
121
|
-
}
|
|
122
|
-
AuthMapper.prototype.role = function (data) {
|
|
123
|
-
return (data && data.role) || null;
|
|
124
|
-
};
|
|
125
|
-
AuthMapper.prototype.toRegister = function (data) {
|
|
126
|
-
// Retrieve the params.
|
|
127
|
-
var token = data.token, refresh_token = data.refresh_token, user = data.user;
|
|
128
|
-
// Map the data to the correct format.
|
|
129
|
-
return { accessToken: token, refreshToken: refresh_token, user: user };
|
|
130
|
-
};
|
|
131
|
-
AuthMapper.prototype.toRefresh = function (data) {
|
|
132
|
-
// Retrieve the params.
|
|
133
|
-
var token = data.token, refresh_token = data.refresh_token;
|
|
134
|
-
// Map the data to the correct format.
|
|
135
|
-
return { accessToken: token, refreshToken: refresh_token };
|
|
136
|
-
};
|
|
137
|
-
return AuthMapper;
|
|
138
|
-
}());
|
|
139
|
-
AuthMapper.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0__namespace, type: AuthMapper, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
140
|
-
AuthMapper.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0__namespace, type: AuthMapper });
|
|
141
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0__namespace, type: AuthMapper, decorators: [{
|
|
142
|
-
type: i0.Injectable
|
|
143
|
-
}] });
|
|
144
|
-
|
|
145
|
-
/*! *****************************************************************************
|
|
146
|
-
Copyright (c) Microsoft Corporation.
|
|
147
|
-
|
|
148
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
149
|
-
purpose with or without fee is hereby granted.
|
|
150
|
-
|
|
151
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
152
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
153
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
154
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
155
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
156
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
157
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
158
|
-
***************************************************************************** */
|
|
159
|
-
/* global Reflect, Promise */
|
|
160
|
-
var extendStatics = function (d, b) {
|
|
161
|
-
extendStatics = Object.setPrototypeOf ||
|
|
162
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
163
|
-
function (d, b) { for (var p in b)
|
|
164
|
-
if (Object.prototype.hasOwnProperty.call(b, p))
|
|
165
|
-
d[p] = b[p]; };
|
|
166
|
-
return extendStatics(d, b);
|
|
167
|
-
};
|
|
168
|
-
function __extends(d, b) {
|
|
169
|
-
if (typeof b !== "function" && b !== null)
|
|
170
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
171
|
-
extendStatics(d, b);
|
|
172
|
-
function __() { this.constructor = d; }
|
|
173
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
174
|
-
}
|
|
175
|
-
var __assign = function () {
|
|
176
|
-
__assign = Object.assign || function __assign(t) {
|
|
177
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
178
|
-
s = arguments[i];
|
|
179
|
-
for (var p in s)
|
|
180
|
-
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
181
|
-
t[p] = s[p];
|
|
182
|
-
}
|
|
183
|
-
return t;
|
|
184
|
-
};
|
|
185
|
-
return __assign.apply(this, arguments);
|
|
186
|
-
};
|
|
187
|
-
function __rest(s, e) {
|
|
188
|
-
var t = {};
|
|
189
|
-
for (var p in s)
|
|
190
|
-
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
191
|
-
t[p] = s[p];
|
|
192
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
193
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
194
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
195
|
-
t[p[i]] = s[p[i]];
|
|
196
|
-
}
|
|
197
|
-
return t;
|
|
198
|
-
}
|
|
199
|
-
function __decorate(decorators, target, key, desc) {
|
|
200
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
201
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
202
|
-
r = Reflect.decorate(decorators, target, key, desc);
|
|
203
|
-
else
|
|
204
|
-
for (var i = decorators.length - 1; i >= 0; i--)
|
|
205
|
-
if (d = decorators[i])
|
|
206
|
-
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
207
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
208
|
-
}
|
|
209
|
-
function __param(paramIndex, decorator) {
|
|
210
|
-
return function (target, key) { decorator(target, key, paramIndex); };
|
|
211
|
-
}
|
|
212
|
-
function __metadata(metadataKey, metadataValue) {
|
|
213
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
214
|
-
return Reflect.metadata(metadataKey, metadataValue);
|
|
215
|
-
}
|
|
216
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
217
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
218
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
219
|
-
function fulfilled(value) { try {
|
|
220
|
-
step(generator.next(value));
|
|
221
|
-
}
|
|
222
|
-
catch (e) {
|
|
223
|
-
reject(e);
|
|
224
|
-
} }
|
|
225
|
-
function rejected(value) { try {
|
|
226
|
-
step(generator["throw"](value));
|
|
227
|
-
}
|
|
228
|
-
catch (e) {
|
|
229
|
-
reject(e);
|
|
230
|
-
} }
|
|
231
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
232
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
function __generator(thisArg, body) {
|
|
236
|
-
var _ = { label: 0, sent: function () { if (t[0] & 1)
|
|
237
|
-
throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
238
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
|
|
239
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
240
|
-
function step(op) {
|
|
241
|
-
if (f)
|
|
242
|
-
throw new TypeError("Generator is already executing.");
|
|
243
|
-
while (_)
|
|
244
|
-
try {
|
|
245
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
|
|
246
|
-
return t;
|
|
247
|
-
if (y = 0, t)
|
|
248
|
-
op = [op[0] & 2, t.value];
|
|
249
|
-
switch (op[0]) {
|
|
250
|
-
case 0:
|
|
251
|
-
case 1:
|
|
252
|
-
t = op;
|
|
253
|
-
break;
|
|
254
|
-
case 4:
|
|
255
|
-
_.label++;
|
|
256
|
-
return { value: op[1], done: false };
|
|
257
|
-
case 5:
|
|
258
|
-
_.label++;
|
|
259
|
-
y = op[1];
|
|
260
|
-
op = [0];
|
|
261
|
-
continue;
|
|
262
|
-
case 7:
|
|
263
|
-
op = _.ops.pop();
|
|
264
|
-
_.trys.pop();
|
|
265
|
-
continue;
|
|
266
|
-
default:
|
|
267
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
268
|
-
_ = 0;
|
|
269
|
-
continue;
|
|
270
|
-
}
|
|
271
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
|
|
272
|
-
_.label = op[1];
|
|
273
|
-
break;
|
|
274
|
-
}
|
|
275
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
276
|
-
_.label = t[1];
|
|
277
|
-
t = op;
|
|
278
|
-
break;
|
|
279
|
-
}
|
|
280
|
-
if (t && _.label < t[2]) {
|
|
281
|
-
_.label = t[2];
|
|
282
|
-
_.ops.push(op);
|
|
283
|
-
break;
|
|
284
|
-
}
|
|
285
|
-
if (t[2])
|
|
286
|
-
_.ops.pop();
|
|
287
|
-
_.trys.pop();
|
|
288
|
-
continue;
|
|
289
|
-
}
|
|
290
|
-
op = body.call(thisArg, _);
|
|
291
|
-
}
|
|
292
|
-
catch (e) {
|
|
293
|
-
op = [6, e];
|
|
294
|
-
y = 0;
|
|
295
|
-
}
|
|
296
|
-
finally {
|
|
297
|
-
f = t = 0;
|
|
298
|
-
}
|
|
299
|
-
if (op[0] & 5)
|
|
300
|
-
throw op[1];
|
|
301
|
-
return { value: op[0] ? op[1] : void 0, done: true };
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
var __createBinding = Object.create ? (function (o, m, k, k2) {
|
|
305
|
-
if (k2 === undefined)
|
|
306
|
-
k2 = k;
|
|
307
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
|
|
308
|
-
}) : (function (o, m, k, k2) {
|
|
309
|
-
if (k2 === undefined)
|
|
310
|
-
k2 = k;
|
|
311
|
-
o[k2] = m[k];
|
|
312
|
-
});
|
|
313
|
-
function __exportStar(m, o) {
|
|
314
|
-
for (var p in m)
|
|
315
|
-
if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
|
|
316
|
-
__createBinding(o, m, p);
|
|
317
|
-
}
|
|
318
|
-
function __values(o) {
|
|
319
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
320
|
-
if (m)
|
|
321
|
-
return m.call(o);
|
|
322
|
-
if (o && typeof o.length === "number")
|
|
323
|
-
return {
|
|
324
|
-
next: function () {
|
|
325
|
-
if (o && i >= o.length)
|
|
326
|
-
o = void 0;
|
|
327
|
-
return { value: o && o[i++], done: !o };
|
|
328
|
-
}
|
|
329
|
-
};
|
|
330
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
331
|
-
}
|
|
332
|
-
function __read(o, n) {
|
|
333
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
334
|
-
if (!m)
|
|
335
|
-
return o;
|
|
336
|
-
var i = m.call(o), r, ar = [], e;
|
|
337
|
-
try {
|
|
338
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
|
|
339
|
-
ar.push(r.value);
|
|
340
|
-
}
|
|
341
|
-
catch (error) {
|
|
342
|
-
e = { error: error };
|
|
343
|
-
}
|
|
344
|
-
finally {
|
|
345
|
-
try {
|
|
346
|
-
if (r && !r.done && (m = i["return"]))
|
|
347
|
-
m.call(i);
|
|
348
|
-
}
|
|
349
|
-
finally {
|
|
350
|
-
if (e)
|
|
351
|
-
throw e.error;
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
return ar;
|
|
355
|
-
}
|
|
356
|
-
/** @deprecated */
|
|
357
|
-
function __spread() {
|
|
358
|
-
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
359
|
-
ar = ar.concat(__read(arguments[i]));
|
|
360
|
-
return ar;
|
|
361
|
-
}
|
|
362
|
-
/** @deprecated */
|
|
363
|
-
function __spreadArrays() {
|
|
364
|
-
for (var s = 0, i = 0, il = arguments.length; i < il; i++)
|
|
365
|
-
s += arguments[i].length;
|
|
366
|
-
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
367
|
-
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
368
|
-
r[k] = a[j];
|
|
369
|
-
return r;
|
|
370
|
-
}
|
|
371
|
-
function __spreadArray(to, from, pack) {
|
|
372
|
-
if (pack || arguments.length === 2)
|
|
373
|
-
for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
374
|
-
if (ar || !(i in from)) {
|
|
375
|
-
if (!ar)
|
|
376
|
-
ar = Array.prototype.slice.call(from, 0, i);
|
|
377
|
-
ar[i] = from[i];
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
381
|
-
}
|
|
382
|
-
function __await(v) {
|
|
383
|
-
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
384
|
-
}
|
|
385
|
-
function __asyncGenerator(thisArg, _arguments, generator) {
|
|
386
|
-
if (!Symbol.asyncIterator)
|
|
387
|
-
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
388
|
-
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
389
|
-
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
390
|
-
function verb(n) { if (g[n])
|
|
391
|
-
i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
392
|
-
function resume(n, v) { try {
|
|
393
|
-
step(g[n](v));
|
|
394
|
-
}
|
|
395
|
-
catch (e) {
|
|
396
|
-
settle(q[0][3], e);
|
|
397
|
-
} }
|
|
398
|
-
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
399
|
-
function fulfill(value) { resume("next", value); }
|
|
400
|
-
function reject(value) { resume("throw", value); }
|
|
401
|
-
function settle(f, v) { if (f(v), q.shift(), q.length)
|
|
402
|
-
resume(q[0][0], q[0][1]); }
|
|
403
|
-
}
|
|
404
|
-
function __asyncDelegator(o) {
|
|
405
|
-
var i, p;
|
|
406
|
-
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
|
407
|
-
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
|
|
408
|
-
}
|
|
409
|
-
function __asyncValues(o) {
|
|
410
|
-
if (!Symbol.asyncIterator)
|
|
411
|
-
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
412
|
-
var m = o[Symbol.asyncIterator], i;
|
|
413
|
-
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
414
|
-
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
415
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
|
|
416
|
-
}
|
|
417
|
-
function __makeTemplateObject(cooked, raw) {
|
|
418
|
-
if (Object.defineProperty) {
|
|
419
|
-
Object.defineProperty(cooked, "raw", { value: raw });
|
|
420
|
-
}
|
|
421
|
-
else {
|
|
422
|
-
cooked.raw = raw;
|
|
423
|
-
}
|
|
424
|
-
return cooked;
|
|
425
|
-
}
|
|
426
|
-
;
|
|
427
|
-
var __setModuleDefault = Object.create ? (function (o, v) {
|
|
428
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
429
|
-
}) : function (o, v) {
|
|
430
|
-
o["default"] = v;
|
|
431
|
-
};
|
|
432
|
-
function __importStar(mod) {
|
|
433
|
-
if (mod && mod.__esModule)
|
|
434
|
-
return mod;
|
|
435
|
-
var result = {};
|
|
436
|
-
if (mod != null)
|
|
437
|
-
for (var k in mod)
|
|
438
|
-
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
|
|
439
|
-
__createBinding(result, mod, k);
|
|
440
|
-
__setModuleDefault(result, mod);
|
|
441
|
-
return result;
|
|
442
|
-
}
|
|
443
|
-
function __importDefault(mod) {
|
|
444
|
-
return (mod && mod.__esModule) ? mod : { default: mod };
|
|
445
|
-
}
|
|
446
|
-
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
447
|
-
if (kind === "a" && !f)
|
|
448
|
-
throw new TypeError("Private accessor was defined without a getter");
|
|
449
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
450
|
-
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
451
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
452
|
-
}
|
|
453
|
-
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
454
|
-
if (kind === "m")
|
|
455
|
-
throw new TypeError("Private method is not writable");
|
|
456
|
-
if (kind === "a" && !f)
|
|
457
|
-
throw new TypeError("Private accessor was defined without a setter");
|
|
458
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
459
|
-
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
460
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
var AuthVerifyProvider = /** @class */ (function () {
|
|
464
|
-
function AuthVerifyProvider(_code, _verifyToken, _endpoint) {
|
|
465
|
-
this._code = _code;
|
|
466
|
-
this._verifyToken = _verifyToken;
|
|
467
|
-
this._endpoint = _endpoint;
|
|
468
|
-
}
|
|
469
|
-
AuthVerifyProvider.prototype.authenticate = function (httpClient) {
|
|
470
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
471
|
-
var _a, token, refresh_token, user;
|
|
472
|
-
return __generator(this, function (_b) {
|
|
473
|
-
switch (_b.label) {
|
|
474
|
-
case 0: return [4 /*yield*/, httpClient.post(this._endpoint, {
|
|
475
|
-
token: this._code,
|
|
476
|
-
verify_token: this._verifyToken
|
|
477
|
-
}).toPromise()];
|
|
478
|
-
case 1:
|
|
479
|
-
_a = _b.sent(), token = _a.token, refresh_token = _a.refresh_token, user = _a.user;
|
|
480
|
-
// Map the data to the correct format.
|
|
481
|
-
return [2 /*return*/, { accessToken: token, refreshToken: refresh_token, user: user }];
|
|
482
|
-
}
|
|
483
|
-
});
|
|
484
|
-
});
|
|
485
|
-
};
|
|
486
|
-
return AuthVerifyProvider;
|
|
487
|
-
}());
|
|
488
|
-
|
|
489
|
-
var AuthEmailProvider = /** @class */ (function () {
|
|
490
|
-
function AuthEmailProvider(_email, _password, _endpoint) {
|
|
491
|
-
this._email = _email;
|
|
492
|
-
this._password = _password;
|
|
493
|
-
this._endpoint = _endpoint;
|
|
494
|
-
}
|
|
495
|
-
AuthEmailProvider.prototype.authenticate = function (httpClient) {
|
|
496
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
497
|
-
var _a, token, refresh_token, user, provider, verify_token;
|
|
498
|
-
return __generator(this, function (_b) {
|
|
499
|
-
switch (_b.label) {
|
|
500
|
-
case 0: return [4 /*yield*/, httpClient.post(this._endpoint, {
|
|
501
|
-
email: this._email,
|
|
502
|
-
password: this._password
|
|
503
|
-
}).toPromise()];
|
|
504
|
-
case 1:
|
|
505
|
-
_a = _b.sent(), token = _a.token, refresh_token = _a.refresh_token, user = _a.user, provider = _a.provider, verify_token = _a.verify_token;
|
|
506
|
-
// Map the data to the correct format.
|
|
507
|
-
return [2 /*return*/, {
|
|
508
|
-
accessToken: token,
|
|
509
|
-
refreshToken: refresh_token,
|
|
510
|
-
user: user,
|
|
511
|
-
provider: provider,
|
|
512
|
-
verifyToken: verify_token
|
|
513
|
-
}];
|
|
514
|
-
}
|
|
515
|
-
});
|
|
516
|
-
});
|
|
517
|
-
};
|
|
518
|
-
return AuthEmailProvider;
|
|
519
|
-
}());
|
|
520
|
-
|
|
521
|
-
var AuthSession = /** @class */ (function () {
|
|
522
|
-
function AuthSession(options) {
|
|
523
|
-
var _a, _b;
|
|
524
|
-
// Readonly data.
|
|
525
|
-
this._jwt = new JwtHelper();
|
|
526
|
-
// Token strings.
|
|
527
|
-
this._accessTokenString = null;
|
|
528
|
-
this._refreshTokenString = null;
|
|
529
|
-
// Token payloads.
|
|
530
|
-
this._accessTokenPayload = null;
|
|
531
|
-
this._refreshTokenPayload = null;
|
|
532
|
-
// Private user data.
|
|
533
|
-
this._user$ = new rxjs.BehaviorSubject(null);
|
|
534
|
-
// Public user data.
|
|
535
|
-
this.user = this._user$.pipe(operators.shareReplay(1));
|
|
536
|
-
this.generateKey = function (applicationId, key) {
|
|
537
|
-
return [applicationId, key].join('_');
|
|
538
|
-
};
|
|
539
|
-
this.isTokenValid = function (token) {
|
|
540
|
-
var _a;
|
|
541
|
-
if (!token) {
|
|
542
|
-
return false;
|
|
543
|
-
}
|
|
544
|
-
return ((_a = token === null || token === void 0 ? void 0 : token.expiresAt) === null || _a === void 0 ? void 0 : _a.getTime()) > Date.now();
|
|
545
|
-
};
|
|
546
|
-
var applicationId = (_a = options === null || options === void 0 ? void 0 : options.id) !== null && _a !== void 0 ? _a : 'ng';
|
|
547
|
-
// Setting up the readonly storage keys.
|
|
548
|
-
this._accessTokenStorageKey = this.generateKey(applicationId, 'au_act');
|
|
549
|
-
this._refreshTokenStorageKey = this.generateKey(applicationId, 'au_rft');
|
|
550
|
-
this._userStorageKey = this.generateKey(applicationId, 'au_usr');
|
|
551
|
-
// Setting up the storage.
|
|
552
|
-
this._storage = (_b = options === null || options === void 0 ? void 0 : options.storage) !== null && _b !== void 0 ? _b : null;
|
|
553
|
-
// Init methods.
|
|
554
|
-
this.restoreFromStorage();
|
|
555
|
-
}
|
|
556
|
-
Object.defineProperty(AuthSession.prototype, "accessToken", {
|
|
557
|
-
get: function () {
|
|
558
|
-
return this.isTokenValid(this._accessTokenPayload)
|
|
559
|
-
? this._accessTokenString
|
|
560
|
-
: null;
|
|
561
|
-
},
|
|
562
|
-
enumerable: false,
|
|
563
|
-
configurable: true
|
|
564
|
-
});
|
|
565
|
-
Object.defineProperty(AuthSession.prototype, "refreshToken", {
|
|
566
|
-
get: function () {
|
|
567
|
-
return this.isTokenValid(this.refreshTokenPayload)
|
|
568
|
-
? this._refreshTokenString
|
|
569
|
-
: null;
|
|
570
|
-
},
|
|
571
|
-
enumerable: false,
|
|
572
|
-
configurable: true
|
|
573
|
-
});
|
|
574
|
-
Object.defineProperty(AuthSession.prototype, "accessTokenPayload", {
|
|
575
|
-
get: function () {
|
|
576
|
-
var _a;
|
|
577
|
-
return (_a = this._accessTokenPayload) !== null && _a !== void 0 ? _a : null;
|
|
578
|
-
},
|
|
579
|
-
enumerable: false,
|
|
580
|
-
configurable: true
|
|
581
|
-
});
|
|
582
|
-
Object.defineProperty(AuthSession.prototype, "refreshTokenPayload", {
|
|
583
|
-
get: function () {
|
|
584
|
-
var _a;
|
|
585
|
-
return (_a = this._refreshTokenPayload) !== null && _a !== void 0 ? _a : null;
|
|
586
|
-
},
|
|
587
|
-
enumerable: false,
|
|
588
|
-
configurable: true
|
|
589
|
-
});
|
|
590
|
-
AuthSession.prototype.authenticated = function () {
|
|
591
|
-
return this.isTokenValid(this._accessTokenPayload) || this.isTokenValid(this._refreshTokenPayload);
|
|
592
|
-
};
|
|
593
|
-
AuthSession.prototype.setTokens = function (accessToken, refreshToken) {
|
|
594
|
-
this.setAccessToken(accessToken);
|
|
595
|
-
this.setRefreshToken(refreshToken);
|
|
596
|
-
this.syncTokensInStorage();
|
|
597
|
-
};
|
|
598
|
-
AuthSession.prototype.setUser = function (user) {
|
|
599
|
-
this._user$.next(user !== null && user !== void 0 ? user : null);
|
|
600
|
-
this.syncUserInStorage();
|
|
601
|
-
};
|
|
602
|
-
AuthSession.prototype.clear = function () {
|
|
603
|
-
this.setTokens(null, null);
|
|
604
|
-
this.setUser(null);
|
|
605
|
-
};
|
|
606
|
-
AuthSession.prototype.restoreFromStorage = function () {
|
|
607
|
-
if (!this._storage) {
|
|
608
|
-
return;
|
|
609
|
-
}
|
|
610
|
-
// Set the access token.
|
|
611
|
-
var accessToken = this._storage.get(this._accessTokenStorageKey);
|
|
612
|
-
this.setAccessToken(accessToken);
|
|
613
|
-
// Set the refresh token.
|
|
614
|
-
var refreshToken = this._storage.get(this._refreshTokenStorageKey);
|
|
615
|
-
this.setRefreshToken(refreshToken);
|
|
616
|
-
// Set the user if we have any correct token payloads.
|
|
617
|
-
if (this._accessTokenPayload || this._refreshTokenPayload) {
|
|
618
|
-
var user = this._storage.get(this._userStorageKey);
|
|
619
|
-
this._user$.next(user !== null && user !== void 0 ? user : null); // Note: just settings here instead of setUser() because of syncing to the storage.
|
|
620
|
-
}
|
|
621
|
-
};
|
|
622
|
-
AuthSession.prototype.syncTokensInStorage = function () {
|
|
623
|
-
var _a, _b;
|
|
624
|
-
if (!this._storage) {
|
|
625
|
-
return;
|
|
626
|
-
}
|
|
627
|
-
// Set the access token if completely valid.
|
|
628
|
-
if (!!this.accessToken) {
|
|
629
|
-
this._storage.set(this._accessTokenStorageKey, this._accessTokenString, {
|
|
630
|
-
expires: (_a = this._accessTokenPayload) === null || _a === void 0 ? void 0 : _a.expiresAt
|
|
631
|
-
});
|
|
632
|
-
}
|
|
633
|
-
else {
|
|
634
|
-
this._storage.remove(this._accessTokenStorageKey);
|
|
635
|
-
}
|
|
636
|
-
// Set the refresh token if completely valid.
|
|
637
|
-
if (!!this.refreshToken) {
|
|
638
|
-
this._storage.set(this._refreshTokenStorageKey, this._refreshTokenString, {
|
|
639
|
-
expires: (_b = this._refreshTokenPayload) === null || _b === void 0 ? void 0 : _b.expiresAt
|
|
640
|
-
});
|
|
641
|
-
}
|
|
642
|
-
else {
|
|
643
|
-
this._storage.remove(this._refreshTokenStorageKey);
|
|
644
|
-
}
|
|
645
|
-
};
|
|
646
|
-
AuthSession.prototype.syncUserInStorage = function () {
|
|
647
|
-
if (!this._storage) {
|
|
648
|
-
return;
|
|
649
|
-
}
|
|
650
|
-
var user = this._user$.getValue();
|
|
651
|
-
if (!user) {
|
|
652
|
-
return this._storage.remove(this._userStorageKey);
|
|
653
|
-
}
|
|
654
|
-
var date = new Date();
|
|
655
|
-
date.setFullYear(date.getFullYear() + 1);
|
|
656
|
-
this._storage.set(this._userStorageKey, user, {
|
|
657
|
-
expires: new Date(date.getTime())
|
|
658
|
-
});
|
|
659
|
-
};
|
|
660
|
-
AuthSession.prototype.setAccessToken = function (value) {
|
|
661
|
-
this._accessTokenString = value !== null && value !== void 0 ? value : null;
|
|
662
|
-
this._accessTokenPayload = this._jwt.decode(this._accessTokenString);
|
|
663
|
-
};
|
|
664
|
-
AuthSession.prototype.setRefreshToken = function (value) {
|
|
665
|
-
this._refreshTokenString = value !== null && value !== void 0 ? value : null;
|
|
666
|
-
this._refreshTokenPayload = this._jwt.decode(this._refreshTokenString);
|
|
667
|
-
};
|
|
668
|
-
return AuthSession;
|
|
669
|
-
}());
|
|
670
|
-
|
|
671
|
-
var Auth = /** @class */ (function () {
|
|
672
|
-
function Auth(_storage, _mapper, _injector, _platform, _httpClient, _config, _state, _httpConfig) {
|
|
673
|
-
var _a, _b, _c;
|
|
674
|
-
this._storage = _storage;
|
|
675
|
-
this._mapper = _mapper;
|
|
676
|
-
this._injector = _injector;
|
|
677
|
-
this._platform = _platform;
|
|
678
|
-
this._httpClient = _httpClient;
|
|
679
|
-
this._config = _config;
|
|
680
|
-
this._state = _state;
|
|
681
|
-
this._httpConfig = _httpConfig;
|
|
682
|
-
// Readonly data.
|
|
683
|
-
this._authStateKey = i6.makeStateKey("bbAuthStateKey");
|
|
684
|
-
this._httpAlias = (_b = (_a = this._httpConfig) === null || _a === void 0 ? void 0 : _a.defaultAlias) !== null && _b !== void 0 ? _b : null;
|
|
685
|
-
this._refreshHandler = null;
|
|
686
|
-
// Starting the new session.
|
|
687
|
-
this.session = new AuthSession({
|
|
688
|
-
id: (_c = this._config) === null || _c === void 0 ? void 0 : _c.applicationId,
|
|
689
|
-
storage: this._storage.select(["cookie" /* Cookie */, "local" /* Local */])
|
|
690
|
-
});
|
|
691
|
-
this.user = this.session.user;
|
|
692
|
-
}
|
|
693
|
-
Auth.prototype.initialize = function () {
|
|
694
|
-
var _this = this;
|
|
695
|
-
return function () { return __awaiter(_this, void 0, void 0, function () {
|
|
696
|
-
var _a, _b, _c, _d, _e, _f, shouldBootstrap, user_1, user;
|
|
697
|
-
return __generator(this, function (_g) {
|
|
698
|
-
switch (_g.label) {
|
|
699
|
-
case 0:
|
|
700
|
-
shouldBootstrap = (_b = (_a = this._config) === null || _a === void 0 ? void 0 : _a.bootstrap) !== null && _b !== void 0 ? _b : true;
|
|
701
|
-
if (!shouldBootstrap) {
|
|
702
|
-
return [2 /*return*/, this.handleAutoRefreshing()];
|
|
703
|
-
}
|
|
704
|
-
// Only retrieve from the server when we are actually authenticated.
|
|
705
|
-
if (!this.session.authenticated()) {
|
|
706
|
-
return [2 /*return*/];
|
|
707
|
-
}
|
|
708
|
-
// Get the key from the server state.
|
|
709
|
-
if (this._state && ((_c = this._state) === null || _c === void 0 ? void 0 : _c.hasKey(this._authStateKey))) {
|
|
710
|
-
user_1 = (_e = (_d = this._state) === null || _d === void 0 ? void 0 : _d.get(this._authStateKey, null)) !== null && _e !== void 0 ? _e : null;
|
|
711
|
-
return [2 /*return*/, this.session.setUser(user_1)];
|
|
712
|
-
}
|
|
713
|
-
return [4 /*yield*/, this.me().pipe(operators.take(1)).toPromise()];
|
|
714
|
-
case 1:
|
|
715
|
-
user = _g.sent();
|
|
716
|
-
// Set the state if exists.
|
|
717
|
-
if (this._state) {
|
|
718
|
-
(_f = this._state) === null || _f === void 0 ? void 0 : _f.set(this._authStateKey, user !== null && user !== void 0 ? user : null);
|
|
719
|
-
}
|
|
720
|
-
// Save the user in the storage and handle auto refreshing.
|
|
721
|
-
this.session.setUser(user);
|
|
722
|
-
this.handleAutoRefreshing();
|
|
723
|
-
return [2 /*return*/];
|
|
724
|
-
}
|
|
725
|
-
});
|
|
726
|
-
}); };
|
|
727
|
-
};
|
|
728
|
-
Auth.prototype.me = function () {
|
|
729
|
-
var url = this.getUrl('auth/me');
|
|
730
|
-
return this._httpClient.get(url);
|
|
731
|
-
};
|
|
732
|
-
Auth.prototype.signIn = function (provider, as) {
|
|
733
|
-
var _a, _b;
|
|
734
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
735
|
-
var _c, accessToken, refreshToken, user, result, apiProvider, apiVerifyToken, availableProviders;
|
|
736
|
-
return __generator(this, function (_g) {
|
|
737
|
-
switch (_g.label) {
|
|
738
|
-
case 0: return [4 /*yield*/, provider.authenticate(this._httpClient)];
|
|
739
|
-
case 1:
|
|
740
|
-
_c = _g.sent(), accessToken = _c.accessToken, refreshToken = _c.refreshToken, user = _c.user, result = __rest(_c, ["accessToken", "refreshToken", "user"]);
|
|
741
|
-
// Check if the role matches.
|
|
742
|
-
if (as && !as.includes(this._mapper.role(user))) {
|
|
743
|
-
throw new Error('Invalid role.');
|
|
744
|
-
}
|
|
745
|
-
apiProvider = (_a = result === null || result === void 0 ? void 0 : result.provider) !== null && _a !== void 0 ? _a : null;
|
|
746
|
-
apiVerifyToken = (_b = result === null || result === void 0 ? void 0 : result.verifyToken) !== null && _b !== void 0 ? _b : null;
|
|
747
|
-
availableProviders = ['email', 'sms', 'totp'];
|
|
748
|
-
if (availableProviders.includes(apiProvider)) {
|
|
749
|
-
return [2 /*return*/, { user: user, provider: apiProvider, verifyToken: apiVerifyToken }];
|
|
750
|
-
}
|
|
751
|
-
// Set the tokens in storage.
|
|
752
|
-
this.setTokens(accessToken, refreshToken);
|
|
753
|
-
// Set the user in storage.
|
|
754
|
-
this.session.setUser(user);
|
|
755
|
-
// Return the user.
|
|
756
|
-
return [2 /*return*/, { user: user }];
|
|
757
|
-
}
|
|
758
|
-
});
|
|
759
|
-
});
|
|
760
|
-
};
|
|
761
|
-
Auth.prototype.signInWithEmail = function (email, password, as) {
|
|
762
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
763
|
-
var url;
|
|
764
|
-
return __generator(this, function (_g) {
|
|
765
|
-
url = this.getUrl('auth/login');
|
|
766
|
-
return [2 /*return*/, this.signIn(new AuthEmailProvider(email, password, url), as)];
|
|
767
|
-
});
|
|
768
|
-
});
|
|
769
|
-
};
|
|
770
|
-
Auth.prototype.signInWithVerifyCode = function (code, verifyToken) {
|
|
771
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
772
|
-
var url;
|
|
773
|
-
return __generator(this, function (_g) {
|
|
774
|
-
url = this.getUrl('auth/verify');
|
|
775
|
-
return [2 /*return*/, this.signIn(new AuthVerifyProvider(code, verifyToken, url))];
|
|
776
|
-
});
|
|
777
|
-
});
|
|
778
|
-
};
|
|
779
|
-
Auth.prototype.resendVerifyCode = function (verifyToken) {
|
|
780
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
781
|
-
var url;
|
|
782
|
-
return __generator(this, function (_g) {
|
|
783
|
-
switch (_g.label) {
|
|
784
|
-
case 0:
|
|
785
|
-
url = this.getUrl('auth/resend');
|
|
786
|
-
return [4 /*yield*/, this._httpClient.post(url, {
|
|
787
|
-
verify_token: verifyToken
|
|
788
|
-
}).toPromise()];
|
|
789
|
-
case 1: return [2 /*return*/, _g.sent()];
|
|
790
|
-
}
|
|
791
|
-
});
|
|
792
|
-
});
|
|
793
|
-
};
|
|
794
|
-
Auth.prototype.register = function (data, options) {
|
|
795
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
796
|
-
var url, result, _g, accessToken, refreshToken, user;
|
|
797
|
-
return __generator(this, function (_h) {
|
|
798
|
-
switch (_h.label) {
|
|
799
|
-
case 0:
|
|
800
|
-
url = this.getUrl('auth/register');
|
|
801
|
-
return [4 /*yield*/, this._httpClient
|
|
802
|
-
.post(url, data, options)
|
|
803
|
-
.toPromise()];
|
|
804
|
-
case 1:
|
|
805
|
-
result = _h.sent();
|
|
806
|
-
_g = this._mapper.toRegister(result), accessToken = _g.accessToken, refreshToken = _g.refreshToken, user = _g.user;
|
|
807
|
-
// Set the tokens in storage.
|
|
808
|
-
this.setTokens(accessToken, refreshToken);
|
|
809
|
-
// Set the user in storage.
|
|
810
|
-
this.session.setUser(user);
|
|
811
|
-
// Return the user.
|
|
812
|
-
return [2 /*return*/, user];
|
|
813
|
-
}
|
|
814
|
-
});
|
|
815
|
-
});
|
|
816
|
-
};
|
|
817
|
-
Auth.prototype.logout = function () {
|
|
818
|
-
// If we don't have a refresh token just clear the session.
|
|
819
|
-
// Note: We do this because else we try to invalidate
|
|
820
|
-
// an "undefined" refresh token.
|
|
821
|
-
var refreshToken = this.session.refreshToken;
|
|
822
|
-
if (!refreshToken) {
|
|
823
|
-
return this.session.clear();
|
|
824
|
-
}
|
|
825
|
-
// We do have a refresh token, so try to
|
|
826
|
-
// invalidate it in the backend.
|
|
827
|
-
try {
|
|
828
|
-
var url = this.getUrl('auth/logout');
|
|
829
|
-
this._httpClient.get(url, {
|
|
830
|
-
headers: { Authorization: refreshToken }
|
|
831
|
-
}).toPromise().then(function (_) { return _; });
|
|
832
|
-
}
|
|
833
|
-
catch (_a) {
|
|
834
|
-
// Do nothing because the tokens will be deleted anyways from the session.
|
|
835
|
-
}
|
|
836
|
-
// Delete the tokens from the session.
|
|
837
|
-
return this.session.clear();
|
|
838
|
-
};
|
|
839
|
-
Auth.prototype.refresh = function () {
|
|
840
|
-
var _this = this;
|
|
841
|
-
var _a, _b;
|
|
842
|
-
// If the refresh token does
|
|
843
|
-
// not exist just return an observable of null.
|
|
844
|
-
var refreshToken = this.session.refreshToken;
|
|
845
|
-
if (!refreshToken) {
|
|
846
|
-
return rxjs.of(null);
|
|
847
|
-
}
|
|
848
|
-
// Perform the refresh call.
|
|
849
|
-
var scheme = (_b = (_a = this._config) === null || _a === void 0 ? void 0 : _a.scheme) !== null && _b !== void 0 ? _b : 'Bearer';
|
|
850
|
-
var url = this.getUrl('auth/refresh');
|
|
851
|
-
var context = new i4.HttpContext()
|
|
852
|
-
.set(USE_AUTHORIZATION, false);
|
|
853
|
-
return this._httpClient.get(url, {
|
|
854
|
-
headers: { Authorization: scheme + " " + refreshToken },
|
|
855
|
-
context: context
|
|
856
|
-
}).pipe(operators.map(function (data) { return _this._mapper.toRefresh(data); }), operators.tap(function (_g) {
|
|
857
|
-
var accessToken = _g.accessToken, refreshToken = _g.refreshToken;
|
|
858
|
-
return _this.setTokens(accessToken, refreshToken);
|
|
859
|
-
}), operators.map(function (_g) {
|
|
860
|
-
var accessToken = _g.accessToken;
|
|
861
|
-
return accessToken;
|
|
862
|
-
}));
|
|
863
|
-
};
|
|
864
|
-
Auth.prototype.requestPassword = function (email, extraParams) {
|
|
865
|
-
if (extraParams === void 0) { extraParams = {}; }
|
|
866
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
867
|
-
var url;
|
|
868
|
-
return __generator(this, function (_g) {
|
|
869
|
-
switch (_g.label) {
|
|
870
|
-
case 0:
|
|
871
|
-
url = this.getUrl('auth/reset');
|
|
872
|
-
return [4 /*yield*/, this._httpClient
|
|
873
|
-
.post(url, Object.assign(Object.assign({}, extraParams), { email: email }))
|
|
874
|
-
.toPromise()];
|
|
875
|
-
case 1: return [2 /*return*/, _g.sent()];
|
|
876
|
-
}
|
|
877
|
-
});
|
|
878
|
-
});
|
|
879
|
-
};
|
|
880
|
-
Auth.prototype.resetPassword = function (token, newPassword, extraParams) {
|
|
881
|
-
if (extraParams === void 0) { extraParams = {}; }
|
|
882
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
883
|
-
var url;
|
|
884
|
-
return __generator(this, function (_g) {
|
|
885
|
-
switch (_g.label) {
|
|
886
|
-
case 0:
|
|
887
|
-
url = this.getUrl('auth/reset-password');
|
|
888
|
-
return [4 /*yield*/, this._httpClient
|
|
889
|
-
.post(url, Object.assign(Object.assign({}, extraParams), { token: token, password: newPassword }))
|
|
890
|
-
.toPromise()];
|
|
891
|
-
case 1: return [2 /*return*/, _g.sent()];
|
|
892
|
-
}
|
|
893
|
-
});
|
|
894
|
-
});
|
|
895
|
-
};
|
|
896
|
-
Auth.prototype.guard = function (type, redirectUrl) {
|
|
897
|
-
var _a, _b, _c, _d, _e, _f;
|
|
898
|
-
var newUrl = null;
|
|
899
|
-
// Get the correct new url.
|
|
900
|
-
switch (type) {
|
|
901
|
-
case 'authenticated':
|
|
902
|
-
newUrl = (_b = (_a = this._config) === null || _a === void 0 ? void 0 : _a.loggedInUrl) !== null && _b !== void 0 ? _b : null;
|
|
903
|
-
break;
|
|
904
|
-
case 'unauthenticated':
|
|
905
|
-
newUrl = (_d = (_c = this._config) === null || _c === void 0 ? void 0 : _c.redirectUrl) !== null && _d !== void 0 ? _d : null;
|
|
906
|
-
break;
|
|
907
|
-
}
|
|
908
|
-
// Append a redirect url if the user is deemed
|
|
909
|
-
// unauthenticated.
|
|
910
|
-
if (type === 'unauthenticated') {
|
|
911
|
-
var setRedirectOnFailedAuth = (_f = (_e = this._config) === null || _e === void 0 ? void 0 : _e.setRedirectOnFailedAuth) !== null && _f !== void 0 ? _f : true;
|
|
912
|
-
if (setRedirectOnFailedAuth && redirectUrl && newUrl) {
|
|
913
|
-
newUrl += "?redirectUrl=" + redirectUrl;
|
|
914
|
-
}
|
|
915
|
-
}
|
|
916
|
-
// Parse the url if it exists.
|
|
917
|
-
if (this.router && newUrl) {
|
|
918
|
-
return this.router.parseUrl(newUrl);
|
|
919
|
-
}
|
|
920
|
-
// Return false if the user is not allowed.
|
|
921
|
-
return false;
|
|
922
|
-
};
|
|
923
|
-
Auth.prototype.clearAndRedirect = function () {
|
|
924
|
-
var _a, _b;
|
|
925
|
-
// 1. Delete the tokens from the session.
|
|
926
|
-
this.session.clear();
|
|
927
|
-
// 2. Compose the route url.
|
|
928
|
-
var redirectUrl = (_b = (_a = this._config) === null || _a === void 0 ? void 0 : _a.redirectUrl) !== null && _b !== void 0 ? _b : null;
|
|
929
|
-
// 3. Route back if the user provided a redirect url.
|
|
930
|
-
if (this.router && redirectUrl) {
|
|
931
|
-
this.router.navigate([redirectUrl]).then(function (_) { return _; });
|
|
932
|
-
}
|
|
933
|
-
};
|
|
934
|
-
Auth.prototype.setTokens = function (accessToken, refreshToken) {
|
|
935
|
-
// Set the tokens in our session.
|
|
936
|
-
this.session.setTokens(accessToken, refreshToken);
|
|
937
|
-
// We need to update the auto refresh of the refresh token.
|
|
938
|
-
this.handleAutoRefreshing();
|
|
939
|
-
};
|
|
940
|
-
Auth.prototype.handleAutoRefreshing = function () {
|
|
941
|
-
var _this = this;
|
|
942
|
-
var _a, _b, _c, _d;
|
|
943
|
-
var shouldAutoRefresh = (_b = (_a = this._config) === null || _a === void 0 ? void 0 : _a.autoRefresh) !== null && _b !== void 0 ? _b : false;
|
|
944
|
-
if (!shouldAutoRefresh) {
|
|
945
|
-
return;
|
|
946
|
-
}
|
|
947
|
-
var expiresAt = (_d = (_c = this.session.refreshTokenPayload) === null || _c === void 0 ? void 0 : _c.expiresAt) !== null && _d !== void 0 ? _d : null;
|
|
948
|
-
if (expiresAt === null || !this._platform.isBrowser) {
|
|
949
|
-
return;
|
|
950
|
-
}
|
|
951
|
-
var differenceInMilliseconds = expiresAt.getTime() - Date.now();
|
|
952
|
-
var offsetInMilliseconds = 10000; // 10 seconds.
|
|
953
|
-
// We want to start the refresh 10 seconds before it expires.
|
|
954
|
-
var actualTiming = differenceInMilliseconds - offsetInMilliseconds;
|
|
955
|
-
if (actualTiming <= 0) {
|
|
956
|
-
return;
|
|
957
|
-
}
|
|
958
|
-
// We need to cap the timings because if
|
|
959
|
-
// we get large numbers it might cause unwanted results.
|
|
960
|
-
var maxTiming = 1000 * 60 * 60 * 24; // 24 hours.
|
|
961
|
-
var cappedTiming = Math.max(1, Math.min(actualTiming, maxTiming));
|
|
962
|
-
try {
|
|
963
|
-
if (this._refreshHandler !== null) {
|
|
964
|
-
clearTimeout === null || clearTimeout === void 0 ? void 0 : clearTimeout(this._refreshHandler);
|
|
965
|
-
this._refreshHandler = null;
|
|
966
|
-
}
|
|
967
|
-
this._refreshHandler = setTimeout === null || setTimeout === void 0 ? void 0 : setTimeout(function () { return _this.autoRefresh(); }, cappedTiming);
|
|
968
|
-
}
|
|
969
|
-
catch (_e) {
|
|
970
|
-
// Just ignore it.
|
|
971
|
-
}
|
|
972
|
-
};
|
|
973
|
-
Auth.prototype.autoRefresh = function () {
|
|
974
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
975
|
-
var _a_1;
|
|
976
|
-
return __generator(this, function (_g) {
|
|
977
|
-
switch (_g.label) {
|
|
978
|
-
case 0:
|
|
979
|
-
_g.trys.push([0, 2, , 3]);
|
|
980
|
-
// We just need to wait for it to refresh.
|
|
981
|
-
return [4 /*yield*/, this.refresh().toPromise()];
|
|
982
|
-
case 1:
|
|
983
|
-
// We just need to wait for it to refresh.
|
|
984
|
-
_g.sent();
|
|
985
|
-
return [3 /*break*/, 3];
|
|
986
|
-
case 2:
|
|
987
|
-
_a_1 = _g.sent();
|
|
988
|
-
// Something went wrong refreshing, we need to clear.
|
|
989
|
-
this.clearAndRedirect();
|
|
990
|
-
return [3 /*break*/, 3];
|
|
991
|
-
case 3: return [2 /*return*/];
|
|
992
|
-
}
|
|
993
|
-
});
|
|
994
|
-
});
|
|
995
|
-
};
|
|
996
|
-
Object.defineProperty(Auth.prototype, "router", {
|
|
997
|
-
get: function () {
|
|
998
|
-
return this._injector.get(router.Router);
|
|
999
|
-
},
|
|
1000
|
-
enumerable: false,
|
|
1001
|
-
configurable: true
|
|
1002
|
-
});
|
|
1003
|
-
Auth.prototype.getUrl = function (endpoint) {
|
|
1004
|
-
return [this._httpAlias, endpoint]
|
|
1005
|
-
.filter(function (item) { return !!item; })
|
|
1006
|
-
.join('/');
|
|
1007
|
-
};
|
|
1008
|
-
return Auth;
|
|
1009
|
-
}());
|
|
1010
|
-
Auth.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0__namespace, type: Auth, deps: [{ token: i1__namespace.Storage }, { token: AuthMapper }, { token: i0__namespace.Injector }, { token: i3__namespace.Platform }, { token: i4__namespace.HttpClient }, { token: AuthConfig, optional: true }, { token: i6__namespace.TransferState, optional: true }, { token: i7__namespace.HttpConfig, optional: true }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
1011
|
-
Auth.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0__namespace, type: Auth });
|
|
1012
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0__namespace, type: Auth, decorators: [{
|
|
1013
|
-
type: i0.Injectable
|
|
1014
|
-
}], ctorParameters: function () {
|
|
1015
|
-
return [{ type: i1__namespace.Storage }, { type: AuthMapper }, { type: i0__namespace.Injector }, { type: i3__namespace.Platform }, { type: i4__namespace.HttpClient }, { type: AuthConfig, decorators: [{
|
|
1016
|
-
type: i0.Optional
|
|
1017
|
-
}] }, { type: i6__namespace.TransferState, decorators: [{
|
|
1018
|
-
type: i0.Optional
|
|
1019
|
-
}] }, { type: i7__namespace.HttpConfig, decorators: [{
|
|
1020
|
-
type: i0.Optional
|
|
1021
|
-
}] }];
|
|
1022
|
-
} });
|
|
1023
|
-
|
|
1024
|
-
var BbAuthenticated = /** @class */ (function () {
|
|
1025
|
-
function BbAuthenticated(_auth, _template, _viewContainerRef) {
|
|
1026
|
-
this._auth = _auth;
|
|
1027
|
-
this._template = _template;
|
|
1028
|
-
this._viewContainerRef = _viewContainerRef;
|
|
1029
|
-
}
|
|
1030
|
-
BbAuthenticated.prototype.ngOnInit = function () {
|
|
1031
|
-
var _this = this;
|
|
1032
|
-
this._subscription = this._auth.user.pipe(operators.map(function (user) { return !!user; }), operators.distinctUntilChanged()).subscribe(function (isAuthenticated) {
|
|
1033
|
-
if (!isAuthenticated) {
|
|
1034
|
-
return _this._viewContainerRef.clear();
|
|
1035
|
-
}
|
|
1036
|
-
_this._viewContainerRef.createEmbeddedView(_this._template);
|
|
1037
|
-
});
|
|
1038
|
-
};
|
|
1039
|
-
BbAuthenticated.prototype.ngOnDestroy = function () {
|
|
1040
|
-
var _a;
|
|
1041
|
-
(_a = this._subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
1042
|
-
};
|
|
1043
|
-
return BbAuthenticated;
|
|
1044
|
-
}());
|
|
1045
|
-
BbAuthenticated.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0__namespace, type: BbAuthenticated, deps: [{ token: Auth }, { token: i0__namespace.TemplateRef }, { token: i0__namespace.ViewContainerRef }], target: i0__namespace.ɵɵFactoryTarget.Directive });
|
|
1046
|
-
BbAuthenticated.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.11", type: BbAuthenticated, selector: "[bbAuthenticated]", ngImport: i0__namespace });
|
|
1047
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0__namespace, type: BbAuthenticated, decorators: [{
|
|
1048
|
-
type: i0.Directive,
|
|
1049
|
-
args: [{
|
|
1050
|
-
selector: '[bbAuthenticated]'
|
|
1051
|
-
}]
|
|
1052
|
-
}], ctorParameters: function () { return [{ type: Auth }, { type: i0__namespace.TemplateRef }, { type: i0__namespace.ViewContainerRef }]; } });
|
|
1053
|
-
|
|
1054
|
-
var BbRole = /** @class */ (function () {
|
|
1055
|
-
function BbRole(_auth, _template, _viewContainerRef) {
|
|
1056
|
-
this._auth = _auth;
|
|
1057
|
-
this._template = _template;
|
|
1058
|
-
this._viewContainerRef = _viewContainerRef;
|
|
1059
|
-
this.getAllowedRoles = function (value) {
|
|
1060
|
-
return Array.isArray(value) ? value : [value];
|
|
1061
|
-
};
|
|
1062
|
-
}
|
|
1063
|
-
BbRole.prototype.ngOnInit = function () {
|
|
1064
|
-
var _this = this;
|
|
1065
|
-
this._subscription = this._auth.user.pipe(operators.map(function (user) { var _a; return (_a = user === null || user === void 0 ? void 0 : user.role) !== null && _a !== void 0 ? _a : null; }), operators.distinctUntilChanged()).subscribe(function (role) {
|
|
1066
|
-
var allowedRoles = _this.getAllowedRoles(_this.bbRole);
|
|
1067
|
-
if (!allowedRoles.includes(role)) {
|
|
1068
|
-
return _this._viewContainerRef.clear();
|
|
1069
|
-
}
|
|
1070
|
-
_this._viewContainerRef.createEmbeddedView(_this._template);
|
|
1071
|
-
});
|
|
1072
|
-
};
|
|
1073
|
-
BbRole.prototype.ngOnDestroy = function () {
|
|
1074
|
-
var _a;
|
|
1075
|
-
(_a = this._subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
1076
|
-
};
|
|
1077
|
-
return BbRole;
|
|
1078
|
-
}());
|
|
1079
|
-
BbRole.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0__namespace, type: BbRole, deps: [{ token: Auth }, { token: i0__namespace.TemplateRef }, { token: i0__namespace.ViewContainerRef }], target: i0__namespace.ɵɵFactoryTarget.Directive });
|
|
1080
|
-
BbRole.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.11", type: BbRole, selector: "[bbRole]", inputs: { bbRole: "bbRole" }, ngImport: i0__namespace });
|
|
1081
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0__namespace, type: BbRole, decorators: [{
|
|
1082
|
-
type: i0.Directive,
|
|
1083
|
-
args: [{
|
|
1084
|
-
selector: '[bbRole]'
|
|
1085
|
-
}]
|
|
1086
|
-
}], ctorParameters: function () { return [{ type: Auth }, { type: i0__namespace.TemplateRef }, { type: i0__namespace.ViewContainerRef }]; }, propDecorators: { bbRole: [{
|
|
1087
|
-
type: i0.Input
|
|
1088
|
-
}] } });
|
|
1089
|
-
|
|
1090
|
-
var Permissions = /** @class */ (function () {
|
|
1091
|
-
function Permissions(_auth, _config) {
|
|
1092
|
-
var _a, _b;
|
|
1093
|
-
this._auth = _auth;
|
|
1094
|
-
this._config = _config;
|
|
1095
|
-
// Data.
|
|
1096
|
-
this._permissions = (_b = (_a = this._config) === null || _a === void 0 ? void 0 : _a.permissions) !== null && _b !== void 0 ? _b : {};
|
|
1097
|
-
this._role$ = this._auth.user.pipe(operators.map(function (user) { var _a; return (_a = user === null || user === void 0 ? void 0 : user.role) !== null && _a !== void 0 ? _a : null; }), operators.distinctUntilChanged());
|
|
1098
|
-
}
|
|
1099
|
-
Permissions.prototype.has = function (value) {
|
|
1100
|
-
var _this = this;
|
|
1101
|
-
var requiredPermissions = Array.isArray(value)
|
|
1102
|
-
? value
|
|
1103
|
-
: [value];
|
|
1104
|
-
return this._role$.pipe(operators.map(function (role) {
|
|
1105
|
-
var e_1, _f;
|
|
1106
|
-
if (role === null || role === undefined) {
|
|
1107
|
-
return false;
|
|
1108
|
-
}
|
|
1109
|
-
try {
|
|
1110
|
-
for (var requiredPermissions_1 = __values(requiredPermissions), requiredPermissions_1_1 = requiredPermissions_1.next(); !requiredPermissions_1_1.done; requiredPermissions_1_1 = requiredPermissions_1.next()) {
|
|
1111
|
-
var requiredPermission = requiredPermissions_1_1.value;
|
|
1112
|
-
var result = _this.validatePermission(requiredPermission, role);
|
|
1113
|
-
if (!result) {
|
|
1114
|
-
return false;
|
|
1115
|
-
}
|
|
1116
|
-
}
|
|
1117
|
-
}
|
|
1118
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1119
|
-
finally {
|
|
1120
|
-
try {
|
|
1121
|
-
if (requiredPermissions_1_1 && !requiredPermissions_1_1.done && (_f = requiredPermissions_1.return)) _f.call(requiredPermissions_1);
|
|
1122
|
-
}
|
|
1123
|
-
finally { if (e_1) throw e_1.error; }
|
|
1124
|
-
}
|
|
1125
|
-
return true;
|
|
1126
|
-
}));
|
|
1127
|
-
};
|
|
1128
|
-
Permissions.prototype.validatePermission = function (type, role) {
|
|
1129
|
-
var _a, _b, _c, _d, _e;
|
|
1130
|
-
var permission = (_b = (_a = this._permissions) === null || _a === void 0 ? void 0 : _a[type]) !== null && _b !== void 0 ? _b : null;
|
|
1131
|
-
if (!permission) {
|
|
1132
|
-
(_c = console === null || console === void 0 ? void 0 : console.warn) === null || _c === void 0 ? void 0 : _c.call(console, "Permissions: Invalid permission requested \"" + type + "\".");
|
|
1133
|
-
return false;
|
|
1134
|
-
}
|
|
1135
|
-
if ((permission === null || permission === void 0 ? void 0 : permission.length) <= 0) {
|
|
1136
|
-
(_d = console === null || console === void 0 ? void 0 : console.warn) === null || _d === void 0 ? void 0 : _d.call(console, "Permissions: No roles were set, please add some roles to this permission.");
|
|
1137
|
-
return false;
|
|
1138
|
-
}
|
|
1139
|
-
// If the permission includes a "*" we allow everyone.
|
|
1140
|
-
if (permission.includes('*')) {
|
|
1141
|
-
return true;
|
|
1142
|
-
}
|
|
1143
|
-
// Validate the role against the permissions.
|
|
1144
|
-
return (_e = permission === null || permission === void 0 ? void 0 : permission.includes(role)) !== null && _e !== void 0 ? _e : false;
|
|
1145
|
-
};
|
|
1146
|
-
return Permissions;
|
|
1147
|
-
}());
|
|
1148
|
-
Permissions.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0__namespace, type: Permissions, deps: [{ token: Auth }, { token: AuthConfig, optional: true }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
1149
|
-
Permissions.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0__namespace, type: Permissions });
|
|
1150
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0__namespace, type: Permissions, decorators: [{
|
|
1151
|
-
type: i0.Injectable
|
|
1152
|
-
}], ctorParameters: function () {
|
|
1153
|
-
return [{ type: Auth }, { type: AuthConfig, decorators: [{
|
|
1154
|
-
type: i0.Optional
|
|
1155
|
-
}] }];
|
|
1156
|
-
} });
|
|
1157
|
-
|
|
1158
|
-
var BbPermission = /** @class */ (function () {
|
|
1159
|
-
function BbPermission(_permissions, _templateRef, _viewContainerRef) {
|
|
1160
|
-
this._permissions = _permissions;
|
|
1161
|
-
this._templateRef = _templateRef;
|
|
1162
|
-
this._viewContainerRef = _viewContainerRef;
|
|
1163
|
-
// Data.
|
|
1164
|
-
this._permission$ = new rxjs.BehaviorSubject([]);
|
|
1165
|
-
this._valid = false;
|
|
1166
|
-
this._elseTemplateRef = null;
|
|
1167
|
-
this._thenViewRef = null;
|
|
1168
|
-
this._elseViewRef = null;
|
|
1169
|
-
this.getAllowedPermissions = function (value) {
|
|
1170
|
-
return Array.isArray(value) ? value : [value];
|
|
1171
|
-
};
|
|
1172
|
-
this.assertTemplate = function (property, templateRef) {
|
|
1173
|
-
var isTemplateRefOrNull = !!(!templateRef || templateRef.createEmbeddedView);
|
|
1174
|
-
if (!isTemplateRefOrNull) {
|
|
1175
|
-
throw new Error(property + " must be a TemplateRef.");
|
|
1176
|
-
}
|
|
1177
|
-
};
|
|
1178
|
-
}
|
|
1179
|
-
Object.defineProperty(BbPermission.prototype, "bbPermission", {
|
|
1180
|
-
set: function (value) {
|
|
1181
|
-
var permissions = this.getAllowedPermissions(value);
|
|
1182
|
-
this._permission$.next(permissions);
|
|
1183
|
-
this.updateView();
|
|
1184
|
-
},
|
|
1185
|
-
enumerable: false,
|
|
1186
|
-
configurable: true
|
|
1187
|
-
});
|
|
1188
|
-
Object.defineProperty(BbPermission.prototype, "bbPermissionElse", {
|
|
1189
|
-
set: function (templateRef) {
|
|
1190
|
-
this.assertTemplate('bbPermissionElse', templateRef);
|
|
1191
|
-
this._elseTemplateRef = templateRef;
|
|
1192
|
-
this.updateView();
|
|
1193
|
-
},
|
|
1194
|
-
enumerable: false,
|
|
1195
|
-
configurable: true
|
|
1196
|
-
});
|
|
1197
|
-
BbPermission.prototype.ngOnInit = function () {
|
|
1198
|
-
var _this = this;
|
|
1199
|
-
var check$ = this._permission$.pipe(operators.switchMap(function (permissions) { return _this._permissions.has(permissions); }));
|
|
1200
|
-
this._subscription = check$.subscribe(function (valid) {
|
|
1201
|
-
_this._valid = valid;
|
|
1202
|
-
_this.updateView();
|
|
1203
|
-
});
|
|
1204
|
-
};
|
|
1205
|
-
BbPermission.prototype.ngOnDestroy = function () {
|
|
1206
|
-
var _a;
|
|
1207
|
-
(_a = this._subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
1208
|
-
};
|
|
1209
|
-
BbPermission.prototype.updateView = function () {
|
|
1210
|
-
if (this._valid) {
|
|
1211
|
-
if (!this._thenViewRef) {
|
|
1212
|
-
this._viewContainerRef.clear();
|
|
1213
|
-
this._elseViewRef = null;
|
|
1214
|
-
if (this._templateRef) {
|
|
1215
|
-
this._thenViewRef = this._viewContainerRef.createEmbeddedView(this._templateRef);
|
|
1216
|
-
}
|
|
1217
|
-
}
|
|
1218
|
-
}
|
|
1219
|
-
else {
|
|
1220
|
-
if (!this._elseViewRef) {
|
|
1221
|
-
this._viewContainerRef.clear();
|
|
1222
|
-
this._thenViewRef = null;
|
|
1223
|
-
if (this._elseTemplateRef) {
|
|
1224
|
-
this._elseViewRef = this._viewContainerRef.createEmbeddedView(this._elseTemplateRef);
|
|
1225
|
-
}
|
|
1226
|
-
}
|
|
1227
|
-
}
|
|
1228
|
-
};
|
|
1229
|
-
return BbPermission;
|
|
1230
|
-
}());
|
|
1231
|
-
BbPermission.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0__namespace, type: BbPermission, deps: [{ token: Permissions }, { token: i0__namespace.TemplateRef }, { token: i0__namespace.ViewContainerRef }], target: i0__namespace.ɵɵFactoryTarget.Directive });
|
|
1232
|
-
BbPermission.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.11", type: BbPermission, selector: "[bbPermission]", inputs: { bbPermission: "bbPermission", bbPermissionElse: "bbPermissionElse" }, ngImport: i0__namespace });
|
|
1233
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0__namespace, type: BbPermission, decorators: [{
|
|
1234
|
-
type: i0.Directive,
|
|
1235
|
-
args: [{
|
|
1236
|
-
selector: '[bbPermission]'
|
|
1237
|
-
}]
|
|
1238
|
-
}], ctorParameters: function () { return [{ type: Permissions }, { type: i0__namespace.TemplateRef }, { type: i0__namespace.ViewContainerRef }]; }, propDecorators: { bbPermission: [{
|
|
1239
|
-
type: i0.Input
|
|
1240
|
-
}], bbPermissionElse: [{
|
|
1241
|
-
type: i0.Input
|
|
1242
|
-
}] } });
|
|
1243
|
-
|
|
1244
|
-
var BbAnonymousGuard = /** @class */ (function () {
|
|
1245
|
-
function BbAnonymousGuard(_auth) {
|
|
1246
|
-
this._auth = _auth;
|
|
1247
|
-
}
|
|
1248
|
-
BbAnonymousGuard.prototype.canActivate = function (_, state) {
|
|
1249
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1250
|
-
var isAuthenticated;
|
|
1251
|
-
return __generator(this, function (_a) {
|
|
1252
|
-
switch (_a.label) {
|
|
1253
|
-
case 0: return [4 /*yield*/, this._auth.user.pipe(operators.map(function (user) { return !!user; }), operators.first()).toPromise()];
|
|
1254
|
-
case 1:
|
|
1255
|
-
isAuthenticated = _a.sent();
|
|
1256
|
-
// If the user is not authenticated it can
|
|
1257
|
-
// access the anonymous page.
|
|
1258
|
-
if (!isAuthenticated) {
|
|
1259
|
-
return [2 /*return*/, true];
|
|
1260
|
-
}
|
|
1261
|
-
// Return the user back to the authenticated page.
|
|
1262
|
-
return [2 /*return*/, this._auth.guard('authenticated', state.url)];
|
|
1263
|
-
}
|
|
1264
|
-
});
|
|
1265
|
-
});
|
|
1266
|
-
};
|
|
1267
|
-
BbAnonymousGuard.prototype.canActivateChild = function (childRoute, state) {
|
|
1268
|
-
return this.canActivate(childRoute, state);
|
|
1269
|
-
};
|
|
1270
|
-
return BbAnonymousGuard;
|
|
1271
|
-
}());
|
|
1272
|
-
BbAnonymousGuard.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0__namespace, type: BbAnonymousGuard, deps: [{ token: Auth }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
1273
|
-
BbAnonymousGuard.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0__namespace, type: BbAnonymousGuard, providedIn: 'root' });
|
|
1274
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0__namespace, type: BbAnonymousGuard, decorators: [{
|
|
1275
|
-
type: i0.Injectable,
|
|
1276
|
-
args: [{
|
|
1277
|
-
providedIn: 'root'
|
|
1278
|
-
}]
|
|
1279
|
-
}], ctorParameters: function () { return [{ type: Auth }]; } });
|
|
1280
|
-
|
|
1281
|
-
var BbAuthenticatedGuard = /** @class */ (function () {
|
|
1282
|
-
function BbAuthenticatedGuard(_auth) {
|
|
1283
|
-
this._auth = _auth;
|
|
1284
|
-
}
|
|
1285
|
-
BbAuthenticatedGuard.prototype.canActivate = function (_, state) {
|
|
1286
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1287
|
-
var isAuthenticated;
|
|
1288
|
-
return __generator(this, function (_a) {
|
|
1289
|
-
switch (_a.label) {
|
|
1290
|
-
case 0: return [4 /*yield*/, this._auth.user.pipe(operators.map(function (user) { return !!user; }), operators.first()).toPromise()];
|
|
1291
|
-
case 1:
|
|
1292
|
-
isAuthenticated = _a.sent();
|
|
1293
|
-
// If the user is authenticated it can
|
|
1294
|
-
// access the authenticated page.
|
|
1295
|
-
if (isAuthenticated) {
|
|
1296
|
-
return [2 /*return*/, true];
|
|
1297
|
-
}
|
|
1298
|
-
// The user is not authorized to see that
|
|
1299
|
-
// page so un-authorize him.
|
|
1300
|
-
return [2 /*return*/, this._auth.guard('unauthenticated', state.url)];
|
|
1301
|
-
}
|
|
1302
|
-
});
|
|
1303
|
-
});
|
|
1304
|
-
};
|
|
1305
|
-
BbAuthenticatedGuard.prototype.canActivateChild = function (childRoute, state) {
|
|
1306
|
-
return this.canActivate(childRoute, state);
|
|
1307
|
-
};
|
|
1308
|
-
return BbAuthenticatedGuard;
|
|
1309
|
-
}());
|
|
1310
|
-
BbAuthenticatedGuard.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0__namespace, type: BbAuthenticatedGuard, deps: [{ token: Auth }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
1311
|
-
BbAuthenticatedGuard.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0__namespace, type: BbAuthenticatedGuard, providedIn: 'root' });
|
|
1312
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0__namespace, type: BbAuthenticatedGuard, decorators: [{
|
|
1313
|
-
type: i0.Injectable,
|
|
1314
|
-
args: [{
|
|
1315
|
-
providedIn: 'root'
|
|
1316
|
-
}]
|
|
1317
|
-
}], ctorParameters: function () { return [{ type: Auth }]; } });
|
|
1318
|
-
|
|
1319
|
-
var AuthInterceptor = /** @class */ (function () {
|
|
1320
|
-
function AuthInterceptor(_auth, _config) {
|
|
1321
|
-
var _this = this;
|
|
1322
|
-
this._auth = _auth;
|
|
1323
|
-
this._config = _config;
|
|
1324
|
-
// Readonly data.
|
|
1325
|
-
this._authHeaderString = 'Authorization';
|
|
1326
|
-
// Data.
|
|
1327
|
-
this.isRefreshing = false;
|
|
1328
|
-
this.refreshingAccessToken$ = new rxjs.BehaviorSubject(null);
|
|
1329
|
-
this.getAccessToken = function (request) {
|
|
1330
|
-
// Get the token based on header.
|
|
1331
|
-
if (request.headers.has('Authorization')) {
|
|
1332
|
-
return request.headers.get('Authorization');
|
|
1333
|
-
}
|
|
1334
|
-
// Return the default access token.
|
|
1335
|
-
return _this._auth.session.accessToken;
|
|
1336
|
-
};
|
|
1337
|
-
this.addAuthorizationHeader = function (request, accessToken) {
|
|
1338
|
-
var _c;
|
|
1339
|
-
if (accessToken === void 0) { accessToken = null; }
|
|
1340
|
-
// Remove auth header when we do not have
|
|
1341
|
-
// an access token.
|
|
1342
|
-
if (!accessToken) {
|
|
1343
|
-
return request.clone({
|
|
1344
|
-
headers: request.headers.delete(_this._authHeaderString)
|
|
1345
|
-
});
|
|
1346
|
-
}
|
|
1347
|
-
// Add the auth header to the request.
|
|
1348
|
-
return request.clone({
|
|
1349
|
-
setHeaders: (_c = {}, _c[_this._authHeaderString] = _this.getFullAuthorizationHeader(accessToken), _c)
|
|
1350
|
-
});
|
|
1351
|
-
};
|
|
1352
|
-
this.getFullAuthorizationHeader = function (token) {
|
|
1353
|
-
var _a, _b;
|
|
1354
|
-
var authScheme = (_b = (_a = _this._config) === null || _a === void 0 ? void 0 : _a.scheme) !== null && _b !== void 0 ? _b : 'Bearer';
|
|
1355
|
-
return [authScheme, token].join(' ');
|
|
1356
|
-
};
|
|
1357
|
-
}
|
|
1358
|
-
AuthInterceptor.prototype.intercept = function (request, next) {
|
|
1359
|
-
var _this = this;
|
|
1360
|
-
// 1. Check if the user wants to use the authorization for this request.
|
|
1361
|
-
if (!request.context.get(USE_AUTHORIZATION)) {
|
|
1362
|
-
return next.handle(request);
|
|
1363
|
-
}
|
|
1364
|
-
// 2. Compose the new request.
|
|
1365
|
-
var accessToken = this.getAccessToken(request);
|
|
1366
|
-
var newRequest = this.addAuthorizationHeader(request, accessToken);
|
|
1367
|
-
// 3. Handle all errors.
|
|
1368
|
-
return next.handle(newRequest).pipe(operators.catchError(function (error) {
|
|
1369
|
-
// Handle the HTTP401 error.
|
|
1370
|
-
if ((error instanceof i4.HttpErrorResponse || error instanceof i7.HttpError) && (error === null || error === void 0 ? void 0 : error.status) === 401) {
|
|
1371
|
-
return _this.handle401Error(request, next);
|
|
1372
|
-
}
|
|
1373
|
-
// Just re-throw the parsed error.
|
|
1374
|
-
return rxjs.throwError(error);
|
|
1375
|
-
}));
|
|
1376
|
-
};
|
|
1377
|
-
AuthInterceptor.prototype.handle401Error = function (request, next) {
|
|
1378
|
-
var _this = this;
|
|
1379
|
-
// If already refreshing wait for the refresh token to complete.
|
|
1380
|
-
if (this.isRefreshing) {
|
|
1381
|
-
return this.refreshingAccessToken$.pipe(operators.filter(function (accessToken) { return accessToken !== null; }), operators.take(1), operators.switchMap(function (accessToken) { return next.handle(_this.addAuthorizationHeader(request, accessToken)); }));
|
|
1382
|
-
}
|
|
1383
|
-
// Set the refreshing to true.
|
|
1384
|
-
this.isRefreshing = true;
|
|
1385
|
-
this.refreshingAccessToken$.next(null);
|
|
1386
|
-
return this._auth.refresh().pipe(operators.switchMap(function (newAccessToken) {
|
|
1387
|
-
if (!newAccessToken) {
|
|
1388
|
-
var error = new Error('No refresh token was available.');
|
|
1389
|
-
return rxjs.throwError(error);
|
|
1390
|
-
}
|
|
1391
|
-
_this.refreshingAccessToken$.next(newAccessToken);
|
|
1392
|
-
return next.handle(_this.addAuthorizationHeader(request, newAccessToken));
|
|
1393
|
-
}), operators.catchError(function () { return _this.logoutUser(); }), operators.finalize(function () { return _this.isRefreshing = false; }));
|
|
1394
|
-
};
|
|
1395
|
-
AuthInterceptor.prototype.logoutUser = function () {
|
|
1396
|
-
// Handle the refresh error.
|
|
1397
|
-
this._auth.clearAndRedirect();
|
|
1398
|
-
// Return null as data.
|
|
1399
|
-
return rxjs.of(null);
|
|
1400
|
-
};
|
|
1401
|
-
return AuthInterceptor;
|
|
1402
|
-
}());
|
|
1403
|
-
AuthInterceptor.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0__namespace, type: AuthInterceptor, deps: [{ token: Auth }, { token: AuthConfig, optional: true }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
1404
|
-
AuthInterceptor.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0__namespace, type: AuthInterceptor });
|
|
1405
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0__namespace, type: AuthInterceptor, decorators: [{
|
|
1406
|
-
type: i0.Injectable
|
|
1407
|
-
}], ctorParameters: function () {
|
|
1408
|
-
return [{ type: Auth }, { type: AuthConfig, decorators: [{
|
|
1409
|
-
type: i0.Optional
|
|
1410
|
-
}] }];
|
|
1411
|
-
} });
|
|
1412
|
-
|
|
1413
|
-
var DECLARATIONS_EXPORTS = [
|
|
1414
|
-
BbAuthenticated,
|
|
1415
|
-
BbRole,
|
|
1416
|
-
BbPermission
|
|
1417
|
-
];
|
|
1418
|
-
var AuthModule = /** @class */ (function () {
|
|
1419
|
-
function AuthModule() {
|
|
1420
|
-
}
|
|
1421
|
-
AuthModule.forRoot = function (config) {
|
|
1422
|
-
return {
|
|
1423
|
-
ngModule: AuthModule,
|
|
1424
|
-
providers: [
|
|
1425
|
-
Auth,
|
|
1426
|
-
Permissions,
|
|
1427
|
-
{ provide: AuthConfig, useValue: config },
|
|
1428
|
-
{ provide: i4.HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true },
|
|
1429
|
-
{ useFactory: initializeAuth, provide: i0.APP_INITIALIZER, deps: [Auth], multi: true }
|
|
1430
|
-
]
|
|
1431
|
-
};
|
|
1432
|
-
};
|
|
1433
|
-
return AuthModule;
|
|
1434
|
-
}());
|
|
1435
|
-
AuthModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0__namespace, type: AuthModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
|
|
1436
|
-
AuthModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0__namespace, type: AuthModule, declarations: [BbAuthenticated,
|
|
1437
|
-
BbRole,
|
|
1438
|
-
BbPermission], imports: [i4.HttpClientModule], exports: [BbAuthenticated,
|
|
1439
|
-
BbRole,
|
|
1440
|
-
BbPermission] });
|
|
1441
|
-
AuthModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0__namespace, type: AuthModule, providers: [
|
|
1442
|
-
{ provide: AuthMapper, useClass: AuthMapper }
|
|
1443
|
-
], imports: [[i4.HttpClientModule]] });
|
|
1444
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0__namespace, type: AuthModule, decorators: [{
|
|
1445
|
-
type: i0.NgModule,
|
|
1446
|
-
args: [{
|
|
1447
|
-
imports: [i4.HttpClientModule],
|
|
1448
|
-
declarations: __spreadArray([], __read(DECLARATIONS_EXPORTS)),
|
|
1449
|
-
exports: __spreadArray([], __read(DECLARATIONS_EXPORTS)),
|
|
1450
|
-
providers: [
|
|
1451
|
-
{ provide: AuthMapper, useClass: AuthMapper }
|
|
1452
|
-
]
|
|
1453
|
-
}]
|
|
1454
|
-
}] });
|
|
1455
|
-
function initializeAuth(auth) {
|
|
1456
|
-
return auth.initialize();
|
|
1457
|
-
}
|
|
1458
|
-
|
|
1459
|
-
/**
|
|
1460
|
-
* Generated bundle index. Do not edit.
|
|
1461
|
-
*/
|
|
1462
|
-
|
|
1463
|
-
exports.Auth = Auth;
|
|
1464
|
-
exports.AuthConfig = AuthConfig;
|
|
1465
|
-
exports.AuthEmailProvider = AuthEmailProvider;
|
|
1466
|
-
exports.AuthMapper = AuthMapper;
|
|
1467
|
-
exports.AuthModule = AuthModule;
|
|
1468
|
-
exports.AuthSession = AuthSession;
|
|
1469
|
-
exports.AuthVerifyProvider = AuthVerifyProvider;
|
|
1470
|
-
exports.BbAnonymousGuard = BbAnonymousGuard;
|
|
1471
|
-
exports.BbAuthenticated = BbAuthenticated;
|
|
1472
|
-
exports.BbAuthenticatedGuard = BbAuthenticatedGuard;
|
|
1473
|
-
exports.BbPermission = BbPermission;
|
|
1474
|
-
exports.BbRole = BbRole;
|
|
1475
|
-
exports.JwtHelper = JwtHelper;
|
|
1476
|
-
exports.Permissions = Permissions;
|
|
1477
|
-
exports.USE_AUTHORIZATION = USE_AUTHORIZATION;
|
|
1478
|
-
exports.initializeAuth = initializeAuth;
|
|
1479
|
-
|
|
1480
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1481
|
-
|
|
1482
|
-
}));
|
|
1483
|
-
//# sourceMappingURL=bravobit-bb-foundation-auth.umd.js.map
|