api

package
v0.0.0-...-db2b337 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: AGPL-3.0 Imports: 52 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 api is the REST API and the websocket endpoints of the backend: routes, authentication middleware and the HTTP handlers on top of the other packages. See openapi-description.yaml.

Index

Constants

View Source
const (
	FeatureJoinPresence   = "join-presence"
	FeatureAccessRequests = "access-requests"
	// FeatureInstancePresence means presence and ghosts are per client instance
	FeatureInstancePresence = "instance-presence"
	// FeatureAgentFocus means agent presence can have a focus, see docs/sync-protocol.md section 6
	FeatureAgentFocus = "agent-focus"
	// FeaturePresenceIndexes means clients send their position as indexes too (at), see
	// docs/sync-protocol.md section 6
	FeaturePresenceIndexes = "presence-indexes"
)

The features of GET /server-info/ for join links and access requests

View Source
const (
	EndpointPathWhoAmI   = "/auth/whoami/"
	EndpointPathWsTicket = "/auth/ws-ticket/"
)
View Source
const (
	AuthMethodSession   = "session"
	AuthMethodAppToken  = "app-token"
	AuthMethodAnonymous = "anonymous"
)

Authentication methods of a request (whoami authMethod)

View Source
const (
	CodeBadRequest                = "bad-request"
	CodeInvalidUsername           = "invalid-username"
	CodeWeakPassword              = "weak-password"
	CodeInvalidLink               = "invalid-link"
	CodeInvalidSecondFactor       = "invalid-second-factor"
	CodePasskeyRegistrationFailed = "passkey-registration-failed"
	CodeUnauthenticated           = "unauthenticated"
	CodeInvalidCredentials        = "invalid-credentials"
	CodeChallengeExpired          = "challenge-expired"
	CodePasskeyVerificationFailed = "passkey-verification-failed"
	CodeForbidden                 = "forbidden"
	CodeAccountDisabled           = "account-disabled"
	CodeReauthRequired            = "reauth-required"
	CodeSecondFactorSetupRequired = "second-factor-setup-required"
	CodeCSRFCheckFailed           = "csrf-check-failed"
	CodeOriginNotAllowed          = "origin-not-allowed"
	CodeNotFound                  = "not-found"
	CodePasskeysDisabled          = "passkeys-disabled"
	CodeUsernameTaken             = "username-taken"
	CodeTOTPAlreadyEnabled        = "totp-already-enabled"
	CodeTOTPNotEnabled            = "totp-not-enabled"
	CodeLastLoginMethod           = "last-login-method"
	CodeSecondFactorRequired      = "second-factor-required"
	CodeConflict                  = "conflict"
	CodeRateLimited               = "rate-limited"
	CodeInternal                  = "internal"
	CodeInvalidAccessRequest      = "invalid-access-request"
	CodeAccessRequestsDisabled    = "access-requests-disabled"
	CodeTooManyAccessRequests     = "too-many-access-requests"
	CodePayloadTooLarge           = "payload-too-large"
	CodeUnsupportedMediaType      = "unsupported-media-type"
	CodeInvalidImage              = "invalid-image"
)

Error codes of REST error responses, see docs/auth.md section 10

View Source
const (
	CodeEditNotFound         = "edit-not-found"
	CodeEditAmbiguous        = "edit-ambiguous"
	CodeUnknownRevision      = "unknown-revision"
	CodeBaseRevisionRequired = "base-revision-required"
)
View Source
const (
	// FeaturePins means the server has the pins of docs/dashboard.md
	FeaturePins = "pins"
	// FeatureFeed means the server has the change feed of docs/dashboard.md
	FeatureFeed = "feed"
	// FeaturePinOrder means the pins can be reordered, see docs/dashboard.md
	FeaturePinOrder = "pin-order"
	// FeatureFeedRanges means edit summaries have textHash and ranges, see docs/dashboard.md
	FeatureFeedRanges = "feed-ranges"
)
View Source
const (
	// EndpointPathForward is the forwardAuth endpoint of a reverse proxy, see docs/auth.md
	// section 4
	EndpointPathForward = "/auth/forward/"
	// FeatureForwardAuth means GET /auth/forward/ exists
	FeatureForwardAuth = "forward-auth"
)
View Source
const (
	// EndpointPathGitRemoteCallback is where the git host sends the admin's browser back. It is
	// no admin path: the handler answers a missing session with a redirect, not with JSON.
	EndpointPathGitRemoteCallback = "/git-remote/callback/"
	// CodeNotConfigured means git.oauth is not set
	CodeNotConfigured = "not-configured"
)
View Source
const (
	GitRemoteNotConfigured = "not-configured"
	GitRemoteDisconnected  = "disconnected"
	GitRemoteConnected     = "connected"
	GitRemoteExpired       = "expired"
	GitRemoteError         = "error"
)

States of GitRemoteResponse

View Source
const (
	// FeaturePush means the server sends Web Push messages, see docs/push.md
	FeaturePush = "push"

	CodeEndpointNotAllowed = "endpoint-not-allowed"
)
View Source
const (
	// FeatureQRCodes means pages can carry QR code keys, see docs/qr.md
	FeatureQRCodes = "qr-codes"

	CodeQRConflict = "qr-conflict"
	CodeQRGone     = "qr-gone"
)
View Source
const (
	RefStatusOK     = "ok"
	RefStatusBroken = "broken"
)

Statuses of references

View Source
const (
	EndpointPathAlive = "/alive/"

	// APIPrefix is the path every route is served under, see docs/sync-protocol.md. Route
	// paths in this package are written without it.
	APIPrefix = "/api"
)
View Source
const (
	CodeRevertConflict  = "revert-conflict"
	CodeNothingToRevert = "nothing-to-revert"
	// FeatureRevert means the server has POST /document/{id}/history/{revision}/revert/
	FeatureRevert = "revert"
	// FeatureRevertCheck means the server has GET /document/{id}/history/{revision}/revert/
	FeatureRevertCheck = "revert-check"
)
View Source
const CodeSectionNotFound = "section-not-found"

