js-stellar-sdk icon indicating copy to clipboard operation
js-stellar-sdk copied to clipboard

Replace all usage of Node.js `Buffer` with `Uint8Array`

Open ScottyPoi opened this issue 2 months ago • 3 comments

This issue proposes removing all direct use of Node.js Buffer throughout the codebase and replacing it with the standard Uint8Array.

The goal is to improve browser compatibility, simplify builds, and align with modern JavaScript and cross-runtime best practices.

The current browser ecosystem (Vite, Bun, Deno, Cloudflare Workers, etc.) no longer includes a global Buffer by default. Using it requires extra shims or polyfills, which increases friction for users and downstream libraries.

In contrast, Uint8Array is a web-standard, cross-environment type that now provides nearly all functionality needed for binary manipulation. Small utility helpers can fill any remaining gaps (e.g., concatenation, encoding, decoding).

Migrating to Uint8Array will make the codebase more portable, future-proof, and browser-friendly with minimal functional changes.

ScottyPoi avatar Oct 20 '25 21:10 ScottyPoi

self-assigning this -- i just don't have the repo authority to actually assign issues to myself 😉

ScottyPoi avatar Oct 20 '25 21:10 ScottyPoi

After looking into this, I actually think it's not possible to do this on just the stellar-sdk. This change would have to begin at the stellar-base level

ScottyPoi avatar Oct 21 '25 22:10 ScottyPoi

@ScottyPoi yeah this issue runs deep - you'd actually have to start at the js-xdr level lol. @Ryang-21 and I discussed this and I think it makes sense to put this off because it's not clear that Uint8Array is well-supported enough on the platforms this SDK needs to support (markets that use our products don't always have the l8st and gr8st hardware). I'll try to survey internally about our targeted baseline of compatibility and get back to you.

Shaptic avatar Oct 21 '25 23:10 Shaptic