@braze/web-sdk 6.0.0 → 6.1.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 +103 -33
- package/package.json +1 -1
- package/shared-lib/encoding-utils.js +1 -1
- package/shared-lib/event-types.js +22 -22
- package/shared-lib/guid.js +3 -3
- package/shared-lib/indexed-db-adapter.js +19 -19
- package/shared-lib/logger.js +18 -18
- package/shared-lib/supported-options.js +15 -15
- package/src/Banner/banner-factory.js +2 -1
- package/src/Banner/banner-provider-factory.js +7 -7
- package/src/Banner/banner-provider.js +92 -98
- package/src/Banner/banner.js +21 -18
- package/src/Banner/display/banner-to-html.js +9 -9
- package/src/Banner/display/destroy-banner-html.js +2 -2
- package/src/Banner/display/detect-banner-impressions.js +2 -2
- package/src/Banner/get-all-banners.js +5 -5
- package/src/Banner/get-banner.js +7 -7
- package/src/Banner/log-banner-click.js +7 -7
- package/src/Banner/log-banner-impressions.js +9 -9
- package/src/Banner/request-banners-refresh.js +16 -20
- package/src/Banner/subscribe-to-banners-updates.js +7 -7
- package/src/Banner/ui/insert-banner.js +6 -6
- package/src/Card/card-manager-factory.js +7 -7
- package/src/Card/card-manager.js +35 -35
- package/src/Card/display/card-display.js +11 -11
- package/src/Card/log-card-dismissal.js +4 -4
- package/src/Card/log-content-card-click.js +4 -4
- package/src/Card/log-content-card-impressions.js +6 -6
- package/src/Card/models/captioned-image.js +21 -21
- package/src/Card/models/card.js +68 -68
- package/src/Card/models/classic-card.js +21 -21
- package/src/Card/models/control-card.js +11 -11
- package/src/Card/models/image-only.js +18 -18
- package/src/Card/util/card-factory.js +35 -35
- package/src/ContentCards/content-cards-provider-factory.js +13 -13
- package/src/ContentCards/content-cards-provider.js +136 -136
- package/src/ContentCards/get-cached-content-cards.js +2 -2
- package/src/ContentCards/request-content-cards-refresh.js +2 -2
- package/src/ContentCards/subscribe-to-content-cards-updates.js +6 -6
- package/src/ContentCards/ui/show-content-cards.js +7 -7
- package/src/Core/add-sdk-metadata.js +3 -3
- package/src/Core/change-user.js +7 -7
- package/src/Core/destroy.js +2 -2
- package/src/Core/disable-sdk.js +8 -8
- package/src/Core/enable-sdk.js +6 -6
- package/src/Core/get-device-id.js +4 -4
- package/src/Core/handle-braze-action.js +5 -5
- package/src/Core/is-disabled.js +1 -1
- package/src/Core/log-custom-event.js +10 -10
- package/src/Core/log-purchase.js +13 -13
- package/src/Core/open-session.js +10 -10
- package/src/Core/set-logger.js +2 -2
- package/src/Core/set-sdk-authentication-signature.js +2 -2
- package/src/Core/toggle-logging.js +2 -2
- package/src/Core/wipe-data.js +7 -7
- package/src/FeatureFlags/feature-flag-factory.js +10 -10
- package/src/FeatureFlags/feature-flag.js +20 -71
- package/src/FeatureFlags/feature-flags-provider-factory.js +12 -12
- package/src/FeatureFlags/feature-flags-provider.js +87 -87
- package/src/FeatureFlags/get-all-feature-flags.js +4 -4
- package/src/FeatureFlags/get-feature-flag.js +4 -4
- package/src/FeatureFlags/log-feature-flag-impression.js +9 -9
- package/src/FeatureFlags/refresh-feature-flags.js +2 -2
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +4 -4
- package/src/InAppMessage/defer-in-app-message.js +4 -4
- package/src/InAppMessage/display/html-message-to-html.js +10 -10
- package/src/InAppMessage/display/in-app-message-to-html.js +28 -28
- package/src/InAppMessage/display/modal-utils.js +7 -7
- package/src/InAppMessage/in-app-message-factory.js +15 -15
- package/src/InAppMessage/in-app-message-manager-factory.js +5 -5
- package/src/InAppMessage/in-app-message-manager.js +100 -100
- package/src/InAppMessage/log-in-app-message-button-click.js +9 -9
- package/src/InAppMessage/log-in-app-message-click.js +6 -6
- package/src/InAppMessage/log-in-app-message-html-click.js +9 -9
- package/src/InAppMessage/log-in-app-message-impression.js +4 -4
- package/src/InAppMessage/models/control-message.js +4 -4
- package/src/InAppMessage/models/full-screen-message.js +35 -35
- package/src/InAppMessage/models/html-message.js +21 -21
- package/src/InAppMessage/models/in-app-message-button.js +5 -5
- package/src/InAppMessage/models/in-app-message.js +75 -75
- package/src/InAppMessage/models/modal-message.js +34 -34
- package/src/InAppMessage/models/slide-up-message.js +31 -31
- package/src/InAppMessage/models/templated-in-app-message.js +8 -8
- package/src/InAppMessage/subscribe-to-in-app-message.js +1 -1
- package/src/InAppMessage/ui/automatically-show-in-app-messages.js +3 -3
- package/src/InAppMessage/ui/show-in-app-message.js +19 -19
- package/src/Push/push-manager-factory.js +9 -9
- package/src/Push/push-manager.js +118 -118
- package/src/Push/utils/push-utils.js +9 -9
- package/src/User/user-manager.js +20 -20
- package/src/User/user.js +44 -45
- package/src/common/base-provider.js +1 -1
- package/src/common/content-cards-display.js +18 -18
- package/src/common/event-logger.js +10 -10
- package/src/common/properties-base.js +56 -0
- package/src/l10n/l10n-manager-factory.js +7 -7
- package/src/l10n/l10n-manager.js +4 -4
- package/src/managers/auth-manager.js +32 -32
- package/src/managers/braze-instance.js +143 -143
- package/src/managers/device-manager.js +22 -22
- package/src/managers/network-manager.js +172 -168
- package/src/managers/server-config-manager.js +73 -73
- package/src/managers/session-manager.js +40 -40
- package/src/managers/storage-manager-factory.js +6 -6
- package/src/managers/storage-manager.js +97 -97
- package/src/managers/subscription-manager.js +12 -12
- package/src/managers/utils.js +1 -1
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +5 -5
- package/src/models/device.js +2 -2
- package/src/models/identifier.js +12 -12
- package/src/models/push-token.js +13 -13
- package/src/models/request-result.js +4 -4
- package/src/models/server-config.js +31 -31
- package/src/request-controller.js +159 -159
- package/src/triggers/models/custom-event-data.js +1 -1
- package/src/triggers/models/custom-event-property-data.js +2 -2
- package/src/triggers/models/filter-set.js +6 -6
- package/src/triggers/models/filter.js +26 -26
- package/src/triggers/models/in-app-message-click-data.js +1 -1
- package/src/triggers/models/purchase-data.js +1 -1
- package/src/triggers/models/purchase-property-data.js +2 -2
- package/src/triggers/models/push-click-data.js +1 -1
- package/src/triggers/models/trigger-condition.js +37 -37
- package/src/triggers/models/trigger-events.js +3 -3
- package/src/triggers/models/trigger.js +16 -16
- package/src/triggers/triggers-provider-factory.js +12 -12
- package/src/triggers/triggers-provider.js +61 -61
- package/src/ui/js/attach-css.js +1 -1
- 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 +6 -6
- package/src/util/browser-detector.js +20 -13
- package/src/util/client-hints-parser.js +6 -6
- package/src/util/code-utils.js +2 -2
- package/src/util/component-utils.js +1 -1
- package/src/util/deprecation-utils.js +2 -2
- package/src/util/device-constants.js +4 -4
- package/src/util/dom-utils.js +9 -9
- package/src/util/html-display-utils.js +7 -7
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +12 -12
- package/src/util/request-header-utils.js +22 -22
- package/src/util/string-utils.js +2 -2
- package/src/util/user-agent-parser.js +16 -16
- package/src/util/validation-utils.js +12 -12
- package/src/util/window-utils.js +2 -2
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
import { isURIJavascriptOrData as tt } from "../../util/url-utils.js";
|
|
14
14
|
import { KeyCodes as ie } from "../../util/key-codes.js";
|
|
15
15
|
import { setupInAppMessageUI as ss } from "../../ui/js/index.js";
|
|
16
|
-
import { logger as
|
|
16
|
+
import { logger as E } from "../../../shared-lib/index.js";
|
|
17
17
|
import { toRgba as ae } from "../../util/color-utils.js";
|
|
18
18
|
import { isIFrame as At } from "../utils/in-app-message-utils.js";
|
|
19
19
|
import fe from "../../l10n/l10n-manager-factory.js";
|
|
@@ -22,7 +22,7 @@ export function showInAppMessage(e, t, s) {
|
|
|
22
22
|
if ((ss(), null == e)) return !1;
|
|
23
23
|
if (e instanceof ControlMessage)
|
|
24
24
|
return (
|
|
25
|
-
|
|
25
|
+
E.info(
|
|
26
26
|
"User received control for a multivariate test, logging to Braze servers.",
|
|
27
27
|
),
|
|
28
28
|
logInAppMessageImpression(e),
|
|
@@ -34,22 +34,22 @@ export function showInAppMessage(e, t, s) {
|
|
|
34
34
|
const o = e instanceof HtmlMessage;
|
|
35
35
|
if (o && !e.trusted && !r.tr())
|
|
36
36
|
return (
|
|
37
|
-
|
|
37
|
+
E.error(
|
|
38
38
|
'HTML in-app messages are disabled. Use the "allowUserSuppliedJavascript" option for braze.initialize to enable these messages.',
|
|
39
39
|
),
|
|
40
40
|
!1
|
|
41
41
|
);
|
|
42
|
-
if ((null == t && (t = document.body), e.
|
|
42
|
+
if ((null == t && (t = document.body), e.Ve())) {
|
|
43
43
|
if (t.querySelectorAll(".ab-modal-interactions").length > 0)
|
|
44
44
|
return (
|
|
45
|
-
|
|
45
|
+
E.info(
|
|
46
46
|
`Cannot show in-app message ${e.message} because another message is being shown.`,
|
|
47
47
|
),
|
|
48
48
|
!1
|
|
49
49
|
);
|
|
50
50
|
}
|
|
51
51
|
if (no.Uo()) {
|
|
52
|
-
const t = no
|
|
52
|
+
const t = no.$o();
|
|
53
53
|
if (
|
|
54
54
|
(t === pe.PORTRAIT &&
|
|
55
55
|
e.orientation === InAppMessage.Orientation.LANDSCAPE) ||
|
|
@@ -62,7 +62,7 @@ export function showInAppMessage(e, t, s) {
|
|
|
62
62
|
? "portrait"
|
|
63
63
|
: "landscape";
|
|
64
64
|
return (
|
|
65
|
-
|
|
65
|
+
E.info(
|
|
66
66
|
`Not showing ${o} in-app message ${e.message} because the screen is currently ${s}`,
|
|
67
67
|
),
|
|
68
68
|
!1
|
|
@@ -81,7 +81,7 @@ export function showInAppMessage(e, t, s) {
|
|
|
81
81
|
} else e.clickAction === InAppMessage.ClickAction.URI && (t = tt(e.uri));
|
|
82
82
|
if (t)
|
|
83
83
|
return (
|
|
84
|
-
|
|
84
|
+
E.error(
|
|
85
85
|
'Javascript click actions are disabled. Use the "allowUserSuppliedJavascript" option for braze.initialize to enable these actions.',
|
|
86
86
|
),
|
|
87
87
|
!1
|
|
@@ -92,14 +92,14 @@ export function showInAppMessage(e, t, s) {
|
|
|
92
92
|
((i.className = "ab-iam-root v3"),
|
|
93
93
|
(i.className += me(e)),
|
|
94
94
|
e.language && !o && (i.lang = e.language),
|
|
95
|
-
e.
|
|
96
|
-
r.ee(z.
|
|
95
|
+
e.Le() && (i.id = e.htmlId),
|
|
96
|
+
r.ee(z.Jo) && (i.style.zIndex = (r.ee(z.Jo) + 1).toString()),
|
|
97
97
|
t.appendChild(i),
|
|
98
|
-
e.
|
|
98
|
+
e.Oe())
|
|
99
99
|
) {
|
|
100
100
|
const t = document.createElement("style");
|
|
101
101
|
(t.innerHTML = e.css),
|
|
102
|
-
(t.id = e.
|
|
102
|
+
(t.id = e.Ge()),
|
|
103
103
|
null != r.ee(z.er) && t.setAttribute("nonce", r.ee(z.er)),
|
|
104
104
|
document.getElementsByTagName("head")[0].appendChild(t);
|
|
105
105
|
}
|
|
@@ -107,12 +107,12 @@ export function showInAppMessage(e, t, s) {
|
|
|
107
107
|
a = le(
|
|
108
108
|
e,
|
|
109
109
|
(t) => {
|
|
110
|
-
if (e.
|
|
110
|
+
if (e.Ve() && e.Bo()) {
|
|
111
111
|
const s = document.createElement("div");
|
|
112
112
|
if (
|
|
113
113
|
((s.className = "ab-page-blocker"),
|
|
114
|
-
e.
|
|
115
|
-
r.ee(z.
|
|
114
|
+
e.Oe() || (s.style.backgroundColor = ae(e.frameColor)),
|
|
115
|
+
r.ee(z.Jo) && (s.style.zIndex = r.ee(z.Jo).toString()),
|
|
116
116
|
i.appendChild(s),
|
|
117
117
|
!r.ee(z.Lh))
|
|
118
118
|
) {
|
|
@@ -159,13 +159,13 @@ export function showInAppMessage(e, t, s) {
|
|
|
159
159
|
"function" == typeof s && s();
|
|
160
160
|
},
|
|
161
161
|
(e) => {
|
|
162
|
-
|
|
162
|
+
E.info(e);
|
|
163
163
|
},
|
|
164
|
-
r.ee(z.
|
|
165
|
-
r.ee(z.
|
|
164
|
+
r.ee(z.Do),
|
|
165
|
+
r.ee(z.Jo),
|
|
166
166
|
r.ee(z.er),
|
|
167
167
|
t,
|
|
168
|
-
fe.ea().
|
|
168
|
+
fe.ea().So(),
|
|
169
169
|
);
|
|
170
170
|
return (o || n) && (i.appendChild(a), e.Ah(i)), !0;
|
|
171
171
|
}
|
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
import r, { OPTIONS as z } from "../managers/braze-instance.js";
|
|
2
2
|
import na from "./push-manager.js";
|
|
3
3
|
const ra = {
|
|
4
|
-
|
|
4
|
+
i: !1,
|
|
5
5
|
aa: null,
|
|
6
6
|
ea: () => (
|
|
7
|
-
ra.
|
|
7
|
+
ra.t(),
|
|
8
8
|
ra.aa ||
|
|
9
9
|
(ra.aa = new na(
|
|
10
10
|
r.gr(),
|
|
11
11
|
r.ba(),
|
|
12
|
-
r.
|
|
13
|
-
r.
|
|
12
|
+
r.de(),
|
|
13
|
+
r.V(),
|
|
14
14
|
r.ee(z.Ma),
|
|
15
15
|
r.ee(z._a),
|
|
16
16
|
r.ee(z.ka),
|
|
17
|
-
r.
|
|
17
|
+
r.l(),
|
|
18
18
|
r.ee(z.qa),
|
|
19
19
|
r.ee(z.Aa),
|
|
20
|
-
r.
|
|
20
|
+
r.p(),
|
|
21
21
|
)),
|
|
22
22
|
ra.aa
|
|
23
23
|
),
|
|
24
|
-
|
|
25
|
-
ra.
|
|
24
|
+
t: () => {
|
|
25
|
+
ra.i || (r.g(ra), (ra.i = !0));
|
|
26
26
|
},
|
|
27
27
|
destroy: () => {
|
|
28
|
-
(ra.aa = null), (ra.
|
|
28
|
+
(ra.aa = null), (ra.i = !1);
|
|
29
29
|
},
|
|
30
30
|
};
|
|
31
31
|
export default ra;
|
package/src/Push/push-manager.js
CHANGED
|
@@ -1,52 +1,52 @@
|
|
|
1
1
|
import { isArray as D, isEqual as ii } from "../util/code-utils.js";
|
|
2
2
|
import ti from "../models/push-token.js";
|
|
3
|
-
import { logger as
|
|
3
|
+
import { logger as E, EncodingUtils as ei } from "../../shared-lib/index.js";
|
|
4
4
|
import { STORAGE_KEYS as s } from "../managers/storage-manager.js";
|
|
5
5
|
import { User } from "../User/index.js";
|
|
6
6
|
import yt from "./utils/push-utils.js";
|
|
7
7
|
import { getErrorMessage as si } from "../util/error-utils.js";
|
|
8
8
|
export default class na {
|
|
9
9
|
constructor(i, t, e, s, r, n, o, u, a, h, c) {
|
|
10
|
-
(this.
|
|
11
|
-
(this.
|
|
12
|
-
(this.
|
|
13
|
-
(this.
|
|
14
|
-
(this.
|
|
15
|
-
(this.
|
|
16
|
-
(this.
|
|
17
|
-
(this.
|
|
18
|
-
(this.
|
|
19
|
-
(this.
|
|
20
|
-
(this.
|
|
21
|
-
(this.
|
|
22
|
-
(this.
|
|
23
|
-
(this.
|
|
24
|
-
(this.
|
|
25
|
-
(this.
|
|
26
|
-
(this.
|
|
27
|
-
(this.
|
|
28
|
-
(this.
|
|
29
|
-
(this.
|
|
30
|
-
(this.
|
|
31
|
-
(this.
|
|
10
|
+
(this.en = i),
|
|
11
|
+
(this.sn = t),
|
|
12
|
+
(this.on = e),
|
|
13
|
+
(this.un = r),
|
|
14
|
+
(this.an = n),
|
|
15
|
+
(this.hn = o),
|
|
16
|
+
(this.h = u),
|
|
17
|
+
(this.cn = a),
|
|
18
|
+
(this.fn = h),
|
|
19
|
+
(this.j = c),
|
|
20
|
+
(this.en = i),
|
|
21
|
+
(this.sn = t),
|
|
22
|
+
(this.on = e),
|
|
23
|
+
(this.ln = s + "/safari/" + t),
|
|
24
|
+
(this.un = r || "/service-worker.js"),
|
|
25
|
+
(this.hn = o),
|
|
26
|
+
(this.h = u),
|
|
27
|
+
(this.cn = a || !1),
|
|
28
|
+
(this.fn = h || !1),
|
|
29
|
+
(this.j = c),
|
|
30
|
+
(this.dn = yt.pn()),
|
|
31
|
+
(this.bn = yt.yn());
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
return this.
|
|
33
|
+
mn() {
|
|
34
|
+
return this.fn;
|
|
35
35
|
}
|
|
36
|
-
|
|
36
|
+
gn(i, t, e, s, r) {
|
|
37
37
|
i.unsubscribe()
|
|
38
38
|
.then((i) => {
|
|
39
39
|
i
|
|
40
|
-
? this.
|
|
41
|
-
: (
|
|
40
|
+
? this.vn(t, e, s, r)
|
|
41
|
+
: (E.error("Failed to unsubscribe device from push."),
|
|
42
42
|
"function" == typeof r && r(!1));
|
|
43
43
|
})
|
|
44
44
|
.catch((i) => {
|
|
45
|
-
|
|
45
|
+
E.error("Push unsubscription error: " + i),
|
|
46
46
|
"function" == typeof r && r(!1);
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
|
-
|
|
49
|
+
wn(i, t, e) {
|
|
50
50
|
var s;
|
|
51
51
|
const r = ((i) => {
|
|
52
52
|
if ("string" == typeof i) return i;
|
|
@@ -55,9 +55,9 @@ export default class na {
|
|
|
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.kn &&
|
|
59
|
+
-1 === i.endpoint.indexOf(e.kn) &&
|
|
60
|
+
(t = i.endpoint + "/" + e.kn),
|
|
61
61
|
t
|
|
62
62
|
);
|
|
63
63
|
})(i);
|
|
@@ -71,7 +71,7 @@ export default class na {
|
|
|
71
71
|
(n = btoa(String.fromCharCode.apply(null, i))),
|
|
72
72
|
(o = btoa(String.fromCharCode.apply(null, t)));
|
|
73
73
|
} catch (i) {
|
|
74
|
-
|
|
74
|
+
E.error(si(i));
|
|
75
75
|
}
|
|
76
76
|
const a = ((i) => {
|
|
77
77
|
let t;
|
|
@@ -84,53 +84,53 @@ export default class na {
|
|
|
84
84
|
.replace(/\//g, "_")
|
|
85
85
|
: null;
|
|
86
86
|
})(u);
|
|
87
|
-
null === (s = this.
|
|
87
|
+
null === (s = this.en) || void 0 === s || s.Pn(r, t, n, o, a),
|
|
88
88
|
r && "function" == typeof e && e(r, n, o);
|
|
89
89
|
}
|
|
90
|
-
|
|
90
|
+
Dn() {
|
|
91
91
|
var i;
|
|
92
|
-
null === (i = this.
|
|
92
|
+
null === (i = this.en) || void 0 === i || i.Sn(!0);
|
|
93
93
|
}
|
|
94
|
-
|
|
94
|
+
An(i, t) {
|
|
95
95
|
var e;
|
|
96
|
-
null === (e = this.
|
|
97
|
-
|
|
96
|
+
null === (e = this.en) || void 0 === e || e.Sn(!1),
|
|
97
|
+
E.info(i),
|
|
98
98
|
"function" == typeof t && t(!1);
|
|
99
99
|
}
|
|
100
|
-
|
|
100
|
+
jn(i, t, e, s) {
|
|
101
101
|
var r;
|
|
102
102
|
if ("default" === t.permission)
|
|
103
103
|
try {
|
|
104
104
|
window.safari.pushNotification.requestPermission(
|
|
105
|
-
this.
|
|
105
|
+
this.ln,
|
|
106
106
|
i,
|
|
107
107
|
{
|
|
108
|
-
api_key: this.
|
|
108
|
+
api_key: this.sn,
|
|
109
109
|
device_id:
|
|
110
|
-
(null === (r = this.
|
|
110
|
+
(null === (r = this.on) || void 0 === r ? void 0 : r.fe().id) ||
|
|
111
111
|
"",
|
|
112
112
|
},
|
|
113
113
|
(t) => {
|
|
114
114
|
"granted" === t.permission &&
|
|
115
|
-
this.
|
|
116
|
-
this.
|
|
115
|
+
this.en &&
|
|
116
|
+
this.en.setPushNotificationSubscriptionType(
|
|
117
117
|
User.NotificationSubscriptionTypes.OPTED_IN,
|
|
118
118
|
),
|
|
119
|
-
this.
|
|
119
|
+
this.jn(i, t, e, s);
|
|
120
120
|
},
|
|
121
121
|
);
|
|
122
122
|
} catch (i) {
|
|
123
|
-
this.
|
|
123
|
+
this.An("Could not request permission for push: " + i, s);
|
|
124
124
|
}
|
|
125
125
|
else
|
|
126
126
|
"denied" === t.permission
|
|
127
|
-
? this.
|
|
127
|
+
? this.An(
|
|
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
|
-
(
|
|
133
|
-
this.
|
|
132
|
+
(E.info("Device successfully subscribed to push."),
|
|
133
|
+
this.wn(t.deviceToken, new Date(), e));
|
|
134
134
|
}
|
|
135
135
|
requestPermission(i, t, e) {
|
|
136
136
|
const s = (s) => {
|
|
@@ -142,7 +142,7 @@ export default class na {
|
|
|
142
142
|
case "denied":
|
|
143
143
|
return void ("function" == typeof e && e());
|
|
144
144
|
default:
|
|
145
|
-
|
|
145
|
+
E.error("Received unexpected permission result " + s);
|
|
146
146
|
}
|
|
147
147
|
};
|
|
148
148
|
let r = !1;
|
|
@@ -159,70 +159,70 @@ export default class na {
|
|
|
159
159
|
: (r = !0);
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
|
-
|
|
162
|
+
vn(i, t, e, s) {
|
|
163
163
|
const r = { userVisibleOnly: !0 };
|
|
164
164
|
null != t && (r.applicationServerKey = t),
|
|
165
165
|
i.pushManager
|
|
166
166
|
.subscribe(r)
|
|
167
167
|
.then((i) => {
|
|
168
|
-
|
|
169
|
-
this.
|
|
168
|
+
E.info("Device successfully subscribed to push."),
|
|
169
|
+
this.wn(i, new Date(), e);
|
|
170
170
|
})
|
|
171
171
|
.catch((i) => {
|
|
172
172
|
yt.isPushBlocked()
|
|
173
|
-
? (
|
|
173
|
+
? (E.info("Permission for push notifications was denied."),
|
|
174
174
|
"function" == typeof s && s(!1))
|
|
175
|
-
: (
|
|
175
|
+
: (E.error("Push subscription failed: " + i),
|
|
176
176
|
"function" == typeof s && s(!0));
|
|
177
177
|
});
|
|
178
178
|
}
|
|
179
|
-
|
|
180
|
-
if (this.
|
|
181
|
-
const i = this.
|
|
182
|
-
return navigator.serviceWorker.register(this.
|
|
179
|
+
xn() {
|
|
180
|
+
if (this.cn) return navigator.serviceWorker.getRegistration(this.un);
|
|
181
|
+
const i = this.an ? { scope: this.an } : void 0;
|
|
182
|
+
return navigator.serviceWorker.register(this.un, i).then(() =>
|
|
183
183
|
navigator.serviceWorker.ready.then(
|
|
184
184
|
(i) => (
|
|
185
185
|
i &&
|
|
186
186
|
"function" == typeof i.update &&
|
|
187
187
|
i.update().catch((i) => {
|
|
188
|
-
|
|
188
|
+
E.info("ServiceWorker update failed: " + i);
|
|
189
189
|
}),
|
|
190
190
|
i
|
|
191
191
|
),
|
|
192
192
|
),
|
|
193
193
|
);
|
|
194
194
|
}
|
|
195
|
-
|
|
196
|
-
this.
|
|
197
|
-
(i.unregister(),
|
|
195
|
+
Nn(i) {
|
|
196
|
+
this.cn ||
|
|
197
|
+
(i.unregister(), E.info("Service worker successfully unregistered."));
|
|
198
198
|
}
|
|
199
199
|
subscribe(i, t) {
|
|
200
200
|
if (!yt.isPushSupported())
|
|
201
|
-
return
|
|
202
|
-
if (this.
|
|
203
|
-
if (!this.
|
|
204
|
-
let i = this.
|
|
201
|
+
return E.info(na.Un), void ("function" == typeof t && t(!1));
|
|
202
|
+
if (this.dn) {
|
|
203
|
+
if (!this.cn && null != window.location) {
|
|
204
|
+
let i = this.un;
|
|
205
205
|
-1 === i.indexOf(window.location.host) &&
|
|
206
206
|
(i = window.location.host + i),
|
|
207
207
|
-1 === i.indexOf(window.location.protocol) &&
|
|
208
208
|
(i = window.location.protocol + "//" + i);
|
|
209
209
|
}
|
|
210
210
|
if (yt.isPushBlocked())
|
|
211
|
-
return void this.
|
|
211
|
+
return void this.An(
|
|
212
212
|
"Notifications from this site are blocked. This may be a temporary embargo or a permanent denial.",
|
|
213
213
|
t,
|
|
214
214
|
);
|
|
215
|
-
if (this.
|
|
215
|
+
if (this.h && !this.h.Wn() && 0 === this.h.Ft())
|
|
216
216
|
return (
|
|
217
|
-
|
|
217
|
+
E.info(
|
|
218
218
|
"Waiting for VAPID key from server config before subscribing to push.",
|
|
219
219
|
),
|
|
220
|
-
void this.
|
|
220
|
+
void this.h._n(() => {
|
|
221
221
|
this.subscribe(i, t);
|
|
222
222
|
})
|
|
223
223
|
);
|
|
224
224
|
const e = () => {
|
|
225
|
-
|
|
225
|
+
E.info("Permission for push notifications was denied."),
|
|
226
226
|
"function" == typeof t && t(!1);
|
|
227
227
|
},
|
|
228
228
|
r = () => {
|
|
@@ -230,21 +230,21 @@ export default class na {
|
|
|
230
230
|
yt.isPushBlocked() &&
|
|
231
231
|
(i +=
|
|
232
232
|
" The browser has automatically blocked further permission requests for a period (probably 1 week)."),
|
|
233
|
-
|
|
233
|
+
E.info(i),
|
|
234
234
|
"function" == typeof t && t(!0);
|
|
235
235
|
},
|
|
236
236
|
n = yt.isPushPermissionGranted(),
|
|
237
237
|
o = () => {
|
|
238
238
|
!n &&
|
|
239
|
-
this.
|
|
240
|
-
this.
|
|
239
|
+
this.en &&
|
|
240
|
+
this.en.setPushNotificationSubscriptionType(
|
|
241
241
|
User.NotificationSubscriptionTypes.OPTED_IN,
|
|
242
242
|
),
|
|
243
|
-
this.
|
|
243
|
+
this.xn()
|
|
244
244
|
.then((e) => {
|
|
245
245
|
if (null == e)
|
|
246
246
|
return (
|
|
247
|
-
|
|
247
|
+
E.error(
|
|
248
248
|
"No service worker registration. Set the `manageServiceWorkerExternally` initialization option to false or ensure that your service worker is registered before calling registerPush.",
|
|
249
249
|
),
|
|
250
250
|
void ("function" == typeof t && t(!0))
|
|
@@ -256,18 +256,18 @@ export default class na {
|
|
|
256
256
|
let o = null;
|
|
257
257
|
if (
|
|
258
258
|
(null !=
|
|
259
|
-
(null === (n = this.
|
|
259
|
+
(null === (n = this.h) || void 0 === n
|
|
260
260
|
? void 0
|
|
261
|
-
: n.
|
|
261
|
+
: n.Wn()) && (o = ei.Tn(this.h.Wn())),
|
|
262
262
|
r)
|
|
263
263
|
) {
|
|
264
264
|
let n,
|
|
265
265
|
u = null,
|
|
266
266
|
a = null;
|
|
267
|
-
if ((this.
|
|
267
|
+
if ((this.j && (n = this.j.lt(s.ct.In)), n && !D(n))) {
|
|
268
268
|
let i;
|
|
269
269
|
try {
|
|
270
|
-
i = ti.
|
|
270
|
+
i = ti.qn(n).Vn;
|
|
271
271
|
} catch (t) {
|
|
272
272
|
i = null;
|
|
273
273
|
}
|
|
@@ -285,102 +285,102 @@ export default class na {
|
|
|
285
285
|
r.options.applicationServerKey.byteLength > 0 &&
|
|
286
286
|
!ii(o, new Uint8Array(r.options.applicationServerKey))
|
|
287
287
|
? (r.options.applicationServerKey.byteLength > 12
|
|
288
|
-
?
|
|
288
|
+
? E.info(
|
|
289
289
|
"Device was already subscribed to push using a different VAPID provider, creating new subscription.",
|
|
290
290
|
)
|
|
291
|
-
:
|
|
291
|
+
: E.info(
|
|
292
292
|
"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.",
|
|
293
293
|
),
|
|
294
|
-
this.
|
|
294
|
+
this.gn(r, e, o, i, t))
|
|
295
295
|
: r.expirationTime &&
|
|
296
296
|
new Date(r.expirationTime).valueOf() <=
|
|
297
297
|
new Date().valueOf()
|
|
298
|
-
? (
|
|
298
|
+
? (E.info(
|
|
299
299
|
"Push subscription is expired, creating new subscription.",
|
|
300
300
|
),
|
|
301
|
-
this.
|
|
301
|
+
this.gn(r, e, o, i, t))
|
|
302
302
|
: n && D(n)
|
|
303
|
-
? this.
|
|
303
|
+
? this.gn(r, e, o, i, t)
|
|
304
304
|
: null == a
|
|
305
|
-
? (
|
|
305
|
+
? (E.info(
|
|
306
306
|
"No push subscription creation date found, creating new subscription.",
|
|
307
307
|
),
|
|
308
|
-
this.
|
|
308
|
+
this.gn(r, e, o, i, t))
|
|
309
309
|
: a.valueOf() <= new Date().valueOf()
|
|
310
|
-
? (
|
|
310
|
+
? (E.info(
|
|
311
311
|
"Push subscription older than 6 months, creating new subscription.",
|
|
312
312
|
),
|
|
313
|
-
this.
|
|
314
|
-
: (
|
|
313
|
+
this.gn(r, e, o, i, t))
|
|
314
|
+
: (E.info(
|
|
315
315
|
"Device already subscribed to push, sending existing subscription to backend.",
|
|
316
316
|
),
|
|
317
|
-
this.
|
|
318
|
-
} else this.
|
|
317
|
+
this.wn(r, u, i));
|
|
318
|
+
} else this.vn(e, o, i, t);
|
|
319
319
|
})
|
|
320
320
|
.catch((i) => {
|
|
321
|
-
|
|
321
|
+
E.error("Error checking current push subscriptions: " + i);
|
|
322
322
|
});
|
|
323
323
|
})
|
|
324
324
|
.catch((i) => {
|
|
325
|
-
|
|
325
|
+
E.error("ServiceWorker registration failed: " + i);
|
|
326
326
|
});
|
|
327
327
|
};
|
|
328
328
|
this.requestPermission(o, r, e);
|
|
329
|
-
} else if (this.
|
|
330
|
-
if (null == this.
|
|
329
|
+
} else if (this.bn) {
|
|
330
|
+
if (null == this.hn || "" === this.hn)
|
|
331
331
|
return (
|
|
332
|
-
|
|
332
|
+
E.error(
|
|
333
333
|
"You must supply the safariWebsitePushId initialization option in order to use registerPush on Safari",
|
|
334
334
|
),
|
|
335
335
|
void ("function" == typeof t && t(!0))
|
|
336
336
|
);
|
|
337
|
-
const e = window.safari.pushNotification.permission(this.
|
|
338
|
-
this.
|
|
337
|
+
const e = window.safari.pushNotification.permission(this.hn);
|
|
338
|
+
this.jn(this.hn, e, i, t);
|
|
339
339
|
}
|
|
340
340
|
}
|
|
341
341
|
unsubscribe(i, t) {
|
|
342
342
|
if (!yt.isPushSupported())
|
|
343
|
-
return
|
|
344
|
-
this.
|
|
345
|
-
? navigator.serviceWorker.getRegistration(this.
|
|
343
|
+
return E.info(na.Un), void ("function" == typeof t && t());
|
|
344
|
+
this.dn
|
|
345
|
+
? navigator.serviceWorker.getRegistration(this.un).then((e) => {
|
|
346
346
|
e
|
|
347
347
|
? e.pushManager
|
|
348
348
|
.getSubscription()
|
|
349
349
|
.then((s) => {
|
|
350
350
|
s
|
|
351
|
-
? (this.
|
|
351
|
+
? (this.Dn(),
|
|
352
352
|
s
|
|
353
353
|
.unsubscribe()
|
|
354
354
|
.then((s) => {
|
|
355
355
|
s
|
|
356
|
-
? (
|
|
356
|
+
? (E.info(
|
|
357
357
|
"Device successfully unsubscribed from push.",
|
|
358
358
|
),
|
|
359
359
|
"function" == typeof i && i())
|
|
360
|
-
: (
|
|
360
|
+
: (E.error(
|
|
361
361
|
"Failed to unsubscribe device from push.",
|
|
362
362
|
),
|
|
363
363
|
"function" == typeof t && t()),
|
|
364
|
-
this.
|
|
364
|
+
this.Nn(e);
|
|
365
365
|
})
|
|
366
366
|
.catch((i) => {
|
|
367
|
-
|
|
367
|
+
E.error("Push unsubscription error: " + i),
|
|
368
368
|
"function" == typeof t && t();
|
|
369
369
|
}))
|
|
370
|
-
: (
|
|
370
|
+
: (E.info("Device already unsubscribed from push."),
|
|
371
371
|
"function" == typeof i && i());
|
|
372
372
|
})
|
|
373
373
|
.catch((i) => {
|
|
374
|
-
|
|
374
|
+
E.error("Error unsubscribing from push: " + i),
|
|
375
375
|
"function" == typeof t && t();
|
|
376
376
|
})
|
|
377
|
-
: (
|
|
377
|
+
: (E.info("Device already unsubscribed from push."),
|
|
378
378
|
"function" == typeof i && i());
|
|
379
379
|
})
|
|
380
|
-
: this.
|
|
381
|
-
(this.
|
|
382
|
-
|
|
380
|
+
: this.bn &&
|
|
381
|
+
(this.Dn(),
|
|
382
|
+
E.info("Device unsubscribed from push."),
|
|
383
383
|
"function" == typeof i && i());
|
|
384
384
|
}
|
|
385
385
|
}
|
|
386
|
-
na.
|
|
386
|
+
na.Un = "Push notifications are not supported in this browser.";
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
const yt = {
|
|
2
|
-
|
|
2
|
+
pn: () =>
|
|
3
3
|
"serviceWorker" in navigator &&
|
|
4
4
|
"undefined" != typeof ServiceWorkerRegistration &&
|
|
5
5
|
"showNotification" in ServiceWorkerRegistration.prototype &&
|
|
6
6
|
"PushManager" in window,
|
|
7
|
-
|
|
7
|
+
yn: () =>
|
|
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: () => yt.
|
|
12
|
+
isPushSupported: () => yt.pn() || yt.yn(),
|
|
13
13
|
isPushBlocked: () => {
|
|
14
14
|
const o =
|
|
15
15
|
yt.isPushSupported() &&
|
|
@@ -28,15 +28,15 @@ const yt = {
|
|
|
28
28
|
null != window.Notification &&
|
|
29
29
|
null != window.Notification.permission &&
|
|
30
30
|
"granted" === window.Notification.permission,
|
|
31
|
-
|
|
31
|
+
Qi: () =>
|
|
32
32
|
yt.isPushBlocked()
|
|
33
|
-
? {
|
|
33
|
+
? { Ui: !1, reason: "blocked" }
|
|
34
34
|
: yt.isPushSupported()
|
|
35
35
|
? yt.isPushPermissionGranted()
|
|
36
|
-
? {
|
|
37
|
-
: {
|
|
38
|
-
: {
|
|
39
|
-
|
|
36
|
+
? { Ui: !1, reason: "permissionGranted" }
|
|
37
|
+
: { Ui: !0 }
|
|
38
|
+
: { Ui: !1, reason: "unsupported" },
|
|
39
|
+
Vi: (o, i) =>
|
|
40
40
|
"blocked" === o
|
|
41
41
|
? `${i} containing a push prompt is not being shown because the user has already declined push permission prompt.`
|
|
42
42
|
: "unsupported" === o
|