@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
@@ -1,5 +1,5 @@
1
1
  import { logger as b } from "../../shared-lib/index.js";
2
- import { getErrorMessage as ai } from "./error-utils.js";
2
+ import { getErrorMessage as ci } from "./error-utils.js";
3
3
  export function _isInView(t, n = !1, e = !1, s = !1) {
4
4
  if (null == t) return !1;
5
5
  (n = n || !1), (e = e || !1);
@@ -19,7 +19,7 @@ export function _isInView(t, n = !1, e = !1, s = !1) {
19
19
  );
20
20
  }
21
21
  export const DOMUtils = { Ic: null, td: _isInView };
22
- export const DIRECTIONS = { Uo: "up", Vo: "down", ie: "left", ne: "right" };
22
+ export const DIRECTIONS = { Jo: "up", Ko: "down", ie: "left", ne: "right" };
23
23
  export function supportsPassive() {
24
24
  if (null == DOMUtils.Ic) {
25
25
  DOMUtils.Ic = !1;
@@ -32,7 +32,7 @@ export function supportsPassive() {
32
32
  window.addEventListener("testPassive", () => {}, t),
33
33
  window.removeEventListener("testPassive", () => {}, t);
34
34
  } catch (t) {
35
- b.error(ai(t));
35
+ b.error(ci(t));
36
36
  }
37
37
  }
38
38
  return DOMUtils.Ic;
@@ -69,9 +69,9 @@ export function detectSwipe(t, n, e) {
69
69
  (i = null))
70
70
  : Math.abs(u) >= 25 &&
71
71
  (((u > 0 &&
72
- n === DIRECTIONS.Uo &&
72
+ n === DIRECTIONS.Jo &&
73
73
  t.scrollTop === t.scrollHeight - t.offsetHeight) ||
74
- (u < 0 && n === DIRECTIONS.Vo && 0 === t.scrollTop)) &&
74
+ (u < 0 && n === DIRECTIONS.Ko && 0 === t.scrollTop)) &&
75
75
  e(o),
76
76
  (s = null),
77
77
  (i = null));
@@ -55,7 +55,7 @@ function _n(n, t) {
55
55
  ),
56
56
  !1);
57
57
  }
58
- function $n(n, t, e) {
58
+ function yn(n, t, e) {
59
59
  if (e > 50)
60
60
  return b.error(`Cannot ${ln} because ${t} is nested too deeply.`), !1;
61
61
  if (null == n || "object" != typeof n) return !0;
@@ -71,7 +71,7 @@ function $n(n, t, e) {
71
71
  ),
72
72
  !1
73
73
  );
74
- } else if (!$n(u, t, e + 1)) return !1;
74
+ } else if (!yn(u, t, e + 1)) return !1;
75
75
  }
76
76
  return !0;
77
77
  }
@@ -89,11 +89,11 @@ function $n(n, t, e) {
89
89
  ),
90
90
  !1
91
91
  );
92
- } else if (null != u && "object" == typeof u && !$n(u, t, e + 1)) return !1;
92
+ } else if (null != u && "object" == typeof u && !yn(u, t, e + 1)) return !1;
93
93
  }
94
94
  return !0;
95
95
  }
