feat(io): add user-approved recovery
This commit is contained in:
parent
25515fa33c
commit
9e90e50662
25 changed files with 2723 additions and 198 deletions
|
|
@ -1,14 +1,23 @@
|
|||
import init, { parse_document } from "./worker_pkg/ocs_web_worker.js";
|
||||
import init, { parse_document, sha256_document } from "./worker_pkg/ocs_web_worker.js?v=3";
|
||||
|
||||
const ready = init();
|
||||
const ready = init(
|
||||
new URL("./worker_pkg/ocs_web_worker_bg.wasm?v=3", import.meta.url),
|
||||
);
|
||||
|
||||
self.onmessage = async ({ data }) => {
|
||||
let stage = "initialize worker";
|
||||
try {
|
||||
await ready;
|
||||
if (data.action === "hash") {
|
||||
const digest = sha256_document(new Uint8Array(data.bytes));
|
||||
self.postMessage({ ok: true, digest });
|
||||
return;
|
||||
}
|
||||
const encoded = parse_document(
|
||||
data.name,
|
||||
new Uint8Array(data.bytes),
|
||||
data.recoveryMode === true,
|
||||
data.initialError || "",
|
||||
(next) => {
|
||||
stage = next;
|
||||
},
|
||||
|
|
@ -21,9 +30,7 @@ self.onmessage = async ({ data }) => {
|
|||
} catch (error) {
|
||||
self.postMessage({
|
||||
ok: false,
|
||||
error: `${stage}: ${
|
||||
error instanceof Error ? error.stack || error.message : String(error)
|
||||
}`,
|
||||
error: `${stage}: ${error instanceof Error ? error.message : String(error)}`,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue