Skip to main content

DDO

@nevermined-io/sdk - v3.0.44 / DDO

Class: DDO

DID Descriptor Object (DDO). Contains all the metadata related to an asset, including the description and the services available.

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new DDO(ddo?): DDO

Parameters

NameType
ddoPartial\<DDO>

Returns

DDO

Defined in

src/ddo/DDO.ts:235

Properties

@context

@context: string = 'https://w3id.org/did/v1'

Defined in

src/ddo/DDO.ts:212


_nvm

_nvm: NvmConfig

Defined in

src/ddo/DDO.ts:221


authentication

authentication: Authentication[] = []

Defined in

src/ddo/DDO.ts:229


created

created: string

Defined in

src/ddo/DDO.ts:223


didSeed

didSeed: string = ''

Defined in

src/ddo/DDO.ts:219


id

id: string = ''

DID, decentralizes ID.

Defined in

src/ddo/DDO.ts:217


proof

proof: Proof

Defined in

src/ddo/DDO.ts:233


publicKey

publicKey: PublicKey[] = []

Defined in

src/ddo/DDO.ts:227


service

service: ServiceCommon[] = []

Defined in

src/ddo/DDO.ts:231


updated

Optional updated: string

Defined in

src/ddo/DDO.ts:225

Methods

addDefaultMetadataService

addDefaultMetadataService(metadata, nftAttributes?): MetaDataMain

Adds a default metadata service to the DDO.

Parameters

NameTypeDescription
metadataMetaDatametadata
nftAttributes?NFTAttributesnft attributes

Returns

MetaDataMain

main metadata attributes

Defined in

src/ddo/DDO.ts:477


addProof

addProof(publicKey): Promise\<void>

Generates and adds a proof using personal sign on the DDO.

Parameters

NameTypeDescription
publicKeystringPublic key to be used on personal sign.

Returns

Promise\<void>

void.

Defined in

src/ddo/DDO.ts:427


addService

addService(service): void

Adds a service to the DDO.

Parameters

NameType
serviceServiceCommon

Returns

void

Defined in

src/ddo/DDO.ts:449


addSignature

addSignature(nevermined, publicKey): Promise\<void>

It adds a signature to the the proof object of the DDO

Parameters

NameTypeDescription
neverminedNeverminednevermined object
publicKeystringpublic key to sign the DDO

Returns

Promise\<void>

Defined in

src/ddo/DDO.ts:559


assignDid

assignDid(didSeed, didRegistry, publisher): Promise\<void>

Assign a DID to the DDO

Parameters

NameTypeDescription
didSeedstringDID seed
didRegistryDIDRegistryDIDRegistry contract
publisherNvmAccountaccount registering the DID

Returns

Promise\<void>

Defined in

src/ddo/DDO.ts:537


checksum

checksum(seed): string

Parameters

NameType
seedstring

Returns

string

Defined in

src/ddo/DDO.ts:389


findServiceByIndex

findServiceByIndex\<T>(index): Service\<T>

Finds a service of a DDO by index number.

Type parameters

NameType
Textends ServiceType

Parameters

NameTypeDescription
indexnumberindex of the service in the DDO.

Returns

Service\<T>

Service.

Defined in

src/ddo/DDO.ts:294


findServiceByReference

findServiceByReference\<T>(serviceReference): Service\<T>

Finds a service of a DDO by index.

Type parameters

NameType
Textends ServiceType

Parameters

NameTypeDescription
serviceReferencenumber | ServiceTypereference to the service (index or type).

Returns

Service\<T>

Service.

Defined in

src/ddo/DDO.ts:328


findServiceByType

findServiceByType\<T>(serviceType): Service\<T>

Finds the first service of a DDO by type.

Type parameters

NameType
Textends ServiceType

Parameters

NameTypeDescription
serviceTypeTService type used by find the service

Returns

Service\<T>

Service.

Throws

DDOServiceNotFoundError If the service is not in the DDO.

Defined in

src/ddo/DDO.ts:314


generateDidSeed

generateDidSeed(seed): Promise\<`0x${string}`>

It generates a DID seed from a seed

Parameters

NameTypeDescription
seedanythe seed

Returns

Promise\<`0x${string}`>

the string represeing the DID seed

Defined in

src/ddo/DDO.ts:550


generateProof

generateProof(publicKey): Promise\<Proof>

Generates proof using personal sign.

Parameters

NameTypeDescription
publicKeystringPublic key to be used on personal sign.

Returns

Promise\<Proof>

