hyper

package
v0.0.0-...-4de0c4c Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2024 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CookieAtk = "__hydrogen_atk"
	CookieRtk = "__hydrogen_rtk"
)
View Source
const (
	ServiceTypeAuthProvider        = "auth"
	ServiceTypeFileProvider        = "files"
	ServiceTypeInteractiveProvider = "interactive"
	ServiceTypeMessagingProvider   = "messaging"
)

Variables

This section is empty.

Functions

func DecodeAccessPolicy

func DecodeAccessPolicy(raw []byte) map[string]any

func EncodeAccessPolicy

func EncodeAccessPolicy(policy map[string]any) []byte

func LinkAccountMiddleware

func LinkAccountMiddleware[T any](tx *gorm.DB, table string, adaptor func(u BaseUser) T) func(c *fiber.Ctx) error

Types

type BaseModel

type BaseModel struct {
	ID        uint           `json:"id" gorm:"primaryKey"`
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"`
}

type BaseRealm

type BaseRealm struct {
	BaseModel

	Alias        string            `json:"alias"`
	Name         string            `json:"name"`
	Description  string            `json:"description"`
	Avatar       string            `json:"avatar"`
	Banner       string            `json:"banner"`
	IsPublic     bool              `json:"is_public"`
	IsCommunity  bool              `json:"is_community"`
	AccessPolicy datatypes.JSONMap `json:"access_policy"`
}

func LinkRealm

func LinkRealm(tx *gorm.DB, table string, info *proto.RealmInfo) (BaseRealm, error)

LinkRealm will help you build a BaseRealm model from proto.RealmInfo

type BaseUser

type BaseUser struct {
	BaseModel

	Name         string `json:"name"`
	Nick         string `json:"nick"`
	Avatar       string `json:"avatar"`
	Banner       string `json:"banner"`
	Description  string `json:"description"`
	EmailAddress string `json:"email_address"`
	AffiliatedTo *uint  `json:"affiliated_to"`
	AutomatedBy  *uint  `json:"automated_by"`
}

func LinkAccount

func LinkAccount(tx *gorm.DB, table string, userinfo *proto.UserInfo) (BaseUser, error)

LinkAccount will help you build a BaseUser model from proto.UserInfo And also will help you to update the info in your database, so that this function requires a database context

type HyperConn

type HyperConn struct {
	Addr string
	Info *proto.ServiceInfo
	// contains filtered or unexported fields
}

func NewHyperConn

func NewHyperConn(addr string, info *proto.ServiceInfo) (*HyperConn, error)

func (*HyperConn) AuthMiddleware

func (v *HyperConn) AuthMiddleware(c *fiber.Ctx) error

func (*HyperConn) CheckPermGranted

func (v *HyperConn) CheckPermGranted(atk string, key string, val []byte) error

func (*HyperConn) DoAuthenticate

func (v *HyperConn) DoAuthenticate(atk, rtk string) (acc *proto.UserInfo, accessTk string, refreshTk string, err error)

func (*HyperConn) EnsureAuthenticated

func (v *HyperConn) EnsureAuthenticated(c *fiber.Ctx) error

func (*HyperConn) EnsureGrantedPerm

func (v *HyperConn) EnsureGrantedPerm(c *fiber.Ctx, key string, val any) error

func (*HyperConn) GetDealerGrpcConn

func (v *HyperConn) GetDealerGrpcConn() *grpc.ClientConn

func (*HyperConn) GetServiceGrpcConn

func (v *HyperConn) GetServiceGrpcConn(t string) (*grpc.ClientConn, error)

func (*HyperConn) KeepRegisterService

func (v *HyperConn) KeepRegisterService() error

func (*HyperConn) RecordAuditLog

func (v *HyperConn) RecordAuditLog(user uint, action, target, ip, ua string) error

func (*HyperConn) RegisterService

func (v *HyperConn) RegisterService() error

type NetworkPackage

type NetworkPackage struct {
	Action   string `json:"w"`
	Endpoint string `json:"e,omitempty"`
	Message  string `json:"m,omitempty"`
	Payload  any    `json:"p"`
}

func (NetworkPackage) Marshal

func (v NetworkPackage) Marshal() []byte

func (NetworkPackage) RawPayload

func (v NetworkPackage) RawPayload() []byte

Jump to

Keyboard shortcuts

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