@wireapp/core 30.1.0 → 30.2.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 CHANGED
@@ -3,6 +3,17 @@
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
+ # [30.2.0](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@30.1.0...@wireapp/core@30.2.0) (2022-09-07)
7
+
8
+
9
+ ### Features
10
+
11
+ * Also create MLS device when logging in with old proteus device ([#4378](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/issues/4378)) ([31cea5a](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/commit/31cea5a31ac69ffb269f33458896d091de6c171f))
12
+
13
+
14
+
15
+
16
+
6
17
  # [30.1.0](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@30.0.5...@wireapp/core@30.1.0) (2022-09-07)
7
18
 
8
19
 
package/package.json CHANGED
@@ -77,6 +77,6 @@
77
77
  "test:node": "nyc jasmine --config=jasmine.json",
78
78
  "watch": "tsc ---watch"
79
79
  },
80
- "version": "30.1.0",
81
- "gitHead": "1d1db30fe5778628cd7b550a0d94891c18792236"
80
+ "version": "30.2.0",
81
+ "gitHead": "d61be6b02a9009a232f74e73a87963092ccf5a30"
82
82
  }
@@ -269,6 +269,9 @@ class Account extends events_1.EventEmitter {
269
269
  return loadedClient;
270
270
  }
271
271
  async createMLSClient(client, context, mlsConfig, entropyData) {
272
+ if (!this.service) {
273
+ throw new Error('Services are not set.');
274
+ }
272
275
  const coreCryptoKeyId = 'corecrypto-key';
273
276
  const { CoreCrypto } = await Promise.resolve().then(() => __importStar(require('@otak/core-crypto')));
274
277
  const dbName = this.generateSecretsDbName(context);
@@ -276,18 +279,27 @@ class Account extends events_1.EventEmitter {
276
279
  ? await (0, encryptedStore_1.createCustomEncryptedStore)(dbName, mlsConfig.secretsCrypto)
277
280
  : await (0, encryptedStore_1.createEncryptedStore)(dbName);
278
281
  let key = await secretStore.getsecretValue(coreCryptoKeyId);
282
+ let isNewMLSDevice = false;
279
283
  if (!key) {
280
284
  key = window.crypto.getRandomValues(new Uint8Array(16));
281
285
  await secretStore.saveSecretValue(coreCryptoKeyId, key);
286
+ // Keeping track that this device is a new MLS device (but can be an old proteus device)
287
+ isNewMLSDevice = true;
282
288
  }
283
289
  const { userId, domain } = this.apiClient.context;
284
- return CoreCrypto.init({
290
+ const mlsClient = await CoreCrypto.init({
285
291
  databaseName: `corecrypto-${this.generateDbName(context)}`,
286
292
  key: bazinga64_1.Encoder.toBase64(key).asString,
287
293
  clientId: `${userId}:${client.id}@${domain}`,
288
294
  wasmFilePath: mlsConfig.coreCrypoWasmFilePath,
289
295
  entropySeed: entropyData,
290
296
  });
297
+ if (isNewMLSDevice) {
298
+ // If the device is new, we need to upload keypackages and public key to the backend
299
+ await this.service.client.uploadMLSPublicKeys(await mlsClient.clientPublicKey(), client.id);
300
+ await this.service.client.uploadMLSKeyPackages(await mlsClient.clientKeypackages(this.nbPrekeys), client.id);
301
+ }
302
+ return mlsClient;
291
303
  }
292
304
  async registerClient(loginData, clientInfo = coreDefaultClient, entropyData) {
293
305
  if (!this.service) {
@@ -297,8 +309,6 @@ class Account extends events_1.EventEmitter {
297
309
  const registeredClient = await this.service.client.register(loginData, clientInfo, entropyData);
298
310
  if (this.mlsConfig) {
299
311
  this.coreCryptoClient = await this.createMLSClient(registeredClient, this.apiClient.context, this.mlsConfig, entropyData);
300
- await this.service.client.uploadMLSPublicKeys(await this.coreCryptoClient.clientPublicKey(), registeredClient.id);
301
- await this.service.client.uploadMLSKeyPackages(await this.coreCryptoClient.clientKeypackages(this.nbPrekeys), registeredClient.id);
302
312
  }
303
313
  this.apiClient.context.clientId = registeredClient.id;
304
314
  this.logger.info('Client is created');