Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support ens resolution #56

Merged
merged 5 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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> {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should remove helia here and the get-helia since we can't pass both custom dnsResolvers and a custom helia instance.

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