interledger / interledger/open-payments-node
[FEATURE REQUEST] Make SDK compatible with more runtimes
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 10
- Forks
- 4
- Avg merge
- 27m
- Merged PRs (30d)
- 3
Description
Feature Request
Presently, the SDK only works in Node.js environment.
The Web Monetization extension does a lot of things to make it work in browser, which could be avoided (polyfill Node.js crypto, fs, etc. APIs, override ED curves as Chrome doesn't support them yet).
Similarly, we're trying to deploy a worker on Cloudflare that uses the SDK, but we faced issues even with nodejs_compat flag as not all things are implemented there.
Describe the solution you'd like
Make the SDK (and its dependencies) use Web Platform APIs, which are supported in most runtimes (e.g. crypto.subtle instead of node:crypto, TextEncoder vs Buffer).
Also, avoid fs APIs. They're used presently for reading key from filesystem, but users can provide key themselves too by reading file themselves in their runtime supported manner (related: https://github.com/interledger/open-payments-node/issues/5).
Also, we have YAML schema's loaded when validateResponses: true (the default). This caused issues in a default Next.js setup during a hackathon. We set validateResponses: false in extension as well to avoid this issue (The schemas could've been converted to JSON and then imported perhaps, removing runtime YAML dependency as well; and can be bundled if needed by users easily).
Ideally, I'd like this SDK becoming lightweight, and that works across different JS runtimes. There's also a tech team goal I added for this year for this.
Describe alternatives you've considered
Keep polyfilling 😢
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the SDK's uses of node:crypto, fs, and runtime YAML loading, especially the validateResponses path. The work is done when the SDK and its dependencies rely on broadly supported Web Platform APIs, avoid required filesystem access and unnecessary runtime YAML dependencies, and work across the stated JavaScript runtimes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- api, developer-experience
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100