models

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2026 License: AGPL-3.0 Imports: 1 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	PermissionLevelMember = 0
	PermissionLevelMod    = 1
	PermissionLevelAdmin  = 2
	PermissionLevelOwner  = 3
)

Permission level constants for server_members.permission_level. Human-readable role labels are stored encrypted in MLS group state.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attachment

type Attachment struct {
	ID          string     `json:"id"`
	ChannelID   string     `json:"channelId"`
	OwnerID     string     `json:"ownerId"`
	StorageKey  string     `json:"-"`
	Size        int64      `json:"size"`
	ContentType string     `json:"contentType"`
	CreatedAt   time.Time  `json:"createdAt"`
	DeletedAt   *time.Time `json:"deletedAt,omitempty"`
}

Attachment is a single client-side-encrypted blob uploaded to the configured storage backend. The encryption key + IV travel inside the MLS message envelope (`AttachmentRef.key`, `AttachmentRef.iv`) and never reach the server. ContentType is advisory; the bytes are opaque.

type AuditLogEntry

type AuditLogEntry struct {
	ID        string                 `json:"id"`
	ServerID  *string                `json:"serverId,omitempty"`
	ActorID   string                 `json:"actorId"`
	TargetID  *string                `json:"targetId,omitempty"`
	Action    string                 `json:"action"`
	Reason    string                 `json:"reason"`
	Metadata  map[string]interface{} `json:"metadata,omitempty"`
	CreatedAt time.Time              `json:"createdAt"`
}

AuditLogEntry records a single moderation action.

type AuthNonce

type AuthNonce struct {
	Nonce         string    `json:"-"`
	UserPublicKey []byte    `json:"-"`
	ExpiresAt     time.Time `json:"-"`
}

AuthNonce is a stored challenge nonce pending signature verification.

type AuthResponse

type AuthResponse struct {
	Token string `json:"token"`
	User  User   `json:"user"`
}

AuthResponse is returned by register and login (token + user).

type Ban

type Ban struct {
	ID        string     `json:"id"`
	ServerID  *string    `json:"serverId,omitempty"`
	UserID    string     `json:"userId"`
	ActorID   string     `json:"actorId"`
	Reason    string     `json:"reason"`
	ExpiresAt *time.Time `json:"expiresAt,omitempty"`
	CreatedAt time.Time  `json:"createdAt"`
	LiftedAt  *time.Time `json:"liftedAt,omitempty"`
	LiftedBy  *string    `json:"liftedBy,omitempty"`
}

Ban represents an active or historical ban record.

type BanRequest

type BanRequest struct {
	UserID    string `json:"userId"`
	Reason    string `json:"reason"`
	ExpiresIn *int   `json:"expiresIn,omitempty"` // seconds; nil = permanent
}

BanRequest is the body for POST /api/moderation/ban.

type ChallengeRequest

type ChallengeRequest struct {
	PublicKey string `json:"publicKey"` // base64-encoded Ed25519 public key
}

ChallengeRequest is the body for POST /api/auth/challenge. The server returns a short-lived nonce that the client must sign.

type ChangePermissionLevelRequest

type ChangePermissionLevelRequest struct {
	UserID          string `json:"userId"`
	PermissionLevel int    `json:"permissionLevel"`
	Reason          string `json:"reason"`
}

ChangePermissionLevelRequest is the body for PUT /api/servers/:id/members/:userId/level. Replaces the old ChangeRoleRequest - role string is now an opaque integer.

type Channel

type Channel struct {
	ID                string  `json:"id"`
	ServerID          *string `json:"serverId,omitempty"`
	EncryptedMetadata []byte  `json:"encryptedMetadata,omitempty"`
	Type              string  `json:"type"`
	ParentID          *string `json:"parentId,omitempty"`
	Position          int     `json:"position"`
}

Channel is a text or voice channel within a guild. Name is removed - it lives in EncryptedMetadata. Type stays plaintext for routing.

type CreateChannelRequest

type CreateChannelRequest struct {
	EncryptedMetadata []byte  `json:"encryptedMetadata,omitempty"`
	Name              string  `json:"name,omitempty"`
	Type              string  `json:"type"`
	ParentID          *string `json:"parentId,omitempty"`
	Position          *int    `json:"position,omitempty"`
}

