@braze/web-sdk 6.3.1 → 6.5.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 (159) hide show
  1. package/README.md +1 -1
  2. package/index.d.ts +38 -5
  3. package/package.json +1 -1
  4. package/shared-lib/encoding-utils.js +3 -3
  5. package/shared-lib/event-types.js +30 -30
  6. package/shared-lib/guid.js +1 -1
  7. package/shared-lib/indexed-db-adapter.js +60 -60
  8. package/shared-lib/logger.js +7 -7
  9. package/shared-lib/supported-options.js +24 -23
  10. package/src/Banner/banner-provider.js +95 -81
  11. package/src/Banner/banner.js +9 -9
  12. package/src/Banner/constants.js +4 -0
  13. package/src/Banner/display/banner-to-html.js +3 -3
  14. package/src/Banner/display/destroy-banner-html.js +3 -3
  15. package/src/Banner/display/detect-banner-impressions.js +16 -16
  16. package/src/Banner/get-all-banners.js +4 -4
  17. package/src/Banner/get-banner.js +5 -4
  18. package/src/Banner/index.js +2 -0
  19. package/src/Banner/log-banner-click.js +2 -2
  20. package/src/Banner/log-banner-impressions.js +6 -6
  21. package/src/Banner/request-banners-refresh.js +18 -20
  22. package/src/Banner/subscribe-to-banners-updates.js +5 -5
  23. package/src/Banner/ui/insert-banner.js +17 -14
  24. package/src/Card/card-manager-factory.js +6 -6
  25. package/src/Card/card-manager.js +28 -28
  26. package/src/Card/constants.js +1 -0
  27. package/src/Card/display/card-display.js +7 -7
  28. package/src/Card/log-card-dismissal.js +3 -3
  29. package/src/Card/log-content-card-click.js +3 -3
  30. package/src/Card/log-content-card-impressions.js +6 -6
  31. package/src/Card/models/captioned-image.js +3 -3
  32. package/src/Card/models/card.js +9 -9
  33. package/src/Card/models/classic-card.js +3 -3
  34. package/src/Card/models/control-card.js +3 -3
  35. package/src/Card/models/image-only.js +3 -3
  36. package/src/ContentCards/content-cards-provider-factory.js +6 -2
  37. package/src/ContentCards/content-cards-provider.js +101 -87
  38. package/src/ContentCards/content-cards.js +4 -4
  39. package/src/ContentCards/request-content-cards-refresh.js +1 -1
  40. package/src/ContentCards/subscribe-to-content-cards-updates.js +4 -4
  41. package/src/ContentCards/ui/show-content-cards.js +5 -5
  42. package/src/Core/add-sdk-metadata.js +2 -2
  43. package/src/Core/change-user.js +1 -1
  44. package/src/Core/disable-sdk.js +5 -5
  45. package/src/Core/enable-sdk.js +3 -3
  46. package/src/Core/get-device-id.js +2 -2
  47. package/src/Core/get-user.js +1 -1
  48. package/src/Core/handle-braze-action.js +3 -3
  49. package/src/Core/is-disabled.js +1 -1
  50. package/src/Core/log-custom-event.js +7 -7
  51. package/src/Core/log-purchase.js +4 -4
  52. package/src/Core/open-session.js +6 -6
  53. package/src/Core/wipe-data.js +3 -3
  54. package/src/DUST/dust-connection-core.js +23 -0
  55. package/src/DUST/dust-provider-factory.js +22 -0
  56. package/src/DUST/dust-provider.js +520 -0
  57. package/src/DUST/dust-shared-worker-code.js +2 -0
  58. package/src/DUST/dust-shared-worker-impl.js +240 -0
  59. package/src/DUST/dust-worker-bridge.js +136 -0
  60. package/src/DUST/index.js +13 -0
  61. package/src/DUST/subscribe-to-dust.js +24 -0
  62. package/src/DUST/types.js +1 -0
  63. package/src/FeatureFlags/feature-flag-factory.js +8 -8
  64. package/src/FeatureFlags/feature-flag.js +6 -6
  65. package/src/FeatureFlags/feature-flags-provider-factory.js +9 -9
  66. package/src/FeatureFlags/feature-flags-provider.js +98 -84
  67. package/src/FeatureFlags/get-all-feature-flags.js +3 -3
  68. package/src/FeatureFlags/get-feature-flag.js +3 -3
  69. package/src/FeatureFlags/log-feature-flag-impression.js +7 -7
  70. package/src/FeatureFlags/refresh-feature-flags.js +5 -5
  71. package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +4 -4
  72. package/src/InAppMessage/constants.js +4 -0
  73. package/src/InAppMessage/defer-in-app-message.js +2 -2
  74. package/src/InAppMessage/display/get-animation-effect.js +1 -1
  75. package/src/InAppMessage/display/html-message-to-html.js +6 -6
  76. package/src/InAppMessage/display/in-app-message-to-html.js +34 -34
  77. package/src/InAppMessage/display/modal-utils.js +14 -14
  78. package/src/InAppMessage/get-deferred-in-app-message.js +2 -2
  79. package/src/InAppMessage/in-app-message-factory.js +4 -4
  80. package/src/InAppMessage/in-app-message-manager-factory.js +7 -7
  81. package/src/InAppMessage/in-app-message-manager.js +98 -98
  82. package/src/InAppMessage/log-in-app-message-button-click.js +12 -12
  83. package/src/InAppMessage/log-in-app-message-click.js +11 -11
  84. package/src/InAppMessage/log-in-app-message-html-click.js +9 -9
  85. package/src/InAppMessage/log-in-app-message-impression.js +8 -8
  86. package/src/InAppMessage/models/control-message.js +5 -5
  87. package/src/InAppMessage/models/full-screen-message.js +21 -21
  88. package/src/InAppMessage/models/html-message.js +18 -18
  89. package/src/InAppMessage/models/in-app-message-button.js +7 -7
  90. package/src/InAppMessage/models/in-app-message.js +145 -145
  91. package/src/InAppMessage/models/modal-message.js +21 -21
  92. package/src/InAppMessage/models/slide-up-message.js +27 -27
  93. package/src/InAppMessage/models/templated-in-app-message.js +8 -8
  94. package/src/InAppMessage/subscribe-to-in-app-message.js +2 -2
  95. package/src/InAppMessage/ui/automatically-show-in-app-messages.js +5 -5
  96. package/src/InAppMessage/ui/remove-all-visible-in-app-messages.js +18 -0
  97. package/src/InAppMessage/ui/show-in-app-message.js +36 -36
  98. package/src/Push/is-push-blocked.js +2 -2
  99. package/src/Push/is-push-permission-granted.js +2 -2
  100. package/src/Push/is-push-supported.js +2 -2
  101. package/src/Push/push-manager-factory.js +15 -15
  102. package/src/Push/push-manager.js +97 -97
  103. package/src/Push/request-push-permission.js +1 -1
  104. package/src/Push/unregister-push.js +1 -1
  105. package/src/Push/utils/push-utils.js +17 -17
  106. package/src/User/user-manager.js +24 -24
  107. package/src/User/user.js +55 -55
  108. package/src/common/constants.js +8 -10
  109. package/src/common/content-cards-display.js +40 -40
  110. package/src/common/event-logger.js +8 -8
  111. package/src/common/properties-base.js +16 -16
  112. package/src/l10n/l10n-manager-factory.js +11 -11
  113. package/src/l10n/l10n-manager.js +2 -2
  114. package/src/managers/auth-manager.js +30 -30
  115. package/src/managers/braze-instance.js +170 -162
  116. package/src/managers/device-manager.js +24 -24
  117. package/src/managers/network-manager.js +149 -149
  118. package/src/managers/server-config-manager.js +140 -95
  119. package/src/managers/session-manager.js +39 -39
  120. package/src/managers/storage-manager-factory.js +10 -10
  121. package/src/managers/storage-manager.js +145 -141
  122. package/src/managers/subscription-manager.js +11 -11
  123. package/src/managers/utils.js +1 -1
  124. package/src/models/backend-errors.js +5 -5
  125. package/src/models/braze-event.js +11 -11
  126. package/src/models/device.js +3 -3
  127. package/src/models/identifier.js +16 -16
  128. package/src/models/push-token.js +13 -13
  129. package/src/models/request-result.js +3 -3
  130. package/src/models/server-config.js +45 -37
  131. package/src/request-controller.js +163 -158
  132. package/src/triggers/models/custom-event-data.js +5 -5
  133. package/src/triggers/models/custom-event-property-data.js +6 -6
  134. package/src/triggers/models/filter-set.js +10 -10
  135. package/src/triggers/models/filter.js +27 -27
  136. package/src/triggers/models/in-app-message-click-data.js +13 -13
  137. package/src/triggers/models/purchase-data.js +2 -2
  138. package/src/triggers/models/purchase-property-data.js +6 -6
  139. package/src/triggers/models/push-click-data.js +6 -6
  140. package/src/triggers/models/trigger-condition.js +47 -47
  141. package/src/triggers/models/trigger-events.js +3 -3
  142. package/src/triggers/models/trigger.js +36 -36
  143. package/src/triggers/triggers-provider-factory.js +5 -5
  144. package/src/triggers/triggers-provider.js +63 -63
  145. package/src/ui/js/attach-css.js +3 -3
  146. package/src/ui/js/load-font-awesome.js +2 -2
  147. package/src/util/base-device-parser.js +9 -9
  148. package/src/util/braze-actions.js +5 -5
  149. package/src/util/browser-detector.js +37 -37
  150. package/src/util/client-hints-parser.js +11 -11
  151. package/src/util/component-utils.js +5 -5
  152. package/src/util/dom-utils.js +13 -13
  153. package/src/util/html-display-utils.js +7 -7
  154. package/src/util/key-codes.js +1 -1
  155. package/src/util/net.js +5 -5
  156. package/src/util/request-header-utils.js +27 -27
  157. package/src/util/user-agent-parser.js +21 -21
  158. package/src/util/validation-utils.js +17 -17
  159. package/src/util/window-utils.js +3 -3
