server

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: MIT Imports: 92 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PrincipalOAuth           PrincipalType = "oauth"
	PrincipalSpaceCredential PrincipalType = "space_credential"
	PrincipalDelegation      PrincipalType = "space_delegation"
	PrincipalServiceAuth     PrincipalType = "service_auth"

	// Verbose aliases are useful to callers that prefer type-prefixed names.
	PrincipalTypeOAuth           = PrincipalOAuth
	PrincipalTypeSpaceCredential = PrincipalSpaceCredential
	PrincipalTypeDelegation      = PrincipalDelegation
	PrincipalTypeServiceAuth     = PrincipalServiceAuth
)
View Source
const (
	OAuthOnlyPolicy              = PolicyOAuthOnly
	OAuthOrSpaceCredentialPolicy = PolicyOAuthOrSpace
	DelegationExchangePolicy     = PolicyDelegationExchange
	SpaceCredentialOnlyPolicy    = PolicySpaceCredentialOnly
	ServiceAuthOnlyPolicy        = PolicyServiceAuthOnly
)

Aliases use the names from the endpoint policy design.

View Source
const (
	BlobDeletionPending = "pending"
	BlobDeletionRetry   = "retry"
	BlobDeletionDeleted = "deleted"
	BlobDeletionFailed  = "failed"
)
View Source
const (
	SpaceNotifyWriteLXM        = "com.atproto.space.notifyWrite"
	SpaceNotifySpaceDeletedLXM = "com.atproto.space.notifySpaceDeleted"
	SpaceNotifyRegistrationTTL = 24 * time.Hour
	SpaceNotifyDeliveryTTL     = 7 * 24 * time.Hour
)
View Source
const (
	SpaceNotifyDeliveryPending   = "pending"
	SpaceNotifyDeliveryRetry     = "retry"
	SpaceNotifyDeliveryDelivered = "delivered"
	SpaceNotifyDeliveryExpired   = "expired"
	SpaceNotifyDeliveryFailed    = "failed"
)
View Source
const (
	SpaceRepoOpCreate SpaceRepoOpType = "create"
	SpaceRepoOpUpdate SpaceRepoOpType = "update"
	SpaceRepoOpDelete SpaceRepoOpType = "delete"
	SpaceRepoOpPut    SpaceRepoOpType = "put"

	// Short aliases make callers that model applyWrites operations concise.
	SpaceRepoCreate = SpaceRepoOpCreate
	SpaceRepoUpdate = SpaceRepoOpUpdate
	SpaceRepoDelete = SpaceRepoOpDelete
	SpaceRepoPut    = SpaceRepoOpPut
)
View Source
const (
	SpaceRepoFailureAfterRepoCreation   SpaceRepoFailureStage = "after-repo-creation"
	SpaceRepoFailureAfterRecordMutation SpaceRepoFailureStage = "after-record-mutation"
	SpaceRepoFailureAfterBlobMutation   SpaceRepoFailureStage = "after-blob-mutation"
	SpaceRepoFailureAfterOplogInsertion SpaceRepoFailureStage = "after-oplog-insertion"
	SpaceRepoFailureAfterHeadUpdate     SpaceRepoFailureStage = "after-head-update"

	// Short names are useful in table-driven tests.
	FailureAfterRepoCreation   = SpaceRepoFailureAfterRepoCreation
	FailureAfterRecordMutation = SpaceRepoFailureAfterRecordMutation
	FailureAfterBlobMutation   = SpaceRepoFailureAfterBlobMutation
	FailureAfterOplogInsertion = SpaceRepoFailureAfterOplogInsertion
	FailureAfterHeadUpdate     = SpaceRepoFailureAfterHeadUpdate
)
View Source
const (
	AccountSessionMaxAge = 30 * 24 * time.Hour // one week
)
View Source
const (

	// BlobDeletionRetention is the documented minimum time successful deletion
	// rows remain available for audit/replay inspection.
	BlobDeletionRetention = 7 * 24 * time.Hour
)
View Source
const (
	BlockstoreVariantSqlite = iota
)

Variables

View Source
var (
	OpTypeCreate = OpType("com.atproto.repo.applyWrites#create")
	OpTypeUpdate = OpType("com.atproto.repo.applyWrites#update")
	OpTypeDelete = OpType("com.atproto.repo.applyWrites#delete")
)
View Source
var (
	CocoonSupportedScopes = []string{
		"atproto",
		"transition:email",
		"transition:generic",
		"transition:chat.bsky",
	}
)
View Source
var ErrSessionUnauthenticated = errors.New("session is unauthenticated")
View Source
var ErrSpaceNotifyRevisionConflict = errors.New("space notification revision has conflicting hash")

ErrSpaceNotifyRevisionConflict indicates that a notification reused an existing revision with a different hash. The conflicting snapshot is never persisted or forwarded.

Functions

func NewDelegationExchangeMiddleware added in v0.11.1

func NewDelegationExchangeMiddleware(s *Server, next echo.HandlerFunc) echo.HandlerFunc

func NewOAuthOnlyMiddleware added in v0.11.1

func NewOAuthOnlyMiddleware(s *Server, next echo.HandlerFunc) echo.HandlerFunc

Constructor-function spellings make policy selection explicit at call sites that prefer package-level middleware constructors.

func NewOAuthOrSpaceCredentialMiddleware added in v0.11.1

func NewOAuthOrSpaceCredentialMiddleware(s *Server, next echo.HandlerFunc) echo.HandlerFunc

func NewServiceAuthOnlyMiddleware added in v0.11.1

func NewServiceAuthOnlyMiddleware(s *Server, next echo.HandlerFunc) echo.HandlerFunc

func NewSpaceCredentialOnlyMiddleware added in v0.11.1

func NewSpaceCredentialOnlyMiddleware(s *Server, next echo.HandlerFunc) echo.HandlerFunc

func ParseSpaceNotificationHash added in v0.11.1

func ParseSpaceNotificationHash(raw string) ([]byte, error)

func SetPrincipal added in v0.11.1

func SetPrincipal(e echo.Context, principal Principal)

SetPrincipal installs the typed principal and a compatibility alias in an Echo context. The alias is intentionally not used for authorization.

Types

type AccountRevokeInput added in v0.7.2

type AccountRevokeInput struct {
	Token string `form:"token"`
}

type AccountSwitchRequest added in v0.11.0

type AccountSwitchRequest struct {
	Did         string `form:"did"`
	QueryParams string `form:"query_params"`
	Next        string `form:"next"`
}

type ApplyWriteResult

type ApplyWriteResult struct {
	Type             *string     `json:"$type,omitempty"`
	Uri              *string     `json:"uri,omitempty"`
	Cid              *string     `json:"cid,omitempty"`
	Commit           *RepoCommit `json:"commit,omitempty"`
	ValidationStatus *string     `json:"validationStatus,omitempty"`
}

type Args

type Args struct {
	Logger *slog.Logger

	LogLevel        slog.Level
	Addr            string
	DbName          string
	DbType          string
	DatabaseURL     string
	Version         string
	Did             string
	Hostname        string
	RotationKeyPath string
	JwkPath         string
	ContactEmail    string
	Relays          []string
	AdminPassword   string
	RequireInvite   bool
	SpacesEnabled   bool

	SmtpUser  string
	SmtpPass  string
	SmtpHost  string
	SmtpPort  string
	SmtpEmail string
	SmtpName  string

	S3Config *S3Config

	SessionSecret    string
	SessionCookieKey string

	BlockstoreVariant BlockstoreVariant
	FallbackProxy     string
}

type AuthPolicy added in v0.11.1

type AuthPolicy string

Policy names are intentionally explicit. A route should select one policy rather than composing the old legacy and OAuth middlewares by accident.

const (
	PolicyOAuthOnly           AuthPolicy = "oauth_only"
	PolicyOAuthOrSpace        AuthPolicy = "oauth_or_space_credential"
	PolicyDelegationExchange  AuthPolicy = "delegation_exchange"
	PolicySpaceCredentialOnly AuthPolicy = "space_credential_only"
	PolicyServiceAuthOnly     AuthPolicy = "service_auth_only"
)

type AuthPrincipal added in v0.11.1

type AuthPrincipal = Principal

type BlobDeletionS3Client added in v0.11.1

type BlobDeletionS3Client interface {
	DeleteObject(*s3.DeleteObjectInput) (*s3.DeleteObjectOutput, error)
}

BlobDeletionS3Client is the small part of the AWS client needed by the durable deletion worker. Keeping this interface narrow makes tests safe and prevents the worker from depending on provider-specific client state.

type BlobDeletionWorker added in v0.11.1

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

BlobDeletionWorker processes only rows visible through the root database connection. Consequently rows written by an account-delete transaction are not eligible until that transaction commits.

func NewBlobDeletionWorker added in v0.11.1

func NewBlobDeletionWorker(s *Server) *BlobDeletionWorker

func NewBlobDeletionWorkerForDB added in v0.11.1

func NewBlobDeletionWorkerForDB(database *db.DB, client BlobDeletionS3Client, clock func() time.Time) *BlobDeletionWorker

