Documentation ¶
Index ¶
- Constants
- Variables
- func BodyParser(c *fiber.Ctx, data interface{}) error
- func DecryptAES(key, ciphertext []byte) ([]byte, error)
- func DecryptRSA(privateKey *rsa.PrivateKey, ciphertext []byte) ([]byte, error)
- func EncryptAES(key, plaintext []byte) ([]byte, error)
- func EncryptRSA(publicKey *rsa.PublicKey, message []byte) ([]byte, error)
- func FailedRequest(c *fiber.Ctx, message localization.Translations, err error) error
- func GenerateRSAKey(keySize int) (*rsa.PrivateKey, *rsa.PublicKey, error)
- func GenerateToken(tkLength int32) string
- func GetBoolSetting(node *pipes.LocalNode, name string) (bool, error)
- func GetCurrent(identifier string) (id int64, token string, app uint, domain string)
- func InvalidRequest(c *fiber.Ctx, message string) error
- func NewAESKey() ([]byte, error)
- func PackageRSAPrivateKey(privateKey *rsa.PrivateKey) string
- func PackageRSAPublicKey(publicKey *rsa.PublicKey) string
- func PostRequestBackend(url string, body map[string]interface{}) (map[string]interface{}, error)
- func PostRequestBackendGeneric[T any](url string, body map[string]interface{}) (T, error)
- func PostRequestBackendServer(server string, url string, body map[string]interface{}) (map[string]interface{}, error)
- func PostRequestBackendServerGeneric[T any](server string, url string, body map[string]interface{}) (T, error)
- func PostRequestNoTC(url string, body map[string]interface{}) (map[string]interface{}, error)
- func PostRequestTC(server string, path string, body map[string]interface{}) (map[string]interface{}, error)
- func PostRequestTCGeneric[T any](server string, path string, body map[string]interface{}) (T, error)
- func ReportOffline(node pipes.Node)
- func ReturnJSON(c *fiber.Ctx, data interface{}) error
- func SetOnline(identifier string) map[string]interface{}
- func Setup(identifier string, loadEnv bool) bool
- func SignRSA(privateKey *rsa.PrivateKey, message string) (string, error)
- func SuccessfulRequest(c *fiber.Ctx) error
- func TestAES()
- func Translate(c *fiber.Ctx, message localization.Translations) string
- func UnpackageRSAPrivateKey(priv string) (*rsa.PrivateKey, error)
- func UnpackageRSAPublicKey(pub string) (*rsa.PublicKey, error)
- func VerifyRSASignature(signature string, publicKey *rsa.PublicKey, message string) error
- type NodeData
- type NormalResponse
- type SessionInformation
Constants ¶
const ApiVersion = "v1"
* Important
const AppTagChatNode = "liphium_chat"
App tags for the different node types
const AppTagSpaceNode = "liphium_spaces"
const IdentifierChatNode = "chat"
Identifiers for the different node types
const IdentifierSpaceNode = "space"
const SettingDecentralizationEnabled = "decentralization.enabled"
Predefined settings
const SettingDecentralizationUnsafeAllowed = "decentralization.allow_unsafe"
const StandardKeySize = 2048
const StatusError = 2
const StatusOffline = 1
const StatusOnline = 0
Variables ¶
var BasePath = "http://localhost:3000"
var Domain = "localhost:3000"
var FilePath = ""
var JwtSecret = ""
var NodePrivateKey *rsa.PrivateKey // Private key for current node
* Credentials for this node
var NodePublicKey *rsa.PublicKey // Public key for current node
var Protocol = "http://"
var ServerPublicKey *rsa.PublicKey // Public key from the backend server
var Testing = false
var TestingToken = ""
Functions ¶
func DecryptAES ¶
Decrypt decrypts the given ciphertext using AES-GCM.
func DecryptRSA ¶
func DecryptRSA(privateKey *rsa.PrivateKey, ciphertext []byte) ([]byte, error)
Decrypt a message with a private key. (can't be infinitely long)
func EncryptAES ¶
Encrypt encrypts the given plaintext using AES-GCM.
func EncryptRSA ¶
Encrypt a message with a public key. (can't be infinitely long)
func FailedRequest ¶
func FailedRequest(c *fiber.Ctx, message localization.Translations, err error) error
func GenerateRSAKey ¶
Generate a new RSA key pair.
func GenerateToken ¶
func GetBoolSetting ¶
Get any setting on the backend and parse it
func GetCurrent ¶
func InvalidRequest ¶
func PackageRSAPrivateKey ¶
func PackageRSAPrivateKey(privateKey *rsa.PrivateKey) string
PackageRSAPrivateKey packages a private key into our own format. Packaging order: modulus, public exponent, private exponent, p, q
func PackageRSAPublicKey ¶
PackageRSAPublicKey packages a public key into our own format. Packaging order: modulus, public exponent
func PostRequestBackend ¶
Send a post request (with TC protection encryption)
func PostRequestBackendGeneric ¶
Send a post request (with TC protection encryption)
func PostRequestBackendServer ¶
func PostRequestBackendServer(server string, url string, body map[string]interface{}) (map[string]interface{}, error)
Send a post request (with TC protection encryption)
func PostRequestBackendServerGeneric ¶
func PostRequestBackendServerGeneric[T any](server string, url string, body map[string]interface{}) (T, error)
Send a post request (with TC protection encryption)
func PostRequestNoTC ¶
Send a post request (without TC encryption and custom URL)
func PostRequestTC ¶
func PostRequestTC(server string, path string, body map[string]interface{}) (map[string]interface{}, error)
Send a post request (with TC protection encryption, public key will be cached and retrieved)
func PostRequestTCGeneric ¶
func PostRequestTCGeneric[T any](server string, path string, body map[string]interface{}) (T, error)
Send a post request (with TC protection encryption, public key will be cached and retrieved)
func ReportOffline ¶
func SignRSA ¶
func SignRSA(privateKey *rsa.PrivateKey, message string) (string, error)
Sign a message with a private key.
func SuccessfulRequest ¶
func SuccessfulRequest(c *fiber.Ctx) error
func Translate ¶
func Translate(c *fiber.Ctx, message localization.Translations) string
Translate any message on a request
func UnpackageRSAPrivateKey ¶
func UnpackageRSAPrivateKey(priv string) (*rsa.PrivateKey, error)
Unpackage private key (in our own format that is kinda crappy but who cares)
func UnpackageRSAPublicKey ¶
Unpackage public key (in our own format that is kinda crappy but who cares)
Types ¶
type NormalResponse ¶
type SessionInformation ¶
type SessionInformation struct { Valid bool Account string PermissionLevel uint // contains filtered or unexported fields }
func ValidateSession ¶
func ValidateSession(node *pipes.LocalNode, session string) *SessionInformation
Validate a session with the id (ideally from the JWT token)