@braze/web-sdk 6.11.0 → 6.12.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 (102) hide show
  1. package/index.d.ts +36 -5
  2. package/package.json +1 -1
  3. package/shared-lib/event-types.js +4 -4
  4. package/shared-lib/indexed-db-adapter.js +51 -51
  5. package/shared-lib/logger.js +7 -7
  6. package/shared-lib/supported-options.js +9 -9
  7. package/src/DUST/dust-config-store.js +89 -0
  8. package/src/DUST/dust-connection-core.js +7 -21
  9. package/src/DUST/dust-message-dedup.js +33 -0
  10. package/src/DUST/dust-provider.js +367 -397
  11. package/src/DUST/dust-tab-identity.js +30 -0
  12. package/src/DUST/index.js +7 -9
  13. package/src/DUST/subscribe-to-dust.js +5 -5
  14. package/src/FeatureFlags/feature-flag-factory.js +4 -4
  15. package/src/FeatureFlags/feature-flag.js +5 -5
  16. package/src/FeatureFlags/feature-flags-provider-factory.js +8 -1
  17. package/src/FeatureFlags/feature-flags-provider.js +74 -74
  18. package/src/FeatureFlags/get-all-feature-flags.js +2 -2
  19. package/src/FeatureFlags/get-feature-flag.js +2 -2
  20. package/src/FeatureFlags/log-feature-flag-impression.js +3 -3
  21. package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +1 -1
  22. package/src/InAppMessage/defer-in-app-message.js +2 -2
  23. package/src/InAppMessage/display/get-animation-effect.js +1 -1
  24. package/src/InAppMessage/display/html-message-display-utils.js +4 -4
  25. package/src/InAppMessage/display/html-message-to-html.js +10 -10
  26. package/src/InAppMessage/display/in-app-message-to-html.js +42 -42
  27. package/src/InAppMessage/display/modal-utils.js +14 -14
  28. package/src/InAppMessage/get-deferred-in-app-message.js +2 -2
  29. package/src/InAppMessage/in-app-message-factory.js +6 -6
  30. package/src/InAppMessage/in-app-message-manager-factory.js +5 -5
  31. package/src/InAppMessage/in-app-message-manager.js +73 -73
  32. package/src/InAppMessage/log-in-app-message-button-click.js +2 -2
  33. package/src/InAppMessage/log-in-app-message-click.js +2 -2
  34. package/src/InAppMessage/log-in-app-message-html-click.js +2 -2
  35. package/src/InAppMessage/log-in-app-message-impression.js +2 -2
  36. package/src/InAppMessage/models/full-screen-message.js +9 -9
  37. package/src/InAppMessage/models/html-message.js +4 -4
  38. package/src/InAppMessage/models/in-app-message-button.js +2 -2
  39. package/src/InAppMessage/models/in-app-message.js +52 -52
  40. package/src/InAppMessage/models/modal-message.js +7 -7
  41. package/src/InAppMessage/models/slide-up-message.js +11 -11
  42. package/src/InAppMessage/models/templated-in-app-message.js +8 -8
  43. package/src/InAppMessage/subscribe-to-in-app-message.js +2 -2
  44. package/src/InAppMessage/ui/automatically-show-in-app-messages.js +5 -5
  45. package/src/InAppMessage/ui/show-in-app-message.js +36 -36
  46. package/src/Push/is-push-blocked.js +2 -2
  47. package/src/Push/is-push-permission-granted.js +2 -2
  48. package/src/Push/is-push-supported.js +2 -2
  49. package/src/Push/push-manager-factory.js +6 -6
  50. package/src/Push/push-manager.js +14 -14
  51. package/src/Push/unregister-push-token-on-server.js +3 -3
  52. package/src/Push/utils/push-utils.js +10 -10
  53. package/src/User/user.js +19 -19
  54. package/src/common/content-cards-display.js +21 -21
  55. package/src/common/event-logger.js +2 -2
  56. package/src/l10n/l10n-manager-factory.js +7 -7
  57. package/src/l10n/l10n-manager.js +5 -5
  58. package/src/managers/auth-manager.js +1 -1
  59. package/src/managers/braze-instance.js +41 -41
  60. package/src/managers/device-manager.js +22 -22
  61. package/src/managers/network-manager.js +108 -108
  62. package/src/managers/server-config-manager.js +83 -83
  63. package/src/managers/session-manager.js +6 -6
  64. package/src/managers/storage-manager-factory.js +4 -4
  65. package/src/managers/storage-manager.js +127 -125
  66. package/src/managers/subscription-manager.js +1 -1
  67. package/src/managers/utils.js +1 -1
  68. package/src/models/backend-errors.js +5 -5
  69. package/src/models/braze-event.js +7 -7
  70. package/src/models/device.js +3 -3
  71. package/src/models/identifier.js +3 -3
  72. package/src/models/push-token.js +3 -3
  73. package/src/models/server-config.js +31 -31
  74. package/src/request-controller.js +39 -39
  75. package/src/triggers/models/filter.js +58 -58
  76. package/src/triggers/models/in-app-message-click-data.js +4 -4
  77. package/src/triggers/models/push-click-data.js +2 -2
  78. package/src/triggers/models/trigger-condition.js +35 -35
  79. package/src/triggers/models/trigger.js +37 -37
  80. package/src/triggers/triggers-provider-factory.js +3 -3
  81. package/src/triggers/triggers-provider.js +50 -50
  82. package/src/types.js +2 -2
  83. package/src/ui/js/attach-css.js +1 -1
  84. package/src/ui/js/feed-css.js +2 -2
  85. package/src/ui/js/iam-css.js +2 -2
  86. package/src/util/base-device-parser.js +2 -2
  87. package/src/util/braze-actions.js +2 -2
  88. package/src/util/browser-detector.js +15 -15
  89. package/src/util/client-hints-parser.js +5 -5
  90. package/src/util/component-utils.js +4 -4
  91. package/src/util/dom-utils.js +5 -5
  92. package/src/util/ecommerce-event-validation.js +77 -48
  93. package/src/util/key-codes.js +1 -1
  94. package/src/util/net.js +4 -4
  95. package/src/util/request-header-utils.js +20 -20
  96. package/src/util/string-utils.js +5 -0
  97. package/src/util/user-agent-parser.js +18 -18
  98. package/src/util/validation-utils.js +4 -4
  99. package/src/util/window-utils.js +2 -2
  100. package/src/DUST/dust-shared-worker-code.js +0 -2
  101. package/src/DUST/dust-shared-worker-impl.js +0 -234
  102. package/src/DUST/dust-worker-bridge.js +0 -151
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Type definitions for @braze/web-sdk v6.11.0
2
+ * Type definitions for @braze/web-sdk v6.12.0
3
3
  * Project: https://github.com/braze-inc/braze-web-sdk
