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

    The Reader class supports reading C2PA data out of an asset.

    const reader = await Reader.fromBlob(c2pa, blob.type, blob);
    const activeManifest = await reader.activeManifest();
    Index

    Methods

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

      Returns Promise<void>

    • Resolves a URI reference to a binary object (e.g. a thumbnail) in the resource store.

      Parameters

      • uri: string

        URI of the binary object to resolve.

      Returns Promise<Uint8Array<ArrayBuffer>>

      A Uint8Array of the resource's bytes.

      const reader = await Reader.fromBlob(c2pa, blob.type, blob);
      const activeManifest = await reader.activeManifest();
      const thumbnailBuffer = await reader.resourceToBytes(activeManifest.thumbnail!.identifier);
    • Create a Reader from an asset's format and a blob of its bytes.

      Parameters

      • c2pa: C2pa

        The C2pa instance (from createC2pa) to create this reader on.

      • format: string | undefined

        Asset format (MIME type or extension), typically blob.type. If omitted or empty, the native library will attempt to detect the format from the asset's bytes instead. Always provide the format if known, and only omit this when the caller has no way to determine the asset's format otherwise.

      • blob: Blob

        Blob of asset bytes.

      • context: Context = ...

        Optional Context configuring this reader's behavior.

      Returns Promise<Reader | null>

      A Reader object or null if no C2PA metadata was found.

      If the asset is too large.

    • Create a Reader from an initial fragment and a subsequent fragment.

      Parameters

      • c2pa: C2pa

        The C2pa instance (from createC2pa) to create this reader on.

      • format: string

        Asset format (MIME type or extension). Unlike fromBlob, fragmented assets cannot be auto-detected from their bytes, so a format must be supplied.

      • init: Blob

        Blob of initial fragment bytes.

      • fragment: Blob

        Blob of fragment bytes.

      • context: Context = ...

        Optional Context configuring this reader's behavior.

      Returns Promise<Reader | null>

      A Reader object or null if no C2PA metadata was found.

      If the asset is too large.