CreateChannelRequest is the body for POST /api/channels. Clients should send EncryptedMetadata (MLS-encrypted blob). When MLS is not yet bootstrapped, the plaintext Name fallback is accepted and stored as a JSON metadata blob so the channel is still usable.

type CreateDMRequest

type CreateDMRequest struct {
	OtherUserID string `json:"otherUserId"`
}

CreateDMRequest is the body for POST /api/guilds/dm.

type CreateInviteRequest

type CreateInviteRequest struct {
	MaxUses   *int `json:"maxUses,omitempty"`
	ExpiresIn *int `json:"expiresIn,omitempty"` // seconds
}

CreateInviteRequest is the body for POST /api/invites.

type CreateServerRequest

type CreateServerRequest struct {
	EncryptedMetadata []byte  `json:"encryptedMetadata,omitempty"`
	Name              string  `json:"name,omitempty"`
	TemplateID        *string `json:"templateId,omitempty"`
}

CreateServerRequest is the body for POST /api/servers. EncryptedMetadata may be nil on creation if the client has not yet set up the guild metadata MLS group (two-step creation flow).

type DMResponse

type DMResponse struct {
	Server    Server                 `json:"server"`
	OtherUser UserSearchPublicResult `json:"otherUser"`
	ChannelID string                 `json:"channelId"`
}

DMResponse is returned by POST /api/guilds/dm. Wraps the DM guild server with the other participant's identity.

type DeviceKey

type DeviceKey struct {
	ID              string     `json:"id"`
	UserID          string     `json:"userId"`
	DeviceID        string     `json:"deviceId"`
	DevicePublicKey []byte     `json:"-"` // never sent in JSON responses
	Certificate     []byte     `json:"-"` // root-key signature over DevicePublicKey; nil for first device
	CertifiedAt     time.Time  `json:"certifiedAt"`
	LastSeen        *time.Time `json:"lastSeen,omitempty"`
	Label           *string    `json:"label,omitempty"`
}

DeviceKey records a certified public key for a user's device. The first device (registered with root key) has a nil Certificate. Subsequent devices must carry a Certificate = Sign(root_priv, device_pub).

type DiscoverGuild

type DiscoverGuild struct {
	ID                string    `json:"id"`
	PublicName        string    `json:"publicName"`
	PublicDescription string    `json:"publicDescription"`
	Category          string    `json:"category"`
	AccessPolicy      string    `json:"accessPolicy"`
	MemberCount       int       `json:"memberCount"`
	CreatedAt         time.Time `json:"createdAt"`
}

DiscoverGuild is one card in the GET /api/guilds/discover response. Only fields that discoverable guild admins have opted to expose are included.

type DmChannelSummary

type DmChannelSummary struct {
	ID          string `json:"id"`
	UnreadCount int    `json:"unreadCount"`
}

DmChannelSummary is a minimal channel representation for DM guild list responses. UnreadCount is the caller's unread message count for this channel.

type FederatedIdentity

type FederatedIdentity struct {
	ID           string    `json:"id"`
	PublicKey    []byte    `json:"-"`
	HomeInstance string    `json:"homeInstance"`
	Username     string    `json:"username"`
	DisplayName  string    `json:"displayName"`
	CachedAt     time.Time `json:"cachedAt"`
}

FederatedIdentity represents a user from a foreign Hush instance, identified by their Ed25519 public key and home instance URL.

type FederatedVerifyRequest

type FederatedVerifyRequest struct {
	PublicKey    string `json:"publicKey"`    // base64-encoded Ed25519 public key
	Nonce        string `json:"nonce"`        // hex nonce from /challenge response
	Signature    string `json:"signature"`    // base64-encoded Ed25519 signature over nonce bytes
	HomeInstance string `json:"homeInstance"` // URL of the user's home instance
	Username     string `json:"username"`     // username on the home instance
	DisplayName  string `json:"displayName"`  // display name on the home instance
}

FederatedVerifyRequest is the body for POST /api/auth/federated-verify. Used when a user from a foreign instance authenticates on this instance.

type GuestAuthResponse

type GuestAuthResponse struct {
	Token     string    `json:"token"`
	GuestID   string    `json:"guestId"`
	ExpiresAt time.Time `json:"expiresAt"`
}

GuestAuthResponse is returned by POST /api/auth/guest. The guest session is ephemeral - no user record is persisted. The client uses ExpiresAt to schedule the 5-minute warning and expiry redirect.

type GuildBillingStats