func (*BlobDeletionWorker) ProcessOnce added in v0.11.1

func (w *BlobDeletionWorker) ProcessOnce(ctx context.Context, limit int) (int, error)

func (*BlobDeletionWorker) PruneDeleted added in v0.11.1

func (w *BlobDeletionWorker) PruneDeleted(ctx context.Context) (int64, error)

PruneDeleted removes only successful deletion rows older than the configured retention interval. Pending/retry/failed rows are never pruned.

func (*BlobDeletionWorker) RunOnce added in v0.11.1

func (w *BlobDeletionWorker) RunOnce(ctx context.Context, limit int) (int, error)

RunOnce processes at most limit eligible rows. Network I/O happens before the terminal DB update, never inside an account transaction. DeleteObject is idempotent; a provider's not-found response is therefore success.

func (*BlobDeletionWorker) SetClock added in v0.11.1

func (w *BlobDeletionWorker) SetClock(clock func() time.Time)

func (*BlobDeletionWorker) SetOptions added in v0.11.1

func (w *BlobDeletionWorker) SetOptions(options BlobDeletionWorkerOptions)

func (*BlobDeletionWorker) SetS3Client added in v0.11.1

func (w *BlobDeletionWorker) SetS3Client(client BlobDeletionS3Client)

type BlobDeletionWorkerOptions added in v0.11.1

type BlobDeletionWorkerOptions struct {
	BaseDelay time.Duration
	MaxDelay  time.Duration
	// MaxAttempts is retained for configuration compatibility. Deletion rows
	// never become terminally failed; it no longer limits retry eligibility.
	MaxAttempts      int
	BatchSize        int
	DeletedRetention time.Duration
}

type BlockstoreVariant

type BlockstoreVariant int

func MustReturnBlockstoreVariant

func MustReturnBlockstoreVariant(maybeBsv string) BlockstoreVariant

type ComAtprotoIdentityUpdateHandleRequest

type ComAtprotoIdentityUpdateHandleRequest struct {
	Handle string `json:"handle" validate:"atproto-handle"`
}

type ComAtprotoLabelQueryLabelsResponse added in v0.7.1

type ComAtprotoLabelQueryLabelsResponse struct {
	Cursor *string `json:"cursor,omitempty"`
	Labels []Label `json:"labels"`
}

type ComAtprotoRepoApplyWritesInput added in v0.7.2

type ComAtprotoRepoApplyWritesInput struct {
	Repo       string                          `json:"repo" validate:"required,atproto-did"`
	Validate   *bool                           `json:"bool,omitempty"`
	Writes     []ComAtprotoRepoApplyWritesItem `json:"writes"`
	SwapCommit *string                         `json:"swapCommit"`
}

type ComAtprotoRepoApplyWritesItem

type ComAtprotoRepoApplyWritesItem struct {
	Type       string          `json:"$type"`
	Collection string          `json:"collection"`
	Rkey       string          `json:"rkey"`
	Value      *MarshalableMap `json:"value,omitempty"`
}

type ComAtprotoRepoApplyWritesOutput added in v0.7.2

type ComAtprotoRepoApplyWritesOutput struct {
	Commit  RepoCommit         `json:"commit"`
	Results []ApplyWriteResult `json:"results"`
}

type ComAtprotoRepoCreateRecordInput added in v0.7.2

type ComAtprotoRepoCreateRecordInput struct {
	Repo       string         `json:"repo" validate:"required,atproto-did"`
	Collection string         `json:"collection" validate:"required,atproto-nsid"`
	Rkey       *string        `json:"rkey,omitempty"`
	Validate   *bool          `json:"bool,omitempty"`
	Record     MarshalableMap `json:"record" validate:"required"`
	SwapRecord *string        `json:"swapRecord"`
	SwapCommit *string        `json:"swapCommit"`
}

type ComAtprotoRepoDeleteRecordInput added in v0.7.2

type ComAtprotoRepoDeleteRecordInput struct {
	Repo       string  `json:"repo" validate:"required,atproto-did"`
	Collection string  `json:"collection" validate:"required,atproto-nsid"`
	Rkey       string  `json:"rkey" validate:"required,atproto-rkey"`
	SwapRecord *string `json:"swapRecord"`
	SwapCommit *string `json:"swapCommit"`
}

type ComAtprotoRepoDescribeRepoResponse

type ComAtprotoRepoDescribeRepoResponse struct {
	Did             string          `json:"did"`
	Handle          string          `json:"handle"`
	DidDoc          identity.DidDoc `json:"didDoc"`
	Collections     []string        `json:"collections"`
	HandleIsCorrect bool            `json:"handleIsCorrect"`
}

type ComAtprotoRepoGetRecordResponse

type ComAtprotoRepoGetRecordResponse struct {
	Uri   string         `json:"uri"`
	Cid   string         `json:"cid"`
	Value map[string]any `json:"value"`
}

type ComAtprotoRepoListMissingBlobsRecordBlob added in v0.6.0

type ComAtprotoRepoListMissingBlobsRecordBlob struct {
	Cid       string `json:"cid"`
	RecordUri string `json:"recordUri"`
}

type ComAtprotoRepoListMissingBlobsResponse added in v0.6.0

type ComAtprotoRepoListMissingBlobsResponse struct {
	Cursor *string                                    `json:"cursor,omitempty"`
	Blobs  []ComAtprotoRepoListMissingBlobsRecordBlob `json:"blobs"`
}

type ComAtprotoRepoListRecordsRecordItem

type ComAtprotoRepoListRecordsRecordItem struct {
	Uri   string         `json:"uri"`
	Cid   string         `json:"cid"`
	Value map[string]any `json:"value"`
}

type ComAtprotoRepoListRecordsRequest

type ComAtprotoRepoListRecordsRequest struct {
	Repo       string `query:"repo" validate:"required"`
	Collection string `query:"collection" validate:"required,atproto-nsid"`
	Limit      int64  `query:"limit"`
	Cursor     string `query:"cursor"`
	Reverse    bool   `query:"reverse"`
}

type ComAtprotoRepoListRecordsResponse

type ComAtprotoRepoListRecordsResponse struct {
	Cursor  *string                               `json:"cursor,omitempty"`
	Records []ComAtprotoRepoListRecordsRecordItem `json:"records"`
}

type ComAtprotoRepoPutRecordInput added in v0.7.2

type ComAtprotoRepoPutRecordInput struct {
	Repo       string         `json:"repo" validate:"required,atproto-did"`
	Collection string         `json:"collection" validate:"required,atproto-nsid"`
	Rkey       string         `json:"rkey" validate:"required,atproto-rkey"`
	Validate   *bool          `json:"bool,omitempty"`
	Record     MarshalableMap `json:"record" validate:"required"`
	SwapRecord *string        `json:"swapRecord"`
	SwapCommit *string        `json:"swapCommit"`
}

type ComAtprotoRepoUploadBlobResponse

type ComAtprotoRepoUploadBlobResponse struct {
	Blob struct {
		Type string `json:"$type"`
		Ref  struct {
			Link string `json:"$link"`
		} `json:"ref"`
		MimeType string `json:"mimeType"`
		Size     int    `json:"size"`
	} `json:"blob"`
}

type ComAtprotoRequestEmailUpdateResponse

type ComAtprotoRequestEmailUpdateResponse struct {
	TokenRequired bool `json:"tokenRequired"`
}

type ComAtprotoServerActivateAccountRequest

type ComAtprotoServerActivateAccountRequest struct {
	// NOTE: this implementation will not pay attention to this value
	DeleteAfter time.Time `json:"deleteAfter"`
}

type ComAtprotoServerCheckAccountStatusResponse

type ComAtprotoServerCheckAccountStatusResponse struct {
	Activated          bool   `json:"activated"`
	ValidDid           bool   `json:"validDid"`
	RepoCommit         string `json:"repoCommit"`
	RepoRev            string `json:"repoRev"`
	RepoBlocks         int64  `json:"repoBlocks"`
	IndexedRecords     int64  `json:"indexedRecords"`
	PrivateStateValues int64  `json:"privateStateValues"`
	ExpectedBlobs      int64  `json:"expectedBlobs"`
	ImportedBlobs      int64  `json:"importedBlobs"`
}

type ComAtprotoServerConfirmEmailRequest

type ComAtprotoServerConfirmEmailRequest struct {
	Email string `json:"email" validate:"required"`
	Token string `json:"token" validate:"required"`
}

type ComAtprotoServerCreateAccountRequest

type ComAtprotoServerCreateAccountRequest struct {
	Email      string  `json:"email" validate:"required,email"`
	Handle     string  `json:"handle" validate:"required,atproto-handle"`
	Did        *string `json:"did" validate:"atproto-did"`
	Password   string  `json:"password" validate:"required"`
	InviteCode string  `json:"inviteCode" validate:"omitempty"`
}

type ComAtprotoServerCreateAccountResponse

