@braze/web-sdk 5.0.1 → 5.1.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 (158) hide show
  1. package/README.md +1 -1
  2. package/index.d.ts +10 -5
  3. package/package.json +1 -1
  4. package/shared-lib/encoding-utils.js +3 -3
  5. package/shared-lib/event-types.js +29 -29
  6. package/shared-lib/guid.js +3 -3
  7. package/shared-lib/index.js +6 -0
  8. package/shared-lib/indexed-db-adapter.js +70 -70
  9. package/shared-lib/logger.js +18 -18
  10. package/shared-lib/supported-options.js +21 -21
  11. package/src/Card/card-manager.js +43 -45
  12. package/src/Card/display/card-display.js +60 -60
  13. package/src/Card/log-card-click.js +4 -4
  14. package/src/Card/log-card-dismissal.js +2 -3
  15. package/src/Card/log-card-impressions.js +7 -7
  16. package/src/Card/models/captioned-image.js +21 -21
  17. package/src/Card/models/card.js +73 -73
  18. package/src/Card/models/classic-card.js +21 -21
  19. package/src/Card/models/control-card.js +11 -11
  20. package/src/Card/models/image-only.js +19 -19
  21. package/src/Card/util/card-factory.js +68 -68
  22. package/src/ContentCards/content-cards-provider-factory.js +3 -3
  23. package/src/ContentCards/content-cards-provider.js +255 -245
  24. package/src/ContentCards/content-cards.js +2 -2
  25. package/src/ContentCards/get-cached-content-cards.js +1 -1
  26. package/src/ContentCards/request-content-cards-refresh.js +1 -1
  27. package/src/ContentCards/subscribe-to-content-cards-updates.js +6 -6
  28. package/src/ContentCards/ui/hide-content-cards.js +1 -1
  29. package/src/ContentCards/ui/show-content-cards.js +24 -24
  30. package/src/ContentCards/ui/toggle-content-cards.js +1 -1
  31. package/src/Core/add-sdk-metadata.js +21 -19
  32. package/src/Core/change-user.js +10 -10
  33. package/src/Core/destroy.js +2 -2
  34. package/src/Core/disable-sdk.js +11 -11
  35. package/src/Core/enable-sdk.js +7 -7
  36. package/src/Core/get-device-id.js +6 -6
  37. package/src/Core/get-user.js +1 -1
  38. package/src/Core/handle-braze-action.js +41 -41
  39. package/src/Core/is-disabled.js +2 -2
  40. package/src/Core/log-custom-event.js +15 -15
  41. package/src/Core/log-purchase.js +31 -37
  42. package/src/Core/open-session.js +12 -12
  43. package/src/Core/remove-all-subscriptions.js +1 -1
  44. package/src/Core/remove-subscription.js +1 -1
  45. package/src/Core/request-immediate-data-flush.js +1 -1
  46. package/src/Core/set-logger.js +2 -2
  47. package/src/Core/set-sdk-authentication-signature.js +3 -3
  48. package/src/Core/subscribe-to-sdk-authentication-failures.js +6 -4
  49. package/src/Core/toggle-logging.js +2 -2
  50. package/src/Core/wipe-data.js +9 -9
  51. package/src/FeatureFlags/feature-flag-factory.js +12 -12
  52. package/src/FeatureFlags/feature-flag.js +10 -10
  53. package/src/FeatureFlags/feature-flags-provider-factory.js +3 -2
  54. package/src/FeatureFlags/feature-flags-provider.js +108 -80
  55. package/src/FeatureFlags/get-all-feature-flags.js +5 -5
  56. package/src/FeatureFlags/get-feature-flag.js +6 -6
  57. package/src/FeatureFlags/log-feature-flag-impression.js +15 -13
  58. package/src/FeatureFlags/refresh-feature-flags.js +1 -1
  59. package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +7 -4
  60. package/src/Feed/feed-provider-factory.js +2 -2
  61. package/src/Feed/feed-provider.js +44 -44
  62. package/src/Feed/feed.js +1 -1
  63. package/src/Feed/get-cached-feed.js +1 -1
  64. package/src/Feed/log-feed-displayed.js +4 -4
  65. package/src/Feed/request-feed-refresh.js +1 -1
  66. package/src/Feed/subscribe-to-feed-updates.js +1 -1
  67. package/src/Feed/ui/hide-feed.js +1 -1
  68. package/src/Feed/ui/show-feed.js +28 -28
  69. package/src/Feed/ui/toggle-feed.js +1 -1
  70. package/src/InAppMessage/defer-in-app-message.js +5 -5
  71. package/src/InAppMessage/display/html-message-to-html.js +54 -54
  72. package/src/InAppMessage/display/in-app-message-to-html.js +79 -79
  73. package/src/InAppMessage/display/modal-utils.js +8 -8
  74. package/src/InAppMessage/get-deferred-in-app-message.js +1 -1
  75. package/src/InAppMessage/in-app-message-factory.js +49 -49
  76. package/src/InAppMessage/in-app-message-manager-factory.js +1 -1
  77. package/src/InAppMessage/in-app-message-manager.js +143 -138
  78. package/src/InAppMessage/log-in-app-message-button-click.js +12 -12
  79. package/src/InAppMessage/log-in-app-message-click.js +9 -9
  80. package/src/InAppMessage/log-in-app-message-html-click.js +12 -12
  81. package/src/InAppMessage/log-in-app-message-impression.js +6 -6
  82. package/src/InAppMessage/models/full-screen-message.js +33 -33
  83. package/src/InAppMessage/models/html-message.js +20 -20
  84. package/src/InAppMessage/models/in-app-message-button.js +6 -6
  85. package/src/InAppMessage/models/in-app-message.js +99 -99
  86. package/src/InAppMessage/models/modal-message.js +32 -32
  87. package/src/InAppMessage/models/slide-up-message.js +28 -28
  88. package/src/InAppMessage/models/templated-in-app-message.js +8 -8
  89. package/src/InAppMessage/subscribe-to-in-app-message.js +2 -2
  90. package/src/InAppMessage/ui/automatically-show-in-app-messages.js +4 -4
  91. package/src/InAppMessage/ui/show-in-app-message.js +81 -81
  92. package/src/Push/is-push-blocked.js +1 -1
  93. package/src/Push/is-push-permission-granted.js +1 -1
  94. package/src/Push/is-push-supported.js +1 -1
  95. package/src/Push/push-manager-factory.js +5 -5
  96. package/src/Push/push-manager.js +176 -173
  97. package/src/Push/request-push-permission.js +1 -1
  98. package/src/Push/unregister-push.js +1 -1
  99. package/src/Push/utils/push-utils.js +4 -4
  100. package/src/User/user-manager.js +29 -29
  101. package/src/User/user.js +72 -74
  102. package/src/common/base-feed.js +7 -7
  103. package/src/common/base-provider.js +1 -1
  104. package/src/common/constants.js +2 -0
  105. package/src/common/event-logger.js +21 -18
  106. package/src/common/feed-display.js +44 -44
  107. package/src/l10n/l10n-manager-factory.js +3 -3
  108. package/src/l10n/l10n-manager.js +7 -7
  109. package/src/managers/auth-manager.js +32 -32
  110. package/src/managers/braze-instance.js +188 -190
  111. package/src/managers/device-manager.js +28 -28
  112. package/src/managers/network-manager.js +189 -138
  113. package/src/managers/server-config-manager.js +69 -53
  114. package/src/managers/session-manager.js +34 -30
  115. package/src/managers/storage-manager-factory.js +16 -16
  116. package/src/managers/storage-manager.js +178 -163
  117. package/src/managers/subscription-manager.js +12 -12
  118. package/src/models/backend-errors.js +5 -5
  119. package/src/models/braze-event.js +4 -4
  120. package/src/models/device.js +2 -2
  121. package/src/models/identifier.js +34 -14
  122. package/src/models/push-token.js +8 -8
  123. package/src/models/request-result.js +3 -3
  124. package/src/models/server-config.js +32 -23
  125. package/src/request-controller.js +187 -179
  126. package/src/triggers/models/custom-event-data.js +7 -7
  127. package/src/triggers/models/custom-event-property-data.js +10 -10
  128. package/src/triggers/models/filter-set.js +13 -13
  129. package/src/triggers/models/filter.js +45 -45
  130. package/src/triggers/models/in-app-message-click-data.js +12 -12
  131. package/src/triggers/models/purchase-data.js +2 -2
  132. package/src/triggers/models/purchase-property-data.js +10 -10
  133. package/src/triggers/models/push-click-data.js +7 -7
  134. package/src/triggers/models/trigger-condition.js +57 -59
  135. package/src/triggers/models/trigger-events.js +4 -4
  136. package/src/triggers/models/trigger.js +38 -38
  137. package/src/triggers/triggers-provider-factory.js +4 -4
  138. package/src/triggers/triggers-provider.js +127 -130
  139. package/src/ui/js/attach-css.js +2 -2
  140. package/src/ui/js/iam-css.js +1 -1
  141. package/src/ui/js/load-font-awesome.js +1 -1
  142. package/src/util/base-device-parser.js +3 -3
  143. package/src/util/braze-actions.js +35 -35
  144. package/src/util/browser-detector.js +21 -21
  145. package/src/util/client-hints-parser.js +8 -8
  146. package/src/util/code-utils.js +2 -2
  147. package/src/util/component-utils.js +1 -1
  148. package/src/util/deprecation-utils.js +4 -4
  149. package/src/util/device-constants.js +1 -1
  150. package/src/util/dom-utils.js +18 -18
  151. package/src/util/key-codes.js +1 -1
  152. package/src/util/net.js +18 -18
  153. package/src/util/request-header-utils.js +39 -37
  154. package/src/util/string-utils.js +10 -10
  155. package/src/util/user-agent-parser.js +18 -18
  156. package/src/util/validation-utils.js +37 -39
  157. package/src/util/window-utils.js +3 -3
  158. package/shared-lib/braze-shared-lib.js +0 -8
