@braze/web-sdk 6.3.1 → 6.4.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 +35 -3
- 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 +2 -2
- package/shared-lib/indexed-db-adapter.js +7 -7
- package/shared-lib/logger.js +2 -2
- package/shared-lib/supported-options.js +22 -21
- package/src/Banner/display/banner-to-html.js +2 -2
- package/src/Banner/display/detect-banner-impressions.js +7 -7
- package/src/Banner/index.js +2 -0
- package/src/Banner/request-banners-refresh.js +6 -6
- package/src/Banner/ui/insert-banner.js +4 -4
- package/src/Card/card-manager-factory.js +5 -5
- package/src/Card/card-manager.js +4 -4
- package/src/Card/display/card-display.js +7 -7
- package/src/Card/log-card-dismissal.js +3 -3
- package/src/Card/log-content-card-click.js +3 -3
- package/src/Card/log-content-card-impressions.js +6 -6
- package/src/Card/models/card.js +7 -7
- package/src/Card/util/card-factory.js +6 -6
- package/src/ContentCards/content-cards-provider-factory.js +14 -10
- package/src/ContentCards/content-cards-provider.js +28 -28
- package/src/ContentCards/content-cards.js +4 -4
- 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 +3 -3
- 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 +5 -5
- package/src/Core/disable-sdk.js +3 -3
- package/src/Core/enable-sdk.js +3 -3
- package/src/Core/get-user.js +1 -1
- package/src/Core/is-disabled.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 +11 -11
- package/src/Core/set-sdk-authentication-signature.js +2 -2
- package/src/Core/wipe-data.js +5 -5
- package/src/DUST/dust-provider-factory.js +20 -0
- package/src/DUST/dust-provider.js +288 -0
- package/src/DUST/index.js +3 -0
- package/src/DUST/subscribe-to-dust.js +24 -0
- package/src/DUST/types.js +1 -0
- package/src/FeatureFlags/feature-flags-provider-factory.js +9 -9
- package/src/FeatureFlags/feature-flags-provider.js +38 -38
- package/src/FeatureFlags/get-all-feature-flags.js +3 -3
- package/src/FeatureFlags/get-feature-flag.js +3 -3
- package/src/FeatureFlags/log-feature-flag-impression.js +5 -5
- package/src/FeatureFlags/refresh-feature-flags.js +5 -5
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +3 -3
- package/src/InAppMessage/defer-in-app-message.js +1 -1
- package/src/InAppMessage/display/html-message-to-html.js +5 -5
- package/src/InAppMessage/display/in-app-message-to-html.js +22 -22
- package/src/InAppMessage/display/modal-utils.js +5 -5
- package/src/InAppMessage/get-deferred-in-app-message.js +1 -1
- package/src/InAppMessage/in-app-message-factory.js +4 -4
- package/src/InAppMessage/in-app-message-manager.js +80 -80
- 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 +1 -1
- package/src/InAppMessage/models/full-screen-message.js +12 -12
- package/src/InAppMessage/models/html-message.js +14 -14
- package/src/InAppMessage/models/in-app-message-button.js +4 -4
- package/src/InAppMessage/models/in-app-message.js +119 -121
- package/src/InAppMessage/models/modal-message.js +12 -12
- package/src/InAppMessage/models/slide-up-message.js +21 -21
- 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/remove-all-visible-in-app-messages.js +18 -0
- package/src/InAppMessage/ui/show-in-app-message.js +24 -24
- 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/utils/push-utils.js +17 -17
- package/src/User/user-manager.js +12 -12
- package/src/User/user.js +48 -48
- package/src/common/constants.js +1 -0
- package/src/common/content-cards-display.js +20 -20
- package/src/common/event-logger.js +4 -4
- package/src/common/properties-base.js +16 -16
- package/src/l10n/l10n-manager-factory.js +2 -2
- package/src/l10n/l10n-manager.js +1 -1
- package/src/managers/auth-manager.js +29 -29
- package/src/managers/braze-instance.js +141 -133
- package/src/managers/device-manager.js +18 -18
- package/src/managers/network-manager.js +139 -139
- package/src/managers/server-config-manager.js +99 -82
- package/src/managers/session-manager.js +32 -32
- package/src/managers/storage-manager-factory.js +8 -8
- package/src/managers/storage-manager.js +76 -74
- package/src/managers/subscription-manager.js +10 -10
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +9 -9
- package/src/models/device.js +2 -2
- package/src/models/identifier.js +12 -12
- package/src/models/push-token.js +12 -12
- package/src/models/request-result.js +1 -1
- package/src/models/server-config.js +38 -34
- package/src/request-controller.js +136 -134
- package/src/triggers/models/custom-event-data.js +4 -4
- package/src/triggers/models/custom-event-property-data.js +5 -5
- package/src/triggers/models/filter-set.js +8 -8
- package/src/triggers/models/filter.js +30 -30
- 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 +36 -36
- package/src/triggers/models/trigger-events.js +2 -2
- package/src/triggers/models/trigger.js +15 -15
- package/src/triggers/triggers-provider-factory.js +3 -3
- package/src/triggers/triggers-provider.js +25 -25
- 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 +3 -3
- package/src/util/browser-detector.js +13 -13
- package/src/util/client-hints-parser.js +6 -6
- package/src/util/component-utils.js +1 -1
- package/src/util/dom-utils.js +10 -10
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +1 -1
- package/src/util/request-header-utils.js +22 -22
- package/src/util/user-agent-parser.js +14 -14
- package/src/util/validation-utils.js +9 -9
- package/src/util/window-utils.js +1 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { PAUSE_SCROLLING_CLASS as It } from "../../common/constants.js";
|
|
2
|
+
export function removeAllVisibleInAppMessages() {
|
|
3
|
+
const o = document.querySelectorAll(".ab-iam-root");
|
|
4
|
+
for (let t = 0; t < o.length; t++) {
|
|
5
|
+
const n = o[t];
|
|
6
|
+
if (n.id) {
|
|
7
|
+
const o = n.id + "-css",
|
|
8
|
+
t = document.getElementById(o);
|
|
9
|
+
t && t.parentNode && t.parentNode.removeChild(t);
|
|
10
|
+
}
|
|
11
|
+
n.parentNode && n.parentNode.removeChild(n);
|
|
12
|
+
}
|
|
13
|
+
const t = document.getElementsByClassName(It);
|
|
14
|
+
for (let o = 0; o < t.length; o++) {
|
|
15
|
+
const n = t[o].classList;
|
|
16
|
+
n.contains(It) && n.remove(It);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import r, { OPTIONS as
|
|
1
|
+
import r, { OPTIONS as q } 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";
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
ORIENTATION as pe,
|
|
11
11
|
WindowUtils as no,
|
|
12
12
|
} from "../../util/window-utils.js";
|
|
13
|
-
import { isURIJavascriptOrData as
|
|
13
|
+
import { isURIJavascriptOrData as Z } 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
16
|
import { logger as E } from "../../../shared-lib/index.js";
|
|
@@ -30,16 +30,16 @@ export function showInAppMessage(e, t, s) {
|
|
|
30
30
|
);
|
|
31
31
|
if (!(e instanceof InAppMessage)) return !1;
|
|
32
32
|
if (e.constructor === InAppMessage) return !1;
|
|
33
|
-
e.
|
|
33
|
+
e.mh();
|
|
34
34
|
const o = e instanceof HtmlMessage;
|
|
35
|
-
if (o && !e.trusted && !r.
|
|
35
|
+
if (o && !e.trusted && !r.nr())
|
|
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.We())) {
|
|
43
43
|
if (t.querySelectorAll(".ab-modal-interactions").length > 0)
|
|
44
44
|
return (
|
|
45
45
|
E.info(
|
|
@@ -69,16 +69,16 @@ export function showInAppMessage(e, t, s) {
|
|
|
69
69
|
);
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
if (!r.
|
|
72
|
+
if (!r.nr()) {
|
|
73
73
|
let t = !1;
|
|
74
74
|
if (e.buttons && e.buttons.length > 0) {
|
|
75
75
|
const s = e.buttons;
|
|
76
76
|
for (let e = 0; e < s.length; e++)
|
|
77
77
|
if (s[e].clickAction === InAppMessage.ClickAction.URI) {
|
|
78
78
|
const o = s[e].uri;
|
|
79
|
-
t =
|
|
79
|
+
t = Z(o);
|
|
80
80
|
}
|
|
81
|
-
} else e.clickAction === InAppMessage.ClickAction.URI && (t =
|
|
81
|
+
} else e.clickAction === InAppMessage.ClickAction.URI && (t = Z(e.uri));
|
|
82
82
|
if (t)
|
|
83
83
|
return (
|
|
84
84
|
E.error(
|
|
@@ -92,37 +92,37 @@ 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(
|
|
95
|
+
e.Pe() && (i.id = e.htmlId),
|
|
96
|
+
r.ee(q.Jo) && (i.style.zIndex = (r.ee(q.Jo) + 1).toString()),
|
|
97
97
|
t.appendChild(i),
|
|
98
98
|
e.Oe())
|
|
99
99
|
) {
|
|
100
100
|
const t = document.createElement("style");
|
|
101
101
|
(t.innerHTML = e.css),
|
|
102
|
-
(t.id = e.
|
|
103
|
-
null != r.ee(
|
|
102
|
+
(t.id = e.He()),
|
|
103
|
+
null != r.ee(q.er) && t.setAttribute("nonce", r.ee(q.er)),
|
|
104
104
|
document.getElementsByTagName("head")[0].appendChild(t);
|
|
105
105
|
}
|
|
106
106
|
const n = e instanceof SlideUpMessage,
|
|
107
107
|
a = le(
|
|
108
108
|
e,
|
|
109
109
|
(t) => {
|
|
110
|
-
if (e.
|
|
110
|
+
if (e.We() && e.Po()) {
|
|
111
111
|
const s = document.createElement("div");
|
|
112
112
|
if (
|
|
113
113
|
((s.className = "ab-page-blocker"),
|
|
114
114
|
e.Oe() || (s.style.backgroundColor = ae(e.frameColor)),
|
|
115
|
-
r.ee(
|
|
115
|
+
r.ee(q.Jo) && (s.style.zIndex = r.ee(q.Jo).toString()),
|
|
116
116
|
i.appendChild(s),
|
|
117
|
-
!r.ee(
|
|
117
|
+
!r.ee(q.Oh))
|
|
118
118
|
) {
|
|
119
119
|
const o = new Date().valueOf();
|
|
120
120
|
s.onclick = (s) => {
|
|
121
|
-
new Date().valueOf() - o > InAppMessage.
|
|
121
|
+
new Date().valueOf() - o > InAppMessage.bh &&
|
|
122
122
|
(e.ll(t), s.stopPropagation());
|
|
123
123
|
};
|
|
124
124
|
}
|
|
125
|
-
i.appendChild(t), t.focus(), e.
|
|
125
|
+
i.appendChild(t), t.focus(), e.ah(i);
|
|
126
126
|
} else if (n) {
|
|
127
127
|
const s = document.querySelectorAll(".ab-slideup");
|
|
128
128
|
let o = null;
|
|
@@ -143,12 +143,12 @@ export function showInAppMessage(e, t, s) {
|
|
|
143
143
|
o.offsetTop),
|
|
144
144
|
(t.style.bottom = Math.max(e, 0) + "px");
|
|
145
145
|
}
|
|
146
|
-
} else if (o && !r.ee(
|
|
146
|
+
} else if (o && !r.ee(q.Oh)) {
|
|
147
147
|
const s = e;
|
|
148
148
|
At(t) &&
|
|
149
149
|
t.contentWindow &&
|
|
150
150
|
t.contentWindow.addEventListener("keydown", function (e) {
|
|
151
|
-
e.keyCode === ie.
|
|
151
|
+
e.keyCode === ie.Ih && s.closeMessage();
|
|
152
152
|
});
|
|
153
153
|
}
|
|
154
154
|
logInAppMessageImpression(e),
|
|
@@ -161,11 +161,11 @@ export function showInAppMessage(e, t, s) {
|
|
|
161
161
|
(e) => {
|
|
162
162
|
E.info(e);
|
|
163
163
|
},
|
|
164
|
-
r.ee(
|
|
165
|
-
r.ee(
|
|
166
|
-
r.ee(
|
|
164
|
+
r.ee(q.To),
|
|
165
|
+
r.ee(q.Jo),
|
|
166
|
+
r.ee(q.er),
|
|
167
167
|
t,
|
|
168
|
-
fe.ea().
|
|
168
|
+
fe.ea().Ho(),
|
|
169
169
|
);
|
|
170
|
-
return (o || n) && (i.appendChild(a), e.
|
|
170
|
+
return (o || n) && (i.appendChild(a), e.ah(i)), !0;
|
|
171
171
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import r from "../managers/braze-instance.js";
|
|
2
|
-
import
|
|
2
|
+
import vt from "./utils/push-utils.js";
|
|
3
3
|
export function isPushPermissionGranted() {
|
|
4
|
-
if (r.rr()) return
|
|
4
|
+
if (r.rr()) return vt.isPushPermissionGranted();
|
|
5
5
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import r, { OPTIONS as
|
|
1
|
+
import r, { OPTIONS as q } from "../managers/braze-instance.js";
|
|
2
2
|
import na from "./push-manager.js";
|
|
3
3
|
const ra = {
|
|
4
4
|
i: !1,
|
|
@@ -7,16 +7,16 @@ const ra = {
|
|
|
7
7
|
ra.t(),
|
|
8
8
|
ra.aa ||
|
|
9
9
|
(ra.aa = new na(
|
|
10
|
-
r.
|
|
11
|
-
r.
|
|
10
|
+
r.br(),
|
|
11
|
+
r.Ma(),
|
|
12
12
|
r.de(),
|
|
13
13
|
r.V(),
|
|
14
|
-
r.ee(
|
|
15
|
-
r.ee(
|
|
16
|
-
r.ee(
|
|
14
|
+
r.ee(q._a),
|
|
15
|
+
r.ee(q.Aa),
|
|
16
|
+
r.ee(q.Ba),
|
|
17
17
|
r.l(),
|
|
18
|
-
r.ee(
|
|
19
|
-
r.ee(
|
|
18
|
+
r.ee(q.Ca),
|
|
19
|
+
r.ee(q.Da),
|
|
20
20
|
r.p(),
|
|
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 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
|
-
import
|
|
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.wn = i),
|
|
11
|
+
(this.Pn = t),
|
|
12
|
+
(this.Dn = e),
|
|
13
|
+
(this.Sn = r),
|
|
14
|
+
(this.xn = n),
|
|
15
|
+
(this.Nn = o),
|
|
16
16
|
(this.h = u),
|
|
17
|
-
(this.
|
|
18
|
-
(this.
|
|
17
|
+
(this.Un = a),
|
|
18
|
+
(this.Wn = h),
|
|
19
19
|
(this.j = c),
|
|
20
|
-
(this.
|
|
21
|
-
(this.
|
|
22
|
-
(this.
|
|
23
|
-
(this.
|
|
24
|
-
(this.
|
|
25
|
-
(this.
|
|
20
|
+
(this.wn = i),
|
|
21
|
+
(this.Pn = t),
|
|
22
|
+
(this.Dn = e),
|
|
23
|
+
(this._n = s + "/safari/" + t),
|
|
24
|
+
(this.Sn = r || "/service-worker.js"),
|
|
25
|
+
(this.Nn = o),
|
|
26
26
|
(this.h = u),
|
|
27
|
-
(this.
|
|
28
|
-
(this.
|
|
27
|
+
(this.Un = a || !1),
|
|
28
|
+
(this.Wn = h || !1),
|
|
29
29
|
(this.j = c),
|
|
30
|
-
(this.
|
|
31
|
-
(this.
|
|
30
|
+
(this.Vn = vt.qn()),
|
|
31
|
+
(this.zn = vt.En());
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
return this.
|
|
33
|
+
Rn() {
|
|
34
|
+
return this.Wn;
|
|
35
35
|
}
|
|
36
|
-
|
|
36
|
+
Cn(i, t, e, s, r) {
|
|
37
37
|
i.unsubscribe()
|
|
38
38
|
.then((i) => {
|
|
39
39
|
i
|
|
40
|
-
? this.
|
|
40
|
+
? this.Fn(t, e, s, r)
|
|
41
41
|
: (E.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
|
+
On(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.Bn &&
|
|
59
|
+
-1 === i.endpoint.indexOf(e.Bn) &&
|
|
60
|
+
(t = i.endpoint + "/" + e.Bn),
|
|
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.wn) || void 0 === s || s.Yn(r, t, n, o, a),
|
|
88
88
|
r && "function" == typeof e && e(r, n, o);
|
|
89
89
|
}
|
|
90
|
-
|
|
90
|
+
Gn() {
|
|
91
91
|
var i;
|
|
92
|
-
null === (i = this.
|
|
92
|
+
null === (i = this.wn) || void 0 === i || i.Hn(!0);
|
|
93
93
|
}
|
|
94
|
-
|
|
94
|
+
Jn(i, t) {
|
|
95
95
|
var e;
|
|
96
|
-
null === (e = this.
|
|
96
|
+
null === (e = this.wn) || void 0 === e || e.Hn(!1),
|
|
97
97
|
E.info(i),
|
|
98
98
|
"function" == typeof t && t(!1);
|
|
99
99
|
}
|
|
100
|
-
|
|
100
|
+
Kn(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._n,
|
|
106
106
|
i,
|
|
107
107
|
{
|
|
108
|
-
api_key: this.
|
|
108
|
+
api_key: this.Pn,
|
|
109
109
|
device_id:
|
|
110
|
-
(null === (r = this.
|
|
110
|
+
(null === (r = this.Dn) || 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.wn &&
|
|
116
|
+
this.wn.setPushNotificationSubscriptionType(
|
|
117
117
|
User.NotificationSubscriptionTypes.OPTED_IN,
|
|
118
118
|
),
|
|
119
|
-
this.
|
|
119
|
+
this.Kn(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
|
(E.info("Device successfully subscribed to push."),
|
|
133
|
-
this.
|
|
133
|
+
this.On(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
|
+
Fn(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
|
E.info("Device successfully subscribed to push."),
|
|
169
|
-
this.
|
|
169
|
+
this.On(i, new Date(), e);
|
|
170
170
|
})
|
|
171
171
|
.catch((i) => {
|
|
172
|
-
|
|
172
|
+
vt.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
|
+
Ln() {
|
|
180
|
+
if (this.Un) return navigator.serviceWorker.getRegistration(this.Sn);
|
|
181
|
+
const i = this.xn ? { scope: this.xn } : void 0;
|
|
182
|
+
return navigator.serviceWorker.register(this.Sn, 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
|
+
Qn(i) {
|
|
196
|
+
this.Un ||
|
|
197
197
|
(i.unregister(), E.info("Service worker successfully unregistered."));
|
|
198
198
|
}
|
|
199
199
|
subscribe(i, t) {
|
|
200
|
-
if (!
|
|
201
|
-
return E.info(na.
|
|
202
|
-
if (this.
|
|
203
|
-
if (!this.
|
|
204
|
-
let i = this.
|
|
200
|
+
if (!vt.isPushSupported())
|
|
201
|
+
return E.info(na.Xn), void ("function" == typeof t && t(!1));
|
|
202
|
+
if (this.Vn) {
|
|
203
|
+
if (!this.Un && null != window.location) {
|
|
204
|
+
let i = this.Sn;
|
|
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 (vt.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.h && !this.h.
|
|
215
|
+
if (this.h && !this.h.Zn() && 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.h
|
|
220
|
+
void this.h.$n(() => {
|
|
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
|
+
vt.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
|
-
n =
|
|
236
|
+
n = vt.isPushPermissionGranted(),
|
|
237
237
|
o = () => {
|
|
238
238
|
!n &&
|
|
239
|
-
this.
|
|
240
|
-
this.
|
|
239
|
+
this.wn &&
|
|
240
|
+
this.wn.setPushNotificationSubscriptionType(
|
|
241
241
|
User.NotificationSubscriptionTypes.OPTED_IN,
|
|
242
242
|
),
|
|
243
|
-
this.
|
|
243
|
+
this.Ln()
|
|
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.h) || void 0 === n
|
|
260
260
|
? void 0
|
|
261
|
-
: n.
|
|
261
|
+
: n.Zn()) && (o = ei.No(this.h.Zn())),
|
|
262
262
|
r)
|
|
263
263
|
) {
|
|
264
264
|
let n,
|
|
265
265
|
u = null,
|
|
266
266
|
a = null;
|
|
267
|
-
if ((this.j && (n = this.j.lt(s.ct.
|
|
267
|
+
if ((this.j && (n = this.j.lt(s.ct.Wo)), n && !z(n))) {
|
|
268
268
|
let i;
|
|
269
269
|
try {
|
|
270
|
-
i = ti.
|
|
270
|
+
i = ti.Vo(n)._o;
|
|
271
271
|
} catch (t) {
|
|
272
272
|
i = null;
|
|
273
273
|
}
|
|
@@ -291,31 +291,31 @@ export default class na {
|
|
|
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.Cn(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.
|
|
302
|
-
: n &&
|
|
303
|
-
? this.
|
|
301
|
+
this.Cn(r, e, o, i, t))
|
|
302
|
+
: n && z(n)
|
|
303
|
+
? this.Cn(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.Cn(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.
|
|
313
|
+
this.Cn(r, e, o, i, t))
|
|
314
314
|
: (E.info(
|
|
315
315
|
"Device already subscribed to push, sending existing subscription to backend.",
|
|
316
316
|
),
|
|
317
|
-
this.
|
|
318
|
-
} else this.
|
|
317
|
+
this.On(r, u, i));
|
|
318
|
+
} else this.Fn(e, o, i, t);
|
|
319
319
|
})
|
|
320
320
|
.catch((i) => {
|
|
321
321
|
E.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.zn) {
|
|
330
|
+
if (null == this.Nn || "" === this.Nn)
|
|
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.Nn);
|
|
338
|
+
this.Kn(this.Nn, e, i, t);
|
|
339
339
|
}
|
|
340
340
|
}
|
|
341
341
|
unsubscribe(i, t) {
|
|
342
|
-
if (!
|
|
343
|
-
return E.info(na.
|
|
344
|
-
this.
|
|
345
|
-
? navigator.serviceWorker.getRegistration(this.
|
|
342
|
+
if (!vt.isPushSupported())
|
|
343
|
+
return E.info(na.Xn), void ("function" == typeof t && t());
|
|
344
|
+
this.Vn
|
|
345
|
+
? navigator.serviceWorker.getRegistration(this.Sn).then((e) => {
|
|
346
346
|
e
|
|
347
347
|
? e.pushManager
|
|
348
348
|
.getSubscription()
|
|
349
349
|
.then((s) => {
|
|
350
350
|
s
|
|
351
|
-
? (this.
|
|
351
|
+
? (this.Gn(),
|
|
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.Qn(e);
|
|
365
365
|
})
|
|
366
366
|
.catch((i) => {
|
|
367
367
|
E.error("Push unsubscription error: " + i),
|
|
@@ -377,10 +377,10 @@ export default class na {
|
|
|
377
377
|
: (E.info("Device already unsubscribed from push."),
|
|
378
378
|
"function" == typeof i && i());
|
|
379
379
|
})
|
|
380
|
-
: this.
|
|
381
|
-
(this.
|
|
380
|
+
: this.zn &&
|
|
381
|
+
(this.Gn(),
|
|
382
382
|
E.info("Device unsubscribed from push."),
|
|
383
383
|
"function" == typeof i && i());
|
|
384
384
|
}
|
|
385
385
|
}
|
|
386
|
-
na.
|
|
386
|
+
na.Xn = "Push notifications are not supported in this browser.";
|
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
1
|
+
const vt = {
|
|
2
|
+
qn: () =>
|
|
3
3
|
"serviceWorker" in navigator &&
|
|
4
4
|
"undefined" != typeof ServiceWorkerRegistration &&
|
|
5
5
|
"showNotification" in ServiceWorkerRegistration.prototype &&
|
|
6
6
|
"PushManager" in window,
|
|
7
|
-
|
|
7
|
+
En: () =>
|
|
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: () =>
|
|
12
|
+
isPushSupported: () => vt.qn() || vt.En(),
|
|
13
13
|
isPushBlocked: () => {
|
|
14
14
|
const o =
|
|
15
|
-
|
|
15
|
+
vt.isPushSupported() &&
|
|
16
16
|
"Notification" in window &&
|
|
17
17
|
null != window.Notification &&
|
|
18
18
|
null != window.Notification.permission &&
|
|
19
19
|
"denied" === window.Notification.permission,
|
|
20
20
|
i =
|
|
21
|
-
|
|
21
|
+
vt.isPushSupported() &&
|
|
22
22
|
(!("Notification" in window) || null == window.Notification);
|
|
23
23
|
return o || i;
|
|
24
24
|
},
|
|
25
25
|
isPushPermissionGranted: () =>
|
|
26
|
-
|
|
26
|
+
vt.isPushSupported() &&
|
|
27
27
|
"Notification" in window &&
|
|
28
28
|
null != window.Notification &&
|
|
29
29
|
null != window.Notification.permission &&
|
|
30
30
|
"granted" === window.Notification.permission,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
? {
|
|
34
|
-
:
|
|
35
|
-
?
|
|
36
|
-
? {
|
|
37
|
-
: {
|
|
38
|
-
: {
|
|
39
|
-
|
|
31
|
+
en: () =>
|
|
32
|
+
vt.isPushBlocked()
|
|
33
|
+
? { sn: !1, reason: "blocked" }
|
|
34
|
+
: vt.isPushSupported()
|
|
35
|
+
? vt.isPushPermissionGranted()
|
|
36
|
+
? { sn: !1, reason: "permissionGranted" }
|
|
37
|
+
: { sn: !0 }
|
|
38
|
+
: { sn: !1, reason: "unsupported" },
|
|
39
|
+
on: (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
|
|
43
43
|
? `${i} containing a push prompt is not being shown because the browser doesn't support push notifications.`
|
|
44
44
|
: `${i} containing a push prompt is not being shown because the user has already accepted the permission prompt.`,
|
|
45
45
|
};
|
|
46
|
-
export default
|
|
46
|
+
export default vt;
|