type ComAtprotoServerCreateAccountResponse struct {
	AccessJwt  string `json:"accessJwt"`
	RefreshJwt string `json:"refreshJwt"`
	Handle     string `json:"handle"`
	Did        string `json:"did"`
}

type ComAtprotoServerCreateInviteCodeRequest

type ComAtprotoServerCreateInviteCodeRequest struct {
	UseCount   int     `json:"useCount" validate:"required"`
	ForAccount *string `json:"forAccount,omitempty"`
}

type ComAtprotoServerCreateInviteCodeResponse

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

type ComAtprotoServerCreateInviteCodesItem

type ComAtprotoServerCreateInviteCodesItem struct {
	Account string   `json:"account"`
	Codes   []string `json:"codes"`
}

type ComAtprotoServerCreateInviteCodesRequest

type ComAtprotoServerCreateInviteCodesRequest struct {
	CodeCount   *int      `json:"codeCount,omitempty"`
	UseCount    int       `json:"useCount" validate:"required"`
	ForAccounts *[]string `json:"forAccounts,omitempty"`
}

type ComAtprotoServerCreateInviteCodesResponse

type ComAtprotoServerCreateInviteCodesResponse []ComAtprotoServerCreateInviteCodesItem

type ComAtprotoServerCreateSessionRequest

type ComAtprotoServerCreateSessionRequest struct {
	Identifier      string  `json:"identifier" validate:"required"`
	Password        string  `json:"password" validate:"required"`
	AuthFactorToken *string `json:"authFactorToken,omitempty"`
}

type ComAtprotoServerCreateSessionResponse

type ComAtprotoServerCreateSessionResponse struct {
	AccessJwt       string  `json:"accessJwt"`
	RefreshJwt      string  `json:"refreshJwt"`
	Handle          string  `json:"handle"`
	Did             string  `json:"did"`
	Email           string  `json:"email"`
	EmailConfirmed  bool    `json:"emailConfirmed"`
	EmailAuthFactor bool    `json:"emailAuthFactor"`
	Active          bool    `json:"active"`
	Status          *string `json:"status,omitempty"`
}

type ComAtprotoServerDeactivateAccountRequest

type ComAtprotoServerDeactivateAccountRequest struct {
	// NOTE: this implementation will not pay attention to this value
	DeleteAfter time.Time `json:"deleteAfter"`
}

type ComAtprotoServerDeleteAccountRequest added in v0.7.0

type ComAtprotoServerDeleteAccountRequest struct {
	Did      string `json:"did" validate:"required"`
	Password string `json:"password" validate:"required"`
	Token    string `json:"token" validate:"required"`
}

type ComAtprotoServerDescribeServerResponse

type ComAtprotoServerDescribeServerResponse struct {
	InviteCodeRequired        bool                                          `json:"inviteCodeRequired"`
	PhoneVerificationRequired bool                                          `json:"phoneVerificationRequired"`
	AvailableUserDomains      []string                                      `json:"availableUserDomains"`
	Links                     ComAtprotoServerDescribeServerResponseLinks   `json:"links"`
	Contact                   ComAtprotoServerDescribeServerResponseContact `json:"contact"`
	Did                       string                                        `json:"did"`
}

type ComAtprotoServerDescribeServerResponseContact

type ComAtprotoServerDescribeServerResponseContact struct {
	Email string `json:"email"`
}
type ComAtprotoServerDescribeServerResponseLinks struct {
	PrivacyPolicy  *string `json:"privacyPolicy,omitempty"`
	TermsOfService *string `json:"termsOfService,omitempty"`
}

type ComAtprotoServerGetSessionResponse

type ComAtprotoServerGetSessionResponse struct {
	Handle          string  `json:"handle"`
	Did             string  `json:"did"`
	Email           string  `json:"email"`
	EmailConfirmed  bool    `json:"emailConfirmed"`
	EmailAuthFactor bool    `json:"emailAuthFactor"`
	Active          bool    `json:"active"`
	Status          *string `json:"status,omitempty"`
}

type ComAtprotoServerRefreshSessionResponse

type ComAtprotoServerRefreshSessionResponse struct {
	AccessJwt  string  `json:"accessJwt"`
	RefreshJwt string  `json:"refreshJwt"`
	Handle     string  `json:"handle"`
	Did        string  `json:"did"`
	Active     bool    `json:"active"`
	Status     *string `json:"status,omitempty"`
}

type ComAtprotoServerRequestPasswordResetRequest

type ComAtprotoServerRequestPasswordResetRequest struct {
	Email string `json:"email" validate:"required"`
}

type ComAtprotoServerResetPasswordRequest

type ComAtprotoServerResetPasswordRequest struct {
	Token    string `json:"token" validate:"required"`
	Password string `json:"password" validate:"required"`
}

type ComAtprotoServerUpdateEmailRequest

type ComAtprotoServerUpdateEmailRequest struct {
	Email           string `json:"email" validate:"required"`
	EmailAuthFactor bool   `json:"emailAuthFactor"`
	Token           string `json:"token"`
}

type ComAtprotoSignPlcOperationRequest

type ComAtprotoSignPlcOperationRequest struct {
	Token               string                                `json:"token"`
	VerificationMethods *map[string]string                    `json:"verificationMethods"`
	RotationKeys        *[]string                             `json:"rotationKeys"`
	AlsoKnownAs         *[]string                             `json:"alsoKnownAs"`
	Services            *map[string]identity.OperationService `json:"services"`
}

type ComAtprotoSignPlcOperationResponse

type ComAtprotoSignPlcOperationResponse struct {
	Operation plc.Operation `json:"operation"`
}

type ComAtprotoSimpleSpaceCreateSpaceInput added in v0.11.1

type ComAtprotoSimpleSpaceCreateSpaceInput struct {
	Type      string          `json:"type"`
	SKey      *string         `json:"skey,omitempty"`
	Policy    json.RawMessage `json:"policy"`
	AppAccess json.RawMessage `json:"appAccess"`
}

type ComAtprotoSimpleSpaceCreateSpaceOutput added in v0.11.1

type ComAtprotoSimpleSpaceCreateSpaceOutput struct {
	URI string `json:"uri"`
}

type ComAtprotoSimpleSpaceDeleteSpaceInput added in v0.11.1

type ComAtprotoSimpleSpaceDeleteSpaceInput struct {
	Space string `json:"space"`
}

type ComAtprotoSimpleSpaceGetSpaceOutput added in v0.11.1

type ComAtprotoSimpleSpaceGetSpaceOutput struct {
	URI       string          `json:"uri"`
	Policy    json.RawMessage `json:"policy"`
	AppAccess json.RawMessage `json:"appAccess"`
}

type ComAtprotoSimpleSpaceListMembersOutput added in v0.11.1

type ComAtprotoSimpleSpaceListMembersOutput struct {
	Cursor  *string                       `json:"cursor,omitempty"`
	Members []ComAtprotoSimpleSpaceMember `json:"members"`
}

type ComAtprotoSimpleSpaceMember added in v0.11.1

type ComAtprotoSimpleSpaceMember struct {
	DID string `json:"did"`
}

type ComAtprotoSimpleSpaceMemberInput added in v0.11.1

type ComAtprotoSimpleSpaceMemberInput struct {
	Space string `json:"space"`
	DID   string `json:"did"`
}

type ComAtprotoSimpleSpaceUpdateSpaceInput added in v0.11.1

type ComAtprotoSimpleSpaceUpdateSpaceInput struct {
	Space     string          `json:"space"`
	Policy    json.RawMessage `json:"policy,omitempty"`
	AppAccess json.RawMessage `json:"appAccess,omitempty"`
}

type ComAtprotoSpaceApplyWritesElement added in v0.11.1

type ComAtprotoSpaceApplyWritesElement struct {
	Type       string         `json:"$type"`
	Collection string         `json:"collection"`
	Rkey       *string        `json:"rkey,omitempty"`
	Value      MarshalableMap `json:"value,omitempty"`
}

ComAtprotoSpaceApplyWritesElement is the closed union element. Type is one of com.atproto.space.applyWrites#{create,update,delete}.

type ComAtprotoSpaceApplyWritesInput added in v0.11.1

type ComAtprotoSpaceApplyWritesInput struct {
	Space    string                              `json:"space"`
	Repo     string                              `json:"repo"`
	Validate *bool                               `json:"validate,omitempty"`
	Writes   []ComAtprotoSpaceApplyWritesElement `json:"writes"`
}

ComAtprotoSpaceApplyWritesInput is the pinned input shape for com.atproto.space.applyWrites.

type ComAtprotoSpaceApplyWritesOutput added in v0.11.1

type ComAtprotoSpaceApplyWritesOutput struct {
	Results []ComAtprotoSpaceApplyWritesResult `json:"results"`
}

ComAtprotoSpaceApplyWritesOutput is the pinned applyWrites output shape.

type ComAtprotoSpaceApplyWritesResult added in v0.11.1

type ComAtprotoSpaceApplyWritesResult struct {
	Type             string  `json:"$type"`
	URI              string  `json:"uri,omitempty"`
	CID              string  `json:"cid,omitempty"`
	ValidationStatus *string `json:"validationStatus,omitempty"`
}

