@bravobit/bb-foundation 0.23.6 → 0.24.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 (209) hide show
  1. package/auth/lib/auth.module.d.ts +2 -3
  2. package/auth/lib/auth.session.d.ts +5 -0
  3. package/auth/lib/interfaces/config.interface.d.ts +0 -4
  4. package/auth/public_api.d.ts +0 -5
  5. package/esm2020/auth/lib/auth.interceptor.mjs +4 -4
  6. package/esm2020/auth/lib/auth.module.mjs +7 -16
  7. package/esm2020/auth/lib/auth.service.mjs +6 -6
  8. package/esm2020/auth/lib/auth.session.mjs +8 -1
  9. package/esm2020/auth/lib/directives/authenticated.directive.mjs +4 -4
  10. package/esm2020/auth/lib/guards/anonymous.guard.mjs +4 -4
  11. package/esm2020/auth/lib/guards/authenticated.guard.mjs +4 -4
  12. package/esm2020/auth/lib/interfaces/config.interface.mjs +1 -1
  13. package/esm2020/auth/public_api.mjs +1 -6
  14. package/esm2020/collections/lib/collections.module.mjs +5 -5
  15. package/esm2020/collections/lib/components/collections-pager/collections-pager.component.mjs +4 -4
  16. package/esm2020/collections/lib/components/collections-viewer/collections-viewer.component.mjs +4 -4
  17. package/esm2020/collections/lib/components/collections.directive.mjs +13 -13
  18. package/esm2020/controls/lib/checkbox/checkbox/checkbox.component.mjs +4 -4
  19. package/esm2020/controls/lib/checkbox/checkbox-group/checkbox-group.component.mjs +4 -4
  20. package/esm2020/controls/lib/checkbox/checkbox.module.mjs +5 -5
  21. package/esm2020/controls/lib/control-error/control-error/control-error.component.mjs +4 -4
  22. package/esm2020/controls/lib/control-error/control-error-submit.directive.mjs +4 -4
  23. package/esm2020/controls/lib/control-error/control-error.module.mjs +5 -5
  24. package/esm2020/controls/lib/controls.module.mjs +5 -5
  25. package/esm2020/controls/lib/form-control/form-control/form-control.component.mjs +4 -4
  26. package/esm2020/controls/lib/form-control/form-control-addon/form-control-addon.component.mjs +4 -4
  27. package/esm2020/controls/lib/form-control/form-control-input.directive.mjs +4 -4
  28. package/esm2020/controls/lib/form-control/form-control.module.mjs +5 -5
  29. package/esm2020/controls/lib/radio/radio-button/radio-button.component.mjs +4 -4
  30. package/esm2020/controls/lib/radio/radio-group/radio-group.component.mjs +4 -4
  31. package/esm2020/controls/lib/radio/radio.module.mjs +5 -5
  32. package/esm2020/controls/lib/toggle/toggle/toggle.component.mjs +4 -4
  33. package/esm2020/controls/lib/toggle/toggle-group/toggle-group.component.mjs +4 -4
  34. package/esm2020/controls/lib/toggle/toggle.module.mjs +5 -5
  35. package/esm2020/dashboard/lib/dashboard/dashboard.component.mjs +4 -4
  36. package/esm2020/dashboard/lib/dashboard-header/dashboard-header.component.mjs +4 -4
  37. package/esm2020/dashboard/lib/dashboard-menu/dashboard-menu.component.mjs +4 -4
  38. package/esm2020/dashboard/lib/dashboard-menu-item/dashboard-menu-item.component.mjs +4 -4
  39. package/esm2020/dashboard/lib/dashboard-sidebar/dashboard-sidebar.component.mjs +4 -4
  40. package/esm2020/dashboard/lib/dashboard-sidebar-group/dashboard-sidebar-group.component.mjs +4 -4
  41. package/esm2020/dashboard/lib/dashboard-sidebar-item/dashboard-sidebar-item.component.mjs +4 -4
  42. package/esm2020/dashboard/lib/dashboard.module.mjs +5 -5
  43. package/esm2020/dialog/lib/dialog-actions/dialog-actions.component.mjs +4 -4
  44. package/esm2020/dialog/lib/dialog-confirm/dialog-confirm.component.mjs +4 -4
  45. package/esm2020/dialog/lib/dialog-container/dialog-container.component.mjs +4 -4
  46. package/esm2020/dialog/lib/dialog-header/dialog-header.component.mjs +4 -4
  47. package/esm2020/dialog/lib/dialog-link/dialog-link.component.mjs +4 -4
  48. package/esm2020/dialog/lib/dialog-modal/dialog-modal.component.mjs +4 -4
  49. package/esm2020/dialog/lib/dialog-overlay/dialog-overlay.component.mjs +4 -4
  50. package/esm2020/dialog/lib/dialog.insertion.mjs +4 -4
  51. package/esm2020/dialog/lib/dialog.module.mjs +5 -5
  52. package/esm2020/dialog/lib/dialog.service.mjs +4 -4
  53. package/esm2020/elements/lib/avatar/avatar.component.mjs +4 -4
  54. package/esm2020/elements/lib/button/button.component.mjs +7 -7
  55. package/esm2020/elements/lib/checkbox/checkbox.component.mjs +4 -4
  56. package/esm2020/elements/lib/date-picker/date-picker.component.mjs +4 -4
  57. package/esm2020/elements/lib/directives/addon.directive.mjs +7 -7
  58. package/esm2020/elements/lib/directives/form-submit.directive.mjs +4 -4
  59. package/esm2020/elements/lib/directives/form-submitter.directive.mjs +4 -4
  60. package/esm2020/elements/lib/directives/input.directive.mjs +7 -7
  61. package/esm2020/elements/lib/dropdown/dropdown.component.mjs +7 -7
  62. package/esm2020/elements/lib/elements.module.mjs +5 -5
  63. package/esm2020/elements/lib/file-picker/file-picker.component.mjs +4 -4
  64. package/esm2020/elements/lib/form-control/form-control.component.mjs +4 -4
  65. package/esm2020/elements/lib/form-error/form-error.component.mjs +4 -4
  66. package/esm2020/elements/lib/form-group/form-group.component.mjs +4 -4
  67. package/esm2020/elements/lib/icon/icon.component.mjs +4 -4
  68. package/esm2020/elements/lib/image-picker/image-picker.component.mjs +4 -4
  69. package/esm2020/elements/lib/pipes/file-image.pipe.mjs +4 -4
  70. package/esm2020/elements/lib/pipes/file-size.pipe.mjs +4 -4
  71. package/esm2020/elements/lib/pipes/relative-time.pipe.mjs +4 -4
  72. package/esm2020/elements/lib/spinner/spinner.component.mjs +4 -4
  73. package/esm2020/elements/lib/tag/tag.component.mjs +4 -4
  74. package/esm2020/http/lib/http.module.mjs +5 -5
  75. package/esm2020/http/lib/interceptors/base-url.interceptor.mjs +4 -4
  76. package/esm2020/http/lib/interceptors/error.interceptor.mjs +4 -4
  77. package/esm2020/lib/core/services/clipboard.service.mjs +4 -4
  78. package/esm2020/lib/core/services/exif.service.mjs +4 -4
  79. package/esm2020/lib/core/services/file-loader.service.mjs +4 -4
  80. package/esm2020/lib/core/services/image-converter.service.mjs +4 -4
  81. package/esm2020/lib/core/services/languages.service.mjs +4 -4
  82. package/esm2020/lib/core/services/network.service.mjs +4 -4
  83. package/esm2020/lib/core/services/patch.service.mjs +4 -4
  84. package/esm2020/localize/lib/localize.module.mjs +5 -5
  85. package/esm2020/localize/lib/localize.pipe.mjs +4 -4
  86. package/esm2020/localize/lib/localize.service.mjs +4 -4
  87. package/esm2020/localize/lib/views/localize-string/localize-string.component.mjs +4 -4
  88. package/esm2020/localize/lib/views/localize-template.directive.mjs +4 -4
  89. package/esm2020/masking/lib/directives/currency-mask.directive.mjs +4 -4
  90. package/esm2020/masking/lib/directives/date-mask.directive.mjs +4 -4
  91. package/esm2020/masking/lib/directives/input-mask.directive.mjs +4 -4
  92. package/esm2020/masking/lib/masking.module.mjs +5 -5
  93. package/esm2020/masking/lib/masking.service.mjs +4 -4
  94. package/esm2020/notifications/lib/notifications-item/notifications-item.component.mjs +4 -4
  95. package/esm2020/notifications/lib/notifications-list/notifications-list.component.mjs +4 -4
  96. package/esm2020/notifications/lib/notifications.module.mjs +5 -5
  97. package/esm2020/notifications/lib/notifications.service.mjs +4 -4
  98. package/esm2020/permissions/bravobit-bb-foundation-permissions.mjs +5 -0
  99. package/esm2020/permissions/lib/directives/permission.directive.mjs +88 -0
  100. package/esm2020/permissions/lib/guards/permission.guard.mjs +57 -0
  101. package/esm2020/permissions/lib/handlers/abstract.handler.mjs +3 -0
  102. package/esm2020/permissions/lib/handlers/role.handler.mjs +27 -0
  103. package/esm2020/permissions/lib/permissions.interface.mjs +3 -0
  104. package/esm2020/permissions/lib/permissions.module.mjs +39 -0
  105. package/esm2020/permissions/lib/permissions.service.mjs +86 -0
  106. package/esm2020/permissions/public_api.mjs +8 -0
  107. package/esm2020/recaptcha/lib/recaptcha/recaptcha.component.mjs +4 -4
  108. package/esm2020/recaptcha/lib/recaptcha-loader.service.mjs +4 -4
  109. package/esm2020/recaptcha/lib/recaptcha.module.mjs +5 -5
  110. package/esm2020/storage/lib/storage.service.mjs +4 -4
  111. package/esm2020/table/lib/components/table/table.component.mjs +10 -10
  112. package/esm2020/table/lib/components/table-cell/table-cell.component.mjs +4 -4
  113. package/esm2020/table/lib/components/table-header-cell/table-header-cell.component.mjs +4 -4
  114. package/esm2020/table/lib/components/table-pager/table-pager.component.mjs +4 -4
  115. package/esm2020/table/lib/table.module.mjs +5 -5
  116. package/esm2020/theming/lib/theming.directive.mjs +4 -4
  117. package/esm2020/theming/lib/theming.module.mjs +5 -5
  118. package/esm2020/utils/lib/directives/autosize.directive.mjs +4 -4
  119. package/esm2020/utils/lib/directives/focus-trap.directive.mjs +4 -4
  120. package/esm2020/utils/lib/directives/focus.directive.mjs +4 -4
  121. package/esm2020/utils/lib/directives/template.directive.mjs +4 -4
  122. package/esm2020/utils/lib/utils.module.mjs +5 -5
  123. package/fesm2015/bravobit-bb-foundation-auth.mjs +40 -254
  124. package/fesm2015/bravobit-bb-foundation-auth.mjs.map +1 -1
  125. package/fesm2015/bravobit-bb-foundation-collections.mjs +22 -22
  126. package/fesm2015/bravobit-bb-foundation-collections.mjs.map +1 -1
  127. package/fesm2015/bravobit-bb-foundation-controls.mjs +57 -57
  128. package/fesm2015/bravobit-bb-foundation-controls.mjs.map +1 -1
  129. package/fesm2015/bravobit-bb-foundation-dashboard.mjs +25 -25
  130. package/fesm2015/bravobit-bb-foundation-dashboard.mjs.map +1 -1
  131. package/fesm2015/bravobit-bb-foundation-dialog.mjs +31 -31
  132. package/fesm2015/bravobit-bb-foundation-dialog.mjs.map +1 -1
  133. package/fesm2015/bravobit-bb-foundation-elements.mjs +76 -76
  134. package/fesm2015/bravobit-bb-foundation-elements.mjs.map +1 -1
  135. package/fesm2015/bravobit-bb-foundation-http.mjs +10 -10
  136. package/fesm2015/bravobit-bb-foundation-http.mjs.map +1 -1
  137. package/fesm2015/bravobit-bb-foundation-localize.mjs +16 -16
  138. package/fesm2015/bravobit-bb-foundation-localize.mjs.map +1 -1
  139. package/fesm2015/bravobit-bb-foundation-masking.mjs +16 -16
  140. package/fesm2015/bravobit-bb-foundation-masking.mjs.map +1 -1
  141. package/fesm2015/bravobit-bb-foundation-notifications.mjs +13 -13
  142. package/fesm2015/bravobit-bb-foundation-notifications.mjs.map +1 -1
  143. package/fesm2015/bravobit-bb-foundation-permissions.mjs +301 -0
  144. package/fesm2015/bravobit-bb-foundation-permissions.mjs.map +1 -0
  145. package/fesm2015/bravobit-bb-foundation-recaptcha.mjs +10 -10
  146. package/fesm2015/bravobit-bb-foundation-recaptcha.mjs.map +1 -1
  147. package/fesm2015/bravobit-bb-foundation-storage.mjs +3 -3
  148. package/fesm2015/bravobit-bb-foundation-storage.mjs.map +1 -1
  149. package/fesm2015/bravobit-bb-foundation-table.mjs +22 -22
  150. package/fesm2015/bravobit-bb-foundation-table.mjs.map +1 -1
  151. package/fesm2015/bravobit-bb-foundation-theming.mjs +7 -7
  152. package/fesm2015/bravobit-bb-foundation-theming.mjs.map +1 -1
  153. package/fesm2015/bravobit-bb-foundation-utils.mjs +16 -16
  154. package/fesm2015/bravobit-bb-foundation-utils.mjs.map +1 -1
  155. package/fesm2015/bravobit-bb-foundation.mjs +21 -21
  156. package/fesm2015/bravobit-bb-foundation.mjs.map +1 -1
  157. package/fesm2020/bravobit-bb-foundation-auth.mjs +33 -231
  158. package/fesm2020/bravobit-bb-foundation-auth.mjs.map +1 -1
  159. package/fesm2020/bravobit-bb-foundation-collections.mjs +22 -22
  160. package/fesm2020/bravobit-bb-foundation-collections.mjs.map +1 -1
  161. package/fesm2020/bravobit-bb-foundation-controls.mjs +57 -57
  162. package/fesm2020/bravobit-bb-foundation-controls.mjs.map +1 -1
  163. package/fesm2020/bravobit-bb-foundation-dashboard.mjs +25 -25
  164. package/fesm2020/bravobit-bb-foundation-dashboard.mjs.map +1 -1
  165. package/fesm2020/bravobit-bb-foundation-dialog.mjs +31 -31
  166. package/fesm2020/bravobit-bb-foundation-dialog.mjs.map +1 -1
  167. package/fesm2020/bravobit-bb-foundation-elements.mjs +76 -76
  168. package/fesm2020/bravobit-bb-foundation-elements.mjs.map +1 -1
  169. package/fesm2020/bravobit-bb-foundation-http.mjs +10 -10
  170. package/fesm2020/bravobit-bb-foundation-http.mjs.map +1 -1
  171. package/fesm2020/bravobit-bb-foundation-localize.mjs +16 -16
  172. package/fesm2020/bravobit-bb-foundation-localize.mjs.map +1 -1
  173. package/fesm2020/bravobit-bb-foundation-masking.mjs +16 -16
  174. package/fesm2020/bravobit-bb-foundation-masking.mjs.map +1 -1
  175. package/fesm2020/bravobit-bb-foundation-notifications.mjs +13 -13
  176. package/fesm2020/bravobit-bb-foundation-notifications.mjs.map +1 -1
  177. package/fesm2020/bravobit-bb-foundation-permissions.mjs +289 -0
  178. package/fesm2020/bravobit-bb-foundation-permissions.mjs.map +1 -0
  179. package/fesm2020/bravobit-bb-foundation-recaptcha.mjs +10 -10
  180. package/fesm2020/bravobit-bb-foundation-recaptcha.mjs.map +1 -1
  181. package/fesm2020/bravobit-bb-foundation-storage.mjs +3 -3
  182. package/fesm2020/bravobit-bb-foundation-storage.mjs.map +1 -1
  183. package/fesm2020/bravobit-bb-foundation-table.mjs +22 -22
  184. package/fesm2020/bravobit-bb-foundation-table.mjs.map +1 -1
  185. package/fesm2020/bravobit-bb-foundation-theming.mjs +7 -7
  186. package/fesm2020/bravobit-bb-foundation-theming.mjs.map +1 -1
  187. package/fesm2020/bravobit-bb-foundation-utils.mjs +16 -16
  188. package/fesm2020/bravobit-bb-foundation-utils.mjs.map +1 -1
  189. package/fesm2020/bravobit-bb-foundation.mjs +21 -21
  190. package/fesm2020/bravobit-bb-foundation.mjs.map +1 -1
  191. package/package.json +13 -5
  192. package/permissions/index.d.ts +5 -0
  193. package/{auth → permissions}/lib/directives/permission.directive.d.ts +9 -4
  194. package/{auth → permissions}/lib/guards/permission.guard.d.ts +4 -5
  195. package/permissions/lib/handlers/abstract.handler.d.ts +4 -0
  196. package/permissions/lib/handlers/role.handler.d.ts +9 -0
  197. package/permissions/lib/permissions.interface.d.ts +11 -0
  198. package/permissions/lib/permissions.module.d.ts +10 -0
  199. package/permissions/lib/permissions.service.d.ts +22 -0
  200. package/permissions/public_api.d.ts +7 -0
  201. package/README.md +0 -47
  202. package/auth/lib/interfaces/permission.interface.d.ts +0 -6
  203. package/auth/lib/permissions/permissions.handler.d.ts +0 -9
  204. package/auth/lib/permissions/permissions.service.d.ts +0 -16
  205. package/esm2020/auth/lib/directives/permission.directive.mjs +0 -58
  206. package/esm2020/auth/lib/guards/permission.guard.mjs +0 -63
  207. package/esm2020/auth/lib/interfaces/permission.interface.mjs +0 -2
  208. package/esm2020/auth/lib/permissions/permissions.handler.mjs +0 -33
  209. package/esm2020/auth/lib/permissions/permissions.service.mjs +0 -64
