From be06864b1f2ea297784e3f6ad61cd57705860f27 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Fri, 13 Sep 2024 17:09:45 +0100 Subject: [PATCH 1/2] fix!: update to libp2p@2.x.x Updates all deps to the latest libp2p version. BREAKING CHANGE: helia now uses libp2p@2.x.x --- benchmarks/add-dir/package.json | 4 +- benchmarks/gc/package.json | 4 +- benchmarks/transfer/package.json | 4 +- benchmarks/transports/package.json | 2 +- package.json | 7 +- packages/bitswap/package.json | 17 +- packages/bitswap/src/errors.ts | 8 + packages/bitswap/src/index.ts | 2 +- packages/bitswap/src/network.ts | 20 +- packages/bitswap/src/pb/message.ts | 8 +- .../bitswap/src/peer-want-lists/ledger.ts | 2 +- packages/bitswap/src/session.ts | 2 +- packages/bitswap/src/stats.ts | 4 +- packages/bitswap/src/utils/split-message.ts | 5 +- packages/bitswap/test/bitswap.spec.ts | 15 +- packages/bitswap/test/network.spec.ts | 39 +- packages/bitswap/test/peer-want-list.spec.ts | 31 +- packages/bitswap/test/session.spec.ts | 19 +- packages/bitswap/test/stats.spec.ts | 11 +- .../bitswap/test/utils/split-message.spec.ts | 2 +- packages/bitswap/test/want-list.spec.ts | 17 +- packages/block-brokers/package.json | 9 +- .../test/trustless-gateway-sessions.spec.ts | 13 +- .../test/trustless-gateway.spec.ts | 13 +- packages/car/package.json | 8 +- packages/dag-cbor/package.json | 4 +- packages/dag-json/package.json | 4 +- packages/helia/package.json | 47 +- .../src/utils/libp2p-defaults.browser.ts | 4 +- packages/helia/src/utils/libp2p-defaults.ts | 8 +- packages/helia/src/utils/libp2p.ts | 25 +- packages/http/package.json | 6 +- packages/interface/package.json | 4 +- packages/interface/src/errors.ts | 17 + packages/interface/src/index.ts | 1 + packages/interop/package.json | 21 +- .../interop/src/fixtures/create-peer-ids.ts | 2 +- packages/interop/src/ipns-http.spec.ts | 8 +- packages/interop/src/ipns-pubsub.spec.ts | 40 +- packages/interop/src/ipns.spec.ts | 31 +- packages/ipns/package.json | 13 +- packages/ipns/src/dnslink.ts | 12 +- packages/ipns/src/errors.ts | 53 + packages/ipns/src/index.ts | 77 +- packages/ipns/src/routing/local-store.ts | 2 +- packages/ipns/src/routing/pubsub.ts | 15 +- packages/ipns/src/utils.ts | 8 + packages/ipns/test/publish.spec.ts | 27 +- packages/ipns/test/resolve-dnslink.spec.ts | 26 +- packages/ipns/test/resolve.spec.ts | 128 +- packages/json/package.json | 4 +- packages/mfs/package.json | 8 +- packages/mfs/src/index.ts | 2 +- packages/mfs/test/cat.spec.ts | 2 +- packages/mfs/test/cp.spec.ts | 8 +- packages/mfs/test/mkdir.spec.ts | 2 +- packages/mfs/test/rm.spec.ts | 8 +- packages/routers/package.json | 7 +- .../routers/src/delegated-http-routing.ts | 31 +- packages/routers/src/http-gateway-routing.ts | 55 +- .../test/delegated-http-routing.spec.ts | 20 +- packages/strings/package.json | 4 +- packages/unixfs/package.json | 6 +- packages/unixfs/test/cat.spec.ts | 4 +- packages/unixfs/test/chmod.spec.ts | 2 +- packages/unixfs/test/cp.spec.ts | 10 +- packages/unixfs/test/ls.spec.ts | 2 +- packages/unixfs/test/mkdir.spec.ts | 4 +- packages/unixfs/test/rm.spec.ts | 10 +- packages/unixfs/test/stat.spec.ts | 2 +- packages/unixfs/test/touch.spec.ts | 2 +- packages/utils/package.json | 15 +- packages/utils/src/abstract-session.ts | 6 +- packages/utils/src/index.ts | 11 +- packages/utils/src/pins.ts | 2 +- packages/utils/src/routing.ts | 13 +- packages/utils/src/utils/networked-storage.ts | 6 +- packages/utils/test/abstract-session.spec.ts | 33 +- packages/utils/test/block-broker.spec.ts | 2 +- .../test/utils/networked-storage.spec.ts | 4 +- ...ted-routing-v1-http-api-client+3.0.2.patch | 1218 +++++++++++++++++ 81 files changed, 1838 insertions(+), 514 deletions(-) create mode 100644 packages/bitswap/src/errors.ts create mode 100644 packages/interface/src/errors.ts create mode 100644 packages/ipns/src/errors.ts create mode 100644 packages/ipns/src/utils.ts create mode 100644 patches/@helia+delegated-routing-v1-http-api-client+3.0.2.patch diff --git a/benchmarks/add-dir/package.json b/benchmarks/add-dir/package.json index 38527e6a4..bb230adaa 100644 --- a/benchmarks/add-dir/package.json +++ b/benchmarks/add-dir/package.json @@ -23,12 +23,12 @@ "execa": "^8.0.1", "helia": "^4.1.1", "ipfs-unixfs-importer": "^15.1.5", - "ipfsd-ctl": "^14.0.0", + "ipfsd-ctl": "^15.0.0", "it-all": "^3.0.4", "it-drain": "^3.0.5", "it-map": "^3.0.5", "kubo": "^0.28.0", - "kubo-rpc-client": "^4.0.0", + "kubo-rpc-client": "^5.0.0", "libp2p": "^1.1.0", "multiformats": "^13.1.0", "tinybench": "^2.4.0" diff --git a/benchmarks/gc/package.json b/benchmarks/gc/package.json index eb53a6b2e..a2f636923 100644 --- a/benchmarks/gc/package.json +++ b/benchmarks/gc/package.json @@ -16,12 +16,12 @@ "datastore-level": "^10.1.5", "execa": "^8.0.1", "helia": "^4.1.1", - "ipfsd-ctl": "^14.0.0", + "ipfsd-ctl": "^15.0.0", "it-all": "^3.0.4", "it-drain": "^3.0.5", "it-map": "^3.0.5", "kubo": "^0.28.0", - "kubo-rpc-client": "^4.0.0", + "kubo-rpc-client": "^5.0.0", "multiformats": "^13.0.0", "tinybench": "^2.5.1" }, diff --git a/benchmarks/transfer/package.json b/benchmarks/transfer/package.json index 1853821e0..743f4795e 100644 --- a/benchmarks/transfer/package.json +++ b/benchmarks/transfer/package.json @@ -23,13 +23,13 @@ "execa": "^8.0.1", "helia": "^4.1.0", "ipfs-unixfs-importer": "^15.1.1", - "ipfsd-ctl": "^14.0.0", + "ipfsd-ctl": "^15.0.0", "it-all": "^3.0.1", "it-buffer-stream": "^3.0.2", "it-drain": "^3.0.1", "it-map": "^3.0.2", "kubo": "^0.28.0", - "kubo-rpc-client": "^4.0.0", + "kubo-rpc-client": "^5.0.0", "libp2p": "^1.4.0", "multiformats": "^13.1.0", "tinybench": "^2.4.0" diff --git a/benchmarks/transports/package.json b/benchmarks/transports/package.json index 647dabff3..d46c81c26 100644 --- a/benchmarks/transports/package.json +++ b/benchmarks/transports/package.json @@ -42,7 +42,7 @@ "it-buffer-stream": "^3.0.2", "it-drain": "^3.0.7", "kubo": "^0.28.0", - "kubo-rpc-client": "^4.1.1", + "kubo-rpc-client": "^5.0.0", "libp2p": "^1.4.0", "multiformats": "^13.1.0", "playwright-test": "^14.1.1", diff --git a/package.json b/package.json index 19d967ed7..a552c8b9d 100644 --- a/package.json +++ b/package.json @@ -34,11 +34,14 @@ "npm:release": "aegir exec --bail false npm -- publish", "release:rc": "aegir release-rc", "docs": "aegir docs", - "docs:no-publish": "aegir docs --publish false" + "docs:no-publish": "aegir docs --publish false", + "postinstall": "patch-package && rimraf node_modules/@helia/delegated-routing-v1-http-api-client/node_modules" }, "devDependencies": { "aegir": "^44.0.1", - "npm-run-all": "^4.1.5" + "npm-run-all": "^4.1.5", + "patch-package": "^8.0.0", + "rimraf": "^6.0.1" }, "type": "module", "workspaces": [ diff --git a/packages/bitswap/package.json b/packages/bitswap/package.json index ddbe6884a..0dbd90131 100644 --- a/packages/bitswap/package.json +++ b/packages/bitswap/package.json @@ -150,14 +150,14 @@ "dependencies": { "@helia/interface": "^4.3.1", "@helia/utils": "^0.3.3", - "@libp2p/interface": "^1.1.4", - "@libp2p/logger": "^4.0.5", - "@libp2p/peer-collections": "^5.1.6", - "@libp2p/utils": "^5.2.3", + "@libp2p/interface": "^2.0.0", + "@libp2p/logger": "^5.0.0", + "@libp2p/peer-collections": "^6.0.0", + "@libp2p/utils": "^6.0.0", "@multiformats/multiaddr": "^12.1.14", "any-signal": "^4.1.1", "interface-blockstore": "^5.2.9", - "interface-store": "^5.1.7", + "interface-store": "^6.0.0", "it-drain": "^3.0.5", "it-length-prefixed": "^9.0.0", "it-length-prefixed-stream": "^1.1.6", @@ -174,12 +174,11 @@ "uint8arrays": "^5.0.1" }, "devDependencies": { - "@libp2p/crypto": "^4.0.6", - "@libp2p/interface-compliance-tests": "^5.1.3", - "@libp2p/peer-id-factory": "^4.0.5", + "@libp2p/crypto": "^5.0.0", + "@libp2p/interface-compliance-tests": "^6.0.0", "@types/sinon": "^17.0.3", "aegir": "^44.0.1", - "blockstore-core": "^4.3.10", + "blockstore-core": "^5.0.0", "delay": "^6.0.0", "it-all": "^3.0.4", "it-pair": "^2.0.6", diff --git a/packages/bitswap/src/errors.ts b/packages/bitswap/src/errors.ts new file mode 100644 index 000000000..d46e762e7 --- /dev/null +++ b/packages/bitswap/src/errors.ts @@ -0,0 +1,8 @@ +export class BlockTooLargeError extends Error { + static name = 'BlockTooLargeError' + + constructor (message = 'Block too large') { + super(message) + this.name = 'BlockTooLargeError' + } +} diff --git a/packages/bitswap/src/index.ts b/packages/bitswap/src/index.ts index d3989a26e..183739a4c 100644 --- a/packages/bitswap/src/index.ts +++ b/packages/bitswap/src/index.ts @@ -103,7 +103,7 @@ export interface BitswapOptions { * * @default false */ - runOnTransientConnections?: boolean + runOnLimitedConnections?: boolean /** * Enables loading esoteric hash functions diff --git a/packages/bitswap/src/network.ts b/packages/bitswap/src/network.ts index 49a3a8127..6e82a5aa7 100644 --- a/packages/bitswap/src/network.ts +++ b/packages/bitswap/src/network.ts @@ -1,4 +1,4 @@ -import { CodeError, TypedEventEmitter, setMaxListeners } from '@libp2p/interface' +import { InvalidParametersError, NotStartedError, TimeoutError, TypedEventEmitter, UnsupportedProtocolError, setMaxListeners } from '@libp2p/interface' import { PeerQueue, type PeerQueueJobOptions } from '@libp2p/utils/peer-queue' import drain from 'it-drain' import * as lp from 'it-length-prefixed' @@ -41,7 +41,7 @@ export interface NetworkInit { messageReceiveTimeout?: number messageSendConcurrency?: number protocols?: string[] - runOnTransientConnections?: boolean + runOnLimitedConnections?: boolean maxOutgoingMessageSize?: number maxIncomingMessageSize?: number } @@ -80,7 +80,7 @@ export class Network extends TypedEventEmitter { private registrarIds: string[] private readonly metrics: { blocksSent?: Counter, dataSent?: Counter } private readonly sendQueue: PeerQueue - private readonly runOnTransientConnections: boolean + private readonly runOnLimitedConnections: boolean private readonly maxOutgoingMessageSize: number private readonly maxIncomingMessageSize: number @@ -99,7 +99,7 @@ export class Network extends TypedEventEmitter { this.maxInboundStreams = init.maxInboundStreams ?? DEFAULT_MAX_INBOUND_STREAMS this.maxOutboundStreams = init.maxOutboundStreams ?? DEFAULT_MAX_OUTBOUND_STREAMS this.messageReceiveTimeout = init.messageReceiveTimeout ?? DEFAULT_MESSAGE_RECEIVE_TIMEOUT - this.runOnTransientConnections = init.runOnTransientConnections ?? DEFAULT_RUN_ON_TRANSIENT_CONNECTIONS + this.runOnLimitedConnections = init.runOnLimitedConnections ?? DEFAULT_RUN_ON_TRANSIENT_CONNECTIONS this.maxIncomingMessageSize = init.maxIncomingMessageSize ?? DEFAULT_MAX_OUTGOING_MESSAGE_SIZE this.maxOutgoingMessageSize = init.maxOutgoingMessageSize ?? init.maxIncomingMessageSize ?? DEFAULT_MAX_INCOMING_MESSAGE_SIZE this.metrics = { @@ -127,7 +127,7 @@ export class Network extends TypedEventEmitter { await this.libp2p.handle(this.protocols, this._onStream, { maxInboundStreams: this.maxInboundStreams, maxOutboundStreams: this.maxOutboundStreams, - runOnTransientConnection: this.runOnTransientConnections + runOnLimitedConnection: this.runOnLimitedConnections }) // register protocol with topology @@ -188,7 +188,7 @@ export class Network extends TypedEventEmitter { this.log('incoming new bitswap %s stream from %p', stream.protocol, connection.remotePeer) const abortListener = (): void => { if (stream.status === 'open') { - stream.abort(new CodeError(`Incoming Bitswap stream timed out after ${this.messageReceiveTimeout}ms`, 'ERR_TIMEOUT')) + stream.abort(new TimeoutError(`Incoming Bitswap stream timed out after ${this.messageReceiveTimeout}ms`)) } else { this.log('stream aborted with status %s', stream.status) } @@ -247,7 +247,7 @@ export class Network extends TypedEventEmitter { for await (const provider of this.routing.findProviders(cid, options)) { // make sure we can dial the provider const dialable = await this.libp2p.isDialable(provider.multiaddrs, { - runOnTransientConnection: this.runOnTransientConnections + runOnLimitedConnection: this.runOnLimitedConnections }) if (!dialable) { @@ -300,7 +300,7 @@ export class Network extends TypedEventEmitter { const message = options?.message if (message == null) { - throw new CodeError('No message to send', 'ERR_NO_MESSAGE') + throw new InvalidParametersError('No message to send') } this.log('sendMessage to %p', peerId) @@ -337,7 +337,7 @@ export class Network extends TypedEventEmitter { */ async connectTo (peer: PeerId, options?: AbortOptions & ProgressOptions): Promise { // eslint-disable-line require-await if (!this.running) { - throw new CodeError('Network isn\'t running', 'ERR_NOT_STARTED') + throw new NotStartedError('Network isn\'t running') } options?.onProgress?.(new CustomProgressEvent('bitswap:network:dial', peer)) @@ -359,7 +359,7 @@ export class Network extends TypedEventEmitter { return true } - throw new CodeError(`${peer} did not support ${BITSWAP_120}`, 'ERR_BITSWAP_UNSUPPORTED_BY_PEER') + throw new UnsupportedProtocolError(`${peer} did not support ${BITSWAP_120}`) } }) ]) diff --git a/packages/bitswap/src/pb/message.ts b/packages/bitswap/src/pb/message.ts index 77fc6fb27..7023fa267 100644 --- a/packages/bitswap/src/pb/message.ts +++ b/packages/bitswap/src/pb/message.ts @@ -4,7 +4,7 @@ /* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */ /* eslint-disable @typescript-eslint/no-empty-interface */ -import { type Codec, CodeError, decodeMessage, type DecodeOptions, encodeMessage, enumeration, message } from 'protons-runtime' +import { type Codec, decodeMessage, type DecodeOptions, encodeMessage, enumeration, MaxLengthError, message } from 'protons-runtime' import { alloc as uint8ArrayAlloc } from 'uint8arrays/alloc' import type { Uint8ArrayList } from 'uint8arraylist' @@ -167,7 +167,7 @@ export namespace Wantlist { switch (tag >>> 3) { case 1: { if (opts.limits?.entries != null && obj.entries.length === opts.limits.entries) { - throw new CodeError('decode error - map field "entries" had too many elements', 'ERR_MAX_LENGTH') + throw new MaxLengthError('Decode error - map field "entries" had too many elements') } obj.entries.push(WantlistEntry.codec().decode(reader, reader.uint32(), { @@ -424,7 +424,7 @@ export namespace BitswapMessage { } case 3: { if (opts.limits?.blocks != null && obj.blocks.length === opts.limits.blocks) { - throw new CodeError('decode error - map field "blocks" had too many elements', 'ERR_MAX_LENGTH') + throw new MaxLengthError('Decode error - map field "blocks" had too many elements') } obj.blocks.push(Block.codec().decode(reader, reader.uint32(), { @@ -434,7 +434,7 @@ export namespace BitswapMessage { } case 4: { if (opts.limits?.blockPresences != null && obj.blockPresences.length === opts.limits.blockPresences) { - throw new CodeError('decode error - map field "blockPresences" had too many elements', 'ERR_MAX_LENGTH') + throw new MaxLengthError('Decode error - map field "blockPresences" had too many elements') } obj.blockPresences.push(BlockPresence.codec().decode(reader, reader.uint32(), { diff --git a/packages/bitswap/src/peer-want-lists/ledger.ts b/packages/bitswap/src/peer-want-lists/ledger.ts index acc15da2e..4242cf1f6 100644 --- a/packages/bitswap/src/peer-want-lists/ledger.ts +++ b/packages/bitswap/src/peer-want-lists/ledger.ts @@ -125,7 +125,7 @@ export class Ledger { }) } } catch (err: any) { - if (err.code !== 'ERR_NOT_FOUND') { + if (err.name !== 'NotFoundError') { throw err } diff --git a/packages/bitswap/src/session.ts b/packages/bitswap/src/session.ts index c5d7d52d4..3ea865248 100644 --- a/packages/bitswap/src/session.ts +++ b/packages/bitswap/src/session.ts @@ -48,7 +48,7 @@ class BitswapSession extends AbstractSession } toEvictionKey (provider: PeerId): Uint8Array | string { - return provider.toBytes() + return provider.toMultihash().bytes } equals (providerA: PeerId, providerB: PeerId): boolean { diff --git a/packages/bitswap/src/stats.ts b/packages/bitswap/src/stats.ts index 7b2880f64..0ca3cef32 100644 --- a/packages/bitswap/src/stats.ts +++ b/packages/bitswap/src/stats.ts @@ -19,7 +19,7 @@ export class Stats { } updateBlocksReceived (count: number = 1, peerId?: PeerId): void { - const stats: Record = { + const stats: Record = { global: count } @@ -31,7 +31,7 @@ export class Stats { } updateDuplicateBlocksReceived (count: number = 1, peerId?: PeerId): void { - const stats: Record = { + const stats: Record = { global: count } diff --git a/packages/bitswap/src/utils/split-message.ts b/packages/bitswap/src/utils/split-message.ts index 38119563c..c085015c5 100644 --- a/packages/bitswap/src/utils/split-message.ts +++ b/packages/bitswap/src/utils/split-message.ts @@ -1,6 +1,7 @@ /* eslint-disable complexity */ -import { CodeError } from '@libp2p/interface' + import { encodingLength } from 'uint8-varint' +import { BlockTooLargeError } from '../errors.js' import { BitswapMessage, Block, BlockPresence, WantlistEntry } from '../pb/message.js' import type { QueuedBitswapMessage } from './bitswap-message.js' @@ -93,7 +94,7 @@ function addToMessage (input: T[], output: T[], start: number, maxSize: numb const itemSize = calculateSize(item) if (itemSize > MAX_ENCODED_BLOCK_SIZE) { - throw new CodeError('Cannot send block as after encoding it is over the max message size', 'ERR_BLOCK_TOO_LARGE') + throw new BlockTooLargeError('Cannot send block as after encoding it is over the max message size') } const newSize = size + itemSize diff --git a/packages/bitswap/test/bitswap.spec.ts b/packages/bitswap/test/bitswap.spec.ts index 7dbf18c67..f2658f071 100644 --- a/packages/bitswap/test/bitswap.spec.ts +++ b/packages/bitswap/test/bitswap.spec.ts @@ -1,6 +1,7 @@ +import { generateKeyPair } from '@libp2p/crypto/keys' import { start, stop } from '@libp2p/interface' import { defaultLogger } from '@libp2p/logger' -import { createEd25519PeerId } from '@libp2p/peer-id-factory' +import { peerIdFromPrivateKey } from '@libp2p/peer-id' import { expect } from 'aegir/chai' import { MemoryBlockstore } from 'blockstore-core' import { CID } from 'multiformats/cid' @@ -35,7 +36,7 @@ describe('bitswap', () => { cid = CID.createV0(mh).toV1() components = { - peerId: await createEd25519PeerId(), + peerId: peerIdFromPrivateKey(await generateKeyPair('Ed25519')), routing: stubInterface(), blockstore: new MemoryBlockstore(), libp2p: stubInterface({ @@ -61,7 +62,7 @@ describe('bitswap', () => { describe('want', () => { it('should want a block that is available on the network', async () => { - const remotePeer = await createEd25519PeerId() + const remotePeer = peerIdFromPrivateKey(await generateKeyPair('Ed25519')) const findProvsSpy = bitswap.network.findAndConnect = Sinon.stub() findProvsSpy.resolves() @@ -112,7 +113,7 @@ describe('bitswap', () => { }) await expect(p).to.eventually.be.rejected - .with.property('code', 'ABORT_ERR') + .with.property('name', 'AbortError') }) it('should notify peers we have a block', async () => { @@ -126,7 +127,7 @@ describe('bitswap', () => { describe('wantlist', () => { it('should remove CIDs from the wantlist when the block arrives', async () => { - const remotePeer = await createEd25519PeerId() + const remotePeer = peerIdFromPrivateKey(await generateKeyPair('Ed25519')) expect(bitswap.getWantlist()).to.be.empty() const findProvsSpy = bitswap.network.findAndConnect = Sinon.stub() @@ -182,7 +183,7 @@ describe('bitswap', () => { expect(bitswap.getWantlist().map(w => w.cid)).to.include(cid) await expect(p).to.eventually.be.rejected - .with.property('code', 'ABORT_ERR') + .with.property('name', 'AbortError') expect(bitswap.getWantlist()).to.be.empty() }) @@ -190,7 +191,7 @@ describe('bitswap', () => { describe('peer wantlist', () => { it('should return a peer wantlist', async () => { - const remotePeer = await createEd25519PeerId() + const remotePeer = peerIdFromPrivateKey(await generateKeyPair('Ed25519')) // don't have this peer yet expect(bitswap.getPeerWantlist(remotePeer)).to.be.undefined() diff --git a/packages/bitswap/test/network.spec.ts b/packages/bitswap/test/network.spec.ts index d8b088daf..d88a8df3a 100644 --- a/packages/bitswap/test/network.spec.ts +++ b/packages/bitswap/test/network.spec.ts @@ -1,8 +1,9 @@ -import { CustomEvent, isPeerId } from '@libp2p/interface' +import { generateKeyPair } from '@libp2p/crypto/keys' +import { isPeerId } from '@libp2p/interface' import { matchMultiaddr } from '@libp2p/interface-compliance-tests/matchers' import { mockStream } from '@libp2p/interface-compliance-tests/mocks' import { defaultLogger } from '@libp2p/logger' -import { createEd25519PeerId } from '@libp2p/peer-id-factory' +import { peerIdFromPrivateKey } from '@libp2p/peer-id' import { multiaddr } from '@multiformats/multiaddr' import { expect } from 'aegir/chai' import delay from 'delay' @@ -61,10 +62,10 @@ describe('network', () => { it('should not connect if not running', async () => { await network.stop() - const peerId = await createEd25519PeerId() + const peerId = peerIdFromPrivateKey(await generateKeyPair('Ed25519')) - await expect(network.connectTo(peerId)) - .to.eventually.be.rejected.with.property('code', 'ERR_NOT_STARTED') + await expect(network.connectTo(peerId)).to.eventually.be.rejected + .with.property('name', 'NotStartedError') }) it('should register protocol handlers', () => { @@ -87,7 +88,7 @@ describe('network', () => { }) it('should emit a bitswap:message event when receiving an incoming message', async () => { - const remotePeer = await createEd25519PeerId() + const remotePeer = peerIdFromPrivateKey(await generateKeyPair('Ed25519')) const connection = stubInterface({ remotePeer }) @@ -120,7 +121,7 @@ describe('network', () => { }) it('should close the stream if parsing an incoming message fails', async () => { - const remotePeer = await createEd25519PeerId() + const remotePeer = peerIdFromPrivateKey(await generateKeyPair('Ed25519')) const connection = stubInterface({ remotePeer }) @@ -144,7 +145,7 @@ describe('network', () => { }) it('should close the stream if no message is received', async () => { - const remotePeer = await createEd25519PeerId() + const remotePeer = peerIdFromPrivateKey(await generateKeyPair('Ed25519')) const connection = stubInterface({ remotePeer }) @@ -166,7 +167,7 @@ describe('network', () => { it('should find providers', async () => { const cid = CID.parse('QmaQwYWpchozXhFv8nvxprECWBSCEppN9dfd2VQiJfRo3F') - const peerId = await createEd25519PeerId() + const peerId = peerIdFromPrivateKey(await generateKeyPair('Ed25519')) const providers = [{ id: peerId, @@ -189,7 +190,7 @@ describe('network', () => { it('should ignore providers with only transient addresses', async () => { const cid = CID.parse('QmaQwYWpchozXhFv8nvxprECWBSCEppN9dfd2VQiJfRo3F') - const peerId = await createEd25519PeerId() + const peerId = peerIdFromPrivateKey(await generateKeyPair('Ed25519')) const providers = [{ id: peerId, @@ -204,7 +205,7 @@ describe('network', () => { components.libp2p.isDialable = Sinon.stub() components.libp2p.isDialable.withArgs(matchMultiaddr(providers[0].multiaddrs[0]), { - runOnTransientConnection: false + runOnLimitedConnection: false }) const output = await all(network.findProviders(cid)) @@ -218,13 +219,13 @@ describe('network', () => { ...components, logger: defaultLogger() }, { - runOnTransientConnections: true + runOnLimitedConnections: true }) await network.start() const cid = CID.parse('QmaQwYWpchozXhFv8nvxprECWBSCEppN9dfd2VQiJfRo3F') - const peerId = await createEd25519PeerId() + const peerId = peerIdFromPrivateKey(await generateKeyPair('Ed25519')) const providers = [{ id: peerId, @@ -247,7 +248,7 @@ describe('network', () => { it('should find and connect to a peer', async () => { const cid = CID.parse('QmaQwYWpchozXhFv8nvxprECWBSCEppN9dfd2VQiJfRo3F') - const peerId = await createEd25519PeerId() + const peerId = peerIdFromPrivateKey(await generateKeyPair('Ed25519')) const providers = [{ id: peerId, @@ -301,12 +302,12 @@ describe('network', () => { ...components, logger: defaultLogger() }, { - runOnTransientConnections: true + runOnLimitedConnections: true }) await network.start() const cid = CID.parse('QmaQwYWpchozXhFv8nvxprECWBSCEppN9dfd2VQiJfRo3F') - const peerId = await createEd25519PeerId() + const peerId = peerIdFromPrivateKey(await generateKeyPair('Ed25519')) const providers = [{ id: peerId, @@ -355,7 +356,7 @@ describe('network', () => { }) it('should send a message', async () => { - const peerId = await createEd25519PeerId() + const peerId = peerIdFromPrivateKey(await generateKeyPair('Ed25519')) const [localDuplex, remoteDuplex] = duplexPair() const remoteStream = stubInterface(remoteDuplex) @@ -379,7 +380,7 @@ describe('network', () => { }) await network.start() - const peerId = await createEd25519PeerId() + const peerId = peerIdFromPrivateKey(await generateKeyPair('Ed25519')) const [localDuplex, remoteDuplex] = duplexPair() const remoteStream = stubInterface(remoteDuplex) @@ -440,7 +441,7 @@ describe('network', () => { messageB.pendingBytes = 7 // block the queue with a slow request - const slowPeer = await createEd25519PeerId() + const slowPeer = peerIdFromPrivateKey(await generateKeyPair('Ed25519')) components.libp2p.dialProtocol.withArgs(slowPeer).callsFake(async () => { await delay(100) throw new Error('Urk!') diff --git a/packages/bitswap/test/peer-want-list.spec.ts b/packages/bitswap/test/peer-want-list.spec.ts index 84e05d374..f5990602d 100644 --- a/packages/bitswap/test/peer-want-list.spec.ts +++ b/packages/bitswap/test/peer-want-list.spec.ts @@ -1,5 +1,6 @@ +import { generateKeyPair } from '@libp2p/crypto/keys' import { defaultLogger } from '@libp2p/logger' -import { createEd25519PeerId } from '@libp2p/peer-id-factory' +import { peerIdFromPrivateKey } from '@libp2p/peer-id' import { expect } from 'aegir/chai' import { MemoryBlockstore } from 'blockstore-core' import delay from 'delay' @@ -42,7 +43,7 @@ describe('peer-want-lists', () => { }) components = { - peerId: await createEd25519PeerId(), + peerId: peerIdFromPrivateKey(await generateKeyPair('Ed25519')), blockstore: new MemoryBlockstore(), network, libp2p, @@ -53,7 +54,7 @@ describe('peer-want-lists', () => { }) it('should keep a ledger for a peer', async () => { - const remotePeer = await createEd25519PeerId() + const remotePeer = peerIdFromPrivateKey(await generateKeyPair('Ed25519')) expect(wantLists.ledgerForPeer(remotePeer)).to.be.undefined('should not have list initially') @@ -87,7 +88,7 @@ describe('peer-want-lists', () => { }) it('should replace the wantlist for a peer when the full list is received', async () => { - const remotePeer = await createEd25519PeerId() + const remotePeer = peerIdFromPrivateKey(await generateKeyPair('Ed25519')) const cid1 = CID.parse('QmaQwYWpchozXhFv8nvxprECWBSCEppN9dfd2VQiJfRo3F') const cid2 = CID.parse('bafyreidykglsfhoixmivffc5uwhcgshx4j465xwqntbmu43nb2dzqwfvae') @@ -140,7 +141,7 @@ describe('peer-want-lists', () => { }) it('should merge the wantlist for a peer when a partial list is received', async () => { - const remotePeer = await createEd25519PeerId() + const remotePeer = peerIdFromPrivateKey(await generateKeyPair('Ed25519')) const cid1 = CID.parse('QmaQwYWpchozXhFv8nvxprECWBSCEppN9dfd2VQiJfRo3F') const cid2 = CID.parse('bafyreidykglsfhoixmivffc5uwhcgshx4j465xwqntbmu43nb2dzqwfvae') @@ -192,7 +193,7 @@ describe('peer-want-lists', () => { }) it('should record the amount of incoming data', async () => { - const remotePeer = await createEd25519PeerId() + const remotePeer = peerIdFromPrivateKey(await generateKeyPair('Ed25519')) network.safeDispatchEvent('bitswap:message', { detail: { @@ -218,7 +219,7 @@ describe('peer-want-lists', () => { it('should send requested blocks to peer', async () => { const sendMessageStub = network.sendMessage = Sinon.stub() - const remotePeer = await createEd25519PeerId() + const remotePeer = peerIdFromPrivateKey(await generateKeyPair('Ed25519')) const cid = CID.parse('QmaQwYWpchozXhFv8nvxprECWBSCEppN9dfd2VQiJfRo3F') const block = Uint8Array.from([0, 1, 2, 3, 4]) @@ -267,7 +268,7 @@ describe('peer-want-lists', () => { it('should send requested block presences to peer', async () => { const sendMessageStub = network.sendMessage = Sinon.stub() - const remotePeer = await createEd25519PeerId() + const remotePeer = peerIdFromPrivateKey(await generateKeyPair('Ed25519')) const cid = CID.parse('QmaQwYWpchozXhFv8nvxprECWBSCEppN9dfd2VQiJfRo3F') const block = Uint8Array.from(new Array(DEFAULT_MAX_SIZE_REPLACE_HAS_WITH_BLOCK + 1)) @@ -310,7 +311,7 @@ describe('peer-want-lists', () => { it('should send requested lack of block presences to peer', async () => { const sendMessageStub = network.sendMessage = Sinon.stub() - const remotePeer = await createEd25519PeerId() + const remotePeer = peerIdFromPrivateKey(await generateKeyPair('Ed25519')) // CID for a block we don't have const cid = CID.parse('QmaQwYWpchozXhFv8nvxprECWBSCEppN9dfd2VQiJfRo3F') @@ -351,7 +352,7 @@ describe('peer-want-lists', () => { it('should send requested blocks to peer when presence was requested but block size is less than maxSizeReplaceHasWithBlock', async () => { const sendMessageStub = network.sendMessage = Sinon.stub() - const remotePeer = await createEd25519PeerId() + const remotePeer = peerIdFromPrivateKey(await generateKeyPair('Ed25519')) const cid = CID.parse('QmaQwYWpchozXhFv8nvxprECWBSCEppN9dfd2VQiJfRo3F') const block = Uint8Array.from([0, 1, 2, 3, 4]) @@ -401,7 +402,7 @@ describe('peer-want-lists', () => { it('should send requested block presences to peer for blocks we don\'t have', async () => { const sendMessageStub = network.sendMessage = Sinon.stub() - const remotePeer = await createEd25519PeerId() + const remotePeer = peerIdFromPrivateKey(await generateKeyPair('Ed25519')) const cid = CID.parse('QmaQwYWpchozXhFv8nvxprECWBSCEppN9dfd2VQiJfRo3F') @@ -440,7 +441,7 @@ describe('peer-want-lists', () => { }) it('should remove wants when peer cancels', async () => { - const remotePeer = await createEd25519PeerId() + const remotePeer = peerIdFromPrivateKey(await generateKeyPair('Ed25519')) const cid = CID.parse('QmaQwYWpchozXhFv8nvxprECWBSCEppN9dfd2VQiJfRo3F') @@ -485,7 +486,7 @@ describe('peer-want-lists', () => { }) it('should remove wantlist and ledger when peer disconnects', async () => { - const remotePeer = await createEd25519PeerId() + const remotePeer = peerIdFromPrivateKey(await generateKeyPair('Ed25519')) const cid = CID.parse('QmaQwYWpchozXhFv8nvxprECWBSCEppN9dfd2VQiJfRo3F') const block = Uint8Array.from([0, 1, 2, 3, 4]) @@ -520,7 +521,7 @@ describe('peer-want-lists', () => { }) it('should return peers with want lists', async () => { - const remotePeer = await createEd25519PeerId() + const remotePeer = peerIdFromPrivateKey(await generateKeyPair('Ed25519')) expect(wantLists.peers()).to.be.empty() @@ -546,7 +547,7 @@ describe('peer-want-lists', () => { it('should send requested blocks to peer when they are received', async () => { const sendMessageStub = network.sendMessage = Sinon.stub() - const remotePeer = await createEd25519PeerId() + const remotePeer = peerIdFromPrivateKey(await generateKeyPair('Ed25519')) const cid = CID.parse('QmaQwYWpchozXhFv8nvxprECWBSCEppN9dfd2VQiJfRo3F') const block = Uint8Array.from([0, 1, 2, 3, 4]) diff --git a/packages/bitswap/test/session.spec.ts b/packages/bitswap/test/session.spec.ts index ad8fc1329..5702338ad 100644 --- a/packages/bitswap/test/session.spec.ts +++ b/packages/bitswap/test/session.spec.ts @@ -1,13 +1,14 @@ import { DEFAULT_SESSION_MAX_PROVIDERS } from '@helia/interface' +import { generateKeyPair } from '@libp2p/crypto/keys' +import { UnsupportedProtocolError } from '@libp2p/interface' import { defaultLogger } from '@libp2p/logger' import { PeerMap } from '@libp2p/peer-collections' -import { createEd25519PeerId } from '@libp2p/peer-id-factory' +import { peerIdFromPrivateKey } from '@libp2p/peer-id' import { multiaddr } from '@multiformats/multiaddr' import { expect } from 'aegir/chai' import delay from 'delay' import { CID } from 'multiformats/cid' import pWaitFor from 'p-wait-for' -import { CodeError } from 'protons-runtime' import { stubInterface, type StubbedInstance } from 'sinon-ts' import { createBitswapSession } from '../src/session.js' import type { Network } from '../src/network.js' @@ -45,7 +46,7 @@ describe('session', () => { const providers = await Promise.all( new Array(10).fill(0).map(async (_, i) => { return { - id: await createEd25519PeerId(), + id: peerIdFromPrivateKey(await generateKeyPair('Ed25519')), multiaddrs: [ multiaddr(`/ip4/4${i}.4${i}.4${i}.4${i}/tcp/${1234 + i}`) ] @@ -112,13 +113,13 @@ describe('session', () => { })()) await expect(session.retrieve(cid)).to.eventually.be.rejected - .with.property('code', 'ERR_INSUFFICIENT_PROVIDERS_FOUND') + .with.property('name', 'InsufficientProvidersError') }) it('should error when creating a session when no providers have the block', async () => { // providers found via routing const providers = [{ - id: await createEd25519PeerId(), + id: peerIdFromPrivateKey(await generateKeyPair('Ed25519')), multiaddrs: [ multiaddr('/ip4/41.41.41.41/tcp/1234') ] @@ -137,18 +138,18 @@ describe('session', () => { const session = createBitswapSession(components, {}) await expect(session.retrieve(cid)).to.eventually.be.rejected - .with.property('code', 'ERR_INSUFFICIENT_PROVIDERS_FOUND') + .with.property('name', 'InsufficientProvidersError') }) it('should exclude non-bitswap providers from the session', async () => { // providers found via routing const providers = [{ - id: await createEd25519PeerId(), + id: peerIdFromPrivateKey(await generateKeyPair('Ed25519')), multiaddrs: [ multiaddr('/ip4/41.41.41.41/tcp/1234') ] }, { - id: await createEd25519PeerId(), + id: peerIdFromPrivateKey(await generateKeyPair('Ed25519')), multiaddrs: [ multiaddr('/ip4/41.41.41.41/tcp/1235') ] @@ -158,7 +159,7 @@ describe('session', () => { yield * providers })()) - components.wantList.wantSessionBlock.withArgs(cid, providers[0].id).rejects(new CodeError('Protocol negotiation failed', 'ERR_UNSUPPORTED_PROTOCOL')) + components.wantList.wantSessionBlock.withArgs(cid, providers[0].id).rejects(new UnsupportedProtocolError('Protocol negotiation failed')) components.wantList.wantSessionBlock.withArgs(cid, providers[1].id).resolves({ sender: providers[1].id, has: true, diff --git a/packages/bitswap/test/stats.spec.ts b/packages/bitswap/test/stats.spec.ts index 19c37cfe0..d2c99c178 100644 --- a/packages/bitswap/test/stats.spec.ts +++ b/packages/bitswap/test/stats.spec.ts @@ -1,4 +1,5 @@ -import { createEd25519PeerId } from '@libp2p/peer-id-factory' +import { generateKeyPair } from '@libp2p/crypto/keys' +import { peerIdFromPrivateKey } from '@libp2p/peer-id' import { expect } from 'aegir/chai' import { stubInterface, type StubbedInstance } from 'sinon-ts' import { Stats } from '../src/stats.js' @@ -37,7 +38,7 @@ describe('stats', () => { }) it('should update blocks received from a peer', async () => { - const peerId = await createEd25519PeerId() + const peerId = peerIdFromPrivateKey(await generateKeyPair('Ed25519')) stats.updateBlocksReceived(1, peerId) @@ -56,7 +57,7 @@ describe('stats', () => { }) it('should update duplicate blocks received from a peer', async () => { - const peerId = await createEd25519PeerId() + const peerId = peerIdFromPrivateKey(await generateKeyPair('Ed25519')) stats.updateDuplicateBlocksReceived(1, peerId) @@ -75,7 +76,7 @@ describe('stats', () => { }) it('should update data received from a peer', async () => { - const peerId = await createEd25519PeerId() + const peerId = peerIdFromPrivateKey(await generateKeyPair('Ed25519')) stats.updateDataReceived(1, peerId) @@ -94,7 +95,7 @@ describe('stats', () => { }) it('should update duplicate data received from a peer', async () => { - const peerId = await createEd25519PeerId() + const peerId = peerIdFromPrivateKey(await generateKeyPair('Ed25519')) stats.updateDuplicateDataReceived(1, peerId) diff --git a/packages/bitswap/test/utils/split-message.spec.ts b/packages/bitswap/test/utils/split-message.spec.ts index 70331e4a6..4bec27e2a 100644 --- a/packages/bitswap/test/utils/split-message.spec.ts +++ b/packages/bitswap/test/utils/split-message.spec.ts @@ -174,6 +174,6 @@ describe('split-message', () => { input.addBlock(block.cid, block.block) expect(() => all(splitMessage(input, DEFAULT_MAX_OUTGOING_MESSAGE_SIZE))).to.throw() - .with.property('code', 'ERR_BLOCK_TOO_LARGE') + .with.property('name', 'BlockTooLargeError') }) }) diff --git a/packages/bitswap/test/want-list.spec.ts b/packages/bitswap/test/want-list.spec.ts index 100b0977b..b2bc124e9 100644 --- a/packages/bitswap/test/want-list.spec.ts +++ b/packages/bitswap/test/want-list.spec.ts @@ -1,6 +1,7 @@ +import { generateKeyPair } from '@libp2p/crypto/keys' import { matchPeerId } from '@libp2p/interface-compliance-tests/matchers' import { defaultLogger } from '@libp2p/logger' -import { createEd25519PeerId } from '@libp2p/peer-id-factory' +import { peerIdFromPrivateKey } from '@libp2p/peer-id' import { expect } from 'aegir/chai' import { CID } from 'multiformats/cid' import { stubInterface, type StubbedInstance } from 'sinon-ts' @@ -41,7 +42,7 @@ describe('wantlist', () => { }) it('should add peers to peer list on connect', async () => { - const peerId = await createEd25519PeerId() + const peerId = peerIdFromPrivateKey(await generateKeyPair('Ed25519')) await wantList.peerConnected(peerId) @@ -49,7 +50,7 @@ describe('wantlist', () => { }) it('should remove peers to peer list on disconnect', async () => { - const peerId = await createEd25519PeerId() + const peerId = peerIdFromPrivateKey(await generateKeyPair('Ed25519')) await wantList.peerConnected(peerId) @@ -62,7 +63,7 @@ describe('wantlist', () => { it('should want blocks', async () => { const cid = CID.parse('QmaQwYWpchozXhFv8nvxprECWBSCEppN9dfd2VQiJfRo3F') - const peerId = await createEd25519PeerId() + const peerId = peerIdFromPrivateKey(await generateKeyPair('Ed25519')) await wantList.peerConnected(peerId) @@ -71,7 +72,7 @@ describe('wantlist', () => { await expect(wantList.wantBlock(cid, { signal: AbortSignal.timeout(500) })).to.eventually.be.rejected - .with.property('code', 'ABORT_ERR') + .with.property('name', 'AbortError') const sentToPeer = components.network.sendMessage.getCall(0).args[0] expect(sentToPeer.toString()).equal(peerId.toString()) @@ -85,8 +86,8 @@ describe('wantlist', () => { it('should not send session block wants to non-session peers', async () => { const cid = CID.parse('QmaQwYWpchozXhFv8nvxprECWBSCEppN9dfd2VQiJfRo3F') - const sessionPeer = await createEd25519PeerId() - const nonSessionPeer = await createEd25519PeerId() + const sessionPeer = peerIdFromPrivateKey(await generateKeyPair('Ed25519')) + const nonSessionPeer = peerIdFromPrivateKey(await generateKeyPair('Ed25519')) await wantList.peerConnected(sessionPeer) await wantList.peerConnected(nonSessionPeer) @@ -94,7 +95,7 @@ describe('wantlist', () => { await expect(wantList.wantSessionBlock(cid, sessionPeer, { signal: AbortSignal.timeout(500) })).to.eventually.be.rejected - .with.property('code', 'ABORT_ERR') + .with.property('name', 'AbortError') expect(components.network.sendMessage.callCount).to.equal(1) diff --git a/packages/block-brokers/package.json b/packages/block-brokers/package.json index 02f74e562..75b968317 100644 --- a/packages/block-brokers/package.json +++ b/packages/block-brokers/package.json @@ -56,19 +56,18 @@ "@helia/bitswap": "^1.1.3", "@helia/interface": "^4.3.1", "@helia/utils": "^0.3.3", - "@libp2p/interface": "^1.1.4", - "@libp2p/utils": "^5.2.6", + "@libp2p/interface": "^2.0.0", + "@libp2p/utils": "^6.0.0", "@multiformats/multiaddr": "^12.2.1", "@multiformats/multiaddr-matcher": "^1.2.0", "@multiformats/multiaddr-to-uri": "^10.0.1", "interface-blockstore": "^5.2.10", - "interface-store": "^5.1.8", + "interface-store": "^6.0.0", "multiformats": "^13.1.0", "progress-events": "^1.0.0" }, "devDependencies": { - "@libp2p/logger": "^4.0.7", - "@libp2p/peer-id-factory": "^4.0.7", + "@libp2p/logger": "^5.0.0", "@multiformats/uri-to-multiaddr": "^8.0.0", "@types/polka": "^0.5.7", "@types/sinon": "^17.0.3", diff --git a/packages/block-brokers/test/trustless-gateway-sessions.spec.ts b/packages/block-brokers/test/trustless-gateway-sessions.spec.ts index f2216ceb0..e8aa4cdaf 100644 --- a/packages/block-brokers/test/trustless-gateway-sessions.spec.ts +++ b/packages/block-brokers/test/trustless-gateway-sessions.spec.ts @@ -1,7 +1,8 @@ /* eslint-env mocha */ +import { generateKeyPair } from '@libp2p/crypto/keys' import { defaultLogger } from '@libp2p/logger' -import { createEd25519PeerId } from '@libp2p/peer-id-factory' +import { peerIdFromPrivateKey } from '@libp2p/peer-id' import { multiaddr } from '@multiformats/multiaddr' import { uriToMultiaddr } from '@multiformats/uri-to-multiaddr' import { expect } from 'aegir/chai' @@ -38,7 +39,7 @@ describe('trustless-gateway sessions', () => { components.routing.findProviders.returns(async function * () { yield { - id: await createEd25519PeerId(), + id: peerIdFromPrivateKey(await generateKeyPair('Ed25519')), multiaddrs: [ uriToMultiaddr(process.env.TRUSTLESS_GATEWAY ?? '') ] @@ -59,19 +60,19 @@ describe('trustless-gateway sessions', () => { components.routing.findProviders.returns(async function * () { yield { - id: await createEd25519PeerId(), + id: peerIdFromPrivateKey(await generateKeyPair('Ed25519')), multiaddrs: [ multiaddr('/ip4/127.0.0.1/tcp/1234') ] } yield { - id: await createEd25519PeerId(), + id: peerIdFromPrivateKey(await generateKeyPair('Ed25519')), multiaddrs: [ multiaddr('/ip4/127.0.0.1/udp/1234/quic-v1') ] } yield { - id: await createEd25519PeerId(), + id: peerIdFromPrivateKey(await generateKeyPair('Ed25519')), multiaddrs: [ uriToMultiaddr(process.env.TRUSTLESS_GATEWAY ?? '') ] @@ -93,7 +94,7 @@ describe('trustless-gateway sessions', () => { const queryProviderSpy = Sinon.spy(session, 'queryProvider') const prov = { - id: await createEd25519PeerId(), + id: peerIdFromPrivateKey(await generateKeyPair('Ed25519')), multiaddrs: [ uriToMultiaddr(process.env.TRUSTLESS_GATEWAY ?? '') ] diff --git a/packages/block-brokers/test/trustless-gateway.spec.ts b/packages/block-brokers/test/trustless-gateway.spec.ts index 3e8aefdf4..8b9496632 100644 --- a/packages/block-brokers/test/trustless-gateway.spec.ts +++ b/packages/block-brokers/test/trustless-gateway.spec.ts @@ -1,7 +1,8 @@ /* eslint-env mocha */ +import { generateKeyPair } from '@libp2p/crypto/keys' import { defaultLogger } from '@libp2p/logger' -import { createEd25519PeerId } from '@libp2p/peer-id-factory' +import { peerIdFromPrivateKey } from '@libp2p/peer-id' import { multiaddr } from '@multiformats/multiaddr' import { uriToMultiaddr } from '@multiformats/uri-to-multiaddr' import { expect } from 'aegir/chai' @@ -31,13 +32,13 @@ describe('trustless-gateway-block-broker', () => { routing = stubInterface() badGatewayPeer = { - id: await createEd25519PeerId(), + id: peerIdFromPrivateKey(await generateKeyPair('Ed25519')), multiaddrs: [ uriToMultiaddr(process.env.BAD_TRUSTLESS_GATEWAY ?? '') ] } goodGatewayPeer = { - id: await createEd25519PeerId(), + id: peerIdFromPrivateKey(await generateKeyPair('Ed25519')), multiaddrs: [ uriToMultiaddr(process.env.TRUSTLESS_GATEWAY ?? '') ] @@ -112,19 +113,19 @@ describe('trustless-gateway-block-broker', () => { routing.findProviders.returns(async function * () { // non-http provider yield { - id: await createEd25519PeerId(), + id: peerIdFromPrivateKey(await generateKeyPair('Ed25519')), multiaddrs: [ multiaddr('/ip4/132.32.25.6/tcp/1234') ] } // expired peer info yield { - id: await createEd25519PeerId(), + id: peerIdFromPrivateKey(await generateKeyPair('Ed25519')), multiaddrs: [] } // http gateway yield { - id: await createEd25519PeerId(), + id: peerIdFromPrivateKey(await generateKeyPair('Ed25519')), multiaddrs: [ uriToMultiaddr(process.env.TRUSTLESS_GATEWAY ?? '') ] diff --git a/packages/car/package.json b/packages/car/package.json index cee0fb05a..7801f36c7 100644 --- a/packages/car/package.json +++ b/packages/car/package.json @@ -141,8 +141,8 @@ "dependencies": { "@helia/interface": "^4.3.1", "@ipld/car": "^5.3.0", - "@libp2p/interface": "^1.1.4", - "@libp2p/utils": "^5.4.6", + "@libp2p/interface": "^2.0.0", + "@libp2p/utils": "^6.0.0", "interface-blockstore": "^5.2.10", "it-drain": "^3.0.5", "it-map": "^3.0.5", @@ -156,8 +156,8 @@ "@helia/unixfs": "^3.0.7", "@ipld/dag-pb": "^4.1.0", "aegir": "^44.0.1", - "blockstore-core": "^4.4.0", - "datastore-core": "^9.2.9", + "blockstore-core": "^5.0.0", + "datastore-core": "^10.0.0", "ipfs-unixfs-importer": "^15.2.4", "it-to-buffer": "^4.0.5" }, diff --git a/packages/dag-cbor/package.json b/packages/dag-cbor/package.json index 1fe7fab3d..b906662f0 100644 --- a/packages/dag-cbor/package.json +++ b/packages/dag-cbor/package.json @@ -142,14 +142,14 @@ "dependencies": { "@helia/interface": "^4.3.1", "@ipld/dag-cbor": "^9.2.0", - "@libp2p/interface": "^1.1.4", + "@libp2p/interface": "^2.0.0", "interface-blockstore": "^5.2.10", "multiformats": "^13.1.0", "progress-events": "^1.0.0" }, "devDependencies": { "aegir": "^44.0.1", - "blockstore-core": "^4.4.0" + "blockstore-core": "^5.0.0" }, "sideEffects": false } diff --git a/packages/dag-json/package.json b/packages/dag-json/package.json index 0dea28ab9..bae55d1cc 100644 --- a/packages/dag-json/package.json +++ b/packages/dag-json/package.json @@ -141,14 +141,14 @@ "dependencies": { "@helia/interface": "^4.3.1", "@ipld/dag-json": "^10.2.0", - "@libp2p/interface": "^1.1.4", + "@libp2p/interface": "^2.0.0", "interface-blockstore": "^5.2.10", "multiformats": "^13.1.0", "progress-events": "^1.0.0" }, "devDependencies": { "aegir": "^44.0.1", - "blockstore-core": "^4.4.0" + "blockstore-core": "^5.0.0" }, "sideEffects": false } diff --git a/packages/helia/package.json b/packages/helia/package.json index b353c43f6..f7da5f260 100644 --- a/packages/helia/package.json +++ b/packages/helia/package.json @@ -54,37 +54,38 @@ "prepublishOnly": "node scripts/update-version.js && npm run build" }, "dependencies": { - "@chainsafe/libp2p-noise": "^15.0.0", - "@chainsafe/libp2p-yamux": "^6.0.2", + "@chainsafe/libp2p-noise": "^16.0.0", + "@chainsafe/libp2p-yamux": "^7.0.0", "@helia/block-brokers": "^3.0.3", "@helia/delegated-routing-v1-http-api-client": "^3.0.0", "@helia/interface": "^4.3.1", "@helia/routers": "^1.1.1", "@helia/utils": "^0.3.3", - "@libp2p/autonat": "^1.0.13", - "@libp2p/bootstrap": "^10.0.16", - "@libp2p/circuit-relay-v2": "^1.0.16", - "@libp2p/dcutr": "^1.0.13", - "@libp2p/identify": "^2.0.0", - "@libp2p/interface": "^1.1.4", - "@libp2p/kad-dht": "^12.0.8", - "@libp2p/keychain": "^4.0.9", - "@libp2p/logger": "^4.0.7", - "@libp2p/mdns": "^10.0.16", - "@libp2p/mplex": "^10.0.16", - "@libp2p/ping": "^1.0.12", - "@libp2p/tcp": "^9.0.16", - "@libp2p/upnp-nat": "^1.0.14", - "@libp2p/webrtc": "^4.0.20", - "@libp2p/websockets": "^8.0.16", - "@libp2p/webtransport": "^4.0.20", + "@libp2p/autonat": "^2.0.0", + "@libp2p/bootstrap": "^11.0.0", + "@libp2p/circuit-relay-v2": "^2.0.0", + "@libp2p/dcutr": "^2.0.0", + "@libp2p/identify": "^3.0.0", + "@libp2p/interface": "^2.0.0", + "@libp2p/kad-dht": "^13.0.0", + "@libp2p/keychain": "^5.0.2", + "@libp2p/logger": "^5.0.0", + "@libp2p/mdns": "^11.0.0", + "@libp2p/mplex": "^11.0.0", + "@libp2p/ping": "^2.0.0", + "@libp2p/tcp": "^10.0.0", + "@libp2p/tls": "^2.0.1", + "@libp2p/upnp-nat": "^2.0.0", + "@libp2p/webrtc": "^5.0.0", + "@libp2p/websockets": "^9.0.0", + "@libp2p/webtransport": "^5.0.0", "@multiformats/dns": "^1.0.1", - "blockstore-core": "^4.4.0", - "datastore-core": "^9.2.9", + "blockstore-core": "^5.0.0", + "datastore-core": "^10.0.0", "interface-blockstore": "^5.2.10", "interface-datastore": "^8.2.11", - "ipns": "^9.0.0", - "libp2p": "^1.3.0", + "ipns": "^10.0.0", + "libp2p": "^2.0.0", "multiformats": "^13.1.0" }, "devDependencies": { diff --git a/packages/helia/src/utils/libp2p-defaults.browser.ts b/packages/helia/src/utils/libp2p-defaults.browser.ts index 85cd58391..80ce8c1d9 100644 --- a/packages/helia/src/utils/libp2p-defaults.browser.ts +++ b/packages/helia/src/utils/libp2p-defaults.browser.ts @@ -35,7 +35,7 @@ export function libp2pDefaults (options: Libp2pDefaultsOptions = {}): Libp2pOpti const agentVersion = `${name}/${version} ${libp2pInfo.name}/${libp2pInfo.version} UserAgent=${globalThis.navigator.userAgent}` return { - peerId: options.peerId, + privateKey: options.privateKey, dns: options.dns, addresses: { listen: [ @@ -51,7 +51,7 @@ export function libp2pDefaults (options: Libp2pDefaultsOptions = {}): Libp2pOpti webTransport(), webSockets() ], - connectionEncryption: [ + connectionEncrypters: [ noise() ], streamMuxers: [ diff --git a/packages/helia/src/utils/libp2p-defaults.ts b/packages/helia/src/utils/libp2p-defaults.ts index b7c6b8ab6..39324d1b5 100644 --- a/packages/helia/src/utils/libp2p-defaults.ts +++ b/packages/helia/src/utils/libp2p-defaults.ts @@ -12,6 +12,7 @@ import { mdns } from '@libp2p/mdns' import { mplex } from '@libp2p/mplex' import { ping, type PingService } from '@libp2p/ping' import { tcp } from '@libp2p/tcp' +import { tls } from '@libp2p/tls' import { uPnPNAT } from '@libp2p/upnp-nat' import { webRTC, webRTCDirect } from '@libp2p/webrtc' import { webSockets } from '@libp2p/websockets' @@ -39,7 +40,7 @@ export function libp2pDefaults (options: Libp2pDefaultsOptions = {}): Libp2pOpti const agentVersion = `${name}/${version} ${libp2pInfo.name}/${libp2pInfo.version} UserAgent=${process.version}` return { - peerId: options.peerId, + privateKey: options.privateKey, dns: options.dns, addresses: { listen: [ @@ -57,8 +58,9 @@ export function libp2pDefaults (options: Libp2pDefaultsOptions = {}): Libp2pOpti webRTCDirect(), webSockets() ], - connectionEncryption: [ - noise() + connectionEncrypters: [ + noise(), + tls() ], streamMuxers: [ yamux(), diff --git a/packages/helia/src/utils/libp2p.ts b/packages/helia/src/utils/libp2p.ts index f5597e08e..c906722f9 100644 --- a/packages/helia/src/utils/libp2p.ts +++ b/packages/helia/src/utils/libp2p.ts @@ -1,10 +1,11 @@ +import { generateKeyPair } from '@libp2p/crypto/keys' import { keychain } from '@libp2p/keychain' import { defaultLogger } from '@libp2p/logger' import { Key } from 'interface-datastore' import { createLibp2p as create } from 'libp2p' import { libp2pDefaults } from './libp2p-defaults.js' import type { DefaultLibp2pServices } from './libp2p-defaults.js' -import type { ComponentLogger, Libp2p, PeerId } from '@libp2p/interface' +import type { ComponentLogger, Libp2p, PrivateKey } from '@libp2p/interface' import type { Keychain, KeychainInit } from '@libp2p/keychain' import type { DNS } from '@multiformats/dns' import type { Datastore } from 'interface-datastore' @@ -19,28 +20,35 @@ export interface CreateLibp2pOptions> { } export interface Libp2pDefaultsOptions { - peerId?: PeerId + privateKey?: PrivateKey keychain?: KeychainInit dns?: DNS } export async function createLibp2p = DefaultLibp2pServices> (options: CreateLibp2pOptions): Promise> { - const peerId = options.libp2p?.peerId + const privateKey = options.libp2p?.privateKey const logger = options.logger ?? defaultLogger() const selfKey = new Key('/pkcs8/self') let chain: Keychain | undefined // if no peer id was passed, try to load it from the keychain - if (peerId == null && options.datastore != null) { + if (privateKey == null && options.datastore != null) { chain = keychain(options.keychain)({ datastore: options.datastore, logger }) + options.libp2p = options.libp2p ?? {} + if (await options.datastore.has(selfKey)) { // load the peer id from the keychain - options.libp2p = options.libp2p ?? {} - options.libp2p.peerId = await chain.exportPeerId('self') + options.libp2p.privateKey = await chain.exportKey('self') + } else { + const privateKey = await generateKeyPair('Ed25519') + options.libp2p.privateKey = privateKey + + // persist the peer id in the keychain for next time + await chain.importKey('self', privateKey) } } @@ -55,10 +63,5 @@ export async function createLibp2p = DefaultL start: false }) - if (peerId == null && chain != null && !await options.datastore.has(selfKey)) { - // persist the peer id in the keychain for next time - await chain.importPeer('self', node.peerId) - } - return node } diff --git a/packages/http/package.json b/packages/http/package.json index d2564433a..8862902e9 100644 --- a/packages/http/package.json +++ b/packages/http/package.json @@ -57,11 +57,11 @@ "@helia/interface": "^4.3.1", "@helia/routers": "^1.1.1", "@helia/utils": "^0.3.3", - "blockstore-core": "^4.4.0", - "datastore-core": "^9.2.9" + "blockstore-core": "^5.0.0", + "datastore-core": "^10.0.0" }, "devDependencies": { - "@libp2p/interface": "^1.1.4", + "@libp2p/interface": "^2.0.0", "aegir": "^44.0.1", "interface-datastore": "^8.2.11", "multiformats": "^13.1.0", diff --git a/packages/interface/package.json b/packages/interface/package.json index 951de50f6..e8dae9cb8 100644 --- a/packages/interface/package.json +++ b/packages/interface/package.json @@ -70,11 +70,11 @@ "build": "aegir build" }, "dependencies": { - "@libp2p/interface": "^1.1.4", + "@libp2p/interface": "^2.0.0", "@multiformats/dns": "^1.0.1", "interface-blockstore": "^5.2.10", "interface-datastore": "^8.2.11", - "interface-store": "^5.1.8", + "interface-store": "^6.0.0", "multiformats": "^13.1.0", "progress-events": "^1.0.0" }, diff --git a/packages/interface/src/errors.ts b/packages/interface/src/errors.ts new file mode 100644 index 000000000..c302b06a0 --- /dev/null +++ b/packages/interface/src/errors.ts @@ -0,0 +1,17 @@ +export class InsufficientProvidersError extends Error { + static name = 'InsufficientProvidersError' + + constructor (message = 'Insufficient providers found') { + super(message) + this.name = 'InsufficientProvidersError' + } +} + +export class NoRoutersAvailableError extends Error { + static name = 'NoRoutersAvailableError' + + constructor (message = 'No routers available') { + super(message) + this.name = 'NoRoutersAvailableError' + } +} diff --git a/packages/interface/src/index.ts b/packages/interface/src/index.ts index 81bb34509..e915a1e4d 100644 --- a/packages/interface/src/index.ts +++ b/packages/interface/src/index.ts @@ -113,5 +113,6 @@ export interface DAGWalker { } export * from './blocks.js' +export * from './errors.js' export * from './pins.js' export * from './routing.js' diff --git a/packages/interop/package.json b/packages/interop/package.json index 8bee779c0..abca5d898 100644 --- a/packages/interop/package.json +++ b/packages/interop/package.json @@ -57,7 +57,7 @@ "test:electron-main": "aegir test -t electron-main" }, "dependencies": { - "@chainsafe/libp2p-gossipsub": "^13.0.0", + "@chainsafe/libp2p-gossipsub": "^14.0.0", "@helia/block-brokers": "^3.0.3", "@helia/car": "^3.2.0", "@helia/dag-cbor": "^3.0.5", @@ -72,25 +72,24 @@ "@helia/unixfs": "^3.0.7", "@ipld/car": "^5.3.0", "@ipld/dag-cbor": "^9.2.0", - "@libp2p/interface": "^1.1.4", - "@libp2p/kad-dht": "^12.0.8", - "@libp2p/keychain": "^4.0.9", - "@libp2p/peer-id": "^4.0.7", - "@libp2p/peer-id-factory": "^4.0.7", - "@libp2p/websockets": "^8.0.16", + "@libp2p/interface": "^2.0.0", + "@libp2p/kad-dht": "^13.0.0", + "@libp2p/keychain": "^5.0.2", + "@libp2p/peer-id": "^5.0.0", + "@libp2p/websockets": "^9.0.0", "@multiformats/sha3": "^3.0.2", "aegir": "^44.0.1", "helia": "^4.2.5", "ipfs-unixfs-importer": "^15.2.4", - "ipfsd-ctl": "^14.0.0", + "ipfsd-ctl": "^15.0.0", "it-all": "^3.0.4", "it-drain": "^3.0.5", "it-last": "^3.0.4", "it-map": "^3.0.5", "it-to-buffer": "^4.0.5", - "kubo": "^0.29.0", - "kubo-rpc-client": "^4.0.0", - "libp2p": "^1.2.4", + "kubo": "^0.30.0", + "kubo-rpc-client": "^5.0.0", + "libp2p": "^2.0.0", "multiformats": "^13.1.0", "p-defer": "^4.0.0", "uint8arrays": "^5.0.2", diff --git a/packages/interop/src/fixtures/create-peer-ids.ts b/packages/interop/src/fixtures/create-peer-ids.ts index 60e0094b7..cde0a72a3 100644 --- a/packages/interop/src/fixtures/create-peer-ids.ts +++ b/packages/interop/src/fixtures/create-peer-ids.ts @@ -33,7 +33,7 @@ export async function sortClosestPeers (buf: Uint8Array, peers: PeerId[]): Promi * Creates a DHT ID by hashing a Peer ID */ export async function convertPeerId (peerId: PeerId): Promise { - return convertBuffer(peerId.toBytes()) + return convertBuffer(peerId.toMultihash().bytes) } /** diff --git a/packages/interop/src/ipns-http.spec.ts b/packages/interop/src/ipns-http.spec.ts index 56e7ead04..1d51b8b4f 100644 --- a/packages/interop/src/ipns-http.spec.ts +++ b/packages/interop/src/ipns-http.spec.ts @@ -2,8 +2,9 @@ import { ipns } from '@helia/ipns' import { delegatedHTTPRouting } from '@helia/routers' -import { peerIdFromString } from '@libp2p/peer-id' +import { peerIdFromCID } from '@libp2p/peer-id' import { expect } from 'aegir/chai' +import { CID } from 'multiformats/cid' import { isNode } from 'wherearewe' import { createHeliaHTTP } from './fixtures/create-helia-http.js' import { createKuboNode } from './fixtures/create-kubo.js' @@ -58,9 +59,8 @@ describe('@helia/ipns - http', () => { key: keyName }) - const key = peerIdFromString(res.name) - - const { cid: resolvedCid } = await name.resolve(key) + const key = peerIdFromCID(CID.parse(res.name)) + const { cid: resolvedCid } = await name.resolve(key.toMultihash()) expect(resolvedCid.toString()).to.equal(cid.toString()) }) }) diff --git a/packages/interop/src/ipns-pubsub.spec.ts b/packages/interop/src/ipns-pubsub.spec.ts index fa4a1b25e..bcbdbd421 100644 --- a/packages/interop/src/ipns-pubsub.spec.ts +++ b/packages/interop/src/ipns-pubsub.spec.ts @@ -4,13 +4,14 @@ import { gossipsub } from '@chainsafe/libp2p-gossipsub' import { ipns } from '@helia/ipns' import { pubsub } from '@helia/ipns/routing' -import { peerIdFromKeys } from '@libp2p/peer-id' +import { hasCode } from '@helia/utils' +import { generateKeyPair } from '@libp2p/crypto/keys' +import { peerIdFromCID } from '@libp2p/peer-id' import { expect } from 'aegir/chai' import last from 'it-last' import { base36 } from 'multiformats/bases/base36' import { CID } from 'multiformats/cid' import * as raw from 'multiformats/codecs/raw' -import { identity } from 'multiformats/hashes/identity' import { sha256 } from 'multiformats/hashes/sha2' import { concat as uint8ArrayConcat } from 'uint8arrays/concat' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' @@ -26,8 +27,6 @@ import type { Keychain } from '@libp2p/keychain' import type { HeliaLibp2p } from 'helia' import type { KuboNode } from 'ipfsd-ctl' -const LIBP2P_KEY_CODEC = 0x72 - // skip RSA tests because we need the DHT enabled to find the public key // component of the keypair, but that means we can't test pubsub // resolution because Kubo will use the DHT as well @@ -70,21 +69,16 @@ keyTypes.filter(keyType => keyType !== 'RSA').forEach(keyType => { const digest = await sha256.digest(input) const cid = CID.createV1(raw.code, digest) - const keyName = 'my-ipns-key' - await helia.libp2p.services.keychain.createKey(keyName, keyType) - const peerId = await helia.libp2p.services.keychain.exportPeerId(keyName) - - if (peerId.publicKey == null) { - throw new Error('No public key present') - } + const privateKey = await generateKeyPair('Ed25519') - // first call to pubsub resolver will fail but we should trigger subscribing pubsub for updates - await expect(last(kubo.api.name.resolve(peerId, { + // first call to pubsub resolver will fail but we should trigger + // subscribing pubsub for updates + await expect(last(kubo.api.name.resolve(privateKey.publicKey.toString(), { timeout: 100 }))).to.eventually.be.undefined() // wait for kubo to be subscribed to updates - const kuboSubscriptionName = `/ipns/${CID.createV1(LIBP2P_KEY_CODEC, identity.digest(peerId.publicKey)).toString(base36)}` + const kuboSubscriptionName = `/ipns/${privateKey.publicKey.toCID().toString(base36)}` await waitFor(async () => { const subs = await kubo.api.name.pubsub.subs() return subs.includes(kuboSubscriptionName) @@ -96,7 +90,7 @@ keyTypes.filter(keyType => keyType !== 'RSA').forEach(keyType => { // wait for helia to see that kubo is subscribed to the topic for record updates const heliaSubscriptionName = `/record/${uint8ArrayToString(uint8ArrayConcat([ uint8ArrayFromString('/ipns/'), - peerId.toBytes() + privateKey.publicKey.toMultihash().bytes ]), 'base64url')}` const kuboPeerId = (await kubo.api.id()).id.toString() await waitFor(async () => { @@ -108,10 +102,10 @@ keyTypes.filter(keyType => keyType !== 'RSA').forEach(keyType => { }) // publish should now succeed - await name.publish(peerId, cid) + await name.publish(privateKey, cid) // kubo should now be able to resolve IPNS name instantly - const resolved = await last(kubo.api.name.resolve(peerId, { + const resolved = await last(kubo.api.name.resolve(privateKey.publicKey.toString(), { timeout: 100 })) @@ -133,15 +127,19 @@ keyTypes.filter(keyType => keyType !== 'RSA').forEach(keyType => { // the generated id is libp2p-key CID with the public key as an identity multihash const peerCid = CID.parse(result.id, base36) - const peerId = await peerIdFromKeys(peerCid.multihash.digest) + const peerId = peerIdFromCID(peerCid) + + if (!hasCode(peerCid.multihash, 0)) { + throw new Error('Incorrect hash type') + } // first call to pubsub resolver should fail but we should now be subscribed for updates - await expect(name.resolve(peerId)).to.eventually.be.rejected() + await expect(name.resolve(peerCid.multihash)).to.eventually.be.rejected() // actual pubsub subscription name const subscriptionName = `/record/${uint8ArrayToString(uint8ArrayConcat([ uint8ArrayFromString('/ipns/'), - peerId.toBytes() + peerId.toMultihash().bytes ]), 'base64url')}` // wait for helia to be subscribed to the topic for record updates @@ -172,7 +170,7 @@ keyTypes.filter(keyType => keyType !== 'RSA').forEach(keyType => { // we should get an update eventually await waitFor(async () => { try { - resolveResult = await name.resolve(peerId) + resolveResult = await name.resolve(peerId.toMultihash()) return true } catch { diff --git a/packages/interop/src/ipns.spec.ts b/packages/interop/src/ipns.spec.ts index c5690cc37..f00562d33 100644 --- a/packages/interop/src/ipns.spec.ts +++ b/packages/interop/src/ipns.spec.ts @@ -1,15 +1,14 @@ /* eslint-env mocha */ import { ipns } from '@helia/ipns' +import { generateKeyPair, privateKeyToProtobuf } from '@libp2p/crypto/keys' import { peerIdFromString } from '@libp2p/peer-id' -import { createEd25519PeerId, createRSAPeerId, createSecp256k1PeerId } from '@libp2p/peer-id-factory' import { expect } from 'aegir/chai' +import { multihashToIPNSRoutingKey } from 'ipns' import last from 'it-last' import { CID } from 'multiformats/cid' import * as raw from 'multiformats/codecs/raw' import { sha256 } from 'multiformats/hashes/sha2' -import { concat as uint8ArrayConcat } from 'uint8arrays/concat' -import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' import { isElectronMain } from 'wherearewe' import { connect } from './fixtures/connect.js' import { createHeliaNode } from './fixtures/create-helia.js' @@ -18,7 +17,7 @@ import { sortClosestPeers } from './fixtures/create-peer-ids.js' import { keyTypes } from './fixtures/key-types.js' import { waitFor } from './fixtures/wait-for.js' import type { IPNS } from '@helia/ipns' -import type { PeerId } from '@libp2p/interface' +import type { PrivateKey } from '@libp2p/interface' import type { HeliaLibp2p } from 'helia' import type { KuboNode } from 'ipfsd-ctl' @@ -32,7 +31,7 @@ keyTypes.forEach(type => { let value: CID // the public key we will use to publish the value - let key: PeerId + let key: PrivateKey /** * Ensure that for the CID we are going to publish, the resolver has a peer ID that @@ -50,17 +49,14 @@ keyTypes.forEach(type => { // find a PeerId that is KAD-closer to the resolver than the publisher when used as an IPNS key while (true) { if (type === 'Ed25519') { - key = await createEd25519PeerId() + key = await generateKeyPair('Ed25519') } else if (type === 'secp256k1') { - key = await createSecp256k1PeerId() + key = await generateKeyPair('secp256k1') } else { - key = await createRSAPeerId() + key = await generateKeyPair('RSA', 2048) } - const routingKey = uint8ArrayConcat([ - uint8ArrayFromString('/ipns/'), - key.toBytes() - ]) + const routingKey = multihashToIPNSRoutingKey(key.publicKey?.toMultihash()) const [closest] = await sortClosestPeers(routingKey, [ helia.libp2p.peerId, @@ -128,12 +124,11 @@ keyTypes.forEach(type => { it(`should publish on helia and resolve on kubo using a ${type} key`, async () => { await createNodes('kubo') - const keyName = 'my-ipns-key' - await helia.libp2p.services.keychain.importPeer(keyName, key) + const privateKey = await generateKeyPair('Ed25519') - await name.publish(key, value) + await name.publish(privateKey, value) - const resolved = await last(kubo.api.name.resolve(key.toString())) + const resolved = await last(kubo.api.name.resolve(privateKey.publicKey.toString())) if (resolved == null) { throw new Error('kubo failed to resolve name') @@ -161,7 +156,7 @@ keyTypes.forEach(type => { // ensure the key is in the kubo keychain so we can use it to publish the IPNS record const body = new FormData() - body.append('key', new Blob([key.privateKey ?? new Uint8Array(0)])) + body.append('key', new Blob([privateKeyToProtobuf(key)])) // can't use the kubo-rpc-api for this call yet const config = kubo.api.getEndpointConfig() @@ -179,7 +174,7 @@ keyTypes.forEach(type => { ttl: '1h' }) - const { cid: resolvedCid, record } = await name.resolve(key) + const { cid: resolvedCid, record } = await name.resolve(key.publicKey) expect(resolvedCid.toString()).to.equal(cid.toString()) expect(record.ttl).to.equal(oneHourNS) }) diff --git a/packages/ipns/package.json b/packages/ipns/package.json index 77681517f..dc3417b0f 100644 --- a/packages/ipns/package.json +++ b/packages/ipns/package.json @@ -165,22 +165,21 @@ }, "dependencies": { "@helia/interface": "^4.3.1", - "@libp2p/interface": "^1.1.4", - "@libp2p/kad-dht": "^12.0.8", - "@libp2p/logger": "^4.0.7", - "@libp2p/peer-id": "^4.0.7", + "@libp2p/interface": "^2.0.0", + "@libp2p/kad-dht": "^13.0.0", + "@libp2p/logger": "^5.0.0", + "@libp2p/peer-id": "^5.0.0", "@multiformats/dns": "^1.0.1", "interface-datastore": "^8.2.11", - "ipns": "^9.1.0", + "ipns": "^10.0.0", "multiformats": "^13.1.0", "progress-events": "^1.0.0", "uint8arrays": "^5.0.2" }, "devDependencies": { - "@libp2p/peer-id-factory": "^4.0.7", "@types/dns-packet": "^5.6.5", "aegir": "^44.0.1", - "datastore-core": "^9.2.9", + "datastore-core": "^10.0.0", "it-drain": "^3.0.5", "sinon": "^18.0.0", "sinon-ts": "^2.0.0" diff --git a/packages/ipns/src/dnslink.ts b/packages/ipns/src/dnslink.ts index c2060400b..8ccf9ce68 100644 --- a/packages/ipns/src/dnslink.ts +++ b/packages/ipns/src/dnslink.ts @@ -1,8 +1,10 @@ -import { CodeError, type Logger } from '@libp2p/interface' +import { } from '@libp2p/interface' import { peerIdFromString } from '@libp2p/peer-id' import { RecordType } from '@multiformats/dns' import { CID } from 'multiformats/cid' +import { DNSLinkNotFoundError } from './errors.js' import type { ResolveDNSLinkOptions } from './index.js' +import type { Logger } from '@libp2p/interface' import type { Answer, DNS } from '@multiformats/dns' const MAX_RECURSIVE_DEPTH = 32 @@ -26,7 +28,7 @@ async function recursiveResolveDnslink (domain: string, depth: number, dns: DNS, }) // sort the TXT records to ensure deterministic processing - const txtRecords = txtRecordsResponse.Answer + const txtRecords = (txtRecordsResponse?.Answer ?? []) .sort((a, b) => a.data.localeCompare(b.data)) log('found %d TXT records for %s', txtRecords.length, domain) @@ -98,7 +100,7 @@ async function recursiveResolveDnslink (domain: string, depth: number, dns: DNS, }) // sort the CNAME records to ensure deterministic processing - const cnameRecords = cnameRecordsResponse.Answer + const cnameRecords = (cnameRecordsResponse?.Answer ?? []) .sort((a, b) => a.data.localeCompare(b.data)) log('found %d CNAME records for %s', cnameRecords.length, domain) @@ -111,7 +113,7 @@ async function recursiveResolveDnslink (domain: string, depth: number, dns: DNS, } } - throw new CodeError(`No DNSLink records found for domain: ${domain}`, 'ERR_DNSLINK_NOT_FOUND') + throw new DNSLinkNotFoundError(`No DNSLink records found for domain: ${domain}`) } async function recursiveResolveDomain (domain: string, depth: number, dns: DNS, log: Logger, options: ResolveDNSLinkOptions = {}): Promise { @@ -130,7 +132,7 @@ async function recursiveResolveDomain (domain: string, depth: number, dns: DNS, return await recursiveResolveDnslink(domain, depth, dns, log, options) } catch (err: any) { // If the code is not ENOTFOUND or ERR_DNSLINK_NOT_FOUND or ENODATA then throw the error - if (err.code !== 'ENOTFOUND' && err.code !== 'ERR_DNSLINK_NOT_FOUND' && err.code !== 'ENODATA') { + if (err.code !== 'ENOTFOUND' && err.code !== 'ENODATA' && err.name !== 'DNSLinkNotFoundError' && err.name !== 'NotFoundError') { throw err } diff --git a/packages/ipns/src/errors.ts b/packages/ipns/src/errors.ts new file mode 100644 index 000000000..39360163d --- /dev/null +++ b/packages/ipns/src/errors.ts @@ -0,0 +1,53 @@ +export class DNSLinkNotFoundError extends Error { + static name = 'DNSLinkNotFoundError' + + constructor (message = 'DNSLink not found') { + super(message) + this.name = 'DNSLinkNotFoundError' + } +} + +export class RecordsFailedValidationError extends Error { + static name = 'RecordsFailedValidationError' + + constructor (message = 'Records failed validation') { + super(message) + this.name = 'RecordsFailedValidationError' + } +} + +export class UnsupportedMultibasePrefixError extends Error { + static name = 'UnsupportedMultibasePrefixError' + + constructor (message = 'Unsupported multibase prefix') { + super(message) + this.name = 'UnsupportedMultibasePrefixError' + } +} + +export class UnsupportedMultihashCodecError extends Error { + static name = 'UnsupportedMultihashCodecError' + + constructor (message = 'Unsupported multihash codec') { + super(message) + this.name = 'UnsupportedMultihashCodecError' + } +} + +export class InvalidValueError extends Error { + static name = 'InvalidValueError' + + constructor (message = 'Invalid value') { + super(message) + this.name = 'InvalidValueError' + } +} + +export class InvalidTopicError extends Error { + static name = 'InvalidTopicError' + + constructor (message = 'Invalid topic') { + super(message) + this.name = 'InvalidTopicError' + } +} diff --git a/packages/ipns/src/index.ts b/packages/ipns/src/index.ts index 1d9533b8f..f2a0a152b 100644 --- a/packages/ipns/src/index.ts +++ b/packages/ipns/src/index.ts @@ -227,23 +227,28 @@ * ``` */ -import { CodeError } from '@libp2p/interface' +import { NotFoundError, isPublicKey } from '@libp2p/interface' import { logger } from '@libp2p/logger' -import { peerIdFromString } from '@libp2p/peer-id' -import { create, marshal, peerIdToRoutingKey, unmarshal } from 'ipns' +import { createIPNSRecord, marshalIPNSRecord, multihashToIPNSRoutingKey, unmarshalIPNSRecord, type IPNSRecord } from 'ipns' import { ipnsSelector } from 'ipns/selector' import { ipnsValidator } from 'ipns/validator' +import { base36 } from 'multiformats/bases/base36' +import { base58btc } from 'multiformats/bases/base58' import { CID } from 'multiformats/cid' +import * as Digest from 'multiformats/hashes/digest' import { CustomProgressEvent } from 'progress-events' import { resolveDNSLink } from './dnslink.js' +import { InvalidValueError, RecordsFailedValidationError, UnsupportedMultibasePrefixError, UnsupportedMultihashCodecError } from './errors.js' import { helia } from './routing/helia.js' import { localStore, type LocalStore } from './routing/local-store.js' +import { isCodec, IDENTITY_CODEC, SHA2_256_CODEC } from './utils.js' import type { IPNSRouting, IPNSRoutingEvents } from './routing/index.js' import type { Routing } from '@helia/interface' -import type { AbortOptions, ComponentLogger, Logger, PeerId } from '@libp2p/interface' +import type { AbortOptions, ComponentLogger, Logger, PrivateKey, PublicKey } from '@libp2p/interface' import type { Answer, DNS, ResolveDnsProgressEvents } from '@multiformats/dns' import type { Datastore } from 'interface-datastore' -import type { IPNSRecord } from 'ipns' +import type { MultibaseDecoder } from 'multiformats/bases/interface' +import type { MultihashDigest } from 'multiformats/hashes/interface' import type { ProgressEvent, ProgressOptions } from 'progress-events' const log = logger('helia:ipns') @@ -375,13 +380,13 @@ export interface IPNS { * * If the value is a PeerId, a recursive IPNS record will be created. */ - publish(key: PeerId, value: CID | PeerId | string, options?: PublishOptions): Promise + publish(key: PrivateKey, value: CID | PublicKey | MultihashDigest<0x00 | 0x12> | string, options?: PublishOptions): Promise /** * Accepts a public key formatted as a libp2p PeerID and resolves the IPNS record * corresponding to that public key until a value is found */ - resolve(key: PeerId, options?: ResolveOptions): Promise + resolve(key: PublicKey | MultihashDigest<0x00 | 0x12>, options?: ResolveOptions): Promise /** * Resolve a CID from a dns-link style IPNS record @@ -403,6 +408,11 @@ export interface IPNSComponents { logger: ComponentLogger } +const bases: Record> = { + [base36.prefix]: base36, + [base58btc.prefix]: base58btc +} + class DefaultIPNS implements IPNS { private readonly routers: IPNSRouting[] private readonly localStore: LocalStore @@ -420,21 +430,21 @@ class DefaultIPNS implements IPNS { this.log = components.logger.forComponent('helia:ipns') } - async publish (key: PeerId, value: CID | PeerId | string, options: PublishOptions = {}): Promise { + async publish (key: PrivateKey, value: CID | PublicKey | MultihashDigest<0x00 | 0x12> | string, options: PublishOptions = {}): Promise { try { let sequenceNumber = 1n - const routingKey = peerIdToRoutingKey(key) + const routingKey = multihashToIPNSRoutingKey(key.publicKey.toMultihash()) if (await this.localStore.has(routingKey, options)) { // if we have published under this key before, increment the sequence number const { record } = await this.localStore.get(routingKey, options) - const existingRecord = unmarshal(record) + const existingRecord = unmarshalIPNSRecord(record) sequenceNumber = existingRecord.sequence + 1n } // create record - const record = await create(key, value, sequenceNumber, options.lifetime ?? DEFAULT_LIFETIME_MS, options) - const marshaledRecord = marshal(record) + const record = await createIPNSRecord(key, value, sequenceNumber, options.lifetime ?? DEFAULT_LIFETIME_MS, options) + const marshaledRecord = marshalIPNSRecord(record) await this.localStore.put(routingKey, marshaledRecord, options) @@ -450,8 +460,9 @@ class DefaultIPNS implements IPNS { } } - async resolve (key: PeerId, options: ResolveOptions = {}): Promise { - const routingKey = peerIdToRoutingKey(key) + async resolve (key: PublicKey | MultihashDigest<0x00 | 0x12>, options: ResolveOptions = {}): Promise { + const digest = isPublicKey(key) ? key.toMultihash() : key + const routingKey = multihashToIPNSRoutingKey(digest) const record = await this.#findIpnsRecord(routingKey, options) return { @@ -511,7 +522,31 @@ class DefaultIPNS implements IPNS { const scheme = parts[1] if (scheme === 'ipns') { - const { cid } = await this.resolve(peerIdFromString(parts[2]), options) + const str = parts[2] + const prefix = str.substring(0, 1) + let buf: Uint8Array | undefined + + if (prefix === '1' || prefix === 'Q') { + buf = base58btc.decode(`z${str}`) + } else if (bases[prefix] != null) { + buf = bases[prefix].decode(str) + } else { + throw new UnsupportedMultibasePrefixError(`Unsupported multibase prefix "${prefix}"`) + } + + let digest: MultihashDigest + + try { + digest = Digest.decode(buf) + } catch { + digest = CID.decode(buf).multihash + } + + if (!isCodec(digest, IDENTITY_CODEC) && !isCodec(digest, SHA2_256_CODEC)) { + throw new UnsupportedMultihashCodecError(`Unsupported multihash codec "${digest.code}"`) + } + + const { cid } = await this.resolve(digest, options) const path = parts.slice(3).join('/') return { cid, @@ -530,7 +565,7 @@ class DefaultIPNS implements IPNS { } log.error('invalid ipfs path %s', ipfsPath) - throw new Error('Invalid value') + throw new InvalidValueError('Invalid value') } async #findIpnsRecord (routingKey: Uint8Array, options: ResolveOptions = {}): Promise { @@ -553,7 +588,7 @@ class DefaultIPNS implements IPNS { this.log('record was valid') // check the TTL - const ipnsRecord = unmarshal(record) + const ipnsRecord = unmarshalIPNSRecord(record) // IPNS TTL is in nanoseconds, convert to milliseconds, default to one // hour @@ -588,7 +623,7 @@ class DefaultIPNS implements IPNS { } if (options.offline === true) { - throw new CodeError('Record was not present in the cache or has expired', 'ERR_NOT_FOUND') + throw new NotFoundError('Record was not present in the cache or has expired') } log('did not have record locally') @@ -624,17 +659,17 @@ class DefaultIPNS implements IPNS { if (records.length === 0) { if (foundInvalid > 0) { - throw new CodeError(`${foundInvalid > 1 ? `${foundInvalid} records` : 'Record'} found for routing key ${foundInvalid > 1 ? 'were' : 'was'} invalid`, 'ERR_RECORDS_FAILED_VALIDATION') + throw new RecordsFailedValidationError(`${foundInvalid > 1 ? `${foundInvalid} records` : 'Record'} found for routing key ${foundInvalid > 1 ? 'were' : 'was'} invalid`) } - throw new CodeError('Could not find record for routing key', 'ERR_NOT_FOUND') + throw new NotFoundError('Could not find record for routing key') } const record = records[ipnsSelector(routingKey, records)] await this.localStore.put(routingKey, record, options) - return unmarshal(record) + return unmarshalIPNSRecord(record) } } diff --git a/packages/ipns/src/routing/local-store.ts b/packages/ipns/src/routing/local-store.ts index 90dc2bbe4..0ac87e5ef 100644 --- a/packages/ipns/src/routing/local-store.ts +++ b/packages/ipns/src/routing/local-store.ts @@ -48,7 +48,7 @@ export function localStore (datastore: Datastore): LocalStore { return } } catch (err: any) { - if (err.code !== 'ERR_NOT_FOUND') { + if (err.name !== 'NotFoundError') { throw err } } diff --git a/packages/ipns/src/routing/pubsub.ts b/packages/ipns/src/routing/pubsub.ts index 7679cb5bf..4e4075a7e 100644 --- a/packages/ipns/src/routing/pubsub.ts +++ b/packages/ipns/src/routing/pubsub.ts @@ -1,16 +1,18 @@ -import { CodeError } from '@libp2p/interface' +import { isPublicKey } from '@libp2p/interface' import { logger } from '@libp2p/logger' -import { peerIdToRoutingKey } from 'ipns' +import { multihashToIPNSRoutingKey } from 'ipns' import { ipnsSelector } from 'ipns/selector' import { ipnsValidator } from 'ipns/validator' import { CustomProgressEvent, type ProgressEvent } from 'progress-events' import { equals as uint8ArrayEquals } from 'uint8arrays/equals' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' import { toString as uint8ArrayToString } from 'uint8arrays/to-string' +import { InvalidTopicError } from '../errors.js' import { localStore, type LocalStore } from './local-store.js' import type { GetOptions, IPNSRouting, PutOptions } from './index.js' -import type { PeerId, Message, PublishResult, PubSub } from '@libp2p/interface' +import type { PeerId, Message, PublishResult, PubSub, PublicKey } from '@libp2p/interface' import type { Datastore } from 'interface-datastore' +import type { MultihashDigest } from 'multiformats/hashes/interface' const log = logger('helia:ipns:routing:pubsub') @@ -147,8 +149,9 @@ class PubSubRouting implements IPNSRouting { /** * Cancel pubsub subscriptions related to ipns */ - cancel (key: PeerId): void { - const routingKey = peerIdToRoutingKey(key) + cancel (key: PublicKey | MultihashDigest<0x00 | 0x12>): void { + const digest = isPublicKey(key) ? key.toMultihash() : key + const routingKey = multihashToIPNSRoutingKey(digest) const topic = keyToTopic(routingKey) // Not found topic @@ -177,7 +180,7 @@ function keyToTopic (key: Uint8Array): string { */ function topicToKey (topic: string): Uint8Array { if (topic.substring(0, PUBSUB_NAMESPACE.length) !== PUBSUB_NAMESPACE) { - throw new CodeError('topic received is not from a record', 'ERR_TOPIC_IS_NOT_FROM_RECORD_NAMESPACE') + throw new InvalidTopicError('Topic received is not from a record') } const key = topic.substring(PUBSUB_NAMESPACE.length) diff --git a/packages/ipns/src/utils.ts b/packages/ipns/src/utils.ts new file mode 100644 index 000000000..9e22204ea --- /dev/null +++ b/packages/ipns/src/utils.ts @@ -0,0 +1,8 @@ +import type { MultihashDigest } from 'multiformats/hashes/interface' + +export const IDENTITY_CODEC = 0x0 +export const SHA2_256_CODEC = 0x12 + +export function isCodec (digest: MultihashDigest, codec: T): digest is MultihashDigest { + return digest.code === codec +} diff --git a/packages/ipns/test/publish.spec.ts b/packages/ipns/test/publish.spec.ts index 4043ec25e..93ad92521 100644 --- a/packages/ipns/test/publish.spec.ts +++ b/packages/ipns/test/publish.spec.ts @@ -1,17 +1,18 @@ /* eslint-env mocha */ +import { generateKeyPair } from '@libp2p/crypto/keys' import { defaultLogger } from '@libp2p/logger' -import { createEd25519PeerId } from '@libp2p/peer-id-factory' import { expect } from 'aegir/chai' import { MemoryDatastore } from 'datastore-core' import { base36 } from 'multiformats/bases/base36' import { CID } from 'multiformats/cid' import Sinon from 'sinon' -import { type StubbedInstance, stubInterface } from 'sinon-ts' +import { stubInterface } from 'sinon-ts' import { ipns } from '../src/index.js' import type { IPNS, IPNSRouting } from '../src/index.js' import type { Routing } from '@helia/interface' import type { DNS } from '@multiformats/dns' +import type { StubbedInstance } from 'sinon-ts' const cid = CID.parse('QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn') @@ -40,7 +41,7 @@ describe('publish', () => { }) it('should publish an IPNS record with the default params', async function () { - const key = await createEd25519PeerId() + const key = await generateKeyPair('Ed25519') const ipnsEntry = await name.publish(key, cid) expect(ipnsEntry).to.have.property('sequence', 1n) @@ -48,7 +49,7 @@ describe('publish', () => { }) it('should publish an IPNS record with a custom ttl params', async function () { - const key = await createEd25519PeerId() + const key = await generateKeyPair('Ed25519') const lifetime = 123000 const ipnsEntry = await name.publish(key, cid, { lifetime @@ -62,7 +63,7 @@ describe('publish', () => { }) it('should publish a record offline', async () => { - const key = await createEd25519PeerId() + const key = await generateKeyPair('Ed25519') await name.publish(key, cid, { offline: true }) @@ -72,7 +73,7 @@ describe('publish', () => { }) it('should emit progress events', async function () { - const key = await createEd25519PeerId() + const key = await generateKeyPair('Ed25519') const onProgress = Sinon.stub() await name.publish(key, cid, { onProgress @@ -82,21 +83,21 @@ describe('publish', () => { }) it('should publish recursively', async () => { - const key = await createEd25519PeerId() + const key = await generateKeyPair('Ed25519') const record = await name.publish(key, cid, { offline: true }) expect(record.value).to.equal(`/ipfs/${cid.toV1().toString()}`) - const recursiveKey = await createEd25519PeerId() - const recursiveRecord = await name.publish(recursiveKey, key, { + const recursiveKey = await generateKeyPair('Ed25519') + const recursiveRecord = await name.publish(recursiveKey, key.publicKey, { offline: true }) - expect(recursiveRecord.value).to.equal(`/ipns/${key.toCID().toString(base36)}`) + expect(recursiveRecord.value).to.equal(`/ipns/${key.publicKey.toCID().toString(base36)}`) - const recursiveResult = await name.resolve(recursiveKey) + const recursiveResult = await name.resolve(recursiveKey.publicKey) expect(recursiveResult.cid.toString()).to.equal(cid.toV1().toString()) }) @@ -104,14 +105,14 @@ describe('publish', () => { const path = '/foo/bar/baz' const fullPath = `/ipfs/${cid}/${path}` - const key = await createEd25519PeerId() + const key = await generateKeyPair('Ed25519') const record = await name.publish(key, fullPath, { offline: true }) expect(record.value).to.equal(fullPath) - const result = await name.resolve(key) + const result = await name.resolve(key.publicKey) expect(result.cid.toString()).to.equal(cid.toString()) expect(result.path).to.equal(path) diff --git a/packages/ipns/test/resolve-dnslink.spec.ts b/packages/ipns/test/resolve-dnslink.spec.ts index e6f6b2d61..588a37f08 100644 --- a/packages/ipns/test/resolve-dnslink.spec.ts +++ b/packages/ipns/test/resolve-dnslink.spec.ts @@ -1,17 +1,20 @@ /* eslint-env mocha */ -import { CodeError } from '@libp2p/interface' +import { generateKeyPair } from '@libp2p/crypto/keys' +import { NotFoundError } from '@libp2p/interface' import { defaultLogger } from '@libp2p/logger' -import { createEd25519PeerId } from '@libp2p/peer-id-factory' +import { peerIdFromPrivateKey } from '@libp2p/peer-id' import { RecordType } from '@multiformats/dns' import { expect } from 'aegir/chai' import { MemoryDatastore } from 'datastore-core' -import { type Datastore } from 'interface-datastore' import { CID } from 'multiformats/cid' -import { type StubbedInstance, stubInterface } from 'sinon-ts' -import { ipns, type IPNS } from '../src/index.js' +import { stubInterface } from 'sinon-ts' +import { ipns } from '../src/index.js' +import type { IPNS } from '../src/index.js' import type { Routing } from '@helia/interface' import type { DNS, Answer, DNSResponse } from '@multiformats/dns' +import type { Datastore } from 'interface-datastore' +import type { StubbedInstance } from 'sinon-ts' function dnsResponse (ansers: Answer[]): DNSResponse { return { @@ -58,7 +61,7 @@ describe('resolveDNSLink', () => { }) it('should retry without `_dnslink.` on a domain', async () => { - dns.query.withArgs('_dnslink.foobar.baz').rejects(new CodeError('Not found', 'ENOTFOUND')) + dns.query.withArgs('_dnslink.foobar.baz').rejects(new NotFoundError('Not found')) dns.query.withArgs('foobar.baz').resolves(dnsResponse([{ name: 'foobar.baz.', TTL: 60, @@ -148,12 +151,13 @@ describe('resolveDNSLink', () => { it('should resolve recursive dnslink -> /', async () => { const cid = CID.parse('QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn') - const key = await createEd25519PeerId() + const key = await generateKeyPair('Ed25519') + const peerId = peerIdFromPrivateKey(key) dns.query.withArgs('_dnslink.foobar.baz').resolves(dnsResponse([{ name: 'foobar.baz.', TTL: 60, type: RecordType.TXT, - data: `dnslink=/ipns/${key}/foobar/path/123` + data: `dnslink=/ipns/${peerId}/foobar/path/123` }])) await name.publish(key, cid) @@ -170,7 +174,7 @@ describe('resolveDNSLink', () => { it('should follow CNAMES to delegated DNSLink domains', async () => { const cid = CID.parse('bafybeifcaqowoyito3qvsmbwbiugsu4umlxn4ehu223hvtubbfvwyuxjoe') - const key = await createEd25519PeerId() + const key = await generateKeyPair('Ed25519') dns.query.withArgs('_dnslink.foobar.baz').resolves(dnsResponse([{ name: '_dnslink.foobar.baz.', TTL: 60, @@ -197,7 +201,7 @@ describe('resolveDNSLink', () => { it('should resolve dnslink namespace', async () => { const cid = CID.parse('bafybeifcaqowoyito3qvsmbwbiugsu4umlxn4ehu223hvtubbfvwyuxjoe') - const key = await createEd25519PeerId() + const key = await generateKeyPair('Ed25519') dns.query.withArgs('_dnslink.foobar.baz').resolves(dnsResponse([{ name: '_dnslink.foobar.baz.', TTL: 60, @@ -224,7 +228,7 @@ describe('resolveDNSLink', () => { it('should include DNS Answer in result', async () => { const cid = CID.parse('bafybeifcaqowoyito3qvsmbwbiugsu4umlxn4ehu223hvtubbfvwyuxjoe') - const key = await createEd25519PeerId() + const key = await generateKeyPair('Ed25519') const answer = { name: '_dnslink.foobar.baz.', TTL: 60, diff --git a/packages/ipns/test/resolve.spec.ts b/packages/ipns/test/resolve.spec.ts index b61351374..8ed9d8f94 100644 --- a/packages/ipns/test/resolve.spec.ts +++ b/packages/ipns/test/resolve.spec.ts @@ -1,12 +1,12 @@ /* eslint-env mocha */ +import { generateKeyPair } from '@libp2p/crypto/keys' import { Record } from '@libp2p/kad-dht' import { defaultLogger } from '@libp2p/logger' -import { createEd25519PeerId } from '@libp2p/peer-id-factory' import { expect } from 'aegir/chai' import { MemoryDatastore } from 'datastore-core' import { type Datastore, Key } from 'interface-datastore' -import { create, createWithExpiration, marshal, peerIdToRoutingKey, unmarshal } from 'ipns' +import { createIPNSRecord, createIPNSRecordWithExpiration, marshalIPNSRecord, multihashToIPNSRoutingKey, unmarshalIPNSRecord } from 'ipns' import drain from 'it-drain' import { CID } from 'multiformats/cid' import Sinon from 'sinon' @@ -46,15 +46,15 @@ describe('resolve', () => { }) it('should resolve a record', async () => { - const key = await createEd25519PeerId() + const key = await generateKeyPair('Ed25519') const record = await name.publish(key, cid) // empty the datastore to ensure we resolve using the routing await drain(datastore.deleteMany(datastore.queryKeys({}))) - heliaRouting.get.resolves(marshal(record)) + heliaRouting.get.resolves(marshalIPNSRecord(record)) - const resolvedValue = await name.resolve(key) + const resolvedValue = await name.resolve(key.publicKey) expect(resolvedValue.cid.toString()).to.equal(cid.toV1().toString()) expect(heliaRouting.get.called).to.be.true() @@ -62,13 +62,13 @@ describe('resolve', () => { }) it('should resolve a record offline', async () => { - const key = await createEd25519PeerId() + const key = await generateKeyPair('Ed25519') await name.publish(key, cid) expect(heliaRouting.put.called).to.be.true() expect(customRouting.put.called).to.be.true() - const resolvedValue = await name.resolve(key, { + const resolvedValue = await name.resolve(key.publicKey, { offline: true }) expect(resolvedValue.cid.toString()).to.equal(cid.toV1().toString()) @@ -81,12 +81,12 @@ describe('resolve', () => { const cachePutSpy = Sinon.spy(datastore, 'put') const cacheGetSpy = Sinon.spy(datastore, 'get') - const key = await createEd25519PeerId() + const key = await generateKeyPair('Ed25519') const record = await name.publish(key, cid) - heliaRouting.get.resolves(marshal(record)) + heliaRouting.get.resolves(marshalIPNSRecord(record)) - const resolvedValue = await name.resolve(key, { + const resolvedValue = await name.resolve(key.publicKey, { nocache: true }) expect(resolvedValue.cid.toString()).to.equal(cid.toV1().toString()) @@ -101,10 +101,10 @@ describe('resolve', () => { it('should retrieve from local cache when resolving a record', async () => { const cacheGetSpy = Sinon.spy(datastore, 'get') - const key = await createEd25519PeerId() + const key = await generateKeyPair('Ed25519') await name.publish(key, cid) - const resolvedValue = await name.resolve(key) + const resolvedValue = await name.resolve(key.publicKey) expect(resolvedValue.cid.toString()).to.equal(cid.toV1().toString()) expect(heliaRouting.get.called).to.be.false() @@ -113,31 +113,31 @@ describe('resolve', () => { }) it('should resolve a recursive record', async () => { - const key1 = await createEd25519PeerId() - const key2 = await createEd25519PeerId() + const key1 = await generateKeyPair('Ed25519') + const key2 = await generateKeyPair('Ed25519') await name.publish(key2, cid) - await name.publish(key1, key2) + await name.publish(key1, key2.publicKey) - const resolvedValue = await name.resolve(key1) + const resolvedValue = await name.resolve(key1.publicKey) expect(resolvedValue.cid.toString()).to.equal(cid.toV1().toString()) }) it('should resolve a recursive record with path', async () => { - const key1 = await createEd25519PeerId() - const key2 = await createEd25519PeerId() + const key1 = await generateKeyPair('Ed25519') + const key2 = await generateKeyPair('Ed25519') await name.publish(key2, cid) - await name.publish(key1, key2) + await name.publish(key1, key2.publicKey) - const resolvedValue = await name.resolve(key1) + const resolvedValue = await name.resolve(key1.publicKey) expect(resolvedValue.cid.toString()).to.equal(cid.toV1().toString()) }) it('should emit progress events', async function () { const onProgress = Sinon.stub() - const key = await createEd25519PeerId() + const key = await generateKeyPair('Ed25519') await name.publish(key, cid) - await name.resolve(key, { + await name.resolve(key.publicKey, { onProgress }) @@ -145,30 +145,30 @@ describe('resolve', () => { }) it('should cache a record', async function () { - const peerId = await createEd25519PeerId() - const customRoutingKey = peerIdToRoutingKey(peerId) + const key = await generateKeyPair('Ed25519') + const customRoutingKey = multihashToIPNSRoutingKey(key.publicKey.toMultihash()) const dhtKey = new Key('/dht/record/' + uint8ArrayToString(customRoutingKey, 'base32'), false) expect(datastore.has(dhtKey)).to.be.false('already had record') - const record = await create(peerId, cid, 0n, 60000) - const marshalledRecord = marshal(record) + const record = await createIPNSRecord(key, cid, 0n, 60000) + const marshalledRecord = marshalIPNSRecord(record) customRouting.get.withArgs(customRoutingKey).resolves(marshalledRecord) - const result = await name.resolve(peerId) + const result = await name.resolve(key.publicKey) expect(result.cid.toString()).to.equal(cid.toV1().toString(), 'incorrect record resolved') expect(datastore.has(dhtKey)).to.be.true('did not cache record locally') }) it('should cache the most recent record', async function () { - const peerId = await createEd25519PeerId() - const customRoutingKey = peerIdToRoutingKey(peerId) + const key = await generateKeyPair('Ed25519') + const customRoutingKey = multihashToIPNSRoutingKey(key.publicKey.toMultihash()) const dhtKey = new Key('/dht/record/' + uint8ArrayToString(customRoutingKey, 'base32'), false) - const marshalledRecordA = marshal(await create(peerId, cid, 0n, 60000)) - const marshalledRecordB = marshal(await create(peerId, cid, 10n, 60000)) + const marshalledRecordA = marshalIPNSRecord(await createIPNSRecord(key, cid, 0n, 60000)) + const marshalledRecordB = marshalIPNSRecord(await createIPNSRecord(key, cid, 10n, 60000)) // records should not match expect(marshalledRecordA).to.not.equalBytes(marshalledRecordB) @@ -177,7 +177,7 @@ describe('resolve', () => { await datastore.put(dhtKey, marshalledRecordA) customRouting.get.withArgs(customRoutingKey).resolves(marshalledRecordB) - const result = await name.resolve(peerId) + const result = await name.resolve(key.publicKey) expect(result.cid.toString()).to.equal(cid.toV1().toString(), 'incorrect record resolved') const cached = await datastore.get(dhtKey) @@ -188,110 +188,110 @@ describe('resolve', () => { }) it('should include IPNS record in result', async () => { - const key = await createEd25519PeerId() + const key = await generateKeyPair('Ed25519') await name.publish(key, cid) - const customRoutingKey = peerIdToRoutingKey(key) + const customRoutingKey = multihashToIPNSRoutingKey(key.publicKey.toMultihash()) const dhtKey = new Key('/dht/record/' + uint8ArrayToString(customRoutingKey, 'base32'), false) const buf = await datastore.get(dhtKey) const dhtRecord = Record.deserialize(buf) - const record = unmarshal(dhtRecord.value) + const record = unmarshalIPNSRecord(dhtRecord.value) - const result = await name.resolve(key) + const result = await name.resolve(key.publicKey) expect(result).to.have.deep.property('record', record) }) it('should not search the routing for updated IPNS records when a locally cached copy is within the TTL', async () => { - const key = await createEd25519PeerId() - const customRoutingKey = peerIdToRoutingKey(key) + const key = await generateKeyPair('Ed25519') + const customRoutingKey = multihashToIPNSRoutingKey(key.publicKey.toMultihash()) const dhtKey = new Key('/dht/record/' + uint8ArrayToString(customRoutingKey, 'base32'), false) // create a record with a valid lifetime and a non-expired TTL - const ipnsRecord = await create(key, cid, 1, Math.pow(2, 10), { + const ipnsRecord = await createIPNSRecord(key, cid, 1, Math.pow(2, 10), { ttlNs: 10_000_000_000 }) - const dhtRecord = new Record(customRoutingKey, marshal(ipnsRecord), new Date(Date.now())) + const dhtRecord = new Record(customRoutingKey, marshalIPNSRecord(ipnsRecord), new Date(Date.now())) await datastore.put(dhtKey, dhtRecord.serialize()) - const result = await name.resolve(key) - expect(result).to.have.deep.property('record', unmarshal(marshal(ipnsRecord))) + const result = await name.resolve(key.publicKey) + expect(result).to.have.deep.property('record', unmarshalIPNSRecord(marshalIPNSRecord(ipnsRecord))) // should not have searched the routing expect(customRouting.get.called).to.be.false() }) it('should search the routing for updated IPNS records when a locally cached copy has passed the TTL', async () => { - const key = await createEd25519PeerId() + const key = await generateKeyPair('Ed25519') - const customRoutingKey = peerIdToRoutingKey(key) + const customRoutingKey = multihashToIPNSRoutingKey(key.publicKey.toMultihash()) const dhtKey = new Key('/dht/record/' + uint8ArrayToString(customRoutingKey, 'base32'), false) // create a record with a valid lifetime but an expired ttl - const ipnsRecord = await create(key, cid, 1, Math.pow(2, 10), { + const ipnsRecord = await createIPNSRecord(key, cid, 1, Math.pow(2, 10), { ttlNs: 10 }) - const dhtRecord = new Record(customRoutingKey, marshal(ipnsRecord), new Date(Date.now() - 1000)) + const dhtRecord = new Record(customRoutingKey, marshalIPNSRecord(ipnsRecord), new Date(Date.now() - 1000)) await datastore.put(dhtKey, dhtRecord.serialize()) - const result = await name.resolve(key) - expect(result).to.have.deep.property('record', unmarshal(marshal(ipnsRecord))) + const result = await name.resolve(key.publicKey) + expect(result).to.have.deep.property('record', unmarshalIPNSRecord(marshalIPNSRecord(ipnsRecord))) // should have searched the routing expect(customRouting.get.called).to.be.true() }) it('should search the routing for updated IPNS records when a locally cached copy has passed the TTL and choose the record with a higher sequence number', async () => { - const key = await createEd25519PeerId() + const key = await generateKeyPair('Ed25519') - const customRoutingKey = peerIdToRoutingKey(key) + const customRoutingKey = multihashToIPNSRoutingKey(key.publicKey.toMultihash()) const dhtKey = new Key('/dht/record/' + uint8ArrayToString(customRoutingKey, 'base32'), false) // create a record with a valid lifetime but an expired ttl - const ipnsRecord = await create(key, cid, 10, Math.pow(2, 10), { + const ipnsRecord = await createIPNSRecord(key, cid, 10, Math.pow(2, 10), { ttlNs: 10 }) - const dhtRecord = new Record(customRoutingKey, marshal(ipnsRecord), new Date(Date.now() - 1000)) + const dhtRecord = new Record(customRoutingKey, marshalIPNSRecord(ipnsRecord), new Date(Date.now() - 1000)) await datastore.put(dhtKey, dhtRecord.serialize()) // the routing returns a valid record with an higher sequence number - const ipnsRecordFromRouting = await create(key, cid, 11, Math.pow(2, 10), { + const ipnsRecordFromRouting = await createIPNSRecord(key, cid, 11, Math.pow(2, 10), { ttlNs: 10_000_000 }) - customRouting.get.withArgs(customRoutingKey).resolves(marshal(ipnsRecordFromRouting)) + customRouting.get.withArgs(customRoutingKey).resolves(marshalIPNSRecord(ipnsRecordFromRouting)) - const result = await name.resolve(key) - expect(result).to.have.deep.property('record', unmarshal(marshal(ipnsRecordFromRouting))) + const result = await name.resolve(key.publicKey) + expect(result).to.have.deep.property('record', unmarshalIPNSRecord(marshalIPNSRecord(ipnsRecordFromRouting))) // should have searched the routing expect(customRouting.get.called).to.be.true() }) it('should search the routing when a locally cached copy has an expired lifetime', async () => { - const key = await createEd25519PeerId() + const key = await generateKeyPair('Ed25519') - const customRoutingKey = peerIdToRoutingKey(key) + const customRoutingKey = multihashToIPNSRoutingKey(key.publicKey.toMultihash()) const dhtKey = new Key('/dht/record/' + uint8ArrayToString(customRoutingKey, 'base32'), false) // create a record with an expired lifetime but valid TTL - const ipnsRecord = await createWithExpiration(key, cid, 10, new Date(Date.now() - Math.pow(2, 10)).toString(), { + const ipnsRecord = await createIPNSRecordWithExpiration(key, cid, 10, new Date(Date.now() - Math.pow(2, 10)).toString(), { ttlNs: 10_000_000 }) - const dhtRecord = new Record(customRoutingKey, marshal(ipnsRecord), new Date(Date.now())) + const dhtRecord = new Record(customRoutingKey, marshalIPNSRecord(ipnsRecord), new Date(Date.now())) await datastore.put(dhtKey, dhtRecord.serialize()) // the routing returns a valid record with an higher sequence number - const ipnsRecordFromRouting = await create(key, cid, 11, Math.pow(2, 10), { + const ipnsRecordFromRouting = await createIPNSRecord(key, cid, 11, Math.pow(2, 10), { ttlNs: 10_000_000 }) - customRouting.get.withArgs(customRoutingKey).resolves(marshal(ipnsRecordFromRouting)) + customRouting.get.withArgs(customRoutingKey).resolves(marshalIPNSRecord(ipnsRecordFromRouting)) - const result = await name.resolve(key) - expect(result).to.have.deep.property('record', unmarshal(marshal(ipnsRecordFromRouting))) + const result = await name.resolve(key.publicKey) + expect(result).to.have.deep.property('record', unmarshalIPNSRecord(marshalIPNSRecord(ipnsRecordFromRouting))) // should have searched the routing expect(customRouting.get.called).to.be.true() diff --git a/packages/json/package.json b/packages/json/package.json index e3972d7f9..ac62bc34e 100644 --- a/packages/json/package.json +++ b/packages/json/package.json @@ -140,14 +140,14 @@ }, "dependencies": { "@helia/interface": "^4.3.1", - "@libp2p/interface": "^1.1.4", + "@libp2p/interface": "^2.0.0", "interface-blockstore": "^5.2.10", "multiformats": "^13.1.0", "progress-events": "^1.0.0" }, "devDependencies": { "aegir": "^44.0.1", - "blockstore-core": "^4.4.0" + "blockstore-core": "^5.0.0" }, "sideEffects": false } diff --git a/packages/mfs/package.json b/packages/mfs/package.json index 73f2b582c..82179dd7e 100644 --- a/packages/mfs/package.json +++ b/packages/mfs/package.json @@ -140,8 +140,8 @@ }, "dependencies": { "@helia/unixfs": "^3.0.7", - "@libp2p/interface": "^1.1.4", - "@libp2p/logger": "^4.0.7", + "@libp2p/interface": "^2.0.0", + "@libp2p/logger": "^5.0.0", "interface-blockstore": "^5.2.10", "interface-datastore": "^8.2.11", "ipfs-unixfs": "^11.1.3", @@ -152,8 +152,8 @@ "devDependencies": { "@ipld/dag-pb": "^4.1.0", "aegir": "^44.0.1", - "blockstore-core": "^4.4.0", - "datastore-core": "^9.2.9", + "blockstore-core": "^5.0.0", + "datastore-core": "^10.0.0", "delay": "^6.0.0", "it-all": "^3.0.4", "it-drain": "^3.0.5", diff --git a/packages/mfs/src/index.ts b/packages/mfs/src/index.ts index 887988f57..6fa4c2372 100644 --- a/packages/mfs/src/index.ts +++ b/packages/mfs/src/index.ts @@ -266,7 +266,7 @@ class DefaultMFS implements MFS { const buf = await this.components.datastore.get(this.key) this.root = CID.decode(buf) } catch (err: any) { - if (err.code !== 'ERR_NOT_FOUND') { + if (err.name !== 'NotFoundError') { throw err } diff --git a/packages/mfs/test/cat.spec.ts b/packages/mfs/test/cat.spec.ts index b66530a38..6afca6a64 100644 --- a/packages/mfs/test/cat.spec.ts +++ b/packages/mfs/test/cat.spec.ts @@ -76,7 +76,7 @@ describe('cat', () => { await fs.mkdir(path) await expect(drain(fs.cat(path))).to.eventually.be.rejected - .with.property('code', 'ERR_NOT_A_FILE') + .with.property('name', 'NotAFileError') }) it('reads file from inside a sharded directory', async () => { diff --git a/packages/mfs/test/cp.spec.ts b/packages/mfs/test/cp.spec.ts index 71dc26104..c8e946196 100644 --- a/packages/mfs/test/cp.spec.ts +++ b/packages/mfs/test/cp.spec.ts @@ -51,12 +51,12 @@ describe('cp', () => { const source = CID.createV1(identity.code, hash) await expect(fs.cp(source, '/foo.txt')).to.eventually.be.rejected - .with.property('code', 'ERR_NOT_UNIXFS') + .with.property('name', 'NotUnixFSError') }) it('refuses to copy a non-existant file', async () => { await expect(fs.cp('/foo.txt', '/bar.txt')).to.eventually.be.rejected - .with.property('code', 'ERR_DOES_NOT_EXIST') + .with.property('name', 'DoesNotExistError') }) it('refuses to copy files to an existing file', async () => { @@ -64,7 +64,7 @@ describe('cp', () => { await fs.writeBytes(Uint8Array.from([0, 1, 3, 4]), path) await expect(fs.cp(path, path)).to.eventually.be.rejected - .with.property('code', 'ERR_ALREADY_EXISTS') + .with.property('name', 'AlreadyExistsError') // should succeed with force option await expect(fs.cp(path, path, { @@ -160,7 +160,7 @@ describe('cp', () => { } await expect(fs.cp(file.cid, `${shardedDirPath}/${file.name}`)).to.eventually.be.rejected - .with.property('code', 'ERR_ALREADY_EXISTS') + .with.property('name', 'AlreadyExistsError') // should succeed with force option await expect(fs.cp(file.cid, `${shardedDirPath}/${file.name}`, { diff --git a/packages/mfs/test/mkdir.spec.ts b/packages/mfs/test/mkdir.spec.ts index a837794dc..8335f2c98 100644 --- a/packages/mfs/test/mkdir.spec.ts +++ b/packages/mfs/test/mkdir.spec.ts @@ -65,7 +65,7 @@ describe('mkdir', () => { await fs.mkdir(dirPath) await expect(fs.mkdir(dirPath)).to.eventually.be.rejected() - .with.property('code', 'ERR_ALREADY_EXISTS') + .with.property('name', 'AlreadyExistsError') }) it('creates a nested directory with a different CID version to the parent', async () => { diff --git a/packages/mfs/test/rm.spec.ts b/packages/mfs/test/rm.spec.ts index d9f961c90..ee1ea8727 100644 --- a/packages/mfs/test/rm.spec.ts +++ b/packages/mfs/test/rm.spec.ts @@ -38,7 +38,7 @@ describe('rm', () => { await fs.rm(filePath) await expect(fs.stat(filePath)).to.eventually.be.rejected - .with.property('code', 'ERR_DOES_NOT_EXIST') + .with.property('name', 'DoesNotExistError') }) it('removes a directory', async () => { @@ -49,7 +49,7 @@ describe('rm', () => { await fs.rm(dirPath) await expect(fs.stat(dirPath)).to.eventually.be.rejected - .with.property('code', 'ERR_DOES_NOT_EXIST') + .with.property('name', 'DoesNotExistError') }) it('removes a sharded directory inside a normal directory', async () => { @@ -68,7 +68,7 @@ describe('rm', () => { await fs.rm(shardedDirPath) await expect(fs.stat(shardedDirPath)).to.eventually.be.rejected - .with.property('code', 'ERR_DOES_NOT_EXIST') + .with.property('name', 'DoesNotExistError') await expect(fs.stat(dirPath)).to.eventually.have.nested.property('unixfs.type', 'directory') }) @@ -89,7 +89,7 @@ describe('rm', () => { await fs.rm(shardedSubDirPath) await expect(fs.stat(shardedSubDirPath)).to.eventually.be.rejected - .with.property('code', 'ERR_DOES_NOT_EXIST') + .with.property('name', 'DoesNotExistError') const shardedDirStats = await fs.stat(shardedDirPath) expect(shardedDirStats.cid.toString()).to.equal(shardedDirCid.toString(), 'adding and removing a file from a sharded directory did not result in the original sharded CID') diff --git a/packages/routers/package.json b/packages/routers/package.json index 8f691383a..05b54aa9f 100644 --- a/packages/routers/package.json +++ b/packages/routers/package.json @@ -55,17 +55,16 @@ "dependencies": { "@helia/delegated-routing-v1-http-api-client": "^3.0.0", "@helia/interface": "^4.3.1", - "@libp2p/interface": "^1.1.4", + "@libp2p/interface": "^2.0.0", "@multiformats/uri-to-multiaddr": "^8.0.0", - "ipns": "^9.0.0", + "ipns": "^10.0.0", "it-first": "^3.0.4", "it-map": "^3.0.5", "multiformats": "^13.1.0", "uint8arrays": "^5.0.2" }, "devDependencies": { - "@libp2p/peer-id": "^4.0.7", - "@libp2p/peer-id-factory": "^4.0.7", + "@libp2p/peer-id": "^5.0.0", "aegir": "^44.0.1", "it-all": "^3.0.4", "it-drain": "^3.0.5", diff --git a/packages/routers/src/delegated-http-routing.ts b/packages/routers/src/delegated-http-routing.ts index f54882cf7..6a05a6a80 100644 --- a/packages/routers/src/delegated-http-routing.ts +++ b/packages/routers/src/delegated-http-routing.ts @@ -1,14 +1,15 @@ import { createDelegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client' -import { CodeError } from '@libp2p/interface' -import { marshal, unmarshal, peerIdFromRoutingKey } from 'ipns' +import { NotFoundError } from '@libp2p/interface' +import { marshalIPNSRecord, multihashFromIPNSRoutingKey, unmarshalIPNSRecord } from 'ipns' import first from 'it-first' import map from 'it-map' +import { CID } from 'multiformats/cid' import { equals as uint8ArrayEquals } from 'uint8arrays/equals' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' import type { DelegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client' import type { Provider, Routing, RoutingOptions } from '@helia/interface' import type { PeerId, PeerInfo } from '@libp2p/interface' -import type { CID, Version } from 'multiformats' +import type { Version } from 'multiformats' const IPNS_PREFIX = uint8ArrayFromString('/ipns/') @@ -42,28 +43,30 @@ class DelegatedHTTPRouter implements Routing { return } - const peerId = peerIdFromRoutingKey(key) - const record = unmarshal(value) + const digest = multihashFromIPNSRoutingKey(key) + const cid = CID.createV1(0x72, digest) + const record = unmarshalIPNSRecord(value) - await this.client.putIPNS(peerId, record, options) + await this.client.putIPNS(cid, record, options) } async get (key: Uint8Array, options?: RoutingOptions | undefined): Promise { if (!isIPNSKey(key)) { - throw new CodeError('Not found', 'ERR_NOT_FOUND') + throw new NotFoundError('Not found') } - const peerId = peerIdFromRoutingKey(key) + const digest = multihashFromIPNSRoutingKey(key) + const cid = CID.createV1(0x72, digest) try { - const record = await this.client.getIPNS(peerId, options) + const record = await this.client.getIPNS(cid, options) - return marshal(record) + return marshalIPNSRecord(record) } catch (err: any) { - // ERR_BAD_RESPONSE is thrown when the response had no body, which means + // BadResponseError is thrown when the response had no body, which means // the record couldn't be found - if (err.code === 'ERR_BAD_RESPONSE') { - throw new CodeError('Not found', 'ERR_NOT_FOUND') + if (err.name === 'BadResponseError') { + throw new NotFoundError('Not found') } throw err @@ -80,7 +83,7 @@ class DelegatedHTTPRouter implements Routing { } } - throw new CodeError('Not found', 'ERR_NOT_FOUND') + throw new NotFoundError('Not found') } async * getClosestPeers (key: Uint8Array, options?: RoutingOptions | undefined): AsyncIterable { diff --git a/packages/routers/src/http-gateway-routing.ts b/packages/routers/src/http-gateway-routing.ts index 88692a328..ae2e30da6 100644 --- a/packages/routers/src/http-gateway-routing.ts +++ b/packages/routers/src/http-gateway-routing.ts @@ -1,12 +1,11 @@ -import { peerIdSymbol } from '@libp2p/interface' +import { peerIdFromCID } from '@libp2p/peer-id' import { uriToMultiaddr } from '@multiformats/uri-to-multiaddr' import { CID } from 'multiformats/cid' import { identity } from 'multiformats/hashes/identity' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' -import { toString as uint8ArrayToString } from 'uint8arrays/to-string' import type { Provider, Routing, RoutingOptions } from '@helia/interface' -import type { PeerId, PeerInfo } from '@libp2p/interface' -import type { MultihashDigest, Version } from 'multiformats' +import type { PeerInfo } from '@libp2p/interface' +import type { Version } from 'multiformats' export const DEFAULT_TRUSTLESS_GATEWAYS = [ // 2023-10-03: IPNS, Origin, and Block/CAR support from https://ipfs-public-gateway-checker.on.fleek.co/ @@ -20,58 +19,14 @@ export interface HTTPGatwayRouterInit { gateways?: Array } -// these values are from https://github.com/multiformats/multicodec/blob/master/table.csv +// this value is from https://github.com/multiformats/multicodec/blob/master/table.csv const TRANSPORT_IPFS_GATEWAY_HTTP_CODE = 0x0920 -const inspect = Symbol.for('nodejs.util.inspect.custom') - -class URLPeerId implements PeerId { - readonly type = 'url' - readonly multihash: MultihashDigest - readonly privateKey?: Uint8Array - readonly publicKey?: Uint8Array - readonly url: string - - constructor (url: URL) { - this.url = url.toString() - this.multihash = identity.digest(uint8ArrayFromString(this.url)) - } - - [inspect] (): string { - return `PeerId(${this.url})` - } - - readonly [peerIdSymbol] = true - - toString (): string { - return this.toCID().toString() - } - - toCID (): CID { - return CID.createV1(TRANSPORT_IPFS_GATEWAY_HTTP_CODE, this.multihash) - } - - toBytes (): Uint8Array { - return this.toCID().bytes - } - - equals (other?: PeerId | Uint8Array | string): boolean { - if (other == null) { - return false - } - - if (other instanceof Uint8Array) { - other = uint8ArrayToString(other) - } - - return other.toString() === this.toString() - } -} function toPeerInfo (url: string | URL): PeerInfo { url = url.toString() return { - id: new URLPeerId(new URL(url)), + id: peerIdFromCID(CID.createV1(TRANSPORT_IPFS_GATEWAY_HTTP_CODE, identity.digest(uint8ArrayFromString(url)))), multiaddrs: [ uriToMultiaddr(url) ] diff --git a/packages/routers/test/delegated-http-routing.spec.ts b/packages/routers/test/delegated-http-routing.spec.ts index c8443777e..36159dee3 100644 --- a/packages/routers/test/delegated-http-routing.spec.ts +++ b/packages/routers/test/delegated-http-routing.spec.ts @@ -1,7 +1,7 @@ +import { generateKeyPair } from '@libp2p/crypto/keys' import { peerIdFromString } from '@libp2p/peer-id' -import { createEd25519PeerId } from '@libp2p/peer-id-factory' import { expect } from 'aegir/chai' -import { peerIdToRoutingKey, create, marshal } from 'ipns' +import { multihashToIPNSRoutingKey, createIPNSRecord, marshalIPNSRecord } from 'ipns' import drain from 'it-drain' import { CID } from 'multiformats' import { stubInterface } from 'sinon-ts' @@ -47,10 +47,10 @@ describe('delegated-http-routing', () => { }) it('should put a IPNS record value', async () => { - const peerId = await createEd25519PeerId() - const key = peerIdToRoutingKey(peerId) - const record = await create(peerId, '/hello world', 0, 100) - const value = marshal(record) + const privateKey = await generateKeyPair('Ed25519') + const key = multihashToIPNSRoutingKey(privateKey.publicKey.toMultihash()) + const record = await createIPNSRecord(privateKey, '/hello world', 0, 100) + const value = marshalIPNSRecord(record) const options = {} await router.put(key, value, options) @@ -69,9 +69,9 @@ describe('delegated-http-routing', () => { }) it('should get a IPNS record value', async () => { - const peerId = await createEd25519PeerId() - const key = peerIdToRoutingKey(peerId) - const record = await create(peerId, '/hello world', 0, 100) + const privateKey = await generateKeyPair('Ed25519') + const key = multihashToIPNSRoutingKey(privateKey.publicKey.toMultihash()) + const record = await createIPNSRecord(privateKey, '/hello world', 0, 100) const options = {} client.getIPNS.resolves(record) @@ -86,7 +86,7 @@ describe('delegated-http-routing', () => { const options = {} await expect(router.get(key, options)).to.eventually.be.rejected - .with.property('code', 'ERR_NOT_FOUND') + .with.property('name', 'NotFoundError') expect(client.getIPNS.called).to.be.false() }) diff --git a/packages/strings/package.json b/packages/strings/package.json index 9e08b27c3..05abfb323 100644 --- a/packages/strings/package.json +++ b/packages/strings/package.json @@ -142,7 +142,7 @@ }, "dependencies": { "@helia/interface": "^4.3.1", - "@libp2p/interface": "^1.1.4", + "@libp2p/interface": "^2.0.0", "interface-blockstore": "^5.2.10", "multiformats": "^13.1.0", "progress-events": "^1.0.0", @@ -150,7 +150,7 @@ }, "devDependencies": { "aegir": "^44.0.1", - "blockstore-core": "^4.4.0" + "blockstore-core": "^5.0.0" }, "sideEffects": false } diff --git a/packages/unixfs/package.json b/packages/unixfs/package.json index 7d7ccbf2a..5b8e62eb5 100644 --- a/packages/unixfs/package.json +++ b/packages/unixfs/package.json @@ -161,8 +161,8 @@ "dependencies": { "@helia/interface": "^4.3.1", "@ipld/dag-pb": "^4.1.0", - "@libp2p/interface": "^1.1.4", - "@libp2p/logger": "^4.0.7", + "@libp2p/interface": "^2.0.0", + "@libp2p/logger": "^5.0.0", "@multiformats/murmur3": "^2.1.8", "hamt-sharding": "^3.0.6", "interface-blockstore": "^5.2.10", @@ -181,7 +181,7 @@ }, "devDependencies": { "aegir": "^44.0.1", - "blockstore-core": "^4.4.0", + "blockstore-core": "^5.0.0", "delay": "^6.0.0", "iso-url": "^1.2.1", "it-drain": "^3.0.5", diff --git a/packages/unixfs/test/cat.spec.ts b/packages/unixfs/test/cat.spec.ts index bded215b4..bf6f7905c 100644 --- a/packages/unixfs/test/cat.spec.ts +++ b/packages/unixfs/test/cat.spec.ts @@ -65,7 +65,7 @@ describe('cat', () => { it('refuses to read a directory', async () => { await expect(drain(fs.cat(emptyDirCid))).to.eventually.be.rejected - .with.property('code', 'ERR_NOT_A_FILE') + .with.property('name', 'NotAFileError') }) it('refuses to read missing blocks', async () => { @@ -77,7 +77,7 @@ describe('cat', () => { await expect(drain(fs.cat(cid, { offline: true }))).to.eventually.be.rejected - .with.property('code', 'ERR_NOT_FOUND') + .with.property('name', 'NotFoundError') }) it('reads file from inside a sharded directory', async () => { diff --git a/packages/unixfs/test/chmod.spec.ts b/packages/unixfs/test/chmod.spec.ts index e0fdc6b42..16513a4e5 100644 --- a/packages/unixfs/test/chmod.spec.ts +++ b/packages/unixfs/test/chmod.spec.ts @@ -99,6 +99,6 @@ describe('chmod', () => { await expect(fs.chmod(cid, 0o777, { offline: true })).to.eventually.be.rejected - .with.property('code', 'ERR_NOT_FOUND') + .with.property('name', 'NotFoundError') }) }) diff --git a/packages/unixfs/test/cp.spec.ts b/packages/unixfs/test/cp.spec.ts index 53f183215..b932133cc 100644 --- a/packages/unixfs/test/cp.spec.ts +++ b/packages/unixfs/test/cp.spec.ts @@ -52,7 +52,7 @@ describe('cp', () => { const target = CID.createV1(identity.code, hash) await expect(fs.cp(source, target, 'foo')).to.eventually.be.rejected - .with.property('code', 'ERR_NOT_A_DIRECTORY') + .with.property('name', 'NotADirectoryError') }) it('refuses to copy files from an unreadable node', async () => { @@ -60,7 +60,7 @@ describe('cp', () => { const source = CID.createV1(identity.code, hash) await expect(fs.cp(source, emptyDirCid, 'foo')).to.eventually.be.rejected - .with.property('code', 'ERR_NOT_UNIXFS') + .with.property('name', 'NotUnixFSError') }) it('refuses to copy files to an existing file', async () => { @@ -69,7 +69,7 @@ describe('cp', () => { const target = await fs.cp(source, emptyDirCid, path) await expect(fs.cp(source, target, path)).to.eventually.be.rejected - .with.property('code', 'ERR_ALREADY_EXISTS') + .with.property('name', 'AlreadyExistsError') // should succeed with force option await expect(fs.cp(source, target, path, { @@ -159,7 +159,7 @@ describe('cp', () => { } await expect(fs.cp(file.cid, shardedDirCid, file.name)).to.eventually.be.rejected - .with.property('code', 'ERR_ALREADY_EXISTS') + .with.property('name', 'AlreadyExistsError') // should succeed with force option await expect(fs.cp(file.cid, shardedDirCid, file.name, { @@ -190,6 +190,6 @@ describe('cp', () => { await expect(fs.cp(cid, cid, 'file.txt', { offline: true })).to.eventually.be.rejected - .with.property('code', 'ERR_NOT_FOUND') + .with.property('name', 'NotFoundError') }) }) diff --git a/packages/unixfs/test/ls.spec.ts b/packages/unixfs/test/ls.spec.ts index 2d5b680f6..e6ca94329 100644 --- a/packages/unixfs/test/ls.spec.ts +++ b/packages/unixfs/test/ls.spec.ts @@ -130,6 +130,6 @@ describe('ls', () => { await expect(drain(fs.ls(cid, { offline: true }))).to.eventually.be.rejected - .with.property('code', 'ERR_NOT_FOUND') + .with.property('name', 'NotFoundError') }) }) diff --git a/packages/unixfs/test/mkdir.spec.ts b/packages/unixfs/test/mkdir.spec.ts index ce7e7dde5..a131d9f40 100644 --- a/packages/unixfs/test/mkdir.spec.ts +++ b/packages/unixfs/test/mkdir.spec.ts @@ -72,7 +72,7 @@ describe('mkdir', () => { const dirCid = await fs.mkdir(emptyDirCid, path) await expect(fs.mkdir(dirCid, path)).to.eventually.be.rejected() - .with.property('code', 'ERR_ALREADY_EXISTS') + .with.property('name', 'AlreadyExistsError') }) it('creates a nested directory with a different CID version to the parent', async () => { @@ -127,6 +127,6 @@ describe('mkdir', () => { await expect(fs.mkdir(cid, 'dir', { offline: true })).to.eventually.be.rejected - .with.property('code', 'ERR_NOT_FOUND') + .with.property('name', 'NotFoundError') }) }) diff --git a/packages/unixfs/test/rm.spec.ts b/packages/unixfs/test/rm.spec.ts index 380657d99..fad81c62d 100644 --- a/packages/unixfs/test/rm.spec.ts +++ b/packages/unixfs/test/rm.spec.ts @@ -38,7 +38,7 @@ describe('rm', () => { await expect(fs.stat(updatedDirCid, { path })).to.eventually.be.rejected - .with.property('code', 'ERR_NOT_FOUND') + .with.property('name', 'NotFoundError') }) it('removes a directory', async () => { @@ -49,7 +49,7 @@ describe('rm', () => { await expect(fs.stat(updatedDirCid, { path })).to.eventually.be.rejected - .with.property('code', 'ERR_NOT_FOUND') + .with.property('name', 'NotFoundError') }) it('removes a sharded directory inside a normal directory', async () => { @@ -67,7 +67,7 @@ describe('rm', () => { await expect(fs.stat(updatedContainingDirCid, { path: dirName })).to.eventually.be.rejected - .with.property('code', 'ERR_NOT_FOUND') + .with.property('name', 'NotFoundError') }) it('removes a sharded directory inside a sharded directory', async () => { @@ -86,7 +86,7 @@ describe('rm', () => { await expect(fs.stat(updatedContainingDirCid, { path: dirName })).to.eventually.be.rejected - .with.property('code', 'ERR_NOT_FOUND') + .with.property('name', 'NotFoundError') expect(updatedContainingDirCid.toString()).to.equal(shardedDirCid.toString(), 'adding and removing a file from a sharded directory did not result in the original sharded CID') }) @@ -227,6 +227,6 @@ describe('rm', () => { await expect(fs.rm(cid, 'dir', { offline: true })).to.eventually.be.rejected - .with.property('code', 'ERR_NOT_FOUND') + .with.property('name', 'NotFoundError') }) }) diff --git a/packages/unixfs/test/stat.spec.ts b/packages/unixfs/test/stat.spec.ts index 6b50d034a..7f1202597 100644 --- a/packages/unixfs/test/stat.spec.ts +++ b/packages/unixfs/test/stat.spec.ts @@ -207,6 +207,6 @@ describe('stat', function () { await expect(fs.stat(cid, { offline: true })).to.eventually.be.rejected - .with.property('code', 'ERR_NOT_FOUND') + .with.property('name', 'NotFoundError') }) }) diff --git a/packages/unixfs/test/touch.spec.ts b/packages/unixfs/test/touch.spec.ts index d42967276..ccf42dad3 100644 --- a/packages/unixfs/test/touch.spec.ts +++ b/packages/unixfs/test/touch.spec.ts @@ -156,6 +156,6 @@ describe('.files.touch', () => { await expect(fs.touch(cid, { offline: true })).to.eventually.be.rejected - .with.property('code', 'ERR_NOT_FOUND') + .with.property('name', 'NotFoundError') }) }) diff --git a/packages/utils/package.json b/packages/utils/package.json index 4fc34c713..0d25bccbb 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -57,18 +57,18 @@ "@ipld/dag-cbor": "^9.2.0", "@ipld/dag-json": "^10.2.0", "@ipld/dag-pb": "^4.1.0", - "@libp2p/crypto": "^4.0.6", - "@libp2p/interface": "^1.1.4", - "@libp2p/logger": "^4.0.7", - "@libp2p/utils": "^5.2.6", + "@libp2p/crypto": "^5.0.0", + "@libp2p/interface": "^2.0.0", + "@libp2p/logger": "^5.0.0", + "@libp2p/utils": "^6.0.0", "@multiformats/dns": "^1.0.1", "@types/murmurhash3js-revisited": "^3.0.3", "any-signal": "^4.1.1", - "blockstore-core": "^4.4.1", + "blockstore-core": "^5.0.0", "cborg": "^4.0.9", "interface-blockstore": "^5.2.10", "interface-datastore": "^8.2.11", - "interface-store": "^5.1.8", + "interface-store": "^6.0.0", "it-drain": "^3.0.5", "it-filter": "^3.0.4", "it-foreach": "^2.0.6", @@ -82,10 +82,9 @@ "uint8arrays": "^5.0.2" }, "devDependencies": { - "@libp2p/peer-id-factory": "^4.0.9", "@types/sinon": "^17.0.3", "aegir": "^44.0.1", - "datastore-core": "^9.2.9", + "datastore-core": "^10.0.0", "delay": "^6.0.0", "it-all": "^3.0.4", "race-signal": "^1.0.2", diff --git a/packages/utils/src/abstract-session.ts b/packages/utils/src/abstract-session.ts index 41718411b..889df563f 100644 --- a/packages/utils/src/abstract-session.ts +++ b/packages/utils/src/abstract-session.ts @@ -1,5 +1,5 @@ -import { DEFAULT_SESSION_MIN_PROVIDERS, DEFAULT_SESSION_MAX_PROVIDERS } from '@helia/interface' -import { CodeError, TypedEventEmitter, setMaxListeners } from '@libp2p/interface' +import { DEFAULT_SESSION_MIN_PROVIDERS, DEFAULT_SESSION_MAX_PROVIDERS, InsufficientProvidersError } from '@helia/interface' +import { TypedEventEmitter, setMaxListeners } from '@libp2p/interface' import { Queue } from '@libp2p/utils/queue' import { base64 } from 'multiformats/bases/base64' import pDefer from 'p-defer' @@ -249,7 +249,7 @@ export abstract class AbstractSession { diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts index 045348748..3b2f367f7 100644 --- a/packages/utils/src/index.ts +++ b/packages/utils/src/index.ts @@ -37,7 +37,7 @@ import type { DNS } from '@multiformats/dns' import type { Blockstore } from 'interface-blockstore' import type { Datastore } from 'interface-datastore' import type { CID } from 'multiformats/cid' -import type { MultihashHasher } from 'multiformats/hashes/interface' +import type { MultihashDigest, MultihashHasher } from 'multiformats/hashes/interface' export { AbstractSession, type AbstractCreateSessionOptions } from './abstract-session.js' export { BloomFilter } from './bloom-filter.js' @@ -267,3 +267,12 @@ export class Helia implements HeliaInterface { this.log('gc finished') } } + +/** + * Used to check that the passed multihash has the passed code + * + * Remove after https://github.com/multiformats/js-multiformats/pull/308 + */ +export function hasCode (digest: MultihashDigest, code: T): digest is MultihashDigest { + return digest.code === code +} diff --git a/packages/utils/src/pins.ts b/packages/utils/src/pins.ts index 72ff70932..76f01be9a 100644 --- a/packages/utils/src/pins.ts +++ b/packages/utils/src/pins.ts @@ -154,7 +154,7 @@ export class PinsImpl implements Pins { try { pinnedBlock = cborg.decode(await this.datastore.get(blockKey, options)) } catch (err: any) { - if (err.code !== 'ERR_NOT_FOUND') { + if (err.name !== 'NotFoundError') { throw err } } diff --git a/packages/utils/src/routing.ts b/packages/utils/src/routing.ts index 0d2761310..11db18f62 100644 --- a/packages/utils/src/routing.ts +++ b/packages/utils/src/routing.ts @@ -1,4 +1,5 @@ -import { CodeError, start, stop } from '@libp2p/interface' +import { NoRoutersAvailableError } from '@helia/interface' +import { NotFoundError, start, stop } from '@libp2p/interface' import { PeerQueue } from '@libp2p/utils/peer-queue' import merge from 'it-merge' import type { Routing as RoutingInterface, Provider, RoutingOptions } from '@helia/interface' @@ -41,7 +42,7 @@ export class Routing implements RoutingInterface, Startable { */ async * findProviders (key: CID, options: RoutingOptions = {}): AsyncIterable { if (this.routers.length === 0) { - throw new CodeError('No content routers available', 'ERR_NO_ROUTERS_AVAILABLE') + throw new NoRoutersAvailableError('No content routers available') } // provider multiaddrs are only cached for a limited time, so they can come @@ -103,7 +104,7 @@ export class Routing implements RoutingInterface, Startable { */ async provide (key: CID, options: AbortOptions = {}): Promise { if (this.routers.length === 0) { - throw new CodeError('No content routers available', 'ERR_NO_ROUTERS_AVAILABLE') + throw new NoRoutersAvailableError('No content routers available') } await Promise.all( @@ -144,7 +145,7 @@ export class Routing implements RoutingInterface, Startable { */ async findPeer (id: PeerId, options?: RoutingOptions): Promise { if (this.routers.length === 0) { - throw new CodeError('No peer routers available', 'ERR_NO_ROUTERS_AVAILABLE') + throw new NoRoutersAvailableError('No peer routers available') } const self = this @@ -167,7 +168,7 @@ export class Routing implements RoutingInterface, Startable { return peer } - throw new CodeError('Could not find peer in routing', 'ERR_NOT_FOUND') + throw new NotFoundError('Could not find peer in routing') } /** @@ -175,7 +176,7 @@ export class Routing implements RoutingInterface, Startable { */ async * getClosestPeers (key: Uint8Array, options: RoutingOptions = {}): AsyncIterable { if (this.routers.length === 0) { - throw new CodeError('No peer routers available', 'ERR_NO_ROUTERS_AVAILABLE') + throw new NoRoutersAvailableError('No peer routers available') } for await (const peer of merge( diff --git a/packages/utils/src/utils/networked-storage.ts b/packages/utils/src/utils/networked-storage.ts index e31461c81..465b6bd54 100644 --- a/packages/utils/src/utils/networked-storage.ts +++ b/packages/utils/src/utils/networked-storage.ts @@ -1,4 +1,4 @@ -import { CodeError, setMaxListeners, start, stop } from '@libp2p/interface' +import { InvalidMultihashError, InvalidParametersError, setMaxListeners, start, stop } from '@libp2p/interface' import { anySignal } from 'any-signal' import { IdentityBlockstore } from 'blockstore-core/identity' import filter from 'it-filter' @@ -390,7 +390,7 @@ function isRetrievingBlockBroker (broker: BlockBroker): broker is Required['validateFn'] => { if (hasher == null) { - throw new CodeError(`No hasher configured for multihash code 0x${cid.multihash.code.toString(16)}, please configure one. You can look up which hash this is at https://github.com/multiformats/multicodec/blob/master/table.csv`, 'ERR_UNKNOWN_HASH_ALG') + throw new InvalidParametersError(`No hasher configured for multihash code 0x${cid.multihash.code.toString(16)}, please configure one. You can look up which hash this is at https://github.com/multiformats/multicodec/blob/master/table.csv`) } return async (block: Uint8Array): Promise => { @@ -399,7 +399,7 @@ export const getCidBlockVerifierFunction = (cid: CID, hasher: MultihashHasher): if (!uint8ArrayEquals(hash.digest, cid.multihash.digest)) { // if a hash mismatch occurs for a TrustlessGatewayBlockBroker, we should try another gateway - throw new CodeError('Hash of downloaded block did not match multihash from passed CID', 'ERR_HASH_MISMATCH') + throw new InvalidMultihashError('Hash of downloaded block did not match multihash from passed CID') } } } diff --git a/packages/utils/test/abstract-session.spec.ts b/packages/utils/test/abstract-session.spec.ts index 025ca29ac..cd430e668 100644 --- a/packages/utils/test/abstract-session.spec.ts +++ b/packages/utils/test/abstract-session.spec.ts @@ -1,5 +1,6 @@ +import { generateKeyPair } from '@libp2p/crypto/keys' import { defaultLogger } from '@libp2p/logger' -import { createEd25519PeerId } from '@libp2p/peer-id-factory' +import { peerIdFromPrivateKey } from '@libp2p/peer-id' import { expect } from 'aegir/chai' import delay from 'delay' import { CID } from 'multiformats/cid' @@ -43,7 +44,7 @@ describe('abstract-session', () => { session.findNewProviders.callsFake(async function * () { yield { - id: await createEd25519PeerId() + id: peerIdFromPrivateKey(await generateKeyPair('Ed25519')) } }) session.queryProvider.withArgs(cid).resolves(block) @@ -58,9 +59,9 @@ describe('abstract-session', () => { const block = Uint8Array.from([0, 1, 2, 3]) const providers: SessionPeer[] = [{ - id: await createEd25519PeerId() + id: peerIdFromPrivateKey(await generateKeyPair('Ed25519')) }, { - id: await createEd25519PeerId() + id: peerIdFromPrivateKey(await generateKeyPair('Ed25519')) }] session.findNewProviders.callsFake(async function * () { @@ -92,9 +93,9 @@ describe('abstract-session', () => { const block = Uint8Array.from([0, 1, 2, 3]) const providers: SessionPeer[] = [{ - id: await createEd25519PeerId() + id: peerIdFromPrivateKey(await generateKeyPair('Ed25519')) }, { - id: await createEd25519PeerId() + id: peerIdFromPrivateKey(await generateKeyPair('Ed25519')) }] session.findNewProviders.callsFake(async function * () { @@ -119,7 +120,7 @@ describe('abstract-session', () => { session.findNewProviders.callsFake(async function * () { yield { - id: await createEd25519PeerId() + id: peerIdFromPrivateKey(await generateKeyPair('Ed25519')) } }) session.queryProvider.callsFake(async () => { @@ -156,7 +157,7 @@ describe('abstract-session', () => { await delay(100) return { - id: await createEd25519PeerId() + id: peerIdFromPrivateKey(await generateKeyPair('Ed25519')) } })(), options.signal) }) @@ -164,7 +165,7 @@ describe('abstract-session', () => { await expect(session.retrieve(cid, { signal })).to.eventually.be.rejected - .with.property('code', 'ABORT_ERR') + .with.property('name', 'AbortError') }) it('should search for more session providers if the current ones cannot provide the block', async () => { @@ -174,9 +175,9 @@ describe('abstract-session', () => { const block = Uint8Array.from([0, 1, 2, 3]) const providers: SessionPeer[] = [{ - id: await createEd25519PeerId() + id: peerIdFromPrivateKey(await generateKeyPair('Ed25519')) }, { - id: await createEd25519PeerId() + id: peerIdFromPrivateKey(await generateKeyPair('Ed25519')) }] session.findNewProviders.onFirstCall().callsFake(async function * () { @@ -204,9 +205,9 @@ describe('abstract-session', () => { const block = Uint8Array.from([0, 1, 2, 3]) const providers: SessionPeer[] = [{ - id: await createEd25519PeerId() + id: peerIdFromPrivateKey(await generateKeyPair('Ed25519')) }, { - id: await createEd25519PeerId() + id: peerIdFromPrivateKey(await generateKeyPair('Ed25519')) }] session.findNewProviders.onFirstCall().callsFake(async function * () { @@ -217,7 +218,7 @@ describe('abstract-session', () => { await delay(100) return { - id: await createEd25519PeerId() + id: peerIdFromPrivateKey(await generateKeyPair('Ed25519')) } })(), options.signal) }) @@ -231,13 +232,13 @@ describe('abstract-session', () => { await expect(session.retrieve(cid, { signal })).to.eventually.be.rejected() - .with.property('code', 'ABORT_ERR') + .with.property('name', 'AbortError') }) it('should not make multiple requests to the only found provider', async function () { const session = new Session() const cid = CID.parse('bafybeifaymukvfkyw6xgh4th7tsctiifr4ea2btoznf46y6b2fnvikdczi') - const id = await createEd25519PeerId() // same provider + const id = peerIdFromPrivateKey(await generateKeyPair('Ed25519')) // same provider session.findNewProviders.callsFake(async function * () { yield { diff --git a/packages/utils/test/block-broker.spec.ts b/packages/utils/test/block-broker.spec.ts index 140b7a51a..6f75aa301 100644 --- a/packages/utils/test/block-broker.spec.ts +++ b/packages/utils/test/block-broker.spec.ts @@ -142,7 +142,7 @@ describe('block-broker', () => { const error = err as AggregateError & { errors: Error & { code: string } } expect(error).to.be.an('error') expect(error.errors).to.be.an('array').with.lengthOf(1) - expect(error.errors[0]).to.be.an('error').with.property('code', 'ERR_HASH_MISMATCH') + expect(error.errors[0]).to.be.an('error').with.property('name', 'InvalidMultihashError') } }) }) diff --git a/packages/utils/test/utils/networked-storage.spec.ts b/packages/utils/test/utils/networked-storage.spec.ts index f3103d7c3..00ef07938 100644 --- a/packages/utils/test/utils/networked-storage.spec.ts +++ b/packages/utils/test/utils/networked-storage.spec.ts @@ -60,7 +60,7 @@ describe('networked-storage', () => { await expect(storage.get(cid, { offline: true - })).to.eventually.be.rejected.with.property('code', 'ERR_NOT_FOUND') + })).to.eventually.be.rejected.with.property('name', 'NotFoundError') }) it('gets a block from the blockstore with progress', async () => { @@ -98,7 +98,7 @@ describe('networked-storage', () => { await expect(drain(storage.getMany([cid], { offline: true - }))).to.eventually.be.rejected.with.property('code', 'ERR_NOT_FOUND') + }))).to.eventually.be.rejected.with.property('name', 'NotFoundError') }) it('puts a block into the blockstore', async () => { diff --git a/patches/@helia+delegated-routing-v1-http-api-client+3.0.2.patch b/patches/@helia+delegated-routing-v1-http-api-client+3.0.2.patch new file mode 100644 index 000000000..3eabc9ec3 --- /dev/null +++ b/patches/@helia+delegated-routing-v1-http-api-client+3.0.2.patch @@ -0,0 +1,1218 @@ +diff --git a/node_modules/@helia/delegated-routing-v1-http-api-client/dist/index.min.js b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/index.min.js +index 01e6259..505fab4 100644 +--- a/node_modules/@helia/delegated-routing-v1-http-api-client/dist/index.min.js ++++ b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/index.min.js +@@ -1,11 +1,10 @@ + (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.HeliaDelegatedRoutingV1HttpApiClient = factory()}(typeof self !== 'undefined' ? self : this, function () { +-"use strict";var HeliaDelegatedRoutingV1HttpApiClient=(()=>{var th=Object.create;var qn=Object.defineProperty;var rh=Object.getOwnPropertyDescriptor;var nh=Object.getOwnPropertyNames;var oh=Object.getPrototypeOf,ih=Object.prototype.hasOwnProperty;var zn=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),me=(r,e)=>{for(var t in e)qn(r,t,{get:e[t],enumerable:!0})},Ma=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of nh(e))!ih.call(r,o)&&o!==t&&qn(r,o,{get:()=>e[o],enumerable:!(n=rh(e,o))||n.enumerable});return r};var rr=(r,e,t)=>(t=r!=null?th(oh(r)):{},Ma(e||!r||!r.__esModule?qn(t,"default",{value:r,enumerable:!0}):t,r)),sh=r=>Ma(qn({},"__esModule",{value:!0}),r);var fu=zn($r=>{"use strict";var gp="[object ArrayBuffer]",At=class r{static isArrayBuffer(e){return Object.prototype.toString.call(e)===gp}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,t){if(e.constructor===t)return e;if(this.isArrayBuffer(e))return new t(e);if(this.isArrayBufferView(e))return new t(e.buffer,e.byteOffset,e.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}static isArrayBufferView(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}static isEqual(e,t){let n=r.toUint8Array(e),o=r.toUint8Array(t);if(n.length!==o.byteLength)return!1;for(let i=0;io.byteLength).reduce((o,i)=>o+i),t=new Uint8Array(e),n=0;return r.map(o=>new Uint8Array(o)).forEach(o=>{for(let i of o)t[n++]=i}),t.buffer}function vp(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;let t=new Uint8Array(r),n=new Uint8Array(e);for(let o=0;o{"use strict";function yl(r,e){for(let t in e)Object.defineProperty(r,t,{value:e[t],enumerable:!0,configurable:!0});return r}function rm(r,e,t){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");t||(t={}),typeof e=="object"&&(t=e,e=""),e&&(t.code=e);try{return yl(r,t)}catch{t.message=r.message,t.stack=r.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(r)),yl(new o,t)}}wl.exports=rm});var ya=zn((_1,ga)=>{var N1=function(){typeof ga<"u"&&(ga.exports=m);var r=86400,e=3200,t=146097*e/400,n=r*t,o=1e3*n,i=864e13,s=4294967296,a=1e6,c="000000000",f=Math.trunc||function(b){var v=b-b%1;return v==0&&(b<0||b===0&&1/b!=1/0)?-0:v},u=m.prototype,l=(m.fromDate=function(b){return new m(+b)},m.fromInt64BE=k(0,1,2,3,0,4),m.fromInt64LE=k(3,2,1,0,4,0),m.fromString=function(_){var v,F=new m,_=(_+="").replace(/^\s*[+\-]?\d+/,function($){var $=+$,S=1970+($-1970)%400;return F.year=$-S,S}).replace(/(?:Z|([+\-]\d{2}):?(\d{2}))$/,function(C,$,S){return $<0&&(S*=-1),v=6e4*(60*+$+ +S),""}).replace(/\.\d+$/,function(C){return F.nano=+(C+c).substr(1,9),""}).split(/\D+/);if(1<_.length?_[1]--:_[1]=0,F.time=v=Date.UTC.apply(Date,_)-(v||0),isNaN(v))throw new TypeError("Invalid Date");return d(F)},m.fromTimeT=function(b){return R(b,0)},u.year=0,u.time=0,u.nano=0,u.addNano=function(b){return this.nano+=+b||0,this},u.getNano=function(){var b=d(this);return(b.time%1e3*a+ +b.nano+1e9)%1e9},u.getTimeT=function(){var v=d(this),b=Math.floor(v.time/1e3),v=v.year;return v&&(b+=v*t*r/e),b},u.getYear=function(){return this.toDate().getUTCFullYear()+this.year},u.toDate=function(){return E(d(this).time)},u.toJSON=function(){return this.toString().replace(/0{1,6}Z$/,"Z")},u.toString=function(b){var v=this,F=v.toDate(),_={H:function(){return V(F.getUTCHours())},L:function(){return N(F.getUTCMilliseconds(),3)},M:function(){return V(F.getUTCMinutes())},N:function(){return N(v.getNano(),9)},S:function(){return V(F.getUTCSeconds())},Y:function(){var C=v.getYear();return 999999>24&255,I[g+v]=p>>16&255,I[g+F]=p>>8&255,I[g+_]=255&p}}function k(b,v,F,_,C,$){return function(I,g){D(I,g|=0);var p=S(I,g+C);return R(S(I,g+$),p)};function S(I,g){return 16777216*I[g+b]+(I[g+v]<<16|I[g+F]<<8|I[g+_])}}function D(b,v){if(b=b&&b.length,b==null)throw new TypeError("Invalid Buffer");if(b{"use strict";var Hm=Object.prototype.hasOwnProperty,_e="~";function Mn(){}Object.create&&(Mn.prototype=Object.create(null),new Mn().__proto__||(_e=!1));function Km(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function Df(r,e,t,n,o){if(typeof t!="function")throw new TypeError("The listener must be a function");var i=new Km(t,n||r,o),s=_e?_e+e:e;return r._events[s]?r._events[s].fn?r._events[s]=[r._events[s],i]:r._events[s].push(i):(r._events[s]=i,r._eventsCount++),r}function Si(r,e){--r._eventsCount===0?r._events=new Mn:delete r._events[e]}function Re(){this._events=new Mn,this._eventsCount=0}Re.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)Hm.call(t,n)&&e.push(_e?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};Re.prototype.listeners=function(e){var t=_e?_e+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,i=n.length,s=new Array(i);oYm});var Ha=Symbol.for("@libp2p/content-routing");var Gn=Symbol.for("@libp2p/peer-id");function Ka(r){return r!=null&&!!r[Gn]}var $a=Symbol.for("@libp2p/peer-routing");var P=class extends Error{code;props;constructor(e,t,n){super(e),this.code=t,this.name=n?.name??"CodeError",this.props=n??{}}};var gr=(r,...e)=>{try{[...e]}catch{}};var Li={};me(Li,{base32:()=>We,base32hex:()=>ph,base32hexpad:()=>gh,base32hexpadupper:()=>yh,base32hexupper:()=>mh,base32pad:()=>hh,base32padupper:()=>dh,base32upper:()=>Wa,base32z:()=>wh});var rg=new Uint8Array(0);function qa(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n>>0,k=new Uint8Array(y);E!==R;){for(var D=B[E],V=0,N=y-1;(D!==0||V>>0,k[N]=D%a>>>0,D=D/a>>>0;if(D!==0)throw new Error("Non-zero carry");d=V,E++}for(var b=y-d;b!==y&&k[b]===0;)b++;for(var v=c.repeat(m);b>>0,y=new Uint8Array(R);B[m];){var k=t[B.charCodeAt(m)];if(k===255)return;for(var D=0,V=R-1;(k!==0||D>>0,y[V]=k%256>>>0,k=k/256>>>0;if(k!==0)throw new Error("Non-zero carry");E=D,m++}if(B[m]!==" "){for(var N=R-E;N!==R&&y[N]===0;)N++;for(var b=new Uint8Array(d+(R-N)),v=d;N!==R;)b[v++]=y[N++];return b}}}function w(B){var m=h(B);if(m)return m;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:h,decode:w}}var ch=ah,uh=ch,Ya=uh;var Ci=class{name;prefix;baseEncode;constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Ni=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Za(this,e)}},_i=class{decoders;constructor(e){this.decoders=e}or(e){return Za(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Za(r,e){return new _i({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var Ui=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new Ci(e,t,n),this.decoder=new Ni(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function yr({name:r,prefix:e,encode:t,decode:n}){return new Ui(r,e,t,n)}function Lt({name:r,prefix:e,alphabet:t}){let{encode:n,decode:o}=Ya(t,r);return yr({prefix:e,name:r,encode:n,decode:i=>yt(o(i))})}function lh(r,e,t,n){let o={};for(let u=0;u=8&&(a-=8,s[f++]=255&c>>a)}if(a>=t||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s}function fh(r,e,t){let n=e[e.length-1]==="=",o=(1<t;)s-=t,i+=e[o&a>>s];if(s!==0&&(i+=e[o&a<ae,base58flickr:()=>bh});var ae=Lt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),bh=Lt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Oi={};me(Oi,{base64:()=>rn,base64pad:()=>xh,base64url:()=>Eh,base64urlpad:()=>vh});var rn=ie({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),xh=ie({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Eh=ie({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),vh=ie({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function Bh(r,e){try{if(typeof r=="string"&&r.length>0)return Ah(r);if(typeof r=="number"&&isFinite(r))return e?.long?Ih(r):Sh(r);throw new Error("Value is not a string or number.")}catch(t){let n=Rh(t)?`${t.message}. value=${JSON.stringify(r)}`:"An unknown error has occured.";throw new Error(n)}}function Ah(r){if(r=String(r),r.length>100)throw new Error("Value exceeds the maximum length of 100 characters.");let e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(r);if(!e)return NaN;let t=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return t*315576e5;case"weeks":case"week":case"w":return t*6048e5;case"days":case"day":case"d":return t*864e5;case"hours":case"hour":case"hrs":case"hr":case"h":return t*36e5;case"minutes":case"minute":case"mins":case"min":case"m":return t*6e4;case"seconds":case"second":case"secs":case"sec":case"s":return t*1e3;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:throw new Error(`The unit ${n} was matched, but no matching case exists.`)}}var Yn=Bh;function Sh(r){let e=Math.abs(r);return e>=864e5?`${Math.round(r/864e5)}d`:e>=36e5?`${Math.round(r/36e5)}h`:e>=6e4?`${Math.round(r/6e4)}m`:e>=1e3?`${Math.round(r/1e3)}s`:`${r}ms`}function Ih(r){let e=Math.abs(r);return e>=864e5?jn(r,e,864e5,"day"):e>=36e5?jn(r,e,36e5,"hour"):e>=6e4?jn(r,e,6e4,"minute"):e>=1e3?jn(r,e,1e3,"second"):`${r} ms`}function jn(r,e,t,n){let o=e>=t*1.5;return`${Math.round(r/t)} ${n}${o?"s":""}`}function Rh(r){return typeof r=="object"&&r!==null&&"message"in r}function Di(r){t.debug=t,t.default=t,t.coerce=c,t.disable=i,t.enable=o,t.enabled=s,t.humanize=Yn,t.destroy=f,Object.keys(r).forEach(u=>{t[u]=r[u]}),t.names=[],t.skips=[],t.formatters={};function e(u){let l=0;for(let h=0;h{if(V==="%%")return"%";k++;let b=t.formatters[N];if(typeof b=="function"){let v=d[k];V=b.call(E,v),d.splice(k,1),k--}return V}),t.formatArgs.call(E,d),(E.log||t.log).apply(E,d)}return m.namespace=u,m.useColors=t.useColors(),m.color=t.selectColor(u),m.extend=n,m.destroy=t.destroy,Object.defineProperty(m,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:(w!==t.namespaces&&(w=t.namespaces,B=t.enabled(u)),B),set:d=>{h=d}}),typeof t.init=="function"&&t.init(m),m}function n(u,l){let h=t(this.namespace+(typeof l>"u"?":":l)+u);return h.log=this.log,h}function o(u){t.save(u),t.namespaces=u,t.names=[],t.skips=[];let l,h=(typeof u=="string"?u:"").split(/[\s,]+/),w=h.length;for(l=0;l"-"+l)].join(",");return t.enable(""),u}function s(u){if(u[u.length-1]==="*")return!0;let l,h;for(l=0,h=t.skips.length;l=31||typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/applewebkit\/(\d+)/)}function Ch(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+Yn(this.diff),!this.useColors)return;let e="color: "+this.color;r.splice(1,0,e,"color: inherit");let t=0,n=0;r[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(t++,o==="%c"&&(n=t))}),r.splice(n,0,e)}var Nh=console.debug??console.log??(()=>{});function _h(r){try{r?Zn?.setItem("debug",r):Zn?.removeItem("debug")}catch{}}function Uh(){let r;try{r=Zn?.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function Lh(){try{return localStorage}catch{}}function Vh(r){r.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}}var Ja=Di({formatArgs:Ch,save:_h,load:Uh,useColors:Th,setupFormatters:Vh,colors:kh,storage:Zn,log:Nh});var Fe=Ja;Fe.formatters.b=r=>r==null?"undefined":ae.baseEncode(r);Fe.formatters.t=r=>r==null?"undefined":We.baseEncode(r);Fe.formatters.m=r=>r==null?"undefined":rn.baseEncode(r);Fe.formatters.p=r=>r==null?"undefined":r.toString();Fe.formatters.c=r=>r==null?"undefined":r.toString();Fe.formatters.k=r=>r==null?"undefined":r.toString();Fe.formatters.a=r=>r==null?"undefined":r.toString();function Oh(r){let e=()=>{};return e.enabled=!1,e.color="",e.diff=0,e.log=()=>{},e.namespace=r,e.destroy=()=>!0,e.extend=()=>e,e}function Vt(r){let e=Oh(`${r}:trace`);return Fe.enabled(`${r}:trace`)&&Fe.names.map(t=>t.toString()).find(t=>t.includes(":trace"))!=null&&(e=Fe(`${r}:trace`)),Object.assign(Fe(r),{error:Fe(`${r}:error`),trace:e})}var Pi={};me(Pi,{base10:()=>Dh});var Dh=Lt({prefix:"9",name:"base10",alphabet:"0123456789"});var Fi={};me(Fi,{base16:()=>Ph,base16upper:()=>Fh});var Ph=ie({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Fh=ie({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Mi={};me(Mi,{base2:()=>Mh});var Mh=ie({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Hi={};me(Hi,{base256emoji:()=>zh});var Xa=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),Hh=Xa.reduce((r,e,t)=>(r[t]=e,r),[]),Kh=Xa.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function $h(r){return r.reduce((e,t)=>(e+=Hh[t],e),"")}function qh(r){let e=[];for(let t of r){let n=Kh[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var zh=yr({prefix:"\u{1F680}",name:"base256emoji",encode:$h,decode:qh});var Ki={};me(Ki,{base36:()=>Wn,base36upper:()=>Gh});var Wn=Lt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Gh=Lt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var $i={};me($i,{base8:()=>jh});var jh=ie({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var qi={};me(qi,{identity:()=>Yh});var Yh=yr({prefix:"\0",name:"identity",encode:r=>Ga(r),decode:r=>za(r)});var Ng=new TextEncoder,_g=new TextDecoder;var Gi={};me(Gi,{identity:()=>Je});var Jh=tc,Qa=128,Xh=127,Qh=~Xh,ed=Math.pow(2,31);function tc(r,e,t){e=e||[],t=t||0;for(var n=t;r>=ed;)e[t++]=r&255|Qa,r/=128;for(;r&Qh;)e[t++]=r&255|Qa,r>>>=7;return e[t]=r|0,tc.bytes=t-n+1,e}var td=zi,rd=128,ec=127;function zi(r,n){var t=0,n=n||0,o=0,i=n,s,a=r.length;do{if(i>=a)throw zi.bytes=0,new RangeError("Could not decode varint");s=r[i++],t+=o<28?(s&ec)<=rd);return zi.bytes=i-n,t}var nd=Math.pow(2,7),od=Math.pow(2,14),id=Math.pow(2,21),sd=Math.pow(2,28),ad=Math.pow(2,35),cd=Math.pow(2,42),ud=Math.pow(2,49),ld=Math.pow(2,56),fd=Math.pow(2,63),hd=function(r){return rxe,sha512:()=>yd});function Yi({name:r,code:e,encode:t}){return new ji(r,e,t)}var ji=class{name;code;encode;constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?ut(this.code,t):t.then(n=>ut(this.code,n))}else throw Error("Unknown type, must be binary type")}};function sc(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var xe=Yi({name:"sha2-256",code:18,encode:sc("SHA-256")}),yd=Yi({name:"sha2-512",code:19,encode:sc("SHA-512")});function ac(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return bd(t,Wi(r),e??ae.encoder);default:return xd(t,Wi(r),e??We.encoder)}}var cc=new WeakMap;function Wi(r){let e=cc.get(r);if(e==null){let t=new Map;return cc.set(r,t),t}return e}var Be=class r{code;version;multihash;bytes;"/";constructor(e,t,n,o){this.code=t,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:t}=this;if(e!==sn)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Ed)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,n=ut(e,t);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return r.equals(this,e)}static equals(e,t){let n=t;return n!=null&&e.code===n.code&&e.version===n.version&&rc(e.multihash,n.multihash)}toString(e){return ac(this,e)}toJSON(){return{"/":ac(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof r)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:i,bytes:s}=t;return new r(n,o,i,s??uc(n,o,i.bytes))}else if(t[vd]===!0){let{version:n,multihash:o,code:i}=t,s=Ot(o);return r.create(n,i,s)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==sn)throw new Error(`Version 0 CID must use dag-pb (code: ${sn}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=uc(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,sn,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,o=yt(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let i=o.subarray(t.multihashSize-t.digestSize),s=new xr(t.multihashCode,t.digestSize,i,o);return[t.version===0?r.createV0(s):r.createV1(t.codec,s),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[l,h]=on(e.subarray(t));return t+=h,l},o=n(),i=sn;if(o===18?(o=0,t=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=t,a=n(),c=n(),f=t+c,u=f-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:u,size:f}}static parse(e,t){let[n,o]=wd(e,t),i=r.decode(o);if(i.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Wi(i).set(n,e),i}};function wd(r,e){switch(r[0]){case"Q":{let t=e??ae;return[ae.prefix,t.decode(`${ae.prefix}${r}`)]}case ae.prefix:{let t=e??ae;return[ae.prefix,t.decode(r)]}case We.prefix:{let t=e??We;return[We.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}function bd(r,e,t){let{prefix:n}=t;if(n!==ae.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let i=t.encode(r).slice(1);return e.set(n,i),i}else return o}function xd(r,e,t){let{prefix:n}=t,o=e.get(n);if(o==null){let i=t.encode(r);return e.set(n,i),i}else return o}var sn=112,Ed=18;function uc(r,e,t){let n=br(r),o=n+br(e),i=new Uint8Array(o+t.byteLength);return wr(r,i,0),wr(e,i,n),i.set(t,o),i}var vd=Symbol.for("@ipld/js-cid/CID");var Pt={...qi,...Mi,...$i,...Pi,...Fi,...Li,...Ki,...Vi,...Oi,...Hi},Qg={...Zi,...Gi};function ue(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Ji=fc("ascii","a",r=>{let e="a";for(let t=0;t{r=r.substring(1);let e=Xe(r.length);for(let t=0;tr.decoder).reduce((r,e)=>r.or(e),Pt.identity.decoder),pc=114,es=36,ts=37,an=class{type;multihash;privateKey;publicKey;string;constructor(e){this.type=e.type,this.multihash=e.multihash,this.privateKey=e.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[Gn]=!0;toString(){return this.string==null&&(this.string=ae.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return Be.createV1(pc,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return ue(this.multihash.bytes,e);if(typeof e=="string")return rs(e).equals(this);if(e?.multihash?.bytes!=null)return ue(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[dc](){return`PeerId(${this.toString()})`}},Er=class extends an{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},vr=class extends an{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}},Br=class extends an{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}},Xi=2336,Qi=class{type="url";multihash;privateKey;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=Je.digest(Y(this.url))}[dc](){return`PeerId(${this.url})`}[Gn]=!0;toString(){return this.toCID().toString()}toCID(){return Be.createV1(Xi,this.multihash)}toBytes(){return this.toCID().bytes}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=z(e)),e.toString()===this.toString())}};function rs(r,e){if(e=e??hc,r.charAt(0)==="1"||r.charAt(0)==="Q"){let t=Ot(ae.decode(`z${r}`));return r.startsWith("12D")?new vr({multihash:t}):r.startsWith("16U")?new Br({multihash:t}):new Er({multihash:t})}return cn(hc.decode(r))}function cn(r){try{let e=Ot(r);if(e.code===Je.code){if(e.digest.length===es)return new vr({multihash:e});if(e.digest.length===ts)return new Br({multihash:e})}if(e.code===xe.code)return new Er({multihash:e})}catch{return Ad(Be.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function Ad(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==pc&&r.code!==Xi)throw new Error("Supplied PeerID CID is invalid");if(r.code===Xi){let t=z(r.multihash.digest);return new Qi(new URL(t))}let e=r.multihash;if(e.code===xe.code)return new Er({multihash:r.multihash});if(e.code===Je.code){if(e.digest.length===es)return new vr({multihash:r.multihash});if(e.digest.length===ts)return new Br({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}async function mc(r,e){return r.length===es?new vr({multihash:ut(Je.code,r),privateKey:e}):r.length===ts?new Br({multihash:ut(Je.code,r),privateKey:e}):new Er({multihash:await xe.digest(r),publicKey:r,privateKey:e})}var Sd=Math.pow(2,7),Id=Math.pow(2,14),Rd=Math.pow(2,21),ns=Math.pow(2,28),os=Math.pow(2,35),is=Math.pow(2,42),ss=Math.pow(2,49),X=128,Ae=127;function Ve(r){if(rNumber.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function as(r,e,t=0){switch(Ve(r)){case 8:e[t++]=r&255|X,r/=128;case 7:e[t++]=r&255|X,r/=128;case 6:e[t++]=r&255|X,r/=128;case 5:e[t++]=r&255|X,r/=128;case 4:e[t++]=r&255|X,r>>>=7;case 3:e[t++]=r&255|X,r>>>=7;case 2:e[t++]=r&255|X,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function kd(r,e,t=0){switch(Ve(r)){case 8:e.set(t++,r&255|X),r/=128;case 7:e.set(t++,r&255|X),r/=128;case 6:e.set(t++,r&255|X),r/=128;case 5:e.set(t++,r&255|X),r/=128;case 4:e.set(t++,r&255|X),r>>>=7;case 3:e.set(t++,r&255|X),r>>>=7;case 2:e.set(t++,r&255|X),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function cs(r,e){let t=r[e],n=0;if(n+=t&Ae,to+i.length,0));let t=Xe(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return t}var Qn=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let t=this.index,n=e();return n===void 0&&(this.index=t),n}parseWith(e){let t=e();if(this.index===this.input.length)return t}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(e){return this.readAtomically(()=>{let t=this.readChar();if(t===e)return t})}readSeparator(e,t,n){return this.readAtomically(()=>{if(!(t>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,t,n,o){return this.readAtomically(()=>{let i=0,s=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",f=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let l=this.readChar();if(l===void 0)return;let h=Number.parseInt(l,e);if(!Number.isNaN(h))return h});if(u===void 0)break;if(i*=e,i+=u,i>f||(s+=1,t!==void 0&&s>t))return}if(s!==0)return!n&&c&&s>1?void 0:i})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let t=0;tthis.readNumber(10,3,!1,1));if(n===void 0)return;e[t]=n}return e})}readIPv6Addr(){let e=t=>{for(let n=0;nthis.readIPv4Addr());if(s!==void 0)return t[o]=s[0],t[o+1]=s[1],t[o+2]=s[2],t[o+3]=s[3],[o+4,!0]}let i=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(i===void 0)return[o,!1];t[o]=i>>8,t[o+1]=i&255}return[t.length,!1]};return this.readAtomically(()=>{let t=new Uint8Array(16),[n,o]=e(t);if(n===16)return t;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let i=new Uint8Array(14),s=16-(n+2),[a]=e(i.subarray(0,s));return t.set(i.subarray(0,a),16-a),t})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var yc=45,Cd=15,Sr=new Qn;function us(r){if(!(r.length>Cd))return Sr.new(r).parseWith(()=>Sr.readIPv4Addr())}function ls(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>yc))return Sr.new(r).parseWith(()=>Sr.readIPv6Addr())}function eo(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>yc))return Sr.new(r).parseWith(()=>Sr.readIPAddr())}var Vy=parseInt("0xFFFF",16),Oy=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function xc(r){return!!us(r)}function Ec(r){return!!ls(r)}function to(r){return!!eo(r)}var vc=xc,Vd=Ec,fs=function(r){let e=0;if(r=r.toString().trim(),vc(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(Vd(r)){let t=r.split(":",8),n;for(n=0;n0;n--)i.push("0");t.splice.apply(t,i)}let o=new Uint8Array(e+16);for(n=0;n>8&255,o[e++]=i&255}return o}throw new Error("invalid ip address")},Bc=function(r,e=0,t){e=~~e,t=t??r.length-e;let n=new DataView(r.buffer);if(t===4){let o=[];for(let i=0;i{let e=Pd(...r);hs[e.code]=e,Ir[e.name]=e});function Pd(r,e,t,n,o){return{code:r,size:e,name:t,resolvable:!!n,path:!!o}}function te(r){if(typeof r=="number"){if(hs[r]!=null)return hs[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Ir[r]!=null)return Ir[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var bw=te("ip4"),xw=te("ip6"),Ew=te("ipcidr");function gs(r,e){switch(te(r).code){case 4:case 41:return Md(e);case 42:return ms(e);case 6:case 273:case 33:case 132:return Ic(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return ms(e);case 421:return qd(e);case 444:return Sc(e);case 445:return Sc(e);case 466:return $d(e);case 481:return globalThis.encodeURIComponent(ms(e));default:return z(e,"base16")}}function ys(r,e){switch(te(r).code){case 4:return Ac(e);case 41:return Ac(e);case 42:return ps(e);case 6:case 273:case 33:case 132:return ws(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return ps(e);case 421:return Hd(e);case 444:return zd(e);case 445:return Gd(e);case 466:return Kd(e);case 481:return ps(globalThis.decodeURIComponent(e));default:return Y(e,"base16")}}var ds=Object.values(Pt).map(r=>r.decoder),Fd=function(){let r=ds[0].or(ds[1]);return ds.slice(2).forEach(e=>r=r.or(e)),r}();function Ac(r){if(!to(r))throw new Error("invalid ip address");return fs(r)}function Md(r){let e=Bc(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!to(e))throw new Error("invalid ip address");return e}function ws(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function Ic(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function ps(r){let e=Y(r),t=Uint8Array.from(Ar(e.length));return Te([t,e],t.length+e.length)}function ms(r){let e=nr(r);if(r=r.slice(Ve(e)),r.length!==e)throw new Error("inconsistent lengths");return z(r)}function Hd(r){let e;r[0]==="Q"||r[0]==="1"?e=Ot(ae.decode(`z${r}`)).bytes:e=Be.parse(r).multihash.bytes;let t=Uint8Array.from(Ar(e.length));return Te([t,e],t.length+e.length)}function Kd(r){let e=Fd.decode(r),t=Uint8Array.from(Ar(e.length));return Te([t,e],t.length+e.length)}function $d(r){let e=nr(r),t=r.slice(Ve(e));if(t.length!==e)throw new Error("inconsistent lengths");return"u"+z(t,"base64url")}function qd(r){let e=nr(r),t=r.slice(Ve(e));if(t.length!==e)throw new Error("inconsistent lengths");return z(t,"base58btc")}function zd(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let t=We.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ws(n);return Te([t,o],t.length+o.length)}function Gd(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let t=We.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ws(n);return Te([t,o],t.length+o.length)}function Sc(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=z(e,"base32"),o=Ic(t);return`${n}:${o}`}function Rc(r){r=bs(r);let e=[],t=[],n=null,o=r.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let i=0;i=o.length)throw Tc("invalid address: "+r);if(a.path===!0){n=bs(o.slice(i).join("/")),e.push([a.code,ys(a.code,n)]),t.push([a.code,n]);break}let c=ys(a.code,o[i]);e.push([a.code,c]),t.push([a.code,gs(a.code,c)])}return{string:kc(t),bytes:Es(e),tuples:e,stringTuples:t,path:n}}function xs(r){let e=[],t=[],n=null,o=0;for(;or.length)throw Tc("Invalid address Uint8Array: "+z(r,"base16"));e.push([i,f]);let u=gs(i,f);if(t.push([i,u]),a.path===!0){n=u;break}}return{bytes:Uint8Array.from(r),string:kc(t),tuples:e,stringTuples:t,path:n}}function kc(r){let e=[];return r.map(t=>{let n=te(t[0]);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),bs(e.join("/"))}function Es(r){return Te(r.map(e=>{let t=te(e[0]),n=Uint8Array.from(Ar(t.code));return e.length>1&&e[1]!=null&&(n=Te([n,e[1]])),n}))}function jd(r,e){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let t=nr(e instanceof Uint8Array?e:Uint8Array.from(e));return t+Ve(t)}}function bs(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function Tc(r){return new Error("Error parsing address: "+r)}var Yd=Symbol.for("nodejs.util.inspect.custom"),Bs=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Zd=[te("dns").code,te("dns4").code,te("dns6").code,te("dnsaddr").code],vs=class extends Error{constructor(e="No available resolver"){super(e),this.name="NoAvailableResolverError"}},ro=class r{bytes;#e;#r;#i;#a;[Bs]=!0;constructor(e){e==null&&(e="");let t;if(e instanceof Uint8Array)t=xs(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);t=Rc(e)}else if(Nc(e))t=xs(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=t.bytes,this.#e=t.string,this.#r=t.tuples,this.#i=t.stringTuples,this.#a=t.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let e,t,n,o,i="",s=te("tcp"),a=te("udp"),c=te("ip4"),f=te("ip6"),u=te("dns6"),l=te("ip6zone");for(let[w,B]of this.stringTuples())w===l.code&&(i=`%${B??""}`),Zd.includes(w)&&(t=s.name,o=443,n=`${B??""}${i}`,e=w===u.code?6:4),(w===s.code||w===a.code)&&(t=te(w).name,o=parseInt(B??"")),(w===c.code||w===f.code)&&(t=te(w).name,n=`${B??""}${i}`,e=w===f.code?6:4);if(e==null||t==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e,host:n,transport:t,port:o}}protos(){return this.#r.map(([e])=>Object.assign({},te(e)))}protoCodes(){return this.#r.map(([e])=>e)}protoNames(){return this.#r.map(([e])=>te(e).name)}tuples(){return this.#r}stringTuples(){return this.#i}encapsulate(e){return e=new r(e),new r(this.toString()+e.toString())}decapsulate(e){let t=e.toString(),n=this.toString(),o=n.lastIndexOf(t);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new r(n.slice(0,o))}decapsulateCode(e){let t=this.tuples();for(let n=t.length-1;n>=0;n--)if(t[n][0]===e)return new r(Es(t.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,o])=>{n===Ir.p2p.code&&e.push([n,o]),n===Ir["p2p-circuit"].code&&(e=[])});let t=e.pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?z(ae.decode(`z${n}`),"base58btc"):z(Be.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#a}equals(e){return ue(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(i=>i.resolvable);if(t==null)return[this];let n=Cc.get(t.name);if(n==null)throw new vs(`no available resolver for ${t.name}`);return(await n(this,e)).map(i=>un(i))}nodeAddress(){let e=this.toOptions();if(e.transport!=="tcp"&&e.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){let t=(e??this).protos();return!(t.length!==2||t[0].code!==4&&t[0].code!==41||t[1].code!==6&&t[1].code!==273)}[Yd](){return`Multiaddr(${this.#e})`}};var Cc=new Map;function Nc(r){return!!r?.[Bs]}function un(r){return new ro(r)}function ln(r){let e=new globalThis.AbortController;function t(){e.abort();for(let i of r)i?.removeEventListener!=null&&i.removeEventListener("abort",t)}for(let i of r){if(i?.aborted===!0){t();break}i?.addEventListener!=null&&i.addEventListener("abort",t)}function n(){for(let i of r)i?.removeEventListener!=null&&i.removeEventListener("abort",t)}let o=e.signal;return o.clear=n,o}async function*no(r,e={}){let t=r.getReader();try{for(;;){let n=await t.read();if(n.done)return;yield n.value}}finally{e.preventCancel!==!0&&await t.cancel(),t.releaseLock()}}var Qs={};me(Qs,{Ed25519PrivateKey:()=>hr,Ed25519PublicKey:()=>wn,generateKeyPair:()=>dp,generateKeyPairFromSeed:()=>lu,unmarshalEd25519PrivateKey:()=>fp,unmarshalEd25519PublicKey:()=>hp});function Ge(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function Rr(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`positive integer expected, not ${r}`)}function Wd(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function kr(r,...e){if(!Wd(r))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(r.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${r.length}`)}function oo(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Rr(r.outputLen),Rr(r.blockLen)}function Tr(r,e=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(e&&r.finished)throw new Error("Hash#digest() has already been called")}function _c(r,e){kr(r);let t=e.outputLen;if(r.lengthnew DataView(r.buffer,r.byteOffset,r.byteLength),Qe=(r,e)=>r<<32-e|r>>>e;var eb=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;var Jd=async()=>{};async function Uc(r,e,t){let n=Date.now();for(let o=0;o=0&&ir().update(Ft(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function _r(r=32){if(or&&typeof or.getRandomValues=="function")return or.getRandomValues(new Uint8Array(r));if(or&&typeof or.randomBytes=="function")return or.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function Qd(r,e,t,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,n);let o=BigInt(32),i=BigInt(4294967295),s=Number(t>>o&i),a=Number(t&i),c=n?4:0,f=n?0:4;r.setUint32(e+c,s,n),r.setUint32(e+f,a,n)}var Oc=(r,e,t)=>r&e^~r&t,Dc=(r,e,t)=>r&e^r&t^e&t,Ur=class extends Cr{constructor(e,t,n,o){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Nr(this.buffer)}update(e){Tr(this);let{view:t,buffer:n,blockLen:o}=this;e=Ft(e);let i=e.length;for(let s=0;so-s&&(this.process(n,0),s=0);for(let l=s;lu.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l>Ss&so)}:{h:Number(r>>Ss&so)|0,l:Number(r&so)|0}}function e0(r,e=!1){let t=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let o=0;oBigInt(r>>>0)<>>0),r0=(r,e,t)=>r>>>t,n0=(r,e,t)=>r<<32-t|e>>>t,o0=(r,e,t)=>r>>>t|e<<32-t,i0=(r,e,t)=>r<<32-t|e>>>t,s0=(r,e,t)=>r<<64-t|e>>>t-32,a0=(r,e,t)=>r>>>t-32|e<<64-t,c0=(r,e)=>e,u0=(r,e)=>r,l0=(r,e,t)=>r<>>32-t,f0=(r,e,t)=>e<>>32-t,h0=(r,e,t)=>e<>>64-t,d0=(r,e,t)=>r<>>64-t;function p0(r,e,t,n){let o=(e>>>0)+(n>>>0);return{h:r+t+(o/2**32|0)|0,l:o|0}}var m0=(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),g0=(r,e,t,n)=>e+t+n+(r/2**32|0)|0,y0=(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),w0=(r,e,t,n,o)=>e+t+n+o+(r/2**32|0)|0,b0=(r,e,t,n,o)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(o>>>0),x0=(r,e,t,n,o,i)=>e+t+n+o+i+(r/2**32|0)|0;var E0={fromBig:Pc,split:e0,toBig:t0,shrSH:r0,shrSL:n0,rotrSH:o0,rotrSL:i0,rotrBH:s0,rotrBL:a0,rotr32H:c0,rotr32L:u0,rotlSH:l0,rotlSL:f0,rotlBH:h0,rotlBL:d0,add:p0,add3L:m0,add3H:g0,add4L:y0,add4H:w0,add5H:x0,add5L:b0},q=E0;var[v0,B0]=q.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),Mt=new Uint32Array(80),Ht=new Uint32Array(80),Is=class extends Ur{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:e,Al:t,Bh:n,Bl:o,Ch:i,Cl:s,Dh:a,Dl:c,Eh:f,El:u,Fh:l,Fl:h,Gh:w,Gl:B,Hh:m,Hl:d}=this;return[e,t,n,o,i,s,a,c,f,u,l,h,w,B,m,d]}set(e,t,n,o,i,s,a,c,f,u,l,h,w,B,m,d){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=u|0,this.Fh=l|0,this.Fl=h|0,this.Gh=w|0,this.Gl=B|0,this.Hh=m|0,this.Hl=d|0}process(e,t){for(let y=0;y<16;y++,t+=4)Mt[y]=e.getUint32(t),Ht[y]=e.getUint32(t+=4);for(let y=16;y<80;y++){let k=Mt[y-15]|0,D=Ht[y-15]|0,V=q.rotrSH(k,D,1)^q.rotrSH(k,D,8)^q.shrSH(k,D,7),N=q.rotrSL(k,D,1)^q.rotrSL(k,D,8)^q.shrSL(k,D,7),b=Mt[y-2]|0,v=Ht[y-2]|0,F=q.rotrSH(b,v,19)^q.rotrBH(b,v,61)^q.shrSH(b,v,6),_=q.rotrSL(b,v,19)^q.rotrBL(b,v,61)^q.shrSL(b,v,6),C=q.add4L(N,_,Ht[y-7],Ht[y-16]),$=q.add4H(C,V,F,Mt[y-7],Mt[y-16]);Mt[y]=$|0,Ht[y]=C|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:f,Dl:u,Eh:l,El:h,Fh:w,Fl:B,Gh:m,Gl:d,Hh:E,Hl:R}=this;for(let y=0;y<80;y++){let k=q.rotrSH(l,h,14)^q.rotrSH(l,h,18)^q.rotrBH(l,h,41),D=q.rotrSL(l,h,14)^q.rotrSL(l,h,18)^q.rotrBL(l,h,41),V=l&w^~l&m,N=h&B^~h&d,b=q.add5L(R,D,N,B0[y],Ht[y]),v=q.add5H(b,E,k,V,v0[y],Mt[y]),F=b|0,_=q.rotrSH(n,o,28)^q.rotrBH(n,o,34)^q.rotrBH(n,o,39),C=q.rotrSL(n,o,28)^q.rotrBL(n,o,34)^q.rotrBL(n,o,39),$=n&i^n&a^i&a,S=o&s^o&c^s&c;E=m|0,R=d|0,m=w|0,d=B|0,w=l|0,B=h|0,{h:l,l:h}=q.add(f|0,u|0,v|0,F|0),f=a|0,u=c|0,a=i|0,c=s|0,i=n|0,s=o|0;let I=q.add3L(F,C,S);n=q.add3H(I,v,_,$),o=I|0}({h:n,l:o}=q.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=q.add(this.Bh|0,this.Bl|0,i|0,s|0),{h:a,l:c}=q.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:u}=q.add(this.Dh|0,this.Dl|0,f|0,u|0),{h:l,l:h}=q.add(this.Eh|0,this.El|0,l|0,h|0),{h:w,l:B}=q.add(this.Fh|0,this.Fl|0,w|0,B|0),{h:m,l:d}=q.add(this.Gh|0,this.Gl|0,m|0,d|0),{h:E,l:R}=q.add(this.Hh|0,this.Hl|0,E|0,R|0),this.set(n,o,i,s,a,c,f,u,l,h,w,B,m,d,E,R)}roundClean(){Mt.fill(0),Ht.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var fn=io(()=>new Is);var co={};me(co,{aInRange:()=>Oe,abool:()=>et,abytes:()=>Lr,bitGet:()=>T0,bitLen:()=>Ns,bitMask:()=>dn,bitSet:()=>C0,bytesToHex:()=>bt,bytesToNumberBE:()=>xt,bytesToNumberLE:()=>$t,concatBytes:()=>Et,createHmacDrbg:()=>_s,ensureBytes:()=>se,equalBytes:()=>R0,hexToBytes:()=>sr,hexToNumber:()=>Cs,inRange:()=>hn,isBytes:()=>Kt,memoized:()=>cr,notImplemented:()=>_0,numberToBytesBE:()=>qt,numberToBytesLE:()=>ar,numberToHexUnpadded:()=>ir,numberToVarBytesBE:()=>I0,utf8ToBytes:()=>k0,validateObject:()=>lt});var Ts=BigInt(0),ao=BigInt(1),A0=BigInt(2);function Kt(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Lr(r){if(!Kt(r))throw new Error("Uint8Array expected")}function et(r,e){if(typeof e!="boolean")throw new Error(`${r} must be valid boolean, got "${e}".`)}var S0=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function bt(r){Lr(r);let e="";for(let t=0;t=wt._0&&r<=wt._9)return r-wt._0;if(r>=wt._A&&r<=wt._F)return r-(wt._A-10);if(r>=wt._a&&r<=wt._f)return r-(wt._a-10)}function sr(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let e=r.length,t=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(t);for(let o=0,i=0;otypeof r=="bigint"&&Ts<=r;function hn(r,e,t){return Rs(r)&&Rs(e)&&Rs(t)&&e<=r&&rTs;r>>=ao,e+=1);return e}function T0(r,e){return r>>BigInt(e)&ao}function C0(r,e,t){return r|(t?ao:Ts)<(A0<new Uint8Array(r),Mc=r=>Uint8Array.from(r);function _s(r,e,t){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");let n=ks(r),o=ks(r),i=0,s=()=>{n.fill(1),o.fill(0),i=0},a=(...l)=>t(o,n,...l),c=(l=ks())=>{o=a(Mc([0]),l),n=a(),l.length!==0&&(o=a(Mc([1]),l),n=a())},f=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,h=[];for(;l{s(),c(l);let w;for(;!(w=h(f()));)c();return s(),w}}var N0={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||Kt(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,e)=>e.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function lt(r,e,t={}){let n=(o,i,s)=>{let a=N0[i];if(typeof a!="function")throw new Error(`Invalid validator "${i}", expected function`);let c=r[o];if(!(s&&c===void 0)&&!a(c,r))throw new Error(`Invalid param ${String(o)}=${c} (${typeof c}), expected ${i}`)};for(let[o,i]of Object.entries(e))n(o,i,!1);for(let[o,i]of Object.entries(t))n(o,i,!0);return r}var _0=()=>{throw new Error("not implemented")};function cr(r){let e=new WeakMap;return(t,...n)=>{let o=e.get(t);if(o!==void 0)return o;let i=r(t,...n);return e.set(t,i),i}}var he=BigInt(0),ne=BigInt(1),ur=BigInt(2),U0=BigInt(3),Us=BigInt(4),Hc=BigInt(5),Kc=BigInt(8),L0=BigInt(9),V0=BigInt(16);function ee(r,e){let t=r%e;return t>=he?t:e+t}function O0(r,e,t){if(t<=he||e 0");if(t===ne)return he;let n=ne;for(;e>he;)e&ne&&(n=n*r%t),r=r*r%t,e>>=ne;return n}function oe(r,e,t){let n=r;for(;e-- >he;)n*=n,n%=t;return n}function uo(r,e){if(r===he||e<=he)throw new Error(`invert: expected positive integers, got n=${r} mod=${e}`);let t=ee(r,e),n=e,o=he,i=ne,s=ne,a=he;for(;t!==he;){let f=n/t,u=n%t,l=o-s*f,h=i-a*f;n=t,t=u,o=s,i=a,s=l,a=h}if(n!==ne)throw new Error("invert: does not exist");return ee(o,e)}function D0(r){let e=(r-ne)/ur,t,n,o;for(t=r-ne,n=0;t%ur===he;t/=ur,n++);for(o=ur;o(ee(r,e)&ne)===ne,F0=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ls(r){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=F0.reduce((n,o)=>(n[o]="function",n),e);return lt(r,t)}function M0(r,e,t){if(t 0");if(t===he)return r.ONE;if(t===ne)return e;let n=r.ONE,o=e;for(;t>he;)t&ne&&(n=r.mul(n,o)),o=r.sqr(o),t>>=ne;return n}function H0(r,e){let t=new Array(e.length),n=e.reduce((i,s,a)=>r.is0(s)?i:(t[a]=i,r.mul(i,s)),r.ONE),o=r.inv(n);return e.reduceRight((i,s,a)=>r.is0(s)?i:(t[a]=r.mul(i,t[a]),r.mul(i,s)),o),t}function Vs(r,e){let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function zt(r,e,t=!1,n={}){if(r<=he)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:o,nByteLength:i}=Vs(r,e);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");let s=P0(r),a=Object.freeze({ORDER:r,BITS:o,BYTES:i,MASK:dn(o),ZERO:he,ONE:ne,create:c=>ee(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return he<=c&&cc===he,isOdd:c=>(c&ne)===ne,neg:c=>ee(-c,r),eql:(c,f)=>c===f,sqr:c=>ee(c*c,r),add:(c,f)=>ee(c+f,r),sub:(c,f)=>ee(c-f,r),mul:(c,f)=>ee(c*f,r),pow:(c,f)=>M0(a,c,f),div:(c,f)=>ee(c*uo(f,r),r),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>uo(c,r),sqrt:n.sqrt||(c=>s(a,c)),invertBatch:c=>H0(a,c),cmov:(c,f,u)=>u?f:c,toBytes:c=>t?ar(c,i):qt(c,i),fromBytes:c=>{if(c.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${c.length}`);return t?$t(c):xt(c)}});return Object.freeze(a)}function qc(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let e=r.toString(2).length;return Math.ceil(e/8)}function Os(r){let e=qc(r);return e+Math.ceil(e/2)}function zc(r,e,t=!1){let n=r.length,o=qc(e),i=Os(e);if(n<16||n1024)throw new Error(`expected ${i}-1024 bytes of input, got ${n}`);let s=t?xt(r):$t(r),a=ee(s,e-ne)+ne;return t?ar(a,o):qt(a,o)}var $0=BigInt(0),Ds=BigInt(1),Ps=new WeakMap,Gc=new WeakMap;function lo(r,e){let t=(i,s)=>{let a=s.negate();return i?a:s},n=i=>{if(!Number.isSafeInteger(i)||i<=0||i>e)throw new Error(`Wrong window size=${i}, should be [1..${e}]`)},o=i=>{n(i);let s=Math.ceil(e/i)+1,a=2**(i-1);return{windows:s,windowSize:a}};return{constTimeNegate:t,unsafeLadder(i,s){let a=r.ZERO,c=i;for(;s>$0;)s&Ds&&(a=a.add(c)),c=c.double(),s>>=Ds;return a},precomputeWindow(i,s){let{windows:a,windowSize:c}=o(s),f=[],u=i,l=u;for(let h=0;h>=B,E>f&&(E-=w,a+=Ds);let R=d,y=d+Math.abs(E)-1,k=m%2!==0,D=E<0;E===0?l=l.add(t(k,s[R])):u=u.add(t(D,s[y]))}return{p:u,f:l}},wNAFCached(i,s,a){let c=Gc.get(i)||1,f=Ps.get(i);return f||(f=this.precomputeWindow(i,c),c!==1&&Ps.set(i,a(f))),this.wNAF(c,f,s)},setWindowSize(i,s){n(s),Gc.set(i,s),Ps.delete(i)}}}function fo(r,e,t,n){if(!Array.isArray(t)||!Array.isArray(n)||n.length!==t.length)throw new Error("arrays of points and scalars must have equal length");n.forEach((u,l)=>{if(!e.isValid(u))throw new Error(`wrong scalar at index ${l}`)}),t.forEach((u,l)=>{if(!(u instanceof r))throw new Error(`wrong point at index ${l}`)});let o=Ns(BigInt(t.length)),i=o>12?o-3:o>4?o-2:o?2:1,s=(1<=0;u-=i){a.fill(r.ZERO);for(let h=0;h>BigInt(u)&BigInt(s));a[B]=a[B].add(t[h])}let l=r.ZERO;for(let h=a.length-1,w=r.ZERO;h>0;h--)w=w.add(a[h]),l=l.add(w);if(f=f.add(l),u!==0)for(let h=0;h{try{return{isValid:!0,value:t.sqrt(g*t.inv(p))}}catch{return{isValid:!1,value:tt}}}),w=e.adjustScalarBytes||(g=>g),B=e.domain||((g,p,A)=>{if(et("phflag",A),p.length||A)throw new Error("Contexts/pre-hash are not supported");return g});function m(g,p){Oe("coordinate "+g,p,tt,f)}function d(g){if(!(g instanceof y))throw new Error("ExtendedPoint expected")}let E=cr((g,p)=>{let{ex:A,ey:O,ez:M}=g,H=g.is0();p==null&&(p=H?q0:t.inv(M));let G=u(A*p),W=u(O*p),j=u(M*p);if(H)return{x:tt,y:De};if(j!==De)throw new Error("invZ was invalid");return{x:G,y:W}}),R=cr(g=>{let{a:p,d:A}=e;if(g.is0())throw new Error("bad point: ZERO");let{ex:O,ey:M,ez:H,et:G}=g,W=u(O*O),j=u(M*M),Q=u(H*H),re=u(Q*Q),de=u(W*p),pe=u(Q*u(de+j)),be=u(re+u(A*u(W*j)));if(pe!==be)throw new Error("bad point: equation left != right (1)");let ke=u(O*M),fe=u(H*G);if(ke!==fe)throw new Error("bad point: equation left != right (2)");return!0});class y{constructor(p,A,O,M){this.ex=p,this.ey=A,this.ez=O,this.et=M,m("x",p),m("y",A),m("z",O),m("t",M),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(p){if(p instanceof y)throw new Error("extended point not allowed");let{x:A,y:O}=p||{};return m("x",A),m("y",O),new y(A,O,De,u(A*O))}static normalizeZ(p){let A=t.invertBatch(p.map(O=>O.ez));return p.map((O,M)=>O.toAffine(A[M])).map(y.fromAffine)}static msm(p,A){return fo(y,l,p,A)}_setWindowSize(p){V.setWindowSize(this,p)}assertValidity(){R(this)}equals(p){d(p);let{ex:A,ey:O,ez:M}=this,{ex:H,ey:G,ez:W}=p,j=u(A*W),Q=u(H*M),re=u(O*W),de=u(G*M);return j===Q&&re===de}is0(){return this.equals(y.ZERO)}negate(){return new y(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:p}=e,{ex:A,ey:O,ez:M}=this,H=u(A*A),G=u(O*O),W=u(ho*u(M*M)),j=u(p*H),Q=A+O,re=u(u(Q*Q)-H-G),de=j+G,pe=de-W,be=j-G,ke=u(re*pe),fe=u(de*be),Le=u(re*be),gt=u(pe*de);return new y(ke,fe,gt,Le)}add(p){d(p);let{a:A,d:O}=e,{ex:M,ey:H,ez:G,et:W}=this,{ex:j,ey:Q,ez:re,et:de}=p;if(A===BigInt(-1)){let Ua=u((H-M)*(Q+j)),La=u((H+M)*(Q-j)),Ti=u(La-Ua);if(Ti===tt)return this.double();let Va=u(G*ho*de),Oa=u(W*ho*re),Da=Oa+Va,Pa=La+Ua,Fa=Oa-Va,Jf=u(Da*Ti),Xf=u(Pa*Fa),Qf=u(Da*Fa),eh=u(Ti*Pa);return new y(Jf,Xf,eh,Qf)}let pe=u(M*j),be=u(H*Q),ke=u(W*O*de),fe=u(G*re),Le=u((M+H)*(j+Q)-pe-be),gt=fe-ke,en=fe+ke,tn=u(be-A*pe),jf=u(Le*gt),Yf=u(en*tn),Zf=u(Le*tn),Wf=u(gt*en);return new y(jf,Yf,Wf,Zf)}subtract(p){return this.add(p.negate())}wNAF(p){return V.wNAFCached(this,p,y.normalizeZ)}multiply(p){let A=p;Oe("scalar",A,De,n);let{p:O,f:M}=this.wNAF(A);return y.normalizeZ([O,M])[0]}multiplyUnsafe(p){let A=p;return Oe("scalar",A,tt,n),A===tt?D:this.equals(D)||A===De?this:this.equals(k)?this.wNAF(A).p:V.unsafeLadder(this,A)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return V.unsafeLadder(this,n).is0()}toAffine(p){return E(this,p)}clearCofactor(){let{h:p}=e;return p===De?this:this.multiplyUnsafe(p)}static fromHex(p,A=!1){let{d:O,a:M}=e,H=t.BYTES;p=se("pointHex",p,H),et("zip215",A);let G=p.slice(),W=p[H-1];G[H-1]=W&-129;let j=$t(G),Q=A?f:t.ORDER;Oe("pointHex.y",j,tt,Q);let re=u(j*j),de=u(re-De),pe=u(O*re-M),{isValid:be,value:ke}=h(de,pe);if(!be)throw new Error("Point.fromHex: invalid y coordinate");let fe=(ke&De)===De,Le=(W&128)!==0;if(!A&&ke===tt&&Le)throw new Error("Point.fromHex: x=0 and x_0=1");return Le!==fe&&(ke=u(-ke)),y.fromAffine({x:ke,y:j})}static fromPrivateKey(p){return v(p).point}toRawBytes(){let{x:p,y:A}=this.toAffine(),O=ar(A,t.BYTES);return O[O.length-1]|=p&De?128:0,O}toHex(){return bt(this.toRawBytes())}}y.BASE=new y(e.Gx,e.Gy,De,u(e.Gx*e.Gy)),y.ZERO=new y(tt,De,De,tt);let{BASE:k,ZERO:D}=y,V=lo(y,a*8);function N(g){return ee(g,n)}function b(g){return N($t(g))}function v(g){let p=a;g=se("private key",g,p);let A=se("hashed private key",i(g),2*p),O=w(A.slice(0,p)),M=A.slice(p,2*p),H=b(O),G=k.multiply(H),W=G.toRawBytes();return{head:O,prefix:M,scalar:H,point:G,pointBytes:W}}function F(g){return v(g).pointBytes}function _(g=new Uint8Array,...p){let A=Et(...p);return b(i(B(A,se("context",g),!!o)))}function C(g,p,A={}){g=se("message",g),o&&(g=o(g));let{prefix:O,scalar:M,pointBytes:H}=v(p),G=_(A.context,O,g),W=k.multiply(G).toRawBytes(),j=_(A.context,W,H,g),Q=N(G+j*M);Oe("signature.s",Q,tt,n);let re=Et(W,ar(Q,t.BYTES));return se("result",re,a*2)}let $=z0;function S(g,p,A,O=$){let{context:M,zip215:H}=O,G=t.BYTES;g=se("signature",g,2*G),p=se("message",p),H!==void 0&&et("zip215",H),o&&(p=o(p));let W=$t(g.slice(G,2*G)),j,Q,re;try{j=y.fromHex(A,H),Q=y.fromHex(g.slice(0,G),H),re=k.multiplyUnsafe(W)}catch{return!1}if(!H&&j.isSmallOrder())return!1;let de=_(M,Q.toRawBytes(),j.toRawBytes(),p);return Q.add(j.multiplyUnsafe(de)).subtract(re).clearCofactor().equals(y.ZERO)}return k._setWindowSize(8),{CURVE:e,getPublicKey:F,sign:C,verify:S,ExtendedPoint:y,utils:{getExtendedPublicKey:v,randomPrivateKey:()=>s(t.BYTES),precompute(g=8,p=y.BASE){return p._setWindowSize(g),p.multiply(BigInt(3)),p}}}}var Fs=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Yc=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Bb=BigInt(0),j0=BigInt(1),Zc=BigInt(2),Ab=BigInt(3),Y0=BigInt(5),Z0=BigInt(8);function W0(r){let e=BigInt(10),t=BigInt(20),n=BigInt(40),o=BigInt(80),i=Fs,a=r*r%i*r%i,c=oe(a,Zc,i)*a%i,f=oe(c,j0,i)*r%i,u=oe(f,Y0,i)*f%i,l=oe(u,e,i)*u%i,h=oe(l,t,i)*l%i,w=oe(h,n,i)*h%i,B=oe(w,o,i)*w%i,m=oe(B,o,i)*w%i,d=oe(m,e,i)*u%i;return{pow_p_5_8:oe(d,Zc,i)*r%i,b2:a}}function J0(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function X0(r,e){let t=Fs,n=ee(e*e*e,t),o=ee(n*n*e,t),i=W0(r*o).pow_p_5_8,s=ee(r*n*i,t),a=ee(e*s*s,t),c=s,f=ee(s*Yc,t),u=a===r,l=a===ee(-r,t),h=a===ee(-r*Yc,t);return u&&(s=c),(l||h)&&(s=f),$c(s,t)&&(s=ee(-s,t)),{isValid:u||l,value:s}}var Q0=zt(Fs,void 0,!0),ep={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Q0,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Z0,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:fn,randomBytes:_r,adjustScalarBytes:J0,uvRatio:X0},Vr=jc(ep);var Or=32,vt=64,po=32;function Wc(){let r=Vr.utils.randomPrivateKey(),e=Vr.getPublicKey(r);return{privateKey:eu(r,e),publicKey:e}}function Jc(r){if(r.length!==po)throw new TypeError('"seed" must be 32 bytes in length.');if(!(r instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, or Uint8Array.');let e=r,t=Vr.getPublicKey(e);return{privateKey:eu(e,t),publicKey:t}}function Xc(r,e){let t=r.subarray(0,po);return Vr.sign(e instanceof Uint8Array?e:e.subarray(),t)}function Qc(r,e,t){return Vr.verify(e,t instanceof Uint8Array?t:t.subarray(),r)}function eu(r,e){let t=new Uint8Array(vt);for(let n=0;n>>31>0){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(t+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(BigInt(t)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?t===0?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return lr;if(eop)return this.fromNumber(Number(e));let t=e<0n;t&&(e=-e);let n=e>>32n,o=e-(n<<32n);return t&&(n=~n|0n,o=~o|0n,++o>su&&(o=0n,++n>su&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(e){if(e===0)return lr;let t=e<0;t&&(e=-e);let n=e>>>0,o=(e-n)/4294967296>>>0;return t&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)}static from(e){return typeof e=="number"?r.fromNumber(e):typeof e=="bigint"?r.fromBigInt(e):typeof e=="string"?r.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new r(e.low>>>0,e.high>>>0):lr}},lr=new Me(0,0);lr.toBigInt=function(){return 0n};lr.zzEncode=lr.zzDecode=function(){return this};lr.length=function(){return 1};var su=4294967296n;function au(r){let e=0,t=0;for(let n=0;n191&&a<224?i[s++]=(a&31)<<6|r[e++]&63:a>239&&a<365?(a=((a&7)<<18|(r[e++]&63)<<12|(r[e++]&63)<<6|r[e++]&63)-65536,i[s++]=55296+(a>>10),i[s++]=56320+(a&1023)):i[s++]=(a&15)<<12|(r[e++]&63)<<6|r[e++]&63,s>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o!=null?(s>0&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function $s(r,e,t){let n=t,o,i;for(let s=0;s>6|192,e[t++]=o&63|128):(o&64512)===55296&&((i=r.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,e[t++]=o>>18|240,e[t++]=o>>12&63|128,e[t++]=o>>6&63|128,e[t++]=o&63|128):(e[t++]=o>>12|224,e[t++]=o>>6&63|128,e[t++]=o&63|128);return t-n}function rt(r,e){return RangeError(`index out of range: ${r.pos} + ${e??1} > ${r.len}`)}function mo(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}var qs=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,rt(this,10);return e}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw rt(this,4);return mo(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw rt(this,4);return mo(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw rt(this,4);let e=nu(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw rt(this,4);let e=iu(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),t=this.pos,n=this.pos+e;if(n>this.len)throw rt(this,e);return this.pos+=e,t===n?new Uint8Array(0):this.buf.subarray(t,n)}string(){let e=this.bytes();return cu(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw rt(this,e);this.pos+=e}else do if(this.pos>=this.len)throw rt(this);while(this.buf[this.pos++]&128);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new Me(0,0),t=0;if(this.len-this.pos>4){for(;t<4;++t)if(e.lo=(e.lo|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;t=0}else{for(;t<3;++t){if(this.pos>=this.len)throw rt(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<>>0,e}if(this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw rt(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw rt(this,8);let e=mo(this.buf,this.pos+=4),t=mo(this.buf,this.pos+=4);return new Me(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=cs(this.buf,this.pos);return this.pos+=Ve(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function zs(r){return new qs(r instanceof Uint8Array?r:r.subarray())}function Pr(r,e,t){let n=zs(r);return e.decode(n,void 0,t)}function Gs(r){let e=r??8192,t=e>>>1,n,o=e;return function(s){if(s<1||s>t)return Xe(s);o+s>e&&(n=Xe(e),o=0);let a=n.subarray(o,o+=s);return o&7&&(o=(o|7)+1),a}}var fr=class{fn;len;next;val;constructor(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}};function js(){}var Zs=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},ip=Gs();function sp(r){return globalThis.Buffer!=null?Xe(r):ip(r)}var gn=class{len;head;tail;states;constructor(){this.len=0,this.head=new fr(js,0,0),this.tail=this.head,this.states=null}_push(e,t,n){return this.tail=this.tail.next=new fr(e,t,n),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new Ws((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(go,10,Me.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=Me.fromBigInt(e);return this._push(go,t.length(),t)}uint64Number(e){return this._push(as,Ve(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let t=Me.fromBigInt(e).zzEncode();return this._push(go,t.length(),t)}sint64Number(e){let t=Me.fromNumber(e).zzEncode();return this._push(go,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Ys,1,e?1:0)}fixed32(e){return this._push(mn,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=Me.fromBigInt(e);return this._push(mn,4,t.lo)._push(mn,4,t.hi)}fixed64Number(e){let t=Me.fromNumber(e);return this._push(mn,4,t.lo)._push(mn,4,t.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(ru,4,e)}double(e){return this._push(ou,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(Ys,1,0):this.uint32(t)._push(cp,t,e)}string(e){let t=au(e);return t!==0?this.uint32(t)._push($s,t,e):this._push(Ys,1,0)}fork(){return this.states=new Zs(this),this.head=this.tail=new fr(js,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new fr(js,0,0),this.len=0),this}ldelim(){let e=this.head,t=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=e.next,this.tail=t,this.len+=n),this}finish(){let e=this.head.next,t=sp(this.len),n=0;for(;e!=null;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}};function Ys(r,e,t){e[t]=r&255}function ap(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}var Ws=class extends fr{next;constructor(e,t){super(ap,e,t),this.next=void 0}};function go(r,e,t){for(;r.hi!==0;)e[t++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)e[t++]=r.lo&127|128,r.lo=r.lo>>>7;e[t++]=r.lo}function mn(r,e,t){e[t]=r&255,e[t+1]=r>>>8&255,e[t+2]=r>>>16&255,e[t+3]=r>>>24}function cp(r,e,t){e.set(r,t)}globalThis.Buffer!=null&&(gn.prototype.bytes=function(r){let e=r.length>>>0;return this.uint32(e),e>0&&this._push(up,e,r),this},gn.prototype.string=function(r){let e=globalThis.Buffer.byteLength(r);return this.uint32(e),e>0&&this._push(lp,e,r),this});function up(r,e,t){e.set(r,t)}function lp(r,e,t){r.length<40?$s(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(Y(r),t)}function Js(){return new gn}function Fr(r,e){let t=Js();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}var Mr;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(Mr||(Mr={}));function yo(r,e,t,n){return{name:r,type:e,encode:t,decode:n}}function yn(r){function e(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let t=function(i,s){let a=e(i);s.int32(a)},n=function(i){let s=i.int32();return e(s)};return yo("enum",Mr.VARINT,t,n)}function Hr(r,e){return yo("message",Mr.LENGTH_DELIMITED,r,e)}var ce;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.Secp256k1="Secp256k1"})(ce||(ce={}));var Xs;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.Secp256k1=2]="Secp256k1"})(Xs||(Xs={}));(function(r){r.codec=()=>yn(Xs)})(ce||(ce={}));var ft;(function(r){let e;r.codec=()=>(e==null&&(e=Hr((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),ce.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),o.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let o={},i=n==null?t.len:t.pos+n;for(;t.pos>>3){case 1:o.Type=ce.codec().decode(t);break;case 2:o.Data=t.bytes();break;default:t.skipType(s&7);break}}return o})),e),r.encode=t=>Fr(t,r.codec()),r.decode=t=>Pr(t,r.codec())})(ft||(ft={}));var Bt;(function(r){let e;r.codec=()=>(e==null&&(e=Hr((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),ce.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),o.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let o={},i=n==null?t.len:t.pos+n;for(;t.pos>>3){case 1:o.Type=ce.codec().decode(t);break;case 2:o.Data=t.bytes();break;default:t.skipType(s&7);break}}return o})),e),r.encode=t=>Fr(t,r.codec()),r.decode=t=>Pr(t,r.codec())})(Bt||(Bt={}));var wn=class{_key;constructor(e){this._key=Kr(e,Or)}verify(e,t){return Qc(this._key,t,e)}marshal(){return this._key}get bytes(){return ft.encode({Type:ce.Ed25519,Data:this.marshal()}).subarray()}equals(e){return ue(this.bytes,e.bytes)}hash(){let e=xe.digest(this.bytes);return Ge(e)?e.then(({bytes:t})=>t):e.bytes}},hr=class{_key;_publicKey;constructor(e,t){this._key=Kr(e,vt),this._publicKey=Kr(t,Or)}sign(e){return Xc(this._key,e)}get public(){return new wn(this._publicKey)}marshal(){return this._key}get bytes(){return Bt.encode({Type:ce.Ed25519,Data:this.marshal()}).subarray()}equals(e){return ue(this.bytes,e.bytes)}async hash(){let e=xe.digest(this.bytes),t;return Ge(e)?{bytes:t}=await e:t=e.bytes,t}async id(){let e=Je.digest(this.public.bytes);return ae.encode(e.bytes).substring(1)}async export(e,t="libp2p-key"){if(t==="libp2p-key")return Dr(this.bytes,e);throw new P(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function fp(r){if(r.length>vt){r=Kr(r,vt+Or);let n=r.subarray(0,vt),o=r.subarray(vt,r.length);return new hr(n,o)}r=Kr(r,vt);let e=r.subarray(0,vt),t=r.subarray(Or);return new hr(e,t)}function hp(r){return r=Kr(r,Or),new wn(r)}async function dp(){let{privateKey:r,publicKey:e}=Wc();return new hr(r,e)}async function lu(r){let{privateKey:e,publicKey:t}=Jc(r);return new hr(e,t)}function Kr(r,e){if(r=Uint8Array.from(r??[]),r.length!==e)throw new P(`Key must be a Uint8Array of length ${e}, got ${r.length}`,"ERR_INVALID_KEY_TYPE");return r}var ua={};me(ua,{MAX_RSA_KEY_SIZE:()=>Cn,RsaPrivateKey:()=>jr,RsaPublicKey:()=>Tn,fromJwk:()=>Mp,generateKeyPair:()=>Hp,unmarshalRsaPrivateKey:()=>aa,unmarshalRsaPublicKey:()=>Fp});function dr(r){if(isNaN(r)||r<=0)throw new P("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return _r(r)}var Wt={};me(Wt,{exportToPem:()=>Lp,importFromPem:()=>Vp,jwkToPkcs1:()=>Cp,jwkToPkix:()=>_p,pkcs1ToJwk:()=>Tp,pkixToJwk:()=>Np});var bo=class extends Cr{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,oo(e);let n=Ft(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,i=new Uint8Array(o);i.set(n.length>o?e.create().update(n).digest():n);for(let s=0;snew bo(r,e).update(t).digest();bn.create=(r,e)=>new bo(r,e);function pp(r,e,t,n){oo(r);let o=Vc({dkLen:32,asyncTick:10},n),{c:i,dkLen:s,asyncTick:a}=o;if(Rr(i),Rr(s),Rr(a),i<1)throw new Error("PBKDF2: iterations (c) should be >= 1");let c=Ft(e),f=Ft(t),u=new Uint8Array(s),l=bn.create(r,c),h=l._cloneInto().update(f);return{c:i,dkLen:s,asyncTick:a,DK:u,PRF:l,PRFSalt:h}}function mp(r,e,t,n,o){return r.destroy(),e.destroy(),n&&n.destroy(),o.fill(0),t}async function ea(r,e,t,n){let{c:o,dkLen:i,asyncTick:s,DK:a,PRF:c,PRFSalt:f}=pp(r,e,t,n),u,l=new Uint8Array(4),h=Nr(l),w=new Uint8Array(c.outputLen);for(let B=1,m=0;m{c._cloneInto(u).update(w).digestInto(w);for(let E=0;E=0;n--)t+=r[r.length-1-n]*Math.pow(2,e*n);return t}function jt(r,e,t=-1){let n=t,o=r,i=0,s=Math.pow(2,e);for(let a=1;a<8;a++){if(r=0;u--){let l=Math.pow(2,u*e);f[i-u-1]=Math.floor(o/l),o-=f[i-u-1]*l}return c}s*=Math.pow(2,e)}return new ArrayBuffer(0)}function vo(...r){let e=0,t=0;for(let i of r)e+=i.length;let n=new ArrayBuffer(e),o=new Uint8Array(n);for(let i of r)o.set(i,t),t+=i.length;return o}function ra(){let r=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){let a=r[0]===255&&r[1]&128,c=r[0]===0&&(r[1]&128)===0;(a||c)&&this.warnings.push("Needlessly long format")}let e=new ArrayBuffer(this.valueHex.byteLength),t=new Uint8Array(e);for(let a=0;a"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function na(r){let e=0,t=0;for(let o=0;o=i.length)return this.error="End of input reached before message was fully decoded",-1;if(c===u){u+=255;let h=new Uint8Array(u);for(let w=0;w8)return this.error="Too big integer",-1;if(s+1>i.length)return this.error="End of input reached before message was fully decoded",-1;let a=t+1,c=o.subarray(a,a+s);return c[s-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=pr(c,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=s+1,t+this.blockLength}toBER(e=!1){let t,n;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=128),t;if(this.longFormUsed){let o=jt(this.length,8);if(o.byteLength>127)return this.error="Too big length",ot;if(t=new ArrayBuffer(o.byteLength+1),e)return t;let i=new Uint8Array(o);n=new Uint8Array(t),n[0]=o.byteLength|128;for(let s=0;s=37&&o.idBlock.isHexOnly===!1)return o.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:o};switch(o.idBlock.tagNumber){case 0:if(o.idBlock.isConstructed&&o.lenBlock.length>0)return o.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:o};c=U.EndOfContent;break;case 1:c=U.Boolean;break;case 2:c=U.Integer;break;case 3:c=U.BitString;break;case 4:c=U.OctetString;break;case 5:c=U.Null;break;case 6:c=U.ObjectIdentifier;break;case 10:c=U.Enumerated;break;case 12:c=U.Utf8String;break;case 13:c=U.RelativeObjectIdentifier;break;case 14:c=U.TIME;break;case 15:return o.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:o};case 16:c=U.Sequence;break;case 17:c=U.Set;break;case 18:c=U.NumericString;break;case 19:c=U.PrintableString;break;case 20:c=U.TeletexString;break;case 21:c=U.VideotexString;break;case 22:c=U.IA5String;break;case 23:c=U.UTCTime;break;case 24:c=U.GeneralizedTime;break;case 25:c=U.GraphicString;break;case 26:c=U.VisibleString;break;case 27:c=U.GeneralString;break;case 28:c=U.UniversalString;break;case 29:c=U.CharacterString;break;case 30:c=U.BmpString;break;case 31:c=U.DATE;break;case 32:c=U.TimeOfDay;break;case 33:c=U.DateTime;break;case 34:c=U.Duration;break;default:{let f=o.idBlock.isConstructed?new U.Constructed:new U.Primitive;f.idBlock=o.idBlock,f.lenBlock=o.lenBlock,f.warnings=o.warnings,o=f}}break;case 2:case 3:case 4:default:c=o.idBlock.isConstructed?U.Constructed:U.Primitive}return o=Ap(o,c),a=o.fromBER(r,e,o.lenBlock.isIndefiniteForm?t:o.lenBlock.length),o.valueBeforeDecodeView=r.subarray(n,n+o.blockLength),{offset:a,result:o}}function Gr(r){if(!r.byteLength){let e=new Ee({},Ie);return e.error="Input buffer has zero length",{offset:-1,result:e}}return ai(Z.BufferSourceConverter.toUint8Array(r).slice(),0,r.byteLength)}function Sp(r,e){return r?1:e}var ht=class extends Ie{constructor({value:e=[],isIndefiniteForm:t=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n){let o=Z.BufferSourceConverter.toUint8Array(e);if(!kt(this,o,t,n))return-1;if(this.valueBeforeDecodeView=o.subarray(t,t+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),t;let i=t;for(;Sp(this.isIndefiniteForm,n)>0;){let s=ai(o,i,n);if(s.offset===-1)return this.error=s.result.error,this.warnings.concat(s.result.warnings),-1;if(i=s.offset,this.blockLength+=s.result.blockLength,n-=s.result.blockLength,this.value.push(s.result),this.isIndefiniteForm&&s.result.constructor.NAME===vn)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===vn?this.value.pop():this.warnings.push("No EndOfContent block encoded")),i}toBER(e,t){let n=t||new En;for(let o=0;o{var Nf=Object.create;var kn=Object.defineProperty;var Uf=Object.getOwnPropertyDescriptor;var Rf=Object.getOwnPropertyNames;var _f=Object.getPrototypeOf,Lf=Object.prototype.hasOwnProperty;var Bi=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Ie=(r,e)=>{for(var t in e)kn(r,t,{get:e[t],enumerable:!0})},ka=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Rf(e))!Lf.call(r,o)&&o!==t&&kn(r,o,{get:()=>e[o],enumerable:!(n=Uf(e,o))||n.enumerable});return r};var Cn=(r,e,t)=>(t=r!=null?Nf(_f(r)):{},ka(e||!r||!r.__esModule?kn(t,"default",{value:r,enumerable:!0}):t,r)),Vf=r=>ka(kn({},"__esModule",{value:!0}),r);var Nc=Bi(Br=>{"use strict";var w0="[object ArrayBuffer]",wt=class r{static isArrayBuffer(e){return Object.prototype.toString.call(e)===w0}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,t){if(e.constructor===t)return e;if(this.isArrayBuffer(e))return new t(e);if(this.isArrayBufferView(e))return new t(e.buffer,e.byteOffset,e.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}static isArrayBufferView(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}static isEqual(e,t){let n=r.toUint8Array(e),o=r.toUint8Array(t);if(n.length!==o.byteLength)return!1;for(let i=0;io.byteLength).reduce((o,i)=>o+i),t=new Uint8Array(e),n=0;return r.map(o=>new Uint8Array(o)).forEach(o=>{for(let i of o)t[n++]=i}),t.buffer}function A0(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;let t=new Uint8Array(r),n=new Uint8Array(e);for(let o=0;o{var m1=function(){typeof sa<"u"&&(sa.exports=w);var r=86400,e=3200,t=146097*e/400,n=r*t,o=1e3*n,i=864e13,s=4294967296,a=1e6,c="000000000",f=Math.trunc||function(g){var v=g-g%1;return v==0&&(g<0||g===0&&1/g!=1/0)?-0:v},u=w.prototype,l=(w.fromDate=function(g){return new w(+g)},w.fromInt64BE=T(0,1,2,3,0,4),w.fromInt64LE=T(3,2,1,0,4,0),w.fromString=function(R){var v,O=new w,R=(R+="").replace(/^\s*[+\-]?\d+/,function($){var $=+$,A=1970+($-1970)%400;return O.year=$-A,A}).replace(/(?:Z|([+\-]\d{2}):?(\d{2}))$/,function(N,$,A){return $<0&&(A*=-1),v=6e4*(60*+$+ +A),""}).replace(/\.\d+$/,function(N){return O.nano=+(N+c).substr(1,9),""}).split(/\D+/);if(1>24&255,S[m+v]=p>>16&255,S[m+O]=p>>8&255,S[m+R]=255&p}}function T(g,v,O,R,N,$){return function(S,m){F(S,m|=0);var p=A(S,m+N);return C(A(S,m+$),p)};function A(S,m){return 16777216*S[m+g]+(S[m+v]<<16|S[m+O]<<8|S[m+R])}}function F(g,v){if(g=g&&g.length,g==null)throw new TypeError("Invalid Buffer");if(g{"use strict";var Yp=Object.prototype.hasOwnProperty,Ce="~";function Bn(){}Object.create&&(Bn.prototype=Object.create(null),new Bn().__proto__||(Ce=!1));function Xp(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function hf(r,e,t,n,o){if(typeof t!="function")throw new TypeError("The listener must be a function");var i=new Xp(t,n||r,o),s=Ce?Ce+e:e;return r._events[s]?r._events[s].fn?r._events[s]=[r._events[s],i]:r._events[s].push(i):(r._events[s]=i,r._eventsCount++),r}function wi(r,e){--r._eventsCount===0?r._events=new Bn:delete r._events[e]}function Ae(){this._events=new Bn,this._eventsCount=0}Ae.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)Yp.call(t,n)&&e.push(Ce?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};Ae.prototype.listeners=function(e){var t=Ce?Ce+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,i=n.length,s=new Array(i);oom});var Ca=Symbol.for("@libp2p/content-routing");var Ai=Symbol.for("@libp2p/peer-id");var Ta=Symbol.for("@libp2p/peer-routing");var be=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}},or=class extends Error{static name="InvalidPublicKeyError";constructor(e="Invalid public key"){super(e),this.name="InvalidPublicKeyError"}};var nt=class extends Error{static name="NotFoundError";constructor(e="Not found"){super(e),this.name="NotFoundError"}};var ir=class extends Error{static name="InvalidMultihashError";constructor(e="Invalid Multihash"){super(e),this.name="InvalidMultihashError"}};var sr=class extends Error{static name="UnsupportedKeyTypeError";constructor(e="Unsupported key type"){super(e),this.name="UnsupportedKeyTypeError"}};var ar=(r,...e)=>{try{[...e]}catch{}};var Ti={};Ie(Ti,{base32:()=>ze,base32hex:()=>qf,base32hexpad:()=>jf,base32hexpadupper:()=>Gf,base32hexupper:()=>zf,base32pad:()=>$f,base32padupper:()=>Kf,base32upper:()=>Hf,base32z:()=>Zf});var hm=new Uint8Array(0);function Na(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n>>0,T=new Uint8Array(x);E!==C;){for(var F=I[E],V=0,U=x-1;(F!==0||V>>0,T[U]=F%a>>>0,F=F/a>>>0;if(F!==0)throw new Error("Non-zero carry");d=V,E++}for(var g=x-d;g!==x&&T[g]===0;)g++;for(var v=c.repeat(w);g>>0,x=new Uint8Array(C);I[w];){var T=t[I.charCodeAt(w)];if(T===255)return;for(var F=0,V=C-1;(T!==0||F>>0,x[V]=T%256>>>0,T=T/256>>>0;if(T!==0)throw new Error("Non-zero carry");E=F,w++}if(I[w]!==" "){for(var U=C-E;U!==C&&x[U]===0;)U++;for(var g=new Uint8Array(d+(C-U)),v=d;U!==C;)g[v++]=x[U++];return g}}}function b(I){var w=h(I);if(w)return w;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:h,decode:b}}var Ff=Pf,Of=Ff,La=Of;var Si=class{name;prefix;baseEncode;constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Ii=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Va(this,e)}},ki=class{decoders;constructor(e){this.decoders=e}or(e){return Va(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Va(r,e){return new ki({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var Ci=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new Si(e,t,n),this.decoder=new Ii(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function cr({name:r,prefix:e,encode:t,decode:n}){return new Ci(r,e,t,n)}function kt({name:r,prefix:e,alphabet:t}){let{encode:n,decode:o}=La(t,r);return cr({prefix:e,name:r,encode:n,decode:i=>ft(o(i))})}function Df(r,e,t,n){let o={};for(let u=0;u=8&&(a-=8,s[f++]=255&c>>a)}if(a>=t||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s}function Mf(r,e,t){let n=e[e.length-1]==="=",o=(1<t;)s-=t,i+=e[o&a>>s];if(s!==0&&(i+=e[o&a<re,base58flickr:()=>Wf});var re=kt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Wf=kt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ri={};Ie(Ri,{base64:()=>Ui,base64pad:()=>Jf,base64url:()=>Yf,base64urlpad:()=>Xf});var Ui=se({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Jf=se({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Yf=se({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Xf=se({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function Qf(r,e){try{if(typeof r=="string"&&r.length>0)return eh(r);if(typeof r=="number"&&isFinite(r))return e?.long?rh(r):th(r);throw new Error("Value is not a string or number.")}catch(t){let n=nh(t)?`${t.message}. value=${JSON.stringify(r)}`:"An unknown error has occured.";throw new Error(n)}}function eh(r){if(r=String(r),r.length>100)throw new Error("Value exceeds the maximum length of 100 characters.");let e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(r);if(!e)return NaN;let t=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return t*315576e5;case"weeks":case"week":case"w":return t*6048e5;case"days":case"day":case"d":return t*864e5;case"hours":case"hour":case"hrs":case"hr":case"h":return t*36e5;case"minutes":case"minute":case"mins":case"min":case"m":return t*6e4;case"seconds":case"second":case"secs":case"sec":case"s":return t*1e3;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:throw new Error(`The unit ${n} was matched, but no matching case exists.`)}}var Nn=Qf;function th(r){let e=Math.abs(r);return e>=864e5?`${Math.round(r/864e5)}d`:e>=36e5?`${Math.round(r/36e5)}h`:e>=6e4?`${Math.round(r/6e4)}m`:e>=1e3?`${Math.round(r/1e3)}s`:`${r}ms`}function rh(r){let e=Math.abs(r);return e>=864e5?Tn(r,e,864e5,"day"):e>=36e5?Tn(r,e,36e5,"hour"):e>=6e4?Tn(r,e,6e4,"minute"):e>=1e3?Tn(r,e,1e3,"second"):`${r} ms`}function Tn(r,e,t,n){let o=e>=t*1.5;return`${Math.round(r/t)} ${n}${o?"s":""}`}function nh(r){return typeof r=="object"&&r!==null&&"message"in r}function _i(r){t.debug=t,t.default=t,t.coerce=c,t.disable=i,t.enable=o,t.enabled=s,t.humanize=Nn,t.destroy=f,Object.keys(r).forEach(u=>{t[u]=r[u]}),t.names=[],t.skips=[],t.formatters={};function e(u){let l=0;for(let h=0;h{if(V==="%%")return"%";T++;let g=t.formatters[U];if(typeof g=="function"){let v=d[T];V=g.call(E,v),d.splice(T,1),T--}return V}),t.formatArgs.call(E,d),(E.log||t.log).apply(E,d)}return w.namespace=u,w.useColors=t.useColors(),w.color=t.selectColor(u),w.extend=n,w.destroy=t.destroy,Object.defineProperty(w,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:(b!==t.namespaces&&(b=t.namespaces,I=t.enabled(u)),I),set:d=>{h=d}}),typeof t.init=="function"&&t.init(w),w}function n(u,l){let h=t(this.namespace+(typeof l>"u"?":":l)+u);return h.log=this.log,h}function o(u){t.save(u),t.namespaces=u,t.names=[],t.skips=[];let l,h=(typeof u=="string"?u:"").split(/[\s,]+/),b=h.length;for(l=0;l"-"+l)].join(",");return t.enable(""),u}function s(u){if(u[u.length-1]==="*")return!0;let l,h;for(l=0,h=t.skips.length;l=31||typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/applewebkit\/(\d+)/)}function sh(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+Nn(this.diff),!this.useColors)return;let e="color: "+this.color;r.splice(1,0,e,"color: inherit");let t=0,n=0;r[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(t++,o==="%c"&&(n=t))}),r.splice(n,0,e)}var ah=console.debug??console.log??(()=>{});function ch(r){try{r?Un?.setItem("debug",r):Un?.removeItem("debug")}catch{}}function uh(){let r;try{r=Un?.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function lh(){try{return localStorage}catch{}}function fh(r){r.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}}var Pa=_i({formatArgs:sh,save:ch,load:uh,useColors:ih,setupFormatters:fh,colors:oh,storage:Un,log:ah});var Ve=Pa;Ve.formatters.b=r=>r==null?"undefined":re.baseEncode(r);Ve.formatters.t=r=>r==null?"undefined":ze.baseEncode(r);Ve.formatters.m=r=>r==null?"undefined":Ui.baseEncode(r);Ve.formatters.p=r=>r==null?"undefined":r.toString();Ve.formatters.c=r=>r==null?"undefined":r.toString();Ve.formatters.k=r=>r==null?"undefined":r.toString();Ve.formatters.a=r=>r==null?"undefined":r.toString();function hh(r){let e=()=>{};return e.enabled=!1,e.color="",e.diff=0,e.log=()=>{},e.namespace=r,e.destroy=()=>!0,e.extend=()=>e,e}function Ct(r){let e=hh(`${r}:trace`);return Ve.enabled(`${r}:trace`)&&Ve.names.map(t=>t.toString()).find(t=>t.includes(":trace"))!=null&&(e=Ve(`${r}:trace`)),Object.assign(Ve(r),{error:Ve(`${r}:error`),trace:e})}var dh=Da,Fa=128,ph=127,mh=~ph,gh=Math.pow(2,31);function Da(r,e,t){e=e||[],t=t||0;for(var n=t;r>=gh;)e[t++]=r&255|Fa,r/=128;for(;r&mh;)e[t++]=r&255|Fa,r>>>=7;return e[t]=r|0,Da.bytes=t-n+1,e}var yh=Li,wh=128,Oa=127;function Li(r,n){var t=0,n=n||0,o=0,i=n,s,a=r.length;do{if(i>=a)throw Li.bytes=0,new RangeError("Could not decode varint");s=r[i++],t+=o<28?(s&Oa)<=wh);return Li.bytes=i-n,t}var xh=Math.pow(2,7),bh=Math.pow(2,14),vh=Math.pow(2,21),Eh=Math.pow(2,28),Bh=Math.pow(2,35),Ah=Math.pow(2,42),Sh=Math.pow(2,49),Ih=Math.pow(2,56),kh=Math.pow(2,63),Ch=function(r){return r{let[l,h]=Kr(e.subarray(t));return t+=h,l},o=n(),i=qr;if(o===18?(o=0,t=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=t,a=n(),c=n(),f=t+c,u=f-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:u,size:f}}static parse(e,t){let[n,o]=Uh(e,t),i=r.decode(o);if(i.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Vi(i).set(n,e),i}};function Uh(r,e){switch(r[0]){case"Q":{let t=e??re;return[re.prefix,t.decode(`${re.prefix}${r}`)]}case re.prefix:{let t=e??re;return[re.prefix,t.decode(r)]}case ze.prefix:{let t=e??ze;return[ze.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}function Rh(r,e,t){let{prefix:n}=t;if(n!==re.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let i=t.encode(r).slice(1);return e.set(n,i),i}else return o}function _h(r,e,t){let{prefix:n}=t,o=e.get(n);if(o==null){let i=t.encode(r);return e.set(n,i),i}else return o}var qr=112,Lh=18;function Ka(r,e,t){let n=lr(r),o=n+lr(e),i=new Uint8Array(o+t.byteLength);return ur(r,i,0),ur(e,i,n),i.set(t,o),i}var Vh=Symbol.for("@ipld/js-cid/CID");var Pi={};Ie(Pi,{identity:()=>dt});var qa=0,Ph="identity",za=ft;function Fh(r){return je(qa,za(r))}var dt={code:qa,name:Ph,encode:za,digest:Fh};function ue(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t0&&!e.includes(r.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${r.length}`)}function Ga(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");ja(r.outputLen),ja(r.blockLen)}function dr(r,e=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(e&&r.finished)throw new Error("Hash#digest() has already been called")}function Za(r,e){hr(r);let t=e.outputLen;if(r.lengthnew DataView(r.buffer,r.byteOffset,r.byteLength),Ge=(r,e)=>r<<32-e|r>>>e;var Gm=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Wa(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function zr(r){return typeof r=="string"&&(r=Wa(r)),hr(r),r}function Fi(...r){let e=0;for(let n=0;nr().update(zr(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function Vn(r=32){if(zt&&typeof zt.getRandomValues=="function")return zt.getRandomValues(new Uint8Array(r));if(zt&&typeof zt.randomBytes=="function")return zt.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function Dh(r,e,t,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,n);let o=BigInt(32),i=BigInt(4294967295),s=Number(t>>o&i),a=Number(t&i),c=n?4:0,f=n?0:4;r.setUint32(e+c,s,n),r.setUint32(e+f,a,n)}var Ja=(r,e,t)=>r&e^~r&t,Ya=(r,e,t)=>r&e^r&t^e&t,mr=class extends pr{constructor(e,t,n,o){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=_n(this.buffer)}update(e){dr(this);let{view:t,buffer:n,blockLen:o}=this;e=zr(e);let i=e.length;for(let s=0;so-s&&(this.process(n,0),s=0);for(let l=s;lu.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l>Oi&Pn)}:{h:Number(r>>Oi&Pn)|0,l:Number(r&Pn)|0}}function Mh(r,e=!1){let t=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let o=0;oBigInt(r>>>0)<>>0),$h=(r,e,t)=>r>>>t,Kh=(r,e,t)=>r<<32-t|e>>>t,qh=(r,e,t)=>r>>>t|e<<32-t,zh=(r,e,t)=>r<<32-t|e>>>t,jh=(r,e,t)=>r<<64-t|e>>>t-32,Gh=(r,e,t)=>r>>>t-32|e<<64-t,Zh=(r,e)=>e,Wh=(r,e)=>r,Jh=(r,e,t)=>r<>>32-t,Yh=(r,e,t)=>e<>>32-t,Xh=(r,e,t)=>e<>>64-t,Qh=(r,e,t)=>r<>>64-t;function ed(r,e,t,n){let o=(e>>>0)+(n>>>0);return{h:r+t+(o/2**32|0)|0,l:o|0}}var td=(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),rd=(r,e,t,n)=>e+t+n+(r/2**32|0)|0,nd=(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),od=(r,e,t,n,o)=>e+t+n+o+(r/2**32|0)|0,id=(r,e,t,n,o)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(o>>>0),sd=(r,e,t,n,o,i)=>e+t+n+o+i+(r/2**32|0)|0;var ad={fromBig:Xa,split:Mh,toBig:Hh,shrSH:$h,shrSL:Kh,rotrSH:qh,rotrSL:zh,rotrBH:jh,rotrBL:Gh,rotr32H:Zh,rotr32L:Wh,rotlSH:Jh,rotlSL:Yh,rotlBH:Xh,rotlBL:Qh,add:ed,add3L:td,add3H:rd,add4L:nd,add4H:od,add5H:sd,add5L:id},K=ad;var[cd,ud]=K.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),Nt=new Uint32Array(80),Ut=new Uint32Array(80),Di=class extends mr{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:e,Al:t,Bh:n,Bl:o,Ch:i,Cl:s,Dh:a,Dl:c,Eh:f,El:u,Fh:l,Fl:h,Gh:b,Gl:I,Hh:w,Hl:d}=this;return[e,t,n,o,i,s,a,c,f,u,l,h,b,I,w,d]}set(e,t,n,o,i,s,a,c,f,u,l,h,b,I,w,d){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=u|0,this.Fh=l|0,this.Fl=h|0,this.Gh=b|0,this.Gl=I|0,this.Hh=w|0,this.Hl=d|0}process(e,t){for(let x=0;x<16;x++,t+=4)Nt[x]=e.getUint32(t),Ut[x]=e.getUint32(t+=4);for(let x=16;x<80;x++){let T=Nt[x-15]|0,F=Ut[x-15]|0,V=K.rotrSH(T,F,1)^K.rotrSH(T,F,8)^K.shrSH(T,F,7),U=K.rotrSL(T,F,1)^K.rotrSL(T,F,8)^K.shrSL(T,F,7),g=Nt[x-2]|0,v=Ut[x-2]|0,O=K.rotrSH(g,v,19)^K.rotrBH(g,v,61)^K.shrSH(g,v,6),R=K.rotrSL(g,v,19)^K.rotrBL(g,v,61)^K.shrSL(g,v,6),N=K.add4L(U,R,Ut[x-7],Ut[x-16]),$=K.add4H(N,V,O,Nt[x-7],Nt[x-16]);Nt[x]=$|0,Ut[x]=N|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:f,Dl:u,Eh:l,El:h,Fh:b,Fl:I,Gh:w,Gl:d,Hh:E,Hl:C}=this;for(let x=0;x<80;x++){let T=K.rotrSH(l,h,14)^K.rotrSH(l,h,18)^K.rotrBH(l,h,41),F=K.rotrSL(l,h,14)^K.rotrSL(l,h,18)^K.rotrBL(l,h,41),V=l&b^~l&w,U=h&I^~h&d,g=K.add5L(C,F,U,ud[x],Ut[x]),v=K.add5H(g,E,T,V,cd[x],Nt[x]),O=g|0,R=K.rotrSH(n,o,28)^K.rotrBH(n,o,34)^K.rotrBH(n,o,39),N=K.rotrSL(n,o,28)^K.rotrBL(n,o,34)^K.rotrBL(n,o,39),$=n&i^n&a^i&a,A=o&s^o&c^s&c;E=w|0,C=d|0,w=b|0,d=I|0,b=l|0,I=h|0,{h:l,l:h}=K.add(f|0,u|0,v|0,O|0),f=a|0,u=c|0,a=i|0,c=s|0,i=n|0,s=o|0;let S=K.add3L(O,N,A);n=K.add3H(S,v,R,$),o=S|0}({h:n,l:o}=K.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=K.add(this.Bh|0,this.Bl|0,i|0,s|0),{h:a,l:c}=K.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:u}=K.add(this.Dh|0,this.Dl|0,f|0,u|0),{h:l,l:h}=K.add(this.Eh|0,this.El|0,l|0,h|0),{h:b,l:I}=K.add(this.Fh|0,this.Fl|0,b|0,I|0),{h:w,l:d}=K.add(this.Gh|0,this.Gl|0,w|0,d|0),{h:E,l:C}=K.add(this.Hh|0,this.Hl|0,E|0,C|0),this.set(n,o,i,s,a,c,f,u,l,h,b,I,w,d,E,C)}roundClean(){Nt.fill(0),Ut.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var Qa=Ln(()=>new Di);var On={};Ie(On,{aInRange:()=>Ue,abool:()=>Ze,abytes:()=>gr,bitGet:()=>md,bitLen:()=>qi,bitMask:()=>Gr,bitSet:()=>gd,bytesToHex:()=>mt,bytesToNumberBE:()=>gt,bytesToNumberLE:()=>_t,concatBytes:()=>yt,createHmacDrbg:()=>zi,ensureBytes:()=>ae,equalBytes:()=>dd,hexToBytes:()=>Gt,hexToNumber:()=>Ki,inRange:()=>jr,isBytes:()=>Rt,memoized:()=>Wt,notImplemented:()=>wd,numberToBytesBE:()=>Lt,numberToBytesLE:()=>Zt,numberToHexUnpadded:()=>jt,numberToVarBytesBE:()=>hd,utf8ToBytes:()=>pd,validateObject:()=>ot});var $i=BigInt(0),Fn=BigInt(1),ld=BigInt(2);function Rt(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function gr(r){if(!Rt(r))throw new Error("Uint8Array expected")}function Ze(r,e){if(typeof e!="boolean")throw new Error(`${r} must be valid boolean, got "${e}".`)}var fd=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function mt(r){gr(r);let e="";for(let t=0;t=pt._0&&r<=pt._9)return r-pt._0;if(r>=pt._A&&r<=pt._F)return r-(pt._A-10);if(r>=pt._a&&r<=pt._f)return r-(pt._a-10)}function Gt(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let e=r.length,t=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(t);for(let o=0,i=0;otypeof r=="bigint"&&$i<=r;function jr(r,e,t){return Mi(r)&&Mi(e)&&Mi(t)&&e<=r&&r$i;r>>=Fn,e+=1);return e}function md(r,e){return r>>BigInt(e)&Fn}function gd(r,e,t){return r|(t?Fn:$i)<(ld<new Uint8Array(r),tc=r=>Uint8Array.from(r);function zi(r,e,t){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");let n=Hi(r),o=Hi(r),i=0,s=()=>{n.fill(1),o.fill(0),i=0},a=(...l)=>t(o,n,...l),c=(l=Hi())=>{o=a(tc([0]),l),n=a(),l.length!==0&&(o=a(tc([1]),l),n=a())},f=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,h=[];for(;l{s(),c(l);let b;for(;!(b=h(f()));)c();return s(),b}}var yd={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||Rt(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,e)=>e.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function ot(r,e,t={}){let n=(o,i,s)=>{let a=yd[i];if(typeof a!="function")throw new Error(`Invalid validator "${i}", expected function`);let c=r[o];if(!(s&&c===void 0)&&!a(c,r))throw new Error(`Invalid param ${String(o)}=${c} (${typeof c}), expected ${i}`)};for(let[o,i]of Object.entries(e))n(o,i,!1);for(let[o,i]of Object.entries(t))n(o,i,!0);return r}var wd=()=>{throw new Error("not implemented")};function Wt(r){let e=new WeakMap;return(t,...n)=>{let o=e.get(t);if(o!==void 0)return o;let i=r(t,...n);return e.set(t,i),i}}var le=BigInt(0),ne=BigInt(1),Jt=BigInt(2),xd=BigInt(3),ji=BigInt(4),rc=BigInt(5),nc=BigInt(8),bd=BigInt(9),vd=BigInt(16);function Q(r,e){let t=r%e;return t>=le?t:e+t}function Ed(r,e,t){if(t<=le||e 0");if(t===ne)return le;let n=ne;for(;e>le;)e&ne&&(n=n*r%t),r=r*r%t,e>>=ne;return n}function oe(r,e,t){let n=r;for(;e-- >le;)n*=n,n%=t;return n}function Dn(r,e){if(r===le||e<=le)throw new Error(`invert: expected positive integers, got n=${r} mod=${e}`);let t=Q(r,e),n=e,o=le,i=ne,s=ne,a=le;for(;t!==le;){let f=n/t,u=n%t,l=o-s*f,h=i-a*f;n=t,t=u,o=s,i=a,s=l,a=h}if(n!==ne)throw new Error("invert: does not exist");return Q(o,e)}function Bd(r){let e=(r-ne)/Jt,t,n,o;for(t=r-ne,n=0;t%Jt===le;t/=Jt,n++);for(o=Jt;o(Q(r,e)&ne)===ne,Sd=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Gi(r){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=Sd.reduce((n,o)=>(n[o]="function",n),e);return ot(r,t)}function Id(r,e,t){if(t 0");if(t===le)return r.ONE;if(t===ne)return e;let n=r.ONE,o=e;for(;t>le;)t&ne&&(n=r.mul(n,o)),o=r.sqr(o),t>>=ne;return n}function kd(r,e){let t=new Array(e.length),n=e.reduce((i,s,a)=>r.is0(s)?i:(t[a]=i,r.mul(i,s)),r.ONE),o=r.inv(n);return e.reduceRight((i,s,a)=>r.is0(s)?i:(t[a]=r.mul(i,t[a]),r.mul(i,s)),o),t}function Zi(r,e){let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function Vt(r,e,t=!1,n={}){if(r<=le)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:o,nByteLength:i}=Zi(r,e);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");let s=Ad(r),a=Object.freeze({ORDER:r,BITS:o,BYTES:i,MASK:Gr(o),ZERO:le,ONE:ne,create:c=>Q(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return le<=c&&cc===le,isOdd:c=>(c&ne)===ne,neg:c=>Q(-c,r),eql:(c,f)=>c===f,sqr:c=>Q(c*c,r),add:(c,f)=>Q(c+f,r),sub:(c,f)=>Q(c-f,r),mul:(c,f)=>Q(c*f,r),pow:(c,f)=>Id(a,c,f),div:(c,f)=>Q(c*Dn(f,r),r),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>Dn(c,r),sqrt:n.sqrt||(c=>s(a,c)),invertBatch:c=>kd(a,c),cmov:(c,f,u)=>u?f:c,toBytes:c=>t?Zt(c,i):Lt(c,i),fromBytes:c=>{if(c.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${c.length}`);return t?_t(c):gt(c)}});return Object.freeze(a)}function ic(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let e=r.toString(2).length;return Math.ceil(e/8)}function Wi(r){let e=ic(r);return e+Math.ceil(e/2)}function sc(r,e,t=!1){let n=r.length,o=ic(e),i=Wi(e);if(n<16||n1024)throw new Error(`expected ${i}-1024 bytes of input, got ${n}`);let s=t?gt(r):_t(r),a=Q(s,e-ne)+ne;return t?Zt(a,o):Lt(a,o)}var Td=BigInt(0),Ji=BigInt(1),Yi=new WeakMap,ac=new WeakMap;function Mn(r,e){let t=(i,s)=>{let a=s.negate();return i?a:s},n=i=>{if(!Number.isSafeInteger(i)||i<=0||i>e)throw new Error(`Wrong window size=${i}, should be [1..${e}]`)},o=i=>{n(i);let s=Math.ceil(e/i)+1,a=2**(i-1);return{windows:s,windowSize:a}};return{constTimeNegate:t,unsafeLadder(i,s){let a=r.ZERO,c=i;for(;s>Td;)s&Ji&&(a=a.add(c)),c=c.double(),s>>=Ji;return a},precomputeWindow(i,s){let{windows:a,windowSize:c}=o(s),f=[],u=i,l=u;for(let h=0;h>=I,E>f&&(E-=b,a+=Ji);let C=d,x=d+Math.abs(E)-1,T=w%2!==0,F=E<0;E===0?l=l.add(t(T,s[C])):u=u.add(t(F,s[x]))}return{p:u,f:l}},wNAFCached(i,s,a){let c=ac.get(i)||1,f=Yi.get(i);return f||(f=this.precomputeWindow(i,c),c!==1&&Yi.set(i,a(f))),this.wNAF(c,f,s)},setWindowSize(i,s){n(s),ac.set(i,s),Yi.delete(i)}}}function Hn(r,e,t,n){if(!Array.isArray(t)||!Array.isArray(n)||n.length!==t.length)throw new Error("arrays of points and scalars must have equal length");n.forEach((u,l)=>{if(!e.isValid(u))throw new Error(`wrong scalar at index ${l}`)}),t.forEach((u,l)=>{if(!(u instanceof r))throw new Error(`wrong point at index ${l}`)});let o=qi(BigInt(t.length)),i=o>12?o-3:o>4?o-2:o?2:1,s=(1<=0;u-=i){a.fill(r.ZERO);for(let h=0;h>BigInt(u)&BigInt(s));a[I]=a[I].add(t[h])}let l=r.ZERO;for(let h=a.length-1,b=r.ZERO;h>0;h--)b=b.add(a[h]),l=l.add(b);if(f=f.add(l),u!==0)for(let h=0;h{try{return{isValid:!0,value:t.sqrt(m*t.inv(p))}}catch{return{isValid:!1,value:We}}}),b=e.adjustScalarBytes||(m=>m),I=e.domain||((m,p,B)=>{if(Ze("phflag",B),p.length||B)throw new Error("Contexts/pre-hash are not supported");return m});function w(m,p){Ue("coordinate "+m,p,We,f)}function d(m){if(!(m instanceof x))throw new Error("ExtendedPoint expected")}let E=Wt((m,p)=>{let{ex:B,ey:P,ez:D}=m,M=m.is0();p==null&&(p=M?Nd:t.inv(D));let q=u(B*p),G=u(P*p),z=u(D*p);if(M)return{x:We,y:Re};if(z!==Re)throw new Error("invZ was invalid");return{x:q,y:G}}),C=Wt(m=>{let{a:p,d:B}=e;if(m.is0())throw new Error("bad point: ZERO");let{ex:P,ey:D,ez:M,et:q}=m,G=u(P*P),z=u(D*D),X=u(M*M),te=u(X*X),he=u(G*p),de=u(X*u(he+z)),ge=u(te+u(B*u(G*z)));if(de!==ge)throw new Error("bad point: equation left != right (1)");let Se=u(P*D),ce=u(M*q);if(Se!==ce)throw new Error("bad point: equation left != right (2)");return!0});class x{constructor(p,B,P,D){this.ex=p,this.ey=B,this.ez=P,this.et=D,w("x",p),w("y",B),w("z",P),w("t",D),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(p){if(p instanceof x)throw new Error("extended point not allowed");let{x:B,y:P}=p||{};return w("x",B),w("y",P),new x(B,P,Re,u(B*P))}static normalizeZ(p){let B=t.invertBatch(p.map(P=>P.ez));return p.map((P,D)=>P.toAffine(B[D])).map(x.fromAffine)}static msm(p,B){return Hn(x,l,p,B)}_setWindowSize(p){V.setWindowSize(this,p)}assertValidity(){C(this)}equals(p){d(p);let{ex:B,ey:P,ez:D}=this,{ex:M,ey:q,ez:G}=p,z=u(B*G),X=u(M*D),te=u(P*G),he=u(q*D);return z===X&&te===he}is0(){return this.equals(x.ZERO)}negate(){return new x(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:p}=e,{ex:B,ey:P,ez:D}=this,M=u(B*B),q=u(P*P),G=u($n*u(D*D)),z=u(p*M),X=B+P,te=u(u(X*X)-M-q),he=z+q,de=he-G,ge=z-q,Se=u(te*de),ce=u(he*ge),Ne=u(te*ge),lt=u(de*he);return new x(Se,ce,lt,Ne)}add(p){d(p);let{a:B,d:P}=e,{ex:D,ey:M,ez:q,et:G}=this,{ex:z,ey:X,ez:te,et:he}=p;if(B===BigInt(-1)){let ba=u((M-D)*(X+z)),va=u((M+D)*(X-z)),Ei=u(va-ba);if(Ei===We)return this.double();let Ea=u(q*$n*he),Ba=u(G*$n*te),Aa=Ba+Ea,Sa=va+ba,Ia=Ba-Ea,If=u(Aa*Ei),kf=u(Sa*Ia),Cf=u(Aa*Ia),Tf=u(Ei*Sa);return new x(If,kf,Tf,Cf)}let de=u(D*z),ge=u(M*X),Se=u(G*P*he),ce=u(q*te),Ne=u((D+M)*(z+X)-de-ge),lt=ce-Se,Mr=ce+Se,Hr=u(ge-B*de),Ef=u(Ne*lt),Bf=u(Mr*Hr),Af=u(Ne*Hr),Sf=u(lt*Mr);return new x(Ef,Bf,Sf,Af)}subtract(p){return this.add(p.negate())}wNAF(p){return V.wNAFCached(this,p,x.normalizeZ)}multiply(p){let B=p;Ue("scalar",B,Re,n);let{p:P,f:D}=this.wNAF(B);return x.normalizeZ([P,D])[0]}multiplyUnsafe(p){let B=p;return Ue("scalar",B,We,n),B===We?F:this.equals(F)||B===Re?this:this.equals(T)?this.wNAF(B).p:V.unsafeLadder(this,B)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return V.unsafeLadder(this,n).is0()}toAffine(p){return E(this,p)}clearCofactor(){let{h:p}=e;return p===Re?this:this.multiplyUnsafe(p)}static fromHex(p,B=!1){let{d:P,a:D}=e,M=t.BYTES;p=ae("pointHex",p,M),Ze("zip215",B);let q=p.slice(),G=p[M-1];q[M-1]=G&-129;let z=_t(q),X=B?f:t.ORDER;Ue("pointHex.y",z,We,X);let te=u(z*z),he=u(te-Re),de=u(P*te-D),{isValid:ge,value:Se}=h(he,de);if(!ge)throw new Error("Point.fromHex: invalid y coordinate");let ce=(Se&Re)===Re,Ne=(G&128)!==0;if(!B&&Se===We&&Ne)throw new Error("Point.fromHex: x=0 and x_0=1");return Ne!==ce&&(Se=u(-Se)),x.fromAffine({x:Se,y:z})}static fromPrivateKey(p){return v(p).point}toRawBytes(){let{x:p,y:B}=this.toAffine(),P=Zt(B,t.BYTES);return P[P.length-1]|=p&Re?128:0,P}toHex(){return mt(this.toRawBytes())}}x.BASE=new x(e.Gx,e.Gy,Re,u(e.Gx*e.Gy)),x.ZERO=new x(We,Re,Re,We);let{BASE:T,ZERO:F}=x,V=Mn(x,a*8);function U(m){return Q(m,n)}function g(m){return U(_t(m))}function v(m){let p=a;m=ae("private key",m,p);let B=ae("hashed private key",i(m),2*p),P=b(B.slice(0,p)),D=B.slice(p,2*p),M=g(P),q=T.multiply(M),G=q.toRawBytes();return{head:P,prefix:D,scalar:M,point:q,pointBytes:G}}function O(m){return v(m).pointBytes}function R(m=new Uint8Array,...p){let B=yt(...p);return g(i(I(B,ae("context",m),!!o)))}function N(m,p,B={}){m=ae("message",m),o&&(m=o(m));let{prefix:P,scalar:D,pointBytes:M}=v(p),q=R(B.context,P,m),G=T.multiply(q).toRawBytes(),z=R(B.context,G,M,m),X=U(q+z*D);Ue("signature.s",X,We,n);let te=yt(G,Zt(X,t.BYTES));return ae("result",te,a*2)}let $=Ud;function A(m,p,B,P=$){let{context:D,zip215:M}=P,q=t.BYTES;m=ae("signature",m,2*q),p=ae("message",p),M!==void 0&&Ze("zip215",M),o&&(p=o(p));let G=_t(m.slice(q,2*q)),z,X,te;try{z=x.fromHex(B,M),X=x.fromHex(m.slice(0,q),M),te=T.multiplyUnsafe(G)}catch{return!1}if(!M&&z.isSmallOrder())return!1;let he=R(D,X.toRawBytes(),z.toRawBytes(),p);return X.add(z.multiplyUnsafe(he)).subtract(te).clearCofactor().equals(x.ZERO)}return T._setWindowSize(8),{CURVE:e,getPublicKey:O,sign:N,verify:A,ExtendedPoint:x,utils:{getExtendedPublicKey:v,randomPrivateKey:()=>s(t.BYTES),precompute(m=8,p=x.BASE){return p._setWindowSize(m),p.multiply(BigInt(3)),p}}}}var Xi=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),uc=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),yg=BigInt(0),_d=BigInt(1),lc=BigInt(2),wg=BigInt(3),Ld=BigInt(5),Vd=BigInt(8);function Pd(r){let e=BigInt(10),t=BigInt(20),n=BigInt(40),o=BigInt(80),i=Xi,a=r*r%i*r%i,c=oe(a,lc,i)*a%i,f=oe(c,_d,i)*r%i,u=oe(f,Ld,i)*f%i,l=oe(u,e,i)*u%i,h=oe(l,t,i)*l%i,b=oe(h,n,i)*h%i,I=oe(b,o,i)*b%i,w=oe(I,o,i)*b%i,d=oe(w,e,i)*u%i;return{pow_p_5_8:oe(d,lc,i)*r%i,b2:a}}function Fd(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Od(r,e){let t=Xi,n=Q(e*e*e,t),o=Q(n*n*e,t),i=Pd(r*o).pow_p_5_8,s=Q(r*n*i,t),a=Q(e*s*s,t),c=s,f=Q(s*uc,t),u=a===r,l=a===Q(-r,t),h=a===Q(-r*uc,t);return u&&(s=c),(l||h)&&(s=f),oc(s,t)&&(s=Q(-s,t)),{isValid:u||l,value:s}}var Dd=Vt(Xi,void 0,!0),Md={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Dd,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Vd,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Qa,randomBytes:Vn,adjustScalarBytes:Fd,uvRatio:Od},fc=cc(Md);var Kn=32;function hc(r,e,t){return fc.verify(e,t instanceof Uint8Array?t:t.subarray(),r)}var qn=class{type="Ed25519";raw;constructor(e){this.raw=Qi(e,Kn)}toMultihash(){return dt.digest(zn(this))}toCID(){return ie.createV1(114,this.toMultihash())}toString(){return re.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ue(this.raw,e.raw)}verify(e,t){return hc(this.raw,t,e)}};function es(r){return r=Qi(r,Kn),new qn(r)}function Qi(r,e){if(r=Uint8Array.from(r??[]),r.length!==e)throw new be(`Key must be a Uint8Array of length ${e}, got ${r.length}`);return r}function Je(r=0){return new Uint8Array(r)}var $d=Math.pow(2,7),Kd=Math.pow(2,14),qd=Math.pow(2,21),ts=Math.pow(2,28),rs=Math.pow(2,35),ns=Math.pow(2,42),os=Math.pow(2,49),J=128,ve=127;function _e(r){if(r<$d)return 1;if(rNumber.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function is(r,e,t=0){switch(_e(r)){case 8:e[t++]=r&255|J,r/=128;case 7:e[t++]=r&255|J,r/=128;case 6:e[t++]=r&255|J,r/=128;case 5:e[t++]=r&255|J,r/=128;case 4:e[t++]=r&255|J,r>>>=7;case 3:e[t++]=r&255|J,r>>>=7;case 2:e[t++]=r&255|J,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function zd(r,e,t=0){switch(_e(r)){case 8:e.set(t++,r&255|J),r/=128;case 7:e.set(t++,r&255|J),r/=128;case 6:e.set(t++,r&255|J),r/=128;case 5:e.set(t++,r&255|J),r/=128;case 4:e.set(t++,r&255|J),r>>>=7;case 3:e.set(t++,r&255|J),r>>>=7;case 2:e.set(t++,r&255|J),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function ss(r,e){let t=r[e],n=0;if(n+=t&ve,t>>31>0){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(t+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(BigInt(t)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?t===0?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return Xt;if(eZd)return this.fromNumber(Number(e));let t=e<0n;t&&(e=-e);let n=e>>32n,o=e-(n<<32n);return t&&(n=~n|0n,o=~o|0n,++o>xc&&(o=0n,++n>xc&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(e){if(e===0)return Xt;let t=e<0;t&&(e=-e);let n=e>>>0,o=(e-n)/4294967296>>>0;return t&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)}static from(e){return typeof e=="number"?r.fromNumber(e):typeof e=="bigint"?r.fromBigInt(e):typeof e=="string"?r.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new r(e.low>>>0,e.high>>>0):Xt}},Xt=new Pe(0,0);Xt.toBigInt=function(){return 0n};Xt.zzEncode=Xt.zzDecode=function(){return this};Xt.length=function(){return 1};var xc=4294967296n;function bc(r){let e=0,t=0;for(let n=0;n191&&a<224?i[s++]=(a&31)<<6|r[e++]&63:a>239&&a<365?(a=((a&7)<<18|(r[e++]&63)<<12|(r[e++]&63)<<6|r[e++]&63)-65536,i[s++]=55296+(a>>10),i[s++]=56320+(a&1023)):i[s++]=(a&15)<<12|(r[e++]&63)<<6|r[e++]&63,s>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o!=null?(s>0&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function us(r,e,t){let n=t,o,i;for(let s=0;s>6|192,e[t++]=o&63|128):(o&64512)===55296&&((i=r.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,e[t++]=o>>18|240,e[t++]=o>>12&63|128,e[t++]=o>>6&63|128,e[t++]=o&63|128):(e[t++]=o>>12|224,e[t++]=o>>6&63|128,e[t++]=o&63|128);return t-n}function Ye(r,e){return RangeError(`index out of range: ${r.pos} + ${e??1} > ${r.len}`)}function jn(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}var ls=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,Ye(this,10);return e}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw Ye(this,4);return jn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Ye(this,4);return jn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Ye(this,4);let e=gc(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw Ye(this,4);let e=wc(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),t=this.pos,n=this.pos+e;if(n>this.len)throw Ye(this,e);return this.pos+=e,t===n?new Uint8Array(0):this.buf.subarray(t,n)}string(){let e=this.bytes();return vc(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw Ye(this,e);this.pos+=e}else do if(this.pos>=this.len)throw Ye(this);while(this.buf[this.pos++]&128);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new Pe(0,0),t=0;if(this.len-this.pos>4){for(;t<4;++t)if(e.lo=(e.lo|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;t=0}else{for(;t<3;++t){if(this.pos>=this.len)throw Ye(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<>>0,e}if(this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw Ye(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Ye(this,8);let e=jn(this.buf,this.pos+=4),t=jn(this.buf,this.pos+=4);return new Pe(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=ss(this.buf,this.pos);return this.pos+=_e(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function fs(r){return new ls(r instanceof Uint8Array?r:r.subarray())}function wr(r,e,t){let n=fs(r);return e.decode(n,void 0,t)}var hs={};Ie(hs,{base10:()=>Wd});var Wd=kt({prefix:"9",name:"base10",alphabet:"0123456789"});var ds={};Ie(ds,{base16:()=>Jd,base16upper:()=>Yd});var Jd=se({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Yd=se({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var ps={};Ie(ps,{base2:()=>Xd});var Xd=se({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var ms={};Ie(ms,{base256emoji:()=>n0});var Bc=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),Qd=Bc.reduce((r,e,t)=>(r[t]=e,r),[]),e0=Bc.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function t0(r){return r.reduce((e,t)=>(e+=Qd[t],e),"")}function r0(r){let e=[];for(let t of r){let n=e0[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var n0=cr({prefix:"\u{1F680}",name:"base256emoji",encode:t0,decode:r0});var gs={};Ie(gs,{base36:()=>Ac,base36upper:()=>o0});var Ac=kt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),o0=kt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ys={};Ie(ys,{base8:()=>i0});var i0=se({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var ws={};Ie(ws,{identity:()=>s0});var s0=cr({prefix:"\0",name:"identity",encode:r=>Ra(r),decode:r=>Ua(r)});var ey=new TextEncoder,ty=new TextDecoder;var vs={};Ie(vs,{sha256:()=>Wr,sha512:()=>u0});function bs({name:r,code:e,encode:t}){return new xs(r,e,t)}var xs=class{name;code;encode;constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?je(this.code,t):t.then(n=>je(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Ic(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var Wr=bs({name:"sha2-256",code:18,encode:Ic("SHA-256")}),u0=bs({name:"sha2-512",code:19,encode:Ic("SHA-512")});var Jr={...ws,...ps,...ys,...hs,...ds,...Ti,...gs,...Ni,...Ri,...ms},dy={...vs,...Pi};function Cc(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var kc=Cc("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Es=Cc("ascii","a",r=>{let e="a";for(let t=0;t{r=r.substring(1);let e=Je(r.length);for(let t=0;t>>1,n,o=e;return function(s){if(s<1||s>t)return Je(s);o+s>e&&(n=Je(e),o=0);let a=n.subarray(o,o+=s);return o&7&&(o=(o|7)+1),a}}var Qt=class{fn;len;next;val;constructor(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}};function As(){}var Is=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},f0=Bs();function h0(r){return globalThis.Buffer!=null?Je(r):f0(r)}var Xr=class{len;head;tail;states;constructor(){this.len=0,this.head=new Qt(As,0,0),this.tail=this.head,this.states=null}_push(e,t,n){return this.tail=this.tail.next=new Qt(e,t,n),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new ks((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(Zn,10,Pe.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=Pe.fromBigInt(e);return this._push(Zn,t.length(),t)}uint64Number(e){return this._push(is,_e(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let t=Pe.fromBigInt(e).zzEncode();return this._push(Zn,t.length(),t)}sint64Number(e){let t=Pe.fromNumber(e).zzEncode();return this._push(Zn,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Ss,1,e?1:0)}fixed32(e){return this._push(Yr,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=Pe.fromBigInt(e);return this._push(Yr,4,t.lo)._push(Yr,4,t.hi)}fixed64Number(e){let t=Pe.fromNumber(e);return this._push(Yr,4,t.lo)._push(Yr,4,t.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(mc,4,e)}double(e){return this._push(yc,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(Ss,1,0):this.uint32(t)._push(p0,t,e)}string(e){let t=bc(e);return t!==0?this.uint32(t)._push(us,t,e):this._push(Ss,1,0)}fork(){return this.states=new Is(this),this.head=this.tail=new Qt(As,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new Qt(As,0,0),this.len=0),this}ldelim(){let e=this.head,t=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=e.next,this.tail=t,this.len+=n),this}finish(){let e=this.head.next,t=h0(this.len),n=0;for(;e!=null;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}};function Ss(r,e,t){e[t]=r&255}function d0(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}var ks=class extends Qt{next;constructor(e,t){super(d0,e,t),this.next=void 0}};function Zn(r,e,t){for(;r.hi!==0;)e[t++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)e[t++]=r.lo&127|128,r.lo=r.lo>>>7;e[t++]=r.lo}function Yr(r,e,t){e[t]=r&255,e[t+1]=r>>>8&255,e[t+2]=r>>>16&255,e[t+3]=r>>>24}function p0(r,e,t){e.set(r,t)}globalThis.Buffer!=null&&(Xr.prototype.bytes=function(r){let e=r.length>>>0;return this.uint32(e),e>0&&this._push(m0,e,r),this},Xr.prototype.string=function(r){let e=globalThis.Buffer.byteLength(r);return this.uint32(e),e>0&&this._push(g0,e,r),this});function m0(r,e,t){e.set(r,t)}function g0(r,e,t){r.length<40?us(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(Y(r),t)}function Cs(){return new Xr}function xr(r,e){let t=Cs();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}var br;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(br||(br={}));function Wn(r,e,t,n){return{name:r,type:e,encode:t,decode:n}}function Qr(r){function e(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let t=function(i,s){let a=e(i);s.int32(a)},n=function(i){let s=i.int32();return e(s)};return Wn("enum",br.VARINT,t,n)}function vr(r,e){return Wn("message",br.LENGTH_DELIMITED,r,e)}var fe;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1"})(fe||(fe={}));var Ts;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1"})(Ts||(Ts={}));(function(r){r.codec=()=>Qr(Ts)})(fe||(fe={}));var it;(function(r){let e;r.codec=()=>(e==null&&(e=vr((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),fe.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),o.lengthDelimited!==!1&&n.ldelim()},(t,n,o={})=>{let i={},s=n==null?t.len:t.pos+n;for(;t.pos>>3){case 1:{i.Type=fe.codec().decode(t);break}case 2:{i.Data=t.bytes();break}default:{t.skipType(a&7);break}}}return i})),e),r.encode=t=>xr(t,r.codec()),r.decode=(t,n)=>wr(t,r.codec(),n)})(it||(it={}));var Ns;(function(r){let e;r.codec=()=>(e==null&&(e=vr((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),fe.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),o.lengthDelimited!==!1&&n.ldelim()},(t,n,o={})=>{let i={},s=n==null?t.len:t.pos+n;for(;t.pos>>3){case 1:{i.Type=fe.codec().decode(t);break}case 2:{i.Data=t.bytes();break}default:{t.skipType(a&7);break}}}return i})),e),r.encode=t=>xr(t,r.codec()),r.decode=(t,n)=>wr(t,r.codec(),n)})(Ns||(Ns={}));var ln={};Ie(ln,{MAX_RSA_KEY_SIZE:()=>Ho,generateRSAKeyPair:()=>Su,jwkToJWKKeyPair:()=>Iu,jwkToPkcs1:()=>R0,jwkToPkix:()=>Ds,jwkToRSAPrivateKey:()=>Au,pkcs1ToJwk:()=>vu,pkcs1ToRSAPrivateKey:()=>Bu,pkixToJwk:()=>Eu,pkixToRSAPublicKey:()=>Ms});var y0=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ft=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ot=new Uint32Array(64),Us=class extends mr{constructor(){super(64,32,8,!1),this.A=Ft[0]|0,this.B=Ft[1]|0,this.C=Ft[2]|0,this.D=Ft[3]|0,this.E=Ft[4]|0,this.F=Ft[5]|0,this.G=Ft[6]|0,this.H=Ft[7]|0}get(){let{A:e,B:t,C:n,D:o,E:i,F:s,G:a,H:c}=this;return[e,t,n,o,i,s,a,c]}set(e,t,n,o,i,s,a,c){this.A=e|0,this.B=t|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(e,t){for(let l=0;l<16;l++,t+=4)Ot[l]=e.getUint32(t,!1);for(let l=16;l<64;l++){let h=Ot[l-15],b=Ot[l-2],I=Ge(h,7)^Ge(h,18)^h>>>3,w=Ge(b,17)^Ge(b,19)^b>>>10;Ot[l]=w+Ot[l-7]+I+Ot[l-16]|0}let{A:n,B:o,C:i,D:s,E:a,F:c,G:f,H:u}=this;for(let l=0;l<64;l++){let h=Ge(a,6)^Ge(a,11)^Ge(a,25),b=u+h+Ja(a,c,f)+y0[l]+Ot[l]|0,w=(Ge(n,2)^Ge(n,13)^Ge(n,22))+Ya(n,o,i)|0;u=f,f=c,c=a,a=s+b|0,s=i,i=o,o=n,n=b+w|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(n,o,i,s,a,c,f,u)}roundClean(){Ot.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Er=Ln(()=>new Us);var j=Cn(Nc());function er(r,e){let t=0;if(r.length===1)return r[0];for(let n=r.length-1;n>=0;n--)t+=r[r.length-1-n]*Math.pow(2,e*n);return t}function Dt(r,e,t=-1){let n=t,o=r,i=0,s=Math.pow(2,e);for(let a=1;a<8;a++){if(r=0;u--){let l=Math.pow(2,u*e);f[i-u-1]=Math.floor(o/l),o-=f[i-u-1]*l}return c}s*=Math.pow(2,e)}return new ArrayBuffer(0)}function Xn(...r){let e=0,t=0;for(let i of r)e+=i.length;let n=new ArrayBuffer(e),o=new Uint8Array(n);for(let i of r)o.set(i,t),t+=i.length;return o}function _s(){let r=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){let a=r[0]===255&&r[1]&128,c=r[0]===0&&(r[1]&128)===0;(a||c)&&this.warnings.push("Needlessly long format")}let e=new ArrayBuffer(this.valueHex.byteLength),t=new Uint8Array(e);for(let a=0;a"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function Ls(r){let e=0,t=0;for(let o=0;o=i.length)return this.error="End of input reached before message was fully decoded",-1;if(c===u){u+=255;let h=new Uint8Array(u);for(let b=0;b8)return this.error="Too big integer",-1;if(s+1>i.length)return this.error="End of input reached before message was fully decoded",-1;let a=t+1,c=o.subarray(a,a+s);return c[s-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=er(c,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=s+1,t+this.blockLength}toBER(e=!1){let t,n;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=128),t;if(this.longFormUsed){let o=Dt(this.length,8);if(o.byteLength>127)return this.error="Too big length",Xe;if(t=new ArrayBuffer(o.byteLength+1),e)return t;let i=new Uint8Array(o);n=new Uint8Array(t),n[0]=o.byteLength|128;for(let s=0;s=37&&o.idBlock.isHexOnly===!1)return o.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:o};switch(o.idBlock.tagNumber){case 0:if(o.idBlock.isConstructed&&o.lenBlock.length>0)return o.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:o};c=_.EndOfContent;break;case 1:c=_.Boolean;break;case 2:c=_.Integer;break;case 3:c=_.BitString;break;case 4:c=_.OctetString;break;case 5:c=_.Null;break;case 6:c=_.ObjectIdentifier;break;case 10:c=_.Enumerated;break;case 12:c=_.Utf8String;break;case 13:c=_.RelativeObjectIdentifier;break;case 14:c=_.TIME;break;case 15:return o.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:o};case 16:c=_.Sequence;break;case 17:c=_.Set;break;case 18:c=_.NumericString;break;case 19:c=_.PrintableString;break;case 20:c=_.TeletexString;break;case 21:c=_.VideotexString;break;case 22:c=_.IA5String;break;case 23:c=_.UTCTime;break;case 24:c=_.GeneralizedTime;break;case 25:c=_.GraphicString;break;case 26:c=_.VisibleString;break;case 27:c=_.GeneralString;break;case 28:c=_.UniversalString;break;case 29:c=_.CharacterString;break;case 30:c=_.BmpString;break;case 31:c=_.DATE;break;case 32:c=_.TimeOfDay;break;case 33:c=_.DateTime;break;case 34:c=_.Duration;break;default:{let f=o.idBlock.isConstructed?new _.Constructed:new _.Primitive;f.idBlock=o.idBlock,f.lenBlock=o.lenBlock,f.warnings=o.warnings,o=f}}break;case 2:case 3:case 4:default:c=o.idBlock.isConstructed?_.Constructed:_.Primitive}return o=I0(o,c),a=o.fromBER(r,e,o.lenBlock.isIndefiniteForm?t:o.lenBlock.length),o.valueBeforeDecodeView=r.subarray(n,n+o.blockLength),{offset:a,result:o}}function Ps(r){if(!r.byteLength){let e=new ye({},Be);return e.error="Input buffer has zero length",{offset:-1,result:e}}return Do(j.BufferSourceConverter.toUint8Array(r).slice(),0,r.byteLength)}function k0(r,e){return r?1:e}var st=class extends Be{constructor({value:e=[],isIndefiniteForm:t=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n){let o=j.BufferSourceConverter.toUint8Array(e);if(!Et(this,o,t,n))return-1;if(this.valueBeforeDecodeView=o.subarray(t,t+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),t;let i=t;for(;k0(this.isIndefiniteForm,n)>0;){let s=Do(o,i,n);if(s.offset===-1)return this.error=s.result.error,this.warnings.concat(s.result.warnings),-1;if(i=s.offset,this.blockLength+=s.result.blockLength,n-=s.result.blockLength,this.value.push(s.result),this.isIndefiniteForm&&s.result.constructor.NAME===rn)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===rn?this.value.pop():this.warnings.push("No EndOfContent block encoded")),i}toBER(e,t){let n=t||new tn;for(let o=0;o` ${o}`).join(` + `));let t=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return e.length?`${t} : + ${e.join(` +-`)}`:`${t} :`}};xu=Yt;U.Constructed=xu;Yt.NAME="CONSTRUCTED";var To=class extends Ie{fromBER(e,t,n){return t}toBER(e){return ot}};To.override="EndOfContentValueBlock";var Eu,Co=class extends Ee{constructor(e={}){super(e,To),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};Eu=Co;U.EndOfContent=Eu;Co.NAME=vn;var vu,Zt=class extends Ee{constructor(e={}){super(e,Ie),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,t,n){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=n,t+n>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):t+n}toBER(e,t){let n=new ArrayBuffer(2);if(!e){let o=new Uint8Array(n);o[0]=5,o[1]=0}return t&&t.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}};vu=Zt;U.Null=vu;Zt.NAME="NULL";var No=class extends Tt(Ie){constructor({value:e,...t}={}){super(t),t.valueHex?this.valueHexView=Z.BufferSourceConverter.toUint8Array(t.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}get value(){for(let e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}fromBER(e,t,n){let o=Z.BufferSourceConverter.toUint8Array(e);return kt(this,o,t,n)?(this.valueHexView=o.subarray(t,t+n),n>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,ra.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};No.NAME="BooleanValueBlock";var Bu,_o=class extends Ee{constructor(e={}){super(e,No),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}};Bu=_o;U.Boolean=Bu;_o.NAME="BOOLEAN";var Uo=class extends Tt(ht){constructor({isConstructed:e=!1,...t}={}){super(t),this.isConstructed=e}fromBER(e,t,n){let o=0;if(this.isConstructed){if(this.isHexOnly=!1,o=ht.prototype.fromBER.call(this,e,t,n),o===-1)return o;for(let i=0;i0&&f.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=f.unusedBits}return o}let i=Z.BufferSourceConverter.toUint8Array(e);if(!kt(this,i,t,n))return-1;let s=i.subarray(t,t+n);if(this.unusedBits=s[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){let a=s.subarray(1);try{if(a.byteLength){let c=ai(a,0,a.byteLength);c.offset!==-1&&c.offset===n-1&&(this.value=[c.result])}}catch{}}return this.valueHexView=s.subarray(1),this.blockLength=s.length,t+n}toBER(e,t){if(this.isConstructed)return ht.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return ot;let n=new Uint8Array(this.valueHexView.length+1);return n[0]=this.unusedBits,n.set(this.valueHexView,1),n.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}};Lo.NAME="BitStringValueBlock";var Su,qr=class extends Ee{constructor({idBlock:e={},lenBlock:t={},...n}={}){var o,i;(o=n.isConstructed)!==null&&o!==void 0||(n.isConstructed=!!(!((i=n.value)===null||i===void 0)&&i.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},Lo),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,t,n){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,t,n)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return Yt.prototype.onAsciiEncoding.call(this);{let e=[],t=this.valueBlock.valueHexView;for(let o of t)e.push(o.toString(2).padStart(8,"0"));let n=e.join("");return`${this.constructor.NAME} : ${n.substring(0,n.length-this.valueBlock.unusedBits)}`}}};Su=qr;U.BitString=Su;qr.NAME=yu;var Iu;function Ip(r,e){let t=new Uint8Array([0]),n=new Uint8Array(r),o=new Uint8Array(e),i=n.slice(0),s=i.length-1,a=o.slice(0),c=a.length-1,f=0,u=c=0;h--,l++){switch(!0){case l=i.length:i=vo(new Uint8Array([f%10]),i);break;default:i[s-l]=f%10}}return t[0]>0&&(i=vo(t,i)),i}function mu(r){if(r>=xn.length)for(let e=xn.length;e<=r;e++){let t=new Uint8Array([0]),n=xn[e-1].slice(0);for(let o=n.length-1;o>=0;o--){let i=new Uint8Array([(n[o]<<1)+t[0]]);t[0]=i[0]/10,n[o]=i[0]%10}t[0]>0&&(n=vo(t,n)),xn.push(n)}return xn[r]}function Rp(r,e){let t=0,n=new Uint8Array(r),o=new Uint8Array(e),i=n.slice(0),s=i.length-1,a=o.slice(0),c=a.length-1,f,u=0;for(let l=c;l>=0;l--,u++)switch(f=i[s-u]-a[c-u]-t,!0){case f<0:t=1,i[s-u]=f+10;break;default:t=0,i[s-u]=f}if(t>0)for(let l=s-c+1;l>=0;l--,u++)if(f=i[s-u]-t,f<0)t=1,i[s-u]=f+10;else{t=0,i[s-u]=f;break}return i.slice()}var Bn=class extends Tt(Ie){constructor({value:e,...t}={}){super(t),this._valueDec=0,t.valueHex&&this.setValueHex(),e!==void 0&&(this.valueDec=e)}setValueHex(){this.valueHexView.length>=4?(this.warnings.push("Too big Integer for decoding, hex only"),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,this.valueHexView.length>0&&(this._valueDec=ra.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(hu(e))}get valueDec(){return this._valueDec}fromDER(e,t,n,o=0){let i=this.fromBER(e,t,n);if(i===-1)return i;let s=this.valueHexView;return s[0]===0&&s[1]&128?this.valueHexView=s.subarray(1):o!==0&&s.length1&&(o=s.length+1),this.valueHexView=s.subarray(o-s.length)),i}toDER(e=!1){let t=this.valueHexView;switch(!0){case(t[0]&128)!==0:{let n=new Uint8Array(this.valueHexView.length+1);n[0]=0,n.set(t,1),this.valueHexView=n}break;case(t[0]===0&&(t[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(e)}fromBER(e,t,n){let o=super.fromBER(e,t,n);return o===-1||this.setValueHex(),o}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){let e=this.valueHexView.length*8-1,t=new Uint8Array(this.valueHexView.length*8/3),n=0,o,i=this.valueHexView,s="",a=!1;for(let c=i.byteLength-1;c>=0;c--){o=i[c];for(let f=0;f<8;f++){if((o&1)===1)switch(n){case e:t=Rp(mu(n),t),s="-";break;default:t=Ip(t,mu(n))}n++,o>>=1}}for(let c=0;c0;){let i=new An;if(o=i.fromBER(e,o,n),o===-1)return this.blockLength=0,this.error=i.error,o;this.value.length===0&&(i.isFirstSid=!0),this.blockLength+=i.blockLength,n-=i.blockLength,this.value.push(i)}return o}toBER(e){let t=[];for(let n=0;nNumber.MAX_SAFE_INTEGER){Bo();let a=BigInt(o);s.valueBigInt=a}else if(s.valueDec=parseInt(o,10),isNaN(s.valueDec))return;this.value.length||(s.isFirstSid=!0,i=!0),this.value.push(s)}while(n!==-1)}toString(){let e="",t=!1;for(let n=0;n0;){let i=new Sn;if(o=i.fromBER(e,o,n),o===-1)return this.blockLength=0,this.error=i.error,o;this.blockLength+=i.blockLength,n-=i.blockLength,this.value.push(i)}return o}toBER(e,t){let n=[];for(let o=0;o4)continue;let a=4-s.length;for(let c=s.length-1;c>=0;c--)n[o*4+c+a]=s[c]}this.valueBlock.value=e}};zo.NAME="UniversalStringValueBlock";var Vu,Go=class extends zo{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};Vu=Go;U.UniversalString=Vu;Go.NAME="UniversalString";var Ou,jo=class extends Ne{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};Ou=jo;U.NumericString=Ou;jo.NAME="NumericString";var Du,Yo=class extends Ne{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};Du=Yo;U.PrintableString=Du;Yo.NAME="PrintableString";var Pu,Zo=class extends Ne{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};Pu=Zo;U.TeletexString=Pu;Zo.NAME="TeletexString";var Fu,Wo=class extends Ne{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};Fu=Wo;U.VideotexString=Fu;Wo.NAME="VideotexString";var Mu,Jo=class extends Ne{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};Mu=Jo;U.IA5String=Mu;Jo.NAME="IA5String";var Hu,Xo=class extends Ne{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};Hu=Xo;U.GraphicString=Hu;Xo.NAME="GraphicString";var Ku,In=class extends Ne{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};Ku=In;U.VisibleString=Ku;In.NAME="VisibleString";var $u,Qo=class extends Ne{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};$u=Qo;U.GeneralString=$u;Qo.NAME="GeneralString";var qu,ei=class extends Ne{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};qu=ei;U.CharacterString=qu;ei.NAME="CharacterString";var zu,Rn=class extends In{constructor({value:e,valueDate:t,...n}={}){if(super(n),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let o=0;o=50?this.year=1900+o:this.year=2e3+o,this.month=parseInt(n[2],10),this.day=parseInt(n[3],10),this.hour=parseInt(n[4],10),this.minute=parseInt(n[5],10),this.second=parseInt(n[6],10)}toString(e="iso"){if(e==="iso"){let t=new Array(7);return t[0]=Pe(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=Pe(this.month,2),t[2]=Pe(this.day,2),t[3]=Pe(this.hour,2),t[4]=Pe(this.minute,2),t[5]=Pe(this.second,2),t[6]="Z",t.join("")}return super.toString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}};zu=Rn;U.UTCTime=zu;Rn.NAME="UTCTime";var Gu,ti=class extends Rn{constructor(e={}){var t;super(e),(t=this.millisecond)!==null&&t!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(e){let t=!1,n="",o="",i=0,s,a=0,c=0;if(e[e.length-1]==="Z")n=e.substring(0,e.length-1),t=!0;else{let l=new Number(e[e.length-1]);if(isNaN(l.valueOf()))throw new Error("Wrong input string for conversion");n=e}if(t){if(n.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(n.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let l=1,h=n.indexOf("+"),w="";if(h===-1&&(h=n.indexOf("-"),l=-1),h!==-1){if(w=n.substring(h+1),n=n.substring(0,h),w.length!==2&&w.length!==4)throw new Error("Wrong input string for conversion");let B=parseInt(w.substring(0,2),10);if(isNaN(B.valueOf()))throw new Error("Wrong input string for conversion");if(a=l*B,w.length===4){if(B=parseInt(w.substring(2,4),10),isNaN(B.valueOf()))throw new Error("Wrong input string for conversion");c=l*B}}}let f=n.indexOf(".");if(f===-1&&(f=n.indexOf(",")),f!==-1){let l=new Number(`0${n.substring(f)}`);if(isNaN(l.valueOf()))throw new Error("Wrong input string for conversion");i=l.valueOf(),o=n.substring(0,f)}else o=n;switch(!0){case o.length===8:if(s=/(\d{4})(\d{2})(\d{2})/ig,f!==-1)throw new Error("Wrong input string for conversion");break;case o.length===10:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let l=60*i;this.minute=Math.floor(l),l=60*(l-this.minute),this.second=Math.floor(l),l=1e3*(l-this.second),this.millisecond=Math.floor(l)}break;case o.length===12:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let l=60*i;this.second=Math.floor(l),l=1e3*(l-this.second),this.millisecond=Math.floor(l)}break;case o.length===14:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let l=1e3*i;this.millisecond=Math.floor(l)}break;default:throw new Error("Wrong input string for conversion")}let u=s.exec(o);if(u===null)throw new Error("Wrong input string for conversion");for(let l=1;l0&&(e=`0${e}`);let t=e.length/2,n=new Uint8Array(t),o=0,i=0;for(;o0&&(n=`0${n}`),e.push(n)}),BigInt("0x"+e.join(""))}var Up=16,ia=32,sa=1e4;async function Lp(r,e){let t=Ce.get(),o=new ge({value:[new le({value:0}),new ge({value:[new nt({value:"1.2.840.113549.1.1.1"}),new Zt]}),new It({valueHex:r.marshal()})]}).toBER(),i=new Uint8Array(o,0,o.byteLength),s=dr(Up),a=await ea(fn,e,s,{c:sa,dkLen:ia}),c=dr(16),f=await t.subtle.importKey("raw",a,"AES-CBC",!1,["encrypt"]),u=await t.subtle.encrypt({name:"AES-CBC",iv:c},f,i),l=new ge({value:[new It({valueHex:s}),new le({value:sa}),new le({value:ia}),new ge({value:[new nt({value:"1.2.840.113549.2.11"}),new Zt]})]}),h=new ge({value:[new nt({value:"1.2.840.113549.1.5.13"}),new ge({value:[new ge({value:[new nt({value:"1.2.840.113549.1.5.12"}),l]}),new ge({value:[new nt({value:"2.16.840.1.101.3.4.1.42"}),new It({valueHex:c})]})]})]}),B=new ge({value:[h,new It({valueHex:u})]}).toBER(),m=new Uint8Array(B,0,B.byteLength);return["-----BEGIN ENCRYPTED PRIVATE KEY-----",...z(m,"base64pad").split(/(.{64})/).filter(Boolean),"-----END ENCRYPTED PRIVATE KEY-----"].join(` +-`)}async function Vp(r,e){let t=Ce.get(),n;if(r.includes("-----BEGIN ENCRYPTED PRIVATE KEY-----")){let o=Y(r.replace("-----BEGIN ENCRYPTED PRIVATE KEY-----","").replace("-----END ENCRYPTED PRIVATE KEY-----","").replace(/\n/g,"").trim(),"base64pad"),{result:i}=Gr(o),{iv:s,salt:a,iterations:c,keySize:f,cipherText:u}=Op(i),l=await ea(fn,e,a,{c,dkLen:f}),h=await t.subtle.importKey("raw",l,"AES-CBC",!1,["decrypt"]),w=kn(await t.subtle.decrypt({name:"AES-CBC",iv:s},h,u)),{result:B}=Gr(w);n=Xu(B)}else if(r.includes("-----BEGIN PRIVATE KEY-----")){let o=Y(r.replace("-----BEGIN PRIVATE KEY-----","").replace("-----END PRIVATE KEY-----","").replace(/\n/g,"").trim(),"base64pad"),{result:i}=Gr(o);n=Xu(i)}else throw new P("Could not parse private key from PEM data","ERR_INVALID_PARAMETERS");return aa(n)}function Op(r){let e=r.valueBlock.value[0];if(e.valueBlock.value[0].toString()!=="OBJECT IDENTIFIER : 1.2.840.113549.1.5.13")throw new P("Only pkcs5PBES2 encrypted private keys are supported","ERR_INVALID_PARAMS");let n=e.valueBlock.value[1].valueBlock.value[0];if(n.valueBlock.value[0].toString()!=="OBJECT IDENTIFIER : 1.2.840.113549.1.5.12")throw new P("Only pkcs5PBKDF2 key derivation functions are supported","ERR_INVALID_PARAMS");let i=n.valueBlock.value[1],s=kn(i.valueBlock.value[0].getValue()),a=sa,c=ia;if(i.valueBlock.value.length===3)a=Number(i.valueBlock.value[1].toBigInt()),c=Number(i.valueBlock.value[2].toBigInt());else if(i.valueBlock.value.length===2)throw new P("Could not derive key size and iterations from PEM file - please use @libp2p/rsa to re-import your key","ERR_INVALID_PARAMS");let f=e.valueBlock.value[1].valueBlock.value[1],u=f.valueBlock.value[0].toString();if(u!=="OBJECT IDENTIFIER : 1.2.840.113549.3.7"){if(u!=="OBJECT IDENTIFIER : 1.3.14.3.2.7"){if(u!=="OBJECT IDENTIFIER : 2.16.840.1.101.3.4.1.2"){if(u!=="OBJECT IDENTIFIER : 2.16.840.1.101.3.4.1.22"){if(u!=="OBJECT IDENTIFIER : 2.16.840.1.101.3.4.1.42")throw new P("Only AES-CBC encryption schemes are supported","ERR_INVALID_PARAMS")}}}}let l=kn(f.valueBlock.value[1].getValue());return{cipherText:kn(r.valueBlock.value[1].getValue()),salt:s,iterations:a,keySize:c,iv:l}}function Xu(r){return kn(r.valueBlock.value[2].getValue())}function kn(r){return new Uint8Array(r,0,r.byteLength)}async function Qu(r){let e=await Ce.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:r,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),t=await rl(e);return{privateKey:t[0],publicKey:t[1]}}async function ca(r){let t=[await Ce.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await Dp(r)],n=await rl({privateKey:t[0],publicKey:t[1]});return{privateKey:n[0],publicKey:n[1]}}async function el(r,e){let t=await Ce.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await Ce.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},t,e instanceof Uint8Array?e:e.subarray());return new Uint8Array(n,0,n.byteLength)}async function tl(r,e,t){let n=await Ce.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return Ce.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,e,t instanceof Uint8Array?t:t.subarray())}async function rl(r){if(r.privateKey==null||r.publicKey==null)throw new P("Private and public key are required","ERR_INVALID_PARAMETERS");return Promise.all([Ce.get().subtle.exportKey("jwk",r.privateKey),Ce.get().subtle.exportKey("jwk",r.publicKey)])}async function Dp(r){return Ce.get().subtle.importKey("jwk",{kty:r.kty,n:r.n,e:r.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}function ci(r){if(r.kty!=="RSA")throw new P("invalid key type","ERR_INVALID_KEY_TYPE");if(r.n==null)throw new P("invalid key modulus","ERR_INVALID_KEY_MODULUS");return Y(r.n,"base64url").length*8}var Cn=8192,Tn=class{_key;constructor(e){this._key=e}verify(e,t){return tl(this._key,t,e)}marshal(){return Wt.jwkToPkix(this._key)}get bytes(){return ft.encode({Type:ce.RSA,Data:this.marshal()}).subarray()}equals(e){return ue(this.bytes,e.bytes)}hash(){let e=xe.digest(this.bytes);return Ge(e)?e.then(({bytes:t})=>t):e.bytes}},jr=class{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return dr(16)}sign(e){return el(this._key,e)}get public(){if(this._publicKey==null)throw new P("public key not provided","ERR_PUBKEY_NOT_PROVIDED");return new Tn(this._publicKey)}marshal(){return Wt.jwkToPkcs1(this._key)}get bytes(){return Bt.encode({Type:ce.RSA,Data:this.marshal()}).subarray()}equals(e){return ue(this.bytes,e.bytes)}hash(){let e=xe.digest(this.bytes);return Ge(e)?e.then(({bytes:t})=>t):e.bytes}async id(){let e=await this.public.hash();return z(e,"base58btc")}async export(e,t="pkcs-8"){if(t==="pkcs-8")return Wt.exportToPem(this,e);if(t==="libp2p-key")return Dr(this.bytes,e);throw new P(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};async function aa(r){let e=Wt.pkcs1ToJwk(r);if(ci(e)>Cn)throw new P("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let t=await ca(e);return new jr(t.privateKey,t.publicKey)}function Fp(r){let e=Wt.pkixToJwk(r);if(ci(e)>Cn)throw new P("key size is too large","ERR_KEY_SIZE_TOO_LARGE");return new Tn(e)}async function Mp(r){if(ci(r)>Cn)throw new P("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let e=await ca(r);return new jr(e.privateKey,e.publicKey)}async function Hp(r){if(r>Cn)throw new P("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let e=await Qu(r);return new jr(e.privateKey,e.publicKey)}var pa={};me(pa,{Secp256k1PrivateKey:()=>_n,Secp256k1PublicKey:()=>Nn,generateKeyPair:()=>em,unmarshalSecp256k1PrivateKey:()=>Xp,unmarshalSecp256k1PublicKey:()=>Qp});var Kp=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Jt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Xt=new Uint32Array(64),la=class extends Ur{constructor(){super(64,32,8,!1),this.A=Jt[0]|0,this.B=Jt[1]|0,this.C=Jt[2]|0,this.D=Jt[3]|0,this.E=Jt[4]|0,this.F=Jt[5]|0,this.G=Jt[6]|0,this.H=Jt[7]|0}get(){let{A:e,B:t,C:n,D:o,E:i,F:s,G:a,H:c}=this;return[e,t,n,o,i,s,a,c]}set(e,t,n,o,i,s,a,c){this.A=e|0,this.B=t|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(e,t){for(let l=0;l<16;l++,t+=4)Xt[l]=e.getUint32(t,!1);for(let l=16;l<64;l++){let h=Xt[l-15],w=Xt[l-2],B=Qe(h,7)^Qe(h,18)^h>>>3,m=Qe(w,17)^Qe(w,19)^w>>>10;Xt[l]=m+Xt[l-7]+B+Xt[l-16]|0}let{A:n,B:o,C:i,D:s,E:a,F:c,G:f,H:u}=this;for(let l=0;l<64;l++){let h=Qe(a,6)^Qe(a,11)^Qe(a,25),w=u+h+Oc(a,c,f)+Kp[l]+Xt[l]|0,m=(Qe(n,2)^Qe(n,13)^Qe(n,22))+Dc(n,o,i)|0;u=f,f=c,c=a,a=s+w|0,s=i,i=o,o=n,n=w+m|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(n,o,i,s,a,c,f,u)}roundClean(){Xt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var nl=io(()=>new la);function ol(r){r.lowS!==void 0&&et("lowS",r.lowS),r.prehash!==void 0&&et("prehash",r.prehash)}function $p(r){let e=pn(r);lt(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:t,Fp:n,a:o}=e;if(t){if(!n.eql(o,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}var{bytesToNumberBE:qp,hexToBytes:zp}=co,Ct={Err:class extends Error{constructor(e=""){super(e)}},_tlv:{encode:(r,e)=>{let{Err:t}=Ct;if(r<0||r>256)throw new t("tlv.encode: wrong tag");if(e.length&1)throw new t("tlv.encode: unpadded data");let n=e.length/2,o=ir(n);if(o.length/2&128)throw new t("tlv.encode: long form length too big");let i=n>127?ir(o.length/2|128):"";return`${ir(r)}${i}${o}${e}`},decode(r,e){let{Err:t}=Ct,n=0;if(r<0||r>256)throw new t("tlv.encode: wrong tag");if(e.length<2||e[n++]!==r)throw new t("tlv.decode: wrong tlv");let o=e[n++],i=!!(o&128),s=0;if(!i)s=o;else{let c=o&127;if(!c)throw new t("tlv.decode(long): indefinite length not supported");if(c>4)throw new t("tlv.decode(long): byte length is too big");let f=e.subarray(n,n+c);if(f.length!==c)throw new t("tlv.decode: length bytes not complete");if(f[0]===0)throw new t("tlv.decode(long): zero leftmost byte");for(let u of f)s=s<<8|u;if(n+=c,s<128)throw new t("tlv.decode(long): not minimal encoding")}let a=e.subarray(n,n+s);if(a.length!==s)throw new t("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+s)}}},_int:{encode(r){let{Err:e}=Ct;if(r{let R=d.toAffine();return Et(Uint8Array.from([4]),t.toBytes(R.x),t.toBytes(R.y))}),i=e.fromBytes||(m=>{let d=m.subarray(1),E=t.fromBytes(d.subarray(0,t.BYTES)),R=t.fromBytes(d.subarray(t.BYTES,2*t.BYTES));return{x:E,y:R}});function s(m){let{a:d,b:E}=e,R=t.sqr(m),y=t.mul(R,m);return t.add(t.add(y,t.mul(m,d)),E)}if(!t.eql(t.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function a(m){return hn(m,ye,e.n)}function c(m){let{allowedPrivateKeyLengths:d,nByteLength:E,wrapPrivateKey:R,n:y}=e;if(d&&typeof m!="bigint"){if(Kt(m)&&(m=bt(m)),typeof m!="string"||!d.includes(m.length))throw new Error("Invalid key");m=m.padStart(E*2,"0")}let k;try{k=typeof m=="bigint"?m:xt(se("private key",m,E))}catch{throw new Error(`private key must be ${E} bytes, hex or bigint, not ${typeof m}`)}return R&&(k=ee(k,y)),Oe("private key",k,ye,y),k}function f(m){if(!(m instanceof h))throw new Error("ProjectivePoint expected")}let u=cr((m,d)=>{let{px:E,py:R,pz:y}=m;if(t.eql(y,t.ONE))return{x:E,y:R};let k=m.is0();d==null&&(d=k?t.ONE:t.inv(y));let D=t.mul(E,d),V=t.mul(R,d),N=t.mul(y,d);if(k)return{x:t.ZERO,y:t.ZERO};if(!t.eql(N,t.ONE))throw new Error("invZ was invalid");return{x:D,y:V}}),l=cr(m=>{if(m.is0()){if(e.allowInfinityPoint&&!t.is0(m.py))return;throw new Error("bad point: ZERO")}let{x:d,y:E}=m.toAffine();if(!t.isValid(d)||!t.isValid(E))throw new Error("bad point: x or y not FE");let R=t.sqr(E),y=s(d);if(!t.eql(R,y))throw new Error("bad point: equation left != right");if(!m.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class h{constructor(d,E,R){if(this.px=d,this.py=E,this.pz=R,d==null||!t.isValid(d))throw new Error("x required");if(E==null||!t.isValid(E))throw new Error("y required");if(R==null||!t.isValid(R))throw new Error("z required");Object.freeze(this)}static fromAffine(d){let{x:E,y:R}=d||{};if(!d||!t.isValid(E)||!t.isValid(R))throw new Error("invalid affine point");if(d instanceof h)throw new Error("projective point not allowed");let y=k=>t.eql(k,t.ZERO);return y(E)&&y(R)?h.ZERO:new h(E,R,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){let E=t.invertBatch(d.map(R=>R.pz));return d.map((R,y)=>R.toAffine(E[y])).map(h.fromAffine)}static fromHex(d){let E=h.fromAffine(i(se("pointHex",d)));return E.assertValidity(),E}static fromPrivateKey(d){return h.BASE.multiply(c(d))}static msm(d,E){return fo(h,n,d,E)}_setWindowSize(d){B.setWindowSize(this,d)}assertValidity(){l(this)}hasEvenY(){let{y:d}=this.toAffine();if(t.isOdd)return!t.isOdd(d);throw new Error("Field doesn't support isOdd")}equals(d){f(d);let{px:E,py:R,pz:y}=this,{px:k,py:D,pz:V}=d,N=t.eql(t.mul(E,V),t.mul(k,y)),b=t.eql(t.mul(R,V),t.mul(D,y));return N&&b}negate(){return new h(this.px,t.neg(this.py),this.pz)}double(){let{a:d,b:E}=e,R=t.mul(E,il),{px:y,py:k,pz:D}=this,V=t.ZERO,N=t.ZERO,b=t.ZERO,v=t.mul(y,y),F=t.mul(k,k),_=t.mul(D,D),C=t.mul(y,k);return C=t.add(C,C),b=t.mul(y,D),b=t.add(b,b),V=t.mul(d,b),N=t.mul(R,_),N=t.add(V,N),V=t.sub(F,N),N=t.add(F,N),N=t.mul(V,N),V=t.mul(C,V),b=t.mul(R,b),_=t.mul(d,_),C=t.sub(v,_),C=t.mul(d,C),C=t.add(C,b),b=t.add(v,v),v=t.add(b,v),v=t.add(v,_),v=t.mul(v,C),N=t.add(N,v),_=t.mul(k,D),_=t.add(_,_),v=t.mul(_,C),V=t.sub(V,v),b=t.mul(_,F),b=t.add(b,b),b=t.add(b,b),new h(V,N,b)}add(d){f(d);let{px:E,py:R,pz:y}=this,{px:k,py:D,pz:V}=d,N=t.ZERO,b=t.ZERO,v=t.ZERO,F=e.a,_=t.mul(e.b,il),C=t.mul(E,k),$=t.mul(R,D),S=t.mul(y,V),I=t.add(E,R),g=t.add(k,D);I=t.mul(I,g),g=t.add(C,$),I=t.sub(I,g),g=t.add(E,y);let p=t.add(k,V);return g=t.mul(g,p),p=t.add(C,S),g=t.sub(g,p),p=t.add(R,y),N=t.add(D,V),p=t.mul(p,N),N=t.add($,S),p=t.sub(p,N),v=t.mul(F,g),N=t.mul(_,S),v=t.add(N,v),N=t.sub($,v),v=t.add($,v),b=t.mul(N,v),$=t.add(C,C),$=t.add($,C),S=t.mul(F,S),g=t.mul(_,g),$=t.add($,S),S=t.sub(C,S),S=t.mul(F,S),g=t.add(g,S),C=t.mul($,g),b=t.add(b,C),C=t.mul(p,g),N=t.mul(I,N),N=t.sub(N,C),C=t.mul(I,$),v=t.mul(p,v),v=t.add(v,C),new h(N,b,v)}subtract(d){return this.add(d.negate())}is0(){return this.equals(h.ZERO)}wNAF(d){return B.wNAFCached(this,d,h.normalizeZ)}multiplyUnsafe(d){Oe("scalar",d,Nt,e.n);let E=h.ZERO;if(d===Nt)return E;if(d===ye)return this;let{endo:R}=e;if(!R)return B.unsafeLadder(this,d);let{k1neg:y,k1:k,k2neg:D,k2:V}=R.splitScalar(d),N=E,b=E,v=this;for(;k>Nt||V>Nt;)k&ye&&(N=N.add(v)),V&ye&&(b=b.add(v)),v=v.double(),k>>=ye,V>>=ye;return y&&(N=N.negate()),D&&(b=b.negate()),b=new h(t.mul(b.px,R.beta),b.py,b.pz),N.add(b)}multiply(d){let{endo:E,n:R}=e;Oe("scalar",d,ye,R);let y,k;if(E){let{k1neg:D,k1:V,k2neg:N,k2:b}=E.splitScalar(d),{p:v,f:F}=this.wNAF(V),{p:_,f:C}=this.wNAF(b);v=B.constTimeNegate(D,v),_=B.constTimeNegate(N,_),_=new h(t.mul(_.px,E.beta),_.py,_.pz),y=v.add(_),k=F.add(C)}else{let{p:D,f:V}=this.wNAF(d);y=D,k=V}return h.normalizeZ([y,k])[0]}multiplyAndAddUnsafe(d,E,R){let y=h.BASE,k=(V,N)=>N===Nt||N===ye||!V.equals(y)?V.multiplyUnsafe(N):V.multiply(N),D=k(this,E).add(k(d,R));return D.is0()?void 0:D}toAffine(d){return u(this,d)}isTorsionFree(){let{h:d,isTorsionFree:E}=e;if(d===ye)return!0;if(E)return E(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:d,clearCofactor:E}=e;return d===ye?this:E?E(h,this):this.multiplyUnsafe(e.h)}toRawBytes(d=!0){return et("isCompressed",d),this.assertValidity(),o(h,this,d)}toHex(d=!0){return et("isCompressed",d),bt(this.toRawBytes(d))}}h.BASE=new h(e.Gx,e.Gy,t.ONE),h.ZERO=new h(t.ZERO,t.ONE,t.ZERO);let w=e.nBitLength,B=lo(h,e.endo?Math.ceil(w/2):w);return{CURVE:e,ProjectivePoint:h,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:a}}function jp(r){let e=pn(r);return lt(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function sl(r){let e=jp(r),{Fp:t,n}=e,o=t.BYTES+1,i=2*t.BYTES+1;function s(S){return ee(S,n)}function a(S){return uo(S,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:f,weierstrassEquation:u,isWithinCurveOrder:l}=Gp({...e,toBytes(S,I,g){let p=I.toAffine(),A=t.toBytes(p.x),O=Et;return et("isCompressed",g),g?O(Uint8Array.from([I.hasEvenY()?2:3]),A):O(Uint8Array.from([4]),A,t.toBytes(p.y))},fromBytes(S){let I=S.length,g=S[0],p=S.subarray(1);if(I===o&&(g===2||g===3)){let A=xt(p);if(!hn(A,ye,t.ORDER))throw new Error("Point is not on curve");let O=u(A),M;try{M=t.sqrt(O)}catch(W){let j=W instanceof Error?": "+W.message:"";throw new Error("Point is not on curve"+j)}let H=(M&ye)===ye;return(g&1)===1!==H&&(M=t.neg(M)),{x:A,y:M}}else if(I===i&&g===4){let A=t.fromBytes(p.subarray(0,t.BYTES)),O=t.fromBytes(p.subarray(t.BYTES,2*t.BYTES));return{x:A,y:O}}else throw new Error(`Point of length ${I} was invalid. Expected ${o} compressed bytes or ${i} uncompressed bytes`)}}),h=S=>bt(qt(S,e.nByteLength));function w(S){let I=n>>ye;return S>I}function B(S){return w(S)?s(-S):S}let m=(S,I,g)=>xt(S.slice(I,g));class d{constructor(I,g,p){this.r=I,this.s=g,this.recovery=p,this.assertValidity()}static fromCompact(I){let g=e.nByteLength;return I=se("compactSignature",I,g*2),new d(m(I,0,g),m(I,g,2*g))}static fromDER(I){let{r:g,s:p}=Ct.toSig(se("DER",I));return new d(g,p)}assertValidity(){Oe("r",this.r,ye,n),Oe("s",this.s,ye,n)}addRecoveryBit(I){return new d(this.r,this.s,I)}recoverPublicKey(I){let{r:g,s:p,recovery:A}=this,O=V(se("msgHash",I));if(A==null||![0,1,2,3].includes(A))throw new Error("recovery id invalid");let M=A===2||A===3?g+e.n:g;if(M>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");let H=A&1?"03":"02",G=c.fromHex(H+h(M)),W=a(M),j=s(-O*W),Q=s(p*W),re=c.BASE.multiplyAndAddUnsafe(G,j,Q);if(!re)throw new Error("point at infinify");return re.assertValidity(),re}hasHighS(){return w(this.s)}normalizeS(){return this.hasHighS()?new d(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return sr(this.toDERHex())}toDERHex(){return Ct.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return sr(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}let E={isValidPrivateKey(S){try{return f(S),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let S=Os(e.n);return zc(e.randomBytes(S),e.n)},precompute(S=8,I=c.BASE){return I._setWindowSize(S),I.multiply(BigInt(3)),I}};function R(S,I=!0){return c.fromPrivateKey(S).toRawBytes(I)}function y(S){let I=Kt(S),g=typeof S=="string",p=(I||g)&&S.length;return I?p===o||p===i:g?p===2*o||p===2*i:S instanceof c}function k(S,I,g=!0){if(y(S))throw new Error("first arg must be private key");if(!y(I))throw new Error("second arg must be public key");return c.fromHex(I).multiply(f(S)).toRawBytes(g)}let D=e.bits2int||function(S){let I=xt(S),g=S.length*8-e.nBitLength;return g>0?I>>BigInt(g):I},V=e.bits2int_modN||function(S){return s(D(S))},N=dn(e.nBitLength);function b(S){return Oe(`num < 2^${e.nBitLength}`,S,Nt,N),qt(S,e.nByteLength)}function v(S,I,g=F){if(["recovered","canonical"].some(pe=>pe in g))throw new Error("sign() legacy options not supported");let{hash:p,randomBytes:A}=e,{lowS:O,prehash:M,extraEntropy:H}=g;O==null&&(O=!0),S=se("msgHash",S),ol(g),M&&(S=se("prehashed msgHash",p(S)));let G=V(S),W=f(I),j=[b(W),b(G)];if(H!=null&&H!==!1){let pe=H===!0?A(t.BYTES):H;j.push(se("extraEntropy",pe))}let Q=Et(...j),re=G;function de(pe){let be=D(pe);if(!l(be))return;let ke=a(be),fe=c.BASE.multiply(be).toAffine(),Le=s(fe.x);if(Le===Nt)return;let gt=s(ke*s(re+Le*W));if(gt===Nt)return;let en=(fe.x===Le?0:2)|Number(fe.y&ye),tn=gt;return O&&w(gt)&&(tn=B(gt),en^=1),new d(Le,tn,en)}return{seed:Q,k2sig:de}}let F={lowS:e.lowS,prehash:!1},_={lowS:e.lowS,prehash:!1};function C(S,I,g=F){let{seed:p,k2sig:A}=v(S,I,g),O=e;return _s(O.hash.outputLen,O.nByteLength,O.hmac)(p,A)}c.BASE._setWindowSize(8);function $(S,I,g,p=_){let A=S;if(I=se("msgHash",I),g=se("publicKey",g),"strict"in p)throw new Error("options.strict was renamed to lowS");ol(p);let{lowS:O,prehash:M}=p,H,G;try{if(typeof A=="string"||Kt(A))try{H=d.fromDER(A)}catch(fe){if(!(fe instanceof Ct.Err))throw fe;H=d.fromCompact(A)}else if(typeof A=="object"&&typeof A.r=="bigint"&&typeof A.s=="bigint"){let{r:fe,s:Le}=A;H=new d(fe,Le)}else throw new Error("PARSE");G=c.fromHex(g)}catch(fe){if(fe.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(O&&H.hasHighS())return!1;M&&(I=e.hash(I));let{r:W,s:j}=H,Q=V(I),re=a(j),de=s(Q*re),pe=s(W*re),be=c.BASE.multiplyAndAddUnsafe(G,de,pe)?.toAffine();return be?s(be.x)===W:!1}return{CURVE:e,getPublicKey:R,getSharedSecret:k,sign:C,verify:$,ProjectivePoint:c,Signature:d,utils:E}}function Yp(r){return{hash:r,hmac:(e,...t)=>bn(r,e,As(...t)),randomBytes:_r}}function al(r,e){let t=n=>sl({...r,...Yp(n)});return Object.freeze({...t(e),create:t})}var ll=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),cl=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Zp=BigInt(1),fa=BigInt(2),ul=(r,e)=>(r+e/fa)/e;function Wp(r){let e=ll,t=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),f=r*r*r%e,u=f*f*r%e,l=oe(u,t,e)*u%e,h=oe(l,t,e)*u%e,w=oe(h,fa,e)*f%e,B=oe(w,o,e)*w%e,m=oe(B,i,e)*B%e,d=oe(m,a,e)*m%e,E=oe(d,c,e)*d%e,R=oe(E,a,e)*m%e,y=oe(R,t,e)*u%e,k=oe(y,s,e)*B%e,D=oe(k,n,e)*f%e,V=oe(D,fa,e);if(!ha.eql(ha.sqr(V),r))throw new Error("Cannot find square root");return V}var ha=zt(ll,void 0,void 0,{sqrt:Wp}),it=al({a:BigInt(0),b:BigInt(7),Fp:ha,n:cl,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let e=cl,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Zp*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=t,s=BigInt("0x100000000000000000000000000000000"),a=ul(i*r,e),c=ul(-n*r,e),f=ee(r-a*t-c*o,e),u=ee(-a*n-c*i,e),l=f>s,h=u>s;if(l&&(f=e-f),h&&(u=e-u),f>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:l,k1:f,k2neg:h,k2:u}}}},nl),f1=BigInt(0);var h1=it.ProjectivePoint;function fl(){return it.utils.randomPrivateKey()}function hl(r,e){let t=xe.digest(e instanceof Uint8Array?e:e.subarray());if(Ge(t))return t.then(({digest:n})=>it.sign(n,r).toDERRawBytes()).catch(n=>{throw new P(String(n),"ERR_INVALID_INPUT")});try{return it.sign(t.digest,r).toDERRawBytes()}catch(n){throw new P(String(n),"ERR_INVALID_INPUT")}}function dl(r,e,t){let n=xe.digest(t instanceof Uint8Array?t:t.subarray());if(Ge(n))return n.then(({digest:o})=>it.verify(e,o,r)).catch(o=>{throw new P(String(o),"ERR_INVALID_INPUT")});try{return it.verify(e,n.digest,r)}catch(o){throw new P(String(o),"ERR_INVALID_INPUT")}}function pl(r){return it.ProjectivePoint.fromHex(r).toRawBytes(!0)}function ml(r){try{it.getPublicKey(r,!0)}catch(e){throw new P(String(e),"ERR_INVALID_PRIVATE_KEY")}}function da(r){try{it.ProjectivePoint.fromHex(r)}catch(e){throw new P(String(e),"ERR_INVALID_PUBLIC_KEY")}}function gl(r){try{return it.getPublicKey(r,!0)}catch(e){throw new P(String(e),"ERR_INVALID_PRIVATE_KEY")}}var Nn=class{_key;constructor(e){da(e),this._key=e}verify(e,t){return dl(this._key,t,e)}marshal(){return pl(this._key)}get bytes(){return ft.encode({Type:ce.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return ue(this.bytes,e.bytes)}async hash(){let e=xe.digest(this.bytes),t;return Ge(e)?{bytes:t}=await e:t=e.bytes,t}},_n=class{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t??gl(e),ml(this._key),da(this._publicKey)}sign(e){return hl(this._key,e)}get public(){return new Nn(this._publicKey)}marshal(){return this._key}get bytes(){return Bt.encode({Type:ce.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return ue(this.bytes,e.bytes)}hash(){let e=xe.digest(this.bytes);return Ge(e)?e.then(({bytes:t})=>t):e.bytes}async id(){let e=await this.public.hash();return z(e,"base58btc")}async export(e,t="libp2p-key"){if(t==="libp2p-key")return Dr(this.bytes,e);throw new P(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function Xp(r){return new _n(r)}function Qp(r){return new Nn(r)}async function em(){let r=fl();return new _n(r)}var ui={rsa:ua,ed25519:Qs,secp256k1:pa};function tm(r){let e=Object.keys(ui).join(" / ");return new P(`invalid or unsupported key type ${r}. Must be ${e}`,"ERR_UNSUPPORTED_KEY_TYPE")}function ma(r){let e=ft.decode(r),t=e.Data??new Uint8Array;switch(e.Type){case ce.RSA:return ui.rsa.unmarshalRsaPublicKey(t);case ce.Ed25519:return ui.ed25519.unmarshalEd25519PublicKey(t);case ce.Secp256k1:return ui.secp256k1.unmarshalSecp256k1PublicKey(t);default:throw tm(e.Type??"unknown")}}var Om=rr(li(),1);var nm="/",om=new TextEncoder().encode(nm),T1=om[0];var Dm=rr(ya(),1);var bl="ERR_IPNS_EXPIRED_RECORD",fi="ERR_UNRECOGNIZED_VALIDITY";var _t="ERR_SIGNATURE_VERIFICATION";var wa="ERR_UNDEFINED_PARAMETER",xl="ERR_INVALID_RECORD_DATA",El="ERR_INVALID_VALUE",vl="ERR_INVALID_EMBEDDED_KEY";var Bl="ERR_RECORD_TOO_LARGE";var st;(function(r){let e;(function(o){o.EOL="EOL"})(e=r.ValidityType||(r.ValidityType={}));let t;(function(o){o[o.EOL=0]="EOL"})(t||(t={})),function(o){o.codec=()=>yn(t)}(e=r.ValidityType||(r.ValidityType={}));let n;r.codec=()=>(n==null&&(n=Hr((o,i,s={})=>{s.lengthDelimited!==!1&&i.fork(),o.value!=null&&(i.uint32(10),i.bytes(o.value)),o.signatureV1!=null&&(i.uint32(18),i.bytes(o.signatureV1)),o.validityType!=null&&(i.uint32(24),r.ValidityType.codec().encode(o.validityType,i)),o.validity!=null&&(i.uint32(34),i.bytes(o.validity)),o.sequence!=null&&(i.uint32(40),i.uint64(o.sequence)),o.ttl!=null&&(i.uint32(48),i.uint64(o.ttl)),o.pubKey!=null&&(i.uint32(58),i.bytes(o.pubKey)),o.signatureV2!=null&&(i.uint32(66),i.bytes(o.signatureV2)),o.data!=null&&(i.uint32(74),i.bytes(o.data)),s.lengthDelimited!==!1&&i.ldelim()},(o,i)=>{let s={},a=i==null?o.len:o.pos+i;for(;o.pos>>3){case 1:s.value=o.bytes();break;case 2:s.signatureV1=o.bytes();break;case 3:s.validityType=r.ValidityType.codec().decode(o);break;case 4:s.validity=o.bytes();break;case 5:s.sequence=o.uint64();break;case 6:s.ttl=o.uint64();break;case 7:s.pubKey=o.bytes();break;case 8:s.signatureV2=o.bytes();break;case 9:s.data=o.bytes();break;default:o.skipType(c&7);break}}return s})),n),r.encode=o=>Fr(o,r.codec()),r.decode=o=>Pr(o,r.codec())})(st||(st={}));var im=["string","number","bigint","symbol"],sm=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function Sl(r){if(r===null)return"null";if(r===void 0)return"undefined";if(r===!0||r===!1)return"boolean";let e=typeof r;if(im.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(r))return"Array";if(am(r))return"Buffer";let t=cm(r);return t||"Object"}function am(r){return r&&r.constructor&&r.constructor.isBuffer&&r.constructor.isBuffer.call(null,r)}function cm(r){let e=Object.prototype.toString.call(r).slice(8,-1);if(sm.includes(e))return e}var x=class{constructor(e,t,n){this.major=e,this.majorEncoded=e<<5,this.name=t,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.majore.major?1:0}};x.uint=new x(0,"uint",!0);x.negint=new x(1,"negint",!0);x.bytes=new x(2,"bytes",!0);x.string=new x(3,"string",!0);x.array=new x(4,"array",!1);x.map=new x(5,"map",!1);x.tag=new x(6,"tag",!1);x.float=new x(7,"float",!0);x.false=new x(7,"false",!0);x.true=new x(7,"true",!0);x.null=new x(7,"null",!0);x.undefined=new x(7,"undefined",!0);x.break=new x(7,"break",!0);var L=class{constructor(e,t,n){this.type=e,this.value=t,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var Yr=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",um=new TextDecoder,lm=new TextEncoder;function hi(r){return Yr&&globalThis.Buffer.isBuffer(r)}function Tl(r){return r instanceof Uint8Array?hi(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r:Uint8Array.from(r)}var Cl=Yr?(r,e,t)=>t-e>64?globalThis.Buffer.from(r.subarray(e,t)).toString("utf8"):Rl(r,e,t):(r,e,t)=>t-e>64?um.decode(r.subarray(e,t)):Rl(r,e,t),Nl=Yr?r=>r.length>64?globalThis.Buffer.from(r):Il(r):r=>r.length>64?lm.encode(r):Il(r);var Zr=Yr?(r,e,t)=>hi(r)?new Uint8Array(r.subarray(e,t)):r.slice(e,t):(r,e,t)=>r.slice(e,t),_l=Yr?(r,e)=>(r=r.map(t=>t instanceof Uint8Array?t:globalThis.Buffer.from(t)),Tl(globalThis.Buffer.concat(r,e))):(r,e)=>{let t=new Uint8Array(e),n=0;for(let o of r)n+o.length>t.length&&(o=o.subarray(0,t.length-n)),t.set(o,n),n+=o.length;return t},Ul=Yr?r=>globalThis.Buffer.allocUnsafe(r):r=>new Uint8Array(r);function Ll(r,e){if(hi(r)&&hi(e))return r.compare(e);for(let t=0;t>6|192,e[t++]=o&63|128):(o&64512)===55296&&n+1>18|240,e[t++]=o>>12&63|128,e[t++]=o>>6&63|128,e[t++]=o&63|128):(e[t++]=o>>12|224,e[t++]=o>>6&63|128,e[t++]=o&63|128)}return e}function Rl(r,e,t){let n=[];for(;e239?4:o>223?3:o>191?2:1;if(e+s<=t){let a,c,f,u;switch(s){case 1:o<128&&(i=o);break;case 2:a=r[e+1],(a&192)===128&&(u=(o&31)<<6|a&63,u>127&&(i=u));break;case 3:a=r[e+1],c=r[e+2],(a&192)===128&&(c&192)===128&&(u=(o&15)<<12|(a&63)<<6|c&63,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:a=r[e+1],c=r[e+2],f=r[e+3],(a&192)===128&&(c&192)===128&&(f&192)===128&&(u=(o&15)<<18|(a&63)<<12|(c&63)<<6|f&63,u>65535&&u<1114112&&(i=u))}}i===null?(i=65533,s=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),e+=s}return fm(n)}var kl=4096;function fm(r){let e=r.length;if(e<=kl)return String.fromCharCode.apply(String,r);let t="",n=0;for(;nn.length/2?(t=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):t=Zr(n,0,this.cursor)}else t=_l(this.chunks,this.cursor);return e&&this.reset(),t}};var K="CBOR decode error:",ba="CBOR encode error:",Un=[];Un[23]=1;Un[24]=2;Un[25]=3;Un[26]=5;Un[27]=9;function Ut(r,e,t){if(r.length-e>>8,n&255])}else if(t>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(t);if(n>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&255,o[4]=s&255,s=s>>8,o[3]=s&255,s=s>>8,o[2]=s&255,s=s>>8,o[1]=s&255,r.push(o)}else throw new Error(`${K} encountered BigInt larger than allowable range`)}}Ye.encodedSize=function(e){return ve.encodedSize(e.value)};ve.encodedSize=function(e){return et.value?1:0};function Fl(r,e,t,n){return new L(x.negint,-1-He(r,e+1,n),2)}function Ml(r,e,t,n){return new L(x.negint,-1-Ke(r,e+1,n),3)}function Hl(r,e,t,n){return new L(x.negint,-1-$e(r,e+1,n),5)}var xa=BigInt(-1),Kl=BigInt(1);function $l(r,e,t,n){let o=qe(r,e+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new L(x.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${K} integers outside of the safe integer range are not supported`);return new L(x.negint,xa-BigInt(o),9)}function pi(r,e){let t=e.value,n=typeof t=="bigint"?t*xa-Kl:t*-1-1;ve(r,e.type.majorEncoded,n)}pi.encodedSize=function(e){let t=e.value,n=typeof t=="bigint"?t*xa-Kl:t*-1-1;return nt.value?-1:0};function Ln(r,e,t,n){Ut(r,e,t+n);let o=Zr(r,e+t,e+t+n);return new L(x.bytes,o,t+n)}function ql(r,e,t,n){return Ln(r,e,1,t)}function zl(r,e,t,n){return Ln(r,e,2,He(r,e+1,n))}function Gl(r,e,t,n){return Ln(r,e,3,Ke(r,e+1,n))}function jl(r,e,t,n){return Ln(r,e,5,$e(r,e+1,n))}function Yl(r,e,t,n){let o=qe(r,e+1,n);if(typeof o=="bigint")throw new Error(`${K} 64-bit integer bytes lengths not supported`);return Ln(r,e,9,o)}function mi(r){return r.encodedBytes===void 0&&(r.encodedBytes=r.type===x.string?Nl(r.value):r.value),r.encodedBytes}function Wr(r,e){let t=mi(e);ve(r,e.type.majorEncoded,t.length),r.push(t)}Wr.encodedSize=function(e){let t=mi(e);return ve.encodedSize(t.length)+t.length};Wr.compareTokens=function(e,t){return pm(mi(e),mi(t))};function pm(r,e){return r.lengthe.length?1:Ll(r,e)}function Vn(r,e,t,n,o){let i=t+n;Ut(r,e,i);let s=new L(x.string,Cl(r,e+t,e+i),i);return o.retainStringBytes===!0&&(s.byteValue=Zr(r,e+t,e+i)),s}function Zl(r,e,t,n){return Vn(r,e,1,t,n)}function Wl(r,e,t,n){return Vn(r,e,2,He(r,e+1,n),n)}function Jl(r,e,t,n){return Vn(r,e,3,Ke(r,e+1,n),n)}function Xl(r,e,t,n){return Vn(r,e,5,$e(r,e+1,n),n)}function Ql(r,e,t,n){let o=qe(r,e+1,n);if(typeof o=="bigint")throw new Error(`${K} 64-bit integer string lengths not supported`);return Vn(r,e,9,o,n)}var ef=Wr;function Jr(r,e,t,n){return new L(x.array,n,t)}function tf(r,e,t,n){return Jr(r,e,1,t)}function rf(r,e,t,n){return Jr(r,e,2,He(r,e+1,n))}function nf(r,e,t,n){return Jr(r,e,3,Ke(r,e+1,n))}function of(r,e,t,n){return Jr(r,e,5,$e(r,e+1,n))}function sf(r,e,t,n){let o=qe(r,e+1,n);if(typeof o=="bigint")throw new Error(`${K} 64-bit integer array lengths not supported`);return Jr(r,e,9,o)}function af(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${K} indefinite length items not allowed`);return Jr(r,e,1,1/0)}function gi(r,e){ve(r,x.array.majorEncoded,e.value)}gi.compareTokens=Ye.compareTokens;gi.encodedSize=function(e){return ve.encodedSize(e.value)};function Xr(r,e,t,n){return new L(x.map,n,t)}function cf(r,e,t,n){return Xr(r,e,1,t)}function uf(r,e,t,n){return Xr(r,e,2,He(r,e+1,n))}function lf(r,e,t,n){return Xr(r,e,3,Ke(r,e+1,n))}function ff(r,e,t,n){return Xr(r,e,5,$e(r,e+1,n))}function hf(r,e,t,n){let o=qe(r,e+1,n);if(typeof o=="bigint")throw new Error(`${K} 64-bit integer map lengths not supported`);return Xr(r,e,9,o)}function df(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${K} indefinite length items not allowed`);return Xr(r,e,1,1/0)}function yi(r,e){ve(r,x.map.majorEncoded,e.value)}yi.compareTokens=Ye.compareTokens;yi.encodedSize=function(e){return ve.encodedSize(e.value)};function pf(r,e,t,n){return new L(x.tag,t,1)}function mf(r,e,t,n){return new L(x.tag,He(r,e+1,n),2)}function gf(r,e,t,n){return new L(x.tag,Ke(r,e+1,n),3)}function yf(r,e,t,n){return new L(x.tag,$e(r,e+1,n),5)}function wf(r,e,t,n){return new L(x.tag,qe(r,e+1,n),9)}function wi(r,e){ve(r,x.tag.majorEncoded,e.value)}wi.compareTokens=Ye.compareTokens;wi.encodedSize=function(e){return ve.encodedSize(e.value)};var xm=20,Em=21,vm=22,Bm=23;function bf(r,e,t,n){if(n.allowUndefined===!1)throw new Error(`${K} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new L(x.null,null,1):new L(x.undefined,void 0,1)}function xf(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${K} indefinite length items not allowed`);return new L(x.break,void 0,1)}function Ea(r,e,t){if(t){if(t.allowNaN===!1&&Number.isNaN(r))throw new Error(`${K} NaN values are not supported`);if(t.allowInfinity===!1&&(r===1/0||r===-1/0))throw new Error(`${K} Infinity values are not supported`)}return new L(x.float,r,e)}function Ef(r,e,t,n){return Ea(va(r,e+1),3,n)}function vf(r,e,t,n){return Ea(Ba(r,e+1),5,n)}function Bf(r,e,t,n){return Ea(Rf(r,e+1),9,n)}function bi(r,e,t){let n=e.value;if(n===!1)r.push([x.float.majorEncoded|xm]);else if(n===!0)r.push([x.float.majorEncoded|Em]);else if(n===null)r.push([x.float.majorEncoded|vm]);else if(n===void 0)r.push([x.float.majorEncoded|Bm]);else{let o,i=!1;(!t||t.float64!==!0)&&(Sf(n),o=va(at,1),n===o||Number.isNaN(n)?(at[0]=249,r.push(at.slice(0,3)),i=!0):(If(n),o=Ba(at,1),n===o&&(at[0]=250,r.push(at.slice(0,5)),i=!0))),i||(Am(n),o=Rf(at,1),at[0]=251,r.push(at.slice(0,9)))}}bi.encodedSize=function(e,t){let n=e.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!t||t.float64!==!0){Sf(n);let o=va(at,1);if(n===o||Number.isNaN(n))return 3;if(If(n),o=Ba(at,1),n===o)return 5}return 9};var Af=new ArrayBuffer(9),Ze=new DataView(Af,1),at=new Uint8Array(Af,0);function Sf(r){if(r===1/0)Ze.setUint16(0,31744,!1);else if(r===-1/0)Ze.setUint16(0,64512,!1);else if(Number.isNaN(r))Ze.setUint16(0,32256,!1);else{Ze.setFloat32(0,r);let e=Ze.getUint32(0),t=(e&2139095040)>>23,n=e&8388607;if(t===255)Ze.setUint16(0,31744,!1);else if(t===0)Ze.setUint16(0,(r&2147483648)>>16|n>>13,!1);else{let o=t-127;o<-24?Ze.setUint16(0,0):o<-14?Ze.setUint16(0,(e&2147483648)>>16|1<<24+o,!1):Ze.setUint16(0,(e&2147483648)>>16|o+15<<10|n>>13,!1)}}}function va(r,e){if(r.length-e<2)throw new Error(`${K} not enough data for float16`);let t=(r[e]<<8)+r[e+1];if(t===31744)return 1/0;if(t===64512)return-1/0;if(t===32256)return NaN;let n=t>>10&31,o=t&1023,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,t&32768?-i:i}function If(r){Ze.setFloat32(0,r,!1)}function Ba(r,e){if(r.length-e<4)throw new Error(`${K} not enough data for float32`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,4).getFloat32(0,!1)}function Am(r){Ze.setFloat64(0,r,!1)}function Rf(r,e){if(r.length-e<8)throw new Error(`${K} not enough data for float64`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,8).getFloat64(0,!1)}bi.compareTokens=Ye.compareTokens;function J(r,e,t){throw new Error(`${K} encountered invalid minor (${t}) for major ${r[e]>>>5}`)}function xi(r){return()=>{throw new Error(`${K} ${r}`)}}var T=[];for(let r=0;r<=23;r++)T[r]=J;T[24]=Vl;T[25]=Ol;T[26]=Dl;T[27]=Pl;T[28]=J;T[29]=J;T[30]=J;T[31]=J;for(let r=32;r<=55;r++)T[r]=J;T[56]=Fl;T[57]=Ml;T[58]=Hl;T[59]=$l;T[60]=J;T[61]=J;T[62]=J;T[63]=J;for(let r=64;r<=87;r++)T[r]=ql;T[88]=zl;T[89]=Gl;T[90]=jl;T[91]=Yl;T[92]=J;T[93]=J;T[94]=J;T[95]=xi("indefinite length bytes/strings are not supported");for(let r=96;r<=119;r++)T[r]=Zl;T[120]=Wl;T[121]=Jl;T[122]=Xl;T[123]=Ql;T[124]=J;T[125]=J;T[126]=J;T[127]=xi("indefinite length bytes/strings are not supported");for(let r=128;r<=151;r++)T[r]=tf;T[152]=rf;T[153]=nf;T[154]=of;T[155]=sf;T[156]=J;T[157]=J;T[158]=J;T[159]=af;for(let r=160;r<=183;r++)T[r]=cf;T[184]=uf;T[185]=lf;T[186]=ff;T[187]=hf;T[188]=J;T[189]=J;T[190]=J;T[191]=df;for(let r=192;r<=215;r++)T[r]=pf;T[216]=mf;T[217]=gf;T[218]=yf;T[219]=wf;T[220]=J;T[221]=J;T[222]=J;T[223]=J;for(let r=224;r<=243;r++)T[r]=xi("simple values are not supported");T[244]=J;T[245]=J;T[246]=J;T[247]=bf;T[248]=xi("simple values are not supported");T[249]=Ef;T[250]=vf;T[251]=Bf;T[252]=J;T[253]=J;T[254]=J;T[255]=xf;var ct=[];for(let r=0;r<24;r++)ct[r]=new L(x.uint,r,1);for(let r=-1;r>=-24;r--)ct[31-r]=new L(x.negint,r,1);ct[64]=new L(x.bytes,new Uint8Array(0),1);ct[96]=new L(x.string,"",1);ct[128]=new L(x.array,0,1);ct[160]=new L(x.map,0,1);ct[244]=new L(x.false,!1,1);ct[245]=new L(x.true,!0,1);ct[246]=new L(x.null,null,1);function Im(){let r=[];return r[x.uint.major]=Ye,r[x.negint.major]=pi,r[x.bytes.major]=Wr,r[x.string.major]=ef,r[x.array.major]=gi,r[x.map.major]=yi,r[x.tag.major]=wi,r[x.float.major]=bi,r}var IE=Im(),RE=new di,Ei=class r{constructor(e,t){this.obj=e,this.parent=t}includes(e){let t=this;do if(t.obj===e)return!0;while(t=t.parent);return!1}static createCheck(e,t){if(e&&e.includes(t))throw new Error(`${ba} object contains circular references`);return new r(t,e)}},Qt={null:new L(x.null,null),undefined:new L(x.undefined,void 0),true:new L(x.true,!0),false:new L(x.false,!1),emptyArray:new L(x.array,0),emptyMap:new L(x.map,0)},er={number(r,e,t,n){return!Number.isInteger(r)||!Number.isSafeInteger(r)?new L(x.float,r):r>=0?new L(x.uint,r):new L(x.negint,r)},bigint(r,e,t,n){return r>=BigInt(0)?new L(x.uint,r):new L(x.negint,r)},Uint8Array(r,e,t,n){return new L(x.bytes,r)},string(r,e,t,n){return new L(x.string,r)},boolean(r,e,t,n){return r?Qt.true:Qt.false},null(r,e,t,n){return Qt.null},undefined(r,e,t,n){return Qt.undefined},ArrayBuffer(r,e,t,n){return new L(x.bytes,new Uint8Array(r))},DataView(r,e,t,n){return new L(x.bytes,new Uint8Array(r.buffer,r.byteOffset,r.byteLength))},Array(r,e,t,n){if(!r.length)return t.addBreakTokens===!0?[Qt.emptyArray,new L(x.break)]:Qt.emptyArray;n=Ei.createCheck(n,r);let o=[],i=0;for(let s of r)o[i++]=Aa(s,t,n);return t.addBreakTokens?[new L(x.array,r.length),o,new L(x.break)]:[new L(x.array,r.length),o]},Object(r,e,t,n){let o=e!=="Object",i=o?r.keys():Object.keys(r),s=o?r.size:i.length;if(!s)return t.addBreakTokens===!0?[Qt.emptyMap,new L(x.break)]:Qt.emptyMap;n=Ei.createCheck(n,r);let a=[],c=0;for(let f of i)a[c++]=[Aa(f,t,n),Aa(o?r.get(f):r[f],t,n)];return Rm(a,t),t.addBreakTokens?[new L(x.map,s),a,new L(x.break)]:[new L(x.map,s),a]}};er.Map=er.Object;er.Buffer=er.Uint8Array;for(let r of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))er[`${r}Array`]=er.DataView;function Aa(r,e={},t){let n=Sl(r),o=e&&e.typeEncoders&&e.typeEncoders[n]||er[n];if(typeof o=="function"){let s=o(r,n,e,t);if(s!=null)return s}let i=er[n];if(!i)throw new Error(`${ba} unsupported type: ${n}`);return i(r,n,e,t)}function Rm(r,e){e.mapSorter&&r.sort(e.mapSorter)}var km={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},vi=class{constructor(e,t={}){this._pos=0,this.data=e,this.options=t}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let e=this.data[this._pos],t=ct[e];if(t===void 0){let n=T[e];if(!n)throw new Error(`${K} no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,"0")})`);let o=e&31;t=n(this.data,this._pos,o,this.options)}return this._pos+=t.encodedLength,t}},On=Symbol.for("DONE"),Bi=Symbol.for("BREAK");function Tm(r,e,t){let n=[];for(let o=0;o0)throw new Error(`${K} too many terminals, data makes no sense`);return t}var ze=rr(li(),1);var Tf=Vt("ipns:utils"),Cf=Y("/ipns/"),Um=114,Nf=async(r,e)=>{if(e==null||r==null){let n=new Error("one or more of the provided parameters are not defined");throw Tf.error(n),(0,ze.default)(n,wa)}let t;if(e.pubKey!=null){try{t=ma(e.pubKey)}catch(o){throw Tf.error(o),o}if(!(await mc(e.pubKey)).equals(r))throw(0,ze.default)(new Error("Embedded public key did not match PeerID"),vl)}else r.publicKey!=null&&(t=ma(r.publicKey));if(t!=null)return t;throw(0,ze.default)(new Error("no public key is available"),wa)};var _f=r=>{let e=Y("ipns-signature:");return Te([e,r])},Dn=r=>"signatureV1"in r?st.encode({value:Y(r.value),signatureV1:r.signatureV1,validityType:r.validityType,validity:Y(r.validity),sequence:r.sequence,ttl:r.ttl,pubKey:r.pubKey,signatureV2:r.signatureV2,data:r.data}):st.encode({pubKey:r.pubKey,signatureV2:r.signatureV2,data:r.data});function tr(r){let e=st.decode(r);if(e.sequence!=null&&(e.sequence=BigInt(e.sequence)),e.ttl!=null&&(e.ttl=BigInt(e.ttl)),e.signatureV2==null||e.data==null)throw(0,ze.default)(new Error("missing data or signatureV2"),_t);let t=Lf(e.data),n=Lm(t.Value),o=z(t.Validity);if(e.value!=null&&e.signatureV1!=null)return Vm(e),{value:n,validityType:st.ValidityType.EOL,validity:o,sequence:t.Sequence,ttl:t.TTL,pubKey:e.pubKey,signatureV1:e.signatureV1,signatureV2:e.signatureV2,data:e.data};if(e.signatureV2!=null)return{value:n,validityType:st.ValidityType.EOL,validity:o,sequence:t.Sequence,ttl:t.TTL,pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data};throw new Error("invalid record: does not include signatureV1 or signatureV2")}var Ia=r=>Te([Cf,r.toBytes()]),Uf=r=>cn(r.slice(Cf.length));var Lf=r=>{let e=Sa(r);if(e.ValidityType===0)e.ValidityType=st.ValidityType.EOL;else throw(0,ze.default)(new Error("Unknown validity type"),fi);return Number.isInteger(e.Sequence)&&(e.Sequence=BigInt(e.Sequence)),Number.isInteger(e.TTL)&&(e.TTL=BigInt(e.TTL)),e},Lm=r=>{if(r!=null){if(Ka(r))return`/ipns/${r.toCID().toString(Wn)}`;if(r instanceof Uint8Array){let n=z(r);n.startsWith("/")&&(r=n)}let e=r.toString().trim();if(e.startsWith("/")&&e.length>1)return e;let t=Be.asCID(r);if(t!=null)return t.code===Um?`/ipns/${t.toString(Wn)}`:`/ipfs/${t.toV1().toString()}`;try{return r instanceof Uint8Array?`/ipfs/${Be.decode(r).toV1().toString()}`:`/ipfs/${Be.parse(e).toV1().toString()}`}catch{}}throw(0,ze.default)(new Error("Value must be a valid content path starting with /"),El)},Vm=r=>{if(r.data==null)throw(0,ze.default)(new Error("Record data is missing"),xl);let e=Lf(r.data);if(!ue(e.Value,r.value??new Uint8Array(0)))throw(0,ze.default)(new Error('Field "value" did not match between protobuf and CBOR'),_t);if(!ue(e.Validity,r.validity??new Uint8Array(0)))throw(0,ze.default)(new Error('Field "validity" did not match between protobuf and CBOR'),_t);if(e.ValidityType!==r.validityType)throw(0,ze.default)(new Error('Field "validityType" did not match between protobuf and CBOR'),_t);if(e.Sequence!==r.sequence)throw(0,ze.default)(new Error('Field "sequence" did not match between protobuf and CBOR'),_t);if(e.TTL!==r.ttl)throw(0,ze.default)(new Error('Field "ttl" did not match between protobuf and CBOR'),_t)};var t2=Vt("ipns"),r2=Je.code,n2=60*60*1e9,Pm="/ipns/",o2=Pm.length;var Pn=rr(li(),1),Vf=rr(ya(),1);var Ai=Vt("ipns:validator"),Fm=1024*10,Mm=async(r,e)=>{let t=tr(e),n;try{let o=_f(t.data);n=await r.verify(o,t.signatureV2)}catch{n=!1}if(!n)throw Ai.error("record signature verification failed"),(0,Pn.default)(new Error("record signature verification failed"),_t);if(t.validityType===st.ValidityType.EOL){if(Vf.default.fromString(t.validity).toDate().getTime()Fm)throw(0,Pn.default)(new Error("record too large"),Bl);let t=Uf(r),n=tr(e),o=await Nf(t,n);await Mm(o,e)}async function*Fn(r){let e=/\r?\n/,t=new TextDecoder("utf8"),n="";for await(let o of r){typeof o=="string"&&(o=new TextEncoder().encode(o)),n+=t.decode(o,{stream:!0});let i=n.split(e);n=i.pop()??"";for(let s=0;s{r.resolve=e,r.reject=t}),r}var ka=rr(Pf(),1);var Hn=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},Ta=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},Ff=r=>globalThis.DOMException===void 0?new Ta(r):new DOMException(r),Mf=r=>{let e=r.reason===void 0?Ff("This operation was aborted."):r.reason;return e instanceof Error?e:Ff(e)};function Ca(r,e){let{milliseconds:t,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout}}=e,s,c=new Promise((f,u)=>{if(typeof t!="number"||Math.sign(t)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${t}\``);if(e.signal){let{signal:h}=e;h.aborted&&u(Mf(h)),h.addEventListener("abort",()=>{u(Mf(h))})}if(t===Number.POSITIVE_INFINITY){r.then(f,u);return}let l=new Hn;s=i.setTimeout.call(void 0,()=>{if(n){try{f(n())}catch(h){u(h)}return}typeof r.cancel=="function"&&r.cancel(),o===!1?f():o instanceof Error?u(o):(l.message=o??`Promise timed out after ${t} milliseconds`,u(l))},t),(async()=>{try{f(await r)}catch(h){u(h)}})()}).finally(()=>{c.clear()});return c.clear=()=>{i.clearTimeout.call(void 0,s),s=void 0},c}function Na(r,e,t){let n=0,o=r.length;for(;o>0;){let i=Math.trunc(o/2),s=n+i;t(r[s],e)<=0?(n=++s,o-=i+1):o=i}return n}var Kn=class{#e=[];enqueue(e,t){t={priority:0,...t};let n={priority:t.priority,run:e};if(this.size&&this.#e[this.size-1].priority>=t.priority){this.#e.push(n);return}let o=Na(this.#e,n,(i,s)=>s.priority-i.priority);this.#e.splice(o,0,n)}dequeue(){return this.#e.shift()?.run}filter(e){return this.#e.filter(t=>t.priority===e.priority).map(t=>t.run)}get size(){return this.#e.length}};var $n=class extends ka.default{#e;#r;#i=0;#a;#c;#p=0;#n;#u;#t;#m;#o=0;#l;#s;#g;timeout;constructor(e){if(super(),e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:Kn,...e},!(typeof e.intervalCap=="number"&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${e.intervalCap?.toString()??""}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${e.interval?.toString()??""}\` (${typeof e.interval})`);this.#e=e.carryoverConcurrencyCount,this.#r=e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,this.#a=e.intervalCap,this.#c=e.interval,this.#t=new e.queueClass,this.#m=e.queueClass,this.concurrency=e.concurrency,this.timeout=e.timeout,this.#g=e.throwOnTimeout===!0,this.#s=e.autoStart===!1}get#b(){return this.#r||this.#i{this.#v()},t)),!0}return!1}#f(){if(this.#t.size===0)return this.#n&&clearInterval(this.#n),this.#n=void 0,this.emit("empty"),this.#o===0&&this.emit("idle"),!1;if(!this.#s){let e=!this.#B;if(this.#b&&this.#x){let t=this.#t.dequeue();return t?(this.emit("active"),t(),e&&this.#y(),!0):!1}}return!1}#y(){this.#r||this.#n!==void 0||(this.#n=setInterval(()=>{this.#w()},this.#c),this.#p=Date.now()+this.#c)}#w(){this.#i===0&&this.#o===0&&this.#n&&(clearInterval(this.#n),this.#n=void 0),this.#i=this.#e?this.#o:0,this.#h()}#h(){for(;this.#f(););}get concurrency(){return this.#l}set concurrency(e){if(!(typeof e=="number"&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);this.#l=e,this.#h()}async#A(e){return new Promise((t,n)=>{e.addEventListener("abort",()=>{n(e.reason)},{once:!0})})}async add(e,t={}){return t={timeout:this.timeout,throwOnTimeout:this.#g,...t},new Promise((n,o)=>{this.#t.enqueue(async()=>{this.#o++,this.#i++;try{t.signal?.throwIfAborted();let i=e({signal:t.signal});t.timeout&&(i=Ca(Promise.resolve(i),{milliseconds:t.timeout})),t.signal&&(i=Promise.race([i,this.#A(t.signal)]));let s=await i;n(s),this.emit("completed",s)}catch(i){if(i instanceof Hn&&!t.throwOnTimeout){n();return}o(i),this.emit("error",i)}finally{this.#E()}},t),this.emit("add"),this.#f()})}async addAll(e,t){return Promise.all(e.map(async n=>this.add(n,t)))}start(){return this.#s?(this.#s=!1,this.#h(),this):this}pause(){this.#s=!0}clear(){this.#t=new this.#m}async onEmpty(){this.#t.size!==0&&await this.#d("empty")}async onSizeLessThan(e){this.#t.sizethis.#t.size{let o=()=>{t&&!t()||(this.off(e,o),n())};this.on(e,o)})}get size(){return this.#t.size}sizeBy(e){return this.#t.filter(e).length}get pending(){return this.#o}get isPaused(){return this.#s}};function $m(r){return r[Symbol.asyncIterator]!=null}function qm(r){if($m(r))return(async()=>{for await(let e of r)return e})();for(let e of r)return e}var Hf=qm;function zm(r){let[e,t]=r[Symbol.asyncIterator]!=null?[r[Symbol.asyncIterator](),Symbol.asyncIterator]:[r[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>e.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:e.next(),[t](){return this}}}var Kf=zm;function Gm(r){return r[Symbol.asyncIterator]!=null}function jm(r,e){let t=0;if(Gm(r))return async function*(){for await(let c of r)yield e(c,t++)}();let n=Kf(r),{value:o,done:i}=n.next();if(i===!0)return function*(){}();let s=e(o,t++);if(typeof s.then=="function")return async function*(){yield await s;for await(let c of n)yield e(c,t++)}();let a=e;return function*(){yield s;for(let c of n)yield a(c,t++)}()}var $f=jm;var _a=Y("/ipns/");function qf(r){return ue(r.subarray(0,_a.byteLength),_a)}var zf=r=>cn(r.slice(_a.length)),Ii=class{client;constructor(e){this.client=e}async*findProviders(e,t={}){yield*$f(this.client.getProviders(e,t),n=>({id:n.ID,multiaddrs:n.Addrs??[]}))}async provide(){}async put(e,t,n){if(!qf(e))return;let o=zf(e),i=tr(t);await this.client.putIPNS(o,i,n)}async get(e,t){if(!qf(e))throw new P("Not found","ERR_NOT_FOUND");let n=zf(e);try{let o=await this.client.getIPNS(n,t);return Dn(o)}catch(o){throw o.code==="ERR_BAD_RESPONSE"?new P("Not found","ERR_NOT_FOUND"):o}}},Ri=class{client;constructor(e){this.client=e}async findPeer(e,t={}){let n=await Hf(this.client.getPeers(e,t));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new P("Not found","ERR_NOT_FOUND")}async*getClosestPeers(e,t={}){}};var Ue=Vt("delegated-routing-v1-http-api-client"),Gf={concurrentRequests:4,timeout:3e4},ki=class{started;httpQueue;shutDownController;clientUrl;timeout;contentRouting;peerRouting;constructor(e,t={}){this.started=!1,this.shutDownController=new AbortController,gr(1/0,this.shutDownController.signal),this.httpQueue=new $n({concurrency:t.concurrentRequests??Gf.concurrentRequests}),this.clientUrl=e instanceof URL?e:new URL(e),this.timeout=t.timeout??Gf.timeout,this.contentRouting=new Ii(this),this.peerRouting=new Ri(this)}get[Ha](){return this.contentRouting}get[$a](){return this.peerRouting}isStarted(){return this.started}start(){this.started=!0}stop(){this.httpQueue.clear(),this.shutDownController.abort(),this.started=!1}async*getProviders(e,t={}){Ue("getProviders starts: %c",e);let n=AbortSignal.timeout(this.timeout),o=ln([this.shutDownController.signal,n,t.signal]);gr(1/0,n,o);let i=mt(),s=mt();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let a=`${this.clientUrl}routing/v1/providers/${e.toString()}`,f=await fetch(a,{headers:{Accept:"application/x-ndjson"},signal:o});if(f.status===404)throw new P("No matching records found.","ERR_NOT_FOUND");if(f.status===422)throw new P("Request does not conform to schema or semantic constraints.","ERR_INVALID_REQUEST");if(f.body==null)throw new P("Routing response had no body","ERR_BAD_RESPONSE");if(f.headers.get("Content-Type")==="application/json"){let l=await f.json();for(let h of l.Providers){let w=this.#e(h);w!=null&&(yield w)}}else for await(let l of Fn(no(f.body))){let h=this.#e(l);h!=null&&(yield h)}}catch(a){Ue.error("getProviders errored:",a)}finally{o.clear(),s.resolve(),Ue("getProviders finished: %c",e)}}async*getPeers(e,t={}){Ue("getPeers starts: %c",e);let n=AbortSignal.timeout(this.timeout),o=ln([this.shutDownController.signal,n,t.signal]);gr(1/0,n,o);let i=mt(),s=mt();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let a=`${this.clientUrl}routing/v1/peers/${e.toCID().toString()}`,f=await fetch(a,{headers:{Accept:"application/x-ndjson"},signal:o});if(f.status===404)throw new P("No matching records found.","ERR_NOT_FOUND");if(f.status===422)throw new P("Request does not conform to schema or semantic constraints.","ERR_INVALID_REQUEST");if(f.body==null)throw new P("Routing response had no body","ERR_BAD_RESPONSE");if(f.headers.get("Content-Type")==="application/json"){let l=await f.json();for(let h of l.Peers){let w=this.#e(h);w!=null&&(yield w)}}else for await(let l of Fn(no(f.body))){let h=this.#e(l);h!=null&&(yield h)}}catch(a){Ue.error("getPeers errored:",a)}finally{o.clear(),s.resolve(),Ue("getPeers finished: %c",e)}}async getIPNS(e,t={}){Ue("getIPNS starts: %c",e);let n=AbortSignal.timeout(this.timeout),o=ln([this.shutDownController.signal,n,t.signal]);gr(1/0,n,o);let i=mt(),s=mt();this.httpQueue.add(async()=>(i.resolve(),s.promise));let a=`${this.clientUrl}routing/v1/ipns/${e.toCID().toString()}`;try{await i.promise;let f=await fetch(a,{headers:{Accept:"application/vnd.ipfs.ipns-record"},signal:o});if(Ue("getIPNS GET %s %d",a,f.status),f.status===404)throw new P("No matching records found.","ERR_NOT_FOUND");if(f.status===422)throw new P("Request does not conform to schema or semantic constraints.","ERR_INVALID_REQUEST");if(f.body==null)throw new P("GET ipns response had no body","ERR_BAD_RESPONSE");let u=await f.arrayBuffer(),l=new Uint8Array(u,0,u.byteLength);return t.validate!==!1&&await Of(Ia(e),l),tr(l)}catch(c){throw Ue.error("getIPNS GET %s error:",a,c),c}finally{o.clear(),s.resolve(),Ue("getIPNS finished: %c",e)}}async putIPNS(e,t,n={}){Ue("putIPNS starts: %c",e);let o=AbortSignal.timeout(this.timeout),i=ln([this.shutDownController.signal,o,n.signal]);gr(1/0,o,i);let s=mt(),a=mt();this.httpQueue.add(async()=>(s.resolve(),a.promise));let c=`${this.clientUrl}routing/v1/ipns/${e.toCID().toString()}`;try{await s.promise;let f=Dn(t),l=await fetch(c,{method:"PUT",headers:{"Content-Type":"application/vnd.ipfs.ipns-record"},body:f,signal:i});if(Ue("putIPNS PUT %s %d",c,l.status),l.status!==200)throw new P("PUT ipns response had status other than 200","ERR_BAD_RESPONSE")}catch(f){throw Ue.error("putIPNS PUT %s error:",c,f.stack),f}finally{i.clear(),a.resolve(),Ue("putIPNS finished: %c",e)}}#e(e){try{let t=[],n=e.Addrs?.map(un)??[];return e.Protocols!=null&&t.push(...e.Protocols),e.Protocol!=null&&(t.push(e.Protocol),delete e.Protocol),{...e,Schema:"peer",ID:rs(e.ID),Addrs:n,Protocols:t}}catch(t){Ue.error("could not conform record to peer schema",t)}}};function Ym(r,e={}){return new ki(new URL(r),e)}return sh(Zm);})(); ++`)}`:`${t} :`}};Dc=Mt;_.Constructed=Dc;Mt.NAME="CONSTRUCTED";var io=class extends Be{fromBER(e,t,n){return t}toBER(e){return Xe}};io.override="EndOfContentValueBlock";var Mc,so=class extends ye{constructor(e={}){super(e,io),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};Mc=so;_.EndOfContent=Mc;so.NAME=rn;var Hc,Ar=class extends ye{constructor(e={}){super(e,Be),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,t,n){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=n,t+n>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):t+n}toBER(e,t){let n=new ArrayBuffer(2);if(!e){let o=new Uint8Array(n);o[0]=5,o[1]=0}return t&&t.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}};Hc=Ar;_.Null=Hc;Ar.NAME="NULL";var ao=class extends Bt(Be){constructor({value:e,...t}={}){super(t),t.valueHex?this.valueHexView=j.BufferSourceConverter.toUint8Array(t.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}get value(){for(let e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}fromBER(e,t,n){let o=j.BufferSourceConverter.toUint8Array(e);return Et(this,o,t,n)?(this.valueHexView=o.subarray(t,t+n),n>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,_s.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};ao.NAME="BooleanValueBlock";var $c,co=class extends ye{constructor(e={}){super(e,ao),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}};$c=co;_.Boolean=$c;co.NAME="BOOLEAN";var uo=class extends Bt(st){constructor({isConstructed:e=!1,...t}={}){super(t),this.isConstructed=e}fromBER(e,t,n){let o=0;if(this.isConstructed){if(this.isHexOnly=!1,o=st.prototype.fromBER.call(this,e,t,n),o===-1)return o;for(let i=0;i0&&f.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=f.unusedBits}return o}let i=j.BufferSourceConverter.toUint8Array(e);if(!Et(this,i,t,n))return-1;let s=i.subarray(t,t+n);if(this.unusedBits=s[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){let a=s.subarray(1);try{if(a.byteLength){let c=Do(a,0,a.byteLength);c.offset!==-1&&c.offset===n-1&&(this.value=[c.result])}}catch{}}return this.valueHexView=s.subarray(1),this.blockLength=s.length,t+n}toBER(e,t){if(this.isConstructed)return st.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return Xe;let n=new Uint8Array(this.valueHexView.length+1);return n[0]=this.unusedBits,n.set(this.valueHexView,1),n.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}};fo.NAME="BitStringValueBlock";var qc,Sr=class extends ye{constructor({idBlock:e={},lenBlock:t={},...n}={}){var o,i;(o=n.isConstructed)!==null&&o!==void 0||(n.isConstructed=!!(!((i=n.value)===null||i===void 0)&&i.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},fo),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,t,n){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,t,n)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return Mt.prototype.onAsciiEncoding.call(this);{let e=[],t=this.valueBlock.valueHexView;for(let o of t)e.push(o.toString(2).padStart(8,"0"));let n=e.join("");return`${this.constructor.NAME} : ${n.substring(0,n.length-this.valueBlock.unusedBits)}`}}};qc=Sr;_.BitString=qc;Sr.NAME=Pc;var zc;function C0(r,e){let t=new Uint8Array([0]),n=new Uint8Array(r),o=new Uint8Array(e),i=n.slice(0),s=i.length-1,a=o.slice(0),c=a.length-1,f=0,u=c=0;h--,l++){switch(!0){case l=i.length:i=Xn(new Uint8Array([f%10]),i);break;default:i[s-l]=f%10}}return t[0]>0&&(i=Xn(t,i)),i}function Lc(r){if(r>=en.length)for(let e=en.length;e<=r;e++){let t=new Uint8Array([0]),n=en[e-1].slice(0);for(let o=n.length-1;o>=0;o--){let i=new Uint8Array([(n[o]<<1)+t[0]]);t[0]=i[0]/10,n[o]=i[0]%10}t[0]>0&&(n=Xn(t,n)),en.push(n)}return en[r]}function T0(r,e){let t=0,n=new Uint8Array(r),o=new Uint8Array(e),i=n.slice(0),s=i.length-1,a=o.slice(0),c=a.length-1,f,u=0;for(let l=c;l>=0;l--,u++)switch(f=i[s-u]-a[c-u]-t,!0){case f<0:t=1,i[s-u]=f+10;break;default:t=0,i[s-u]=f}if(t>0)for(let l=s-c+1;l>=0;l--,u++)if(f=i[s-u]-t,f<0)t=1,i[s-u]=f+10;else{t=0,i[s-u]=f;break}return i.slice()}var nn=class extends Bt(Be){constructor({value:e,...t}={}){super(t),this._valueDec=0,t.valueHex&&this.setValueHex(),e!==void 0&&(this.valueDec=e)}setValueHex(){this.valueHexView.length>=4?(this.warnings.push("Too big Integer for decoding, hex only"),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,this.valueHexView.length>0&&(this._valueDec=_s.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(Uc(e))}get valueDec(){return this._valueDec}fromDER(e,t,n,o=0){let i=this.fromBER(e,t,n);if(i===-1)return i;let s=this.valueHexView;return s[0]===0&&s[1]&128?this.valueHexView=s.subarray(1):o!==0&&s.length1&&(o=s.length+1),this.valueHexView=s.subarray(o-s.length)),i}toDER(e=!1){let t=this.valueHexView;switch(!0){case(t[0]&128)!==0:{let n=new Uint8Array(this.valueHexView.length+1);n[0]=0,n.set(t,1),this.valueHexView=n}break;case(t[0]===0&&(t[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(e)}fromBER(e,t,n){let o=super.fromBER(e,t,n);return o===-1||this.setValueHex(),o}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){let e=this.valueHexView.length*8-1,t=new Uint8Array(this.valueHexView.length*8/3),n=0,o,i=this.valueHexView,s="",a=!1;for(let c=i.byteLength-1;c>=0;c--){o=i[c];for(let f=0;f<8;f++){if((o&1)===1)switch(n){case e:t=T0(Lc(n),t),s="-";break;default:t=C0(t,Lc(n))}n++,o>>=1}}for(let c=0;c0;){let i=new on;if(o=i.fromBER(e,o,n),o===-1)return this.blockLength=0,this.error=i.error,o;this.value.length===0&&(i.isFirstSid=!0),this.blockLength+=i.blockLength,n-=i.blockLength,this.value.push(i)}return o}toBER(e){let t=[];for(let n=0;nNumber.MAX_SAFE_INTEGER){Qn();let a=BigInt(o);s.valueBigInt=a}else if(s.valueDec=parseInt(o,10),isNaN(s.valueDec))return;this.value.length||(s.isFirstSid=!0,i=!0),this.value.push(s)}while(n!==-1)}toString(){let e="",t=!1;for(let n=0;n0;){let i=new sn;if(o=i.fromBER(e,o,n),o===-1)return this.blockLength=0,this.error=i.error,o;this.blockLength+=i.blockLength,n-=i.blockLength,this.value.push(i)}return o}toBER(e,t){let n=[];for(let o=0;o4)continue;let a=4-s.length;for(let c=s.length-1;c>=0;c--)n[o*4+c+a]=s[c]}this.valueBlock.value=e}};Bo.NAME="UniversalStringValueBlock";var eu,Ao=class extends Bo{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};eu=Ao;_.UniversalString=eu;Ao.NAME="UniversalString";var tu,So=class extends ke{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};tu=So;_.NumericString=tu;So.NAME="NumericString";var ru,Io=class extends ke{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};ru=Io;_.PrintableString=ru;Io.NAME="PrintableString";var nu,ko=class extends ke{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};nu=ko;_.TeletexString=nu;ko.NAME="TeletexString";var ou,Co=class extends ke{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};ou=Co;_.VideotexString=ou;Co.NAME="VideotexString";var iu,To=class extends ke{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};iu=To;_.IA5String=iu;To.NAME="IA5String";var su,No=class extends ke{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};su=No;_.GraphicString=su;No.NAME="GraphicString";var au,an=class extends ke{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};au=an;_.VisibleString=au;an.NAME="VisibleString";var cu,Uo=class extends ke{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};cu=Uo;_.GeneralString=cu;Uo.NAME="GeneralString";var uu,Ro=class extends ke{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};uu=Ro;_.CharacterString=uu;Ro.NAME="CharacterString";var lu,cn=class extends an{constructor({value:e,valueDate:t,...n}={}){if(super(n),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let o=0;o=50?this.year=1900+o:this.year=2e3+o,this.month=parseInt(n[2],10),this.day=parseInt(n[3],10),this.hour=parseInt(n[4],10),this.minute=parseInt(n[5],10),this.second=parseInt(n[6],10)}toString(e="iso"){if(e==="iso"){let t=new Array(7);return t[0]=Le(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=Le(this.month,2),t[2]=Le(this.day,2),t[3]=Le(this.hour,2),t[4]=Le(this.minute,2),t[5]=Le(this.second,2),t[6]="Z",t.join("")}return super.toString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}};lu=cn;_.UTCTime=lu;cn.NAME="UTCTime";var fu,_o=class extends cn{constructor(e={}){var t;super(e),(t=this.millisecond)!==null&&t!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(e){let t=!1,n="",o="",i=0,s,a=0,c=0;if(e[e.length-1]==="Z")n=e.substring(0,e.length-1),t=!0;else{let l=new Number(e[e.length-1]);if(isNaN(l.valueOf()))throw new Error("Wrong input string for conversion");n=e}if(t){if(n.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(n.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let l=1,h=n.indexOf("+"),b="";if(h===-1&&(h=n.indexOf("-"),l=-1),h!==-1){if(b=n.substring(h+1),n=n.substring(0,h),b.length!==2&&b.length!==4)throw new Error("Wrong input string for conversion");let I=parseInt(b.substring(0,2),10);if(isNaN(I.valueOf()))throw new Error("Wrong input string for conversion");if(a=l*I,b.length===4){if(I=parseInt(b.substring(2,4),10),isNaN(I.valueOf()))throw new Error("Wrong input string for conversion");c=l*I}}}let f=n.indexOf(".");if(f===-1&&(f=n.indexOf(",")),f!==-1){let l=new Number(`0${n.substring(f)}`);if(isNaN(l.valueOf()))throw new Error("Wrong input string for conversion");i=l.valueOf(),o=n.substring(0,f)}else o=n;switch(!0){case o.length===8:if(s=/(\d{4})(\d{2})(\d{2})/ig,f!==-1)throw new Error("Wrong input string for conversion");break;case o.length===10:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let l=60*i;this.minute=Math.floor(l),l=60*(l-this.minute),this.second=Math.floor(l),l=1e3*(l-this.second),this.millisecond=Math.floor(l)}break;case o.length===12:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let l=60*i;this.second=Math.floor(l),l=1e3*(l-this.second),this.millisecond=Math.floor(l)}break;case o.length===14:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let l=1e3*i;this.millisecond=Math.floor(l)}break;default:throw new Error("Wrong input string for conversion")}let u=s.exec(o);if(u===null)throw new Error("Wrong input string for conversion");for(let l=1;l0&&(e=`0${e}`);let t=e.length/2,n=new Uint8Array(t),o=0,i=0;for(;o0&&(n=`0${n}`),e.push(n)}),BigInt("0x"+e.join(""))}function Bu(r){let e=vu(r);return Au(e)}function Ms(r){let e=Eu(r);if(Fs(e)>Ho)throw new or("Key size is too large");let t=Er(it.encode({Type:fe.RSA,Data:r})),n=je(Os,t);return new Cr(e,n)}function Au(r){if(Fs(r)>Ho)throw new be("Key size is too large");let e=Iu(r),t=Er(it.encode({Type:fe.RSA,Data:Ds(e.publicKey)})),n=je(Os,t);return new fn(e.privateKey,new Cr(e.publicKey,n))}async function Su(r){if(r>Ho)throw new be("Key size is too large");let e=await wu(r),t=Er(it.encode({Type:fe.RSA,Data:Ds(e.publicKey)})),n=je(Os,t);return new fn(e.privateKey,new Cr(e.publicKey,n))}function Iu(r){if(r==null)throw new be("Missing key parameter");return{privateKey:r,publicKey:{kty:r.kty,n:r.n,e:r.e}}}var $o=class extends pr{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,Ga(e);let n=zr(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,i=new Uint8Array(o);i.set(n.length>o?e.create().update(n).digest():n);for(let s=0;snew $o(r,e).update(t).digest();Hs.create=(r,e)=>new $o(r,e);function ku(r){r.lowS!==void 0&&Ze("lowS",r.lowS),r.prehash!==void 0&&Ze("prehash",r.prehash)}function _0(r){let e=Zr(r);ot(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:t,Fp:n,a:o}=e;if(t){if(!n.eql(o,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}var{bytesToNumberBE:L0,hexToBytes:V0}=On,At={Err:class extends Error{constructor(e=""){super(e)}},_tlv:{encode:(r,e)=>{let{Err:t}=At;if(r<0||r>256)throw new t("tlv.encode: wrong tag");if(e.length&1)throw new t("tlv.encode: unpadded data");let n=e.length/2,o=jt(n);if(o.length/2&128)throw new t("tlv.encode: long form length too big");let i=n>127?jt(o.length/2|128):"";return`${jt(r)}${i}${o}${e}`},decode(r,e){let{Err:t}=At,n=0;if(r<0||r>256)throw new t("tlv.encode: wrong tag");if(e.length<2||e[n++]!==r)throw new t("tlv.decode: wrong tlv");let o=e[n++],i=!!(o&128),s=0;if(!i)s=o;else{let c=o&127;if(!c)throw new t("tlv.decode(long): indefinite length not supported");if(c>4)throw new t("tlv.decode(long): byte length is too big");let f=e.subarray(n,n+c);if(f.length!==c)throw new t("tlv.decode: length bytes not complete");if(f[0]===0)throw new t("tlv.decode(long): zero leftmost byte");for(let u of f)s=s<<8|u;if(n+=c,s<128)throw new t("tlv.decode(long): not minimal encoding")}let a=e.subarray(n,n+s);if(a.length!==s)throw new t("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+s)}}},_int:{encode(r){let{Err:e}=At;if(r{let C=d.toAffine();return yt(Uint8Array.from([4]),t.toBytes(C.x),t.toBytes(C.y))}),i=e.fromBytes||(w=>{let d=w.subarray(1),E=t.fromBytes(d.subarray(0,t.BYTES)),C=t.fromBytes(d.subarray(t.BYTES,2*t.BYTES));return{x:E,y:C}});function s(w){let{a:d,b:E}=e,C=t.sqr(w),x=t.mul(C,w);return t.add(t.add(x,t.mul(w,d)),E)}if(!t.eql(t.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function a(w){return jr(w,pe,e.n)}function c(w){let{allowedPrivateKeyLengths:d,nByteLength:E,wrapPrivateKey:C,n:x}=e;if(d&&typeof w!="bigint"){if(Rt(w)&&(w=mt(w)),typeof w!="string"||!d.includes(w.length))throw new Error("Invalid key");w=w.padStart(E*2,"0")}let T;try{T=typeof w=="bigint"?w:gt(ae("private key",w,E))}catch{throw new Error(`private key must be ${E} bytes, hex or bigint, not ${typeof w}`)}return C&&(T=Q(T,x)),Ue("private key",T,pe,x),T}function f(w){if(!(w instanceof h))throw new Error("ProjectivePoint expected")}let u=Wt((w,d)=>{let{px:E,py:C,pz:x}=w;if(t.eql(x,t.ONE))return{x:E,y:C};let T=w.is0();d==null&&(d=T?t.ONE:t.inv(x));let F=t.mul(E,d),V=t.mul(C,d),U=t.mul(x,d);if(T)return{x:t.ZERO,y:t.ZERO};if(!t.eql(U,t.ONE))throw new Error("invZ was invalid");return{x:F,y:V}}),l=Wt(w=>{if(w.is0()){if(e.allowInfinityPoint&&!t.is0(w.py))return;throw new Error("bad point: ZERO")}let{x:d,y:E}=w.toAffine();if(!t.isValid(d)||!t.isValid(E))throw new Error("bad point: x or y not FE");let C=t.sqr(E),x=s(d);if(!t.eql(C,x))throw new Error("bad point: equation left != right");if(!w.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class h{constructor(d,E,C){if(this.px=d,this.py=E,this.pz=C,d==null||!t.isValid(d))throw new Error("x required");if(E==null||!t.isValid(E))throw new Error("y required");if(C==null||!t.isValid(C))throw new Error("z required");Object.freeze(this)}static fromAffine(d){let{x:E,y:C}=d||{};if(!d||!t.isValid(E)||!t.isValid(C))throw new Error("invalid affine point");if(d instanceof h)throw new Error("projective point not allowed");let x=T=>t.eql(T,t.ZERO);return x(E)&&x(C)?h.ZERO:new h(E,C,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){let E=t.invertBatch(d.map(C=>C.pz));return d.map((C,x)=>C.toAffine(E[x])).map(h.fromAffine)}static fromHex(d){let E=h.fromAffine(i(ae("pointHex",d)));return E.assertValidity(),E}static fromPrivateKey(d){return h.BASE.multiply(c(d))}static msm(d,E){return Hn(h,n,d,E)}_setWindowSize(d){I.setWindowSize(this,d)}assertValidity(){l(this)}hasEvenY(){let{y:d}=this.toAffine();if(t.isOdd)return!t.isOdd(d);throw new Error("Field doesn't support isOdd")}equals(d){f(d);let{px:E,py:C,pz:x}=this,{px:T,py:F,pz:V}=d,U=t.eql(t.mul(E,V),t.mul(T,x)),g=t.eql(t.mul(C,V),t.mul(F,x));return U&&g}negate(){return new h(this.px,t.neg(this.py),this.pz)}double(){let{a:d,b:E}=e,C=t.mul(E,Cu),{px:x,py:T,pz:F}=this,V=t.ZERO,U=t.ZERO,g=t.ZERO,v=t.mul(x,x),O=t.mul(T,T),R=t.mul(F,F),N=t.mul(x,T);return N=t.add(N,N),g=t.mul(x,F),g=t.add(g,g),V=t.mul(d,g),U=t.mul(C,R),U=t.add(V,U),V=t.sub(O,U),U=t.add(O,U),U=t.mul(V,U),V=t.mul(N,V),g=t.mul(C,g),R=t.mul(d,R),N=t.sub(v,R),N=t.mul(d,N),N=t.add(N,g),g=t.add(v,v),v=t.add(g,v),v=t.add(v,R),v=t.mul(v,N),U=t.add(U,v),R=t.mul(T,F),R=t.add(R,R),v=t.mul(R,N),V=t.sub(V,v),g=t.mul(R,O),g=t.add(g,g),g=t.add(g,g),new h(V,U,g)}add(d){f(d);let{px:E,py:C,pz:x}=this,{px:T,py:F,pz:V}=d,U=t.ZERO,g=t.ZERO,v=t.ZERO,O=e.a,R=t.mul(e.b,Cu),N=t.mul(E,T),$=t.mul(C,F),A=t.mul(x,V),S=t.add(E,C),m=t.add(T,F);S=t.mul(S,m),m=t.add(N,$),S=t.sub(S,m),m=t.add(E,x);let p=t.add(T,V);return m=t.mul(m,p),p=t.add(N,A),m=t.sub(m,p),p=t.add(C,x),U=t.add(F,V),p=t.mul(p,U),U=t.add($,A),p=t.sub(p,U),v=t.mul(O,m),U=t.mul(R,A),v=t.add(U,v),U=t.sub($,v),v=t.add($,v),g=t.mul(U,v),$=t.add(N,N),$=t.add($,N),A=t.mul(O,A),m=t.mul(R,m),$=t.add($,A),A=t.sub(N,A),A=t.mul(O,A),m=t.add(m,A),N=t.mul($,m),g=t.add(g,N),N=t.mul(p,m),U=t.mul(S,U),U=t.sub(U,N),N=t.mul(S,$),v=t.mul(p,v),v=t.add(v,N),new h(U,g,v)}subtract(d){return this.add(d.negate())}is0(){return this.equals(h.ZERO)}wNAF(d){return I.wNAFCached(this,d,h.normalizeZ)}multiplyUnsafe(d){Ue("scalar",d,St,e.n);let E=h.ZERO;if(d===St)return E;if(d===pe)return this;let{endo:C}=e;if(!C)return I.unsafeLadder(this,d);let{k1neg:x,k1:T,k2neg:F,k2:V}=C.splitScalar(d),U=E,g=E,v=this;for(;T>St||V>St;)T&pe&&(U=U.add(v)),V&pe&&(g=g.add(v)),v=v.double(),T>>=pe,V>>=pe;return x&&(U=U.negate()),F&&(g=g.negate()),g=new h(t.mul(g.px,C.beta),g.py,g.pz),U.add(g)}multiply(d){let{endo:E,n:C}=e;Ue("scalar",d,pe,C);let x,T;if(E){let{k1neg:F,k1:V,k2neg:U,k2:g}=E.splitScalar(d),{p:v,f:O}=this.wNAF(V),{p:R,f:N}=this.wNAF(g);v=I.constTimeNegate(F,v),R=I.constTimeNegate(U,R),R=new h(t.mul(R.px,E.beta),R.py,R.pz),x=v.add(R),T=O.add(N)}else{let{p:F,f:V}=this.wNAF(d);x=F,T=V}return h.normalizeZ([x,T])[0]}multiplyAndAddUnsafe(d,E,C){let x=h.BASE,T=(V,U)=>U===St||U===pe||!V.equals(x)?V.multiplyUnsafe(U):V.multiply(U),F=T(this,E).add(T(d,C));return F.is0()?void 0:F}toAffine(d){return u(this,d)}isTorsionFree(){let{h:d,isTorsionFree:E}=e;if(d===pe)return!0;if(E)return E(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:d,clearCofactor:E}=e;return d===pe?this:E?E(h,this):this.multiplyUnsafe(e.h)}toRawBytes(d=!0){return Ze("isCompressed",d),this.assertValidity(),o(h,this,d)}toHex(d=!0){return Ze("isCompressed",d),mt(this.toRawBytes(d))}}h.BASE=new h(e.Gx,e.Gy,t.ONE),h.ZERO=new h(t.ZERO,t.ONE,t.ZERO);let b=e.nBitLength,I=Mn(h,e.endo?Math.ceil(b/2):b);return{CURVE:e,ProjectivePoint:h,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:a}}function F0(r){let e=Zr(r);return ot(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function Tu(r){let e=F0(r),{Fp:t,n}=e,o=t.BYTES+1,i=2*t.BYTES+1;function s(A){return Q(A,n)}function a(A){return Dn(A,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:f,weierstrassEquation:u,isWithinCurveOrder:l}=P0({...e,toBytes(A,S,m){let p=S.toAffine(),B=t.toBytes(p.x),P=yt;return Ze("isCompressed",m),m?P(Uint8Array.from([S.hasEvenY()?2:3]),B):P(Uint8Array.from([4]),B,t.toBytes(p.y))},fromBytes(A){let S=A.length,m=A[0],p=A.subarray(1);if(S===o&&(m===2||m===3)){let B=gt(p);if(!jr(B,pe,t.ORDER))throw new Error("Point is not on curve");let P=u(B),D;try{D=t.sqrt(P)}catch(G){let z=G instanceof Error?": "+G.message:"";throw new Error("Point is not on curve"+z)}let M=(D&pe)===pe;return(m&1)===1!==M&&(D=t.neg(D)),{x:B,y:D}}else if(S===i&&m===4){let B=t.fromBytes(p.subarray(0,t.BYTES)),P=t.fromBytes(p.subarray(t.BYTES,2*t.BYTES));return{x:B,y:P}}else throw new Error(`Point of length ${S} was invalid. Expected ${o} compressed bytes or ${i} uncompressed bytes`)}}),h=A=>mt(Lt(A,e.nByteLength));function b(A){let S=n>>pe;return A>S}function I(A){return b(A)?s(-A):A}let w=(A,S,m)=>gt(A.slice(S,m));class d{constructor(S,m,p){this.r=S,this.s=m,this.recovery=p,this.assertValidity()}static fromCompact(S){let m=e.nByteLength;return S=ae("compactSignature",S,m*2),new d(w(S,0,m),w(S,m,2*m))}static fromDER(S){let{r:m,s:p}=At.toSig(ae("DER",S));return new d(m,p)}assertValidity(){Ue("r",this.r,pe,n),Ue("s",this.s,pe,n)}addRecoveryBit(S){return new d(this.r,this.s,S)}recoverPublicKey(S){let{r:m,s:p,recovery:B}=this,P=V(ae("msgHash",S));if(B==null||![0,1,2,3].includes(B))throw new Error("recovery id invalid");let D=B===2||B===3?m+e.n:m;if(D>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");let M=B&1?"03":"02",q=c.fromHex(M+h(D)),G=a(D),z=s(-P*G),X=s(p*G),te=c.BASE.multiplyAndAddUnsafe(q,z,X);if(!te)throw new Error("point at infinify");return te.assertValidity(),te}hasHighS(){return b(this.s)}normalizeS(){return this.hasHighS()?new d(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return Gt(this.toDERHex())}toDERHex(){return At.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Gt(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}let E={isValidPrivateKey(A){try{return f(A),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let A=Wi(e.n);return sc(e.randomBytes(A),e.n)},precompute(A=8,S=c.BASE){return S._setWindowSize(A),S.multiply(BigInt(3)),S}};function C(A,S=!0){return c.fromPrivateKey(A).toRawBytes(S)}function x(A){let S=Rt(A),m=typeof A=="string",p=(S||m)&&A.length;return S?p===o||p===i:m?p===2*o||p===2*i:A instanceof c}function T(A,S,m=!0){if(x(A))throw new Error("first arg must be private key");if(!x(S))throw new Error("second arg must be public key");return c.fromHex(S).multiply(f(A)).toRawBytes(m)}let F=e.bits2int||function(A){let S=gt(A),m=A.length*8-e.nBitLength;return m>0?S>>BigInt(m):S},V=e.bits2int_modN||function(A){return s(F(A))},U=Gr(e.nBitLength);function g(A){return Ue(`num < 2^${e.nBitLength}`,A,St,U),Lt(A,e.nByteLength)}function v(A,S,m=O){if(["recovered","canonical"].some(de=>de in m))throw new Error("sign() legacy options not supported");let{hash:p,randomBytes:B}=e,{lowS:P,prehash:D,extraEntropy:M}=m;P==null&&(P=!0),A=ae("msgHash",A),ku(m),D&&(A=ae("prehashed msgHash",p(A)));let q=V(A),G=f(S),z=[g(G),g(q)];if(M!=null&&M!==!1){let de=M===!0?B(t.BYTES):M;z.push(ae("extraEntropy",de))}let X=yt(...z),te=q;function he(de){let ge=F(de);if(!l(ge))return;let Se=a(ge),ce=c.BASE.multiply(ge).toAffine(),Ne=s(ce.x);if(Ne===St)return;let lt=s(Se*s(te+Ne*G));if(lt===St)return;let Mr=(ce.x===Ne?0:2)|Number(ce.y&pe),Hr=lt;return P&&b(lt)&&(Hr=I(lt),Mr^=1),new d(Ne,Hr,Mr)}return{seed:X,k2sig:he}}let O={lowS:e.lowS,prehash:!1},R={lowS:e.lowS,prehash:!1};function N(A,S,m=O){let{seed:p,k2sig:B}=v(A,S,m),P=e;return zi(P.hash.outputLen,P.nByteLength,P.hmac)(p,B)}c.BASE._setWindowSize(8);function $(A,S,m,p=R){let B=A;if(S=ae("msgHash",S),m=ae("publicKey",m),"strict"in p)throw new Error("options.strict was renamed to lowS");ku(p);let{lowS:P,prehash:D}=p,M,q;try{if(typeof B=="string"||Rt(B))try{M=d.fromDER(B)}catch(ce){if(!(ce instanceof At.Err))throw ce;M=d.fromCompact(B)}else if(typeof B=="object"&&typeof B.r=="bigint"&&typeof B.s=="bigint"){let{r:ce,s:Ne}=B;M=new d(ce,Ne)}else throw new Error("PARSE");q=c.fromHex(m)}catch(ce){if(ce.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(P&&M.hasHighS())return!1;D&&(S=e.hash(S));let{r:G,s:z}=M,X=V(S),te=a(z),he=s(X*te),de=s(G*te),ge=c.BASE.multiplyAndAddUnsafe(q,he,de)?.toAffine();return ge?s(ge.x)===G:!1}return{CURVE:e,getPublicKey:C,getSharedSecret:T,sign:N,verify:$,ProjectivePoint:c,Signature:d,utils:E}}function O0(r){return{hash:r,hmac:(e,...t)=>Hs(r,e,Fi(...t)),randomBytes:Vn}}function Nu(r,e){let t=n=>Tu({...r,...O0(n)});return Object.freeze({...t(e),create:t})}var _u=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Uu=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),D0=BigInt(1),$s=BigInt(2),Ru=(r,e)=>(r+e/$s)/e;function M0(r){let e=_u,t=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),f=r*r*r%e,u=f*f*r%e,l=oe(u,t,e)*u%e,h=oe(l,t,e)*u%e,b=oe(h,$s,e)*f%e,I=oe(b,o,e)*b%e,w=oe(I,i,e)*I%e,d=oe(w,a,e)*w%e,E=oe(d,c,e)*d%e,C=oe(E,a,e)*w%e,x=oe(C,t,e)*u%e,T=oe(x,s,e)*I%e,F=oe(T,n,e)*f%e,V=oe(F,$s,e);if(!Ks.eql(Ks.sqr(V),r))throw new Error("Cannot find square root");return V}var Ks=Vt(_u,void 0,void 0,{sqrt:M0}),tr=Nu({a:BigInt(0),b:BigInt(7),Fp:Ks,n:Uu,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let e=Uu,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-D0*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=t,s=BigInt("0x100000000000000000000000000000000"),a=Ru(i*r,e),c=Ru(-n*r,e),f=Q(r-a*t-c*o,e),u=Q(-a*n-c*i,e),l=f>s,h=u>s;if(l&&(f=e-f),h&&(u=e-u),f>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:l,k1:f,k2neg:h,k2:u}}}},Er),Pw=BigInt(0);var Fw=tr.ProjectivePoint;function Fe(r,e){e==null&&(e=r.reduce((o,i)=>o+i.length,0));let t=Je(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return t}function Lu(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function Vu(r,e,t){let n=Wr.digest(t instanceof Uint8Array?t:t.subarray());if(Lu(n))return n.then(({digest:o})=>tr.verify(e,o,r)).catch(o=>{throw new un(String(o))});try{return tr.verify(e,n.digest,r)}catch(o){throw new un(String(o))}}var Ko=class{type="secp256k1";raw;_key;constructor(e){this._key=Fu(e),this.raw=Pu(this._key)}toMultihash(){return dt.digest(zn(this))}toCID(){return ie.createV1(114,this.toMultihash())}toString(){return re.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ue(this.raw,e.raw)}verify(e,t){return Vu(this._key,t,e)}};function qs(r){return new Ko(r)}function Pu(r){return tr.ProjectivePoint.fromHex(r).toRawBytes(!0)}function Fu(r){try{return tr.ProjectivePoint.fromHex(r),r}catch(e){throw new or(String(e))}}function Ou(r){let{Type:e,Data:t}=it.decode(r),n=t??new Uint8Array;switch(e){case fe.RSA:return Ms(n);case fe.Ed25519:return es(n);case fe.secp256k1:return qs(n);default:throw new sr}}function qo(r){let{Type:e,Data:t}=it.decode(r.digest),n=t??new Uint8Array;switch(e){case fe.Ed25519:return es(n);case fe.secp256k1:return qs(n);default:throw new sr}}function zn(r){return it.encode({Type:fe[r.type],Data:r.raw})}var Du=Symbol.for("nodejs.util.inspect.custom"),H0=114,hn=class{type;multihash;publicKey;string;constructor(e){this.type=e.type,this.multihash=e.multihash,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[Ai]=!0;toString(){return this.string==null&&(this.string=re.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return ie.createV1(H0,this.multihash)}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return ue(this.multihash.bytes,e);if(typeof e=="string")return this.toString()===e;if(e?.toMultihash()?.bytes!=null)return ue(this.multihash.bytes,e.toMultihash().bytes);throw new Error("not valid Id")}[Du](){return`PeerId(${this.toString()})`}},zo=class extends hn{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},jo=class extends hn{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.publicKey}},Go=class extends hn{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.publicKey}},$0=2336,Zo=class{type="url";multihash;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=dt.digest(Y(this.url))}[Du](){return`PeerId(${this.url})`}[Ai]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return ie.createV1($0,this.toMultihash())}toJSON(){return this.toString()}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=Z(e)),e.toString()===this.toString())}};function Mu(r,e){let t;if(r.charAt(0)==="1"||r.charAt(0)==="Q")t=ht(re.decode(`z${r}`));else{if(e==null)throw new be('Please pass a multibase decoder for strings that do not start with "1" or "Q"');t=ht(e.decode(r))}return K0(t)}function K0(r){if(z0(r))return new zo({multihash:r});if(q0(r))try{let e=qo(r);if(e.type==="Ed25519")return new jo({multihash:r,publicKey:e});if(e.type==="secp256k1")return new Go({multihash:r,publicKey:e})}catch{let t=Z(r.digest);return new Zo(new URL(t))}throw new ir("Supplied PeerID Multihash is invalid")}function q0(r){return r.code===dt.code}function z0(r){return r.code===Wr.code}var Wo=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let t=this.index,n=e();return n===void 0&&(this.index=t),n}parseWith(e){let t=e();if(this.index===this.input.length)return t}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(e){return this.readAtomically(()=>{let t=this.readChar();if(t===e)return t})}readSeparator(e,t,n){return this.readAtomically(()=>{if(!(t>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,t,n,o){return this.readAtomically(()=>{let i=0,s=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",f=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let l=this.readChar();if(l===void 0)return;let h=Number.parseInt(l,e);if(!Number.isNaN(h))return h});if(u===void 0)break;if(i*=e,i+=u,i>f||(s+=1,t!==void 0&&s>t))return}if(s!==0)return!n&&c&&s>1?void 0:i})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let t=0;tthis.readNumber(10,3,!1,1));if(n===void 0)return;e[t]=n}return e})}readIPv6Addr(){let e=t=>{for(let n=0;nthis.readIPv4Addr());if(s!==void 0)return t[o]=s[0],t[o+1]=s[1],t[o+2]=s[2],t[o+3]=s[3],[o+4,!0]}let i=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(i===void 0)return[o,!1];t[o]=i>>8,t[o+1]=i&255}return[t.length,!1]};return this.readAtomically(()=>{let t=new Uint8Array(16),[n,o]=e(t);if(n===16)return t;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let i=new Uint8Array(14),s=16-(n+2),[a]=e(i.subarray(0,s));return t.set(i.subarray(0,a),16-a),t})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Hu=45,j0=15,Tr=new Wo;function zs(r){if(!(r.length>j0))return Tr.new(r).parseWith(()=>Tr.readIPv4Addr())}function js(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Hu))return Tr.new(r).parseWith(()=>Tr.readIPv6Addr())}function Jo(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Hu))return Tr.new(r).parseWith(()=>Tr.readIPAddr())}var Qx=parseInt("0xFFFF",16),eb=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function qu(r){return!!zs(r)}function zu(r){return!!js(r)}function Yo(r){return!!Jo(r)}var ju=qu,Y0=zu,Gs=function(r){let e=0;if(r=r.toString().trim(),ju(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(Y0(r)){let t=r.split(":",8),n;for(n=0;n0;n--)i.push("0");t.splice.apply(t,i)}let o=new Uint8Array(e+16);for(n=0;n>8&255,o[e++]=i&255}return o}throw new Error("invalid ip address")},Gu=function(r,e=0,t){e=~~e,t=t??r.length-e;let n=new DataView(r.buffer);if(t===4){let o=[];for(let i=0;i{let e=ep(...r);Zs[e.code]=e,Nr[e.name]=e});function ep(r,e,t,n,o){return{code:r,size:e,name:t,resolvable:!!n,path:!!o}}function ee(r){if(typeof r=="number"){if(Zs[r]!=null)return Zs[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Nr[r]!=null)return Nr[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var Fb=ee("ip4"),Ob=ee("ip6"),Db=ee("ipcidr");function Xs(r,e){switch(ee(r).code){case 4:case 41:return rp(e);case 42:return Ys(e);case 6:case 273:case 33:case 132:return Ju(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Ys(e);case 421:return sp(e);case 444:return Wu(e);case 445:return Wu(e);case 466:return ip(e);case 481:return globalThis.encodeURIComponent(Ys(e));default:return Z(e,"base16")}}function Qs(r,e){switch(ee(r).code){case 4:return Zu(e);case 41:return Zu(e);case 42:return Js(e);case 6:case 273:case 33:case 132:return ea(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Js(e);case 421:return np(e);case 444:return ap(e);case 445:return cp(e);case 466:return op(e);case 481:return Js(globalThis.decodeURIComponent(e));default:return Y(e,"base16")}}var Ws=Object.values(Jr).map(r=>r.decoder),tp=function(){let r=Ws[0].or(Ws[1]);return Ws.slice(2).forEach(e=>r=r.or(e)),r}();function Zu(r){if(!Yo(r))throw new Error("invalid ip address");return Gs(r)}function rp(r){let e=Gu(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!Yo(e))throw new Error("invalid ip address");return e}function ea(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function Ju(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Js(r){let e=Y(r),t=Uint8Array.from(yr(e.length));return Fe([t,e],t.length+e.length)}function Ys(r){let e=Yt(r);if(r=r.slice(_e(e)),r.length!==e)throw new Error("inconsistent lengths");return Z(r)}function np(r){let e;r[0]==="Q"||r[0]==="1"?e=ht(re.decode(`z${r}`)).bytes:e=ie.parse(r).multihash.bytes;let t=Uint8Array.from(yr(e.length));return Fe([t,e],t.length+e.length)}function op(r){let e=tp.decode(r),t=Uint8Array.from(yr(e.length));return Fe([t,e],t.length+e.length)}function ip(r){let e=Yt(r),t=r.slice(_e(e));if(t.length!==e)throw new Error("inconsistent lengths");return"u"+Z(t,"base64url")}function sp(r){let e=Yt(r),t=r.slice(_e(e));if(t.length!==e)throw new Error("inconsistent lengths");return Z(t,"base58btc")}function ap(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let t=ze.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ea(n);return Fe([t,o],t.length+o.length)}function cp(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let t=ze.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ea(n);return Fe([t,o],t.length+o.length)}function Wu(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=Z(e,"base32"),o=Ju(t);return`${n}:${o}`}function Yu(r){r=ta(r);let e=[],t=[],n=null,o=r.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let i=0;i=o.length)throw Qu("invalid address: "+r);if(a.path===!0){n=ta(o.slice(i).join("/")),e.push([a.code,Qs(a.code,n)]),t.push([a.code,n]);break}let c=Qs(a.code,o[i]);e.push([a.code,c]),t.push([a.code,Xs(a.code,c)])}return{string:Xu(t),bytes:na(e),tuples:e,stringTuples:t,path:n}}function ra(r){let e=[],t=[],n=null,o=0;for(;or.length)throw Qu("Invalid address Uint8Array: "+Z(r,"base16"));e.push([i,f]);let u=Xs(i,f);if(t.push([i,u]),a.path===!0){n=u;break}}return{bytes:Uint8Array.from(r),string:Xu(t),tuples:e,stringTuples:t,path:n}}function Xu(r){let e=[];return r.map(t=>{let n=ee(t[0]);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),ta(e.join("/"))}function na(r){return Fe(r.map(e=>{let t=ee(e[0]),n=Uint8Array.from(yr(t.code));return e.length>1&&e[1]!=null&&(n=Fe([n,e[1]])),n}))}function up(r,e){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let t=Yt(e instanceof Uint8Array?e:Uint8Array.from(e));return t+_e(t)}}function ta(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function Qu(r){return new Error("Error parsing address: "+r)}var lp=Symbol.for("nodejs.util.inspect.custom"),ia=Symbol.for("@multiformats/js-multiaddr/multiaddr"),fp=[ee("dns").code,ee("dns4").code,ee("dns6").code,ee("dnsaddr").code],oa=class extends Error{constructor(e="No available resolver"){super(e),this.name="NoAvailableResolverError"}},Xo=class r{bytes;#e;#r;#i;#a;[ia]=!0;constructor(e){e==null&&(e="");let t;if(e instanceof Uint8Array)t=ra(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);t=Yu(e)}else if(tl(e))t=ra(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=t.bytes,this.#e=t.string,this.#r=t.tuples,this.#i=t.stringTuples,this.#a=t.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let e,t,n,o,i="",s=ee("tcp"),a=ee("udp"),c=ee("ip4"),f=ee("ip6"),u=ee("dns6"),l=ee("ip6zone");for(let[b,I]of this.stringTuples())b===l.code&&(i=`%${I??""}`),fp.includes(b)&&(t=s.name,o=443,n=`${I??""}${i}`,e=b===u.code?6:4),(b===s.code||b===a.code)&&(t=ee(b).name,o=parseInt(I??"")),(b===c.code||b===f.code)&&(t=ee(b).name,n=`${I??""}${i}`,e=b===f.code?6:4);if(e==null||t==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e,host:n,transport:t,port:o}}protos(){return this.#r.map(([e])=>Object.assign({},ee(e)))}protoCodes(){return this.#r.map(([e])=>e)}protoNames(){return this.#r.map(([e])=>ee(e).name)}tuples(){return this.#r}stringTuples(){return this.#i}encapsulate(e){return e=new r(e),new r(this.toString()+e.toString())}decapsulate(e){let t=e.toString(),n=this.toString(),o=n.lastIndexOf(t);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new r(n.slice(0,o))}decapsulateCode(e){let t=this.tuples();for(let n=t.length-1;n>=0;n--)if(t[n][0]===e)return new r(na(t.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,o])=>{n===Nr.p2p.code&&e.push([n,o]),n===Nr["p2p-circuit"].code&&(e=[])});let t=e.pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?Z(re.decode(`z${n}`),"base58btc"):Z(ie.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#a}equals(e){return ue(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(i=>i.resolvable);if(t==null)return[this];let n=el.get(t.name);if(n==null)throw new oa(`no available resolver for ${t.name}`);return(await n(this,e)).map(i=>dn(i))}nodeAddress(){let e=this.toOptions();if(e.transport!=="tcp"&&e.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){let t=(e??this).protos();return!(t.length!==2||t[0].code!==4&&t[0].code!==41||t[1].code!==6&&t[1].code!==273)}[lp](){return`Multiaddr(${this.#e})`}};var el=new Map;function tl(r){return!!r?.[ia]}function dn(r){return new Xo(r)}function pn(r){let e=new globalThis.AbortController;function t(){e.abort();for(let i of r)i?.removeEventListener!=null&&i.removeEventListener("abort",t)}for(let i of r){if(i?.aborted===!0){t();break}i?.addEventListener!=null&&i.addEventListener("abort",t)}function n(){for(let i of r)i?.removeEventListener!=null&&i.removeEventListener("abort",t)}let o=e.signal;return o.clear=n,o}async function*Qo(r,e={}){let t=r.getReader();try{for(;;){let n=await t.read();if(n.done)return;yield n.value}}finally{e.preventCancel!==!0&&await t.cancel(),t.releaseLock()}}var hp="/",dp=new TextEncoder().encode(hp),d1=dp[0];var Gp=Cn(aa(),1);var Qe=class extends Error{static name="SignatureVerificationError";constructor(e="Record signature verification failed"){super(e),this.name="SignatureVerificationError"}},ei=class extends Error{static name="RecordExpiredError";constructor(e="Record has expired"){super(e),this.name="RecordExpiredError"}},Ur=class extends Error{static name="UnsupportedValidityError";constructor(e="The validity type is unsupported"){super(e),this.name="UnsupportedValidityError"}},ti=class extends Error{static name="RecordTooLargeError";constructor(e="The record is too large"){super(e),this.name="RecordTooLargeError"}},ri=class extends Error{static name="InvalidValueError";constructor(e="Value must be a valid content path starting with /"){super(e),this.name="InvalidValueError"}},ni=class extends Error{static name="InvalidRecordDataError";constructor(e="Invalid record data"){super(e),this.name="InvalidRecordDataError"}},mn=class extends Error{static name="InvalidEmbeddedPublicKeyError";constructor(e="Invalid embedded public key"){super(e),this.name="InvalidEmbeddedPublicKeyError"}};var et;(function(r){let e;(function(o){o.EOL="EOL"})(e=r.ValidityType||(r.ValidityType={}));let t;(function(o){o[o.EOL=0]="EOL"})(t||(t={})),function(o){o.codec=()=>Qr(t)}(e=r.ValidityType||(r.ValidityType={}));let n;r.codec=()=>(n==null&&(n=vr((o,i,s={})=>{s.lengthDelimited!==!1&&i.fork(),o.value!=null&&(i.uint32(10),i.bytes(o.value)),o.signatureV1!=null&&(i.uint32(18),i.bytes(o.signatureV1)),o.validityType!=null&&(i.uint32(24),r.ValidityType.codec().encode(o.validityType,i)),o.validity!=null&&(i.uint32(34),i.bytes(o.validity)),o.sequence!=null&&(i.uint32(40),i.uint64(o.sequence)),o.ttl!=null&&(i.uint32(48),i.uint64(o.ttl)),o.pubKey!=null&&(i.uint32(58),i.bytes(o.pubKey)),o.signatureV2!=null&&(i.uint32(66),i.bytes(o.signatureV2)),o.data!=null&&(i.uint32(74),i.bytes(o.data)),s.lengthDelimited!==!1&&i.ldelim()},(o,i,s={})=>{let a={},c=i==null?o.len:o.pos+i;for(;o.pos>>3){case 1:{a.value=o.bytes();break}case 2:{a.signatureV1=o.bytes();break}case 3:{a.validityType=r.ValidityType.codec().decode(o);break}case 4:{a.validity=o.bytes();break}case 5:{a.sequence=o.uint64();break}case 6:{a.ttl=o.uint64();break}case 7:{a.pubKey=o.bytes();break}case 8:{a.signatureV2=o.bytes();break}case 9:{a.data=o.bytes();break}default:{o.skipType(f&7);break}}}return a})),n),r.encode=o=>xr(o,r.codec()),r.decode=(o,i)=>wr(o,r.codec(),i)})(et||(et={}));var pp=["string","number","bigint","symbol"],mp=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function rl(r){if(r===null)return"null";if(r===void 0)return"undefined";if(r===!0||r===!1)return"boolean";let e=typeof r;if(pp.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(r))return"Array";if(gp(r))return"Buffer";let t=yp(r);return t||"Object"}function gp(r){return r&&r.constructor&&r.constructor.isBuffer&&r.constructor.isBuffer.call(null,r)}function yp(r){let e=Object.prototype.toString.call(r).slice(8,-1);if(mp.includes(e))return e}var y=class{constructor(e,t,n){this.major=e,this.majorEncoded=e<<5,this.name=t,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.majore.major?1:0}};y.uint=new y(0,"uint",!0);y.negint=new y(1,"negint",!0);y.bytes=new y(2,"bytes",!0);y.string=new y(3,"string",!0);y.array=new y(4,"array",!1);y.map=new y(5,"map",!1);y.tag=new y(6,"tag",!1);y.float=new y(7,"float",!0);y.false=new y(7,"false",!0);y.true=new y(7,"true",!0);y.null=new y(7,"null",!0);y.undefined=new y(7,"undefined",!0);y.break=new y(7,"break",!0);var L=class{constructor(e,t,n){this.type=e,this.value=t,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var Rr=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",wp=new TextDecoder,xp=new TextEncoder;function oi(r){return Rr&&globalThis.Buffer.isBuffer(r)}function sl(r){return r instanceof Uint8Array?oi(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r:Uint8Array.from(r)}var al=Rr?(r,e,t)=>t-e>64?globalThis.Buffer.from(r.subarray(e,t)).toString("utf8"):ol(r,e,t):(r,e,t)=>t-e>64?wp.decode(r.subarray(e,t)):ol(r,e,t),cl=Rr?r=>r.length>64?globalThis.Buffer.from(r):nl(r):r=>r.length>64?xp.encode(r):nl(r);var _r=Rr?(r,e,t)=>oi(r)?new Uint8Array(r.subarray(e,t)):r.slice(e,t):(r,e,t)=>r.slice(e,t),ul=Rr?(r,e)=>(r=r.map(t=>t instanceof Uint8Array?t:globalThis.Buffer.from(t)),sl(globalThis.Buffer.concat(r,e))):(r,e)=>{let t=new Uint8Array(e),n=0;for(let o of r)n+o.length>t.length&&(o=o.subarray(0,t.length-n)),t.set(o,n),n+=o.length;return t},ll=Rr?r=>globalThis.Buffer.allocUnsafe(r):r=>new Uint8Array(r);function fl(r,e){if(oi(r)&&oi(e))return r.compare(e);for(let t=0;t>6|192,e[t++]=o&63|128):(o&64512)===55296&&n+1>18|240,e[t++]=o>>12&63|128,e[t++]=o>>6&63|128,e[t++]=o&63|128):(e[t++]=o>>12|224,e[t++]=o>>6&63|128,e[t++]=o&63|128)}return e}function ol(r,e,t){let n=[];for(;e239?4:o>223?3:o>191?2:1;if(e+s<=t){let a,c,f,u;switch(s){case 1:o<128&&(i=o);break;case 2:a=r[e+1],(a&192)===128&&(u=(o&31)<<6|a&63,u>127&&(i=u));break;case 3:a=r[e+1],c=r[e+2],(a&192)===128&&(c&192)===128&&(u=(o&15)<<12|(a&63)<<6|c&63,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:a=r[e+1],c=r[e+2],f=r[e+3],(a&192)===128&&(c&192)===128&&(f&192)===128&&(u=(o&15)<<18|(a&63)<<12|(c&63)<<6|f&63,u>65535&&u<1114112&&(i=u))}}i===null?(i=65533,s=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),e+=s}return bp(n)}var il=4096;function bp(r){let e=r.length;if(e<=il)return String.fromCharCode.apply(String,r);let t="",n=0;for(;nn.length/2?(t=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):t=_r(n,0,this.cursor)}else t=ul(this.chunks,this.cursor);return e&&this.reset(),t}};var H="CBOR decode error:",ca="CBOR encode error:",gn=[];gn[23]=1;gn[24]=2;gn[25]=3;gn[26]=5;gn[27]=9;function It(r,e,t){if(r.length-e>>8,n&255])}else if(t>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(t);if(n>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&255,o[4]=s&255,s=s>>8,o[3]=s&255,s=s>>8,o[2]=s&255,s=s>>8,o[1]=s&255,r.push(o)}else throw new Error(`${H} encountered BigInt larger than allowable range`)}}Ke.encodedSize=function(e){return xe.encodedSize(e.value)};xe.encodedSize=function(e){return et.value?1:0};function gl(r,e,t,n){return new L(y.negint,-1-Oe(r,e+1,n),2)}function yl(r,e,t,n){return new L(y.negint,-1-De(r,e+1,n),3)}function wl(r,e,t,n){return new L(y.negint,-1-Me(r,e+1,n),5)}var ua=BigInt(-1),xl=BigInt(1);function bl(r,e,t,n){let o=He(r,e+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new L(y.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${H} integers outside of the safe integer range are not supported`);return new L(y.negint,ua-BigInt(o),9)}function si(r,e){let t=e.value,n=typeof t=="bigint"?t*ua-xl:t*-1-1;xe(r,e.type.majorEncoded,n)}si.encodedSize=function(e){let t=e.value,n=typeof t=="bigint"?t*ua-xl:t*-1-1;return nt.value?-1:0};function yn(r,e,t,n){It(r,e,t+n);let o=_r(r,e+t,e+t+n);return new L(y.bytes,o,t+n)}function vl(r,e,t,n){return yn(r,e,1,t)}function El(r,e,t,n){return yn(r,e,2,Oe(r,e+1,n))}function Bl(r,e,t,n){return yn(r,e,3,De(r,e+1,n))}function Al(r,e,t,n){return yn(r,e,5,Me(r,e+1,n))}function Sl(r,e,t,n){let o=He(r,e+1,n);if(typeof o=="bigint")throw new Error(`${H} 64-bit integer bytes lengths not supported`);return yn(r,e,9,o)}function ai(r){return r.encodedBytes===void 0&&(r.encodedBytes=r.type===y.string?cl(r.value):r.value),r.encodedBytes}function Lr(r,e){let t=ai(e);xe(r,e.type.majorEncoded,t.length),r.push(t)}Lr.encodedSize=function(e){let t=ai(e);return xe.encodedSize(t.length)+t.length};Lr.compareTokens=function(e,t){return Bp(ai(e),ai(t))};function Bp(r,e){return r.lengthe.length?1:fl(r,e)}function wn(r,e,t,n,o){let i=t+n;It(r,e,i);let s=new L(y.string,al(r,e+t,e+i),i);return o.retainStringBytes===!0&&(s.byteValue=_r(r,e+t,e+i)),s}function Il(r,e,t,n){return wn(r,e,1,t,n)}function kl(r,e,t,n){return wn(r,e,2,Oe(r,e+1,n),n)}function Cl(r,e,t,n){return wn(r,e,3,De(r,e+1,n),n)}function Tl(r,e,t,n){return wn(r,e,5,Me(r,e+1,n),n)}function Nl(r,e,t,n){let o=He(r,e+1,n);if(typeof o=="bigint")throw new Error(`${H} 64-bit integer string lengths not supported`);return wn(r,e,9,o,n)}var Ul=Lr;function Vr(r,e,t,n){return new L(y.array,n,t)}function Rl(r,e,t,n){return Vr(r,e,1,t)}function _l(r,e,t,n){return Vr(r,e,2,Oe(r,e+1,n))}function Ll(r,e,t,n){return Vr(r,e,3,De(r,e+1,n))}function Vl(r,e,t,n){return Vr(r,e,5,Me(r,e+1,n))}function Pl(r,e,t,n){let o=He(r,e+1,n);if(typeof o=="bigint")throw new Error(`${H} 64-bit integer array lengths not supported`);return Vr(r,e,9,o)}function Fl(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${H} indefinite length items not allowed`);return Vr(r,e,1,1/0)}function ci(r,e){xe(r,y.array.majorEncoded,e.value)}ci.compareTokens=Ke.compareTokens;ci.encodedSize=function(e){return xe.encodedSize(e.value)};function Pr(r,e,t,n){return new L(y.map,n,t)}function Ol(r,e,t,n){return Pr(r,e,1,t)}function Dl(r,e,t,n){return Pr(r,e,2,Oe(r,e+1,n))}function Ml(r,e,t,n){return Pr(r,e,3,De(r,e+1,n))}function Hl(r,e,t,n){return Pr(r,e,5,Me(r,e+1,n))}function $l(r,e,t,n){let o=He(r,e+1,n);if(typeof o=="bigint")throw new Error(`${H} 64-bit integer map lengths not supported`);return Pr(r,e,9,o)}function Kl(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${H} indefinite length items not allowed`);return Pr(r,e,1,1/0)}function ui(r,e){xe(r,y.map.majorEncoded,e.value)}ui.compareTokens=Ke.compareTokens;ui.encodedSize=function(e){return xe.encodedSize(e.value)};function ql(r,e,t,n){return new L(y.tag,t,1)}function zl(r,e,t,n){return new L(y.tag,Oe(r,e+1,n),2)}function jl(r,e,t,n){return new L(y.tag,De(r,e+1,n),3)}function Gl(r,e,t,n){return new L(y.tag,Me(r,e+1,n),5)}function Zl(r,e,t,n){return new L(y.tag,He(r,e+1,n),9)}function li(r,e){xe(r,y.tag.majorEncoded,e.value)}li.compareTokens=Ke.compareTokens;li.encodedSize=function(e){return xe.encodedSize(e.value)};var Tp=20,Np=21,Up=22,Rp=23;function Wl(r,e,t,n){if(n.allowUndefined===!1)throw new Error(`${H} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new L(y.null,null,1):new L(y.undefined,void 0,1)}function Jl(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${H} indefinite length items not allowed`);return new L(y.break,void 0,1)}function la(r,e,t){if(t){if(t.allowNaN===!1&&Number.isNaN(r))throw new Error(`${H} NaN values are not supported`);if(t.allowInfinity===!1&&(r===1/0||r===-1/0))throw new Error(`${H} Infinity values are not supported`)}return new L(y.float,r,e)}function Yl(r,e,t,n){return la(fa(r,e+1),3,n)}function Xl(r,e,t,n){return la(ha(r,e+1),5,n)}function Ql(r,e,t,n){return la(nf(r,e+1),9,n)}function fi(r,e,t){let n=e.value;if(n===!1)r.push([y.float.majorEncoded|Tp]);else if(n===!0)r.push([y.float.majorEncoded|Np]);else if(n===null)r.push([y.float.majorEncoded|Up]);else if(n===void 0)r.push([y.float.majorEncoded|Rp]);else{let o,i=!1;(!t||t.float64!==!0)&&(tf(n),o=fa(tt,1),n===o||Number.isNaN(n)?(tt[0]=249,r.push(tt.slice(0,3)),i=!0):(rf(n),o=ha(tt,1),n===o&&(tt[0]=250,r.push(tt.slice(0,5)),i=!0))),i||(_p(n),o=nf(tt,1),tt[0]=251,r.push(tt.slice(0,9)))}}fi.encodedSize=function(e,t){let n=e.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!t||t.float64!==!0){tf(n);let o=fa(tt,1);if(n===o||Number.isNaN(n))return 3;if(rf(n),o=ha(tt,1),n===o)return 5}return 9};var ef=new ArrayBuffer(9),qe=new DataView(ef,1),tt=new Uint8Array(ef,0);function tf(r){if(r===1/0)qe.setUint16(0,31744,!1);else if(r===-1/0)qe.setUint16(0,64512,!1);else if(Number.isNaN(r))qe.setUint16(0,32256,!1);else{qe.setFloat32(0,r);let e=qe.getUint32(0),t=(e&2139095040)>>23,n=e&8388607;if(t===255)qe.setUint16(0,31744,!1);else if(t===0)qe.setUint16(0,(r&2147483648)>>16|n>>13,!1);else{let o=t-127;o<-24?qe.setUint16(0,0):o<-14?qe.setUint16(0,(e&2147483648)>>16|1<<24+o,!1):qe.setUint16(0,(e&2147483648)>>16|o+15<<10|n>>13,!1)}}}function fa(r,e){if(r.length-e<2)throw new Error(`${H} not enough data for float16`);let t=(r[e]<<8)+r[e+1];if(t===31744)return 1/0;if(t===64512)return-1/0;if(t===32256)return NaN;let n=t>>10&31,o=t&1023,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,t&32768?-i:i}function rf(r){qe.setFloat32(0,r,!1)}function ha(r,e){if(r.length-e<4)throw new Error(`${H} not enough data for float32`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,4).getFloat32(0,!1)}function _p(r){qe.setFloat64(0,r,!1)}function nf(r,e){if(r.length-e<8)throw new Error(`${H} not enough data for float64`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,8).getFloat64(0,!1)}fi.compareTokens=Ke.compareTokens;function W(r,e,t){throw new Error(`${H} encountered invalid minor (${t}) for major ${r[e]>>>5}`)}function hi(r){return()=>{throw new Error(`${H} ${r}`)}}var k=[];for(let r=0;r<=23;r++)k[r]=W;k[24]=hl;k[25]=dl;k[26]=pl;k[27]=ml;k[28]=W;k[29]=W;k[30]=W;k[31]=W;for(let r=32;r<=55;r++)k[r]=W;k[56]=gl;k[57]=yl;k[58]=wl;k[59]=bl;k[60]=W;k[61]=W;k[62]=W;k[63]=W;for(let r=64;r<=87;r++)k[r]=vl;k[88]=El;k[89]=Bl;k[90]=Al;k[91]=Sl;k[92]=W;k[93]=W;k[94]=W;k[95]=hi("indefinite length bytes/strings are not supported");for(let r=96;r<=119;r++)k[r]=Il;k[120]=kl;k[121]=Cl;k[122]=Tl;k[123]=Nl;k[124]=W;k[125]=W;k[126]=W;k[127]=hi("indefinite length bytes/strings are not supported");for(let r=128;r<=151;r++)k[r]=Rl;k[152]=_l;k[153]=Ll;k[154]=Vl;k[155]=Pl;k[156]=W;k[157]=W;k[158]=W;k[159]=Fl;for(let r=160;r<=183;r++)k[r]=Ol;k[184]=Dl;k[185]=Ml;k[186]=Hl;k[187]=$l;k[188]=W;k[189]=W;k[190]=W;k[191]=Kl;for(let r=192;r<=215;r++)k[r]=ql;k[216]=zl;k[217]=jl;k[218]=Gl;k[219]=Zl;k[220]=W;k[221]=W;k[222]=W;k[223]=W;for(let r=224;r<=243;r++)k[r]=hi("simple values are not supported");k[244]=W;k[245]=W;k[246]=W;k[247]=Wl;k[248]=hi("simple values are not supported");k[249]=Yl;k[250]=Xl;k[251]=Ql;k[252]=W;k[253]=W;k[254]=W;k[255]=Jl;var rt=[];for(let r=0;r<24;r++)rt[r]=new L(y.uint,r,1);for(let r=-1;r>=-24;r--)rt[31-r]=new L(y.negint,r,1);rt[64]=new L(y.bytes,new Uint8Array(0),1);rt[96]=new L(y.string,"",1);rt[128]=new L(y.array,0,1);rt[160]=new L(y.map,0,1);rt[244]=new L(y.false,!1,1);rt[245]=new L(y.true,!0,1);rt[246]=new L(y.null,null,1);function Vp(){let r=[];return r[y.uint.major]=Ke,r[y.negint.major]=si,r[y.bytes.major]=Lr,r[y.string.major]=Ul,r[y.array.major]=ci,r[y.map.major]=ui,r[y.tag.major]=li,r[y.float.major]=fi,r}var f2=Vp(),h2=new ii,di=class r{constructor(e,t){this.obj=e,this.parent=t}includes(e){let t=this;do if(t.obj===e)return!0;while(t=t.parent);return!1}static createCheck(e,t){if(e&&e.includes(t))throw new Error(`${ca} object contains circular references`);return new r(t,e)}},$t={null:new L(y.null,null),undefined:new L(y.undefined,void 0),true:new L(y.true,!0),false:new L(y.false,!1),emptyArray:new L(y.array,0),emptyMap:new L(y.map,0)},Kt={number(r,e,t,n){return!Number.isInteger(r)||!Number.isSafeInteger(r)?new L(y.float,r):r>=0?new L(y.uint,r):new L(y.negint,r)},bigint(r,e,t,n){return r>=BigInt(0)?new L(y.uint,r):new L(y.negint,r)},Uint8Array(r,e,t,n){return new L(y.bytes,r)},string(r,e,t,n){return new L(y.string,r)},boolean(r,e,t,n){return r?$t.true:$t.false},null(r,e,t,n){return $t.null},undefined(r,e,t,n){return $t.undefined},ArrayBuffer(r,e,t,n){return new L(y.bytes,new Uint8Array(r))},DataView(r,e,t,n){return new L(y.bytes,new Uint8Array(r.buffer,r.byteOffset,r.byteLength))},Array(r,e,t,n){if(!r.length)return t.addBreakTokens===!0?[$t.emptyArray,new L(y.break)]:$t.emptyArray;n=di.createCheck(n,r);let o=[],i=0;for(let s of r)o[i++]=da(s,t,n);return t.addBreakTokens?[new L(y.array,r.length),o,new L(y.break)]:[new L(y.array,r.length),o]},Object(r,e,t,n){let o=e!=="Object",i=o?r.keys():Object.keys(r),s=o?r.size:i.length;if(!s)return t.addBreakTokens===!0?[$t.emptyMap,new L(y.break)]:$t.emptyMap;n=di.createCheck(n,r);let a=[],c=0;for(let f of i)a[c++]=[da(f,t,n),da(o?r.get(f):r[f],t,n)];return Pp(a,t),t.addBreakTokens?[new L(y.map,s),a,new L(y.break)]:[new L(y.map,s),a]}};Kt.Map=Kt.Object;Kt.Buffer=Kt.Uint8Array;for(let r of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Kt[`${r}Array`]=Kt.DataView;function da(r,e={},t){let n=rl(r),o=e&&e.typeEncoders&&e.typeEncoders[n]||Kt[n];if(typeof o=="function"){let s=o(r,n,e,t);if(s!=null)return s}let i=Kt[n];if(!i)throw new Error(`${ca} unsupported type: ${n}`);return i(r,n,e,t)}function Pp(r,e){e.mapSorter&&r.sort(e.mapSorter)}var Fp={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},pi=class{constructor(e,t={}){this._pos=0,this.data=e,this.options=t}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let e=this.data[this._pos],t=rt[e];if(t===void 0){let n=k[e];if(!n)throw new Error(`${H} no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,"0")})`);let o=e&31;t=n(this.data,this._pos,o,this.options)}return this._pos+=t.encodedLength,t}},xn=Symbol.for("DONE"),mi=Symbol.for("BREAK");function Op(r,e,t){let n=[];for(let o=0;o0)throw new Error(`${H} too many terminals, data makes no sense`);return t}var $p=Ct("ipns:utils"),sf=Y("/ipns/");var Kp=0,qp=18;function af(r){let e;if(r.pubKey!=null)try{e=Ou(r.pubKey)}catch(t){throw $p.error(t),t}if(e!=null)return e}function cf(r){let e=Y("ipns-signature:");return Fe([e,r])}function bn(r){return"signatureV1"in r?et.encode({value:Y(r.value),signatureV1:r.signatureV1,validityType:r.validityType,validity:Y(r.validity),sequence:r.sequence,ttl:r.ttl,pubKey:r.pubKey,signatureV2:r.signatureV2,data:r.data}):et.encode({pubKey:r.pubKey,signatureV2:r.signatureV2,data:r.data})}function qt(r){let e=et.decode(r);if(e.sequence!=null&&(e.sequence=BigInt(e.sequence)),e.ttl!=null&&(e.ttl=BigInt(e.ttl)),e.signatureV2==null||e.data==null)throw new Qe("Missing data or signatureV2");let t=uf(e.data),n=zp(t.Value),o=Z(t.Validity);if(e.value!=null&&e.signatureV1!=null)return jp(e),{value:n,validityType:et.ValidityType.EOL,validity:o,sequence:t.Sequence,ttl:t.TTL,pubKey:e.pubKey,signatureV1:e.signatureV1,signatureV2:e.signatureV2,data:e.data};if(e.signatureV2!=null)return{value:n,validityType:et.ValidityType.EOL,validity:o,sequence:t.Sequence,ttl:t.TTL,pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data};throw new Error("invalid record: does not include signatureV1 or signatureV2")}function vn(r){return Fe([sf,r.bytes])}function Or(r){let e=ht(r.slice(sf.length));if(!gi(e,Kp)&&!gi(e,qp))throw new ir("Multihash in IPNS key was not identity or sha2-256");return e}function uf(r){let e=pa(r);if(e.ValidityType===0)e.ValidityType=et.ValidityType.EOL;else throw new Ur("The validity type is unsupported");return Number.isInteger(e.Sequence)&&(e.Sequence=BigInt(e.Sequence)),Number.isInteger(e.TTL)&&(e.TTL=BigInt(e.TTL)),e}function zp(r){let e=Z(r).trim();if(e.startsWith("/"))return e;try{return`/ipfs/${ie.decode(r).toV1().toString()}`}catch{}try{return`/ipfs/${ie.parse(e).toV1().toString()}`}catch{}throw new ri("Value must be a valid content path starting with /")}function jp(r){if(r.data==null)throw new ni("Record data is missing");let e=uf(r.data);if(!ue(e.Value,r.value??new Uint8Array(0)))throw new Qe('Field "value" did not match between protobuf and CBOR');if(!ue(e.Validity,r.validity??new Uint8Array(0)))throw new Qe('Field "validity" did not match between protobuf and CBOR');if(e.ValidityType!==r.validityType)throw new Qe('Field "validityType" did not match between protobuf and CBOR');if(e.Sequence!==r.sequence)throw new Qe('Field "sequence" did not match between protobuf and CBOR');if(e.TTL!==r.ttl)throw new Qe('Field "ttl" did not match between protobuf and CBOR')}function gi(r,e){return r.code===e}var P2=Ct("ipns"),F2=60*60*1e9,Zp="/ipns/",O2=Zp.length;var lf=Cn(aa(),1);var yi=Ct("ipns:validator"),Wp=1024*10,Jp=async(r,e)=>{let t=qt(e),n;try{let o=cf(t.data);n=await r.verify(o,t.signatureV2)}catch{n=!1}if(!n)throw yi.error("record signature verification failed"),new Qe("Record signature verification failed");if(t.validityType===et.ValidityType.EOL){if(lf.default.fromString(t.validity).toDate().getTime()Wp)throw new ti("The record is too large");let t=Or(r),n;gi(t,0)&&(n=qo(t));let o=qt(e),i=af(o)??n;if(i==null)throw new mn("Could not extract public key from IPNS record or routing key");let s=vn(i.toMultihash());if(!ue(r,s))throw new mn("Embedded public key did not match routing key");await Jp(i,e)}async function*En(r){let e=/\r?\n/,t=new TextDecoder("utf8"),n="";for await(let o of r){typeof o=="string"&&(o=new TextEncoder().encode(o)),n+=t.decode(o,{stream:!0});let i=n.split(e);n=i.pop()??"";for(let s=0;s{r.resolve=e,r.reject=t}),r}var ga=Cn(df(),1);var An=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},ya=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},pf=r=>globalThis.DOMException===void 0?new ya(r):new DOMException(r),mf=r=>{let e=r.reason===void 0?pf("This operation was aborted."):r.reason;return e instanceof Error?e:pf(e)};function wa(r,e){let{milliseconds:t,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout}}=e,s,c=new Promise((f,u)=>{if(typeof t!="number"||Math.sign(t)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${t}\``);if(e.signal){let{signal:h}=e;h.aborted&&u(mf(h)),h.addEventListener("abort",()=>{u(mf(h))})}if(t===Number.POSITIVE_INFINITY){r.then(f,u);return}let l=new An;s=i.setTimeout.call(void 0,()=>{if(n){try{f(n())}catch(h){u(h)}return}typeof r.cancel=="function"&&r.cancel(),o===!1?f():o instanceof Error?u(o):(l.message=o??`Promise timed out after ${t} milliseconds`,u(l))},t),(async()=>{try{f(await r)}catch(h){u(h)}})()}).finally(()=>{c.clear()});return c.clear=()=>{i.clearTimeout.call(void 0,s),s=void 0},c}function xa(r,e,t){let n=0,o=r.length;for(;o>0;){let i=Math.trunc(o/2),s=n+i;t(r[s],e)<=0?(n=++s,o-=i+1):o=i}return n}var Sn=class{#e=[];enqueue(e,t){t={priority:0,...t};let n={priority:t.priority,run:e};if(this.size&&this.#e[this.size-1].priority>=t.priority){this.#e.push(n);return}let o=xa(this.#e,n,(i,s)=>s.priority-i.priority);this.#e.splice(o,0,n)}dequeue(){return this.#e.shift()?.run}filter(e){return this.#e.filter(t=>t.priority===e.priority).map(t=>t.run)}get size(){return this.#e.length}};var In=class extends ga.default{#e;#r;#i=0;#a;#c;#p=0;#n;#u;#t;#m;#o=0;#l;#s;#g;timeout;constructor(e){if(super(),e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:Sn,...e},!(typeof e.intervalCap=="number"&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${e.intervalCap?.toString()??""}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${e.interval?.toString()??""}\` (${typeof e.interval})`);this.#e=e.carryoverConcurrencyCount,this.#r=e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,this.#a=e.intervalCap,this.#c=e.interval,this.#t=new e.queueClass,this.#m=e.queueClass,this.concurrency=e.concurrency,this.timeout=e.timeout,this.#g=e.throwOnTimeout===!0,this.#s=e.autoStart===!1}get#x(){return this.#r||this.#i{this.#E()},t)),!0}return!1}#f(){if(this.#t.size===0)return this.#n&&clearInterval(this.#n),this.#n=void 0,this.emit("empty"),this.#o===0&&this.emit("idle"),!1;if(!this.#s){let e=!this.#B;if(this.#x&&this.#b){let t=this.#t.dequeue();return t?(this.emit("active"),t(),e&&this.#y(),!0):!1}}return!1}#y(){this.#r||this.#n!==void 0||(this.#n=setInterval(()=>{this.#w()},this.#c),this.#p=Date.now()+this.#c)}#w(){this.#i===0&&this.#o===0&&this.#n&&(clearInterval(this.#n),this.#n=void 0),this.#i=this.#e?this.#o:0,this.#h()}#h(){for(;this.#f(););}get concurrency(){return this.#l}set concurrency(e){if(!(typeof e=="number"&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);this.#l=e,this.#h()}async#A(e){return new Promise((t,n)=>{e.addEventListener("abort",()=>{n(e.reason)},{once:!0})})}async add(e,t={}){return t={timeout:this.timeout,throwOnTimeout:this.#g,...t},new Promise((n,o)=>{this.#t.enqueue(async()=>{this.#o++,this.#i++;try{t.signal?.throwIfAborted();let i=e({signal:t.signal});t.timeout&&(i=wa(Promise.resolve(i),{milliseconds:t.timeout})),t.signal&&(i=Promise.race([i,this.#A(t.signal)]));let s=await i;n(s),this.emit("completed",s)}catch(i){if(i instanceof An&&!t.throwOnTimeout){n();return}o(i),this.emit("error",i)}finally{this.#v()}},t),this.emit("add"),this.#f()})}async addAll(e,t){return Promise.all(e.map(async n=>this.add(n,t)))}start(){return this.#s?(this.#s=!1,this.#h(),this):this}pause(){this.#s=!0}clear(){this.#t=new this.#m}async onEmpty(){this.#t.size!==0&&await this.#d("empty")}async onSizeLessThan(e){this.#t.sizethis.#t.size{let o=()=>{t&&!t()||(this.off(e,o),n())};this.on(e,o)})}get size(){return this.#t.size}sizeBy(e){return this.#t.filter(e).length}get pending(){return this.#o}get isPaused(){return this.#s}};var Dr=class extends Error{static name="InvalidRequestError";constructor(e="Invalid request"){super(e),this.name="InvalidRequestError"}},nr=class extends Error{static name="BadResponseError";constructor(e="Bad response"){super(e),this.name="BadResponseError"}};function Qp(r){return r[Symbol.asyncIterator]!=null}function em(r){if(Qp(r))return(async()=>{for await(let e of r)return e})();for(let e of r)return e}var gf=em;function tm(r){let[e,t]=r[Symbol.asyncIterator]!=null?[r[Symbol.asyncIterator](),Symbol.asyncIterator]:[r[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>e.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:e.next(),[t](){return this}}}var yf=tm;function rm(r){return r[Symbol.asyncIterator]!=null}function nm(r,e){let t=0;if(rm(r))return async function*(){for await(let c of r)yield e(c,t++)}();let n=yf(r),{value:o,done:i}=n.next();if(i===!0)return function*(){}();let s=e(o,t++);if(typeof s.then=="function")return async function*(){yield await s;for await(let c of n)yield e(c,t++)}();let a=e;return function*(){yield s;for(let c of n)yield a(c,t++)}()}var wf=nm;var xf=Y("/ipns/");function bf(r){return ue(r.subarray(0,xf.byteLength),xf)}var xi=class{client;constructor(e){this.client=e}async*findProviders(e,t={}){yield*wf(this.client.getProviders(e,t),n=>({id:n.ID,multiaddrs:n.Addrs??[]}))}async provide(){}async put(e,t,n){if(!bf(e))return;let o=Or(e),i=ie.createV1(114,o),s=qt(t);await this.client.putIPNS(i,s,n)}async get(e,t){if(!bf(e))throw new nt("Not found");let n=Or(e),o=ie.createV1(114,n);try{let i=await this.client.getIPNS(o,t);return bn(i)}catch(i){throw i.name==="BadResponseError"?new nt("Not found"):i}}},bi=class{client;constructor(e){this.client=e}async findPeer(e,t={}){let n=await gf(this.client.getPeers(e,t));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new nt("Not found")}async*getClosestPeers(e,t={}){}};var Te=Ct("delegated-routing-v1-http-api-client"),vf={concurrentRequests:4,timeout:3e4},vi=class{started;httpQueue;shutDownController;clientUrl;timeout;contentRouting;peerRouting;constructor(e,t={}){this.started=!1,this.shutDownController=new AbortController,ar(1/0,this.shutDownController.signal),this.httpQueue=new In({concurrency:t.concurrentRequests??vf.concurrentRequests}),this.clientUrl=e instanceof URL?e:new URL(e),this.timeout=t.timeout??vf.timeout,this.contentRouting=new xi(this),this.peerRouting=new bi(this)}get[Ca](){return this.contentRouting}get[Ta](){return this.peerRouting}isStarted(){return this.started}start(){this.started=!0}stop(){this.httpQueue.clear(),this.shutDownController.abort(),this.started=!1}async*getProviders(e,t={}){Te("getProviders starts: %c",e);let n=AbortSignal.timeout(this.timeout),o=pn([this.shutDownController.signal,n,t.signal]);ar(1/0,n,o);let i=ut(),s=ut();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let a=`${this.clientUrl}routing/v1/providers/${e.toString()}`,f=await fetch(a,{headers:{Accept:"application/x-ndjson"},signal:o});if(f.status===404)throw new nt("No matching records found");if(f.status===422)throw new Dr("Request does not conform to schema or semantic constraints");if(f.body==null)throw new nr("Routing response had no body");if(f.headers.get("Content-Type")==="application/json"){let l=await f.json();for(let h of l.Providers){let b=this.#e(h);b!=null&&(yield b)}}else for await(let l of En(Qo(f.body))){let h=this.#e(l);h!=null&&(yield h)}}catch(a){Te.error("getProviders errored:",a)}finally{o.clear(),s.resolve(),Te("getProviders finished: %c",e)}}async*getPeers(e,t={}){Te("getPeers starts: %c",e);let n=AbortSignal.timeout(this.timeout),o=pn([this.shutDownController.signal,n,t.signal]);ar(1/0,n,o);let i=ut(),s=ut();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let a=`${this.clientUrl}routing/v1/peers/${e.toCID().toString()}`,f=await fetch(a,{headers:{Accept:"application/x-ndjson"},signal:o});if(f.status===404)throw new nt("No matching records found");if(f.status===422)throw new Dr("Request does not conform to schema or semantic constraints");if(f.body==null)throw new nr("Routing response had no body");if(f.headers.get("Content-Type")==="application/json"){let l=await f.json();for(let h of l.Peers){let b=this.#e(h);b!=null&&(yield b)}}else for await(let l of En(Qo(f.body))){let h=this.#e(l);h!=null&&(yield h)}}catch(a){Te.error("getPeers errored:",a)}finally{o.clear(),s.resolve(),Te("getPeers finished: %c",e)}}async getIPNS(e,t={}){Te("getIPNS starts: %s",e);let n=AbortSignal.timeout(this.timeout),o=pn([this.shutDownController.signal,n,t.signal]);ar(1/0,n,o);let i=ut(),s=ut();this.httpQueue.add(async()=>(i.resolve(),s.promise));let a=`${this.clientUrl}routing/v1/ipns/${e}`;try{await i.promise;let f=await fetch(a,{headers:{Accept:"application/vnd.ipfs.ipns-record"},signal:o});if(Te("getIPNS GET %s %d",a,f.status),f.status===404)throw new nt("No matching records found");if(f.status===422)throw new Dr("Request does not conform to schema or semantic constraints");if(f.body==null)throw new nr("GET ipns response had no body");let u=await f.arrayBuffer(),l=new Uint8Array(u,0,u.byteLength);return t.validate!==!1&&await ff(vn(e.multihash),l),qt(l)}catch(c){throw Te.error("getIPNS GET %s error:",a,c),c}finally{o.clear(),s.resolve(),Te("getIPNS finished: %s",e)}}async putIPNS(e,t,n={}){Te("putIPNS starts: %c",e);let o=AbortSignal.timeout(this.timeout),i=pn([this.shutDownController.signal,o,n.signal]);ar(1/0,o,i);let s=ut(),a=ut();this.httpQueue.add(async()=>(s.resolve(),a.promise));let c=`${this.clientUrl}routing/v1/ipns/${e}`;try{await s.promise;let f=bn(t),l=await fetch(c,{method:"PUT",headers:{"Content-Type":"application/vnd.ipfs.ipns-record"},body:f,signal:i});if(Te("putIPNS PUT %s %d",c,l.status),l.status!==200)throw new nr("PUT ipns response had status other than 200")}catch(f){throw Te.error("putIPNS PUT %s error:",c,f.stack),f}finally{i.clear(),a.resolve(),Te("putIPNS finished: %c",e)}}#e(e){try{let t=[],n=e.Addrs?.map(dn)??[];return e.Protocols!=null&&t.push(...e.Protocols),e.Protocol!=null&&(t.push(e.Protocol),delete e.Protocol),{...e,Schema:"peer",ID:Mu(e.ID),Addrs:n,Protocols:t}}catch(t){Te.error("could not conform record to peer schema",t)}}};function om(r,e={}){return new vi(new URL(r),e)}return Vf(im);})(); + /*! Bundled license information: + + pvtsutils/build/index.js: +diff --git a/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/client.d.ts b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/client.d.ts +index f7699eb..6723325 100644 +--- a/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/client.d.ts ++++ b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/client.d.ts +@@ -23,7 +23,7 @@ export declare class DefaultDelegatedRoutingV1HttpApiClient implements Delegated + stop(): void; + getProviders(cid: CID, options?: AbortOptions): AsyncGenerator; + getPeers(peerId: PeerId, options?: AbortOptions | undefined): AsyncGenerator; +- getIPNS(peerId: PeerId, options?: GetIPNSOptions): Promise; +- putIPNS(peerId: PeerId, record: IPNSRecord, options?: AbortOptions): Promise; ++ getIPNS(libp2pKey: CID, options?: GetIPNSOptions): Promise; ++ putIPNS(libp2pKey: CID, record: IPNSRecord, options?: AbortOptions): Promise; + } + //# sourceMappingURL=client.d.ts.map +\ No newline at end of file +diff --git a/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/client.d.ts.map b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/client.d.ts.map +index b693f84..c070c1d 100644 +--- a/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/client.d.ts.map ++++ b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/client.d.ts.map +@@ -1 +1 @@ +-{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAA8B,MAAM,mBAAmB,CAAA;AAMvG,OAAO,EAAa,KAAK,UAAU,EAA+B,MAAM,MAAM,CAAA;AAM9E,OAAO,KAAK,EAAE,+BAA+B,EAAE,mCAAmC,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAClI,OAAO,KAAK,EAAE,cA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C,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,UAAU,CAAC;IA4D1G,OAAO,CAAE,SAAS,EAAE,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;CAkE7H"} +\ No newline at end of file +diff --git a/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/client.js b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/client.js +index 19ab17c..9f1152b 100644 +--- a/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/client.js ++++ b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/client.js +@@ -1,14 +1,15 @@ +-import { contentRoutingSymbol, peerRoutingSymbol, CodeError, setMaxListeners } from '@libp2p/interface'; ++import { NotFoundError, contentRoutingSymbol, peerRoutingSymbol, setMaxListeners } from '@libp2p/interface'; + import { logger } from '@libp2p/logger'; + import { peerIdFromString } from '@libp2p/peer-id'; + import { multiaddr } from '@multiformats/multiaddr'; + import { anySignal } from 'any-signal'; + import toIt from 'browser-readablestream-to-it'; +-import { unmarshal, marshal, peerIdToRoutingKey } from 'ipns'; ++import { unmarshalIPNSRecord, marshalIPNSRecord, multihashToIPNSRoutingKey } from 'ipns'; + import { ipnsValidator } from 'ipns/validator'; + import { parse as ndjson } from 'it-ndjson'; + import defer from 'p-defer'; + import PQueue from 'p-queue'; ++import { BadResponseError, InvalidRequestError } from './errors.js'; + import { DelegatedRoutingV1HttpApiClientContentRouting, DelegatedRoutingV1HttpApiClientPeerRouting } from './routings.js'; + const log = logger('delegated-routing-v1-http-api-client'); + const defaultValues = { +@@ -74,16 +75,16 @@ export class DefaultDelegatedRoutingV1HttpApiClient { + const res = await fetch(resource, getOptions); + if (res.status === 404) { + // https://specs.ipfs.tech/routing/http-routing-v1/#response-status-codes +- // 404 (Not Found): must be returned if no matching records are found. +- throw new CodeError('No matching records found.', 'ERR_NOT_FOUND'); ++ // 404 (Not Found): must be returned if no matching records are found ++ throw new NotFoundError('No matching records found'); + } + if (res.status === 422) { + // https://specs.ipfs.tech/routing/http-routing-v1/#response-status-codes +- // 422 (Unprocessable Entity): request does not conform to schema or semantic constraints. +- throw new CodeError('Request does not conform to schema or semantic constraints.', 'ERR_INVALID_REQUEST'); ++ // 422 (Unprocessable Entity): request does not conform to schema or semantic constraints ++ throw new InvalidRequestError('Request does not conform to schema or semantic constraints'); + } + if (res.body == null) { +- throw new CodeError('Routing response had no body', 'ERR_BAD_RESPONSE'); ++ throw new BadResponseError('Routing response had no body'); + } + const contentType = res.headers.get('Content-Type'); + if (contentType === 'application/json') { +@@ -133,15 +134,15 @@ export class DefaultDelegatedRoutingV1HttpApiClient { + if (res.status === 404) { + // https://specs.ipfs.tech/routing/http-routing-v1/#response-status-codes + // 404 (Not Found): must be returned if no matching records are found. +- throw new CodeError('No matching records found.', 'ERR_NOT_FOUND'); ++ throw new NotFoundError('No matching records found'); + } + if (res.status === 422) { + // https://specs.ipfs.tech/routing/http-routing-v1/#response-status-codes +- // 422 (Unprocessable Entity): request does not conform to schema or semantic constraints. +- throw new CodeError('Request does not conform to schema or semantic constraints.', 'ERR_INVALID_REQUEST'); ++ // 422 (Unprocessable Entity): request does not conform to schema or semantic constraints ++ throw new InvalidRequestError('Request does not conform to schema or semantic constraints'); + } + if (res.body == null) { +- throw new CodeError('Routing response had no body', 'ERR_BAD_RESPONSE'); ++ throw new BadResponseError('Routing response had no body'); + } + const contentType = res.headers.get('Content-Type'); + if (contentType === 'application/json') { +@@ -171,8 +172,8 @@ export class DefaultDelegatedRoutingV1HttpApiClient { + log('getPeers finished: %c', peerId); + } + } +- async getIPNS(peerId, options = {}) { +- log('getIPNS starts: %c', peerId); ++ async getIPNS(libp2pKey, options = {}) { ++ log('getIPNS starts: %s', libp2pKey); + const timeoutSignal = AbortSignal.timeout(this.timeout); + const signal = anySignal([this.shutDownController.signal, timeoutSignal, options.signal]); + setMaxListeners(Infinity, timeoutSignal, signal); +@@ -183,7 +184,7 @@ export class DefaultDelegatedRoutingV1HttpApiClient { + return onFinish.promise; + }); + // https://specs.ipfs.tech/routing/http-routing-v1/ +- const resource = `${this.clientUrl}routing/v1/ipns/${peerId.toCID().toString()}`; ++ const resource = `${this.clientUrl}routing/v1/ipns/${libp2pKey}`; + try { + await onStart.promise; + const getOptions = { headers: { Accept: 'application/vnd.ipfs.ipns-record' }, signal }; +@@ -191,23 +192,23 @@ export class DefaultDelegatedRoutingV1HttpApiClient { + log('getIPNS GET %s %d', resource, res.status); + if (res.status === 404) { + // https://specs.ipfs.tech/routing/http-routing-v1/#response-status-codes +- // 404 (Not Found): must be returned if no matching records are found. +- throw new CodeError('No matching records found.', 'ERR_NOT_FOUND'); ++ // 404 (Not Found): must be returned if no matching records are found ++ throw new NotFoundError('No matching records found'); + } + if (res.status === 422) { + // https://specs.ipfs.tech/routing/http-routing-v1/#response-status-codes +- // 422 (Unprocessable Entity): request does not conform to schema or semantic constraints. +- throw new CodeError('Request does not conform to schema or semantic constraints.', 'ERR_INVALID_REQUEST'); ++ // 422 (Unprocessable Entity): request does not conform to schema or semantic constraints ++ throw new InvalidRequestError('Request does not conform to schema or semantic constraints'); + } + if (res.body == null) { +- throw new CodeError('GET ipns response had no body', 'ERR_BAD_RESPONSE'); ++ throw new BadResponseError('GET ipns response had no body'); + } + const buf = await res.arrayBuffer(); + const body = new Uint8Array(buf, 0, buf.byteLength); + if (options.validate !== false) { +- await ipnsValidator(peerIdToRoutingKey(peerId), body); ++ await ipnsValidator(multihashToIPNSRoutingKey(libp2pKey.multihash), body); + } +- return unmarshal(body); ++ return unmarshalIPNSRecord(body); + } + catch (err) { + log.error('getIPNS GET %s error:', resource, err); +@@ -216,11 +217,11 @@ export class DefaultDelegatedRoutingV1HttpApiClient { + finally { + signal.clear(); + onFinish.resolve(); +- log('getIPNS finished: %c', peerId); ++ log('getIPNS finished: %s', libp2pKey); + } + } +- async putIPNS(peerId, record, options = {}) { +- log('putIPNS starts: %c', peerId); ++ async putIPNS(libp2pKey, record, options = {}) { ++ log('putIPNS starts: %c', libp2pKey); + const timeoutSignal = AbortSignal.timeout(this.timeout); + const signal = anySignal([this.shutDownController.signal, timeoutSignal, options.signal]); + setMaxListeners(Infinity, timeoutSignal, signal); +@@ -231,15 +232,15 @@ export class DefaultDelegatedRoutingV1HttpApiClient { + return onFinish.promise; + }); + // https://specs.ipfs.tech/routing/http-routing-v1/ +- const resource = `${this.clientUrl}routing/v1/ipns/${peerId.toCID().toString()}`; ++ const resource = `${this.clientUrl}routing/v1/ipns/${libp2pKey}`; + try { + await onStart.promise; +- const body = marshal(record); ++ const body = marshalIPNSRecord(record); + const getOptions = { method: 'PUT', headers: { 'Content-Type': 'application/vnd.ipfs.ipns-record' }, body, signal }; + const res = await fetch(resource, getOptions); + log('putIPNS PUT %s %d', resource, res.status); + if (res.status !== 200) { +- throw new CodeError('PUT ipns response had status other than 200', 'ERR_BAD_RESPONSE'); ++ throw new BadResponseError('PUT ipns response had status other than 200'); + } + } + catch (err) { +@@ -249,7 +250,7 @@ export class DefaultDelegatedRoutingV1HttpApiClient { + finally { + signal.clear(); + onFinish.resolve(); +- log('putIPNS finished: %c', peerId); ++ log('putIPNS finished: %c', libp2pKey); + } + } + #conformToPeerSchema(record) { +diff --git a/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/client.js.map b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/client.js.map +index 4c1a7f9..03c1c68 100644 +--- a/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/client.js.map ++++ b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/client.js.map +@@ -1 +1 @@ +-{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACvG,OAAO,EA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W;QAC/B,IAAI,CAAC;YACH,MAAM,SAAS,GAAa,EAAE,CAAA;YAC9B,MAAM,UAAU,GAAgB,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,CAAA;YAElE,IAAI,MAAM,CAAC,SAAS,IAAI,IAAI,EAAE,CAAC;gBAC7B,SAAS,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,SAAS,CAAC,CAAA;YACrC,CAAC;YAED,IAAI,MAAM,CAAC,QAAQ,IAAI,IAAI,EAAE,CAAC;gBAC5B,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;gBAC/B,OAAO,MAAM,CAAC,QAAQ,CAAA;YACxB,CAAC;YAED,OAAO;gBACL,GAAG,MAAM;gBACT,MAAM,EAAE,MAAM;gBACd,EAAE,EAAE,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC/B,KAAK,EAAE,UAAU;gBACjB,SAAS,EAAE,SAAS;aACrB,CAAA;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,GAAG,CAAC,KAAK,CAAC,yCAAyC,EAAE,GAAG,CAAC,CAAA;QAC3D,CAAC;IACH,CAAC;CACF"} +\ No newline at end of file +diff --git a/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/errors.d.ts b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/errors.d.ts +new file mode 100644 +index 0000000..bd8734c +--- /dev/null ++++ b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/errors.d.ts +@@ -0,0 +1,9 @@ ++export declare class InvalidRequestError extends Error { ++ static name: string; ++ constructor(message?: string); ++} ++export declare class BadResponseError extends Error { ++ static name: string; ++ constructor(message?: string); ++} ++//# sourceMappingURL=errors.d.ts.map +\ No newline at end of file +diff --git a/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/errors.d.ts.map b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/errors.d.ts.map +new file mode 100644 +index 0000000..7de287c +--- /dev/null ++++ b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/errors.d.ts.map +@@ -0,0 +1 @@ ++{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,MAAM,CAAC,IAAI,SAAwB;gBAEtB,OAAO,SAAoB;CAIzC;AAED,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,MAAM,CAAC,IAAI,SAAqB;gBAEnB,OAAO,SAAiB;CAItC"} +\ No newline at end of file +diff --git a/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/errors.js b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/errors.js +new file mode 100644 +index 0000000..5e7cae6 +--- /dev/null ++++ b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/errors.js +@@ -0,0 +1,15 @@ ++export class InvalidRequestError extends Error { ++ static name = 'InvalidRequestError'; ++ constructor(message = 'Invalid request') { ++ super(message); ++ this.name = 'InvalidRequestError'; ++ } ++} ++export class BadResponseError extends Error { ++ static name = 'BadResponseError'; ++ constructor(message = 'Bad response') { ++ super(message); ++ this.name = 'BadResponseError'; ++ } ++} ++//# sourceMappingURL=errors.js.map +\ No newline at end of file +diff --git a/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/errors.js.map b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/errors.js.map +new file mode 100644 +index 0000000..3612512 +--- /dev/null ++++ b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/errors.js.map +@@ -0,0 +1 @@ ++{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAC5C,MAAM,CAAC,IAAI,GAAG,qBAAqB,CAAA;IAEnC,YAAa,OAAO,GAAG,iBAAiB;QACtC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAA;IACnC,CAAC;;AAGH,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IACzC,MAAM,CAAC,IAAI,GAAG,kBAAkB,CAAA;IAEhC,YAAa,OAAO,GAAG,cAAc;QACnC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAA;IAChC,CAAC"} +\ No newline at end of file +diff --git a/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/index.d.ts b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/index.d.ts +index 8678174..95b83e2 100644 +--- a/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/index.d.ts ++++ b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/index.d.ts +@@ -93,13 +93,13 @@ export interface DelegatedRoutingV1HttpApiClient { + */ + getPeers(peerId: PeerId, options?: AbortOptions): AsyncGenerator; + /** +- * Returns a promise of a {@link IPNSRecord} for the given {@link PeerId} ++ * Returns a promise of a {@link IPNSRecord} for the given {@link MultihashDigest} + */ +- getIPNS(peerId: PeerId, options?: GetIPNSOptions): Promise; ++ getIPNS(libp2pKey: CID, options?: GetIPNSOptions): Promise; + /** +- * Publishes the given {@link IPNSRecord} for the provided {@link PeerId} ++ * Publishes the given {@link IPNSRecord} for the provided {@link MultihashDigest} + */ +- putIPNS(peerId: PeerId, record: IPNSRecord, options?: AbortOptions): Promise; ++ putIPNS(libp2pKey: CID, record: IPNSRecord, options?: AbortOptions): Promise; + /** + * Shut down any currently running HTTP requests and clear up any resources + * that are in use +diff --git a/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/index.d.ts.map b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/index.d.ts.map +index f1dd1a2..8590842 100644 +--- a/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/index.d.ts.map ++++ b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/index.d.ts.map +@@ -1 +1 @@ +-{"version":3,"file":"index.d.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AU,CAAC,CAAA;IAE5E;;OAEG;IACH,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;IAErG;;OAEG;IACH,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAEjH;;;OAGG;IACH,IAAI,IAAI,IAAI,CAAA;CACb;AAED;;GAEG;AACH,wBAAgB,qCAAqC,CAAE,GAAG,EAAE,GAAG,GAAG,MAAM,EAAE,IAAI,GAAE,mCAAwC,GAAG,+BAA+B,CAEzJ"} +\ No newline at end of file +diff --git a/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/routings.d.ts b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/routings.d.ts +index e74efdc..cb4d597 100644 +--- a/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/routings.d.ts ++++ b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/routings.d.ts +@@ -1,6 +1,6 @@ + import { type ContentRouting, type PeerRouting, type AbortOptions, type PeerId, type PeerInfo } from '@libp2p/interface'; ++import { CID } from 'multiformats/cid'; + import type { DelegatedRoutingV1HttpApiClient } from './index.js'; +-import type { CID } from 'multiformats/cid'; + /** + * Wrapper class to convert [http-routing-v1 content events](https://specs.ipfs.tech/routing/http-routing-v1/#response-body) into returned values + */ +diff --git a/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/routings.d.ts.map b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/routings.d.ts.map +index f252d18..339187b 100644 +--- a/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/routings.d.ts.map ++++ b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/routings.d.ts.map +@@ -1 +1 @@ +-{"version":3,"file":"routings.d.ts","sourceRoot":"","sources":["../../src/routings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,KAAK,MAAM,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAQxH,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,YAAY,CAAA;AACjE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAY3C;;GAEG;AACH,qBAAa,6CAA8C,YAAW,cAAc;IAClF,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiC;gBAE3C,MAAM,EAAE,+BAA+B;IAI5C,aAAa,CAAE,GAAG,EAAE,GAAG,EAAE,OAAO,GAAE,YAAiB,GAAG,aAAa,CAAC,QAAQ,CAAC;IAS/E,OAAO,IAAK,OAAO,CAAC,IAAI,CAAC;IAIzB,GAAG,CAAE,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAW/E,GAAG,CAAE,GAAG,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC;CAqBzE;AAED;;GAEG;AACH,qBAAa,0CAA2C,YAAW,WAAW;IAC5E,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiC;gBAE3C,MAAM,EAAE,+BAA+B;IAI9C,QAAQ,CAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAatE,eAAe,CAAE,GAAG,EAAE,UAAU,EAAE,OAAO,GAAE,YAAiB,GAAG,aAAa,CAAC,QAAQ,CAAC;CAG/F"} +\ No newline at end of file ++{"version":3,"file":"routings.d.ts","sourceRoot":"","sources":["../../src/routings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,KAAK,MAAM,EAAE,KAAK,QAAQ,EAAiB,MAAM,mBAAmB,CAAA;AAIvI,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAGtC,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,YAAY,CAAA;AAQjE;;GAEG;AACH,qBAAa,6CAA8C,YAAW,cAAc;IAClF,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiC;gBAE3C,MAAM,EAAE,+BAA+B;IAI5C,aAAa,CAAE,GAAG,EAAE,GAAG,EAAE,OAAO,GAAE,YAAiB,GAAG,aAAa,CAAC,QAAQ,CAAC;IAS/E,OAAO,IAAK,OAAO,CAAC,IAAI,CAAC;IAIzB,GAAG,CAAE,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAY/E,GAAG,CAAE,GAAG,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC;CAsBzE;AAED;;GAEG;AACH,qBAAa,0CAA2C,YAAW,WAAW;IAC5E,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiC;gBAE3C,MAAM,EAAE,+BAA+B;IAI9C,QAAQ,CAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAatE,eAAe,CAAE,GAAG,EAAE,UAAU,EAAE,OAAO,GAAE,YAAiB,GAAG,aAAa,CAAC,QAAQ,CAAC;CAG/F"} +\ No newline at end of file +diff --git a/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/routings.js b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/routings.js +index 0f026c2..8171e81 100644 +--- a/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/routings.js ++++ b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/routings.js +@@ -1,18 +1,14 @@ +-import {} from '@libp2p/interface'; +-import { CodeError } from '@libp2p/interface'; +-import { peerIdFromBytes } from '@libp2p/peer-id'; +-import { marshal, unmarshal } from 'ipns'; ++import { NotFoundError } from '@libp2p/interface'; ++import { marshalIPNSRecord, multihashFromIPNSRoutingKey, unmarshalIPNSRecord } from 'ipns'; + import first from 'it-first'; + import map from 'it-map'; ++import { CID } from 'multiformats/cid'; + import { equals as uint8ArrayEquals } from 'uint8arrays/equals'; + import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'; + const IPNS_PREFIX = uint8ArrayFromString('/ipns/'); + function isIPNSKey(key) { + return uint8ArrayEquals(key.subarray(0, IPNS_PREFIX.byteLength), IPNS_PREFIX); + } +-const peerIdFromRoutingKey = (key) => { +- return peerIdFromBytes(key.slice(IPNS_PREFIX.length)); +-}; + /** + * Wrapper class to convert [http-routing-v1 content events](https://specs.ipfs.tech/routing/http-routing-v1/#response-body) into returned values + */ +@@ -36,24 +32,26 @@ export class DelegatedRoutingV1HttpApiClientContentRouting { + if (!isIPNSKey(key)) { + return; + } +- const peerId = peerIdFromRoutingKey(key); +- const record = unmarshal(value); +- await this.client.putIPNS(peerId, record, options); ++ const digest = multihashFromIPNSRoutingKey(key); ++ const cid = CID.createV1(0x72, digest); ++ const record = unmarshalIPNSRecord(value); ++ await this.client.putIPNS(cid, record, options); + } + async get(key, options) { + if (!isIPNSKey(key)) { +- throw new CodeError('Not found', 'ERR_NOT_FOUND'); ++ throw new NotFoundError('Not found'); + } +- const peerId = peerIdFromRoutingKey(key); ++ const digest = multihashFromIPNSRoutingKey(key); ++ const cid = CID.createV1(0x72, digest); + try { +- const record = await this.client.getIPNS(peerId, options); +- return marshal(record); ++ const record = await this.client.getIPNS(cid, options); ++ return marshalIPNSRecord(record); + } + catch (err) { +- // ERR_BAD_RESPONSE is thrown when the response had no body, which means ++ // BadResponseError is thrown when the response had no body, which means + // the record couldn't be found +- if (err.code === 'ERR_BAD_RESPONSE') { +- throw new CodeError('Not found', 'ERR_NOT_FOUND'); ++ if (err.name === 'BadResponseError') { ++ throw new NotFoundError('Not found'); + } + throw err; + } +@@ -75,7 +73,7 @@ export class DelegatedRoutingV1HttpApiClientPeerRouting { + multiaddrs: peer.Addrs ?? [] + }; + } +- throw new CodeError('Not found', 'ERR_NOT_FOUND'); ++ throw new NotFoundError('Not found'); + } + async *getClosestPeers(key, options = {}) { + // noop +diff --git a/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/routings.js.map b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/routings.js.map +index 6f06e4e..0066d3f 100644 +--- a/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/routings.js.map ++++ b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/src/routings.js.map +@@ -1 +1 @@ +-{"version":3,"file":"routings.js","sourceRoot":"","sources":["../../src/routings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwF,MAAM,mBAAmB,CAAA;AACxH,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAA;AACzC,OAAO,KAAK,MAAM,UAAU,CAAA;AAC5B,OAAO,GAAG,MAAM,QAAQ,CAAA;AACxB,OAAO,EAAE,MAAM,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAC/D,OAAO,EAAE,UAAU,IAAI,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAI5E,MAAM,WAAW,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAA;AAElD,SAAS,SAAS,CAAE,GAAe;IACjC,OAAO,gBAAgB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,WAAW,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC,CAAA;AAC/E,CAAC;AAED,M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A;QAExC,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;YAEzD,OAAO,OAAO,CAAC,MAAM,CAAC,CAAA;QACxB,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,wEAAwE;YACxE,+BAA+B;YAC/B,IAAI,GAAG,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;gBACpC,MAAM,IAAI,SAAS,CAAC,WAAW,EAAE,eAAe,CAAC,CAAA;YACnD,CAAC;YAED,MAAM,GAAG,CAAA;QACX,CAAC;IACH,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,0CAA0C;IACpC,MAAM,CAAiC;IAExD,YAAa,MAAuC;QAClD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IAED,KAAK,CAAC,QAAQ,CAAE,MAAc,EAAE,UAAwB,EAAE;QACxD,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;QAE/D,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;YACjB,OAAO;gBACL,EAAE,EAAE,IAAI,CAAC,EAAE;gBACX,UAAU,EAAE,IAAI,CAAC,KAAK,IAAI,EAAE;aAC7B,CAAA;QACH,CAAC;QAED,MAAM,IAAI,SAAS,CAAC,WAAW,EAAE,eAAe,CAAC,CAAA;IACnD,CAAC;IAED,KAAK,CAAC,CAAE,eAAe,CAAE,GAAe,EAAE,UAAwB,EAAE;QAClE,OAAO;IACT,CAAC;CACF"} +\ No newline at end of file ++{"version":3,"file":"routings.js","sourceRoot":"","sources":["../../src/routings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwF,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACvI,OAAO,EAAE,iBAAiB,EAAE,2BAA2B,EAAE,mBAAmB,EAAE,MAAM,MA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C;YACjB,OAAO;gBACL,EAAE,EAAE,IAAI,CAAC,EAAE;gBACX,UAAU,EAAE,IAAI,CAAC,KAAK,IAAI,EAAE;aAC7B,CAAA;QACH,CAAC;QAED,MAAM,IAAI,aAAa,CAAC,WAAW,CAAC,CAAA;IACtC,CAAC;IAED,KAAK,CAAC,CAAE,eAAe,CAAE,GAAe,EAAE,UAAwB,EAAE;QAClE,OAAO;IACT,CAAC;CACF"} +\ No newline at end of file +diff --git a/node_modules/@helia/delegated-routing-v1-http-api-client/dist/test/index.spec.d.ts b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/test/index.spec.d.ts +new file mode 100644 +index 0000000..b37c2d2 +--- /dev/null ++++ b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/test/index.spec.d.ts +@@ -0,0 +1,2 @@ ++export {}; ++//# sourceMappingURL=index.spec.d.ts.map +\ No newline at end of file +diff --git a/node_modules/@helia/delegated-routing-v1-http-api-client/dist/test/index.spec.d.ts.map b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/test/index.spec.d.ts.map +new file mode 100644 +index 0000000..5c89780 +--- /dev/null ++++ b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/test/index.spec.d.ts.map +@@ -0,0 +1 @@ ++{"version":3,"file":"index.spec.d.ts","sourceRoot":"","sources":["../../test/index.spec.ts"],"names":[],"mappings":""} +\ No newline at end of file +diff --git a/node_modules/@helia/delegated-routing-v1-http-api-client/dist/test/index.spec.js b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/test/index.spec.js +new file mode 100644 +index 0000000..ee19225 +--- /dev/null ++++ b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/test/index.spec.js +@@ -0,0 +1,215 @@ ++/* eslint-env mocha */ ++import { generateKeyPair } from '@libp2p/crypto/keys'; ++import { peerIdFromPrivateKey, peerIdFromString } from '@libp2p/peer-id'; ++import { multiaddr } from '@multiformats/multiaddr'; ++import { expect } from 'aegir/chai'; ++import { createIPNSRecord, marshalIPNSRecord } from 'ipns'; ++import all from 'it-all'; ++import { CID } from 'multiformats/cid'; ++import { createDelegatedRoutingV1HttpApiClient } from '../src/index.js'; ++if (process.env.ECHO_SERVER == null) { ++ throw new Error('Echo server not configured correctly'); ++} ++const serverUrl = process.env.ECHO_SERVER; ++describe('delegated-routing-v1-http-api-client', () => { ++ let client; ++ beforeEach(() => { ++ client = createDelegatedRoutingV1HttpApiClient(new URL(serverUrl)); ++ }); ++ afterEach(async () => { ++ if (client != null) { ++ client.stop(); ++ } ++ }); ++ it('should find providers', async () => { ++ const providers = [{ ++ Protocol: 'transport-bitswap', ++ Schema: 'bitswap', ++ Metadata: 'gBI=', ++ ID: (await generateKeyPair('Ed25519')).publicKey.toString(), ++ Addrs: ['/ip4/41.41.41.41/tcp/1234'] ++ }, { ++ Protocol: 'transport-bitswap', ++ Schema: 'peer', ++ Metadata: 'gBI=', ++ ID: (await generateKeyPair('Ed25519')).publicKey.toString(), ++ Addrs: ['/ip4/42.42.42.42/tcp/1234'] ++ }, { ++ ID: (await generateKeyPair('Ed25519')).publicKey.toString(), ++ Addrs: ['/ip4/43.43.43.43/tcp/1234'] ++ }]; ++ const cid = CID.parse('QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn'); ++ // load providers for the router to fetch ++ await fetch(`${process.env.ECHO_SERVER}/add-providers/${cid.toString()}`, { ++ method: 'POST', ++ body: providers.map(prov => JSON.stringify(prov)).join('\n') ++ }); ++ const provs = await all(client.getProviders(cid)); ++ expect(provs.map(prov => ({ ++ id: prov.ID.toString(), ++ addrs: prov.Addrs?.map(ma => ma.toString()) ++ }))).to.deep.equal(providers.map(prov => ({ ++ id: prov.ID, ++ addrs: prov.Addrs ++ }))); ++ }); ++ it('should handle non-json input', async () => { ++ const cid = CID.parse('QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn'); ++ // load providers for the router to fetch ++ await fetch(`${process.env.ECHO_SERVER}/add-providers/${cid.toString()}`, { ++ method: 'POST', ++ body: 'not json' ++ }); ++ const provs = await all(client.getProviders(cid)); ++ expect(provs).to.be.empty(); ++ }); ++ it('should handle bad input providers', async () => { ++ const providers = [{ ++ Metadata: 'gBI=', ++ Provider: { ++ Bad: 'field' ++ } ++ }, { ++ Metadata: 'gBI=', ++ ContextID: '', ++ Another: { ++ Bad: 'field' ++ } ++ }]; ++ const cid = CID.parse('QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn'); ++ // load providers for the router to fetch ++ await fetch(`${process.env.ECHO_SERVER}/add-providers/${cid.toString()}`, { ++ method: 'POST', ++ body: providers.map(prov => JSON.stringify(prov)).join('\n') ++ }); ++ const provs = await all(client.getProviders(cid)); ++ expect(provs).to.be.empty(); ++ }); ++ it('should handle empty input', async () => { ++ const cid = CID.parse('QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn'); ++ const provs = await all(client.getProviders(cid)); ++ expect(provs).to.be.empty(); ++ }); ++ it('should conform records to peer schema', async () => { ++ const privateKey = await generateKeyPair('Ed25519'); ++ const records = [{ ++ Protocol: 'transport-bitswap', ++ Schema: 'bitswap', ++ Metadata: 'gBI=', ++ ID: privateKey.publicKey.toString(), ++ Addrs: ['/ip4/41.41.41.41/tcp/1234'] ++ }, { ++ Protocol: 'transport-saddle', ++ Schema: 'horse-ride', ++ Metadata: 'gBI=', ++ ID: privateKey.publicKey.toString(), ++ Addrs: ['/ip4/41.41.41.41/tcp/1234'] ++ }, { ++ Protocols: ['transport-bitswap'], ++ Schema: 'peer', ++ Metadata: 'gBI=', ++ ID: privateKey.publicKey.toString(), ++ Addrs: ['/ip4/42.42.42.42/tcp/1234'] ++ }, { ++ Protocol: 'transport-bitswap', ++ Schema: 'peer', ++ Metadata: 'gBI=', ++ ID: (await generateKeyPair('Ed25519')).publicKey.toString(), ++ Addrs: ['/ip4/42.42.42.42/tcp/1234'] ++ }, { ++ Schema: 'peer', ++ ID: (await generateKeyPair('Ed25519')).publicKey.toString() ++ }]; ++ const peers = [{ ++ Protocols: ['transport-bitswap'], ++ Schema: 'peer', ++ Metadata: 'gBI=', ++ ID: peerIdFromString(records[0].ID), ++ Addrs: [multiaddr('/ip4/41.41.41.41/tcp/1234')] ++ }, { ++ Protocols: ['transport-saddle'], ++ Schema: 'peer', ++ Metadata: 'gBI=', ++ ID: peerIdFromString(records[1].ID), ++ Addrs: [multiaddr('/ip4/41.41.41.41/tcp/1234')] ++ }, { ++ Protocols: ['transport-bitswap'], ++ Schema: 'peer', ++ Metadata: 'gBI=', ++ ID: peerIdFromString(records[2].ID), ++ Addrs: [multiaddr('/ip4/42.42.42.42/tcp/1234')] ++ }, { ++ Protocols: ['transport-bitswap'], ++ Schema: 'peer', ++ Metadata: 'gBI=', ++ ID: peerIdFromString(records[3].ID), ++ Addrs: [multiaddr('/ip4/42.42.42.42/tcp/1234')] ++ }, { ++ Protocols: [], ++ Schema: 'peer', ++ ID: peerIdFromString(records[4].ID), ++ Addrs: [] ++ }]; ++ // load peer for the router to fetch ++ await fetch(`${process.env.ECHO_SERVER}/add-peers/${privateKey.publicKey.toCID()}`, { ++ method: 'POST', ++ body: records.map(prov => JSON.stringify(prov)).join('\n') ++ }); ++ const peerRecords = await all(client.getPeers(peerIdFromPrivateKey(privateKey))); ++ expect(peerRecords.map(peerRecord => ({ ++ ...peerRecord, ++ ID: peerRecord.ID.toString(), ++ Addrs: peerRecord.Addrs?.map(ma => ma.toString()) ?? [] ++ }))).to.deep.equal(peers.map(peerRecord => ({ ++ ...peerRecord, ++ ID: peerRecord.ID.toString(), ++ Addrs: peerRecord.Addrs?.map(ma => ma.toString()) ++ }))); ++ }); ++ it('should get ipns record', async () => { ++ const cid = CID.parse('QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn'); ++ const privateKey = await generateKeyPair('Ed25519'); ++ const record = await createIPNSRecord(privateKey, cid, 0, 1000); ++ // load record for the router to fetch ++ await fetch(`${process.env.ECHO_SERVER}/add-ipns/${privateKey.publicKey.toCID()}`, { ++ method: 'POST', ++ headers: { ++ 'Content-Type': 'application/vnd.ipfs.ipns-record' ++ }, ++ body: marshalIPNSRecord(record) ++ }); ++ const ipnsRecord = await client.getIPNS(privateKey.publicKey.toCID()); ++ expect(marshalIPNSRecord(ipnsRecord)).to.equalBytes(marshalIPNSRecord(record)); ++ }); ++ it('get ipns record fails with bad record', async () => { ++ const cid = CID.parse('QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn'); ++ const privateKey = await generateKeyPair('Ed25519'); ++ const otherPrivateKey = await generateKeyPair('Ed25519'); ++ const record = await createIPNSRecord(otherPrivateKey, cid, 0, 1000); ++ // load record for the router to fetch ++ await fetch(`${process.env.ECHO_SERVER}/add-ipns/${privateKey.publicKey.toCID()}`, { ++ method: 'POST', ++ headers: { ++ 'Content-Type': 'application/vnd.ipfs.ipns-record' ++ }, ++ body: marshalIPNSRecord(record) ++ }); ++ await expect(client.getIPNS(privateKey.publicKey.toCID())).to.be.rejected(); ++ }); ++ it('should put ipns', async () => { ++ const cid = CID.parse('QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn'); ++ const privateKey = await generateKeyPair('Ed25519'); ++ const record = await createIPNSRecord(privateKey, cid, 0, 1000); ++ await client.putIPNS(privateKey.publicKey.toCID(), record); ++ // load record that our client just PUT to remote server ++ const res = await fetch(`${process.env.ECHO_SERVER}/get-ipns/${privateKey.publicKey.toCID()}`, { ++ method: 'GET', ++ headers: { ++ Accept: 'application/vnd.ipfs.ipns-record' ++ } ++ }); ++ const receivedRecord = new Uint8Array(await res.arrayBuffer()); ++ expect(marshalIPNSRecord(record)).to.equalBytes(receivedRecord); ++ }); ++}); ++//# sourceMappingURL=index.spec.js.map +\ No newline at end of file +diff --git a/node_modules/@helia/delegated-routing-v1-http-api-client/dist/test/index.spec.js.map b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/test/index.spec.js.map +new file mode 100644 +index 0000000..748332f +--- /dev/null ++++ b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/test/index.spec.js.map +@@ -0,0 +1 @@ ++{"version":3,"file":"index.spec.js","sourceRoot":"","sources":["../../test/index.spec.ts"],"names":[],"mappings":"AAAA,sBAAsB;AAEtB,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACnC,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAA;AAC1D,OAAO,GAAG,MAAM,QAAQ,CAAA;AACxB,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AACtC,OAAO,EAAE,qCAAqC,EAAwC,MAAM,iBAAiB,CAAA;AAE7G,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,IAAI,EAAE,CAAC;IACpC,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAA;AACzD,CAAC;AAED,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,CAAA;AAEzC,QAAQ,CAAC,sCAAsC,EAAE,GAAG,EAAE;IACpD,IAAI,MAAuC,CAAA;IAE3C,UAAU,CAAC,GAAG,EAAE;QACd,MAAM,GAAG,qCAAqC,CAAC,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC,CAAA;IACpE,CAAC,CAAC,CAAA;IAEF,SAAS,CAAC,KAAK,IAAI,EAAE;QACnB,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;YACnB,MAAM,CAAC,IAAI,EAAE,CAAA;QACf,CAAC;IACH,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,uBAAuB,EAAE,KAAK,IAAI,EAAE;QACrC,MAAM,SAAS,GAAG,CAAC;gBACjB,QAAQ,EAAE,mBAAmB;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AM,cAAc,GAAG,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,WAAW,EAAE,CAAC,CAAA;QAC9D,MAAM,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,cAAc,CAAC,CAAA;IACjE,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"} +\ No newline at end of file +diff --git a/node_modules/@helia/delegated-routing-v1-http-api-client/dist/test/routings.spec.d.ts b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/test/routings.spec.d.ts +new file mode 100644 +index 0000000..5c070a7 +--- /dev/null ++++ b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/test/routings.spec.d.ts +@@ -0,0 +1,2 @@ ++export {}; ++//# sourceMappingURL=routings.spec.d.ts.map +\ No newline at end of file +diff --git a/node_modules/@helia/delegated-routing-v1-http-api-client/dist/test/routings.spec.d.ts.map b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/test/routings.spec.d.ts.map +new file mode 100644 +index 0000000..9ccc0ec +--- /dev/null ++++ b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/test/routings.spec.d.ts.map +@@ -0,0 +1 @@ ++{"version":3,"file":"routings.spec.d.ts","sourceRoot":"","sources":["../../test/routings.spec.ts"],"names":[],"mappings":""} +\ No newline at end of file +diff --git a/node_modules/@helia/delegated-routing-v1-http-api-client/dist/test/routings.spec.js b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/test/routings.spec.js +new file mode 100644 +index 0000000..88eed91 +--- /dev/null ++++ b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/test/routings.spec.js +@@ -0,0 +1,214 @@ ++/* eslint-disable max-nested-callbacks */ ++/* eslint-env mocha */ ++import { generateKeyPair } from '@libp2p/crypto/keys'; ++import { contentRoutingSymbol, peerRoutingSymbol } from '@libp2p/interface'; ++import { peerIdFromPrivateKey } from '@libp2p/peer-id'; ++import { expect } from 'aegir/chai'; ++import { createIPNSRecord, marshalIPNSRecord, multihashToIPNSRoutingKey } from 'ipns'; ++import all from 'it-all'; ++import { CID } from 'multiformats/cid'; ++import { concat as uint8ArrayConcat } from 'uint8arrays/concat'; ++import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'; ++import { createDelegatedRoutingV1HttpApiClient } from '../src/index.js'; ++const serverUrl = process.env.ECHO_SERVER; ++if (serverUrl == null) { ++ throw new Error('Echo server not configured correctly'); ++} ++describe('libp2p content-routing', () => { ++ let client; ++ beforeEach(() => { ++ client = createDelegatedRoutingV1HttpApiClient(new URL(serverUrl)); ++ }); ++ afterEach(async () => { ++ if (client != null) { ++ client.stop(); ++ } ++ const res = await fetch(`${process.env.ECHO_SERVER}/reset-call-count`); ++ await res.text(); ++ }); ++ it('should provide a content routing implementation', () => { ++ const routing = getContentRouting(client); ++ expect(routing).to.be.ok(); ++ }); ++ it('should find providers', async () => { ++ const routing = getContentRouting(client); ++ if (routing == null) { ++ throw new Error('ContentRouting not found'); ++ } ++ const providers = [{ ++ Protocol: 'transport-bitswap', ++ Schema: 'bitswap', ++ Metadata: 'gBI=', ++ ID: (await generateKeyPair('Ed25519')).publicKey.toString(), ++ Addrs: ['/ip4/41.41.41.41/tcp/1234'] ++ }, { ++ Protocol: 'transport-bitswap', ++ Schema: 'peer', ++ Metadata: 'gBI=', ++ ID: (await generateKeyPair('Ed25519')).publicKey.toString(), ++ Addrs: ['/ip4/42.42.42.42/tcp/1234'] ++ }, { ++ ID: (await generateKeyPair('Ed25519')).publicKey.toString(), ++ Addrs: ['/ip4/43.43.43.43/tcp/1234'] ++ }]; ++ const cid = CID.parse('QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn'); ++ // load providers for the router to fetch ++ await fetch(`${process.env.ECHO_SERVER}/add-providers/${cid.toString()}`, { ++ method: 'POST', ++ body: providers.map(prov => JSON.stringify(prov)).join('\n') ++ }); ++ const provs = await all(routing.findProviders(cid)); ++ expect(provs.map(prov => ({ ++ id: prov.id.toString(), ++ multiaddrs: prov.multiaddrs.map(ma => ma.toString()) ++ }))).to.deep.equal(providers.map(prov => ({ ++ id: prov.ID, ++ multiaddrs: prov.Addrs ++ }))); ++ }); ++ it('should provide without error', async () => { ++ const routing = getContentRouting(client); ++ if (routing == null) { ++ throw new Error('ContentRouting not found'); ++ } ++ const cid = CID.parse('QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn'); ++ await expect(routing.provide(cid)).to.eventually.be.undefined(); ++ }); ++ it('should put ipns records', async () => { ++ const routing = getContentRouting(client); ++ if (routing == null) { ++ throw new Error('ContentRouting not found'); ++ } ++ const cid = CID.parse('QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn'); ++ const privateKey = await generateKeyPair('Ed25519'); ++ const record = await createIPNSRecord(privateKey, cid, 0, 1000); ++ const key = multihashToIPNSRoutingKey(privateKey.publicKey.toMultihash()); ++ await routing.put(key, marshalIPNSRecord(record)); ++ // load record that our client just PUT to remote server ++ const res = await fetch(`${process.env.ECHO_SERVER}/get-ipns/${privateKey.publicKey.toCID()}`, { ++ method: 'GET', ++ headers: { ++ Accept: 'application/vnd.ipfs.ipns-record' ++ } ++ }); ++ const receivedRecord = new Uint8Array(await res.arrayBuffer()); ++ expect(marshalIPNSRecord(record)).to.equalBytes(receivedRecord); ++ }); ++ it('should not put other records', async () => { ++ const routing = getContentRouting(client); ++ if (routing == null) { ++ throw new Error('ContentRouting not found'); ++ } ++ const privateKey = await generateKeyPair('Ed25519'); ++ const key = uint8ArrayConcat([ ++ uint8ArrayFromString('/an-unknown-key/'), ++ privateKey.publicKey.toMultihash().bytes ++ ]); ++ await routing.put(key, Uint8Array.from([0, 1, 2, 3, 4])); ++ await expect(getServerCallCount()).to.eventually.equal(0); ++ }); ++ it('should get ipns records', async () => { ++ const routing = getContentRouting(client); ++ if (routing == null) { ++ throw new Error('ContentRouting not found'); ++ } ++ const cid = CID.parse('QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn'); ++ const privateKey = await generateKeyPair('Ed25519'); ++ const record = await createIPNSRecord(privateKey, cid, 0, 1000); ++ // load record for the router to fetch ++ await fetch(`${process.env.ECHO_SERVER}/add-ipns/${privateKey.publicKey.toCID()}`, { ++ method: 'POST', ++ headers: { ++ 'Content-Type': 'application/vnd.ipfs.ipns-record' ++ }, ++ body: marshalIPNSRecord(record) ++ }); ++ const key = uint8ArrayConcat([ ++ uint8ArrayFromString('/ipns/'), ++ privateKey.publicKey.toMultihash().bytes ++ ]); ++ const value = await routing.get(key); ++ expect(value).to.equalBytes(marshalIPNSRecord(record)); ++ }); ++ it('should not get unknown records', async () => { ++ const routing = getContentRouting(client); ++ if (routing == null) { ++ throw new Error('ContentRouting not found'); ++ } ++ const privateKey = await generateKeyPair('Ed25519'); ++ const key = uint8ArrayConcat([ ++ uint8ArrayFromString('/am-unknown-key/'), ++ privateKey.publicKey.toMultihash().bytes ++ ]); ++ await expect(routing.get(key)).to.eventually.be.rejected ++ .with.property('name', 'NotFoundError'); ++ await expect(getServerCallCount()).to.eventually.equal(0); ++ }); ++}); ++describe('libp2p peer-routing', () => { ++ let client; ++ beforeEach(() => { ++ client = createDelegatedRoutingV1HttpApiClient(new URL(serverUrl)); ++ }); ++ afterEach(async () => { ++ if (client != null) { ++ client.stop(); ++ } ++ }); ++ describe('peer routing', () => { ++ it('should provide a peer routing implementation', () => { ++ const routing = getPeerRouting(client); ++ expect(routing).to.be.ok(); ++ }); ++ it('should find peer info', async () => { ++ const routing = getPeerRouting(client); ++ if (routing == null) { ++ throw new Error('PeerRouting not found'); ++ } ++ const privateKey = await generateKeyPair('Ed25519'); ++ const peerId = peerIdFromPrivateKey(privateKey); ++ const records = [{ ++ Protocol: 'transport-bitswap', ++ Schema: 'peer', ++ Metadata: 'gBI=', ++ ID: peerId.toString(), ++ Addrs: ['/ip4/41.41.41.41/tcp/1234'] ++ }]; ++ // load peer for the router to fetch ++ await fetch(`${process.env.ECHO_SERVER}/add-peers/${peerId.toCID().toString()}`, { ++ method: 'POST', ++ body: records.map(prov => JSON.stringify(prov)).join('\n') ++ }); ++ const peerInfo = await routing.findPeer(peerId); ++ expect(peerInfo.id.toString()).to.equal(records[0].ID); ++ expect(peerInfo.multiaddrs.map(ma => ma.toString())).to.deep.equal(records[0].Addrs); ++ }); ++ it('should not get closest peers', async () => { ++ const routing = getPeerRouting(client); ++ if (routing == null) { ++ throw new Error('PeerRouting not found'); ++ } ++ await expect(all(routing.getClosestPeers(Uint8Array.from([0, 1, 2, 3, 4])))).to.eventually.be.empty(); ++ }); ++ }); ++}); ++function getContentRouting(obj) { ++ const routing = obj?.[contentRoutingSymbol]; ++ if (routing == null) { ++ throw new Error('ContentRouting not found'); ++ } ++ return routing; ++} ++function getPeerRouting(obj) { ++ const routing = obj?.[peerRoutingSymbol]; ++ if (routing == null) { ++ throw new Error('PeerRouting not found'); ++ } ++ return routing; ++} ++async function getServerCallCount() { ++ const res = await fetch(`${process.env.ECHO_SERVER}/get-call-count`); ++ const body = await res.text(); ++ return Number(body); ++} ++//# sourceMappingURL=routings.spec.js.map +\ No newline at end of file +diff --git a/node_modules/@helia/delegated-routing-v1-http-api-client/dist/test/routings.spec.js.map b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/test/routings.spec.js.map +new file mode 100644 +index 0000000..328e281 +--- /dev/null ++++ b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/test/routings.spec.js.map +@@ -0,0 +1 @@ ++{"version":3,"file":"routings.spec.js","sourceRoot":"","sources":["../../test/routings.spec.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,sBAAsB;AAEtB,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAC3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACnC,OAAO,E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AC;IAED,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,KAAK,UAAU,kBAAkB;IAC/B,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,iBAAiB,CAAC,CAAA;IACpE,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAA;IAE7B,OAAO,MAAM,CAAC,IAAI,CAAC,CAAA;AACrB,CAAC"} +\ No newline at end of file +diff --git a/node_modules/@helia/delegated-routing-v1-http-api-client/dist/tsconfig.tsbuildinfo b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/tsconfig.tsbuildinfo +new file mode 100644 +index 0000000..108d20e +--- /dev/null ++++ b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/tsconfig.tsbuildinfo +@@ -0,0 +1 @@ ++{"program":{"fileNames":["../../../node_modules/typescript/lib/lib.es5.d.ts","../../../node_modules/typescript/lib/lib.es2015.d.ts","../../../node_modules/typescript/lib/lib.es2016.d.ts","../../../node_modules/typescript/lib/lib.es2017.d.ts","../../../node_modules/typescript/lib/lib.es2018.d.ts","../../../node_modules/typescript/lib/lib.es2019.d.ts","../../../node_modules/typescript/lib/lib.es2020.d.ts","../../../node_modules/typescript/lib/lib.es2021.d.ts","../../../node_modules/typescript/lib/lib.es2022.d.ts","../../../node_modules/typescript/lib/lib.es2023.d.ts","../../../node_modules/typescript/lib/lib.dom.d.ts","../../../node_modules/typescript/lib/lib.dom.iterable.d.ts","../../../node_modules/typescript/lib/lib.webworker.d.ts","../../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../node_modules/typescript/lib/lib.es2016.intl.d.ts","../../../node_modules/typescript/lib/lib.es2017.date.d.ts","../../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../node_modules/typescript/lib/lib.es2019.intl.d.ts","../../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../node_modules/typescript/lib/lib.es2020.date.d.ts","../../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../node_modules/typescript/lib/lib.es2020.number.d.ts","../../../node_modules/typescript/lib/lib.es2021.promise.d.ts","../../../node_modules/typescript/lib/lib.es2021.string.d.ts","../../../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../../node_modules/typescript/lib/lib.es2021.intl.d.ts","../../../node_modules/typescript/lib/lib.es2022.array.d.ts","../../../node_modules/typescript/lib/lib.es2022.error.d.ts","../../../node_modules/typescript/lib/lib.es2022.intl.d.ts","../../../node_modules/typescript/lib/lib.es2022.object.d.ts","../../../node_modules/typescript/lib/lib.es2022.sharedmemory.d.ts","../../../node_modules/typescript/lib/lib.es2022.string.d.ts","../../../node_modules/typescript/lib/lib.es2022.regexp.d.ts","../../../node_modules/typescript/lib/lib.es2023.array.d.ts","../../../node_modules/typescript/lib/lib.es2023.collection.d.ts","../../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../../node_modules/typescript/lib/lib.decorators.d.ts","../../../node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../../node_modules/multiformats/dist/src/bases/interface.d.ts","../../../node_modules/multiformats/dist/src/block/interface.d.ts","../../../node_modules/multiformats/dist/src/hashes/interface.d.ts","../../../node_modules/multiformats/dist/src/link/interface.d.ts","../../../node_modules/multiformats/dist/src/cid.d.ts","../../../node_modules/uint8arraylist/dist/src/index.d.ts","../../../node_modules/@libp2p/interface/dist/src/keys/index.d.ts","../../../node_modules/@libp2p/interface/dist/src/peer-id/index.d.ts","../../../node_modules/@multiformats/multiaddr/dist/src/protocols-table.d.ts","../../../node_modules/@multiformats/dns/dist/src/resolvers/dns-over-https.d.ts","../../../node_modules/@multiformats/dns/dist/src/resolvers/dns-json-over-https.d.ts","../../../node_modules/@multiformats/dns/dist/src/resolvers/index.d.ts","../../../node_modules/progress-events/dist/src/index.d.ts","../../../node_modules/@multiformats/dns/dist/src/index.d.ts","../../../node_modules/@multiformats/multiaddr/dist/src/resolvers/dnsaddr.d.ts","../../../node_modules/@multiformats/multiaddr/dist/src/resolvers/index.d.ts","../../../node_modules/@multiformats/multiaddr/dist/src/filter/multiaddr-filter.d.ts","../../../node_modules/@multiformats/multiaddr/dist/src/index.d.ts","../../../node_modules/it-stream-types/dist/src/index.d.ts","../../../node_modules/@libp2p/interface/dist/src/connection/index.d.ts","../../../node_modules/@libp2p/interface/dist/src/peer-info/index.d.ts","../../../node_modules/@libp2p/interface/dist/src/content-routing/index.d.ts","../../../node_modules/@libp2p/interface/dist/src/event-target.d.ts","../../../node_modules/@libp2p/interface/dist/src/metrics/index.d.ts","../../../node_modules/@libp2p/interface/dist/src/peer-routing/index.d.ts","../../../node_modules/@libp2p/interface/dist/src/peer-store/index.d.ts","../../../node_modules/@libp2p/interface/dist/src/startable.d.ts","../../../node_modules/@libp2p/interface/dist/src/stream-handler/index.d.ts","../../../node_modules/@libp2p/interface/dist/src/topology/index.d.ts","../../../node_modules/@libp2p/interface/dist/src/stream-muxer/index.d.ts","../../../node_modules/@libp2p/interface/dist/src/transport/index.d.ts","../../../node_modules/@libp2p/interface/dist/src/connection-encrypter/index.d.ts","../../../node_modules/@libp2p/interface/dist/src/connection-gater/index.d.ts","../../../node_modules/@libp2p/interface/dist/src/peer-discovery/index.d.ts","../../../node_modules/@libp2p/interface/dist/src/peer-store/tags.d.ts","../../../node_modules/it-pushable/dist/src/index.d.ts","../../../node_modules/@libp2p/interface/dist/src/pubsub/index.d.ts","../../../node_modules/@libp2p/interface/dist/src/record/index.d.ts","../../../node_modules/@libp2p/interface/dist/src/errors.d.ts","../../../node_modules/@types/node/assert.d.ts","../../../node_modules/@types/node/assert/strict.d.ts","../../../node_modules/buffer/index.d.ts","../../../node_modules/undici-types/header.d.ts","../../../node_modules/undici-types/readable.d.ts","../../../node_modules/undici-types/file.d.ts","../../../node_modules/undici-types/fetch.d.ts","../../../node_modules/undici-types/formdata.d.ts","../../../node_modules/undici-types/connector.d.ts","../../../node_modules/undici-types/client.d.ts","../../../node_modules/undici-types/errors.d.ts","../../../node_modules/undici-types/dispatcher.d.ts","../../../node_modules/undici-types/global-dispatcher.d.ts","../../../node_modules/undici-types/global-origin.d.ts","../../../node_modules/undici-types/pool-stats.d.ts","../../../node_modules/undici-types/pool.d.ts","../../../node_modules/undici-types/handlers.d.ts","../../../node_modules/undici-types/balanced-pool.d.ts","../../../node_modules/undici-types/agent.d.ts","../../../node_modules/undici-types/mock-interceptor.d.ts","../../../node_modules/undici-types/mock-agent.d.ts","../../../node_modules/undici-types/mock-client.d.ts","../../../node_modules/undici-types/mock-pool.d.ts","../../../node_modules/undici-types/mock-errors.d.ts","../../../node_modules/undici-types/proxy-agent.d.ts","../../../node_modules/undici-types/env-http-proxy-agent.d.ts","../../../node_modules/undici-types/retry-handler.d.ts","../../../node_modules/undici-types/retry-agent.d.ts","../../../node_modules/undici-types/api.d.ts","../../../node_modules/undici-types/interceptors.d.ts","../../../node_modules/undici-types/util.d.ts","../../../node_modules/undici-types/cookies.d.ts","../../../node_modules/undici-types/patch.d.ts","../../../node_modules/undici-types/websocket.d.ts","../../../node_modules/undici-types/eventsource.d.ts","../../../node_modules/undici-types/filereader.d.ts","../../../node_modules/undici-types/diagnostics-channel.d.ts","../../../node_modules/undici-types/content-type.d.ts","../../../node_modules/undici-types/cache.d.ts","../../../node_modules/undici-types/index.d.ts","../../../node_modules/@types/node/globals.d.ts","../../../node_modules/@types/node/async_hooks.d.ts","../../../node_modules/@types/node/buffer.d.ts","../../../node_modules/@types/node/child_process.d.ts","../../../node_modules/@types/node/cluster.d.ts","../../../node_modules/@types/node/console.d.ts","../../../node_modules/@types/node/constants.d.ts","../../../node_modules/@types/node/crypto.d.ts","../../../node_modules/@types/node/dgram.d.ts","../../../node_modules/@types/node/diagnostics_channel.d.ts","../../../node_modules/@types/node/dns.d.ts","../../../node_modules/@types/node/dns/promises.d.ts","../../../node_modules/@types/node/domain.d.ts","../../../node_modules/@types/node/dom-events.d.ts","../../../node_modules/@types/node/events.d.ts","../../../node_modules/@types/node/fs.d.ts","../../../node_modules/@types/node/fs/promises.d.ts","../../../node_modules/@types/node/http.d.ts","../../../node_modules/@types/node/http2.d.ts","../../../node_modules/@types/node/https.d.ts","../../../node_modules/@types/node/inspector.d.ts","../../../node_modules/@types/node/module.d.ts","../../../node_modules/@types/node/net.d.ts","../../../node_modules/@types/node/os.d.ts","../../../node_modules/@types/node/path.d.ts","../../../node_modules/@types/node/perf_hooks.d.ts","../../../node_modules/querystring/decode.d.ts","../../../node_modules/querystring/encode.d.ts","../../../node_modules/querystring/index.d.ts","../../../node_modules/@types/node/process.d.ts","../../../node_modules/@types/node/punycode.d.ts","../../../node_modules/@types/node/querystring.d.ts","../../../node_modules/@types/node/readline.d.ts","../../../node_modules/@types/node/readline/promises.d.ts","../../../node_modules/@types/node/repl.d.ts","../../../node_modules/@types/node/sea.d.ts","../../../node_modules/@types/node/stream.d.ts","../../../node_modules/@types/node/stream/promises.d.ts","../../../node_modules/@types/node/stream/consumers.d.ts","../../../node_modules/@types/node/stream/web.d.ts","../../../node_modules/@types/node/string_decoder.d.ts","../../../node_modules/@types/node/test.d.ts","../../../node_modules/@types/node/timers.d.ts","../../../node_modules/@types/node/timers/promises.d.ts","../../../node_modules/@types/node/tls.d.ts","../../../node_modules/@types/node/trace_events.d.ts","../../../node_modules/@types/node/tty.d.ts","../../../node_modules/@types/node/url.d.ts","../../../node_modules/@types/node/util.d.ts","../../../node_modules/@types/node/v8.d.ts","../../../node_modules/@types/node/vm.d.ts","../../../node_modules/@types/node/wasi.d.ts","../../../node_modules/@types/node/worker_threads.d.ts","../../../node_modules/@types/node/zlib.d.ts","../../../node_modules/@types/node/globals.global.d.ts","../../../node_modules/@types/node/index.d.ts","../../../node_modules/@libp2p/interface/dist/src/events.d.ts","../../../node_modules/@libp2p/interface/dist/src/index.d.ts","../../../node_modules/@libp2p/logger/dist/src/index.d.ts","../../../node_modules/@libp2p/peer-id/dist/src/index.d.ts","../../../node_modules/any-signal/dist/src/index.d.ts","../../../node_modules/browser-readablestream-to-it/dist/src/index.d.ts","../../../node_modules/multiformats/dist/src/codecs/interface.d.ts","../../../node_modules/multiformats/dist/src/codecs/json.d.ts","../../../node_modules/multiformats/dist/src/codecs/raw.d.ts","../../../node_modules/multiformats/dist/src/bytes.d.ts","../../../node_modules/multiformats/dist/src/hashes/digest.d.ts","../../../node_modules/multiformats/dist/src/hashes/hasher.d.ts","../../../node_modules/multiformats/dist/src/varint.d.ts","../../../node_modules/multiformats/dist/src/interface.d.ts","../../../node_modules/multiformats/dist/src/index.d.ts","../../../node_modules/multiformats/dist/src/bases/base.d.ts","../../../node_modules/multiformats/dist/src/basics.d.ts","../../../node_modules/uint8arrays/dist/src/util/bases.d.ts","../../../node_modules/uint8arrays/dist/src/to-string.d.ts","../../../node_modules/interface-datastore/dist/src/key.d.ts","../../../node_modules/protons-runtime/dist/src/codec.d.ts","../../../node_modules/protons-runtime/dist/src/decode.d.ts","../../../node_modules/protons-runtime/dist/src/encode.d.ts","../../../node_modules/protons-runtime/dist/src/codecs/enum.d.ts","../../../node_modules/protons-runtime/dist/src/codecs/message.d.ts","../../../node_modules/protons-runtime/dist/src/utils/reader.d.ts","../../../node_modules/protons-runtime/dist/src/utils/writer.d.ts","../../../node_modules/protons-runtime/dist/src/index.d.ts","../../../node_modules/ipns/dist/src/pb/ipns.d.ts","../../../node_modules/ipns/dist/src/utils.d.ts","../../../node_modules/ipns/dist/src/index.d.ts","../../../node_modules/ipns/dist/src/validator.d.ts","../../../node_modules/it-ndjson/dist/src/parse.d.ts","../../../node_modules/it-ndjson/dist/src/stringify.d.ts","../../../node_modules/it-ndjson/dist/src/index.d.ts","../../../node_modules/p-defer/index.d.ts","../../../node_modules/eventemitter3/index.d.ts","../../../node_modules/p-queue/dist/queue.d.ts","../../../node_modules/p-queue/dist/options.d.ts","../../../node_modules/p-queue/dist/priority-queue.d.ts","../../../node_modules/p-queue/dist/index.d.ts","../src/errors.ts","../../../node_modules/it-first/dist/src/index.d.ts","../../../node_modules/it-map/dist/src/index.d.ts","../../../node_modules/uint8arrays/dist/src/equals.d.ts","../../../node_modules/uint8arrays/dist/src/from-string.d.ts","../src/index.ts","../src/routings.ts","../src/client.ts","../../../node_modules/@libp2p/crypto/dist/src/keys/interface.d.ts","../../../node_modules/@libp2p/crypto/dist/src/keys/ecdh/index.d.ts","../../../node_modules/@libp2p/crypto/dist/src/keys/key-stretcher.d.ts","../../../node_modules/@libp2p/crypto/dist/src/keys/index.d.ts","../../../node_modules/@types/chai/index.d.ts","../../../node_modules/@types/chai-as-promised/index.d.ts","../../../node_modules/chai-parentheses/index.d.ts","../../../node_modules/@types/chai-subset/index.d.ts","../../../node_modules/chai-bites/index.d.ts","../../../node_modules/@types/chai-string/index.d.ts","../../../node_modules/aegir/dist/utils/chai.d.ts","../../../node_modules/it-all/dist/src/index.d.ts","../test/index.spec.ts","../../../node_modules/uint8arrays/dist/src/concat.d.ts","../test/routings.spec.ts","../../../node_modules/keyv/src/index.d.ts","../../../node_modules/@types/http-cache-semantics/index.d.ts","../../../node_modules/@types/responselike/index.d.ts","../../../node_modules/@types/cacheable-request/index.d.ts","../../../node_modules/@types/ms/index.d.ts","../../../node_modules/@types/debug/index.d.ts","../../../node_modules/@types/dns-packet/index.d.ts","../../../node_modules/@types/istanbul-lib-coverage/index.d.ts","../../../node_modules/@types/istanbul-lib-report/index.d.ts","../../../node_modules/@types/istanbul-reports/index.d.ts","../../../node_modules/@types/json-schema/index.d.ts","../../../node_modules/@types/json5/index.d.ts","../../../node_modules/@types/keyv/index.d.ts","../../../node_modules/@types/unist/index.d.ts","../../../node_modules/@types/mdast/index.d.ts","../../../node_modules/@types/minimatch/index.d.ts","../../../node_modules/@types/minimist/index.d.ts","../../../node_modules/@types/mocha/index.d.ts","../../../node_modules/@types/multicast-dns/index.d.ts","../../../node_modules/@types/murmurhash3js-revisited/index.d.ts","../../../node_modules/@types/node-forge/index.d.ts","../../../node_modules/@types/normalize-package-data/index.d.ts","../../../node_modules/@types/parse-json/index.d.ts","../../../node_modules/@types/retry/index.d.ts","../../../node_modules/@types/semver/classes/semver.d.ts","../../../node_modules/@types/semver/functions/parse.d.ts","../../../node_modules/@types/semver/functions/valid.d.ts","../../../node_modules/@types/semver/functions/clean.d.ts","../../../node_modules/@types/semver/functions/inc.d.ts","../../../node_modules/@types/semver/functions/diff.d.ts","../../../node_modules/@types/semver/functions/major.d.ts","../../../node_modules/@types/semver/functions/minor.d.ts","../../../node_modules/@types/semver/functions/patch.d.ts","../../../node_modules/@types/semver/functions/prerelease.d.ts","../../../node_modules/@types/semver/functions/compare.d.ts","../../../node_modules/@types/semver/functions/rcompare.d.ts","../../../node_modules/@types/semver/functions/compare-loose.d.ts","../../../node_modules/@types/semver/functions/compare-build.d.ts","../../../node_modules/@types/semver/functions/sort.d.ts","../../../node_modules/@types/semver/functions/rsort.d.ts","../../../node_modules/@types/semver/functions/gt.d.ts","../../../node_modules/@types/semver/functions/lt.d.ts","../../../node_modules/@types/semver/functions/eq.d.ts","../../../node_modules/@types/semver/functions/neq.d.ts","../../../node_modules/@types/semver/functions/gte.d.ts","../../../node_modules/@types/semver/functions/lte.d.ts","../../../node_modules/@types/semver/functions/cmp.d.ts","../../../node_modules/@types/semver/functions/coerce.d.ts","../../../node_modules/@types/semver/classes/comparator.d.ts","../../../node_modules/@types/semver/classes/range.d.ts","../../../node_modules/@types/semver/functions/satisfies.d.ts","../../../node_modules/@types/semver/ranges/max-satisfying.d.ts","../../../node_modules/@types/semver/ranges/min-satisfying.d.ts","../../../node_modules/@types/semver/ranges/to-comparators.d.ts","../../../node_modules/@types/semver/ranges/min-version.d.ts","../../../node_modules/@types/semver/ranges/valid.d.ts","../../../node_modules/@types/semver/ranges/outside.d.ts","../../../node_modules/@types/semver/ranges/gtr.d.ts","../../../node_modules/@types/semver/ranges/ltr.d.ts","../../../node_modules/@types/semver/ranges/intersects.d.ts","../../../node_modules/@types/semver/ranges/simplify.d.ts","../../../node_modules/@types/semver/ranges/subset.d.ts","../../../node_modules/@types/semver/internals/identifiers.d.ts","../../../node_modules/@types/semver/index.d.ts","../../../node_modules/@types/sinonjs__fake-timers/index.d.ts","../../../node_modules/@types/sinon/index.d.ts","../../../node_modules/@types/stack-utils/index.d.ts","../../../node_modules/@types/strip-bom/index.d.ts","../../../node_modules/@types/strip-json-comments/index.d.ts","../../../node_modules/@types/ws/index.d.ts","../../../node_modules/@types/yargs-parser/index.d.ts","../../../node_modules/@types/yargs/index.d.ts","../../../node_modules/@types/yauzl/index.d.ts"],"fileInfos":[{"version":"824cb491a40f7e8fdeb56f1df5edf91b23f3e3ee6b4cde84d4a99be32338faee","affectsGlobalScope":true},"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","3facaf05f0c5fc569c5649dd359892c98a85557e3e0c847964caeb67076f4d75","9a68c0c07ae2fa71b44384a839b7b8d81662a236d4b9ac30916718f7510b1b2d","5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","feecb1be483ed332fad555aff858affd90a48ab19ba7272ee084704eb7167569","5514e54f17d6d74ecefedc73c504eadffdeda79c7ea205cf9febead32d45c4bc","1c0cdb8dc619bc549c3e5020643e7cf7ae7940058e8c7e5aefa5871b6d86f44b",{"version":"87d693a4920d794a73384b3c779cadcb8548ac6945aa7a925832fe2418c9527a","affectsGlobalScope":true},{"version":"76f838d5d49b65de83bc345c04aa54c62a3cfdb72a477dc0c0fce89a30596c30","affectsGlobalScope":true},{"version":"db88e2781075c7bca86634724f38a132de718ddf3a470a3a2cdb182f4364af9e","affectsGlobalScope":true},{"version":"138fb588d26538783b78d1e3b2c2cc12d55840b97bf5e08bca7f7a174fbe2f17","affectsGlobalScope":true},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true},{"version":"4443e68b35f3332f753eacc66a04ac1d2053b8b035a0e0ac1d455392b5e243b3","affectsGlobalScope":true},{"version":"bc47685641087c015972a3f072480889f0d6c65515f12bd85222f49a98952ed7","affectsGlobalScope":true},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true},{"version":"93495ff27b8746f55d19fcbcdbaccc99fd95f19d057aed1bd2c0cafe1335fbf0","affectsGlobalScope":true},{"version":"6fc23bb8c3965964be8c597310a2878b53a0306edb71d4b5a4dfe760186bcc01","affectsGlobalScope":true},{"version":"ea011c76963fb15ef1cdd7ce6a6808b46322c527de2077b6cfdf23ae6f5f9ec7","affectsGlobalScope":true},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true},{"version":"bb42a7797d996412ecdc5b2787720de477103a0b2e53058569069a0e2bae6c7e","affectsGlobalScope":true},{"version":"4738f2420687fd85629c9efb470793bb753709c2379e5f85bc1815d875ceadcd","affectsGlobalScope":true},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true},{"version":"9fc46429fbe091ac5ad2608c657201eb68b6f1b8341bd6d670047d32ed0a88fa","affectsGlobalScope":true},{"version":"61c37c1de663cf4171e1192466e52c7a382afa58da01b1dc75058f032ddf0839","affectsGlobalScope":true},{"version":"b541a838a13f9234aba650a825393ffc2292dc0fc87681a5d81ef0c96d281e7a","affectsGlobalScope":true},{"version":"b20fe0eca9a4e405f1a5ae24a2b3290b37cf7f21eba6cbe4fc3fab979237d4f3","affectsGlobalScope":true},{"version":"811ec78f7fefcabbda4bfa93b3eb67d9ae166ef95f9bff989d964061cbf81a0c","affectsGlobalScope":true},{"version":"717937616a17072082152a2ef351cb51f98802fb4b2fdabd32399843875974ca","affectsGlobalScope":true},{"version":"d7e7d9b7b50e5f22c915b525acc5a49a7a6584cf8f62d0569e557c5cfc4b2ac2","affectsGlobalScope":true},{"version":"71c37f4c9543f31dfced6c7840e068c5a5aacb7b89111a4364b1d5276b852557","affectsGlobalScope":true},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true},{"version":"49ed889be54031e1044af0ad2c603d627b8bda8b50c1a68435fe85583901d072","affectsGlobalScope":true},{"version":"e93d098658ce4f0c8a0779e6cab91d0259efb88a318137f686ad76f8410ca270","affectsGlobalScope":true},{"version":"063600664504610fe3e99b717a1223f8b1900087fab0b4cad1496a114744f8df","affectsGlobalScope":true},{"version":"934019d7e3c81950f9a8426d093458b65d5aff2c7c1511233c0fd5b941e608ab","affectsGlobalScope":true},{"version":"bf14a426dbbf1022d11bd08d6b8e709a2e9d246f0c6c1032f3b2edb9a902adbe","affectsGlobalScope":true},{"version":"5e07ed3809d48205d5b985642a59f2eba47c402374a7cf8006b686f79efadcbd","affectsGlobalScope":true},{"version":"2b72d528b2e2fe3c57889ca7baef5e13a56c957b946906d03767c642f386bbc3","affectsGlobalScope":true},{"version":"8073890e29d2f46fdbc19b8d6d2eb9ea58db9a2052f8640af20baff9afbc8640","affectsGlobalScope":true},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true},{"version":"af3dd424cf267428f30ccfc376f47a2c0114546b55c44d8c0f1d57d841e28d74","affectsGlobalScope":true},{"version":"995c005ab91a498455ea8dfb63aa9f83fa2ea793c3d8aa344be4a1678d06d399","affectsGlobalScope":true},{"version":"51e547984877a62227042850456de71a5c45e7fe86b7c975c6e68896c86fa23b","affectsGlobalScope":true},{"version":"956d27abdea9652e8368ce029bb1e0b9174e9678a273529f426df4b3d90abd60","affectsGlobalScope":true},{"version":"4fa6ed14e98aa80b91f61b9805c653ee82af3502dc21c9da5268d3857772ca05","affectsGlobalScope":true},{"version":"e6633e05da3ff36e6da2ec170d0d03ccf33de50ca4dc6f5aeecb572cedd162fb","affectsGlobalScope":true},{"version":"d8670852241d4c6e03f2b89d67497a4bbefe29ecaa5a444e2c11a9b05e6fccc6","affectsGlobalScope":true},{"version":"8444af78980e3b20b49324f4a16ba35024fef3ee069a0eb67616ea6ca821c47a","affectsGlobalScope":true},{"version":"caccc56c72713969e1cfe5c3d44e5bab151544d9d2b373d7dbe5a1e4166652be","affectsGlobalScope":true},{"version":"3287d9d085fbd618c3971944b65b4be57859f5415f495b33a6adc994edd2f004","affectsGlobalScope":true},{"version":"50d53ccd31f6667aff66e3d62adf948879a3a16f05d89882d1188084ee415bbc","affectsGlobalScope":true},{"version":"08a58483392df5fcc1db57d782e87734f77ae9eab42516028acbfe46f29a3ef7","affectsGlobalScope":true},{"version":"436aaf437562f276ec2ddbee2f2cdedac7664c1e4c1d2c36839ddd582eeb3d0a","affectsGlobalScope":true},{"version":"13f6e6380c78e15e140243dc4be2fa546c287c6d61f4729bc2dd7cf449605471","affectsGlobalScope":true},{"version":"33358442698bb565130f52ba79bfd3d4d484ac85fe33f3cb1759c54d18201393","affectsGlobalScope":true},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true},"4a3605bef1a5ef29fd5a1696dd95b0b4e2259e2d07a4d88fac79f3a9765c44a2","370079895f1acdd4bb5194a403c85bf60cfbb2654bced9430a6c7210e7246be8","90240231e730deed31569f6c686766a538e4a024bbc33ea1738fe924f477ba61","552223520e823223ee13c5764e9b69b1819c985818a8bcda435d8d1dbd909bee","49b7c3ddd683c09aa437dd92681699387441f522524b14d2331ce494a9bf2f27","d35b5db21a04a45ae6323c4d4b25acc983dfe2870fc670fd05249eb19d839a5e","637b97f727f21c07a73f09130dc7bf5ac94d04511b179b5eb3e9a4d85a16147a","51720c0374406647b50f84f24c7b623f1d01e1955f7e929da7c5c0629b4390ad","5212dd78d1d63ab33332c8846a0ea5ce248159e74033cde16de48373036b4704","954b3c04ee9f94ca1e262f3e5a6e833b0da0066514b3d4b97b92b7f0c85f8700","a2fc9ce1ae5bed7068d701d8aeebf13321de0f42c217dc2e10f1622dcaa53a7f","8e81f220cb935d551e88cff11541d5e89d3a3494a52fe6247e98016a9dbd4c2d","6b2576a04253626ba41b7dc7ec5977bec07f3b6952b16249d9fa8a3a0d79901c","9de17491f2bfbccea92500e174079d53bdedae34dbebe5d4a12a06ab09814710","e88481085a8576fa52efc913e631c1a833d16179486469b8538d8c4fab2f7381","aec68502c8f4ffaecb4440b37363473582fec0bfee4fb8668a87daa7f700f708","d71577e78c7a4257074aaf82f595724175210c89e8b467ef82f949a6cbd891bc","cf548af8b03cbbc79fdc4f357b5560f618c6d2f68c8688e6eb759c3c11d962c3","c84146dbc9d2e5f43d2cbf15485a4eabf90219dbb66c0d481f20f12d3851bffc","9dc5a1d8f09f9faf21207253a92b461190d59c81ee12c9ac612630e699749990","99c24f331c9f4e75a779b9a988e942442db3cf29923ceb820d3bdd4ed1edfef2","25b1f20d5868ef9ef18132f7dd76b40b7038688ff7c56c58930537a8dff9f231","4105fa0ecfaffb578c8051c3de22e8c984191aac8de14641ee99beed9c5e5bd9","af080582e94b991e099383c1da15f189ca240c12ff5e2338344b7263ab10e305","8c92080253bac0506d82b83d555a029582595f0944abb349954ea732322baa5c","45d4c8d63a67224af62bebff18da32bb2817e306c9fd9e5d1dac6ef8d2da7ead","230eb449f719119cab1728252f20ecdd36d7a20cef659e4a51ada1a232a8aaad","5f264ca312dfcbf23917febc8d7a73ef5be9c248af605939de1c7c4129aa65f2","c1c7b50665ce0b8aa4b95f3843167ac7ac25d1f724d77c2a07b597abb9cf394c","1bf687d978bdd6d5aff10b9eb0ff0695179f8594d4446946fd0182d6d25fa433","ec26029e3a4eccf8ee79d5c76093fbe928cedc83d813fca9be4f055d61530013","e0ff6a627dfbfb9d32e49f34879a763680e37758c509ddd809cb316b96f34390","2113d72680c7ddad6d3b6f70a29432a35c074c94ec6823a7c16ccd69847d965c","c8ffd61bf2db2e7bccb996dd70c9499805cb338f1b1c781987e38ba99dd5b296","55e5a976b594dc02f054860fb59a5299872a5b3c8c90e96733a5c9c9d4ed1fb8","fac83d4c6898d5bf90c508cc84409ded40fdc14611cf42d7fb750fb2c7847979","1668310e691181966c371fce881c88cb1c2e65ac832ef5470434ad926998da2f","4f1eb6b9c2b666278e09019281953fc4ecadad3b2ba2781b2602445743eaaeca","75848e9f0cfb046e64bc8610b0b07e97288d340196a2d5bc6bcbf01e595a81d9","2db0dd3aaa2ed285950273ce96ae8a450b45423aa9da2d10e194570f1233fa6b","7394959e5a741b185456e1ef5d64599c36c60a323207450991e7a42e08911419","4967529644e391115ca5592184d4b63980569adf60ee685f968fd59ab1557188","5929864ce17fba74232584d90cb721a89b7ad277220627cc97054ba15a98ea8f","24bd580b5743dc56402c440dc7f9a4f5d592ad7a419f25414d37a7bfe11e342b","25c8056edf4314820382a5fdb4bb7816999acdcb929c8f75e3f39473b87e85bc","c464d66b20788266e5353b48dc4aa6bc0dc4a707276df1e7152ab0c9ae21fad8","78d0d27c130d35c60b5e5566c9f1e5be77caf39804636bc1a40133919a949f21","c6fd2c5a395f2432786c9cb8deb870b9b0e8ff7e22c029954fabdd692bff6195","1d6e127068ea8e104a912e42fc0a110e2aa5a66a356a917a163e8cf9a65e4a75","5ded6427296cdf3b9542de4471d2aa8d3983671d4cac0f4bf9c637208d1ced43","6bdc71028db658243775263e93a7db2fd2abfce3ca569c3cca5aee6ed5eb186d","cadc8aced301244057c4e7e73fbcae534b0f5b12a37b150d80e5a45aa4bebcbd","385aab901643aa54e1c36f5ef3107913b10d1b5bb8cbcd933d4263b80a0d7f20","9670d44354bab9d9982eca21945686b5c24a3f893db73c0dae0fd74217a4c219","0b8a9268adaf4da35e7fa830c8981cfa22adbbe5b3f6f5ab91f6658899e657a7","11396ed8a44c02ab9798b7dca436009f866e8dae3c9c25e8c1fbc396880bf1bb","ba7bc87d01492633cb5a0e5da8a4a42a1c86270e7b3d2dea5d156828a84e4882","4893a895ea92c85345017a04ed427cbd6a1710453338df26881a6019432febdd","c21dc52e277bcfc75fac0436ccb75c204f9e1b3fa5e12729670910639f27343e","13f6f39e12b1518c6650bbb220c8985999020fe0f21d818e28f512b7771d00f9","9b5369969f6e7175740bf51223112ff209f94ba43ecd3bb09eefff9fd675624a","4fe9e626e7164748e8769bbf74b538e09607f07ed17c2f20af8d680ee49fc1da","24515859bc0b836719105bb6cc3d68255042a9f02a6022b3187948b204946bd2","ea0148f897b45a76544ae179784c95af1bd6721b8610af9ffa467a518a086a43","24c6a117721e606c9984335f71711877293a9651e44f59f3d21c1ea0856f9cc9","dd3273ead9fbde62a72949c97dbec2247ea08e0c6952e701a483d74ef92d6a17","405822be75ad3e4d162e07439bac80c6bcc6dbae1929e179cf467ec0b9ee4e2e","0db18c6e78ea846316c012478888f33c11ffadab9efd1cc8bcc12daded7a60b6","4d2b0eb911816f66abe4970898f97a2cfc902bcd743cbfa5017fad79f7ef90d8","bd0532fd6556073727d28da0edfd1736417a3f9f394877b6d5ef6ad88fba1d1a","89167d696a849fce5ca508032aabfe901c0868f833a8625d5a9c6e861ef935d2","e53a3c2a9f624d90f24bf4588aacd223e7bec1b9d0d479b68d2f4a9e6011147f","24b8685c62562f5d98615c5a0c1d05f297cf5065f15246edfe99e81ec4c0e011","93507c745e8f29090efb99399c3f77bec07db17acd75634249dc92f961573387","339dc5265ee5ed92e536a93a04c4ebbc2128f45eeec6ed29f379e0085283542c","4732aec92b20fb28c5fe9ad99521fb59974289ed1e45aecb282616202184064f","2e85db9e6fd73cfa3d7f28e0ab6b55417ea18931423bd47b409a96e4a169e8e6","c46e079fe54c76f95c67fb89081b3e399da2c7d109e7dca8e4b58d83e332e605","bf67d53d168abc1298888693338cb82854bdb2e69ef83f8a0092093c2d562107",{"version":"c75ac0682b74face8d051331544f633445f5d203dc773d579fa109a7cbee9f06","affectsGlobalScope":true},"3d77c73be94570813f8cadd1f05ebc3dc5e2e4fdefe4d340ca20cd018724ee36",{"version":"e8dbde089a4b9d5b2124764ebbcfe577ffcb3a1df5cfb512a504c708ddfc7262","affectsGlobalScope":true},"62f1c00d3d246e0e3cf0224f91e122d560428ec1ccc36bb51d4574a84f1dbad0","53f0960fdcc53d097918adfd8861ffbe0db989c56ffc16c052197bf115da5ed6",{"version":"662163e5327f260b23ca0a1a1ad8a74078aabb587c904fcb5ef518986987eaff","affectsGlobalScope":true},"a40826e8476694e90da94aa008283a7de50d1dafd37beada623863f1901cb7fb",{"version":"f85c06e750743acf31f0cfd3be284a364d469761649e29547d0dd6be48875150","affectsGlobalScope":true},"b0c0d1d13be149f790a75b381b413490f98558649428bb916fd2d71a3f47a134","3c884d9d9ec454bdf0d5a0b8465bf8297d2caa4d853851d92cc417ac6f30b969","0364f8bb461d6e84252412d4e5590feda4eb582f77d47f7a024a7a9ff105dfdc","5433f7f77cd1fd53f45bd82445a4e437b2f6a72a32070e907530a4fea56c30c8","d0ca5d7df114035258a9d01165be309371fcccf0cccd9d57b1453204686d1ed0",{"version":"ee1ee365d88c4c6c0c0a5a5701d66ebc27ccd0bcfcfaa482c6e2e7fe7b98edf7","affectsGlobalScope":true},{"version":"9a30b7fefd7f8abbca4828d481c61c18e40fe5ff107e113b1c1fcd2c8dcf2743","affectsGlobalScope":true},"173b6275a81ebdb283b180654890f46516c21199734fed01a773b1c168b8c45c","304f66274aa8119e8d65a49b1cff84cbf803def6afe1b2cc987386e9a9890e22","1b9adafe8a7fefaeaf9099a0e06f602903f6268438147b843a33a5233ac71745","98273274f2dbb79b0b2009b20f74eca4a7146a3447c912d580cd5d2d94a7ae30","c933f7ba4b201c98b14275fd11a14abb950178afd2074703250fe3654fc10cd2","dccdf1677e531e33f8ac961a68bc537418c9a414797c1ea7e91307501cdc3f5e",{"version":"ea455cc68871b049bcecd9f56d4cf27b852d6dafd5e3b54468ca87cc11604e4d","affectsGlobalScope":true},"8f5814f29dbaf8bacd1764aebdf1c8a6eb86381f6a188ddbac0fcbaab855ce52","a63d03de72adfb91777784015bd3b4125abd2f5ef867fc5a13920b5649e8f52b","d20e003f3d518a7c1f749dbe27c6ab5e3be7b3c905a48361b04a9557de4a6900",{"version":"452e8a437aa57fe832dece2a5d3ea8dd0ab1de03ca778d09798c56ece0a29e80","affectsGlobalScope":true},"ad7e61eca7f2f8bf47e72695f9f6663b75e41d87ef49abdb17c0cb843862f8aa","ecba2e44af95b0599c269a92628cec22e752868bce37396740deb51a5c547a26","46a9fb41a8f3bc7539eeebc15a6e04b9e55d7537a081615ad3614220d34c3e0f",{"version":"a20f1e119615bf7632729fd89b6c0b5ffdc2df3b512d6304146294528e3ebe19","affectsGlobalScope":true},"575fb200043b11b464db8e42cc64379c5fd322b6d787638e005b5ee98a64486d","6de2f225d942562733e231a695534b30039bdf1875b377bb7255881f0df8ede8","56249fd3ef1f6b90888e606f4ea648c43978ef43a7263aafad64f8d83cd3b8aa","139ad1dc93a503da85b7a0d5f615bddbae61ad796bc68fedd049150db67a1e26","7b166975fdbd3b37afb64707b98bca88e46577bbc6c59871f9383a7df2daacd1","9eece5e586312581ccd106d4853e861aaaa1a39f8e3ea672b8c3847eedd12f6e","81505c54d7cad0009352eaa21bd923ab7cdee7ec3405357a54d9a5da033a2084","269929a24b2816343a178008ac9ae9248304d92a8ba8e233055e0ed6dbe6ef71","93452d394fdd1dc551ec62f5042366f011a00d342d36d50793b3529bfc9bd633",{"version":"73aa178e8fb1449ef3666093d8dca25f96302a80ee45f8ff027df8e4792bf9fd","affectsGlobalScope":true},"2ee1645e0df9d84467cfe1d67b0ad3003c2f387de55874d565094464ee6f2927",{"version":"f61ec7355ade6c4cffc2b121bab7bd6882a262c44b498f4fedbbbc8c8830a8cd","affectsGlobalScope":true},{"version":"9cf780e96b687e4bdfd1907ed26a688c18b89797490a00598fa8b8ab683335dd","affectsGlobalScope":true},"98e00f3613402504bc2a2c9a621800ab48e0a463d1eed062208a4ae98ad8f84c","9ae88ce9f73446c24b2d2452e993b676da1b31fca5ceb7276e7f36279f693ed1","e49d7625faff2a7842e4e7b9b197f972633fca685afcf6b4403400c97d087c36","b82c38abc53922b1b3670c3af6f333c21b735722a8f156e7d357a2da7c53a0a0",{"version":"b423f53647708043299ded4daa68d95c967a2ac30aa1437adc4442129d7d0a6c","affectsGlobalScope":true},{"version":"21fcdcb618236f0feaca7e511e2da10c19970f86e09c934cef2d45b340ad92b5","affectsGlobalScope":true},"4f0fc7b7f54422bd97cfaf558ddb4bca86893839367b746a8f86b60ac7619673","4cdd8b6b51599180a387cc7c1c50f49eca5ce06595d781638fd0216520d98246","d91a7d8b5655c42986f1bdfe2105c4408f472831c8f20cf11a8c3345b6b56c8c",{"version":"8704423bf338bff381ebc951ed819935d0252d90cd6de7dffe5b0a5debb65d07","affectsGlobalScope":true},"b33379077284c9e55d2410d814b71b15522c5f71f9e93e15a8c3c41d463b00f6",{"version":"ab9b9a36e5284fd8d3bf2f7d5fcbc60052f25f27e4d20954782099282c60d23e","affectsGlobalScope":true},"a42be67ed1ddaec743582f41fc219db96a1b69719fccac6d1464321178d610fc","c663a7e4ee2cb54d99cf095479a5bcf1dd18d762ffdfa038aa1b2d79b070b0d7","5463c98206a890ea7a759fbcc97b0c042ab1a740b3e24037f7fbf40bae70a3c5","841f7ca2af7f4d9cca1f9fa2288a4849fc9d49ca15b47336892efd06a14dd1d8","5bccd6ffc11fed820a432ac819200e6af38f8c3625e6eae0cf0f07ca85856392","ca027df9fd496a200d99ca0db4b0077463ce4926a6c8e05cfae522c5971ccbc0","1b264ffd6af49c225160e08d55034a903eb95543c4bc5eed6dc0742d6e5946da","1447d46bff9e7c5c77da14515a7456ea5e919ce6e28f5e6746edf99818e4be47","ba3f6f0ee47f46cdce55620aec5726de80e92a930982634afe9918c114c38f0b","6f38045547cdfd54ec19abcd943cace72c775fde739c5e0e1d917cf3030c16b5","929fc31f7523aaa1d19735b77e637af06e58d76007648ec088ecfbec1521cbfe","8510595d2ca2660e6407be65d8bf95f0c53877dbb812e269cdd980fc34de5f78","a6eb23f2a83113ce0ab7203bfda2be0888720f8d694a20abaef83b9f62832061","363dca5004ac5a3d9c2bba12812b97a64461911762f0b8f9320a8856ec53bcad","557b8c7481296f4b7ed362320f3bbb40bb87404edf880c81224f365a8d1e17f3","283ed3d075bf7d3e8793f63b2a52f475ed84d95b7b6351c5d5bcc6c49d4b845b","6544dab49004fecb69a4ef775e9ad2773a6148b1f9bfd9b75508e3afa11f5d35","bd4c741820ec3574b7ed3b782c8d78034d6e4631d11997e701e6b955b86a87c1","e2dd36a524ea5b13de1ed104ede9cea79696588175c1df1940d6a29113a4aee0","a878d4c7237a7af50e96534295fcf723134d70cbb1e9bfd8365266b912aee6ec","a1f708ddf34053065f8f53682123421af299cee37ae110a86ba07851adf940da","6d268309f0e15dd820b2df9806234166554cb4e2fe00d11737adcb4e5489f700","58cf96187feb10cc8ad3bb080871cd30888ef63bc5db131f11458850ef8f6245","9102986ff52326a2016e8cddc1cf3092f0808ac916dcc8dc2d2c7195cd181987","fa82b7b22d9df87323e31e9e2ad75911028f3e544647fd212424b3c4452fee3f","01f20dac9dc14f0d306e5d1215c5c1c3b4d1805905e60ae92fabac4031eae7da","9ceec2a882368c0160a8a3879aa0efce0fb985751fc23ff6191006030969cfa4","cad5d6451789234434c28dd2d6a8267b0d64c479b1ad267321faa31ba90d570b","6516fc98fa10b0cb22c7e332bacea4a7ea80257e113f6cdddd924d03bfde218e","e7df88db638a7f62201d1befd4af78346a74e25368730318e5cf54d880edd7c5","69ff0e3dd7b3a03966b4e2765ffd85a540b4a9207d2f0ef60e7ec94d9f646abb","bbb50d98d9774aa63660c3d38bccd78359491e7c06bd21ad828874a9469b7b74","439b61b2e4a451ae4c9b1c29dfb375ece00e11106e4d5b2179a2c6af17ae0c04","330e6ac00ea505070726d0c1eb3d49ab7dec7aac38ccc27a68d65eb4a32cbe8b","0fba70efa3a0a0a3b6c30d7e8c6e9b686f842781999ee456d425e802c4d44a8e","e2bd07a2128ccbdfa5a5bad3aad90ea43a0381782f4b71a32e3f6435556d8d64","68f02ba57c531227ef5804dd57f2e940b10c544c96dadd3c0ef958ba4b6fdbc1","27679e96d1bd38c5938178aaf4abe8627493090b63d6bae2ce8436e6a87ebe4d","136f00f14878a614113b221f2797dd7f5a7fb2220f95cbbbc390a85675f991c0","b04de4c5a5e9e0cc6b6b3d99b0e046705d9226fc384cb89c73014b2be4a84417","af4eea486904e256eb4e3a79c21355b9b065298952e9f2a0a921e8d75168f4a7","1841e57d29c33dd1798d82ceca05b7a95430b7976f14dabd4bcf81f6d114f235",{"version":"49d727e3216ff60b1125c0e6b136d4bd38a3be2765e8a55df224006721d92d3b","signature":"e17d4599fe98dee10c75b88faf18ddbffd7dd233cd784bb450f2e62ba9b5d3a3"},"f0d7ddd36a5f0302dbad31ae1756103614b1d2cb5d66787f6c7707421844600f","bcc66913f07d898149b4bb118d1b04c4925f0d61dceeecc65ef5bb58b5004d4c","66336b5a5d5e897e932cbf1e306ff8ac8a9929971409a8049c8c8a249cd8b57c","ac63a01fcac70315fc9b416e9a57e568b18032c7cfcaa314e1751f03ef71286f",{"version":"7879f1a53872adccc221a04d3885bf75f9bee87a436b2b5b889117de6a8cd9e6","signature":"6aecf00eacee4f20fdef08ddbb600abf64687515e07447d04edc7418b4dfe056"},{"version":"29f62b8f2f3a829b7f61342c65faee83d0256031133597d72d82b0a2701fec3d","signature":"bd152375a1e65b39e9e394ef3aa12a0f3dd0646b5a7c6bee09f6b8ab31f01bbd"},{"version":"fdc5d783c3222485082d88a681b9fc198bbeb4eaa95884c4d59fcf8c32cc3949","signature":"9ddc10cfd8da813b251836986542d63e0120b2caed8ea97f14583809ff47e5f4"},"7a6f74294b8fb90f5e3832be21e25898dd81b2a1adc36dda6929813ba4135311","3f1370424c252aed11747282fc619f04497e426f63917bf2182fd46d51adc58a","5d40e6a7071d0d1e6e558e17214ff786ecb3ea73e31b25a88c2cbe2435fa1252","9e1d4141a748616ed5138f4c01853738a6e06b24c92520aff77a6b0deadcf431",{"version":"6a9eb9c5d3f7474937973fe4b0a9e53025634c2e39118eda436d89f3e9df976f","affectsGlobalScope":true},{"version":"86e56d97b13ef0a58bc9c59aee782ae7d47d63802b5b32129ec5e5d62c20dbfa","affectsGlobalScope":true},{"version":"c1f79c6d85cd84518fd7349588b3c61bdc189f58e3866f925cbf4631c81e31f9","affectsGlobalScope":true},{"version":"54db406753da16e177f094aa66da79840f447de6d87ddd1543a80c9418c52545","affectsGlobalScope":true},{"version":"42f28f4cfca4a70bd89c1d55d76c7978275030b894f6793f36890265c11a83a4","affectsGlobalScope":true},{"version":"7cf1027da9599f056355b46bbea31dbf7f715f797dffb9cbb3402d4490c503e5","affectsGlobalScope":true},"96dbd0787b57ae02981d26d5f2441f0f8444fb46d7578c56527eab89cff13a7d","5ccc3c7f73ef48c223635cd4506f21133560de7abc4c09c623327bb1b54386dc",{"version":"63dc53a63cba17f8f45c13a75c41ac2ef767b40dce8fff3e82aa041dae6c5935","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881"},"2e34b7e7c07624978db18b34c8a528928a7c24bc4b047add3e9d90bdc49e267f",{"version":"154f765991a71587e41b691d834fe85e0c3f5b481650e0cbb633ccc12d045ca9","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881"},"42baf4ca38c38deaf411ea73f37bc39ff56c6e5c761a968b64ac1b25c92b5cd8","d7dbe0ad36bdca8a6ecf143422a48e72cc8927bab7b23a1a2485c2f78a7022c6","8718fa41d7cf4aa91de4e8f164c90f88e0bf343aa92a1b9b725a9c675c64e16b","f992cd6cc0bcbaa4e6c810468c90f2d8595f8c6c3cf050c806397d3de8585562","68cc8d6fcc2f270d7108f02f3ebc59480a54615be3e09a47e14527f349e9d53e","3eb11dbf3489064a47a2e1cf9d261b1f100ef0b3b50ffca6c44dd99d6dd81ac1","bc222163edcb8df6ba9b506d053d6c5afcae50e85695151cf4636a3107deaba9","035a5df183489c2e22f3cf59fc1ed2b043d27f357eecc0eb8d8e840059d44245","a4809f4d92317535e6b22b01019437030077a76fec1d93b9881c9ed4738fcc54","5f53fa0bd22096d2a78533f94e02c899143b8f0f9891a46965294ee8b91a9434","f3d8c757e148ad968f0d98697987db363070abada5f503da3c06aefd9d4248c1","96d14f21b7652903852eef49379d04dbda28c16ed36468f8c9fa08f7c14c9538","fec943fdb3275eb6e006b35e04a8e2e99e9adf3f4b969ddf15315ac7575a93e4","89121c1bf2990f5219bfd802a3e7fc557de447c62058d6af68d6b6348d64499a","d4a22007b481fe2a2e6bfd3a42c00cd62d41edb36d30fc4697df2692e9891fc8","8841e2aa774b89bd23302dede20663306dc1b9902431ac64b24be8b8d0e3f649","fbca5ffaebf282ec3cdac47b0d1d4a138a8b0bb32105251a38acb235087d3318",{"version":"90ebf5865e27d8966ef44b073e6e83b0ddd45058bab1d58b1e4b5a47d36396c4","affectsGlobalScope":true},"62a8effc4dd17bbc2c05927b4ca5f67e73fdb458e203b128c041d0d70ffa6b55","cb482592bfcbdfcefa8d155590399e8bff66277e60e17bfada7c2f31322e7b87","8b5402ae709d042c3530ed3506c135a967159f42aed3221267e70c5b7240b577","22293bd6fa12747929f8dfca3ec1684a3fe08638aa18023dd286ab337e88a592","916be7d770b0ae0406be9486ac12eb9825f21514961dd050594c4b250617d5a8","510616459e6edd01acbce333fb256e06bdffdad43ca233a9090164bf8bb83912","cf3d384d082b933d987c4e2fe7bfb8710adfd9dc8155190056ed6695a25a559e","9871b7ee672bc16c78833bdab3052615834b08375cb144e4d2cba74473f4a589","c863198dae89420f3c552b5a03da6ed6d0acfa3807a64772b895db624b0de707","8b03a5e327d7db67112ebbc93b4f744133eda2c1743dbb0a990c61a8007823ef","86c73f2ee1752bac8eeeece234fd05dfcf0637a4fbd8032e4f5f43102faa8eec","42fad1f540271e35ca37cecda12c4ce2eef27f0f5cf0f8dd761d723c744d3159","ff3743a5de32bee10906aff63d1de726f6a7fd6ee2da4b8229054dfa69de2c34","83acd370f7f84f203e71ebba33ba61b7f1291ca027d7f9a662c6307d74e4ac22","1445cec898f90bdd18b2949b9590b3c012f5b7e1804e6e329fb0fe053946d5ec","0e5318ec2275d8da858b541920d9306650ae6ac8012f0e872fe66eb50321a669","cf530297c3fb3a92ec9591dd4fa229d58b5981e45fe6702a0bd2bea53a5e59be","c1f6f7d08d42148ddfe164d36d7aba91f467dbcb3caa715966ff95f55048b3a4","f4e9bf9103191ef3b3612d3ec0044ca4044ca5be27711fe648ada06fad4bcc85","0c1ee27b8f6a00097c2d6d91a21ee4d096ab52c1e28350f6362542b55380059a","7677d5b0db9e020d3017720f853ba18f415219fb3a9597343b1b1012cfd699f7","bc1c6bc119c1784b1a2be6d9c47addec0d83ef0d52c8fbe1f14a51b4dfffc675","52cf2ce99c2a23de70225e252e9822a22b4e0adb82643ab0b710858810e00bf1","770625067bb27a20b9826255a8d47b6b5b0a2d3dfcbd21f89904c731f671ba77","d1ed6765f4d7906a05968fb5cd6d1db8afa14dbe512a4884e8ea5c0f5e142c80","799c0f1b07c092626cf1efd71d459997635911bb5f7fc1196efe449bba87e965","2a184e4462b9914a30b1b5c41cf80c6d3428f17b20d3afb711fff3f0644001fd","9eabde32a3aa5d80de34af2c2206cdc3ee094c6504a8d0c2d6d20c7c179503cc","397c8051b6cfcb48aa22656f0faca2553c5f56187262135162ee79d2b2f6c966","a8ead142e0c87dcd5dc130eba1f8eeed506b08952d905c47621dc2f583b1bff9","a02f10ea5f73130efca046429254a4e3c06b5475baecc8f7b99a0014731be8b3","c2576a4083232b0e2d9bd06875dd43d371dee2e090325a9eac0133fd5650c1cb","4c9a0564bb317349de6a24eb4efea8bb79898fa72ad63a1809165f5bd42970dd","f40ac11d8859092d20f953aae14ba967282c3bb056431a37fced1866ec7a2681","cc11e9e79d4746cc59e0e17473a59d6f104692fd0eeea1bdb2e206eabed83b03","b444a410d34fb5e98aa5ee2b381362044f4884652e8bc8a11c8fe14bbd85518e","c35808c1f5e16d2c571aa65067e3cb95afeff843b259ecfa2fc107a9519b5392","14d5dc055143e941c8743c6a21fa459f961cbc3deedf1bfe47b11587ca4b3ef5","a3ad4e1fc542751005267d50a6298e6765928c0c3a8dce1572f2ba6ca518661c","f237e7c97a3a89f4591afd49ecb3bd8d14f51a1c4adc8fcae3430febedff5eb6","3ffdfbec93b7aed71082af62b8c3e0cc71261cc68d796665faa1e91604fbae8f","662201f943ed45b1ad600d03a90dffe20841e725203ced8b708c91fcd7f9379a","c9ef74c64ed051ea5b958621e7fb853fe3b56e8787c1587aefc6ea988b3c7e79","2462ccfac5f3375794b861abaa81da380f1bbd9401de59ffa43119a0b644253d","34baf65cfee92f110d6653322e2120c2d368ee64b3c7981dff08ed105c4f19b0","7d8ddf0f021c53099e34ee831a06c394d50371816caa98684812f089b4c6b3d4","7d2a0ba1297be385a89b5515b88cd31b4a1eeef5236f710166dc1b36b1741e1b","8e87660f5170c195ade218937e360484775be6a4e75a098665d9ba5a2e4cdc15","ab82804a14454734010dcdcd43f564ff7b0389bee4c5692eec76ff5b30d4cf66","4006c872e38a2c4e09c593bc0cdd32b7b4f5c4843910bea0def631c483fff6c5","ab6aa3a65d473871ee093e3b7b71ed0f9c69e07d1d4295f45c9efd91a771241d","9a2eaab4e54953c6b2ba21f7ac4c2593859da03917011c10a2acd8864e38e7b2","bae8d023ef6b23df7da26f51cea44321f95817c190342a36882e93b80d07a960","26a770cec4bd2e7dbba95c6e536390fffe83c6268b78974a93727903b515c4e7","74d5a87c3616cd5d8691059d531504403aa857e09cbaecb1c64dfb9ace0db185"],"root":[241,[246,248],261,263],"options":{"allowJs":true,"checkJs":true,"composite":true,"declaration":true,"declarationMap":true,"emitDeclarationOnly":false,"esModuleInterop":true,"module":7,"noEmitOnError":true,"outDir":"./","removeComments":false,"skipLibCheck":true,"sourceMap":true,"strict":true,"stripInternal":true,"target":9},"fileIdsList":[[249],[201,214,250,251],[70,72,83,84,201],[72,82,84],[70,72,82,83,201],[69,85,201],[158,199],[71,72,77,82,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,101,102,103,200],[67,69,70],[84],[85,87],[67,69,71],[72,82],[72,85,201],[71,72,82],[70,71,72,84,87,100],[70,71],[70,83,84,201],[72,84],[77,82,84,87,94,201],[201],[67,69,201],[76,77],[76],[74,75,78],[82],[73,78,80,81],[78,80,82],[79,82],[158,161,191,199,264,265,266],[253],[268],[199],[271],[272],[277],[152,158,199,270],[104],[145],[146,151,183],[147,152,158,159,166,180,191],[147,148,158,166],[149,192],[150,151,159,167],[151,180,188],[152,154,158,166],[145,153],[154,155],[158],[156,158],[145,158],[158,159,160,180,191],[158,159,160,176,180,183],[143,196],[154,158,161,166,180,191],[158,159,161,162,166,180,188,191],[161,163,180,188,191],[104,105,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198],[158,164],[165,191,196],[154,158,166,180],[167],[168],[145,169],[104,105,145,146,147,148,149,150,151,152,153,154,155,156,158,159,160,161,162,163,164,165,166,167,168,169,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197],[174],[175],[158,176,177],[176,178,192,194],[146,158,180,181,182,183],[146,180,182],[180,181],[183],[184],[104,180],[158,186,187],[186,187],[151,166,180,188],[189],[166,190],[146,161,175,191],[151,192],[180,193],[165,194],[195],[146,151,158,160,169,180,191,194,196],[180,197],[161,180,199],[288,327],[288,312,327],[327],[288],[288,313,327],[288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,310,311,312,313,314,315,316,317,318,319,320,321,322,323,324,325,326],[313,327],[328],[158,161,163,180,188,191,197,199],[334],[158,180,199],[253,254,255,256,257,258],[253,254],[218],[67,69,201,219,228,229],[70,227],[69,201,228,230],[232,233],[65],[207,208,214,215],[68,69],[68],[66],[206],[67],[67,210],[69,209,210,211,212,213],[65,66,67,68,206],[65,66,67],[236,237,238,239],[237],[237,238],[227],[220],[70,220],[220,221,222,223,224,225,226],[170,171],[217],[214,216],[115,119,191],[115,180,191],[110],[112,115,188,191],[166,188],[110,199],[112,115,166,191],[107,108,111,114,146,158,180,191],[115,122],[107,113],[115,136,137],[111,115,146,183,191,199],[146,199],[136,146,199],[109,110,199],[115],[109,110,111,112,113,114,115,116,117,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,137,138,139,140,141,142],[115,130],[115,122,123],[113,115,123,124],[114],[107,110,115],[115,119,123,124],[119],[113,115,118,191],[107,112,115,122],[146,180],[110,115,136,146,196,199],[82,201,202,203,204,205,214,230,231,234,235,240,241,246,247],[69,82,201,230,248],[69,201,230,242,243,244,245,246],[69,82,203,230,246,252,259,260],[69,201,203,230,245,246,252,259,260,262],[201,214,230,246],[69,82,201,230],[69,201,246]],"referencedMap":[[250,1],[252,2],[251,1],[96,3],[97,4],[84,5],[86,6],[200,7],[201,8],[71,9],[88,10],[98,11],[72,12],[85,13],[89,14],[90,15],[101,16],[102,17],[92,10],[94,18],[93,19],[95,20],[202,21],[203,22],[78,23],[75,24],[74,24],[76,25],[81,26],[82,27],[73,26],[79,28],[80,29],[267,30],[254,31],[258,31],[256,31],[269,32],[270,33],[272,34],[273,35],[276,7],[278,36],[282,37],[284,33],[104,38],[105,38],[145,39],[146,40],[147,41],[148,42],[149,43],[150,44],[151,45],[152,46],[153,47],[154,48],[155,48],[157,49],[156,50],[158,51],[159,52],[160,53],[144,54],[161,55],[162,56],[163,57],[199,58],[164,59],[165,60],[166,61],[167,62],[168,63],[169,64],[173,65],[174,66],[175,67],[176,68],[177,68],[178,69],[180,70],[182,71],[181,72],[183,73],[184,74],[185,75],[186,76],[187,77],[188,78],[189,79],[190,80],[191,81],[192,82],[193,83],[194,84],[195,85],[196,86],[197,87],[266,88],[312,89],[313,90],[288,91],[291,91],[310,89],[311,89],[301,89],[300,92],[298,89],[293,89],[306,89],[304,89],[308,89],[292,89],[305,89],[309,89],[294,89],[295,89],[307,89],[289,89],[296,89],[297,89],[299,89],[303,89],[314,93],[302,89],[290,89],[327,94],[321,93],[323,95],[322,93],[315,93],[316,93],[318,93],[320,93],[324,95],[325,95],[317,95],[319,95],[329,96],[333,97],[335,98],[336,99],[259,100],[257,31],[255,101],[219,102],[230,103],[228,104],[229,105],[231,21],[234,106],[264,49],[215,107],[216,108],[66,109],[69,110],[206,111],[207,112],[208,112],[210,113],[211,114],[214,115],[213,116],[68,117],[240,118],[238,119],[239,120],[220,121],[223,122],[224,122],[221,123],[222,122],[227,124],[225,104],[226,121],[172,125],[245,126],[218,126],[217,127],[122,128],[132,129],[121,128],[142,130],[113,131],[112,132],[141,33],[135,133],[140,134],[115,135],[129,136],[114,137],[138,138],[110,139],[109,140],[139,141],[111,142],[116,143],[120,143],[143,144],[133,145],[124,146],[125,147],[127,148],[123,149],[126,150],[136,33],[118,151],[119,152],[128,153],[108,154],[131,145],[130,143],[137,155],[248,156],[246,157],[247,158],[261,159],[263,160]],"exportedModulesMap":[[250,1],[252,2],[251,1],[96,3],[97,4],[84,5],[86,6],[200,7],[201,8],[71,9],[88,10],[98,11],[72,12],[85,13],[89,14],[90,15],[101,16],[102,17],[92,10],[94,18],[93,19],[95,20],[202,21],[203,22],[78,23],[75,24],[74,24],[76,25],[81,26],[82,27],[73,26],[79,28],[80,29],[267,30],[254,31],[258,31],[256,31],[269,32],[270,33],[272,34],[273,35],[276,7],[278,36],[282,37],[284,33],[104,38],[105,38],[145,39],[146,40],[147,41],[148,42],[149,43],[150,44],[151,45],[152,46],[153,47],[154,48],[155,48],[157,49],[156,50],[158,51],[159,52],[160,53],[144,54],[161,55],[162,56],[163,57],[199,58],[164,59],[165,60],[166,61],[167,62],[168,63],[169,64],[173,65],[174,66],[175,67],[176,68],[177,68],[178,69],[180,70],[182,71],[181,72],[183,73],[184,74],[185,75],[186,76],[187,77],[188,78],[189,79],[190,80],[191,81],[192,82],[193,83],[194,84],[195,85],[196,86],[197,87],[266,88],[312,89],[313,90],[288,91],[291,91],[310,89],[311,89],[301,89],[300,92],[298,89],[293,89],[306,89],[304,89],[308,89],[292,89],[305,89],[309,89],[294,89],[295,89],[307,89],[289,89],[296,89],[297,89],[299,89],[303,89],[314,93],[302,89],[290,89],[327,94],[321,93],[323,95],[322,93],[315,93],[316,93],[318,93],[320,93],[324,95],[325,95],[317,95],[319,95],[329,96],[333,97],[335,98],[336,99],[259,100],[257,31],[255,101],[219,102],[230,103],[228,104],[229,105],[231,21],[234,106],[264,49],[215,107],[216,108],[66,109],[69,110],[206,111],[207,112],[208,112],[210,113],[211,114],[214,115],[213,116],[68,117],[240,118],[238,119],[239,120],[220,121],[223,122],[224,122],[221,123],[222,122],[227,124],[225,104],[226,121],[172,125],[245,126],[218,126],[217,127],[122,128],[132,129],[121,128],[142,130],[113,131],[112,132],[141,33],[135,133],[140,134],[115,135],[129,136],[114,137],[138,138],[110,139],[109,140],[139,141],[111,142],[116,143],[120,143],[143,144],[133,145],[124,146],[125,147],[127,148],[123,149],[126,150],[136,33],[118,151],[119,152],[128,153],[108,154],[131,145],[130,143],[137,155],[248,161],[246,162],[247,163]],"semanticDiagnosticsPerFile":[250,252,249,251,96,97,84,86,103,87,200,201,71,88,98,72,85,89,90,99,101,102,91,92,94,93,95,202,203,78,75,74,76,81,82,73,79,80,267,254,258,256,253,269,270,265,271,272,273,274,275,276,278,279,280,281,268,282,283,284,104,105,145,146,147,148,149,150,151,152,153,154,155,157,156,158,159,160,144,198,161,162,163,199,164,165,166,167,168,169,173,174,175,176,177,178,179,180,182,181,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,285,286,266,287,312,313,288,291,310,311,301,300,298,293,306,304,308,292,305,309,294,295,307,289,296,297,299,303,314,302,290,327,326,321,323,322,315,316,318,320,324,325,317,319,329,328,330,331,332,277,333,334,335,336,259,204,205,106,257,255,236,219,230,228,229,231,260,242,243,234,232,233,100,83,264,215,65,216,66,209,69,206,207,208,210,211,67,214,213,68,212,235,240,238,239,237,77,220,223,224,221,222,227,225,226,170,171,172,63,64,11,12,15,14,2,16,17,18,19,20,21,22,23,3,24,4,25,29,26,27,28,30,31,32,5,33,34,35,36,6,40,37,38,39,41,7,42,47,48,43,44,45,46,8,52,49,50,51,53,9,54,55,56,59,57,58,60,61,10,1,62,13,70,262,244,245,218,217,122,132,121,142,113,112,141,135,140,115,129,114,138,110,109,139,111,116,117,120,107,143,133,124,125,127,123,126,136,118,119,128,108,131,130,134,137,248,241,246,247,261,263],"latestChangedDtsFile":"./test/routings.spec.d.ts"},"version":"5.4.5"} +\ No newline at end of file +diff --git a/node_modules/@helia/delegated-routing-v1-http-api-client/dist/typedoc-urls.json b/node_modules/@helia/delegated-routing-v1-http-api-client/dist/typedoc-urls.json +deleted file mode 100644 +index c210189..0000000 +--- a/node_modules/@helia/delegated-routing-v1-http-api-client/dist/typedoc-urls.json ++++ /dev/null +@@ -1,12 +0,0 @@ +-{ +- "DelegatedRoutingV1HttpApiClient": "https://ipfs.github.io/helia-delegated-routing-v1-http-api/interfaces/_helia_delegated_routing_v1_http_api_client.DelegatedRoutingV1HttpApiClient.html", +- ".:DelegatedRoutingV1HttpApiClient": "https://ipfs.github.io/helia-delegated-routing-v1-http-api/interfaces/_helia_delegated_routing_v1_http_api_client.DelegatedRoutingV1HttpApiClient.html", +- "DelegatedRoutingV1HttpApiClientInit": "https://ipfs.github.io/helia-delegated-routing-v1-http-api/interfaces/_helia_delegated_routing_v1_http_api_client.DelegatedRoutingV1HttpApiClientInit.html", +- ".:DelegatedRoutingV1HttpApiClientInit": "https://ipfs.github.io/helia-delegated-routing-v1-http-api/interfaces/_helia_delegated_routing_v1_http_api_client.DelegatedRoutingV1HttpApiClientInit.html", +- "GetIPNSOptions": "https://ipfs.github.io/helia-delegated-routing-v1-http-api/interfaces/_helia_delegated_routing_v1_http_api_client.GetIPNSOptions.html", +- ".:GetIPNSOptions": "https://ipfs.github.io/helia-delegated-routing-v1-http-api/interfaces/_helia_delegated_routing_v1_http_api_client.GetIPNSOptions.html", +- "PeerRecord": "https://ipfs.github.io/helia-delegated-routing-v1-http-api/interfaces/_helia_delegated_routing_v1_http_api_client.PeerRecord.html", +- ".:PeerRecord": "https://ipfs.github.io/helia-delegated-routing-v1-http-api/interfaces/_helia_delegated_routing_v1_http_api_client.PeerRecord.html", +- "createDelegatedRoutingV1HttpApiClient": "https://ipfs.github.io/helia-delegated-routing-v1-http-api/functions/_helia_delegated_routing_v1_http_api_client.createDelegatedRoutingV1HttpApiClient.html", +- ".:createDelegatedRoutingV1HttpApiClient": "https://ipfs.github.io/helia-delegated-routing-v1-http-api/functions/_helia_delegated_routing_v1_http_api_client.createDelegatedRoutingV1HttpApiClient.html" +-} +\ No newline at end of file +diff --git a/node_modules/@helia/delegated-routing-v1-http-api-client/src/client.ts b/node_modules/@helia/delegated-routing-v1-http-api-client/src/client.ts +index 706e05d..fb01200 100644 +--- a/node_modules/@helia/delegated-routing-v1-http-api-client/src/client.ts ++++ b/node_modules/@helia/delegated-routing-v1-http-api-client/src/client.ts +@@ -1,14 +1,15 @@ +-import { contentRoutingSymbol, peerRoutingSymbol, CodeError, setMaxListeners } from '@libp2p/interface' ++import { NotFoundError, contentRoutingSymbol, peerRoutingSymbol, setMaxListeners } from '@libp2p/interface' + import { logger } from '@libp2p/logger' + import { peerIdFromString } from '@libp2p/peer-id' + import { multiaddr } from '@multiformats/multiaddr' + import { anySignal } from 'any-signal' + import toIt from 'browser-readablestream-to-it' +-import { unmarshal, type IPNSRecord, marshal, peerIdToRoutingKey } from 'ipns' ++import { unmarshalIPNSRecord, type IPNSRecord, marshalIPNSRecord, multihashToIPNSRoutingKey } from 'ipns' + import { ipnsValidator } from 'ipns/validator' + import { parse as ndjson } from 'it-ndjson' + import defer from 'p-defer' + import PQueue from 'p-queue' ++import { BadResponseError, InvalidRequestError } from './errors.js' + import { DelegatedRoutingV1HttpApiClientContentRouting, DelegatedRoutingV1HttpApiClientPeerRouting } from './routings.js' + import type { DelegatedRoutingV1HttpApiClient, DelegatedRoutingV1HttpApiClientInit, GetIPNSOptions, PeerRecord } from './index.js' + import type { ContentRouting, PeerRouting, AbortOptions, PeerId } from '@libp2p/interface' +@@ -93,18 +94,18 @@ export class DefaultDelegatedRoutingV1HttpApiClient implements DelegatedRoutingV + + if (res.status === 404) { + // https://specs.ipfs.tech/routing/http-routing-v1/#response-status-codes +- // 404 (Not Found): must be returned if no matching records are found. +- throw new CodeError('No matching records found.', 'ERR_NOT_FOUND') ++ // 404 (Not Found): must be returned if no matching records are found ++ throw new NotFoundError('No matching records found') + } + + if (res.status === 422) { + // https://specs.ipfs.tech/routing/http-routing-v1/#response-status-codes +- // 422 (Unprocessable Entity): request does not conform to schema or semantic constraints. +- throw new CodeError('Request does not conform to schema or semantic constraints.', 'ERR_INVALID_REQUEST') ++ // 422 (Unprocessable Entity): request does not conform to schema or semantic constraints ++ throw new InvalidRequestError('Request does not conform to schema or semantic constraints') + } + + if (res.body == null) { +- throw new CodeError('Routing response had no body', 'ERR_BAD_RESPONSE') ++ throw new BadResponseError('Routing response had no body') + } + + const contentType = res.headers.get('Content-Type') +@@ -159,17 +160,17 @@ export class DefaultDelegatedRoutingV1HttpApiClient implements DelegatedRoutingV + if (res.status === 404) { + // https://specs.ipfs.tech/routing/http-routing-v1/#response-status-codes + // 404 (Not Found): must be returned if no matching records are found. +- throw new CodeError('No matching records found.', 'ERR_NOT_FOUND') ++ throw new NotFoundError('No matching records found') + } + + if (res.status === 422) { + // https://specs.ipfs.tech/routing/http-routing-v1/#response-status-codes +- // 422 (Unprocessable Entity): request does not conform to schema or semantic constraints. +- throw new CodeError('Request does not conform to schema or semantic constraints.', 'ERR_INVALID_REQUEST') ++ // 422 (Unprocessable Entity): request does not conform to schema or semantic constraints ++ throw new InvalidRequestError('Request does not conform to schema or semantic constraints') + } + + if (res.body == null) { +- throw new CodeError('Routing response had no body', 'ERR_BAD_RESPONSE') ++ throw new BadResponseError('Routing response had no body') + } + + const contentType = res.headers.get('Content-Type') +@@ -199,8 +200,8 @@ export class DefaultDelegatedRoutingV1HttpApiClient implements DelegatedRoutingV + } + } + +- async getIPNS (peerId: PeerId, options: GetIPNSOptions = {}): Promise { +- log('getIPNS starts: %c', peerId) ++ async getIPNS (libp2pKey: CID, options: GetIPNSOptions = {}): Promise { ++ log('getIPNS starts: %s', libp2pKey) + + const timeoutSignal = AbortSignal.timeout(this.timeout) + const signal = anySignal([this.shutDownController.signal, timeoutSignal, options.signal]) +@@ -214,7 +215,7 @@ export class DefaultDelegatedRoutingV1HttpApiClient implements DelegatedRoutingV + }) + + // https://specs.ipfs.tech/routing/http-routing-v1/ +- const resource = `${this.clientUrl}routing/v1/ipns/${peerId.toCID().toString()}` ++ const resource = `${this.clientUrl}routing/v1/ipns/${libp2pKey}` + + try { + await onStart.promise +@@ -226,28 +227,28 @@ export class DefaultDelegatedRoutingV1HttpApiClient implements DelegatedRoutingV + + if (res.status === 404) { + // https://specs.ipfs.tech/routing/http-routing-v1/#response-status-codes +- // 404 (Not Found): must be returned if no matching records are found. +- throw new CodeError('No matching records found.', 'ERR_NOT_FOUND') ++ // 404 (Not Found): must be returned if no matching records are found ++ throw new NotFoundError('No matching records found') + } + + if (res.status === 422) { + // https://specs.ipfs.tech/routing/http-routing-v1/#response-status-codes +- // 422 (Unprocessable Entity): request does not conform to schema or semantic constraints. +- throw new CodeError('Request does not conform to schema or semantic constraints.', 'ERR_INVALID_REQUEST') ++ // 422 (Unprocessable Entity): request does not conform to schema or semantic constraints ++ throw new InvalidRequestError('Request does not conform to schema or semantic constraints') + } + + if (res.body == null) { +- throw new CodeError('GET ipns response had no body', 'ERR_BAD_RESPONSE') ++ throw new BadResponseError('GET ipns response had no body') + } + + const buf = await res.arrayBuffer() + const body = new Uint8Array(buf, 0, buf.byteLength) + + if (options.validate !== false) { +- await ipnsValidator(peerIdToRoutingKey(peerId), body) ++ await ipnsValidator(multihashToIPNSRoutingKey(libp2pKey.multihash), body) + } + +- return unmarshal(body) ++ return unmarshalIPNSRecord(body) + } catch (err: any) { + log.error('getIPNS GET %s error:', resource, err) + +@@ -255,12 +256,12 @@ export class DefaultDelegatedRoutingV1HttpApiClient implements DelegatedRoutingV + } finally { + signal.clear() + onFinish.resolve() +- log('getIPNS finished: %c', peerId) ++ log('getIPNS finished: %s', libp2pKey) + } + } + +- async putIPNS (peerId: PeerId, record: IPNSRecord, options: AbortOptions = {}): Promise { +- log('putIPNS starts: %c', peerId) ++ async putIPNS (libp2pKey: CID, record: IPNSRecord, options: AbortOptions = {}): Promise { ++ log('putIPNS starts: %c', libp2pKey) + + const timeoutSignal = AbortSignal.timeout(this.timeout) + const signal = anySignal([this.shutDownController.signal, timeoutSignal, options.signal]) +@@ -274,12 +275,12 @@ export class DefaultDelegatedRoutingV1HttpApiClient implements DelegatedRoutingV + }) + + // https://specs.ipfs.tech/routing/http-routing-v1/ +- const resource = `${this.clientUrl}routing/v1/ipns/${peerId.toCID().toString()}` ++ const resource = `${this.clientUrl}routing/v1/ipns/${libp2pKey}` + + try { + await onStart.promise + +- const body = marshal(record) ++ const body = marshalIPNSRecord(record) + + const getOptions = { method: 'PUT', headers: { 'Content-Type': 'application/vnd.ipfs.ipns-record' }, body, signal } + const res = await fetch(resource, getOptions) +@@ -287,7 +288,7 @@ export class DefaultDelegatedRoutingV1HttpApiClient implements DelegatedRoutingV + log('putIPNS PUT %s %d', resource, res.status) + + if (res.status !== 200) { +- throw new CodeError('PUT ipns response had status other than 200', 'ERR_BAD_RESPONSE') ++ throw new BadResponseError('PUT ipns response had status other than 200') + } + } catch (err: any) { + log.error('putIPNS PUT %s error:', resource, err.stack) +@@ -296,7 +297,7 @@ export class DefaultDelegatedRoutingV1HttpApiClient implements DelegatedRoutingV + } finally { + signal.clear() + onFinish.resolve() +- log('putIPNS finished: %c', peerId) ++ log('putIPNS finished: %c', libp2pKey) + } + } + +diff --git a/node_modules/@helia/delegated-routing-v1-http-api-client/src/errors.ts b/node_modules/@helia/delegated-routing-v1-http-api-client/src/errors.ts +new file mode 100644 +index 0000000..c0dcbca +--- /dev/null ++++ b/node_modules/@helia/delegated-routing-v1-http-api-client/src/errors.ts +@@ -0,0 +1,17 @@ ++export class InvalidRequestError extends Error { ++ static name = 'InvalidRequestError' ++ ++ constructor (message = 'Invalid request') { ++ super(message) ++ this.name = 'InvalidRequestError' ++ } ++} ++ ++export class BadResponseError extends Error { ++ static name = 'BadResponseError' ++ ++ constructor (message = 'Bad response') { ++ super(message) ++ this.name = 'BadResponseError' ++ } ++} +diff --git a/node_modules/@helia/delegated-routing-v1-http-api-client/src/index.ts b/node_modules/@helia/delegated-routing-v1-http-api-client/src/index.ts +index ca02c4e..7dd4bcf 100644 +--- a/node_modules/@helia/delegated-routing-v1-http-api-client/src/index.ts ++++ b/node_modules/@helia/delegated-routing-v1-http-api-client/src/index.ts +@@ -102,14 +102,14 @@ export interface DelegatedRoutingV1HttpApiClient { + getPeers(peerId: PeerId, options?: AbortOptions): AsyncGenerator + + /** +- * Returns a promise of a {@link IPNSRecord} for the given {@link PeerId} ++ * Returns a promise of a {@link IPNSRecord} for the given {@link MultihashDigest} + */ +- getIPNS(peerId: PeerId, options?: GetIPNSOptions): Promise ++ getIPNS(libp2pKey: CID, options?: GetIPNSOptions): Promise + + /** +- * Publishes the given {@link IPNSRecord} for the provided {@link PeerId} ++ * Publishes the given {@link IPNSRecord} for the provided {@link MultihashDigest} + */ +- putIPNS(peerId: PeerId, record: IPNSRecord, options?: AbortOptions): Promise ++ putIPNS(libp2pKey: CID, record: IPNSRecord, options?: AbortOptions): Promise + + /** + * Shut down any currently running HTTP requests and clear up any resources +diff --git a/node_modules/@helia/delegated-routing-v1-http-api-client/src/routings.ts b/node_modules/@helia/delegated-routing-v1-http-api-client/src/routings.ts +index 9e16d80..1f2061d 100644 +--- a/node_modules/@helia/delegated-routing-v1-http-api-client/src/routings.ts ++++ b/node_modules/@helia/delegated-routing-v1-http-api-client/src/routings.ts +@@ -1,13 +1,11 @@ +-import { type ContentRouting, type PeerRouting, type AbortOptions, type PeerId, type PeerInfo } from '@libp2p/interface' +-import { CodeError } from '@libp2p/interface' +-import { peerIdFromBytes } from '@libp2p/peer-id' +-import { marshal, unmarshal } from 'ipns' ++import { type ContentRouting, type PeerRouting, type AbortOptions, type PeerId, type PeerInfo, NotFoundError } from '@libp2p/interface' ++import { marshalIPNSRecord, multihashFromIPNSRoutingKey, unmarshalIPNSRecord } from 'ipns' + import first from 'it-first' + import map from 'it-map' ++import { CID } from 'multiformats/cid' + import { equals as uint8ArrayEquals } from 'uint8arrays/equals' + import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' + import type { DelegatedRoutingV1HttpApiClient } from './index.js' +-import type { CID } from 'multiformats/cid' + + const IPNS_PREFIX = uint8ArrayFromString('/ipns/') + +@@ -15,10 +13,6 @@ function isIPNSKey (key: Uint8Array): boolean { + return uint8ArrayEquals(key.subarray(0, IPNS_PREFIX.byteLength), IPNS_PREFIX) + } + +-const peerIdFromRoutingKey = (key: Uint8Array): PeerId => { +- return peerIdFromBytes(key.slice(IPNS_PREFIX.length)) +-} +- + /** + * Wrapper class to convert [http-routing-v1 content events](https://specs.ipfs.tech/routing/http-routing-v1/#response-body) into returned values + */ +@@ -47,28 +41,30 @@ export class DelegatedRoutingV1HttpApiClientContentRouting implements ContentRou + return + } + +- const peerId = peerIdFromRoutingKey(key) +- const record = unmarshal(value) ++ const digest = multihashFromIPNSRoutingKey(key) ++ const cid = CID.createV1(0x72, digest) ++ const record = unmarshalIPNSRecord(value) + +- await this.client.putIPNS(peerId, record, options) ++ await this.client.putIPNS(cid, record, options) + } + + async get (key: Uint8Array, options?: AbortOptions): Promise { + if (!isIPNSKey(key)) { +- throw new CodeError('Not found', 'ERR_NOT_FOUND') ++ throw new NotFoundError('Not found') + } + +- const peerId = peerIdFromRoutingKey(key) ++ const digest = multihashFromIPNSRoutingKey(key) ++ const cid = CID.createV1(0x72, digest) + + try { +- const record = await this.client.getIPNS(peerId, options) ++ const record = await this.client.getIPNS(cid, options) + +- return marshal(record) ++ return marshalIPNSRecord(record) + } catch (err: any) { +- // ERR_BAD_RESPONSE is thrown when the response had no body, which means ++ // BadResponseError is thrown when the response had no body, which means + // the record couldn't be found +- if (err.code === 'ERR_BAD_RESPONSE') { +- throw new CodeError('Not found', 'ERR_NOT_FOUND') ++ if (err.name === 'BadResponseError') { ++ throw new NotFoundError('Not found') + } + + throw err +@@ -96,7 +92,7 @@ export class DelegatedRoutingV1HttpApiClientPeerRouting implements PeerRouting { + } + } + +- throw new CodeError('Not found', 'ERR_NOT_FOUND') ++ throw new NotFoundError('Not found') + } + + async * getClosestPeers (key: Uint8Array, options: AbortOptions = {}): AsyncIterable { From 605802cab3d55ec7f8ea60e989710b5fef5e9b86 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Fri, 13 Sep 2024 18:45:47 +0100 Subject: [PATCH 2/2] chore: fix deps --- packages/bitswap/package.json | 1 + packages/block-brokers/package.json | 2 ++ packages/helia/package.json | 1 + packages/interop/package.json | 3 +++ packages/ipns/package.json | 1 + packages/routers/package.json | 3 ++- packages/utils/package.json | 1 + 7 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/bitswap/package.json b/packages/bitswap/package.json index a0becf36a..a2ec10e8b 100644 --- a/packages/bitswap/package.json +++ b/packages/bitswap/package.json @@ -176,6 +176,7 @@ "devDependencies": { "@libp2p/crypto": "^5.0.0", "@libp2p/interface-compliance-tests": "^6.0.0", + "@libp2p/peer-id": "^5.0.0", "@types/sinon": "^17.0.3", "aegir": "^44.0.1", "blockstore-core": "^5.0.0", diff --git a/packages/block-brokers/package.json b/packages/block-brokers/package.json index f6b187861..a1b4c0aa6 100644 --- a/packages/block-brokers/package.json +++ b/packages/block-brokers/package.json @@ -67,7 +67,9 @@ "progress-events": "^1.0.0" }, "devDependencies": { + "@libp2p/crypto": "^5.0.0", "@libp2p/logger": "^5.0.0", + "@libp2p/peer-id": "^5.0.0", "@multiformats/uri-to-multiaddr": "^8.0.0", "@types/polka": "^0.5.7", "@types/sinon": "^17.0.3", diff --git a/packages/helia/package.json b/packages/helia/package.json index c548f1d52..e8f5de57f 100644 --- a/packages/helia/package.json +++ b/packages/helia/package.json @@ -64,6 +64,7 @@ "@libp2p/autonat": "^2.0.0", "@libp2p/bootstrap": "^11.0.0", "@libp2p/circuit-relay-v2": "^2.0.0", + "@libp2p/crypto": "^5.0.0", "@libp2p/dcutr": "^2.0.0", "@libp2p/identify": "^3.0.0", "@libp2p/interface": "^2.0.0", diff --git a/packages/interop/package.json b/packages/interop/package.json index 9b31255e3..bb898f028 100644 --- a/packages/interop/package.json +++ b/packages/interop/package.json @@ -69,9 +69,11 @@ "@helia/mfs": "^3.0.8", "@helia/routers": "^1.1.1", "@helia/strings": "^3.0.6", + "@helia/utils": "^0.3.3", "@helia/unixfs": "^3.0.7", "@ipld/car": "^5.3.0", "@ipld/dag-cbor": "^9.2.0", + "@libp2p/crypto": "^5.0.0", "@libp2p/interface": "^2.0.0", "@libp2p/kad-dht": "^13.0.0", "@libp2p/keychain": "^5.0.2", @@ -82,6 +84,7 @@ "helia": "^4.2.6", "ipfs-unixfs-importer": "^15.2.4", "ipfsd-ctl": "^15.0.0", + "ipns": "^10.0.0", "it-all": "^3.0.4", "it-drain": "^3.0.5", "it-last": "^3.0.4", diff --git a/packages/ipns/package.json b/packages/ipns/package.json index dc3417b0f..8a9dff1cc 100644 --- a/packages/ipns/package.json +++ b/packages/ipns/package.json @@ -177,6 +177,7 @@ "uint8arrays": "^5.0.2" }, "devDependencies": { + "@libp2p/crypto": "^5.0.0", "@types/dns-packet": "^5.6.5", "aegir": "^44.0.1", "datastore-core": "^10.0.0", diff --git a/packages/routers/package.json b/packages/routers/package.json index 05b54aa9f..72ff524bd 100644 --- a/packages/routers/package.json +++ b/packages/routers/package.json @@ -55,6 +55,7 @@ "dependencies": { "@helia/delegated-routing-v1-http-api-client": "^3.0.0", "@helia/interface": "^4.3.1", + "@libp2p/peer-id": "^5.0.0", "@libp2p/interface": "^2.0.0", "@multiformats/uri-to-multiaddr": "^8.0.0", "ipns": "^10.0.0", @@ -64,7 +65,7 @@ "uint8arrays": "^5.0.2" }, "devDependencies": { - "@libp2p/peer-id": "^5.0.0", + "@libp2p/crypto": "^5.0.0", "aegir": "^44.0.1", "it-all": "^3.0.4", "it-drain": "^3.0.5", diff --git a/packages/utils/package.json b/packages/utils/package.json index 0d25bccbb..eafdd9b62 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -82,6 +82,7 @@ "uint8arrays": "^5.0.2" }, "devDependencies": { + "@libp2p/peer-id": "^5.0.0", "@types/sinon": "^17.0.3", "aegir": "^44.0.1", "datastore-core": "^10.0.0",