ComAtprotoSpaceApplyWritesResult is the closed result union. The $type tag is required on the wire even though it is implicit in the lexicon union.

type ComAtprotoSpaceCreateRecordInput added in v0.11.1

type ComAtprotoSpaceCreateRecordInput struct {
	Space      string         `json:"space"`
	Repo       string         `json:"repo"`
	Collection string         `json:"collection"`
	Rkey       *string        `json:"rkey,omitempty"`
	Validate   *bool          `json:"validate,omitempty"`
	Record     MarshalableMap `json:"record"`
}

ComAtprotoSpaceCreateRecordInput is the pinned input shape for com.atproto.space.createRecord.

type ComAtprotoSpaceDeleteRecordInput added in v0.11.1

type ComAtprotoSpaceDeleteRecordInput struct {
	Space      string `json:"space"`
	Repo       string `json:"repo"`
	Collection string `json:"collection"`
	Rkey       string `json:"rkey"`
}

ComAtprotoSpaceDeleteRecordInput is the pinned input shape for com.atproto.space.deleteRecord.

type ComAtprotoSpaceGetDelegationTokenOutput added in v0.11.1

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

ComAtprotoSpaceGetDelegationTokenOutput is the pinned delegation output.

type ComAtprotoSpaceGetLatestCommitResponse added in v0.11.1

type ComAtprotoSpaceGetLatestCommitResponse struct {
	Commit space.SignedCommit `json:"commit"`
}

type ComAtprotoSpaceGetRecordResponse added in v0.11.1

type ComAtprotoSpaceGetRecordResponse struct {
	URI   string `json:"uri"`
	CID   string `json:"cid,omitempty"`
	Value any    `json:"value"`
}

type ComAtprotoSpaceGetSpaceCredentialInput added in v0.11.1

type ComAtprotoSpaceGetSpaceCredentialInput struct {
	Space             string `json:"space"`
	ClientAttestation string `json:"clientAttestation,omitempty"`
}

type ComAtprotoSpaceGetSpaceCredentialOutput added in v0.11.1

type ComAtprotoSpaceGetSpaceCredentialOutput struct {
	Credential string `json:"credential"`
}

type ComAtprotoSpaceListBlobsResponse added in v0.11.1

type ComAtprotoSpaceListBlobsResponse struct {
	Cursor *string  `json:"cursor,omitempty"`
	CIDs   []string `json:"cids"`
}

type ComAtprotoSpaceListRecordsRecord added in v0.11.1

type ComAtprotoSpaceListRecordsRecord struct {
	Collection string `json:"collection"`
	Rkey       string `json:"rkey"`
	CID        string `json:"cid"`
	Value      any    `json:"value,omitempty"`
}

type ComAtprotoSpaceListRecordsResponse added in v0.11.1

type ComAtprotoSpaceListRecordsResponse struct {
	Cursor  *string                            `json:"cursor,omitempty"`
	Records []ComAtprotoSpaceListRecordsRecord `json:"records"`
}

type ComAtprotoSpaceListRepoOpsResponse added in v0.11.1

type ComAtprotoSpaceListRepoOpsResponse struct {
	Cursor *string                 `json:"cursor,omitempty"`
	Ops    []ComAtprotoSpaceRepoOp `json:"ops"`
	Commit *space.SignedCommit     `json:"commit,omitempty"`
}

type ComAtprotoSpaceListReposRepoRef added in v0.11.1

type ComAtprotoSpaceListReposRepoRef struct {
	DID  string `json:"did"`
	Rev  string `json:"rev"`
	Hash string `json:"hash"`
}

func (ComAtprotoSpaceListReposRepoRef) MarshalJSON added in v0.11.1

func (r ComAtprotoSpaceListReposRepoRef) MarshalJSON() ([]byte, error)

func (*ComAtprotoSpaceListReposRepoRef) UnmarshalJSON added in v0.11.1

func (r *ComAtprotoSpaceListReposRepoRef) UnmarshalJSON(data []byte) error

type ComAtprotoSpaceListReposResponse added in v0.11.1

type ComAtprotoSpaceListReposResponse struct {
	Cursor *string                           `json:"cursor,omitempty"`
	Repos  []ComAtprotoSpaceListReposRepoRef `json:"repos"`
}

type ComAtprotoSpaceListSpacesOutput added in v0.11.1

type ComAtprotoSpaceListSpacesOutput struct {
	Cursor *string                              `json:"cursor,omitempty"`
	Spaces []ComAtprotoSpaceListSpacesSpaceView `json:"spaces"`
}

ComAtprotoSpaceListSpacesOutput is the pinned listSpaces output shape.

type ComAtprotoSpaceListSpacesSpaceView added in v0.11.1

type ComAtprotoSpaceListSpacesSpaceView struct {
	URI string `json:"uri"`
}

ComAtprotoSpaceListSpacesSpaceView is the pinned listSpaces spaceView.

type ComAtprotoSpaceNotifySpaceDeletedInput added in v0.11.1

type ComAtprotoSpaceNotifySpaceDeletedInput struct {
	Space string `json:"space"`
}

type ComAtprotoSpaceNotifyWriteInput added in v0.11.1

type ComAtprotoSpaceNotifyWriteInput struct {
	Space string `json:"space"`
	Repo  string `json:"repo"`
	Rev   string `json:"rev"`
	Hash  string `json:"hash"`
}

ComAtprotoSpaceNotifyWriteInput is deliberately metadata-only. Hash is the JSON bytes string from the pinned Lexicon; no record or blob fields are accepted or persisted.

type ComAtprotoSpacePutRecordInput added in v0.11.1

type ComAtprotoSpacePutRecordInput struct {
	Space      string         `json:"space"`
	Repo       string         `json:"repo"`
	Collection string         `json:"collection"`
	Rkey       string         `json:"rkey"`
	Validate   *bool          `json:"validate,omitempty"`
	Record     MarshalableMap `json:"record"`
}

ComAtprotoSpacePutRecordInput is the pinned input shape for com.atproto.space.putRecord.

type ComAtprotoSpaceRecordWriteOutput added in v0.11.1

type ComAtprotoSpaceRecordWriteOutput struct {
	URI              string  `json:"uri"`
	CID              string  `json:"cid"`
	ValidationStatus *string `json:"validationStatus,omitempty"`
}

ComAtprotoSpaceRecordWriteOutput is shared by createRecord and putRecord.

type ComAtprotoSpaceRegisterNotifyInput added in v0.11.1

type ComAtprotoSpaceRegisterNotifyInput struct {
	Space   string `json:"space"`
	Service string `json:"service"`
}

ComAtprotoSpaceRegisterNotifyInput is the pinned registerNotify body.

type ComAtprotoSpaceRegisterNotifyOutput added in v0.11.1

type ComAtprotoSpaceRegisterNotifyOutput struct {
	ExpiresAt time.Time `json:"expiresAt"`
}

type ComAtprotoSpaceRepoOp added in v0.11.1

type ComAtprotoSpaceRepoOp struct {
	Rev        string  `json:"rev"`
	Collection string  `json:"collection"`
	RKey       string  `json:"rkey"`
	CID        *string `json:"cid"`
	Prev       *string `json:"prev"`
	Value      any     `json:"value,omitempty"`
}

type ComAtprotoSpaceUnregisterNotifyInput added in v0.11.1

type ComAtprotoSpaceUnregisterNotifyInput struct {
	Space   string `json:"space"`
	Service string `json:"service"`
}

ComAtprotoSpaceUnregisterNotifyInput is the pinned unregisterNotify body.

type ComAtprotoSubmitPlcOperationRequest

type ComAtprotoSubmitPlcOperationRequest struct {
	Operation plc.Operation `json:"operation"`
}

type ComAtprotoSyncGetBlocksRequest

type ComAtprotoSyncGetBlocksRequest struct {
	Did  string   `query:"did"`
	Cids []string `query:"cids"`
}

type ComAtprotoSyncGetLatestCommitResponse

type ComAtprotoSyncGetLatestCommitResponse struct {
	Cid string `json:"cid"`
	Rev string `json:"rev"`
}

type ComAtprotoSyncGetRepoStatusResponse

type ComAtprotoSyncGetRepoStatusResponse struct {
	Did    string  `json:"did"`
	Active bool    `json:"active"`
	Status *string `json:"status,omitempty"`
	Rev    *string `json:"rev,omitempty"`
}

type ComAtprotoSyncListBlobsResponse

type ComAtprotoSyncListBlobsResponse struct {
	Cursor *string  `json:"cursor,omitempty"`
	Cids   []string `json:"cids"`
}

type ComAtprotoSyncListReposRepoItem

type ComAtprotoSyncListReposRepoItem struct {
	Did    string  `json:"did"`
	Head   string  `json:"head"`
	Rev    string  `json:"rev"`
	Active bool    `json:"active"`
	Status *string `json:"status,omitempty"`
}

type ComAtprotoSyncListReposResponse

