@braze/service-worker 6.3.0 → 6.3.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 +162 -143
package/package.json
CHANGED
package/service-worker.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Braze Web SDK v6.3.
|
|
2
|
+
* Braze Web SDK v6.3.1
|
|
3
3
|
* (c) Braze, Inc. 2025 - http://braze.com
|
|
4
4
|
* License available at https://github.com/braze-inc/braze-web-sdk/blob/master/LICENSE
|
|
5
|
-
* Compiled on 2025-
|
|
5
|
+
* Compiled on 2025-11-13
|
|
6
6
|
*/
|
|
7
7
|
const h = {
|
|
8
8
|
A: function (a) {
|
|
@@ -30,19 +30,38 @@ const h = {
|
|
|
30
30
|
},
|
|
31
31
|
warn: function (a) {
|
|
32
32
|
h.m &&
|
|
33
|
-
((a = "Braze SDK Warning: " + a + " (v6.3.
|
|
33
|
+
((a = "Braze SDK Warning: " + a + " (v6.3.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.3.
|
|
38
|
+
((a = "Braze SDK Error: " + a + " (v6.3.1)"),
|
|
39
39
|
null != h.j ? h.j(a) : console.error(a));
|
|
40
40
|
},
|
|
41
41
|
};
|
|
42
42
|
function l() {
|
|
43
|
-
|
|
43
|
+
if ("undefined" !== typeof window && window.crypto) {
|
|
44
|
+
if ("function" === typeof window.crypto.randomUUID)
|
|
45
|
+
return window.crypto.randomUUID();
|
|
46
|
+
if ("function" === typeof window.crypto.getRandomValues)
|
|
47
|
+
try {
|
|
48
|
+
var a = new Uint8Array(16);
|
|
49
|
+
window.crypto.getRandomValues(a);
|
|
50
|
+
a[6] = (a[6] & 15) | 64;
|
|
51
|
+
a[8] = (a[8] & 63) | 128;
|
|
52
|
+
const b = Array.from(a, (e) => ("0" + e.toString(16)).slice(-2));
|
|
53
|
+
return [
|
|
54
|
+
b.slice(0, 4).join(""),
|
|
55
|
+
b.slice(4, 6).join(""),
|
|
56
|
+
b.slice(6, 8).join(""),
|
|
57
|
+
b.slice(8, 10).join(""),
|
|
58
|
+
b.slice(10, 16).join(""),
|
|
59
|
+
].join("-");
|
|
60
|
+
} catch (b) {}
|
|
61
|
+
}
|
|
62
|
+
a = (b = !1) => {
|
|
44
63
|
const e = (Math.random().toString(16) + "000000000").substr(2, 8);
|
|
45
|
-
return
|
|
64
|
+
return b ? "-" + e.substr(0, 4) + "-" + e.substr(4, 4) : e;
|
|
46
65
|
};
|
|
47
66
|
return a() + a(!0) + a(!0) + a();
|
|
48
67
|
}
|
|
@@ -50,19 +69,19 @@ function q(a) {
|
|
|
50
69
|
if ("indexedDB" in a.parent) return a.parent.indexedDB;
|
|
51
70
|
}
|
|
52
71
|
function r(a) {
|
|
53
|
-
var
|
|
72
|
+
var b;
|
|
54
73
|
try {
|
|
55
74
|
if (null == q(a)) return !1;
|
|
56
75
|
const e =
|
|
57
|
-
null === (
|
|
76
|
+
null === (b = q(a)) || void 0 === b
|
|
58
77
|
? void 0
|
|
59
|
-
:
|
|
78
|
+
: b.open("Braze IndexedDB Support Test");
|
|
60
79
|
e &&
|
|
61
80
|
((e.onupgradeneeded = () => e.result.close()),
|
|
62
81
|
(e.onsuccess = () => e.result.close()));
|
|
63
82
|
if ("undefined" !== typeof window) {
|
|
64
|
-
|
|
65
|
-
const g =
|
|
83
|
+
b = window;
|
|
84
|
+
const g = b.L || b.K || b.N;
|
|
66
85
|
if (g && g.J && g.J.id)
|
|
67
86
|
return (
|
|
68
87
|
a.j.info(
|
|
@@ -79,24 +98,24 @@ function r(a) {
|
|
|
79
98
|
);
|
|
80
99
|
}
|
|
81
100
|
}
|
|
82
|
-
function v(a,
|
|
101
|
+
function v(a, b, e) {
|
|
83
102
|
var g;
|
|
84
103
|
const d =
|
|
85
104
|
null === (g = q(a)) || void 0 === g ? void 0 : g.open(a.h.l, a.h.VERSION);
|
|
86
105
|
if (null == d) return "function" === typeof e && e(), !1;
|
|
87
106
|
d.onupgradeneeded = (f) => {
|
|
88
|
-
var
|
|
107
|
+
var c;
|
|
89
108
|
a.j.info("Upgrading indexedDB " + a.h.l + " to v" + a.h.VERSION + "...");
|
|
90
|
-
f = null === (
|
|
109
|
+
f = null === (c = f.target) || void 0 === c ? void 0 : c.result;
|
|
91
110
|
for (const k in a.h.g)
|
|
92
|
-
(
|
|
111
|
+
(c = k),
|
|
93
112
|
a.h.g.hasOwnProperty(k) &&
|
|
94
|
-
!f.objectStoreNames.contains(a.h.g[
|
|
95
|
-
f.createObjectStore(a.h.g[
|
|
113
|
+
!f.objectStoreNames.contains(a.h.g[c]) &&
|
|
114
|
+
f.createObjectStore(a.h.g[c]);
|
|
96
115
|
};
|
|
97
116
|
d.onsuccess = (f) => {
|
|
98
|
-
var
|
|
99
|
-
const k = null === (
|
|
117
|
+
var c;
|
|
118
|
+
const k = null === (c = f.target) || void 0 === c ? void 0 : c.result;
|
|
100
119
|
k.onversionchange = () => {
|
|
101
120
|
k.close();
|
|
102
121
|
"function" === typeof e && e();
|
|
@@ -104,53 +123,53 @@ function v(a, c, e) {
|
|
|
104
123
|
"Needed to close the database unexpectedly because of an upgrade in another tab",
|
|
105
124
|
);
|
|
106
125
|
};
|
|
107
|
-
|
|
126
|
+
b(k);
|
|
108
127
|
};
|
|
109
128
|
d.onerror = (f) => {
|
|
110
|
-
var
|
|
129
|
+
var c;
|
|
111
130
|
a.j.info(
|
|
112
131
|
"Could not open indexedDB " +
|
|
113
132
|
a.h.l +
|
|
114
133
|
" v" +
|
|
115
134
|
a.h.VERSION +
|
|
116
135
|
": " +
|
|
117
|
-
(null === (
|
|
136
|
+
(null === (c = f.target) || void 0 === c ? void 0 : c.errorCode),
|
|
118
137
|
);
|
|
119
138
|
"function" === typeof e && e();
|
|
120
139
|
return !0;
|
|
121
140
|
};
|
|
122
141
|
return !0;
|
|
123
142
|
}
|
|
124
|
-
function w(a,
|
|
143
|
+
function w(a, b, e, g) {
|
|
125
144
|
r(a)
|
|
126
145
|
? v(
|
|
127
146
|
a,
|
|
128
147
|
(d) => {
|
|
129
|
-
if (d.objectStoreNames.contains(
|
|
130
|
-
var f = d.transaction([
|
|
148
|
+
if (d.objectStoreNames.contains(b)) {
|
|
149
|
+
var f = d.transaction([b], "readonly");
|
|
131
150
|
f.oncomplete = () => d.close();
|
|
132
|
-
f = f.objectStore(
|
|
151
|
+
f = f.objectStore(b).openCursor(null, "prev");
|
|
133
152
|
f.onerror = () => {
|
|
134
153
|
a.j.error(
|
|
135
|
-
"Could not open cursor for " +
|
|
154
|
+
"Could not open cursor for " + b + " on indexedDB " + a.h.l,
|
|
136
155
|
);
|
|
137
156
|
"function" === typeof g && g();
|
|
138
157
|
};
|
|
139
|
-
f.onsuccess = (
|
|
158
|
+
f.onsuccess = (c) => {
|
|
140
159
|
var k;
|
|
141
|
-
|
|
142
|
-
null !=
|
|
143
|
-
? e(
|
|
160
|
+
c = null === (k = c.target) || void 0 === k ? void 0 : k.result;
|
|
161
|
+
null != c && null != c.value && null != c.key
|
|
162
|
+
? e(c.key, c.value)
|
|
144
163
|
: "function" === typeof g && g();
|
|
145
164
|
};
|
|
146
165
|
} else
|
|
147
166
|
a.j.error(
|
|
148
167
|
"Could not retrieve last record from " +
|
|
149
|
-
|
|
168
|
+
b +
|
|
150
169
|
" on indexedDB " +
|
|
151
170
|
a.h.l +
|
|
152
171
|
" - " +
|
|
153
|
-
|
|
172
|
+
b +
|
|
154
173
|
" is not a valid objectStore",
|
|
155
174
|
),
|
|
156
175
|
"function" === typeof g && g(),
|
|
@@ -163,27 +182,27 @@ function w(a, c, e, g) {
|
|
|
163
182
|
class x {
|
|
164
183
|
constructor() {
|
|
165
184
|
var a = y,
|
|
166
|
-
|
|
185
|
+
b = h;
|
|
167
186
|
this.h = a;
|
|
168
|
-
this.j =
|
|
187
|
+
this.j = b;
|
|
169
188
|
this.parent = "undefined" === typeof window ? self : window;
|
|
170
189
|
this.h = a;
|
|
171
|
-
this.j =
|
|
190
|
+
this.j = b;
|
|
172
191
|
}
|
|
173
|
-
setItem(a,
|
|
192
|
+
setItem(a, b, e, g, d) {
|
|
174
193
|
if (!r(this)) return "function" === typeof d && d(), !1;
|
|
175
194
|
const f = this;
|
|
176
195
|
return v(
|
|
177
196
|
this,
|
|
178
|
-
(
|
|
179
|
-
if (
|
|
180
|
-
var k =
|
|
181
|
-
k.oncomplete = () =>
|
|
182
|
-
k = k.objectStore(a).put(e,
|
|
197
|
+
(c) => {
|
|
198
|
+
if (c.objectStoreNames.contains(a)) {
|
|
199
|
+
var k = c.transaction([a], "readwrite");
|
|
200
|
+
k.oncomplete = () => c.close();
|
|
201
|
+
k = k.objectStore(a).put(e, b);
|
|
183
202
|
k.onerror = () => {
|
|
184
203
|
f.j.error(
|
|
185
204
|
"Could not store object " +
|
|
186
|
-
|
|
205
|
+
b +
|
|
187
206
|
" in " +
|
|
188
207
|
a +
|
|
189
208
|
" on indexedDB " +
|
|
@@ -197,7 +216,7 @@ class x {
|
|
|
197
216
|
} else
|
|
198
217
|
f.j.error(
|
|
199
218
|
"Could not store object " +
|
|
200
|
-
|
|
219
|
+
b +
|
|
201
220
|
" in " +
|
|
202
221
|
a +
|
|
203
222
|
" on indexedDB " +
|
|
@@ -207,38 +226,38 @@ class x {
|
|
|
207
226
|
" is not a valid objectStore",
|
|
208
227
|
),
|
|
209
228
|
"function" === typeof d && d(),
|
|
210
|
-
|
|
229
|
+
c.close();
|
|
211
230
|
},
|
|
212
231
|
d,
|
|
213
232
|
);
|
|
214
233
|
}
|
|
215
|
-
getItem(a,
|
|
234
|
+
getItem(a, b, e) {
|
|
216
235
|
if (!r(this)) return !1;
|
|
217
236
|
const g = this;
|
|
218
237
|
return v(this, (d) => {
|
|
219
238
|
if (d.objectStoreNames.contains(a)) {
|
|
220
239
|
var f = d.transaction([a], "readonly");
|
|
221
240
|
f.oncomplete = () => d.close();
|
|
222
|
-
f = f.objectStore(a).get(
|
|
241
|
+
f = f.objectStore(a).get(b);
|
|
223
242
|
f.onerror = () => {
|
|
224
243
|
g.j.error(
|
|
225
244
|
"Could not retrieve object " +
|
|
226
|
-
|
|
245
|
+
b +
|
|
227
246
|
" in " +
|
|
228
247
|
a +
|
|
229
248
|
" on indexedDB " +
|
|
230
249
|
g.h.l,
|
|
231
250
|
);
|
|
232
251
|
};
|
|
233
|
-
f.onsuccess = (
|
|
252
|
+
f.onsuccess = (c) => {
|
|
234
253
|
var k;
|
|
235
|
-
|
|
236
|
-
null !=
|
|
254
|
+
c = null === (k = c.target) || void 0 === k ? void 0 : k.result;
|
|
255
|
+
null != c && e(c);
|
|
237
256
|
};
|
|
238
257
|
} else
|
|
239
258
|
g.j.error(
|
|
240
259
|
"Could not retrieve object " +
|
|
241
|
-
|
|
260
|
+
b +
|
|
242
261
|
" in " +
|
|
243
262
|
a +
|
|
244
263
|
" on indexedDB " +
|
|
@@ -259,18 +278,18 @@ class x {
|
|
|
259
278
|
this.h.g[g] !== this.h.g.B &&
|
|
260
279
|
a.push(this.h.g[g]);
|
|
261
280
|
}
|
|
262
|
-
const
|
|
281
|
+
const b = this;
|
|
263
282
|
return v(this, function (e) {
|
|
264
283
|
const g = e.transaction(a, "readwrite");
|
|
265
284
|
g.oncomplete = () => e.close();
|
|
266
285
|
for (let d = 0; d < a.length; d++)
|
|
267
286
|
g.objectStore(a[d]).clear().onerror = function () {
|
|
268
|
-
|
|
269
|
-
"Could not clear " + this.source.name + " on indexedDB " +
|
|
287
|
+
b.j.error(
|
|
288
|
+
"Could not clear " + this.source.name + " on indexedDB " + b.h.l,
|
|
270
289
|
);
|
|
271
290
|
};
|
|
272
291
|
g.onerror = function () {
|
|
273
|
-
|
|
292
|
+
b.j.error("Could not clear object stores on indexedDB " + b.h.l);
|
|
274
293
|
};
|
|
275
294
|
});
|
|
276
295
|
}
|
|
@@ -291,8 +310,8 @@ var y = {
|
|
|
291
310
|
s: 1,
|
|
292
311
|
};
|
|
293
312
|
function z() {
|
|
294
|
-
return new Promise(function (a,
|
|
295
|
-
w(new x(), y.g.B,
|
|
313
|
+
return new Promise(function (a, b) {
|
|
314
|
+
w(new x(), y.g.B, b, a);
|
|
296
315
|
});
|
|
297
316
|
}
|
|
298
317
|
function A() {
|
|
@@ -300,7 +319,7 @@ function A() {
|
|
|
300
319
|
w(
|
|
301
320
|
new x(),
|
|
302
321
|
y.g.I,
|
|
303
|
-
(
|
|
322
|
+
(b, e) => {
|
|
304
323
|
a(e);
|
|
305
324
|
},
|
|
306
325
|
() => {
|
|
@@ -309,22 +328,22 @@ function A() {
|
|
|
309
328
|
);
|
|
310
329
|
});
|
|
311
330
|
}
|
|
312
|
-
function C(a,
|
|
331
|
+
function C(a, b, e) {
|
|
313
332
|
h.info(
|
|
314
|
-
`${
|
|
333
|
+
`${b} due to SDK Authentication failure with error code ${e.error_code}. The data will be logged on the user's next session start.`,
|
|
315
334
|
);
|
|
316
335
|
new x().setItem(y.g.G, l(), a);
|
|
317
336
|
}
|
|
318
|
-
function D(a,
|
|
337
|
+
function D(a, b, e) {
|
|
319
338
|
return new Promise(function (g, d) {
|
|
320
339
|
const f = {};
|
|
321
340
|
f.time = Math.floor(new Date().valueOf() / 1e3);
|
|
322
341
|
f.device_id = e;
|
|
323
342
|
f.api_key = a;
|
|
324
|
-
f.sdk_version = "6.3.
|
|
343
|
+
f.sdk_version = "6.3.1";
|
|
325
344
|
f.sdk_flavor = "amp";
|
|
326
345
|
f.respond_with = { config: { config_time: 0 } };
|
|
327
|
-
fetch(
|
|
346
|
+
fetch(b + "/data/", {
|
|
328
347
|
method: "POST",
|
|
329
348
|
headers: {
|
|
330
349
|
"Content-type": "application/json",
|
|
@@ -334,41 +353,41 @@ function D(a, c, e) {
|
|
|
334
353
|
},
|
|
335
354
|
body: JSON.stringify(f),
|
|
336
355
|
})
|
|
337
|
-
.then(function (
|
|
338
|
-
|
|
339
|
-
return
|
|
356
|
+
.then(function (c) {
|
|
357
|
+
c.ok || h.error("Unable to get config: " + c.status);
|
|
358
|
+
return c.json();
|
|
340
359
|
})
|
|
341
|
-
.then(function (
|
|
342
|
-
|
|
343
|
-
|
|
360
|
+
.then(function (c) {
|
|
361
|
+
c.error && (h.error("Unable to get config: " + c.error), d());
|
|
362
|
+
c.auth_error &&
|
|
344
363
|
(h.error(
|
|
345
364
|
"Unable to get config due to authentication error. SDK Authentication does not support AMP pages.",
|
|
346
365
|
),
|
|
347
366
|
d());
|
|
348
|
-
if (!
|
|
349
|
-
|
|
350
|
-
var k = "=".repeat((4 - (
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
k = new Uint8Array(
|
|
354
|
-
for (let m = 0; m <
|
|
367
|
+
if (!c.error && !c.auth_error) {
|
|
368
|
+
c = c.config.vapid_public_key;
|
|
369
|
+
var k = "=".repeat((4 - (c.length % 4)) % 4);
|
|
370
|
+
c = (c + k).replace(/\-/g, "+").replace(/_/g, "/");
|
|
371
|
+
c = atob(c);
|
|
372
|
+
k = new Uint8Array(c.length);
|
|
373
|
+
for (let m = 0; m < c.length; ++m) k[m] = c.charCodeAt(m);
|
|
355
374
|
g({ userVisibleOnly: !0, applicationServerKey: k });
|
|
356
375
|
}
|
|
357
376
|
})
|
|
358
|
-
.catch(function (
|
|
359
|
-
h.error("Unable to get config: " +
|
|
377
|
+
.catch(function (c) {
|
|
378
|
+
h.error("Unable to get config: " + c);
|
|
360
379
|
d();
|
|
361
380
|
});
|
|
362
381
|
});
|
|
363
382
|
}
|
|
364
|
-
function E(a,
|
|
383
|
+
function E(a, b, e, g, d, f, c, k, m) {
|
|
365
384
|
return A().then(
|
|
366
385
|
(p) =>
|
|
367
386
|
new Promise(function (O, B) {
|
|
368
387
|
const t = {};
|
|
369
388
|
t.device_id = e;
|
|
370
389
|
t.api_key = a;
|
|
371
|
-
t.sdk_version = "6.3.
|
|
390
|
+
t.sdk_version = "6.3.1";
|
|
372
391
|
null != f && (t.sdk_flavor = f);
|
|
373
392
|
var u = null;
|
|
374
393
|
let H = null,
|
|
@@ -401,7 +420,7 @@ function E(a, c, e, g, d, f, b, k, m) {
|
|
|
401
420
|
"X-Braze-Req-Attempt": 1,
|
|
402
421
|
};
|
|
403
422
|
p && m && (u["X-Braze-Auth-Signature"] = p);
|
|
404
|
-
fetch(
|
|
423
|
+
fetch(b + "/data/", {
|
|
405
424
|
method: "POST",
|
|
406
425
|
headers: u,
|
|
407
426
|
body: JSON.stringify(t),
|
|
@@ -413,7 +432,7 @@ function E(a, c, e, g, d, f, b, k, m) {
|
|
|
413
432
|
.then(function (n) {
|
|
414
433
|
n.error && (h.error(k + " " + n.error), B());
|
|
415
434
|
n.auth_error && (C(t, k, n.auth_error), B());
|
|
416
|
-
n.error || n.auth_error || (h.info(
|
|
435
|
+
n.error || n.auth_error || (h.info(c), O());
|
|
417
436
|
})
|
|
418
437
|
.catch(function (n) {
|
|
419
438
|
h.error(k + " " + n);
|
|
@@ -422,7 +441,7 @@ function E(a, c, e, g, d, f, b, k, m) {
|
|
|
422
441
|
}),
|
|
423
442
|
);
|
|
424
443
|
}
|
|
425
|
-
function F(a,
|
|
444
|
+
function F(a, b) {
|
|
426
445
|
return z()
|
|
427
446
|
.then(function () {
|
|
428
447
|
return A();
|
|
@@ -435,7 +454,7 @@ function F(a, c) {
|
|
|
435
454
|
a.time = g;
|
|
436
455
|
a.user_id = d.userId;
|
|
437
456
|
f.events = [a];
|
|
438
|
-
f.sdk_version = "6.3.
|
|
457
|
+
f.sdk_version = "6.3.1";
|
|
439
458
|
g = {
|
|
440
459
|
"Content-Type": "application/json",
|
|
441
460
|
"X-Braze-Api-Key": f.api_key,
|
|
@@ -448,18 +467,18 @@ function F(a, c) {
|
|
|
448
467
|
headers: g,
|
|
449
468
|
body: JSON.stringify(f),
|
|
450
469
|
})
|
|
451
|
-
.then(function (
|
|
452
|
-
|
|
453
|
-
return
|
|
470
|
+
.then(function (c) {
|
|
471
|
+
c.ok || h.error("Unable to log " + b + ": " + c.status);
|
|
472
|
+
return c.json();
|
|
454
473
|
})
|
|
455
|
-
.then(function (
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
474
|
+
.then(function (c) {
|
|
475
|
+
c.error && h.error("Unable to log " + b + ":", c.error);
|
|
476
|
+
c.auth_error && C(f, "Unable to log " + b, c.auth_error);
|
|
477
|
+
c.error || c.auth_error || h.info("Successfully logged " + b);
|
|
459
478
|
return Promise.resolve();
|
|
460
479
|
})
|
|
461
|
-
.catch(function (
|
|
462
|
-
h.error("Unable to log " +
|
|
480
|
+
.catch(function (c) {
|
|
481
|
+
h.error("Unable to log " + b + ":", c);
|
|
463
482
|
return Promise.resolve();
|
|
464
483
|
});
|
|
465
484
|
});
|
|
@@ -482,14 +501,14 @@ function J() {
|
|
|
482
501
|
h.error("Missing base URL in query params.");
|
|
483
502
|
return null;
|
|
484
503
|
}
|
|
485
|
-
function K(a,
|
|
504
|
+
function K(a, b) {
|
|
486
505
|
self.clients.matchAll().then(function (e) {
|
|
487
506
|
for (let g = 0; g < e.length; g++)
|
|
488
|
-
e[g].postMessage({ command: a, payload:
|
|
507
|
+
e[g].postMessage({ command: a, payload: b });
|
|
489
508
|
});
|
|
490
509
|
}
|
|
491
|
-
function L(a,
|
|
492
|
-
return D(a,
|
|
510
|
+
function L(a, b, e, g, d) {
|
|
511
|
+
return D(a, b, e)
|
|
493
512
|
.then(function (f) {
|
|
494
513
|
return self.registration.pushManager.subscribe(f);
|
|
495
514
|
})
|
|
@@ -497,7 +516,7 @@ function L(a, c, e, g, d) {
|
|
|
497
516
|
K("amp-web-push-subscribe", null);
|
|
498
517
|
return E(
|
|
499
518
|
a,
|
|
500
|
-
|
|
519
|
+
b,
|
|
501
520
|
e,
|
|
502
521
|
g,
|
|
503
522
|
f,
|
|
@@ -526,7 +545,7 @@ function M() {
|
|
|
526
545
|
}
|
|
527
546
|
function N() {
|
|
528
547
|
const a = new x();
|
|
529
|
-
return new Promise(function (
|
|
548
|
+
return new Promise(function (b, e) {
|
|
530
549
|
w(
|
|
531
550
|
a,
|
|
532
551
|
y.g.o,
|
|
@@ -539,7 +558,7 @@ function N() {
|
|
|
539
558
|
d.sdkAuthEnabled,
|
|
540
559
|
)
|
|
541
560
|
.then(function () {
|
|
542
|
-
|
|
561
|
+
b();
|
|
543
562
|
})
|
|
544
563
|
.catch(function () {
|
|
545
564
|
e();
|
|
@@ -551,10 +570,10 @@ function N() {
|
|
|
551
570
|
w(
|
|
552
571
|
a,
|
|
553
572
|
y.g.v,
|
|
554
|
-
function (f,
|
|
555
|
-
L(g, d,
|
|
573
|
+
function (f, c) {
|
|
574
|
+
L(g, d, c, null)
|
|
556
575
|
.then(function () {
|
|
557
|
-
|
|
576
|
+
b();
|
|
558
577
|
})
|
|
559
578
|
.catch(function () {
|
|
560
579
|
e();
|
|
@@ -562,14 +581,14 @@ function N() {
|
|
|
562
581
|
},
|
|
563
582
|
function () {
|
|
564
583
|
const f = l();
|
|
565
|
-
new Promise(function (
|
|
566
|
-
a.setItem(y.g.v, y.s, f,
|
|
584
|
+
new Promise(function (c, k) {
|
|
585
|
+
a.setItem(y.g.v, y.s, f, c, k);
|
|
567
586
|
})
|
|
568
587
|
.then(function () {
|
|
569
588
|
return L(g, d, f, null);
|
|
570
589
|
})
|
|
571
590
|
.then(function () {
|
|
572
|
-
|
|
591
|
+
b();
|
|
573
592
|
})
|
|
574
593
|
.catch(function () {
|
|
575
594
|
e();
|
|
@@ -579,8 +598,8 @@ function N() {
|
|
|
579
598
|
},
|
|
580
599
|
);
|
|
581
600
|
}).then(function () {
|
|
582
|
-
return new Promise(function (
|
|
583
|
-
a.setItem(y.g.C, y.s, !0,
|
|
601
|
+
return new Promise(function (b, e) {
|
|
602
|
+
a.setItem(y.g.C, y.s, !0, b, e);
|
|
584
603
|
});
|
|
585
604
|
});
|
|
586
605
|
}
|
|
@@ -593,7 +612,7 @@ function P() {
|
|
|
593
612
|
.then(function () {
|
|
594
613
|
K("amp-web-push-unsubscribe", null);
|
|
595
614
|
const a = new x();
|
|
596
|
-
return new Promise(function (
|
|
615
|
+
return new Promise(function (b, e) {
|
|
597
616
|
w(
|
|
598
617
|
a,
|
|
599
618
|
y.g.o,
|
|
@@ -610,7 +629,7 @@ function P() {
|
|
|
610
629
|
d.sdkAuthEnabled,
|
|
611
630
|
)
|
|
612
631
|
.then(function () {
|
|
613
|
-
|
|
632
|
+
b();
|
|
614
633
|
})
|
|
615
634
|
.catch(function () {
|
|
616
635
|
e();
|
|
@@ -635,7 +654,7 @@ function P() {
|
|
|
635
654
|
null,
|
|
636
655
|
)
|
|
637
656
|
.then(function () {
|
|
638
|
-
|
|
657
|
+
b();
|
|
639
658
|
})
|
|
640
659
|
.catch(function () {
|
|
641
660
|
e();
|
|
@@ -649,8 +668,8 @@ function P() {
|
|
|
649
668
|
},
|
|
650
669
|
);
|
|
651
670
|
}).then(function () {
|
|
652
|
-
return new Promise(function (
|
|
653
|
-
a.setItem(y.g.C, y.s, !1,
|
|
671
|
+
return new Promise(function (b, e) {
|
|
672
|
+
a.setItem(y.g.C, y.s, !1, b, e);
|
|
654
673
|
});
|
|
655
674
|
});
|
|
656
675
|
})
|
|
@@ -659,9 +678,9 @@ function P() {
|
|
|
659
678
|
return Promise.reject();
|
|
660
679
|
});
|
|
661
680
|
}
|
|
662
|
-
function Q(a,
|
|
681
|
+
function Q(a, b) {
|
|
663
682
|
a.waitUntil(
|
|
664
|
-
|
|
683
|
+
b.catch(function (e) {
|
|
665
684
|
e && h.info(e);
|
|
666
685
|
}),
|
|
667
686
|
);
|
|
@@ -672,14 +691,14 @@ function R(a) {
|
|
|
672
691
|
return Promise.reject(
|
|
673
692
|
"Server has no pending push message for this registration. Ignoring push event.",
|
|
674
693
|
);
|
|
675
|
-
const
|
|
694
|
+
const b = a.t,
|
|
676
695
|
e = a.a,
|
|
677
696
|
g = a.i,
|
|
678
697
|
d = a.img,
|
|
679
698
|
f = { url: a.u, ab_ids: { cid: a.cid }, extra: a.e },
|
|
680
|
-
|
|
699
|
+
c = a.ri;
|
|
681
700
|
a.ab_push_fetch_test_triggers_key &&
|
|
682
|
-
(h.info("Service worker 6.3.
|
|
701
|
+
(h.info("Service worker 6.3.1 found trigger fetch key in push payload."),
|
|
683
702
|
(f.fetchTriggers = !0));
|
|
684
703
|
var k = a.ab_cd;
|
|
685
704
|
null != k &&
|
|
@@ -704,13 +723,13 @@ function R(a) {
|
|
|
704
723
|
f.actionTargets = k;
|
|
705
724
|
h.info("Displaying push notification!");
|
|
706
725
|
return self.registration
|
|
707
|
-
.showNotification(
|
|
726
|
+
.showNotification(b, {
|
|
708
727
|
body: e,
|
|
709
728
|
icon: g,
|
|
710
729
|
image: d,
|
|
711
730
|
data: f,
|
|
712
731
|
actions: a,
|
|
713
|
-
requireInteraction:
|
|
732
|
+
requireInteraction: c,
|
|
714
733
|
})
|
|
715
734
|
.catch(function (m) {
|
|
716
735
|
h.info(m);
|
|
@@ -723,12 +742,12 @@ self.addEventListener("activate", function () {
|
|
|
723
742
|
return self.clients.claim();
|
|
724
743
|
});
|
|
725
744
|
self.addEventListener("push", function (a) {
|
|
726
|
-
h.info("Service worker 6.3.
|
|
745
|
+
h.info("Service worker 6.3.1 received push");
|
|
727
746
|
null != a.data && null != a.data.json
|
|
728
747
|
? Q(a, R(a.data.json()))
|
|
729
748
|
: Q(
|
|
730
749
|
a,
|
|
731
|
-
new Promise(function (
|
|
750
|
+
new Promise(function (b, e) {
|
|
732
751
|
w(new x(), y.g.o, function (g, d) {
|
|
733
752
|
const f = d.data;
|
|
734
753
|
z()
|
|
@@ -742,23 +761,23 @@ self.addEventListener("push", function (a) {
|
|
|
742
761
|
body: JSON.stringify(f),
|
|
743
762
|
});
|
|
744
763
|
})
|
|
745
|
-
.then(function (
|
|
746
|
-
return
|
|
747
|
-
?
|
|
764
|
+
.then(function (c) {
|
|
765
|
+
return c.ok
|
|
766
|
+
? c.json()
|
|
748
767
|
: (h.error(
|
|
749
768
|
"Unable to retrieve push payload from server: " +
|
|
750
|
-
|
|
769
|
+
c.status,
|
|
751
770
|
),
|
|
752
771
|
Promise.reject());
|
|
753
772
|
})
|
|
754
|
-
.then(function (
|
|
773
|
+
.then(function (c) {
|
|
755
774
|
h.info("Retrieved push payload from server");
|
|
756
|
-
|
|
775
|
+
b(R(c));
|
|
757
776
|
})
|
|
758
|
-
.catch(function (
|
|
777
|
+
.catch(function (c) {
|
|
759
778
|
e(
|
|
760
779
|
"Unable to retrieve push payload from server or user has opt-out: " +
|
|
761
|
-
|
|
780
|
+
c,
|
|
762
781
|
);
|
|
763
782
|
});
|
|
764
783
|
});
|
|
@@ -775,8 +794,8 @@ self.addEventListener("notificationclick", function (a) {
|
|
|
775
794
|
a.notification.data &&
|
|
776
795
|
a.notification.data.ab_ids)
|
|
777
796
|
) {
|
|
778
|
-
var
|
|
779
|
-
var e =
|
|
797
|
+
var b = null != a.action && "" !== a.action;
|
|
798
|
+
var e = b
|
|
780
799
|
? F(
|
|
781
800
|
{
|
|
782
801
|
name: "ca",
|
|
@@ -788,17 +807,17 @@ self.addEventListener("notificationclick", function (a) {
|
|
|
788
807
|
{ name: "pc", data: { cid: a.notification.data.ab_ids.cid } },
|
|
789
808
|
"push click",
|
|
790
809
|
);
|
|
791
|
-
if (!
|
|
792
|
-
const
|
|
810
|
+
if (!b) {
|
|
811
|
+
const c = {
|
|
793
812
|
lastClick: new Date().valueOf(),
|
|
794
813
|
trackingString: a.notification.data.ab_ids.cid,
|
|
795
814
|
};
|
|
796
|
-
a.notification.data.fetchTriggers && (
|
|
815
|
+
a.notification.data.fetchTriggers && (c.fetchTriggers = !0);
|
|
797
816
|
const k = new x();
|
|
798
817
|
var g = e
|
|
799
818
|
.then(function () {
|
|
800
819
|
return new Promise(function (m, p) {
|
|
801
|
-
k.setItem(y.g.H, y.s,
|
|
820
|
+
k.setItem(y.g.H, y.s, c, m, p);
|
|
802
821
|
});
|
|
803
822
|
})
|
|
804
823
|
.catch(function () {
|
|
@@ -806,7 +825,7 @@ self.addEventListener("notificationclick", function (a) {
|
|
|
806
825
|
return Promise.resolve();
|
|
807
826
|
});
|
|
808
827
|
}
|
|
809
|
-
if (
|
|
828
|
+
if (b) var d = a.notification.data.actionTargets[a.action];
|
|
810
829
|
else if (((d = a.notification.data.url), null == d || "" === d)) d = "/";
|
|
811
830
|
var f;
|
|
812
831
|
null != d &&
|
|
@@ -822,11 +841,11 @@ self.addEventListener("pushsubscriptionchange", function (a) {
|
|
|
822
841
|
a,
|
|
823
842
|
z()
|
|
824
843
|
.then(function () {
|
|
825
|
-
let
|
|
826
|
-
null != a.oldSubscription && (
|
|
827
|
-
return self.registration.pushManager.subscribe(
|
|
844
|
+
let b = { userVisibleOnly: !0 };
|
|
845
|
+
null != a.oldSubscription && (b = a.oldSubscription.options);
|
|
846
|
+
return self.registration.pushManager.subscribe(b);
|
|
828
847
|
})
|
|
829
|
-
.then(function (
|
|
848
|
+
.then(function (b) {
|
|
830
849
|
return new Promise(function (e, g) {
|
|
831
850
|
w(new x(), y.g.o, function (d, f) {
|
|
832
851
|
E(
|
|
@@ -834,7 +853,7 @@ self.addEventListener("pushsubscriptionchange", function (a) {
|
|
|
834
853
|
f.baseUrl,
|
|
835
854
|
f.data.device_id,
|
|
836
855
|
f.userId,
|
|
837
|
-
|
|
856
|
+
b,
|
|
838
857
|
null,
|
|
839
858
|
"Successfully resubscribed user after expiration",
|
|
840
859
|
"Unable to resubscribe user",
|