diff --git a/web/database/database-module-provider.js b/web/database/database-module-provider.js --- a/web/database/database-module-provider.js +++ b/web/database/database-module-provider.js @@ -41,7 +41,7 @@ } } - init() { + init(encryptionKey?: ?SubtleCrypto$JsonWebKey) { this.status = databaseStatuses.initInProgress; this.worker = new SharedWorker(DATABASE_WORKER_PATH); this.worker.onerror = console.error; @@ -58,6 +58,7 @@ type: workerRequestMessageTypes.INIT, sqljsFilePath: `${origin}${SQLJS_FILE_PATH}`, sqljsFilename, + encryptionKey, }); this.status = databaseStatuses.initSuccess; console.info('Database initialization success'); @@ -68,7 +69,10 @@ })(); } - initDBForLoggedInUser(currentLoggedInUserID: ?string) { + initDBForLoggedInUser( + currentLoggedInUserID: ?string, + encryptionKey?: ?SubtleCrypto$JsonWebKey, + ) { if (this.status === databaseStatuses.initSuccess) { return; } @@ -77,7 +81,7 @@ this.status === databaseStatuses.notSupported && isSQLiteSupported(currentLoggedInUserID) ) { - this.init(); + this.init(encryptionKey); } } diff --git a/web/types/worker-types.js b/web/types/worker-types.js --- a/web/types/worker-types.js +++ b/web/types/worker-types.js @@ -36,6 +36,7 @@ +type: 1, +sqljsFilePath: string, +sqljsFilename: ?string, + +encryptionKey?: ?SubtleCrypto$JsonWebKey, }; export type GenerateDatabaseEncryptionKeyRequestMessage = {