type GuildBillingStats struct {
	ID                string     `json:"id"`
	MemberCount       int        `json:"memberCount"`
	StorageBytes      int64      `json:"storageBytes"`
	MessageCount      int64      `json:"messageCount"`
	ActiveMembers30d  int        `json:"activeMembers30d"`
	LastActiveAt      *time.Time `json:"lastActiveAt,omitempty"`
	CreatedAt         time.Time  `json:"createdAt"`
	MemberCapOverride *int       `json:"memberCapOverride,omitempty"`
}

GuildBillingStats exposes guild infrastructure metrics to the instance operator. No guild name, channel list, or member details - privacy boundary is preserved.

type InstanceAdmin

type InstanceAdmin struct {
	ID           string     `json:"id"`
	Username     string     `json:"username"`
	Email        *string    `json:"email,omitempty"`
	PasswordHash string     `json:"-"`
	Role         string     `json:"role"`
	IsActive     bool       `json:"isActive"`
	LastLoginAt  *time.Time `json:"lastLoginAt,omitempty"`
	CreatedAt    time.Time  `json:"createdAt"`
	UpdatedAt    time.Time  `json:"updatedAt"`
}

InstanceAdmin is a local instance-operator account for the admin dashboard. It is separate from Hush users and cannot be used for end-user authentication.

type InstanceAdminSession

type InstanceAdminSession struct {
	ID         string     `json:"id"`
	AdminID    string     `json:"adminId"`
	TokenHash  string     `json:"-"`
	ExpiresAt  time.Time  `json:"expiresAt"`
	LastSeenAt *time.Time `json:"lastSeenAt,omitempty"`
	CreatedIP  *string    `json:"createdIp,omitempty"`
	UserAgent  *string    `json:"userAgent,omitempty"`
	CreatedAt  time.Time  `json:"createdAt"`
	RevokedAt  *time.Time `json:"revokedAt,omitempty"`
}

InstanceAdminSession is a persisted dashboard session for an instance admin. Only the opaque cookie token hash is stored server-side.

type InstanceAuditLogEntry

type InstanceAuditLogEntry struct {
	ID        string                 `json:"id"`
	ActorID   string                 `json:"actorId"`
	TargetID  *string                `json:"targetId,omitempty"`
	Action    string                 `json:"action"`
	Reason    string                 `json:"reason"`
	Metadata  map[string]interface{} `json:"metadata,omitempty"`
	CreatedAt time.Time              `json:"createdAt"`
}

InstanceAuditLogEntry records an instance-level admin action.

type InstanceBan

type InstanceBan struct {
	ID        string     `json:"id"`
	UserID    string     `json:"userId"`
	ActorID   string     `json:"actorId"`
	Reason    string     `json:"reason"`
	ExpiresAt *time.Time `json:"expiresAt,omitempty"`
	CreatedAt time.Time  `json:"createdAt"`
	LiftedAt  *time.Time `json:"liftedAt,omitempty"`
	LiftedBy  *string    `json:"liftedBy,omitempty"`
}

InstanceBan is an instance-level ban record (separate from guild bans).

type InstanceBanRequest

type InstanceBanRequest struct {
	UserID    string `json:"userId"`
	Reason    string `json:"reason"`
	ExpiresIn *int   `json:"expiresIn,omitempty"` // seconds; nil = permanent
}

InstanceBanRequest is the body for POST /api/instance/bans.

type InstanceConfig

type InstanceConfig struct {
	ID                             string    `json:"id"`
	Name                           string    `json:"name"`
	IconURL                        *string   `json:"iconUrl"`
	RegistrationMode               string    `json:"registrationMode"`
	GuildDiscovery                 string    `json:"guildDiscovery"`
	ServerCreationPolicy           string    `json:"serverCreationPolicy"`
	MaxServersPerUser              *int      `json:"maxServersPerUser,omitempty"`
	MaxMembersPerServer            *int      `json:"maxMembersPerServer,omitempty"`
	MaxRegisteredUsers             *int      `json:"maxRegisteredUsers,omitempty"`
	ScreenShareResolutionCap       string    `json:"screenShareResolutionCap"`
	MaxAttachmentBytes             int64     `json:"maxAttachmentBytes"`
	MaxGuildAttachmentStorageBytes *int64    `json:"maxGuildAttachmentStorageBytes,omitempty"`
	MessageRetentionDays           int       `json:"messageRetentionDays"`
	CreatedAt                      time.Time `json:"createdAt"`
}

