@wireapp/core 27.5.0 → 28.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 +3 -3
- package/src/main/Account.d.ts +20 -9
- package/src/main/Account.js +13 -13
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
|
+
# [28.1.0](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@28.0.0...@wireapp/core@28.1.0) (2022-07-04)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **core:** More suited types for Account ([051b4f3](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/commit/051b4f35be7164624f3ed7913366010bdf8b17c4))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* **api-client:** Adapt to api version 2 ([#4308](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/issues/4308)) ([2ac928d](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/commit/2ac928d0b812080faa81e2cd9de12c959eb59276))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# [28.0.0](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@27.6.0...@wireapp/core@28.0.0) (2022-07-01)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
|
|
27
|
+
* Use mls config object ([#4307](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/issues/4307)) ([3d510d0](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/commit/3d510d0e041a3d049282e6a312ffa880d9bafd89))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
### BREAKING CHANGES
|
|
31
|
+
|
|
32
|
+
* the enableMLS flag has been removed in favor of a config object. If the config object is set, then MLS will be activated
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
# [27.6.0](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@27.5.0...@wireapp/core@27.6.0) (2022-06-30)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
### Features
|
|
42
|
+
|
|
43
|
+
* Give proper database name to corecrypto db ([#4306](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/issues/4306)) ([50c7a7a](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/commit/50c7a7a6ca97a0e848a0bb7d9a781e5410909368))
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
6
49
|
# [27.5.0](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@27.4.2...@wireapp/core@27.5.0) (2022-06-30)
|
|
7
50
|
|
|
8
51
|
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"@otak/core-crypto": "0.2.0-beta-3",
|
|
8
8
|
"@types/long": "4.0.1",
|
|
9
9
|
"@types/node": "~14",
|
|
10
|
-
"@wireapp/api-client": "19.
|
|
10
|
+
"@wireapp/api-client": "19.8.0",
|
|
11
11
|
"@wireapp/cryptobox": "12.8.0",
|
|
12
12
|
"bazinga64": "5.10.0",
|
|
13
13
|
"hash.js": "1.1.7",
|
|
@@ -73,6 +73,6 @@
|
|
|
73
73
|
"test:project": "yarn dist && yarn test",
|
|
74
74
|
"test:node": "nyc jasmine --config=jasmine.json"
|
|
75
75
|
},
|
|
76
|
-
"version": "
|
|
77
|
-
"gitHead": "
|
|
76
|
+
"version": "28.1.0",
|
|
77
|
+
"gitHead": "4b3f49cdb3d62b745a325faa6deab76ad93b07f2"
|
|
78
78
|
}
|
package/src/main/Account.d.ts
CHANGED
|
@@ -59,13 +59,22 @@ declare type SecretCrypto<T> = {
|
|
|
59
59
|
encrypt: (value: Uint8Array) => Promise<T>;
|
|
60
60
|
decrypt: (payload: T) => Promise<Uint8Array>;
|
|
61
61
|
};
|
|
62
|
-
interface
|
|
63
|
-
/**
|
|
64
|
-
|
|
65
|
-
/** encrypt/decrypt function pair that will be called before storing/fetching secrets in the secrets database.
|
|
62
|
+
interface MLSConfig<T = any> {
|
|
63
|
+
/**
|
|
64
|
+
* encrypt/decrypt function pair that will be called before storing/fetching secrets in the secrets database.
|
|
66
65
|
* If not provided will use the built in encryption mechanism
|
|
67
66
|
*/
|
|
68
67
|
secretsCrypto?: SecretCrypto<T>;
|
|
68
|
+
/**
|
|
69
|
+
* path on the public server to the core crypto wasm file.
|
|
70
|
+
* This file will be downloaded lazily when corecrypto is needed.
|
|
71
|
+
* It, thus, needs to know where, on the server, the file can be found
|
|
72
|
+
*/
|
|
73
|
+
coreCrypoWasmFilePath: string;
|
|
74
|
+
}
|
|
75
|
+
interface AccountOptions<T> {
|
|
76
|
+
/** Used to store info in the database (will create a inMemory engine if returns undefined) */
|
|
77
|
+
createStore?: CreateStoreFn;
|
|
69
78
|
/** Number of prekeys to generate when creating a new device (defaults to 2)
|
|
70
79
|
* Prekeys are Diffie-Hellmann public keys which allow offline initiation of a secure Proteus session between two devices.
|
|
71
80
|
* Having a high value will:
|
|
@@ -76,16 +85,18 @@ interface AccountOptions<T> {
|
|
|
76
85
|
* - 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
|
|
77
86
|
*/
|
|
78
87
|
nbPrekeys?: number;
|
|
79
|
-
|
|
88
|
+
/**
|
|
89
|
+
* Config for MLS devices. Will not load corecrypt or create MLS devices if undefined
|
|
90
|
+
*/
|
|
91
|
+
mlsConfig?: MLSConfig<T>;
|
|
80
92
|
}
|
|
81
|
-
export declare class Account<T =
|
|
93
|
+
export declare class Account<T = any> extends EventEmitter {
|
|
82
94
|
private readonly apiClient;
|
|
83
95
|
private readonly logger;
|
|
84
96
|
private readonly createStore;
|
|
85
97
|
private storeEngine?;
|
|
86
|
-
private readonly secretsCrypto?;
|
|
87
98
|
private readonly nbPrekeys;
|
|
88
|
-
private readonly
|
|
99
|
+
private readonly mlsConfig?;
|
|
89
100
|
private coreCryptoClient?;
|
|
90
101
|
static readonly TOPIC: typeof TOPIC;
|
|
91
102
|
service?: {
|
|
@@ -108,7 +119,7 @@ export declare class Account<T = unknown> extends EventEmitter {
|
|
|
108
119
|
* @param apiClient The apiClient instance to use in the core (will create a new new one if undefined)
|
|
109
120
|
* @param accountOptions
|
|
110
121
|
*/
|
|
111
|
-
constructor(apiClient?: APIClient, { createStore, nbPrekeys,
|
|
122
|
+
constructor(apiClient?: APIClient, { createStore, nbPrekeys, mlsConfig }?: AccountOptions<T>);
|
|
112
123
|
private persistCookie;
|
|
113
124
|
get clientId(): string;
|
|
114
125
|
get userId(): string;
|
package/src/main/Account.js
CHANGED
|
@@ -71,6 +71,7 @@ const user_1 = require("./user/");
|
|
|
71
71
|
const account_1 = require("./account/");
|
|
72
72
|
const linkPreview_1 = require("./linkPreview");
|
|
73
73
|
const encryptedStore_1 = require("./util/encryptedStore");
|
|
74
|
+
const bazinga64_1 = require("bazinga64");
|
|
74
75
|
var TOPIC;
|
|
75
76
|
(function (TOPIC) {
|
|
76
77
|
TOPIC["ERROR"] = "Account.TOPIC.ERROR";
|
|
@@ -85,14 +86,13 @@ class Account extends events_1.EventEmitter {
|
|
|
85
86
|
* @param apiClient The apiClient instance to use in the core (will create a new new one if undefined)
|
|
86
87
|
* @param accountOptions
|
|
87
88
|
*/
|
|
88
|
-
constructor(apiClient = new api_client_1.APIClient(), { createStore = () => undefined, nbPrekeys = 2,
|
|
89
|
+
constructor(apiClient = new api_client_1.APIClient(), { createStore = () => undefined, nbPrekeys = 2, mlsConfig } = {}) {
|
|
89
90
|
super();
|
|
90
91
|
this.apiClient = apiClient;
|
|
91
92
|
this.backendFeatures = this.apiClient.backendFeatures;
|
|
92
|
-
this.
|
|
93
|
+
this.mlsConfig = this.mlsConfig;
|
|
93
94
|
this.nbPrekeys = nbPrekeys;
|
|
94
95
|
this.createStore = createStore;
|
|
95
|
-
this.enableMLS = enableMLS;
|
|
96
96
|
apiClient.on(api_client_1.APIClient.TOPIC.COOKIE_REFRESH, async (cookie) => {
|
|
97
97
|
if (cookie && this.storeEngine) {
|
|
98
98
|
try {
|
|
@@ -259,17 +259,17 @@ class Account extends events_1.EventEmitter {
|
|
|
259
259
|
const loadedClient = await this.service.client.getLocalClient();
|
|
260
260
|
await this.apiClient.api.client.getClient(loadedClient.id);
|
|
261
261
|
this.apiClient.context.clientId = loadedClient.id;
|
|
262
|
-
if (this.
|
|
263
|
-
this.coreCryptoClient = await this.createMLSClient(loadedClient, this.apiClient.context);
|
|
262
|
+
if (this.mlsConfig) {
|
|
263
|
+
this.coreCryptoClient = await this.createMLSClient(loadedClient, this.apiClient.context, this.mlsConfig);
|
|
264
264
|
}
|
|
265
265
|
return loadedClient;
|
|
266
266
|
}
|
|
267
|
-
async createMLSClient(client, context) {
|
|
267
|
+
async createMLSClient(client, context, mlsConfig) {
|
|
268
268
|
const coreCryptoKeyId = 'corecrypto-key';
|
|
269
269
|
const { CoreCrypto } = await Promise.resolve().then(() => __importStar(require('@otak/core-crypto')));
|
|
270
270
|
const dbName = `secrets-${this.generateDbName(context)}`;
|
|
271
|
-
const secretStore =
|
|
272
|
-
? await (0, encryptedStore_1.createCustomEncryptedStore)(dbName,
|
|
271
|
+
const secretStore = mlsConfig.secretsCrypto
|
|
272
|
+
? await (0, encryptedStore_1.createCustomEncryptedStore)(dbName, mlsConfig.secretsCrypto)
|
|
273
273
|
: await (0, encryptedStore_1.createEncryptedStore)(dbName);
|
|
274
274
|
let key = await secretStore.getsecretValue(coreCryptoKeyId);
|
|
275
275
|
if (!key) {
|
|
@@ -278,8 +278,8 @@ class Account extends events_1.EventEmitter {
|
|
|
278
278
|
}
|
|
279
279
|
const { userId, domain } = this.apiClient.context;
|
|
280
280
|
return CoreCrypto.init({
|
|
281
|
-
path:
|
|
282
|
-
key:
|
|
281
|
+
path: `corecrypto-${this.generateDbName(context)}`,
|
|
282
|
+
key: bazinga64_1.Encoder.toBase64(key).asString,
|
|
283
283
|
clientId: `${userId}:${client.id}@${domain}`,
|
|
284
284
|
});
|
|
285
285
|
}
|
|
@@ -287,10 +287,10 @@ class Account extends events_1.EventEmitter {
|
|
|
287
287
|
if (!this.service) {
|
|
288
288
|
throw new Error('Services are not set.');
|
|
289
289
|
}
|
|
290
|
-
this.logger.info(`Creating new client {mls: ${!!this.
|
|
290
|
+
this.logger.info(`Creating new client {mls: ${!!this.mlsConfig}}`);
|
|
291
291
|
const registeredClient = await this.service.client.register(loginData, clientInfo, entropyData);
|
|
292
|
-
if (this.
|
|
293
|
-
this.coreCryptoClient = await this.createMLSClient(registeredClient, this.apiClient.context);
|
|
292
|
+
if (this.mlsConfig) {
|
|
293
|
+
this.coreCryptoClient = await this.createMLSClient(registeredClient, this.apiClient.context, this.mlsConfig);
|
|
294
294
|
await this.service.client.uploadMLSPublicKeys(this.coreCryptoClient.clientPublicKey(), registeredClient.id);
|
|
295
295
|
await this.service.client.uploadMLSKeyPackages(this.coreCryptoClient.clientKeypackages(this.nbPrekeys), registeredClient.id);
|
|
296
296
|
}
|