identity

package
v0.14.1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultPlcURL = "https://plc.directory"

DefaultPlcURL is the public PLC directory used when no override is configured.

Variables

This section is empty.

Functions

func DidToDocUrl

func DidToDocUrl(plcURL, did string) (string, error)

DidToDocUrl returns the URL of the DID document for did. did:plc documents are fetched from plcURL (DefaultPlcURL when empty).

func NormalizePlcURL added in v0.11.4

func NormalizePlcURL(raw string) (string, error)

NormalizePlcURL validates a PLC directory base URL and returns it without a trailing slash. An empty value yields DefaultPlcURL. Plain http is accepted so a local PLC directory can be used for testing.

func ResolveHandle

func ResolveHandle(ctx context.Context, cli *http.Client, handle string) (string, error)

func ResolveHandleFromTXT

func ResolveHandleFromTXT(ctx context.Context, handle string) (string, error)

func ResolveHandleFromWellKnown

func ResolveHandleFromWellKnown(ctx context.Context, cli *http.Client, handle string) (string, error)

func ResolveService

func ResolveService(ctx context.Context, cli *http.Client, plcURL, did string) (string, error)

Types

type BackingCache

type BackingCache interface {
	GetDoc(did string) (*DidDoc, bool)
	PutDoc(did string, doc *DidDoc) error
	BustDoc(did string) error

	GetDid(handle string) (string, bool)
	PutDid(handle string, did string) error
	BustDid(handle string) error
}

type DidAuditEntry

type DidAuditEntry struct {
	Did       string      `json:"did"`
	Operation DidLogEntry `json:"operation"`
	Cid       string      `json:"cid"`
	Nullified bool        `json:"nullified"`
	CreatedAt string      `json:"createdAt"`
}

type DidAuditLog

type DidAuditLog []DidAuditEntry

func FetchDidAuditLog

func FetchDidAuditLog(ctx context.Context, cli *http.Client, plcURL, did string) (DidAuditLog, error)

type DidData

type DidData struct {
	Did                 string                      `json:"did"`
	VerificationMethods map[string]string           `json:"verificationMethods"`
	RotationKeys        []string                    `json:"rotationKeys"`
	AlsoKnownAs         []string                    `json:"alsoKnownAs"`
	Services            map[string]OperationService `json:"services"`
}

func FetchDidData

func FetchDidData(ctx context.Context, cli *http.Client, plcURL, did string) (*DidData, error)

type DidDoc

type DidDoc struct {
	Context             []string                   `json:"@context"`
	Id                  string                     `json:"id"`
	AlsoKnownAs         []string                   `json:"alsoKnownAs"`
	VerificationMethods []DidDocVerificationMethod `json:"verificationMethod"`
	Service             []DidDocService            `json:"service"`
}

func FetchDidDoc

func FetchDidDoc(ctx context.Context, cli *http.Client, plcURL, did string) (*DidDoc, error)

type DidDocService

type DidDocService struct {
	Id              string `json:"id"`
	Type            string `json:"type"`
	ServiceEndpoint string `json:"serviceEndpoint"`
}

type DidDocVerificationMethod

type DidDocVerificationMethod struct {
	Id                 string `json:"id"`
	Type               string `json:"type"`
	Controller         string `json:"controller"`
	PublicKeyMultibase string `json:"publicKeyMultibase"`
}

type DidLog

type DidLog []DidLogEntry

type DidLogEntry

type DidLogEntry struct {
	Sig                 string                      `json:"sig"`
	Prev                *string                     `json:"prev"`
	Type                string                      `json:"string"`
	Services            map[string]OperationService `json:"services"`
	AlsoKnownAs         []string                    `json:"alsoKnownAs"`
	RotationKeys        []string                    `json:"rotationKeys"`
	VerificationMethods map[string]string           `json:"verificationMethods"`
}

type MemCache

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

func NewMemCache

func NewMemCache(size int) *MemCache

func (*MemCache) BustDid

func (mc *MemCache) BustDid(handle string) error

func (*MemCache) BustDoc

func (mc *MemCache) BustDoc(did string) error

func (*MemCache) GetDid

func (mc *MemCache) GetDid(handle string) (string, bool)

func (*MemCache) GetDoc

func (mc *MemCache) GetDoc(did string) (*DidDoc, bool)

func (*MemCache) PutDid

func (mc *MemCache) PutDid(handle string, did string) error

func (*MemCache) PutDoc

func (mc *MemCache) PutDoc(did string, doc *DidDoc) error

type OperationService

type OperationService struct {
	Type     string `json:"type"`
	Endpoint string `json:"endpoint"`
}

type Passport

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

func NewPassport

func NewPassport(h *http.Client, bc BackingCache, opts ...PassportOption) *Passport

NewPassport uses restricted web fetching and a separate client for the configured PLC directory. An explicit client overrides both defaults.

func (*Passport) BustDid

func (p *Passport) BustDid(ctx context.Context, handle string) error

func (*Passport) BustDoc

func (p *Passport) BustDoc(ctx context.Context, did string) error

func (*Passport) FetchDoc

func (p *Passport) FetchDoc(ctx context.Context, did string) (*DidDoc, error)

func (*Passport) ResolveHandle

func (p *Passport) ResolveHandle(ctx context.Context, handle string) (string, error)

type PassportOption added in v0.11.4

type PassportOption func(*Passport)

PassportOption configures optional Passport behavior.

func WithPlcURL added in v0.11.4

func WithPlcURL(plcURL string) PassportOption

WithPlcURL sets the PLC directory used to resolve did:plc documents. An empty value keeps DefaultPlcURL.

Jump to

Keyboard shortcuts

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