Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: replace node buffers with uint8arrays #67

Merged
merged 3 commits into from
Aug 14, 2020

Conversation

achingbrain
Copy link
Member

BREAKING CHANGES:

  • All deps of this module use Uint8Arrays instead of Buffers
  • value and validity fields of IPNSEntries are now Uint8Arrays instead
    of Strings as they are bytes in the protobuf definition

BREAKING CHANGES:

- All deps of this module use Uint8Arrays instead of Buffers
- value and validity fields of IPNSEntries are now Uint8Arrays instead
  of Strings as they are `bytes` in the protobuf definition
src/index.js Outdated
@@ -193,7 +196,7 @@ const extractPublicKey = (peerId, entry) => {
if (entry.pubKey) {
let pubKey
try {
pubKey = crypto.keys.unmarshalPublicKey(entry.pubKey)
pubKey = crypto.keys.unmarshalPublicKey(Buffer.from(entry.pubKey))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't we replacing the Buffers everywhere?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The underlying crypto libraries do not understand Uint8Arrays and require Buffers :(

But! The user should be able to pass Uint8Arrays to our modules without them exploding.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be updated to use libp2p-crypto@0.18.0, it does use Uint8Array now

node: {
path: true,

Buffer: true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I've updated the file with comments about which modules require the node libs

@vasco-santos vasco-santos merged commit 06ee535 into master Aug 14, 2020
@vasco-santos vasco-santos deleted the fix/replace-node-buffers-with-uint8arrays branch August 14, 2020 08:12
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.

3 participants