type ComAtprotoSyncListReposResponse struct {
	Cursor *string                           `json:"cursor,omitempty"`
	Repos  []ComAtprotoSyncListReposRepoItem `json:"repos"`
}

type CustomValidator

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

func (*CustomValidator) Validate

func (cv *CustomValidator) Validate(i any) error

type DIDDocumentFetcher added in v0.11.1

type DIDDocumentFetcher interface {
	FetchDoc(context.Context, string) (*cocoon_identity.DidDoc, error)
	ResolveHandle(context.Context, string) (string, error)
	BustDoc(context.Context, string) error
	BustDid(context.Context, string) error
}

DIDDocumentFetcher is the small Passport contract needed by Space auth. It keeps production backed by the server's Passport while allowing hermetic tests to provide a fake document source.

type DIDSpaceAuthorityKeyResolver added in v0.11.1

type DIDSpaceAuthorityKeyResolver struct{ Source SpaceAuthorityKeySource }

DIDSpaceAuthorityKeyResolver adapts a DID key source and retries a #atproto_space lookup with the legacy #atproto key id. This is the explicit fallback contract; it does not itself perform network resolution.

func NewDIDSpaceAuthorityKeyResolver added in v0.11.1

func NewDIDSpaceAuthorityKeyResolver(source SpaceAuthorityKeySource) *DIDSpaceAuthorityKeyResolver

func (*DIDSpaceAuthorityKeyResolver) ResolveSigningKey added in v0.11.1

type DbPersister added in v0.8.4

type DbPersister struct {
	Db *gorm.DB

	Lk  sync.Mutex
	Seq int64

	Broadcast func(*events.XRPCStreamEvent)

	// how long do we actually want to keep these things around
	Retention time.Duration
}

func NewDbPersister added in v0.8.4

func NewDbPersister(db *gorm.DB, retention time.Duration) (*DbPersister, error)

func (*DbPersister) Flush added in v0.8.4

func (p *DbPersister) Flush(ctx context.Context) error

func (*DbPersister) Persist added in v0.8.4

func (p *DbPersister) Persist(ctx context.Context, e *events.XRPCStreamEvent) error

func (*DbPersister) Playback added in v0.8.4

func (p *DbPersister) Playback(ctx context.Context, since int64, cb func(*events.XRPCStreamEvent) error) error

func (*DbPersister) SetEventBroadcaster added in v0.8.4

func (p *DbPersister) SetEventBroadcaster(brc func(*events.XRPCStreamEvent))

func (*DbPersister) Shutdown added in v0.8.4

func (p *DbPersister) Shutdown(ctx context.Context) error

func (*DbPersister) TakeDownRepo added in v0.8.4

func (p *DbPersister) TakeDownRepo(ctx context.Context, uid indigomodels.Uid) error

type DelegationPrincipal added in v0.11.1

type DelegationPrincipal struct {
	SpaceURI     string
	AuthorityDID string
	Token        string
	Claims       space.SpaceTokenClaims
	DPoPJKT      string
	DPoPJTI      string
	DPoPIssuedAt time.Time
}

DelegationPrincipal is installed by DelegationExchange after both the delegation token and issuance DPoP proof have been verified.

func (*DelegationPrincipal) PrincipalType added in v0.11.1

func (p *DelegationPrincipal) PrincipalType() PrincipalType

type ES256KSigningMethod

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

func (*ES256KSigningMethod) Alg

func (m *ES256KSigningMethod) Alg() string

func (*ES256KSigningMethod) Sign

func (m *ES256KSigningMethod) Sign(signingString string, key interface{}) (string, error)

func (*ES256KSigningMethod) Verify

func (m *ES256KSigningMethod) Verify(signingString string, signature string, key interface{}) error

type FirehoseOp

type FirehoseOp struct {
	Cid    cid.Cid
	Path   string
	Action string
}

type HandleOauthAuthorizeGetInput added in v0.8.1

type HandleOauthAuthorizeGetInput struct {
	RequestUri string `query:"request_uri"`
}

type Label added in v0.7.1

type Label struct {
	Ver *int    `json:"ver,omitempty"`
	Src string  `json:"src"`
	Uri string  `json:"uri"`
	Cid *string `json:"cid,omitempty"`
	Val string  `json:"val"`
	Neg *bool   `json:"neg,omitempty"`
	Cts string  `json:"cts"`
	Exp *string `json:"exp,omitempty"`
	Sig []byte  `json:"sig,omitempty"`
}

type MarshalableMap

type MarshalableMap map[string]any

func (*MarshalableMap) MarshalCBOR

func (mm *MarshalableMap) MarshalCBOR(w io.Writer) error

type OAuthPrincipal added in v0.11.1

type OAuthPrincipal struct {
	Subject  string
	ClientID string
	Scopes   []string
	DPoPJKT  string
	Token    string
	Repo     *models.RepoActor
	// Legacy marks a password/session access token. Reference atproto permits
	// these tokens on authorization routes and bypasses granular OAuth scopes.
	Legacy bool
}

OAuthPrincipal describes an OAuth access token that passed token and (when applicable) DPoP/token-database validation.

func (*OAuthPrincipal) GetClientID added in v0.11.1

func (p *OAuthPrincipal) GetClientID() string

func (*OAuthPrincipal) GetScopes added in v0.11.1

func (p *OAuthPrincipal) GetScopes() []string

func (*OAuthPrincipal) GetSubject added in v0.11.1

func (p *OAuthPrincipal) GetSubject() string

func (*OAuthPrincipal) PrincipalType added in v0.11.1

func (p *OAuthPrincipal) PrincipalType() PrincipalType

type OauthAuthorizationMetadata

type OauthAuthorizationMetadata struct {
	Issuer                                     string   `json:"issuer"`
	RequestParameterSupported                  bool     `json:"request_parameter_supported"`
	RequestUriParameterSupported               bool     `json:"request_uri_parameter_supported"`
	RequireRequestUriRegistration              *bool    `json:"require_request_uri_registration,omitempty"`
	ScopesSupported                            []string `json:"scopes_supported"`
	SubjectTypesSupported                      []string `json:"subject_types_supported"`
	ResponseTypesSupported                     []string `json:"response_types_supported"`
	ResponseModesSupported                     []string `json:"response_modes_supported"`
	GrantTypesSupported                        []string `json:"grant_types_supported"`
	CodeChallengeMethodsSupported              []string `json:"code_challenge_methods_supported"`
	UILocalesSupported                         []string `json:"ui_locales_supported"`
	DisplayValuesSupported                     []string `json:"display_values_supported"`
	RequestObjectSigningAlgValuesSupported     []string `json:"request_object_signing_alg_values_supported"`
	AuthorizationResponseISSParameterSupported bool     `json:"authorization_response_iss_parameter_supported"`
	RequestObjectEncryptionAlgValuesSupported  []string `json:"request_object_encryption_alg_values_supported"`
	RequestObjectEncryptionEncValuesSupported  []string `json:"request_object_encryption_enc_values_supported"`
	JwksUri                                    string   `json:"jwks_uri"`
	AuthorizationEndpoint                      string   `json:"authorization_endpoint"`
	TokenEndpoint                              string   `json:"token_endpoint"`
	TokenEndpointAuthMethodsSupported          []string `json:"token_endpoint_auth_methods_supported"`
	TokenEndpointAuthSigningAlgValuesSupported []string `json:"token_endpoint_auth_signing_alg_values_supported"`
	RevocationEndpoint                         string   `json:"revocation_endpoint"`
	IntrospectionEndpoint                      string   `json:"introspection_endpoint"`
	PushedAuthorizationRequestEndpoint         string   `json:"pushed_authorization_request_endpoint"`
	RequirePushedAuthorizationRequests         bool     `json:"require_pushed_authorization_requests"`
	DpopSigningAlgValuesSupported              []string `json:"dpop_signing_alg_values_supported"`
	ProtectedResources                         []string `json:"protected_resources"`
	ClientIDMetadataDocumentSupported          bool     `json:"client_id_metadata_document_supported"`
}

type OauthAuthorizePostRequest

type OauthAuthorizePostRequest struct {
	RequestUri    string `form:"request_uri"`
	AcceptOrRejct string `form:"accept_or_reject"`
}

type OauthJwksResponse

type OauthJwksResponse struct {
	Keys []any `json:"keys"`
}

type OauthParResponse

type OauthParResponse struct {
	ExpiresIn  int64  `json:"expires_in"`
	RequestURI string `json:"request_uri"`
}

type OauthRevokeRequest added in v0.11.0

type OauthRevokeRequest struct {
	provider.AuthenticateClientRequestBase
	Token         string  `form:"token" json:"token"`
	TokenTypeHint *string `form:"token_type_hint" json:"token_type_hint,omitempty"`
}

type OauthSigninInput added in v0.7.2

type OauthSigninInput struct {
	Username        string `form:"username"`
	Password        string `form:"password"`
	AuthFactorToken string `form:"token"`
	QueryParams     string `form:"query_params"`
}

type OauthTokenRequest

