@braze/web-sdk 5.4.0 → 5.6.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 (183) hide show
  1. package/index.d.ts +109 -7
  2. package/package.json +1 -1
  3. package/shared-lib/encoding-utils.js +1 -1
  4. package/shared-lib/event-types.js +33 -31
  5. package/shared-lib/guid.js +3 -3
  6. package/shared-lib/indexed-db-adapter.js +20 -20
  7. package/shared-lib/logger.js +18 -18
  8. package/shared-lib/supported-options.js +24 -24
  9. package/src/Banner/banner-factory.js +14 -0
  10. package/src/Banner/banner-provider-factory.js +19 -0
  11. package/src/Banner/banner-provider.js +198 -0
  12. package/src/Banner/banner.js +30 -0
  13. package/src/Banner/display/banner-to-html.js +57 -0
  14. package/src/Banner/display/destroy-banner-html.js +7 -0
  15. package/src/Banner/display/detect-banner-impressions.js +28 -0
  16. package/src/Banner/get-all-banners.js +13 -0
  17. package/src/Banner/get-banner.js +19 -0
  18. package/src/Banner/index.js +7 -0
  19. package/src/Banner/log-banner-click.js +22 -0
  20. package/src/Banner/log-banner-impressions.js +31 -0
  21. package/src/Banner/request-banners-refresh.js +35 -0
  22. package/src/Banner/subscribe-to-banners-updates.js +23 -0
  23. package/src/Banner/types.js +1 -0
  24. package/src/Banner/ui/insert-banner.js +24 -0
  25. package/src/Card/card-manager-factory.js +10 -10
  26. package/src/Card/card-manager.js +64 -58
  27. package/src/Card/display/card-display.js +77 -91
  28. package/src/Card/log-card-click.js +6 -6
  29. package/src/Card/log-card-dismissal.js +6 -5
  30. package/src/Card/log-card-impressions.js +11 -11
  31. package/src/Card/models/captioned-image.js +21 -21
  32. package/src/Card/models/card.js +111 -105
  33. package/src/Card/models/classic-card.js +21 -21
  34. package/src/Card/models/control-card.js +11 -11
  35. package/src/Card/models/image-only.js +19 -19
  36. package/src/Card/util/card-factory.js +58 -58
  37. package/src/ContentCards/content-cards-provider-factory.js +14 -14
  38. package/src/ContentCards/content-cards-provider.js +260 -262
  39. package/src/ContentCards/content-cards.js +5 -5
  40. package/src/ContentCards/get-cached-content-cards.js +3 -3
  41. package/src/ContentCards/request-content-cards-refresh.js +4 -4
  42. package/src/ContentCards/subscribe-to-content-cards-updates.js +13 -13
  43. package/src/ContentCards/ui/hide-content-cards.js +7 -7
  44. package/src/ContentCards/ui/show-content-cards.js +52 -52
  45. package/src/ContentCards/ui/toggle-content-cards.js +4 -4
  46. package/src/Core/add-sdk-metadata.js +9 -9
  47. package/src/Core/change-user.js +14 -14
  48. package/src/Core/destroy.js +3 -3
  49. package/src/Core/disable-sdk.js +13 -13
  50. package/src/Core/enable-sdk.js +9 -9
  51. package/src/Core/get-device-id.js +10 -10
  52. package/src/Core/get-user.js +2 -2
  53. package/src/Core/handle-braze-action.js +53 -53
  54. package/src/Core/initialize.js +2 -2
  55. package/src/Core/is-disabled.js +2 -2
  56. package/src/Core/is-initialized.js +2 -2
  57. package/src/Core/log-custom-event.js +24 -24
  58. package/src/Core/log-purchase.js +38 -38
  59. package/src/Core/open-session.js +18 -18
  60. package/src/Core/remove-all-subscriptions.js +2 -2
  61. package/src/Core/remove-subscription.js +3 -3
  62. package/src/Core/request-immediate-data-flush.js +5 -5
  63. package/src/Core/set-logger.js +2 -2
  64. package/src/Core/set-sdk-authentication-signature.js +6 -6
  65. package/src/Core/subscribe-to-sdk-authentication-failures.js +5 -5
  66. package/src/Core/toggle-logging.js +2 -2
  67. package/src/Core/wipe-data.js +10 -10
  68. package/src/FeatureFlags/feature-flag-factory.js +13 -13
  69. package/src/FeatureFlags/feature-flag.js +10 -10
  70. package/src/FeatureFlags/feature-flags-provider-factory.js +13 -14
  71. package/src/FeatureFlags/feature-flags-provider.js +118 -116
  72. package/src/FeatureFlags/get-all-feature-flags.js +10 -10
  73. package/src/FeatureFlags/get-feature-flag.js +9 -9
  74. package/src/FeatureFlags/log-feature-flag-impression.js +18 -18
  75. package/src/FeatureFlags/refresh-feature-flags.js +6 -6
  76. package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +9 -9
  77. package/src/Feed/feed-provider-factory.js +12 -12
  78. package/src/Feed/feed-provider.js +59 -59
  79. package/src/Feed/feed.js +4 -4
  80. package/src/Feed/get-cached-feed.js +3 -3
  81. package/src/Feed/log-feed-displayed.js +5 -5
  82. package/src/Feed/request-feed-refresh.js +3 -3
  83. package/src/Feed/subscribe-to-feed-updates.js +4 -4
  84. package/src/Feed/ui/hide-feed.js +5 -5
  85. package/src/Feed/ui/show-feed.js +53 -53
  86. package/src/Feed/ui/toggle-feed.js +4 -4
  87. package/src/InAppMessage/defer-in-app-message.js +9 -9
  88. package/src/InAppMessage/display/html-message-display-utils.js +18 -164
  89. package/src/InAppMessage/display/html-message-to-html.js +55 -62
  90. package/src/InAppMessage/display/in-app-message-to-html.js +74 -74
  91. package/src/InAppMessage/display/modal-utils.js +17 -17
  92. package/src/InAppMessage/get-deferred-in-app-message.js +2 -2
  93. package/src/InAppMessage/in-app-message-factory.js +61 -61
  94. package/src/InAppMessage/in-app-message-manager-factory.js +9 -9
  95. package/src/InAppMessage/in-app-message-manager.js +158 -156
  96. package/src/InAppMessage/log-in-app-message-button-click.js +16 -16
  97. package/src/InAppMessage/log-in-app-message-click.js +11 -11
  98. package/src/InAppMessage/log-in-app-message-html-click.js +15 -15
  99. package/src/InAppMessage/log-in-app-message-impression.js +6 -6
  100. package/src/InAppMessage/models/control-message.js +15 -8
  101. package/src/InAppMessage/models/full-screen-message.js +34 -34
  102. package/src/InAppMessage/models/html-message.js +23 -23
  103. package/src/InAppMessage/models/in-app-message-button.js +10 -10
  104. package/src/InAppMessage/models/in-app-message.js +155 -155
  105. package/src/InAppMessage/models/modal-message.js +33 -33
  106. package/src/InAppMessage/models/slide-up-message.js +35 -35
  107. package/src/InAppMessage/models/templated-in-app-message.js +8 -8
  108. package/src/InAppMessage/subscribe-to-in-app-message.js +3 -3
  109. package/src/InAppMessage/ui/automatically-show-in-app-messages.js +6 -6
  110. package/src/InAppMessage/ui/show-in-app-message.js +103 -103
  111. package/src/Push/is-push-blocked.js +2 -2
  112. package/src/Push/is-push-permission-granted.js +2 -2
  113. package/src/Push/is-push-supported.js +2 -2
  114. package/src/Push/push-manager-factory.js +25 -25
  115. package/src/Push/push-manager.js +176 -176
  116. package/src/Push/request-push-permission.js +8 -8
  117. package/src/Push/unregister-push.js +4 -4
  118. package/src/Push/utils/push-utils.js +4 -4
  119. package/src/User/user-manager.js +38 -38
  120. package/src/User/user.js +95 -92
  121. package/src/common/base-feed.js +9 -9
  122. package/src/common/base-provider.js +2 -2
  123. package/src/common/constants.js +1 -0
  124. package/src/common/detect-impression.js +18 -0
  125. package/src/common/event-logger.js +22 -22
  126. package/src/common/feed-display.js +53 -53
  127. package/src/index.js +1 -0
  128. package/src/l10n/l10n-manager-factory.js +15 -15
  129. package/src/l10n/l10n-manager.js +4 -4
  130. package/src/managers/auth-manager.js +38 -38
  131. package/src/managers/braze-instance.js +212 -212
  132. package/src/managers/device-manager.js +30 -30
  133. package/src/managers/network-manager.js +231 -232
  134. package/src/managers/server-config-manager.js +99 -83
  135. package/src/managers/session-manager.js +46 -50
  136. package/src/managers/storage-manager-factory.js +13 -13
  137. package/src/managers/storage-manager.js +182 -180
  138. package/src/managers/subscription-manager.js +12 -12
  139. package/src/managers/utils.js +4 -4
  140. package/src/models/backend-errors.js +5 -5
  141. package/src/models/braze-event.js +9 -9
  142. package/src/models/device.js +2 -2
  143. package/src/models/identifier.js +15 -15
  144. package/src/models/push-token.js +10 -10
  145. package/src/models/request-result.js +4 -4
  146. package/src/models/server-config.js +38 -34
  147. package/src/request-controller.js +228 -228
  148. package/src/triggers/models/custom-event-data.js +5 -5
  149. package/src/triggers/models/custom-event-property-data.js +6 -6
  150. package/src/triggers/models/filter-set.js +10 -10
  151. package/src/triggers/models/filter.js +66 -66
  152. package/src/triggers/models/in-app-message-click-data.js +10 -10
  153. package/src/triggers/models/purchase-data.js +2 -2
  154. package/src/triggers/models/purchase-property-data.js +6 -6
  155. package/src/triggers/models/push-click-data.js +5 -5
  156. package/src/triggers/models/trigger-condition.js +46 -46
  157. package/src/triggers/models/trigger-events.js +4 -4
  158. package/src/triggers/models/trigger.js +33 -33
  159. package/src/triggers/triggers-provider-factory.js +16 -16
  160. package/src/triggers/triggers-provider.js +156 -154
  161. package/src/ui/js/attach-css.js +7 -7
  162. package/src/ui/js/banner-css.js +11 -0
  163. package/src/ui/js/feed-css.js +4 -4
  164. package/src/ui/js/iam-css.js +4 -4
  165. package/src/ui/js/index.js +1 -0
  166. package/src/ui/js/load-font-awesome.js +8 -8
  167. package/src/util/base-device-parser.js +9 -9
  168. package/src/util/braze-actions.js +32 -32
  169. package/src/util/browser-detector.js +27 -27
  170. package/src/util/client-hints-parser.js +9 -9
  171. package/src/util/code-utils.js +5 -5
  172. package/src/util/component-utils.js +5 -5
  173. package/src/util/deprecation-utils.js +3 -3
  174. package/src/util/device-constants.js +1 -1
  175. package/src/util/dom-utils.js +13 -13
  176. package/src/util/html-display-utils.js +158 -0
  177. package/src/util/key-codes.js +1 -1
  178. package/src/util/net.js +21 -21
  179. package/src/util/request-header-utils.js +31 -30
  180. package/src/util/string-utils.js +2 -2
  181. package/src/util/user-agent-parser.js +9 -9
  182. package/src/util/validation-utils.js +89 -85
  183. package/src/util/window-utils.js +3 -3
