vault

package
v0.16.521 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: AGPL-3.0 Imports: 12 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 vault carries an agent's request that the person's page log in on a site with the password safe: the origin check, the cleaning of the page's answer, the per-tab rate limit and the bridge over the sync socket. A value of the safe never passes through here, only a status.

Index

Constants

This section is empty.

Variables

View Source
var Statuses = []string{"logged-in", "not-logged-in", "needs-approval", "denied", "no-entry", "no-tab", "unavailable", "failed"}

Statuses a page may report.

Functions

func CLIReply

func CLIReply(o Outcome) (int, *jsvalue.Object)

CLIReply is the status and body the CLI gets for an outcome.

func Origin

func Origin(v any) string

Origin is the one spelling of a site a password belongs to, `https://host[:port]` (lowercase, no default port); "" for anything else: another scheme, a path, a query, `user@`, a trailing dot.

Types

type Bridge

type Bridge struct {
	Publish     func(event *jsvalue.Object)
	Subscribers func() int
	Now         func() time.Time
	Timeout     time.Duration
	// contains filtered or unexported fields
}

Bridge carries requests to the pages and answers back.

func NewBridge

func NewBridge(publish func(*jsvalue.Object), subscribers func() int) *Bridge

NewBridge is a bridge with the limit of six requests a tab in ten minutes.

func (*Bridge) Answer

func (b *Bridge) Answer(id string, r Result) bool

Answer settles a request with the first answer; false for a later one or an id never issued.

func (*Bridge) Dispatch

func (b *Bridge) Dispatch(tabID, origin string) Outcome

Dispatch asks the person's page to log in on origin for the tab and waits for the answer.

type Limiter

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

Limiter is a set of sliding windows per key, every rule at once. A refused take takes no slot, and keys whose stamps all left the longest window are dropped.

func NewLimiter

func NewLimiter(rules ...Rule) *Limiter

func (*Limiter) Take

func (l *Limiter) Take(key string, now int64) (bool, int64)

Take counts a take of key at now (ms); false and the wait until a slot frees when refused.

type Outcome

type Outcome struct {
	Kind   string
	Result Result
}

Outcome is how a request ended: answered (with Result), no-ui, timeout, busy or rate-limited.

type Result

type Result struct {
	Status, Message string
}

Result is how a login went, as the page says: a status and one safe line.

func ParseResult

func ParseResult(v any) *Result

ParseResult reads a page's answer; nil when it is not one.

func (Result) JSON

func (r Result) JSON() *jsvalue.Object

JSON is the result as the CLI reads it.

type Rule

type Rule struct {
	Limit  int
	Window time.Duration
}

Rule is one sliding window: at most Limit takes within Window.

Jump to

Keyboard shortcuts

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