@bravobit/bb-foundation 0.40.8 → 0.42.1

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 (188) hide show
  1. package/auth/lib/auth.interceptor.d.ts +3 -6
  2. package/dialog/lib/dialog-confirm/dialog-confirm.component.d.ts +2 -5
  3. package/dialog/lib/dialog-container/dialog-container.component.d.ts +4 -6
  4. package/dialog/lib/dialog-overlay/dialog-overlay.component.d.ts +5 -7
  5. package/esm2022/auth/lib/auth.interceptor.mjs +36 -42
  6. package/esm2022/auth/lib/auth.module.mjs +4 -4
  7. package/esm2022/auth/lib/auth.service.mjs +18 -7
  8. package/esm2022/auth/lib/auth.session.mjs +26 -22
  9. package/esm2022/auth/lib/directives/authenticated.directive.mjs +16 -12
  10. package/esm2022/auth/lib/helpers/jwt.helper.mjs +29 -31
  11. package/esm2022/auth/lib/providers/email.provider.mjs +4 -1
  12. package/esm2022/auth/lib/providers/verify.provider.mjs +4 -1
  13. package/esm2022/collections/lib/collection.mjs +17 -7
  14. package/esm2022/collections/lib/collections.module.mjs +6 -6
  15. package/esm2022/collections/lib/components/collections-actions/collections-actions.component.mjs +7 -9
  16. package/esm2022/collections/lib/components/collections-grid/collections-grid.component.mjs +11 -11
  17. package/esm2022/collections/lib/components/collections-pager/collections-pager.component.mjs +10 -10
  18. package/esm2022/collections/lib/components/collections-table/collections-table.component.mjs +16 -16
  19. package/esm2022/collections/lib/components/collections-table-label/collections-table-label.component.mjs +9 -11
  20. package/esm2022/collections/lib/components/collections-table-sorting/collections-table-sorting.component.mjs +12 -9
  21. package/esm2022/collections/lib/components/collections-viewer/collections-viewer.component.mjs +10 -7
  22. package/esm2022/collections/lib/directives/collections-data-row.directive.mjs +6 -3
  23. package/esm2022/collections/lib/directives/collections-data.directive.mjs +6 -3
  24. package/esm2022/collections/lib/directives/collections-empty.directive.mjs +6 -3
  25. package/esm2022/collections/lib/directives/collections-error.directive.mjs +6 -3
  26. package/esm2022/collections/lib/directives/collections-initial.directive.mjs +4 -3
  27. package/esm2022/collections/lib/directives/collections-item.directive.mjs +6 -3
  28. package/esm2022/collections/lib/providers/api-collection.provider.mjs +6 -4
  29. package/esm2022/collections/lib/providers/local-collection.provider.mjs +2 -2
  30. package/esm2022/combobox/combobox/combobox-container.directive.mjs +12 -7
  31. package/esm2022/combobox/combobox/combobox.component.mjs +23 -20
  32. package/esm2022/combobox/combobox-label.directive.mjs +3 -3
  33. package/esm2022/combobox/combobox-option.directive.mjs +3 -3
  34. package/esm2022/combobox/combobox-panel/combobox-panel.component.mjs +10 -6
  35. package/esm2022/dashboard/lib/dashboard/dashboard.component.mjs +13 -13
  36. package/esm2022/dashboard/lib/dashboard-header/dashboard-header.component.mjs +5 -7
  37. package/esm2022/dashboard/lib/dashboard-menu/dashboard-menu.component.mjs +8 -10
  38. package/esm2022/dashboard/lib/dashboard-menu-item/dashboard-menu-item.component.mjs +5 -7
  39. package/esm2022/dashboard/lib/dashboard-sidebar/dashboard-sidebar.component.mjs +12 -13
  40. package/esm2022/dashboard/lib/dashboard-sidebar-group/dashboard-sidebar-group.component.mjs +13 -12
  41. package/esm2022/dashboard/lib/dashboard-sidebar-item/dashboard-sidebar-item.component.mjs +7 -5
  42. package/esm2022/dashboard/lib/dashboard.module.mjs +5 -5
  43. package/esm2022/dialog/lib/dialog-actions/dialog-actions.component.mjs +3 -3
  44. package/esm2022/dialog/lib/dialog-confirm/dialog-confirm.component.mjs +21 -20
  45. package/esm2022/dialog/lib/dialog-container/dialog-container.component.mjs +19 -24
  46. package/esm2022/dialog/lib/dialog-header/dialog-header.component.mjs +5 -7
  47. package/esm2022/dialog/lib/dialog-link/dialog-link.component.mjs +3 -3
  48. package/esm2022/dialog/lib/dialog-modal/dialog-modal.component.mjs +9 -6
  49. package/esm2022/dialog/lib/dialog-overlay/dialog-overlay.component.mjs +19 -26
  50. package/esm2022/dialog/lib/dialog.insertion.mjs +4 -3
  51. package/esm2022/dialog/lib/dialog.interfaces.mjs +4 -1
  52. package/esm2022/dialog/lib/dialog.module.mjs +6 -6
  53. package/esm2022/dialog/lib/dialog.ref.mjs +4 -6
  54. package/esm2022/dialog/lib/dialog.service.mjs +5 -3
  55. package/esm2022/dialog/lib/directives/confirm.directive.mjs +12 -14
  56. package/esm2022/elements/lib/avatar/avatar.component.mjs +75 -77
  57. package/esm2022/elements/lib/button/button.component.mjs +12 -10
  58. package/esm2022/elements/lib/checkbox/checkbox.component.mjs +21 -17
  59. package/esm2022/elements/lib/checkbox-group/checkbox-group.component.mjs +8 -10
  60. package/esm2022/elements/lib/date-picker/date-picker.component.mjs +82 -76
  61. package/esm2022/elements/lib/directives/addon.directive.mjs +5 -5
  62. package/esm2022/elements/lib/directives/extra-error-controls.directive.mjs +7 -9
  63. package/esm2022/elements/lib/directives/form-submit.directive.mjs +6 -3
  64. package/esm2022/elements/lib/directives/form-submitter.directive.mjs +5 -7
  65. package/esm2022/elements/lib/directives/image-upload.directive.mjs +14 -11
  66. package/esm2022/elements/lib/directives/input.directive.mjs +6 -4
  67. package/esm2022/elements/lib/elements.module.mjs +6 -6
  68. package/esm2022/elements/lib/file-picker/file-picker.component.mjs +52 -51
  69. package/esm2022/elements/lib/form-control/form-control.component.mjs +14 -14
  70. package/esm2022/elements/lib/form-error/form-error.component.mjs +16 -8
  71. package/esm2022/elements/lib/form-group/form-group.component.mjs +5 -7
  72. package/esm2022/elements/lib/icon/icon.component.mjs +14 -13
  73. package/esm2022/elements/lib/image-picker/image-picker.component.mjs +20 -17
  74. package/esm2022/elements/lib/multi-file-control/multi-file-control.component.mjs +28 -24
  75. package/esm2022/elements/lib/pipes/date.pipe.mjs +6 -8
  76. package/esm2022/elements/lib/pipes/file-image.pipe.mjs +6 -3
  77. package/esm2022/elements/lib/pipes/file-size.pipe.mjs +13 -15
  78. package/esm2022/elements/lib/pipes/relative-time.pipe.mjs +37 -35
  79. package/esm2022/elements/lib/radio-button/radio-button.component.mjs +8 -7
  80. package/esm2022/elements/lib/radio-group/radio-group.component.mjs +21 -20
  81. package/esm2022/elements/lib/spinner/spinner.component.mjs +7 -9
  82. package/esm2022/http/lib/classes/http.config.mjs +19 -15
  83. package/esm2022/http/lib/http.interfaces.mjs +1 -1
  84. package/esm2022/http/lib/http.module.mjs +5 -4
  85. package/esm2022/http/lib/interceptors/base-url.interceptor.mjs +12 -20
  86. package/esm2022/http/lib/interceptors/error.interceptor.mjs +9 -14
  87. package/esm2022/lib/core/services/exif.service.mjs +102 -100
  88. package/esm2022/lib/core/services/file-loader.service.mjs +15 -17
  89. package/esm2022/lib/core/services/files.service.mjs +7 -3
  90. package/esm2022/lib/core/services/image-converter.service.mjs +33 -30
  91. package/esm2022/lib/core/services/languages.service.mjs +25 -24
  92. package/esm2022/lib/core/services/network.service.mjs +8 -5
  93. package/esm2022/lib/core/services/patch.service.mjs +9 -6
  94. package/esm2022/localize/lib/dictionary/dictionary.class.mjs +7 -1
  95. package/esm2022/localize/lib/dictionary/dictionary.context.mjs +2 -4
  96. package/esm2022/localize/lib/dictionary/dictionary.data.mjs +2 -1
  97. package/esm2022/localize/lib/handlers/missing.handler.mjs +2 -4
  98. package/esm2022/localize/lib/localize.module.mjs +5 -5
  99. package/esm2022/localize/lib/localize.pipe.mjs +4 -3
  100. package/esm2022/localize/lib/localize.service.mjs +30 -21
  101. package/esm2022/localize/lib/transforms/interpolate.transform.mjs +5 -1
  102. package/esm2022/localize/lib/transforms/plural.transform.mjs +6 -4
  103. package/esm2022/localize/lib/transforms/reference.transform.mjs +3 -1
  104. package/esm2022/localize/lib/views/localize-string/localize-string.component.mjs +14 -11
  105. package/esm2022/localize/lib/views/localize-template.directive.mjs +6 -5
  106. package/esm2022/masking/lib/directives/currency-mask.directive.mjs +11 -6
  107. package/esm2022/masking/lib/directives/date-mask.directive.mjs +11 -6
  108. package/esm2022/masking/lib/directives/input-mask.directive.mjs +21 -14
  109. package/esm2022/masking/lib/masking.module.mjs +5 -5
  110. package/esm2022/masking/lib/masking.service.mjs +4 -3
  111. package/esm2022/notifications/lib/notifications-item/notifications-item.component.mjs +50 -36
  112. package/esm2022/notifications/lib/notifications-list/notifications-list.component.mjs +8 -7
  113. package/esm2022/notifications/lib/notifications.interfaces.mjs +10 -1
  114. package/esm2022/notifications/lib/notifications.module.mjs +4 -4
  115. package/esm2022/notifications/lib/notifications.service.mjs +24 -10
  116. package/esm2022/permissions/lib/directives/permission.directive.mjs +20 -14
  117. package/esm2022/permissions/lib/handlers/local.handler.mjs +3 -1
  118. package/esm2022/permissions/lib/permissions.interface.mjs +4 -1
  119. package/esm2022/permissions/lib/permissions.module.mjs +4 -4
  120. package/esm2022/permissions/lib/permissions.service.mjs +8 -7
  121. package/esm2022/recaptcha/lib/recaptcha/recaptcha.component.mjs +34 -27
  122. package/esm2022/recaptcha/lib/recaptcha-loader.service.mjs +15 -15
  123. package/esm2022/recaptcha/lib/recaptcha.module.mjs +4 -4
  124. package/esm2022/select/lib/select/select.component.mjs +52 -47
  125. package/esm2022/select/lib/select-label.directive.mjs +4 -3
  126. package/esm2022/select/lib/select-multi-label.directive.mjs +4 -3
  127. package/esm2022/select/lib/select-option-group.directive.mjs +4 -3
  128. package/esm2022/select/lib/select-option.directive.mjs +4 -3
  129. package/esm2022/select/lib/select.module.mjs +5 -5
  130. package/esm2022/storage/lib/storage.service.mjs +25 -21
  131. package/esm2022/storage/lib/strategies/cookie-storage.strategy.mjs +66 -64
  132. package/esm2022/storage/lib/strategies/memory-storage.strategy.mjs +16 -18
  133. package/esm2022/storage/lib/strategies/polyfill-storage.strategy.mjs +31 -30
  134. package/esm2022/table/lib/components/table/table.component.mjs +30 -20
  135. package/esm2022/table/lib/components/table-cell/table-cell.component.mjs +3 -3
  136. package/esm2022/table/lib/components/table-header-cell/table-header-cell.component.mjs +15 -11
  137. package/esm2022/table/lib/components/table-pager/table-pager.component.mjs +18 -16
  138. package/esm2022/table/lib/data/datasource.data.mjs +4 -6
  139. package/esm2022/table/lib/data/generic.data.mjs +38 -36
  140. package/esm2022/table/lib/table.module.mjs +6 -6
  141. package/esm2022/tooltip/lib/tooltip-container/tooltip-container.component.mjs +5 -7
  142. package/esm2022/tooltip/lib/tooltip.directive.mjs +15 -15
  143. package/esm2022/tooltip/lib/tooltip.module.mjs +4 -4
  144. package/esm2022/utils/lib/directives/autosize.directive.mjs +9 -7
  145. package/esm2022/utils/lib/directives/focus-trap.directive.mjs +24 -22
  146. package/esm2022/utils/lib/directives/focus.directive.mjs +8 -5
  147. package/esm2022/utils/lib/directives/template.directive.mjs +7 -3
  148. package/esm2022/utils/lib/utils.module.mjs +5 -5
  149. package/fesm2022/bravobit-bb-foundation-auth.mjs +127 -110
  150. package/fesm2022/bravobit-bb-foundation-auth.mjs.map +1 -1
  151. package/fesm2022/bravobit-bb-foundation-collections.mjs +123 -93
  152. package/fesm2022/bravobit-bb-foundation-collections.mjs.map +1 -1
  153. package/fesm2022/bravobit-bb-foundation-combobox.mjs +46 -34
  154. package/fesm2022/bravobit-bb-foundation-combobox.mjs.map +1 -1
  155. package/fesm2022/bravobit-bb-foundation-dashboard.mjs +60 -64
  156. package/fesm2022/bravobit-bb-foundation-dashboard.mjs.map +1 -1
  157. package/fesm2022/bravobit-bb-foundation-dialog.mjs +97 -103
  158. package/fesm2022/bravobit-bb-foundation-dialog.mjs.map +1 -1
  159. package/fesm2022/bravobit-bb-foundation-elements.mjs +468 -440
  160. package/fesm2022/bravobit-bb-foundation-elements.mjs.map +1 -1
  161. package/fesm2022/bravobit-bb-foundation-http.mjs +40 -46
  162. package/fesm2022/bravobit-bb-foundation-http.mjs.map +1 -1
  163. package/fesm2022/bravobit-bb-foundation-localize.mjs +74 -49
  164. package/fesm2022/bravobit-bb-foundation-localize.mjs.map +1 -1
  165. package/fesm2022/bravobit-bb-foundation-masking.mjs +47 -29
  166. package/fesm2022/bravobit-bb-foundation-masking.mjs.map +1 -1
  167. package/fesm2022/bravobit-bb-foundation-notifications.mjs +91 -53
  168. package/fesm2022/bravobit-bb-foundation-notifications.mjs.map +1 -1
  169. package/fesm2022/bravobit-bb-foundation-permissions.mjs +34 -22
  170. package/fesm2022/bravobit-bb-foundation-permissions.mjs.map +1 -1
  171. package/fesm2022/bravobit-bb-foundation-recaptcha.mjs +50 -43
  172. package/fesm2022/bravobit-bb-foundation-recaptcha.mjs.map +1 -1
  173. package/fesm2022/bravobit-bb-foundation-select.mjs +67 -58
  174. package/fesm2022/bravobit-bb-foundation-select.mjs.map +1 -1
  175. package/fesm2022/bravobit-bb-foundation-storage.mjs +134 -129
  176. package/fesm2022/bravobit-bb-foundation-storage.mjs.map +1 -1
  177. package/fesm2022/bravobit-bb-foundation-table.mjs +107 -91
  178. package/fesm2022/bravobit-bb-foundation-table.mjs.map +1 -1
  179. package/fesm2022/bravobit-bb-foundation-tooltip.mjs +21 -23
  180. package/fesm2022/bravobit-bb-foundation-tooltip.mjs.map +1 -1
  181. package/fesm2022/bravobit-bb-foundation-utils.mjs +48 -37
  182. package/fesm2022/bravobit-bb-foundation-utils.mjs.map +1 -1
  183. package/fesm2022/bravobit-bb-foundation.mjs +192 -178
  184. package/fesm2022/bravobit-bb-foundation.mjs.map +1 -1
  185. package/http/lib/http.interfaces.d.ts +2 -1
  186. package/http/lib/interceptors/base-url.interceptor.d.ts +2 -4
  187. package/http/lib/interceptors/error.interceptor.d.ts +1 -3
  188. package/package.json +18 -18
