From 3e2d860fb61ee796c4c788a89e667cb7ca670745 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 7 May 2026 10:10:52 +0000 Subject: [PATCH 1/2] deps: bump multiformats Bumps the interplanetary-deps group with 1 update in the / directory: [multiformats](https://github.com/multiformats/js-multiformats). Updates `multiformats` from 13.4.2 to 14.0.0 - [Release notes](https://github.com/multiformats/js-multiformats/releases) - [Changelog](https://github.com/multiformats/js-multiformats/blob/master/CHANGELOG.md) - [Commits](https://github.com/multiformats/js-multiformats/compare/v13.4.2...v14.0.0) --- updated-dependencies: - dependency-name: multiformats dependency-version: 14.0.0 dependency-type: direct:production update-type: version-update:semver-major dependency-group: interplanetary-deps ... Signed-off-by: dependabot[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a388902b..dbffc1dc 100644 --- a/package.json +++ b/package.json @@ -145,7 +145,7 @@ }, "dependencies": { "@chainsafe/is-ip": "^2.0.1", - "multiformats": "^13.0.0", + "multiformats": "^14.0.0", "uint8-varint": "^2.0.1", "uint8arrays": "^5.0.0" }, From ddaaed0c122bcc8f0b7ee7d7deffb69e59c41c78 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Tue, 12 May 2026 13:07:14 +0300 Subject: [PATCH 2/2] chore: update deps --- package.json | 4 ++-- src/components.ts | 5 +++-- src/index.ts | 6 +++--- src/multiaddr.ts | 4 ++-- src/registry.ts | 2 +- src/utils.ts | 14 +++++++------- 6 files changed, 18 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index 58c8b950..b933a6ea 100644 --- a/package.json +++ b/package.json @@ -147,8 +147,8 @@ "dependencies": { "@chainsafe/is-ip": "^2.0.1", "multiformats": "^14.0.0", - "uint8-varint": "^2.0.1", - "uint8arrays": "^5.0.0" + "uint8-varint": "^3.0.0", + "uint8arrays": "^6.1.1" }, "devDependencies": { "aegir": "^48.0.4" diff --git a/src/components.ts b/src/components.ts index f6009e11..924ceea4 100644 --- a/src/components.ts +++ b/src/components.ts @@ -1,4 +1,5 @@ import * as varint from 'uint8-varint' +import { withArrayBuffer } from 'uint8arrays' import { concat as uint8ArrayConcat } from 'uint8arrays/concat' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' import { toString as uint8ArrayToString } from 'uint8arrays/to-string' @@ -27,7 +28,7 @@ export function bytesToComponents (bytes: Uint8Array): Component[] { const component: Component = { code, name: codec.name, - bytes: bytes.subarray(i, i + componentLength) + bytes: withArrayBuffer(bytes.subarray(i, i + componentLength)) } if (size > 0) { @@ -45,7 +46,7 @@ export function bytesToComponents (bytes: Uint8Array): Component[] { return components } -export function componentsToBytes (components: Component[]): Uint8Array { +export function componentsToBytes (components: Component[]): Uint8Array { let length = 0 const bytes: Uint8Array[] = [] diff --git a/src/index.ts b/src/index.ts index 86b6bae4..94113baf 100644 --- a/src/index.ts +++ b/src/index.ts @@ -123,11 +123,11 @@ export interface Component { * The bytes that make up the component. This will be set if the multiaddr * was parsed from a `Uint8Array`, or if `.bytes` has been accessed on it. */ - bytes?: Uint8Array + bytes?: Uint8Array } export interface Multiaddr { - bytes: Uint8Array + bytes: Uint8Array /** * Returns Multiaddr as a String @@ -258,7 +258,7 @@ export interface Multiaddr { * // false * ``` */ - equals(addr: { bytes: Uint8Array }): boolean + equals(addr?: any): boolean } /** diff --git a/src/multiaddr.ts b/src/multiaddr.ts index 7a93359a..573cc702 100644 --- a/src/multiaddr.ts +++ b/src/multiaddr.ts @@ -54,7 +54,7 @@ export class Multiaddr implements MultiaddrInterface { // cache string representation #string: string | undefined // cache byte representation - #bytes: Uint8Array | undefined + #bytes: Uint8Array | undefined constructor (addr: MultiaddrInput | Component[] = '/', options: MultiaddrOptions = {}) { this.#components = toComponents(addr) @@ -64,7 +64,7 @@ export class Multiaddr implements MultiaddrInterface { } } - get bytes (): Uint8Array { + get bytes (): Uint8Array { if (this.#bytes == null) { this.#bytes = componentsToBytes(this.#components) } diff --git a/src/registry.ts b/src/registry.ts index 1c345467..de211924 100644 --- a/src/registry.ts +++ b/src/registry.ts @@ -48,7 +48,7 @@ export interface ProtocolCodec { /** * To encode the multiaddr as bytes, convert the value to bytes */ - valueToBytes?(value: string): Uint8Array + valueToBytes?(value: string): Uint8Array /** * To decode bytes to a multiaddr, convert the value bytes to a string diff --git a/src/utils.ts b/src/utils.ts index d75f6b71..1b496f21 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -14,7 +14,7 @@ export function bytesToString (base: SupportedEncodings): (buf: Uint8Array) => s } } -export function stringToBytes (base: SupportedEncodings): (value: string) => Uint8Array { +export function stringToBytes (base: SupportedEncodings): (value: string) => Uint8Array { return (buf) => { return uint8ArrayFromString(buf, base) } @@ -25,7 +25,7 @@ export function bytes2port (buf: Uint8Array): string { return view.getUint16(buf.byteOffset).toString() } -export function port2bytes (port: string | number): Uint8Array { +export function port2bytes (port: string | number): Uint8Array { const buf = new ArrayBuffer(2) const view = new DataView(buf) view.setUint16(0, typeof port === 'string' ? parseInt(port) : port) @@ -33,7 +33,7 @@ export function port2bytes (port: string | number): Uint8Array { return new Uint8Array(buf) } -export function onion2bytes (str: string): Uint8Array { +export function onion2bytes (str: string): Uint8Array { const addr = str.split(':') if (addr.length !== 2) { @@ -59,7 +59,7 @@ export function onion2bytes (str: string): Uint8Array { return uint8ArrayConcat([buf, portBuf], buf.length + portBuf.length) } -export function onion32bytes (str: string): Uint8Array { +export function onion32bytes (str: string): Uint8Array { const addr = str.split(':') if (addr.length !== 2) { @@ -95,7 +95,7 @@ export function bytes2onion (buf: Uint8Array): string { // Copied from https://github.com/indutny/node-ip/blob/master/lib/ip.js#L7 // but with buf/offset args removed because we don't use them -export const ip4ToBytes = function (ip: string): Uint8Array { +export const ip4ToBytes = function (ip: string): Uint8Array { ip = ip.toString().trim() const bytes = new Uint8Array(4) @@ -115,7 +115,7 @@ export const ip4ToBytes = function (ip: string): Uint8Array { // Copied from https://github.com/indutny/node-ip/blob/master/lib/ip.js#L7 // but with buf/offset args removed because we don't use them -export const ip6ToBytes = function (ip: string): Uint8Array { +export const ip6ToBytes = function (ip: string): Uint8Array { let offset = 0 ip = ip.toString().trim() @@ -228,7 +228,7 @@ const anybaseDecoder = (function () { return acc })() -export function mb2bytes (mbstr: string): Uint8Array { +export function mb2bytes (mbstr: string): Uint8Array { return anybaseDecoder.decode(mbstr) }