From 60165d4d1ff80341b6f28907501a8e2eb7874dd0 Mon Sep 17 00:00:00 2001 From: chad Date: Thu, 2 Nov 2023 22:45:36 -0500 Subject: [PATCH] refactor!: move fetch into seperate package (#1913) --- doc/migrations/v0.46-v1.0.0.md | 17 +++++ packages/interface/src/errors.ts | 3 + packages/libp2p/src/errors.ts | 68 ------------------ .../configuration/protocol-prefix.node.ts | 2 +- packages/libp2p/tsconfig.json | 2 +- packages/protocol-autonat/package.json | 5 +- packages/protocol-fetch/LICENSE | 4 ++ packages/protocol-fetch/LICENSE-APACHE | 5 ++ packages/protocol-fetch/LICENSE-MIT | 19 +++++ .../src/fetch => protocol-fetch}/README.md | 2 +- packages/protocol-fetch/package.json | 72 +++++++++++++++++++ .../fetch => protocol-fetch/src}/constants.ts | 0 .../src/fetch => protocol-fetch/src}/index.ts | 13 ++-- .../src}/pb/proto.proto | 0 .../fetch => protocol-fetch/src}/pb/proto.ts | 0 .../test}/fetch.node.ts | 19 +++-- .../test}/index.spec.ts | 4 +- packages/protocol-fetch/tsconfig.json | 10 +++ packages/protocol-fetch/typedoc.json | 5 ++ 19 files changed, 155 insertions(+), 95 deletions(-) create mode 100644 packages/protocol-fetch/LICENSE create mode 100644 packages/protocol-fetch/LICENSE-APACHE create mode 100644 packages/protocol-fetch/LICENSE-MIT rename packages/{libp2p/src/fetch => protocol-fetch}/README.md (98%) create mode 100644 packages/protocol-fetch/package.json rename packages/{libp2p/src/fetch => protocol-fetch/src}/constants.ts (100%) rename packages/{libp2p/src/fetch => protocol-fetch/src}/index.ts (95%) rename packages/{libp2p/src/fetch => protocol-fetch/src}/pb/proto.proto (100%) rename packages/{libp2p/src/fetch => protocol-fetch/src}/pb/proto.ts (100%) rename packages/{libp2p/test/fetch => protocol-fetch/test}/fetch.node.ts (93%) rename packages/{libp2p/test/fetch => protocol-fetch/test}/index.spec.ts (95%) create mode 100644 packages/protocol-fetch/tsconfig.json create mode 100644 packages/protocol-fetch/typedoc.json diff --git a/doc/migrations/v0.46-v1.0.0.md b/doc/migrations/v0.46-v1.0.0.md index e6b04bddee..13ee735733 100644 --- a/doc/migrations/v0.46-v1.0.0.md +++ b/doc/migrations/v0.46-v1.0.0.md @@ -6,6 +6,7 @@ A migration guide for refactoring your application code from libp2p `v0.46` to ` ## Table of Contents - [AutoNAT](#autonat) +- [Fetch](#fetch) - [KeyChain](#keychain) - [Pnet](#pnet) - [Metrics](#metrics) @@ -26,6 +27,22 @@ import { autoNATService } from 'libp2p/autonat' import { autoNATService } from '@libp2p/autonat' ``` +## Fetch + +The Fetch service is now publisehd as it's own package. + +**Before** + +```ts +import { autoNATService } from 'libp2p/fetch' +``` + +**After** + +```ts +import { autoNATService } from '@libp2p/fetch' +``` + ## KeyChain The KeyChain object is no longer included on Libp2p and must be instantiated explicitly if desired. diff --git a/packages/interface/src/errors.ts b/packages/interface/src/errors.ts index 4f5f8b4c3a..b7fb770c07 100644 --- a/packages/interface/src/errors.ts +++ b/packages/interface/src/errors.ts @@ -69,3 +69,6 @@ export class InvalidCryptoTransmissionError extends Error { // Error codes export const ERR_TIMEOUT = 'ERR_TIMEOUT' +export const ERR_INVALID_MESSAGE = 'ERR_INVALID_MESSAGE' +export const ERR_INVALID_PARAMETERS = 'ERR_INVALID_PARAMETERS' +export const ERR_KEY_ALREADY_EXISTS = 'ERR_KEY_ALREADY_EXISTS' diff --git a/packages/libp2p/src/errors.ts b/packages/libp2p/src/errors.ts index 0b84215aa9..ef1fc8196b 100644 --- a/packages/libp2p/src/errors.ts +++ b/packages/libp2p/src/errors.ts @@ -7,71 +7,3 @@ export enum messages { ERR_PROTECTOR_REQUIRED = 'Private network is enforced, but no protector was provided', NOT_FOUND = 'Not found' } - -export enum codes { - DHT_DISABLED = 'ERR_DHT_DISABLED', - ERR_PUBSUB_DISABLED = 'ERR_PUBSUB_DISABLED', - PUBSUB_NOT_STARTED = 'ERR_PUBSUB_NOT_STARTED', - DHT_NOT_STARTED = 'ERR_DHT_NOT_STARTED', - CONN_ENCRYPTION_REQUIRED = 'ERR_CONN_ENCRYPTION_REQUIRED', - ERR_TRANSPORTS_REQUIRED = 'ERR_TRANSPORTS_REQUIRED', - ERR_PROTECTOR_REQUIRED = 'ERR_PROTECTOR_REQUIRED', - ERR_PEER_DIAL_INTERCEPTED = 'ERR_PEER_DIAL_INTERCEPTED', - ERR_CONNECTION_INTERCEPTED = 'ERR_CONNECTION_INTERCEPTED', - ERR_INVALID_PROTOCOLS_FOR_STREAM = 'ERR_INVALID_PROTOCOLS_FOR_STREAM', - ERR_CONNECTION_ENDED = 'ERR_CONNECTION_ENDED', - ERR_CONNECTION_FAILED = 'ERR_CONNECTION_FAILED', - ERR_NODE_NOT_STARTED = 'ERR_NODE_NOT_STARTED', - ERR_ALREADY_ABORTED = 'ERR_ALREADY_ABORTED', - ERR_TOO_MANY_ADDRESSES = 'ERR_TOO_MANY_ADDRESSES', - ERR_NO_VALID_ADDRESSES = 'ERR_NO_VALID_ADDRESSES', - ERR_RELAYED_DIAL = 'ERR_RELAYED_DIAL', - ERR_DIALED_SELF = 'ERR_DIALED_SELF', - ERR_DISCOVERED_SELF = 'ERR_DISCOVERED_SELF', - ERR_DUPLICATE_TRANSPORT = 'ERR_DUPLICATE_TRANSPORT', - ERR_ENCRYPTION_FAILED = 'ERR_ENCRYPTION_FAILED', - ERR_HOP_REQUEST_FAILED = 'ERR_HOP_REQUEST_FAILED', - ERR_INVALID_KEY = 'ERR_INVALID_KEY', - ERR_INVALID_MESSAGE = 'ERR_INVALID_MESSAGE', - ERR_INVALID_PARAMETERS = 'ERR_INVALID_PARAMETERS', - ERR_INVALID_PEER = 'ERR_INVALID_PEER', - ERR_MUXER_UNAVAILABLE = 'ERR_MUXER_UNAVAILABLE', - ERR_NOT_FOUND = 'ERR_NOT_FOUND', - ERR_TRANSPORT_UNAVAILABLE = 'ERR_TRANSPORT_UNAVAILABLE', - ERR_TRANSPORT_DIAL_FAILED = 'ERR_TRANSPORT_DIAL_FAILED', - ERR_UNSUPPORTED_PROTOCOL = 'ERR_UNSUPPORTED_PROTOCOL', - ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED = 'ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED', - ERR_INVALID_MULTIADDR = 'ERR_INVALID_MULTIADDR', - ERR_SIGNATURE_NOT_VALID = 'ERR_SIGNATURE_NOT_VALID', - ERR_FIND_SELF = 'ERR_FIND_SELF', - ERR_NO_ROUTERS_AVAILABLE = 'ERR_NO_ROUTERS_AVAILABLE', - ERR_CONNECTION_NOT_MULTIPLEXED = 'ERR_CONNECTION_NOT_MULTIPLEXED', - ERR_NO_DIAL_TOKENS = 'ERR_NO_DIAL_TOKENS', - ERR_INVALID_CMS = 'ERR_INVALID_CMS', - ERR_MISSING_KEYS = 'ERR_MISSING_KEYS', - ERR_NO_KEY = 'ERR_NO_KEY', - ERR_INVALID_KEY_NAME = 'ERR_INVALID_KEY_NAME', - ERR_INVALID_KEY_TYPE = 'ERR_INVALID_KEY_TYPE', - ERR_KEY_ALREADY_EXISTS = 'ERR_KEY_ALREADY_EXISTS', - ERR_INVALID_KEY_SIZE = 'ERR_INVALID_KEY_SIZE', - ERR_KEY_NOT_FOUND = 'ERR_KEY_NOT_FOUND', - ERR_OLD_KEY_NAME_INVALID = 'ERR_OLD_KEY_NAME_INVALID', - ERR_NEW_KEY_NAME_INVALID = 'ERR_NEW_KEY_NAME_INVALID', - ERR_PASSWORD_REQUIRED = 'ERR_PASSWORD_REQUIRED', - ERR_PEM_REQUIRED = 'ERR_PEM_REQUIRED', - ERR_CANNOT_READ_KEY = 'ERR_CANNOT_READ_KEY', - ERR_MISSING_PRIVATE_KEY = 'ERR_MISSING_PRIVATE_KEY', - ERR_MISSING_PUBLIC_KEY = 'ERR_MISSING_PUBLIC_KEY', - ERR_INVALID_OLD_PASS_TYPE = 'ERR_INVALID_OLD_PASS_TYPE', - ERR_INVALID_NEW_PASS_TYPE = 'ERR_INVALID_NEW_PASS_TYPE', - ERR_INVALID_PASS_LENGTH = 'ERR_INVALID_PASS_LENGTH', - ERR_NOT_IMPLEMENTED = 'ERR_NOT_IMPLEMENTED', - ERR_WRONG_PING_ACK = 'ERR_WRONG_PING_ACK', - ERR_INVALID_RECORD = 'ERR_INVALID_RECORD', - ERR_ALREADY_SUCCEEDED = 'ERR_ALREADY_SUCCEEDED', - ERR_NO_HANDLER_FOR_PROTOCOL = 'ERR_NO_HANDLER_FOR_PROTOCOL', - ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS = 'ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS', - ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS = 'ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS', - ERR_CONNECTION_DENIED = 'ERR_CONNECTION_DENIED', - ERR_TRANSFER_LIMIT_EXCEEDED = 'ERR_TRANSFER_LIMIT_EXCEEDED' -} diff --git a/packages/libp2p/test/configuration/protocol-prefix.node.ts b/packages/libp2p/test/configuration/protocol-prefix.node.ts index db4ecea61c..fd6fb53d56 100644 --- a/packages/libp2p/test/configuration/protocol-prefix.node.ts +++ b/packages/libp2p/test/configuration/protocol-prefix.node.ts @@ -1,8 +1,8 @@ /* eslint-env mocha */ +import { type FetchService, fetchService } from '@libp2p/fetch' import { expect } from 'aegir/chai' import { pEvent } from 'p-event' -import { type FetchService, fetchService } from '../../src/fetch/index.js' import { identifyService } from '../../src/identify/index.js' import { createLibp2p } from '../../src/index.js' import { type PingService, pingService } from '../../src/ping/index.js' diff --git a/packages/libp2p/tsconfig.json b/packages/libp2p/tsconfig.json index e52e22da16..4b261417f0 100644 --- a/packages/libp2p/tsconfig.json +++ b/packages/libp2p/tsconfig.json @@ -6,7 +6,7 @@ "include": [ "src", "test" - ], +, "../protocol-fetch/test/fetch.node.ts", "../protocol-fetch/test/index.spec.ts" ], "references": [ { "path": "../crypto" diff --git a/packages/protocol-autonat/package.json b/packages/protocol-autonat/package.json index 0648c94c11..a7bfd0ab08 100644 --- a/packages/protocol-autonat/package.json +++ b/packages/protocol-autonat/package.json @@ -32,7 +32,6 @@ } }, "scripts": { - "start": "node dist/src/main.js", "build": "aegir build", "test": "aegir test", "clean": "aegir clean", @@ -48,8 +47,8 @@ "dependencies": { "@libp2p/interface": "^0.1.2", "@libp2p/interface-internal": "^0.1.5", - "@libp2p/peer-id": "^3.0.2" , - "@libp2p/peer-id-factory": "^3.0.4" , + "@libp2p/peer-id": "^3.0.2", + "@libp2p/peer-id-factory": "^3.0.4", "@libp2p/logger": "^3.0.2", "@multiformats/multiaddr": "^12.1.5", "it-first": "^3.0.1", diff --git a/packages/protocol-fetch/LICENSE b/packages/protocol-fetch/LICENSE new file mode 100644 index 0000000000..20ce483c86 --- /dev/null +++ b/packages/protocol-fetch/LICENSE @@ -0,0 +1,4 @@ +This project is dual licensed under MIT and Apache-2.0. + +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 diff --git a/packages/protocol-fetch/LICENSE-APACHE b/packages/protocol-fetch/LICENSE-APACHE new file mode 100644 index 0000000000..14478a3b60 --- /dev/null +++ b/packages/protocol-fetch/LICENSE-APACHE @@ -0,0 +1,5 @@ +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/packages/protocol-fetch/LICENSE-MIT b/packages/protocol-fetch/LICENSE-MIT new file mode 100644 index 0000000000..72dc60d84b --- /dev/null +++ b/packages/protocol-fetch/LICENSE-MIT @@ -0,0 +1,19 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/packages/libp2p/src/fetch/README.md b/packages/protocol-fetch/README.md similarity index 98% rename from packages/libp2p/src/fetch/README.md rename to packages/protocol-fetch/README.md index 8d231d2e83..fb38d2f9de 100644 --- a/packages/libp2p/src/fetch/README.md +++ b/packages/protocol-fetch/README.md @@ -16,7 +16,7 @@ The fetch protocol is a simple protocol for requesting a value corresponding to ## Usage -```javascript +```ts import { createLibp2p } from 'libp2p' /** diff --git a/packages/protocol-fetch/package.json b/packages/protocol-fetch/package.json new file mode 100644 index 0000000000..049a8064ac --- /dev/null +++ b/packages/protocol-fetch/package.json @@ -0,0 +1,72 @@ +{ + "name": "@libp2p/fetch", + "version": "1.0.0", + "description": "Implementation of the Fetch Protocol", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/libp2p/js-libp2p/tree/master/packages/protocol-fetch#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/libp2p/js-libp2p.git" + }, + "bugs": { + "url": "https://github.com/libp2p/js-libp2p/issues" + }, + "type": "module", + "types": "./dist/src/index.d.ts", + "files": [ + "src", + "dist", + "!dist/test", + "!**/*.tsbuildinfo" + ], + "exports": { + ".": { + "types": "./dist/src/index.d.ts", + "import": "./dist/src/index.js" + } + }, + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } + }, + "scripts": { + "build": "aegir build", + "test": "aegir test", + "clean": "aegir clean", + "generate": "protons ./src/pb/index.proto", + "lint": "aegir lint", + "test:chrome": "aegir test -t browser --cov", + "test:chrome-webworker": "aegir test -t webworker", + "test:firefox": "aegir test -t browser -- --browser firefox", + "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", + "test:node": "aegir test -t node --cov", + "dep-check": "aegir dep-check" + }, + "dependencies": { + "@libp2p/interface": "^0.1.4", + "@libp2p/interface-internal": "^0.1.7", + "@libp2p/logger": "^3.0.4", + "it-first": "^3.0.3", + "it-length-prefixed": "^9.0.3", + "it-pipe": "^3.0.1", + "protons-runtime": "^5.2.0", + "uint8arraylist": "^2.4.3", + "uint8arrays": "^4.0.6" + }, + "devDependencies": { + "@chainsafe/libp2p-noise": "^13.0.2", + "@chainsafe/libp2p-yamux": "^5.0.0", + "@libp2p/interface-compliance-tests": "^4.1.2", + "@libp2p/peer-id-factory": "^3.0.6", + "@libp2p/peer-store": "^9.0.7", + "@libp2p/tcp": "^8.0.10", + "aegir": "^40.0.8", + "datastore-core": "^9.2.3", + "delay": "^6.0.0", + "libp2p": "^0.46.16", + "sinon": "^17.0.1", + "sinon-ts": "^2.0.0" + } +} diff --git a/packages/libp2p/src/fetch/constants.ts b/packages/protocol-fetch/src/constants.ts similarity index 100% rename from packages/libp2p/src/fetch/constants.ts rename to packages/protocol-fetch/src/constants.ts diff --git a/packages/libp2p/src/fetch/index.ts b/packages/protocol-fetch/src/index.ts similarity index 95% rename from packages/libp2p/src/fetch/index.ts rename to packages/protocol-fetch/src/index.ts index b9fad11e92..fe88e0874a 100644 --- a/packages/libp2p/src/fetch/index.ts +++ b/packages/protocol-fetch/src/index.ts @@ -1,12 +1,11 @@ -import { CodeError, ERR_TIMEOUT } from '@libp2p/interface/errors' import { setMaxListeners } from '@libp2p/interface/events' +import { CodeError, ERR_TIMEOUT, ERR_INVALID_MESSAGE, ERR_INVALID_PARAMETERS, ERR_KEY_ALREADY_EXISTS } from '@libp2p/interface/errors' import { logger } from '@libp2p/logger' import first from 'it-first' import * as lp from 'it-length-prefixed' import { pipe } from 'it-pipe' import { fromString as uint8arrayFromString } from 'uint8arrays/from-string' import { toString as uint8arrayToString } from 'uint8arrays/to-string' -import { codes } from '../errors.js' import { PROTOCOL_NAME, PROTOCOL_VERSION } from './constants.js' import { FetchRequest, FetchResponse } from './pb/proto.js' import type { AbortOptions } from '@libp2p/interface' @@ -172,7 +171,7 @@ class DefaultFetchService implements Startable, FetchService { const buf = await first(source) if (buf == null) { - throw new CodeError('No data received', codes.ERR_INVALID_MESSAGE) + throw new CodeError('No data received', ERR_INVALID_MESSAGE) } const response = FetchResponse.decode(buf) @@ -189,11 +188,11 @@ class DefaultFetchService implements Startable, FetchService { case (FetchResponse.StatusCode.ERROR): { log('received status for %s error', key) const errmsg = uint8arrayToString(response.data) - throw new CodeError('Error in fetch protocol response: ' + errmsg, codes.ERR_INVALID_PARAMETERS) + throw new CodeError('Error in fetch protocol response: ' + errmsg, ERR_INVALID_PARAMETERS) } default: { log('received status for %s unknown', key) - throw new CodeError('Unknown response status', codes.ERR_INVALID_MESSAGE) + throw new CodeError('Unknown response status', ERR_INVALID_MESSAGE) } } } @@ -224,7 +223,7 @@ class DefaultFetchService implements Startable, FetchService { const buf = await first(source) if (buf == null) { - throw new CodeError('No data received', codes.ERR_INVALID_MESSAGE) + throw new CodeError('No data received', ERR_INVALID_MESSAGE) } // for await (const buf of source) { @@ -280,7 +279,7 @@ class DefaultFetchService implements Startable, FetchService { */ registerLookupFunction (prefix: string, lookup: LookupFunction): void { if (this.lookupFunctions.has(prefix)) { - throw new CodeError(`Fetch protocol handler for key prefix '${prefix}' already registered`, codes.ERR_KEY_ALREADY_EXISTS) + throw new CodeError(`Fetch protocol handler for key prefix '${prefix}' already registered`, ERR_KEY_ALREADY_EXISTS) } this.lookupFunctions.set(prefix, lookup) diff --git a/packages/libp2p/src/fetch/pb/proto.proto b/packages/protocol-fetch/src/pb/proto.proto similarity index 100% rename from packages/libp2p/src/fetch/pb/proto.proto rename to packages/protocol-fetch/src/pb/proto.proto diff --git a/packages/libp2p/src/fetch/pb/proto.ts b/packages/protocol-fetch/src/pb/proto.ts similarity index 100% rename from packages/libp2p/src/fetch/pb/proto.ts rename to packages/protocol-fetch/src/pb/proto.ts diff --git a/packages/libp2p/test/fetch/fetch.node.ts b/packages/protocol-fetch/test/fetch.node.ts similarity index 93% rename from packages/libp2p/test/fetch/fetch.node.ts rename to packages/protocol-fetch/test/fetch.node.ts index 53420c9a45..247e0b1b78 100644 --- a/packages/libp2p/test/fetch/fetch.node.ts +++ b/packages/protocol-fetch/test/fetch.node.ts @@ -1,16 +1,14 @@ /* eslint-env mocha */ import { yamux } from '@chainsafe/libp2p-yamux' -import { mplex } from '@libp2p/mplex' +import { type FetchService, fetchService } from '../src/index.js' import { tcp } from '@libp2p/tcp' import { expect } from 'aegir/chai' -import { codes } from '../../src/errors.js' -import { type FetchService, fetchService } from '../../src/fetch/index.js' -import { createLibp2p } from '../../src/index.js' -import { plaintext } from '../../src/insecure/index.js' -import { createPeerId } from '../fixtures/creators/peer.js' import type { Libp2p } from '@libp2p/interface' import type { PeerId } from '@libp2p/interface/peer-id' +import { createLibp2p } from 'libp2p' +import { noise } from '@chainsafe/libp2p-noise' +import { createEd25519PeerId } from '@libp2p/peer-id-factory' async function createNode (peerId: PeerId): Promise> { return createLibp2p({ @@ -24,11 +22,10 @@ async function createNode (peerId: PeerId): Promise { } beforeEach(async () => { - const peerIdA = await createPeerId() - const peerIdB = await createPeerId() + const peerIdA = await createEd25519PeerId() + const peerIdB = await createEd25519PeerId() sender = await createNode(peerIdA) receiver = await createNode(peerIdB) diff --git a/packages/libp2p/test/fetch/index.spec.ts b/packages/protocol-fetch/test/index.spec.ts similarity index 95% rename from packages/libp2p/test/fetch/index.spec.ts rename to packages/protocol-fetch/test/index.spec.ts index dd7d1d921a..fbd03acae8 100644 --- a/packages/libp2p/test/fetch/index.spec.ts +++ b/packages/protocol-fetch/test/index.spec.ts @@ -1,5 +1,6 @@ /* eslint-env mocha */ +import { fetchService, type FetchServiceInit } from '../src/index.js' import { ERR_TIMEOUT } from '@libp2p/interface/errors' import { TypedEventEmitter } from '@libp2p/interface/events' import { start, stop } from '@libp2p/interface/startable' @@ -12,9 +13,6 @@ import delay from 'delay' import { pipe } from 'it-pipe' import sinon from 'sinon' import { stubInterface } from 'sinon-ts' -import { defaultComponents, type Components } from '../../src/components.js' -import { DefaultConnectionManager } from '../../src/connection-manager/index.js' -import { fetchService, type FetchServiceInit } from '../../src/fetch/index.js' import type { ConnectionGater } from '@libp2p/interface/connection-gater' import type { TransportManager } from '@libp2p/interface-internal/transport-manager' diff --git a/packages/protocol-fetch/tsconfig.json b/packages/protocol-fetch/tsconfig.json new file mode 100644 index 0000000000..13a3599639 --- /dev/null +++ b/packages/protocol-fetch/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "aegir/src/config/tsconfig.aegir.json", + "compilerOptions": { + "outDir": "dist" + }, + "include": [ + "src", + "test" + ] +} diff --git a/packages/protocol-fetch/typedoc.json b/packages/protocol-fetch/typedoc.json new file mode 100644 index 0000000000..f599dc728d --- /dev/null +++ b/packages/protocol-fetch/typedoc.json @@ -0,0 +1,5 @@ +{ + "entryPoints": [ + "./src/index.ts" + ] +}