@braze/web-sdk 4.7.2 → 4.8.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 (164) hide show
  1. package/index.d.ts +32 -26
  2. package/package.json +1 -1
  3. package/shared-lib/braze-shared-lib.js +5 -5
  4. package/shared-lib/encoding-utils.js +1 -1
  5. package/shared-lib/event-types.js +25 -25
  6. package/shared-lib/guid.js +3 -3
  7. package/shared-lib/indexed-db-adapter.js +74 -74
  8. package/shared-lib/logger.js +18 -18
  9. package/shared-lib/supported-options.js +18 -18
  10. package/src/Card/card-manager-factory.js +2 -2
  11. package/src/Card/card-manager.js +48 -42
  12. package/src/Card/display/card-display.js +70 -67
  13. package/src/Card/log-card-click.js +1 -1
  14. package/src/Card/log-card-dismissal.js +1 -1
  15. package/src/Card/log-card-impressions.js +3 -3
  16. package/src/Card/models/banner.js +3 -2
  17. package/src/Card/models/captioned-image.js +6 -5
  18. package/src/Card/models/card.js +107 -87
  19. package/src/Card/models/classic-card.js +5 -5
  20. package/src/Card/models/control-card.js +5 -21
  21. package/src/Card/types.js +1 -0
  22. package/src/Card/util/card-factory.js +32 -32
  23. package/src/ContentCards/content-cards-provider-factory.js +3 -3
  24. package/src/ContentCards/content-cards-provider.js +283 -175
  25. package/src/ContentCards/content-cards.js +2 -2
  26. package/src/ContentCards/get-cached-content-cards.js +1 -1
  27. package/src/ContentCards/log-content-cards-displayed.js +2 -2
  28. package/src/ContentCards/request-content-cards-refresh.js +1 -1
  29. package/src/ContentCards/subscribe-to-content-cards-updates.js +9 -6
  30. package/src/ContentCards/types.js +1 -0
  31. package/src/ContentCards/ui/hide-content-cards.js +2 -2
  32. package/src/ContentCards/ui/show-content-cards.js +36 -34
  33. package/src/Core/add-sdk-metadata.js +17 -18
  34. package/src/Core/change-user.js +12 -14
  35. package/src/Core/destroy.js +1 -1
  36. package/src/Core/disable-sdk.js +8 -6
  37. package/src/Core/enable-sdk.js +4 -4
  38. package/src/Core/get-device-id.js +7 -6
  39. package/src/Core/get-user.js +1 -1
  40. package/src/Core/handle-braze-action.js +57 -40
  41. package/src/Core/is-disabled.js +2 -2
  42. package/src/Core/log-custom-event.js +22 -15
  43. package/src/Core/log-purchase.js +33 -33
  44. package/src/Core/open-session.js +17 -15
  45. package/src/Core/request-immediate-data-flush.js +4 -2
  46. package/src/Core/set-logger.js +1 -1
  47. package/src/Core/set-sdk-authentication-signature.js +5 -6
  48. package/src/Core/subscribe-to-sdk-authentication-failures.js +3 -1
  49. package/src/Core/toggle-logging.js +1 -1
  50. package/src/Core/types.js +1 -0
  51. package/src/Core/wipe-data.js +11 -10
  52. package/src/FeatureFlags/feature-flag-factory.js +6 -6
  53. package/src/FeatureFlags/feature-flag.js +17 -17
  54. package/src/FeatureFlags/feature-flags-provider-factory.js +2 -2
  55. package/src/FeatureFlags/feature-flags-provider.js +67 -65
  56. package/src/FeatureFlags/get-all-feature-flags.js +3 -3
  57. package/src/FeatureFlags/get-feature-flag.js +4 -4
  58. package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +4 -1
  59. package/src/Feed/feed-provider-factory.js +8 -8
  60. package/src/Feed/feed-provider.js +57 -46
  61. package/src/Feed/feed.js +1 -1
  62. package/src/Feed/get-cached-feed.js +2 -2
  63. package/src/Feed/log-feed-displayed.js +3 -1
  64. package/src/Feed/request-feed-refresh.js +2 -2
  65. package/src/Feed/subscribe-to-feed-updates.js +2 -2
  66. package/src/Feed/types.js +1 -0
  67. package/src/Feed/ui/hide-feed.js +2 -2
  68. package/src/Feed/ui/show-feed.js +41 -37
  69. package/src/InAppMessage/display/html-message-to-html.js +125 -119
  70. package/src/InAppMessage/display/in-app-message-to-html.js +72 -69
  71. package/src/InAppMessage/display/modal-utils.js +18 -13
  72. package/src/InAppMessage/in-app-message-factory.js +9 -8
  73. package/src/InAppMessage/in-app-message-manager-factory.js +7 -7
  74. package/src/InAppMessage/in-app-message-manager.js +130 -110
  75. package/src/InAppMessage/log-in-app-message-button-click.js +10 -10
  76. package/src/InAppMessage/log-in-app-message-click.js +9 -9
  77. package/src/InAppMessage/log-in-app-message-html-click.js +10 -10
  78. package/src/InAppMessage/log-in-app-message-impression.js +5 -5
  79. package/src/InAppMessage/models/control-message.js +4 -1
  80. package/src/InAppMessage/models/full-screen-message.js +35 -37
  81. package/src/InAppMessage/models/html-message.js +34 -33
  82. package/src/InAppMessage/models/in-app-message-button.js +23 -16
  83. package/src/InAppMessage/models/in-app-message.js +147 -105
  84. package/src/InAppMessage/models/modal-message.js +34 -36
  85. package/src/InAppMessage/models/slide-up-message.js +25 -27
  86. package/src/InAppMessage/models/templated-in-app-message.js +12 -7
  87. package/src/InAppMessage/subscribe-to-in-app-message.js +2 -2
  88. package/src/InAppMessage/types.js +1 -0
  89. package/src/InAppMessage/ui/automatically-show-in-app-messages.js +4 -4
  90. package/src/InAppMessage/ui/show-in-app-message.js +95 -89
  91. package/src/InAppMessage/utils/in-app-message-utils.js +1 -0
  92. package/src/Push/is-push-blocked.js +2 -2
  93. package/src/Push/is-push-permission-granted.js +2 -2
  94. package/src/Push/is-push-supported.js +2 -2
  95. package/src/Push/push-manager-factory.js +20 -20
  96. package/src/Push/push-manager.js +193 -174
  97. package/src/Push/request-push-permission.js +4 -3
  98. package/src/Push/types.js +1 -0
  99. package/src/Push/unregister-push.js +2 -2
  100. package/src/Push/utils/push-utils.js +10 -10
  101. package/src/User/types.js +1 -0
  102. package/src/User/user-manager.js +24 -24
  103. package/src/User/user.js +117 -105
  104. package/src/common/base-feed.js +7 -7
  105. package/src/common/base-provider.js +2 -2
  106. package/src/common/constants.js +6 -0
  107. package/src/common/event-logger.js +6 -6
  108. package/src/common/feed-display.js +95 -85
  109. package/src/common/types.js +1 -0
  110. package/src/l10n/l10n-manager-factory.js +10 -10
  111. package/src/l10n/l10n-manager.js +1 -1
  112. package/src/managers/auth-manager.js +37 -34
  113. package/src/managers/braze-instance.js +209 -193
  114. package/src/managers/device-manager.js +43 -38
  115. package/src/managers/network-manager.js +119 -96
  116. package/src/managers/server-config-manager.js +68 -48
  117. package/src/managers/session-manager.js +52 -45
  118. package/src/managers/storage-manager-factory.js +29 -22
  119. package/src/managers/storage-manager.js +288 -273
  120. package/src/managers/subscription-manager.js +9 -6
  121. package/src/managers/types.js +1 -0
  122. package/src/models/backend-errors.js +5 -5
  123. package/src/models/braze-event.js +14 -8
  124. package/src/models/device.js +10 -18
  125. package/src/models/identifier.js +10 -11
  126. package/src/models/push-token.js +17 -12
  127. package/src/models/request-result.js +4 -4
  128. package/src/models/server-config.js +36 -20
  129. package/src/models/types.js +1 -0
  130. package/src/request-controller.js +176 -174
  131. package/src/triggers/models/custom-event-data.js +6 -6
  132. package/src/triggers/models/custom-event-property-data.js +9 -9
  133. package/src/triggers/models/filter-set.js +9 -9
  134. package/src/triggers/models/filter.js +64 -64
  135. package/src/triggers/models/in-app-message-click-data.js +12 -12
  136. package/src/triggers/models/purchase-data.js +3 -3
  137. package/src/triggers/models/purchase-property-data.js +9 -9
  138. package/src/triggers/models/push-click-data.js +7 -7
  139. package/src/triggers/models/trigger-condition.js +57 -57
  140. package/src/triggers/models/trigger-events.js +2 -2
  141. package/src/triggers/models/trigger.js +42 -42
  142. package/src/triggers/triggers-provider-factory.js +8 -8
  143. package/src/triggers/triggers-provider.js +173 -170
  144. package/src/types.js +1 -0
  145. package/src/ui/js/attach-css.js +3 -3
  146. package/src/ui/js/load-font-awesome.js +2 -2
  147. package/src/util/base-device-parser.js +2 -2
  148. package/src/util/braze-actions.js +20 -20
  149. package/src/util/browser-detector.js +22 -22
  150. package/src/util/client-hints-parser.js +7 -7
  151. package/src/util/code-utils.js +1 -1
  152. package/src/util/color-utils.js +2 -2
  153. package/src/util/component-utils.js +2 -2
  154. package/src/util/deprecation-utils.js +1 -1
  155. package/src/util/device-constants.js +3 -3
  156. package/src/util/dom-utils.js +7 -7
  157. package/src/util/error-utils.js +2 -0
  158. package/src/util/key-codes.js +1 -1
  159. package/src/util/net.js +11 -11
  160. package/src/util/request-header-utils.js +23 -0
  161. package/src/util/string-utils.js +1 -1
  162. package/src/util/user-agent-parser.js +21 -21
  163. package/src/util/validation-utils.js +44 -44
  164. package/src/util/window-utils.js +3 -3
