server

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2026 License: MIT Imports: 78 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",
	}
)

Functions

This section is empty.

Types

type AccountRevokeInput added in v0.7.2

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

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

	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

	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"`
	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" validate:"required"`
}

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:"string"`
	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 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 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 OauthSigninInput added in v0.7.2

type OauthSigninInput struct {
	Username    string `form:"username"`
	Password    string `form:"password"`
	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 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 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