InstanceConfig is the single-row table that describes this Hush instance. OwnerID is removed: instance ownership is API key auth. ServerCreationPolicy controls whether authenticated users may create guilds.

type InstanceServiceIdentity

type InstanceServiceIdentity struct {
	ID                 string    `json:"id"`
	Username           string    `json:"username"`
	PublicKey          []byte    `json:"-"`
	WrappedPrivateKey  []byte    `json:"-"`
	WrappingKeyVersion string    `json:"wrappingKeyVersion"`
	CreatedAt          time.Time `json:"createdAt"`
	UpdatedAt          time.Time `json:"updatedAt"`
}

InstanceServiceIdentity stores the instance-scoped technical Hush identity. It is a non-human account and must never be used for dashboard login.

type InstanceUnbanRequest

type InstanceUnbanRequest struct {
	UserID string `json:"userId"`
	Reason string `json:"reason"`
}

InstanceUnbanRequest is the body for POST /api/instance/unban.

type InviteCode

type InviteCode struct {
	Code      string    `json:"code"`
	ServerID  *string   `json:"serverId,omitempty"`
	CreatedBy string    `json:"createdBy"`
	ExpiresAt time.Time `json:"expiresAt"`
	MaxUses   int       `json:"maxUses"`
	Uses      int       `json:"uses"`
}

InviteCode is an invite link token for the instance or a specific guild.

type KickRequest

type KickRequest struct {
	UserID string `json:"userId"`
	Reason string `json:"reason"`
}

KickRequest is the body for POST /api/moderation/kick.

type Member

type Member struct {
	ID          string    `json:"id"`
	Username    string    `json:"username"`
	DisplayName string    `json:"displayName"`
	Role        string    `json:"role"`
	CreatedAt   time.Time `json:"createdAt"`
}

Member is a user with their instance role, used for member list responses.

type MerkleInclusionProof

type MerkleInclusionProof struct {
	LeafIndex uint64   `json:"leafIndex"`
	TreeSize  uint64   `json:"treeSize"`
	AuditPath [][]byte `json:"-"` // raw binary; use AuditPathHex for JSON
	RootHash  []byte   `json:"-"` // raw binary; use RootHashHex for JSON
	LogSig    []byte   `json:"-"` // raw binary; use LogSignatureB64 for JSON

	// Wire-format fields populated by the API handler (never stored).
	AuditPathHex    []string `json:"auditPath,omitempty"`    // hex-encoded sibling hashes
	RootHashHex     string   `json:"rootHash,omitempty"`     // hex-encoded root
	LogSignatureB64 string   `json:"logSignature,omitempty"` // base64-encoded log signature
}

MerkleInclusionProof is returned by the transparency verify API endpoint. Clients use WebCrypto SHA-256 to recompute the root from the audit path.

Binary fields are excluded from JSON (json:"-"); their wire representations use explicit encoding:

  • AuditPathHex: each 32-byte sibling hash as a lowercase hex string.
  • RootHashHex: 32-byte root as a lowercase hex string.
  • LogSignatureB64: 64-byte Ed25519 signature as standard base64.

Hex is used for AuditPath and RootHash because the client's verifyInclusion() function passes sibling hashes to hexToBytes() and compares the recomputed root with bytesToHex(). Base64 is used for LogSignature because base64ToBytes() is called on it. These encodings must match the client's transparencyVerifier.js.

type Message

type Message struct {
	ID                string    `json:"id"`
	ChannelID         string    `json:"channelId"`
	SenderID          *string   `json:"senderId,omitempty"`
	FederatedSenderID *string   `json:"federatedSenderId,omitempty"`
	RecipientID       *string   `json:"recipientId,omitempty"`
	Ciphertext        []byte    `json:"ciphertext"` // base64-encoded in JSON
	Timestamp         time.Time `json:"timestamp"`
}

Message is a stored encrypted message. Ciphertext is opaque to the server. RecipientID is nil for broadcast/single-ciphertext; set for fan-out per recipient. Exactly one of SenderID or FederatedSenderID must be non-nil.

type MoveChannelRequest

type MoveChannelRequest struct {
	ParentID *string `json:"parentId"`
	Position int     `json:"position"`
}

MoveChannelRequest is the body for PUT /api/channels/:id/move.

type Mute

