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

    Exposes methods for building C2PA manifests and signing assets.

    interface Builder {
        addAction: (action: Action) => Promise<void>;
        addIngredient: (ingredientDefinition: Ingredient) => Promise<void>;
        addIngredientFromBlob: (
            ingredientDefinition: Ingredient,
            format: string,
            blob: Blob,
        ) => Promise<void>;
        addResourceFromBlob: (resourceId: string, blob: Blob) => Promise<void>;
        free: () => Promise<void>;
        getDefinition: () => Promise<ManifestDefinition>;
        setIntent: (intent: BuilderIntent) => Promise<void>;
        setNoEmbed: (noEmbed: boolean) => Promise<void>;
        setRemoteUrl: (url: string) => Promise<void>;
        setThumbnailFromBlob: (format: string, blob: Blob) => Promise<void>;
        sign: (
            signer: Signer,
            format: string,
            blob: Blob,
        ) => Promise<Uint8Array<ArrayBuffer>>;
        signAndGetManifestBytes: (
            signer: Signer,
            format: string,
            blob: Blob,
        ) => Promise<ManifestAndAssetBytes>;
        toArchive: () => Promise<Uint8Array<ArrayBuffer>>;
    }
    Index

    Properties

    addAction: (action: Action) => Promise<void>

    Add an action to the manifest's actions assertion.

    Type Declaration

      • (action: Action): Promise<void>
      • Parameters

        • action: Action

          Object representing the action to be added.

        Returns Promise<void>

    addIngredient: (ingredientDefinition: Ingredient) => Promise<void>

    Add an ingredient to the builder from a definition only.

    Type Declaration

    addIngredientFromBlob: (
        ingredientDefinition: Ingredient,
        format: string,
        blob: Blob,
    ) => Promise<void>

    Add an ingredient to the builder from a definition, format, and blob. Values specified in the ingredient definition will be merged with the ingredient, and these values take precendence.

    Type Declaration

      • (ingredientDefinition: Ingredient, format: string, blob: Blob): Promise<void>
      • Parameters

        • ingredientDefinition: Ingredient

          Ingredient definition.

        • format: string

          Format of the ingredient.

        • blob: Blob

          Blob of the ingredient's bytes.

        Returns Promise<void>

    addResourceFromBlob: (resourceId: string, blob: Blob) => Promise<void>

    Add a resource to the builder's resource store with an ID and blob of the resource's bytes.

    Type Declaration

      • (resourceId: string, blob: Blob): Promise<void>
      • Parameters

        • resourceId: string

          ID associated with the resource being added.

        • blob: Blob

          Blob of the resource's bytes.

        Returns Promise<void>

    free: () => Promise<void>

    Dispose of this Builder, freeing the memory it occupied and preventing further use. Call this whenever the Builder is no longer needed.

    getDefinition: () => Promise<ManifestDefinition>

    Gets the current manifest definition held by the builder.

    Type Declaration

    setIntent: (intent: BuilderIntent) => Promise<void>

    Sets the builder "intent."

    Additional documentation coming soon.

    setNoEmbed: (noEmbed: boolean) => Promise<void>

    Sets the state of the no_embed flag. To skip embedding a manifest (e.g. for the remote-only case) set this to true.

    Type Declaration

      • (noEmbed: boolean): Promise<void>
      • Parameters

        • noEmbed: boolean

          Value to set the no_embed flag.

        Returns Promise<void>

    setRemoteUrl: (url: string) => Promise<void>

    Sets the remote URL for a remote manifest. The manifest is expected to be available at this location.

    Type Declaration

      • (url: string): Promise<void>
      • Parameters

        • url: string

          URL pointing to the location the remote manifest will be stored.

        Returns Promise<void>

    setThumbnailFromBlob: (format: string, blob: Blob) => Promise<void>

    Set a thumbnail from a blob to be included in the manifest. The blob should represent the asset being signed.

    Type Declaration

      • (format: string, blob: Blob): Promise<void>
      • Parameters

        • format: string

          Format of the thumbnail

        • blob: Blob

          Blob of the thumbnail bytes

        Returns Promise<void>

    sign: (
        signer: Signer,
        format: string,
        blob: Blob,
    ) => Promise<Uint8Array<ArrayBuffer>>

    Sign an asset.

    Docs coming soon

    signAndGetManifestBytes: (
        signer: Signer,
        format: string,
        blob: Blob,
    ) => Promise<ManifestAndAssetBytes>

    Sign an asset and get both the signed asset bytes and the manifest bytes.

    Docs coming soon

    toArchive: () => Promise<Uint8Array<ArrayBuffer>>

    Save the builder into .c2pa format. This "archive" can be added to as an ingredient with addIngredientFromBlob

    Type Declaration

      • (): Promise<Uint8Array<ArrayBuffer>>
      • Returns Promise<Uint8Array<ArrayBuffer>>

        A builder archive in application/c2pa format.