Skip to main content

Content Management

Methods for managing content types, libraries and objects

AddLibraryContentType

AddLibraryContentType({
  libraryId,
  typeId, // optional
  typeName, // optional
  typeHash, // optional
  customContractAddress // optional
}) → Promise.<string>

Add a specified content type to a library

Returns: Hash of the addContentType transaction

Parameters

NameTypeRequiredDescription
libraryIdstring

ID of the library

typeIdstring

ID of the content type

typeNamestring

Name of the content type

typeHashstring

Version hash of the content type

customContractAddressstring

Address of the custom contract to associate with this content type for this library

CopyContentObject

CopyContentObject({
  libraryId,
  originalVersionHash,
  options // optional
}) → Promise.<Object>

Create a new content object draft from an existing content object version.

Note: The type of the new copy can be different from the original object.

Returns: Response containing the object ID and write token of the draft

Parameters

NameTypeRequiredDescription
libraryIdstring

ID of the library in which to create the new object

originalVersionHash

Version hash of the object to copy

optionsObject

type: Version hash of the content type to associate with the object - may be different from the original object

meta: Metadata to use for the new object - This will be merged into the metadata of the original object

CreateAndFinalizeContentObject

CreateAndFinalizeContentObject({
  libraryId,
  callback, // optional
  options, // optional
  commitMessage, // optional
  publish, // optional
  awaitCommitConfirmation // optional
}) → Promise.<object>

Create and finalize new content object draft from an existing object.

Equivalent to:

CreateContentObject()

callback({objectId, writeToken})

FinalizeContentObject()

Returns: Response from FinalizeContentObject

Parameters

NameTypeRequiredDescription
libraryIdstring

ID of the library

callbackfunction

Async function to perform after creating the content draft and before finalizing. Object ID and write token are passed as named parameters.

optionsobject

meta: New metadata for the object - will be merged into existing metadata if specified type: New type for the object - Object ID, version hash or name of type

commitMessagestring

Message to include about this commit

publishboolean

If specified, the object will also be published

(default: true)
awaitCommitConfirmationboolean

If specified, will wait for the publish commit to be confirmed. Irrelevant if not publishing.

(default: true)

CreateContentLibrary

CreateContentLibrary({
  name,
  description, // optional
  image, // optional
  imageName, // optional
  metadata, // optional
  kmsId, // optional
  tenantContractId // optional
}) → Promise.<string>

Create a new content library.

A new content library contract is deployed from the content space, and that contract ID is used to determine the library ID to create in the fabric.

Returns: Library ID of created library

Parameters

NameTypeRequiredDescription
namestring

Library name

descriptionstring

Library description

imageblob

Image associated with the library

imageNamestring

Name of the image associated with the library (required if image specified)

metadataObject

Metadata of library object

kmsIdstring

ID of the KMS to use for content in this library. If not specified, the default KMS will be used.

tenantContractIdstring

ID of the tenant to use for this library

CreateContentObject

CreateContentObject({
  libraryId,
  objectId, // optional
  options // optional
}) → Promise.<Object>

Create a new content object draft.

A new content object contract is deployed from the content library, and that contract ID is used to determine the object ID to create in the fabric.

Returns: Response containing the object ID and write token of the draft, as well as the url of the node that created the write token.

Parameters

NameTypeRequiredDescription
libraryIdstring

ID of the library

objectIdstring

ID of the object (if contract already exists)

optionsObject

type: Version hash of the content type to associate with the object

meta: Metadata to use for the new object

noEncryptionConk: Set to true to prevent creation of an encryption conk for the object

createKMSConk: Set to true to create a KMS conk for object (usually for sharing a playable object) (incompatible with noEncryptionConk: true)

CreateContentType

CreateContentType({
  libraryId, // optional
  name,
  metadata,
  bitcode // optional
}) → Promise.<string>

Create a new content type.

A new content type contract is deployed from the content space, and that contract ID is used to determine the object ID to create in the fabric. The content type object will be created in the special content space library (ilib)

Returns: Object ID of created content type

Parameters

NameTypeRequiredDescription
libraryIdstring

ID of the library in which to create the content type. If not specified, it will be created in the content space library

namestring

Name of the content type

metadataobject

Metadata for the new content type

bitcodeBlob | Buffer

Bitcode to be used for the content type

CreateLinks({
  libraryId,
  objectId,
  writeToken,
  links
})

Create links to files, metadata and/or representations of this or or other content objects.

Expected format of links:

[ { path: string (metadata path for the link) target: string (path to link target), type: string ("file", "meta" | "metadata", "rep" - default "metadata") targetHash: string (optional, for cross-object links), autoUpdate: boolean (if specified, link will be automatically updated to latest version by UpdateContentObjectGraph method), authContainer: string (optional, object id of container object if creating a signed link) } ]

