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