session

package
v0.0.0-...-cbb00c2 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: MIT Imports: 20 Imported by: 2

Documentation

Index

Constants

View Source
const (
	SNServerURL              = "https://api.standardnotes.com"
	KeyringApplicationName   = "Session"
	KeyringService           = "StandardNotesCLI"
	MsgSessionRemovalSuccess = "session removed successfully"
	MsgSessionRemovalFailure = "failed to remove session"
	DefaultSessionExpiryTime = 12 * time.Hour
	RefreshSessionThreshold  = 10 * time.Minute
)

Variables

This section is empty.

Functions

func AddSession

func AddSession(httpClient *retryablehttp.Client, snServer, inKey string, k keyring.Keyring, debug bool) (res string, err error)

func GetCredentials

func GetCredentials(inServer string) (email, password, apiServer, errMsg string)

func GetSessionFromKeyring

func GetSessionFromKeyring(k keyring.Keyring) (s string, err error)

func RemoveSession

func RemoveSession(k keyring.Keyring) string

RemoveSession removes the SN Session from the keyring.

func SessionExists

func SessionExists(k keyring.Keyring) error

func SessionStatus

func SessionStatus(sKey string, k keyring.Keyring) (msg string, err error)

func UpdateSession

func UpdateSession(sess *Session, k keyring.Keyring, debug bool) error

Types

type MinimalSession

type MinimalSession struct {
	Server            string
	Token             string
	MasterKey         string
	KeyParams         auth.KeyParams `json:"keyParams"`
	AccessToken       string         `json:"access_token"`
	RefreshToken      string         `json:"refresh_token"`
	AccessExpiration  int64          `json:"access_expiration"`
	RefreshExpiration int64          `json:"refresh_expiration"`
	SchemaValidation  bool
}

type Session

type Session struct {
	Debug            bool
	HTTPClient       *retryablehttp.Client
	SchemaValidation bool
	Server           string
	FilesServerUrl   string `json:"filesServerUrl"`
	Token            string
	MasterKey        string
	ItemsKeys        []SessionItemsKey
	// ImporterItemsKeys is the key used to encrypt exported items and set during import only
	// ImporterItemsKeys []SessionItemsKey
	DefaultItemsKey   SessionItemsKey
	KeyParams         auth.KeyParams `json:"keyParams"`
	AccessToken       string         `json:"access_token"`
	RefreshToken      string         `json:"refresh_token"`
	AccessExpiration  int64          `json:"access_expiration"`
	RefreshExpiration int64          `json:"refresh_expiration"`
	ReadOnlyAccess    bool           `json:"readonly_access"`
	PasswordNonce     string
	Schemas           map[string]*jsonschema.Schema
}

Session holds authentication and encryption parameters required to communicate with the API and process transferred data.

func GetSession

func GetSession(httpClient *retryablehttp.Client, loadSession bool, sessionKey, server string, debug bool) (session Session, email string, err error)

func GetSessionFromUser

func GetSessionFromUser(httpClient *retryablehttp.Client, server string, debug bool) (Session, string, error)

func ParseSessionString

func ParseSessionString(ss string) (sess Session, err error)

func (*Session) Refresh

func (sess *Session) Refresh() error

func (*Session) Valid

func (sess *Session) Valid() bool

type SessionItemsKey

type SessionItemsKey struct {
	UUID               string `json:"uuid"`
	ItemsKey           string `json:"itemsKey"`
	Default            bool   `json:"isDefault"`
	CreatedAtTimestamp int64  `json:"created_at_timestamp"`
	UpdatedAtTimestamp int64  `json:"updated_at_timestamp"`
}

Jump to

Keyboard shortcuts

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