Something went wrong. Try again.
An atproto PDS written in Go
Something went wrong. Try again.
Go
at oauth-stuff
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139package models
import ( "context" "time"
"github.com/Azure/go-autorest/autorest/to" "github.com/bluesky-social/indigo/atproto/atcrypto")
type TwoFactorType string
var ( TwoFactorTypeNone = TwoFactorType("none") TwoFactorTypeEmail = TwoFactorType("email"))
type Repo struct { Did string `gorm:"primaryKey"` CreatedAt time.Time Email string `gorm:"uniqueIndex"` EmailConfirmedAt *time.Time EmailVerificationCode *string EmailVerificationCodeExpiresAt *time.Time EmailUpdateCode *string EmailUpdateCodeExpiresAt *time.Time PasswordResetCode *string PasswordResetCodeExpiresAt *time.Time PlcOperationCode *string PlcOperationCodeExpiresAt *time.Time AccountDeleteCode *string AccountDeleteCodeExpiresAt *time.Time Password string SigningKey []byte Rev string Root []byte Preferences []byte Deactivated bool TwoFactorCode *string TwoFactorCodeExpiresAt *time.Time TwoFactorType TwoFactorType `gorm:"default:none"`}
func (r *Repo) SignFor(ctx context.Context, did string, msg []byte) ([]byte, error) { k, err := atcrypto.ParsePrivateBytesK256(r.SigningKey) if err != nil { return nil, err }
sig, err := k.HashAndSign(msg) if err != nil { return nil, err }
return sig, nil}
func (r *Repo) Status() *string { var status *string if r.Deactivated { status = to.StringPtr("deactivated") } return status}
func (r *Repo) Active() bool { return r.Status() == nil}
type Actor struct { Did string `gorm:"primaryKey"` Handle string `gorm:"uniqueIndex"`}
type RepoActor struct { Repo Actor}
type InviteCode struct { Code string `gorm:"primaryKey"` Did string `gorm:"index"` RemainingUseCount int}
type Token struct { Token string `gorm:"primaryKey"` Did string `gorm:"index"` RefreshToken string `gorm:"index"` CreatedAt time.Time ExpiresAt time.Time `gorm:"index:,sort:asc"`}
type RefreshToken struct { Token string `gorm:"primaryKey"` Did string `gorm:"index"` CreatedAt time.Time ExpiresAt time.Time `gorm:"index:,sort:asc"`}
type Record struct { Did string `gorm:"primaryKey:idx_record_did_created_at;index:idx_record_did_nsid"` CreatedAt string `gorm:"index;index:idx_record_did_created_at,sort:desc"` Nsid string `gorm:"primaryKey;index:idx_record_did_nsid"` Rkey string `gorm:"primaryKey"` Cid string Value []byte}
type Block struct { Did string `gorm:"primaryKey;index:idx_blocks_by_rev"` Cid []byte `gorm:"primaryKey"` Rev string `gorm:"index:idx_blocks_by_rev,sort:desc"` Value []byte}
type Blob struct { ID uint CreatedAt string `gorm:"index"` Did string `gorm:"index;index:idx_blob_did_cid"` Cid []byte `gorm:"index;index:idx_blob_did_cid"` RefCount int Storage string `gorm:"default:sqlite"`}
type BlobPart struct { Blob Blob BlobID uint `gorm:"primaryKey"` Idx int `gorm:"primaryKey"` Data []byte}
type ReservedKey struct { KeyDid string `gorm:"primaryKey"` Did *string `gorm:"index"` PrivateKey []byte CreatedAt time.Time `gorm:"index"`}