@wireapp/core 46.31.7 → 46.32.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.
Files changed (22) hide show
  1. package/lib/Account.d.ts +6 -2
  2. package/lib/Account.d.ts.map +1 -1
  3. package/lib/Account.js +73 -36
  4. package/lib/Account.test.js +61 -13
  5. package/lib/client/ClientService.d.ts +1 -1
  6. package/lib/client/ClientService.d.ts.map +1 -1
  7. package/lib/client/ClientService.js +6 -2
  8. package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.d.ts.map +1 -1
  9. package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.js +6 -11
  10. package/lib/notification/NotificationBackendRepository.d.ts +1 -1
  11. package/lib/notification/NotificationBackendRepository.d.ts.map +1 -1
  12. package/lib/notification/NotificationBackendRepository.js +2 -2
  13. package/lib/notification/NotificationService.d.ts +1 -1
  14. package/lib/notification/NotificationService.d.ts.map +1 -1
  15. package/lib/notification/NotificationService.js +11 -4
  16. package/package.json +6 -6
  17. package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingProposalsQueue/IncomingProposalsQueue.d.ts +0 -5
  18. package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingProposalsQueue/IncomingProposalsQueue.d.ts.map +0 -1
  19. package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingProposalsQueue/IncomingProposalsQueue.js +0 -39
  20. package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingProposalsQueue/index.d.ts +0 -2
  21. package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingProposalsQueue/index.d.ts.map +0 -1
  22. package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingProposalsQueue/index.js +0 -35
