Support for running proof check on client side

This commit is contained in:
N-Pex 2025-09-05 13:48:52 +02:00
parent 66eef037e0
commit 46479d4c37
6 changed files with 126 additions and 29 deletions

View file

@ -28,6 +28,20 @@ class ProofMode {
const worker = await this.getProofcheckWorker();
const res = await worker.checkFiles([file]);
if (res && res.files && res.files.length == 1) {
delete res.files[0].data; // Don't need to hang on to the data!
return res.files[0];
}
} catch (error) {
}
return undefined;
}
async proofCheckSource(src: string): Promise<ProofCheckResult | undefined> {
try {
const worker = await this.getProofcheckWorker();
const res = await worker.checkURLs([src]);
if (res && res.files && res.files.length == 1) {
delete res.files[0].data; // Don't need to hang on to the data!
return res.files[0];
}
} catch (error) {
@ -35,4 +49,6 @@ class ProofMode {
return undefined;
}
}
export default new ProofMode();

View file

@ -1,6 +1,6 @@
import { Observable, Subject } from "threads/observable";
import { expose } from "threads/worker";
import { checkFiles } from "@guardianproject/proofmode";
import { checkFiles, checkURLs } from "@guardianproject/proofmode";
let subject = new Subject();
@ -12,6 +12,9 @@ const check = {
checkFiles: (files) => {
return checkFiles(files, sendMessage);
},
checkURLs: (urls) => {
return checkURLs(urls, sendMessage);
},
values: () => {
return Observable.from(subject);
},