{"_id":"@bun-win32/dnsapi","_rev":"5-27cc83177e4984dac56686050699f012","name":"@bun-win32/dnsapi","dist-tags":{"latest":"2.0.1"},"versions":{"1.0.0":{"name":"@bun-win32/dnsapi","version":"1.0.0","keywords":["bun","ffi","win32","windows","dnsapi","dns","resolver","lookup","mx","srv","txt","aaaa","ipv6","bindings","typescript","dll"],"author":"Stev Peifer <stev@bell.net>","license":"MIT","_id":"@bun-win32/dnsapi@1.0.0","maintainers":[{"name":"obscuritysrl","email":"stev@bell.net"}],"homepage":"https://github.com/ObscuritySRL/bun-win32#readme","bugs":{"url":"https://github.com/ObscuritySRL/bun-win32/issues"},"dist":{"shasum":"84c4e4a3fc14784b0d5dea7a8d55daa3b8a17c7f","tarball":"https://registry.npmjs.org/@bun-win32/dnsapi/-/dnsapi-1.0.0.tgz","fileCount":6,"integrity":"sha512-1hEIKV5cjibJ2sY1s+2we9imSrYpnn11SRRjLLOh93rDYB+rO6WjAcFeFiANcp+jlS3ZTZ7MMnGEsC4BDv9fEw==","signatures":[{"sig":"MEQCICHARz6T/Pkqu4Lj7Ex4MeJK/kvbIDcAEGyaGRYelnJpAiAZukEqOK4Dw9bSD2ZEP00rnxHJ0MhMPkjtmtOFIhYrcw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":36769},"main":"./index.ts","type":"module","module":"index.ts","shasum":"84c4e4a3fc14784b0d5dea7a8d55daa3b8a17c7f","engines":{"bun":">=1.1.0"},"exports":{".":"./index.ts"},"private":false,"scripts":{"example:dns-tree":"bun ./example/dns-tree.ts","example:dns-forensics":"bun ./example/dns-forensics.ts"},"_npmUser":{"name":"obscuritysrl","email":"stev@bell.net"},"_integrity":"sha512-1hEIKV5cjibJ2sY1s+2we9imSrYpnn11SRRjLLOh93rDYB+rO6WjAcFeFiANcp+jlS3ZTZ7MMnGEsC4BDv9fEw==","repository":{"url":"git://github.com/ObscuritySRL/bun-win32.git","type":"git","directory":"packages/dnsapi"},"_npmVersion":"10.8.3","description":"Zero-dependency, zero-overhead Win32 DNSAPI bindings for Bun (FFI) on Windows.","directories":{},"sideEffects":false,"_nodeVersion":"24.3.0","dependencies":{"@bun-win32/core":"1.1.2"},"_hasShrinkwrap":false,"devDependencies":{"@types/bun":"latest"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/dnsapi_1.0.0_1778690191124_0.9761637867195647","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@bun-win32/dnsapi","version":"1.0.1","keywords":["bun","ffi","win32","windows","dnsapi","dns","resolver","lookup","mx","srv","txt","aaaa","ipv6","bindings","typescript","dll"],"author":"Stev Peifer <stev@bell.net>","license":"MIT","_id":"@bun-win32/dnsapi@1.0.1","maintainers":[{"name":"obscuritysrl","email":"stev@bell.net"}],"homepage":"https://github.com/ObscuritySRL/bun-win32#readme","bugs":{"url":"https://github.com/ObscuritySRL/bun-win32/issues"},"dist":{"shasum":"7cf8132dbef6a901bd3d4ea09ffa856302d759e2","tarball":"https://registry.npmjs.org/@bun-win32/dnsapi/-/dnsapi-1.0.1.tgz","fileCount":6,"integrity":"sha512-Iro63+g9N3qn7yOO4j6PZDF8wcGcKP5Aspr4dygtzkqBr7TLEVoWdD2FvAmEnYtgqHImfGBGDON733xaA6W1xA==","signatures":[{"sig":"MEYCIQD/y2IZSvV+KeAER0+n2qx00fCtNT7g3moURiiJAKcewgIhALrTdyTcnFtJD5rdLhv8M8azh1HNSLWih2oJsIeeJhgW","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":36776},"main":"./index.ts","type":"module","module":"index.ts","shasum":"7cf8132dbef6a901bd3d4ea09ffa856302d759e2","engines":{"bun":">=1.1.0"},"exports":{".":"./index.ts"},"private":false,"scripts":{"example:dns-tree":"bun ./example/dns-tree.ts","example:dns-forensics":"bun ./example/dns-forensics.ts"},"_npmUser":{"name":"obscuritysrl","email":"stev@bell.net"},"_integrity":"sha512-Iro63+g9N3qn7yOO4j6PZDF8wcGcKP5Aspr4dygtzkqBr7TLEVoWdD2FvAmEnYtgqHImfGBGDON733xaA6W1xA==","repository":{"url":"git://github.com/ObscuritySRL/bun-win32.git","type":"git","directory":"packages/dnsapi"},"_npmVersion":"10.8.3","description":"Zero-dependency, zero-overhead Win32 DNSAPI bindings for Bun (FFI) on Windows.","directories":{},"sideEffects":false,"_nodeVersion":"24.3.0","dependencies":{"@bun-win32/core":"1.1.2"},"_hasShrinkwrap":false,"devDependencies":{"@types/bun":"latest"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/dnsapi_1.0.1_1780581904480_0.7360376131118391","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@bun-win32/dnsapi","version":"1.0.2","keywords":["bun","ffi","win32","windows","dnsapi","dns","resolver","lookup","mx","srv","txt","aaaa","ipv6","bindings","typescript","dll"],"author":"Stev Peifer <stev.p@outlook.com>","license":"MIT","_id":"@bun-win32/dnsapi@1.0.2","maintainers":[{"name":"obscuritysrl","email":"stev@bell.net"}],"homepage":"https://github.com/ObscuritySRL/bun-win32#readme","bugs":{"url":"https://github.com/ObscuritySRL/bun-win32/issues"},"dist":{"shasum":"2834df764b92993f4abf101274aecde2f98ef00e","tarball":"https://registry.npmjs.org/@bun-win32/dnsapi/-/dnsapi-1.0.2.tgz","fileCount":6,"integrity":"sha512-/iH24IKDBWzN83W1m82ghkp/VpUSiTK4fwPE7kdW7ksP6Us/kXxTBg8+y7fJz7A8KsSs5kIYTQgyKsSbDWvCTg==","signatures":[{"sig":"MEMCIDAcFRZZESLcb59DD6gUTlRZ1uRXjC3SugL/yfS1APXVAh92sQiXiVG+3iL8+d8qyh3C0Qoe0Fui6dL7DYoK7KiA","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":36781},"main":"./index.ts","type":"module","module":"index.ts","shasum":"2834df764b92993f4abf101274aecde2f98ef00e","engines":{"bun":">=1.1.0"},"exports":{".":"./index.ts"},"private":false,"scripts":{"example:dns-tree":"bun ./example/dns-tree.ts","example:dns-forensics":"bun ./example/dns-forensics.ts"},"_npmUser":{"name":"obscuritysrl","email":"stev@bell.net"},"_integrity":"sha512-/iH24IKDBWzN83W1m82ghkp/VpUSiTK4fwPE7kdW7ksP6Us/kXxTBg8+y7fJz7A8KsSs5kIYTQgyKsSbDWvCTg==","repository":{"url":"git://github.com/ObscuritySRL/bun-win32.git","type":"git","directory":"packages/dnsapi"},"_npmVersion":"10.8.3","description":"Zero-dependency, zero-overhead Win32 DNSAPI bindings for Bun (FFI) on Windows.","directories":{},"sideEffects":false,"_nodeVersion":"24.3.0","dependencies":{"@bun-win32/core":"1.1.4"},"_hasShrinkwrap":false,"devDependencies":{"@types/bun":"latest"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/dnsapi_1.0.2_1781130820867_0.72871091505688","host":"s3://npm-registry-packages-npm-production"}},"2.0.0":{"name":"@bun-win32/dnsapi","version":"2.0.0","keywords":["bun","ffi","win32","windows","dnsapi","dns","resolver","lookup","mx","srv","txt","aaaa","ipv6","bindings","typescript","dll"],"author":"Stev Peifer <stev.p@outlook.com>","license":"MIT","_id":"@bun-win32/dnsapi@2.0.0","maintainers":[{"name":"obscuritysrl","email":"stev.p@outlook.com"}],"homepage":"https://github.com/ObscuritySRL/bun-win32#readme","bugs":{"url":"https://github.com/ObscuritySRL/bun-win32/issues"},"dist":{"shasum":"82c5f4c5beb06014145a3a744853f542c6a08e73","tarball":"https://registry.npmjs.org/@bun-win32/dnsapi/-/dnsapi-2.0.0.tgz","fileCount":6,"integrity":"sha512-73X5WS+bNuTBexlSriKNMGX6j55nEvYFpvfwJtXd8eC8UUq055CA7FeW6wF3/bqIbjUpuu4m7faLooCj9Uvzlw==","signatures":[{"sig":"MEYCIQDKexwqqJM4o1BTwtKYsxAPCShn6C8ovyqJI1aLrrh8RAIhAOxNmfRtpHHprAbquKwVIcNqq74JCn3R4hAO03X4bIIM","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":38949},"main":"./index.ts","type":"module","module":"index.ts","shasum":"82c5f4c5beb06014145a3a744853f542c6a08e73","engines":{"bun":">=1.1.0"},"exports":{".":"./index.ts"},"private":false,"scripts":{"example:dns-tree":"bun ./example/dns-tree.ts","example:dns-forensics":"bun ./example/dns-forensics.ts"},"_npmUser":{"name":"obscuritysrl","email":"stev.p@outlook.com"},"_integrity":"sha512-73X5WS+bNuTBexlSriKNMGX6j55nEvYFpvfwJtXd8eC8UUq055CA7FeW6wF3/bqIbjUpuu4m7faLooCj9Uvzlw==","repository":{"url":"git://github.com/ObscuritySRL/bun-win32.git","type":"git","directory":"packages/dnsapi"},"_npmVersion":"10.8.3","description":"Zero-dependency, zero-overhead Win32 DNSAPI bindings for Bun (FFI) on Windows.","directories":{},"sideEffects":false,"_nodeVersion":"26.3.0","dependencies":{"@bun-win32/core":"2.0.0"},"_hasShrinkwrap":false,"devDependencies":{"@types/bun":"latest"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/dnsapi_2.0.0_1782435298816_0.6795221103708535","host":"s3://npm-registry-packages-npm-production"}},"2.0.1":{"author":"Stev Peifer <stev.p@outlook.com>","bugs":{"url":"https://github.com/ObscuritySRL/bun-win32/issues"},"dependencies":{"@bun-win32/core":"2.0.1"},"description":"Zero-dependency, zero-overhead Win32 DNSAPI bindings for Bun (FFI) on Windows.","devDependencies":{"@types/bun":"latest"},"exports":{".":"./index.ts"},"license":"MIT","module":"index.ts","name":"@bun-win32/dnsapi","peerDependencies":{"typescript":"^5"},"private":false,"homepage":"https://github.com/ObscuritySRL/bun-win32#readme","repository":{"type":"git","url":"git://github.com/ObscuritySRL/bun-win32.git","directory":"packages/dnsapi"},"type":"module","version":"2.0.1","main":"./index.ts","keywords":["bun","ffi","win32","windows","dnsapi","dns","resolver","lookup","mx","srv","txt","aaaa","ipv6","bindings","typescript","dll"],"sideEffects":false,"engines":{"bun":">=1.1.0"},"scripts":{"example:dns-forensics":"bun ./example/dns-forensics.ts","example:dns-tree":"bun ./example/dns-tree.ts"},"_id":"@bun-win32/dnsapi@2.0.1","_integrity":"sha512-415i53KrvkHx69hs6U879MzTKzeDLlk5swX3jf7p1vXXCaIKaiijKiPsN4hdvjMOs2ntCpnq/gHlzhsdduLKCg==","_nodeVersion":"26.3.0","_npmVersion":"10.8.3","shasum":"a0d48055d05228236c5696ae543cf7d05070a47c","dist":{"integrity":"sha512-415i53KrvkHx69hs6U879MzTKzeDLlk5swX3jf7p1vXXCaIKaiijKiPsN4hdvjMOs2ntCpnq/gHlzhsdduLKCg==","shasum":"a0d48055d05228236c5696ae543cf7d05070a47c","tarball":"https://registry.npmjs.org/@bun-win32/dnsapi/-/dnsapi-2.0.1.tgz","fileCount":6,"unpackedSize":38949,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCICqClDq+L0nxv6cQSyRQl4OweY8VMTFEXzzhsl2aaDd6AiBM5r5LjcxQgz3haA2YJIVuS8WzvdVQnAeL8KaQgr6Aow=="}]},"_npmUser":{"name":"obscuritysrl","email":"stev.p@outlook.com"},"directories":{},"maintainers":[{"name":"obscuritysrl","email":"stev.p@outlook.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/dnsapi_2.0.1_1782437759497_0.26185532129476585"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-13T16:36:30.993Z","modified":"2026-06-26T01:35:59.751Z","1.0.0":"2026-05-13T16:36:31.324Z","1.0.1":"2026-06-04T14:05:04.625Z","1.0.2":"2026-06-10T22:33:41.018Z","2.0.0":"2026-06-26T00:54:58.951Z","2.0.1":"2026-06-26T01:35:59.640Z"},"bugs":{"url":"https://github.com/ObscuritySRL/bun-win32/issues"},"author":"Stev Peifer <stev.p@outlook.com>","license":"MIT","homepage":"https://github.com/ObscuritySRL/bun-win32#readme","keywords":["bun","ffi","win32","windows","dnsapi","dns","resolver","lookup","mx","srv","txt","aaaa","ipv6","bindings","typescript","dll"],"repository":{"type":"git","url":"git://github.com/ObscuritySRL/bun-win32.git","directory":"packages/dnsapi"},"description":"Zero-dependency, zero-overhead Win32 DNSAPI bindings for Bun (FFI) on Windows.","maintainers":[{"name":"obscuritysrl","email":"stev.p@outlook.com"}],"readme":"# @bun-win32/dnsapi\n\nZero-dependency, zero-overhead Win32 Dnsapi bindings for [Bun](https://bun.sh) on Windows.\n\n## Overview\n\n`@bun-win32/dnsapi` exposes the `dnsapi.dll` exports using [Bun](https://bun.sh)'s FFI. It provides a single class, `Dnsapi`, which lazily binds native symbols on first use. You can optionally preload a subset or all symbols up-front via `Preload()`.\n\nThe bindings are strongly typed for a smooth DX in TypeScript.\n\n## Features\n\n- [Bun](https://bun.sh)-first ergonomics on Windows 10/11.\n- Direct FFI to `dnsapi.dll` (DNS queries for every record type, name validation, server discovery, DNS-SD service browsing, mDNS, and async resolution).\n- In-source docs in `structs/Dnsapi.ts` with links to Microsoft Docs.\n- Lazy binding on first call; optional eager preload (`Dnsapi.Preload()`).\n- No wrapper overhead; calls map 1:1 to native APIs.\n- Strongly-typed Win32 aliases (see `types/Dnsapi.ts`).\n\n## Requirements\n\n- [Bun](https://bun.sh) runtime\n- Windows 10 or later\n\n## Installation\n\n```sh\nbun add @bun-win32/dnsapi\n```\n\n## Quick Start\n\n```ts\nimport { read, toArrayBuffer, type Pointer } from 'bun:ffi';\n\nimport Dnsapi, { DnsFreeType, DnsQueryOption, DnsType } from '@bun-win32/dnsapi';\n\n// Query A records for example.com\nconst name = Buffer.from('example.com\\0', 'utf16le');\nconst out = Buffer.alloc(8);\n\nconst status = Dnsapi.DnsQuery_W(name.ptr, DnsType.DNS_TYPE_A, DnsQueryOption.DNS_QUERY_STANDARD, null, out.ptr, null);\n\nif (status !== 0) {\n  throw new Error(`DnsQuery_W failed with status ${status}`);\n}\n\nconst head = read.ptr(out.ptr) as Pointer | null;\nlet cur: Pointer | null = head;\n\nwhile (cur) {\n  // DNS_RECORD header is 32 bytes; DNS_A_DATA places the IPv4 octets at offset 32\n  const buf = Buffer.from(toArrayBuffer(cur, 0, 40));\n  const pNext = Number(buf.readBigUInt64LE(0));\n  const wType = buf.readUInt16LE(16);\n\n  if (wType === DnsType.DNS_TYPE_A) {\n    console.log(`${buf[32]}.${buf[33]}.${buf[34]}.${buf[35]}`);\n  }\n\n  cur = pNext !== 0 ? (pNext as Pointer) : null;\n}\n\nif (head) Dnsapi.DnsRecordListFree(head, DnsFreeType.DnsFreeRecordList);\n```\n\n> [!NOTE]\n> AI agents: see `AI.md` for the package binding contract and source-navigation guidance. It explains how to use the package without scanning the entire implementation.\n\n## Examples\n\nRun the included examples:\n\n```sh\nbun run example:dns-tree\nbun run example:dns-forensics\nbun run example:dns-forensics microsoft.com github.com   # custom targets\n```\n\n## Notes\n\n- Either rely on lazy binding or call `Dnsapi.Preload()`.\n- DNS records returned by `DnsQuery_W`/`DnsQuery_A`/`DnsQuery_UTF8` are a linked list rooted at the pointer written into the `ppQueryResults` out-buffer; release the whole list with `DnsRecordListFree(head, DnsFreeType.DnsFreeRecordList)`.\n- Windows only. Bun runtime required.\n- **SAL types & naming:** nullability is in the **type** — `Optional<T>` (formally optional, SAL `_*opt_`) and `Nullable<T>` (plain `[in]`/`[out]` the docs say can be NULL), the null sentinel derived from `T` (`null` for pointers `LP*`/`P*`, `0n` for handles/by-value addresses); direction is in the **parameter name** — `_out` (`_Out_`), `_in_out` (`_Inout_`), `_In_` bare. See `AI.md` and the repo `AGENTS.md`.\n","readmeFilename":"README.md"}