🦀 SMB/Samba for TypeScript, powered by a bundled Rust engine. `@push.rocks/smartsamba` gives Node.js projects a clean TypeScript API for running an SMB server, connecting to SMB shares, and doing real file operations without shelling out to `smbd` or `smbclient`.
## Issue Reporting and Security
For reporting bugs, issues, or security vulnerabilities, please visit [community.foss.global/](https://community.foss.global/). This is the central community hub for all issue reporting. Developers who sign and comply with our contribution agreement and go through identification can also get a [code.foss.global/](https://code.foss.global/) account to submit Pull Requests directly.
## What It Does
`smartsamba` is for code that needs SMB/CIFS behavior directly from TypeScript:
- Start an embedded SMB server that exposes local folders as shares.
- Connect to existing SMB servers with username, password, and optional domain credentials.
- List shares and directories.
- Read and write files as `Buffer` or string data.
Use `port: 0` for tests and local tooling when you want the OS to choose a free port. Use a fixed port when you need a predictable endpoint.
## Architecture
The TypeScript layer talks to a bundled `rustsamba` binary through `@push.rocks/smartrust`. The Rust side implements the SMB engine and exposes a small JSON-lines management protocol to the TypeScript API.
That means:
- No dependency on system `smbd`.
- No dependency on system `smbclient`.
- No fragile shell parsing.
- The same TypeScript API controls both client and server operations.
- The native helper can be overridden with `SMARTSAMBA_RUST_BINARY` for debugging or custom builds.
During development, `@git.zone/tsrust` builds the Rust binary and places it in `dist_rust/`. Published packages include the built Rust artifact.
By default, `SambaServer` listens on `127.0.0.1:445`. Passing `port: 0` lets the OS assign a free port. Share folders are created automatically unless `createIfMissing: false` is set.
## API Reference
### `SambaClient`
```ts
constclient=newSambaClient(options);
```
Client options:
| Option | Type | Description |
| --- | --- | --- |
| `host` | `string` | SMB server hostname or IP address. |
| `port` | `number` | SMB TCP port. Defaults to the Rust client's SMB default when omitted. |
| `auth.username` | `string` | Username for NTLM authentication. |
| `auth.password` | `string` | Password for NTLM authentication. |
| `rust/target/release/rustsamba` | Local release build fallback. |
| `rust/target/debug/rustsamba` | Local debug build fallback. |
If no helper can be started, operations throw an error asking you to run the build or test preparation step.
## Development
```sh
pnpm install
pnpm test
pnpm run build
```
`pnpm test` builds the Rust helper first, then runs the Node.js integration test. The test starts a local SMB server, writes a file through the SMB client, reads it back, lists the share, stats the file, renames it, and deletes it.
## Operational Notes
- Binding to port `445` may require elevated privileges on some systems. Use `port: 0` or a high port for development and tests.
-`SambaServer` manages one embedded server per instance.
- Call `stop()` in `finally` blocks to cleanly shut down bridge processes.
-`rust/target/`, `node_modules/`, `dist_ts/`, and `dist_rust/` are build artifacts or generated outputs and are not source history.
## License and Legal Information
This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [license](./license) file.
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
### Trademarks
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH or third parties, and are not included within the scope of the MIT license granted herein.
Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines or the guidelines of the respective third-party owners, and any usage must be approved in writing. Third-party trademarks used herein are the property of their respective owners and used only in a descriptive manner, e.g. for an implementation of an API or similar.
### Company Information
Task Venture Capital GmbH
Registered at District Court Bremen HRB 35230 HB, Germany
For any legal inquiries or further information, please contact us via email at hello@task.vc.
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.