ports

package
v0.0.0-...-ad95247 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DriverPostgres = Driver(dialect.Postgres)
	DriverSQLite   = Driver(dialect.SQLite)
)
View Source
const (
	RegistrationTokenLength = 32
	TokenKeyLength          = 16
)
View Source
const (
	IsAdminClaimName            = "is_admin"
	SessionKeyClaimName         = "idk_enc_key"
	SessionIdentityKeyClaimName = "idk"
)
View Source
const (
	SessionKeySuffixUserIdentity = "identity"
)

Variables

View Source
var ErrKeyEmpty = errors.New("the key may not be empty")
View Source
var ErrNoSuchCipher = errors.New("no such cipher")
View Source
var (
	ErrNoSuchSessionKey = errors.New("no such session key")
)
View Source
var ErrNoSuchStorage = errors.New("no such filesystem")
View Source
var ErrRegistrationExpired = errors.New("registration expired")

Functions

func TryClose

func TryClose(a any) error

Types

type Algorithmer

type Algorithmer interface {
	Algorithm() string
}

type AuthenticationResult

type AuthenticationResult struct {
	User                 domain.User
	IdentityKey          SessionKey
	SessionEncryptionKey []byte
}

func (AuthenticationResult) Session

func (r AuthenticationResult) Session() *Session

type BucketsReadRepository

type BucketsReadRepository interface {
}

type BucketsRepository

type BucketsRepository interface {
	BucketsReadRepository
	BucketsWriteRepository
}

type BucketsWriteRepository

type BucketsWriteRepository interface {
	CreateBucket(ctx context.Context, bucket dto.CreateBucketCommand) (*dto.CreateBucketResponse, error)
}

type Cache

type Cache[T any] interface {
	Get(key string) (*T, error)
	Set(key string, value T) error
}

type CacheDriver

type CacheDriver interface {
	Get(domain, key []byte) ([]byte, error)
	Set(domain, key, value []byte) error
}

type Cipher

type Cipher interface {
	Algorithmer
	KeyLengther
	Seal(plainText, key []byte) (sealed, nonce []byte, err error)
	Open(sealed, key, nonce []byte) (plainText []byte, err error)
}

type CipherTextDecoder

type CipherTextDecoder interface {
	Decode(text []byte) (*CipherTextDecoderResult, error)
}

type CipherTextDecoderResult

type CipherTextDecoderResult struct {
	Salt       []byte
	Nonce      []byte
	CipherText []byte
	Deriver    KeyDeriver
	Cipher     Cipher
}

type CipherTextEncoder

type CipherTextEncoder interface {
	EncodeHash(key, salt []byte, deriver KeyDeriver) []byte
	EncodeCipherText(cipherText, salt, nonce []byte, deriver KeyDeriver, cipher Cipher) []byte
}

type Clock

type Clock interface {
	Now() time.Time
}

type ClockFunc

type ClockFunc func() time.Time

func (ClockFunc) Now

func (f ClockFunc) Now() time.Time

type Driver

type Driver string

func (Driver) String

func (t Driver) String() string

type FileEntriesReadRepository

type FileEntriesReadRepository interface {
	ListFiles(ctx context.Context, query dto.FileEntryListQuery) ([]domain.FileEntry, error)
}

type FileEntriesRepository

type FileEntriesRepository interface {
	FileEntriesReadRepository
	FileEntriesWriteRepository
}

type FileEntriesWriteRepository

type FileEntriesWriteRepository interface {
}

type FileMeta

type FileMeta struct {
	Size        int64
	ContentType string
	// Expires optionally allows you to set an expiration time
	// this will only be used if the filesystem backend supports it
	Expires time.Time
}

type FileSystem

type FileSystem interface {
	Key() string
	OpenRead(ctx context.Context, path string) (io.ReadCloser, error)
	WriteFile(ctx context.Context, cmd WriteFileCommand) error
	Remove(ctx context.Context, path string) error
}

type IdentityOpener

type IdentityOpener interface {
	OpenIdentity(cipherText, key []byte) (*age.X25519Identity, error)
}

type IdentitySealer

type IdentitySealer interface {
	KeyLengther
	SealIdentity(identity *age.X25519Identity, key []byte) ([]byte, error)
}

type KeyDeriver