@@ -4,37 +4,11 @@ import { COOKIE } from '@bravobit/bb-foundation';
4
4
  import * as i1 from '@angular/cdk/platform';
5
5
 
6
6
  class PolyfillStorage {
7
+ _storage;
8
+ // State.
9
+ _isSupported = false;
7
10
  constructor(_storage) {
8
11
  this._storage = _storage;
9
- // State.
10
- this._isSupported = false;
11
- this.encode = (value, attributes) => {
12
- // Make sure the expires attribute is a date and not a number.
13
- const data = { value };
14
- if (typeof attributes.expires === 'number') {
15
- attributes.expires = new Date(attributes.expires);
16
- }
17
- if (attributes.expires) {
18
- data['expires'] = attributes.expires;
19
- }
20
- return JSON.stringify(data);
21
- };
22
- this.testIfSupported = () => {
23
- if (typeof this._storage === 'undefined') {
24
- return false;
25
- }
26
- try {
27
- const x = '__storage_test__';
28
- this._storage.setItem(x, x);
29
- this._storage.removeItem(x);
30
- return true;
31
- }
32
- catch (error) {
33
- return error instanceof DOMException
34
- && (error.name === 'QuotaExceededError' || error.name === 'NS_ERROR_DOM_QUOTA_REACHED')
35
- && (this._storage && this._storage.length !== 0);
36
- }
37
- };
38
12
  // Check if the storage is supported.
39
13
  this._isSupported = this.testIfSupported();
40
14
  }
@@ -100,75 +74,43 @@ class PolyfillStorage {
100
74
  // Return the parsed data.
101
75
  return parsedData;
102
76
  }
77
+ encode = (value, attributes) => {
78
+ // Make sure the expires attribute is a date and not a number.
79
+ const data = { value };
80
+ if (typeof attributes.expires === 'number') {
81
+ attributes.expires = new Date(attributes.expires);
82
+ }
83
+ if (attributes.expires) {
84
+ data['expires'] = attributes.expires;
85
+ }
86
+ return JSON.stringify(data);
87
+ };
88
+ testIfSupported = () => {
89
+ if (typeof this._storage === 'undefined') {
90
+ return false;
91
+ }
92
+ try {
93
+ const x = '__storage_test__';
94
+ this._storage.setItem(x, x);
95
+ this._storage.removeItem(x);
96
+ return true;
97
+ }
98
+ catch (error) {
99
+ return error instanceof DOMException
100
+ && (error.name === 'QuotaExceededError' || error.name === 'NS_ERROR_DOM_QUOTA_REACHED')
101
+ && (this._storage && this._storage.length !== 0);
102
+ }
103
+ };
103
104
  }
