threeid

package
v0.0.0-...-f291c22 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 24, 2021 License: Apache-2.0 Imports: 11 Imported by: 2

Documentation

Overview

Package threeid provides tools for resolving the did:3 method format for the ceramic network: https://github.com/ceramicnetwork/CIP/blob/main/CIPs/CIP-79/CIP-79.md Copyright 2021 Textile Copyright 2021 Ceramic Network

Package threeid provides tools for resolving the did:3 method format for the ceramic network: https://github.com/ceramicnetwork/CIP/blob/main/CIPs/CIP-79/CIP-79.md Copyright 2021 Textile Copyright 2021 Ceramic Network

Package threeid provides tools for resolving the did:3 method format for the ceramic network: https://github.com/ceramicnetwork/CIP/blob/main/CIPs/CIP-79/CIP-79.md Copyright 2021 Textile Copyright 2021 Ceramic Network

Index

Constants

View Source
const (
	// DefaultAPIPath is the default version path for the Ceramic api
	DefaultAPIPath = "/api/v0"
	// DefaultHost is the default host path/url for the Ceramic api
	DefaultHost = "http://localhost:7007"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AnchorProof

type AnchorProof struct {
	ChainID        string `json:"chainId,omitempty"`
	BlockNumber    uint64 `json:"blockNumber,omitempty"`
	BlockTimestamp uint64 `json:"blockTimestamp,omitempty"`
	TxHash         string `json:"txHash,omitempty"`
	Root           string `json:"root,omitempty"`
}

AnchorProof represents metadata about the on-chain anchor proof.

type Client

type Client interface {
	LoadDocument(docID DocIdentifier) (*DocState, error)
}

Client is a basic client interface for interacting with the Ceramic network.

type CommitID

type CommitID struct {
	DocID
	// contains filtered or unexported fields
}

CommitID is a commit identifier, includes doctype, genesis cid, commit cid.

func (*CommitID) Bytes

func (doc *CommitID) Bytes() []byte

Bytes returns the bytes representation for a doc id.

func (*CommitID) Commit

func (doc *CommitID) Commit() cid.Cid

Commit returns the document commit cid.

func (*CommitID) String

func (doc *CommitID) String() string

type DocID

type DocID struct {
	// contains filtered or unexported fields
}

DocID is a document identifier, no commit information included. Encoded as '<multibase-prefix><multicodec-docid><doctype><genesis-cid-bytes>'

func (*DocID) AtCommit

func (doc *DocID) AtCommit(commit cid.Cid) (*CommitID, error)

AtCommit returns a CommitID based on the DocID

func (*DocID) Bytes

func (doc *DocID) Bytes() []byte

Bytes returns the bytes representation for a doc id.

func (*DocID) CID

func (doc *DocID) CID() cid.Cid

CID returns the document cid. The genesis cid is undefined (i.e., cid.Undef).

func (*DocID) String

func (doc *DocID) String() string

func (*DocID) Type

func (doc *DocID) Type() uint64

Type returns the document type.

type DocIdentifier

type DocIdentifier interface {
	fmt.Stringer
	Type() uint64
	CID() cid.Cid
	Bytes() []byte
}

DocIdentifier defines any cid-based document with a type and bytes representation.

type DocMetadata

type DocMetadata struct {
	Controllers []string `json:"controllers,omitempty"`
	Schema      string   `json:"schema,omitempty"`
	Tags        []string `json:"tags,omitempty"`
}

DocMetadata represents metadata about the primary ceramic document.

type DocNext

type DocNext struct {
	Content     *json.RawMessage `json:"content,omitempty"`
	Controllers []string         `json:"contollers,omitempty"`
	Metadata    DocMetadata      `json:"metadata,omitempty"`
}

DocNext represents information about the next iteration.

type DocResponse

type DocResponse struct {
	DocID string   `json:"docId"`
	State DocState `json:"state"`
}

DocResponse represents the primary document query response.

type DocState

type DocState struct {
	Doctype            string           `json:"doctype"`
	Content            *json.RawMessage `json:"content,omitempty"`
	Next               DocNext          `json:"next,omitempty"`
	Metadata           DocMetadata      `json:"metadata,omitempty"`
	Signature          uint64           `json:"signature,omitempty"`          // 0=GENESIS, 1=PARTIAL, 2=SIGNED
	AnchorStatus       string           `json:"anchorStatus,omitempty"`       // NOT_REQUESTED, PENDING, PROCESSING, ANCHORED, FAILED
	AnchorScheduledFor uint64           `json:"anchorScheduledFor,omitempty"` // only present when anchor status is pending
	AnchorProof        AnchorProof      `json:"anchorProof,omitempty"`        // The anchor proof of the latest anchor, only present when anchor status is anchored
	Log                []LogEntry       `json:"log,omitempty"`
}

DocState represents the primary ceramic document.

type HTTPClient

type HTTPClient struct {
	APIURL string
}

HTTPClient interfaces with the ceramic network via local or remote ceramic daemon.

func (*HTTPClient) Load

func (client *HTTPClient) Load(docID DocIdentifier) (*DocResponse, error)

Load fetches the remote Ceramic document and returns it.

func (*HTTPClient) LoadDocument

func (client *HTTPClient) LoadDocument(docID DocIdentifier) (*DocState, error)

LoadDocument loads a ceramic document using a local or remote ceramic daemon.

type LogEntry

type LogEntry struct {
	// TODO: We actually want this as a cid.CID at some point
	// CID  cid.Cid
	CID  string `json:"cid"`
	Type uint   `json:"type"`
}

LogEntry represents an entry in a document's update history.

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}

Resolver defines a basic key resolver, conforming the to Resolver interface.

func New

func New() *Resolver

New creates and returns a new key Resolver.

func (*Resolver) Method

func (r *Resolver) Method() string

Method returns the method that this resolver is capable of resolving.

func (*Resolver) Resolve

func (r *Resolver) Resolve(did string, parsed *did.DID, res resolver.Resolver) (*resolver.Document, error)

Resolve is the primary resolution method for this resolver.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL