@braze/web-sdk 5.7.0 → 5.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +4 -4
- package/package.json +1 -1
- package/shared-lib/encoding-utils.js +1 -1
- package/shared-lib/event-types.js +23 -23
- package/shared-lib/guid.js +1 -1
- package/shared-lib/indexed-db-adapter.js +21 -21
- package/shared-lib/logger.js +2 -2
- package/shared-lib/supported-options.js +18 -18
- package/src/Banner/banner-provider.js +79 -79
- package/src/Banner/banner.js +9 -9
- package/src/Banner/display/banner-to-html.js +2 -2
- package/src/Banner/get-all-banners.js +3 -4
- package/src/Banner/get-banner.js +11 -11
- package/src/Banner/log-banner-click.js +2 -2
- package/src/Banner/log-banner-impressions.js +4 -4
- package/src/Banner/request-banners-refresh.js +21 -13
- package/src/Banner/subscribe-to-banners-updates.js +14 -13
- package/src/Banner/ui/insert-banner.js +11 -9
- package/src/Card/card-manager.js +35 -35
- package/src/Card/display/card-display.js +8 -8
- package/src/Card/log-card-click.js +1 -1
- package/src/Card/log-card-dismissal.js +1 -1
- package/src/Card/log-card-impressions.js +3 -3
- package/src/Card/models/captioned-image.js +21 -21
- package/src/Card/models/card.js +92 -92
- 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 +19 -19
- package/src/Card/util/card-factory.js +39 -39
- package/src/ContentCards/content-cards-provider-factory.js +1 -1
- package/src/ContentCards/content-cards-provider.js +142 -142
- package/src/ContentCards/content-cards.js +3 -3
- package/src/ContentCards/get-cached-content-cards.js +1 -1
- package/src/ContentCards/request-content-cards-refresh.js +1 -1
- package/src/ContentCards/subscribe-to-content-cards-updates.js +4 -4
- package/src/ContentCards/ui/show-content-cards.js +8 -8
- package/src/Core/add-sdk-metadata.js +2 -2
- package/src/Core/change-user.js +3 -3
- package/src/Core/disable-sdk.js +7 -7
- package/src/Core/enable-sdk.js +5 -5
- package/src/Core/get-device-id.js +2 -2
- package/src/Core/get-user.js +1 -1
- package/src/Core/handle-braze-action.js +2 -2
- package/src/Core/is-disabled.js +2 -2
- package/src/Core/is-initialized.js +1 -1
- package/src/Core/log-custom-event.js +5 -5
- package/src/Core/log-purchase.js +4 -4
- package/src/Core/open-session.js +7 -7
- package/src/Core/wipe-data.js +3 -3
- package/src/FeatureFlags/feature-flag-factory.js +10 -10
- package/src/FeatureFlags/feature-flag.js +19 -19
- package/src/FeatureFlags/feature-flags-provider.js +61 -61
- package/src/FeatureFlags/get-all-feature-flags.js +6 -7
- package/src/FeatureFlags/get-feature-flag.js +5 -6
- package/src/FeatureFlags/log-feature-flag-impression.js +4 -4
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +2 -2
- package/src/Feed/feed-provider.js +41 -41
- package/src/Feed/feed.js +2 -2
- package/src/Feed/get-cached-feed.js +1 -1
- package/src/Feed/log-feed-displayed.js +1 -1
- package/src/Feed/request-feed-refresh.js +1 -1
- package/src/Feed/subscribe-to-feed-updates.js +1 -1
- package/src/Feed/ui/show-feed.js +5 -5
- package/src/InAppMessage/defer-in-app-message.js +1 -1
- package/src/InAppMessage/display/html-message-to-html.js +6 -6
- package/src/InAppMessage/display/in-app-message-to-html.js +20 -20
- package/src/InAppMessage/display/modal-utils.js +4 -4
- package/src/InAppMessage/in-app-message-factory.js +7 -7
- package/src/InAppMessage/in-app-message-manager-factory.js +1 -1
- package/src/InAppMessage/in-app-message-manager.js +89 -89
- package/src/InAppMessage/log-in-app-message-button-click.js +6 -6
- package/src/InAppMessage/log-in-app-message-click.js +5 -5
- package/src/InAppMessage/log-in-app-message-html-click.js +7 -7
- package/src/InAppMessage/log-in-app-message-impression.js +2 -2
- package/src/InAppMessage/models/control-message.js +5 -5
- package/src/InAppMessage/models/full-screen-message.js +34 -34
- package/src/InAppMessage/models/html-message.js +20 -20
- package/src/InAppMessage/models/in-app-message-button.js +8 -8
- package/src/InAppMessage/models/in-app-message.js +83 -83
- package/src/InAppMessage/models/modal-message.js +33 -33
- package/src/InAppMessage/models/slide-up-message.js +30 -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 +19 -19
- package/src/Push/push-manager-factory.js +8 -8
- package/src/Push/push-manager.js +96 -96
- package/src/Push/utils/push-utils.js +4 -4
- package/src/User/user-manager.js +19 -19
- package/src/User/user.js +41 -41
- package/src/common/base-feed.js +3 -3
- package/src/common/base-provider.js +1 -1
- package/src/common/event-logger.js +6 -6
- package/src/common/feed-display.js +10 -10
- package/src/l10n/l10n-manager-factory.js +2 -2
- package/src/l10n/l10n-manager.js +1 -1
- package/src/managers/auth-manager.js +31 -31
- package/src/managers/braze-instance.js +139 -139
- package/src/managers/device-manager.js +24 -24
- package/src/managers/network-manager.js +151 -151
- package/src/managers/server-config-manager.js +86 -86
- package/src/managers/session-manager.js +38 -38
- package/src/managers/storage-manager-factory.js +12 -12
- package/src/managers/storage-manager.js +96 -96
- package/src/managers/subscription-manager.js +10 -10
- package/src/managers/utils.js +4 -4
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +4 -4
- package/src/models/device.js +2 -2
- package/src/models/identifier.js +12 -12
- package/src/models/push-token.js +8 -8
- package/src/models/request-result.js +3 -3
- package/src/models/server-config.js +31 -31
- package/src/request-controller.js +152 -152
- 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 +2 -2
- 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 +33 -33
- package/src/triggers/models/trigger-events.js +3 -3
- package/src/triggers/models/trigger.js +11 -11
- package/src/triggers/triggers-provider-factory.js +3 -3
- package/src/triggers/triggers-provider.js +74 -74
- package/src/ui/js/attach-css.js +3 -3
- package/src/ui/js/load-font-awesome.js +2 -2
- package/src/util/base-device-parser.js +3 -3
- package/src/util/braze-actions.js +4 -4
- package/src/util/browser-detector.js +5 -5
- package/src/util/client-hints-parser.js +1 -1
- package/src/util/component-utils.js +1 -1
- package/src/util/dom-utils.js +7 -7
- package/src/util/html-display-utils.js +6 -6
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +6 -6
- package/src/util/request-header-utils.js +21 -21
- package/src/util/user-agent-parser.js +1 -1
- package/src/util/validation-utils.js +4 -4
- package/src/util/window-utils.js +1 -1
|
@@ -59,51 +59,51 @@ export default class SlideUpMessage extends InAppMessage {
|
|
|
59
59
|
M,
|
|
60
60
|
b,
|
|
61
61
|
),
|
|
62
|
-
(this.
|
|
62
|
+
(this.Co = InAppMessage.TextAlignment.START);
|
|
63
63
|
}
|
|
64
|
-
|
|
64
|
+
wo() {
|
|
65
65
|
return !1;
|
|
66
66
|
}
|
|
67
|
-
|
|
67
|
+
Mo() {
|
|
68
68
|
const e = document.createElement("span");
|
|
69
69
|
return e.appendChild(document.createTextNode(this.message || "")), e;
|
|
70
70
|
}
|
|
71
71
|
Ah(e) {
|
|
72
72
|
const t = e.getElementsByClassName("ab-in-app-message")[0];
|
|
73
|
-
ue.
|
|
73
|
+
ue.Ho(t, !0, !0) ||
|
|
74
74
|
(this.slideFrom === InAppMessage.SlideFrom.TOP
|
|
75
75
|
? (t.style.top = "0px")
|
|
76
76
|
: (t.style.bottom = "0px")),
|
|
77
77
|
super.Ah(e);
|
|
78
78
|
}
|
|
79
|
-
|
|
80
|
-
return super.
|
|
79
|
+
bt() {
|
|
80
|
+
return super.bt(SlideUpMessage.ds);
|
|
81
81
|
}
|
|
82
|
-
static
|
|
82
|
+
static Ur(e) {
|
|
83
83
|
return new SlideUpMessage(
|
|
84
|
-
e[InAppMessage.
|
|
85
|
-
e[InAppMessage.
|
|
86
|
-
e[InAppMessage.
|
|
87
|
-
e[InAppMessage.
|
|
88
|
-
e[InAppMessage.
|
|
89
|
-
e[InAppMessage.
|
|
90
|
-
e[InAppMessage.
|
|
91
|
-
e[InAppMessage.
|
|
92
|
-
e[InAppMessage.
|
|
93
|
-
e[InAppMessage.
|
|
94
|
-
e[InAppMessage.
|
|
95
|
-
e[InAppMessage.
|
|
96
|
-
e[InAppMessage.
|
|
97
|
-
e[InAppMessage.
|
|
98
|
-
e[InAppMessage.
|
|
99
|
-
e[InAppMessage.
|
|
100
|
-
e[InAppMessage.
|
|
101
|
-
e[InAppMessage.
|
|
102
|
-
e[InAppMessage.
|
|
103
|
-
e[InAppMessage.
|
|
104
|
-
e[InAppMessage.
|
|
105
|
-
e[InAppMessage.
|
|
84
|
+
e[InAppMessage.es.ra],
|
|
85
|
+
e[InAppMessage.es.sa],
|
|
86
|
+
e[InAppMessage.es.Sh],
|
|
87
|
+
e[InAppMessage.es.vs],
|
|
88
|
+
e[InAppMessage.es.ta],
|
|
89
|
+
e[InAppMessage.es.ia],
|
|
90
|
+
e[InAppMessage.es.URI],
|
|
91
|
+
e[InAppMessage.es.oa],
|
|
92
|
+
e[InAppMessage.es.pa],
|
|
93
|
+
e[InAppMessage.es.ma],
|
|
94
|
+
e[InAppMessage.es.na],
|
|
95
|
+
e[InAppMessage.es.fs],
|
|
96
|
+
e[InAppMessage.es.ca],
|
|
97
|
+
e[InAppMessage.es.fa],
|
|
98
|
+
e[InAppMessage.es.da],
|
|
99
|
+
e[InAppMessage.es.la],
|
|
100
|
+
e[InAppMessage.es.ga],
|
|
101
|
+
e[InAppMessage.es.ja],
|
|
102
|
+
e[InAppMessage.es.xa],
|
|
103
|
+
e[InAppMessage.es.ka],
|
|
104
|
+
e[InAppMessage.es.CSS],
|
|
105
|
+
e[InAppMessage.es.qa],
|
|
106
106
|
);
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
|
-
SlideUpMessage.
|
|
109
|
+
SlideUpMessage.ds = InAppMessage.po.Yr;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
export default class wt {
|
|
2
2
|
constructor(t, s, i, h, l) {
|
|
3
3
|
(this.triggerId = t),
|
|
4
|
-
(this.
|
|
5
|
-
(this.
|
|
6
|
-
(this.
|
|
7
|
-
(this.
|
|
4
|
+
(this.Hr = s),
|
|
5
|
+
(this.Cr = i),
|
|
6
|
+
(this.Jr = h),
|
|
7
|
+
(this.Kr = l),
|
|
8
8
|
(this.triggerId = t),
|
|
9
|
-
(this.
|
|
10
|
-
(this.
|
|
11
|
-
(this.
|
|
12
|
-
(this.
|
|
9
|
+
(this.Hr = s),
|
|
10
|
+
(this.Cr = i),
|
|
11
|
+
(this.Jr = h),
|
|
12
|
+
(this.Kr = l);
|
|
13
13
|
}
|
|
14
14
|
static fromJson(t, s, i, h, l) {
|
|
15
15
|
return null == t || null == t.trigger_id
|
|
@@ -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.Ji()) {
|
|
11
11
|
const r = subscribeToInAppMessage((s) => showInAppMessage(s));
|
|
12
|
-
s.
|
|
12
|
+
s.Ki(r);
|
|
13
13
|
}
|
|
14
|
-
return s.
|
|
14
|
+
return s.Ji();
|
|
15
15
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import r, { OPTIONS as
|
|
1
|
+
import r, { OPTIONS as w } 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";
|
|
@@ -33,14 +33,14 @@ export function showInAppMessage(e, t, o) {
|
|
|
33
33
|
if (e.constructor === InAppMessage) return !1;
|
|
34
34
|
e.Lh();
|
|
35
35
|
const s = e instanceof HtmlMessage;
|
|
36
|
-
if (s && !e.trusted && !r.
|
|
36
|
+
if (s && !e.trusted && !r.tr())
|
|
37
37
|
return (
|
|
38
38
|
N.error(
|
|
39
39
|
'HTML in-app messages are disabled. Use the "allowUserSuppliedJavascript" option for braze.initialize to enable these messages.',
|
|
40
40
|
),
|
|
41
41
|
!1
|
|
42
42
|
);
|
|
43
|
-
if ((null == t && (t = document.body), e.
|
|
43
|
+
if ((null == t && (t = document.body), e.wo())) {
|
|
44
44
|
if (t.querySelectorAll(".ab-modal-interactions").length > 0)
|
|
45
45
|
return (
|
|
46
46
|
N.info(
|
|
@@ -70,7 +70,7 @@ export function showInAppMessage(e, t, o) {
|
|
|
70
70
|
);
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
if (!r.
|
|
73
|
+
if (!r.tr()) {
|
|
74
74
|
let t = !1;
|
|
75
75
|
if (e.buttons && e.buttons.length > 0) {
|
|
76
76
|
const o = e.buttons;
|
|
@@ -93,15 +93,15 @@ export function showInAppMessage(e, t, o) {
|
|
|
93
93
|
((i.className = "ab-iam-root v3"),
|
|
94
94
|
(i.className += me(e)),
|
|
95
95
|
i.setAttribute("role", "complementary"),
|
|
96
|
-
e.
|
|
97
|
-
r.
|
|
96
|
+
e.bo() && (i.id = e.htmlId),
|
|
97
|
+
r.ee(w.No) && (i.style.zIndex = (r.ee(w.No) + 1).toString()),
|
|
98
98
|
t.appendChild(i),
|
|
99
|
-
e.
|
|
99
|
+
e.lo())
|
|
100
100
|
) {
|
|
101
101
|
const t = document.createElement("style");
|
|
102
102
|
(t.innerHTML = e.css),
|
|
103
|
-
(t.id = e.
|
|
104
|
-
null != r.
|
|
103
|
+
(t.id = e.do()),
|
|
104
|
+
null != r.ee(w.er) && t.setAttribute("nonce", r.ee(w.er)),
|
|
105
105
|
document.getElementsByTagName("head")[0].appendChild(t);
|
|
106
106
|
}
|
|
107
107
|
const n = e instanceof SlideUpMessage,
|
|
@@ -109,18 +109,18 @@ export function showInAppMessage(e, t, o) {
|
|
|
109
109
|
e,
|
|
110
110
|
() => {
|
|
111
111
|
import("../../Feed/ui/show-feed.js").then((e) => {
|
|
112
|
-
r.
|
|
112
|
+
r._t() ? e.showFeed() : N.error(p);
|
|
113
113
|
});
|
|
114
114
|
},
|
|
115
115
|
(t) => {
|
|
116
|
-
if (e.
|
|
116
|
+
if (e.wo() && e.Po()) {
|
|
117
117
|
const o = document.createElement("div");
|
|
118
118
|
if (
|
|
119
119
|
((o.className = "ab-page-blocker"),
|
|
120
|
-
e.
|
|
121
|
-
r.
|
|
120
|
+
e.lo() || (o.style.backgroundColor = le(e.frameColor)),
|
|
121
|
+
r.ee(w.No) && (o.style.zIndex = r.ee(w.No).toString()),
|
|
122
122
|
i.appendChild(o),
|
|
123
|
-
!r.
|
|
123
|
+
!r.ee(w.mh))
|
|
124
124
|
) {
|
|
125
125
|
const s = new Date().valueOf();
|
|
126
126
|
o.onclick = (o) => {
|
|
@@ -149,7 +149,7 @@ export function showInAppMessage(e, t, o) {
|
|
|
149
149
|
s.offsetTop),
|
|
150
150
|
(t.style.bottom = Math.max(e, 0) + "px");
|
|
151
151
|
}
|
|
152
|
-
} else if (s && !r.
|
|
152
|
+
} else if (s && !r.ee(w.mh)) {
|
|
153
153
|
const o = e;
|
|
154
154
|
It(t) &&
|
|
155
155
|
t.contentWindow &&
|
|
@@ -167,11 +167,11 @@ export function showInAppMessage(e, t, o) {
|
|
|
167
167
|
(e) => {
|
|
168
168
|
N.info(e);
|
|
169
169
|
},
|
|
170
|
-
r.
|
|
171
|
-
r.
|
|
172
|
-
r.
|
|
170
|
+
r.ee(w.Ko),
|
|
171
|
+
r.ee(w.No),
|
|
172
|
+
r.ee(w.er),
|
|
173
173
|
t,
|
|
174
|
-
ge.ea().
|
|
174
|
+
ge.ea().Oo(),
|
|
175
175
|
);
|
|
176
176
|
return (s || n) && (i.appendChild(a), e.Ah(i)), !0;
|
|
177
177
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import r, { OPTIONS as
|
|
1
|
+
import r, { OPTIONS as w } 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.
|
|
10
|
+
r.mr(),
|
|
11
11
|
r.Ma(),
|
|
12
|
-
r.
|
|
12
|
+
r.ue(),
|
|
13
13
|
r.Z(),
|
|
14
|
-
r.
|
|
15
|
-
r.
|
|
16
|
-
r.
|
|
14
|
+
r.ee(w._a),
|
|
15
|
+
r.ee(w.Aa),
|
|
16
|
+
r.ee(w.Ba),
|
|
17
17
|
r.v(),
|
|
18
|
-
r.
|
|
19
|
-
r.
|
|
18
|
+
r.ee(w.Ca),
|
|
19
|
+
r.ee(w.Da),
|
|
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 z, 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
|
-
import { STORAGE_KEYS as
|
|
4
|
+
import { STORAGE_KEYS as s } from "../managers/storage-manager.js";
|
|
5
5
|
import { User } from "../User/index.js";
|
|
6
6
|
import vt 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.on = i),
|
|
11
|
+
(this.un = t),
|
|
12
|
+
(this.an = e),
|
|
13
|
+
(this.hn = r),
|
|
14
|
+
(this.cn = n),
|
|
15
|
+
(this.fn = o),
|
|
16
16
|
(this.B = u),
|
|
17
|
-
(this.
|
|
18
|
-
(this.
|
|
17
|
+
(this.ln = a),
|
|
18
|
+
(this.dn = h),
|
|
19
19
|
(this.C = c),
|
|
20
|
-
(this.
|
|
21
|
-
(this.
|
|
22
|
-
(this.
|
|
23
|
-
(this.
|
|
24
|
-
(this.
|
|
25
|
-
(this.
|
|
20
|
+
(this.on = i),
|
|
21
|
+
(this.un = t),
|
|
22
|
+
(this.an = e),
|
|
23
|
+
(this.pn = s + "/safari/" + t),
|
|
24
|
+
(this.hn = r || "/service-worker.js"),
|
|
25
|
+
(this.fn = o),
|
|
26
26
|
(this.B = u),
|
|
27
|
-
(this.
|
|
28
|
-
(this.
|
|
27
|
+
(this.ln = a || !1),
|
|
28
|
+
(this.dn = h || !1),
|
|
29
29
|
(this.C = c),
|
|
30
|
-
(this.
|
|
31
|
-
(this.
|
|
30
|
+
(this.bn = vt.yn()),
|
|
31
|
+
(this.mn = vt.gn());
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
return this.
|
|
33
|
+
vn() {
|
|
34
|
+
return this.dn;
|
|
35
35
|
}
|
|
36
|
-
|
|
36
|
+
wn(i, t, e, s, r) {
|
|
37
37
|
i.unsubscribe()
|
|
38
38
|
.then((i) => {
|
|
39
39
|
i
|
|
40
|
-
? this.
|
|
40
|
+
? this.kn(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
|
+
Pn(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.Dn &&
|
|
59
|
+
-1 === i.endpoint.indexOf(e.Dn) &&
|
|
60
|
+
(t = i.endpoint + "/" + e.Dn),
|
|
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.on) || void 0 === s || s.Sn(r, t, n, o, a),
|
|
88
88
|
r && "function" == typeof e && e(r, n, o);
|
|
89
89
|
}
|
|
90
|
-
|
|
90
|
+
An() {
|
|
91
91
|
var i;
|
|
92
|
-
null === (i = this.
|
|
92
|
+
null === (i = this.on) || void 0 === i || i.jn(!0);
|
|
93
93
|
}
|
|
94
|
-
|
|
94
|
+
xn(i, t) {
|
|
95
95
|
var e;
|
|
96
|
-
null === (e = this.
|
|
96
|
+
null === (e = this.on) || void 0 === e || e.jn(!1),
|
|
97
97
|
N.info(i),
|
|
98
98
|
"function" == typeof t && t(!1);
|
|
99
99
|
}
|
|
100
|
-
|
|
100
|
+
Nn(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.pn,
|
|
106
106
|
i,
|
|
107
107
|
{
|
|
108
|
-
api_key: this.
|
|
108
|
+
api_key: this.un,
|
|
109
109
|
device_id:
|
|
110
|
-
(null === (r = this.
|
|
110
|
+
(null === (r = this.an) || 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.on &&
|
|
116
|
+
this.on.setPushNotificationSubscriptionType(
|
|
117
117
|
User.NotificationSubscriptionTypes.OPTED_IN,
|
|
118
118
|
),
|
|
119
|
-
this.
|
|
119
|
+
this.Nn(i, t, e, s);
|
|
120
120
|
},
|
|
121
121
|
);
|
|
122
122
|
} catch (i) {
|
|
123
|
-
this.
|
|
123
|
+
this.xn("Could not request permission for push: " + i, s);
|
|
124
124
|
}
|
|
125
125
|
else
|
|
126
126
|
"denied" === t.permission
|
|
127
|
-
? this.
|
|
127
|
+
? this.xn(
|
|
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.Pn(t.deviceToken, new Date(), e));
|
|
134
134
|
}
|
|
135
135
|
requestPermission(i, t, e) {
|
|
136
136
|
const s = (s) => {
|
|
@@ -159,14 +159,14 @@ export default class na {
|
|
|
159
159
|
: (r = !0);
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
|
-
|
|
162
|
+
kn(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.Pn(i, new Date(), e);
|
|
170
170
|
})
|
|
171
171
|
.catch((i) => {
|
|
172
172
|
vt.isPushBlocked()
|
|
@@ -176,10 +176,10 @@ export default class na {
|
|
|
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
|
+
Un() {
|
|
180
|
+
if (this.ln) return navigator.serviceWorker.getRegistration(this.hn);
|
|
181
|
+
const i = this.cn ? { scope: this.cn } : void 0;
|
|
182
|
+
return navigator.serviceWorker.register(this.hn, i).then(() =>
|
|
183
183
|
navigator.serviceWorker.ready.then(
|
|
184
184
|
(i) => (
|
|
185
185
|
i &&
|
|
@@ -192,38 +192,38 @@ export default class na {
|
|
|
192
192
|
),
|
|
193
193
|
);
|
|
194
194
|
}
|
|
195
|
-
|
|
196
|
-
this.
|
|
195
|
+
Wn(i) {
|
|
196
|
+
this.ln ||
|
|
197
197
|
(i.unregister(), N.info("Service worker successfully unregistered."));
|
|
198
198
|
}
|
|
199
|
-
subscribe(i,
|
|
199
|
+
subscribe(i, t) {
|
|
200
200
|
if (!vt.isPushSupported())
|
|
201
|
-
return N.info(na.
|
|
202
|
-
if (this.
|
|
203
|
-
if (!this.
|
|
204
|
-
let i = this.
|
|
201
|
+
return N.info(na._n), void ("function" == typeof t && t(!1));
|
|
202
|
+
if (this.bn) {
|
|
203
|
+
if (!this.ln && null != window.location) {
|
|
204
|
+
let i = this.hn;
|
|
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 (vt.isPushBlocked())
|
|
211
|
-
return void this.
|
|
211
|
+
return void this.xn(
|
|
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.Tn() && 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.
|
|
221
|
-
this.subscribe(i,
|
|
220
|
+
void this.B.In(() => {
|
|
221
|
+
this.subscribe(i, t);
|
|
222
222
|
})
|
|
223
223
|
);
|
|
224
|
-
const
|
|
224
|
+
const e = () => {
|
|
225
225
|
N.info("Permission for push notifications was denied."),
|
|
226
|
-
"function" == typeof
|
|
226
|
+
"function" == typeof t && t(!1);
|
|
227
227
|
},
|
|
228
228
|
r = () => {
|
|
229
229
|
let i = "Permission for push notifications was ignored.";
|
|
@@ -231,25 +231,25 @@ export default class na {
|
|
|
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
|
-
"function" == typeof
|
|
234
|
+
"function" == typeof t && t(!0);
|
|
235
235
|
},
|
|
236
236
|
n = vt.isPushPermissionGranted(),
|
|
237
237
|
o = () => {
|
|
238
238
|
!n &&
|
|
239
|
-
this.
|
|
240
|
-
this.
|
|
239
|
+
this.on &&
|
|
240
|
+
this.on.setPushNotificationSubscriptionType(
|
|
241
241
|
User.NotificationSubscriptionTypes.OPTED_IN,
|
|
242
242
|
),
|
|
243
|
-
this.
|
|
244
|
-
.then((
|
|
245
|
-
if (null ==
|
|
243
|
+
this.Un()
|
|
244
|
+
.then((e) => {
|
|
245
|
+
if (null == e)
|
|
246
246
|
return (
|
|
247
247
|
N.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
|
-
void ("function" == typeof
|
|
250
|
+
void ("function" == typeof t && t(!0))
|
|
251
251
|
);
|
|
252
|
-
|
|
252
|
+
e.pushManager
|
|
253
253
|
.getSubscription()
|
|
254
254
|
.then((r) => {
|
|
255
255
|
var n;
|
|
@@ -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.Tn()) && (o = ei.Vn(this.B.Tn())),
|
|
262
262
|
r)
|
|
263
263
|
) {
|
|
264
264
|
let n,
|
|
265
265
|
u = null,
|
|
266
266
|
a = null;
|
|
267
|
-
if ((this.C && (n = this.C.
|
|
267
|
+
if ((this.C && (n = this.C.ft(s.gt.qn)), n && !z(n))) {
|
|
268
268
|
let i;
|
|
269
269
|
try {
|
|
270
|
-
i = ti.
|
|
270
|
+
i = ti.En(n).zn;
|
|
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.wn(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.wn(r, e, o, i, t))
|
|
302
|
+
: n && z(n)
|
|
303
|
+
? this.wn(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.wn(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.wn(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.Pn(r, u, i));
|
|
318
|
+
} else this.kn(e, o, i, t);
|
|
319
319
|
})
|
|
320
320
|
.catch((i) => {
|
|
321
321
|
N.error("Error checking current push subscriptions: " + i);
|
|
@@ -325,30 +325,30 @@ export default class na {
|
|
|
325
325
|
N.error("ServiceWorker registration failed: " + i);
|
|
326
326
|
});
|
|
327
327
|
};
|
|
328
|
-
this.requestPermission(o, r,
|
|
329
|
-
} else if (this.
|
|
330
|
-
if (null == this.
|
|
328
|
+
this.requestPermission(o, r, e);
|
|
329
|
+
} else if (this.mn) {
|
|
330
|
+
if (null == this.fn || "" === this.fn)
|
|
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
|
-
void ("function" == typeof
|
|
335
|
+
void ("function" == typeof t && t(!0))
|
|
336
336
|
);
|
|
337
|
-
const
|
|
338
|
-
this.
|
|
337
|
+
const e = window.safari.pushNotification.permission(this.fn);
|
|
338
|
+
this.Nn(this.fn, e, i, t);
|
|
339
339
|
}
|
|
340
340
|
}
|
|
341
341
|
unsubscribe(i, t) {
|
|
342
342
|
if (!vt.isPushSupported())
|
|
343
|
-
return N.info(na.
|
|
344
|
-
this.
|
|
345
|
-
? navigator.serviceWorker.getRegistration(this.
|
|
343
|
+
return N.info(na._n), void ("function" == typeof t && t());
|
|
344
|
+
this.bn
|
|
345
|
+
? navigator.serviceWorker.getRegistration(this.hn).then((e) => {
|
|
346
346
|
e
|
|
347
347
|
? e.pushManager
|
|
348
348
|
.getSubscription()
|
|
349
349
|
.then((s) => {
|
|
350
350
|
s
|
|
351
|
-
? (this.
|
|
351
|
+
? (this.An(),
|
|
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.Wn(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.mn &&
|
|
381
|
+
(this.An(),
|
|
382
382
|
N.info("Device unsubscribed from push."),
|
|
383
383
|
"function" == typeof i && i());
|
|
384
384
|
}
|
|
385
385
|
}
|
|
386
|
-
na.
|
|
386
|
+
na._n = "Push notifications are not supported in this browser.";
|