@wireapp/core 46.46.6-beta.14.f6fd03fe6 → 46.46.6
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/lib/Account.d.ts +156 -51
- package/lib/Account.d.ts.map +1 -1
- package/lib/Account.js +503 -127
- package/lib/Account.test.js +158 -147
- package/lib/broadcast/AvailabilityType.d.ts +1 -1
- package/lib/broadcast/AvailabilityType.d.ts.map +1 -1
- package/lib/broadcast/BroadcastService.d.ts +1 -1
- package/lib/broadcast/BroadcastService.d.ts.map +1 -1
- package/lib/broadcast/BroadcastService.js +1 -1
- package/lib/client/ClientService.d.ts +4 -3
- package/lib/client/ClientService.d.ts.map +1 -1
- package/lib/client/ClientService.js +19 -5
- package/lib/conversation/AbortReason.d.ts +1 -1
- package/lib/conversation/AbortReason.d.ts.map +1 -1
- package/lib/conversation/AssetService/AssetService.d.ts +12 -30
- package/lib/conversation/AssetService/AssetService.d.ts.map +1 -1
- package/lib/conversation/AssetService/AssetService.js +1 -10
- package/lib/conversation/AssetService/AssetService.test.js +8 -3
- package/lib/conversation/ClientActionType.d.ts +1 -1
- package/lib/conversation/ClientActionType.d.ts.map +1 -1
- package/lib/conversation/ClientActionType.js +1 -1
- package/lib/conversation/ConversationService/ConversationService.d.ts +98 -14
- package/lib/conversation/ConversationService/ConversationService.d.ts.map +1 -1
- package/lib/conversation/ConversationService/ConversationService.js +314 -101
- package/lib/conversation/ConversationService/ConversationService.test.js +441 -47
- package/lib/conversation/ConversationService/ConversationService.types.d.ts +5 -4
- package/lib/conversation/ConversationService/ConversationService.types.d.ts.map +1 -1
- package/lib/conversation/ConversationService/Utility/getConversationQualifiedMembers.d.ts.map +1 -1
- package/lib/conversation/ConversationService/Utility/getConversationQualifiedMembers.js +6 -3
- package/lib/conversation/SubconversationService/SubconversationService.d.ts.map +1 -1
- package/lib/conversation/SubconversationService/SubconversationService.js +158 -11
- package/lib/conversation/SubconversationService/SubconversationService.test.js +8 -2
- package/lib/conversation/content/AssetContent.d.ts +1 -1
- package/lib/conversation/content/AssetContent.d.ts.map +1 -1
- package/lib/conversation/content/ButtonActionConfirmationContent.d.ts +1 -1
- package/lib/conversation/content/ButtonActionConfirmationContent.d.ts.map +1 -1
- package/lib/conversation/content/ButtonActionContent.d.ts +1 -1
- package/lib/conversation/content/ButtonActionContent.d.ts.map +1 -1
- package/lib/conversation/content/ClearedContent.d.ts +1 -1
- package/lib/conversation/content/ClearedContent.d.ts.map +1 -1
- package/lib/conversation/content/ClientActionContent.d.ts +1 -1
- package/lib/conversation/content/ClientActionContent.d.ts.map +1 -1
- package/lib/conversation/content/CompositeContent.d.ts +1 -1
- package/lib/conversation/content/CompositeContent.d.ts.map +1 -1
- package/lib/conversation/content/ConfirmationContent.d.ts +1 -1
- package/lib/conversation/content/ConfirmationContent.d.ts.map +1 -1
- package/lib/conversation/content/DeletedContent.d.ts +1 -1
- package/lib/conversation/content/DeletedContent.d.ts.map +1 -1
- package/lib/conversation/content/HiddenContent.d.ts +1 -1
- package/lib/conversation/content/HiddenContent.d.ts.map +1 -1
- package/lib/conversation/content/KnockContent.d.ts +1 -1
- package/lib/conversation/content/KnockContent.d.ts.map +1 -1
- package/lib/conversation/content/LinkPreviewContent.d.ts +1 -1
- package/lib/conversation/content/LinkPreviewContent.d.ts.map +1 -1
- package/lib/conversation/content/MentionContent.d.ts +1 -1
- package/lib/conversation/content/MentionContent.d.ts.map +1 -1
- package/lib/conversation/content/MultipartContent.d.ts +1 -1
- package/lib/conversation/content/MultipartContent.d.ts.map +1 -1
- package/lib/conversation/content/QuoteContent.d.ts +1 -1
- package/lib/conversation/content/QuoteContent.d.ts.map +1 -1
- package/lib/conversation/content/TweetContent.d.ts +1 -1
- package/lib/conversation/content/TweetContent.d.ts.map +1 -1
- package/lib/conversation/content/index.d.ts +1 -1
- package/lib/conversation/content/index.d.ts.map +1 -1
- package/lib/conversation/content/index.js +1 -1
- package/lib/conversation/message/MessageBuilder.d.ts +1 -1
- package/lib/conversation/message/MessageBuilder.d.ts.map +1 -1
- package/lib/conversation/message/MessageBuilder.js +1 -1
- package/lib/conversation/message/MessageService.d.ts.map +1 -1
- package/lib/conversation/message/MessageService.js +1 -1
- package/lib/conversation/message/MessageService.test.js +7 -1
- package/lib/conversation/message/MessageToProtoMapper.d.ts +1 -1
- package/lib/conversation/message/MessageToProtoMapper.d.ts.map +1 -1
- package/lib/conversation/message/MessageToProtoMapper.js +1 -1
- package/lib/conversation/message/messageSender.js +2 -2
- package/lib/cryptography/AssetCryptography/EncryptedAsset.d.ts +2 -2
- package/lib/cryptography/AssetCryptography/EncryptedAsset.d.ts.map +1 -1
- package/lib/messagingProtocols/common.types.d.ts +9 -0
- package/lib/messagingProtocols/common.types.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIService.types.d.ts +2 -2
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIService.types.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIService.types.js +2 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.d.ts +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.js +13 -11
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.test.js +21 -16
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceInternal.d.ts +9 -3
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceInternal.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceInternal.js +31 -12
- package/lib/messagingProtocols/mls/E2EIdentityService/Helper/index.d.ts +6 -0
- package/lib/messagingProtocols/mls/E2EIdentityService/Helper/index.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/Helper/index.js +19 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingProposalsQueue/IncomingProposalsQueue.d.ts +7 -0
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingProposalsQueue/IncomingProposalsQueue.d.ts.map +1 -0
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingProposalsQueue/IncomingProposalsQueue.js +48 -0
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingProposalsQueue/index.d.ts +2 -0
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/{IncomingMessagesQueue → IncomingProposalsQueue}/index.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/{IncomingMessagesQueue → IncomingProposalsQueue}/index.js +1 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/index.d.ts +0 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/index.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/index.js +0 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.js +23 -14
- package/lib/messagingProtocols/mls/EventHandler/events/welcomeMessage/welcomeMessage.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/EventHandler/events/welcomeMessage/welcomeMessage.js +5 -2
- package/lib/messagingProtocols/mls/EventHandler/events/welcomeMessage/welcomeMessage.test.js +13 -3
- package/lib/messagingProtocols/mls/MLSService/CoreCryptoMLSError.d.ts +38 -2
- package/lib/messagingProtocols/mls/MLSService/CoreCryptoMLSError.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/MLSService/CoreCryptoMLSError.js +41 -6
- package/lib/messagingProtocols/mls/MLSService/CoreCryptoMLSError.test.d.ts +2 -0
- package/lib/messagingProtocols/mls/MLSService/CoreCryptoMLSError.test.d.ts.map +1 -0
- package/lib/messagingProtocols/mls/MLSService/CoreCryptoMLSError.test.js +124 -0
- package/lib/messagingProtocols/mls/MLSService/MLSService.d.ts +38 -34
- package/lib/messagingProtocols/mls/MLSService/MLSService.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/MLSService/MLSService.js +267 -208
- package/lib/messagingProtocols/mls/MLSService/MLSService.test.js +157 -160
- package/lib/messagingProtocols/mls/MLSService/commitBundleUtil.js +3 -3
- package/lib/messagingProtocols/mls/MLSService/commitBundleUtil.test.js +5 -5
- package/lib/messagingProtocols/mls/conversationRejoinQueue.js +2 -2
- package/lib/messagingProtocols/mls/recovery/MlsErrorMapper.d.ts +78 -0
- package/lib/messagingProtocols/mls/recovery/MlsErrorMapper.d.ts.map +1 -0
- package/lib/messagingProtocols/mls/recovery/MlsErrorMapper.js +173 -0
- package/lib/messagingProtocols/mls/recovery/MlsErrorMapper.test.d.ts +2 -0
- package/lib/messagingProtocols/mls/recovery/MlsErrorMapper.test.d.ts.map +1 -0
- package/lib/messagingProtocols/mls/recovery/MlsErrorMapper.test.js +117 -0
- package/lib/messagingProtocols/mls/recovery/MlsRecoveryOrchestrator.d.ts +167 -0
- package/lib/messagingProtocols/mls/recovery/MlsRecoveryOrchestrator.d.ts.map +1 -0
- package/lib/messagingProtocols/mls/recovery/MlsRecoveryOrchestrator.js +317 -0
- package/lib/messagingProtocols/mls/recovery/MlsRecoveryOrchestrator.test.d.ts +2 -0
- package/lib/messagingProtocols/mls/recovery/MlsRecoveryOrchestrator.test.d.ts.map +1 -0
- package/lib/messagingProtocols/mls/recovery/MlsRecoveryOrchestrator.test.js +248 -0
- package/lib/messagingProtocols/mls/recovery/index.d.ts +5 -0
- package/lib/messagingProtocols/mls/recovery/index.d.ts.map +1 -0
- package/lib/messagingProtocols/mls/recovery/index.js +28 -0
- package/lib/messagingProtocols/mls/types.d.ts +0 -8
- package/lib/messagingProtocols/mls/types.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/EventHandler/events/otrMessageAdd/otrMessageAdd.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/EventHandler/events/otrMessageAdd/otrMessageAdd.js +7 -1
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/CoreCryptoWrapper.d.ts +8 -15
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/CoreCryptoWrapper.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/CoreCryptoWrapper.js +97 -62
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoClient.types.d.ts +0 -6
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoClient.types.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/DecryptionErrorGenerator/DecryptionErrorGenerator.d.ts +1 -6
- package/lib/messagingProtocols/proteus/ProteusService/DecryptionErrorGenerator/DecryptionErrorGenerator.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/DecryptionErrorGenerator/DecryptionErrorGenerator.js +19 -22
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.d.ts +5 -3
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.js +11 -24
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.mocks.d.ts +1 -0
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.mocks.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.mocks.js +11 -2
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.test.js +13 -9
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.types.d.ts +3 -2
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.types.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/WithMockedGenerics.test.js +11 -4
- package/lib/messagingProtocols/proteus/ProteusService/cryptoMigrationStateStore.d.ts +0 -4
- package/lib/messagingProtocols/proteus/ProteusService/cryptoMigrationStateStore.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/cryptoMigrationStateStore.js +0 -5
- package/lib/messagingProtocols/proteus/ProteusService/identityClearer.d.ts +2 -1
- package/lib/messagingProtocols/proteus/ProteusService/identityClearer.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/identityClearer.js +8 -2
- package/lib/messagingProtocols/proteus/Utility/SessionHandler/SessionHandler.test.js +4 -0
- package/lib/messagingProtocols/proteus/Utility/getGenericMessageParams.d.ts +1 -1
- package/lib/messagingProtocols/proteus/Utility/getGenericMessageParams.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/Utility/getGenericMessageParams.js +1 -1
- package/lib/notification/NotificationService.d.ts +20 -6
- package/lib/notification/NotificationService.d.ts.map +1 -1
- package/lib/notification/NotificationService.js +23 -14
- package/lib/notification/NotificationService.test.js +8 -0
- package/lib/secretStore/secretKeyGenerator.d.ts +1 -0
- package/lib/secretStore/secretKeyGenerator.d.ts.map +1 -1
- package/lib/secretStore/secretKeyGenerator.js +3 -1
- package/lib/self/SelfService.d.ts +2 -2
- package/lib/self/SelfService.d.ts.map +1 -1
- package/lib/self/SelfService.test.js +5 -2
- package/lib/team/TeamService.d.ts +5 -2
- package/lib/team/TeamService.d.ts.map +1 -1
- package/lib/team/TeamService.js +12 -2
- package/lib/test/StoreHelper.d.ts +2 -0
- package/lib/test/StoreHelper.d.ts.map +1 -0
- package/lib/test/StoreHelper.js +27 -0
- package/lib/user/UserService.d.ts +2 -2
- package/lib/user/UserService.d.ts.map +1 -1
- package/lib/user/UserService.js +3 -3
- package/lib/util/TypePredicateUtil.d.ts.map +1 -1
- package/lib/util/TypePredicateUtil.js +2 -2
- package/package.json +3 -3
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingMessagesQueue/IncomingMesssagesQueue.d.ts +0 -4
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingMessagesQueue/IncomingMesssagesQueue.d.ts.map +0 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingMessagesQueue/IncomingMesssagesQueue.js +0 -69
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingMessagesQueue/index.d.ts +0 -2
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.test.d.ts +0 -2
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.test.d.ts.map +0 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.test.js +0 -98
package/lib/Account.test.js
CHANGED
|
@@ -41,15 +41,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
41
41
|
return result;
|
|
42
42
|
};
|
|
43
43
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
-
const protocol_messaging_1 = require("@pydio/protocol-messaging");
|
|
45
44
|
const auth_1 = require("@wireapp/api-client/lib/auth");
|
|
46
45
|
const client_1 = require("@wireapp/api-client/lib/client");
|
|
46
|
+
const Config_1 = require("@wireapp/api-client/lib/Config");
|
|
47
47
|
const conversation_1 = require("@wireapp/api-client/lib/conversation");
|
|
48
|
-
const event_1 = require("@wireapp/api-client/lib/event");
|
|
49
48
|
const http_1 = require("@wireapp/api-client/lib/http");
|
|
50
49
|
const notification_1 = require("@wireapp/api-client/lib/notification");
|
|
50
|
+
const ConsumableNotification_1 = require("@wireapp/api-client/lib/notification/ConsumableNotification");
|
|
51
51
|
const self_1 = require("@wireapp/api-client/lib/self");
|
|
52
|
-
const tcp_1 = require("@wireapp/api-client/lib/tcp");
|
|
53
52
|
const ReconnectingWebsocket_1 = require("@wireapp/api-client/lib/tcp/ReconnectingWebsocket");
|
|
54
53
|
const http_status_codes_1 = require("http-status-codes");
|
|
55
54
|
const jest_websocket_mock_1 = require("jest-websocket-mock");
|
|
@@ -57,6 +56,20 @@ const nock_1 = __importStar(require("nock"));
|
|
|
57
56
|
const uuid_1 = require("uuid");
|
|
58
57
|
const api_client_1 = require("@wireapp/api-client");
|
|
59
58
|
const commons_1 = require("@wireapp/commons");
|
|
59
|
+
const protocol_messaging_1 = require("@wireapp/protocol-messaging");
|
|
60
|
+
// Mock ConversationService to avoid requiring MLSService in constructor during tests
|
|
61
|
+
jest.mock('./conversation', () => {
|
|
62
|
+
const actual = jest.requireActual('./conversation');
|
|
63
|
+
class FakeConversationService {
|
|
64
|
+
constructor(..._args) { }
|
|
65
|
+
// Return unhandled so NotificationService falls back to generic handling in tests
|
|
66
|
+
handleEvent = jest.fn(async () => ({ status: 'unhandled' }));
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
...actual,
|
|
70
|
+
ConversationService: FakeConversationService,
|
|
71
|
+
};
|
|
72
|
+
});
|
|
60
73
|
const Account_1 = require("./Account");
|
|
61
74
|
const notification_2 = require("./notification");
|
|
62
75
|
const BASE_URL = 'mock-backend.wire.com';
|
|
@@ -65,8 +78,10 @@ const MOCK_BACKEND = {
|
|
|
65
78
|
rest: `https://${BASE_URL}`,
|
|
66
79
|
ws: `wss://${BASE_URL}`,
|
|
67
80
|
};
|
|
81
|
+
const apiClients = [];
|
|
68
82
|
async function createAccount() {
|
|
69
83
|
const apiClient = new api_client_1.APIClient({ urls: MOCK_BACKEND });
|
|
84
|
+
apiClients.push(apiClient);
|
|
70
85
|
const account = new Account_1.Account(apiClient);
|
|
71
86
|
await account['initServices']({
|
|
72
87
|
clientType: client_1.ClientType.TEMPORARY,
|
|
@@ -97,6 +112,9 @@ const waitFor = (assertion) => {
|
|
|
97
112
|
/* eslint-disable jest/no-conditional-expect */
|
|
98
113
|
describe('Account', () => {
|
|
99
114
|
const CLIENT_ID = '4e37b32f57f6da55';
|
|
115
|
+
afterAll(() => {
|
|
116
|
+
apiClients.forEach(client => client.disconnect());
|
|
117
|
+
});
|
|
100
118
|
// Fix for node 16, crypto.subtle.decrypt has a type problem
|
|
101
119
|
jest.spyOn(global.crypto.subtle, 'decrypt').mockResolvedValue(new Uint8Array(32));
|
|
102
120
|
const accessTokenData = {
|
|
@@ -105,6 +123,8 @@ describe('Account', () => {
|
|
|
105
123
|
token_type: 'Bearer',
|
|
106
124
|
user: 'aaf9a833-ef30-4c22-86a0-9adc8a15b3b4',
|
|
107
125
|
};
|
|
126
|
+
const markerId = '90da5591-0a26-45f8-bbb2-6c0fc4a2df19';
|
|
127
|
+
const websocketServerAddress = `${MOCK_BACKEND.ws}/v${Config_1.MINIMUM_API_VERSION}/events?access_token=${accessTokenData.access_token}&marker=${markerId}`;
|
|
108
128
|
beforeEach(() => {
|
|
109
129
|
(0, nock_1.default)(MOCK_BACKEND.rest)
|
|
110
130
|
.post(auth_1.AuthAPI.URL.LOGIN, body => body.email && body.password)
|
|
@@ -134,6 +154,14 @@ describe('Account', () => {
|
|
|
134
154
|
.get(`${notification_1.NotificationAPI.URL.NOTIFICATION}/${notification_1.NotificationAPI.URL.LAST}`)
|
|
135
155
|
.query({ client: CLIENT_ID })
|
|
136
156
|
.reply(http_status_codes_1.StatusCodes.OK, {});
|
|
157
|
+
(0, nock_1.default)(MOCK_BACKEND.rest)
|
|
158
|
+
.get(`/api-version`)
|
|
159
|
+
.reply(http_status_codes_1.StatusCodes.OK, {
|
|
160
|
+
supported: [Config_1.MINIMUM_API_VERSION],
|
|
161
|
+
federation: false,
|
|
162
|
+
development: [Config_1.MINIMUM_API_VERSION + 1],
|
|
163
|
+
domain: 'zinfra.io',
|
|
164
|
+
});
|
|
137
165
|
(0, nock_1.default)(MOCK_BACKEND.rest)
|
|
138
166
|
.get(notification_1.NotificationAPI.URL.NOTIFICATION)
|
|
139
167
|
.query({ client: CLIENT_ID, size: 10000 })
|
|
@@ -142,6 +170,16 @@ describe('Account', () => {
|
|
|
142
170
|
(0, nock_1.default)(MOCK_BACKEND.rest)
|
|
143
171
|
.get(client_1.ClientAPI.URL.CLIENTS)
|
|
144
172
|
.reply(http_status_codes_1.StatusCodes.OK, [{ id: CLIENT_ID }]);
|
|
173
|
+
(0, nock_1.default)(MOCK_BACKEND.rest)
|
|
174
|
+
.put(/\/clients\/[\w-]+$/, {
|
|
175
|
+
capabilities: ['legalhold-implicit-consent', 'consumable-notifications'],
|
|
176
|
+
})
|
|
177
|
+
.reply(http_status_codes_1.StatusCodes.OK);
|
|
178
|
+
(0, nock_1.default)(MOCK_BACKEND.rest)
|
|
179
|
+
.put(/\/clients\/[\w-]+$/, {
|
|
180
|
+
capabilities: ['legalhold-implicit-consent'],
|
|
181
|
+
})
|
|
182
|
+
.reply(http_status_codes_1.StatusCodes.OK);
|
|
145
183
|
(0, nock_1.default)(MOCK_BACKEND.rest)
|
|
146
184
|
.get(self_1.SelfAPI.URL.SELF)
|
|
147
185
|
.reply(http_status_codes_1.StatusCodes.OK, {
|
|
@@ -163,6 +201,7 @@ describe('Account', () => {
|
|
|
163
201
|
(0, nock_1.cleanAll)();
|
|
164
202
|
});
|
|
165
203
|
const currentClient = {
|
|
204
|
+
capabilities: [],
|
|
166
205
|
id: CLIENT_ID,
|
|
167
206
|
cookie: '',
|
|
168
207
|
time: '',
|
|
@@ -173,6 +212,9 @@ describe('Account', () => {
|
|
|
173
212
|
describe('"init"', () => {
|
|
174
213
|
it('initializes the Protocol buffers', async () => {
|
|
175
214
|
const account = new Account_1.Account();
|
|
215
|
+
if (account['apiClient']) {
|
|
216
|
+
apiClients.push(account['apiClient']);
|
|
217
|
+
}
|
|
176
218
|
await account['initServices']({ clientType: client_1.ClientType.TEMPORARY, userId: '' });
|
|
177
219
|
expect(account.service.conversation).toBeDefined();
|
|
178
220
|
const message = protocol_messaging_1.GenericMessage.create({
|
|
@@ -185,6 +227,7 @@ describe('Account', () => {
|
|
|
185
227
|
describe('"login"', () => {
|
|
186
228
|
it('logs in with correct credentials', async () => {
|
|
187
229
|
const apiClient = new api_client_1.APIClient({ urls: MOCK_BACKEND });
|
|
230
|
+
apiClients.push(apiClient);
|
|
188
231
|
const account = new Account_1.Account(apiClient);
|
|
189
232
|
await account['initServices']({ clientType: client_1.ClientType.TEMPORARY, userId: '' });
|
|
190
233
|
const { clientType, userId } = await account.login({
|
|
@@ -197,6 +240,7 @@ describe('Account', () => {
|
|
|
197
240
|
});
|
|
198
241
|
it('does not log in with incorrect credentials', async () => {
|
|
199
242
|
const apiClient = new api_client_1.APIClient({ urls: MOCK_BACKEND });
|
|
243
|
+
apiClients.push(apiClient);
|
|
200
244
|
const account = new Account_1.Account(apiClient);
|
|
201
245
|
let backendError;
|
|
202
246
|
await account['initServices']({ clientType: client_1.ClientType.TEMPORARY, userId: '' });
|
|
@@ -218,35 +262,9 @@ describe('Account', () => {
|
|
|
218
262
|
}
|
|
219
263
|
});
|
|
220
264
|
});
|
|
221
|
-
it('emits text messages', () => {
|
|
222
|
-
return new Promise(async (resolve) => {
|
|
223
|
-
const { account, apiClient } = await createAccount();
|
|
224
|
-
await account.login({
|
|
225
|
-
clientType: client_1.ClientType.TEMPORARY,
|
|
226
|
-
email: 'hello@example.com',
|
|
227
|
-
password: 'my-secret',
|
|
228
|
-
});
|
|
229
|
-
account['currentClient'] = currentClient;
|
|
230
|
-
jest.spyOn(apiClient, 'connect').mockImplementation();
|
|
231
|
-
jest.spyOn(account.service.notification, 'handleEvent').mockReturnValue({
|
|
232
|
-
status: 'handled',
|
|
233
|
-
payload: {
|
|
234
|
-
event: { type: event_1.CONVERSATION_EVENT.OTR_MESSAGE_ADD },
|
|
235
|
-
},
|
|
236
|
-
});
|
|
237
|
-
const kill = account.listen({
|
|
238
|
-
onEvent: ({ event }) => {
|
|
239
|
-
expect(event.type).toBe(event_1.CONVERSATION_EVENT.OTR_MESSAGE_ADD);
|
|
240
|
-
resolve();
|
|
241
|
-
},
|
|
242
|
-
});
|
|
243
|
-
apiClient.transport.ws.emit(tcp_1.WebSocketClient.TOPIC.ON_MESSAGE, { payload: [{}] });
|
|
244
|
-
kill();
|
|
245
|
-
});
|
|
246
|
-
});
|
|
247
265
|
describe('Websocket connection', () => {
|
|
248
|
-
let server;
|
|
249
266
|
let dependencies;
|
|
267
|
+
let server;
|
|
250
268
|
const mockNotifications = (size) => {
|
|
251
269
|
const notifications = Array.from(new Array(size)).map(() => ({
|
|
252
270
|
id: (0, uuid_1.v4)(),
|
|
@@ -267,12 +285,12 @@ describe('Account', () => {
|
|
|
267
285
|
return callback();
|
|
268
286
|
};
|
|
269
287
|
};
|
|
270
|
-
|
|
271
|
-
server = new jest_websocket_mock_1.WS(`${MOCK_BACKEND.ws}/await?access_token=${accessTokenData.access_token}`);
|
|
288
|
+
beforeAll(() => {
|
|
272
289
|
// Forces the reconnecting websocket not to automatically reconnect (to avoid infinitely hanging tests)
|
|
273
290
|
ReconnectingWebsocket_1.ReconnectingWebsocket['RECONNECTING_OPTIONS'].maxRetries = 0;
|
|
274
291
|
});
|
|
275
292
|
beforeEach(async () => {
|
|
293
|
+
server = new jest_websocket_mock_1.WS(websocketServerAddress); // isolate per test
|
|
276
294
|
dependencies = await createAccount();
|
|
277
295
|
const { account } = dependencies;
|
|
278
296
|
await account.login({
|
|
@@ -287,46 +305,48 @@ describe('Account', () => {
|
|
|
287
305
|
jest
|
|
288
306
|
.spyOn(dependencies.account.service.notification['database'], 'getLastNotificationId')
|
|
289
307
|
.mockResolvedValue('0');
|
|
308
|
+
await account.useAPIVersion(Config_1.MINIMUM_API_VERSION, Config_1.MINIMUM_API_VERSION);
|
|
309
|
+
jest
|
|
310
|
+
.spyOn(dependencies.apiClient.transport.ws, 'buildWebSocketUrl')
|
|
311
|
+
.mockResolvedValue(websocketServerAddress);
|
|
312
|
+
jest.spyOn(dependencies.account, 'getNotificationEventTime').mockReturnValue('2025-10-01T00:00:00Z');
|
|
290
313
|
});
|
|
291
314
|
afterEach(() => {
|
|
292
|
-
server.close();
|
|
315
|
+
server.close(); // ensure server shutdown
|
|
316
|
+
jest_websocket_mock_1.WS.clean();
|
|
293
317
|
});
|
|
294
318
|
describe('listen', () => {
|
|
295
|
-
it('
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
Account_1.ConnectionState.PROCESSING_NOTIFICATIONS,
|
|
300
|
-
Account_1.ConnectionState.LIVE,
|
|
301
|
-
Account_1.ConnectionState.CLOSED,
|
|
302
|
-
];
|
|
303
|
-
const disconnect = dependencies.account.listen({
|
|
304
|
-
onConnectionStateChanged: state => {
|
|
305
|
-
expect(state).toBe(expectedConnectionStates.splice(0, 1)[0]);
|
|
306
|
-
switch (state) {
|
|
307
|
-
case Account_1.ConnectionState.LIVE:
|
|
308
|
-
// We socket is live we disconnect before ending the test
|
|
309
|
-
disconnect();
|
|
310
|
-
break;
|
|
311
|
-
case Account_1.ConnectionState.CLOSED:
|
|
312
|
-
resolve();
|
|
313
|
-
}
|
|
314
|
-
},
|
|
315
|
-
});
|
|
316
|
-
});
|
|
317
|
-
});
|
|
318
|
-
it('processes notification stream upon connection', async () => {
|
|
319
|
+
it('connects to websocket after the notification stream has been processed', async () => {
|
|
320
|
+
jest
|
|
321
|
+
.spyOn(dependencies.account, 'getClientCapabilities')
|
|
322
|
+
.mockReturnValue([client_1.ClientCapability.LEGAL_HOLD_IMPLICIT_CONSENT]);
|
|
319
323
|
return new Promise(async (resolve) => {
|
|
320
324
|
const nbNotifications = 10;
|
|
321
325
|
const onNotificationStreamProgress = jest.fn();
|
|
322
|
-
const onEvent = jest.fn();
|
|
326
|
+
const onEvent = jest.fn().mockImplementation(() => { });
|
|
323
327
|
mockNotifications(nbNotifications);
|
|
324
|
-
|
|
325
|
-
|
|
328
|
+
await dependencies.account.listen({
|
|
329
|
+
useLegacy: false,
|
|
330
|
+
onConnectionStateChanged: callWhen(Account_1.ConnectionState.LIVE, async () => {
|
|
326
331
|
expect(onNotificationStreamProgress).toHaveBeenCalledTimes(nbNotifications);
|
|
327
332
|
expect(onEvent).toHaveBeenCalledTimes(nbNotifications);
|
|
328
333
|
expect(onEvent).toHaveBeenCalledWith(expect.any(Object), notification_2.NotificationSource.NOTIFICATION_STREAM);
|
|
329
|
-
|
|
334
|
+
expect(onEvent).not.toHaveBeenCalledWith(expect.any(Object), notification_2.NotificationSource.WEBSOCKET);
|
|
335
|
+
onEvent.mockReset();
|
|
336
|
+
await server.connected;
|
|
337
|
+
jest
|
|
338
|
+
.spyOn(dependencies.account.service.notification, 'handleNotification')
|
|
339
|
+
.mockReturnValue([{ event: { testData: 1 } }]);
|
|
340
|
+
server.send(JSON.stringify({
|
|
341
|
+
type: ConsumableNotification_1.ConsumableEvent.EVENT,
|
|
342
|
+
data: {
|
|
343
|
+
delivery_tag: 1000,
|
|
344
|
+
event: { id: (0, uuid_1.v4)(), payload: [] },
|
|
345
|
+
},
|
|
346
|
+
}));
|
|
347
|
+
await waitFor(() => expect(onEvent).toHaveBeenCalledTimes(1));
|
|
348
|
+
expect(onEvent).not.toHaveBeenCalledWith(expect.any(Object), notification_2.NotificationSource.NOTIFICATION_STREAM);
|
|
349
|
+
expect(onEvent).toHaveBeenCalledWith(expect.any(Object), notification_2.NotificationSource.WEBSOCKET);
|
|
330
350
|
resolve();
|
|
331
351
|
}),
|
|
332
352
|
onEvent: onEvent,
|
|
@@ -334,24 +354,66 @@ describe('Account', () => {
|
|
|
334
354
|
});
|
|
335
355
|
});
|
|
336
356
|
});
|
|
337
|
-
it('
|
|
357
|
+
it('sends information to consumer of the connection state change in order', async () => {
|
|
358
|
+
await new Promise(async (resolve) => {
|
|
359
|
+
mockNotifications(10);
|
|
360
|
+
const onConnectionStateChanged = jest.fn().mockImplementation((state) => {
|
|
361
|
+
switch (state) {
|
|
362
|
+
case Account_1.ConnectionState.LIVE:
|
|
363
|
+
break;
|
|
364
|
+
case Account_1.ConnectionState.CLOSED:
|
|
365
|
+
// Expect all states to have been called in order
|
|
366
|
+
expect(onConnectionStateChanged).toHaveBeenNthCalledWith(1, Account_1.ConnectionState.PROCESSING_NOTIFICATIONS);
|
|
367
|
+
expect(onConnectionStateChanged).toHaveBeenNthCalledWith(2, Account_1.ConnectionState.CONNECTING);
|
|
368
|
+
expect(onConnectionStateChanged).toHaveBeenNthCalledWith(3, Account_1.ConnectionState.LIVE);
|
|
369
|
+
resolve();
|
|
370
|
+
break;
|
|
371
|
+
}
|
|
372
|
+
});
|
|
373
|
+
const disconnect = await dependencies.account.listen({
|
|
374
|
+
useLegacy: false,
|
|
375
|
+
onConnectionStateChanged,
|
|
376
|
+
});
|
|
377
|
+
await waitFor(() => expect(onConnectionStateChanged).toHaveBeenCalledWith(Account_1.ConnectionState.LIVE));
|
|
378
|
+
disconnect();
|
|
379
|
+
});
|
|
380
|
+
});
|
|
381
|
+
it('warns consumer of the connection close', async () => {
|
|
382
|
+
await new Promise(async (resolve) => {
|
|
383
|
+
mockNotifications(10);
|
|
384
|
+
const onConnectionStateChanged = jest.fn().mockImplementation((state) => {
|
|
385
|
+
switch (state) {
|
|
386
|
+
case Account_1.ConnectionState.LIVE:
|
|
387
|
+
break;
|
|
388
|
+
case Account_1.ConnectionState.CLOSED:
|
|
389
|
+
// Expect all states to have been called in order
|
|
390
|
+
expect(onConnectionStateChanged).toHaveBeenNthCalledWith(1, Account_1.ConnectionState.PROCESSING_NOTIFICATIONS);
|
|
391
|
+
expect(onConnectionStateChanged).toHaveBeenNthCalledWith(2, Account_1.ConnectionState.CONNECTING);
|
|
392
|
+
expect(onConnectionStateChanged).toHaveBeenNthCalledWith(3, Account_1.ConnectionState.CLOSED);
|
|
393
|
+
resolve();
|
|
394
|
+
break;
|
|
395
|
+
}
|
|
396
|
+
});
|
|
397
|
+
const disconnect = await dependencies.account.listen({
|
|
398
|
+
useLegacy: false,
|
|
399
|
+
onConnectionStateChanged,
|
|
400
|
+
});
|
|
401
|
+
await waitFor(() => expect(onConnectionStateChanged).toHaveBeenCalledWith(Account_1.ConnectionState.PROCESSING_NOTIFICATIONS));
|
|
402
|
+
disconnect();
|
|
403
|
+
});
|
|
404
|
+
});
|
|
405
|
+
it('processes notification stream upon connection', async () => {
|
|
338
406
|
return new Promise(async (resolve) => {
|
|
339
407
|
const nbNotifications = 10;
|
|
340
408
|
const onNotificationStreamProgress = jest.fn();
|
|
341
409
|
const onEvent = jest.fn();
|
|
342
410
|
mockNotifications(nbNotifications);
|
|
343
|
-
|
|
344
|
-
|
|
411
|
+
await dependencies.account.listen({
|
|
412
|
+
useLegacy: false,
|
|
413
|
+
onConnectionStateChanged: callWhen(Account_1.ConnectionState.LIVE, () => {
|
|
345
414
|
expect(onNotificationStreamProgress).toHaveBeenCalledTimes(nbNotifications);
|
|
346
415
|
expect(onEvent).toHaveBeenCalledTimes(nbNotifications);
|
|
347
416
|
expect(onEvent).toHaveBeenCalledWith(expect.any(Object), notification_2.NotificationSource.NOTIFICATION_STREAM);
|
|
348
|
-
expect(onEvent).not.toHaveBeenCalledWith(expect.any(Object), notification_2.NotificationSource.WEBSOCKET);
|
|
349
|
-
onEvent.mockReset();
|
|
350
|
-
server.send(JSON.stringify({ id: (0, uuid_1.v4)(), payload: [{}] }));
|
|
351
|
-
await waitFor(() => expect(onEvent).toHaveBeenCalledTimes(1));
|
|
352
|
-
expect(onEvent).not.toHaveBeenCalledWith(expect.any(Object), notification_2.NotificationSource.NOTIFICATION_STREAM);
|
|
353
|
-
expect(onEvent).toHaveBeenCalledWith(expect.any(Object), notification_2.NotificationSource.WEBSOCKET);
|
|
354
|
-
disconnect();
|
|
355
417
|
resolve();
|
|
356
418
|
}),
|
|
357
419
|
onEvent: onEvent,
|
|
@@ -359,63 +421,41 @@ describe('Account', () => {
|
|
|
359
421
|
});
|
|
360
422
|
});
|
|
361
423
|
});
|
|
362
|
-
it('
|
|
424
|
+
it('does stop processing messages if websocket connection is aborted', async () => {
|
|
425
|
+
jest
|
|
426
|
+
.spyOn(dependencies.account, 'getClientCapabilities')
|
|
427
|
+
.mockReturnValue([client_1.ClientCapability.LEGAL_HOLD_IMPLICIT_CONSENT, client_1.ClientCapability.CONSUMABLE_NOTIFICATIONS]);
|
|
363
428
|
const nbNotifications = 10;
|
|
364
429
|
const onNotificationStreamProgress = jest.fn();
|
|
365
|
-
const onEvent = jest
|
|
366
|
-
mockNotifications(nbNotifications);
|
|
367
|
-
return new Promise(async (resolve) => {
|
|
368
|
-
const disconnect = dependencies.account.listen({
|
|
369
|
-
onConnectionStateChanged: async (state) => {
|
|
370
|
-
switch (state) {
|
|
371
|
-
case Account_1.ConnectionState.PROCESSING_NOTIFICATIONS:
|
|
372
|
-
// sending a message as soon as the notificaiton stream starts to process
|
|
373
|
-
// This message should only be forwarded once the notification stream is fully processed
|
|
374
|
-
server.send(JSON.stringify({ id: (0, uuid_1.v4)(), payload: [{}] }));
|
|
375
|
-
break;
|
|
376
|
-
case Account_1.ConnectionState.LIVE:
|
|
377
|
-
expect(onNotificationStreamProgress).toHaveBeenCalledTimes(nbNotifications);
|
|
378
|
-
expect(onEvent).toHaveBeenCalledTimes(nbNotifications);
|
|
379
|
-
expect(onEvent).toHaveBeenCalledWith(expect.any(Object), notification_2.NotificationSource.NOTIFICATION_STREAM);
|
|
380
|
-
expect(onEvent).not.toHaveBeenCalledWith(expect.any(Object), notification_2.NotificationSource.WEBSOCKET);
|
|
381
|
-
onEvent.mockReset();
|
|
382
|
-
await waitFor(() => expect(onEvent).toHaveBeenCalledTimes(1));
|
|
383
|
-
expect(onEvent).not.toHaveBeenCalledWith(expect.any(Object), notification_2.NotificationSource.NOTIFICATION_STREAM);
|
|
384
|
-
expect(onEvent).toHaveBeenCalledWith(expect.any(Object), notification_2.NotificationSource.WEBSOCKET);
|
|
385
|
-
disconnect();
|
|
386
|
-
resolve();
|
|
387
|
-
}
|
|
388
|
-
},
|
|
389
|
-
onEvent: onEvent,
|
|
390
|
-
onNotificationStreamProgress: onNotificationStreamProgress,
|
|
391
|
-
});
|
|
392
|
-
});
|
|
393
|
-
});
|
|
394
|
-
it('does not unlock the websocket if the connection was aborted', async () => {
|
|
395
|
-
const nbNotifications = 10;
|
|
396
|
-
const onNotificationStreamProgress = jest
|
|
430
|
+
const onEvent = jest
|
|
397
431
|
.fn()
|
|
398
432
|
.mockImplementationOnce(() => { })
|
|
399
|
-
.mockImplementationOnce(() =>
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
433
|
+
.mockImplementationOnce(() => {
|
|
434
|
+
// abort websocket connection after the second notification is processeed
|
|
435
|
+
server.close({ reason: 'Aborted by test', code: 2000, wasClean: true });
|
|
436
|
+
});
|
|
437
|
+
return new Promise(async (resolve) => {
|
|
438
|
+
return dependencies.account.listen({
|
|
439
|
+
useLegacy: false,
|
|
404
440
|
onConnectionStateChanged: async (state) => {
|
|
405
441
|
switch (state) {
|
|
406
|
-
case Account_1.ConnectionState.
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
442
|
+
case Account_1.ConnectionState.CONNECTING:
|
|
443
|
+
await server.connected;
|
|
444
|
+
for (let i = 0; i < nbNotifications; i++) {
|
|
445
|
+
server.send(JSON.stringify({
|
|
446
|
+
type: ConsumableNotification_1.ConsumableEvent.EVENT,
|
|
447
|
+
data: {
|
|
448
|
+
delivery_tag: 1000,
|
|
449
|
+
event: { id: (0, uuid_1.v4)(), payload: [{ domain: 'zinfra.io', type: 'federation.delete' }] },
|
|
450
|
+
},
|
|
451
|
+
}));
|
|
452
|
+
}
|
|
410
453
|
break;
|
|
411
|
-
case Account_1.ConnectionState.LIVE:
|
|
412
|
-
reject(new Error());
|
|
413
|
-
throw new Error('should not go to `live` state');
|
|
414
454
|
case Account_1.ConnectionState.CLOSED:
|
|
415
455
|
expect(onNotificationStreamProgress).toHaveBeenCalledTimes(2);
|
|
416
456
|
expect(onEvent).toHaveBeenCalledTimes(2);
|
|
417
|
-
expect(onEvent).toHaveBeenCalledWith(
|
|
418
|
-
expect(dependencies.account.service.notification.handleNotification).
|
|
457
|
+
expect(onEvent).toHaveBeenCalledWith({ domain: 'zinfra.io', type: 'federation.delete' }, notification_2.NotificationSource.WEBSOCKET);
|
|
458
|
+
expect(dependencies.account.service.notification.handleNotification).toHaveBeenCalledTimes(2);
|
|
419
459
|
resolve();
|
|
420
460
|
}
|
|
421
461
|
},
|
|
@@ -424,35 +464,6 @@ describe('Account', () => {
|
|
|
424
464
|
});
|
|
425
465
|
});
|
|
426
466
|
});
|
|
427
|
-
it('cancels notification stream process if socket is disconnected', () => {
|
|
428
|
-
const nbNotifications = 10;
|
|
429
|
-
const onNotificationStreamProgress = jest.fn();
|
|
430
|
-
const onEvent = jest
|
|
431
|
-
.fn()
|
|
432
|
-
.mockImplementationOnce(() => { })
|
|
433
|
-
.mockImplementationOnce(() => {
|
|
434
|
-
// on second message, we kill the websocket
|
|
435
|
-
server.close();
|
|
436
|
-
});
|
|
437
|
-
mockNotifications(nbNotifications);
|
|
438
|
-
return new Promise(resolve => {
|
|
439
|
-
dependencies.account.listen({
|
|
440
|
-
onConnectionStateChanged: callWhen(Account_1.ConnectionState.CLOSED, () => {
|
|
441
|
-
try {
|
|
442
|
-
expect(onNotificationStreamProgress).toHaveBeenCalledTimes(1);
|
|
443
|
-
expect(onEvent).toHaveBeenCalledTimes(2);
|
|
444
|
-
expect(onEvent).toHaveBeenCalledWith(expect.any(Object), notification_2.NotificationSource.NOTIFICATION_STREAM);
|
|
445
|
-
}
|
|
446
|
-
catch (error) {
|
|
447
|
-
throw error;
|
|
448
|
-
}
|
|
449
|
-
resolve();
|
|
450
|
-
}, 1),
|
|
451
|
-
onEvent: onEvent,
|
|
452
|
-
onNotificationStreamProgress: onNotificationStreamProgress,
|
|
453
|
-
});
|
|
454
|
-
});
|
|
455
|
-
});
|
|
456
467
|
});
|
|
457
468
|
});
|
|
458
469
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AvailabilityType.d.ts","sourceRoot":"","sources":["../../src/broadcast/AvailabilityType.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,YAAY,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"AvailabilityType.d.ts","sourceRoot":"","sources":["../../src/broadcast/AvailabilityType.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,YAAY,EAAC,MAAM,6BAA6B,CAAC;AAEzD,MAAM,MAAM,gBAAgB,GAAG,YAAY,CAAC,IAAI,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { GenericMessage } from '@pydio/protocol-messaging';
|
|
2
1
|
import { MessageSendingStatus, QualifiedUserClients } from '@wireapp/api-client/lib/conversation';
|
|
3
2
|
import { APIClient } from '@wireapp/api-client';
|
|
3
|
+
import { GenericMessage } from '@wireapp/protocol-messaging';
|
|
4
4
|
import { ProteusService } from '../messagingProtocols/proteus';
|
|
5
5
|
export declare class BroadcastService {
|
|
6
6
|
private readonly apiClient;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BroadcastService.d.ts","sourceRoot":"","sources":["../../src/broadcast/BroadcastService.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"BroadcastService.d.ts","sourceRoot":"","sources":["../../src/broadcast/BroadcastService.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,oBAAoB,EAAE,oBAAoB,EAAC,MAAM,sCAAsC,CAAC;AAEhG,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAC,cAAc,EAAC,MAAM,6BAA6B,CAAC;AAK3D,OAAO,EAAC,cAAc,EAAC,MAAM,+BAA+B,CAAC;AAE7D,qBAAa,gBAAgB;IAIzB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,cAAc;IAJjC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAiB;gBAG7B,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,cAAc;IAKpC,uBAAuB,CAClC,cAAc,EAAE,cAAc,EAC9B,UAAU,EAAE,oBAAoB,EAChC,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,oBAAoB,KAAK,IAAI,GAAG,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;CAY3F"}
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
exports.BroadcastService = void 0;
|
|
22
|
-
const protocol_messaging_1 = require("@
|
|
22
|
+
const protocol_messaging_1 = require("@wireapp/protocol-messaging");
|
|
23
23
|
const messageSender_1 = require("../conversation/message/messageSender");
|
|
24
24
|
const MessageService_1 = require("../conversation/message/MessageService");
|
|
25
25
|
const UserClientsUtil_1 = require("../conversation/message/UserClientsUtil");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LoginData } from '@wireapp/api-client/lib/auth/';
|
|
2
|
-
import { RegisteredClient } from '@wireapp/api-client/lib/client/';
|
|
2
|
+
import { ClientCapabilityData, RegisteredClient } from '@wireapp/api-client/lib/client/';
|
|
3
3
|
import { APIClient } from '@wireapp/api-client';
|
|
4
4
|
import { CRUDEngine } from '@wireapp/store-engine';
|
|
5
5
|
import type { ProteusService } from '../messagingProtocols/proteus';
|
|
@@ -45,13 +45,14 @@ export declare class ClientService {
|
|
|
45
45
|
*
|
|
46
46
|
* @return the loaded client or undefined
|
|
47
47
|
*/
|
|
48
|
-
loadClient(): Promise<
|
|
48
|
+
loadClient(): Promise<MetaClient | undefined>;
|
|
49
49
|
private createLocalClient;
|
|
50
|
+
putClientCapabilities(clientId: string, capabilities: ClientCapabilityData): Promise<void>;
|
|
50
51
|
/**
|
|
51
52
|
* Will download all the clients of the self user (excluding the current client) and will store them in the database
|
|
52
53
|
* @param currentClient - the id of the current client (to be excluded from the list)
|
|
53
54
|
*/
|
|
54
55
|
synchronizeClients(currentClient: string): Promise<MetaClient[]>;
|
|
55
|
-
register(loginData: LoginData, clientInfo: ClientInfo, { prekeys, lastPrekey }: InitialPrekeys): Promise<RegisteredClient>;
|
|
56
|
+
register(loginData: LoginData, clientInfo: ClientInfo, { prekeys, lastPrekey }: InitialPrekeys, useLegacyNotificationStream?: boolean): Promise<RegisteredClient>;
|
|
56
57
|
}
|
|
57
58
|
//# sourceMappingURL=ClientService.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClientService.d.ts","sourceRoot":"","sources":["../../src/client/ClientService.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,SAAS,EAAC,MAAM,+BAA+B,CAAC;AACxD,OAAO,
|
|
1
|
+
{"version":3,"file":"ClientService.d.ts","sourceRoot":"","sources":["../../src/client/ClientService.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,SAAS,EAAC,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAEL,oBAAoB,EAGpB,gBAAgB,EACjB,MAAM,iCAAiC,CAAC;AAKzC,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AAEjD,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAC,cAAc,EAAC,MAAM,2DAA2D,CAAC;AAEzF,OAAO,EAAC,UAAU,EAAoD,MAAM,IAAI,CAAC;AAEjF,MAAM,WAAW,UAAW,SAAQ,gBAAgB;IAClD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE;QACJ,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,eAAe,CAAC,EAAE,OAAO,CAAC;QAC1B,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;CACH;AAED,qBAAa,aAAa;IAMtB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,WAAW;IAP9B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA2B;IACpD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA0B;IAClD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgD;gBAGpD,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,cAAc,EAC9B,WAAW,EAAE,UAAU;IAMnC,UAAU,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAIhD;;;;;;;OAOG;IACU,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAMhF;;;OAGG;IACU,iBAAiB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;YAepD,cAAc;IAQ5B;;;;;;;OAOG;IACU,UAAU,IAAI,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAyB1D,OAAO,CAAC,iBAAiB;IAIlB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAIjG;;;OAGG;IACU,kBAAkB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAUhE,QAAQ,CACnB,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,UAAU,EACtB,EAAC,OAAO,EAAE,UAAU,EAAC,EAAE,cAAc,EACrC,2BAA2B,GAAE,OAAc,GAC1C,OAAO,CAAC,gBAAgB,CAAC;CAkC7B"}
|
|
@@ -64,9 +64,16 @@ class ClientService {
|
|
|
64
64
|
async deleteLocalClient(password) {
|
|
65
65
|
const localClientId = this.apiClient.context?.clientId;
|
|
66
66
|
if (!localClientId) {
|
|
67
|
-
|
|
67
|
+
// No client in context -> there's nothing to delete on backend, just drop local state
|
|
68
|
+
this.logger.warn('No local client id in context; deleting local client data from DB only.');
|
|
69
|
+
return this.database.deleteLocalClient();
|
|
70
|
+
}
|
|
71
|
+
try {
|
|
72
|
+
await this.backend.deleteClient(localClientId, password);
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
this.logger.warn('Failed to delete client on backend', error);
|
|
68
76
|
}
|
|
69
|
-
await this.backend.deleteClient(localClientId, password);
|
|
70
77
|
return this.database.deleteLocalClient();
|
|
71
78
|
}
|
|
72
79
|
async getLocalClient() {
|
|
@@ -98,7 +105,7 @@ class ClientService {
|
|
|
98
105
|
const notFoundOnBackend = axios_1.default.isAxiosError(error) ? error.response?.status === http_status_codes_1.StatusCodes.NOT_FOUND : false;
|
|
99
106
|
if (notFoundOnBackend && this.storeEngine) {
|
|
100
107
|
const shouldDeleteWholeDatabase = loadedClient.type === client_1.ClientType.TEMPORARY;
|
|
101
|
-
await this.proteusService.wipe(
|
|
108
|
+
await this.proteusService.wipe();
|
|
102
109
|
if (shouldDeleteWholeDatabase) {
|
|
103
110
|
await this.storeEngine.clearTables();
|
|
104
111
|
}
|
|
@@ -111,6 +118,9 @@ class ClientService {
|
|
|
111
118
|
createLocalClient(client, domain) {
|
|
112
119
|
return this.database.createLocalClient(client, domain);
|
|
113
120
|
}
|
|
121
|
+
putClientCapabilities(clientId, capabilities) {
|
|
122
|
+
return this.backend.putClient(clientId, capabilities);
|
|
123
|
+
}
|
|
114
124
|
/**
|
|
115
125
|
* Will download all the clients of the self user (excluding the current client) and will store them in the database
|
|
116
126
|
* @param currentClient - the id of the current client (to be excluded from the list)
|
|
@@ -121,16 +131,20 @@ class ClientService {
|
|
|
121
131
|
return this.database.createClientList({ id: this.apiClient.context.userId, domain: this.apiClient.context.domain ?? '' }, filteredClients);
|
|
122
132
|
}
|
|
123
133
|
// TODO: Split functionality into "create" and "register" client
|
|
124
|
-
async register(loginData, clientInfo, { prekeys, lastPrekey }) {
|
|
134
|
+
async register(loginData, clientInfo, { prekeys, lastPrekey }, useLegacyNotificationStream = true) {
|
|
125
135
|
if (!this.apiClient.context) {
|
|
126
136
|
throw new Error('Context is not set.');
|
|
127
137
|
}
|
|
128
138
|
if (loginData.clientType === client_1.ClientType.NONE) {
|
|
129
139
|
throw new Error(`Can't register client of type "${client_1.ClientType.NONE}"`);
|
|
130
140
|
}
|
|
141
|
+
const capabilities = [client_1.ClientCapability.LEGAL_HOLD_IMPLICIT_CONSENT];
|
|
142
|
+
if (!useLegacyNotificationStream) {
|
|
143
|
+
capabilities.push(client_1.ClientCapability.CONSUMABLE_NOTIFICATIONS);
|
|
144
|
+
}
|
|
131
145
|
const newClient = {
|
|
132
146
|
class: clientInfo.classification,
|
|
133
|
-
capabilities
|
|
147
|
+
capabilities,
|
|
134
148
|
cookie: clientInfo.cookieLabel,
|
|
135
149
|
label: clientInfo.label,
|
|
136
150
|
lastkey: lastPrekey,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbortReason.d.ts","sourceRoot":"","sources":["../../src/conversation/AbortReason.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,KAAK,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"AbortReason.d.ts","sourceRoot":"","sources":["../../src/conversation/AbortReason.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,KAAK,EAAC,MAAM,6BAA6B,CAAC;AAElD,MAAM,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC"}
|