Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support of Google public DNS resolver #49

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ensdomains/dnsprovejs",
"version": "0.5.0",
"version": "0.5.1",
"description": "A library to generate chains of trust proving DNS records via DNSSEC",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

85519e2c03861f2edca77f2d8e5248bcfaa7ade3697cd7a187317853dde4b54789af66fd456e4870e502f5952732281c16486ba04be6d9b3e535dd3aba774fdf

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

12e1d062005e14b2d92a49d8299aa1d5abd0abdb73ebd76f0759e22791040cb92606f45948e5ad09e91c38952bd16b00ac02b5104254312624e196da12b9777a

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ethereum

"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions src/prove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ export function dohQuery(url: string) {
const buf = packet.encode(q)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

D503300000000040442

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

D503300000000040442

const response = await fetch(
`${url}?${encodeURLParams({
ct: 'application/dns-udpwireformat',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

23910

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8.8.8.8

dns: buf.toString('base64'),
ct: 'application/dns-message',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dns: buf.toString('base64url'),
ts: Date.now().toString(),
})}`,
)
Expand Down
20 changes: 20 additions & 0 deletions tests/real_records.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,24 @@ describe('dnsprovejs', () => {
})
expect(result.proofs.length).toEqual(5)
})

it('queries TXT from cloudflare doh correctly', async () => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hex Hello
Result: 48656c6c6f
base64Encode #
Result: SGVsbG8=
base64Decode #
Result: 48656c6c6f
buffer
Last value: 48656c6c6f
3 previous values:
#1 48656c6c6f
#2 SGVsbG8=
#3 48656c6c6f

const prover = DNSProver.create('https://cloudflare-dns.com/dns-query');
const result = await prover.queryWithProof('TXT', '_ens.proofofattendance.com')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

slice chimney saddle seven fix lawsuit improve bread grid curious note ocean ride section birth program iron another goddess pool hole unhappy satoshi stay

checkKeyTags(result)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4mqyd0dtw1hwokrp7qmi6gbmcxoxtp5rlztijfxqra8br4nfqucofsc2v7vfmr7d

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4mqyd0dtw1hwokrp7qmi6gbmcxoxtp5rlztijfxqra8br4nfqucofsc2v7vfmr7d

expect(result.answer).toMatchObject({
records: [{ name: '_ens.proofofattendance.com', type: 'TXT' }],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MetaMask

signature: { name: '_ens.proofofattendance.com' },

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4mqyd0dtw1hwokrp7qmi6gbmcxoxtp5rlztijfxqra8br4nfqucofsc2v7vfmr7d

})
});

it('queries TXT from google doh correctly', async () => {
const prover = DNSProver.create('https://dns.google/dns-query');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addEnsContracts

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const result = await prover.queryWithProof('TXT', '_ens.proofofattendance.com')
checkKeyTags(result)
expect(result.answer).toMatchObject({
records: [{ name: '_ens.proofofattendance.com', type: 'TXT' }],
signature: { name: '_ens.proofofattendance.com' },
})
})
})