1.5.0 • Published 10 months ago

@cere/media-sdk-client v1.5.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
10 months ago

@cere/media-sdk-client

Installation

Install the package:

NPM

npm install @cere/media-sdk-client --save

Yarn

yarn add @cere/media-sdk-client

Create an instance

The MediaSdkClient instance can be created using the static create method. It takes two arguments

Arguments

  • signer - an ethers compatible signer instance
  • chainNamespace - the Network namespace
  • chainId - the Network chainId

  • options - a config object to define the environment and tenant to connect to

    • deployment - the deployed environment to connect to
    • tenant - the tenant to connect to
  • logger - whether to enable debug logging for the client
interface MediaClientOptions {
  deployment: Deployment;
  tenant: Tenant;
  logger?: boolean;
}

type Deployment = 'production' | 'staging' | 'development' | 'local';
type Tenant = 'davinci' | 'cerefans';

Example

import { MediaClientOptions } from '@cere/media-sdk-client';

const signer = // Get Signer from currently connected wallet

// With default options
const client = await MediaSdkClient.create(signer)

// With config arguments
const client = await MediaSdkClient.create({ deployment: "development", tenant: "davinci" })

// With logger enabled
const client = await MediaSdkClient.create({ ...options, logger: true })

API

The methods provided by the MediaSdkClient are:

create()

Creates and initializes a new instance of MediaSdkClient.

Arguments:

  • signer (Signer): An ethers compatible signer instance for authentication.
  • chainNamespace: the Network namespace
  • chainId: the Network chainId

  • options (MediaClientOptions): Configuration options including deployment, tenant, and logger settings.

Returns:

MediaSdkClient - A promise that resolves to a new instance of MediaSdkClient.

getNftMetadata()

Gets detailed metadata for a specific NFT.

Arguments:

  • contractAddress (string): The contract address of the NFT collection.
  • nftId (number): The ID of the NFT within the collection.

Returns:

NftMetadata - An object containing NFT details like name, description, preview, and associated assets.

getNftAssets()

Retrieves assets associated with a specific NFT.

Arguments:

  • contractAddress (string): The contract address of the NFT collection.
  • nftId (number): The ID of the NFT within the collection.

Returns:

NftAsset[] - An array of NftAsset objects, each detailing an asset associated with the NFT including name, description, asset link, preview link, and content type.

getCanAccess()

Checks if a wallet has access to an NFT's content.

Arguments:

  • collectionAddress (string): The address of the Freeport Collection smart contract.
  • nftId (number): The ID of the NFT on the Freeport Collection smart contract.
  • walletAddress (string): The address to check access for. Defaults to the signer's address if not specified.

Returns:

boolean - Returns true if the given wallet address can access the given NFT, false otherwise.

getContentDek()

Retrieves the Data Encryption Key (DEK) for a given NFT's content.

Arguments:

  • collectionAddress (string): The address of the collection containing the NFT.
  • nftId (number): The ID of the NFT within the collection.
  • asset (string): The identifier for the asset to get the DEK for.

Returns:

GetContentDekResponse (string) - The DEK for the given NFT's content.

getContent()

Gets the decrypted content for a given NFT.

Arguments:

  • collectionAddress (string): The address of the collection containing the NFT.
  • walletAddress (string): The address of the wallet holding the NFT.
  • asset (string): The identifier for the asset to get the content for.

Returns:

GetContentResponse (Blob) - The decrypted content for the given NFT.

1.5.0

10 months ago

1.4.2-rc.16

11 months ago

1.4.2-rc.13

11 months ago

1.4.2-rc.12

11 months ago

1.4.2-rc.15

11 months ago

1.4.2-rc.14

11 months ago

1.4.2-rc.0

1 year ago

1.4.2-rc.9

1 year ago

1.4.2-rc.8

1 year ago

1.4.3

1 year ago

1.4.2-rc.11

11 months ago

1.4.2-rc.10

11 months ago

1.4.4-rc.1

1 year ago

1.4.4-rc.0

1 year ago

1.4.3-rc.3

1 year ago

1.4.3-rc.2

1 year ago

1.4.3-rc.1

1 year ago

1.4.3-rc.0

1 year ago

1.4.3-rc.5

1 year ago

1.4.3-rc.4

1 year ago

1.4.2-rc.2

1 year ago

1.4.1

1 year ago

1.4.2-rc.3

1 year ago

1.4.0

1 year ago

1.4.1-rc.3

1 year ago

1.4.1-rc.0

1 year ago

1.4.1-rc.1

1 year ago

1.4.0-rc.21

1 year ago

1.4.0-rc.17

1 year ago

1.4.0-rc.9

1 year ago

1.4.0-rc.11

1 year ago

1.4.0-rc.13

1 year ago

1.4.0-rc.12

1 year ago

1.4.0-rc.15

1 year ago

1.4.0-rc.14

1 year ago

1.4.0-rc.8

1 year ago

1.4.0-rc.6

1 year ago

1.4.0-rc.7

1 year ago

1.4.0-rc.5

1 year ago

1.4.0-rc.2

1 year ago

1.4.0-rc.3

1 year ago

1.4.0-rc.1

1 year ago

1.4.0-rc.0

1 year ago

1.3.0

1 year ago

1.3.0-rc.6

1 year ago

1.3.0-rc.5

1 year ago

1.3.0-rc.4

1 year ago

1.3.0-rc.3

1 year ago

1.3.0-rc.2

1 year ago

1.3.0-rc.0

1 year ago

1.3.0-rc.1

1 year ago

1.2.1-rc.4

1 year ago

1.2.1-rc.3

1 year ago

1.2.1-rc.2

1 year ago

1.2.1-rc.1

1 year ago

1.2.0

1 year ago

1.2.0-rc.0

1 year ago

1.1.0

1 year ago

1.1.0-rc.6

1 year ago

1.1.0-rc.5

1 year ago

1.1.0-rc.1

1 year ago