Proof object.

Defined in

src/ddo/DDO.ts:398


getAssetPriceFromDDOByServiceType

getAssetPriceFromDDOByServiceType(service): AssetPrice

It gets the AssetPrice from a service given the serviceType

Parameters

NameTypeDescription
serviceServiceTypethe service to search in

Returns

AssetPrice

the AssetPrice object

Defined in

src/ddo/DDO.ts:714


getPriceByService

getPriceByService(serviceType?): bigint

Get the total price of a service.

Parameters

NameTypeDefault valueDescription
serviceTypeServiceType'access'Service type

Returns

bigint

bigint

Example

const price = ddo.getPriceByService('nft-access')

Throws

DDOPriceNotFoundError

Defined in

src/ddo/DDO.ts:379


getProofChecksum

getProofChecksum(): string

Get the checksum of the proof.

Returns

string

string containing the checksum of the proof.

Defined in

src/ddo/DDO.ts:418


getServicesByType

getServicesByType\<T>(serviceType): Service\<T>[]

Gets all the services of a DDO with a specific type.

Type parameters

NameType
Textends ServiceType

Parameters

NameTypeDescription
serviceTypeTService type.

Returns

Service\<T>[]

Service.

Defined in

src/ddo/DDO.ts:344


reorderServices

reorderServices(): void

It reorders the services of the DDO using the service index

Returns

void

Defined in

src/ddo/DDO.ts:437


replaceService

replaceService(index, service): void

Replaces a service in the DDO.

Parameters

NameType
indexnumber
serviceany

Returns

void

Defined in

src/ddo/DDO.ts:465


serviceExists

serviceExists\<T>(serviceType): boolean

Checks if a service exists in the DDO.

Type parameters

NameType
Textends ServiceType

Parameters

NameTypeDescription
serviceTypeTService type.

Returns

boolean

true if service exists.

Defined in

src/ddo/DDO.ts:354


serviceIndexExists

serviceIndexExists(serviceIndex): boolean

Checks if a service index in the DDO.

Parameters

NameTypeDescription
serviceIndexnumberService index.

Returns

boolean

true if service exists.

Defined in

src/ddo/DDO.ts:364


setAssetPriceFromDDOByService

setAssetPriceFromDDOByService(serviceType, rewards): void

Given a service type, it sets the AssetPrice in the escrowPayment condition

Parameters

NameTypeDescription
serviceTypeServiceTypethe service to search in
rewardsAssetPricethe AssetPrice object to set

Returns

void

Defined in

src/ddo/DDO.ts:724


setNFTRewardsFromService

setNFTRewardsFromService(serviceType, rewards, holderAddress): undefined | DDOConditionNotFoundError

Given the service type it sets the AssetPrice and NFT holder

Parameters

NameTypeDescription
serviceTypeServiceTypethe service type to search in
rewardsAssetPricethe AssetPrice object to set
holderAddressstringthe NFT Holder address to set

Returns

undefined | DDOConditionNotFoundError

Defined in

src/ddo/DDO.ts:751


shortId

shortId(): string

It returns the DDO id without the prefix

Returns

string

the DID without the prefix

Defined in

src/ddo/DDO.ts:285


updateMetadataService

updateMetadataService(service): void

Updates a service in the DDO

Parameters

NameTypeDescription
serviceanythe service to be updated

Returns

void

Defined in

src/ddo/DDO.ts:523


updateService

updateService(service, serviceIndex?): void

Parameters

NameTypeDefault valueDescription
serviceanyundefinedthe service to be updated
serviceIndexnumber0the position of the service in the DDO.services array

Returns

void

Deprecated

use the updateMetadataService or replaceService methods instead Updates a service in the DDO

Defined in

src/ddo/DDO.ts:514


createAuthorizationService

createAuthorizationService(neverminedNodeUri, publicKey, method): ServiceCommon

It creates an authorization service that can be included later as part of a DDO

Parameters

NameTypeDescription
neverminedNodeUristringURL of the Nevermined Node managing this asset
publicKeystringPublic key of the user
methodstringEncryption method

Returns

ServiceCommon

The authorization service

Defined in

src/ddo/DDO.ts:193


deserialize

deserialize(ddoString): DDO

Deserializes the DDO object.

Parameters

NameTypeDescription
ddoStringstringThe serialized DDO to be deserialized.

Returns

DDO

The deserialized DDO.

Defined in

src/ddo/DDO.ts:180


findAndReplaceDDOAttribute

