@wireapp/core 46.45.0 → 46.45.1

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.
@@ -65,8 +65,10 @@ const MOCK_BACKEND = {
65
65
  rest: `https://${BASE_URL}`,
66
66
  ws: `wss://${BASE_URL}`,
67
67
  };
68
+ const apiClients = [];
68
69
  async function createAccount() {
69
70
  const apiClient = new api_client_1.APIClient({ urls: MOCK_BACKEND });
71
+ apiClients.push(apiClient);
70
72
  const account = new Account_1.Account(apiClient);
71
73
  await account['initServices']({
72
74
  clientType: client_1.ClientType.TEMPORARY,
@@ -97,6 +99,9 @@ const waitFor = (assertion) => {
97
99
  /* eslint-disable jest/no-conditional-expect */
98
100
  describe('Account', () => {
99
101
  const CLIENT_ID = '4e37b32f57f6da55';
102
+ afterAll(() => {
103
+ apiClients.forEach(client => client.disconnect());
104
+ });
100
105
  // Fix for node 16, crypto.subtle.decrypt has a type problem
101
106
  jest.spyOn(global.crypto.subtle, 'decrypt').mockResolvedValue(new Uint8Array(32));
102
107
  const accessTokenData = {
@@ -194,6 +199,9 @@ describe('Account', () => {
194
199
  describe('"init"', () => {
195
200
  it('initializes the Protocol buffers', async () => {
196
201
  const account = new Account_1.Account();
202
+ if (account['apiClient']) {
203
+ apiClients.push(account['apiClient']);
204
+ }
197
205
  await account['initServices']({ clientType: client_1.ClientType.TEMPORARY, userId: '' });
198
206
  expect(account.service.conversation).toBeDefined();
199
207
  const message = protocol_messaging_1.GenericMessage.create({
@@ -206,6 +214,7 @@ describe('Account', () => {
206
214
  describe('"login"', () => {
207
215
  it('logs in with correct credentials', async () => {
208
216
  const apiClient = new api_client_1.APIClient({ urls: MOCK_BACKEND });
217
+ apiClients.push(apiClient);
209
218
  const account = new Account_1.Account(apiClient);
210
219
  await account['initServices']({ clientType: client_1.ClientType.TEMPORARY, userId: '' });
211
220
  const { clientType, userId } = await account.login({
@@ -218,6 +227,7 @@ describe('Account', () => {
218
227
  });
219
228
  it('does not log in with incorrect credentials', async () => {
220
229
  const apiClient = new api_client_1.APIClient({ urls: MOCK_BACKEND });
230
+ apiClients.push(apiClient);
221
231
  const account = new Account_1.Account(apiClient);
222
232
  let backendError;
223
233
  await account['initServices']({ clientType: client_1.ClientType.TEMPORARY, userId: '' });
@@ -31,9 +31,9 @@ export declare class AssetService {
31
31
  */
32
32
  uploadRawAsset(asset: Buffer | Uint8Array, options?: AssetOptions, progressCallback?: ProgressCallback): RequestCancelable<{
33
33
  key: string;
34
- token: string;
35
- expires: string;
36
- domain?: string | undefined;
34
+ domain: string;
35
+ token?: string | undefined;
36
+ expires?: string | undefined;
37
37
  }>;
38
38
  /**
39
39
  * Will encrypt and upload an asset to the backend
@@ -23,10 +23,15 @@ const api_client_1 = require("@wireapp/api-client");
23
23
  const AssetService_1 = require("./AssetService");
24
24
  describe('AssetService', () => {
25
25
  describe('"uploadAsset"', () => {
26
+ let apiClient;
27
+ afterEach(() => {
28
+ apiClient?.disconnect();
29
+ });
26
30
  it('builds an encrypted asset payload', async () => {
27
- const apiClient = new api_client_1.APIClient();
31
+ apiClient = new api_client_1.APIClient();
28
32
  const assetService = new AssetService_1.AssetService(apiClient);
29
33
  const assetServerData = {
34
+ domain: 'asset-server.test.wire.com',
30
35
  key: `3-2-${(0, uuid_1.v4)()}`,
31
36
  token: (0, uuid_1.v4)(),
32
37
  expires: '',
@@ -44,7 +49,7 @@ describe('AssetService', () => {
44
49
  }));
45
50
  });
46
51
  it('allows cancelling asset upload', async () => {
47
- const apiClient = new api_client_1.APIClient();
52
+ apiClient = new api_client_1.APIClient();
48
53
  const assetService = new AssetService_1.AssetService(apiClient);
49
54
  const apiUpload = {
50
55
  cancel: jest.fn(),
@@ -56,7 +61,7 @@ describe('AssetService', () => {
56
61
  expect(apiUpload.cancel).toHaveBeenCalled();
57
62
  });
58
63
  it('exposes upload progress', async () => {
59
- const apiClient = new api_client_1.APIClient();
64
+ apiClient = new api_client_1.APIClient();
60
65
  const assetService = new AssetService_1.AssetService(apiClient);
61
66
  const apiUpload = {
62
67
  cancel: jest.fn(),
@@ -89,9 +89,14 @@ const mockedProteusService = {
89
89
  encryptGenericMessage: () => Promise.resolve(),
90
90
  sendProteusMessage: () => Promise.resolve({ sentAt: new Date() }),
91
91
  };
92
+ const apiClients = [];
92
93
  describe('ConversationService', () => {
94
+ afterAll(() => {
95
+ apiClients.forEach(client => client.disconnect());
96
+ });
93
97
  async function buildConversationService() {
94
98
  const client = new api_client_1.APIClient({ urls: api_client_1.APIClient.BACKEND.STAGING });
99
+ apiClients.push(client);
95
100
  jest.spyOn(client.api.conversation, 'postMlsMessage').mockReturnValue(Promise.resolve({
96
101
  events: [],
97
102
  time: new Date().toISOString(),
@@ -999,6 +1004,7 @@ function generateImage() {
999
1004
  keyBytes: Buffer.from([]),
1000
1005
  sha256: Buffer.from([]),
1001
1006
  token: '',
1007
+ domain: 'example.com',
1002
1008
  },
1003
1009
  };
1004
1010
  }
@@ -36,8 +36,10 @@ const getSubconversationResponse = ({ epoch, epochTimestamp, parentConversationI
36
36
  epoch_timestamp: epochTimestamp,
37
37
  };
38
38
  };
39
+ const apiClients = [];
39
40
  const buildSubconversationService = async (isFederated = false) => {
40
41
  const apiClient = new api_client_1.APIClient({ urls: api_client_1.APIClient.BACKEND.STAGING });
42
+ apiClients.push(apiClient);
41
43
  apiClient.backendFeatures.isFederated = isFederated;
42
44
  const mlsService = {
43
45
  conversationExists: jest.fn(),
@@ -58,6 +60,9 @@ const buildSubconversationService = async (isFederated = false) => {
58
60
  return [subconversationService, { apiClient, mlsService, coreDatabase }];
59
61
  };
60
62
  describe('SubconversationService', () => {
63
+ afterAll(() => {
64
+ apiClients.forEach(client => client.disconnect());
65
+ });
61
66
  describe('joinConferenceSubconversation', () => {
62
67
  afterEach(() => {
63
68
  jest.useRealTimers();
@@ -71,14 +71,20 @@ function fakeEncrypt(_, recipients) {
71
71
  }, {});
72
72
  return Promise.resolve({ payloads: encryptedPayload });
73
73
  }
74
+ const apiClients = [];
74
75
  const buildMessageService = async () => {
75
76
  const apiClient = new api_client_1.APIClient();
77
+ apiClients.push(apiClient);
76
78
  const [proteusService] = await (0, ProteusService_mocks_1.buildProteusService)();
77
79
  const messageService = new MessageService_1.MessageService(apiClient, proteusService);
78
80
  jest.spyOn(proteusService, 'encrypt').mockImplementation(fakeEncrypt);
79
81
  return [messageService, { apiClient, proteusService }];
80
82
  };
81
83
  describe('MessageService', () => {
84
+ afterAll(() => {
85
+ apiClients.forEach(client => client.disconnect());
86
+ (0, ProteusService_mocks_1.cleanupProteusServiceMocks)();
87
+ });
82
88
  describe('sendMessage', () => {
83
89
  const generateUsers = (userCount, clientsPerUser) => {
84
90
  return Array.from(Array(userCount)).map((_, i) => ({
@@ -6,7 +6,7 @@ export interface EncryptedAsset {
6
6
  }
7
7
  export interface EncryptedAssetUploaded extends EncryptedAsset {
8
8
  key: string;
9
- domain?: string;
10
- token: string;
9
+ domain: string;
10
+ token?: string;
11
11
  }
12
12
  //# sourceMappingURL=EncryptedAsset.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"EncryptedAsset.d.ts","sourceRoot":"","sources":["../../../src/cryptography/AssetCryptography/EncryptedAsset.ts"],"names":[],"mappings":"AAmBA,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,UAAU,CAAC;IACvB,QAAQ,EAAE,UAAU,CAAC;IACrB,sCAAsC;IACtC,MAAM,EAAE,UAAU,CAAC;CACpB;AAED,MAAM,WAAW,sBAAuB,SAAQ,cAAc;IAC5D,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf"}
1
+ {"version":3,"file":"EncryptedAsset.d.ts","sourceRoot":"","sources":["../../../src/cryptography/AssetCryptography/EncryptedAsset.ts"],"names":[],"mappings":"AAmBA,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,UAAU,CAAC;IACvB,QAAQ,EAAE,UAAU,CAAC;IACrB,sCAAsC;IACtC,MAAM,EAAE,UAAU,CAAC;CACpB;AAED,MAAM,WAAW,sBAAuB,SAAQ,cAAc;IAC5D,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB"}
@@ -70,8 +70,10 @@ const defaultMLSInitConfig = {
70
70
  // Needs to be divisible by 4 to be a valid base64 string
71
71
  const mockGroupId = 'Z3JvdXAtdGVzdC0x';
72
72
  const mockedMLSWelcomeEventData = '';
73
+ const apiClients = [];
73
74
  const createMLSService = async () => {
74
75
  const apiClient = new api_client_1.APIClient();
76
+ apiClients.push(apiClient);
75
77
  const transactionContext = {
76
78
  mlsInit: jest.fn(),
77
79
  wipeConversation: jest.fn(),
@@ -112,6 +114,9 @@ afterAll(() => {
112
114
  jest.clearAllTimers();
113
115
  });
114
116
  describe('MLSService', () => {
117
+ afterAll(() => {
118
+ apiClients.forEach(client => client.disconnect());
119
+ });
115
120
  describe('registerConversation', () => {
116
121
  let mlsService;
117
122
  let apiClient;
@@ -5,4 +5,5 @@ export declare const buildProteusService: () => Promise<[ProteusService, {
5
5
  apiClient: APIClient;
6
6
  cryptoClient: CryptoClient;
7
7
  }]>;
8
+ export declare const cleanupProteusServiceMocks: () => void;
8
9
  //# sourceMappingURL=ProteusService.mocks.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ProteusService.mocks.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/proteus/ProteusService/ProteusService.mocks.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAKhD,eAAO,MAAM,mBAAmB,QAAa,OAAO,CAClD,CAAC,cAAc,EAAE;IAAC,SAAS,EAAE,SAAS,CAAC;IAAC,YAAY,EAAE,YAAY,CAAA;CAAC,CAAC,CAwBrE,CAAC"}
1
+ {"version":3,"file":"ProteusService.mocks.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/proteus/ProteusService/ProteusService.mocks.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAOhD,eAAO,MAAM,mBAAmB,QAAa,OAAO,CAClD,CAAC,cAAc,EAAE;IAAC,SAAS,EAAE,SAAS,CAAC;IAAC,YAAY,EAAE,YAAY,CAAA;CAAC,CAAC,CAyBrE,CAAC;AAEF,eAAO,MAAM,0BAA0B,YAGtC,CAAC"}
@@ -18,15 +18,17 @@
18
18
  *
19
19
  */
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.buildProteusService = void 0;
21
+ exports.cleanupProteusServiceMocks = exports.buildProteusService = void 0;
22
22
  const client_1 = require("@wireapp/api-client/lib/client");
23
23
  const api_client_1 = require("@wireapp/api-client");
24
24
  const CoreCryptoWrapper_1 = require("./CryptoClient/CoreCryptoWrapper/CoreCryptoWrapper");
25
25
  const ProteusService_1 = require("./ProteusService");
26
26
  const PayloadHelper_1 = require("../../../test/PayloadHelper");
27
27
  const StoreHelper_1 = require("../../../test/StoreHelper");
28
+ const createdApiClients = [];
28
29
  const buildProteusService = async () => {
29
30
  const apiClient = new api_client_1.APIClient({ urls: api_client_1.APIClient.BACKEND.STAGING });
31
+ createdApiClients.push(apiClient);
30
32
  apiClient.context = {
31
33
  clientType: client_1.ClientType.NONE,
32
34
  userId: (0, PayloadHelper_1.getUUID)(),
@@ -40,3 +42,8 @@ const buildProteusService = async () => {
40
42
  return [proteusService, { apiClient, cryptoClient }];
41
43
  };
42
44
  exports.buildProteusService = buildProteusService;
45
+ const cleanupProteusServiceMocks = () => {
46
+ createdApiClients.forEach(client => client.disconnect());
47
+ createdApiClients.length = 0;
48
+ };
49
+ exports.cleanupProteusServiceMocks = cleanupProteusServiceMocks;
@@ -128,6 +128,9 @@ const prepareDataForEncryption = async () => {
128
128
  };
129
129
  };
130
130
  describe('ProteusService', () => {
131
+ afterAll(() => {
132
+ (0, ProteusService_mocks_1.cleanupProteusServiceMocks)();
133
+ });
131
134
  const domain1 = 'domain1';
132
135
  const domain2 = 'domain2';
133
136
  const domain3 = 'domain3';
@@ -44,18 +44,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
44
44
  /* eslint-disable import/order */
45
45
  const GenericMessageParams = __importStar(require("../Utility/getGenericMessageParams"));
46
46
  const client_1 = require("@wireapp/api-client/lib/client");
47
+ const team_1 = require("@wireapp/api-client/lib/team");
47
48
  const conversation_1 = require("../../../conversation");
48
49
  const MessageBuilder_1 = require("../../../conversation/message/MessageBuilder");
49
50
  const ProteusService_mocks_1 = require("./ProteusService.mocks");
50
- const team_1 = require("@wireapp/api-client/lib/team");
51
51
  jest.mock('../Utility/getGenericMessageParams', () => {
52
52
  return {
53
53
  getGenericMessageParams: jest.fn(),
54
54
  };
55
55
  });
56
56
  const MockedGenericMessageParams = GenericMessageParams;
57
+ const apiClients = [];
57
58
  const prepareProteusService = async () => {
58
59
  const [proteusService, { apiClient }] = await (0, ProteusService_mocks_1.buildProteusService)();
60
+ apiClients.push(apiClient);
59
61
  jest.spyOn(apiClient.api.user, 'postListClients').mockImplementation(() => Promise.resolve({
60
62
  qualified_user_map: {
61
63
  'test-domain': {
@@ -74,6 +76,8 @@ const prepareProteusService = async () => {
74
76
  };
75
77
  afterAll(() => {
76
78
  jest.clearAllTimers();
79
+ apiClients.forEach(client => client.disconnect());
80
+ (0, ProteusService_mocks_1.cleanupProteusServiceMocks)();
77
81
  });
78
82
  describe('sendGenericMessage', () => {
79
83
  describe('targetted messages', () => {
@@ -61,6 +61,7 @@ describe('SessionHandler', () => {
61
61
  });
62
62
  afterAll(() => {
63
63
  jest.clearAllTimers();
64
+ apiClient.disconnect();
64
65
  });
65
66
  describe('constructSessionId', () => {
66
67
  describe('constructs a session ID', () => {
@@ -28,12 +28,17 @@ const MOCK_BACKEND = {
28
28
  ws: `wss://${BASE_URL}`,
29
29
  };
30
30
  const mockedConversationService = {};
31
+ const apiClients = [];
31
32
  describe('NotificationService', () => {
33
+ afterAll(() => {
34
+ apiClients.forEach(client => client.disconnect());
35
+ });
32
36
  describe('handleEvent', () => {
33
37
  it('propagates errors to the outer calling function', async () => {
34
38
  const storeEngine = new store_engine_1.MemoryEngine();
35
39
  await storeEngine.init('NotificationService.test');
36
40
  const apiClient = new api_client_1.APIClient({ urls: MOCK_BACKEND });
41
+ apiClients.push(apiClient);
37
42
  const notificationService = new _1.NotificationService(apiClient, storeEngine, mockedConversationService);
38
43
  jest.spyOn(notificationService, 'handleEvent').mockImplementation(() => {
39
44
  throw new Error('Test error');
@@ -57,6 +62,7 @@ describe('NotificationService', () => {
57
62
  const storeEngine = new store_engine_1.MemoryEngine();
58
63
  await storeEngine.init('NotificationService.test');
59
64
  const apiClient = new api_client_1.APIClient({ urls: MOCK_BACKEND });
65
+ apiClients.push(apiClient);
60
66
  const notificationService = new _1.NotificationService(apiClient, storeEngine, mockedConversationService);
61
67
  jest.spyOn(notificationService, 'handleEvent').mockReturnValue({});
62
68
  const spySetLastNotificationId = jest
@@ -75,6 +81,7 @@ describe('NotificationService', () => {
75
81
  const storeEngine = new store_engine_1.MemoryEngine();
76
82
  await storeEngine.init('NotificationService.test');
77
83
  const apiClient = new api_client_1.APIClient({ urls: MOCK_BACKEND });
84
+ apiClients.push(apiClient);
78
85
  const notificationService = new _1.NotificationService(apiClient, storeEngine, mockedConversationService);
79
86
  jest.spyOn(notificationService, 'handleEvent').mockReturnValue({});
80
87
  const spySetLastNotificationId = jest
@@ -93,6 +100,7 @@ describe('NotificationService', () => {
93
100
  const storeEngine = new store_engine_1.MemoryEngine();
94
101
  await storeEngine.init('NotificationService.test');
95
102
  const apiClient = new api_client_1.APIClient({ urls: MOCK_BACKEND });
103
+ apiClients.push(apiClient);
96
104
  const notificationService = new _1.NotificationService(apiClient, storeEngine, mockedConversationService);
97
105
  notificationService.on(_1.NotificationService.TOPIC.NOTIFICATION_ERROR, notificationError => {
98
106
  expect(notificationError.error.message).toBe('Test error');
@@ -31,6 +31,9 @@ describe('SelfService', () => {
31
31
  describe('putSupportedProtocols', () => {
32
32
  const apiClient = new api_client_1.APIClient({ urls: MOCK_BACKEND });
33
33
  apiClient.backendFeatures.supportsMLS = true;
34
+ afterAll(() => {
35
+ apiClient.disconnect();
36
+ });
34
37
  it('updates the list of self supported protocols', async () => {
35
38
  const selfService = new SelfService_1.SelfService(apiClient);
36
39
  const supportedProtocols = [team_1.CONVERSATION_PROTOCOL.PROTEUS, team_1.CONVERSATION_PROTOCOL.MLS];
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "./lib/cryptography/AssetCryptography/crypto.node": "./lib/cryptography/AssetCryptography/crypto.browser.js"
12
12
  },
13
13
  "dependencies": {
14
- "@wireapp/api-client": "^27.87.0",
14
+ "@wireapp/api-client": "^27.87.1",
15
15
  "@wireapp/commons": "^5.4.9",
16
16
  "@wireapp/core-crypto": "9.1.0",
17
17
  "@wireapp/cryptobox": "12.8.0",
@@ -61,6 +61,6 @@
61
61
  "test:coverage": "jest --coverage",
62
62
  "watch": "tsc --watch"
63
63
  },
64
- "version": "46.45.0",
65
- "gitHead": "031bc333d66a0228a3475dc0a10b5c3685784132"
64
+ "version": "46.45.1",
65
+ "gitHead": "de036306195ee6af235aa1541443b1ffefaa8e26"
66
66
  }