@braze/web-sdk 6.9.0 → 6.10.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.
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Type definitions for @braze/web-sdk v6.9.0
2
+ * Type definitions for @braze/web-sdk v6.10.1
3
3
  * Project: https://github.com/braze-inc/braze-web-sdk
4
4
  * (c) Braze, Inc. 2026 - http://braze.com
5
5
  * License available at https://github.com/braze-inc/braze-web-sdk/blob/master/LICENSE
@@ -2535,6 +2535,18 @@ export function logPurchase(
2535
2535
  */
2536
2536
  export function openSession(): void;
2537
2537
 
2538
+ /**
2539
+ * Logs out the current user. This unregisters push for this browser via `unregisterPush`, and on success
2540
+ * wipes all locally stored SDK data (see `wipeData`) and disables the SDK (see `disableSDK`).
2541
+ *
2542
+ * @param successCallback - When the user is successfully logged out, this callback will be invoked.
2543
+ * @param errorCallback - If the logout fails for unknown reasons, this callback will be invoked.
2544
+ */
2545
+ export function logout(
2546
+ successCallback?: () => void,
2547
+ errorCallback?: () => void,
2548
+ ): void;
2549
+
2538
2550
  /**
2539
2551
  * Register this browser environment to receive web push for this user. Supports browsers which implement the
2540
2552
  * [W3C Push API](https://developer.mozilla.org/en-US/docs/Web/API/Push_API) (browsers in which
@@ -2547,7 +2559,7 @@ export function openSession(): void;
2547
2559
  * - Create a `service-worker.js` file with the content below and place it in the root directory of your website:
2548
2560
  *
2549
2561
  * ```
2550
- * self.importScripts('https://js.appboycdn.com/web-sdk/6.9/service-worker.js');
2562
+ * self.importScripts('https://js.appboycdn.com/web-sdk/6.10/service-worker.js');
2551
2563
  * ```
2552
2564
  *
2553
2565
  * For more details, see [Our Product Documentation](https://www.braze.com/docs/developer_guide/platform_integration_guides/web/push_notifications/integration).
@@ -2738,8 +2750,8 @@ export function toggleLogging(): void;
2738
2750
  * Note that for Safari, Apple does not offer any unsubscribe mechanism, so on Safari this method leaves the user
2739
2751
  * with push permission granted and simply sets their subscription status to unsubscribed.
2740
2752
  *
2741
- * @param successCallback - When the unsubscribe is successfully recorded and processed by Braze, this
2742
- * callback will be invoked.
2753
+ * @param successCallback - Invoked when unregister processing completes. This includes when push is not supported
2754
+ * in the browser or the device is already unsubscribed.
2743
2755
  * @param errorCallback - If the unsubscribe fails for unknown reasons, this callback will be invoked.
2744
2756
  */
2745
2757
  export function unregisterPush(
@@ -2969,7 +2981,7 @@ export type InitializationOptions = {
2969
2981
  * lifecycle of, set this option to true and the Braze SDK will not register or unregister a service worker. If you set this
2970
2982
  * option to true, in order for push to function correctly you must register the service worker yourself BEFORE calling
2971
2983
  * `requestPushPermission`, and ensure that it contains Braze's service worker code, either with
2972
- * `self.importScripts('https://js.appboycdn.com/web-sdk/6.9/service-worker.js');` or by including the content
2984
+ * `self.importScripts('https://js.appboycdn.com/web-sdk/6.10/service-worker.js');` or by including the content
2973
2985
  * of that file directly. When this option is true, the `serviceWorkerLocation` option is irrelevant and is ignored.
2974
2986
  */
2975
2987
  manageServiceWorkerExternally?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@braze/web-sdk",
3
- "version": "6.9.0",
3
+ "version": "6.10.1",
4
4
  "description": "Braze SDK for web sites and other JS platforms.",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -3,8 +3,8 @@ const p = {
3
3
  Pr: "p",
4
4
  $c: "pc",
5
5
  Fc: "ca",
6
- gl: "i",
7
- Ya: "ie",
6
+ bl: "i",
7
+ Qa: "ie",
8
8
  vs: "cci",
9
9
  ws: "ccic",
10
10
  us: "ccc",
@@ -6,16 +6,16 @@ export default class et {
6
6
  (this.database = t),
7
7
  (this.Ud = e);
8
8
  }
9
- Od() {
9
+ kd() {
10
10
  if ("indexedDB" in this.parent) return this.parent.indexedDB;
11
11
  }
12
12
  isSupported() {
13
13
  var t;
14
14
  try {
15
- if (null == this.Od()) return !1;
15
+ if (null == this.kd()) return !1;
16
16
  {
17
17
  const e =
18
- null === (t = this.Od()) || void 0 === t
18
+ null === (t = this.kd()) || void 0 === t
19
19
  ? void 0
20
20
  : t.open("Braze IndexedDB Support Test");
21
21
  if (
@@ -25,7 +25,7 @@ export default class et {
25
25
  "undefined" != typeof window)
26
26
  ) {
27
27
  const t = window,
28
- e = t.chrome || t.browser || t.kd;
28
+ e = t.chrome || t.browser || t.Kd;
29
29
  if (e && e.runtime && e.runtime.id)
30
30
  return (
31
31
  this.Ud.info(
@@ -45,12 +45,12 @@ export default class et {
45
45
  );
46
46
  }
47
47
  }
48
- Kd(t, e) {
48
+ Gd(t, e) {
49
49
  var n;
50
50
  const o =
51
- null === (n = this.Od()) || void 0 === n
51
+ null === (n = this.kd()) || void 0 === n
52
52
  ? void 0
53
- : n.open(this.database.Gd, this.database.VERSION);
53
+ : n.open(this.database.Hd, this.database.VERSION);
54
54
  if (null == o) return "function" == typeof e && e(), !1;
55
55
  const i = this;
56
56
  return (
@@ -58,7 +58,7 @@ export default class et {
58
58
  var e;
59
59
  i.Ud.info(
60
60
  "Upgrading indexedDB " +
61
- i.database.Gd +
61
+ i.database.Hd +
62
62
  " to v" +
63
63
  i.database.VERSION +
64
64
  "...",
@@ -89,7 +89,7 @@ export default class et {
89
89
  return (
90
90
  i.Ud.info(
91
91
  "Could not open indexedDB " +
92
- i.database.Gd +
92
+ i.database.Hd +
93
93
  " v" +
94
94
  i.database.VERSION +
95
95
  ": " +
@@ -105,7 +105,7 @@ export default class et {
105
105
  setItem(t, e, n, o, i) {
106
106
  if (!this.isSupported()) return "function" == typeof i && i(), !1;
107
107
  const r = this;
108
- return this.Kd((d) => {
108
+ return this.Gd((d) => {
109
109
  if (!d.objectStoreNames.contains(t))
110
110
  return (
111
111
  r.Ud.error(
@@ -114,7 +114,7 @@ export default class et {
114
114
  " in " +
115
115
  t +
116
116
  " on indexedDB " +
117
- r.database.Gd +
117
+ r.database.Hd +
118
118
  " - " +
119
119
  t +
120
120
  " is not a valid objectStore",
@@ -132,7 +132,7 @@ export default class et {
132
132
  " in " +
133
133
  t +
134
134
  " on indexedDB " +
135
- r.database.Gd,
135
+ r.database.Hd,
136
136
  ),
137
137
  "function" == typeof i && i();
138
138
  }),
@@ -144,7 +144,7 @@ export default class et {
144
144
  getItem(t, e, n) {
145
145
  if (!this.isSupported()) return !1;
146
146
  const o = this;
147
- return this.Kd((i) => {
147
+ return this.Gd((i) => {
148
148
  if (!i.objectStoreNames.contains(t))
149
149
  return (
150
150
  o.Ud.error(
@@ -153,7 +153,7 @@ export default class et {
153
153
  " in " +
154
154
  t +
155
155
  " on indexedDB " +
156
- o.database.Gd +
156
+ o.database.Hd +
157
157
  " - " +
158
158
  t +
159
159
  " is not a valid objectStore",
@@ -170,7 +170,7 @@ export default class et {
170
170
  " in " +
171
171
  t +
172
172
  " on indexedDB " +
173
- o.database.Gd,
173
+ o.database.Hd,
174
174
  );
175
175
  }),
176
176
  (d.onsuccess = (t) => {
@@ -183,14 +183,14 @@ export default class et {
183
183
  kr(t, e, n) {
184
184
  if (!this.isSupported()) return "function" == typeof n && n(), !1;
185
185
  const o = this;
186
- return this.Kd((i) => {
186
+ return this.Gd((i) => {
187
187
  if (!i.objectStoreNames.contains(t))
188
188
  return (
189
189
  o.Ud.error(
190
190
  "Could not retrieve last record from " +
191
191
  t +
192
192
  " on indexedDB " +
193
- o.database.Gd +
193
+ o.database.Hd +
194
194
  " - " +
195
195
  t +
196
196
  " is not a valid objectStore",
@@ -203,7 +203,7 @@ export default class et {
203
203
  const d = r.objectStore(t).openCursor(null, "prev");
204
204
  (d.onerror = () => {
205
205
  o.Ud.error(
206
- "Could not open cursor for " + t + " on indexedDB " + o.database.Gd,
206
+ "Could not open cursor for " + t + " on indexedDB " + o.database.Hd,
207
207
  ),
208
208
  "function" == typeof n && n();
209
209
  }),
@@ -219,7 +219,7 @@ export default class et {
219
219
  ge(t, e) {
220
220
  if (!this.isSupported()) return !1;
221
221
  const n = this;
222
- return this.Kd((o) => {
222
+ return this.Gd((o) => {
223
223
  if (!o.objectStoreNames.contains(t))
224
224
  return (
225
225
  n.Ud.error(
@@ -228,7 +228,7 @@ export default class et {
228
228
  " from " +
229
229
  t +
230
230
  " on indexedDB " +
231
- n.database.Gd +
231
+ n.database.Hd +
232
232
  " - " +
233
233
  t +
234
234
  " is not a valid objectStore",
@@ -244,7 +244,7 @@ export default class et {
244
244
  " from " +
245
245
  t +
246
246
  " on indexedDB " +
247
- n.database.Gd,
247
+ n.database.Hd,
248
248
  );
249
249
  };
250
250
  });
@@ -252,14 +252,14 @@ export default class et {
252
252
  Qs(t, e) {
253
253
  if (!this.isSupported()) return !1;
254
254
  const n = this;
255
- return this.Kd((o) => {
255
+ return this.Gd((o) => {
256
256
  if (!o.objectStoreNames.contains(t))
257
257
  return (
258
258
  n.Ud.error(
259
259
  "Could not retrieve objects from " +
260
260
  t +
261
261
  " on indexedDB " +
262
- n.database.Gd +
262
+ n.database.Hd +
263
263
  " - " +
264
264
  t +
265
265
  " is not a valid objectStore",
@@ -277,14 +277,14 @@ export default class et {
277
277
  "Cursor closed midway through for " +
278
278
  t +
279
279
  " on indexedDB " +
280
- n.database.Gd,
280
+ n.database.Hd,
281
281
  ),
282
282
  e(s))
283
283
  : n.Ud.error(
284
284
  "Could not open cursor for " +
285
285
  t +
286
286
  " on indexedDB " +
287
- n.database.Gd,
287
+ n.database.Hd,
288
288
  );
289
289
  }),
290
290
  (d.onsuccess = (t) => {
@@ -311,7 +311,7 @@ export default class et {
311
311
  t.push(this.database.Ws[n]);
312
312
  }
313
313
  const e = this;
314
- return this.Kd(function (n) {
314
+ return this.Gd(function (n) {
315
315
  const o = n.transaction(t, "readwrite");
316
316
  o.oncomplete = () => n.close();
317
317
  for (let n = 0; n < t.length; n++) {
@@ -321,13 +321,13 @@ export default class et {
321
321
  "Could not clear " +
322
322
  this.source.name +
323
323
  " on indexedDB " +
324
- e.database.Gd,
324
+ e.database.Hd,
325
325
  );
326
326
  };
327
327
  }
328
328
  o.onerror = function () {
329
329
  e.Ud.error(
330
- "Could not clear object stores on indexedDB " + e.database.Gd,
330
+ "Could not clear object stores on indexedDB " + e.database.Hd,
331
331
  );
332
332
  };
333
333
  });
@@ -335,13 +335,13 @@ export default class et {
335
335
  }
336
336
  et._s = {
337
337
  Xs: {
338
- Gd: "AppboyServiceWorkerAsyncStorage",
338
+ Hd: "AppboyServiceWorkerAsyncStorage",
339
339
  VERSION: 6,
340
340
  Ws: {
341
341
  pn: "data",
342
342
  yr: "pushClicks",
343
343
  Fu: "pushSubscribed",
344
- Hd: "fallbackDevice",
344
+ Vd: "fallbackDevice",
345
345
  Vs: "cardUpdates",
346
346
  pe: "optOut",
347
347
  Br: "pendingData",
@@ -24,13 +24,13 @@ const b = {
24
24
  },
25
25
  warn: function (n) {
26
26
  if (b.zg) {
27
- const o = "Braze SDK Warning: " + n + " (v6.9.0)";
27
+ const o = "Braze SDK Warning: " + n + " (v6.10.1)";
28
28
  null != b.Ud ? b.Ud(o) : console.warn(o);
29
29
  }
30
30
  },
31
31
  error: function (n) {
32
32
  if (b.zg) {
33
- const o = "Braze SDK Error: " + n + " (v6.9.0)";
33
+ const o = "Braze SDK Error: " + n + " (v6.10.1)";
34
34
  null != b.Ud ? b.Ud(o) : console.error(o);
35
35
  }
36
36
  },
@@ -14,7 +14,7 @@ export default {
14
14
  Mh: "appVersionNumber",
15
15
  xa: "serviceWorkerLocation",
16
16
  Ma: "safariWebsitePushId",
17
- qa: "localization",
17
+ Aa: "localization",
18
18
  sr: "contentSecurityNonce",
19
19
  nr: "allowUserSuppliedJavascript",
20
20
  ja: "inAppMessageZIndex",
package/src/Core/index.js CHANGED
@@ -11,6 +11,7 @@ export { initialize } from "./initialize.js";
11
11
  export { isDisabled } from "./is-disabled.js";
12
12
  export { isInitialized } from "./is-initialized.js";
13
13
  export { logCustomEvent } from "./log-custom-event.js";
14
+ export { logout } from "./logout.js";
14
15
  export { logEcommerceEvent } from "./log-ecommerce-event.js";
15
16
  export { logPurchase } from "./log-purchase.js";
16
17
  export { openSession } from "./open-session.js";
@@ -0,0 +1,22 @@
1
+ import r from "../managers/braze-instance.js";
2
+ import { unregisterPush } from "../Push/unregister-push.js";
3
+ import { disableSDK } from "./disable-sdk.js";
4
+ import { wipeData } from "./wipe-data.js";
5
+ export const logoutDependencies = {
6
+ unregisterPush: unregisterPush,
7
+ disableSDK: disableSDK,
8
+ wipeData: wipeData,
9
+ };
10
+ export function logout(e, o) {
11
+ r.rr() &&
12
+ logoutDependencies.unregisterPush(
13
+ () => {
14
+ logoutDependencies.wipeData(),
15
+ logoutDependencies.disableSDK(),
16
+ "function" == typeof e && e();
17
+ },
18
+ () => {
19
+ "function" == typeof o && o();
20
+ },
21
+ );
22
+ }
@@ -340,7 +340,7 @@ export default class na {
340
340
  }
341
341
  unsubscribe(i, t) {
342
342
  if (!It.isPushSupported())
343
- return b.info(na.Au), void ("function" == typeof t && t());
343
+ return b.info(na.Au), void ("function" == typeof i && i());
344
344
  this.hu
345
345
  ? navigator.serviceWorker.getRegistration(this.su).then((e) => {
346
346
  e
@@ -0,0 +1,35 @@
1
+ import r from "../managers/braze-instance.js";
2
+ import { STORAGE_KEYS as s } from "../managers/storage-manager.js";
3
+ import ui from "../models/push-token.js";
4
+ import l from "../util/net.js";
5
+ import h from "../util/request-header-utils.js";
6
+ export function unregisterPushTokenOnServer() {
7
+ if (!r.rr()) return;
8
+ const e = r.m();
9
+ if (!e) return;
10
+ const t = r.p(),
11
+ n = null == t ? void 0 : t.St(s.It.Uu);
12
+ if (!n || "object" != typeof n || Array.isArray(n)) return;
13
+ const o = ui._u(n);
14
+ if (!o.endpoint) return;
15
+ const i = e.Z({}, !0);
16
+ i.push_token = o.endpoint;
17
+ const a = e.tt(i, h.it.qa);
18
+ e.et(
19
+ i,
20
+ (n = -1) => {
21
+ r.rr() &&
22
+ (h.nt(t, h.it.qa, new Date().valueOf()),
23
+ -1 !== n && a.push(["X-Braze-Req-Tokens-Remaining", n.toString()]),
24
+ l.ot({
25
+ url: `${e.ht()}/push/unregister`,
26
+ data: i,
27
+ headers: a,
28
+ lt: (r) => {
29
+ e.ut(i, r, a) && e.ct();
30
+ },
31
+ }));
32
+ },
33
+ h.it.qa,
34
+ );
35
+ }
@@ -1,5 +1,6 @@
1
1
  import r from "../managers/braze-instance.js";
2
2
  import ra from "./push-manager-factory.js";
3
+ import { unregisterPushTokenOnServer as gr } from "./unregister-push-token-on-server.js";
3
4
  export function unregisterPush(e, n) {
4
- if (r.rr()) return ra.ra().unsubscribe(e, n);
5
+ if (r.rr()) return gr(), ra.ra().unsubscribe(e, n);
5
6
  }
@@ -1,6 +1,6 @@
1
1
  import r, { OPTIONS as U } from "../managers/braze-instance.js";
2
2
  import ro from "../util/browser-detector.js";
3
- import gr from "./l10n-manager.js";
3
+ import jr from "./l10n-manager.js";
4
4
  const Je = {
5
5
  i: !1,
6
6
  na: null,
@@ -8,7 +8,7 @@ const Je = {
8
8
  if ((Je.t(), !Je.na)) {
9
9
  let e = ro.language,
10
10
  t = !1;
11
- r.er(U.qa) && ((e = r.er(U.qa)), (t = !0)), (Je.na = new gr(e, t));
11
+ r.er(U.Aa) && ((e = r.er(U.Aa)), (t = !0)), (Je.na = new jr(e, t));
12
12
  }
13
13
  return Je.na;
14
14
  },
@@ -1,6 +1,6 @@
1
1
  import { logger as b } from "../../shared-lib/index.js";
2
2
  import zt from "../common/translations.js";
3
- export default class gr {
3
+ export default class jr {
4
4
  constructor(t, e = !1) {
5
5
  if (
6
6
  ((this.language = t),
@@ -42,7 +42,7 @@ const U = {
42
42
  Mh: "appVersionNumber",
43
43
  xa: "serviceWorkerLocation",
44
44
  Ma: "safariWebsitePushId",
45
- qa: "localization",
45
+ Aa: "localization",
46
46
  sr: "contentSecurityNonce",
47
47
  nr: "allowUserSuppliedJavascript",
48
48
  ja: "inAppMessageZIndex",
@@ -77,7 +77,7 @@ class ci {
77
77
  (this.Jh = []),
78
78
  (this.Xh = []),
79
79
  (this.In = []),
80
- (this.Vh = "6.9.0");
80
+ (this.Vh = "6.10.1");
81
81
  }
82
82
  Zh(t) {
83
83
  this.qh.Ut(t);
@@ -45,8 +45,8 @@ export default class Pt {
45
45
  return r;
46
46
  }
47
47
  Fa() {
48
- if (ro.Aa()) return ro.Aa();
49
- const t = this.j.St(s.It.Ba);
48
+ if (ro.Ba()) return ro.Ba();
49
+ const t = this.j.St(s.It.Ha);
50
50
  return t && t.os_version ? t.os_version : ro.Fa();
51
51
  }
52
52
  Ja(t) {
@@ -66,9 +66,9 @@ export default class Pt {
66
66
  }
67
67
  if (e) return "";
68
68
  const r = t.getTimezoneOffset();
69
- return this.Ha(r);
69
+ return this.Ka(r);
70
70
  }
71
- Ha(t) {
71
+ Ka(t) {
72
72
  const e = Math.trunc(t / 60),
73
73
  r = Math.trunc(t % 60);
74
74
  let s = "GMT";