messagebox

package
v0.8.6 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package messagebox is a BRC-33 message box client, reduced to the three calls a reader and a deliverer need: send a message to one recipient's box, list a box, and acknowledge what was taken from it.

Every call is mutually authenticated (BRC-103/104) by go-sdk's AuthFetch under the caller's wallet, so the server knows who sent a message and who is listing a box, and the recipient learns the sender's identity key from the server. A box that asks for payment is refused rather than paid: the wallet handed to AuthFetch cannot create an action, so nothing here spends.

Index

Constants

This section is empty.

Variables

View Source
var ErrPayment = errors.New("messagebox: the box asks for payment, which bfinger does not make")

ErrPayment is a box that wants paying, which this client never does.

Functions

This section is empty.

Types

type Client

type Client struct {
	Base  string
	Fetch Fetcher
}

Client talks to one message box server.

func New

func New(base string, w wallet.Interface) *Client

New is a client for base that authenticates as w.

func (*Client) Acknowledge

func (c *Client) Acknowledge(ctx context.Context, box string, ids []string) error

Acknowledge removes messages from the caller's box. Acknowledging a message the server no longer holds succeeds.

func (*Client) List

func (c *Client) List(ctx context.Context, box string) ([]Message, error)

List is every message in the caller's box.

func (*Client) Send

func (c *Client) Send(ctx context.Context, recipient, box, messageID, body string) error

Send puts body in recipient's box under messageID.

type Fetcher

type Fetcher interface {
	Fetch(ctx context.Context, url string, cfg *authhttp.SimplifiedFetchRequestOptions) (*http.Response, error)
}

Fetcher is the authenticated transport: AuthFetch in use, anything with its Fetch in a test.

type Message

type Message struct {
	MessageID string `json:"messageId"`
	Body      string `json:"body"`
	Sender    string `json:"sender"`
	CreatedAt string `json:"created_at,omitempty"`
}

Message is one message in a box.

Directories

Path Synopsis
Package mbtest is a stand-in BRC-33 message box server for tests: the three calls in the shapes of the HTTP conformance vectors, with the caller's identity taken from the header the vectors show instead of from a mutual authentication.
Package mbtest is a stand-in BRC-33 message box server for tests: the three calls in the shapes of the HTTP conformance vectors, with the caller's identity taken from the header the vectors show instead of from a mutual authentication.

Jump to

Keyboard shortcuts

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