etebase

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2020 License: BSD-3-Clause Imports: 9 Imported by: 0

README

Etebase - Encrypt Everything

A (work in progress) Go library for Etebase

GitHub tag Build Status PkgGoDev Chat with us

Star and watch to show your interest and get notified once it's ready!

TODO:

  • Authentication
    • Signup
    • Login
    • Logout
    • Password Change
  • Collections
  • Items
  • Invitations

Documentation

Overview

package etebase implements a Etebase client. Etebase is an end-to-end encrypted backend as a service. Think Firebase, but encrypted in a way that only your users can access their data.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	// contains filtered or unexported fields
}

Account represents a user account and is the main object for all user interactions and data manipulation.

func Login

func Login(c *Client, username, password string) (*Account, error)

Login a user and returns a handle to an Account instance.

Example
var (
	client = NewClient(PartnerClientOptions("your-name"))
	user   = User{
		Username: "john",
		Email:    "john@etebase.com",
	}
	password = "john's-secret"
)

if _, err := Signup(client, user, password); err != nil {
	panic(err)
}

acc, err := Login(client, user.Username, password)
if err != nil {
	panic(err)
}

_ = acc
Output:

func Signup

func Signup(c *Client, user User, password string) (*Account, error)

Signup a new user account and returns an Account instance.

func (*Account) Collection

func (acc *Account) Collection() error

Collection is not implemented yet.

func (*Account) IsEtebaseServer

func (acc *Account) IsEtebaseServer() (bool, error)

IsEtebaseServer checks whether the Client is pointing to a valid Etebase server.

func (*Account) Logout added in v0.0.3

func (acc *Account) Logout() error

Logout the user from the current session and invalidate the authentication token.

func (*Account) PasswordChange

func (acc *Account) PasswordChange(newPassword string) error

PasswordChange changes the password of an active session.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client implements the network client to use to interact with the Etebase server.

func NewClient

func NewClient(opts ClientOptions) *Client

NewClient returns a new client object given a name (your etebase account name), and options inside the ClientOptions struct.

func (*Client) Get

func (c *Client) Get(path string) (*http.Response, error)

func (*Client) Host added in v0.0.3

func (c *Client) Host() string

func (*Client) Post

func (c *Client) Post(path string, v interface{}) (*http.Response, error)

Post posts an encoded value `v` to the server. `v` will be encoded using msgpack format.

func (Client) WithToken

func (c Client) WithToken(token string) *Client

WithToken returns a client that attaches a `Authorization: Token <token>` to any request.

type ClientOptions

type ClientOptions struct {
	// Host is the Etebase server host.
	Host string
	// Prefix is a string used as a prefix for requests.
	// Possible values are `/partner/your-username` or
	// `/developer/your-username` if your are using etebase.com server.
	// For local server leave it blank.
	Prefix string

	// UseSSL specifies is ssl should be used or not.
	UseSSL bool

	Logger interface {
		Logf(format string, v ...interface{})
	}
}

ClientOptions allow you control specific options of the client. Most of the users should use DefaultClientOptions when constructing the client.

func DeveloperClientOptions

func DeveloperClientOptions(name string) ClientOptions

DefaultClientOptions will make your client point to the official Etebase server in 'developer' mode.

func PartnerClientOptions

func PartnerClientOptions(name string) ClientOptions

type ErrorResponse

type ErrorResponse struct {
	Code   string          `msgpack:"code"`
	Detail string          `msgpack:"detail"`
	Errors []ErrorResponse `msgpack:"errors,omitempty"`
}

func (*ErrorResponse) Error

func (err *ErrorResponse) Error() string

type LoginChallengeRequest

type LoginChallengeRequest struct {
	Username string `msgpack:"username"`
}

type LoginChallengeResponse

type LoginChallengeResponse struct {
	Salt      []byte `msgpack:"salt"`
	Challenge []byte `msgpack:"challenge"`
}

type LoginRequest

type LoginRequest struct {
	// These fields are common to login and passwordChange
	Username  string `msgpack:"username"`
	Challenge []byte `msgpack:"challenge"`
	Host      string `msgpack:"host"`
	Action    string `msgpack:"action"`

	// These fields exclusively used for passwordChange
	LoginPubKey      []byte `msgpack:"loginPubkey,omitempty"`
	EncryptedContent []byte `msgpack:"encryptedContent,omitempty"`
}

type LoginResponse

type LoginResponse struct {
	Token string `msgpack:"token"`
	User  struct {
		User
		PubKey           string `msgpack:"pubkey"`
		EncryptedContent string `msgpack:"encryptedContent"`
	} `msgpack:"user"`
}

type SignupRequest

type SignupRequest struct {
	User             User   `msgpack:"user"`
	Salt             []byte `msgpack:"salt"`
	LoginPubkey      []byte `msgpack:"loginPubkey"`
	PubKey           []byte `msgpack:"pubkey"`
	EncryptedContent []byte `msgpack:"encryptedContent"`
}

type User

type User struct {
	Username string `msgpack:"username"`
	Email    string `msgpack:"email"`
}

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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