96
- function vn(n, t) {
96
+ function $n(n, t) {
97
97
  if (!g(n))
98
98
  return (
99
99
  b.error(`Cannot ${ln} because ${t} must be an array of strings.`), !1
@@ -101,10 +101,10 @@ function vn(n, t) {
101
101
  for (const e of n) if (!1 === dn(e, t, !0)) return !1;
102
102
  return !0;
103
103
  }
104
- function yn(n, t) {
105
- if (void 0 === n) return;
106
- const [e, r] = nt(null != n ? n : {}, R.QE, "metadata", ln, t);
107
- return !!e && !(null != r && !$n(r, t, 0)) && r;
104
+ function vn(n, t) {
105
+ if (null == n) return;
106
+ const [e, r] = nt(n, R.QE, "metadata", ln, t);
107
+ return !!e && !(null != r && !yn(r, t, 0)) && r;
108
108
  }
109
109
  function gn(n) {
110
110
  if (null == n || "object" != typeof n || g(n))
@@ -130,10 +130,10 @@ function gn(n) {
130
130
  })(t.quantity),
131
131
  c = pn(t.price, "product price");
132
132
  if (!1 === e || !1 === r || !1 === u || !1 === o || !1 === c) return null;
133
- const i = dn(t.image_url, "image_url", !1),
134
- a = dn(t.product_url, "product_url", !1);
135
- if (!1 === i || !1 === a) return null;
136
- const s = yn(t.metadata, "eCommerce product metadata");
133
+ const a = dn(t.image_url, "image_url", !1),
134
+ i = dn(t.product_url, "product_url", !1);
135
+ if (!1 === a || !1 === i) return null;
136
+ const s = vn(t.metadata, "eCommerce product metadata");
137
137
  if (!1 === s) return null;
138
138
  const l = {
139
139
  product_id: e,
@@ -143,8 +143,8 @@ function gn(n) {
143
143
  price: c,
144
144
  };
145
145
  return (
146
- null != i && (l.image_url = i),
147
- null != a && (l.product_url = a),
146
+ null != a && (l.image_url = a),
147
+ null != i && (l.product_url = i),
148
148
  null != s && (l.metadata = s),
149
149
  l
150
150
  );
@@ -161,7 +161,7 @@ function Cn(n) {
161
161
  }
162
162
  return t;
163
163
  }
164
- function hn(n) {
164
+ function jn(n) {
165
165
  const t = (function (n) {
166
166
  if (null == n || "string" != typeof n || n.length <= 0)
167
167
  return (
@@ -179,7 +179,7 @@ function hn(n) {
179
179
  e = dn(n.source, "source", !0);
180
180
  return !1 === t || !1 === e ? null : { currency: t, source: e };
181
181
  }
182
- function jn(n, t) {
182
+ function hn(n, t) {
183
183
  const e = ["subtotal_value", "tax", "shipping"];
184
184
  for (const r of e)
185
185
  if (null != t[r]) {
@@ -189,14 +189,43 @@ function jn(n, t) {
189
189
  }
190
190
  return !0;
191
191
  }
192
- function wn(n, t) {
193
- const e = yn(t, "eCommerce event metadata");
192
+ function kn(n, t) {
193
+ const e = vn(t, "eCommerce event metadata");
194
194
  return !1 !== e && (null != e && (n.metadata = e), !0);
195
195
  }
196
- function kn(n, t) {
196
+ function wn(n, t) {
197
+ return null == n || !1 !== dn(n, t, !1);
198
+ }
199
+ function qn(n) {
200
+ if (null == n || "object" != typeof n || g(n)) return !0;
201
+ const t = n;
202
+ if (!wn(t.country, "metadata.country")) return !1;
203
+ if (!wn(t.market_handle, "metadata.market_handle")) return !1;
204
+ if (null == t.presentment_currency) return !0;
205
+ if ("object" != typeof t.presentment_currency || g(t.presentment_currency))
206
+ return (
207
+ b.error(
208
+ `Cannot ${ln} because metadata.presentment_currency must be an object.`,
209
+ ),
210
+ !1
211
+ );
212
+ const e = t.presentment_currency;
213
+ if (!wn(e.price, "metadata.presentment_currency.price")) return !1;
214
+ if (null == e.code) return !0;
215
+ const r = dn(e.code, "metadata.presentment_currency.code", !1);
216
+ if ("string" != typeof r) return !1;
217
+ const u = r.toUpperCase();
218
+ return or(u)
219
+ ? ((e.code = u), !0)
220
+ : (b.error(
221
+ `${R.QE} requires a valid ISO 4217 currency code, got "${r}". Ignoring event.`,
222
+ ),
223
+ !1);
224
+ }
225
+ function En(n, t) {
197
226
  const e = dn(n.cart_id, "cart_id", !0),
198
227
  r =
199
- void 0 === n.action
228
+ null == n.action
200
229
  ? un.REPLACE
201
230
  : ((u = n.action),
202
231
  !!ta(
@@ -208,11 +237,10 @@ function kn(n, t) {
208
237
  var u;
209
238
  const o = Cn(n.products);
210
239
  if (!1 === e || !1 === r || null == o) return null;
211
- const c = r === un.Od || r === un.Ud,
212
- i =
213
- void 0 === n.total_value && c ? void 0 : pn(n.total_value, "total_value");
214
- if (!1 === i) return null;
215
- const a = {
240
+ const c = r === un.Ld || r === un.Md,
241
+ a = null == n.total_value && c ? void 0 : pn(n.total_value, "total_value");
242
+ if (!1 === a) return null;
243
+ const i = {
216
244
  cart_id: e,
217
245
  action: r,
218
246
  currency: t.currency,
@@ -220,8 +248,8 @@ function kn(n, t) {
220
248
  source: t.source,
221
249
  };
222
250
  return (
223
- void 0 !== i && (a.total_value = i),
224
- jn(a, n) && wn(a, n.metadata) ? a : null
251
+ void 0 !== a && (i.total_value = a),
252
+ hn(i, n) && kn(i, n.metadata) ? i : null
225
253
  );
226
254
  }
227
255
  export function sanitizeEcommerceEvent(n) {
@@ -229,26 +257,26 @@ export function sanitizeEcommerceEvent(n) {
229
257
  if (null == t || "object" != typeof t || g(t))
230
258
  return b.error(`${R.QE} requires a properties object.`), null;
231
259
  const e = t,
232
- r = hn(e);
260
+ r = jn(e);
233
261
  if (null == r) return null;
234
262
  switch (n.name) {
235
263
  case "ecommerce.product_viewed":
236
264
  return (function (n, t) {
237
265
  const e = n.metadata;
238
- if (void 0 !== n.type && !vn(n.type, "type")) return null;
266
+ if (null != n.type && !$n(n.type, "type")) return null;
239
267
  const r = dn(n.product_id, "product_id", !0),
240
268
  u = dn(n.product_name, "product_name", !0),
241
269
  o = dn(n.variant_id, "variant_id", !0),
242
270
  c = pn(n.price, "price"),
243
- i = dn(n.image_url, "image_url", !1),
244
- a = dn(n.product_url, "product_url", !1);
271
+ a = dn(n.image_url, "image_url", !1),
272
+ i = dn(n.product_url, "product_url", !1);
245
273
  if (
246
274
  !1 === r ||
247
275
  !1 === u ||
248
276
  !1 === o ||
249
277
  !1 === c ||
250
- !1 === i ||
251
- !1 === a
278
+ !1 === a ||
279
+ !1 === i
252
280
  )
253
281
  return null;
254
282
  const s = {
@@ -260,14 +288,14 @@ export function sanitizeEcommerceEvent(n) {
260
288
  source: t.source,
261
289
  };
262
290
  return (
263
- null != i && (s.image_url = i),
264
- null != a && (s.product_url = a),
265
- void 0 !== n.type && (s.type = n.type),
266
- wn(s, e) ? s : null
291
+ null != a && (s.image_url = a),
292
+ null != i && (s.product_url = i),
293
+ null != n.type && (s.type = n.type),
294
+ kn(s, e) ? s : null
267
295
  );
268
296
  })(e, r);
269
297
  case "ecommerce.cart_updated":
270
- return kn(e, r);
298
+ return En(e, r);
271
299
  case "ecommerce.checkout_started":
272
300
  return (function (n, t) {
273
301
  const e = dn(n.checkout_id, "checkout_id", !0),
@@ -283,7 +311,8 @@ export function sanitizeEcommerceEvent(n) {
283
311
  source: t.source,
284
312
  };
285
313
  return (
286
- null != o && (c.cart_id = o), jn(c, n) && wn(c, n.metadata) ? c : null
314
+ null != o && (c.cart_id = o),
315
+ hn(c, n) && qn(n.metadata) && kn(c, n.metadata) ? c : null
287
316
  );
288
317
  })(e, r);
289
318
  case "ecommerce.order_placed":
@@ -291,10 +320,10 @@ export function sanitizeEcommerceEvent(n) {
291
320
  const e = n.metadata;
292
321
  if (null != e && "object" == typeof e && !g(e)) {
293
322
  const n = e;
294
- if (void 0 !== n.tags && !vn(n.tags, "metadata.tags")) return null;
323
+ if (null != n.tags && !$n(n.tags, "metadata.tags")) return null;
295
324
  if (
296
- void 0 !== n.payment_gateway_names &&
297
- !vn(n.payment_gateway_names, "metadata.payment_gateway_names")
325
+ null != n.payment_gateway_names &&
326
+ !$n(n.payment_gateway_names, "metadata.payment_gateway_names")
298
327
  )
299
328
  return null;
300
329
  }
@@ -303,19 +332,19 @@ export function sanitizeEcommerceEvent(n) {
303
332
  o = Cn(n.products),
304
333
  c = dn(n.cart_id, "cart_id", !1);
305
334
  if (!1 === r || !1 === u || null == o || !1 === c) return null;
306
- const i = {
335
+ const a = {
307
336
  order_id: r,
308
337
  total_value: u,
309
338
  currency: t.currency,
310
339
  products: o,
311
340
  source: t.source,
312
341
  };
313
- if ((null != c && (i.cart_id = c), null != n.total_discounts)) {
342
+ if ((null != c && (a.cart_id = c), null != n.total_discounts)) {
314
343
  const t = pn(n.total_discounts, "total_discounts");
315
344
  if (!1 === t) return null;
316
- i.total_discounts = t;
345
+ a.total_discounts = t;
317
346
  }
318
- if (void 0 !== n.discounts) {
347
+ if (null != n.discounts) {
319
348
  if (!g(n.discounts))
320
349
  return (
321
350
  b.error(`Cannot ${ln} because discounts must be an array.`), null
@@ -328,9 +357,9 @@ export function sanitizeEcommerceEvent(n) {
328
357
  "eCommerce order discounts",
329
358
  );
330
359
  if (!t || null == e) return null;
331
- i.discounts = e.discounts;
360
+ a.discounts = e.discounts;
332
361
  }
333
- return jn(i, n) && wn(i, n.metadata) ? i : null;
362
+ return hn(a, n) && qn(n.metadata) && kn(a, n.metadata) ? a : null;
334
363
  })(e, r);
335
364
  default:
336
365
  return (
@@ -1 +1 @@
1
- export const KeyCodes = { Ao: 32, Wo: 9, Lo: 13, oh: 27 };
1
+ export const KeyCodes = { To: 32, No: 9, Lo: 13, oh: 27 };
package/src/util/net.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { logger as b } from "../../shared-lib/index.js";
2
- import Ne from "../models/backend-errors.js";
3
- import { getErrorMessage as ai } from "./error-utils.js";
2
+ import Re from "../models/backend-errors.js";
3
+ import { getErrorMessage as ci } from "./error-utils.js";
4
4
  const l = {
5
5
  ot: (t) => {
6
6
  let e, o;
@@ -27,7 +27,7 @@ const l = {
27
27
  o = JSON.parse(e.responseText);
28
28
  } catch (o) {
29
29
  const n = {
30
- error: "" === e.responseText ? Ne.dl : Ne.ml,
30
+ error: "" === e.responseText ? Re.Ha : Re.Wa,
31
31
  response: e.responseText,
32
32
  };
33
33
  (0, t.lt)(n, r);
@@ -51,7 +51,7 @@ const l = {
51
51
  for (const t of i) e.setRequestHeader(t[0], t[1]);
52
52
  e.send(o);
53
53
  } catch (t) {
54
- b.error(`Network request error: ${ai(t)}`);
54
+ b.error(`Network request error: ${ci(t)}`);
55
55
  }
56
56
  },
57
57
  };
@@ -1,52 +1,52 @@
1
- import { REQUEST_ATTEMPT_DEFAULT as Qe } from "../common/constants.js";
1
+ import { REQUEST_ATTEMPT_DEFAULT as Ne } from "../common/constants.js";
2
2
  import { STORAGE_KEYS as s } from "../managers/storage-manager.js";
3
3
  const h = {
4
4
  it: {
5
- pn: "data",
5
+ Cn: "data",
6
6
  Mi: "content_cards/sync",
7
- Co: "feature_flags/sync",
8
- ta: "template",
7
+ vo: "feature_flags/sync",
8
+ Xo: "template",
9
9
  st: "banners/sync",
10
- Ra: "push/unregister",
10
+ ka: "push/unregister",
11
11
  },
12
- Gl: (e) => (null == e ? void 0 : e.St(s.It.sS)),
13
- Rm: (e) => (null == e ? void 0 : e.St(s.It.rS)),
12
+ Il: (e) => (null == e ? void 0 : e.St(s.It.lS)),
13
+ Rm: (e) => (null == e ? void 0 : e.St(s.It._S)),
14
14
  Am: (e, t) => {
15
- null == e || e.Pt(s.It.sS, t);
15
+ null == e || e.Pt(s.It.lS, t);
16
16
  },
17
17
  qm: (e, t) => {
18
- null == e || e.Pt(s.It.rS, t);
18
+ null == e || e.Pt(s.It._S, t);
19
19
  },
20
- yl: (e, t) => {
20
+ gl: (e, t) => {
21
21
  if (!e || !t) return -1;
22
- const s = h.Gl(e);
22
+ const s = h.Il(e);
23
23
  if (null == s) return -1;
24
24
  const n = s[t];
25
25
  return null == n || isNaN(n) ? -1 : n;
26
26
  },
27
- wl: (e, t) => {
28
- let s = Qe;
27
+ bl: (e, t) => {
28
+ let s = Ne;
29
29
  if (!e || !t) return s;
30
30
  const n = h.Rm(e);
31
- return null == n ? s : ((s = n[t]), null == s || isNaN(s) ? Qe : s);
31
+ return null == n ? s : ((s = n[t]), null == s || isNaN(s) ? Ne : s);
32
32
  },
33
33
  nt: (e, t, s) => {
34
34
  if (!e || !t) return;
35
- let n = h.Gl(e);
35
+ let n = h.Il(e);
36
36
  null == n && (n = {}), (n[t] = s), h.Am(e, n);
37
37
  },
38
- Nl: (e, t, s) => {
38
+ ql: (e, t, s) => {
39
39
  if (!e || !t) return;
40
40
  let n = h.Rm(e);
41
41
  null == n && (n = {}), (n[t] = s), h.qm(e, n);
42
42
  },
43
43
  Ji: (e, t) => {
44
- e && t && h.Nl(e, t, Qe);
44
+ e && t && h.ql(e, t, Ne);
45
45
  },
46
- Ll: (e, t) => {
46
+ Sl: (e, t) => {
47
47
  if (!e || !t) return;
48
- const s = h.wl(e, t);
49
- h.Nl(e, t, s + 1);
48
+ const s = h.bl(e, t);
49
+ h.ql(e, t, s + 1);
50
50
  },
51
51
  };
52
52
  export default h;
@@ -1,4 +1,9 @@
1
1
  import { logger as b } from "../../shared-lib/index.js";
2
+ export function isAlphanumericChar(t) {
3
+ return (
4
+ (t >= "a" && t <= "z") || (t >= "A" && t <= "Z") || (t >= "0" && t <= "9")
5
+ );
6
+ }
2
7
  export function getByteLength(t) {
3
8
  let e = t.length;
4
9
  for (let n = t.length - 1; n >= 0; n--) {
@@ -1,19 +1,19 @@
1
- import Ve from "./base-device-parser.js";
2
- import { Browsers as yi, OperatingSystems as so } from "./device-constants.js";
3
- export default class vi extends Ve {
1
+ import Oe from "./base-device-parser.js";
2
+ import { Browsers as xi, OperatingSystems as so } from "./device-constants.js";
3
+ export default class yi extends Oe {
4
4
  constructor() {
5
- super(), (this.Vd = vi.Bc(navigator.userAgent || ""));
5
+ super(), (this.Sd = yi.Bc(navigator.userAgent || ""));
6
6
  }
7
7
  ef() {
8
- return this.Vd[0] || "Unknown Browser";
8
+ return this.Sd[0] || "Unknown Browser";
9
9
  }
10
10
  ff() {
11
- return this.Vd[1] || "Unknown Version";
11
+ return this.Sd[1] || "Unknown Version";
12
12
  }
13
- Ga(r) {
13
+ Fa(r) {
14
14
  for (let n = 0; n < r.length; n++) {
15
15
  const e = r[n].string;
16
- let i = vi.nf(e, r[n]);
16
+ let i = yi.nf(e, r[n]);
17
17
  if (i)
18
18
  return (
19
19
  i === so.Pg && navigator.maxTouchPoints > 1 && (i = so.co),
@@ -40,40 +40,40 @@ export default class vi extends Ve {
40
40
  if (-1 !== r.indexOf("PhilipsTV")) return ["Philips Smart TV", null];
41
41
  if (r.match(/\b(Roku)\b/)) return ["Roku", null];
42
42
  if (r.match(/\bAFTM\b/)) return ["Amazon Fire Stick", null];
43
- if (e[1] === yi.rO) {
44
- if (r.includes(yi.Sg)) return [yi.Sg, e[2]];
43
+ if (e[1] === xi.rO) {
44
+ if (r.includes(xi.Sg)) return [xi.Sg, e[2]];
45
45
  if (
46
46
  ((n = r.match(/\b(OPR|Edge|EdgA|Edg|UCBrowser)\/(\.?\d+(\.\d+)*)/)),
47
47
  null != n)
48
48
  )
49
49
  return (
50
50
  (n = n.slice(1)),
51
- (n[0] = n[0].replace("OPR", yi.oO)),
52
- (n[0] = n[0].replace("EdgA", yi.eO)),
53
- "Edg" === n[0] && (n[0] = yi.eO),
51
+ (n[0] = n[0].replace("OPR", xi.oO)),
52
+ (n[0] = n[0].replace("EdgA", xi.eO)),
53
+ "Edg" === n[0] && (n[0] = xi.eO),
54
54
  [n[0], n[1]]
55
55
  );
56
56
  }
57
57
  if (
58
- e[1] === yi.Bg &&
58
+ e[1] === xi.Bg &&
59
59
  ((n = r.match(/\b(EdgiOS)\/(\.?\d+(\.\d+)*)/)), null != n)
60
60
  )
61
61
  return (
62
- (n = n.slice(1)), (n[0] = n[0].replace("EdgiOS", yi.eO)), [n[0], n[1]]
62
+ (n = n.slice(1)), (n[0] = n[0].replace("EdgiOS", xi.eO)), [n[0], n[1]]
63
63
  );
64
64
  if (
65
65
  ((e = e[2] ? [e[1], e[2]] : [null, null]),
66
- e[0] === yi.Bg &&
66
+ e[0] === xi.Bg &&
67
67
  null != (n = r.match(/version\/(\.?\d+(\.\d+)*)/i)) &&
68
68
  e.splice(1, 1, n[1]),
69
69
  null != (n = r.match(/\b(UCBrowser)\/(\.?\d+(\.\d+)*)/)) &&
70
70
  e.splice(1, 1, n[2]),
71
- e[0] === yi.oO && null != (n = r.match(/mini\/(\.?\d+(\.\d+)*)/i)))
71
+ e[0] === xi.oO && null != (n = r.match(/mini\/(\.?\d+(\.\d+)*)/i)))
72
72
  )
73
73
  return ["Opera Mini", n[1] || ""];
74
74
  if (e[0]) {
75
75
  const r = e[0].toLowerCase();
76
- "crios" === r && (e[0] = yi.rO),
76
+ "crios" === r && (e[0] = xi.rO),
77
77
  "tizen" === r && ((e[0] = "Samsung Smart TV"), (e[1] = null)),
78
78
  "samsungbrowser" === r && (e[0] = "Samsung Browser");
79
79
  }
@@ -6,7 +6,7 @@ import {
6
6
  } from "./code-utils.js";
7
7
  import { getByteLength as er } from "./string-utils.js";
8
8
  import { logger as b } from "../../shared-lib/index.js";
9
- import { toValidBackendTimeString as $t } from "./date-utils.js";
9
+ import { toValidBackendTimeString as Rt } from "./date-utils.js";
10
10
  import { BRAZE_ACTIONS as oo } from "./braze-actions.js";
11
11
  import { CoreStrings as R } from "../common/constants.js";
12
12
  export const CUSTOM_DATA_REGEX = /^[^\x00-\x1F\x22]+$/;
@@ -61,7 +61,7 @@ export function _validateNestedProperties(t, e, r) {
61
61
  if (g(t) && g(e)) {
62
62
  for (let r = 0; r < t.length && r < e.length; r++)
63
63
  if (
64
- (Nt(t[r]) && (e[r] = $t(t[r])),
64
+ (Nt(t[r]) && (e[r] = Rt(t[r])),
65
65
  !_validateNestedProperties(t[r], e[r], o))
66
66
  )
67
67
  return !1;
@@ -71,7 +71,7 @@ export function _validateNestedProperties(t, e, r) {
71
71
  const i = t[r];
72
72
  if (n && !validateCustomAttributeKey(r)) return !1;
73
73
  if (Nt(i)) {
74
- e[r] = $t(i);
74
+ e[r] = Rt(i);
75
75
  }
76
76
  if (!_validateNestedProperties(i, e[r], o)) return !1;
77
77
  }
@@ -127,7 +127,7 @@ export function validateCustomProperties(t, e, r, n, o) {
127
127
  delete t[r], delete u[r];
128
128
  continue;
129
129
  }
130
- Nt(i) && (u[r] = $t(i));
130
+ Nt(i) && (u[r] = Rt(i));
131
131
  if (
132
132
  !_validateEventPropertyValue(
133
133
  i,
@@ -28,7 +28,7 @@ export function _getCurrentUrl() {
28
28
  }
29
29
  export const WindowUtils = {
30
30
  openUri: _openUri,
31
- ba: _isPhone,
32
- wa: _getOrientation,
31
+ pa: _isPhone,
32
+ fa: _getOrientation,
33
33
  Qh: _getCurrentUrl,
34
34
  };
@@ -1,2 +0,0 @@
1
- export const DUST_SHARED_WORKER_CODE =
2
- '\n"use strict";\nconst workerSelf = self;\nlet eventSource = null;\nlet currentConfig = null;\nlet retryCount = 0;\nlet retryTimeoutId = null;\nlet connectionInProgress = false;\nconst maxRetries = 5;\nconst connectedPorts = new Map();\nlet lastSleepMs = null;\nlet currentRcs = null;\nlet ttlTimeoutId = null;\nlet leaderPortId = null;\nlet ddrTimeoutId = null;\nconst fn = {\n startConnection: null,\n handleMessage: null,\n};\nfunction broadcast(message) {\n connectedPorts.forEach((portInfo, portId) => {\n try {\n portInfo.port.postMessage(message);\n }\n catch (_a) {\n connectedPorts.delete(portId);\n }\n });\n}\nfunction randomInclusive(min, max) {\n return Math.floor(Math.random() * (max - min + 1)) + min;\n}\nfunction electLeader() {\n if (leaderPortId && connectedPorts.has(leaderPortId)) {\n return;\n }\n const firstPortId = connectedPorts.keys().next().value;\n leaderPortId = firstPortId || null;\n if (leaderPortId) {\n console.log("[Braze Real-Time] Elected leader port:", leaderPortId);\n }\n}\nfunction promoteToLeader(portId) {\n if (connectedPorts.has(portId) && leaderPortId !== portId) {\n leaderPortId = portId;\n console.log("[Braze Real-Time] Promoted to leader (tab became active):", portId);\n }\n}\nfunction sendToLeader(message) {\n electLeader();\n if (!leaderPortId) {\n console.warn("[Braze Real-Time] No leader to send message to");\n return;\n }\n const leader = connectedPorts.get(leaderPortId);\n if (leader) {\n try {\n leader.port.postMessage(message);\n }\n catch (_a) {\n connectedPorts.delete(leaderPortId);\n leaderPortId = null;\n sendToLeader(message);\n }\n }\n}\nfunction closeConnection() {\n connectionInProgress = false;\n if (retryTimeoutId !== null) {\n clearTimeout(retryTimeoutId);\n retryTimeoutId = null;\n }\n if (ttlTimeoutId !== null) {\n clearTimeout(ttlTimeoutId);\n ttlTimeoutId = null;\n }\n if (ddrTimeoutId !== null) {\n clearTimeout(ddrTimeoutId);\n ddrTimeoutId = null;\n }\n if (eventSource) {\n eventSource.close();\n eventSource = null;\n broadcast({ type: "disconnected" });\n }\n}\nfunction retryWithBackoff() {\n if (!currentConfig) {\n return;\n }\n retryCount++;\n const { minSleepMs, maxSleepMs, scaleFactor } = currentConfig.backoff;\n let previousSleepMs = lastSleepMs;\n if (previousSleepMs == null || previousSleepMs < minSleepMs) {\n previousSleepMs = minSleepMs;\n }\n const backoffMs = Math.min(maxSleepMs, randomInclusive(minSleepMs, previousSleepMs * scaleFactor));\n lastSleepMs = backoffMs;\n console.log(`[Braze Real-Time] Retrying in ${backoffMs}ms (attempt ${retryCount}/${maxRetries})`);\n retryTimeoutId = setTimeout(function () {\n retryTimeoutId = null;\n fn.startConnection();\n }, backoffMs);\n}\nfunction startConnection(oldEventSourceToClose) {\n if (!currentConfig) {\n return;\n }\n if (eventSource && !oldEventSourceToClose) {\n console.warn("[Braze Real-Time] Connection already exists");\n return;\n }\n if (connectionInProgress && !oldEventSourceToClose) {\n console.warn("[Braze Real-Time] Connection attempt already in progress");\n return;\n }\n connectionInProgress = true;\n const { dustHost, mite, auth } = currentConfig;\n const dustHostWithScheme = /^https?:\\/\\//i.test(dustHost) ? dustHost : `https://${dustHost}`;\n let queryString = `mite=${encodeURIComponent(mite)}&attempts=${retryCount}`;\n if (auth) {\n queryString += `&auth=${encodeURIComponent(auth)}`;\n }\n if (currentRcs) {\n queryString += `&rcs=${encodeURIComponent(currentRcs)}`;\n }\n const subscribeUrl = `${dustHostWithScheme}/sse?${queryString}`;\n try {\n const newEventSource = new EventSource(subscribeUrl);\n newEventSource.onopen = function () {\n if (oldEventSourceToClose) {\n console.log("[Braze Real-Time] Gapless reconnection: new connection established, closing old connection");\n oldEventSourceToClose.close();\n }\n else {\n console.log("[Braze Real-Time] Connection established");\n }\n eventSource = newEventSource;\n connectionInProgress = false;\n retryCount = 0;\n lastSleepMs = null;\n broadcast({ type: "connected" });\n };\n newEventSource.addEventListener("msg", function (event) {\n fn.handleMessage(event.data);\n });\n newEventSource.onerror = function () {\n const readyState = newEventSource ? newEventSource.readyState : -1;\n if (readyState === 0) {\n console.log("[Braze Real-Time] Failed to connect");\n }\n else {\n console.log("[Braze Real-Time] Connection lost");\n }\n if (oldEventSourceToClose && eventSource !== newEventSource) {\n console.log("[Braze Real-Time] Gapless reconnection failed, keeping old connection");\n newEventSource.close();\n connectionInProgress = false;\n if (retryCount < maxRetries) {\n retryWithBackoff();\n }\n return;\n }\n closeConnection();\n if (retryCount < maxRetries) {\n retryWithBackoff();\n }\n else {\n console.error("[Braze Real-Time] Max retries reached");\n broadcast({ type: "error", error: "Max retry attempts reached" });\n }\n };\n }\n catch (error) {\n connectionInProgress = false;\n console.error("[Braze Real-Time] Failed to create EventSource:", error);\n broadcast({ type: "error", error: String(error) });\n }\n}\nfunction handleTtlMessage(tMs, rcs) {\n if (typeof tMs !== "number") {\n return;\n }\n if (typeof rcs === "string") {\n currentRcs = rcs;\n }\n console.log(`[Braze Real-Time] TTL set to ${tMs}ms, will perform gapless reconnection when expired`);\n if (ttlTimeoutId !== null) {\n clearTimeout(ttlTimeoutId);\n }\n ttlTimeoutId = setTimeout(function () {\n ttlTimeoutId = null;\n console.log("[Braze Real-Time] TTL expired, performing gapless reconnection");\n startConnection(eventSource || undefined);\n }, tMs);\n}\nfunction handleDdrMessage(rMs, reason) {\n if (typeof rMs !== "number") {\n return;\n }\n const backoffConfig = currentConfig === null || currentConfig === void 0 ? void 0 : currentConfig.backoff;\n const minSleepMs = (backoffConfig === null || backoffConfig === void 0 ? void 0 : backoffConfig.minSleepMs) || 10000;\n const scaleFactor = (backoffConfig === null || backoffConfig === void 0 ? void 0 : backoffConfig.scaleFactor) || 3;\n const maxSleepMs = (backoffConfig === null || backoffConfig === void 0 ? void 0 : backoffConfig.maxSleepMs) || 300000;\n const backoffMs = Math.min(maxSleepMs, randomInclusive(minSleepMs, minSleepMs * scaleFactor));\n const waitMs = Math.round(rMs + backoffMs);\n const reasonStr = reason ? ` (${reason})` : "";\n console.log(`[Braze Real-Time] Admin requested disconnect${reasonStr}, reconnecting in ${waitMs}ms (r_ms=${rMs} + backoff=${backoffMs})`);\n if (ddrTimeoutId !== null) {\n clearTimeout(ddrTimeoutId);\n }\n closeConnection();\n ddrTimeoutId = setTimeout(function () {\n ddrTimeoutId = null;\n fn.startConnection();\n }, waitMs);\n}\nfunction handleMessage(data) {\n try {\n const message = JSON.parse(data);\n if (!message.type) {\n console.warn("[Braze Real-Time] Message without type:", message);\n return;\n }\n if (message.type === "ttl" && message.body) {\n handleTtlMessage(message.body.t_ms, message.body.rcs);\n return;\n }\n if (message.type === "ddr" && message.body) {\n handleDdrMessage(message.body.r_ms, message.body.e);\n return;\n }\n console.log(`[Braze Real-Time] Routing \'${message.type}\' message to leader`);\n sendToLeader({ type: "message", data: message });\n }\n catch (error) {\n console.warn("[Braze Real-Time] Failed to parse message:", error);\n }\n}\nfn.startConnection = startConnection;\nfn.handleMessage = handleMessage;\nfunction handlePortMessage(port, portId, message) {\n switch (message.type) {\n case "connect":\n if (currentConfig &&\n (currentConfig.mite !== message.config.mite || currentConfig.dustHost !== message.config.dustHost)) {\n console.log("[Braze Real-Time] Config changed, reconnecting");\n closeConnection();\n retryCount = 0;\n lastSleepMs = null;\n currentRcs = null;\n }\n currentConfig = message.config;\n if (!connectedPorts.has(portId)) {\n connectedPorts.set(portId, { port: port });\n }\n electLeader();\n if (!eventSource && !connectionInProgress) {\n startConnection();\n }\n else if (eventSource) {\n port.postMessage({ type: "connected" });\n }\n break;\n case "disconnect":\n connectedPorts.delete(portId);\n if (portId === leaderPortId) {\n leaderPortId = null;\n electLeader();\n }\n if (connectedPorts.size === 0) {\n console.log("[Braze Real-Time] No more ports, closing connection");\n closeConnection();\n currentConfig = null;\n currentRcs = null;\n leaderPortId = null;\n }\n break;\n case "tab_active":\n promoteToLeader(portId);\n break;\n case "ping":\n port.postMessage({ type: "pong" });\n break;\n default:\n console.warn("[Braze Real-Time] Unknown message type:", message.type);\n }\n}\nworkerSelf.onconnect = function (event) {\n const port = event.ports[0];\n const portId = `port-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;\n connectedPorts.set(portId, { port: port });\n port.onmessage = function (messageEvent) {\n try {\n handlePortMessage(port, portId, messageEvent.data);\n }\n catch (error) {\n console.error("[Braze Real-Time] Error handling message:", error);\n }\n };\n port.onmessageerror = function () {\n console.warn("[Braze Real-Time] Message error from port:", portId);\n connectedPorts.delete(portId);\n };\n port.start();\n};\n';