Skip to content

Ship a browser-safe build — UUID.TB can't run in the renderer (static node crypto import) #21

Description

@Shinrai

@cldmv/uuid can't run in a browser, which blocks using it as the fleet PK primitive on the client side.

dist/uuid.mjs does a static import crypto from "crypto" (node builtin) at module top and calls crypto.randomBytes(16) for entropy — including on the UUID.TB() path. The package has no browser export condition and no browser build. So esbuild-bundling it for the browser (platform: "browser") fails to resolve crypto (and fs/url/path from the dynamically-imported issuer-registry), and any renderer import of @cldmv/uuid 404s / throws.

This came up wiring rummage's offline-first data facade (CLDMV/rummage#25): a client-minted create id BECOMES the server PK, so it must be a UUID.TB — but the renderer can't mint one today. As an interim, rummage's facade minter is injectable and falls back to a native UUID; that's a stopgap, not the PK format the fleet rule (D36) wants.

What would fix it: an isomorphic randomness source — use globalThis.crypto.getRandomValues in the browser and node crypto in node (the standard pattern) — and a browser export condition (or a pre-bundled browser entry) so platform: "browser" bundlers resolve cleanly. The issuer-registry node bits (fs/url/path) are already behind a dynamic import(), so they only need to stay off the UUID.TB static path (they appear to be). Ideally UUID.TB() / UUID.TA() work in the browser with zero node builtins.

Once this lands, rummage vendors @cldmv/uuid into the client-storage browser bundle and injects the UUID.TB minter into the facade (the seam is already in place), so every client-minted PK across the fleet is a real UUID.TB.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: coreTouches core library / runtime source codetype: feature requestA request to add new functionality that does not currently exist

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions