@wireapp/core 30.0.1 → 30.0.4
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 +24 -0
- package/package.json +3 -3
- package/src/main/Account.js +1 -1
- package/src/main/connection/ConnectionService.d.ts +3 -2
- package/src/main/connection/ConnectionService.js +4 -1
- package/src/main/notification/NotificationService.js +6 -3
- package/src/main/user/UserService.d.ts +18 -1
- package/src/main/user/UserService.js +42 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,30 @@
|
|
|
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
|
+
## [30.0.4](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@30.0.3...@wireapp/core@30.0.4) (2022-09-02)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @wireapp/core
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [30.0.3](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@30.0.2...@wireapp/core@30.0.3) (2022-08-30)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @wireapp/core
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## [30.0.2](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@30.0.1...@wireapp/core@30.0.2) (2022-08-30)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @wireapp/core
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
6
30
|
## [30.0.1](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@30.0.0...@wireapp/core@30.0.1) (2022-08-29)
|
|
7
31
|
|
|
8
32
|
**Note:** Version bump only for package @wireapp/core
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"@otak/core-crypto": "0.3.0-es2017",
|
|
8
8
|
"@types/long": "4.0.1",
|
|
9
9
|
"@types/node": "~14",
|
|
10
|
-
"@wireapp/api-client": "20.0.
|
|
10
|
+
"@wireapp/api-client": "20.0.3",
|
|
11
11
|
"@wireapp/commons": "4.3.0",
|
|
12
12
|
"@wireapp/cryptobox": "12.8.0",
|
|
13
13
|
"@wireapp/store-engine-dexie": "1.6.10",
|
|
@@ -77,6 +77,6 @@
|
|
|
77
77
|
"test:node": "nyc jasmine --config=jasmine.json",
|
|
78
78
|
"watch": "tsc ---watch"
|
|
79
79
|
},
|
|
80
|
-
"version": "30.0.
|
|
81
|
-
"gitHead": "
|
|
80
|
+
"version": "30.0.4",
|
|
81
|
+
"gitHead": "d665c69bb63545f58d6d061ca3fda4abcc6b050a"
|
|
82
82
|
}
|
package/src/main/Account.js
CHANGED
|
@@ -241,7 +241,7 @@ class Account extends events_1.EventEmitter {
|
|
|
241
241
|
const selfService = new self_1.SelfService(this.apiClient);
|
|
242
242
|
const teamService = new team_1.TeamService(this.apiClient);
|
|
243
243
|
const broadcastService = new broadcast_1.BroadcastService(this.apiClient, cryptographyService);
|
|
244
|
-
const userService = new user_1.UserService(this.apiClient);
|
|
244
|
+
const userService = new user_1.UserService(this.apiClient, broadcastService, conversationService, connectionService);
|
|
245
245
|
this.service = {
|
|
246
246
|
account: accountService,
|
|
247
247
|
asset: assetService,
|
|
@@ -4,7 +4,8 @@ import { QualifiedId } from '@wireapp/api-client/src/user';
|
|
|
4
4
|
export declare class ConnectionService {
|
|
5
5
|
private readonly apiClient;
|
|
6
6
|
constructor(apiClient: APIClient);
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
getConnections(): Promise<Connection[]>;
|
|
8
|
+
acceptConnection(userId: string): Promise<Connection>;
|
|
9
|
+
ignoreConnection(userId: string): Promise<Connection>;
|
|
9
10
|
createConnection(userId: QualifiedId): Promise<Connection>;
|
|
10
11
|
}
|
|
@@ -24,6 +24,9 @@ class ConnectionService {
|
|
|
24
24
|
constructor(apiClient) {
|
|
25
25
|
this.apiClient = apiClient;
|
|
26
26
|
}
|
|
27
|
+
getConnections() {
|
|
28
|
+
return this.apiClient.api.connection.getAllConnections();
|
|
29
|
+
}
|
|
27
30
|
acceptConnection(userId) {
|
|
28
31
|
return this.apiClient.api.connection.putConnection(userId, {
|
|
29
32
|
status: connection_1.ConnectionStatus.ACCEPTED,
|
|
@@ -35,7 +38,7 @@ class ConnectionService {
|
|
|
35
38
|
});
|
|
36
39
|
}
|
|
37
40
|
createConnection(userId) {
|
|
38
|
-
return this.apiClient.api.connection.postConnection(userId);
|
|
41
|
+
return this.apiClient.api.connection.postConnection(userId, '');
|
|
39
42
|
}
|
|
40
43
|
}
|
|
41
44
|
exports.ConnectionService = ConnectionService;
|
|
@@ -212,11 +212,11 @@ class NotificationService extends events_1.EventEmitter {
|
|
|
212
212
|
async handleEvent(event, source, dryRun = false) {
|
|
213
213
|
var _a, _b;
|
|
214
214
|
const coreCryptoClient = this.coreCryptoClientProvider();
|
|
215
|
-
if (!coreCryptoClient) {
|
|
216
|
-
throw new Error('Unable to access core crypto client');
|
|
217
|
-
}
|
|
218
215
|
switch (event.type) {
|
|
219
216
|
case Events.CONVERSATION_EVENT.MLS_WELCOME_MESSAGE:
|
|
217
|
+
if (!coreCryptoClient) {
|
|
218
|
+
throw new Error('Unable to access core crypto client');
|
|
219
|
+
}
|
|
220
220
|
const data = bazinga64_1.Decoder.fromBase64(event.data).asBytes;
|
|
221
221
|
// We extract the groupId from the welcome message and let coreCrypto store this group
|
|
222
222
|
const newGroupId = await coreCryptoClient.processWelcomeMessage(data);
|
|
@@ -227,6 +227,9 @@ class NotificationService extends events_1.EventEmitter {
|
|
|
227
227
|
mappedEvent: ConversationMapper_1.ConversationMapper.mapConversationEvent(Object.assign(Object.assign({}, event), { data: groupIdStr }), source),
|
|
228
228
|
};
|
|
229
229
|
case Events.CONVERSATION_EVENT.MLS_MESSAGE_ADD:
|
|
230
|
+
if (!coreCryptoClient) {
|
|
231
|
+
throw new Error('Unable to access core crypto client');
|
|
232
|
+
}
|
|
230
233
|
const encryptedData = bazinga64_1.Decoder.fromBase64(event.data).asBytes;
|
|
231
234
|
const groupId = await this.getUint8ArrayFromConversationGroupId((_a = event.qualified_conversation) !== null && _a !== void 0 ? _a : { id: event.conversation, domain: '' });
|
|
232
235
|
// Check if the message includes proposals
|
|
@@ -1,8 +1,25 @@
|
|
|
1
1
|
import type { APIClient } from '@wireapp/api-client';
|
|
2
2
|
import type { QualifiedId, User } from '@wireapp/api-client/src/user/';
|
|
3
|
+
import type { AvailabilityType, BroadcastService } from '../broadcast/';
|
|
4
|
+
import { ConnectionService } from '../connection';
|
|
5
|
+
import { ConversationService } from '../conversation';
|
|
3
6
|
export declare class UserService {
|
|
4
7
|
private readonly apiClient;
|
|
5
|
-
|
|
8
|
+
private readonly broadcastService;
|
|
9
|
+
private readonly connectionService;
|
|
10
|
+
private readonly conversationService;
|
|
11
|
+
constructor(apiClient: APIClient, broadcastService: BroadcastService, conversationService: ConversationService, connectionService: ConnectionService);
|
|
6
12
|
getUser(userId: string | QualifiedId): Promise<User>;
|
|
7
13
|
getUsers(userIds: string[] | QualifiedId[]): Promise<User[]>;
|
|
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>;
|
|
8
25
|
}
|
|
@@ -17,12 +17,21 @@
|
|
|
17
17
|
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
18
18
|
*
|
|
19
19
|
*/
|
|
20
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
21
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
22
|
+
};
|
|
20
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
24
|
exports.UserService = void 0;
|
|
25
|
+
const protocol_messaging_1 = require("@wireapp/protocol-messaging");
|
|
26
|
+
const uuidjs_1 = __importDefault(require("uuidjs"));
|
|
22
27
|
const TypePredicateUtil_1 = require("../util/TypePredicateUtil");
|
|
28
|
+
const connection_1 = require("@wireapp/api-client/src/connection");
|
|
23
29
|
class UserService {
|
|
24
|
-
constructor(apiClient) {
|
|
30
|
+
constructor(apiClient, broadcastService, conversationService, connectionService) {
|
|
25
31
|
this.apiClient = apiClient;
|
|
32
|
+
this.broadcastService = broadcastService;
|
|
33
|
+
this.connectionService = connectionService;
|
|
34
|
+
this.conversationService = conversationService;
|
|
26
35
|
}
|
|
27
36
|
getUser(userId) {
|
|
28
37
|
return this.apiClient.api.user.getUser(userId);
|
|
@@ -35,6 +44,38 @@ class UserService {
|
|
|
35
44
|
? this.apiClient.api.user.postListUsers({ qualified_ids: userIds })
|
|
36
45
|
: this.apiClient.api.user.getUsers({ ids: userIds });
|
|
37
46
|
}
|
|
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 } = {}) {
|
|
55
|
+
// Get pre-key bundles for members of your own team
|
|
56
|
+
const preKeyBundlesFromTeam = await this.broadcastService.getPreKeyBundlesFromTeam(teamId, false, !sendAll);
|
|
57
|
+
// Get pre-key bundles for all of your other 1:1 connections
|
|
58
|
+
const connections = await this.connectionService.getConnections();
|
|
59
|
+
const acceptedConnections = connections.filter(connection => connection.status === connection_1.ConnectionStatus.ACCEPTED);
|
|
60
|
+
const preKeyBundlePromises = acceptedConnections.map(connection => {
|
|
61
|
+
const mappedConnection = {
|
|
62
|
+
userId: connection.to,
|
|
63
|
+
conversationId: connection.conversation,
|
|
64
|
+
};
|
|
65
|
+
return this.conversationService.getPreKeyBundleMap(mappedConnection.conversationId, [mappedConnection.userId]);
|
|
66
|
+
});
|
|
67
|
+
const preKeyBundlesFromConnections = await Promise.all(preKeyBundlePromises);
|
|
68
|
+
// Merge pre-key bundles
|
|
69
|
+
const allPreKeyBundles = preKeyBundlesFromConnections.reduce((accumulator, preKeyBundleMap) => {
|
|
70
|
+
return Object.assign(Object.assign({}, accumulator), preKeyBundleMap);
|
|
71
|
+
}, preKeyBundlesFromTeam);
|
|
72
|
+
const genericMessage = protocol_messaging_1.GenericMessage.create({
|
|
73
|
+
availability: new protocol_messaging_1.Availability({ type }),
|
|
74
|
+
messageId: uuidjs_1.default.genV4().toString(),
|
|
75
|
+
});
|
|
76
|
+
// Broadcast availability status to your team members & external 1:1 connections
|
|
77
|
+
await this.broadcastService.broadcastGenericMessage(genericMessage, allPreKeyBundles, sendAsProtobuf);
|
|
78
|
+
}
|
|
38
79
|
}
|
|
39
80
|
exports.UserService = UserService;
|
|
40
81
|
//# sourceMappingURL=UserService.js.map
|