@wireapp/core 20.1.2 → 20.4.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 +41 -0
- package/package.json +3 -3
- package/src/main/broadcast/BroadcastService.d.ts +2 -2
- package/src/main/broadcast/BroadcastService.js +3 -2
- package/src/main/conversation/AssetService.d.ts +17 -0
- package/src/main/conversation/AssetService.js +20 -1
- package/src/main/conversation/ConversationService.d.ts +32 -5
- package/src/main/conversation/ConversationService.js +60 -9
- package/src/main/conversation/GenericMessageType.d.ts +1 -0
- package/src/main/conversation/GenericMessageType.js +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,47 @@
|
|
|
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.4.0](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@20.3.0...@wireapp/core@20.4.0) (2021-12-17)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **core:** Allow broadcasting to a limited set of users ([99dca26](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/commit/99dca265bc38e84b6279ca5ac9a928e6ef7e3239))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [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)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* **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))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# [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)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Features
|
|
32
|
+
|
|
33
|
+
* **core:** Add a method to upload an unencrypted asset ([#4203](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/issues/4203)) ([7bbef28](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/commit/7bbef28b49b877312512dc59c31d2249f876fa67))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
## [20.1.3](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@20.1.2...@wireapp/core@20.1.3) (2021-12-16)
|
|
40
|
+
|
|
41
|
+
**Note:** Version bump only for package @wireapp/core
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
6
47
|
## [20.1.2](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@20.1.1...@wireapp/core@20.1.2) (2021-12-15)
|
|
7
48
|
|
|
8
49
|
|
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": "16.
|
|
8
|
+
"@wireapp/api-client": "16.2.0",
|
|
9
9
|
"@wireapp/cryptobox": "12.7.1",
|
|
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": "20.
|
|
73
|
-
"gitHead": "
|
|
72
|
+
"version": "20.4.0",
|
|
73
|
+
"gitHead": "402569ffffefe2ee4319454e04219374685d70dd"
|
|
74
74
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { APIClient } from '@wireapp/api-client';
|
|
2
|
-
import { ClientMismatch } from '@wireapp/api-client/src/conversation';
|
|
2
|
+
import { ClientMismatch, UserClients } from '@wireapp/api-client/src/conversation';
|
|
3
3
|
import type { UserPreKeyBundleMap } from '@wireapp/api-client/src/user/';
|
|
4
4
|
import { GenericMessage } from '@wireapp/protocol-messaging';
|
|
5
5
|
import type { CryptographyService } from '../cryptography/';
|
|
@@ -9,5 +9,5 @@ export declare class BroadcastService {
|
|
|
9
9
|
private readonly messageService;
|
|
10
10
|
constructor(apiClient: APIClient, cryptographyService: CryptographyService);
|
|
11
11
|
getPreKeyBundlesFromTeam(teamId: string, skipOwnClients?: boolean): Promise<UserPreKeyBundleMap>;
|
|
12
|
-
broadcastGenericMessage(genericMessage: GenericMessage,
|
|
12
|
+
broadcastGenericMessage(genericMessage: GenericMessage, recipients: UserPreKeyBundleMap | UserClients, sendAsProtobuf?: boolean): Promise<ClientMismatch>;
|
|
13
13
|
}
|
|
@@ -43,10 +43,11 @@ class BroadcastService {
|
|
|
43
43
|
return bundleMap;
|
|
44
44
|
}, {});
|
|
45
45
|
}
|
|
46
|
-
async broadcastGenericMessage(genericMessage,
|
|
46
|
+
async broadcastGenericMessage(genericMessage, recipients, sendAsProtobuf) {
|
|
47
47
|
const plainTextArray = protocol_messaging_1.GenericMessage.encode(genericMessage).finish();
|
|
48
|
-
return this.messageService.sendMessage(this.apiClient.validatedClientId,
|
|
48
|
+
return this.messageService.sendMessage(this.apiClient.validatedClientId, recipients, plainTextArray, {
|
|
49
49
|
sendAsProtobuf,
|
|
50
|
+
reportMissing: Object.keys(recipients),
|
|
50
51
|
});
|
|
51
52
|
}
|
|
52
53
|
}
|
|
@@ -6,5 +6,22 @@ import type { EncryptedAssetUploaded } from '../cryptography/';
|
|
|
6
6
|
export declare class AssetService {
|
|
7
7
|
private readonly apiClient;
|
|
8
8
|
constructor(apiClient: APIClient);
|
|
9
|
+
/**
|
|
10
|
+
* Uploads a raw asset to the backend without encrypting it
|
|
11
|
+
*
|
|
12
|
+
* @param plainText The raw content of the asset to upload
|
|
13
|
+
* @param options?
|
|
14
|
+
* @param progressCallback?
|
|
15
|
+
* @return cancellable request that resolves with the uploaded image
|
|
16
|
+
*/
|
|
17
|
+
uploadRawAsset(asset: Buffer | Uint8Array, options?: AssetOptions, progressCallback?: ProgressCallback): RequestCancelable<import("@wireapp/api-client/src/asset").AssetUploadData>;
|
|
18
|
+
/**
|
|
19
|
+
* Will encrypt and upload an asset to the backend
|
|
20
|
+
*
|
|
21
|
+
* @param plainText The raw content of the asset to upload
|
|
22
|
+
* @param options?
|
|
23
|
+
* @param progressCallback?
|
|
24
|
+
* @return cancellable request that resolves with the uploaded image and decryption keys
|
|
25
|
+
*/
|
|
9
26
|
uploadAsset(plainText: Buffer | Uint8Array, options?: AssetOptions, progressCallback?: ProgressCallback): Promise<RequestCancelable<EncryptedAssetUploaded>>;
|
|
10
27
|
}
|
|
@@ -24,13 +24,32 @@ class AssetService {
|
|
|
24
24
|
constructor(apiClient) {
|
|
25
25
|
this.apiClient = apiClient;
|
|
26
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Uploads a raw asset to the backend without encrypting it
|
|
29
|
+
*
|
|
30
|
+
* @param plainText The raw content of the asset to upload
|
|
31
|
+
* @param options?
|
|
32
|
+
* @param progressCallback?
|
|
33
|
+
* @return cancellable request that resolves with the uploaded image
|
|
34
|
+
*/
|
|
35
|
+
uploadRawAsset(asset, options, progressCallback) {
|
|
36
|
+
return this.apiClient.asset.api.postAsset(new Uint8Array(asset), options, progressCallback);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Will encrypt and upload an asset to the backend
|
|
40
|
+
*
|
|
41
|
+
* @param plainText The raw content of the asset to upload
|
|
42
|
+
* @param options?
|
|
43
|
+
* @param progressCallback?
|
|
44
|
+
* @return cancellable request that resolves with the uploaded image and decryption keys
|
|
45
|
+
*/
|
|
27
46
|
async uploadAsset(plainText, options, progressCallback) {
|
|
28
47
|
const { cipherText, keyBytes, sha256 } = await (0, AssetCryptography_1.encryptAsset)({
|
|
29
48
|
plainText,
|
|
30
49
|
algorithm: options === null || options === void 0 ? void 0 : options.algorithm,
|
|
31
50
|
hash: options === null || options === void 0 ? void 0 : options.hash,
|
|
32
51
|
});
|
|
33
|
-
const request = this.
|
|
52
|
+
const request = this.uploadRawAsset(cipherText, options, progressCallback);
|
|
34
53
|
return Object.assign(Object.assign({}, request), { response: request.response.then(response => {
|
|
35
54
|
const { key, token } = response;
|
|
36
55
|
return {
|
|
@@ -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
|
|
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
|
|
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
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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
|
|
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.
|
|
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.
|
|
554
|
+
const { id: selfConversationId } = await this.getSelfConversationId();
|
|
504
555
|
await this.sendGenericMessage(this.apiClient.validatedClientId, selfConversationId, genericMessage, {
|
|
505
556
|
sendAsProtobuf,
|
|
506
557
|
conversationDomain,
|
|
@@ -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";
|