@@ -1,76 +1,77 @@
1
- import { isArray as p, isEqual as ii } from "../util/code-utils.js";
1
+ import { isArray as j, isEqual as ii } from "../util/code-utils.js";
2
2
  import ti from "../models/push-token.js";
3
- import r from "../../shared-lib/braze-shared-lib.js";
4
- import { STORAGE_KEYS as i } from "../managers/storage-manager.js";
3
+ import { logger as r, EncodingUtils as ei } from "../../shared-lib/index.js";
4
+ import { STORAGE_KEYS as o } from "../managers/storage-manager.js";
5
5
  import { User } from "../User/index.js";
6
- import { WindowUtils as Y } from "../util/window-utils.js";
6
+ import { WindowUtils as eo } from "../util/window-utils.js";
7
7
  import vt from "./utils/push-utils.js";
8
- import { getErrorMessage as ei } from "../util/error-utils.js";
8
+ import { getErrorMessage as si } from "../util/error-utils.js";
9
9
  export default class ea {
10
- constructor(i, t, e, s, r, n, o, u, h, a) {
11
- (this.hn = i),
12
- (this.cn = t),
13
- (this.fn = e),
14
- (this.dn = r),
15
- (this.bn = n),
10
+ constructor(i, t, e, s, r, n, o, u, a, h) {
11
+ (this.un = i),
12
+ (this.an = t),
13
+ (this.hn = e),
14
+ (this.cn = r),
15
+ (this.fn = n),
16
16
  (this.yt = o),
17
- (this.yn = u),
18
- (this.gn = h),
19
- (this.u = a),
20
- (this.hn = i),
21
- (this.cn = t),
22
- (this.fn = e),
23
- (this.wn = s + "/safari/" + t),
24
- (this.dn = r || "/service-worker.js"),
25
- (this.bn = n),
17
+ (this.ln = u),
18
+ (this.dn = a),
19
+ (this.u = h),
20
+ (this.un = i),
21
+ (this.an = t),
22
+ (this.hn = e),
23
+ (this.pn = s + "/safari/" + t),
24
+ (this.cn = r || "/service-worker.js"),
25
+ (this.fn = n),
26
26
  (this.yt = o),
27
- (this.yn = u || !1),
28
- (this.gn = h || !1),
29
- (this.u = a),
30
- (this.vn = vt.kn()),
31
- (this.Pn = vt.Dn());
27
+ (this.ln = u || !1),
28
+ (this.dn = a || !1),
29
+ (this.u = h),
30
+ (this.bn = vt.mn()),
31
+ (this.yn = vt.gn());
32
32
  }
33
- Sn() {
34
- return this.gn;
33
+ vn() {
34
+ return this.dn;
35
35
  }
36
- An(i, t, e, s, n) {
36
+ wn(i, t, e, s, n) {
37
37
  i.unsubscribe()
38
38
  .then((i) => {
39
39
  i
40
- ? this.jn(t, e, s, n)
41
- : (r.j.error("Failed to unsubscribe device from push."),
40
+ ? this.kn(t, e, s, n)
41
+ : (r.error("Failed to unsubscribe device from push."),
42
42
  "function" == typeof n && n(!1));
43
43
  })
44
44
  .catch((i) => {
45
- r.j.error("Push unsubscription error: " + i),
45
+ r.error("Push unsubscription error: " + i),
46
46
  "function" == typeof n && n(!1);
47
47
  });
48
48
  }
49
- Un(i, t, e) {
50
- const s = ((i) => {
49
+ Pn(i, t, e) {
50
+ var s;
51
+ const n = ((i) => {
51
52
  if ("string" == typeof i) return i;
52
53
  if (0 !== i.endpoint.indexOf("https://android.googleapis.com/gcm/send"))
53
54
  return i.endpoint;
54
55
  let t = i.endpoint;
55
56
  const e = i;
56
57
  return (
57
- e.Wn &&
58
- -1 === i.endpoint.indexOf(e.Wn) &&
59
- (t = i.endpoint + "/" + e.Wn),
58
+ e.Dn &&
59
+ -1 === i.endpoint.indexOf(e.Dn) &&
60
+ (t = i.endpoint + "/" + e.Dn),
60
61
  t
61
62
  );
62
63
  })(i);
63
- let n = null,
64
- o = null;
65
- const u = i;
66
- if (null != u.getKey)
64
+ let o = null,
65
+ u = null;
66
+ const a = i;
67
+ if (null != a.getKey)
67
68
  try {
68
- const i = Array.from(new Uint8Array(u.getKey("p256dh"))),
69
- t = Array.from(new Uint8Array(u.getKey("auth")));
70
- (n = btoa(String.fromCharCode.apply(null, i))),
71
- (o = btoa(String.fromCharCode.apply(null, t)));
69
+ const i = Array.from(new Uint8Array(a.getKey("p256dh"))),
70
+ t = Array.from(new Uint8Array(a.getKey("auth")));
71
+ (o = btoa(String.fromCharCode.apply(null, i))),
72
+ (u = btoa(String.fromCharCode.apply(null, t)));
72
73
  } catch (i) {
73
- r.j.error(ei(i));
74
+ r.error(si(i));
74
75
  }
75
76
  const h = ((i) => {
76
77
  let t;
@@ -82,50 +83,54 @@ export default class ea {
82
83
  .replace(/\+/g, "-")
83
84
  .replace(/\//g, "_")
84
85
  : null;
85
- })(u);
86
- this.hn && this.hn._n(s, t, n, o, h),
87
- s && "function" == typeof e && e(s, n, o);
86
+ })(a);
87
+ null === (s = this.un) || void 0 === s || s.Sn(n, t, o, u, h),
88
+ n && "function" == typeof e && e(n, o, u);
88
89
  }
89
- xn() {
90
- this.hn && this.hn.Nn(!0);
90
+ An() {
91
+ var i;
92
+ null === (i = this.un) || void 0 === i || i.jn(!0);
91
93
  }
92
- Tn(i, t) {
93
- this.hn && this.hn.Nn(!1), r.j.info(i), "function" == typeof t && t(!1);
94
+ xn(i, t) {
95
+ var e;
96
+ null === (e = this.un) || void 0 === e || e.jn(!1),
97
+ r.info(i),
98
+ "function" == typeof t && t(!1);
94
99
  }
95
- zn(i, t, e, s) {
100
+ Un(i, t, e, s) {
96
101
  var n;
97
102
  if ("default" === t.permission)
98
103
  try {
99
104
  window.safari.pushNotification.requestPermission(
100
- this.wn,
105
+ this.pn,
101
106
  i,
102
107
  {
103
- api_key: this.cn,
108
+ api_key: this.an,
104
109
  device_id:
105
- (null === (n = this.fn) || void 0 === n ? void 0 : n.ce().id) ||
110
+ (null === (n = this.hn) || void 0 === n ? void 0 : n.ce().id) ||
106
111
  "",
107
112
  },
108
113
  (t) => {
109
114
  "granted" === t.permission &&
110
- this.hn &&
111
- this.hn.setPushNotificationSubscriptionType(
115
+ this.un &&
116
+ this.un.setPushNotificationSubscriptionType(
112
117
  User.NotificationSubscriptionTypes.OPTED_IN,
113
118
  ),
114
- this.zn(i, t, e, s);
119
+ this.Un(i, t, e, s);
115
120
  },
116
121
  );
117
122
  } catch (i) {
118
- this.Tn("Could not request permission for push: " + i, s);
123
+ this.xn("Could not request permission for push: " + i, s);
119
124
  }
120
125
  else
121
126
  "denied" === t.permission
122
- ? this.Tn(
127
+ ? this.xn(
123
128
  "The user has blocked notifications from this site, or Safari push is not configured in the Braze dashboard.",
124
129
  s,
125
130
  )
126
131
  : "granted" === t.permission &&
127
- (r.j.info("Device successfully subscribed to push."),
128
- this.Un(t.deviceToken, new Date(), e));
132
+ (r.info("Device successfully subscribed to push."),
133
+ this.Pn(t.deviceToken, new Date(), e));
129
134
  }
130
135
  requestPermission(i, t, e) {
131
136
  const s = (s) => {
@@ -137,7 +142,7 @@ export default class ea {
137
142
  case "denied":
138
143
  return void ("function" == typeof e && e());
139
144
  default:
140
- r.j.error("Received unexpected permission result " + s);
145
+ r.error("Received unexpected permission result " + s);
141
146
  }
142
147
  };
143
148
  let n = !1;
@@ -150,238 +155,236 @@ export default class ea {
150
155
  })
151
156
  : (n = !0);
152
157
  }
153
- jn(i, t, e, s) {
158
+ kn(i, t, e, s) {
154
159
  const n = { userVisibleOnly: !0 };
155
160
  null != t && (n.applicationServerKey = t),
156
161
  i.pushManager
157
162
  .subscribe(n)
158
163
  .then((i) => {
159
- r.j.info("Device successfully subscribed to push."),
160
- this.Un(i, new Date(), e);
164
+ r.info("Device successfully subscribed to push."),
165
+ this.Pn(i, new Date(), e);
161
166
  })
162
167
  .catch((i) => {
163
168
  vt.isPushBlocked()
164
- ? (r.j.info("Permission for push notifications was denied."),
169
+ ? (r.info("Permission for push notifications was denied."),
165
170
  "function" == typeof s && s(!1))
166
- : (r.j.error("Push subscription failed: " + i),
171
+ : (r.error("Push subscription failed: " + i),
167
172
  "function" == typeof s && s(!0));
168
173
  });
169
174
  }
170
- In() {
171
- return this.yn
172
- ? navigator.serviceWorker.getRegistration(this.dn)
173
- : navigator.serviceWorker.register(this.dn).then(() =>
175
+ Wn() {
176
+ return this.ln
177
+ ? navigator.serviceWorker.getRegistration(this.cn)
178
+ : navigator.serviceWorker.register(this.cn).then(() =>
174
179
  navigator.serviceWorker.ready.then(
175
180
  (i) => (
176
181
  i &&
177
182
  "function" == typeof i.update &&
178
183
  i.update().catch((i) => {
179
- r.j.info("ServiceWorker update failed: " + i);
184
+ r.info("ServiceWorker update failed: " + i);
180
185
  }),
181
186
  i
182
187
  ),
183
188
  ),
184
189
  );
185
190
  }
186
- Vn(i) {
187
- this.yn ||
188
- (i.unregister(), r.j.info("Service worker successfully unregistered."));
191
+ _n(i) {
192
+ this.ln ||
193
+ (i.unregister(), r.info("Service worker successfully unregistered."));
189
194
  }
190
- subscribe(t, e) {
195
+ subscribe(i, t) {
191
196
  if (!vt.isPushSupported())
192
- return r.j.info(ea.qn), void ("function" == typeof e && e(!1));
193
- if (this.vn) {
194
- if (!this.yn && null != window.location) {
195
- let i = this.dn;
197
+ return r.info(ea.Nn), void ("function" == typeof t && t(!1));
198
+ if (this.bn) {
199
+ if (!this.ln && null != window.location) {
200
+ let i = this.cn;
196
201
  -1 === i.indexOf(window.location.host) &&
197
202
  (i = window.location.host + i),
198
203
  -1 === i.indexOf(window.location.protocol) &&
199
204
  (i = window.location.protocol + "//" + i);
200
- const t = i.substr(0, i.lastIndexOf("/") + 1);
201
- if (0 !== Y.Cn().indexOf(t))
205
+ const e = i.substr(0, i.lastIndexOf("/") + 1);
206
+ if (0 !== eo.Tn().indexOf(e))
202
207
  return (
203
- r.j.error(
208
+ r.error(
204
209
  "Cannot subscribe to push from a path higher than the service worker location (tried to subscribe from " +
205
210
  window.location.pathname +
206
211
  " but service worker is at " +
207
212
  i +
208
213
  ")",
209
214
  ),
210
- void ("function" == typeof e && e(!0))
215
+ void ("function" == typeof t && t(!0))
211
216
  );
212
217
  }
213
218
  if (vt.isPushBlocked())
214
- return void this.Tn(
219
+ return void this.xn(
215
220
  "Notifications from this site are blocked. This may be a temporary embargo or a permanent denial.",
216
- e,
221
+ t,
217
222
  );
218
- if (this.yt && !this.yt.En() && 0 === this.yt.li())
223
+ if (this.yt && !this.yt.In() && 0 === this.yt.ni())
219
224
  return (
220
- r.j.info(
225
+ r.info(
221
226
  "Waiting for VAPID key from server config before subscribing to push.",
222
227
  ),
223
- void this.yt.Rn(() => {
224
- this.subscribe(t, e);
228
+ void this.yt.Vn(() => {
229
+ this.subscribe(i, t);
225
230
  })
226
231
  );
227
- const s = () => {
228
- r.j.info("Permission for push notifications was denied."),
229
- "function" == typeof e && e(!1);
232
+ const e = () => {
233
+ r.info("Permission for push notifications was denied."),
234
+ "function" == typeof t && t(!1);
230
235
  },
231
- n = () => {
236
+ s = () => {
232
237
  let i = "Permission for push notifications was ignored.";
233
238
  vt.isPushBlocked() &&
234
239
  (i +=
235
240
  " The browser has automatically blocked further permission requests for a period (probably 1 week)."),
236
- r.j.info(i),
237
- "function" == typeof e && e(!0);
241
+ r.info(i),
242
+ "function" == typeof t && t(!0);
238
243
  },
239
- o = vt.isPushPermissionGranted(),
244
+ n = vt.isPushPermissionGranted(),
240
245
  u = () => {
241
- !o &&
242
- this.hn &&
243
- this.hn.setPushNotificationSubscriptionType(
246
+ !n &&
247
+ this.un &&
248
+ this.un.setPushNotificationSubscriptionType(
244
249
  User.NotificationSubscriptionTypes.OPTED_IN,
245
250
  ),
246
- this.In()
247
- .then((s) => {
248
- if (null == s)
251
+ this.Wn()
252
+ .then((e) => {
253
+ if (null == e)
249
254
  return (
250
- r.j.error(
255
+ r.error(
251
256
  "No service worker registration. Set the `manageServiceWorkerExternally` initialization option to false or ensure that your service worker is registered before calling registerPush.",
252
257
  ),
253
- void ("function" == typeof e && e(!0))
258
+ void ("function" == typeof t && t(!0))
254
259
  );
255
- s.pushManager
260
+ e.pushManager
256
261
  .getSubscription()
257
- .then((n) => {
258
- let o = null;
262
+ .then((s) => {
263
+ var n;
264
+ let u = null;
259
265
  if (
260
- (this.yt &&
261
- null != this.yt.En() &&
262
- (o = r.On.Fn(this.yt.En())),
263
- n)
266
+ (null !=
267
+ (null === (n = this.yt) || void 0 === n
268
+ ? void 0
269
+ : n.In()) && (u = ei.qn(this.yt.In())),
270
+ s)
264
271
  ) {
265
- let u,
266
- h = null,
267
- a = null;
268
- if ((this.u && (u = this.u.v(i.k.Bn)), u && !p(u))) {
272
+ let n,
273
+ a = null,
274
+ h = null;
275
+ if ((this.u && (n = this.u.j(o.C.zn)), n && !j(n))) {
269
276
  let i;
270
277
  try {
271
- i = ti.Yn(u).Mn;
278
+ i = ti.En(n).Cn;
272
279
  } catch (t) {
273
280
  i = null;
274
281
  }
275
282
  null == i ||
276
283
  isNaN(i.getTime()) ||
277
284
  0 === i.getTime() ||
278
- ((h = i),
279
- (a = new Date(h)),
280
- a.setMonth(h.getMonth() + 6));
285
+ ((a = i),
286
+ (h = new Date(a)),
287
+ h.setMonth(a.getMonth() + 6));
281
288
  }
282
- null != o &&
283
- n.options &&
284
- n.options.applicationServerKey &&
285
- n.options.applicationServerKey.byteLength &&
286
- n.options.applicationServerKey.byteLength > 0 &&
287
- !ii(o, new Uint8Array(n.options.applicationServerKey))
288
- ? (n.options.applicationServerKey.byteLength > 12
289
- ? r.j.info(
289
+ null != u &&
290
+ s.options &&
291
+ s.options.applicationServerKey &&
292
+ s.options.applicationServerKey.byteLength &&
293
+ s.options.applicationServerKey.byteLength > 0 &&
294
+ !ii(u, new Uint8Array(s.options.applicationServerKey))
295
+ ? (s.options.applicationServerKey.byteLength > 12
296
+ ? r.info(
290
297
  "Device was already subscribed to push using a different VAPID provider, creating new subscription.",
291
298
  )
292
- : r.j.info(
299
+ : r.info(
293
300
  "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.",
294
301
  ),
295
- this.An(n, s, o, t, e))
296
- : n.expirationTime &&
297
- new Date(n.expirationTime).valueOf() <=
302
+ this.wn(s, e, u, i, t))
303
+ : s.expirationTime &&
304
+ new Date(s.expirationTime).valueOf() <=
298
305
  new Date().valueOf()
299
- ? (r.j.info(
306
+ ? (r.info(
300
307
  "Push subscription is expired, creating new subscription.",
301
308
  ),
302
- this.An(n, s, o, t, e))
303
- : u && p(u)
304
- ? this.An(n, s, o, t, e)
305
- : null == a
306
- ? (r.j.info(
309
+ this.wn(s, e, u, i, t))
310
+ : n && j(n)
311
+ ? this.wn(s, e, u, i, t)
312
+ : null == h
313
+ ? (r.info(
307
314
  "No push subscription creation date found, creating new subscription.",
308
315
  ),
309
- this.An(n, s, o, t, e))
310
- : a.valueOf() <= new Date().valueOf()
311
- ? (r.j.info(
316
+ this.wn(s, e, u, i, t))
317
+ : h.valueOf() <= new Date().valueOf()
318
+ ? (r.info(
312
319
  "Push subscription older than 6 months, creating new subscription.",
313
320
  ),
314
- this.An(n, s, o, t, e))
315
- : (r.j.info(
321
+ this.wn(s, e, u, i, t))
322
+ : (r.info(
316
323
  "Device already subscribed to push, sending existing subscription to backend.",
317
324
  ),
318
- this.Un(n, h, t));
319
- } else this.jn(s, o, t, e);
325
+ this.Pn(s, a, i));
326
+ } else this.kn(e, u, i, t);
320
327
  })
321
328
  .catch((i) => {
322
- r.j.error(
323
- "Error checking current push subscriptions: " + i,
324
- );
329
+ r.error("Error checking current push subscriptions: " + i);
325
330
  });
326
331
  })
327
332
  .catch((i) => {
328
- r.j.error("ServiceWorker registration failed: " + i);
333
+ r.error("ServiceWorker registration failed: " + i);
329
334
  });
330
335
  };
331
- this.requestPermission(u, n, s);
332
- } else if (this.Pn) {
333
- if (null == this.bn || "" === this.bn)
336
+ this.requestPermission(u, s, e);
337
+ } else if (this.yn) {
338
+ if (null == this.fn || "" === this.fn)
334
339
  return (
335
- r.j.error(
340
+ r.error(
336
341
  "You must supply the safariWebsitePushId initialization option in order to use registerPush on Safari",
337
342
  ),
338
- void ("function" == typeof e && e(!0))
343
+ void ("function" == typeof t && t(!0))
339
344
  );
340
- const i = window.safari.pushNotification.permission(this.bn);
341
- this.zn(this.bn, i, t, e);
345
+ const e = window.safari.pushNotification.permission(this.fn);
346
+ this.Un(this.fn, e, i, t);
342
347
  }
343
348
  }
344
349
  unsubscribe(i, t) {
345
350
  if (!vt.isPushSupported())
346
- return r.j.info(ea.qn), void ("function" == typeof t && t());
347
- this.vn
351
+ return r.info(ea.Nn), void ("function" == typeof t && t());
352
+ this.bn
348
353
  ? navigator.serviceWorker.getRegistration().then((e) => {
349
354
  e
350
355
  ? e.pushManager
351
356
  .getSubscription()
352
357
  .then((s) => {
353
358
  s &&
354
- (this.xn(),
359
+ (this.An(),
355
360
  s
356
361
  .unsubscribe()
357
362
  .then((s) => {
358
363
  s
359
- ? (r.j.info(
364
+ ? (r.info(
360
365
  "Device successfully unsubscribed from push.",
361
366
  ),
362
367
  "function" == typeof i && i())
363
- : (r.j.error(
364
- "Failed to unsubscribe device from push.",
365
- ),
368
+ : (r.error("Failed to unsubscribe device from push."),
366
369
  "function" == typeof t && t()),
367
- this.Vn(e);
370
+ this._n(e);
368
371
  })
369
372
  .catch((i) => {
370
- r.j.error("Push unsubscription error: " + i),
373
+ r.error("Push unsubscription error: " + i),
371
374
  "function" == typeof t && t();
372
375
  }));
373
376
  })
374
377
  .catch((i) => {
375
- r.j.error("Error unsubscribing from push: " + i),
378
+ r.error("Error unsubscribing from push: " + i),
376
379
  "function" == typeof t && t();
377
380
  })
378
- : (r.j.info("Device already unsubscribed from push."),
381
+ : (r.info("Device already unsubscribed from push."),
379
382
  "function" == typeof i && i());
380
383
  })
381
- : this.Pn &&
382
- (this.xn(),
383
- r.j.info("Device unsubscribed from push."),
384
+ : this.yn &&
385
+ (this.An(),
386
+ r.info("Device unsubscribed from push."),
384
387
  "function" == typeof i && i());
385
388
  }
386
389
  }
387
- ea.qn = "Push notifications are not supported in this browser.";
390
+ ea.Nn = "Push notifications are not supported in this browser.";
@@ -1,7 +1,7 @@
1
1
  import e from "../managers/braze-instance.js";
2
2
  import na from "./push-manager-factory.js";
3
3
  export function requestPushPermission(r, n) {
4
- if (e.rr())
4
+ if (e.X())
5
5
  return na.m().subscribe((n, o, t) => {
6
6
  const s = e.cr();
7
7
  s && s.requestImmediateDataFlush(), "function" == typeof r && r(n, o, t);
@@ -1,5 +1,5 @@
1
1
  import e from "../managers/braze-instance.js";
2
2
  import na from "./push-manager-factory.js";
3
3
  export function unregisterPush(r, n) {
4
- if (e.rr()) return na.m().unsubscribe(r, n);
4
+ if (e.X()) return na.m().unsubscribe(r, n);
5
5
  }
@@ -1,15 +1,15 @@
1
1
  const vt = {
2
- kn: () =>
2
+ mn: () =>
3
3
  "serviceWorker" in navigator &&
4
4
  "undefined" != typeof ServiceWorkerRegistration &&
5
5
  "showNotification" in ServiceWorkerRegistration.prototype &&
6
6
  "PushManager" in window,
7
- Dn: () =>
7
+ gn: () =>
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: () => vt.kn() || vt.Dn(),
12
+ isPushSupported: () => vt.mn() || vt.gn(),
13
13
  isPushBlocked: () => {
14
14
  const i =
15
15
  vt.isPushSupported() &&
@@ -28,7 +28,7 @@ const vt = {
28
28
  null != window.Notification &&
29
29
  null != window.Notification.permission &&
30
30
  "granted" === window.Notification.permission,
31
- Gr: () =>
31
+ Yi: () =>
32
32
  !vt.isPushBlocked() &&
33
33
  vt.isPushSupported() &&
34
34
  !vt.isPushPermissionGranted(),