1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-07-13 00:10:37 +02:00

All: Add support for public-private key pairs and improved master password support (#5438)

Also improved SCSS support, which was needed for the master password dialog.
This commit is contained in:
Laurent
2021-10-03 16:00:49 +01:00
committed by GitHub
parent e5e1382255
commit c758377188
72 changed files with 4495 additions and 5296 deletions

View File

@ -57,9 +57,11 @@ import { loadKeychainServiceAndSettings } from '../services/SettingUtils';
import { setActiveMasterKeyId, setEncryptionEnabled } from '../services/synchronizer/syncInfoUtils';
import Synchronizer from '../Synchronizer';
import SyncTargetNone from '../SyncTargetNone';
import { setRSA } from '../services/e2ee/ppk';
const md5 = require('md5');
const S3 = require('aws-sdk/clients/s3');
const { Dirnames } = require('../services/synchronizer/utils/types');
import RSA from '../services/e2ee/RSA.node';
// Each suite has its own separate data and temp directory so that multiple
// suites can be run at the same time. suiteName is what is used to
@ -436,6 +438,8 @@ async function setupDatabaseAndSynchronizer(id: number, options: any = null) {
resourceFetchers_[id] = new ResourceFetcher(() => { return synchronizers_[id].api(); });
kvStores_[id] = new KvStore();
setRSA(RSA);
await fileApi().initialize();
await fileApi().clearRoot();
}
@ -505,11 +509,12 @@ function resourceFetcher(id: number = null) {
async function loadEncryptionMasterKey(id: number = null, useExisting = false) {
const service = encryptionService(id);
const password = '123456';
let masterKey = null;
if (!useExisting) { // Create it
masterKey = await service.generateMasterKey('123456');
masterKey = await service.generateMasterKey(password);
masterKey = await MasterKey.save(masterKey);
} else { // Use the one already available
const masterKeys = await MasterKey.all();
@ -517,7 +522,12 @@ async function loadEncryptionMasterKey(id: number = null, useExisting = false) {
masterKey = masterKeys[0];
}
await service.loadMasterKey(masterKey, '123456', true);
const passwordCache = Setting.value('encryption.passwordCache');
passwordCache[masterKey.id] = password;
Setting.setValue('encryption.passwordCache', passwordCache);
await Setting.saveAll();
await service.loadMasterKey(masterKey, password, true);
setActiveMasterKeyId(masterKey.id);