Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3392687
D11042.id37333.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
7 KB
Referenced Files
None
Subscribers
None
D11042.id37333.diff
View Options
diff --git a/keyserver/src/responders/website-responders.js b/keyserver/src/responders/website-responders.js
--- a/keyserver/src/responders/website-responders.js
+++ b/keyserver/src/responders/website-responders.js
@@ -44,6 +44,7 @@
+olmFilename: string,
+commQueryExecutorFilename: string,
+opaqueURL: string,
+ +backupClientFilename: string,
};
let assetInfo: ?AssetInfo = null;
async function getAssetInfo() {
@@ -59,6 +60,7 @@
olmFilename: '',
commQueryExecutorFilename: '',
opaqueURL: 'http://localhost:8080/opaque-ke.wasm',
+ backupClientFilename: '',
};
return assetInfo;
}
@@ -83,6 +85,7 @@
olmFilename: manifest['olm.wasm'],
commQueryExecutorFilename: webworkersManifest['comm_query_executor.wasm'],
opaqueURL: `compiled/${manifest['comm_opaque2_wasm_bg.wasm']}`,
+ backupClientFilename: webworkersManifest['backup-client-wasm_bg.wasm'],
};
return assetInfo;
} catch {
@@ -134,6 +137,7 @@
olmFilename,
opaqueURL,
commQueryExecutorFilename,
+ backupClientFilename,
} = await assetInfoPromise;
// prettier-ignore
@@ -185,6 +189,7 @@
var baseURL = "${baseURL}";
var olmFilename = "${olmFilename}";
var commQueryExecutorFilename = "${commQueryExecutorFilename}";
+ var backupClientFilename = "${backupClientFilename}";
var opaqueURL = "${opaqueURL}";
</script>
<script src="${jsURL}"></script>
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
@@ -24,6 +24,8 @@
declare var baseURL: string;
declare var commQueryExecutorFilename: string;
+declare var backupClientFilename: string;
+
const databaseStatuses = Object.freeze({
notRunning: 'NOT_RUNNING',
initSuccess: 'INIT_SUCCESS',
@@ -90,9 +92,10 @@
invariant(this.workerProxy, 'Worker proxy should exist');
await this.workerProxy.scheduleOnWorker({
type: workerRequestMessageTypes.INIT,
- databaseModuleFilePath: `${origin}${baseURL}${WORKERS_MODULES_DIR_PATH}`,
+ webworkerModulesFilePath: `${origin}${baseURL}${WORKERS_MODULES_DIR_PATH}`,
encryptionKey,
commQueryExecutorFilename,
+ backupClientFilename,
});
this.status = { type: databaseStatuses.initSuccess };
console.info('Database initialization success');
diff --git a/web/database/db-module.js b/web/database/db-module.js
--- a/web/database/db-module.js
+++ b/web/database/db-module.js
@@ -6,7 +6,7 @@
function getDatabaseModule(
databaseModuleFilename?: ?string,
- databaseModuleFilePath?: string,
+ webworkerModulesFilePath?: string,
): EmscriptenModule {
const fileName = databaseModuleFilename
? databaseModuleFilename
@@ -14,8 +14,8 @@
return Module({
locateFile: (path: string, prefix?: string) => {
- if (databaseModuleFilePath) {
- return `${databaseModuleFilePath}/${fileName}`;
+ if (webworkerModulesFilePath) {
+ return `${webworkerModulesFilePath}/${fileName}`;
}
return `${prefix ?? ''}${fileName}`;
},
diff --git a/web/database/utils/constants.js b/web/database/utils/constants.js
--- a/web/database/utils/constants.js
+++ b/web/database/utils/constants.js
@@ -11,6 +11,7 @@
export const WORKERS_MODULES_DIR_PATH = '/compiled/webworkers';
export const DEFAULT_COMM_QUERY_EXECUTOR_FILENAME = 'comm_query_executor.wasm';
+export const DEFAULT_BACKUP_CLIENT_FILENAME = 'backup-client-wasm_bg.wasm';
export const DEFAULT_OLM_FILENAME = 'olm.wasm';
diff --git a/web/database/worker/db-worker.js b/web/database/worker/db-worker.js
--- a/web/database/worker/db-worker.js
+++ b/web/database/worker/db-worker.js
@@ -6,6 +6,7 @@
getClientStoreFromQueryExecutor,
processDBStoreOperations,
} from './process-operations.js';
+import initBackupClientModule from '../../backup-client-wasm/wasm/backup-client-wasm.js';
import {
decryptData,
encryptData,
@@ -31,6 +32,7 @@
localforageConfig,
SQLITE_CONTENT,
SQLITE_ENCRYPTION_KEY,
+ DEFAULT_BACKUP_CLIENT_FILENAME,
} from '../utils/constants.js';
import {
clearSensitiveData,
@@ -49,7 +51,7 @@
let persistInProgress: boolean = false;
async function initDatabase(
- databaseModuleFilePath: string,
+ webworkerModulesFilePath: string,
commQueryExecutorFilename: ?string,
encryptionKeyJWK?: ?SubtleCrypto$JsonWebKey,
) {
@@ -60,7 +62,7 @@
const newModule = dbModule
? dbModule
- : getDatabaseModule(commQueryExecutorFilename, databaseModuleFilePath);
+ : getDatabaseModule(commQueryExecutorFilename, webworkerModulesFilePath);
if (!dbModule) {
dbModule = newModule;
}
@@ -102,6 +104,19 @@
);
}
+async function initBackupClient(
+ webworkerModulesFilePath: string,
+ backupClientFilename: ?string,
+) {
+ let modulePath;
+ if (!!backupClientFilename && backupClientFilename.length > 0) {
+ modulePath = `${webworkerModulesFilePath}/${backupClientFilename}`;
+ } else {
+ modulePath = `${webworkerModulesFilePath}/${DEFAULT_BACKUP_CLIENT_FILENAME}`;
+ }
+ await initBackupClientModule(modulePath);
+}
+
async function persist() {
persistInProgress = true;
const module = dbModule;
@@ -148,11 +163,23 @@
// database operations
if (message.type === workerRequestMessageTypes.INIT) {
- await initDatabase(
- message.databaseModuleFilePath,
- message.commQueryExecutorFilename,
- message.encryptionKey,
+ const promises = [];
+ promises.push(
+ initDatabase(
+ message.webworkerModulesFilePath,
+ message.commQueryExecutorFilename,
+ message.encryptionKey,
+ ),
);
+ if (message.backupClientFilename !== undefined) {
+ promises.push(
+ initBackupClient(
+ message.webworkerModulesFilePath,
+ message.backupClientFilename,
+ ),
+ );
+ }
+ await Promise.all(promises);
return undefined;
} else if (message.type === workerRequestMessageTypes.CLEAR_SENSITIVE_DATA) {
encryptionKey = null;
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
@@ -34,9 +34,10 @@
export type InitWorkerRequestMessage = {
+type: 1,
- +databaseModuleFilePath: string,
+ +webworkerModulesFilePath: string,
+commQueryExecutorFilename: ?string,
+encryptionKey?: ?SubtleCrypto$JsonWebKey,
+ +backupClientFilename?: ?string,
};
export type GenerateDatabaseEncryptionKeyRequestMessage = {
diff --git a/web/webpack.config.cjs b/web/webpack.config.cjs
--- a/web/webpack.config.cjs
+++ b/web/webpack.config.cjs
@@ -152,6 +152,14 @@
},
],
}),
+ new CopyPlugin({
+ patterns: [
+ {
+ from: 'backup-client-wasm/wasm/backup-client-wasm_bg.wasm',
+ to: path.join(__dirname, 'dist', 'webworkers'),
+ },
+ ],
+ }),
];
const prodWebWorkersPlugins = [
@@ -181,6 +189,19 @@
},
],
}),
+ new CopyPlugin({
+ patterns: [
+ {
+ from: 'backup-client-wasm/wasm/backup-client-wasm_bg.wasm',
+ to: path.join(
+ __dirname,
+ 'dist',
+ 'webworkers',
+ 'backup-client.[contenthash:12].wasm',
+ ),
+ },
+ ],
+ }),
new WebpackManifestPlugin({
publicPath: '',
}),
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 1, 9:50 AM (20 h, 16 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2604618
Default Alt Text
D11042.id37333.diff (7 KB)
Attached To
Mode
D11042: [web] Import backup client
Attached
Detach File
Event Timeline
Log In to Comment