Send progress in main view

This commit is contained in:
N-Pex 2025-08-20 15:12:04 +02:00
parent 41232fbd90
commit e9accdebf1
11 changed files with 465 additions and 86 deletions

View file

@ -53,6 +53,72 @@ export type Proof = {
data?: any;
name?: string;
json?: string;
integrity?: { pgp?: any; c2pa?: any; exif?: {[key: string]: string | Object}; opentimestamps?: any };
integrity?: { pgp?: any; c2pa?: C2PAData; exif?: {[key: string]: string | Object}; opentimestamps?: any };
ai?: { inferenceResult?: AIInferenceResult};
}
export type ProofHintFlags = {
aiGenerated?: boolean;
aiEdited?: boolean;
screenshot?: boolean;
camera?: boolean;
}
export const extractProofHintFlags = (proof?: Proof): (ProofHintFlags | undefined) => {
if (!proof) return undefined;
let screenshot = false;
let camera = false;
let aiGenerated = false;
let aiEdited = false;
let valid = false;
try {
let results = proof.integrity?.c2pa?.manifest_info.validation_results?.activeManifest;
if (results) {
valid = results.failure.length == 0 && results.success.length > 0;
}
const manifests = Object.values(proof.integrity?.c2pa?.manifest_info.manifests ?? {});
for (const manifest of manifests) {
for (const assertion of manifest.assertions) {
if (assertion.label === "c2pa.actions") {
const actions = (assertion.data as C2PAActionsAssertion)?.actions ?? [];
const a = actions.find((a) => a.action === "c2pa.created");
if (a) {
// creator.value = a.softwareAgent;
// dateCreated.value = dayjs(Date.parse(manifest.signature_info.time));
if (a.digitalSourceType === C2PASourceTypeScreenCapture) {
screenshot = true;
}
if (
a.digitalSourceType === C2PASourceTypeDigitalCapture ||
a.digitalSourceType === C2PASourceTypeComputationalCapture ||
a.digitalSourceType === C2PASourceTypeCompositeCapture
) {
camera = true;
}
if (
a.digitalSourceType === C2PASourceTypeTrainedAlgorithmicMedia ||
a.digitalSourceType === C2PASourceTypeCompositeWithTrainedAlgorithmicMedia
) {
aiGenerated = true;
}
return;
}
}
}
}
if (valid) {
const flags: ProofHintFlags = {
aiGenerated,
aiEdited,
screenshot,
camera
};
return flags;
}
} catch (error) {
}
return undefined;
};