@braze/web-sdk 6.10.2 → 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 (109) hide show
  1. package/index.d.ts +61 -6
  2. package/package.json +1 -1
  3. package/shared-lib/encoding-utils.js +3 -3
  4. package/shared-lib/event-types.js +12 -12
  5. package/shared-lib/indexed-db-adapter.js +52 -52
  6. package/shared-lib/logger.js +7 -7
  7. package/shared-lib/supported-options.js +10 -10
  8. package/src/Core/logout.js +2 -2
  9. package/src/DUST/dust-config-store.js +89 -0
  10. package/src/DUST/dust-connection-core.js +7 -21
  11. package/src/DUST/dust-message-dedup.js +33 -0
  12. package/src/DUST/dust-provider.js +367 -397
  13. package/src/DUST/dust-tab-identity.js +30 -0
  14. package/src/DUST/index.js +7 -9
  15. package/src/DUST/subscribe-to-dust.js +5 -5
  16. package/src/FeatureFlags/feature-flag-factory.js +4 -4
  17. package/src/FeatureFlags/feature-flag.js +5 -5
  18. package/src/FeatureFlags/feature-flags-provider-factory.js +8 -1
  19. package/src/FeatureFlags/feature-flags-provider.js +74 -74
  20. package/src/FeatureFlags/get-all-feature-flags.js +2 -2
  21. package/src/FeatureFlags/get-feature-flag.js +2 -2
  22. package/src/FeatureFlags/log-feature-flag-impression.js +3 -3
  23. package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +1 -1
  24. package/src/InAppMessage/constants.js +39 -47
  25. package/src/InAppMessage/defer-in-app-message.js +2 -2
  26. package/src/InAppMessage/display/get-animation-effect.js +1 -1
  27. package/src/InAppMessage/display/html-message-display-utils.js +4 -4
  28. package/src/InAppMessage/display/html-message-to-html.js +10 -10
  29. package/src/InAppMessage/display/in-app-message-to-html.js +68 -66
  30. package/src/InAppMessage/display/modal-utils.js +14 -14
  31. package/src/InAppMessage/get-deferred-in-app-message.js +2 -2
  32. package/src/InAppMessage/in-app-message-factory.js +6 -6
  33. package/src/InAppMessage/in-app-message-manager-factory.js +5 -5
  34. package/src/InAppMessage/in-app-message-manager.js +101 -80
  35. package/src/InAppMessage/log-in-app-message-button-click.js +2 -2
  36. package/src/InAppMessage/log-in-app-message-click.js +2 -2
  37. package/src/InAppMessage/log-in-app-message-html-click.js +4 -4
  38. package/src/InAppMessage/log-in-app-message-impression.js +3 -3
  39. package/src/InAppMessage/models/full-screen-message.js +25 -25
  40. package/src/InAppMessage/models/html-message.js +14 -14
  41. package/src/InAppMessage/models/in-app-message-button.js +4 -4
  42. package/src/InAppMessage/models/in-app-message.js +100 -98
  43. package/src/InAppMessage/models/modal-message.js +23 -23
  44. package/src/InAppMessage/models/slide-up-message.js +29 -29
  45. package/src/InAppMessage/models/templated-in-app-message.js +8 -8
  46. package/src/InAppMessage/subscribe-to-in-app-message.js +2 -2
  47. package/src/InAppMessage/ui/automatically-show-in-app-messages.js +2 -2
  48. package/src/InAppMessage/ui/show-in-app-message.js +42 -40
  49. package/src/Push/index.js +1 -0
  50. package/src/Push/is-push-blocked.js +2 -2
  51. package/src/Push/is-push-permission-granted.js +2 -2
  52. package/src/Push/is-push-supported.js +2 -2
  53. package/src/Push/push-manager-factory.js +6 -6
  54. package/src/Push/push-manager.js +228 -185
  55. package/src/Push/register-push.js +9 -0
  56. package/src/Push/unregister-push-token-on-server.js +4 -4
  57. package/src/Push/utils/push-utils.js +16 -16
  58. package/src/User/user-manager.js +19 -19
  59. package/src/User/user.js +36 -36
  60. package/src/common/constants.js +1 -1
  61. package/src/common/content-cards-display.js +21 -21
  62. package/src/common/event-logger.js +2 -2
  63. package/src/l10n/l10n-manager-factory.js +7 -7
  64. package/src/l10n/l10n-manager.js +5 -5
  65. package/src/managers/auth-manager.js +1 -1
  66. package/src/managers/braze-instance.js +70 -66
  67. package/src/managers/device-manager.js +12 -12
  68. package/src/managers/network-manager.js +118 -118
  69. package/src/managers/server-config-manager.js +84 -84
  70. package/src/managers/session-manager.js +10 -10
  71. package/src/managers/storage-manager-factory.js +4 -4
  72. package/src/managers/storage-manager.js +138 -136
  73. package/src/managers/subscription-manager.js +1 -1
  74. package/src/managers/utils.js +1 -1
  75. package/src/models/backend-errors.js +5 -5
  76. package/src/models/braze-event.js +7 -7
  77. package/src/models/device.js +2 -2
  78. package/src/models/identifier.js +6 -6
  79. package/src/models/push-token.js +6 -6
  80. package/src/models/server-config.js +31 -31
  81. package/src/request-controller.js +91 -91
  82. package/src/triggers/models/filter.js +58 -58
  83. package/src/triggers/models/in-app-message-click-data.js +4 -4
  84. package/src/triggers/models/push-click-data.js +2 -2
  85. package/src/triggers/models/trigger-condition.js +35 -35
  86. package/src/triggers/models/trigger.js +37 -37
  87. package/src/triggers/triggers-provider-factory.js +3 -3
  88. package/src/triggers/triggers-provider.js +61 -53
  89. package/src/types.js +1 -1
  90. package/src/ui/js/attach-css.js +1 -1
  91. package/src/ui/js/feed-css.js +2 -2
  92. package/src/ui/js/iam-css.js +2 -2
  93. package/src/util/base-device-parser.js +1 -1
  94. package/src/util/braze-actions.js +4 -4
  95. package/src/util/browser-detector.js +13 -13
  96. package/src/util/client-hints-parser.js +4 -4
  97. package/src/util/component-utils.js +4 -4
  98. package/src/util/dom-utils.js +5 -5
  99. package/src/util/ecommerce-event-validation.js +77 -48
  100. package/src/util/key-codes.js +1 -1
  101. package/src/util/net.js +4 -4
  102. package/src/util/request-header-utils.js +20 -20
  103. package/src/util/string-utils.js +5 -0
  104. package/src/util/user-agent-parser.js +15 -15
  105. package/src/util/validation-utils.js +9 -9
  106. package/src/util/window-utils.js +2 -2
  107. package/src/DUST/dust-shared-worker-code.js +0 -2
  108. package/src/DUST/dust-shared-worker-impl.js +0 -234
  109. package/src/DUST/dust-worker-bridge.js +0 -151
