refactor: remove dependency on global Buffer in js #19483
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Removed
Bufferglobal mentions in the whole codebase by replacing it withbufferAlloc,bufferFromand similar utils. It still usesBufferbut now imported from thebuffernpm package. The main files to review arefoundation/src/buffer/utils.tsandplayground/*.Caveats
import('buffer').Bufferdiffers from nodejsBuffer. It does NOT support base64url encoding. Does not appear to support 'base64url' encoding like Node Buffer feross/buffer#309writeBigUint64BE(with lower "i") is not supported writeBigUint64BE isn't defined, but writeBigUInt64BE is feross/buffer#318How it is done
Since this is a large change from an external contributor(a security risk), here are the steps I took to implement it, so an internal employee can safely do the same in 5-10 minutes.
open
Then post fixes (commit e0db90a)
And then removed the polyfills from the playground (commit de0aff7)
TODO
@trackSpan(function () { SyntaxError: Invalid or unexpected tokenwhen I tried toyarn start --local-networkinside theyarn-project/aztec.Buffer.xxxusage