type KeyDeriver interface {
	encoding.TextMarshaler
	encoding.TextUnmarshaler
	Algorithmer
	GenerateKey(password, existingSalt []byte, keyLength int) (key, salt []byte)
}

type KeyLengther

type KeyLengther interface {
	KeyLength() int
}

type KeySetManager

type KeySetManager interface {
	Set() jwk.Set
	AddKey(kid string) error
	RemoveKey(kid string) error
}

type KeyValidator

type KeyValidator interface {
	Validate(hashed, key []byte, keyLength int) error
}

type MigrationRequest

type MigrationRequest struct {
	Driver Driver
	URL    string
}

type Migrator

type Migrator interface {
	Migrate(ctx context.Context, req MigrationRequest) error
}

type RevisionReadWriter

type RevisionReadWriter interface {
	migrate.RevisionReadWriter
	Client() *ent.Client
}

type Session

type Session struct {
	SessionID             ulid.ULID  `json:"sid"`
	IdentityKey           SessionKey `json:"idk"`
	IdentityEncryptionKey []byte     `json:"idk_enc_key"`
	UserID                uuid.UUID  `json:"sub"`
	Email                 string     `json:"email"`
	GivenName             string     `json:"given_name"`
	Surname               string     `json:"surname"`
	IsAdmin               bool       `json:"is_admin"`
}

type SessionKey

type SessionKey []byte

func NewSessionKey

func NewSessionKey(userId uuid.UUID, suffix string) SessionKey

func (SessionKey) Bytes

func (k SessionKey) Bytes() []byte

func (SessionKey) MarshalJSON

func (k SessionKey) MarshalJSON() ([]byte, error)

func (SessionKey) String

func (k SessionKey) String() string

func (*SessionKey) UnmarshalJSON

func (k *SessionKey) UnmarshalJSON(b []byte) error

type SessionStore

type SessionStore interface {
	Set(ctx context.Context, key SessionKey, value []byte) error
	Get(ctx context.Context, key SessionKey) (value []byte, err error)
}

type SessionTokenBuilder

type SessionTokenBuilder interface {
	Build(session *Session) ([]byte, error)
}

type Storage

type Storage interface {
	StoreFile(cmd StoreFileCommand) (any, error)
}

type StoreFileCommand

type StoreFileCommand struct {
	Reader     io.ReadCloser
	StorageKey string
	Path       string
	Meta       FileMeta
}

type UserAuthenticator

type UserAuthenticator interface {
	AuthenticateWithPassword(ctx context.Context, userMail string, password []byte) (*AuthenticationResult, error)
}

type UserAuthenticatorFunc

type UserAuthenticatorFunc func(ctx context.Context, userMail string, password []byte) (*AuthenticationResult, error)

func (UserAuthenticatorFunc) AuthenticateWithPassword

func (f UserAuthenticatorFunc) AuthenticateWithPassword(ctx context.Context, userMail string, password []byte) (*AuthenticationResult, error)

type UserInvitesReadRepository

type UserInvitesReadRepository interface {
	Redeem(ctx context.Context, inviteID uuid.UUID) (*domain.UserInvite, error)
}

type UserInvitesRepository

type UserInvitesRepository interface {
	UserInvitesReadRepository
	UserInvitesWriteRepository
}

type UserInvitesWriteRepository

type UserInvitesWriteRepository interface {
	CreateInvite(ctx context.Context, invite dto.CreateUserInviteCommand) (*dto.CreateUserInviteResponse, error)
}

type UserReadRepository

type UserReadRepository interface {
	UserByID(ctx context.Context, id uuid.UUID) (*domain.User, error)
	UserByEmail(ctx context.Context, email string) (*domain.User, error)
	AnyUser(ctx context.Context) (bool, error)
}

type UserRegistration

type UserRegistration interface {
	RegisterUser(ctx context.Context, cmd dto.RegisterUserCommand) error
}

type UserRepository

type UserRepository interface {
	UserReadRepository
	UserWriteRepository
}

type UserWriteRepository

type UserWriteRepository interface {
	CreateUser(ctx context.Context, user dto.CreateUserCommand) error
}

type WriteFileCommand

type WriteFileCommand struct {
	Reader      io.ReadCloser
	Size        int64
	Path        string
	ContentType string

	// Expires optionally allows you to set an expiration time
	// this will only be used if the filesystem backend supports it
	Expires time.Time
}

Jump to

Keyboard shortcuts

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