Store API keys and tokens, shown once and masked after.
Secrets
BILLING_API_KEYAPI key
ProductionExpires Jan 14, 2027
Saved Oct 14, 2026 by Maya Chen · ends in 4f2a · Used by 3 workflows
WEBHOOK_SIGNING_SECRETSigning secret
ProductionPreview
Saved Nov 2, 2026 by Maya Chen · ends in 91c0
LEGACY_CRM_TOKENToken
PreviewExpired Nov 28
Saved May 30, 2026 · ends in 0b17
import { UiSchema } from "@effect/ui"import { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { Redacted, Schema } from "effect"import { SecretField, SecretValues, ShownOnce, Vault, VaultItem } from "./ui/uicontext/components/kit/Secret.ts"import { sx } from "./ui/uicontext/components/Sx.ts"const styles = stylex.create({ frame: { inlineSize: "min(100%, 40rem)", display: "flex", flexDirection: "column", gap: 16 } })const Message = UiSchema.TaggedEnum({ Rotated: { id: Schema.String }, Removed: { id: Schema.String }, Replaced: { id: Schema.String }, Done: {}, RequestedAddSecret: {}, SavedNewSecret: { values: SecretValues }, CancelledNewSecret: {},})const maya = { id: "maya", name: "Maya Chen", kind: "person" } as constconst seed: ReadonlyArray<VaultItem> = [ { id: "billing", name: "BILLING_API_KEY", kind: "API key", scopes: ["Production"], expires: "Expires Jan 14, 2027", saved: { at: "2026-10-14T09:12:00Z", actor: maya, hint: "ends in 4f2a" }, usedBy: "Used by 3 workflows", can: ["rotate", "remove"], rotateWarning: "The old key keeps working for 24 hours, then the 3 workflows that use it need the new one.", }, { id: "webhook", name: "WEBHOOK_SIGNING_SECRET", kind: "Signing secret", scopes: ["Production", "Preview"], saved: { at: "2026-11-02T16:40:00Z", actor: maya, hint: "ends in 91c0" }, can: ["replace", "rotate", "remove"], }, { id: "legacy", name: "LEGACY_CRM_TOKEN", kind: "Token", scopes: ["Preview"], expires: "Expired Nov 28", expired: true, saved: { at: "2026-05-30T10:00:00Z", hint: "ends in 0b17" }, removeWarning: "Nothing uses it any more.", can: ["replace", "remove"], },]export const ProjectSecrets = Html.component({ name: "ProjectSecrets", model: Schema.Struct({ items: Schema.Array(VaultItem), fresh: Schema.NullOr(Schema.String), adding: Schema.Boolean, added: Schema.Number }), message: Message,}).make({ init: () => ({ items: seed, fresh: null, adding: false, added: 0 }), update: { // a real app asks its server for the new value; here it's made up Rotated: ($, { id }) => $.evolve({ fresh: id, items: (items) => items.map((i) => (i.id === id ? { ...i, saved: { at: "2026-12-01T10:00:00Z", actor: maya, hint: "ends in 7d3e" } } : i)), }), Removed: ($, { id }) => $.evolve({ items: (items) => items.filter((i) => i.id !== id) }), Replaced: ($, { id }) => $.evolve({ items: (items) => items.map((i) => (i.id === id ? { ...i, saved: { at: "2026-12-01T10:00:00Z", actor: maya } } : i)) }), Done: ($) => $.evolve({ fresh: null }), RequestedAddSecret: ($) => $.evolve({ adding: true }), CancelledNewSecret: ($) => $.evolve({ adding: false }), // a real app sends the value to its vault and keeps only a hint; the name is plain text SavedNewSecret: ($, { values }) => { const name = values["name"] === undefined ? "" : Redacted.value(values["name"]).trim().toUpperCase() const value = values["value"] === undefined ? "" : Redacted.value(values["value"]) return $.evolve({ adding: false, added: (n) => n + 1, items: (items) => [ { id: `new-${$.model.added + 1}`, name: name === "" ? "UNNAMED_SECRET" : name, kind: "API key", scopes: ["Production"], saved: { at: "2026-12-01T10:00:00Z", actor: maya, hint: `ends in ${value.slice(-4)}` }, can: ["replace", "rotate", "remove"], }, ...items, ], }) }, }, view: (h, model) => h.div.attrs(sx(styles.frame)).children( model.adding && SecretField(h, { key: `new-${model.added}`, props: { agentId: "vault-demo-new", label: "New secret", saved: null, inputs: [ { name: "name", label: "Name", secret: false, placeholder: "STRIPE_API_KEY", autocomplete: "off" }, { name: "value", label: "Value" }, ], cancel: { label: "Cancel" }, }, onEmit: { RequestedSave: ({ values }) => Message.SavedNewSecret({ values }), RequestedRemove: () => undefined, RequestedCancel: () => Message.CancelledNewSecret(), }, }), model.fresh !== null && ShownOnce(h, { key: model.fresh, props: { label: `New ${model.items.find((i) => i.id === model.fresh)?.name ?? "value"}`, value: Redacted.make("bk_live_9f2c41aa07d34e1b8c55e0d17d3e"), description: "Copy it now and paste it where the old one was. It won’t be shown again.", doneLabel: "Done", }, onEmit: { RequestedDone: () => Message.Done() }, }), Vault(h, { props: { label: "Secrets", agentId: "vault-demo", items: model.items, addLabel: "Add secret", timeZone: "UTC" }, onEmit: { RequestedAdd: () => Message.RequestedAddSecret(), RequestedReplace: ({ id }) => Message.Replaced({ id }), RequestedRemove: ({ id }) => Message.Removed({ id }), RequestedRotate: ({ id }) => Message.Rotated({ id }), }, }), ),})Installation
pnpm dlx shadcn@latest add checkfu/uicontext/secretUsage
import { SecretValues, Vault, type VaultItem } from "./ui/uicontext/components/kit/Secret.ts"const Message = UiSchema.TaggedEnum({ ReplacedSecret: { id: Schema.String, values: SecretValues }, RotatedSecret: { id: Schema.String }, RemovedSecret: { id: Schema.String },})export const Secrets = (h: Html.H<typeof Message.Type>, items: ReadonlyArray<VaultItem>) => Vault(h, { props: { label: "Secrets", items }, onEmit: { RequestedReplace: ({ id, values }) => Message.ReplacedSecret({ id, values }), RequestedRotate: ({ id }) => Message.RotatedSecret({ id }), RequestedRemove: ({ id }) => Message.RemovedSecret({ id }), RequestedAdd: () => undefined, }, })API reference
SecretFieldComponent
Props
| Name | Type | Default | Description |
|---|---|---|---|
agentId | string | — | The field's unique ID for agents, such as "secret-service-key". |
labelrequired | string | — | The secret's display name, such as "Service API key". |
description | string | — | What it's for, or where it goes: "Used by sessions during setup only." |
savedrequired | SavedSecret | null | — | Null while nothing is saved |
usedBy | string | — | What uses it: "Used by 2 preflight scripts" |
inputs | SecretInput[] | — | The inputs; one masked input named "value" by default |
can | Can(["edit", "remove"]) | — | What this person may do: "edit" enters or replaces the value, "remove" removes the saved one. Left out, they may edit and not remove. |
lockedReason | string | — | Why it can't be changed, when it can't: "Set by your admin" |
removeWarning | string | — | Said in the remove confirm: "Sessions that use it fail until it's replaced." |
saveLabel | string | Save securely | The save button's words; Save securely by default |
removeLabel | string | Remove | The remove button's words; Remove by default |
note | string | " | Said under the input; "Saved straight to the vault. Nobody can view it after you save it." by default |
outcome | Outcome | — | The app's answer to the last request: "save" for RequestedSave, "remove" for RequestedRemove. Pending shows "Saving securely…"; a refusal shows its reason ("The secret was not saved. Try again."). |
expires | string | — | A countdown, formatted by the app: "Expires in 4:12" |
closed | string | — | The entry is over (expired, cancelled, used); this sentence replaces the form |
cancel | { label } | — | A Cancel that the app hears (stop a sign-in), in place of the local one |
timeZone | string | — | The time zone (IANA) the saved date is shown in |
locale | string | — | The locale the saved date is formatted in; the browser's by default |
Events
| Event | Payload | Description |
|---|---|---|
RequestedSave | { values: SecretValues } | The values typed, by input name; the app sends them to its vault and drops them |
RequestedRemove | {} | Remove the saved value, after the person confirmed |
RequestedCancel | {} | The app's Cancel (the cancel prop) was pressed |
Agent actions
| Action | Description |
|---|---|
ClickedReplace | Open the field so the person can type a new value. You never see or type the value: tell the person it's ready for them. |
ConfirmedRemoveasks first | Remove the saved value. Name its label and savedAt as the target. |
VaultComponent
Props
| Name | Type | Default | Description |
|---|---|---|---|
agentId | string | vault:<label> | The id agents know this vault by; vault:<label> by default |
labelrequired | string | — | "Secrets", "Vault", "Environment variables" |
itemsrequired | VaultItem[] | — | The saved secrets, by name, with who saved them and when; never their values |
addLabel | string | — | "Add secret"; leave out when this person can't add |
emptyTitle | string | Nothing saved yet | What an empty vault says; Nothing saved yet by default |
emptyHint | string | — | A hint under the empty title |
note | string | — | Said under the input when replacing a value |
timeZone | string | — | The time zone (IANA) saved dates are shown in |
locale | string | — | The locale saved dates are formatted in; the browser's by default |
Events
| Event | Payload | Description |
|---|---|---|
RequestedAdd | {} | The add button was pressed: open the app's form for a new secret |
RequestedReplace | { id: string; values: SecretValues } | A secret's new value, typed by input name; the app sends it to its vault and drops it |
RequestedRemove | { id: string } | Remove a secret, after the person confirmed |
RequestedRotate | { id: string } | Make a new value for a secret, after the person confirmed; show it with ShownOnce |
Agent actions
| Action | Description |
|---|---|
ClickedReplace | Open an item's replace field for the person to type into. You never see or type the value: tell the person it's ready. |
ConfirmedRemoveasks first | Remove an item by id. Name that item's { id, name, savedAt }, as in the snapshot, as the target. |
ShownOnceComponent
Props
| Name | Type | Default | Description |
|---|---|---|---|
agentId | string | shown-once:<label> | The id agents know this by; shown-once:<label> by default |
labelrequired | string | — | "Personal access token", "Connection token" |
valuerequired | Redacted | — | The new token, shown this once |
description | string | — | What to do with it: "Paste it into your client's settings." |
doneLabel | string | — | "Done"; leave out when the app closes it some other way |
Events
| Event | Payload | Description |
|---|---|---|
RequestedDone | {} | The person pressed Done: close it, and the value is gone |
Accessibility
- The value is a masked input with a Show button (
aria-pressed); nothing typed is kept after it's sent. - Saved secrets show their name and who saved them, never their value.
- A value shown once is selected when focused, and copying it says whether it worked.