ccme

package
v0.0.0-...-8ec9e52 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: 0BSD Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultBaseURL = "https://cc.me/"

DefaultBaseURL is the public cc.me endpoint.

Variables

This section is empty.

Functions

func GeneratePrivateKey

func GeneratePrivateKey() (string, error)

GeneratePrivateKey returns a freshly generated private key: a 32-byte Ed25519 seed encoded as base64url without padding.

func PrivateKey

func PrivateKey(path string) (string, error)

PrivateKey loads the base64url seed from path, creating it (mode 0600) with a freshly generated key if it does not exist. An existing file is reused and re-secured to 0600. The file contains the base64url seed followed by a newline.

func TrampolineURL

func TrampolineURL(target string, opts ...func(*urlConfig)) string

TrampolineURL builds GET {base}/?at={target} plus any extra query params.

func WithBaseURL

func WithBaseURL(baseURL string) func(*urlConfig)

WithBaseURL overrides the base URL for a builder call.

func WithParams

func WithParams(params map[string]string) func(*urlConfig)

WithParams adds extra query parameters (used by TrampolineURL).

Types

type AliasResponse

type AliasResponse struct {
	URL string `json:"url"`
}

AliasResponse is the result of CreateAlias.

func CreateAlias

func CreateAlias(target string, opts ...func(*urlConfig)) (AliasResponse, error)

CreateAlias registers a permanent alias for target: POST {base}/c with {"at": target}. It is idempotent and requires no authentication.

type ClaimOptions

type ClaimOptions struct {
	Limit int
	Poll  bool
}

ClaimOptions controls Claim.

type Client

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

Client talks to a cc.me inbox using a private key for owner authentication.

func NewClient

func NewClient(baseURL, privateKey string) (*Client, error)

NewClient constructs a Client. If baseURL is empty, DefaultBaseURL is used.

func (*Client) Ack

func (c *Client) Ack(ids []string) (IDResponse, error)

Ack confirms handling of the given delivery ids.

func (*Client) Claim

func (c *Client) Claim(opts ClaimOptions) (*DeliveryResponse, error)

Claim reserves up to Limit deliveries until they are acked or released.

func (*Client) CloudEventsURL

func (c *Client) CloudEventsURL() string

CloudEventsURL returns the cloudevents receiver URL.

func (*Client) DiscordURL

func (c *Client) DiscordURL(appPublicKey string) string

DiscordURL returns the discord receiver URL for the given app public key.

func (*Client) InboxURL

func (c *Client) InboxURL(opts InboxOptions) string

InboxURL returns the inbox URL with optional query parameters.

func (*Client) MetaURL

func (c *Client) MetaURL(verifyToken string) string

MetaURL returns the meta receiver URL, appending ?v={verifyToken} when set.

func (*Client) Peek

func (c *Client) Peek(opts PeekOptions) (*DeliveryResponse, error)

Peek fetches deliveries without reserving them.

func (*Client) PingbackURL

func (c *Client) PingbackURL() string

PingbackURL returns the pingback receiver URL.

func (*Client) Release

func (c *Client) Release(ids []string) (IDResponse, error)

Release returns the given delivery ids to the queue.

func (*Client) SlackURL

func (c *Client) SlackURL() string

SlackURL returns the slack receiver URL.

func (*Client) WebmentionURL

func (c *Client) WebmentionURL() string

WebmentionURL returns the webmention receiver URL.

func (*Client) WebsubURL

func (c *Client) WebsubURL() string

WebsubURL returns the websub receiver URL.

type Delivery

type Delivery struct {
	ID               string
	ReceivedAtUnixMs int64
	Method           string
	Path             string
	Query            string
	Headers          []Header
	BodyBytes        []byte
}

Delivery is a decrypted captured request.

func (*Delivery) JSON

func (d *Delivery) JSON(v any) error

JSON unmarshals the body into v.

func (*Delivery) Text

func (d *Delivery) Text() string

Text returns the body decoded as a UTF-8 string.

type DeliveryResponse

type DeliveryResponse struct {
	Count    int
	Cursor   string
	Requests []*Delivery
}

DeliveryResponse holds the decrypted deliveries from peek/claim.

type Header struct {
	Name       string
	Value      string
	ValueBytes []byte
}

Header is a single captured request header. Value is the UTF-8 decoding of ValueBytes; ValueBytes holds the raw bytes.

type IDResponse

type IDResponse struct {
	Acked    int      `json:"acked"`
	Released int      `json:"released"`
	Missing  []string `json:"missing"`
}

IDResponse is the result of Ack and Release.

type InboxOptions

type InboxOptions struct {
	// Limit, when > 0, sets the `l` query parameter.
	Limit int
	// Cursor, when non-empty, sets the `c` query parameter.
	Cursor string
	// Poll, when true, sets the `p` query parameter with an empty value.
	Poll bool
}

InboxOptions controls the optional query parameters on an inbox URL.

type PeekOptions

type PeekOptions = InboxOptions

PeekOptions controls Peek.

Jump to

Keyboard shortcuts

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