doipjs/src/serviceproviders/dns.js

38 lines
657 B
JavaScript
Raw Normal View History

2020-10-24 03:18:06 -06:00
const reURI = /^dns:([a-zA-Z0-9\.\-\_]*)(?:\?(.*))?/
2020-10-23 14:35:53 -06:00
2020-10-24 03:20:34 -06:00
const processURI = (uri, opts) => {
const match = uri.match(reURI)
2020-10-23 14:35:53 -06:00
return {
type: "domain",
profile: {
display: match[1],
2020-10-24 03:18:06 -06:00
uri: `https://${match[1]}`
2020-10-23 14:35:53 -06:00
},
proof: {
2020-10-24 03:18:06 -06:00
uri: `https://dns.shivering-isles.com/dns-query?name=${match[1]}&type=TXT`,
2020-10-23 14:35:53 -06:00
fetch: null
},
qr: null
}
}
const tests = [
{
2020-10-24 03:18:06 -06:00
uri: 'dns:domain.org',
2020-10-23 17:06:46 -06:00
shouldMatch: true
2020-10-23 14:35:53 -06:00
},
{
2020-10-24 03:18:06 -06:00
uri: 'dns:domain.org?type=TXT',
2020-10-23 17:06:46 -06:00
shouldMatch: true
2020-10-23 14:35:53 -06:00
},
{
2020-10-24 03:18:06 -06:00
uri: 'https://domain.org',
2020-10-23 14:35:53 -06:00
shouldMatch: false
}
]
2020-10-24 03:18:06 -06:00
exports.reURI = reURI
2020-10-24 03:20:34 -06:00
exports.processURI = processURI
2020-10-23 14:35:53 -06:00
exports.tests = tests