@wireapp/core 46.28.0 → 46.29.1

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.
@@ -50,24 +50,23 @@ const migrateOnceAndGetKey = async (generateSecretKey, coreCryptoDbName) => {
50
50
  const keyOld = await getKey(generateSecretKey, coreCryptoKeyId, 16);
51
51
  // We retrieve the new key if it exists or generate a new one
52
52
  const keyNew = await getKey(generateSecretKey, coreCryptoNewKeyId, 32);
53
- // If we dont retreive any key, we throw an error
54
- // This should not happen since we generate a new key if it does not exist
55
53
  if (!keyNew || !keyOld) {
54
+ // If we dont retreive any key, we throw an error
55
+ // This should not happen since we generate a new key if it does not exist
56
56
  throw new Error('Key not found and could not be generated');
57
57
  }
58
58
  /**
59
- * If the old key is freshly generated we dont need to migrate and return the new key
60
- * If the old key exists and the new key is freshly generated, we need to migrate and then return the new key (This should only happen once !!!!)
61
- * If the old key exists and the new key exists we return the new key
59
+ * Handles migration and cleanup of encryption keys.
60
+ *
61
+ * - If `keyNew` is freshly generated and `keyOld` is not freshly generated:
62
+ * - Migrate data from `keyOld` to `keyNew`
62
63
  */
63
- if (!keyOld.freshlyGenerated && keyNew.freshlyGenerated) {
64
- // Create the new key in the format used by coreCrypto
64
+ if (keyNew.freshlyGenerated && !keyOld.freshlyGenerated) {
65
65
  const databaseKey = new core_crypto_1.DatabaseKey(keyNew.key);
66
- // Run the migration
67
66
  await (0, core_crypto_1.migrateDatabaseKeyTypeToBytes)(coreCryptoDbName, bazinga64_1.Encoder.toBase64(keyOld.key).asString, databaseKey);
68
- // delete the old key, it will be freshly generated in the next call and ensure we dont run the migration again
69
- await keyOld.deleteKey();
70
67
  }
68
+ // Always clean up the old key
69
+ await keyOld.deleteKey();
71
70
  return {
72
71
  key: new core_crypto_1.DatabaseKey(keyNew.key),
73
72
  deleteKey: keyNew.deleteKey,
@@ -559,7 +559,7 @@ describe('ProteusService', () => {
559
559
  id: '',
560
560
  type: conversation_1.CONVERSATION_TYPE.REGULAR,
561
561
  creator: '',
562
- cells_state: 'disabled',
562
+ cells_state: conversation_1.CONVERSATION_CELLS_STATE.DISABLED,
563
563
  access: [],
564
564
  access_role: [conversation_1.CONVERSATION_ACCESS_ROLE.GUEST],
565
565
  members: {
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "./lib/cryptography/AssetCryptography/crypto.node": "./lib/cryptography/AssetCryptography/crypto.browser.js"
12
12
  },
13
13
  "dependencies": {
14
- "@wireapp/api-client": "^27.64.0",
14
+ "@wireapp/api-client": "^27.65.0",
15
15
  "@wireapp/commons": "^5.4.2",
16
16
  "@wireapp/core-crypto": "7.0.1",
17
17
  "@wireapp/cryptobox": "12.8.0",
@@ -61,6 +61,6 @@
61
61
  "test:coverage": "jest --coverage",
62
62
  "watch": "tsc --watch"
63
63
  },
64
- "version": "46.28.0",
65
- "gitHead": "ce17f11c034dd96498c9e8a6a7da16044e669ff6"
64
+ "version": "46.29.1",
65
+ "gitHead": "6b802b2fef0ce58ce62913bc808297670aa3013d"
66
66
  }