type Mute struct {
	ID        string     `json:"id"`
	ServerID  *string    `json:"serverId,omitempty"`
	UserID    string     `json:"userId"`
	ActorID   string     `json:"actorId"`
	Reason    string     `json:"reason"`
	ExpiresAt *time.Time `json:"expiresAt,omitempty"`
	CreatedAt time.Time  `json:"createdAt"`
	LiftedAt  *time.Time `json:"liftedAt,omitempty"`
	LiftedBy  *string    `json:"liftedBy,omitempty"`
}

Mute represents an active or historical mute record (text AND voice).

type MuteRequest

type MuteRequest struct {
	UserID    string `json:"userId"`
	Reason    string `json:"reason"`
	ExpiresIn *int   `json:"expiresIn,omitempty"` // seconds; nil = permanent
}

MuteRequest is the body for POST /api/moderation/mute.

type OneTimePreKeyRow

type OneTimePreKeyRow struct {
	KeyID     int    `json:"keyId"`
	PublicKey []byte `json:"publicKey"`
}

OneTimePreKeyRow is one entry in a batch of one-time pre-keys for upload.

type PreKeyBundle

type PreKeyBundle struct {
	IdentityKey           []byte `json:"identityKey"`
	SignedPreKey          []byte `json:"signedPreKey"`
	SignedPreKeySignature []byte `json:"signedPreKeySignature"`
	SignedPreKeyID        int    `json:"signedPreKeyId"`
	RegistrationID        int    `json:"registrationId"`
	OneTimePreKeyID       *int   `json:"oneTimePreKeyId,omitempty"`
	OneTimePreKey         []byte `json:"oneTimePreKey,omitempty"`
}

PreKeyBundle is returned by GET /api/keys/:userId and GET /api/keys/:userId/:deviceId.

type PreKeyUploadRequest

type PreKeyUploadRequest struct {
	DeviceID              string             `json:"deviceId"`
	IdentityKey           []byte             `json:"identityKey"`
	SignedPreKey          []byte             `json:"signedPreKey"`
	SignedPreKeySignature []byte             `json:"signedPreKeySignature"`
	RegistrationID        int                `json:"registrationId"`
	OneTimePreKeys        []OneTimePreKeyRow `json:"oneTimePreKeys"`
}

PreKeyUploadRequest is the body for POST /api/keys/upload.

type RegisterRequest

type RegisterRequest struct {
	Username    string `json:"username"`
	DisplayName string `json:"displayName"`
	PublicKey   string `json:"publicKey"`  // base64-encoded Ed25519 public key
	DeviceID    string `json:"deviceId"`   // optional; generated server-side if empty
	Label       string `json:"label"`      // optional human-readable device name
	InviteCode  string `json:"inviteCode"` // required when registrationMode == "invite_only"
}

RegisterRequest is the body for POST /api/auth/register. PublicKey is the base64-encoded Ed25519 root public key derived from the user's BIP39 mnemonic. No password field - identity is cryptographic.

type Server

type Server struct {
	ID                  string     `json:"id"`
	EncryptedMetadata   []byte     `json:"encryptedMetadata,omitempty"`
	MemberCount         int        `json:"memberCount"`
	TextChannelCount    int        `json:"textChannelCount"`
	VoiceChannelCount   int        `json:"voiceChannelCount"`
	StorageBytes        int64      `json:"storageBytes"`
	MessageCount        int64      `json:"messageCount"`
	ActiveMembers30d    int        `json:"activeMembers30d"`
	LastActiveAt        *time.Time `json:"lastActiveAt,omitempty"`
	AccessPolicy        string     `json:"accessPolicy"`
	Discoverable        bool       `json:"discoverable"`
	AdminLabelEncrypted []byte     `json:"adminLabelEncrypted,omitempty"`
	CreatedAt           time.Time  `json:"createdAt"`
	// DM and discovery fields (migration 000021).
	MemberCapOverride *int    `json:"memberCapOverride,omitempty"`
	IsDm              bool    `json:"isDm"`
	Category          *string `json:"category,omitempty"`
	PublicName        *string `json:"publicName,omitempty"`
	PublicDescription *string `json:"publicDescription,omitempty"`
	// Populated only for DM guilds (IsDm=true). Nil for regular guilds.
	OtherUser *UserSearchPublicResult `json:"otherUser,omitempty"`
	ChannelID *string                 `json:"channelId,omitempty"`
	// Channels is populated for DM guilds only with the single DM channel summary.
	Channels []DmChannelSummary `json:"channels,omitempty"`
}

