/** * @copyright * (c) 2025 netTrek GmbH & Co. KG – All rights reserved. * * This source code is part of the C2PA-HLS integration library. */ import { type Action, type Manifest, type ManifestStore, type ValidationStatus, type ValidationState, type Reader } from '@contentauth/c2pa-web'; import { type GenerativeContentLevel } from './utils/containsGenerativeContent'; export { type GenerativeContentLevel } from './utils/containsGenerativeContent'; /** * Represents the validation status of a C2PA manifest. */ export interface C2PAValidationStatus { code: string; url?: string; explanation?: string; } /** * Enumeration for selecting formatted display values from a manifest. */ export declare enum C2paFormatedItemType { ISSUER = 0, DATE = 1, VALIDATION_STATUS = 2 } /** * A single training / data-mining usage permission, drawn from the CAWG * `cawg.training-mining` assertion (or the legacy `c2pa.training-mining`). * * See {@link https://cawg.io/training-and-data-mining/1.1/}. */ export interface TrainingMiningEntry { /** The usage category key, e.g. `cawg.ai_generative_training` or the legacy `c2pa.*` form. */ key: string; /** Whether the use is permitted. Standard values: `allowed`, `notAllowed`, `constrained`. */ use: string; /** Free-text constraint description; present when `use` is `constrained`. */ constraintInfo?: string; } /** * A normalized creator/author entry, sourced from the schema.org CreativeWork * assertion (typed) or CAWG-era metadata assertions (`cawg.metadata` / `stds.iptc`). */ export interface Creator { name: string; /** schema.org `@type` (`Organization` | `Person`) when known, otherwise `undefined`. */ type?: string; } /** * A verified identity declared by the CAWG identity assertion (`cawg.identity`). * * See {@link https://cawg.io/identity/}. */ export interface VerifiedIdentity { /** Display name of the verified identity (person, account holder, or signer). */ name: string; /** * The kind of identity, e.g. `cawg.social_media` / `cawg.document_verification` * for an ICA verifiable credential, or `cawg.x509.cose` when the identity is * derived from the signing certificate issuer. */ type?: string; /** Identity-provider name, e.g. `linkedin`, when reported (ICA form only). */ provider?: string; /** Public URI for the identity (e.g. a social profile), when reported. */ uri?: string; } /** * A reference to a binary resource (e.g. a thumbnail) in the manifest store, * resolvable to bytes via {@link C2paManifestHelper.getResourceDataUrl}. */ export interface ResourceThumbnail { /** JUMBF URI of the resource within the store. */ identifier: string; /** MIME type of the resource, e.g. `image/jpeg`. */ format: string; } /** * An ingredient placed into a manifest via a `c2pa.placed` action, resolved to * display info. See {@link C2paManifestHelper.getPlacedIngredients}. */ export interface PlacedIngredient { /** Ingredient title, falling back to the source manifest's title; `null` if unknown. */ title: string | null; /** Ingredient MIME type, falling back to the source manifest's format; `null` if unknown. */ format: string | null; /** The ingredient relationship (`parentOf` | `componentOf` | `inputTo`) when reported. */ relationship?: string; /** A representative thumbnail for the placed ingredient, when one is resolvable. */ thumbnail?: ResourceThumbnail | null; /** * Store key (label) of the ingredient's own manifest, when that manifest is * present in the store — i.e. the ingredient resolves to another manifest in * the same provenance graph. `null` otherwise. Lets callers link to it. */ manifestLabel?: string | null; } /** * Wrapper class for accessing and formatting information from a C2PA read result. * Provides helpers for signature presence, validation status, custom metadata, and formatted output. */ export declare class C2paManifestHelper { private readonly store; private readonly reader?; constructor(store: ManifestStore, reader?: Reader | undefined); /** * Returns the raw underlying {@link ManifestStore}, or `null` if unavailable. */ getManifestStore(): ManifestStore | null; /** * Returns the manifest store as crJSON (the canonical C2PA JSON representation * introduced in c2pa-web v0.8.0). Requires a {@link Reader} to be passed to the * constructor; returns `null` otherwise. */ crJson(): Promise; /** * Checks if the result contains a valid manifest store (i.e., a signature exists). */ containsSignature(): boolean; /** * Returns the three-state validation result of the manifest store: * `"Valid"`, `"Trusted"`, or `"Invalid"`. Returns `null` if no manifest is present. */ getManifestStoreValidationState(): ValidationState | null; /** * Returns whether the manifest store passes validation. * Considers both `"Valid"` and `"Trusted"` states as valid. * Falls back to checking for absence of validation errors when `validation_state` is unavailable. * * @deprecated Use {@link getManifestStoreValidationState} for the full three-state result. */ isValid(): boolean; /** * Returns any validation errors associated with the manifest. */ getValidationErrors(): ValidationStatus[]; /** * Returns the full manifest map, indexed by manifest ID. */ getManifestMap(): Record; getActiveManifest(): Manifest | null; /** * Retrieves custom metadata for a specific assertion identifier. * * @param identifier A string key used in the manifest assertions (may be application-specific). * @param manifest An optional manifest object to use for lookup. Defaults to the active manifest. * @returns The custom metadata value associated with the identifier, or `null` if not found. */ getCustomMetadata(identifier: string, manifest?: Manifest): any | null; /** * Checks whether any of the manifests contain AI-generated content. * * Iterates through all available manifests in the manifest store and * tries to detect the presence of C2PA actions indicating AI-generated * content (e.g. `c2pa.created`). * * @returns {boolean} `true` if at least one manifest contains evidence * of AI-generated content, otherwise `false`. */ containsAIGeneratedContent(): boolean; /** * Returns the merged action list of a manifest, drawn from its `c2pa.actions` * and `c2pa.actions.v2` assertions (in that order), with v2 action templates * resolved so template-inherited fields (software agent, description, * digitalSourceType) appear directly on each action. Defaults to the active * manifest. Returns an empty array when no action assertions are present. * * @param manifest An optional manifest object. Defaults to the active manifest. */ getActions(manifest?: Manifest): Action[]; /** * Returns the training / data-mining usage permissions of a manifest. * * Prefers the current CAWG assertion `cawg.training-mining` (C2PA ≥ 2.2) and * falls back to the legacy `c2pa.training-mining` label. Returns an empty array * when neither assertion is present or the shape is unrecognized. Defaults to * the active manifest. * * @param manifest An optional manifest object. Defaults to the active manifest. */ getTrainingMiningUsage(manifest?: Manifest): TrainingMiningEntry[]; /** * Returns the normalized creator/author list of a manifest. * * Prefers the typed schema.org CreativeWork authors when present (they carry an * `@type`), and otherwise falls back to the CAWG-era metadata assertions * (`cawg.metadata` / `stds.iptc`), reading `dc:creator` (a string array). * Returns an empty array when no creators are declared. Defaults to the active * manifest. * * @param manifest An optional manifest object. Defaults to the active manifest. */ getCreators(manifest?: Manifest): Creator[]; /** * Returns the verified identities declared by a manifest's CAWG identity * assertion (`cawg.identity`). Two assertion shapes are recognized: * * - the Identity Claims Aggregation (ICA) verifiable credential, which lists * `verifiedIdentities` (named persons/accounts verified via a provider), and * - the `cawg.x509.cose` form, whose `signature_info.issuer` names the signer * (emitted with `type: 'cawg.x509.cose'`). * * Returns an empty array when no identity assertion is present. Defaults to * the active manifest. * * @param manifest An optional manifest object. Defaults to the active manifest. */ getVerifiedIdentities(manifest?: Manifest): VerifiedIdentity[]; /** * Returns the graded generative-AI classification of a manifest: * `'generated'`, `'partial'`, or `'none'`. Returns `null` when the manifest * carries no action/generative assertions, so callers can hide the section * rather than assert "no AI". Defaults to the active manifest. * * @param manifest An optional manifest object. Defaults to the active manifest. */ getGenerativeContentLevel(manifest?: Manifest): GenerativeContentLevel | null; /** * Returns the highest generative-AI level across *all* manifests in the store, * not just the active one. * * The active manifest is frequently a packaging/publishing step (e.g. a * repackaged-for-delivery signature) that carries no generative assertions, * while the actual AI evidence lives in ingredient manifests. This walks the * whole provenance chain and returns the strongest signal: `'generated'` if any * manifest is fully synthetic, otherwise `'partial'` if any is partly * AI-assisted, otherwise `'none'` if relevant action/generative assertions * exist but none indicate AI, and `null` when no manifest carries any such * assertions at all (so callers can omit the section rather than assert "no AI"). */ getCumulativeGenerativeContentLevel(): GenerativeContentLevel | null; /** * Returns the ingredients placed into a manifest through its `c2pa.placed` * actions, resolved to display info. * * Each `c2pa.placed` action references an ingredient assertion * (`c2pa.ingredient.v2|v3`, optionally `__N`-suffixed for duplicates); the * suffix is the 0-based index into the manifest's `ingredients` list. Title and * format fall back to the ingredient's source manifest when the ingredient * carries none, and a representative thumbnail is resolved from the ingredient, * else its source manifest, else the first thumbnail among the source * manifest's own ingredients. Defaults to the active manifest. * * @param manifest An optional manifest object. Defaults to the active manifest. */ getPlacedIngredients(manifest?: Manifest): PlacedIngredient[]; /** * Resolves the ingredient a single action acts on (e.g. `c2pa.opened`, * `c2pa.placed`) to display info, or `null` when the action references no * ingredient. The action's ingredient-assertion URI is mapped to the manifest's * `ingredients` list by its `__N` index; title/format/thumbnail fall back to the * ingredient's source manifest as in {@link getPlacedIngredients}. Defaults to * the active manifest. * * @param action The action to resolve (as returned by {@link getActions}). * @param manifest An optional manifest object. Defaults to the active manifest. */ getActionIngredient(action: Action, manifest?: Manifest): PlacedIngredient | null; /** * Resolves a manifest resource (e.g. an ingredient thumbnail) to a `data:` URL, * using the {@link Reader} passed to the constructor. Returns `null` when no * reader is available or the resource cannot be read. * * @param resource The resource reference to resolve (identifier + MIME type). */ getResourceDataUrl(resource: ResourceThumbnail): Promise; /** * Returns a human-readable string representation for common metadata fields. * * @param item The metadata field to extract from the manifest. */ getItem(item: C2paFormatedItemType): string | boolean; /** * Converts the raw result to a pretty-printed JSON string (safe against circular references). */ toString(): string; }