@braze/web-sdk 5.4.0 → 5.6.0

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