{"_id":"@bun-win32/winhttp","_rev":"4-a2217b205ebf6bd2dca019f0da8b85a0","name":"@bun-win32/winhttp","dist-tags":{"latest":"2.0.1"},"versions":{"1.0.0":{"name":"@bun-win32/winhttp","version":"1.0.0","keywords":["bun","ffi","win32","windows","winhttp","bindings","typescript","dll"],"author":"Stev Peifer <stev@bell.net>","license":"MIT","_id":"@bun-win32/winhttp@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":"87f088665eaa4f4bbf63e5c56a22e779457158e2","tarball":"https://registry.npmjs.org/@bun-win32/winhttp/-/winhttp-1.0.0.tgz","fileCount":6,"integrity":"sha512-CIbZfn2KGikdYR0IBc8Sm7exxpn9B3y1Kn3y93Vbv+ViFGwcw0mXM5N3Y1NYD0hHnZQcpWomlFtgRJxLiO/8vg==","signatures":[{"sig":"MEQCIHedVl2aNTNIrAWxIDzFCeOn8E8PSn5hjP17lfher1KwAiBx+WGN5LMyR5FCfyKQDpsrS8XjVTrXcSdseZDa7d9gRQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":45453},"main":"./index.ts","type":"module","module":"index.ts","shasum":"87f088665eaa4f4bbf63e5c56a22e779457158e2","engines":{"bun":">=1.1.0"},"exports":{".":"./index.ts"},"private":false,"scripts":{"example:url-radar":"bun ./example/url-radar.ts","example:request-inspector":"bun ./example/request-inspector.ts"},"_npmUser":{"name":"obscuritysrl","email":"stev@bell.net"},"_integrity":"sha512-CIbZfn2KGikdYR0IBc8Sm7exxpn9B3y1Kn3y93Vbv+ViFGwcw0mXM5N3Y1NYD0hHnZQcpWomlFtgRJxLiO/8vg==","repository":{"url":"git://github.com/ObscuritySRL/bun-win32.git","type":"git","directory":"packages/winhttp"},"_npmVersion":"10.8.3","description":"Zero-dependency, zero-overhead Win32 WINHTTP 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/winhttp_1.0.0_1778689590217_0.3136294898006957","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@bun-win32/winhttp","version":"1.0.1","keywords":["bun","ffi","win32","windows","winhttp","bindings","typescript","dll"],"author":"Stev Peifer <stev@bell.net>","license":"MIT","_id":"@bun-win32/winhttp@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":"7ad9a5432823634bd0cb8a67bb3f64a30e37ed09","tarball":"https://registry.npmjs.org/@bun-win32/winhttp/-/winhttp-1.0.1.tgz","fileCount":6,"integrity":"sha512-9ebPWjm6CL3CAinzKKHHLgTKkfjtBKISoRdxCBwZNWwve7JHzdIQewFID6SPVnqGTTIJPxvCRYOcZG/Vdw0bSw==","signatures":[{"sig":"MEUCIQCK0VR1MZtn7pr/8ZkXuPIGSh4KTe7tV1J+hnZPn3V7igIgIdsH4oHSL5ki6SXfzKPk7zvdHfHDENJGLXMemL0LlpU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":45467},"main":"./index.ts","type":"module","module":"index.ts","shasum":"7ad9a5432823634bd0cb8a67bb3f64a30e37ed09","engines":{"bun":">=1.1.0"},"exports":{".":"./index.ts"},"private":false,"scripts":{"example:url-radar":"bun ./example/url-radar.ts","example:request-inspector":"bun ./example/request-inspector.ts"},"_npmUser":{"name":"obscuritysrl","email":"stev@bell.net"},"_integrity":"sha512-9ebPWjm6CL3CAinzKKHHLgTKkfjtBKISoRdxCBwZNWwve7JHzdIQewFID6SPVnqGTTIJPxvCRYOcZG/Vdw0bSw==","repository":{"url":"git://github.com/ObscuritySRL/bun-win32.git","type":"git","directory":"packages/winhttp"},"_npmVersion":"10.8.3","description":"Zero-dependency, zero-overhead Win32 WINHTTP 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/winhttp_1.0.1_1780581928951_0.7605746968797211","host":"s3://npm-registry-packages-npm-production"}},"2.0.0":{"name":"@bun-win32/winhttp","version":"2.0.0","keywords":["bun","ffi","win32","windows","winhttp","bindings","typescript","dll"],"author":"Stev Peifer <stev.p@outlook.com>","license":"MIT","_id":"@bun-win32/winhttp@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":"6914be95808dba3093e6326b331537a723270529","tarball":"https://registry.npmjs.org/@bun-win32/winhttp/-/winhttp-2.0.0.tgz","fileCount":6,"integrity":"sha512-r/GDJKuMUxKs4C+Wq/Qrnl+AD7dFiTGNAQn2UI2H/bba9cjRQLeBQ/YtwHcycRkkbqHIsQAM1c9VdJc/rylW4A==","signatures":[{"sig":"MEUCIHhFT9NO/rCRY1huU6IQpleRK7OMq/8g3i2Q4IPXGqmdAiEA04Sk+YenooA8xYVMqe8x+ni77L+Zmb3jJWUjkiwRV5I=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":47334},"main":"./index.ts","type":"module","module":"index.ts","shasum":"6914be95808dba3093e6326b331537a723270529","engines":{"bun":">=1.1.0"},"exports":{".":"./index.ts"},"private":false,"scripts":{"example:url-radar":"bun ./example/url-radar.ts","example:request-inspector":"bun ./example/request-inspector.ts"},"_npmUser":{"name":"obscuritysrl","email":"stev.p@outlook.com"},"_integrity":"sha512-r/GDJKuMUxKs4C+Wq/Qrnl+AD7dFiTGNAQn2UI2H/bba9cjRQLeBQ/YtwHcycRkkbqHIsQAM1c9VdJc/rylW4A==","repository":{"url":"git://github.com/ObscuritySRL/bun-win32.git","type":"git","directory":"packages/winhttp"},"_npmVersion":"10.8.3","description":"Zero-dependency, zero-overhead Win32 WINHTTP 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/winhttp_2.0.0_1782435991774_0.7137228802141855","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 WINHTTP bindings for Bun (FFI) on Windows.","devDependencies":{"@types/bun":"latest"},"exports":{".":"./index.ts"},"license":"MIT","module":"index.ts","name":"@bun-win32/winhttp","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/winhttp"},"type":"module","version":"2.0.1","main":"./index.ts","keywords":["bun","ffi","win32","windows","winhttp","bindings","typescript","dll"],"sideEffects":false,"engines":{"bun":">=1.1.0"},"scripts":{"example:request-inspector":"bun ./example/request-inspector.ts","example:url-radar":"bun ./example/url-radar.ts"},"_id":"@bun-win32/winhttp@2.0.1","_integrity":"sha512-iTNt/qQ2qpFfdqSHIYSy7fhjqmXHo7211hnA99OsQWynT+I9PY1swn6YTV4qvusUYwGOIrYsxgWXZbnoIoWSPg==","_nodeVersion":"26.3.0","_npmVersion":"10.8.3","shasum":"86e929252f084dda513a882b250d54215fae8979","dist":{"integrity":"sha512-iTNt/qQ2qpFfdqSHIYSy7fhjqmXHo7211hnA99OsQWynT+I9PY1swn6YTV4qvusUYwGOIrYsxgWXZbnoIoWSPg==","shasum":"86e929252f084dda513a882b250d54215fae8979","tarball":"https://registry.npmjs.org/@bun-win32/winhttp/-/winhttp-2.0.1.tgz","fileCount":6,"unpackedSize":47334,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIHX0AhwGamQw+vGLhn6IkGtZ67vdnypCWBtji3JOoMaxAiEAoXxP2p2b8q2RJuwf7R9HwrBaU+sBU1E/IdM4SkA+GjM="}]},"_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/winhttp_2.0.1_1782438217203_0.3852363475430982"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-13T16:26:30.078Z","modified":"2026-06-26T01:43:37.448Z","1.0.0":"2026-05-13T16:26:30.378Z","1.0.1":"2026-06-04T14:05:29.079Z","2.0.0":"2026-06-26T01:06:31.921Z","2.0.1":"2026-06-26T01:43:37.331Z"},"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","winhttp","bindings","typescript","dll"],"repository":{"type":"git","url":"git://github.com/ObscuritySRL/bun-win32.git","directory":"packages/winhttp"},"description":"Zero-dependency, zero-overhead Win32 WINHTTP bindings for Bun (FFI) on Windows.","maintainers":[{"name":"obscuritysrl","email":"stev.p@outlook.com"}],"readme":"# @bun-win32/winhttp\n\nZero-dependency, zero-overhead Win32 WinHTTP bindings for [Bun](https://bun.sh) on Windows.\n\n## Overview\n\n`@bun-win32/winhttp` exposes the `winhttp.dll` exports using [Bun](https://bun.sh)'s FFI. It provides a single class, `Winhttp`, 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 `winhttp.dll` (HTTP/HTTPS client, WebSockets, proxy auto-detect, PAC discovery, TLS configuration, and request tracing).\n- In-source docs in `structs/Winhttp.ts` with links to Microsoft Docs.\n- Lazy binding on first call; optional eager preload (`Winhttp.Preload()`).\n- No wrapper overhead; calls map 1:1 to native APIs.\n- Strongly-typed Win32 aliases (see `types/Winhttp.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/winhttp\n```\n\n## Quick Start\n\n```ts\nimport Winhttp, { WinHttpAccessType, WinHttpFlag, WinHttpQuery } from '@bun-win32/winhttp';\n\nWinhttp.Preload(['WinHttpOpen', 'WinHttpConnect', 'WinHttpOpenRequest', 'WinHttpSendRequest', 'WinHttpReceiveResponse', 'WinHttpQueryHeaders', 'WinHttpReadData', 'WinHttpCloseHandle']);\n\nconst agent = Buffer.from('bun-win32/1.0\\0', 'utf16le');\nconst hSession = Winhttp.WinHttpOpen(agent.ptr, WinHttpAccessType.AUTOMATIC_PROXY, null, null, 0);\n\nconst host = Buffer.from('learn.microsoft.com\\0', 'utf16le');\nconst hConnect = Winhttp.WinHttpConnect(hSession, host.ptr, 443, 0);\n\nconst path = Buffer.from('/en-us/windows/win32/winhttp/about-winhttp\\0', 'utf16le');\nconst hRequest = Winhttp.WinHttpOpenRequest(hConnect, null, path.ptr, null, null, null, WinHttpFlag.SECURE);\n\nWinhttp.WinHttpSendRequest(hRequest, null, 0, null, 0, 0, 0n);\nWinhttp.WinHttpReceiveResponse(hRequest, null);\n\n// Read the HTTP status code as a number.\nconst statusBuf = Buffer.alloc(4);\nconst lenBuf = Buffer.alloc(4);\nlenBuf.writeUInt32LE(4, 0);\nWinhttp.WinHttpQueryHeaders(hRequest, WinHttpQuery.STATUS_CODE | 0x2000_0000 /* FLAG_NUMBER */, null, statusBuf.ptr, lenBuf.ptr, null);\nconsole.log('Status:', statusBuf.readUInt32LE(0));\n\nWinhttp.WinHttpCloseHandle(hRequest);\nWinhttp.WinHttpCloseHandle(hConnect);\nWinhttp.WinHttpCloseHandle(hSession);\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:url-radar\nbun run example:request-inspector\n```\n\n## Notes\n\n- Either rely on lazy binding or call `Winhttp.Preload()`.\n- Windows only. Bun runtime required.\n- Handles returned by `WinHttpOpen`, `WinHttpConnect`, and `WinHttpOpenRequest` are `HINTERNET` (`bigint`). Always close them with `WinHttpCloseHandle`.\n- Strings are UTF-16LE (`LPCWSTR`); allocate them with `Buffer.from('...\\0', 'utf16le')` and pass `.ptr`.\n- WebSocket support requires Windows 8+ and uses `WinHttpWebSocketCompleteUpgrade` after a request opened with `WinHttpSetOption(..., WINHTTP_OPTION_UPGRADE_TO_WEB_SOCKET, ...)`.\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"}