@@ -2,8 +2,8 @@ import * as i0 from '@angular/core';
2
2
  import { InjectionToken, Injectable, Optional, Inject, Directive, Input, APP_INITIALIZER, NgModule } from '@angular/core';
3
3
  import * as i3 from '@angular/common/http';
4
4
  import { HttpContextToken, HttpContext, HttpErrorResponse, HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http';
5
- import { shareReplay, tap, map, distinctUntilChanged, switchMap, catchError, filter, take, finalize } from 'rxjs/operators';
6
- import { firstValueFrom, BehaviorSubject, of, Subscription, combineLatest, first, throwError } from 'rxjs';
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
7
  import { __awaiter, __rest } from 'tslib';
8
8
  import * as i5 from '@angular/platform-browser';
9
9
  import { makeStateKey } from '@angular/platform-browser';
@@ -213,6 +213,13 @@ class AuthSession {
213
213
  // Init methods.
214
214
  this.restoreFromStorage();
215
215
  }
216
+ get snapshot() {
217
+ return {
218
+ user: this._user$.getValue(),
219
+ accessToken: this.accessToken,
220
+ refreshToken: this.refreshToken
221
+ };
222
+ }
216
223
  get accessToken() {
217
224
  return this.isTokenValid(this._accessTokenPayload)
218
225
  ? this._accessTokenString
@@ -372,19 +379,19 @@ class Auth {
372
379
  return this._httpClient.get(url);
373
380
  }
374
381
  signIn(provider, as) {
375
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
382
+ var _a, _b, _c, _d, _e;
376
383
  return __awaiter(this, void 0, void 0, function* () {
377
- const _k = yield provider.authenticate(this._httpClient), { accessToken, refreshToken, user } = _k, result = __rest(_k, ["accessToken", "refreshToken", "user"]);
384
+ const _f = yield provider.authenticate(this._httpClient), { accessToken, refreshToken, user } = _f, result = __rest(_f, ["accessToken", "refreshToken", "user"]);
378
385
  // Check if the role matches.
379
- const role = (_e = (_d = (_c = (_b = (_a = this._config) === null || _a === void 0 ? void 0 : _a.permissions) === null || _b === void 0 ? void 0 : _b.getRole) === null || _c === void 0 ? void 0 : _c.call(_b, user)) !== null && _d !== void 0 ? _d : user === null || user === void 0 ? void 0 : user.role) !== null && _e !== void 0 ? _e : null;
386
+ const role = (_a = user === null || user === void 0 ? void 0 : user.role) !== null && _a !== void 0 ? _a : null;
380
387
  if (as && !as.includes(role)) {
381
388
  throw new Error('Invalid role.');
382
389
  }
383
390
  // Validate if the provider is one of the available
384
391
  // providers then return the user object and the provider.
385
- const apiProvider = (_f = result === null || result === void 0 ? void 0 : result.provider) !== null && _f !== void 0 ? _f : null;
386
- const apiVerifyToken = (_g = result === null || result === void 0 ? void 0 : result.verifyToken) !== null && _g !== void 0 ? _g : null;
387
- const availableProviders = (_j = (_h = this._config) === null || _h === void 0 ? void 0 : _h.providers) !== null && _j !== void 0 ? _j : ['email', 'sms', 'totp'];
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'];
388
395
  if (availableProviders.includes(apiProvider)) {
389
396
  return { user, provider: apiProvider, verifyToken: apiVerifyToken };
390
397
  }
@@ -516,7 +523,7 @@ class Auth {
516
523
  this.handleAutoRefreshing();
517
524
  }
518
525
  handleAutoRefreshing() {
519
- var _a, _b, _c, _d;
526
+ var _a, _b, _c, _d, _e;
520
527
  const shouldAutoRefresh = (_b = (_a = this._config) === null || _a === void 0 ? void 0 : _a.autoRefresh) !== null && _b !== void 0 ? _b : false;
521
528
  if (!shouldAutoRefresh) {
522
529
  return;
@@ -541,9 +548,9 @@ class Auth {
541
548
  clearTimeout === null || clearTimeout === void 0 ? void 0 : clearTimeout(this._refreshHandler);
542
549
  this._refreshHandler = null;
543
550
  }
544
- this._refreshHandler = setTimeout === null || setTimeout === void 0 ? void 0 : setTimeout(() => this.autoRefresh(), cappedTiming);
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);
545
552
  }
546
- catch (_e) {
553
+ catch (_f) {
547
554
  // Just ignore it.
548
555
  }
549
556
  }
@@ -569,9 +576,9 @@ class Auth {
569
576
  .join('/');
570
577
  }
571
578
  }
572
- Auth.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", 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 });
573
- Auth.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: Auth });
574
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: Auth, decorators: [{
579
+ Auth.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.10", 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: "14.2.10", ngImport: i0, type: Auth });
581
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.10", ngImport: i0, type: Auth, decorators: [{
575
582
  type: Injectable
576
583
  }], ctorParameters: function () {
577
584
  return [{ type: i1.Storage }, { type: i0.Injector }, { type: i2.Platform }, { type: i3.HttpClient }, { type: AuthConfig, decorators: [{
@@ -614,9 +621,9 @@ class BbAuthenticated extends AbstractAuthDirective {
614
621
  (_a = this._subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
615
622
  }
616
623
  }
617
- BbAuthenticated.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: BbAuthenticated, deps: [{ token: Auth }, { token: i0.TemplateRef }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
618
- BbAuthenticated.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.2", type: BbAuthenticated, selector: "[bbAuthenticated]", inputs: { bbAuthenticatedElse: "bbAuthenticatedElse" }, usesInheritance: true, ngImport: i0 });
619
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: BbAuthenticated, decorators: [{
624
+ BbAuthenticated.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.10", 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: "14.2.10", type: BbAuthenticated, selector: "[bbAuthenticated]", inputs: { bbAuthenticatedElse: "bbAuthenticatedElse" }, usesInheritance: true, ngImport: i0 });
626
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.10", ngImport: i0, type: BbAuthenticated, decorators: [{
620
627
  type: Directive,
621
628
  args: [{
622
629
  selector: '[bbAuthenticated]'
@@ -625,160 +632,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImpor
625
632
  type: Input
626
633
  }] } });
627
634
 
628
- class Permissions {
629
- constructor(_auth, _config) {
630
- var _a, _b;
631
- this._auth = _auth;
632
- this._config = _config;
633
- // Data.
634
- this._permissionHandler = (_b = (_a = this._config) === null || _a === void 0 ? void 0 : _a.permissions) !== null && _b !== void 0 ? _b : null;
635
- }
636
- has(value, options) {
637
- const requiredPermissions = this.getRequiredPermissions(value);
638
- if ((requiredPermissions === null || requiredPermissions === void 0 ? void 0 : requiredPermissions.length) <= 0) {
639
- return of(false);
640
- }
641
- return this._auth.user.pipe(map(user => {
642
- var _a;
643
- if (user === null || user === undefined || !this._permissionHandler) {
644
- return false;
645
- }
646
- const mode = (_a = options === null || options === void 0 ? void 0 : options.mode) !== null && _a !== void 0 ? _a : 'and';
647
- switch (mode) {
648
- case 'or':
649
- return this.verifyModeOr(requiredPermissions, user);
650
- case 'and':
651
- default:
652
- return this.verifyModeAnd(requiredPermissions, user);
653
- }
654
- }), distinctUntilChanged());
655
- }
656
- verifyModeAnd(permissions, user) {
657
- for (const permission of permissions) {
658
- const verified = this._permissionHandler.verifyForUser(permission, user);
659
- if (!verified) {
660
- return false;
661
- }
662
- }
663
- return true;
664
- }
665
- verifyModeOr(permissions, user) {
666
- for (const permission of permissions) {
667
- const verified = this._permissionHandler.verifyForUser(permission, user);
668
- if (verified) {
669
- return true;
670
- }
671
- }
672
- return false;
673
- }
674
- getRequiredPermissions(value) {
675
- return Array.isArray(value)
676
- ? value
677
- : [value];
678
- }
679
- }
680
- Permissions.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: Permissions, deps: [{ token: Auth }, { token: AuthConfig, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
681
- Permissions.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: Permissions });
682
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: Permissions, decorators: [{
683
- type: Injectable
684
- }], ctorParameters: function () {
685
- return [{ type: Auth }, { type: AuthConfig, decorators: [{
686
- type: Optional
687
- }] }];
688
- } });
689
-
690
- class BbPermission extends AbstractAuthDirective {
691
- constructor(_permissions, _templateRef, _viewContainerRef) {
692
- super(_templateRef, _viewContainerRef);
693
- this._permissions = _permissions;
694
- this._templateRef = _templateRef;
695
- this._viewContainerRef = _viewContainerRef;
696
- // Data.
697
- this._permission$ = new BehaviorSubject([]);
698
- this._mode$ = new BehaviorSubject('and');
699
- // Subscriptions.
700
- this._subscription = new Subscription();
701
- }
702
- set bbPermission(value) {
703
- const permissions = Array.isArray(value) ? value : [value];
704
- this._permission$.next(permissions);
705
- this.updateView();
706
- }
707
- set bbPermissionElse(templateRef) {
708
- this.assertTemplate('bbPermissionElse', templateRef);
709
- this.elseTemplateRef = templateRef;
710
- this.updateView();
711
- }
712
- set bbPermissionMode(mode) {
713
- this._mode$.next(mode);
714
- }
715
- ngOnInit() {
716
- const check$ = combineLatest([this._permission$, this._mode$]).pipe(switchMap(([permissions, mode]) => this._permissions.has(permissions, { mode })), distinctUntilChanged());
717
- const subscription = check$.subscribe(valid => {
718
- this.valid = valid;
719
- this.updateView();
720
- });
721
- this._subscription.add(subscription);
722
- }
723
- ngOnDestroy() {
724
- var _a;
725
- (_a = this._subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
726
- }
727
- }
728
- BbPermission.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: BbPermission, deps: [{ token: Permissions }, { token: i0.TemplateRef }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
729
- BbPermission.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.2", type: BbPermission, selector: "[bbPermission]", inputs: { bbPermission: "bbPermission", bbPermissionElse: "bbPermissionElse", bbPermissionMode: "bbPermissionMode" }, usesInheritance: true, ngImport: i0 });
730
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: BbPermission, decorators: [{
731
- type: Directive,
732
- args: [{
733
- selector: '[bbPermission]'
734
- }]
735
- }], ctorParameters: function () { return [{ type: Permissions }, { type: i0.TemplateRef }, { type: i0.ViewContainerRef }]; }, propDecorators: { bbPermission: [{
736
- type: Input
737
- }], bbPermissionElse: [{
738
- type: Input
739
- }], bbPermissionMode: [{
740
- type: Input
741
- }] } });
742
-
743
- class AppPermissions {
744
- constructor(_data) {
745
- this._data = _data;
746
- }
747
- verify(permission, role) {
748
- var _a, _b, _c, _d;
749
- if ((typeof ngDevMode === 'undefined' || ngDevMode) && !((_a = this._data) === null || _a === void 0 ? void 0 : _a[role])) {
750
- (_b = console === null || console === void 0 ? void 0 : console.warn) === null || _b === void 0 ? void 0 : _b.call(console, `Current permissions do not include role: "${role}".`);
751
- }
752
- const availablePermissions = (_d = (_c = this._data) === null || _c === void 0 ? void 0 : _c[role]) !== null && _d !== void 0 ? _d : [];
753
- return availablePermissions.includes(permission);
754
- }
755
- verifyForUser(permission, data) {
756
- const role = this.getRole(data);
757
- return this.verify(permission, role);
758
- }
759
- getRole(data) {
760
- var _a;
761
- return (_a = data === null || data === void 0 ? void 0 : data['role']) !== null && _a !== void 0 ? _a : null;
762
- }
763
- static forRoles(data) {
764
- var _a;
765
- const permissions = (_a = Object.keys(data)) !== null && _a !== void 0 ? _a : [];
766
- const roles = permissions.reduce((previous, current) => {
767
- var _a;
768
- return ([
769
- ...previous,
770
- ...((_a = data === null || data === void 0 ? void 0 : data[current]) !== null && _a !== void 0 ? _a : [])
771
- ]);
772
- }, []);
773
- const uniqueRoles = [...new Set(roles)];
774
- const formattedData = uniqueRoles.reduce((previous, current) => {
775
- const rolePermissions = permissions.filter(permission => { var _a; return (_a = data === null || data === void 0 ? void 0 : data[permission]) === null || _a === void 0 ? void 0 : _a.includes(current); });
776
- return Object.assign(Object.assign({}, previous), { [current]: rolePermissions });
777
- }, {});
778
- return new AppPermissions(formattedData);
779
- }
780
- }
781
-
782
635
  class BbAnonymousGuard {
783
636
  constructor(_auth, _router, _config, _handler) {
784
637
  this._auth = _auth;
@@ -809,9 +662,9 @@ class BbAnonymousGuard {
809
662
  return this.canActivate(childRoute, state);
810
663
  }
811
664
  }
812
- BbAnonymousGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", 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 });
813
- BbAnonymousGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: BbAnonymousGuard, providedIn: 'root' });
814
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: BbAnonymousGuard, decorators: [{
665
+ BbAnonymousGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.10", 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: "14.2.10", ngImport: i0, type: BbAnonymousGuard, providedIn: 'root' });
667
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.10", ngImport: i0, type: BbAnonymousGuard, decorators: [{
815
668
  type: Injectable,
816
669
  args: [{
817
670
  providedIn: 'root'
@@ -860,9 +713,9 @@ class BbAuthenticatedGuard {
860
713
  return this.canActivate(childRoute, state);
861
714
  }
862
715
  }
863
- BbAuthenticatedGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", 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 });
864
- BbAuthenticatedGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: BbAuthenticatedGuard, providedIn: 'root' });
865
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: BbAuthenticatedGuard, decorators: [{
716
+ BbAuthenticatedGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.10", 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: "14.2.10", ngImport: i0, type: BbAuthenticatedGuard, providedIn: 'root' });
718
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.10", ngImport: i0, type: BbAuthenticatedGuard, decorators: [{
866
719
  type: Injectable,
867
720
  args: [{
868
721
  providedIn: 'root'
@@ -878,66 +731,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImpor
878
731
  }] }];
879
732
  } });
880
733
 
881
- class BbPermissionGuard {
882
- constructor(_router, _permissions, _config, _handler) {
883
- this._router = _router;
884
- this._permissions = _permissions;
885
- this._config = _config;
886
- this._handler = _handler;
887
- }
888
- canActivate(snapshot, state) {
889
- var _a, _b;
890
- const permission = (_b = (_a = snapshot === null || snapshot === void 0 ? void 0 : snapshot.data) === null || _a === void 0 ? void 0 : _a['permission']) !== null && _b !== void 0 ? _b : null;
891
- const permission$ = this.parsePermission(permission);
892
- return permission$.pipe(map(valid => {
893
- var _a, _b, _c;
894
- if (valid) {
895
- return true;
896
- }
897
- if (this._handler) {
898
- return this._handler.onPermissionDenied(snapshot, state);
899
- }
900
- const nextUrl = (_c = (_b = (_a = this._config) === null || _a === void 0 ? void 0 : _a.redirects) === null || _b === void 0 ? void 0 : _b.permissionDenied) !== null && _c !== void 0 ? _c : null;
901
- if (!nextUrl) {
902
- return false;
903
- }
904
- const commands = Array.isArray(nextUrl) ? nextUrl : [nextUrl];
905
- return valid ? true : this._router.createUrlTree(commands);
906
- }));
907
- }
908
- canActivateChild(childRoute, state) {
909
- return this.canActivate(childRoute, state);
910
- }
911
- parsePermission(data) {
912
- var _a;
913
- if ((typeof ngDevMode === 'undefined' || ngDevMode) && (data === undefined || data === null)) {
914
- (_a = console === null || console === void 0 ? void 0 : console.warn) === null || _a === void 0 ? void 0 : _a.call(console, `No "data.permission" property was passed.`);
915
- return of(false);
916
- }
917
- if (Array.isArray(data) || typeof data === 'string') {
918
- return this._permissions.has(data);
919
- }
920
- return this._permissions.has(data === null || data === void 0 ? void 0 : data.value, data === null || data === void 0 ? void 0 : data.options);
921
- }
922
- }
923
- BbPermissionGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: BbPermissionGuard, deps: [{ token: i2$1.Router }, { token: Permissions }, { token: AuthConfig, optional: true }, { token: AUTH_REDIRECT_HANDLER, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
924
- BbPermissionGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: BbPermissionGuard, providedIn: 'root' });
925
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: BbPermissionGuard, decorators: [{
926
- type: Injectable,
927
- args: [{
928
- providedIn: 'root'
929
- }]
930
- }], ctorParameters: function () {
931
- return [{ type: i2$1.Router }, { type: Permissions }, { type: AuthConfig, decorators: [{
932
- type: Optional
933
- }] }, { type: undefined, decorators: [{
934
- type: Optional
935
- }, {
936
- type: Inject,
937
- args: [AUTH_REDIRECT_HANDLER]
938
- }] }];
939
- } });
940
-
941
734
  class AuthInterceptor {
942
735
  constructor(_auth, _config) {
943
736
  var _a, _b, _c, _d, _e, _f;
@@ -1012,9 +805,9 @@ class AuthInterceptor {
1012
805
  return of(null);
1013
806
  }
1014
807
  }
1015
- AuthInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: AuthInterceptor, deps: [{ token: Auth }, { token: AuthConfig, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
1016
- AuthInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: AuthInterceptor });
1017
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: AuthInterceptor, decorators: [{
808
+ AuthInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.10", 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: "14.2.10", ngImport: i0, type: AuthInterceptor });
810
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.10", ngImport: i0, type: AuthInterceptor, decorators: [{
1018
811
  type: Injectable
1019
812
  }], ctorParameters: function () {
1020
813
  return [{ type: Auth }, { type: AuthConfig, decorators: [{
@@ -1022,17 +815,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImpor
1022
815
  }] }];
1023
816
  } });
