@braze/web-sdk 6.7.1 → 6.9.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 +165 -38
- package/package.json +1 -1
- package/shared-lib/encoding-utils.js +2 -2
- package/shared-lib/event-types.js +16 -16
- package/shared-lib/indexed-db-adapter.js +65 -65
- package/shared-lib/logger.js +18 -18
- package/shared-lib/supported-options.js +1 -1
- package/src/Banner/banner-provider.js +67 -59
- package/src/Banner/banner.js +40 -19
- package/src/Banner/dismiss-banner.js +4 -0
- package/src/Banner/display/banner-to-html.js +10 -10
- package/src/Banner/display/destroy-banner-html.js +2 -2
- package/src/Banner/get-all-banners.js +6 -6
- package/src/Banner/get-banner.js +6 -6
- package/src/Banner/index.js +1 -0
- package/src/Banner/log-banner-click.js +7 -7
- package/src/Banner/log-banner-dismissal.js +7 -7
- package/src/Banner/log-banner-impressions.js +27 -18
- package/src/Banner/request-banners-refresh.js +8 -8
- package/src/Banner/subscribe-to-banners-updates.js +5 -5
- package/src/Banner/ui/insert-banner.js +8 -8
- package/src/Card/card-manager.js +31 -31
- package/src/Card/log-card-dismissal.js +2 -2
- package/src/Card/log-content-card-click.js +2 -2
- package/src/Card/log-content-card-impressions.js +4 -4
- package/src/Card/models/captioned-image.js +15 -15
- package/src/Card/models/card.js +89 -89
- package/src/Card/models/classic-card.js +16 -16
- package/src/Card/models/control-card.js +7 -7
- package/src/Card/models/image-only.js +13 -13
- package/src/Card/util/card-factory.js +32 -32
- package/src/ContentCards/content-cards-provider-factory.js +13 -11
- package/src/ContentCards/content-cards-provider.js +105 -105
- 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 +10 -10
- package/src/ContentCards/ui/show-content-cards.js +7 -7
- package/src/Core/add-sdk-metadata.js +2 -2
- package/src/Core/change-user.js +5 -5
- package/src/Core/destroy.js +2 -2
- package/src/Core/disable-sdk.js +4 -4
- package/src/Core/enable-sdk.js +4 -4
- package/src/Core/get-device-id.js +2 -2
- package/src/Core/handle-braze-action.js +5 -5
- package/src/Core/index.js +1 -0
- package/src/Core/log-custom-event.js +5 -5
- package/src/Core/log-ecommerce-event.js +29 -0
- package/src/Core/log-purchase.js +23 -198
- package/src/Core/open-session.js +10 -10
- package/src/Core/set-logger.js +2 -2
- package/src/Core/set-sdk-authentication-signature.js +1 -1
- package/src/Core/subscribe-to-sdk-authentication-failures.js +1 -1
- package/src/Core/toggle-logging.js +2 -2
- package/src/Core/wipe-data.js +6 -6
- package/src/DUST/dust-connection-core.js +1 -0
- package/src/DUST/dust-provider-factory.js +10 -10
- package/src/DUST/dust-provider.js +258 -226
- package/src/DUST/dust-shared-worker-code.js +1 -1
- package/src/DUST/dust-shared-worker-impl.js +97 -103
- package/src/DUST/dust-worker-bridge.js +55 -40
- package/src/DUST/subscribe-to-dust.js +7 -7
- package/src/FeatureFlags/feature-flag-factory.js +8 -8
- package/src/FeatureFlags/feature-flag.js +3 -3
- package/src/FeatureFlags/feature-flags-provider.js +21 -21
- package/src/FeatureFlags/log-feature-flag-impression.js +5 -5
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +1 -1
- package/src/InAppMessage/constants.js +3 -3
- package/src/InAppMessage/defer-in-app-message.js +3 -3
- package/src/InAppMessage/display/html-message-to-html.js +4 -4
- package/src/InAppMessage/display/in-app-message-to-html.js +32 -32
- package/src/InAppMessage/display/modal-utils.js +2 -2
- package/src/InAppMessage/in-app-message-factory.js +36 -36
- package/src/InAppMessage/in-app-message-manager.js +35 -35
- package/src/InAppMessage/log-in-app-message-button-click.js +3 -3
- package/src/InAppMessage/log-in-app-message-click.js +3 -3
- package/src/InAppMessage/log-in-app-message-html-click.js +3 -3
- package/src/InAppMessage/log-in-app-message-impression.js +3 -3
- package/src/InAppMessage/models/control-message.js +4 -4
- package/src/InAppMessage/models/full-screen-message.js +9 -9
- package/src/InAppMessage/models/html-message.js +2 -2
- package/src/InAppMessage/models/in-app-message-button.js +4 -4
- package/src/InAppMessage/models/in-app-message.js +34 -34
- package/src/InAppMessage/models/modal-message.js +7 -7
- package/src/InAppMessage/models/slide-up-message.js +8 -8
- package/src/InAppMessage/ui/show-in-app-message.js +20 -20
- package/src/Push/push-manager.js +44 -44
- package/src/User/user-manager.js +19 -19
- package/src/User/user.js +17 -17
- package/src/common/base-provider.js +1 -1
- package/src/common/constants.js +1 -0
- package/src/common/content-cards-display.js +6 -6
- package/src/common/event-logger.js +3 -3
- package/src/common/properties-base.js +3 -3
- package/src/l10n/l10n-manager.js +2 -2
- package/src/managers/auth-manager.js +11 -11
- package/src/managers/braze-instance.js +59 -59
- package/src/managers/device-manager.js +9 -9
- package/src/managers/network-manager.js +65 -63
- package/src/managers/server-config-manager.js +110 -93
- package/src/managers/session-manager.js +20 -20
- package/src/managers/storage-manager-factory.js +9 -9
- package/src/managers/storage-manager.js +137 -137
- package/src/managers/subscription-manager.js +2 -2
- package/src/managers/utils.js +1 -1
- package/src/models/braze-event.js +2 -2
- package/src/models/identifier.js +5 -5
- package/src/models/push-token.js +8 -8
- package/src/models/request-result.js +1 -1
- package/src/models/server-config.js +46 -28
- package/src/request-controller.js +124 -124
- 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 +2 -2
- package/src/triggers/models/filter.js +1 -1
- package/src/triggers/models/in-app-message-click-data.js +5 -5
- 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 +5 -5
- package/src/triggers/models/trigger-condition.js +45 -45
- package/src/triggers/models/trigger-events.js +3 -3
- package/src/triggers/models/trigger.js +30 -30
- package/src/triggers/triggers-provider.js +63 -63
- package/src/types.js +5 -1
- package/src/ui/js/attach-css.js +1 -1
- package/src/util/braze-actions.js +6 -6
- package/src/util/browser-detector.js +13 -13
- package/src/util/client-hints-parser.js +5 -5
- package/src/util/code-utils.js +2 -2
- package/src/util/deprecation-utils.js +2 -2
- package/src/util/dom-utils.js +8 -8
- package/src/util/ecommerce-event-validation.js +343 -0
- package/src/util/html-display-utils.js +11 -11
- package/src/util/iso-4217-currency-codes.js +176 -0
- package/src/util/net.js +4 -4
- package/src/util/request-header-utils.js +10 -10
- package/src/util/string-utils.js +2 -2
- package/src/util/user-agent-parser.js +15 -15
- package/src/util/validation-utils.js +14 -14
|
@@ -4,8 +4,8 @@ import {
|
|
|
4
4
|
IamColors as ss,
|
|
5
5
|
IamSerializationKeys as cr,
|
|
6
6
|
IamServerTypes as dt,
|
|
7
|
-
IamSlideFrom as
|
|
8
|
-
IamTextAlignment as
|
|
7
|
+
IamSlideFrom as Ee,
|
|
8
|
+
IamTextAlignment as Fe,
|
|
9
9
|
} from "../constants.js";
|
|
10
10
|
export default class SlideUpMessage extends InAppMessage {
|
|
11
11
|
constructor(
|
|
@@ -38,7 +38,7 @@ export default class SlideUpMessage extends InAppMessage {
|
|
|
38
38
|
(v = v || ss.OE),
|
|
39
39
|
super(
|
|
40
40
|
t,
|
|
41
|
-
(s = s ||
|
|
41
|
+
(s = s || Fe.START),
|
|
42
42
|
e,
|
|
43
43
|
o,
|
|
44
44
|
i,
|
|
@@ -70,7 +70,7 @@ export default class SlideUpMessage extends InAppMessage {
|
|
|
70
70
|
b,
|
|
71
71
|
z,
|
|
72
72
|
),
|
|
73
|
-
(this.Go =
|
|
73
|
+
(this.Go = Fe.START);
|
|
74
74
|
}
|
|
75
75
|
zo() {
|
|
76
76
|
return !1;
|
|
@@ -82,7 +82,7 @@ export default class SlideUpMessage extends InAppMessage {
|
|
|
82
82
|
eh(t) {
|
|
83
83
|
const s = t.getElementsByClassName("ab-in-app-message")[0];
|
|
84
84
|
Mt.td(s, !0, !0) ||
|
|
85
|
-
(this.slideFrom ===
|
|
85
|
+
(this.slideFrom === Ee.TOP
|
|
86
86
|
? (s.style.top = "0px")
|
|
87
87
|
: (s.style.bottom = "0px")),
|
|
88
88
|
super.eh(t);
|
|
@@ -95,7 +95,7 @@ export default class SlideUpMessage extends InAppMessage {
|
|
|
95
95
|
t[cr.rE],
|
|
96
96
|
t[cr.mE],
|
|
97
97
|
t[cr.GE],
|
|
98
|
-
t[cr.
|
|
98
|
+
t[cr.Is],
|
|
99
99
|
t[cr.FE],
|
|
100
100
|
t[cr.HE],
|
|
101
101
|
t[cr.URI],
|
|
@@ -103,7 +103,7 @@ export default class SlideUpMessage extends InAppMessage {
|
|
|
103
103
|
t[cr.BE],
|
|
104
104
|
t[cr.lE],
|
|
105
105
|
t[cr.bE],
|
|
106
|
-
t[cr.
|
|
106
|
+
t[cr.Bs],
|
|
107
107
|
t[cr.YE],
|
|
108
108
|
t[cr.KE],
|
|
109
109
|
t[cr.XE],
|
|
@@ -115,7 +115,7 @@ export default class SlideUpMessage extends InAppMessage {
|
|
|
115
115
|
t[cr.CSS],
|
|
116
116
|
t[cr.JE],
|
|
117
117
|
t[cr.LANGUAGE],
|
|
118
|
-
t[cr.
|
|
118
|
+
t[cr.Ns],
|
|
119
119
|
);
|
|
120
120
|
}
|
|
121
121
|
}
|
|
@@ -4,7 +4,7 @@ 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 be from "../display/get-animation-effect.js";
|
|
7
|
-
import
|
|
7
|
+
import Ge from "../display/in-app-message-to-html.js";
|
|
8
8
|
import { logInAppMessageImpression } from "../log-in-app-message-impression.js";
|
|
9
9
|
import {
|
|
10
10
|
ORIENTATION as Ue,
|
|
@@ -13,23 +13,23 @@ import {
|
|
|
13
13
|
import { isURIJavascriptOrData as tt } from "../../util/url-utils.js";
|
|
14
14
|
import { KeyCodes as Ce } from "../../util/key-codes.js";
|
|
15
15
|
import { setupInAppMessageUI as rs } from "../../ui/js/index.js";
|
|
16
|
-
import { logger as
|
|
16
|
+
import { logger as b } from "../../../shared-lib/index.js";
|
|
17
17
|
import { toRgba as ke } from "../../util/color-utils.js";
|
|
18
18
|
import { isIFrame as St } from "../utils/in-app-message-utils.js";
|
|
19
19
|
import Je from "../../l10n/l10n-manager-factory.js";
|
|
20
20
|
import {
|
|
21
21
|
IamTiming as Et,
|
|
22
|
-
IamClickAction as
|
|
22
|
+
IamClickAction as Le,
|
|
23
23
|
IamDismissType as pr,
|
|
24
|
-
IamOrientation as
|
|
25
|
-
IamSlideFrom as
|
|
24
|
+
IamOrientation as De,
|
|
25
|
+
IamSlideFrom as Ee,
|
|
26
26
|
} from "../constants.js";
|
|
27
27
|
export function showInAppMessage(e, t, s) {
|
|
28
28
|
if (!r.rr()) return;
|
|
29
29
|
if ((rs(), null == e)) return !1;
|
|
30
30
|
if (e instanceof ControlMessage)
|
|
31
31
|
return (
|
|
32
|
-
|
|
32
|
+
b.info(
|
|
33
33
|
"User received control for a multivariate test, logging to Braze servers.",
|
|
34
34
|
),
|
|
35
35
|
logInAppMessageImpression(e),
|
|
@@ -39,9 +39,9 @@ export function showInAppMessage(e, t, s) {
|
|
|
39
39
|
if (e.constructor === InAppMessage) return !1;
|
|
40
40
|
e.lh();
|
|
41
41
|
const o = e instanceof HtmlMessage;
|
|
42
|
-
if (o && !e.trusted && !r.
|
|
42
|
+
if (o && !e.trusted && !r.dr())
|
|
43
43
|
return (
|
|
44
|
-
|
|
44
|
+
b.error(
|
|
45
45
|
'HTML in-app messages are disabled. Use the "allowUserSuppliedJavascript" option for braze.initialize to enable these messages.',
|
|
46
46
|
),
|
|
47
47
|
!1
|
|
@@ -49,7 +49,7 @@ export function showInAppMessage(e, t, s) {
|
|
|
49
49
|
if ((null == t && (t = document.body), e.zo())) {
|
|
50
50
|
if (t.querySelectorAll(".ab-modal-interactions").length > 0)
|
|
51
51
|
return (
|
|
52
|
-
|
|
52
|
+
b.info(
|
|
53
53
|
`Cannot show in-app message ${e.message} because another message is being shown.`,
|
|
54
54
|
),
|
|
55
55
|
!1
|
|
@@ -58,32 +58,32 @@ export function showInAppMessage(e, t, s) {
|
|
|
58
58
|
if (no.da()) {
|
|
59
59
|
const t = no.ga();
|
|
60
60
|
if (
|
|
61
|
-
(t === Ue.PORTRAIT && e.orientation ===
|
|
62
|
-
(t === Ue.LANDSCAPE && e.orientation ===
|
|
61
|
+
(t === Ue.PORTRAIT && e.orientation === De.LANDSCAPE) ||
|
|
62
|
+
(t === Ue.LANDSCAPE && e.orientation === De.PORTRAIT)
|
|
63
63
|
) {
|
|
64
64
|
const s = t === Ue.PORTRAIT ? "portrait" : "landscape",
|
|
65
|
-
o = e.orientation ===
|
|
65
|
+
o = e.orientation === De.PORTRAIT ? "portrait" : "landscape";
|
|
66
66
|
return (
|
|
67
|
-
|
|
67
|
+
b.info(
|
|
68
68
|
`Not showing ${o} in-app message ${e.message} because the screen is currently ${s}`,
|
|
69
69
|
),
|
|
70
70
|
!1
|
|
71
71
|
);
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
-
if (!r.
|
|
74
|
+
if (!r.dr()) {
|
|
75
75
|
let t = !1;
|
|
76
76
|
if (e.buttons && e.buttons.length > 0) {
|
|
77
77
|
const s = e.buttons;
|
|
78
78
|
for (let e = 0; e < s.length; e++)
|
|
79
|
-
if (s[e].clickAction ===
|
|
79
|
+
if (s[e].clickAction === Le.URI) {
|
|
80
80
|
const o = s[e].uri;
|
|
81
81
|
t = tt(o);
|
|
82
82
|
}
|
|
83
|
-
} else e.clickAction ===
|
|
83
|
+
} else e.clickAction === Le.URI && (t = tt(e.uri));
|
|
84
84
|
if (t)
|
|
85
85
|
return (
|
|
86
|
-
|
|
86
|
+
b.error(
|
|
87
87
|
'Javascript click actions are disabled. Use the "allowUserSuppliedJavascript" option for braze.initialize to enable these actions.',
|
|
88
88
|
),
|
|
89
89
|
!1
|
|
@@ -106,7 +106,7 @@ export function showInAppMessage(e, t, s) {
|
|
|
106
106
|
document.getElementsByTagName("head")[0].appendChild(t);
|
|
107
107
|
}
|
|
108
108
|
const n = e instanceof SlideUpMessage,
|
|
109
|
-
a =
|
|
109
|
+
a = Ge(
|
|
110
110
|
e,
|
|
111
111
|
(t) => {
|
|
112
112
|
if (e.zo() && e.od()) {
|
|
@@ -133,7 +133,7 @@ export function showInAppMessage(e, t, s) {
|
|
|
133
133
|
o = s[e];
|
|
134
134
|
break;
|
|
135
135
|
}
|
|
136
|
-
if (e.slideFrom ===
|
|
136
|
+
if (e.slideFrom === Ee.TOP) {
|
|
137
137
|
let e = 0;
|
|
138
138
|
null != o && (e = o.offsetTop + o.offsetHeight),
|
|
139
139
|
(t.style.top = Math.max(e, 0) + "px");
|
|
@@ -161,7 +161,7 @@ export function showInAppMessage(e, t, s) {
|
|
|
161
161
|
"function" == typeof s && s();
|
|
162
162
|
},
|
|
163
163
|
(e) => {
|
|
164
|
-
|
|
164
|
+
b.info(e);
|
|
165
165
|
},
|
|
166
166
|
r.er(U.ba),
|
|
167
167
|
r.er(U.ja),
|
package/src/Push/push-manager.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { isArray as g, isEqual as
|
|
2
|
-
import
|
|
3
|
-
import { logger as
|
|
1
|
+
import { isArray as g, isEqual as oi } from "../util/code-utils.js";
|
|
2
|
+
import ui from "../models/push-token.js";
|
|
3
|
+
import { logger as b, EncodingUtils as ai } 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 It from "./utils/push-utils.js";
|
|
7
|
-
import { getErrorMessage as
|
|
7
|
+
import { getErrorMessage as hi } 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
10
|
(this.iu = i),
|
|
@@ -16,7 +16,7 @@ export default class na {
|
|
|
16
16
|
(this.h = u),
|
|
17
17
|
(this.ou = a),
|
|
18
18
|
(this.uu = h),
|
|
19
|
-
(this.
|
|
19
|
+
(this.j = c),
|
|
20
20
|
(this.iu = i),
|
|
21
21
|
(this.tu = t),
|
|
22
22
|
(this.eu = e),
|
|
@@ -26,7 +26,7 @@ export default class na {
|
|
|
26
26
|
(this.h = u),
|
|
27
27
|
(this.ou = a || !1),
|
|
28
28
|
(this.uu = h || !1),
|
|
29
|
-
(this.
|
|
29
|
+
(this.j = c),
|
|
30
30
|
(this.hu = It.cu()),
|
|
31
31
|
(this.fu = It.lu());
|
|
32
32
|
}
|
|
@@ -38,11 +38,11 @@ export default class na {
|
|
|
38
38
|
.then((i) => {
|
|
39
39
|
i
|
|
40
40
|
? this.bu(t, e, s, r)
|
|
41
|
-
: (
|
|
41
|
+
: (b.error("Failed to unsubscribe device from push."),
|
|
42
42
|
"function" == typeof r && r(!1));
|
|
43
43
|
})
|
|
44
44
|
.catch((i) => {
|
|
45
|
-
|
|
45
|
+
b.error("Push unsubscription error: " + i),
|
|
46
46
|
"function" == typeof r && r(!1);
|
|
47
47
|
});
|
|
48
48
|
}
|
|
@@ -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
|
+
b.error(hi(i));
|
|
75
75
|
}
|
|
76
76
|
const a = ((i) => {
|
|
77
77
|
let t;
|
|
@@ -94,7 +94,7 @@ export default class na {
|
|
|
94
94
|
ku(i, t) {
|
|
95
95
|
var e;
|
|
96
96
|
null === (e = this.iu) || void 0 === e || e.wu(!1),
|
|
97
|
-
|
|
97
|
+
b.info(i),
|
|
98
98
|
"function" == typeof t && t(!1);
|
|
99
99
|
}
|
|
100
100
|
Pu(i, t, e, s) {
|
|
@@ -129,7 +129,7 @@ export default class na {
|
|
|
129
129
|
s,
|
|
130
130
|
)
|
|
131
131
|
: "granted" === t.permission &&
|
|
132
|
-
(
|
|
132
|
+
(b.info("Device successfully subscribed to push."),
|
|
133
133
|
this.yu(t.deviceToken, new Date(), e));
|
|
134
134
|
}
|
|
135
135
|
requestPermission(i, t, e) {
|
|
@@ -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
|
+
b.error("Received unexpected permission result " + s);
|
|
146
146
|
}
|
|
147
147
|
};
|
|
148
148
|
let r = !1;
|
|
@@ -165,14 +165,14 @@ export default class na {
|
|
|
165
165
|
i.pushManager
|
|
166
166
|
.subscribe(r)
|
|
167
167
|
.then((i) => {
|
|
168
|
-
|
|
168
|
+
b.info("Device successfully subscribed to push."),
|
|
169
169
|
this.yu(i, new Date(), e);
|
|
170
170
|
})
|
|
171
171
|
.catch((i) => {
|
|
172
172
|
It.isPushBlocked()
|
|
173
|
-
? (
|
|
173
|
+
? (b.info("Permission for push notifications was denied."),
|
|
174
174
|
"function" == typeof s && s(!1))
|
|
175
|
-
: (
|
|
175
|
+
: (b.error("Push subscription failed: " + i),
|
|
176
176
|
"function" == typeof s && s(!0));
|
|
177
177
|
});
|
|
178
178
|
}
|
|
@@ -185,7 +185,7 @@ export default class na {
|
|
|
185
185
|
i &&
|
|
186
186
|
"function" == typeof i.update &&
|
|
187
187
|
i.update().catch((i) => {
|
|
188
|
-
|
|
188
|
+
b.info("ServiceWorker update failed: " + i);
|
|
189
189
|
}),
|
|
190
190
|
i
|
|
191
191
|
),
|
|
@@ -194,11 +194,11 @@ export default class na {
|
|
|
194
194
|
}
|
|
195
195
|
Su(i) {
|
|
196
196
|
this.ou ||
|
|
197
|
-
(i.unregister(),
|
|
197
|
+
(i.unregister(), b.info("Service worker successfully unregistered."));
|
|
198
198
|
}
|
|
199
199
|
subscribe(i, t) {
|
|
200
200
|
if (!It.isPushSupported())
|
|
201
|
-
return
|
|
201
|
+
return b.info(na.Au), void ("function" == typeof t && t(!1));
|
|
202
202
|
if (this.hu) {
|
|
203
203
|
if (!this.ou && null != window.location) {
|
|
204
204
|
let i = this.su;
|
|
@@ -212,9 +212,9 @@ export default class na {
|
|
|
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.ju() && 0 === this.h.
|
|
215
|
+
if (this.h && !this.h.ju() && 0 === this.h.Qt())
|
|
216
216
|
return (
|
|
217
|
-
|
|
217
|
+
b.info(
|
|
218
218
|
"Waiting for VAPID key from server config before subscribing to push.",
|
|
219
219
|
),
|
|
220
220
|
void this.h.xu(() => {
|
|
@@ -222,7 +222,7 @@ export default class na {
|
|
|
222
222
|
})
|
|
223
223
|
);
|
|
224
224
|
const e = () => {
|
|
225
|
-
|
|
225
|
+
b.info("Permission for push notifications was denied."),
|
|
226
226
|
"function" == typeof t && t(!1);
|
|
227
227
|
},
|
|
228
228
|
r = () => {
|
|
@@ -230,7 +230,7 @@ export default class na {
|
|
|
230
230
|
It.isPushBlocked() &&
|
|
231
231
|
(i +=
|
|
232
232
|
" The browser has automatically blocked further permission requests for a period (probably 1 week)."),
|
|
233
|
-
|
|
233
|
+
b.info(i),
|
|
234
234
|
"function" == typeof t && t(!0);
|
|
235
235
|
},
|
|
236
236
|
n = It.isPushPermissionGranted(),
|
|
@@ -244,7 +244,7 @@ export default class na {
|
|
|
244
244
|
.then((e) => {
|
|
245
245
|
if (null == e)
|
|
246
246
|
return (
|
|
247
|
-
|
|
247
|
+
b.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))
|
|
@@ -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.ju()) && (o =
|
|
261
|
+
: n.ju()) && (o = ai.Nu(this.h.ju())),
|
|
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.St(s.It.Uu)), n && !g(n))) {
|
|
268
268
|
let i;
|
|
269
269
|
try {
|
|
270
|
-
i =
|
|
270
|
+
i = ui._u(n).Wu;
|
|
271
271
|
} catch (t) {
|
|
272
272
|
i = null;
|
|
273
273
|
}
|
|
@@ -283,53 +283,53 @@ export default class na {
|
|
|
283
283
|
r.options.applicationServerKey &&
|
|
284
284
|
r.options.applicationServerKey.byteLength &&
|
|
285
285
|
r.options.applicationServerKey.byteLength > 0 &&
|
|
286
|
-
!
|
|
286
|
+
!oi(o, new Uint8Array(r.options.applicationServerKey))
|
|
287
287
|
? (r.options.applicationServerKey.byteLength > 12
|
|
288
|
-
?
|
|
288
|
+
? b.info(
|
|
289
289
|
"Device was already subscribed to push using a different VAPID provider, creating new subscription.",
|
|
290
290
|
)
|
|
291
|
-
:
|
|
291
|
+
: b.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
294
|
this.pu(r, e, o, i, t))
|
|
295
295
|
: r.expirationTime &&
|
|
296
296
|
new Date(r.expirationTime).valueOf() <=
|
|
297
297
|
new Date().valueOf()
|
|
298
|
-
? (
|
|
298
|
+
? (b.info(
|
|
299
299
|
"Push subscription is expired, creating new subscription.",
|
|
300
300
|
),
|
|
301
301
|
this.pu(r, e, o, i, t))
|
|
302
302
|
: n && g(n)
|
|
303
303
|
? this.pu(r, e, o, i, t)
|
|
304
304
|
: null == a
|
|
305
|
-
? (
|
|
305
|
+
? (b.info(
|
|
306
306
|
"No push subscription creation date found, creating new subscription.",
|
|
307
307
|
),
|
|
308
308
|
this.pu(r, e, o, i, t))
|
|
309
309
|
: a.valueOf() <= new Date().valueOf()
|
|
310
|
-
? (
|
|
310
|
+
? (b.info(
|
|
311
311
|
"Push subscription older than 6 months, creating new subscription.",
|
|
312
312
|
),
|
|
313
313
|
this.pu(r, e, o, i, t))
|
|
314
|
-
: (
|
|
314
|
+
: (b.info(
|
|
315
315
|
"Device already subscribed to push, sending existing subscription to backend.",
|
|
316
316
|
),
|
|
317
317
|
this.yu(r, u, i));
|
|
318
318
|
} else this.bu(e, o, i, t);
|
|
319
319
|
})
|
|
320
320
|
.catch((i) => {
|
|
321
|
-
|
|
321
|
+
b.error("Error checking current push subscriptions: " + i);
|
|
322
322
|
});
|
|
323
323
|
})
|
|
324
324
|
.catch((i) => {
|
|
325
|
-
|
|
325
|
+
b.error("ServiceWorker registration failed: " + i);
|
|
326
326
|
});
|
|
327
327
|
};
|
|
328
328
|
this.requestPermission(o, r, e);
|
|
329
329
|
} else if (this.fu) {
|
|
330
330
|
if (null == this.nu || "" === this.nu)
|
|
331
331
|
return (
|
|
332
|
-
|
|
332
|
+
b.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))
|
|
@@ -340,7 +340,7 @@ export default class na {
|
|
|
340
340
|
}
|
|
341
341
|
unsubscribe(i, t) {
|
|
342
342
|
if (!It.isPushSupported())
|
|
343
|
-
return
|
|
343
|
+
return b.info(na.Au), void ("function" == typeof t && t());
|
|
344
344
|
this.hu
|
|
345
345
|
? navigator.serviceWorker.getRegistration(this.su).then((e) => {
|
|
346
346
|
e
|
|
@@ -353,33 +353,33 @@ export default class na {
|
|
|
353
353
|
.unsubscribe()
|
|
354
354
|
.then((s) => {
|
|
355
355
|
s
|
|
356
|
-
? (
|
|
356
|
+
? (b.info(
|
|
357
357
|
"Device successfully unsubscribed from push.",
|
|
358
358
|
),
|
|
359
359
|
"function" == typeof i && i())
|
|
360
|
-
: (
|
|
360
|
+
: (b.error(
|
|
361
361
|
"Failed to unsubscribe device from push.",
|
|
362
362
|
),
|
|
363
363
|
"function" == typeof t && t()),
|
|
364
364
|
this.Su(e);
|
|
365
365
|
})
|
|
366
366
|
.catch((i) => {
|
|
367
|
-
|
|
367
|
+
b.error("Push unsubscription error: " + i),
|
|
368
368
|
"function" == typeof t && t();
|
|
369
369
|
}))
|
|
370
|
-
: (
|
|
370
|
+
: (b.info("Device already unsubscribed from push."),
|
|
371
371
|
"function" == typeof i && i());
|
|
372
372
|
})
|
|
373
373
|
.catch((i) => {
|
|
374
|
-
|
|
374
|
+
b.error("Error unsubscribing from push: " + i),
|
|
375
375
|
"function" == typeof t && t();
|
|
376
376
|
})
|
|
377
|
-
: (
|
|
377
|
+
: (b.info("Device already unsubscribed from push."),
|
|
378
378
|
"function" == typeof i && i());
|
|
379
379
|
})
|
|
380
380
|
: this.fu &&
|
|
381
381
|
(this.vu(),
|
|
382
|
-
|
|
382
|
+
b.info("Device unsubscribed from push."),
|
|
383
383
|
"function" == typeof i && i());
|
|
384
384
|
}
|
|
385
385
|
}
|
package/src/User/user-manager.js
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
import _t from "../models/identifier.js";
|
|
2
|
-
import { getByteLength as
|
|
3
|
-
import
|
|
4
|
-
import { logger as
|
|
2
|
+
import { getByteLength as er } from "../util/string-utils.js";
|
|
3
|
+
import ui from "../models/push-token.js";
|
|
4
|
+
import { logger as b, IndexedDBAdapter as et } from "../../shared-lib/index.js";
|
|
5
5
|
import { STORAGE_KEYS as s } from "../managers/storage-manager.js";
|
|
6
6
|
import { User } from "../User/index.js";
|
|
7
7
|
export default class Ut {
|
|
8
8
|
constructor(t, s) {
|
|
9
|
-
(this.h = t), (this.
|
|
9
|
+
(this.h = t), (this.j = s), (this.h = t), (this.j = s);
|
|
10
10
|
}
|
|
11
11
|
getUserId() {
|
|
12
|
-
const t = this.
|
|
12
|
+
const t = this.j.$u(s.Ou.Cu);
|
|
13
13
|
if (null == t) return null;
|
|
14
14
|
let i = t.Tu,
|
|
15
|
-
e =
|
|
15
|
+
e = er(i);
|
|
16
16
|
if (e > User.br) {
|
|
17
|
-
for (; e > User.br; ) (i = i.slice(0, i.length - 1)), (e =
|
|
18
|
-
(t.Tu = i), this.
|
|
17
|
+
for (; e > User.br; ) (i = i.slice(0, i.length - 1)), (e = er(i));
|
|
18
|
+
(t.Tu = i), this.j.Iu(s.Ou.Cu, t);
|
|
19
19
|
}
|
|
20
20
|
return i;
|
|
21
21
|
}
|
|
22
22
|
Ju(t) {
|
|
23
23
|
const i = null == this.getUserId();
|
|
24
|
-
this.
|
|
24
|
+
this.j.Iu(s.Ou.Cu, new _t(t)), i && this.j.Lu(t);
|
|
25
25
|
}
|
|
26
26
|
setCustomUserAttribute(t, s) {
|
|
27
27
|
if (this.h.qu(t))
|
|
28
28
|
return (
|
|
29
|
-
|
|
29
|
+
b.info('Custom Attribute "' + t + '" is blocklisted, ignoring.'), !1
|
|
30
30
|
);
|
|
31
31
|
const i = {};
|
|
32
32
|
return (i[t] = s), this.zu(User.Bu, i, !0);
|
|
33
33
|
}
|
|
34
34
|
zu(t, s, i = !1, e = !1) {
|
|
35
|
-
const u = this.
|
|
35
|
+
const u = this.j.Eu(this.getUserId(), t, s);
|
|
36
36
|
let o = "",
|
|
37
37
|
r = t,
|
|
38
38
|
h = s;
|
|
@@ -43,7 +43,7 @@ export default class Ut {
|
|
|
43
43
|
((r = Object.keys(s)[0]),
|
|
44
44
|
(h = s[r]),
|
|
45
45
|
"object" == typeof h && (h = JSON.stringify(h, null, 2)))),
|
|
46
|
-
!e && u &&
|
|
46
|
+
!e && u && b.info(`Logged${o} attribute ${r} with value ${h}`),
|
|
47
47
|
u
|
|
48
48
|
);
|
|
49
49
|
}
|
|
@@ -52,10 +52,10 @@ export default class Ut {
|
|
|
52
52
|
this.zu("custom_push_public_key", e, !1, !0),
|
|
53
53
|
this.zu("custom_push_user_auth", u, !1, !0),
|
|
54
54
|
this.zu("custom_push_vapid_public_key", o, !1, !0);
|
|
55
|
-
const r = et.
|
|
56
|
-
h = new et(r,
|
|
57
|
-
n = new
|
|
58
|
-
this.
|
|
55
|
+
const r = et._s.Xs,
|
|
56
|
+
h = new et(r, b),
|
|
57
|
+
n = new ui(t, i, e, u, o);
|
|
58
|
+
this.j.Pt(s.It.Uu, n.qt()), h.setItem(r.Ws.Fu, r.be, !0);
|
|
59
59
|
}
|
|
60
60
|
wu(t) {
|
|
61
61
|
if (
|
|
@@ -65,9 +65,9 @@ export default class Ut {
|
|
|
65
65
|
this.zu("custom_push_vapid_public_key", null, !1, !0),
|
|
66
66
|
t)
|
|
67
67
|
) {
|
|
68
|
-
const t = et.
|
|
69
|
-
i = new et(t,
|
|
70
|
-
this.
|
|
68
|
+
const t = et._s.Xs,
|
|
69
|
+
i = new et(t, b);
|
|
70
|
+
this.j.Pt(s.It.Uu, !1), i.setItem(t.Ws.Fu, t.be, !1);
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
}
|