Options
All
  • Public
  • Public/Protected
  • All
Menu

ContentApi provide methods to communication with content stored in dcore_js network.

Hierarchy

  • ContentApi

Index

Constructors

constructor

  • new ContentApi(dbApi: DatabaseApi, chainApi: ChainApi): ContentApi

Methods

addContent

  • addContent(content: SubmitObject, privateKey: string): Promise<void>
  • Submit content to blockchain Need to supply control checksum 'ripemdHash' and 'key' generated by seeders in getContentKeys

    Parameters

    Returns Promise<void>

buyContent

  • buyContent(contentId: string, buyerId: string, elGammalPub: string, privateKey: string): Promise<void>
  • Request buy content.

    Parameters

    • contentId: string

      Id of content to be bought, example: '1.2.123'

    • buyerId: string

      Account id of user buying content, example: '1.2.123'

    • elGammalPub: string

      ElGammal public key which will be used to identify users bought content

    • privateKey: string

    Returns Promise<void>

generateContentKeys

  • generateContentKeys(seeders: string[]): Promise<ContentKeys>
  • Obtains content key with key parts of each seeder to encrypt content to be uploaded.

    Parameters

    • seeders: string[]

      Array of seeders ids example: ['1.2.12', '1.4.13']

    Returns Promise<ContentKeys>

getContent

  • getContent(id: string): Promise<Content>
  • Fetch content object from blockchain for given content id

    Parameters

    • id: string

      example: '1.2.345'

    Returns Promise<Content>

getPurchasedContent

  • getPurchasedContent(accountId: string, order?: string, startObjectId?: string, term?: string, resultSize?: number): Promise<Content[]>
  • Return all purchased content for account id.

    Parameters

    • accountId: string

      example: '1.2.345'

    • Default value order: string = SearchParamsOrder.createdDesc

      example: '1.2.345'

    • Default value startObjectId: string = "0.0.0"

      example: '1.2.345'

    • Default value term: string = ""

      example: '1.2.345'

    • Default value resultSize: number = 100

      Number of results default = 100

    Returns Promise<Content[]>

getSeeders

  • getSeeders(resultSize?: number): Promise<Seeder[]>
  • List available seeders ordered by price.

    Parameters

    • Default value resultSize: number = 100

      Number of results per request. Default 100(max)

    Returns Promise<Seeder[]>

removeContent

  • removeContent(contentId: string, authorId: string, privateKey: string): Promise<void>
  • Cancel submitted content record from blockchain.

    Parameters

    • contentId: string

      example: '2.13.1234'

    • authorId: string

      example: '1.2.532'

    • privateKey: string

    Returns Promise<void>

restoreContentKeys

  • restoreContentKeys(contentId: string, accountId: string, ...elGamalKeys: KeyPair[]): Promise<string>
  • Restores key to decrypt downloaded content.

    ElGamalPrivate contains keys used to identify if user have bought content. May contains older keys, if elGamal keys pair were changed, to restore content bought before keys have been changed. Otherwise content keys would not be restored.

    memberof

    ContentApi

    Parameters

    • contentId: string

      example: '1.2.453'

    • accountId: string

      example: '1.2.453'

    • Rest ...elGamalKeys: KeyPair[]

    Returns Promise<string>

searchContent

  • searchContent(searchParams: SearchParams): Promise<Content[]>
  • Searches content submitted to dcore_js network and is not expired.

    Parameters

    • searchParams: SearchParams

    Returns Promise<Content[]>

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc