Documentation
¶
Overview ¶
Package feedtest is an in-process PeerFeed Object (peer worker src/feed.ts) for the host side's tests: the hello check against a source secret and reader tokens, the fan-out of a source's records to every viewer with its ack, the replay request a viewer's connect sends every source with its key, the frames addressed to one viewer, and the signed config at /feed/<party id>/config — verified as the worker verifies it, the card under the party id and the body under the card's current identity key.
Index ¶
- Variables
- func Hash(secret string) string
- func Verify(party, cardHdr, sig string, msg []byte) error
- type Frame
- type Held
- type Server
- func (s *Server) CloseSources()
- func (s *Server) Config() *Held
- func (s *Server) Connect(ctx context.Context, token, key string) (*Viewer, json.RawMessage, error)
- func (s *Server) Frames() []Frame
- func (s *Server) NoAck(off bool)
- func (s *Server) Puts() int
- func (s *Server) Refused() int
- func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (s *Server) Sources() int
- type Viewer
Constants ¶
This section is empty.
Variables ¶
var ( // ErrCard is a missing X-Peer-Card, one that does not decode, or a card // the party id did not sign. ErrCard = errors.New("X-Peer-Card is not this party's root-signed card") // ErrSignature is a signature the card's current identity key did not make. ErrSignature = errors.New("X-Peer-Signature is not the card's identity key's signature") )
Errors Verify returns, matched by the worker's codes.
Functions ¶
func Verify ¶
Verify is the check the worker makes on a config request: cardHdr (X-Peer-Card: base64url of signature ‖ card bytes) is party's root-signed card, and sig (X-Peer-Signature, base64url) is the XEdDSA signature of msg by the card's current identity key — the first key with no until. A signature by the root key, by another identity key, or under another party's card is refused.
Types ¶
type Frame ¶
type Frame struct {
Host string
Body json.RawMessage
}
Frame is one frame a source sent, as the Object saw it.
type Held ¶
type Held struct {
V int `json:"v"`
Party string `json:"party"`
At string `json:"at"`
Source string `json:"source"`
Readers []string `json:"readers"`
}
Held is the config the Object holds, as GET answers it.
type Server ¶
Server is one party's fake feed.
func Start ¶
Start serves a feed for party, over TLS as the worker is; Client() is the client that trusts it. A secret seeds the config as a PUT would — the source secret and the reader tokens admitted — so a test needs no setup; "" starts with no config, as a party's feed is before peer feed setup.
func (*Server) CloseSources ¶
func (s *Server) CloseSources()
CloseSources closes every source socket with 1001, as a deploy does.
func (*Server) Connect ¶
Connect opens a viewer with token and, when key is not "", the reader key its page holds; the hello's answer is returned.