Cotal TypeScript packages
    Preparing search index...

    The default filesystem SecretStore: the workstation adapter behind core's abstract seam.

    Keys are opaque logical strings the owning packages build to MIRROR today's exact .cotal layout per kind — delivery.creds, auth/callout.json, <agent>.creds, and so on — so a local cotal up writes byte-for-byte the same files it does today. That layout is heterogeneous (a few kinds are already space-segmented on disk, most are not), so each key builder reproduces its kind's current path verbatim. Crucially the key carries NO injected tenant / <space> prefix: a hosted KMS/Vault adapter adds per-tenant scope inside ITS OWN resolve from its injection context, which keeps one backend-agnostic key per kind and preserves local byte-for-byte.

    This adapter adds nothing of its own: it delegates to the secret-fs primitives for the 0600 / icacls / atomic-replace / fail-closed guarantees. Constructed with an EXPLICIT base root (no ambient ~/.cotal), absolutized so keys are cwd-independent. Lives in @cotal-ai/workspace, not core, because on-disk layout is a workstation concern, not the wire protocol.

    Residual (documented): a symlink UNDER the root that points outside is not caught (no realpath) — acceptable for a single-tenant workstation; a multi-tenant FS deployment should realpath-check.

    Implements

    Index
    • identityRoot is the root the identity names when that is not the store's own directory: the workspace store lives in <root>/.cotal and is named by <root>.

      Parameters

      • root: string
      • OptionalidentityRoot: string

      Returns FsSecretStore

    • Store value under key only while key is absent, deciding that in one atomic step: of concurrent creates of one key exactly one resolves true, and the others resolve false with the winner's value untouched. A concurrent get observes the key absent or the complete value (FS adapter → temp + exclusive link; a managed backend → a conditional create). A load-or-create kind writes its first value here and adopts the stored one when it loses, because a read followed by put lets two first callers each keep a value of their own.

      Parameters

      • key: string
      • value: string

      Returns Promise<boolean>

    • Remove key. Idempotent. The ONLY portable contract is: after a successful delete, get(key) returns absent. This is NOT cryptographic shred, revocation, or credential kill — a backend may retain recoverable versions, and any already-issued NATS cred or signing seed stays valid until its credential lifetime ends or broker/key rotation invalidates it (those are mint / renewal / eviction concerns, not SecretStore).

      Parameters

      • key: string

      Returns Promise<void>

    • Store value under key, replacing any prior value AS A WHOLE: a concurrent get observes either the complete old value or the complete new one, never a partial or torn intermediate (FS adapter → atomic temp+rename; a managed backend → a conditional / whole-object put). This atomicity is part of the contract because standing daemon/agent creds are re-read live during renewal. Private perms / hardening beyond the atomicity guarantee remain the adapter's concern.

      Parameters

      • key: string
      • value: string

      Returns Promise<void>