1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-07-16 00:14:34 +02:00

Chore: Convert E2EE related files to TypeScript

This commit is contained in:
Laurent Cozic
2021-08-07 12:22:37 +01:00
parent 3fb77c4e37
commit c3f10d31cb
21 changed files with 237 additions and 158 deletions

View File

@ -9,6 +9,13 @@ import KvStore from './KvStore';
const EventEmitter = require('events');
interface DecryptionResult {
skippedItemCount?: number;
decryptedItemCounts?: number;
decryptedItemCount?: number;
error: any;
}
export default class DecryptionWorker {
public static instance_: DecryptionWorker = null;
@ -107,7 +114,7 @@ export default class DecryptionWorker {
this.dispatch(action);
}
async start_(options: any = null) {
private async start_(options: any = null): Promise<DecryptionResult> {
if (options === null) options = {};
if (!('masterKeyNotLoadedHandler' in options)) options.masterKeyNotLoadedHandler = 'throw';
if (!('errorHandler' in options)) options.errorHandler = 'log';
@ -260,10 +267,11 @@ export default class DecryptionWorker {
let decryptedItemCount = 0;
for (const itemType in decryptedItemCounts) decryptedItemCount += decryptedItemCounts[itemType];
const finalReport = {
const finalReport: DecryptionResult = {
skippedItemCount: skippedItemCount,
decryptedItemCounts: decryptedItemCounts,
decryptedItemCount: decryptedItemCount,
error: null,
};
this.dispatchReport(Object.assign({}, finalReport, { state: 'idle' }));
@ -276,7 +284,7 @@ export default class DecryptionWorker {
return finalReport;
}
async start(options: any) {
public async start(options: any = {}) {
this.startCalls_.push(true);
let output = null;
try {