4
4
  * (c) Braze, Inc. 2026 - http://braze.com
5
5
  * License available at https://github.com/braze-inc/braze-web-sdk/blob/master/LICENSE
@@ -1652,6 +1652,37 @@ export interface EcommerceEventProperties {
1652
1652
  source: string;
1653
1653
  }
1654
1654
 
1655
+ /**
1656
+ * Optional metadata fields shared by `ecommerce.checkout_started` and `ecommerce.order_placed`,
1657
+ * only applicable to Shopify integrations.
1658
+ */
1659
+ export interface EcommerceEventMetadata {
1660
+ /**
1661
+ * ISO country code of the market, only applicable to Shopify integrations. Cannot exceed 255 characters in length.
1662
+ */
1663
+ country?: string;
1664
+
1665
+ /**
1666
+ * Handle of the Shopify market, only applicable to Shopify integrations. Cannot exceed 255 characters in length.
1667
+ */
1668
+ market_handle?: string;
1669
+
1670
+ /**
1671
+ * Currency and amount the shopper was charged, only applicable to Shopify integrations.
1672
+ */
1673
+ presentment_currency?: {
1674
+ /**
1675
+ * ISO 4217 currency code of the presentment currency.
1676
+ */
1677
+ code?: string;
1678
+
1679
+ /**
1680
+ * Order total in presentment currency. Shopify stamps this as a string (e.g. `"525.00"`), not a number.
1681
+ */
1682
+ price?: string;
1683
+ };
1684
+ }
1685
+
1655
1686
  export interface CheckoutStartedEventProperties
1656
1687
  extends EcommerceEventProperties {
1657
1688
  /**
@@ -1695,7 +1726,7 @@ export interface CheckoutStartedEventProperties
1695
1726
  * Additional metadata about the checkout. Keys are limited to 255 characters in length, cannot begin with a $ character,
1696
1727
  * and can only contain alphanumeric characters and punctuation. Total size of metadata cannot exceed 50KB.
1697
1728
  */
1698
- metadata?: {
1729
+ metadata?: EcommerceEventMetadata & {
1699
1730
  checkout_url?: string;
1700
1731
  [key: string]: any;
1701
1732
  };
@@ -1867,7 +1898,7 @@ export interface OrderPlacedEventProperties extends EcommerceEventProperties {
1867
1898
  * Additional metadata about the product viewed. Keys are limited to 255 characters in length, cannot begin with a $ character,
1868
1899
  * and can only contain alphanumeric characters and punctuation. Total size of metadata cannot exceed 50KB.
1869
1900
  */
1870
- metadata?: {
1901
+ metadata?: EcommerceEventMetadata & {
1871
1902
  /**
1872
1903
  * The URL to view the status of the order. Cannot exceed 255 characters in length.
1873
1904
  */
@@ -2559,7 +2590,7 @@ export function logout(
2559
2590
  * - Create a `service-worker.js` file with the content below and place it in the root directory of your website:
2560
2591
  *
2561
2592
  * ```
2562
- * self.importScripts('https://js.appboycdn.com/web-sdk/6.11/service-worker.js');
2593
+ * self.importScripts('https://js.appboycdn.com/web-sdk/6.12/service-worker.js');
2563
2594
  * ```
2564
2595
  *
2565
2596
  * For more details, see [Our Product Documentation](https://www.braze.com/docs/developer_guide/platform_integration_guides/web/push_notifications/integration).
@@ -3005,7 +3036,7 @@ export type InitializationOptions = {
3005
3036
  * lifecycle of, set this option to true and the Braze SDK will not register or unregister a service worker. If you set this
3006
3037
  * option to true, in order for push to function correctly you must register the service worker yourself BEFORE calling
3007
3038
  * `requestPushPermission`, and ensure that it contains Braze's service worker code, either with
3008
- * `self.importScripts('https://js.appboycdn.com/web-sdk/6.11/service-worker.js');` or by including the content
3039
+ * `self.importScripts('https://js.appboycdn.com/web-sdk/6.12/service-worker.js');` or by including the content
3009
3040
  * of that file directly. When this option is true, the `serviceWorkerLocation` option is irrelevant and is ignored.
3010
3041
  */
3011
3042
  manageServiceWorkerExternally?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@braze/web-sdk",
3
- "version": "6.11.0",
3
+ "version": "6.12.0",
4
4
  "description": "Braze SDK for web sites and other JS platforms.",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -3,8 +3,8 @@ const p = {
3
3
  Pr: "p",
4
4
  $c: "pc",
5
5
  Fc: "ca",
6
- kl: "i",
7
- fl: "ie",
6
+ vl: "i",
7
+ _a: "ie",
8
8
  vs: "cci",
9
9
  ws: "ccic",
10
10
  us: "ccc",
@@ -31,5 +31,5 @@ const p = {
31
31
  Nt: "bc",
32
32
  Rt: "bd",
33
33
  },
34
- We = { Gc: "content_cards_displayed" };
35
- export { p as EventTypes, We as InternalEventTypes };
34
+ Ee = { Gc: "content_cards_displayed" };
35
+ export { p as EventTypes, Ee as InternalEventTypes };
@@ -1,21 +1,21 @@
1
1
  export default class et {
2
2
  constructor(t, e) {
3
3
  (this.database = t),
4
- (this.kd = e),
4
+ (this.Bd = e),
5
5
  (this.parent = "undefined" == typeof window ? self : window),
6
6
  (this.database = t),
7
- (this.kd = e);
7
+ (this.Bd = e);
8
8
  }
9
- Kd() {
9
+ Ud() {
10
10
  if ("indexedDB" in this.parent) return this.parent.indexedDB;
11
11
  }
12
12
  isSupported() {
13
13
  var t;
14
14
  try {
15
- if (null == this.Kd()) return !1;
15
+ if (null == this.Ud()) return !1;
16
16
  {
17
17
  const e =
18
- null === (t = this.Kd()) || void 0 === t
18
+ null === (t = this.Ud()) || void 0 === t
19
19
  ? void 0
20
20
  : t.open("Braze IndexedDB Support Test");
21
21
  if (
@@ -25,10 +25,10 @@ export default class et {
25
25
  "undefined" != typeof window)
26
26
  ) {
27
27
  const t = window,
28
- e = t.chrome || t.browser || t.Gd;
28
+ e = t.chrome || t.browser || t.Od;
29
29
  if (e && e.runtime && e.runtime.id)
30
30
  return (
31
- this.kd.info(
31
+ this.Bd.info(
32
32
  "Not using IndexedDB for storage because we are running inside an extension",
33
33
  ),
34
34
  !1
@@ -38,27 +38,27 @@ export default class et {
38
38
  }
39
39
  } catch (t) {
40
40
  return (
41
- this.kd.info(
41
+ this.Bd.info(
42
42
  "Not using IndexedDB for storage due to following error: " + t,
43
43
  ),
44
44
  !1
45
45
  );
46
46
  }
47
47
  }
48
- Wd(t, e) {
48
+ kd(t, e) {
49
49
  var n;
50
50
  const o =
51
- null === (n = this.Kd()) || void 0 === n
51
+ null === (n = this.Ud()) || void 0 === n
52
52
  ? void 0
53
- : n.open(this.database.Jd, this.database.VERSION);
53
+ : n.open(this.database.Kd, this.database.VERSION);
54
54
  if (null == o) return "function" == typeof e && e(), !1;
55
55
  const i = this;
56
56
  return (
57
57
  (o.onupgradeneeded = (t) => {
58
58
  var e;
59
- i.kd.info(
59
+ i.Bd.info(
60
60
  "Upgrading indexedDB " +
61
- i.database.Jd +
61
+ i.database.Kd +
62
62
  " to v" +
63
63
  i.database.VERSION +
64
64
  "...",
@@ -77,7 +77,7 @@ export default class et {
77
77
  (r.onversionchange = () => {
78
78
  r.close(),
79
79
  "function" == typeof e && e(),
80
- i.kd.error(
80
+ i.Bd.error(
81
81
  "Needed to close the database unexpectedly because of an upgrade in another tab",
82
82
  );
83
83
  }),
@@ -87,9 +87,9 @@ export default class et {
87
87
  var n;
88
88
  const o = t;
89
89
  return (
90
- i.kd.info(
90
+ i.Bd.info(
91
91
  "Could not open indexedDB " +
92
- i.database.Jd +
92
+ i.database.Kd +
93
93
  " v" +
94
94
  i.database.VERSION +
95
95
  ": " +
@@ -105,16 +105,16 @@ export default class et {
105
105
  setItem(t, e, n, o, i) {
106
106
  if (!this.isSupported()) return "function" == typeof i && i(), !1;
107
107
  const r = this;
108
- return this.Wd((d) => {
108
+ return this.kd((d) => {
109
109
  if (!d.objectStoreNames.contains(t))
110
110
  return (
111
- r.kd.error(
111
+ r.Bd.error(
112
112
  "Could not store object " +
113
113
  e +
114
114
  " in " +
115
115
  t +
116
116
  " on indexedDB " +
117
- r.database.Jd +
117
+ r.database.Kd +
118
118
  " - " +
119
119
  t +
120
120
  " is not a valid objectStore",
@@ -126,13 +126,13 @@ export default class et {
126
126
  s.oncomplete = () => d.close();
127
127
  const u = s.objectStore(t).put(n, e);
128
128
  (u.onerror = () => {
129
- r.kd.error(
129
+ r.Bd.error(
130
130
  "Could not store object " +
131
131
  e +
132
132
  " in " +
133
133
  t +
134
134
  " on indexedDB " +
135
- r.database.Jd,
135
+ r.database.Kd,
136
136
  ),
137
137
  "function" == typeof i && i();
138
138
  }),
@@ -144,16 +144,16 @@ export default class et {
144
144
  getItem(t, e, n) {
145
145
  if (!this.isSupported()) return !1;
146
146
  const o = this;
147
- return this.Wd((i) => {
147
+ return this.kd((i) => {
148
148
  if (!i.objectStoreNames.contains(t))
149
149
  return (
150
- o.kd.error(
150
+ o.Bd.error(
151
151
  "Could not retrieve object " +
152
152
  e +
153
153
  " in " +
154
154
  t +
155
155
  " on indexedDB " +
156
- o.database.Jd +
156
+ o.database.Kd +
157
157
  " - " +
158
158
  t +
159
159
  " is not a valid objectStore",
@@ -164,13 +164,13 @@ export default class et {
164
164
  r.oncomplete = () => i.close();
165
165
  const d = r.objectStore(t).get(e);
166
166
  (d.onerror = () => {
167
- o.kd.error(
167
+ o.Bd.error(
168
168
  "Could not retrieve object " +
169
169
  e +
170
170
  " in " +
171
171
  t +
172
172
  " on indexedDB " +
173
- o.database.Jd,
173
+ o.database.Kd,
174
174
  );
175
175
  }),
176
176
  (d.onsuccess = (t) => {
@@ -183,14 +183,14 @@ export default class et {
183
183
  kr(t, e, n) {
184
184
  if (!this.isSupported()) return "function" == typeof n && n(), !1;
185
185
  const o = this;
186
- return this.Wd((i) => {
186
+ return this.kd((i) => {
187
187
  if (!i.objectStoreNames.contains(t))
188
188
  return (
189
- o.kd.error(
189
+ o.Bd.error(
190
190
  "Could not retrieve last record from " +
191
191
  t +
192
192
  " on indexedDB " +
193
- o.database.Jd +
193
+ o.database.Kd +
194
194
  " - " +
195
195
  t +
196
196
  " is not a valid objectStore",
@@ -202,8 +202,8 @@ export default class et {
202
202
  r.oncomplete = () => i.close();
203
203
  const d = r.objectStore(t).openCursor(null, "prev");
204
204
  (d.onerror = () => {
205
- o.kd.error(
206
- "Could not open cursor for " + t + " on indexedDB " + o.database.Jd,
205
+ o.Bd.error(
206
+ "Could not open cursor for " + t + " on indexedDB " + o.database.Kd,
207
207
  ),
208
208
  "function" == typeof n && n();
209
209
  }),
@@ -219,16 +219,16 @@ export default class et {
219
219
  ge(t, e) {
220
220
  if (!this.isSupported()) return !1;
221
221
  const n = this;
222
- return this.Wd((o) => {
222
+ return this.kd((o) => {
223
223
  if (!o.objectStoreNames.contains(t))
224
224
  return (
225
- n.kd.error(
225
+ n.Bd.error(
226
226
  "Could not delete record " +
227
227
  e +
228
228
  " from " +
229
229
  t +
230
230
  " on indexedDB " +
231
- n.database.Jd +
231
+ n.database.Kd +
232
232
  " - " +
233
233
  t +
234
234
  " is not a valid objectStore",
@@ -238,13 +238,13 @@ export default class et {
238
238
  const i = o.transaction([t], "readwrite");
239
239
  i.oncomplete = () => o.close();
240
240
  i.objectStore(t).delete(e).onerror = () => {
241
- n.kd.error(
241
+ n.Bd.error(
242
242
  "Could not delete record " +
243
243
  e +
244
244
  " from " +
245
245
  t +
246
246
  " on indexedDB " +
247
- n.database.Jd,
247
+ n.database.Kd,
248
248
  );
249
249
  };
250
250
  });
@@ -252,14 +252,14 @@ export default class et {
252
252
  Qs(t, e) {
253
253
  if (!this.isSupported()) return !1;
254
254
  const n = this;
255
- return this.Wd((o) => {
255
+ return this.kd((o) => {
256
256
  if (!o.objectStoreNames.contains(t))
257
257
  return (
258
- n.kd.error(
258
+ n.Bd.error(
259
259
  "Could not retrieve objects from " +
260
260
  t +
261
261
  " on indexedDB " +
262
- n.database.Jd +
262
+ n.database.Kd +
263
263
  " - " +
264
264
  t +
265
265
  " is not a valid objectStore",
@@ -273,18 +273,18 @@ export default class et {
273
273
  s = [];
274
274
  (d.onerror = () => {
275
275
  s.length > 0
276
- ? (n.kd.info(
276
+ ? (n.Bd.info(
277
277
  "Cursor closed midway through for " +
278
278
  t +
279
279
  " on indexedDB " +
280
- n.database.Jd,
280
+ n.database.Kd,
281
281
  ),
282
282
  e(s))
283
- : n.kd.error(
283
+ : n.Bd.error(
284
284
  "Could not open cursor for " +
285
285
  t +
286
286
  " on indexedDB " +
287
- n.database.Jd,
287
+ n.database.Kd,
288
288
  );
289
289
  }),
290
290
  (d.onsuccess = (t) => {
@@ -311,23 +311,23 @@ export default class et {
311
311
  t.push(this.database.Ws[n]);
312
312
  }
313
313
  const e = this;
314
- return this.Wd(function (n) {
314
+ return this.kd(function (n) {
315
315
  const o = n.transaction(t, "readwrite");
316
316
  o.oncomplete = () => n.close();
317
317
  for (let n = 0; n < t.length; n++) {
318
318
  const i = t[n];
319
319
  o.objectStore(i).clear().onerror = function () {
320
- e.kd.error(
320
+ e.Bd.error(
321
321
  "Could not clear " +
322
322
  this.source.name +
323
323
  " on indexedDB " +
324
- e.database.Jd,
324
+ e.database.Kd,
325
325
  );
326
326
  };
327
327
  }
328
328
  o.onerror = function () {
329
- e.kd.error(
330
- "Could not clear object stores on indexedDB " + e.database.Jd,
329
+ e.Bd.error(
330
+ "Could not clear object stores on indexedDB " + e.database.Kd,
331
331
  );
332
332
  };
333
333
  });
@@ -335,13 +335,13 @@ export default class et {
335
335
  }
336
336
  et._s = {
337
337
  Xs: {
338
- Jd: "AppboyServiceWorkerAsyncStorage",
338
+ Kd: "AppboyServiceWorkerAsyncStorage",
339
339
  VERSION: 6,
340
340
  Ws: {
341
- pn: "data",
341
+ Cn: "data",
342
342
  yr: "pushClicks",
343
343
  Gu: "pushSubscribed",
344
- qd: "fallbackDevice",
344
+ Gd: "fallbackDevice",
345
345
  Vs: "cardUpdates",
346
346
  pe: "optOut",
347
347
  Br: "pendingData",
@@ -3,11 +3,11 @@ const b = {
3
3
  (void 0 === n && void 0 !== b.zg) || (b.zg = !!n), b.i || (b.i = !0);
4
4
  },
5
5
  destroy: function () {
6
- (b.i = !1), (b.zg = void 0), (b.kd = void 0);
6
+ (b.i = !1), (b.zg = void 0), (b.Bd = void 0);
7
7
  },
8
8
  setLogger: function (n) {
9
9
  "function" == typeof n
10
- ? (b.init(), (b.kd = n))
10
+ ? (b.init(), (b.Bd = n))
11
11
  : b.info("Ignoring setLogger call since logger is not a function");
12
12
  },
13
13
  toggleLogging: function () {
@@ -19,19 +19,19 @@ const b = {
19
19
  info: function (n) {
20
20
  if (b.zg) {
21
21
  const o = "Braze: " + n;
22
- null != b.kd ? b.kd(o) : console.log(o);
22
+ null != b.Bd ? b.Bd(o) : console.log(o);
23
23
  }
24
24
  },
25
25
  warn: function (n) {
26
26
  if (b.zg) {
27
- const o = "Braze SDK Warning: " + n + " (v6.11.0)";
28
- null != b.kd ? b.kd(o) : console.warn(o);
27
+ const o = "Braze SDK Warning: " + n + " (v6.12.0)";
28
+ null != b.Bd ? b.Bd(o) : console.warn(o);
29
29
  }
30
30
  },
31
31
  error: function (n) {
32
32
  if (b.zg) {
33
- const o = "Braze SDK Error: " + n + " (v6.11.0)";
34
- null != b.kd ? b.kd(o) : console.error(o);
33
+ const o = "Braze SDK Error: " + n + " (v6.12.0)";
34
+ null != b.Bd ? b.Bd(o) : console.error(o);
35
35
  }
36
36
  },
37
37
  };
@@ -4,26 +4,26 @@ export default {
4
4
  se: "cookieExpiryInDays",
5
5
  Oh: "noCookies",
6
6
  Th: "devicePropertyAllowlist",
7
- Aa: "disablePushTokenMaintenance",
7
+ xa: "disablePushTokenMaintenance",
8
8
  Rh: "enableLogging",
9
9
  Ph: "enableSdkAuthentication",
10
- qa: "manageServiceWorkerExternally",
10
+ wa: "manageServiceWorkerExternally",
11
11
  Dh: "minimumIntervalBetweenTriggerActionsInSeconds",
12
12
  Lh: "sessionTimeoutInSeconds",
13
13
  yh: "appVersion",
14
14
  Mh: "appVersionNumber",
15
- Ma: "serviceWorkerLocation",
16
- ka: "safariWebsitePushId",
17
- Ba: "localization",
15
+ za: "serviceWorkerLocation",
16
+ ha: "safariWebsitePushId",
17
+ Ma: "localization",
18
18
  sr: "contentSecurityNonce",
19
19
  nr: "allowUserSuppliedJavascript",
20
- va: "inAppMessageZIndex",
21
- ya: "openInAppMessagesInNewTab",
20
+ ca: "inAppMessageZIndex",
21
+ da: "openInAppMessagesInNewTab",
22
22
  lh: "requireExplicitInAppMessageDismissal",
23
23
  Uh: "doNotLoadFontAwesome",
24
24
  Wh: "deviceId",
25
- _a: "serviceWorkerScope",
26
- Ye: "dustHost",
25
+ ba: "serviceWorkerScope",
26
+ Oi: "dustHost",
27
27
  Bh: "sdkFlavor",
28
28
  tn: "openCardsInNewTab",
29
29
  };
@@ -0,0 +1,89 @@
1
+ import { STORAGE_KEYS as s } from "../managers/storage-manager.js";
2
+ import { Guid as V, logger as b } from "../../shared-lib/index.js";
3
+ export const REFRESH_LOCK_TTL_MS = 2e3;
4
+ export const CONFIG_POLL_INTERVAL_MS = 100;
5
+ const ht = [s.It._i, s.It.Oi, s.It.Gi, s.It.Hi];
6
+ export function isConfigExpired(t) {
7
+ return !!t && Math.floor(new Date().valueOf() / 1e3) >= t;
8
+ }
9
+ export function isConfigUsable(t) {
10
+ return Boolean(t.Ki && t.host) && !isConfigExpired(t.expiration);
11
+ }
12
+ export default class lt {
13
+ constructor(t) {
14
+ (this.j = t), (this.j = t), (this.Vi = null), (this.Wi = null);
15
+ }
16
+ read() {
17
+ return this.j
18
+ ? {
19
+ Ki: this.j.St(s.It._i),
20
+ host: this.j.St(s.It.Oi),
21
+ Qi: this.j.St(s.It.Gi),
22
+ expiration: this.j.St(s.It.Hi),
23
+ }
24
+ : { Ki: null, host: null, Qi: null, expiration: null };
25
+ }
26
+ write(t) {
27
+ const i = this.j;
28
+ i &&
29
+ (i.Pt(s.It._i, t.Ki),
30
+ i.Pt(s.It.Oi, t.host),
31
+ t.Qi ? i.Pt(s.It.Gi, t.Qi) : i.Vt(s.It.Gi),
32
+ t.expiration ? i.Pt(s.It.Hi, t.expiration) : i.Vt(s.It.Hi));
33
+ }
34
+ clear() {
35
+ const t = this.j;
36
+ t && (t.Vt(s.It._i), t.Vt(s.It.Oi), t.Vt(s.It.Gi), t.Vt(s.It.Hi));
37
+ }
38
+ Yi() {
39
+ const t = this.j;
40
+ if (!t) return V.de();
41
+ const i = t.St(s.It.Zi),
42
+ e = new Date().valueOf();
43
+ if (i && "number" == typeof i.e && i.e > e) return null;
44
+ const n = V.de();
45
+ t.Pt(s.It.Zi, { t: n, e: e + 2e3 });
46
+ const r = t.St(s.It.Zi);
47
+ return r && r.t === n ? n : null;
48
+ }
49
+ we(t) {
50
+ const i = this.j;
51
+ if (!i) return;
52
+ const e = i.St(s.It.Zi);
53
+ (e && e.t !== t) || i.Vt(s.It.Zi);
54
+ }
55
+ xe(t, i) {
56
+ if (this.Vi || null !== this.Wi) return !1;
57
+ const e = this.read();
58
+ if (isConfigUsable(e)) return t(e), !0;
59
+ const s = new Date().valueOf() + 2e3,
60
+ n = () => {
61
+ const e = this.read();
62
+ if (isConfigUsable(e)) return this.Le(), void t(e);
63
+ new Date().valueOf() >= s &&
64
+ (this.Le(),
65
+ b.info(
66
+ "Timed out waiting for another tab to refresh real-time messaging configuration",
67
+ ),
68
+ i());
69
+ };
70
+ return (
71
+ (this.Vi = (t) => {
72
+ if (t.key)
73
+ for (let i = 0; i < ht.length; i++)
74
+ if (0 === t.key.indexOf(ht[i])) return void n();
75
+ }),
76
+ window.addEventListener("storage", this.Vi),
77
+ (this.Wi = window.setInterval(n, 100)),
78
+ !0
79
+ );
80
+ }
81
+ Le() {
82
+ this.Vi &&
83
+ (window.removeEventListener("storage", this.Vi), (this.Vi = null)),
84
+ null !== this.Wi && (window.clearInterval(this.Wi), (this.Wi = null));
85
+ }
86
+ destroy() {
87
+ this.Le();
88
+ }
89
+ }
@@ -1,24 +1,10 @@
1
- export const MIN_BACKOFF_MS = 1e4;
2
- export const MAX_BACKOFF_MS = 3e5;
3
- export const BACKOFF_SCALE_FACTOR = 3;
4
- export const MAX_RETRIES = 5;
5
- export const CONNECTION_VALID_THRESHOLD_MS = 3e3;
6
- export function randomInRange(t, e) {
7
- return Math.floor(Math.random() * (e - t + 1)) + t;
8
- }
9
- export function calculateBackoff(t) {
10
- let e = t;
11
- return (
12
- (null === e || e < 1e4) && (e = 1e4),
13
- Math.min(3e5, randomInRange(1e4, 3 * e))
14
- );
15
- }
16
- export function buildSseUrl(t, e, n, o, r) {
17
- const c = /^https?:\/\//i.test(t) ? t : `https://${t}`;
18
- let p = `mite=${encodeURIComponent(e)}&attempts=${n}`;
1
+ export const MAX_RETRIES = 15;
2
+ export function buildSseUrl(t, e, n, o, s) {
3
+ const p = /^https?:\/\//i.test(t) ? t : `https://${t}`;
4
+ let c = `mite=${encodeURIComponent(e)}&attempts=${n}`;
19
5
  return (
20
- o && (p += `&auth=${encodeURIComponent(o)}`),
21
- r && (p += `&rcs=${encodeURIComponent(r)}`),
22
- `${c}/sse?${p}`
6
+ o && (c += `&auth=${encodeURIComponent(o)}`),
7
+ s && (c += `&rcs=${encodeURIComponent(s)}`),
8
+ `${p}/sse?${c}`
23
9
  );
24
10
  }
@@ -0,0 +1,33 @@
1
+ import { STORAGE_KEYS as s } from "../managers/storage-manager.js";
2
+ export const MESSAGE_CLAIM_WINDOW_MS = 500;
3
+ const ct = ["ccr", "ffr", "tgr"];
4
+ export default class at {
5
+ constructor(t) {
6
+ (this.j = t), (this.j = t);
7
+ }
8
+ Mr(t) {
9
+ const r = this.j;
10
+ if (
11
+ !r ||
12
+ !(function (t) {
13
+ for (const r of ct) if (r === t) return !0;
14
+ return !1;
15
+ })(t)
16
+ )
17
+ return !0;
18
+ const n = new Date().valueOf(),
19
+ e = r.St(s.It._r);
20
+ if (e && this.Ir(e[t], n)) return !1;
21
+ const o = {};
22
+ if (e) for (const t in e) this.Ir(e[t], n) && (o[t] = e[t]);
23
+ (o[t] = n), r.Pt(s.It._r, o);
24
+ const i = r.St(s.It._r);
25
+ return !i || i[t] === n;
26
+ }
27
+ Wr() {
28
+ this.j && this.j.Vt(s.It._r);
29
+ }
30
+ Ir(t, r) {
31
+ return "number" == typeof t && Math.abs(r - t) < 500;
32
+ }
33
+ }