@contentauth/c2pa-js
    Preparing search index...

    Interface BuilderInterface

    interface BuilderInterface {
        addAction(actionJson: string): void;
        addAssertion(
            label: string,
            assertion: unknown,
            assertionKind?: ManifestAssertionKind,
        ): void;
        addIngredient(
            ingredientJson: string,
            ingredient?: SourceAsset,
        ): Promise<void>;
        addIngredientFromReader(reader: ReaderInterface): Ingredient;
        addRedaction(uri: string, reason: string): void;
        addResource(uri: string, resource: SourceAsset): Promise<void>;
        filterActions(keep: (action: Action) => boolean): void;
        filterIngredients(
            rescue: (
                ingredient: Ingredient,
                provenance: ManifestStore | null,
            ) => boolean,
        ): void;
        getHandle(): unknown;
        getManifestDefinition(): Manifest;
        setIntent(intent: BuilderIntent): void;
        setNoEmbed(noEmbed: boolean): void;
        setRemoteUrl(url: string): void;
        sign(
            signer: LocalSignerInterface,
            input: SourceAsset,
            output: DestinationAsset,
        ): Buffer;
        signAsync(
            callbackSigner:
                | CallbackSignerInterface
                | IdentityAssertionSignerInterface,
            input: SourceAsset,
            output: DestinationAsset,
        ): Promise<Buffer<ArrayBufferLike>>;
        signConfigAsync(
            callback: (data: Buffer) => Promise<Buffer<ArrayBufferLike>>,
            signerConfig: JsCallbackSignerConfig,
            input: SourceAsset,
            output: DestinationAsset,
        ): Promise<Buffer<ArrayBufferLike>>;
        signFile(
            signer: LocalSignerInterface,
            filePath: string,
            output: DestinationAsset,
        ): Buffer;
        toArchive(asset: DestinationAsset): Promise<void>;
        updateManifestProperty(
            property: string,
            value: string | ClaimVersion,
        ): void;
    }

    Implemented by

    Index

    Methods

    • Add a single action to the manifest. This is a convenience method for adding an action to the Actions assertion.

      Parameters

      • actionJson: string

        The JSON representation of the action

      Returns void

    • Add CBOR assertion to the builder

      Parameters

      • label: string

        The label of the assertion

      • assertion: unknown

        The assertion, should be a string if the type is JSON, otherwise a JS Object

      • OptionalassertionKind: ManifestAssertionKind

        The type of assertion

      Returns void

    • Add an ingredient to the manifest

      Parameters

      • ingredientJson: string

        The JSON representation of the ingredient

      • Optionalingredient: SourceAsset

        Optional source asset (buffer or file) for the ingredient

      Returns Promise<void>

    • Redact an assertion from an ingredient manifest and record the reason. Adds the URI to definition.redactions and appends a c2pa.redacted action with parameters.redacted pointing to the same URI.

      Parameters

      • uri: string

        JUMBF URI of the assertion to redact (e.g. self#jumbf=/c2pa/{label}/c2pa.assertions/{name})

      • reason: string

        Why the assertion is being redacted. Use "c2pa.PII.present" for PII removal.

      Returns void

    • Add a resource from a buffer or file

      Parameters

      • uri: string

        The URI of the resource

      • resource: SourceAsset

        The source and format of the resource

      Returns Promise<void>

    • Experimental. Retains only the actions for which keep returns true.

      The inception action, c2pa.created or c2pa.opened, is always kept regardless of keep, and is moved to index 0 if needed, so the manifest stays valid per the C2PA spec. Sets allActionsIncluded = false when anything is removed. This does not touch ingredients. Call filterIngredients, using filterIngredients(() => false) to drop all orphans, afterwards if you also want to drop ingredients now orphaned by the removed actions.

      Parameters

      • keep: (action: Action) => boolean

        The action is retained when the predicate returns true.

      Returns void

    • Experimental. Retains ingredients, then rewrites positional ingredient references so linked actions stay valid.

      An ingredient is kept if it is referenced by a current action, is a parentOf ingredient, or rescue returns true for it. rescue therefore only ever rescues an otherwise-orphaned ingredient. It can never drop a referenced or lineage ingredient. Call filterActions first if you are also removing actions: the keep-set is computed from whatever actions currently remain.

      rescue receives the ingredient and its provenance: the ingredient's embedded manifest_data parsed into a ManifestStore, or null when it has no embedded manifest. This lets the predicate make provenance-aware decisions, e.g. "this ingredient's chain contains AI", without re-reading the whole builder first.

      Parameters

      • rescue: (ingredient: Ingredient, provenance: ManifestStore | null) => boolean

        Can rescue an otherwise-orphaned ingredient by returning true.

      Returns void

    • An intent lets the API know what kind of manifest to create. Intents are Create, Edit, or Update. This allows the API to check that you are doing the right thing. It can also do things for you, like add parent ingredients from the source asset and automatically add required c2pa.created or c2pa.opened actions. Create requires a DigitalSourceType. It is used for assets without a parent ingredient. Edit requires a parent ingredient and is used for most assets that are being edited. Update is a special case with many restrictions but is more compact than Edit.

      Parameters

      Returns void

    • Set the no embed flag of the manifest

      Parameters

      • noEmbed: boolean

        The no embed flag of the manifest

      Returns void

    • Set the remote URL of the manifest

      Parameters

      • url: string

        The remote URL of the manifest

      Returns void

    • Sign an asset from a buffer or file asynchronously, using a callback and not passing a private key

      Parameters

      Returns Promise<Buffer<ArrayBufferLike>>

      the bytes of the c2pa_manifest that was embedded