@braze/web-sdk 6.8.0 → 6.10.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 (141) hide show
  1. package/index.d.ts +113 -21
  2. package/package.json +1 -1
  3. package/shared-lib/event-types.js +20 -20
  4. package/shared-lib/indexed-db-adapter.js +64 -64
  5. package/shared-lib/logger.js +18 -18
  6. package/shared-lib/supported-options.js +8 -8
  7. package/src/Banner/banner-provider.js +67 -59
  8. package/src/Banner/banner.js +40 -19
  9. package/src/Banner/dismiss-banner.js +4 -0
  10. package/src/Banner/display/banner-to-html.js +10 -10
  11. package/src/Banner/display/destroy-banner-html.js +2 -2
  12. package/src/Banner/get-all-banners.js +6 -6
  13. package/src/Banner/get-banner.js +6 -6
  14. package/src/Banner/index.js +1 -0
  15. package/src/Banner/log-banner-click.js +7 -7
  16. package/src/Banner/log-banner-dismissal.js +7 -7
  17. package/src/Banner/log-banner-impressions.js +10 -10
  18. package/src/Banner/request-banners-refresh.js +8 -8
  19. package/src/Banner/subscribe-to-banners-updates.js +5 -5
  20. package/src/Banner/ui/insert-banner.js +8 -8
  21. package/src/Card/card-manager.js +31 -31
  22. package/src/Card/log-card-dismissal.js +2 -2
  23. package/src/Card/log-content-card-click.js +2 -2
  24. package/src/Card/log-content-card-impressions.js +4 -4
  25. package/src/Card/models/captioned-image.js +15 -15
  26. package/src/Card/models/card.js +89 -89
  27. package/src/Card/models/classic-card.js +16 -16
  28. package/src/Card/models/control-card.js +7 -7
  29. package/src/Card/models/image-only.js +13 -13
  30. package/src/Card/util/card-factory.js +32 -32
  31. package/src/ContentCards/content-cards-provider.js +102 -102
  32. package/src/ContentCards/get-cached-content-cards.js +1 -1
  33. package/src/ContentCards/subscribe-to-content-cards-updates.js +3 -3
  34. package/src/ContentCards/ui/show-content-cards.js +5 -5
  35. package/src/Core/add-sdk-metadata.js +2 -2
  36. package/src/Core/change-user.js +3 -3
  37. package/src/Core/destroy.js +2 -2
  38. package/src/Core/disable-sdk.js +4 -4
  39. package/src/Core/enable-sdk.js +4 -4
  40. package/src/Core/get-device-id.js +2 -2
  41. package/src/Core/handle-braze-action.js +5 -5
  42. package/src/Core/index.js +1 -0
  43. package/src/Core/log-custom-event.js +5 -5
  44. package/src/Core/log-ecommerce-event.js +5 -5
  45. package/src/Core/log-purchase.js +9 -9
  46. package/src/Core/logout.js +22 -0
  47. package/src/Core/open-session.js +7 -7
  48. package/src/Core/set-logger.js +2 -2
  49. package/src/Core/toggle-logging.js +2 -2
  50. package/src/Core/wipe-data.js +6 -6
  51. package/src/DUST/dust-provider.js +249 -240
  52. package/src/DUST/dust-shared-worker-code.js +1 -1
  53. package/src/DUST/dust-shared-worker-impl.js +15 -14
  54. package/src/DUST/dust-worker-bridge.js +50 -35
  55. package/src/DUST/subscribe-to-dust.js +7 -7
  56. package/src/FeatureFlags/feature-flag-factory.js +8 -8
  57. package/src/FeatureFlags/feature-flag.js +3 -3
  58. package/src/FeatureFlags/feature-flags-provider.js +21 -21
  59. package/src/FeatureFlags/log-feature-flag-impression.js +5 -5
  60. package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +1 -1
  61. package/src/InAppMessage/constants.js +3 -3
  62. package/src/InAppMessage/defer-in-app-message.js +4 -4
  63. package/src/InAppMessage/display/html-message-to-html.js +4 -4
  64. package/src/InAppMessage/display/in-app-message-to-html.js +16 -16
  65. package/src/InAppMessage/in-app-message-factory.js +36 -36
  66. package/src/InAppMessage/in-app-message-manager.js +78 -78
  67. package/src/InAppMessage/log-in-app-message-button-click.js +4 -4
  68. package/src/InAppMessage/log-in-app-message-click.js +3 -3
  69. package/src/InAppMessage/log-in-app-message-html-click.js +5 -5
  70. package/src/InAppMessage/log-in-app-message-impression.js +4 -4
  71. package/src/InAppMessage/models/control-message.js +4 -4
  72. package/src/InAppMessage/models/full-screen-message.js +4 -4
  73. package/src/InAppMessage/models/html-message.js +3 -3
  74. package/src/InAppMessage/models/in-app-message-button.js +4 -4
  75. package/src/InAppMessage/models/in-app-message.js +12 -12
  76. package/src/InAppMessage/models/modal-message.js +4 -4
  77. package/src/InAppMessage/models/slide-up-message.js +4 -4
  78. package/src/InAppMessage/models/templated-in-app-message.js +8 -8
  79. package/src/InAppMessage/subscribe-to-in-app-message.js +1 -1
  80. package/src/InAppMessage/ui/automatically-show-in-app-messages.js +3 -3
  81. package/src/InAppMessage/ui/show-in-app-message.js +14 -14
  82. package/src/Push/push-manager-factory.js +2 -2
  83. package/src/Push/push-manager.js +38 -38
  84. package/src/Push/unregister-push-token-on-server.js +35 -0
  85. package/src/Push/unregister-push.js +2 -1
  86. package/src/Push/utils/push-utils.js +6 -6
  87. package/src/User/user-manager.js +14 -14
  88. package/src/User/user.js +25 -25
  89. package/src/common/base-provider.js +1 -1
  90. package/src/common/content-cards-display.js +7 -7
  91. package/src/common/event-logger.js +3 -3
  92. package/src/common/properties-base.js +3 -3
  93. package/src/l10n/l10n-manager-factory.js +2 -2
  94. package/src/l10n/l10n-manager.js +4 -4
  95. package/src/managers/auth-manager.js +11 -11
  96. package/src/managers/braze-instance.js +56 -56
  97. package/src/managers/device-manager.js +10 -10
  98. package/src/managers/network-manager.js +103 -102
  99. package/src/managers/server-config-manager.js +112 -95
  100. package/src/managers/session-manager.js +20 -20
  101. package/src/managers/storage-manager-factory.js +9 -9
  102. package/src/managers/storage-manager.js +73 -73
  103. package/src/managers/subscription-manager.js +2 -2
  104. package/src/managers/utils.js +1 -1
  105. package/src/models/backend-errors.js +5 -5
  106. package/src/models/braze-event.js +1 -1
  107. package/src/models/device.js +1 -1
  108. package/src/models/identifier.js +2 -2
  109. package/src/models/push-token.js +6 -6
  110. package/src/models/request-result.js +1 -1
  111. package/src/models/server-config.js +42 -24
  112. package/src/request-controller.js +126 -126
  113. package/src/triggers/models/custom-event-data.js +4 -4
  114. package/src/triggers/models/custom-event-property-data.js +5 -5
  115. package/src/triggers/models/filter-set.js +2 -2
  116. package/src/triggers/models/filter.js +1 -1
  117. package/src/triggers/models/in-app-message-click-data.js +1 -1
  118. package/src/triggers/models/purchase-data.js +1 -1
  119. package/src/triggers/models/purchase-property-data.js +2 -2
  120. package/src/triggers/models/push-click-data.js +3 -3
  121. package/src/triggers/models/trigger-condition.js +36 -36
  122. package/src/triggers/models/trigger-events.js +1 -1
  123. package/src/triggers/models/trigger.js +33 -33
  124. package/src/triggers/triggers-provider-factory.js +1 -1
  125. package/src/triggers/triggers-provider.js +68 -68
  126. package/src/types.js +2 -2
  127. package/src/ui/js/attach-css.js +1 -1
  128. package/src/util/braze-actions.js +7 -7
  129. package/src/util/browser-detector.js +2 -2
  130. package/src/util/client-hints-parser.js +4 -4
  131. package/src/util/code-utils.js +2 -2
  132. package/src/util/deprecation-utils.js +2 -2
  133. package/src/util/dom-utils.js +7 -7
  134. package/src/util/ecommerce-event-validation.js +52 -35
  135. package/src/util/html-display-utils.js +11 -11
  136. package/src/util/net.js +4 -4
  137. package/src/util/request-header-utils.js +36 -35
  138. package/src/util/string-utils.js +2 -2
  139. package/src/util/user-agent-parser.js +2 -2
  140. package/src/util/validation-utils.js +12 -12
  141. package/src/util/window-utils.js +2 -2
