Documentation
¶
Overview ¶
Package agentic reads the local agentic-wallet config and signs requests as that wallet.
Requests authenticate with the wallet's own HMAC secret rather than the user's bearer token. The signature proves possession of one specific wallet's secret, so a caller can only ever read the wallet it actually holds, and no endpoint has to accept "tell me about wallet X" from an account that merely has access to the platform.
Index ¶
Constants ¶
const ( HeaderSubOrg = "X-KH-Sub-Org" HeaderTimestamp = "X-KH-Timestamp" HeaderSignature = "X-KH-Signature" )
Header names carrying the signature. The platform also accepts an optional X-KH-Key-Version to pin secret selection during rotation; it is deliberately not sent, so an unpinned request is verified against every active secret and keeps working through the rotation grace window.
const ConfigName = "wallet.json"
ConfigName is the file `kh wallet add` writes, mode 0600.
Variables ¶
var ErrIncompleteConfig = errors.New("agentic wallet config is incomplete")
ErrIncompleteConfig reports a config file that is present but missing a field needed to use it. Distinct from ErrNotConfigured so a caller can say "the file is there and broken" rather than sending someone to re-run the command that already wrote it.
var ErrNotConfigured = errors.New("no agentic wallet configured")
ErrNotConfigured reports that no agentic wallet exists on this machine. It is a normal state, not a failure: most installs never provision one.
Functions ¶
func ConfigPath ¶
ConfigPath returns the location of the agentic wallet config.
func Sign ¶
Sign returns the hex HMAC-SHA256 over `method\npath\nsubOrgId\nsha256_hex(body)\ntimestamp`, the format the platform verifies. path is the URL pathname only, with no host or query. A GET signs over an empty body.
func SignRequest ¶
SignRequest attaches the signature headers to req.
The signed path is taken from req.URL, never from a caller-supplied constant. The platform signs the pathname it actually received, so a host configured with a path prefix would otherwise produce a signature over a different string and come back 401, which reads as a rotated secret rather than a configuration problem.
body must be the exact bytes sent; a GET signs over an empty string.
Types ¶
type Config ¶
type Config struct {
SubOrgID string `json:"subOrgId"`
WalletAddress string `json:"walletAddress"`
HMACSecret string `json:"hmacSecret"`
}
Config is the on-disk agentic wallet. HMACSecret must never be printed or logged; it is the wallet's only credential.