n8n-nodes-dns 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +186 -0
  3. package/dist/coverage/lcov-report/favicon.png +0 -0
  4. package/dist/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  5. package/dist/package.json +97 -0
  6. package/dist/src/credentials/DnsServerApi.credentials.d.ts +7 -0
  7. package/dist/src/credentials/DnsServerApi.credentials.js +30 -0
  8. package/dist/src/credentials/DnsServerApi.credentials.js.map +1 -0
  9. package/dist/src/credentials/dnsServerApi.svg +4 -0
  10. package/dist/src/nodes/DnsLookup/DnsLookup.node.d.ts +16 -0
  11. package/dist/src/nodes/DnsLookup/DnsLookup.node.js +222 -0
  12. package/dist/src/nodes/DnsLookup/DnsLookup.node.js.map +1 -0
  13. package/dist/src/nodes/DnsLookup/DnsLookup.node.json +33 -0
  14. package/dist/src/nodes/DnsLookup/dnsLookup.svg +4 -0
  15. package/dist/src/nodes/DnsWatch/DnsWatch.node.d.ts +15 -0
  16. package/dist/src/nodes/DnsWatch/DnsWatch.node.js +247 -0
  17. package/dist/src/nodes/DnsWatch/DnsWatch.node.js.map +1 -0
  18. package/dist/src/nodes/DnsWatch/DnsWatch.node.json +26 -0
  19. package/dist/src/nodes/DnsWatch/dnsWatch.svg +4 -0
  20. package/dist/src/nodes/shared/dns-node-helpers.d.ts +43 -0
  21. package/dist/src/nodes/shared/dns-node-helpers.js +133 -0
  22. package/dist/src/nodes/shared/dns-node-helpers.js.map +1 -0
  23. package/dist/src/nodes/shared/dns-node-properties.d.ts +6 -0
  24. package/dist/src/nodes/shared/dns-node-properties.js +139 -0
  25. package/dist/src/nodes/shared/dns-node-properties.js.map +1 -0
  26. package/dist/src/transport/dns-client.d.ts +22 -0
  27. package/dist/src/transport/dns-client.js +168 -0
  28. package/dist/src/transport/dns-client.js.map +1 -0
  29. package/dist/src/transport/dns-packet.d.ts +49 -0
  30. package/dist/src/transport/dns-packet.js +178 -0
  31. package/dist/src/transport/dns-packet.js.map +1 -0
  32. package/dist/src/transport/dns-resolvers.d.ts +18 -0
  33. package/dist/src/transport/dns-resolvers.js +132 -0
  34. package/dist/src/transport/dns-resolvers.js.map +1 -0
  35. package/dist/src/transport/index.d.ts +6 -0
  36. package/dist/src/transport/index.js +21 -0
  37. package/dist/src/transport/index.js.map +1 -0
  38. package/dist/src/utils/authoritative-discovery.d.ts +9 -0
  39. package/dist/src/utils/authoritative-discovery.js +77 -0
  40. package/dist/src/utils/authoritative-discovery.js.map +1 -0
  41. package/dist/src/utils/index.d.ts +8 -0
  42. package/dist/src/utils/index.js +13 -0
  43. package/dist/src/utils/index.js.map +1 -0
  44. package/dist/src/utils/name-compression.d.ts +5 -0
  45. package/dist/src/utils/name-compression.js +63 -0
  46. package/dist/src/utils/name-compression.js.map +1 -0
  47. package/dist/src/utils/record-parsers.d.ts +53 -0
  48. package/dist/src/utils/record-parsers.js +232 -0
  49. package/dist/src/utils/record-parsers.js.map +1 -0
  50. package/dist/src/utils/txt-parsers.d.ts +40 -0
  51. package/dist/src/utils/txt-parsers.js +204 -0
  52. package/dist/src/utils/txt-parsers.js.map +1 -0
  53. package/dist/tsconfig.tsbuildinfo +1 -0
  54. package/package.json +97 -0
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.walkDelegationChain = walkDelegationChain;
4
+ const dns_client_1 = require("../transport/dns-client");
5
+ const name_compression_1 = require("./name-compression");
6
+ const NS_TYPE = 2;
7
+ const A_TYPE = 1;
8
+ const DNS_PORT = 53;
9
+ function extractNsHostnames(response) {
10
+ return response.answers
11
+ .filter((record) => record.recordType === NS_TYPE)
12
+ .map((record) => (0, name_compression_1.decompressName)(response.rawPacket, record.rdataOffset).name);
13
+ }
14
+ function parseIpFromArdata(rdata) {
15
+ return `${rdata[0]}.${rdata[1]}.${rdata[2]}.${rdata[3]}`;
16
+ }
17
+ function extractGlueRecords(response, nameserverHostnames) {
18
+ const glueMap = new Map();
19
+ for (const record of response.additionals) {
20
+ if (record.recordType === A_TYPE && nameserverHostnames.has(record.name)) {
21
+ glueMap.set(record.name, parseIpFromArdata(record.rdata));
22
+ }
23
+ }
24
+ return glueMap;
25
+ }
26
+ function isARecord(record) {
27
+ return record.recordType === A_TYPE && record.rdataLength === 4;
28
+ }
29
+ async function resolveNameserverIps(options) {
30
+ const { hostnames, glueRecords, recursiveResolver, queryFn, clientOptions } = options;
31
+ const servers = [];
32
+ for (const hostname of hostnames) {
33
+ const glueIp = glueRecords.get(hostname);
34
+ if (glueIp) {
35
+ servers.push({ address: glueIp, port: DNS_PORT });
36
+ continue;
37
+ }
38
+ try {
39
+ const result = await queryFn(hostname, 'A', recursiveResolver, clientOptions);
40
+ if (!result.response)
41
+ continue;
42
+ for (const answer of result.response.answers) {
43
+ if (isARecord(answer)) {
44
+ servers.push({ address: parseIpFromArdata(answer.rdata), port: DNS_PORT });
45
+ }
46
+ }
47
+ }
48
+ catch {
49
+ }
50
+ }
51
+ return servers;
52
+ }
53
+ async function walkDelegationChain(domain, options) {
54
+ var _a;
55
+ const queryFn = (_a = options.queryFn) !== null && _a !== void 0 ? _a : dns_client_1.querySingleServer;
56
+ let nsResult;
57
+ try {
58
+ nsResult = await queryFn(domain, 'NS', options.recursiveResolver, options.clientOptions);
59
+ }
60
+ catch {
61
+ return [];
62
+ }
63
+ if (!nsResult.response)
64
+ return [];
65
+ const nameserverHostnames = extractNsHostnames(nsResult.response);
66
+ if (nameserverHostnames.length === 0)
67
+ return [];
68
+ const glueRecords = extractGlueRecords(nsResult.response, new Set(nameserverHostnames));
69
+ return resolveNameserverIps({
70
+ hostnames: nameserverHostnames,
71
+ glueRecords,
72
+ recursiveResolver: options.recursiveResolver,
73
+ queryFn,
74
+ ...(options.clientOptions !== undefined && { clientOptions: options.clientOptions }),
75
+ });
76
+ }
77
+ //# sourceMappingURL=authoritative-discovery.js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C;QACJ,QAAQ,GAAG,MAAM,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;IAC1F,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,EAAE,CAAC;IACX,CAAC;IAED,IAAI,CAAC,QAAQ,CAAC,QAAQ;QAAE,OAAO,EAAE,CAAC;IAElC,MAAM,mBAAmB,GAAG,kBAAkB,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAClE,IAAI,mBAAmB,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAEhD,MAAM,WAAW,GAAG,kBAAkB,CAAC,QAAQ,CAAC,QAAQ,EAAE,IAAI,GAAG,CAAC,mBAAmB,CAAC,CAAC,CAAC;IAExF,OAAO,oBAAoB,CAAC;QAC3B,SAAS,EAAE,mBAAmB;QAC9B,WAAW;QACX,iBAAiB,EAAE,OAAO,CAAC,iBAAiB;QAC5C,OAAO;QACP,GAAG,CAAC,OAAO,CAAC,aAAa,KAAK,SAAS,IAAI,EAAE,aAAa,EAAE,OAAO,CAAC,aAAa,EAAE,CAAC;KACpF,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,8 @@
1
+ export declare const DNS_MAX_NAME_LENGTH = 253;
2
+ export { decompressName, type DecompressedName } from './name-compression';
3
+ export { walkDelegationChain } from './authoritative-discovery';
4
+ export type { QueryFunction, WalkDelegationChainOptions } from './authoritative-discovery';
5
+ export { parseRdata } from './record-parsers';
6
+ export type { RecordValue, MxRecordValue, TxtRecordValue, SrvRecordValue, SoaRecordValue, CaaRecordValue, NaptrRecordValue, DnskeyRecordValue, TlsaRecordValue, } from './record-parsers';
7
+ export { enrichTxtRecord } from './txt-parsers';
8
+ export type { TxtParsed, SpfParsed, SpfMechanism, DmarcParsed, DkimParsed, VerificationParsed, } from './txt-parsers';
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.enrichTxtRecord = exports.parseRdata = exports.walkDelegationChain = exports.decompressName = exports.DNS_MAX_NAME_LENGTH = void 0;
4
+ exports.DNS_MAX_NAME_LENGTH = 253;
5
+ var name_compression_1 = require("./name-compression");
6
+ Object.defineProperty(exports, "decompressName", { enumerable: true, get: function () { return name_compression_1.decompressName; } });
7
+ var authoritative_discovery_1 = require("./authoritative-discovery");
8
+ Object.defineProperty(exports, "walkDelegationChain", { enumerable: true, get: function () { return authoritative_discovery_1.walkDelegationChain; } });
9
+ var record_parsers_1 = require("./record-parsers");
10
+ Object.defineProperty(exports, "parseRdata", { enumerable: true, get: function () { return record_parsers_1.parseRdata; } });
11
+ var txt_parsers_1 = require("./txt-parsers");
12
+ Object.defineProperty(exports, "enrichTxtRecord", { enumerable: true, get: function () { return txt_parsers_1.enrichTxtRecord; } });
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":";;;AAAa,QAAA,mBAAmB,GAAG,GAAG,CAAC;AACvC,uDAA2E;AAAlE,kHAAA,cAAc,OAAA;AACvB,qEAAgE;AAAvD,8HAAA,mBAAmB,OAAA;AAE5B,mDAA8C;AAArC,4GAAA,UAAU,OAAA;AAYnB,6CAAgD;AAAvC,8GAAA,eAAe,OAAA"}
@@ -0,0 +1,5 @@
1
+ export interface DecompressedName {
2
+ name: string;
3
+ bytesConsumed: number;
4
+ }
5
+ export declare function decompressName(packet: Buffer, offset: number): DecompressedName;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.decompressName = decompressName;
4
+ const index_1 = require("./index");
5
+ const POINTER_MASK = 0xc0;
6
+ const POINTER_OFFSET_MASK = 0x3fff;
7
+ const MAX_POINTER_DEPTH = 10;
8
+ const MAX_LABEL_LENGTH = 63;
9
+ function isPointerByte(byte) {
10
+ return (byte & POINTER_MASK) === POINTER_MASK;
11
+ }
12
+ function readPointerTarget(packet, position) {
13
+ return packet.readUInt16BE(position) & POINTER_OFFSET_MASK;
14
+ }
15
+ function readLabel(packet, position, labelLength) {
16
+ if (position + 1 + labelLength > packet.length) {
17
+ throw new Error('DNS name decompression reached end of packet unexpectedly');
18
+ }
19
+ return packet.toString('ascii', position + 1, position + 1 + labelLength);
20
+ }
21
+ function decompressName(packet, offset) {
22
+ const labels = [];
23
+ let currentPosition = offset;
24
+ let bytesConsumed;
25
+ let depth = 0;
26
+ let nameLength = 0;
27
+ for (;;) {
28
+ if (depth > MAX_POINTER_DEPTH) {
29
+ throw new Error(`DNS name decompression exceeded maximum pointer depth of ${MAX_POINTER_DEPTH}`);
30
+ }
31
+ if (currentPosition >= packet.length) {
32
+ throw new Error('DNS name decompression reached end of packet unexpectedly');
33
+ }
34
+ const currentByte = packet.readUInt8(currentPosition);
35
+ if (currentByte === 0x00) {
36
+ bytesConsumed !== null && bytesConsumed !== void 0 ? bytesConsumed : (bytesConsumed = currentPosition - offset + 1);
37
+ break;
38
+ }
39
+ if (isPointerByte(currentByte)) {
40
+ bytesConsumed !== null && bytesConsumed !== void 0 ? bytesConsumed : (bytesConsumed = currentPosition - offset + 2);
41
+ const targetOffset = readPointerTarget(packet, currentPosition);
42
+ if (targetOffset >= packet.length) {
43
+ throw new Error(`DNS compression pointer references offset ${targetOffset} beyond packet boundary`);
44
+ }
45
+ currentPosition = targetOffset;
46
+ depth++;
47
+ continue;
48
+ }
49
+ const labelLength = currentByte;
50
+ if (labelLength > MAX_LABEL_LENGTH) {
51
+ throw new Error(`DNS label length ${labelLength} exceeds maximum of ${MAX_LABEL_LENGTH} bytes`);
52
+ }
53
+ const label = readLabel(packet, currentPosition, labelLength);
54
+ nameLength += (labels.length > 0 ? 1 : 0) + labelLength;
55
+ if (nameLength > index_1.DNS_MAX_NAME_LENGTH) {
56
+ throw new Error(`DNS name exceeds maximum length of ${index_1.DNS_MAX_NAME_LENGTH} characters`);
57
+ }
58
+ labels.push(label);
59
+ currentPosition += 1 + labelLength;
60
+ }
61
+ return { name: labels.join('.'), bytesConsumed: bytesConsumed };
62
+ }
63
+ //# sourceMappingURL=name-compression.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"name-compression.js","sourceRoot":"","sources":["../../../src/utils/name-compression.ts"],"names":[],"mappings":";;AA2BA,wCAwDC;AAnFD,mCAA8C;AAE9C,MAAM,YAAY,GAAG,IAAI,CAAC;AAC1B,MAAM,mBAAmB,GAAG,MAAM,CAAC;AACnC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAC7B,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAO5B,SAAS,aAAa,CAAC,IAAY;IAClC,OAAO,CAAC,IAAI,GAAG,YAAY,CAAC,KAAK,YAAY,CAAC;AAC/C,CAAC;AAED,SAAS,iBAAiB,CAAC,MAAc,EAAE,QAAgB;IAC1D,OAAO,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,mBAAmB,CAAC;AAC5D,CAAC;AAED,SAAS,SAAS,CAAC,MAAc,EAAE,QAAgB,EAAE,WAAmB;IACvE,IAAI,QAAQ,GAAG,CAAC,GAAG,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;IAC9E,CAAC;IACD,OAAO,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,GAAG,CAAC,EAAE,QAAQ,GAAG,CAAC,GAAG,WAAW,CAAC,CAAC;AAC3E,CAAC;AAED,SAAgB,cAAc,CAAC,MAAc,EAAE,MAAc;IAC5D,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,IAAI,eAAe,GAAG,MAAM,CAAC;IAC7B,IAAI,aAAiC,CAAC;IACtC,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,UAAU,GAAG,CAAC,CAAC;IAEnB,SAAS,CAAC;QACT,IAAI,KAAK,GAAG,iBAAiB,EAAE,CA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,2BAAmB,EAAE,CAAC;YACtC,MAAM,IAAI,KAAK,CAAC,sCAAsC,2BAAmB,aAAa,CAAC,CAAC;QACzF,CAAC;QAED,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACnB,eAAe,IAAI,CAAC,GAAG,WAAW,CAAC;IACpC,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,aAAa,EAAE,aAAc,EAAE,CAAC;AAClE,CAAC"}
@@ -0,0 +1,53 @@
1
+ import type { DnsResourceRecord } from '../transport/dns-packet';
2
+ import type { TxtParsed } from './txt-parsers';
3
+ export interface MxRecordValue {
4
+ priority: number;
5
+ exchange: string;
6
+ }
7
+ export interface TxtRecordValue {
8
+ raw: string;
9
+ parsed: TxtParsed | null;
10
+ parseError?: string;
11
+ }
12
+ export interface SrvRecordValue {
13
+ priority: number;
14
+ weight: number;
15
+ port: number;
16
+ target: string;
17
+ }
18
+ export interface SoaRecordValue {
19
+ mname: string;
20
+ rname: string;
21
+ serial: number;
22
+ refresh: number;
23
+ retry: number;
24
+ expire: number;
25
+ minimum: number;
26
+ }
27
+ export interface CaaRecordValue {
28
+ flags: number;
29
+ tag: string;
30
+ value: string;
31
+ }
32
+ export interface NaptrRecordValue {
33
+ order: number;
34
+ preference: number;
35
+ flags: string;
36
+ service: string;
37
+ regexp: string;
38
+ replacement: string;
39
+ }
40
+ export interface DnskeyRecordValue {
41
+ flags: number;
42
+ protocol: number;
43
+ algorithm: number;
44
+ publicKey: string;
45
+ }
46
+ export interface TlsaRecordValue {
47
+ usage: number;
48
+ selector: number;
49
+ matchingType: number;
50
+ certificateData: string;
51
+ }
52
+ export type RecordValue = string | MxRecordValue | TxtRecordValue | SrvRecordValue | SoaRecordValue | CaaRecordValue | NaptrRecordValue | DnskeyRecordValue | TlsaRecordValue;
53
+ export declare function parseRdata(record: DnsResourceRecord, packet: Buffer): RecordValue;
@@ -0,0 +1,232 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseRdata = parseRdata;
4
+ const name_compression_1 = require("./name-compression");
5
+ const txt_parsers_1 = require("./txt-parsers");
6
+ const TYPE_A = 1;
7
+ const TYPE_NS = 2;
8
+ const TYPE_CNAME = 5;
9
+ const TYPE_SOA = 6;
10
+ const TYPE_PTR = 12;
11
+ const TYPE_MX = 15;
12
+ const TYPE_TXT = 16;
13
+ const TYPE_AAAA = 28;
14
+ const TYPE_SRV = 33;
15
+ const TYPE_NAPTR = 35;
16
+ const TYPE_DNSKEY = 48;
17
+ const TYPE_TLSA = 52;
18
+ const TYPE_CAA = 257;
19
+ const A_RECORD_LENGTH = 4;
20
+ const AAAA_RECORD_LENGTH = 16;
21
+ const IPV6_GROUP_COUNT = 8;
22
+ function parseARecord(rdata) {
23
+ if (rdata.length < A_RECORD_LENGTH) {
24
+ throw new Error(`A record RDATA expected ${A_RECORD_LENGTH} bytes, got ${rdata.length}`);
25
+ }
26
+ return `${rdata[0]}.${rdata[1]}.${rdata[2]}.${rdata[3]}`;
27
+ }
28
+ function findLongestZeroRun(groups) {
29
+ let bestStart = -1;
30
+ let bestLength = 0;
31
+ let currentStart = -1;
32
+ let currentLength = 0;
33
+ for (let groupIndex = 0; groupIndex < groups.length; groupIndex++) {
34
+ if (groups[groupIndex] === 0) {
35
+ if (currentStart === -1) {
36
+ currentStart = groupIndex;
37
+ currentLength = 1;
38
+ }
39
+ else {
40
+ currentLength++;
41
+ }
42
+ }
43
+ else {
44
+ if (currentLength > bestLength) {
45
+ bestStart = currentStart;
46
+ bestLength = currentLength;
47
+ }
48
+ currentStart = -1;
49
+ currentLength = 0;
50
+ }
51
+ }
52
+ if (currentLength > bestLength) {
53
+ bestStart = currentStart;
54
+ bestLength = currentLength;
55
+ }
56
+ return { start: bestStart, length: bestLength };
57
+ }
58
+ function formatIpv6Address(rdata) {
59
+ const groups = [];
60
+ for (let groupIndex = 0; groupIndex < IPV6_GROUP_COUNT; groupIndex++) {
61
+ groups.push(rdata.readUInt16BE(groupIndex * 2));
62
+ }
63
+ const longestZeroRun = findLongestZeroRun(groups);
64
+ if (longestZeroRun.length < 2) {
65
+ return groups.map((group) => group.toString(16)).join(':');
66
+ }
67
+ const beforeCompression = groups
68
+ .slice(0, longestZeroRun.start)
69
+ .map((group) => group.toString(16));
70
+ const afterCompression = groups
71
+ .slice(longestZeroRun.start + longestZeroRun.length)
72
+ .map((group) => group.toString(16));
73
+ if (beforeCompression.length === 0 && afterCompression.length === 0) {
74
+ return '::';
75
+ }
76
+ if (beforeCompression.length === 0) {
77
+ return `::${afterCompression.join(':')}`;
78
+ }
79
+ if (afterCompression.length === 0) {
80
+ return `${beforeCompression.join(':')}::`;
81
+ }
82
+ return `${beforeCompression.join(':')}::${afterCompression.join(':')}`;
83
+ }
84
+ function parseAaaaRecord(rdata) {
85
+ if (rdata.length < AAAA_RECORD_LENGTH) {
86
+ throw new Error(`AAAA record RDATA expected ${AAAA_RECORD_LENGTH} bytes, got ${rdata.length}`);
87
+ }
88
+ return formatIpv6Address(rdata);
89
+ }
90
+ function parseDomainNameRdata(_rdata, packet, rdataOffset) {
91
+ return (0, name_compression_1.decompressName)(packet, rdataOffset).name;
92
+ }
93
+ function parseMxRecord(rdata, packet, rdataOffset) {
94
+ if (rdata.length < 3) {
95
+ throw new Error(`MX record RDATA expected at least 3 bytes, got ${rdata.length}`);
96
+ }
97
+ const priority = rdata.readUInt16BE(0);
98
+ const { name: exchange } = (0, name_compression_1.decompressName)(packet, rdataOffset + 2);
99
+ return { priority, exchange };
100
+ }
101
+ function parseSrvRecord(rdata, packet, rdataOffset) {
102
+ if (rdata.length < 7) {
103
+ throw new Error(`SRV record RDATA expected at least 7 bytes, got ${rdata.length}`);
104
+ }
105
+ const priority = rdata.readUInt16BE(0);
106
+ const weight = rdata.readUInt16BE(2);
107
+ const port = rdata.readUInt16BE(4);
108
+ const { name: target } = (0, name_compression_1.decompressName)(packet, rdataOffset + 6);
109
+ return { priority, weight, port, target };
110
+ }
111
+ function parseSoaRecord(rdata, packet, rdataOffset) {
112
+ const { name: mname, bytesConsumed: mnameBytes } = (0, name_compression_1.decompressName)(packet, rdataOffset);
113
+ const { name: rname, bytesConsumed: rnameBytes } = (0, name_compression_1.decompressName)(packet, rdataOffset + mnameBytes);
114
+ const integersOffset = mnameBytes + rnameBytes;
115
+ if (rdata.length < integersOffset + 20) {
116
+ throw new Error(`SOA record RDATA expected at least ${integersOffset + 20} bytes, got ${rdata.length}`);
117
+ }
118
+ return {
119
+ mname,
120
+ rname,
121
+ serial: rdata.readUInt32BE(integersOffset),
122
+ refresh: rdata.readUInt32BE(integersOffset + 4),
123
+ retry: rdata.readUInt32BE(integersOffset + 8),
124
+ expire: rdata.readUInt32BE(integersOffset + 12),
125
+ minimum: rdata.readUInt32BE(integersOffset + 16),
126
+ };
127
+ }
128
+ function readCharacterString(buffer, offset) {
129
+ if (offset >= buffer.length) {
130
+ throw new Error('Character string extends beyond buffer');
131
+ }
132
+ const stringLength = buffer.readUInt8(offset);
133
+ if (offset + 1 + stringLength > buffer.length) {
134
+ throw new Error(`Character string length ${stringLength} extends beyond buffer at offset ${offset}`);
135
+ }
136
+ return {
137
+ value: buffer.toString('utf-8', offset + 1, offset + 1 + stringLength),
138
+ bytesConsumed: 1 + stringLength,
139
+ };
140
+ }
141
+ function parseNaptrRecord(rdata, packet, rdataOffset) {
142
+ if (rdata.length < 5) {
143
+ throw new Error(`NAPTR record RDATA expected at least 5 bytes, got ${rdata.length}`);
144
+ }
145
+ const order = rdata.readUInt16BE(0);
146
+ const preference = rdata.readUInt16BE(2);
147
+ let currentOffset = 4;
148
+ const { value: flags, bytesConsumed: flagsBytes } = readCharacterString(rdata, currentOffset);
149
+ currentOffset += flagsBytes;
150
+ const { value: service, bytesConsumed: serviceBytes } = readCharacterString(rdata, currentOffset);
151
+ currentOffset += serviceBytes;
152
+ const { value: regexp, bytesConsumed: regexpBytes } = readCharacterString(rdata, currentOffset);
153
+ currentOffset += regexpBytes;
154
+ const { name: replacement } = (0, name_compression_1.decompressName)(packet, rdataOffset + currentOffset);
155
+ return { order, preference, flags, service, regexp, replacement };
156
+ }
157
+ function parseTxtRecord(rdata) {
158
+ const segments = [];
159
+ let currentOffset = 0;
160
+ while (currentOffset < rdata.length) {
161
+ const { value, bytesConsumed } = readCharacterString(rdata, currentOffset);
162
+ segments.push(value);
163
+ currentOffset += bytesConsumed;
164
+ }
165
+ const raw = segments.join('');
166
+ const enrichment = (0, txt_parsers_1.enrichTxtRecord)(raw);
167
+ if ('parseError' in enrichment) {
168
+ return { raw, parsed: null, parseError: enrichment.parseError };
169
+ }
170
+ return { raw, parsed: enrichment.parsed };
171
+ }
172
+ function parseCaaRecord(rdata) {
173
+ if (rdata.length < 2) {
174
+ throw new Error(`CAA record RDATA expected at least 2 bytes, got ${rdata.length}`);
175
+ }
176
+ const flags = rdata.readUInt8(0);
177
+ const tagLength = rdata.readUInt8(1);
178
+ if (rdata.length < 2 + tagLength) {
179
+ throw new Error(`CAA record tag length ${tagLength} extends beyond RDATA of ${rdata.length} bytes`);
180
+ }
181
+ const tag = rdata.toString('ascii', 2, 2 + tagLength);
182
+ const value = rdata.toString('ascii', 2 + tagLength);
183
+ return { flags, tag, value };
184
+ }
185
+ function parseDnskeyRecord(rdata) {
186
+ if (rdata.length < 4) {
187
+ throw new Error(`DNSKEY record RDATA expected at least 4 bytes, got ${rdata.length}`);
188
+ }
189
+ const flags = rdata.readUInt16BE(0);
190
+ const protocol = rdata.readUInt8(2);
191
+ const algorithm = rdata.readUInt8(3);
192
+ const publicKey = rdata.subarray(4).toString('base64');
193
+ return { flags, protocol, algorithm, publicKey };
194
+ }
195
+ function parseTlsaRecord(rdata) {
196
+ if (rdata.length < 3) {
197
+ throw new Error(`TLSA record RDATA expected at least 3 bytes, got ${rdata.length}`);
198
+ }
199
+ const usage = rdata.readUInt8(0);
200
+ const selector = rdata.readUInt8(1);
201
+ const matchingType = rdata.readUInt8(2);
202
+ const certificateData = rdata.subarray(3).toString('hex');
203
+ return { usage, selector, matchingType, certificateData };
204
+ }
205
+ const RDATA_PARSERS = {
206
+ [TYPE_A]: parseARecord,
207
+ [TYPE_AAAA]: parseAaaaRecord,
208
+ [TYPE_NS]: parseDomainNameRdata,
209
+ [TYPE_CNAME]: parseDomainNameRdata,
210
+ [TYPE_PTR]: parseDomainNameRdata,
211
+ [TYPE_MX]: parseMxRecord,
212
+ [TYPE_SRV]: parseSrvRecord,
213
+ [TYPE_SOA]: parseSoaRecord,
214
+ [TYPE_NAPTR]: parseNaptrRecord,
215
+ [TYPE_TXT]: parseTxtRecord,
216
+ [TYPE_CAA]: parseCaaRecord,
217
+ [TYPE_DNSKEY]: parseDnskeyRecord,
218
+ [TYPE_TLSA]: parseTlsaRecord,
219
+ };
220
+ function parseRdata(record, packet) {
221
+ const parser = RDATA_PARSERS[record.recordType];
222
+ if (!parser) {
223
+ return record.rdata.toString('hex');
224
+ }
225
+ try {
226
+ return parser(record.rdata, packet, record.rdataOffset);
227
+ }
228
+ catch (error) {
229
+ return `[Parse error: ${error.message}]`;
230
+ }
231
+ }
232
+ //# sourceMappingURL=record-parsers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record-parsers.js","sourceRoot":"","sources":["../../../src/utils/record-parsers.ts"],"names":[],"mappings":";;AA2UA,gCAYC;AAtVD,yDAAoD;AAEpD,+CAAgD;AAGhD,MAAM,MAAM,GAAG,CAAC,CAAC;AACjB,MAAM,OAAO,GAAG,CAAC,CAAC;AAClB,MAAM,UAAU,GAAG,CAAC,CAAC;AACrB,MAAM,QAAQ,GAAG,CAAC,CAAC;AACnB,MAAM,QAAQ,GAAG,EAAE,CAAC;AACpB,MAAM,OAAO,GAAG,EAAE,CAAC;AACnB,MAAM,QAAQ,GAAG,EAAE,CAAC;AACpB,MAAM,SAAS,GAAG,EAAE,CAAC;AACrB,MAAM,QAAQ,GAAG,EAAE,CAAC;AACpB,MAAM,UAAU,GAAG,EAAE,CAAC;AACtB,MAA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CAAC,QAAQ,CAAC,EAAE,cAAc;IAC1B,CAAC,WAAW,CAAC,EAAE,iBAAiB;IAChC,CAAC,SAAS,CAAC,EAAE,eAAe;CAC5B,CAAC;AAEF,SAAgB,UAAU,CAAC,MAAyB,EAAE,MAAc;IACnE,MAAM,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAEhD,IAAI,CAAC,MAAM,EAAE,CAAC;QACb,OAAO,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC;IAED,IAAI,CAAC;QACJ,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;IACzD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,OAAO,iBAAkB,KAAe,CAAC,OAAO,GAAG,CAAC;IACrD,CAAC;AACF,CAAC"}
@@ -0,0 +1,40 @@
1
+ export interface SpfMechanism {
2
+ qualifier: string;
3
+ type: string;
4
+ value: string | null;
5
+ }
6
+ export interface SpfParsed {
7
+ type: 'spf';
8
+ version: string;
9
+ mechanisms: SpfMechanism[];
10
+ }
11
+ export interface DmarcParsed {
12
+ type: 'dmarc';
13
+ version: string;
14
+ policy: string;
15
+ subdomainPolicy: string | null;
16
+ percentage: number;
17
+ reportAggregate: string[];
18
+ reportForensic: string[];
19
+ alignmentDkim: string;
20
+ alignmentSpf: string;
21
+ }
22
+ export interface DkimParsed {
23
+ type: 'dkim';
24
+ version: string;
25
+ keyType: string;
26
+ publicKey: string;
27
+ hashAlgorithms: string[];
28
+ serviceTypes: string[];
29
+ flags: string[];
30
+ }
31
+ export interface VerificationParsed {
32
+ type: 'verification';
33
+ provider: string;
34
+ token: string;
35
+ }
36
+ export type TxtParsed = SpfParsed | DmarcParsed | DkimParsed | VerificationParsed;
37
+ export declare function enrichTxtRecord(raw: string): {
38
+ parsed: TxtParsed | null;
39
+ parseError?: string;
40
+ };