@braze/web-sdk 4.9.0 → 4.10.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 (202) hide show
  1. package/index.d.ts +2296 -2235
  2. package/package.json +1 -1
  3. package/shared-lib/braze-shared-lib.js +1 -8
  4. package/shared-lib/encoding-utils.js +1 -12
  5. package/shared-lib/event-types.js +1 -34
  6. package/shared-lib/guid.js +1 -10
  7. package/shared-lib/indexed-db-adapter.js +1 -352
  8. package/shared-lib/logger.js +1 -38
  9. package/shared-lib/supported-options.js +1 -26
  10. package/shared-lib/types.js +1 -1
  11. package/src/Card/card-manager-factory.js +1 -14
  12. package/src/Card/card-manager.js +1 -78
  13. package/src/Card/display/card-display.js +1 -138
  14. package/src/Card/index.js +1 -6
  15. package/src/Card/log-card-click.js +1 -11
  16. package/src/Card/log-card-dismissal.js +1 -11
  17. package/src/Card/log-card-impressions.js +1 -13
  18. package/src/Card/log-content-card-click.js +1 -4
  19. package/src/Card/log-content-card-impressions.js +1 -4
  20. package/src/Card/models/banner.js +1 -31
  21. package/src/Card/models/captioned-image.js +1 -33
  22. package/src/Card/models/card.js +1 -196
  23. package/src/Card/models/classic-card.js +1 -32
  24. package/src/Card/models/control-card.js +1 -23
  25. package/src/Card/models/image-only.js +1 -32
  26. package/src/Card/models/index.js +1 -6
  27. package/src/Card/types.js +1 -1
  28. package/src/Card/util/card-factory.js +1 -104
  29. package/src/ContentCards/content-cards-provider-factory.js +1 -20
  30. package/src/ContentCards/content-cards-provider.js +1 -391
  31. package/src/ContentCards/content-cards.js +1 -24
  32. package/src/ContentCards/get-cached-content-cards.js +1 -5
  33. package/src/ContentCards/index.js +1 -8
  34. package/src/ContentCards/log-content-cards-displayed.js +1 -5
  35. package/src/ContentCards/request-content-cards-refresh.js +1 -5
  36. package/src/ContentCards/subscribe-to-content-cards-updates.js +1 -17
  37. package/src/ContentCards/types.js +1 -1
  38. package/src/ContentCards/ui/hide-content-cards.js +1 -8
  39. package/src/ContentCards/ui/show-content-cards.js +1 -77
  40. package/src/ContentCards/ui/toggle-content-cards.js +1 -8
  41. package/src/Core/add-sdk-metadata.js +1 -26
  42. package/src/Core/braze-sdk-metadata.js +1 -10
  43. package/src/Core/change-user.js +1 -17
  44. package/src/Core/destroy.js +1 -5
  45. package/src/Core/device-properties.js +1 -9
  46. package/src/Core/disable-sdk.js +1 -15
  47. package/src/Core/enable-sdk.js +1 -11
  48. package/src/Core/get-device-id.js +1 -11
  49. package/src/Core/get-user.js +1 -4
  50. package/src/Core/handle-braze-action.js +1 -87
  51. package/src/Core/index.js +1 -23
  52. package/src/Core/initialize.js +1 -4
  53. package/src/Core/is-disabled.js +1 -4
  54. package/src/Core/log-custom-event.js +1 -38
  55. package/src/Core/log-purchase.js +1 -245
  56. package/src/Core/open-session.js +1 -25
  57. package/src/Core/remove-all-subscriptions.js +1 -4
  58. package/src/Core/remove-subscription.js +1 -4
  59. package/src/Core/request-immediate-data-flush.js +1 -6
  60. package/src/Core/set-logger.js +1 -4
  61. package/src/Core/set-sdk-authentication-signature.js +1 -8
  62. package/src/Core/subscribe-to-sdk-authentication-failures.js +1 -6
  63. package/src/Core/toggle-logging.js +1 -4
  64. package/src/Core/types.js +1 -1
  65. package/src/Core/wipe-data.js +1 -16
  66. package/src/FeatureFlags/feature-flag-factory.js +1 -24
  67. package/src/FeatureFlags/feature-flag.js +1 -64
  68. package/src/FeatureFlags/feature-flags-provider-factory.js +1 -19
  69. package/src/FeatureFlags/feature-flags-provider.js +1 -145
  70. package/src/FeatureFlags/get-all-feature-flags.js +1 -12
  71. package/src/FeatureFlags/get-feature-flag.js +1 -12
  72. package/src/FeatureFlags/index.js +1 -6
  73. package/src/FeatureFlags/log-feature-flag-impression.js +1 -23
  74. package/src/FeatureFlags/refresh-feature-flags.js +1 -9
  75. package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +1 -9
  76. package/src/FeatureFlags/types.js +1 -1
  77. package/src/Feed/feed-provider-factory.js +1 -18
  78. package/src/Feed/feed-provider.js +1 -90
  79. package/src/Feed/feed.js +1 -20
  80. package/src/Feed/get-cached-feed.js +1 -5
  81. package/src/Feed/index.js +1 -8
  82. package/src/Feed/log-feed-displayed.js +1 -7
  83. package/src/Feed/request-feed-refresh.js +1 -5
  84. package/src/Feed/subscribe-to-feed-updates.js +1 -5
  85. package/src/Feed/types.js +1 -1
  86. package/src/Feed/ui/hide-feed.js +1 -7
  87. package/src/Feed/ui/show-feed.js +1 -96
  88. package/src/Feed/ui/toggle-feed.js +1 -8
  89. package/src/InAppMessage/defer-in-app-message.js +1 -13
  90. package/src/InAppMessage/display/get-animation-effect.js +1 -19
  91. package/src/InAppMessage/display/html-message-to-html.js +1 -244
  92. package/src/InAppMessage/display/in-app-message-to-html.js +1 -188
  93. package/src/InAppMessage/display/modal-utils.js +1 -73
  94. package/src/InAppMessage/get-deferred-in-app-message.js +1 -5
  95. package/src/InAppMessage/in-app-message-factory.js +1 -166
  96. package/src/InAppMessage/in-app-message-manager-factory.js +1 -16
  97. package/src/InAppMessage/in-app-message-manager.js +1 -248
  98. package/src/InAppMessage/index.js +1 -16
  99. package/src/InAppMessage/log-in-app-message-button-click.js +1 -27
  100. package/src/InAppMessage/log-in-app-message-click.js +1 -19
  101. package/src/InAppMessage/log-in-app-message-html-click.js +1 -23
  102. package/src/InAppMessage/log-in-app-message-impression.js +1 -13
  103. package/src/InAppMessage/models/control-message.js +1 -11
  104. package/src/InAppMessage/models/full-screen-message.js +1 -105
  105. package/src/InAppMessage/models/html-message.js +1 -68
  106. package/src/InAppMessage/models/in-app-message-button.js +1 -47
  107. package/src/InAppMessage/models/in-app-message.js +1 -382
  108. package/src/InAppMessage/models/modal-message.js +1 -101
  109. package/src/InAppMessage/models/slide-up-message.js +1 -84
  110. package/src/InAppMessage/models/templated-in-app-message.js +1 -19
  111. package/src/InAppMessage/subscribe-to-in-app-message.js +1 -10
  112. package/src/InAppMessage/types.js +1 -1
  113. package/src/InAppMessage/ui/automatically-show-in-app-messages.js +1 -15
  114. package/src/InAppMessage/ui/show-in-app-message.js +1 -181
  115. package/src/InAppMessage/utils/in-app-message-utils.js +1 -1
  116. package/src/Push/index.js +1 -5
  117. package/src/Push/is-push-blocked.js +1 -5
  118. package/src/Push/is-push-permission-granted.js +1 -5
  119. package/src/Push/is-push-supported.js +1 -5
  120. package/src/Push/push-manager-factory.js +1 -30
  121. package/src/Push/push-manager.js +1 -387
  122. package/src/Push/request-push-permission.js +1 -9
  123. package/src/Push/types.js +1 -1
  124. package/src/Push/unregister-push.js +1 -5
  125. package/src/Push/utils/push-utils.js +1 -36
  126. package/src/User/index.js +1 -1
  127. package/src/User/types.js +1 -1
  128. package/src/User/user-manager.js +1 -73
  129. package/src/User/user.js +1 -301
  130. package/src/common/base-feed.js +1 -28
  131. package/src/common/base-provider.js +1 -6
  132. package/src/common/constants.js +1 -14
  133. package/src/common/event-logger.js +1 -31
  134. package/src/common/feed-display.js +1 -210
  135. package/src/common/translations.js +1 -148
  136. package/src/common/types.js +1 -1
  137. package/src/index.js +1 -9
  138. package/src/l10n/l10n-manager-factory.js +1 -22
  139. package/src/l10n/l10n-manager.js +1 -25
  140. package/src/l10n/types.js +1 -1
  141. package/src/managers/auth-manager.js +1 -51
  142. package/src/managers/braze-instance.js +1 -329
  143. package/src/managers/device-manager.js +1 -85
  144. package/src/managers/network-manager.js +1 -253
  145. package/src/managers/server-config-manager.js +1 -108
  146. package/src/managers/session-manager.js +1 -75
  147. package/src/managers/storage-manager-factory.js +1 -42
  148. package/src/managers/storage-manager.js +1 -419
  149. package/src/managers/subscription-manager.js +1 -28
  150. package/src/managers/types.js +1 -1
  151. package/src/models/backend-errors.js +1 -8
  152. package/src/models/braze-event.js +1 -47
  153. package/src/models/braze-sdk-metadata.js +1 -10
  154. package/src/models/device.js +1 -18
  155. package/src/models/identifier.js +1 -19
  156. package/src/models/push-token.js +1 -27
  157. package/src/models/request-result.js +1 -8
  158. package/src/models/server-config.js +1 -48
  159. package/src/models/types.js +1 -1
  160. package/src/request-controller.js +1 -307
  161. package/src/triggers/models/custom-event-data.js +1 -14
  162. package/src/triggers/models/custom-event-property-data.js +1 -21
  163. package/src/triggers/models/filter-set.js +1 -55
  164. package/src/triggers/models/filter.js +1 -102
  165. package/src/triggers/models/in-app-message-click-data.js +1 -25
  166. package/src/triggers/models/purchase-data.js +1 -14
  167. package/src/triggers/models/purchase-property-data.js +1 -21
  168. package/src/triggers/models/push-click-data.js +1 -15
  169. package/src/triggers/models/trigger-condition.js +1 -105
  170. package/src/triggers/models/trigger-events.js +1 -8
  171. package/src/triggers/models/trigger.js +1 -122
  172. package/src/triggers/triggers-provider-factory.js +1 -34
  173. package/src/triggers/triggers-provider.js +1 -326
  174. package/src/triggers/types.js +1 -1
  175. package/src/types.js +1 -1
  176. package/src/ui/js/attach-css.js +1 -13
  177. package/src/ui/js/feed-css.js +1 -12
  178. package/src/ui/js/iam-css.js +1 -12
  179. package/src/ui/js/index.js +1 -3
  180. package/src/ui/js/load-font-awesome.js +1 -13
  181. package/src/util/base-device-parser.js +1 -14
  182. package/src/util/braze-actions.js +1 -84
  183. package/src/util/browser-detector.js +1 -84
  184. package/src/util/client-hints-parser.js +1 -66
  185. package/src/util/code-utils.js +1 -100
  186. package/src/util/color-utils.js +1 -29
  187. package/src/util/component-utils.js +1 -26
  188. package/src/util/date-utils.js +1 -28
  189. package/src/util/deprecation-utils.js +1 -5
  190. package/src/util/device-constants.js +1 -14
  191. package/src/util/dom-utils.js +1 -91
  192. package/src/util/error-utils.js +1 -2
  193. package/src/util/key-codes.js +1 -1
  194. package/src/util/math.js +1 -5
  195. package/src/util/net.js +1 -71
  196. package/src/util/request-header-utils.js +1 -46
  197. package/src/util/string-utils.js +1 -22
  198. package/src/util/types.js +1 -1
  199. package/src/util/url-utils.js +1 -20
  200. package/src/util/user-agent-parser.js +1 -85
  201. package/src/util/validation-utils.js +1 -217
  202. package/src/util/window-utils.js +1 -34
