messaging

package
v0.25.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2025 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ListVaultAction      uint32 = 1
	UnlockVaultAction    uint32 = 2
	CreateVaultAction    uint32 = 3
	ListItemsVaultAction uint32 = 4
	GetLoginItem         uint32 = 5
	GetTLDPlusOneAction  uint32 = 6
	GetAppStateAction    uint32 = 7
)

Variables

View Source
var (
	ErrInvalidMessageLenght = errors.New("invalid message lenght")
)

Functions

func NewPawMux

func NewPawMux(h ...Handler) *mux

Types

type ActionHandlerMismatchError

type ActionHandlerMismatchError struct {
	ReqAction     uint32
	HandlerAction uint32
}

func (*ActionHandlerMismatchError) Error

type ActionNotRegisteredError

type ActionNotRegisteredError struct {
	Action uint32
}

func (*ActionNotRegisteredError) Error

func (e *ActionNotRegisteredError) Error() string

type CreateVaultHandler

type CreateVaultHandler struct {
	Storage paw.Storage
}

func (*CreateVaultHandler) Action

func (h *CreateVaultHandler) Action() uint32

Action implements browser.Handler.

func (*CreateVaultHandler) Serve

func (h *CreateVaultHandler) Serve(res *Response, req *Request)

Serve implements browser.Handler.

type CreateVaultHandlerRequestPayload

type CreateVaultHandlerRequestPayload struct {
	Vault  string `json:"vault"`
	Secret string `json:"secret"`
}

type CreateVaultHandlerResponsePayload

type CreateVaultHandlerResponsePayload struct {
	SessionID string `json:"session_id"`
}

type GetAppStateHandler

type GetAppStateHandler struct {
	Storage paw.Storage
}

func (*GetAppStateHandler) Action

func (h *GetAppStateHandler) Action() uint32

Action implements browser.Handler.

func (*GetAppStateHandler) Serve

func (h *GetAppStateHandler) Serve(res *Response, req *Request)

Serve implements browser.Handler.

type GetAppStateHandlerRequestPayload

type GetAppStateHandlerRequestPayload struct {
	Modified time.Time `json:"modified"`
}

type GetAppStateHandlerResponsePayload

type GetAppStateHandlerResponsePayload struct {
	AppStatate *paw.AppState `json:"app_state"`
}

type GetLoginItemHandler

type GetLoginItemHandler struct {
	Storage paw.Storage
}

func (*GetLoginItemHandler) Action

func (h *GetLoginItemHandler) Action() uint32

Action implements browser.Handler.

func (*GetLoginItemHandler) Serve

func (h *GetLoginItemHandler) Serve(res *Response, req *Request)

Serve implements browser.Handler.

type GetLoginItemHandlerRequestPayload

type GetLoginItemHandlerRequestPayload struct {
	Vault     string `json:"vault"`
	SessionID string `json:"session_id"`
	Name      string `json:"name"`
	Type      int    `json:"type"`
}

type GetLoginItemHandlerResponsePayload

type GetLoginItemHandlerResponsePayload struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type GetTLDPlusOneHandler

type GetTLDPlusOneHandler struct {
}

func (*GetTLDPlusOneHandler) Action

func (h *GetTLDPlusOneHandler) Action() uint32

Action implements browser.Handler.

func (*GetTLDPlusOneHandler) Serve

func (h *GetTLDPlusOneHandler) Serve(res *Response, req *Request)

Serve implements browser.Handler.

type GetTLDPlusOneHandlerRequestPayload

type GetTLDPlusOneHandlerRequestPayload struct {
	Hostname string `json:"hostname"`
	Type     int    `json:"type"`
}

type GetTLDPlusOneHandlerResponsePayload

type GetTLDPlusOneHandlerResponsePayload struct {
	TldPlusOne string `json:"tld_plus_one"`
}

type Handler

type Handler interface {
	Serve(res *Response, req *Request)
	Action() uint32
}

A Handler responds to an native message request.

type InvalidRequestPayloadError

type InvalidRequestPayloadError struct {
	Got      any
	Expected any
}

func (*InvalidRequestPayloadError) Error

type ListItemsVaultHandler

type ListItemsVaultHandler struct {
	Storage paw.Storage
}

func (*ListItemsVaultHandler) Action

func (h *ListItemsVaultHandler) Action() uint32

Action implements browser.Handler.

func (*ListItemsVaultHandler) Serve

func (h *ListItemsVaultHandler) Serve(res *Response, req *Request)

Serve implements browser.Handler.

type ListItemsVaultHandlerRequestPayload

type ListItemsVaultHandlerRequestPayload struct {
	Vault      string `json:"vault"`
	SessionID  string `json:"session_id"`
	FilterName string `json:"filter_name"`
	FilterType int    `json:"filter_type"`
}

type ListItemsVaultHandlerResponsePayload

type ListItemsVaultHandlerResponsePayload struct {
	Items any `json:"items"`
}

type ListVaultHandler

type ListVaultHandler struct {
	Storage paw.Storage
}

func (*ListVaultHandler) Action

func (h *ListVaultHandler) Action() uint32

Action implements browser.Handler.

func (*ListVaultHandler) Serve

func (h *ListVaultHandler) Serve(res *Response, req *Request)

Serve implements browser.Handler.

type ListVaultHandlerResponsePayload

type ListVaultHandlerResponsePayload struct {
	Vaults []string `json:"vaults"`
}

type Request

type Request struct {
	Action  uint32          `json:"action"`  //the action to handled
	Payload json.RawMessage `json:"payload"` //the json raw data will be unmarshaled by the action handler
}

Request represents the native message request

func (*Request) IsPayloadEmpty

func (req *Request) IsPayloadEmpty() bool

IsPayloadEmpty returns true if the payload contains no data

type Response

type Response struct {
	Action  uint32 `json:"action"`  //the handled action
	Error   error  `json:"error"`   //the error occurred handling the action, if any
	Payload any    `json:"payload"` //the paylod action response to be marshaled as json
}

Response represents the native message response

func (*Response) MarshalJSON

func (p *Response) MarshalJSON() ([]byte, error)

Custom marshal method for Response

type UnlockVaultHandler

type UnlockVaultHandler struct {
	Storage paw.Storage
}

func (*UnlockVaultHandler) Action

func (h *UnlockVaultHandler) Action() uint32

Action implements browser.Handler.

func (*UnlockVaultHandler) Serve

func (h *UnlockVaultHandler) Serve(res *Response, req *Request)

Serve implements browser.Handler.

type UnlockVaultHandlerRequestPayload

type UnlockVaultHandlerRequestPayload struct {
	Vault  string `json:"vault"`
	Secret string `json:"secret"`
}

type UnlockVaultHandlerResponsePayload

type UnlockVaultHandlerResponsePayload struct {
	SessionID string `json:"session_id"`
}

Jump to

Keyboard shortcuts

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