Skip to content

chore: remove utils crypto import#562

Merged
rolznz merged 1 commit into
masterfrom
fix/utils-remove-crypto-import
May 20, 2026
Merged

chore: remove utils crypto import#562
rolznz merged 1 commit into
masterfrom
fix/utils-remove-crypto-import

Conversation

@rolznz
Copy link
Copy Markdown
Member

@rolznz rolznz commented May 20, 2026

Closes #561

updates generatePreimageAndPaymentHash to use crypto subtle to work in all environments

Summary by CodeRabbit

  • Chores
    • Updated SDK version to 8.0.2 across all examples and documentation references.

Review Change Stack

updates generatePreimageAndPaymentHash to use crypto subtle to work in all environments
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 20, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 63b2e61f-2382-4c17-a458-bf79370c97de

📥 Commits

Reviewing files that changed from the base of the PR and between 919b2e3 and 08545b7.

📒 Files selected for processing (7)
  • README.md
  • examples/lnclient/paywall-esm.html
  • examples/nwc/auth.html
  • examples/nwc/auth_manual.html
  • examples/nwc/client/auth.html
  • examples/nwc/client/auth_manual.html
  • src/utils.ts

📝 Walkthrough

Walkthrough

This PR bumps the SDK version reference from 8.0.1 to 8.0.2 across documentation and examples, and refactors the cryptographic preimage and hash generation in src/utils.ts to use Web Crypto APIs instead of Node.js-specific crypto modules, enabling broader platform support.

Changes

Documentation and Examples Version Update

Layer / File(s) Summary
Documentation and examples SDK version update
README.md, examples/lnclient/paywall-esm.html, examples/nwc/auth.html, examples/nwc/auth_manual.html, examples/nwc/client/auth.html, examples/nwc/client/auth_manual.html
All documentation and example HTML files update their esm.sh imports from @getalby/sdk@8.0.1 to @getalby/sdk@8.0.2; no logic changes.
Web Crypto migration in utility functions
src/utils.ts
The generatePreimageAndPaymentHash function removes the explicit Node.js crypto import and replaces it with Web Crypto APIs: crypto.getRandomValues for preimage generation and crypto.subtle.digest("SHA-256", ...) for hash computation, maintaining the same exported function signature.

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • getAlby/js-sdk#524: Introduces generatePreimageAndPaymentHash helper that is refactored in this PR to use Web Crypto APIs for cross-platform compatibility.
  • getAlby/js-sdk#560: Updates the same README and example import URLs to bump the SDK version from 8.0.1 to 8.0.2.

Poem

🐰 From Node's crypto lands we hop away,
To Web APIs, cross-platform and grand,
With getRandomValues and subtle's display,
SHA-256 hashes now work hand in hand,
Version 8.0.2 lights up the day! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'chore: remove utils crypto import' accurately describes the main change: removing the Node.js crypto import from utils.ts and replacing it with Web Crypto APIs.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/utils-remove-crypto-import

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@rolznz rolznz merged commit 5ba0c8b into master May 20, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Do not import crypto by default

1 participant