diff --git a/.pnp.cjs b/.pnp.cjs index dc40079f..e5f41343 100755 --- a/.pnp.cjs +++ b/.pnp.cjs @@ -4166,6 +4166,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { [null, {\ "packageLocation": "./",\ "packageDependencies": [\ + ["@types/dns-packet", "npm:5.2.4"],\ ["@typescript-eslint/eslint-plugin", "virtual:18871a8dec559cd45f159cc6ccc35dca6943896d73c1129c917a6367a95f6a0920e5882fbc8f2d0416f94184bd0f22f6747f25ff9398c218d855f8cc83da6ea8#npm:5.15.0"],\ ["@typescript-eslint/parser", "virtual:18871a8dec559cd45f159cc6ccc35dca6943896d73c1129c917a6367a95f6a0920e5882fbc8f2d0416f94184bd0f22f6747f25ff9398c218d855f8cc83da6ea8#npm:5.15.0"],\ ["eslint", "npm:8.11.0"],\ @@ -9922,6 +9923,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "packageLocation": "./",\ "packageDependencies": [\ ["ensjs-monorepo", "workspace:."],\ + ["@types/dns-packet", "npm:5.2.4"],\ ["@typescript-eslint/eslint-plugin", "virtual:18871a8dec559cd45f159cc6ccc35dca6943896d73c1129c917a6367a95f6a0920e5882fbc8f2d0416f94184bd0f22f6747f25ff9398c218d855f8cc83da6ea8#npm:5.15.0"],\ ["@typescript-eslint/parser", "virtual:18871a8dec559cd45f159cc6ccc35dca6943896d73c1129c917a6367a95f6a0920e5882fbc8f2d0416f94184bd0f22f6747f25ff9398c218d855f8cc83da6ea8#npm:5.15.0"],\ ["eslint", "npm:8.11.0"],\ diff --git a/package.json b/package.json index 868ba86e..badc8c79 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "publish:local:ensjs": "yalc publish packages/ensjs --push --up" }, "devDependencies": { + "@types/dns-packet": "^5.2.4", "@typescript-eslint/eslint-plugin": "^5.15.0", "@typescript-eslint/parser": "^5.15.0", "eslint": "^8.11.0", diff --git a/packages/ensjs/src/@types/dns-packet.d.ts b/packages/ensjs/src/@types/dns-packet.d.ts new file mode 100644 index 00000000..a4519dca --- /dev/null +++ b/packages/ensjs/src/@types/dns-packet.d.ts @@ -0,0 +1 @@ +declare module 'dns-packet' diff --git a/packages/ensjs/src/@types/dns-packet/index.d.ts b/packages/ensjs/src/@types/dns-packet/index.d.ts new file mode 100644 index 00000000..bf37b107 --- /dev/null +++ b/packages/ensjs/src/@types/dns-packet/index.d.ts @@ -0,0 +1,114 @@ +declare module 'dns-packet' { + const AUTHORITATIVE_ANSWER: number + const TRUNCATED_RESPONSE: number + const RECURSION_DESIRED: number + const RECURSION_AVAILABLE: number + const AUTHENTIC_DATA: number + const CHECKING_DISABLED: number + const DNSSEC_OK: number + + interface decoder { + (buf: Buffer, offset?: number): T + bytes: number; + } + + const decode: decoder; + + interface encoder { + (packet: T, buf?: Buffer, offset?: number): Buffer + bytes: number; + } + + const encode: encoder; + + interface Packet { + id?: number + type: 'query' | 'response' + flags?: number + rcode?: string + questions: Question[] + answers?: Answer[] + authorities?: Answer[] + additionals?: Answer[] + } + + interface Question { + type: string + class: string + name: string + } + + interface AnswerBase { + type: string + class: string + name: string + ttl?: number + } + + interface A extends AnswerBase { + type: 'A' + data: string + } + + interface Dnskey extends AnswerBase { + type: 'DNSKEY' + data: { + flags: number + algorithm: number + key: Buffer + } + } + + interface Ds extends AnswerBase { + type: 'DS' + data: { + keyTag: number + algorithm: number + digestType: number + digest: Buffer + } + } + + interface Opt extends AnswerBase { + type: 'OPT' + udpPayloadSize?: number + extendedRcode?: number + ednsVersion?: number + flags?: number + data?: any + } + + interface Rrsig extends AnswerBase { + type: 'RRSIG' + data: { + typeCovered: string + algorithm: number + labels: number + originalTTL: number + expiration: number + inception: number + keyTag: number + signersName: string + signature: Buffer + } + } + + interface Rtxt extends AnswerBase { + type: 'TXT' + data: Buffer[] + } + + type Answer = A|Dnskey|Ds|Opt|Rrsig|Rtxt + + interface Encodable { + decode: decoder + encode: encoder + } + + const record: (type: string) => Encodable + const answer: Encodable + const dnskey: Encodable + const name: Encodable + const rrsig: Encodable + } + \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 149987b9..7d6cd72a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4656,6 +4656,7 @@ __metadata: version: 0.0.0-use.local resolution: "ensjs-monorepo@workspace:." dependencies: + "@types/dns-packet": ^5.2.4 "@typescript-eslint/eslint-plugin": ^5.15.0 "@typescript-eslint/parser": ^5.15.0 eslint: ^8.11.0