sfgo

package module
v0.0.0-...-bb11971 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2018 License: MPL-2.0 Imports: 19 Imported by: 0

README

SFGO

Client for StandardFile written in golang

Implemented the bare minimum to make it work. Do not use for production API might change at any time.

Working:

  • Sync with server
  • Decrypt item
  • Update item
  • Create new item

TODO:

  • Register a user
  • Update a user's password

Example

package main

import (
	sf "github.com/VictorNine/sfgo"
	"fmt"
)

func main() {
	sess := sf.NewSession(
		"https://sync.standardnotes.org",
		"## YOUR EMAIL ##",
	)

	err := sess.Signin("## YOUR PASSWORD ##")
	if err != nil {
		log.Fatal(err)
	}

	log.Println("Login successful!")

	items, _ := sess.Sync()

	fmt.Printf("%+v\n", items)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthParmas

type AuthParmas struct {
	Identifier string  `json:"identifier"`
	PwSalt     *string `json:"pw_salt"`
	PwCost     int     `json:"pw_cost"`
	PwNonce    string  `json:"pw_nonce"`
	Version    string  `json:"version"`
	PW         string  `json:"-"`
	MK         string  `json:"-"`
	AK         string  `json:"-"`
}

type Item

type Item struct {
	UUID        string  `json:"uuid"`
	Content     string  `json:"content"`
	ContentType string  `json:"content_type"`
	EncItemKey  string  `json:"enc_item_key"`
	AuthHash    *string `json:"auth_hash"`
	CreatedAt   string  `json:"created_at"`
	UpdatedAt   string  `json:"updated_at"`
	Deleted     bool    `json:"deleted"`
	PlanText    []byte  `json:"-"`
}

type Items

type Items struct {
	RetrievedItems []Item  `json:"retrieved_items"`
	SavedItems     []Item  `json:"saved_items"`
	Unsaved        []Item  `json:"unsaved"`
	SyncToken      string  `json:"sync_token"`
	CursorToken    *string `json:"cursor_token"`
}

type Session

type Session struct {
	Email      string
	JWT        string
	URL        string
	SyncToken  *string
	Auth       AuthParmas
	AddedItems []Item // List off items that has not been synced
}

func NewSession

func NewSession(URL string, email string) *Session

NewSession create a new session

func (*Session) Decrypt

func (sess *Session) Decrypt(item *Item) ([]byte, error)

Decrypt decrypt an item

func (*Session) EncryptItem

func (sess *Session) EncryptItem(item *Item) error

EncryptItem Encrypt an item with existing EncItemKey

func (*Session) GenerateKeys

func (sess *Session) GenerateKeys(password string)

GenerateKeys generate login and encryption keys

func (*Session) NewItem

func (sess *Session) NewItem(plainText []byte, contentType string) error

NewItem Create new item

func (*Session) Signin

func (sess *Session) Signin(pw string) error

Signin Authenticates a user and returns a JWT.

func (*Session) Sync

func (sess *Session) Sync() (Items, error)

Sync Sync with server

func (*Session) UpdateItem

func (sess *Session) UpdateItem(item Item) error

UpdateItem Put item in que to be synced

Jump to

Keyboard shortcuts

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