@wireapp/core 46.29.0 → 46.29.2
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
|
-
*
|
|
60
|
-
*
|
|
61
|
-
* If
|
|
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 (
|
|
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,
|
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.
|
|
14
|
+
"@wireapp/api-client": "^27.66.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.29.
|
|
65
|
-
"gitHead": "
|
|
64
|
+
"version": "46.29.2",
|
|
65
|
+
"gitHead": "f8ef71b6324ed285409374a561e822127f488163"
|
|
66
66
|
}
|