@@ -0,0 +1,158 @@
1
+ import { logger as N } from "../../shared-lib/index.js";
2
+ import { getUser as ao } from "../Core/get-user.js";
3
+ import { BRAZE_MUST_BE_INITIALIZED_ERROR as p } from "../common/constants.js";
4
+ import r from "../managers/braze-instance.js";
5
+ import { keys as y } from "../util/code-utils.js";
6
+ export const buildBrazeBridge = (t, e, o) => {
7
+ const n = { display: {}, web: {} },
8
+ requestPushPermission = function () {
9
+ return function () {
10
+ const t = arguments;
11
+ import("../Push/request-push-permission.js").then((e) => {
12
+ r.nt()
13
+ ? e.requestPushPermission(...Array.prototype.slice.call(t))
14
+ : N.error(p);
15
+ });
16
+ };
17
+ },
18
+ s = {
19
+ requestImmediateDataFlush: function () {
20
+ const t = arguments;
21
+ import("../Core/request-immediate-data-flush.js").then(
22
+ ({ requestImmediateDataFlush: requestImmediateDataFlush }) => {
23
+ r.nt()
24
+ ? requestImmediateDataFlush(...Array.prototype.slice.call(t))
25
+ : N.error(p);
26
+ },
27
+ );
28
+ },
29
+ logCustomEvent: function () {
30
+ const t = arguments;
31
+ import("../Core/log-custom-event.js").then(
32
+ ({ logCustomEvent: logCustomEvent }) => {
33
+ if (!r.nt()) return void N.error(p);
34
+ logCustomEvent(...Array.prototype.slice.call(t));
35
+ },
36
+ );
37
+ },
38
+ logPurchase: function () {
39
+ const t = arguments;
40
+ import("../Core/log-purchase.js").then(
41
+ ({ logPurchase: logPurchase }) => {
42
+ if (!r.nt()) return void N.error(p);
43
+ logPurchase(...Array.prototype.slice.call(t));
44
+ },
45
+ );
46
+ },
47
+ unregisterPush: function () {
48
+ const t = arguments;
49
+ import("../Push/unregister-push.js").then(
50
+ ({ unregisterPush: unregisterPush }) => {
51
+ r.nt()
52
+ ? unregisterPush(...Array.prototype.slice.call(t))
53
+ : N.error(p);
54
+ },
55
+ );
56
+ },
57
+ requestPushPermission: requestPushPermission(),
58
+ changeUser: function () {
59
+ const t = arguments;
60
+ import("../Core/change-user.js").then(({ changeUser: changeUser }) => {
61
+ if (!r.nt()) return void N.error(p);
62
+ changeUser(...Array.prototype.slice.call(t));
63
+ });
64
+ },
65
+ },
66
+ i = function (t) {
67
+ return function () {
68
+ s[t](...Array.prototype.slice.call(arguments));
69
+ };
70
+ };
71
+ for (const t of y(s)) n[t] = i(t);
72
+ const u = [
73
+ "setFirstName",
74
+ "setLastName",
75
+ "setEmail",
76
+ "setGender",
77
+ "setDateOfBirth",
78
+ "setCountry",
79
+ "setHomeCity",
80
+ "setEmailNotificationSubscriptionType",
81
+ "setLanguage",
82
+ "addAlias",
83
+ "setPushNotificationSubscriptionType",
84
+ "setPhoneNumber",
85
+ "setCustomUserAttribute",
86
+ "addToCustomAttributeArray",
87
+ "removeFromCustomAttributeArray",
88
+ "incrementCustomUserAttribute",
89
+ "setCustomLocationAttribute",
90
+ "addToSubscriptionGroup",
91
+ "removeFromSubscriptionGroup",
92
+ ],
93
+ c = function (t) {
94
+ return function () {
95
+ const e = ao();
96
+ e && e[t](...Array.prototype.slice.call(arguments));
97
+ };
98
+ },
99
+ a = {};
100
+ for (let t = 0; t < u.length; t++) a[u[t]] = c(u[t]);
101
+ n.getUser = function () {
102
+ return a;
103
+ };
104
+ const m = { showFeed: e },
105
+ f = function (e) {
106
+ return function () {
107
+ const r = arguments;
108
+ "function" != typeof o
109
+ ? m[e](...Array.prototype.slice.call(r))
110
+ : o(t, function () {
111
+ m[e](...Array.prototype.slice.call(r));
112
+ });
113
+ };
114
+ },
115
+ l = n.display;
116
+ for (const t of y(m)) l[t] = f(t);
117
+ const d = { registerAppboyPushMessages: requestPushPermission() },
118
+ h = function (t) {
119
+ return function () {
120
+ d[t](...Array.prototype.slice.call(arguments));
121
+ };
122
+ },
123
+ g = n.web;
124
+ for (const t of y(d)) g[t] = h(t);
125
+ return n;
126
+ };
127
+ export const applyNonceToDynamicallyCreatedTags = (t, e, r) => {
128
+ const o = `([\\w]+)\\s*=\\s*document.createElement\\(['"]${r}['"]\\)`,
129
+ n = t.match(new RegExp(o));
130
+ if (n) {
131
+ const r = `${n[1]}.setAttribute("nonce", "${e}")`;
132
+ return `${t.slice(0, n.index + n[0].length)};${r};${t.slice(
133
+ n.index + n[0].length,
134
+ )}`;
135
+ }
136
+ return null;
137
+ };
138
+ export const attachHtmlToIframeWithNonce = (t, e, r) => {
139
+ let o = null;
140
+ if (null != r) {
141
+ (o = document.createElement("html")), (o.innerHTML = e || "");
142
+ const t = o.getElementsByTagName("style");
143
+ for (let e = 0; e < t.length; e++) t[e].setAttribute("nonce", r);
144
+ const n = o.getElementsByTagName("script");
145
+ for (let t = 0; t < n.length; t++) {
146
+ n[t].setAttribute("nonce", r),
147
+ (n[t].innerHTML = n[t].innerHTML.replace(
148
+ /<style>/g,
149
+ `<style nonce='${r}'>`,
150
+ ));
151
+ const e = applyNonceToDynamicallyCreatedTags(n[t].innerHTML, r, "script");
152
+ e && (n[t].innerHTML = e);
153
+ const o = applyNonceToDynamicallyCreatedTags(n[t].innerHTML, r, "style");
154
+ o && (n[t].innerHTML = o);
155
+ }
156
+ }
157
+ t.srcdoc = o ? o.innerHTML : e || "";
158
+ };
@@ -1 +1 @@
1
- export const KeyCodes = { Fo: 32, lo: 9, To: 13, mh: 27 };
1
+ export const KeyCodes = { To: 32, yo: 9, _o: 13, _h: 27 };
package/src/util/net.js CHANGED
@@ -1,19 +1,19 @@
1
- import { logger as r } from "../../shared-lib/index.js";
1
+ import { logger as N } from "../../shared-lib/index.js";
2
2
  import Xt from "../models/backend-errors.js";