type OauthTokenRequest struct {
	provider.AuthenticateClientRequestBase
	GrantType    string  `form:"grant_type" json:"grant_type"`
	Code         *string `form:"code" json:"code,omitempty"`
	CodeVerifier *string `form:"code_verifier" json:"code_verifier,omitempty"`
	RedirectURI  *string `form:"redirect_uri" json:"redirect_uri,omitempty"`
	RefreshToken *string `form:"refresh_token" json:"refresh_token,omitempty"`
}

type OauthTokenResponse

type OauthTokenResponse struct {
	AccessToken  string `json:"access_token"`
	TokenType    string `json:"token_type"`
	RefreshToken string `json:"refresh_token"`
	Scope        string `json:"scope"`
	ExpiresIn    int64  `json:"expires_in"`
	Sub          string `json:"sub"`
}

type Op

type Op struct {
	Type       OpType          `json:"$type"`
	Collection string          `json:"collection"`
	Rkey       *string         `json:"rkey,omitempty"`
	Validate   *bool           `json:"validate,omitempty"`
	SwapRecord *string         `json:"swapRecord,omitempty"`
	Record     *MarshalableMap `json:"record,omitempty"`
}

type OpType

type OpType string

func (OpType) String

func (ot OpType) String() string

type PassportSpaceAuthorityKeyResolver added in v0.11.1

type PassportSpaceAuthorityKeyResolver struct{ Passport DIDDocumentFetcher }

PassportSpaceAuthorityKeyResolver is the production DID-backed resolver for Space credentials and delegation tokens.

func NewPassportSpaceAuthorityKeyResolver added in v0.11.1

func NewPassportSpaceAuthorityKeyResolver(passport DIDDocumentFetcher) *PassportSpaceAuthorityKeyResolver

func (*PassportSpaceAuthorityKeyResolver) ResolveSigningKey added in v0.11.1

type Principal added in v0.11.1

type Principal interface {
	PrincipalType() PrincipalType
}

Principal is the common request-context authentication contract. Concrete principals deliberately retain protocol-specific claims for handlers that need them, while new handlers can make authorization decisions without reading legacy context keys.

func GetPrincipal added in v0.11.1

func GetPrincipal(e echo.Context) Principal

GetPrincipal is a compatibility accessor for new handlers.

func PrincipalFromContext added in v0.11.1

func PrincipalFromContext(e echo.Context) Principal

PrincipalFromContext returns the verified request principal, if any.

type PrincipalType added in v0.11.1

type PrincipalType string

PrincipalType identifies the authenticated protocol principal installed on a request. A principal is installed only after its protocol-specific verifier has completed successfully.

type RecommitOptions added in v0.11.0

type RecommitOptions struct {
	// Dids is the set of repos to process.
	Dids []string
	// DryRun reports planned actions without mutating repos or emitting events.
	DryRun bool
	// BlockstoreVariant selects the block store (mirrors the server flag).
	BlockstoreVariant string
	Logger            *slog.Logger
}

RecommitOptions configures RunRecommitMigration.

type RecommitResult added in v0.11.0

type RecommitResult struct {
	Did         string
	OldRev      string
	NewRev      string
	OldHead     string
	NewHead     string
	Recommitted bool
	Err         error
}

RecommitResult is the per-repo outcome of the migration.

func RunRecommitMigration added in v0.11.0

func RunRecommitMigration(ctx context.Context, gdb *gorm.DB, opts RecommitOptions) ([]RecommitResult, error)

RunRecommitMigration re-mints valid revs for repos whose stored rev is not a valid TID, and announces each repo's current head to the firehose.

For every did it re-commits when the rev is invalid (a fresh signed commit with a current 13-char TID rev and new head), then emits #sync (head announcement), #identity (handle refresh), and #account (active) so relays observe the repo's authoritative state. Re-committing is silent on the commit stream; #sync is the spec's frame for out-of-band state changes.

IMPORTANT: events carry an in-memory sequence number, so this must run with the PDS stopped to avoid colliding with the live server's sequence.

type RepoCommit

type RepoCommit struct {
	Cid string `json:"cid"`
	Rev string `json:"rev"`
}

type RepoMan

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

func NewRepoMan

func NewRepoMan(s *Server) *RepoMan

type RequestPrincipal added in v0.11.1

type RequestPrincipal = Principal

RequestPrincipal and AuthPrincipal are compatibility spellings for Principal.

type S3Config

type S3Config struct {
	BackupsEnabled   bool
	BlobstoreEnabled bool
	Endpoint         string
	Region           string
	Bucket           string
	AccessKey        string
	SecretKey        string
	CDNUrl           string
}

type Server

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

func New

func New(args *Args) (*Server, error)

func (*Server) AuthDispatcher added in v0.11.1

func (s *Server) AuthDispatcher(policy AuthPolicy, next echo.HandlerFunc) echo.HandlerFunc

AuthDispatcher is the one entry point for route-specific authentication. It never calls legacy middleware for Space token types.

func (*Server) DelegationExchange added in v0.11.1

func (s *Server) DelegationExchange(next echo.HandlerFunc) echo.HandlerFunc

func (*Server) OAuthOnly added in v0.11.1

func (s *Server) OAuthOnly(next echo.HandlerFunc) echo.HandlerFunc

Explicit policy constructors. These methods are suitable as Echo route middleware and do not need to be combined with legacy middleware.

func (*Server) OAuthOrSpaceCredential added in v0.11.1

func (s *Server) OAuthOrSpaceCredential(next echo.HandlerFunc) echo.HandlerFunc

func (*Server) QueueSpaceDeletedNotifications added in v0.11.1

func (s *Server) QueueSpaceDeletedNotifications(ctx context.Context, spaceRef, source string) error

QueueSpaceDeletedNotifications records the tombstone and fans out durable deletion deliveries; it performs no network I/O.

func (*Server) RecordSpaceNotifySpaceDeleted added in v0.11.1

func (s *Server) RecordSpaceNotifySpaceDeleted(ctx context.Context, uri, source string, queueForwarding bool) error

func (*Server) RecordSpaceNotifyWrite added in v0.11.1

func (s *Server) RecordSpaceNotifyWrite(ctx context.Context, uri, author, rev string, hash []byte, source string) error

func (*Server) Serve

func (s *Server) Serve(ctx context.Context) error

func (*Server) ServiceAuthOnly added in v0.11.1

func (s *Server) ServiceAuthOnly(next echo.HandlerFunc) echo.HandlerFunc

func (*Server) SetBlobDeletionS3Client added in v0.11.1

func (s *Server) SetBlobDeletionS3Client(client BlobDeletionS3Client)

func (*Server) SetManagingAppAuthorizer added in v0.11.1

func (s *Server) SetManagingAppAuthorizer(a SimpleSpaceManagingAppAuthorizer)

SetManagingAppAuthorizer is a concise compatibility spelling for integration.

func (*Server) SetPassport added in v0.11.1

func (s *Server) SetPassport(passport DIDDocumentFetcher)

SetPassport injects the Passport-compatible identity source used by service-auth and production Space authority key resolution. It is primarily useful for hermetic tests and hosts with a custom identity cache.

func (*Server) SetSimpleSpaceManagingAppAuthorizer added in v0.11.1

func (s *Server) SetSimpleSpaceManagingAppAuthorizer(a SimpleSpaceManagingAppAuthorizer)

SetSimpleSpaceManagingAppAuthorizer installs the managing-app checker. A nil checker intentionally leaves the policy fail-closed.

func (*Server) SetSpaceAuthorityKeyResolver added in v0.11.1

func (s *Server) SetSpaceAuthorityKeyResolver(resolver SpaceAuthorityKeyResolver)

SetSpaceAuthorityKeyResolver injects the DID/JWKS resolver used by Space credential and delegation verification. It is primarily useful for tests and for hosts with an identity cache.

func (*Server) SetSpaceNotificationClock added in v0.11.1

func (s *Server) SetSpaceNotificationClock(now func() time.Time)

func (*Server) SetSpaceNotificationResolver added in v0.11.1

func (s *Server) SetSpaceNotificationResolver(r SpaceNotificationResolver)

func (*Server) SetSpaceNotificationSender added in v0.11.1

func (s *Server) SetSpaceNotificationSender(sender SpaceNotificationSender)

func (*Server) SetSpaceReplayStore added in v0.11.1

func (s *Server) SetSpaceReplayStore(store space.ReplayStore)

SetSpaceReplayStore injects a replay store. Production New configures a durable GORM store; tests may use space.MemoryReplayStore.

func (*Server) SetSpaceTypeResolver added in v0.11.1

func (s *Server) SetSpaceTypeResolver(resolver scopes.SpaceTypeResolver)

SetSpaceTypeResolver injects the local, typed space declaration resolver used for omitted-collection OAuth grants. It never performs network resolution.

func (*Server) SpaceCredentialOnly added in v0.11.1

func (s *Server) SpaceCredentialOnly(next echo.HandlerFunc) echo.HandlerFunc

func (*Server) UpdateRepo

func (s *Server) UpdateRepo(ctx context.Context, did string, root cid.Cid, rev string) error