CodeSectionNotFound means the section of a restore is missing in the revision or the live text

View Source
const ConnectPayloadVersion = 1

ConnectPayloadVersion is the version of the connect link payload

View Source
const EndpointPathMCP = "/mcp/"

EndpointPathMCP is the path of the MCP server, below APIPrefix

View Source
const (

	// EndpointPathUpload is the prefix of the upload URLs, below APIPrefix
	EndpointPathUpload = "/uploads/"
)
View Source
const (
	// FeatureAvatars means accounts have profile pictures, see docs/auth.md
	FeatureAvatars = "avatars"
)
View Source
const FeatureBlame = "blame"

FeatureBlame means the server has GET /document/{id}/blame/

View Source
const FeatureChanges = "changes"

FeatureChanges means the server has GET /document/{id}/changes/ and PUT /document/{id}/seen/, see docs/sync-protocol.md section 11

View Source
const FeatureHistory = "history"

FeatureHistory means git is enabled and history entries have summary and agents, with format=json for diffs and agent edits in commits of their own, see docs/sync-protocol.md section 11

View Source
const FeatureMovedLookup = "moved-lookup"

FeatureMovedLookup in GET /server-info/ says that the server has GET /moved/?id=…&id=…

View Source
const (
	// FeatureOAuth means the OAuth endpoints exist
	FeatureOAuth = "oauth"
)
View Source
const FeaturePageMeta = "page-meta"

FeaturePageMeta means documents in the tree have title and meta, see docs/page-meta.md

View Source
const FeatureWikiConfig = "wiki-config"

FeatureWikiConfig means the server has GET /wiki/config/, see docs/page-meta.md

View Source
const RevisionCurrent = "current"

RevisionCurrent names the live text in a diff

Variables

View Source
var ErrUnknownRevision = errors.New("unknown revision")

ErrUnknownRevision is returned for a revision that is not in the history of the file

Functions

func AppTokenFromContext

func AppTokenFromContext(c *echo.Context) *auth.AppToken

AppTokenFromContext returns the app token of a request authenticated by one, or nil

func ParseTrustedProxies

func ParseTrustedProxies(entries []string) ([]*net.IPNet, error)

ParseTrustedProxies parses server.trustedProxies (CIDRs or single addresses)

func SessionFromContext

func SessionFromContext(c *echo.Context) *auth.Session

SessionFromContext returns the session of a request authenticated by a session, or nil

func UserFromContext

func UserFromContext(c *echo.Context) *auth.User

UserFromContext returns the authenticated user of a request, or nil

Types

type AccessRequestStatusRequest

type AccessRequestStatusRequest struct {
	Token string `json:"token"`
}

request and response bodies of access requests, see docs/auth.md section 8

type AccessRequestStatusResponse

type AccessRequestStatusResponse struct {
	Status      string `json:"status"`
	InviteToken string `json:"inviteToken,omitempty"`
}

request and response bodies of access requests, see docs/auth.md section 8

type AccessRequestView

type AccessRequestView struct {
	ID                 string    `json:"id"`
	Name               string    `json:"name"`
	Message            string    `json:"message"`
	Status             string    `json:"status"`
	CreatedAt          time.Time `json:"createdAt"`
	ExpiresAt          time.Time `json:"expiresAt"`
	DocumentID         *string   `json:"documentId"`
	DocumentPath       *string   `json:"documentPath"`
	InvitedByAccountID *string   `json:"invitedByAccountId"`
	InvitedByName      *string   `json:"invitedByName"`
}

AccessRequestView is what admins see of a request. The claims of the requester are resolved only here, and are null if they name nothing that exists.

type AccountResponse

type AccountResponse struct {
	UserView
	Email                string     `json:"email"`
	CreatedAt            time.Time  `json:"createdAt"`
	HasPassword          bool       `json:"hasPassword"`
	TOTPEnabled          bool       `json:"totpEnabled"`
	RecoveryCodesLeft    int        `json:"recoveryCodesLeft"`
	PasskeyCount         int        `json:"passkeyCount"`
	Require2FA           bool       `json:"require2FA"`
	ReauthenticatedUntil *time.Time `json:"reauthenticatedUntil"`
}

request and response bodies of the account endpoints, see docs/auth.md section 9

type AccountUpdateRequest

type AccountUpdateRequest struct {
	Username    *string `json:"username"`
	DisplayName *string `json:"displayName"`
	Color       *string `json:"color"`
	Email       *string `json:"email"`
}

request and response bodies of the account endpoints, see docs/auth.md section 9

type AdminUserUpdateRequest

type AdminUserUpdateRequest struct {
	Role        *string `json:"role"`
	Status      *string `json:"status"`
	Username    *string `json:"username"`
	DisplayName *string `json:"displayName"`
	Color       *string `json:"color"`
	Email       *string `json:"email"`
}

request and response bodies of the admin and app token endpoints, see docs/auth.md section 9

type AppTokenRequest

type AppTokenRequest struct {
	Name          string `json:"name"`
	Scope         string `json:"scope"`
	ExpiresInDays int    `json:"expiresInDays"`
	// ExpiresAt is an absolute end, instead of ExpiresInDays
	ExpiresAt *time.Time `json:"expiresAt"`
}

request and response bodies of the admin and app token endpoints, see docs/auth.md section 9

type AppTokenUpdateRequest

type AppTokenUpdateRequest struct {
	Name      *string         `json:"name"`
	ExpiresAt json.RawMessage `json:"expiresAt"`
}

AppTokenUpdateRequest is the body of PATCH /account/tokens/{id}/. The end of a token cannot change: expiresAt is rejected.

type ApproveAccessRequestRequest

