@bravobit/bb-foundation 0.21.1 → 0.21.2

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