@bravobit/bb-foundation 0.26.3 → 0.28.0

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