@wireapp/core 17.30.0 → 17.31.3

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.
Files changed (239) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/package.json +8 -8
  3. package/src/main/cryptography/GenericMessageMapper.d.ts +0 -1
  4. package/src/main/cryptography/GenericMessageMapper.js +23 -158
  5. package/src/main/Account.js.map +0 -1
  6. package/src/main/Account.test.browser.js +0 -114
  7. package/src/main/Account.test.node.d.ts +0 -1
  8. package/src/main/Account.test.node.js +0 -214
  9. package/src/main/Account.test.node.js.map +0 -1
  10. package/src/main/Account.test.node.ts +0 -236
  11. package/src/main/Account.ts +0 -401
  12. package/src/main/CoreError.js.map +0 -1
  13. package/src/main/CoreError.ts +0 -30
  14. package/src/main/auth/LoginSanitizer.js.map +0 -1
  15. package/src/main/auth/LoginSanitizer.test.node.d.ts +0 -1
  16. package/src/main/auth/LoginSanitizer.test.node.js +0 -56
  17. package/src/main/auth/LoginSanitizer.test.node.js.map +0 -1
  18. package/src/main/auth/LoginSanitizer.test.node.ts +0 -68
  19. package/src/main/auth/LoginSanitizer.ts +0 -44
  20. package/src/main/auth/index.js.map +0 -1
  21. package/src/main/auth/index.ts +0 -20
  22. package/src/main/broadcast/AvailabilityType.js.map +0 -1
  23. package/src/main/broadcast/AvailabilityType.ts +0 -22
  24. package/src/main/broadcast/BroadcastService.js.map +0 -1
  25. package/src/main/broadcast/BroadcastService.ts +0 -66
  26. package/src/main/broadcast/index.js.map +0 -1
  27. package/src/main/broadcast/index.ts +0 -21
  28. package/src/main/client/ClientBackendRepository.js.map +0 -1
  29. package/src/main/client/ClientBackendRepository.ts +0 -33
  30. package/src/main/client/ClientDatabaseRepository.js.map +0 -1
  31. package/src/main/client/ClientDatabaseRepository.ts +0 -130
  32. package/src/main/client/ClientInfo.js.map +0 -1
  33. package/src/main/client/ClientInfo.ts +0 -28
  34. package/src/main/client/ClientService.js.map +0 -1
  35. package/src/main/client/ClientService.ts +0 -116
  36. package/src/main/client/index.js.map +0 -1
  37. package/src/main/client/index.ts +0 -23
  38. package/src/main/connection/ConnectionService.js.map +0 -1
  39. package/src/main/connection/ConnectionService.ts +0 -49
  40. package/src/main/connection/index.js.map +0 -1
  41. package/src/main/connection/index.ts +0 -20
  42. package/src/main/conversation/AbortReason.js.map +0 -1
  43. package/src/main/conversation/AbortReason.ts +0 -22
  44. package/src/main/conversation/AssetService.js.map +0 -1
  45. package/src/main/conversation/AssetService.test.node.d.ts +0 -1
  46. package/src/main/conversation/AssetService.test.node.js +0 -61
  47. package/src/main/conversation/AssetService.test.node.js.map +0 -1
  48. package/src/main/conversation/AssetService.test.node.ts +0 -65
  49. package/src/main/conversation/AssetService.ts +0 -60
  50. package/src/main/conversation/AssetTransferState.js.map +0 -1
  51. package/src/main/conversation/AssetTransferState.ts +0 -23
  52. package/src/main/conversation/ClientActionType.js.map +0 -1
  53. package/src/main/conversation/ClientActionType.ts +0 -20
  54. package/src/main/conversation/ConversationMapper.js.map +0 -1
  55. package/src/main/conversation/ConversationMapper.test.node.d.ts +0 -1
  56. package/src/main/conversation/ConversationMapper.test.node.js +0 -111
  57. package/src/main/conversation/ConversationMapper.test.node.js.map +0 -1
  58. package/src/main/conversation/ConversationMapper.test.node.ts +0 -154
  59. package/src/main/conversation/ConversationMapper.ts +0 -56
  60. package/src/main/conversation/ConversationService.js.map +0 -1
  61. package/src/main/conversation/ConversationService.test.node.d.ts +0 -1
  62. package/src/main/conversation/ConversationService.test.node.js +0 -344
  63. package/src/main/conversation/ConversationService.test.node.js.map +0 -1
  64. package/src/main/conversation/ConversationService.test.node.ts +0 -416
  65. package/src/main/conversation/ConversationService.ts +0 -1024
  66. package/src/main/conversation/GenericMessageType.js.map +0 -1
  67. package/src/main/conversation/GenericMessageType.ts +0 -44
  68. package/src/main/conversation/MessageTimer.js.map +0 -1
  69. package/src/main/conversation/MessageTimer.test.node.d.ts +0 -1
  70. package/src/main/conversation/MessageTimer.test.node.js +0 -88
  71. package/src/main/conversation/MessageTimer.test.node.js.map +0 -1
  72. package/src/main/conversation/MessageTimer.test.node.ts +0 -103
  73. package/src/main/conversation/MessageTimer.ts +0 -56
  74. package/src/main/conversation/ReactionType.js.map +0 -1
  75. package/src/main/conversation/ReactionType.ts +0 -23
  76. package/src/main/conversation/content/AssetContent.js.map +0 -1
  77. package/src/main/conversation/content/AssetContent.ts +0 -71
  78. package/src/main/conversation/content/ButtonActionConfirmationContent.js.map +0 -1
  79. package/src/main/conversation/content/ButtonActionConfirmationContent.ts +0 -21
  80. package/src/main/conversation/content/ButtonActionContent.js.map +0 -1
  81. package/src/main/conversation/content/ButtonActionContent.ts +0 -21
  82. package/src/main/conversation/content/CallingContent.js.map +0 -1
  83. package/src/main/conversation/content/CallingContent.ts +0 -20
  84. package/src/main/conversation/content/ClearedContent.js.map +0 -1
  85. package/src/main/conversation/content/ClearedContent.ts +0 -21
  86. package/src/main/conversation/content/ClientActionContent.js.map +0 -1
  87. package/src/main/conversation/content/ClientActionContent.ts +0 -22
  88. package/src/main/conversation/content/ClientAddContent.js.map +0 -1
  89. package/src/main/conversation/content/ClientAddContent.ts +0 -24
  90. package/src/main/conversation/content/ClientRemoveContent.js.map +0 -1
  91. package/src/main/conversation/content/ClientRemoveContent.ts +0 -25
  92. package/src/main/conversation/content/CompositeContent.js.map +0 -1
  93. package/src/main/conversation/content/CompositeContent.ts +0 -21
  94. package/src/main/conversation/content/ConfirmationContent.js.map +0 -1
  95. package/src/main/conversation/content/ConfirmationContent.ts +0 -21
  96. package/src/main/conversation/content/ContentType.js.map +0 -1
  97. package/src/main/conversation/content/ContentType.ts +0 -112
  98. package/src/main/conversation/content/ConversationContent.js.map +0 -1
  99. package/src/main/conversation/content/ConversationContent.ts +0 -71
  100. package/src/main/conversation/content/DeletedContent.js.map +0 -1
  101. package/src/main/conversation/content/DeletedContent.ts +0 -21
  102. package/src/main/conversation/content/EditedTextContent.js.map +0 -1
  103. package/src/main/conversation/content/EditedTextContent.ts +0 -31
  104. package/src/main/conversation/content/FileContent.js.map +0 -1
  105. package/src/main/conversation/content/FileContent.ts +0 -32
  106. package/src/main/conversation/content/HiddenContent.js.map +0 -1
  107. package/src/main/conversation/content/HiddenContent.ts +0 -21
  108. package/src/main/conversation/content/ImageContent.js.map +0 -1
  109. package/src/main/conversation/content/ImageContent.ts +0 -25
  110. package/src/main/conversation/content/KnockContent.js.map +0 -1
  111. package/src/main/conversation/content/KnockContent.ts +0 -21
  112. package/src/main/conversation/content/LinkPreviewContent.js.map +0 -1
  113. package/src/main/conversation/content/LinkPreviewContent.ts +0 -32
  114. package/src/main/conversation/content/LocationContent.js.map +0 -1
  115. package/src/main/conversation/content/LocationContent.ts +0 -29
  116. package/src/main/conversation/content/MentionContent.js.map +0 -1
  117. package/src/main/conversation/content/MentionContent.ts +0 -21
  118. package/src/main/conversation/content/QuoteContent.js.map +0 -1
  119. package/src/main/conversation/content/QuoteContent.ts +0 -29
  120. package/src/main/conversation/content/ReactionContent.js.map +0 -1
  121. package/src/main/conversation/content/ReactionContent.ts +0 -27
  122. package/src/main/conversation/content/TextContent.js.map +0 -1
  123. package/src/main/conversation/content/TextContent.ts +0 -29
  124. package/src/main/conversation/content/TweetContent.js.map +0 -1
  125. package/src/main/conversation/content/TweetContent.ts +0 -21
  126. package/src/main/conversation/content/index.js.map +0 -1
  127. package/src/main/conversation/content/index.ts +0 -49
  128. package/src/main/conversation/index.js.map +0 -1
  129. package/src/main/conversation/index.ts +0 -28
  130. package/src/main/conversation/message/CompositeContentBuilder.js.map +0 -1
  131. package/src/main/conversation/message/CompositeContentBuilder.ts +0 -60
  132. package/src/main/conversation/message/Message.js.map +0 -1
  133. package/src/main/conversation/message/Message.ts +0 -24
  134. package/src/main/conversation/message/MessageBuilder.js.map +0 -1
  135. package/src/main/conversation/message/MessageBuilder.test.browser.js +0 -27
  136. package/src/main/conversation/message/MessageBuilder.ts +0 -488
  137. package/src/main/conversation/message/MessageService.js.map +0 -1
  138. package/src/main/conversation/message/MessageService.test.node.d.ts +0 -1
  139. package/src/main/conversation/message/MessageService.test.node.js +0 -308
  140. package/src/main/conversation/message/MessageService.test.node.js.map +0 -1
  141. package/src/main/conversation/message/MessageService.test.node.ts +0 -398
  142. package/src/main/conversation/message/MessageService.ts +0 -383
  143. package/src/main/conversation/message/MessageToProtoMapper.js.map +0 -1
  144. package/src/main/conversation/message/MessageToProtoMapper.ts +0 -114
  145. package/src/main/conversation/message/OtrMessage.js.map +0 -1
  146. package/src/main/conversation/message/OtrMessage.ts +0 -160
  147. package/src/main/conversation/message/PayloadBundle.js.map +0 -1
  148. package/src/main/conversation/message/PayloadBundle.ts +0 -101
  149. package/src/main/conversation/message/TeamMessage.js.map +0 -1
  150. package/src/main/conversation/message/TeamMessage.ts +0 -72
  151. package/src/main/conversation/message/TextContentBuilder.js.map +0 -1
  152. package/src/main/conversation/message/TextContentBuilder.ts +0 -88
  153. package/src/main/conversation/message/UserClientsUtil.js.map +0 -1
  154. package/src/main/conversation/message/UserClientsUtil.ts +0 -44
  155. package/src/main/conversation/message/UserClientsUtils.test.node.d.ts +0 -1
  156. package/src/main/conversation/message/UserClientsUtils.test.node.js +0 -42
  157. package/src/main/conversation/message/UserClientsUtils.test.node.js.map +0 -1
  158. package/src/main/conversation/message/UserClientsUtils.test.node.ts +0 -44
  159. package/src/main/conversation/message/UserMessage.js.map +0 -1
  160. package/src/main/conversation/message/UserMessage.ts +0 -95
  161. package/src/main/cryptography/AssetCryptography.browser.js.map +0 -1
  162. package/src/main/cryptography/AssetCryptography.browser.ts +0 -76
  163. package/src/main/cryptography/AssetCryptography.node.js.map +0 -1
  164. package/src/main/cryptography/AssetCryptography.node.ts +0 -85
  165. package/src/main/cryptography/CryptographyDatabaseRepository.js.map +0 -1
  166. package/src/main/cryptography/CryptographyDatabaseRepository.ts +0 -44
  167. package/src/main/cryptography/CryptographyService.js.map +0 -1
  168. package/src/main/cryptography/CryptographyService.test.browser.js +0 -195
  169. package/src/main/cryptography/CryptographyService.test.node.d.ts +0 -1
  170. package/src/main/cryptography/CryptographyService.test.node.js +0 -228
  171. package/src/main/cryptography/CryptographyService.test.node.js.map +0 -1
  172. package/src/main/cryptography/CryptographyService.test.node.ts +0 -246
  173. package/src/main/cryptography/CryptographyService.ts +0 -246
  174. package/src/main/cryptography/EncryptedAsset.js.map +0 -1
  175. package/src/main/cryptography/EncryptedAsset.ts +0 -30
  176. package/src/main/cryptography/GenericMessageMapper.js.map +0 -1
  177. package/src/main/cryptography/GenericMessageMapper.ts +0 -364
  178. package/src/main/cryptography/MessageHashService.js.map +0 -1
  179. package/src/main/cryptography/MessageHashService.test.browser.js +0 -176
  180. package/src/main/cryptography/MessageHashService.test.node.d.ts +0 -1
  181. package/src/main/cryptography/MessageHashService.test.node.js +0 -138
  182. package/src/main/cryptography/MessageHashService.test.node.js.map +0 -1
  183. package/src/main/cryptography/MessageHashService.test.node.ts +0 -176
  184. package/src/main/cryptography/MessageHashService.ts +0 -109
  185. package/src/main/cryptography/SessionPayloadBundle.js.map +0 -1
  186. package/src/main/cryptography/SessionPayloadBundle.ts +0 -23
  187. package/src/main/cryptography/index.js.map +0 -1
  188. package/src/main/cryptography/index.ts +0 -23
  189. package/src/main/giphy/GiphyService.js.map +0 -1
  190. package/src/main/giphy/GiphyService.ts +0 -37
  191. package/src/main/giphy/index.js.map +0 -1
  192. package/src/main/giphy/index.ts +0 -20
  193. package/src/main/index.js.map +0 -1
  194. package/src/main/index.test.browser.js +0 -22
  195. package/src/main/index.ts +0 -34
  196. package/src/main/notification/NotificationBackendRepository.js.map +0 -1
  197. package/src/main/notification/NotificationBackendRepository.ts +0 -33
  198. package/src/main/notification/NotificationDatabaseRepository.js.map +0 -1
  199. package/src/main/notification/NotificationDatabaseRepository.ts +0 -74
  200. package/src/main/notification/NotificationService.js.map +0 -1
  201. package/src/main/notification/NotificationService.test.browser.js +0 -179
  202. package/src/main/notification/NotificationService.test.node.d.ts +0 -1
  203. package/src/main/notification/NotificationService.test.node.js +0 -99
  204. package/src/main/notification/NotificationService.test.node.js.map +0 -1
  205. package/src/main/notification/NotificationService.test.node.ts +0 -124
  206. package/src/main/notification/NotificationService.ts +0 -260
  207. package/src/main/notification/index.js.map +0 -1
  208. package/src/main/notification/index.ts +0 -20
  209. package/src/main/self/SelfService.js.map +0 -1
  210. package/src/main/self/SelfService.ts +0 -59
  211. package/src/main/self/index.js.map +0 -1
  212. package/src/main/self/index.ts +0 -20
  213. package/src/main/team/TeamService.js.map +0 -1
  214. package/src/main/team/TeamService.ts +0 -68
  215. package/src/main/team/index.js.map +0 -1
  216. package/src/main/team/index.ts +0 -20
  217. package/src/main/test/CryptographyHelper.js.map +0 -1
  218. package/src/main/test/CryptographyHelper.ts +0 -57
  219. package/src/main/test/PayloadHelper.js.map +0 -1
  220. package/src/main/test/PayloadHelper.ts +0 -60
  221. package/src/main/user/UserMapper.js.map +0 -1
  222. package/src/main/user/UserMapper.test.node.d.ts +0 -1
  223. package/src/main/user/UserMapper.test.node.js +0 -55
  224. package/src/main/user/UserMapper.test.node.js.map +0 -1
  225. package/src/main/user/UserMapper.test.node.ts +0 -63
  226. package/src/main/user/UserMapper.ts +0 -92
  227. package/src/main/user/UserService.js.map +0 -1
  228. package/src/main/user/UserService.test.node.js +0 -141
  229. package/src/main/user/UserService.ts +0 -98
  230. package/src/main/user/index.js.map +0 -1
  231. package/src/main/user/index.ts +0 -20
  232. package/src/main/util/TypePredicateUtil.js.map +0 -1
  233. package/src/main/util/TypePredicateUtil.test.node.d.ts +0 -1
  234. package/src/main/util/TypePredicateUtil.test.node.js +0 -42
  235. package/src/main/util/TypePredicateUtil.test.node.js.map +0 -1
  236. package/src/main/util/TypePredicateUtil.test.node.ts +0 -44
  237. package/src/main/util/TypePredicateUtil.ts +0 -52
  238. package/src/main/util/index.js.map +0 -1
  239. 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"}
@@ -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"}
@@ -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';