@braze/service-worker 6.6.0 → 6.7.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/package.json +1 -1
- package/service-worker.js +60 -52
package/package.json
CHANGED
package/service-worker.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Braze Web SDK v6.
|
|
2
|
+
* Braze Web SDK v6.7.1
|
|
3
3
|
* (c) Braze, Inc. 2026 - http://braze.com
|
|
4
4
|
* License available at https://github.com/braze-inc/braze-web-sdk/blob/master/LICENSE
|
|
5
|
-
* Compiled on 2026-
|
|
5
|
+
* Compiled on 2026-04-17
|
|
6
6
|
*/
|
|
7
7
|
const h = {
|
|
8
8
|
A: function (a) {
|
|
@@ -30,12 +30,12 @@ const h = {
|
|
|
30
30
|
},
|
|
31
31
|
warn: function (a) {
|
|
32
32
|
h.m &&
|
|
33
|
-
((a = "Braze SDK Warning: " + a + " (v6.
|
|
33
|
+
((a = "Braze SDK Warning: " + a + " (v6.7.1)"),
|
|
34
34
|
null != h.j ? h.j(a) : console.warn(a));
|
|
35
35
|
},
|
|
36
36
|
error: function (a) {
|
|
37
37
|
h.m &&
|
|
38
|
-
((a = "Braze SDK Error: " + a + " (v6.
|
|
38
|
+
((a = "Braze SDK Error: " + a + " (v6.7.1)"),
|
|
39
39
|
null != h.j ? h.j(a) : console.error(a));
|
|
40
40
|
},
|
|
41
41
|
};
|
|
@@ -340,7 +340,7 @@ function D(a, b, e) {
|
|
|
340
340
|
f.time = Math.floor(new Date().valueOf() / 1e3);
|
|
341
341
|
f.device_id = e;
|
|
342
342
|
f.api_key = a;
|
|
343
|
-
f.sdk_version = "6.
|
|
343
|
+
f.sdk_version = "6.7.1";
|
|
344
344
|
f.sdk_flavor = "amp";
|
|
345
345
|
f.respond_with = { config: { config_time: 0 } };
|
|
346
346
|
fetch(b + "/data/", {
|
|
@@ -383,11 +383,11 @@ function D(a, b, e) {
|
|
|
383
383
|
function E(a, b, e, g, d, f, c, k, m) {
|
|
384
384
|
return A().then(
|
|
385
385
|
(p) =>
|
|
386
|
-
new Promise(function (
|
|
386
|
+
new Promise(function (P, B) {
|
|
387
387
|
const t = {};
|
|
388
388
|
t.device_id = e;
|
|
389
389
|
t.api_key = a;
|
|
390
|
-
t.sdk_version = "6.
|
|
390
|
+
t.sdk_version = "6.7.1";
|
|
391
391
|
null != f && (t.sdk_flavor = f);
|
|
392
392
|
var u = null;
|
|
393
393
|
let H = null,
|
|
@@ -432,7 +432,7 @@ function E(a, b, e, g, d, f, c, k, m) {
|
|
|
432
432
|
.then(function (n) {
|
|
433
433
|
n.error && (h.error(k + " " + n.error), B());
|
|
434
434
|
n.auth_error && (C(t, k, n.auth_error), B());
|
|
435
|
-
n.error || n.auth_error || (h.info(c),
|
|
435
|
+
n.error || n.auth_error || (h.info(c), P());
|
|
436
436
|
})
|
|
437
437
|
.catch(function (n) {
|
|
438
438
|
h.error(k + " " + n);
|
|
@@ -454,7 +454,7 @@ function F(a, b) {
|
|
|
454
454
|
a.time = g;
|
|
455
455
|
a.user_id = d.userId;
|
|
456
456
|
f.events = [a];
|
|
457
|
-
f.sdk_version = "6.
|
|
457
|
+
f.sdk_version = "6.7.1";
|
|
458
458
|
g = {
|
|
459
459
|
"Content-Type": "application/json",
|
|
460
460
|
"X-Braze-Api-Key": f.api_key,
|
|
@@ -603,7 +603,7 @@ function N() {
|
|
|
603
603
|
});
|
|
604
604
|
});
|
|
605
605
|
}
|
|
606
|
-
function
|
|
606
|
+
function O() {
|
|
607
607
|
return self.registration.pushManager
|
|
608
608
|
.getSubscription()
|
|
609
609
|
.then(function (a) {
|
|
@@ -687,6 +687,11 @@ function Q(a, b) {
|
|
|
687
687
|
}
|
|
688
688
|
h.A(!0);
|
|
689
689
|
function R(a) {
|
|
690
|
+
if (null == a) return !1;
|
|
691
|
+
a = a._ab;
|
|
692
|
+
return !0 === a || "true" === a;
|
|
693
|
+
}
|
|
694
|
+
function S(a) {
|
|
690
695
|
if (null == a || 0 === Object.keys(a).length)
|
|
691
696
|
return Promise.reject(
|
|
692
697
|
"Server has no pending push message for this registration. Ignoring push event.",
|
|
@@ -698,7 +703,7 @@ function R(a) {
|
|
|
698
703
|
f = { url: a.u, ab_ids: { cid: a.cid }, extra: a.e },
|
|
699
704
|
c = a.ri;
|
|
700
705
|
a.ab_push_fetch_test_triggers_key &&
|
|
701
|
-
(h.info("Service worker 6.
|
|
706
|
+
(h.info("Service worker 6.7.1 found trigger fetch key in push payload."),
|
|
702
707
|
(f.fetchTriggers = !0));
|
|
703
708
|
var k = a.ab_cd;
|
|
704
709
|
null != k &&
|
|
@@ -742,47 +747,50 @@ self.addEventListener("activate", function () {
|
|
|
742
747
|
return self.clients.claim();
|
|
743
748
|
});
|
|
744
749
|
self.addEventListener("push", function (a) {
|
|
745
|
-
h.info("Service worker 6.
|
|
746
|
-
null != a.data && null != a.data.json
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
.then(function (c) {
|
|
765
|
-
return c.ok
|
|
766
|
-
? c.json()
|
|
767
|
-
: (h.error(
|
|
768
|
-
"Unable to retrieve push payload from server: " +
|
|
769
|
-
c.status,
|
|
770
|
-
),
|
|
771
|
-
Promise.reject());
|
|
772
|
-
})
|
|
773
|
-
.then(function (c) {
|
|
774
|
-
h.info("Retrieved push payload from server");
|
|
775
|
-
b(R(c));
|
|
776
|
-
})
|
|
777
|
-
.catch(function (c) {
|
|
778
|
-
e(
|
|
779
|
-
"Unable to retrieve push payload from server or user has opt-out: " +
|
|
780
|
-
c,
|
|
781
|
-
);
|
|
750
|
+
h.info("Service worker 6.7.1 received push");
|
|
751
|
+
if (null != a.data && null != a.data.json) {
|
|
752
|
+
const b = a.data.json();
|
|
753
|
+
R(b) ? Q(a, S(b)) : h.info("Service worker 6.7.1 ignoring non-Braze push");
|
|
754
|
+
} else
|
|
755
|
+
Q(
|
|
756
|
+
a,
|
|
757
|
+
new Promise(function (b, e) {
|
|
758
|
+
w(new x(), y.g.o, function (g, d) {
|
|
759
|
+
const f = d.data;
|
|
760
|
+
z()
|
|
761
|
+
.then(function () {
|
|
762
|
+
return fetch(d.baseUrl + "/web_push/", {
|
|
763
|
+
method: "POST",
|
|
764
|
+
headers: {
|
|
765
|
+
"Content-type": "application/json",
|
|
766
|
+
"X-Braze-Api-Key": f.api_key,
|
|
767
|
+
},
|
|
768
|
+
body: JSON.stringify(f),
|
|
782
769
|
});
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
770
|
+
})
|
|
771
|
+
.then(function (c) {
|
|
772
|
+
return c.ok
|
|
773
|
+
? c.json()
|
|
774
|
+
: (h.error(
|
|
775
|
+
"Unable to retrieve push payload from server: " + c.status,
|
|
776
|
+
),
|
|
777
|
+
Promise.reject());
|
|
778
|
+
})
|
|
779
|
+
.then(function (c) {
|
|
780
|
+
h.info("Retrieved push payload from server");
|
|
781
|
+
R(c)
|
|
782
|
+
? b(S(c))
|
|
783
|
+
: (h.info("Service worker 6.7.1 ignoring non-Braze push"), b());
|
|
784
|
+
})
|
|
785
|
+
.catch(function (c) {
|
|
786
|
+
e(
|
|
787
|
+
"Unable to retrieve push payload from server or user has opt-out: " +
|
|
788
|
+
c,
|
|
789
|
+
);
|
|
790
|
+
});
|
|
791
|
+
});
|
|
792
|
+
}),
|
|
793
|
+
);
|
|
786
794
|
});
|
|
787
795
|
self.addEventListener("notificationclick", function (a) {
|
|
788
796
|
if (
|
|
@@ -887,7 +895,7 @@ self.addEventListener("message", function (a) {
|
|
|
887
895
|
case "amp-web-push-subscribe":
|
|
888
896
|
return N();
|
|
889
897
|
case "amp-web-push-unsubscribe":
|
|
890
|
-
return
|
|
898
|
+
return O();
|
|
891
899
|
default:
|
|
892
900
|
return Promise.resolve();
|
|
893
901
|
}
|