@@ -46,7 +46,7 @@ export default class HtmlMessage extends InAppMessage {
46
46
  od() {
47
47
  return !1;
48
48
  }
49
- ss(i) {
49
+ Yt(i) {
50
50
  if (this.ko === dt.iE) {
51
51
  if (this.rd) return !1;
52
52
  this.rd = !0;
@@ -57,10 +57,10 @@ export default class HtmlMessage extends InAppMessage {
57
57
  const i = super.qt(dt.iE);
58
58
  return (i[cr.qE] = this.messageFields), i;
59
59
  }
60
- static ga(i) {
60
+ static ha(i) {
61
61
  return new HtmlMessage(
62
62
  i[cr.rE],
63
- i[cr.Fs],
63
+ i[cr.Is],
64
64
  i[cr.FE],
65
65
  i[cr.BE],
66
66
  i[cr.lE],
@@ -15,13 +15,13 @@ export default class InAppMessageButton {
15
15
  (this.borderColor = r || this.backgroundColor),
16
16
  (this.clickAction = h || Le.NONE),
17
17
  (this.uri = e),
18
- null == n && (n = InAppMessageButton.Qn),
18
+ null == n && (n = InAppMessageButton.Kn),
19
19
  (this.id = n),
20
20
  (this.rd = !1),
21
21
  (this.ti = new f());
22
22
  }
23
23
  subscribeToClickedEvent(s) {
24
- return this.ti.Kt(s);
24
+ return this.ti.Ut(s);
25
25
  }
26
26
  removeSubscription(s) {
27
27
  this.ti.removeSubscription(s);
@@ -29,7 +29,7 @@ export default class InAppMessageButton {
29
29
  removeAllSubscriptions() {
30
30
  this.ti.removeAllSubscriptions();
31
31
  }
32
- ss() {
32
+ Yt() {
33
33
  return !this.rd && ((this.rd = !0), this.ti.A(), !0);
34
34
  }
35
35
  static fromJson(s) {
@@ -44,4 +44,4 @@ export default class InAppMessageButton {
44
44
  );
45
45
  }
46
46
  }
47
- InAppMessageButton.Qn = -1;
47
+ InAppMessageButton.Kn = -1;
@@ -128,7 +128,7 @@ export default class InAppMessage {
128
128
  (this.language = D),
129
129
  (this.altImageText = z),
130
130
  (this.th = !1),
131
- (this.Zt = !1),
131
+ (this.hs = !1),
132
132
  (this.rd = !1),
133
133
  (this.sh = !1),
134
134
  (this.Eo = null),
@@ -138,10 +138,10 @@ export default class InAppMessage {
138
138
  (this.Go = Fe.CENTER);
139
139
  }
140
140
  subscribeToClickedEvent(t) {
141
- return this.ti.Kt(t);
141
+ return this.ti.Ut(t);
142
142
  }
143
143
  subscribeToDismissedEvent(t) {
144
- return this.ih.Kt(t);
144
+ return this.ih.Ut(t);
145
145
  }
146
146
  removeSubscription(t) {
147
147
  this.ti.removeSubscription(t), this.ih.removeSubscription(t);
@@ -167,16 +167,16 @@ export default class InAppMessage {
167
167
  Oo() {
168
168
  if (this.Bo() && this.Mo()) return this.htmlId + "-css";
169
169
  }
170
- gs() {
171
- return !this.Zt && ((this.Zt = !0), !0);
170
+ js() {
171
+ return !this.hs && ((this.hs = !0), !0);
172
172
  }
173
173
  sm() {
174
- return this.Zt;
174
+ return this.hs;
175
175
  }
176
- ss(t) {
176
+ Yt(t) {
177
177
  return !this.rd && ((this.rd = !0), this.ti.A(), !0);
178
178
  }
179
- ls() {
179
+ Ft() {
180
180
  return !this.sh && ((this.sh = !0), this.ih.A(), !0);
181
181
  }
182
182
  hide(t) {
@@ -215,7 +215,7 @@ export default class InAppMessage {
215
215
  t && t.parentNode && t.parentNode.removeChild(t);
216
216
  }
217
217
  null != e && "Safari" === ro.browser && (e.scrollTop = n),
218
- s ? s() : this.ls();
218
+ s ? s() : this.Ft();
219
219
  };
220
220
  h ? setTimeout(r, Et.gr) : r(), this.$o && this.$o.focus();
221
221
  }
@@ -289,7 +289,7 @@ export default class InAppMessage {
289
289
  ? ((s[cr.rE] = this.message),
290
290
  (s[cr.mE] = this.messageAlignment),
291
291
  (s[cr.GE] = this.slideFrom),
292
- (s[cr.Fs] = this.extras),
292
+ (s[cr.Is] = this.extras),
293
293
  (s[cr.FE] = this.triggerId),
294
294
  (s[cr.HE] = this.clickAction),
295
295
  (s[cr.URI] = this.uri),
@@ -297,7 +297,7 @@ export default class InAppMessage {
297
297
  (s[cr.BE] = this.dismissType),
298
298
  (s[cr.lE] = this.duration),
299
299
  (s[cr.bE] = this.icon),
300
- (s[cr.ys] = this.imageUrl),
300
+ (s[cr.Bs] = this.imageUrl),
301
301
  (s[cr.gE] = this.imageStyle),
302
302
  (s[cr.YE] = this.iconColor),
303
303
  (s[cr.KE] = this.iconBackgroundColor),
@@ -318,7 +318,7 @@ export default class InAppMessage {
318
318
  (s[cr.xs] = t),
319
319
  (s[cr.JE] = this.messageExtras),
320
320
  (s[cr.LANGUAGE] = this.language),
321
- (s[cr.Ks] = this.altImageText),
321
+ (s[cr.Ns] = this.altImageText),
322
322
  s)
323
323
  : s;
324
324
  }
@@ -79,11 +79,11 @@ export default class ModalMessage extends InAppMessage {
79
79
  qt() {
80
80
  return super.qt(dt.aE);
81
81
  }
82
- static ga(r) {
82
+ static ha(r) {
83
83
  return new ModalMessage(
84
84
  r[cr.rE],
85
85
  r[cr.mE],
86
- r[cr.Fs],
86
+ r[cr.Is],
87
87
  r[cr.FE],
88
88
  r[cr.HE],
89
89
  r[cr.URI],
@@ -91,7 +91,7 @@ export default class ModalMessage extends InAppMessage {
91
91
  r[cr.BE],
92
92
  r[cr.lE],
93
93
  r[cr.bE],
94
- r[cr.ys],
94
+ r[cr.Bs],
95
95
  r[cr.gE],
96
96
  r[cr.YE],
97
97
  r[cr.KE],
@@ -110,7 +110,7 @@ export default class ModalMessage extends InAppMessage {
110
110
  r[cr.CSS],
111
111
  r[cr.JE],
112
112
  r[cr.LANGUAGE],
113
- r[cr.Ks],
113
+ r[cr.Ns],
114
114
  );
115
115
  }
116
116
  }
@@ -90,12 +90,12 @@ export default class SlideUpMessage extends InAppMessage {
90
90
  qt() {
91
91
  return super.qt(dt.sE);
92
92
  }
93
- static ga(t) {
93
+ static ha(t) {
94
94
  return new SlideUpMessage(
95
95
  t[cr.rE],
96
96
  t[cr.mE],
97
97
  t[cr.GE],
98
- t[cr.Fs],
98
+ t[cr.Is],
99
99
  t[cr.FE],
100
100
  t[cr.HE],
101
101
  t[cr.URI],
@@ -103,7 +103,7 @@ export default class SlideUpMessage extends InAppMessage {
103
103
  t[cr.BE],
104
104
  t[cr.lE],
105
105
  t[cr.bE],
106
- t[cr.ys],
106
+ t[cr.Bs],
107
107
  t[cr.YE],
108
108
  t[cr.KE],
109
109
  t[cr.XE],
@@ -115,7 +115,7 @@ export default class SlideUpMessage extends InAppMessage {
115
115
  t[cr.CSS],
116
116
  t[cr.JE],
117
117
  t[cr.LANGUAGE],
118
- t[cr.Ks],
118
+ t[cr.Ns],
119
119
  );
120
120
  }
121
121
  }
@@ -1,15 +1,15 @@
1
1
  export default class Jt {
2
2
  constructor(t, s, i, h, l) {
3
3
  (this.triggerId = t),
4
- (this.ca = s),
5
- (this.la = i),
6
- (this.pa = h),
7
- (this.ha = l),
4
+ (this.ua = s),
5
+ (this.ia = i),
6
+ (this.ma = h),
7
+ (this.ca = l),
8
8
  (this.triggerId = t),
9
- (this.ca = s),
10
- (this.la = i),
11
- (this.pa = h),
12
- (this.ha = l);
9
+ (this.ua = s),
10
+ (this.ia = i),
11
+ (this.ma = h),
12
+ (this.ca = l);
13
13
  }
14
14
  static fromJson(t, s, i, h, l) {
15
15
  return null == t || null == t.trigger_id
@@ -4,7 +4,7 @@ export function subscribeToInAppMessage(n) {
4
4
  if (r.rr())
5
5
  return "function" != typeof n
6
6
  ? null
7
- : je.ra().Nn(function (r) {
7
+ : je.ra().En(function (r) {
8
8
  return n(r[0]), r.slice(1);
9
9
  });
10
10
  }
@@ -7,9 +7,9 @@ export function automaticallyShowInAppMessages() {
7
7
  if (!r.rr()) return;
8
8
  rs();
9
9
  const s = je.ra();
10
- if (null == s.Fn()) {
10
+ if (null == s.Gn()) {
11
11
  const r = subscribeToInAppMessage((s) => showInAppMessage(s));
12
- s.On(r);
12
+ s.Nn(r);
13
13
  }
14
- return s.Fn();
14
+ return s.Gn();
15
15
  }
@@ -13,7 +13,7 @@ import {
13
13
  import { isURIJavascriptOrData as tt } from "../../util/url-utils.js";
14
14
  import { KeyCodes as Ce } from "../../util/key-codes.js";
15
15
  import { setupInAppMessageUI as rs } from "../../ui/js/index.js";
16
- import { logger as E } from "../../../shared-lib/index.js";
16
+ import { logger as b } from "../../../shared-lib/index.js";
17
17
  import { toRgba as ke } from "../../util/color-utils.js";
18
18
  import { isIFrame as St } from "../utils/in-app-message-utils.js";
19
19
  import Je from "../../l10n/l10n-manager-factory.js";
@@ -29,7 +29,7 @@ export function showInAppMessage(e, t, s) {
29
29
  if ((rs(), null == e)) return !1;
30
30
  if (e instanceof ControlMessage)
31
31
  return (
32
- E.info(
32
+ b.info(
33
33
  "User received control for a multivariate test, logging to Braze servers.",
34
34
  ),
35
35
  logInAppMessageImpression(e),
@@ -41,7 +41,7 @@ export function showInAppMessage(e, t, s) {
41
41
  const o = e instanceof HtmlMessage;
42
42
  if (o && !e.trusted && !r.dr())
43
43
  return (
44
- E.error(
44
+ b.error(
45
45
  'HTML in-app messages are disabled. Use the "allowUserSuppliedJavascript" option for braze.initialize to enable these messages.',
46
46
  ),
47
47
  !1
@@ -49,14 +49,14 @@ export function showInAppMessage(e, t, s) {
49
49
  if ((null == t && (t = document.body), e.zo())) {
50
50
  if (t.querySelectorAll(".ab-modal-interactions").length > 0)
51
51
  return (
52
- E.info(
52
+ b.info(
53
53
  `Cannot show in-app message ${e.message} because another message is being shown.`,
54
54
  ),
55
55
  !1
56
56
  );
57
57
  }
58
- if (no.ja()) {
59
- const t = no.ba();
58
+ if (no.da()) {
59
+ const t = no.ga();
60
60
  if (
61
61
  (t === Ue.PORTRAIT && e.orientation === De.LANDSCAPE) ||
62
62
  (t === Ue.LANDSCAPE && e.orientation === De.PORTRAIT)
@@ -64,7 +64,7 @@ export function showInAppMessage(e, t, s) {
64
64
  const s = t === Ue.PORTRAIT ? "portrait" : "landscape",
65
65
  o = e.orientation === De.PORTRAIT ? "portrait" : "landscape";
66
66
  return (
67
- E.info(
67
+ b.info(
68
68
  `Not showing ${o} in-app message ${e.message} because the screen is currently ${s}`,
69
69
  ),
70
70
  !1
@@ -83,7 +83,7 @@ export function showInAppMessage(e, t, s) {
83
83
  } else e.clickAction === Le.URI && (t = tt(e.uri));
84
84
  if (t)
85
85
  return (
86
- E.error(
86
+ b.error(
87
87
  'Javascript click actions are disabled. Use the "allowUserSuppliedJavascript" option for braze.initialize to enable these actions.',
88
88
  ),
89
89
  !1
@@ -95,7 +95,7 @@ export function showInAppMessage(e, t, s) {
95
95
  (i.className += be(e)),
96
96
  e.language && !o && (i.lang = e.language),
97
97
  e.Bo() && (i.id = e.htmlId),
98
- r.er(U.wa) && (i.style.zIndex = (r.er(U.wa) + 1).toString()),
98
+ r.er(U.ja) && (i.style.zIndex = (r.er(U.ja) + 1).toString()),
99
99
  t.appendChild(i),
100
100
  e.Mo())
101
101
  ) {
@@ -114,7 +114,7 @@ export function showInAppMessage(e, t, s) {
114
114
  if (
115
115
  ((s.className = "ab-page-blocker"),
116
116
  e.Mo() || (s.style.backgroundColor = ke(e.frameColor)),
117
- r.er(U.wa) && (s.style.zIndex = r.er(U.wa).toString()),
117
+ r.er(U.ja) && (s.style.zIndex = r.er(U.ja).toString()),
118
118
  i.appendChild(s),
119
119
  !r.er(U.oh))
120
120
  ) {
@@ -161,13 +161,13 @@ export function showInAppMessage(e, t, s) {
161
161
  "function" == typeof s && s();
162
162
  },
163
163
  (e) => {
164
- E.info(e);
164
+ b.info(e);
165
165
  },
166
- r.er(U.va),
167
- r.er(U.wa),
166
+ r.er(U.ba),
167
+ r.er(U.ja),
168
168
  r.er(U.sr),
169
169
  t,
170
- Je.ra().ya(),
170
+ Je.ra().wa(),
171
171
  );
172
172
  return (o || n) && (i.appendChild(a), e.eh(i)), !0;
173
173
  }
@@ -12,11 +12,11 @@ const ra = {
12
12
  r.ue(),
13
13
  r.ht(),
14
14
  r.er(U.xa),
15
+ r.er(U.ya),
15
16
  r.er(U.Ma),
16
- r.er(U._a),
17
17
  r.l(),
18
+ r.er(U._a),
18
19
  r.er(U.ka),
19
- r.er(U.qa),
20
20
  r.p(),
21
21
  )),
22
22
  ra.na
@@ -1,6 +1,6 @@
1
1
  import { isArray as g, isEqual as oi } from "../util/code-utils.js";
2
2
  import ui from "../models/push-token.js";
3
- import { logger as E, EncodingUtils as ai } from "../../shared-lib/index.js";
3
+ import { logger as b, EncodingUtils as ai } from "../../shared-lib/index.js";
4
4
  import { STORAGE_KEYS as s } from "../managers/storage-manager.js";
5
5
  import { User } from "../User/index.js";
6
6
  import It from "./utils/push-utils.js";
@@ -16,7 +16,7 @@ export default class na {
16
16
  (this.h = u),
17
17
  (this.ou = a),
18
18
  (this.uu = h),
19
- (this.C = c),
19
+ (this.j = c),
20
20
  (this.iu = i),
21
21
  (this.tu = t),
22
22
  (this.eu = e),
@@ -26,7 +26,7 @@ export default class na {
26
26
  (this.h = u),
27
27
  (this.ou = a || !1),
28
28
  (this.uu = h || !1),
29
- (this.C = c),
29
+ (this.j = c),
30
30
  (this.hu = It.cu()),
31
31
  (this.fu = It.lu());
32
32
  }
@@ -38,11 +38,11 @@ export default class na {
38
38
  .then((i) => {
39
39
  i
40
40
  ? this.bu(t, e, s, r)
41
- : (E.error("Failed to unsubscribe device from push."),
41
+ : (b.error("Failed to unsubscribe device from push."),
42
42
  "function" == typeof r && r(!1));
43
43
  })
44
44
  .catch((i) => {
45
- E.error("Push unsubscription error: " + i),
45
+ b.error("Push unsubscription error: " + i),
46
46
  "function" == typeof r && r(!1);
47
47
  });
48
48
  }
@@ -71,7 +71,7 @@ export default class na {
71
71
  (n = btoa(String.fromCharCode.apply(null, i))),
72
72
  (o = btoa(String.fromCharCode.apply(null, t)));
73
73
  } catch (i) {
74
- E.error(hi(i));
74
+ b.error(hi(i));
75
75
  }
76
76
  const a = ((i) => {
77
77
  let t;
@@ -94,7 +94,7 @@ export default class na {
94
94
  ku(i, t) {
95
95
  var e;
96
96
  null === (e = this.iu) || void 0 === e || e.wu(!1),
97
- E.info(i),
97
+ b.info(i),
98
98
  "function" == typeof t && t(!1);
99
99
  }
100
100
  Pu(i, t, e, s) {
@@ -129,7 +129,7 @@ export default class na {
129
129
  s,
130
130
  )
131
131
  : "granted" === t.permission &&
132
- (E.info("Device successfully subscribed to push."),
132
+ (b.info("Device successfully subscribed to push."),
133
133
  this.yu(t.deviceToken, new Date(), e));
134
134
  }
135
135
  requestPermission(i, t, e) {
@@ -142,7 +142,7 @@ export default class na {
142
142
  case "denied":
143
143
  return void ("function" == typeof e && e());
144
144
  default:
145
- E.error("Received unexpected permission result " + s);
145
+ b.error("Received unexpected permission result " + s);
146
146
  }
147
147
  };
148
148
  let r = !1;
@@ -165,14 +165,14 @@ export default class na {
165
165
  i.pushManager
166
166
  .subscribe(r)
167
167
  .then((i) => {
168
- E.info("Device successfully subscribed to push."),
168
+ b.info("Device successfully subscribed to push."),
169
169
  this.yu(i, new Date(), e);
170
170
  })
171
171
  .catch((i) => {
172
172
  It.isPushBlocked()
173
- ? (E.info("Permission for push notifications was denied."),
173
+ ? (b.info("Permission for push notifications was denied."),
174
174
  "function" == typeof s && s(!1))
175
- : (E.error("Push subscription failed: " + i),
175
+ : (b.error("Push subscription failed: " + i),
176
176
  "function" == typeof s && s(!0));
177
177
  });
178
178
  }
@@ -185,7 +185,7 @@ export default class na {
185
185
  i &&
186
186
  "function" == typeof i.update &&
187
187
  i.update().catch((i) => {
188
- E.info("ServiceWorker update failed: " + i);
188
+ b.info("ServiceWorker update failed: " + i);
189
189
  }),
190
190
  i
191
191
  ),
@@ -194,11 +194,11 @@ export default class na {
194
194
  }
195
195
  Su(i) {
196
196
  this.ou ||
197
- (i.unregister(), E.info("Service worker successfully unregistered."));
197
+ (i.unregister(), b.info("Service worker successfully unregistered."));
198
198
  }
199
199
  subscribe(i, t) {
200
200
  if (!It.isPushSupported())
201
- return E.info(na.Au), void ("function" == typeof t && t(!1));
201
+ return b.info(na.Au), void ("function" == typeof t && t(!1));
202
202
  if (this.hu) {
203
203
  if (!this.ou && null != window.location) {
204
204
  let i = this.su;
@@ -212,9 +212,9 @@ export default class na {
212
212
  "Notifications from this site are blocked. This may be a temporary embargo or a permanent denial.",
213
213
  t,
214
214
  );
215
- if (this.h && !this.h.ju() && 0 === this.h.Ot())
215
+ if (this.h && !this.h.ju() && 0 === this.h.Qt())
216
216
  return (
217
- E.info(
217
+ b.info(
218
218
  "Waiting for VAPID key from server config before subscribing to push.",
219
219
  ),
220
220
  void this.h.xu(() => {
@@ -222,7 +222,7 @@ export default class na {
222
222
  })
223
223
  );
224
224
  const e = () => {
225
- E.info("Permission for push notifications was denied."),
225
+ b.info("Permission for push notifications was denied."),
226
226
  "function" == typeof t && t(!1);
227
227
  },
228
228
  r = () => {
@@ -230,7 +230,7 @@ export default class na {
230
230
  It.isPushBlocked() &&
231
231
  (i +=
232
232
  " The browser has automatically blocked further permission requests for a period (probably 1 week)."),
233
- E.info(i),
233
+ b.info(i),
234
234
  "function" == typeof t && t(!0);
235
235
  },
236
236
  n = It.isPushPermissionGranted(),
@@ -244,7 +244,7 @@ export default class na {
244
244
  .then((e) => {
245
245
  if (null == e)
246
246
  return (
247
- E.error(
247
+ b.error(
248
248
  "No service worker registration. Set the `manageServiceWorkerExternally` initialization option to false or ensure that your service worker is registered before calling registerPush.",
249
249
  ),
250
250
  void ("function" == typeof t && t(!0))
@@ -264,7 +264,7 @@ export default class na {
264
264
  let n,
265
265
  u = null,
266
266
  a = null;
267
- if ((this.C && (n = this.C.Rt(s.Tt.Uu)), n && !g(n))) {
267
+ if ((this.j && (n = this.j.St(s.It.Uu)), n && !g(n))) {
268
268
  let i;
269
269
  try {
270
270
  i = ui._u(n).Wu;
@@ -285,51 +285,51 @@ export default class na {
285
285
  r.options.applicationServerKey.byteLength > 0 &&
286
286
  !oi(o, new Uint8Array(r.options.applicationServerKey))
287
287
  ? (r.options.applicationServerKey.byteLength > 12
288
- ? E.info(
288
+ ? b.info(
289
289
  "Device was already subscribed to push using a different VAPID provider, creating new subscription.",
290
290
  )
291
- : E.info(
291
+ : b.info(
292
292
  "Attempting to upgrade a gcm_sender_id-based push registration to VAPID - depending on the browser this may or may not result in the same gcm_sender_id-based subscription.",
293
293
  ),
294
294
  this.pu(r, e, o, i, t))
295
295
  : r.expirationTime &&
296
296
  new Date(r.expirationTime).valueOf() <=
297
297
  new Date().valueOf()
298
- ? (E.info(
298
+ ? (b.info(
299
299
  "Push subscription is expired, creating new subscription.",
300
300
  ),
301
301
  this.pu(r, e, o, i, t))
302
302
  : n && g(n)
303
303
  ? this.pu(r, e, o, i, t)
304
304
  : null == a
305
- ? (E.info(
305
+ ? (b.info(
306
306
  "No push subscription creation date found, creating new subscription.",
307
307
  ),
308
308
  this.pu(r, e, o, i, t))
309
309
  : a.valueOf() <= new Date().valueOf()
310
- ? (E.info(
310
+ ? (b.info(
311
311
  "Push subscription older than 6 months, creating new subscription.",
312
312
  ),
313
313
  this.pu(r, e, o, i, t))
314
- : (E.info(
314
+ : (b.info(
315
315
  "Device already subscribed to push, sending existing subscription to backend.",
316
316
  ),
317
317
  this.yu(r, u, i));
318
318
  } else this.bu(e, o, i, t);
319
319
  })
320
320
  .catch((i) => {
321
- E.error("Error checking current push subscriptions: " + i);
321
+ b.error("Error checking current push subscriptions: " + i);
322
322
  });
323
323
  })
324
324
  .catch((i) => {
325
- E.error("ServiceWorker registration failed: " + i);
325
+ b.error("ServiceWorker registration failed: " + i);
326
326
  });
327
327
  };
328
328
  this.requestPermission(o, r, e);
329
329
  } else if (this.fu) {
330
330
  if (null == this.nu || "" === this.nu)
331
331
  return (
332
- E.error(
332
+ b.error(
333
333
  "You must supply the safariWebsitePushId initialization option in order to use registerPush on Safari",
334
334
  ),
335
335
  void ("function" == typeof t && t(!0))
@@ -340,7 +340,7 @@ export default class na {
340
340
  }
341
341
  unsubscribe(i, t) {
342
342
  if (!It.isPushSupported())
343
- return E.info(na.Au), void ("function" == typeof t && t());
343
+ return b.info(na.Au), void ("function" == typeof i && i());
344
344
  this.hu
345
345
  ? navigator.serviceWorker.getRegistration(this.su).then((e) => {
346
346
  e
@@ -353,33 +353,33 @@ export default class na {
353
353
  .unsubscribe()
354
354
  .then((s) => {
355
355
  s
356
- ? (E.info(
356
+ ? (b.info(
357
357
  "Device successfully unsubscribed from push.",
358
358
  ),
359
359
  "function" == typeof i && i())
360
- : (E.error(
360
+ : (b.error(
361
361
  "Failed to unsubscribe device from push.",
362
362
  ),
363
363
  "function" == typeof t && t()),
364
364
  this.Su(e);
365
365
  })
366
366
  .catch((i) => {
367
- E.error("Push unsubscription error: " + i),
367
+ b.error("Push unsubscription error: " + i),
368
368
  "function" == typeof t && t();
369
369
  }))
370
- : (E.info("Device already unsubscribed from push."),
370
+ : (b.info("Device already unsubscribed from push."),
371
371
  "function" == typeof i && i());
372
372
  })
373
373
  .catch((i) => {
374
- E.error("Error unsubscribing from push: " + i),
374
+ b.error("Error unsubscribing from push: " + i),
375
375
  "function" == typeof t && t();
376
376
  })
377
- : (E.info("Device already unsubscribed from push."),
377
+ : (b.info("Device already unsubscribed from push."),
378
378
  "function" == typeof i && i());
379
379
  })
380
380
  : this.fu &&
381
381
  (this.vu(),
382
- E.info("Device unsubscribed from push."),
382
+ b.info("Device unsubscribed from push."),
383
383
  "function" == typeof i && i());
384
384
  }
385
385
  }
@@ -0,0 +1,35 @@
1
+ import r from "../managers/braze-instance.js";
2
+ import { STORAGE_KEYS as s } from "../managers/storage-manager.js";
3
+ import ui from "../models/push-token.js";
4
+ import l from "../util/net.js";
5
+ import h from "../util/request-header-utils.js";
6
+ export function unregisterPushTokenOnServer() {
7
+ if (!r.rr()) return;
8
+ const e = r.m();
9
+ if (!e) return;
10
+ const t = r.p(),
11
+ n = null == t ? void 0 : t.St(s.It.Uu);
12
+ if (!n || "object" != typeof n || Array.isArray(n)) return;
13
+ const o = ui._u(n);
14
+ if (!o.endpoint) return;
15
+ const i = e.Z({}, !0);
16
+ i.push_token = o.endpoint;
17
+ const a = e.tt(i, h.it.qa);
18
+ e.et(
19
+ i,
20
+ (n = -1) => {
21
+ r.rr() &&
22
+ (h.nt(t, h.it.qa, new Date().valueOf()),
23
+ -1 !== n && a.push(["X-Braze-Req-Tokens-Remaining", n.toString()]),
24
+ l.ot({
25
+ url: `${e.ht()}/push/unregister`,
26
+ data: i,
27
+ headers: a,
28
+ lt: (r) => {
29
+ e.ut(i, r, a) && e.ct();
30
+ },
31
+ }));
32
+ },
33
+ h.it.qa,
34
+ );
35
+ }
@@ -1,5 +1,6 @@
1
1
  import r from "../managers/braze-instance.js";
2
2
  import ra from "./push-manager-factory.js";
3
+ import { unregisterPushTokenOnServer as gr } from "./unregister-push-token-on-server.js";
3
4
  export function unregisterPush(e, n) {
4
- if (r.rr()) return ra.ra().unsubscribe(e, n);
5
+ if (r.rr()) return gr(), ra.ra().unsubscribe(e, n);
5
6
  }