did

package
v0.7.6 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: GPL-3.0 Imports: 14 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidFragment   = errors.New("fragment must be a valid NanoID")
	ErrMissingFragment   = errors.New("missing fragment")
	ErrInvalidDID        = errors.New("invalid DID")
	ErrEmptyDID          = errors.New("empty DID")
	ErrDIDIsNil          = errors.New("DID is nil")
	ErrInvalidPrefix     = fmt.Errorf("invalid prefix. Must start with  %s", ma.DID_PREFIX)
	ErrInvalidFormat     = errors.New("invalid DID format, must contain both an identifier and a fragment and nothing else")
	ErrInvalidIdentifier = errors.New("identifier must be a valid IPNS name")
	ErrMissingIdentifier = errors.New("missing identifier")
	ErrIPFSKeyNotFound   = errors.New("ipfsKey not found")
)

Functions

func AreIdentical

func AreIdentical(did1 DID, did2 DID) bool

AreIdentical checks if two DIDs have the same ID, ignoring the fragment. This is a stretched interpretation of the word Identical, but I couldn't help myself. It means they are derived from the same key, which makes them Identical in my book.

func IsValid added in v0.6.0

func IsValid(didStr string) bool

func Validate added in v0.6.0

func Validate(didStr string) error

Types

type DID

type DID struct {
	// The Id is the full DID
	Id string
	// The Identifier is the IPNS name without the /ipns/ prefix
	Identifier string
	// The fragment is a NanoID that is used to identify the entity locally
	Fragment string
}

func GetOrCreate added in v0.6.1

func GetOrCreate(name string) (DID, error)

Creates a new DID my actually creating or fetching a new key in IPFS And get the names - notably the IPNS name from there.

func New

func New(didStr string) (DID, error)

This creates a new DID from an identifier. This is the base function for all the rest. The identitifier is the IPNS name and the fragment is the key shortname, eg did:ma:k51qzi5uqu5dj9807pbuod1pplf0vxh8m4lfy3ewl9qbm2s8dsf9ugdf9gedhr#bahner

Remember that is needs to pre-exist in IPFS or be published to IPFS to be useful.

func (*DID) IsIdenticalTo

func (d *DID) IsIdenticalTo(did DID) bool

func (*DID) IsValid

func (d *DID) IsValid() bool

ValidateDID checks if the DID is valid.

func (*DID) Name

func (d *DID) Name() string

func (*DID) Path added in v0.2.0

func (d *DID) Path() (path.Path, error)

func (*DID) PeerID added in v0.7.4

func (d *DID) PeerID() (peer.ID, error)

func (*DID) Verify added in v0.6.0

func (d *DID) Verify() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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