@braze/web-sdk 4.4.0 → 4.5.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 +15 -3
- package/package.json +1 -1
- package/shared-lib/braze-shared-lib.js +1 -1
- package/shared-lib/encoding-utils.js +1 -1
- package/shared-lib/event-types.js +7 -7
- package/shared-lib/indexed-db-adapter.js +1 -1
- package/shared-lib/logger.js +2 -2
- package/shared-lib/supported-options.js +13 -13
- package/src/Card/models/card.js +1 -0
- package/src/Card/models/control-card.js +3 -2
- package/src/InAppMessage/log-in-app-message-click.js +4 -1
- package/src/InAppMessage/models/control-message.js +1 -1
- package/src/InAppMessage/models/in-app-message.js +8 -4
- package/src/Push/push-manager.js +54 -54
- package/src/Push/utils/push-utils.js +3 -3
- package/src/User/user-manager.js +4 -4
- package/src/User/user.js +8 -8
- package/src/managers/auth-manager.js +4 -4
- package/src/managers/braze-instance.js +81 -81
- package/src/managers/device-manager.js +7 -7
- package/src/managers/network-manager.js +39 -39
- package/src/managers/server-config-manager.js +4 -4
- package/src/managers/session-manager.js +1 -1
- package/src/managers/storage-manager-factory.js +1 -1
- package/src/managers/storage-manager.js +40 -40
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +1 -1
- package/src/models/identifier.js +1 -1
- package/src/models/push-token.js +3 -3
- package/src/models/server-config.js +3 -3
- package/src/request-controller.js +64 -64
- package/src/triggers/models/custom-event-data.js +1 -1
- package/src/triggers/models/custom-event-property-data.js +5 -5
- package/src/triggers/models/filter-set.js +4 -4
- package/src/triggers/models/filter.js +57 -57
- 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 +5 -5
- package/src/triggers/models/push-click-data.js +1 -1
- package/src/triggers/models/trigger-condition.js +4 -4
- package/src/triggers/models/trigger.js +16 -16
- package/src/triggers/triggers-provider-factory.js +1 -1
- package/src/triggers/triggers-provider.js +14 -14
- package/src/ui/js/attach-css.js +1 -1
- package/src/ui/js/feed-css.js +1 -1
- package/src/ui/js/iam-css.js +1 -1
- package/src/ui/js/load-font-awesome.js +1 -1
- package/src/util/base-device-parser.js +1 -1
- package/src/util/browser-detector.js +5 -5
- package/src/util/client-hints-parser.js +1 -1
- package/src/util/net.js +3 -3
- package/src/util/user-agent-parser.js +1 -1
- package/src/util/window-utils.js +1 -1
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Type definitions for @braze/web-sdk v4.
|
|
2
|
+
* Type definitions for @braze/web-sdk v4.5.1
|
|
3
3
|
* Project: https://github.com/braze-inc/braze-web-sdk
|
|
4
4
|
* (c) Braze, Inc. 2022 - http://braze.com
|
|
5
5
|
* License available at https://github.com/braze-inc/braze-web-sdk/blob/master/LICENSE
|
|
@@ -122,6 +122,9 @@
|
|
|
122
122
|
/** Whether to pin this card to the top of the view. */
|
|
123
123
|
pinned: boolean;
|
|
124
124
|
|
|
125
|
+
/** Whether this card is a ControlCard. */
|
|
126
|
+
isControl: boolean;
|
|
127
|
+
|
|
125
128
|
|
|
126
129
|
}
|
|
127
130
|
|
|
@@ -468,6 +471,12 @@
|
|
|
468
471
|
* Braze with in-app message analytics events.
|
|
469
472
|
*/
|
|
470
473
|
triggerId?: string;
|
|
474
|
+
|
|
475
|
+
/** Object of string/string key/value pairs. */
|
|
476
|
+
extras: Record<string, any>;
|
|
477
|
+
|
|
478
|
+
/** Whether this message is a ControlMessage. */
|
|
479
|
+
isControl: boolean;
|
|
471
480
|
}
|
|
472
481
|
|
|
473
482
|
|
|
@@ -588,6 +597,9 @@
|
|
|
588
597
|
*/
|
|
589
598
|
css?: string;
|
|
590
599
|
|
|
600
|
+
/** Whether this message is a ControlMessage. */
|
|
601
|
+
isControl: boolean;
|
|
602
|
+
|
|
591
603
|
/**
|
|
592
604
|
* Call this method if you wish to programmatically remove the message from the DOM. This method will only
|
|
593
605
|
* work with the Braze UI.
|
|
@@ -1932,7 +1944,7 @@
|
|
|
1932
1944
|
* - Create a `service-worker.js` file with the content below and place it in the root directory of your website:
|
|
1933
1945
|
*
|
|
1934
1946
|
* ```
|
|
1935
|
-
* self.importScripts('https://js.appboycdn.com/web-sdk-develop/4.
|
|
1947
|
+
* self.importScripts('https://js.appboycdn.com/web-sdk-develop/4.5/service-worker.js');
|
|
1936
1948
|
* ```
|
|
1937
1949
|
*
|
|
1938
1950
|
* For more details, see [Our Product Documentation](https://www.braze.com/docs/developer_guide/platform_integration_guides/web/push_notifications/integration).
|
|
@@ -2285,7 +2297,7 @@
|
|
|
2285
2297
|
* lifecycle of, set this option to true and the Braze SDK will not register or unregister a service worker. If you set this
|
|
2286
2298
|
* option to true, in order for push to function correctly you must register the service worker yourself BEFORE calling
|
|
2287
2299
|
* `requestPushPermission`, and ensure that it contains Braze's service worker code, either with
|
|
2288
|
-
* `self.importScripts('https://js.appboycdn.com/web-sdk-develop/4.
|
|
2300
|
+
* `self.importScripts('https://js.appboycdn.com/web-sdk-develop/4.5/service-worker.js');` or by including the content
|
|
2289
2301
|
* of that file directly. When this option is true, the `serviceWorkerLocation` option is irrelevant and is ignored.
|
|
2290
2302
|
*/
|
|
2291
2303
|
manageServiceWorkerExternally?: boolean;
|
package/package.json
CHANGED
|
@@ -4,5 +4,5 @@ import Ae from "./guid.js";
|
|
|
4
4
|
import Ge from "./indexed-db-adapter.js";
|
|
5
5
|
import Oe from "./logger.js";
|
|
6
6
|
import Ue from "./supported-options.js";
|
|
7
|
-
const r = {
|
|
7
|
+
const r = { kn: ve, A: De, qr: Be, it: Ae, qt: Ge, xt: Ge.ep, D: Oe, Vo: Ue };
|
|
8
8
|
export default r;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
const De = {
|
|
2
2
|
CustomEvent: "ce",
|
|
3
3
|
Pr: "p",
|
|
4
|
-
|
|
4
|
+
xl: "pc",
|
|
5
5
|
cc: "ca",
|
|
6
|
-
|
|
6
|
+
za: "i",
|
|
7
7
|
qs: "ie",
|
|
8
8
|
T: "cci",
|
|
9
9
|
W: "ccic",
|
|
@@ -16,17 +16,17 @@ const De = {
|
|
|
16
16
|
mi: "sbc",
|
|
17
17
|
ui: "sfe",
|
|
18
18
|
ro: "iec",
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
Ul: "lr",
|
|
20
|
+
Ol: "uae",
|
|
21
21
|
U: "ci",
|
|
22
22
|
F: "cc",
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
Bl: "lcaa",
|
|
24
|
+
Wl: "lcar",
|
|
25
25
|
Fn: "inc",
|
|
26
26
|
Un: "add",
|
|
27
27
|
En: "rem",
|
|
28
28
|
An: "set",
|
|
29
|
-
|
|
29
|
+
Gl: "sgu"
|
|
30
30
|
},
|
|
31
31
|
Be = { Fr: "feed_displayed", dc: "content_cards_displayed" };
|
|
32
32
|
export { De as EventTypes, Be as InternalEventTypes };
|
package/shared-lib/logger.js
CHANGED
|
@@ -24,13 +24,13 @@ const Oe = {
|
|
|
24
24
|
},
|
|
25
25
|
warn: function(n) {
|
|
26
26
|
if (Oe.zg) {
|
|
27
|
-
const o = "Braze SDK Warning: " + n + " (v4.
|
|
27
|
+
const o = "Braze SDK Warning: " + n + " (v4.5.1)";
|
|
28
28
|
null != Oe.nd ? Oe.nd(o) : console.warn(o);
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
error: function(n) {
|
|
32
32
|
if (Oe.zg) {
|
|
33
|
-
const o = "Braze SDK Error: " + n + " (v4.
|
|
33
|
+
const o = "Braze SDK Error: " + n + " (v4.5.1)";
|
|
34
34
|
null != Oe.nd ? Oe.nd(o) : console.error(o);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
Zn: "allowCrawlerActivity",
|
|
3
|
+
ho: "baseUrl",
|
|
4
|
+
po: "noCookies",
|
|
5
|
+
Eo: "devicePropertyAllowlist",
|
|
6
6
|
ta: "disablePushTokenMaintenance",
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
_o: "enableLogging",
|
|
8
|
+
Io: "enableSdkAuthentication",
|
|
9
9
|
ia: "manageServiceWorkerExternally",
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
Ao: "minimumIntervalBetweenTriggerActionsInSeconds",
|
|
11
|
+
So: "sessionTimeoutInSeconds",
|
|
12
|
+
No: "appVersion",
|
|
13
13
|
na: "serviceWorkerLocation",
|
|
14
14
|
ra: "safariWebsitePushId",
|
|
15
15
|
jn: "localization",
|
|
16
16
|
ao: "contentSecurityNonce",
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
wo: "enableHtmlInAppMessages",
|
|
18
|
+
To: "allowUserSuppliedJavascript",
|
|
19
19
|
no: "inAppMessageZIndex",
|
|
20
20
|
lo: "openInAppMessagesInNewTab",
|
|
21
21
|
en: "openNewsFeedCardsInNewTab",
|
|
22
22
|
qi: "requireExplicitInAppMessageDismissal",
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
Oo: "doNotLoadFontAwesome",
|
|
24
|
+
vo: "sdkFlavor",
|
|
25
25
|
tn: "openCardsInNewTab"
|
|
26
26
|
};
|
package/src/Card/models/card.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Card from "./card.js";
|
|
2
2
|
export default class ControlCard extends Card {
|
|
3
|
-
constructor(l, t, s, n,
|
|
3
|
+
constructor(l, t, s, n, i, u) {
|
|
4
4
|
super(
|
|
5
5
|
l,
|
|
6
6
|
t,
|
|
@@ -14,10 +14,11 @@ export default class ControlCard extends Card {
|
|
|
14
14
|
null,
|
|
15
15
|
null,
|
|
16
16
|
null,
|
|
17
|
-
u,
|
|
18
17
|
i,
|
|
18
|
+
u,
|
|
19
19
|
null
|
|
20
20
|
),
|
|
21
|
+
(this.isControl = !0),
|
|
21
22
|
(this.Y = "ab-control-card"),
|
|
22
23
|
(this.Z = !1);
|
|
23
24
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import e from "../managers/braze-instance.js";
|
|
2
2
|
import InAppMessage from "./models/in-app-message.js";
|
|
3
3
|
import pe from "./in-app-message-manager-factory.js";
|
|
4
|
+
import { logInAppMessageImpression } from "./log-in-app-message-impression.js";
|
|
4
5
|
import { MUST_BE_IN_APP_MESSAGE_WARNING as or } from "../common/constants.js";
|
|
5
6
|
import r from "../../shared-lib/braze-shared-lib.js";
|
|
6
7
|
import V from "../triggers/models/trigger-events.js";
|
|
@@ -9,8 +10,10 @@ export function logInAppMessageClick(o) {
|
|
|
9
10
|
if (!e.rr()) return !1;
|
|
10
11
|
if (!(o instanceof InAppMessage)) return r.D.error(or), !1;
|
|
11
12
|
const s = pe.m().G(o, r.A.pi);
|
|
12
|
-
if (s)
|
|
13
|
+
if (s) {
|
|
14
|
+
o.Cr() || logInAppMessageImpression(o);
|
|
13
15
|
for (let r = 0; r < s.ve.length; r++)
|
|
14
16
|
W.er().je(V.Ar, [o.triggerId], s.ve[r]);
|
|
17
|
+
}
|
|
15
18
|
return s.S;
|
|
16
19
|
}
|
|
@@ -35,8 +35,8 @@ export default class InAppMessage {
|
|
|
35
35
|
R,
|
|
36
36
|
b,
|
|
37
37
|
P,
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
p,
|
|
39
|
+
C
|
|
40
40
|
) {
|
|
41
41
|
(this.message = t),
|
|
42
42
|
(this.messageAlignment = s || InAppMessage.TextAlignment.CENTER),
|
|
@@ -67,8 +67,9 @@ export default class InAppMessage {
|
|
|
67
67
|
(this.buttons = R || []),
|
|
68
68
|
(this.cropType = b || InAppMessage.CropType.FIT_CENTER),
|
|
69
69
|
(this.orientation = P),
|
|
70
|
-
(this.htmlId =
|
|
71
|
-
(this.css =
|
|
70
|
+
(this.htmlId = p),
|
|
71
|
+
(this.css = C),
|
|
72
|
+
(this.isControl = !1),
|
|
72
73
|
(this.Ri = !1),
|
|
73
74
|
(this.nl = !1),
|
|
74
75
|
(this.Pi = !1),
|
|
@@ -108,6 +109,9 @@ export default class InAppMessage {
|
|
|
108
109
|
R() {
|
|
109
110
|
return !this.Ri && ((this.Ri = !0), !0);
|
|
110
111
|
}
|
|
112
|
+
Cr() {
|
|
113
|
+
return this.Ri;
|
|
114
|
+
}
|
|
111
115
|
k() {
|
|
112
116
|
return !this.nl && ((this.nl = !0), this.lt.St(), !0);
|
|
113
117
|
}
|
package/src/Push/push-manager.js
CHANGED
|
@@ -15,19 +15,19 @@ export default class aa {
|
|
|
15
15
|
(this.Ir = n),
|
|
16
16
|
(this.gt = o),
|
|
17
17
|
(this.Vr = u || !1),
|
|
18
|
-
(this.
|
|
18
|
+
(this.Er = a || !1),
|
|
19
19
|
(this.h = h),
|
|
20
|
-
(this.
|
|
21
|
-
(this.
|
|
20
|
+
(this.Or = dt.Br()),
|
|
21
|
+
(this.Mr = dt.Yr());
|
|
22
22
|
}
|
|
23
|
-
|
|
24
|
-
return this.
|
|
23
|
+
Gr() {
|
|
24
|
+
return this.Er;
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
Hr(i, e, t, s, n) {
|
|
27
27
|
i.unsubscribe()
|
|
28
28
|
.then(i => {
|
|
29
29
|
i
|
|
30
|
-
? this.
|
|
30
|
+
? this.Jr(e, t, s, n)
|
|
31
31
|
: (r.D.error("Failed to unsubscribe device from push."),
|
|
32
32
|
"function" == typeof n && n(!1));
|
|
33
33
|
})
|
|
@@ -36,16 +36,16 @@ export default class aa {
|
|
|
36
36
|
"function" == typeof n && n(!1);
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
|
-
|
|
39
|
+
Kr(i, e, t) {
|
|
40
40
|
const s = (i => {
|
|
41
41
|
if ("string" == typeof i) return i;
|
|
42
42
|
if (0 !== i.endpoint.indexOf("https://android.googleapis.com/gcm/send"))
|
|
43
43
|
return i.endpoint;
|
|
44
44
|
let e = i.endpoint;
|
|
45
45
|
return (
|
|
46
|
-
i.
|
|
47
|
-
-1 === i.endpoint.indexOf(i.
|
|
48
|
-
(e = i.endpoint + "/" + i.
|
|
46
|
+
i.Lr &&
|
|
47
|
+
-1 === i.endpoint.indexOf(i.Lr) &&
|
|
48
|
+
(e = i.endpoint + "/" + i.Lr),
|
|
49
49
|
e
|
|
50
50
|
);
|
|
51
51
|
})(i);
|
|
@@ -73,15 +73,15 @@ export default class aa {
|
|
|
73
73
|
.replace(/\//g, "_")
|
|
74
74
|
: null;
|
|
75
75
|
})(i);
|
|
76
|
-
this.Sr.
|
|
76
|
+
this.Sr.Qr(s, t, r, n, o), s && "function" == typeof e && e(s, r, n);
|
|
77
77
|
}
|
|
78
|
-
|
|
79
|
-
this.Sr.
|
|
78
|
+
Xr() {
|
|
79
|
+
this.Sr.Zr(!0);
|
|
80
80
|
}
|
|
81
|
-
|
|
82
|
-
this.Sr.
|
|
81
|
+
hn(i, e) {
|
|
82
|
+
this.Sr.Zr(!1), r.D.info(i), "function" == typeof e && e(!1);
|
|
83
83
|
}
|
|
84
|
-
|
|
84
|
+
fn(i, e, t, s) {
|
|
85
85
|
if ("default" === e.permission)
|
|
86
86
|
try {
|
|
87
87
|
window.safari.pushNotification.requestPermission(
|
|
@@ -93,23 +93,23 @@ export default class aa {
|
|
|
93
93
|
this.Sr.setPushNotificationSubscriptionType(
|
|
94
94
|
User.NotificationSubscriptionTypes.OPTED_IN
|
|
95
95
|
),
|
|
96
|
-
this.
|
|
96
|
+
this.fn(i, e, t, s);
|
|
97
97
|
}
|
|
98
98
|
);
|
|
99
99
|
} catch (i) {
|
|
100
|
-
this.
|
|
100
|
+
this.hn("Could not request permission for push: " + i, s);
|
|
101
101
|
}
|
|
102
102
|
else
|
|
103
103
|
"denied" === e.permission
|
|
104
|
-
? this.
|
|
104
|
+
? this.hn(
|
|
105
105
|
"The user has blocked notifications from this site, or Safari push is not configured in the Braze dashboard.",
|
|
106
106
|
s
|
|
107
107
|
)
|
|
108
108
|
: "granted" === e.permission &&
|
|
109
109
|
(r.D.info("Device successfully subscribed to push."),
|
|
110
|
-
this.
|
|
110
|
+
this.Kr(e.deviceToken, t, new Date()));
|
|
111
111
|
}
|
|
112
|
-
|
|
112
|
+
dn(i, e, t) {
|
|
113
113
|
const s = s => {
|
|
114
114
|
switch (s) {
|
|
115
115
|
case "granted":
|
|
@@ -132,14 +132,14 @@ export default class aa {
|
|
|
132
132
|
})
|
|
133
133
|
: (n = !0);
|
|
134
134
|
}
|
|
135
|
-
|
|
135
|
+
Jr(i, e, t, s) {
|
|
136
136
|
const n = { userVisibleOnly: !0 };
|
|
137
137
|
null != e && (n.applicationServerKey = e),
|
|
138
138
|
i.pushManager
|
|
139
139
|
.subscribe(n)
|
|
140
140
|
.then(i => {
|
|
141
141
|
r.D.info("Device successfully subscribed to push."),
|
|
142
|
-
this.
|
|
142
|
+
this.Kr(i, t, new Date());
|
|
143
143
|
})
|
|
144
144
|
.catch(i => {
|
|
145
145
|
dt.isPushBlocked()
|
|
@@ -148,7 +148,7 @@ export default class aa {
|
|
|
148
148
|
: r.D.error("Push subscription failed: " + i);
|
|
149
149
|
});
|
|
150
150
|
}
|
|
151
|
-
|
|
151
|
+
pn() {
|
|
152
152
|
return this.Vr
|
|
153
153
|
? navigator.serviceWorker.getRegistration()
|
|
154
154
|
: navigator.serviceWorker.register(this.Nr).then(() =>
|
|
@@ -164,13 +164,13 @@ export default class aa {
|
|
|
164
164
|
)
|
|
165
165
|
);
|
|
166
166
|
}
|
|
167
|
-
|
|
167
|
+
bn(i) {
|
|
168
168
|
this.Vr ||
|
|
169
169
|
(i.unregister(), r.D.info("Service worker successfully unregistered."));
|
|
170
170
|
}
|
|
171
171
|
subscribe(i, e) {
|
|
172
172
|
if (dt.isPushSupported()) {
|
|
173
|
-
if (this.
|
|
173
|
+
if (this.Or) {
|
|
174
174
|
if (!this.Vr && null != window.location) {
|
|
175
175
|
let i = this.Nr;
|
|
176
176
|
-1 === i.indexOf(window.location.host) &&
|
|
@@ -178,7 +178,7 @@ export default class aa {
|
|
|
178
178
|
-1 === i.indexOf(window.location.protocol) &&
|
|
179
179
|
(i = window.location.protocol + "//" + i);
|
|
180
180
|
const e = i.substr(0, i.lastIndexOf("/") + 1);
|
|
181
|
-
if (0 !== H.
|
|
181
|
+
if (0 !== H.gn().indexOf(e))
|
|
182
182
|
return void r.D.error(
|
|
183
183
|
"Cannot subscribe to push from a path higher than the service worker location (tried to subscribe from " +
|
|
184
184
|
window.location.pathname +
|
|
@@ -188,16 +188,16 @@ export default class aa {
|
|
|
188
188
|
);
|
|
189
189
|
}
|
|
190
190
|
if (dt.isPushBlocked())
|
|
191
|
-
return void this.
|
|
191
|
+
return void this.hn(
|
|
192
192
|
"Notifications from this site are blocked. This may be a temporary embargo or a permanent denial.",
|
|
193
193
|
e
|
|
194
194
|
);
|
|
195
|
-
if (this.gt && !this.gt.
|
|
195
|
+
if (this.gt && !this.gt.wn() && 0 === this.gt.Zs())
|
|
196
196
|
return (
|
|
197
197
|
r.D.info(
|
|
198
198
|
"Waiting for VAPID key from server config before subscribing to push."
|
|
199
199
|
),
|
|
200
|
-
void this.gt.
|
|
200
|
+
void this.gt.yn(() => {
|
|
201
201
|
this.subscribe(i, e);
|
|
202
202
|
})
|
|
203
203
|
);
|
|
@@ -219,7 +219,7 @@ export default class aa {
|
|
|
219
219
|
this.Sr.setPushNotificationSubscriptionType(
|
|
220
220
|
User.NotificationSubscriptionTypes.OPTED_IN
|
|
221
221
|
),
|
|
222
|
-
this.
|
|
222
|
+
this.pn()
|
|
223
223
|
.then(t => {
|
|
224
224
|
if (null == t)
|
|
225
225
|
return (
|
|
@@ -234,17 +234,17 @@ export default class aa {
|
|
|
234
234
|
let n = null;
|
|
235
235
|
if (
|
|
236
236
|
(this.gt &&
|
|
237
|
-
null != this.gt.
|
|
238
|
-
(n = r.vn
|
|
237
|
+
null != this.gt.wn() &&
|
|
238
|
+
(n = r.kn.vn(this.gt.wn())),
|
|
239
239
|
s)
|
|
240
240
|
) {
|
|
241
241
|
let u = null,
|
|
242
242
|
a = null;
|
|
243
|
-
const h = this.h.I(o.q.
|
|
243
|
+
const h = this.h.I(o.q.Pn);
|
|
244
244
|
if (h && !p(h)) {
|
|
245
245
|
let i;
|
|
246
246
|
try {
|
|
247
|
-
i = ei.
|
|
247
|
+
i = ei.Sn(h).Dn;
|
|
248
248
|
} catch (e) {
|
|
249
249
|
i = null;
|
|
250
250
|
}
|
|
@@ -268,30 +268,30 @@ export default class aa {
|
|
|
268
268
|
: r.D.info(
|
|
269
269
|
"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."
|
|
270
270
|
),
|
|
271
|
-
this.
|
|
271
|
+
this.Hr(s, t, n, i, e))
|
|
272
272
|
: s.expirationTime &&
|
|
273
273
|
new Date(s.expirationTime) <= new Date().valueOf()
|
|
274
274
|
? (r.D.info(
|
|
275
275
|
"Push subscription is expired, creating new subscription."
|
|
276
276
|
),
|
|
277
|
-
this.
|
|
277
|
+
this.Hr(s, t, n, i, e))
|
|
278
278
|
: h && p(h)
|
|
279
|
-
? this.
|
|
279
|
+
? this.Hr(s, t, n, i, e)
|
|
280
280
|
: null == a
|
|
281
281
|
? (r.D.info(
|
|
282
282
|
"No push subscription creation date found, creating new subscription."
|
|
283
283
|
),
|
|
284
|
-
this.
|
|
284
|
+
this.Hr(s, t, n, i, e))
|
|
285
285
|
: a <= new Date().valueOf()
|
|
286
286
|
? (r.D.info(
|
|
287
287
|
"Push subscription older than 6 months, creating new subscription."
|
|
288
288
|
),
|
|
289
|
-
this.
|
|
289
|
+
this.Hr(s, t, n, i, e))
|
|
290
290
|
: (r.D.info(
|
|
291
291
|
"Device already subscribed to push, sending existing subscription to backend."
|
|
292
292
|
),
|
|
293
|
-
this.
|
|
294
|
-
} else this.
|
|
293
|
+
this.Kr(s, i, u));
|
|
294
|
+
} else this.Jr(t, n, i, e);
|
|
295
295
|
})
|
|
296
296
|
.catch(i => {
|
|
297
297
|
r.D.error(
|
|
@@ -303,27 +303,27 @@ export default class aa {
|
|
|
303
303
|
r.D.error("ServiceWorker registration failed: " + i);
|
|
304
304
|
});
|
|
305
305
|
};
|
|
306
|
-
this.
|
|
307
|
-
} else if (this.
|
|
306
|
+
this.dn(u, s, t);
|
|
307
|
+
} else if (this.Mr) {
|
|
308
308
|
if (null == this.Ir || "" === this.Ir)
|
|
309
309
|
return void r.D.error(
|
|
310
310
|
"You must supply the safariWebsitePushId initialization option in order to use registerPush on Safari"
|
|
311
311
|
);
|
|
312
312
|
const t = window.safari.pushNotification.permission(this.Ir);
|
|
313
|
-
this.
|
|
313
|
+
this.fn(this.Ir, t, i, e);
|
|
314
314
|
}
|
|
315
|
-
} else r.D.info(this.
|
|
315
|
+
} else r.D.info(this._n);
|
|
316
316
|
}
|
|
317
317
|
unsubscribe(i, e) {
|
|
318
318
|
dt.isPushSupported()
|
|
319
|
-
? this.
|
|
319
|
+
? this.Or
|
|
320
320
|
? navigator.serviceWorker.getRegistration().then(t => {
|
|
321
321
|
t
|
|
322
322
|
? t.pushManager
|
|
323
323
|
.getSubscription()
|
|
324
324
|
.then(s => {
|
|
325
325
|
s &&
|
|
326
|
-
(this.
|
|
326
|
+
(this.Xr(),
|
|
327
327
|
s
|
|
328
328
|
.unsubscribe()
|
|
329
329
|
.then(s => {
|
|
@@ -336,7 +336,7 @@ export default class aa {
|
|
|
336
336
|
"Failed to unsubscribe device from push."
|
|
337
337
|
),
|
|
338
338
|
"function" == typeof e && e()),
|
|
339
|
-
this.
|
|
339
|
+
this.bn(t);
|
|
340
340
|
})
|
|
341
341
|
.catch(i => {
|
|
342
342
|
r.D.error("Push unsubscription error: " + i),
|
|
@@ -350,11 +350,11 @@ export default class aa {
|
|
|
350
350
|
: (r.D.info("Device already unsubscribed from push."),
|
|
351
351
|
"function" == typeof i && i());
|
|
352
352
|
})
|
|
353
|
-
: this.
|
|
354
|
-
(this.
|
|
353
|
+
: this.Mr &&
|
|
354
|
+
(this.Xr(),
|
|
355
355
|
r.D.info("Device unsubscribed from push."),
|
|
356
356
|
"function" == typeof i && i())
|
|
357
|
-
: r.D.info(this.
|
|
357
|
+
: r.D.info(this._n);
|
|
358
358
|
}
|
|
359
359
|
}
|
|
360
|
-
aa.
|
|
360
|
+
aa._n = "Push notifications are not supported in this browser.";
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
const dt = {
|
|
2
|
-
|
|
2
|
+
Br: () =>
|
|
3
3
|
"serviceWorker" in navigator &&
|
|
4
4
|
"undefined" != typeof ServiceWorkerRegistration &&
|
|
5
5
|
"showNotification" in ServiceWorkerRegistration.prototype &&
|
|
6
6
|
"PushManager" in window,
|
|
7
|
-
|
|
7
|
+
Yr: () =>
|
|
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: () => dt.
|
|
12
|
+
isPushSupported: () => dt.Br() || dt.Yr(),
|
|
13
13
|
isPushBlocked: () => {
|
|
14
14
|
const i =
|
|
15
15
|
dt.isPushSupported() &&
|
package/src/User/user-manager.js
CHANGED
|
@@ -44,7 +44,7 @@ export default class bt {
|
|
|
44
44
|
u
|
|
45
45
|
);
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
Qr(t, s, e, i, u) {
|
|
48
48
|
this.nu("push_token", t, !1, !0),
|
|
49
49
|
this.nu("custom_push_public_key", e, !1, !0),
|
|
50
50
|
this.nu("custom_push_user_auth", i, !1, !0),
|
|
@@ -52,9 +52,9 @@ export default class bt {
|
|
|
52
52
|
const h = r.xt.Ft,
|
|
53
53
|
n = new r.qt(h, r.D),
|
|
54
54
|
l = new ei(t, s, e, i, u);
|
|
55
|
-
this.h.B(o.q.
|
|
55
|
+
this.h.B(o.q.Pn, l.ss()), n.setItem(h.$t.cu, h.se, !0);
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
Zr(t) {
|
|
58
58
|
if (
|
|
59
59
|
(this.nu("push_token", null, !1, !0),
|
|
60
60
|
this.nu("custom_push_public_key", null, !1, !0),
|
|
@@ -64,7 +64,7 @@ export default class bt {
|
|
|
64
64
|
) {
|
|
65
65
|
const t = r.xt.Ft,
|
|
66
66
|
s = new r.qt(t, r.D);
|
|
67
|
-
this.h.B(o.q.
|
|
67
|
+
this.h.B(o.q.Pn, !1), s.setItem(t.$t.cu, t.se, !1);
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
}
|
package/src/User/user.js
CHANGED
|
@@ -236,7 +236,7 @@ export default class User {
|
|
|
236
236
|
"addToSubscriptionGroup requires a non-empty subscription group ID"
|
|
237
237
|
),
|
|
238
238
|
!1)
|
|
239
|
-
: this.si.$n(t, User.
|
|
239
|
+
: this.si.$n(t, User.Bn.SUBSCRIBED).S;
|
|
240
240
|
}
|
|
241
241
|
removeFromSubscriptionGroup(t) {
|
|
242
242
|
return !R(
|
|
@@ -249,13 +249,13 @@ export default class User {
|
|
|
249
249
|
"removeFromSubscriptionGroup requires a non-empty subscription group ID"
|
|
250
250
|
),
|
|
251
251
|
!1)
|
|
252
|
-
: this.si.$n(t, User.
|
|
252
|
+
: this.si.$n(t, User.Bn.UNSUBSCRIBED).S;
|
|
253
253
|
}
|
|
254
|
-
|
|
255
|
-
this.v.
|
|
254
|
+
Qr(t, e, s, r, i) {
|
|
255
|
+
this.v.Qr(t, e, s, r, i), this.si.Ln();
|
|
256
256
|
}
|
|
257
|
-
|
|
258
|
-
this.v.
|
|
257
|
+
Zr(t) {
|
|
258
|
+
this.v.Zr(t);
|
|
259
259
|
}
|
|
260
260
|
}
|
|
261
261
|
(User.Cn = /^[0-9 .\\(\\)\\+\\-]+$/),
|
|
@@ -272,7 +272,7 @@ export default class User {
|
|
|
272
272
|
SUBSCRIBED: "subscribed",
|
|
273
273
|
UNSUBSCRIBED: "unsubscribed"
|
|
274
274
|
}),
|
|
275
|
-
(User.
|
|
276
|
-
(User.
|
|
275
|
+
(User.Bn = { SUBSCRIBED: "subscribed", UNSUBSCRIBED: "unsubscribed" }),
|
|
276
|
+
(User.Rn = "user_id"),
|
|
277
277
|
(User.lu = "custom"),
|
|
278
278
|
(User.ee = 997);
|