Skip to content

Commit

Permalink
feat: support ens resolution (#56)
Browse files Browse the repository at this point in the history
* chore: use latest verified-fetch RC

* feat: add cloudflare eth resolver

* tmp: use sgtpooki.com/dns-query

until either cloudflare or delegated-ipfs.dev dns-query is working, this is working for ens resolution

* feat: use delegated-ipfs.dev/dns-query
  • Loading branch information
SgtPooki authored Feb 27, 2024
1 parent d933208 commit 4c9a3f3
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 77 deletions.
197 changes: 122 additions & 75 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@
"@helia/block-brokers": "^2.0.1",
"@helia/http": "^1.0.0",
"@helia/interface": "^4.0.0",
"@helia/ipns": "^6.0.0",
"@helia/routers": "^1.0.0",
"@helia/verified-fetch": "^0.0.0-28d62f7",
"@helia/verified-fetch": "^0.0.0-6f8c15b",
"@libp2p/logger": "^4.0.6",
"@sgtpooki/file-type": "^1.0.1",
"blockstore-idb": "^1.1.8",
Expand Down
9 changes: 8 additions & 1 deletion src/lib/heliaFetch.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { dnsJsonOverHttps } from '@helia/ipns/dns-resolvers'
import { createVerifiedFetch, type ContentTypeParser } from '@helia/verified-fetch'
import { fileTypeFromBuffer } from '@sgtpooki/file-type'
import { getConfig } from './config-db'
import { trace } from './logger'
import type { Helia } from '@helia/interface'

Expand Down Expand Up @@ -122,7 +124,12 @@ function changeCssFontPath (path: string): string {
*
*/
export async function heliaFetch ({ path, helia, signal, headers, id, protocol }: HeliaFetchOptions): Promise<Response> {
const verifiedFetch = await createVerifiedFetch(helia, {
const config = await getConfig()
const verifiedFetch = await createVerifiedFetch({
gateways: ['https://trustless-gateway.link', ...config.gateways],
routers: ['https://delegated-ipfs.dev', ...config.routers],
dnsResolvers: ['https://delegated-ipfs.dev/dns-query'].map(dnsJsonOverHttps)
}, {
contentTypeParser
})

Expand Down

0 comments on commit 4c9a3f3

Please sign in to comment.