1024
817
 
1025
- const DECLARATIONS_EXPORTS = [
1026
- BbAuthenticated,
1027
- BbPermission
1028
- ];
1029
818
  class AuthModule {
1030
819
  static forRoot(config) {
1031
820
  return {
1032
821
  ngModule: AuthModule,
1033
822
  providers: [
1034
823
  Auth,
1035
- Permissions,
1036
824
  { provide: AuthConfig, useValue: config },
1037
825
  { provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true },
1038
826
  { useFactory: initializeAuth, provide: APP_INITIALIZER, deps: [Auth], multi: true }
@@ -1040,17 +828,15 @@ class AuthModule {
1040
828
  };
1041
829
  }
1042
830
  }
1043
- AuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: AuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1044
- AuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.2", ngImport: i0, type: AuthModule, declarations: [BbAuthenticated,
1045
- BbPermission], imports: [HttpClientModule], exports: [BbAuthenticated,
1046
- BbPermission] });
1047
- AuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: AuthModule, imports: [HttpClientModule] });
1048
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: AuthModule, decorators: [{
831
+ AuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.10", ngImport: i0, type: AuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
832
+ AuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.10", ngImport: i0, type: AuthModule, declarations: [BbAuthenticated], imports: [HttpClientModule], exports: [BbAuthenticated] });
833
+ AuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.10", ngImport: i0, type: AuthModule, imports: [HttpClientModule] });
834
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.10", ngImport: i0, type: AuthModule, decorators: [{
1049
835
  type: NgModule,
1050
836
  args: [{
1051
837
  imports: [HttpClientModule],
1052
- declarations: [...DECLARATIONS_EXPORTS],
1053
- exports: [...DECLARATIONS_EXPORTS]
838
+ declarations: [BbAuthenticated],
839
+ exports: [BbAuthenticated]
1054
840
  }]
1055
841
  }] });
1056
842
  function initializeAuth(auth) {
@@ -1061,5 +847,5 @@ function initializeAuth(auth) {
1061
847
  * Generated bundle index. Do not edit.
1062
848
  */
1063
849
 
1064
- export { AUTH_REDIRECT_HANDLER, AppPermissions, Auth, AuthConfig, AuthEmailProvider, AuthModule, AuthSession, AuthVerifyProvider, BbAnonymousGuard, BbAuthenticated, BbAuthenticatedGuard, BbPermission, BbPermissionGuard, JwtHelper, Permissions, USE_AUTHORIZATION, initializeAuth };
850
+ export { AUTH_REDIRECT_HANDLER, Auth, AuthConfig, AuthEmailProvider, AuthModule, AuthSession, AuthVerifyProvider, BbAnonymousGuard, BbAuthenticated, BbAuthenticatedGuard, JwtHelper, USE_AUTHORIZATION, initializeAuth };
1065
851
  //# sourceMappingURL=bravobit-bb-foundation-auth.mjs.map