Documentation
¶
Overview ¶
Package tinyclient renders relay HTML pages and browser support modules.
App owns the HTTP surface, templates, page data and browser assets. It asks Backend for relay identity, policy and method results, and uses ActorResolver to associate a request with the authenticated public key. The daemon owns relay policy and relay writes.
New embeds the client with a local Backend. NewRemote renders against a relay's authenticated HTTP backend contract and proxies data protocols.
Pages use a shared shell in page.html. The shell supplies the navigation rail, content column, contextual panel and command footer. Each page template supplies one content section and remains readable when scripts are disabled. JavaScript modules progressively add signing, navigation, forms, components, room streams, file transfers and WebMCP controls.
Index ¶
- Constants
- func NewRemote(options RemoteOptions) (http.Handler, error)
- type AccountPreferencesReader
- type ActorResolver
- type App
- type Backend
- type ChatActivityReader
- type CustomHost
- type CustomView
- type CustomViewSource
- type Delivery
- type Features
- type FileLimits
- type Inbox
- type MemberInvites
- type NameDirectory
- type Notify
- type Options
- type PageData
- type Policy
- type PrivateReader
- type QRProvider
- type RemoteOptions
- type RetentionRule
- type RoomList
- type RoomMember
- type RoomMessage
- type RoomPage
- type RoomSummary
- type RoomsReader
- type Sites
- type Succession
Constants ¶
const BackendPath = "/api/tinyclient"
BackendPath is the read-only adapter endpoint mounted by App. It uses the relay's normal actor resolver; a client-supplied public key is never trusted.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AccountPreferencesReader ¶
type AccountPreferencesReader interface {
}
AccountPreferencesReader provides private, account-scoped preferences to server-rendered account pages. It is optional for small embedders.
type ActorResolver ¶
ActorResolver returns the authenticated public key associated with request. An empty key represents an anonymous browser request.
type App ¶
type App struct {
// contains filtered or unexported fields
}
func (*App) BackendHandler ¶
BackendHandler exposes the read contract without rendering HTML. Mount it at BackendPath when embedding the client separately from its data service. Query authorization remains the responsibility of Backend.Query.
type Backend ¶
type Backend interface {
Query(ctx context.Context, method string, params []json.RawMessage, actor string) (any, error)
Policy() Policy
URL() string
Slug() string
Identity() string
}
Backend supplies relay identity and the method calls used by page handlers. Query receives the request context, method name, JSON arguments and actor public key, and returns the method's JSON-shaped result. Policy, URL, slug and identity describe the relay rendered into each page.
type ChatActivityReader ¶
type CustomHost ¶
type CustomHost = policy.CustomHost
type CustomView ¶
CustomView describes a fenced-block renderer offered by the backend.
type CustomViewSource ¶
type CustomViewSource interface {
CustomViews() []CustomView
}
CustomViewSource is the optional backend summary of the custom views the renderers show in place of fenced code blocks: names and languages only.
type FileLimits ¶
type FileLimits = policy.FileLimits
type MemberInvites ¶
type MemberInvites = policy.MemberInvites
type NameDirectory ¶
type NameDirectory interface {
// NameFor returns the member name for a pubkey, or "" when it has none.
NameFor(ctx context.Context, pubkey string) string
// PubKeyFor returns the pubkey behind a member name, or "" when unknown.
PubKeyFor(ctx context.Context, name string) string
}
NameDirectory resolves relay member names for URLs. It is optional; a backend without it writes and reads hex pubkeys only.
type Options ¶
type Options struct {
Actor ActorResolver
QR QRProvider
// Version and Revision identify the relay build on the health page.
Version, Revision string
}
type PageData ¶
type PageData struct {
Activity chatActivityPage
Version string
Revision string
Title string
URL string
Slug string
Identity string
Policy policy.Policy
Actor string
Owner bool
Tab string
Notice string
Error string
Methods []string
Event any
Invite string
View string
Feed []any
Base string
Query url.Values
Private bool
Path string
Readme template.HTML
Tree []any
// Merge is the browsewikimerge detail shown by a wiki page compare view.
Merge any
// Connections lists the ways to open this relay in client apps that the
// viewer may see, with link placeholders already resolved.
Connections []any
// Rooms lists the rooms the viewer may see; the rooms rail renders it.
Rooms []any
// Callbacks lists the event callbacks shown beside each agent.
Callbacks []any
// CustomViews lists the owner's custom views on the Views page.
CustomViews []any
// Requests lists the access requests on the People page, pending first;
// Review is true when the viewer may decide them.
Requests []any
Review bool
}
type Policy ¶
Policy contains the relay settings displayed by the client. These aliases let embedders implement Backend without importing a relay-internal package.
func DefaultPolicy ¶
DefaultPolicy returns the standard presentation and feature settings.
type PrivateReader ¶
PrivateReader is implemented by the daemon so web pages use the same membership check as websocket and HTTP data paths. It is optional to keep webui usable with small embedders; those embedders get owner-only fallback.
type QRProvider ¶
QRProvider encodes text as an image for pages that show a connection QR.
type RemoteOptions ¶
type RemoteOptions struct {
BackendURL string
PublicURL string
// Transport optionally supplies TLS roots or other HTTP transport settings.
Transport http.RoundTripper
}
RemoteOptions connects a standalone renderer to one relay tenant. PublicURL is the browser-facing URL; BackendURL is its upstream HTTP address. Use the same tenant path at both addresses so cookies and signed URLs retain scope.
type RetentionRule ¶
type RetentionRule = policy.RetentionRule
type RoomList ¶
type RoomList struct {
// Rooms contains visible room summaries in ascending ID order.
Rooms []RoomSummary `json:"rooms"`
// NextCursor is the last room ID when another page is available.
NextCursor string `json:"next_cursor,omitempty"`
}
type RoomMember ¶
type RoomMessage ¶
type RoomPage ¶
type RoomPage struct {
Room RoomSummary `json:"room"`
Members []RoomMember `json:"members,omitempty"`
Messages []RoomMessage `json:"messages,omitempty"`
// ReplyCounts and ReactionCounts carry folded interaction summaries for
// the roots in Messages without expanding every reply into the timeline.
ReplyCounts map[string]int `json:"reply_counts,omitempty"`
ReactionCounts map[string]map[string]int `json:"reaction_counts,omitempty"`
Replies []RoomMessage `json:"replies,omitempty"`
Edits []RoomMessage `json:"edits,omitempty"`
Root *RoomMessage `json:"root,omitempty"`
NextCursor string `json:"next_cursor,omitempty"`
}
RoomPage is the typed result for a room or thread read. A room read fills Members and Messages; a thread read fills Root and Replies. Edits contains the newest visible edit for the returned targets.
type RoomSummary ¶
type RoomSummary struct {
ID string `json:"id"`
Name string `json:"name,omitempty"`
Access string `json:"access,omitempty"`
About string `json:"about,omitempty"`
Picture string `json:"picture,omitempty"`
CreatedBy string `json:"created_by,omitempty"`
CreatedAt int64 `json:"created_at,omitempty"`
EventID string `json:"event_id,omitempty"`
DeletedAt int64 `json:"deleted_at,omitempty"`
Members int `json:"members,omitempty"`
LastMessageAt int64 `json:"last_message_at,omitempty"`
Role string `json:"role,omitempty"`
}
RoomSummary is the room metadata shown in the rail and room header.
type RoomsReader ¶
type RoomsReader interface {
// ListRooms returns up to limit visible room summaries after cursor.
ListRooms(ctx context.Context, actor, cursor string, limit int) (RoomList, error)
// ReadRoom returns one visible room, its members, messages and edits after cursor.
ReadRoom(ctx context.Context, actor, roomID, cursor string, limit int) (RoomPage, error)
// ReadThread returns one room thread root, replies and edits after cursor.
ReadThread(ctx context.Context, actor, roomID, rootID, cursor string, limit int) (RoomPage, error)
}
RoomsReader supplies the typed reads used by room pages. actor is the authenticated public key, or an empty string for an anonymous request. cursor is empty for the newest page and otherwise is the value returned in NextCursor. limit requests at most that many rows. The daemon adapter uses 100 when the requested limit falls outside 1 through 100.
ListRooms returns visible room summaries ordered by room ID and a cursor for the next page. ReadRoom returns the room summary, visible members, newest room messages, message edits and a cursor for older messages. ReadThread returns the room summary, one root event, its replies, edits and a cursor for older replies. Reads enforce tenant and room access and return errors for missing rooms, invalid cursors or an inaccessible room. ReadThread also returns an error when rootID is not a lower-case hexadecimal event ID or does not identify a message in roomID.
type Succession ¶
type Succession = policy.Succession
Source Files
¶
- approvals.go
- assets.go
- avatars.go
- chat-activity.go
- chat_pages.go
- collaboration.go
- connections.go
- contracts.go
- custom_views.go
- doc.go
- files.go
- job_views.go
- markdown.go
- mobile_header.go
- open.go
- podcast_rss.go
- prefix.go
- private.go
- public_pages.go
- read_contracts.go
- remote.go
- remote_rooms.go
- repo_navigation.go
- review.go
- room_attachments.go
- rooms.go
- route_groups.go
- routes.go
- signin.go
- site_metadata.go
- social_content.go
- social_mentions.go
- social_navigation.go
- social_pages.go
- social_podcasts.go
- social_profile.go
- social_reference_routes.go
- source_render.go
- templates.go
- webmcp.go
- webui.go
- wiki.go