Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

Buffer instead of Uint8Array #126

Closed
xmaysonnave opened this issue Aug 29, 2020 · 4 comments · Fixed by #127
Closed

Buffer instead of Uint8Array #126

xmaysonnave opened this issue Aug 29, 2020 · 4 comments · Fixed by #127

Comments

@xmaysonnave
Copy link

I lately upgrade js-cid from 0.8.3 to 1.0.0 who is a major upgarde as Uint8Array are used instead of Buffer.

However it appears that js-multibase do not always return Uint8Arrays.
I've a set of tests who crashed immediately when upgraded

ipfs cidv0 to ipfs cidv1 (base58btc, dag-pb) and vice versa
ipns cidv0 to ipns cidv1 (base58btc, dag-pb) to (base32, libp2p-key) and vice versa
ipns cidv1 to ipns cidv1 (base32, libp2p-key) to (base36, lip2p-key) and vice versa

According to :
https://github.com/multiformats/js-multibase/blob/master/src/constants.js

base58btc (dag-pb) who is used in IPFS cidv0 returns a Buffer
base36 (libp2p-key) who is used in IPNS cidv1 returns a Buffer

Thanks

@vmx
Copy link
Member

vmx commented Aug 31, 2020

There are still issues that should get fixed with multiformats/js-multibase#64.

In the meantime the good news are, that Node.js Buffer is also a Uint8Array. So if you your code works with Uint8Arrays, it should automatically work even if a Node.js Buffer is returned.

@xmaysonnave
Copy link
Author

I'm glad that you are aware of this issue. The proposed PR seems to address the problem.
Thanks for the hint though.

@jacobheun
Copy link

multiformats/js-multibase#64 has been merged and released, can this be closed are does anything need to be updated here?

vmx added a commit that referenced this issue Sep 25, 2020
There were cases where CIDs where returned as Node.js Buffers. Now all
CIDs are returned as Uint8Array only.

Fixes #126.
vmx added a commit that referenced this issue Sep 25, 2020
With updating the dependencies, we now never return Node.js Buffers

There were cases where CIDs where returned as Node.js Buffers. Now all
CIDs are returned as Uint8Array only.

Fixes #126.
@vmx vmx closed this as completed in #127 Sep 25, 2020
vmx added a commit that referenced this issue Sep 25, 2020
With updating the dependencies, we now never return Node.js Buffers

There were cases where CIDs where returned as Node.js Buffers. Now all
CIDs are returned as Uint8Array only.

Fixes #126.
@vmx
Copy link
Member

vmx commented Sep 25, 2020

@jacobheun thanks for pinging, I've released 1.0.1 which should be fully Node.js Buffer free.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants