@gahmen/dnsprove
v0.0.1
Published
Helper utility for retrieving OpenAttestations document store address records from DNS
Downloads
6
Readme
Open Attestation (dnsprove)
A helper library to retrieve OpenAttestation DNS-TXT records from domains using Google's public DNS service.
A valid OpenAttestation DNS-TXT record looks like:
[
{
name: "example.openattestation.com.",
type: 16,
TTL: 110,
data: '"openatts net=ethereum netId=3 addr=0x2f60375e8144e16Adf1979936301D8341D58C36C"',
},
];
Validation is run on all retrieved records to ensure they conform to the expected format, and records that fail validation will simply be omitted from the returned results.
Installation
npm i @govtechsg/dnsprove
Debug
To see validation failures run the library with the debug flag turned on, either
In Browser:
localStorage.debug="dnsprove*"
In NodeJS:
DEBUG="dnsprove*" npm run test
Types
This library uses runtypes for compile time static type checking as well as run time input validation. The generated documentation below is inaccurate for any Runtypes generated types due to documentation generator limitations.
API
Table of Contents
- OpenAttestationDNSTextRecord
- OpenAttestationDnsDidRecord
- IDNSRecord
- IDNSQueryResponse
- CustomDnsResolver
- defaultDnsResolvers
- queryDns
- parseOpenAttestationRecord
- parseDocumentStoreResults
- parseDnsDidResults
- getDocumentStoreRecords
- getDnsDidRecords
OpenAttestationDNSTextRecord
OpenAttestationDnsDidRecord
IDNSRecord
IDNSQueryResponse
CustomDnsResolver
Type: function (domain: string): Promise<IDNSQueryResponse>
defaultDnsResolvers
Type: Array<CustomDnsResolver>
queryDns
Parameters
domain
stringcustomDnsResolvers
Array<CustomDnsResolver>
Returns Promise<IDNSQueryResponse>
parseOpenAttestationRecord
Parses one openattestation DNS-TXT record and turns it into an OpenAttestationsDNSTextRecord object
Parameters
record
string e.g: '"openatts net=ethereum netId=3 addr=0x0c9d5E6C766030cc6f0f49951D275Ad0701F81EC"'
Returns GenericObject
parseDocumentStoreResults
Takes a DNS-TXT Record set and returns openattestation document store records if any
Parameters
recordSet
Array<IDNSRecord> Refer to tests for examples (optional, default[]
)dnssec
boolean
Returns Array<OpenAttestationDNSTextRecord>
parseDnsDidResults
Parameters
recordSet
Array<IDNSRecord> (optional, default[]
)dnssec
boolean
Returns Array<OpenAttestationDnsDidRecord>
getDocumentStoreRecords
Queries a given domain and parses the results to retrieve openattestation document store records if any
Parameters
domain
string e.g: "example.openattestation.com"customDnsResolvers
Array<CustomDnsResolver>?
Examples
> getDocumentStoreRecords("example.openattestation.com")
> [ { type: 'openatts',
net: 'ethereum',
netId: '3',
addr: '0x2f60375e8144e16Adf1979936301D8341D58C36C',
dnssec: true } ]
Returns Promise<Array<OpenAttestationDNSTextRecord>>
getDnsDidRecords
Parameters
domain
stringcustomDnsResolvers
Array<CustomDnsResolver>?
Returns Promise<Array<OpenAttestationDnsDidRecord>>
License
MIT