@braze/service-worker 4.8.3 → 4.9.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.
- package/package.json +1 -1
- package/service-worker.js +399 -376
package/package.json
CHANGED
package/service-worker.js
CHANGED
|
@@ -1,110 +1,104 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Braze Web SDK v4.
|
|
2
|
+
* Braze Web SDK v4.9.0
|
|
3
3
|
* (c) Braze, Inc. 2023 - http://braze.com
|
|
4
4
|
* License available at https://github.com/braze-inc/braze-web-sdk/blob/master/LICENSE
|
|
5
|
-
* Compiled on 2023-
|
|
5
|
+
* Compiled on 2023-09-15
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var b = "=".repeat((4 - (a.length % 4)) % 4);
|
|
10
|
-
a = (a + b).replace(/\-/g, "+").replace(/_/g, "/");
|
|
11
|
-
a = atob(a);
|
|
12
|
-
b = new Uint8Array(a.length);
|
|
13
|
-
for (let c = 0; c < a.length; ++c) b[c] = a.charCodeAt(c);
|
|
14
|
-
return b;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
const l = {
|
|
18
|
-
H: () => {
|
|
19
|
-
const a = b => {
|
|
20
|
-
const c = (Math.random().toString(16) + "000000000").substr(2, 8);
|
|
21
|
-
return b ? "-" + c.substr(0, 4) + "-" + c.substr(4, 4) : c;
|
|
22
|
-
};
|
|
23
|
-
return a() + a(!0) + a(!0) + a();
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
function q(a) {
|
|
27
|
-
if ("indexedDB" in a.G) return a.G.indexedDB;
|
|
7
|
+
function k(a) {
|
|
8
|
+
if ("indexedDB" in a.parent) return a.parent.indexedDB;
|
|
28
9
|
}
|
|
29
|
-
function
|
|
10
|
+
function l(a) {
|
|
11
|
+
var b;
|
|
30
12
|
try {
|
|
31
|
-
if (null ==
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
13
|
+
if (null == k(a)) return !1;
|
|
14
|
+
const c =
|
|
15
|
+
null === (b = k(a)) || void 0 === b
|
|
16
|
+
? void 0
|
|
17
|
+
: b.open("Braze IndexedDB Support Test");
|
|
18
|
+
c &&
|
|
19
|
+
((c.onupgradeneeded = () => c.result.close()),
|
|
20
|
+
(c.onsuccess = () => c.result.close()));
|
|
35
21
|
if ("undefined" !== typeof window) {
|
|
36
|
-
|
|
37
|
-
|
|
22
|
+
b = window;
|
|
23
|
+
const f = b.ra || b.qa || b.ta;
|
|
24
|
+
if (f && f.N && f.N.id)
|
|
38
25
|
return (
|
|
39
26
|
a.j.info(
|
|
40
|
-
"Not using IndexedDB for storage because we are running inside an extension"
|
|
27
|
+
"Not using IndexedDB for storage because we are running inside an extension",
|
|
41
28
|
),
|
|
42
29
|
!1
|
|
43
30
|
);
|
|
44
31
|
}
|
|
45
32
|
return !0;
|
|
46
|
-
} catch (
|
|
33
|
+
} catch (c) {
|
|
47
34
|
return (
|
|
48
|
-
a.j.info("Not using IndexedDB for storage due to following error: " +
|
|
35
|
+
a.j.info("Not using IndexedDB for storage due to following error: " + c),
|
|
49
36
|
!1
|
|
50
37
|
);
|
|
51
38
|
}
|
|
52
39
|
}
|
|
53
|
-
function
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
40
|
+
function q(a, b, c) {
|
|
41
|
+
var f;
|
|
42
|
+
const g =
|
|
43
|
+
null === (f = k(a)) || void 0 === f ? void 0 : f.open(a.h.l, a.h.VERSION);
|
|
44
|
+
if (null == g) return "function" === typeof c && c(), !1;
|
|
45
|
+
g.onupgradeneeded = (e) => {
|
|
46
|
+
var d;
|
|
57
47
|
a.j.info("Upgrading indexedDB " + a.h.l + " to v" + a.h.VERSION + "...");
|
|
58
|
-
e = e.target.result;
|
|
59
|
-
for (const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
48
|
+
e = null === (d = e.target) || void 0 === d ? void 0 : d.result;
|
|
49
|
+
for (const h in a.h.g)
|
|
50
|
+
(d = h),
|
|
51
|
+
a.h.g.hasOwnProperty(h) &&
|
|
52
|
+
!e.objectStoreNames.contains(a.h.g[d]) &&
|
|
53
|
+
e.createObjectStore(a.h.g[d]);
|
|
63
54
|
};
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
d
|
|
67
|
-
|
|
55
|
+
g.onsuccess = (e) => {
|
|
56
|
+
var d;
|
|
57
|
+
const h = null === (d = e.target) || void 0 === d ? void 0 : d.result;
|
|
58
|
+
h.onversionchange = () => {
|
|
59
|
+
h.close();
|
|
68
60
|
"function" === typeof c && c();
|
|
69
61
|
a.j.error(
|
|
70
|
-
"Needed to close the database unexpectedly because of an upgrade in another tab"
|
|
62
|
+
"Needed to close the database unexpectedly because of an upgrade in another tab",
|
|
71
63
|
);
|
|
72
64
|
};
|
|
73
|
-
b(
|
|
65
|
+
b(h);
|
|
74
66
|
};
|
|
75
|
-
|
|
67
|
+
g.onerror = (e) => {
|
|
68
|
+
var d;
|
|
76
69
|
a.j.info(
|
|
77
70
|
"Could not open indexedDB " +
|
|
78
71
|
a.h.l +
|
|
79
72
|
" v" +
|
|
80
73
|
a.h.VERSION +
|
|
81
74
|
": " +
|
|
82
|
-
e.target.errorCode
|
|
75
|
+
(null === (d = e.target) || void 0 === d ? void 0 : d.errorCode),
|
|
83
76
|
);
|
|
84
77
|
"function" === typeof c && c();
|
|
85
78
|
return !0;
|
|
86
79
|
};
|
|
87
80
|
return !0;
|
|
88
81
|
}
|
|
89
|
-
function
|
|
90
|
-
|
|
91
|
-
?
|
|
82
|
+
function r(a, b, c, f) {
|
|
83
|
+
l(a)
|
|
84
|
+
? q(
|
|
92
85
|
a,
|
|
93
|
-
|
|
94
|
-
if (
|
|
95
|
-
var
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
86
|
+
(g) => {
|
|
87
|
+
if (g.objectStoreNames.contains(b)) {
|
|
88
|
+
var e = g.transaction([b], "readonly");
|
|
89
|
+
e.oncomplete = () => g.close();
|
|
90
|
+
e = e.objectStore(b).openCursor(null, "prev");
|
|
91
|
+
e.onerror = () => {
|
|
99
92
|
a.j.error(
|
|
100
|
-
"Could not open cursor for " + b + " on indexedDB " + a.h.l
|
|
93
|
+
"Could not open cursor for " + b + " on indexedDB " + a.h.l,
|
|
101
94
|
);
|
|
102
95
|
"function" === typeof f && f();
|
|
103
96
|
};
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
97
|
+
e.onsuccess = (d) => {
|
|
98
|
+
var h;
|
|
99
|
+
d = null === (h = d.target) || void 0 === h ? void 0 : h.result;
|
|
100
|
+
null != d && null != d.value && null != d.key
|
|
101
|
+
? c(d.key, d.value)
|
|
108
102
|
: "function" === typeof f && f();
|
|
109
103
|
};
|
|
110
104
|
} else
|
|
@@ -115,84 +109,87 @@ function w(a, b, c, f) {
|
|
|
115
109
|
a.h.l +
|
|
116
110
|
" - " +
|
|
117
111
|
b +
|
|
118
|
-
" is not a valid objectStore"
|
|
112
|
+
" is not a valid objectStore",
|
|
119
113
|
),
|
|
120
114
|
"function" === typeof f && f(),
|
|
121
|
-
|
|
115
|
+
g.close();
|
|
122
116
|
},
|
|
123
|
-
f
|
|
117
|
+
f,
|
|
124
118
|
)
|
|
125
119
|
: "function" === typeof f && f();
|
|
126
120
|
}
|
|
127
|
-
class
|
|
121
|
+
class t {
|
|
128
122
|
constructor(a, b) {
|
|
129
|
-
this.
|
|
123
|
+
this.h = a;
|
|
124
|
+
this.j = b;
|
|
125
|
+
this.parent = "undefined" === typeof window ? self : window;
|
|
130
126
|
this.h = a;
|
|
131
127
|
this.j = b;
|
|
132
128
|
}
|
|
133
|
-
setItem(a, b, c, f,
|
|
134
|
-
if (!
|
|
135
|
-
const
|
|
136
|
-
return
|
|
129
|
+
setItem(a, b, c, f, g) {
|
|
130
|
+
if (!l(this)) return "function" === typeof g && g(), !1;
|
|
131
|
+
const e = this;
|
|
132
|
+
return q(
|
|
137
133
|
this,
|
|
138
|
-
|
|
139
|
-
if (
|
|
140
|
-
var h =
|
|
141
|
-
h.oncomplete = () =>
|
|
134
|
+
(d) => {
|
|
135
|
+
if (d.objectStoreNames.contains(a)) {
|
|
136
|
+
var h = d.transaction([a], "readwrite");
|
|
137
|
+
h.oncomplete = () => d.close();
|
|
142
138
|
h = h.objectStore(a).put(c, b);
|
|
143
139
|
h.onerror = () => {
|
|
144
|
-
|
|
140
|
+
e.j.error(
|
|
145
141
|
"Could not store object " +
|
|
146
142
|
b +
|
|
147
143
|
" in " +
|
|
148
144
|
a +
|
|
149
145
|
" on indexedDB " +
|
|
150
|
-
|
|
146
|
+
e.h.l,
|
|
151
147
|
);
|
|
152
|
-
"function" === typeof
|
|
148
|
+
"function" === typeof g && g();
|
|
153
149
|
};
|
|
154
150
|
h.onsuccess = () => {
|
|
155
151
|
"function" === typeof f && f();
|
|
156
152
|
};
|
|
157
153
|
} else
|
|
158
|
-
|
|
154
|
+
e.j.error(
|
|
159
155
|
"Could not store object " +
|
|
160
156
|
b +
|
|
161
157
|
" in " +
|
|
162
158
|
a +
|
|
163
159
|
" on indexedDB " +
|
|
164
|
-
|
|
160
|
+
e.h.l +
|
|
165
161
|
" - " +
|
|
166
162
|
a +
|
|
167
|
-
" is not a valid objectStore"
|
|
163
|
+
" is not a valid objectStore",
|
|
168
164
|
),
|
|
169
|
-
"function" === typeof
|
|
170
|
-
|
|
165
|
+
"function" === typeof g && g(),
|
|
166
|
+
d.close();
|
|
171
167
|
},
|
|
172
|
-
|
|
168
|
+
g,
|
|
173
169
|
);
|
|
174
170
|
}
|
|
175
171
|
getItem(a, b, c) {
|
|
176
|
-
if (!
|
|
172
|
+
if (!l(this)) return !1;
|
|
177
173
|
const f = this;
|
|
178
|
-
return
|
|
179
|
-
if (
|
|
180
|
-
var
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
174
|
+
return q(this, (g) => {
|
|
175
|
+
if (g.objectStoreNames.contains(a)) {
|
|
176
|
+
var e = g.transaction([a], "readonly");
|
|
177
|
+
e.oncomplete = () => g.close();
|
|
178
|
+
e = e.objectStore(a).get(b);
|
|
179
|
+
e.onerror = () => {
|
|
184
180
|
f.j.error(
|
|
185
181
|
"Could not retrieve object " +
|
|
186
182
|
b +
|
|
187
183
|
" in " +
|
|
188
184
|
a +
|
|
189
185
|
" on indexedDB " +
|
|
190
|
-
f.h.l
|
|
186
|
+
f.h.l,
|
|
191
187
|
);
|
|
192
188
|
};
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
null
|
|
189
|
+
e.onsuccess = (d) => {
|
|
190
|
+
var h;
|
|
191
|
+
d = null === (h = d.target) || void 0 === h ? void 0 : h.result;
|
|
192
|
+
null != d && c(d);
|
|
196
193
|
};
|
|
197
194
|
} else
|
|
198
195
|
f.j.error(
|
|
@@ -204,213 +201,236 @@ class x {
|
|
|
204
201
|
f.h.l +
|
|
205
202
|
" - " +
|
|
206
203
|
a +
|
|
207
|
-
" is not a valid objectStore"
|
|
204
|
+
" is not a valid objectStore",
|
|
208
205
|
),
|
|
209
|
-
|
|
206
|
+
g.close();
|
|
210
207
|
});
|
|
211
208
|
}
|
|
212
209
|
clearData() {
|
|
213
|
-
if (!
|
|
210
|
+
if (!l(this)) return !1;
|
|
214
211
|
const a = [];
|
|
215
|
-
for (const c in this.h.g)
|
|
212
|
+
for (const c in this.h.g) {
|
|
213
|
+
const f = c;
|
|
216
214
|
this.h.g.hasOwnProperty(c) &&
|
|
217
|
-
this.h.g[
|
|
218
|
-
a.push(this.h.g[
|
|
215
|
+
this.h.g[f] !== this.h.g.C &&
|
|
216
|
+
a.push(this.h.g[f]);
|
|
217
|
+
}
|
|
219
218
|
const b = this;
|
|
220
|
-
return
|
|
219
|
+
return q(this, function (c) {
|
|
221
220
|
const f = c.transaction(a, "readwrite");
|
|
222
221
|
f.oncomplete = () => c.close();
|
|
223
|
-
for (let
|
|
224
|
-
f.objectStore(a[
|
|
222
|
+
for (let g = 0; g < a.length; g++)
|
|
223
|
+
f.objectStore(a[g]).clear().onerror = function () {
|
|
225
224
|
b.j.error(
|
|
226
|
-
"Could not clear " + this.source.name + " on indexedDB " + b.h.l
|
|
225
|
+
"Could not clear " + this.source.name + " on indexedDB " + b.h.l,
|
|
227
226
|
);
|
|
228
227
|
};
|
|
229
|
-
f.onerror = function() {
|
|
228
|
+
f.onerror = function () {
|
|
230
229
|
b.j.error("Could not clear object stores on indexedDB " + b.h.l);
|
|
231
230
|
};
|
|
232
231
|
});
|
|
233
232
|
}
|
|
234
233
|
}
|
|
235
|
-
const
|
|
236
|
-
B: function(a) {
|
|
237
|
-
if (void 0 !== a || void 0 ===
|
|
238
|
-
|
|
234
|
+
const w = {
|
|
235
|
+
B: function (a) {
|
|
236
|
+
if (void 0 !== a || void 0 === w.o) w.o = !!a;
|
|
237
|
+
w.G || (w.G = !0);
|
|
239
238
|
},
|
|
240
|
-
sa: function() {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
239
|
+
sa: function () {
|
|
240
|
+
w.G = !1;
|
|
241
|
+
w.o = void 0;
|
|
242
|
+
w.j = void 0;
|
|
244
243
|
},
|
|
245
|
-
ua: function(a) {
|
|
244
|
+
ua: function (a) {
|
|
246
245
|
"function" !== typeof a
|
|
247
|
-
?
|
|
248
|
-
: (
|
|
246
|
+
? w.info("Ignoring setLogger call since logger is not a function")
|
|
247
|
+
: (w.B(), (w.j = a));
|
|
249
248
|
},
|
|
250
|
-
va: function() {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
? (console.log("Disabling Braze logging"), (
|
|
254
|
-
: (console.log("Enabled Braze logging"), (
|
|
249
|
+
va: function () {
|
|
250
|
+
w.B();
|
|
251
|
+
w.o
|
|
252
|
+
? (console.log("Disabling Braze logging"), (w.o = !1))
|
|
253
|
+
: (console.log("Enabled Braze logging"), (w.o = !0));
|
|
255
254
|
},
|
|
256
|
-
info: function(a) {
|
|
257
|
-
|
|
255
|
+
info: function (a) {
|
|
256
|
+
w.o && ((a = "Braze: " + a), null != w.j ? w.j(a) : console.log(a));
|
|
258
257
|
},
|
|
259
|
-
warn: function(a) {
|
|
260
|
-
|
|
261
|
-
((a = "Braze SDK Warning: " + a + " (v4.
|
|
262
|
-
null !=
|
|
258
|
+
warn: function (a) {
|
|
259
|
+
w.o &&
|
|
260
|
+
((a = "Braze SDK Warning: " + a + " (v4.9.0)"),
|
|
261
|
+
null != w.j ? w.j(a) : console.warn(a));
|
|
262
|
+
},
|
|
263
|
+
error: function (a) {
|
|
264
|
+
w.o &&
|
|
265
|
+
((a = "Braze SDK Error: " + a + " (v4.9.0)"),
|
|
266
|
+
null != w.j ? w.j(a) : console.error(a));
|
|
263
267
|
},
|
|
264
|
-
error: function(a) {
|
|
265
|
-
y.o &&
|
|
266
|
-
((a = "Braze SDK Error: " + a + " (v4.8.3)"),
|
|
267
|
-
null != y.j ? y.j(a) : console.error(a));
|
|
268
|
-
}
|
|
269
268
|
};
|
|
270
|
-
var
|
|
269
|
+
var x = {
|
|
270
|
+
O: function (a) {
|
|
271
|
+
var b = "=".repeat((4 - (a.length % 4)) % 4);
|
|
272
|
+
a = (a + b).replace(/\-/g, "+").replace(/_/g, "/");
|
|
273
|
+
a = atob(a);
|
|
274
|
+
b = new Uint8Array(a.length);
|
|
275
|
+
for (let c = 0; c < a.length; ++c) b[c] = a.charCodeAt(c);
|
|
276
|
+
return b;
|
|
277
|
+
},
|
|
278
|
+
},
|
|
279
|
+
y = {
|
|
271
280
|
CustomEvent: "ce",
|
|
272
281
|
ga: "p",
|
|
273
|
-
|
|
274
|
-
|
|
282
|
+
L: "pc",
|
|
283
|
+
K: "ca",
|
|
275
284
|
ia: "i",
|
|
276
285
|
ha: "ie",
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
286
|
+
V: "cci",
|
|
287
|
+
W: "ccic",
|
|
288
|
+
T: "ccc",
|
|
289
|
+
U: "ccd",
|
|
281
290
|
oa: "ss",
|
|
282
291
|
na: "se",
|
|
283
292
|
fa: "si",
|
|
284
293
|
da: "sc",
|
|
285
294
|
ca: "sbc",
|
|
286
295
|
ea: "sfe",
|
|
287
|
-
|
|
296
|
+
X: "iec",
|
|
288
297
|
la: "lr",
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
298
|
+
P: "uae",
|
|
299
|
+
S: "ci",
|
|
300
|
+
R: "cc",
|
|
292
301
|
ja: "lcaa",
|
|
293
302
|
ka: "lcar",
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
303
|
+
Z: "inc",
|
|
304
|
+
Y: "add",
|
|
305
|
+
$: "rem",
|
|
306
|
+
aa: "set",
|
|
298
307
|
ma: "ncam",
|
|
299
|
-
pa: "sgu"
|
|
308
|
+
pa: "sgu",
|
|
309
|
+
ba: "ffi",
|
|
300
310
|
},
|
|
301
|
-
|
|
311
|
+
z = {
|
|
312
|
+
F: function () {
|
|
313
|
+
const a = (b = !1) => {
|
|
314
|
+
const c = (Math.random().toString(16) + "000000000").substr(2, 8);
|
|
315
|
+
return b ? "-" + c.substr(0, 4) + "-" + c.substr(4, 4) : c;
|
|
316
|
+
};
|
|
317
|
+
return a() + a(!0) + a(!0) + a();
|
|
318
|
+
},
|
|
319
|
+
},
|
|
320
|
+
A = t,
|
|
302
321
|
B = {
|
|
303
322
|
m: {
|
|
304
323
|
l: "AppboyServiceWorkerAsyncStorage",
|
|
305
324
|
VERSION: 6,
|
|
306
325
|
g: {
|
|
307
326
|
s: "data",
|
|
308
|
-
|
|
327
|
+
J: "pushClicks",
|
|
309
328
|
D: "pushSubscribed",
|
|
310
329
|
A: "fallbackDevice",
|
|
311
|
-
|
|
330
|
+
H: "cardUpdates",
|
|
312
331
|
C: "optOut",
|
|
313
|
-
|
|
314
|
-
|
|
332
|
+
I: "pendingData",
|
|
333
|
+
M: "sdkAuthenticationSignature",
|
|
315
334
|
},
|
|
316
|
-
v: 1
|
|
317
|
-
}
|
|
335
|
+
v: 1,
|
|
336
|
+
},
|
|
318
337
|
},
|
|
319
|
-
E =
|
|
338
|
+
E = w;
|
|
320
339
|
function F() {
|
|
321
|
-
return new Promise(function(a, b) {
|
|
340
|
+
return new Promise(function (a, b) {
|
|
322
341
|
const c = B.m;
|
|
323
|
-
|
|
342
|
+
r(new A(c, E), c.g.C, b, a);
|
|
324
343
|
});
|
|
325
344
|
}
|
|
326
345
|
function G() {
|
|
327
|
-
return new Promise(a => {
|
|
346
|
+
return new Promise((a) => {
|
|
328
347
|
const b = B.m;
|
|
329
|
-
|
|
348
|
+
r(
|
|
330
349
|
new A(b, E),
|
|
331
|
-
b.g.
|
|
350
|
+
b.g.M,
|
|
332
351
|
(c, f) => {
|
|
333
352
|
a(f);
|
|
334
353
|
},
|
|
335
354
|
() => {
|
|
336
355
|
a(null);
|
|
337
|
-
}
|
|
356
|
+
},
|
|
338
357
|
);
|
|
339
358
|
});
|
|
340
359
|
}
|
|
341
360
|
function H(a, b, c) {
|
|
342
361
|
E.info(
|
|
343
|
-
`${b} due to SDK Authentication failure with error code ${c.error_code}. The data will be logged on the user's next session start
|
|
362
|
+
`${b} due to SDK Authentication failure with error code ${c.error_code}. The data will be logged on the user's next session start.`,
|
|
344
363
|
);
|
|
345
364
|
b = B.m;
|
|
346
|
-
new A(b, E).setItem(b.g.
|
|
365
|
+
new A(b, E).setItem(b.g.I, z.F(), a);
|
|
347
366
|
}
|
|
348
367
|
function I(a, b, c) {
|
|
349
|
-
return new Promise(function(f,
|
|
350
|
-
const
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
368
|
+
return new Promise(function (f, g) {
|
|
369
|
+
const e = {};
|
|
370
|
+
e.time = Math.floor(new Date().valueOf() / 1e3);
|
|
371
|
+
e.device_id = c;
|
|
372
|
+
e.api_key = a;
|
|
373
|
+
e.sdk_version = "4.9.0";
|
|
374
|
+
e.sdk_flavor = "amp";
|
|
375
|
+
e.respond_with = { config: { config_time: 0 } };
|
|
357
376
|
fetch(b + "/data/", {
|
|
358
377
|
method: "POST",
|
|
359
378
|
headers: {
|
|
360
379
|
"Content-type": "application/json",
|
|
361
380
|
"X-Braze-Api-Key": a,
|
|
362
|
-
"X-Braze-Last-Req-Ms-Ago": 72e5
|
|
381
|
+
"X-Braze-Last-Req-Ms-Ago": 72e5,
|
|
382
|
+
"X-Braze-Req-Attempt": 1,
|
|
363
383
|
},
|
|
364
|
-
body: JSON.stringify(
|
|
384
|
+
body: JSON.stringify(e),
|
|
365
385
|
})
|
|
366
|
-
.then(function(
|
|
367
|
-
|
|
368
|
-
return
|
|
386
|
+
.then(function (d) {
|
|
387
|
+
d.ok || E.error("Unable to get config: " + d.status);
|
|
388
|
+
return d.json();
|
|
369
389
|
})
|
|
370
|
-
.then(function(
|
|
371
|
-
|
|
372
|
-
|
|
390
|
+
.then(function (d) {
|
|
391
|
+
d.error && (E.error("Unable to get config: " + d.error), g());
|
|
392
|
+
d.auth_error &&
|
|
373
393
|
(E.error(
|
|
374
|
-
"Unable to get config due to authentication error. SDK Authentication does not support AMP pages."
|
|
394
|
+
"Unable to get config due to authentication error. SDK Authentication does not support AMP pages.",
|
|
375
395
|
),
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
((
|
|
396
|
+
g());
|
|
397
|
+
d.error ||
|
|
398
|
+
d.auth_error ||
|
|
399
|
+
((d = {
|
|
380
400
|
userVisibleOnly: !0,
|
|
381
|
-
applicationServerKey:
|
|
401
|
+
applicationServerKey: x.O(d.config.vapid_public_key),
|
|
382
402
|
}),
|
|
383
|
-
f(
|
|
403
|
+
f(d));
|
|
384
404
|
})
|
|
385
|
-
.catch(function(
|
|
386
|
-
E.error("Unable to get config: " +
|
|
387
|
-
|
|
405
|
+
.catch(function (d) {
|
|
406
|
+
E.error("Unable to get config: " + d);
|
|
407
|
+
g();
|
|
388
408
|
});
|
|
389
409
|
});
|
|
390
410
|
}
|
|
391
|
-
function J(a, b, c, f, e, d,
|
|
411
|
+
function J(a, b, c, f, g, e, d, h, m) {
|
|
392
412
|
return G().then(
|
|
393
|
-
n =>
|
|
394
|
-
new Promise(function(C, D) {
|
|
413
|
+
(n) =>
|
|
414
|
+
new Promise(function (C, D) {
|
|
395
415
|
const u = {};
|
|
396
416
|
u.device_id = c;
|
|
397
417
|
u.api_key = a;
|
|
398
|
-
u.sdk_version = "4.
|
|
399
|
-
null !=
|
|
418
|
+
u.sdk_version = "4.9.0";
|
|
419
|
+
null != e && (u.sdk_flavor = e);
|
|
400
420
|
var v = null;
|
|
401
421
|
let K = null,
|
|
402
422
|
L = null;
|
|
403
|
-
|
|
404
|
-
((L =
|
|
405
|
-
|
|
423
|
+
g &&
|
|
424
|
+
((L = g.endpoint),
|
|
425
|
+
g.getKey &&
|
|
406
426
|
((v = btoa(
|
|
407
427
|
String.fromCharCode.apply(
|
|
408
428
|
null,
|
|
409
|
-
new Uint8Array(
|
|
410
|
-
)
|
|
429
|
+
new Uint8Array(g.getKey("p256dh")),
|
|
430
|
+
),
|
|
411
431
|
)),
|
|
412
432
|
(K = btoa(
|
|
413
|
-
String.fromCharCode.apply(null, new Uint8Array(
|
|
433
|
+
String.fromCharCode.apply(null, new Uint8Array(g.getKey("auth"))),
|
|
414
434
|
))));
|
|
415
435
|
u.time = Math.floor(new Date().valueOf() / 1e3);
|
|
416
436
|
u.attributes = [
|
|
@@ -418,81 +438,83 @@ function J(a, b, c, f, e, d, g, h, m) {
|
|
|
418
438
|
user_id: f,
|
|
419
439
|
push_token: L,
|
|
420
440
|
custom_push_public_key: v,
|
|
421
|
-
custom_push_user_auth: K
|
|
422
|
-
}
|
|
441
|
+
custom_push_user_auth: K,
|
|
442
|
+
},
|
|
423
443
|
];
|
|
424
444
|
v = {
|
|
425
445
|
"Content-type": "application/json",
|
|
426
446
|
"X-Braze-Api-Key": u.api_key,
|
|
427
|
-
"X-Braze-Last-Req-Ms-Ago": 72e5
|
|
447
|
+
"X-Braze-Last-Req-Ms-Ago": 72e5,
|
|
448
|
+
"X-Braze-Req-Attempt": 1,
|
|
428
449
|
};
|
|
429
450
|
n && m && (v["X-Braze-Auth-Signature"] = n);
|
|
430
451
|
fetch(b + "/data/", {
|
|
431
452
|
method: "POST",
|
|
432
453
|
headers: v,
|
|
433
|
-
body: JSON.stringify(u)
|
|
454
|
+
body: JSON.stringify(u),
|
|
434
455
|
})
|
|
435
|
-
.then(function(p) {
|
|
456
|
+
.then(function (p) {
|
|
436
457
|
p.ok || E.error(h + " " + p.status);
|
|
437
458
|
return p.json();
|
|
438
459
|
})
|
|
439
|
-
.then(function(p) {
|
|
460
|
+
.then(function (p) {
|
|
440
461
|
p.error && (E.error(h + " " + p.error), D());
|
|
441
462
|
p.auth_error && (H(u, h, p.auth_error), D());
|
|
442
|
-
p.error || p.auth_error || (E.info(
|
|
463
|
+
p.error || p.auth_error || (E.info(d), C());
|
|
443
464
|
})
|
|
444
|
-
.catch(function(p) {
|
|
465
|
+
.catch(function (p) {
|
|
445
466
|
E.error(h + " " + p);
|
|
446
467
|
D();
|
|
447
468
|
});
|
|
448
|
-
})
|
|
469
|
+
}),
|
|
449
470
|
);
|
|
450
471
|
}
|
|
451
472
|
function M(a, b) {
|
|
452
473
|
return F()
|
|
453
|
-
.then(function() {
|
|
474
|
+
.then(function () {
|
|
454
475
|
return G();
|
|
455
476
|
})
|
|
456
|
-
.then(function(c) {
|
|
477
|
+
.then(function (c) {
|
|
457
478
|
const f = B.m;
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
const
|
|
461
|
-
|
|
462
|
-
a.time =
|
|
463
|
-
a.user_id =
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
479
|
+
r(new A(f, E), f.g.s, function (g, e) {
|
|
480
|
+
g = Math.floor(new Date().valueOf() / 1e3);
|
|
481
|
+
const d = e.data;
|
|
482
|
+
d.time = g;
|
|
483
|
+
a.time = g;
|
|
484
|
+
a.user_id = e.userId;
|
|
485
|
+
d.events = [a];
|
|
486
|
+
d.sdk_version = "4.9.0";
|
|
487
|
+
g = {
|
|
467
488
|
"Content-Type": "application/json",
|
|
468
|
-
"X-Braze-Api-Key":
|
|
469
|
-
"X-Braze-Last-Req-Ms-Ago": 72e5
|
|
489
|
+
"X-Braze-Api-Key": d.api_key,
|
|
490
|
+
"X-Braze-Last-Req-Ms-Ago": 72e5,
|
|
491
|
+
"X-Braze-Req-Attempt": 1,
|
|
470
492
|
};
|
|
471
|
-
c &&
|
|
472
|
-
fetch(
|
|
493
|
+
c && e.sdkAuthEnabled && (g["X-Braze-Auth-Signature"] = c);
|
|
494
|
+
fetch(e.baseUrl + "/data/", {
|
|
473
495
|
method: "POST",
|
|
474
|
-
headers:
|
|
475
|
-
body: JSON.stringify(
|
|
496
|
+
headers: g,
|
|
497
|
+
body: JSON.stringify(d),
|
|
476
498
|
})
|
|
477
|
-
.then(function(h) {
|
|
499
|
+
.then(function (h) {
|
|
478
500
|
h.ok || E.error("Unable to log " + b + ": " + h.status);
|
|
479
501
|
return h.json();
|
|
480
502
|
})
|
|
481
|
-
.then(function(h) {
|
|
503
|
+
.then(function (h) {
|
|
482
504
|
h.error && E.error("Unable to log " + b + ":", h.error);
|
|
483
|
-
h.auth_error && H(
|
|
505
|
+
h.auth_error && H(d, "Unable to log " + b, h.auth_error);
|
|
484
506
|
h.error || h.auth_error || E.info("Successfully logged " + b);
|
|
485
507
|
return Promise.resolve();
|
|
486
508
|
})
|
|
487
|
-
.catch(function(h) {
|
|
509
|
+
.catch(function (h) {
|
|
488
510
|
E.error("Unable to log " + b + ":", h);
|
|
489
511
|
return Promise.resolve();
|
|
490
512
|
});
|
|
491
513
|
});
|
|
492
514
|
})
|
|
493
|
-
.catch(function() {
|
|
515
|
+
.catch(function () {
|
|
494
516
|
return Promise.reject(
|
|
495
|
-
"Not sending data to Braze backend due to opt-out."
|
|
517
|
+
"Not sending data to Braze backend due to opt-out.",
|
|
496
518
|
);
|
|
497
519
|
});
|
|
498
520
|
}
|
|
@@ -509,31 +531,31 @@ function O() {
|
|
|
509
531
|
return null;
|
|
510
532
|
}
|
|
511
533
|
function P(a, b) {
|
|
512
|
-
self.clients.matchAll().then(function(c) {
|
|
534
|
+
self.clients.matchAll().then(function (c) {
|
|
513
535
|
for (let f = 0; f < c.length; f++)
|
|
514
536
|
c[f].postMessage({ command: a, payload: b });
|
|
515
537
|
});
|
|
516
538
|
}
|
|
517
|
-
function Q(a, b, c, f,
|
|
539
|
+
function Q(a, b, c, f, g) {
|
|
518
540
|
return I(a, b, c)
|
|
519
|
-
.then(function(
|
|
520
|
-
return self.registration.pushManager.subscribe(
|
|
541
|
+
.then(function (e) {
|
|
542
|
+
return self.registration.pushManager.subscribe(e);
|
|
521
543
|
})
|
|
522
|
-
.then(function(
|
|
544
|
+
.then(function (e) {
|
|
523
545
|
P("amp-web-push-subscribe", null);
|
|
524
546
|
return J(
|
|
525
547
|
a,
|
|
526
548
|
b,
|
|
527
549
|
c,
|
|
528
550
|
f,
|
|
529
|
-
|
|
551
|
+
e,
|
|
530
552
|
"amp",
|
|
531
553
|
"Successfully sent AMP push subscription to Braze backend.",
|
|
532
554
|
"Unable to send AMP push subscription to Braze backend.",
|
|
533
|
-
|
|
555
|
+
g,
|
|
534
556
|
);
|
|
535
557
|
})
|
|
536
|
-
.catch(function() {
|
|
558
|
+
.catch(function () {
|
|
537
559
|
E.error("Failed to subscribe for AMP push.");
|
|
538
560
|
return Promise.reject();
|
|
539
561
|
});
|
|
@@ -541,72 +563,72 @@ function Q(a, b, c, f, e) {
|
|
|
541
563
|
function R() {
|
|
542
564
|
self.registration.pushManager
|
|
543
565
|
.getSubscription()
|
|
544
|
-
.then(function(a) {
|
|
566
|
+
.then(function (a) {
|
|
545
567
|
return a
|
|
546
568
|
? self.registration.pushManager.permissionState(a.options)
|
|
547
569
|
: null;
|
|
548
570
|
})
|
|
549
|
-
.then(function(a) {
|
|
571
|
+
.then(function (a) {
|
|
550
572
|
P("amp-web-push-subscription-state", "granted" === a);
|
|
551
573
|
});
|
|
552
574
|
}
|
|
553
575
|
function S() {
|
|
554
576
|
const a = B.m,
|
|
555
577
|
b = new A(a, E);
|
|
556
|
-
return new Promise(function(c, f) {
|
|
557
|
-
|
|
578
|
+
return new Promise(function (c, f) {
|
|
579
|
+
r(
|
|
558
580
|
b,
|
|
559
581
|
a.g.s,
|
|
560
|
-
function(
|
|
582
|
+
function (g, e) {
|
|
561
583
|
Q(
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
584
|
+
e.data.api_key,
|
|
585
|
+
e.baseUrl,
|
|
586
|
+
e.data.device_id,
|
|
587
|
+
e.userId,
|
|
588
|
+
e.sdkAuthEnabled,
|
|
567
589
|
)
|
|
568
|
-
.then(function() {
|
|
590
|
+
.then(function () {
|
|
569
591
|
c();
|
|
570
592
|
})
|
|
571
|
-
.catch(function() {
|
|
593
|
+
.catch(function () {
|
|
572
594
|
f();
|
|
573
595
|
});
|
|
574
596
|
},
|
|
575
|
-
function() {
|
|
576
|
-
const
|
|
577
|
-
|
|
578
|
-
|
|
597
|
+
function () {
|
|
598
|
+
const g = N(),
|
|
599
|
+
e = O();
|
|
600
|
+
r(
|
|
579
601
|
b,
|
|
580
602
|
a.g.A,
|
|
581
|
-
function(
|
|
582
|
-
Q(
|
|
583
|
-
.then(function() {
|
|
603
|
+
function (d, h) {
|
|
604
|
+
Q(g, e, h, null)
|
|
605
|
+
.then(function () {
|
|
584
606
|
c();
|
|
585
607
|
})
|
|
586
|
-
.catch(function() {
|
|
608
|
+
.catch(function () {
|
|
587
609
|
f();
|
|
588
610
|
});
|
|
589
611
|
},
|
|
590
|
-
function() {
|
|
591
|
-
const
|
|
592
|
-
new Promise(function(h, m) {
|
|
593
|
-
b.setItem(a.g.A, a.v,
|
|
612
|
+
function () {
|
|
613
|
+
const d = z.F();
|
|
614
|
+
new Promise(function (h, m) {
|
|
615
|
+
b.setItem(a.g.A, a.v, d, h, m);
|
|
594
616
|
})
|
|
595
|
-
.then(function() {
|
|
596
|
-
return Q(e, d,
|
|
617
|
+
.then(function () {
|
|
618
|
+
return Q(g, e, d, null);
|
|
597
619
|
})
|
|
598
|
-
.then(function() {
|
|
620
|
+
.then(function () {
|
|
599
621
|
c();
|
|
600
622
|
})
|
|
601
|
-
.catch(function() {
|
|
623
|
+
.catch(function () {
|
|
602
624
|
f();
|
|
603
625
|
});
|
|
604
|
-
}
|
|
626
|
+
},
|
|
605
627
|
);
|
|
606
|
-
}
|
|
628
|
+
},
|
|
607
629
|
);
|
|
608
|
-
}).then(function() {
|
|
609
|
-
return new Promise(function(c, f) {
|
|
630
|
+
}).then(function () {
|
|
631
|
+
return new Promise(function (c, f) {
|
|
610
632
|
b.setItem(a.g.D, a.v, !0, c, f);
|
|
611
633
|
});
|
|
612
634
|
});
|
|
@@ -614,107 +636,107 @@ function S() {
|
|
|
614
636
|
function T() {
|
|
615
637
|
return self.registration.pushManager
|
|
616
638
|
.getSubscription()
|
|
617
|
-
.then(function(a) {
|
|
639
|
+
.then(function (a) {
|
|
618
640
|
return a.unsubscribe();
|
|
619
641
|
})
|
|
620
|
-
.then(function() {
|
|
642
|
+
.then(function () {
|
|
621
643
|
P("amp-web-push-unsubscribe", null);
|
|
622
644
|
const a = B.m,
|
|
623
645
|
b = new A(a, E);
|
|
624
|
-
return new Promise(function(c, f) {
|
|
625
|
-
|
|
646
|
+
return new Promise(function (c, f) {
|
|
647
|
+
r(
|
|
626
648
|
b,
|
|
627
649
|
a.g.s,
|
|
628
|
-
function(
|
|
650
|
+
function (g, e) {
|
|
629
651
|
J(
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
652
|
+
e.data.api_key,
|
|
653
|
+
e.baseUrl,
|
|
654
|
+
e.data.device_id,
|
|
655
|
+
e.userId,
|
|
634
656
|
null,
|
|
635
657
|
"amp",
|
|
636
658
|
"Successfully sent AMP push unsubscription to Braze backend.",
|
|
637
659
|
"Unable to send AMP push unsubscription to Braze backend.",
|
|
638
|
-
|
|
660
|
+
e.sdkAuthEnabled,
|
|
639
661
|
)
|
|
640
|
-
.then(function() {
|
|
662
|
+
.then(function () {
|
|
641
663
|
c();
|
|
642
664
|
})
|
|
643
|
-
.catch(function() {
|
|
665
|
+
.catch(function () {
|
|
644
666
|
f();
|
|
645
667
|
});
|
|
646
668
|
},
|
|
647
|
-
function() {
|
|
648
|
-
|
|
669
|
+
function () {
|
|
670
|
+
r(
|
|
649
671
|
b,
|
|
650
672
|
a.g.A,
|
|
651
|
-
function(
|
|
652
|
-
|
|
653
|
-
const
|
|
673
|
+
function (g, e) {
|
|
674
|
+
g = N();
|
|
675
|
+
const d = O();
|
|
654
676
|
J(
|
|
655
|
-
e,
|
|
656
677
|
g,
|
|
657
678
|
d,
|
|
679
|
+
e,
|
|
658
680
|
null,
|
|
659
681
|
null,
|
|
660
682
|
"amp",
|
|
661
683
|
"Successfully sent AMP push unsubscription to Braze backend.",
|
|
662
684
|
"Unable to send AMP push unsubscription to Braze backend.",
|
|
663
|
-
null
|
|
685
|
+
null,
|
|
664
686
|
)
|
|
665
|
-
.then(function() {
|
|
687
|
+
.then(function () {
|
|
666
688
|
c();
|
|
667
689
|
})
|
|
668
|
-
.catch(function() {
|
|
690
|
+
.catch(function () {
|
|
669
691
|
f();
|
|
670
692
|
});
|
|
671
693
|
},
|
|
672
|
-
function() {
|
|
694
|
+
function () {
|
|
673
695
|
E.error("No device found during unsubscription.");
|
|
674
696
|
f();
|
|
675
|
-
}
|
|
697
|
+
},
|
|
676
698
|
);
|
|
677
|
-
}
|
|
699
|
+
},
|
|
678
700
|
);
|
|
679
|
-
}).then(function() {
|
|
680
|
-
return new Promise(function(c, f) {
|
|
701
|
+
}).then(function () {
|
|
702
|
+
return new Promise(function (c, f) {
|
|
681
703
|
b.setItem(a.g.D, a.v, !1, c, f);
|
|
682
704
|
});
|
|
683
705
|
});
|
|
684
706
|
})
|
|
685
|
-
.catch(function() {
|
|
707
|
+
.catch(function () {
|
|
686
708
|
E.error("Failed to unsubscribe for AMP push.");
|
|
687
709
|
return Promise.reject();
|
|
688
710
|
});
|
|
689
711
|
}
|
|
690
712
|
function U(a, b) {
|
|
691
713
|
a.waitUntil(
|
|
692
|
-
b.catch(function(c) {
|
|
714
|
+
b.catch(function (c) {
|
|
693
715
|
c && E.info(c);
|
|
694
|
-
})
|
|
716
|
+
}),
|
|
695
717
|
);
|
|
696
718
|
}
|
|
697
719
|
E.B(!0);
|
|
698
720
|
function V(a) {
|
|
699
721
|
if (null == a || 0 === Object.keys(a).length)
|
|
700
722
|
return Promise.reject(
|
|
701
|
-
"Server has no pending push message for this registration. Ignoring push event."
|
|
723
|
+
"Server has no pending push message for this registration. Ignoring push event.",
|
|
702
724
|
);
|
|
703
725
|
const b = a.t,
|
|
704
726
|
c = a.a,
|
|
705
727
|
f = a.i,
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
728
|
+
g = a.img,
|
|
729
|
+
e = { url: a.u, ab_ids: { cid: a.cid }, extra: a.e },
|
|
730
|
+
d = a.ri;
|
|
709
731
|
a.ab_push_fetch_test_triggers_key &&
|
|
710
|
-
(E.info("Service worker 4.
|
|
711
|
-
(
|
|
732
|
+
(E.info("Service worker 4.9.0 found trigger fetch key in push payload."),
|
|
733
|
+
(e.fetchTriggers = !0));
|
|
712
734
|
var h = a.ab_cd;
|
|
713
735
|
if (null != h) {
|
|
714
736
|
var m = B.m;
|
|
715
|
-
new A(m, E).setItem(m.g.
|
|
737
|
+
new A(m, E).setItem(m.g.H, new Date().valueOf(), {
|
|
716
738
|
userId: a.ab_cd_uid,
|
|
717
|
-
card: h
|
|
739
|
+
card: h,
|
|
718
740
|
});
|
|
719
741
|
}
|
|
720
742
|
a = a.pab || [];
|
|
@@ -731,71 +753,72 @@ function V(a) {
|
|
|
731
753
|
}
|
|
732
754
|
h[a[m].action] = n;
|
|
733
755
|
}
|
|
734
|
-
|
|
756
|
+
e.actionTargets = h;
|
|
735
757
|
E.info("Displaying push notification!");
|
|
736
758
|
return self.registration
|
|
737
759
|
.showNotification(b, {
|
|
738
760
|
body: c,
|
|
739
761
|
icon: f,
|
|
740
|
-
image:
|
|
741
|
-
data:
|
|
762
|
+
image: g,
|
|
763
|
+
data: e,
|
|
742
764
|
actions: a,
|
|
743
|
-
requireInteraction:
|
|
765
|
+
requireInteraction: d,
|
|
744
766
|
})
|
|
745
|
-
.catch(function(n) {
|
|
767
|
+
.catch(function (n) {
|
|
746
768
|
E.info(n);
|
|
747
769
|
});
|
|
748
770
|
}
|
|
749
|
-
self.addEventListener("install", function(a) {
|
|
771
|
+
self.addEventListener("install", function (a) {
|
|
750
772
|
a.waitUntil(self.skipWaiting());
|
|
751
773
|
});
|
|
752
|
-
self.addEventListener("activate", function() {
|
|
774
|
+
self.addEventListener("activate", function () {
|
|
753
775
|
return self.clients.claim();
|
|
754
776
|
});
|
|
755
|
-
self.addEventListener("push", function(a) {
|
|
756
|
-
E.info("Service worker 4.
|
|
777
|
+
self.addEventListener("push", function (a) {
|
|
778
|
+
E.info("Service worker 4.9.0 received push");
|
|
757
779
|
null != a.data && null != a.data.json
|
|
758
780
|
? U(a, V(a.data.json()))
|
|
759
781
|
: U(
|
|
760
782
|
a,
|
|
761
|
-
new Promise(function(b, c) {
|
|
783
|
+
new Promise(function (b, c) {
|
|
762
784
|
const f = B.m;
|
|
763
|
-
|
|
764
|
-
const
|
|
785
|
+
r(new A(f, E), f.g.s, function (g, e) {
|
|
786
|
+
const d = e.data;
|
|
765
787
|
F()
|
|
766
|
-
.then(function() {
|
|
767
|
-
return fetch(
|
|
788
|
+
.then(function () {
|
|
789
|
+
return fetch(e.baseUrl + "/web_push/", {
|
|
768
790
|
method: "POST",
|
|
769
791
|
headers: {
|
|
770
792
|
"Content-type": "application/json",
|
|
771
|
-
"X-Braze-Api-Key":
|
|
793
|
+
"X-Braze-Api-Key": d.api_key,
|
|
772
794
|
},
|
|
773
|
-
body: JSON.stringify(
|
|
795
|
+
body: JSON.stringify(d),
|
|
774
796
|
});
|
|
775
797
|
})
|
|
776
|
-
.then(function(h) {
|
|
798
|
+
.then(function (h) {
|
|
777
799
|
return h.ok
|
|
778
800
|
? h.json()
|
|
779
801
|
: (E.error(
|
|
780
|
-
"Unable to retrieve push payload from server: " +
|
|
802
|
+
"Unable to retrieve push payload from server: " +
|
|
803
|
+
h.status,
|
|
781
804
|
),
|
|
782
805
|
Promise.reject());
|
|
783
806
|
})
|
|
784
|
-
.then(function(h) {
|
|
807
|
+
.then(function (h) {
|
|
785
808
|
E.info("Retrieved push payload from server");
|
|
786
809
|
b(V(h));
|
|
787
810
|
})
|
|
788
|
-
.catch(function(h) {
|
|
811
|
+
.catch(function (h) {
|
|
789
812
|
c(
|
|
790
813
|
"Unable to retrieve push payload from server or user has opt-out: " +
|
|
791
|
-
h
|
|
814
|
+
h,
|
|
792
815
|
);
|
|
793
816
|
});
|
|
794
817
|
});
|
|
795
|
-
})
|
|
818
|
+
}),
|
|
796
819
|
);
|
|
797
820
|
});
|
|
798
|
-
self.addEventListener("notificationclick", function(a) {
|
|
821
|
+
self.addEventListener("notificationclick", function (a) {
|
|
799
822
|
if (
|
|
800
823
|
a &&
|
|
801
824
|
a.notification &&
|
|
@@ -809,91 +832,91 @@ self.addEventListener("notificationclick", function(a) {
|
|
|
809
832
|
var c = b
|
|
810
833
|
? M(
|
|
811
834
|
{
|
|
812
|
-
name:
|
|
813
|
-
data: { cid: a.notification.data.ab_ids.cid, a: a.action }
|
|
835
|
+
name: y.K,
|
|
836
|
+
data: { cid: a.notification.data.ab_ids.cid, a: a.action },
|
|
814
837
|
},
|
|
815
|
-
"push button click"
|
|
838
|
+
"push button click",
|
|
816
839
|
)
|
|
817
840
|
: M(
|
|
818
|
-
{ name:
|
|
819
|
-
"push click"
|
|
841
|
+
{ name: y.L, data: { cid: a.notification.data.ab_ids.cid } },
|
|
842
|
+
"push click",
|
|
820
843
|
);
|
|
821
844
|
if (!b) {
|
|
822
|
-
const
|
|
845
|
+
const d = {
|
|
823
846
|
lastClick: new Date().valueOf(),
|
|
824
|
-
trackingString: a.notification.data.ab_ids.cid
|
|
847
|
+
trackingString: a.notification.data.ab_ids.cid,
|
|
825
848
|
};
|
|
826
|
-
a.notification.data.fetchTriggers && (
|
|
849
|
+
a.notification.data.fetchTriggers && (d.fetchTriggers = !0);
|
|
827
850
|
const h = B.m,
|
|
828
851
|
m = new A(h, E);
|
|
829
852
|
var f = c
|
|
830
|
-
.then(function() {
|
|
831
|
-
return new Promise(function(n, C) {
|
|
832
|
-
m.setItem(h.g.
|
|
853
|
+
.then(function () {
|
|
854
|
+
return new Promise(function (n, C) {
|
|
855
|
+
m.setItem(h.g.J, h.v, d, n, C);
|
|
833
856
|
});
|
|
834
857
|
})
|
|
835
|
-
.catch(function() {
|
|
858
|
+
.catch(function () {
|
|
836
859
|
E.info("Not storing push click due to no click event being created.");
|
|
837
860
|
return Promise.resolve();
|
|
838
861
|
});
|
|
839
862
|
}
|
|
840
|
-
if (b) var
|
|
841
|
-
else if (((
|
|
842
|
-
var
|
|
843
|
-
null !=
|
|
844
|
-
"" !==
|
|
845
|
-
(
|
|
846
|
-
if (clients.openWindow) return clients.openWindow(
|
|
863
|
+
if (b) var g = a.notification.data.actionTargets[a.action];
|
|
864
|
+
else if (((g = a.notification.data.url), null == g || "" === g)) g = "/";
|
|
865
|
+
var e;
|
|
866
|
+
null != g &&
|
|
867
|
+
"" !== g &&
|
|
868
|
+
(e = clients.matchAll({ type: "window" }).then(function () {
|
|
869
|
+
if (clients.openWindow) return clients.openWindow(g);
|
|
847
870
|
}));
|
|
848
|
-
U(a, Promise.all([
|
|
871
|
+
U(a, Promise.all([e, f]));
|
|
849
872
|
}
|
|
850
873
|
});
|
|
851
|
-
self.addEventListener("pushsubscriptionchange", function(a) {
|
|
874
|
+
self.addEventListener("pushsubscriptionchange", function (a) {
|
|
852
875
|
U(
|
|
853
876
|
a,
|
|
854
877
|
F()
|
|
855
|
-
.then(function() {
|
|
878
|
+
.then(function () {
|
|
856
879
|
let b = { userVisibleOnly: !0 };
|
|
857
880
|
null != a.oldSubscription && (b = a.oldSubscription.options);
|
|
858
881
|
return self.registration.pushManager.subscribe(b);
|
|
859
882
|
})
|
|
860
|
-
.then(function(b) {
|
|
883
|
+
.then(function (b) {
|
|
861
884
|
const c = B.m;
|
|
862
|
-
return new Promise(function(f,
|
|
863
|
-
|
|
885
|
+
return new Promise(function (f, g) {
|
|
886
|
+
r(new A(c, E), c.g.s, function (e, d) {
|
|
864
887
|
J(
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
888
|
+
d.data.api_key,
|
|
889
|
+
d.baseUrl,
|
|
890
|
+
d.data.device_id,
|
|
891
|
+
d.userId,
|
|
869
892
|
b,
|
|
870
893
|
null,
|
|
871
894
|
"Successfully resubscribed user after expiration",
|
|
872
895
|
"Unable to resubscribe user",
|
|
873
|
-
|
|
896
|
+
d.sdkAuthEnabled,
|
|
874
897
|
)
|
|
875
|
-
.then(function() {
|
|
898
|
+
.then(function () {
|
|
876
899
|
f();
|
|
877
900
|
})
|
|
878
|
-
.catch(function() {
|
|
879
|
-
|
|
901
|
+
.catch(function () {
|
|
902
|
+
g();
|
|
880
903
|
});
|
|
881
904
|
});
|
|
882
905
|
});
|
|
883
906
|
})
|
|
884
|
-
.catch(function() {
|
|
907
|
+
.catch(function () {
|
|
885
908
|
return Promise.reject(
|
|
886
|
-
"Not resubscribing user for push due to opt-out."
|
|
909
|
+
"Not resubscribing user for push due to opt-out.",
|
|
887
910
|
);
|
|
888
|
-
})
|
|
911
|
+
}),
|
|
889
912
|
);
|
|
890
913
|
});
|
|
891
|
-
self.addEventListener("message", function(a) {
|
|
914
|
+
self.addEventListener("message", function (a) {
|
|
892
915
|
a.waitUntil &&
|
|
893
916
|
a.data.command &&
|
|
894
917
|
a.waitUntil(
|
|
895
918
|
F()
|
|
896
|
-
.then(function() {
|
|
919
|
+
.then(function () {
|
|
897
920
|
switch (a.data.command) {
|
|
898
921
|
case "amp-web-push-subscription-state":
|
|
899
922
|
return R(), Promise.resolve();
|
|
@@ -905,9 +928,9 @@ self.addEventListener("message", function(a) {
|
|
|
905
928
|
return Promise.resolve();
|
|
906
929
|
}
|
|
907
930
|
})
|
|
908
|
-
.catch(function() {
|
|
931
|
+
.catch(function () {
|
|
909
932
|
E.info("Ignoring message from amp-web-push due to opt-out.");
|
|
910
933
|
return Promise.resolve();
|
|
911
|
-
})
|
|
934
|
+
}),
|
|
912
935
|
);
|
|
913
936
|
});
|