@@ -1,14 +1,14 @@
1
- import ti from "./client-hints-parser.js";
2
- import ni from "./user-agent-parser.js";
3
- import { Browsers as ri, OperatingSystems as rt } from "./device-constants.js";
4
- class si {
1
+ import ni from "./client-hints-parser.js";
2
+ import ai from "./user-agent-parser.js";
3
+ import { Browsers as gi, OperatingSystems as W } from "./device-constants.js";
4
+ class oi {
5
5
  constructor() {
6
- const t = navigator.userAgentData ? ti : ni;
6
+ const t = navigator.userAgentData ? ni : ai;
7
7
  (this.Sg = new t()),
8
8
  (this.userAgent = navigator.userAgent),
9
9
  (this.browser = this.Sg.tf()),
10
10
  (this.version = this.Sg.ef()),
11
- this.Yo().then(t => (this.OS = t)),
11
+ this.Zo().then(t => (this.OS = t)),
12
12
  (this.language = (
13
13
  navigator.userLanguage ||
14
14
  navigator.language ||
@@ -16,21 +16,21 @@ class si {
16
16
  navigator.systemLanguage ||
17
17
  ""
18
18
  ).toLowerCase()),
19
- (this.zo = si.Bg(this.userAgent));
19
+ (this.Ho = oi.Bg(this.userAgent));
20
20
  }
21
21
  Og() {
22
- return this.browser !== ri.Pg || this.version > 8;
22
+ return this.browser !== gi.Pg || this.version > 8;
23
23
  }
24
- xa() {
25
- return this.browser === ri.kg;
24
+ $a() {
25
+ return this.browser === gi.kg;
26
26
  }
27
- Qo() {
27
+ ca() {
28
28
  return this.OS || null;
29
29
  }
30
- Yo() {
30
+ Zo() {
31
31
  return this.OS
32
32
  ? Promise.resolve(this.OS)
33
- : this.Sg.Yo(si.xg).then(t => ((this.OS = t), t));
33
+ : this.Sg.Zo(oi.xg).then(t => ((this.OS = t), t));
34
34
  }
35
35
  static Bg(t) {
36
36
  t = t.toLowerCase();
@@ -56,9 +56,9 @@ class si {
56
56
  return !1;
57
57
  }
58
58
  }
59
- si.xg = [
60
- { string: navigator.platform, if: "Win", identity: rt.Dg },
61
- { string: navigator.platform, if: "Mac", identity: rt.jg },
59
+ oi.xg = [
60
+ { string: navigator.platform, if: "Win", identity: W.Dg },
61
+ { string: navigator.platform, if: "Mac", identity: W.Fg },
62
62
  { string: navigator.platform, if: "BlackBerry", identity: "BlackBerry" },
63
63
  { string: navigator.platform, if: "FreeBSD", identity: "FreeBSD" },
64
64
  { string: navigator.platform, if: "OpenBSD", identity: "OpenBSD" },
@@ -69,17 +69,17 @@ si.xg = [
69
69
  {
70
70
  string: navigator.userAgent,
71
71
  if: ["iPhone", "iPad", "iPod"],
72
- identity: rt.$e
72
+ identity: W.fe
73
73
  },
74
- { string: navigator.platform, if: "Pike v", identity: rt.$e },
74
+ { string: navigator.platform, if: "Pike v", identity: W.fe },
75
75
  { string: navigator.userAgent, if: ["Web0S"], identity: "WebOS" },
76
76
  {
77
77
  string: navigator.platform,
78
78
  if: ["Linux armv7l", "Android"],
79
- identity: rt.Fg
79
+ identity: W.Lg
80
80
  },
81
- { string: navigator.userAgent, if: ["Android"], identity: rt.Fg },
81
+ { string: navigator.userAgent, if: ["Android"], identity: W.Lg },
82
82
  { string: navigator.platform, if: "Linux", identity: "Linux" }
83
83
  ];
84
- const ot = new si();
85
- export { ot as default, si as BrowserDetector };
84
+ const V = new oi();
85
+ export { V as default, oi as BrowserDetector };
@@ -1,6 +1,6 @@
1
- import Oe from "./base-device-parser.js";
2
- import { Browsers as ri } from "./device-constants.js";
3
- export default class ti extends Oe {
1
+ import ge from "./base-device-parser.js";
2
+ import { Browsers as gi } from "./device-constants.js";
3
+ export default class ni extends ge {
4
4
  constructor() {
5
5
  if (
6
6
  (super(),
@@ -18,11 +18,11 @@ export default class ti extends Oe {
18
18
  ef() {
19
19
  return this.version;
20
20
  }
21
- Yo(t) {
21
+ Zo(t) {
22
22
  if (this.OS) return Promise.resolve(this.OS);
23
23
  const r = r => {
24
24
  for (let s = 0; s < t.length; s++) {
25
- const e = ti.rf(r, t[s]);
25
+ const e = ni.rf(r, t[s]);
26
26
  if (e) return (this.OS = e), this.OS;
27
27
  }
28
28
  return r;
@@ -38,7 +38,7 @@ export default class ti extends Oe {
38
38
  r = this.userAgentData.brands;
39
39
  if (r && r.length)
40
40
  for (const s of r) {
41
- const r = this.oc(ri),
41
+ const r = this.oc(gi),
42
42
  e = s.brand.match(r);
43
43
  if (e && e.length > 0) {
44
44
  (t.browser = e[0]), (t.version = s.version);
@@ -49,7 +49,7 @@ export default class ti extends Oe {
49
49
  }
50
50
  oc(t) {
51
51
  const r = [];
52
- for (const s in t) t[s] !== ri.Pg && r.push(t[s]);
52
+ for (const s in t) t[s] !== gi.Pg && r.push(t[s]);
53
53
  return new RegExp("(" + r.join("|") + ")", "i");
54
54
  }
55
55
  nc() {
@@ -11,7 +11,7 @@ export function validateValueIsFromEnum(t, e, n, o) {
11
11
  const c = values(t);
12
12
  return (
13
13
  -1 !== c.indexOf(e) ||
14
- (r.D.error(`${n} Valid values from ${o} are "${c.join('"/"')}".`), !1)
14
+ (r.j.error(`${n} Valid values from ${o} are "${c.join('"/"')}".`), !1)
15
15
  );
16
16
  }
17
17
  export function isArray(t) {
@@ -1,4 +1,4 @@
1
- import ot from "./browser-detector.js";
1
+ import V from "./browser-detector.js";
2
2
  export function isTransparent(r) {
3
3
  return (r = parseInt(r)), !isNaN(r) && (4278190080 & r) >>> 24 == 0;
4
4
  }
@@ -9,7 +9,7 @@ export function toRgba(r, t) {
9
9
  e = (65280 & r) >>> 8,
10
10
  o = (16711680 & r) >>> 16,
11
11
  a = ((4278190080 & r) >>> 24) / 255;
12
- return ot.Og()
12
+ return V.Og()
13
13
  ? "rgba(" + [o, e, n, a * t].join(",") + ")"
14
14
  : "rgb(" + [o, e, n].join(",") + ")";
15
15
  }
@@ -1,5 +1,5 @@
1
1
  import { addPassiveEventListener as oe, buildSvg as ae } from "./dom-utils.js";
2
- import { KeyCodes as at } from "./key-codes.js";
2
+ import { KeyCodes as lt } from "./key-codes.js";
3
3
  export function createCloseButton(t, o, e) {
4
4
  const n = document.createElement("button");
5
5
  n.setAttribute("aria-label", t),
@@ -15,7 +15,7 @@ export function createCloseButton(t, o, e) {
15
15
  return (
16
16
  n.appendChild(r),
17
17
  n.addEventListener("keydown", t => {
18
- (t.keyCode !== at.fo && t.keyCode !== at.co) ||
18
+ (t.keyCode !== lt.yo && t.keyCode !== lt.Fo) ||
19
19
  (e(), t.stopPropagation());
20
20
  }),
21
21
  (n.onclick = t => {
@@ -1,5 +1,5 @@
1
1
  import r from "../../shared-lib/braze-shared-lib.js";
2
2
  export function logDeprecationWarning(e, a, i) {
3
3
  let s = `The '${e}' ${a} is deprecated.`;
4
- i && (s += ` Please use '${i}' instead.`), r.D.warn(s);
4
+ i && (s += ` Please use '${i}' instead.`), r.j.warn(s);
5
5
  }
@@ -7,8 +7,8 @@ export const Browsers = {
7
7
  oE: "Firefox"
8
8
  };
9
9
  export const OperatingSystems = {
10
- Fg: "Android",
11
- $e: "iOS",
12
- jg: "Mac",
10
+ Lg: "Android",
11
+ fe: "iOS",
12
+ Fg: "Mac",
13
13
  Dg: "Windows"
14
14
  };
@@ -16,22 +16,22 @@ export function _isInView(t, n, e, s) {
16
16
  !s)
17
17
  );
18
18
  }
19
- export const DOMUtils = { Ou: null, eo: _isInView };
20
- export const DIRECTIONS = { Je: "up", Ke: "down", ot: "left", et: "right" };
19
+ export const DOMUtils = { lc: null, eo: _isInView };
20
+ export const DIRECTIONS = { Je: "up", Ke: "down", W: "left", X: "right" };
21
21
  export function supportsPassive() {
22
- if (null == DOMUtils.Ou) {
23
- DOMUtils.Ou = !1;
22
+ if (null == DOMUtils.lc) {
23
+ DOMUtils.lc = !1;
24
24
  try {
25
25
  const t = Object.defineProperty({}, "passive", {
26
26
  get: () => {
27
- DOMUtils.Ou = !0;
27
+ DOMUtils.lc = !0;
28
28
  }
29
29
  });
30
30
  window.addEventListener("testPassive", null, t),
31
31
  window.removeEventListener("testPassive", null, t);
32
32
  } catch (t) {}
33
33
  }
34
- return DOMUtils.Ou;
34
+ return DOMUtils.lc;
35
35
  }
36
36
  export function addPassiveEventListener(t, n, e = () => {}) {
37
37
  t.addEventListener(n, e, !!supportsPassive() && { passive: !0 });
@@ -59,7 +59,7 @@ export function detectSwipe(t, n, e) {
59
59
  const l = s - o.touches[0].clientX,
60
60
  u = i - o.touches[0].clientY;
61
61
  Math.abs(l) > Math.abs(u) && Math.abs(l) >= 25
62
- ? (((l > 0 && n === DIRECTIONS.ot) || (l < 0 && n === DIRECTIONS.et)) &&
62
+ ? (((l > 0 && n === DIRECTIONS.W) || (l < 0 && n === DIRECTIONS.X)) &&
63
63
  e(o),
64
64
  (s = null),
65
65
  (i = null))
@@ -0,0 +1,2 @@
1
+ export const getErrorMessage = r =>
2
+ r instanceof Error ? r.message : String(r);
@@ -1 +1 @@
1
- export const KeyCodes = { fo: 32, oo: 9, co: 13, mh: 27 };
1
+ export const KeyCodes = { yo: 32, oo: 9, Fo: 13, Ih: 27 };
package/src/util/net.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import r from "../../shared-lib/braze-shared-lib.js";
2
2
  import qt from "../models/backend-errors.js";
3
- const b = {
4
- Hs: t => {
3
+ const C = {
4
+ Ys: t => {
5
5
  let e, o;
6
6
  try {
7
7
  const n = () => {
8
- r.D.error("This browser does not have any supported ajax options!");
8
+ r.j.error("This browser does not have any supported ajax options!");
9
9
  };
10
10
  if (
11
11
  (window.XMLHttpRequest ? ((e = new XMLHttpRequest()), e || n()) : n(),
@@ -13,7 +13,7 @@ const b = {
13
13
  ) {
14
14
  const r = () => {
15
15
  "function" == typeof t.error && t.error(e.status),
16
- "function" == typeof t.wi && t.wi(!1);
16
+ "function" == typeof t.ei && t.ei(!1);
17
17
  };
18
18
  (e.onload = () => {
19
19
  let o = !1;
@@ -21,21 +21,21 @@ const b = {
21
21
  if (
22
22
  ((o = (e.status >= 200 && e.status < 300) || 304 === e.status), o)
23
23
  ) {
24
- if ("function" == typeof t.S) {
24
+ if ("function" == typeof t.O) {
25
25
  let o, r;
26
26
  try {
27
27
  (o = JSON.parse(e.responseText)),
28
28
  (r = e.getAllResponseHeaders());
29
29
  } catch (o) {
30
30
  const n = {
31
- error: "" === e.responseText ? qt.la : qt.fa,
31
+ error: "" === e.responseText ? qt.ga : qt.qa,
32
32
  response: e.responseText
33
33
  };
34
- t.S(n, r);
34
+ t.O(n, r);
35
35
  }
36
- o && t.S(o, r);
36
+ o && t.O(o, r);
37
37
  }
38
- "function" == typeof t.wi && t.wi(!0);
38
+ "function" == typeof t.ei && t.ei(!0);
39
39
  } else r();
40
40
  }),
41
41
  (e.onerror = () => {
@@ -53,7 +53,7 @@ const b = {
53
53
  e.send(o);
54
54
  }
55
55
  } catch (t) {
56
- r.D.error(`Network request error: ${t.message}`);
56
+ r.j.error(`Network request error: ${t.message}`);
57
57
  }
58
58
  }
59
59
  };
@@ -72,4 +72,4 @@ export const readResponseHeaders = t => {
72
72
  (e[r] = n));
73
73
  return e;
74
74
  };
75
- export default b;
75
+ export default C;
@@ -0,0 +1,23 @@
1
+ import { STORAGE_KEYS as i } from "../managers/storage-manager.js";
2
+ const T = {
3
+ Qs: { Sa: "d", Os: "cc", xi: "ff", Yi: "t" },
4
+ eT: e => {
5
+ if (e) return e.v(i.k.Ua);
6
+ },
7
+ tT: (e, t) => {
8
+ e && e.D(i.k.Ua, t);
9
+ },
10
+ Xa: (e, t) => {
11
+ if (!e || !t) return -1;
12
+ const r = T.eT(e);
13
+ if (null == r) return -1;
14
+ const s = r[t];
15
+ return null == s || isNaN(s) ? -1 : s;
16
+ },
17
+ Xs: (e, t, r) => {
18
+ if (!e || !t) return;
19
+ let s = T.eT(e);
20
+ null == s && (s = {}), (s[t] = r), T.tT(e, s);
21
+ }
22
+ };
23
+ export default T;
@@ -17,6 +17,6 @@ export function decodeBrazeActions(e) {
17
17
  let n = new Uint16Array(r.buffer);
18
18
  return String.fromCharCode(...n);
19
19
  } catch (e) {
20
- return r.D.error("Unable to decode Base64: " + e), null;
20
+ return r.j.error("Unable to decode Base64: " + e), null;
21
21
  }
22
22
  }
@@ -1,28 +1,28 @@
1
- import Oe from "./base-device-parser.js";
2
- import { Browsers as ri, OperatingSystems as rt } from "./device-constants.js";
3
- export default class ni extends Oe {
1
+ import ge from "./base-device-parser.js";
2
+ import { Browsers as gi, OperatingSystems as W } from "./device-constants.js";
3
+ export default class ai extends ge {
4
4
  constructor() {
5
- super(), (this.Su = ni.Vu(navigator.userAgent || ""));
5
+ super(), (this.rd = ai.ed(navigator.userAgent || ""));
6
6
  }
7
7
  tf() {
8
- return this.Su[0] || "Unknown Browser";
8
+ return this.rd[0] || "Unknown Browser";
9
9
  }
10
10
  ef() {
11
- return this.Su[1] || "Unknown Version";
11
+ return this.rd[1] || "Unknown Version";
12
12
  }
13
- Yo(r) {
13
+ Zo(r) {
14
14
  for (let e = 0; e < r.length; e++) {
15
15
  let n = r[e].string,
16
- i = ni.rf(n, r[e]);
16
+ i = ai.rf(n, r[e]);
17
17
  if (i)
18
18
  return (
19
- i === rt.jg && navigator.maxTouchPoints > 1 && (i = rt.$e),
19
+ i === W.Fg && navigator.maxTouchPoints > 1 && (i = W.fe),
20
20
  Promise.resolve(i)
21
21
  );
22
22
  }
23
23
  return Promise.resolve(navigator.platform);
24
24
  }
25
- static Vu(r) {
25
+ static ed(r) {
26
26
  let e,
27
27
  n =
28
28
  r.match(
@@ -30,7 +30,7 @@ export default class ni extends Oe {
30
30
  ) || [];
31
31
  if (/trident/i.test(n[1]))
32
32
  return (
33
- (e = /\brv[ :]+(\.?\d+(\.\d+)*)/g.exec(r) || []), [ri.Pg, e[1] || ""]
33
+ (e = /\brv[ :]+(\.?\d+(\.\d+)*)/g.exec(r) || []), [gi.Pg, e[1] || ""]
34
34
  );
35
35
  if (-1 !== r.indexOf("(Web0S; Linux/SmartTV)"))
36
36
  return ["LG Smart TV", null];
@@ -45,38 +45,38 @@ export default class ni extends Oe {
45
45
  if (r.match(/\b(Roku)\b/)) return ["Roku", null];
46
46
  if (r.match(/\bAFTM\b/)) return ["Amazon Fire Stick", null];
47
47
  if (
48
- n[1] === ri.rE &&
48
+ n[1] === gi.rE &&
49
49
  ((e = r.match(/\b(OPR|Edge|EdgA|Edg|UCBrowser)\/(\.?\d+(\.\d+)*)/)),
50
50
  null != e)
51
51
  )
52
52
  return (
53
53
  (e = e.slice(1)),
54
- (e[0] = e[0].replace("OPR", ri.EE)),
55
- (e[0] = e[0].replace("EdgA", ri.eE)),
56
- "Edg" === e[0] && (e[0] = ri.eE),
54
+ (e[0] = e[0].replace("OPR", gi.EE)),
55
+ (e[0] = e[0].replace("EdgA", gi.eE)),
56
+ "Edg" === e[0] && (e[0] = gi.eE),
57
57
  [e[0], e[1]]
58
58
  );
59
59
  if (
60
- n[1] === ri.kg &&
60
+ n[1] === gi.kg &&
61
61
  ((e = r.match(/\b(EdgiOS)\/(\.?\d+(\.\d+)*)/)), null != e)
62
62
  )
63
63
  return (
64
- (e = e.slice(1)), (e[0] = e[0].replace("EdgiOS", ri.eE)), [e[0], e[1]]
64
+ (e = e.slice(1)), (e[0] = e[0].replace("EdgiOS", gi.eE)), [e[0], e[1]]
65
65
  );
66
66
  if (
67
67
  ((n = n[2] ? [n[1], n[2]] : [null, null]),
68
- n[0] === ri.kg &&
68
+ n[0] === gi.kg &&
69
69
  null != (e = r.match(/version\/(\.?\d+(\.\d+)*)/i)) &&
70
70
  n.splice(1, 1, e[1]),
71
71
  null != (e = r.match(/\b(UCBrowser)\/(\.?\d+(\.\d+)*)/)) &&
72
72
  n.splice(1, 1, e[2]),
73
- n[0] === ri.EE && null != (e = r.match(/mini\/(\.?\d+(\.\d+)*)/i)))
73
+ n[0] === gi.EE && null != (e = r.match(/mini\/(\.?\d+(\.\d+)*)/i)))
74
74
  )
75
75
  return ["Opera Mini", e[1] || ""];
76
76
  if (n[0]) {
77
77
  const r = n[0].toLowerCase();
78
- "msie" === r && (n[0] = ri.Pg),
79
- "crios" === r && (n[0] = ri.rE),
78
+ "msie" === r && (n[0] = gi.Pg),
79
+ "crios" === r && (n[0] = gi.rE),
80
80
  "tizen" === r && ((n[0] = "Samsung Smart TV"), (n[1] = null)),
81
81
  "samsungbrowser" === r && (n[0] = "Samsung Browser");
82
82
  }
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  isArray as p,
3
3
  isDate as Nt,
4
- isObject as yt,
5
- keys as or
4
+ isObject as Ct,
5
+ keys as oo
6
6
  } from "./code-utils.js";
7
7
  import { getByteLength as U } from "./string-utils.js";
8
8
  import r from "../../shared-lib/braze-shared-lib.js";
9
- import { toValidBackendTimeString as Ft } from "./date-utils.js";
10
- import { BRAZE_ACTIONS as P } from "./braze-actions.js";
11
- import { SET_CUSTOM_USER_ATTRIBUTE_STRING as Ut } from "../common/constants.js";
9
+ import { toValidBackendTimeString as kt } from "./date-utils.js";
10
+ import { BRAZE_ACTIONS as _ } from "./braze-actions.js";
11
+ import { SET_CUSTOM_USER_ATTRIBUTE_STRING as $t } from "../common/constants.js";
12
12
  export const CUSTOM_DATA_REGEX = /^[^\x00-\x1F\x22]+$/;
13
13
  export const CUSTOM_ATTRIBUTE_SPECIAL_CHARS_REGEX = /[$.]/;
14
14
  export const CUSTOM_ATTRIBUTE_RESERVED_OPERATORS = [
@@ -32,14 +32,14 @@ export function validateCustomString(t, e, n) {
32
32
  null != t &&
33
33
  "string" == typeof t &&
34
34
  ("" === t || t.match(CUSTOM_DATA_REGEX));
35
- return o || r.D.error(`Cannot ${e} because ${n} "${t}" is invalid.`), o;
35
+ return o || r.j.error(`Cannot ${e} because ${n} "${t}" is invalid.`), o;
36
36
  }
37
37
  export function validateCustomAttributeKey(t) {
38
38
  return (
39
39
  null != t &&
40
40
  t.match(CUSTOM_ATTRIBUTE_SPECIAL_CHARS_REGEX) &&
41
41
  -1 === CUSTOM_ATTRIBUTE_RESERVED_OPERATORS.indexOf(t) &&
42
- r.D.warn("Custom attribute keys cannot contain '$' or '.'"),
42
+ r.j.warn("Custom attribute keys cannot contain '$' or '.'"),
43
43
  validateCustomString(t, "set custom user attribute", "the given key")
44
44
  );
45
45
  }
@@ -53,22 +53,22 @@ export function _validateNestedProperties(t, e, n) {
53
53
  const o = -1 !== n;
54
54
  if (o && n > 50)
55
55
  return (
56
- r.D.error("Nested attributes cannot be more than 50 levels deep."), !1
56
+ r.j.error("Nested attributes cannot be more than 50 levels deep."), !1
57
57
  );
58
58
  const i = o ? n + 1 : -1;
59
59
  if (p(t) && p(e)) {
60
60
  for (let r = 0; r < t.length && r < e.length; r++)
61
61
  if (
62
- (Nt(t[r]) && (e[r] = Ft(t[r])),
62
+ (Nt(t[r]) && (e[r] = kt(t[r])),
63
63
  !_validateNestedProperties(t[r], e[r], i))
64
64
  )
65
65
  return !1;
66
66
  } else {
67
- if (!yt(t)) return validatePropertyType(t);
68
- for (const r of or(t)) {
67
+ if (!Ct(t)) return validatePropertyType(t);
68
+ for (const r of oo(t)) {
69
69
  if (o && !validateCustomAttributeKey(r)) return !1;
70
70
  if (
71
- (Nt(t[r]) && (e[r] = Ft(t[r])),
71
+ (Nt(t[r]) && (e[r] = kt(t[r])),
72
72
  !_validateNestedProperties(t[r], e[r], i))
73
73
  )
74
74
  return !1;
@@ -80,29 +80,29 @@ export function _validateEventPropertyValue(t, e, n, o, i) {
80
80
  let a;
81
81
  return (
82
82
  (a =
83
- yt(t) || p(t)
83
+ Ct(t) || p(t)
84
84
  ? _validateNestedProperties(t, e, i ? 1 : -1)
85
85
  : validatePropertyType(t)),
86
- a || r.D.error(`Cannot ${n} because ${o} "${t}" is invalid.`),
86
+ a || r.j.error(`Cannot ${n} because ${o} "${t}" is invalid.`),
87
87
  a
88
88
  );
89
89
  }
90
90
  export function validateStandardString(t, e, n, o) {
91
91
  const i = "string" == typeof t || (null === t && o);
92
- return i || r.D.error(`Cannot ${e} because ${n} "${t}" is invalid.`), i;
92
+ return i || r.j.error(`Cannot ${e} because ${n} "${t}" is invalid.`), i;
93
93
  }
94
94
  export function validateCustomProperties(t, e, n, o, i) {
95
95
  if ((null == t && (t = {}), "object" != typeof t || p(t)))
96
96
  return (
97
- r.D.error(`${e} requires that ${n} be an object. Ignoring ${i}.`),
97
+ r.j.error(`${e} requires that ${n} be an object. Ignoring ${i}.`),
98
98
  [!1, null]
99
99
  );
100
100
  let a, s;
101
- e === Ut ? ((a = 76800), (s = "75KB")) : ((a = 51200), (s = "50KB"));
101
+ e === $t ? ((a = 76800), (s = "75KB")) : ((a = 51200), (s = "50KB"));
102
102
  const u = JSON.stringify(t);
103
103
  if (U(u) > a)
104
104
  return (
105
- r.D.error(
105
+ r.j.error(
106
106
  `Could not ${o} because ${n} was greater than the max size of ${s}.`
107
107
  ),
108
108
  [!1, null]
@@ -112,27 +112,27 @@ export function validateCustomProperties(t, e, n, o, i) {
112
112
  l = JSON.parse(u);
113
113
  } catch (t) {
114
114
  return (
115
- r.D.error(`Could not ${o} because ${n} did not contain valid JSON.`),
115
+ r.j.error(`Could not ${o} because ${n} did not contain valid JSON.`),
116
116
  [!1, null]
117
117
  );
118
118
  }
119
119
  for (let r in t) {
120
- if (e === Ut && !validateCustomAttributeKey(r)) return [!1, null];
120
+ if (e === $t && !validateCustomAttributeKey(r)) return [!1, null];
121
121
  if (!validateCustomString(r, o, `the ${i} property name`))
122
122
  return [!1, null];
123
123
  const n = t[r];
124
- if (e !== Ut && null == n) {
124
+ if (e !== $t && null == n) {
125
125
  delete t[r], delete l[r];
126
126
  continue;
127
127
  }
128
- Nt(n) && (l[r] = Ft(n));
128
+ Nt(n) && (l[r] = kt(n));
129
129
  if (
130
130
  !_validateEventPropertyValue(
131
131
  n,
132
132
  l[r],
133
133
  o,
134
134
  `the ${i} property "${r}"`,
135
- e === Ut
135
+ e === $t
136
136
  )
137
137
  )
138
138
  return [!1, null];
@@ -143,7 +143,7 @@ export function validateCustomAttributeArrayType(t, e) {
143
143
  let n = !1,
144
144
  o = !1;
145
145
  const i = () => {
146
- r.D.error(
146
+ r.j.error(
147
147
  "Custom attribute arrays must be either string arrays or object arrays."
148
148
  );
149
149
  };
@@ -160,12 +160,12 @@ export function validateCustomAttributeArrayType(t, e) {
160
160
  return [!1, !1];
161
161
  n = !0;
162
162
  } else {
163
- if (!yt(r)) return i(), [!1, !1];
163
+ if (!Ct(r)) return i(), [!1, !1];
164
164
  if (n) return i(), [!1, !1];
165
165
  if (
166
166
  !validateCustomProperties(
167
167
  r,
168
- Ut,
168
+ $t,
169
169
  "attribute value",
170
170
  `set custom user attribute "${t}"`,
171
171
  "custom user attribute"
@@ -182,24 +182,24 @@ export function isValidEmail(t) {
182
182
  );
183
183
  }
184
184
  export function isValidBrazeActionJson(t) {
185
- if (!(P.properties.type in t)) return !1;
186
- switch (t[P.properties.type]) {
187
- case P.types.ue:
188
- if (P.properties.me in t) return !0;
185
+ if (!(_.properties.type in t)) return !1;
186
+ switch (t[_.properties.type]) {
187
+ case _.types.le:
188
+ if (_.properties.ce in t) return !0;
189
189
  break;
190
- case P.types.logCustomEvent:
191
- case P.types.setEmailNotificationSubscriptionType:
192
- case P.types.setPushNotificationSubscriptionType:
193
- case P.types.setCustomUserAttribute:
194
- case P.types.addToSubscriptionGroup:
195
- case P.types.removeFromSubscriptionGroup:
196
- case P.types.addToCustomAttributeArray:
197
- case P.types.removeFromCustomAttributeArray:
198
- case P.types.de:
199
- case P.types.pe:
200
- if (P.properties.fe in t) return !0;
190
+ case _.types.logCustomEvent:
191
+ case _.types.setEmailNotificationSubscriptionType:
192
+ case _.types.setPushNotificationSubscriptionType:
193
+ case _.types.setCustomUserAttribute:
194
+ case _.types.addToSubscriptionGroup:
195
+ case _.types.removeFromSubscriptionGroup:
196
+ case _.types.addToCustomAttributeArray:
197
+ case _.types.removeFromCustomAttributeArray:
198
+ case _.types.de:
199
+ case _.types.pe:
200
+ if (_.properties.me in t) return !0;
201
201
  break;
202
- case P.types.requestPushPermission:
202
+ case _.types.requestPushPermission:
203
203
  return !0;
204
204
  default:
205
205
  return !1;
@@ -209,8 +209,8 @@ export function isValidBrazeActionJson(t) {
209
209
  export function isValidBrazeActionType(t) {
210
210
  let e = !1;
211
211
  return (
212
- Object.keys(P.types).forEach(r => {
213
- P.types[r] !== t.toString() || (e = !0);
212
+ Object.keys(_.types).forEach(r => {
213
+ _.types[r] !== t.toString() || (e = !0);
214
214
  }),
215
215
  e
216
216
  );
@@ -29,7 +29,7 @@ export function _getCurrentUrl() {
29
29
  }
30
30
  export const WindowUtils = {
31
31
  openUri: _openUri,
32
- so: _isPhone,
33
- io: _getOrientation,
34
- bn: _getCurrentUrl
32
+ no: _isPhone,
33
+ ao: _getOrientation,
34
+ jn: _getCurrentUrl
35
35
  };