@wireapp/core 17.31.1 → 17.31.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 +11 -0
- package/package.json +7 -7
- package/src/main/Account.js.map +0 -1
- package/src/main/Account.test.browser.js +0 -114
- package/src/main/Account.test.node.d.ts +0 -1
- package/src/main/Account.test.node.js +0 -214
- package/src/main/Account.test.node.js.map +0 -1
- package/src/main/Account.test.node.ts +0 -236
- package/src/main/Account.ts +0 -401
- package/src/main/CoreError.js.map +0 -1
- package/src/main/CoreError.ts +0 -30
- package/src/main/auth/LoginSanitizer.js.map +0 -1
- package/src/main/auth/LoginSanitizer.test.node.d.ts +0 -1
- package/src/main/auth/LoginSanitizer.test.node.js +0 -56
- package/src/main/auth/LoginSanitizer.test.node.js.map +0 -1
- package/src/main/auth/LoginSanitizer.test.node.ts +0 -68
- package/src/main/auth/LoginSanitizer.ts +0 -44
- package/src/main/auth/index.js.map +0 -1
- package/src/main/auth/index.ts +0 -20
- package/src/main/broadcast/AvailabilityType.js.map +0 -1
- package/src/main/broadcast/AvailabilityType.ts +0 -22
- package/src/main/broadcast/BroadcastService.js.map +0 -1
- package/src/main/broadcast/BroadcastService.ts +0 -66
- package/src/main/broadcast/index.js.map +0 -1
- package/src/main/broadcast/index.ts +0 -21
- package/src/main/client/ClientBackendRepository.js.map +0 -1
- package/src/main/client/ClientBackendRepository.ts +0 -33
- package/src/main/client/ClientDatabaseRepository.js.map +0 -1
- package/src/main/client/ClientDatabaseRepository.ts +0 -130
- package/src/main/client/ClientInfo.js.map +0 -1
- package/src/main/client/ClientInfo.ts +0 -28
- package/src/main/client/ClientService.js.map +0 -1
- package/src/main/client/ClientService.ts +0 -116
- package/src/main/client/index.js.map +0 -1
- package/src/main/client/index.ts +0 -23
- package/src/main/connection/ConnectionService.js.map +0 -1
- package/src/main/connection/ConnectionService.ts +0 -49
- package/src/main/connection/index.js.map +0 -1
- package/src/main/connection/index.ts +0 -20
- package/src/main/conversation/AbortReason.js.map +0 -1
- package/src/main/conversation/AbortReason.ts +0 -22
- package/src/main/conversation/AssetService.js.map +0 -1
- package/src/main/conversation/AssetService.test.node.d.ts +0 -1
- package/src/main/conversation/AssetService.test.node.js +0 -61
- package/src/main/conversation/AssetService.test.node.js.map +0 -1
- package/src/main/conversation/AssetService.test.node.ts +0 -65
- package/src/main/conversation/AssetService.ts +0 -60
- package/src/main/conversation/AssetTransferState.js.map +0 -1
- package/src/main/conversation/AssetTransferState.ts +0 -23
- package/src/main/conversation/ClientActionType.js.map +0 -1
- package/src/main/conversation/ClientActionType.ts +0 -20
- package/src/main/conversation/ConversationMapper.js.map +0 -1
- package/src/main/conversation/ConversationMapper.test.node.d.ts +0 -1
- package/src/main/conversation/ConversationMapper.test.node.js +0 -111
- package/src/main/conversation/ConversationMapper.test.node.js.map +0 -1
- package/src/main/conversation/ConversationMapper.test.node.ts +0 -154
- package/src/main/conversation/ConversationMapper.ts +0 -56
- package/src/main/conversation/ConversationService.js.map +0 -1
- package/src/main/conversation/ConversationService.test.node.d.ts +0 -1
- package/src/main/conversation/ConversationService.test.node.js +0 -344
- package/src/main/conversation/ConversationService.test.node.js.map +0 -1
- package/src/main/conversation/ConversationService.test.node.ts +0 -416
- package/src/main/conversation/ConversationService.ts +0 -1024
- package/src/main/conversation/GenericMessageType.js.map +0 -1
- package/src/main/conversation/GenericMessageType.ts +0 -44
- package/src/main/conversation/MessageTimer.js.map +0 -1
- package/src/main/conversation/MessageTimer.test.node.d.ts +0 -1
- package/src/main/conversation/MessageTimer.test.node.js +0 -88
- package/src/main/conversation/MessageTimer.test.node.js.map +0 -1
- package/src/main/conversation/MessageTimer.test.node.ts +0 -103
- package/src/main/conversation/MessageTimer.ts +0 -56
- package/src/main/conversation/ReactionType.js.map +0 -1
- package/src/main/conversation/ReactionType.ts +0 -23
- package/src/main/conversation/content/AssetContent.js.map +0 -1
- package/src/main/conversation/content/AssetContent.ts +0 -71
- package/src/main/conversation/content/ButtonActionConfirmationContent.js.map +0 -1
- package/src/main/conversation/content/ButtonActionConfirmationContent.ts +0 -21
- package/src/main/conversation/content/ButtonActionContent.js.map +0 -1
- package/src/main/conversation/content/ButtonActionContent.ts +0 -21
- package/src/main/conversation/content/CallingContent.js.map +0 -1
- package/src/main/conversation/content/CallingContent.ts +0 -20
- package/src/main/conversation/content/ClearedContent.js.map +0 -1
- package/src/main/conversation/content/ClearedContent.ts +0 -21
- package/src/main/conversation/content/ClientActionContent.js.map +0 -1
- package/src/main/conversation/content/ClientActionContent.ts +0 -22
- package/src/main/conversation/content/ClientAddContent.js.map +0 -1
- package/src/main/conversation/content/ClientAddContent.ts +0 -24
- package/src/main/conversation/content/ClientRemoveContent.js.map +0 -1
- package/src/main/conversation/content/ClientRemoveContent.ts +0 -25
- package/src/main/conversation/content/CompositeContent.js.map +0 -1
- package/src/main/conversation/content/CompositeContent.ts +0 -21
- package/src/main/conversation/content/ConfirmationContent.js.map +0 -1
- package/src/main/conversation/content/ConfirmationContent.ts +0 -21
- package/src/main/conversation/content/ContentType.js.map +0 -1
- package/src/main/conversation/content/ContentType.ts +0 -112
- package/src/main/conversation/content/ConversationContent.js.map +0 -1
- package/src/main/conversation/content/ConversationContent.ts +0 -71
- package/src/main/conversation/content/DeletedContent.js.map +0 -1
- package/src/main/conversation/content/DeletedContent.ts +0 -21
- package/src/main/conversation/content/EditedTextContent.js.map +0 -1
- package/src/main/conversation/content/EditedTextContent.ts +0 -31
- package/src/main/conversation/content/FileContent.js.map +0 -1
- package/src/main/conversation/content/FileContent.ts +0 -32
- package/src/main/conversation/content/HiddenContent.js.map +0 -1
- package/src/main/conversation/content/HiddenContent.ts +0 -21
- package/src/main/conversation/content/ImageContent.js.map +0 -1
- package/src/main/conversation/content/ImageContent.ts +0 -25
- package/src/main/conversation/content/KnockContent.js.map +0 -1
- package/src/main/conversation/content/KnockContent.ts +0 -21
- package/src/main/conversation/content/LinkPreviewContent.js.map +0 -1
- package/src/main/conversation/content/LinkPreviewContent.ts +0 -32
- package/src/main/conversation/content/LocationContent.js.map +0 -1
- package/src/main/conversation/content/LocationContent.ts +0 -29
- package/src/main/conversation/content/MentionContent.js.map +0 -1
- package/src/main/conversation/content/MentionContent.ts +0 -21
- package/src/main/conversation/content/QuoteContent.js.map +0 -1
- package/src/main/conversation/content/QuoteContent.ts +0 -29
- package/src/main/conversation/content/ReactionContent.js.map +0 -1
- package/src/main/conversation/content/ReactionContent.ts +0 -27
- package/src/main/conversation/content/TextContent.js.map +0 -1
- package/src/main/conversation/content/TextContent.ts +0 -29
- package/src/main/conversation/content/TweetContent.js.map +0 -1
- package/src/main/conversation/content/TweetContent.ts +0 -21
- package/src/main/conversation/content/index.js.map +0 -1
- package/src/main/conversation/content/index.ts +0 -49
- package/src/main/conversation/index.js.map +0 -1
- package/src/main/conversation/index.ts +0 -28
- package/src/main/conversation/message/CompositeContentBuilder.js.map +0 -1
- package/src/main/conversation/message/CompositeContentBuilder.ts +0 -60
- package/src/main/conversation/message/Message.js.map +0 -1
- package/src/main/conversation/message/Message.ts +0 -24
- package/src/main/conversation/message/MessageBuilder.js.map +0 -1
- package/src/main/conversation/message/MessageBuilder.test.browser.js +0 -27
- package/src/main/conversation/message/MessageBuilder.ts +0 -488
- package/src/main/conversation/message/MessageService.js.map +0 -1
- package/src/main/conversation/message/MessageService.test.node.d.ts +0 -1
- package/src/main/conversation/message/MessageService.test.node.js +0 -308
- package/src/main/conversation/message/MessageService.test.node.js.map +0 -1
- package/src/main/conversation/message/MessageService.test.node.ts +0 -398
- package/src/main/conversation/message/MessageService.ts +0 -383
- package/src/main/conversation/message/MessageToProtoMapper.js.map +0 -1
- package/src/main/conversation/message/MessageToProtoMapper.ts +0 -114
- package/src/main/conversation/message/OtrMessage.js.map +0 -1
- package/src/main/conversation/message/OtrMessage.ts +0 -160
- package/src/main/conversation/message/PayloadBundle.js.map +0 -1
- package/src/main/conversation/message/PayloadBundle.ts +0 -101
- package/src/main/conversation/message/TeamMessage.js.map +0 -1
- package/src/main/conversation/message/TeamMessage.ts +0 -72
- package/src/main/conversation/message/TextContentBuilder.js.map +0 -1
- package/src/main/conversation/message/TextContentBuilder.ts +0 -88
- package/src/main/conversation/message/UserClientsUtil.js.map +0 -1
- package/src/main/conversation/message/UserClientsUtil.ts +0 -44
- package/src/main/conversation/message/UserClientsUtils.test.node.d.ts +0 -1
- package/src/main/conversation/message/UserClientsUtils.test.node.js +0 -42
- package/src/main/conversation/message/UserClientsUtils.test.node.js.map +0 -1
- package/src/main/conversation/message/UserClientsUtils.test.node.ts +0 -44
- package/src/main/conversation/message/UserMessage.js.map +0 -1
- package/src/main/conversation/message/UserMessage.ts +0 -95
- package/src/main/cryptography/AssetCryptography.browser.js.map +0 -1
- package/src/main/cryptography/AssetCryptography.browser.ts +0 -76
- package/src/main/cryptography/AssetCryptography.node.js.map +0 -1
- package/src/main/cryptography/AssetCryptography.node.ts +0 -85
- package/src/main/cryptography/CryptographyDatabaseRepository.js.map +0 -1
- package/src/main/cryptography/CryptographyDatabaseRepository.ts +0 -44
- package/src/main/cryptography/CryptographyService.js.map +0 -1
- package/src/main/cryptography/CryptographyService.test.browser.js +0 -195
- package/src/main/cryptography/CryptographyService.test.node.d.ts +0 -1
- package/src/main/cryptography/CryptographyService.test.node.js +0 -228
- package/src/main/cryptography/CryptographyService.test.node.js.map +0 -1
- package/src/main/cryptography/CryptographyService.test.node.ts +0 -246
- package/src/main/cryptography/CryptographyService.ts +0 -246
- package/src/main/cryptography/EncryptedAsset.js.map +0 -1
- package/src/main/cryptography/EncryptedAsset.ts +0 -30
- package/src/main/cryptography/GenericMessageMapper.js.map +0 -1
- package/src/main/cryptography/GenericMessageMapper.ts +0 -274
- package/src/main/cryptography/MessageHashService.js.map +0 -1
- package/src/main/cryptography/MessageHashService.test.browser.js +0 -176
- package/src/main/cryptography/MessageHashService.test.node.d.ts +0 -1
- package/src/main/cryptography/MessageHashService.test.node.js +0 -138
- package/src/main/cryptography/MessageHashService.test.node.js.map +0 -1
- package/src/main/cryptography/MessageHashService.test.node.ts +0 -176
- package/src/main/cryptography/MessageHashService.ts +0 -109
- package/src/main/cryptography/SessionPayloadBundle.js.map +0 -1
- package/src/main/cryptography/SessionPayloadBundle.ts +0 -23
- package/src/main/cryptography/index.js.map +0 -1
- package/src/main/cryptography/index.ts +0 -23
- package/src/main/giphy/GiphyService.js.map +0 -1
- package/src/main/giphy/GiphyService.ts +0 -37
- package/src/main/giphy/index.js.map +0 -1
- package/src/main/giphy/index.ts +0 -20
- package/src/main/index.js.map +0 -1
- package/src/main/index.test.browser.js +0 -22
- package/src/main/index.ts +0 -34
- package/src/main/notification/NotificationBackendRepository.js.map +0 -1
- package/src/main/notification/NotificationBackendRepository.ts +0 -33
- package/src/main/notification/NotificationDatabaseRepository.js.map +0 -1
- package/src/main/notification/NotificationDatabaseRepository.ts +0 -74
- package/src/main/notification/NotificationService.js.map +0 -1
- package/src/main/notification/NotificationService.test.browser.js +0 -179
- package/src/main/notification/NotificationService.test.node.d.ts +0 -1
- package/src/main/notification/NotificationService.test.node.js +0 -99
- package/src/main/notification/NotificationService.test.node.js.map +0 -1
- package/src/main/notification/NotificationService.test.node.ts +0 -124
- package/src/main/notification/NotificationService.ts +0 -260
- package/src/main/notification/index.js.map +0 -1
- package/src/main/notification/index.ts +0 -20
- package/src/main/self/SelfService.js.map +0 -1
- package/src/main/self/SelfService.ts +0 -59
- package/src/main/self/index.js.map +0 -1
- package/src/main/self/index.ts +0 -20
- package/src/main/team/TeamService.js.map +0 -1
- package/src/main/team/TeamService.ts +0 -68
- package/src/main/team/index.js.map +0 -1
- package/src/main/team/index.ts +0 -20
- package/src/main/test/CryptographyHelper.js.map +0 -1
- package/src/main/test/CryptographyHelper.ts +0 -57
- package/src/main/test/PayloadHelper.js.map +0 -1
- package/src/main/test/PayloadHelper.ts +0 -60
- package/src/main/user/UserMapper.js.map +0 -1
- package/src/main/user/UserMapper.test.node.d.ts +0 -1
- package/src/main/user/UserMapper.test.node.js +0 -55
- package/src/main/user/UserMapper.test.node.js.map +0 -1
- package/src/main/user/UserMapper.test.node.ts +0 -63
- package/src/main/user/UserMapper.ts +0 -92
- package/src/main/user/UserService.js.map +0 -1
- package/src/main/user/UserService.test.node.js +0 -141
- package/src/main/user/UserService.ts +0 -98
- package/src/main/user/index.js.map +0 -1
- package/src/main/user/index.ts +0 -20
- package/src/main/util/TypePredicateUtil.js.map +0 -1
- package/src/main/util/TypePredicateUtil.test.node.d.ts +0 -1
- package/src/main/util/TypePredicateUtil.test.node.js +0 -42
- package/src/main/util/TypePredicateUtil.test.node.js.map +0 -1
- package/src/main/util/TypePredicateUtil.test.node.ts +0 -44
- package/src/main/util/TypePredicateUtil.ts +0 -52
- package/src/main/util/index.js.map +0 -1
- package/src/main/util/index.ts +0 -20
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Wire
|
|
3
|
-
* Copyright (C) 2018 Wire Swiss GmbH
|
|
4
|
-
*
|
|
5
|
-
* This program is free software: you can redistribute it and/or modify
|
|
6
|
-
* it under the terms of the GNU General Public License as published by
|
|
7
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
* (at your option) any later version.
|
|
9
|
-
*
|
|
10
|
-
* This program is distributed in the hope that it will be useful,
|
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
* GNU General Public License for more details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU General Public License
|
|
16
|
-
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
const nock = require('nock');
|
|
21
|
-
|
|
22
|
-
const {Account} = require('@wireapp/core');
|
|
23
|
-
const {UserAPI} = require('@wireapp/api-client/src/user/');
|
|
24
|
-
const {MemberAPI} = require('@wireapp/api-client/src/team/member/');
|
|
25
|
-
const {TeamAPI} = require('@wireapp/api-client/src/team/team/');
|
|
26
|
-
const {BroadcastAPI} = require('@wireapp/api-client/src/broadcast/');
|
|
27
|
-
const {StatusCode} = require('@wireapp/api-client/src/http/');
|
|
28
|
-
const {Backend} = require('@wireapp/api-client/src/env/');
|
|
29
|
-
const {Permissions} = require('@wireapp/api-client/src/team/member/');
|
|
30
|
-
|
|
31
|
-
const PayloadHelper = require('../test/PayloadHelper');
|
|
32
|
-
|
|
33
|
-
describe('UserService', () => {
|
|
34
|
-
let hasState;
|
|
35
|
-
|
|
36
|
-
afterAll(() => nock.cleanAll());
|
|
37
|
-
|
|
38
|
-
beforeAll(() => {
|
|
39
|
-
nock(Backend.PRODUCTION.rest)
|
|
40
|
-
.get(UserAPI.URL.USERS)
|
|
41
|
-
.query(() => true)
|
|
42
|
-
.reply(uri => {
|
|
43
|
-
const ids = PayloadHelper.getUrlParameter(uri, 'ids');
|
|
44
|
-
|
|
45
|
-
const userPayloads = ids.split(',').map(requestedUserId => {
|
|
46
|
-
return PayloadHelper.mockUserPayload(requestedUserId);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
return [StatusCode.OK, JSON.stringify(userPayloads)];
|
|
50
|
-
})
|
|
51
|
-
.persist();
|
|
52
|
-
|
|
53
|
-
nock(Backend.PRODUCTION.rest)
|
|
54
|
-
.post(BroadcastAPI.URL.BROADCAST, requestBody => {
|
|
55
|
-
hasState[requestBody.sender] = true;
|
|
56
|
-
return true;
|
|
57
|
-
})
|
|
58
|
-
.query(() => true)
|
|
59
|
-
.reply((uri, requestBody) => {
|
|
60
|
-
const userClients = {};
|
|
61
|
-
const requestedRecipients = requestBody.recipients;
|
|
62
|
-
|
|
63
|
-
for (const recipient in requestedRecipients) {
|
|
64
|
-
userClients[recipient] = [];
|
|
65
|
-
for (const device in requestedRecipients[recipient]) {
|
|
66
|
-
userClients[recipient].push(device);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return [StatusCode.OK, JSON.stringify(userClients)];
|
|
71
|
-
})
|
|
72
|
-
.persist();
|
|
73
|
-
|
|
74
|
-
nock(Backend.PRODUCTION.rest)
|
|
75
|
-
.get(new RegExp(`${TeamAPI.URL.TEAMS}/.*/${MemberAPI.URL.MEMBERS}`))
|
|
76
|
-
.query(() => true)
|
|
77
|
-
.reply(() => {
|
|
78
|
-
const data = {
|
|
79
|
-
members: [
|
|
80
|
-
{
|
|
81
|
-
permissions: {
|
|
82
|
-
copy: Permissions.DELETE_TEAM | Permissions.GET_BILLING | Permissions.SET_BILLING,
|
|
83
|
-
self: Permissions.DELETE_TEAM | Permissions.GET_BILLING | Permissions.SET_BILLING,
|
|
84
|
-
},
|
|
85
|
-
user: PayloadHelper.getUUID(),
|
|
86
|
-
},
|
|
87
|
-
],
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
return [StatusCode.OK, JSON.stringify(data)];
|
|
91
|
-
})
|
|
92
|
-
.persist();
|
|
93
|
-
|
|
94
|
-
nock(Backend.PRODUCTION.rest)
|
|
95
|
-
.get(new RegExp(`${UserAPI.URL.USERS}/.*/${UserAPI.URL.PRE_KEYS}`))
|
|
96
|
-
.query(() => true)
|
|
97
|
-
.reply(uri => {
|
|
98
|
-
const requestedUserId = uri.replace(`${UserAPI.URL.USERS}/`, '').replace(`/${UserAPI.URL.PRE_KEYS}`, '');
|
|
99
|
-
|
|
100
|
-
const data = {
|
|
101
|
-
clients: [
|
|
102
|
-
{
|
|
103
|
-
client: PayloadHelper.getUUID(),
|
|
104
|
-
prekey: {},
|
|
105
|
-
},
|
|
106
|
-
],
|
|
107
|
-
user: requestedUserId,
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
return [StatusCode.OK, JSON.stringify(data)];
|
|
111
|
-
})
|
|
112
|
-
.persist();
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
beforeEach(() => (hasState = {}));
|
|
116
|
-
|
|
117
|
-
describe('getUsers', () => {
|
|
118
|
-
it('fetches users', async () => {
|
|
119
|
-
const userIds = [PayloadHelper.getUUID(), PayloadHelper.getUUID()];
|
|
120
|
-
const account = new Account();
|
|
121
|
-
await account.init();
|
|
122
|
-
const users = await account.service.user.getUsers(userIds);
|
|
123
|
-
expect(users.length).toBe(userIds.length);
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
describe('setAvailability', () => {
|
|
128
|
-
it('sets the availability', async () => {
|
|
129
|
-
const teamId = PayloadHelper.getUUID();
|
|
130
|
-
const account = new Account();
|
|
131
|
-
await account.init();
|
|
132
|
-
const clientId = PayloadHelper.getUUID();
|
|
133
|
-
|
|
134
|
-
account.service.conversation.setClientID(clientId);
|
|
135
|
-
expect(hasState[clientId]).toBeUndefined();
|
|
136
|
-
|
|
137
|
-
await account.service.user.setAvailability(teamId, 1);
|
|
138
|
-
expect(hasState[clientId]).toBe(true);
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
});
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Wire
|
|
3
|
-
* Copyright (C) 2018 Wire Swiss GmbH
|
|
4
|
-
*
|
|
5
|
-
* This program is free software: you can redistribute it and/or modify
|
|
6
|
-
* it under the terms of the GNU General Public License as published by
|
|
7
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
* (at your option) any later version.
|
|
9
|
-
*
|
|
10
|
-
* This program is distributed in the hope that it will be useful,
|
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
* GNU General Public License for more details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU General Public License
|
|
16
|
-
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import type {APIClient} from '@wireapp/api-client';
|
|
21
|
-
import type {QualifiedId, User} from '@wireapp/api-client/src/user/';
|
|
22
|
-
import {Availability, GenericMessage} from '@wireapp/protocol-messaging';
|
|
23
|
-
import UUID from 'uuidjs';
|
|
24
|
-
|
|
25
|
-
import type {AvailabilityType, BroadcastService} from '../broadcast/';
|
|
26
|
-
import {isQualifiedIdArray} from '../util/TypePredicateUtil';
|
|
27
|
-
import {ConnectionService} from '../connection';
|
|
28
|
-
import {ConnectionStatus} from '@wireapp/api-client/src/connection';
|
|
29
|
-
import {ConversationService} from '../conversation';
|
|
30
|
-
import {UserPreKeyBundleMap} from '@wireapp/api-client/src/user/';
|
|
31
|
-
|
|
32
|
-
export class UserService {
|
|
33
|
-
private readonly apiClient: APIClient;
|
|
34
|
-
private readonly broadcastService: BroadcastService;
|
|
35
|
-
private readonly connectionService: ConnectionService;
|
|
36
|
-
private readonly conversationService: ConversationService;
|
|
37
|
-
|
|
38
|
-
constructor(
|
|
39
|
-
apiClient: APIClient,
|
|
40
|
-
broadcastService: BroadcastService,
|
|
41
|
-
conversationService: ConversationService,
|
|
42
|
-
connectionService: ConnectionService,
|
|
43
|
-
) {
|
|
44
|
-
this.apiClient = apiClient;
|
|
45
|
-
this.broadcastService = broadcastService;
|
|
46
|
-
this.connectionService = connectionService;
|
|
47
|
-
this.conversationService = conversationService;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
public getUser(userId: string | QualifiedId): Promise<User> {
|
|
51
|
-
return this.apiClient.user.api.getUser(userId as QualifiedId);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
public async getUsers(userIds: string[] | QualifiedId[]): Promise<User[]> {
|
|
55
|
-
if (!userIds.length) {
|
|
56
|
-
return [];
|
|
57
|
-
}
|
|
58
|
-
return isQualifiedIdArray(userIds)
|
|
59
|
-
? this.apiClient.user.api.postListUsers({qualified_ids: userIds})
|
|
60
|
-
: this.apiClient.user.api.getUsers({ids: userIds});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
public async setAvailability(teamId: string, type: AvailabilityType, sendAsProtobuf?: boolean): Promise<void> {
|
|
64
|
-
// Get pre-key bundles for members of your own team
|
|
65
|
-
const preKeyBundlesFromTeam = await this.broadcastService.getPreKeyBundlesFromTeam(teamId);
|
|
66
|
-
|
|
67
|
-
// Get pre-key bundles for all of your other 1:1 connections
|
|
68
|
-
const connections = await this.connectionService.getConnections();
|
|
69
|
-
const acceptedConnections = connections.filter(connection => connection.status === ConnectionStatus.ACCEPTED);
|
|
70
|
-
const preKeyBundlePromises = acceptedConnections.map(connection => {
|
|
71
|
-
const mappedConnection = {
|
|
72
|
-
userId: connection.to,
|
|
73
|
-
conversationId: connection.conversation,
|
|
74
|
-
};
|
|
75
|
-
return this.conversationService.getPreKeyBundleMap(mappedConnection.conversationId, [mappedConnection.userId]);
|
|
76
|
-
});
|
|
77
|
-
const preKeyBundlesFromConnections = await Promise.all(preKeyBundlePromises);
|
|
78
|
-
|
|
79
|
-
// Merge pre-key bundles
|
|
80
|
-
const allPreKeyBundles = preKeyBundlesFromConnections.reduce(
|
|
81
|
-
(accumulator: UserPreKeyBundleMap, preKeyBundleMap: UserPreKeyBundleMap) => {
|
|
82
|
-
return {
|
|
83
|
-
...accumulator,
|
|
84
|
-
...preKeyBundleMap,
|
|
85
|
-
};
|
|
86
|
-
},
|
|
87
|
-
preKeyBundlesFromTeam,
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
const genericMessage = GenericMessage.create({
|
|
91
|
-
availability: new Availability({type}),
|
|
92
|
-
messageId: UUID.genV4().toString(),
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
// Broadcast availability status to your team members & external 1:1 connections
|
|
96
|
-
await this.broadcastService.broadcastGenericMessage(genericMessage, allPreKeyBundles, sendAsProtobuf);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;;;;;;;;;AAEH,gDAA8B"}
|
package/src/main/user/index.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Wire
|
|
3
|
-
* Copyright (C) 2018 Wire Swiss GmbH
|
|
4
|
-
*
|
|
5
|
-
* This program is free software: you can redistribute it and/or modify
|
|
6
|
-
* it under the terms of the GNU General Public License as published by
|
|
7
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
* (at your option) any later version.
|
|
9
|
-
*
|
|
10
|
-
* This program is distributed in the hope that it will be useful,
|
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
* GNU General Public License for more details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU General Public License
|
|
16
|
-
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
export * from './UserService';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TypePredicateUtil.js","sourceRoot":"","sources":["TypePredicateUtil.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAKH,SAAgB,aAAa,CAAC,GAAQ;IACpC,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,GAAG,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC;AAChF,CAAC;AAFD,sCAEC;AAED,SAAgB,aAAa,CAAC,GAAQ;IACpC,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,OAAO,GAAG,CAAC,QAAQ,CAAC,KAAK,QAAQ,CAAC;AACtE,CAAC;AAFD,sCAEC;AAED,SAAgB,kBAAkB,CAAC,GAAQ;IACzC,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACrD,CAAC;AAFD,gDAEC;AAED,SAAgB,sBAAsB,CAAC,GAAQ;;IAC7C,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;QAC3B,MAAM,qBAAqB,GAAG,MAAA,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,0CAAG,CAAC,CAAC,CAAC;QACtD,IAAI,OAAO,qBAAqB,KAAK,QAAQ,EAAE;YAC7C,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC,qBAA+B,CAAC,CAAC,CAAC,CAAC,CAAC;YAC7E,OAAO,aAAa,CAAC,kBAAkB,CAAC,CAAC;SAC1C;KACF;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AATD,wDASC;AAED,SAAgB,aAAa,CAAC,GAAQ;;IACpC,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;QAC3B,MAAM,oBAAoB,GAAG,MAAA,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,0CAAG,CAAC,CAAC,CAAC;QACrD,OAAO,aAAa,CAAC,oBAAoB,CAAC,CAAC;KAC5C;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAND,sCAMC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Wire
|
|
4
|
-
* Copyright (C) 2021 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
|
-
const TypePredicateUtil_1 = require("./TypePredicateUtil");
|
|
22
|
-
describe('TypePredicatUtil', () => {
|
|
23
|
-
describe('isQualifiedUserClients', () => {
|
|
24
|
-
it('detects QualifiedUserClients', () => {
|
|
25
|
-
const validUserClients = [
|
|
26
|
-
{ domain1: { user1: ['client1'] } },
|
|
27
|
-
{ domain1: { user1: [] } }, // When a user has no clients
|
|
28
|
-
];
|
|
29
|
-
validUserClients.forEach(payload => expect((0, TypePredicateUtil_1.isQualifiedUserClients)(payload)).toBeTrue());
|
|
30
|
-
});
|
|
31
|
-
it('rejects non QualifiedUserClients', () => {
|
|
32
|
-
const invalidUserClients = [
|
|
33
|
-
{ domain1: { user1: '' } },
|
|
34
|
-
{ domain1: { user1: {} } },
|
|
35
|
-
{ domain1: [] },
|
|
36
|
-
{ domain1: { user1: [{}] } },
|
|
37
|
-
];
|
|
38
|
-
invalidUserClients.forEach(payload => expect((0, TypePredicateUtil_1.isQualifiedUserClients)(payload)).toBeFalse());
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
//# sourceMappingURL=TypePredicateUtil.test.node.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TypePredicateUtil.test.node.js","sourceRoot":"","sources":["TypePredicateUtil.test.node.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;AAEH,2DAA2D;AAE3D,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;QACtC,EAAE,CAAC,8BAA8B,EAAE,GAAG,EAAE;YACtC,MAAM,gBAAgB,GAAG;gBACvB,EAAC,OAAO,EAAE,EAAC,KAAK,EAAE,CAAC,SAAS,CAAC,EAAC,EAAC;gBAC/B,EAAC,OAAO,EAAE,EAAC,KAAK,EAAE,EAAE,EAAC,EAAC,EAAE,6BAA6B;aACtD,CAAC;YAEF,gBAAgB,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,MAAM,CAAC,IAAA,0CAAsB,EAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC1F,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE;YAC1C,MAAM,kBAAkB,GAAG;gBACzB,EAAC,OAAO,EAAE,EAAC,KAAK,EAAE,EAAE,EAAC,EAAC;gBACtB,EAAC,OAAO,EAAE,EAAC,KAAK,EAAE,EAAE,EAAC,EAAC;gBACtB,EAAC,OAAO,EAAE,EAAE,EAAC;gBACb,EAAC,OAAO,EAAE,EAAC,KAAK,EAAE,CAAC,EAAE,CAAC,EAAC,EAAC;aACzB,CAAC;YAEF,kBAAkB,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,MAAM,CAAC,IAAA,0CAAsB,EAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC;QAC7F,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Wire
|
|
3
|
-
* Copyright (C) 2021 Wire Swiss GmbH
|
|
4
|
-
*
|
|
5
|
-
* This program is free software: you can redistribute it and/or modify
|
|
6
|
-
* it under the terms of the GNU General Public License as published by
|
|
7
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
* (at your option) any later version.
|
|
9
|
-
*
|
|
10
|
-
* This program is distributed in the hope that it will be useful,
|
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
* GNU General Public License for more details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU General Public License
|
|
16
|
-
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import {isQualifiedUserClients} from './TypePredicateUtil';
|
|
21
|
-
|
|
22
|
-
describe('TypePredicatUtil', () => {
|
|
23
|
-
describe('isQualifiedUserClients', () => {
|
|
24
|
-
it('detects QualifiedUserClients', () => {
|
|
25
|
-
const validUserClients = [
|
|
26
|
-
{domain1: {user1: ['client1']}},
|
|
27
|
-
{domain1: {user1: []}}, // When a user has no clients
|
|
28
|
-
];
|
|
29
|
-
|
|
30
|
-
validUserClients.forEach(payload => expect(isQualifiedUserClients(payload)).toBeTrue());
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('rejects non QualifiedUserClients', () => {
|
|
34
|
-
const invalidUserClients = [
|
|
35
|
-
{domain1: {user1: ''}},
|
|
36
|
-
{domain1: {user1: {}}},
|
|
37
|
-
{domain1: []},
|
|
38
|
-
{domain1: {user1: [{}]}},
|
|
39
|
-
];
|
|
40
|
-
|
|
41
|
-
invalidUserClients.forEach(payload => expect(isQualifiedUserClients(payload)).toBeFalse());
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
});
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Wire
|
|
3
|
-
* Copyright (C) 2021 Wire Swiss GmbH
|
|
4
|
-
*
|
|
5
|
-
* This program is free software: you can redistribute it and/or modify
|
|
6
|
-
* it under the terms of the GNU General Public License as published by
|
|
7
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
* (at your option) any later version.
|
|
9
|
-
*
|
|
10
|
-
* This program is distributed in the hope that it will be useful,
|
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
* GNU General Public License for more details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU General Public License
|
|
16
|
-
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import type {QualifiedUserClients, UserClients} from '@wireapp/api-client/src/conversation/';
|
|
21
|
-
import type {QualifiedId} from '@wireapp/api-client/src/user/';
|
|
22
|
-
|
|
23
|
-
export function isStringArray(obj: any): obj is string[] {
|
|
24
|
-
return Array.isArray(obj) && (obj.length === 0 || typeof obj[0] === 'string');
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function isQualifiedId(obj: any): obj is QualifiedId {
|
|
28
|
-
return typeof obj === 'object' && typeof obj['domain'] === 'string';
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function isQualifiedIdArray(obj: any): obj is QualifiedId[] {
|
|
32
|
-
return Array.isArray(obj) && isQualifiedId(obj[0]);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function isQualifiedUserClients(obj: any): obj is QualifiedUserClients {
|
|
36
|
-
if (typeof obj === 'object') {
|
|
37
|
-
const firstUserClientObject = Object.values(obj)?.[0];
|
|
38
|
-
if (typeof firstUserClientObject === 'object') {
|
|
39
|
-
const firstClientIdArray = Object.values(firstUserClientObject as object)[0];
|
|
40
|
-
return isStringArray(firstClientIdArray);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export function isUserClients(obj: any): obj is UserClients {
|
|
47
|
-
if (typeof obj === 'object') {
|
|
48
|
-
const firstUserClientArray = Object.values(obj)?.[0];
|
|
49
|
-
return isStringArray(firstUserClientArray);
|
|
50
|
-
}
|
|
51
|
-
return false;
|
|
52
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;;;;;;;;;AAEH,sDAAoC"}
|
package/src/main/util/index.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Wire
|
|
3
|
-
* Copyright (C) 2021 Wire Swiss GmbH
|
|
4
|
-
*
|
|
5
|
-
* This program is free software: you can redistribute it and/or modify
|
|
6
|
-
* it under the terms of the GNU General Public License as published by
|
|
7
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
* (at your option) any later version.
|
|
9
|
-
*
|
|
10
|
-
* This program is distributed in the hope that it will be useful,
|
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
* GNU General Public License for more details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU General Public License
|
|
16
|
-
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
export * from './TypePredicateUtil';
|