{"_id":"@bun-win32/ktmw32","_rev":"4-edc0d4da385d3913a83e7ac1cc78ad0e","name":"@bun-win32/ktmw32","dist-tags":{"latest":"2.0.1"},"versions":{"1.0.0":{"name":"@bun-win32/ktmw32","version":"1.0.0","keywords":["bun","ffi","win32","windows","ktmw32","ktm","transaction","txf","bindings","typescript","dll"],"author":"Stev Peifer <stev@bell.net>","license":"MIT","_id":"@bun-win32/ktmw32@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":"776fe9d76703d7dcfb2a6631e05296dea9022e62","tarball":"https://registry.npmjs.org/@bun-win32/ktmw32/-/ktmw32-1.0.0.tgz","fileCount":6,"integrity":"sha512-nyOEyqU4oZqqHymEvEkV71py6HIk/WmWqHtxPYjt0tv+YeWNkHWOQSrwQgd8u6nZZ6il5NwC4K1yJG3K38KgPA==","signatures":[{"sig":"MEUCIQDfqpJzSZnCcAF7ElJzD+bYYQehruDSTUQ2tZZmI/PzbQIgVOQ0RKy+z8+7elEUjPngO1zNKS7p2ziJWQXTDNEbOkw=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":29871},"main":"./index.ts","type":"module","module":"index.ts","shasum":"776fe9d76703d7dcfb2a6631e05296dea9022e62","engines":{"bun":">=1.1.0"},"exports":{".":"./index.ts"},"private":false,"scripts":{"example:atomic-ledger":"bun ./example/atomic-ledger.ts","example:transaction-forensics":"bun ./example/transaction-forensics.ts"},"_npmUser":{"name":"obscuritysrl","email":"stev@bell.net"},"_integrity":"sha512-nyOEyqU4oZqqHymEvEkV71py6HIk/WmWqHtxPYjt0tv+YeWNkHWOQSrwQgd8u6nZZ6il5NwC4K1yJG3K38KgPA==","repository":{"url":"git://github.com/ObscuritySRL/bun-win32.git","type":"git","directory":"packages/ktmw32"},"_npmVersion":"10.8.3","description":"Zero-dependency, zero-overhead Win32 KTMW32 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","@bun-win32/kernel32":"1.0.24"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/ktmw32_1.0.0_1780539753322_0.9581235372632395","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@bun-win32/ktmw32","version":"1.0.1","keywords":["bun","ffi","win32","windows","ktmw32","ktm","transaction","txf","bindings","typescript","dll"],"author":"Stev Peifer <stev@bell.net>","license":"MIT","_id":"@bun-win32/ktmw32@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":"081855605b26f1943ed216bb20fd51890ab275e1","tarball":"https://registry.npmjs.org/@bun-win32/ktmw32/-/ktmw32-1.0.1.tgz","fileCount":6,"integrity":"sha512-IZ15u0hgYnRyXuC+Y4sdQER6CQUTNGrRKZFr8n6n12/Bvf1QR5OrV7rQTmPwDTzh8t9W7Lq/XfR2eFA/2en3Wg==","signatures":[{"sig":"MEUCIBlswobnL7qk4kQQlyYEWMAictg5gv/S9f/QawJLLVUsAiEAkw1G3Hab727fnkMcK8hcD6bJmh8aW6zNVWzTcxKDJXU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":29878},"main":"./index.ts","type":"module","module":"index.ts","shasum":"081855605b26f1943ed216bb20fd51890ab275e1","engines":{"bun":">=1.1.0"},"exports":{".":"./index.ts"},"private":false,"scripts":{"example:atomic-ledger":"bun ./example/atomic-ledger.ts","example:transaction-forensics":"bun ./example/transaction-forensics.ts"},"_npmUser":{"name":"obscuritysrl","email":"stev@bell.net"},"_integrity":"sha512-IZ15u0hgYnRyXuC+Y4sdQER6CQUTNGrRKZFr8n6n12/Bvf1QR5OrV7rQTmPwDTzh8t9W7Lq/XfR2eFA/2en3Wg==","repository":{"url":"git://github.com/ObscuritySRL/bun-win32.git","type":"git","directory":"packages/ktmw32"},"_npmVersion":"10.8.3","description":"Zero-dependency, zero-overhead Win32 KTMW32 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","@bun-win32/kernel32":"1.0.25"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/ktmw32_1.0.1_1780581910682_0.9953159853323639","host":"s3://npm-registry-packages-npm-production"}},"2.0.0":{"name":"@bun-win32/ktmw32","version":"2.0.0","keywords":["bun","ffi","win32","windows","ktmw32","ktm","transaction","txf","bindings","typescript","dll"],"author":"Stev Peifer <stev.p@outlook.com>","license":"MIT","_id":"@bun-win32/ktmw32@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":"f42a8e3569f85087666fd20bed454c69b6d3415c","tarball":"https://registry.npmjs.org/@bun-win32/ktmw32/-/ktmw32-2.0.0.tgz","fileCount":6,"integrity":"sha512-XHE8K7g7ixDNAFcL2IoAGgo32ur3Kp+t5Cj1yCTiS05srfZQ4Euzke3ansj8AAbsY4Hovalw/88603yBYB/WRw==","signatures":[{"sig":"MEQCIFSWiTR+ge2a0381G/DIBD0MVWPgyrhzwPZx1nrc9/8zAiAYfhxau4Ovofi5wNgW/A75QdQAAevw9q0r2e7YsRsF3w==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":31447},"main":"./index.ts","type":"module","module":"index.ts","shasum":"f42a8e3569f85087666fd20bed454c69b6d3415c","engines":{"bun":">=1.1.0"},"exports":{".":"./index.ts"},"private":false,"scripts":{"example:atomic-ledger":"bun ./example/atomic-ledger.ts","example:transaction-forensics":"bun ./example/transaction-forensics.ts"},"_npmUser":{"name":"obscuritysrl","email":"stev.p@outlook.com"},"_integrity":"sha512-XHE8K7g7ixDNAFcL2IoAGgo32ur3Kp+t5Cj1yCTiS05srfZQ4Euzke3ansj8AAbsY4Hovalw/88603yBYB/WRw==","repository":{"url":"git://github.com/ObscuritySRL/bun-win32.git","type":"git","directory":"packages/ktmw32"},"_npmVersion":"10.8.3","description":"Zero-dependency, zero-overhead Win32 KTMW32 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","@bun-win32/kernel32":"2.0.0"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/ktmw32_2.0.0_1782435325373_0.8775806332971259","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 KTMW32 bindings for Bun (FFI) on Windows.","devDependencies":{"@bun-win32/kernel32":"2.0.1","@types/bun":"latest"},"exports":{".":"./index.ts"},"license":"MIT","module":"index.ts","name":"@bun-win32/ktmw32","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/ktmw32"},"type":"module","version":"2.0.1","main":"./index.ts","keywords":["bun","ffi","win32","windows","ktmw32","ktm","transaction","txf","bindings","typescript","dll"],"sideEffects":false,"engines":{"bun":">=1.1.0"},"scripts":{"example:atomic-ledger":"bun ./example/atomic-ledger.ts","example:transaction-forensics":"bun ./example/transaction-forensics.ts"},"_id":"@bun-win32/ktmw32@2.0.1","_integrity":"sha512-XjfBu+xAycScJzBx+jqchkh37F4ltDe4Yewn0WGckmEeuOxKA3P4V1fJgxc1N7wWig3sXTkljjuxu8so6+RDkw==","_nodeVersion":"26.3.0","_npmVersion":"10.8.3","shasum":"0b8454354a1296bc01c988d72b63912e68036015","dist":{"integrity":"sha512-XjfBu+xAycScJzBx+jqchkh37F4ltDe4Yewn0WGckmEeuOxKA3P4V1fJgxc1N7wWig3sXTkljjuxu8so6+RDkw==","shasum":"0b8454354a1296bc01c988d72b63912e68036015","tarball":"https://registry.npmjs.org/@bun-win32/ktmw32/-/ktmw32-2.0.1.tgz","fileCount":6,"unpackedSize":31447,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDtpla3wlUuFTgcXqu6JDNUBRLhHLcBEN4LTaXtQDH++gIhAOOlZrGouUAsG1vaxhFL7UCEUM9IUd5wJaRc3jUz9We2"}]},"_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/ktmw32_2.0.1_1782437789663_0.3997564238185678"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-04T02:22:33.117Z","modified":"2026-06-26T01:36:30.008Z","1.0.0":"2026-06-04T02:22:33.470Z","1.0.1":"2026-06-04T14:05:10.930Z","2.0.0":"2026-06-26T00:55:25.507Z","2.0.1":"2026-06-26T01:36:29.802Z"},"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","ktmw32","ktm","transaction","txf","bindings","typescript","dll"],"repository":{"type":"git","url":"git://github.com/ObscuritySRL/bun-win32.git","directory":"packages/ktmw32"},"description":"Zero-dependency, zero-overhead Win32 KTMW32 bindings for Bun (FFI) on Windows.","maintainers":[{"name":"obscuritysrl","email":"stev.p@outlook.com"}],"readme":"# @bun-win32/ktmw32\n\nZero-dependency, zero-overhead Win32 KTM (Kernel Transaction Manager) bindings for [Bun](https://bun.sh) on Windows.\n\n## Overview\n\n`@bun-win32/ktmw32` exposes the `ktmw32.dll` exports using [Bun](https://bun.sh)'s FFI. It provides a single class, `Ktmw32`, which lazily binds native symbols on first use. You can optionally preload a subset or all symbols up-front via `Preload()`.\n\nThe Kernel Transaction Manager is Windows' built-in distributed-transaction engine. Open a transaction with `CreateTransaction`, enlist work in it — transacted-NTFS files (via `kernel32`'s `CreateFileTransactedW`), the transacted registry, or your own resource manager — then `CommitTransaction` to apply everything atomically and durably, or `RollbackTransaction` to discard the whole batch as if it never happened. The full Transaction-Manager → Resource-Manager → Enlistment object graph, the two-phase-commit verbs, and virtual-clock recovery are all bound.\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 `ktmw32.dll` (transactions, transaction managers, resource managers, enlistments, two-phase commit).\n- In-source docs in `structs/Ktmw32.ts` with links to Microsoft Docs.\n- Lazy binding on first call; optional eager preload (`Ktmw32.Preload()`).\n- No wrapper overhead; calls map 1:1 to native APIs.\n- Strongly-typed Win32 aliases and the full KTM enum set (see `types/Ktmw32.ts`).\n\n## Requirements\n\n- [Bun](https://bun.sh) runtime\n- Windows 10 or later (KTM since Windows Vista / Server 2008)\n\n## Installation\n\n```sh\nbun add @bun-win32/ktmw32\n```\n\n## Quick Start\n\n```ts\nimport Ktmw32, { TransactionOutcome } from '@bun-win32/ktmw32';\nimport Kernel32 from '@bun-win32/kernel32';\n\n// Open a KTM transaction (all-access handle; INVALID_HANDLE_VALUE on failure).\nconst hTx = Ktmw32.CreateTransaction(null, null, 0, 0, 0, 0, null);\n\n// Create/replace a file *inside* the transaction — invisible to outside readers until commit.\nconst path = Buffer.from('C:\\\\Temp\\\\ledger.txt\\0', 'utf16le');\nconst hFile = Kernel32.CreateFileTransactedW(path.ptr, 0x4000_0000 /* GENERIC_WRITE */, 0, null!, 2 /* CREATE_ALWAYS */, 0x80 /* FILE_ATTRIBUTE_NORMAL */, 0n, hTx, null!, null!);\nconst data = Buffer.from('balance=100');\nKernel32.WriteFile(hFile, data.ptr, data.byteLength, Buffer.alloc(4).ptr, null!);\nKernel32.CloseHandle(hFile);\n\n// Inspect the live transaction, then resolve it atomically.\nconst outcome = Buffer.alloc(4);\nKtmw32.GetTransactionInformation(hTx, outcome.ptr, null, null, null, 0, null);\nconsole.log('outcome:', TransactionOutcome[outcome.readUInt32LE(0)]); // TransactionOutcomeUndetermined\n\nKtmw32.CommitTransaction(hTx); // ...or Ktmw32.RollbackTransaction(hTx) to discard everything\nKernel32.CloseHandle(hTx);\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/atomic-ledger.ts\nbun run example/transaction-forensics.ts\n```\n\n## Notes\n\n- Either rely on lazy binding or call `Ktmw32.Preload()`.\n- `CreateTransaction` / `CreateTransactionManager` / `CreateResourceManager` / `CreateEnlistment` / `Open*` return a `HANDLE`; failure is `INVALID_HANDLE_VALUE` (`0xFFFFFFFFFFFFFFFFn`), **not** `0n`. Close every handle with `kernel32`'s `CloseHandle`.\n- Closing the last transaction handle before `CommitTransaction` implicitly rolls the transaction back.\n- After `CreateTransactionManager` / `OpenTransactionManager*` you must call `RecoverTransactionManager` for durable TMs; volatile TMs (`TRANSACTION_MANAGER_VOLATILE`, `LogFileName` = `NULL`) do not perform recovery.\n- A volatile resource manager can live on a durable TM, but a durable RM cannot live on a volatile TM.\n- Every resource manager must register at least `TRANSACTION_NOTIFY_PREPREPARE | PREPARE | COMMIT | ROLLBACK` in its `CreateEnlistment` notification mask.\n- `GetTransactionInformation` returns `BOOL`; the `Outcome` out-param decodes via the `TransactionOutcome` enum.\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"}