Documentation
¶
Overview ¶
Package secret generates and hashes credentials. Plaintext secrets are shown once at creation; only SHA-256 digests (for high-entropy tokens) or argon2id hashes (for passwords) are stored.
Index ¶
- Constants
- Variables
- func Display(plain string) string
- func Equal(a, b string) bool
- func Hash(s string) string
- func HashPassword(password string) string
- func NewAPIKey() (plain, hash, display string)
- func NewAgentToken() (plain, hash, display string)
- func NewToken(prefix string, length int) (plain, hash, display string)
- func PKCEVerify(verifier, challenge, method string) bool
- func Random(n int) string
- func RandomURLSafe(n int) string
- func VerifyPassword(encoded, password string) bool
Constants ¶
const ( APIKeyPrefix = "sk-sb-" AgentTokenPrefix = "sba_" OAuthTokenPrefix = "sbo_" RefreshPrefix = "sbr_" )
Variables ¶
var ErrInvalid = errors.New("invalid credential")
ErrInvalid is returned by verifiers when a credential does not match.
Functions ¶
func HashPassword ¶
HashPassword returns a PHC-formatted argon2id hash.
func NewAPIKey ¶
func NewAPIKey() (plain, hash, display string)
NewAPIKey mints an OpenAI-style API key.
func NewAgentToken ¶
func NewAgentToken() (plain, hash, display string)
NewAgentToken mints a static MCP bearer token.
func NewToken ¶
NewToken returns a fresh token with the given prefix plus its hash and a display prefix.
func PKCEVerify ¶
PKCEVerify checks an OAuth PKCE verifier against an S256 challenge.
func RandomURLSafe ¶
RandomURLSafe returns a base64url string with n random bytes of entropy.
func VerifyPassword ¶
VerifyPassword checks password against a hash produced by HashPassword.
Types ¶
This section is empty.