common

package
v0.0.0-...-5b3d988 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// WIDGET_NOTES_REFRESH_INTERVAL_MILLIS is the default refresh interval for the notes widget
	WIDGET_NOTES_REFRESH_INTERVAL_MILLIS = 2000 * time.Microsecond
	// Length of the encryption key generated by the application at first run
	ENCRYPTION_KEY_LENGTH = 256
	// STEF delete this
	// DEFAULT_ENCRYPTION_ALGORITHM = "aes-256-cbc"
	// CONFIG_ENCRYPTION_KEY               = "encryption_key"
	// CONFIG_ENCRYPTION_ALGORITHM         = "encryption_algorithm"
	CONFIG_CUR_ENCRYPTION_KEY_NAME      = "cur_encryption_key_name"
	CONFIG_ENCRYPTION_KEYS_PWD          = "encryption_keys_pwd"
	CONFIG_KVDB_PATH                    = "kvdb_path"
	CONFIG_GOOGLE_PROVIDER_PATH         = "google_provider_path"
	CONFIG_GOOGLE_CREDENTIALS_FILE_PATH = "google_credentials_file"
	CONFIG_GOOGLE_SHEET_ID              = "google_sheet_id"
	CONFIG_LOG_LEVEL                    = "log_level"
	CONFIG_LOG_FILE_PATH                = "log_file_path"
	CONFIG_KEY_FILE_PATH                = "key_file_path"

	EncryptionKeyAction_Generate EncryptionKeyAction = iota
	EncryptionKeyAction_Decrypt
	EncryptionKeyAction_Encrypt
	EncryptionKeyAction_Verify

	WindowAspect_Normal WindowAspect = iota
	WindowAspect_FullScreen

	WindowMode_Edit WindowMode = iota // edit/update mode
	WindowMode_View                   // read only

	WindowAction_New    WindowAction = iota // window with new data (create mode)
	WindowAction_Update                     // update data in window (update mode)
	WindowAction_Delete                     // prepare to delete data (delete mode)

	OPT_WINDOW_ASPECT = "window_aspect"
	OPT_WINDOW_MODE   = "window_mode"
	OPT_WINDOW_ACTION = "window_action"

	WIN_MAIN         = "main"
	WIN_NOTE_DETAILS = "note_details"

	BTN_CANCEL          = "btn_cancel"
	BTN_SAVE_NEW        = "btn_save_new"
	BTN_SAVE_UPDATED    = "btn_save_updated"
	BTN_DELETE          = "btn_delete"
	BTN_OK              = "btn_ok"
	BTN_TOGGLE_CONTENT  = "btn_toggle_content"
	BTN_COPY_ENCRYPTED  = "btn_copy_encrypted"
	BTN_PASTE_ENCRYPTED = "btn_paste_encrypted"
	BTN_PASSWORD_MODAL  = "btn_password_modal"

	WDG_NOTE_DETAILS_TITLE             = "note_details_title"
	WDG_NOTE_DETAILS_CONTENT           = "note_details_content"
	WDG_NOTE_DETAILS_CONTENT_RICH_TEXT = "note_details_content_rich_text"
	WDG_NOTE_DETAILS_HIDDEN            = "note_details_hidden"
	WDG_NOTE_DETAILS_ENCRYPTED         = "note_details_encrypted"
	WDG_NOTE_DETAILS_CREATED_AT        = "note_details_created_at"
	WDG_NOTE_DETAILS_UPDATED_AT        = "note_details_updated_at"
	WDG_NOTE_LIST                      = "note_list"
	WDG_PASSWORD_MODAL                 = "password_modal"
	WDG_SEARCH_BOX                     = "search_box"

	// log levels
	LOG_LEVEL_TRACE = "trace"
	LOG_LEVEL_DEBUG = "debug"
	LOG_LEVEL_INFO  = "info"
	LOG_LEVEL_WARN  = "warn"
	LOG_LEVEL_ERROR = "error"
	LOG_LEVEL_FATAL = "fatal"
	LOG_LEVEL_PANIC = "panic"

	ENCRYPTION_ALGORITHM_AES_256_CBC = "aes-256-cbc"
	ENCRYPTION_ALGORITHM_RSA_OAEP    = "rsa-oaep"
)
View Source
const (
	ERR_NOTE_NOT_FOUND                        = "note not found"
	ERR_NOTE_ALREADY_EXISTS                   = "note already exists"
	ERR_NOTE_EMPTY                            = "note is empty"
	ERR_NOTE_TITLE_SAME                       = "note title is same"
	ERR_NOTE_TITLE_EMPTY                      = "note title is empty"
	ERR_NOTE_TITLE_OLD_EMPTY                  = "note previous title is empty"
	ERR_ENCRYPTION_KEY_NOT_SET                = "encryption key not set"
	ERR_NOTE_ID_NOT_UNIQUE                    = "note ID is not unique"
	ERR_BUCKET_EMPTY                          = "bucket is empty"
	ERR_INVALID_GOOGLE_PROVIDER_CONFIG        = "invalid Google provider configuration"
	ERR_NO_KEY                                = "no key"
	ERR_KEY_NOT_FOUND                         = "key not found"
	ERR_EMPTY_KEY_BLOCK                       = "empty key block"
	ERR_INVALID_KEY_TYPE                      = "invalid key type"
	ERR_INVALID_KEY_LENGTH                    = "invalid key length"
	ERR_SYMMETRIC_KEY_SIGNING_NOT_IMPLEMENTED = "symmetric key signing not implemented"
	ERR_INVALID_HEX_STRING                    = "invalid hex string"
	ERR_CERT_NOT_FOUND                        = "certificate not found"
	ERR_CANNOT_DECRYPT_MISSING_KEY            = "message cannot be decrypted. Missing key?"
	ERR_UNKNOWN_KEY_ACTION                    = "unknown key action"
)

