fix: use globalThis.crypto.randomUUID for cross-runtime compat#5
Open
orveth wants to merge 3 commits into
Open
fix: use globalThis.crypto.randomUUID for cross-runtime compat#5orveth wants to merge 3 commits into
orveth wants to merge 3 commits into
Conversation
…orage })
Introduces a StorageProvider interface and a `browserStorage` helper. Every
SDK consumer now passes a storage provider explicitly via configure() — no
silent localStorage fallback, no hidden environment branching.
Browser apps import the bundled helper:
import { configure, browserStorage } from "@agicash/opensecret-sdk";
configure({ apiUrl, clientId, storage: browserStorage });
Non-browser consumers (React Native, Node, Bun, CLI, MCP) implement the
two-namespace interface against their own backing store. browserStorage
uses getters so importing it in a non-browser context is safe — window is
only referenced if the provider is actually accessed.
Updates the test setup to pass browserStorage so existing integration test
fixtures keep working.
Swap all 43 direct window.localStorage / window.sessionStorage / bare localStorage / bare sessionStorage callsites across api.ts, encryptedApi.ts, ai.ts, getAttestation.ts, platformApi.ts, main.tsx, and developer.tsx for getStorage().persistent.* / getStorage().session.*. OpenSecretProvider — the React DOM component — wires the SDK's internal configure() call with the bundled browserStorage helper, since the provider is intrinsically browser-only.
db1e111 to
3c38f16
Compare
window.crypto is browser-only; Node 19+, Bun, and Deno expose the same WebCrypto interface at globalThis.crypto. Swap the three randomUUID() callsites (getAttestation.ts, main.tsx, developer.tsx) so the SDK can generate attestation nonces on non-browser runtimes.
a015dfd to
11adae4
Compare
pmilic021
approved these changes
May 28, 2026
3c38f16 to
15899a6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #4.
window.cryptois browser-only; Node 19+, Bun, and Deno expose the same WebCrypto interface atglobalThis.crypto. Swap the threerandomUUID()callsites (getAttestation.ts,main.tsx,developer.tsx) so the SDK can generate attestation nonces on non-browser runtimes.3 lines changed across 3 files. Rebase target moves from
feat/storage-provider-cleantomasteronce #4 merges.