From ead057d4a56b05003f4e683db669f18b84a5e2f7 Mon Sep 17 00:00:00 2001 From: Cayman Date: Wed, 11 Sep 2024 14:01:30 -0400 Subject: [PATCH] feat!: update libp2p deps (#295) --- package.json | 7 +- packages/discv5/package.json | 8 +- packages/discv5/src/libp2p/discv5.ts | 9 +- packages/discv5/src/packet/encode.ts | 3 +- packages/discv5/src/service/service.ts | 27 +- packages/discv5/src/service/types.ts | 3 +- packages/discv5/src/session/nodeInfo.ts | 9 +- packages/discv5/src/util/error.ts | 7 + packages/discv5/src/util/index.ts | 1 + packages/discv5/test/e2e/connect.test.ts | 19 +- .../discv5/test/e2e/mainnetBootnodes.test.ts | 19 +- .../discv5/test/unit/keypair/index.test.ts | 27 -- .../discv5/test/unit/service/service.test.ts | 11 +- packages/enr/package.json | 9 +- packages/enr/src/enr.ts | 17 +- packages/enr/src/peerId.ts | 53 +--- packages/enr/test/unit/enr.test.ts | 14 +- yarn.lock | 284 ++++++++++++------ 18 files changed, 271 insertions(+), 256 deletions(-) create mode 100644 packages/discv5/src/util/error.ts delete mode 100644 packages/discv5/test/unit/keypair/index.test.ts diff --git a/package.json b/package.json index 33279b42..6bf53168 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,9 @@ "version": "0.0.0", "description": "Discovery V5 monorepo", "type": "module", - "workspaces": ["packages/*"], + "workspaces": [ + "packages/*" + ], "scripts": { "check-types": "lerna run check-types", "build": "lerna run build", @@ -38,5 +40,6 @@ "prettier": "^2.6.2", "ts-node": "^10.8.1", "typescript": "^4.7.3" - } + }, + "packageManager": "yarn@1.22.22+sha256.c17d3797fb9a9115bf375e31bfd30058cac6bc9c3b8807a3d8cb2094794b51ca" } diff --git a/packages/discv5/package.json b/packages/discv5/package.json index 142d5ad2..610cdba5 100644 --- a/packages/discv5/package.json +++ b/packages/discv5/package.json @@ -64,13 +64,11 @@ "url": "https://github.com/ChainSafe/discv5/issues" }, "homepage": "https://github.com/ChainSafe/discv5#readme", - "devDependencies": { - "@libp2p/peer-id-factory": "^4.0.3" - }, + "devDependencies": {}, "dependencies": { "@chainsafe/enr": "^3.1.0", - "@libp2p/crypto": "^4.0.1", - "@libp2p/interface": "^1.1.1", + "@libp2p/crypto": "^5.0.0", + "@libp2p/interface": "^2.0.0", "@multiformats/multiaddr": "^12.1.10", "bcrypto": "^5.4.0", "bigint-buffer": "^1.1.5", diff --git a/packages/discv5/src/libp2p/discv5.ts b/packages/discv5/src/libp2p/discv5.ts index ea2fb0cf..f2ffa59d 100644 --- a/packages/discv5/src/libp2p/discv5.ts +++ b/packages/discv5/src/libp2p/discv5.ts @@ -1,10 +1,9 @@ import { - CustomEvent, PeerDiscovery, PeerDiscoveryEvents, peerDiscoverySymbol, - PeerId, PeerInfo, + PrivateKey, TypedEventEmitter, } from "@libp2p/interface"; import { Multiaddr, multiaddr } from "@multiformats/multiaddr"; @@ -58,7 +57,7 @@ export interface IDiscv5DiscoveryInputOptions extends Partial { } export interface IDiscv5DiscoveryOptions extends IDiscv5DiscoveryInputOptions { - peerId: PeerId; + privateKey: PrivateKey; } /** @@ -77,7 +76,7 @@ export class Discv5Discovery extends TypedEventEmitter impl super(); this.discv5 = Discv5.create({ enr: options.enr, - peerId: options.peerId, + privateKey: options.privateKey, bindAddrs: { ip4: options.bindAddrs.ip4 ? multiaddr(options.bindAddrs.ip4) : undefined, ip6: options.bindAddrs.ip6 ? multiaddr(options.bindAddrs.ip6) : undefined, @@ -142,7 +141,7 @@ export class Discv5Discovery extends TypedEventEmitter impl this.dispatchEvent( new CustomEvent("peer", { detail: { - id: await enr.peerId(), + id: enr.peerId, multiaddrs, }, }) diff --git a/packages/discv5/src/packet/encode.ts b/packages/discv5/src/packet/encode.ts index f47234f2..e24cacd6 100644 --- a/packages/discv5/src/packet/encode.ts +++ b/packages/discv5/src/packet/encode.ts @@ -1,8 +1,7 @@ -import { CodeError } from "@libp2p/interface"; import cipher from "bcrypto/lib/cipher.js"; import { toBigIntBE, toBufferBE } from "bigint-buffer"; -import { bufferToNumber, fromHex, numberToBuffer, toHex } from "../util/index.js"; +import { bufferToNumber, CodeError, fromHex, numberToBuffer, toHex } from "../util/index.js"; import { AUTHDATA_SIZE_SIZE, EPH_KEY_SIZE_SIZE, diff --git a/packages/discv5/src/service/service.ts b/packages/discv5/src/service/service.ts index 6240d77e..e76ea8da 100644 --- a/packages/discv5/src/service/service.ts +++ b/packages/discv5/src/service/service.ts @@ -2,16 +2,8 @@ import { EventEmitter } from "events"; import debug from "debug"; import { randomBytes } from "@libp2p/crypto"; import { Multiaddr } from "@multiformats/multiaddr"; -import { CodeError, PeerId } from "@libp2p/interface"; -import { - createPeerIdFromPublicKey, - createPrivateKeyFromPeerId, - ENR, - NodeId, - MAX_RECORD_SIZE, - createNodeId, - SignableENR, -} from "@chainsafe/enr"; +import { PeerId, PrivateKey } from "@libp2p/interface"; +import { createPeerIdFromPublicKey, ENR, NodeId, MAX_RECORD_SIZE, createNodeId, SignableENR } from "@chainsafe/enr"; import { BindAddrs, IPMode, ITransportService, UDPTransportService } from "../transport/index.js"; import { MAX_PACKET_SIZE } from "../packet/index.js"; @@ -44,7 +36,7 @@ import { RequestId, } from "../message/index.js"; import { AddrVotes } from "./addrVotes.js"; -import { toBuffer } from "../util/index.js"; +import { CodeError, toBuffer } from "../util/index.js"; import { IDiscv5Config, defaultConfig } from "../config/index.js"; import { createNodeContact, getNodeAddress, getNodeId, INodeAddress, NodeContact } from "../session/nodeInfo.js"; import { @@ -89,7 +81,7 @@ const log = debug("discv5:service"); export interface IDiscv5CreateOptions { enr: SignableENRInput; - peerId: PeerId; + privateKey: PrivateKey; bindAddrs: BindAddrs; config?: Partial; metricsRegistry?: MetricsRegister | null; @@ -207,16 +199,15 @@ export class Discv5 extends (EventEmitter as { new (): Discv5EventEmitter }) { * Convenience method to create a new discv5 service. * * @param enr the ENR record identifying the current node. - * @param peerId the PeerId with the keypair that identifies the enr + * @param privateKey the PrivateKey that identifies the enr * @param multiaddr The multiaddr which contains the network interface and port to which the UDP server binds */ public static create(opts: IDiscv5CreateOptions): Discv5 { - const { enr, peerId, bindAddrs, config = {}, metricsRegistry, transport } = opts; + const { enr, privateKey, bindAddrs, config = {}, metricsRegistry, transport } = opts; const fullConfig = { ...defaultConfig, ...config }; const metrics = metricsRegistry ? createDiscv5Metrics(metricsRegistry) : undefined; - const { type, privateKey } = createPrivateKeyFromPeerId(peerId); - const keypair = createKeypair({ type, privateKey }); - const decodedEnr = typeof enr === "string" ? SignableENR.decodeTxt(enr, privateKey) : enr; + const keypair = createKeypair({ type: privateKey.type, privateKey: privateKey.raw }); + const decodedEnr = typeof enr === "string" ? SignableENR.decodeTxt(enr, privateKey.raw) : enr; const rateLimiter = opts.rateLimiterOpts && new RateLimiter(opts.rateLimiterOpts, metrics ?? null); const sessionService = new SessionService( fullConfig, @@ -309,7 +300,7 @@ export class Discv5 extends (EventEmitter as { new (): Discv5EventEmitter }) { return this.sessionService.keypair; } - public peerId(): Promise { + public get peerId(): PeerId { return createPeerIdFromPublicKey(this.keypair.type, this.keypair.publicKey); } diff --git a/packages/discv5/src/service/types.ts b/packages/discv5/src/service/types.ts index b1c978f8..72f55e7e 100644 --- a/packages/discv5/src/service/types.ts +++ b/packages/discv5/src/service/types.ts @@ -1,6 +1,5 @@ import { EventEmitter } from "events"; import StrictEventEmitter from "strict-event-emitter-types"; -import { CodeError } from "@libp2p/interface"; import { Multiaddr } from "@multiformats/multiaddr"; import { ENR, SequenceNumber, SignableENR } from "@chainsafe/enr"; @@ -14,7 +13,7 @@ import { } from "../message/index.js"; import { INodeAddress, NodeContact } from "../session/nodeInfo.js"; import { ConnectionDirection } from "../session/index.js"; -import { SocketAddress } from "../util/ip.js"; +import { CodeError, SocketAddress } from "../util/index.js"; export interface IDiscv5Events { /** diff --git a/packages/discv5/src/session/nodeInfo.ts b/packages/discv5/src/session/nodeInfo.ts index 2218d8e7..9ff09144 100644 --- a/packages/discv5/src/session/nodeInfo.ts +++ b/packages/discv5/src/session/nodeInfo.ts @@ -1,6 +1,6 @@ import { Multiaddr, isMultiaddr } from "@multiformats/multiaddr"; import { peerIdFromString } from "@libp2p/peer-id"; -import { createPublicKeyFromPeerId, ENR, NodeId, getV4Crypto } from "@chainsafe/enr"; +import { ENR, NodeId, getV4Crypto } from "@chainsafe/enr"; import { createKeypair, IKeypair } from "../keypair/index.js"; import { IPMode } from "../transport/types.js"; import { getSocketAddressMultiaddrOnENR } from "../util/ip.js"; @@ -81,8 +81,11 @@ export function createNodeContact(input: ENR | Multiaddr, ipMode: IPMode): NodeC throw new Error("Multiaddr must specify a peer id"); } const peerId = peerIdFromString(peerIdStr); - const { type, publicKey } = createPublicKeyFromPeerId(peerId); - const keypair = createKeypair({ type, publicKey }); + const publicKey = peerId.publicKey; + if (!publicKey) { + throw new Error("Peer ID must have a public key"); + } + const keypair = createKeypair({ type: publicKey.type, publicKey: publicKey.raw }); const nodeId = getV4Crypto().nodeId(keypair.publicKey); return { type: INodeContactType.Raw, diff --git a/packages/discv5/src/util/error.ts b/packages/discv5/src/util/error.ts new file mode 100644 index 00000000..1ba33693 --- /dev/null +++ b/packages/discv5/src/util/error.ts @@ -0,0 +1,7 @@ +export class CodeError extends Error { + code: string; + constructor(message: string, code: string) { + super(message); + this.code = code; + } +} diff --git a/packages/discv5/src/util/index.ts b/packages/discv5/src/util/index.ts index 7455b396..4a477454 100644 --- a/packages/discv5/src/util/index.ts +++ b/packages/discv5/src/util/index.ts @@ -3,3 +3,4 @@ export * from "./timeoutMap.js"; export * from "./toBuffer.js"; export * from "./crypto.js"; export * from "./ip.js"; +export * from "./error.js"; diff --git a/packages/discv5/test/e2e/connect.test.ts b/packages/discv5/test/e2e/connect.test.ts index cfed08bf..038a42f9 100644 --- a/packages/discv5/test/e2e/connect.test.ts +++ b/packages/discv5/test/e2e/connect.test.ts @@ -1,9 +1,8 @@ /* eslint-env mocha */ import { expect } from "chai"; +import { privateKeyFromProtobuf } from "@libp2p/crypto/keys"; +import { PrivateKey } from "@libp2p/interface"; import { multiaddr } from "@multiformats/multiaddr"; -import { PeerId } from "@libp2p/interface"; -import { createFromPrivKey } from "@libp2p/peer-id-factory"; -import { unmarshalPrivateKey } from "@libp2p/crypto/keys"; import { SignableENR } from "@chainsafe/enr"; import { Discv5 } from "../../src/index.js"; @@ -14,15 +13,15 @@ describe("discv5 integration test", function () { const nodes: Discv5[] = []; type Node = { - peerId: PeerId; + privateKey: PrivateKey; enr: SignableENR; discv5: Discv5; }; async function getDiscv5Node(): Promise { const idx = nodeIdx++; const port = portBase + idx; - const peerId = await getPeerId(idx); - const enr = SignableENR.createFromPeerId(peerId); + const privateKey = getPrivateKey(idx); + const enr = SignableENR.createFromPrivateKey(privateKey); const bindAddrUdp = `/ip4/127.0.0.1/udp/${port}`; const multiAddrUdp = multiaddr(bindAddrUdp); @@ -30,7 +29,7 @@ describe("discv5 integration test", function () { const discv5 = Discv5.create({ enr, - peerId, + privateKey, bindAddrs: { ip4: multiAddrUdp }, config: { lookupTimeout: 2000, @@ -41,7 +40,7 @@ describe("discv5 integration test", function () { await discv5.start(); - return { peerId, enr, discv5 }; + return { privateKey, enr, discv5 }; } // 2862ae92fa59042fd4d4a3e3bddb92b33a53b72be15deafce07dfbd7c3b12812 @@ -87,7 +86,7 @@ describe("discv5 integration test", function () { }); }); -async function getPeerId(i: number): Promise { +function getPrivateKey(i: number): PrivateKey { const privKeysBase64 = [ "CAISIF9nhmNn+vOoMPdR+adfKwjSdgqrVGmAX0AWe6Tgjj/p", "CAISIMSR1N4+3m62NGJ8pdgiUPzFR4vv8pZKG6q+iys+B2DL", @@ -100,5 +99,5 @@ async function getPeerId(i: number): Promise { "CAISIHRKcVKLTpKhQOEIPwQjH2xx/nvJWWLUCr90/NOuuZ+l", "CAISIP3n7vFWZKye7duop0nhfttFJUXTVvQfd4q0dPpURLke", ]; - return await createFromPrivKey(await unmarshalPrivateKey(Buffer.from(privKeysBase64[i], "base64"))); + return privateKeyFromProtobuf(Buffer.from(privKeysBase64[i], "base64")); } diff --git a/packages/discv5/test/e2e/mainnetBootnodes.test.ts b/packages/discv5/test/e2e/mainnetBootnodes.test.ts index 756b921f..2300742f 100644 --- a/packages/discv5/test/e2e/mainnetBootnodes.test.ts +++ b/packages/discv5/test/e2e/mainnetBootnodes.test.ts @@ -1,8 +1,7 @@ /* eslint-env mocha */ import { expect } from "chai"; +import { generateKeyPair, privateKeyFromProtobuf } from "@libp2p/crypto/keys"; import { multiaddr } from "@multiformats/multiaddr"; -import { createSecp256k1PeerId, createFromPrivKey } from "@libp2p/peer-id-factory"; -import { unmarshalPrivateKey } from "@libp2p/crypto/keys"; import { ENR, SignableENR } from "@chainsafe/enr"; import { Discv5 } from "../../src/index.js"; @@ -11,7 +10,7 @@ let port = 9000; describe("discv5 integration test", function () { this.timeout("5min"); - const RANDOM_PEER_ID = true; // Otherwise uses a fixed private key + const RANDOM_PRIVATE_KEY = true; // Otherwise uses a fixed private key const bootnodesENRText = getMainnetBootnodesENRText(); for (const bindAddrs of [ @@ -30,19 +29,17 @@ describe("discv5 integration test", function () { // ip6 test fails in github runner if (process.env.CI && bindAddrs.ip6) this.skip(); - const peerId = RANDOM_PEER_ID - ? await createSecp256k1PeerId() - : await createFromPrivKey( - await unmarshalPrivateKey( - Buffer.from("080212205465237331224a07d9c7b9c458e0859f401ab49f01c971857d373a3e6f6fdf3a", "hex") - ) + const privateKey = RANDOM_PRIVATE_KEY + ? await generateKeyPair("secp256k1") + : privateKeyFromProtobuf( + Buffer.from("080212205465237331224a07d9c7b9c458e0859f401ab49f01c971857d373a3e6f6fdf3a", "hex") ); - const enr = SignableENR.createFromPeerId(peerId); + const enr = SignableENR.createFromPrivateKey(privateKey); const discv5 = Discv5.create({ enr, - peerId, + privateKey, bindAddrs, config: { lookupTimeout: 2000, diff --git a/packages/discv5/test/unit/keypair/index.test.ts b/packages/discv5/test/unit/keypair/index.test.ts deleted file mode 100644 index 5b093a8f..00000000 --- a/packages/discv5/test/unit/keypair/index.test.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { expect } from "chai"; -import { createFromPrivKey, createFromPubKey } from "@libp2p/peer-id-factory"; -import { supportedKeys } from "@libp2p/crypto/keys"; -import { createPeerIdFromPrivateKey, createPeerIdFromPublicKey } from "@chainsafe/enr"; -import { generateKeypair } from "../../../src/keypair/index.js"; - -describe("createPeerIdFromPrivateKey", function () { - it("should properly create a PeerId from a secp256k1 private key", async function () { - const keypair = generateKeypair("secp256k1"); - const privKey = new supportedKeys.secp256k1.Secp256k1PrivateKey(keypair.privateKey, keypair.publicKey); - - const expectedPeerId = await createFromPrivKey(privKey); - const actualPeerId = await createPeerIdFromPrivateKey(keypair.type, keypair.privateKey); - - expect(actualPeerId).to.be.deep.equal(expectedPeerId); - }); - it("should properly create a PeerId from a secp256k1 public key", async function () { - const keypair = generateKeypair("secp256k1"); - delete (keypair as any)._privateKey; - const pubKey = new supportedKeys.secp256k1.Secp256k1PublicKey(keypair.publicKey); - - const expectedPeerId = await createFromPubKey(pubKey); - const actualPeerId = await createPeerIdFromPublicKey(keypair.type, keypair.publicKey); - - expect(actualPeerId).to.be.deep.equal(expectedPeerId); - }); -}); diff --git a/packages/discv5/test/unit/service/service.test.ts b/packages/discv5/test/unit/service/service.test.ts index a10f1923..4d94f601 100644 --- a/packages/discv5/test/unit/service/service.test.ts +++ b/packages/discv5/test/unit/service/service.test.ts @@ -1,18 +1,19 @@ /* eslint-env mocha */ import { expect } from "chai"; +import { privateKeyFromRaw } from "@libp2p/crypto/keys"; import { multiaddr } from "@multiformats/multiaddr"; -import { createPeerIdFromPrivateKey, SignableENR } from "@chainsafe/enr"; +import { SignableENR } from "@chainsafe/enr"; import { Discv5 } from "../../../src/service/service.js"; import { generateKeypair } from "../../../src/keypair/index.js"; describe("Discv5", async () => { const kp0 = generateKeypair("secp256k1"); - const peerId0 = await createPeerIdFromPrivateKey(kp0.type, kp0.privateKey); + const privateKey0 = privateKeyFromRaw(kp0.privateKey); const enr0 = SignableENR.createV4(kp0.privateKey); const mu0 = multiaddr("/ip4/127.0.0.1/udp/40000"); - const service0 = Discv5.create({ enr: enr0, peerId: peerId0, bindAddrs: { ip4: mu0 } }); + const service0 = Discv5.create({ enr: enr0, privateKey: privateKey0, bindAddrs: { ip4: mu0 } }); beforeEach(async () => { await service0.start(); @@ -41,7 +42,7 @@ describe("Discv5", async () => { it("should complete a lookup to another node", async function () { this.timeout(10000); const kp1 = generateKeypair("secp256k1"); - const peerId1 = await createPeerIdFromPrivateKey(kp1.type, kp1.privateKey); + const privateKey1 = privateKeyFromRaw(kp1.privateKey); const enr1 = SignableENR.createV4(kp1.privateKey); const mu1 = multiaddr("/ip4/127.0.0.1/udp/10360"); const addr1 = mu1.tuples(); @@ -53,7 +54,7 @@ describe("Discv5", async () => { enr1.set("ip", addr1[0][1]); enr1.set("udp", addr1[1][1]); enr1.encode(); - const service1 = Discv5.create({ enr: enr1, peerId: peerId1, bindAddrs: { ip4: mu1 } }); + const service1 = Discv5.create({ enr: enr1, privateKey: privateKey1, bindAddrs: { ip4: mu1 } }); await service1.start(); for (let i = 0; i < 100; i++) { const kp = generateKeypair("secp256k1"); diff --git a/packages/enr/package.json b/packages/enr/package.json index b9845bdc..9260c389 100644 --- a/packages/enr/package.json +++ b/packages/enr/package.json @@ -50,16 +50,15 @@ }, "homepage": "https://github.com/ChainSafe/discv5#readme", "devDependencies": { - "@libp2p/peer-id-factory": "^4.0.3", "@types/bn.js": "^4.11.5" }, "dependencies": { - "@libp2p/crypto": "^4.0.1", - "@libp2p/interface": "^1.1.1", - "@libp2p/peer-id": "^4.0.4", + "@libp2p/crypto": "^5.0.0", + "@libp2p/interface": "^2.0.0", + "@libp2p/peer-id": "^5.0.0", "@multiformats/multiaddr": "^12.1.10", "bigint-buffer": "^1.1.5", - "ethereum-cryptography": "^2.1.3", + "ethereum-cryptography": "^2.2.0", "rlp": "^2.2.6", "uint8-varint": "^2.0.2", "uint8arrays": "^5.0.1" diff --git a/packages/enr/src/enr.ts b/packages/enr/src/enr.ts index 41bf8342..1ef9dc5f 100644 --- a/packages/enr/src/enr.ts +++ b/packages/enr/src/enr.ts @@ -1,12 +1,12 @@ import { Multiaddr, multiaddr, protocols } from "@multiformats/multiaddr"; import * as RLP from "rlp"; -import { KeyType, PeerId } from "@libp2p/interface"; +import { KeyType, PeerId, PrivateKey } from "@libp2p/interface"; import { convertToString, convertToBytes } from "@multiformats/multiaddr/convert"; import { encode as varintEncode } from "uint8-varint"; import { ERR_INVALID_ID, MAX_RECORD_SIZE } from "./constants.js"; import { ENRKey, ENRValue, SequenceNumber, NodeId } from "./types.js"; -import { createPeerIdFromPublicKey, createPrivateKeyFromPeerId } from "./peerId.js"; +import { createPeerIdFromPublicKey } from "./peerId.js"; import { fromBase64url, toBase64url, toBigInt, toNewUint8Array } from "./util.js"; import { getV4Crypto } from "./crypto.js"; import { compare, fromString, toString } from "uint8arrays"; @@ -265,7 +265,7 @@ export abstract class BaseENR { get keypairType(): KeyType { return keyType(this.id); } - async peerId(): Promise { + get peerId(): PeerId { return createPeerIdFromPublicKey(this.keypairType, this.publicKey); } @@ -356,7 +356,7 @@ export abstract class BaseENR { async getFullMultiaddr(protocol: Protocol): Promise { const locationMultiaddr = this.getLocationMultiaddr(protocol); if (locationMultiaddr) { - const peerId = await this.peerId(); + const peerId = this.peerId; return locationMultiaddr.encapsulate(`/p2p/${peerId.toString()}`); } } @@ -488,11 +488,10 @@ export class SignableENR extends BaseENR { privateKey ); } - static createFromPeerId(peerId: PeerId, kvs: Record = {}): SignableENR { - const { type, privateKey } = createPrivateKeyFromPeerId(peerId); - switch (type) { + static createFromPrivateKey(privateKey: PrivateKey, kvs: Record = {}): SignableENR { + switch (privateKey.type) { case "secp256k1": - return SignableENR.createV4(privateKey, kvs); + return SignableENR.createV4(privateKey.raw, kvs); default: throw new Error(); } @@ -537,7 +536,7 @@ export class SignableENR extends BaseENR { // Identity methods - async peerId(): Promise { + get peerId(): PeerId { return createPeerIdFromPublicKey(this.keypairType, this.publicKey); } diff --git a/packages/enr/src/peerId.ts b/packages/enr/src/peerId.ts index 93a35e58..4af9217c 100644 --- a/packages/enr/src/peerId.ts +++ b/packages/enr/src/peerId.ts @@ -1,52 +1,13 @@ import { KeyType, PeerId } from "@libp2p/interface"; -import { peerIdFromKeys } from "@libp2p/peer-id"; -import { keysPBM, supportedKeys } from "@libp2p/crypto/keys"; +import { peerIdFromPublicKey } from "@libp2p/peer-id"; +import { publicKeyFromRaw } from "@libp2p/crypto/keys"; export const ERR_TYPE_NOT_IMPLEMENTED = "Keypair type not implemented"; -/** Translate to KeyType from keysPBM enum */ -enum KeyTypeTranslator { - RSA = "RSA", - Ed25519 = "Ed25519", - Secp256k1 = "secp256k1", -} - -export async function createPeerIdFromPublicKey(type: KeyType, publicKey: Uint8Array): Promise { - switch (type) { - case "secp256k1": { - const pubKey = new supportedKeys.secp256k1.Secp256k1PublicKey(publicKey); - return peerIdFromKeys(pubKey.bytes); - } - default: - throw new Error(ERR_TYPE_NOT_IMPLEMENTED); - } -} - -export async function createPeerIdFromPrivateKey(type: KeyType, privateKey: Uint8Array): Promise { - switch (type) { - case "secp256k1": { - const privKey = new supportedKeys.secp256k1.Secp256k1PrivateKey(privateKey); - return peerIdFromKeys(privKey.public.bytes, privKey.bytes); - } - default: - throw new Error(ERR_TYPE_NOT_IMPLEMENTED); - } -} - -export function createPublicKeyFromPeerId(peerId: PeerId): { type: KeyType; publicKey: Uint8Array } { - // pub/privkey bytes from peer-id are encoded in protobuf format - if (!peerId.publicKey) { - throw new Error("Public key required"); - } - const pub = keysPBM.PublicKey.decode(peerId.publicKey); - return { type: KeyTypeTranslator[pub.Type!], publicKey: pub.Data! }; -} - -export function createPrivateKeyFromPeerId(peerId: PeerId): { type: KeyType; privateKey: Uint8Array } { - // pub/privkey bytes from peer-id are encoded in protobuf format - if (!peerId.privateKey) { - throw new Error("Private key required"); +export function createPeerIdFromPublicKey(type: KeyType, publicKey: Uint8Array): PeerId { + const pubKey = publicKeyFromRaw(publicKey); + if (pubKey.type !== "secp256k1") { + throw new Error(ERR_TYPE_NOT_IMPLEMENTED); } - const priv = keysPBM.PrivateKey.decode(peerId.privateKey); - return { type: KeyTypeTranslator[priv.Type!], privateKey: priv.Data! }; + return peerIdFromPublicKey(pubKey); } diff --git a/packages/enr/test/unit/enr.test.ts b/packages/enr/test/unit/enr.test.ts index 79af936d..eb749ece 100644 --- a/packages/enr/test/unit/enr.test.ts +++ b/packages/enr/test/unit/enr.test.ts @@ -1,7 +1,7 @@ /* eslint-env mocha */ import { expect } from "chai"; +import { generateKeyPair } from "@libp2p/crypto/keys"; import { multiaddr } from "@multiformats/multiaddr"; -import { createSecp256k1PeerId } from "@libp2p/peer-id-factory"; import { BaseENR, ENR, SignableENR, getV4Crypto } from "../../src/index.js"; const toHex = (buf: Uint8Array): string => Buffer.from(buf).toString("hex"); @@ -148,8 +148,8 @@ describe("ENR multiaddr support", () => { const udp = 8080; const quic = 8081; - const peerId = await createSecp256k1PeerId(); - const enr = SignableENR.createFromPeerId(peerId); + const privateKey = await generateKeyPair("secp256k1"); + const enr = SignableENR.createFromPrivateKey(privateKey); enr.ip = ip4; enr.ip6 = ip6; enr.tcp = tcp; @@ -227,8 +227,8 @@ describe("ENR multiaddr support", () => { describe("ENR", function () { describe("decodeTxt", () => { it("should encodeTxt and decodeTxt", async () => { - const peerId = await createSecp256k1PeerId(); - const enr = SignableENR.createFromPeerId(peerId); + const privateKey = await generateKeyPair("secp256k1"); + const enr = SignableENR.createFromPrivateKey(privateKey); enr.setLocationMultiaddr(multiaddr("/ip4/18.223.219.100/udp/9000")); const txt = enr.encodeTxt(); expect(txt.slice(0, 4)).to.be.equal("enr:"); @@ -248,8 +248,8 @@ describe("ENR", function () { }); it("should encodeTxt and decodeTxt ipv6 enr successfully", async () => { - const peerId = await createSecp256k1PeerId(); - const enr = SignableENR.createFromPeerId(peerId); + const privateKey = await generateKeyPair("secp256k1"); + const enr = SignableENR.createFromPrivateKey(privateKey); enr.setLocationMultiaddr(multiaddr("/ip6/aaaa:aaaa:aaaa:aaaa:aaaa:aaaa:aaaa:aaaa/udp/9000")); const enr2 = ENR.decodeTxt(enr.encodeTxt()); expect(enr2.udp6).to.equal(9000); diff --git a/yarn.lock b/yarn.lock index 216bb5b6..a76ab8f4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -452,6 +452,11 @@ "@jridgewell/resolve-uri" "^3.1.0" "@jridgewell/sourcemap-codec" "^1.4.14" +"@leichtgewicht/ip-codec@^2.0.1": + version "2.0.5" + resolved "https://registry.yarnpkg.com/@leichtgewicht/ip-codec/-/ip-codec-2.0.5.tgz#4fc56c15c580b9adb7dc3c333a134e540b44bfb1" + integrity sha512-Vo+PSpZG2/fmgmiNzYK9qWRh8h/CHrwD0mo1h1DzL4yzHNSfWYujGTYsWGreD000gcgmZ7K4Ys6Tx9TxtsKdDw== + "@lerna/child-process@7.4.2": version "7.4.2" resolved "https://registry.yarnpkg.com/@lerna/child-process/-/child-process-7.4.2.tgz#a2fd013ac2150dc288270d3e0d0b850c06bec511" @@ -532,77 +537,90 @@ yargs "16.2.0" yargs-parser "20.2.4" -"@libp2p/crypto@^4.0.1": - version "4.0.1" - resolved "https://registry.yarnpkg.com/@libp2p/crypto/-/crypto-4.0.1.tgz#350f3397c8fba18d30a74173c3791fe199821062" - integrity sha512-lKGbX8TvQt4JbqlttdexEz2VtYJnTwY31kVBDQviwt0pMF+6Uy2hzNnEQ1FHZBwnow8BIlyb6UevHfgyOFlnkw== +"@libp2p/crypto@^5.0.0": + version "5.0.0" + resolved "https://registry.yarnpkg.com/@libp2p/crypto/-/crypto-5.0.0.tgz#708a7a4d227593cffe3ba819d42cf217523142af" + integrity sha512-qU3D2jApJNIp0VMZ2B2QhZ1PK9sTnc4WTQ7NZ/LbZC9hDfeqZlviHhgwWzy0L6d7P0ScDi+XdIX5zxxugOL6DA== dependencies: - "@libp2p/interface" "^1.1.2" - "@noble/curves" "^1.1.0" - "@noble/hashes" "^1.3.3" + "@libp2p/interface" "^2.0.0" + "@noble/curves" "^1.4.0" + "@noble/hashes" "^1.4.0" asn1js "^3.0.5" - multiformats "^13.0.0" - protons-runtime "^5.0.0" - uint8arraylist "^2.4.7" - uint8arrays "^5.0.0" + multiformats "^13.1.0" + protons-runtime "^5.4.0" + uint8arraylist "^2.4.8" + uint8arrays "^5.1.0" -"@libp2p/interface@^1.0.0", "@libp2p/interface@^1.1.1", "@libp2p/interface@^1.1.2": - version "1.1.2" - resolved "https://registry.yarnpkg.com/@libp2p/interface/-/interface-1.1.2.tgz#debfd9d1bd4b81929c9e30eb35c2801ca246ce2b" - integrity sha512-uC4hxtEJuWiDiZfokkSNEEbCzdyZrqb5kp67Wc5PjZsySZ2IoImdIfie003yQXlB1xBp/XUJzdC6kVu4M7LUmg== +"@libp2p/interface@^2.0.0": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@libp2p/interface/-/interface-2.0.0.tgz#bcec0c4e347516f31fd4e08ede40f5fde0eddc35" + integrity sha512-NaPyfEFcxRzu3jL3z3lsX84+Dvnu9RpeHI9SjdYvcsEnIQbRllDgA9rmA8SnQkyNKlW9V37UkXAQCQnIaOvT1Q== dependencies: - "@multiformats/multiaddr" "^12.1.10" + "@multiformats/multiaddr" "^12.2.3" it-pushable "^3.2.3" it-stream-types "^2.0.1" - multiformats "^13.0.0" + multiformats "^13.1.0" progress-events "^1.0.0" - uint8arraylist "^2.4.7" - -"@libp2p/peer-id-factory@^4.0.3": - version "4.0.5" - resolved "https://registry.yarnpkg.com/@libp2p/peer-id-factory/-/peer-id-factory-4.0.5.tgz#a8b3b87ba3657ed0c19cac9cc71ffc3a20e52c94" - integrity sha512-9fy1TCiBViqIFuoFzW/o9fVh3j600IYDHaXUqvx6HQFeB/dEM8utRU4FxVZVv/MMcKfUf7mydHXVHRyp28uG8w== - dependencies: - "@libp2p/crypto" "^4.0.1" - "@libp2p/interface" "^1.1.2" - "@libp2p/peer-id" "^4.0.5" - protons-runtime "^5.0.0" - uint8arraylist "^2.4.7" - uint8arrays "^5.0.0" + uint8arraylist "^2.4.8" -"@libp2p/peer-id@^4.0.4", "@libp2p/peer-id@^4.0.5": - version "4.0.5" - resolved "https://registry.yarnpkg.com/@libp2p/peer-id/-/peer-id-4.0.5.tgz#ed8be246b4d7ba2b7806968b4bfa8d59b82a4b2a" - integrity sha512-/J9U6I/CWSOsYrTpFZpRQrhOhi+bp9WFp7+9Gc7kVt/oevIYTapUEjpxevjViem9ddR5RbdYeCj4ZLHA04QOoQ== +"@libp2p/peer-id@^5.0.0": + version "5.0.0" + resolved "https://registry.yarnpkg.com/@libp2p/peer-id/-/peer-id-5.0.0.tgz#39f8b702437e0cd4f89881145bb2a53e1fd8456c" + integrity sha512-1niX7fZJsOXKCs0UtArtgmNbEHkO6MDA/IfAZ84wBW/qAvdXbvxqYazWYKBfTRrD+3MG1GQ5l3MR8ciRx8pyyg== dependencies: - "@libp2p/interface" "^1.1.2" - multiformats "^13.0.0" - uint8arrays "^5.0.0" + "@libp2p/crypto" "^5.0.0" + "@libp2p/interface" "^2.0.0" + multiformats "^13.1.0" + uint8arrays "^5.1.0" -"@multiformats/multiaddr@^12.1.10": - version "12.1.12" - resolved "https://registry.yarnpkg.com/@multiformats/multiaddr/-/multiaddr-12.1.12.tgz#d1609933dc5589d53f6b77fb88fe5e5ea787deae" - integrity sha512-hrY4uN/oeYhn410jBSpVXn37eenn4djKOj6Dh20Yh4xzGgqmS6u+/X08zQfHgWNjk7NJejPUcRfHEfs8e/MOcw== +"@multiformats/dns@^1.0.3": + version "1.0.6" + resolved "https://registry.yarnpkg.com/@multiformats/dns/-/dns-1.0.6.tgz#b8c7de11459a02a5f4e609d35d3cdb95cb6ad152" + integrity sha512-nt/5UqjMPtyvkG9BQYdJ4GfLK3nMqGpFZOzf4hAmIa0sJh2LlS9YKXZ4FgwBDsaHvzZqR/rUFIywIc7pkHNNuw== + dependencies: + "@types/dns-packet" "^5.6.5" + buffer "^6.0.3" + dns-packet "^5.6.1" + hashlru "^2.3.0" + p-queue "^8.0.1" + progress-events "^1.0.0" + uint8arrays "^5.0.2" + +"@multiformats/multiaddr@^12.1.10", "@multiformats/multiaddr@^12.2.3": + version "12.3.1" + resolved "https://registry.yarnpkg.com/@multiformats/multiaddr/-/multiaddr-12.3.1.tgz#953ceb4ae3b39125b7b2c721230ea7b398cf49fe" + integrity sha512-yoGODQY4nIj41ENJClucS8FtBoe8w682bzbKldEQr9lSlfdHqAsRC+vpJAOBpiMwPps1tHua4kxrDmvprdhoDQ== dependencies: "@chainsafe/is-ip" "^2.0.1" "@chainsafe/netmask" "^2.0.0" - "@libp2p/interface" "^1.0.0" - dns-over-http-resolver "3.0.0" + "@multiformats/dns" "^1.0.3" multiformats "^13.0.0" uint8-varint "^2.0.1" uint8arrays "^5.0.0" -"@noble/curves@1.3.0", "@noble/curves@^1.1.0", "@noble/curves@~1.3.0": - version "1.3.0" - resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.3.0.tgz#01be46da4fd195822dab821e72f71bf4aeec635e" - integrity sha512-t01iSXPuN+Eqzb4eBX0S5oubSqXbK/xXa1Ne18Hj8f9pStxztHCE2gfboSp/dZRLSqfuLpRK2nDXDK+W9puocA== +"@noble/curves@1.4.2", "@noble/curves@~1.4.0": + version "1.4.2" + resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.4.2.tgz#40309198c76ed71bc6dbf7ba24e81ceb4d0d1fe9" + integrity sha512-TavHr8qycMChk8UwMld0ZDRvatedkzWfH8IiaeGCfymOP5i0hSCozz9vHOL0nkwk7HRMlFnAiKpS2jrUmSybcw== dependencies: - "@noble/hashes" "1.3.3" + "@noble/hashes" "1.4.0" -"@noble/hashes@1.3.3", "@noble/hashes@^1.3.3", "@noble/hashes@~1.3.2": - version "1.3.3" - resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.3.tgz#39908da56a4adc270147bb07968bf3b16cfe1699" - integrity sha512-V7/fPHgl+jsVPXqqeOzT8egNj2iBIVt+ECeMMG8TdcnTikP3oaBtUVqpT/gYCR68aEBJSF+XbYUxStjbFMqIIA== +"@noble/curves@^1.4.0": + version "1.6.0" + resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.6.0.tgz#be5296ebcd5a1730fccea4786d420f87abfeb40b" + integrity sha512-TlaHRXDehJuRNR9TfZDNQ45mMEd5dwUwmicsafcIX4SsNiqnCHKjE/1alYPd/lDRVhxdhUAlv8uEhMCI5zjIJQ== + dependencies: + "@noble/hashes" "1.5.0" + +"@noble/hashes@1.4.0", "@noble/hashes@~1.4.0": + version "1.4.0" + resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.4.0.tgz#45814aa329f30e4fe0ba49426f49dfccdd066426" + integrity sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg== + +"@noble/hashes@1.5.0", "@noble/hashes@^1.4.0": + version "1.5.0" + resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.5.0.tgz#abadc5ca20332db2b1b2aa3e496e9af1213570b0" + integrity sha512-1j6kQFb7QRru7eKN3ZDvRcP13rugwdxZqCjbiAVZfIJwgj2A65UmT4TgARXGlXgnRkORLTDTrO19ZErt7+QXgA== "@nodelib/fs.scandir@2.1.5": version "2.1.5" @@ -991,27 +1009,27 @@ resolved "https://registry.yarnpkg.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz#a77ea742fab25775145434eb1d2328cf5013ac33" integrity sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg== -"@scure/base@~1.1.4": - version "1.1.5" - resolved "https://registry.yarnpkg.com/@scure/base/-/base-1.1.5.tgz#1d85d17269fe97694b9c592552dd9e5e33552157" - integrity sha512-Brj9FiG2W1MRQSTB212YVPRrcbjkv48FoZi/u4l/zds/ieRrqsh7aUf6CLwkAq61oKXr/ZlTzlY66gLIj3TFTQ== +"@scure/base@~1.1.6": + version "1.1.8" + resolved "https://registry.yarnpkg.com/@scure/base/-/base-1.1.8.tgz#8f23646c352f020c83bca750a82789e246d42b50" + integrity sha512-6CyAclxj3Nb0XT7GHK6K4zK6k2xJm6E4Ft0Ohjt4WgegiFUHEtFb2CGzmPmGBwoIhrLsqNLYfLr04Y1GePrzZg== -"@scure/bip32@1.3.3": - version "1.3.3" - resolved "https://registry.yarnpkg.com/@scure/bip32/-/bip32-1.3.3.tgz#a9624991dc8767087c57999a5d79488f48eae6c8" - integrity sha512-LJaN3HwRbfQK0X1xFSi0Q9amqOgzQnnDngIt+ZlsBC3Bm7/nE7K0kwshZHyaru79yIVRv/e1mQAjZyuZG6jOFQ== +"@scure/bip32@1.4.0": + version "1.4.0" + resolved "https://registry.yarnpkg.com/@scure/bip32/-/bip32-1.4.0.tgz#4e1f1e196abedcef395b33b9674a042524e20d67" + integrity sha512-sVUpc0Vq3tXCkDGYVWGIZTRfnvu8LoTDaev7vbwh0omSvVORONr960MQWdKqJDCReIEmTj3PAr73O3aoxz7OPg== dependencies: - "@noble/curves" "~1.3.0" - "@noble/hashes" "~1.3.2" - "@scure/base" "~1.1.4" + "@noble/curves" "~1.4.0" + "@noble/hashes" "~1.4.0" + "@scure/base" "~1.1.6" -"@scure/bip39@1.2.2": - version "1.2.2" - resolved "https://registry.yarnpkg.com/@scure/bip39/-/bip39-1.2.2.tgz#f3426813f4ced11a47489cbcf7294aa963966527" - integrity sha512-HYf9TUXG80beW+hGAt3TRM8wU6pQoYur9iNypTROm42dorCGmLnFe3eWjz3gOq6G62H2WRh0FCzAR1PI+29zIA== +"@scure/bip39@1.3.0": + version "1.3.0" + resolved "https://registry.yarnpkg.com/@scure/bip39/-/bip39-1.3.0.tgz#0f258c16823ddd00739461ac31398b4e7d6a18c3" + integrity sha512-disdg7gHuTDZtY+ZdkmLpPCk7fxZSu3gBiEGuoC1XYxv9cGx3Z6cpTggCgW6odSOOIXCiDjuGejW+aJKCY/pIQ== dependencies: - "@noble/hashes" "~1.3.2" - "@scure/base" "~1.1.4" + "@noble/hashes" "~1.4.0" + "@scure/base" "~1.1.6" "@sigstore/bundle@^1.1.0": version "1.1.0" @@ -1104,6 +1122,13 @@ dependencies: "@types/ms" "*" +"@types/dns-packet@^5.6.5": + version "5.6.5" + resolved "https://registry.yarnpkg.com/@types/dns-packet/-/dns-packet-5.6.5.tgz#49fc29a40f5d30227ed028fa1ee82601d3745e15" + integrity sha512-qXOC7XLOEe43ehtWJCMnQXvgcIpv6rPmQ1jXT98Ad8A3TB1Ue50jsCbSSSyuazScEuZ/Q026vHbrOTVkmwA+7Q== + dependencies: + "@types/node" "*" + "@types/eslint@^6.1.3": version "6.8.1" resolved "https://registry.yarnpkg.com/@types/eslint/-/eslint-6.8.1.tgz#e26f365a5dda12445d1d5a17eb70efd7c844a3d8" @@ -1753,6 +1778,14 @@ buffer@^5.5.0: base64-js "^1.3.1" ieee754 "^1.1.13" +buffer@^6.0.3: + version "6.0.3" + resolved "https://registry.yarnpkg.com/buffer/-/buffer-6.0.3.tgz#2ace578459cc8fbe2a70aaa8f52ee63b6a74c6c6" + integrity sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA== + dependencies: + base64-js "^1.3.1" + ieee754 "^1.2.1" + bufio@~1.0.7: version "1.0.7" resolved "https://registry.yarnpkg.com/bufio/-/bufio-1.0.7.tgz#b7f63a1369a0829ed64cc14edf0573b3e382a33e" @@ -2439,13 +2472,12 @@ dir-glob@^3.0.1: dependencies: path-type "^4.0.0" -dns-over-http-resolver@3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/dns-over-http-resolver/-/dns-over-http-resolver-3.0.0.tgz#2a8edcfb1c830cc3fff0cd37f01b824a55fa209a" - integrity sha512-5+BI+B7n8LKhNaEZBYErr+CBd9t5nYtjunByLhrLGtZ+i3TRgiU8yE87pCjEBu2KOwNsD9ljpSXEbZ4S8xih5g== +dns-packet@^5.6.1: + version "5.6.1" + resolved "https://registry.yarnpkg.com/dns-packet/-/dns-packet-5.6.1.tgz#ae888ad425a9d1478a0674256ab866de1012cf2f" + integrity sha512-l4gcSouhcgIKRvyy99RNVOgxXiicE+2jZoNmaNmZ6JXiGajBOJAesk1OBlJuM5k2c+eudGdLxDqXuPCKIj6kpw== dependencies: - debug "^4.3.4" - receptacle "^1.3.2" + "@leichtgewicht/ip-codec" "^2.0.1" doctrine@^3.0.0: version "3.0.0" @@ -2771,15 +2803,15 @@ esutils@^2.0.2: resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== -ethereum-cryptography@^2.1.3: - version "2.1.3" - resolved "https://registry.yarnpkg.com/ethereum-cryptography/-/ethereum-cryptography-2.1.3.tgz#1352270ed3b339fe25af5ceeadcf1b9c8e30768a" - integrity sha512-BlwbIL7/P45W8FGW2r7LGuvoEZ+7PWsniMvQ4p5s2xCyw9tmaDlpfsN9HjAucbF+t/qpVHwZUisgfK24TCW8aA== +ethereum-cryptography@^2.2.0: + version "2.2.1" + resolved "https://registry.yarnpkg.com/ethereum-cryptography/-/ethereum-cryptography-2.2.1.tgz#58f2810f8e020aecb97de8c8c76147600b0b8ccf" + integrity sha512-r/W8lkHSiTLxUxW8Rf3u4HGB0xQweG2RyETjywylKZSzLWoWAijRz8WCuOtJ6wah+avllXBqZuk29HCCvhEIRg== dependencies: - "@noble/curves" "1.3.0" - "@noble/hashes" "1.3.3" - "@scure/bip32" "1.3.3" - "@scure/bip39" "1.2.2" + "@noble/curves" "1.4.2" + "@noble/hashes" "1.4.0" + "@scure/bip32" "1.4.0" + "@scure/bip39" "1.3.0" event-target-shim@^5.0.0: version "5.0.1" @@ -2791,6 +2823,11 @@ eventemitter3@^4.0.0, eventemitter3@^4.0.4: resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.7.tgz#2de9b68f6528d5644ef5c59526a1b4a07306169f" integrity sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw== +eventemitter3@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-5.0.1.tgz#53f5ffd0a492ac800721bb42c66b841de96423c4" + integrity sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA== + events@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/events/-/events-1.1.1.tgz#9ebdb7635ad099c70dcc4c2a1f5004288e8bd924" @@ -3399,6 +3436,11 @@ hasha@^3.0.0: dependencies: is-stream "^1.0.1" +hashlru@^2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/hashlru/-/hashlru-2.3.0.tgz#5dc15928b3f6961a2056416bb3a4910216fdfb51" + integrity sha512-0cMsjjIC8I+D3M44pOQdsy0OHXGLVz6Z0beRuufhKa0KfaD2wGwAev6jILzXsd3/vpnNQJmWyZtIILqM1N+n5A== + hasown@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/hasown/-/hasown-2.0.0.tgz#f4c513d454a57b7c7e1650778de226b11700546c" @@ -3515,7 +3557,7 @@ ieee754@1.1.13: resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.13.tgz#ec168558e95aa181fd87d37f55c32bbcb6708b84" integrity sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg== -ieee754@^1.1.13, ieee754@^1.1.4: +ieee754@^1.1.13, ieee754@^1.1.4, ieee754@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352" integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA== @@ -4677,6 +4719,11 @@ multiformats@^13.0.0: resolved "https://registry.yarnpkg.com/multiformats/-/multiformats-13.0.1.tgz#c0622affa5171189eacd57c06f977195ca7acb08" integrity sha512-bt3R5iXe2O8xpp3wkmQhC73b/lC4S2ihU8Dndwcsysqbydqb8N+bpP116qMcClZ17g58iSIwtXUTcg2zT4sniA== +multiformats@^13.1.0: + version "13.2.2" + resolved "https://registry.yarnpkg.com/multiformats/-/multiformats-13.2.2.tgz#16da153ee8b68d8c9da31b52176e90b3cd8b43ef" + integrity sha512-RWI+nyf0q64vyOxL8LbKtjJMki0sogRL/8axvklNtiTM0iFCVtHwME9w6+0P1/v4dQvsIg8A45oT3ka1t/M/+A== + multimatch@5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/multimatch/-/multimatch-5.0.0.tgz#932b800963cea7a31a033328fa1e0c3a1874dbe6" @@ -5183,6 +5230,14 @@ p-queue@6.6.2: eventemitter3 "^4.0.4" p-timeout "^3.2.0" +p-queue@^8.0.1: + version "8.0.1" + resolved "https://registry.yarnpkg.com/p-queue/-/p-queue-8.0.1.tgz#718b7f83836922ef213ddec263ff4223ce70bef8" + integrity sha512-NXzu9aQJTAzbBqOt2hwsR63ea7yvxJc0PwN/zobNAudYfb1B7R08SzB4TsLeSbUCuG467NhnoT0oO6w1qRO+BA== + dependencies: + eventemitter3 "^5.0.1" + p-timeout "^6.1.2" + p-reduce@2.1.0, p-reduce@^2.0.0, p-reduce@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/p-reduce/-/p-reduce-2.1.0.tgz#09408da49507c6c274faa31f28df334bc712b64a" @@ -5195,6 +5250,11 @@ p-timeout@^3.2.0: dependencies: p-finally "^1.0.0" +p-timeout@^6.1.2: + version "6.1.2" + resolved "https://registry.yarnpkg.com/p-timeout/-/p-timeout-6.1.2.tgz#22b8d8a78abf5e103030211c5fc6dee1166a6aa5" + integrity sha512-UbD77BuZ9Bc9aABo74gfXhNvzC9Tx7SxtHSh1fxvx3jTLLYvmVhiQZZrJzqqU0jKbN32kb5VOKiLEQI/3bIjgQ== + p-try@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/p-try/-/p-try-1.0.0.tgz#cbc79cdbaf8fd4228e13f621f2b1a237c1b207b3" @@ -5464,11 +5524,12 @@ protocols@^2.0.0, protocols@^2.0.1: resolved "https://registry.yarnpkg.com/protocols/-/protocols-2.0.1.tgz#8f155da3fc0f32644e83c5782c8e8212ccf70a86" integrity sha512-/XJ368cyBJ7fzLMwLKv1e4vLxOju2MNAIokcr7meSaNcVbWz/CPcW22cP04mwxOErdA5mwjA8Q6w/cdAQxVn7Q== -protons-runtime@^5.0.0: - version "5.2.2" - resolved "https://registry.yarnpkg.com/protons-runtime/-/protons-runtime-5.2.2.tgz#0b36918ebcbecb8b7eb90d11bb367342f480b2e8" - integrity sha512-o97rNPN9pE3cxOxjs/waZNRKlbY/DR11oc20rUvarWZgFzQLLLzJU0RFh5JPi6GJCN67VGVn9/FDIEtFblfB3A== +protons-runtime@^5.4.0: + version "5.5.0" + resolved "https://registry.yarnpkg.com/protons-runtime/-/protons-runtime-5.5.0.tgz#ea06d9ef843aad77ea5de3e1ebafa81b58c24570" + integrity sha512-EsALjF9QsrEk6gbCx3lmfHxVN0ah7nG3cY7GySD4xf4g8cr7g543zB88Foh897Sr1RQJ9yDCUsoT1i1H/cVUFA== dependencies: + uint8-varint "^2.0.2" uint8arraylist "^2.4.3" uint8arrays "^5.0.1" @@ -5661,13 +5722,6 @@ readdirp@~3.6.0: dependencies: picomatch "^2.2.1" -receptacle@^1.3.2: - version "1.3.2" - resolved "https://registry.yarnpkg.com/receptacle/-/receptacle-1.3.2.tgz#a7994c7efafc7a01d0e2041839dab6c4951360d2" - integrity sha512-HrsFvqZZheusncQRiEE7GatOAETrARKV/lnfYicIm8lbvp/JQOdADOfhjBd2DajvoszEyxSM6RlAAIZgEoeu/A== - dependencies: - ms "^2.1.1" - redent@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/redent/-/redent-3.0.0.tgz#e557b7998316bb53c9f1f56fa626352c6963059f" @@ -6111,7 +6165,16 @@ strict-event-emitter-types@^2.0.0: resolved "https://registry.yarnpkg.com/strict-event-emitter-types/-/strict-event-emitter-types-2.0.0.tgz#05e15549cb4da1694478a53543e4e2f4abcf277f" integrity sha512-Nk/brWYpD85WlOgzw5h173aci0Teyv8YdIAEtV+N88nDB0dLlazZyJMIsN6eo1/AR61l+p6CJTG1JIyFaoNEEA== -"string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: +"string-width-cjs@npm:string-width@^4.2.0": + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + +"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== @@ -6152,7 +6215,7 @@ string_decoder@~1.1.1: dependencies: safe-buffer "~5.1.0" -"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1: +"strip-ansi-cjs@npm:strip-ansi@^6.0.1": version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== @@ -6166,6 +6229,13 @@ strip-ansi@^5.0.0, strip-ansi@^5.1.0, strip-ansi@^5.2.0: dependencies: ansi-regex "^4.1.0" +strip-ansi@^6.0.0, strip-ansi@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + strip-ansi@^7.0.1: version "7.1.0" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45" @@ -6498,7 +6568,7 @@ uint8-varint@^2.0.1, uint8-varint@^2.0.2: uint8arraylist "^2.0.0" uint8arrays "^5.0.0" -uint8arraylist@^2.0.0, uint8arraylist@^2.4.3, uint8arraylist@^2.4.7: +uint8arraylist@^2.0.0, uint8arraylist@^2.4.3, uint8arraylist@^2.4.8: version "2.4.8" resolved "https://registry.yarnpkg.com/uint8arraylist/-/uint8arraylist-2.4.8.tgz#5a4d17f4defd77799cb38e93fd5db0f0dceddc12" integrity sha512-vc1PlGOzglLF0eae1M8mLRTBivsvrGsdmJ5RbK3e+QRvRLOZfZhQROTwH/OfyF3+ZVUg9/8hE8bmKP2CvP9quQ== @@ -6512,6 +6582,13 @@ uint8arrays@^5.0.0, uint8arrays@^5.0.1: dependencies: multiformats "^13.0.0" +uint8arrays@^5.0.2, uint8arrays@^5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/uint8arrays/-/uint8arrays-5.1.0.tgz#14047c9bdf825d025b7391299436e5e50e7270f1" + integrity sha512-vA6nFepEmlSKkMBnLBaUMVvAC4G3CTmO58C12y4sq6WPDOR7mOFYOi7GlrQ4djeSbP6JG9Pv9tJDM97PedRSww== + dependencies: + multiformats "^13.0.0" + ultron@~1.1.0: version "1.1.1" resolved "https://registry.yarnpkg.com/ultron/-/ultron-1.1.1.tgz#9fe1536a10a664a65266a1e3ccf85fd36302bc9c" @@ -6762,7 +6839,7 @@ workerpool@6.2.1: resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.2.1.tgz#46fc150c17d826b86a008e5a4508656777e9c343" integrity sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw== -"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0: +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== @@ -6789,6 +6866,15 @@ wrap-ansi@^6.0.1: string-width "^4.1.0" strip-ansi "^6.0.0" +wrap-ansi@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" + wrap-ansi@^8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"