package/lib/Account.d.ts CHANGED
@@ -164,7 +164,7 @@ export declare class Account extends TypedEventEmitter<Events> {
164
164
  /**
165
165
  * Will register a new client for the current user
166
166
  */
167
- registerClient: (loginData: LoginData, clientInfo?: ClientInfo, entropyData?: Uint8Array) => Promise<RegisteredClient>;
167
+ registerClient: (loginData: LoginData, clientInfo: ClientInfo | undefined, useLegacyNotificationStream: boolean, entropyData?: Uint8Array) => Promise<RegisteredClient>;
168
168
  getLocalClient(): Promise<import("./client/ClientService").MetaClient | undefined> | undefined;
169
169
  /**
170
170
  * Will initiate all the cryptographic material of the given registered device and setup all the background tasks.
@@ -212,7 +212,7 @@ export declare class Account extends TypedEventEmitter<Events> {
212
212
  * @param callbacks callbacks that will be called to handle different events
213
213
  * @returns close a function that will disconnect from the websocket
214
214
  */
215
- listen: ({ onEvent, onConnectionStateChanged: onConnectionStateChangedCallBack, onNotificationStreamProgress, onMissedNotifications, dryRun, }?: {
215
+ listen: ({ useLegacy, onEvent, onConnectionStateChanged: onConnectionStateChangedCallBack, onNotificationStreamProgress, onMissedNotifications, dryRun, }?: {
216
216
  /**
217
217
  * Called when a new event arrives from backend
218
218
  * @param payload the payload of the event. Contains the raw event received and the decrypted data (if event was encrypted)
@@ -235,6 +235,10 @@ export declare class Account extends TypedEventEmitter<Events> {
235
235
  * @param {string} notificationId
236
236
  */
237
237
  onMissedNotifications?: (notificationId: string) => void;
238
+ /**
239
+ * When set to true, will use the legacy notification stream instead of the new async notifications.
240
+ */
241
+ useLegacy?: boolean;
238
242
  /**
239
243
  * 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
240
244
  */
@@ -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,OAA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AC,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
@@ -67,7 +67,6 @@ const linkPreview_1 = require("./linkPreview");
67
67
  const mls_1 = require("./messagingProtocols/mls");
68
68
  const conversationRejoinQueue_1 = require("./messagingProtocols/mls/conversationRejoinQueue");
69
69
  const E2EIdentityService_1 = require("./messagingProtocols/mls/E2EIdentityService");
70
- const IncomingProposalsQueue_1 = require("./messagingProtocols/mls/EventHandler/events/messageAdd/IncomingProposalsQueue");
71
70
  const proteus_1 = require("./messagingProtocols/proteus");
72
71
  const CryptoClient_1 = require("./messagingProtocols/proteus/ProteusService/CryptoClient");
73
72
  const CoreCryptoWrapper_1 = require("./messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper");
@@ -125,7 +124,10 @@ class Account extends commons_1.TypedEventEmitter {
125
124
  * @param apiClient The apiClient instance to use in the core (will create a new new one if undefined)
126
125
  * @param accountOptions
127
126
  */
128
- constructor(apiClient = new api_client_1.APIClient(), options = { nbPrekeys: 100, coreCryptoConfig: { wasmFilePath: '', enabled: false } }) {
127
+ constructor(apiClient = new api_client_1.APIClient(), options = {
128
+ nbPrekeys: 100,
129
+ coreCryptoConfig: { wasmFilePath: '', enabled: false },
130
+ }) {
129
131
  super();
130
132
  this.options = options;
131
133
  this.apiClient = apiClient;
@@ -236,17 +238,23 @@ class Account extends commons_1.TypedEventEmitter {
236
238
  /**
237
239
  * Will register a new client for the current user
238
240
  */
239
- registerClient = async (loginData, clientInfo = coreDefaultClient,
241
+ registerClient = async (loginData, clientInfo = coreDefaultClient, useLegacyNotificationStream,
240
242
  /** will add extra manual entropy to the client's identity being created */
241
243
  entropyData) => {
242
244
  if (!this.service || !this.apiClient.context || !this.storeEngine) {
243
245
  throw new Error('Services are not set or context not initialized.');
244
246
  }
247
+ if (typeof useLegacyNotificationStream !== 'boolean') {
248
+ throw new Error('use of legacy notifications must be explicitly set to true or false');
249
+ }
245
250
  // we reset the services to re-instantiate a new CryptoClient instance
246
251
  await this.initServices(this.apiClient.context);
247
252
  const initialPreKeys = await this.service.proteus.createClient(entropyData);
248
- const client = await this.service.client.register(loginData, clientInfo, initialPreKeys);
253
+ const client = await this.service.client.register(loginData, clientInfo, initialPreKeys, useLegacyNotificationStream);
249
254
  const clientId = client.id;
255
+ if (useLegacyNotificationStream) {
256
+ await this.service.notification.legacyInitializeNotificationStream(clientId);
257
+ }
250
258
  await this.service.client.synchronizeClients(clientId);
251
259
  return client;
252
260
  };
@@ -425,23 +433,33 @@ class Account extends commons_1.TypedEventEmitter {
425
433
  * @param callbacks callbacks that will be called to handle different events
426
434
  * @returns close a function that will disconnect from the websocket
427
435
  */
428
- listen = async ({ onEvent = () => { }, onConnectionStateChanged: onConnectionStateChangedCallBack = () => { }, onNotificationStreamProgress = () => { }, onMissedNotifications = () => { }, dryRun = false, } = {}) => {
436
+ listen = async ({ useLegacy, onEvent = () => { }, onConnectionStateChanged: onConnectionStateChangedCallBack = () => { }, onNotificationStreamProgress = () => { }, onMissedNotifications = () => { }, dryRun = false, } = {}) => {
429
437
  if (!this.currentClient) {
430
438
  throw new Error('Client has not been initialized - please login first');
431
439
  }
440
+ if (typeof useLegacy !== 'boolean') {
441
+ throw new Error('use of legacy notifications must be explicitly set to true or false');
442
+ }
432
443
  const onConnectionStateChanged = this.createConnectionStateChangedHandler(onConnectionStateChangedCallBack);
433
444
  const handleEvent = this.createEventHandler(onEvent);
434
445
  const handleLegacyNotification = this.createLegacyNotificationHandler(handleEvent, dryRun);
435
446
  const handleNotification = this.createNotificationHandler(handleEvent, onNotificationStreamProgress, onConnectionStateChanged, dryRun);
436
447
  const handleMissedNotifications = this.createLegacyMissedNotificationsHandler(onMissedNotifications);
437
- const processNotificationStream = this.createLegacyNotificationStreamProcessor({
448
+ const legacyProcessNotificationStream = this.createLegacyNotificationStreamProcessor({
438
449
  handleLegacyNotification,
439
450
  handleMissedNotifications,
440
451
  onNotificationStreamProgress,
441
452
  onConnectionStateChanged,
442
453
  });
443
- this.setupWebSocketListeners(handleNotification, onConnectionStateChanged);
454
+ this.setupWebSocketListeners(onConnectionStateChanged, handleNotification, handleLegacyNotification);
444
455
  const isClientCapableOfConsumableNotifications = this.getClientCapabilities().includes(client_1.ClientCapability.CONSUMABLE_NOTIFICATIONS);
456
+ const capabilities = [client_1.ClientCapability.LEGAL_HOLD_IMPLICIT_CONSENT];
457
+ if (!useLegacy) {
458
+ // let the backend now client is capable of consumable notifications
459
+ capabilities.push(client_1.ClientCapability.CONSUMABLE_NOTIFICATIONS);
460
+ this.apiClient.transport.ws.useAsyncNotificationsSocket();
461
+ }
462
+ await this.service?.client.putClientCapabilities(this.currentClient.id, { capabilities });
445
463
  /*
446
464
  * When enabling async notifications, be aware that the backend maintains a separate queue
447
465
  * for new async notifications (/events weboscket endpoint), which only starts populating *after* the client declares support
@@ -456,20 +474,23 @@ class Account extends commons_1.TypedEventEmitter {
456
474
  *
457
475
  * @todo This can be removed when all clients are capable of consumable notifications.
458
476
  */
459
- if (!isClientCapableOfConsumableNotifications) {
460
- // let the backend now client is capable of consumable notifications
461
- await this.service?.client.putClientCapabilities(this.currentClient.id, {
462
- capabilities: [client_1.ClientCapability.LEGAL_HOLD_IMPLICIT_CONSENT, client_1.ClientCapability.CONSUMABLE_NOTIFICATIONS],
463
- });
477
+ if (!isClientCapableOfConsumableNotifications && !useLegacy) {
464
478
  // do a quick legacy sync without connecting to any websockets
465
- await processNotificationStream();
479
+ await legacyProcessNotificationStream();
466
480
  }
467
- this.apiClient.connect(() => {
481
+ if (useLegacy) {
482
+ /**
483
+ * immediately lock the websocket to prevent any new messages from being received
484
+ * before legacy notifications endpoint is fetched otherwise it'll update the last notification ID
485
+ * and fetching legacy notifications will return an empty list
486
+ */
487
+ this.apiClient.transport.ws.lock();
488
+ }
489
+ this.apiClient.connect(async (abortController) => {
468
490
  /**
469
491
  * This is to avoid passing proposals too early to core crypto
470
492
  * @See WPB-18995
471
493
  */
472
- (0, IncomingProposalsQueue_1.pauseProposalProcessing)();
473
494
  (0, messageSender_1.pauseMessageSending)(); // pause message sending while processing notifications, it will be resumed once the processing is done and we have the marker token
474
495
  /**
475
496
  * unpause the notification processing queue
@@ -479,6 +500,9 @@ class Account extends commons_1.TypedEventEmitter {
479
500
  * so we need to acknowledge the notifications to let the backend know we are ready for the next batch
480
501
  */
481
502
  this.notificationProcessingQueue.pause(false);
503
+ if (useLegacy) {
504
+ await legacyProcessNotificationStream(abortController);
505
+ }
482
506
  });
483
507
  return () => {
484
508
  this.pauseAndFlushNotificationQueue();
@@ -522,15 +546,19 @@ class Account extends commons_1.TypedEventEmitter {
522
546
  */
523
547
  createLegacyNotificationHandler = (handleEvent, dryRun) => {
524
548
  return async (notification, source) => {
525
- try {
526
- const messages = this.service.notification.handleNotification(notification, source, dryRun);
527
- for await (const message of messages) {
528
- await handleEvent(message, source);
549
+ void this.notificationProcessingQueue
550
+ .push(async () => {
551
+ try {
552
+ const messages = this.service.notification.handleNotification(notification, source, dryRun);
553
+ for await (const message of messages) {
554
+ await handleEvent(message, source);
555
+ }
529
556
  }
530
- }
531
- catch (error) {
532
- this.logger.error(`Failed to handle legacy notification "${notification.id}": ${error.message}`, error);
533
- }
557
+ catch (error) {
558
+ this.logger.error(`Failed to handle legacy notification "${notification.id}": ${error.message}`, error);
559
+ }
560
+ })
561
+ .catch(this.handleNotificationQueueError);
534
562
  };
535
563
  };
536
564
  createNotificationHandler = (handleEvent, onNotificationStreamProgress, onConnectionStateChanged, dryRun) => {
@@ -541,12 +569,12 @@ class Account extends commons_1.TypedEventEmitter {
541
569
  return;
542
570
  }
543
571
  if (notification.type === ConsumableNotification_1.ConsumableEvent.SYNCHRONIZATION) {
544
- void this.notificationProcessingQueue
572
+ this.notificationProcessingQueue
545
573
  .push(() => this.handleSynchronizationNotification(notification, onConnectionStateChanged))
546
574
  .catch(this.handleNotificationQueueError);
547
575
  return;
548
576
  }
549
- void this.notificationProcessingQueue
577
+ this.notificationProcessingQueue
550
578
  .push(() => this.decryptAckEmitNotification(notification, handleEvent, source, onNotificationStreamProgress, dryRun))
551
579
  .catch(this.handleNotificationQueueError);
552
580
  }
@@ -577,7 +605,6 @@ class Account extends commons_1.TypedEventEmitter {
577
605
  * if the marker ID matches the current marker ID.
578
606
  */
579
607
  if (markerId === currentMarkerId) {
580
- (0, IncomingProposalsQueue_1.resumeProposalProcessing)();
581
608
  (0, messageSender_1.resumeMessageSending)();
582
609
  onConnectionStateChanged(ConnectionState.LIVE);
583
610
  }
@@ -635,8 +662,8 @@ class Account extends commons_1.TypedEventEmitter {
635
662
  * @param handlers Various logic handlers wired to notification callbacks
636
663
  */
637
664
  createLegacyNotificationStreamProcessor = ({ handleLegacyNotification, handleMissedNotifications, onNotificationStreamProgress, onConnectionStateChanged, }) => {
638
- return async () => {
639
- (0, IncomingProposalsQueue_1.pauseProposalProcessing)();
665
+ return async (abortController) => {
666
+ this.apiClient.transport.ws.lock();
640
667
  (0, messageSender_1.pauseMessageSending)();
641
668
  // We want to avoid triggering rejoins of out-of-sync MLS conversations while we are processing the notification stream
642
669
  (0, conversationRejoinQueue_1.pauseRejoiningMLSConversations)();
@@ -647,15 +674,19 @@ class Account extends commons_1.TypedEventEmitter {
647
674
  if (notificationTime) {
648
675
  onNotificationStreamProgress(notificationTime);
649
676
  }
650
- }, handleMissedNotifications);
677
+ }, handleMissedNotifications, abortController);
651
678
  this.logger.info('Finished processing notifications from the legacy endpoint', results);
652
679
  // We need to wait for the notification stream to be fully handled before releasing the message sending queue.
653
680
  // This is due to the nature of how message are encrypted, any change in mls epoch needs to happen before we start encrypting any kind of messages
654
- this.logger.info(`Resuming message sending. ${(0, messageSender_1.getQueueLength)()} messages to be sent`);
655
- (0, IncomingProposalsQueue_1.resumeProposalProcessing)();
656
- (0, messageSender_1.resumeMessageSending)();
657
- (0, conversationRejoinQueue_1.resumeRejoiningMLSConversations)();
658
- onConnectionStateChanged(ConnectionState.LIVE);
681
+ void this.notificationProcessingQueue
682
+ .push(async () => {
683
+ this.logger.info(`Resuming message sending. ${(0, messageSender_1.getQueueLength)()} messages to be sent`);
684
+ (0, messageSender_1.resumeMessageSending)();
685
+ (0, conversationRejoinQueue_1.resumeRejoiningMLSConversations)();
686
+ onConnectionStateChanged(ConnectionState.LIVE);
687
+ this.apiClient.transport.ws.unlock();
688
+ })
689
+ .catch(this.handleNotificationQueueError);
659
690
  };
660
691
  };
661
692
  /**
@@ -676,9 +707,15 @@ class Account extends commons_1.TypedEventEmitter {
676
707
  * On each new backend message, we pass it to the notification handler.
677
708
  * On state changes, we map raw socket states to public connection states and emit them.
678
709
  */
679
- setupWebSocketListeners = (handleNotification, onConnectionStateChanged) => {
710
+ setupWebSocketListeners = (onConnectionStateChanged, handleNotification, handleLegacyNotification) => {
680
711
  this.apiClient.transport.ws.removeAllListeners(tcp_1.WebSocketClient.TOPIC.ON_MESSAGE);
681
- this.apiClient.transport.ws.on(tcp_1.WebSocketClient.TOPIC.ON_MESSAGE, notification => handleNotification(notification, notification_1.NotificationSource.WEBSOCKET));
712
+ this.apiClient.transport.ws.on(tcp_1.WebSocketClient.TOPIC.ON_MESSAGE, notification => {
713
+ if (this.checkIsConsumable(notification)) {
714
+ void handleNotification(notification, notification_1.NotificationSource.WEBSOCKET);
715
+ return;
716
+ }
717
+ void handleLegacyNotification(notification, notification_1.NotificationSource.WEBSOCKET);
718
+ });
682
719
  this.apiClient.transport.ws.on(tcp_1.WebSocketClient.TOPIC.ON_STATE_CHANGE, wsState => {
683
720
  const mapping = {
684
721
  [ReconnectingWebsocket_1.WEBSOCKET_STATE.CLOSED]: ConnectionState.CLOSED,
@@ -157,6 +157,11 @@ describe('Account', () => {
157
157
  capabilities: ['legalhold-implicit-consent', 'consumable-notifications'],
158
158
  })
159
159
  .reply(http_status_codes_1.StatusCodes.OK);
160
+ (0, nock_1.default)(MOCK_BACKEND.rest)
161
+ .put(/\/clients\/[\w-]+$/, {
162
+ capabilities: ['legalhold-implicit-consent'],
163
+ })
164
+ .reply(http_status_codes_1.StatusCodes.OK);
160
165
  (0, nock_1.default)(MOCK_BACKEND.rest)
161
166
  .get(self_1.SelfAPI.URL.SELF)
162
167
  .reply(http_status_codes_1.StatusCodes.OK, {
@@ -298,6 +303,7 @@ describe('Account', () => {
298
303
  const onEvent = jest.fn().mockImplementation(() => { });
299
304
  mockNotifications(nbNotifications);
300
305
  await dependencies.account.listen({
306
+ useLegacy: false,
301
307
  onConnectionStateChanged: callWhen(Account_1.ConnectionState.LIVE, async () => {
302
308
  expect(onNotificationStreamProgress).toHaveBeenCalledTimes(nbNotifications);
303
309
  expect(onEvent).toHaveBeenCalledTimes(nbNotifications);
@@ -310,7 +316,10 @@ describe('Account', () => {
310
316
  .mockReturnValue([{ event: { testData: 1 } }]);
311
317
  server.send(JSON.stringify({
312
318
  type: ConsumableNotification_1.ConsumableEvent.EVENT,
313
- data: { delivery_tag: 1000, event: { id: (0, uuid_1.v4)(), payload: [] } },
319
+ data: {
320
+ delivery_tag: 1000,
321
+ event: { id: (0, uuid_1.v4)(), payload: [] },
322
+ },
314
323
  }));
315
324
  await waitFor(() => expect(onEvent).toHaveBeenCalledTimes(1));
316
325
  expect(onEvent).not.toHaveBeenCalledWith(expect.any(Object), notification_2.NotificationSource.NOTIFICATION_STREAM);
@@ -322,7 +331,31 @@ describe('Account', () => {
322
331
  });
323
332
  });
324
333
  });
325
- it('warns consumer of the connection state', async () => {
334
+ it('sends information to consumer of the connection state change in order', async () => {
335
+ await new Promise(async (resolve) => {
336
+ mockNotifications(10);
337
+ const onConnectionStateChanged = jest.fn().mockImplementation((state) => {
338
+ switch (state) {
339
+ case Account_1.ConnectionState.LIVE:
340
+ break;
341
+ case Account_1.ConnectionState.CLOSED:
342
+ // Expect all states to have been called in order
343
+ expect(onConnectionStateChanged).toHaveBeenNthCalledWith(1, Account_1.ConnectionState.PROCESSING_NOTIFICATIONS);
344
+ expect(onConnectionStateChanged).toHaveBeenNthCalledWith(2, Account_1.ConnectionState.CONNECTING);
345
+ expect(onConnectionStateChanged).toHaveBeenNthCalledWith(3, Account_1.ConnectionState.LIVE);
346
+ resolve();
347
+ break;
348
+ }
349
+ });
350
+ const disconnect = await dependencies.account.listen({
351
+ useLegacy: false,
352
+ onConnectionStateChanged,
353
+ });
354
+ await waitFor(() => expect(onConnectionStateChanged).toHaveBeenCalledWith(Account_1.ConnectionState.LIVE));
355
+ disconnect();
356
+ });
357
+ });
358
+ it('warns consumer of the connection close', async () => {
326
359
  await new Promise(async (resolve) => {
327
360
  mockNotifications(10);
328
361
  const onConnectionStateChanged = jest.fn().mockImplementation((state) => {
@@ -332,12 +365,14 @@ describe('Account', () => {
332
365
  case Account_1.ConnectionState.CLOSED:
333
366
  // Expect all states to have been called in order
334
367
  expect(onConnectionStateChanged).toHaveBeenNthCalledWith(1, Account_1.ConnectionState.PROCESSING_NOTIFICATIONS);
335
- expect(onConnectionStateChanged).toHaveBeenNthCalledWith(2, Account_1.ConnectionState.LIVE);
368
+ expect(onConnectionStateChanged).toHaveBeenNthCalledWith(2, Account_1.ConnectionState.CONNECTING);
369
+ expect(onConnectionStateChanged).toHaveBeenNthCalledWith(3, Account_1.ConnectionState.CLOSED);
336
370
  resolve();
337
371
  break;
338
372
  }
339
373
  });
340
374
  const disconnect = await dependencies.account.listen({
375
+ useLegacy: false,
341
376
  onConnectionStateChanged,
342
377
  });
343
378
  await waitFor(() => expect(onConnectionStateChanged).toHaveBeenCalledWith(Account_1.ConnectionState.PROCESSING_NOTIFICATIONS));
@@ -351,6 +386,7 @@ describe('Account', () => {
351
386
  const onEvent = jest.fn();
352
387
  mockNotifications(nbNotifications);
353
388
  await dependencies.account.listen({
389
+ useLegacy: false,
354
390
  onConnectionStateChanged: callWhen(Account_1.ConnectionState.LIVE, () => {
355
391
  expect(onNotificationStreamProgress).toHaveBeenCalledTimes(nbNotifications);
356
392
  expect(onEvent).toHaveBeenCalledTimes(nbNotifications);
@@ -362,28 +398,40 @@ describe('Account', () => {
362
398
  });
363
399
  });
364
400
  });
365
- it('does not stop proccessing messages if websocket connection is aborted', async () => {
401
+ it('does stop processing messages if websocket connection is aborted', async () => {
366
402
  jest
367
403
  .spyOn(dependencies.account, 'getClientCapabilities')
368
- .mockReturnValue([client_1.ClientCapability.LEGAL_HOLD_IMPLICIT_CONSENT]);
404
+ .mockReturnValue([client_1.ClientCapability.LEGAL_HOLD_IMPLICIT_CONSENT, client_1.ClientCapability.CONSUMABLE_NOTIFICATIONS]);
369
405
  const nbNotifications = 10;
370
- const onNotificationStreamProgress = jest
406
+ const onNotificationStreamProgress = jest.fn();
407
+ const onEvent = jest
371
408
  .fn()
372
409
  .mockImplementationOnce(() => { })
373
410
  .mockImplementationOnce(() => {
374
411
  // abort websocket connection after the second notification is processeed
375
- server.close();
412
+ server.close({ reason: 'Aborted by test', code: 2000, wasClean: true });
376
413
  });
377
- const onEvent = jest.fn();
378
- mockNotifications(nbNotifications);
379
414
  return new Promise(async (resolve) => {
380
415
  return dependencies.account.listen({
416
+ useLegacy: false,
381
417
  onConnectionStateChanged: async (state) => {
382
418
  switch (state) {
383
- case Account_1.ConnectionState.LIVE:
384
- expect(onNotificationStreamProgress).toHaveBeenCalledTimes(10);
385
- expect(onEvent).toHaveBeenCalledTimes(10);
386
- expect(onEvent).toHaveBeenCalledWith(expect.any(Object), notification_2.NotificationSource.NOTIFICATION_STREAM);
419
+ case Account_1.ConnectionState.CONNECTING:
420
+ await server.connected;
421
+ for (let i = 0; i < nbNotifications; i++) {
422
+ server.send(JSON.stringify({
423
+ type: ConsumableNotification_1.ConsumableEvent.EVENT,
424
+ data: {
425
+ delivery_tag: 1000,
426
+ event: { id: (0, uuid_1.v4)(), payload: [{ domain: 'zinfra.io', type: 'federation.delete' }] },
427
+ },
428
+ }));
429
+ }
430
+ break;
431
+ case Account_1.ConnectionState.CLOSED:
432
+ expect(onNotificationStreamProgress).toHaveBeenCalledTimes(2);
433
+ expect(onEvent).toHaveBeenCalledTimes(2);
434
+ expect(onEvent).toHaveBeenCalledWith({ domain: 'zinfra.io', type: 'federation.delete' }, notification_2.NotificationSource.WEBSOCKET);
387
435
  expect(dependencies.account.service.notification.handleNotification).not.toHaveBeenCalledWith(expect.any(Object), notification_2.NotificationSource.WEBSOCKET);
388
436
  resolve();
389
437
  }
@@ -53,6 +53,6 @@ export declare class ClientService {
53
53
  * @param currentClient - the id of the current client (to be excluded from the list)
54
54
  */
55
55
  synchronizeClients(currentClient: string): Promise<MetaClient[]>;
56
- register(loginData: LoginData, clientInfo: ClientInfo, { prekeys, lastPrekey }: InitialPrekeys): Promise<RegisteredClient>;
56
+ register(loginData: LoginData, clientInfo: ClientInfo, { prekeys, lastPrekey }: InitialPrekeys, useLegacyNotificationStream?: boolean): Promise<RegisteredClient>;
57
57
  }
58
58
  //# sourceMappingURL=ClientService.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ClientService.d.ts","sourceRoot":"","sources":["../../src/client/ClientService.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,SAAS,EAAC,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAEL,oBAAoB,EAGpB,gBAAgB,EACjB,MAAM,iCAAiC,CAAC;AAKzC,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AAEjD,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAC,cAAc,EAAC,MAAM,2DAA2D,CAAC;AAEzF,OAAO,EAAC,UAAU,EAAoD,MAAM,IAAI,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O,CAAC;IAMhF;;;OAGG;IACU,iBAAiB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;YAcpD,cAAc;IAQ5B;;;;;;;OAOG;IACU,UAAU,IAAI,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAyB1D,OAAO,CAAC,iBAAiB;IAIlB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAIjG;;;OAGG;IACU,kBAAkB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAUhE,QAAQ,CACnB,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,UAAU,EACtB,EAAC,OAAO,EAAE,UAAU,EAAC,EAAE,cAAc,EACrC,2BAA2B,GAAE,OAAc,GAC1C,OAAO,CAAC,gBAAgB,CAAC;CAkC7B"}
@@ -131,16 +131,20 @@ class ClientService {
131
131
  return this.database.createClientList({ id: this.apiClient.context.userId, domain: this.apiClient.context.domain ?? '' }, filteredClients);
132
132
  }
133
133
  // TODO: Split functionality into "create" and "register" client
134
- async register(loginData, clientInfo, { prekeys, lastPrekey }) {
134
+ async register(loginData, clientInfo, { prekeys, lastPrekey }, useLegacyNotificationStream = true) {
135
135
  if (!this.apiClient.context) {
136
136
  throw new Error('Context is not set.');
137
137
  }
138
138
  if (loginData.clientType === client_1.ClientType.NONE) {
139
139
  throw new Error(`Can't register client of type "${client_1.ClientType.NONE}"`);
140
140
  }
141
+ const capabilities = [client_1.ClientCapability.LEGAL_HOLD_IMPLICIT_CONSENT];
142
+ if (!useLegacyNotificationStream) {
143
+ capabilities.push(client_1.ClientCapability.CONSUMABLE_NOTIFICATIONS);
144
+ }
141
145
  const newClient = {
142
146
  class: clientInfo.classification,
143
- capabilities: [client_1.ClientCapability.LEGAL_HOLD_IMPLICIT_CONSENT, client_1.ClientCapability.CONSUMABLE_NOTIFICATIONS],
147
+ capabilities,
144
148
  cookie: clientInfo.cookieLabel,
145
149
  label: clientInfo.label,
146
150
  lastkey: lastPrekey,
@@ -1 +1 @@
1
- {"version":3,"file":"messageAdd.d.ts","sourceRoot":"","sources":["../../../../../../src/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,8BAA8B,EAAC,MAAM,+BAA+B,CAAC;AAO7E,OAAO,EAAC,mBAAmB,EAAC,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAC,UAAU,EAAuB,MAAM,gCAAgC,CAAC;AAEhF,UAAU,yBAAyB;IACjC,KAAK,EAAE,8BAA8B,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,UAAU,CAAC;CACxB;AAED,eAAO,MAAM,mBAAmB,oCAI7B,yBAAyB,KAAG,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAoChE,CAAC"}
1
+ {"version":3,"file":"messageAdd.d.ts","sourceRoot":"","sources":["../../../../../../src/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,8BAA8B,EAAC,MAAM,+BAA+B,CAAC;AAK7E,OAAO,EAAC,mBAAmB,EAAC,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAC,UAAU,EAAuB,MAAM,gCAAgC,CAAC;AAEhF,UAAU,yBAAyB;IACjC,KAAK,EAAE,8BAA8B,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,UAAU,CAAC;CACxB;AAED,eAAO,MAAM,mBAAmB,oCAI7B,yBAAyB,KAAG,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAgChE,CAAC"}
@@ -21,7 +21,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.handleMLSMessageAdd = void 0;
22
22
  const bazinga64_1 = require("bazinga64");
23
23
  const protocol_messaging_1 = require("@wireapp/protocol-messaging");
24
- const IncomingProposalsQueue_1 = require("./IncomingProposalsQueue");
25
24
  const MLSService_1 = require("../../../MLSService/MLSService");
26
25
  const handleMLSMessageAdd = async ({ event, groupId, mlsService, }) => {
27
26
  const encryptedData = bazinga64_1.Decoder.fromBase64(event.data).asBytes;
@@ -39,16 +38,12 @@ const handleMLSMessageAdd = async ({ event, groupId, mlsService, }) => {
39
38
  }
40
39
  // Check if the message includes proposals
41
40
  if (typeof commitDelay === 'number') {
42
- (0, IncomingProposalsQueue_1.queueProposal)(async () => {
43
- // we are dealing with a proposal, add a task to process this proposal later on
44
- // Those proposals are stored inside of coreCrypto and will be handled after a timeout
45
- await mlsService.handlePendingProposals({
46
- groupId,
47
- delayInMs: commitDelay ?? 0,
48
- eventTime: event.time,
49
- });
50
- }).catch(error => {
51
- console.error('Failed to process proposal:', error);
41
+ // we are dealing with a proposal, add a task to process this proposal later on
42
+ // Those proposals are stored inside of coreCrypto and will be handled after a timeout
43
+ await mlsService.handlePendingProposals({
44
+ groupId,
45
+ delayInMs: commitDelay ?? 0,
46
+ eventTime: event.time,
52
47
  });
53
48
  }
54
49
  return message ? { event, decryptedData: protocol_messaging_1.GenericMessage.decode(message) } : null;
@@ -3,7 +3,7 @@ import { APIClient } from '@wireapp/api-client';
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, abortController?: AbortController): Promise<{
7
7
  notifications: Notification[];
8
8
  missedNotification?: string;
9
9
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"NotificationBackendRepository.d.ts","sourceRoot":"","sources":["../../src/notification/NotificationBackendRepository.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,YAAY,EAAC,MAAM,uCAAuC,CAAC;AAEnE,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAE9C,qBAAa,6BAA6B;IAC5B,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAAT,SAAS,EAAE,SAAS;IAEpC,mBAAmB,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,kBAAkB,CAAC,EAAE,MAAM;;;;IAIxE,mBAAmB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;CAGrE"}
1
+ {"version":3,"file":"NotificationBackendRepository.d.ts","sourceRoot":"","sources":["../../src/notification/NotificationBackendRepository.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,YAAY,EAAC,MAAM,uCAAuC,CAAC;AAEnE,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAE9C,qBAAa,6BAA6B;IAC5B,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAAT,SAAS,EAAE,SAAS;IAEpC,mBAAmB,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,kBAAkB,CAAC,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,eAAe;;;;IAI3G,mBAAmB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;CAGrE"}
@@ -24,8 +24,8 @@ class NotificationBackendRepository {
24
24
  constructor(apiClient) {
25
25
  this.apiClient = apiClient;
26
26
  }
27
- async getAllNotifications(clientId, lastNotificationId) {
28
- return this.apiClient.api.notification.getAllNotifications(clientId, lastNotificationId);
27
+ async getAllNotifications(clientId, lastNotificationId, abortController) {
28
+ return this.apiClient.api.notification.getAllNotifications(clientId, lastNotificationId, abortController);
29
29
  }
30
30
  getLastNotification(clientId) {
31
31
  return this.apiClient.api.notification.getLastNotification(clientId);
@@ -70,7 +70,7 @@ export declare class NotificationService extends TypedEventEmitter<Events> {
70
70
  *
71
71
  * @deprecated When all client are migrated to the consumable/async notification stream, this method must be removed.
72
72
  */
73
- legacyProcessNotificationStream(notificationHandler: NotificationHandler, onMissedNotifications: (notificationId: string) => void): Promise<{
73
+ legacyProcessNotificationStream(notificationHandler: NotificationHandler, onMissedNotifications: (notificationId: string) => void, abortHandler?: AbortController): Promise<{
74
74
  total: number;
75
75
  error: number;
76
76
  success: number;
@@ -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,CAAC;AAEnE,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAa,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAC,cAAc,EAAC,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAC,UAAU,EAA4B,MAAM,uBAAuB,CAAC;AAI5E,OAAO,EAAC,kBAAkB,EAAC,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAC,mBAAmB,EAAC,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAY,iBAAiB,EAAC,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAC,eAAe,EAAC,MAAM,2BAA2B,CAAC;AAE1D,MAAM,MAAM,mBAAmB,GAAG;IAChC,0CAA0C;IAC1C,KAAK,EAAE,YAAY,CAAC;IACpB,kEAAkE;IAClE,aAAa,CAAC,EAAE,cAAc,CAAC;IAC/B,8FAA8F;IAC9F,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAC1B;IAAC,MAAM,EAAE,WAAW,CAAA;CAAC,GACrB;IAAC,MAAM,EAAE,SAAS,CAAA;CAAC,GACnB;IAAC,MAAM,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,mBAAmB,GAAG,IAAI,CAAA;CAAC,CAAC;AAE7D,aAAK,KAAK;IACR,kBAAkB,iDAAiD;CACpE;AAED,MAAM,MAAM,mBAAmB,GAAG,CAChC,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,kBAAkB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AAkB,CAC9B,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,kBAAkB,EAC1B,MAAM,GAAE,OAAe,GACtB,cAAc,CAAC,mBAAmB,CAAC;IAmCtC;;;;;OAKG;YACW,WAAW;CAc1B"}
@@ -43,9 +43,9 @@ class NotificationService extends commons_1.TypedEventEmitter {
43
43
  this.backend = new NotificationBackendRepository_1.NotificationBackendRepository(this.apiClient);
44
44
  this.database = new NotificationDatabaseRepository_1.NotificationDatabaseRepository(storeEngine);
45
45
  }
46
- async getAllNotifications(since) {
46
+ async getAllNotifications(since, abortController) {
47
47
  const clientId = this.apiClient.clientId;
48
- return this.backend.getAllNotifications(clientId, since);
48
+ return this.backend.getAllNotifications(clientId, since, abortController);
49
49
  }
50
50
  /**
51
51
  * Should only be called with a completely new client.
@@ -95,9 +95,9 @@ class NotificationService extends commons_1.TypedEventEmitter {
95
95
  *
96
96
  * @deprecated When all client are migrated to the consumable/async notification stream, this method must be removed.
97
97
  */
98
- async legacyProcessNotificationStream(notificationHandler, onMissedNotifications) {
98
+ async legacyProcessNotificationStream(notificationHandler, onMissedNotifications, abortHandler) {
99
99
  const lastNotificationId = await this.database.getLastNotificationId();
100
- const { notifications, missedNotification } = await this.getAllNotifications(lastNotificationId);
100
+ const { notifications, missedNotification } = await this.getAllNotifications(lastNotificationId, abortHandler);
101
101
  if (missedNotification) {
102
102
  onMissedNotifications(missedNotification);
103
103
  }
@@ -107,6 +107,13 @@ class NotificationService extends commons_1.TypedEventEmitter {
107
107
  : `No notification to process from the stream`;
108
108
  this.logger.log(logMessage);
109
109
  for (const [index, notification] of notifications.entries()) {
110
+ if (abortHandler?.signal.aborted) {
111
+ /* Stop handling notifications if the websocket has been disconnected.
112
+ * Upon reconnecting we are going to restart handling the notification stream for where we left of
113
+ */
114
+ this.logger.warn(`Stop processing notifications as connection to websocket was closed`);
115
+ return results;
116
+ }
110
117
  try {
111
118
  await notificationHandler(notification, Notifications_types_1.NotificationSource.NOTIFICATION_STREAM, {
112
119
  done: index + 1,
package/package.json CHANGED
@@ -11,20 +11,20 @@
11
11
  "./lib/cryptography/AssetCryptography/crypto.node": "./lib/cryptography/AssetCryptography/crypto.browser.js"
12
12
  },
13
13
  "dependencies": {
14
- "@wireapp/api-client": "^27.70.0",
14
+ "@wireapp/api-client": "^27.71.0",
15
15
  "@wireapp/commons": "^5.4.3",
16
16
  "@wireapp/core-crypto": "7.0.1",
17
17
  "@wireapp/cryptobox": "12.8.0",
18
18
  "@wireapp/priority-queue": "^2.1.11",
19
19
  "@wireapp/promise-queue": "^2.4.1",
20
- "@wireapp/protocol-messaging": "1.52.0",
20
+ "@wireapp/protocol-messaging": "1.53.0",
21
21
  "@wireapp/store-engine": "^5.1.11",
22
- "axios": "1.7.9",
22
+ "axios": "1.11.0",
23
23
  "bazinga64": "^6.5.0",
24
24
  "deepmerge-ts": "6.0.0",
25
25
  "hash.js": "1.1.7",
26
26
  "http-status-codes": "2.3.0",
27
- "idb": "8.0.2",
27
+ "idb": "8.0.3",
28
28
  "logdown": "3.3.1",
29
29
  "long": "^5.2.0",
30
30
  "uuid": "9.0.1",
@@ -61,6 +61,6 @@
61
61
  "test:coverage": "jest --coverage",
62
62
  "watch": "tsc --watch"
63
63
  },
64
- "version": "46.31.7",
65
- "gitHead": "c4711f0c33eebf8910cd9a6dd4f94f8696c3da7b"
64
+ "version": "46.32.0",
65
+ "gitHead": "7e213a5a2a318bbcd06f3f87808ebe43b0cb4cae"
66
66
  }
@@ -1,5 +0,0 @@
1
- import { Task } from '@wireapp/promise-queue';
2
- export declare function queueProposal<T>(cb: Task<T>): Promise<T>;
3
- export declare function resumeProposalProcessing(): void;
4
- export declare function pauseProposalProcessing(): void;
5
- //# sourceMappingURL=IncomingProposalsQueue.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IncomingProposalsQueue.d.ts","sourceRoot":"","sources":["../../../../../../../src/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingProposalsQueue/IncomingProposalsQueue.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAC,IAAI,EAAe,MAAM,wBAAwB,CAAC;AAM1D,wBAAgB,aAAa,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAGxD;AAED,wBAAgB,wBAAwB,IAAI,IAAI,CAG/C;AAED,wBAAgB,uBAAuB,IAAI,IAAI,CAG9C"}
@@ -1,39 +0,0 @@
1
- "use strict";
2
- /*
3
- * Wire
4
- * Copyright (C) 2025 Wire Swiss GmbH
5
- *
6
- * This program is free software: you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation, either version 3 of the License, or
9
- * (at your option) any later version.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License
17
- * along with this program. If not, see http://www.gnu.org/licenses/.
18
- *
19
- */
20
- Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.queueProposal = queueProposal;
22
- exports.resumeProposalProcessing = resumeProposalProcessing;
23
- exports.pauseProposalProcessing = pauseProposalProcessing;
24
- const commons_1 = require("@wireapp/commons");
25
- const promise_queue_1 = require("@wireapp/promise-queue");
26
- const logger = commons_1.LogFactory.getLogger('@wireapp/core/MLSService/IncomingProposalsQueue');
27
- const proposalsQueue = new promise_queue_1.PromiseQueue({ name: 'incoming-proposals-queue', paused: true });
28
- function queueProposal(cb) {
29
- logger.info('Queueing proposal for processing');
30
- return proposalsQueue.push(cb);
31
- }
32
- function resumeProposalProcessing() {
33
- logger.info('Resuming proposal processing');
34
- proposalsQueue.pause(false);
35
- }
36
- function pauseProposalProcessing() {
37
- logger.info('Pausing proposal processing');
38
- proposalsQueue.pause(true);
39
- }
@@ -1,2 +0,0 @@
1
- export * from './IncomingProposalsQueue';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingProposalsQueue/index.ts"],"names":[],"mappings":"AAmBA,cAAc,0BAA0B,CAAC"}
@@ -1,35 +0,0 @@
1
- "use strict";
2
- /*
3
- * Wire
4
- * Copyright (C) 2023 Wire Swiss GmbH
5
- *
6
- * This program is free software: you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation, either version 3 of the License, or
9
- * (at your option) any later version.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License
17
- * along with this program. If not, see http://www.gnu.org/licenses/.
18
- *
19
- */
20
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
21
- if (k2 === undefined) k2 = k;
22
- var desc = Object.getOwnPropertyDescriptor(m, k);
23
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
24
- desc = { enumerable: true, get: function() { return m[k]; } };
25
- }
26
- Object.defineProperty(o, k2, desc);
27
- }) : (function(o, m, k, k2) {
28
- if (k2 === undefined) k2 = k;
29
- o[k2] = m[k];
30
- }));
31
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
32
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
33
- };
34
- Object.defineProperty(exports, "__esModule", { value: true });
35
- __exportStar(require("./IncomingProposalsQueue"), exports);