findAndReplaceDDOAttribute(ddo, paramName, value): DDO

Finds an attribute in the DDO and replace it with the given value

Parameters

NameTypeDescription
ddoDDOthe originial DDO
paramNamestring | RegExpthe param name to replace
valuestringthe new value

Returns

DDO

the DDO with the replaced attribute

Defined in

src/ddo/DDO.ts:774


findServiceConditionByName

findServiceConditionByName(service, name): ServiceAgreementTemplateCondition

If fins a service condition by name

Parameters

NameTypeDescription
serviceServiceCommonthe service to search in
nameConditionTypethe name of the condition

Returns

ServiceAgreementTemplateCondition

ServiceAgreementTemplateCondition the condition

Defined in

src/ddo/DDO.ts:571


getAssetPriceFromService

getAssetPriceFromService(service): AssetPrice

It gets the AssetPrice from a service with escrowPayment condition

Parameters

NameTypeDescription
serviceServiceCommonthe service to search in

Returns

AssetPrice

the AssetPrice object

Defined in

src/ddo/DDO.ts:689


getDIDFromService

getDIDFromService(service): string

Gets the DID in the escrowPayment condition of the service

Parameters

NameTypeDescription
serviceServiceCommonthe service to search in

Returns

string

the DID

Defined in

src/ddo/DDO.ts:587


getDurationFromService

getDurationFromService(service): number

Gets the duration parameter in the transferNFT condition of the service

Parameters

NameTypeDescription
serviceServiceCommonthe service to search in

Returns

number

the duration of the subscription

Defined in

src/ddo/DDO.ts:644


getInstance

getInstance(userId, publisherAddress, appId?): DDO

It gets an instance of a DDO with the basic structure

Parameters

NameTypeDescription
userIdstringThe unique identifier of the user
publisherAddressstringThe address of the publisher
appId?stringThe application id

Returns

DDO

a DDO instance

Defined in

src/ddo/DDO.ts:248


getNFTTransferFromService

getNFTTransferFromService(service): boolean

Gets the nftTransfer parameter in the transferNFT condition of the service

Parameters

NameTypeDescription
serviceServiceCommonthe service to search in

Returns

boolean

if condition will do a nft transfer or a mint

Defined in

src/ddo/DDO.ts:633


getNewDateFormatted

getNewDateFormatted(date?): string

It gets a new date formatted

Parameters

NameTypeDescription
dateDatethe date to format

Returns

string

the date string formatted

Defined in

src/ddo/DDO.ts:277


getNftAmountFromService

getNftAmountFromService(service): bigint

Gets the number of NFTs in the transferNFT condition of the service

Parameters

NameTypeDescription
serviceServiceCommonthe service to search in

Returns

bigint

the number of NFTs

Defined in

src/ddo/DDO.ts:619


getNftContractAddressFromService

getNftContractAddressFromService(service): string

Gets the NFT Contract address used in the NFT Access or NFT Sales service

Parameters

NameTypeDescription
serviceServiceNFTAccess | ServiceNFTSalesthe service to search in

Returns

string

the NFT contract address

Defined in

src/ddo/DDO.ts:673


getNftHolderFromService

getNftHolderFromService(service): string

Gets the NFT Holder in the transferNFT condition of the service

Parameters

NameTypeDescription
serviceServiceCommonthe service to search in

Returns

string

the NFT Holder address

Defined in

src/ddo/DDO.ts:597


getParameterFromCondition

getParameterFromCondition(service, conditionType, paramName): string | number | string[]

Given a service, condition and param name it returns the value

Parameters

NameTypeDescription
serviceServiceCommonThe service where the condition is
conditionTypeConditionTypethe condition type
paramNamestringthe param name

Returns

string | number | string[]

the value

Defined in

src/ddo/DDO.ts:655


getTokenIdFromService

getTokenIdFromService(service): string

Gets the NFT TokenId in the nftHolder condition of the service

Parameters

NameTypeDescription
serviceServiceCommonthe service to search in

Returns

string

the NFT Token Id

Defined in

src/ddo/DDO.ts:606


parseDDOWebServiceAttributes

parseDDOWebServiceAttributes(webService, did): WebService

Parameters

NameType
webServiceWebService
didstring

Returns

WebService

Defined in

src/ddo/DDO.ts:782


serialize

serialize(ddo): string

Serializes the DDO object.

Parameters

NameTypeDescription
ddoDDOThe DDO to be serialized.

Returns

string

DDO serialized.

Defined in

src/ddo/DDO.ts:171