Server is a guild within this Hush instance. All plaintext name/icon/owner fields are removed - the backend is a blind relay. Exception: PublicName and PublicDescription are plaintext when Discoverable=true - guild admins explicitly opt in to this exposure by enabling discoverability.

type ServerMember

type ServerMember struct {
	ID                  string    `json:"id"`
	ServerID            string    `json:"serverId"`
	UserID              *string   `json:"userId,omitempty"`
	FederatedIdentityID *string   `json:"federatedIdentityId,omitempty"`
	PermissionLevel     int       `json:"permissionLevel"`
	JoinedAt            time.Time `json:"joinedAt"`
}

ServerMember records a user's (or federated identity's) membership and integer permission level within a guild. Exactly one of UserID or FederatedIdentityID must be non-nil.

type ServerMemberWithUser

type ServerMemberWithUser struct {
	ID              string    `json:"id"`
	Username        string    `json:"username"`
	DisplayName     string    `json:"displayName"`
	CreatedAt       time.Time `json:"createdAt"`
	PermissionLevel int       `json:"permissionLevel"`
	JoinedAt        time.Time `json:"joinedAt"`
	HomeInstance    *string   `json:"homeInstance,omitempty"` // nil = local, set = federated
}

ServerMemberWithUser combines user fields with guild membership info for member-list responses. HomeInstance is nil for local users and set to the home instance URL for federated users.

type ServerTemplate

type ServerTemplate struct {
	ID        string            `json:"id"`
	Name      string            `json:"name"`
	Channels  []TemplateChannel `json:"channels"`
	IsDefault bool              `json:"isDefault"`
	Position  int               `json:"position"`
	CreatedAt time.Time         `json:"createdAt"`
	UpdatedAt time.Time         `json:"updatedAt"`
}

ServerTemplate is a named, reusable channel template for guild creation.

type Session

type Session struct {
	ID        string    `json:"-"`
	UserID    string    `json:"-"`
	TokenHash string    `json:"-"`
	ExpiresAt time.Time `json:"-"`
}

Session is a stored session (token_hash, expires_at). ID is the session UUID.

type SystemMessage

type SystemMessage struct {
	ID        string                 `json:"id"`
	ServerID  string                 `json:"serverId"`
	EventType string                 `json:"eventType"`
	ActorID   string                 `json:"actorId"`
	TargetID  *string                `json:"targetId,omitempty"`
	Reason    string                 `json:"reason"`
	Metadata  map[string]interface{} `json:"metadata,omitempty"`
	CreatedAt time.Time              `json:"createdAt"`
}

SystemMessage is an event log entry in a guild's #system channel.

type TemplateChannel

type TemplateChannel struct {
	Name string `json:"name"`
	Type string `json:"type"`

	ParentRef *string `json:"parentRef,omitempty"`
	Position  int     `json:"position"`
}

TemplateChannel describes a single channel in a server creation template.

type TransparencyLogEntry

type TransparencyLogEntry struct {
	ID         int64     `json:"id"`
	LeafIndex  uint64    `json:"leafIndex"`
	Operation  string    `json:"operation"`
	UserPubKey []byte    `json:"-"`
	SubjectKey []byte    `json:"-"`
	EntryCBOR  []byte    `json:"-"`
	LeafHash   []byte    `json:"-"`
	UserSig    []byte    `json:"-"`
	LogSig     []byte    `json:"-"`
	LoggedAt   time.Time `json:"loggedAt"`

	// Wire-format fields populated by the API handler (never stored).
	// EntryCBORB64 is standard base64 (RFC 4648) for client WebCrypto use.
	// LeafHashHex and LogSigB64 are hex and base64 respectively for display/verify.
	EntryCBORB64  string `json:"entryCbor,omitempty"`
	LeafHashHex   string `json:"leafHash,omitempty"`
	LogSigB64     string `json:"logSig,omitempty"`
	UserPubKeyHex string `json:"userPubKey,omitempty"`
}

TransparencyLogEntry mirrors one row from the transparency_log_entries table. It is returned by GetTransparencyLogEntriesByPubKey for proof generation.

