-
Notifications
You must be signed in to change notification settings - Fork 145
Expand file tree
/
Copy pathindex.ts
More file actions
35 lines (27 loc) · 1.33 KB
/
index.ts
File metadata and controls
35 lines (27 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { TrustlessGatewayBlockBroker } from './broker.js'
import type { BlockRetriever } from '@helia/interface/src/blocks.js'
import type { ComponentLogger } from '@libp2p/interface'
import type { ProgressEvent } from 'progress-events'
export const DEFAULT_TRUSTLESS_GATEWAYS: TrustlessGatewayUrl[] = [
// 2024-02-20: IPNS and Block/CAR support from https://ipfs.github.io/public-gateway-checker/
{ url: 'https://trustless-gateway.link', isSubdomain: false },
// 2024-02-20: IPNS and Block/CAR support from https://ipfs.github.io/public-gateway-checker/
{ url: 'https://cloudflare-ipfs.com', isSubdomain: false },
// 2024-02-20: IPNS, Origin, and Block/CAR support from https://ipfs.github.io/public-gateway-checker/
{ url: 'https://4everland.io', isSubdomain: true },
]
interface TrustlessGatewayUrl {
url: string | URL
isSubdomain: boolean
}
export type TrustlessGatewayGetBlockProgressEvents =
ProgressEvent<'trustless-gateway:get-block:fetch', URL>
export interface TrustlessGatewayBlockBrokerInit {
gateways?: Array<TrustlessGatewayUrl>
}
export interface TrustlessGatewayComponents {
logger: ComponentLogger
}
export function trustlessGateway (init: TrustlessGatewayBlockBrokerInit = {}): (components: TrustlessGatewayComponents) => BlockRetriever {
return (components) => new TrustlessGatewayBlockBroker(components, init)
}