Secrets
createSecretsFeature stores arbitrary per-tenant secrets (API keys, tokens,
credentials) encrypted at rest with AES-256, using a key-encryption-key
(KEK) loaded from the KUMIKO_SECRETS_MASTER_KEY_V1 env var (plus successive
versions for rotation). It belongs on the server/platform side, values
should not live in plain env vars per tenant.
import { createSecretsFeature } from "@cosmicdrift/kumiko-bundled-features/secrets";How it works
Section titled “How it works”- Read a secret in a handler via
ctx.secrets.get(tenantId, handle); every read automatically appends atenantSecretReadaudit event, so all access is traceable. - A
rotatejob re-encrypts all envelopes after a KEK version bump. set/delete/listhandlers share one access rule (no per-handler drift in the blast radius).
Access control
Section titled “Access control”set/delete/list are gated by a single rule. Default is admin-only;
adopt the host’s role vocabulary or open it to any authenticated tenant user:
createSecretsFeature({ roles: ["TenantAdmin"] }); // defaultcreateSecretsFeature({ access: { roles: ["Ops"] } }); // custom vocabulary// any tenant membercreateSecretsFeature({ access: { openToAll: { reason: "every tenant member maintains the integration API keys in this product" }, },});- Default:
{ roles: ["TenantAdmin"] }, only admins read previews and set/delete secrets. rolesis shorthand for{ access: { roles } }and is mutually exclusive withaccess.{ access: { openToAll: { reason } } }lets any authenticated tenant user read secret previews and write/delete secrets.reasonis required and names why no role check is needed.
openToAllis a large blast radius, every tenant member becomes a writer and gets preview access. Only use it when the product truly requires it; otherwise keep the default or set an explicitroleslist.
Example
Section titled “Example”import { runDevApp } from "@cosmicdrift/kumiko-dev-server";import { createSecretsFeature } from "@cosmicdrift/kumiko-bundled-features/secrets";
await runDevApp({ secrets: createSecretsFeature({ access: { roles: ["TenantAdmin"] } }),});See also
Section titled “See also”feature-reference/secretsfor the command surface and dependenciescustom-fields, the sibling feature with role-scoped write options