@wireapp/core 25.3.0 → 26.1.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 +43 -0
- package/package.json +2 -2
- package/src/main/Account.d.ts +17 -4
- package/src/main/Account.js +4 -2
- package/src/main/client/ClientBackendRepository.d.ts +1 -1
- package/src/main/client/ClientDatabaseRepository.js +1 -1
- package/src/main/client/ClientService.d.ts +10 -5
- package/src/main/client/ClientService.js +19 -10
- package/src/main/conversation/ConversationService.d.ts +4 -4
- package/src/main/conversation/ConversationService.js +6 -12
- package/src/main/cryptography/CryptographyService.d.ts +3 -2
- package/src/main/cryptography/CryptographyService.js +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,49 @@
|
|
|
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
|
+
# [26.1.0](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@26.0.0...@wireapp/core@26.1.0) (2022-05-16)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Allow consumer to set number of prekeys generated ([#4263](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/issues/4263)) ([648ecda](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/commit/648ecdad260488e1d07965a84a28c346d6f015c3))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [26.0.0](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@25.3.1...@wireapp/core@26.0.0) (2022-05-16)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* Allow sending targeted lastRead and Countly messages ([#4262](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/issues/4262)) ([69c7d98](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/commit/69c7d98272dc9beea6e5d9a99d6392177f0be361))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### BREAKING CHANGES
|
|
26
|
+
|
|
27
|
+
* To send `lastRead` and `countly` as protobuf message, you now need to provide a `MessageSendingOptions` object as last parameter.
|
|
28
|
+
|
|
29
|
+
```js
|
|
30
|
+
core.service.conversation.sendLastRead(conversation, timestamp, true);
|
|
31
|
+
|
|
32
|
+
// Becomes
|
|
33
|
+
|
|
34
|
+
core.service.converstaion.sendLastRead(conversation, timestamp, {sendAsProtobuf: true});
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
## [25.3.1](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@25.3.0...@wireapp/core@25.3.1) (2022-05-16)
|
|
42
|
+
|
|
43
|
+
**Note:** Version bump only for package @wireapp/core
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
6
49
|
# [25.3.0](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@25.2.1...@wireapp/core@25.3.0) (2022-05-16)
|
|
7
50
|
|
|
8
51
|
|
package/package.json
CHANGED
|
@@ -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": "26.1.0",
|
|
73
|
+
"gitHead": "3b458a889a4e5ebebf2c66429c8fac7f39119891"
|
|
74
74
|
}
|
package/src/main/Account.d.ts
CHANGED
|
@@ -53,11 +53,26 @@ export interface Account {
|
|
|
53
53
|
on(event: TOPIC.ERROR, listener: (payload: CoreError) => void): this;
|
|
54
54
|
}
|
|
55
55
|
export declare type CreateStoreFn = (storeName: string, context: Context) => undefined | Promise<CRUDEngine | undefined>;
|
|
56
|
+
interface AccountOptions {
|
|
57
|
+
/** Used to store info in the database (will create a inMemory engine if returns undefined) */
|
|
58
|
+
createStore?: CreateStoreFn;
|
|
59
|
+
/** Number of prekeys to generate when creating a new device (defaults to 2)
|
|
60
|
+
* Prekeys are Diffie-Hellmann public keys which allow offline initiation of a secure Proteus session between two devices.
|
|
61
|
+
* Having a high value will:
|
|
62
|
+
* - make creating a new device consuming more CPU resources
|
|
63
|
+
* - make it less likely that all prekeys get consumed while the device is offline and the last resort prekey will not be used to create new session
|
|
64
|
+
* Having a low value will:
|
|
65
|
+
* - make creating a new device fast
|
|
66
|
+
* - make it likely that all prekeys get consumed while the device is offline and the last resort prekey will be used to create new session
|
|
67
|
+
*/
|
|
68
|
+
nbPrekeys?: number;
|
|
69
|
+
}
|
|
56
70
|
export declare class Account extends EventEmitter {
|
|
57
71
|
private readonly apiClient;
|
|
58
72
|
private readonly logger;
|
|
59
73
|
private readonly createStore;
|
|
60
74
|
private storeEngine?;
|
|
75
|
+
private readonly nbPrekeys;
|
|
61
76
|
static readonly TOPIC: typeof TOPIC;
|
|
62
77
|
service?: {
|
|
63
78
|
account: AccountService;
|
|
@@ -77,11 +92,9 @@ export declare class Account extends EventEmitter {
|
|
|
77
92
|
backendFeatures: BackendFeatures;
|
|
78
93
|
/**
|
|
79
94
|
* @param apiClient The apiClient instance to use in the core (will create a new new one if undefined)
|
|
80
|
-
* @param storeEngineProvider
|
|
95
|
+
* @param storeEngineProvider
|
|
81
96
|
*/
|
|
82
|
-
constructor(apiClient?: APIClient, { createStore }?:
|
|
83
|
-
createStore?: CreateStoreFn;
|
|
84
|
-
});
|
|
97
|
+
constructor(apiClient?: APIClient, { createStore, nbPrekeys }?: AccountOptions);
|
|
85
98
|
private persistCookie;
|
|
86
99
|
get clientId(): string;
|
|
87
100
|
get userId(): string;
|
package/src/main/Account.js
CHANGED
|
@@ -70,9 +70,9 @@ var TOPIC;
|
|
|
70
70
|
class Account extends events_1.EventEmitter {
|
|
71
71
|
/**
|
|
72
72
|
* @param apiClient The apiClient instance to use in the core (will create a new new one if undefined)
|
|
73
|
-
* @param storeEngineProvider
|
|
73
|
+
* @param storeEngineProvider
|
|
74
74
|
*/
|
|
75
|
-
constructor(apiClient = new api_client_1.APIClient(), { createStore = () => undefined } = {}) {
|
|
75
|
+
constructor(apiClient = new api_client_1.APIClient(), { createStore = () => undefined, nbPrekeys = 2 } = {}) {
|
|
76
76
|
super();
|
|
77
77
|
this.handlePayload = async (payload) => {
|
|
78
78
|
switch (payload.type) {
|
|
@@ -90,6 +90,7 @@ class Account extends events_1.EventEmitter {
|
|
|
90
90
|
};
|
|
91
91
|
this.apiClient = apiClient;
|
|
92
92
|
this.backendFeatures = this.apiClient.backendFeatures;
|
|
93
|
+
this.nbPrekeys = nbPrekeys;
|
|
93
94
|
this.createStore = createStore;
|
|
94
95
|
apiClient.on(api_client_1.APIClient.TOPIC.COOKIE_REFRESH, async (cookie) => {
|
|
95
96
|
if (cookie && this.storeEngine) {
|
|
@@ -136,6 +137,7 @@ class Account extends events_1.EventEmitter {
|
|
|
136
137
|
const cryptographyService = new cryptography_1.CryptographyService(this.apiClient, this.storeEngine, {
|
|
137
138
|
// We want to encrypt with fully qualified session ids, only if the backend is federated with other backends
|
|
138
139
|
useQualifiedIds: this.backendFeatures.isFederated,
|
|
140
|
+
nbPrekeys: this.nbPrekeys,
|
|
139
141
|
});
|
|
140
142
|
const clientService = new client_2.ClientService(this.apiClient, this.storeEngine, cryptographyService);
|
|
141
143
|
const connectionService = new connection_1.ConnectionService(this.apiClient);
|
|
@@ -6,6 +6,6 @@ export declare class ClientBackendRepository {
|
|
|
6
6
|
getClients(): Promise<RegisteredClient[]>;
|
|
7
7
|
postClient(client: CreateClientPayload): Promise<RegisteredClient>;
|
|
8
8
|
putClient(clientId: string, updates: UpdateClientPayload): Promise<void>;
|
|
9
|
-
deleteClient(clientId: string, password
|
|
9
|
+
deleteClient(clientId: string, password?: string): Promise<void>;
|
|
10
10
|
uploadMLSKeyPackages(clientId: string, keyPackages: string[]): Promise<void>;
|
|
11
11
|
}
|
|
@@ -35,7 +35,7 @@ class ClientDatabaseRepository {
|
|
|
35
35
|
return this.storeEngine.read(ClientDatabaseRepository.STORES.CLIENTS, sessionId);
|
|
36
36
|
}
|
|
37
37
|
deleteLocalClient() {
|
|
38
|
-
return this.
|
|
38
|
+
return this.deleteClient(ClientDatabaseRepository.KEYS.LOCAL_IDENTITY);
|
|
39
39
|
}
|
|
40
40
|
deleteClient(sessionId) {
|
|
41
41
|
return this.storeEngine.delete(ClientDatabaseRepository.STORES.CLIENTS, sessionId);
|
|
@@ -18,16 +18,21 @@ export declare class ClientService {
|
|
|
18
18
|
private readonly database;
|
|
19
19
|
private readonly backend;
|
|
20
20
|
constructor(apiClient: APIClient, storeEngine: CRUDEngine, cryptographyService: CryptographyService);
|
|
21
|
-
deleteLocalClient(): Promise<string>;
|
|
22
21
|
getClients(): Promise<RegisteredClient[]>;
|
|
23
22
|
/**
|
|
24
23
|
* Will delete the given client from backend and will also delete it from the local database
|
|
24
|
+
*
|
|
25
|
+
* note: use deleteLocalClient if you wish to delete the client currently used by the user
|
|
26
|
+
*
|
|
25
27
|
* @param clientId The id of the client to delete
|
|
26
|
-
* @param password Password of the owning user
|
|
27
|
-
* @param isLocalClient Is the client also the client currently used by the app (as opposed to a client the user owns but not currenly in use)
|
|
28
|
-
* @returns Promise
|
|
28
|
+
* @param password? Password of the owning user. Can be omitted for temporary devices
|
|
29
29
|
*/
|
|
30
|
-
deleteClient(clientId: string, password
|
|
30
|
+
deleteClient(clientId: string, password?: string): Promise<unknown>;
|
|
31
|
+
/**
|
|
32
|
+
* Will delete the local client (client currently in use by the user) from backend and will also delete it from the local database
|
|
33
|
+
* @param password? Password of the owning user. Can be omitted for temporary devices
|
|
34
|
+
*/
|
|
35
|
+
deleteLocalClient(password?: string): Promise<string>;
|
|
31
36
|
getLocalClient(): Promise<MetaClient>;
|
|
32
37
|
createLocalClient(client: RegisteredClient, domain?: string): Promise<MetaClient>;
|
|
33
38
|
synchronizeClients(): Promise<MetaClient[]>;
|
|
@@ -29,25 +29,34 @@ class ClientService {
|
|
|
29
29
|
this.database = new _1.ClientDatabaseRepository(this.storeEngine, this.cryptographyService);
|
|
30
30
|
this.backend = new _1.ClientBackendRepository(this.apiClient);
|
|
31
31
|
}
|
|
32
|
-
deleteLocalClient() {
|
|
33
|
-
return this.database.deleteLocalClient();
|
|
34
|
-
}
|
|
35
32
|
getClients() {
|
|
36
33
|
return this.backend.getClients();
|
|
37
34
|
}
|
|
38
35
|
/**
|
|
39
36
|
* Will delete the given client from backend and will also delete it from the local database
|
|
37
|
+
*
|
|
38
|
+
* note: use deleteLocalClient if you wish to delete the client currently used by the user
|
|
39
|
+
*
|
|
40
40
|
* @param clientId The id of the client to delete
|
|
41
|
-
* @param password Password of the owning user
|
|
42
|
-
* @param isLocalClient Is the client also the client currently used by the app (as opposed to a client the user owns but not currenly in use)
|
|
43
|
-
* @returns Promise
|
|
41
|
+
* @param password? Password of the owning user. Can be omitted for temporary devices
|
|
44
42
|
*/
|
|
45
|
-
async deleteClient(clientId, password
|
|
43
|
+
async deleteClient(clientId, password) {
|
|
46
44
|
const userId = { id: this.apiClient.userId, domain: this.apiClient.domain || '' };
|
|
47
45
|
await this.backend.deleteClient(clientId, password);
|
|
48
|
-
return
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
return this.database.deleteClient(this.cryptographyService.constructSessionId(userId, clientId));
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Will delete the local client (client currently in use by the user) from backend and will also delete it from the local database
|
|
50
|
+
* @param password? Password of the owning user. Can be omitted for temporary devices
|
|
51
|
+
*/
|
|
52
|
+
async deleteLocalClient(password) {
|
|
53
|
+
var _a;
|
|
54
|
+
const localClientId = (_a = this.apiClient.context) === null || _a === void 0 ? void 0 : _a.clientId;
|
|
55
|
+
if (!localClientId) {
|
|
56
|
+
throw new Error('Trying to delete local client, but local client has not been set');
|
|
57
|
+
}
|
|
58
|
+
await this.backend.deleteClient(localClientId, password);
|
|
59
|
+
return this.database.deleteLocalClient();
|
|
51
60
|
}
|
|
52
61
|
getLocalClient() {
|
|
53
62
|
return this.database.getLocalClient();
|
|
@@ -115,10 +115,10 @@ export declare class ConversationService {
|
|
|
115
115
|
*
|
|
116
116
|
* @param conversationId The conversation which has been read
|
|
117
117
|
* @param lastReadTimestamp The timestamp at which the conversation was read
|
|
118
|
-
* @param
|
|
118
|
+
* @param sendingOptions?
|
|
119
119
|
* @return Resolves when the message has been sent
|
|
120
120
|
*/
|
|
121
|
-
sendLastRead(conversationId: string, lastReadTimestamp: number,
|
|
121
|
+
sendLastRead(conversationId: string, lastReadTimestamp: number, sendingOptions?: MessageSendingOptions): Promise<(MessageSendingStatus & {
|
|
122
122
|
errored?: boolean | undefined;
|
|
123
123
|
}) | (ClientMismatch & {
|
|
124
124
|
errored?: boolean | undefined;
|
|
@@ -127,10 +127,10 @@ export declare class ConversationService {
|
|
|
127
127
|
* Syncs all self user's devices with the countly id
|
|
128
128
|
*
|
|
129
129
|
* @param countlyId The countly id of the current device
|
|
130
|
-
* @param
|
|
130
|
+
* @param sendingOptions?
|
|
131
131
|
* @return Resolves when the message has been sent
|
|
132
132
|
*/
|
|
133
|
-
sendCountlySync(countlyId: string,
|
|
133
|
+
sendCountlySync(countlyId: string, sendingOptions: MessageSendingOptions): Promise<(MessageSendingStatus & {
|
|
134
134
|
errored?: boolean | undefined;
|
|
135
135
|
}) | (ClientMismatch & {
|
|
136
136
|
errored?: boolean | undefined;
|
|
@@ -470,10 +470,10 @@ class ConversationService {
|
|
|
470
470
|
*
|
|
471
471
|
* @param conversationId The conversation which has been read
|
|
472
472
|
* @param lastReadTimestamp The timestamp at which the conversation was read
|
|
473
|
-
* @param
|
|
473
|
+
* @param sendingOptions?
|
|
474
474
|
* @return Resolves when the message has been sent
|
|
475
475
|
*/
|
|
476
|
-
async sendLastRead(conversationId, lastReadTimestamp,
|
|
476
|
+
async sendLastRead(conversationId, lastReadTimestamp, sendingOptions) {
|
|
477
477
|
const lastRead = new protocol_messaging_1.LastRead({
|
|
478
478
|
conversationId,
|
|
479
479
|
lastReadTimestamp,
|
|
@@ -483,19 +483,16 @@ class ConversationService {
|
|
|
483
483
|
messageId: MessageBuilder_1.MessageBuilder.createId(),
|
|
484
484
|
});
|
|
485
485
|
const { id: selfConversationId, domain: selfConversationDomain } = await this.getSelfConversationId();
|
|
486
|
-
return this.sendGenericMessage(this.apiClient.validatedClientId, selfConversationId, genericMessage, {
|
|
487
|
-
conversationDomain: selfConversationDomain,
|
|
488
|
-
sendAsProtobuf,
|
|
489
|
-
});
|
|
486
|
+
return this.sendGenericMessage(this.apiClient.validatedClientId, selfConversationId, genericMessage, Object.assign({ conversationDomain: selfConversationDomain }, sendingOptions));
|
|
490
487
|
}
|
|
491
488
|
/**
|
|
492
489
|
* Syncs all self user's devices with the countly id
|
|
493
490
|
*
|
|
494
491
|
* @param countlyId The countly id of the current device
|
|
495
|
-
* @param
|
|
492
|
+
* @param sendingOptions?
|
|
496
493
|
* @return Resolves when the message has been sent
|
|
497
494
|
*/
|
|
498
|
-
async sendCountlySync(countlyId,
|
|
495
|
+
async sendCountlySync(countlyId, sendingOptions) {
|
|
499
496
|
const { id: selfConversationId, domain: selfConversationDomain } = await this.getSelfConversationId();
|
|
500
497
|
const dataTransfer = new protocol_messaging_1.DataTransfer({
|
|
501
498
|
trackingIdentifier: {
|
|
@@ -506,10 +503,7 @@ class ConversationService {
|
|
|
506
503
|
[conversation_2.GenericMessageType.DATA_TRANSFER]: dataTransfer,
|
|
507
504
|
messageId: MessageBuilder_1.MessageBuilder.createId(),
|
|
508
505
|
});
|
|
509
|
-
return this.sendGenericMessage(this.apiClient.validatedClientId, selfConversationId, genericMessage, {
|
|
510
|
-
conversationDomain: selfConversationDomain,
|
|
511
|
-
sendAsProtobuf,
|
|
512
|
-
});
|
|
506
|
+
return this.sendGenericMessage(this.apiClient.validatedClientId, selfConversationId, genericMessage, Object.assign({ conversationDomain: selfConversationDomain }, sendingOptions));
|
|
513
507
|
}
|
|
514
508
|
/**
|
|
515
509
|
* Get a fresh list from backend of clients for all the participants of the conversation.
|
|
@@ -20,8 +20,9 @@ export declare class CryptographyService {
|
|
|
20
20
|
private readonly logger;
|
|
21
21
|
cryptobox: Cryptobox;
|
|
22
22
|
private readonly database;
|
|
23
|
-
constructor(apiClient: APIClient, storeEngine: CRUDEngine, config
|
|
24
|
-
useQualifiedIds
|
|
23
|
+
constructor(apiClient: APIClient, storeEngine: CRUDEngine, config: {
|
|
24
|
+
useQualifiedIds: boolean;
|
|
25
|
+
nbPrekeys: number;
|
|
25
26
|
});
|
|
26
27
|
constructSessionId(userId: string | QualifiedId, clientId: string, domain?: string): string;
|
|
27
28
|
static convertArrayRecipientsToBase64(recipients: OTRRecipients<Uint8Array>): OTRRecipients<string>;
|
|
@@ -32,11 +32,11 @@ const util_1 = require("../util");
|
|
|
32
32
|
const CryptographyDatabaseRepository_1 = require("./CryptographyDatabaseRepository");
|
|
33
33
|
const GenericMessageMapper_1 = require("./GenericMessageMapper");
|
|
34
34
|
class CryptographyService {
|
|
35
|
-
constructor(apiClient, storeEngine, config
|
|
35
|
+
constructor(apiClient, storeEngine, config) {
|
|
36
36
|
this.apiClient = apiClient;
|
|
37
37
|
this.storeEngine = storeEngine;
|
|
38
38
|
this.config = config;
|
|
39
|
-
this.cryptobox = new cryptobox_1.Cryptobox(this.storeEngine);
|
|
39
|
+
this.cryptobox = new cryptobox_1.Cryptobox(this.storeEngine, config.nbPrekeys);
|
|
40
40
|
this.database = new CryptographyDatabaseRepository_1.CryptographyDatabaseRepository(this.storeEngine);
|
|
41
41
|
this.logger = (0, logdown_1.default)('@wireapp/core/cryptography/CryptographyService', {
|
|
42
42
|
logger: console,
|