share

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2023 License: AGPL-3.0-or-later Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultServerURL         = "https://minishare.cryptag.org"
	DefaultServerTorURL      = "http://ptga662wjtg2cie3.onion"
	DefaultWordsInPassphrase = 12
)

Variables

View Source
var (
	ErrInvalidInviteURL = errors.New("share: invalid invite URL")
)

Functions

func BuildShareURL

func BuildShareURL(serverBaseURL string, passphrase string) string

BuildShareURL builds and returns the final URL at which the Share server at serverBaseURL is hosting Shares for the user whose keypair can be generated with passphrase.

func CreateEphemeral

func CreateEphemeral(serverBaseURL string, cfg *backend.Config) (shareURL string, err error)

CreateEphemeral uses passphrase to use miniLock to encrypt JSON-marshaled cfg and store it at the share server at serverBaseURL, returning the location at which the Backend Config (aka invite) can be retrieved.

If serverBaseURL is empty, DefaultServerURL is used.

func EmailFromPassphrase

func EmailFromPassphrase(passphrase string) string

EmailFromPassphrase generates an "email" suitable for combining with the given passphrase for use in generating a miniLock/session25519 key pair.

func Get

func Get(cl *Client, path string, keypair *taber.Keys) (*http.Response, error)

Get does an authenticated GET request to serverBaseURL+path. If authToken is empty or stale, this function will log into the server to get a new auth token, and _then_ execute the GET.

func GetConfigsByInviteURL

func GetConfigsByInviteURL(url string) ([]*backend.Config, error)

func GetConfigsByKeypair

func GetConfigsByKeypair(cl *Client, keypair *taber.Keys) ([]*backend.Config, error)

func Login

func Login(cl *Client, keypair *taber.Keys) (authToken string, err error)

func NewKeyPair

func NewKeyPair(passphrase string) (keypair *taber.Keys, err error)

NewKeyPair generates an "email" from the given passphrase, then uses that email/passphrase pair to generate a new keypair.

func ParseInviteURL

func ParseInviteURL(url string) (serverBaseURL, passphrase string, err error)

func Post

func Post(cl *Client, urlPath string, filebr io.Reader, headers http.Header) error

Posts reads filebr and POSTs it to the Share server at cl.ServerBaseURL + urlPath.

func RandomPassphrase

func RandomPassphrase(numWords int) (string, error)

RandomPassphrase uses a capitalized version of the EFF's user-friendly wordlist (see https://www.eff.org/deeplinks/2016/07/new-wordlists-random-passphrases) to generate a random passphrase consisting of numWords words. Each additional word contributes 10.34 bits of entropy to the overall strength of the resulting passphrase.

func ToConfig

func ToConfig(share *Share) (*backend.Config, error)

func ToConfigs

func ToConfigs(shares []*Share) ([]*backend.Config, error)

Types

type Client

type Client struct {
	ServerBaseURL string
	AuthToken     string
	Client        *http.Client
	UsingTor      bool
}

func NewClient

func NewClient(serverBaseURL string) *Client

type Share

type Share struct {
	SenderID string
	Filename string
	Contents []byte
}

Share represents a(n originally miniLock-encrypted) "share" -- something that has been shared via a share server.

func GetShares

func GetShares(cl *Client, recipEmail, recipPassphrase string) ([]*Share, error)

GetShares fetches all shares for the user with the given email and passphrase.

func GetSharesByInviteURL

func GetSharesByInviteURL(inviteURL string) ([]*Share, error)

func GetSharesByKeypair

func GetSharesByKeypair(cl *Client, keypair *taber.Keys) ([]*Share, error)

GetShares fetches all shares for the user with the given keypair.

Jump to

Keyboard shortcuts

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