@@ -1,91 +1 @@
1
- import r from "../../shared-lib/braze-shared-lib.js";
2
- import { getErrorMessage as ei } from "./error-utils.js";
3
- export function _isInView(t, n = !1, e = !1, s = !1) {
4
- if (null == t) return !1;
5
- (n = n || !1), (e = e || !1);
6
- const i = t.getBoundingClientRect();
7
- return (
8
- null != i &&
9
- ((i.top >= 0 &&
10
- i.top <= (window.innerHeight || document.documentElement.clientHeight)) ||
11
- !n) &&
12
- (i.left >= 0 || !s) &&
13
- ((i.bottom >= 0 &&
14
- i.bottom <=
15
- (window.innerHeight || document.documentElement.clientHeight)) ||
16
- !e) &&
17
- (i.right <= (window.innerWidth || document.documentElement.clientWidth) ||
18
- !s)
19
- );
20
- }
21
- export const DOMUtils = { Wu: null, no: _isInView };
22
- export const DIRECTIONS = { Oe: "up", Qe: "down", W: "left", X: "right" };
23
- export function supportsPassive() {
24
- if (null == DOMUtils.Wu) {
25
- DOMUtils.Wu = !1;
26
- try {
27
- const t = Object.defineProperty({}, "passive", {
28
- get: () => {
29
- DOMUtils.Wu = !0;
30
- },
31
- });
32
- window.addEventListener("testPassive", () => {}, t),
33
- window.removeEventListener("testPassive", () => {}, t);
34
- } catch (t) {
35
- r.j.error(ei(t));
36
- }
37
- }
38
- return DOMUtils.Wu;
39
- }
40
- export function addPassiveEventListener(t, n, e = () => {}) {
41
- t.addEventListener(n, e, !!supportsPassive() && { passive: !0 });
42
- }
43
- export function topIsInView(t) {
44
- return DOMUtils.no(t, !0, !1, !1);
45
- }
46
- export function bottomIsInView(t) {
47
- return DOMUtils.no(t, !1, !0, !1);
48
- }
49
- export function clickElement(t) {
50
- if (t.onclick) {
51
- const n = document.createEvent("MouseEvents");
52
- n.initEvent("click", !0, !0), t.onclick.apply(t, [n]);
53
- }
54
- }
55
- export function detectSwipe(t, n, e) {
56
- let s = null,
57
- i = null;
58
- addPassiveEventListener(t, "touchstart", (t) => {
59
- (s = t.touches[0].clientX), (i = t.touches[0].clientY);
60
- }),
61
- addPassiveEventListener(t, "touchmove", (o) => {
62
- if (null == s || null == i) return;
63
- const l = s - o.touches[0].clientX,
64
- r = i - o.touches[0].clientY;
65
- Math.abs(l) > Math.abs(r) && Math.abs(l) >= 25
66
- ? (((l > 0 && n === DIRECTIONS.W) || (l < 0 && n === DIRECTIONS.X)) &&
67
- e(o),
68
- (s = null),
69
- (i = null))
70
- : Math.abs(r) >= 25 &&
71
- (((r > 0 &&
72
- n === DIRECTIONS.Oe &&
73
- t.scrollTop === t.scrollHeight - t.offsetHeight) ||
74
- (r < 0 && n === DIRECTIONS.Qe && 0 === t.scrollTop)) &&
75
- e(o),
76
- (s = null),
77
- (i = null));
78
- });
79
- }
80
- export function buildSvg(t, n, e) {
81
- const s = "http://www.w3.org/2000/svg",
82
- i = document.createElementNS(s, "svg");
83
- i.setAttribute("viewBox", t), i.setAttribute("xmlns", s);
84
- const o = document.createElementNS(s, "path");
85
- return (
86
- o.setAttribute("d", n),
87
- null != e && o.setAttribute("fill", e),
88
- i.appendChild(o),
89
- i
90
- );
91
- }
1
+ import r from"../../shared-lib/braze-shared-lib.js";import{getErrorMessage as ei}from"./error-utils.js";export function _isInView(t,n=!1,e=!1,s=!1){if(null==t)return!1;n=n||!1,e=e||!1;const i=t.getBoundingClientRect();return null!=i&&((i.top>=0&&i.top<=(window.innerHeight||document.documentElement.clientHeight)||!n)&&(i.left>=0||!s)&&(i.bottom>=0&&i.bottom<=(window.innerHeight||document.documentElement.clientHeight)||!e)&&(i.right<=(window.innerWidth||document.documentElement.clientWidth)||!s))}export const DOMUtils={lc:null,no:_isInView};export const DIRECTIONS={Oe:"up",Qe:"down",W:"left",X:"right"};export function supportsPassive(){if(null==DOMUtils.lc){DOMUtils.lc=!1;try{const t=Object.defineProperty({},"passive",{get:()=>{DOMUtils.lc=!0}});window.addEventListener("testPassive",(()=>{}),t),window.removeEventListener("testPassive",(()=>{}),t)}catch(t){r.j.error(ei(t))}}return DOMUtils.lc}export function addPassiveEventListener(t,n,e=(()=>{})){t.addEventListener(n,e,!!supportsPassive()&&{passive:!0})}export function topIsInView(t){return DOMUtils.no(t,!0,!1,!1)}export function bottomIsInView(t){return DOMUtils.no(t,!1,!0,!1)}export function clickElement(t){if(t.onclick){const n=document.createEvent("MouseEvents");n.initEvent("click",!0,!0),t.onclick.apply(t,[n])}}export function detectSwipe(t,n,e){let s=null,i=null;addPassiveEventListener(t,"touchstart",(t=>{s=t.touches[0].clientX,i=t.touches[0].clientY})),addPassiveEventListener(t,"touchmove",(o=>{if(null==s||null==i)return;const l=s-o.touches[0].clientX,r=i-o.touches[0].clientY;Math.abs(l)>Math.abs(r)&&Math.abs(l)>=25?((l>0&&n===DIRECTIONS.W||l<0&&n===DIRECTIONS.X)&&e(o),s=null,i=null):Math.abs(r)>=25&&((r>0&&n===DIRECTIONS.Oe&&t.scrollTop===t.scrollHeight-t.offsetHeight||r<0&&n===DIRECTIONS.Qe&&0===t.scrollTop)&&e(o),s=null,i=null)}))}export function buildSvg(t,n,e){const s="http://www.w3.org/2000/svg",i=document.createElementNS(s,"svg");i.setAttribute("viewBox",t),i.setAttribute("xmlns",s);const o=document.createElementNS(s,"path");return o.setAttribute("d",n),null!=e&&o.setAttribute("fill",e),i.appendChild(o),i}
@@ -1,2 +1 @@
1
- export const getErrorMessage = (r) =>
2
- r instanceof Error ? r.message : String(r);
1
+ export const getErrorMessage=r=>r instanceof Error?r.message:String(r);
@@ -1 +1 @@
1
- export const KeyCodes = { Fo: 32, oo: 9, To: 13, _h: 27 };
1
+ export const KeyCodes={Fo:32,oo:9,To:13,_h:27};
package/src/util/math.js CHANGED
@@ -1,5 +1 @@
1
- export const randomInclusive = (t, a) => (
2
- (t = Math.ceil(t)),
3
- (a = Math.floor(a)),
4
- Math.floor(Math.random() * (a - t + 1)) + t
5
- );
1
+ export const randomInclusive=(t,a)=>(t=Math.ceil(t),a=Math.floor(a),Math.floor(Math.random()*(a-t+1))+t);
package/src/util/net.js CHANGED
@@ -1,71 +1 @@
1
- import r from "../../shared-lib/braze-shared-lib.js";
2
- import qt from "../models/backend-errors.js";
3
- import { getErrorMessage as ei } from "./error-utils.js";
4
- const C = {
5
- Xs: (t) => {
6
- let e, o;
7
- try {
8
- const s = () => {
9
- r.j.error("This browser does not have any supported ajax options!");
10
- };
11
- let n = !1;
12
- if ((window.XMLHttpRequest && (n = !0), !n)) return void s();
13
- e = new XMLHttpRequest();
14
- const i = () => {
15
- "function" == typeof t.error && t.error(e.status),
16
- "function" == typeof t.ei && t.ei(!1);
17
- };
18
- (e.onload = () => {
19
- let o = !1;
20
- if (4 === e.readyState)
21
- if (
22
- ((o = (e.status >= 200 && e.status < 300) || 304 === e.status), o)
23
- ) {
24
- if ("function" == typeof t.O) {
25
- let o, r;
26
- try {
27
- (o = JSON.parse(e.responseText)),
28
- (r = e.getAllResponseHeaders());
29
- } catch (o) {
30
- const s = {
31
- error: "" === e.responseText ? qt.Na : qt.Ha,
32
- response: e.responseText,
33
- };
34
- (0, t.O)(s, r);
35
- }
36
- o && t.O(o, r);
37
- }
38
- "function" == typeof t.ei && t.ei(!0);
39
- } else i();
40
- }),
41
- (e.onerror = () => {
42
- i();
43
- }),
44
- (e.ontimeout = () => {
45
- i();
46
- }),
47
- (o = JSON.stringify(t.data)),
48
- e.open("POST", t.url, !0),
49
- e.setRequestHeader("Content-type", "application/json"),
50
- e.setRequestHeader("X-Requested-With", "XMLHttpRequest");
51
- const f = t.headers || [];
52
- for (const t of f) e.setRequestHeader(t[0], t[1]);
53
- e.send(o);
54
- } catch (t) {
55
- r.j.error(`Network request error: ${ei(t)}`);
56
- }
57
- },
58
- };
59
- export const readResponseHeaders = (t) => {
60
- const e = {},
61
- o = t.toString().split("\r\n");
62
- if (!o) return e;
63
- let r, s;
64
- for (const t of o)
65
- t &&
66
- ((r = t.slice(0, t.indexOf(":")).toLowerCase().trim()),
67
- (s = t.slice(t.indexOf(":") + 1).trim()),
68
- (e[r] = s));
69
- return e;
70
- };
71
- export default C;
1
+ import r from"../../shared-lib/braze-shared-lib.js";import qt from"../models/backend-errors.js";import{getErrorMessage as ei}from"./error-utils.js";const C={Xs:t=>{let e,o;try{const s=()=>{r.j.error("This browser does not have any supported ajax options!")};let n=!1;if(window.XMLHttpRequest&&(n=!0),!n)return void s();e=new XMLHttpRequest;const i=()=>{"function"==typeof t.error&&t.error(e.status),"function"==typeof t.ei&&t.ei(!1)};e.onload=()=>{let o=!1;if(4===e.readyState)if(o=e.status>=200&&e.status<300||304===e.status,o){if("function"==typeof t.O){let o,r;try{o=JSON.parse(e.responseText),r=e.getAllResponseHeaders()}catch(o){const s={error:""===e.responseText?qt.Vh:qt.Zh,response:e.responseText};(0,t.O)(s,r)}o&&t.O(o,r)}"function"==typeof t.ei&&t.ei(!0)}else i()},e.onerror=()=>{i()},e.ontimeout=()=>{i()},o=JSON.stringify(t.data),e.open("POST",t.url,!0),e.setRequestHeader("Content-type","application/json"),e.setRequestHeader("X-Requested-With","XMLHttpRequest");const f=t.headers||[];for(const t of f)e.setRequestHeader(t[0],t[1]);e.send(o)}catch(t){r.j.error(`Network request error: ${ei(t)}`)}}};export const readResponseHeaders=t=>{const e={},o=t.toString().split("\r\n");if(!o)return e;let r,s;for(const t of o)t&&(r=t.slice(0,t.indexOf(":")).toLowerCase().trim(),s=t.slice(t.indexOf(":")+1).trim(),e[r]=s);return e};export default C;
@@ -1,46 +1 @@
1
- import { REQUEST_ATTEMPT_DEFAULT as Ae } from "../common/constants.js";
2
- import { STORAGE_KEYS as i } from "../managers/storage-manager.js";
3
- const T = {
4
- Os: { Ja: "d", Ks: "cc", Si: "ff", Lr: "t" },
5
- Qu: (e) => {
6
- if (e) return e.v(i.k.EE);
7
- },
8
- Xu: (e) => {
9
- if (e) return e.v(i.k.lE);
10
- },
11
- Yu: (e, t) => {
12
- e && e.D(i.k.EE, t);
13
- },
14
- Zu: (e, t) => {
15
- e && e.D(i.k.lE, t);
16
- },
17
- Ga: (e, t) => {
18
- if (!e || !t) return -1;
19
- const r = T.Qu(e);
20
- if (null == r) return -1;
21
- const s = r[t];
22
- return null == s || isNaN(s) ? -1 : s;
23
- },
24
- Xh: (e, t) => {
25
- let r = Ae;
26
- if (!e || !t) return r;
27
- const s = T.Xu(e);
28
- return null == s ? r : ((r = s[t]), null == r || isNaN(r) ? Ae : r);
29
- },
30
- Ws: (e, t, r) => {
31
- if (!e || !t) return;
32
- let s = T.Qu(e);
33
- null == s && (s = {}), (s[t] = r), T.Yu(e, s);
34
- },
35
- si: (e, t, r) => {
36
- if (!e || !t) return;
37
- let s = T.Xu(e);
38
- null == s && (s = {}), (s[t] = r), T.Zu(e, s);
39
- },
40
- hi: (e, t) => {
41
- if (!e || !t) return;
42
- const r = T.Xh(e, t);
43
- T.si(e, t, r + 1);
44
- },
45
- };
46
- export default T;
1
+ import{REQUEST_ATTEMPT_DEFAULT as Ae}from"../common/constants.js";import{STORAGE_KEYS as i}from"../managers/storage-manager.js";const T={Os:{Na:"d",Ks:"cc",Si:"ff",Lr:"t"},rm:e=>{if(e)return e.v(i.k.EE)},sm:e=>{if(e)return e.v(i.k.lE)},nm:(e,t)=>{e&&e.D(i.k.EE,t)},um:(e,t)=>{e&&e.D(i.k.lE,t)},La:(e,t)=>{if(!e||!t)return-1;const r=T.rm(e);if(null==r)return-1;const s=r[t];return null==s||isNaN(s)?-1:s},Wa:(e,t)=>{let r=Ae;if(!e||!t)return r;const s=T.sm(e);return null==s?r:(r=s[t],null==r||isNaN(r)?Ae:r)},Ws:(e,t,r)=>{if(!e||!t)return;let s=T.rm(e);null==s&&(s={}),s[t]=r,T.nm(e,s)},si:(e,t,r)=>{if(!e||!t)return;let s=T.sm(e);null==s&&(s={}),s[t]=r,T.um(e,s)},hi:(e,t)=>{if(!e||!t)return;const r=T.Wa(e,t);T.si(e,t,r+1)}};export default T;
@@ -1,22 +1 @@
1
- import r from "../../shared-lib/braze-shared-lib.js";
2
- export function getByteLength(t) {
3
- let e = t.length;
4
- for (let r = t.length - 1; r >= 0; r--) {
5
- const n = t.charCodeAt(r);
6
- n > 127 && n <= 2047 ? e++ : n > 2047 && n <= 65535 && (e += 2),
7
- n >= 56320 && n <= 57343 && r--;
8
- }
9
- return e;
10
- }
11
- export function decodeBrazeActions(t) {
12
- try {
13
- t = t.replace(/-/g, "+").replace(/_/g, "/");
14
- const e = window.atob(t),
15
- r = new Uint8Array(e.length);
16
- for (let t = 0; t < e.length; t++) r[t] = e.charCodeAt(t);
17
- const n = new Uint16Array(r.buffer);
18
- return String.fromCharCode(...n);
19
- } catch (t) {
20
- return r.j.error("Unable to decode Base64: " + t), null;
21
- }
22
- }
1
+ import r from"../../shared-lib/braze-shared-lib.js";export function getByteLength(t){let e=t.length;for(let r=t.length-1;r>=0;r--){const n=t.charCodeAt(r);n>127&&n<=2047?e++:n>2047&&n<=65535&&(e+=2),n>=56320&&n<=57343&&r--}return e}export function decodeBrazeActions(t){try{t=t.replace(/-/g,"+").replace(/_/g,"/");const e=window.atob(t),r=new Uint8Array(e.length);for(let t=0;t<e.length;t++)r[t]=e.charCodeAt(t);const n=new Uint16Array(r.buffer);return String.fromCharCode(...n)}catch(t){return r.j.error("Unable to decode Base64: "+t),null}}
package/src/util/types.js CHANGED
@@ -1 +1 @@
1
- export {};
1
+ export{};
@@ -1,20 +1 @@
1
- export function parseQueryStringKeyValues(t) {
2
- null == t && (t = "");
3
- const r = t.split("?").slice(1).join("?"),
4
- n = {};
5
- if (null != r) {
6
- const t = r.split("&");
7
- for (let r = 0; r < t.length; r++) {
8
- const a = t[r].split("=");
9
- "" !== a[0] && (n[a[0]] = a[1]);
10
- }
11
- }
12
- return n;
13
- }
14
- export function isURIJavascriptOrData(t) {
15
- return !(
16
- !t ||
17
- (0 !== (t = t.toString().toLowerCase()).lastIndexOf("javascript:", 0) &&
18
- 0 !== t.lastIndexOf("data:", 0))
19
- );
20
- }
1
+ export function parseQueryStringKeyValues(t){null==t&&(t="");const r=t.split("?").slice(1).join("?"),n={};if(null!=r){const t=r.split("&");for(let r=0;r<t.length;r++){const a=t[r].split("=");""!==a[0]&&(n[a[0]]=a[1])}}return n}export function isURIJavascriptOrData(t){return!(!t||0!==(t=t.toString().toLowerCase()).lastIndexOf("javascript:",0)&&0!==t.lastIndexOf("data:",0))}
@@ -1,85 +1 @@
1
- import ge from "./base-device-parser.js";
2
- import { Browsers as oi, OperatingSystems as W } from "./device-constants.js";
3
- export default class ai extends ge {
4
- constructor() {
5
- super(), (this.rd = ai.Uu(navigator.userAgent || ""));
6
- }
7
- tf() {
8
- return this.rd[0] || "Unknown Browser";
9
- }
10
- ef() {
11
- return this.rd[1] || "Unknown Version";
12
- }
13
- Ia(r) {
14
- for (let n = 0; n < r.length; n++) {
15
- const e = r[n].string;
16
- let i = ai.rf(e, r[n]);
17
- if (i)
18
- return (
19
- i === W.kg && navigator.maxTouchPoints > 1 && (i = W.de),
20
- Promise.resolve(i)
21
- );
22
- }
23
- return Promise.resolve(navigator.platform);
24
- }
25
- static Uu(r) {
26
- let n,
27
- e =
28
- r.match(
29
- /(samsungbrowser|tizen|roku|konqueror|icab|crios|opera|ucbrowser|chrome|safari|firefox|camino|msie|trident(?=\/))\/?\s*(\.?\d+(\.\d+)*)/i,
30
- ) || [];
31
- if (e[1] && /trident/i.test(e[1]))
32
- return (
33
- (n = /\brv[ :]+(\.?\d+(\.\d+)*)/g.exec(r) || []), [oi.Ku, n[1] || ""]
34
- );
35
- if (-1 !== r.indexOf("(Web0S; Linux/SmartTV)"))
36
- return ["LG Smart TV", null];
37
- if (-1 !== r.indexOf("CrKey")) return ["Chromecast", null];
38
- if (
39
- -1 !== r.indexOf("BRAVIA") ||
40
- -1 !== r.indexOf("SonyCEBrowser") ||
41
- -1 !== r.indexOf("SonyDTV")
42
- )
43
- return ["Sony Smart TV", null];
44
- if (-1 !== r.indexOf("PhilipsTV")) return ["Philips Smart TV", null];
45
- if (r.match(/\b(Roku)\b/)) return ["Roku", null];
46
- if (r.match(/\bAFTM\b/)) return ["Amazon Fire Stick", null];
47
- if (
48
- e[1] === oi.pE &&
49
- ((n = r.match(/\b(OPR|Edge|EdgA|Edg|UCBrowser)\/(\.?\d+(\.\d+)*)/)),
50
- null != n)
51
- )
52
- return (
53
- (n = n.slice(1)),
54
- (n[0] = n[0].replace("OPR", oi.FE)),
55
- (n[0] = n[0].replace("EdgA", oi.xE)),
56
- "Edg" === n[0] && (n[0] = oi.xE),
57
- [n[0], n[1]]
58
- );
59
- if (
60
- e[1] === oi.Bg &&
61
- ((n = r.match(/\b(EdgiOS)\/(\.?\d+(\.\d+)*)/)), null != n)
62
- )
63
- return (
64
- (n = n.slice(1)), (n[0] = n[0].replace("EdgiOS", oi.xE)), [n[0], n[1]]
65
- );
66
- if (
67
- ((e = e[2] ? [e[1], e[2]] : [null, null]),
68
- e[0] === oi.Bg &&
69
- null != (n = r.match(/version\/(\.?\d+(\.\d+)*)/i)) &&
70
- e.splice(1, 1, n[1]),
71
- null != (n = r.match(/\b(UCBrowser)\/(\.?\d+(\.\d+)*)/)) &&
72
- e.splice(1, 1, n[2]),
73
- e[0] === oi.FE && null != (n = r.match(/mini\/(\.?\d+(\.\d+)*)/i)))
74
- )
75
- return ["Opera Mini", n[1] || ""];
76
- if (e[0]) {
77
- const r = e[0].toLowerCase();
78
- "msie" === r && (e[0] = oi.Ku),
79
- "crios" === r && (e[0] = oi.pE),
80
- "tizen" === r && ((e[0] = "Samsung Smart TV"), (e[1] = null)),
81
- "samsungbrowser" === r && (e[0] = "Samsung Browser");
82
- }
83
- return e;
84
- }
85
- }
1
+ import ge from"./base-device-parser.js";import{Browsers as oi,OperatingSystems as W}from"./device-constants.js";export default class ai extends ge{constructor(){super(),this.rd=ai.ic(navigator.userAgent||"")}tf(){return this.rd[0]||"Unknown Browser"}ef(){return this.rd[1]||"Unknown Version"}Ta(r){for(let n=0;n<r.length;n++){const e=r[n].string;let i=ai.rf(e,r[n]);if(i)return i===W.kg&&navigator.maxTouchPoints>1&&(i=W.de),Promise.resolve(i)}return Promise.resolve(navigator.platform)}static ic(r){let n,e=r.match(/(samsungbrowser|tizen|roku|konqueror|icab|crios|opera|ucbrowser|chrome|safari|firefox|camino|msie|trident(?=\/))\/?\s*(\.?\d+(\.\d+)*)/i)||[];if(e[1]&&/trident/i.test(e[1]))return n=/\brv[ :]+(\.?\d+(\.\d+)*)/g.exec(r)||[],[oi.oc,n[1]||""];if(-1!==r.indexOf("(Web0S; Linux/SmartTV)"))return["LG Smart TV",null];if(-1!==r.indexOf("CrKey"))return["Chromecast",null];if(-1!==r.indexOf("BRAVIA")||-1!==r.indexOf("SonyCEBrowser")||-1!==r.indexOf("SonyDTV"))return["Sony Smart TV",null];if(-1!==r.indexOf("PhilipsTV"))return["Philips Smart TV",null];if(r.match(/\b(Roku)\b/))return["Roku",null];if(r.match(/\bAFTM\b/))return["Amazon Fire Stick",null];if(e[1]===oi.pE&&(n=r.match(/\b(OPR|Edge|EdgA|Edg|UCBrowser)\/(\.?\d+(\.\d+)*)/),null!=n))return n=n.slice(1),n[0]=n[0].replace("OPR",oi.FE),n[0]=n[0].replace("EdgA",oi.xE),"Edg"===n[0]&&(n[0]=oi.xE),[n[0],n[1]];if(e[1]===oi.Bg&&(n=r.match(/\b(EdgiOS)\/(\.?\d+(\.\d+)*)/),null!=n))return n=n.slice(1),n[0]=n[0].replace("EdgiOS",oi.xE),[n[0],n[1]];if(e=e[2]?[e[1],e[2]]:[null,null],e[0]===oi.Bg&&null!=(n=r.match(/version\/(\.?\d+(\.\d+)*)/i))&&e.splice(1,1,n[1]),null!=(n=r.match(/\b(UCBrowser)\/(\.?\d+(\.\d+)*)/))&&e.splice(1,1,n[2]),e[0]===oi.FE&&null!=(n=r.match(/mini\/(\.?\d+(\.\d+)*)/i)))return["Opera Mini",n[1]||""];if(e[0]){const r=e[0].toLowerCase();"msie"===r&&(e[0]=oi.oc),"crios"===r&&(e[0]=oi.pE),"tizen"===r&&(e[0]="Samsung Smart TV",e[1]=null),"samsungbrowser"===r&&(e[0]="Samsung Browser")}return e}}
@@ -1,217 +1 @@
1
- import {
2
- isArray as p,
3
- isDate as Nt,
4
- isObject as yt,
5
- keys as oo,
6
- } from "./code-utils.js";
7
- import { getByteLength as U } from "./string-utils.js";
8
- import r from "../../shared-lib/braze-shared-lib.js";
9
- import { toValidBackendTimeString as $t } from "./date-utils.js";
10
- import { BRAZE_ACTIONS as _ } from "./braze-actions.js";
11
- import { SET_CUSTOM_USER_ATTRIBUTE_STRING as Ft } from "../common/constants.js";
12
- export const CUSTOM_DATA_REGEX = /^[^\x00-\x1F\x22]+$/;
13
- export const CUSTOM_ATTRIBUTE_SPECIAL_CHARS_REGEX = /[$.]/;
14
- export const CUSTOM_ATTRIBUTE_RESERVED_OPERATORS = [
15
- "$add",
16
- "$update",
17
- "$remove",
18
- "$identifier_key",
19
- "$identifier_value",
20
- "$new_object",
21
- "$time",
22
- ];
23
- export const EMAIL_ADDRESS_REGEX = new RegExp(/^.+@.+\..+$/);
24
- export const CUSTOM_PROPERTIES_MAX_SIZE_BYTES = 51200;
25
- export const CUSTOM_PROPERTIES_MAX_SIZE_STRING = "50KB";
26
- export const CUSTOM_ATTRIBUTES_MAX_SIZE_BYTES = 76800;
27
- export const CUSTOM_ATTRIBUTES_MAX_SIZE_STRING = "75KB";
28
- export const CUSTOM_ATTRIBUTE_MAX_DEPTH = 50;
29
- export const BRAZE_ACTION_URI_REGEX = /^brazeActions:\/\/v\d+\//;
30
- export function validateCustomString(t, e, n) {
31
- const o =
32
- null != t &&
33
- "string" == typeof t &&
34
- ("" === t || null != t.match(CUSTOM_DATA_REGEX));
35
- return o || r.j.error(`Cannot ${e} because ${n} "${t}" is invalid.`), o;
36
- }
37
- export function validateCustomAttributeKey(t) {
38
- return (
39
- null != t &&
40
- t.match(CUSTOM_ATTRIBUTE_SPECIAL_CHARS_REGEX) &&
41
- -1 === CUSTOM_ATTRIBUTE_RESERVED_OPERATORS.indexOf(t) &&
42
- r.j.warn("Custom attribute keys cannot contain '$' or '.'"),
43
- validateCustomString(t, "set custom user attribute", "the given key")
44
- );
45
- }
46
- export function validatePropertyType(t) {
47
- const e = typeof t;
48
- return (
49
- null == t || "number" === e || "boolean" === e || Nt(t) || "string" === e
50
- );
51
- }
52
- export function _validateNestedProperties(t, e, n) {
53
- const o = -1 !== n;
54
- if (o && n > 50)
55
- return (
56
- r.j.error("Nested attributes cannot be more than 50 levels deep."), !1
57
- );
58
- const i = o ? n + 1 : -1;
59
- if (p(t) && p(e)) {
60
- for (let r = 0; r < t.length && r < e.length; r++)
61
- if (
62
- (Nt(t[r]) && (e[r] = $t(t[r])),
63
- !_validateNestedProperties(t[r], e[r], i))
64
- )
65
- return !1;
66
- } else {
67
- if (!yt(t)) return validatePropertyType(t);
68
- for (const r of oo(t)) {
69
- const n = t[r];
70
- if (o && !validateCustomAttributeKey(r)) return !1;
71
- if (Nt(n)) {
72
- e[r] = $t(n);
73
- }
74
- if (!_validateNestedProperties(n, e[r], i)) return !1;
75
- }
76
- }
77
- return !0;
78
- }
79
- export function _validateEventPropertyValue(t, e, n, o, i) {
80
- let a;
81
- return (
82
- (a =
83
- yt(t) || p(t)
84
- ? _validateNestedProperties(t, e, i ? 1 : -1)
85
- : validatePropertyType(t)),
86
- a || r.j.error(`Cannot ${n} because ${o} "${t}" is invalid.`),
87
- a
88
- );
89
- }
90
- export function validateStandardString(t, e, n, o = !1) {
91
- const i = "string" == typeof t || (null === t && o);
92
- return i || r.j.error(`Cannot ${e} because ${n} "${t}" is invalid.`), i;
93
- }
94
- export function validateCustomProperties(t, e, n, o, i) {
95
- if ((null == t && (t = {}), "object" != typeof t || p(t)))
96
- return (
97
- r.j.error(`${e} requires that ${n} be an object. Ignoring ${i}.`),
98
- [!1, null]
99
- );
100
- let a, s;
101
- e === Ft ? ((a = 76800), (s = "75KB")) : ((a = 51200), (s = "50KB"));
102
- const u = JSON.stringify(t);
103
- if (U(u) > a)
104
- return (
105
- r.j.error(
106
- `Could not ${o} because ${n} was greater than the max size of ${s}.`,
107
- ),
108
- [!1, null]
109
- );
110
- let l;
111
- try {
112
- l = JSON.parse(u);
113
- } catch (t) {
114
- return (
115
- r.j.error(`Could not ${o} because ${n} did not contain valid JSON.`),
116
- [!1, null]
117
- );
118
- }
119
- for (const r in t) {
120
- if (e === Ft && !validateCustomAttributeKey(r)) return [!1, null];
121
- if (!validateCustomString(r, o, `the ${i} property name`))
122
- return [!1, null];
123
- const n = t[r];
124
- if (e !== Ft && null == n) {
125
- delete t[r], delete l[r];
126
- continue;
127
- }
128
- Nt(n) && (l[r] = $t(n));
129
- if (
130
- !_validateEventPropertyValue(
131
- n,
132
- l[r],
133
- o,
134
- `the ${i} property "${r}"`,
135
- e === Ft,
136
- )
137
- )
138
- return [!1, null];
139
- }
140
- return [!0, l];
141
- }
142
- export function validateCustomAttributeArrayType(t, e) {
143
- let n = !1,
144
- o = !1;
145
- const i = () => {
146
- r.j.error(
147
- "Custom attribute arrays must be either string arrays or object arrays.",
148
- );
149
- };
150
- for (const r of e)
151
- if ("string" == typeof r) {
152
- if (o) return i(), [!1, !1];
153
- if (
154
- !validateCustomString(
155
- r,
156
- `set custom user attribute "${t}"`,
157
- "the element in the given array",
158
- )
159
- )
160
- return [!1, !1];
161
- n = !0;
162
- } else {
163
- if (!yt(r)) return i(), [!1, !1];
164
- if (n) return i(), [!1, !1];
165
- if (
166
- !validateCustomProperties(
167
- r,
168
- Ft,
169
- "attribute value",
170
- `set custom user attribute "${t}"`,
171
- "custom user attribute",
172
- )
173
- )
174
- return [!1, !1];
175
- o = !0;
176
- }
177
- return [n, o];
178
- }
179
- export function isValidEmail(t) {
180
- return (
181
- "string" == typeof t && null != t.toLowerCase().match(EMAIL_ADDRESS_REGEX)
182
- );
183
- }
184
- export function isValidBrazeActionJson(t) {
185
- if (!(_.properties.type in t)) return !1;
186
- switch (t[_.properties.type]) {
187
- case _.types.ue:
188
- if (_.properties.me in t) return !0;
189
- break;
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.pe:
199
- case _.types.je:
200
- if (_.properties.le in t) return !0;
201
- break;
202
- case _.types.requestPushPermission:
203
- return !0;
204
- default:
205
- return !1;
206
- }
207
- return !1;
208
- }
209
- export function isValidBrazeActionType(t) {
210
- let e = !1;
211
- return (
212
- Object.keys(_.types).forEach((r) => {
213
- _.types[r] !== t.toString() || (e = !0);
214
- }),
215
- e
216
- );
217
- }
1
+ import{isArray as p,isDate as yt,isObject as Nt,keys as oo}from"./code-utils.js";import{getByteLength as U}from"./string-utils.js";import r from"../../shared-lib/braze-shared-lib.js";import{toValidBackendTimeString as $t}from"./date-utils.js";import{BRAZE_ACTIONS as _}from"./braze-actions.js";import{SET_CUSTOM_USER_ATTRIBUTE_STRING as Ft}from"../common/constants.js";export const CUSTOM_DATA_REGEX=/^[^\x00-\x1F\x22]+$/;export const CUSTOM_ATTRIBUTE_SPECIAL_CHARS_REGEX=/[$.]/;export const CUSTOM_ATTRIBUTE_RESERVED_OPERATORS=["$add","$update","$remove","$identifier_key","$identifier_value","$new_object","$time"];export const EMAIL_ADDRESS_REGEX=new RegExp(/^.+@.+\..+$/);export const CUSTOM_PROPERTIES_MAX_SIZE_BYTES=51200;export const CUSTOM_PROPERTIES_MAX_SIZE_STRING="50KB";export const CUSTOM_ATTRIBUTES_MAX_SIZE_BYTES=76800;export const CUSTOM_ATTRIBUTES_MAX_SIZE_STRING="75KB";export const CUSTOM_ATTRIBUTE_MAX_DEPTH=50;export const BRAZE_ACTION_URI_REGEX=/^brazeActions:\/\/v\d+\//;export function validateCustomString(t,e,n){const o=null!=t&&"string"==typeof t&&(""===t||null!=t.match(CUSTOM_DATA_REGEX));return o||r.j.error(`Cannot ${e} because ${n} "${t}" is invalid.`),o}export function validateCustomAttributeKey(t){return null!=t&&t.match(CUSTOM_ATTRIBUTE_SPECIAL_CHARS_REGEX)&&-1===CUSTOM_ATTRIBUTE_RESERVED_OPERATORS.indexOf(t)&&r.j.warn("Custom attribute keys cannot contain '$' or '.'"),validateCustomString(t,"set custom user attribute","the given key")}export function validatePropertyType(t){const e=typeof t;return null==t||"number"===e||"boolean"===e||yt(t)||"string"===e}export function _validateNestedProperties(t,e,n){const o=-1!==n;if(o&&n>50)return r.j.error("Nested attributes cannot be more than 50 levels deep."),!1;const i=o?n+1:-1;if(p(t)&&p(e)){for(let r=0;r<t.length&&r<e.length;r++)if(yt(t[r])&&(e[r]=$t(t[r])),!_validateNestedProperties(t[r],e[r],i))return!1}else{if(!Nt(t))return validatePropertyType(t);for(const r of oo(t)){const n=t[r];if(o&&!validateCustomAttributeKey(r))return!1;if(yt(n)){e[r]=$t(n)}if(!_validateNestedProperties(n,e[r],i))return!1}}return!0}export function _validateEventPropertyValue(t,e,n,o,i){let a;return a=Nt(t)||p(t)?_validateNestedProperties(t,e,i?1:-1):validatePropertyType(t),a||r.j.error(`Cannot ${n} because ${o} "${t}" is invalid.`),a}export function validateStandardString(t,e,n,o=!1){const i="string"==typeof t||null===t&&o;return i||r.j.error(`Cannot ${e} because ${n} "${t}" is invalid.`),i}export function validateCustomProperties(t,e,n,o,i){if(null==t&&(t={}),"object"!=typeof t||p(t))return r.j.error(`${e} requires that ${n} be an object. Ignoring ${i}.`),[!1,null];let a,s;e===Ft?(a=76800,s="75KB"):(a=51200,s="50KB");const u=JSON.stringify(t);if(U(u)>a)return r.j.error(`Could not ${o} because ${n} was greater than the max size of ${s}.`),[!1,null];let l;try{l=JSON.parse(u)}catch(t){return r.j.error(`Could not ${o} because ${n} did not contain valid JSON.`),[!1,null]}for(const r in t){if(e===Ft&&!validateCustomAttributeKey(r))return[!1,null];if(!validateCustomString(r,o,`the ${i} property name`))return[!1,null];const n=t[r];if(e!==Ft&&null==n){delete t[r],delete l[r];continue}yt(n)&&(l[r]=$t(n));if(!_validateEventPropertyValue(n,l[r],o,`the ${i} property "${r}"`,e===Ft))return[!1,null]}return[!0,l]}export function validateCustomAttributeArrayType(t,e){let n=!1,o=!1;const i=()=>{r.j.error("Custom attribute arrays must be either string arrays or object arrays.")};for(const r of e)if("string"==typeof r){if(o)return i(),[!1,!1];if(!validateCustomString(r,`set custom user attribute "${t}"`,"the element in the given array"))return[!1,!1];n=!0}else{if(!Nt(r))return i(),[!1,!1];if(n)return i(),[!1,!1];if(!validateCustomProperties(r,Ft,"attribute value",`set custom user attribute "${t}"`,"custom user attribute"))return[!1,!1];o=!0}return[n,o]}export function isValidEmail(t){return"string"==typeof t&&null!=t.toLowerCase().match(EMAIL_ADDRESS_REGEX)}export function isValidBrazeActionJson(t){if(!(_.properties.type in t))return!1;switch(t[_.properties.type]){case _.types.ue:if(_.properties.me in t)return!0;break;case _.types.logCustomEvent:case _.types.setEmailNotificationSubscriptionType:case _.types.setPushNotificationSubscriptionType:case _.types.setCustomUserAttribute:case _.types.addToSubscriptionGroup:case _.types.removeFromSubscriptionGroup:case _.types.addToCustomAttributeArray:case _.types.removeFromCustomAttributeArray:case _.types.pe:case _.types.je:if(_.properties.le in t)return!0;break;case _.types.requestPushPermission:return!0;default:return!1}return!1}export function isValidBrazeActionType(t){let e=!1;return Object.keys(_.types).forEach((r=>{_.types[r]!==t.toString()||(e=!0)})),e}
@@ -1,34 +1 @@
1
- export const ORIENTATION = { PORTRAIT: 0, LANDSCAPE: 1 };
2
- export function _isPhone() {
3
- return screen.width <= 600;
4
- }
5
- export function _getOrientation() {
6
- if ("orientation" in window)
7
- return 90 === Math.abs(window.orientation) || 270 === window.orientation
8
- ? ORIENTATION.LANDSCAPE
9
- : ORIENTATION.PORTRAIT;
10
- const n = window;
11
- if ("screen" in n) {
12
- let e =
13
- n.screen.orientation || screen.mozOrientation || screen.msOrientation;
14
- return (
15
- null != e && "object" == typeof e && (e = e.type),
16
- "landscape-primary" === e || "landscape-secondary" === e
17
- ? ORIENTATION.LANDSCAPE
18
- : ORIENTATION.PORTRAIT
19
- );
20
- }
21
- return ORIENTATION.PORTRAIT;
22
- }
23
- export function _openUri(n, e, t) {
24
- n && (e || (null != t && t.metaKey) ? window.open(n) : (window.location = n));
25
- }
26
- export function _getCurrentUrl() {
27
- return window.location.href;
28
- }
29
- export const WindowUtils = {
30
- openUri: _openUri,
31
- ao: _isPhone,
32
- mo: _getOrientation,
33
- Cn: _getCurrentUrl,
34
- };
1
+ export const ORIENTATION={PORTRAIT:0,LANDSCAPE:1};export function _isPhone(){return screen.width<=600}export function _getOrientation(){if("orientation"in window)return 90===Math.abs(window.orientation)||270===window.orientation?ORIENTATION.LANDSCAPE:ORIENTATION.PORTRAIT;const n=window;if("screen"in n){let e=n.screen.orientation||screen.mozOrientation||screen.msOrientation;return null!=e&&"object"==typeof e&&(e=e.type),"landscape-primary"===e||"landscape-secondary"===e?ORIENTATION.LANDSCAPE:ORIENTATION.PORTRAIT}return ORIENTATION.PORTRAIT}export function _openUri(n,e,t){n&&(e||null!=t&&t.metaKey?window.open(n):window.location=n)}export function _getCurrentUrl(){return window.location.href}export const WindowUtils={openUri:_openUri,ao:_isPhone,mo:_getOrientation,Cn:_getCurrentUrl};