type ApproveAccessRequestRequest struct {
	Role           string `json:"role"`
	ExpiresInHours int    `json:"expiresInHours"`
}

request and response bodies of access requests, see docs/auth.md section 8

type ApprovedAccessRequestResponse

type ApprovedAccessRequestResponse struct {
	Request *AccessRequestView `json:"request"`
	Invite  *auth.Link         `json:"invite"`
	Token   string             `json:"token"`
	URL     *string            `json:"url"`
}

request and response bodies of access requests, see docs/auth.md section 8

type AuditResponse

type AuditResponse struct {
	Events []*auth.AuditEntry `json:"events"`
	Next   *int64             `json:"next"`
}

request and response bodies of the admin and app token endpoints, see docs/auth.md section 9

type AuthServerMetadata

type AuthServerMetadata struct {
	Issuer                                 string   `json:"issuer"`
	AuthorizationEndpoint                  string   `json:"authorization_endpoint"`
	TokenEndpoint                          string   `json:"token_endpoint"`
	RegistrationEndpoint                   string   `json:"registration_endpoint"`
	RevocationEndpoint                     string   `json:"revocation_endpoint"`
	ScopesSupported                        []string `json:"scopes_supported"`
	ResponseTypesSupported                 []string `json:"response_types_supported"`
	ResponseModesSupported                 []string `json:"response_modes_supported"`
	GrantTypesSupported                    []string `json:"grant_types_supported"`
	TokenEndpointAuthMethodsSupported      []string `json:"token_endpoint_auth_methods_supported"`
	RevocationEndpointAuthMethodsSupported []string `json:"revocation_endpoint_auth_methods_supported"`
	CodeChallengeMethodsSupported          []string `json:"code_challenge_methods_supported"`
	ClientIDMetadataDocumentSupported      bool     `json:"client_id_metadata_document_supported"`
}

AuthServerMetadata is RFC 8414 metadata

type AuthStatusResponse

type AuthStatusResponse struct {
	SetupRequired  bool           `json:"setupRequired"`
	AuthDisabled   bool           `json:"authDisabled"`
	Passkeys       PasskeyStatus  `json:"passkeys"`
	PasswordPolicy PasswordPolicy `json:"passwordPolicy"`
}

request and response bodies of the account endpoints, see docs/auth.md sections 8 and 9

type Author

type Author struct {
	AccountID   string  `json:"accountId,omitempty"`
	Username    string  `json:"username,omitempty"`
	DisplayName string  `json:"displayName"`
	Color       string  `json:"color"`
	Avatar      *string `json:"avatar"`
}

Author is who pinned a document or made a feed entry

type Backlink struct {
	Source      *references.ItemRef `json:"source"`
	Kind        string              `json:"kind"`
	Line        int                 `json:"line"`
	Column      int                 `json:"column"`
	Destination string              `json:"destination"`
	Anchor      string              `json:"anchor"`
	Target      *references.ItemRef `json:"target"`
	Internal    bool                `json:"internal"`
}

Backlink is a reference to an item

type Backlinks struct {
	Item      *references.ItemRef `json:"item"`
	Backlinks []*Backlink         `json:"backlinks"`
}

Backlinks is the answer of the backlinks endpoints

type BlameBlock

type BlameBlock struct {
	// Start and End are the first and the last line, 1-based
	Start int `json:"start"`
	End   int `json:"end"`
	// Pending is true for lines not committed yet; then Revision, Time and Message are null
	Pending  bool    `json:"pending"`
	Revision *string `json:"revision"`
	Time     *string `json:"time"`
	Message  *string `json:"message"`
	// Author is the commit's author, or who wrote most of the pending lines. Null if unknown.
	Author *Author `json:"author"`
	// Agents are the app tokens of the commit or of the pending lines
	Agents []string `json:"agents"`
}

BlameBlock are consecutive lines last changed by the same commit, or not committed yet and written by the same account

type BlameResponse

type BlameResponse struct {
	// Revision is the revision (seenToken) of the text the lines belong to
	Revision string `json:"revision"`
	// Lines is the number of lines of the text
	Lines  int          `json:"lines"`
	Blocks []BlameBlock `json:"blocks"`
}

BlameResponse is the answer of GET /document/{id}/blame/

type BrokenReference

type BrokenReference struct {
	Source *references.ItemRef `json:"source"`
	*Reference
}

BrokenReference is a broken reference with its document

type BrokenReferences

type BrokenReferences struct {
	Broken []*BrokenReference `json:"broken"`
}

BrokenReferences is the answer of GET /references/broken/

type CeremonyResponse

type CeremonyResponse struct {
	CeremonyID string `json:"ceremonyId"`
	PublicKey  any    `json:"publicKey"`
}

CeremonyResponse holds the options for navigator.credentials or Credential Manager

type ChangeAuthor

type ChangeAuthor struct {
	Author
	Agents []string `json:"agents"`
}

ChangeAuthor is an account that changed the document since, with the app tokens (agents) it used

type ChangesResponse

type ChangesResponse struct {
	// Since is nil if the account never saw the document: then there are no hunks
	Since *ChangesSince `json:"since"`
	// SeenToken is the revision of the live text the hunks lead to; PUT it to seen/
	// after showing the changes
	SeenToken string          `json:"seenToken"`
	Authors   []ChangeAuthor  `json:"authors"`
	Hunks     []activity.Hunk `json:"hunks"`
	Summary   HistorySummary  `json:"summary"`
}

ChangesResponse is the answer of GET /document/{id}/changes/

type ChangesSince

type ChangesSince struct {
	// Time is when the account saw the text, or the time of the newest change of the
	// seenToken given in ?since=
	Time      string `json:"time"`
	SeenToken string `json:"seenToken"`
}

ChangesSince is the starting point of the changes

type ConnectPayload

type ConnectPayload struct {
	V          int       `json:"v"`
	BackendURL string    `json:"backendUrl"`
	Username   string    `json:"username"`
	Token      string    `json:"token"`
	ExpiresAt  time.Time `json:"expiresAt"`
}