type ServerGetServiceAuthRequest

type ServerGetServiceAuthRequest struct {
	Aud string `query:"aud" validate:"required,atproto-did"`
	// exp should be a float, as some clients will send a non-integer expiration
	Exp float64 `query:"exp"`
	Lxm string  `query:"lxm"`
}

type ServerReserveSigningKeyRequest added in v0.7.0

type ServerReserveSigningKeyRequest struct {
	Did *string `json:"did"`
}

type ServerReserveSigningKeyResponse added in v0.7.0

type ServerReserveSigningKeyResponse struct {
	SigningKey string `json:"signingKey"`
}

type ServiceAuthPrincipal added in v0.11.1

type ServiceAuthPrincipal struct {
	Issuer   string
	Audience string
	LXM      string
	Token    string
	Repo     *models.RepoActor
}

ServiceAuthPrincipal describes a verified atproto service-auth token.

func (*ServiceAuthPrincipal) GetAudience added in v0.11.1

func (p *ServiceAuthPrincipal) GetAudience() string

func (*ServiceAuthPrincipal) GetIssuer added in v0.11.1

func (p *ServiceAuthPrincipal) GetIssuer() string

func (*ServiceAuthPrincipal) GetLXM added in v0.11.1

func (p *ServiceAuthPrincipal) GetLXM() string

func (*ServiceAuthPrincipal) PrincipalType added in v0.11.1

func (p *ServiceAuthPrincipal) PrincipalType() PrincipalType

type Session

type Session struct {
	AccessToken  string
	RefreshToken string
}

type SimpleSpaceManagingAppAuthorizer added in v0.11.1

type SimpleSpaceManagingAppAuthorizer interface {
	CheckUserAccess(context.Context, string, string, string, string) (bool, error)
}

SimpleSpaceManagingAppAuthorizer is the narrow host integration used for the pinned managing-app policy. The implementation must perform the outbound checkUserAccess request as the authority; this package deliberately has no inbound checkUserAccess route.

type SimpleSpaceManagingAppAuthorizerFunc added in v0.11.1

type SimpleSpaceManagingAppAuthorizerFunc func(context.Context, string, string, string, string) (bool, error)

SimpleSpaceManagingAppAuthorizerFunc adapts a function to the interface.

func (SimpleSpaceManagingAppAuthorizerFunc) CheckUserAccess added in v0.11.1

func (f SimpleSpaceManagingAppAuthorizerFunc) CheckUserAccess(ctx context.Context, app, spaceURI, userDID, clientID string) (bool, error)

type SpaceAuthorityKeyResolver added in v0.11.1

type SpaceAuthorityKeyResolver interface {
	ResolveSigningKey(context.Context, space.KeyResolutionRequest) (space.Verifier, error)
}

SpaceAuthorityKeyResolver resolves a Space authority verification key. The request's kid is untrusted until VerifySpaceToken verifies the signature; a resolver must therefore use it only as a key selection hint.

type SpaceAuthorityKeyResolverFunc added in v0.11.1

type SpaceAuthorityKeyResolverFunc func(context.Context, space.KeyResolutionRequest) (space.Verifier, error)

SpaceAuthorityKeyResolverFunc adapts a function to SpaceAuthorityKeyResolver.

func (SpaceAuthorityKeyResolverFunc) ResolveSigningKey added in v0.11.1

type SpaceAuthorityKeySource added in v0.11.1

type SpaceAuthorityKeySource interface {
	ResolveSpaceKey(context.Context, string, string, string) (space.Verifier, error)
}

SpaceAuthorityKeySource is the adapter contract for test/local key lookups. Production uses PassportSpaceAuthorityKeyResolver above.

type SpaceAuthorityKeySourceFunc added in v0.11.1

type SpaceAuthorityKeySourceFunc func(context.Context, string, string, string) (space.Verifier, error)

SpaceAuthorityKeySourceFunc adapts a DID/key lookup function.

func (SpaceAuthorityKeySourceFunc) ResolveSpaceKey added in v0.11.1

func (f SpaceAuthorityKeySourceFunc) ResolveSpaceKey(ctx context.Context, issuer, kid, alg string) (space.Verifier, error)

type SpaceCredentialPrincipal added in v0.11.1

type SpaceCredentialPrincipal struct {
	SpaceURI     string
	AuthorityDID string
	DPoPJKT      string
	Token        string
	Claims       space.SpaceTokenClaims
	TokenClaims  space.SpaceTokenClaims
	Repo         *models.RepoActor
}

SpaceCredentialPrincipal describes a verified, DPoP-bound Space credential.

func (*SpaceCredentialPrincipal) GetAuthorityDID added in v0.11.1

func (p *SpaceCredentialPrincipal) GetAuthorityDID() string

func (*SpaceCredentialPrincipal) GetDPoPJKT added in v0.11.1

func (p *SpaceCredentialPrincipal) GetDPoPJKT() string

func (*SpaceCredentialPrincipal) GetSpaceURI added in v0.11.1

func (p *SpaceCredentialPrincipal) GetSpaceURI() string

func (*SpaceCredentialPrincipal) PrincipalType added in v0.11.1

func (p *SpaceCredentialPrincipal) PrincipalType() PrincipalType

type SpaceNotificationRepoSnapshot added in v0.11.1

type SpaceNotificationRepoSnapshot struct {
	Repo string
	Rev  string
	Hash []byte
	Host string
}

SpaceNotificationRepoSnapshot is the bounded listRepos metadata used by reconciliation. A partial page never causes absent writers to be deleted.

type SpaceNotificationResolver added in v0.11.1

type SpaceNotificationResolver interface {
	Resolve(context.Context, string) (string, error)
}

SpaceNotificationResolver is optional: registration can persist a service identifier without doing network I/O, while hosts that have a resolver may reject an unresolvable service eagerly.

type SpaceNotificationResolverFunc added in v0.11.1

type SpaceNotificationResolverFunc func(context.Context, string) (string, error)

func (SpaceNotificationResolverFunc) Resolve added in v0.11.1

func (f SpaceNotificationResolverFunc) Resolve(ctx context.Context, service string) (string, error)

type SpaceNotificationSender added in v0.11.1

type SpaceNotificationSender interface {
	Send(context.Context, string, models.SpaceNotifyDelivery) error
}

type SpaceNotificationSenderFunc added in v0.11.1

type SpaceNotificationSenderFunc func(context.Context, string, models.SpaceNotifyDelivery) error

func (SpaceNotificationSenderFunc) Send added in v0.11.1

type SpaceNotificationTargetResolver added in v0.11.1

type SpaceNotificationTargetResolver = SpaceNotificationResolver

SpaceNotificationSender is the only network-facing dependency of the durable worker. Send must make the supplied delivery idempotent using its IdempotencyKey; a process crash after Send and before the DB update is safe. Descriptive aliases retain the existing resolver names while making the injection contract discoverable to lifecycle owners.

type SpaceNotificationTargetResolverFunc added in v0.11.1

type SpaceNotificationTargetResolverFunc = SpaceNotificationResolverFunc

type SpaceNotificationWorker added in v0.11.1

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

SpaceNotificationWorker is intentionally pull-based. It starts no goroutine; the lifecycle owner calls RunOnce after commit and on its desired schedule.

func NewSpaceNotificationWorker added in v0.11.1

func NewSpaceNotificationWorker(s *Server, sender SpaceNotificationSender, resolver ...SpaceNotificationResolver) *SpaceNotificationWorker

func NewSpaceNotificationWorkerForDB added in v0.11.1

func NewSpaceNotificationWorkerForDB(database *db.DB, sender SpaceNotificationSender, clock func() time.Time, resolver SpaceNotificationResolver) *SpaceNotificationWorker

func NewSpaceNotificationWorkerWithOptions added in v0.11.1

func NewSpaceNotificationWorkerWithOptions(s *Server, sender SpaceNotificationSender, options SpaceNotificationWorkerOptions, resolver ...SpaceNotificationResolver) *SpaceNotificationWorker

func (*SpaceNotificationWorker) ProcessOnce added in v0.11.1

func (w *SpaceNotificationWorker) ProcessOnce(ctx context.Context, limit int) (int, error)

func (*SpaceNotificationWorker) ReconcileNotifyWriters added in v0.11.1

func (w *SpaceNotificationWorker) ReconcileNotifyWriters(ctx context.Context, spaceRef string, snapshots []SpaceNotificationRepoSnapshot, limit int) (int, error)

func (*SpaceNotificationWorker) ReconcileSpaceWriters added in v0.11.1

func (w *SpaceNotificationWorker) ReconcileSpaceWriters(ctx context.Context, spaceRef string, snapshots []SpaceNotificationRepoSnapshot, limit int) (int, error)

func (*SpaceNotificationWorker) RunOnce added in v0.11.1

func (w *SpaceNotificationWorker) RunOnce(ctx context.Context, limit int) (int, error)

RunOnce selects durable pending/retry rows in ID order. It deliberately does not use a process-local claim: duplicate workers and crash redelivery are handled by the sender's deterministic idempotency key.

