kpclient

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

View Source
const (
	CodeUnknownError               = 0
	CodeDatabaseNotOpened          = 1
	CodeDatabaseHashNotReceived    = 2
	CodeClientPublicKeyNotReceived = 3
	CodeCannotDecryptMessage       = 4
	CodeTimeoutOrNotConnected      = 5
	CodeActionCancelledOrDenied    = 6
	CodePublicKeyNotFound          = 7
	CodeAssociationFailed          = 8
	CodeKeyChangeFailed            = 9
	CodeEncryptionKeyUnrecognized  = 10
	CodeNoSavedDatabasesFound      = 11
	CodeIncorrectAction            = 12
	CodeEmptyMessageReceived       = 13
	CodeNoURLProvided              = 14
	CodeNoLoginsFound              = 15
)
View Source
const (
	ActionChangePublicKeys = "change-public-keys"
	ActionAssociate        = "associate"
	ActionGetLogins        = "get-logins"
	ActionTestAssociate    = "test-associate"
	ActionGetTOTP          = "get-totp"
)

Variables

View Source
var (
	ErrUnknownError               = errors.New("unknown error")
	ErrDatabaseNotOpened          = errors.New("database not opened")
	ErrDatabaseHashNotReceived    = errors.New("database hash not received")
	ErrClientPublicKeyNotReceived = errors.New("client public key not received")
	ErrCannotDecryptMessage       = errors.New("cannot decrypt message")
	ErrTimeoutOrNotConnected      = errors.New("timeout or not connected")
	ErrActionCancelledOrDenied    = errors.New("action cancelled or denied")
	ErrPublicKeyNotFound          = errors.New("public key not found")
	ErrAssociationFailed          = errors.New("association failed")
	ErrKeyChangeFailed            = errors.New("key change failed")
	ErrEncryptionKeyUnrecognized  = errors.New("encryption key unrecognized")
	ErrNoSavedDatabasesFound      = errors.New("no saved databases found")
	ErrIncorrectAction            = errors.New("incorrect action")
	ErrEmptyMessageReceived       = errors.New("empty message received")
	ErrNoURLProvided              = errors.New("no url provided")
	ErrNoLoginsFound              = errors.New("no logins found")
)
View Source
var ErrFailedToOpen = errors.New("failed to open message")

Functions

func Nonce

func Nonce() (nonce *[24]byte, err error)

Types

type AssociateRequest

type AssociateRequest struct {
	Action string `json:"action"`
	Key    []byte `json:"key"`   // client pubkey
	IDKey  []byte `json:"idKey"` // new id pubkey
}

type AssociateResponse

type AssociateResponse struct {
	Response
}

type ChangePublicKeysRequest

type ChangePublicKeysRequest struct {
	Request
	PulicKey []byte `json:"publicKey"`
}

type ChangePublicKeysResponse

type ChangePublicKeysResponse struct {
	Response
	PulicKey []byte `json:"publicKey"`
}

type Client

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

func New

func New(conn net.Conn, idKey []byte, clientIdentifier string) (c *Client, err error)

func (*Client) Associate

func (c *Client) Associate() (resp AssociateResponse, err error)

func (*Client) AssociationData

func (c *Client) AssociationData() (idKey [24]byte, identifier string)

func (*Client) ChangePublicKeys

func (c *Client) ChangePublicKeys() (resp ChangePublicKeysResponse, err error)

func (*Client) GetLogins

func (c *Client) GetLogins(url string) (resp GetLoginsResponse, err error)

func (*Client) GetTOTP

func (c *Client) GetTOTP(uuid string) (resp GetTOTPResponse, err error)

func (*Client) TestAssociate

func (c *Client) TestAssociate(triggerUnlock bool) (resp TestAssociateResponse, err error)

type DBKey

type DBKey struct {
	ID  string `json:"id"`  // saved DB identifier
	Key []byte `json:"key"` // saved pubkey
}

type GetLoginsRequest

type GetLoginsRequest struct {
	Action    string  `json:"action"`
	URL       string  `json:"url"`
	SubmitURL string  `json:"submitUrl,omitempty"`
	HTTPAuth  string  `json:"httpAuth,omitempty"`
	Keys      []DBKey `json:"keys,omitempty"`
}

type GetLoginsResponse

type GetLoginsResponse struct {
	Response
	Entries []LoginEntry `json:"entries"`
	Count   int          `json:"count"`
}

type GetTOTPRequest

type GetTOTPRequest struct {
	Action string `json:"action"`
	UUID   string `json:"uuid"`
}

type GetTOTPResponse

type GetTOTPResponse struct {
	Response
	TOTP string `json:"totp"`
}

type LoginEntry

type LoginEntry struct {
	Login        string              `json:"login"`
	Name         string              `json:"name"`
	Password     string              `json:"password"`
	UUID         string              `json:"uuid"`
	StringFields []map[string]string `json:"stringFields"`
}

type Request

type Request struct {
	Action        string `json:"action"`
	ClientID      []byte `json:"clientID"`
	Nonce         []byte `json:"nonce"`
	Message       []byte `json:"message,omitempty"`
	TriggerUnlock bool   `json:"triggerUnlock,string,omitempty"`
}

type Response

type Response struct {
	Message []byte  `json:"message"`
	Nonce   []byte  `json:"nonce"`
	Error   *string `json:"error"`
	Code    *int    `json:"errorCode,string"`
	Success *bool   `json:"success,string"`
	Version *string `json:"version"`
	Hash    *string `json:"hash"`
	ID      string  `json:"id"`
}

type TestAssociateRequest

type TestAssociateRequest struct {
	Action string `json:"action"`
	DBKey
}

type TestAssociateResponse

type TestAssociateResponse struct {
	Response
}

Jump to

Keyboard shortcuts

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