3
3
  import { getErrorMessage as si } from "./error-utils.js";
4
- const C = {
5
- Gs: (t) => {
4
+ const l = {
5
+ Y: (t) => {
6
6
  let e, o;
7
7
  try {
8
- const n = () => {
9
- r.error("This browser does not have any supported ajax options!");
8
+ const r = () => {
9
+ N.error("This browser does not have any supported ajax options!");
10
10
  };
11
- let s = !1;
12
- if ((window.XMLHttpRequest && (s = !0), !s)) return void n();
11
+ let n = !1;
12
+ if ((window.XMLHttpRequest && (n = !0), !n)) return void r();
13
13
  e = new XMLHttpRequest();
14
- const i = () => {
14
+ const s = () => {
15
15
  "function" == typeof t.error && t.error(e.status),
16
- "function" == typeof t.Ws && t.Ws(!1);
16
+ "function" == typeof t.os && t.os(!1);
17
17
  };
18
18
  (e.onload = () => {
19
19
  let o = !1;
@@ -21,38 +21,38 @@ const C = {
21
21
  if (
22
22
  ((o = (e.status >= 200 && e.status < 300) || 304 === e.status), o)
23
23
  ) {
24
- if ("function" == typeof t.L) {
24
+ if ("function" == typeof t.ss) {
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 ? Xt.Ra : Xt.qa,
31
+ error: "" === e.responseText ? Xt.Tu : Xt.ku,
32
32
  response: e.responseText,
33
33
  };
34
- (0, t.L)(n, r);
34
+ (0, t.ss)(n, r);
35
35
  }
36
- o && t.L(o, r);
36
+ o && t.ss(o, r);
37
37
  }
38
- "function" == typeof t.Ws && t.Ws(!0);
39
- } else i();
38
+ "function" == typeof t.os && t.os(!0);
39
+ } else s();
40
40
  }),
41
41
  (e.onerror = () => {
42
- i();
42
+ s();
43
43
  }),
44
44
  (e.ontimeout = () => {
45
- i();
45
+ s();
46
46
  }),
47
47
  (o = JSON.stringify(t.data)),
48
48
  e.open("POST", t.url, !0),
49
49
  e.setRequestHeader("Content-type", "application/json"),
50
50
  e.setRequestHeader("X-Requested-With", "XMLHttpRequest");
51
- const f = t.headers || [];
52
- for (const t of f) e.setRequestHeader(t[0], t[1]);
51
+ const i = t.headers || [];
52
+ for (const t of i) e.setRequestHeader(t[0], t[1]);
53
53
  e.send(o);
54
54
  } catch (t) {
55
- r.error(`Network request error: ${si(t)}`);
55
+ N.error(`Network request error: ${si(t)}`);
56
56
  }
57
57
  },
58
58
  };
@@ -68,4 +68,4 @@ export const readResponseHeaders = (t) => {
68
68
  (e[r] = n));
69
69
  return e;
70
70
  };
71
- export default C;
71
+ export default l;
@@ -1,47 +1,48 @@
1
1
  import { REQUEST_ATTEMPT_DEFAULT as Ae } from "../common/constants.js";
2
- import { STORAGE_KEYS as o } from "../managers/storage-manager.js";
3
- const D = {
4
- Ps: {
5
- La: "data",
6
- Bs: "content_cards/sync",
7
- bi: "feature_flags/sync",
8
- Ir: "template",
9
- },
10
- Du: (t) => (null == t ? void 0 : t.j(o.C.lE)),
11
- sm: (t) => (null == t ? void 0 : t.j(o.C.SE)),
12
- nm: (t, e) => {
13
- null == t || t.k(o.C.lE, e);
14
- },
15
- um: (t, e) => {
16
- null == t || t.k(o.C.SE, e);
17
- },
18
- Ua: (t, e) => {
2
+ import { STORAGE_KEYS as t } from "../managers/storage-manager.js";
3
+ const h = {
4
+ O: {
5
+ Xu: "data",
6
+ Pi: "content_cards/sync",
7
+ De: "feature_flags/sync",
8
+ sn: "template",
9
+ K: "banners/sync",
10
+ },
11
+ el: (e) => (null == e ? void 0 : e.ps(t.bs.EE)),
12
+ Ac: (e) => (null == e ? void 0 : e.ps(t.bs.lE)),
13
+ Rc: (e, s) => {
14
+ null == e || e.js(t.bs.EE, s);
15
+ },
16
+ qc: (e, s) => {
17
+ null == e || e.js(t.bs.lE, s);
18
+ },
19
+ Eu: (t, e) => {
19
20
  if (!t || !e) return -1;
20
- const s = D.Du(t);
21
+ const s = h.el(t);
21
22
  if (null == s) return -1;
22
23
  const n = s[e];
23
24
  return null == n || isNaN(n) ? -1 : n;
24
25
  },
25
- Ha: (t, e) => {
26
+ Fu: (t, e) => {
26
27
  let s = Ae;
27
28
  if (!t || !e) return s;
28
- const n = D.sm(t);
29
+ const n = h.Ac(t);
29
30
  return null == n ? s : ((s = n[e]), null == s || isNaN(s) ? Ae : s);
30
31
  },
31
- _s: (t, e, s) => {
32
+ W: (t, e, s) => {
32
33
  if (!t || !e) return;
33
- let n = D.Du(t);
34
- null == n && (n = {}), (n[e] = s), D.nm(t, n);
34
+ let n = h.el(t);
35
+ null == n && (n = {}), (n[e] = s), h.Rc(t, n);
35
36
  },
36
- Qs: (t, e, s) => {
37
+ ns: (t, e, s) => {
37
38
  if (!t || !e) return;
38
- let n = D.sm(t);
39
- null == n && (n = {}), (n[e] = s), D.um(t, n);
39
+ let n = h.Ac(t);
40
+ null == n && (n = {}), (n[e] = s), h.qc(t, n);
40
41
  },
41
- Ys: (t, e) => {
42
+ hs: (t, e) => {
42
43
  if (!t || !e) return;
43
- const s = D.Ha(t, e);
44
- D.Qs(t, e, s + 1);
44
+ const s = h.Fu(t, e);
45
+ h.ns(t, e, s + 1);
45
46
  },
46
47
  };
47
- export default D;
48
+ export default h;
@@ -1,4 +1,4 @@
1
- import { logger as r } from "../../shared-lib/index.js";
1
+ import { logger as N } from "../../shared-lib/index.js";
2
2
  export function getByteLength(t) {
3
3
  let e = t.length;
4
4
  for (let n = t.length - 1; n >= 0; n--) {
@@ -17,6 +17,6 @@ export function decodeBrazeActions(t) {
17
17
  const r = new Uint16Array(n.buffer);
18
18
  return String.fromCharCode(...r);
19
19
  } catch (t) {
20
- return r.error("Unable to decode Base64: " + t), null;
20
+ return N.error("Unable to decode Base64: " + t), null;
21
21
  }
22
22
  }
@@ -1,28 +1,28 @@
1
- import ge from "./base-device-parser.js";
2
- import { Browsers as gi, OperatingSystems as Y } from "./device-constants.js";
3
- export default class oi extends ge {
1
+ import Oe from "./base-device-parser.js";
2
+ import { Browsers as gi, OperatingSystems as so } from "./device-constants.js";
3
+ export default class oi extends Oe {
4
4
  constructor() {
5
- super(), (this.fd = oi.hc(navigator.userAgent || ""));
5
+ super(), (this.fd = oi.Bc(navigator.userAgent || ""));
6
6
  }
7
7
  ef() {
8
8
  return this.fd[0] || "Unknown Browser";
9
9
  }
10
- sf() {
10
+ ff() {
11
11
  return this.fd[1] || "Unknown Version";
12
12
  }
13
- Da(r) {
13
+ Ja(r) {
14
14
  for (let n = 0; n < r.length; n++) {
15
15
  const e = r[n].string;
16
- let i = oi.ff(e, r[n]);
16
+ let i = oi.nf(e, r[n]);
17
17
  if (i)
18
18
  return (
19
- i === Y.Pg && navigator.maxTouchPoints > 1 && (i = Y.io),
19
+ i === so.Pg && navigator.maxTouchPoints > 1 && (i = so.ao),
20
20
  Promise.resolve(i)
21
21
  );
22
22
  }
23
23
  return Promise.resolve(navigator.platform);
24
24
  }
25
- static hc(r) {
25
+ static Bc(r) {
26
26
  let n,
27
27
  e =
28
28
  r.match(
@@ -1,13 +1,13 @@
1
1
  import {
2
- isArray as j,
2
+ isArray as w,
3
3
  isDate as Nt,
4
4
  isObject as Ct,
5
- keys as to,
5
+ keys as y,
6
6
  } from "./code-utils.js";
7
- import { getByteLength as O } from "./string-utils.js";
8
- import { logger as r } from "../../shared-lib/index.js";
7
+ import { getByteLength as er } from "./string-utils.js";
8
+ import { logger as N } from "../../shared-lib/index.js";
9
9
  import { toValidBackendTimeString as Bt } from "./date-utils.js";
10
- import { BRAZE_ACTIONS as V } from "./braze-actions.js";
10
+ import { BRAZE_ACTIONS as oo } from "./braze-actions.js";
11
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 = /[$.]/;
@@ -29,19 +29,20 @@ export const CUSTOM_ATTRIBUTES_MAX_SIZE_BYTES = 76800;
29
29
  export const CUSTOM_ATTRIBUTES_MAX_SIZE_STRING = "75KB";
30
30
  export const CUSTOM_ATTRIBUTE_MAX_DEPTH = 50;
31
31
  export const BRAZE_ACTION_URI_REGEX = /^brazeActions:\/\/v\d+\//;
32
- export function validateCustomString(t, e, n) {
33
- const o =
32
+ export const VALID_UTF8_STRING_NO_WHITESPACES_REGEX = /^[^\s]+$/;
33
+ export function validateCustomString(t, e, r) {
34
+ const n =
34
35
  null != t &&
35
36
  "string" == typeof t &&
36
37
  ("" === t || null != t.match(CUSTOM_DATA_REGEX));
37
- return o || r.error(`Cannot ${e} because ${n} "${t}" is invalid.`), o;
38
+ return n || N.error(`Cannot ${e} because ${r} "${t}" is invalid.`), n;
38
39
  }
39
40
  export function validateCustomAttributeKey(t) {
40
41
  return (
41
42
  null != t &&
42
43
  t.match(CUSTOM_ATTRIBUTE_SPECIAL_CHARS_REGEX) &&
43
44
  -1 === CUSTOM_ATTRIBUTE_RESERVED_OPERATORS.indexOf(t) &&
44
- r.warn("Custom attribute keys cannot contain '$' or '.'"),
45
+ N.warn("Custom attribute keys cannot contain '$' or '.'"),
45
46
  validateCustomString(t, "set custom user attribute", "the given key")
46
47
  );
47
48
  }
@@ -51,120 +52,120 @@ export function validatePropertyType(t) {
51
52
  null == t || "number" === e || "boolean" === e || Nt(t) || "string" === e
52
53
  );
53
54
  }
54
- export function _validateNestedProperties(t, e, n) {
55
- const o = -1 !== n;
56
- if (o && n > 50)
57
- return r.error("Nested attributes cannot be more than 50 levels deep."), !1;
58
- const i = o ? n + 1 : -1;
59
- if (j(t) && j(e)) {
55
+ export function _validateNestedProperties(t, e, r) {
56
+ const n = -1 !== r;
57
+ if (n && r > 50)
58
+ return N.error("Nested attributes cannot be more than 50 levels deep."), !1;
59
+ const o = n ? r + 1 : -1;
60
+ if (w(t) && w(e)) {
60
61
  for (let r = 0; r < t.length && r < e.length; r++)
61
62
  if (
62
63
  (Nt(t[r]) && (e[r] = Bt(t[r])),
63
- !_validateNestedProperties(t[r], e[r], i))
64
+ !_validateNestedProperties(t[r], e[r], o))
64
65
  )
65
66
  return !1;
66
67
  } else {
67
68
  if (!Ct(t)) return validatePropertyType(t);
68
- for (const r of to(t)) {
69
- const n = t[r];
70
- if (o && !validateCustomAttributeKey(r)) return !1;
71
- if (Nt(n)) {
72
- e[r] = Bt(n);
69
+ for (const r of y(t)) {
70
+ const i = t[r];
71
+ if (n && !validateCustomAttributeKey(r)) return !1;
72
+ if (Nt(i)) {
73
+ e[r] = Bt(i);
73
74
  }
74
- if (!_validateNestedProperties(n, e[r], i)) return !1;
75
+ if (!_validateNestedProperties(i, e[r], o)) return !1;
75
76
  }
76
77
  }
77
78
  return !0;
78
79
  }
79
- export function _validateEventPropertyValue(t, e, n, o, i) {
80
- let a;
80
+ export function _validateEventPropertyValue(t, e, r, n, o) {
81
+ let i;
81
82
  return (
82
- (a =
83
- Ct(t) || j(t)
84
- ? _validateNestedProperties(t, e, i ? 1 : -1)
83
+ (i =
84
+ Ct(t) || w(t)
85
+ ? _validateNestedProperties(t, e, o ? 1 : -1)
85
86
  : validatePropertyType(t)),
86
- a || r.error(`Cannot ${n} because ${o} "${t}" is invalid.`),
87
- a
87
+ i || N.error(`Cannot ${r} because ${n} "${t}" is invalid.`),
88
+ i
88
89
  );
89
90
  }
90
- export function validateStandardString(t, e, n, o = !1) {
91
- const i = "string" == typeof t || (null === t && o);
92
- return i || r.error(`Cannot ${e} because ${n} "${t}" is invalid.`), i;
91
+ export function validateStandardString(t, e, r, n = !1) {
92
+ const o = "string" == typeof t || (null === t && n);
93
+ return o || N.error(`Cannot ${e} because ${r} "${t}" is invalid.`), o;
93
94
  }
94
- export function validateCustomProperties(t, e, n, o, i) {
95
- if ((null == t && (t = {}), "object" != typeof t || j(t)))
95
+ export function validateCustomProperties(t, e, r, n, o) {
96
+ if ((null == t && (t = {}), "object" != typeof t || w(t)))
96
97
  return (
97
- r.error(`${e} requires that ${n} be an object. Ignoring ${i}.`),
98
+ N.error(`${e} requires that ${r} be an object. Ignoring ${o}.`),
98
99
  [!1, null]
99
100
  );
100
- let a, s;
101
- e === $t ? ((a = 76800), (s = "75KB")) : ((a = 51200), (s = "50KB"));
102
- const u = JSON.stringify(t);
103
- if (O(u) > a)
101
+ let i, a;
102
+ e === $t ? ((i = 76800), (a = "75KB")) : ((i = 51200), (a = "50KB"));
103
+ const s = JSON.stringify(t);
104
+ if (er(s) > i)
104
105
  return (
105
- r.error(
106
- `Could not ${o} because ${n} was greater than the max size of ${s}.`,
106
+ N.error(
107
+ `Could not ${n} because ${r} was greater than the max size of ${a}.`,
107
108
  ),
108
109
  [!1, null]
109
110
  );
110
- let l;
111
+ let u;
111
112
  try {
112
- l = JSON.parse(u);
113
+ u = JSON.parse(s);
113
114
  } catch (t) {
114
115
  return (
115
- r.error(`Could not ${o} because ${n} did not contain valid JSON.`),
116
+ N.error(`Could not ${n} because ${r} did not contain valid JSON.`),
116
117
  [!1, null]
117
118
  );
118
119
  }
119
120
  for (const r in t) {
120
121
  if (e === $t && !validateCustomAttributeKey(r)) return [!1, null];
121
- if (!validateCustomString(r, o, `the ${i} property name`))
122
+ if (!validateCustomString(r, n, `the ${o} property name`))
122
123
  return [!1, null];
123
- const n = t[r];
124
- if (e !== $t && null == n) {
125
- delete t[r], delete l[r];
124
+ const i = t[r];
125
+ if (e !== $t && null == i) {
126
+ delete t[r], delete u[r];
126
127
  continue;
127
128
  }
128
- Nt(n) && (l[r] = Bt(n));
129
+ Nt(i) && (u[r] = Bt(i));
129
130
  if (
130
131
  !_validateEventPropertyValue(
132
+ i,
133
+ u[r],
131
134
  n,
132
- l[r],
133
- o,
134
- `the ${i} property "${r}"`,
135
+ `the ${o} property "${r}"`,
135
136
  e === $t,
136
137
  )
137
138
  )
138
139
  return [!1, null];
139
140
  }
140
- return [!0, l];
141
+ return [!0, u];
141
142
  }
142
143
  export function validateCustomAttributeArrayType(t, e) {
143
- let n = !1,
144
- o = !1;
145
- const i = () => {
146
- r.error(
144
+ let r = !1,
145
+ n = !1;
146
+ const o = () => {
147
+ N.error(
147
148
  "Custom attribute arrays must be either string arrays or object arrays.",
148
149
  );
149
150
  };
150
- for (const r of e)
151
- if ("string" == typeof r) {
152
- if (o) return i(), [!1, !1];
151
+ for (const i of e)
152
+ if ("string" == typeof i) {
153
+ if (n) return o(), [!1, !1];
153
154
  if (
154
155
  !validateCustomString(
155
- r,
156
+ i,
156
157
  `set custom user attribute "${t}"`,
157
158
  "the element in the given array",
158
159
  )
159
160
  )
160
161
  return [!1, !1];
161
- n = !0;
162
+ r = !0;
162
163
  } else {
163
- if (!Ct(r)) return i(), [!1, !1];
164
- if (n) return i(), [!1, !1];
164
+ if (!Ct(i)) return o(), [!1, !1];
165
+ if (r) return o(), [!1, !1];
165
166
  if (
166
167
  !validateCustomProperties(
167
- r,
168
+ i,
168
169
  $t,
169
170
  "attribute value",
170
171
  `set custom user attribute "${t}"`,
@@ -172,9 +173,9 @@ export function validateCustomAttributeArrayType(t, e) {
172
173
  )
173
174
  )
174
175
  return [!1, !1];
175
- o = !0;
176
+ n = !0;
176
177
  }
177
- return [n, o];
178
+ return [r, n];
178
179
  }
179
180
  export function isValidEmail(t) {
180
181
  return (
@@ -182,24 +183,24 @@ export function isValidEmail(t) {
182
183
  );
183
184
  }
184
185
  export function isValidBrazeActionJson(t) {
185
- if (!(V.properties.type in t)) return !1;
186
- switch (t[V.properties.type]) {
187
- case V.types.ro:
188
- if (V.properties.oo in t) return !0;
186
+ if (!(oo.properties.type in t)) return !1;
187
+ switch (t[oo.properties.type]) {
188
+ case oo.types.io:
189
+ if (oo.properties.eo in t) return !0;
189
190
  break;
190
- case V.types.logCustomEvent:
191
- case V.types.setEmailNotificationSubscriptionType:
192
- case V.types.setPushNotificationSubscriptionType:
193
- case V.types.setCustomUserAttribute:
194
- case V.types.addToSubscriptionGroup:
195
- case V.types.removeFromSubscriptionGroup:
196
- case V.types.addToCustomAttributeArray:
197
- case V.types.removeFromCustomAttributeArray:
198
- case V.types.no:
199
- case V.types.ao:
200
- if (V.properties.eo in t) return !0;
191
+ case oo.types.logCustomEvent:
192
+ case oo.types.setEmailNotificationSubscriptionType:
193
+ case oo.types.setPushNotificationSubscriptionType:
194
+ case oo.types.setCustomUserAttribute:
195
+ case oo.types.addToSubscriptionGroup:
196
+ case oo.types.removeFromSubscriptionGroup:
197
+ case oo.types.addToCustomAttributeArray:
198
+ case oo.types.removeFromCustomAttributeArray:
199
+ case oo.types.co:
200
+ case oo.types.mo:
201
+ if (oo.properties.so in t) return !0;
201
202
  break;
202
- case V.types.requestPushPermission:
203
+ case oo.types.requestPushPermission:
203
204
  return !0;
204
205
  default:
205
206
  return !1;
@@ -209,9 +210,12 @@ export function isValidBrazeActionJson(t) {
209
210
  export function isValidBrazeActionType(t) {
210
211
  let e = !1;
211
212
  return (
212
- Object.keys(V.types).forEach((r) => {
213
- V.types[r] !== t.toString() || (e = !0);
213
+ Object.keys(oo.types).forEach((r) => {
214
+ oo.types[r] !== t.toString() || (e = !0);
214
215
  }),
215
216
  e
216
217
  );
217
218
  }
219
+ export function isValidBannerPlacementId(t) {
220
+ return VALID_UTF8_STRING_NO_WHITESPACES_REGEX.test(t);
221
+ }