integration

package
v0.0.0-...-347cd60 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2024 License: Apache-2.0 Imports: 26 Imported by: 17

Documentation

Index

Constants

View Source
const ApiVersion = "v1"

* Important

View Source
const AppTagChatNode = "liphium_chat"

App tags for the different node types

View Source
const AppTagSpaceNode = "liphium_spaces"
View Source
const IdentifierChatNode = "chat"

Identifiers for the different node types

View Source
const IdentifierSpaceNode = "space"
View Source
const SettingDecentralizationEnabled = "decentralization.enabled"

Predefined settings

View Source
const SettingDecentralizationUnsafeAllowed = "decentralization.allow_unsafe"
View Source
const StandardKeySize = 2048
View Source
const StatusError = 2
View Source
const StatusOffline = 1
View Source
const StatusOnline = 0

Variables

View Source
var BasePath = "http://localhost:3000"
View Source
var Domain = "localhost:3000"
View Source
var FilePath = ""
View Source
var JwtSecret = ""
View Source
var Log = log.New(os.Stdout, "node-integration ", log.Flags())
View Source
var NodePrivateKey *rsa.PrivateKey // Private key for current node

* Credentials for this node

View Source
var NodePublicKey *rsa.PublicKey // Public key for current node
View Source
var Protocol = "http://"
View Source
var ServerPublicKey *rsa.PublicKey // Public key from the backend server
View Source
var Testing = false
View Source
var TestingToken = ""

Functions

func BodyParser

func BodyParser(c *fiber.Ctx, data interface{}) error

Parse encrypted json

func DecryptAES

func DecryptAES(key, ciphertext []byte) ([]byte, error)

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

func EncryptAES(key, plaintext []byte) ([]byte, error)

Encrypt encrypts the given plaintext using AES-GCM.

func EncryptRSA

func EncryptRSA(publicKey *rsa.PublicKey, message []byte) ([]byte, error)

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

func GenerateRSAKey(keySize int) (*rsa.PrivateKey, *rsa.PublicKey, error)

Generate a new RSA key pair.

func GenerateToken

func GenerateToken(tkLength int32) string

func GetBoolSetting

func GetBoolSetting(node *pipes.LocalNode, name string) (bool, error)

Get any setting on the backend and parse it

func GetCurrent

func GetCurrent(identifier string) (id int64, token string, app uint, domain string)

func InvalidRequest

func InvalidRequest(c *fiber.Ctx, message string) error

func NewAESKey

func NewAESKey() ([]byte, error)

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

func PackageRSAPublicKey(publicKey *rsa.PublicKey) string

PackageRSAPublicKey packages a public key into our own format. Packaging order: modulus, public exponent

func PostRequestBackend

func PostRequestBackend(url string, body map[string]interface{}) (map[string]interface{}, error)

Send a post request (with TC protection encryption)

func PostRequestBackendGeneric

func PostRequestBackendGeneric[T any](url string, body map[string]interface{}) (T, error)

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

func PostRequestNoTC(url string, body map[string]interface{}) (map[string]interface{}, error)

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 ReportOffline(node pipes.Node)

func ReturnJSON

func ReturnJSON(c *fiber.Ctx, data interface{}) error

Return encrypted json

func SetOnline

func SetOnline(identifier string) map[string]interface{}

func Setup

func Setup(identifier string, loadEnv bool) bool

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 TestAES

func TestAES()

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

func UnpackageRSAPublicKey(pub string) (*rsa.PublicKey, error)

Unpackage public key (in our own format that is kinda crappy but who cares)

func VerifyRSASignature

func VerifyRSASignature(signature string, publicKey *rsa.PublicKey, message string) error

Verify a signature with a public key. (valid signature = nil error)

Types

type NodeData

type NodeData struct {
	NodeToken string
	NodeId    uint
	AppId     uint
}

type NormalResponse

type NormalResponse struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
}

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)

Jump to

Keyboard shortcuts

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