@@ -1,43 +1,43 @@
1
- import { isArray as D, isEqual as ii } from "../util/code-utils.js";
2
- import ti from "../models/push-token.js";
3
- import { logger as E, EncodingUtils as ei } from "../../shared-lib/index.js";
1
+ import { isArray as R, isEqual as ni } from "../util/code-utils.js";
2
+ import oi from "../models/push-token.js";
3
+ import { logger as E, EncodingUtils as ui } 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
- import yt from "./utils/push-utils.js";
7
- import { getErrorMessage as si } from "../util/error-utils.js";
6
+ import vt from "./utils/push-utils.js";
7
+ import { getErrorMessage as ai } from "../util/error-utils.js";
8
8
  export default class na {
9
9
  constructor(i, t, e, s, r, n, o, u, a, h, c) {
10
- (this.en = i),
11
- (this.sn = t),
12
- (this.on = e),
13
- (this.un = r),
14
- (this.an = n),
15
- (this.hn = o),
10
+ (this.iu = i),
11
+ (this.tu = t),
12
+ (this.eu = e),
13
+ (this.su = r),
14
+ (this.ru = n),
15
+ (this.nu = o),
16
16
  (this.h = u),
17
- (this.cn = a),
18
- (this.fn = h),
19
- (this.j = c),
20
- (this.en = i),
21
- (this.sn = t),
22
- (this.on = e),
23
- (this.ln = s + "/safari/" + t),
24
- (this.un = r || "/service-worker.js"),
25
- (this.hn = o),
17
+ (this.ou = a),
18
+ (this.uu = h),
19
+ (this.B = c),
20
+ (this.iu = i),
21
+ (this.tu = t),
22
+ (this.eu = e),
23
+ (this.au = s + "/safari/" + t),
24
+ (this.su = r || "/service-worker.js"),
25
+ (this.nu = o),
26
26
  (this.h = u),
27
- (this.cn = a || !1),
28
- (this.fn = h || !1),
29
- (this.j = c),
30
- (this.dn = yt.pn()),
31
- (this.bn = yt.yn());
27
+ (this.ou = a || !1),
28
+ (this.uu = h || !1),
29
+ (this.B = c),
30
+ (this.hu = vt.cu()),
31
+ (this.fu = vt.lu());
32
32
  }
33
- mn() {
34
- return this.fn;
33
+ du() {
34
+ return this.uu;
35
35
  }
36
- gn(i, t, e, s, r) {
36
+ pu(i, t, e, s, r) {
37
37
  i.unsubscribe()
38
38
  .then((i) => {
39
39
  i
40
- ? this.vn(t, e, s, r)
40
+ ? this.bu(t, e, s, r)
41
41
  : (E.error("Failed to unsubscribe device from push."),
42
42
  "function" == typeof r && r(!1));
43
43
  })
@@ -46,7 +46,7 @@ export default class na {
46
46
  "function" == typeof r && r(!1);
47
47
  });
48
48
  }
49
- wn(i, t, e) {
49
+ yu(i, t, e) {
50
50
  var s;
51
51
  const r = ((i) => {
52
52
  if ("string" == typeof i) return i;
@@ -55,9 +55,9 @@ export default class na {
55
55
  let t = i.endpoint;
56
56
  const e = i;
57
57
  return (
58
- e.kn &&
59
- -1 === i.endpoint.indexOf(e.kn) &&
60
- (t = i.endpoint + "/" + e.kn),
58
+ e.mu &&
59
+ -1 === i.endpoint.indexOf(e.mu) &&
60
+ (t = i.endpoint + "/" + e.mu),
61
61
  t
62
62
  );
63
63
  })(i);
@@ -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(si(i));
74
+ E.error(ai(i));
75
75
  }
76
76
  const a = ((i) => {
77
77
  let t;
@@ -84,53 +84,53 @@ export default class na {
84
84
  .replace(/\//g, "_")
85
85
  : null;
86
86
  })(u);
87
- null === (s = this.en) || void 0 === s || s.Pn(r, t, n, o, a),
87
+ null === (s = this.iu) || void 0 === s || s.gu(r, t, n, o, a),
88
88
  r && "function" == typeof e && e(r, n, o);
89
89
  }
90
- Dn() {
90
+ vu() {
91
91
  var i;
92
- null === (i = this.en) || void 0 === i || i.Sn(!0);
92
+ null === (i = this.iu) || void 0 === i || i.wu(!0);
93
93
  }
94
- An(i, t) {
94
+ ku(i, t) {
95
95
  var e;
96
- null === (e = this.en) || void 0 === e || e.Sn(!1),
96
+ null === (e = this.iu) || void 0 === e || e.wu(!1),
97
97
  E.info(i),
98
98
  "function" == typeof t && t(!1);
99
99
  }
100
- jn(i, t, e, s) {
100
+ Pu(i, t, e, s) {
101
101
  var r;
102
102
  if ("default" === t.permission)
103
103
  try {
104
104
  window.safari.pushNotification.requestPermission(
105
- this.ln,
105
+ this.au,
106
106
  i,
107
107
  {
108
- api_key: this.sn,
108
+ api_key: this.tu,
109
109
  device_id:
110
- (null === (r = this.on) || void 0 === r ? void 0 : r.fe().id) ||
110
+ (null === (r = this.eu) || void 0 === r ? void 0 : r.ve().id) ||
111
111
  "",
112
112
  },
113
113
  (t) => {
114
114
  "granted" === t.permission &&
115
- this.en &&
116
- this.en.setPushNotificationSubscriptionType(
115
+ this.iu &&
116
+ this.iu.setPushNotificationSubscriptionType(
117
117
  User.NotificationSubscriptionTypes.OPTED_IN,
118
118
  ),
119
- this.jn(i, t, e, s);
119
+ this.Pu(i, t, e, s);
120
120
  },
121
121
  );
122
122
  } catch (i) {
123
- this.An("Could not request permission for push: " + i, s);
123
+ this.ku("Could not request permission for push: " + i, s);
124
124
  }
125
125
  else
126
126
  "denied" === t.permission
127
- ? this.An(
127
+ ? this.ku(
128
128
  "The user has blocked notifications from this site, or Safari push is not configured in the Braze dashboard.",
129
129
  s,
130
130
  )
131
131
  : "granted" === t.permission &&
132
132
  (E.info("Device successfully subscribed to push."),
133
- this.wn(t.deviceToken, new Date(), e));
133
+ this.yu(t.deviceToken, new Date(), e));
134
134
  }
135
135
  requestPermission(i, t, e) {
136
136
  const s = (s) => {
@@ -159,27 +159,27 @@ export default class na {
159
159
  : (r = !0);
160
160
  }
161
161
  }
162
- vn(i, t, e, s) {
162
+ bu(i, t, e, s) {
163
163
  const r = { userVisibleOnly: !0 };
164
164
  null != t && (r.applicationServerKey = t),
165
165
  i.pushManager
166
166
  .subscribe(r)
167
167
  .then((i) => {
168
168
  E.info("Device successfully subscribed to push."),
169
- this.wn(i, new Date(), e);
169
+ this.yu(i, new Date(), e);
170
170
  })
171
171
  .catch((i) => {
172
- yt.isPushBlocked()
172
+ vt.isPushBlocked()
173
173
  ? (E.info("Permission for push notifications was denied."),
174
174
  "function" == typeof s && s(!1))
175
175
  : (E.error("Push subscription failed: " + i),
176
176
  "function" == typeof s && s(!0));
177
177
  });
178
178
  }
179
- xn() {
180
- if (this.cn) return navigator.serviceWorker.getRegistration(this.un);
181
- const i = this.an ? { scope: this.an } : void 0;
182
- return navigator.serviceWorker.register(this.un, i).then(() =>
179
+ Du() {
180
+ if (this.ou) return navigator.serviceWorker.getRegistration(this.su);
181
+ const i = this.ru ? { scope: this.ru } : void 0;
182
+ return navigator.serviceWorker.register(this.su, i).then(() =>
183
183
  navigator.serviceWorker.ready.then(
184
184
  (i) => (
185
185
  i &&
@@ -192,32 +192,32 @@ export default class na {
192
192
  ),
193
193
  );
194
194
  }
195
- Nn(i) {
196
- this.cn ||
195
+ Su(i) {
196
+ this.ou ||
197
197
  (i.unregister(), E.info("Service worker successfully unregistered."));
198
198
  }
199
199
  subscribe(i, t) {
200
- if (!yt.isPushSupported())
201
- return E.info(na.Un), void ("function" == typeof t && t(!1));
202
- if (this.dn) {
203
- if (!this.cn && null != window.location) {
204
- let i = this.un;
200
+ if (!vt.isPushSupported())
201
+ return E.info(na.Au), void ("function" == typeof t && t(!1));
202
+ if (this.hu) {
203
+ if (!this.ou && null != window.location) {
204
+ let i = this.su;
205
205
  -1 === i.indexOf(window.location.host) &&
206
206
  (i = window.location.host + i),
207
207
  -1 === i.indexOf(window.location.protocol) &&
208
208
  (i = window.location.protocol + "//" + i);
209
209
  }
210
- if (yt.isPushBlocked())
211
- return void this.An(
210
+ if (vt.isPushBlocked())
211
+ return void this.ku(
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.Wn() && 0 === this.h.Ft())
215
+ if (this.h && !this.h.ju() && 0 === this.h.xt())
216
216
  return (
217
217
  E.info(
218
218
  "Waiting for VAPID key from server config before subscribing to push.",
219
219
  ),
220
- void this.h._n(() => {
220
+ void this.h.xu(() => {
221
221
  this.subscribe(i, t);
222
222
  })
223
223
  );
@@ -227,20 +227,20 @@ export default class na {
227
227
  },
228
228
  r = () => {
229
229
  let i = "Permission for push notifications was ignored.";
230
- yt.isPushBlocked() &&
230
+ vt.isPushBlocked() &&
231
231
  (i +=
232
232
  " The browser has automatically blocked further permission requests for a period (probably 1 week)."),
233
233
  E.info(i),
234
234
  "function" == typeof t && t(!0);
235
235
  },
236
- n = yt.isPushPermissionGranted(),
236
+ n = vt.isPushPermissionGranted(),
237
237
  o = () => {
238
238
  !n &&
239
- this.en &&
240
- this.en.setPushNotificationSubscriptionType(
239
+ this.iu &&
240
+ this.iu.setPushNotificationSubscriptionType(
241
241
  User.NotificationSubscriptionTypes.OPTED_IN,
242
242
  ),
243
- this.xn()
243
+ this.Du()
244
244
  .then((e) => {
245
245
  if (null == e)
246
246
  return (
@@ -258,16 +258,16 @@ export default class na {
258
258
  (null !=
259
259
  (null === (n = this.h) || void 0 === n
260
260
  ? void 0
261
- : n.Wn()) && (o = ei.Tn(this.h.Wn())),
261
+ : n.ju()) && (o = ui.Nu(this.h.ju())),
262
262
  r)
263
263
  ) {
264
264
  let n,
265
265
  u = null,
266
266
  a = null;
267
- if ((this.j && (n = this.j.lt(s.ct.In)), n && !D(n))) {
267
+ if ((this.B && (n = this.B.dt(s.ft.Uu)), n && !R(n))) {
268
268
  let i;
269
269
  try {
270
- i = ti.qn(n).Vn;
270
+ i = oi._u(n).Wu;
271
271
  } catch (t) {
272
272
  i = null;
273
273
  }
@@ -283,7 +283,7 @@ export default class na {
283
283
  r.options.applicationServerKey &&
284
284
  r.options.applicationServerKey.byteLength &&
285
285
  r.options.applicationServerKey.byteLength > 0 &&
286
- !ii(o, new Uint8Array(r.options.applicationServerKey))
286
+ !ni(o, new Uint8Array(r.options.applicationServerKey))
287
287
  ? (r.options.applicationServerKey.byteLength > 12
288
288
  ? E.info(
289
289
  "Device was already subscribed to push using a different VAPID provider, creating new subscription.",
@@ -291,31 +291,31 @@ export default class na {
291
291
  : E.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
- this.gn(r, e, o, i, t))
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
298
  ? (E.info(
299
299
  "Push subscription is expired, creating new subscription.",
300
300
  ),
301
- this.gn(r, e, o, i, t))
302
- : n && D(n)
303
- ? this.gn(r, e, o, i, t)
301
+ this.pu(r, e, o, i, t))
302
+ : n && R(n)
303
+ ? this.pu(r, e, o, i, t)
304
304
  : null == a
305
305
  ? (E.info(
306
306
  "No push subscription creation date found, creating new subscription.",
307
307
  ),
308
- this.gn(r, e, o, i, t))
308
+ this.pu(r, e, o, i, t))
309
309
  : a.valueOf() <= new Date().valueOf()
310
310
  ? (E.info(
311
311
  "Push subscription older than 6 months, creating new subscription.",
312
312
  ),
313
- this.gn(r, e, o, i, t))
313
+ this.pu(r, e, o, i, t))
314
314
  : (E.info(
315
315
  "Device already subscribed to push, sending existing subscription to backend.",
316
316
  ),
317
- this.wn(r, u, i));
318
- } else this.vn(e, o, i, t);
317
+ this.yu(r, u, i));
318
+ } else this.bu(e, o, i, t);
319
319
  })
320
320
  .catch((i) => {
321
321
  E.error("Error checking current push subscriptions: " + i);
@@ -326,29 +326,29 @@ export default class na {
326
326
  });
327
327
  };
328
328
  this.requestPermission(o, r, e);
329
- } else if (this.bn) {
330
- if (null == this.hn || "" === this.hn)
329
+ } else if (this.fu) {
330
+ if (null == this.nu || "" === this.nu)
331
331
  return (
332
332
  E.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))
336
336
  );
337
- const e = window.safari.pushNotification.permission(this.hn);
338
- this.jn(this.hn, e, i, t);
337
+ const e = window.safari.pushNotification.permission(this.nu);
338
+ this.Pu(this.nu, e, i, t);
339
339
  }
340
340
  }
341
341
  unsubscribe(i, t) {
342
- if (!yt.isPushSupported())
343
- return E.info(na.Un), void ("function" == typeof t && t());
344
- this.dn
345
- ? navigator.serviceWorker.getRegistration(this.un).then((e) => {
342
+ if (!vt.isPushSupported())
343
+ return E.info(na.Au), void ("function" == typeof t && t());
344
+ this.hu
345
+ ? navigator.serviceWorker.getRegistration(this.su).then((e) => {
346
346
  e
347
347
  ? e.pushManager
348
348
  .getSubscription()
349
349
  .then((s) => {
350
350
  s
351
- ? (this.Dn(),
351
+ ? (this.vu(),
352
352
  s
353
353
  .unsubscribe()
354
354
  .then((s) => {
@@ -361,7 +361,7 @@ export default class na {
361
361
  "Failed to unsubscribe device from push.",
362
362
  ),
363
363
  "function" == typeof t && t()),
364
- this.Nn(e);
364
+ this.Su(e);
365
365
  })
366
366
  .catch((i) => {
367
367
  E.error("Push unsubscription error: " + i),
@@ -377,10 +377,10 @@ export default class na {
377
377
  : (E.info("Device already unsubscribed from push."),
378
378
  "function" == typeof i && i());
379
379
  })
380
- : this.bn &&
381
- (this.Dn(),
380
+ : this.fu &&
381
+ (this.vu(),
382
382
  E.info("Device unsubscribed from push."),
383
383
  "function" == typeof i && i());
384
384
  }
385
385
  }
386
- na.Un = "Push notifications are not supported in this browser.";
386
+ na.Au = "Push notifications are not supported in this browser.";
@@ -2,7 +2,7 @@ import r from "../managers/braze-instance.js";
2
2
  import ra from "./push-manager-factory.js";
3
3
  export function requestPushPermission(n, o) {
4
4
  if (r.rr())
5
- return ra.ea().subscribe((o, t, e) => {
5
+ return ra.ra().subscribe((o, t, e) => {
6
6
  const s = r.nn();
7
7
  s && s.requestImmediateDataFlush(), "function" == typeof n && n(o, t, e);
8
8
  }, o);
@@ -1,5 +1,5 @@
1
1
  import r from "../managers/braze-instance.js";
2
2
  import ra from "./push-manager-factory.js";
3
3
  export function unregisterPush(e, n) {
4
- if (r.rr()) return ra.ea().unsubscribe(e, n);
4
+ if (r.rr()) return ra.ra().unsubscribe(e, n);
5
5
  }
@@ -1,46 +1,46 @@
1
- const yt = {
2
- pn: () =>
1
+ const vt = {
2
+ cu: () =>
3
3
  "serviceWorker" in navigator &&
4
4
  "undefined" != typeof ServiceWorkerRegistration &&
5
5
  "showNotification" in ServiceWorkerRegistration.prototype &&
6
6
  "PushManager" in window,
7
- yn: () =>
7
+ lu: () =>
8
8
  "safari" in window &&
9
9
  "pushNotification" in window.safari &&
10
10
  "function" == typeof window.safari.pushNotification.permission &&
11
11
  "function" == typeof window.safari.pushNotification.requestPermission,
12
- isPushSupported: () => yt.pn() || yt.yn(),
12
+ isPushSupported: () => vt.cu() || vt.lu(),
13
13
  isPushBlocked: () => {
14
14
  const o =
15
- yt.isPushSupported() &&
15
+ vt.isPushSupported() &&
16
16
  "Notification" in window &&
17
17
  null != window.Notification &&
18
18
  null != window.Notification.permission &&
19
19
  "denied" === window.Notification.permission,
20
20
  i =
21
- yt.isPushSupported() &&
21
+ vt.isPushSupported() &&
22
22
  (!("Notification" in window) || null == window.Notification);
23
23
  return o || i;
24
24
  },
25
25
  isPushPermissionGranted: () =>
26
- yt.isPushSupported() &&
26
+ vt.isPushSupported() &&
27
27
  "Notification" in window &&
28
28
  null != window.Notification &&
29
29
  null != window.Notification.permission &&
30
30
  "granted" === window.Notification.permission,
31
- Qi: () =>
32
- yt.isPushBlocked()
33
- ? { Ui: !1, reason: "blocked" }
34
- : yt.isPushSupported()
35
- ? yt.isPushPermissionGranted()
36
- ? { Ui: !1, reason: "permissionGranted" }
37
- : { Ui: !0 }
38
- : { Ui: !1, reason: "unsupported" },
39
- Vi: (o, i) =>
31
+ En: () =>
32
+ vt.isPushBlocked()
33
+ ? { Gn: !1, reason: "blocked" }
34
+ : vt.isPushSupported()
35
+ ? vt.isPushPermissionGranted()
36
+ ? { Gn: !1, reason: "permissionGranted" }
37
+ : { Gn: !0 }
38
+ : { Gn: !1, reason: "unsupported" },
39
+ Nn: (o, i) =>
40
40
  "blocked" === o
41
41
  ? `${i} containing a push prompt is not being shown because the user has already declined push permission prompt.`
42
42
  : "unsupported" === o
43
43
  ? `${i} containing a push prompt is not being shown because the browser doesn't support push notifications.`
44
44
  : `${i} containing a push prompt is not being shown because the user has already accepted the permission prompt.`,
45
45
  };
46
- export default yt;
46
+ export default vt;
@@ -1,38 +1,38 @@
1
1
  import _t from "../models/identifier.js";
2
2
  import { getByteLength as er } from "../util/string-utils.js";
3
- import ti from "../models/push-token.js";
3
+ import oi from "../models/push-token.js";
4
4
  import { logger as E, IndexedDBAdapter as et } from "../../shared-lib/index.js";
5
5
  import { STORAGE_KEYS as s } from "../managers/storage-manager.js";
6
6
  import { User } from "../User/index.js";
7
7
  export default class bt {
8
8
  constructor(t, s) {
9
- (this.h = t), (this.j = s), (this.h = t), (this.j = s);
9
+ (this.h = t), (this.B = s), (this.h = t), (this.B = s);
10
10
  }
11
11
  getUserId() {
12
- const t = this.j.tu(s.iu.su);
12
+ const t = this.B.$u(s.Ou.Cu);
13
13
  if (null == t) return null;
14
- let i = t.eu,
14
+ let i = t.Tu,
15
15
  e = er(i);
16
16
  if (e > User.mr) {
17
17
  for (; e > User.mr; ) (i = i.slice(0, i.length - 1)), (e = er(i));
18
- (t.eu = i), this.j.uu(s.iu.su, t);
18
+ (t.Tu = i), this.B.Iu(s.Ou.Cu, t);
19
19
  }
20
20
  return i;
21
21
  }
22
- ou(t) {
22
+ Ju(t) {
23
23
  const i = null == this.getUserId();
24
- this.j.uu(s.iu.su, new _t(t)), i && this.j.ru(t);
24
+ this.B.Iu(s.Ou.Cu, new _t(t)), i && this.B.Lu(t);
25
25
  }
26
26
  setCustomUserAttribute(t, s) {
27
- if (this.h.hu(t))
27
+ if (this.h.qu(t))
28
28
  return (
29
29
  E.info('Custom Attribute "' + t + '" is blocklisted, ignoring.'), !1
30
30
  );
31
31
  const i = {};
32
- return (i[t] = s), this.nu(User.lu, i, !0);
32
+ return (i[t] = s), this.zu(User.Bu, i, !0);
33
33
  }
34
- nu(t, s, i = !1, e = !1) {
35
- const u = this.j.mu(this.getUserId(), t, s);
34
+ zu(t, s, i = !1, e = !1) {
35
+ const u = this.B.Eu(this.getUserId(), t, s);
36
36
  let o = "",
37
37
  r = t,
38
38
  h = s;
@@ -47,27 +47,27 @@ export default class bt {
47
47
  u
48
48
  );
49
49
  }
50
- Pn(t, i, e, u, o) {
51
- this.nu("push_token", t, !1, !0),
52
- this.nu("custom_push_public_key", e, !1, !0),
53
- this.nu("custom_push_user_auth", u, !1, !0),
54
- this.nu("custom_push_vapid_public_key", o, !1, !0);
50
+ gu(t, i, e, u, o) {
51
+ this.zu("push_token", t, !1, !0),
52
+ this.zu("custom_push_public_key", e, !1, !0),
53
+ this.zu("custom_push_user_auth", u, !1, !0),
54
+ this.zu("custom_push_vapid_public_key", o, !1, !0);
55
55
  const r = et.Us.Rs,
56
56
  h = new et(r, E),
57
- n = new ti(t, i, e, u, o);
58
- this.j.ft(s.ct.In, n.dt()), h.setItem(r.Fs.cu, r.me, !0);
57
+ n = new oi(t, i, e, u, o);
58
+ this.B.bt(s.ft.Uu, n.gt()), h.setItem(r.Fs.Fu, r.fe, !0);
59
59
  }
60
- Sn(t) {
60
+ wu(t) {
61
61
  if (
62
- (this.nu("push_token", null, !1, !0),
63
- this.nu("custom_push_public_key", null, !1, !0),
64
- this.nu("custom_push_user_auth", null, !1, !0),
65
- this.nu("custom_push_vapid_public_key", null, !1, !0),
62
+ (this.zu("push_token", null, !1, !0),
63
+ this.zu("custom_push_public_key", null, !1, !0),
64
+ this.zu("custom_push_user_auth", null, !1, !0),
65
+ this.zu("custom_push_vapid_public_key", null, !1, !0),
66
66
  t)
67
67
  ) {
68
68
  const t = et.Us.Rs,
69
69
  i = new et(t, E);
70
- this.j.ft(s.ct.In, !1), i.setItem(t.Fs.cu, t.me, !1);
70
+ this.B.bt(s.ft.Uu, !1), i.setItem(t.Fs.Fu, t.fe, !1);
71
71
  }
72
72
  }
73
73
  }