-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathprotocols.js
54 lines (54 loc) · 2.02 KB
/
protocols.js
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
module.exports = Object.freeze({
async dat (context, name) {
let record = context.matchRegex(name, /^(?<key>[0-9a-f]{64})$/i)
if (record !== undefined) {
return record
}
record = await context.getDNSTxtRecord(name, /^\s*"?datkey=(?<key>[0-9a-f]{64})"?\s*$/i)
if (record !== undefined) {
return record
}
return await context.fetchWellKnown(name, 'dat', /^\s*(?:dat:)?(?:\/\/)?(?<key>[0-9a-f]{64})\s*$/i, 6)
},
async hyper (context, name) {
let record = context.matchRegex(name, /^(?<key>[0-9a-f]{64})$/i)
if (record !== undefined) {
return record
}
record = await context.getDNSTxtRecord(name, /^\s*"?hyperkey=(?<key>[0-9a-f]{64})"?\s*$/i)
if (record !== undefined) {
return record
}
record = await context.getDNSTxtRecord(name, /^\s*"?datkey=(?<key>[0-9a-f]{64})"?\s*$/i)
if (record !== undefined) {
return record
}
record = await context.fetchWellKnown(name, 'hyper', /^\s*(?:(?:dat|hyper):)?(?:\/\/)?(?<key>[0-9a-f]{64})\s*$/i, 6)
if (record !== undefined) {
return record
}
return await context.fetchWellKnown(name, 'dat', /^\s*(?:dat:)?(?:\/\/)?(?<key>[0-9a-f]{64})\s*$/i, 6)
},
async cabal (context, name) {
let record = context.matchRegex(name, /^(?<key>[0-9a-f]{64})$/i)
if (record !== undefined) {
return record
}
record = await context.getDNSTxtRecord(name, /^\s*"?(?:cabalkey)=(?<key>[0-9a-f]{64})"?\s*$/i)
if (record !== undefined) {
return record
}
return await context.fetchWellKnown(name, 'cabal', /^\s*(?:cabal:)?(?:\/\/)?(?<key>[0-9a-f]{64})\s*$/i, 6)
},
async ara (context, name) {
let record = context.matchRegex(name, /^(?<key>[0-9a-f]{64})$/i)
if (record !== undefined) {
return record
}
record = await context.getDNSTxtRecord(name, /^\s*"?(?:did:ara:)(?<key>[0-9a-f]{64})"?\s*$/i)
if (record !== undefined) {
return record
}
return await context.fetchWellKnown(name, 'ara', /^\s*(?:did:ara:)?(?:\/\/)?(?<key>[0-9a-f]{64})\s*$/i, 6)
}
})