mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-08-29 10:09:26 +02:00
core: add logs to diagnose why decryption fails after changing password (#10139)
This commit is contained in:
@@ -387,6 +387,10 @@ export class Sync {
|
||||
const itemsToDecrypt = itemsByKeyVersion.get(keyInfo.version);
|
||||
if (!itemsToDecrypt || itemsToDecrypt.length === 0) continue;
|
||||
|
||||
this.logger.info("Decrypting using key", {
|
||||
keyInfo: keyInfo.version,
|
||||
items: itemsToDecrypt.length
|
||||
});
|
||||
decrypted.push(
|
||||
...(await this.db.storage().decryptMulti(keyInfo.key, itemsToDecrypt))
|
||||
);
|
||||
|
||||
@@ -404,11 +404,13 @@ class UserManager {
|
||||
{ version: KeyVersion; key: SerializedKey }[] | undefined
|
||||
> {
|
||||
const masterKey = await this.getMasterKey();
|
||||
logger.info("master key exists: ", { masterKey: !!masterKey });
|
||||
if (!masterKey) return;
|
||||
|
||||
const dataEncryptionKey = await this.keyManager.get("dataEncryptionKey", {
|
||||
refetchUser: false
|
||||
});
|
||||
logger.info("DEK exists: ", { dataEncryptionKey: !!dataEncryptionKey });
|
||||
if (!dataEncryptionKey)
|
||||
return [
|
||||
{
|
||||
@@ -424,6 +426,9 @@ class UserManager {
|
||||
refetchUser: false
|
||||
}
|
||||
);
|
||||
logger.info("legacy DEK exists: ", {
|
||||
legacyDataEncryptionKey: !!legacyDataEncryptionKey
|
||||
});
|
||||
if (legacyDataEncryptionKey)
|
||||
keys.push({
|
||||
key: await this.keyManager.unwrapKey(
|
||||
@@ -436,6 +441,10 @@ class UserManager {
|
||||
key: await this.keyManager.unwrapKey(dataEncryptionKey, masterKey),
|
||||
version: KEY_VERSION.DEK
|
||||
});
|
||||
logger.info("Keys:", {
|
||||
keys: keys.length,
|
||||
keyVersions: keys.map((k) => k.version)
|
||||
});
|
||||
return keys;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user