@wireapp/core 42.19.2 → 42.20.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.
@@ -1,7 +1,9 @@
1
+ import { ConversationProtocol } from '@wireapp/api-client/lib/conversation';
1
2
  import { Self } from '@wireapp/api-client/lib/self/';
2
3
  import { APIClient } from '@wireapp/api-client';
3
4
  export declare class SelfService {
4
5
  private readonly apiClient;
6
+ private readonly logger;
5
7
  constructor(apiClient: APIClient);
6
8
  checkUsername(username: string): Promise<boolean>;
7
9
  checkUsernames(usernames: string[]): Promise<string[]>;
@@ -10,5 +12,10 @@ export declare class SelfService {
10
12
  getUsername(): Promise<string | undefined>;
11
13
  setName(name: string): Promise<void>;
12
14
  setUsername(username: string): Promise<void>;
15
+ /**
16
+ * Update self user's list of supported-protocols
17
+ * @param supportedProtocols The list of supported protocols
18
+ */
19
+ putSupportedProtocols(supportedProtocols: ConversationProtocol[]): Promise<void>;
13
20
  }
14
21
  //# sourceMappingURL=SelfService.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SelfService.d.ts","sourceRoot":"","sources":["../../src/self/SelfService.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,IAAI,EAAC,MAAM,+BAA+B,CAAC;AAEnD,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAE9C,qBAAa,WAAW;IACV,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAAT,SAAS,EAAE,SAAS;IAEpC,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAKvD,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAMhD,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;IAK1B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAKxB,WAAW,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAKhD,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIpC,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGpD"}
1
+ {"version":3,"file":"SelfService.d.ts","sourceRoot":"","sources":["../../src/self/SelfService.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,oBAAoB,EAAC,MAAM,sCAAsC,CAAC;AAC1E,OAAO,EAAC,IAAI,EAAC,MAAM,+BAA+B,CAAC;AAGnD,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAE9C,qBAAa,WAAW;IAGV,OAAO,CAAC,QAAQ,CAAC,SAAS;IAFtC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwC;gBAElC,SAAS,EAAE,SAAS;IAEpC,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAKvD,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAMhD,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;IAK1B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAKxB,WAAW,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAKhD,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIpC,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAInD;;;OAGG;IACU,qBAAqB,CAAC,kBAAkB,EAAE,oBAAoB,EAAE;CAY9E"}
@@ -17,11 +17,16 @@
17
17
  * along with this program. If not, see http://www.gnu.org/licenses/.
18
18
  *
19
19
  */
20
+ var __importDefault = (this && this.__importDefault) || function (mod) {
21
+ return (mod && mod.__esModule) ? mod : { "default": mod };
22
+ };
20
23
  Object.defineProperty(exports, "__esModule", { value: true });
21
24
  exports.SelfService = void 0;
25
+ const logdown_1 = __importDefault(require("logdown"));
22
26
  class SelfService {
23
27
  constructor(apiClient) {
24
28
  this.apiClient = apiClient;
29
+ this.logger = (0, logdown_1.default)('@wireapp/core/SelfService');
25
30
  }
26
31
  async checkUsername(username) {
27
32
  const [availableUsername] = await this.checkUsernames([username]);
@@ -50,5 +55,19 @@ class SelfService {
50
55
  setUsername(username) {
51
56
  return this.apiClient.api.self.putHandle({ handle: username });
52
57
  }
58
+ /**
59
+ * Update self user's list of supported-protocols
60
+ * @param supportedProtocols The list of supported protocols
61
+ */
62
+ async putSupportedProtocols(supportedProtocols) {
63
+ if (!this.apiClient.backendFeatures.supportsMLS) {
64
+ this.logger.warn('Self supported protocols were not updated, because endpoint is not supported by backend');
65
+ return;
66
+ }
67
+ if (!supportedProtocols || supportedProtocols.length === 0) {
68
+ throw new Error('Supported protocols must be a non-empty protocols list');
69
+ }
70
+ return this.apiClient.api.self.putSupportedProtocols(supportedProtocols);
71
+ }
53
72
  }
54
73
  exports.SelfService = SelfService;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=SelfService.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SelfService.test.d.ts","sourceRoot":"","sources":["../../src/self/SelfService.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ /*
3
+ * Wire
4
+ * Copyright (C) 2023 Wire Swiss GmbH
5
+ *
6
+ * This program is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU General Public License as published by
8
+ * the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU General Public License
17
+ * along with this program. If not, see http://www.gnu.org/licenses/.
18
+ *
19
+ */
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ const conversation_1 = require("@wireapp/api-client/lib/conversation");
22
+ const api_client_1 = require("@wireapp/api-client");
23
+ const SelfService_1 = require("./SelfService");
24
+ const BASE_URL = 'mock-backend.wire.com';
25
+ const MOCK_BACKEND = {
26
+ name: 'mock',
27
+ rest: `https://${BASE_URL}`,
28
+ ws: `wss://${BASE_URL}`,
29
+ };
30
+ describe('SelfService', () => {
31
+ describe('putSupportedProtocols', () => {
32
+ const apiClient = new api_client_1.APIClient({ urls: MOCK_BACKEND });
33
+ apiClient.backendFeatures.supportsMLS = true;
34
+ it('updates the list of self supported protocols', async () => {
35
+ const selfService = new SelfService_1.SelfService(apiClient);
36
+ const supportedProtocols = [conversation_1.ConversationProtocol.PROTEUS, conversation_1.ConversationProtocol.MLS];
37
+ jest.spyOn(apiClient.api.self, 'putSupportedProtocols').mockImplementation(jest.fn());
38
+ await selfService.putSupportedProtocols(supportedProtocols);
39
+ expect(apiClient.api.self.putSupportedProtocols).toHaveBeenCalledWith(supportedProtocols);
40
+ });
41
+ it('throws if supported protocols list is not provided', async () => {
42
+ const selfService = new SelfService_1.SelfService(apiClient);
43
+ const supportedProtocols = undefined;
44
+ jest.spyOn(apiClient.api.self, 'putSupportedProtocols').mockImplementation(jest.fn());
45
+ await expect(() => selfService.putSupportedProtocols(supportedProtocols)).rejects.toThrow('Supported protocols must be a non-empty protocols list');
46
+ });
47
+ it('throws if supported protocols list is empty', async () => {
48
+ const selfService = new SelfService_1.SelfService(apiClient);
49
+ const supportedProtocols = [];
50
+ jest.spyOn(apiClient.api.self, 'putSupportedProtocols').mockImplementation(jest.fn());
51
+ await expect(() => selfService.putSupportedProtocols(supportedProtocols)).rejects.toThrow('Supported protocols must be a non-empty protocols list');
52
+ });
53
+ });
54
+ });
@@ -1,3 +1,4 @@
1
+ import { ConversationProtocol } from '@wireapp/api-client/lib/conversation';
1
2
  import { QualifiedId, User } from '@wireapp/api-client/lib/user/';
2
3
  import { APIClient } from '@wireapp/api-client';
3
4
  export declare class UserService {
@@ -9,5 +10,9 @@ export declare class UserService {
9
10
  failed?: QualifiedId[] | undefined;
10
11
  not_found?: QualifiedId[] | undefined;
11
12
  } | never[]>;
13
+ /**
14
+ * Get the list of other user's supported protocols.
15
+ */
16
+ getUserSupportedProtocols(userId: QualifiedId): Promise<ConversationProtocol[]>;
12
17
  }
13
18
  //# sourceMappingURL=UserService.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"UserService.d.ts","sourceRoot":"","sources":["../../src/user/UserService.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,WAAW,EAAE,IAAI,EAAC,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAE9C,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;gBAE1B,SAAS,EAAE,SAAS;IAIzB,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9C,QAAQ,CAAC,OAAO,EAAE,WAAW,EAAE;;;;;CAM7C"}
1
+ {"version":3,"file":"UserService.d.ts","sourceRoot":"","sources":["../../src/user/UserService.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,oBAAoB,EAAC,MAAM,sCAAsC,CAAC;AAC1E,OAAO,EAAC,WAAW,EAAE,IAAI,EAAC,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAE9C,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;gBAE1B,SAAS,EAAE,SAAS;IAIzB,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9C,QAAQ,CAAC,OAAO,EAAE,WAAW,EAAE;;;;;IAO5C;;OAEG;IACU,yBAAyB,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,oBAAoB,EAAE,CAAC;CAS7F"}
@@ -19,6 +19,7 @@
19
19
  */
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.UserService = void 0;
22
+ const conversation_1 = require("@wireapp/api-client/lib/conversation");
22
23
  class UserService {
23
24
  constructor(apiClient) {
24
25
  this.apiClient = apiClient;
@@ -32,5 +33,16 @@ class UserService {
32
33
  }
33
34
  return this.apiClient.api.user.postListUsers({ qualified_ids: userIds });
34
35
  }
36
+ /**
37
+ * Get the list of other user's supported protocols.
38
+ */
39
+ async getUserSupportedProtocols(userId) {
40
+ // Clients that uses version below the one supporting MLS, are not aware of user's supported protocols, we default to Proteus in this case.
41
+ if (!this.apiClient.backendFeatures.supportsMLS) {
42
+ return [conversation_1.ConversationProtocol.PROTEUS];
43
+ }
44
+ const supportedProtocols = await this.apiClient.api.user.getUserSupportedProtocols(userId);
45
+ return supportedProtocols.length > 0 ? supportedProtocols : [conversation_1.ConversationProtocol.PROTEUS];
46
+ }
35
47
  }
36
48
  exports.UserService = UserService;
package/package.json CHANGED
@@ -11,16 +11,16 @@
11
11
  "./lib/cryptography/AssetCryptography/crypto.node": "./lib/cryptography/AssetCryptography/crypto.browser.js"
12
12
  },
13
13
  "dependencies": {
14
- "@wireapp/api-client": "^26.5.1",
15
- "@wireapp/commons": "^5.2.2",
14
+ "@wireapp/api-client": "^26.5.3",
15
+ "@wireapp/commons": "^5.2.3",
16
16
  "@wireapp/core-crypto": "1.0.0-rc.16",
17
17
  "@wireapp/cryptobox": "12.8.0",
18
- "@wireapp/promise-queue": "^2.2.7",
18
+ "@wireapp/promise-queue": "^2.2.8",
19
19
  "@wireapp/protocol-messaging": "1.44.0",
20
20
  "@wireapp/store-engine": "5.1.4",
21
21
  "@wireapp/store-engine-dexie": "^2.1.6",
22
- "axios": "1.5.1",
23
- "bazinga64": "^6.3.2",
22
+ "axios": "1.6.2",
23
+ "bazinga64": "^6.3.3",
24
24
  "deepmerge-ts": "5.1.0",
25
25
  "hash.js": "1.1.7",
26
26
  "http-status-codes": "2.3.0",
@@ -37,14 +37,14 @@
37
37
  "@types/jest": "^29.2.0",
38
38
  "@types/long": "^5.0.0",
39
39
  "@types/rimraf": "^3.0.2",
40
- "@types/tough-cookie": "4.0.4",
40
+ "@types/tough-cookie": "4.0.5",
41
41
  "commander": "11.1.0",
42
42
  "cross-env": "7.0.3",
43
43
  "dotenv-defaults": "5.0.2",
44
44
  "fake-indexeddb": "^4.0.0",
45
45
  "jest": "^29.2.1",
46
46
  "jest-websocket-mock": "2.5.0",
47
- "nock": "13.3.6",
47
+ "nock": "13.3.8",
48
48
  "rimraf": "^3.0.2",
49
49
  "typescript": "^5.0.4"
50
50
  },
@@ -61,6 +61,6 @@
61
61
  "test:coverage": "jest --coverage",
62
62
  "watch": "tsc --watch"
63
63
  },
64
- "version": "42.19.2",
65
- "gitHead": "96506c0e52f08f30c956c8b6a067d1e9e3e1abd2"
64
+ "version": "42.20.1",
65
+ "gitHead": "7013cb299e2b41827ded167f8996c236719d7b72"
66
66
  }