@@ -1,5 +1,5 @@
1
1
  import { isArray as g } from "./code-utils.js";
2
- export default class Ve {
2
+ export default class Oe {
3
3
  constructor() {}
4
4
  ef() {}
5
5
  ff() {}
@@ -1,5 +1,5 @@
1
1
  import { logger as b } from "../../shared-lib/index.js";
2
- import { getErrorMessage as hi } from "./error-utils.js";
2
+ import { getErrorMessage as ci } from "./error-utils.js";
3
3
  import { decodeBrazeActions as uo } from "./string-utils.js";
4
4
  import {
5
5
  BRAZE_ACTION_URI_REGEX as to,
@@ -25,11 +25,11 @@ export const BRAZE_ACTIONS = {
25
25
  properties: { type: "type", eo: "steps", so: "args" },
26
26
  };
27
27
  export const INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES = {
28
- Un: "unknownBrazeAction",
28
+ Wn: "unknownBrazeAction",
29
29
  Nc: "noPushPrompt",
30
30
  };
31
31
  export const ineligibleBrazeActionURLErrorMessage = (t, o) =>
32
- t === INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES.Un
32
+ t === INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES.Wn
33
33
  ? `${o} contains an unknown braze action type and will not be displayed.`
34
34
  : "";
35
35
  export function getDecodedBrazeAction(t) {
@@ -46,7 +46,7 @@ export function getDecodedBrazeAction(t) {
46
46
  ? JSON.parse(e)
47
47
  : void b.error(`Failed to decode base64 encoded brazeAction: ${n}`);
48
48
  } catch (o) {
49
- return void b.error(`Failed to process brazeAction URL ${t} : ${hi(o)}`);
49
+ return void b.error(`Failed to process brazeAction URL ${t} : ${ci(o)}`);
50
50
  }
51
51
  }
52
52
  function po(t, o) {
@@ -1,13 +1,13 @@
1
1
  import Si from "./client-hints-parser.js";
2
- import vi from "./user-agent-parser.js";
3
- import { Browsers as yi, OperatingSystems as so } from "./device-constants.js";
4
- class xi {
2
+ import yi from "./user-agent-parser.js";
3
+ import { Browsers as xi, OperatingSystems as so } from "./device-constants.js";
4
+ class Bi {
5
5
  constructor() {
6
6
  let t;
7
7
  (t =
8
- navigator.userAgent.toLowerCase().includes(yi.Sg.toLowerCase()) ||
8
+ navigator.userAgent.toLowerCase().includes(xi.Sg.toLowerCase()) ||
9
9
  !navigator.userAgentData
10
- ? vi
10
+ ? yi
11
11
  : Si),
12
12
  (this.vg = new t()),
13
13
  (this.userAgent = navigator.userAgent),
@@ -23,18 +23,18 @@ class xi {
23
23
  i.systemLanguage ||
24
24
  ""
25
25
  ).toLowerCase()),
26
- (this.il = xi.xg(this.userAgent));
26
+ (this.il = Bi.xg(this.userAgent));
27
27
  }
28
- bS() {
29
- return this.browser === yi.Bg;
28
+ mS() {
29
+ return this.browser === xi.Bg;
30
30
  }
31
- Ba() {
31
+ qa() {
32
32
  return this.OS || null;
33
33
  }
34
34
  Fa() {
35
35
  return this.OS
36
36
  ? Promise.resolve(this.OS)
37
- : this.vg.Fa(xi.Og).then((t) => ((this.OS = t), t));
37
+ : this.vg.Fa(Bi.Og).then((t) => ((this.OS = t), t));
38
38
  }
39
39
  static xg(t) {
40
40
  t = t.toLowerCase();
@@ -63,7 +63,7 @@ class xi {
63
63
  return !1;
64
64
  }
65
65
  }
66
- xi.Og = [
66
+ Bi.Og = [
67
67
  { string: navigator.platform, cf: "Win", identity: so.kg },
68
68
  { string: navigator.platform, cf: "Mac", identity: so.Pg },
69
69
  { string: navigator.platform, cf: "BlackBerry", identity: "BlackBerry" },
@@ -91,5 +91,5 @@ xi.Og = [
91
91
  { string: navigator.userAgent, cf: ["Android"], identity: so.Dg },
92
92
  { string: navigator.platform, cf: "Linux", identity: "Linux" },
93
93
  ];
94
- const ro = new xi();
95
- export { ro as default, xi as BrowserDetector };
94
+ const ro = new Bi();
95
+ export { ro as default, Bi as BrowserDetector };
@@ -1,6 +1,6 @@
1
- import Ve from "./base-device-parser.js";
2
- import { Browsers as yi } from "./device-constants.js";
3
- export default class Si extends Ve {
1
+ import Oe from "./base-device-parser.js";
2
+ import { Browsers as xi } from "./device-constants.js";
3
+ export default class Si extends Oe {
4
4
  constructor() {
5
5
  if (
6
6
  (super(),
@@ -41,7 +41,7 @@ export default class Si extends Ve {
41
41
  s = this.userAgentData.brands;
42
42
  if (s && s.length)
43
43
  for (const r of s) {
44
- const s = this.Vc(yi),
44
+ const s = this.Vc(xi),
45
45
  i = r.brand.match(s);
46
46
  if (i && i.length > 0) {
47
47
  (t.browser = i[0]), (t.version = r.version);
@@ -1,5 +1,5 @@
1
- import { addPassiveEventListener as F, buildSvg as we } from "./dom-utils.js";
2
- import { KeyCodes as Ce } from "./key-codes.js";
1
+ import { addPassiveEventListener as F, buildSvg as oe } from "./dom-utils.js";
2
+ import { KeyCodes as le } from "./key-codes.js";
3
3
  export function createCloseButton(t, o, e, r = "ltr") {
4
4
  const n = document.createElement("button");
5
5
  n.setAttribute("aria-label", t),
@@ -7,7 +7,7 @@ export function createCloseButton(t, o, e, r = "ltr") {
7
7
  (n.dir = r),
8
8
  F(n, "touchstart"),
9
9
  (n.className = "ab-close-button");
10
- const l = we(
10
+ const l = oe(
11
11
  "0 0 15 15",
12
12
  "M15 1.5L13.5 0l-6 6-6-6L0 1.5l6 6-6 6L1.5 15l6-6 6 6 1.5-1.5-6-6 6-6z",
13
13
  o,
@@ -16,7 +16,7 @@ export function createCloseButton(t, o, e, r = "ltr") {
16
16
  n.appendChild(l),
17
17
  l.setAttribute("aria-hidden", "true"),
18
18
  n.addEventListener("keydown", (t) => {
19
- (t.keyCode !== Ce.Ao && t.keyCode !== Ce.Lo) ||
19
+ (t.keyCode !== le.To && t.keyCode !== le.Lo) ||
20
20
  (e(), t.stopPropagation());
21
21
  }),
22
22
  (n.onclick = (t) => {
@@ -1,5 +1,5 @@
1
1
  import { logger as b } from "../../shared-lib/index.js";
2
- import { getErrorMessage as hi } 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(hi(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.Ld || r === un.Od,
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, rh: 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 hi } 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.Ya : Ne.Va,
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: ${hi(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
- Yo: "template",
7
+ vo: "feature_flags/sync",
8
+ Xo: "template",
9
9
  st: "banners/sync",
10
- qa: "push/unregister",
10
+ ka: "push/unregister",
11
11
  },
12
- Ul: (e) => (null == e ? void 0 : e.St(s.It.ES)),
13
- Rm: (e) => (null == e ? void 0 : e.St(s.It.SS)),
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.ES, t);
15
+ null == e || e.Pt(s.It.lS, t);
16
16
  },
17
17
  qm: (e, t) => {
18
- null == e || e.Pt(s.It.SS, t);
18
+ null == e || e.Pt(s.It._S, t);
19
19
  },
20
- Al: (e, t) => {
20
+ gl: (e, t) => {
21
21
  if (!e || !t) return -1;
22
- const s = h.Ul(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
- Dl: (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.Ul(e);
35
+ let n = h.Il(e);
36
36
  null == n && (n = {}), (n[t] = s), h.Am(e, n);
37
37
  },
38
- Tl: (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.Tl(e, t, Qe);
44
+ e && t && h.ql(e, t, Ne);
45
45
  },
46
- jl: (e, t) => {
46
+ Sl: (e, t) => {
47
47
  if (!e || !t) return;
48
- const s = h.Dl(e, t);
49
- h.Tl(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,8 +1,8 @@
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.Sd = vi.Bc(navigator.userAgent || ""));
5
+ super(), (this.Sd = yi.Bc(navigator.userAgent || ""));
6
6
  }
7
7
  ef() {
8
8
  return this.Sd[0] || "Unknown Browser";
@@ -13,7 +13,7 @@ export default class vi extends Ve {
13
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
  }