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