ConnectPayload is the fragment of a connect link (base64url JSON without padding)

type CreateAccessRequestRequest

type CreateAccessRequestRequest struct {
	Name       string `json:"name"`
	Message    string `json:"message"`
	DocumentID string `json:"documentId"`
	InvitedBy  string `json:"invitedBy"`
}

request and response bodies of access requests, see docs/auth.md section 8

type CreateDeviceLinkRequest

type CreateDeviceLinkRequest struct {
	DeviceName string `json:"deviceName"`
}

request and response bodies of server info and device pairing, see docs/auth.md

type CreateInviteRequest

type CreateInviteRequest struct {
	Role           string `json:"role"`
	ExpiresInHours int    `json:"expiresInHours"`
	Note           string `json:"note"`
}

request and response bodies of the account endpoints, see docs/auth.md sections 8 and 9

type CreatedAccessRequestResponse

type CreatedAccessRequestResponse struct {
	RequestID string    `json:"requestId"`
	Token     string    `json:"token"`
	Status    string    `json:"status"`
	ExpiresAt time.Time `json:"expiresAt"`
}

request and response bodies of access requests, see docs/auth.md section 8

type CreatedAppTokenResponse

type CreatedAppTokenResponse struct {
	AppToken *auth.AppToken `json:"appToken"`
	Token    string         `json:"token"`
}

request and response bodies of the admin and app token endpoints, see docs/auth.md section 9

type CreatedDeviceLinkResponse

type CreatedDeviceLinkResponse struct {
	DeviceLink *auth.DeviceLink `json:"deviceLink"`
	Token      string           `json:"token"`
	ExpiresAt  time.Time        `json:"expiresAt"`
	ConnectURL *string          `json:"connectUrl"`
}

request and response bodies of server info and device pairing, see docs/auth.md

type CreatedLinkResponse

type CreatedLinkResponse struct {
	Invite *auth.Link `json:"invite,omitempty"`
	Link   *auth.Link `json:"link,omitempty"`
	Token  string     `json:"token"`
	URL    *string    `json:"url"`
}

request and response bodies of the account endpoints, see docs/auth.md sections 8 and 9

type DocumentReferences

type DocumentReferences struct {
	Document   *references.ItemRef `json:"document"`
	References []*Reference        `json:"references"`
}

DocumentReferences is the answer of GET /document/{id}/references/

type EditRequest

type EditRequest struct {
	Edits        []collab.TextEdit `json:"edits"`
	BaseRevision string            `json:"baseRevision,omitempty"`
}

EditRequest is the body of POST /document/{id}/edits/

type ErrorResult

type ErrorResult struct {
	Name    string         `json:"name"`
	Code    string         `json:"code,omitempty"`
	Message string         `json:"message"`
	Details map[string]any `json:"details,omitempty"`
}

type FeedEntryResponse

type FeedEntryResponse struct {
	ID         string `json:"id"`
	Time       string `json:"time"`
	Kind       string `json:"kind"`
	ItemType   string `json:"itemType"`
	DocumentID string `json:"documentId,omitempty"`
	// Title is the page name of the document at path, null if there is none
	Title   *string           `json:"title"`
	Path    string            `json:"path"`
	OldPath string            `json:"oldPath,omitempty"`
	Authors []Author          `json:"authors"`
	Summary *activity.Summary `json:"summary,omitempty"`
}

FeedEntryResponse is an entry of the feed

type FeedResponse

type FeedResponse struct {
	Entries []FeedEntryResponse `json:"entries"`
	Next    *string             `json:"next"`
}

FeedResponse is the answer of GET /feed/

type GitRemoteConnectResponse

type GitRemoteConnectResponse struct {
	AuthorizeURL string `json:"authorizeUrl"`
}

GitRemoteConnectResponse is the answer of POST /admin/git-remote/connect/

type GitRemotePushError

type GitRemotePushError struct {
	At      string `json:"at"`
	Message string `json:"message"`
}

GitRemotePushError is the last failed push

type GitRemoteRefreshError

type GitRemoteRefreshError struct {
	At        string `json:"at"`
	Message   string `json:"message"`
	Permanent bool   `json:"permanent"`
}

GitRemoteRefreshError is a failed refresh; permanent means the grant is gone

type GitRemoteResponse

type GitRemoteResponse struct {
	State            string                 `json:"state"`
	PushEnabled      bool                   `json:"pushEnabled"`
	Provider         *string                `json:"provider"`
	ProviderName     *string                `json:"providerName"`
	ProviderURL      *string                `json:"providerUrl"`
	GrantsURL        *string                `json:"grantsUrl"`
	ScopedGrants     bool                   `json:"scopedGrants"`
	Repo             *string                `json:"repo"`
	ExpectedUser     *string                `json:"expectedUser"`
	AllowAdmin       bool                   `json:"allowAdmin"`
	RemoteUser       *GitRemoteUser         `json:"remoteUser"`
	CanPush          *bool                  `json:"canPush"`
	ConnectedAt      *string                `json:"connectedAt"`
	ConnectedBy      *string                `json:"connectedBy"`
	LastRefreshAt    *string                `json:"lastRefreshAt"`
	RefreshExpiresAt *string                `json:"refreshExpiresAt"`
	LastRefreshError *GitRemoteRefreshError `json:"lastRefreshError"`
	LastPushAt       *string                `json:"lastPushAt"`
	LastPushError    *GitRemotePushError    `json:"lastPushError"`
	PendingCommits   *int                   `json:"pendingCommits"`
}

GitRemoteResponse is the answer of GET /admin/git-remote/

type GitRemoteUser

type GitRemoteUser struct {
	Login     string `json:"login"`
	AvatarURL string `json:"avatarUrl"`
	IsAdmin   bool   `json:"isAdmin"`
}

