Run storage service on link
This commit is contained in:
parent
3050a314f9
commit
08eb4fc168
3 changed files with 19 additions and 1 deletions
|
@ -1368,6 +1368,7 @@ export async function startApp(): Promise<void> {
|
||||||
|
|
||||||
async function runStorageService() {
|
async function runStorageService() {
|
||||||
StorageService.enableStorageService();
|
StorageService.enableStorageService();
|
||||||
|
StorageService.runStorageServiceSyncJob();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function start() {
|
async function start() {
|
||||||
|
|
|
@ -14,6 +14,7 @@ import {
|
||||||
encryptProfile,
|
encryptProfile,
|
||||||
decryptProfile,
|
decryptProfile,
|
||||||
deriveMasterKeyFromGroupV1,
|
deriveMasterKeyFromGroupV1,
|
||||||
|
deriveStorageServiceKey,
|
||||||
} from '../Crypto';
|
} from '../Crypto';
|
||||||
import {
|
import {
|
||||||
mergeAccountRecord,
|
mergeAccountRecord,
|
||||||
|
@ -1725,7 +1726,18 @@ async function sync(
|
||||||
ignoreConflicts = false
|
ignoreConflicts = false
|
||||||
): Promise<Proto.ManifestRecord | undefined> {
|
): Promise<Proto.ManifestRecord | undefined> {
|
||||||
if (!window.storage.get('storageKey')) {
|
if (!window.storage.get('storageKey')) {
|
||||||
throw new Error('storageService.sync: Cannot start; no storage key!');
|
const masterKeyBase64 = window.storage.get('masterKey');
|
||||||
|
if (!masterKeyBase64) {
|
||||||
|
throw new Error(
|
||||||
|
'storageService.sync: Cannot start; no storage or master key!'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const masterKey = Bytes.fromBase64(masterKeyBase64);
|
||||||
|
const storageKeyBase64 = Bytes.toBase64(deriveStorageServiceKey(masterKey));
|
||||||
|
await window.storage.put('storageKey', storageKeyBase64);
|
||||||
|
|
||||||
|
log.warn('storageService.sync: fixed storage key');
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info(
|
log.info(
|
||||||
|
|
|
@ -32,6 +32,7 @@ import {
|
||||||
getRandomBytes,
|
getRandomBytes,
|
||||||
decryptDeviceName,
|
decryptDeviceName,
|
||||||
encryptDeviceName,
|
encryptDeviceName,
|
||||||
|
deriveStorageServiceKey,
|
||||||
} from '../Crypto';
|
} from '../Crypto';
|
||||||
import {
|
import {
|
||||||
generateKeyPair,
|
generateKeyPair,
|
||||||
|
@ -1237,6 +1238,10 @@ export default class AccountManager extends EventTarget {
|
||||||
}
|
}
|
||||||
if (masterKey) {
|
if (masterKey) {
|
||||||
await storage.put('masterKey', Bytes.toBase64(masterKey));
|
await storage.put('masterKey', Bytes.toBase64(masterKey));
|
||||||
|
await storage.put(
|
||||||
|
'storageKey',
|
||||||
|
Bytes.toBase64(deriveStorageServiceKey(masterKey))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
await storage.put('read-receipt-setting', Boolean(readReceipts));
|
await storage.put('read-receipt-setting', Boolean(readReceipts));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue