Skip to content

Add the browser export condition to @cipherstash/stack-supabase, with a live browser smoke test #805

Description

@tobyhede

Follow-up from the portable-encryptedSupabase design (#708). Blocked on the clientKey question — see #804. Do not start this one until that is answered "yes, clientKey is browser-safe".

Why the condition was cut

browser was in the design's proposed export map and was deliberately removed before shipping. It sorts first, so it wins over import/require for anyone whose tooling sets it — and two very ordinary Node setups do:

  • jest-environment-jsdom sets customExportConditions: ['browser']
  • Vite client builds set it

So a working Node customer who happens to run a jsdom test suite would silently start resolving the WASM build. That is a regression bought for a target that is both unclaimed and, per the clientKey finding, unreachable.

The typeof document !== 'undefined' refusal of config.accessKey in makeClient was dropped with it. The guard is not unsound — typeof document is the right probe for Workers/Deno/SSR — it simply had no legitimate firing site left once browser was gone. It comes back with the condition, not before it.

Checklist when it lands

  1. Add a "browser" branch to the export map, ahead of workerd.
  2. Add browser to NON_NODE_RUNTIMES in package-exports.test.ts.
  3. Reinstate the typeof document !== 'undefined' / config.accessKey refusal in makeClient — and give it a remedy that is not "pass a native client", because fromWasmEncryptionClient cannot adapt one.
  4. Add browser to the runtime lists in the skill, README, AGENTS.md and the changeset.
  5. Replace the "Browser is not supported" paragraphs with the OIDC-federation instruction, and narrow the design spec's warning to name only accessKey.
  6. Add the live browser smoke test — a headless-browser harness that loads the bundle and proves the import graph resolves and the WASM blob instantiates. The series already proves the import graph four ways under Node/Deno; this adds the browser engine to CI to prove the fifth.

This is a breaking change

Reintroducing browser is what makes the export-map change breaking for jsdom and Vite-client consumers — so this PR takes the feat(stack-supabase)!: marker and a major changeset that the current, browser-less map correctly does not need.

Guard that must not regress

The series ships a grep asserting no positive browser claim exists in any shipping artifact. It will fail — correctly — when this work lands. Update it rather than deleting it.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions