In fact, WinterCG (the standards body governing alternative JS runtime interoperability) mandates btoa on the global scope for compliant runtimes (which is basically any edge runtime that’s not Node or Bun).
The merits of using btoa are mixed. It’s not actually a deprecated API; it’s merely marked as legacy and the recommendation for modern code (especially when using Unicode, which we don’t) is to use something more compatible. If you have a single implementation with known inputs and you know it’s going to create the output correctly, it’s probably fine to use btoa.
I recommend this package uses btoa instead of Buffer.from().toString(“base64”), because it’s more compatible and doesn’t introduce that much of a footgun. The alternative would be to ponyfill buffer, or introduce a separate package just for base64 encoding/decoding; these would add more complexity and downstream dependencies so are probably less favourable.
The new
oauth.token
method usesBuffer.from
under the hood, butBuffer
is Node-specific and won’t work in other runtimes.The recommendations for other runtimes appear to be:
btoa
btoa
orstd/encoding/base64
btoa
btoa
In fact, WinterCG (the standards body governing alternative JS runtime interoperability) mandates
btoa
on the global scope for compliant runtimes (which is basically any edge runtime that’s not Node or Bun).The merits of using
btoa
are mixed. It’s not actually a deprecated API; it’s merely marked as legacy and the recommendation for modern code (especially when using Unicode, which we don’t) is to use something more compatible. If you have a single implementation with known inputs and you know it’s going to create the output correctly, it’s probably fine to usebtoa
.I recommend this package uses
btoa
instead ofBuffer.from().toString(“base64”)
, because it’s more compatible and doesn’t introduce that much of a footgun. The alternative would be to ponyfillbuffer
, or introduce a separate package just for base64 encoding/decoding; these would add more complexity and downstream dependencies so are probably less favourable.As always, will gladly PR this.