Options
All
  • Public
  • Public/Protected
  • All
Menu

Module @ceramicnetwork/docid

Ceramic DocId

This package contains Ceramic DocId implementation.

Implements Ceramic DocIDs as defined in ceramic spec and CIP

<docid> ::= <multibase-prefix><multicodec-docid><doctype><genesis-cid-bytes>

or including DocID commit

<docid> ::= <multibase-prefix><multicodec-docid><doctype><genesis-cid-bytes><commit-cid-bytes>

Getting started

Installation

$ npm install @ceramicnetwork/docid

Usage

You can create an instance from the parts. Document type string or integer and CID instance or string are required. Commit CID and multibaseName are optional and default to null and 'base36' respectively.

import DocID from '@ceramicnetwork/docid'

const docid = new DocId('tile', 'bagcqcerakszw2vsov...', commit, 'devnet', 'base36)

docid.type           // 0
docid.typeName       // 'tile'
docid.multibaseName  // 'base36'
docid.bytes          // Uint8Array(41) [ 206,   1,   0,   0,   1, 133,   1, ...] 
docid.cid            // CID('bagcqcerakszw2vsov...')
docid.toString()     
//k3y52l7mkcvtg023bt9txegccxe1bah8os3naw5asin3baf3l3t54atn0cuy98yws
docid.toUrl()   
//ceramic://k3y52l7mkcvtg023bt9txegccxe1bah8os3naw5asin3baf3l3t54atn0cuy98yws

You can also create DocID instance from DocID string or bytes.

const docid = DocID.fromString('k3y52l7mkcvtg023bt9txe...')
const docid = DocID.fromBytes(Uint8Array(41) [ 206,   1,   0,   0,   1, 133,   1, ...])

Development

Run tests:

$ npm test

Run linter:

npm run lint

Contributing

We are happy to accept small and large contributions. Make sure to check out the Ceramic specifications for details of how the protocol works.

License

Index

Classes

Variables

Functions

Object literals

Variables

Const DEFAULT_BASE

DEFAULT_BASE: "base36" = "base36"

Const DOCID_CODEC

DOCID_CODEC: 206 = 206

Functions

Const getKey

  • getKey(obj: {}, value: number): string | undefined

Object literals

Const table

table: object

caip10-link

caip10-link: number = 1

tile

tile: number = 0