@wireapp/core 23.0.0 → 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 +16 -0
- package/package.json +3 -3
- package/src/main/Account.d.ts +3 -7
- package/src/main/Account.js +5 -4
- 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 +1 -5
- package/src/main/conversation/ConversationService.d.ts +1 -1
- package/src/main/conversation/ConversationService.js +6 -10
- package/src/main/cryptography/CryptographyService.d.ts +2 -2
- package/src/main/cryptography/CryptographyService.js +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
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
|
+
|
|
6
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)
|
|
7
23
|
|
|
8
24
|
|
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",
|
|
@@ -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);
|
|
@@ -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
|
}
|
|
@@ -38,11 +38,7 @@ class ConnectionService {
|
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
createConnection(userId) {
|
|
41
|
-
return this.apiClient.api.connection.postConnection(
|
|
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;
|
|
@@ -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.api.conversation.getConversation(conversationId
|
|
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
|
|
@@ -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,
|
|
@@ -646,13 +646,9 @@ class ConversationService {
|
|
|
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.api.conversation.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
654
|
await this.apiClient.api.conversation.deleteMember(conversationId, userId);
|
|
@@ -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) {
|