npm package: @silentwitness/typescript-sdk
Description: The official TypeScript SDK for the Silent Witness API
Author: Silent Witness
Latest version: 0.1.4

# Silent Witness TypeScript SDK

The official TypeScript SDK for the Silent Witness API. This SDK provides a type-safe, modern interface for interacting with Silent Witness services using Connect-RPC.

## Features

- ✅ **Type-Safe**: Full TypeScript support with generated types from Protocol Buffers
- ✅ **Modern**: Built on Connect-RPC for efficient, modern API communication
- ✅ **Minimal Dependencies**: Only 4 production dependencies for a small bundle size
- ✅ **Secure**: Regular security audits and zero known vulnerabilities
- ✅ **Easy to Use**: Simple, intuitive API design

## Installation

Install using your preferred package manager:

```bash
# npm
npm install @silentwitness/typescript-sdk

# pnpm
pnpm add @silentwitness/typescript-sdk

# bun
bun add @silentwitness/typescript-sdk

# yarn
yarn add @silentwitness/typescript-sdk
```

## Quick Start

```typescript
import { createPromiseClient } from "@connectrpc/connect";
import { createConnectTransport } from "@connectrpc/connect-node";
import { CaseService } from "@silentwitness/typescript-sdk/v1/case_connect";

// Create transport with your API endpoint and key
const transport = createConnectTransport({
  baseUrl: "https://core.silentwitness.ai:50051",
  httpVersion: "2",
  interceptors: [
    (next) => async (req) => {
      req.header.set("Authorization", `Bearer ${process.env.SW_API_KEY}`);
      return await next(req);
    },
  ],
});

// Create client for the service
const client = createPromiseClient(CaseService, transport);

// Use the client
const response = await client.createCase({
  name: "My Case",
  description: "Case description",
});

console.log("Created case:", response.case?.id);
```

## Available Services

The SDK provides clients for the following services:

- **CaseService**: Manage cases for organizing files and analyses
- **CrashAnalysisService**: Perform crash analysis operations
- **FileService**: Upload and manage files
- **OrganizationService**: Manage organization settings

## Usage Examples

### Creating a Case

```typescript
const caseResponse = await client.createCase({
  name: "Vehicle Accident Case #123",
  description: "Analysis for insurance claim",
});
```

### Listing Cases

```typescript
const cases = await client.listCases({
  pageSize: 10,
  pageToken: "",
});

for (const case of cases.cases) {
  console.log(`Case: ${case.name} (${case.id})`);
}
```

### Working with Files

```typescript
import { FileService } from "@silentwitness/typescript-sdk/v1/file_connect";

const fileClient = createPromiseClient(FileService, transport);

// Upload a file
const uploadResponse = await fileClient.uploadFile({
  caseId: "case-id-here",
  filename: "accident-report.pdf",
  content: fileBuffer,
});
```

## Authentication

The SDK requires an API key for authentication. Set your API key as an environment variable:

```bash
export SW_API_KEY="your-api-key-here"
```

**Security Best Practice**: Never hardcode API keys in your source code. Always use environment variables or secure credential management systems.

## Security

### Security Status

- ✅ **Zero known vulnerabilities** (as of latest audit)
- ✅ **Minimal dependencies**: Only 4 production dependencies
- ✅ **Trusted sources**: All dependencies from @connectrpc and @bufbuild

### Running Security Checks

To verify the security status of this SDK, run from the **project root directory**:

```bash
cd /path/to/core
make security-check
```

This command will:
- Run vulnerability scans using `npm audit`
- Check for outdated dependencies with `npm outdated`

### Reporting Security Issues

If you discover a security vulnerability, please see our [Security Policy](./SECURITY.md) for responsible disclosure guidelines.

## Development

### Build

```bash
bun run build
```

### Watch Mode

```bash
bun run dev
```

### Format Code

```bash
bun run format
```

### Lint

```bash
bun run lint
```

## Requirements

- Node.js 18+ or Bun 1.0+
- TypeScript 5.0+

## Dependencies

This SDK maintains a minimal dependency footprint:

### Production Dependencies (4)
- `@connectrpc/connect` - Connect RPC core
- `@connectrpc/connect-web` - Browser support
- `@connectrpc/connect-node` - Node.js support
- `@bufbuild/protobuf` - Protocol Buffer runtime

All dependencies are from trusted, actively maintained sources.

## Support

- **Documentation**: [Full API Documentation](https://docs.silentwitness.com)
- **Issues**: [GitHub Issues](https://github.com/silentwitnessai/typescript-sdk/issues)
- **Security**: See [SECURITY.md](./SECURITY.md)

## License

MIT

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

---

**Made with ❤️ by Silent Witness**