You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ships both CommonJS and native ESM bundles with conditional exports tuned for Node, browsers, and React Native.
Adds an optional snstr/nip07-ambient side-effect import to type the window.nostr extension API without bundling extra runtime logic.
Tightens the relay + in-memory WebSocket typings so handlers match DOM events, removing any usage across tests and source.
Refreshes README/example docs, including a Next.js + Turbopack guide and an exhaustive script index for tests and demos.
Cleans up CI by removing unused workflows merged via PR #68.
Detailed Changes
Build & Packaging
Introduced build:cjs and build:esm steps plus a postbuild-esm script that writes dist/esm/package.json with { "type": "module" }, eliminating interop hiccups for bundlers.
Root exports map now points each condition (import, require, browser, react-native) at the correct artifact, ensuring require('snstr') still hits CommonJS while modern bundlers grab the ESM tree.
React Native consumers now resolve through the ESM bundle so Metro no longer needs to polyfill Node built-ins.
Browser / NIP-07
New src/nip07/ambient.ts (also re-exported as snstr/nip07-ambient) augments window.nostr typings via a single import for teams that want TypeScript coverage around extension APIs.
The root index exports the ambient helper so version upgrades never strand browser projects on private paths.
Relay & WebSocket Stack
Added src/utils/websocket-types.ts and refactored both src/nip01/relay.ts and src/utils/inMemoryWebSocket.ts to consume explicit handler/event types, matching DOM semantics and tightening inference around message, open, and close callbacks.
Hardened the in-memory WebSocket shim so stress tests no longer encounter undefined data payloads or handler parameter mismatches.
Expanded the relay test utilities to share wait helpers, reducing flake risk and centralizing timing knobs for future work.
Documentation & Examples
README now calls out the dual-build story plus a "Next.js / Turbopack Guidance" section with concrete recommendations (prefer default import, avoid unnecessary transpilation, use dynamic import() where needed).
Example + NIP-specific READMEs align with the script names in package.json, including new commands for relay URL normalization, Zap flows, wallet connect scenarios, and rate-limit demos.
Script tables highlight the dedicated test:crypto path and add coverage for relay WebSocket harnesses.
Engineering Hygiene
Deleted obsolete .github/workflows/claude.yml and .github/workflows/release.yml now that staging→main merges rely on the new release workflow.
Tidied lint config and Jest setup to mirror the shared WebSocket typings while keeping the test matrix green.
Upgrade Checklist
npm install snstr@0.1.9 (or bump your lockfile) and re-run npm run build to cache the new dual build outputs.
Browser consumers who want ambient typings can add import 'snstr/nip07-ambient'; once near their bootstrap code.
Custom WebSocket shims should adopt the new helper types from src/utils/websocket-types (or rely on the generated declarations) to stay aligned with the relay expectations.
If you removed the legacy GitHub workflows locally, ensure your CI uses the maintained release pipeline before tagging.