@contentauth/c2pa-node


@contentauth/c2pa-node / Builder

Class: Builder

Defined in: Builder.ts:32

Implements

Methods

addAction()

addAction(actionJson): void

Defined in: Builder.ts:73

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

Implementation of

BuilderInterface.addAction


addAssertion()

addAssertion(label, assertion, assertionKind?): void

Defined in: Builder.ts:77

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

assertionKind?

ManifestAssertionKind

The type of assertion

Returns

void

Implementation of

BuilderInterface.addAssertion


addIngredient()

addIngredient(ingredientJson, ingredient?): Promise<void>

Defined in: Builder.ts:94

Add an ingredient to the manifest

Parameters

ingredientJson

string

The JSON representation of the ingredient

ingredient?

SourceAsset

Optional source asset (buffer or file) for the ingredient

Returns

Promise<void>

Implementation of

BuilderInterface.addIngredient


addResource()

addResource(uri, resource): Promise<void>

Defined in: Builder.ts:90

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>

Implementation of

BuilderInterface.addResource


getManifestDefinition()

getManifestDefinition(): Manifest

Defined in: Builder.ts:211

Getter for the builder’s manifest definition

Returns

Manifest

The manifest definition

Implementation of

BuilderInterface.getManifestDefinition


setIntent()

setIntent(intent): void

Defined in: Builder.ts:60

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

intent

BuilderIntent

The intent of the manifest

Returns

void

Implementation of

BuilderInterface.setIntent


setNoEmbed()

setNoEmbed(noEmbed): void

Defined in: Builder.ts:65

Set the no embed flag of the manifest

Parameters

noEmbed

boolean = true

The no embed flag of the manifest

Returns

void

Implementation of

BuilderInterface.setNoEmbed


setRemoteUrl()

setRemoteUrl(remoteUrl): void

Defined in: Builder.ts:69

Set the remote URL of the manifest

Parameters

remoteUrl

string

Returns

void

Implementation of

BuilderInterface.setRemoteUrl


sign()

sign(signer, input, output): Buffer

Defined in: Builder.ts:120

Sign an asset from a buffer or file

Parameters

signer

LocalSignerInterface

The local signer to use

input

SourceAsset

output

DestinationAsset

Returns

Buffer

the bytes of the c2pa_manifest that was embedded

Implementation of

BuilderInterface.sign


signAsync()

signAsync(signer, input, output): Promise<Buffer<ArrayBufferLike>>

Defined in: Builder.ts:180

Sign an asset from a buffer or file asynchronously, using a CallbackSigner

Parameters

signer
CallbackSignerInterface IdentityAssertionSignerInterface
input

SourceAsset

output

DestinationAsset

Returns

Promise<Buffer<ArrayBufferLike>>

the bytes of the c2pa_manifest that was embedded

Implementation of

BuilderInterface.signAsync


signConfigAsync()

signConfigAsync(callback, signerConfig, input, output): Promise<Buffer<ArrayBufferLike>>

Defined in: Builder.ts:147

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

Parameters

callback

(data) => Promise<Buffer<ArrayBufferLike>>

The callback function to sign the asset

signerConfig

JsCallbackSignerConfig

The configuration for the signer

input

SourceAsset

output

DestinationAsset

Returns

Promise<Buffer<ArrayBufferLike>>

the bytes of the c2pa_manifest that was embedded

Implementation of

BuilderInterface.signConfigAsync


signFile()

signFile(signer, filePath, output): Buffer

Defined in: Builder.ts:133

Embed a signed manifest into a stream using the LocalSigner

Parameters

signer

LocalSignerInterface

The local signer to use

filePath

string

output

DestinationAsset

Returns

Buffer

the bytes of the c2pa_manifest that was embedded

Implementation of

BuilderInterface.signFile


toArchive()

toArchive(asset): Promise<void>

Defined in: Builder.ts:112

Convert the Builder into a archive formatted buffer or file

Parameters

asset

DestinationAsset

The file or buffer for the archive

Returns

Promise<void>

Implementation of

BuilderInterface.toArchive


updateManifestProperty()

updateManifestProperty(property, value): void

Defined in: Builder.ts:217

Update a string property of the manifest

Parameters

property

string

value

ClaimVersion

Returns

void

The manifest definition

Implementation of

BuilderInterface.updateManifestProperty


fromArchive()

static fromArchive(asset): Promise<Builder>

Defined in: Builder.ts:116

Parameters

asset

SourceAsset

Returns

Promise<Builder>


new()

static new(): Builder

Defined in: Builder.ts:35

Returns

Builder


withJson()

static withJson(json): Builder

Defined in: Builder.ts:40

Parameters

json

Manifest

Returns

Builder