Documentation
¶
Overview ¶
Package material is the sealed payload for an item.
Token is the API key / password. TOTP is the base32 *seed*, never a 6-digit code. Codes are minted at inject time with pquerna/otp (https://pkg.go.dev/github.com/pquerna/otp/totp — GenerateCode).
Index ¶
- Constants
- func AccessToken(ctx context.Context, env Envelope, client *http.Client) (string, error)
- func AccessTokenWithMetadata(ctx context.Context, env Envelope, client *http.Client) (access, nextRefresh, extraScrub string, err error)
- func AccessTokenWithRefresh(ctx context.Context, env Envelope, client *http.Client) (access, nextRefresh string, err error)
- func Apply(h http.Header, env Envelope, now time.Time) (code string, err error)
- func AuthorizationValue(token string) string
- func FileBytes(env Envelope) ([]byte, error)
- func Mint(seed string, now time.Time) (string, error)
- func Pack(token, totpSeed []byte) ([]byte, error)
- func PackCard(number, expMonth, expYear, cvv, name string) ([]byte, error)
- func PackFile(name, mime string, body []byte) ([]byte, error)
- func PackIdentity(given, family, address, city, region, postal, country, phone, email string) ([]byte, error)
- func PackOAuth(refresh, tokenURL, clientID, clientSecret []byte) ([]byte, error)
- func PackPasskey(pem, credID, rpID, userHandle string) ([]byte, error)
- func PackWIF(opts WIFOpts) ([]byte, error)
- func ScrubList(env Envelope, extra ...[]byte) [][]byte
- func WithLogin(raw []byte, login string) ([]byte, error)
- func WithRefresh(raw []byte, refresh string) ([]byte, error)
- func WithRotatedToken(raw, token []byte, keyID, pendingKeyID string) ([]byte, error)
- func WithRotatedTokenMeta(raw, token []byte, keyID, pendingKeyID, mgmtItemID, interval string, ...) ([]byte, error)
- func WithToken(raw, token []byte) ([]byte, error)
- type Envelope
- type TokenCache
- type WIFOpts
Constants ¶
const ( Version = 1 HeaderTOTP = "X-TOTP" MaxFile = 8 << 20 )
Variables ¶
This section is empty.
Functions ¶
func AccessToken ¶
AccessToken follows Authsome's "log in once" pattern. Refresh stays here. golang.org/x/oauth2 performs the refresh. The access token is for inject only.
func AccessTokenWithMetadata ¶
func AccessTokenWithMetadata(ctx context.Context, env Envelope, client *http.Client) (access, nextRefresh, extraScrub string, err error)
AccessTokenWithMetadata is AccessTokenWithRefresh plus any intermediate secret material (such as a minted WIF assertion JWT) that the caller must include in response scrubbing.
func AccessTokenWithRefresh ¶
func AccessTokenWithRefresh(ctx context.Context, env Envelope, client *http.Client) (access, nextRefresh string, err error)
AccessTokenWithRefresh performs the OAuth refresh (or RFC 7523 jwt-bearer WIF exchange when FederationRuleID is set) and also returns any rotated refresh token issued by the provider so the broker can persist it.
func AuthorizationValue ¶
AuthorizationValue is the Authorization header for an injected token. Stripe/GitHub/OpenAI want Bearer. Linear API keys (lin_api_) reject it.
func PackIdentity ¶
func PackPasskey ¶
func WithLogin ¶
WithLogin puts the fill username in the sealed blob. Empty login leaves raw unchanged. Item list and MCP never see this field.
func WithRefresh ¶
WithRefresh seals a rotated OAuth refresh token into an existing envelope, preserving all other fields.
func WithRotatedToken ¶
WithRotatedToken seals a rotated token and the dual-phase provider key IDs in one envelope. Item list and MCP never see these fields.
func WithRotatedTokenMeta ¶
func WithRotatedTokenMeta(raw, token []byte, keyID, pendingKeyID, mgmtItemID, interval string, nextRotateAt int64) ([]byte, error)
WithRotatedTokenMeta seals a rotated token, dual-phase key IDs, and optional management-credential / rotation-schedule metadata inside the envelope.
Types ¶
type Envelope ¶
type Envelope struct {
V int `json:"v"`
Token string `json:"token,omitempty"`
Login string `json:"login,omitempty"`
TOTP string `json:"totp,omitempty"`
Refresh string `json:"refresh,omitempty"`
TokenURL string `json:"token_url,omitempty"`
ClientID string `json:"client_id,omitempty"`
ClientSec string `json:"client_secret,omitempty"`
FileName string `json:"file_name,omitempty"`
MIME string `json:"mime,omitempty"`
FileB64 string `json:"file_b64,omitempty"`
PasskeyPEM string `json:"passkey_pem,omitempty"`
CredID string `json:"cred_id,omitempty"`
RpID string `json:"rp_id,omitempty"`
UserHandle string `json:"user_handle,omitempty"`
Number string `json:"number,omitempty"`
ExpMonth string `json:"exp_month,omitempty"`
ExpYear string `json:"exp_year,omitempty"`
CVV string `json:"cvv,omitempty"`
GivenName string `json:"given_name,omitempty"`
FamilyName string `json:"family_name,omitempty"`
Address string `json:"address,omitempty"`
City string `json:"city,omitempty"`
Region string `json:"region,omitempty"`
Postal string `json:"postal,omitempty"`
Country string `json:"country,omitempty"`
Phone string `json:"phone,omitempty"`
Email string `json:"email,omitempty"`
KeyID string `json:"key_id,omitempty"`
PendingKeyID string `json:"pending_key_id,omitempty"`
ManagementItemID string `json:"management_item_id,omitempty"`
RotateInterval string `json:"rotate_interval,omitempty"`
NextRotateAt int64 `json:"next_rotate_at,omitempty"`
AssertionTokenURL string `json:"assertion_token_url,omitempty"`
AssertionClientID string `json:"assertion_client_id,omitempty"`
AssertionClientSec string `json:"assertion_client_secret,omitempty"`
AssertionAudience string `json:"assertion_audience,omitempty"`
FederationRuleID string `json:"federation_rule_id,omitempty"`
FederationOrgID string `json:"federation_org_id,omitempty"`
ServiceAccountID string `json:"service_account_id,omitempty"`
WorkspaceID string `json:"workspace_id,omitempty"`
}
type TokenCache ¶
type TokenCache struct {
// contains filtered or unexported fields
}
TokenCache caches short-lived access tokens minted from OAuth refresh or RFC 7523 WIF exchanges until expiresAt - 60s headroom, keyed by a SHA-256 digest of the envelope's token-minting inputs. Rotating or editing the item's secret changes the digest and invalidates the entry automatically.
func NewTokenCache ¶
func NewTokenCache() *TokenCache
type WIFOpts ¶
type WIFOpts struct {
TokenURL string
AssertionTokenURL string
AssertionClientID string
AssertionSecret string
AssertionAudience string
FederationRuleID string
OrganizationID string
ServiceAccountID string
WorkspaceID string
}
WIFOpts configures an outbound RFC 7523 jwt-bearer Workload Identity Federation item (such as Anthropic's POST /v1/oauth/token) so Veil mints a short-lived upstream access token per use without storing a static API key.