@wireapp/core 20.7.1 → 21.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +47 -0
- package/package.json +3 -3
- package/src/main/broadcast/BroadcastService.d.ts +8 -1
- package/src/main/broadcast/BroadcastService.js +14 -3
- package/src/main/conversation/ConversationService.d.ts +1 -2
- package/src/main/conversation/ConversationService.js +3 -3
- package/src/main/cryptography/AssetCryptography/EncryptedAsset.d.ts +3 -4
- package/src/main/cryptography/AssetCryptography/crypto.browser.js +4 -4
- package/src/main/cryptography/AssetCryptography/index.d.ts +2 -3
- package/src/main/cryptography/AssetCryptography/index.js +1 -1
- package/src/main/cryptography/AssetCryptography/interfaces.d.ts +6 -7
- package/src/main/user/UserService.d.ts +11 -1
- package/src/main/user/UserService.js +9 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,53 @@
|
|
|
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
|
+
## [21.0.2](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@21.0.1...@wireapp/core@21.0.2) (2022-01-19)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **core:** Use Uint8Array in place of Buffer ([#4214](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/issues/4214)) ([d9c8692](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/commit/d9c869291e60325411070b87f71d8803561bde49))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [21.0.1](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@21.0.0...@wireapp/core@21.0.1) (2022-01-18)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* **core:** Improve types for setAvailability ([26da881](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/commit/26da88113adf9eaba987ad22265df758231e5dc1))
|
|
23
|
+
* **core:** Improve types for setAvailability ([dcbada4](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/commit/dcbada4e353296e17307baeac8d4b775158a1436))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
# [21.0.0](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@20.7.2...@wireapp/core@21.0.0) (2022-01-18)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
### Features
|
|
33
|
+
|
|
34
|
+
* **core:** Send availability status only to directly connected members ([#4213](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/issues/4213)) ([73bad2f](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/commit/73bad2fb8f75a473b686fa9273b1c03774afd5c7))
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
### BREAKING CHANGES
|
|
38
|
+
|
|
39
|
+
* **core:** the setAvailability of the user service will by default now only send to directly connected users. To send to absolutely all the users in the team call `setAvailability` with the `{sendAll: true}` option
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
## [20.7.2](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@20.7.1...@wireapp/core@20.7.2) (2022-01-12)
|
|
46
|
+
|
|
47
|
+
**Note:** Version bump only for package @wireapp/core
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
6
53
|
## [20.7.1](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@20.7.0...@wireapp/core@20.7.1) (2022-01-12)
|
|
7
54
|
|
|
8
55
|
|
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.6.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": "
|
|
73
|
-
"gitHead": "
|
|
72
|
+
"version": "21.0.2",
|
|
73
|
+
"gitHead": "9838da9b1a1dcb702154c73c28a15e53fc35af9f"
|
|
74
74
|
}
|
|
@@ -8,6 +8,13 @@ export declare class BroadcastService {
|
|
|
8
8
|
private readonly cryptographyService;
|
|
9
9
|
private readonly messageService;
|
|
10
10
|
constructor(apiClient: APIClient, cryptographyService: CryptographyService);
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Will create a key bundle for all the users of the team
|
|
13
|
+
*
|
|
14
|
+
* @param teamId
|
|
15
|
+
* @param skipOwnClients=false
|
|
16
|
+
* @param onlyDirectConnections=false Will generate a bundle only for directly connected users (users the self user has conversation with). Allows avoiding broadcasting messages to too many people
|
|
17
|
+
*/
|
|
18
|
+
getPreKeyBundlesFromTeam(teamId: string, skipOwnClients?: boolean, onlyDirectConnections?: boolean): Promise<UserPreKeyBundleMap>;
|
|
12
19
|
broadcastGenericMessage(genericMessage: GenericMessage, recipients: UserPreKeyBundleMap | UserClients, sendAsProtobuf?: boolean): Promise<ClientMismatch>;
|
|
13
20
|
}
|
|
@@ -27,9 +27,20 @@ class BroadcastService {
|
|
|
27
27
|
this.cryptographyService = cryptographyService;
|
|
28
28
|
this.messageService = new MessageService_1.MessageService(this.apiClient, this.cryptographyService);
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Will create a key bundle for all the users of the team
|
|
32
|
+
*
|
|
33
|
+
* @param teamId
|
|
34
|
+
* @param skipOwnClients=false
|
|
35
|
+
* @param onlyDirectConnections=false Will generate a bundle only for directly connected users (users the self user has conversation with). Allows avoiding broadcasting messages to too many people
|
|
36
|
+
*/
|
|
37
|
+
async getPreKeyBundlesFromTeam(teamId, skipOwnClients = false, onlyDirectConnections = false) {
|
|
38
|
+
const teamMembers = onlyDirectConnections
|
|
39
|
+
? (await this.apiClient.conversation.api.getConversations()).conversations
|
|
40
|
+
.map(({ members }) => members.others.map(user => user.id).concat(members.self.id))
|
|
41
|
+
.flat()
|
|
42
|
+
: (await this.apiClient.teams.member.api.getAllMembers(teamId)).members.map(({ user }) => user);
|
|
43
|
+
let members = Array.from(new Set(teamMembers)).map(member => ({ id: member }));
|
|
33
44
|
if (skipOwnClients) {
|
|
34
45
|
const selfUser = await this.apiClient.self.api.getSelf();
|
|
35
46
|
members = members.filter(member => member.id !== selfUser.id);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import type { APIClient } from '@wireapp/api-client';
|
|
3
2
|
import { MessageSendingStatus, Conversation, DefaultConversationRoleName, MutedStatus, QualifiedUserClients, UserClients, ClientMismatch } from '@wireapp/api-client/src/conversation';
|
|
4
3
|
import type { ConversationMemberLeaveEvent } from '@wireapp/api-client/src/event';
|
|
@@ -150,7 +149,7 @@ export declare class ConversationService {
|
|
|
150
149
|
createConversation(name: string, otherUserIds?: string | string[]): Promise<Conversation>;
|
|
151
150
|
getConversations(conversationId: string): Promise<Conversation>;
|
|
152
151
|
getConversations(conversationIds?: string[]): Promise<Conversation[]>;
|
|
153
|
-
getAsset({ assetId, assetToken, otrKey, sha256 }: RemoteData): Promise<
|
|
152
|
+
getAsset({ assetId, assetToken, otrKey, sha256 }: RemoteData): Promise<Uint8Array>;
|
|
154
153
|
getUnencryptedAsset(assetId: string, assetToken?: string): Promise<ArrayBuffer>;
|
|
155
154
|
addUser<T extends string | string[] | QualifiedId | QualifiedId[]>(conversationId: string, userIds: T): Promise<T>;
|
|
156
155
|
removeUser(conversationId: string, userId: string): Promise<string>;
|
|
@@ -633,9 +633,9 @@ class ConversationService {
|
|
|
633
633
|
const request = this.apiClient.asset.api.getAssetV3(assetId, assetToken);
|
|
634
634
|
const encryptedBuffer = (await request.response).buffer;
|
|
635
635
|
return (0, AssetCryptography_1.decryptAsset)({
|
|
636
|
-
cipherText:
|
|
637
|
-
keyBytes:
|
|
638
|
-
sha256:
|
|
636
|
+
cipherText: new Uint8Array(encryptedBuffer),
|
|
637
|
+
keyBytes: otrKey,
|
|
638
|
+
sha256: sha256,
|
|
639
639
|
});
|
|
640
640
|
}
|
|
641
641
|
async getUnencryptedAsset(assetId, assetToken) {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
export interface EncryptedAsset {
|
|
3
|
-
cipherText:
|
|
4
|
-
keyBytes:
|
|
2
|
+
cipherText: Uint8Array;
|
|
3
|
+
keyBytes: Uint8Array;
|
|
5
4
|
/** The SHA-256 sum of `cipherText` */
|
|
6
|
-
sha256:
|
|
5
|
+
sha256: Uint8Array;
|
|
7
6
|
}
|
|
8
7
|
export interface EncryptedAssetUploaded extends EncryptedAsset {
|
|
9
8
|
key: string;
|
|
@@ -23,22 +23,22 @@ const cryptoLib = window.crypto;
|
|
|
23
23
|
exports.crypto = {
|
|
24
24
|
async digest(cipherText) {
|
|
25
25
|
const checksum = await cryptoLib.subtle.digest('SHA-256', cipherText);
|
|
26
|
-
return
|
|
26
|
+
return new Uint8Array(checksum);
|
|
27
27
|
},
|
|
28
28
|
async decrypt(cipherText, keyBytes) {
|
|
29
29
|
const key = await cryptoLib.subtle.importKey('raw', keyBytes, 'AES-CBC', false, ['decrypt']);
|
|
30
30
|
const initializationVector = cipherText.slice(0, 16);
|
|
31
31
|
const assetCipherText = cipherText.slice(16);
|
|
32
32
|
const decipher = await cryptoLib.subtle.decrypt({ iv: initializationVector, name: 'AES-CBC' }, key, assetCipherText);
|
|
33
|
-
return
|
|
33
|
+
return new Uint8Array(decipher);
|
|
34
34
|
},
|
|
35
35
|
getRandomValues(size) {
|
|
36
|
-
return
|
|
36
|
+
return cryptoLib.getRandomValues(new Uint8Array(size));
|
|
37
37
|
},
|
|
38
38
|
async encrypt(plainText, keyBytes, initializationVector) {
|
|
39
39
|
const key = await cryptoLib.subtle.importKey('raw', keyBytes, 'AES-CBC', true, ['encrypt']);
|
|
40
40
|
return {
|
|
41
|
-
key:
|
|
41
|
+
key: new Uint8Array(await cryptoLib.subtle.exportKey('raw', key)),
|
|
42
42
|
cipher: await cryptoLib.subtle.encrypt({ iv: initializationVector, name: 'AES-CBC' }, key, plainText),
|
|
43
43
|
};
|
|
44
44
|
},
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { CipherOptions } from '@wireapp/api-client/src/asset';
|
|
3
2
|
import type { EncryptedAsset } from './EncryptedAsset';
|
|
4
3
|
interface EncryptOptions extends CipherOptions {
|
|
5
|
-
plainText:
|
|
4
|
+
plainText: Uint8Array;
|
|
6
5
|
}
|
|
7
|
-
export declare const decryptAsset: ({ cipherText, keyBytes, sha256: referenceSha256, }: EncryptedAsset) => Promise<
|
|
6
|
+
export declare const decryptAsset: ({ cipherText, keyBytes, sha256: referenceSha256, }: EncryptedAsset) => Promise<Uint8Array>;
|
|
8
7
|
export declare const encryptAsset: ({ plainText, algorithm }: EncryptOptions) => Promise<EncryptedAsset>;
|
|
9
8
|
export {};
|
|
@@ -44,7 +44,7 @@ const encryptAsset = async ({ plainText, algorithm = 'AES-256-CBC' }) => {
|
|
|
44
44
|
ivCipherText.set(new Uint8Array(cipher), initializationVector.byteLength);
|
|
45
45
|
const sha256 = await crypto_node_1.crypto.digest(ivCipherText);
|
|
46
46
|
return {
|
|
47
|
-
cipherText:
|
|
47
|
+
cipherText: ivCipherText,
|
|
48
48
|
keyBytes: key,
|
|
49
49
|
sha256,
|
|
50
50
|
};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
export interface Crypto {
|
|
3
|
-
digest(cipherText:
|
|
4
|
-
decrypt(cipherText:
|
|
5
|
-
getRandomValues(size: number):
|
|
6
|
-
encrypt(plainText:
|
|
7
|
-
key:
|
|
8
|
-
cipher:
|
|
2
|
+
digest(cipherText: Uint8Array): Promise<Uint8Array>;
|
|
3
|
+
decrypt(cipherText: Uint8Array, keyBytes: Uint8Array): Promise<Uint8Array>;
|
|
4
|
+
getRandomValues(size: number): Uint8Array;
|
|
5
|
+
encrypt(plainText: Uint8Array, keyBytes: Uint8Array, initializationVector: Uint8Array, algorithm: string): Promise<{
|
|
6
|
+
key: Uint8Array;
|
|
7
|
+
cipher: Uint8Array;
|
|
9
8
|
}>;
|
|
10
9
|
}
|
|
@@ -11,5 +11,15 @@ export declare class UserService {
|
|
|
11
11
|
constructor(apiClient: APIClient, broadcastService: BroadcastService, conversationService: ConversationService, connectionService: ConnectionService);
|
|
12
12
|
getUser(userId: string | QualifiedId): Promise<User>;
|
|
13
13
|
getUsers(userIds: string[] | QualifiedId[]): Promise<User[]>;
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Sends a availability update to members of the same team
|
|
16
|
+
* @param teamId
|
|
17
|
+
* @param type
|
|
18
|
+
* @param options.sendAll=false will broadcast the message to all the members of the team (instead of just direct connections). Should be avoided in a big team
|
|
19
|
+
* @param options.sendAsProtobuf=false
|
|
20
|
+
*/
|
|
21
|
+
setAvailability(teamId: string, type: AvailabilityType, { sendAll, sendAsProtobuf }?: {
|
|
22
|
+
sendAll?: boolean | undefined;
|
|
23
|
+
sendAsProtobuf?: boolean | undefined;
|
|
24
|
+
}): Promise<void>;
|
|
15
25
|
}
|
|
@@ -44,9 +44,16 @@ class UserService {
|
|
|
44
44
|
? this.apiClient.user.api.postListUsers({ qualified_ids: userIds })
|
|
45
45
|
: this.apiClient.user.api.getUsers({ ids: userIds });
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Sends a availability update to members of the same team
|
|
49
|
+
* @param teamId
|
|
50
|
+
* @param type
|
|
51
|
+
* @param options.sendAll=false will broadcast the message to all the members of the team (instead of just direct connections). Should be avoided in a big team
|
|
52
|
+
* @param options.sendAsProtobuf=false
|
|
53
|
+
*/
|
|
54
|
+
async setAvailability(teamId, type, { sendAll = false, sendAsProtobuf = false } = {}) {
|
|
48
55
|
// Get pre-key bundles for members of your own team
|
|
49
|
-
const preKeyBundlesFromTeam = await this.broadcastService.getPreKeyBundlesFromTeam(teamId);
|
|
56
|
+
const preKeyBundlesFromTeam = await this.broadcastService.getPreKeyBundlesFromTeam(teamId, false, !sendAll);
|
|
50
57
|
// Get pre-key bundles for all of your other 1:1 connections
|
|
51
58
|
const connections = await this.connectionService.getConnections();
|
|
52
59
|
const acceptedConnections = connections.filter(connection => connection.status === connection_1.ConnectionStatus.ACCEPTED);
|