moolticute

package module
v0.0.0-...-27443a9 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2021 License: GPL-3.0 Imports: 5 Imported by: 0

README

Moolticute Go package & mc-get CLI

License GPLv3

Go package to interact with a running moolticute daemon.

As well as a mc-get CLI to retrieve credentials from the command line.

moolticute go package

Simply import it

import "git.sr.ht/~oliverpool/go-moolticute"

mc-get installation

Install go if needed. Add $GOPATH/bin to your path.

go install git.sr.ht/~oliverpool/go-moolticute/cmd/mc-get@latest
Usage (mc-get -h)
usage:
	mc-get [options] <service> [<login>]

  -url string
    	URL of the moolticute daemon (default "ws://localhost:30035")

Rationale / Why not use mc-cli?

This code took inspiration from mc-cli (and copied the request/response structs).

However I wasn't pleased with it for several reasons:

  • it does not use modules (go.mod/go.sum)
  • it has 8 external dependencies (I can't audit them all, to ensure that my passwords stay safe) - this repo has 2 external dependencies (which only use the stdlib)
  • it does much more than I actually need (I manage my passwords using the moolticute GUI, I just need to read them via the CLI)
  • I has some ideas to simplify the code

Documentation

Overview

Package moolticute provides a client to interact with a moolticute daemon

Index

Constants

View Source
const (
	DAEMON_DEFAULT_URL = "ws://localhost:30035"
)

Variables

View Source
var ErrDeviceDisconnected = errors.New("device is disconnected")

Functions

This section is empty.

Types

type Client

type Client struct {
	UUID string
	Conn *websocket.Conn
}

func NewClient

func NewClient(url string) (*Client, error)

NewClient makes a new websocket connection to the moolticute daemon If the url is empty, the MOOLTICUTE_DAEMON_DEFAULT_URL will be used

func (*Client) Close

func (c *Client) Close() error

Close the underlying websocket connection Conn

func (*Client) Do

func (c *Client) Do(msg string, req Data, opts ...Opt) (resp Data, err error)

Do makes a request to the daemon and returns the response

type Data

type Data struct {
	Service         string `json:"service,omitempty"`
	FallbackService string `json:"fallback_service,omitempty"`
	NodeData        string `json:"node_data,omitempty"`
	Failed          bool   `json:"failed,omitempty"`
	ErrorMessage    string `json:"error_message,omitempty"`
	Login           string `json:"login,omitempty"`
	Password        string `json:"password,omitempty"`
	Description     string `json:"description,omitempty"`
	RequestId       string `json:"request_id,omitempty"`
	ProgressTotal   int    `json:"progress_total,omitempty"`
	ProgressCurrent int    `json:"progress_current,omitempty"`
}

Data represents data sent and received from the daemon copied from https://github.com/raoulh/mc-cli

func MakeRequest

func MakeRequest(url, msg string, data Data, opts ...Opt) (Data, error)

MakeRequest creates a client and makes a request

type Opt

type Opt func(*opt)

func HandleOtherMsg

func HandleOtherMsg(f func(msg string, data json.RawMessage) error) Opt

type ResponseError

type ResponseError struct {
	Message string
}

func (ResponseError) Error

func (r ResponseError) Error() string

type StatusError

type StatusError struct {
	Status string // NoCardInserted, Locked, ...
}

func (StatusError) Error

func (s StatusError) Error() string

Directories

Path Synopsis
cmd
mc-get
mc-get is a program for retrieving password from a mooltipass device (via the moolticute daemon)
mc-get is a program for retrieving password from a mooltipass device (via the moolticute daemon)

Jump to

Keyboard shortcuts

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