@braze/web-sdk 5.9.1 → 6.0.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 +109 -253
- package/package.json +1 -1
- package/shared-lib/encoding-utils.js +1 -1
- package/shared-lib/event-types.js +24 -26
- package/shared-lib/guid.js +2 -2
- package/shared-lib/indexed-db-adapter.js +19 -19
- package/shared-lib/logger.js +2 -2
- package/shared-lib/supported-options.js +21 -22
- package/src/Banner/display/banner-to-html.js +13 -25
- package/src/Banner/display/destroy-banner-html.js +2 -2
- package/src/Banner/display/detect-banner-impressions.js +11 -11
- package/src/Banner/index.js +0 -1
- package/src/Banner/request-banners-refresh.js +8 -8
- package/src/Banner/subscribe-to-banners-updates.js +2 -2
- package/src/Banner/ui/insert-banner.js +7 -7
- package/src/Card/card-manager.js +35 -37
- package/src/Card/display/card-display.js +76 -74
- package/src/Card/index.js +0 -2
- package/src/Card/log-card-dismissal.js +2 -2
- package/src/Card/log-content-card-click.js +9 -2
- package/src/Card/log-content-card-impressions.js +11 -2
- package/src/Card/models/captioned-image.js +20 -20
- package/src/Card/models/card.js +110 -104
- package/src/Card/models/classic-card.js +20 -20
- package/src/Card/models/control-card.js +14 -14
- package/src/Card/models/image-only.js +19 -20
- package/src/Card/util/card-factory.js +57 -78
- package/src/ContentCards/content-cards-provider-factory.js +10 -10
- package/src/ContentCards/content-cards-provider.js +109 -109
- package/src/ContentCards/content-cards.js +21 -13
- 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 +5 -5
- package/src/ContentCards/ui/hide-content-cards.js +5 -5
- package/src/ContentCards/ui/show-content-cards.js +34 -34
- package/src/Core/add-sdk-metadata.js +2 -2
- package/src/Core/change-user.js +7 -7
- package/src/Core/disable-sdk.js +6 -6
- package/src/Core/enable-sdk.js +5 -5
- package/src/Core/get-user.js +1 -1
- package/src/Core/handle-braze-action.js +7 -7
- package/src/Core/is-disabled.js +2 -2
- package/src/Core/is-initialized.js +1 -1
- package/src/Core/log-custom-event.js +9 -9
- package/src/Core/log-purchase.js +7 -7
- package/src/Core/open-session.js +12 -12
- package/src/Core/request-immediate-data-flush.js +1 -1
- package/src/Core/set-sdk-authentication-signature.js +2 -2
- package/src/Core/wipe-data.js +7 -7
- package/src/FeatureFlags/feature-flag-factory.js +7 -7
- package/src/FeatureFlags/feature-flag.js +6 -6
- package/src/FeatureFlags/feature-flags-provider-factory.js +9 -9
- package/src/FeatureFlags/feature-flags-provider.js +1 -1
- package/src/FeatureFlags/get-all-feature-flags.js +2 -2
- package/src/FeatureFlags/get-feature-flag.js +2 -2
- package/src/FeatureFlags/log-feature-flag-impression.js +4 -4
- package/src/FeatureFlags/refresh-feature-flags.js +2 -2
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +2 -2
- package/src/InAppMessage/defer-in-app-message.js +1 -1
- package/src/InAppMessage/display/html-message-to-html.js +37 -37
- package/src/InAppMessage/display/in-app-message-to-html.js +139 -133
- package/src/InAppMessage/display/modal-utils.js +39 -41
- package/src/InAppMessage/get-deferred-in-app-message.js +1 -1
- package/src/InAppMessage/in-app-message-factory.js +22 -14
- package/src/InAppMessage/in-app-message-manager.js +90 -88
- package/src/InAppMessage/log-in-app-message-button-click.js +5 -5
- package/src/InAppMessage/log-in-app-message-click.js +5 -5
- package/src/InAppMessage/log-in-app-message-html-click.js +5 -5
- package/src/InAppMessage/log-in-app-message-impression.js +1 -1
- package/src/InAppMessage/models/control-message.js +2 -2
- package/src/InAppMessage/models/full-screen-message.js +40 -34
- package/src/InAppMessage/models/html-message.js +23 -21
- package/src/InAppMessage/models/in-app-message-button.js +2 -2
- package/src/InAppMessage/models/in-app-message.js +137 -133
- package/src/InAppMessage/models/modal-message.js +39 -33
- package/src/InAppMessage/models/slide-up-message.js +36 -30
- 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 +56 -62
- package/src/Push/is-push-blocked.js +2 -2
- package/src/Push/is-push-permission-granted.js +2 -2
- package/src/Push/is-push-supported.js +2 -2
- package/src/Push/push-manager-factory.js +8 -8
- package/src/Push/push-manager.js +90 -90
- package/src/Push/request-push-permission.js +1 -1
- package/src/Push/utils/push-utils.js +25 -15
- package/src/User/user-manager.js +14 -14
- package/src/User/user.js +55 -55
- package/src/common/content-cards-display.js +211 -0
- package/src/common/event-logger.js +6 -6
- package/src/index.js +0 -1
- package/src/l10n/l10n-manager-factory.js +9 -9
- package/src/l10n/l10n-manager.js +6 -6
- package/src/managers/auth-manager.js +27 -27
- package/src/managers/braze-instance.js +136 -137
- package/src/managers/device-manager.js +22 -22
- package/src/managers/network-manager.js +180 -183
- package/src/managers/server-config-manager.js +63 -63
- package/src/managers/session-manager.js +34 -34
- package/src/managers/storage-manager-factory.js +11 -11
- package/src/managers/storage-manager.js +139 -141
- package/src/managers/subscription-manager.js +3 -3
- package/src/managers/utils.js +1 -1
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +15 -15
- package/src/models/device.js +3 -3
- package/src/models/identifier.js +13 -13
- package/src/models/push-token.js +12 -12
- package/src/models/request-result.js +2 -2
- package/src/models/server-config.js +29 -29
- package/src/request-controller.js +175 -174
- package/src/triggers/models/custom-event-data.js +6 -6
- package/src/triggers/models/custom-event-property-data.js +7 -7
- package/src/triggers/models/filter-set.js +8 -8
- package/src/triggers/models/filter.js +45 -45
- package/src/triggers/models/in-app-message-click-data.js +3 -3
- package/src/triggers/models/purchase-data.js +1 -1
- 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 +47 -47
- package/src/triggers/models/trigger-events.js +3 -3
- package/src/triggers/models/trigger.js +15 -15
- package/src/triggers/triggers-provider-factory.js +4 -4
- package/src/triggers/triggers-provider.js +44 -44
- package/src/ui/js/attach-css.js +3 -3
- package/src/ui/js/banner-css.js +1 -1
- package/src/ui/js/iam-css.js +1 -1
- package/src/ui/js/load-font-awesome.js +2 -2
- package/src/util/base-device-parser.js +4 -4
- package/src/util/braze-actions.js +8 -14
- package/src/util/browser-detector.js +12 -12
- package/src/util/client-hints-parser.js +3 -3
- package/src/util/component-utils.js +14 -14
- package/src/util/device-constants.js +1 -1
- package/src/util/dom-utils.js +6 -6
- package/src/util/html-display-utils.js +37 -37
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +1 -1
- package/src/util/request-header-utils.js +17 -17
- package/src/util/user-agent-parser.js +4 -4
- package/src/util/validation-utils.js +20 -20
- package/src/util/window-utils.js +1 -1
- package/src/Card/log-card-click.js +0 -11
- package/src/Card/log-card-impressions.js +0 -13
- package/src/Feed/feed-provider-factory.js +0 -18
- package/src/Feed/feed-provider.js +0 -90
- package/src/Feed/feed.js +0 -20
- package/src/Feed/get-cached-feed.js +0 -5
- package/src/Feed/index.js +0 -8
- package/src/Feed/log-feed-displayed.js +0 -7
- package/src/Feed/request-feed-refresh.js +0 -5
- package/src/Feed/subscribe-to-feed-updates.js +0 -5
- package/src/Feed/types.js +0 -1
- package/src/Feed/ui/hide-feed.js +0 -7
- package/src/Feed/ui/show-feed.js +0 -96
- package/src/Feed/ui/toggle-feed.js +0 -8
- package/src/common/base-feed.js +0 -29
- package/src/common/feed-display.js +0 -211
|
@@ -7,9 +7,9 @@ export function automaticallyShowInAppMessages() {
|
|
|
7
7
|
if (!r.rr()) return;
|
|
8
8
|
ss();
|
|
9
9
|
const s = se.ea();
|
|
10
|
-
if (null == s.
|
|
10
|
+
if (null == s.Pi()) {
|
|
11
11
|
const r = subscribeToInAppMessage((s) => showInAppMessage(s));
|
|
12
|
-
s.
|
|
12
|
+
s.Gi(r);
|
|
13
13
|
}
|
|
14
|
-
return s.
|
|
14
|
+
return s.Pi();
|
|
15
15
|
}
|
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
import r, { OPTIONS as
|
|
1
|
+
import r, { OPTIONS as z } from "../../managers/braze-instance.js";
|
|
2
2
|
import ControlMessage from "../models/control-message.js";
|
|
3
3
|
import HtmlMessage from "../models/html-message.js";
|
|
4
4
|
import InAppMessage from "../models/in-app-message.js";
|
|
5
5
|
import SlideUpMessage from "../models/slide-up-message.js";
|
|
6
6
|
import me from "../display/get-animation-effect.js";
|
|
7
|
-
import
|
|
7
|
+
import le from "../display/in-app-message-to-html.js";
|
|
8
8
|
import { logInAppMessageImpression } from "../log-in-app-message-impression.js";
|
|
9
9
|
import {
|
|
10
|
-
ORIENTATION as
|
|
10
|
+
ORIENTATION as pe,
|
|
11
11
|
WindowUtils as no,
|
|
12
12
|
} from "../../util/window-utils.js";
|
|
13
|
-
import { isURIJavascriptOrData as
|
|
14
|
-
import { KeyCodes as
|
|
13
|
+
import { isURIJavascriptOrData as tt } from "../../util/url-utils.js";
|
|
14
|
+
import { KeyCodes as ie } from "../../util/key-codes.js";
|
|
15
15
|
import { setupInAppMessageUI as ss } from "../../ui/js/index.js";
|
|
16
16
|
import { logger as N } from "../../../shared-lib/index.js";
|
|
17
|
-
import { toRgba as
|
|
18
|
-
import {
|
|
19
|
-
import
|
|
20
|
-
|
|
21
|
-
export function showInAppMessage(e, t, o) {
|
|
17
|
+
import { toRgba as ae } from "../../util/color-utils.js";
|
|
18
|
+
import { isIFrame as At } from "../utils/in-app-message-utils.js";
|
|
19
|
+
import fe from "../../l10n/l10n-manager-factory.js";
|
|
20
|
+
export function showInAppMessage(e, t, s) {
|
|
22
21
|
if (!r.rr()) return;
|
|
23
22
|
if ((ss(), null == e)) return !1;
|
|
24
23
|
if (e instanceof ControlMessage)
|
|
@@ -31,9 +30,9 @@ export function showInAppMessage(e, t, o) {
|
|
|
31
30
|
);
|
|
32
31
|
if (!(e instanceof InAppMessage)) return !1;
|
|
33
32
|
if (e.constructor === InAppMessage) return !1;
|
|
34
|
-
e.
|
|
35
|
-
const
|
|
36
|
-
if (
|
|
33
|
+
e._h();
|
|
34
|
+
const o = e instanceof HtmlMessage;
|
|
35
|
+
if (o && !e.trusted && !r.tr())
|
|
37
36
|
return (
|
|
38
37
|
N.error(
|
|
39
38
|
'HTML in-app messages are disabled. Use the "allowUserSuppliedJavascript" option for braze.initialize to enable these messages.',
|
|
@@ -52,19 +51,19 @@ export function showInAppMessage(e, t, o) {
|
|
|
52
51
|
if (no.Uo()) {
|
|
53
52
|
const t = no.No();
|
|
54
53
|
if (
|
|
55
|
-
(t ===
|
|
54
|
+
(t === pe.PORTRAIT &&
|
|
56
55
|
e.orientation === InAppMessage.Orientation.LANDSCAPE) ||
|
|
57
|
-
(t ===
|
|
56
|
+
(t === pe.LANDSCAPE &&
|
|
58
57
|
e.orientation === InAppMessage.Orientation.PORTRAIT)
|
|
59
58
|
) {
|
|
60
|
-
const
|
|
61
|
-
|
|
59
|
+
const s = t === pe.PORTRAIT ? "portrait" : "landscape",
|
|
60
|
+
o =
|
|
62
61
|
e.orientation === InAppMessage.Orientation.PORTRAIT
|
|
63
62
|
? "portrait"
|
|
64
63
|
: "landscape";
|
|
65
64
|
return (
|
|
66
65
|
N.info(
|
|
67
|
-
`Not showing ${
|
|
66
|
+
`Not showing ${o} in-app message ${e.message} because the screen is currently ${s}`,
|
|
68
67
|
),
|
|
69
68
|
!1
|
|
70
69
|
);
|
|
@@ -73,13 +72,13 @@ export function showInAppMessage(e, t, o) {
|
|
|
73
72
|
if (!r.tr()) {
|
|
74
73
|
let t = !1;
|
|
75
74
|
if (e.buttons && e.buttons.length > 0) {
|
|
76
|
-
const
|
|
77
|
-
for (let e = 0; e <
|
|
78
|
-
if (
|
|
79
|
-
const
|
|
80
|
-
t =
|
|
75
|
+
const s = e.buttons;
|
|
76
|
+
for (let e = 0; e < s.length; e++)
|
|
77
|
+
if (s[e].clickAction === InAppMessage.ClickAction.URI) {
|
|
78
|
+
const o = s[e].uri;
|
|
79
|
+
t = tt(o);
|
|
81
80
|
}
|
|
82
|
-
} else e.clickAction === InAppMessage.ClickAction.URI && (t =
|
|
81
|
+
} else e.clickAction === InAppMessage.ClickAction.URI && (t = tt(e.uri));
|
|
83
82
|
if (t)
|
|
84
83
|
return (
|
|
85
84
|
N.error(
|
|
@@ -92,69 +91,64 @@ export function showInAppMessage(e, t, o) {
|
|
|
92
91
|
if (
|
|
93
92
|
((i.className = "ab-iam-root v3"),
|
|
94
93
|
(i.className += me(e)),
|
|
95
|
-
i.
|
|
96
|
-
e.
|
|
97
|
-
r.ee(
|
|
94
|
+
e.language && !o && (i.lang = e.language),
|
|
95
|
+
e.jo() && (i.id = e.htmlId),
|
|
96
|
+
r.ee(z.Ko) && (i.style.zIndex = (r.ee(z.Ko) + 1).toString()),
|
|
98
97
|
t.appendChild(i),
|
|
99
98
|
e.lo())
|
|
100
99
|
) {
|
|
101
100
|
const t = document.createElement("style");
|
|
102
101
|
(t.innerHTML = e.css),
|
|
103
102
|
(t.id = e.do()),
|
|
104
|
-
null != r.ee(
|
|
103
|
+
null != r.ee(z.er) && t.setAttribute("nonce", r.ee(z.er)),
|
|
105
104
|
document.getElementsByTagName("head")[0].appendChild(t);
|
|
106
105
|
}
|
|
107
106
|
const n = e instanceof SlideUpMessage,
|
|
108
|
-
a =
|
|
107
|
+
a = le(
|
|
109
108
|
e,
|
|
110
|
-
() => {
|
|
111
|
-
import("../../Feed/ui/show-feed.js").then((e) => {
|
|
112
|
-
r.nn() ? e.showFeed() : N.error(p);
|
|
113
|
-
});
|
|
114
|
-
},
|
|
115
109
|
(t) => {
|
|
116
110
|
if (e.vo() && e.Po()) {
|
|
117
|
-
const
|
|
111
|
+
const s = document.createElement("div");
|
|
118
112
|
if (
|
|
119
|
-
((
|
|
120
|
-
e.lo() || (
|
|
121
|
-
r.ee(
|
|
122
|
-
i.appendChild(
|
|
123
|
-
!r.ee(
|
|
113
|
+
((s.className = "ab-page-blocker"),
|
|
114
|
+
e.lo() || (s.style.backgroundColor = ae(e.frameColor)),
|
|
115
|
+
r.ee(z.Ko) && (s.style.zIndex = r.ee(z.Ko).toString()),
|
|
116
|
+
i.appendChild(s),
|
|
117
|
+
!r.ee(z.Lh))
|
|
124
118
|
) {
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
new Date().valueOf() -
|
|
128
|
-
(e.ll(t),
|
|
119
|
+
const o = new Date().valueOf();
|
|
120
|
+
s.onclick = (s) => {
|
|
121
|
+
new Date().valueOf() - o > InAppMessage.Ph &&
|
|
122
|
+
(e.ll(t), s.stopPropagation());
|
|
129
123
|
};
|
|
130
124
|
}
|
|
131
125
|
i.appendChild(t), t.focus(), e.Ah(i);
|
|
132
126
|
} else if (n) {
|
|
133
|
-
const
|
|
134
|
-
let
|
|
135
|
-
for (let e =
|
|
136
|
-
if (
|
|
137
|
-
|
|
127
|
+
const s = document.querySelectorAll(".ab-slideup");
|
|
128
|
+
let o = null;
|
|
129
|
+
for (let e = s.length - 1; e >= 0; e--)
|
|
130
|
+
if (s[e] !== t) {
|
|
131
|
+
o = s[e];
|
|
138
132
|
break;
|
|
139
133
|
}
|
|
140
134
|
if (e.slideFrom === InAppMessage.SlideFrom.TOP) {
|
|
141
135
|
let e = 0;
|
|
142
|
-
null !=
|
|
136
|
+
null != o && (e = o.offsetTop + o.offsetHeight),
|
|
143
137
|
(t.style.top = Math.max(e, 0) + "px");
|
|
144
138
|
} else {
|
|
145
139
|
let e = 0;
|
|
146
|
-
null !=
|
|
140
|
+
null != o &&
|
|
147
141
|
(e =
|
|
148
142
|
(window.innerHeight || document.documentElement.clientHeight) -
|
|
149
|
-
|
|
143
|
+
o.offsetTop),
|
|
150
144
|
(t.style.bottom = Math.max(e, 0) + "px");
|
|
151
145
|
}
|
|
152
|
-
} else if (
|
|
153
|
-
const
|
|
154
|
-
|
|
146
|
+
} else if (o && !r.ee(z.Lh)) {
|
|
147
|
+
const s = e;
|
|
148
|
+
At(t) &&
|
|
155
149
|
t.contentWindow &&
|
|
156
150
|
t.contentWindow.addEventListener("keydown", function (e) {
|
|
157
|
-
e.keyCode ===
|
|
151
|
+
e.keyCode === ie.Oh && s.closeMessage();
|
|
158
152
|
});
|
|
159
153
|
}
|
|
160
154
|
logInAppMessageImpression(e),
|
|
@@ -162,16 +156,16 @@ export function showInAppMessage(e, t, o) {
|
|
|
162
156
|
setTimeout(() => {
|
|
163
157
|
i.contains(t) && e.ll(t);
|
|
164
158
|
}, e.duration),
|
|
165
|
-
"function" == typeof
|
|
159
|
+
"function" == typeof s && s();
|
|
166
160
|
},
|
|
167
161
|
(e) => {
|
|
168
162
|
N.info(e);
|
|
169
163
|
},
|
|
170
|
-
r.ee(
|
|
171
|
-
r.ee(
|
|
172
|
-
r.ee(
|
|
164
|
+
r.ee(z.Qo),
|
|
165
|
+
r.ee(z.Ko),
|
|
166
|
+
r.ee(z.er),
|
|
173
167
|
t,
|
|
174
|
-
|
|
168
|
+
fe.ea().Ro(),
|
|
175
169
|
);
|
|
176
|
-
return (
|
|
170
|
+
return (o || n) && (i.appendChild(a), e.Ah(i)), !0;
|
|
177
171
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import r from "../managers/braze-instance.js";
|
|
2
|
-
import
|
|
2
|
+
import yt from "./utils/push-utils.js";
|
|
3
3
|
export function isPushPermissionGranted() {
|
|
4
|
-
if (r.rr()) return
|
|
4
|
+
if (r.rr()) return yt.isPushPermissionGranted();
|
|
5
5
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import r, { OPTIONS as
|
|
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
|
l: !1,
|
|
@@ -7,16 +7,16 @@ const ra = {
|
|
|
7
7
|
ra.p(),
|
|
8
8
|
ra.aa ||
|
|
9
9
|
(ra.aa = new na(
|
|
10
|
-
r.
|
|
11
|
-
r.
|
|
10
|
+
r.gr(),
|
|
11
|
+
r.ba(),
|
|
12
12
|
r.ue(),
|
|
13
13
|
r.Z(),
|
|
14
|
-
r.ee(
|
|
15
|
-
r.ee(
|
|
16
|
-
r.ee(
|
|
14
|
+
r.ee(z.Ma),
|
|
15
|
+
r.ee(z._a),
|
|
16
|
+
r.ee(z.ka),
|
|
17
17
|
r.v(),
|
|
18
|
-
r.ee(
|
|
19
|
-
r.ee(
|
|
18
|
+
r.ee(z.qa),
|
|
19
|
+
r.ee(z.Aa),
|
|
20
20
|
r.j(),
|
|
21
21
|
)),
|
|
22
22
|
ra.aa
|
package/src/Push/push-manager.js
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import { isArray as
|
|
1
|
+
import { isArray as D, isEqual as ii } from "../util/code-utils.js";
|
|
2
2
|
import ti from "../models/push-token.js";
|
|
3
3
|
import { logger as N, 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
|
-
import
|
|
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.
|
|
10
|
+
(this.sn = i),
|
|
11
|
+
(this.on = t),
|
|
12
|
+
(this.un = e),
|
|
13
|
+
(this.an = r),
|
|
14
|
+
(this.hn = n),
|
|
15
|
+
(this.cn = o),
|
|
16
16
|
(this.B = u),
|
|
17
|
-
(this.
|
|
18
|
-
(this.
|
|
17
|
+
(this.fn = a),
|
|
18
|
+
(this.ln = h),
|
|
19
19
|
(this.C = c),
|
|
20
|
-
(this.
|
|
21
|
-
(this.
|
|
22
|
-
(this.
|
|
23
|
-
(this.
|
|
24
|
-
(this.
|
|
25
|
-
(this.
|
|
20
|
+
(this.sn = i),
|
|
21
|
+
(this.on = t),
|
|
22
|
+
(this.un = e),
|
|
23
|
+
(this.dn = s + "/safari/" + t),
|
|
24
|
+
(this.an = r || "/service-worker.js"),
|
|
25
|
+
(this.cn = o),
|
|
26
26
|
(this.B = u),
|
|
27
|
-
(this.
|
|
28
|
-
(this.
|
|
27
|
+
(this.fn = a || !1),
|
|
28
|
+
(this.ln = h || !1),
|
|
29
29
|
(this.C = c),
|
|
30
|
-
(this.
|
|
31
|
-
(this.
|
|
30
|
+
(this.pn = yt.bn()),
|
|
31
|
+
(this.yn = yt.mn());
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
return this.
|
|
33
|
+
gn() {
|
|
34
|
+
return this.ln;
|
|
35
35
|
}
|
|
36
|
-
|
|
36
|
+
vn(i, t, e, s, r) {
|
|
37
37
|
i.unsubscribe()
|
|
38
38
|
.then((i) => {
|
|
39
39
|
i
|
|
40
|
-
? this.
|
|
40
|
+
? this.wn(t, e, s, r)
|
|
41
41
|
: (N.error("Failed to unsubscribe device from push."),
|
|
42
42
|
"function" == typeof r && r(!1));
|
|
43
43
|
})
|
|
@@ -46,7 +46,7 @@ export default class na {
|
|
|
46
46
|
"function" == typeof r && r(!1);
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
|
-
|
|
49
|
+
kn(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.Pn &&
|
|
59
|
+
-1 === i.endpoint.indexOf(e.Pn) &&
|
|
60
|
+
(t = i.endpoint + "/" + e.Pn),
|
|
61
61
|
t
|
|
62
62
|
);
|
|
63
63
|
})(i);
|
|
@@ -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.sn) || void 0 === s || s.Dn(r, t, n, o, a),
|
|
88
88
|
r && "function" == typeof e && e(r, n, o);
|
|
89
89
|
}
|
|
90
|
-
|
|
90
|
+
Sn() {
|
|
91
91
|
var i;
|
|
92
|
-
null === (i = this.
|
|
92
|
+
null === (i = this.sn) || void 0 === i || i.An(!0);
|
|
93
93
|
}
|
|
94
|
-
|
|
94
|
+
jn(i, t) {
|
|
95
95
|
var e;
|
|
96
|
-
null === (e = this.
|
|
96
|
+
null === (e = this.sn) || void 0 === e || e.An(!1),
|
|
97
97
|
N.info(i),
|
|
98
98
|
"function" == typeof t && t(!1);
|
|
99
99
|
}
|
|
100
|
-
|
|
100
|
+
xn(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.dn,
|
|
106
106
|
i,
|
|
107
107
|
{
|
|
108
|
-
api_key: this.
|
|
108
|
+
api_key: this.on,
|
|
109
109
|
device_id:
|
|
110
|
-
(null === (r = this.
|
|
110
|
+
(null === (r = this.un) || void 0 === r ? void 0 : r.ve().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.xn(i, t, e, s);
|
|
120
120
|
},
|
|
121
121
|
);
|
|
122
122
|
} catch (i) {
|
|
123
|
-
this.
|
|
123
|
+
this.jn("Could not request permission for push: " + i, s);
|
|
124
124
|
}
|
|
125
125
|
else
|
|
126
126
|
"denied" === t.permission
|
|
127
|
-
? this.
|
|
127
|
+
? this.jn(
|
|
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
|
(N.info("Device successfully subscribed to push."),
|
|
133
|
-
this.
|
|
133
|
+
this.kn(t.deviceToken, new Date(), e));
|
|
134
134
|
}
|
|
135
135
|
requestPermission(i, t, e) {
|
|
136
136
|
const s = (s) => {
|
|
@@ -159,27 +159,27 @@ export default class na {
|
|
|
159
159
|
: (r = !0);
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
|
-
|
|
162
|
+
wn(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
168
|
N.info("Device successfully subscribed to push."),
|
|
169
|
-
this.
|
|
169
|
+
this.kn(i, new Date(), e);
|
|
170
170
|
})
|
|
171
171
|
.catch((i) => {
|
|
172
|
-
|
|
172
|
+
yt.isPushBlocked()
|
|
173
173
|
? (N.info("Permission for push notifications was denied."),
|
|
174
174
|
"function" == typeof s && s(!1))
|
|
175
175
|
: (N.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
|
+
Nn() {
|
|
180
|
+
if (this.fn) return navigator.serviceWorker.getRegistration(this.an);
|
|
181
|
+
const i = this.hn ? { scope: this.hn } : void 0;
|
|
182
|
+
return navigator.serviceWorker.register(this.an, i).then(() =>
|
|
183
183
|
navigator.serviceWorker.ready.then(
|
|
184
184
|
(i) => (
|
|
185
185
|
i &&
|
|
@@ -192,32 +192,32 @@ export default class na {
|
|
|
192
192
|
),
|
|
193
193
|
);
|
|
194
194
|
}
|
|
195
|
-
|
|
196
|
-
this.
|
|
195
|
+
Un(i) {
|
|
196
|
+
this.fn ||
|
|
197
197
|
(i.unregister(), N.info("Service worker successfully unregistered."));
|
|
198
198
|
}
|
|
199
199
|
subscribe(i, t) {
|
|
200
|
-
if (!
|
|
201
|
-
return N.info(na.
|
|
202
|
-
if (this.
|
|
203
|
-
if (!this.
|
|
204
|
-
let i = this.
|
|
200
|
+
if (!yt.isPushSupported())
|
|
201
|
+
return N.info(na.Wn), void ("function" == typeof t && t(!1));
|
|
202
|
+
if (this.pn) {
|
|
203
|
+
if (!this.fn && null != window.location) {
|
|
204
|
+
let i = this.an;
|
|
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
|
-
if (
|
|
211
|
-
return void this.
|
|
210
|
+
if (yt.isPushBlocked())
|
|
211
|
+
return void this.jn(
|
|
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.B && !this.B.
|
|
215
|
+
if (this.B && !this.B._n() && 0 === this.B.Et())
|
|
216
216
|
return (
|
|
217
217
|
N.info(
|
|
218
218
|
"Waiting for VAPID key from server config before subscribing to push.",
|
|
219
219
|
),
|
|
220
|
-
void this.B.
|
|
220
|
+
void this.B.Tn(() => {
|
|
221
221
|
this.subscribe(i, t);
|
|
222
222
|
})
|
|
223
223
|
);
|
|
@@ -227,20 +227,20 @@ export default class na {
|
|
|
227
227
|
},
|
|
228
228
|
r = () => {
|
|
229
229
|
let i = "Permission for push notifications was ignored.";
|
|
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
|
N.info(i),
|
|
234
234
|
"function" == typeof t && t(!0);
|
|
235
235
|
},
|
|
236
|
-
n =
|
|
236
|
+
n = yt.isPushPermissionGranted(),
|
|
237
237
|
o = () => {
|
|
238
238
|
!n &&
|
|
239
|
-
this.
|
|
240
|
-
this.
|
|
239
|
+
this.sn &&
|
|
240
|
+
this.sn.setPushNotificationSubscriptionType(
|
|
241
241
|
User.NotificationSubscriptionTypes.OPTED_IN,
|
|
242
242
|
),
|
|
243
|
-
this.
|
|
243
|
+
this.Nn()
|
|
244
244
|
.then((e) => {
|
|
245
245
|
if (null == e)
|
|
246
246
|
return (
|
|
@@ -258,16 +258,16 @@ export default class na {
|
|
|
258
258
|
(null !=
|
|
259
259
|
(null === (n = this.B) || void 0 === n
|
|
260
260
|
? void 0
|
|
261
|
-
: n.
|
|
261
|
+
: n._n()) && (o = ei.In(this.B._n())),
|
|
262
262
|
r)
|
|
263
263
|
) {
|
|
264
264
|
let n,
|
|
265
265
|
u = null,
|
|
266
266
|
a = null;
|
|
267
|
-
if ((this.C && (n = this.C.ft(s.gt.
|
|
267
|
+
if ((this.C && (n = this.C.ft(s.gt.Vn)), n && !D(n))) {
|
|
268
268
|
let i;
|
|
269
269
|
try {
|
|
270
|
-
i = ti.
|
|
270
|
+
i = ti.zn(n).qn;
|
|
271
271
|
} catch (t) {
|
|
272
272
|
i = null;
|
|
273
273
|
}
|
|
@@ -291,31 +291,31 @@ export default class na {
|
|
|
291
291
|
: N.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.vn(r, e, o, i, t))
|
|
295
295
|
: r.expirationTime &&
|
|
296
296
|
new Date(r.expirationTime).valueOf() <=
|
|
297
297
|
new Date().valueOf()
|
|
298
298
|
? (N.info(
|
|
299
299
|
"Push subscription is expired, creating new subscription.",
|
|
300
300
|
),
|
|
301
|
-
this.
|
|
302
|
-
: n &&
|
|
303
|
-
? this.
|
|
301
|
+
this.vn(r, e, o, i, t))
|
|
302
|
+
: n && D(n)
|
|
303
|
+
? this.vn(r, e, o, i, t)
|
|
304
304
|
: null == a
|
|
305
305
|
? (N.info(
|
|
306
306
|
"No push subscription creation date found, creating new subscription.",
|
|
307
307
|
),
|
|
308
|
-
this.
|
|
308
|
+
this.vn(r, e, o, i, t))
|
|
309
309
|
: a.valueOf() <= new Date().valueOf()
|
|
310
310
|
? (N.info(
|
|
311
311
|
"Push subscription older than 6 months, creating new subscription.",
|
|
312
312
|
),
|
|
313
|
-
this.
|
|
313
|
+
this.vn(r, e, o, i, t))
|
|
314
314
|
: (N.info(
|
|
315
315
|
"Device already subscribed to push, sending existing subscription to backend.",
|
|
316
316
|
),
|
|
317
|
-
this.
|
|
318
|
-
} else this.
|
|
317
|
+
this.kn(r, u, i));
|
|
318
|
+
} else this.wn(e, o, i, t);
|
|
319
319
|
})
|
|
320
320
|
.catch((i) => {
|
|
321
321
|
N.error("Error checking current push subscriptions: " + i);
|
|
@@ -326,29 +326,29 @@ export default class na {
|
|
|
326
326
|
});
|
|
327
327
|
};
|
|
328
328
|
this.requestPermission(o, r, e);
|
|
329
|
-
} else if (this.
|
|
330
|
-
if (null == this.
|
|
329
|
+
} else if (this.yn) {
|
|
330
|
+
if (null == this.cn || "" === this.cn)
|
|
331
331
|
return (
|
|
332
332
|
N.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.cn);
|
|
338
|
+
this.xn(this.cn, e, i, t);
|
|
339
339
|
}
|
|
340
340
|
}
|
|
341
341
|
unsubscribe(i, t) {
|
|
342
|
-
if (!
|
|
343
|
-
return N.info(na.
|
|
344
|
-
this.
|
|
345
|
-
? navigator.serviceWorker.getRegistration(this.
|
|
342
|
+
if (!yt.isPushSupported())
|
|
343
|
+
return N.info(na.Wn), void ("function" == typeof t && t());
|
|
344
|
+
this.pn
|
|
345
|
+
? navigator.serviceWorker.getRegistration(this.an).then((e) => {
|
|
346
346
|
e
|
|
347
347
|
? e.pushManager
|
|
348
348
|
.getSubscription()
|
|
349
349
|
.then((s) => {
|
|
350
350
|
s
|
|
351
|
-
? (this.
|
|
351
|
+
? (this.Sn(),
|
|
352
352
|
s
|
|
353
353
|
.unsubscribe()
|
|
354
354
|
.then((s) => {
|
|
@@ -361,7 +361,7 @@ export default class na {
|
|
|
361
361
|
"Failed to unsubscribe device from push.",
|
|
362
362
|
),
|
|
363
363
|
"function" == typeof t && t()),
|
|
364
|
-
this.
|
|
364
|
+
this.Un(e);
|
|
365
365
|
})
|
|
366
366
|
.catch((i) => {
|
|
367
367
|
N.error("Push unsubscription error: " + i),
|
|
@@ -377,10 +377,10 @@ export default class na {
|
|
|
377
377
|
: (N.info("Device already unsubscribed from push."),
|
|
378
378
|
"function" == typeof i && i());
|
|
379
379
|
})
|
|
380
|
-
: this.
|
|
381
|
-
(this.
|
|
380
|
+
: this.yn &&
|
|
381
|
+
(this.Sn(),
|
|
382
382
|
N.info("Device unsubscribed from push."),
|
|
383
383
|
"function" == typeof i && i());
|
|
384
384
|
}
|
|
385
385
|
}
|
|
386
|
-
na.
|
|
386
|
+
na.Wn = "Push notifications are not supported in this browser.";
|