Parameters

NameTypeRequiredDescription
libraryIdstring

ID of the library

objectIdstring

ID of the object

writeTokenstring

Write token of the draft

linksArray.<Object>

Link specifications

CreateNonOwnerCap

CreateNonOwnerCap({
  libraryId,
  objectId,
  publicKey,
  writeToken
}) → Promise.<Object>

Create a non-owner cap key using the specified public key and address

Parameters

NameTypeRequiredDescription
libraryIdstring

ID of the library

objectIdstring

ID of the object

publicKeystring

Public key for the target cap

writeTokenstring

Write token for the content object - If specified, info will be retrieved from the write draft instead of creating a new draft and finalizing

DeleteContentLibrary

DeleteContentLibrary({ libraryId })

NOT YET SUPPORTED - Delete the specified content library

Parameters

NameTypeRequiredDescription
libraryIdstring

ID of the library to delete

DeleteContentObject

DeleteContentObject({
  libraryId,
  objectId
})

Delete specified content object

Parameters

NameTypeRequiredDescription
libraryIdstring

ID of the library

objectIdstring

ID of the object

DeleteContentVersion

DeleteContentVersion({ versionHash }) // optional

Delete specified version of the content object

Parameters

NameTypeRequiredDescription
versionHashstring

Hash of the object version - if not specified, most recent version will be deleted

DeleteMetadata

DeleteMetadata({
  libraryId,
  objectId,
  writeToken,
  metadataSubtree // optional
})

Delete content object metadata of specified subtree

Parameters

NameTypeRequiredDescription
libraryIdstring

ID of the library

objectIdstring

ID of the object

writeTokenstring

Write token of the draft

metadataSubtreestring

Subtree of the object metadata to modify

  • if not specified, all metadata will be deleted

DeleteWriteToken

DeleteWriteToken({ writeToken })

Delete the specified write token

Parameters

NameTypeRequiredDescription
writeTokenstring

Write token to delete

EditAndFinalizeContentObject

EditAndFinalizeContentObject({
  libraryId,
  objectId,
  callback, // optional
  options, // optional
  commitMessage, // optional
  publish, // optional
  awaitCommitConfirmation // optional
}) → Promise.<object>

Create and finalize new content object draft from an existing object.

Equivalent to:

EditContentObject()

callback({writeToken})

FinalizeContentObject()

Returns: Response from FinalizeContentObject

Parameters

NameTypeRequiredDescription
libraryIdstring

ID of the library

objectIdstring

ID of the object

callbackfunction

Async function to perform after creating the content draft and before finalizing. Write token is passed as a named parameter.

optionsobject

meta: New metadata for the object - will be merged into existing metadata if specified type: New type for the object - Object ID, version hash or name of type

commitMessagestring

Message to include about this commit

publishboolean

If specified, the object will also be published

(default: true)
awaitCommitConfirmationboolean

If specified, will wait for the publish commit to be confirmed. Irrelevant if not publishing.

(default: true)

EditContentObject

EditContentObject({
  libraryId,
  objectId,
  options // optional
}) → Promise.<object>

Create a new content object draft from an existing object.

Returns: Response containing the object ID and write token of the draft, as well as URL of node handling the draft

Parameters

NameTypeRequiredDescription
libraryIdstring

ID of the library

objectIdstring

ID of the object

optionsobject
options.metaobject

New metadata for the object - will be merged into existing metadata if specified

options.typestring

New type for the object - Object ID, version hash or name of type

FinalizeContentObject

FinalizeContentObject({
  libraryId,
  objectId,
  writeToken,
  commitMessage, // optional
  publish, // optional
  awaitCommitConfirmation // optional
})

Finalize content draft

Parameters

NameTypeRequiredDescription
libraryIdstring

ID of the library

objectIdstring

ID of the object

writeTokenstring

Write token of the draft

commitMessagestring

Message to include about this commit

publishboolean

If specified, the object will also be published

(default: true)
awaitCommitConfirmationboolean

If specified, will wait for the publish commit to be confirmed. Irrelevant if not publishing.

(default: true)

GenerateSignedLinkToken

GenerateSignedLinkToken({
  containerId, // optional
  versionHash, // optional
  link, // optional
  duration // optional
}) → Promise.<string>

Generate a signed link token.

Returns: The state channel token

Parameters

NameTypeRequiredDescription
containerIdstring

ID of the container object

versionHashstring

Version hash of the object

linkstring

Path

durationstring

How long the link should last in milliseconds

InitializeAuthPolicy

InitializeAuthPolicy({
  libraryId,
  objectId,
  writeToken,
  target, // optional
  body,
  version,
  description, // optional
  id // optional
})