GitRemoteUser is the user of the git host the connection belongs to

type HistoryAgent

type HistoryAgent struct {
	Name string `json:"name"`
	// AccountID is the account that used the token, "" if it is unknown
	AccountID string `json:"accountId"`
}

HistoryAgent is an app token (an agent such as Claude Code) that made changes of a commit

type HistoryAuthor

type HistoryAuthor struct {
	Name        string  `json:"name"`
	Email       string  `json:"email"`
	Username    string  `json:"username"`
	AccountID   string  `json:"accountId"`
	DisplayName string  `json:"displayName"`
	Color       string  `json:"color"`
	Avatar      *string `json:"avatar"`
}

HistoryAuthor is a commit author. Username and AccountID are empty if the author is not an account. Username is the current username of the account. DisplayName, Color and Avatar are those of the account, as in the feed, else the git name and a color derived from it.

type HistoryDiffResponse

type HistoryDiffResponse struct {
	From  string          `json:"from"`
	To    string          `json:"to"`
	Hunks []activity.Hunk `json:"hunks"`
}

HistoryDiffResponse is the structured diff of GET /document/{id}/history/diff/?format=json

type HistoryEntry

type HistoryEntry struct {
	Revision  string          `json:"revision"`
	Time      time.Time       `json:"time"`
	Author    HistoryAuthor   `json:"author"`
	CoAuthors []HistoryAuthor `json:"coAuthors"`
	Message   string          `json:"message"`
	Path      string          `json:"path"`
	// AppTokens are the names of the app tokens (agents) the changes were made with
	AppTokens []string `json:"appTokens"`
	// Agents are the app tokens with their accounts
	Agents []HistoryAgent `json:"agents"`
	// Summary compares the text of the commit with the one before
	Summary HistorySummary `json:"summary"`
}

HistoryEntry is a commit in the revision history of a document

type HistorySummary

type HistorySummary struct {
	LinesAdded   int `json:"linesAdded"`
	LinesRemoved int `json:"linesRemoved"`
	// Headings are the headings above the changed lines, at most 5, in document order
	Headings []string `json:"headings"`
}

HistorySummary tells what a commit changed in the document

type LinkInspectResponse

type LinkInspectResponse struct {
	Kind               string    `json:"kind"`
	Role               string    `json:"role,omitempty"`
	Note               string    `json:"note,omitempty"`
	Username           string    `json:"username,omitempty"`
	DisplayName        string    `json:"displayName,omitempty"`
	ResetSecondFactors bool      `json:"resetSecondFactors,omitempty"`
	ExpiresAt          time.Time `json:"expiresAt"`
}

request and response bodies of the account endpoints, see docs/auth.md sections 8 and 9

type LinkPasskeyBeginRequest

type LinkPasskeyBeginRequest struct {
	Token       string `json:"token"`
	Username    string `json:"username"`
	DisplayName string `json:"displayName"`
}

request and response bodies of the passkey endpoints, see docs/auth.md section 8

type LinkPasskeyFinishRequest

type LinkPasskeyFinishRequest struct {
	CeremonyID  string          `json:"ceremonyId"`
	Credential  json.RawMessage `json:"credential"`
	PasskeyName string          `json:"passkeyName"`
	// contains filtered or unexported fields
}

request and response bodies of the passkey endpoints, see docs/auth.md section 8

type LinkRedeemRequest

type LinkRedeemRequest struct {
	Token       string `json:"token"`
	Username    string `json:"username"`
	DisplayName string `json:"displayName"`
	Password    string `json:"password"`
	// contains filtered or unexported fields
}

request and response bodies of the account endpoints, see docs/auth.md sections 8 and 9

type LinkResult

type LinkResult struct {
	Destination string              `json:"destination"`
	Markdown    string              `json:"markdown"`
	Target      *references.ItemRef `json:"target"`
}

LinkResult is the answer of GET /link/

type LinkTokenRequest

type LinkTokenRequest struct {
	Token string `json:"token"`
}

request and response bodies of the account endpoints, see docs/auth.md sections 8 and 9

type LoginRequest

type LoginRequest struct {
	Username string `json:"username"`
	Password string `json:"password"`
	// contains filtered or unexported fields
}

request and response bodies of the account endpoints, see docs/auth.md sections 8 and 9

type MetricsCollector

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

MetricsCollector reports the current state of the backend at scrape time, so these values cannot drift away from it

func NewMetricsCollector

func NewMetricsCollector(syncServer *collab.SyncServer, tree *wiki.TreeManager, git *gitstore.Committer) *MetricsCollector

NewMetricsCollector creates the collector. git may be nil.

func (*MetricsCollector) Collect

func (m *MetricsCollector) Collect(ch chan<- prometheus.Metric)

Collect implements prometheus.Collector

func (*MetricsCollector) Describe

func (m *MetricsCollector) Describe(ch chan<- *prometheus.Desc)

Describe implements prometheus.Collector

type MovedListResponse

type MovedListResponse struct {
	Moved []*MovedResponse `json:"moved"`
}

MovedListResponse is the answer of GET /moved/?id=…&id=…

type MovedResponse

type MovedResponse struct {
	OldID   string              `json:"oldId"`
	Type    string              `json:"type"`
	Item    *references.ItemRef `json:"item"`
	MovedAt time.Time           `json:"movedAt"`
}

MovedResponse is the answer of GET /moved/{id}/

type NewItemRequest

type NewItemRequest struct {
	Parent string `json:"parent" xml:"parent" form:"parent"`
	Name   string `json:"name" xml:"name" form:"name"`
}

NewItemRequest is the body of POST /section/ and POST /document/. form and xml bodies are bound too, for older clients.

type OAuthClientResponse

