@wireapp/core 22.1.1 → 24.0.0
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/CHANGELOG.md +48 -0
- package/package.json +5 -5
- package/src/main/Account.d.ts +3 -7
- package/src/main/Account.js +6 -5
- package/src/main/account/AccountService.js +1 -1
- package/src/main/account/AccountService.js.map +1 -1
- package/src/main/account/AccountService.ts +1 -1
- package/src/main/broadcast/BroadcastService.js +4 -4
- package/src/main/client/ClientBackendRepository.js +2 -2
- package/src/main/client/ClientDatabaseRepository.d.ts +8 -6
- package/src/main/client/ClientDatabaseRepository.js +8 -5
- package/src/main/client/ClientService.d.ts +2 -2
- package/src/main/client/ClientService.js +4 -3
- package/src/main/connection/ConnectionService.d.ts +2 -1
- package/src/main/connection/ConnectionService.js +4 -8
- package/src/main/conversation/AssetService.js +5 -5
- package/src/main/conversation/ConversationService.d.ts +1 -1
- package/src/main/conversation/ConversationService.js +23 -27
- package/src/main/conversation/message/MessageService.js +7 -7
- package/src/main/cryptography/CryptographyService.d.ts +2 -2
- package/src/main/cryptography/CryptographyService.js +6 -6
- package/src/main/giphy/GiphyService.js +3 -3
- package/src/main/notification/NotificationBackendRepository.js +2 -2
- package/src/main/self/SelfService.js +5 -5
- package/src/main/team/TeamService.js +9 -9
- package/src/main/user/UserService.js +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,54 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [24.0.0](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@23.0.0...@wireapp/core@24.0.0) (2022-02-22)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **api-client:** Allow setting a backend version ([#4226](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/issues/4226)) ([7cda792](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/commit/7cda792e98ebcf4317dc165d9e027654fb11b78f))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### BREAKING CHANGES
|
|
15
|
+
|
|
16
|
+
* **api-client:** All the methods that were using useFederation do not need this parameter anymore (since the federation state is guessed from the api version number)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# [23.0.0](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@22.1.3...@wireapp/core@23.0.0) (2022-02-21)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Code Refactoring
|
|
26
|
+
|
|
27
|
+
* **api-client:** Move all the specific apis to an `api` namespace of the ApiClient ([#4228](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/issues/4228)) ([d18b348](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/commit/d18b34841822eea20114d99db67dc376b1311f15))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
### BREAKING CHANGES
|
|
31
|
+
|
|
32
|
+
* **api-client:** All the specific api accessible from the apiClient have moved from `apiClient.<specificApi>.api` to `apiClient.api.<specificApi>` (eg. `apiClient.user.api` needs to be replaced with `apiClient.api.user`)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
## [22.1.3](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@22.1.2...@wireapp/core@22.1.3) (2022-02-17)
|
|
39
|
+
|
|
40
|
+
**Note:** Version bump only for package @wireapp/core
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
## [22.1.2](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@22.1.1...@wireapp/core@22.1.2) (2022-02-01)
|
|
47
|
+
|
|
48
|
+
**Note:** Version bump only for package @wireapp/core
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
6
54
|
## [22.1.1](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@22.1.0...@wireapp/core@22.1.1) (2022-02-01)
|
|
7
55
|
|
|
8
56
|
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@types/long": "4.0.1",
|
|
7
7
|
"@types/node": "~14",
|
|
8
|
-
"@wireapp/api-client": "
|
|
8
|
+
"@wireapp/api-client": "18.0.0",
|
|
9
9
|
"@wireapp/cryptobox": "12.7.1",
|
|
10
10
|
"bazinga64": "5.10.0",
|
|
11
11
|
"hash.js": "1.1.7",
|
|
@@ -20,14 +20,14 @@
|
|
|
20
20
|
"@types/jasmine": "3.8.2",
|
|
21
21
|
"@types/karma": "6.3.1",
|
|
22
22
|
"@wireapp/commons": "4.2.13",
|
|
23
|
-
"@wireapp/store-engine-dexie": "1.6.
|
|
23
|
+
"@wireapp/store-engine-dexie": "1.6.8",
|
|
24
24
|
"commander": "8.0.0",
|
|
25
25
|
"cross-env": "7.0.3",
|
|
26
26
|
"dotenv-defaults": "2.0.2",
|
|
27
27
|
"faker": "5.5.3",
|
|
28
28
|
"istanbul": "1.1.0-alpha.1",
|
|
29
29
|
"jasmine": "3.8.0",
|
|
30
|
-
"karma": "6.3.
|
|
30
|
+
"karma": "6.3.14",
|
|
31
31
|
"karma-chrome-launcher": "3.1.0",
|
|
32
32
|
"karma-jasmine": "4.0.1",
|
|
33
33
|
"karma-jasmine-diff-reporter": "2.0.1",
|
|
@@ -69,6 +69,6 @@
|
|
|
69
69
|
"test:project": "yarn dist && yarn test",
|
|
70
70
|
"test:node": "nyc jasmine --config=jasmine.json"
|
|
71
71
|
},
|
|
72
|
-
"version": "
|
|
73
|
-
"gitHead": "
|
|
72
|
+
"version": "24.0.0",
|
|
73
|
+
"gitHead": "60af9b22cf064dec167da40a7e14c8edc8b13aa8"
|
|
74
74
|
}
|
package/src/main/Account.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { APIClient } from '@wireapp/api-client';
|
|
2
|
+
import { APIClient, BackendFeatures } from '@wireapp/api-client';
|
|
3
3
|
import type { RegisterData } from '@wireapp/api-client/src/auth';
|
|
4
4
|
import { Context, Cookie, LoginData } from '@wireapp/api-client/src/auth/';
|
|
5
5
|
import { ClientType, RegisteredClient } from '@wireapp/api-client/src/client/';
|
|
@@ -53,12 +53,7 @@ export interface Account {
|
|
|
53
53
|
on(event: TOPIC.ERROR, listener: (payload: CoreError) => void): this;
|
|
54
54
|
}
|
|
55
55
|
export declare type StoreEngineProvider = (storeName: string) => Promise<CRUDEngine>;
|
|
56
|
-
declare type AccountConfig = {
|
|
57
|
-
/** If set to true, will use fully qualified ids and federated endpoints */
|
|
58
|
-
useQualifiedIds?: boolean;
|
|
59
|
-
};
|
|
60
56
|
export declare class Account extends EventEmitter {
|
|
61
|
-
private readonly config;
|
|
62
57
|
private readonly apiClient;
|
|
63
58
|
private readonly logger;
|
|
64
59
|
private readonly storeEngineProvider;
|
|
@@ -79,11 +74,12 @@ export declare class Account extends EventEmitter {
|
|
|
79
74
|
team: TeamService;
|
|
80
75
|
user: UserService;
|
|
81
76
|
};
|
|
77
|
+
backendFeatures: BackendFeatures;
|
|
82
78
|
/**
|
|
83
79
|
* @param apiClient The apiClient instance to use in the core (will create a new new one if undefined)
|
|
84
80
|
* @param storeEngineProvider Used to store info in the database (will create a inMemory engine if undefined)
|
|
85
81
|
*/
|
|
86
|
-
constructor(apiClient?: APIClient, storeEngineProvider?: StoreEngineProvider
|
|
82
|
+
constructor(apiClient?: APIClient, storeEngineProvider?: StoreEngineProvider);
|
|
87
83
|
private persistCookie;
|
|
88
84
|
get clientId(): string;
|
|
89
85
|
get userId(): string;
|
package/src/main/Account.js
CHANGED
|
@@ -72,9 +72,8 @@ class Account extends events_1.EventEmitter {
|
|
|
72
72
|
* @param apiClient The apiClient instance to use in the core (will create a new new one if undefined)
|
|
73
73
|
* @param storeEngineProvider Used to store info in the database (will create a inMemory engine if undefined)
|
|
74
74
|
*/
|
|
75
|
-
constructor(apiClient = new api_client_1.APIClient(), storeEngineProvider
|
|
75
|
+
constructor(apiClient = new api_client_1.APIClient(), storeEngineProvider) {
|
|
76
76
|
super();
|
|
77
|
-
this.config = config;
|
|
78
77
|
this.handlePayload = async (payload) => {
|
|
79
78
|
switch (payload.type) {
|
|
80
79
|
case conversation_1.PayloadBundleType.TIMER_UPDATE: {
|
|
@@ -90,6 +89,7 @@ class Account extends events_1.EventEmitter {
|
|
|
90
89
|
this.emit(Account.TOPIC.ERROR, accountError);
|
|
91
90
|
};
|
|
92
91
|
this.apiClient = apiClient;
|
|
92
|
+
this.backendFeatures = this.apiClient.backendFeatures;
|
|
93
93
|
if (storeEngineProvider) {
|
|
94
94
|
this.storeEngineProvider = storeEngineProvider;
|
|
95
95
|
}
|
|
@@ -149,14 +149,15 @@ class Account extends events_1.EventEmitter {
|
|
|
149
149
|
return context;
|
|
150
150
|
}
|
|
151
151
|
async initServices(storeEngine) {
|
|
152
|
+
const config = { useQualifiedIds: this.apiClient.backendFeatures.federationEndpoints };
|
|
152
153
|
const accountService = new account_1.AccountService(this.apiClient);
|
|
153
154
|
const assetService = new conversation_1.AssetService(this.apiClient);
|
|
154
|
-
const cryptographyService = new cryptography_1.CryptographyService(this.apiClient, storeEngine,
|
|
155
|
+
const cryptographyService = new cryptography_1.CryptographyService(this.apiClient, storeEngine, config);
|
|
155
156
|
const clientService = new client_2.ClientService(this.apiClient, storeEngine, cryptographyService);
|
|
156
157
|
const connectionService = new connection_1.ConnectionService(this.apiClient);
|
|
157
158
|
const giphyService = new giphy_1.GiphyService(this.apiClient);
|
|
158
159
|
const linkPreviewService = new linkPreview_1.LinkPreviewService(assetService);
|
|
159
|
-
const conversationService = new conversation_1.ConversationService(this.apiClient, cryptographyService,
|
|
160
|
+
const conversationService = new conversation_1.ConversationService(this.apiClient, cryptographyService, config);
|
|
160
161
|
const notificationService = new notification_1.NotificationService(this.apiClient, cryptographyService, storeEngine);
|
|
161
162
|
const selfService = new self_1.SelfService(this.apiClient);
|
|
162
163
|
const teamService = new team_1.TeamService(this.apiClient);
|
|
@@ -238,7 +239,7 @@ class Account extends events_1.EventEmitter {
|
|
|
238
239
|
async loadAndValidateLocalClient() {
|
|
239
240
|
await this.service.cryptography.initCryptobox();
|
|
240
241
|
const loadedClient = await this.service.client.getLocalClient();
|
|
241
|
-
await this.apiClient.client.
|
|
242
|
+
await this.apiClient.api.client.getClient(loadedClient.id);
|
|
242
243
|
this.apiClient.context.clientId = loadedClient.id;
|
|
243
244
|
return loadedClient;
|
|
244
245
|
}
|
|
@@ -26,7 +26,7 @@ class AccountService {
|
|
|
26
26
|
}
|
|
27
27
|
getCallConfig() {
|
|
28
28
|
const iceCandidateLimit = commons_1.Runtime.isFirefox() ? 3 : undefined;
|
|
29
|
-
return this.apiClient.account.
|
|
29
|
+
return this.apiClient.api.account.getCallConfig(iceCandidateLimit);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
exports.AccountService = AccountService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountService.js","sourceRoot":"","sources":["AccountService.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAGH,8CAAyC;AAGzC,MAAa,cAAc;IACzB,YAA6B,SAAoB;QAApB,cAAS,GAAT,SAAS,CAAW;IAAG,CAAC;IAErD,aAAa;QACX,MAAM,iBAAiB,GAAG,iBAAO,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAC9D,OAAO,IAAI,CAAC,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"AccountService.js","sourceRoot":"","sources":["AccountService.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAGH,8CAAyC;AAGzC,MAAa,cAAc;IACzB,YAA6B,SAAoB;QAApB,cAAS,GAAT,SAAS,CAAW;IAAG,CAAC;IAErD,aAAa;QACX,MAAM,iBAAiB,GAAG,iBAAO,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAC9D,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC;IACrE,CAAC;CACF;AAPD,wCAOC"}
|
|
@@ -26,6 +26,6 @@ export class AccountService {
|
|
|
26
26
|
|
|
27
27
|
getCallConfig(): Promise<CallConfigData> {
|
|
28
28
|
const iceCandidateLimit = Runtime.isFirefox() ? 3 : undefined;
|
|
29
|
-
return this.apiClient.account.
|
|
29
|
+
return this.apiClient.api.account.getCallConfig(iceCandidateLimit);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -36,16 +36,16 @@ class BroadcastService {
|
|
|
36
36
|
*/
|
|
37
37
|
async getPreKeyBundlesFromTeam(teamId, skipOwnClients = false, onlyDirectConnections = false) {
|
|
38
38
|
const teamMembers = onlyDirectConnections
|
|
39
|
-
? (await this.apiClient.conversation.
|
|
39
|
+
? (await this.apiClient.api.conversation.getConversations()).conversations
|
|
40
40
|
.map(({ members }) => members.others.map(user => user.id).concat(members.self.id))
|
|
41
41
|
.flat()
|
|
42
|
-
: (await this.apiClient.teams.member.
|
|
42
|
+
: (await this.apiClient.api.teams.member.getAllMembers(teamId)).members.map(({ user }) => user);
|
|
43
43
|
let members = Array.from(new Set(teamMembers)).map(member => ({ id: member }));
|
|
44
44
|
if (skipOwnClients) {
|
|
45
|
-
const selfUser = await this.apiClient.self.
|
|
45
|
+
const selfUser = await this.apiClient.api.self.getSelf();
|
|
46
46
|
members = members.filter(member => member.id !== selfUser.id);
|
|
47
47
|
}
|
|
48
|
-
const preKeys = await Promise.all(members.map(member => this.apiClient.user.
|
|
48
|
+
const preKeys = await Promise.all(members.map(member => this.apiClient.api.user.getUserPreKeys(member.id)));
|
|
49
49
|
return preKeys.reduce((bundleMap, bundle) => {
|
|
50
50
|
bundleMap[bundle.user] = {};
|
|
51
51
|
for (const client of bundle.clients) {
|
|
@@ -24,10 +24,10 @@ class ClientBackendRepository {
|
|
|
24
24
|
this.apiClient = apiClient;
|
|
25
25
|
}
|
|
26
26
|
getClients() {
|
|
27
|
-
return this.apiClient.client.
|
|
27
|
+
return this.apiClient.api.client.getClients();
|
|
28
28
|
}
|
|
29
29
|
postClient(client) {
|
|
30
|
-
return this.apiClient.client.
|
|
30
|
+
return this.apiClient.api.client.postClient(client);
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
exports.ClientBackendRepository = ClientBackendRepository;
|
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
import type { RegisteredClient } from '@wireapp/api-client/src/client/';
|
|
2
2
|
import type { CRUDEngine } from '@wireapp/store-engine';
|
|
3
|
+
import { CryptographyService } from '../cryptography/';
|
|
3
4
|
import type { MetaClient } from './ClientService';
|
|
4
5
|
export declare enum DatabaseStores {
|
|
5
6
|
CLIENTS = "clients"
|
|
6
7
|
}
|
|
7
8
|
export declare class ClientDatabaseRepository {
|
|
8
9
|
private readonly storeEngine;
|
|
10
|
+
private readonly cryptographyService;
|
|
9
11
|
static readonly STORES: typeof DatabaseStores;
|
|
10
12
|
static KEYS: {
|
|
11
13
|
LOCAL_IDENTITY: string;
|
|
12
14
|
};
|
|
13
|
-
constructor(storeEngine: CRUDEngine);
|
|
15
|
+
constructor(storeEngine: CRUDEngine, cryptographyService: CryptographyService);
|
|
14
16
|
getLocalClient(): Promise<MetaClient>;
|
|
15
17
|
getClient(sessionId: string): Promise<MetaClient>;
|
|
16
18
|
deleteLocalClient(): Promise<string>;
|
|
17
19
|
deleteClient(sessionId: string): Promise<string>;
|
|
18
|
-
createClientList(userId: string, clientList: RegisteredClient[], domain
|
|
19
|
-
createLocalClient(client: RegisteredClient, domain
|
|
20
|
-
updateLocalClient(client: RegisteredClient, domain
|
|
21
|
-
updateClient(userId: string, client: RegisteredClient, domain
|
|
22
|
-
createClient(userId: string, client: RegisteredClient, domain
|
|
20
|
+
createClientList(userId: string, clientList: RegisteredClient[], domain?: string): Promise<MetaClient[]>;
|
|
21
|
+
createLocalClient(client: RegisteredClient, domain?: string): Promise<MetaClient>;
|
|
22
|
+
updateLocalClient(client: RegisteredClient, domain?: string): Promise<MetaClient>;
|
|
23
|
+
updateClient(userId: string, client: RegisteredClient, domain?: string): Promise<MetaClient>;
|
|
24
|
+
createClient(userId: string, client: RegisteredClient, domain?: string): Promise<MetaClient>;
|
|
23
25
|
private transformClient;
|
|
24
26
|
private transformLocalClient;
|
|
25
27
|
}
|
|
@@ -19,14 +19,14 @@
|
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
exports.ClientDatabaseRepository = exports.DatabaseStores = void 0;
|
|
22
|
-
const cryptography_1 = require("../cryptography/");
|
|
23
22
|
var DatabaseStores;
|
|
24
23
|
(function (DatabaseStores) {
|
|
25
24
|
DatabaseStores["CLIENTS"] = "clients";
|
|
26
25
|
})(DatabaseStores = exports.DatabaseStores || (exports.DatabaseStores = {}));
|
|
27
26
|
class ClientDatabaseRepository {
|
|
28
|
-
constructor(storeEngine) {
|
|
27
|
+
constructor(storeEngine, cryptographyService) {
|
|
29
28
|
this.storeEngine = storeEngine;
|
|
29
|
+
this.cryptographyService = cryptographyService;
|
|
30
30
|
}
|
|
31
31
|
getLocalClient() {
|
|
32
32
|
return this.getClient(ClientDatabaseRepository.KEYS.LOCAL_IDENTITY);
|
|
@@ -59,16 +59,19 @@ class ClientDatabaseRepository {
|
|
|
59
59
|
}
|
|
60
60
|
async updateClient(userId, client, domain) {
|
|
61
61
|
const transformedClient = this.transformClient(userId, client, false, domain);
|
|
62
|
-
await this.storeEngine.update(ClientDatabaseRepository.STORES.CLIENTS,
|
|
62
|
+
await this.storeEngine.update(ClientDatabaseRepository.STORES.CLIENTS, this.cryptographyService.constructSessionId(userId, client.id, domain), transformedClient);
|
|
63
63
|
return transformedClient;
|
|
64
64
|
}
|
|
65
65
|
async createClient(userId, client, domain) {
|
|
66
66
|
const transformedClient = this.transformClient(userId, client, false, domain);
|
|
67
|
-
await this.storeEngine.create(ClientDatabaseRepository.STORES.CLIENTS,
|
|
67
|
+
await this.storeEngine.create(ClientDatabaseRepository.STORES.CLIENTS, this.cryptographyService.constructSessionId(userId, client.id, domain), transformedClient);
|
|
68
68
|
return transformedClient;
|
|
69
69
|
}
|
|
70
70
|
transformClient(userId, client, verified, domain) {
|
|
71
|
-
return Object.assign(Object.assign({}, client), { domain, meta: {
|
|
71
|
+
return Object.assign(Object.assign({}, client), { domain, meta: {
|
|
72
|
+
is_verified: verified,
|
|
73
|
+
primary_key: this.cryptographyService.constructSessionId(userId, client.id, domain),
|
|
74
|
+
} });
|
|
72
75
|
}
|
|
73
76
|
transformLocalClient(client, domain) {
|
|
74
77
|
return Object.assign(Object.assign({}, client), { domain, meta: { is_verified: true, primary_key: ClientDatabaseRepository.KEYS.LOCAL_IDENTITY } });
|
|
@@ -5,7 +5,7 @@ import type { CRUDEngine } from '@wireapp/store-engine';
|
|
|
5
5
|
import type { CryptographyService } from '../cryptography/';
|
|
6
6
|
import { ClientInfo } from './';
|
|
7
7
|
export interface MetaClient extends RegisteredClient {
|
|
8
|
-
domain
|
|
8
|
+
domain?: string;
|
|
9
9
|
meta: {
|
|
10
10
|
is_verified?: boolean;
|
|
11
11
|
primary_key: string;
|
|
@@ -21,7 +21,7 @@ export declare class ClientService {
|
|
|
21
21
|
deleteLocalClient(): Promise<string>;
|
|
22
22
|
getClients(): Promise<RegisteredClient[]>;
|
|
23
23
|
getLocalClient(): Promise<MetaClient>;
|
|
24
|
-
createLocalClient(client: RegisteredClient, domain
|
|
24
|
+
createLocalClient(client: RegisteredClient, domain?: string): Promise<MetaClient>;
|
|
25
25
|
synchronizeClients(): Promise<MetaClient[]>;
|
|
26
26
|
register(loginData: LoginData, clientInfo?: ClientInfo): Promise<RegisteredClient>;
|
|
27
27
|
}
|
|
@@ -26,7 +26,7 @@ class ClientService {
|
|
|
26
26
|
this.apiClient = apiClient;
|
|
27
27
|
this.storeEngine = storeEngine;
|
|
28
28
|
this.cryptographyService = cryptographyService;
|
|
29
|
-
this.database = new _1.ClientDatabaseRepository(this.storeEngine);
|
|
29
|
+
this.database = new _1.ClientDatabaseRepository(this.storeEngine, this.cryptographyService);
|
|
30
30
|
this.backend = new _1.ClientBackendRepository(this.apiClient);
|
|
31
31
|
}
|
|
32
32
|
deleteLocalClient() {
|
|
@@ -42,9 +42,10 @@ class ClientService {
|
|
|
42
42
|
return this.database.createLocalClient(client, domain);
|
|
43
43
|
}
|
|
44
44
|
async synchronizeClients() {
|
|
45
|
+
var _a;
|
|
45
46
|
const registeredClients = await this.backend.getClients();
|
|
46
47
|
const filteredClients = registeredClients.filter(client => client.id !== this.apiClient.context.clientId);
|
|
47
|
-
return this.database.createClientList(this.apiClient.context.userId, filteredClients, this.apiClient.context
|
|
48
|
+
return this.database.createClientList(this.apiClient.context.userId, filteredClients, (_a = this.apiClient.context) === null || _a === void 0 ? void 0 : _a.domain);
|
|
48
49
|
}
|
|
49
50
|
// TODO: Split functionality into "create" and "register" client
|
|
50
51
|
async register(loginData, clientInfo = {
|
|
@@ -74,7 +75,7 @@ class ClientService {
|
|
|
74
75
|
type: loginData.clientType,
|
|
75
76
|
};
|
|
76
77
|
const client = await this.backend.postClient(newClient);
|
|
77
|
-
await this.createLocalClient(client, this.apiClient.context.domain
|
|
78
|
+
await this.createLocalClient(client, this.apiClient.context.domain);
|
|
78
79
|
await this.cryptographyService.initCryptobox();
|
|
79
80
|
return client;
|
|
80
81
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { APIClient } from '@wireapp/api-client';
|
|
2
2
|
import { Connection } from '@wireapp/api-client/src/connection/';
|
|
3
|
+
import { QualifiedId } from '@wireapp/api-client/src/user';
|
|
3
4
|
export declare class ConnectionService {
|
|
4
5
|
private readonly apiClient;
|
|
5
6
|
constructor(apiClient: APIClient);
|
|
6
7
|
getConnections(): Promise<Connection[]>;
|
|
7
8
|
acceptConnection(userId: string): Promise<Connection>;
|
|
8
9
|
ignoreConnection(userId: string): Promise<Connection>;
|
|
9
|
-
createConnection(userId:
|
|
10
|
+
createConnection(userId: QualifiedId): Promise<Connection>;
|
|
10
11
|
}
|
|
@@ -25,24 +25,20 @@ class ConnectionService {
|
|
|
25
25
|
this.apiClient = apiClient;
|
|
26
26
|
}
|
|
27
27
|
getConnections() {
|
|
28
|
-
return this.apiClient.connection.
|
|
28
|
+
return this.apiClient.api.connection.getAllConnections();
|
|
29
29
|
}
|
|
30
30
|
acceptConnection(userId) {
|
|
31
|
-
return this.apiClient.connection.
|
|
31
|
+
return this.apiClient.api.connection.putConnection(userId, {
|
|
32
32
|
status: connection_1.ConnectionStatus.ACCEPTED,
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
ignoreConnection(userId) {
|
|
36
|
-
return this.apiClient.connection.
|
|
36
|
+
return this.apiClient.api.connection.putConnection(userId, {
|
|
37
37
|
status: connection_1.ConnectionStatus.IGNORED,
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
createConnection(userId) {
|
|
41
|
-
return this.apiClient.connection.
|
|
42
|
-
message: ' ',
|
|
43
|
-
name: ' ',
|
|
44
|
-
user: userId,
|
|
45
|
-
});
|
|
41
|
+
return this.apiClient.api.connection.postConnection(userId, '');
|
|
46
42
|
}
|
|
47
43
|
}
|
|
48
44
|
exports.ConnectionService = ConnectionService;
|
|
@@ -36,13 +36,13 @@ class AssetService {
|
|
|
36
36
|
const { forceCaching } = assetData;
|
|
37
37
|
switch (assetData.version) {
|
|
38
38
|
case 1:
|
|
39
|
-
return this.apiClient.asset.
|
|
39
|
+
return this.apiClient.api.asset.getAssetV1(assetData.assetId, assetData.conversationId, forceCaching, progressCallback);
|
|
40
40
|
case 2:
|
|
41
|
-
return this.apiClient.asset.
|
|
41
|
+
return this.apiClient.api.asset.getAssetV2(assetData.assetId, assetData.conversationId, forceCaching, progressCallback);
|
|
42
42
|
case 3:
|
|
43
|
-
return this.apiClient.asset.
|
|
43
|
+
return this.apiClient.api.asset.getAssetV3(assetData.assetKey, assetData.assetToken, forceCaching, progressCallback);
|
|
44
44
|
case 4:
|
|
45
|
-
return this.apiClient.asset.
|
|
45
|
+
return this.apiClient.api.asset.getAssetV4(assetData.assetKey, assetData.assetDomain, assetData.assetToken, forceCaching, progressCallback);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
@@ -54,7 +54,7 @@ class AssetService {
|
|
|
54
54
|
* @return cancellable request that resolves with the uploaded image
|
|
55
55
|
*/
|
|
56
56
|
uploadRawAsset(asset, options, progressCallback) {
|
|
57
|
-
return this.apiClient.asset.
|
|
57
|
+
return this.apiClient.api.asset.postAsset(new Uint8Array(asset), options, progressCallback);
|
|
58
58
|
}
|
|
59
59
|
/**
|
|
60
60
|
* Will encrypt and upload an asset to the backend
|
|
@@ -154,7 +154,7 @@ export declare class ConversationService {
|
|
|
154
154
|
getConversations(conversationIds?: string[]): Promise<Conversation[]>;
|
|
155
155
|
getAsset({ assetId, assetToken, otrKey, sha256 }: RemoteData): Promise<Uint8Array>;
|
|
156
156
|
getUnencryptedAsset(assetId: string, assetToken?: string): Promise<ArrayBuffer>;
|
|
157
|
-
addUser
|
|
157
|
+
addUser(conversationId: string, userIds: string | string[] | QualifiedId | QualifiedId[]): Promise<QualifiedId[]>;
|
|
158
158
|
removeUser(conversationId: string, userId: string): Promise<string>;
|
|
159
159
|
/**
|
|
160
160
|
* Sends a message to a conversation
|
|
@@ -53,7 +53,7 @@ class ConversationService {
|
|
|
53
53
|
return genericMessage;
|
|
54
54
|
}
|
|
55
55
|
async getConversationQualifiedMembers(conversationId) {
|
|
56
|
-
const conversation = await this.apiClient.conversation.
|
|
56
|
+
const conversation = await this.apiClient.api.conversation.getConversation(conversationId);
|
|
57
57
|
/*
|
|
58
58
|
* If you are sending a message to a conversation, you have to include
|
|
59
59
|
* yourself in the list of users if you want to sync a message also to your
|
|
@@ -89,7 +89,7 @@ class ConversationService {
|
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
const preKeys = await Promise.all(targets.map(async ({ id: userId, clients }) => {
|
|
92
|
-
const prekeyBundle = await this.apiClient.user.
|
|
92
|
+
const prekeyBundle = await this.apiClient.api.user.getUserPreKeys(userId);
|
|
93
93
|
// We filter the clients that should not receive the message (if a QualifiedUserClients was given as parameter)
|
|
94
94
|
const userClients = clients
|
|
95
95
|
? prekeyBundle.clients.filter(client => clients.includes(client.client))
|
|
@@ -117,7 +117,7 @@ class ConversationService {
|
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
if (!members.length) {
|
|
120
|
-
const conversation = await this.apiClient.conversation.
|
|
120
|
+
const conversation = await this.apiClient.api.conversation.getConversation(conversationId);
|
|
121
121
|
/*
|
|
122
122
|
* If you are sending a message to a conversation, you have to include
|
|
123
123
|
* yourself in the list of users if you want to sync a message also to your
|
|
@@ -125,7 +125,7 @@ class ConversationService {
|
|
|
125
125
|
*/
|
|
126
126
|
members = conversation.members.others.map(member => member.id).concat(conversation.members.self.id);
|
|
127
127
|
}
|
|
128
|
-
const preKeys = await Promise.all(members.map(member => this.apiClient.user.
|
|
128
|
+
const preKeys = await Promise.all(members.map(member => this.apiClient.api.user.getUserPreKeys(member)));
|
|
129
129
|
return preKeys.reduce((bundleMap, bundle) => {
|
|
130
130
|
const userId = bundle.user;
|
|
131
131
|
bundleMap[userId] || (bundleMap[userId] = {});
|
|
@@ -138,7 +138,7 @@ class ConversationService {
|
|
|
138
138
|
async getSelfConversationId() {
|
|
139
139
|
if (!this.selfConversationId) {
|
|
140
140
|
const { userId } = this.apiClient.context;
|
|
141
|
-
const { qualified_id, id } = await this.apiClient.conversation.
|
|
141
|
+
const { qualified_id, id } = await this.apiClient.api.conversation.getConversation(userId);
|
|
142
142
|
const domain = this.config.useQualifiedIds ? qualified_id.domain : '';
|
|
143
143
|
this.selfConversationId = { id, domain };
|
|
144
144
|
}
|
|
@@ -170,7 +170,7 @@ class ConversationService {
|
|
|
170
170
|
if (targetMode !== MessageTargetMode.NONE && !userIds) {
|
|
171
171
|
throw new Error('Cannot send targetted message when no userIds are given');
|
|
172
172
|
}
|
|
173
|
-
if (conversationDomain) {
|
|
173
|
+
if (conversationDomain && this.config.useQualifiedIds) {
|
|
174
174
|
if ((0, TypePredicateUtil_1.isStringArray)(userIds) || (0, TypePredicateUtil_1.isUserClients)(userIds)) {
|
|
175
175
|
throw new Error('Invalid userIds option for sending to federated backend');
|
|
176
176
|
}
|
|
@@ -530,7 +530,7 @@ class ConversationService {
|
|
|
530
530
|
// When the mismatch happens, we ask the messageService to cancel the sending
|
|
531
531
|
return false;
|
|
532
532
|
};
|
|
533
|
-
if (conversationDomain) {
|
|
533
|
+
if (conversationDomain && this.config.useQualifiedIds) {
|
|
534
534
|
await this.messageService.sendFederatedMessage(sendingClientId, recipients, text, {
|
|
535
535
|
conversationId: { id: conversationId, domain: conversationDomain },
|
|
536
536
|
onClientMismatch,
|
|
@@ -602,7 +602,7 @@ class ConversationService {
|
|
|
602
602
|
};
|
|
603
603
|
}
|
|
604
604
|
leaveConversation(conversationId) {
|
|
605
|
-
return this.apiClient.conversation.
|
|
605
|
+
return this.apiClient.api.conversation.deleteMember(conversationId, this.apiClient.context.userId);
|
|
606
606
|
}
|
|
607
607
|
async leaveConversations(conversationIds) {
|
|
608
608
|
if (!conversationIds) {
|
|
@@ -620,19 +620,19 @@ class ConversationService {
|
|
|
620
620
|
receipt_mode: null,
|
|
621
621
|
users: ids,
|
|
622
622
|
};
|
|
623
|
-
return this.apiClient.conversation.
|
|
623
|
+
return this.apiClient.api.conversation.postConversation(newConversation);
|
|
624
624
|
}
|
|
625
625
|
async getConversations(conversationIds) {
|
|
626
626
|
if (!conversationIds || !conversationIds.length) {
|
|
627
|
-
return this.apiClient.conversation.
|
|
627
|
+
return this.apiClient.api.conversation.getAllConversations();
|
|
628
628
|
}
|
|
629
629
|
if (typeof conversationIds === 'string') {
|
|
630
|
-
return this.apiClient.conversation.
|
|
630
|
+
return this.apiClient.api.conversation.getConversation(conversationIds);
|
|
631
631
|
}
|
|
632
|
-
return this.apiClient.conversation.
|
|
632
|
+
return this.apiClient.api.conversation.getConversationsByIds(conversationIds);
|
|
633
633
|
}
|
|
634
634
|
async getAsset({ assetId, assetToken, otrKey, sha256 }) {
|
|
635
|
-
const request = this.apiClient.asset.
|
|
635
|
+
const request = this.apiClient.api.asset.getAssetV3(assetId, assetToken);
|
|
636
636
|
const encryptedBuffer = (await request.response).buffer;
|
|
637
637
|
return (0, AssetCryptography_1.decryptAsset)({
|
|
638
638
|
cipherText: new Uint8Array(encryptedBuffer),
|
|
@@ -641,21 +641,17 @@ class ConversationService {
|
|
|
641
641
|
});
|
|
642
642
|
}
|
|
643
643
|
async getUnencryptedAsset(assetId, assetToken) {
|
|
644
|
-
const request = await this.apiClient.asset.
|
|
644
|
+
const request = await this.apiClient.api.asset.getAssetV3(assetId, assetToken);
|
|
645
645
|
return (await request.response).buffer;
|
|
646
646
|
}
|
|
647
647
|
async addUser(conversationId, userIds) {
|
|
648
648
|
const ids = Array.isArray(userIds) ? userIds : [userIds];
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
else if ((0, TypePredicateUtil_1.isQualifiedIdArray)(ids)) {
|
|
653
|
-
await this.apiClient.conversation.api.postMembersV2(conversationId, ids);
|
|
654
|
-
}
|
|
655
|
-
return userIds;
|
|
649
|
+
const qualifiedIds = (0, TypePredicateUtil_1.isStringArray)(ids) ? ids.map(id => ({ id, domain: '' })) : ids;
|
|
650
|
+
await this.apiClient.api.conversation.postMembers(conversationId, qualifiedIds);
|
|
651
|
+
return qualifiedIds;
|
|
656
652
|
}
|
|
657
653
|
async removeUser(conversationId, userId) {
|
|
658
|
-
await this.apiClient.conversation.
|
|
654
|
+
await this.apiClient.api.conversation.deleteMember(conversationId, userId);
|
|
659
655
|
return userId;
|
|
660
656
|
}
|
|
661
657
|
/**
|
|
@@ -750,10 +746,10 @@ class ConversationService {
|
|
|
750
746
|
return Object.assign(Object.assign({}, payloadBundle), { content: processedContent || payloadBundle.content, messageTimer: ((_d = genericMessage.ephemeral) === null || _d === void 0 ? void 0 : _d.expireAfterMillis) || 0, state: response.errored ? conversation_2.PayloadBundleState.CANCELLED : conversation_2.PayloadBundleState.OUTGOING_SENT });
|
|
751
747
|
}
|
|
752
748
|
sendTypingStart(conversationId) {
|
|
753
|
-
return this.apiClient.conversation.
|
|
749
|
+
return this.apiClient.api.conversation.postTyping(conversationId, { status: data_1.CONVERSATION_TYPING.STARTED });
|
|
754
750
|
}
|
|
755
751
|
sendTypingStop(conversationId) {
|
|
756
|
-
return this.apiClient.conversation.
|
|
752
|
+
return this.apiClient.api.conversation.postTyping(conversationId, { status: data_1.CONVERSATION_TYPING.STOPPED });
|
|
757
753
|
}
|
|
758
754
|
setConversationMutedStatus(conversationId, status, muteTimestamp) {
|
|
759
755
|
if (typeof muteTimestamp === 'number') {
|
|
@@ -763,7 +759,7 @@ class ConversationService {
|
|
|
763
759
|
otr_muted_ref: muteTimestamp.toISOString(),
|
|
764
760
|
otr_muted_status: status,
|
|
765
761
|
};
|
|
766
|
-
return this.apiClient.conversation.
|
|
762
|
+
return this.apiClient.api.conversation.putMembershipProperties(conversationId, payload);
|
|
767
763
|
}
|
|
768
764
|
toggleArchiveConversation(conversationId, archived, archiveTimestamp = new Date()) {
|
|
769
765
|
if (typeof archiveTimestamp === 'number') {
|
|
@@ -773,10 +769,10 @@ class ConversationService {
|
|
|
773
769
|
otr_archived: archived,
|
|
774
770
|
otr_archived_ref: archiveTimestamp.toISOString(),
|
|
775
771
|
};
|
|
776
|
-
return this.apiClient.conversation.
|
|
772
|
+
return this.apiClient.api.conversation.putMembershipProperties(conversationId, payload);
|
|
777
773
|
}
|
|
778
774
|
setMemberConversationRole(conversationId, userId, conversationRole) {
|
|
779
|
-
return this.apiClient.conversation.
|
|
775
|
+
return this.apiClient.api.conversation.putOtherMember(userId, conversationId, {
|
|
780
776
|
conversation_role: conversationRole,
|
|
781
777
|
});
|
|
782
778
|
}
|
|
@@ -166,7 +166,7 @@ class MessageService {
|
|
|
166
166
|
throw new Error('Unimplemented federated broadcast');
|
|
167
167
|
}
|
|
168
168
|
const { id, domain } = options.conversationId;
|
|
169
|
-
return this.apiClient.conversation.
|
|
169
|
+
return this.apiClient.api.conversation.postOTRMessageV2(id, domain, protoMessage);
|
|
170
170
|
}
|
|
171
171
|
async sendOTRMessage(sendingClientId, recipients, options) {
|
|
172
172
|
const message = {
|
|
@@ -184,8 +184,8 @@ class MessageService {
|
|
|
184
184
|
ignoreMissing = typeof options.reportMissing === 'boolean' ? !options.reportMissing : false;
|
|
185
185
|
}
|
|
186
186
|
return !options.conversationId
|
|
187
|
-
? this.apiClient.broadcast.
|
|
188
|
-
: this.apiClient.conversation.
|
|
187
|
+
? this.apiClient.api.broadcast.postBroadcastMessage(sendingClientId, message, ignoreMissing)
|
|
188
|
+
: this.apiClient.api.conversation.postOTRMessage(sendingClientId, options.conversationId, message, ignoreMissing);
|
|
189
189
|
}
|
|
190
190
|
async generateExternalPayload(plainText) {
|
|
191
191
|
const asset = await (0, AssetCryptography_1.encryptAsset)({ plainText });
|
|
@@ -221,7 +221,7 @@ class MessageService {
|
|
|
221
221
|
// remove deleted clients to the recipients
|
|
222
222
|
deleted.forEach(({ userId, data }) => data.forEach(clientId => delete recipients[userId.id][clientId]));
|
|
223
223
|
if (missing.length) {
|
|
224
|
-
const missingPreKeyBundles = await this.apiClient.user.
|
|
224
|
+
const missingPreKeyBundles = await this.apiClient.api.user.postMultiPreKeyBundles(mismatch.missing);
|
|
225
225
|
const { encrypted } = await this.cryptographyService.encrypt(plainText, missingPreKeyBundles);
|
|
226
226
|
const reEncryptedPayloads = (0, UserClientsUtil_1.flattenUserClients)(encrypted);
|
|
227
227
|
// add missing clients to the recipients
|
|
@@ -243,7 +243,7 @@ class MessageService {
|
|
|
243
243
|
// remove deleted clients to the recipients
|
|
244
244
|
deleted.forEach(({ userId, data }) => data.forEach(clientId => delete recipients[userId.domain][userId.id][clientId]));
|
|
245
245
|
if (Object.keys(missing).length) {
|
|
246
|
-
const missingPreKeyBundles = await this.apiClient.user.
|
|
246
|
+
const missingPreKeyBundles = await this.apiClient.api.user.postQualifiedMultiPreKeyBundles(mismatch.missing);
|
|
247
247
|
const { encrypted } = await this.cryptographyService.encryptQualified(plainText, missingPreKeyBundles);
|
|
248
248
|
const reEncryptedPayloads = (0, UserClientsUtil_1.flattenQualifiedUserClients)(encrypted);
|
|
249
249
|
reEncryptedPayloads.forEach(({ data, userId }) => (recipients[userId.domain][userId.id] = Object.assign(Object.assign({}, recipients[userId.domain][userId.id]), data)));
|
|
@@ -286,8 +286,8 @@ class MessageService {
|
|
|
286
286
|
protoMessage.blob = options.assetData;
|
|
287
287
|
}
|
|
288
288
|
return !options.conversationId
|
|
289
|
-
? this.apiClient.broadcast.
|
|
290
|
-
: this.apiClient.conversation.
|
|
289
|
+
? this.apiClient.api.broadcast.postBroadcastProtobufMessage(sendingClientId, protoMessage, ignoreMissing)
|
|
290
|
+
: this.apiClient.api.conversation.postOTRProtobufMessage(sendingClientId, options.conversationId, protoMessage, ignoreMissing);
|
|
291
291
|
}
|
|
292
292
|
}
|
|
293
293
|
exports.MessageService = MessageService;
|
|
@@ -3,7 +3,7 @@ import type { PreKey as SerializedPreKey } from '@wireapp/api-client/src/auth/';
|
|
|
3
3
|
import type { RegisteredClient } from '@wireapp/api-client/src/client/';
|
|
4
4
|
import type { OTRRecipients, QualifiedOTRRecipients, QualifiedUserClients, UserClients } from '@wireapp/api-client/src/conversation/';
|
|
5
5
|
import type { ConversationOtrMessageAddEvent } from '@wireapp/api-client/src/event';
|
|
6
|
-
import type { QualifiedUserPreKeyBundleMap, UserPreKeyBundleMap } from '@wireapp/api-client/src/user/';
|
|
6
|
+
import type { QualifiedId, QualifiedUserPreKeyBundleMap, UserPreKeyBundleMap } from '@wireapp/api-client/src/user/';
|
|
7
7
|
import { Cryptobox } from '@wireapp/cryptobox';
|
|
8
8
|
import type { CRUDEngine } from '@wireapp/store-engine';
|
|
9
9
|
import { PayloadBundle, PayloadBundleSource } from '../conversation';
|
|
@@ -23,7 +23,7 @@ export declare class CryptographyService {
|
|
|
23
23
|
constructor(apiClient: APIClient, storeEngine: CRUDEngine, config?: {
|
|
24
24
|
useQualifiedIds?: boolean;
|
|
25
25
|
});
|
|
26
|
-
|
|
26
|
+
constructSessionId(userId: string | QualifiedId, clientId: string, domain?: string): string;
|
|
27
27
|
static convertArrayRecipientsToBase64(recipients: OTRRecipients<Uint8Array>): OTRRecipients<string>;
|
|
28
28
|
static convertBase64RecipientsToArray(recipients: OTRRecipients<string>): OTRRecipients<Uint8Array>;
|
|
29
29
|
createCryptobox(): Promise<SerializedPreKey[]>;
|
|
@@ -43,9 +43,10 @@ class CryptographyService {
|
|
|
43
43
|
markdown: false,
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
|
|
46
|
+
constructSessionId(userId, clientId, domain) {
|
|
47
|
+
const { id, domain: baseDomain } = typeof userId === 'string' ? { id: userId, domain } : userId;
|
|
48
|
+
const baseId = `${id}@${clientId}`;
|
|
49
|
+
return baseDomain && this.config.useQualifiedIds ? `${baseDomain}@${baseId}` : baseId;
|
|
49
50
|
}
|
|
50
51
|
static convertArrayRecipientsToBase64(recipients) {
|
|
51
52
|
return Object.fromEntries(Object.entries(recipients).map(([userId, otrClientMap]) => {
|
|
@@ -105,7 +106,7 @@ class CryptographyService {
|
|
|
105
106
|
.filter(clientId => !!users[userId][clientId]);
|
|
106
107
|
for (const clientId of clientIds) {
|
|
107
108
|
const base64PreKey = (0, util_1.isUserClients)(users) ? undefined : (_a = users[userId][clientId]) === null || _a === void 0 ? void 0 : _a.key;
|
|
108
|
-
const sessionId =
|
|
109
|
+
const sessionId = this.constructSessionId(userId, clientId, domain);
|
|
109
110
|
const result = await this.encryptPayloadForSession(sessionId, plainText, base64PreKey);
|
|
110
111
|
if (result) {
|
|
111
112
|
encrypted[userId] || (encrypted[userId] = {});
|
|
@@ -152,8 +153,7 @@ class CryptographyService {
|
|
|
152
153
|
}
|
|
153
154
|
async decodeGenericMessage(otrMessage, source) {
|
|
154
155
|
const { from, qualified_from, data: { sender, text: cipherText }, } = otrMessage;
|
|
155
|
-
const
|
|
156
|
-
const sessionId = CryptographyService.constructSessionId(from, sender, domain);
|
|
156
|
+
const sessionId = this.constructSessionId(from, sender, qualified_from === null || qualified_from === void 0 ? void 0 : qualified_from.domain);
|
|
157
157
|
const decryptedMessage = await this.decrypt(sessionId, cipherText);
|
|
158
158
|
const genericMessage = protocol_messaging_1.GenericMessage.decode(decryptedMessage);
|
|
159
159
|
if (genericMessage.content === conversation_1.GenericMessageType.EPHEMERAL) {
|
|
@@ -24,13 +24,13 @@ class GiphyService {
|
|
|
24
24
|
this.apiClient = apiClient;
|
|
25
25
|
}
|
|
26
26
|
getRandomGif(tag, rating) {
|
|
27
|
-
return this.apiClient.giphy.
|
|
27
|
+
return this.apiClient.api.giphy.getGiphyRandom({ rating, tag });
|
|
28
28
|
}
|
|
29
29
|
getTrendingGif(rating) {
|
|
30
|
-
return this.apiClient.giphy.
|
|
30
|
+
return this.apiClient.api.giphy.getGiphyTrending({ rating });
|
|
31
31
|
}
|
|
32
32
|
searchGif(options) {
|
|
33
|
-
return this.apiClient.giphy.
|
|
33
|
+
return this.apiClient.api.giphy.getGiphySearch(options);
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
exports.GiphyService = GiphyService;
|
|
@@ -24,10 +24,10 @@ class NotificationBackendRepository {
|
|
|
24
24
|
this.apiClient = apiClient;
|
|
25
25
|
}
|
|
26
26
|
async getAllNotifications(clientId, lastNotificationId) {
|
|
27
|
-
return this.apiClient.notification.
|
|
27
|
+
return this.apiClient.api.notification.getAllNotifications(clientId, lastNotificationId);
|
|
28
28
|
}
|
|
29
29
|
getLastNotification(clientId) {
|
|
30
|
-
return this.apiClient.notification.
|
|
30
|
+
return this.apiClient.api.notification.getLastNotification(clientId);
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
exports.NotificationBackendRepository = NotificationBackendRepository;
|
|
@@ -28,16 +28,16 @@ class SelfService {
|
|
|
28
28
|
return !!availableUsername;
|
|
29
29
|
}
|
|
30
30
|
checkUsernames(usernames) {
|
|
31
|
-
return this.apiClient.user.
|
|
31
|
+
return this.apiClient.api.user.postHandles({
|
|
32
32
|
handles: usernames,
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
async getName() {
|
|
36
|
-
const { name } = await this.apiClient.self.
|
|
36
|
+
const { name } = await this.apiClient.api.self.getName();
|
|
37
37
|
return name;
|
|
38
38
|
}
|
|
39
39
|
async getSelf() {
|
|
40
|
-
const selfData = await this.apiClient.self.
|
|
40
|
+
const selfData = await this.apiClient.api.self.getSelf();
|
|
41
41
|
return selfData;
|
|
42
42
|
}
|
|
43
43
|
async getUsername() {
|
|
@@ -45,10 +45,10 @@ class SelfService {
|
|
|
45
45
|
return handle;
|
|
46
46
|
}
|
|
47
47
|
setName(name) {
|
|
48
|
-
return this.apiClient.self.
|
|
48
|
+
return this.apiClient.api.self.putSelf({ name });
|
|
49
49
|
}
|
|
50
50
|
setUsername(username) {
|
|
51
|
-
return this.apiClient.self.
|
|
51
|
+
return this.apiClient.api.self.putHandle({ handle: username });
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
exports.SelfService = SelfService;
|
|
@@ -24,31 +24,31 @@ class TeamService {
|
|
|
24
24
|
this.apiClient = apiClient;
|
|
25
25
|
}
|
|
26
26
|
addMember(teamId, memberData) {
|
|
27
|
-
return this.apiClient.teams.member.
|
|
27
|
+
return this.apiClient.api.teams.member.postMembers(teamId, memberData);
|
|
28
28
|
}
|
|
29
29
|
createTeam(teamData) {
|
|
30
|
-
return this.apiClient.teams.team.
|
|
30
|
+
return this.apiClient.api.teams.team.postTeam(teamData);
|
|
31
31
|
}
|
|
32
32
|
deleteTeam(teamId, password) {
|
|
33
|
-
return this.apiClient.teams.team.
|
|
33
|
+
return this.apiClient.api.teams.team.deleteTeam(teamId, password);
|
|
34
34
|
}
|
|
35
35
|
getAllMembers(teamId) {
|
|
36
|
-
return this.apiClient.teams.member.
|
|
36
|
+
return this.apiClient.api.teams.member.getAllMembers(teamId);
|
|
37
37
|
}
|
|
38
38
|
getTeam(teamId) {
|
|
39
|
-
return this.apiClient.teams.team.
|
|
39
|
+
return this.apiClient.api.teams.team.getTeam(teamId);
|
|
40
40
|
}
|
|
41
41
|
getTeams() {
|
|
42
|
-
return this.apiClient.teams.team.
|
|
42
|
+
return this.apiClient.api.teams.team.getTeams();
|
|
43
43
|
}
|
|
44
44
|
removeMember(teamId, userId, password) {
|
|
45
|
-
return this.apiClient.teams.member.
|
|
45
|
+
return this.apiClient.api.teams.member.deleteMember(teamId, userId, password);
|
|
46
46
|
}
|
|
47
47
|
updateMember(teamId, memberData) {
|
|
48
|
-
return this.apiClient.teams.member.
|
|
48
|
+
return this.apiClient.api.teams.member.putMembers(teamId, memberData);
|
|
49
49
|
}
|
|
50
50
|
updateTeam(teamId, teamData) {
|
|
51
|
-
return this.apiClient.teams.team.
|
|
51
|
+
return this.apiClient.api.teams.team.putTeam(teamId, teamData);
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
exports.TeamService = TeamService;
|
|
@@ -34,15 +34,15 @@ class UserService {
|
|
|
34
34
|
this.conversationService = conversationService;
|
|
35
35
|
}
|
|
36
36
|
getUser(userId) {
|
|
37
|
-
return this.apiClient.user.
|
|
37
|
+
return this.apiClient.api.user.getUser(userId);
|
|
38
38
|
}
|
|
39
39
|
async getUsers(userIds) {
|
|
40
40
|
if (!userIds.length) {
|
|
41
41
|
return [];
|
|
42
42
|
}
|
|
43
43
|
return (0, TypePredicateUtil_1.isQualifiedIdArray)(userIds)
|
|
44
|
-
? this.apiClient.user.
|
|
45
|
-
: this.apiClient.user.
|
|
44
|
+
? this.apiClient.api.user.postListUsers({ qualified_ids: userIds })
|
|
45
|
+
: this.apiClient.api.user.getUsers({ ids: userIds });
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
48
|
* Sends a availability update to members of the same team
|