server

package
v0.11.3 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 90 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AccountSessionMaxAge = 30 * 24 * time.Hour // one week
)
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")

Functions

This section is empty.

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

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

	S3Config *S3Config

	SessionSecret    string
	SessionCookieKey string

	BlockstoreVariant BlockstoreVariant
	FallbackProxy     string
}

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,omitempty"`
	EmailConfirmed  *bool   `json:"emailConfirmed,omitempty"`
	EmailAuthFactor *bool   `json:"emailAuthFactor,omitempty"`
	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 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 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) EventSeqRange added in v0.11.3

func (p *DbPersister) EventSeqRange(ctx context.Context) (oldest, newest int64, ok bool, err error)

EventSeqRange reports the oldest and newest seq this host still retains.

The pair describes the only range that can be served: pruning removes whole seqs from the bottom, so a cursor below the oldest retained seq names events that no longer exist. ok is false when the store holds no events at all, which is not the same as an empty range.

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 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 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 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 RepoGcOptions added in v0.11.2

type RepoGcOptions struct {
	// Dids is the set of repos to process.
	Dids []string
	// DryRun reports planned deletions without removing any blocks.
	DryRun bool
	// BlockstoreVariant selects the block store (mirrors the server flag).
	BlockstoreVariant string
	Logger            *slog.Logger
}

RepoGcOptions configures RunRepoGcMigration.

type RepoGcResult added in v0.11.2

type RepoGcResult struct {
	Did           string
	Head          string
	TotalBlocks   int64
	LiveBlocks    int64
	RemovedBlocks int64
	Err           error
}

RepoGcResult is the per-repo outcome of the migration.

func RunRepoGcMigration added in v0.11.2

func RunRepoGcMigration(ctx context.Context, gdb *gorm.DB, opts RepoGcOptions) ([]RepoGcResult, error)

RunRepoGcMigration removes blocks that are unreachable from a repo's current head commit: superseded MST nodes, blocks of deleted or overwritten records, and historical commit objects — the strata accumulated before commits started deleting their removedCids.

For each did it walks the MST at the current root, collecting every reachable block CID (the commit block, all MST nodes, all record blocks), then deletes every other block row for that did.

The repo itself is never mutated: no new commit, no re-signing, no firehose events. It is still safest to run with the PDS stopped (a concurrent write would race this pass), and a VACUUM may be needed afterwards to return SQLite file space to the OS.

type RepoMan

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

func NewRepoMan

func NewRepoMan(s *Server) *RepoMan

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) Serve

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

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 Session

type Session struct {
	AccessToken  string
	RefreshToken string
}

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