-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
resolve-context.d.ts
40 lines (37 loc) · 1.22 KB
/
resolve-context.d.ts
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
36
37
38
39
40
import { ResolveOptions } from './resolve'
declare function createResolveContext (
fetch: createResolveContext.Fetch,
dnsTxtFallback: createResolveContext.DNSTxtFallback,
opts: ResolveOptions
): createResolveContext.ResolveContext
declare namespace createResolveContext {
interface LookupEntry {
key: string
ttl?: number
}
interface ResolveContext {
isLocal: typeof isLocal
matchRegex: typeof matchRegex
getDNSTxtRecord: (name: string, textRegex: RegExp) => Promise<LookupEntry>
fetchWellKnown: (name: string, schema: string, keyRegex: RegExp, followRedirects: number) => Promise<LookupEntry>
}
function isLocal (name: string): boolean
function matchRegex (name: string, regex: RegExp): LookupEntry | undefined
interface FetchOptions {
signal: AbortSignal
redirect: 'manual',
headers: {
Accept: 'text/plain' | 'application/dns-json',
'User-Agent'?: string
}
}
interface Response {
headers: Map<string, string>
status: number
href: string
text (): Promise<string>
}
type DNSTxtFallback = (name: string) => Array<{ data: string, TTL?: number }>
type Fetch = (href: string, options: FetchOptions) => Promise<Response>
}
export = createResolveContext