invite

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: GPL-3.0 Imports: 10 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

Overview

Package invite formats and parses the invite link

https://<host>/peer/i/<channel id>#v1.<token>.<rootpub>.<exp>.<secret>

(design §4). The fragment never reaches a server; it carries the one-time invite token, the inviter's Ed25519 root public key (base64url, no padding), the expiry (unix seconds) and the link secret: 16 random bytes the relay never sees, which the guest proves at accept and which binds the verification code to this invite. A link is valid for 72 h.

Index

Constants

View Source
const LinkKeySize = 32

LinkKeySize is a feed link key's length in bytes.

View Source
const SecretSize = 16

SecretSize is the link secret's length in bytes.

View Source
const Validity = 72 * time.Hour

Validity is how long a new link stays valid.

Variables

View Source
var (
	ErrMalformed = errors.New("invite: malformed link")
	ErrExpired   = errors.New("invite: link expired")
)

Functions

func NewSecret

func NewSecret() ([]byte, error)

NewSecret draws a link secret.

Types

type Feed added in v0.2.0

type Feed struct {
	Relay string            // relay base, e.g. https://example.com/peer
	Room  string            // room id
	Token string            // the read token
	Key   []byte            // LinkKeySize bytes
	Owner ed25519.PublicKey // the owner's room signing key
}

Feed is the second form of link (contract § Sealed record, Feed link):

https://<host>/peer/f/<room id>#v1.<readToken>.<linkKey>.<ownerSign>

The fragment carries the feed's multi-use read token, the link key the link stanza's X25519 key derives from, and the owner's room signing key, the key a holder verifies every record under. It does not expire: a new link cuts every old holder off.

func ParseFeed added in v0.2.0

func ParseFeed(s string) (Feed, error)

ParseFeed reads a feed link and refuses anything else: a v1 invite link, a link whose fragment is not v1.<readToken>.<linkKey>.<ownerSign>, a key of the wrong size.

func (Feed) Check added in v0.2.0

func (f Feed) Check() error

Check refuses a feed link with a bad room id, token, key or relay base.

func (Feed) String added in v0.2.0

func (f Feed) String() string

String renders the feed link.

type Link struct {
	Relay   string            // relay base, e.g. https://example.com/peer
	Channel string            // channel id
	Token   string            // one-time invite token
	Root    ed25519.PublicKey // inviter's root key, pinned on accept
	Expires time.Time         // whole seconds
	Secret  []byte            // SecretSize bytes, known to the two CLIs alone
}

Link is a parsed invite.

func New

func New(relayBase, channel, token string, root ed25519.PublicKey, secret []byte, now time.Time) (Link, error)

New makes a link that expires Validity after now.

func Parse

func Parse(s string, now time.Time) (Link, error)

Parse reads a link and refuses it when it is malformed or expired at now.

func (Link) String

func (l Link) String() string

String renders the link.

Jump to

Keyboard shortcuts

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