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>
$ npm install @ceramicnetwork/docid
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, ...])
Run tests:
$ npm test
Run linter:
npm run lint
We are happy to accept small and large contributions. Make sure to check out the Ceramic specifications for details of how the protocol works.
Ceramic DocId
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.
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