Vow, uncensorable PDS written in Go
at main 115 lines 3.2 kB view raw
1package models 2 3import ( 4 "time" 5) 6 7type Repo struct { 8 Did string `gorm:"primaryKey"` 9 CreatedAt time.Time 10 Email string `gorm:"uniqueIndex"` 11 EmailConfirmedAt *time.Time 12 EmailVerificationCode *string 13 EmailVerificationCodeExpiresAt *time.Time 14 EmailUpdateCode *string 15 EmailUpdateCodeExpiresAt *time.Time 16 PasswordResetCode *string 17 PasswordResetCodeExpiresAt *time.Time 18 PlcOperationCode *string 19 PlcOperationCodeExpiresAt *time.Time 20 AccountDeleteCode *string 21 AccountDeleteCodeExpiresAt *time.Time 22 Password string 23 // AuthPublicKey holds the compressed P-256 public key bytes for WebAuthn assertion verification. 24 AuthPublicKey []byte 25 // SigningPublicKey holds the compressed P-256 public key bytes for commit signature verification. 26 SigningPublicKey []byte 27 // CredentialID is the WebAuthn credential ID returned by the authenticator 28 // during registration. It is stored so the server can build the 29 // allowCredentials list when requesting an assertion from the passkey. 30 CredentialID []byte 31 Rev string 32 Root []byte 33 Preferences []byte 34 Deactivated bool 35} 36 37func (r *Repo) Status() *string { 38 var status *string 39 if r.Deactivated { 40 status = new("deactivated") 41 } 42 return status 43} 44 45func (r *Repo) Active() bool { 46 return r.Status() == nil 47} 48 49type Actor struct { 50 Did string `gorm:"primaryKey"` 51 Handle string `gorm:"uniqueIndex"` 52} 53 54type RepoActor struct { 55 Repo 56 Actor 57} 58 59type InviteCode struct { 60 Code string `gorm:"primaryKey"` 61 Did string `gorm:"index"` 62 RemainingUseCount int 63 CreatedAt time.Time 64 Disabled bool `gorm:"default:false"` 65} 66 67type InviteCodeUse struct { 68 ID uint `gorm:"primaryKey"` 69 Code string `gorm:"index"` 70 UsedBy string 71 UsedAt time.Time 72} 73 74type Token struct { 75 Token string `gorm:"primaryKey"` 76 Did string `gorm:"index"` 77 RefreshToken string `gorm:"index"` 78 CreatedAt time.Time 79 ExpiresAt time.Time `gorm:"index:,sort:asc"` 80} 81 82type RefreshToken struct { 83 Token string `gorm:"primaryKey"` 84 Did string `gorm:"index"` 85 CreatedAt time.Time 86 ExpiresAt time.Time `gorm:"index:,sort:asc"` 87} 88 89type Record struct { 90 Did string `gorm:"primaryKey:idx_record_did_created_at;index:idx_record_did_nsid"` 91 CreatedAt string `gorm:"index;index:idx_record_did_created_at,sort:desc"` 92 Nsid string `gorm:"primaryKey;index:idx_record_did_nsid"` 93 Rkey string `gorm:"primaryKey"` 94 Cid string 95 Value []byte 96} 97 98// Blob is a metadata index entry for a user-uploaded blob. The actual blob 99// data lives on IPFS; this row exists so we can list blobs by DID, track 100// reference counts from records, and know which user owns each CID. 101type Blob struct { 102 ID uint 103 CreatedAt string `gorm:"index"` 104 Did string `gorm:"index;index:idx_blob_did_cid"` 105 Cid []byte `gorm:"index;index:idx_blob_did_cid"` 106 RefCount int 107} 108 109type EventRecord struct { 110 Seq int64 `gorm:"primaryKey;autoIncrement:false"` 111 CreatedAt time.Time 112 Did string `gorm:"index"` 113 Type string 114 Data []byte 115}