Binary fields (EntryCBOR, LeafHash, LogSig) are excluded from JSON via json:"-". Their wire representations are the base64-encoded string fields (EntryCBORB64, LeafHashHex, LogSigB64) which are populated by the API handler before writing the response. This makes the encoding contract explicit and avoids surprises from Go's implicit base64 marshaling of []byte.

type TransparencyTreeHead

type TransparencyTreeHead struct {
	TreeSize  uint64    `json:"treeSize"`
	RootHash  []byte    `json:"rootHash"`
	Fringe    []byte    `json:"-"` // serialized [][32]byte - not sent to clients
	HeadSig   []byte    `json:"headSig"`
	CreatedAt time.Time `json:"createdAt"`
}

TransparencyTreeHead mirrors one row from the transparency_tree_heads table. The most recent row is loaded on startup to reconstruct the Merkle tree fringe.

type UnbanRequest

type UnbanRequest struct {
	UserID string `json:"userId"`
	Reason string `json:"reason"`
}

UnbanRequest is the body for POST /api/moderation/unban.

type UnmuteRequest

type UnmuteRequest struct {
	UserID string `json:"userId"`
	Reason string `json:"reason"`
}

UnmuteRequest is the body for POST /api/moderation/unmute.

type UpdateInstanceRequest

type UpdateInstanceRequest struct {
	Name             *string `json:"name,omitempty"`
	IconURL          *string `json:"iconUrl,omitempty"`
	RegistrationMode *string `json:"registrationMode,omitempty"`
	GuildDiscovery   *string `json:"guildDiscovery,omitempty"`
}

UpdateInstanceRequest is the body for PATCH /api/instance. ServerCreationPolicy removed; GuildDiscovery added.

type User

type User struct {
	ID            string    `json:"id"`
	Username      string    `json:"username"`
	RootPublicKey []byte    `json:"-"`
	DisplayName   string    `json:"displayName"`
	Role          string    `json:"role"`
	CreatedAt     time.Time `json:"createdAt"`
}

User is the domain user. RootPublicKey is the Ed25519 root public key derived from the user's BIP39 mnemonic; never included in JSON responses.

type UserSearchPublicResult

type UserSearchPublicResult struct {
	ID          string `json:"id"`
	Username    string `json:"username"`
	DisplayName string `json:"displayName"`
}

UserSearchPublicResult is a user record safe for public search endpoints. Contains only identity fields - no ban status, roles, or credentials.

type UserSearchResult

type UserSearchResult struct {
	ID           string     `json:"id"`
	Username     string     `json:"username"`
	DisplayName  string     `json:"displayName"`
	Role         string     `json:"role"`
	CreatedAt    time.Time  `json:"createdAt"`
	IsBanned     bool       `json:"isBanned"`
	BanReason    *string    `json:"banReason,omitempty"`
	BanExpiresAt *time.Time `json:"banExpiresAt,omitempty"`
}

UserSearchResult is returned by the admin user search endpoint.

type VerifyRequest

type VerifyRequest struct {
	PublicKey        string `json:"publicKey"`                  // base64-encoded Ed25519 public key
	Nonce            string `json:"nonce"`                      // hex nonce from /challenge response
	Signature        string `json:"signature"`                  // base64-encoded Ed25519 signature
	DeviceID         string `json:"deviceId"`                   // stable per-device identifier (UUID)
	Label            string `json:"label,omitempty"`            // client-reported human-readable device label
	ChallengeVersion int    `json:"challengeVersion,omitempty"` // 2 = audience-bound payload; 0 = legacy nonce
	Audience         string `json:"audience,omitempty"`         // canonical API origin the client signed for
}

VerifyRequest is the body for POST /api/auth/verify. The client signs the nonce received from /challenge and submits it here.

Two challenge protocol versions are supported:

  • v1 (legacy): ChallengeVersion is zero AND Audience is empty. Signature is an Ed25519 signature over the raw nonce bytes. This form is vulnerable to a cross-instance signing oracle: an attacker server can relay a victim's home-instance nonce to the victim and receive a signature it can redeem on the home instance. Retained only for old clients that have not yet upgraded.

  • v2: ChallengeVersion == 2 AND/OR Audience is non-empty. Signature is an Ed25519 signature over auth.BuildChallengeV2Payload(Nonce, Audience). The server MUST refuse v2 requests whose declared Audience does not match the server's canonical public API origin, and MUST NOT fall back to v1 verification for v2 requests.

Jump to

Keyboard shortcuts

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