type OAuthClientResponse struct {
	ClientID                string   `json:"client_id"`
	ClientIDIssuedAt        int64    `json:"client_id_issued_at"`
	ClientName              string   `json:"client_name"`
	RedirectURIs            []string `json:"redirect_uris"`
	GrantTypes              []string `json:"grant_types"`
	ResponseTypes           []string `json:"response_types"`
	TokenEndpointAuthMethod string   `json:"token_endpoint_auth_method"`
	Scope                   string   `json:"scope"`
}

OAuthClientResponse is the answer of the registration endpoint (RFC 7591 section 3.2.1)

type OAuthDecisionRequest

type OAuthDecisionRequest struct {
	// Scope lowers the requested scope to read; empty keeps it
	Scope string `json:"scope"`
	// Name of the grant (1 to 64 characters); empty: the client's name
	Name string `json:"name"`
	// ExpiresAt is the fixed end of the grant (RFC 3339); null or absent: no fixed end
	ExpiresAt *time.Time `json:"expiresAt"`
}

OAuthDecisionRequest is the body of POST /oauth/requests/{id}/approve/

type OAuthDecisionResponse

type OAuthDecisionResponse struct {
	RedirectURL string `json:"redirectUrl"`
}

OAuthDecisionResponse tells the web client where to send the browser

type OAuthGrantDefaults

type OAuthGrantDefaults struct {
	Name string `json:"name"`
	// ExpiresAt nil: no fixed end, the grant lives while it is used (30 days after the last
	// refresh)
	ExpiresAt *time.Time `json:"expiresAt"`
	// MaxExpiresAt is the latest end an approval may set
	MaxExpiresAt time.Time `json:"maxExpiresAt"`
}

OAuthGrantDefaults are the name and end a grant gets when the approval does not set them

type OAuthRequestView

type OAuthRequestView struct {
	ID         string `json:"id"`
	ClientID   string `json:"clientId"`
	ClientName string `json:"clientName"`
	// RedirectURI is where the browser goes after the decision
	RedirectURI string `json:"redirectUri"`
	// Scope is the requested scope, read or write
	Scope string `json:"scope"`
	// AllowedScopes are the scopes the user may grant: readers only read
	AllowedScopes []string `json:"allowedScopes"`
	Resource      string   `json:"resource"`
	// ExpiresAt is when the request ends (10 minutes), not the grant
	ExpiresAt time.Time `json:"expiresAt"`
	// Defaults of the grant, to prefill the consent page
	Defaults OAuthGrantDefaults `json:"defaults"`
}

OAuthRequestView is a pending authorization request, for the consent page

type OAuthTokenResponse

type OAuthTokenResponse struct {
	AccessToken  string `json:"access_token"`
	TokenType    string `json:"token_type"`
	ExpiresIn    int    `json:"expires_in"`
	RefreshToken string `json:"refresh_token"`
	Scope        string `json:"scope"`
}

OAuthTokenResponse is the answer of the token endpoint (RFC 6749 section 5.1)

type PasskeyFinishRequest

type PasskeyFinishRequest struct {
	CeremonyID string          `json:"ceremonyId"`
	Credential json.RawMessage `json:"credential"`
	Name       string          `json:"name"`
}

request and response bodies of the passkey endpoints, see docs/auth.md section 8

type PasskeyLoginBeginRequest

type PasskeyLoginBeginRequest struct {
	Challenge string `json:"challenge"`
}

request and response bodies of the passkey endpoints, see docs/auth.md section 8

type PasskeyLoginFinishRequest

type PasskeyLoginFinishRequest struct {
	CeremonyID string          `json:"ceremonyId"`
	Credential json.RawMessage `json:"credential"`
	// contains filtered or unexported fields
}

request and response bodies of the passkey endpoints, see docs/auth.md section 8

type PasskeyRenameRequest

type PasskeyRenameRequest struct {
	Name string `json:"name"`
}

request and response bodies of the passkey endpoints, see docs/auth.md section 8

type PasskeyStatus

type PasskeyStatus struct {
	Enabled bool   `json:"enabled"`
	RPID    string `json:"rpId,omitempty"`
}

request and response bodies of the account endpoints, see docs/auth.md sections 8 and 9

type PasswordChangeRequest

type PasswordChangeRequest struct {
	CurrentPassword *string `json:"currentPassword"`
	NewPassword     string  `json:"newPassword"`
}

request and response bodies of the account endpoints, see docs/auth.md section 9

type PasswordPolicy

type PasswordPolicy struct {
	MinLength int `json:"minLength"`
	MaxLength int `json:"maxLength"`
}

request and response bodies of the account endpoints, see docs/auth.md sections 8 and 9

type PinOrderRequest

type PinOrderRequest struct {
	DocumentIDs []string `json:"documentIds"`
}

PinOrderRequest is the body of PUT /pins/{family|personal}/order/

type PinResponse

type PinResponse struct {
	DocumentID string `json:"documentId"`
	Path       string `json:"path"`
	Name       string `json:"name"`
	// Title is the page name, see docs/page-meta.md
	Title    string `json:"title"`
	PinnedBy Author `json:"pinnedBy"`
	PinnedAt string `json:"pinnedAt"`
}

PinResponse is a pinned document

type PinsResponse

type PinsResponse struct {
	Family   []PinResponse `json:"family"`
	Personal []PinResponse `json:"personal"`
}

PinsResponse is the answer of GET /pins/ and of the pin changes

type ProtectedResourceMetadata

type ProtectedResourceMetadata struct {
	Resource               string   `json:"resource"`
	AuthorizationServers   []string `json:"authorization_servers"`
	ScopesSupported        []string `json:"scopes_supported"`
	BearerMethodsSupported []string `json:"bearer_methods_supported"`
	ResourceName           string   `json:"resource_name,omitempty"`
}

ProtectedResourceMetadata is RFC 9728 metadata

type PushEndpointRequest

type PushEndpointRequest struct {
	Endpoint string `json:"endpoint"`
}

PushEndpointRequest is the body of DELETE /push/subscriptions/

