Options
All
  • Public
  • Public/Protected
  • All
Menu

Module @ceramicnetwork/core

Ceramic Core

This package contains the implementation of the core Ceramic protocol. It's exposed using a simple JavaScript API.

Getting started

Installation

$ npm install @ceramicnetwork/core

Usage

import Ceramic from '@ceramicnetwork/core'

import IPFS from 'ipfs'
import dagJose from 'dag-jose'
import basicsImport from 'multiformats/cjs/src/basics-import.js'
import legacy from 'multiformats/cjs/src/legacy.js'

basicsImport.multicodec.add(dagJose)
const format = legacy(basicsImport, dagJose.name)

const ipfs = Ipfs.create({
    ipld: { formats: [format] },
})

const config: CeramicConfig = {}
const ceramic = await Ceramic.create(ipfs, config)

// create document example
const doctype1 = await ceramic.createDocument('tile', { content: { test: 123 } })

Ceramic API

Complete Ceramic core API is available on Ceramic API.

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

Type aliases

Props

Props: { networkName?: string; pinningBackends?: PinningBackendStatic[]; pinningEndpoints?: string[]; pinsetDirectory?: string }

Type declaration

  • Optional networkName?: string
  • Optional pinningBackends?: PinningBackendStatic[]
  • Optional pinningEndpoints?: string[]
  • Optional pinsetDirectory?: string

Variables

Const BASE_CHAIN_ID

BASE_CHAIN_ID: "eip155" = "eip155"

Const CHAIN_ID

CHAIN_ID: "inmemory:12345" = "inmemory:12345"

Const DEFAULT_DOC_CACHE_LIMIT

DEFAULT_DOC_CACHE_LIMIT: 500 = 500

Const DEFAULT_MAX_POLL_TIME

DEFAULT_MAX_POLL_TIME: 7200000 = 7200000

Const DEFAULT_NETWORK

DEFAULT_NETWORK: "inmemory" = "inmemory"

Const DEFAULT_PINSET_DIRECTORY

DEFAULT_PINSET_DIRECTORY: string = path.join(os.homedir(), ".ceramic", "pinset")

Const DEFAULT_POLL_TIME

DEFAULT_POLL_TIME: 60000 = 60000

Const DID_MATCHER

DID_MATCHER: "^(did:([a-zA-Z0-9_]+):([a-zA-Z0-9_.-]+(:[a-zA-Z0-9_.-]+)*)((;[a-zA-Z0-9_.:%-]+=[a-zA-Z0-9_.:%-]*)*)(/[^#?]*)?)([?][^#]*)?(#.*)?" = "^(did:([a-zA-Z0-9_]+):([a-zA-Z0-9_.-]+(:[a-zA-Z0-9_.-]+)*)((;[a-zA-Z0-9_.:%-]+=[a-zA-Z0-9_.:%-]*)*)(/[^#?]*)?)([?][^#]*)?(#.*)?"

Const HTTP_STATUS_NOT_FOUND

HTTP_STATUS_NOT_FOUND: 404 = 404

Const IPFS_GET_TIMEOUT

IPFS_GET_TIMEOUT: 60000 = 60000

Const IPFS_GET_TIMEOUT

IPFS_GET_TIMEOUT: 60000 = 60000

Const IPFS_GET_TIMEOUT

IPFS_GET_TIMEOUT: 60000 = 60000

Const IPFS_MAX_RECORD_SIZE

IPFS_MAX_RECORD_SIZE: 256000 = 256000

Const IPFS_RESUBSCRIBE_INTERVAL_DELAY

IPFS_RESUBSCRIBE_INTERVAL_DELAY: number = 1000 * 15

Const MAX_NUMBER_OF_EVENT_LISTENERS

MAX_NUMBER_OF_EVENT_LISTENERS: 100 = 100

Const PEER_DISCOVERY_INTERVAL_DELAY

PEER_DISCOVERY_INTERVAL_DELAY: number = 1000 * 60 * 60

Const TESTING

TESTING: boolean = process.env.NODE_ENV == 'test'

Const TESTING

TESTING: boolean = process.env.NODE_ENV == 'test'

Let peerDiscoveryPeriodicTask

peerDiscoveryPeriodicTask: any

Functions

cancelPeriodicConnectToPeersTask

  • cancelPeriodicConnectToPeersTask(): Promise<void>

connectToPeers

  • connectToPeers(network: string, ipfs: IpfsApi): Promise<void>
  • As a temporary workaround to the js-ipfs DHT being broken, we are doing ipfs peer discovery manually by querying a centralized file that lists all registered ceramic nodes.

    Parameters

    • network: string

      ceramic network name

    • ipfs: IpfsApi

      ipfs connection

    Returns Promise<void>

fetchJson

  • fetchJson(url: string): Promise<any>

Const normalizeDocID

periodicallyConnectToPeers

  • periodicallyConnectToPeers(network: string, ipfs: IpfsApi): Promise<void>
  • Calls connectToPeers once, then starts a background task to periodically re-call it.

    Parameters

    • network: string

      ceramic network name

    • ipfs: IpfsApi

      ipfs connection

    Returns Promise<void>

Const promiseTimeout

  • promiseTimeout(ms: number, promise: Promise<any>): Promise<any>

Const tryDocId

  • tryDocId(id: string): DocID | null

Object literals

Const DEFAULT_LOAD_DOCOPTS

DEFAULT_LOAD_DOCOPTS: object

anchor

anchor: boolean = false

publish

publish: boolean = false

sync

sync: boolean = true

Const DEFAULT_WRITE_DOCOPTS

DEFAULT_WRITE_DOCOPTS: object

anchor

anchor: boolean = true

publish

publish: boolean = true

sync

sync: boolean = false

Const ETH_CHAIN_ID_MAPPINGS

ETH_CHAIN_ID_MAPPINGS: object

Maps some of Ethereum chain IDs to network configuration

eip155:1

eip155:1: object

chain

chain: string = "ETH"

chainId

chainId: number = 1

network

network: string = "mainnet"

networkId

networkId: number = 1

type

type: string = "Production"

eip155:3

eip155:3: object

chain

chain: string = "ETH"

chainId

chainId: number = 3

network

network: string = "ropsten"

networkId

networkId: number = 3

type

type: string = "Test"

Const PEER_FILE_URLS

PEER_FILE_URLS: object

dev-unstable

dev-unstable: string = "https://raw.githubusercontent.com/ceramicnetwork/peerlist/main/dev-unstable.json"

testnet-clay

testnet-clay: string = "https://raw.githubusercontent.com/ceramicnetwork/peerlist/main/testnet-clay.json"