Initialize or replace the signed auth policy for the specified object

Parameters

NameTypeRequiredDescription
libraryIdstring

ID of the library

objectIdstring

ID of the object

writeTokenstring

Write token of the draft

targetstring

The metadata location of the auth policy

(default: "auth_policy_spec")
bodystring

The body of the policy

versionstring

The version of the policy

descriptionstring

A description for the policy

idstring

The ID of the policy

MergeMetadata

MergeMetadata({
  libraryId,
  objectId,
  writeToken,
  metadata,
  metadataSubtree // optional
})

Merge specified metadata into existing content object metadata

Parameters

NameTypeRequiredDescription
libraryIdstring

ID of the library

objectIdstring

ID of the object

writeTokenstring

Write token of the draft

metadataObject

New metadata to merge

metadataSubtreestring

Subtree of the object metadata to modify

PublishContentVersion

PublishContentVersion({
  libraryId,
  objectId,
  versionHash,
  awaitCommitConfirmation // optional
})

Publish a previously finalized content object version

Parameters

NameTypeRequiredDescription
libraryIdstring

ID of the library

objectIdstring

ID of the object

versionHashstring

The version hash of the content object to publish

awaitCommitConfirmationboolean

If specified, will wait for the publish commit to be confirmed.

(default: true)

RemoveLibraryContentType

RemoveLibraryContentType({
  libraryId,
  typeId, // optional
  typeName, // optional
  typeHash // optional
}) → Promise.<string>

Remove the specified content type from a library

Returns: Hash of the removeContentType transaction

Parameters

NameTypeRequiredDescription
libraryIdstring

ID of the library

typeIdstring

ID of the content type (required unless typeName is specified)

typeNamestring

Name of the content type (required unless typeId is specified)

typeHashstring

Version hash of the content type

ReplaceMetadata

ReplaceMetadata({
  libraryId,
  objectId,
  writeToken,
  metadata,
  metadataSubtree // optional
})

Replace content object metadata with specified metadata

Parameters

NameTypeRequiredDescription
libraryIdstring

ID of the library

objectIdstring

ID of the object

writeTokenstring

Write token of the draft

metadataObject

New metadata to merge

metadataSubtreestring

Subtree of the object metadata to modify

SetAccessCharge

SetAccessCharge({
  objectId,
  accessCharge
})

Set the access charge for the specified object

Parameters

NameTypeRequiredDescription
objectIdstring

ID of the object

accessChargenumber | string

The new access charge, in ether

SetAuthPolicy

SetAuthPolicy({
  objectId,
  policyId
})

Set the authorization policy for the specified object

Parameters

NameTypeRequiredDescription
objectIdstring

The ID of the object

policyIdstring

The ID of the policy

SetContentLibraryImage

SetContentLibraryImage({
  libraryId,
  writeToken,
  image,
  imageName // optional
})

Set the image associated with this library

Parameters

NameTypeRequiredDescription
libraryIdstring

ID of the library

writeTokenstring

Write token for the draft

imageBlob | ArrayBuffer | Buffer

Image to upload

imageNamestring

Name of the image file

SetContentObjectImage

SetContentObjectImage({
  libraryId,
  objectId,
  writeToken,
  image,
  imageName, // optional
  imagePath // optional
})

Set the image associated with this object

Parameters

NameTypeRequiredDescription
libraryIdstring

ID of the library

objectIdstring

ID of the object

writeTokenstring

Write token of the draft

imageBlob | ArrayBuffer | Buffer

Image to upload

imageNamestring

Name of the image file

imagePathstring

Metadata path of the image link (default is recommended)

(default: public/display_image)

SetPermission

SetPermission(
  objectId,
  permission,
  writeToken
)

Set the current permission level for the specified object. See client.permissionLevels for all available permissions.

Note: This method is only intended for normal content objects, not types, libraries, etc.

Parameters

NameTypeRequiredDescription
objectIdstring

The ID of the object

permissionstring

The key for the permission to set - See client.permissionLevels for available permissions

writeTokenstring

Write token for the content object - If specified, info will be retrieved from the write draft instead of creating a new draft and finalizing

UpdateContentObjectGraph

UpdateContentObjectGraph(
  libraryId, // optional
  objectId, // optional
  versionHash, // optional
  callback // optional
)

Recursively update all auto_update links in the specified object.

Note: Links will not be updated unless they are specifically marked as auto_update

Parameters

NameTypeRequiredDescription
libraryIdstring

ID of the library

objectIdstring

ID of the object

versionHashstring

Version hash of the object -- if not specified, latest version is returned

callbackfunction

If specified, the callback will be called each time an object is updated with current progress as well as information about the last update (action)

  • Format: {completed: number, total: number, action: string}