Skip to content

Graceful degradation when Web Crypto is missing (old WebView / non-secure context) — cryptic crypto.randomUUID crash #10

@melvincarvalho

Description

@melvincarvalho

Problem

solid-oidc requires modern Web Crypto: crypto.randomUUID (state/nonce/PKCE verifier) and crypto.subtle (SHA-256 digest for the PKCE code_challenge, plus DPoP key-gen/sign). Both are gated to Chromium 92+ and secure contexts.

On browsers that lack them, sign-in dies at the first call with a cryptic:

crypto.randomUUID is not a function

…with no hint of the real cause. Two common situations hit this:

  1. De-Googled Android phones (LineageOS/pmOS without GApps) — the Android System WebView is stale because it normally updates via the Play Store, which isn't installed. So the default browsing surface can be an old Chromium lacking randomUUID/subtle.
  2. Non-secure contexts — a pod accessed over http://<lan-ip>:port (not localhost, not HTTPS) → crypto.subtle/randomUUID are undefined even on a modern browser.

This is the path made strict by #5 (jose → Web Crypto) — great for zero-deps, but it now hard-requires modern + secure-context crypto, and fails opaquely when that's absent.

Repro

Open a jspod/xlogin sign-in (which imports solid-oidc) on a de-Googled phone's stale WebView, or any pre-Chromium-92 / non-secure context → crypto.randomUUID is not a function.

Asks

  1. Polyfill crypto.randomUUID via crypto.getRandomValues (widely supported, not secure-context-gated) so the lib clears the first hurdle.

  2. Detect missing crypto.subtle up front and throw a clear, actionable error, e.g.:

    solid-oidc requires Web Crypto (crypto.subtle); this browser/context doesn't provide it. Use an up-to-date browser over HTTPS or localhost.

    …instead of a cryptic mid-flow randomUUID crash.

  3. (Optional) a JS SHA-256 fallback for the PKCE code_challenge so PKCE survives without subtlebut DPoP (ECDSA key-gen/sign) genuinely needs crypto.subtle, so this can't fully run on a browser that lacks it. The realistic win is (1) + (2): a clear "update your browser" message, not a magic fix.

Impact

Affects jspod onboarding sign-in, xlogin, and every app that authenticates via solid-oidc — especially the Solid-Pod-on-a-de-Googled-phone use case. Turning an opaque crash into "your browser is too old / use HTTPS or localhost" is the main improvement.

Related

#5 (jose → Web Crypto). Same family as the secure-context / stale-WebView constraints on de-Googled devices.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions