Documentation
¶
Overview ¶
Package app is the product facade. CLI and MCP are thin wrappers around it.
Index ¶
- Constants
- Variables
- func Accept(dir string, priv, blob []byte) error
- func IsSessionToken(raw string) bool
- type App
- func (a *App) AddAgent(name string) (protocol.Principal, error)
- func (a *App) AddAgentFor(owner protocol.Principal, name string) (protocol.Principal, error)
- func (a *App) AddGrant(agentID, itemID string, level protocol.GrantLevel) (protocol.Grant, error)
- func (a *App) AddGroup(actor protocol.Principal, name string) (protocol.Group, error)
- func (a *App) AddItem(name, uri string, secret []byte) (protocol.Item, error)
- func (a *App) AgentFromOIDC(ctx context.Context, rawToken string) (protocol.Principal, error)
- func (a *App) Approve(grantID string, ttl time.Duration) (protocol.Approval, error)
- func (a *App) ApproveOIDC(ctx context.Context, grantID, rawToken string, ttl time.Duration) (protocol.Approval, error)
- func (a *App) ApproveRequest(reqID string, ttl time.Duration) (protocol.ApprovalRequest, error)
- func (a *App) ArchiveItem(name string) error
- func (a *App) ArchiveItemFor(actor protocol.Principal, name string) error
- func (a *App) AttachTOTP(p protocol.Principal, itemID, seed string) error
- func (a *App) BillingCheckoutURL(ctx context.Context, orgID string) (string, error)
- func (a *App) BindWorkload(agentID, issuer, subject, audience string) (protocol.Workload, error)
- func (a *App) BindWorkloadFor(actor protocol.Principal, agentID, issuer, subject, audience string) (protocol.Workload, error)
- func (a *App) BindWorkloadForWithClaims(actor protocol.Principal, agentID, issuer, subject, audience string, ...) (protocol.Workload, error)
- func (a *App) BindWorkloadWithClaims(agentID, issuer, subject, audience string, claims map[string][]string) (protocol.Workload, error)
- func (a *App) CanCreateGrant(p protocol.Principal) (bool, error)
- func (a *App) ChildEnv(ctx context.Context, agentID string) ([]string, error)
- func (a *App) Close() error
- func (a *App) CreateSession(actor protocol.Principal, agentID string, ttl time.Duration, maxUses int) (protocol.Session, string, error)
- func (a *App) DeleteItem(name string) error
- func (a *App) DeleteItemFor(actor protocol.Principal, name string) error
- func (a *App) DeleteMe(ctx context.Context, rawToken string) error
- func (a *App) DeleteOrg(ctx context.Context, rawToken string) (store.PurgeReport, error)
- func (a *App) DemoteOwner(ctx context.Context, rawToken, memberID string) error
- func (a *App) FillLogin(p protocol.Principal, uuid string, mintTotp bool) (FillEntry, error)
- func (a *App) FillLogins(p protocol.Principal, rawURL string) ([]FillEntry, error)
- func (a *App) FillPasskeyGet(p protocol.Principal, origin string, publicKey json.RawMessage) (json.RawMessage, error)
- func (a *App) FillPasskeyRegister(p protocol.Principal, origin string, publicKey json.RawMessage, ...) (json.RawMessage, error)
- func (a *App) FillSync(p protocol.Principal, since string) ([]FillSyncRow, string, error)
- func (a *App) FillTOTP(p protocol.Principal, itemID string, now time.Time) (string, error)
- func (a *App) GrantSubject(actor protocol.Principal, kind protocol.SubjectKind, subject, itemID string, ...) (protocol.Grant, error)
- func (a *App) GrantUntil(actor protocol.Principal, grantee, itemID string, level protocol.GrantLevel, ...) (protocol.Grant, error)
- func (a *App) GroupAddMember(actor protocol.Principal, groupName string, kind protocol.PrincipalKind, ...) error
- func (a *App) GroupMemberList(actor protocol.Principal, groupName string) ([]protocol.GroupMember, error)
- func (a *App) GroupRemoveMember(actor protocol.Principal, groupName string, kind protocol.PrincipalKind, ...) error
- func (a *App) Groups(actor protocol.Principal) ([]protocol.Group, error)
- func (a *App) ImportItems(p protocol.Principal, rows []oneimport.Row) (ImportResult, error)
- func (a *App) InjectFile(src, dest string, pairs []string) error
- func (a *App) InviteHuman(ctx context.Context, rawToken, email string) (InviteResult, error)
- func (a *App) ItemsForAgent(agentID string) ([]protocol.Item, error)
- func (a *App) ItemsForPrincipal(p protocol.Principal) ([]protocol.Item, error)
- func (a *App) ListSessions(actor protocol.Principal) ([]protocol.Session, error)
- func (a *App) Match(p protocol.Principal, rawURL string) ([]protocol.Item, error)
- func (a *App) MayWriteItem(p protocol.Principal, item protocol.Item) (bool, error)
- func (a *App) Offer(peerPub []byte) ([]byte, error)
- func (a *App) OwnsVault(p protocol.Principal) (bool, error)
- func (a *App) PrincipalFromOIDC(ctx context.Context, rawToken string) (protocol.Principal, error)
- func (a *App) PrincipalFromSession(rawToken string) (protocol.Principal, error)
- func (a *App) PromoteOwner(ctx context.Context, rawToken, memberID string) error
- func (a *App) ProvisionHuman(ctx context.Context, rawToken string) (protocol.Principal, error)
- func (a *App) PutItem(opts ItemOpts) (protocol.Item, error)
- func (a *App) PutItemFor(p protocol.Principal, opts ItemOpts) (protocol.Item, error)
- func (a *App) RecordFillEvents(p protocol.Principal, evs []FillEventReport) error
- func (a *App) RemoveMember(ctx context.Context, rawToken, memberID string) error
- func (a *App) RenewSession(actor protocol.Principal, id string) (protocol.Session, error)
- func (a *App) RevokeAgent(actor protocol.Principal, agentID string) error
- func (a *App) RevokeSession(actor protocol.Principal, id string) (protocol.Session, error)
- func (a *App) RotateDue(now time.Time, maxItems int) (int, error)
- func (a *App) RotateItem(actor protocol.Principal, name string) (protocol.Item, error)
- func (a *App) RotateItemWith(actor protocol.Principal, name string, opts RotateOpts) (protocol.Item, error)
- func (a *App) SecurityReport(ctx context.Context, p protocol.Principal, check health.Checker) (health.Report, error)
- func (a *App) StartRotationTicker()
- func (a *App) UnbindWorkloadFor(actor protocol.Principal, agentID, issuer, subject string) error
- func (a *App) UpdateItem(name string, replaceURIs, addURIs, tags []string, login string, token []byte) (protocol.Item, error)
- func (a *App) UpdateItemFor(actor protocol.Principal, name string, replaceURIs, addURIs, tags []string, ...) (protocol.Item, error)
- func (a *App) Use(ctx context.Context, agentID, itemID, method, rawURL string) (protocol.UseResult, error)
- func (a *App) UseCheck(ctx context.Context, agentID, itemID, method, rawURL string) (protocol.UseResult, error)
- func (a *App) UseFetch(ctx context.Context, agentID, itemID string, fetch protocol.Fetch) (protocol.UseResult, error)
- func (a *App) UseFetchSession(ctx context.Context, rawToken, itemID string, fetch protocol.Fetch) (protocol.UseResult, error)
- func (a *App) UseSession(ctx context.Context, rawToken, itemID, method, rawURL string) (protocol.UseResult, error)
- func (a *App) VerifyIssuer(ctx context.Context, actor protocol.Principal, issuer string) (workload.VerifyResult, error)
- func (a *App) VerifyItem(ctx context.Context, actor protocol.Principal, name string) (string, error)
- func (a *App) WorkloadsForAgent(actor protocol.Principal, agentID string) ([]protocol.Workload, error)
- func (a *App) WriteFile(name, dest string) error
- type FillEntry
- type FillEventReport
- type FillSyncRow
- type HumanVerifier
- type ImportResult
- type InviteResult
- type Inviter
- type ItemOpts
- type MemberCheck
- type OrgAdmin
- type Provisioner
- type RequestNotify
- type RotateOpts
Constants ¶
const ( DefaultOrg = protocol.LocalOrgID DefaultHuman = "self" )
const ( SessionPrefix = "ses_" SessionTTLDefault = 15 * time.Minute SessionTTLMax = time.Hour )
Variables ¶
var ( ErrTOTPEnrollDenied = errors.New("app: totp enroll denied") ErrAgentRevoked = errors.New("app: agent revoked") )
var ( ErrForbidden = errors.New("app: forbidden") ErrSessionExpired = errors.New("app: session expired") ErrSessionRevoked = errors.New("app: session revoked") ErrSessionExhausted = errors.New("app: session uses exhausted") )
var ErrBillingDisabled = errors.New("app: billing checkout not configured")
ErrBillingDisabled — checkout/reporting needs the Vortex wiring (VEIL_VORTEX_* envs) plus VEIL_VORTEX_PRICE_ID for the plan price.
var ErrExists = errors.New("app: vault already exists")
ErrIdentityUnavailable marks dependency failures in the identity plane (Keto membership, Hydra verification) — distinct from bad credentials so API callers see 503-unavailable instead of a misleading 401.
var ErrInviteLimit = errors.New("app: invite rate limit")
ErrInviteLimit is returned when an inviter or a recipient address has hit the invite ceiling for the window. The API maps it to 429.
ErrUnauthorized marks token/principal resolution failure on verbs that distinguish it from a bad argument — the API maps it to 401, not 400.
Functions ¶
func Accept ¶
Accept writes device.key and a wrap. Not a second vault. Not plaintext master. Copy vault.db and config.json yourself. This is not sync.
func IsSessionToken ¶
Types ¶
type App ¶
type App struct {
Dir string
OrgID string
HumanID string
Store store.Store
Auditor audit.Auditor
Broker *broker.Broker
Human HumanVerifier
Workload *workload.Checker
Members MemberCheck
Provision Provisioner
Invites Inviter
OrgAdmin OrgAdmin
Notify RequestNotify
// Push wakes registered phone devices on a filed ask — the same
// RequestNotify shape as email, fanned out next to it. Nil when the
// APNs envs are unset.
Push RequestNotify
// BillingCustomers is the merchant-scoped Vortex client — nil when the
// VEIL_VORTEX_* envs are unset (billing off; dev and tests unaffected).
BillingCustomers *billing.Client
// contains filtered or unexported fields
}
func OpenOrInit ¶
OpenOrInit opens an existing vault, or creates one when there is no key material. A stray vault.db without wraps or master.key is not "empty" — Init would hit ErrExists and Open would print the misleading master.key miss that Railway crash-looped on.
func OpenPostgres ¶
OpenPostgres opens a stateless origin backed by a Postgres DSN. The deployment KEK is read from the VEIL_KEK environment variable (hex) and seals per-org master keys in org_keys. VEIL_MASTER_KEY is the pre-multi-org legacy: when set, it is seeded once as this org's wrapped master and can be removed afterward.
func (*App) AddAgentFor ¶
AddAgentFor registers an agent owned by the calling human, in their org.
func (*App) AgentFromOIDC ¶
func (*App) ApproveOIDC ¶
func (a *App) ApproveOIDC(ctx context.Context, grantID, rawToken string, ttl time.Duration) (protocol.Approval, error)
ApproveOIDC is Approve with a Hydra ID token. An approval mints the credential release — the same owner-scope as administering the grant. Planted `self` is the laptop stand-in when no issuer is configured.
func (*App) ApproveRequest ¶
ApproveRequest resolves one pending ask locally — the approval lands only while the ask is open; a lost race is ErrRequestResolved, no side effects.
func (*App) ArchiveItem ¶
func (*App) ArchiveItemFor ¶
func (*App) BillingCheckoutURL ¶
BillingCheckoutURL mints the org's hosted upgrade link — the owner clicks it, pays, and the subscription webhook flips the plan. Provisions the billing link lazily so orgs that predate billing (or hit a provisioning outage) can still upgrade. ErrBillingDisabled when checkout isn't wired.
func (*App) BindWorkload ¶
func (*App) BindWorkloadFor ¶
func (a *App) BindWorkloadFor(actor protocol.Principal, agentID, issuer, subject, audience string) (protocol.Workload, error)
BindWorkloadFor enrolls a workload identity on behalf of actor — owner only, same bar as grants: binding an auth method to a foreign agent is a grant-adjacent write.
func (*App) BindWorkloadForWithClaims ¶
func (*App) BindWorkloadWithClaims ¶
func (*App) CreateSession ¶
func (*App) DeleteItem ¶
func (*App) DeleteItemFor ¶
func (*App) DeleteMe ¶
DeleteMe is the human kill-switch: drop both tuple legs and the humans row — the token resolves nothing from this point. A sole owner cannot leave an org with members in it: promote someone, or delete the org.
func (*App) DeleteOrg ¶
DeleteOrg is teardown: kill every access path first (Keto tuples), then purge every vault row for the org in one transaction. Audit rows survive — teardown must not erase the record of what happened.
func (*App) DemoteOwner ¶
DemoteOwner strips the owners tuple — the last owner cannot be demoted or the org has no one who can administer it.
func (*App) FillLogin ¶
FillLogin decrypts one item. mintTotp puts a 6-digit code in TOTP instead of "*".
func (*App) FillLogins ¶
func (*App) FillPasskeyGet ¶
func (a *App) FillPasskeyGet(p protocol.Principal, origin string, publicKey json.RawMessage) (json.RawMessage, error)
func (*App) FillPasskeyRegister ¶
func (a *App) FillPasskeyRegister(p protocol.Principal, origin string, publicKey json.RawMessage, extraURIs []string) (json.RawMessage, error)
func (*App) FillSync ¶
FillSync is the replica pull. Human only. since is reserved; this cut is a full pull.
func (*App) GrantSubject ¶
func (a *App) GrantSubject(actor protocol.Principal, kind protocol.SubjectKind, subject, itemID string, level protocol.GrantLevel, expires *time.Time) (protocol.Grant, error)
GrantSubject is GrantUntil widened to a subject kind (VEIL-20): an agent or human is the same direct grant; a group subject makes an org-owned item plus this grant the shared vault — one row instead of one grant per member. level=deny writes the explicit block that beats inherited allows.
func (*App) GrantUntil ¶
func (a *App) GrantUntil(actor protocol.Principal, grantee, itemID string, level protocol.GrantLevel, expires *time.Time) (protocol.Grant, error)
GrantUntil grants grantee access to itemID on behalf of actor. The grant lives in the item's org; a grantee outside it is not a grantee, and an agent owned by a different human is not the actor's to delegate.
func (*App) GroupAddMember ¶
func (*App) GroupMemberList ¶
func (a *App) GroupMemberList(actor protocol.Principal, groupName string) ([]protocol.GroupMember, error)
GroupMemberList returns a group's members — owner-administered.
func (*App) GroupRemoveMember ¶
func (*App) ImportItems ¶
func (*App) InviteHuman ¶
InviteHuman is the private-alpha gate: a verified, provisioned human invites an email into their org. The identity and recovery link live in Kratos; owner-ness is enforced by the Inviter (Keto) inside glue.
func (*App) ItemsForPrincipal ¶
func (*App) ListSessions ¶
func (*App) MayWriteItem ¶
func (*App) Offer ¶
Offer wraps master to a second device's public key. nacl box. The blob is not JSON. The grant does not get a copy. Master is not a file.
func (*App) PrincipalFromOIDC ¶
PrincipalFromOIDC is origin identity. Session lease first. Bound agent next. Else Hydra human plus Keto membership. Grants stay in the vault.
func (*App) PrincipalFromSession ¶
func (*App) PromoteOwner ¶
PromoteOwner grants an existing member the owners tuple.
func (*App) ProvisionHuman ¶
ProvisionHuman is signup. A verified human with no vault row gets an org (new UUID), an org master minted and sealed under the KEK via EnsureOrgKey, Keto owner+member tuples, and the Kratos organization_id stamp — all the same join key. Idempotent: a planted human returns their existing org, and a retry after a mid-flight failure resumes from the anchored humans row rather than minting a second org.
func (*App) PutItemFor ¶
func (*App) RecordFillEvents ¶
func (a *App) RecordFillEvents(p protocol.Principal, evs []FillEventReport) error
func (*App) RemoveMember ¶
RemoveMember offboards a member: drops the Keto tuple and the humans row — their token stops resolving immediately. Owners cannot be removed this way; demote first (or delete the org).
func (*App) RenewSession ¶
func (*App) RevokeSession ¶
func (*App) RotateDue ¶
RotateDue rotates up to maxItems items whose sealed NextRotateAt watermark is due at now. Egress contract (AGENTS.md rule 9): zero Postgres writes and zero outbound provider calls when no item is due; bounded to maxItems per invocation so a backlog drains across ticks without a burst.
func (*App) RotateItem ¶
RotateItem swaps an item's credential server-side: the provider's key-management API mints a replacement, the new secret is verified and sealed in place — item id and grants are untouched, agents keep calling Use. Retire of the old provider key is best-effort and audited either way. Owner-only: rotation is vault administration, not a grant.
func (*App) RotateItemWith ¶
func (*App) SecurityReport ¶
func (a *App) SecurityReport(ctx context.Context, p protocol.Principal, check health.Checker) (health.Report, error)
SecurityReport is the vault health report — weak, reused, and optionally breached passwords across what the principal can see. Human only, like fill: the report reads sealed material in-process and emits metadata only. check is nil for the default offline report; pass health.HIBP{}.Check to opt into k-anonymity breach lookup.
func (*App) StartRotationTicker ¶
func (a *App) StartRotationTicker()
StartRotationTicker runs RotateDue once per hour (max 20 due items/tick). Egress rate (AGENTS.md rule 9): 0 bytes/tick when no item has next_rotate_at <= now; bounded to <=20 provider rotations/hour when due.
func (*App) UnbindWorkloadFor ¶
func (*App) UpdateItem ¶
func (*App) UpdateItemFor ¶
func (a *App) UpdateItemFor(actor protocol.Principal, name string, replaceURIs, addURIs, tags []string, login string, token []byte) (protocol.Item, error)
UpdateItemFor is UpdateItem attributed to an explicit actor — the HTTP layer's write-gated path.
func (*App) UseCheck ¶
func (a *App) UseCheck(ctx context.Context, agentID, itemID, method, rawURL string) (protocol.UseResult, error)
UseCheck evaluates a Use without executing it: grant + approval checks run (and the need_approval ask is filed) but no use is claimed and the secret is never touched. Agents pre-flight with it; humans see the ask.
func (*App) UseFetchSession ¶
func (*App) UseSession ¶
func (*App) VerifyIssuer ¶
func (a *App) VerifyIssuer(ctx context.Context, actor protocol.Principal, issuer string) (workload.VerifyResult, error)
VerifyIssuer dry-runs an OIDC issuer discovery for actor (owner-only).
func (*App) VerifyItem ¶
func (a *App) VerifyItem(ctx context.Context, actor protocol.Principal, name string) (string, error)
VerifyItem dry-runs an item's credential (WIF jwt-bearer exchange, OAuth refresh, or provider rotator Verify) without revealing the secret. Owner-only.
func (*App) WorkloadsForAgent ¶
type FillEntry ¶
FillEntry is native-host material. Not protocol.Item. Not MCP. Login is the fill username from the sealed envelope. Empty if unset. Never fall back to item.Name on the URL form. TOTP is "*" when a seed exists so KeePassXC-Browser will call get-totp. FillLogin(mintTotp) puts a 6-digit code instead. Never the seed.
type FillEventReport ¶
FillEventReport is a client-reported disclosure. When the fill host serves a secret from the sealed replica instead of calling origin, it attests the release here so the audit feed sees the same row an online fill writes. At is the client's fill time — a queued report can land long after it happened. Kind is the client's claim; for a known item the store's kind wins. Unknown or cross-org uuids still record, under the reporter's org — a lost audit is worse than a row that cannot name its item's true kind.
type FillSyncRow ¶
FillSyncRow is one replica pull record. Material is the envelope JSON. Not protocol.Item. Not MCP. Not OpenAPI.
type HumanVerifier ¶
HumanVerifier verifies a human bearer token down to its subject. *human.Verifier is the production impl.
type ImportResult ¶
type ImportResult struct {
Names []string `json:"names"`
Count int `json:"count"`
// Kind breakdown of what actually imported — "login":47 reads better
// than a bare count after a 400-row export.
Kinds map[string]int `json:"kinds,omitempty"`
// Skipped names already in the vault. Local CLI shows them; the origin
// ImportResponse schema is names+count only (spec is SDK-locked).
Skipped []string `json:"skipped,omitempty"`
}
type InviteResult ¶
InviteResult is what an owner gets back from an invite: the new identity, whether the email went out, and the recovery link when it did not.
type Inviter ¶
type Inviter interface {
Invite(ctx context.Context, email, actor, orgID string) (InviteResult, error)
}
Inviter creates a Kratos identity plus recovery link under the owner's org. glue.Glue satisfies it via a thin adapter; nil in local vaults.
type ItemOpts ¶
type ItemOpts struct {
ID string
Name string
URI string
URIs []string
Tags []string
Kind protocol.ItemKind
Token []byte
Login string
TOTPSeed []byte
Refresh []byte
TokenURL string
ClientID string
ClientSecret []byte
FileName string
MIME string
File []byte
Passkey []byte
WIF *material.WIFOpts
Owner protocol.Owner
// OrgID is the caller's org. Empty falls back to the deployment default —
// the local vault path; the origin always sets it from the principal.
OrgID string
}
type MemberCheck ¶
type MemberCheck interface {
IsMember(ctx context.Context, orgID, identityID string) (bool, error)
IsOwner(ctx context.Context, orgID, identityID string) (bool, error)
}
MemberCheck is identity-plane owner/member. Keto via glue. Not grants.
type OrgAdmin ¶
type OrgAdmin interface {
RemoveMember(ctx context.Context, orgID, identityID string) error
RemoveOwner(ctx context.Context, orgID, identityID string) error
PromoteOwner(ctx context.Context, orgID, identityID string) error
RemoveOrgTuples(ctx context.Context, orgID string) error
ListOwners(ctx context.Context, orgID string) ([]string, error)
}
OrgAdmin is org membership surgery against the identity plane — Keto tuple writes/deletes. glue.Glue satisfies it; nil in local vaults.
type Provisioner ¶
type Provisioner interface {
ProvisionMember(ctx context.Context, orgID, identityID string) error
SetIdentityOrg(ctx context.Context, identityID, orgID string) error
IdentityOrg(ctx context.Context, identityID string) (string, error)
}
Provisioner plants a human's membership in their org: Keto tuples plus the Kratos organization_id stamp. glue.Glue satisfies it; nil in local vaults. IdentityOrg reads the stamp — an invite sets it, and provisioning honors it.
type RequestNotify ¶
type RequestNotify interface {
NotifyRequest(ctx context.Context, req protocol.ApprovalRequest) error
}
RequestNotify pings org owners when an ask lands — veil-mail via glue; nil in local vaults. Best-effort: the request row is the durable part.