From aecac3d92cbd22a7331afee8e6f87ef31a9f7d95 Mon Sep 17 00:00:00 2001 From: Daniel Norman <1992255+2color@users.noreply.github.com> Date: Mon, 4 Nov 2024 12:19:52 +0100 Subject: [PATCH] fix: add tls to default delegated routing filters (#670) * fix: add tls to all default filters * chore: avoid duplication of filters * fix: use normal imports with .js * chore: export delegated routing defaults * fix: import --------- Co-authored-by: Daniel N <2color@users.noreply.github.com> --- packages/helia/src/utils/libp2p-defaults.browser.ts | 6 ++---- packages/helia/src/utils/libp2p-defaults.ts | 6 ++---- packages/routers/src/index.ts | 1 + .../src/utils/delegated-http-routing-defaults.browser.ts | 2 +- .../routers/src/utils/delegated-http-routing-defaults.ts | 2 +- 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/packages/helia/src/utils/libp2p-defaults.browser.ts b/packages/helia/src/utils/libp2p-defaults.browser.ts index 7bd756fd..1de3ce90 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' 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'] - }), + 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 547a8bae..41eaffc0 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' 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'] - }), + delegatedRouting: () => createDelegatedRoutingV1HttpApiClient('https://delegated-ipfs.dev', delegatedHTTPRoutingDefaults()), dht: kadDHT({ validators: { ipns: ipnsValidator diff --git a/packages/routers/src/index.ts b/packages/routers/src/index.ts index 23c014c8..c4f7b7c7 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.js' export { httpGatewayRouting } from './http-gateway-routing.js' export type { HTTPGatwayRouterInit } from './http-gateway-routing.js' export { libp2pRouting } from './libp2p-routing.js' 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'] } }