@wireapp/core 27.1.0 → 27.2.2
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/CHANGELOG.md +30 -0
- package/package.json +3 -3
- package/src/main/Account.d.ts +9 -1
- package/src/main/Account.js +6 -2
- package/src/main/notification/NotificationBackendRepository.d.ts +4 -1
- package/src/main/notification/NotificationService.d.ts +1 -1
- package/src/main/notification/NotificationService.js +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,36 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [27.2.2](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@27.2.1...@wireapp/core@27.2.2) (2022-05-31)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* Ensure websocket messages are not handled while handling notification stream ([#4277](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/issues/4277)) ([e858923](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/commit/e858923b13d47accf95c31881aeae4c370c73dbb))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [27.2.1](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@27.2.0...@wireapp/core@27.2.1) (2022-05-31)
|
|
18
|
+
|
|
19
|
+
**Note:** Version bump only for package @wireapp/core
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# [27.2.0](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@27.1.0...@wireapp/core@27.2.0) (2022-05-30)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Features
|
|
29
|
+
|
|
30
|
+
* Add missed notifications hook ([#4275](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/issues/4275)) ([f81217b](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/commit/f81217bad53fed2e4fb163c6ae871b39ca16cf58))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
6
36
|
# [27.1.0](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@27.0.5...@wireapp/core@27.1.0) (2022-05-30)
|
|
7
37
|
|
|
8
38
|
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@types/long": "4.0.1",
|
|
7
7
|
"@types/node": "~14",
|
|
8
|
-
"@wireapp/api-client": "19.
|
|
8
|
+
"@wireapp/api-client": "19.3.1",
|
|
9
9
|
"@wireapp/cryptobox": "12.8.0",
|
|
10
10
|
"bazinga64": "5.10.0",
|
|
11
11
|
"hash.js": "1.1.7",
|
|
@@ -69,6 +69,6 @@
|
|
|
69
69
|
"test:project": "yarn dist && yarn test",
|
|
70
70
|
"test:node": "nyc jasmine --config=jasmine.json"
|
|
71
71
|
},
|
|
72
|
-
"version": "27.
|
|
73
|
-
"gitHead": "
|
|
72
|
+
"version": "27.2.2",
|
|
73
|
+
"gitHead": "765718b967368720fad3ed83f12d497c48de5bdd"
|
|
74
74
|
}
|
package/src/main/Account.d.ts
CHANGED
|
@@ -150,7 +150,7 @@ export declare class Account extends EventEmitter {
|
|
|
150
150
|
* @param callbacks callbacks that will be called to handle different events
|
|
151
151
|
* @returns close a function that will disconnect from the websocket
|
|
152
152
|
*/
|
|
153
|
-
listen({ onEvent, onConnected, onConnectionStateChanged, onNotificationStreamProgress, }?: {
|
|
153
|
+
listen({ onEvent, onConnected, onConnectionStateChanged, onNotificationStreamProgress, onMissedNotifications, }?: {
|
|
154
154
|
/**
|
|
155
155
|
* Called when a new event arrives from backend
|
|
156
156
|
* @param payload the payload of the event. Contains the raw event received and the decrypted data (if event was encrypted)
|
|
@@ -172,6 +172,14 @@ export declare class Account extends EventEmitter {
|
|
|
172
172
|
* called when the connection stateh with the backend has changed
|
|
173
173
|
*/
|
|
174
174
|
onConnectionStateChanged?: (state: WEBSOCKET_STATE) => void;
|
|
175
|
+
/**
|
|
176
|
+
* called when we detect lost notification from backend.
|
|
177
|
+
* When a client doesn't log in for a while (28 days, as of now) notifications that are older than 28 days will be deleted from backend.
|
|
178
|
+
* If the client query the backend for the notifications since a particular notification ID and this ID doesn't exist anymore on the backend, we deduce that some messages were not sync before they were removed from backend.
|
|
179
|
+
* We can then detect that something was wrong and warn the consumer that there might be some missing old messages
|
|
180
|
+
* @param {string} notificationId
|
|
181
|
+
*/
|
|
182
|
+
onMissedNotifications?: (notificationId: string) => void;
|
|
175
183
|
}): Promise<() => void>;
|
|
176
184
|
private initEngine;
|
|
177
185
|
}
|
package/src/main/Account.js
CHANGED
|
@@ -284,7 +284,7 @@ class Account extends events_1.EventEmitter {
|
|
|
284
284
|
* @param callbacks callbacks that will be called to handle different events
|
|
285
285
|
* @returns close a function that will disconnect from the websocket
|
|
286
286
|
*/
|
|
287
|
-
async listen({ onEvent = () => { }, onConnected = () => { }, onConnectionStateChanged = () => { }, onNotificationStreamProgress = () => { }, } = {}) {
|
|
287
|
+
async listen({ onEvent = () => { }, onConnected = () => { }, onConnectionStateChanged = () => { }, onNotificationStreamProgress = () => { }, onMissedNotifications = () => { }, } = {}) {
|
|
288
288
|
if (!this.apiClient.context) {
|
|
289
289
|
throw new Error('Context is not set - please login first');
|
|
290
290
|
}
|
|
@@ -329,10 +329,14 @@ class Account extends events_1.EventEmitter {
|
|
|
329
329
|
this.apiClient.transport.ws.on(tcp_1.WebSocketClient.TOPIC.ON_MESSAGE, notification => handleNotification(notification, conversation_1.PayloadBundleSource.WEBSOCKET));
|
|
330
330
|
this.apiClient.transport.ws.on(tcp_1.WebSocketClient.TOPIC.ON_STATE_CHANGE, onConnectionStateChanged);
|
|
331
331
|
const onBeforeConnect = async () => {
|
|
332
|
+
// Lock websocket in order to buffer any message that arrives while we handle the notification stream
|
|
333
|
+
this.apiClient.transport.ws.lock();
|
|
332
334
|
await this.service.notification.handleNotificationStream(async (notification, source, progress) => {
|
|
333
335
|
await handleNotification(notification, source);
|
|
334
336
|
onNotificationStreamProgress(progress);
|
|
335
|
-
});
|
|
337
|
+
}, onMissedNotifications);
|
|
338
|
+
// We can now unlock the websocket and let the new messages being handled and decrypted
|
|
339
|
+
this.apiClient.transport.ws.unlock();
|
|
336
340
|
onConnected();
|
|
337
341
|
};
|
|
338
342
|
await this.apiClient.connect(onBeforeConnect);
|
|
@@ -3,6 +3,9 @@ import type { Notification } from '@wireapp/api-client/src/notification/';
|
|
|
3
3
|
export declare class NotificationBackendRepository {
|
|
4
4
|
private readonly apiClient;
|
|
5
5
|
constructor(apiClient: APIClient);
|
|
6
|
-
getAllNotifications(clientId?: string, lastNotificationId?: string): Promise<
|
|
6
|
+
getAllNotifications(clientId?: string, lastNotificationId?: string): Promise<{
|
|
7
|
+
notifications: Notification[];
|
|
8
|
+
missedNotification?: string | undefined;
|
|
9
|
+
}>;
|
|
7
10
|
getLastNotification(clientId?: string): Promise<Notification>;
|
|
8
11
|
}
|
|
@@ -42,7 +42,7 @@ export declare class NotificationService extends EventEmitter {
|
|
|
42
42
|
getNotificationEventList(): Promise<Events.BackendEvent[]>;
|
|
43
43
|
setLastEventDate(eventDate: Date): Promise<Date>;
|
|
44
44
|
setLastNotificationId(lastNotification: Notification): Promise<string>;
|
|
45
|
-
handleNotificationStream(notificationHandler: NotificationHandler): Promise<void>;
|
|
45
|
+
handleNotificationStream(notificationHandler: NotificationHandler, onMissedNotifications: (notificationId: string) => void): Promise<void>;
|
|
46
46
|
handleNotification(notification: Notification, source: PayloadBundleSource): AsyncGenerator<HandledEventPayload>;
|
|
47
47
|
private cleanupPayloadBundle;
|
|
48
48
|
private handleEvent;
|
|
@@ -118,8 +118,11 @@ class NotificationService extends events_1.EventEmitter {
|
|
|
118
118
|
async setLastNotificationId(lastNotification) {
|
|
119
119
|
return this.database.updateLastNotificationId(lastNotification);
|
|
120
120
|
}
|
|
121
|
-
async handleNotificationStream(notificationHandler) {
|
|
122
|
-
const notifications = await this.getAllNotifications();
|
|
121
|
+
async handleNotificationStream(notificationHandler, onMissedNotifications) {
|
|
122
|
+
const { notifications, missedNotification } = await this.getAllNotifications();
|
|
123
|
+
if (missedNotification) {
|
|
124
|
+
onMissedNotifications(missedNotification);
|
|
125
|
+
}
|
|
123
126
|
for (const [index, notification] of notifications.entries()) {
|
|
124
127
|
await notificationHandler(notification, conversation_1.PayloadBundleSource.NOTIFICATION_STREAM, {
|
|
125
128
|
done: index + 1,
|