104
105
 
105
106
  class CookieStorage {
107
+ _isBrowser;
108
+ _cookieString;
109
+ // State.
110
+ _isSupported = false;
106
111
  constructor(_isBrowser, _cookieString) {
107
112
  this._isBrowser = _isBrowser;
108
113
  this._cookieString = _cookieString;
109
- // State.
110
- this._isSupported = false;
111
- this.decode = (cookieString) => {
112
- const result = {};
113
- const cookies = cookieString ? cookieString.split('; ') : [];
114
- const rdecode = /(%[0-9A-Z]{2})+/g;
115
- for (let index = 0; index < cookies.length; index++) {
116
- const parts = cookies[index].split('=');
117
- let cookie = parts.slice(1).join('=');
118
- if (cookie.charAt(0) === '"') {
119
- cookie = cookie.slice(1, -1);
120
- }
121
- try {
122
- const name = parts[0].replace(rdecode, decodeURIComponent);
123
- const value = cookie.replace(rdecode, decodeURIComponent);
124
- result[name] = this.jsonParse(value);
125
- }
126
- catch {
127
- // Ignore cookies with an invalid name/value encoding.
128
- }
129
- }
130
- return result;
131
- };
132
- this.jsonParse = (rawValue) => {
133
- // Try to parse the data.
134
- let parsedValue = undefined;
135
- // Only parse the value when it is not null.
136
- if (rawValue !== undefined) {
137
- try {
138
- parsedValue = JSON.parse(rawValue);
139
- }
140
- catch {
141
- // The string could not be parsed to JSON.
142
- }
143
- }
144
- // Return the parsed value.
145
- return parsedValue;
146
- };
147
- this.stringifyAttribute = (token, value) => {
148
- if (!value) {
149
- return '';
150
- }
151
- const stringified = `; ${token}`;
152
- // Boolean attributes should not have a value.
153
- if (value === true) {
154
- return stringified;
155
- }
156
- return stringified + `= ${value}`;
157
- };
158
- this.testIfSupported = () => {
159
- // We are using an aggressive test here, because we cannot rely on navigator.cookieEnabled
160
- // it does not return the correct value at all times.
161
- const testCookieString = `bbcookietest`;
162
- try {
163
- document.cookie = `${testCookieString}=1`;
164
- const result = document.cookie.indexOf(`${testCookieString}=`) !== -1;
165
- document.cookie = `${testCookieString}=1; expires=Thu, 01-Jan-1970 00:00:01 GMT`;
166
- return result;
167
- }
168
- catch {
169
- return false;
170
- }
171
- };
172
114
  // Check if the storage is supported.
173
115
  this._isSupported = this.testIfSupported();
174
116
  }
@@ -223,6 +165,42 @@ class CookieStorage {
223
165
  // Return the completed encoded string.
224
166
  return [encodedToken, '=', encodedValue, this.stringifyCookie(attributes)].join('');
225
167
  }
168
+ decode = (cookieString) => {
169
+ const result = {};
170
+ const cookies = cookieString ? cookieString.split('; ') : [];
171
+ const rdecode = /(%[0-9A-Z]{2})+/g;
172
+ for (let index = 0; index < cookies.length; index++) {
173
+ const parts = cookies[index].split('=');
174
+ let cookie = parts.slice(1).join('=');
175
+ if (cookie.charAt(0) === '"') {
176
+ cookie = cookie.slice(1, -1);
177
+ }
178
+ try {
179
+ const name = parts[0].replace(rdecode, decodeURIComponent);
180
+ const value = cookie.replace(rdecode, decodeURIComponent);
181
+ result[name] = this.jsonParse(value);
182
+ }
183
+ catch {
184
+ // Ignore cookies with an invalid name/value encoding.
185
+ }
186
+ }
187
+ return result;
188
+ };
189
+ jsonParse = (rawValue) => {
190
+ // Try to parse the data.
191
+ let parsedValue = undefined;
192
+ // Only parse the value when it is not null.
193
+ if (rawValue !== undefined) {
194
+ try {
195
+ parsedValue = JSON.parse(rawValue);
196
+ }
197
+ catch {
198
+ // The string could not be parsed to JSON.
199
+ }
200
+ }
201
+ // Return the parsed value.
202
+ return parsedValue;
203
+ };
226
204
  stringifyCookie(attributes) {
227
205
  // Make sure the expires attribute is a date and not a number.
228
206
  if (typeof attributes.expires === 'number') {
@@ -242,26 +220,36 @@ class CookieStorage {
242
220
  + this.stringifyAttribute('Secure', attributes.secure)
243
221
  + this.stringifyAttribute('SameSite', attributes.sameSite);
244
222
  }
223
+ stringifyAttribute = (token, value) => {
224
+ if (!value) {
225
+ return '';
226
+ }
227
+ const stringified = `; ${token}`;
228
+ // Boolean attributes should not have a value.
229
+ if (value === true) {
230
+ return stringified;
231
+ }
232
+ return stringified + `= ${value}`;
233
+ };
234
+ testIfSupported = () => {
235
+ // We are using an aggressive test here, because we cannot rely on navigator.cookieEnabled
236
+ // it does not return the correct value at all times.
237
+ const testCookieString = `bbcookietest`;
238
+ try {
239
+ document.cookie = `${testCookieString}=1`;
240
+ const result = document.cookie.indexOf(`${testCookieString}=`) !== -1;
241
+ document.cookie = `${testCookieString}=1; expires=Thu, 01-Jan-1970 00:00:01 GMT`;
242
+ return result;
243
+ }
244
+ catch {
245
+ return false;
246
+ }
247
+ };
245
248
  }
246
249
 
247
250
  class MemoryStorage {
248
- constructor() {
249
- // State.
250
- this._storage = {};
251
- this.encode = (value, attributes) => {
252
- const data = { value };
253
- // Make sure the expires is a date object.
254
- if (typeof attributes.expires === 'number') {
255
- attributes.expires = new Date(attributes.expires);
256
- }
257
- // Add the expire date if it was set.
258
- if (attributes.expires) {
259
- data['expires'] = attributes.expires;
260
- }
261
- // Return the encoded data.
262
- return data;
263
- };
264
- }
251
+ // State.
252
+ _storage = {};
265
253
  get(token) {
266
254
  // Grab the data from the memory storage.
267
255
  const result = this._storage[token];
@@ -298,30 +286,31 @@ class MemoryStorage {
298
286
  // The memory storage is always supported.
299
287
  return true;
300
288
  }
289
+ encode = (value, attributes) => {
290
+ const data = { value };
291
+ // Make sure the expires is a date object.
292
+ if (typeof attributes.expires === 'number') {
293
+ attributes.expires = new Date(attributes.expires);
294
+ }
295
+ // Add the expire date if it was set.
296
+ if (attributes.expires) {
297
+ data['expires'] = attributes.expires;
298
+ }
299
+ // Return the encoded data.
300
+ return data;
301
+ };
301
302
  }
302
303
 
303
304
  class Storage {
305
+ _platform;
306
+ _cookieString;
307
+ // All available strategies (sorted best to last).
308
+ _strategies;
309
+ // Current selected storage strategy.
310
+ _current = null;
304
311
  constructor(_platform, _cookieString) {
305
312
  this._platform = _platform;
306
313
  this._cookieString = _cookieString;
307
- // Current selected storage strategy.
308
- this._current = null;
309
- this.getLocalStorage = () => {
310
- try {
311
- return (typeof window !== 'undefined') ? window?.localStorage : null;
312
- }
313
- catch {
314
- return null;
315
- }
316
- };
317
- this.getSessionStorage = () => {
318
- try {
319
- return (typeof window !== 'undefined') ? window?.sessionStorage : null;
320
- }
321
- catch {
322
- return null;
323
- }
324
- };
325
314
  this._strategies = {
326
315
  ["local" /* StorageOption.Local */]: new PolyfillStorage(this.getLocalStorage()),
327
316
  ["cookie" /* StorageOption.Cookie */]: new CookieStorage(this._platform.isBrowser, this._cookieString),
@@ -387,8 +376,24 @@ class Storage {
387
376
  }
388
377
  return this._strategies.memory;
389
378
  }
390
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: Storage, deps: [{ token: i1.Platform }, { token: COOKIE, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
391
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: Storage, providedIn: 'root' }); }
379
+ getLocalStorage = () => {
380
+ try {
381
+ return (typeof window !== 'undefined') ? window?.localStorage : null;
382
+ }
383
+ catch {
384
+ return null;
385
+ }
386
+ };
387
+ getSessionStorage = () => {
388
+ try {
389
+ return (typeof window !== 'undefined') ? window?.sessionStorage : null;
390
+ }
391
+ catch {
392
+ return null;
393
+ }
394
+ };
395
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: Storage, deps: [{ token: i1.Platform }, { token: COOKIE, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
396
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: Storage, providedIn: 'root' });
392
397
  }
393
398
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: Storage, decorators: [{
394
399
  type: Injectable,
@@ -1 +1 @@
1
- {"version":3,"file":"bravobit-bb-foundation-storage.mjs","sources":["../../../projects/bb-foundation/storage/src/lib/strategies/polyfill-storage.strategy.ts","../../../projects/bb-foundation/storage/src/lib/strategies/cookie-storage.strategy.ts","../../../projects/bb-foundation/storage/src/lib/strategies/memory-storage.strategy.ts","../../../projects/bb-foundation/storage/src/lib/storage.service.ts","../../../projects/bb-foundation/storage/src/bravobit-bb-foundation-storage.ts"],"sourcesContent":["import {PolyfillStorageAttributes} from '../interfaces/attributes.interface';\nimport {StorageStrategy} from '../interfaces/strategy.interface';\n\nexport class PolyfillStorage implements StorageStrategy {\n\n // State.\n private readonly _isSupported: boolean = false;\n\n constructor(private _storage?: Storage) {\n // Check if the storage is supported.\n this._isSupported = this.testIfSupported();\n }\n\n get<T = any>(token: string) {\n // Validate that the storage is supported.\n if (!this._isSupported) {\n return undefined;\n }\n\n return this.decode<T>(token);\n }\n\n set<T = any>(token: string, value: T, attributes?: PolyfillStorageAttributes) {\n // Validate that the storage is supported.\n if (!this._isSupported) {\n return;\n }\n\n // Stringify the data.\n const rawData = this.encode<T>(value, {...attributes});\n\n // Set the raw data in the storage.\n this._storage.setItem(token, rawData);\n }\n\n remove(token: string) {\n // Validate that the storage is supported.\n if (!this._isSupported) {\n return;\n }\n\n // Remove the item in the storage.\n this._storage.removeItem(token);\n }\n\n clear() {\n // Validate that the storage is supported.\n if (!this._isSupported) {\n return;\n }\n\n // Clear the storage.\n this._storage.clear();\n }\n\n isSupported() {\n return this._isSupported;\n }\n\n private decode<T>(token: string) {\n // Retrieve the raw data from the storage.\n const rawData = this._storage.getItem(token);\n\n // Try to parse the data.\n let parsedData: T | undefined = undefined;\n\n // Only parse the data when it is not null.\n if (rawData !== null) {\n try {\n const {value, expires} = JSON.parse(rawData);\n\n if (expires !== undefined) {\n const now = Date.now();\n const expireDate = new Date(expires).getTime();\n\n if (expireDate <= now) {\n this.remove(token);\n return undefined;\n }\n }\n\n parsedData = value;\n } catch {\n // We dont do anything with failed parsing.\n }\n }\n\n // Return the parsed data.\n return parsedData;\n }\n\n private encode = <T>(value: T, attributes: PolyfillStorageAttributes) => {\n // Make sure the expires attribute is a date and not a number.\n const data = {value};\n\n if (typeof attributes.expires === 'number') {\n attributes.expires = new Date(attributes.expires);\n }\n\n if (attributes.expires) {\n data['expires'] = attributes.expires;\n }\n\n return JSON.stringify(data);\n };\n\n private testIfSupported = () => {\n if (typeof this._storage === 'undefined') {\n return false;\n }\n\n try {\n const x = '__storage_test__';\n this._storage.setItem(x, x);\n this._storage.removeItem(x);\n return true;\n } catch (error) {\n return error instanceof DOMException\n && (error.name === 'QuotaExceededError' || error.name === 'NS_ERROR_DOM_QUOTA_REACHED')\n && (this._storage && this._storage.length !== 0);\n }\n };\n\n}\n","import {CookieStorageAttributes} from '../interfaces/attributes.interface';\nimport {StorageStrategy} from '../interfaces/strategy.interface';\n\nexport class CookieStorage implements StorageStrategy {\n\n // State.\n private readonly _isSupported: boolean = false;\n\n constructor(private _isBrowser: boolean,\n private _cookieString?: string) {\n // Check if the storage is supported.\n this._isSupported = this.testIfSupported();\n }\n\n get<T = any>(token: string) {\n // Get all values and pick one out.\n const values = this.all();\n return values?.[token] as T;\n }\n\n set<T = any>(token: string, value: T, attributes?: CookieStorageAttributes) {\n // Validate that the storage is supported.\n if (!this._isSupported) {\n return;\n }\n\n // Write a new cookie.\n document.cookie = this.encode(token, value, {path: '/', sameSite: 'Lax', ...attributes});\n }\n\n remove(token: string, attributes?: CookieStorageAttributes) {\n // Validate that the storage is supported.\n if (!this._isSupported) {\n return;\n }\n\n this.set(token, '', {...attributes, expires: -1});\n }\n\n clear(attributes?: CookieStorageAttributes) {\n // Validate that the storage is supported.\n if (!this._isSupported) {\n return;\n }\n\n const items = this.all();\n\n for (const token in items) {\n this.remove(token, attributes);\n }\n }\n\n isSupported() {\n return this._isSupported;\n }\n\n private all() {\n const cookieString = this._isBrowser\n ? document?.cookie\n : this._cookieString;\n\n return this.decode(cookieString);\n }\n\n private encode(token: string, value: any, attributes: CookieStorageAttributes) {\n // Encode the token.\n const encodedToken = encodeURIComponent(token)\n .replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent)\n .replace(/\\(/g, '%28').replace(/\\)/g, '%29');\n\n const rawValue = JSON.stringify(value);\n\n // Encode the value.\n const encodedValue = encodeURIComponent(rawValue)\n .replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent);\n\n // Return the completed encoded string.\n return [encodedToken, '=', encodedValue, this.stringifyCookie(attributes)].join('');\n }\n\n private decode = (cookieString: string) => {\n const result: { [token: string]: any } = {};\n const cookies = cookieString ? cookieString.split('; ') : [];\n const rdecode = /(%[0-9A-Z]{2})+/g;\n\n for (let index = 0; index < cookies.length; index++) {\n const parts = cookies[index].split('=');\n let cookie = parts.slice(1).join('=');\n\n if (cookie.charAt(0) === '\"') {\n cookie = cookie.slice(1, -1);\n }\n\n try {\n const name = parts[0].replace(rdecode, decodeURIComponent);\n const value = cookie.replace(rdecode, decodeURIComponent);\n result[name] = this.jsonParse(value);\n } catch {\n // Ignore cookies with an invalid name/value encoding.\n }\n }\n\n return result;\n };\n\n private jsonParse = <T = any>(rawValue: string) => {\n // Try to parse the data.\n let parsedValue: T | undefined = undefined;\n\n // Only parse the value when it is not null.\n if (rawValue !== undefined) {\n try {\n parsedValue = JSON.parse(rawValue);\n } catch {\n // The string could not be parsed to JSON.\n }\n }\n\n // Return the parsed value.\n return parsedValue;\n };\n\n private stringifyCookie(attributes: CookieStorageAttributes) {\n // Make sure the expires attribute is a date and not a number.\n if (typeof attributes.expires === 'number') {\n const expires = new Date();\n expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 864e+5);\n attributes.expires = expires;\n }\n\n // Force secure when sameSite=None.\n if (attributes.sameSite === 'None') {\n attributes.secure = true;\n console?.warn?.('Cooke was forced with secure flag because sameSite=None');\n }\n\n // Stringify all attributes.\n return this.stringifyAttribute('Expires', attributes.expires ? attributes.expires.toUTCString() : '')\n + this.stringifyAttribute('Domain', attributes.domain)\n + this.stringifyAttribute('Path', attributes.path)\n + this.stringifyAttribute('Secure', attributes.secure)\n + this.stringifyAttribute('SameSite', attributes.sameSite);\n }\n\n private stringifyAttribute = (token: string, value: string | boolean | undefined) => {\n if (!value) {\n return '';\n }\n\n const stringified = `; ${token}`;\n\n // Boolean attributes should not have a value.\n if (value === true) {\n return stringified;\n }\n\n return stringified + `= ${value}`;\n };\n\n private testIfSupported = () => {\n // We are using an aggressive test here, because we cannot rely on navigator.cookieEnabled\n // it does not return the correct value at all times.\n const testCookieString = `bbcookietest`;\n try {\n document.cookie = `${testCookieString}=1`;\n const result = document.cookie.indexOf(`${testCookieString}=`) !== -1;\n document.cookie = `${testCookieString}=1; expires=Thu, 01-Jan-1970 00:00:01 GMT`;\n return result;\n } catch {\n return false;\n }\n };\n\n}\n","import {MemoryStorageAttributes} from '../interfaces/attributes.interface';\nimport {MemoryStorageData} from '../interfaces/memory.interface';\nimport {StorageStrategy} from '../interfaces/strategy.interface';\n\nexport class MemoryStorage implements StorageStrategy {\n\n // State.\n private _storage: MemoryStorageData = {};\n\n get<T = any>(token: string): T {\n // Grab the data from the memory storage.\n const result = this._storage[token];\n\n // Validate the data exists.\n if (result === undefined) {\n return undefined;\n }\n\n // Extract the value and expire date.\n const {value, expires} = result;\n\n // Validate the value is still valid.\n if (expires !== undefined) {\n const now = Date.now();\n const expireDate = new Date(expires).getTime();\n\n // Remove the value if it is expired.\n if (expireDate <= now) {\n this.remove(token);\n return undefined;\n }\n }\n\n // Return the value.\n return value;\n }\n\n set<T = any>(token: string, value: T, attributes?: MemoryStorageAttributes) {\n // Save the encoded value with the attributes.\n this._storage[token] = this.encode<T>(value, {...attributes});\n }\n\n remove(token: string) {\n delete this._storage[token];\n }\n\n clear() {\n this._storage = {};\n }\n\n isSupported() {\n // The memory storage is always supported.\n return true;\n }\n\n private encode = <T>(value: T, attributes: MemoryStorageAttributes) => {\n const data = {value};\n\n // Make sure the expires is a date object.\n if (typeof attributes.expires === 'number') {\n attributes.expires = new Date(attributes.expires);\n }\n\n // Add the expire date if it was set.\n if (attributes.expires) {\n data['expires'] = attributes.expires;\n }\n\n // Return the encoded data.\n return data;\n };\n\n}\n","import {StorageOption, StorageStrategy} from './interfaces/strategy.interface';\nimport {PolyfillStorage} from './strategies/polyfill-storage.strategy';\nimport {StorageAttributes} from './interfaces/attributes.interface';\nimport {CookieStorage} from './strategies/cookie-storage.strategy';\nimport {MemoryStorage} from './strategies/memory-storage.strategy';\nimport {Inject, Injectable, Optional} from '@angular/core';\nimport {Platform} from '@angular/cdk/platform';\nimport {COOKIE} from '@bravobit/bb-foundation';\n\ndeclare let ngDevMode;\n\n@Injectable({\n providedIn: 'root'\n})\nexport class Storage implements StorageStrategy {\n\n // All available strategies (sorted best to last).\n private readonly _strategies: { [key in `${StorageOption}`]: StorageStrategy };\n\n // Current selected storage strategy.\n private readonly _current: StorageStrategy | null = null;\n\n constructor(private _platform: Platform,\n @Optional() @Inject(COOKIE) private _cookieString?: string) {\n this._strategies = {\n [StorageOption.Local]: new PolyfillStorage(this.getLocalStorage()),\n [StorageOption.Cookie]: new CookieStorage(this._platform.isBrowser, this._cookieString),\n [StorageOption.Session]: new PolyfillStorage(this.getSessionStorage()),\n [StorageOption.Memory]: new MemoryStorage()\n };\n\n this._current = this.findBestStorageStrategy();\n }\n\n select(option: StorageOption | StorageOption[]) {\n const items = Array.isArray(option) ? option : [option];\n for (const item of items) {\n const strategy = this._strategies?.[item] ?? null;\n if (strategy && strategy.isSupported()) {\n return strategy;\n }\n }\n\n if (this._platform.isBrowser && (typeof ngDevMode === 'undefined' || ngDevMode)) {\n console?.warn?.('[Storage]: Could not select proper storage option, using memory fallback.');\n }\n\n // Always return as a fallback the memory storage since it should be always available.\n return this._strategies.memory;\n }\n\n get local() {\n return this._strategies.local;\n }\n\n get cookie() {\n return this._strategies.cookie;\n }\n\n get session() {\n return this._strategies.session;\n }\n\n get memory() {\n return this._strategies.memory;\n }\n\n get<T = any>(token: string): T {\n return this._current.get(token);\n }\n\n set<T = any>(token: string, value: T, attributes?: StorageAttributes) {\n this._current.set<T>(token, value, attributes);\n }\n\n remove(token: string, attributes?: StorageAttributes) {\n this._current.remove(token, attributes);\n }\n\n clear(attributes?: StorageAttributes) {\n this._current.clear(attributes);\n }\n\n isSupported() {\n return !!this._current;\n }\n\n private findBestStorageStrategy() {\n // Loop through all available strategies to find the best.\n for (const type in this._strategies) {\n const strategy = this._strategies?.[type];\n\n // The first supported strategy is the best.\n if (strategy?.isSupported()) {\n return strategy;\n }\n }\n\n // If no strategy was returned we fallback to memory\n // storage since it should be available always.\n if (this._platform.isBrowser && (typeof ngDevMode === 'undefined' || ngDevMode)) {\n console?.warn?.('[Storage]: Could not select proper storage option, using memory fallback.');\n }\n\n return this._strategies.memory;\n }\n\n private getLocalStorage = () => {\n try {\n return (typeof window !== 'undefined') ? window?.localStorage : null;\n } catch {\n return null;\n }\n };\n\n private getSessionStorage = () => {\n try {\n return (typeof window !== 'undefined') ? window?.sessionStorage : null;\n } catch {\n return null;\n }\n };\n\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;MAGa,eAAe,CAAA;AAKxB,IAAA,WAAA,CAAoB,QAAkB,EAAA;QAAlB,IAAQ,CAAA,QAAA,GAAR,QAAQ,CAAU;;QAFrB,IAAY,CAAA,YAAA,GAAY,KAAK,CAAC;AAqFvC,QAAA,IAAA,CAAA,MAAM,GAAG,CAAI,KAAQ,EAAE,UAAqC,KAAI;;AAEpE,YAAA,MAAM,IAAI,GAAG,EAAC,KAAK,EAAC,CAAC;AAErB,YAAA,IAAI,OAAO,UAAU,CAAC,OAAO,KAAK,QAAQ,EAAE;gBACxC,UAAU,CAAC,OAAO,GAAG,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;aACrD;AAED,YAAA,IAAI,UAAU,CAAC,OAAO,EAAE;AACpB,gBAAA,IAAI,CAAC,SAAS,CAAC,GAAG,UAAU,CAAC,OAAO,CAAC;aACxC;AAED,YAAA,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;AAChC,SAAC,CAAC;QAEM,IAAe,CAAA,eAAA,GAAG,MAAK;AAC3B,YAAA,IAAI,OAAO,IAAI,CAAC,QAAQ,KAAK,WAAW,EAAE;AACtC,gBAAA,OAAO,KAAK,CAAC;aAChB;AAED,YAAA,IAAI;gBACA,MAAM,CAAC,GAAG,kBAAkB,CAAC;gBAC7B,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC5B,gBAAA,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AAC5B,gBAAA,OAAO,IAAI,CAAC;aACf;YAAC,OAAO,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,EAAA,EAAA,IAAA,EAAA,OAAO,cAFJ,MAAM,EAAA,CAAA,CAAA,EAAA;;2FAET,OAAO,EAAA,UAAA,EAAA,CAAA;kBAHnB,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,UAAU,EAAE,MAAM;AACrB,iBAAA,CAAA;;0BAUgB,QAAQ;;0BAAI,MAAM;2BAAC,MAAM,CAAA;;;ACvB1C;;AAEG;;;;"}
1
+ {"version":3,"file":"bravobit-bb-foundation-storage.mjs","sources":["../../../projects/bb-foundation/storage/src/lib/strategies/polyfill-storage.strategy.ts","../../../projects/bb-foundation/storage/src/lib/strategies/cookie-storage.strategy.ts","../../../projects/bb-foundation/storage/src/lib/strategies/memory-storage.strategy.ts","../../../projects/bb-foundation/storage/src/lib/storage.service.ts","../../../projects/bb-foundation/storage/src/bravobit-bb-foundation-storage.ts"],"sourcesContent":["import {PolyfillStorageAttributes} from '../interfaces/attributes.interface';\nimport {StorageStrategy} from '../interfaces/strategy.interface';\n\nexport class PolyfillStorage implements StorageStrategy {\n\n // State.\n private readonly _isSupported: boolean = false;\n\n constructor(private _storage?: Storage) {\n // Check if the storage is supported.\n this._isSupported = this.testIfSupported();\n }\n\n get<T = any>(token: string) {\n // Validate that the storage is supported.\n if (!this._isSupported) {\n return undefined;\n }\n\n return this.decode<T>(token);\n }\n\n set<T = any>(token: string, value: T, attributes?: PolyfillStorageAttributes) {\n // Validate that the storage is supported.\n if (!this._isSupported) {\n return;\n }\n\n // Stringify the data.\n const rawData = this.encode<T>(value, {...attributes});\n\n // Set the raw data in the storage.\n this._storage.setItem(token, rawData);\n }\n\n remove(token: string) {\n // Validate that the storage is supported.\n if (!this._isSupported) {\n return;\n }\n\n // Remove the item in the storage.\n this._storage.removeItem(token);\n }\n\n clear() {\n // Validate that the storage is supported.\n if (!this._isSupported) {\n return;\n }\n\n // Clear the storage.\n this._storage.clear();\n }\n\n isSupported() {\n return this._isSupported;\n }\n\n private decode<T>(token: string) {\n // Retrieve the raw data from the storage.\n const rawData = this._storage.getItem(token);\n\n // Try to parse the data.\n let parsedData: T | undefined = undefined;\n\n // Only parse the data when it is not null.\n if (rawData !== null) {\n try {\n const {value, expires} = JSON.parse(rawData);\n\n if (expires !== undefined) {\n const now = Date.now();\n const expireDate = new Date(expires).getTime();\n\n if (expireDate <= now) {\n this.remove(token);\n return undefined;\n }\n }\n\n parsedData = value;\n } catch {\n // We dont do anything with failed parsing.\n }\n }\n\n // Return the parsed data.\n return parsedData;\n }\n\n private encode = <T>(value: T, attributes: PolyfillStorageAttributes) => {\n // Make sure the expires attribute is a date and not a number.\n const data = {value};\n\n if (typeof attributes.expires === 'number') {\n attributes.expires = new Date(attributes.expires);\n }\n\n if (attributes.expires) {\n data['expires'] = attributes.expires;\n }\n\n return JSON.stringify(data);\n };\n\n private testIfSupported = () => {\n if (typeof this._storage === 'undefined') {\n return false;\n }\n\n try {\n const x = '__storage_test__';\n this._storage.setItem(x, x);\n this._storage.removeItem(x);\n return true;\n } catch (error) {\n return error instanceof DOMException\n && (error.name === 'QuotaExceededError' || error.name === 'NS_ERROR_DOM_QUOTA_REACHED')\n && (this._storage && this._storage.length !== 0);\n }\n };\n\n}\n","import {CookieStorageAttributes} from '../interfaces/attributes.interface';\nimport {StorageStrategy} from '../interfaces/strategy.interface';\n\nexport class CookieStorage implements StorageStrategy {\n\n // State.\n private readonly _isSupported: boolean = false;\n\n constructor(private _isBrowser: boolean,\n private _cookieString?: string) {\n // Check if the storage is supported.\n this._isSupported = this.testIfSupported();\n }\n\n get<T = any>(token: string) {\n // Get all values and pick one out.\n const values = this.all();\n return values?.[token] as T;\n }\n\n set<T = any>(token: string, value: T, attributes?: CookieStorageAttributes) {\n // Validate that the storage is supported.\n if (!this._isSupported) {\n return;\n }\n\n // Write a new cookie.\n document.cookie = this.encode(token, value, {path: '/', sameSite: 'Lax', ...attributes});\n }\n\n remove(token: string, attributes?: CookieStorageAttributes) {\n // Validate that the storage is supported.\n if (!this._isSupported) {\n return;\n }\n\n this.set(token, '', {...attributes, expires: -1});\n }\n\n clear(attributes?: CookieStorageAttributes) {\n // Validate that the storage is supported.\n if (!this._isSupported) {\n return;\n }\n\n const items = this.all();\n\n for (const token in items) {\n this.remove(token, attributes);\n }\n }\n\n isSupported() {\n return this._isSupported;\n }\n\n private all() {\n const cookieString = this._isBrowser\n ? document?.cookie\n : this._cookieString;\n\n return this.decode(cookieString);\n }\n\n private encode(token: string, value: any, attributes: CookieStorageAttributes) {\n // Encode the token.\n const encodedToken = encodeURIComponent(token)\n .replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent)\n .replace(/\\(/g, '%28').replace(/\\)/g, '%29');\n\n const rawValue = JSON.stringify(value);\n\n // Encode the value.\n const encodedValue = encodeURIComponent(rawValue)\n .replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent);\n\n // Return the completed encoded string.\n return [encodedToken, '=', encodedValue, this.stringifyCookie(attributes)].join('');\n }\n\n private decode = (cookieString: string) => {\n const result: { [token: string]: any } = {};\n const cookies = cookieString ? cookieString.split('; ') : [];\n const rdecode = /(%[0-9A-Z]{2})+/g;\n\n for (let index = 0; index < cookies.length; index++) {\n const parts = cookies[index].split('=');\n let cookie = parts.slice(1).join('=');\n\n if (cookie.charAt(0) === '\"') {\n cookie = cookie.slice(1, -1);\n }\n\n try {\n const name = parts[0].replace(rdecode, decodeURIComponent);\n const value = cookie.replace(rdecode, decodeURIComponent);\n result[name] = this.jsonParse(value);\n } catch {\n // Ignore cookies with an invalid name/value encoding.\n }\n }\n\n return result;\n };\n\n private jsonParse = <T = any>(rawValue: string) => {\n // Try to parse the data.\n let parsedValue: T | undefined = undefined;\n\n // Only parse the value when it is not null.\n if (rawValue !== undefined) {\n try {\n parsedValue = JSON.parse(rawValue);\n } catch {\n // The string could not be parsed to JSON.\n }\n }\n\n // Return the parsed value.\n return parsedValue;\n };\n\n private stringifyCookie(attributes: CookieStorageAttributes) {\n // Make sure the expires attribute is a date and not a number.\n if (typeof attributes.expires === 'number') {\n const expires = new Date();\n expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 864e+5);\n attributes.expires = expires;\n }\n\n // Force secure when sameSite=None.\n if (attributes.sameSite === 'None') {\n attributes.secure = true;\n console?.warn?.('Cooke was forced with secure flag because sameSite=None');\n }\n\n // Stringify all attributes.\n return this.stringifyAttribute('Expires', attributes.expires ? attributes.expires.toUTCString() : '')\n + this.stringifyAttribute('Domain', attributes.domain)\n + this.stringifyAttribute('Path', attributes.path)\n + this.stringifyAttribute('Secure', attributes.secure)\n + this.stringifyAttribute('SameSite', attributes.sameSite);\n }\n\n private stringifyAttribute = (token: string, value: string | boolean | undefined) => {\n if (!value) {\n return '';\n }\n\n const stringified = `; ${token}`;\n\n // Boolean attributes should not have a value.\n if (value === true) {\n return stringified;\n }\n\n return stringified + `= ${value}`;\n };\n\n private testIfSupported = () => {\n // We are using an aggressive test here, because we cannot rely on navigator.cookieEnabled\n // it does not return the correct value at all times.\n const testCookieString = `bbcookietest`;\n try {\n document.cookie = `${testCookieString}=1`;\n const result = document.cookie.indexOf(`${testCookieString}=`) !== -1;\n document.cookie = `${testCookieString}=1; expires=Thu, 01-Jan-1970 00:00:01 GMT`;\n return result;\n } catch {\n return false;\n }\n };\n\n}\n","import {MemoryStorageAttributes} from '../interfaces/attributes.interface';\nimport {MemoryStorageData} from '../interfaces/memory.interface';\nimport {StorageStrategy} from '../interfaces/strategy.interface';\n\nexport class MemoryStorage implements StorageStrategy {\n\n // State.\n private _storage: MemoryStorageData = {};\n\n get<T = any>(token: string): T {\n // Grab the data from the memory storage.\n const result = this._storage[token];\n\n // Validate the data exists.\n if (result === undefined) {\n return undefined;\n }\n\n // Extract the value and expire date.\n const {value, expires} = result;\n\n // Validate the value is still valid.\n if (expires !== undefined) {\n const now = Date.now();\n const expireDate = new Date(expires).getTime();\n\n // Remove the value if it is expired.\n if (expireDate <= now) {\n this.remove(token);\n return undefined;\n }\n }\n\n // Return the value.\n return value;\n }\n\n set<T = any>(token: string, value: T, attributes?: MemoryStorageAttributes) {\n // Save the encoded value with the attributes.\n this._storage[token] = this.encode<T>(value, {...attributes});\n }\n\n remove(token: string) {\n delete this._storage[token];\n }\n\n clear() {\n this._storage = {};\n }\n\n isSupported() {\n // The memory storage is always supported.\n return true;\n }\n\n private encode = <T>(value: T, attributes: MemoryStorageAttributes) => {\n const data = {value};\n\n // Make sure the expires is a date object.\n if (typeof attributes.expires === 'number') {\n attributes.expires = new Date(attributes.expires);\n }\n\n // Add the expire date if it was set.\n if (attributes.expires) {\n data['expires'] = attributes.expires;\n }\n\n // Return the encoded data.\n return data;\n };\n\n}\n","import {StorageOption, StorageStrategy} from './interfaces/strategy.interface';\nimport {PolyfillStorage} from './strategies/polyfill-storage.strategy';\nimport {StorageAttributes} from './interfaces/attributes.interface';\nimport {CookieStorage} from './strategies/cookie-storage.strategy';\nimport {MemoryStorage} from './strategies/memory-storage.strategy';\nimport {Inject, Injectable, Optional} from '@angular/core';\nimport {Platform} from '@angular/cdk/platform';\nimport {COOKIE} from '@bravobit/bb-foundation';\n\ndeclare let ngDevMode;\n\n@Injectable({\n providedIn: 'root'\n})\nexport class Storage implements StorageStrategy {\n\n // All available strategies (sorted best to last).\n private readonly _strategies: { [key in `${StorageOption}`]: StorageStrategy };\n\n // Current selected storage strategy.\n private readonly _current: StorageStrategy | null = null;\n\n constructor(private _platform: Platform,\n @Optional() @Inject(COOKIE) private _cookieString?: string) {\n this._strategies = {\n [StorageOption.Local]: new PolyfillStorage(this.getLocalStorage()),\n [StorageOption.Cookie]: new CookieStorage(this._platform.isBrowser, this._cookieString),\n [StorageOption.Session]: new PolyfillStorage(this.getSessionStorage()),\n [StorageOption.Memory]: new MemoryStorage()\n };\n\n this._current = this.findBestStorageStrategy();\n }\n\n select(option: StorageOption | StorageOption[]) {\n const items = Array.isArray(option) ? option : [option];\n for (const item of items) {\n const strategy = this._strategies?.[item] ?? null;\n if (strategy && strategy.isSupported()) {\n return strategy;\n }\n }\n\n if (this._platform.isBrowser && (typeof ngDevMode === 'undefined' || ngDevMode)) {\n console?.warn?.('[Storage]: Could not select proper storage option, using memory fallback.');\n }\n\n // Always return as a fallback the memory storage since it should be always available.\n return this._strategies.memory;\n }\n\n get local() {\n return this._strategies.local;\n }\n\n get cookie() {\n return this._strategies.cookie;\n }\n\n get session() {\n return this._strategies.session;\n }\n\n get memory() {\n return this._strategies.memory;\n }\n\n get<T = any>(token: string): T {\n return this._current.get(token);\n }\n\n set<T = any>(token: string, value: T, attributes?: StorageAttributes) {\n this._current.set<T>(token, value, attributes);\n }\n\n remove(token: string, attributes?: StorageAttributes) {\n this._current.remove(token, attributes);\n }\n\n clear(attributes?: StorageAttributes) {\n this._current.clear(attributes);\n }\n\n isSupported() {\n return !!this._current;\n }\n\n private findBestStorageStrategy() {\n // Loop through all available strategies to find the best.\n for (const type in this._strategies) {\n const strategy = this._strategies?.[type];\n\n // The first supported strategy is the best.\n if (strategy?.isSupported()) {\n return strategy;\n }\n }\n\n // If no strategy was returned we fallback to memory\n // storage since it should be available always.\n if (this._platform.isBrowser && (typeof ngDevMode === 'undefined' || ngDevMode)) {\n console?.warn?.('[Storage]: Could not select proper storage option, using memory fallback.');\n }\n\n return this._strategies.memory;\n }\n\n private getLocalStorage = () => {\n try {\n return (typeof window !== 'undefined') ? window?.localStorage : null;\n } catch {\n return null;\n }\n };\n\n private getSessionStorage = () => {\n try {\n return (typeof window !== 'undefined') ? window?.sessionStorage : null;\n } catch {\n return null;\n }\n };\n\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;MAGa,eAAe,CAAA;AAKJ,IAAA,QAAA,CAAA;;IAFH,YAAY,GAAY,KAAK,CAAC;AAE/C,IAAA,WAAA,CAAoB,QAAkB,EAAA;QAAlB,IAAQ,CAAA,QAAA,GAAR,QAAQ,CAAU;;AAElC,QAAA,IAAI,CAAC,YAAY,GAAG,I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