@ethora/chat-component 26.2.4 → 26.2.6
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/dist/firebase-messaging-sw.js +45 -39
- package/dist/main.js +7215 -7076
- package/dist/main.js.map +1 -1
- package/dist/networking/xmppClient.d.ts +2 -0
- package/dist/utils/firebasePushNotifications.d.ts +4 -0
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
- package/public/firebase-messaging-sw.js +45 -39
|
@@ -58,6 +58,8 @@ export declare class XmppClient implements XmppClientInterface {
|
|
|
58
58
|
private maxOfflineReconnectAttempts;
|
|
59
59
|
private reconnectBaseDelayMs;
|
|
60
60
|
private pausedDueToOfflineCap;
|
|
61
|
+
private authFailureDetected;
|
|
62
|
+
private isTerminalAuthFailure;
|
|
61
63
|
constructor(username: string, password: string, xmppSettings?: xmppSettingsInterface);
|
|
62
64
|
initializeClient(): Promise<void>;
|
|
63
65
|
disconnect(): Promise<void>;
|
|
@@ -31,4 +31,8 @@ export declare function initPushNotifications(options?: FcmRegistrationOptions):
|
|
|
31
31
|
* Returns an unsubscribe function.
|
|
32
32
|
*/
|
|
33
33
|
export declare function listenForForegroundMessages(handler: (payload: MessagePayload) => void, firebaseConfig?: any): () => void;
|
|
34
|
+
/**
|
|
35
|
+
* disablePushNotifications()
|
|
36
|
+
*/
|
|
37
|
+
export declare function disablePushNotifications(): Promise<void>;
|
|
34
38
|
export {};
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const ETHORA_CHAT_COMPONENT_VERSION = "26.02.
|
|
1
|
+
export declare const ETHORA_CHAT_COMPONENT_VERSION = "26.02.06";
|
package/package.json
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
|
+
/* eslint-disable no-empty, no-restricted-globals */
|
|
2
|
+
/* eslint-env worker */
|
|
3
|
+
/* global firebase, clients */
|
|
4
|
+
|
|
1
5
|
// ── Firebase SDK ──────────────────────────────────────────────
|
|
2
|
-
importScripts(
|
|
3
|
-
|
|
6
|
+
importScripts(
|
|
7
|
+
'https://www.gstatic.com/firebasejs/10.12.0/firebase-app-compat.js'
|
|
8
|
+
);
|
|
9
|
+
importScripts(
|
|
10
|
+
'https://www.gstatic.com/firebasejs/10.12.0/firebase-messaging-compat.js'
|
|
11
|
+
);
|
|
4
12
|
|
|
5
13
|
// ── Dynamic Configuration ─────────────────────────────────────
|
|
6
14
|
const params = new URL(self.location.href).searchParams;
|
|
@@ -27,7 +35,7 @@ if (
|
|
|
27
35
|
}
|
|
28
36
|
messaging = firebase.messaging();
|
|
29
37
|
} else {
|
|
30
|
-
// console.warn('[SW] Firebase config missing → FCM disabled');
|
|
38
|
+
// console.warn('[SW] Firebase config missing → FCM disabled');
|
|
31
39
|
}
|
|
32
40
|
|
|
33
41
|
const APP_URL = self.location.origin;
|
|
@@ -39,7 +47,7 @@ const DEDUP_TTL_MS = 60_000;
|
|
|
39
47
|
function markHandledByFcm(id) {
|
|
40
48
|
if (!id) return;
|
|
41
49
|
_handledByFcm.add(id);
|
|
42
|
-
// console.log('[SW] FCM handled:', id);
|
|
50
|
+
// console.log('[SW] FCM handled:', id);
|
|
43
51
|
setTimeout(() => _handledByFcm.delete(id), DEDUP_TTL_MS);
|
|
44
52
|
}
|
|
45
53
|
|
|
@@ -86,7 +94,7 @@ function postBridgeToClients(windowClients, payload) {
|
|
|
86
94
|
|
|
87
95
|
function normalizeRawPushPayload(event) {
|
|
88
96
|
if (!event.data) {
|
|
89
|
-
// console.warn('[SW][EMPTY_PUSH] Push without payload');
|
|
97
|
+
// console.warn('[SW][EMPTY_PUSH] Push without payload');
|
|
90
98
|
return {
|
|
91
99
|
sourceType: 'empty',
|
|
92
100
|
raw: {
|
|
@@ -102,11 +110,11 @@ function normalizeRawPushPayload(event) {
|
|
|
102
110
|
try {
|
|
103
111
|
textPayload = event.data.text();
|
|
104
112
|
} catch (err) {
|
|
105
|
-
// console.warn('[SW][PUSH_TEXT_READ_FAILED]', err);
|
|
113
|
+
// console.warn('[SW][PUSH_TEXT_READ_FAILED]', err);
|
|
106
114
|
}
|
|
107
115
|
|
|
108
116
|
if (!textPayload) {
|
|
109
|
-
// console.warn('[SW][EMPTY_PUSH_TEXT] Push payload text is empty');
|
|
117
|
+
// console.warn('[SW][EMPTY_PUSH_TEXT] Push payload text is empty');
|
|
110
118
|
return {
|
|
111
119
|
sourceType: 'empty',
|
|
112
120
|
raw: {
|
|
@@ -119,13 +127,13 @@ function normalizeRawPushPayload(event) {
|
|
|
119
127
|
|
|
120
128
|
try {
|
|
121
129
|
const parsed = JSON.parse(textPayload);
|
|
122
|
-
// console.log('[SW][JSON_PUSH]', parsed);
|
|
130
|
+
// console.log('[SW][JSON_PUSH]', parsed);
|
|
123
131
|
return {
|
|
124
132
|
sourceType: 'json',
|
|
125
133
|
raw: parsed,
|
|
126
134
|
};
|
|
127
135
|
} catch (err) {
|
|
128
|
-
/* console.warn('[SW][TEXT_PUSH] Non-JSON push received, processing as plain text', {
|
|
136
|
+
/* console.warn('[SW][TEXT_PUSH] Non-JSON push received, processing as plain text', {
|
|
129
137
|
error: err,
|
|
130
138
|
rawText: textPayload,
|
|
131
139
|
});*/
|
|
@@ -144,7 +152,7 @@ function normalizeRawPushPayload(event) {
|
|
|
144
152
|
// ── FCM ───────────────────────────────────────────────────────
|
|
145
153
|
if (messaging) {
|
|
146
154
|
messaging.onBackgroundMessage((payload) => {
|
|
147
|
-
// console.log('[SW][FCM_PUSH]', payload);
|
|
155
|
+
// console.log('[SW][FCM_PUSH]', payload);
|
|
148
156
|
|
|
149
157
|
const data = payload.data || {};
|
|
150
158
|
const notification = payload.notification || {};
|
|
@@ -159,8 +167,7 @@ if (messaging) {
|
|
|
159
167
|
data.title ||
|
|
160
168
|
'New Message';
|
|
161
169
|
|
|
162
|
-
const body =
|
|
163
|
-
notification.body || data.body || 'You have a new message.';
|
|
170
|
+
const body = notification.body || data.body || 'You have a new message.';
|
|
164
171
|
|
|
165
172
|
const url = buildTargetUrl(data, notification, data.url);
|
|
166
173
|
|
|
@@ -205,13 +212,13 @@ if (messaging) {
|
|
|
205
212
|
postBridgeToClients(windowClients, bridgePayload);
|
|
206
213
|
|
|
207
214
|
if (!isAnyClientVisible(windowClients)) {
|
|
208
|
-
/* console.log(
|
|
215
|
+
/* console.log(
|
|
209
216
|
`[NotifyPolicy] source=fcm_bg action=show reason=${isSystem ? 'system' : 'background'} msgId=${messageId || ''}`
|
|
210
217
|
);*/
|
|
211
218
|
return self.registration.showNotification(title, options);
|
|
212
219
|
}
|
|
213
220
|
|
|
214
|
-
/* console.log(
|
|
221
|
+
/* console.log(
|
|
215
222
|
`[NotifyPolicy] source=fcm_bg action=skip reason=tab_visible msgId=${messageId || ''}`
|
|
216
223
|
);*/
|
|
217
224
|
});
|
|
@@ -220,7 +227,7 @@ if (messaging) {
|
|
|
220
227
|
|
|
221
228
|
// ── PUSH (WebPush / text / fallback) ──────────────────────────
|
|
222
229
|
self.addEventListener('push', (event) => {
|
|
223
|
-
// console.log('[SW] push event');
|
|
230
|
+
// console.log('[SW] push event');
|
|
224
231
|
|
|
225
232
|
const { sourceType, raw } = normalizeRawPushPayload(event);
|
|
226
233
|
|
|
@@ -239,19 +246,19 @@ self.addEventListener('push', (event) => {
|
|
|
239
246
|
null;
|
|
240
247
|
|
|
241
248
|
if (wasHandledByFcm(messageId)) {
|
|
242
|
-
// console.log(`[SW] push skipped – already handled by FCM (msgId=${messageId})`);
|
|
249
|
+
// console.log(`[SW] push skipped – already handled by FCM (msgId=${messageId})`);
|
|
243
250
|
return;
|
|
244
251
|
}
|
|
245
252
|
|
|
246
253
|
if (sourceType !== 'json') {
|
|
247
|
-
/* console.log('[SW][NON_JSON_PUSH_PROCESSED]', {
|
|
254
|
+
/* console.log('[SW][NON_JSON_PUSH_PROCESSED]', {
|
|
248
255
|
sourceType,
|
|
249
256
|
raw,
|
|
250
257
|
});*/
|
|
251
258
|
}
|
|
252
259
|
|
|
253
260
|
if (!raw.from && !raw.fcmOptions) {
|
|
254
|
-
// console.log('[SW][NON_FCM_PUSH]', raw);
|
|
261
|
+
// console.log('[SW][NON_FCM_PUSH]', raw);
|
|
255
262
|
}
|
|
256
263
|
|
|
257
264
|
const isSystem = isSystemPayload(payloadData);
|
|
@@ -270,10 +277,7 @@ self.addEventListener('push', (event) => {
|
|
|
270
277
|
'You have a new message.';
|
|
271
278
|
|
|
272
279
|
const icon =
|
|
273
|
-
raw.icon ||
|
|
274
|
-
notification.icon ||
|
|
275
|
-
notification.image ||
|
|
276
|
-
'/favicon.ico';
|
|
280
|
+
raw.icon || notification.icon || notification.image || '/favicon.ico';
|
|
277
281
|
|
|
278
282
|
const url = buildTargetUrl(
|
|
279
283
|
payloadData,
|
|
@@ -332,13 +336,13 @@ self.addEventListener('push', (event) => {
|
|
|
332
336
|
postBridgeToClients(windowClients, bridgePayload);
|
|
333
337
|
|
|
334
338
|
if (!isAnyClientVisible(windowClients)) {
|
|
335
|
-
/* console.log(
|
|
339
|
+
/* console.log(
|
|
336
340
|
`[NotifyPolicy] source=push_bg action=show type=${sourceType} msgId=${messageId || ''}`
|
|
337
341
|
);*/
|
|
338
342
|
return self.registration.showNotification(title, options);
|
|
339
343
|
}
|
|
340
344
|
|
|
341
|
-
/* console.log(
|
|
345
|
+
/* console.log(
|
|
342
346
|
`[NotifyPolicy] source=push_bg action=skip reason=tab_visible type=${sourceType} msgId=${messageId || ''}`
|
|
343
347
|
);*/
|
|
344
348
|
})
|
|
@@ -347,13 +351,13 @@ self.addEventListener('push', (event) => {
|
|
|
347
351
|
|
|
348
352
|
// ── Notification Click ────────────────────────────────────────
|
|
349
353
|
self.addEventListener('notificationclick', (event) => {
|
|
350
|
-
// console.log('[NotifyPolicy] source=push_bg action=click_start');
|
|
354
|
+
// console.log('[NotifyPolicy] source=push_bg action=click_start');
|
|
351
355
|
event.notification.close();
|
|
352
356
|
|
|
353
357
|
const targetUrl =
|
|
354
358
|
(event.notification.data && event.notification.data.url) || APP_URL;
|
|
355
359
|
|
|
356
|
-
/* console.log('[NotifyPolicy] source=push_bg action=click_url', {
|
|
360
|
+
/* console.log('[NotifyPolicy] source=push_bg action=click_url', {
|
|
357
361
|
url: targetUrl,
|
|
358
362
|
});*/
|
|
359
363
|
|
|
@@ -364,7 +368,7 @@ self.addEventListener('notificationclick', (event) => {
|
|
|
364
368
|
includeUncontrolled: true,
|
|
365
369
|
});
|
|
366
370
|
|
|
367
|
-
/* console.log('[NotifyPolicy] source=push_bg action=clients_found', {
|
|
371
|
+
/* console.log('[NotifyPolicy] source=push_bg action=clients_found', {
|
|
368
372
|
count: windowClients.length,
|
|
369
373
|
});*/
|
|
370
374
|
|
|
@@ -383,7 +387,7 @@ self.addEventListener('notificationclick', (event) => {
|
|
|
383
387
|
|
|
384
388
|
for (const client of windowClients) {
|
|
385
389
|
if (client.url === targetUrl && 'focus' in client) {
|
|
386
|
-
/* console.log('[NotifyPolicy] source=push_bg action=focus_exact', {
|
|
390
|
+
/* console.log('[NotifyPolicy] source=push_bg action=focus_exact', {
|
|
387
391
|
url: client.url,
|
|
388
392
|
});*/
|
|
389
393
|
return client.focus();
|
|
@@ -396,7 +400,7 @@ self.addEventListener('notificationclick', (event) => {
|
|
|
396
400
|
const swOrigin = self.location.origin;
|
|
397
401
|
|
|
398
402
|
if (clientOrigin === swOrigin && 'focus' in client) {
|
|
399
|
-
/* console.log(
|
|
403
|
+
/* console.log(
|
|
400
404
|
'[NotifyPolicy] source=push_bg action=focus_and_navigate',
|
|
401
405
|
{ from: client.url, to: targetUrl }
|
|
402
406
|
);*/
|
|
@@ -413,7 +417,7 @@ self.addEventListener('notificationclick', (event) => {
|
|
|
413
417
|
}
|
|
414
418
|
|
|
415
419
|
if (clients.openWindow) {
|
|
416
|
-
/* console.log('[NotifyPolicy] source=push_bg action=open_new_window', {
|
|
420
|
+
/* console.log('[NotifyPolicy] source=push_bg action=open_new_window', {
|
|
417
421
|
url: targetUrl,
|
|
418
422
|
});*/
|
|
419
423
|
return clients.openWindow(targetUrl);
|
|
@@ -432,25 +436,27 @@ self.addEventListener('notificationclick', (event) => {
|
|
|
432
436
|
|
|
433
437
|
// ── Debug / Subscription ──────────────────────────────────────
|
|
434
438
|
self.addEventListener('pushsubscriptionchange', (event) => {
|
|
435
|
-
// console.warn('[SW][POSSIBLE_DROP] subscription changed');
|
|
439
|
+
// console.warn('[SW][POSSIBLE_DROP] subscription changed');
|
|
436
440
|
event.waitUntil(
|
|
437
|
-
clients
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
+
clients
|
|
442
|
+
.matchAll({ type: 'window', includeUncontrolled: true })
|
|
443
|
+
.then((allClients) => {
|
|
444
|
+
allClients.forEach((client) => {
|
|
445
|
+
client.postMessage({
|
|
446
|
+
type: 'PUSH_SUBSCRIPTION_CHANGED',
|
|
447
|
+
});
|
|
441
448
|
});
|
|
442
|
-
})
|
|
443
|
-
})
|
|
449
|
+
})
|
|
444
450
|
);
|
|
445
451
|
});
|
|
446
452
|
|
|
447
453
|
// ── Lifecycle ─────────────────────────────────────────────────
|
|
448
454
|
self.addEventListener('activate', (event) => {
|
|
449
|
-
// console.warn('[SW] activated');
|
|
455
|
+
// console.warn('[SW] activated');
|
|
450
456
|
event.waitUntil(clients.claim());
|
|
451
457
|
});
|
|
452
458
|
|
|
453
459
|
self.addEventListener('install', (event) => {
|
|
454
|
-
// console.log('[SW] installed');
|
|
460
|
+
// console.log('[SW] installed');
|
|
455
461
|
event.waitUntil(self.skipWaiting());
|
|
456
462
|
});
|