johnandersen777.bsky.social/socialweb-computer-console
console.socialweb.computer: kcp, kubectl and ssh compiled to wasm in a browser tab with a terminal; a kcp fork
browserinfra/vault
In-memory, browser-side substitute for the OpenBao-backed vault contract. It implements three read-only-tree interfaces over one concurrency-safe store:
| Interface | Type | Source |
|---|---|---|
vault.KV (Read/Write/Delete) | *Store | internal/contract/vault |
atproto.SecretStore (Get/Put/Delete) | *Secrets | internal/marketidentity/atproto |
component.CredentialResolver + CredentialWriter + CredentialDeleter | *Credentials | internal/component |
No JavaScript, no network, no OpenBao client calls. The only use of the
read-only internal/vault/openbao package is its ErrNotFound sentinel, so
existing errors.Is(err, openbao.ErrNotFound) checks keep working.
Intended integration
- One
*Storeper browser workspace (or tab profile). Share it betweenNewSecrets(store)andNewCredentials(store)so identity OAuth state, PDS sessions, and component credentials all see the same memory. - The eventual OpenBaoServer substitute controller should serve
vault.CapabilityRead/vault.CapabilityWritethrough the bus from this store, mirroring thebus.Providewiring ininternal/controllers/vault/provider.go, but resolving to the local store instead of dialing OpenBao. Do not route throughopenbao.ServerOf: it requires TLS material that does not exist in the browser. - Persistence:
store.Snapshot()is JSON-round-trippable ({"entries":[{"mount","path","version","data"}]}). Write it to IndexedDB/localStorage and callstore.Restore(snapshot)on load. Restore replaces the whole store (no merge). Snapshot data is JSON-shaped;[]bytevalues are base64 through JSON. Secrets/CredentialsexposeSnapshot/Restoredelegating to the same store.
Semantics worth knowing
- Keys are the pair
(mount, path); both are required. Paths nest with/andmount/data/...ormount/metadata/...prefixes are accepted, matchingopenbao.Handle. Store.List(ctx, mount, path)returns immediate children, sorted, with a trailing/on directories. It is not part ofvault.KV; it exists for the substitute controller's listing surface.Deleteis idempotent (a missing key is not an error), matching OpenBao KV metadata deletes.- Only the current version is retained.
Read/Resolvewithversion > 0succeeds only when it equals the current version; otherwiseErrNotFound. Secrets.Getmaps a missing or empty secret toatproto.ErrSecretNotFound.SecretRef.Vault,SecretRef.Key, andCredentialRef.Serverare ignored (the browser has one store).- Leases, PKI, Trust, and key rotation are not implemented; those capabilities stay unavailable in the browser.
OpenBaoServer CRD status for Ready
The Vault controller sets its own Ready from
server.status.ready && server.status.observedGeneration == server.metadata.generation
(internal/controllers/vault/controller.go). A substitute controller must
write, on the OpenBaoServer status:
observedGeneration:metadata.generation(required, or Vault never binds)ready: truephase: Ready(OpenBaoServerPhaseReady)initialized: truesealed: falseaddress: non-empty, e.g.memory://browserrefs.kvMount: the default KV mount used when avault.KVcall passes no mount (the provider'sdefaultMount)conditions: aReady=Truecondition whoseobservedGenerationequals the object generation (convention; the OpenBaoServer path only readsreadyandobservedGeneration, butRemoteOpenBaoand other consumers check conditions)version: optional, e.g.browser-memory
Tests
cd socialweb-wasm && go test ./internal/browserinfra/vault/...