@wireapp/core 46.46.6-beta.10.d7a6c4c53 → 46.46.6-beta.14.f6fd03fe6
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 +51 -168
- package/lib/Account.d.ts.map +1 -1
- package/lib/Account.js +127 -517
- package/lib/Account.test.js +147 -158
- 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 +3 -4
- package/lib/client/ClientService.d.ts.map +1 -1
- package/lib/client/ClientService.js +5 -19
- package/lib/conversation/AbortReason.d.ts +1 -1
- package/lib/conversation/AbortReason.d.ts.map +1 -1
- package/lib/conversation/AssetService/AssetService.d.ts +30 -12
- package/lib/conversation/AssetService/AssetService.d.ts.map +1 -1
- package/lib/conversation/AssetService/AssetService.js +10 -1
- package/lib/conversation/AssetService/AssetService.test.js +3 -8
- 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 +14 -98
- package/lib/conversation/ConversationService/ConversationService.d.ts.map +1 -1
- package/lib/conversation/ConversationService/ConversationService.js +101 -314
- package/lib/conversation/ConversationService/ConversationService.test.js +47 -441
- package/lib/conversation/ConversationService/ConversationService.types.d.ts +4 -5
- 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 +3 -6
- package/lib/conversation/SubconversationService/SubconversationService.d.ts.map +1 -1
- package/lib/conversation/SubconversationService/SubconversationService.js +11 -158
- package/lib/conversation/SubconversationService/SubconversationService.test.js +2 -8
- 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 +1 -7
- 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 +0 -9
- 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 +1 -2
- 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 +11 -13
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.test.js +16 -21
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceInternal.d.ts +3 -9
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceInternal.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceInternal.js +12 -31
- package/lib/messagingProtocols/mls/E2EIdentityService/Helper/index.d.ts +0 -6
- package/lib/messagingProtocols/mls/E2EIdentityService/Helper/index.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/Helper/index.js +1 -19
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingMessagesQueue/IncomingMesssagesQueue.d.ts +4 -0
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingMessagesQueue/IncomingMesssagesQueue.d.ts.map +1 -0
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingMessagesQueue/IncomingMesssagesQueue.js +69 -0
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingMessagesQueue/index.d.ts +2 -0
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/{IncomingProposalsQueue → IncomingMessagesQueue}/index.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/{IncomingProposalsQueue → IncomingMessagesQueue}/index.js +1 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/index.d.ts +1 -0
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/index.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/index.js +1 -0
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.js +14 -23
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.test.d.ts +2 -0
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.test.d.ts.map +1 -0
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.test.js +98 -0
- package/lib/messagingProtocols/mls/EventHandler/events/welcomeMessage/welcomeMessage.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/EventHandler/events/welcomeMessage/welcomeMessage.js +2 -5
- package/lib/messagingProtocols/mls/EventHandler/events/welcomeMessage/welcomeMessage.test.js +3 -13
- package/lib/messagingProtocols/mls/MLSService/CoreCryptoMLSError.d.ts +2 -38
- package/lib/messagingProtocols/mls/MLSService/CoreCryptoMLSError.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/MLSService/CoreCryptoMLSError.js +6 -41
- package/lib/messagingProtocols/mls/MLSService/MLSService.d.ts +34 -38
- package/lib/messagingProtocols/mls/MLSService/MLSService.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/MLSService/MLSService.js +208 -267
- package/lib/messagingProtocols/mls/MLSService/MLSService.test.js +160 -157
- 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/types.d.ts +8 -0
- 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 +1 -7
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/CoreCryptoWrapper.d.ts +15 -8
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/CoreCryptoWrapper.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/CoreCryptoWrapper.js +62 -97
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoClient.types.d.ts +6 -0
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoClient.types.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/DecryptionErrorGenerator/DecryptionErrorGenerator.d.ts +6 -1
- package/lib/messagingProtocols/proteus/ProteusService/DecryptionErrorGenerator/DecryptionErrorGenerator.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/DecryptionErrorGenerator/DecryptionErrorGenerator.js +22 -19
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.d.ts +3 -5
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.js +24 -11
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.mocks.d.ts +0 -1
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.mocks.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.mocks.js +2 -11
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.test.js +9 -13
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.types.d.ts +2 -3
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.types.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/WithMockedGenerics.test.js +4 -11
- package/lib/messagingProtocols/proteus/ProteusService/cryptoMigrationStateStore.d.ts +4 -0
- package/lib/messagingProtocols/proteus/ProteusService/cryptoMigrationStateStore.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/cryptoMigrationStateStore.js +5 -0
- package/lib/messagingProtocols/proteus/ProteusService/identityClearer.d.ts +1 -2
- package/lib/messagingProtocols/proteus/ProteusService/identityClearer.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/identityClearer.js +2 -8
- package/lib/messagingProtocols/proteus/Utility/SessionHandler/SessionHandler.test.js +0 -4
- 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 +6 -20
- package/lib/notification/NotificationService.d.ts.map +1 -1
- package/lib/notification/NotificationService.js +14 -23
- package/lib/notification/NotificationService.test.js +0 -8
- package/lib/secretStore/secretKeyGenerator.d.ts +0 -1
- package/lib/secretStore/secretKeyGenerator.d.ts.map +1 -1
- package/lib/secretStore/secretKeyGenerator.js +1 -3
- package/lib/self/SelfService.d.ts +2 -2
- package/lib/self/SelfService.d.ts.map +1 -1
- package/lib/self/SelfService.test.js +2 -5
- package/lib/team/TeamService.d.ts +2 -5
- package/lib/team/TeamService.d.ts.map +1 -1
- package/lib/team/TeamService.js +2 -12
- 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/IncomingProposalsQueue/IncomingProposalsQueue.d.ts +0 -7
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingProposalsQueue/IncomingProposalsQueue.d.ts.map +0 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingProposalsQueue/IncomingProposalsQueue.js +0 -48
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingProposalsQueue/index.d.ts +0 -2
- package/lib/messagingProtocols/mls/MLSService/CoreCryptoMLSError.test.d.ts +0 -2
- package/lib/messagingProtocols/mls/MLSService/CoreCryptoMLSError.test.d.ts.map +0 -1
- package/lib/messagingProtocols/mls/MLSService/CoreCryptoMLSError.test.js +0 -124
- package/lib/messagingProtocols/mls/recovery/MlsErrorMapper.d.ts +0 -78
- package/lib/messagingProtocols/mls/recovery/MlsErrorMapper.d.ts.map +0 -1
- package/lib/messagingProtocols/mls/recovery/MlsErrorMapper.js +0 -173
- package/lib/messagingProtocols/mls/recovery/MlsErrorMapper.test.d.ts +0 -2
- package/lib/messagingProtocols/mls/recovery/MlsErrorMapper.test.d.ts.map +0 -1
- package/lib/messagingProtocols/mls/recovery/MlsErrorMapper.test.js +0 -117
- package/lib/messagingProtocols/mls/recovery/MlsRecoveryOrchestrator.d.ts +0 -167
- package/lib/messagingProtocols/mls/recovery/MlsRecoveryOrchestrator.d.ts.map +0 -1
- package/lib/messagingProtocols/mls/recovery/MlsRecoveryOrchestrator.js +0 -317
- package/lib/messagingProtocols/mls/recovery/MlsRecoveryOrchestrator.test.d.ts +0 -2
- package/lib/messagingProtocols/mls/recovery/MlsRecoveryOrchestrator.test.d.ts.map +0 -1
- package/lib/messagingProtocols/mls/recovery/MlsRecoveryOrchestrator.test.js +0 -248
- package/lib/messagingProtocols/mls/recovery/index.d.ts +0 -5
- package/lib/messagingProtocols/mls/recovery/index.d.ts.map +0 -1
- package/lib/messagingProtocols/mls/recovery/index.js +0 -28
- package/lib/test/StoreHelper.d.ts +0 -2
- package/lib/test/StoreHelper.d.ts.map +0 -1
- package/lib/test/StoreHelper.js +0 -27
package/lib/Account.test.js
CHANGED
|
@@ -41,14 +41,15 @@ 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");
|
|
44
45
|
const auth_1 = require("@wireapp/api-client/lib/auth");
|
|
45
46
|
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");
|
|
48
49
|
const http_1 = require("@wireapp/api-client/lib/http");
|
|
49
50
|
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");
|
|
52
53
|
const ReconnectingWebsocket_1 = require("@wireapp/api-client/lib/tcp/ReconnectingWebsocket");
|
|
53
54
|
const http_status_codes_1 = require("http-status-codes");
|
|
54
55
|
const jest_websocket_mock_1 = require("jest-websocket-mock");
|
|
@@ -56,20 +57,6 @@ const nock_1 = __importStar(require("nock"));
|
|
|
56
57
|
const uuid_1 = require("uuid");
|
|
57
58
|
const api_client_1 = require("@wireapp/api-client");
|
|
58
59
|
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
|
-
});
|
|
73
60
|
const Account_1 = require("./Account");
|
|
74
61
|
const notification_2 = require("./notification");
|
|
75
62
|
const BASE_URL = 'mock-backend.wire.com';
|
|
@@ -78,10 +65,8 @@ const MOCK_BACKEND = {
|
|
|
78
65
|
rest: `https://${BASE_URL}`,
|
|
79
66
|
ws: `wss://${BASE_URL}`,
|
|
80
67
|
};
|
|
81
|
-
const apiClients = [];
|
|
82
68
|
async function createAccount() {
|
|
83
69
|
const apiClient = new api_client_1.APIClient({ urls: MOCK_BACKEND });
|
|
84
|
-
apiClients.push(apiClient);
|
|
85
70
|
const account = new Account_1.Account(apiClient);
|
|
86
71
|
await account['initServices']({
|
|
87
72
|
clientType: client_1.ClientType.TEMPORARY,
|
|
@@ -112,9 +97,6 @@ const waitFor = (assertion) => {
|
|
|
112
97
|
/* eslint-disable jest/no-conditional-expect */
|
|
113
98
|
describe('Account', () => {
|
|
114
99
|
const CLIENT_ID = '4e37b32f57f6da55';
|
|
115
|
-
afterAll(() => {
|
|
116
|
-
apiClients.forEach(client => client.disconnect());
|
|
117
|
-
});
|
|
118
100
|
// Fix for node 16, crypto.subtle.decrypt has a type problem
|
|
119
101
|
jest.spyOn(global.crypto.subtle, 'decrypt').mockResolvedValue(new Uint8Array(32));
|
|
120
102
|
const accessTokenData = {
|
|
@@ -123,8 +105,6 @@ describe('Account', () => {
|
|
|
123
105
|
token_type: 'Bearer',
|
|
124
106
|
user: 'aaf9a833-ef30-4c22-86a0-9adc8a15b3b4',
|
|
125
107
|
};
|
|
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}`;
|
|
128
108
|
beforeEach(() => {
|
|
129
109
|
(0, nock_1.default)(MOCK_BACKEND.rest)
|
|
130
110
|
.post(auth_1.AuthAPI.URL.LOGIN, body => body.email && body.password)
|
|
@@ -154,14 +134,6 @@ describe('Account', () => {
|
|
|
154
134
|
.get(`${notification_1.NotificationAPI.URL.NOTIFICATION}/${notification_1.NotificationAPI.URL.LAST}`)
|
|
155
135
|
.query({ client: CLIENT_ID })
|
|
156
136
|
.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
|
-
});
|
|
165
137
|
(0, nock_1.default)(MOCK_BACKEND.rest)
|
|
166
138
|
.get(notification_1.NotificationAPI.URL.NOTIFICATION)
|
|
167
139
|
.query({ client: CLIENT_ID, size: 10000 })
|
|
@@ -170,16 +142,6 @@ describe('Account', () => {
|
|
|
170
142
|
(0, nock_1.default)(MOCK_BACKEND.rest)
|
|
171
143
|
.get(client_1.ClientAPI.URL.CLIENTS)
|
|
172
144
|
.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);
|
|
183
145
|
(0, nock_1.default)(MOCK_BACKEND.rest)
|
|
184
146
|
.get(self_1.SelfAPI.URL.SELF)
|
|
185
147
|
.reply(http_status_codes_1.StatusCodes.OK, {
|
|
@@ -201,7 +163,6 @@ describe('Account', () => {
|
|
|
201
163
|
(0, nock_1.cleanAll)();
|
|
202
164
|
});
|
|
203
165
|
const currentClient = {
|
|
204
|
-
capabilities: [],
|
|
205
166
|
id: CLIENT_ID,
|
|
206
167
|
cookie: '',
|
|
207
168
|
time: '',
|
|
@@ -212,9 +173,6 @@ describe('Account', () => {
|
|
|
212
173
|
describe('"init"', () => {
|
|
213
174
|
it('initializes the Protocol buffers', async () => {
|
|
214
175
|
const account = new Account_1.Account();
|
|
215
|
-
if (account['apiClient']) {
|
|
216
|
-
apiClients.push(account['apiClient']);
|
|
217
|
-
}
|
|
218
176
|
await account['initServices']({ clientType: client_1.ClientType.TEMPORARY, userId: '' });
|
|
219
177
|
expect(account.service.conversation).toBeDefined();
|
|
220
178
|
const message = protocol_messaging_1.GenericMessage.create({
|
|
@@ -227,7 +185,6 @@ describe('Account', () => {
|
|
|
227
185
|
describe('"login"', () => {
|
|
228
186
|
it('logs in with correct credentials', async () => {
|
|
229
187
|
const apiClient = new api_client_1.APIClient({ urls: MOCK_BACKEND });
|
|
230
|
-
apiClients.push(apiClient);
|
|
231
188
|
const account = new Account_1.Account(apiClient);
|
|
232
189
|
await account['initServices']({ clientType: client_1.ClientType.TEMPORARY, userId: '' });
|
|
233
190
|
const { clientType, userId } = await account.login({
|
|
@@ -240,7 +197,6 @@ describe('Account', () => {
|
|
|
240
197
|
});
|
|
241
198
|
it('does not log in with incorrect credentials', async () => {
|
|
242
199
|
const apiClient = new api_client_1.APIClient({ urls: MOCK_BACKEND });
|
|
243
|
-
apiClients.push(apiClient);
|
|
244
200
|
const account = new Account_1.Account(apiClient);
|
|
245
201
|
let backendError;
|
|
246
202
|
await account['initServices']({ clientType: client_1.ClientType.TEMPORARY, userId: '' });
|
|
@@ -262,9 +218,35 @@ describe('Account', () => {
|
|
|
262
218
|
}
|
|
263
219
|
});
|
|
264
220
|
});
|
|
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
|
+
});
|
|
265
247
|
describe('Websocket connection', () => {
|
|
266
|
-
let dependencies;
|
|
267
248
|
let server;
|
|
249
|
+
let dependencies;
|
|
268
250
|
const mockNotifications = (size) => {
|
|
269
251
|
const notifications = Array.from(new Array(size)).map(() => ({
|
|
270
252
|
id: (0, uuid_1.v4)(),
|
|
@@ -285,12 +267,12 @@ describe('Account', () => {
|
|
|
285
267
|
return callback();
|
|
286
268
|
};
|
|
287
269
|
};
|
|
288
|
-
|
|
270
|
+
beforeEach(() => {
|
|
271
|
+
server = new jest_websocket_mock_1.WS(`${MOCK_BACKEND.ws}/await?access_token=${accessTokenData.access_token}`);
|
|
289
272
|
// Forces the reconnecting websocket not to automatically reconnect (to avoid infinitely hanging tests)
|
|
290
273
|
ReconnectingWebsocket_1.ReconnectingWebsocket['RECONNECTING_OPTIONS'].maxRetries = 0;
|
|
291
274
|
});
|
|
292
275
|
beforeEach(async () => {
|
|
293
|
-
server = new jest_websocket_mock_1.WS(websocketServerAddress); // isolate per test
|
|
294
276
|
dependencies = await createAccount();
|
|
295
277
|
const { account } = dependencies;
|
|
296
278
|
await account.login({
|
|
@@ -305,48 +287,46 @@ describe('Account', () => {
|
|
|
305
287
|
jest
|
|
306
288
|
.spyOn(dependencies.account.service.notification['database'], 'getLastNotificationId')
|
|
307
289
|
.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');
|
|
313
290
|
});
|
|
314
291
|
afterEach(() => {
|
|
315
|
-
server.close();
|
|
316
|
-
jest_websocket_mock_1.WS.clean();
|
|
292
|
+
server.close();
|
|
317
293
|
});
|
|
318
294
|
describe('listen', () => {
|
|
319
|
-
it('
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
295
|
+
it('warns consumer of the connection state', async () => {
|
|
296
|
+
return new Promise(async (resolve) => {
|
|
297
|
+
const expectedConnectionStates = [
|
|
298
|
+
Account_1.ConnectionState.CONNECTING,
|
|
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 () => {
|
|
323
319
|
return new Promise(async (resolve) => {
|
|
324
320
|
const nbNotifications = 10;
|
|
325
321
|
const onNotificationStreamProgress = jest.fn();
|
|
326
|
-
const onEvent = jest.fn()
|
|
322
|
+
const onEvent = jest.fn();
|
|
327
323
|
mockNotifications(nbNotifications);
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
onConnectionStateChanged: callWhen(Account_1.ConnectionState.LIVE, async () => {
|
|
324
|
+
const disconnect = dependencies.account.listen({
|
|
325
|
+
onConnectionStateChanged: callWhen(Account_1.ConnectionState.LIVE, () => {
|
|
331
326
|
expect(onNotificationStreamProgress).toHaveBeenCalledTimes(nbNotifications);
|
|
332
327
|
expect(onEvent).toHaveBeenCalledTimes(nbNotifications);
|
|
333
328
|
expect(onEvent).toHaveBeenCalledWith(expect.any(Object), notification_2.NotificationSource.NOTIFICATION_STREAM);
|
|
334
|
-
|
|
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);
|
|
329
|
+
disconnect();
|
|
350
330
|
resolve();
|
|
351
331
|
}),
|
|
352
332
|
onEvent: onEvent,
|
|
@@ -354,66 +334,24 @@ describe('Account', () => {
|
|
|
354
334
|
});
|
|
355
335
|
});
|
|
356
336
|
});
|
|
357
|
-
it('
|
|
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 () => {
|
|
337
|
+
it('fowards events from websocket to consumer after the notification stream has been processed', async () => {
|
|
406
338
|
return new Promise(async (resolve) => {
|
|
407
339
|
const nbNotifications = 10;
|
|
408
340
|
const onNotificationStreamProgress = jest.fn();
|
|
409
341
|
const onEvent = jest.fn();
|
|
410
342
|
mockNotifications(nbNotifications);
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
onConnectionStateChanged: callWhen(Account_1.ConnectionState.LIVE, () => {
|
|
343
|
+
const disconnect = dependencies.account.listen({
|
|
344
|
+
onConnectionStateChanged: callWhen(Account_1.ConnectionState.LIVE, async () => {
|
|
414
345
|
expect(onNotificationStreamProgress).toHaveBeenCalledTimes(nbNotifications);
|
|
415
346
|
expect(onEvent).toHaveBeenCalledTimes(nbNotifications);
|
|
416
347
|
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();
|
|
417
355
|
resolve();
|
|
418
356
|
}),
|
|
419
357
|
onEvent: onEvent,
|
|
@@ -421,41 +359,63 @@ describe('Account', () => {
|
|
|
421
359
|
});
|
|
422
360
|
});
|
|
423
361
|
});
|
|
424
|
-
it('
|
|
425
|
-
jest
|
|
426
|
-
.spyOn(dependencies.account, 'getClientCapabilities')
|
|
427
|
-
.mockReturnValue([client_1.ClientCapability.LEGAL_HOLD_IMPLICIT_CONSENT, client_1.ClientCapability.CONSUMABLE_NOTIFICATIONS]);
|
|
362
|
+
it('locks the websocket and waits for notification stream to be processed before sending websocket events', async () => {
|
|
428
363
|
const nbNotifications = 10;
|
|
429
364
|
const onNotificationStreamProgress = jest.fn();
|
|
430
|
-
const onEvent = jest
|
|
365
|
+
const onEvent = jest.fn();
|
|
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
|
|
431
397
|
.fn()
|
|
432
398
|
.mockImplementationOnce(() => { })
|
|
433
|
-
.mockImplementationOnce(() =>
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
return dependencies.account.listen({
|
|
439
|
-
useLegacy: false,
|
|
399
|
+
.mockImplementationOnce(() => server.close());
|
|
400
|
+
const onEvent = jest.fn();
|
|
401
|
+
mockNotifications(nbNotifications);
|
|
402
|
+
return new Promise(async (resolve, reject) => {
|
|
403
|
+
dependencies.account.listen({
|
|
440
404
|
onConnectionStateChanged: async (state) => {
|
|
441
405
|
switch (state) {
|
|
442
|
-
case Account_1.ConnectionState.
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
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
|
-
}
|
|
406
|
+
case Account_1.ConnectionState.PROCESSING_NOTIFICATIONS:
|
|
407
|
+
// sending a message as soon as the notificaiton stream starts to process
|
|
408
|
+
// This message should only be forwarded once the notification stream is fully processed
|
|
409
|
+
server.send(JSON.stringify({ id: (0, uuid_1.v4)(), payload: [{}] }));
|
|
453
410
|
break;
|
|
411
|
+
case Account_1.ConnectionState.LIVE:
|
|
412
|
+
reject(new Error());
|
|
413
|
+
throw new Error('should not go to `live` state');
|
|
454
414
|
case Account_1.ConnectionState.CLOSED:
|
|
455
415
|
expect(onNotificationStreamProgress).toHaveBeenCalledTimes(2);
|
|
456
416
|
expect(onEvent).toHaveBeenCalledTimes(2);
|
|
457
|
-
expect(onEvent).toHaveBeenCalledWith(
|
|
458
|
-
expect(dependencies.account.service.notification.handleNotification).
|
|
417
|
+
expect(onEvent).toHaveBeenCalledWith(expect.any(Object), notification_2.NotificationSource.NOTIFICATION_STREAM);
|
|
418
|
+
expect(dependencies.account.service.notification.handleNotification).not.toHaveBeenCalledWith(expect.any(Object), notification_2.NotificationSource.WEBSOCKET);
|
|
459
419
|
resolve();
|
|
460
420
|
}
|
|
461
421
|
},
|
|
@@ -464,6 +424,35 @@ describe('Account', () => {
|
|
|
464
424
|
});
|
|
465
425
|
});
|
|
466
426
|
});
|
|
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
|
+
});
|
|
467
456
|
});
|
|
468
457
|
});
|
|
469
458
|
});
|
|
@@ -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,2BAA2B,CAAC;AAEvD,MAAM,MAAM,gBAAgB,GAAG,YAAY,CAAC,IAAI,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { GenericMessage } from '@pydio/protocol-messaging';
|
|
1
2
|
import { MessageSendingStatus, QualifiedUserClients } from '@wireapp/api-client/lib/conversation';
|
|
2
3
|
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,cAAc,EAAC,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAC,oBAAoB,EAAE,oBAAoB,EAAC,MAAM,sCAAsC,CAAC;AAEhG,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAK9C,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("@pydio/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 {
|
|
2
|
+
import { 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,14 +45,13 @@ export declare class ClientService {
|
|
|
45
45
|
*
|
|
46
46
|
* @return the loaded client or undefined
|
|
47
47
|
*/
|
|
48
|
-
loadClient(): Promise<
|
|
48
|
+
loadClient(): Promise<RegisteredClient | undefined>;
|
|
49
49
|
private createLocalClient;
|
|
50
|
-
putClientCapabilities(clientId: string, capabilities: ClientCapabilityData): Promise<void>;
|
|
51
50
|
/**
|
|
52
51
|
* Will download all the clients of the self user (excluding the current client) and will store them in the database
|
|
53
52
|
* @param currentClient - the id of the current client (to be excluded from the list)
|
|
54
53
|
*/
|
|
55
54
|
synchronizeClients(currentClient: string): Promise<MetaClient[]>;
|
|
56
|
-
register(loginData: LoginData, clientInfo: ClientInfo, { prekeys, lastPrekey }: InitialPrekeys
|
|
55
|
+
register(loginData: LoginData, clientInfo: ClientInfo, { prekeys, lastPrekey }: InitialPrekeys): Promise<RegisteredClient>;
|
|
57
56
|
}
|
|
58
57
|
//# 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,EAAoD,gBAAgB,EAAC,MAAM,iCAAiC,CAAC;AAKpH,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;YASpD,cAAc;IAQ5B;;;;;;;OAOG;IACU,UAAU,IAAI,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;IAyBhE,OAAO,CAAC,iBAAiB;IAIzB;;;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,GACpC,OAAO,CAAC,gBAAgB,CAAC;CA6B7B"}
|
|
@@ -64,16 +64,9 @@ class ClientService {
|
|
|
64
64
|
async deleteLocalClient(password) {
|
|
65
65
|
const localClientId = this.apiClient.context?.clientId;
|
|
66
66
|
if (!localClientId) {
|
|
67
|
-
|
|
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);
|
|
67
|
+
throw new Error('Trying to delete local client, but local client has not been set');
|
|
76
68
|
}
|
|
69
|
+
await this.backend.deleteClient(localClientId, password);
|
|
77
70
|
return this.database.deleteLocalClient();
|
|
78
71
|
}
|
|
79
72
|
async getLocalClient() {
|
|
@@ -105,7 +98,7 @@ class ClientService {
|
|
|
105
98
|
const notFoundOnBackend = axios_1.default.isAxiosError(error) ? error.response?.status === http_status_codes_1.StatusCodes.NOT_FOUND : false;
|
|
106
99
|
if (notFoundOnBackend && this.storeEngine) {
|
|
107
100
|
const shouldDeleteWholeDatabase = loadedClient.type === client_1.ClientType.TEMPORARY;
|
|
108
|
-
await this.proteusService.wipe();
|
|
101
|
+
await this.proteusService.wipe(this.storeEngine);
|
|
109
102
|
if (shouldDeleteWholeDatabase) {
|
|
110
103
|
await this.storeEngine.clearTables();
|
|
111
104
|
}
|
|
@@ -118,9 +111,6 @@ class ClientService {
|
|
|
118
111
|
createLocalClient(client, domain) {
|
|
119
112
|
return this.database.createLocalClient(client, domain);
|
|
120
113
|
}
|
|
121
|
-
putClientCapabilities(clientId, capabilities) {
|
|
122
|
-
return this.backend.putClient(clientId, capabilities);
|
|
123
|
-
}
|
|
124
114
|
/**
|
|
125
115
|
* Will download all the clients of the self user (excluding the current client) and will store them in the database
|
|
126
116
|
* @param currentClient - the id of the current client (to be excluded from the list)
|
|
@@ -131,20 +121,16 @@ class ClientService {
|
|
|
131
121
|
return this.database.createClientList({ id: this.apiClient.context.userId, domain: this.apiClient.context.domain ?? '' }, filteredClients);
|
|
132
122
|
}
|
|
133
123
|
// TODO: Split functionality into "create" and "register" client
|
|
134
|
-
async register(loginData, clientInfo, { prekeys, lastPrekey }
|
|
124
|
+
async register(loginData, clientInfo, { prekeys, lastPrekey }) {
|
|
135
125
|
if (!this.apiClient.context) {
|
|
136
126
|
throw new Error('Context is not set.');
|
|
137
127
|
}
|
|
138
128
|
if (loginData.clientType === client_1.ClientType.NONE) {
|
|
139
129
|
throw new Error(`Can't register client of type "${client_1.ClientType.NONE}"`);
|
|
140
130
|
}
|
|
141
|
-
const capabilities = [client_1.ClientCapability.LEGAL_HOLD_IMPLICIT_CONSENT];
|
|
142
|
-
if (!useLegacyNotificationStream) {
|
|
143
|
-
capabilities.push(client_1.ClientCapability.CONSUMABLE_NOTIFICATIONS);
|
|
144
|
-
}
|
|
145
131
|
const newClient = {
|
|
146
132
|
class: clientInfo.classification,
|
|
147
|
-
capabilities,
|
|
133
|
+
capabilities: [client_1.ClientCapability.LEGAL_HOLD_IMPLICIT_CONSENT],
|
|
148
134
|
cookie: clientInfo.cookieLabel,
|
|
149
135
|
label: clientInfo.label,
|
|
150
136
|
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,2BAA2B,CAAC;AAEhD,MAAM,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC"}
|