type PushInfo

type PushInfo struct {
	VAPIDPublicKey string `json:"vapidPublicKey"`
}

PushInfo is the push part of GET /server-info/

type PushSubscriptionRequest

type PushSubscriptionRequest struct {
	Endpoint string `json:"endpoint"`
	Keys     struct {
		P256DH string `json:"p256dh"`
		Auth   string `json:"auth"`
	} `json:"keys"`
}

PushSubscriptionRequest is the body of POST /push/subscriptions/, the format of the PushSubscription of browsers and of UnifiedPush

type PushSubscriptionResponse

type PushSubscriptionResponse struct {
	Endpoint   string  `json:"endpoint"`
	CreatedAt  string  `json:"createdAt"`
	LastPushAt *string `json:"lastPushAt"`
	// Current is true for the subscription of the requesting session
	Current bool `json:"current"`
}

type PushSubscriptionsResponse

type PushSubscriptionsResponse struct {
	Subscriptions []PushSubscriptionResponse `json:"subscriptions"`
}

type QRCodeResponse

type QRCodeResponse struct {
	Key   string  `json:"key"`
	Label *string `json:"label"`
	QRItem
	LastScannedAt *string `json:"lastScannedAt"`
}

QRCodeResponse is a key on exactly one document

type QRConflictResponse

type QRConflictResponse struct {
	Key           string   `json:"key"`
	Items         []QRItem `json:"items"`
	LastScannedAt *string  `json:"lastScannedAt"`
}

QRConflictResponse is a key on more than one document

type QRGoneResponse

type QRGoneResponse struct {
	Key           string  `json:"key"`
	Label         *string `json:"label"`
	LastPath      string  `json:"lastPath"`
	LastScannedAt *string `json:"lastScannedAt"`
}

QRGoneResponse is a key no document has any more

type QRInvalidResponse

type QRInvalidResponse struct {
	Value string `json:"value"`
	QRItem
}

QRInvalidResponse is a qr value that is no valid key

type QRItem

type QRItem struct {
	Item  *references.ItemRef `json:"item"`
	Title string              `json:"title"`
}

QRItem is a document with a QR code

type QRListResponse

type QRListResponse struct {
	Codes     []QRCodeResponse     `json:"codes"`
	Conflicts []QRConflictResponse `json:"conflicts"`
	Invalid   []QRInvalidResponse  `json:"invalid"`
	Gone      []QRGoneResponse     `json:"gone"`
}

type ReauthRequest

type ReauthRequest struct {
	Password string `json:"password"`
	Code     string `json:"code"`
}

request and response bodies of the account endpoints, see docs/auth.md section 9

type ReauthResponse

type ReauthResponse struct {
	ReauthenticatedUntil time.Time `json:"reauthenticatedUntil"`
}

request and response bodies of the account endpoints, see docs/auth.md section 9

type RecoveryCodesResponse

type RecoveryCodesResponse struct {
	RecoveryCodes []string `json:"recoveryCodes"`
}

request and response bodies of the account endpoints, see docs/auth.md section 9

type RedeemDeviceLinkRequest

type RedeemDeviceLinkRequest struct {
	Token    string `json:"token"`
	Username string `json:"username"`
	// contains filtered or unexported fields
}

request and response bodies of server info and device pairing, see docs/auth.md

type Reference

type Reference struct {
	Kind        string              `json:"kind"`
	Line        int                 `json:"line"`
	Column      int                 `json:"column"`
	Destination string              `json:"destination"`
	Anchor      string              `json:"anchor"`
	Status      string              `json:"status"`
	Target      *references.ItemRef `json:"target"`
	Reason      string              `json:"reason,omitempty"`
	Path        string              `json:"path,omitempty"`
	// MovedTo and SuggestedDestination are set for broken references to old paths of moved items
	MovedTo              *references.ItemRef `json:"movedTo,omitempty"`
	SuggestedDestination string              `json:"suggestedDestination,omitempty"`
}

Reference is one reference of a document, see docs/references.md section 4

type RenameRequest

type RenameRequest struct {
	Name string `json:"name" xml:"name" form:"name"`
}

RenameRequest is the body of the rename endpoints

type ResetLinkRequest

type ResetLinkRequest struct {
	ExpiresInMinutes   int  `json:"expiresInMinutes"`
	ResetSecondFactors bool `json:"resetSecondFactors"`
}

request and response bodies of the admin and app token endpoints, see docs/auth.md section 9

type RestService

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

func NewRestService

func NewRestService(
	server configuration.ServerConfiguration,
	treeManager *wiki.TreeManager,
	syncServer *collab.SyncServer,
	authenticator *auth.Service,
) *RestService

func (*RestService) ReturnError

func (rs *RestService) ReturnError(c *echo.Context, e error) error

ReturnError writes an error response. Known errors are mapped to matching status codes. The text of other errors can name server paths, so it is only logged.

func (*RestService) ReturnNotFound

func (rs *RestService) ReturnNotFound(c *echo.Context, id string) (err error)

return a "not found" message. For an old id of a moved item, details.movedTo names the item now.

func (*RestService) SetGitCommitter

func (rs *RestService) SetGitCommitter(c *gitstore.Committer)

SetGitCommitter makes tree changes over REST commit to git. Call it before Start.

func (*RestService) SetGitRemote

func (rs *RestService) SetGitRemote(m *gitremote.Manager)

SetGitRemote enables the connection to the git host. Call it before Start.

func (*RestService) SetPush

func (rs *RestService) SetPush(n *push.Notifier)

SetPush makes the server send pushes. Call it before Start; without it push is off.

func (*RestService) Shutdown

func (rs *RestService) Shutdown(ctx context.Context)

Shutdown stops the REST service gracefully

func (*RestService) Start

func (rs *RestService) Start() error

Start the REST service. It returns after Shutdown, or with the error if serving fails.

type RestoreSectionRequest

