@braze/web-sdk 5.1.0 → 5.2.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/index.d.ts +14 -8
- package/package.json +1 -1
- package/shared-lib/encoding-utils.js +1 -1
- package/shared-lib/event-types.js +18 -18
- package/shared-lib/indexed-db-adapter.js +32 -32
- package/shared-lib/logger.js +2 -2
- package/shared-lib/supported-options.js +22 -21
- package/src/InAppMessage/display/html-message-to-html.js +38 -35
- package/src/InAppMessage/display/in-app-message-to-html.js +2 -2
- package/src/InAppMessage/display/modal-utils.js +2 -2
- package/src/InAppMessage/in-app-message-factory.js +21 -19
- package/src/InAppMessage/in-app-message-manager.js +58 -78
- package/src/InAppMessage/log-in-app-message-button-click.js +2 -2
- package/src/InAppMessage/log-in-app-message-click.js +3 -3
- package/src/InAppMessage/log-in-app-message-html-click.js +3 -3
- package/src/InAppMessage/log-in-app-message-impression.js +1 -1
- package/src/InAppMessage/models/control-message.js +4 -2
- package/src/InAppMessage/models/full-screen-message.js +5 -2
- package/src/InAppMessage/models/html-message.js +6 -4
- package/src/InAppMessage/models/in-app-message-button.js +2 -2
- package/src/InAppMessage/models/in-app-message.js +51 -46
- package/src/InAppMessage/models/modal-message.js +5 -2
- package/src/InAppMessage/models/slide-up-message.js +33 -8
- package/src/InAppMessage/models/templated-in-app-message.js +8 -8
- package/src/InAppMessage/ui/show-in-app-message.js +28 -34
- package/src/InAppMessage/utils/in-app-message-utils.js +18 -1
- package/src/Push/push-manager-factory.js +3 -3
- package/src/Push/push-manager.js +118 -110
- package/src/Push/utils/push-utils.js +4 -4
- package/src/User/user-manager.js +4 -4
- package/src/User/user.js +17 -17
- package/src/common/base-feed.js +1 -1
- package/src/common/feed-display.js +12 -12
- package/src/l10n/l10n-manager-factory.js +1 -1
- package/src/l10n/l10n-manager.js +4 -4
- package/src/managers/auth-manager.js +26 -26
- package/src/managers/braze-instance.js +59 -52
- package/src/managers/device-manager.js +15 -15
- package/src/managers/network-manager.js +98 -93
- package/src/managers/server-config-manager.js +9 -9
- package/src/managers/storage-manager.js +99 -96
- package/src/managers/utils.js +6 -0
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +20 -12
- package/src/models/device.js +3 -3
- package/src/models/identifier.js +33 -19
- package/src/models/push-token.js +4 -4
- package/src/models/server-config.js +6 -6
- package/src/request-controller.js +77 -73
- package/src/triggers/models/custom-event-data.js +2 -2
- package/src/triggers/models/custom-event-property-data.js +4 -4
- package/src/triggers/models/filter-set.js +5 -5
- package/src/triggers/models/filter.js +6 -6
- package/src/triggers/models/in-app-message-click-data.js +1 -1
- package/src/triggers/models/purchase-data.js +2 -2
- package/src/triggers/models/purchase-property-data.js +4 -4
- package/src/triggers/models/push-click-data.js +1 -1
- package/src/triggers/models/trigger-condition.js +41 -41
- package/src/triggers/models/trigger-events.js +1 -1
- package/src/triggers/models/trigger.js +36 -36
- package/src/triggers/triggers-provider-factory.js +1 -1
- package/src/triggers/triggers-provider.js +71 -82
- package/src/ui/js/attach-css.js +2 -2
- package/src/ui/js/load-font-awesome.js +1 -1
- package/src/util/base-device-parser.js +1 -1
- package/src/util/braze-actions.js +4 -4
- package/src/util/browser-detector.js +9 -8
- package/src/util/client-hints-parser.js +1 -1
- package/src/util/component-utils.js +2 -2
- package/src/util/device-constants.js +2 -2
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +1 -1
- package/src/util/request-header-utils.js +6 -6
- package/src/util/user-agent-parser.js +5 -5
- package/src/util/validation-utils.js +2 -0
- package/src/util/window-utils.js +3 -3
package/src/Push/push-manager.js
CHANGED
|
@@ -7,37 +7,37 @@ import { WindowUtils as eo } from "../util/window-utils.js";
|
|
|
7
7
|
import vt from "./utils/push-utils.js";
|
|
8
8
|
import { getErrorMessage as si } from "../util/error-utils.js";
|
|
9
9
|
export default class ea {
|
|
10
|
-
constructor(i, t, e, s, r, n, o, u, a,
|
|
11
|
-
(this.
|
|
12
|
-
(this.
|
|
13
|
-
(this.
|
|
14
|
-
(this.
|
|
15
|
-
(this.
|
|
10
|
+
constructor(i, t, e, s, r, n, o, u, a, c) {
|
|
11
|
+
(this.sn = i),
|
|
12
|
+
(this.rn = t),
|
|
13
|
+
(this.on = e),
|
|
14
|
+
(this.un = r),
|
|
15
|
+
(this.an = n),
|
|
16
16
|
(this.yt = o),
|
|
17
|
-
(this.
|
|
18
|
-
(this.
|
|
19
|
-
(this.u =
|
|
20
|
-
(this.
|
|
21
|
-
(this.
|
|
22
|
-
(this.
|
|
23
|
-
(this.
|
|
24
|
-
(this.
|
|
25
|
-
(this.
|
|
17
|
+
(this.cn = u),
|
|
18
|
+
(this.hn = a),
|
|
19
|
+
(this.u = c),
|
|
20
|
+
(this.sn = i),
|
|
21
|
+
(this.rn = t),
|
|
22
|
+
(this.on = e),
|
|
23
|
+
(this.fn = s + "/safari/" + t),
|
|
24
|
+
(this.un = r || "/service-worker.js"),
|
|
25
|
+
(this.an = n),
|
|
26
26
|
(this.yt = o),
|
|
27
|
-
(this.
|
|
28
|
-
(this.
|
|
29
|
-
(this.u =
|
|
30
|
-
(this.
|
|
31
|
-
(this.
|
|
27
|
+
(this.cn = u || !1),
|
|
28
|
+
(this.hn = a || !1),
|
|
29
|
+
(this.u = c),
|
|
30
|
+
(this.ln = vt.dn()),
|
|
31
|
+
(this.pn = vt.bn());
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
return this.
|
|
33
|
+
mn() {
|
|
34
|
+
return this.hn;
|
|
35
35
|
}
|
|
36
|
-
|
|
36
|
+
yn(i, t, e, s, n) {
|
|
37
37
|
i.unsubscribe()
|
|
38
38
|
.then((i) => {
|
|
39
39
|
i
|
|
40
|
-
? this.
|
|
40
|
+
? this.vn(t, e, s, n)
|
|
41
41
|
: (r.error("Failed to unsubscribe device from push."),
|
|
42
42
|
"function" == typeof n && n(!1));
|
|
43
43
|
})
|
|
@@ -46,7 +46,7 @@ export default class ea {
|
|
|
46
46
|
"function" == typeof n && n(!1);
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
|
-
|
|
49
|
+
gn(i, t, e) {
|
|
50
50
|
var s;
|
|
51
51
|
const n = ((i) => {
|
|
52
52
|
if ("string" == typeof i) return i;
|
|
@@ -55,9 +55,9 @@ export default class ea {
|
|
|
55
55
|
let t = i.endpoint;
|
|
56
56
|
const e = i;
|
|
57
57
|
return (
|
|
58
|
-
e.
|
|
59
|
-
-1 === i.endpoint.indexOf(e.
|
|
60
|
-
(t = i.endpoint + "/" + e.
|
|
58
|
+
e.wn &&
|
|
59
|
+
-1 === i.endpoint.indexOf(e.wn) &&
|
|
60
|
+
(t = i.endpoint + "/" + e.wn),
|
|
61
61
|
t
|
|
62
62
|
);
|
|
63
63
|
})(i);
|
|
@@ -73,7 +73,7 @@ export default class ea {
|
|
|
73
73
|
} catch (i) {
|
|
74
74
|
r.error(si(i));
|
|
75
75
|
}
|
|
76
|
-
const
|
|
76
|
+
const c = ((i) => {
|
|
77
77
|
let t;
|
|
78
78
|
return i.options &&
|
|
79
79
|
(t = i.options.applicationServerKey) &&
|
|
@@ -84,53 +84,53 @@ export default class ea {
|
|
|
84
84
|
.replace(/\//g, "_")
|
|
85
85
|
: null;
|
|
86
86
|
})(a);
|
|
87
|
-
null === (s = this.
|
|
87
|
+
null === (s = this.sn) || void 0 === s || s.kn(n, t, o, u, c),
|
|
88
88
|
n && "function" == typeof e && e(n, o, u);
|
|
89
89
|
}
|
|
90
|
-
|
|
90
|
+
Pn() {
|
|
91
91
|
var i;
|
|
92
|
-
null === (i = this.
|
|
92
|
+
null === (i = this.sn) || void 0 === i || i.Dn(!0);
|
|
93
93
|
}
|
|
94
|
-
|
|
94
|
+
Sn(i, t) {
|
|
95
95
|
var e;
|
|
96
|
-
null === (e = this.
|
|
96
|
+
null === (e = this.sn) || void 0 === e || e.Dn(!1),
|
|
97
97
|
r.info(i),
|
|
98
98
|
"function" == typeof t && t(!1);
|
|
99
99
|
}
|
|
100
|
-
|
|
100
|
+
An(i, t, e, s) {
|
|
101
101
|
var n;
|
|
102
102
|
if ("default" === t.permission)
|
|
103
103
|
try {
|
|
104
104
|
window.safari.pushNotification.requestPermission(
|
|
105
|
-
this.
|
|
105
|
+
this.fn,
|
|
106
106
|
i,
|
|
107
107
|
{
|
|
108
|
-
api_key: this.
|
|
108
|
+
api_key: this.rn,
|
|
109
109
|
device_id:
|
|
110
|
-
(null === (n = this.
|
|
110
|
+
(null === (n = this.on) || void 0 === n ? void 0 : n.ce().id) ||
|
|
111
111
|
"",
|
|
112
112
|
},
|
|
113
113
|
(t) => {
|
|
114
114
|
"granted" === t.permission &&
|
|
115
|
-
this.
|
|
116
|
-
this.
|
|
115
|
+
this.sn &&
|
|
116
|
+
this.sn.setPushNotificationSubscriptionType(
|
|
117
117
|
User.NotificationSubscriptionTypes.OPTED_IN,
|
|
118
118
|
),
|
|
119
|
-
this.
|
|
119
|
+
this.An(i, t, e, s);
|
|
120
120
|
},
|
|
121
121
|
);
|
|
122
122
|
} catch (i) {
|
|
123
|
-
this.
|
|
123
|
+
this.Sn("Could not request permission for push: " + i, s);
|
|
124
124
|
}
|
|
125
125
|
else
|
|
126
126
|
"denied" === t.permission
|
|
127
|
-
? this.
|
|
127
|
+
? this.Sn(
|
|
128
128
|
"The user has blocked notifications from this site, or Safari push is not configured in the Braze dashboard.",
|
|
129
129
|
s,
|
|
130
130
|
)
|
|
131
131
|
: "granted" === t.permission &&
|
|
132
132
|
(r.info("Device successfully subscribed to push."),
|
|
133
|
-
this.
|
|
133
|
+
this.gn(t.deviceToken, new Date(), e));
|
|
134
134
|
}
|
|
135
135
|
requestPermission(i, t, e) {
|
|
136
136
|
const s = (s) => {
|
|
@@ -146,23 +146,27 @@ export default class ea {
|
|
|
146
146
|
}
|
|
147
147
|
};
|
|
148
148
|
let n = !1;
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
149
|
+
if ("default" !== window.Notification.permission)
|
|
150
|
+
s(Notification.permission);
|
|
151
|
+
else {
|
|
152
|
+
const i = window.Notification.requestPermission((i) => {
|
|
153
|
+
n && s(i);
|
|
154
|
+
});
|
|
155
|
+
i
|
|
156
|
+
? i.then((i) => {
|
|
157
|
+
s(i);
|
|
158
|
+
})
|
|
159
|
+
: (n = !0);
|
|
160
|
+
}
|
|
157
161
|
}
|
|
158
|
-
|
|
162
|
+
vn(i, t, e, s) {
|
|
159
163
|
const n = { userVisibleOnly: !0 };
|
|
160
164
|
null != t && (n.applicationServerKey = t),
|
|
161
165
|
i.pushManager
|
|
162
166
|
.subscribe(n)
|
|
163
167
|
.then((i) => {
|
|
164
168
|
r.info("Device successfully subscribed to push."),
|
|
165
|
-
this.
|
|
169
|
+
this.gn(i, new Date(), e);
|
|
166
170
|
})
|
|
167
171
|
.catch((i) => {
|
|
168
172
|
vt.isPushBlocked()
|
|
@@ -172,10 +176,10 @@ export default class ea {
|
|
|
172
176
|
"function" == typeof s && s(!0));
|
|
173
177
|
});
|
|
174
178
|
}
|
|
175
|
-
|
|
176
|
-
return this.
|
|
177
|
-
? navigator.serviceWorker.getRegistration(this.
|
|
178
|
-
: navigator.serviceWorker.register(this.
|
|
179
|
+
jn() {
|
|
180
|
+
return this.cn
|
|
181
|
+
? navigator.serviceWorker.getRegistration(this.un)
|
|
182
|
+
: navigator.serviceWorker.register(this.un).then(() =>
|
|
179
183
|
navigator.serviceWorker.ready.then(
|
|
180
184
|
(i) => (
|
|
181
185
|
i &&
|
|
@@ -188,22 +192,22 @@ export default class ea {
|
|
|
188
192
|
),
|
|
189
193
|
);
|
|
190
194
|
}
|
|
191
|
-
|
|
192
|
-
this.
|
|
195
|
+
xn(i) {
|
|
196
|
+
this.cn ||
|
|
193
197
|
(i.unregister(), r.info("Service worker successfully unregistered."));
|
|
194
198
|
}
|
|
195
199
|
subscribe(i, t) {
|
|
196
200
|
if (!vt.isPushSupported())
|
|
197
201
|
return r.info(ea.Nn), void ("function" == typeof t && t(!1));
|
|
198
|
-
if (this.
|
|
199
|
-
if (!this.
|
|
200
|
-
let i = this.
|
|
202
|
+
if (this.ln) {
|
|
203
|
+
if (!this.cn && null != window.location) {
|
|
204
|
+
let i = this.un;
|
|
201
205
|
-1 === i.indexOf(window.location.host) &&
|
|
202
206
|
(i = window.location.host + i),
|
|
203
207
|
-1 === i.indexOf(window.location.protocol) &&
|
|
204
208
|
(i = window.location.protocol + "//" + i);
|
|
205
209
|
const e = i.substr(0, i.lastIndexOf("/") + 1);
|
|
206
|
-
if (0 !== eo.
|
|
210
|
+
if (0 !== eo.Un().indexOf(e))
|
|
207
211
|
return (
|
|
208
212
|
r.error(
|
|
209
213
|
"Cannot subscribe to push from a path higher than the service worker location (tried to subscribe from " +
|
|
@@ -216,16 +220,16 @@ export default class ea {
|
|
|
216
220
|
);
|
|
217
221
|
}
|
|
218
222
|
if (vt.isPushBlocked())
|
|
219
|
-
return void this.
|
|
223
|
+
return void this.Sn(
|
|
220
224
|
"Notifications from this site are blocked. This may be a temporary embargo or a permanent denial.",
|
|
221
225
|
t,
|
|
222
226
|
);
|
|
223
|
-
if (this.yt && !this.yt.
|
|
227
|
+
if (this.yt && !this.yt.Wn() && 0 === this.yt.ni())
|
|
224
228
|
return (
|
|
225
229
|
r.info(
|
|
226
230
|
"Waiting for VAPID key from server config before subscribing to push.",
|
|
227
231
|
),
|
|
228
|
-
void this.yt.
|
|
232
|
+
void this.yt._n(() => {
|
|
229
233
|
this.subscribe(i, t);
|
|
230
234
|
})
|
|
231
235
|
);
|
|
@@ -244,11 +248,11 @@ export default class ea {
|
|
|
244
248
|
n = vt.isPushPermissionGranted(),
|
|
245
249
|
u = () => {
|
|
246
250
|
!n &&
|
|
247
|
-
this.
|
|
248
|
-
this.
|
|
251
|
+
this.sn &&
|
|
252
|
+
this.sn.setPushNotificationSubscriptionType(
|
|
249
253
|
User.NotificationSubscriptionTypes.OPTED_IN,
|
|
250
254
|
),
|
|
251
|
-
this.
|
|
255
|
+
this.jn()
|
|
252
256
|
.then((e) => {
|
|
253
257
|
if (null == e)
|
|
254
258
|
return (
|
|
@@ -266,16 +270,16 @@ export default class ea {
|
|
|
266
270
|
(null !=
|
|
267
271
|
(null === (n = this.yt) || void 0 === n
|
|
268
272
|
? void 0
|
|
269
|
-
: n.
|
|
273
|
+
: n.Wn()) && (u = ei.Tn(this.yt.Wn())),
|
|
270
274
|
s)
|
|
271
275
|
) {
|
|
272
276
|
let n,
|
|
273
277
|
a = null,
|
|
274
|
-
|
|
275
|
-
if ((this.u && (n = this.u.j(o.C.
|
|
278
|
+
c = null;
|
|
279
|
+
if ((this.u && (n = this.u.j(o.C.In)), n && !j(n))) {
|
|
276
280
|
let i;
|
|
277
281
|
try {
|
|
278
|
-
i = ti.
|
|
282
|
+
i = ti.qn(n).Vn;
|
|
279
283
|
} catch (t) {
|
|
280
284
|
i = null;
|
|
281
285
|
}
|
|
@@ -283,8 +287,8 @@ export default class ea {
|
|
|
283
287
|
isNaN(i.getTime()) ||
|
|
284
288
|
0 === i.getTime() ||
|
|
285
289
|
((a = i),
|
|
286
|
-
(
|
|
287
|
-
|
|
290
|
+
(c = new Date(a)),
|
|
291
|
+
c.setMonth(a.getMonth() + 6));
|
|
288
292
|
}
|
|
289
293
|
null != u &&
|
|
290
294
|
s.options &&
|
|
@@ -299,31 +303,31 @@ export default class ea {
|
|
|
299
303
|
: r.info(
|
|
300
304
|
"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.",
|
|
301
305
|
),
|
|
302
|
-
this.
|
|
306
|
+
this.yn(s, e, u, i, t))
|
|
303
307
|
: s.expirationTime &&
|
|
304
308
|
new Date(s.expirationTime).valueOf() <=
|
|
305
309
|
new Date().valueOf()
|
|
306
310
|
? (r.info(
|
|
307
311
|
"Push subscription is expired, creating new subscription.",
|
|
308
312
|
),
|
|
309
|
-
this.
|
|
313
|
+
this.yn(s, e, u, i, t))
|
|
310
314
|
: n && j(n)
|
|
311
|
-
? this.
|
|
312
|
-
: null ==
|
|
315
|
+
? this.yn(s, e, u, i, t)
|
|
316
|
+
: null == c
|
|
313
317
|
? (r.info(
|
|
314
318
|
"No push subscription creation date found, creating new subscription.",
|
|
315
319
|
),
|
|
316
|
-
this.
|
|
317
|
-
:
|
|
320
|
+
this.yn(s, e, u, i, t))
|
|
321
|
+
: c.valueOf() <= new Date().valueOf()
|
|
318
322
|
? (r.info(
|
|
319
323
|
"Push subscription older than 6 months, creating new subscription.",
|
|
320
324
|
),
|
|
321
|
-
this.
|
|
325
|
+
this.yn(s, e, u, i, t))
|
|
322
326
|
: (r.info(
|
|
323
327
|
"Device already subscribed to push, sending existing subscription to backend.",
|
|
324
328
|
),
|
|
325
|
-
this.
|
|
326
|
-
} else this.
|
|
329
|
+
this.gn(s, a, i));
|
|
330
|
+
} else this.vn(e, u, i, t);
|
|
327
331
|
})
|
|
328
332
|
.catch((i) => {
|
|
329
333
|
r.error("Error checking current push subscriptions: " + i);
|
|
@@ -334,45 +338,49 @@ export default class ea {
|
|
|
334
338
|
});
|
|
335
339
|
};
|
|
336
340
|
this.requestPermission(u, s, e);
|
|
337
|
-
} else if (this.
|
|
338
|
-
if (null == this.
|
|
341
|
+
} else if (this.pn) {
|
|
342
|
+
if (null == this.an || "" === this.an)
|
|
339
343
|
return (
|
|
340
344
|
r.error(
|
|
341
345
|
"You must supply the safariWebsitePushId initialization option in order to use registerPush on Safari",
|
|
342
346
|
),
|
|
343
347
|
void ("function" == typeof t && t(!0))
|
|
344
348
|
);
|
|
345
|
-
const e = window.safari.pushNotification.permission(this.
|
|
346
|
-
this.
|
|
349
|
+
const e = window.safari.pushNotification.permission(this.an);
|
|
350
|
+
this.An(this.an, e, i, t);
|
|
347
351
|
}
|
|
348
352
|
}
|
|
349
353
|
unsubscribe(i, t) {
|
|
350
354
|
if (!vt.isPushSupported())
|
|
351
355
|
return r.info(ea.Nn), void ("function" == typeof t && t());
|
|
352
|
-
this.
|
|
356
|
+
this.ln
|
|
353
357
|
? navigator.serviceWorker.getRegistration().then((e) => {
|
|
354
358
|
e
|
|
355
359
|
? e.pushManager
|
|
356
360
|
.getSubscription()
|
|
357
361
|
.then((s) => {
|
|
358
|
-
s
|
|
359
|
-
(this.
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
362
|
+
s
|
|
363
|
+
? (this.Pn(),
|
|
364
|
+
s
|
|
365
|
+
.unsubscribe()
|
|
366
|
+
.then((s) => {
|
|
367
|
+
s
|
|
368
|
+
? (r.info(
|
|
369
|
+
"Device successfully unsubscribed from push.",
|
|
370
|
+
),
|
|
371
|
+
"function" == typeof i && i())
|
|
372
|
+
: (r.error(
|
|
373
|
+
"Failed to unsubscribe device from push.",
|
|
374
|
+
),
|
|
375
|
+
"function" == typeof t && t()),
|
|
376
|
+
this.xn(e);
|
|
377
|
+
})
|
|
378
|
+
.catch((i) => {
|
|
379
|
+
r.error("Push unsubscription error: " + i),
|
|
380
|
+
"function" == typeof t && t();
|
|
381
|
+
}))
|
|
382
|
+
: (r.info("Device already unsubscribed from push."),
|
|
383
|
+
"function" == typeof i && i());
|
|
376
384
|
})
|
|
377
385
|
.catch((i) => {
|
|
378
386
|
r.error("Error unsubscribing from push: " + i),
|
|
@@ -381,8 +389,8 @@ export default class ea {
|
|
|
381
389
|
: (r.info("Device already unsubscribed from push."),
|
|
382
390
|
"function" == typeof i && i());
|
|
383
391
|
})
|
|
384
|
-
: this.
|
|
385
|
-
(this.
|
|
392
|
+
: this.pn &&
|
|
393
|
+
(this.Pn(),
|
|
386
394
|
r.info("Device unsubscribed from push."),
|
|
387
395
|
"function" == typeof i && i());
|
|
388
396
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
const vt = {
|
|
2
|
-
|
|
2
|
+
dn: () =>
|
|
3
3
|
"serviceWorker" in navigator &&
|
|
4
4
|
"undefined" != typeof ServiceWorkerRegistration &&
|
|
5
5
|
"showNotification" in ServiceWorkerRegistration.prototype &&
|
|
6
6
|
"PushManager" in window,
|
|
7
|
-
|
|
7
|
+
bn: () =>
|
|
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: () => vt.
|
|
12
|
+
isPushSupported: () => vt.dn() || vt.bn(),
|
|
13
13
|
isPushBlocked: () => {
|
|
14
14
|
const i =
|
|
15
15
|
vt.isPushSupported() &&
|
|
@@ -28,7 +28,7 @@ const vt = {
|
|
|
28
28
|
null != window.Notification &&
|
|
29
29
|
null != window.Notification.permission &&
|
|
30
30
|
"granted" === window.Notification.permission,
|
|
31
|
-
|
|
31
|
+
Wi: () =>
|
|
32
32
|
!vt.isPushBlocked() &&
|
|
33
33
|
vt.isPushSupported() &&
|
|
34
34
|
!vt.isPushPermissionGranted(),
|
package/src/User/user-manager.js
CHANGED
|
@@ -47,7 +47,7 @@ export default class bt {
|
|
|
47
47
|
u
|
|
48
48
|
);
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
kn(t, s, i, e, u) {
|
|
51
51
|
this.nu("push_token", t, !1, !0),
|
|
52
52
|
this.nu("custom_push_public_key", i, !1, !0),
|
|
53
53
|
this.nu("custom_push_user_auth", e, !1, !0),
|
|
@@ -55,9 +55,9 @@ export default class bt {
|
|
|
55
55
|
const h = A.Yt.Qt,
|
|
56
56
|
n = new A(h, r),
|
|
57
57
|
l = new ti(t, s, i, e, u);
|
|
58
|
-
this.u.k(o.C.
|
|
58
|
+
this.u.k(o.C.In, l.Y()), n.setItem(h.ss.cu, h.ie, !0);
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
Dn(t) {
|
|
61
61
|
if (
|
|
62
62
|
(this.nu("push_token", null, !1, !0),
|
|
63
63
|
this.nu("custom_push_public_key", null, !1, !0),
|
|
@@ -67,7 +67,7 @@ export default class bt {
|
|
|
67
67
|
) {
|
|
68
68
|
const t = A.Yt.Qt,
|
|
69
69
|
s = new A(t, r);
|
|
70
|
-
this.u.k(o.C.
|
|
70
|
+
this.u.k(o.C.In, !1), s.setItem(t.ss.cu, t.ie, !1);
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
}
|
package/src/User/user.js
CHANGED
|
@@ -33,7 +33,7 @@ export default class User {
|
|
|
33
33
|
? (r.error("addAlias requires a non-empty alias"), !1)
|
|
34
34
|
: !P(e, "add alias", "the label", !1) || e.length <= 0
|
|
35
35
|
? (r.error("addAlias requires a non-empty label"), !1)
|
|
36
|
-
: this.Ei.
|
|
36
|
+
: this.Ei.Cn(t, e).L;
|
|
37
37
|
}
|
|
38
38
|
setFirstName(t) {
|
|
39
39
|
return (
|
|
@@ -126,7 +126,7 @@ export default class User {
|
|
|
126
126
|
setPhoneNumber(t) {
|
|
127
127
|
return (
|
|
128
128
|
!!P(t, "set phone number", "the phoneNumber", !0) &&
|
|
129
|
-
(null === t || t.match(User
|
|
129
|
+
(null === t || t.match(User.En)
|
|
130
130
|
? this.wt.nu("phone", t)
|
|
131
131
|
: (r.error(`Cannot set phone number - "${t}" did not pass validation.`),
|
|
132
132
|
!1))
|
|
@@ -179,11 +179,11 @@ export default class User {
|
|
|
179
179
|
if (j(e)) {
|
|
180
180
|
const [r, n] = St(t, e);
|
|
181
181
|
if (!r && !n && 0 !== e.length) return !1;
|
|
182
|
-
if (r || 0 === e.length) return this.Ei.
|
|
182
|
+
if (r || 0 === e.length) return this.Ei.Fn(i.$n, t, e).L;
|
|
183
183
|
for (const t of e) if (!s(t)) return !1;
|
|
184
184
|
} else if (Nt(e)) {
|
|
185
185
|
if (!s(e)) return !1;
|
|
186
|
-
if (r) return this.Ei.
|
|
186
|
+
if (r) return this.Ei.Fn(i.Bn, t, e).L;
|
|
187
187
|
} else {
|
|
188
188
|
if (!(void 0 !== e && Ut(e))) return !1;
|
|
189
189
|
if (
|
|
@@ -206,7 +206,7 @@ export default class User {
|
|
|
206
206
|
null != e &&
|
|
207
207
|
!rt(e, "add to custom user attribute array", "the given value")
|
|
208
208
|
) &&
|
|
209
|
-
this.Ei.
|
|
209
|
+
this.Ei.Fn(i.Ln, t, e).L
|
|
210
210
|
);
|
|
211
211
|
}
|
|
212
212
|
removeFromCustomAttributeArray(t, e) {
|
|
@@ -216,7 +216,7 @@ export default class User {
|
|
|
216
216
|
null != e &&
|
|
217
217
|
!rt(e, "remove from custom user attribute array", "the given value")
|
|
218
218
|
) &&
|
|
219
|
-
this.Ei.
|
|
219
|
+
this.Ei.Fn(i.Rn, t, e).L
|
|
220
220
|
);
|
|
221
221
|
}
|
|
222
222
|
incrementCustomUserAttribute(t, e) {
|
|
@@ -228,7 +228,7 @@ export default class User {
|
|
|
228
228
|
`Cannot increment custom user attribute because the given incrementValue "${e}" is not an integer.`,
|
|
229
229
|
),
|
|
230
230
|
!1)
|
|
231
|
-
: this.Ei.
|
|
231
|
+
: this.Ei.Fn(i.On, t, s).L;
|
|
232
232
|
}
|
|
233
233
|
setCustomLocationAttribute(t, e, s) {
|
|
234
234
|
return (
|
|
@@ -244,7 +244,7 @@ export default class User {
|
|
|
244
244
|
"Received invalid values for latitude and/or longitude. Latitude and longitude are bounded by ±90 and ±180 respectively, or must both be null for removal.",
|
|
245
245
|
),
|
|
246
246
|
!1)
|
|
247
|
-
: this.Ei.
|
|
247
|
+
: this.Ei.Gn(t, e, s).L)
|
|
248
248
|
);
|
|
249
249
|
}
|
|
250
250
|
addToSubscriptionGroup(t) {
|
|
@@ -258,7 +258,7 @@ export default class User {
|
|
|
258
258
|
"addToSubscriptionGroup requires a non-empty subscription group ID",
|
|
259
259
|
),
|
|
260
260
|
!1)
|
|
261
|
-
: this.Ei.
|
|
261
|
+
: this.Ei.Hn(t, User.Kn.SUBSCRIBED).L;
|
|
262
262
|
}
|
|
263
263
|
removeFromSubscriptionGroup(t) {
|
|
264
264
|
return !P(
|
|
@@ -271,13 +271,13 @@ export default class User {
|
|
|
271
271
|
"removeFromSubscriptionGroup requires a non-empty subscription group ID",
|
|
272
272
|
),
|
|
273
273
|
!1)
|
|
274
|
-
: this.Ei.
|
|
274
|
+
: this.Ei.Hn(t, User.Kn.UNSUBSCRIBED).L;
|
|
275
275
|
}
|
|
276
|
-
|
|
277
|
-
this.wt.
|
|
276
|
+
kn(t, e, r, s, n) {
|
|
277
|
+
this.wt.kn(t, e, r, s, n), this.Ei.Mn();
|
|
278
278
|
}
|
|
279
|
-
|
|
280
|
-
this.wt.
|
|
279
|
+
Dn(t) {
|
|
280
|
+
this.wt.Dn(t);
|
|
281
281
|
}
|
|
282
282
|
}
|
|
283
283
|
(User.Genders = {
|
|
@@ -293,8 +293,8 @@ export default class User {
|
|
|
293
293
|
SUBSCRIBED: "subscribed",
|
|
294
294
|
UNSUBSCRIBED: "unsubscribed",
|
|
295
295
|
}),
|
|
296
|
-
(User
|
|
297
|
-
(User.
|
|
298
|
-
(User.
|
|
296
|
+
(User.En = /^[0-9 .\\(\\)\\+\\-]+$/),
|
|
297
|
+
(User.Kn = { SUBSCRIBED: "subscribed", UNSUBSCRIBED: "unsubscribed" }),
|
|
298
|
+
(User.Yn = "user_id"),
|
|
299
299
|
(User.lu = "custom"),
|
|
300
300
|
(User.lr = 997);
|
package/src/common/base-feed.js
CHANGED