Documentation ¶
Index ¶
- Constants
- func AddSession(snServer, inKey string, k keyring.Keyring) (res string, err error)
- func Decrypt(key []byte, cryptoText string) (pt string, err error)
- func Encrypt(key []byte, text string) string
- func GenUUID() string
- func GetCredentials(inServer string) (email, password, apiServer, errMsg string)
- func GetSessionFromKeyring(k keyring.Keyring) (s string, err error)
- func MakeSessionString(email string, session Session) string
- func RemoveSession(k keyring.Keyring) string
- func SessionExists(k keyring.Keyring) error
- func SessionStatus(sKey string, k keyring.Keyring) (msg string, err error)
- type AppDataContent
- type AppTagConfig
- type ClientStructure
- type ComponentClientStructure
- type ComponentContent
- func (cc *ComponentContent) AssociateItems(newItems []string)
- func (cc *ComponentContent) DisassociateItems(itemsToRemove []string)
- func (cc *ComponentContent) GetActive() bool
- func (cc *ComponentContent) GetAppData() AppDataContent
- func (cc *ComponentContent) GetItemAssociations() []string
- func (cc *ComponentContent) GetItemDisassociations() []string
- func (cc *ComponentContent) GetName() string
- func (cc *ComponentContent) GetText() string
- func (cc *ComponentContent) GetTitle() string
- func (cc *ComponentContent) GetUpdateTime() (time.Time, error)
- func (cc *ComponentContent) References() ItemReferences
- func (cc *ComponentContent) SetAppData(data AppDataContent)
- func (cc *ComponentContent) SetReferences(input ItemReferences)
- func (cc *ComponentContent) SetText(input string)
- func (cc *ComponentContent) SetTitle(title string)
- func (cc *ComponentContent) SetUpdateTime(uTime time.Time)
- func (cc *ComponentContent) UpsertReferences(input ItemReferences)
- type DecryptedItem
- type DecryptedItems
- type EncryptedItem
- type EncryptedItems
- type Filter
- type GetItemsInput
- type GetItemsOutput
- type Item
- type ItemFilters
- type ItemReference
- type ItemReferences
- type Items
- type NoteClientStructure
- type NoteContent
- func (noteContent *NoteContent) AddItemAssociations() string
- func (noteContent *NoteContent) AssociateItems(newItems []string)
- func (noteContent NoteContent) Copy() *NoteContent
- func (noteContent *NoteContent) DisassociateItems(newItems []string)
- func (noteContent *NoteContent) GetActive() bool
- func (noteContent *NoteContent) GetAppData() AppDataContent
- func (noteContent *NoteContent) GetItemAssociations() []string
- func (noteContent *NoteContent) GetItemDisassociations() []string
- func (noteContent *NoteContent) GetName() string
- func (noteContent *NoteContent) GetText() string
- func (noteContent *NoteContent) GetTitle() string
- func (noteContent *NoteContent) GetUpdateTime() (time.Time, error)
- func (noteContent *NoteContent) References() ItemReferences
- func (noteContent *NoteContent) SetAppData(data AppDataContent)
- func (noteContent *NoteContent) SetReferences(newRefs ItemReferences)
- func (noteContent *NoteContent) SetText(text string)
- func (noteContent *NoteContent) SetTitle(title string)
- func (noteContent *NoteContent) SetUpdateTime(uTime time.Time)
- func (noteContent *NoteContent) UpsertReferences(newRefs ItemReferences)
- type OrgStandardNotesSNDetail
- type PutItemsInput
- type PutItemsOutput
- type RegisterInput
- type Session
- func CliSignIn(email, password, apiServer string) (session Session, err error)
- func GetSession(loadSession bool, sessionKey, server string) (session Session, email string, err error)
- func GetSessionFromUser(server string) (Session, string, error)
- func ParseSessionString(in string) (email string, session Session, err error)
- type SignInInput
- type SignInOutput
- type TagContent
- func (tagContent *TagContent) AssociateItems(newItems []string)
- func (tagContent TagContent) Copy() *TagContent
- func (tagContent *TagContent) DisassociateItems(newItems []string)
- func (tagContent TagContent) Equals(e TagContent) bool
- func (tagContent *TagContent) GetActive() bool
- func (tagContent *TagContent) GetAppData() AppDataContent
- func (tagContent *TagContent) GetItemAssociations() []string
- func (tagContent *TagContent) GetItemDisassociations() []string
- func (tagContent *TagContent) GetName() string
- func (tagContent *TagContent) GetText() string
- func (tagContent *TagContent) GetTitle() string
- func (tagContent *TagContent) GetUpdateTime() (time.Time, error)
- func (tagContent *TagContent) References() ItemReferences
- func (tagContent *TagContent) SetAppData(data AppDataContent)
- func (tagContent *TagContent) SetReferences(newRefs ItemReferences)
- func (tagContent *TagContent) SetText(text string)
- func (tagContent *TagContent) SetTitle(title string)
- func (tagContent *TagContent) SetUpdateTime(uTime time.Time)
- func (tagContent *TagContent) TextContains(findString string, matchCase bool) bool
- func (tagContent *TagContent) UpsertReferences(newRefs ItemReferences)
- type UpdateItemRefsInput
- type UpdateItemRefsOutput
Constants ¶
const ( SNServerURL = "https://sync.standardnotes.org" KeyringApplicationName = "session" KeyringService = "StandardNotesCLI" MsgSessionRemovalSuccess = "session removed successfully" MsgSessionRemovalFailure = "failed to remove session" )
const (
// PageSize is the maximum number of items to return with each call
PageSize = 300
)
Variables ¶
This section is empty.
Functions ¶
func AddSession ¶
func GenUUID ¶
func GenUUID() string
GenUUID generates a unique identifier required when creating a new item
func GetCredentials ¶
func MakeSessionString ¶
func RemoveSession ¶
RemoveSession removes the SN session from the keyring
func SessionExists ¶
Types ¶
type AppDataContent ¶
type AppDataContent struct {
OrgStandardNotesSN OrgStandardNotesSNDetail `json:"org.standardnotes.sn"`
}
type AppTagConfig ¶
type AppTagConfig struct { Email string Token string FindText string FindTag string NewTags []string Debug bool }
AppTagConfig defines expected configuration structure for making Tag related operations
type ClientStructure ¶
type ClientStructure interface { References() ItemReferences // update or insert item references UpsertReferences(input ItemReferences) // set references SetReferences(input ItemReferences) // return title GetTitle() string // set title SetTitle(input string) // get last update time GetUpdateTime() (time.Time, error) // set last update time SetUpdateTime(time.Time) // get appdata GetAppData() AppDataContent // set appdata SetAppData(data AppDataContent) // client structure methods for Note NoteClientStructure // client structure methods for Component ComponentClientStructure }
ClientStructure defines behaviour of an Item's content entry
type ComponentClientStructure ¶ added in v0.0.2
type ComponentClientStructure interface { // return name GetName() string // return active status GetActive() bool // get item associations GetItemAssociations() []string // get item disassociations GetItemDisassociations() []string // associate items AssociateItems(items []string) // disassociate items DisassociateItems(items []string) }
ClientStructure defines behaviour of a Component Item's content entry
type ComponentContent ¶ added in v0.0.2
type ComponentContent struct { LegacyURL string `json:"legacy_url"` HostedURL string `json:"hosted_url"` LocalURL string `json:"local_url"` ValidUntil string `json:"valid_until"` OfflineOnly string `json:"offlineOnly"` Name string `json:"name"` Area string `json:"area"` PackageInfo interface{} `json:"package_info"` Permissions interface{} `json:"permissions"` Active interface{} `json:"active"` AutoUpdateDisabled string `json:"autoupdateDisabled"` ComponentData interface{} `json:"componentData"` DissociatedItemIds []string `json:"disassociatedItemIds"` AssociatedItemIds []string `json:"associatedItemIds"` ItemReferences ItemReferences `json:"references"` AppData AppDataContent `json:"appData"` }
func NewComponentContent ¶ added in v0.0.2
func NewComponentContent() *ComponentContent
NewTagContent returns an empty Tag content instance
func (*ComponentContent) AssociateItems ¶ added in v0.0.2
func (cc *ComponentContent) AssociateItems(newItems []string)
func (*ComponentContent) DisassociateItems ¶ added in v0.0.2
func (cc *ComponentContent) DisassociateItems(itemsToRemove []string)
func (*ComponentContent) GetActive ¶ added in v0.0.2
func (cc *ComponentContent) GetActive() bool
func (*ComponentContent) GetAppData ¶ added in v0.0.2
func (cc *ComponentContent) GetAppData() AppDataContent
func (*ComponentContent) GetItemAssociations ¶ added in v0.0.2
func (cc *ComponentContent) GetItemAssociations() []string
func (*ComponentContent) GetItemDisassociations ¶ added in v0.0.2
func (cc *ComponentContent) GetItemDisassociations() []string
func (*ComponentContent) GetName ¶ added in v0.0.2
func (cc *ComponentContent) GetName() string
func (*ComponentContent) GetText ¶ added in v0.0.2
func (cc *ComponentContent) GetText() string
func (*ComponentContent) GetTitle ¶ added in v0.0.2
func (cc *ComponentContent) GetTitle() string
func (*ComponentContent) GetUpdateTime ¶ added in v0.0.2
func (cc *ComponentContent) GetUpdateTime() (time.Time, error)
func (*ComponentContent) References ¶ added in v0.0.2
func (cc *ComponentContent) References() ItemReferences
func (*ComponentContent) SetAppData ¶ added in v0.0.2
func (cc *ComponentContent) SetAppData(data AppDataContent)
func (*ComponentContent) SetReferences ¶ added in v0.0.2
func (cc *ComponentContent) SetReferences(input ItemReferences)
func (*ComponentContent) SetText ¶ added in v0.0.2
func (cc *ComponentContent) SetText(input string)
func (*ComponentContent) SetTitle ¶ added in v0.0.2
func (cc *ComponentContent) SetTitle(title string)
func (*ComponentContent) SetUpdateTime ¶ added in v0.0.2
func (cc *ComponentContent) SetUpdateTime(uTime time.Time)
func (*ComponentContent) UpsertReferences ¶ added in v0.0.2
func (cc *ComponentContent) UpsertReferences(input ItemReferences)
type DecryptedItem ¶
type DecryptedItems ¶
type DecryptedItems []DecryptedItem
func (*DecryptedItems) Parse ¶
func (di *DecryptedItems) Parse() (p Items, err error)
func (*DecryptedItems) RemoveDeleted ¶
func (di *DecryptedItems) RemoveDeleted()
type EncryptedItem ¶
type EncryptedItems ¶
type EncryptedItems []EncryptedItem
func (*EncryptedItems) DeDupe ¶
func (ei *EncryptedItems) DeDupe()
func (EncryptedItems) Decrypt ¶
func (ei EncryptedItems) Decrypt(Mk, Ak string, debug bool) (o DecryptedItems, err error)
func (EncryptedItems) DecryptAndParse ¶
func (ei EncryptedItems) DecryptAndParse(Mk, Ak string, debug bool) (o Items, err error)
func (*EncryptedItems) RemoveDeleted ¶
func (ei *EncryptedItems) RemoveDeleted()
type GetItemsInput ¶
type GetItemsInput struct { Session Session SyncToken string CursorToken string OutType string BatchSize int // number of items to retrieve PageSize int // override default number of items to request with each sync call Debug bool }
GetItemsInput defines the input for retrieving items
type GetItemsOutput ¶
type GetItemsOutput struct { Items EncryptedItems // items new or modified since last sync SavedItems EncryptedItems // dirty items needing resolution Unsaved EncryptedItems // items not saved during sync SyncToken string Cursor string }
GetItemsOutput defines the output from retrieving items It contains slices of items based on their state see: https://standardfile.org/ for state details
func GetItems ¶
func GetItems(input GetItemsInput) (output GetItemsOutput, err error)
GetItems retrieves items from the API using optional filters
type Item ¶
type Item struct { UUID string Content ClientStructure ContentType string Deleted bool CreatedAt string UpdatedAt string ContentSize int }
Item describes a decrypted item
func NewComponent ¶ added in v0.0.2
func NewComponent() *Item
NewComponent returns an Item of type Component without content
type ItemFilters ¶
type ItemReference ¶
type ItemReference struct { // unique identifier of the item being referenced UUID string `json:"uuid"` // type of item being referenced ContentType string `json:"content_type"` }
ItemReference defines a reference from one item to another
type ItemReferences ¶
type ItemReferences []ItemReference
type Items ¶
type Items []Item
func (*Items) Encrypt ¶
func (i *Items) Encrypt(Mk, Ak string, debug bool) (e EncryptedItems, err error)
func (*Items) Filter ¶
func (i *Items) Filter(f ItemFilters)
func (*Items) RemoveDeleted ¶
func (i *Items) RemoveDeleted()
type NoteClientStructure ¶ added in v0.0.2
type NoteClientStructure interface { // set text SetText(input string) // return text GetText() string }
ClientStructure defines behaviour of a Component Item's content entry
type NoteContent ¶
type NoteContent struct { Title string `json:"title"` Text string `json:"text"` ItemReferences ItemReferences `json:"references"` AppData AppDataContent `json:"appData"` }
func NewNoteContent ¶
func NewNoteContent() *NoteContent
NewNoteContent returns an empty Note content instance
func (*NoteContent) AddItemAssociations ¶ added in v0.0.2
func (noteContent *NoteContent) AddItemAssociations() string
func (*NoteContent) AssociateItems ¶ added in v0.0.2
func (noteContent *NoteContent) AssociateItems(newItems []string)
func (NoteContent) Copy ¶
func (noteContent NoteContent) Copy() *NoteContent
func (*NoteContent) DisassociateItems ¶ added in v0.0.2
func (noteContent *NoteContent) DisassociateItems(newItems []string)
func (*NoteContent) GetActive ¶ added in v0.0.2
func (noteContent *NoteContent) GetActive() bool
func (*NoteContent) GetAppData ¶
func (noteContent *NoteContent) GetAppData() AppDataContent
func (*NoteContent) GetItemAssociations ¶ added in v0.0.2
func (noteContent *NoteContent) GetItemAssociations() []string
func (*NoteContent) GetItemDisassociations ¶ added in v0.0.2
func (noteContent *NoteContent) GetItemDisassociations() []string
func (*NoteContent) GetName ¶ added in v0.0.2
func (noteContent *NoteContent) GetName() string
func (*NoteContent) GetText ¶
func (noteContent *NoteContent) GetText() string
func (*NoteContent) GetTitle ¶
func (noteContent *NoteContent) GetTitle() string
func (*NoteContent) GetUpdateTime ¶
func (noteContent *NoteContent) GetUpdateTime() (time.Time, error)
func (*NoteContent) References ¶
func (noteContent *NoteContent) References() ItemReferences
func (*NoteContent) SetAppData ¶
func (noteContent *NoteContent) SetAppData(data AppDataContent)
func (*NoteContent) SetReferences ¶
func (noteContent *NoteContent) SetReferences(newRefs ItemReferences)
func (*NoteContent) SetText ¶
func (noteContent *NoteContent) SetText(text string)
func (*NoteContent) SetTitle ¶
func (noteContent *NoteContent) SetTitle(title string)
func (*NoteContent) SetUpdateTime ¶
func (noteContent *NoteContent) SetUpdateTime(uTime time.Time)
func (*NoteContent) UpsertReferences ¶
func (noteContent *NoteContent) UpsertReferences(newRefs ItemReferences)
type OrgStandardNotesSNDetail ¶
type OrgStandardNotesSNDetail struct {
ClientUpdatedAt string `json:"client_updated_at"`
}
type PutItemsInput ¶
type PutItemsInput struct { Items EncryptedItems SyncToken string Session Session Debug bool }
PutItemsInput defines the input used to put items
type PutItemsOutput ¶
type PutItemsOutput struct {
ResponseBody syncResponse
}
PutItemsOutput defines the output from putting items
func PutItems ¶
func PutItems(i PutItemsInput) (output PutItemsOutput, err error)
PutItems validates and then syncs items via API
type RegisterInput ¶
func (RegisterInput) Register ¶
func (input RegisterInput) Register() (token string, err error)
Register creates a new user token Params: email, password, pw_cost, pw_nonce, version
type Session ¶
Session holds authentication and encryption parameters required to communicate with the API and process transferred data
func CliSignIn ¶
CLiSignIn takes the server URL and credentials and sends them to the API to get a response including an authentication token plus the keys required to encrypt and decrypt SN items
func GetSession ¶
func ParseSessionString ¶
type SignInInput ¶
type SignInOutput ¶
func SignIn ¶
func SignIn(input SignInInput) (output SignInOutput, err error)
SignIn authenticates with the server using credentials and optional MFA in order to obtain the data required to interact with Standard Notes
type TagContent ¶
type TagContent struct { Title string `json:"title"` ItemReferences ItemReferences `json:"references"` AppData AppDataContent `json:"appData"` }
func NewTagContent ¶
func NewTagContent() *TagContent
NewTagContent returns an empty Tag content instance
func (*TagContent) AssociateItems ¶ added in v0.0.2
func (tagContent *TagContent) AssociateItems(newItems []string)
func (TagContent) Copy ¶
func (tagContent TagContent) Copy() *TagContent
func (*TagContent) DisassociateItems ¶ added in v0.0.2
func (tagContent *TagContent) DisassociateItems(newItems []string)
func (TagContent) Equals ¶
func (tagContent TagContent) Equals(e TagContent) bool
func (*TagContent) GetActive ¶ added in v0.0.2
func (tagContent *TagContent) GetActive() bool
func (*TagContent) GetAppData ¶
func (tagContent *TagContent) GetAppData() AppDataContent
func (*TagContent) GetItemAssociations ¶ added in v0.0.2
func (tagContent *TagContent) GetItemAssociations() []string
func (*TagContent) GetItemDisassociations ¶ added in v0.0.2
func (tagContent *TagContent) GetItemDisassociations() []string
func (*TagContent) GetName ¶ added in v0.0.2
func (tagContent *TagContent) GetName() string
func (*TagContent) GetText ¶
func (tagContent *TagContent) GetText() string
func (*TagContent) GetTitle ¶
func (tagContent *TagContent) GetTitle() string
func (*TagContent) GetUpdateTime ¶
func (tagContent *TagContent) GetUpdateTime() (time.Time, error)
func (*TagContent) References ¶
func (tagContent *TagContent) References() ItemReferences
func (*TagContent) SetAppData ¶
func (tagContent *TagContent) SetAppData(data AppDataContent)
func (*TagContent) SetReferences ¶
func (tagContent *TagContent) SetReferences(newRefs ItemReferences)
func (*TagContent) SetText ¶
func (tagContent *TagContent) SetText(text string)
func (*TagContent) SetTitle ¶
func (tagContent *TagContent) SetTitle(title string)
func (*TagContent) SetUpdateTime ¶
func (tagContent *TagContent) SetUpdateTime(uTime time.Time)
func (*TagContent) TextContains ¶
func (tagContent *TagContent) TextContains(findString string, matchCase bool) bool
func (*TagContent) UpsertReferences ¶
func (tagContent *TagContent) UpsertReferences(newRefs ItemReferences)
type UpdateItemRefsInput ¶
type UpdateItemRefsOutput ¶
type UpdateItemRefsOutput struct {
Items Items // Tags
}
func UpdateItemRefs ¶
func UpdateItemRefs(i UpdateItemRefsInput) UpdateItemRefsOutput