fix!: accept Uint8Arrays as keys #2909
Open
+91
−56
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.
To allow use cases like fetching IPNS records in a way compatible with go-libp2p we need to send binary as fetch identifiers.
JavaScript strings are UTF-16 so we can't round-trip binary reliably since some byte sequences are interpreted as multi-byte or otherwise non-printable characters.
Instead we need to accept Uint8Arrays and send them over the wire as-is.
This is a backwards compatible change as far as interop goes since protobuf
bytes
andstring
types are identical on the wire, but it's breaking for API consumers in that the lookup function now needs to accept aUint8Array
identifier instead of astring
.Refs: libp2p/specs#656
BREAKING CHANGE: registered lookup functions now receive a Uint8Array identifier instead of a string
Change checklist