@wireapp/core 46.31.0 → 46.31.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/lib/Account.d.ts CHANGED
@@ -122,9 +122,9 @@ export declare class Account extends TypedEventEmitter<Events> {
122
122
  * - useVersion(0, 1, true) > version 1 is used
123
123
  * @return The highest version that is both supported by client and backend
124
124
  */
125
- useAPIVersion(min: number, max: number, allowDev?: boolean): Promise<BackendFeatures>;
125
+ useAPIVersion: (min: number, max: number, allowDev?: boolean) => Promise<BackendFeatures>;
126
126
  private persistCookie;
127
- enrollE2EI({ displayName, handle, teamId, discoveryUrl, getOAuthToken, getAllConversations, certificateTtl, }: {
127
+ enrollE2EI: ({ displayName, handle, teamId, discoveryUrl, getOAuthToken, getAllConversations, certificateTtl, }: {
128
128
  /** display name of the user (should match the identity provider) */
129
129
  displayName: string;
130
130
  /** handle of the user (should match the identity provider) */
@@ -138,7 +138,7 @@ export declare class Account extends TypedEventEmitter<Events> {
138
138
  getAllConversations: getAllConversationsCallback;
139
139
  /** number of seconds the certificate should be valid (default 90 days) */
140
140
  certificateTtl?: number;
141
- }): Promise<void>;
141
+ }) => Promise<void>;
142
142
  get clientId(): string;
143
143
  get userId(): string;
144
144
  /**
@@ -147,33 +147,31 @@ export declare class Account extends TypedEventEmitter<Events> {
147
147
  * @param registration The user's data
148
148
  * @param clientType Type of client to create (temporary or permanent)
149
149
  */
150
- register(registration: RegisterData, clientType: ClientType): Promise<Context>;
150
+ register: (registration: RegisterData, clientType: ClientType) => Promise<Context>;
151
151
  /**
152
152
  * Will init the core with an already logged in user
153
153
  *
154
154
  * @param clientType The type of client the user is using (temporary or permanent)
155
155
  */
156
- init(clientType: ClientType, { cookie }?: InitOptions): Promise<Context>;
156
+ init: (clientType: ClientType, { cookie }?: InitOptions) => Promise<Context>;
157
157
  /**
158
158
  * Will log the user in with the given credential.
159
159
  *
160
160
  * @param loginData The credentials of the user
161
161
  * @param clientInfo Info about the client to create (name, type...)
162
162
  */
163
- login(loginData: LoginData): Promise<Context>;
163
+ login: (loginData: LoginData) => Promise<Context>;
164
164
  /**
165
165
  * Will register a new client for the current user
166
166
  */
167
- registerClient(loginData: LoginData, clientInfo?: ClientInfo,
168
- /** will add extra manual entropy to the client's identity being created */
169
- entropyData?: Uint8Array): Promise<RegisteredClient>;
167
+ registerClient: (loginData: LoginData, clientInfo?: ClientInfo, entropyData?: Uint8Array) => Promise<RegisteredClient>;
170
168
  getLocalClient(): Promise<import("./client/ClientService").MetaClient | undefined> | undefined;
171
169
  /**
172
170
  * Will initiate all the cryptographic material of the given registered device and setup all the background tasks.
173
171
  *
174
172
  * @returns The local existing client or undefined if the client does not exist or is not valid (non existing on backend)
175
173
  */
176
- initClient(client: RegisteredClient, mlsConfig?: InitClientOptions): Promise<RegisteredClient>;
174
+ initClient: (client: RegisteredClient, mlsConfig?: InitClientOptions) => Promise<RegisteredClient>;
177
175
  private buildCryptoClient;
178
176
  /**
179
177
  * In order to be able to send MLS messages, the core needs a few information from the consumer.
@@ -182,17 +180,17 @@ export declare class Account extends TypedEventEmitter<Events> {
182
180
  * - what is the groupId of a conversation
183
181
  * @param coreCallbacks
184
182
  */
185
- configureCoreCallbacks(coreCallbacks: CoreCallbacks): void;
183
+ configureCoreCallbacks: (coreCallbacks: CoreCallbacks) => void;
186
184
  private initServices;
187
185
  private resetContext;
188
186
  /**
189
187
  * Will logout the current user
190
188
  * @param clearData if set to `true` will completely wipe any database that was created by the Account
191
189
  */
192
- logout(data?: {
190
+ logout: (data?: {
193
191
  clearAllData?: boolean;
194
192
  clearCryptoData?: boolean;
195
- }): Promise<void>;
193
+ }) => Promise<void>;
196
194
  private wipeCommonData;
197
195
  /**
198
196
  * Will delete the identity and history of the current user
@@ -214,7 +212,7 @@ export declare class Account extends TypedEventEmitter<Events> {
214
212
  * @param callbacks callbacks that will be called to handle different events
215
213
  * @returns close a function that will disconnect from the websocket
216
214
  */
217
- listen({ onEvent, onConnectionStateChanged: onConnectionStateChangedCallBack, onNotificationStreamProgress, onMissedNotifications, dryRun, }?: {
215
+ listen: ({ onEvent, onConnectionStateChanged: onConnectionStateChangedCallBack, onNotificationStreamProgress, onMissedNotifications, dryRun, }?: {
218
216
  /**
219
217
  * Called when a new event arrives from backend
220
218
  * @param payload the payload of the event. Contains the raw event received and the decrypted data (if event was encrypted)
@@ -241,7 +239,7 @@ export declare class Account extends TypedEventEmitter<Events> {
241
239
  * When set will not decrypt and not store the last notification ID. This is useful if you only want to subscribe to unencrypted backend events
242
240
  */
243
241
  dryRun?: boolean;
244
- }): Promise<() => void>;
242
+ }) => Promise<() => void>;
245
243
  private createConnectionStateChangedHandler;
246
244
  /**
247
245
  * Creates the event handler that is invoked for each decrypted event from the backend.
@@ -257,10 +255,11 @@ export declare class Account extends TypedEventEmitter<Events> {
257
255
  */
258
256
  private createLegacyNotificationHandler;
259
257
  private createNotificationHandler;
258
+ private handleNotificationQueueError;
260
259
  private acknowledgeSynchronizationNotification;
261
260
  private handleSynchronizationNotification;
262
261
  private decryptAckEmitNotification;
263
- getNotificationEventTime(backendEvent: Events.BackendEvent): string | null;
262
+ getNotificationEventTime: (backendEvent: Events.BackendEvent) => string | null;
264
263
  /**
265
264
  * Returns a function to handle missed notifications — i.e., when the backend indicates
266
265
  * that some notifications were lost due to age (typically >28 days).
@@ -283,6 +282,13 @@ export declare class Account extends TypedEventEmitter<Events> {
283
282
  * @param handlers Various logic handlers wired to notification callbacks
284
283
  */
285
284
  private createLegacyNotificationStreamProcessor;
285
+ /**
286
+ * In case of a closed connection, we flush the notification processing queue.
287
+ * As we are not acknowledging them before decryption is done
288
+ * they will be resent next time the connection is opened
289
+ * this is to avoid duplicate decryption of notifications
290
+ */
291
+ private pauseAndFlushNotificationQueue;
286
292
  /**
287
293
  * Sets up WebSocket event listeners for:
288
294
  * - Incoming backend messages
@@ -313,14 +319,14 @@ export declare class Account extends TypedEventEmitter<Events> {
313
319
  * then we remove the flag.
314
320
  */
315
321
  private reactToMissedNotification;
316
- getClientCapabilities(): ClientCapability[];
317
- checkIsConsumable(notification: Notification | ConsumableNotification): notification is ConsumableNotification;
322
+ getClientCapabilities: () => ClientCapability[];
323
+ checkIsConsumable: (notification: Notification | ConsumableNotification) => notification is ConsumableNotification;
318
324
  private generateDbName;
319
325
  private generateCoreDbName;
320
326
  private generateEncryptedDbName;
321
327
  private initEngine;
322
328
  private groupIdFromConversationId;
323
- isMLSActiveForClient(): Promise<boolean>;
329
+ isMLSActiveForClient: () => Promise<boolean>;
324
330
  }
325
331
  export {};
326
332
  //# sourceMappingURL=Account.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Account.d.ts","sourceRoot":"","sources":["../src/Account.ts"],"names":[],"mappings":"AAmBA,OAAO,EACL,YAAY,EAGZ,OAAO,EACP,MAAM,EAEN,SAAS,EAEV,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAC,gBAAgB,EAAwB,UAAU,EAAE,gBAAgB,EAAC,MAAM,iCAAiC,CAAC;AAErH,OAAO,KAAK,MAAM,MAAM,+BAA+B,CAAC;AAExD,OAAO,EAAC,YAAY,EAAC,MAAM,uCAAuC,CAAC;AACnE,OAAO,EAEL,sBAAsB,EAGvB,MAAM,6DAA6D,CAAC;AAQrE,OAAO,EAAC,SAAS,EAAE,eAAe,EAAC,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAa,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AAE/D,OAAO,EAAC,UAAU,EAAe,MAAM,uBAAuB,CAAC;AAE/D,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAC;AAE1C,OAAO,EAAC,gBAAgB,EAAC,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAC,UAAU,EAAE,aAAa,EAAC,MAAM,WAAW,CAAC;AACpD,OAAO,EAAC,iBAAiB,EAAC,MAAM,eAAe,CAAC;AAChD,OAAO,EAAC,YAAY,EAAE,mBAAmB,EAAC,MAAM,iBAAiB,CAAC;AAElE,OAAO,E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,MAAM,CAAC,EAAE,OAAO,CAAC;KAClB,KAAQ,OAAO,CAAC,MAAM,IAAI,CAAC,CAyE1B;IAEF,OAAO,CAAC,mCAAmC,CAQzC;IAEF;;;;OAIG;IACH,OAAO,CAAC,kBAAkB,CAkBxB;IAEF;;;;;OAKG;IACH,OAAO,CAAC,+BAA+B,CAkBrC;IAEF,OAAO,CAAC,yBAAyB,CA6B/B;IAEF,OAAO,CAAC,4BAA4B,CAOlC;IAEF,OAAO,CAAC,sCAAsC,CAE5C;IAEF,OAAO,CAAC,iCAAiC,CAmBvC;IAEF,OAAO,CAAC,0BAA0B,CAyBhC;IAEK,wBAAwB,iBAAkB,MAAM,CAAC,YAAY,mBAMlE;IAEF;;;;;;;;OAQG;IACH,OAAO,CAAC,sCAAsC,CAU5C;IAEF;;;;;;;;;;OAUG;IACH,OAAO,CAAC,uCAAuC,CAkC7C;IAEF;;;;;OAKG;IACH,OAAO,CAAC,8BAA8B,CAIpC;IAEF;;;;;;OAMG;IACH,OAAO,CAAC,uBAAuB,CA0B7B;IAEF;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,OAAO,CAAC,yBAAyB,CAa/B;IAEK,qBAAqB,2BAE1B;IAEK,iBAAiB,iBACR,YAAY,GAAG,sBAAsB,KAClD,YAAY,IAAI,sBAAsB,CAEvC;IAEF,OAAO,CAAC,cAAc,CAGpB;IAEF,OAAO,CAAC,kBAAkB,CAExB;IAEF,OAAO,CAAC,uBAAuB,CAE7B;IAEF,OAAO,CAAC,UAAU,CAqBhB;IAEF,OAAO,CAAC,yBAAyB,CAS/B;IAEK,oBAAoB,QAAa,OAAO,CAAC,OAAO,CAAC,CActD;CACH"}
package/lib/Account.js CHANGED
@@ -165,16 +165,16 @@ class Account extends commons_1.TypedEventEmitter {
165
165
  * - useVersion(0, 1, true) > version 1 is used
166
166
  * @return The highest version that is both supported by client and backend
167
167
  */
168
- async useAPIVersion(min, max, allowDev) {
168
+ useAPIVersion = async (min, max, allowDev) => {
169
169
  const features = await this.apiClient.useVersion(min, max, allowDev);
170
170
  this.backendFeatures = features;
171
171
  return features;
172
- }
173
- persistCookie(storeEngine, cookie) {
172
+ };
173
+ persistCookie = (storeEngine, cookie) => {
174
174
  const entity = { expiration: cookie.expiration, zuid: cookie.zuid };
175
175
  return storeEngine.updateOrCreate(auth_1.AUTH_TABLE_NAME, auth_1.AUTH_COOKIE_KEY, entity);
176
- }
177
- async enrollE2EI({ displayName, handle, teamId, discoveryUrl, getOAuthToken, getAllConversations, certificateTtl = 90 * (TimeUtil_1.TimeInMillis.DAY / 1000), }) {
176
+ };
177
+ enrollE2EI = async ({ displayName, handle, teamId, discoveryUrl, getOAuthToken, getAllConversations, certificateTtl = 90 * (TimeUtil_1.TimeInMillis.DAY / 1000), }) => {
178
178
  const context = this.apiClient.context;
179
179
  const domain = context?.domain ?? '';
180
180
  if (!this.currentClient) {
@@ -191,7 +191,7 @@ class Account extends commons_1.TypedEventEmitter {
191
191
  id: this.userId,
192
192
  };
193
193
  return this.service.mls.enrollE2EI(discoveryUrl, user, this.currentClient, this.options.nbPrekeys, certificateTtl, getOAuthToken, getAllConversations);
194
- }
194
+ };
195
195
  get clientId() {
196
196
  return this.apiClient.validatedClientId;
197
197
  }
@@ -204,40 +204,40 @@ class Account extends commons_1.TypedEventEmitter {
204
204
  * @param registration The user's data
205
205
  * @param clientType Type of client to create (temporary or permanent)
206
206
  */
207
- async register(registration, clientType) {
207
+ register = async (registration, clientType) => {
208
208
  const context = await this.apiClient.register(registration, clientType);
209
209
  await this.initServices(context);
210
210
  return context;
211
- }
211
+ };
212
212
  /**
213
213
  * Will init the core with an already logged in user
214
214
  *
215
215
  * @param clientType The type of client the user is using (temporary or permanent)
216
216
  */
217
- async init(clientType, { cookie } = {}) {
217
+ init = async (clientType, { cookie } = {}) => {
218
218
  const context = await this.apiClient.init(clientType, cookie);
219
219
  await this.initServices(context);
220
220
  return context;
221
- }
221
+ };
222
222
  /**
223
223
  * Will log the user in with the given credential.
224
224
  *
225
225
  * @param loginData The credentials of the user
226
226
  * @param clientInfo Info about the client to create (name, type...)
227
227
  */
228
- async login(loginData) {
228
+ login = async (loginData) => {
229
229
  this.resetContext();
230
230
  auth_2.LoginSanitizer.removeNonPrintableCharacters(loginData);
231
231
  const context = await this.apiClient.login(loginData);
232
232
  await this.initServices(context);
233
233
  return context;
234
- }
234
+ };
235
235
  /**
236
236
  * Will register a new client for the current user
237
237
  */
238
- async registerClient(loginData, clientInfo = coreDefaultClient,
238
+ registerClient = async (loginData, clientInfo = coreDefaultClient,
239
239
  /** will add extra manual entropy to the client's identity being created */
240
- entropyData) {
240
+ entropyData) => {
241
241
  if (!this.service || !this.apiClient.context || !this.storeEngine) {
242
242
  throw new Error('Services are not set or context not initialized.');
243
243
  }
@@ -246,10 +246,9 @@ class Account extends commons_1.TypedEventEmitter {
246
246
  const initialPreKeys = await this.service.proteus.createClient(entropyData);
247
247
  const client = await this.service.client.register(loginData, clientInfo, initialPreKeys);
248
248
  const clientId = client.id;
249
- await this.service.notification.initializeNotificationStream(clientId);
250
249
  await this.service.client.synchronizeClients(clientId);
251
250
  return client;
252
- }
251
+ };
253
252
  getLocalClient() {
254
253
  return this.service?.client.loadClient();
255
254
  }
@@ -258,7 +257,7 @@ class Account extends commons_1.TypedEventEmitter {
258
257
  *
259
258
  * @returns The local existing client or undefined if the client does not exist or is not valid (non existing on backend)
260
259
  */
261
- async initClient(client, mlsConfig) {
260
+ initClient = async (client, mlsConfig) => {
262
261
  if (!this.service || !this.apiClient.context || !this.storeEngine) {
263
262
  throw new Error('Services are not set.');
264
263
  }
@@ -278,8 +277,8 @@ class Account extends commons_1.TypedEventEmitter {
278
277
  }
279
278
  this.currentClient = client;
280
279
  return client;
281
- }
282
- async buildCryptoClient(context, storeEngine, encryptedStore) {
280
+ };
281
+ buildCryptoClient = async (context, storeEngine, encryptedStore) => {
283
282
  const baseConfig = {
284
283
  nbPrekeys: this.options.nbPrekeys,
285
284
  onNewPrekeys: async (prekeys) => {
@@ -299,7 +298,7 @@ class Account extends commons_1.TypedEventEmitter {
299
298
  const { buildClient } = await Promise.resolve().then(() => __importStar(require('./messagingProtocols/proteus/ProteusService/CryptoClient/CryptoboxWrapper')));
300
299
  const client = buildClient(storeEngine, baseConfig);
301
300
  return [CryptoClient_1.CryptoClientType.CRYPTOBOX, client];
302
- }
301
+ };
303
302
  /**
304
303
  * In order to be able to send MLS messages, the core needs a few information from the consumer.
305
304
  * Namely:
@@ -307,10 +306,10 @@ class Account extends commons_1.TypedEventEmitter {
307
306
  * - what is the groupId of a conversation
308
307
  * @param coreCallbacks
309
308
  */
310
- configureCoreCallbacks(coreCallbacks) {
309
+ configureCoreCallbacks = (coreCallbacks) => {
311
310
  this.coreCallbacks = coreCallbacks;
312
- }
313
- async initServices(context) {
311
+ };
312
+ initServices = async (context) => {
314
313
  const encryptedStoreName = this.generateEncryptedDbName(context);
315
314
  this.encryptedDb = this.options.systemCrypto
316
315
  ? await (0, encryptedStore_1.createCustomEncryptedStore)(encryptedStoreName, this.options.systemCrypto)
@@ -360,17 +359,17 @@ class Account extends commons_1.TypedEventEmitter {
360
359
  team: teamService,
361
360
  user: userService,
362
361
  };
363
- }
364
- resetContext() {
362
+ };
363
+ resetContext = () => {
365
364
  this.currentClient = undefined;
366
365
  delete this.apiClient.context;
367
366
  delete this.service;
368
- }
367
+ };
369
368
  /**
370
369
  * Will logout the current user
371
370
  * @param clearData if set to `true` will completely wipe any database that was created by the Account
372
371
  */
373
- async logout(data) {
372
+ logout = async (data) => {
374
373
  this.db?.close();
375
374
  this.encryptedDb?.close();
376
375
  if (data?.clearAllData) {
@@ -381,19 +380,19 @@ class Account extends commons_1.TypedEventEmitter {
381
380
  }
382
381
  await this.apiClient.logout();
383
382
  this.resetContext();
384
- }
385
- async wipeCommonData() {
383
+ };
384
+ wipeCommonData = async () => {
386
385
  await this.service?.client.deleteLocalClient();
387
386
  if (this.storeEngine) {
388
387
  await (0, CoreCryptoWrapper_1.wipeCoreCryptoDb)(this.storeEngine);
389
388
  }
390
389
  // needs to be wiped last
391
390
  await this.encryptedDb?.wipe();
392
- }
391
+ };
393
392
  /**
394
393
  * Will delete the identity and history of the current user
395
394
  */
396
- async wipeAllData() {
395
+ wipeAllData = async () => {
397
396
  if (this.storeEngine) {
398
397
  await (0, identityClearer_1.deleteIdentity)(this.storeEngine, false);
399
398
  }
@@ -401,17 +400,17 @@ class Account extends commons_1.TypedEventEmitter {
401
400
  await (0, CoreDB_1.deleteDB)(this.db);
402
401
  }
403
402
  await this.wipeCommonData();
404
- }
403
+ };
405
404
  /**
406
405
  * Will delete the cryptography and client of the current user
407
406
  * Will keep the history intact
408
407
  */
409
- async wipeCryptoData() {
408
+ wipeCryptoData = async () => {
410
409
  if (this.storeEngine) {
411
410
  await (0, identityClearer_1.deleteIdentity)(this.storeEngine, true);
412
411
  }
413
412
  await this.wipeCommonData();
414
- }
413
+ };
415
414
  /**
416
415
  * return true if the current user has a MLS device that is initialized and ready to use
417
416
  */
@@ -425,7 +424,7 @@ class Account extends commons_1.TypedEventEmitter {
425
424
  * @param callbacks callbacks that will be called to handle different events
426
425
  * @returns close a function that will disconnect from the websocket
427
426
  */
428
- async listen({ onEvent = () => { }, onConnectionStateChanged: onConnectionStateChangedCallBack = () => { }, onNotificationStreamProgress = () => { }, onMissedNotifications = () => { }, dryRun = false, } = {}) {
427
+ listen = async ({ onEvent = () => { }, onConnectionStateChanged: onConnectionStateChangedCallBack = () => { }, onNotificationStreamProgress = () => { }, onMissedNotifications = () => { }, dryRun = false, } = {}) => {
429
428
  if (!this.currentClient) {
430
429
  throw new Error('Client has not been initialized - please login first');
431
430
  }
@@ -476,25 +475,25 @@ class Account extends commons_1.TypedEventEmitter {
476
475
  this.notificationProcessingQueue.pause(false);
477
476
  });
478
477
  return () => {
478
+ this.pauseAndFlushNotificationQueue();
479
479
  this.apiClient.disconnect();
480
480
  onConnectionStateChanged(ConnectionState.CLOSED);
481
481
  this.apiClient.transport.ws.removeAllListeners();
482
482
  };
483
- }
484
- createConnectionStateChangedHandler(onConnectionStateChanged) {
483
+ };
484
+ createConnectionStateChangedHandler = (onConnectionStateChanged) => {
485
485
  return (state) => {
486
- console.info(`Connection state changed to: ${state}`);
487
486
  this.connectionState = state;
488
487
  onConnectionStateChanged(state);
489
488
  this.logger.info(`Connection state changed to: ${state}`);
490
489
  };
491
- }
490
+ };
492
491
  /**
493
492
  * Creates the event handler that is invoked for each decrypted event from the backend.
494
493
  * Responsible for handling specific event types like `MESSAGE_TIMER_UPDATE`, and then
495
494
  * forwarding the event to the consumer via the `onEvent` callback.
496
495
  */
497
- createEventHandler(onEvent) {
496
+ createEventHandler = (onEvent) => {
498
497
  return async (payload, source) => {
499
498
  const { event } = payload;
500
499
  switch (event?.type) {
@@ -508,14 +507,14 @@ class Account extends commons_1.TypedEventEmitter {
508
507
  // Always forward the event to the consumer
509
508
  onEvent(payload, source);
510
509
  };
511
- }
510
+ };
512
511
  /**
513
512
  * @deprecated This method is used to handle legacy notifications from the backend.
514
513
  * It processes notifications from the legacy system, decrypts them, and emits events.
515
514
  * It can be replaced with the new notification handling system using `ConsumableNotification`
516
515
  * when all clients are capable of handling consumable notifications.
517
516
  */
518
- createLegacyNotificationHandler(handleEvent, dryRun) {
517
+ createLegacyNotificationHandler = (handleEvent, dryRun) => {
519
518
  return async (notification, source) => {
520
519
  try {
521
520
  const messages = this.service.notification.handleNotification(notification, source, dryRun);
@@ -527,8 +526,8 @@ class Account extends commons_1.TypedEventEmitter {
527
526
  this.logger.error(`Failed to handle legacy notification "${notification.id}": ${error.message}`, error);
528
527
  }
529
528
  };
530
- }
531
- createNotificationHandler(handleEvent, onNotificationStreamProgress, onConnectionStateChanged, dryRun) {
529
+ };
530
+ createNotificationHandler = (handleEvent, onNotificationStreamProgress, onConnectionStateChanged, dryRun) => {
532
531
  return async (notification, source) => {
533
532
  try {
534
533
  if (notification.type === ConsumableNotification_1.ConsumableEvent.MISSED) {
@@ -536,20 +535,32 @@ class Account extends commons_1.TypedEventEmitter {
536
535
  return;
537
536
  }
538
537
  if (notification.type === ConsumableNotification_1.ConsumableEvent.SYNCHRONIZATION) {
539
- void this.notificationProcessingQueue.push(() => this.handleSynchronizationNotification(notification, onConnectionStateChanged));
538
+ void this.notificationProcessingQueue
539
+ .push(() => this.handleSynchronizationNotification(notification, onConnectionStateChanged))
540
+ .catch(this.handleNotificationQueueError);
540
541
  return;
541
542
  }
542
- void this.notificationProcessingQueue.push(() => this.decryptAckEmitNotification(notification, handleEvent, source, onNotificationStreamProgress, dryRun));
543
+ void this.notificationProcessingQueue
544
+ .push(() => this.decryptAckEmitNotification(notification, handleEvent, source, onNotificationStreamProgress, dryRun))
545
+ .catch(this.handleNotificationQueueError);
543
546
  }
544
547
  catch (error) {
545
548
  this.logger.error(`Failed to handle notification "${notification.type}": ${error.message}`, error);
546
549
  }
547
550
  };
548
- }
549
- acknowledgeSynchronizationNotification(notification) {
551
+ };
552
+ handleNotificationQueueError = (error) => {
553
+ if (error instanceof Error && error.message.includes('Queue was flushed')) {
554
+ // queue is flushed manually so we ignore the error
555
+ this.logger.info('Notification processing queue was flushed, ignoring error', error);
556
+ return;
557
+ }
558
+ throw error;
559
+ };
560
+ acknowledgeSynchronizationNotification = (notification) => {
550
561
  this.apiClient.transport.ws.acknowledgeConsumableNotificationSynchronization(notification);
551
- }
552
- async handleSynchronizationNotification(notification, onConnectionStateChanged) {
562
+ };
563
+ handleSynchronizationNotification = async (notification, onConnectionStateChanged) => {
553
564
  this.acknowledgeSynchronizationNotification(notification);
554
565
  const markerId = notification.data.marker_id;
555
566
  const currentMarkerId = this.apiClient.transport.http.accessTokenStore.markerToken;
@@ -563,8 +574,8 @@ class Account extends commons_1.TypedEventEmitter {
563
574
  (0, messageSender_1.resumeMessageSending)();
564
575
  onConnectionStateChanged(ConnectionState.LIVE);
565
576
  }
566
- }
567
- async decryptAckEmitNotification(notification, handleEvent, source, onNotificationStreamProgress, dryRun) {
577
+ };
578
+ decryptAckEmitNotification = async (notification, handleEvent, source, onNotificationStreamProgress, dryRun) => {
568
579
  try {
569
580
  const payloads = this.service.notification.handleNotification(notification.data.event, source, dryRun);
570
581
  const notificationTime = this.getNotificationEventTime(notification.data.event.payload[0]);
@@ -581,13 +592,13 @@ class Account extends commons_1.TypedEventEmitter {
581
592
  catch (err) {
582
593
  this.logger.error(`Failed to process notification ${notification.data.delivery_tag}`, err);
583
594
  }
584
- }
585
- getNotificationEventTime(backendEvent) {
595
+ };
596
+ getNotificationEventTime = (backendEvent) => {
586
597
  if ('time' in backendEvent && typeof backendEvent.time === 'string') {
587
598
  return backendEvent.time;
588
599
  }
589
600
  return null;
590
- }
601
+ };
591
602
  /**
592
603
  * Returns a function to handle missed notifications — i.e., when the backend indicates
593
604
  * that some notifications were lost due to age (typically >28 days).
@@ -597,14 +608,14 @@ class Account extends commons_1.TypedEventEmitter {
597
608
  * It should be replaced with the new notification handling system using `ConsumableNotification`.
598
609
  * when all clients are capable of handling consumable notifications.
599
610
  */
600
- createLegacyMissedNotificationsHandler(onMissedNotifications) {
611
+ createLegacyMissedNotificationsHandler = (onMissedNotifications) => {
601
612
  return async (notificationId) => {
602
613
  if (this.hasMLSDevice) {
603
614
  (0, conversationRejoinQueue_1.queueConversationRejoin)('all-conversations', () => this.service.conversation.handleConversationsEpochMismatch());
604
615
  }
605
616
  return onMissedNotifications(notificationId);
606
617
  };
607
- }
618
+ };
608
619
  /**
609
620
  * Returns a processor function for the notification stream (legacy sync).
610
621
  * It pauses message sending and MLS rejoining during stream handling to prevent race conditions,
@@ -616,7 +627,7 @@ class Account extends commons_1.TypedEventEmitter {
616
627
  *
617
628
  * @param handlers Various logic handlers wired to notification callbacks
618
629
  */
619
- createLegacyNotificationStreamProcessor({ handleLegacyNotification, handleMissedNotifications, onNotificationStreamProgress, onConnectionStateChanged, }) {
630
+ createLegacyNotificationStreamProcessor = ({ handleLegacyNotification, handleMissedNotifications, onNotificationStreamProgress, onConnectionStateChanged, }) => {
620
631
  return async () => {
621
632
  (0, messageSender_1.pauseMessageSending)();
622
633
  // We want to avoid triggering rejoins of out-of-sync MLS conversations while we are processing the notification stream
@@ -637,7 +648,18 @@ class Account extends commons_1.TypedEventEmitter {
637
648
  (0, conversationRejoinQueue_1.resumeRejoiningMLSConversations)();
638
649
  onConnectionStateChanged(ConnectionState.LIVE);
639
650
  };
640
- }
651
+ };
652
+ /**
653
+ * In case of a closed connection, we flush the notification processing queue.
654
+ * As we are not acknowledging them before decryption is done
655
+ * they will be resent next time the connection is opened
656
+ * this is to avoid duplicate decryption of notifications
657
+ */
658
+ pauseAndFlushNotificationQueue = () => {
659
+ this.notificationProcessingQueue.pause();
660
+ this.notificationProcessingQueue.flush();
661
+ this.logger.info('Notification processing queue paused and flushed');
662
+ };
641
663
  /**
642
664
  * Sets up WebSocket event listeners for:
643
665
  * - Incoming backend messages
@@ -645,7 +667,7 @@ class Account extends commons_1.TypedEventEmitter {
645
667
  * On each new backend message, we pass it to the notification handler.
646
668
  * On state changes, we map raw socket states to public connection states and emit them.
647
669
  */
648
- setupWebSocketListeners(handleNotification, onConnectionStateChanged) {
670
+ setupWebSocketListeners = (handleNotification, onConnectionStateChanged) => {
649
671
  this.apiClient.transport.ws.removeAllListeners(tcp_1.WebSocketClient.TOPIC.ON_MESSAGE);
650
672
  this.apiClient.transport.ws.on(tcp_1.WebSocketClient.TOPIC.ON_MESSAGE, notification => handleNotification(notification, notification_1.NotificationSource.WEBSOCKET));
651
673
  this.apiClient.transport.ws.on(tcp_1.WebSocketClient.TOPIC.ON_STATE_CHANGE, wsState => {
@@ -655,20 +677,13 @@ class Account extends commons_1.TypedEventEmitter {
655
677
  };
656
678
  const connectionState = mapping[wsState];
657
679
  if (connectionState === ConnectionState.CLOSED) {
658
- this.notificationProcessingQueue.pause();
659
- /**
660
- * In case of a closed connection, we flush the notification processing queue.
661
- * As we are not acknowledging them before decryption is done
662
- * they will be resent next time the connection is opened
663
- * this is to avoid duplicate decryption of notifications
664
- */
665
- this.notificationProcessingQueue.flush();
680
+ this.pauseAndFlushNotificationQueue();
666
681
  }
667
682
  if (connectionState) {
668
683
  onConnectionStateChanged(connectionState);
669
684
  }
670
685
  });
671
- }
686
+ };
672
687
  /**
673
688
  * Handles logic for reacting to a missed notification event.
674
689
  *
@@ -690,7 +705,7 @@ class Account extends commons_1.TypedEventEmitter {
690
705
  * the WebSocket transport, unblocking the backend so it resumes sending updates
691
706
  * then we remove the flag.
692
707
  */
693
- reactToMissedNotification() {
708
+ reactToMissedNotification = () => {
694
709
  const localStorageKey = 'has_missing_notification';
695
710
  // First-time handling: set flag and reload to trigger full re-fetch of state.
696
711
  if (!exports.AccountLocalStorageStore.has(localStorageKey)) {
@@ -701,24 +716,24 @@ class Account extends commons_1.TypedEventEmitter {
701
716
  // After reload: acknowledge the missed notification so backend resumes notifications.
702
717
  this.apiClient.transport.ws.acknowledgeMissedNotification();
703
718
  exports.AccountLocalStorageStore.remove(localStorageKey);
704
- }
705
- getClientCapabilities() {
719
+ };
720
+ getClientCapabilities = () => {
706
721
  return this.currentClient?.capabilities || [];
707
- }
708
- checkIsConsumable(notification) {
722
+ };
723
+ checkIsConsumable = (notification) => {
709
724
  return 'type' in notification;
710
- }
711
- generateDbName(context) {
725
+ };
726
+ generateDbName = (context) => {
712
727
  const clientType = context.clientType === client_1.ClientType.NONE ? '' : `@${context.clientType}`;
713
728
  return `wire@${this.apiClient.config.urls.name}@${context.userId}${clientType}`;
714
- }
715
- generateCoreDbName(context) {
729
+ };
730
+ generateCoreDbName = (context) => {
716
731
  return `core-${this.generateDbName(context)}`;
717
- }
718
- generateEncryptedDbName(context) {
732
+ };
733
+ generateEncryptedDbName = (context) => {
719
734
  return `secrets-${this.generateDbName(context)}`;
720
- }
721
- async initEngine(context, encryptedStore) {
735
+ };
736
+ initEngine = async (context, encryptedStore) => {
722
737
  const dbName = this.generateDbName(context);
723
738
  this.logger.debug(`Initialising store with name "${dbName}"...`);
724
739
  const openDb = async () => {
@@ -739,14 +754,14 @@ class Account extends commons_1.TypedEventEmitter {
739
754
  await this.persistCookie(storeEngine, cookie);
740
755
  }
741
756
  return storeEngine;
742
- }
757
+ };
743
758
  groupIdFromConversationId = async (conversationId, subconversationId) => {
744
759
  if (!subconversationId) {
745
760
  return this.coreCallbacks?.groupIdFromConversationId(conversationId);
746
761
  }
747
762
  return this.service?.subconversation.getSubconversationGroupId(conversationId, subconversationId);
748
763
  };
749
- async isMLSActiveForClient() {
764
+ isMLSActiveForClient = async () => {
750
765
  // Check for CoreCrypto library, it is required for MLS
751
766
  if (!this.options.coreCryptoConfig?.enabled) {
752
767
  return false;
@@ -758,6 +773,6 @@ class Account extends commons_1.TypedEventEmitter {
758
773
  // Check if MLS is enabled for the public via backend feature flag
759
774
  const commonConfig = (await this.service?.team.getCommonFeatureConfig()) ?? {};
760
775
  return commonConfig[team_1.FEATURE_KEY.MLS]?.status === team_1.FeatureStatus.ENABLED;
761
- }
776
+ };
762
777
  }
763
778
  exports.Account = Account;
@@ -49,8 +49,13 @@ export declare class NotificationService extends TypedEventEmitter<Events> {
49
49
  static readonly TOPIC: typeof TOPIC;
50
50
  constructor(apiClient: APIClient, storeEngine: CRUDEngine, conversationService: ConversationService);
51
51
  private getAllNotifications;
52
- /** Should only be called with a completely new client. */
53
- initializeNotificationStream(clientId: string): Promise<string>;
52
+ /**
53
+ * Should only be called with a completely new client.
54
+ *
55
+ * @deprecated This method is used to handle legacy notifications from the backend.
56
+ * It can be removed when all clients are capable of handling consumable notifications.
57
+ */
58
+ legacyInitializeNotificationStream(clientId: string): Promise<string>;
54
59
  hasHistory(): Promise<boolean>;
55
60
  getNotificationEventList(): Promise<BackendEvent[]>;
56
61
  setLastEventDate(eventDate: Date): Promise<Date>;
@@ -1 +1 @@
1
- {"version":3,"file":"NotificationService.d.ts","sourceRoot":"","sources":["../../src/notification/NotificationService.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,YAAY,EAAC,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAC,YAAY,EAAC,MAAM,uCAAuC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oB,SAAQ,iBAAiB,CAAC,MAAM,CAAC;IAU9D,OAAO,CAAC,QAAQ,CAAC,mBAAmB;IATtC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;IACtC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgC;IACxD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAiC;IAC1D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA6D;IACpF,gBAAuB,KAAK,eAAS;gBAGnC,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,UAAU,EACN,mBAAmB,EAAE,mBAAmB;YAQ7C,mBAAmB;IAKjC;;;;;OAKG;IACU,kCAAkC,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAMrE,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC;IAKpC,wBAAwB,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;IAI7C,gBAAgB,CAAC,SAAS,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;YAsB/C,qBAAqB;IAInC;;;;;;;;;OASG;IACU,+BAA+B,CAC1C,mBAAmB,EAAE,mBAAmB,EACxC,qBAAqB,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,IAAI,GACtD,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAC,CAAC;IA6B3D;;;;;;;OAOG;IACH,OAAO,CAAC,eAAe;IAYT,kBAAkB,CAC9B,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,kBAAkB,EAC1B,MAAM,GAAE,OAAe,GACtB,cAAc,CAAC,mBAAmB,CAAC;IAmCtC;;;;;OAKG;YACW,WAAW;CAc1B"}
@@ -47,8 +47,13 @@ class NotificationService extends commons_1.TypedEventEmitter {
47
47
  const clientId = this.apiClient.clientId;
48
48
  return this.backend.getAllNotifications(clientId, since);
49
49
  }
50
- /** Should only be called with a completely new client. */
51
- async initializeNotificationStream(clientId) {
50
+ /**
51
+ * Should only be called with a completely new client.
52
+ *
53
+ * @deprecated This method is used to handle legacy notifications from the backend.
54
+ * It can be removed when all clients are capable of handling consumable notifications.
55
+ */
56
+ async legacyInitializeNotificationStream(clientId) {
52
57
  await this.setLastEventDate(new Date(0));
53
58
  const latestNotification = await this.backend.getLastNotification(clientId);
54
59
  return this.setLastNotificationId(latestNotification);
package/package.json CHANGED
@@ -61,6 +61,6 @@
61
61
  "test:coverage": "jest --coverage",
62
62
  "watch": "tsc --watch"
63
63
  },
64
- "version": "46.31.0",
65
- "gitHead": "e924b1027a151d63f23b7d4f463832eae04b901e"
64
+ "version": "46.31.2",
65
+ "gitHead": "ff2a8d4ad241662fad2299fe4e89b71154b8b07e"
66
66
  }