From fe9024efe2b37a9395b33993417fc9472ad96f84 Mon Sep 17 00:00:00 2001 From: Daniel N <2color@users.noreply.github.com> Date: Wed, 30 Oct 2024 14:15:58 +0100 Subject: [PATCH 1/5] fix: add tls to all default filters --- packages/helia/src/utils/libp2p-defaults.browser.ts | 2 +- packages/helia/src/utils/libp2p-defaults.ts | 2 +- .../src/utils/delegated-http-routing-defaults.browser.ts | 2 +- packages/routers/src/utils/delegated-http-routing-defaults.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/helia/src/utils/libp2p-defaults.browser.ts b/packages/helia/src/utils/libp2p-defaults.browser.ts index 7bd756fd..9e3696aa 100644 --- a/packages/helia/src/utils/libp2p-defaults.browser.ts +++ b/packages/helia/src/utils/libp2p-defaults.browser.ts @@ -65,7 +65,7 @@ export function libp2pDefaults (options: Libp2pDefaultsOptions = {}): Libp2pOpti dcutr: dcutr(), delegatedRouting: () => createDelegatedRoutingV1HttpApiClient('https://delegated-ipfs.dev', { filterProtocols: ['unknown', 'transport-bitswap', 'transport-ipfs-gateway-http'], - filterAddrs: ['https', 'webtransport', 'webrtc', 'webrtc-direct', 'wss'] + filterAddrs: ['https', 'webtransport', 'webrtc', 'webrtc-direct', 'wss', 'tls'] }), dht: kadDHT({ clientMode: true, diff --git a/packages/helia/src/utils/libp2p-defaults.ts b/packages/helia/src/utils/libp2p-defaults.ts index 547a8bae..e02ce449 100644 --- a/packages/helia/src/utils/libp2p-defaults.ts +++ b/packages/helia/src/utils/libp2p-defaults.ts @@ -74,7 +74,7 @@ export function libp2pDefaults (options: Libp2pDefaultsOptions = {}): Libp2pOpti dcutr: dcutr(), delegatedRouting: () => createDelegatedRoutingV1HttpApiClient('https://delegated-ipfs.dev', { filterProtocols: ['unknown', 'transport-bitswap', 'transport-ipfs-gateway-http'], - filterAddrs: ['https', 'tcp', 'webrtc', 'webrtc-direct', 'wss'] + filterAddrs: ['https', 'tcp', 'webrtc', 'webrtc-direct', 'wss', 'tls'] }), dht: kadDHT({ validators: { diff --git a/packages/routers/src/utils/delegated-http-routing-defaults.browser.ts b/packages/routers/src/utils/delegated-http-routing-defaults.browser.ts index eaed6bff..afe4a7fb 100644 --- a/packages/routers/src/utils/delegated-http-routing-defaults.browser.ts +++ b/packages/routers/src/utils/delegated-http-routing-defaults.browser.ts @@ -3,6 +3,6 @@ import type { DelegatedRoutingV1HttpApiClientInit } from '@helia/delegated-routi export function delegatedHTTPRoutingDefaults (): DelegatedRoutingV1HttpApiClientInit { return { filterProtocols: ['unknown', 'transport-bitswap', 'transport-ipfs-gateway-http'], - filterAddrs: ['https', 'webtransport', 'webrtc', 'webrtc-direct', 'wss'] + filterAddrs: ['https', 'webtransport', 'webrtc', 'webrtc-direct', 'wss', 'tls'] } } diff --git a/packages/routers/src/utils/delegated-http-routing-defaults.ts b/packages/routers/src/utils/delegated-http-routing-defaults.ts index 740346b2..e5966dd7 100644 --- a/packages/routers/src/utils/delegated-http-routing-defaults.ts +++ b/packages/routers/src/utils/delegated-http-routing-defaults.ts @@ -3,6 +3,6 @@ import type { DelegatedRoutingV1HttpApiClientInit } from '@helia/delegated-routi export function delegatedHTTPRoutingDefaults (): DelegatedRoutingV1HttpApiClientInit { return { filterProtocols: ['unknown', 'transport-bitswap', 'transport-ipfs-gateway-http'], - filterAddrs: ['https', 'tcp', 'webrtc', 'webrtc-direct', 'wss'] + filterAddrs: ['https', 'tcp', 'webrtc', 'webrtc-direct', 'wss', 'tls'] } } From 2c071080d1790ec8e24fa25773a46987a381dc98 Mon Sep 17 00:00:00 2001 From: Daniel N <2color@users.noreply.github.com> Date: Wed, 30 Oct 2024 14:17:29 +0100 Subject: [PATCH 2/5] chore: avoid duplication of filters --- packages/helia/src/utils/libp2p-defaults.browser.ts | 6 ++---- packages/helia/src/utils/libp2p-defaults.ts | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/packages/helia/src/utils/libp2p-defaults.browser.ts b/packages/helia/src/utils/libp2p-defaults.browser.ts index 9e3696aa..b48ab288 100644 --- a/packages/helia/src/utils/libp2p-defaults.browser.ts +++ b/packages/helia/src/utils/libp2p-defaults.browser.ts @@ -1,6 +1,7 @@ import { noise } from '@chainsafe/libp2p-noise' import { yamux } from '@chainsafe/libp2p-yamux' import { createDelegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client' +import { delegatedHTTPRoutingDefaults } from '@helia/routers/src/utils/delegated-http-routing-defaults.js' import { autoNAT } from '@libp2p/autonat' import { bootstrap } from '@libp2p/bootstrap' import { circuitRelayTransport } from '@libp2p/circuit-relay-v2' @@ -63,10 +64,7 @@ export function libp2pDefaults (options: Libp2pDefaultsOptions = {}): Libp2pOpti services: { autoNAT: autoNAT(), dcutr: dcutr(), - delegatedRouting: () => createDelegatedRoutingV1HttpApiClient('https://delegated-ipfs.dev', { - filterProtocols: ['unknown', 'transport-bitswap', 'transport-ipfs-gateway-http'], - filterAddrs: ['https', 'webtransport', 'webrtc', 'webrtc-direct', 'wss', 'tls'] - }), + delegatedRouting: () => createDelegatedRoutingV1HttpApiClient('https://delegated-ipfs.dev', delegatedHTTPRoutingDefaults()), dht: kadDHT({ clientMode: true, validators: { diff --git a/packages/helia/src/utils/libp2p-defaults.ts b/packages/helia/src/utils/libp2p-defaults.ts index e02ce449..2dd466c1 100644 --- a/packages/helia/src/utils/libp2p-defaults.ts +++ b/packages/helia/src/utils/libp2p-defaults.ts @@ -1,6 +1,7 @@ import { noise } from '@chainsafe/libp2p-noise' import { yamux } from '@chainsafe/libp2p-yamux' import { createDelegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client' +import { delegatedHTTPRoutingDefaults } from '@helia/routers/src/utils/delegated-http-routing-defaults.js' import { autoNAT } from '@libp2p/autonat' import { bootstrap } from '@libp2p/bootstrap' import { circuitRelayTransport, circuitRelayServer, type CircuitRelayService } from '@libp2p/circuit-relay-v2' @@ -72,10 +73,7 @@ export function libp2pDefaults (options: Libp2pDefaultsOptions = {}): Libp2pOpti services: { autoNAT: autoNAT(), dcutr: dcutr(), - delegatedRouting: () => createDelegatedRoutingV1HttpApiClient('https://delegated-ipfs.dev', { - filterProtocols: ['unknown', 'transport-bitswap', 'transport-ipfs-gateway-http'], - filterAddrs: ['https', 'tcp', 'webrtc', 'webrtc-direct', 'wss', 'tls'] - }), + delegatedRouting: () => createDelegatedRoutingV1HttpApiClient('https://delegated-ipfs.dev', delegatedHTTPRoutingDefaults()), dht: kadDHT({ validators: { ipns: ipnsValidator From bce39edc931591213017dd9446d540466280439a Mon Sep 17 00:00:00 2001 From: Daniel N <2color@users.noreply.github.com> Date: Wed, 30 Oct 2024 14:18:43 +0100 Subject: [PATCH 3/5] fix: use normal imports with .js --- packages/helia/src/utils/libp2p-defaults.browser.ts | 2 +- packages/helia/src/utils/libp2p-defaults.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/helia/src/utils/libp2p-defaults.browser.ts b/packages/helia/src/utils/libp2p-defaults.browser.ts index b48ab288..53f973e0 100644 --- a/packages/helia/src/utils/libp2p-defaults.browser.ts +++ b/packages/helia/src/utils/libp2p-defaults.browser.ts @@ -1,7 +1,7 @@ import { noise } from '@chainsafe/libp2p-noise' import { yamux } from '@chainsafe/libp2p-yamux' import { createDelegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client' -import { delegatedHTTPRoutingDefaults } from '@helia/routers/src/utils/delegated-http-routing-defaults.js' +import { delegatedHTTPRoutingDefaults } from '@helia/routers/src/utils/delegated-http-routing-defaults' import { autoNAT } from '@libp2p/autonat' import { bootstrap } from '@libp2p/bootstrap' import { circuitRelayTransport } from '@libp2p/circuit-relay-v2' diff --git a/packages/helia/src/utils/libp2p-defaults.ts b/packages/helia/src/utils/libp2p-defaults.ts index 2dd466c1..26454b8e 100644 --- a/packages/helia/src/utils/libp2p-defaults.ts +++ b/packages/helia/src/utils/libp2p-defaults.ts @@ -1,7 +1,7 @@ import { noise } from '@chainsafe/libp2p-noise' import { yamux } from '@chainsafe/libp2p-yamux' import { createDelegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client' -import { delegatedHTTPRoutingDefaults } from '@helia/routers/src/utils/delegated-http-routing-defaults.js' +import { delegatedHTTPRoutingDefaults } from '@helia/routers/src/utils/delegated-http-routing-defaults' import { autoNAT } from '@libp2p/autonat' import { bootstrap } from '@libp2p/bootstrap' import { circuitRelayTransport, circuitRelayServer, type CircuitRelayService } from '@libp2p/circuit-relay-v2' From 3f8558a87735c74a2b4907c9b7de83b5fa6dd5c6 Mon Sep 17 00:00:00 2001 From: Daniel N <2color@users.noreply.github.com> Date: Wed, 30 Oct 2024 14:54:57 +0100 Subject: [PATCH 4/5] chore: export delegated routing defaults --- packages/helia/src/utils/libp2p-defaults.browser.ts | 2 +- packages/helia/src/utils/libp2p-defaults.ts | 2 +- packages/routers/src/index.ts | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/helia/src/utils/libp2p-defaults.browser.ts b/packages/helia/src/utils/libp2p-defaults.browser.ts index 53f973e0..1de3ce90 100644 --- a/packages/helia/src/utils/libp2p-defaults.browser.ts +++ b/packages/helia/src/utils/libp2p-defaults.browser.ts @@ -1,7 +1,7 @@ import { noise } from '@chainsafe/libp2p-noise' import { yamux } from '@chainsafe/libp2p-yamux' import { createDelegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client' -import { delegatedHTTPRoutingDefaults } from '@helia/routers/src/utils/delegated-http-routing-defaults' +import { delegatedHTTPRoutingDefaults } from '@helia/routers' import { autoNAT } from '@libp2p/autonat' import { bootstrap } from '@libp2p/bootstrap' import { circuitRelayTransport } from '@libp2p/circuit-relay-v2' diff --git a/packages/helia/src/utils/libp2p-defaults.ts b/packages/helia/src/utils/libp2p-defaults.ts index 26454b8e..41eaffc0 100644 --- a/packages/helia/src/utils/libp2p-defaults.ts +++ b/packages/helia/src/utils/libp2p-defaults.ts @@ -1,7 +1,7 @@ import { noise } from '@chainsafe/libp2p-noise' import { yamux } from '@chainsafe/libp2p-yamux' import { createDelegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client' -import { delegatedHTTPRoutingDefaults } from '@helia/routers/src/utils/delegated-http-routing-defaults' +import { delegatedHTTPRoutingDefaults } from '@helia/routers' import { autoNAT } from '@libp2p/autonat' import { bootstrap } from '@libp2p/bootstrap' import { circuitRelayTransport, circuitRelayServer, type CircuitRelayService } from '@libp2p/circuit-relay-v2' diff --git a/packages/routers/src/index.ts b/packages/routers/src/index.ts index 23c014c8..a3973a45 100644 --- a/packages/routers/src/index.ts +++ b/packages/routers/src/index.ts @@ -4,6 +4,7 @@ * Abstraction layer over different content and peer routing mechanisms. */ export { delegatedHTTPRouting } from './delegated-http-routing.js' +export { delegatedHTTPRoutingDefaults } from './utils/delegated-http-routing-defaults' export { httpGatewayRouting } from './http-gateway-routing.js' export type { HTTPGatwayRouterInit } from './http-gateway-routing.js' export { libp2pRouting } from './libp2p-routing.js' From d3653e018d55fd3ab1b6b88ab472f627300e7c7a Mon Sep 17 00:00:00 2001 From: Daniel N <2color@users.noreply.github.com> Date: Thu, 31 Oct 2024 10:19:04 +0100 Subject: [PATCH 5/5] fix: import --- packages/routers/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/routers/src/index.ts b/packages/routers/src/index.ts index a3973a45..c4f7b7c7 100644 --- a/packages/routers/src/index.ts +++ b/packages/routers/src/index.ts @@ -4,7 +4,7 @@ * Abstraction layer over different content and peer routing mechanisms. */ export { delegatedHTTPRouting } from './delegated-http-routing.js' -export { delegatedHTTPRoutingDefaults } from './utils/delegated-http-routing-defaults' +export { delegatedHTTPRoutingDefaults } from './utils/delegated-http-routing-defaults.js' export { httpGatewayRouting } from './http-gateway-routing.js' export type { HTTPGatwayRouterInit } from './http-gateway-routing.js' export { libp2pRouting } from './libp2p-routing.js'