did

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: GPL-3.0 Imports: 8 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidID       = errors.New("invalid ID")
	ErrInvalidFragment = errors.New("invalid fragment")
)

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 GenerateFragment

func GenerateFragment() string

func GetFragment

func GetFragment(did string) string

func GetIdentifier

func GetIdentifier(did string) string

func IsValidDID

func IsValidDID(didStr string) bool

func IsValidFragment

func IsValidFragment(str string) bool

This simply checks that the string is a valid nanoID, prefixed with a "#".

func IsValidIdentifier

func IsValidIdentifier(identifier string) bool

func ValidateDID

func ValidateDID(didStr string) error

Types

type DID

type DID struct {
	// The identifier is the IPNS name without the /ipns/ prefix
	Identifier string
	// The Fragment is the key shortname and internal name for the key
	Fragment string
}

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) Path added in v0.2.0

func (d *DID) Path(space string) string

func (*DID) String

func (d *DID) String() string

Directories

Path Synopsis
doc
cmd

Jump to

Keyboard shortcuts

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