IDX library

Installation

npm install @ceramicstudio/idx

IDX class

constructor

Arguments

  1. options: IDXOptions

.authenticate

Arguments

  1. options?: AuthenticateOptions

Returns Promise<void>

.authenticated

Returns boolean

.ceramic

Returns CeramicApi

.resolver

Returns Resolver

.did

Accessing this property will throw an error if the instance is not authenticated

Returns DID

.id

Accessing this property will throw an error if the instance is not authenticated

Returns string

.isSupported

Checks if the provided did supports IDX. Calling methods such as get using a DID without IDX support will result in these methods returning null or other fallbacks.

If the did argument is not provided, the check will be performed on the DID authenticated with the IDX instance. Calling mutation methods such as set using a DID without IDX support will throw errors.

Arguments

  1. did?: string

Returns Promise<boolean>

.has

Returns whether an entry with the name alias, IndexKey or definition DocID string exists in the Identity Index of the specified did

Arguments

  1. name: string
  2. did?: string = this.id

Returns Promise<boolean>

.get

Returns the referenced content for the given name alias, IndexKey or definition DocID string of the specified did

Arguments

  1. name: string
  2. did?: string = this.id

Returns Promise<unknown>

.set

Sets the content for the given name alias, IndexKey or definition DocID string in the Identity Index of the authenticated DID

The provided options are only applied if the document is being created, if it already exists they are ignored

Arguments

  1. name: string
  2. content: unknown
  3. options?: CreateOptions

Returns Promise<DocID> the DocID of the created content document

.merge

Performs a shallow (only one level) merge the contents for the given name alias, IndexKey or definition DocID string in the Identity Index of the authenticated DID

The provided options are only applied if the document is being created, if it already exists they are ignored

Arguments

  1. name: string
  2. content: unknown
  3. options?: CreateOptions

Returns Promise<DocID> the DocID of the created content document

.setAll

Similar to the set method but for setting multiple keys at once in a more efficient way.

The Identity Index document will only get updated if all the contents are successfully set.

Arguments

  1. contents: Record<string, unknown>
  2. options?: CreateOptions

.setDefaults

Similar to the setAll method but only sets contents for keys that are not already present in the Identity Index document.

Arguments

  1. contents: Record<string, unknown>
  2. options?: CreateOptions

.remove

Removes the definition for the name alias, IndexKey or definition DocID string in the Identity Index of the authenticated DID

Arguments

  1. name: string

Returns Promise<void>

.getIDXDocID

Returns the DocID of the Identity Index associated to the given did

Arguments

  1. did: string

Returns Promise<DocID | null>

.getIDXContent

Returns the contents of the Identity Index associated to the given did

Arguments

  1. did?: string = this.id

Returns Promise<IdentityIndexContent | null>

.contentIterator

Returns an async iterator of ContentEntry for the given did

Arguments

  1. did?: string = this.id

Returns AsyncIterableIterator<ContentEntry>

.getDefinition

Loads an existing Definition by its DocID string or IndexKey

Arguments

  1. id: string

Returns Promise<Definition>