From 6ef9adf80504d299c7b31cfd422597838c6d3729 Mon Sep 17 00:00:00 2001 From: derain Date: Fri, 3 Nov 2023 20:33:51 +0300 Subject: [PATCH 1/2] Add support of Google public DNS resolver by using modern application/dns-message and base64url encoding. --- src/prove.ts | 4 ++-- tests/real_records.test.ts | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/prove.ts b/src/prove.ts index 0307ce0..1041e78 100644 --- a/src/prove.ts +++ b/src/prove.ts @@ -92,8 +92,8 @@ export function dohQuery(url: string) { const buf = packet.encode(q) const response = await fetch( `${url}?${encodeURLParams({ - ct: 'application/dns-udpwireformat', - dns: buf.toString('base64'), + ct: 'application/dns-message', + dns: buf.toString('base64url'), ts: Date.now().toString(), })}`, ) diff --git a/tests/real_records.test.ts b/tests/real_records.test.ts index 3abe0c4..a87958a 100644 --- a/tests/real_records.test.ts +++ b/tests/real_records.test.ts @@ -98,4 +98,24 @@ describe('dnsprovejs', () => { }) expect(result.proofs.length).toEqual(5) }) + + it('queries TXT from cloudflare doh correctly', async () => { + const prover = DNSProver.create('https://cloudflare-dns.com/dns-query'); + 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' }, + }) + }); + + it('queries TXT from google doh correctly', async () => { + const prover = DNSProver.create('https://dns.google/dns-query'); + 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' }, + }) + }) }) From 54bfb4fca5bc24fb1c5d6b1affdb5451438259be Mon Sep 17 00:00:00 2001 From: derain Date: Fri, 3 Nov 2023 20:43:07 +0300 Subject: [PATCH 2/2] Bump package version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5135c50..2925296 100644 --- a/package.json +++ b/package.json @@ -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", "main": "dist/index.js", "types": "dist/index.d.ts",