@wireapp/core 20.2.0 → 20.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
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
+ # [20.3.0](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@20.2.0...@wireapp/core@20.3.0) (2021-12-17)
7
+
8
+
9
+ ### Features
10
+
11
+ * **core:** Add lastRead and Countly message to the core ([#4204](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/issues/4204)) ([64a2336](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/commit/64a2336f9de1f7ada34bd88652c624e28ac8169d))
12
+
13
+
14
+
15
+
16
+
6
17
  # [20.2.0](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@20.1.3...@wireapp/core@20.2.0) (2021-12-16)
7
18
 
8
19
 
package/package.json CHANGED
@@ -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": "20.2.0",
73
- "gitHead": "5ff57f8efd8713ae9767f12c103ea918acbbaa3b"
72
+ "version": "20.3.0",
73
+ "gitHead": "552d75acec7e4a981d8b0ca28cbf852ff3c064bc"
74
74
  }
@@ -1,8 +1,8 @@
1
1
  /// <reference types="node" />
2
2
  import type { APIClient } from '@wireapp/api-client';
3
- import { MessageSendingStatus, Conversation, DefaultConversationRoleName, MutedStatus, QualifiedUserClients, UserClients, ClientMismatch } from '@wireapp/api-client/src/conversation/';
4
- import type { ConversationMemberLeaveEvent } from '@wireapp/api-client/src/event/';
5
- import type { QualifiedId, UserPreKeyBundleMap } from '@wireapp/api-client/src/user/';
3
+ import { MessageSendingStatus, Conversation, DefaultConversationRoleName, MutedStatus, QualifiedUserClients, UserClients, ClientMismatch } from '@wireapp/api-client/src/conversation';
4
+ import type { ConversationMemberLeaveEvent } from '@wireapp/api-client/src/event';
5
+ import type { QualifiedId, UserPreKeyBundleMap } from '@wireapp/api-client/src/user';
6
6
  import { GenericMessage } from '@wireapp/protocol-messaging';
7
7
  import { MessageTimer } from '../conversation/';
8
8
  import type { RemoteData } from '../conversation/content/';
@@ -63,6 +63,7 @@ export declare class ConversationService {
63
63
  private readonly apiClient;
64
64
  readonly messageTimer: MessageTimer;
65
65
  private readonly messageService;
66
+ private selfConversationId?;
66
67
  constructor(apiClient: APIClient, cryptographyService: CryptographyService);
67
68
  private createEphemeral;
68
69
  private getConversationQualifiedMembers;
@@ -76,7 +77,7 @@ export declare class ConversationService {
76
77
  */
77
78
  private getQualifiedPreKeyBundle;
78
79
  getPreKeyBundleMap(conversationId: string, userIds?: string[] | UserClients): Promise<UserPreKeyBundleMap>;
79
- private getSelfConversation;
80
+ private getSelfConversationId;
80
81
  private getQualifiedRecipientsForConversation;
81
82
  private getRecipientsForConversation;
82
83
  /**
@@ -105,7 +106,33 @@ export declare class ConversationService {
105
106
  private generateSessionResetGenericMessage;
106
107
  private generateCallGenericMessage;
107
108
  private generateTextGenericMessage;
108
- clearConversation(conversationId: string, timestamp?: number | Date, messageId?: string, sendAsProtobuf?: boolean, conversationDomain?: string): Promise<ClearConversationMessage>;
109
+ clearConversation(conversationId: string, timestamp?: number | Date, messageId?: string, sendAsProtobuf?: boolean): Promise<ClearConversationMessage>;
110
+ /**
111
+ * Sends a LastRead message to the current user's self conversation.
112
+ * This will allow all the user's devices to compute which messages are unread
113
+ *
114
+ * @param conversationId The conversation which has been read
115
+ * @param lastReadTimestamp The timestamp at which the conversation was read
116
+ * @param sendAsProtobuf?
117
+ * @return Resolves when the message has been sent
118
+ */
119
+ sendLastRead(conversationId: string, lastReadTimestamp: number, sendAsProtobuf?: boolean): Promise<(MessageSendingStatus & {
120
+ errored?: boolean | undefined;
121
+ }) | (ClientMismatch & {
122
+ errored?: boolean | undefined;
123
+ })>;
124
+ /**
125
+ * Syncs all self user's devices with the countly id
126
+ *
127
+ * @param countlyId The countly id of the current device
128
+ * @param sendAsProtobuf?
129
+ * @return Resolves when the message has been sent
130
+ */
131
+ sendCountlySync(countlyId: string, sendAsProtobuf?: boolean): Promise<(MessageSendingStatus & {
132
+ errored?: boolean | undefined;
133
+ }) | (ClientMismatch & {
134
+ errored?: boolean | undefined;
135
+ })>;
109
136
  /**
110
137
  * Get a fresh list from backend of clients for all the participants of the conversation.
111
138
  * This is a hacky way of getting all the clients for a conversation.
@@ -19,8 +19,8 @@
19
19
  */
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.ConversationService = exports.MessageTargetMode = void 0;
22
- const conversation_1 = require("@wireapp/api-client/src/conversation/");
23
- const data_1 = require("@wireapp/api-client/src/conversation/data/");
22
+ const conversation_1 = require("@wireapp/api-client/src/conversation");
23
+ const data_1 = require("@wireapp/api-client/src/conversation/data");
24
24
  const protocol_messaging_1 = require("@wireapp/protocol-messaging");
25
25
  const conversation_2 = require("../conversation/");
26
26
  const AssetCryptography_1 = require("../cryptography/AssetCryptography");
@@ -134,9 +134,13 @@ class ConversationService {
134
134
  return bundleMap;
135
135
  }, {});
136
136
  }
137
- getSelfConversation() {
138
- const { userId } = this.apiClient.context;
139
- return this.apiClient.conversation.api.getConversation(userId);
137
+ async getSelfConversationId() {
138
+ if (!this.selfConversationId) {
139
+ const { userId } = this.apiClient.context;
140
+ const { qualified_id, id } = await this.apiClient.conversation.api.getConversation(userId);
141
+ this.selfConversationId = qualified_id || { id, domain: '' };
142
+ }
143
+ return this.selfConversationId;
140
144
  }
141
145
  async getQualifiedRecipientsForConversation(conversationId, userIds) {
142
146
  if ((0, TypePredicateUtil_1.isQualifiedUserClients)(userIds)) {
@@ -426,7 +430,7 @@ class ConversationService {
426
430
  const expireAfterMillis = this.messageTimer.getMessageTimer(payloadBundle.conversation);
427
431
  return expireAfterMillis > 0 ? this.createEphemeral(genericMessage, expireAfterMillis) : genericMessage;
428
432
  }
429
- async clearConversation(conversationId, timestamp = new Date(), messageId = MessageBuilder_1.MessageBuilder.createId(), sendAsProtobuf, conversationDomain) {
433
+ async clearConversation(conversationId, timestamp = new Date(), messageId = MessageBuilder_1.MessageBuilder.createId(), sendAsProtobuf) {
430
434
  if (timestamp instanceof Date) {
431
435
  timestamp = timestamp.getTime();
432
436
  }
@@ -439,9 +443,9 @@ class ConversationService {
439
443
  [conversation_2.GenericMessageType.CLEARED]: clearedMessage,
440
444
  messageId,
441
445
  });
442
- const { id: selfConversationId } = await this.getSelfConversation();
446
+ const { id: selfConversationId, domain } = await this.getSelfConversationId();
443
447
  await this.sendGenericMessage(this.apiClient.validatedClientId, selfConversationId, genericMessage, {
444
- conversationDomain,
448
+ conversationDomain: domain,
445
449
  sendAsProtobuf,
446
450
  });
447
451
  return {
@@ -456,6 +460,53 @@ class ConversationService {
456
460
  type: conversation_2.PayloadBundleType.CONVERSATION_CLEAR,
457
461
  };
458
462
  }
463
+ /**
464
+ * Sends a LastRead message to the current user's self conversation.
465
+ * This will allow all the user's devices to compute which messages are unread
466
+ *
467
+ * @param conversationId The conversation which has been read
468
+ * @param lastReadTimestamp The timestamp at which the conversation was read
469
+ * @param sendAsProtobuf?
470
+ * @return Resolves when the message has been sent
471
+ */
472
+ async sendLastRead(conversationId, lastReadTimestamp, sendAsProtobuf) {
473
+ const lastRead = new protocol_messaging_1.LastRead({
474
+ conversationId,
475
+ lastReadTimestamp,
476
+ });
477
+ const genericMessage = protocol_messaging_1.GenericMessage.create({
478
+ [conversation_2.GenericMessageType.LAST_READ]: lastRead,
479
+ messageId: MessageBuilder_1.MessageBuilder.createId(),
480
+ });
481
+ const { id: selfConversationId, domain: selfConversationDomain } = await this.getSelfConversationId();
482
+ return this.sendGenericMessage(this.apiClient.validatedClientId, selfConversationId, genericMessage, {
483
+ conversationDomain: selfConversationDomain,
484
+ sendAsProtobuf,
485
+ });
486
+ }
487
+ /**
488
+ * Syncs all self user's devices with the countly id
489
+ *
490
+ * @param countlyId The countly id of the current device
491
+ * @param sendAsProtobuf?
492
+ * @return Resolves when the message has been sent
493
+ */
494
+ async sendCountlySync(countlyId, sendAsProtobuf) {
495
+ const { id: selfConversationId, domain: selfConversationDomain } = await this.getSelfConversationId();
496
+ const dataTransfer = new protocol_messaging_1.DataTransfer({
497
+ trackingIdentifier: {
498
+ identifier: countlyId,
499
+ },
500
+ });
501
+ const genericMessage = new protocol_messaging_1.GenericMessage({
502
+ [conversation_2.GenericMessageType.DATA_TRANSFER]: dataTransfer,
503
+ messageId: MessageBuilder_1.MessageBuilder.createId(),
504
+ });
505
+ return this.sendGenericMessage(this.apiClient.validatedClientId, selfConversationId, genericMessage, {
506
+ conversationDomain: selfConversationDomain,
507
+ sendAsProtobuf,
508
+ });
509
+ }
459
510
  /**
460
511
  * Get a fresh list from backend of clients for all the participants of the conversation.
461
512
  * This is a hacky way of getting all the clients for a conversation.
@@ -500,7 +551,7 @@ class ConversationService {
500
551
  [conversation_2.GenericMessageType.HIDDEN]: content,
501
552
  messageId,
502
553
  });
503
- const { id: selfConversationId } = await this.getSelfConversation();
554
+ const { id: selfConversationId } = await this.getSelfConversationId();
504
555
  await this.sendGenericMessage(this.apiClient.validatedClientId, selfConversationId, genericMessage, {
505
556
  sendAsProtobuf,
506
557
  conversationDomain,
@@ -10,6 +10,7 @@ export declare enum GenericMessageType {
10
10
  CLIENT_ACTION = "clientAction",
11
11
  COMPOSITE = "composite",
12
12
  CONFIRMATION = "confirmation",
13
+ DATA_TRANSFER = "dataTransfer",
13
14
  DELETED = "deleted",
14
15
  EDITED = "edited",
15
16
  EPHEMERAL = "ephemeral",
@@ -33,6 +33,7 @@ var GenericMessageType;
33
33
  GenericMessageType["CLIENT_ACTION"] = "clientAction";
34
34
  GenericMessageType["COMPOSITE"] = "composite";
35
35
  GenericMessageType["CONFIRMATION"] = "confirmation";
36
+ GenericMessageType["DATA_TRANSFER"] = "dataTransfer";
36
37
  GenericMessageType["DELETED"] = "deleted";
37
38
  GenericMessageType["EDITED"] = "edited";
38
39
  GenericMessageType["EPHEMERAL"] = "ephemeral";