carddav

package
v1.40.2 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 19 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidURL       = errors.New("invalid CardDAV server URL")
	ErrScheme           = errors.New("CardDAV server URL must use https")
	ErrUntrustedOrigin  = errors.New("CardDAV discovery target outside server domain")
	ErrAuthFailed       = errors.New("CardDAV authentication failed")
	ErrNoAddressBooks   = errors.New("no CardDAV address books found")
	ErrSyncTokenInvalid = errors.New("CardDAV sync-token expired or unsupported")
)

Functions

func NormalizeURL

func NormalizeURL(raw string) (*url.URL, error)

NormalizeURL parses and validates a user-supplied or preset CardDAV URL. Hostnames without a scheme default to https://; http:// is permitted only on loopback.

Types

type CardEmail

type CardEmail struct {
	Pos     int
	AddrKey string
	Address string
	Pref    bool
}

CardEmail is one normalized email address parsed from a vCard.

type CardPhoto

type CardPhoto struct {
	Data []byte
	URL  string
}

CardPhoto is either inline image bytes or an external https:// URI from PHOTO.

type Client

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

func NewClient

func NewClient(transport http.RoundTripper) *Client

func (*Client) Discover

func (c *Client) Discover(ctx context.Context, start *url.URL, creds Credentials) (string, []DiscoveredCollection, error)

Discover resolves an addressbook-home-set URL and its addressbook collections following RFC 6764 (/.well-known/carddav) and RFC 6352 (principal -> home-set).

func (*Client) FetchCards

func (c *Client) FetchCards(ctx context.Context, home *url.URL, colHref string, hrefs []string, creds Credentials) ([]FetchedCard, error)

FetchCards downloads vCard payloads for hrefs in batches via card:addressbook-multiget REPORT.

func (*Client) ListCollectionETags

func (c *Client) ListCollectionETags(ctx context.Context, home *url.URL, colHref string, creds Credentials) (map[string]string, string, string, error)

ListCollectionETags lists every member vCard href -> ETag in colHref via PROPFIND Depth: 1.

func (*Client) ListCollections

func (c *Client) ListCollections(ctx context.Context, home *url.URL, creds Credentials, countCards bool) ([]DiscoveredCollection, error)

ListCollections lists all card:addressbook collections under home (or home itself if it is one).

func (*Client) SyncCollection

func (c *Client) SyncCollection(ctx context.Context, home *url.URL, colHref, syncToken string, creds Credentials) (SyncDelta, error)

SyncCollection queries incremental changes since syncToken via RFC 6578 sync-collection REPORT. Returns ErrSyncTokenInvalid when the token is expired or the server does not support sync-collection.

type Credentials

type Credentials struct {
	Username, Password string
	BearerToken        string
}

type DiscoveredCollection

type DiscoveredCollection struct {
	Href      string
	Name      string
	SyncToken string
	CardCount int
}

type FetchedCard

type FetchedCard struct {
	Href     string
	ETag     string
	RawVCard string
}

type ParsedCard

type ParsedCard struct {
	FN     string
	Org    string
	Title  string
	Emails []CardEmail
	Photos []CardPhoto
}

ParsedCard holds the subset of vCard 3.0 / 4.0 fields Godwit caches (ADR 0040).

func ParseVCard

func ParseVCard(raw string) ParsedCard

ParseVCard extracts FN (falling back to ORG when blank), ORG, TITLE, EMAIL (with TYPE=PREF and PREF=1..100), and PHOTO from a vCard 3.0 or 4.0 payload.

type SyncDelta

type SyncDelta struct {
	NextSyncToken string
	Upserted      map[string]string // canonical path href -> etag
	Deleted       []string          // canonical path hrefs
}

Jump to

Keyboard shortcuts

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