@vrtmrz/livesync-commonlib 0.1.30 → 0.1.31
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.
|
@@ -110,6 +110,8 @@ export declare abstract class SettingService<T extends ServiceContext = ServiceC
|
|
|
110
110
|
clearUsedPassphrase(): void;
|
|
111
111
|
decryptConfigurationItem(encrypted: string, passphrase: string): Promise<string | false>;
|
|
112
112
|
encryptConfigurationItem(src: string, settings: ObsidianLiveSyncSettings): Promise<string>;
|
|
113
|
+
private encryptPlainConfigurationItem;
|
|
114
|
+
private encryptConfigurationItemWith;
|
|
113
115
|
/**
|
|
114
116
|
* Decrypt the given settings.
|
|
115
117
|
* @param settings The settings to decrypt.
|
|
@@ -13,6 +13,7 @@ import { ServiceBase } from "./ServiceBase.js";
|
|
|
13
13
|
import { createInstanceLogFunction } from "../lib/logUtils.js";
|
|
14
14
|
import { isCloudantURI } from "../../pouchdb/utils_couchdb.js";
|
|
15
15
|
import { decryptString, encryptString } from "../../encryption/stringEncryption.js";
|
|
16
|
+
import { encryptWithEphemeralSalt } from "octagonal-wheels/encryption/hkdf";
|
|
16
17
|
import {
|
|
17
18
|
activateP2PRemoteConfiguration,
|
|
18
19
|
activateRemoteConfiguration,
|
|
@@ -207,7 +208,7 @@ class SettingService extends ServiceBase {
|
|
|
207
208
|
settings.endpoint = "";
|
|
208
209
|
}
|
|
209
210
|
if (settings.encrypt && settings.passphrase != "") {
|
|
210
|
-
settings.encryptedPassphrase = await this.
|
|
211
|
+
settings.encryptedPassphrase = await this.encryptPlainConfigurationItem(settings.passphrase, settings);
|
|
211
212
|
settings.passphrase = "";
|
|
212
213
|
}
|
|
213
214
|
await this.encryptRemoteConfigurationUris(settings);
|
|
@@ -405,8 +406,14 @@ class SettingService extends ServiceBase {
|
|
|
405
406
|
return false;
|
|
406
407
|
}
|
|
407
408
|
async encryptConfigurationItem(src, settings) {
|
|
409
|
+
return this.encryptConfigurationItemWith(src, settings, encryptString);
|
|
410
|
+
}
|
|
411
|
+
async encryptPlainConfigurationItem(src, settings) {
|
|
412
|
+
return this.encryptConfigurationItemWith(src, settings, encryptWithEphemeralSalt);
|
|
413
|
+
}
|
|
414
|
+
async encryptConfigurationItemWith(src, settings, encrypt) {
|
|
408
415
|
if (this.usedPassphrase != "") {
|
|
409
|
-
return await
|
|
416
|
+
return await encrypt(src, this.usedPassphrase + SALT_OF_PASSPHRASE);
|
|
410
417
|
}
|
|
411
418
|
const passphrase = await this.getPassphrase(settings);
|
|
412
419
|
if (passphrase === false) {
|
|
@@ -416,7 +423,7 @@ class SettingService extends ServiceBase {
|
|
|
416
423
|
);
|
|
417
424
|
return "";
|
|
418
425
|
}
|
|
419
|
-
const dec = await
|
|
426
|
+
const dec = await encrypt(src, passphrase + SALT_OF_PASSPHRASE);
|
|
420
427
|
if (dec) {
|
|
421
428
|
this.usedPassphrase = passphrase;
|
|
422
429
|
return dec;
|
package/package.json
CHANGED