@braze/web-sdk 6.12.0 → 6.13.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 +240 -3
- package/package.json +1 -1
- package/shared-lib/event-types.js +18 -18
- package/shared-lib/indexed-db-adapter.js +58 -58
- package/shared-lib/logger.js +7 -7
- package/shared-lib/supported-options.js +25 -24
- package/src/ConversationalChat/automatically-manage-chat.js +5 -0
- package/src/ConversationalChat/chat-message-factory.js +25 -0
- package/src/ConversationalChat/chat-message.js +33 -0
- package/src/ConversationalChat/constants.js +1 -0
- package/src/ConversationalChat/conversational-chat-provider-factory.js +26 -0
- package/src/ConversationalChat/conversational-chat-provider.js +372 -0
- package/src/ConversationalChat/display/chat-widget-manager.js +113 -0
- package/src/ConversationalChat/display/chat-widget-to-html.js +58 -0
- package/src/ConversationalChat/get-chat-messages.js +7 -0
- package/src/ConversationalChat/index.js +12 -0
- package/src/ConversationalChat/is-chat-conversation-ended.js +7 -0
- package/src/ConversationalChat/is-chat-turn-errored.js +7 -0
- package/src/ConversationalChat/is-chat-turn-in-progress.js +7 -0
- package/src/ConversationalChat/register-chat-action-handler.js +10 -0
- package/src/ConversationalChat/reset-chat-conversation.js +5 -0
- package/src/ConversationalChat/retrieve-chat-config.js +7 -0
- package/src/ConversationalChat/send-chat-message.js +17 -0
- package/src/ConversationalChat/subscribe-to-chat-action.js +5 -0
- package/src/ConversationalChat/subscribe-to-chat-conversation-updated.js +5 -0
- package/src/ConversationalChat/subscribe-to-chat-message-received.js +5 -0
- package/src/ConversationalChat/trigger-chat-action.js +11 -0
- package/src/ConversationalChat/types.js +1 -0
- package/src/Core/add-sdk-metadata.js +5 -5
- package/src/Core/change-user.js +6 -6
- package/src/Core/disable-sdk.js +6 -6
- package/src/Core/enable-sdk.js +3 -3
- package/src/Core/get-device-id.js +2 -2
- package/src/Core/handle-braze-action.js +20 -13
- package/src/Core/is-disabled.js +1 -1
- package/src/Core/is-initialized.js +1 -1
- package/src/Core/log-custom-event.js +9 -9
- package/src/Core/log-ecommerce-event.js +4 -4
- package/src/Core/log-purchase.js +14 -14
- package/src/Core/open-session.js +8 -8
- package/src/Core/set-sdk-authentication-signature.js +3 -3
- package/src/Core/subscribe-to-sdk-authentication-failures.js +1 -1
- package/src/Core/wipe-data.js +1 -1
- package/src/DUST/dust-config-store.js +35 -35
- package/src/DUST/dust-message-dedup.js +3 -3
- package/src/DUST/dust-provider-factory.js +10 -10
- package/src/DUST/dust-provider.js +234 -234
- package/src/DUST/subscribe-to-dust.js +7 -7
- package/src/FeatureFlags/feature-flag-factory.js +2 -2
- package/src/FeatureFlags/feature-flag.js +4 -4
- package/src/FeatureFlags/feature-flags-provider-factory.js +11 -11
- 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 +4 -4
- 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-display-utils.js +4 -4
- package/src/InAppMessage/display/html-message-to-html.js +13 -13
- package/src/InAppMessage/display/in-app-message-to-html.js +20 -20
- package/src/InAppMessage/display/modal-utils.js +7 -7
- package/src/InAppMessage/in-app-message-factory.js +6 -6
- package/src/InAppMessage/in-app-message-manager.js +92 -92
- package/src/InAppMessage/log-in-app-message-button-click.js +9 -9
- package/src/InAppMessage/log-in-app-message-click.js +7 -7
- package/src/InAppMessage/log-in-app-message-html-click.js +6 -6
- package/src/InAppMessage/log-in-app-message-impression.js +3 -3
- package/src/InAppMessage/models/full-screen-message.js +39 -39
- package/src/InAppMessage/models/html-message.js +20 -20
- package/src/InAppMessage/models/in-app-message-button.js +2 -2
- package/src/InAppMessage/models/in-app-message.js +102 -102
- package/src/InAppMessage/models/modal-message.js +38 -38
- package/src/InAppMessage/models/slide-up-message.js +34 -34
- 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 +3 -3
- package/src/InAppMessage/ui/show-in-app-message.js +27 -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 +15 -15
- package/src/Push/push-manager.js +13 -13
- package/src/Push/register-push.js +2 -2
- package/src/Push/request-push-permission.js +2 -2
- package/src/Push/unregister-push-token-on-server.js +3 -3
- package/src/Push/unregister-push.js +3 -3
- package/src/Push/utils/push-utils.js +15 -15
- package/src/User/user-manager.js +9 -9
- package/src/User/user.js +50 -50
- package/src/common/constants.js +1 -1
- package/src/common/content-cards-display.js +22 -22
- package/src/common/event-logger.js +3 -3
- package/src/index.js +2 -9
- package/src/l10n/l10n-manager-factory.js +4 -4
- package/src/l10n/l10n-manager.js +6 -6
- package/src/managers/auth-manager.js +28 -28
- package/src/managers/braze-action-manager.js +14 -0
- package/src/managers/braze-instance.js +159 -151
- package/src/managers/device-manager.js +26 -26
- package/src/managers/network-manager.js +120 -120
- package/src/managers/server-config-manager.js +95 -86
- package/src/managers/session-manager.js +25 -25
- package/src/managers/storage-manager-factory.js +12 -12
- package/src/managers/storage-manager.js +129 -124
- package/src/managers/subscription-manager.js +8 -8
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +5 -5
- package/src/models/device.js +2 -2
- package/src/models/identifier.js +8 -8
- package/src/models/push-token.js +6 -6
- package/src/models/request-result.js +2 -2
- package/src/models/server-config.js +27 -27
- package/src/request-controller.js +117 -117
- package/src/standard-index.js +9 -0
- 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 +5 -5
- package/src/triggers/models/filter.js +31 -31
- package/src/triggers/models/in-app-message-click-data.js +9 -9
- 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 +4 -4
- package/src/triggers/models/trigger-condition.js +35 -35
- package/src/triggers/models/trigger-events.js +3 -3
- package/src/triggers/models/trigger.js +36 -36
- package/src/triggers/triggers-provider-factory.js +5 -5
- package/src/triggers/triggers-provider.js +128 -128
- package/src/types.js +2 -2
- package/src/ui/js/attach-css.js +1 -1
- package/src/ui/js/chat-widget-css.js +11 -0
- package/src/ui/js/load-font-awesome.js +1 -1
- package/src/util/base-device-parser.js +7 -7
- package/src/util/braze-actions.js +5 -5
- package/src/util/browser-detector.js +41 -41
- package/src/util/client-hints-parser.js +10 -10
- package/src/util/component-utils.js +1 -1
- package/src/util/date-utils.js +2 -2
- package/src/util/device-constants.js +5 -5
- package/src/util/dom-utils.js +8 -8
- package/src/util/ecommerce-event-validation.js +13 -13
- package/src/util/html-display-utils.js +6 -6
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +82 -44
- package/src/util/request-header-utils.js +26 -24
- package/src/util/user-agent-parser.js +21 -21
- package/src/util/validation-utils.js +29 -21
- package/src/util/window-utils.js +3 -3
|
@@ -14,13 +14,13 @@ import {
|
|
|
14
14
|
MAX_RETRIES as ii,
|
|
15
15
|
buildSseUrl as ti,
|
|
16
16
|
} from "./dust-connection-core.js";
|
|
17
|
-
import
|
|
18
|
-
import
|
|
17
|
+
import xt, { isConfigExpired as si } from "./dust-config-store.js";
|
|
18
|
+
import At from "./dust-message-dedup.js";
|
|
19
19
|
import {
|
|
20
20
|
buildTabMite as ei,
|
|
21
21
|
generateIndividual as ni,
|
|
22
22
|
} from "./dust-tab-identity.js";
|
|
23
|
-
export default class
|
|
23
|
+
export default class dr extends t {
|
|
24
24
|
constructor(i, t, s, e) {
|
|
25
25
|
super(),
|
|
26
26
|
(this.B = i),
|
|
@@ -30,59 +30,59 @@ export default class sr extends t {
|
|
|
30
30
|
(this.j = t),
|
|
31
31
|
(this.h = s),
|
|
32
32
|
(this.mite = null),
|
|
33
|
-
(this.
|
|
34
|
-
(this.
|
|
35
|
-
(this.
|
|
36
|
-
(this.
|
|
37
|
-
(this.
|
|
38
|
-
(this.
|
|
39
|
-
(this.
|
|
33
|
+
(this.Ze = null),
|
|
34
|
+
(this.Fn = null),
|
|
35
|
+
(this.Jn = null),
|
|
36
|
+
(this.Ln = e || null),
|
|
37
|
+
(this.Pn = null),
|
|
38
|
+
(this.Kn = null),
|
|
39
|
+
(this.Vn = null),
|
|
40
40
|
(this.T = null),
|
|
41
|
-
(this.
|
|
42
|
-
(this.
|
|
43
|
-
(this.
|
|
44
|
-
(this.
|
|
45
|
-
(this.
|
|
46
|
-
(this.
|
|
47
|
-
(this.
|
|
48
|
-
(this.
|
|
49
|
-
(this.
|
|
50
|
-
(this.
|
|
51
|
-
(this.
|
|
52
|
-
(this.
|
|
53
|
-
(this.
|
|
54
|
-
(this.
|
|
55
|
-
(this.
|
|
56
|
-
(this.
|
|
57
|
-
(this.
|
|
58
|
-
(this.
|
|
59
|
-
(this.
|
|
60
|
-
(this.
|
|
61
|
-
this.
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return this.
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
(this.
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return null !== this.
|
|
71
|
-
}
|
|
72
|
-
|
|
41
|
+
(this.Wn = 0),
|
|
42
|
+
(this.Qn = ii),
|
|
43
|
+
(this.Yn = null),
|
|
44
|
+
(this.Zn = null),
|
|
45
|
+
(this.ih = null),
|
|
46
|
+
(this.th = !0),
|
|
47
|
+
(this.sh = null),
|
|
48
|
+
(this.eh = null),
|
|
49
|
+
(this.nh = null),
|
|
50
|
+
(this.hh = null),
|
|
51
|
+
(this.oh = !1),
|
|
52
|
+
(this.rh = new Map()),
|
|
53
|
+
(this.lh = null),
|
|
54
|
+
(this.ah = null),
|
|
55
|
+
(this.uh = null),
|
|
56
|
+
(this.gh = null),
|
|
57
|
+
(this.dh = new xt(t)),
|
|
58
|
+
(this.mh = null),
|
|
59
|
+
(this.fh = new At(t)),
|
|
60
|
+
(this.ph = !1),
|
|
61
|
+
this.wh();
|
|
62
|
+
}
|
|
63
|
+
qn() {
|
|
64
|
+
return this.gh || (this.gh = ni()), this.gh;
|
|
65
|
+
}
|
|
66
|
+
bh() {
|
|
67
|
+
(this.Wn = 0), (this.sh = null), (this.th = !0);
|
|
68
|
+
}
|
|
69
|
+
yh() {
|
|
70
|
+
return null !== this.Kn && this.Kn === this.uh;
|
|
71
|
+
}
|
|
72
|
+
Sh(i, t) {
|
|
73
73
|
const s = i.type;
|
|
74
74
|
if (!s)
|
|
75
75
|
return void b.warn(
|
|
76
76
|
`Received real-time message without type: ${JSON.stringify(i)}`,
|
|
77
77
|
);
|
|
78
78
|
if ((b.info(`Received real-time message of type '${s}'`), "cir" === s))
|
|
79
|
-
return void this.
|
|
80
|
-
if (!this.
|
|
79
|
+
return void this.Rh(t || this.Kn);
|
|
80
|
+
if (!this.fh.Mr(s))
|
|
81
81
|
return void b.info(
|
|
82
82
|
`Another tab is handling the real-time message of type '${s}', skipping it`,
|
|
83
83
|
);
|
|
84
|
-
const e = this.
|
|
85
|
-
if (e && e
|
|
84
|
+
const e = this.rh.get(s);
|
|
85
|
+
if (e && e.$h() > 0)
|
|
86
86
|
try {
|
|
87
87
|
e.A(i);
|
|
88
88
|
} catch (i) {
|
|
@@ -90,46 +90,46 @@ export default class sr extends t {
|
|
|
90
90
|
}
|
|
91
91
|
else b.info(`No subscribers for real-time message type '${s}'`);
|
|
92
92
|
}
|
|
93
|
-
|
|
93
|
+
Rh(i) {
|
|
94
94
|
i &&
|
|
95
|
-
this.
|
|
96
|
-
(b.info("Real-time messaging connection is ready"), (this.
|
|
95
|
+
this.Ch(i) &&
|
|
96
|
+
(b.info("Real-time messaging connection is ready"), (this.uh = i));
|
|
97
97
|
}
|
|
98
|
-
|
|
99
|
-
this.
|
|
98
|
+
kh(i) {
|
|
99
|
+
this.uh === i && (this.uh = null);
|
|
100
100
|
}
|
|
101
|
-
|
|
101
|
+
wh() {
|
|
102
102
|
if (!this.j) return;
|
|
103
|
-
const i = this.
|
|
103
|
+
const i = this.dh.read();
|
|
104
104
|
i.mite && i.host
|
|
105
105
|
? ((this.mite = i.mite),
|
|
106
|
-
(this.
|
|
107
|
-
(this.
|
|
108
|
-
(this.
|
|
106
|
+
(this.Ze = i.host),
|
|
107
|
+
(this.Fn = i.auth),
|
|
108
|
+
(this.Jn = i.expiration),
|
|
109
109
|
b.info("Restored real-time messaging configuration from storage"))
|
|
110
110
|
: (i.mite || i.host) &&
|
|
111
111
|
(b.warn(
|
|
112
112
|
"Incomplete real-time messaging configuration in storage, clearing",
|
|
113
113
|
),
|
|
114
|
-
this.
|
|
114
|
+
this.jh());
|
|
115
115
|
}
|
|
116
|
-
|
|
117
|
-
const i = this.
|
|
116
|
+
xh() {
|
|
117
|
+
const i = this.dh.read();
|
|
118
118
|
i.mite &&
|
|
119
119
|
i.host &&
|
|
120
|
-
(i.auth !== this.
|
|
120
|
+
(i.auth !== this.Fn &&
|
|
121
121
|
b.info(
|
|
122
122
|
"Using real-time messaging configuration refreshed by another tab",
|
|
123
123
|
),
|
|
124
124
|
(this.mite = i.mite),
|
|
125
|
-
(this.
|
|
126
|
-
(this.
|
|
127
|
-
(this.
|
|
125
|
+
(this.Ze = i.host),
|
|
126
|
+
(this.Fn = i.auth),
|
|
127
|
+
(this.Jn = i.expiration));
|
|
128
128
|
}
|
|
129
129
|
Hr() {
|
|
130
|
-
this.
|
|
131
|
-
this.
|
|
132
|
-
((this.
|
|
130
|
+
this.lh ||
|
|
131
|
+
this.ah ||
|
|
132
|
+
((this.lh = this.Mh("ddr", (i) => {
|
|
133
133
|
var t, s, e;
|
|
134
134
|
const n = i.body;
|
|
135
135
|
if (!n) return;
|
|
@@ -145,12 +145,12 @@ export default class sr extends t {
|
|
|
145
145
|
b.info(
|
|
146
146
|
`Admin requested disconnect${p}, reconnecting in ${f}ms (r_ms=${h} + backoff=${g})`,
|
|
147
147
|
),
|
|
148
|
-
this.
|
|
149
|
-
(this.
|
|
150
|
-
(this.
|
|
148
|
+
this.Fh(),
|
|
149
|
+
(this.ih = window.setTimeout(() => {
|
|
150
|
+
(this.ih = null), this.Nh();
|
|
151
151
|
}, f));
|
|
152
152
|
})),
|
|
153
|
-
(this.
|
|
153
|
+
(this.ah = this.Mh("ttl", (i) => {
|
|
154
154
|
const t = i.body;
|
|
155
155
|
if (!t) return;
|
|
156
156
|
b.info(`ttl message: ${JSON.stringify(t)}`);
|
|
@@ -159,42 +159,42 @@ export default class sr extends t {
|
|
|
159
159
|
const e = s;
|
|
160
160
|
b.info(`Time to live set to ${e}ms, will reconnect when expired`);
|
|
161
161
|
const n = t.rcs;
|
|
162
|
-
"string" == typeof n && (this.
|
|
163
|
-
null !== this.
|
|
164
|
-
(this.
|
|
165
|
-
(this.
|
|
162
|
+
"string" == typeof n && (this.Pn = n),
|
|
163
|
+
null !== this.Zn && window.clearTimeout(this.Zn),
|
|
164
|
+
(this.Zn = window.setTimeout(() => {
|
|
165
|
+
(this.Zn = null),
|
|
166
166
|
b.info("Time to live expired, performing gapless reconnection"),
|
|
167
|
-
this.
|
|
167
|
+
this.Th();
|
|
168
168
|
}, e));
|
|
169
169
|
})));
|
|
170
170
|
}
|
|
171
|
-
|
|
172
|
-
this.
|
|
173
|
-
this.
|
|
174
|
-
((this.
|
|
175
|
-
(this.
|
|
171
|
+
Dh() {
|
|
172
|
+
this.eh ||
|
|
173
|
+
this.nh ||
|
|
174
|
+
((this.hh = () => {
|
|
175
|
+
(this.oh = !0), (this.th = !1);
|
|
176
176
|
}),
|
|
177
|
-
window.addEventListener("beforeunload", this.
|
|
178
|
-
(this.
|
|
179
|
-
(this.
|
|
180
|
-
this.
|
|
181
|
-
(this.
|
|
177
|
+
window.addEventListener("beforeunload", this.hh),
|
|
178
|
+
(this.eh = () => {
|
|
179
|
+
(this.oh = !0),
|
|
180
|
+
this.Je(),
|
|
181
|
+
(this.Kn || this.Vn) &&
|
|
182
182
|
(b.info("Page unloading, closing real-time connection gracefully"),
|
|
183
|
-
(this.
|
|
184
|
-
this.
|
|
183
|
+
(this.th = !1),
|
|
184
|
+
this.Fh());
|
|
185
185
|
}),
|
|
186
|
-
window.addEventListener("pagehide", this.
|
|
187
|
-
(this.
|
|
186
|
+
window.addEventListener("pagehide", this.eh),
|
|
187
|
+
(this.nh = (i) => {
|
|
188
188
|
i.persisted &&
|
|
189
|
-
this.
|
|
190
|
-
!this.
|
|
191
|
-
!this.
|
|
189
|
+
this.Uh() &&
|
|
190
|
+
!this.Kn &&
|
|
191
|
+
!this.Vn &&
|
|
192
192
|
(b.info("Page restored from bfcache, reconnecting"),
|
|
193
|
-
(this.
|
|
194
|
-
this.
|
|
195
|
-
this.
|
|
193
|
+
(this.oh = !1),
|
|
194
|
+
this.bh(),
|
|
195
|
+
this.Nh());
|
|
196
196
|
}),
|
|
197
|
-
window.addEventListener("pageshow", this.
|
|
197
|
+
window.addEventListener("pageshow", this.nh));
|
|
198
198
|
}
|
|
199
199
|
Et() {
|
|
200
200
|
return this.T;
|
|
@@ -202,75 +202,75 @@ export default class sr extends t {
|
|
|
202
202
|
Lt(i) {
|
|
203
203
|
this.T = i;
|
|
204
204
|
}
|
|
205
|
-
|
|
205
|
+
Mh(i, t) {
|
|
206
206
|
if ("function" != typeof t) return null;
|
|
207
|
-
let s = this.
|
|
208
|
-
return s || ((s = new f()), this.
|
|
207
|
+
let s = this.rh.get(i);
|
|
208
|
+
return s || ((s = new f()), this.rh.set(i, s), r.S(s)), s.Ut(t);
|
|
209
209
|
}
|
|
210
|
-
|
|
211
|
-
const s = this.
|
|
210
|
+
Ah(i, t) {
|
|
211
|
+
const s = this.rh.get(i);
|
|
212
212
|
s && s.removeSubscription(t);
|
|
213
213
|
}
|
|
214
|
-
|
|
215
|
-
return Boolean(this.mite && this.
|
|
214
|
+
Uh() {
|
|
215
|
+
return Boolean(this.mite && this.Ze);
|
|
216
216
|
}
|
|
217
|
-
|
|
218
|
-
return si(this.
|
|
217
|
+
Eh() {
|
|
218
|
+
return si(this.Jn);
|
|
219
219
|
}
|
|
220
|
-
|
|
220
|
+
jh() {
|
|
221
221
|
(this.mite = null),
|
|
222
|
-
(this.
|
|
223
|
-
(this.
|
|
224
|
-
(this.
|
|
225
|
-
(this.
|
|
226
|
-
this.
|
|
222
|
+
(this.Ze = null),
|
|
223
|
+
(this.Fn = null),
|
|
224
|
+
(this.Jn = null),
|
|
225
|
+
(this.Pn = null),
|
|
226
|
+
this.dh.clear();
|
|
227
227
|
}
|
|
228
|
-
|
|
228
|
+
Gh(i, t, s = !1) {
|
|
229
229
|
const e = () => {
|
|
230
230
|
"function" == typeof t && t();
|
|
231
231
|
},
|
|
232
232
|
n = () => {
|
|
233
|
-
this.
|
|
233
|
+
this.Nh(), "function" == typeof i && i();
|
|
234
234
|
};
|
|
235
|
-
if (this.
|
|
235
|
+
if (this.ph) return void e();
|
|
236
236
|
const o = this.B,
|
|
237
237
|
r = this.j;
|
|
238
238
|
if (!o || !r)
|
|
239
239
|
return (
|
|
240
240
|
b.error("NetworkManager or StorageManager not available"), void e()
|
|
241
241
|
);
|
|
242
|
-
if (!this.h || !this.h
|
|
242
|
+
if (!this.h || !this.h.Ih())
|
|
243
243
|
return (
|
|
244
244
|
b.info("Real-time messaging is not enabled, skipping refresh"), void e()
|
|
245
245
|
);
|
|
246
|
-
const a = this.
|
|
246
|
+
const a = this.mh || this.dh.Ve();
|
|
247
247
|
if (!a && !s)
|
|
248
248
|
return (
|
|
249
249
|
b.info(
|
|
250
250
|
"Another tab is refreshing real-time messaging configuration, waiting for the result",
|
|
251
251
|
),
|
|
252
|
-
void this.
|
|
252
|
+
void this.dh.Qe(
|
|
253
253
|
() => {
|
|
254
|
-
this.
|
|
254
|
+
this.xh(), n();
|
|
255
255
|
},
|
|
256
|
-
() => this.
|
|
256
|
+
() => this.Gh(i, t, !0),
|
|
257
257
|
)
|
|
258
258
|
);
|
|
259
|
-
(this.
|
|
260
|
-
this.
|
|
259
|
+
(this.mh = a),
|
|
260
|
+
this.Uh()
|
|
261
261
|
? b.info("Refreshing real-time messaging configuration")
|
|
262
262
|
: b.info("Fetching initial real-time messaging configuration");
|
|
263
263
|
const c = o.Z({}, !0),
|
|
264
|
-
u = o.tt(c, h.it.
|
|
264
|
+
u = o.tt(c, h.it.Jh),
|
|
265
265
|
g = new Date().valueOf();
|
|
266
|
-
h.nt(r, h.it.
|
|
266
|
+
h.nt(r, h.it.Jh, g),
|
|
267
267
|
l.ot({
|
|
268
268
|
url: `${o.ht()}/dust/config`,
|
|
269
269
|
headers: u,
|
|
270
270
|
data: c,
|
|
271
271
|
lt: (i) => {
|
|
272
|
-
if (!this.
|
|
273
|
-
if ((this.
|
|
272
|
+
if (!this.ph) {
|
|
273
|
+
if ((this.Je(), !o.ut(c, i, u)))
|
|
274
274
|
return (
|
|
275
275
|
b.error(
|
|
276
276
|
"Failed to validate server response for real-time messaging configuration",
|
|
@@ -280,134 +280,134 @@ export default class sr extends t {
|
|
|
280
280
|
o.ct(),
|
|
281
281
|
i.mite && i.host
|
|
282
282
|
? ((this.mite = i.mite),
|
|
283
|
-
(this.
|
|
284
|
-
(this.
|
|
285
|
-
(this.
|
|
283
|
+
(this.Ze = i.host),
|
|
284
|
+
(this.Fn = i.auth || null),
|
|
285
|
+
(this.Jn = i.expiration || null),
|
|
286
286
|
b.info(
|
|
287
287
|
"Received real-time messaging configuration from server",
|
|
288
288
|
),
|
|
289
|
-
this.
|
|
289
|
+
this.dh.write({
|
|
290
290
|
mite: this.mite,
|
|
291
|
-
host: this.
|
|
292
|
-
auth: this.
|
|
293
|
-
expiration: this.
|
|
291
|
+
host: this.Ze,
|
|
292
|
+
auth: this.Fn,
|
|
293
|
+
expiration: this.Jn,
|
|
294
294
|
}),
|
|
295
295
|
n())
|
|
296
296
|
: (b.info(
|
|
297
297
|
"Real-time messaging configuration not available - this SDK version may not be supported",
|
|
298
298
|
),
|
|
299
|
-
this.
|
|
299
|
+
this.jh(),
|
|
300
300
|
e());
|
|
301
301
|
}
|
|
302
302
|
},
|
|
303
303
|
error: (i) => {
|
|
304
|
-
this.
|
|
304
|
+
this.ph || (this.Je(), o.dt(i, "retrieving DUST config"), e());
|
|
305
305
|
},
|
|
306
306
|
});
|
|
307
307
|
}
|
|
308
|
-
|
|
309
|
-
this.
|
|
308
|
+
Je() {
|
|
309
|
+
this.mh && (this.dh.Je(this.mh), (this.mh = null));
|
|
310
310
|
}
|
|
311
|
-
|
|
312
|
-
if (!this.
|
|
313
|
-
if (this.
|
|
311
|
+
Nh() {
|
|
312
|
+
if (!this.ph && this.h && this.h.Ih())
|
|
313
|
+
if (this.Vn)
|
|
314
314
|
b.info("Real-time messaging connection attempt already in progress");
|
|
315
315
|
else {
|
|
316
|
-
if ((this.
|
|
317
|
-
return this.
|
|
316
|
+
if ((this.xh(), this.Uh()))
|
|
317
|
+
return this.Eh()
|
|
318
318
|
? (b.info(
|
|
319
319
|
"Real-time messaging auth token has expired, refreshing configuration",
|
|
320
320
|
),
|
|
321
|
-
void this.
|
|
321
|
+
void this.Gh(void 0, () => {
|
|
322
322
|
b.error(
|
|
323
323
|
"Failed to refresh expired real-time messaging configuration",
|
|
324
324
|
);
|
|
325
325
|
}))
|
|
326
326
|
: void (
|
|
327
|
-
this.
|
|
328
|
-
(this.
|
|
329
|
-
(this.
|
|
327
|
+
this.Lh() &&
|
|
328
|
+
(this.Ln || this.Ze) &&
|
|
329
|
+
(this.Kn &&
|
|
330
330
|
(b.info(
|
|
331
331
|
"Real-time connection already exists, closing before starting new subscription",
|
|
332
332
|
),
|
|
333
|
-
this.
|
|
334
|
-
this.
|
|
333
|
+
this.Fh()),
|
|
334
|
+
this.Oh())
|
|
335
335
|
);
|
|
336
336
|
b.error("Cannot start real-time subscription without configuration");
|
|
337
337
|
}
|
|
338
338
|
}
|
|
339
|
-
|
|
340
|
-
return this.mite ? ei(this.mite, this.
|
|
339
|
+
Lh() {
|
|
340
|
+
return this.mite ? ei(this.mite, this.qn()) : null;
|
|
341
341
|
}
|
|
342
|
-
|
|
343
|
-
const i = this.
|
|
344
|
-
t = this.
|
|
342
|
+
Ph() {
|
|
343
|
+
const i = this.Lh(),
|
|
344
|
+
t = this.Ln || this.Ze;
|
|
345
345
|
return i && t
|
|
346
|
-
? ti(t, i, this.
|
|
346
|
+
? ti(t, i, this.Wn, this.Fn || void 0, this.Pn || void 0)
|
|
347
347
|
: null;
|
|
348
348
|
}
|
|
349
|
-
|
|
350
|
-
return this.
|
|
349
|
+
Ch(i) {
|
|
350
|
+
return this.Kn === i || this.Vn === i;
|
|
351
351
|
}
|
|
352
|
-
|
|
353
|
-
if (this.
|
|
354
|
-
const t = this.
|
|
352
|
+
Oh(i) {
|
|
353
|
+
if (this.ph) return;
|
|
354
|
+
const t = this.Ph();
|
|
355
355
|
if (t) {
|
|
356
|
-
this.
|
|
356
|
+
this.Ln && b.info(`Using custom real-time messaging host: ${this.Ln}`);
|
|
357
357
|
try {
|
|
358
358
|
const s = new EventSource(t);
|
|
359
|
-
(this.
|
|
359
|
+
(this.Vn = s),
|
|
360
360
|
b.info(`createConnection: ${t}`),
|
|
361
361
|
(s.onopen = () => {
|
|
362
|
-
this.
|
|
363
|
-
? (this.
|
|
362
|
+
this.Ch(s)
|
|
363
|
+
? (this.Vn === s && (this.Vn = null),
|
|
364
364
|
i
|
|
365
365
|
? (b.info(
|
|
366
366
|
"Gapless reconnection: new connection established, closing old connection",
|
|
367
367
|
),
|
|
368
368
|
i.close())
|
|
369
369
|
: b.info("Real-time messaging connection established"),
|
|
370
|
-
(this.
|
|
371
|
-
this.
|
|
372
|
-
(this.
|
|
373
|
-
(this.
|
|
374
|
-
(this.
|
|
370
|
+
(this.Kn = s),
|
|
371
|
+
this.uh !== s && (this.uh = null),
|
|
372
|
+
(this.Wn = 0),
|
|
373
|
+
(this.sh = null),
|
|
374
|
+
(this.th = !0))
|
|
375
375
|
: s.close();
|
|
376
376
|
}),
|
|
377
377
|
s.addEventListener("msg", (i) => {
|
|
378
|
-
if (!this.
|
|
378
|
+
if (!this.Ch(s))
|
|
379
379
|
return (
|
|
380
380
|
b.info("Ignoring real-time message from superseded connection"),
|
|
381
381
|
void s.close()
|
|
382
382
|
);
|
|
383
|
-
this.
|
|
383
|
+
this.qh(i.data, s);
|
|
384
384
|
}),
|
|
385
385
|
(s.onerror = () => {
|
|
386
386
|
const t = s.readyState;
|
|
387
|
-
if (this.
|
|
387
|
+
if (this.Ch(s)) {
|
|
388
388
|
if (
|
|
389
|
-
(this.
|
|
389
|
+
(this.oh ||
|
|
390
390
|
(0 === t
|
|
391
391
|
? b.info("Real-time messaging failed to connect")
|
|
392
392
|
: b.info("Real-time messaging connection lost")),
|
|
393
|
-
i && this.
|
|
393
|
+
i && this.Kn !== s)
|
|
394
394
|
)
|
|
395
395
|
return (
|
|
396
396
|
b.info("Gapless reconnection failed, keeping old connection"),
|
|
397
397
|
s.close(),
|
|
398
|
-
this.
|
|
399
|
-
void (this.
|
|
398
|
+
this.Vn === s && (this.Vn = null),
|
|
399
|
+
void (this.th && this.Wn < this.Qn && this.Bh())
|
|
400
400
|
);
|
|
401
|
-
if (this.
|
|
402
|
-
return s.close(), (this.
|
|
403
|
-
this.
|
|
404
|
-
this.
|
|
405
|
-
? this.
|
|
406
|
-
: (this.
|
|
401
|
+
if (this.Vn && this.Kn === s)
|
|
402
|
+
return s.close(), (this.Kn = null), void this.kh(s);
|
|
403
|
+
this.Fh(),
|
|
404
|
+
this.th && this.Wn < this.Qn
|
|
405
|
+
? this.Bh()
|
|
406
|
+
: (this.Wn >= this.Qn &&
|
|
407
407
|
b.error(
|
|
408
|
-
`Max retry attempts (${this.
|
|
408
|
+
`Max retry attempts (${this.Qn}) reached for real-time messaging, giving up for current session`,
|
|
409
409
|
),
|
|
410
|
-
(this.
|
|
410
|
+
(this.th = !1));
|
|
411
411
|
} else s.close();
|
|
412
412
|
});
|
|
413
413
|
} catch (i) {
|
|
@@ -419,59 +419,59 @@ export default class sr extends t {
|
|
|
419
419
|
}
|
|
420
420
|
}
|
|
421
421
|
}
|
|
422
|
-
|
|
422
|
+
Bh() {
|
|
423
423
|
var i, t, s;
|
|
424
|
-
this.
|
|
424
|
+
this.Wn++;
|
|
425
425
|
const e = (null === (i = this.h) || void 0 === i ? void 0 : i.vt()) || d,
|
|
426
426
|
n = (null === (t = this.h) || void 0 === t ? void 0 : t.gt()) || m,
|
|
427
427
|
h = (null === (s = this.h) || void 0 === s ? void 0 : s.bt()) || c;
|
|
428
|
-
let o = this.
|
|
428
|
+
let o = this.sh;
|
|
429
429
|
(null == o || o < e) && (o = e);
|
|
430
430
|
const r = Math.min(h, a(e, o * n));
|
|
431
|
-
(this.
|
|
431
|
+
(this.sh = r),
|
|
432
432
|
b.info(
|
|
433
|
-
`Retrying real-time messaging connection in ${r}ms (attempt ${this.
|
|
433
|
+
`Retrying real-time messaging connection in ${r}ms (attempt ${this.Wn}/${this.Qn})`,
|
|
434
434
|
),
|
|
435
|
-
(this.
|
|
436
|
-
(this.
|
|
435
|
+
(this.Yn = window.setTimeout(() => {
|
|
436
|
+
(this.Yn = null), this.Nh();
|
|
437
437
|
}, r));
|
|
438
438
|
}
|
|
439
|
-
|
|
440
|
-
if (this.
|
|
439
|
+
Th() {
|
|
440
|
+
if (this.Vn)
|
|
441
441
|
b.info("Real-time messaging connection attempt already in progress");
|
|
442
442
|
else {
|
|
443
|
-
if ((this.
|
|
444
|
-
return this.
|
|
443
|
+
if ((this.xh(), this.Uh()))
|
|
444
|
+
return this.Eh()
|
|
445
445
|
? (b.info(
|
|
446
446
|
"Auth token expired during gapless reconnection, falling back to regular reconnection",
|
|
447
447
|
),
|
|
448
|
-
this.
|
|
449
|
-
void this.
|
|
450
|
-
: void (this.
|
|
448
|
+
this.Fh(),
|
|
449
|
+
void this.Nh())
|
|
450
|
+
: void (this.Vn
|
|
451
451
|
? b.info(
|
|
452
452
|
"Real-time connection attempt already in progress, skipping gapless reconnection",
|
|
453
453
|
)
|
|
454
|
-
: (null !== this.
|
|
455
|
-
(window.clearTimeout(this.
|
|
456
|
-
this.
|
|
454
|
+
: (null !== this.Zn &&
|
|
455
|
+
(window.clearTimeout(this.Zn), (this.Zn = null)),
|
|
456
|
+
this.Oh(this.Kn || void 0)));
|
|
457
457
|
b.error("Cannot perform gapless reconnection without configuration");
|
|
458
458
|
}
|
|
459
459
|
}
|
|
460
|
-
|
|
461
|
-
null !== this.
|
|
462
|
-
null !== this.
|
|
463
|
-
null !== this.
|
|
464
|
-
(this.
|
|
465
|
-
this.
|
|
466
|
-
this.
|
|
467
|
-
(this.
|
|
468
|
-
(this.
|
|
460
|
+
Fh() {
|
|
461
|
+
null !== this.Yn && (window.clearTimeout(this.Yn), (this.Yn = null)),
|
|
462
|
+
null !== this.Zn && (window.clearTimeout(this.Zn), (this.Zn = null)),
|
|
463
|
+
null !== this.ih && (window.clearTimeout(this.ih), (this.ih = null)),
|
|
464
|
+
(this.uh = null),
|
|
465
|
+
this.Vn && (this.Vn.close(), (this.Vn = null)),
|
|
466
|
+
this.Kn &&
|
|
467
|
+
(this.Kn.close(),
|
|
468
|
+
(this.Kn = null),
|
|
469
469
|
b.info("Real-time messaging connection closed"));
|
|
470
470
|
}
|
|
471
|
-
|
|
471
|
+
qh(i, t) {
|
|
472
472
|
try {
|
|
473
473
|
const s = JSON.parse(i);
|
|
474
|
-
this.
|
|
474
|
+
this.Sh(s, t);
|
|
475
475
|
} catch (i) {
|
|
476
476
|
b.warn(
|
|
477
477
|
`Failed to parse real-time message: ${
|
|
@@ -481,42 +481,42 @@ export default class sr extends t {
|
|
|
481
481
|
}
|
|
482
482
|
}
|
|
483
483
|
changeUser(i = !1) {
|
|
484
|
-
this.
|
|
484
|
+
this.Fh(),
|
|
485
485
|
i ||
|
|
486
|
-
(this.
|
|
486
|
+
(this.Uh() &&
|
|
487
487
|
b.info(
|
|
488
488
|
"Clearing cached real-time messaging configuration for user change",
|
|
489
489
|
),
|
|
490
|
-
this.
|
|
491
|
-
this.
|
|
490
|
+
this.jh()),
|
|
491
|
+
this.bh();
|
|
492
492
|
}
|
|
493
493
|
clearData(i = !1) {
|
|
494
|
-
(this.
|
|
495
|
-
this.
|
|
494
|
+
(this.th = !1),
|
|
495
|
+
this.Fh(),
|
|
496
496
|
i &&
|
|
497
|
-
(this.
|
|
497
|
+
(this.Uh() &&
|
|
498
498
|
b.info(
|
|
499
499
|
"Clearing cached real-time messaging configuration (wipeData)",
|
|
500
500
|
),
|
|
501
|
-
this.
|
|
502
|
-
this.
|
|
503
|
-
this.
|
|
501
|
+
this.jh(),
|
|
502
|
+
this.fh.Wr()),
|
|
503
|
+
this.bh();
|
|
504
504
|
}
|
|
505
505
|
destroy() {
|
|
506
|
-
(this.
|
|
507
|
-
(this.
|
|
508
|
-
this.
|
|
509
|
-
this.
|
|
510
|
-
this.
|
|
511
|
-
this.
|
|
512
|
-
this.
|
|
513
|
-
this.
|
|
514
|
-
this.
|
|
515
|
-
(window.removeEventListener("beforeunload", this.
|
|
516
|
-
this.
|
|
517
|
-
(window.removeEventListener("pagehide", this.
|
|
518
|
-
this.
|
|
519
|
-
(window.removeEventListener("pageshow", this.
|
|
506
|
+
(this.ph = !0),
|
|
507
|
+
(this.th = !1),
|
|
508
|
+
this.Fh(),
|
|
509
|
+
this.Je(),
|
|
510
|
+
this.dh.destroy(),
|
|
511
|
+
this.jh(),
|
|
512
|
+
this.lh && (this.Ah("ddr", this.lh), (this.lh = null)),
|
|
513
|
+
this.ah && (this.Ah("ttl", this.ah), (this.ah = null)),
|
|
514
|
+
this.hh &&
|
|
515
|
+
(window.removeEventListener("beforeunload", this.hh), (this.hh = null)),
|
|
516
|
+
this.eh &&
|
|
517
|
+
(window.removeEventListener("pagehide", this.eh), (this.eh = null)),
|
|
518
|
+
this.nh &&
|
|
519
|
+
(window.removeEventListener("pageshow", this.nh), (this.nh = null)),
|
|
520
520
|
this.T && (r.removeSubscription(this.T), (this.T = null));
|
|
521
521
|
}
|
|
522
522
|
}
|