func (*SpaceNotificationWorker) SetClock added in v0.11.1

func (w *SpaceNotificationWorker) SetClock(clock func() time.Time)

func (*SpaceNotificationWorker) SetOptions added in v0.11.1

func (*SpaceNotificationWorker) SetResolver added in v0.11.1

func (w *SpaceNotificationWorker) SetResolver(resolver SpaceNotificationResolver)

func (*SpaceNotificationWorker) SetSender added in v0.11.1

func (w *SpaceNotificationWorker) SetSender(sender SpaceNotificationSender)

type SpaceNotificationWorkerOptions added in v0.11.1

type SpaceNotificationWorkerOptions struct {
	BaseDelay         time.Duration
	MaxDelay          time.Duration
	MaxAttempts       int
	BatchSize         int
	DeliveryRetention time.Duration
}

type SpaceRepoAction added in v0.11.1

type SpaceRepoAction struct {
	Type       SpaceRepoOpType
	Collection string
	Rkey       string
}

SpaceRepoAction is the concrete mutation selected after resolving an operation against the current repository state. In particular, a put is reported as create or update, never as put.

type SpaceRepoActionAuthorizer added in v0.11.1

type SpaceRepoActionAuthorizer func(SpaceRepoAction) error

SpaceRepoActionAuthorizer authorizes the concrete action selected inside the serialized Apply transaction. It must return nil to permit the mutation.

type SpaceRepoAllowedActions added in v0.11.1

type SpaceRepoAllowedActions map[SpaceRepoOpType]bool

SpaceRepoAllowedActions is a small authorization contract for callers that already have a set of permitted concrete actions.

func (SpaceRepoAllowedActions) Authorize added in v0.11.1

func (a SpaceRepoAllowedActions) Authorize(action SpaceRepoAction) error

type SpaceRepoBatch added in v0.11.1

type SpaceRepoBatch struct {
	Space   string
	Author  string
	Rev     string
	LtHash  []byte
	Changes []SpaceRepoChange
}

SpaceRepoBatch is the result of one atomic batch. All changes use Rev.

type SpaceRepoChange added in v0.11.1

type SpaceRepoChange struct {
	Type        SpaceRepoOpType
	Collection  string
	Rkey        string
	CID         string
	PreviousCID string
	URI         string
}

SpaceRepoChange describes one operation's resulting CID and prior CID.

type SpaceRepoFailureHook added in v0.11.1

type SpaceRepoFailureHook func(SpaceRepoFailureStage) error

SpaceRepoFailureHook is called inside the transaction at a named stage.

type SpaceRepoFailureStage added in v0.11.1

type SpaceRepoFailureStage string

SpaceRepoFailureStage names points at which tests may force a transaction to fail. The hook is intentionally not used by production code unless a caller installs one explicitly.

type SpaceRepoInsufficientScopeError added in v0.11.1

type SpaceRepoInsufficientScopeError struct {
	Action SpaceRepoAction
}

SpaceRepoInsufficientScopeError identifies a concrete action rejected by an action authorizer. Callers can map it to their protocol's scope response.

func (*SpaceRepoInsufficientScopeError) Error added in v0.11.1

type SpaceRepoMan added in v0.11.1

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

SpaceRepoMan owns permissioned-space repo persistence. It deliberately does not expose XRPC/auth behavior: callers provide the already-authorized author.

func NewSpaceRepoMan added in v0.11.1

func NewSpaceRepoMan(s *Server) *SpaceRepoMan

NewSpaceRepoMan constructs the persistence manager for a server.

func NewSpaceRepoManager added in v0.11.1

func NewSpaceRepoManager(s *Server) *SpaceRepoMan

NewSpaceRepoManager is an alias for callers using the longer name.

func (*SpaceRepoMan) Apply added in v0.11.1

func (m *SpaceRepoMan) Apply(ctx context.Context, spaceRef, author string, operations []SpaceRepoOperation) (SpaceRepoBatch, error)

Apply atomically applies operations to one author's repo in one space.

func (*SpaceRepoMan) ApplyWithAuthorization added in v0.11.1

func (m *SpaceRepoMan) ApplyWithAuthorization(ctx context.Context, spaceRef, author string, operations []SpaceRepoOperation, authorize SpaceRepoActionAuthorizer) (SpaceRepoBatch, error)

ApplyWithAuthorization atomically applies operations and invokes authorize after each operation's concrete create/update/delete action is resolved from current state, while the repository lock and transaction are held.

func (*SpaceRepoMan) ApplyWrites added in v0.11.1

func (m *SpaceRepoMan) ApplyWrites(ctx context.Context, spaceRef, author string, operations []SpaceRepoOperation) (SpaceRepoBatch, error)

ApplyWrites is an alias matching the atproto operation name.

func (*SpaceRepoMan) DeleteRecord added in v0.11.1

func (m *SpaceRepoMan) DeleteRecord(ctx context.Context, spaceRef, author, collection, rkey string) (SpaceRepoBatch, error)

DeleteRecord applies a strict delete. Missing records are errors; an endpoint needing idempotent deletion should check GetRecord before calling this method.

func (*SpaceRepoMan) GetRecord added in v0.11.1

func (m *SpaceRepoMan) GetRecord(ctx context.Context, spaceRef, author, collection, rkey string) (*models.SpaceRecord, error)

GetRecord returns one current record.

func (*SpaceRepoMan) GetRepo added in v0.11.1

func (m *SpaceRepoMan) GetRepo(ctx context.Context, spaceRef, author string) (models.SpaceRepo, error)

GetRepo returns the current head for a space/author pair.

func (*SpaceRepoMan) ListCurrentRecords added in v0.11.1

func (m *SpaceRepoMan) ListCurrentRecords(ctx context.Context, spaceRef, author, cursor string, limit int) ([]models.SpaceRecord, string, error)

ListCurrentRecords is an explicit alias for ListRecords.

func (*SpaceRepoMan) ListOperations added in v0.11.1

func (m *SpaceRepoMan) ListOperations(ctx context.Context, spaceRef, author, cursor string, limit int) ([]models.SpaceRepoOp, string, error)

ListOperations is an alias for ListOps.

func (*SpaceRepoMan) ListOps added in v0.11.1

func (m *SpaceRepoMan) ListOps(ctx context.Context, spaceRef, author, cursor string, limit int) ([]models.SpaceRepoOp, string, error)

ListOps lists the append-only operation log in revision/index order. Cursor is encoded as revision + ":" + decimal index.

func (*SpaceRepoMan) ListRecords added in v0.11.1

func (m *SpaceRepoMan) ListRecords(ctx context.Context, spaceRef, author, cursor string, limit int) ([]models.SpaceRecord, string, error)

ListRecords lists current records in canonical path order. Cursor is the previous collection/rkey path (or empty for the first page).

func (*SpaceRepoMan) PutRecord added in v0.11.1

func (m *SpaceRepoMan) PutRecord(ctx context.Context, spaceRef, author, collection, rkey string, record any) (SpaceRepoBatch, error)

PutRecord applies an upsert operation. A blank rkey generates one when the record does not already exist (a nonblank rkey is always used as supplied).

func (*SpaceRepoMan) PutRecordWithAuthorization added in v0.11.1

func (m *SpaceRepoMan) PutRecordWithAuthorization(ctx context.Context, spaceRef, author, collection, rkey string, record any, authorize SpaceRepoActionAuthorizer) (SpaceRepoBatch, error)

PutRecordWithAuthorization applies an upsert while authorizing its concrete create/update action inside the serialized transaction.

func (*SpaceRepoMan) SetFailureHook added in v0.11.1

func (m *SpaceRepoMan) SetFailureHook(hook SpaceRepoFailureHook) func()

SetFailureHook installs a test-only transaction failure hook and returns a restore function. A nil hook disables injection.

func (*SpaceRepoMan) SetFailureStage added in v0.11.1

func (m *SpaceRepoMan) SetFailureStage(stage SpaceRepoFailureStage) func()

SetFailureStage is a convenience test hook that fails once at stage.

type SpaceRepoOpType added in v0.11.1

type SpaceRepoOpType string

SpaceRepoOpType is the operation applied to one current record.

type SpaceRepoOperation added in v0.11.1

type SpaceRepoOperation struct {
	Type       SpaceRepoOpType
	Collection string
	Rkey       string
	Record     any
}

SpaceRepoOperation is a validated mutation in an Apply batch. Rkey may be empty only for create/put operations; create then receives a generated TID.

type SpaceRepoWrite added in v0.11.1

type SpaceRepoWrite = SpaceRepoOperation

SpaceRepoWrite is a compatibility spelling for SpaceRepoOperation.

type TemplateRenderer

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

func (*TemplateRenderer) Render

func (t *TemplateRenderer) Render(w io.Writer, name string, data any, c echo.Context) error

type ValidationError

type ValidationError struct {
	Field string
	Tag   string
	// contains filtered or unexported fields
}

Source Files

Jump to

Keyboard shortcuts

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