Documentation
¶
Overview ¶
Package sanctum provides Go bindings for the Sanctum credential vault via CGo wrapping the sanctum-ffi C library.
Index ¶
- Constants
- Variables
- type Vault
- func (v *Vault) AuditLog(agentIDFilter string) (string, error)
- func (v *Vault) CheckPolicy(name string, agentID string) error
- func (v *Vault) Close()
- func (v *Vault) Delete(name string, agentID string) error
- func (v *Vault) ListCredentials(agentID string) (string, error)
- func (v *Vault) Retrieve(name string, agentID string) ([]byte, error)
- func (v *Vault) Store(name string, secret []byte, agentID string, policyJSON string) error
- func (v *Vault) UseCredential(name string, agentID string, operation string, params map[string]interface{}) (map[string]interface{}, error)
Constants ¶
const Version = "0.4.0"
Version is the SDK version. Matches the SanctumAI release tag.
Variables ¶
var ( ErrNullPointer = errors.New("sanctum: null pointer") ErrInvalidUTF8 = errors.New("sanctum: invalid UTF-8") ErrNotInitialized = errors.New("sanctum: vault not initialized") ErrAccessDenied = errors.New("sanctum: access denied") ErrNotFound = errors.New("sanctum: credential not found") ErrCrypto = errors.New("sanctum: cryptographic error") ErrBufferTooSmall = errors.New("sanctum: buffer too small") ErrJSON = errors.New("sanctum: JSON error") ErrPanic = errors.New("sanctum: panic caught at FFI boundary") ErrUnknown = errors.New("sanctum: unknown error") )
Functions ¶
This section is empty.
Types ¶
type Vault ¶
type Vault struct {
// contains filtered or unexported fields
}
Vault wraps an opaque SanctumVault handle from the FFI layer.
func Init ¶
Init creates and initializes a new vault at the given path with the supplied passphrase.
func (*Vault) AuditLog ¶
AuditLog returns the audit log as a JSON string. If agentIDFilter is non-empty, only entries for that agent are returned.
func (*Vault) CheckPolicy ¶
CheckPolicy checks whether an agent is allowed to retrieve a credential. Returns nil if allowed, ErrAccessDenied if not.
func (*Vault) Close ¶
func (v *Vault) Close()
Close frees the underlying vault handle. Safe to call multiple times.
func (*Vault) ListCredentials ¶
ListCredentials returns credential paths as a JSON array string.
func (*Vault) Store ¶
Store saves a credential in the vault. policyJSON may be empty for no policy; agentID identifies the storing agent.
func (*Vault) UseCredential ¶ added in v0.4.0
func (v *Vault) UseCredential(name string, agentID string, operation string, params map[string]interface{}) (map[string]interface{}, error)
UseCredential performs an operation using a credential without exposing the secret to the caller. This is the recommended way for agents to use credentials — the vault acts as a proxy so the agent never sees raw secrets.
Supported operations:
- "http_request" — make an HTTP request with the credential injected
- "http_header" — get an HTTP authorization header value
- "sign" — sign data (e.g. HMAC)
- "encrypt" — encrypt data
- "decrypt" — decrypt data
params is a map of operation-specific parameters (serialized to JSON internally). Returns the operation result as a map parsed from the JSON response.