Variables

View Source
var (
	DEFAULT_RESOURCE_PATH           = "resources"
	DEFAULT_DB_PATH                 = "db/kv_store"
	DEFAULT_LOG_LEVEL               = LOG_LEVEL_ERROR
	DEFAULT_LOG_FILE_PATH           = filepath.Join("logs", "ecnotes.log")
	DEFAULT_KEY_FILE_PATH           = "key_store.json"
	SUPPORTED_ENCRYPTION_ALGORITHMS = []string{
		ENCRYPTION_ALGORITHM_AES_256_CBC,
		ENCRYPTION_ALGORITHM_RSA_OAEP,
	}
)
View Source
var DefaultTimeFormat = time.RFC3339Nano

DefaultTimeFormat is the time format to use for formatting and parsing time values.

Functions

func FormatTime

func FormatTime(t time.Time) string

FormatTime format time to string RFC3339

func GetCurrentTime

func GetCurrentTime() string

GetCurrentTime get time as string formatted RFC3339

func GetCurrentTimestamp

func GetCurrentTimestamp() int64

GetCurrentTimestamp get unix timestamp in milliseconds

func GetMapValOrNil

func GetMapValOrNil(m map[string]interface{}, key string) interface{}

GetMapValOrNil gets the value from the map and returns nil if the key is not found

func GetUserHomeDir

func GetUserHomeDir() string

GetUserHomeDir returns the user's home directory.

func IsSupportedEncryptionAlgorithm

func IsSupportedEncryptionAlgorithm(algorithm string) bool

IsSupportedEncryptionAlgorithm returns true if the specified encryption algorithm is supported by the application. The supported algorithms are defined as constants

func MarshalJSON

func MarshalJSON(v interface{}) ([]byte, error)

MarshalJSON marshals a struct into JSON

func StringToBool

func StringToBool(s string) bool

StringToBool converts a string to a bool

func StringToInt

func StringToInt(s string) int

StringToInt converts a string to an int

func StringToInt64

func StringToInt64(s string) int64

StringToInt64 converts a string to an int64

func StringToTime

func StringToTime(s string) time.Time

StringToTime converts a string to a time

func TimestampToTime

func TimestampToTime(timestamp int64) time.Time

TimestampToTime convert unix timestamp to time

func UnmarshalJSON

func UnmarshalJSON(data []byte, v interface{}) error

UnmarshalJSON unmarshals a JSON string into a struct

Types

type EncryptionKeyAction

type EncryptionKeyAction int64

EncryptionKeyAction enum to describe the encryption key action

type WindowAction

type WindowAction int64

EncryptionKeyAction enum to describe the encryption key action

type WindowAspect

type WindowAspect int64

EncryptionKeyAction enum to describe the encryption key action

type WindowMode

type WindowMode int64

EncryptionKeyAction enum to describe the encryption key action

Jump to

Keyboard shortcuts

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