type RestoreSectionRequest struct {
	Heading *string `json:"heading"`
	// HeadingOccurrence counts the headings with the same text from the top, 1 (default) for
	// the first
	HeadingOccurrence int `json:"headingOccurrence"`
}

RestoreSectionRequest is the optional body of POST /document/{id}/history/{revision}/restore/: with a heading only that section is restored

type RevertCheck

type RevertCheck struct {
	Possible bool `json:"possible"`
	// Code is CodeNothingToRevert or CodeRevertConflict when not possible
	Code string `json:"code,omitempty"`
	// Details are those of the 409 of POST
	Details map[string]any `json:"details,omitempty"`
}

RevertCheck tells whether a revert would work now

type RevertConflict

type RevertConflict struct {
	// Heading is the nearest heading of the live text above the conflict, nil above the first
	Heading           *string `json:"heading"`
	HeadingOccurrence int     `json:"headingOccurrence"`
	// Line is the 1-based line of the live text where the conflict starts
	Line int `json:"line"`
}

RevertConflict is where a revert conflicts with later edits

type RevisionResponse

type RevisionResponse struct {
	Revision string `json:"revision"`
}

RevisionResponse is the answer of a content change

type RevokedResponse

type RevokedResponse struct {
	Revoked int `json:"revoked"`
}

request and response bodies of the account endpoints, see docs/auth.md sections 8 and 9

type SearchResponse

type SearchResponse struct {
	Results []*SearchResult `json:"results"`
	// Total is the number of matching documents, also those beyond the limit
	Total int `json:"total"`
}

SearchResponse is the answer of GET /search/

type SearchResult

type SearchResult struct {
	ID       string          `json:"id"`
	Path     string          `json:"path"`
	Title    string          `json:"title"`
	Snippets []SearchSnippet `json:"snippets"`
	// contains filtered or unexported fields
}

SearchResult is a document that matches a search

type SearchSnippet

type SearchSnippet struct {
	// Line is the line number, starting at 1
	Line int    `json:"line"`
	Text string `json:"text"`
}

SearchSnippet is a line of a document with a match

type SecondFactorRequest

type SecondFactorRequest struct {
	Challenge    string `json:"challenge"`
	Code         string `json:"code"`
	RecoveryCode string `json:"recoveryCode"`
	// contains filtered or unexported fields
}

request and response bodies of the account endpoints, see docs/auth.md section 9

type SecondFactorRequiredResponse

type SecondFactorRequiredResponse struct {
	Status    string    `json:"status"`
	Challenge string    `json:"challenge"`
	Methods   []string  `json:"methods"`
	ExpiresAt time.Time `json:"expiresAt"`
}

request and response bodies of the account endpoints, see docs/auth.md sections 8 and 9

type SeenRequest

type SeenRequest struct {
	// SeenToken is the seenToken of a changes answer, or any revision of the content API
	SeenToken string `json:"seenToken"`
}

SeenRequest is the body of PUT /document/{id}/seen/

type SeenResponse

type SeenResponse struct {
	SeenAt    string `json:"seenAt"`
	SeenToken string `json:"seenToken"`
}

SeenResponse is what the server stored

type ServerInfoResponse

type ServerInfoResponse struct {
	Name            string        `json:"name"`
	Version         string        `json:"version"`
	ProtocolVersion int           `json:"protocolVersion"`
	BackendURL      *string       `json:"backendUrl"`
	WikiURL         *string       `json:"wikiUrl"`
	WebClientURL    *string       `json:"webClientUrl"`
	SetupRequired   bool          `json:"setupRequired"`
	AuthDisabled    bool          `json:"authDisabled"`
	Passkeys        PasskeyStatus `json:"passkeys"`
	LoginMethods    []string      `json:"loginMethods"`
	Require2FA      bool          `json:"require2FA"`
	Features        []string      `json:"features"`
	// Push is set when the server sends Web Push messages
	Push *PushInfo `json:"push"`
}

request and response bodies of server info and device pairing, see docs/auth.md

type SessionResponse

type SessionResponse struct {
	Status  string        `json:"status"`
	User    *UserView     `json:"user"`
	Session *auth.Session `json:"session"`
	Token   string        `json:"token,omitempty"`
}

request and response bodies of the account endpoints, see docs/auth.md sections 8 and 9

type SettingsUpdateRequest

type SettingsUpdateRequest struct {
	Require2FA            *bool `json:"require2FA"`
	AccessRequestsEnabled *bool `json:"accessRequestsEnabled"`
}

request and response bodies of the admin and app token endpoints, see docs/auth.md section 9

type TOTPConfirmRequest

type TOTPConfirmRequest struct {
	Code string `json:"code"`
}

request and response bodies of the account endpoints, see docs/auth.md section 9

type TicketResponse

type TicketResponse struct {
	Ticket    string    `json:"ticket"`
	ExpiresAt time.Time `json:"expiresAt"`
}

TicketResponse is the response of POST /auth/ws-ticket/

type UnusedResources

type UnusedResources struct {
	Resources []*wiki.Resource `json:"resources"`
}

UnusedResources is the answer of GET /references/unused-resources/

type UserView

type UserView struct {
	auth.User
	SecondFactorSetupRequired bool `json:"secondFactorSetupRequired"`
	PasskeyCount              int  `json:"passkeyCount"`
}

UserView is a user with the state of its second factor setup

type WhoAmIResponse

type WhoAmIResponse struct {
	UserView
	AuthMethod string `json:"authMethod"`
	SessionID  string `json:"sessionId,omitempty"`
}

request and response bodies of the account endpoints, see docs/auth.md sections 8 and 9

type WriteContentRequest

type WriteContentRequest struct {
	Content      *string `json:"content"`
	BaseRevision string  `json:"baseRevision"`
}

WriteContentRequest is the body of PUT /document/{id}/content/

Jump to

Keyboard shortcuts

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